forked from qt-creator/qt-creator
more status line work
This commit is contained in:
@@ -167,7 +167,7 @@ public:
|
|||||||
void moveToNextWord(bool simple);
|
void moveToNextWord(bool simple);
|
||||||
void moveToWordBoundary(bool simple, bool forward);
|
void moveToWordBoundary(bool simple, bool forward);
|
||||||
void handleFfTt(int key);
|
void handleFfTt(int key);
|
||||||
void handleCommand(const QString &cmd);
|
void handleExCommand(const QString &cmd);
|
||||||
|
|
||||||
// helper function for handleCommand. return 1 based line index.
|
// helper function for handleCommand. return 1 based line index.
|
||||||
int readLineCode(QString &cmd);
|
int readLineCode(QString &cmd);
|
||||||
@@ -734,8 +734,7 @@ void FakeVimHandler::Private::handleExMode(int key, const QString &text)
|
|||||||
if (!m_commandBuffer.isEmpty()) {
|
if (!m_commandBuffer.isEmpty()) {
|
||||||
m_commandHistory.takeLast();
|
m_commandHistory.takeLast();
|
||||||
m_commandHistory.append(m_commandBuffer);
|
m_commandHistory.append(m_commandBuffer);
|
||||||
handleCommand(m_commandBuffer);
|
handleExCommand(m_commandBuffer);
|
||||||
m_commandBuffer.clear();
|
|
||||||
m_commandCode = 0;
|
m_commandCode = 0;
|
||||||
}
|
}
|
||||||
m_mode = CommandMode;
|
m_mode = CommandMode;
|
||||||
@@ -745,7 +744,6 @@ void FakeVimHandler::Private::handleExMode(int key, const QString &text)
|
|||||||
m_searchHistory.append(m_commandBuffer);
|
m_searchHistory.append(m_commandBuffer);
|
||||||
m_lastSearchForward = (m_commandCode == '/');
|
m_lastSearchForward = (m_commandCode == '/');
|
||||||
search(lastSearchString(), m_lastSearchForward);
|
search(lastSearchString(), m_lastSearchForward);
|
||||||
m_commandBuffer.clear();
|
|
||||||
m_commandCode = 0;
|
m_commandCode = 0;
|
||||||
}
|
}
|
||||||
m_mode = CommandMode;
|
m_mode = CommandMode;
|
||||||
@@ -839,7 +837,7 @@ QTextCursor FakeVimHandler::Private::selectRange(int beginLine, int endLine)
|
|||||||
return tc;
|
return tc;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FakeVimHandler::Private::handleCommand(const QString &cmd0)
|
void FakeVimHandler::Private::handleExCommand(const QString &cmd0)
|
||||||
{
|
{
|
||||||
QString cmd = cmd0;
|
QString cmd = cmd0;
|
||||||
if (cmd.startsWith("%"))
|
if (cmd.startsWith("%"))
|
||||||
@@ -850,6 +848,7 @@ void FakeVimHandler::Private::handleCommand(const QString &cmd0)
|
|||||||
|
|
||||||
int line = readLineCode(cmd);
|
int line = readLineCode(cmd);
|
||||||
if (line != -1)
|
if (line != -1)
|
||||||
|
m_mode = CommandMode;
|
||||||
beginLine = line;
|
beginLine = line;
|
||||||
|
|
||||||
if (cmd.startsWith(',')) {
|
if (cmd.startsWith(',')) {
|
||||||
@@ -881,6 +880,7 @@ void FakeVimHandler::Private::handleCommand(const QString &cmd0)
|
|||||||
m_registers[reg.at(0).unicode()] = tc.selection().toPlainText();
|
m_registers[reg.at(0).unicode()] = tc.selection().toPlainText();
|
||||||
tc.removeSelectedText();
|
tc.removeSelectedText();
|
||||||
} else if (reWrite.indexIn(cmd) != -1) { // :w
|
} else if (reWrite.indexIn(cmd) != -1) { // :w
|
||||||
|
bool noArgs = (beginLine == -1);
|
||||||
if (beginLine == -1)
|
if (beginLine == -1)
|
||||||
beginLine = 0;
|
beginLine = 0;
|
||||||
if (endLine == -1)
|
if (endLine == -1)
|
||||||
@@ -891,7 +891,7 @@ void FakeVimHandler::Private::handleCommand(const QString &cmd0)
|
|||||||
fileName = m_currentFileName;
|
fileName = m_currentFileName;
|
||||||
QFile file(fileName);
|
QFile file(fileName);
|
||||||
bool exists = file.exists();
|
bool exists = file.exists();
|
||||||
if (exists && !forced) {
|
if (exists && !forced && !noArgs) {
|
||||||
showMessage("E13: File exists (add ! to override)");
|
showMessage("E13: File exists (add ! to override)");
|
||||||
} else {
|
} else {
|
||||||
file.open(QIODevice::ReadWrite);
|
file.open(QIODevice::ReadWrite);
|
||||||
@@ -905,6 +905,7 @@ void FakeVimHandler::Private::handleCommand(const QString &cmd0)
|
|||||||
m_commandBuffer = QString("\"%1\" %2 %3L, %4C written")
|
m_commandBuffer = QString("\"%1\" %2 %3L, %4C written")
|
||||||
.arg(fileName).arg(exists ? " " : " [New] ")
|
.arg(fileName).arg(exists ? " " : " [New] ")
|
||||||
.arg(ba.count('\n')).arg(ba.size());
|
.arg(ba.count('\n')).arg(ba.size());
|
||||||
|
m_mode = CommandMode;
|
||||||
updateMiniBuffer();
|
updateMiniBuffer();
|
||||||
}
|
}
|
||||||
} else if (cmd.startsWith("r ")) { // :r
|
} else if (cmd.startsWith("r ")) { // :r
|
||||||
@@ -916,6 +917,7 @@ void FakeVimHandler::Private::handleCommand(const QString &cmd0)
|
|||||||
EDITOR(setPlainText(data));
|
EDITOR(setPlainText(data));
|
||||||
m_commandBuffer = QString("\"%1\" %2L, %3C")
|
m_commandBuffer = QString("\"%1\" %2L, %3C")
|
||||||
.arg(m_currentFileName).arg(data.count('\n')).arg(data.size());
|
.arg(m_currentFileName).arg(data.count('\n')).arg(data.size());
|
||||||
|
m_mode = CommandMode;
|
||||||
updateMiniBuffer();
|
updateMiniBuffer();
|
||||||
} else {
|
} else {
|
||||||
showMessage("E492: Not an editor command: " + cmd0);
|
showMessage("E492: Not an editor command: " + cmd0);
|
||||||
@@ -1281,6 +1283,6 @@ void FakeVimHandler::handleCommand(QWidget *widget, const QString &cmd)
|
|||||||
{
|
{
|
||||||
d->m_textedit = qobject_cast<QTextEdit *>(widget);
|
d->m_textedit = qobject_cast<QTextEdit *>(widget);
|
||||||
d->m_plaintextedit = qobject_cast<QPlainTextEdit *>(widget);
|
d->m_plaintextedit = qobject_cast<QPlainTextEdit *>(widget);
|
||||||
d->handleCommand(cmd);
|
d->handleExCommand(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user