Commit 6d4d0f04 authored by Rhys Weatherley's avatar Rhys Weatherley
Browse files

Make ZZ and ZQ work in FakeVim as aliases for :x and :q!

parent ef4d2c30
...@@ -142,7 +142,8 @@ enum SubMode ...@@ -142,7 +142,8 @@ enum SubMode
ShiftRightSubMode, // used for > ShiftRightSubMode, // used for >
WindowSubMode, // used for Ctrl-w WindowSubMode, // used for Ctrl-w
YankSubMode, // used for y YankSubMode, // used for y
ZSubMode, ZSubMode, // used for z
CapitalZSubMode // used for Z
}; };
enum SubSubMode enum SubSubMode
...@@ -939,6 +940,13 @@ EventResult FakeVimHandler::Private::handleCommandMode(int key, int unmodified, ...@@ -939,6 +940,13 @@ EventResult FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
qDebug() << "IGNORED Z_MODE " << key << text; qDebug() << "IGNORED Z_MODE " << key << text;
} }
m_submode = NoSubMode; m_submode = NoSubMode;
} else if (m_submode == CapitalZSubMode) {
// Recognize ZZ and ZQ as aliases for ":x" and ":q!".
m_submode = NoSubMode;
if (key == 'Z')
handleExCommand("x");
else if (key == 'Q')
handleExCommand("q!");
} else if (m_subsubmode == FtSubSubMode) { } else if (m_subsubmode == FtSubSubMode) {
m_semicolonType = m_subsubdata; m_semicolonType = m_subsubdata;
m_semicolonKey = key; m_semicolonKey = key;
...@@ -1228,7 +1236,7 @@ EventResult FakeVimHandler::Private::handleCommandMode(int key, int unmodified, ...@@ -1228,7 +1236,7 @@ EventResult FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
} }
} else if (key == 'j' || key == Key_Down) { } else if (key == 'j' || key == Key_Down) {
if (m_submode == NoSubMode || m_submode == ZSubMode if (m_submode == NoSubMode || m_submode == ZSubMode
|| m_submode == RegisterSubMode) { || m_submode == CapitalZSubMode || m_submode == RegisterSubMode) {
moveDown(count()); moveDown(count());
} else { } else {
m_moveType = MoveLineWise; m_moveType = MoveLineWise;
...@@ -1254,7 +1262,7 @@ EventResult FakeVimHandler::Private::handleCommandMode(int key, int unmodified, ...@@ -1254,7 +1262,7 @@ EventResult FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
} }
} else if (key == 'k' || key == Key_Up) { } else if (key == 'k' || key == Key_Up) {
if (m_submode == NoSubMode || m_submode == ZSubMode if (m_submode == NoSubMode || m_submode == ZSubMode
|| m_submode == RegisterSubMode) { || m_submode == CapitalZSubMode || m_submode == RegisterSubMode) {
moveUp(count()); moveUp(count());
} else { } else {
m_moveType = MoveLineWise; m_moveType = MoveLineWise;
...@@ -1434,6 +1442,8 @@ EventResult FakeVimHandler::Private::handleCommandMode(int key, int unmodified, ...@@ -1434,6 +1442,8 @@ EventResult FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
finishMovement(); finishMovement();
} else if (key == 'z') { } else if (key == 'z') {
m_submode = ZSubMode; m_submode = ZSubMode;
} else if (key == 'Z') {
m_submode = CapitalZSubMode;
} else if (key == '~' && !atEndOfLine()) { } else if (key == '~' && !atEndOfLine()) {
setAnchor(); setAnchor();
moveRight(qMin(count(), rightDist())); moveRight(qMin(count(), rightDist()));
...@@ -2260,7 +2270,7 @@ void FakeVimHandler::Private::moveToMatchingParanthesis() ...@@ -2260,7 +2270,7 @@ void FakeVimHandler::Private::moveToMatchingParanthesis()
emit q->moveToMatchingParenthesis(&moved, &forward, &m_tc); emit q->moveToMatchingParenthesis(&moved, &forward, &m_tc);
if (moved && forward) { if (moved && forward) {
if (m_submode == NoSubMode || m_submode == ZSubMode || m_submode == RegisterSubMode) if (m_submode == NoSubMode || m_submode == ZSubMode || m_submode == CapitalZSubMode || m_submode == RegisterSubMode)
m_tc.movePosition(Left, KeepAnchor, 1); m_tc.movePosition(Left, KeepAnchor, 1);
} }
setTargetColumn(); setTargetColumn();
......
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