• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • applications API Reference
  • KDE Home
  • Contact Us
 

Kate

  • sources
  • kde-4.12
  • applications
  • kate
  • part
  • vimode
kateviinputmodemanager.h
Go to the documentation of this file.
1 /* This file is part of the KDE libraries and the Kate part.
2  *
3  * Copyright (C) 2008 Erlend Hamberg <ehamberg@gmail.com>
4  * Copyright (C) 2011 Svyatoslav Kuzmich <svatoslav1@gmail.com>
5  * Copyright (C) 2012 - 2013 Simon St James <kdedevel@etotheipiplusone.com>
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Library General Public
9  * License as published by the Free Software Foundation; either
10  * version 2 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Library General Public License for more details.
16  *
17  * You should have received a copy of the GNU Library General Public License
18  * along with this library; see the file COPYING.LIB. If not, write to
19  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20  * Boston, MA 02110-1301, USA.
21  */
22 
23 #ifndef KATE_VI_INPUT_MODE_MANAGER_INCLUDED
24 #define KATE_VI_INPUT_MODE_MANAGER_INCLUDED
25 
26 #include <QKeyEvent>
27 #include <QList>
28 #include "katepartprivate_export.h"
29 #include <ktexteditor/cursor.h>
30 #include "katedocument.h"
31 
32 class KConfigGroup;
33 class KateView;
34 class KateDocument;
35 class KateViewInternal;
36 class KateViModeBase;
37 class KateViNormalMode;
38 class KateViInsertMode;
39 class KateViVisualMode;
40 class KateViReplaceMode;
41 class KateViKeyParser;
42 class KateViKeyMapper;
43 class QString;
44 
48 enum ViMode {
49  NormalMode,
50  InsertMode,
51  VisualMode,
52  VisualLineMode,
53  VisualBlockMode,
54  ReplaceMode
55 };
56 
57 struct KateViJump {
58  int line;
59  int column;
60 };
61 
62 namespace KTextEditor {
63  class MovingCursor;
64  class Mark;
65  class MarkInterface;
66 }
67 
68 class KATEPART_TESTS_EXPORT KateViInputModeManager : public QObject
69 {
70  Q_OBJECT
71 
72 public:
73  KateViInputModeManager(KateView* view, KateViewInternal* viewInternal);
74  ~KateViInputModeManager();
75 
80  bool handleKeypress(const QKeyEvent *e);
81 
85  void feedKeyPresses(const QString &keyPresses) const;
86 
91  bool isHandlingKeypress() const;
92 
96  ViMode getCurrentViMode() const;
97 
101  KateViModeBase* getCurrentViModeHandler() const;
102 
103  const QString getVerbatimKeys() const;
104 
108  void changeViMode(ViMode newMode);
109 
113  void viEnterNormalMode();
114 
118  void viEnterInsertMode();
119 
123  void viEnterVisualMode( ViMode visualMode = VisualMode );
124 
128  void viEnterReplaceMode();
129 
133  KateViNormalMode* getViNormalMode();
134 
138  KateViInsertMode* getViInsertMode();
139 
143  KateViVisualMode* getViVisualMode();
144 
148  KateViReplaceMode* getViReplaceMode();
149 
153  bool isReplayingLastChange() const { return m_isReplayingLastChange; }
154 
158  void appendKeyEventToLog(const QKeyEvent &e);
159 
163  void clearCurrentChangeLog() { m_currentChangeKeyEventsLog.clear(); m_currentChangeCompletionsLog.clear(); }
164 
168  void storeLastChangeCommand();
169 
173  void repeatLastChange();
174 
175  class Completion
176  {
177  public:
178  enum CompletionType { PlainText, FunctionWithoutArgs, FunctionWithArgs };
179  Completion(const QString& completedText, bool removeTail, CompletionType completionType);
180  QString completedText() const;
181  bool removeTail() const;
182  CompletionType completionType() const;
183  private:
184  QString m_completedText;
185  bool m_removeTail;
186  CompletionType m_completionType;
187  };
188  void startRecordingMacro(QChar macroRegister);
189  void finishRecordingMacro();
190  bool isRecordingMacro();
191  void replayMacro(QChar macroRegister);
192  bool isReplayingMacro();
193  void logCompletionEvent(const Completion& completion);
194  Completion nextLoggedCompletion();
195  void doNotLogCurrentKeypress();
196 
202  const QString getLastSearchPattern() const;
203 
209  void setLastSearchPattern( const QString &p );
210 
214  bool lastSearchBackwards() const { return m_lastSearchBackwards; }
215 
219  void setLastSearchBackwards( bool b ) { m_lastSearchBackwards = b; }
220 
221  void setLastSearchCaseSensitive(bool caseSensitive) { m_lastSearchCaseSensitive = caseSensitive; };
222 
223  void setLastSearchPlacesCursorAtEndOfMatch(bool b) { m_lastSearchPlacedCursorAtEndOfMatch = b; };
224 
225  bool lastSearchCaseSensitive() { return m_lastSearchCaseSensitive; };
226 
227  bool lastSearchPlacesCursorAtEndOfMatch() { return m_lastSearchPlacedCursorAtEndOfMatch; };
228 
229  bool getTemporaryNormalMode() { return m_temporaryNormalMode; }
230 
231  void setTemporaryNormalMode(bool b) { m_temporaryNormalMode = b; }
232 
233  void reset();
234 
235  // Jump Lists
236  void addJump(KTextEditor::Cursor cursor);
237  KTextEditor::Cursor getNextJump(KTextEditor::Cursor cursor);
238  KTextEditor::Cursor getPrevJump(KTextEditor::Cursor cursor);
239  void PrintJumpList();
240 
241  // session stuff
242  void readSessionConfig( const KConfigGroup& config );
243  void writeSessionConfig( KConfigGroup& config );
244 
245  // marks
258  void addMark( KateDocument* doc, const QChar& mark, const KTextEditor::Cursor& pos,
259  const bool moveoninsert = true, const bool showmark = true );
260  KTextEditor::Cursor getMarkPosition( const QChar& mark ) const;
261  void syncViMarksAndBookmarks();
262  QString getMarksOnTheLine(int line);
263 
269  static QString modeToString(ViMode mode);
270 
271  KateViKeyMapper* keyMapper();
272 
273 private Q_SLOTS:
274  void markChanged (KTextEditor::Document* doc,
275  KTextEditor::Mark mark,
276  KTextEditor::MarkInterface::MarkChangeAction action);
277 
278 private:
279  KateViNormalMode* m_viNormalMode;
280  KateViInsertMode* m_viInsertMode;
281  KateViVisualMode* m_viVisualMode;
282  KateViReplaceMode* m_viReplaceMode;
283 
284  ViMode m_currentViMode;
285 
286  KateView *m_view;
287  KateViewInternal *m_viewInternal;
288  KateViKeyParser *m_keyParser;
289 
290  // Create a new keymapper for each macro event, to simplify expansion of mappings in macros
291  // where the macro itself was triggered by expanding a mapping!
292  QStack<QSharedPointer<KateViKeyMapper> > m_keyMapperStack;
293 
294  int m_insideHandlingKeyPressCount;
295 
299  bool m_isReplayingLastChange;
300 
301  bool m_isRecordingMacro;
302 
303  QChar m_recordingMacroRegister;
304  QList<QKeyEvent> m_currentMacroKeyEventsLog;
305 
306  int m_macrosBeingReplayedCount;
307  QChar m_lastPlayedMacroRegister;
308 
309  QList<Completion> m_currentMacroCompletionsLog;
310 
316  QStack<QList<Completion> > m_macroCompletionsToReplay;
317  QStack< int > m_nextLoggedMacroCompletionIndex;
318 
323  QList<QKeyEvent> m_currentChangeKeyEventsLog;
324  QList<Completion> m_currentChangeCompletionsLog;
325  QList<Completion> m_lastChangeCompletionsLog;
326  int m_nextLoggedLastChangeComplexIndex;
327 
331  QString m_lastChange;
332 
333  QString m_lastSearchPattern;
337  bool m_lastSearchBackwards;
341  bool m_lastSearchCaseSensitive;
342 
343  bool m_lastSearchPlacedCursorAtEndOfMatch;
344 
348  bool m_temporaryNormalMode;
349 
353  bool m_markSetInsideViInputModeManager;
354 
355  // jump list
356  QList<KateViJump> *jump_list;
357  QList<KateViJump>::iterator current_jump;
358 
359  // marks
360  QMap<QChar, KTextEditor::MovingCursor*> m_marks;
361 
362 };
363 
364 #endif
InsertMode
Definition: kateviinputmodemanager.h:50
KateViInputModeManager::getTemporaryNormalMode
bool getTemporaryNormalMode()
Definition: kateviinputmodemanager.h:229
cursor.h
KateViModeBase
Definition: katevimodebase.h:64
VisualMode
Definition: kateviinputmodemanager.h:51
KateViInputModeManager::setLastSearchBackwards
void setLastSearchBackwards(bool b)
set search direction of last search.
Definition: kateviinputmodemanager.h:219
ReplaceMode
Definition: kateviinputmodemanager.h:54
katedocument.h
KateViInputModeManager
Definition: kateviinputmodemanager.h:68
KATEPART_TESTS_EXPORT
#define KATEPART_TESTS_EXPORT
Definition: katepartprivate_export.h:36
NormalMode
Definition: kateviinputmodemanager.h:49
QString
QObject
KTextEditor::Cursor
KateViJump
Definition: kateviinputmodemanager.h:57
KTextEditor::MarkInterface::MarkChangeAction
MarkChangeAction
KateViJump::line
int line
Definition: kateviinputmodemanager.h:58
KTextEditor::Document
KateViInputModeManager::Completion::PlainText
Definition: kateviinputmodemanager.h:178
katepartprivate_export.h
KateViJump::column
int column
Definition: kateviinputmodemanager.h:59
KateViewInternal
Definition: kateviewinternal.h:57
KTextEditor::Mark
KateViInputModeManager::setLastSearchPlacesCursorAtEndOfMatch
void setLastSearchPlacesCursorAtEndOfMatch(bool b)
Definition: kateviinputmodemanager.h:223
KateViVisualMode
Definition: katevivisualmode.h:34
ViMode
ViMode
The four vi modes supported by Kate's vi input mode.
Definition: kateviinputmodemanager.h:48
KateViKeyMapper
Definition: katevikeymapper.h:33
KateView
Definition: kateview.h:78
VisualBlockMode
Definition: kateviinputmodemanager.h:53
KateDocument
Definition: katedocument.h:74
KateViInputModeManager::Completion::CompletionType
CompletionType
Definition: kateviinputmodemanager.h:178
KateViInputModeManager::Completion
Definition: kateviinputmodemanager.h:175
KateViNormalMode
Commands for the vi normal mode.
Definition: katevinormalmode.h:49
VisualLineMode
Definition: kateviinputmodemanager.h:52
KConfigGroup
KateViInputModeManager::lastSearchBackwards
bool lastSearchBackwards() const
get search direction of last search.
Definition: kateviinputmodemanager.h:214
KateViInputModeManager::lastSearchCaseSensitive
bool lastSearchCaseSensitive()
Definition: kateviinputmodemanager.h:225
KateViInputModeManager::isReplayingLastChange
bool isReplayingLastChange() const
Definition: kateviinputmodemanager.h:153
KateViKeyParser
for encoding keypresses w/ modifiers into an internal QChar representation and back again to a descri...
Definition: katevikeyparser.h:37
KateViReplaceMode
Commands for the vi replace mode.
Definition: katevireplacemode.h:35
KateViInputModeManager::clearCurrentChangeLog
void clearCurrentChangeLog()
clear the key event log
Definition: kateviinputmodemanager.h:163
reset
KGuiItem reset()
KateViInsertMode
Definition: kateviinsertmode.h:45
KateViInputModeManager::lastSearchPlacesCursorAtEndOfMatch
bool lastSearchPlacesCursorAtEndOfMatch()
Definition: kateviinputmodemanager.h:227
KateViInputModeManager::setTemporaryNormalMode
void setTemporaryNormalMode(bool b)
Definition: kateviinputmodemanager.h:231
QMap< QChar, KTextEditor::MovingCursor * >
QList< QKeyEvent >
KateViInputModeManager::setLastSearchCaseSensitive
void setLastSearchCaseSensitive(bool caseSensitive)
Definition: kateviinputmodemanager.h:221
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:31:53 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

Kate

Skip menu "Kate"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

applications API Reference

Skip menu "applications API Reference"
  •   kate
  •       kate
  •   KTextEditor
  •   Kate
  • Applications
  •   Libraries
  •     libkonq
  • Konsole

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal