Commit 0ecc0444 authored by David Schulz's avatar David Schulz

TextEditor: Add delete(Start/End)OfLine actions

Task-number: QTCREATORBUG-18095
Change-Id: I75e6141687ba5e96ef59384b302357700f79dd55
Reviewed-by: Riitta-Leena Miettinen's avatarLeena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: Eike Ziller's avatarEike Ziller <eike.ziller@qt.io>
parent 12c65d26
......@@ -6264,6 +6264,13 @@ void TextEditorWidget::deleteLine()
textCursor().removeSelectedText();
}
void TextEditorWidget::deleteEndOfLine()
{
moveCursor(QTextCursor::EndOfLine, QTextCursor::KeepAnchor);
textCursor().removeSelectedText();
setTextCursor(textCursor());
}
void TextEditorWidget::deleteEndOfWord()
{
moveCursor(QTextCursor::EndOfWord, QTextCursor::KeepAnchor);
......@@ -6279,6 +6286,13 @@ void TextEditorWidget::deleteEndOfWordCamelCase()
setTextCursor(c);
}
void TextEditorWidget::deleteStartOfLine()
{
moveCursor(QTextCursor::StartOfLine, QTextCursor::KeepAnchor);
textCursor().removeSelectedText();
setTextCursor(textCursor());
}
void TextEditorWidget::deleteStartOfWord()
{
moveCursor(QTextCursor::StartOfWord, QTextCursor::KeepAnchor);
......
......@@ -359,8 +359,10 @@ public:
void duplicateSelection();
void duplicateSelectionAndComment();
void deleteLine();
void deleteEndOfLine();
void deleteEndOfWord();
void deleteEndOfWordCamelCase();
void deleteStartOfLine();
void deleteStartOfWord();
void deleteStartOfWordCamelCase();
void unfoldAll();
......
......@@ -145,8 +145,10 @@ public:
QAction *m_duplicateSelectionAction = nullptr;
QAction *m_duplicateSelectionAndCommentAction = nullptr;
QAction *m_deleteLineAction = nullptr;
QAction *m_deleteEndOfLineAction = nullptr;
QAction *m_deleteEndOfWordAction = nullptr;
QAction *m_deleteEndOfWordCamelCaseAction = nullptr;
QAction *m_deleteStartOfLineAction = nullptr;
QAction *m_deleteStartOfWordAction = nullptr;
QAction *m_deleteStartOfWordCamelCaseAction = nullptr;
QAction *m_selectEncodingAction = nullptr;
......@@ -224,10 +226,14 @@ void TextEditorActionHandlerPrivate::createActions()
[this] (TextEditorWidget *widget) { widget->print(Core::ICore::printer()); });
m_deleteLineAction = registerAction(DELETE_LINE,
[this] (TextEditorWidget *w) { w->deleteLine(); }, true, tr("Delete &Line"));
m_deleteEndOfLineAction = registerAction(DELETE_END_OF_LINE,
[this] (TextEditorWidget *w) { w->deleteEndOfLine(); }, true, tr("Delete Line from Cursor On"));
m_deleteEndOfWordAction = registerAction(DELETE_END_OF_WORD,
[this] (TextEditorWidget *w) { w->deleteEndOfWord(); }, true, tr("Delete Word from Cursor On"));
m_deleteEndOfWordCamelCaseAction = registerAction(DELETE_END_OF_WORD_CAMEL_CASE,
[this] (TextEditorWidget *w) { w->deleteEndOfWordCamelCase(); }, true, tr("Delete Word Camel Case from Cursor On"));
m_deleteStartOfLineAction = registerAction(DELETE_START_OF_LINE,
[this] (TextEditorWidget *w) { w->deleteStartOfLine(); }, true, tr("Delete Line up to Cursor"));
m_deleteStartOfWordAction = registerAction(DELETE_START_OF_WORD,
[this] (TextEditorWidget *w) { w->deleteStartOfWord(); }, true, tr("Delete Word up to Cursor"));
m_deleteStartOfWordCamelCaseAction = registerAction(DELETE_START_OF_WORD_CAMEL_CASE,
......@@ -463,8 +469,10 @@ void TextEditorActionHandlerPrivate::createActions()
m_modifyingActions << m_unCommentSelectionAction;
m_modifyingActions << m_cutLineAction;
m_modifyingActions << m_deleteLineAction;
m_modifyingActions << m_deleteEndOfLineAction;
m_modifyingActions << m_deleteEndOfWordAction;
m_modifyingActions << m_deleteEndOfWordCamelCaseAction;
m_modifyingActions << m_deleteStartOfLineAction;
m_modifyingActions << m_deleteStartOfWordAction;
m_modifyingActions << m_deleteStartOfWordCamelCaseAction;
m_modifyingActions << m_moveLineUpAction;
......
......@@ -148,8 +148,10 @@ const char DUPLICATE_SELECTION[] = "TextEditor.DuplicateSelection";
const char DUPLICATE_SELECTION_AND_COMMENT[] = "TextEditor.DuplicateSelectionAndComment";
const char DELETE_LINE[] = "TextEditor.DeleteLine";
const char DELETE_END_OF_WORD[] = "TextEditor.DeleteEndOfWord";
const char DELETE_END_OF_LINE[] = "TextEditor.DeleteEndOfLine";
const char DELETE_END_OF_WORD_CAMEL_CASE[] = "TextEditor.DeleteEndOfWordCamelCase";
const char DELETE_START_OF_WORD[] = "TextEditor.DeleteStartOfWord";
const char DELETE_START_OF_LINE[] = "TextEditor.DeleteStartOfLine";
const char DELETE_START_OF_WORD_CAMEL_CASE[] = "TextEditor.DeleteStartOfWordCamelCase";
const char SELECT_ENCODING[] = "TextEditor.SelectEncoding";
const char REWRAP_PARAGRAPH[] = "TextEditor.RewrapParagraph";
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment