Kate
katevimodebase.h
Go to the documentation of this file.
00001 /* This file is part of the KDE libraries and the Kate part. 00002 * 00003 * Copyright (C) 2008 - 2009 Erlend Hamberg <ehamberg@gmail.com> 00004 * Copyright (C) 2009 Paul Gideon Dann <pdgiddie@gmail.com> 00005 * 00006 * This library is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU Library General Public 00008 * License as published by the Free Software Foundation; either 00009 * version 2 of the License, or (at your option) any later version. 00010 * 00011 * This library is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 * Library General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU Library General Public License 00017 * along with this library; see the file COPYING.LIB. If not, write to 00018 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00019 * Boston, MA 02110-1301, USA. 00020 */ 00021 00022 #ifndef KATE_VI_MODE_BASE_INCLUDED 00023 #define KATE_VI_MODE_BASE_INCLUDED 00024 00025 #include <ktexteditor/cursor.h> 00026 #include "kateview.h" 00027 #include "katevirange.h" 00028 #include "kateviewinternal.h" 00029 00030 #include <QList> 00031 00032 using KTextEditor::Cursor; 00033 using KTextEditor::Range; 00034 00035 class QKeyEvent; 00036 class QString; 00037 class QRegExp; 00038 class QTimer; 00039 class KateDocument; 00040 class KateViVisualMode; 00041 class KateViNormalMode; 00042 class KateViInputModeManager; 00043 00044 class KateViModeBase : public QObject 00045 { 00046 Q_OBJECT 00047 00048 public: 00049 KateViModeBase() : QObject() {}; 00050 virtual ~KateViModeBase() {}; 00051 00055 QString getVerbatimKeys() const; 00056 00057 virtual void addMapping( const QString &from, const QString &to ) = 0; 00058 virtual const QString getMapping( const QString &from ) const = 0; 00059 virtual const QStringList getMappings() const = 0; 00060 00061 protected: 00062 // helper methods 00063 bool deleteRange( KateViRange &r, bool linewise = true, bool addToRegister = true ); 00064 const QString getRange( KateViRange &r, bool linewise = true ) const; 00065 const QString getLine( int lineNumber = -1 ) const; 00066 const QChar getCharUnderCursor() const; 00067 const QString getWordUnderCursor() const; 00068 KateViRange findPattern( const QString &pattern, bool backwards = false, int count = 1 ) const; 00069 Cursor findNextWordStart( int fromLine, int fromColumn, bool onlyCurrentLine = false ) const; 00070 Cursor findNextWORDStart( int fromLine, int fromColumn, bool onlyCurrentLine = false ) const; 00071 Cursor findPrevWordStart( int fromLine, int fromColumn, bool onlyCurrentLine = false ) const; 00072 Cursor findPrevWORDStart( int fromLine, int fromColumn, bool onlyCurrentLine = false ) const; 00073 Cursor findPrevWordEnd( int fromLine, int fromColumn, bool onlyCurrentLine = false ) const; 00074 Cursor findPrevWORDEnd( int fromLine, int fromColumn, bool onlyCurrentLine = false ) const; 00075 Cursor findWordEnd( int fromLine, int fromColumn, bool onlyCurrentLine = false ) const; 00076 Cursor findWORDEnd( int fromLine, int fromColumn, bool onlyCurrentLine = false ) const; 00077 KateViRange findSurrounding( const QChar &c1, const QChar &c2, bool inner = false ) const; 00078 KateViRange findSurrounding( const QRegExp &c1, const QRegExp &c2, bool inner = false ) const; 00079 int findLineStartingWitchChar( const QChar &c, unsigned int count, bool forward = true ) const; 00080 void updateCursor( const Cursor &c ) const; 00081 const QChar getCharAtVirtualColumn( QString &line, int virtualColumn, int tabWidht ) const; 00082 00083 void addToNumberUnderCursor( int count ); 00084 00085 KateViRange goLineUp(); 00086 KateViRange goLineDown(); 00087 KateViRange goLineUpDown( int lines); 00088 00089 unsigned int linesDisplayed() { return m_viewInternal->linesDisplayed(); } 00090 void scrollViewLines( int l ) { m_viewInternal->scrollViewLines( l ); } 00091 00092 unsigned int getCount() const { return ( m_count > 0 ) ? m_count : 1; } 00093 00094 bool startNormalMode(); 00095 bool startInsertMode(); 00096 bool startVisualMode(); 00097 bool startVisualLineMode(); 00098 bool startVisualBlockMode(); 00099 bool startReplaceMode(); 00100 00101 void error( const QString &errorMsg ) const; 00102 void message( const QString &msg ) const; 00103 00104 QChar getChosenRegister( const QChar &defaultReg ) const; 00105 QString getRegisterContent( const QChar ® ) const; 00106 void fillRegister( const QChar ®, const QString &text); 00107 00108 QChar m_register; 00109 00110 KateViRange m_commandRange; 00111 unsigned int m_count; 00112 00113 QString m_extraWordCharacters; 00114 QString m_keysVerbatim; 00115 00116 int m_stickyColumn; 00117 00118 inline KateDocument* doc() const { return m_view->doc(); }; 00119 00120 // key mappings 00121 int m_timeoutlen; // time to wait for the next keypress of a multi-key mapping (default: 1000 ms) 00122 QTimer *m_mappingTimer; 00123 00124 KateView *m_view; 00125 KateViewInternal *m_viewInternal; 00126 KateViInputModeManager* m_viInputModeManager; 00127 }; 00128 00129 #endif
KDE 4.6 API Reference