Skip to content

Commit

Permalink
Add delete to end of line for unix folk
Browse files Browse the repository at this point in the history
  • Loading branch information
mdales committed Dec 4, 2024
1 parent be6469d commit 526387a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions include/eepp/ui/doc/textdocument.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,8 @@ class EE_API TextDocument {

void deleteToNextChar();

void deleteToEndOfLine();

void deleteToPreviousWord();

void deleteToNextWord();
Expand Down
7 changes: 7 additions & 0 deletions src/eepp/ui/doc/textdocument.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() ) );
Expand Down Expand Up @@ -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(); };
Expand Down

0 comments on commit 526387a

Please sign in to comment.