1.10
text.h
1/*
2 * Copyright (C) 2018 Microchip Technology Inc. All rights reserved.
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6#ifndef EGT_TEXT_H
7#define EGT_TEXT_H
8
14#include <egt/canvas.h>
15#include <egt/detail/meta.h>
16#include <egt/flags.h>
17#include <egt/font.h>
18#include <egt/image.h>
19#include <egt/slider.h>
20#include <egt/textwidget.h>
21#include <egt/timer.h>
22#include <egt/types.h>
23#include <list>
24#include <memory>
25#include <string>
26#include <vector>
27
28namespace egt
29{
30inline namespace v1
31{
32
33
35{
36public:
37
39 enum class TextRectFlag : uint32_t
40 {
43
45 eonel = detail::bit(1),
46
48 bol = detail::bit(2),
49 };
50
53
54 TextRect(uint32_t behave,
55 const Rect& rect,
56 std::string text,
57 const cairo_text_extents_t& te,
58 const TextRectFlags& flags = {}) noexcept
59 : m_text(std::move(text)),
60 m_rect(rect),
61 m_text_rect_flags(flags),
62 m_behave(behave),
63 m_te(te)
64 {}
65
66 const std::string& text(void) const { return m_text; }
67 const Rect& rect(void) const { return m_rect; }
68 void rect(const Rect& r) { m_rect = r; }
69 void point(const Point& p) { m_rect.point(p); }
70 const TextRectFlags& flags(void) const { return m_text_rect_flags; }
71 uint32_t behave(void) const { return m_behave; }
72 const cairo_text_extents_t& text_extents(void) const { return m_te; }
73 void select(void) { m_text_rect_flags.set(TextRectFlag::selected); }
74 void deselect(void) { m_text_rect_flags.clear(TextRectFlag::selected); }
75 bool is_selected(void) const { return m_text_rect_flags.is_set(TextRectFlag::selected); }
76 bool end_of_non_empty_line(void) const { return m_text_rect_flags.is_set(TextRectFlag::eonel); }
77 void mark_beginning_of_line(void) { m_text_rect_flags.set(TextRectFlag::bol); }
78 bool beginning_of_line(void) const { return m_text_rect_flags.is_set(TextRectFlag::bol); }
79
80 bool can_consolidate(const TextRect& r) const noexcept
81 {
82 return ((m_text_rect_flags == r.m_text_rect_flags) &&
83 (m_rect.y() == r.m_rect.y()) &&
84 (m_rect.height() == r.m_rect.height()) &&
85 ((m_rect.x() + m_rect.width()) == r.m_rect.x()) &&
86 (r.m_text != "\n"));
87 }
88
89 size_t length(void) const noexcept;
90 TextRect& consolidate(const TextRect& r, cairo_t* cr) noexcept;
91 TextRect split(size_t pos, cairo_t* cr) noexcept;
92
93private:
94
96 std::string m_text;
97
99 Rect m_rect;
100
102 TextRectFlags m_text_rect_flags{};
103
105 uint32_t m_behave{0};
106
108 cairo_text_extents_t m_te;
109};
110
111using TextRects = std::list<TextRect>;
112
133class EGT_API TextBox : public TextWidget
134{
135public:
136
138 enum class TextFlag : uint32_t
139 {
141 fit_to_width = detail::bit(0),
142
144 multiline = detail::bit(1),
145
147 word_wrap = detail::bit(2),
148
150 no_virt_keyboard = detail::bit(3),
151
153 horizontal_scrollable = detail::bit(4),
154
156 vertical_scrollable = detail::bit(5),
157 };
158
161
166 using ValidatorCallback = std::function<bool(const std::string&)>;
167
171 static void default_text_align(const AlignFlags& align);
172
178 explicit TextBox(const std::string& text = {},
179 const AlignFlags& text_align = default_text_align(),
180 const TextFlags& flags = {}) noexcept;
181
187 explicit TextBox(const std::string& text,
188 const TextFlags& flags,
189 const AlignFlags& text_align = default_text_align()) noexcept;
190
197 TextBox(const std::string& text,
198 const Rect& rect,
199 const AlignFlags& text_align = default_text_align(),
200 const TextFlags& flags = {}) noexcept;
201
208 explicit TextBox(Frame& parent,
209 const std::string& text = {},
210 const AlignFlags& text_align = default_text_align(),
211 const TextFlags& flags = {}) noexcept;
212
220 TextBox(Frame& parent,
221 const std::string& text,
222 const Rect& rect,
223 const AlignFlags& text_align = default_text_align(),
224 const TextFlags& flags = {}) noexcept;
225
229 explicit TextBox(Serializer::Properties& props) noexcept
230 : TextBox(props, false)
231 {
232 }
233
234protected:
235
236 explicit TextBox(Serializer::Properties& props, bool is_derived) noexcept;
237
238public:
239
240 TextBox(const TextBox&) = delete;
241 TextBox& operator=(const TextBox&) = delete;
242 TextBox(TextBox&&) = default;
243 TextBox& operator=(TextBox&&) = default;
244
245 void handle(Event& event) override;
246
247 void draw(Painter& painter, const Rect& rect) override;
248
249 void resize(const Size& size) override;
250
251 using TextWidget::text;
252
253 void text(const std::string& str) override;
254
255 void clear() override;
256
257 using TextWidget::min_size_hint;
258
259 EGT_NODISCARD Size min_size_hint() const override;
260
266 void max_length(size_t len);
267
271 EGT_NODISCARD size_t max_length() const { return m_max_len;}
272
278 void text_flags(const TextFlags& text_flags)
279 {
280 if (detail::change_if_diff<>(m_text_flags, text_flags))
281 {
282 resize_sliders();
283 damage();
284 }
285 }
286
290 EGT_NODISCARD const TextFlags& text_flags() const { return m_text_flags; }
291
303 size_t append(const std::string& str);
304
311 size_t insert(const std::string& str);
312
316 EGT_NODISCARD size_t cursor() const;
317
322
327
334 void cursor_forward(size_t count = 1);
335
342 void cursor_backward(size_t count = 1);
343
349 void cursor_set(size_t pos);
350
355
362 void selection(size_t pos, size_t length);
363
371 void selection_forward(size_t count = 1);
372
380 void selection_backward(size_t count = 1);
381
391 void selection_move(size_t count, bool save_column = true);
392
398 EGT_NODISCARD size_t selection_cursor();
399
403 EGT_NODISCARD size_t selection_start() const
404 {
405 return m_select_start;
406 }
407
411 EGT_NODISCARD size_t selection_length() const
412 {
413 return m_select_len;
414 }
415
423
429 EGT_NODISCARD std::string selected_text() const;
430
435
442 void input_validation_enabled(bool enabled);
443
453
457 EGT_NODISCARD Point text_offset() const;
458
462 void text_offset(const Point& p);
463
464 void serialize(Serializer& serializer) const override;
465
466 ~TextBox() noexcept override;
467
468protected:
469
470 bool internal_drag() const override { return true; }
471
473 EGT_NODISCARD Rect text_boundaries() const;
474
476 EGT_NODISCARD Rect text_rect() const;
477
479 using TextWidget::text_size;
480 EGT_NODISCARD Size text_size() const;
481
484
486 using ValidatorCallbackArray = std::vector<ValidatorCallback>;
487
490
493
496
498 void cursor_set(size_t pos, bool save_column);
499
501 void change_cursor(size_t pos, bool save_column = true);
502
504 size_t point2pos(const Point& p) const;
505
507 size_t beginning_of_line(size_t cursor_pos) const;
508
510 size_t beginning_of_line() const { return beginning_of_line(m_cursor_pos); }
511
513 size_t end_of_line(size_t cursor_pos) const;
514
516 size_t end_of_line() const { return end_of_line(m_cursor_pos); }
517
519 size_t up(size_t cursor_pos) const;
520
522 size_t up() const { return up(m_cursor_pos); }
523
525 size_t down(size_t cursor_pos) const;
526
528 size_t down() const { return down(m_cursor_pos); }
529
531 virtual void handle_key(const Key& key);
532
534 bool validate_input(const std::string& str);
535
538
540 cairo_t* context() const { return m_cr; }
541
543 void tokenize(TextRects& rects);
544
547
549 void consolidate(TextRects& rects);
550
553
561
566 static void get_line(const TextRects& rects,
567 TextRects::iterator& pos,
568 std::string& line,
569 Rect& rect);
570
572 static std::string longest_prefix(const std::string& s1, const std::string& s2);
573
575 static std::string longest_suffix(const std::string& s1, const std::string& s2);
576
579 TextRects::iterator& prev_pos,
580 TextRects& next,
581 TextRects::iterator& next_pos);
582
585 TextRects::iterator& prev_pos,
586 TextRects& next,
587 TextRects::iterator& next_pos);
588
591 TextRects::iterator& prev_pos,
592 TextRects& next,
593 TextRects::iterator& next_pos);
594
596 void tag_line(TextRects& prev,
597 TextRects::iterator& prev_pos,
598 TextRects& next,
599 TextRects::iterator& next_pos);
600
602 void tag_text(TextRects& prev, TextRects& next);
603
605 static void get_line_selection(const TextRects& rects,
606 TextRects::const_iterator& pos,
607 Rect& rect);
608
611 TextRects::const_iterator& prev_pos,
612 const TextRects& next,
613 TextRects::const_iterator& next_pos);
614
616 void tag_text_selection(const TextRects& prev, const TextRects& next);
617
620
623
625 void draw_text(Painter& painter, const Rect& rect);
626
629
631 EGT_NODISCARD Rect text_area() const;
632
635
638
640 static DefaultDim half_screens(DefaultDim size, DefaultDim screen_size);
641
644
647
650
653
656
659
661 void draw_sliders(Painter& painter, const Rect& rect);
662
664 void damage_text(const Rect& rect)
665 {
666 damage(Rect::intersection(rect, text_area()));
667 }
668
671 {
673 damage(Rect::intersection(m_cursor_rect, box()));
674 }
675
678
683 size_t m_cursor_pos{0};
684
689 size_t m_saved_column{0};
690
695 size_t m_select_start{0};
696
698 size_t m_select_len{0};
699
701 size_t m_select_origin{0};
702
704 size_t m_select_drag_start{0};
705
707 bool m_validate_input{false};
708
711
714
717 mutable bool m_text_rect_valid{false};
718
722 cairo_t* m_cr{nullptr};
723
726
731 EGT_NODISCARD size_t width_to_len(const std::string& str) const;
732
733private:
734 class State
735 {
736 public:
737 State() noexcept
738 {}
739
740 explicit State(const Font* font,
741 const Widget::Flags& flags,
742 const AlignFlags& text_align,
743 const TextFlags& text_flags) noexcept
744 : m_font(font),
745 m_flags(flags),
746 m_text_align(text_align),
747 m_text_flags(text_flags)
748 {}
749
750 State& operator=(const State& rhs) noexcept
751 {
752 m_font = rhs.m_font;
753 m_flags = rhs.m_flags;
754 m_text_align = rhs.m_text_align;
755 m_text_flags = rhs.m_text_flags;
756 return *this;
757 }
758
759 State& operator=(State&& rhs) noexcept
760 {
761 m_font = rhs.m_font;
762 m_flags = std::move(rhs.m_flags);
763 m_text_align = std::move(rhs.m_text_align);
764 m_text_flags = std::move(rhs.m_text_flags);
765 return *this;
766 }
767
768 bool operator==(const State& rhs) const noexcept
769 {
770 return m_font == rhs.m_font &&
771 m_flags == rhs.m_flags &&
772 m_text_align == rhs.m_text_align &&
773 m_text_flags == rhs.m_text_flags;
774 }
775
776 bool operator!=(const State& rhs) const noexcept
777 {
778 return !operator==(rhs);
779 }
780
781 private:
782 const Font* m_font{nullptr};
783 Widget::Flags m_flags;
784 AlignFlags m_text_align;
785 TextFlags m_text_flags;
786 };
787
789 void cursor_timeout();
790
792 bool m_cursor_state{false};
793
795 TextFlags m_text_flags{};
796
798 size_t m_max_len{0};
799
800 State m_state;
801
803 Slider m_hslider;
804
806 Slider m_vslider;
807
809 DefaultDim m_slider_dim{8};
810
812 Signal<>::RegisterHandle m_gain_focus_reg{};
813
815 Signal<>::RegisterHandle m_lost_focus_reg{};
816
817 void initialize(bool init_inherited_properties = true);
818
819 void deserialize(Serializer::Properties& props);
820};
821
822namespace detail
823{
825EGT_API void draw_text(Painter& painter,
826 const Rect& b,
827 const std::string& text,
828 const Font& font,
829 const TextBox::TextFlags& flags,
830 const AlignFlags& text_align,
832 const Pattern& text_color,
833 const std::function<void(const Point& offset, size_t height)>& draw_cursor = nullptr,
834 size_t cursor_pos = 0,
835 const Pattern& highlight_color = {},
836 size_t select_start = 0,
837 size_t select_len = 0);
838
840EGT_API void draw_text(Painter& painter,
841 const Rect& b,
842 const std::string& text,
843 const Font& font,
844 const TextBox::TextFlags& flags,
845 const AlignFlags& text_align,
847 const Pattern& text_color,
848 const AlignFlags& image_align,
849 const Image& image,
850 const std::function<void(const Point& offset, size_t height)>& draw_cursor = nullptr,
851 size_t cursor_pos = 0,
852 const Pattern& highlight_color = {},
853 size_t select_start = 0,
854 size_t select_len = 0);
855}
856
857}
858}
859
860#endif
Alignment flags.
Definition widgetflags.h:379
Manages a unique drawing surface and context.
Definition canvas.h:41
EGT_NODISCARD constexpr bool is_set(const T flag) const noexcept
Test if the specified flag is set.
Definition flagsbase.h:64
Utility class for managing a set of flags with the ability to observe changes to the flags.
Definition flags.h:40
bool clear(T flag) noexcept
Clear a single flag.
Definition flags.h:125
bool set(T flag) noexcept
Set a single flag.
Definition flags.h:107
Manages a font and properties of a font.
Definition font.h:35
A Frame is a Widget that has children widgets.
Definition frame.h:45
Drawing interface for 2D graphics.
Definition painter.h:45
Periodic timer.
Definition timer.h:281
EGT_NODISCARD constexpr Dim width() const noexcept
Get the width value.
Definition geometry.h:913
EGT_NODISCARD constexpr Dim x() const noexcept
Get the x value.
Definition geometry.h:903
EGT_NODISCARD constexpr const PointType< Dim, DimCompat > & point() const noexcept
Get the PointType of the rectangle.
Definition geometry.h:722
EGT_NODISCARD constexpr Dim height() const noexcept
Get the height value.
Definition geometry.h:915
EGT_NODISCARD constexpr Dim y() const noexcept
Get the y value.
Definition geometry.h:905
Abstract base serializer class.
Definition serialize.h:34
std::list< std::tuple< std::string, std::string, Serializer::Attributes > > Properties
Definition serialize.h:47
Input text box.
Definition text.h:134
void selection_move(size_t count, bool save_column=true)
Move the selection cursor to count character(s):
TextBox(Serializer::Properties &props, bool is_derived) noexcept
size_t insert(const std::string &str)
Insert text at the cursor.
size_t up(size_t cursor_pos) const
Get the position in the line befor cursor_pos at the same column, if possible.
void move_vslider()
Move the vertical slider, if needed, to track the cursor.
void damage_cursor()
Damage the cursor but only if visible.
Definition text.h:670
EGT_NODISCARD Size min_size_hint() const override
Get a minimum size hint for the Widget.
void tokenize(TextRects &rects)
Split the text into atomic tokens that fill the TextRects parameter.
void update_hslider()
Update the horizontal slider.
void show_cursor()
Show/enable the visibility of the cursor.
void tag_text(TextRects &prev, TextRects &next)
Damage the differences between two texts.
void draw_sliders(Painter &painter, const Rect &rect)
Draw sliders.
void selection_clear()
Clear any selection.
void clear_selection(TextRects &rects)
Clear the TextRectFlag::selected flag from all TextRects in rects.
void invalidate_text_rect()
Invalidate the cache used by text_rect()
void selection_damage()
Compute damage rectangles for selection updates.
void tag_default_aligned_line(TextRects &prev, TextRects::iterator &prev_pos, TextRects &next, TextRects::iterator &next_pos)
Damage the merged rectangle of two text lines if they are not equal.
void change_cursor(size_t pos, bool save_column=true)
Change the value of m_cursor_pos.
void draw(Painter &painter, const Rect &rect) override
Draw the widget.
EGT_NODISCARD std::string selected_text() const
Get, or copy, the selected text.
EGT_NODISCARD size_t selection_cursor()
Get the position of the moving end of the selection, as opposed to its origin (the fixed end of the s...
static std::string longest_prefix(const std::string &s1, const std::string &s2)
Compute the longest common prefix between two strings.
void selection(size_t pos, size_t length)
Set the selection of text.
void init_sliders()
Init sliders.
ValidatorCallbackArray m_validator_callbacks
Callbacks invoked to validate the input.
Definition text.h:710
Rect m_text_rect
The cache for text_rect().
Definition text.h:716
void hide_cursor()
Hide/disable the visibility of the cursor.
EGT_NODISCARD Point text_offset() const
Get the position offset of the drawn text as compared to the whole text.
static void get_line(const TextRects &rects, TextRects::iterator &pos, std::string &line, Rect &rect)
Get the std::string and Rect from pos to the first follwing TextRect in rects with a different height...
void update_sliders()
Update the horizontal and vertical sliders as needed.
TextBox & operator=(const TextBox &)=delete
void cursor_forward(size_t count=1)
Move the cursor forward by the specified count from the current position.
void prepare_text(TextRects &rects)
Tokenize and compute the layout of a text; fill TextRects accordingly.
void tag_line(TextRects &prev, TextRects::iterator &prev_pos, TextRects &next, TextRects::iterator &next_pos)
Damage the differences between two text lines, based on the text alignment.
egt::Flags< TextFlag > TextFlags
Text flags.
Definition text.h:160
EGT_NODISCARD Rect text_rect() const
Get the rectangle of a text.
void tag_line_selection(const TextRects &prev, TextRects::const_iterator &prev_pos, const TextRects &next, TextRects::const_iterator &next_pos)
Damage the differences between two selected text lines.
static AlignFlags default_text_align()
Change text align.
size_t up() const
Get the position in the previous line at the same column, if possible.
Definition text.h:522
static std::string longest_suffix(const std::string &s1, const std::string &s2)
Compute the longest common suffix between two strings.
EGT_NODISCARD size_t selection_length() const
Get the length of the selection.
Definition text.h:411
TextBox(const std::string &text={}, const AlignFlags &text_align=default_text_align(), const TextFlags &flags={}) noexcept
void text_flags(const TextFlags &text_flags)
Set the text flags.
Definition text.h:278
void resize(const Size &size) override
Resize the widget.
void cursor_begin()
Move the cursor to the beginning.
void set_selection(TextRects &rects)
Add the TextRectFlag::selected flag to TextRects based on the m_select_start and m_select_len values.
void cursor_backward(size_t count=1)
Move the cursor backward by the specified count from the current position.
void move_hslider()
Move the horizontal slider, if needed, to track the cursor.
Rect m_cursor_rect
Definition text.h:725
size_t down(size_t cursor_pos) const
Get the position in the line after cursor_pos at the same column, if possible.
TextRects m_rects
Definition text.h:724
size_t append(const std::string &str)
Move the cursor to the end and insert.
EGT_NODISCARD size_t selection_start() const
Get the start position of the selection.
Definition text.h:403
EGT_NODISCARD size_t width_to_len(const std::string &str) const
Given text, return the number of UTF8 characters that will fit on a single line inside of the widget.
void consolidate(TextRects &rects)
Merge adjacent TextRect items, when possible.
void tag_left_aligned_line(TextRects &prev, TextRects::iterator &prev_pos, TextRects &next, TextRects::iterator &next_pos)
Damage the merge rectangle of two text lines, excluding their common prefix.
void serialize(Serializer &serializer) const override
Serialize the widget to the specified serializer.
TextBox(Frame &parent, const std::string &text={}, const AlignFlags &text_align=default_text_align(), const TextFlags &flags={}) noexcept
void draw_text(Painter &painter, const Rect &rect)
Draw the text based on the m_rects TextRects.
static void default_text_align(const AlignFlags &align)
Change default text align.
TextBox & operator=(TextBox &&)=default
void text_offset(const Point &p)
Set the position offset of the drawn text as compared to the whole text.
EGT_NODISCARD Rect text_boundaries() const
Get the rectangle of the text boundaries.
std::vector< ValidatorCallback > ValidatorCallbackArray
Type array used for validator callbacks.
Definition text.h:486
void update_vslider()
Update the vertical slider.
size_t down() const
Get the position in the next line at the same column, if possible.
Definition text.h:528
TextFlag
Text flags.
Definition text.h:139
EGT_NODISCARD size_t max_length() const
Get the max length of allowed text.
Definition text.h:271
TextBox(const std::string &text, const TextFlags &flags, const AlignFlags &text_align=default_text_align()) noexcept
void selection_backward(size_t count=1)
Extend the selection to the left if the cursor is at its end, otherwise reduce the selection from the...
void add_validator_function(ValidatorCallback callback)
Add a callback to be invoked to validate the input.
static void get_line_selection(const TextRects &rects, TextRects::const_iterator &pos, Rect &rect)
Compute the merged Rect for the selected TextRects on the same line as pos.
EGT_NODISCARD size_t cursor() const
Get the cursor position.
cairo_t * context() const
Get the cairo context to compute text extents, hence the text layout.
Definition text.h:540
TextBox(Serializer::Properties &props) noexcept
Definition text.h:229
void cursor_set(size_t pos)
Set the cursor to the specific position.
virtual void handle_key(const Key &key)
Process key events.
void handle(Event &event) override
Handle an event.
TextBox(const TextBox &)=delete
EGT_NODISCARD Rect text_area() const
Return the rectangle boundaries where the text can be drawn.
size_t end_of_line(size_t cursor_pos) const
Get the position of the end of the line at cursor_pos.
size_t end_of_line() const
Get the position of the end of the current line.
Definition text.h:516
size_t beginning_of_line() const
Get the position of the beginning of the current line.
Definition text.h:510
void selection_forward(size_t count=1)
Extend the selection to the right if the cursor is at its beginning, otherwise reduce the selection f...
void input_validation_enabled(bool enabled)
Enable or disable input validation.
void compute_layout(TextRects &rects)
Compute the text layout from the tokens contained in the TextRects.
void tag_text_selection(const TextRects &prev, const TextRects &next)
Damage the differences between two selected texts.
void tag_right_aligned_line(TextRects &prev, TextRects::iterator &prev_pos, TextRects &next, TextRects::iterator &next_pos)
Damage the merge rectangle of two text lines, excluding their common suffix.
void get_cursor_rect()
Update m_cursor_rect based on the current position of the cursor.
void cursor_set(size_t pos, bool save_column)
Set the cursor position.
TextBox(Frame &parent, const std::string &text, const Rect &rect, const AlignFlags &text_align=default_text_align(), const TextFlags &flags={}) noexcept
void damage_text(const Rect &rect)
Damage the text but only if visible.
Definition text.h:664
void selection_all()
Select all of the text.
void selection_delete()
Delete the selected text.
void resize_sliders()
Resize the sliders whenever the widget size changes.
size_t point2pos(const Point &p) const
Convert point coordinates to position in text for cursor or selection.
void move_sliders()
Move sliders, if needed, to track the cursor.
~TextBox() noexcept override
void refresh_text_area()
Compute the new text layout and cursor rectangle.
PeriodicTimer m_timer
Timer for blinking the cursor.
Definition text.h:677
void continue_show_cursor()
If the cursor is shown, keep is shown some more.
bool validate_input(const std::string &str)
Validate the input against the validator pattern.
TextBox(TextBox &&)=default
std::function< bool(const std::string &)> ValidatorCallback
Validator callback type.
Definition text.h:166
void clear() override
Clear the text value.
void max_length(size_t len)
Set the maximum allowed length of the text.
size_t beginning_of_line(size_t cursor_pos) const
Get the position of the beginning of the line at cursor_pos.
void cursor_end()
Move the cursor to the end.
static DefaultDim half_screens(DefaultDim size, DefaultDim screen_size)
Return the lowest multiple of 'screen_size' / 2, greater than 'size'.
EGT_NODISCARD const TextFlags & text_flags() const
Get a const ref of the flags.
Definition text.h:290
EGT_NODISCARD Size text_size() const
void text(const std::string &str) override
Set the text.
Canvas m_canvas
The canvas that provides a cairo context to compute the text layout.
Definition text.h:713
Definition text.h:35
TextRect split(size_t pos, cairo_t *cr) noexcept
void deselect(void)
Definition text.h:74
TextRectFlag
TextRect flags.
Definition text.h:40
@ eonel
End of non-empty line.
bool end_of_non_empty_line(void) const
Definition text.h:76
TextRect & consolidate(const TextRect &r, cairo_t *cr) noexcept
void point(const Point &p)
Definition text.h:69
const TextRectFlags & flags(void) const
Definition text.h:70
uint32_t behave(void) const
Definition text.h:71
void mark_beginning_of_line(void)
Definition text.h:77
const Rect & rect(void) const
Definition text.h:67
const std::string & text(void) const
Definition text.h:66
bool is_selected(void) const
Definition text.h:75
const cairo_text_extents_t & text_extents(void) const
Definition text.h:72
TextRect(uint32_t behave, const Rect &rect, std::string text, const cairo_text_extents_t &te, const TextRectFlags &flags={}) noexcept
Definition text.h:54
size_t length(void) const noexcept
void rect(const Rect &r)
Definition text.h:68
void select(void)
Definition text.h:73
bool beginning_of_line(void) const
Definition text.h:78
bool can_consolidate(const TextRect &r) const noexcept
Definition text.h:80
A widget with text and text related properties.
Definition textwidget.h:33
RectType< DefaultDim, detail::Compatible::normal > Rect
Helper type alias.
Definition geometry.h:1023
PointType< DefaultDim, detail::Compatible::normal > Point
Helper type alias.
Definition geometry.h:314
constexpr T bit(T n)
Utility to create a bit mask for the specified bit.
Definition meta.h:306
constexpr bool operator!=(const Color &lhs, const Color &rhs)
Color operator.
Definition color.h:509
Justification
Generic justification of children flags.
Definition widgetflags.h:667
std::list< TextRect > TextRects
Definition text.h:111
constexpr bool operator==(const Color &lhs, const Color &rhs)
Color operator.
Definition color.h:500
int DefaultDim
Define the default dimension type used for geometry.
Definition geometry.h:34
EGT framework namespace.
Definition animation.h:24
A single event that has information about the event and state for the event.
Definition event.h:255
Keyboard event data.
Definition event.h:165