1 /**************************************************************************
3 ** This file is part of Qt Creator
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
7 ** Contact: Nokia Corporation (qt-info@nokia.com)
11 ** This file contains pre-release code and may not be distributed.
12 ** You may use this file in accordance with the terms and conditions
13 ** contained in the Technology Preview License Agreement accompanying
16 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25 ** In addition, as a special exception, Nokia gives you certain additional
26 ** rights. These rights are described in the Nokia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29 ** If you have questions regarding the use of this file, please contact
30 ** Nokia at qt-info@nokia.com.
32 **************************************************************************/
34 #ifndef FAKEVIM_HANDLER_H
35 #define FAKEVIM_HANDLER_H
37 #include "fakevimactions.h"
39 #include <QtCore/QObject>
40 #include <QtGui/QTextEdit>
49 RangeLineModeExclusive,
50 RangeBlockMode, // Ctrl-v
51 RangeBlockAndTailMode // Ctrl-v for D and X
57 Range(int b, int e, RangeMode m = RangeCharMode);
58 QString toString() const;
67 ExCommand() : hasBang(false), count(1) {}
68 ExCommand(const QString &cmd, const QString &args = QString(),
69 const Range &range = Range());
71 bool matches(const QString &min, const QString &full) const;
80 class FakeVimHandler : public QObject
85 explicit FakeVimHandler(QWidget *widget, QObject *parent = 0);
90 // call before widget is deleted
91 void disconnectFromEditor();
94 void setCurrentFileName(const QString &fileName);
95 QString currentFileName() const;
97 void showBlackMessage(const QString &msg);
98 void showRedMessage(const QString &msg);
100 // This executes an "ex" style command taking context
101 // information from the current widget.
102 void handleCommand(const QString &cmd);
104 void installEventFilter();
108 void restoreWidget(int tabSize);
111 int physicalIndentation(const QString &line) const;
112 int logicalIndentation(const QString &line) const;
113 QString tabExpand(int n) const;
116 void commandBufferChanged(const QString &msg);
117 void statusDataChanged(const QString &msg);
118 void extraInformationChanged(const QString &msg);
119 void selectionChanged(const QList<QTextEdit::ExtraSelection> &selection);
120 void writeAllRequested(QString *error);
121 void moveToMatchingParenthesis(bool *moved, bool *forward, QTextCursor *cursor);
122 void checkForElectricCharacter(bool *result, QChar c);
123 void indentRegion(int beginLine, int endLine, QChar typedChar);
124 void completionRequested();
125 void simpleCompletionRequested(const QString &needle, bool forward);
126 void windowCommandRequested(int key);
127 void findRequested(bool reverse);
128 void findNextRequested(bool reverse);
129 void handleExCommandRequested(bool *handled, const ExCommand &cmd);
130 void requestSetBlockSelection(bool on);
131 void requestHasBlockSelection(bool *on);
137 bool eventFilter(QObject *ob, QEvent *ev);
142 } // namespace Internal
143 } // namespace FakeVim
145 Q_DECLARE_METATYPE(FakeVim::Internal::ExCommand)
148 #endif // FAKEVIM_HANDLER_H