forked from qt-creator/qt-creator
TextEditor: Add delete(Start/End)OfLine actions
Task-number: QTCREATORBUG-18095 Change-Id: I75e6141687ba5e96ef59384b302357700f79dd55 Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io> Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -6264,6 +6264,13 @@ void TextEditorWidget::deleteLine()
|
|||||||
textCursor().removeSelectedText();
|
textCursor().removeSelectedText();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TextEditorWidget::deleteEndOfLine()
|
||||||
|
{
|
||||||
|
moveCursor(QTextCursor::EndOfLine, QTextCursor::KeepAnchor);
|
||||||
|
textCursor().removeSelectedText();
|
||||||
|
setTextCursor(textCursor());
|
||||||
|
}
|
||||||
|
|
||||||
void TextEditorWidget::deleteEndOfWord()
|
void TextEditorWidget::deleteEndOfWord()
|
||||||
{
|
{
|
||||||
moveCursor(QTextCursor::EndOfWord, QTextCursor::KeepAnchor);
|
moveCursor(QTextCursor::EndOfWord, QTextCursor::KeepAnchor);
|
||||||
@@ -6279,6 +6286,13 @@ void TextEditorWidget::deleteEndOfWordCamelCase()
|
|||||||
setTextCursor(c);
|
setTextCursor(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TextEditorWidget::deleteStartOfLine()
|
||||||
|
{
|
||||||
|
moveCursor(QTextCursor::StartOfLine, QTextCursor::KeepAnchor);
|
||||||
|
textCursor().removeSelectedText();
|
||||||
|
setTextCursor(textCursor());
|
||||||
|
}
|
||||||
|
|
||||||
void TextEditorWidget::deleteStartOfWord()
|
void TextEditorWidget::deleteStartOfWord()
|
||||||
{
|
{
|
||||||
moveCursor(QTextCursor::StartOfWord, QTextCursor::KeepAnchor);
|
moveCursor(QTextCursor::StartOfWord, QTextCursor::KeepAnchor);
|
||||||
|
|||||||
@@ -359,8 +359,10 @@ public:
|
|||||||
void duplicateSelection();
|
void duplicateSelection();
|
||||||
void duplicateSelectionAndComment();
|
void duplicateSelectionAndComment();
|
||||||
void deleteLine();
|
void deleteLine();
|
||||||
|
void deleteEndOfLine();
|
||||||
void deleteEndOfWord();
|
void deleteEndOfWord();
|
||||||
void deleteEndOfWordCamelCase();
|
void deleteEndOfWordCamelCase();
|
||||||
|
void deleteStartOfLine();
|
||||||
void deleteStartOfWord();
|
void deleteStartOfWord();
|
||||||
void deleteStartOfWordCamelCase();
|
void deleteStartOfWordCamelCase();
|
||||||
void unfoldAll();
|
void unfoldAll();
|
||||||
|
|||||||
@@ -145,8 +145,10 @@ public:
|
|||||||
QAction *m_duplicateSelectionAction = nullptr;
|
QAction *m_duplicateSelectionAction = nullptr;
|
||||||
QAction *m_duplicateSelectionAndCommentAction = nullptr;
|
QAction *m_duplicateSelectionAndCommentAction = nullptr;
|
||||||
QAction *m_deleteLineAction = nullptr;
|
QAction *m_deleteLineAction = nullptr;
|
||||||
|
QAction *m_deleteEndOfLineAction = nullptr;
|
||||||
QAction *m_deleteEndOfWordAction = nullptr;
|
QAction *m_deleteEndOfWordAction = nullptr;
|
||||||
QAction *m_deleteEndOfWordCamelCaseAction = nullptr;
|
QAction *m_deleteEndOfWordCamelCaseAction = nullptr;
|
||||||
|
QAction *m_deleteStartOfLineAction = nullptr;
|
||||||
QAction *m_deleteStartOfWordAction = nullptr;
|
QAction *m_deleteStartOfWordAction = nullptr;
|
||||||
QAction *m_deleteStartOfWordCamelCaseAction = nullptr;
|
QAction *m_deleteStartOfWordCamelCaseAction = nullptr;
|
||||||
QAction *m_selectEncodingAction = nullptr;
|
QAction *m_selectEncodingAction = nullptr;
|
||||||
@@ -224,10 +226,14 @@ void TextEditorActionHandlerPrivate::createActions()
|
|||||||
[this] (TextEditorWidget *widget) { widget->print(Core::ICore::printer()); });
|
[this] (TextEditorWidget *widget) { widget->print(Core::ICore::printer()); });
|
||||||
m_deleteLineAction = registerAction(DELETE_LINE,
|
m_deleteLineAction = registerAction(DELETE_LINE,
|
||||||
[this] (TextEditorWidget *w) { w->deleteLine(); }, true, tr("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,
|
m_deleteEndOfWordAction = registerAction(DELETE_END_OF_WORD,
|
||||||
[this] (TextEditorWidget *w) { w->deleteEndOfWord(); }, true, tr("Delete Word from Cursor On"));
|
[this] (TextEditorWidget *w) { w->deleteEndOfWord(); }, true, tr("Delete Word from Cursor On"));
|
||||||
m_deleteEndOfWordCamelCaseAction = registerAction(DELETE_END_OF_WORD_CAMEL_CASE,
|
m_deleteEndOfWordCamelCaseAction = registerAction(DELETE_END_OF_WORD_CAMEL_CASE,
|
||||||
[this] (TextEditorWidget *w) { w->deleteEndOfWordCamelCase(); }, true, tr("Delete Word Camel Case from Cursor On"));
|
[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,
|
m_deleteStartOfWordAction = registerAction(DELETE_START_OF_WORD,
|
||||||
[this] (TextEditorWidget *w) { w->deleteStartOfWord(); }, true, tr("Delete Word up to Cursor"));
|
[this] (TextEditorWidget *w) { w->deleteStartOfWord(); }, true, tr("Delete Word up to Cursor"));
|
||||||
m_deleteStartOfWordCamelCaseAction = registerAction(DELETE_START_OF_WORD_CAMEL_CASE,
|
m_deleteStartOfWordCamelCaseAction = registerAction(DELETE_START_OF_WORD_CAMEL_CASE,
|
||||||
@@ -463,8 +469,10 @@ void TextEditorActionHandlerPrivate::createActions()
|
|||||||
m_modifyingActions << m_unCommentSelectionAction;
|
m_modifyingActions << m_unCommentSelectionAction;
|
||||||
m_modifyingActions << m_cutLineAction;
|
m_modifyingActions << m_cutLineAction;
|
||||||
m_modifyingActions << m_deleteLineAction;
|
m_modifyingActions << m_deleteLineAction;
|
||||||
|
m_modifyingActions << m_deleteEndOfLineAction;
|
||||||
m_modifyingActions << m_deleteEndOfWordAction;
|
m_modifyingActions << m_deleteEndOfWordAction;
|
||||||
m_modifyingActions << m_deleteEndOfWordCamelCaseAction;
|
m_modifyingActions << m_deleteEndOfWordCamelCaseAction;
|
||||||
|
m_modifyingActions << m_deleteStartOfLineAction;
|
||||||
m_modifyingActions << m_deleteStartOfWordAction;
|
m_modifyingActions << m_deleteStartOfWordAction;
|
||||||
m_modifyingActions << m_deleteStartOfWordCamelCaseAction;
|
m_modifyingActions << m_deleteStartOfWordCamelCaseAction;
|
||||||
m_modifyingActions << m_moveLineUpAction;
|
m_modifyingActions << m_moveLineUpAction;
|
||||||
|
|||||||
@@ -148,8 +148,10 @@ const char DUPLICATE_SELECTION[] = "TextEditor.DuplicateSelection";
|
|||||||
const char DUPLICATE_SELECTION_AND_COMMENT[] = "TextEditor.DuplicateSelectionAndComment";
|
const char DUPLICATE_SELECTION_AND_COMMENT[] = "TextEditor.DuplicateSelectionAndComment";
|
||||||
const char DELETE_LINE[] = "TextEditor.DeleteLine";
|
const char DELETE_LINE[] = "TextEditor.DeleteLine";
|
||||||
const char DELETE_END_OF_WORD[] = "TextEditor.DeleteEndOfWord";
|
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_END_OF_WORD_CAMEL_CASE[] = "TextEditor.DeleteEndOfWordCamelCase";
|
||||||
const char DELETE_START_OF_WORD[] = "TextEditor.DeleteStartOfWord";
|
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 DELETE_START_OF_WORD_CAMEL_CASE[] = "TextEditor.DeleteStartOfWordCamelCase";
|
||||||
const char SELECT_ENCODING[] = "TextEditor.SelectEncoding";
|
const char SELECT_ENCODING[] = "TextEditor.SelectEncoding";
|
||||||
const char REWRAP_PARAGRAPH[] = "TextEditor.RewrapParagraph";
|
const char REWRAP_PARAGRAPH[] = "TextEditor.RewrapParagraph";
|
||||||
|
|||||||
Reference in New Issue
Block a user