Kate
katevimodebase.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef KATE_VI_MODE_BASE_INCLUDED
00021 #define KATE_VI_MODE_BASE_INCLUDED
00022
00023 #include <ktexteditor/cursor.h>
00024 #include "kateview.h"
00025 #include "katevirange.h"
00026
00027 #include <QList>
00028
00029 class QKeyEvent;
00030 class QString;
00031 class QRegExp;
00032 class QTimer;
00033 class KateDocument;
00034 class KateViewInternal;
00035 class KateViVisualMode;
00036 class KateViNormalMode;
00037 class KateViInputModeManager;
00038
00039 class KateViModeBase : public QObject
00040 {
00041 Q_OBJECT
00042
00043 public:
00044 KateViModeBase() : QObject() {};
00045 virtual ~KateViModeBase() {};
00046
00050 QString getVerbatimKeys() const;
00051 void addMapping( const QString &from, const QString &to );
00052 const QString getMapping( const QString &from ) const;
00053 const QStringList getMappings() const;
00054
00055 protected:
00056
00057 bool deleteRange( KateViRange &r, bool linewise = true, bool addToRegister = true );
00058 const QString getRange( KateViRange &r, bool linewise = true ) const;
00059 const QString getLine( int lineNumber = -1 ) const;
00060 const QChar getCharUnderCursor() const;
00061 KTextEditor::Cursor findNextWordStart( int fromLine, int fromColumn, bool onlyCurrentLine = false ) const;
00062 KTextEditor::Cursor findNextWORDStart( int fromLine, int fromColumn, bool onlyCurrentLine = false ) const;
00063 KTextEditor::Cursor findPrevWordStart( int fromLine, int fromColumn, bool onlyCurrentLine = false ) const;
00064 KTextEditor::Cursor findPrevWORDStart( int fromLine, int fromColumn, bool onlyCurrentLine = false ) const;
00065 KTextEditor::Cursor findPrevWordEnd( int fromLine, int fromColumn, bool onlyCurrentLine = false ) const;
00066 KTextEditor::Cursor findPrevWORDEnd( int fromLine, int fromColumn, bool onlyCurrentLine = false ) const;
00067 KTextEditor::Cursor findWordEnd( int fromLine, int fromColumn, bool onlyCurrentLine = false ) const;
00068 KTextEditor::Cursor findWORDEnd( int fromLine, int fromColumn, bool onlyCurrentLine = false ) const;
00069 KateViRange findSurrounding( const QChar &c1, const QChar &c2, bool inner = false ) const;
00070 KateViRange findSurrounding( const QRegExp &c1, const QRegExp &c2, bool inner = false ) const;
00071 int findLineStartingWitchChar( const QChar &c, unsigned int count, bool forward = true ) const;
00072 void updateCursor( const KTextEditor::Cursor &c ) const;
00073
00074 KateViRange goLineUp();
00075 KateViRange goLineDown();
00076 KateViRange goLineUpDown( int lines);
00077
00078 unsigned int getCount() const { return ( m_count > 0 ) ? m_count : 1; }
00079
00080 bool startNormalMode();
00081 bool startInsertMode();
00082 bool startVisualMode();
00083 bool startVisualLineMode();
00084
00085 void error( const QString &errorMsg ) const;
00086 void message( const QString &msg ) const;
00087
00088 QChar getChosenRegister( const QChar &defaultReg ) const;
00089 QString getRegisterContent( const QChar ® ) const;
00090 void fillRegister( const QChar ®, const QString &text);
00091
00092 QChar m_register;
00093
00094 KateViRange m_commandRange;
00095 unsigned int m_count;
00096
00097 QString m_extraWordCharacters;
00098 QString m_keysVerbatim;
00099
00100 int m_stickyColumn;
00101
00102 inline KateDocument* doc() const { return m_view->doc(); };
00103
00104
00105 int m_timeoutlen;
00106 QTimer *m_mappingTimer;
00107 QHash <QString, QString> m_mappings;
00108
00109 KateView *m_view;
00110 KateViewInternal *m_viewInternal;
00111 KateViInputModeManager* m_viInputModeManager;
00112 };
00113
00114 #endif