From 2d7aaab897ff4a610944e91f14a07e0020f2d09f Mon Sep 17 00:00:00 2001 From: AnotherTest Date: Wed, 16 Sep 2020 05:05:03 +0430 Subject: [PATCH] LibLine: Add a setter for the cursor position --- Libraries/LibLine/Editor.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Libraries/LibLine/Editor.h b/Libraries/LibLine/Editor.h index 5f8109307f..efd7762340 100644 --- a/Libraries/LibLine/Editor.h +++ b/Libraries/LibLine/Editor.h @@ -204,6 +204,12 @@ public: } size_t cursor() const { return m_cursor; } + void set_cursor(size_t cursor) + { + if (cursor > m_buffer.size()) + cursor = m_buffer.size(); + m_cursor = cursor; + } const Vector& buffer() const { return m_buffer; } u32 buffer_at(size_t pos) const { return m_buffer.at(pos); } String line() const { return line(m_buffer.size()); }