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

LibLine: Send over some properties when being inspected

This commit is contained in:
AnotherTest 2020-05-26 15:21:44 +04:30 committed by Andreas Kling
parent d5e9213683
commit e75f7ddb1b
2 changed files with 21 additions and 0 deletions

View file

@ -324,6 +324,24 @@ auto Editor::get_line(const String& prompt) -> Result<String, Editor::Error>
return m_input_error.has_value() ? Result<String, Editor::Error> { m_input_error.value() } : Result<String, Editor::Error> { m_returned_line }; return m_input_error.has_value() ? Result<String, Editor::Error> { m_input_error.value() } : Result<String, Editor::Error> { m_returned_line };
} }
void Editor::save_to(JsonObject& object)
{
Core::Object::save_to(object);
object.set("is_searching", m_is_searching);
object.set("is_editing", m_is_editing);
object.set("cursor_offset", m_cursor);
object.set("needs_refresh", m_refresh_needed);
object.set("unprocessed_characters", m_incomplete_data.size());
object.set("history_size", m_history.size());
object.set("current_prompt", m_new_prompt);
object.set("was_interrupted", m_was_interrupted);
JsonObject display_area;
display_area.set("top_left_x", m_origin_x);
display_area.set("top_left_y", m_origin_y);
display_area.set("line_count", num_lines());
object.set("used_display_area", move(display_area));
}
void Editor::handle_read_event() void Editor::handle_read_event()
{ {
char keybuf[16]; char keybuf[16];

View file

@ -165,6 +165,9 @@ public:
private: private:
explicit Editor(Configuration configuration = {}); explicit Editor(Configuration configuration = {});
// ^Core::Object
virtual void save_to(JsonObject&) override;
struct KeyCallback { struct KeyCallback {
KeyCallback(Function<bool(Editor&)> cb) KeyCallback(Function<bool(Editor&)> cb)
: callback(move(cb)) : callback(move(cb))