diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-03-08 00:49:45 +0100 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-03-08 00:49:45 +0100 |
commit | b5521e1b0d4f8dec7fb47aeff3bedd89b7a7ae85 (patch) | |
tree | 9bcc780dc8d406952cb9d552a8c2b11b6aa666c6 /LibGUI/GTextEditor.h | |
parent | c9c40e1da64ce38f2f5ac9871e33387d718cc004 (diff) | |
download | serenity-b5521e1b0d4f8dec7fb47aeff3bedd89b7a7ae85.zip |
GTextEditor: Add basic selection support.
Diffstat (limited to 'LibGUI/GTextEditor.h')
-rw-r--r-- | LibGUI/GTextEditor.h | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/LibGUI/GTextEditor.h b/LibGUI/GTextEditor.h index 54e5b79127..be734515f8 100644 --- a/LibGUI/GTextEditor.h +++ b/LibGUI/GTextEditor.h @@ -24,6 +24,7 @@ public: void set_column(int column) { m_column = column; } bool operator==(const GTextPosition& other) const { return m_line == other.m_line && m_column == other.m_column; } + bool operator<(const GTextPosition& other) const { return m_line < other.m_line || (m_line == other.m_line && m_column < other.m_column); } private: int m_line { -1 }; @@ -47,6 +48,7 @@ public: int line_height() const { return font().glyph_height() + m_line_spacing; } int padding() const { return 3; } GTextPosition cursor() const { return m_cursor; } + GTextPosition selection_start() const { return m_selection_start; } int glyph_width() const { return font().glyph_width('x'); } bool write_to_file(const String& path); @@ -95,6 +97,7 @@ private: void insert_at_cursor(char); int ruler_width() const; Rect ruler_content_rect(int line) const; + void toggle_selection_if_needed_for_event(const GKeyEvent&); GScrollBar* m_vertical_scrollbar { nullptr }; GScrollBar* m_horizontal_scrollbar { nullptr }; @@ -103,4 +106,5 @@ private: GTextPosition m_cursor; bool m_cursor_state { true }; int m_line_spacing { 2 }; + GTextPosition m_selection_start; }; |