diff options
author | AnotherTest <ali.mpfard@gmail.com> | 2020-05-02 08:12:29 +0430 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-05-02 11:57:21 +0200 |
commit | 7f1d3f6d62a7173312b11f11c4255ed09d21efc0 (patch) | |
tree | ebcffc36b7fcad4085cb9f9494982b00cbcf0a4b /Libraries/LibLine | |
parent | 905de7df584fa6783b844864b17da6959ba72721 (diff) | |
download | serenity-7f1d3f6d62a7173312b11f11c4255ed09d21efc0.zip |
LibLine: Handle ^L while in search mode
This commit fixes the following misbehaviour:
```
> <- search prompt moves here
>
> ^R^L <- actual prompt stays here
```
Diffstat (limited to 'Libraries/LibLine')
-rw-r--r-- | Libraries/LibLine/Editor.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/Libraries/LibLine/Editor.cpp b/Libraries/LibLine/Editor.cpp index e9b542a2fc..2f7115da94 100644 --- a/Libraries/LibLine/Editor.cpp +++ b/Libraries/LibLine/Editor.cpp @@ -690,6 +690,28 @@ String Editor::get_line(const String& prompt) return true; }); + // ^L - This is a source of issues, as the search editor refreshes first, + // and we end up with the wrong order of prompts, so we will first refresh + // ourselves, then refresh the search editor, and then tell him not to process + // this event + m_search_editor->register_character_input_callback(0x0c, [this](auto& search_editor) { + printf("\033[3J\033[H\033[2J"); // Clear screen. + + // refresh our own prompt + m_origin_x = 1; + m_origin_y = 1; + m_refresh_needed = true; + refresh_display(); + + // move the search prompt below ours + // and tell it to redraw itself + search_editor.m_origin_x = 2; + search_editor.m_origin_y = 1; + search_editor.m_refresh_needed = true; + + return false; + }); + // quit without clearing the current buffer m_search_editor->register_character_input_callback('\t', [this](Editor& search_editor) { search_editor.finish(); |