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
This commit is contained in:
mae
2010-11-10 12:53:45 +01:00
parent 3a73f7dfc9
commit b14e54b458
5 changed files with 61 additions and 0 deletions

View File

@@ -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;

View File

@@ -268,6 +268,10 @@ public slots:
void gotoPreviousWordWithSelection();
void gotoNextWord();
void gotoNextWordWithSelection();
void gotoPreviousWordCamelCase();
void gotoPreviousWordCamelCaseWithSelection();
void gotoNextWordCamelCase();
void gotoNextWordCamelCaseWithSelection();
void selectBlockUp();
void selectBlockDown();

View File

@@ -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)

View File

@@ -136,6 +136,10 @@ private slots:
void gotoPreviousWordWithSelection();
void gotoNextWord();
void gotoNextWordWithSelection();
void gotoPreviousWordCamelCase();
void gotoPreviousWordCamelCaseWithSelection();
void gotoNextWordCamelCase();
void gotoNextWordCamelCaseWithSelection();
private:

View File

@@ -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";