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.
This commit is contained in:
Marcus Nilsson 2021-06-02 13:21:17 +02:00 committed by Andreas Kling
parent 9550564767
commit 11fa3e4f92
3 changed files with 11 additions and 0 deletions

View file

@ -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");

View file

@ -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();

View file

@ -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;