summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibGUI/TextDocument.h
diff options
context:
space:
mode:
authorSnow <i@xkun.dev>2022-12-02 16:14:57 +0800
committerSam Atkins <atkinssj@gmail.com>2022-12-11 19:47:42 +0000
commit2f8c7b1b3094811d61b439f15b272b3a3a09d7f9 (patch)
treecd22e2883ccc63541cd18f045a115fdc4a345248 /Userland/Libraries/LibGUI/TextDocument.h
parente06f9174a1fa5c877ae32f0f6fe71ac5338f7fa4 (diff)
downloadserenity-2f8c7b1b3094811d61b439f15b272b3a3a09d7f9.zip
LibGUI: Add shortcut for inserting new line
This adds shortcut for inserting a new empty indented line above/below current cursor position. - <Ctrl-Return> for inserting line below. - <Ctrl-Shift-Return> for inserting line above.
Diffstat (limited to 'Userland/Libraries/LibGUI/TextDocument.h')
-rw-r--r--Userland/Libraries/LibGUI/TextDocument.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/Userland/Libraries/LibGUI/TextDocument.h b/Userland/Libraries/LibGUI/TextDocument.h
index c26bad0890..912354f04d 100644
--- a/Userland/Libraries/LibGUI/TextDocument.h
+++ b/Userland/Libraries/LibGUI/TextDocument.h
@@ -246,6 +246,27 @@ private:
TextRange m_range;
};
+class InsertLineCommand : public TextDocumentUndoCommand {
+public:
+ enum class InsertPosition {
+ Above,
+ Below,
+ };
+
+ InsertLineCommand(TextDocument&, TextPosition, DeprecatedString&&, InsertPosition);
+ virtual ~InsertLineCommand() = default;
+ virtual void undo() override;
+ virtual void redo() override;
+ virtual DeprecatedString action_text() const override;
+
+private:
+ size_t compute_line_number() const;
+
+ TextPosition m_cursor;
+ DeprecatedString m_text;
+ InsertPosition m_pos;
+};
+
class ReplaceAllTextCommand final : public GUI::TextDocumentUndoCommand {
public: