1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 14:38:11 +00:00

HackStudio: Add FindWidget

The find widget appears on Ctrl+F.

It uses the GUI::TextEditor search API to search for text, which also
takes care of highlighting the search results.
This commit is contained in:
Itamar 2022-03-29 16:45:26 +03:00 committed by Andreas Kling
parent de902ab659
commit d9d299f884
8 changed files with 186 additions and 4 deletions

View file

@ -20,11 +20,13 @@ namespace HackStudio {
EditorWrapper::EditorWrapper()
{
set_layout<GUI::VerticalBoxLayout>();
m_filename_title = untitled_label;
// FIXME: Propagate errors instead of giving up
m_editor = MUST(try_add<Editor>());
m_editor = MUST(Editor::try_create());
m_find_widget = add<FindWidget>(*m_editor);
add_child(*m_editor);
m_editor->set_ruler_visible(true);
m_editor->set_automatic_indentation_enabled(true);
@ -115,4 +117,12 @@ void EditorWrapper::set_debug_mode(bool enabled)
m_editor->set_debug_mode(enabled);
}
void EditorWrapper::search_action()
{
if (m_find_widget->visible())
m_find_widget->hide();
else
m_find_widget->show();
}
}