diff --git a/src/plugins/texteditor/basetexteditor.cpp b/src/plugins/texteditor/basetexteditor.cpp index 9b9900f5bb191a67c26cedcdfc71b52cda41ace3..6f0661b8d3b166b3c9541eae2d5d0ba65a71c793 100644 --- a/src/plugins/texteditor/basetexteditor.cpp +++ b/src/plugins/texteditor/basetexteditor.cpp @@ -811,6 +811,35 @@ void BaseTextEditor::gotoNextWordWithSelection() moveCursor(QTextCursor::NextWord, QTextCursor::KeepAnchor); } +void BaseTextEditor::gotoPreviousWordCamelCase() +{ + QTextCursor c = textCursor(); + camelCaseLeft(c, QTextCursor::MoveAnchor); + setTextCursor(c); +} + +void BaseTextEditor::gotoPreviousWordCamelCaseWithSelection() +{ + QTextCursor c = textCursor(); + camelCaseLeft(c, QTextCursor::KeepAnchor); + setTextCursor(c); +} + +void BaseTextEditor::gotoNextWordCamelCase() +{ + qDebug() << Q_FUNC_INFO; + QTextCursor c = textCursor(); + camelCaseRight(c, QTextCursor::MoveAnchor); + setTextCursor(c); +} + +void BaseTextEditor::gotoNextWordCamelCaseWithSelection() +{ + QTextCursor c = textCursor(); + camelCaseRight(c, QTextCursor::KeepAnchor); + setTextCursor(c); +} + static QTextCursor flippedCursor(const QTextCursor &cursor) @@ -1146,6 +1175,7 @@ bool BaseTextEditor::camelCaseLeft(QTextCursor &cursor, QTextCursor::MoveMode mo case Input_U: break; default: + cursor.movePosition(QTextCursor::Right, mode); return true; } break; @@ -1266,6 +1296,9 @@ bool BaseTextEditor::camelCaseRight(QTextCursor &cursor, QTextCursor::MoveMode m case Input_l: cursor.movePosition(QTextCursor::Left, mode); return true; + case Input_underscore: + state = 6; + break; case Input_space: state = 7; break; diff --git a/src/plugins/texteditor/basetexteditor.h b/src/plugins/texteditor/basetexteditor.h index 9296b581269853357bb7fff76f51dcdaac73fdcd..f0774c75b0751c6d9fd4c4b8b7c23decc017819b 100644 --- a/src/plugins/texteditor/basetexteditor.h +++ b/src/plugins/texteditor/basetexteditor.h @@ -268,6 +268,10 @@ public slots: void gotoPreviousWordWithSelection(); void gotoNextWord(); void gotoNextWordWithSelection(); + void gotoPreviousWordCamelCase(); + void gotoPreviousWordCamelCaseWithSelection(); + void gotoNextWordCamelCase(); + void gotoNextWordCamelCaseWithSelection(); void selectBlockUp(); void selectBlockDown(); diff --git a/src/plugins/texteditor/texteditoractionhandler.cpp b/src/plugins/texteditor/texteditoractionhandler.cpp index df4d0959b2d97e0784ebb3bcc2c345418a2d8bc8..d5e20aa9ee479e8e6688fb196ff055cddb4a7f5f 100644 --- a/src/plugins/texteditor/texteditoractionhandler.cpp +++ b/src/plugins/texteditor/texteditoractionhandler.cpp @@ -327,6 +327,12 @@ void TextEditorActionHandler::createActions() a = new QAction(tr("Goto Next Word"), this); command = am->registerAction(a, Constants::GOTO_NEXT_WORD, m_contextId); connect(a, SIGNAL(triggered()), this, SLOT(gotoNextWord())); + a = new QAction(tr("Goto Previous Word Camel Case"), this); + command = am->registerAction(a, Constants::GOTO_PREVIOUS_WORD_CAMEL_CASE, m_contextId); + connect(a, SIGNAL(triggered()), this, SLOT(gotoPreviousWordCamelCase())); + a = new QAction(tr("Goto Next Word Camel Case"), this); + command = am->registerAction(a, Constants::GOTO_NEXT_WORD_CAMEL_CASE, m_contextId); + connect(a, SIGNAL(triggered()), this, SLOT(gotoNextWordCamelCase())); a = new QAction(tr("Goto Line Start With Selection"), this); command = am->registerAction(a, Constants::GOTO_LINE_START_WITH_SELECTION, m_contextId); @@ -352,6 +358,12 @@ void TextEditorActionHandler::createActions() a = new QAction(tr("Goto Next Word With Selection"), this); command = am->registerAction(a, Constants::GOTO_NEXT_WORD_WITH_SELECTION, m_contextId); connect(a, SIGNAL(triggered()), this, SLOT(gotoNextWordWithSelection())); + a = new QAction(tr("Goto Previous Word Camel Case With Selection"), this); + command = am->registerAction(a, Constants::GOTO_PREVIOUS_WORD_CAMEL_CASE_WITH_SELECTION, m_contextId); + connect(a, SIGNAL(triggered()), this, SLOT(gotoPreviousWordCamelCaseWithSelection())); + a = new QAction(tr("Goto Next Word Camel Case With Selection"), this); + command = am->registerAction(a, Constants::GOTO_NEXT_WORD_CAMEL_CASE_WITH_SELECTION, m_contextId); + connect(a, SIGNAL(triggered()), this, SLOT(gotoNextWordCamelCaseWithSelection())); } @@ -532,8 +544,12 @@ FUNCTION(gotoNextCharacter) FUNCTION(gotoNextCharacterWithSelection) FUNCTION(gotoPreviousWord) FUNCTION(gotoPreviousWordWithSelection) +FUNCTION(gotoPreviousWordCamelCase) +FUNCTION(gotoPreviousWordCamelCaseWithSelection) FUNCTION(gotoNextWord) FUNCTION(gotoNextWordWithSelection) +FUNCTION(gotoNextWordCamelCase) +FUNCTION(gotoNextWordCamelCaseWithSelection) void TextEditorActionHandler::updateCurrentEditor(Core::IEditor *editor) diff --git a/src/plugins/texteditor/texteditoractionhandler.h b/src/plugins/texteditor/texteditoractionhandler.h index cfa7f019d7e6c772f48b4baaee67e4d0d2001d3e..eaf9049ade610b89068ec93edf56b87202837c74 100644 --- a/src/plugins/texteditor/texteditoractionhandler.h +++ b/src/plugins/texteditor/texteditoractionhandler.h @@ -136,6 +136,10 @@ private slots: void gotoPreviousWordWithSelection(); void gotoNextWord(); void gotoNextWordWithSelection(); + void gotoPreviousWordCamelCase(); + void gotoPreviousWordCamelCaseWithSelection(); + void gotoNextWordCamelCase(); + void gotoNextWordCamelCaseWithSelection(); private: diff --git a/src/plugins/texteditor/texteditorconstants.h b/src/plugins/texteditor/texteditorconstants.h index 56ca8961c655db427a14ddff0cdac7ccecaa48c8..83b4261e02ff03e020aebbf8885c14acda374f2e 100644 --- a/src/plugins/texteditor/texteditorconstants.h +++ b/src/plugins/texteditor/texteditorconstants.h @@ -78,6 +78,8 @@ const char * const GOTO_PREVIOUS_CHARACTER = "TextEditor.GotoPreviousCharacter"; const char * const GOTO_NEXT_CHARACTER = "TextEditor.GotoNextCharacter"; const char * const GOTO_PREVIOUS_WORD = "TextEditor.GotoPreviousWord"; const char * const GOTO_NEXT_WORD = "TextEditor.GotoNextWord"; +const char * const GOTO_PREVIOUS_WORD_CAMEL_CASE = "TextEditor.GotoPreviousWordCamelCase"; +const char * const GOTO_NEXT_WORD_CAMEL_CASE = "TextEditor.GotoNextWordCamelCase"; const char * const GOTO_LINE_START_WITH_SELECTION = "TextEditor.GotoLineStartWithSelection"; const char * const GOTO_LINE_END_WITH_SELECTION = "TextEditor.GotoLineEndWithSelection"; const char * const GOTO_NEXT_LINE_WITH_SELECTION = "TextEditor.GotoNextLineWithSelection"; @@ -86,6 +88,8 @@ const char * const GOTO_PREVIOUS_CHARACTER_WITH_SELECTION = "TextEditor.GotoPrev const char * const GOTO_NEXT_CHARACTER_WITH_SELECTION = "TextEditor.GotoNextCharacterWithSelection"; const char * const GOTO_PREVIOUS_WORD_WITH_SELECTION = "TextEditor.GotoPreviousWordWithSelection"; const char * const GOTO_NEXT_WORD_WITH_SELECTION = "TextEditor.GotoNextWordWithSelection"; +const char * const GOTO_PREVIOUS_WORD_CAMEL_CASE_WITH_SELECTION = "TextEditor.GotoPreviousWordCamelCaseWithSelection"; +const char * const GOTO_NEXT_WORD_CAMEL_CASE_WITH_SELECTION = "TextEditor.GotoNextWordCamelCaseWithSelection"; const char * const C_TEXTEDITOR_MIMETYPE_TEXT = "text/plain"; const char * const INFO_SYNTAX_DEFINITION = "TextEditor.InfoSyntaxDefinition"; const char * const TASK_DOWNLOAD_DEFINITIONS = "TextEditor.Task.Download";