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