forked from qt-creator/qt-creator
FakeVim: Enable text transforms to work with 'passkeys' option
Commands like 'ciw', 'gUl' work with renaming and code completion if 'passkeys' option is enabled. Change-Id: I0cd69e13a0e7773d7cba82e571cc855aa90af7ba Reviewed-by: hjk <hjk121@nokiamail.com>
This commit is contained in:
@@ -1751,6 +1751,7 @@ public:
|
|||||||
void transformText(const Range &range, Transformation transformation,
|
void transformText(const Range &range, Transformation transformation,
|
||||||
const QVariant &extraData = QVariant());
|
const QVariant &extraData = QVariant());
|
||||||
|
|
||||||
|
void insertText(QTextCursor &tc, const QString &text);
|
||||||
void insertText(const Register ®);
|
void insertText(const Register ®);
|
||||||
void removeText(const Range &range);
|
void removeText(const Range &range);
|
||||||
void removeTransform(TransformationData *td);
|
void removeTransform(TransformationData *td);
|
||||||
@@ -3831,9 +3832,11 @@ bool FakeVimHandler::Private::handleNoSubMode(const Input &input)
|
|||||||
beginEditBlock();
|
beginEditBlock();
|
||||||
if (appendLine) {
|
if (appendLine) {
|
||||||
setPosition(lastPositionInLine(line));
|
setPosition(lastPositionInLine(line));
|
||||||
|
setAnchor();
|
||||||
insertNewLine();
|
insertNewLine();
|
||||||
} else {
|
} else {
|
||||||
setPosition(firstPositionInLine(line));
|
setPosition(firstPositionInLine(line));
|
||||||
|
setAnchor();
|
||||||
insertNewLine();
|
insertNewLine();
|
||||||
moveUp();
|
moveUp();
|
||||||
}
|
}
|
||||||
@@ -6433,7 +6436,7 @@ void FakeVimHandler::Private::transformText(const Range &range,
|
|||||||
tc.setPosition(range.endPos, KeepAnchor);
|
tc.setPosition(range.endPos, KeepAnchor);
|
||||||
TransformationData td(tc.selectedText(), extra);
|
TransformationData td(tc.selectedText(), extra);
|
||||||
(this->*transformFunc)(&td);
|
(this->*transformFunc)(&td);
|
||||||
tc.insertText(td.to);
|
insertText(tc, td.to);
|
||||||
endEditBlock();
|
endEditBlock();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -6464,7 +6467,7 @@ void FakeVimHandler::Private::transformText(const Range &range,
|
|||||||
TransformationData td(tc.selectedText(), extra);
|
TransformationData td(tc.selectedText(), extra);
|
||||||
(this->*transformFunc)(&td);
|
(this->*transformFunc)(&td);
|
||||||
posAfter = tc.anchor();
|
posAfter = tc.anchor();
|
||||||
tc.insertText(td.to);
|
insertText(tc, td.to);
|
||||||
endEditBlock();
|
endEditBlock();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -6487,7 +6490,7 @@ void FakeVimHandler::Private::transformText(const Range &range,
|
|||||||
tc.setPosition(block.position() + eCol, KeepAnchor);
|
tc.setPosition(block.position() + eCol, KeepAnchor);
|
||||||
TransformationData td(tc.selectedText(), extra);
|
TransformationData td(tc.selectedText(), extra);
|
||||||
(this->*transformFunc)(&td);
|
(this->*transformFunc)(&td);
|
||||||
tc.insertText(td.to);
|
insertText(tc, td.to);
|
||||||
block = block.previous();
|
block = block.previous();
|
||||||
}
|
}
|
||||||
endEditBlock();
|
endEditBlock();
|
||||||
@@ -6499,6 +6502,30 @@ void FakeVimHandler::Private::transformText(const Range &range,
|
|||||||
setTargetColumn();
|
setTargetColumn();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FakeVimHandler::Private::insertText(QTextCursor &tc, const QString &text)
|
||||||
|
{
|
||||||
|
if (hasConfig(ConfigPassKeys)) {
|
||||||
|
QTextCursor oldTc = cursor();
|
||||||
|
setCursor(tc);
|
||||||
|
EDITOR(setOverwriteMode(false));
|
||||||
|
|
||||||
|
if (tc.hasSelection() && text.isEmpty()) {
|
||||||
|
QKeyEvent event(QEvent::KeyPress, Qt::Key_Delete, Qt::NoModifier, QString());
|
||||||
|
passEventToEditor(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (QChar c, text) {
|
||||||
|
QKeyEvent event(QEvent::KeyPress, -1, Qt::NoModifier, QString(c));
|
||||||
|
passEventToEditor(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
updateCursorShape();
|
||||||
|
setCursor(oldTc);
|
||||||
|
} else {
|
||||||
|
tc.insertText(text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void FakeVimHandler::Private::insertText(const Register ®)
|
void FakeVimHandler::Private::insertText(const Register ®)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(reg.rangemode == RangeCharMode,
|
QTC_ASSERT(reg.rangemode == RangeCharMode,
|
||||||
@@ -6800,12 +6827,15 @@ QString FakeVimHandler::Private::guessInsertCommand(int pos1, int pos2, int len1
|
|||||||
|
|
||||||
const int up = document()->findBlock(pos2).blockNumber()
|
const int up = document()->findBlock(pos2).blockNumber()
|
||||||
- document()->findBlock(pos1).blockNumber();
|
- document()->findBlock(pos1).blockNumber();
|
||||||
if (up > 0)
|
if (up > 0) {
|
||||||
insert.append(QString(_("<UP>")).repeated(up));
|
insert.append(QString(_("<UP>")).repeated(up));
|
||||||
insert.append(_("<END>"));
|
insert.append(_("<END>"));
|
||||||
const int right = rightDist();
|
const int right = rightDist();
|
||||||
if (right > 0)
|
if (right > 0)
|
||||||
insert.append(QString(_("<LEFT>")).repeated(right));
|
insert.append(QString(_("<LEFT>")).repeated(right));
|
||||||
|
} else {
|
||||||
|
insert.append(QString(_("<LEFT>")).repeated(rest));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
Reference in New Issue
Block a user