forked from qt-creator/qt-creator
Merge branch 'master' of git@scm.dev.nokia.troll.no:creator/mainline
This commit is contained in:
@@ -32,12 +32,13 @@
|
|||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
#include "basefilewizard.h"
|
#include "basefilewizard.h"
|
||||||
#include "mimedatabase.h"
|
|
||||||
|
|
||||||
#include <coreplugin/editormanager/editormanager.h>
|
#include "coreconstants.h"
|
||||||
#include <coreplugin/icore.h>
|
#include "icore.h"
|
||||||
#include <coreplugin/coreconstants.h>
|
#include "ifilewizardextension.h"
|
||||||
#include <coreplugin/ifilewizardextension.h>
|
#include "mimedatabase.h"
|
||||||
|
#include "editormanager/editormanager.h"
|
||||||
|
|
||||||
#include <extensionsystem/pluginmanager.h>
|
#include <extensionsystem/pluginmanager.h>
|
||||||
#include <utils/filewizarddialog.h>
|
#include <utils/filewizarddialog.h>
|
||||||
|
|
||||||
|
@@ -167,3 +167,10 @@ RESOURCES += core.qrc \
|
|||||||
contains(QT_CONFIG, webkit) {
|
contains(QT_CONFIG, webkit) {
|
||||||
QT += webkit
|
QT += webkit
|
||||||
}
|
}
|
||||||
|
|
||||||
|
linux-* {
|
||||||
|
images.files = images/qtcreator_logo_*.png
|
||||||
|
images.path = /share/pixmaps
|
||||||
|
|
||||||
|
INSTALLS += images
|
||||||
|
}
|
||||||
|
@@ -33,15 +33,14 @@
|
|||||||
|
|
||||||
#include "editorsplitter.h"
|
#include "editorsplitter.h"
|
||||||
|
|
||||||
|
#include "coreconstants.h"
|
||||||
#include "editormanager.h"
|
#include "editormanager.h"
|
||||||
|
#include "icore.h"
|
||||||
#include "minisplitter.h"
|
#include "minisplitter.h"
|
||||||
#include "openeditorswindow.h"
|
#include "openeditorswindow.h"
|
||||||
#include "stackededitorgroup.h"
|
#include "stackededitorgroup.h"
|
||||||
|
#include "uniqueidmanager.h"
|
||||||
#include <coreplugin/icore.h>
|
#include "actionmanager/actionmanager.h"
|
||||||
#include <coreplugin/coreconstants.h>
|
|
||||||
#include <coreplugin/uniqueidmanager.h>
|
|
||||||
#include <coreplugin/actionmanager/actionmanager.h>
|
|
||||||
|
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
|
@@ -33,13 +33,14 @@
|
|||||||
|
|
||||||
#include "filemanager.h"
|
#include "filemanager.h"
|
||||||
|
|
||||||
|
#include "editormanager.h"
|
||||||
|
#include "icore.h"
|
||||||
#include "ifile.h"
|
#include "ifile.h"
|
||||||
|
#include "iversioncontrol.h"
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
|
#include "mimedatabase.h"
|
||||||
#include "saveitemsdialog.h"
|
#include "saveitemsdialog.h"
|
||||||
#include "vcsmanager.h"
|
#include "vcsmanager.h"
|
||||||
#include "editormanager.h"
|
|
||||||
#include "mimedatabase.h"
|
|
||||||
#include "iversioncontrol.h"
|
|
||||||
|
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
|
@@ -380,7 +380,7 @@ void MainWindow::registerDefaultContainers()
|
|||||||
menubar->appendGroup(Constants::G_WINDOW);
|
menubar->appendGroup(Constants::G_WINDOW);
|
||||||
menubar->appendGroup(Constants::G_HELP);
|
menubar->appendGroup(Constants::G_HELP);
|
||||||
|
|
||||||
//File Menu
|
// File Menu
|
||||||
ActionContainer *filemenu = am->createMenu(Constants::M_FILE);
|
ActionContainer *filemenu = am->createMenu(Constants::M_FILE);
|
||||||
menubar->addMenu(filemenu, Constants::G_FILE);
|
menubar->addMenu(filemenu, Constants::G_FILE);
|
||||||
filemenu->menu()->setTitle(tr("&File"));
|
filemenu->menu()->setTitle(tr("&File"));
|
||||||
@@ -394,7 +394,7 @@ void MainWindow::registerDefaultContainers()
|
|||||||
connect(filemenu->menu(), SIGNAL(aboutToShow()), this, SLOT(aboutToShowRecentFiles()));
|
connect(filemenu->menu(), SIGNAL(aboutToShow()), this, SLOT(aboutToShowRecentFiles()));
|
||||||
|
|
||||||
|
|
||||||
//Edit Menu
|
// Edit Menu
|
||||||
ActionContainer *medit = am->createMenu(Constants::M_EDIT);
|
ActionContainer *medit = am->createMenu(Constants::M_EDIT);
|
||||||
menubar->addMenu(medit, Constants::G_EDIT);
|
menubar->addMenu(medit, Constants::G_EDIT);
|
||||||
medit->menu()->setTitle(tr("&Edit"));
|
medit->menu()->setTitle(tr("&Edit"));
|
||||||
@@ -405,12 +405,12 @@ void MainWindow::registerDefaultContainers()
|
|||||||
medit->appendGroup(Constants::G_EDIT_FIND);
|
medit->appendGroup(Constants::G_EDIT_FIND);
|
||||||
medit->appendGroup(Constants::G_EDIT_OTHER);
|
medit->appendGroup(Constants::G_EDIT_OTHER);
|
||||||
|
|
||||||
//Tools Menu
|
// Tools Menu
|
||||||
ActionContainer *ac = am->createMenu(Constants::M_TOOLS);
|
ActionContainer *ac = am->createMenu(Constants::M_TOOLS);
|
||||||
menubar->addMenu(ac, Constants::G_TOOLS);
|
menubar->addMenu(ac, Constants::G_TOOLS);
|
||||||
ac->menu()->setTitle(tr("&Tools"));
|
ac->menu()->setTitle(tr("&Tools"));
|
||||||
|
|
||||||
//Window Menu
|
// Window Menu
|
||||||
ActionContainer *mwindow = am->createMenu(Constants::M_WINDOW);
|
ActionContainer *mwindow = am->createMenu(Constants::M_WINDOW);
|
||||||
menubar->addMenu(mwindow, Constants::G_WINDOW);
|
menubar->addMenu(mwindow, Constants::G_WINDOW);
|
||||||
mwindow->menu()->setTitle(tr("&Window"));
|
mwindow->menu()->setTitle(tr("&Window"));
|
||||||
@@ -423,7 +423,7 @@ void MainWindow::registerDefaultContainers()
|
|||||||
mwindow->appendGroup(Constants::G_WINDOW_OTHER);
|
mwindow->appendGroup(Constants::G_WINDOW_OTHER);
|
||||||
mwindow->appendGroup(Constants::G_WINDOW_LIST);
|
mwindow->appendGroup(Constants::G_WINDOW_LIST);
|
||||||
|
|
||||||
//Help Menu
|
// Help Menu
|
||||||
ac = am->createMenu(Constants::M_HELP);
|
ac = am->createMenu(Constants::M_HELP);
|
||||||
menubar->addMenu(ac, Constants::G_HELP);
|
menubar->addMenu(ac, Constants::G_HELP);
|
||||||
ac->menu()->setTitle(tr("&Help"));
|
ac->menu()->setTitle(tr("&Help"));
|
||||||
|
@@ -34,7 +34,7 @@
|
|||||||
#ifndef MAINWINDOW_H
|
#ifndef MAINWINDOW_H
|
||||||
#define MAINWINDOW_H
|
#define MAINWINDOW_H
|
||||||
|
|
||||||
#include "icore.h"
|
#include "core_global.h"
|
||||||
|
|
||||||
#include <QtGui/QMainWindow>
|
#include <QtGui/QMainWindow>
|
||||||
#include <QtCore/QMap>
|
#include <QtCore/QMap>
|
||||||
@@ -61,6 +61,7 @@ class BaseView;
|
|||||||
class EditorManager;
|
class EditorManager;
|
||||||
class FileManager;
|
class FileManager;
|
||||||
class IContext;
|
class IContext;
|
||||||
|
class IWizard;
|
||||||
class MessageManager;
|
class MessageManager;
|
||||||
class MimeDatabase;
|
class MimeDatabase;
|
||||||
class ModeManager;
|
class ModeManager;
|
||||||
@@ -103,7 +104,6 @@ public:
|
|||||||
|
|
||||||
void openFiles(const QStringList &fileNames);
|
void openFiles(const QStringList &fileNames);
|
||||||
|
|
||||||
//ICore
|
|
||||||
inline ExtensionSystem::PluginManager *pluginManager() { return m_pluginManager; }
|
inline ExtensionSystem::PluginManager *pluginManager() { return m_pluginManager; }
|
||||||
Core::ActionManager *actionManager() const;
|
Core::ActionManager *actionManager() const;
|
||||||
Core::FileManager *fileManager() const;
|
Core::FileManager *fileManager() const;
|
||||||
|
@@ -35,6 +35,7 @@
|
|||||||
|
|
||||||
#include "fancytabwidget.h"
|
#include "fancytabwidget.h"
|
||||||
#include "fancyactionbar.h"
|
#include "fancyactionbar.h"
|
||||||
|
#include "icore.h"
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
|
|
||||||
#include <aggregation/aggregate.h>
|
#include <aggregation/aggregate.h>
|
||||||
|
@@ -33,12 +33,13 @@
|
|||||||
|
|
||||||
#include "navigationwidget.h"
|
#include "navigationwidget.h"
|
||||||
|
|
||||||
#include <coreplugin/icore.h>
|
#include "icore.h"
|
||||||
#include <coreplugin/coreconstants.h>
|
#include "coreconstants.h"
|
||||||
#include <coreplugin/inavigationwidgetfactory.h>
|
#include "inavigationwidgetfactory.h"
|
||||||
#include <coreplugin/modemanager.h>
|
#include "modemanager.h"
|
||||||
#include <coreplugin/uniqueidmanager.h>
|
#include "uniqueidmanager.h"
|
||||||
#include <coreplugin/actionmanager/actionmanager.h>
|
#include "actionmanager/actionmanager.h"
|
||||||
|
|
||||||
#include <extensionsystem/pluginmanager.h>
|
#include <extensionsystem/pluginmanager.h>
|
||||||
|
|
||||||
#include <QtCore/QDebug>
|
#include <QtCore/QDebug>
|
||||||
|
@@ -33,6 +33,7 @@
|
|||||||
|
|
||||||
#include "outputpane.h"
|
#include "outputpane.h"
|
||||||
#include "coreconstants.h"
|
#include "coreconstants.h"
|
||||||
|
#include "icore.h"
|
||||||
#include "ioutputpane.h"
|
#include "ioutputpane.h"
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "modemanager.h"
|
#include "modemanager.h"
|
||||||
@@ -55,7 +56,6 @@
|
|||||||
#include <QtGui/QToolBar>
|
#include <QtGui/QToolBar>
|
||||||
#include <QtGui/QToolButton>
|
#include <QtGui/QToolButton>
|
||||||
#include <QtGui/QStackedWidget>
|
#include <QtGui/QStackedWidget>
|
||||||
#include <QDebug>
|
|
||||||
|
|
||||||
using namespace Core;
|
using namespace Core;
|
||||||
using namespace Core::Internal;
|
using namespace Core::Internal;
|
||||||
|
@@ -35,13 +35,15 @@
|
|||||||
#define SCRIPTMANAGER_P_H
|
#define SCRIPTMANAGER_P_H
|
||||||
|
|
||||||
#include <coreplugin/scriptmanager/scriptmanager.h>
|
#include <coreplugin/scriptmanager/scriptmanager.h>
|
||||||
#include <coreplugin/icore.h>
|
|
||||||
|
|
||||||
#include <QtCore/QObject>
|
#include <QtCore/QObject>
|
||||||
#include <QtCore/QList>
|
#include <QtCore/QList>
|
||||||
#include <QtScript/QScriptEngine>
|
#include <QtScript/QScriptEngine>
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
|
|
||||||
|
class ICore;
|
||||||
|
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
class ScriptManagerPrivate : public Core::ScriptManager
|
class ScriptManagerPrivate : public Core::ScriptManager
|
||||||
|
@@ -440,9 +440,9 @@ void CPPEditor::switchDeclarationDefinition()
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
Function *f = lastSymbol->asFunction();
|
Function *f = lastSymbol->asFunction();
|
||||||
if (! f) {
|
if (!f) {
|
||||||
Scope *fs = lastSymbol->scope();
|
Scope *fs = lastSymbol->scope();
|
||||||
if (! fs->isFunctionScope())
|
if (!fs->isFunctionScope())
|
||||||
fs = fs->enclosingFunctionScope();
|
fs = fs->enclosingFunctionScope();
|
||||||
if (fs)
|
if (fs)
|
||||||
f = fs->owner()->asFunction();
|
f = fs->owner()->asFunction();
|
||||||
|
@@ -40,6 +40,7 @@
|
|||||||
#include "workbenchintegration.h"
|
#include "workbenchintegration.h"
|
||||||
|
|
||||||
#include <coreplugin/coreconstants.h>
|
#include <coreplugin/coreconstants.h>
|
||||||
|
#include <coreplugin/icore.h>
|
||||||
#include <coreplugin/uniqueidmanager.h>
|
#include <coreplugin/uniqueidmanager.h>
|
||||||
#include <coreplugin/actionmanager/actionmanager.h>
|
#include <coreplugin/actionmanager/actionmanager.h>
|
||||||
#include <coreplugin/editormanager/editormanager.h>
|
#include <coreplugin/editormanager/editormanager.h>
|
||||||
|
@@ -34,7 +34,6 @@
|
|||||||
#ifndef DESIGNER_SETTINGSPAGE_H
|
#ifndef DESIGNER_SETTINGSPAGE_H
|
||||||
#define DESIGNER_SETTINGSPAGE_H
|
#define DESIGNER_SETTINGSPAGE_H
|
||||||
|
|
||||||
#include <coreplugin/icore.h>
|
|
||||||
#include <coreplugin/dialogs/ioptionspage.h>
|
#include <coreplugin/dialogs/ioptionspage.h>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
@@ -45,6 +45,7 @@
|
|||||||
#include <QtCore/QDebug>
|
#include <QtCore/QDebug>
|
||||||
#include <QtCore/QFile>
|
#include <QtCore/QFile>
|
||||||
#include <QtCore/QObject>
|
#include <QtCore/QObject>
|
||||||
|
#include <QtCore/QPointer>
|
||||||
#include <QtCore/QProcess>
|
#include <QtCore/QProcess>
|
||||||
#include <QtCore/QRegExp>
|
#include <QtCore/QRegExp>
|
||||||
#include <QtCore/QTextStream>
|
#include <QtCore/QTextStream>
|
||||||
@@ -157,6 +158,13 @@ QDebug &operator<<(QDebug &ts, const EditOperation &op)
|
|||||||
return ts;
|
return ts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QDebug &operator<<(QDebug &ts, const QList<QTextEdit::ExtraSelection> &sels)
|
||||||
|
{
|
||||||
|
foreach (QTextEdit::ExtraSelection sel, sels)
|
||||||
|
ts << "SEL: " << sel.cursor.anchor() << sel.cursor.position();
|
||||||
|
return ts;
|
||||||
|
}
|
||||||
|
|
||||||
int lineCount(const QString &text)
|
int lineCount(const QString &text)
|
||||||
{
|
{
|
||||||
//return text.count(QChar(ParagraphSeparator));
|
//return text.count(QChar(ParagraphSeparator));
|
||||||
@@ -166,11 +174,14 @@ int lineCount(const QString &text)
|
|||||||
class FakeVimHandler::Private
|
class FakeVimHandler::Private
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Private(FakeVimHandler *parent);
|
Private(FakeVimHandler *parent, QWidget *widget);
|
||||||
|
|
||||||
bool handleEvent(QKeyEvent *ev);
|
bool handleEvent(QKeyEvent *ev);
|
||||||
void handleExCommand(const QString &cmd);
|
void handleExCommand(const QString &cmd);
|
||||||
|
|
||||||
|
void setupWidget();
|
||||||
|
void restoreWidget();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class FakeVimHandler;
|
friend class FakeVimHandler;
|
||||||
static int shift(int key) { return key + 32; }
|
static int shift(int key) { return key + 32; }
|
||||||
@@ -238,7 +249,6 @@ private:
|
|||||||
int readLineCode(QString &cmd);
|
int readLineCode(QString &cmd);
|
||||||
void selectRange(int beginLine, int endLine);
|
void selectRange(int beginLine, int endLine);
|
||||||
|
|
||||||
void setWidget(QWidget *ob);
|
|
||||||
void enterInsertMode();
|
void enterInsertMode();
|
||||||
void enterCommandMode();
|
void enterCommandMode();
|
||||||
void showRedMessage(const QString &msg);
|
void showRedMessage(const QString &msg);
|
||||||
@@ -328,12 +338,17 @@ public:
|
|||||||
// for restoring cursor position
|
// for restoring cursor position
|
||||||
int m_savedYankPosition;
|
int m_savedYankPosition;
|
||||||
int m_desiredColumn;
|
int m_desiredColumn;
|
||||||
|
|
||||||
|
QPointer<QObject> m_extraData;
|
||||||
};
|
};
|
||||||
|
|
||||||
FakeVimHandler::Private::Private(FakeVimHandler *parent)
|
FakeVimHandler::Private::Private(FakeVimHandler *parent, QWidget *widget)
|
||||||
{
|
{
|
||||||
q = parent;
|
q = parent;
|
||||||
|
|
||||||
|
m_textedit = qobject_cast<QTextEdit *>(widget);
|
||||||
|
m_plaintextedit = qobject_cast<QPlainTextEdit *>(widget);
|
||||||
|
|
||||||
m_mode = CommandMode;
|
m_mode = CommandMode;
|
||||||
m_submode = NoSubMode;
|
m_submode = NoSubMode;
|
||||||
m_subsubmode = NoSubSubMode;
|
m_subsubmode = NoSubSubMode;
|
||||||
@@ -341,8 +356,6 @@ FakeVimHandler::Private::Private(FakeVimHandler *parent)
|
|||||||
m_lastSearchForward = true;
|
m_lastSearchForward = true;
|
||||||
m_register = '"';
|
m_register = '"';
|
||||||
m_gflag = false;
|
m_gflag = false;
|
||||||
m_textedit = 0;
|
|
||||||
m_plaintextedit = 0;
|
|
||||||
m_visualMode = NoVisualMode;
|
m_visualMode = NoVisualMode;
|
||||||
m_desiredColumn = 0;
|
m_desiredColumn = 0;
|
||||||
m_moveType = MoveInclusive;
|
m_moveType = MoveInclusive;
|
||||||
@@ -403,6 +416,37 @@ bool FakeVimHandler::Private::handleEvent(QKeyEvent *ev)
|
|||||||
return handled;
|
return handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FakeVimHandler::Private::setupWidget()
|
||||||
|
{
|
||||||
|
enterCommandMode();
|
||||||
|
if (m_textedit) {
|
||||||
|
m_textedit->installEventFilter(q);
|
||||||
|
//m_textedit->setCursorWidth(QFontMetrics(ed->font()).width(QChar('x')));
|
||||||
|
m_textedit->setLineWrapMode(QTextEdit::NoWrap);
|
||||||
|
m_wasReadOnly = m_textedit->isReadOnly();
|
||||||
|
} else if (m_plaintextedit) {
|
||||||
|
m_plaintextedit->installEventFilter(q);
|
||||||
|
//plaintextedit->setCursorWidth(QFontMetrics(ed->font()).width(QChar('x')));
|
||||||
|
m_plaintextedit->setLineWrapMode(QPlainTextEdit::NoWrap);
|
||||||
|
m_wasReadOnly = m_plaintextedit->isReadOnly();
|
||||||
|
}
|
||||||
|
showBlackMessage("vi emulation mode.");
|
||||||
|
updateMiniBuffer();
|
||||||
|
}
|
||||||
|
|
||||||
|
void FakeVimHandler::Private::restoreWidget()
|
||||||
|
{
|
||||||
|
//showBlackMessage(QString());
|
||||||
|
//updateMiniBuffer();
|
||||||
|
if (m_textedit) {
|
||||||
|
m_textedit->removeEventFilter(q);
|
||||||
|
m_textedit->setReadOnly(m_wasReadOnly);
|
||||||
|
} else if (m_plaintextedit) {
|
||||||
|
m_plaintextedit->removeEventFilter(q);
|
||||||
|
m_plaintextedit->setReadOnly(m_wasReadOnly);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool FakeVimHandler::Private::handleKey(int key, int unmodified, const QString &text)
|
bool FakeVimHandler::Private::handleKey(int key, int unmodified, const QString &text)
|
||||||
{
|
{
|
||||||
//qDebug() << "KEY: " << key << text << "POS: " << m_tc.position();
|
//qDebug() << "KEY: " << key << text << "POS: " << m_tc.position();
|
||||||
@@ -419,6 +463,7 @@ bool FakeVimHandler::Private::handleKey(int key, int unmodified, const QString &
|
|||||||
|
|
||||||
void FakeVimHandler::Private::finishMovement(const QString &dotCommand)
|
void FakeVimHandler::Private::finishMovement(const QString &dotCommand)
|
||||||
{
|
{
|
||||||
|
//qDebug() << "ANCHOR: " << m_anchor;
|
||||||
if (m_submode == FilterSubMode) {
|
if (m_submode == FilterSubMode) {
|
||||||
int beginLine = lineForPosition(anchor());
|
int beginLine = lineForPosition(anchor());
|
||||||
int endLine = lineForPosition(position());
|
int endLine = lineForPosition(position());
|
||||||
@@ -443,6 +488,8 @@ void FakeVimHandler::Private::finishMovement(const QString &dotCommand)
|
|||||||
m_mode = InsertMode;
|
m_mode = InsertMode;
|
||||||
m_submode = NoSubMode;
|
m_submode = NoSubMode;
|
||||||
} else if (m_submode == DeleteSubMode) {
|
} else if (m_submode == DeleteSubMode) {
|
||||||
|
if (m_moveType == MoveInclusive)
|
||||||
|
moveRight(); // correct
|
||||||
if (!dotCommand.isEmpty())
|
if (!dotCommand.isEmpty())
|
||||||
m_dotCommand = "d" + dotCommand;
|
m_dotCommand = "d" + dotCommand;
|
||||||
m_registers[m_register] = recordRemoveSelectedText();
|
m_registers[m_register] = recordRemoveSelectedText();
|
||||||
@@ -467,10 +514,8 @@ void FakeVimHandler::Private::finishMovement(const QString &dotCommand)
|
|||||||
m_tc.setPosition(startBlock.position());
|
m_tc.setPosition(startBlock.position());
|
||||||
moveToFirstNonBlankOnLine();
|
moveToFirstNonBlankOnLine();
|
||||||
m_submode = NoSubMode;
|
m_submode = NoSubMode;
|
||||||
} else if (m_moveType == MoveExclusive) {
|
|
||||||
moveLeft(); // correct
|
|
||||||
m_moveType = MoveInclusive;
|
|
||||||
}
|
}
|
||||||
|
m_moveType = MoveInclusive;
|
||||||
m_mvcount.clear();
|
m_mvcount.clear();
|
||||||
m_opcount.clear();
|
m_opcount.clear();
|
||||||
m_gflag = false;
|
m_gflag = false;
|
||||||
@@ -489,10 +534,13 @@ void FakeVimHandler::Private::updateSelection()
|
|||||||
QTextEdit::ExtraSelection sel;
|
QTextEdit::ExtraSelection sel;
|
||||||
sel.cursor = m_tc;
|
sel.cursor = m_tc;
|
||||||
sel.format = m_tc.blockCharFormat();
|
sel.format = m_tc.blockCharFormat();
|
||||||
//sel.format.setFontWeight(QFont::Bold);
|
#if 0
|
||||||
//sel.format.setFontUnderline(true);
|
sel.format.setFontWeight(QFont::Bold);
|
||||||
|
sel.format.setFontUnderline(true);
|
||||||
|
#else
|
||||||
sel.format.setForeground(Qt::white);
|
sel.format.setForeground(Qt::white);
|
||||||
sel.format.setBackground(Qt::black);
|
sel.format.setBackground(Qt::black);
|
||||||
|
#endif
|
||||||
int cursorPos = m_tc.position();
|
int cursorPos = m_tc.position();
|
||||||
int anchorPos = m_marks['<'];
|
int anchorPos = m_marks['<'];
|
||||||
//qDebug() << "POS: " << cursorPos << " ANCHOR: " << anchorPos;
|
//qDebug() << "POS: " << cursorPos << " ANCHOR: " << anchorPos;
|
||||||
@@ -529,7 +577,8 @@ void FakeVimHandler::Private::updateSelection()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
emit q->selectionChanged(editor(), selections);
|
//qDebug() << "SELECTION: " << selections;
|
||||||
|
emit q->selectionChanged(selections);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FakeVimHandler::Private::updateMiniBuffer()
|
void FakeVimHandler::Private::updateMiniBuffer()
|
||||||
@@ -770,9 +819,11 @@ bool FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
|
|||||||
recordBeginGroup();
|
recordBeginGroup();
|
||||||
m_lastInsertion.clear();
|
m_lastInsertion.clear();
|
||||||
} else if (key == 'b') {
|
} else if (key == 'b') {
|
||||||
|
m_moveType = MoveExclusive;
|
||||||
moveToWordBoundary(false, false);
|
moveToWordBoundary(false, false);
|
||||||
finishMovement();
|
finishMovement();
|
||||||
} else if (key == 'B') {
|
} else if (key == 'B') {
|
||||||
|
m_moveType = MoveExclusive;
|
||||||
moveToWordBoundary(true, false);
|
moveToWordBoundary(true, false);
|
||||||
finishMovement();
|
finishMovement();
|
||||||
} else if (key == 'c') {
|
} else if (key == 'c') {
|
||||||
@@ -795,7 +846,7 @@ bool FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
|
|||||||
m_mvcount.clear();
|
m_mvcount.clear();
|
||||||
m_submode = DeleteSubMode;
|
m_submode = DeleteSubMode;
|
||||||
} else if (key == 'd') {
|
} else if (key == 'd') {
|
||||||
setAnchor();
|
//setAnchor();
|
||||||
leaveVisualMode();
|
leaveVisualMode();
|
||||||
int beginLine = lineForPosition(m_marks['<']);
|
int beginLine = lineForPosition(m_marks['<']);
|
||||||
int endLine = lineForPosition(m_marks['>']);
|
int endLine = lineForPosition(m_marks['>']);
|
||||||
@@ -809,10 +860,11 @@ bool FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
|
|||||||
moveRight(rightDist());
|
moveRight(rightDist());
|
||||||
finishMovement();
|
finishMovement();
|
||||||
} else if (key == 'e') {
|
} else if (key == 'e') {
|
||||||
|
m_moveType = MoveInclusive;
|
||||||
moveToWordBoundary(false, true);
|
moveToWordBoundary(false, true);
|
||||||
m_moveType = MoveExclusive;
|
|
||||||
finishMovement();
|
finishMovement();
|
||||||
} else if (key == 'E') {
|
} else if (key == 'E') {
|
||||||
|
m_moveType = MoveInclusive;
|
||||||
moveToWordBoundary(true, true);
|
moveToWordBoundary(true, true);
|
||||||
finishMovement();
|
finishMovement();
|
||||||
} else if (key == 'f' || key == 'F') {
|
} else if (key == 'f' || key == 'F') {
|
||||||
@@ -1036,6 +1088,20 @@ bool FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
|
|||||||
}
|
}
|
||||||
recordInsertText(str);
|
recordInsertText(str);
|
||||||
recordEndGroup();
|
recordEndGroup();
|
||||||
|
} else if (key == control('d')) {
|
||||||
|
int sline = cursorLineOnScreen();
|
||||||
|
// FIXME: this should use the "scroll" option, and "count"
|
||||||
|
moveDown(linesOnScreen() / 2);
|
||||||
|
moveToFirstNonBlankOnLine();
|
||||||
|
scrollToLineInDocument(cursorLineInDocument() - sline);
|
||||||
|
finishMovement();
|
||||||
|
} else if (key == control('u')) {
|
||||||
|
int sline = cursorLineOnScreen();
|
||||||
|
// FIXME: this should use the "scroll" option, and "count"
|
||||||
|
moveUp(linesOnScreen() / 2);
|
||||||
|
moveToFirstNonBlankOnLine();
|
||||||
|
scrollToLineInDocument(cursorLineInDocument() - sline);
|
||||||
|
finishMovement();
|
||||||
} else if (key == Key_PageDown || key == control('f')) {
|
} else if (key == Key_PageDown || key == control('f')) {
|
||||||
moveDown(count() * (linesOnScreen() - 2));
|
moveDown(count() * (linesOnScreen() - 2));
|
||||||
finishMovement();
|
finishMovement();
|
||||||
@@ -1271,12 +1337,12 @@ int FakeVimHandler::Private::readLineCode(QString &cmd)
|
|||||||
|
|
||||||
void FakeVimHandler::Private::selectRange(int beginLine, int endLine)
|
void FakeVimHandler::Private::selectRange(int beginLine, int endLine)
|
||||||
{
|
{
|
||||||
m_tc.setPosition(positionForLine(beginLine), MoveAnchor);
|
m_anchor = positionForLine(beginLine);
|
||||||
if (endLine == linesInDocument()) {
|
if (endLine == linesInDocument()) {
|
||||||
m_tc.setPosition(positionForLine(endLine), KeepAnchor);
|
m_tc.setPosition(positionForLine(endLine), MoveAnchor);
|
||||||
m_tc.movePosition(EndOfLine, KeepAnchor);
|
m_tc.movePosition(EndOfLine, MoveAnchor);
|
||||||
} else {
|
} else {
|
||||||
m_tc.setPosition(positionForLine(endLine + 1), KeepAnchor);
|
m_tc.setPosition(positionForLine(endLine + 1), MoveAnchor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1329,21 +1395,38 @@ void FakeVimHandler::Private::handleExCommand(const QString &cmd0)
|
|||||||
beginLine = 0;
|
beginLine = 0;
|
||||||
if (endLine == -1)
|
if (endLine == -1)
|
||||||
endLine = linesInDocument();
|
endLine = linesInDocument();
|
||||||
//qDebug() << "LINES: " << beginLine << endLine;
|
qDebug() << "LINES: " << beginLine << endLine;
|
||||||
bool forced = cmd.startsWith("w!");
|
bool forced = cmd.startsWith("w!");
|
||||||
QString fileName = reWrite.cap(2);
|
QString fileName = reWrite.cap(2);
|
||||||
if (fileName.isEmpty())
|
if (fileName.isEmpty())
|
||||||
fileName = m_currentFileName;
|
fileName = m_currentFileName;
|
||||||
QFile file(fileName);
|
QFile file1(fileName);
|
||||||
bool exists = file.exists();
|
bool exists = file1.exists();
|
||||||
if (exists && !forced && !noArgs) {
|
if (exists && !forced && !noArgs) {
|
||||||
showRedMessage(tr("File '%1' exists (add ! to override)").arg(fileName));
|
showRedMessage(tr("File '%1' exists (add ! to override)").arg(fileName));
|
||||||
} else if (file.open(QIODevice::ReadWrite)) {
|
} else if (file1.open(QIODevice::ReadWrite)) {
|
||||||
|
file1.close();
|
||||||
selectRange(beginLine, endLine);
|
selectRange(beginLine, endLine);
|
||||||
emit q->writeFile(fileName, selectedText());
|
QString contents = selectedText();
|
||||||
// check by reading back
|
qDebug() << "LINES: " << beginLine << endLine;
|
||||||
file.open(QIODevice::ReadOnly);
|
bool handled = false;
|
||||||
QByteArray ba = file.readAll();
|
emit q->writeFileRequested(&handled, fileName, contents);
|
||||||
|
// nobody cared, so act ourselves
|
||||||
|
if (!handled) {
|
||||||
|
//qDebug() << "HANDLING MANUAL SAVE TO " << fileName;
|
||||||
|
QFile::remove(fileName);
|
||||||
|
QFile file2(fileName);
|
||||||
|
if (file2.open(QIODevice::ReadWrite)) {
|
||||||
|
QTextStream ts(&file2);
|
||||||
|
ts << contents;
|
||||||
|
} else {
|
||||||
|
showRedMessage(tr("Cannot open file '%1' for writing").arg(fileName));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// check result by reading back
|
||||||
|
QFile file3(fileName);
|
||||||
|
file3.open(QIODevice::ReadOnly);
|
||||||
|
QByteArray ba = file3.readAll();
|
||||||
showBlackMessage(tr("\"%1\" %2 %3L, %4C written")
|
showBlackMessage(tr("\"%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()));
|
||||||
@@ -1401,7 +1484,7 @@ void FakeVimHandler::Private::handleExCommand(const QString &cmd0)
|
|||||||
QString info;
|
QString info;
|
||||||
foreach (const QString &key, m_config.keys())
|
foreach (const QString &key, m_config.keys())
|
||||||
info += key + ": " + m_config.value(key) + "\n";
|
info += key + ": " + m_config.value(key) + "\n";
|
||||||
emit q->extraInformationChanged(editor(), info);
|
emit q->extraInformationChanged(info);
|
||||||
} else {
|
} else {
|
||||||
notImplementedYet();
|
notImplementedYet();
|
||||||
}
|
}
|
||||||
@@ -1417,7 +1500,7 @@ void FakeVimHandler::Private::handleExCommand(const QString &cmd0)
|
|||||||
++i;
|
++i;
|
||||||
info += QString("%1 %2\n").arg(i, -8).arg(item);
|
info += QString("%1 %2\n").arg(i, -8).arg(item);
|
||||||
}
|
}
|
||||||
emit q->extraInformationChanged(editor(), info);
|
emit q->extraInformationChanged(info);
|
||||||
} else {
|
} else {
|
||||||
notImplementedYet();
|
notImplementedYet();
|
||||||
}
|
}
|
||||||
@@ -1566,8 +1649,7 @@ void FakeVimHandler::Private::moveToWordBoundary(bool simple, bool forward)
|
|||||||
int n = forward ? lastPositionInDocument() - 1 : 0;
|
int n = forward ? lastPositionInDocument() - 1 : 0;
|
||||||
int lastClass = -1;
|
int lastClass = -1;
|
||||||
while (true) {
|
while (true) {
|
||||||
forward ? moveRight() : moveLeft();
|
QChar c = doc->characterAt(m_tc.position() + (forward ? 1 : -1));
|
||||||
QChar c = doc->characterAt(m_tc.position());
|
|
||||||
int thisClass = charClass(c, simple);
|
int thisClass = charClass(c, simple);
|
||||||
if (thisClass != lastClass && lastClass != 0)
|
if (thisClass != lastClass && lastClass != 0)
|
||||||
--repeat;
|
--repeat;
|
||||||
@@ -1576,6 +1658,7 @@ void FakeVimHandler::Private::moveToWordBoundary(bool simple, bool forward)
|
|||||||
lastClass = thisClass;
|
lastClass = thisClass;
|
||||||
if (m_tc.position() == n)
|
if (m_tc.position() == n)
|
||||||
break;
|
break;
|
||||||
|
forward ? moveRight() : moveLeft();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1752,6 +1835,7 @@ int FakeVimHandler::Private::lineForPosition(int pos) const
|
|||||||
|
|
||||||
void FakeVimHandler::Private::enterVisualMode(VisualMode visualMode)
|
void FakeVimHandler::Private::enterVisualMode(VisualMode visualMode)
|
||||||
{
|
{
|
||||||
|
setAnchor();
|
||||||
m_visualMode = visualMode;
|
m_visualMode = visualMode;
|
||||||
m_marks['<'] = m_tc.position();
|
m_marks['<'] = m_tc.position();
|
||||||
m_marks['>'] = m_tc.position();
|
m_marks['>'] = m_tc.position();
|
||||||
@@ -1942,16 +2026,10 @@ void FakeVimHandler::Private::enterCommandMode()
|
|||||||
|
|
||||||
void FakeVimHandler::Private::quit()
|
void FakeVimHandler::Private::quit()
|
||||||
{
|
{
|
||||||
showBlackMessage(QString());
|
|
||||||
EDITOR(setOverwriteMode(false));
|
EDITOR(setOverwriteMode(false));
|
||||||
q->quitRequested(editor());
|
q->quitRequested();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FakeVimHandler::Private::setWidget(QWidget *ob)
|
|
||||||
{
|
|
||||||
m_textedit = qobject_cast<QTextEdit *>(ob);
|
|
||||||
m_plaintextedit = qobject_cast<QPlainTextEdit *>(ob);
|
|
||||||
}
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
@@ -1959,12 +2037,13 @@ void FakeVimHandler::Private::setWidget(QWidget *ob)
|
|||||||
//
|
//
|
||||||
///////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
FakeVimHandler::FakeVimHandler(QObject *parent)
|
FakeVimHandler::FakeVimHandler(QWidget *widget, QObject *parent)
|
||||||
: QObject(parent), d(new Private(this))
|
: QObject(parent), d(new Private(this, widget))
|
||||||
{}
|
{}
|
||||||
|
|
||||||
FakeVimHandler::~FakeVimHandler()
|
FakeVimHandler::~FakeVimHandler()
|
||||||
{
|
{
|
||||||
|
qDebug() << "DELETING HANDLER" << this;
|
||||||
delete d;
|
delete d;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1993,40 +2072,18 @@ bool FakeVimHandler::eventFilter(QObject *ob, QEvent *ev)
|
|||||||
return QObject::eventFilter(ob, ev);
|
return QObject::eventFilter(ob, ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FakeVimHandler::addWidget(QWidget *widget)
|
void FakeVimHandler::setupWidget()
|
||||||
{
|
{
|
||||||
widget->installEventFilter(this);
|
d->setupWidget();
|
||||||
d->setWidget(widget);
|
|
||||||
d->enterCommandMode();
|
|
||||||
if (QTextEdit *ed = qobject_cast<QTextEdit *>(widget)) {
|
|
||||||
//ed->setCursorWidth(QFontMetrics(ed->font()).width(QChar('x')));
|
|
||||||
ed->setLineWrapMode(QTextEdit::NoWrap);
|
|
||||||
d->m_wasReadOnly = ed->isReadOnly();
|
|
||||||
} else if (QPlainTextEdit *ed = qobject_cast<QPlainTextEdit *>(widget)) {
|
|
||||||
//ed->setCursorWidth(QFontMetrics(ed->font()).width(QChar('x')));
|
|
||||||
ed->setLineWrapMode(QPlainTextEdit::NoWrap);
|
|
||||||
d->m_wasReadOnly = ed->isReadOnly();
|
|
||||||
}
|
|
||||||
d->showBlackMessage("vi emulation mode.");
|
|
||||||
d->updateMiniBuffer();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FakeVimHandler::removeWidget(QWidget *widget)
|
void FakeVimHandler::restoreWidget()
|
||||||
{
|
{
|
||||||
d->setWidget(widget);
|
d->restoreWidget();
|
||||||
d->showBlackMessage(QString());
|
|
||||||
d->updateMiniBuffer();
|
|
||||||
widget->removeEventFilter(this);
|
|
||||||
if (QTextEdit *ed = qobject_cast<QTextEdit *>(widget)) {
|
|
||||||
ed->setReadOnly(d->m_wasReadOnly);
|
|
||||||
} else if (QPlainTextEdit *ed = qobject_cast<QPlainTextEdit *>(widget)) {
|
|
||||||
ed->setReadOnly(d->m_wasReadOnly);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FakeVimHandler::handleCommand(QWidget *widget, const QString &cmd)
|
void FakeVimHandler::handleCommand(const QString &cmd)
|
||||||
{
|
{
|
||||||
d->setWidget(widget);
|
|
||||||
d->handleExCommand(cmd);
|
d->handleExCommand(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2044,3 +2101,19 @@ void FakeVimHandler::setCurrentFileName(const QString &fileName)
|
|||||||
{
|
{
|
||||||
d->m_currentFileName = fileName;
|
d->m_currentFileName = fileName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QWidget *FakeVimHandler::widget()
|
||||||
|
{
|
||||||
|
return d->editor();
|
||||||
|
}
|
||||||
|
|
||||||
|
void FakeVimHandler::setExtraData(QObject *data)
|
||||||
|
{
|
||||||
|
d->m_extraData = data;
|
||||||
|
}
|
||||||
|
|
||||||
|
QObject *FakeVimHandler::extraData() const
|
||||||
|
{
|
||||||
|
return d->m_extraData;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -50,30 +50,35 @@ class FakeVimHandler : public QObject
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FakeVimHandler(QObject *parent = 0);
|
FakeVimHandler(QWidget *widget, QObject *parent = 0);
|
||||||
~FakeVimHandler();
|
~FakeVimHandler();
|
||||||
|
|
||||||
|
QWidget *widget();
|
||||||
|
|
||||||
|
void setExtraData(QObject *data);
|
||||||
|
QObject *extraData() const;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
// The same handler can be installed on several widgets
|
|
||||||
// FIXME: good idea?
|
|
||||||
void addWidget(QWidget *widget);
|
|
||||||
void removeWidget(QWidget *widget);
|
|
||||||
void setCurrentFileName(const QString &fileName);
|
void setCurrentFileName(const QString &fileName);
|
||||||
|
|
||||||
// This executes an "ex" style command taking context
|
// This executes an "ex" style command taking context
|
||||||
// information from \p widget;
|
// information from widget;
|
||||||
void handleCommand(QWidget *widget, const QString &cmd);
|
void handleCommand(const QString &cmd);
|
||||||
void quit();
|
|
||||||
void setConfigValue(const QString &key, const QString &value);
|
void setConfigValue(const QString &key, const QString &value);
|
||||||
|
void quit();
|
||||||
|
|
||||||
|
// Convenience
|
||||||
|
void setupWidget();
|
||||||
|
void restoreWidget();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void commandBufferChanged(const QString &msg);
|
void commandBufferChanged(const QString &msg);
|
||||||
void statusDataChanged(const QString &msg);
|
void statusDataChanged(const QString &msg);
|
||||||
void extraInformationChanged(QWidget *widget, const QString &msg);
|
void extraInformationChanged(const QString &msg);
|
||||||
void quitRequested(QWidget *widget);
|
void quitRequested();
|
||||||
void selectionChanged(QWidget *widget,
|
void selectionChanged(const QList<QTextEdit::ExtraSelection> &selection);
|
||||||
const QList<QTextEdit::ExtraSelection> &selection);
|
void writeFileRequested(bool *handled,
|
||||||
void writeFile(const QString &fileName, const QString &contents);
|
const QString &fileName, const QString &contents);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool eventFilter(QObject *ob, QEvent *ev);
|
bool eventFilter(QObject *ob, QEvent *ev);
|
||||||
|
@@ -106,27 +106,26 @@ public:
|
|||||||
~FakeVimPluginPrivate();
|
~FakeVimPluginPrivate();
|
||||||
friend class FakeVimPlugin;
|
friend class FakeVimPlugin;
|
||||||
|
|
||||||
bool initialize(const QStringList &arguments, QString *error_message);
|
bool initialize();
|
||||||
void shutdown();
|
void shutdown();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void installHandler();
|
|
||||||
void installHandler(QWidget *widget);
|
|
||||||
void removeHandler(QWidget *widget);
|
|
||||||
void showCommandBuffer(const QString &contents);
|
|
||||||
void showExtraInformation(QWidget *, const QString &msg);
|
|
||||||
void editorOpened(Core::IEditor *);
|
void editorOpened(Core::IEditor *);
|
||||||
void editorAboutToClose(Core::IEditor *);
|
void editorAboutToClose(Core::IEditor *);
|
||||||
void changeSelection(QWidget *widget,
|
|
||||||
const QList<QTextEdit::ExtraSelection> &selections);
|
void installHandler();
|
||||||
void writeFile(const QString &fileName, const QString &contents);
|
void installHandler(Core::IEditor *editor);
|
||||||
|
void removeHandler();
|
||||||
|
|
||||||
|
void showCommandBuffer(const QString &contents);
|
||||||
|
void showExtraInformation(const QString &msg);
|
||||||
|
void changeSelection(const QList<QTextEdit::ExtraSelection> &selections);
|
||||||
|
void writeFile(bool *handled, const QString &fileName, const QString &contents);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
FakeVimPlugin *q;
|
FakeVimPlugin *q;
|
||||||
FakeVimHandler *m_handler;
|
|
||||||
QAction *m_installHandlerAction;
|
QAction *m_installHandlerAction;
|
||||||
Core::ICore *m_core;
|
Core::ICore *m_core;
|
||||||
Core::IFile *m_currentFile;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
@@ -135,10 +134,8 @@ private:
|
|||||||
FakeVimPluginPrivate::FakeVimPluginPrivate(FakeVimPlugin *plugin)
|
FakeVimPluginPrivate::FakeVimPluginPrivate(FakeVimPlugin *plugin)
|
||||||
{
|
{
|
||||||
q = plugin;
|
q = plugin;
|
||||||
m_handler = 0;
|
|
||||||
m_installHandlerAction = 0;
|
m_installHandlerAction = 0;
|
||||||
m_core = 0;
|
m_core = 0;
|
||||||
m_currentFile = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FakeVimPluginPrivate::~FakeVimPluginPrivate()
|
FakeVimPluginPrivate::~FakeVimPluginPrivate()
|
||||||
@@ -147,17 +144,10 @@ FakeVimPluginPrivate::~FakeVimPluginPrivate()
|
|||||||
|
|
||||||
void FakeVimPluginPrivate::shutdown()
|
void FakeVimPluginPrivate::shutdown()
|
||||||
{
|
{
|
||||||
delete m_handler;
|
|
||||||
m_handler = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FakeVimPluginPrivate::initialize(const QStringList &arguments, QString *error_message)
|
bool FakeVimPluginPrivate::initialize()
|
||||||
{
|
{
|
||||||
Q_UNUSED(arguments);
|
|
||||||
Q_UNUSED(error_message);
|
|
||||||
|
|
||||||
m_handler = new FakeVimHandler;
|
|
||||||
|
|
||||||
m_core = Core::ICore::instance();
|
m_core = Core::ICore::instance();
|
||||||
QTC_ASSERT(m_core, return false);
|
QTC_ASSERT(m_core, return false);
|
||||||
|
|
||||||
@@ -195,101 +185,113 @@ bool FakeVimPluginPrivate::initialize(const QStringList &arguments, QString *err
|
|||||||
void FakeVimPluginPrivate::installHandler()
|
void FakeVimPluginPrivate::installHandler()
|
||||||
{
|
{
|
||||||
if (Core::IEditor *editor = m_core->editorManager()->currentEditor())
|
if (Core::IEditor *editor = m_core->editorManager()->currentEditor())
|
||||||
installHandler(editor->widget());
|
installHandler(editor);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FakeVimPluginPrivate::installHandler(QWidget *widget)
|
void FakeVimPluginPrivate::installHandler(Core::IEditor *editor)
|
||||||
{
|
{
|
||||||
connect(m_handler, SIGNAL(extraInformationChanged(QWidget *, QString)),
|
QWidget *widget = editor->widget();
|
||||||
this, SLOT(showExtraInformation(QWidget *, QString)));
|
|
||||||
connect(m_handler, SIGNAL(commandBufferChanged(QString)),
|
FakeVimHandler *handler = new FakeVimHandler(widget, this);
|
||||||
|
|
||||||
|
connect(handler, SIGNAL(extraInformationChanged(QString)),
|
||||||
|
this, SLOT(showExtraInformation(QString)));
|
||||||
|
connect(handler, SIGNAL(commandBufferChanged(QString)),
|
||||||
this, SLOT(showCommandBuffer(QString)));
|
this, SLOT(showCommandBuffer(QString)));
|
||||||
connect(m_handler, SIGNAL(quitRequested(QWidget *)),
|
connect(handler, SIGNAL(quitRequested()),
|
||||||
this, SLOT(removeHandler(QWidget *)));
|
this, SLOT(removeHandler()), Qt::QueuedConnection);
|
||||||
connect(m_handler,
|
connect(handler, SIGNAL(writeFileRequested(bool*,QString,QString)),
|
||||||
SIGNAL(selectionChanged(QWidget*,QList<QTextEdit::ExtraSelection>)),
|
this, SLOT(writeFile(bool*,QString,QString)));
|
||||||
this, SLOT(changeSelection(QWidget*,QList<QTextEdit::ExtraSelection>)));
|
connect(handler, SIGNAL(selectionChanged(QList<QTextEdit::ExtraSelection>)),
|
||||||
|
this, SLOT(changeSelection(QList<QTextEdit::ExtraSelection>)));
|
||||||
|
|
||||||
m_handler->addWidget(widget);
|
handler->setupWidget();
|
||||||
TextEditor::BaseTextEditor* editor =
|
handler->setExtraData(editor);
|
||||||
qobject_cast<TextEditor::BaseTextEditor*>(widget);
|
|
||||||
if (editor) {
|
|
||||||
m_currentFile = editor->file();
|
|
||||||
m_handler->setCurrentFileName(editor->file()->fileName());
|
|
||||||
}
|
|
||||||
|
|
||||||
BaseTextEditor *bt = qobject_cast<BaseTextEditor *>(widget);
|
if (BaseTextEditor *bt = qobject_cast<BaseTextEditor *>(widget)) {
|
||||||
if (bt) {
|
|
||||||
using namespace TextEditor;
|
using namespace TextEditor;
|
||||||
using namespace FakeVim::Constants;
|
using namespace FakeVim::Constants;
|
||||||
|
handler->setCurrentFileName(editor->file()->fileName());
|
||||||
TabSettings settings = bt->tabSettings();
|
TabSettings settings = bt->tabSettings();
|
||||||
m_handler->setConfigValue(ConfigTabStop,
|
handler->setConfigValue(ConfigTabStop,
|
||||||
QString::number(settings.m_tabSize));
|
QString::number(settings.m_tabSize));
|
||||||
m_handler->setConfigValue(ConfigShiftWidth,
|
handler->setConfigValue(ConfigShiftWidth,
|
||||||
QString::number(settings.m_indentSize));
|
QString::number(settings.m_indentSize));
|
||||||
m_handler->setConfigValue(ConfigExpandTab,
|
handler->setConfigValue(ConfigExpandTab,
|
||||||
settings.m_spacesForTabs ? ConfigOn : ConfigOff);
|
settings.m_spacesForTabs ? ConfigOn : ConfigOff);
|
||||||
m_handler->setConfigValue(ConfigSmartTab,
|
handler->setConfigValue(ConfigSmartTab,
|
||||||
settings.m_smartBackspace ? ConfigOn : ConfigOff);
|
settings.m_smartBackspace ? ConfigOn : ConfigOff);
|
||||||
m_handler->setConfigValue(ConfigAutoIndent,
|
handler->setConfigValue(ConfigAutoIndent,
|
||||||
settings.m_autoIndent ? ConfigOn : ConfigOff);
|
settings.m_autoIndent ? ConfigOn : ConfigOff);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FakeVimPluginPrivate::writeFile(const QString &fileName,
|
void FakeVimPluginPrivate::writeFile(bool *handled,
|
||||||
const QString &contents)
|
const QString &fileName, const QString &contents)
|
||||||
{
|
{
|
||||||
if (m_currentFile && fileName == m_currentFile->fileName()) {
|
//qDebug() << "HANDLING WRITE FILE" << fileName << sender();
|
||||||
|
FakeVimHandler *handler = qobject_cast<FakeVimHandler *>(sender());
|
||||||
|
if (!handler)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Core::IEditor *editor = qobject_cast<Core::IEditor *>(handler->extraData());
|
||||||
|
if (editor && editor->file()->fileName() == fileName) {
|
||||||
|
//qDebug() << "HANDLING CORE SAVE";
|
||||||
// Handle that as a special case for nicer interaction with core
|
// Handle that as a special case for nicer interaction with core
|
||||||
m_core->fileManager()->blockFileChange(m_currentFile);
|
Core::IFile *file = editor->file();
|
||||||
m_currentFile->save(fileName);
|
m_core->fileManager()->blockFileChange(file);
|
||||||
m_core->fileManager()->unblockFileChange(m_currentFile);
|
file->save(fileName);
|
||||||
} else {
|
m_core->fileManager()->unblockFileChange(file);
|
||||||
QFile file(fileName);
|
*handled = true;
|
||||||
file.open(QIODevice::ReadWrite);
|
|
||||||
{ QTextStream ts(&file); ts << contents; }
|
|
||||||
file.close();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FakeVimPluginPrivate::removeHandler(QWidget *widget)
|
void FakeVimPluginPrivate::removeHandler()
|
||||||
{
|
{
|
||||||
Q_UNUSED(widget);
|
if (FakeVimHandler *handler = qobject_cast<FakeVimHandler *>(sender())) {
|
||||||
m_handler->removeWidget(widget);
|
handler->restoreWidget();
|
||||||
|
handler->deleteLater();
|
||||||
|
}
|
||||||
Core::EditorManager::instance()->hideEditorInfoBar(
|
Core::EditorManager::instance()->hideEditorInfoBar(
|
||||||
QLatin1String(Constants::MINI_BUFFER));
|
QLatin1String(Constants::MINI_BUFFER));
|
||||||
m_currentFile = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FakeVimPluginPrivate::editorOpened(Core::IEditor *editor)
|
void FakeVimPluginPrivate::editorOpened(Core::IEditor *editor)
|
||||||
{
|
{
|
||||||
Q_UNUSED(editor);
|
Q_UNUSED(editor);
|
||||||
//qDebug() << "OPENING: " << editor << editor->widget();
|
//qDebug() << "OPENING: " << editor << editor->widget();
|
||||||
//installHandler(editor->widget());
|
//installHandler(editor);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FakeVimPluginPrivate::editorAboutToClose(Core::IEditor *editor)
|
void FakeVimPluginPrivate::editorAboutToClose(Core::IEditor *editor)
|
||||||
{
|
{
|
||||||
//qDebug() << "CLOSING: " << editor << editor->widget();
|
Q_UNUSED(editor);
|
||||||
removeHandler(editor->widget());
|
//qDebug() << "CLOSING: " << editor;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FakeVimPluginPrivate::showCommandBuffer(const QString &contents)
|
void FakeVimPluginPrivate::showCommandBuffer(const QString &contents)
|
||||||
{
|
{
|
||||||
|
//qDebug() << "SHOW COMMAND BUFFER" << contents;
|
||||||
|
FakeVimHandler *handler = qobject_cast<FakeVimHandler *>(sender());
|
||||||
|
if (handler) {
|
||||||
Core::EditorManager::instance()->showEditorInfoBar(
|
Core::EditorManager::instance()->showEditorInfoBar(
|
||||||
QLatin1String(Constants::MINI_BUFFER), contents,
|
QLatin1String(Constants::MINI_BUFFER), contents,
|
||||||
tr("Quit FakeVim"), m_handler, SLOT(quit()));
|
tr("Quit FakeVim"), handler, SLOT(quit()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FakeVimPluginPrivate::showExtraInformation(QWidget *widget, const QString &text)
|
void FakeVimPluginPrivate::showExtraInformation(const QString &text)
|
||||||
{
|
{
|
||||||
QMessageBox::information(widget, tr("FakeVim Information"), text);
|
FakeVimHandler *handler = qobject_cast<FakeVimHandler *>(sender());
|
||||||
|
if (handler)
|
||||||
|
QMessageBox::information(handler->widget(), tr("FakeVim Information"), text);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FakeVimPluginPrivate::changeSelection(QWidget *widget,
|
void FakeVimPluginPrivate::changeSelection
|
||||||
const QList<QTextEdit::ExtraSelection> &selection)
|
(const QList<QTextEdit::ExtraSelection> &selection)
|
||||||
{
|
{
|
||||||
if (BaseTextEditor *bt = qobject_cast<BaseTextEditor *>(widget))
|
if (FakeVimHandler *handler = qobject_cast<FakeVimHandler *>(sender()))
|
||||||
|
if (BaseTextEditor *bt = qobject_cast<BaseTextEditor *>(handler->widget()))
|
||||||
bt->setExtraSelections(BaseTextEditor::FakeVimSelection, selection);
|
bt->setExtraSelections(BaseTextEditor::FakeVimSelection, selection);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -309,9 +311,11 @@ FakeVimPlugin::~FakeVimPlugin()
|
|||||||
delete d;
|
delete d;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FakeVimPlugin::initialize(const QStringList &arguments, QString *error_message)
|
bool FakeVimPlugin::initialize(const QStringList &arguments, QString *errorMessage)
|
||||||
{
|
{
|
||||||
return d->initialize(arguments, error_message);
|
Q_UNUSED(arguments);
|
||||||
|
Q_UNUSED(errorMessage);
|
||||||
|
return d->initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FakeVimPlugin::shutdown()
|
void FakeVimPlugin::shutdown()
|
||||||
|
@@ -40,6 +40,7 @@
|
|||||||
#include "projectexplorer.h"
|
#include "projectexplorer.h"
|
||||||
#include "taskwindow.h"
|
#include "taskwindow.h"
|
||||||
|
|
||||||
|
#include <coreplugin/icore.h>
|
||||||
#include <coreplugin/progressmanager/progressmanager.h>
|
#include <coreplugin/progressmanager/progressmanager.h>
|
||||||
#include <coreplugin/progressmanager/futureprogress.h>
|
#include <coreplugin/progressmanager/futureprogress.h>
|
||||||
#include <extensionsystem/pluginmanager.h>
|
#include <extensionsystem/pluginmanager.h>
|
||||||
|
@@ -62,9 +62,10 @@
|
|||||||
|
|
||||||
#include <coreplugin/basemode.h>
|
#include <coreplugin/basemode.h>
|
||||||
#include <coreplugin/coreconstants.h>
|
#include <coreplugin/coreconstants.h>
|
||||||
|
#include <coreplugin/filemanager.h>
|
||||||
|
#include <coreplugin/icore.h>
|
||||||
#include <coreplugin/mainwindow.h>
|
#include <coreplugin/mainwindow.h>
|
||||||
#include <coreplugin/mimedatabase.h>
|
#include <coreplugin/mimedatabase.h>
|
||||||
#include <coreplugin/filemanager.h>
|
|
||||||
#include <coreplugin/modemanager.h>
|
#include <coreplugin/modemanager.h>
|
||||||
#include <coreplugin/uniqueidmanager.h>
|
#include <coreplugin/uniqueidmanager.h>
|
||||||
#include <coreplugin/actionmanager/actionmanager.h>
|
#include <coreplugin/actionmanager/actionmanager.h>
|
||||||
|
@@ -37,6 +37,7 @@
|
|||||||
#include <coreplugin/actionmanager/actionmanager.h>
|
#include <coreplugin/actionmanager/actionmanager.h>
|
||||||
#include <coreplugin/editormanager/editormanager.h>
|
#include <coreplugin/editormanager/editormanager.h>
|
||||||
#include <coreplugin/coreconstants.h>
|
#include <coreplugin/coreconstants.h>
|
||||||
|
#include <coreplugin/icore.h>
|
||||||
#include <coreplugin/uniqueidmanager.h>
|
#include <coreplugin/uniqueidmanager.h>
|
||||||
#include <extensionsystem/pluginmanager.h>
|
#include <extensionsystem/pluginmanager.h>
|
||||||
#include <texteditor/itexteditor.h>
|
#include <texteditor/itexteditor.h>
|
||||||
|
@@ -38,7 +38,6 @@
|
|||||||
|
|
||||||
#include <coreplugin/ioutputpane.h>
|
#include <coreplugin/ioutputpane.h>
|
||||||
#include <coreplugin/icontext.h>
|
#include <coreplugin/icontext.h>
|
||||||
#include <coreplugin/icore.h>
|
|
||||||
|
|
||||||
#include <QtGui/QTreeWidget>
|
#include <QtGui/QTreeWidget>
|
||||||
#include <QtGui/QStyledItemDelegate>
|
#include <QtGui/QStyledItemDelegate>
|
||||||
|
@@ -40,6 +40,7 @@
|
|||||||
#include "qt4projectmanager.h"
|
#include "qt4projectmanager.h"
|
||||||
#include "ui_qt4buildconfigwidget.h"
|
#include "ui_qt4buildconfigwidget.h"
|
||||||
|
|
||||||
|
#include <coreplugin/icore.h>
|
||||||
#include <coreplugin/mainwindow.h>
|
#include <coreplugin/mainwindow.h>
|
||||||
|
|
||||||
#include <QtGui/QFileDialog>
|
#include <QtGui/QFileDialog>
|
||||||
|
@@ -37,7 +37,6 @@
|
|||||||
#include "iquickopenfilter.h"
|
#include "iquickopenfilter.h"
|
||||||
#include "ui_filesystemfilter.h"
|
#include "ui_filesystemfilter.h"
|
||||||
|
|
||||||
#include <coreplugin/icore.h>
|
|
||||||
#include <coreplugin/editormanager/editormanager.h>
|
#include <coreplugin/editormanager/editormanager.h>
|
||||||
|
|
||||||
#include <QtCore/QString>
|
#include <QtCore/QString>
|
||||||
|
@@ -47,9 +47,10 @@
|
|||||||
|
|
||||||
#include <coreplugin/baseview.h>
|
#include <coreplugin/baseview.h>
|
||||||
#include <coreplugin/coreconstants.h>
|
#include <coreplugin/coreconstants.h>
|
||||||
|
#include <coreplugin/icore.h>
|
||||||
#include <coreplugin/uniqueidmanager.h>
|
#include <coreplugin/uniqueidmanager.h>
|
||||||
#include <coreplugin/progressmanager/progressmanager.h>
|
|
||||||
#include <coreplugin/actionmanager/actionmanager.h>
|
#include <coreplugin/actionmanager/actionmanager.h>
|
||||||
|
#include <coreplugin/progressmanager/progressmanager.h>
|
||||||
#include <extensionsystem/pluginmanager.h>
|
#include <extensionsystem/pluginmanager.h>
|
||||||
#include <qtconcurrent/QtConcurrentTools>
|
#include <qtconcurrent/QtConcurrentTools>
|
||||||
|
|
||||||
|
@@ -41,7 +41,6 @@
|
|||||||
#include <QtCore/QHash>
|
#include <QtCore/QHash>
|
||||||
|
|
||||||
#include <coreplugin/dialogs/ioptionspage.h>
|
#include <coreplugin/dialogs/ioptionspage.h>
|
||||||
#include <coreplugin/icore.h>
|
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
class QListWidgetItem;
|
class QListWidgetItem;
|
||||||
|
@@ -17,21 +17,26 @@ class Proxy : public QObject
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Proxy() : QObject(0) {}
|
Proxy(QWidget *widget, QObject *parent = 0)
|
||||||
|
: QObject(parent), m_widget(widget)
|
||||||
|
{}
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void changeSelection(QWidget *w, const QList<QTextEdit::ExtraSelection> &s)
|
void changeSelection(const QList<QTextEdit::ExtraSelection> &s)
|
||||||
{
|
{
|
||||||
if (QPlainTextEdit *ed = qobject_cast<QPlainTextEdit *>(w))
|
if (QPlainTextEdit *ed = qobject_cast<QPlainTextEdit *>(m_widget))
|
||||||
ed->setExtraSelections(s);
|
ed->setExtraSelections(s);
|
||||||
else if (QTextEdit *ed = qobject_cast<QTextEdit *>(w))
|
else if (QTextEdit *ed = qobject_cast<QTextEdit *>(m_widget))
|
||||||
ed->setExtraSelections(s);
|
ed->setExtraSelections(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
void changeExtraInformation(QWidget *w, const QString &info)
|
void changeExtraInformation(const QString &info)
|
||||||
{
|
{
|
||||||
QMessageBox::information(w, "Information", info);
|
QMessageBox::information(m_widget, "Information", info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
QWidget *m_widget;
|
||||||
};
|
};
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
@@ -51,13 +56,13 @@ int main(int argc, char *argv[])
|
|||||||
widget = new QTextEdit;
|
widget = new QTextEdit;
|
||||||
title = "TextEdit";
|
title = "TextEdit";
|
||||||
}
|
}
|
||||||
|
widget->setObjectName("Editor");
|
||||||
widget->resize(450, 350);
|
widget->resize(450, 350);
|
||||||
widget->setFocus();
|
widget->setFocus();
|
||||||
|
|
||||||
Proxy proxy;
|
Proxy proxy(widget);
|
||||||
|
|
||||||
|
FakeVimHandler handler(widget, 0);
|
||||||
FakeVimHandler handler;
|
|
||||||
|
|
||||||
QMainWindow mw;
|
QMainWindow mw;
|
||||||
mw.setWindowTitle("Fakevim (" + title + ")");
|
mw.setWindowTitle("Fakevim (" + title + ")");
|
||||||
@@ -77,18 +82,18 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
QObject::connect(&handler, SIGNAL(commandBufferChanged(QString)),
|
QObject::connect(&handler, SIGNAL(commandBufferChanged(QString)),
|
||||||
mw.statusBar(), SLOT(showMessage(QString)));
|
mw.statusBar(), SLOT(showMessage(QString)));
|
||||||
QObject::connect(&handler, SIGNAL(quitRequested(QWidget *)),
|
QObject::connect(&handler, SIGNAL(quitRequested()),
|
||||||
&app, SLOT(quit()));
|
&app, SLOT(quit()));
|
||||||
QObject::connect(&handler,
|
QObject::connect(&handler,
|
||||||
SIGNAL(selectionChanged(QWidget*,QList<QTextEdit::ExtraSelection>)),
|
SIGNAL(selectionChanged(QList<QTextEdit::ExtraSelection>)),
|
||||||
&proxy, SLOT(changeSelection(QWidget*,QList<QTextEdit::ExtraSelection>)));
|
&proxy, SLOT(changeSelection(QList<QTextEdit::ExtraSelection>)));
|
||||||
QObject::connect(&handler,
|
QObject::connect(&handler,
|
||||||
SIGNAL(extraInformationChanged(QWidget*,QString)),
|
SIGNAL(extraInformationChanged(QString)),
|
||||||
&proxy, SLOT(changeExtraInformation(QWidget*,QString)));
|
&proxy, SLOT(changeExtraInformation(QString)));
|
||||||
|
|
||||||
handler.addWidget(widget);
|
handler.setupWidget();
|
||||||
if (args.size() >= 1)
|
if (args.size() >= 1)
|
||||||
handler.handleCommand(widget, "r " + args.at(0));
|
handler.handleCommand("r " + args.at(0));
|
||||||
|
|
||||||
return app.exec();
|
return app.exec();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user