Commit b14e54b4 authored by mae's avatar mae
Browse files

Extend camel-case cursor movement

We now have different actions to bind to (saves us an explicit option).
Small fixes to state machines.

Done-with: Erik Verbruggen
parent 3a73f7df
...@@ -811,6 +811,35 @@ void BaseTextEditor::gotoNextWordWithSelection() ...@@ -811,6 +811,35 @@ void BaseTextEditor::gotoNextWordWithSelection()
moveCursor(QTextCursor::NextWord, QTextCursor::KeepAnchor); 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) static QTextCursor flippedCursor(const QTextCursor &cursor)
...@@ -1146,6 +1175,7 @@ bool BaseTextEditor::camelCaseLeft(QTextCursor &cursor, QTextCursor::MoveMode mo ...@@ -1146,6 +1175,7 @@ bool BaseTextEditor::camelCaseLeft(QTextCursor &cursor, QTextCursor::MoveMode mo
case Input_U: case Input_U:
break; break;
default: default:
cursor.movePosition(QTextCursor::Right, mode);
return true; return true;
} }
break; break;
...@@ -1266,6 +1296,9 @@ bool BaseTextEditor::camelCaseRight(QTextCursor &cursor, QTextCursor::MoveMode m ...@@ -1266,6 +1296,9 @@ bool BaseTextEditor::camelCaseRight(QTextCursor &cursor, QTextCursor::MoveMode m
case Input_l: case Input_l:
cursor.movePosition(QTextCursor::Left, mode); cursor.movePosition(QTextCursor::Left, mode);
return true; return true;
case Input_underscore:
state = 6;
break;
case Input_space: case Input_space:
state = 7; state = 7;
break; break;
......
...@@ -268,6 +268,10 @@ public slots: ...@@ -268,6 +268,10 @@ public slots:
void gotoPreviousWordWithSelection(); void gotoPreviousWordWithSelection();
void gotoNextWord(); void gotoNextWord();
void gotoNextWordWithSelection(); void gotoNextWordWithSelection();
void gotoPreviousWordCamelCase();
void gotoPreviousWordCamelCaseWithSelection();
void gotoNextWordCamelCase();
void gotoNextWordCamelCaseWithSelection();
void selectBlockUp(); void selectBlockUp();
void selectBlockDown(); void selectBlockDown();
......
...@@ -327,6 +327,12 @@ void TextEditorActionHandler::createActions() ...@@ -327,6 +327,12 @@ void TextEditorActionHandler::createActions()
a = new QAction(tr("Goto Next Word"), this); a = new QAction(tr("Goto Next Word"), this);
command = am->registerAction(a, Constants::GOTO_NEXT_WORD, m_contextId); command = am->registerAction(a, Constants::GOTO_NEXT_WORD, m_contextId);
connect(a, SIGNAL(triggered()), this, SLOT(gotoNextWord())); 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); a = new QAction(tr("Goto Line Start With Selection"), this);
command = am->registerAction(a, Constants::GOTO_LINE_START_WITH_SELECTION, m_contextId); command = am->registerAction(a, Constants::GOTO_LINE_START_WITH_SELECTION, m_contextId);
...@@ -352,6 +358,12 @@ void TextEditorActionHandler::createActions() ...@@ -352,6 +358,12 @@ void TextEditorActionHandler::createActions()
a = new QAction(tr("Goto Next Word With Selection"), this); a = new QAction(tr("Goto Next Word With Selection"), this);
command = am->registerAction(a, Constants::GOTO_NEXT_WORD_WITH_SELECTION, m_contextId); command = am->registerAction(a, Constants::GOTO_NEXT_WORD_WITH_SELECTION, m_contextId);
connect(a, SIGNAL(triggered()), this, SLOT(gotoNextWordWithSelection())); 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) ...@@ -532,8 +544,12 @@ FUNCTION(gotoNextCharacter)
FUNCTION(gotoNextCharacterWithSelection) FUNCTION(gotoNextCharacterWithSelection)
FUNCTION(gotoPreviousWord) FUNCTION(gotoPreviousWord)
FUNCTION(gotoPreviousWordWithSelection) FUNCTION(gotoPreviousWordWithSelection)
FUNCTION(gotoPreviousWordCamelCase)
FUNCTION(gotoPreviousWordCamelCaseWithSelection)
FUNCTION(gotoNextWord) FUNCTION(gotoNextWord)
FUNCTION(gotoNextWordWithSelection) FUNCTION(gotoNextWordWithSelection)
FUNCTION(gotoNextWordCamelCase)
FUNCTION(gotoNextWordCamelCaseWithSelection)
void TextEditorActionHandler::updateCurrentEditor(Core::IEditor *editor) void TextEditorActionHandler::updateCurrentEditor(Core::IEditor *editor)
......
...@@ -136,6 +136,10 @@ private slots: ...@@ -136,6 +136,10 @@ private slots:
void gotoPreviousWordWithSelection(); void gotoPreviousWordWithSelection();
void gotoNextWord(); void gotoNextWord();
void gotoNextWordWithSelection(); void gotoNextWordWithSelection();
void gotoPreviousWordCamelCase();
void gotoPreviousWordCamelCaseWithSelection();
void gotoNextWordCamelCase();
void gotoNextWordCamelCaseWithSelection();
private: private:
......
...@@ -78,6 +78,8 @@ const char * const GOTO_PREVIOUS_CHARACTER = "TextEditor.GotoPreviousCharacter"; ...@@ -78,6 +78,8 @@ const char * const GOTO_PREVIOUS_CHARACTER = "TextEditor.GotoPreviousCharacter";
const char * const GOTO_NEXT_CHARACTER = "TextEditor.GotoNextCharacter"; const char * const GOTO_NEXT_CHARACTER = "TextEditor.GotoNextCharacter";
const char * const GOTO_PREVIOUS_WORD = "TextEditor.GotoPreviousWord"; const char * const GOTO_PREVIOUS_WORD = "TextEditor.GotoPreviousWord";
const char * const GOTO_NEXT_WORD = "TextEditor.GotoNextWord"; 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_START_WITH_SELECTION = "TextEditor.GotoLineStartWithSelection";
const char * const GOTO_LINE_END_WITH_SELECTION = "TextEditor.GotoLineEndWithSelection"; const char * const GOTO_LINE_END_WITH_SELECTION = "TextEditor.GotoLineEndWithSelection";
const char * const GOTO_NEXT_LINE_WITH_SELECTION = "TextEditor.GotoNextLineWithSelection"; const char * const GOTO_NEXT_LINE_WITH_SELECTION = "TextEditor.GotoNextLineWithSelection";
...@@ -86,6 +88,8 @@ const char * const GOTO_PREVIOUS_CHARACTER_WITH_SELECTION = "TextEditor.GotoPrev ...@@ -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_NEXT_CHARACTER_WITH_SELECTION = "TextEditor.GotoNextCharacterWithSelection";
const char * const GOTO_PREVIOUS_WORD_WITH_SELECTION = "TextEditor.GotoPreviousWordWithSelection"; const char * const GOTO_PREVIOUS_WORD_WITH_SELECTION = "TextEditor.GotoPreviousWordWithSelection";
const char * const GOTO_NEXT_WORD_WITH_SELECTION = "TextEditor.GotoNextWordWithSelection"; 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 C_TEXTEDITOR_MIMETYPE_TEXT = "text/plain";
const char * const INFO_SYNTAX_DEFINITION = "TextEditor.InfoSyntaxDefinition"; const char * const INFO_SYNTAX_DEFINITION = "TextEditor.InfoSyntaxDefinition";
const char * const TASK_DOWNLOAD_DEFINITIONS = "TextEditor.Task.Download"; const char * const TASK_DOWNLOAD_DEFINITIONS = "TextEditor.Task.Download";
......
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