diff options
author | Marcus Nilsson <brainbomb@gmail.com> | 2021-06-02 13:21:17 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-06-02 18:08:56 +0200 |
commit | 11fa3e4f92325e265834c05fd1385873f2733ff8 (patch) | |
tree | 1900f3d4533053621a4612b289dadd5877107b53 | |
parent | 9550564767c4ff5566c7277acb35d5b95cdf4e96 (diff) | |
download | serenity-11fa3e4f92325e265834c05fd1385873f2733ff8.zip |
Terminal/LibGUI::TextEditor: Add shift+return to search forwards
This adds support for shift+return key combo in single line TextEditor
fields. Used in this case for searching backwards/forwards in the
Terminal find window.
-rw-r--r-- | Userland/Applications/Terminal/main.cpp | 4 | ||||
-rw-r--r-- | Userland/Libraries/LibGUI/TextEditor.cpp | 6 | ||||
-rw-r--r-- | Userland/Libraries/LibGUI/TextEditor.h | 1 |
3 files changed, 11 insertions, 0 deletions
diff --git a/Userland/Applications/Terminal/main.cpp b/Userland/Applications/Terminal/main.cpp index 3ab77a578f..846b0ffdd2 100644 --- a/Userland/Applications/Terminal/main.cpp +++ b/Userland/Applications/Terminal/main.cpp @@ -190,6 +190,10 @@ static RefPtr<GUI::Window> create_find_window(VT::TerminalWidget& terminal) find_backwards.click(); }; + find_textbox.on_shift_return_pressed = [&]() { + find_forwards.click(); + }; + auto& match_case = search.add<GUI::CheckBox>("Case sensitive"); auto& wrap_around = search.add<GUI::CheckBox>("Wrap around"); diff --git a/Userland/Libraries/LibGUI/TextEditor.cpp b/Userland/Libraries/LibGUI/TextEditor.cpp index aefaa338bd..d6ab1690d2 100644 --- a/Userland/Libraries/LibGUI/TextEditor.cpp +++ b/Userland/Libraries/LibGUI/TextEditor.cpp @@ -731,6 +731,12 @@ void TextEditor::keydown_event(KeyEvent& event) if (event.key() == KeyCode::Key_Tab) return AbstractScrollableWidget::keydown_event(event); + if (event.modifiers() == KeyModifier::Mod_Shift && event.key() == KeyCode::Key_Return) { + if (on_shift_return_pressed) + on_shift_return_pressed(); + return; + } + if (event.key() == KeyCode::Key_Return) { if (on_return_pressed) on_return_pressed(); diff --git a/Userland/Libraries/LibGUI/TextEditor.h b/Userland/Libraries/LibGUI/TextEditor.h index c158198fa2..72f6a46b5a 100644 --- a/Userland/Libraries/LibGUI/TextEditor.h +++ b/Userland/Libraries/LibGUI/TextEditor.h @@ -138,6 +138,7 @@ public: Function<void(bool modified)> on_modified_change; Function<void()> on_mousedown; Function<void()> on_return_pressed; + Function<void()> on_shift_return_pressed; Function<void()> on_escape_pressed; Function<void()> on_up_pressed; Function<void()> on_down_pressed; |