Commit b3a27561 authored by Martin Aumueller's avatar Martin Aumueller Committed by hjk
Browse files

fakevim: 'r' for replacing single characters

parent 13481871
...@@ -97,6 +97,7 @@ enum SubMode ...@@ -97,6 +97,7 @@ enum SubMode
ChangeSubMode, ChangeSubMode,
DeleteSubMode, DeleteSubMode,
FilterSubMode, FilterSubMode,
ReplaceSubMode,
YankSubMode, YankSubMode,
ZSubMode, ZSubMode,
}; };
...@@ -386,6 +387,8 @@ void FakeVimHandler::Private::finishMovement(const QString &dotCommand) ...@@ -386,6 +387,8 @@ void FakeVimHandler::Private::finishMovement(const QString &dotCommand)
m_registers[m_register] = m_tc.selectedText(); m_registers[m_register] = m_tc.selectedText();
m_tc.setPosition(m_savedPosition); m_tc.setPosition(m_savedPosition);
m_submode = NoSubMode; m_submode = NoSubMode;
} else if (m_submode == ReplaceSubMode) {
m_submode = NoSubMode;
} }
m_mvcount.clear(); m_mvcount.clear();
m_opcount.clear(); m_opcount.clear();
...@@ -537,6 +540,13 @@ bool FakeVimHandler::Private::handleCommandMode(int key, const QString &text) ...@@ -537,6 +540,13 @@ bool FakeVimHandler::Private::handleCommandMode(int key, const QString &text)
m_tc.movePosition(Down, KeepAnchor, count()); m_tc.movePosition(Down, KeepAnchor, count());
m_registers[m_register] = m_tc.selectedText(); m_registers[m_register] = m_tc.selectedText();
finishMovement(); finishMovement();
} else if (m_submode == ReplaceSubMode) {
if (atEol())
m_tc.movePosition(Left, KeepAnchor, 1);
else
m_tc.deleteChar();
m_tc.insertText(text);
finishMovement();
} else if (m_submode == ZSubMode) { } else if (m_submode == ZSubMode) {
if (key == Key_Return) { if (key == Key_Return) {
// cursor line to top of window, cursor on first non-blank // cursor line to top of window, cursor on first non-blank
...@@ -783,6 +793,9 @@ bool FakeVimHandler::Private::handleCommandMode(int key, const QString &text) ...@@ -783,6 +793,9 @@ bool FakeVimHandler::Private::handleCommandMode(int key, const QString &text)
m_tc.movePosition(Left); m_tc.movePosition(Left);
} }
m_dotCommand = "p"; m_dotCommand = "p";
} else if (key == 'r') {
m_submode = ReplaceSubMode;
m_dotCommand = "r";
} else if (key == control('r')) { } else if (key == control('r')) {
redo(); redo();
} else if (key == 's') { } else if (key == 's') {
......
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