1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-19 16:45:08 +00:00

GTextEditor: Let's use a Vector for the line backing store.

I'm eventually gonna want to replace this with something more clever,
like a automagically splicing vector or something, but for now, at least
we move away from immutable Strings.
This commit is contained in:
Andreas Kling 2019-03-07 14:35:32 +01:00
parent a21ecd440a
commit ce35cddb1b
4 changed files with 36 additions and 17 deletions

View file

@ -57,18 +57,20 @@ private:
virtual void timer_event(GTimerEvent&) override;
virtual bool accepts_focus() const override { return true; }
void insert_at_cursor(char);
class Line {
public:
Line() { }
Line();
String text() const { return m_text; }
int length() const { return m_text.length(); }
const char* characters() const { return m_text.data(); }
int length() const { return m_text.size() - 1; }
int width(const Font&) const;
void set_text(const String&);
private:
String m_text;
mutable int m_cached_width { -1 };
// NOTE: This vector is null terminated.
Vector<char> m_text;
};
void update_scrollbar_ranges();