1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 10:48:11 +00:00

GTextEditor: Only paint lines inside the dirty rect.

This dramatically improves performance in large documents. :^)
This commit is contained in:
Andreas Kling 2019-03-07 15:03:38 +01:00
parent 3ee0e82206
commit b4df33e453
2 changed files with 25 additions and 8 deletions

View file

@ -23,6 +23,8 @@ public:
void set_line(int line) { m_line = line; }
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; }
private:
int m_line { -1 };
int m_column { -1 };
@ -57,8 +59,6 @@ private:
virtual void timer_event(GTimerEvent&) override;
virtual bool accepts_focus() const override { return true; }
void insert_at_cursor(char);
class Line {
public:
Line();
@ -79,8 +79,11 @@ private:
Rect cursor_content_rect() const;
void update_cursor();
void set_cursor(int line, int column);
void set_cursor(const GTextPosition&);
Line& current_line() { return m_lines[m_cursor.line()]; }
const Line& current_line() const { return m_lines[m_cursor.line()]; }
GTextPosition text_position_at(const Point&) const;
void insert_at_cursor(char);
GScrollBar* m_vertical_scrollbar { nullptr };
GScrollBar* m_horizontal_scrollbar { nullptr };