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

LibGUI: Add IncrementalSearchBanner

Compared to traditional modal search, incremental search begins
matching as soon as the user starts typing, highlighting results
immediately. This refactors Itamar's work for HackStudio into a
common LibGUI widget to be used in all multi-line TextEditors.
This commit is contained in:
thankyouverycool 2022-11-28 17:58:17 -05:00 committed by Sam Atkins
parent 3c4a563415
commit 8231bd9bc3
6 changed files with 267 additions and 1 deletions

View file

@ -0,0 +1,45 @@
/*
* Copyright (c) 2022, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <LibGUI/TextEditor.h>
#include <LibGUI/Widget.h>
namespace GUI {
class IncrementalSearchBanner final : public Widget {
C_OBJECT(IncrementalSearchBanner);
public:
virtual ~IncrementalSearchBanner() override = default;
void show();
void hide();
protected:
explicit IncrementalSearchBanner(TextEditor&);
virtual void paint_event(PaintEvent&) override;
virtual Optional<UISize> calculated_min_size() const override;
private:
void search(TextEditor::SearchDirection);
NonnullRefPtr<TextEditor> m_editor;
RefPtr<Button> m_close_button;
RefPtr<Button> m_next_button;
RefPtr<Button> m_previous_button;
RefPtr<Button> m_wrap_search_button;
RefPtr<Button> m_match_case_button;
RefPtr<Label> m_index_label;
RefPtr<TextBox> m_search_textbox;
TextDocument::SearchShouldWrap m_wrap_search { true };
bool m_match_case { false };
};
}