UICodeEditor copy and cut with multiple cursors.

This commit is contained in:
Martín Lucas Golini
2023-01-27 16:43:09 -03:00
parent 906c0a4358
commit ae592d29ff
3 changed files with 17 additions and 2 deletions

View File

@@ -512,6 +512,8 @@ class EE_API TextDocument {
void selectAllMatches();
String getAllSelectedText() const;
protected:
friend class UndoStack;

View File

@@ -777,6 +777,19 @@ String TextDocument::getText() const {
return getText( getDocRange() );
}
String TextDocument::getAllSelectedText() const {
String text;
for ( size_t i = 0; i < mSelection.size(); ++i ) {
String sel( getSelectedText( i ) );
if ( !sel.empty() ) {
text += std::move( sel );
if ( i != mSelection.size() - 1 )
text += "\n";
}
}
return text;
}
String TextDocument::getSelectedText() const {
return getText( getSelection() );
}

View File

@@ -2393,11 +2393,11 @@ void UICodeEditor::unindent() {
}
void UICodeEditor::copy() {
getUISceneNode()->getWindow()->getClipboard()->setText( mDoc->getSelectedText().toUtf8() );
getUISceneNode()->getWindow()->getClipboard()->setText( mDoc->getAllSelectedText().toUtf8() );
}
void UICodeEditor::cut() {
getUISceneNode()->getWindow()->getClipboard()->setText( mDoc->getSelectedText().toUtf8() );
getUISceneNode()->getWindow()->getClipboard()->setText( mDoc->getAllSelectedText().toUtf8() );
mDoc->deleteSelection();
}