• 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
katevimodebase.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_MODE_BASE_INCLUDED
25 #define KATE_VI_MODE_BASE_INCLUDED
26 
27 #include <ktexteditor/cursor.h>
28 #include "kateview.h"
29 #include "katevirange.h"
30 #include "kateviewinternal.h"
31 #include "katepartprivate_export.h"
32 #include "katedocument.h"
33 #include "katelayoutcache.h"
34 
35 #include <QList>
36 
37 using KTextEditor::Cursor;
38 using KTextEditor::Range;
39 
40 class QKeyEvent;
41 class QString;
42 class QRegExp;
43 class QTimer;
44 class KateDocument;
45 class KateViVisualMode;
46 class KateViNormalMode;
47 class KateViInputModeManager;
48 
49 enum OperationMode {
50  CharWise = 0,
51  LineWise,
52  Block
53 };
54 
55 enum Direction {
56  Up,
57  Down,
58  Left,
59  Right,
60  Next,
61  Prev
62 };
63 
64 class KATEPART_TESTS_EXPORT KateViModeBase : public QObject
65 {
66  Q_OBJECT
67 
68  public:
69  KateViModeBase()
70  : QObject(),
71  m_count(0),
72  m_oneTimeCountOverride(-1),
73  m_iscounted(false),
74  m_stickyColumn(-1)
75  {
76  }
77  virtual ~KateViModeBase() {}
78 
82  QString getVerbatimKeys() const;
83  virtual bool handleKeypress( const QKeyEvent *e ) = 0;
84 
85  void setCount(unsigned int count) { m_count = count; }
86  void setRegister(QChar reg) {m_register = reg;}
87 
88  void error( const QString &errorMsg );
89  void message( const QString &msg );
90 
91  Range findPattern( const QString& pattern, bool backwards, bool caseSensitive, const Cursor& startFrom, int count = -1 /* i.e use getCount() */ ) const;
92  protected:
93  // helper methods
94  void yankToClipBoard(QChar chosen_register, QString text);
95  bool deleteRange( KateViRange &r, OperationMode mode = LineWise, bool addToRegister = true );
96  const QString getRange( KateViRange &r, OperationMode mode = LineWise ) const;
97  const QString getLine(int line = -1) const;
98  const QChar getCharUnderCursor() const;
99  const QString getWordUnderCursor() const;
100  const Range getWordRangeUnderCursor() const;
101  KateViRange findPatternForMotion( const QString& pattern, bool backwards, bool caseSensitive, const Cursor& startFrom, int count = 1 ) const;
102  Cursor findNextWordStart( int fromLine, int fromColumn, bool onlyCurrentLine = false ) const;
103  Cursor findNextWORDStart( int fromLine, int fromColumn, bool onlyCurrentLine = false ) const;
104  Cursor findPrevWordStart( int fromLine, int fromColumn, bool onlyCurrentLine = false ) const;
105  Cursor findPrevWORDStart( int fromLine, int fromColumn, bool onlyCurrentLine = false ) const;
106  Cursor findPrevWordEnd( int fromLine, int fromColumn, bool onlyCurrentLine = false ) const;
107  Cursor findPrevWORDEnd( int fromLine, int fromColumn, bool onlyCurrentLine = false ) const;
108  Cursor findWordEnd( int fromLine, int fromColumn, bool onlyCurrentLine = false ) const;
109  Cursor findWORDEnd( int fromLine, int fromColumn, bool onlyCurrentLine = false ) const;
110 
111  KateViRange findSurroundingBrackets( const QChar &c1, const QChar &c2, bool inner,
112  const QChar &nested1 , const QChar &nested2 ) const;
113  KateViRange findSurrounding( const QRegExp &c1, const QRegExp &c2, bool inner = false ) const;
114  KateViRange findSurroundingQuotes( const QChar &c, bool inner = false ) const;
115 
116  int findLineStartingWitchChar( const QChar &c, unsigned int count, bool forward = true ) const;
117  void updateCursor( const Cursor &c ) const;
118  const QChar getCharAtVirtualColumn( QString &line, int virtualColumn, int tabWidht ) const;
119 
120  void addToNumberUnderCursor( int count );
121 
122  KateViRange goLineUp();
123  KateViRange goLineDown();
124  KateViRange goLineUpDown( int lines);
125  KateViRange goVisualLineUpDown(int lines);
126 
127 
128  unsigned int linesDisplayed() { return m_viewInternal->linesDisplayed(); }
129  void scrollViewLines( int l ) { m_viewInternal->scrollViewLines( l ); }
130 
131  unsigned int getCount() const {
132  if (m_oneTimeCountOverride != -1)
133  {
134  return m_oneTimeCountOverride;
135  }
136  return ( m_count > 0 ) ? m_count : 1;
137  }
138  bool isCounted() { return m_iscounted; }
139 
140  bool startNormalMode();
141  bool startInsertMode();
142  bool startVisualMode();
143  bool startVisualLineMode();
144  bool startVisualBlockMode();
145  bool startReplaceMode();
146 
147  QChar getChosenRegister( const QChar &defaultReg ) const;
148  QString getRegisterContent( const QChar &reg );
149  OperationMode getRegisterFlag( const QChar &reg ) const;
150  void fillRegister( const QChar &reg, const QString &text, OperationMode flag = CharWise);
151 
152  void switchView(Direction direction = Next);
153 
154  QChar m_register;
155 
156  void addJump(KTextEditor::Cursor cursor);
157  KTextEditor::Cursor getNextJump(KTextEditor::Cursor);
158  KTextEditor::Cursor getPrevJump(KTextEditor::Cursor);
159 
160  KateViRange m_commandRange;
161  unsigned int m_count;
162  int m_oneTimeCountOverride;
163  bool m_iscounted;
164 
165  QString m_extraWordCharacters;
166  QString m_keysVerbatim;
167 
168  int m_stickyColumn;
169  bool m_lastMotionWasVisualLineUpOrDown;
170  bool m_currentMotionWasVisualLineUpOrDown;
171 
172  inline KateDocument* doc() const { return m_view->doc(); };
173 
174 
175  KateView *m_view;
176  KateViewInternal *m_viewInternal;
177  KateViInputModeManager* m_viInputModeManager;
178 
179  // info message of vi mode
180  QPointer<KTextEditor::Message> m_infoMessage;
181 };
182 
183 #endif
katevirange.h
kateview.h
KateViModeBase::m_infoMessage
QPointer< KTextEditor::Message > m_infoMessage
Definition: katevimodebase.h:180
CharWise
Definition: katevimodebase.h:50
KateViModeBase::m_currentMotionWasVisualLineUpOrDown
bool m_currentMotionWasVisualLineUpOrDown
Definition: katevimodebase.h:170
QChar
KateViModeBase::m_count
unsigned int m_count
Definition: katevimodebase.h:161
KateViModeBase::KateViModeBase
KateViModeBase()
Definition: katevimodebase.h:69
KateViModeBase
Definition: katevimodebase.h:64
QPointer< KTextEditor::Message >
katedocument.h
KateViInputModeManager
Definition: kateviinputmodemanager.h:68
KATEPART_TESTS_EXPORT
#define KATEPART_TESTS_EXPORT
Definition: katepartprivate_export.h:36
KateViModeBase::m_commandRange
KateViRange m_commandRange
Definition: katevimodebase.h:160
KateViModeBase::isCounted
bool isCounted()
Definition: katevimodebase.h:138
KateViModeBase::m_oneTimeCountOverride
int m_oneTimeCountOverride
Definition: katevimodebase.h:162
QRegExp
QTimer
KateViRange
Definition: katevirange.h:33
Up
Definition: katevimodebase.h:56
KateViModeBase::setCount
void setCount(unsigned int count)
Definition: katevimodebase.h:85
QObject
Left
Definition: katevimodebase.h:58
katelayoutcache.h
katepartprivate_export.h
KateViModeBase::scrollViewLines
void scrollViewLines(int l)
Definition: katevimodebase.h:129
KateViewInternal
Definition: kateviewinternal.h:58
KateViModeBase::~KateViModeBase
virtual ~KateViModeBase()
Definition: katevimodebase.h:77
KateViVisualMode
Definition: katevivisualmode.h:34
kateviewinternal.h
KateViModeBase::setRegister
void setRegister(QChar reg)
Definition: katevimodebase.h:86
QString
KateViModeBase::linesDisplayed
unsigned int linesDisplayed()
Definition: katevimodebase.h:128
Next
Definition: katevimodebase.h:60
Direction
Direction
Definition: katevimodebase.h:55
KateViModeBase::m_iscounted
bool m_iscounted
Definition: katevimodebase.h:163
KateViModeBase::m_stickyColumn
int m_stickyColumn
Definition: katevimodebase.h:168
KateView
Definition: kateview.h:77
KateViModeBase::getCount
unsigned int getCount() const
Definition: katevimodebase.h:131
LineWise
Definition: katevimodebase.h:51
KateDocument
Definition: katedocument.h:74
KateViNormalMode
Commands for the vi normal mode.
Definition: katevinormalmode.h:49
Down
Definition: katevimodebase.h:57
KateViModeBase::m_keysVerbatim
QString m_keysVerbatim
Definition: katevimodebase.h:166
QKeyEvent
Prev
Definition: katevimodebase.h:61
KateViModeBase::m_viInputModeManager
KateViInputModeManager * m_viInputModeManager
Definition: katevimodebase.h:177
KateViModeBase::m_extraWordCharacters
QString m_extraWordCharacters
Definition: katevimodebase.h:165
OperationMode
OperationMode
Definition: katevimodebase.h:49
KateViModeBase::m_lastMotionWasVisualLineUpOrDown
bool m_lastMotionWasVisualLineUpOrDown
Definition: katevimodebase.h:169
Block
Definition: katevimodebase.h:52
KateViModeBase::m_viewInternal
KateViewInternal * m_viewInternal
Definition: katevimodebase.h:176
Right
Definition: katevimodebase.h:59
KateViModeBase::m_register
QChar m_register
Definition: katevimodebase.h:154
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