fakevim: begin work on tab/space configuration

This commit is contained in:
hjk
2009-01-09 16:48:36 +01:00
parent 5632709e0a
commit 80748aa73b
6 changed files with 78 additions and 4 deletions

View File

@@ -16,4 +16,5 @@ SOURCES += \
HEADERS += \ HEADERS += \
handler.h \ handler.h \
fakevimplugin.h fakevimplugin.h \
fakevimconstants.h

View File

@@ -0,0 +1,53 @@
/***************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Qt Software Information (qt-info@nokia.com)
**
**
** Non-Open Source Usage
**
** Licensees may use this file in accordance with the Qt Beta Version
** License Agreement, Agreement version 2.2 provided with the Software or,
** alternatively, in accordance with the terms contained in a written
** agreement between you and Nokia.
**
** GNU General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU General
** Public License versions 2.0 or 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the packaging
** of this file. Please review the following information to ensure GNU
** General Public Licensing requirements will be met:
**
** http://www.fsf.org/licensing/licenses/info/GPLv2.html and
** http://www.gnu.org/copyleft/gpl.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt GPL Exception
** version 1.3, included in the file GPL_EXCEPTION.txt in this package.
**
***************************************************************************/
#ifndef FAKEVIMCONSTANTS_H
#define FAKEVIMCONSTANTS_H
namespace FakeVim {
namespace Constants {
const char * const ConfigOn = "on";
const char * const ConfigOff = "off";
const char * const ConfigStartOfLine = "startofline";
const char * const ConfigTabStop = "tabstop";
const char * const ConfigSmartTab = "smarttab";
const char * const ConfigShiftWidth = "shiftwidth";
const char * const ConfigExpandTab = "expandtab";
} // namespace Constants
} // namespace FakeVim
#endif // FAKEVIMCONSTANTS_H

View File

@@ -156,6 +156,8 @@ void FakeVimPlugin::installHandler()
this, SLOT(showCommandBuffer(QString))); this, SLOT(showCommandBuffer(QString)));
connect(m_handler, SIGNAL(quitRequested(QWidget *)), connect(m_handler, SIGNAL(quitRequested(QWidget *)),
this, SLOT(removeHandler(QWidget *))); this, SLOT(removeHandler(QWidget *)));
connect(m_handler, SIGNAL(configurationNeeded(QHash<QString, QString> *)),
this, SLOT(initializeConfiguration(QHash<QString, QString> *)));
m_handler->addWidget(textEditor->widget()); m_handler->addWidget(textEditor->widget());
} }
@@ -179,6 +181,14 @@ void FakeVimPlugin::showExtraInformation(const QString &text)
QMessageBox::information(0, tr("FakeVim Information"), text); QMessageBox::information(0, tr("FakeVim Information"), text);
} }
void FakeVimPlugin::initializeConfiguaration(QHash<QString, QString> *config)
{
qDebug() << "INIT CONFIG";
//set shiftwidth=4
//set expandtab
//set smarttab
}
//#include "fakevimplugin.moc" //#include "fakevimplugin.moc"

View File

@@ -42,6 +42,7 @@ QT_BEGIN_NAMESPACE
class QAction; class QAction;
class QCursor; class QCursor;
class QAbstractItemView; class QAbstractItemView;
template <class Key, class Value> class QHash;
QT_END_NAMESPACE QT_END_NAMESPACE
@@ -83,6 +84,7 @@ private slots:
void removeHandler(QWidget *widget); void removeHandler(QWidget *widget);
void showCommandBuffer(const QString &contents); void showCommandBuffer(const QString &contents);
void showExtraInformation(const QString &msg); void showExtraInformation(const QString &msg);
void initializeConfiguaration(QHash<QString, QString> *config);
private: private:
FakeVimHandler *m_handler; FakeVimHandler *m_handler;

View File

@@ -33,6 +33,8 @@
#include "handler.h" #include "handler.h"
#include "fakevimconstants.h"
#include <QtCore/QDebug> #include <QtCore/QDebug>
#include <QtCore/QFile> #include <QtCore/QFile>
#include <QtCore/QObject> #include <QtCore/QObject>
@@ -53,6 +55,7 @@
using namespace FakeVim::Internal; using namespace FakeVim::Internal;
using namespace FakeVim::Constants;
#define StartOfLine QTextCursor::StartOfLine #define StartOfLine QTextCursor::StartOfLine
#define EndOfLine QTextCursor::EndOfLine #define EndOfLine QTextCursor::EndOfLine
@@ -114,9 +117,6 @@ enum VisualMode
VisualBlockMode, VisualBlockMode,
}; };
static const QString ConfigStartOfLine = "startofline";
static const QString ConfigOn = "on";
struct EditOperation struct EditOperation
{ {
EditOperation() : m_position(-1), m_itemCount(0) {} EditOperation() : m_position(-1), m_itemCount(0) {}
@@ -282,6 +282,12 @@ FakeVimHandler::Private::Private(FakeVimHandler *parent)
m_visualMode = NoVisualMode; m_visualMode = NoVisualMode;
m_config[ConfigStartOfLine] = ConfigOn; m_config[ConfigStartOfLine] = ConfigOn;
m_config[ConfigTabStop] = 8;
m_config[ConfigSmartTab] = ConfigOff;
m_config[ConfigShiftWidth] = 8;
m_config[ConfigExpandTab] = ConfigOff;
emit q->configurationNeeded(&m_config);
} }
bool FakeVimHandler::Private::handleEvent(QKeyEvent *ev) bool FakeVimHandler::Private::handleEvent(QKeyEvent *ev)

View File

@@ -39,6 +39,7 @@
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QString; class QString;
class QEvent; class QEvent;
template <class Key, class Value> class QHash;
QT_END_NAMESPACE QT_END_NAMESPACE
namespace FakeVim { namespace FakeVim {
@@ -68,6 +69,7 @@ signals:
void statusDataChanged(const QString &msg); void statusDataChanged(const QString &msg);
void extraInformationChanged(const QString &msg); void extraInformationChanged(const QString &msg);
void quitRequested(QWidget *); void quitRequested(QWidget *);
void configurationNeeded(QHash<QString, QString> *config);
private: private:
bool eventFilter(QObject *ob, QEvent *ev); bool eventFilter(QObject *ob, QEvent *ev);