24class Text :
public Node {
28 void ComputeRequirement()
override {
30 requirement_.min_y = 1;
31 has_selection =
false;
34 void Select(Selection&
selection)
override {
51 if (selection_start_ <= x && x <= selection_end_) {
56 selection.AddPart(
ss.str(), box_.y_min, selection_start_, selection_end_);
61 const int y = box_.y_min;
78 if ((x >= selection_start_) && (x <= selection_end_)) {
89 bool has_selection =
false;
90 int selection_start_ = 0;
91 int selection_end_ = -1;
94class VText :
public Node {
96 explicit VText(std::string
text)
99 void ComputeRequirement()
override {
100 requirement_.min_x = width_;
105 const int x = box_.x_min;
107 if (x + width_ - 1 > box_.x_max) {
111 if (y > box_.y_max) {
114 screen.PixelAt(x, y).character =
it;
142 return std::make_shared<Text>(std::move(
text));
191 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