forked from qt-creator/qt-creator
Fixes: fakevim: provide an option in the text editor settings
This commit is contained in:
@@ -2043,7 +2043,6 @@ FakeVimHandler::FakeVimHandler(QWidget *widget, QObject *parent)
|
|||||||
|
|
||||||
FakeVimHandler::~FakeVimHandler()
|
FakeVimHandler::~FakeVimHandler()
|
||||||
{
|
{
|
||||||
qDebug() << "DELETING HANDLER" << this;
|
|
||||||
delete d;
|
delete d;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -183,12 +183,6 @@ bool FakeVimPluginPrivate::initialize()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FakeVimPluginPrivate::installHandler()
|
|
||||||
{
|
|
||||||
if (Core::IEditor *editor = m_core->editorManager()->currentEditor())
|
|
||||||
installHandler(editor);
|
|
||||||
}
|
|
||||||
|
|
||||||
void FakeVimPluginPrivate::installHandler(Core::IEditor *editor)
|
void FakeVimPluginPrivate::installHandler(Core::IEditor *editor)
|
||||||
{
|
{
|
||||||
QWidget *widget = editor->widget();
|
QWidget *widget = editor->widget();
|
||||||
@@ -230,6 +224,8 @@ void FakeVimPluginPrivate::installHandler(Core::IEditor *editor)
|
|||||||
void FakeVimPluginPrivate::writeFile(bool *handled,
|
void FakeVimPluginPrivate::writeFile(bool *handled,
|
||||||
const QString &fileName, const QString &contents)
|
const QString &fileName, const QString &contents)
|
||||||
{
|
{
|
||||||
|
Q_UNUSED(contents);
|
||||||
|
|
||||||
FakeVimHandler *handler = qobject_cast<FakeVimHandler *>(sender());
|
FakeVimHandler *handler = qobject_cast<FakeVimHandler *>(sender());
|
||||||
if (!handler)
|
if (!handler)
|
||||||
return;
|
return;
|
||||||
@@ -260,6 +256,16 @@ void FakeVimPluginPrivate::editorOpened(Core::IEditor *editor)
|
|||||||
Q_UNUSED(editor);
|
Q_UNUSED(editor);
|
||||||
//qDebug() << "OPENING: " << editor << editor->widget();
|
//qDebug() << "OPENING: " << editor << editor->widget();
|
||||||
//installHandler(editor);
|
//installHandler(editor);
|
||||||
|
|
||||||
|
#if 1
|
||||||
|
QSettings *s = ICore::instance()->settings();
|
||||||
|
bool automatic = s->value("textInteractionSettings/UseVim").toBool();
|
||||||
|
//qDebug() << "USE VIM: " << automatic;
|
||||||
|
if (automatic)
|
||||||
|
installHandler(editor);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if 0
|
||||||
QWidget *widget = editor->widget();
|
QWidget *widget = editor->widget();
|
||||||
if (BaseTextEditor *bt = qobject_cast<BaseTextEditor *>(widget)) {
|
if (BaseTextEditor *bt = qobject_cast<BaseTextEditor *>(widget)) {
|
||||||
InteractionSettings settings = bt->interactionSettings();
|
InteractionSettings settings = bt->interactionSettings();
|
||||||
@@ -267,6 +273,7 @@ void FakeVimPluginPrivate::editorOpened(Core::IEditor *editor)
|
|||||||
if (settings.m_useVim)
|
if (settings.m_useVim)
|
||||||
installHandler(editor);
|
installHandler(editor);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void FakeVimPluginPrivate::editorAboutToClose(Core::IEditor *editor)
|
void FakeVimPluginPrivate::editorAboutToClose(Core::IEditor *editor)
|
||||||
|
@@ -416,7 +416,7 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
// the blocks list must be sorted
|
// the blocks list must be sorted
|
||||||
void setIfdefedOutBlocks(const QList<BaseTextEditor::BlockRange> &blocks);
|
void setIfdefedOutBlocks(const QList<BlockRange> &blocks);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
virtual void setTabSettings(const TextEditor::TabSettings &);
|
virtual void setTabSettings(const TextEditor::TabSettings &);
|
||||||
|
@@ -115,10 +115,11 @@ void GeneralSettingsPage::apply()
|
|||||||
newInteractionSettings);
|
newInteractionSettings);
|
||||||
|
|
||||||
Core::ICore *core = Core::ICore::instance();
|
Core::ICore *core = Core::ICore::instance();
|
||||||
|
QSettings *s = core->settings();
|
||||||
|
|
||||||
if (newTabSettings != m_d->m_tabSettings) {
|
if (newTabSettings != m_d->m_tabSettings) {
|
||||||
m_d->m_tabSettings = newTabSettings;
|
m_d->m_tabSettings = newTabSettings;
|
||||||
if (QSettings *s = core->settings())
|
if (s)
|
||||||
m_d->m_tabSettings.toSettings(m_d->m_parameters.settingsPrefix, s);
|
m_d->m_tabSettings.toSettings(m_d->m_parameters.settingsPrefix, s);
|
||||||
|
|
||||||
emit tabSettingsChanged(newTabSettings);
|
emit tabSettingsChanged(newTabSettings);
|
||||||
@@ -126,7 +127,7 @@ void GeneralSettingsPage::apply()
|
|||||||
|
|
||||||
if (newStorageSettings != m_d->m_storageSettings) {
|
if (newStorageSettings != m_d->m_storageSettings) {
|
||||||
m_d->m_storageSettings = newStorageSettings;
|
m_d->m_storageSettings = newStorageSettings;
|
||||||
if (QSettings *s = core->settings())
|
if (s)
|
||||||
m_d->m_storageSettings.toSettings(m_d->m_parameters.settingsPrefix, s);
|
m_d->m_storageSettings.toSettings(m_d->m_parameters.settingsPrefix, s);
|
||||||
|
|
||||||
emit storageSettingsChanged(newStorageSettings);
|
emit storageSettingsChanged(newStorageSettings);
|
||||||
@@ -134,7 +135,7 @@ void GeneralSettingsPage::apply()
|
|||||||
|
|
||||||
if (newDisplaySettings != m_d->m_displaySettings) {
|
if (newDisplaySettings != m_d->m_displaySettings) {
|
||||||
m_d->m_displaySettings = newDisplaySettings;
|
m_d->m_displaySettings = newDisplaySettings;
|
||||||
if (QSettings *s = core->settings())
|
if (s)
|
||||||
m_d->m_displaySettings.toSettings(m_d->m_parameters.settingsPrefix, s);
|
m_d->m_displaySettings.toSettings(m_d->m_parameters.settingsPrefix, s);
|
||||||
|
|
||||||
emit displaySettingsChanged(newDisplaySettings);
|
emit displaySettingsChanged(newDisplaySettings);
|
||||||
@@ -142,10 +143,9 @@ void GeneralSettingsPage::apply()
|
|||||||
|
|
||||||
if (newInteractionSettings != m_d->m_interactionSettings) {
|
if (newInteractionSettings != m_d->m_interactionSettings) {
|
||||||
m_d->m_interactionSettings = newInteractionSettings;
|
m_d->m_interactionSettings = newInteractionSettings;
|
||||||
if (QSettings *s = core->settings())
|
if (s)
|
||||||
m_d->m_interactionSettings.toSettings(m_d->m_parameters.settingsPrefix, s);
|
m_d->m_interactionSettings.toSettings(m_d->m_parameters.settingsPrefix, s);
|
||||||
|
|
||||||
emit interactionSettingsChanged(newInteractionSettings);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -83,7 +83,6 @@ signals:
|
|||||||
void tabSettingsChanged(const TextEditor::TabSettings &);
|
void tabSettingsChanged(const TextEditor::TabSettings &);
|
||||||
void storageSettingsChanged(const TextEditor::StorageSettings &);
|
void storageSettingsChanged(const TextEditor::StorageSettings &);
|
||||||
void displaySettingsChanged(const TextEditor::DisplaySettings &);
|
void displaySettingsChanged(const TextEditor::DisplaySettings &);
|
||||||
void interactionSettingsChanged(const TextEditor::InteractionSettings &);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void settingsFromUI(TabSettings &rc,
|
void settingsFromUI(TabSettings &rc,
|
||||||
|
@@ -38,7 +38,7 @@
|
|||||||
|
|
||||||
namespace TextEditor {
|
namespace TextEditor {
|
||||||
|
|
||||||
static const char *useVimKey = "useVim";
|
static const char *useVimKey = "UseVim";
|
||||||
static const char *groupPostfix = "InteractionSettings";
|
static const char *groupPostfix = "InteractionSettings";
|
||||||
|
|
||||||
InteractionSettings::InteractionSettings()
|
InteractionSettings::InteractionSettings()
|
||||||
|
@@ -43,10 +43,9 @@ using namespace QuickOpen;
|
|||||||
using namespace TextEditor;
|
using namespace TextEditor;
|
||||||
using namespace TextEditor::Internal;
|
using namespace TextEditor::Internal;
|
||||||
|
|
||||||
LineNumberFilter::LineNumberFilter(EditorManager *editorManager, QObject *parent):
|
LineNumberFilter::LineNumberFilter(QObject *parent)
|
||||||
IQuickOpenFilter(parent)
|
: IQuickOpenFilter(parent)
|
||||||
{
|
{
|
||||||
m_editorManager = editorManager;
|
|
||||||
setShortcutString("l");
|
setShortcutString("l");
|
||||||
setIncludedByDefault(true);
|
setIncludedByDefault(true);
|
||||||
}
|
}
|
||||||
@@ -65,17 +64,19 @@ void LineNumberFilter::accept(FilterEntry selection) const
|
|||||||
{
|
{
|
||||||
ITextEditor *editor = currentTextEditor();
|
ITextEditor *editor = currentTextEditor();
|
||||||
if (editor) {
|
if (editor) {
|
||||||
m_editorManager->ensureEditorManagerVisible();
|
Core::EditorManager *editorManager = Core::EditorManager::instance();
|
||||||
m_editorManager->addCurrentPositionToNavigationHistory(true);
|
editorManager->ensureEditorManagerVisible();
|
||||||
|
editorManager->addCurrentPositionToNavigationHistory(true);
|
||||||
editor->gotoLine(selection.internalData.toInt());
|
editor->gotoLine(selection.internalData.toInt());
|
||||||
m_editorManager->addCurrentPositionToNavigationHistory();
|
editorManager->addCurrentPositionToNavigationHistory();
|
||||||
editor->widget()->setFocus();
|
editor->widget()->setFocus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ITextEditor *LineNumberFilter::currentTextEditor() const
|
ITextEditor *LineNumberFilter::currentTextEditor() const
|
||||||
{
|
{
|
||||||
if (!m_editorManager->currentEditor())
|
Core::EditorManager *editorManager = Core::EditorManager::instance();
|
||||||
|
if (!editorManager->currentEditor())
|
||||||
return 0;
|
return 0;
|
||||||
return qobject_cast<TextEditor::ITextEditor*>(m_editorManager->currentEditor());
|
return qobject_cast<TextEditor::ITextEditor*>(editorManager->currentEditor());
|
||||||
}
|
}
|
||||||
|
@@ -38,13 +38,7 @@
|
|||||||
|
|
||||||
#include <QtCore/QString>
|
#include <QtCore/QString>
|
||||||
#include <QtCore/QList>
|
#include <QtCore/QList>
|
||||||
#include <QtCore/QByteArray>
|
|
||||||
#include <QtCore/QFutureInterface>
|
#include <QtCore/QFutureInterface>
|
||||||
#include <QtGui/QWidget>
|
|
||||||
|
|
||||||
namespace Core {
|
|
||||||
class EditorManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace TextEditor {
|
namespace TextEditor {
|
||||||
|
|
||||||
@@ -57,7 +51,8 @@ class LineNumberFilter : public QuickOpen::IQuickOpenFilter
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
LineNumberFilter(Core::EditorManager *editorManager, QObject *parent = 0);
|
explicit LineNumberFilter(QObject *parent = 0);
|
||||||
|
|
||||||
QString trName() const { return tr("Line in current document"); }
|
QString trName() const { return tr("Line in current document"); }
|
||||||
QString name() const { return "Line in current document"; }
|
QString name() const { return "Line in current document"; }
|
||||||
QuickOpen::IQuickOpenFilter::Priority priority() const { return QuickOpen::IQuickOpenFilter::High; }
|
QuickOpen::IQuickOpenFilter::Priority priority() const { return QuickOpen::IQuickOpenFilter::High; }
|
||||||
@@ -67,8 +62,6 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
ITextEditor *currentTextEditor() const;
|
ITextEditor *currentTextEditor() const;
|
||||||
|
|
||||||
Core::EditorManager *m_editorManager;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
@@ -42,6 +42,7 @@
|
|||||||
#include "plaintexteditorfactory.h"
|
#include "plaintexteditorfactory.h"
|
||||||
#include "plaintexteditor.h"
|
#include "plaintexteditor.h"
|
||||||
#include "storagesettings.h"
|
#include "storagesettings.h"
|
||||||
|
#include "interactionsettings.h"
|
||||||
|
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
#include <coreplugin/coreconstants.h>
|
#include <coreplugin/coreconstants.h>
|
||||||
@@ -104,7 +105,7 @@ bool TextEditorPlugin::initialize(const QStringList &arguments, QString *errorMe
|
|||||||
addAutoReleasedObject(m_wizard);
|
addAutoReleasedObject(m_wizard);
|
||||||
|
|
||||||
|
|
||||||
m_settings = new TextEditorSettings(this, this);
|
m_settings = new TextEditorSettings(this);
|
||||||
|
|
||||||
// Add plain text editor factory
|
// Add plain text editor factory
|
||||||
m_editorFactory = new PlainTextEditorFactory;
|
m_editorFactory = new PlainTextEditorFactory;
|
||||||
@@ -112,7 +113,7 @@ bool TextEditorPlugin::initialize(const QStringList &arguments, QString *errorMe
|
|||||||
|
|
||||||
// Goto line functionality for quick open
|
// Goto line functionality for quick open
|
||||||
Core::ICore *core = Core::ICore::instance();
|
Core::ICore *core = Core::ICore::instance();
|
||||||
m_lineNumberFilter = new LineNumberFilter(core->editorManager());
|
m_lineNumberFilter = new LineNumberFilter;
|
||||||
addAutoReleasedObject(m_lineNumberFilter);
|
addAutoReleasedObject(m_lineNumberFilter);
|
||||||
|
|
||||||
int contextId = core->uniqueIDManager()->uniqueIdentifier(TextEditor::Constants::C_TEXTEDITOR);
|
int contextId = core->uniqueIDManager()->uniqueIdentifier(TextEditor::Constants::C_TEXTEDITOR);
|
||||||
|
@@ -51,8 +51,7 @@ using namespace TextEditor::Constants;
|
|||||||
|
|
||||||
TextEditorSettings *TextEditorSettings::m_instance = 0;
|
TextEditorSettings *TextEditorSettings::m_instance = 0;
|
||||||
|
|
||||||
TextEditorSettings::TextEditorSettings(Internal::TextEditorPlugin *plugin,
|
TextEditorSettings::TextEditorSettings(QObject *parent)
|
||||||
QObject *parent)
|
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(!m_instance, return);
|
QTC_ASSERT(!m_instance, return);
|
||||||
|
@@ -46,11 +46,6 @@ class FontSettings;
|
|||||||
struct TabSettings;
|
struct TabSettings;
|
||||||
struct StorageSettings;
|
struct StorageSettings;
|
||||||
struct DisplaySettings;
|
struct DisplaySettings;
|
||||||
struct InteractionSettings;
|
|
||||||
|
|
||||||
namespace Internal {
|
|
||||||
class TextEditorPlugin;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class provides a central place for basic text editor settings. These
|
* This class provides a central place for basic text editor settings. These
|
||||||
@@ -62,7 +57,7 @@ class TEXTEDITOR_EXPORT TextEditorSettings : public QObject
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TextEditorSettings(Internal::TextEditorPlugin *plugin, QObject *parent);
|
explicit TextEditorSettings(QObject *parent);
|
||||||
~TextEditorSettings();
|
~TextEditorSettings();
|
||||||
|
|
||||||
static TextEditorSettings *instance();
|
static TextEditorSettings *instance();
|
||||||
@@ -71,14 +66,12 @@ public:
|
|||||||
TabSettings tabSettings() const;
|
TabSettings tabSettings() const;
|
||||||
StorageSettings storageSettings() const;
|
StorageSettings storageSettings() const;
|
||||||
DisplaySettings displaySettings() const;
|
DisplaySettings displaySettings() const;
|
||||||
InteractionSettings interactionSettings() const;
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void fontSettingsChanged(const TextEditor::FontSettings &);
|
void fontSettingsChanged(const TextEditor::FontSettings &);
|
||||||
void tabSettingsChanged(const TextEditor::TabSettings &);
|
void tabSettingsChanged(const TextEditor::TabSettings &);
|
||||||
void storageSettingsChanged(const TextEditor::StorageSettings &);
|
void storageSettingsChanged(const TextEditor::StorageSettings &);
|
||||||
void displaySettingsChanged(const TextEditor::DisplaySettings &);
|
void displaySettingsChanged(const TextEditor::DisplaySettings &);
|
||||||
void interactionSettingsChanged(const TextEditor::InteractionSettings &);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TextEditor::FontSettingsPage *m_fontSettingsPage;
|
TextEditor::FontSettingsPage *m_fontSettingsPage;
|
||||||
|
Reference in New Issue
Block a user