Kate
katevinormalmode.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_NORMAL_MODE_INCLUDED 00023 #define KATE_VI_NORMAL_MODE_INCLUDED 00024 00025 #include "kateview.h" 00026 #include "kateviewinternal.h" 00027 #include "katevicommand.h" 00028 #include "katevimotion.h" 00029 #include "katevirange.h" 00030 #include "katevimodebase.h" 00031 00032 #include <QKeyEvent> 00033 #include <QVector> 00034 #include <QStack> 00035 #include <QHash> 00036 #include <QRegExp> 00037 #include <ktexteditor/cursor.h> 00038 #include "katevikeyparser.h" 00039 00040 class KateViMotion; 00041 class KateViInputModeManager; 00042 00043 namespace KTextEditor { 00044 class MovingCursor; 00045 } 00046 00050 class KateViNormalMode : public KateViModeBase 00051 { 00052 Q_OBJECT 00053 00054 public slots: 00055 void mappingTimerTimeOut(); 00056 00057 public: 00058 KateViNormalMode( KateViInputModeManager *viInputModeManager, KateView * view, KateViewInternal * viewInternal ); 00059 virtual ~KateViNormalMode(); 00060 00061 bool handleKeypress( const QKeyEvent *e ); 00062 00063 bool commandEnterInsertMode(); 00064 bool commandEnterInsertModeAppend(); 00065 bool commandEnterInsertModeAppendEOL(); 00066 bool commandEnterInsertModeBeforeFirstNonBlankInLine(); 00067 00068 bool commandEnterVisualMode(); 00069 bool commandEnterVisualLineMode(); 00070 bool commandEnterVisualBlockMode(); 00071 bool commandToOtherEnd(); 00072 00073 bool commandEnterReplaceMode(); 00074 00075 bool commandDelete(); 00076 bool commandDeleteToEOL(); 00077 bool commandDeleteLine(); 00078 00079 bool commandMakeLowercase(); 00080 bool commandMakeLowercaseLine(); 00081 bool commandMakeUppercase(); 00082 bool commandMakeUppercaseLine(); 00083 bool commandChangeCase(); 00084 00085 bool commandOpenNewLineUnder(); 00086 bool commandOpenNewLineOver(); 00087 00088 bool commandJoinLines(); 00089 00090 bool commandChange(); 00091 bool commandChangeLine(); 00092 bool commandChangeToEOL(); 00093 bool commandSubstituteChar(); 00094 bool commandSubstituteLine(); 00095 00096 bool commandYank(); 00097 bool commandYankLine(); 00098 bool commandYankToEOL(); 00099 00100 bool commandPaste(); 00101 bool commandPasteBefore(); 00102 00103 bool commandDeleteChar(); 00104 bool commandDeleteCharBackward(); 00105 00106 bool commandReplaceCharacter(); 00107 00108 bool commandSwitchToCmdLine(); 00109 bool commandSearch(); 00110 bool commandUndo(); 00111 bool commandRedo(); 00112 00113 bool commandSetMark(); 00114 00115 bool commandIndentLine(); 00116 bool commandUnindentLine(); 00117 bool commandIndentLines(); 00118 bool commandUnindentLines(); 00119 00120 bool commandScrollPageDown(); 00121 bool commandScrollPageUp(); 00122 bool commandCentreViewOnCursor(); 00123 00124 bool commandAbort(); 00125 00126 bool commandPrintCharacterCode(); 00127 00128 bool commandRepeatLastChange(); 00129 00130 bool commandAlignLine(); 00131 bool commandAlignLines(); 00132 00133 bool commandAddToNumber(); 00134 bool commandSubtractFromNumber(); 00135 00136 // MOTIONS 00137 00138 KateViRange motionLeft(); 00139 KateViRange motionRight(); 00140 KateViRange motionDown(); 00141 KateViRange motionUp(); 00142 00143 KateViRange motionPageDown(); 00144 KateViRange motionPageUp(); 00145 00146 KateViRange motionUpToFirstNonBlank(); 00147 KateViRange motionDownToFirstNonBlank(); 00148 00149 KateViRange motionWordForward(); 00150 KateViRange motionWordBackward(); 00151 KateViRange motionWORDForward(); 00152 KateViRange motionWORDBackward(); 00153 00154 KateViRange motionToEndOfWord(); 00155 KateViRange motionToEndOfWORD(); 00156 KateViRange motionToEndOfPrevWord(); 00157 KateViRange motionToEndOfPrevWORD(); 00158 00159 KateViRange motionFindChar(); 00160 KateViRange motionFindCharBackward(); 00161 KateViRange motionToChar(); 00162 KateViRange motionToCharBackward(); 00163 KateViRange motionRepeatlastTF(); 00164 KateViRange motionRepeatlastTFBackward(); 00165 KateViRange motionFindNext(); 00166 KateViRange motionFindPrev(); 00167 00168 00169 KateViRange motionToEOL(); 00170 KateViRange motionToColumn0(); 00171 KateViRange motionToFirstCharacterOfLine(); 00172 00173 KateViRange motionToLineFirst(); 00174 KateViRange motionToLineLast(); 00175 00176 KateViRange motionToScreenColumn(); 00177 00178 KateViRange motionToMark(); 00179 KateViRange motionToMarkLine(); 00180 00181 KateViRange motionToMatchingItem(); 00182 00183 KateViRange motionToPreviousBraceBlockStart(); 00184 KateViRange motionToNextBraceBlockStart(); 00185 KateViRange motionToPreviousBraceBlockEnd(); 00186 KateViRange motionToNextBraceBlockEnd(); 00187 00188 KateViRange motionToNextOccurrence(); 00189 KateViRange motionToPrevOccurrence(); 00190 00191 // TEXT OBJECTS 00192 00193 KateViRange textObjectAWord(); 00194 KateViRange textObjectInnerWord(); 00195 KateViRange textObjectAWORD(); 00196 KateViRange textObjectInnerWORD(); 00197 00198 KateViRange textObjectAQuoteDouble(); 00199 KateViRange textObjectInnerQuoteDouble(); 00200 00201 KateViRange textObjectAQuoteSingle(); 00202 KateViRange textObjectInnerQuoteSingle(); 00203 00204 KateViRange textObjectAParen(); 00205 KateViRange textObjectInnerParen(); 00206 00207 KateViRange textObjectABracket(); 00208 KateViRange textObjectInnerBracket(); 00209 00210 KateViRange textObjectAComma(); 00211 KateViRange textObjectInnerComma(); 00212 00213 void addCurrentPositionToJumpList(); 00214 00215 void addMapping( const QString &from, const QString &to ); 00216 const QString getMapping( const QString &from ) const; 00217 const QStringList getMappings() const; 00218 00219 protected: 00220 void resetParser(); 00221 virtual void reset(); 00222 void initializeCommands(); 00223 QRegExp generateMatchingItemRegex(); 00224 virtual void goToPos( const KateViRange &r ); 00225 void executeCommand( const KateViCommand* cmd ); 00226 00227 QString m_keys; 00228 unsigned int m_countTemp; 00229 bool m_findWaitingForChar; 00230 00231 QVector<KateViCommand *> m_commands; 00232 QVector<KateViMotion *> m_motions; 00233 QVector<int> m_matchingCommands; 00234 QVector<int> m_matchingMotions; 00235 QStack<int> m_awaitingMotionOrTextObject; 00236 00237 int m_motionOperatorIndex; 00238 00239 QString m_lastTFcommand; // holds the last t/T/f/F command so that it can be repeated with ;/, 00240 00241 // registers 00242 QChar m_defaultRegister; 00243 QString m_registerTemp; 00244 00245 // marks 00246 QMap<QChar, KTextEditor::MovingCursor*> m_marks; 00247 00248 // item matching ('%' motion) 00249 QHash<QString, QString> m_matchingItems; 00250 QRegExp m_matchItemRegex; 00251 00252 // mappings 00253 bool m_mappingKeyPress; 00254 // set after f/F/t/T so the following character isn't translated 00255 bool m_ignoreMapping; 00256 QString m_mappingKeys; 00257 00258 KateViKeyParser *m_keyParser; 00259 }; 00260 00261 #endif
KDE 4.6 API Reference