• 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
katevinormalmode.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 - 2009 Erlend Hamberg <ehamberg@gmail.com>
4  * Copyright (C) 2009 Paul Gideon Dann <pdgiddie@gmail.com>
5  * Copyright (C) 2011 Svyatoslav Kuzmich <svatoslav1@gmail.com>
6  * Copyright (C) 2012 - 2013 Simon St James <kdedevel@etotheipiplusone.com>
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Library General Public
10  * License as published by the Free Software Foundation; either
11  * version 2 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Library General Public License for more details.
17  *
18  * You should have received a copy of the GNU Library General Public License
19  * along with this library; see the file COPYING.LIB. If not, write to
20  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21  * Boston, MA 02110-1301, USA.
22  */
23 
24 #ifndef KATE_VI_NORMAL_MODE_INCLUDED
25 #define KATE_VI_NORMAL_MODE_INCLUDED
26 
27 #include "kateview.h"
28 #include "kateviewinternal.h"
29 #include "katevicommand.h"
30 #include "katevimotion.h"
31 #include "katevirange.h"
32 #include "katevimodebase.h"
33 
34 #include <QKeyEvent>
35 #include <QVector>
36 #include <QStack>
37 #include <QHash>
38 #include <QRegExp>
39 #include <ktexteditor/cursor.h>
40 #include "katevikeyparser.h"
41 #include "katepartprivate_export.h"
42 
43 class KateViMotion;
44 class KateViInputModeManager;
45 
49 class KATEPART_TESTS_EXPORT KateViNormalMode : public KateViModeBase
50 {
51  Q_OBJECT
52 
53  public:
54  KateViNormalMode( KateViInputModeManager *viInputModeManager, KateView * view, KateViewInternal * viewInternal );
55  virtual ~KateViNormalMode();
56 
57  bool handleKeypress( const QKeyEvent *e );
58 
59  bool commandEnterInsertMode();
60  bool commandEnterInsertModeAppend();
61  bool commandEnterInsertModeAppendEOL();
62  bool commandEnterInsertModeBeforeFirstNonBlankInLine();
63  bool commandEnterInsertModeLast();
64 
65  bool commandEnterVisualMode();
66  bool commandEnterVisualLineMode();
67  bool commandEnterVisualBlockMode();
68  bool commandReselectVisual();
69  bool commandToOtherEnd();
70 
71  bool commandEnterReplaceMode();
72 
73  bool commandDelete();
74  bool commandDeleteToEOL();
75  bool commandDeleteLine();
76 
77  bool commandMakeLowercase();
78  bool commandMakeLowercaseLine();
79  bool commandMakeUppercase();
80  bool commandMakeUppercaseLine();
81  bool commandChangeCase();
82  bool commandChangeCaseRange();
83 
84  bool commandOpenNewLineUnder();
85  bool commandOpenNewLineOver();
86 
87  bool commandJoinLines();
88 
89  bool commandChange();
90  bool commandChangeLine();
91  bool commandChangeToEOL();
92  bool commandSubstituteChar();
93  bool commandSubstituteLine();
94 
95  bool commandYank();
96  bool commandYankLine();
97  bool commandYankToEOL();
98 
99  bool commandPaste();
100  bool commandPasteBefore();
101 
102  bool commandgPaste();
103  bool commandgPasteBefore();
104 
105  bool commandIndentedPaste();
106  bool commandIndentedPasteBefore();
107 
108  bool commandDeleteChar();
109  bool commandDeleteCharBackward();
110 
111  bool commandReplaceCharacter();
112 
113  bool commandSwitchToCmdLine();
114  bool commandSearchBackward();
115  bool commandSearchForward();
116  bool commandUndo();
117  bool commandRedo();
118 
119  bool commandSetMark();
120 
121  bool commandIndentLine();
122  bool commandUnindentLine();
123  bool commandIndentLines();
124  bool commandUnindentLines();
125 
126  bool commandScrollPageDown();
127  bool commandScrollPageUp();
128  bool commandScrollHalfPageUp();
129  bool commandScrollHalfPageDown();
130 
131  bool commandCentreViewOnCursor();
132 
133  bool commandAbort();
134 
135  bool commandPrintCharacterCode();
136 
137  bool commandRepeatLastChange();
138 
139  bool commandAlignLine();
140  bool commandAlignLines();
141 
142  bool commandAddToNumber();
143  bool commandSubtractFromNumber();
144 
145  bool commandPrependToBlock();
146  bool commandAppendToBlock();
147 
148  bool commandGoToNextJump();
149  bool commandGoToPrevJump();
150 
151  bool commandSwitchToLeftView();
152  bool commandSwitchToUpView();
153  bool commandSwitchToDownView();
154  bool commandSwitchToRightView();
155  bool commandSwitchToNextView();
156 
157  bool commandSplitHoriz();
158  bool commandSplitVert();
159 
160  bool commandSwitchToNextTab();
161  bool commandSwitchToPrevTab();
162 
163  bool commandFormatLine();
164  bool commandFormatLines();
165 
166  bool commandCollapseToplevelNodes();
167  bool commandCollapseLocal();
168  bool commandExpandAll();
169  bool commandExpandLocal();
170  bool commandToggleRegionVisibility();
171 
172  bool commandStartRecordingMacro();
173  bool commandReplayMacro();
174 
175  // MOTIONS
176 
177  KateViRange motionLeft();
178  KateViRange motionRight();
179  KateViRange motionDown();
180  KateViRange motionUp();
181 
182  KateViRange motionPageDown();
183  KateViRange motionPageUp();
184 
185  KateViRange motionUpToFirstNonBlank();
186  KateViRange motionDownToFirstNonBlank();
187 
188  KateViRange motionWordForward();
189  KateViRange motionWordBackward();
190  KateViRange motionWORDForward();
191  KateViRange motionWORDBackward();
192 
193  KateViRange motionToEndOfWord();
194  KateViRange motionToEndOfWORD();
195  KateViRange motionToEndOfPrevWord();
196  KateViRange motionToEndOfPrevWORD();
197 
198  KateViRange motionFindChar();
199  KateViRange motionFindCharBackward();
200  KateViRange motionToChar();
201  KateViRange motionToCharBackward();
202  KateViRange motionRepeatlastTF();
203  KateViRange motionRepeatlastTFBackward();
204  KateViRange motionFindNext();
205  KateViRange motionFindPrev();
206 
207 
208  KateViRange motionToEOL();
209  KateViRange motionToColumn0();
210  KateViRange motionToFirstCharacterOfLine();
211 
212  KateViRange motionToLineFirst();
213  KateViRange motionToLineLast();
214 
215  KateViRange motionToScreenColumn();
216 
217  KateViRange motionToMark();
218  KateViRange motionToMarkLine();
219 
220  KateViRange motionToMatchingItem();
221 
222  KateViRange motionToPreviousBraceBlockStart();
223  KateViRange motionToNextBraceBlockStart();
224  KateViRange motionToPreviousBraceBlockEnd();
225  KateViRange motionToNextBraceBlockEnd();
226 
227  KateViRange motionToNextOccurrence();
228  KateViRange motionToPrevOccurrence();
229 
230  KateViRange motionToFirstLineOfWindow();
231  KateViRange motionToMiddleLineOfWindow();
232  KateViRange motionToLastLineOfWindow();
233 
234  KateViRange motionToNextVisualLine();
235  KateViRange motionToPrevVisualLine();
236 
237  KateViRange motionToBeforeParagraph();
238  KateViRange motionToAfterParagraph();
239 
240  KateViRange motionToIncrementalSearchMatch();
241 
242  // TEXT OBJECTS
243 
244  KateViRange textObjectAWord();
245  KateViRange textObjectInnerWord();
246  KateViRange textObjectAWORD();
247  KateViRange textObjectInnerWORD();
248 
249  KateViRange textObjectAQuoteDouble();
250  KateViRange textObjectInnerQuoteDouble();
251 
252  KateViRange textObjectAQuoteSingle();
253  KateViRange textObjectInnerQuoteSingle();
254 
255  KateViRange textObjectABackQuote();
256  KateViRange textObjectInnerBackQuote();
257 
258  KateViRange textObjectAParen();
259  KateViRange textObjectInnerParen();
260 
261  KateViRange textObjectABracket();
262  KateViRange textObjectInnerBracket();
263 
264  KateViRange textObjectACurlyBracket();
265  KateViRange textObjectInnerCurlyBracket();
266 
267  KateViRange textObjectAInequalitySign();
268  KateViRange textObjectInnerInequalitySign();
269 
270  KateViRange textObjectAComma();
271  KateViRange textObjectInnerComma();
272 
273  void addCurrentPositionToJumpList();
274 
275  virtual void reset();
276 
277  void beginMonitoringDocumentChanges();
278  protected:
279  void resetParser();
280  void initializeCommands();
281  QRegExp generateMatchingItemRegex();
282  virtual void goToPos( const KateViRange &r );
283  void executeCommand( const KateViCommand* cmd );
284  OperationMode getOperationMode() const;
285  // The 'current position' is the current cursor position for non-linewise pastes, and the current
286  // line for linewise.
287  enum PasteLocation { AtCurrentPosition, AfterCurrentPosition };
288  bool paste(KateViNormalMode::PasteLocation pasteLocation, bool isgPaste, bool isIndentedPaste);
289  Cursor cursorPosAtEndOfPaste(const Cursor& pasteLocation, const QString& pastedText);
290 
291  void joinLines(unsigned int from, unsigned int to) const;
292  void reformatLines(unsigned int from, unsigned int to) const;
293 
294  KateViRange textObjectComma(bool inner);
295  void shrinkRangeAroundCursor(KateViRange& toShrink, const KateViRange& rangeToShrinkTo);
296 
297  QString m_keys;
298  unsigned int m_countTemp;
299  bool m_findWaitingForChar;
300 
301  QVector<KateViCommand *> m_commands;
302  QVector<KateViMotion *> m_motions;
303  QVector<int> m_matchingCommands;
304  QVector<int> m_matchingMotions;
305  QStack<int> m_awaitingMotionOrTextObject;
306  bool motionWillBeUsedWithCommand() { return !m_awaitingMotionOrTextObject.isEmpty(); };
307 
308  int m_motionOperatorIndex;
309 
310  QString m_lastTFcommand; // holds the last t/T/f/F command so that it can be repeated with ;/,
311  bool m_isRepeatedTFcommand;
312 
313  bool m_linewiseCommand;
314  bool m_commandWithMotion;
315  bool m_lastMotionWasLinewiseInnerBlock;
316  bool m_motionCanChangeWholeVisualModeSelection;
317 
318  bool m_commandShouldKeepSelection;
319 
320  bool m_deleteCommand;
321 
322  uint m_scroll_count_limit;
323 
324  // registers
325  QChar m_defaultRegister;
326  QString m_registerTemp;
327 
328  // item matching ('%' motion)
329  QHash<QString, QString> m_matchingItems;
330  QRegExp m_matchItemRegex;
331 
332  KateViKeyParser *m_keyParser;
333 
334  // Ctrl-c or ESC have been pressed, leading to a call to reset().
335  bool m_pendingResetIsDueToExit;
336 
337  KTextEditor::Attribute::Ptr m_highlightYankAttribute;
338  KTextEditor::MovingRange* m_highlightedYank;
339 
340  void highlightYank(const KateViRange& range);
341  KTextEditor::MovingRange*& highlightedYankForDocument();
342 
343  Cursor m_currentChangeEndMarker;
344 
345  bool m_isUndo;
346 
347  Cursor m_positionWhenIncrementalSearchBegan;
348 
349  bool waitingForRegisterOrCharToSearch();
350 private slots:
351  void textInserted(KTextEditor::Document* document, KTextEditor::Range range);
352  void textRemoved(KTextEditor::Document*,KTextEditor::Range);
353  void undoBeginning();
354  void undoEnded();
355 
356  void updateYankHighlightAttrib();
357  void clearYankHighlight();
358  void aboutToDeleteMovingInterfaceContent();
359 };
360 
361 #endif
katevirange.h
KSharedPtr< Attribute >
katevicommand.h
kateview.h
KateViNormalMode::m_keyParser
KateViKeyParser * m_keyParser
Definition: katevinormalmode.h:332
KateViNormalMode::PasteLocation
PasteLocation
Definition: katevinormalmode.h:287
KateViNormalMode::m_commandShouldKeepSelection
bool m_commandShouldKeepSelection
Definition: katevinormalmode.h:318
katevimodebase.h
KateViNormalMode::m_positionWhenIncrementalSearchBegan
Cursor m_positionWhenIncrementalSearchBegan
Definition: katevinormalmode.h:347
KateViNormalMode::m_matchingCommands
QVector< int > m_matchingCommands
Definition: katevinormalmode.h:303
KateViNormalMode::m_registerTemp
QString m_registerTemp
Definition: katevinormalmode.h:326
cursor.h
KateViModeBase
Definition: katevimodebase.h:64
KateViInputModeManager
Definition: kateviinputmodemanager.h:68
KATEPART_TESTS_EXPORT
#define KATEPART_TESTS_EXPORT
Definition: katepartprivate_export.h:36
KTextEditor::MovingRange
KateViNormalMode::m_pendingResetIsDueToExit
bool m_pendingResetIsDueToExit
Definition: katevinormalmode.h:335
QString
QHash< QString, QString >
KTextEditor::Cursor
paste
KAction * paste(const QObject *recvr, const char *slot, QObject *parent)
KateViNormalMode::m_commands
QVector< KateViCommand * > m_commands
Definition: katevinormalmode.h:301
KateViNormalMode::m_keys
QString m_keys
Definition: katevinormalmode.h:297
KateViModeBase::handleKeypress
virtual bool handleKeypress(const QKeyEvent *e)=0
KateViRange
Definition: katevirange.h:33
KTextEditor::Document
KateViNormalMode::m_highlightedYank
KTextEditor::MovingRange * m_highlightedYank
Definition: katevinormalmode.h:338
katepartprivate_export.h
KateViNormalMode::m_lastMotionWasLinewiseInnerBlock
bool m_lastMotionWasLinewiseInnerBlock
Definition: katevinormalmode.h:315
KateViewInternal
Definition: kateviewinternal.h:57
KateViNormalMode::m_isUndo
bool m_isUndo
Definition: katevinormalmode.h:345
kateviewinternal.h
KateViNormalMode::m_lastTFcommand
QString m_lastTFcommand
Definition: katevinormalmode.h:310
KateView
Definition: kateview.h:78
KTextEditor::Range
KateViNormalMode::m_matchingMotions
QVector< int > m_matchingMotions
Definition: katevinormalmode.h:304
katevimotion.h
KateViNormalMode
Commands for the vi normal mode.
Definition: katevinormalmode.h:49
KateViNormalMode::m_isRepeatedTFcommand
bool m_isRepeatedTFcommand
Definition: katevinormalmode.h:311
KateViNormalMode::m_motions
QVector< KateViMotion * > m_motions
Definition: katevinormalmode.h:302
katevikeyparser.h
KateViMotion
combined class for motions and text objects.
Definition: katevimotion.h:38
KateViNormalMode::m_commandWithMotion
bool m_commandWithMotion
Definition: katevinormalmode.h:314
KateViNormalMode::m_awaitingMotionOrTextObject
QStack< int > m_awaitingMotionOrTextObject
Definition: katevinormalmode.h:305
KateViNormalMode::motionWillBeUsedWithCommand
bool motionWillBeUsedWithCommand()
Definition: katevinormalmode.h:306
KateViCommand
KateViNormalMode::m_currentChangeEndMarker
Cursor m_currentChangeEndMarker
Definition: katevinormalmode.h:343
KateViNormalMode::m_findWaitingForChar
bool m_findWaitingForChar
Definition: katevinormalmode.h:299
OperationMode
OperationMode
Definition: katevimodebase.h:49
KateViNormalMode::m_deleteCommand
bool m_deleteCommand
Definition: katevinormalmode.h:320
KateViNormalMode::m_motionCanChangeWholeVisualModeSelection
bool m_motionCanChangeWholeVisualModeSelection
Definition: katevinormalmode.h:316
KateViKeyParser
for encoding keypresses w/ modifiers into an internal QChar representation and back again to a descri...
Definition: katevikeyparser.h:37
KateViNormalMode::m_linewiseCommand
bool m_linewiseCommand
Definition: katevinormalmode.h:313
KateViNormalMode::m_countTemp
unsigned int m_countTemp
Definition: katevinormalmode.h:298
reset
KGuiItem reset()
KateViNormalMode::m_matchingItems
QHash< QString, QString > m_matchingItems
Definition: katevinormalmode.h:329
KateViNormalMode::m_highlightYankAttribute
KTextEditor::Attribute::Ptr m_highlightYankAttribute
Definition: katevinormalmode.h:337
KateViNormalMode::m_scroll_count_limit
uint m_scroll_count_limit
Definition: katevinormalmode.h:322
KateViNormalMode::m_matchItemRegex
QRegExp m_matchItemRegex
Definition: katevinormalmode.h:330
KateViNormalMode::m_defaultRegister
QChar m_defaultRegister
Definition: katevinormalmode.h:325
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