forked from qt-creator/qt-creator
introduce history for ex commands
This commit is contained in:
@@ -278,7 +278,7 @@ void FakeVimHandler::Private::updateMiniBuffer()
|
|||||||
msg = QChar(m_commandCode ? m_commandCode : ' ');
|
msg = QChar(m_commandCode ? m_commandCode : ' ');
|
||||||
for (int i = 0; i != m_commandBuffer.size(); ++i) {
|
for (int i = 0; i != m_commandBuffer.size(); ++i) {
|
||||||
QChar c = m_commandBuffer.at(i);
|
QChar c = m_commandBuffer.at(i);
|
||||||
if (c.unicode() < 64) {
|
if (c.unicode() < 32) {
|
||||||
msg += '^';
|
msg += '^';
|
||||||
msg += QChar(c.unicode() + 64);
|
msg += QChar(c.unicode() + 64);
|
||||||
} else {
|
} else {
|
||||||
@@ -601,27 +601,44 @@ void FakeVimHandler::Private::handleExMode(int key, const QString &text)
|
|||||||
m_commandBuffer.chop(1);
|
m_commandBuffer.chop(1);
|
||||||
updateMiniBuffer();
|
updateMiniBuffer();
|
||||||
} else if (key == Key_Return && m_commandCode == ':') {
|
} else if (key == Key_Return && m_commandCode == ':') {
|
||||||
|
if (!m_commandBuffer.isEmpty()) {
|
||||||
|
m_commandHistory.takeLast();
|
||||||
|
m_commandHistory.append(m_commandBuffer);
|
||||||
handleCommand(m_commandBuffer);
|
handleCommand(m_commandBuffer);
|
||||||
m_commandBuffer.clear();
|
m_commandBuffer.clear();
|
||||||
|
m_commandCode = 0;
|
||||||
|
}
|
||||||
m_mode = CommandMode;
|
m_mode = CommandMode;
|
||||||
|
updateMiniBuffer();
|
||||||
} else if (key == Key_Return && isSearchCommand()) {
|
} else if (key == Key_Return && isSearchCommand()) {
|
||||||
m_lastSearchForward = (m_commandCode == '/');
|
if (!m_commandBuffer.isEmpty()) {
|
||||||
|
m_searchHistory.takeLast();
|
||||||
m_searchHistory.append(m_commandBuffer);
|
m_searchHistory.append(m_commandBuffer);
|
||||||
|
m_lastSearchForward = (m_commandCode == '/');
|
||||||
search(lastSearchString(), m_lastSearchForward);
|
search(lastSearchString(), m_lastSearchForward);
|
||||||
m_commandBuffer.clear();
|
m_commandBuffer.clear();
|
||||||
m_commandCode = 0;
|
m_commandCode = 0;
|
||||||
|
}
|
||||||
m_mode = CommandMode;
|
m_mode = CommandMode;
|
||||||
updateMiniBuffer();
|
updateMiniBuffer();
|
||||||
} else if (key == Key_Up && isSearchCommand()) {
|
} else if (key == Key_Up) {
|
||||||
if (m_searchHistoryIndex > 0) {
|
if (isSearchCommand() && m_searchHistoryIndex > 0) {
|
||||||
--m_searchHistoryIndex;
|
--m_searchHistoryIndex;
|
||||||
m_commandBuffer = m_searchHistory.at(m_searchHistoryIndex);
|
m_commandBuffer = m_searchHistory.at(m_searchHistoryIndex);
|
||||||
|
} else if (m_commandCode == ':' && m_commandHistoryIndex > 0) {
|
||||||
|
--m_commandHistoryIndex;
|
||||||
|
m_commandBuffer = m_commandHistory.at(m_commandHistoryIndex);
|
||||||
}
|
}
|
||||||
updateMiniBuffer();
|
updateMiniBuffer();
|
||||||
} else if (key == Key_Down && isSearchCommand()) {
|
} else if (key == Key_Down) {
|
||||||
if (m_searchHistoryIndex < m_searchHistory.size() - 1) {
|
if (isSearchCommand()
|
||||||
|
&& m_searchHistoryIndex < m_searchHistory.size() - 1) {
|
||||||
++m_searchHistoryIndex;
|
++m_searchHistoryIndex;
|
||||||
m_commandBuffer = m_searchHistory.at(m_searchHistoryIndex);
|
m_commandBuffer = m_searchHistory.at(m_searchHistoryIndex);
|
||||||
|
} else if (m_commandCode == ':'
|
||||||
|
&& m_commandHistoryIndex < m_commandHistory.size() - 1) {
|
||||||
|
++m_commandHistoryIndex;
|
||||||
|
m_commandBuffer = m_commandHistory.at(m_commandHistoryIndex);
|
||||||
}
|
}
|
||||||
updateMiniBuffer();
|
updateMiniBuffer();
|
||||||
} else if (key == Key_Tab) {
|
} else if (key == Key_Tab) {
|
||||||
|
|||||||
Reference in New Issue
Block a user