Remove Ref<XxxOption> and add new interfaces. (#686)

1. Stop taking Ref<XxxOption> in Component constructors. Instead, use
   the XxxOption directly. Passing by copy avoid problems developers had
   where one was shared in between multiple component, causing issues.

2. Add variants of most component constructors taking a struct only.

This replaces:
https://github.com/ArthurSonzogni/FTXUI/pull/670

This fixes:
https://github.com/ArthurSonzogni/FTXUI/issues/426
This commit is contained in:
Arthur Sonzogni
2023-06-25 17:22:05 +02:00
committed by GitHub
parent e73e7f0d68
commit 455998d759
26 changed files with 918 additions and 693 deletions

View File

@@ -7,22 +7,17 @@
#include "ftxui/screen/string.hpp"
#include <stddef.h> // for size_t
#include <array> // for array
#include <cstdint> // for uint32_t, uint8_t, uint16_t, int32_t
#include <string> // for string, basic_string, wstring
#include <tuple> // for _Swallow_assign, ignore
#include <array> // for array
#include <cstddef> // for size_t
#include <cstdint> // for uint32_t, uint8_t, uint16_t, int32_t
#include <string> // for string, basic_string, wstring
#include <tuple> // for _Swallow_assign, ignore
#include "ftxui/screen/deprecated.hpp" // for wchar_width, wstring_width
#include "ftxui/screen/string_internal.hpp" // for WordBreakProperty, EatCodePoint, CodepointToWordBreakProperty, GlyphCount, GlyphIterate, GlyphNext, GlyphPrevious, IsCombining, IsControl, IsFullWidth, Utf8ToWordBreakProperty
namespace {
using ftxui::EatCodePoint;
using ftxui::IsCombining;
using ftxui::IsControl;
using ftxui::IsFullWidth;
struct Interval {
uint32_t first;
uint32_t last;
@@ -1565,8 +1560,9 @@ bool IsControl(uint32_t ucs) {
if (ucs == 0) {
return true;
}
if (ucs < 32) { // NOLINT
return ucs != 10; // 10 => Line feed.
if (ucs < 32) { // NOLINT
const uint32_t LINE_FEED = 10;
return ucs != LINE_FEED;
}
if (ucs >= 0x7f && ucs < 0xa0) { // NOLINT
return true;