1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 04:17:35 +00:00

LibLine: Handle unicode correctly

This commit also fixes a problem with us throwing out data that was
inserted while a command was running.
This commit is contained in:
AnotherTest 2020-05-18 13:47:34 +04:30 committed by Andreas Kling
parent a4e0b585fe
commit 3bc3f36cfe
4 changed files with 90 additions and 29 deletions

View file

@ -147,8 +147,9 @@ public:
void resized() { m_was_resized = true; }
size_t cursor() const { return m_cursor; }
const Vector<char, 1024>& buffer() const { return m_buffer; }
char buffer_at(size_t pos) const { return m_buffer.at(pos); }
const Vector<u32, 1024>& buffer() const { return m_buffer; }
u32 buffer_at(size_t pos) const { return m_buffer.at(pos); }
String line() const;
// only makes sense inside a char_input callback or on_* callback
void set_prompt(const String& prompt)
@ -162,7 +163,7 @@ public:
void clear_line();
void insert(const String&);
void insert(const char);
void insert(const u32);
void stylize(const Span&, const Style&);
void strip_styles()
{
@ -275,9 +276,10 @@ private:
size_t m_search_offset { 0 };
bool m_searching_backwards { true };
size_t m_pre_search_cursor { 0 };
Vector<char, 1024> m_pre_search_buffer;
Vector<u32, 1024> m_pre_search_buffer;
Vector<char, 1024> m_buffer;
Vector<u32, 1024> m_buffer;
Vector<char, 512> m_incomplete_data;
ByteBuffer m_pending_chars;
size_t m_cursor { 0 };
size_t m_drawn_cursor { 0 };