Fixes: fakevim: work on shifting lines

Task:     180315
RevBy:
Details:
This commit is contained in:
hjk
2009-03-06 13:22:39 +01:00
parent dc8045f5be
commit 41535ff25b

View File

@@ -89,6 +89,13 @@
using namespace FakeVim::Internal;
using namespace FakeVim::Constants;
///////////////////////////////////////////////////////////////////////
//
// FakeVimHandler
//
///////////////////////////////////////////////////////////////////////
#define StartOfLine QTextCursor::StartOfLine
#define EndOfLine QTextCursor::EndOfLine
#define MoveAnchor QTextCursor::MoveAnchor
@@ -99,12 +106,6 @@ using namespace FakeVim::Constants;
#define Left QTextCursor::Left
#define EndOfDocument QTextCursor::End
///////////////////////////////////////////////////////////////////////
//
// FakeVimHandler
//
///////////////////////////////////////////////////////////////////////
#define EDITOR(s) (m_textedit ? m_textedit->s : m_plaintextedit->s)
const int ParagraphSeparator = 0x00002029;
@@ -1846,6 +1847,7 @@ void FakeVimHandler::Private::indentRegion(QChar typedChar)
qSwap(beginLine, endLine);
int amount = 0;
emit q->indentRegion(&amount, beginLine, endLine, typedChar);
m_dotCommand = QString("%1==").arg(endLine - beginLine + 1);
}
void FakeVimHandler::Private::shiftRegionRight(int repeat)
@@ -1856,18 +1858,21 @@ void FakeVimHandler::Private::shiftRegionRight(int repeat)
qSwap(beginLine, endLine);
int len = m_config[ConfigShiftWidth].toInt() * repeat;
QString indent(len, ' ');
int firstPos = firstPositionInLine(beginLine);
recordBeginGroup();
recordPosition();
//setPosition(firstPos);
//recordPosition();
for (int line = beginLine; line <= endLine; ++line) {
setPosition(firstPositionInLine(line));
recordInsertText(indent);
}
setPosition(firstPositionInLine(beginLine));
setPosition(firstPos);
moveToFirstNonBlankOnLine();
recordEndGroup();
m_dotCommand = QString("%1>>").arg(endLine - beginLine + 1);
}
void FakeVimHandler::Private::shiftRegionLeft(int repeat)
@@ -1878,9 +1883,11 @@ void FakeVimHandler::Private::shiftRegionLeft(int repeat)
qSwap(beginLine, endLine);
int shift = m_config[ConfigShiftWidth].toInt() * repeat;
int tab = m_config[ConfigTabStop].toInt();
int firstPos = firstPositionInLine(beginLine);
recordBeginGroup();
recordPosition();
//setPosition(firstPos);
//recordPosition();
for (int line = beginLine; line <= endLine; ++line) {
int pos = firstPositionInLine(line);
@@ -1902,9 +1909,10 @@ void FakeVimHandler::Private::shiftRegionLeft(int repeat)
setPosition(pos);
}
setPosition(firstPositionInLine(beginLine));
setPosition(firstPos);
moveToFirstNonBlankOnLine();
recordEndGroup();
m_dotCommand = QString("%1<<").arg(endLine - beginLine + 1);
}
void FakeVimHandler::Private::moveToDesiredColumn()