23class Text :
public Node {
27 void ComputeRequirement()
override {
29 requirement_.min_y = 1;
30 has_selection =
false;
33 void Select(Selection& selection)
override {
50 if (selection_start_ <= x && x <= selection_end_) {
55 selection.AddPart(
ss.str(), box_.y_min, selection_start_, selection_end_);
60 const int y = box_.y_min;
77 if ((x >= selection_start_) && (x <= selection_end_)) {
88 bool has_selection =
false;
89 int selection_start_ = 0;
90 int selection_end_ = -1;
93class VText :
public Node {
95 explicit VText(std::string
text)
98 void ComputeRequirement()
override {
99 requirement_.min_x = width_;
104 const int x = box_.x_min;
106 if (x + width_ - 1 > box_.x_max) {
110 if (y > box_.y_max) {
113 screen.PixelAt(x, y).character =
it;
141 return std::make_shared<Text>(std::move(
text));
190 return std::make_shared<VText>(std::move(
text));
A rectangular grid of Pixel.
std::shared_ptr< Node > Element
std::shared_ptr< T > Make(Args &&... args)
std::vector< std::string > Utf8ToGlyphs(const std::string &input)
int string_width(const std::string &)
std::string to_string(const std::wstring &s)
Convert a UTF8 std::string into a std::wstring.
Element text(std::wstring text)
Display a piece of unicode text.
Element vtext(std::wstring text)
Display a piece unicode text vertically.
void Render(Screen &screen, const Element &element)
Display an element on a ftxui::Screen.
static auto Intersection(Box a, Box b) -> Box