diff options
author | SimonFJ20 <simonfromjakobsen@gmail.com> | 2022-04-12 22:46:26 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-04-13 21:24:48 +0200 |
commit | 661e7d691e7f00f9c24f69ce4a26522e29b0ede9 (patch) | |
tree | 20c6ff770fb17be883c6a61b996433335e1cf9f9 /Userland/Libraries/LibGUI/TextDocument.h | |
parent | 343d69962715b494a538324694ee624d81439849 (diff) | |
download | serenity-661e7d691e7f00f9c24f69ce4a26522e29b0ede9.zip |
LibGUI+GMLPlayground: Replace text using ReplaceAllTextCommand
Diffstat (limited to 'Userland/Libraries/LibGUI/TextDocument.h')
-rw-r--r-- | Userland/Libraries/LibGUI/TextDocument.h | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/Userland/Libraries/LibGUI/TextDocument.h b/Userland/Libraries/LibGUI/TextDocument.h index afef884465..48f569cac9 100644 --- a/Userland/Libraries/LibGUI/TextDocument.h +++ b/Userland/Libraries/LibGUI/TextDocument.h @@ -236,4 +236,20 @@ private: TextRange m_range; }; +class ReplaceAllTextCommand : public GUI::TextDocumentUndoCommand { + +public: + ReplaceAllTextCommand(GUI::TextDocument& document, String const& text, GUI::TextRange const& range); + void redo() override; + void undo() override; + bool merge_with(GUI::Command const&) override; + String action_text() const override; + String const& text() const { return m_text; } + TextRange const& range() const { return m_range; } + +private: + String m_text; + GUI::TextRange m_range; +}; + } |