forked from qt-creator/qt-creator
fakevim: more interaction for entering ex commands
Change-Id: I64e4d662fa9c89d4ac6a6d8b83711f01780ceaa6 Reviewed-on: http://codereview.qt.nokia.com/1700 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: hjk <qthjk@ovi.com>
This commit is contained in:
@@ -312,7 +312,6 @@ QDebug operator<<(QDebug ts, const Range &range)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ExCommand::ExCommand(const QString &c, const QString &a, const Range &r)
|
ExCommand::ExCommand(const QString &c, const QString &a, const Range &r)
|
||||||
: cmd(c), hasBang(false), args(a), range(r), count(1)
|
: cmd(c), hasBang(false), args(a), range(r), count(1)
|
||||||
{}
|
{}
|
||||||
@@ -517,6 +516,69 @@ void Inputs::parseFrom(const QString &str)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This wraps a string and a "cursor position".
|
||||||
|
class CommandBuffer
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CommandBuffer() : m_pos(0) {}
|
||||||
|
|
||||||
|
void clear() { m_buffer.clear(); m_pos = 0; }
|
||||||
|
void setContents(const QString &s) { m_buffer = s; m_pos = s.size(); }
|
||||||
|
QString contents() const { return m_buffer; }
|
||||||
|
bool isEmpty() const { return m_buffer.isEmpty(); }
|
||||||
|
int cursorPos() const { return m_pos; }
|
||||||
|
|
||||||
|
void insertChar(QChar c) { m_buffer.insert(m_pos++, c); }
|
||||||
|
void insertText(const QString &s) { m_buffer.insert(m_pos, s); m_pos += s.size(); }
|
||||||
|
void deleteChar() { if (m_pos) m_buffer.remove(--m_pos, 1); }
|
||||||
|
|
||||||
|
void moveLeft() { if (m_pos) --m_pos; }
|
||||||
|
void moveRight() { if (m_pos < m_buffer.size()) ++m_pos; }
|
||||||
|
void moveStart() { m_pos = 0; }
|
||||||
|
void moveEnd() { m_pos = m_buffer.size(); }
|
||||||
|
|
||||||
|
QString display() const
|
||||||
|
{
|
||||||
|
QString msg;
|
||||||
|
for (int i = 0; i != m_buffer.size(); ++i) {
|
||||||
|
const QChar c = m_buffer.at(i);
|
||||||
|
if (c.unicode() < 32) {
|
||||||
|
msg += '^';
|
||||||
|
msg += QChar(c.unicode() + 64);
|
||||||
|
} else {
|
||||||
|
msg += c;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool handleInput(const Input &input)
|
||||||
|
{
|
||||||
|
if (input.isKey(Key_Left)) {
|
||||||
|
moveLeft();
|
||||||
|
} else if (input.isKey(Key_Right)) {
|
||||||
|
moveRight();
|
||||||
|
} else if (input.isKey(Key_Home)) {
|
||||||
|
moveStart();
|
||||||
|
} else if (input.isKey(Key_End)) {
|
||||||
|
moveEnd();
|
||||||
|
} else if (input.isKey(Key_Delete)) {
|
||||||
|
if (m_pos < m_buffer.size())
|
||||||
|
m_buffer.remove(m_pos, 1);
|
||||||
|
} else if (!input.text().isEmpty()) {
|
||||||
|
insertText(input.text());
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
QString m_buffer;
|
||||||
|
int m_pos;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
class History
|
class History
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -839,7 +901,7 @@ public:
|
|||||||
int m_gflag; // whether current command started with 'g'
|
int m_gflag; // whether current command started with 'g'
|
||||||
|
|
||||||
QString m_commandPrefix;
|
QString m_commandPrefix;
|
||||||
QString m_commandBuffer;
|
CommandBuffer m_commandBuffer;
|
||||||
QString m_currentFileName;
|
QString m_currentFileName;
|
||||||
QString m_currentMessage;
|
QString m_currentMessage;
|
||||||
|
|
||||||
@@ -1438,7 +1500,7 @@ void FakeVimHandler::Private::finishMovement(const QString &dotCommand)
|
|||||||
setPosition(qMin(anchor(), position()));
|
setPosition(qMin(anchor(), position()));
|
||||||
enterExMode();
|
enterExMode();
|
||||||
m_currentMessage.clear();
|
m_currentMessage.clear();
|
||||||
m_commandBuffer = QString(".,+%1!").arg(qAbs(endLine - beginLine));
|
m_commandBuffer.setContents(QString(".,+%1!").arg(qAbs(endLine - beginLine)));
|
||||||
//g.commandHistory.append(QString());
|
//g.commandHistory.append(QString());
|
||||||
updateMiniBuffer();
|
updateMiniBuffer();
|
||||||
return;
|
return;
|
||||||
@@ -1613,6 +1675,7 @@ void FakeVimHandler::Private::updateMiniBuffer()
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
QString msg;
|
QString msg;
|
||||||
|
int cursorPos = -1;
|
||||||
if (m_passing) {
|
if (m_passing) {
|
||||||
msg = "-- PASSING -- ";
|
msg = "-- PASSING -- ";
|
||||||
} else if (!m_currentMessage.isEmpty()) {
|
} else if (!m_currentMessage.isEmpty()) {
|
||||||
@@ -1632,23 +1695,15 @@ void FakeVimHandler::Private::updateMiniBuffer()
|
|||||||
} else if (!m_commandPrefix.isEmpty()) {
|
} else if (!m_commandPrefix.isEmpty()) {
|
||||||
//QTC_ASSERT(m_mode == ExMode || m_subsubmode == SearchSubSubMode,
|
//QTC_ASSERT(m_mode == ExMode || m_subsubmode == SearchSubSubMode,
|
||||||
// qDebug() << "MODE: " << m_mode << m_subsubmode);
|
// qDebug() << "MODE: " << m_mode << m_subsubmode);
|
||||||
msg = m_commandPrefix;
|
msg = m_commandPrefix + m_commandBuffer.display();
|
||||||
foreach (QChar c, m_commandBuffer) {
|
if (m_mode != CommandMode)
|
||||||
if (c.unicode() < 32) {
|
cursorPos = m_commandPrefix.size() + m_commandBuffer.cursorPos();
|
||||||
msg += '^';
|
|
||||||
msg += QChar(c.unicode() + 64);
|
|
||||||
} else {
|
|
||||||
msg += c;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!msg.isEmpty() && m_mode != CommandMode)
|
|
||||||
msg += QChar(10073); // '|'; // FIXME: Use a real "cursor"
|
|
||||||
} else {
|
} else {
|
||||||
QTC_CHECK(m_mode == CommandMode && m_subsubmode != SearchSubSubMode);
|
QTC_CHECK(m_mode == CommandMode && m_subsubmode != SearchSubSubMode);
|
||||||
msg = "-- COMMAND --";
|
msg = "-- COMMAND --";
|
||||||
}
|
}
|
||||||
|
|
||||||
emit q->commandBufferChanged(msg);
|
emit q->commandBufferChanged(msg, cursorPos);
|
||||||
|
|
||||||
int linesInDoc = linesInDocument();
|
int linesInDoc = linesInDocument();
|
||||||
int l = cursorLine();
|
int l = cursorLine();
|
||||||
@@ -1674,7 +1729,7 @@ void FakeVimHandler::Private::showRedMessage(const QString &msg)
|
|||||||
void FakeVimHandler::Private::showBlackMessage(const QString &msg)
|
void FakeVimHandler::Private::showBlackMessage(const QString &msg)
|
||||||
{
|
{
|
||||||
//qDebug() << "MSG: " << msg;
|
//qDebug() << "MSG: " << msg;
|
||||||
m_commandBuffer = msg;
|
m_commandBuffer.setContents(msg);
|
||||||
updateMiniBuffer();
|
updateMiniBuffer();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1977,7 +2032,7 @@ EventResult FakeVimHandler::Private::handleCommandMode1(const Input &input)
|
|||||||
m_currentMessage.clear();
|
m_currentMessage.clear();
|
||||||
m_commandBuffer.clear();
|
m_commandBuffer.clear();
|
||||||
if (isVisualMode())
|
if (isVisualMode())
|
||||||
m_commandBuffer = "'<,'>";
|
m_commandBuffer.setContents("'<,'>");
|
||||||
updateMiniBuffer();
|
updateMiniBuffer();
|
||||||
} else if (input.is('/') || input.is('?')) {
|
} else if (input.is('/') || input.is('?')) {
|
||||||
m_lastSearchForward = input.is('/');
|
m_lastSearchForward = input.is('/');
|
||||||
@@ -2014,7 +2069,7 @@ EventResult FakeVimHandler::Private::handleCommandMode1(const Input &input)
|
|||||||
m_lastSearchForward = input.is('*');
|
m_lastSearchForward = input.is('*');
|
||||||
m_currentMessage.clear();
|
m_currentMessage.clear();
|
||||||
m_commandPrefix = QLatin1Char(m_lastSearchForward ? '/' : '?');
|
m_commandPrefix = QLatin1Char(m_lastSearchForward ? '/' : '?');
|
||||||
m_commandBuffer = needle;
|
m_commandBuffer.setContents(needle);
|
||||||
SearchData sd;
|
SearchData sd;
|
||||||
sd.needle = needle;
|
sd.needle = needle;
|
||||||
sd.forward = m_lastSearchForward;
|
sd.forward = m_lastSearchForward;
|
||||||
@@ -2038,7 +2093,7 @@ EventResult FakeVimHandler::Private::handleCommandMode1(const Input &input)
|
|||||||
} else if (input.is('!') && isVisualMode()) {
|
} else if (input.is('!') && isVisualMode()) {
|
||||||
enterExMode();
|
enterExMode();
|
||||||
m_currentMessage.clear();
|
m_currentMessage.clear();
|
||||||
m_commandBuffer = "'<,'>!";
|
m_commandBuffer.setContents("'<,'>!");
|
||||||
//g.commandHistory.append(QString());
|
//g.commandHistory.append(QString());
|
||||||
updateMiniBuffer();
|
updateMiniBuffer();
|
||||||
} else if (input.is('"')) {
|
} else if (input.is('"')) {
|
||||||
@@ -2938,7 +2993,7 @@ EventResult FakeVimHandler::Private::handleExMode(const Input &input)
|
|||||||
updateMiniBuffer();
|
updateMiniBuffer();
|
||||||
m_ctrlVActive = false;
|
m_ctrlVActive = false;
|
||||||
} else if (m_ctrlVActive) {
|
} else if (m_ctrlVActive) {
|
||||||
m_commandBuffer += input.raw();
|
m_commandBuffer.insertChar(input.raw());
|
||||||
m_ctrlVActive = false;
|
m_ctrlVActive = false;
|
||||||
} else if (input.isControl('v')) {
|
} else if (input.isControl('v')) {
|
||||||
m_ctrlVActive = true;
|
m_ctrlVActive = true;
|
||||||
@@ -2947,40 +3002,37 @@ EventResult FakeVimHandler::Private::handleExMode(const Input &input)
|
|||||||
m_commandPrefix.clear();
|
m_commandPrefix.clear();
|
||||||
enterCommandMode();
|
enterCommandMode();
|
||||||
} else {
|
} else {
|
||||||
m_commandBuffer.chop(1);
|
m_commandBuffer.deleteChar();
|
||||||
}
|
}
|
||||||
updateMiniBuffer();
|
updateMiniBuffer();
|
||||||
} else if (input.isKey(Key_Tab)) {
|
} else if (input.isKey(Key_Tab)) {
|
||||||
QStringList completions;
|
QStringList completions;
|
||||||
foreach (const QString &entry, g.commandHistory.items()) {
|
foreach (const QString &entry, g.commandHistory.items()) {
|
||||||
if (entry.startsWith(m_commandBuffer))
|
if (entry.startsWith(m_commandBuffer.contents()))
|
||||||
completions.append(entry);
|
completions.append(entry);
|
||||||
}
|
}
|
||||||
qDebug() << completions;
|
qDebug() << completions;
|
||||||
} else if (input.isKey(Key_Left)) {
|
} else if (input.isKey(Key_Left)) {
|
||||||
// FIXME:
|
m_commandBuffer.moveLeft();
|
||||||
if (!m_commandBuffer.isEmpty())
|
|
||||||
m_commandBuffer.chop(1);
|
|
||||||
updateMiniBuffer();
|
updateMiniBuffer();
|
||||||
} else if (input.isReturn()) {
|
} else if (input.isReturn()) {
|
||||||
if (!m_commandBuffer.isEmpty()) {
|
if (!m_commandBuffer.isEmpty()) {
|
||||||
//g.commandHistory.takeLast();
|
//g.commandHistory.takeLast();
|
||||||
g.commandHistory.append(m_commandBuffer);
|
g.commandHistory.append(m_commandBuffer.contents());
|
||||||
handleExCommand(m_commandBuffer);
|
handleExCommand(m_commandBuffer.contents());
|
||||||
if (m_textedit || m_plaintextedit)
|
if (m_textedit || m_plaintextedit)
|
||||||
leaveVisualMode();
|
leaveVisualMode();
|
||||||
}
|
}
|
||||||
updateMiniBuffer();
|
updateMiniBuffer();
|
||||||
} else if (input.isKey(Key_Up) || input.isKey(Key_PageUp)) {
|
} else if (input.isKey(Key_Up) || input.isKey(Key_PageUp)) {
|
||||||
g.commandHistory.up();
|
g.commandHistory.up();
|
||||||
m_commandBuffer = g.commandHistory.current();
|
m_commandBuffer.setContents(g.commandHistory.current());
|
||||||
updateMiniBuffer();
|
updateMiniBuffer();
|
||||||
} else if (input.isKey(Key_Down) || input.isKey(Key_PageDown)) {
|
} else if (input.isKey(Key_Down) || input.isKey(Key_PageDown)) {
|
||||||
g.commandHistory.down();
|
g.commandHistory.down();
|
||||||
m_commandBuffer = g.commandHistory.current();
|
m_commandBuffer.setContents(g.commandHistory.current());
|
||||||
updateMiniBuffer();
|
updateMiniBuffer();
|
||||||
} else if (!input.text().isEmpty()) {
|
} else if (m_commandBuffer.handleInput(input)) {
|
||||||
m_commandBuffer += input.text();
|
|
||||||
updateMiniBuffer();
|
updateMiniBuffer();
|
||||||
} else {
|
} else {
|
||||||
qDebug() << "IGNORED IN EX-MODE: " << input.key() << input.text();
|
qDebug() << "IGNORED IN EX-MODE: " << input.key() << input.text();
|
||||||
@@ -3004,16 +3056,18 @@ EventResult FakeVimHandler::Private::handleSearchSubSubMode(const Input &input)
|
|||||||
m_searchCursor = QTextCursor();
|
m_searchCursor = QTextCursor();
|
||||||
enterCommandMode();
|
enterCommandMode();
|
||||||
} else {
|
} else {
|
||||||
m_commandBuffer.chop(1);
|
m_commandBuffer.deleteChar();
|
||||||
}
|
}
|
||||||
updateMiniBuffer();
|
updateMiniBuffer();
|
||||||
} else if (input.isKey(Key_Left)) {
|
} else if (input.isKey(Key_Left)) {
|
||||||
if (!m_commandBuffer.isEmpty())
|
m_commandBuffer.moveLeft();
|
||||||
m_commandBuffer.chop(1);
|
updateMiniBuffer();
|
||||||
|
} else if (input.isKey(Key_Right)) {
|
||||||
|
m_commandBuffer.moveRight();
|
||||||
updateMiniBuffer();
|
updateMiniBuffer();
|
||||||
} else if (input.isReturn()) {
|
} else if (input.isReturn()) {
|
||||||
m_searchCursor = QTextCursor();
|
m_searchCursor = QTextCursor();
|
||||||
QString needle = m_commandBuffer;
|
QString needle = m_commandBuffer.contents();
|
||||||
if (!needle.isEmpty()) {
|
if (!needle.isEmpty()) {
|
||||||
g.searchHistory.append(needle);
|
g.searchHistory.append(needle);
|
||||||
if (!hasConfig(ConfigIncSearch)) {
|
if (!hasConfig(ConfigIncSearch)) {
|
||||||
@@ -3038,16 +3092,15 @@ EventResult FakeVimHandler::Private::handleSearchSubSubMode(const Input &input)
|
|||||||
g.searchHistory.down();
|
g.searchHistory.down();
|
||||||
showBlackMessage(g.searchHistory.current());
|
showBlackMessage(g.searchHistory.current());
|
||||||
} else if (input.isKey(Key_Tab)) {
|
} else if (input.isKey(Key_Tab)) {
|
||||||
m_commandBuffer += QChar(9);
|
m_commandBuffer.insertChar(QChar(9));
|
||||||
updateMiniBuffer();
|
updateMiniBuffer();
|
||||||
} else if (!input.text().isEmpty()) {
|
} else if (m_commandBuffer.handleInput(input)) {
|
||||||
m_commandBuffer += input.text();
|
|
||||||
updateMiniBuffer();
|
updateMiniBuffer();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hasConfig(ConfigIncSearch) && !input.isReturn() && !input.isEscape()) {
|
if (hasConfig(ConfigIncSearch) && !input.isReturn() && !input.isEscape()) {
|
||||||
SearchData sd;
|
SearchData sd;
|
||||||
sd.needle = m_commandBuffer;
|
sd.needle = m_commandBuffer.contents();
|
||||||
sd.forward = m_lastSearchForward;
|
sd.forward = m_lastSearchForward;
|
||||||
sd.mustMove = false;
|
sd.mustMove = false;
|
||||||
sd.highlightCursor = true;
|
sd.highlightCursor = true;
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ public slots:
|
|||||||
QString tabExpand(int n) const;
|
QString tabExpand(int n) const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void commandBufferChanged(const QString &msg);
|
void commandBufferChanged(const QString &msg, int pos);
|
||||||
void statusDataChanged(const QString &msg);
|
void statusDataChanged(const QString &msg);
|
||||||
void extraInformationChanged(const QString &msg);
|
void extraInformationChanged(const QString &msg);
|
||||||
void selectionChanged(const QList<QTextEdit::ExtraSelection> &selection);
|
void selectionChanged(const QList<QTextEdit::ExtraSelection> &selection);
|
||||||
|
|||||||
@@ -75,6 +75,7 @@
|
|||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
#include <utils/savedaction.h>
|
#include <utils/savedaction.h>
|
||||||
#include <utils/treewidgetcolumnstretcher.h>
|
#include <utils/treewidgetcolumnstretcher.h>
|
||||||
|
#include <utils/stylehelper.h>
|
||||||
|
|
||||||
#include <cppeditor/cppeditorconstants.h>
|
#include <cppeditor/cppeditorconstants.h>
|
||||||
|
|
||||||
@@ -121,6 +122,51 @@ const char * const SETTINGS_USER_CMDS_ID = "C.UserCommands";
|
|||||||
namespace FakeVim {
|
namespace FakeVim {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
|
class MiniBuffer : public QLabel
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
void setContents(const QString &contents, int cursorPos)
|
||||||
|
{
|
||||||
|
QString msg = contents;
|
||||||
|
if (cursorPos != -1)
|
||||||
|
msg = contents.left(cursorPos) + QChar(10073) + contents.mid(cursorPos);
|
||||||
|
setText(" " + msg);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class MiniBuffer1 : public QLineEdit
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
MiniBuffer1()
|
||||||
|
{
|
||||||
|
setFrame(false);
|
||||||
|
}
|
||||||
|
void showEvent(QShowEvent *ev)
|
||||||
|
{
|
||||||
|
QLineEdit::showEvent(ev);
|
||||||
|
QColor color = Qt::black;
|
||||||
|
QPalette pal = parentWidget()->palette();
|
||||||
|
pal.setBrush(QPalette::All, QPalette::WindowText, color);
|
||||||
|
pal.setBrush(QPalette::All, QPalette::ButtonText, color);
|
||||||
|
pal.setBrush(QPalette::All, QPalette::Foreground, color);
|
||||||
|
pal.setBrush(QPalette::All, QPalette::Background, color);
|
||||||
|
//color.setAlpha(100);
|
||||||
|
//pal.setBrush(QPalette::Disabled, QPalette::WindowText, color);
|
||||||
|
//pal.setBrush(QPalette::Disabled, QPalette::ButtonText, color);
|
||||||
|
//pal.setBrush(QPalette::Disabled, QPalette::Foreground, color);
|
||||||
|
setPalette(pal);
|
||||||
|
}
|
||||||
|
void setContents(const QString &contents, int cursorPos)
|
||||||
|
{
|
||||||
|
setText(contents);
|
||||||
|
setCursorPosition(cursorPos);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// FakeVimOptionPage
|
// FakeVimOptionPage
|
||||||
@@ -775,7 +821,7 @@ private slots:
|
|||||||
void setBlockSelection(bool);
|
void setBlockSelection(bool);
|
||||||
void hasBlockSelection(bool*);
|
void hasBlockSelection(bool*);
|
||||||
|
|
||||||
void showCommandBuffer(const QString &contents);
|
void showCommandBuffer(const QString &contents, int cursorPos);
|
||||||
void showExtraInformation(const QString &msg);
|
void showExtraInformation(const QString &msg);
|
||||||
void changeSelection(const QList<QTextEdit::ExtraSelection> &selections);
|
void changeSelection(const QList<QTextEdit::ExtraSelection> &selections);
|
||||||
void moveToMatchingParenthesis(bool *moved, bool *forward, QTextCursor *cursor);
|
void moveToMatchingParenthesis(bool *moved, bool *forward, QTextCursor *cursor);
|
||||||
@@ -1332,8 +1378,8 @@ void FakeVimPluginPrivate::editorOpened(Core::IEditor *editor)
|
|||||||
|
|
||||||
connect(handler, SIGNAL(extraInformationChanged(QString)),
|
connect(handler, SIGNAL(extraInformationChanged(QString)),
|
||||||
SLOT(showExtraInformation(QString)));
|
SLOT(showExtraInformation(QString)));
|
||||||
connect(handler, SIGNAL(commandBufferChanged(QString)),
|
connect(handler, SIGNAL(commandBufferChanged(QString,int)),
|
||||||
SLOT(showCommandBuffer(QString)));
|
SLOT(showCommandBuffer(QString,int)));
|
||||||
connect(handler, SIGNAL(selectionChanged(QList<QTextEdit::ExtraSelection>)),
|
connect(handler, SIGNAL(selectionChanged(QList<QTextEdit::ExtraSelection>)),
|
||||||
SLOT(changeSelection(QList<QTextEdit::ExtraSelection>)));
|
SLOT(changeSelection(QList<QTextEdit::ExtraSelection>)));
|
||||||
connect(handler, SIGNAL(moveToMatchingParenthesis(bool*,bool*,QTextCursor*)),
|
connect(handler, SIGNAL(moveToMatchingParenthesis(bool*,bool*,QTextCursor*)),
|
||||||
@@ -1368,7 +1414,7 @@ void FakeVimPluginPrivate::editorOpened(Core::IEditor *editor)
|
|||||||
|
|
||||||
// pop up the bar
|
// pop up the bar
|
||||||
if (theFakeVimSetting(ConfigUseFakeVim)->value().toBool()) {
|
if (theFakeVimSetting(ConfigUseFakeVim)->value().toBool()) {
|
||||||
showCommandBuffer(QString());
|
showCommandBuffer(QString(), -1);
|
||||||
handler->setupWidget();
|
handler->setupWidget();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1400,7 +1446,7 @@ void FakeVimPluginPrivate::setUseFakeVimInternal(bool on)
|
|||||||
//ICore *core = ICore::instance();
|
//ICore *core = ICore::instance();
|
||||||
//core->updateAdditionalContexts(Core::Context(),
|
//core->updateAdditionalContexts(Core::Context(),
|
||||||
// Core::Context(FAKEVIM_CONTEXT));
|
// Core::Context(FAKEVIM_CONTEXT));
|
||||||
showCommandBuffer(QString());
|
showCommandBuffer(QString(), -1);
|
||||||
foreach (Core::IEditor *editor, m_editorToHandler.keys()) {
|
foreach (Core::IEditor *editor, m_editorToHandler.keys()) {
|
||||||
if (TextEditor::BaseTextEditorWidget *textEditor =
|
if (TextEditor::BaseTextEditorWidget *textEditor =
|
||||||
qobject_cast<TextEditor::BaseTextEditorWidget *>(editor->widget())) {
|
qobject_cast<TextEditor::BaseTextEditorWidget *>(editor->widget())) {
|
||||||
@@ -1657,11 +1703,11 @@ void FakeVimPluginPrivate::quitFakeVim()
|
|||||||
theFakeVimSetting(ConfigUseFakeVim)->setValue(false);
|
theFakeVimSetting(ConfigUseFakeVim)->setValue(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FakeVimPluginPrivate::showCommandBuffer(const QString &contents)
|
void FakeVimPluginPrivate::showCommandBuffer(const QString &contents, int cursorPos)
|
||||||
{
|
{
|
||||||
//qDebug() << "SHOW COMMAND BUFFER" << contents;
|
//qDebug() << "SHOW COMMAND BUFFER" << contents;
|
||||||
if (QLabel *label = qobject_cast<QLabel *>(m_statusBar->widget()))
|
if (MiniBuffer *w = qobject_cast<MiniBuffer *>(m_statusBar->widget()))
|
||||||
label->setText(" " + contents);
|
w->setContents(contents, cursorPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FakeVimPluginPrivate::showExtraInformation(const QString &text)
|
void FakeVimPluginPrivate::showExtraInformation(const QString &text)
|
||||||
@@ -1748,8 +1794,7 @@ ExtensionSystem::IPlugin::ShutdownFlag FakeVimPlugin::aboutToShutdown()
|
|||||||
void FakeVimPlugin::extensionsInitialized()
|
void FakeVimPlugin::extensionsInitialized()
|
||||||
{
|
{
|
||||||
d->m_statusBar = new Core::StatusBarWidget;
|
d->m_statusBar = new Core::StatusBarWidget;
|
||||||
d->m_statusBar->setWidget(new QLabel);
|
d->m_statusBar->setWidget(new MiniBuffer);
|
||||||
//d->m_statusBar->setContext(Context(FAKEVIM_CONTEXT));
|
|
||||||
d->m_statusBar->setPosition(StatusBarWidget::Last);
|
d->m_statusBar->setPosition(StatusBarWidget::Last);
|
||||||
addAutoReleasedObject(d->m_statusBar);
|
addAutoReleasedObject(d->m_statusBar);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user