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

Kate

  • kde-4.14
  • 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  bool commandChangeCaseLine();
84 
85  bool commandOpenNewLineUnder();
86  bool commandOpenNewLineOver();
87 
88  bool commandJoinLines();
89 
90  bool commandChange();
91  bool commandChangeLine();
92  bool commandChangeToEOL();
93  bool commandSubstituteChar();
94  bool commandSubstituteLine();
95 
96  bool commandYank();
97  bool commandYankLine();
98  bool commandYankToEOL();
99 
100  bool commandPaste();
101  bool commandPasteBefore();
102 
103  bool commandgPaste();
104  bool commandgPasteBefore();
105 
106  bool commandIndentedPaste();
107  bool commandIndentedPasteBefore();
108 
109  bool commandDeleteChar();
110  bool commandDeleteCharBackward();
111 
112  bool commandReplaceCharacter();
113 
114  bool commandSwitchToCmdLine();
115  bool commandSearchBackward();
116  bool commandSearchForward();
117  bool commandUndo();
118  bool commandRedo();
119 
120  bool commandSetMark();
121 
122  bool commandIndentLine();
123  bool commandUnindentLine();
124  bool commandIndentLines();
125  bool commandUnindentLines();
126 
127  bool commandScrollPageDown();
128  bool commandScrollPageUp();
129  bool commandScrollHalfPageUp();
130  bool commandScrollHalfPageDown();
131 
132  bool commandCenterView(bool onFirst);
133  bool commandCenterViewOnNonBlank();
134  bool commandCenterViewOnCursor();
135  bool commandTopView(bool onFirst);
136  bool commandTopViewOnNonBlank();
137  bool commandTopViewOnCursor();
138  bool commandBottomView(bool onFirst);
139  bool commandBottomViewOnNonBlank();
140  bool commandBottomViewOnCursor();
141 
142  bool commandAbort();
143 
144  bool commandPrintCharacterCode();
145 
146  bool commandRepeatLastChange();
147 
148  bool commandAlignLine();
149  bool commandAlignLines();
150 
151  bool commandAddToNumber();
152  bool commandSubtractFromNumber();
153 
154  bool commandPrependToBlock();
155  bool commandAppendToBlock();
156 
157  bool commandGoToNextJump();
158  bool commandGoToPrevJump();
159 
160  bool commandSwitchToLeftView();
161  bool commandSwitchToUpView();
162  bool commandSwitchToDownView();
163  bool commandSwitchToRightView();
164  bool commandSwitchToNextView();
165 
166  bool commandSplitHoriz();
167  bool commandSplitVert();
168 
169  bool commandSwitchToNextTab();
170  bool commandSwitchToPrevTab();
171 
172  bool commandFormatLine();
173  bool commandFormatLines();
174 
175  bool commandCollapseToplevelNodes();
176  bool commandCollapseLocal();
177  bool commandExpandAll();
178  bool commandExpandLocal();
179  bool commandToggleRegionVisibility();
180 
181  bool commandStartRecordingMacro();
182  bool commandReplayMacro();
183 
184  bool commandCloseWrite();
185  bool commandCloseNocheck();
186 
187  // MOTIONS
188 
189  KateViRange motionLeft();
190  KateViRange motionRight();
191  KateViRange motionDown();
192  KateViRange motionUp();
193 
194  KateViRange motionPageDown();
195  KateViRange motionPageUp();
196 
197  KateViRange motionUpToFirstNonBlank();
198  KateViRange motionDownToFirstNonBlank();
199 
200  KateViRange motionWordForward();
201  KateViRange motionWordBackward();
202  KateViRange motionWORDForward();
203  KateViRange motionWORDBackward();
204 
205  KateViRange motionToEndOfWord();
206  KateViRange motionToEndOfWORD();
207  KateViRange motionToEndOfPrevWord();
208  KateViRange motionToEndOfPrevWORD();
209 
210  KateViRange motionFindChar();
211  KateViRange motionFindCharBackward();
212  KateViRange motionToChar();
213  KateViRange motionToCharBackward();
214  KateViRange motionRepeatlastTF();
215  KateViRange motionRepeatlastTFBackward();
216  KateViRange motionFindNext();
217  KateViRange motionFindPrev();
218 
219 
220  KateViRange motionToEOL();
221  KateViRange motionToColumn0();
222  KateViRange motionToFirstCharacterOfLine();
223 
224  KateViRange motionToLineFirst();
225  KateViRange motionToLineLast();
226 
227  KateViRange motionToScreenColumn();
228 
229  KateViRange motionToMark();
230  KateViRange motionToMarkLine();
231 
232  KateViRange motionToMatchingItem();
233 
234  KateViRange motionToPreviousBraceBlockStart();
235  KateViRange motionToNextBraceBlockStart();
236  KateViRange motionToPreviousBraceBlockEnd();
237  KateViRange motionToNextBraceBlockEnd();
238 
239  KateViRange motionToNextOccurrence();
240  KateViRange motionToPrevOccurrence();
241 
242  KateViRange motionToFirstLineOfWindow();
243  KateViRange motionToMiddleLineOfWindow();
244  KateViRange motionToLastLineOfWindow();
245 
246  KateViRange motionToNextVisualLine();
247  KateViRange motionToPrevVisualLine();
248 
249  KateViRange motionToPreviousSentence();
250  KateViRange motionToNextSentence();
251 
252  KateViRange motionToBeforeParagraph();
253  KateViRange motionToAfterParagraph();
254 
255  KateViRange motionToIncrementalSearchMatch();
256 
257  // TEXT OBJECTS
258 
259  KateViRange textObjectAWord();
260  KateViRange textObjectInnerWord();
261  KateViRange textObjectAWORD();
262  KateViRange textObjectInnerWORD();
263 
264  KateViRange textObjectInnerSentence();
265  KateViRange textObjectASentence();
266 
267  KateViRange textObjectInnerParagraph();
268  KateViRange textObjectAParagraph();
269 
270  KateViRange textObjectAQuoteDouble();
271  KateViRange textObjectInnerQuoteDouble();
272 
273  KateViRange textObjectAQuoteSingle();
274  KateViRange textObjectInnerQuoteSingle();
275 
276  KateViRange textObjectABackQuote();
277  KateViRange textObjectInnerBackQuote();
278 
279  KateViRange textObjectAParen();
280  KateViRange textObjectInnerParen();
281 
282  KateViRange textObjectABracket();
283  KateViRange textObjectInnerBracket();
284 
285  KateViRange textObjectACurlyBracket();
286  KateViRange textObjectInnerCurlyBracket();
287 
288  KateViRange textObjectAInequalitySign();
289  KateViRange textObjectInnerInequalitySign();
290 
291  KateViRange textObjectAComma();
292  KateViRange textObjectInnerComma();
293 
294  void addCurrentPositionToJumpList();
295 
296  virtual void reset();
297 
298  void beginMonitoringDocumentChanges();
299  protected:
300  void resetParser();
301  void initializeCommands();
302  QRegExp generateMatchingItemRegex();
303  virtual void goToPos( const KateViRange &r );
304  void executeCommand( const KateViCommand* cmd );
305  OperationMode getOperationMode() const;
306  // The 'current position' is the current cursor position for non-linewise pastes, and the current
307  // line for linewise.
308  enum PasteLocation { AtCurrentPosition, AfterCurrentPosition };
309  bool paste(KateViNormalMode::PasteLocation pasteLocation, bool isgPaste, bool isIndentedPaste);
310  Cursor cursorPosAtEndOfPaste(const Cursor& pasteLocation, const QString& pastedText);
311 
312  void joinLines(unsigned int from, unsigned int to) const;
313  void reformatLines(unsigned int from, unsigned int to) const;
314 
323  int getFirstNonBlank(int line = -1) const;
324 
325  KateViRange textObjectComma(bool inner);
326  void shrinkRangeAroundCursor(KateViRange& toShrink, const KateViRange& rangeToShrinkTo);
327  Cursor findSentenceStart();
328  Cursor findSentenceEnd();
329  Cursor findParagraphStart();
330  Cursor findParagraphEnd();
331 
332  QString m_keys;
333  unsigned int m_countTemp;
334  bool m_findWaitingForChar;
335 
336  QVector<KateViCommand *> m_commands;
337  QVector<KateViMotion *> m_motions;
338  QVector<int> m_matchingCommands;
339  QVector<int> m_matchingMotions;
340  QStack<int> m_awaitingMotionOrTextObject;
341  bool motionWillBeUsedWithCommand() { return !m_awaitingMotionOrTextObject.isEmpty(); };
342 
343  int m_motionOperatorIndex;
344 
345  QString m_lastTFcommand; // holds the last t/T/f/F command so that it can be repeated with ;/,
346  bool m_isRepeatedTFcommand;
347 
348  bool m_linewiseCommand;
349  bool m_commandWithMotion;
350  bool m_lastMotionWasLinewiseInnerBlock;
351  bool m_motionCanChangeWholeVisualModeSelection;
352 
353  bool m_commandShouldKeepSelection;
354 
355  bool m_deleteCommand;
356 
357  uint m_scroll_count_limit;
358 
359  // registers
360  QChar m_defaultRegister;
361  QString m_registerTemp;
362 
363  // item matching ('%' motion)
364  QHash<QString, QString> m_matchingItems;
365  QRegExp m_matchItemRegex;
366 
367  KateViKeyParser *m_keyParser;
368 
369  // Ctrl-c or ESC have been pressed, leading to a call to reset().
370  bool m_pendingResetIsDueToExit;
371 
372  KTextEditor::Attribute::Ptr m_highlightYankAttribute;
373  QSet<KTextEditor::MovingRange *> m_highlightedYanks;
374 
375  void highlightYank(const KateViRange& range, const OperationMode mode = CharWise);
376  void addHighlightYank(const Range& range);
377  QSet<KTextEditor::MovingRange *> &highlightedYankForDocument();
378 
379  Cursor m_currentChangeEndMarker;
380 
381  bool m_isUndo;
382 
383  Cursor m_positionWhenIncrementalSearchBegan;
384 
385  bool waitingForRegisterOrCharToSearch();
386 private slots:
387  void textInserted(KTextEditor::Document* document, KTextEditor::Range range);
388  void textRemoved(KTextEditor::Document*,KTextEditor::Range);
389  void undoBeginning();
390  void undoEnded();
391 
392  void updateYankHighlightAttrib();
393  void clearYankHighlight();
394  void aboutToDeleteMovingInterfaceContent();
395 };
396 
397 #endif
katevirange.h
katevicommand.h
kateview.h
KateViNormalMode::m_keyParser
KateViKeyParser * m_keyParser
Definition: katevinormalmode.h:367
KateViNormalMode::PasteLocation
PasteLocation
Definition: katevinormalmode.h:308
CharWise
Definition: katevimodebase.h:50
KateViNormalMode::m_commandShouldKeepSelection
bool m_commandShouldKeepSelection
Definition: katevinormalmode.h:353
katevimodebase.h
KateViNormalMode::m_positionWhenIncrementalSearchBegan
Cursor m_positionWhenIncrementalSearchBegan
Definition: katevinormalmode.h:383
QChar
KateViNormalMode::m_matchingCommands
QVector< int > m_matchingCommands
Definition: katevinormalmode.h:338
KateViNormalMode::m_registerTemp
QString m_registerTemp
Definition: katevinormalmode.h:361
KateViModeBase
Definition: katevimodebase.h:64
KateViInputModeManager
Definition: kateviinputmodemanager.h:68
KATEPART_TESTS_EXPORT
#define KATEPART_TESTS_EXPORT
Definition: katepartprivate_export.h:36
KateViNormalMode::m_pendingResetIsDueToExit
bool m_pendingResetIsDueToExit
Definition: katevinormalmode.h:370
KateViNormalMode::m_commands
QVector< KateViCommand * > m_commands
Definition: katevinormalmode.h:336
KateViNormalMode::m_keys
QString m_keys
Definition: katevinormalmode.h:332
QRegExp
KateViModeBase::handleKeypress
virtual bool handleKeypress(const QKeyEvent *e)=0
KateViRange
Definition: katevirange.h:33
QHash< QString, QString >
katepartprivate_export.h
KateViNormalMode::m_lastMotionWasLinewiseInnerBlock
bool m_lastMotionWasLinewiseInnerBlock
Definition: katevinormalmode.h:350
KateViewInternal
Definition: kateviewinternal.h:58
KateViNormalMode::m_isUndo
bool m_isUndo
Definition: katevinormalmode.h:381
kateviewinternal.h
QSet< KTextEditor::MovingRange * >
KateViNormalMode::m_lastTFcommand
QString m_lastTFcommand
Definition: katevinormalmode.h:345
QString
KateView
Definition: kateview.h:77
KateViNormalMode::m_matchingMotions
QVector< int > m_matchingMotions
Definition: katevinormalmode.h:339
katevimotion.h
KateViNormalMode
Commands for the vi normal mode.
Definition: katevinormalmode.h:49
KateViNormalMode::m_isRepeatedTFcommand
bool m_isRepeatedTFcommand
Definition: katevinormalmode.h:346
KateViNormalMode::m_motions
QVector< KateViMotion * > m_motions
Definition: katevinormalmode.h:337
katevikeyparser.h
KateViMotion
combined class for motions and text objects.
Definition: katevimotion.h:38
KateViNormalMode::m_commandWithMotion
bool m_commandWithMotion
Definition: katevinormalmode.h:349
KateViNormalMode::m_awaitingMotionOrTextObject
QStack< int > m_awaitingMotionOrTextObject
Definition: katevinormalmode.h:340
QKeyEvent
KateViNormalMode::motionWillBeUsedWithCommand
bool motionWillBeUsedWithCommand()
Definition: katevinormalmode.h:341
KateViCommand
QVector< KateViCommand * >
KateViNormalMode::m_currentChangeEndMarker
Cursor m_currentChangeEndMarker
Definition: katevinormalmode.h:379
KateViNormalMode::m_findWaitingForChar
bool m_findWaitingForChar
Definition: katevinormalmode.h:334
OperationMode
OperationMode
Definition: katevimodebase.h:49
KateViNormalMode::m_deleteCommand
bool m_deleteCommand
Definition: katevinormalmode.h:355
KateViNormalMode::m_motionCanChangeWholeVisualModeSelection
bool m_motionCanChangeWholeVisualModeSelection
Definition: katevinormalmode.h:351
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:348
KateViNormalMode::m_countTemp
unsigned int m_countTemp
Definition: katevinormalmode.h:333
KateViNormalMode::m_highlightedYanks
QSet< KTextEditor::MovingRange * > m_highlightedYanks
Definition: katevinormalmode.h:373
KateViNormalMode::m_matchingItems
QHash< QString, QString > m_matchingItems
Definition: katevinormalmode.h:364
KateViNormalMode::m_highlightYankAttribute
KTextEditor::Attribute::Ptr m_highlightYankAttribute
Definition: katevinormalmode.h:372
KateViNormalMode::m_scroll_count_limit
uint m_scroll_count_limit
Definition: katevinormalmode.h:357
QStack< int >
KateViNormalMode::m_matchItemRegex
QRegExp m_matchItemRegex
Definition: katevinormalmode.h:365
KateViNormalMode::m_defaultRegister
QChar m_defaultRegister
Definition: katevinormalmode.h:360
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Sat May 9 2020 03:56:59 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
  • 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