Commit f11c85d5 authored by Martin Aumüller's avatar Martin Aumüller Committed by hjk
Browse files

fakevim: improve behaviour of some editing commands while in visual mode



Merge-request: 131
Reviewed-by: default avatarhjk <qtc-committer@nokia.com>
parent 275d429e
...@@ -1428,7 +1428,8 @@ EventResult FakeVimHandler::Private::handleCommandMode(int key, int unmodified, ...@@ -1428,7 +1428,8 @@ EventResult FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
setAnchor(); setAnchor();
moveToMatchingParanthesis(); moveToMatchingParanthesis();
finishMovement(); finishMovement();
} else if (key == 'a') { } else if ((!isVisualMode() && key == 'a') || (isVisualMode() && key == 'A')) {
leaveVisualMode();
enterInsertMode(); enterInsertMode();
m_lastInsertion.clear(); m_lastInsertion.clear();
if (!atEndOfLine()) if (!atEndOfLine())
...@@ -1455,12 +1456,17 @@ EventResult FakeVimHandler::Private::handleCommandMode(int key, int unmodified, ...@@ -1455,12 +1456,17 @@ EventResult FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
moveLeft(); moveLeft();
setAnchor(); setAnchor();
m_submode = ChangeSubMode; m_submode = ChangeSubMode;
} else if (key == 'c' && (isVisualCharMode() || isVisualLineMode())) { } else if ((key == 'c' || key == 'C' || key == 's' || key == 'R')
m_rangemode = isVisualCharMode() ? RangeCharMode : RangeLineMode; && (isVisualCharMode() || isVisualLineMode())) {
if (isVisualLineMode()) { if((key == 'c'|| key == 's') && isVisualCharMode()) {
leaveVisualMode();
m_rangemode = RangeCharMode;
} else {
leaveVisualMode();
m_rangemode = RangeLineMode;
// leaveVisualMode() has set this to MoveInclusive for visual character mode
m_movetype = MoveLineWise; m_movetype = MoveLineWise;
} }
leaveVisualMode();
m_submode = ChangeSubMode; m_submode = ChangeSubMode;
finishMovement(); finishMovement();
} else if (key == 'C') { } else if (key == 'C') {
...@@ -1590,7 +1596,7 @@ EventResult FakeVimHandler::Private::handleCommandMode(int key, int unmodified, ...@@ -1590,7 +1596,7 @@ EventResult FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
moveDown(qMax(count() - 1, 0)); moveDown(qMax(count() - 1, 0));
handleStartOfLine(); handleStartOfLine();
finishMovement(); finishMovement();
} else if (key == 'i' || key == Key_Insert) { } else if (!isVisualMode() && (key == 'i' || key == Key_Insert)) {
setDotCommand(QString(QLatin1Char('i'))); // setDotCommand("%1i", count()); setDotCommand(QString(QLatin1Char('i'))); // setDotCommand("%1i", count());
enterInsertMode(); enterInsertMode();
updateMiniBuffer(); updateMiniBuffer();
...@@ -1727,7 +1733,7 @@ EventResult FakeVimHandler::Private::handleCommandMode(int key, int unmodified, ...@@ -1727,7 +1733,7 @@ EventResult FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
} else if (key == 'r') { } else if (key == 'r') {
m_submode = ReplaceSubMode; m_submode = ReplaceSubMode;
setDotCommand(QString(QLatin1Char('r'))); setDotCommand(QString(QLatin1Char('r')));
} else if (key == 'R') { } else if (!isVisualMode() && key == 'R') {
// FIXME: right now we repeat the insertion count() times, // FIXME: right now we repeat the insertion count() times,
// but not the deletion // but not the deletion
m_lastInsertion.clear(); m_lastInsertion.clear();
...@@ -1738,6 +1744,7 @@ EventResult FakeVimHandler::Private::handleCommandMode(int key, int unmodified, ...@@ -1738,6 +1744,7 @@ EventResult FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
} else if (key == control('r')) { } else if (key == control('r')) {
redo(); redo();
} else if (key == 's') { } else if (key == 's') {
leaveVisualMode();
if (atEndOfLine()) if (atEndOfLine())
moveLeft(); moveLeft();
setAnchor(); setAnchor();
...@@ -1749,9 +1756,11 @@ EventResult FakeVimHandler::Private::handleCommandMode(int key, int unmodified, ...@@ -1749,9 +1756,11 @@ EventResult FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
m_mvcount.clear(); m_mvcount.clear();
enterInsertMode(); enterInsertMode();
} else if (key == 'S') { } else if (key == 'S') {
const int line = cursorLineInDocument() + 1; if(!isVisualMode()) {
setAnchor(firstPositionInLine(line)); const int line = cursorLineInDocument() + 1;
setPosition(lastPositionInLine(line + count() - 1)); setAnchor(firstPositionInLine(line));
setPosition(lastPositionInLine(line + count() - 1));
}
setDotCommand("%1S", count()); setDotCommand("%1S", count());
enterInsertMode(); enterInsertMode();
m_beginEditBlock = false; m_beginEditBlock = false;
......
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