Kate
katevinormalmode.h
Go to the documentation of this file.00001 /* This file is part of the KDE libraries 00002 * Copyright (C) 2008 Erlend Hamberg <ehamberg@gmail.com> 00003 * 00004 * This library is free software; you can redistribute it and/or 00005 * modify it under the terms of the GNU Library General Public 00006 * License as published by the Free Software Foundation; either 00007 * version 2 of the License, or (at your option) version 3. 00008 * 00009 * This library is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 * Library General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU Library General Public License 00015 * along with this library; see the file COPYING.LIB. If not, write to 00016 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00017 * Boston, MA 02110-1301, USA. 00018 */ 00019 00020 #ifndef KATE_VI_NORMAL_MODE_INCLUDED 00021 #define KATE_VI_NORMAL_MODE_INCLUDED 00022 00023 #include "kateview.h" 00024 #include "kateviewinternal.h" 00025 #include "katevicommand.h" 00026 #include "katevimotion.h" 00027 #include "katevirange.h" 00028 #include "katevimodebase.h" 00029 00030 #include <QKeyEvent> 00031 #include <QVector> 00032 #include <QStack> 00033 #include <QHash> 00034 #include <QRegExp> 00035 #include <ktexteditor/cursor.h> 00036 #include "katevikeysequenceparser.h" 00037 00038 class KateViMotion; 00039 class KateViInputModeManager; 00040 00045 class KateViNormalMode : public KateViModeBase 00046 { 00047 Q_OBJECT 00048 00049 public slots: 00050 void mappingTimerTimeOut(); 00051 00052 public: 00053 KateViNormalMode( KateViInputModeManager *viInputModeManager, KateView * view, KateViewInternal * viewInternal ); 00054 virtual ~KateViNormalMode(); 00055 00056 bool handleKeypress( const QKeyEvent *e ); 00057 00058 bool commandEnterInsertMode(); 00059 bool commandEnterInsertModeAppend(); 00060 bool commandEnterInsertModeAppendEOL(); 00061 bool commandEnterInsertModeBeforeFirstCharacterOfLine(); 00062 00063 bool commandEnterVisualMode(); 00064 bool commandEnterVisualLineMode(); 00065 bool commandToOtherEnd(); 00066 00067 bool commandDelete(); 00068 bool commandDeleteToEOL(); 00069 bool commandDeleteLine(); 00070 00071 bool commandMakeLowercase(); 00072 bool commandMakeLowercaseLine(); 00073 bool commandMakeUppercase(); 00074 bool commandMakeUppercaseLine(); 00075 bool commandChangeCase(); 00076 00077 bool commandOpenNewLineUnder(); 00078 bool commandOpenNewLineOver(); 00079 00080 bool commandJoinLines(); 00081 00082 bool commandChange(); 00083 bool commandChangeLine(); 00084 bool commandChangeToEOL(); 00085 bool commandSubstituteChar(); 00086 bool commandSubstituteLine(); 00087 00088 bool commandYank(); 00089 bool commandYankLine(); 00090 bool commandYankToEOL(); 00091 00092 bool commandPaste(); 00093 bool commandPasteBefore(); 00094 00095 bool commandDeleteChar(); 00096 bool commandDeleteCharBackward(); 00097 00098 bool commandReplaceCharacter(); 00099 00100 bool commandSwitchToCmdLine(); 00101 bool commandSearch(); 00102 bool commandUndo(); 00103 bool commandRedo(); 00104 00105 bool commandSetMark(); 00106 00107 bool commandFindNext(); 00108 bool commandFindPrev(); 00109 00110 bool commandIndentLine(); 00111 bool commandUnindentLine(); 00112 bool commandIndentLines(); 00113 bool commandUnindentLines(); 00114 00115 bool commandScrollPageDown(); 00116 bool commandScrollPageUp(); 00117 00118 bool commandAbort(); 00119 00120 bool commandPrintCharacterCode(); 00121 00122 bool commandRepeatLastChange(); 00123 00124 bool commandAlignLine(); 00125 bool commandAlignLines(); 00126 00127 // MOTIONS 00128 00129 KateViRange motionLeft(); 00130 KateViRange motionRight(); 00131 KateViRange motionDown(); 00132 KateViRange motionUp(); 00133 00134 KateViRange motionWordForward(); 00135 KateViRange motionWordBackward(); 00136 KateViRange motionWORDForward(); 00137 KateViRange motionWORDBackward(); 00138 00139 KateViRange motionToEndOfWord(); 00140 KateViRange motionToEndOfWORD(); 00141 KateViRange motionToEndOfPrevWord(); 00142 KateViRange motionToEndOfPrevWORD(); 00143 00144 KateViRange motionFindChar(); 00145 KateViRange motionFindCharBackward(); 00146 KateViRange motionToChar(); 00147 KateViRange motionToCharBackward(); 00148 KateViRange motionRepeatlastTF(); 00149 KateViRange motionRepeatlastTFBackward(); 00150 00151 KateViRange motionToEOL(); 00152 KateViRange motionToColumn0(); 00153 KateViRange motionToFirstCharacterOfLine(); 00154 00155 KateViRange motionToLineFirst(); 00156 KateViRange motionToLineLast(); 00157 00158 KateViRange motionToScreenColumn(); 00159 00160 KateViRange motionToMark(); 00161 KateViRange motionToMarkLine(); 00162 00163 KateViRange motionToMatchingItem(); 00164 00165 KateViRange motionToPreviousBraceBlockStart(); 00166 KateViRange motionToNextBraceBlockStart(); 00167 KateViRange motionToPreviousBraceBlockEnd(); 00168 KateViRange motionToNextBraceBlockEnd(); 00169 00170 // TEXT OBJECTS 00171 00172 KateViRange textObjectAWord(); 00173 KateViRange textObjectInnerWord(); 00174 KateViRange textObjectAWORD(); 00175 KateViRange textObjectInnerWORD(); 00176 00177 KateViRange textObjectAQuoteDouble(); 00178 KateViRange textObjectInnerQuoteDouble(); 00179 00180 KateViRange textObjectAQuoteSingle(); 00181 KateViRange textObjectInnerQuoteSingle(); 00182 00183 KateViRange textObjectAParen(); 00184 KateViRange textObjectInnerParen(); 00185 00186 KateViRange textObjectABracket(); 00187 KateViRange textObjectInnerBracket(); 00188 00189 KateViRange textObjectAComma(); 00190 KateViRange textObjectInnerComma(); 00191 00192 void addCurrentPositionToJumpList(); 00193 00194 protected: 00195 void resetParser(); 00196 virtual void reset(); 00197 void initializeCommands(); 00198 QRegExp generateMatchingItemRegex(); 00199 virtual void goToPos( const KateViRange &r ); 00200 void executeCommand( const KateViCommand* cmd ); 00201 00202 QString m_keys; 00203 unsigned int m_countTemp; 00204 bool m_findWaitingForChar; 00205 int m_waitingForMotionOrTextObject; 00206 00207 QVector<KateViCommand *> m_commands; 00208 QVector<KateViMotion *> m_motions; 00209 QVector<int> m_matchingCommands; 00210 QVector<int> m_matchingMotions; 00211 QStack<int> m_awaitingMotionOrTextObject; 00212 00213 int m_motionOperatorIndex; 00214 00215 QString m_lastTFcommand; // holds the last t/T/f/F command so that it can be repeated with ;/, 00216 00217 // registers 00218 QChar m_defaultRegister; 00219 QString m_registerTemp; 00220 00221 // marks 00222 QMap<QChar, KTextEditor::SmartCursor*> *m_marks; 00223 00224 // item matching ('%' motion) 00225 QHash<QString, QString> m_matchingItems; 00226 QRegExp m_matchItemRegex; 00227 00228 // mappings 00229 bool m_mappingKeyPress; 00230 QString m_mappingKeys; 00231 00232 KateViKeySequenceParser *m_keyParser; 00233 }; 00234 00235 #endif