From 526387a3d6e53799b0dbb5fc493ced4058e3de65 Mon Sep 17 00:00:00 2001 From: Michael Dales Date: Wed, 4 Dec 2024 19:06:59 +0000 Subject: [PATCH] Add delete to end of line for unix folk --- include/eepp/ui/doc/textdocument.hpp | 2 ++ src/eepp/ui/doc/textdocument.cpp | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/include/eepp/ui/doc/textdocument.hpp b/include/eepp/ui/doc/textdocument.hpp index 39be22ddd..dafc0947a 100644 --- a/include/eepp/ui/doc/textdocument.hpp +++ b/include/eepp/ui/doc/textdocument.hpp @@ -313,6 +313,8 @@ class EE_API TextDocument { void deleteToNextChar(); + void deleteToEndOfLine(); + void deleteToPreviousWord(); void deleteToNextWord(); diff --git a/src/eepp/ui/doc/textdocument.cpp b/src/eepp/ui/doc/textdocument.cpp index fbe2b19f1..9b53133f0 100644 --- a/src/eepp/ui/doc/textdocument.cpp +++ b/src/eepp/ui/doc/textdocument.cpp @@ -1910,6 +1910,12 @@ void TextDocument::deleteToNextChar() { mergeSelection(); } +void TextDocument::deleteToEndOfLine() { + for ( size_t i = 0; i < mSelection.size(); ++i ) + deleteTo( i, endOfLine( getSelectionIndex( i ).start() )); + mergeSelection(); +} + void TextDocument::deleteToPreviousWord() { for ( size_t i = 0; i < mSelection.size(); ++i ) deleteTo( i, previousWordBoundary( getSelectionIndex( i ).start() ) ); @@ -3540,6 +3546,7 @@ void TextDocument::initializeCommands() { mCommands["delete-to-next-word"] = [this] { deleteToNextWord(); }; mCommands["delete-to-next-char"] = [this] { deleteToNextChar(); }; mCommands["delete-current-line"] = [this] { deleteCurrentLine(); }; + mCommands["delete-to-end-of-line"] = [this] { deleteToEndOfLine(); }; mCommands["delete-selection"] = [this] { deleteSelection(); }; mCommands["delete-word"] = [this] { deleteWord(); }; mCommands["move-to-previous-char"] = [this] { moveToPreviousChar(); };