somewhat better intergration of fakevim into creator

This commit is contained in:
hjk
2009-01-07 17:41:09 +01:00
parent db595e2f41
commit 634edf2aab
5 changed files with 45 additions and 40 deletions

View File

@@ -65,6 +65,7 @@ enum MakeWritableResult {
};
struct EditorManagerPrivate;
namespace Internal {
class OpenEditorsWindow;
class EditorSplitter;
@@ -224,7 +225,8 @@ private:
namespace Internal {
class EditorClosingCoreListener : public ICoreListener {
class EditorClosingCoreListener : public ICoreListener
{
Q_OBJECT
public:

View File

@@ -2983,6 +2983,7 @@ void GdbEngine::runCustomDumper(const WatchData & data0, bool dumpChildren)
nodetype = m_namespace + "QMapNode";
nodetype += data.type.mid(outertype.size());
} else {
// FIXME: doesn't work for QMultiMap
nodetype = data.type + "::Node";
}
//qDebug() << "OUTERTYPE: " << outertype << " NODETYPE: " << nodetype

View File

@@ -75,6 +75,7 @@ namespace FakeVim {
namespace Constants {
const char * const INSTALL_HANDLER = "FakeVim.InstallHandler";
const char * const MINI_BUFFER = "FakeVim.MiniBuffer";
const char * const INSTALL_KEY = "Alt+V,Alt+V";
} // namespace Constants
@@ -89,7 +90,7 @@ const char * const INSTALL_KEY = "Alt+V,Alt+V";
FakeVimPlugin::FakeVimPlugin()
{
m_pm = 0;
m_core = 0;
m_handler = 0;
}
@@ -109,12 +110,10 @@ bool FakeVimPlugin::initialize(const QStringList &arguments, QString *error_mess
m_handler = new FakeVimHandler;
m_pm = ExtensionSystem::PluginManager::instance();
m_core = ExtensionSystem::PluginManager::instance()->getObject<Core::ICore>();
QTC_ASSERT(m_core, return false);
ICore *core = m_pm->getObject<Core::ICore>();
QTC_ASSERT(core, return false);
Core::ActionManagerInterface *actionManager = core->actionManager();
Core::ActionManagerInterface *actionManager = m_core->actionManager();
QTC_ASSERT(actionManager, return false);
QList<int> globalcontext;
@@ -143,44 +142,32 @@ void FakeVimPlugin::extensionsInitialized()
void FakeVimPlugin::installHandler()
{
ICore *core = m_pm->getObject<Core::ICore>();
if (!core || !core->editorManager())
if (!m_core || !m_core->editorManager())
return;
Core::IEditor *editor = core->editorManager()->currentEditor();
Core::IEditor *editor = m_core->editorManager()->currentEditor();
ITextEditor *textEditor = qobject_cast<ITextEditor*>(editor);
if (!textEditor)
return;
QWidget *widget = textEditor->widget();
QPlainTextEdit *plainTextEdit = qobject_cast<QPlainTextEdit *>(widget);
if (!plainTextEdit)
return;
plainTextEdit->removeEventFilter(m_handler);
plainTextEdit->installEventFilter(m_handler);
QFont font = plainTextEdit->font();
//font.setFamily("Monospace");
m_savedCursorWidth = plainTextEdit->cursorWidth();
plainTextEdit->setCursorWidth(QFontMetrics(font).width(QChar('x')));
//QMainWindow mw;
connect(m_handler, SIGNAL(commandBufferChanged(QString)),
this, SLOT(showCommandBuffer(QString)));
connect(m_handler, SIGNAL(quitRequested(QWidget *)),
this, SLOT(removeHandler(QWidget *)));
m_handler->addWidget(textEditor->widget());
}
void FakeVimPlugin::removeHandler(QWidget *widget)
{
widget->removeEventFilter(m_handler);
QPlainTextEdit *plainTextEdit = qobject_cast<QPlainTextEdit *>(widget);
if (!plainTextEdit)
return;
plainTextEdit->setCursorWidth(m_savedCursorWidth);
m_handler->removeWidget(widget);
Core::EditorManager::instance()
->hideEditorInfoBar(QLatin1String(Constants::MINI_BUFFER));
}
void FakeVimPlugin::showCommandBuffer(const QString &contents)
{
//qDebug() << "CMD: " << contents;
Core::EditorManager::instance()
->showEditorInfoBar(QLatin1String(Constants::MINI_BUFFER), contents);
}

View File

@@ -44,8 +44,21 @@ class QCursor;
class QAbstractItemView;
QT_END_NAMESPACE
namespace Core { class IEditor; }
namespace TextEditor { class ITextEditor; }
namespace Core {
class ICore;
class IEditor;
} // namespace Core
namespace TextEditor {
class ITextEditor;
} // namespace TextEditor
namespace FakeVim {
namespace Internal {
@@ -72,9 +85,8 @@ private slots:
private:
FakeVimHandler *m_handler;
ExtensionSystem::PluginManager *m_pm;
QAction *m_installHandlerAction;
int m_savedCursorWidth;
Core::ICore *m_core;
};
} // namespace Internal

View File

@@ -152,10 +152,7 @@ private:
void handleRegisterMode(int key, const QString &text);
void handleMiniBufferModes(int key, const QString &text);
void finishMovement(const QString &text = QString());
void updateMiniBuffer();
void updateSelection();
void search(const QString &needle, bool forward);
void showMessage(const QString &msg);
int mvCount() const { return m_mvcount.isEmpty() ? 1 : m_mvcount.toInt(); }
int opCount() const { return m_opcount.isEmpty() ? 1 : m_opcount.toInt(); }
@@ -186,9 +183,12 @@ private:
int readLineCode(QString &cmd);
QTextCursor selectRange(int beginLine, int endLine);
void enterInsertMode();
public:
void enterInsertMode();
void enterCommandMode();
void showMessage(const QString &msg);
void updateMiniBuffer();
void updateSelection();
public:
QTextEdit *m_textedit;
@@ -816,7 +816,6 @@ void FakeVimHandler::Private::handleMiniBufferModes(int key, const QString &text
m_commandHistory.append(m_commandBuffer);
handleExCommand(m_commandBuffer);
}
enterCommandMode();
} else if (key == Key_Return && isSearchMode()) {
if (!m_commandBuffer.isEmpty()) {
m_searchHistory.takeLast();
@@ -941,7 +940,7 @@ void FakeVimHandler::Private::handleExCommand(const QString &cmd0)
endLine = line;
}
//qDebug() << "RANGE: " << beginLine << endLine << cmd << cmd0;
qDebug() << "RANGE: " << beginLine << endLine << cmd << cmd0;
static QRegExp reWrite("^w!?( (.*))?$");
static QRegExp reDelete("^d( (.*))?$");
@@ -950,8 +949,9 @@ void FakeVimHandler::Private::handleExCommand(const QString &cmd0)
m_tc.setPosition(positionForLine(beginLine));
showMessage(QString());
} else if (cmd == "q!" || cmd == "q") { // :q
q->quitRequested(editor());
showMessage(QString());
EDITOR(setOverwriteMode(false));
q->quitRequested(editor());
} else if (reDelete.indexIn(cmd) != -1) { // :d
if (beginLine == -1)
beginLine = cursorLineInDocument();
@@ -1369,11 +1369,14 @@ void FakeVimHandler::addWidget(QWidget *widget)
//ed->setCursorWidth(QFontMetrics(ed->font()).width(QChar('x')));
ed->setLineWrapMode(QPlainTextEdit::NoWrap);
}
d->showMessage("vi emulation mode. Hit <Shift+Esc>:q<Return> to quit");
d->updateMiniBuffer();
}
void FakeVimHandler::removeWidget(QWidget *widget)
{
d->enterCommandMode();
d->showMessage(QString());
d->updateMiniBuffer();
widget->removeEventFilter(this);
}