Commit d8dedb43 authored by Leandro Melo's avatar Leandro Melo Committed by Leandro T. C. Melo
Browse files

Editor: Keyboard option for overriding delete word's start/end

Regular and camel-case version.

Task-number: QTCREATORBUG-5160
Change-Id: I749fbc4c768d4f11fb741fd1b9d00ddee56eb965
Reviewed-on: http://codereview.qt-project.org/5537

Reviewed-by: default avatarChristian Kamm <christian.d.kamm@nokia.com>
parent 49441ed4
......@@ -5128,6 +5128,36 @@ void BaseTextEditorWidget::deleteLine()
textCursor().removeSelectedText();
}
void BaseTextEditorWidget::deleteEndOfWord()
{
moveCursor(QTextCursor::EndOfWord, QTextCursor::KeepAnchor);
textCursor().removeSelectedText();
setTextCursor(textCursor());
}
void BaseTextEditorWidget::deleteEndOfWordCamelCase()
{
QTextCursor c = textCursor();
camelCaseRight(c, QTextCursor::KeepAnchor);
c.removeSelectedText();
setTextCursor(c);
}
void BaseTextEditorWidget::deleteStartOfWord()
{
moveCursor(QTextCursor::StartOfWord, QTextCursor::KeepAnchor);
textCursor().removeSelectedText();
setTextCursor(textCursor());
}
void BaseTextEditorWidget::deleteStartOfWordCamelCase()
{
QTextCursor c = textCursor();
camelCaseLeft(c, QTextCursor::KeepAnchor);
c.removeSelectedText();
setTextCursor(c);
}
void BaseTextEditorWidget::setExtraSelections(ExtraSelectionKind kind, const QList<QTextEdit::ExtraSelection> &selections)
{
if (selections.isEmpty() && d->m_extraSelections[kind].isEmpty())
......
......@@ -260,6 +260,10 @@ public slots:
void cutLine();
void copyLine();
void deleteLine();
void deleteEndOfWord();
void deleteEndOfWordCamelCase();
void deleteStartOfWord();
void deleteStartOfWordCamelCase();
void unfoldAll();
void fold();
void unfold();
......
......@@ -78,6 +78,10 @@ TextEditorActionHandler::TextEditorActionHandler(const char *context,
m_cutLineAction(0),
m_copyLineAction(0),
m_deleteLineAction(0),
m_deleteEndOfWordAction(0),
m_deleteEndOfWordCamelCaseAction(0),
m_deleteStartOfWordAction(0),
m_deleteStartOfWordCamelCaseAction(0),
m_selectEncodingAction(0),
m_increaseFontSizeAction(0),
m_decreaseFontSizeAction(0),
......@@ -221,6 +225,26 @@ void TextEditorActionHandler::createActions()
command = am->registerAction(m_deleteLineAction, Constants::DELETE_LINE, m_contextId, true);
connect(m_deleteLineAction, SIGNAL(triggered()), this, SLOT(deleteLine()));
m_deleteEndOfWordAction = new QAction(tr("Delete Word From The Cursor On"), this);
m_modifyingActions << m_deleteEndOfWordAction;
am->registerAction(m_deleteEndOfWordAction, Constants::DELETE_END_OF_WORD, m_contextId, true);
connect(m_deleteEndOfWordAction, SIGNAL(triggered()), this, SLOT(deleteEndOfWord()));
m_deleteEndOfWordCamelCaseAction = new QAction(tr("Delete Word Camel Case From The Cursor On"), this);
m_modifyingActions << m_deleteEndOfWordCamelCaseAction;
am->registerAction(m_deleteEndOfWordCamelCaseAction, Constants::DELETE_END_OF_WORD_CAMEL_CASE, m_contextId, true);
connect(m_deleteEndOfWordCamelCaseAction, SIGNAL(triggered()), this, SLOT(deleteEndOfWordCamelCase()));
m_deleteStartOfWordAction = new QAction(tr("Delete Word Up To The Cursor"), this);
m_modifyingActions << m_deleteStartOfWordAction;
am->registerAction(m_deleteStartOfWordAction, Constants::DELETE_START_OF_WORD, m_contextId, true);
connect(m_deleteStartOfWordAction, SIGNAL(triggered()), this, SLOT(deleteStartOfWord()));
m_deleteStartOfWordCamelCaseAction = new QAction(tr("Delete Word Camel Case Up To The Cursor"), this);
m_modifyingActions << m_deleteStartOfWordCamelCaseAction;
am->registerAction(m_deleteStartOfWordCamelCaseAction, Constants::DELETE_START_OF_WORD_CAMEL_CASE, m_contextId, true);
connect(m_deleteStartOfWordCamelCaseAction, SIGNAL(triggered()), this, SLOT(deleteStartOfWordCamelCase()));
m_foldAction = new QAction(tr("Fold"), this);
command = am->registerAction(m_foldAction, Constants::FOLD, m_contextId, true);
command->setDefaultKeySequence(QKeySequence(tr("Ctrl+<")));
......@@ -552,6 +576,10 @@ FUNCTION(unCommentSelection)
FUNCTION(cutLine)
FUNCTION(copyLine)
FUNCTION(deleteLine)
FUNCTION(deleteEndOfWord)
FUNCTION(deleteEndOfWordCamelCase)
FUNCTION(deleteStartOfWord)
FUNCTION(deleteStartOfWordCamelCase)
FUNCTION(unfoldAll)
FUNCTION(fold)
FUNCTION(unfold)
......
......@@ -112,6 +112,10 @@ private slots:
void cutLine();
void copyLine();
void deleteLine();
void deleteEndOfWord();
void deleteEndOfWordCamelCase();
void deleteStartOfWord();
void deleteStartOfWordCamelCase();
void selectEncoding();
void increaseFontSize();
void decreaseFontSize();
......@@ -176,6 +180,10 @@ private:
QAction *m_cutLineAction;
QAction *m_copyLineAction;
QAction *m_deleteLineAction;
QAction *m_deleteEndOfWordAction;
QAction *m_deleteEndOfWordCamelCaseAction;
QAction *m_deleteStartOfWordAction;
QAction *m_deleteStartOfWordCamelCaseAction;
QAction *m_selectEncodingAction;
QAction *m_increaseFontSizeAction;
QAction *m_decreaseFontSizeAction;
......
......@@ -70,6 +70,10 @@ const char * const LOWERCASE_SELECTION = "TextEditor.LowercaseSelection";
const char * const CUT_LINE = "TextEditor.CutLine";
const char * const COPY_LINE = "TextEditor.CopyLine";
const char * const DELETE_LINE = "TextEditor.DeleteLine";
const char * const DELETE_END_OF_WORD = "TextEditor.DeleteEndOfWord";
const char * const DELETE_END_OF_WORD_CAMEL_CASE = "TextEditor.DeleteEndOfWordCamelCase";
const char * const DELETE_START_OF_WORD = "TextEditor.DeleteStartOfWord";
const char * const DELETE_START_OF_WORD_CAMEL_CASE = "TextEditor.DeleteStartOfWordCamelCase";
const char * const SELECT_ENCODING = "TextEditor.SelectEncoding";
const char * const REWRAP_PARAGRAPH = "TextEditor.RewrapParagraph";
const char * const GOTO_LINE_START = "TextEditor.GotoLineStart";
......
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