forked from qt-creator/qt-creator
Merge branch 'master' of git@scm.dev.nokia.troll.no:creator/mainline
This commit is contained in:
@@ -2988,6 +2988,12 @@ void GdbEngine::runCustomDumper(const WatchData & data0, bool dumpChildren)
|
|||||||
//extraArgs[extraArgCount++] = sizeofTypeExpression(data.type);
|
//extraArgs[extraArgCount++] = sizeofTypeExpression(data.type);
|
||||||
//extraArgs[extraArgCount++] = "(size_t)&(('" + data.type + "'*)0)->value";
|
//extraArgs[extraArgCount++] = "(size_t)&(('" + data.type + "'*)0)->value";
|
||||||
}
|
}
|
||||||
|
} else if (outertype == "std::deque") {
|
||||||
|
// remove 'std::allocator<...>':
|
||||||
|
extraArgs[1] = "0";
|
||||||
|
} else if (outertype == "std::stack") {
|
||||||
|
// remove 'std::allocator<...>':
|
||||||
|
extraArgs[1] = "0";
|
||||||
} else if (outertype == "std::map") {
|
} else if (outertype == "std::map") {
|
||||||
// We don't want the comparator and the allocator confuse gdb.
|
// We don't want the comparator and the allocator confuse gdb.
|
||||||
// But we need the offset of the second item in the value pair.
|
// But we need the offset of the second item in the value pair.
|
||||||
|
|||||||
@@ -191,7 +191,8 @@ private:
|
|||||||
void scrollToLineInDocument(int line);
|
void scrollToLineInDocument(int line);
|
||||||
|
|
||||||
// helper functions for indenting
|
// helper functions for indenting
|
||||||
bool isElectricCharacter(QChar c) const { return (c == '{' || c == '}' || c == '#'); }
|
bool isElectricCharacter(QChar c) const
|
||||||
|
{ return (c == '{' || c == '}' || c == '#'); }
|
||||||
int indentDist() const;
|
int indentDist() const;
|
||||||
void indentRegion(QTextBlock first, QTextBlock last, QChar typedChar=0);
|
void indentRegion(QTextBlock first, QTextBlock last, QChar typedChar=0);
|
||||||
void indentCurrentLine(QChar typedChar);
|
void indentCurrentLine(QChar typedChar);
|
||||||
@@ -201,6 +202,25 @@ private:
|
|||||||
void moveToNextWord(bool simple);
|
void moveToNextWord(bool simple);
|
||||||
void moveToMatchingParanthesis();
|
void moveToMatchingParanthesis();
|
||||||
void moveToWordBoundary(bool simple, bool forward);
|
void moveToWordBoundary(bool simple, bool forward);
|
||||||
|
|
||||||
|
// to reduce line noise
|
||||||
|
typedef QTextCursor::MoveOperation MoveOperation;
|
||||||
|
typedef QTextCursor::MoveMode MoveMode;
|
||||||
|
void moveToEndOfDocument(MoveMode m, int n = 1)
|
||||||
|
{ m_tc.movePosition(QTextCursor::End, m, n); }
|
||||||
|
void moveToStartOfLine(MoveMode m, int n = 1)
|
||||||
|
{ m_tc.movePosition(QTextCursor::StartOfLine, m, n); }
|
||||||
|
void moveToEndOfLine(MoveMode m, int n = 1)
|
||||||
|
{ m_tc.movePosition(QTextCursor::EndOfLine, m, n); }
|
||||||
|
void moveUp(MoveMode m, int n = 1)
|
||||||
|
{ m_tc.movePosition(QTextCursor::Up, m, n); }
|
||||||
|
void moveDown(MoveMode m, int n = 1)
|
||||||
|
{ m_tc.movePosition(QTextCursor::Down, m, n); }
|
||||||
|
void moveRight(MoveMode m, int n = 1)
|
||||||
|
{ m_tc.movePosition(QTextCursor::Right, m, n); }
|
||||||
|
void moveLeft(MoveMode m, int n = 1)
|
||||||
|
{ m_tc.movePosition(QTextCursor::Left, m, n); }
|
||||||
|
|
||||||
void handleFfTt(int key);
|
void handleFfTt(int key);
|
||||||
|
|
||||||
// helper function for handleCommand. return 1 based line index.
|
// helper function for handleCommand. return 1 based line index.
|
||||||
@@ -254,11 +274,18 @@ public:
|
|||||||
void recordRemove(int position, const QString &data);
|
void recordRemove(int position, const QString &data);
|
||||||
void recordRemove(int position, int length);
|
void recordRemove(int position, int length);
|
||||||
void recordMove(int position, int nestedCount);
|
void recordMove(int position, int nestedCount);
|
||||||
void removeSelectedText(QTextCursor &tc);
|
|
||||||
|
void recordRemoveNextChar();
|
||||||
|
void recordInsertText(const QString &data);
|
||||||
|
void recordRemoveSelectedText();
|
||||||
|
void recordBeginGroup();
|
||||||
|
void recordEndGroup();
|
||||||
|
|
||||||
void undo();
|
void undo();
|
||||||
void redo();
|
void redo();
|
||||||
QStack<EditOperation> m_undoStack;
|
QStack<EditOperation> m_undoStack;
|
||||||
QStack<EditOperation> m_redoStack;
|
QStack<EditOperation> m_redoStack;
|
||||||
|
QStack<int> m_undoGroupStack;
|
||||||
|
|
||||||
// extra data for '.'
|
// extra data for '.'
|
||||||
QString m_dotCount;
|
QString m_dotCount;
|
||||||
@@ -336,7 +363,7 @@ bool FakeVimHandler::Private::handleEvent(QKeyEvent *ev)
|
|||||||
m_tc.setVisualNavigation(true);
|
m_tc.setVisualNavigation(true);
|
||||||
|
|
||||||
if (m_fakeEnd)
|
if (m_fakeEnd)
|
||||||
m_tc.movePosition(Right, MoveAnchor, 1);
|
moveRight(MoveAnchor);
|
||||||
|
|
||||||
if ((ev->modifiers() & Qt::ControlModifier) != 0) {
|
if ((ev->modifiers() & Qt::ControlModifier) != 0) {
|
||||||
key += 256;
|
key += 256;
|
||||||
@@ -351,7 +378,7 @@ bool FakeVimHandler::Private::handleEvent(QKeyEvent *ev)
|
|||||||
m_fakeEnd = (atEol() && m_mode == CommandMode);
|
m_fakeEnd = (atEol() && m_mode == CommandMode);
|
||||||
|
|
||||||
if (m_fakeEnd)
|
if (m_fakeEnd)
|
||||||
m_tc.movePosition(Left, MoveAnchor, 1);
|
moveLeft(MoveAnchor);
|
||||||
|
|
||||||
EDITOR(setTextCursor(m_tc));
|
EDITOR(setTextCursor(m_tc));
|
||||||
EDITOR(ensureCursorVisible());
|
EDITOR(ensureCursorVisible());
|
||||||
@@ -378,7 +405,7 @@ void FakeVimHandler::Private::finishMovement(const QString &dotCommand)
|
|||||||
if (m_submode == FilterSubMode) {
|
if (m_submode == FilterSubMode) {
|
||||||
int beginLine = lineForPosition(m_tc.anchor());
|
int beginLine = lineForPosition(m_tc.anchor());
|
||||||
int endLine = lineForPosition(m_tc.position());
|
int endLine = lineForPosition(m_tc.position());
|
||||||
m_tc.setPosition(qMin(m_tc.anchor(), m_tc.position()), MoveAnchor);
|
m_tc.setPosition(qMin(m_tc.anchor(), m_tc.position()));
|
||||||
m_mode = ExMode;
|
m_mode = ExMode;
|
||||||
m_commandBuffer = QString(".,+%1!").arg(qAbs(endLine - beginLine));
|
m_commandBuffer = QString(".,+%1!").arg(qAbs(endLine - beginLine));
|
||||||
m_commandHistory.append(QString());
|
m_commandHistory.append(QString());
|
||||||
@@ -394,7 +421,7 @@ void FakeVimHandler::Private::finishMovement(const QString &dotCommand)
|
|||||||
if (!dotCommand.isEmpty())
|
if (!dotCommand.isEmpty())
|
||||||
m_dotCommand = "c" + dotCommand;
|
m_dotCommand = "c" + dotCommand;
|
||||||
m_registers[m_register] = m_tc.selectedText();
|
m_registers[m_register] = m_tc.selectedText();
|
||||||
removeSelectedText(m_tc);
|
recordRemoveSelectedText();
|
||||||
m_mode = InsertMode;
|
m_mode = InsertMode;
|
||||||
m_submode = NoSubMode;
|
m_submode = NoSubMode;
|
||||||
} else if (m_submode == DeleteSubMode) {
|
} else if (m_submode == DeleteSubMode) {
|
||||||
@@ -402,10 +429,10 @@ void FakeVimHandler::Private::finishMovement(const QString &dotCommand)
|
|||||||
m_dotCommand = "d" + dotCommand;
|
m_dotCommand = "d" + dotCommand;
|
||||||
recordRemove(qMin(m_tc.position(), m_tc.anchor()), m_tc.selectedText());
|
recordRemove(qMin(m_tc.position(), m_tc.anchor()), m_tc.selectedText());
|
||||||
m_registers[m_register] = m_tc.selectedText();
|
m_registers[m_register] = m_tc.selectedText();
|
||||||
removeSelectedText(m_tc);
|
recordRemoveSelectedText();
|
||||||
m_submode = NoSubMode;
|
m_submode = NoSubMode;
|
||||||
if (atEol())
|
if (atEol())
|
||||||
m_tc.movePosition(Left, MoveAnchor, 1);
|
moveLeft(MoveAnchor);
|
||||||
} else if (m_submode == YankSubMode) {
|
} else if (m_submode == YankSubMode) {
|
||||||
m_registers[m_register] = m_tc.selectedText();
|
m_registers[m_register] = m_tc.selectedText();
|
||||||
m_tc.setPosition(m_savedPosition);
|
m_tc.setPosition(m_savedPosition);
|
||||||
@@ -567,23 +594,23 @@ bool FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
|
|||||||
m_register = key;
|
m_register = key;
|
||||||
m_submode = NoSubMode;
|
m_submode = NoSubMode;
|
||||||
} else if (m_submode == ChangeSubMode && key == 'c') {
|
} else if (m_submode == ChangeSubMode && key == 'c') {
|
||||||
m_tc.movePosition(StartOfLine, MoveAnchor);
|
moveToStartOfLine(MoveAnchor);
|
||||||
m_tc.movePosition(Down, KeepAnchor, count());
|
moveDown(KeepAnchor, count());
|
||||||
m_registers[m_register] = m_tc.selectedText();
|
m_registers[m_register] = m_tc.selectedText();
|
||||||
finishMovement("c");
|
finishMovement("c");
|
||||||
} else if (m_submode == DeleteSubMode && key == 'd') {
|
} else if (m_submode == DeleteSubMode && key == 'd') {
|
||||||
m_tc.movePosition(StartOfLine, MoveAnchor);
|
moveToStartOfLine(MoveAnchor);
|
||||||
m_tc.movePosition(Down, KeepAnchor, count());
|
moveDown(KeepAnchor, count());
|
||||||
m_registers[m_register] = m_tc.selectedText();
|
m_registers[m_register] = m_tc.selectedText();
|
||||||
finishMovement("d");
|
finishMovement("d");
|
||||||
} else if (m_submode == YankSubMode && key == 'y') {
|
} else if (m_submode == YankSubMode && key == 'y') {
|
||||||
m_tc.movePosition(StartOfLine, MoveAnchor);
|
moveToStartOfLine(MoveAnchor);
|
||||||
m_tc.movePosition(Down, KeepAnchor, count());
|
moveDown(KeepAnchor, count());
|
||||||
m_registers[m_register] = m_tc.selectedText();
|
m_registers[m_register] = m_tc.selectedText();
|
||||||
finishMovement();
|
finishMovement();
|
||||||
} else if (m_submode == ReplaceSubMode) {
|
} else if (m_submode == ReplaceSubMode) {
|
||||||
if (atEol())
|
if (atEol())
|
||||||
m_tc.movePosition(Left, KeepAnchor, 1);
|
moveLeft(KeepAnchor);
|
||||||
else
|
else
|
||||||
m_tc.deleteChar();
|
m_tc.deleteChar();
|
||||||
m_tc.insertText(text);
|
m_tc.insertText(text);
|
||||||
@@ -652,8 +679,8 @@ bool FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
|
|||||||
} else if (key == '\'') {
|
} else if (key == '\'') {
|
||||||
m_subsubmode = TickSubSubMode;
|
m_subsubmode = TickSubSubMode;
|
||||||
} else if (key == '|') {
|
} else if (key == '|') {
|
||||||
m_tc.movePosition(StartOfLine, KeepAnchor);
|
moveToStartOfLine(KeepAnchor);
|
||||||
m_tc.movePosition(Right, KeepAnchor, qMin(count(), rightDist()) - 1);
|
moveRight(KeepAnchor, qMin(count(), rightDist()) - 1);
|
||||||
finishMovement();
|
finishMovement();
|
||||||
} else if (key == '!' && m_visualMode == NoVisualMode) {
|
} else if (key == '!' && m_visualMode == NoVisualMode) {
|
||||||
m_submode = FilterSubMode;
|
m_submode = FilterSubMode;
|
||||||
@@ -666,8 +693,8 @@ bool FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
|
|||||||
} else if (key == '"') {
|
} else if (key == '"') {
|
||||||
m_submode = RegisterSubMode;
|
m_submode = RegisterSubMode;
|
||||||
} else if (unmodified == Key_Return) {
|
} else if (unmodified == Key_Return) {
|
||||||
m_tc.movePosition(StartOfLine);
|
moveToStartOfLine(MoveAnchor);
|
||||||
m_tc.movePosition(Down);
|
moveDown(MoveAnchor);
|
||||||
moveToFirstNonBlankOnLine();
|
moveToFirstNonBlankOnLine();
|
||||||
finishMovement();
|
finishMovement();
|
||||||
} else if (key == Key_Home) {
|
} else if (key == Key_Home) {
|
||||||
@@ -675,7 +702,7 @@ bool FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
|
|||||||
finishMovement();
|
finishMovement();
|
||||||
} else if (key == '$' || key == Key_End) {
|
} else if (key == '$' || key == Key_End) {
|
||||||
int submode = m_submode;
|
int submode = m_submode;
|
||||||
m_tc.movePosition(EndOfLine, KeepAnchor);
|
moveToEndOfLine(KeepAnchor);
|
||||||
finishMovement();
|
finishMovement();
|
||||||
if (submode == NoSubMode)
|
if (submode == NoSubMode)
|
||||||
m_desiredColumn = -1;
|
m_desiredColumn = -1;
|
||||||
@@ -700,7 +727,7 @@ bool FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
|
|||||||
updateMiniBuffer();
|
updateMiniBuffer();
|
||||||
} else if (key == 'A') {
|
} else if (key == 'A') {
|
||||||
m_mode = InsertMode;
|
m_mode = InsertMode;
|
||||||
m_tc.movePosition(EndOfLine, MoveAnchor);
|
moveToEndOfLine(MoveAnchor);
|
||||||
m_lastInsertion.clear();
|
m_lastInsertion.clear();
|
||||||
} else if (key == 'b') {
|
} else if (key == 'b') {
|
||||||
moveToWordBoundary(false, false);
|
moveToWordBoundary(false, false);
|
||||||
@@ -712,11 +739,11 @@ bool FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
|
|||||||
m_submode = ChangeSubMode;
|
m_submode = ChangeSubMode;
|
||||||
} else if (key == 'C') {
|
} else if (key == 'C') {
|
||||||
m_submode = ChangeSubMode;
|
m_submode = ChangeSubMode;
|
||||||
m_tc.movePosition(EndOfLine, KeepAnchor);
|
moveToEndOfLine(KeepAnchor);
|
||||||
finishMovement();
|
finishMovement();
|
||||||
} else if (key == 'd' && m_visualMode == NoVisualMode) {
|
} else if (key == 'd' && m_visualMode == NoVisualMode) {
|
||||||
if (atEol())
|
if (atEol())
|
||||||
m_tc.movePosition(Left, MoveAnchor, 1);
|
moveLeft(MoveAnchor);
|
||||||
m_opcount = m_mvcount;
|
m_opcount = m_mvcount;
|
||||||
m_mvcount.clear();
|
m_mvcount.clear();
|
||||||
m_submode = DeleteSubMode;
|
m_submode = DeleteSubMode;
|
||||||
@@ -725,11 +752,11 @@ bool FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
|
|||||||
int beginLine = lineForPosition(m_marks['<']);
|
int beginLine = lineForPosition(m_marks['<']);
|
||||||
int endLine = lineForPosition(m_marks['>']);
|
int endLine = lineForPosition(m_marks['>']);
|
||||||
m_tc = selectRange(beginLine, endLine);
|
m_tc = selectRange(beginLine, endLine);
|
||||||
removeSelectedText(m_tc);
|
recordRemoveSelectedText();
|
||||||
} else if (key == 'D') {
|
} else if (key == 'D') {
|
||||||
m_submode = DeleteSubMode;
|
m_submode = DeleteSubMode;
|
||||||
m_tc.movePosition(Down, KeepAnchor, qMax(count() - 1, 0));
|
moveDown(KeepAnchor, qMax(count() - 1, 0));
|
||||||
m_tc.movePosition(Right, KeepAnchor, rightDist());
|
moveRight(KeepAnchor, rightDist());
|
||||||
finishMovement();
|
finishMovement();
|
||||||
} else if (key == 'e') {
|
} else if (key == 'e') {
|
||||||
moveToWordBoundary(false, true);
|
moveToWordBoundary(false, true);
|
||||||
@@ -752,65 +779,67 @@ bool FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
|
|||||||
int n = qMin(count(), leftDist());
|
int n = qMin(count(), leftDist());
|
||||||
if (m_fakeEnd && m_tc.block().length() > 1)
|
if (m_fakeEnd && m_tc.block().length() > 1)
|
||||||
++n;
|
++n;
|
||||||
m_tc.movePosition(Left, KeepAnchor, n);
|
moveLeft(KeepAnchor, n);
|
||||||
finishMovement();
|
finishMovement();
|
||||||
} else if (key == 'H') {
|
} else if (key == 'H') {
|
||||||
m_tc = EDITOR(cursorForPosition(QPoint(0, 0)));
|
m_tc = EDITOR(cursorForPosition(QPoint(0, 0)));
|
||||||
m_tc.movePosition(Down, KeepAnchor, qMax(count() - 1, 0));
|
moveDown(KeepAnchor, qMax(count() - 1, 0));
|
||||||
moveToFirstNonBlankOnLine();
|
moveToFirstNonBlankOnLine();
|
||||||
finishMovement();
|
finishMovement();
|
||||||
} else if (key == 'i') {
|
} else if (key == 'i') {
|
||||||
enterInsertMode();
|
enterInsertMode();
|
||||||
updateMiniBuffer();
|
updateMiniBuffer();
|
||||||
if (atEol())
|
if (atEol())
|
||||||
m_tc.movePosition(Left, MoveAnchor, 1);
|
moveLeft(MoveAnchor);
|
||||||
} else if (key == 'I') {
|
} else if (key == 'I') {
|
||||||
enterInsertMode();
|
enterInsertMode();
|
||||||
if (m_gflag)
|
if (m_gflag)
|
||||||
m_tc.movePosition(StartOfLine, KeepAnchor);
|
moveToStartOfLine(KeepAnchor);
|
||||||
else
|
else
|
||||||
moveToFirstNonBlankOnLine();
|
moveToFirstNonBlankOnLine();
|
||||||
} else if (key == 'j' || key == Key_Down) {
|
} else if (key == 'j' || key == Key_Down) {
|
||||||
int savedColumn = m_desiredColumn;
|
int savedColumn = m_desiredColumn;
|
||||||
if (m_submode == NoSubMode || m_submode == ZSubMode || m_submode == RegisterSubMode) {
|
if (m_submode == NoSubMode || m_submode == ZSubMode
|
||||||
m_tc.movePosition(Down, KeepAnchor, count());
|
|| m_submode == RegisterSubMode) {
|
||||||
|
moveDown(KeepAnchor, count());
|
||||||
moveToDesiredColumn();
|
moveToDesiredColumn();
|
||||||
} else {
|
} else {
|
||||||
m_tc.movePosition(StartOfLine, MoveAnchor);
|
moveToStartOfLine(MoveAnchor);
|
||||||
m_tc.movePosition(Down, KeepAnchor, count()+1);
|
moveDown(KeepAnchor, count() + 1);
|
||||||
}
|
}
|
||||||
finishMovement();
|
finishMovement();
|
||||||
m_desiredColumn = savedColumn;
|
m_desiredColumn = savedColumn;
|
||||||
} else if (key == 'J') {
|
} else if (key == 'J') {
|
||||||
EditOperation op;
|
recordBeginGroup();
|
||||||
if (m_submode == NoSubMode) {
|
if (m_submode == NoSubMode) {
|
||||||
for (int i = qMax(count(), 2) - 1; --i >= 0; ) {
|
for (int i = qMax(count(), 2) - 1; --i >= 0; ) {
|
||||||
m_tc.movePosition(EndOfLine);
|
moveToEndOfLine(MoveAnchor);
|
||||||
m_tc.deleteChar();
|
recordRemoveNextChar();
|
||||||
if (!m_gflag)
|
if (!m_gflag)
|
||||||
m_tc.insertText(" ");
|
recordInsertText(" ");
|
||||||
}
|
}
|
||||||
if (!m_gflag)
|
if (!m_gflag)
|
||||||
m_tc.movePosition(Left, MoveAnchor, 1);
|
moveLeft(MoveAnchor, 1);
|
||||||
}
|
}
|
||||||
|
recordEndGroup();
|
||||||
} else if (key == 'k' || key == Key_Up) {
|
} else if (key == 'k' || key == Key_Up) {
|
||||||
int savedColumn = m_desiredColumn;
|
int savedColumn = m_desiredColumn;
|
||||||
if (m_submode == NoSubMode || m_submode == ZSubMode || m_submode == RegisterSubMode) {
|
if (m_submode == NoSubMode || m_submode == ZSubMode || m_submode == RegisterSubMode) {
|
||||||
m_tc.movePosition(Up, KeepAnchor, count());
|
moveUp(KeepAnchor, count());
|
||||||
moveToDesiredColumn();
|
moveToDesiredColumn();
|
||||||
} else {
|
} else {
|
||||||
m_tc.movePosition(StartOfLine, MoveAnchor);
|
moveToStartOfLine(MoveAnchor);
|
||||||
m_tc.movePosition(Down, MoveAnchor);
|
moveDown(MoveAnchor);
|
||||||
m_tc.movePosition(Up, KeepAnchor, count()+1);
|
moveUp(KeepAnchor, count() + 1);
|
||||||
}
|
}
|
||||||
finishMovement();
|
finishMovement();
|
||||||
m_desiredColumn = savedColumn;
|
m_desiredColumn = savedColumn;
|
||||||
} else if (key == 'l' || key == Key_Right) {
|
} else if (key == 'l' || key == Key_Right) {
|
||||||
m_tc.movePosition(Right, KeepAnchor, qMin(count(), rightDist()));
|
moveRight(KeepAnchor, qMin(count(), rightDist()));
|
||||||
finishMovement();
|
finishMovement();
|
||||||
} else if (key == 'L') {
|
} else if (key == 'L') {
|
||||||
m_tc = EDITOR(cursorForPosition(QPoint(0, EDITOR(height()))));
|
m_tc = EDITOR(cursorForPosition(QPoint(0, EDITOR(height()))));
|
||||||
m_tc.movePosition(Up, KeepAnchor, qMax(count(), 1));
|
moveUp(KeepAnchor, qMax(count(), 1));
|
||||||
moveToFirstNonBlankOnLine();
|
moveToFirstNonBlankOnLine();
|
||||||
finishMovement();
|
finishMovement();
|
||||||
} else if (key == 'm') {
|
} else if (key == 'm') {
|
||||||
@@ -827,12 +856,12 @@ bool FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
|
|||||||
enterInsertMode();
|
enterInsertMode();
|
||||||
moveToFirstNonBlankOnLine();
|
moveToFirstNonBlankOnLine();
|
||||||
int numSpaces = leftDist();
|
int numSpaces = leftDist();
|
||||||
m_tc.movePosition(Up, MoveAnchor, 1);
|
moveUp(MoveAnchor, 1);
|
||||||
if (key == 'o')
|
if (key == 'o')
|
||||||
m_tc.movePosition(Down, MoveAnchor, 1);
|
m_tc.movePosition(Down, MoveAnchor, 1);
|
||||||
m_tc.movePosition(EndOfLine, MoveAnchor);
|
moveToEndOfLine(MoveAnchor);
|
||||||
m_tc.insertText("\n");
|
m_tc.insertText("\n");
|
||||||
m_tc.movePosition(StartOfLine, MoveAnchor);
|
moveToStartOfLine(MoveAnchor);
|
||||||
if (m_config[ConfigAutoIndent] == ConfigOn)
|
if (m_config[ConfigAutoIndent] == ConfigOn)
|
||||||
m_tc.insertText(QString(indentDist(), ' '));
|
m_tc.insertText(QString(indentDist(), ' '));
|
||||||
else
|
else
|
||||||
@@ -888,24 +917,24 @@ bool FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
|
|||||||
finishMovement("W");
|
finishMovement("W");
|
||||||
} else if (key == 'x') { // = "dl"
|
} else if (key == 'x') { // = "dl"
|
||||||
if (atEol())
|
if (atEol())
|
||||||
m_tc.movePosition(Left, MoveAnchor, 1);
|
moveLeft(MoveAnchor);
|
||||||
m_submode = DeleteSubMode;
|
m_submode = DeleteSubMode;
|
||||||
m_tc.movePosition(Right, KeepAnchor, qMin(count(), rightDist()));
|
moveRight(KeepAnchor, qMin(count(), rightDist()));
|
||||||
finishMovement("l");
|
finishMovement("l");
|
||||||
} else if (key == 'X') {
|
} else if (key == 'X') {
|
||||||
if (leftDist() > 0) {
|
if (leftDist() > 0) {
|
||||||
m_tc.movePosition(Left, KeepAnchor, qMin(count(), leftDist()));
|
moveLeft(KeepAnchor, qMin(count(), leftDist()));
|
||||||
m_tc.deleteChar();
|
m_tc.deleteChar();
|
||||||
}
|
}
|
||||||
finishMovement();
|
finishMovement();
|
||||||
} else if (key == 'y') {
|
} else if (key == 'y') {
|
||||||
if (atEol())
|
if (atEol())
|
||||||
m_tc.movePosition(Left, MoveAnchor, 1);
|
moveLeft(MoveAnchor);
|
||||||
m_submode = YankSubMode;
|
m_submode = YankSubMode;
|
||||||
} else if (key == 'z') {
|
} else if (key == 'z') {
|
||||||
m_submode = ZSubMode;
|
m_submode = ZSubMode;
|
||||||
} else if (key == '~' && !atEol()) {
|
} else if (key == '~' && !atEol()) {
|
||||||
m_tc.movePosition(Right, KeepAnchor, qMin(count(), rightDist()));
|
moveRight(KeepAnchor, qMin(count(), rightDist()));
|
||||||
QString str = m_tc.selectedText();
|
QString str = m_tc.selectedText();
|
||||||
for (int i = str.size(); --i >= 0; ) {
|
for (int i = str.size(); --i >= 0; ) {
|
||||||
QChar c = str.at(i);
|
QChar c = str.at(i);
|
||||||
@@ -914,10 +943,10 @@ bool FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
|
|||||||
m_tc.deleteChar();
|
m_tc.deleteChar();
|
||||||
m_tc.insertText(str);
|
m_tc.insertText(str);
|
||||||
} else if (key == Key_PageDown || key == control('f')) {
|
} else if (key == Key_PageDown || key == control('f')) {
|
||||||
m_tc.movePosition(Down, KeepAnchor, count() * (linesOnScreen() - 2));
|
moveDown(KeepAnchor, count() * (linesOnScreen() - 2));
|
||||||
finishMovement();
|
finishMovement();
|
||||||
} else if (key == Key_PageUp || key == control('b')) {
|
} else if (key == Key_PageUp || key == control('b')) {
|
||||||
m_tc.movePosition(Up, KeepAnchor, count() * (linesOnScreen() - 2));
|
moveUp(KeepAnchor, count() * (linesOnScreen() - 2));
|
||||||
finishMovement();
|
finishMovement();
|
||||||
} else if (key == Key_Backspace || key == control('h')) {
|
} else if (key == Key_Backspace || key == control('h')) {
|
||||||
m_tc.deletePreviousChar();
|
m_tc.deletePreviousChar();
|
||||||
@@ -946,21 +975,21 @@ bool FakeVimHandler::Private::handleInsertMode(int key, int, const QString &text
|
|||||||
data += m_lastInsertion;
|
data += m_lastInsertion;
|
||||||
}
|
}
|
||||||
recordInsert(m_tc.position() - m_lastInsertion.size(), data);
|
recordInsert(m_tc.position() - m_lastInsertion.size(), data);
|
||||||
m_tc.movePosition(Left, MoveAnchor, qMin(1, leftDist()));
|
moveLeft(MoveAnchor, qMin(1, leftDist()));
|
||||||
enterCommandMode();
|
enterCommandMode();
|
||||||
} else if (key == Key_Left) {
|
} else if (key == Key_Left) {
|
||||||
m_tc.movePosition(Left, MoveAnchor, 1);
|
moveLeft(MoveAnchor, count());
|
||||||
m_lastInsertion.clear();
|
m_lastInsertion.clear();
|
||||||
} else if (key == Key_Down) {
|
} else if (key == Key_Down) {
|
||||||
m_submode = NoSubMode;
|
m_submode = NoSubMode;
|
||||||
m_tc.movePosition(Down, MoveAnchor, 1);
|
moveDown(MoveAnchor, count());
|
||||||
m_lastInsertion.clear();
|
m_lastInsertion.clear();
|
||||||
} else if (key == Key_Up) {
|
} else if (key == Key_Up) {
|
||||||
m_submode = NoSubMode;
|
m_submode = NoSubMode;
|
||||||
m_tc.movePosition(Up, MoveAnchor, 1);
|
moveUp(MoveAnchor, count());
|
||||||
m_lastInsertion.clear();
|
m_lastInsertion.clear();
|
||||||
} else if (key == Key_Right) {
|
} else if (key == Key_Right) {
|
||||||
m_tc.movePosition(Right, MoveAnchor, 1);
|
moveRight(MoveAnchor, count());
|
||||||
m_lastInsertion.clear();
|
m_lastInsertion.clear();
|
||||||
} else if (key == Key_Return) {
|
} else if (key == Key_Return) {
|
||||||
m_submode = NoSubMode;
|
m_submode = NoSubMode;
|
||||||
@@ -974,10 +1003,10 @@ bool FakeVimHandler::Private::handleInsertMode(int key, int, const QString &text
|
|||||||
m_tc.deleteChar();
|
m_tc.deleteChar();
|
||||||
m_lastInsertion.clear();
|
m_lastInsertion.clear();
|
||||||
} else if (key == Key_PageDown || key == control('f')) {
|
} else if (key == Key_PageDown || key == control('f')) {
|
||||||
m_tc.movePosition(Down, KeepAnchor, count() * (linesOnScreen() - 2));
|
moveDown(KeepAnchor, count() * (linesOnScreen() - 2));
|
||||||
m_lastInsertion.clear();
|
m_lastInsertion.clear();
|
||||||
} else if (key == Key_PageUp || key == control('b')) {
|
} else if (key == Key_PageUp || key == control('b')) {
|
||||||
m_tc.movePosition(Up, KeepAnchor, count() * (linesOnScreen() - 2));
|
moveUp(KeepAnchor, count() * (linesOnScreen() - 2));
|
||||||
m_lastInsertion.clear();
|
m_lastInsertion.clear();
|
||||||
} else if (key == Key_Tab && m_config[ConfigExpandTab] == ConfigOn) {
|
} else if (key == Key_Tab && m_config[ConfigExpandTab] == ConfigOn) {
|
||||||
QString str = QString(m_config[ConfigTabStop].toInt(), ' ');
|
QString str = QString(m_config[ConfigTabStop].toInt(), ' ');
|
||||||
@@ -1707,13 +1736,41 @@ void FakeVimHandler::Private::redo()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void FakeVimHandler::Private::removeSelectedText(QTextCursor &tc)
|
void FakeVimHandler::Private::recordBeginGroup()
|
||||||
|
{
|
||||||
|
m_undoGroupStack.push(m_undoStack.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
void FakeVimHandler::Private::recordEndGroup()
|
||||||
{
|
{
|
||||||
EditOperation op;
|
EditOperation op;
|
||||||
op.m_position = qMin(tc.position(), tc.anchor());
|
op.m_itemCount = m_undoStack.size() - m_undoGroupStack.pop();
|
||||||
op.m_from = tc.selection().toPlainText();
|
|
||||||
recordOperation(op);
|
recordOperation(op);
|
||||||
tc.removeSelectedText();
|
}
|
||||||
|
|
||||||
|
void FakeVimHandler::Private::recordRemoveSelectedText()
|
||||||
|
{
|
||||||
|
EditOperation op;
|
||||||
|
op.m_position = qMin(m_tc.position(), m_tc.anchor());
|
||||||
|
op.m_from = m_tc.selection().toPlainText();
|
||||||
|
recordOperation(op);
|
||||||
|
m_tc.removeSelectedText();
|
||||||
|
}
|
||||||
|
|
||||||
|
void FakeVimHandler::Private::recordRemoveNextChar()
|
||||||
|
{
|
||||||
|
m_tc.setPosition(m_tc.position(), MoveAnchor);
|
||||||
|
m_tc.movePosition(Right, KeepAnchor);
|
||||||
|
recordRemoveSelectedText();
|
||||||
|
}
|
||||||
|
|
||||||
|
void FakeVimHandler::Private::recordInsertText(const QString &data)
|
||||||
|
{
|
||||||
|
EditOperation op;
|
||||||
|
op.m_position = m_tc.position();
|
||||||
|
op.m_to = data;
|
||||||
|
recordOperation(op);
|
||||||
|
m_tc.insertText(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FakeVimHandler::Private::recordOperation(const EditOperation &op)
|
void FakeVimHandler::Private::recordOperation(const EditOperation &op)
|
||||||
|
|||||||
Reference in New Issue
Block a user