Fixes: fakevim: fix behaviour of 'a' at the end of line as

reported by J Hseu

    Details:  also rename 'atEol' to 'atEndOfLine'
This commit is contained in:
hjk
2009-01-23 10:13:12 +01:00
parent 8d932e2adc
commit 51089fba74

View File

@@ -190,7 +190,7 @@ private:
int count() const { return mvCount() * opCount(); } int count() const { return mvCount() * opCount(); }
int leftDist() const { return m_tc.position() - m_tc.block().position(); } int leftDist() const { return m_tc.position() - m_tc.block().position(); }
int rightDist() const { return m_tc.block().length() - leftDist() - 1; } int rightDist() const { return m_tc.block().length() - leftDist() - 1; }
bool atEol() const { return m_tc.atBlockEnd() && m_tc.block().length()>1; } bool atEndOfLine() const { return m_tc.atBlockEnd() && m_tc.block().length()>1; }
int lastPositionInDocument() const; int lastPositionInDocument() const;
int positionForLine(int line) const; // 1 based line, 0 based pos int positionForLine(int line) const; // 1 based line, 0 based pos
@@ -393,7 +393,7 @@ bool FakeVimHandler::Private::handleEvent(QKeyEvent *ev)
bool handled = handleKey(key, um, ev->text()); bool handled = handleKey(key, um, ev->text());
// We fake vi-style end-of-line behaviour // We fake vi-style end-of-line behaviour
m_fakeEnd = (atEol() && m_mode == CommandMode); m_fakeEnd = (atEndOfLine() && m_mode == CommandMode);
if (m_fakeEnd) if (m_fakeEnd)
moveLeft(); moveLeft();
@@ -448,7 +448,7 @@ void FakeVimHandler::Private::finishMovement(const QString &dotCommand)
m_registers[m_register] = recordRemoveSelectedText(); m_registers[m_register] = recordRemoveSelectedText();
recordEndGroup(); recordEndGroup();
m_submode = NoSubMode; m_submode = NoSubMode;
if (atEol()) if (atEndOfLine())
moveLeft(); moveLeft();
} else if (m_submode == YankSubMode) { } else if (m_submode == YankSubMode) {
m_registers[m_register] = selectedText(); m_registers[m_register] = selectedText();
@@ -761,6 +761,7 @@ bool FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
m_mode = InsertMode; m_mode = InsertMode;
recordBeginGroup(); recordBeginGroup();
m_lastInsertion.clear(); m_lastInsertion.clear();
if (!atEndOfLine())
moveRight(); moveRight();
updateMiniBuffer(); updateMiniBuffer();
} else if (key == 'A') { } else if (key == 'A') {
@@ -786,7 +787,7 @@ bool FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
m_mode = InsertMode; m_mode = InsertMode;
finishMovement(); finishMovement();
} else if (key == 'd' && m_visualMode == NoVisualMode) { } else if (key == 'd' && m_visualMode == NoVisualMode) {
if (atEol()) if (atEndOfLine())
moveLeft(); moveLeft();
setAnchor(); setAnchor();
recordBeginGroup(); recordBeginGroup();
@@ -840,7 +841,7 @@ bool FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
} else if (key == 'i') { } else if (key == 'i') {
enterInsertMode(); enterInsertMode();
updateMiniBuffer(); updateMiniBuffer();
if (atEol()) if (atEndOfLine())
moveLeft(); moveLeft();
} else if (key == 'I') { } else if (key == 'I') {
setAnchor(); setAnchor();
@@ -994,7 +995,7 @@ bool FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
moveToNextWord(true); moveToNextWord(true);
finishMovement("W"); finishMovement("W");
} else if (key == 'x') { // = "dl" } else if (key == 'x') { // = "dl"
if (atEol()) if (atEndOfLine())
moveLeft(); moveLeft();
recordBeginGroup(); recordBeginGroup();
setAnchor(); setAnchor();
@@ -1010,7 +1011,7 @@ bool FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
finishMovement(); finishMovement();
} else if (key == 'y') { } else if (key == 'y') {
m_savedYankPosition = m_tc.position(); m_savedYankPosition = m_tc.position();
if (atEol()) if (atEndOfLine())
moveLeft(); moveLeft();
recordBeginGroup(); recordBeginGroup();
setAnchor(); setAnchor();
@@ -1024,7 +1025,7 @@ bool FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
} else if (key == 'z') { } else if (key == 'z') {
recordBeginGroup(); recordBeginGroup();
m_submode = ZSubMode; m_submode = ZSubMode;
} else if (key == '~' && !atEol()) { } else if (key == '~' && !atEndOfLine()) {
recordBeginGroup(); recordBeginGroup();
setAnchor(); setAnchor();
moveRight(qMin(count(), rightDist())); moveRight(qMin(count(), rightDist()));
@@ -1110,7 +1111,7 @@ bool FakeVimHandler::Private::handleInsertMode(int key, int, const QString &text
} else if (!text.isEmpty()) { } else if (!text.isEmpty()) {
m_lastInsertion.append(text); m_lastInsertion.append(text);
if (m_submode == ReplaceSubMode) { if (m_submode == ReplaceSubMode) {
if (atEol()) if (atEndOfLine())
m_submode = NoSubMode; m_submode = NoSubMode;
else else
m_tc.deleteChar(); m_tc.deleteChar();
@@ -1645,7 +1646,7 @@ void FakeVimHandler::Private::moveToMatchingParanthesis()
#if 0 #if 0
// FIXME: remove TextEditor dependency // FIXME: remove TextEditor dependency
bool undoFakeEOL = false; bool undoFakeEOL = false;
if (atEol()) { if (atEndOfLine()) {
m_tc.movePosition(Left, KeepAnchor, 1); m_tc.movePosition(Left, KeepAnchor, 1);
undoFakeEOL = true; undoFakeEOL = true;
} }