24class Text :
public Node {
26 explicit Text(std::string text) : text_(std::move(text)) {}
28 void ComputeRequirement()
override {
30 requirement_.min_y = 1;
31 has_selection =
false;
34 void Select(Selection& selection)
override {
39 const Selection selection_saturated = selection.SaturateHorizontal(box_);
42 selection_start_ = selection_saturated.GetBox().x_min;
43 selection_end_ = selection_saturated.GetBox().x_max;
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;
74 screen.PixelAt(x, y).character = cell;
77 auto selectionTransform =
screen.GetSelectionStyle();
78 if ((x >= selection_start_) && (x <= selection_end_)) {
79 selectionTransform(
screen.PixelAt(x, y));
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)
97 : text_(std::move(text)), width_{std::min(string_width(text_), 1)} {}
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));
161 return std::make_shared<Text>(
to_string(text));
191 return std::make_shared<VText>(std::move(text));
221 return std::make_shared<VText>(
to_string(text));
Element text(std::wstring text)
Affiche un morceau de texte unicode.
Element vtext(std::wstring text)
Affiche un morceau de texte unicode verticalement.
static auto Intersection(Box a, Box b) -> Box
Une grille rectangulaire de pixels.
L'espace de noms FTXUI ftxui::
std::shared_ptr< Node > Element
std::vector< std::string > Utf8ToGlyphs(const std::string &input)
int string_width(const std::string &)
std::string to_string(const std::wstring &s)
Convertit un std::wstring en un std::string UTF8.
void Render(Screen &screen, const Element &element)