forked from qt-creator/qt-creator
fakevim: code cosmetics
This commit is contained in:
@@ -191,7 +191,8 @@ private:
|
|||||||
void scrollToLineInDocument(int line);
|
void scrollToLineInDocument(int line);
|
||||||
|
|
||||||
// helper functions for indenting
|
// helper functions for indenting
|
||||||
bool isElectricCharacter(QChar c) const { return (c == '{' || c == '}' || c == '#'); }
|
bool isElectricCharacter(QChar c) const
|
||||||
|
{ return (c == '{' || c == '}' || c == '#'); }
|
||||||
int indentDist() const;
|
int indentDist() const;
|
||||||
void indentRegion(QTextBlock first, QTextBlock last, QChar typedChar=0);
|
void indentRegion(QTextBlock first, QTextBlock last, QChar typedChar=0);
|
||||||
void indentCurrentLine(QChar typedChar);
|
void indentCurrentLine(QChar typedChar);
|
||||||
@@ -201,6 +202,25 @@ private:
|
|||||||
void moveToNextWord(bool simple);
|
void moveToNextWord(bool simple);
|
||||||
void moveToMatchingParanthesis();
|
void moveToMatchingParanthesis();
|
||||||
void moveToWordBoundary(bool simple, bool forward);
|
void moveToWordBoundary(bool simple, bool forward);
|
||||||
|
|
||||||
|
// to reduce line noise
|
||||||
|
typedef QTextCursor::MoveOperation MoveOperation;
|
||||||
|
typedef QTextCursor::MoveMode MoveMode;
|
||||||
|
void moveToEndOfDocument(MoveMode m, int n = 1)
|
||||||
|
{ m_tc.movePosition(QTextCursor::End, m, n); }
|
||||||
|
void moveToStartOfLine(MoveMode m, int n = 1)
|
||||||
|
{ m_tc.movePosition(QTextCursor::StartOfLine, m, n); }
|
||||||
|
void moveToEndOfLine(MoveMode m, int n = 1)
|
||||||
|
{ m_tc.movePosition(QTextCursor::EndOfLine, m, n); }
|
||||||
|
void moveUp(MoveMode m, int n = 1)
|
||||||
|
{ m_tc.movePosition(QTextCursor::Up, m, n); }
|
||||||
|
void moveDown(MoveMode m, int n = 1)
|
||||||
|
{ m_tc.movePosition(QTextCursor::Down, m, n); }
|
||||||
|
void moveRight(MoveMode m, int n = 1)
|
||||||
|
{ m_tc.movePosition(QTextCursor::Right, m, n); }
|
||||||
|
void moveLeft(MoveMode m, int n = 1)
|
||||||
|
{ m_tc.movePosition(QTextCursor::Left, m, n); }
|
||||||
|
|
||||||
void handleFfTt(int key);
|
void handleFfTt(int key);
|
||||||
|
|
||||||
// helper function for handleCommand. return 1 based line index.
|
// helper function for handleCommand. return 1 based line index.
|
||||||
@@ -343,7 +363,7 @@ bool FakeVimHandler::Private::handleEvent(QKeyEvent *ev)
|
|||||||
m_tc.setVisualNavigation(true);
|
m_tc.setVisualNavigation(true);
|
||||||
|
|
||||||
if (m_fakeEnd)
|
if (m_fakeEnd)
|
||||||
m_tc.movePosition(Right, MoveAnchor, 1);
|
moveRight(MoveAnchor);
|
||||||
|
|
||||||
if ((ev->modifiers() & Qt::ControlModifier) != 0) {
|
if ((ev->modifiers() & Qt::ControlModifier) != 0) {
|
||||||
key += 256;
|
key += 256;
|
||||||
@@ -358,7 +378,7 @@ bool FakeVimHandler::Private::handleEvent(QKeyEvent *ev)
|
|||||||
m_fakeEnd = (atEol() && m_mode == CommandMode);
|
m_fakeEnd = (atEol() && m_mode == CommandMode);
|
||||||
|
|
||||||
if (m_fakeEnd)
|
if (m_fakeEnd)
|
||||||
m_tc.movePosition(Left, MoveAnchor, 1);
|
moveLeft(MoveAnchor);
|
||||||
|
|
||||||
EDITOR(setTextCursor(m_tc));
|
EDITOR(setTextCursor(m_tc));
|
||||||
EDITOR(ensureCursorVisible());
|
EDITOR(ensureCursorVisible());
|
||||||
@@ -385,7 +405,7 @@ void FakeVimHandler::Private::finishMovement(const QString &dotCommand)
|
|||||||
if (m_submode == FilterSubMode) {
|
if (m_submode == FilterSubMode) {
|
||||||
int beginLine = lineForPosition(m_tc.anchor());
|
int beginLine = lineForPosition(m_tc.anchor());
|
||||||
int endLine = lineForPosition(m_tc.position());
|
int endLine = lineForPosition(m_tc.position());
|
||||||
m_tc.setPosition(qMin(m_tc.anchor(), m_tc.position()), MoveAnchor);
|
m_tc.setPosition(qMin(m_tc.anchor(), m_tc.position()));
|
||||||
m_mode = ExMode;
|
m_mode = ExMode;
|
||||||
m_commandBuffer = QString(".,+%1!").arg(qAbs(endLine - beginLine));
|
m_commandBuffer = QString(".,+%1!").arg(qAbs(endLine - beginLine));
|
||||||
m_commandHistory.append(QString());
|
m_commandHistory.append(QString());
|
||||||
@@ -412,7 +432,7 @@ void FakeVimHandler::Private::finishMovement(const QString &dotCommand)
|
|||||||
recordRemoveSelectedText();
|
recordRemoveSelectedText();
|
||||||
m_submode = NoSubMode;
|
m_submode = NoSubMode;
|
||||||
if (atEol())
|
if (atEol())
|
||||||
m_tc.movePosition(Left, MoveAnchor, 1);
|
moveLeft(MoveAnchor);
|
||||||
} else if (m_submode == YankSubMode) {
|
} else if (m_submode == YankSubMode) {
|
||||||
m_registers[m_register] = m_tc.selectedText();
|
m_registers[m_register] = m_tc.selectedText();
|
||||||
m_tc.setPosition(m_savedPosition);
|
m_tc.setPosition(m_savedPosition);
|
||||||
@@ -574,23 +594,23 @@ bool FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
|
|||||||
m_register = key;
|
m_register = key;
|
||||||
m_submode = NoSubMode;
|
m_submode = NoSubMode;
|
||||||
} else if (m_submode == ChangeSubMode && key == 'c') {
|
} else if (m_submode == ChangeSubMode && key == 'c') {
|
||||||
m_tc.movePosition(StartOfLine, MoveAnchor);
|
moveToStartOfLine(MoveAnchor);
|
||||||
m_tc.movePosition(Down, KeepAnchor, count());
|
moveDown(KeepAnchor, count());
|
||||||
m_registers[m_register] = m_tc.selectedText();
|
m_registers[m_register] = m_tc.selectedText();
|
||||||
finishMovement("c");
|
finishMovement("c");
|
||||||
} else if (m_submode == DeleteSubMode && key == 'd') {
|
} else if (m_submode == DeleteSubMode && key == 'd') {
|
||||||
m_tc.movePosition(StartOfLine, MoveAnchor);
|
moveToStartOfLine(MoveAnchor);
|
||||||
m_tc.movePosition(Down, KeepAnchor, count());
|
moveDown(KeepAnchor, count());
|
||||||
m_registers[m_register] = m_tc.selectedText();
|
m_registers[m_register] = m_tc.selectedText();
|
||||||
finishMovement("d");
|
finishMovement("d");
|
||||||
} else if (m_submode == YankSubMode && key == 'y') {
|
} else if (m_submode == YankSubMode && key == 'y') {
|
||||||
m_tc.movePosition(StartOfLine, MoveAnchor);
|
moveToStartOfLine(MoveAnchor);
|
||||||
m_tc.movePosition(Down, KeepAnchor, count());
|
moveDown(KeepAnchor, count());
|
||||||
m_registers[m_register] = m_tc.selectedText();
|
m_registers[m_register] = m_tc.selectedText();
|
||||||
finishMovement();
|
finishMovement();
|
||||||
} else if (m_submode == ReplaceSubMode) {
|
} else if (m_submode == ReplaceSubMode) {
|
||||||
if (atEol())
|
if (atEol())
|
||||||
m_tc.movePosition(Left, KeepAnchor, 1);
|
moveLeft(KeepAnchor);
|
||||||
else
|
else
|
||||||
m_tc.deleteChar();
|
m_tc.deleteChar();
|
||||||
m_tc.insertText(text);
|
m_tc.insertText(text);
|
||||||
@@ -659,8 +679,8 @@ bool FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
|
|||||||
} else if (key == '\'') {
|
} else if (key == '\'') {
|
||||||
m_subsubmode = TickSubSubMode;
|
m_subsubmode = TickSubSubMode;
|
||||||
} else if (key == '|') {
|
} else if (key == '|') {
|
||||||
m_tc.movePosition(StartOfLine, KeepAnchor);
|
moveToStartOfLine(KeepAnchor);
|
||||||
m_tc.movePosition(Right, KeepAnchor, qMin(count(), rightDist()) - 1);
|
moveRight(KeepAnchor, qMin(count(), rightDist()) - 1);
|
||||||
finishMovement();
|
finishMovement();
|
||||||
} else if (key == '!' && m_visualMode == NoVisualMode) {
|
} else if (key == '!' && m_visualMode == NoVisualMode) {
|
||||||
m_submode = FilterSubMode;
|
m_submode = FilterSubMode;
|
||||||
@@ -673,8 +693,8 @@ bool FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
|
|||||||
} else if (key == '"') {
|
} else if (key == '"') {
|
||||||
m_submode = RegisterSubMode;
|
m_submode = RegisterSubMode;
|
||||||
} else if (unmodified == Key_Return) {
|
} else if (unmodified == Key_Return) {
|
||||||
m_tc.movePosition(StartOfLine);
|
moveToStartOfLine(MoveAnchor);
|
||||||
m_tc.movePosition(Down);
|
moveDown(MoveAnchor);
|
||||||
moveToFirstNonBlankOnLine();
|
moveToFirstNonBlankOnLine();
|
||||||
finishMovement();
|
finishMovement();
|
||||||
} else if (key == Key_Home) {
|
} else if (key == Key_Home) {
|
||||||
@@ -682,7 +702,7 @@ bool FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
|
|||||||
finishMovement();
|
finishMovement();
|
||||||
} else if (key == '$' || key == Key_End) {
|
} else if (key == '$' || key == Key_End) {
|
||||||
int submode = m_submode;
|
int submode = m_submode;
|
||||||
m_tc.movePosition(EndOfLine, KeepAnchor);
|
moveToEndOfLine(KeepAnchor);
|
||||||
finishMovement();
|
finishMovement();
|
||||||
if (submode == NoSubMode)
|
if (submode == NoSubMode)
|
||||||
m_desiredColumn = -1;
|
m_desiredColumn = -1;
|
||||||
@@ -707,7 +727,7 @@ bool FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
|
|||||||
updateMiniBuffer();
|
updateMiniBuffer();
|
||||||
} else if (key == 'A') {
|
} else if (key == 'A') {
|
||||||
m_mode = InsertMode;
|
m_mode = InsertMode;
|
||||||
m_tc.movePosition(EndOfLine, MoveAnchor);
|
moveToEndOfLine(MoveAnchor);
|
||||||
m_lastInsertion.clear();
|
m_lastInsertion.clear();
|
||||||
} else if (key == 'b') {
|
} else if (key == 'b') {
|
||||||
moveToWordBoundary(false, false);
|
moveToWordBoundary(false, false);
|
||||||
@@ -719,11 +739,11 @@ bool FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
|
|||||||
m_submode = ChangeSubMode;
|
m_submode = ChangeSubMode;
|
||||||
} else if (key == 'C') {
|
} else if (key == 'C') {
|
||||||
m_submode = ChangeSubMode;
|
m_submode = ChangeSubMode;
|
||||||
m_tc.movePosition(EndOfLine, KeepAnchor);
|
moveToEndOfLine(KeepAnchor);
|
||||||
finishMovement();
|
finishMovement();
|
||||||
} else if (key == 'd' && m_visualMode == NoVisualMode) {
|
} else if (key == 'd' && m_visualMode == NoVisualMode) {
|
||||||
if (atEol())
|
if (atEol())
|
||||||
m_tc.movePosition(Left, MoveAnchor, 1);
|
moveLeft(MoveAnchor);
|
||||||
m_opcount = m_mvcount;
|
m_opcount = m_mvcount;
|
||||||
m_mvcount.clear();
|
m_mvcount.clear();
|
||||||
m_submode = DeleteSubMode;
|
m_submode = DeleteSubMode;
|
||||||
@@ -735,8 +755,8 @@ bool FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
|
|||||||
recordRemoveSelectedText();
|
recordRemoveSelectedText();
|
||||||
} else if (key == 'D') {
|
} else if (key == 'D') {
|
||||||
m_submode = DeleteSubMode;
|
m_submode = DeleteSubMode;
|
||||||
m_tc.movePosition(Down, KeepAnchor, qMax(count() - 1, 0));
|
moveDown(KeepAnchor, qMax(count() - 1, 0));
|
||||||
m_tc.movePosition(Right, KeepAnchor, rightDist());
|
moveRight(KeepAnchor, rightDist());
|
||||||
finishMovement();
|
finishMovement();
|
||||||
} else if (key == 'e') {
|
} else if (key == 'e') {
|
||||||
moveToWordBoundary(false, true);
|
moveToWordBoundary(false, true);
|
||||||
@@ -759,33 +779,33 @@ bool FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
|
|||||||
int n = qMin(count(), leftDist());
|
int n = qMin(count(), leftDist());
|
||||||
if (m_fakeEnd && m_tc.block().length() > 1)
|
if (m_fakeEnd && m_tc.block().length() > 1)
|
||||||
++n;
|
++n;
|
||||||
m_tc.movePosition(Left, KeepAnchor, n);
|
moveLeft(KeepAnchor, n);
|
||||||
finishMovement();
|
finishMovement();
|
||||||
} else if (key == 'H') {
|
} else if (key == 'H') {
|
||||||
m_tc = EDITOR(cursorForPosition(QPoint(0, 0)));
|
m_tc = EDITOR(cursorForPosition(QPoint(0, 0)));
|
||||||
m_tc.movePosition(Down, KeepAnchor, qMax(count() - 1, 0));
|
moveDown(KeepAnchor, qMax(count() - 1, 0));
|
||||||
moveToFirstNonBlankOnLine();
|
moveToFirstNonBlankOnLine();
|
||||||
finishMovement();
|
finishMovement();
|
||||||
} else if (key == 'i') {
|
} else if (key == 'i') {
|
||||||
enterInsertMode();
|
enterInsertMode();
|
||||||
updateMiniBuffer();
|
updateMiniBuffer();
|
||||||
if (atEol())
|
if (atEol())
|
||||||
m_tc.movePosition(Left, MoveAnchor, 1);
|
moveLeft(MoveAnchor);
|
||||||
} else if (key == 'I') {
|
} else if (key == 'I') {
|
||||||
enterInsertMode();
|
enterInsertMode();
|
||||||
if (m_gflag)
|
if (m_gflag)
|
||||||
m_tc.movePosition(StartOfLine, KeepAnchor);
|
moveToStartOfLine(KeepAnchor);
|
||||||
else
|
else
|
||||||
moveToFirstNonBlankOnLine();
|
moveToFirstNonBlankOnLine();
|
||||||
} else if (key == 'j' || key == Key_Down) {
|
} else if (key == 'j' || key == Key_Down) {
|
||||||
int savedColumn = m_desiredColumn;
|
int savedColumn = m_desiredColumn;
|
||||||
if (m_submode == NoSubMode || m_submode == ZSubMode
|
if (m_submode == NoSubMode || m_submode == ZSubMode
|
||||||
|| m_submode == RegisterSubMode) {
|
|| m_submode == RegisterSubMode) {
|
||||||
m_tc.movePosition(Down, KeepAnchor, count());
|
moveDown(KeepAnchor, count());
|
||||||
moveToDesiredColumn();
|
moveToDesiredColumn();
|
||||||
} else {
|
} else {
|
||||||
m_tc.movePosition(StartOfLine, MoveAnchor);
|
moveToStartOfLine(MoveAnchor);
|
||||||
m_tc.movePosition(Down, KeepAnchor, count() + 1);
|
moveDown(KeepAnchor, count() + 1);
|
||||||
}
|
}
|
||||||
finishMovement();
|
finishMovement();
|
||||||
m_desiredColumn = savedColumn;
|
m_desiredColumn = savedColumn;
|
||||||
@@ -793,33 +813,33 @@ bool FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
|
|||||||
recordBeginGroup();
|
recordBeginGroup();
|
||||||
if (m_submode == NoSubMode) {
|
if (m_submode == NoSubMode) {
|
||||||
for (int i = qMax(count(), 2) - 1; --i >= 0; ) {
|
for (int i = qMax(count(), 2) - 1; --i >= 0; ) {
|
||||||
m_tc.movePosition(EndOfLine);
|
moveToEndOfLine(MoveAnchor);
|
||||||
recordRemoveNextChar();
|
recordRemoveNextChar();
|
||||||
if (!m_gflag)
|
if (!m_gflag)
|
||||||
recordInsertText(" ");
|
recordInsertText(" ");
|
||||||
}
|
}
|
||||||
if (!m_gflag)
|
if (!m_gflag)
|
||||||
m_tc.movePosition(Left, MoveAnchor, 1);
|
moveLeft(MoveAnchor, 1);
|
||||||
}
|
}
|
||||||
recordEndGroup();
|
recordEndGroup();
|
||||||
} else if (key == 'k' || key == Key_Up) {
|
} else if (key == 'k' || key == Key_Up) {
|
||||||
int savedColumn = m_desiredColumn;
|
int savedColumn = m_desiredColumn;
|
||||||
if (m_submode == NoSubMode || m_submode == ZSubMode || m_submode == RegisterSubMode) {
|
if (m_submode == NoSubMode || m_submode == ZSubMode || m_submode == RegisterSubMode) {
|
||||||
m_tc.movePosition(Up, KeepAnchor, count());
|
moveUp(KeepAnchor, count());
|
||||||
moveToDesiredColumn();
|
moveToDesiredColumn();
|
||||||
} else {
|
} else {
|
||||||
m_tc.movePosition(StartOfLine, MoveAnchor);
|
moveToStartOfLine(MoveAnchor);
|
||||||
m_tc.movePosition(Down, MoveAnchor);
|
moveDown(MoveAnchor);
|
||||||
m_tc.movePosition(Up, KeepAnchor, count()+1);
|
moveUp(KeepAnchor, count() + 1);
|
||||||
}
|
}
|
||||||
finishMovement();
|
finishMovement();
|
||||||
m_desiredColumn = savedColumn;
|
m_desiredColumn = savedColumn;
|
||||||
} else if (key == 'l' || key == Key_Right) {
|
} else if (key == 'l' || key == Key_Right) {
|
||||||
m_tc.movePosition(Right, KeepAnchor, qMin(count(), rightDist()));
|
moveRight(KeepAnchor, qMin(count(), rightDist()));
|
||||||
finishMovement();
|
finishMovement();
|
||||||
} else if (key == 'L') {
|
} else if (key == 'L') {
|
||||||
m_tc = EDITOR(cursorForPosition(QPoint(0, EDITOR(height()))));
|
m_tc = EDITOR(cursorForPosition(QPoint(0, EDITOR(height()))));
|
||||||
m_tc.movePosition(Up, KeepAnchor, qMax(count(), 1));
|
moveUp(KeepAnchor, qMax(count(), 1));
|
||||||
moveToFirstNonBlankOnLine();
|
moveToFirstNonBlankOnLine();
|
||||||
finishMovement();
|
finishMovement();
|
||||||
} else if (key == 'm') {
|
} else if (key == 'm') {
|
||||||
@@ -836,12 +856,12 @@ bool FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
|
|||||||
enterInsertMode();
|
enterInsertMode();
|
||||||
moveToFirstNonBlankOnLine();
|
moveToFirstNonBlankOnLine();
|
||||||
int numSpaces = leftDist();
|
int numSpaces = leftDist();
|
||||||
m_tc.movePosition(Up, MoveAnchor, 1);
|
moveUp(MoveAnchor, 1);
|
||||||
if (key == 'o')
|
if (key == 'o')
|
||||||
m_tc.movePosition(Down, MoveAnchor, 1);
|
m_tc.movePosition(Down, MoveAnchor, 1);
|
||||||
m_tc.movePosition(EndOfLine, MoveAnchor);
|
moveToEndOfLine(MoveAnchor);
|
||||||
m_tc.insertText("\n");
|
m_tc.insertText("\n");
|
||||||
m_tc.movePosition(StartOfLine, MoveAnchor);
|
moveToStartOfLine(MoveAnchor);
|
||||||
if (m_config[ConfigAutoIndent] == ConfigOn)
|
if (m_config[ConfigAutoIndent] == ConfigOn)
|
||||||
m_tc.insertText(QString(indentDist(), ' '));
|
m_tc.insertText(QString(indentDist(), ' '));
|
||||||
else
|
else
|
||||||
@@ -897,24 +917,24 @@ bool FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
|
|||||||
finishMovement("W");
|
finishMovement("W");
|
||||||
} else if (key == 'x') { // = "dl"
|
} else if (key == 'x') { // = "dl"
|
||||||
if (atEol())
|
if (atEol())
|
||||||
m_tc.movePosition(Left, MoveAnchor, 1);
|
moveLeft(MoveAnchor);
|
||||||
m_submode = DeleteSubMode;
|
m_submode = DeleteSubMode;
|
||||||
m_tc.movePosition(Right, KeepAnchor, qMin(count(), rightDist()));
|
moveRight(KeepAnchor, qMin(count(), rightDist()));
|
||||||
finishMovement("l");
|
finishMovement("l");
|
||||||
} else if (key == 'X') {
|
} else if (key == 'X') {
|
||||||
if (leftDist() > 0) {
|
if (leftDist() > 0) {
|
||||||
m_tc.movePosition(Left, KeepAnchor, qMin(count(), leftDist()));
|
moveLeft(KeepAnchor, qMin(count(), leftDist()));
|
||||||
m_tc.deleteChar();
|
m_tc.deleteChar();
|
||||||
}
|
}
|
||||||
finishMovement();
|
finishMovement();
|
||||||
} else if (key == 'y') {
|
} else if (key == 'y') {
|
||||||
if (atEol())
|
if (atEol())
|
||||||
m_tc.movePosition(Left, MoveAnchor, 1);
|
moveLeft(MoveAnchor);
|
||||||
m_submode = YankSubMode;
|
m_submode = YankSubMode;
|
||||||
} else if (key == 'z') {
|
} else if (key == 'z') {
|
||||||
m_submode = ZSubMode;
|
m_submode = ZSubMode;
|
||||||
} else if (key == '~' && !atEol()) {
|
} else if (key == '~' && !atEol()) {
|
||||||
m_tc.movePosition(Right, KeepAnchor, qMin(count(), rightDist()));
|
moveRight(KeepAnchor, qMin(count(), rightDist()));
|
||||||
QString str = m_tc.selectedText();
|
QString str = m_tc.selectedText();
|
||||||
for (int i = str.size(); --i >= 0; ) {
|
for (int i = str.size(); --i >= 0; ) {
|
||||||
QChar c = str.at(i);
|
QChar c = str.at(i);
|
||||||
@@ -923,10 +943,10 @@ bool FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
|
|||||||
m_tc.deleteChar();
|
m_tc.deleteChar();
|
||||||
m_tc.insertText(str);
|
m_tc.insertText(str);
|
||||||
} else if (key == Key_PageDown || key == control('f')) {
|
} else if (key == Key_PageDown || key == control('f')) {
|
||||||
m_tc.movePosition(Down, KeepAnchor, count() * (linesOnScreen() - 2));
|
moveDown(KeepAnchor, count() * (linesOnScreen() - 2));
|
||||||
finishMovement();
|
finishMovement();
|
||||||
} else if (key == Key_PageUp || key == control('b')) {
|
} else if (key == Key_PageUp || key == control('b')) {
|
||||||
m_tc.movePosition(Up, KeepAnchor, count() * (linesOnScreen() - 2));
|
moveUp(KeepAnchor, count() * (linesOnScreen() - 2));
|
||||||
finishMovement();
|
finishMovement();
|
||||||
} else if (key == Key_Backspace || key == control('h')) {
|
} else if (key == Key_Backspace || key == control('h')) {
|
||||||
m_tc.deletePreviousChar();
|
m_tc.deletePreviousChar();
|
||||||
@@ -955,21 +975,21 @@ bool FakeVimHandler::Private::handleInsertMode(int key, int, const QString &text
|
|||||||
data += m_lastInsertion;
|
data += m_lastInsertion;
|
||||||
}
|
}
|
||||||
recordInsert(m_tc.position() - m_lastInsertion.size(), data);
|
recordInsert(m_tc.position() - m_lastInsertion.size(), data);
|
||||||
m_tc.movePosition(Left, MoveAnchor, qMin(1, leftDist()));
|
moveLeft(MoveAnchor, qMin(1, leftDist()));
|
||||||
enterCommandMode();
|
enterCommandMode();
|
||||||
} else if (key == Key_Left) {
|
} else if (key == Key_Left) {
|
||||||
m_tc.movePosition(Left, MoveAnchor, 1);
|
moveLeft(MoveAnchor, count());
|
||||||
m_lastInsertion.clear();
|
m_lastInsertion.clear();
|
||||||
} else if (key == Key_Down) {
|
} else if (key == Key_Down) {
|
||||||
m_submode = NoSubMode;
|
m_submode = NoSubMode;
|
||||||
m_tc.movePosition(Down, MoveAnchor, 1);
|
moveDown(MoveAnchor, count());
|
||||||
m_lastInsertion.clear();
|
m_lastInsertion.clear();
|
||||||
} else if (key == Key_Up) {
|
} else if (key == Key_Up) {
|
||||||
m_submode = NoSubMode;
|
m_submode = NoSubMode;
|
||||||
m_tc.movePosition(Up, MoveAnchor, 1);
|
moveUp(MoveAnchor, count());
|
||||||
m_lastInsertion.clear();
|
m_lastInsertion.clear();
|
||||||
} else if (key == Key_Right) {
|
} else if (key == Key_Right) {
|
||||||
m_tc.movePosition(Right, MoveAnchor, 1);
|
moveRight(MoveAnchor, count());
|
||||||
m_lastInsertion.clear();
|
m_lastInsertion.clear();
|
||||||
} else if (key == Key_Return) {
|
} else if (key == Key_Return) {
|
||||||
m_submode = NoSubMode;
|
m_submode = NoSubMode;
|
||||||
@@ -983,10 +1003,10 @@ bool FakeVimHandler::Private::handleInsertMode(int key, int, const QString &text
|
|||||||
m_tc.deleteChar();
|
m_tc.deleteChar();
|
||||||
m_lastInsertion.clear();
|
m_lastInsertion.clear();
|
||||||
} else if (key == Key_PageDown || key == control('f')) {
|
} else if (key == Key_PageDown || key == control('f')) {
|
||||||
m_tc.movePosition(Down, KeepAnchor, count() * (linesOnScreen() - 2));
|
moveDown(KeepAnchor, count() * (linesOnScreen() - 2));
|
||||||
m_lastInsertion.clear();
|
m_lastInsertion.clear();
|
||||||
} else if (key == Key_PageUp || key == control('b')) {
|
} else if (key == Key_PageUp || key == control('b')) {
|
||||||
m_tc.movePosition(Up, KeepAnchor, count() * (linesOnScreen() - 2));
|
moveUp(KeepAnchor, count() * (linesOnScreen() - 2));
|
||||||
m_lastInsertion.clear();
|
m_lastInsertion.clear();
|
||||||
} else if (key == Key_Tab && m_config[ConfigExpandTab] == ConfigOn) {
|
} else if (key == Key_Tab && m_config[ConfigExpandTab] == ConfigOn) {
|
||||||
QString str = QString(m_config[ConfigTabStop].toInt(), ' ');
|
QString str = QString(m_config[ConfigTabStop].toInt(), ' ');
|
||||||
|
|||||||
Reference in New Issue
Block a user