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 public: 00048 KateViNormalMode( KateViInputModeManager *viInputModeManager, KateView * view, KateViewInternal * viewInternal ); 00049 virtual ~KateViNormalMode(); 00050 00051 bool handleKeypress( const QKeyEvent *e ); 00052 00053 bool commandEnterInsertMode(); 00054 bool commandEnterInsertModeAppend(); 00055 bool commandEnterInsertModeAppendEOL(); 00056 bool commandEnterInsertModeBeforeFirstCharacterOfLine(); 00057 00058 bool commandEnterVisualMode(); 00059 bool commandEnterVisualLineMode(); 00060 bool commandToOtherEnd(); 00061 00062 bool commandDelete(); 00063 bool commandDeleteToEOL(); 00064 bool commandDeleteLine(); 00065 00066 bool commandMakeLowercase(); 00067 bool commandMakeLowercaseLine(); 00068 bool commandMakeUppercase(); 00069 bool commandMakeUppercaseLine(); 00070 bool commandChangeCase(); 00071 00072 bool commandOpenNewLineUnder(); 00073 bool commandOpenNewLineOver(); 00074 00075 bool commandJoinLines(); 00076 00077 bool commandChange(); 00078 bool commandChangeLine(); 00079 bool commandChangeToEOL(); 00080 bool commandSubstituteChar(); 00081 bool commandSubstituteLine(); 00082 00083 bool commandYank(); 00084 bool commandYankLine(); 00085 bool commandYankToEOL(); 00086 00087 bool commandPaste(); 00088 bool commandPasteBefore(); 00089 00090 bool commandDeleteChar(); 00091 bool commandDeleteCharBackward(); 00092 00093 bool commandReplaceCharacter(); 00094 00095 bool commandSwitchToCmdLine(); 00096 bool commandSearch(); 00097 bool commandUndo(); 00098 bool commandRedo(); 00099 00100 bool commandSetMark(); 00101 00102 bool commandFindNext(); 00103 bool commandFindPrev(); 00104 00105 bool commandIndentLine(); 00106 bool commandUnindentLine(); 00107 bool commandIndentLines(); 00108 bool commandUnindentLines(); 00109 00110 bool commandScrollPageDown(); 00111 bool commandScrollPageUp(); 00112 00113 bool commandAbort(); 00114 00115 bool commandPrintCharacterCode(); 00116 00117 bool commandRepeatLastChange(); 00118 00119 bool commandAlignLine(); 00120 bool commandAlignLines(); 00121 00122 // MOTIONS 00123 00124 KateViRange motionLeft(); 00125 KateViRange motionRight(); 00126 KateViRange motionDown(); 00127 KateViRange motionUp(); 00128 00129 KateViRange motionWordForward(); 00130 KateViRange motionWordBackward(); 00131 KateViRange motionWORDForward(); 00132 KateViRange motionWORDBackward(); 00133 00134 KateViRange motionToEndOfWord(); 00135 KateViRange motionToEndOfWORD(); 00136 KateViRange motionToEndOfPrevWord(); 00137 KateViRange motionToEndOfPrevWORD(); 00138 00139 KateViRange motionFindChar(); 00140 KateViRange motionFindCharBackward(); 00141 KateViRange motionToChar(); 00142 KateViRange motionToCharBackward(); 00143 00144 KateViRange motionToEOL(); 00145 KateViRange motionToColumn0(); 00146 KateViRange motionToFirstCharacterOfLine(); 00147 00148 KateViRange motionToLineFirst(); 00149 KateViRange motionToLineLast(); 00150 00151 KateViRange motionToScreenColumn(); 00152 00153 KateViRange motionToMark(); 00154 KateViRange motionToMarkLine(); 00155 00156 KateViRange motionToMatchingItem(); 00157 00158 KateViRange motionToPreviousBraceBlockStart(); 00159 KateViRange motionToNextBraceBlockStart(); 00160 KateViRange motionToPreviousBraceBlockEnd(); 00161 KateViRange motionToNextBraceBlockEnd(); 00162 00163 // TEXT OBJECTS 00164 00165 KateViRange textObjectAWord(); 00166 KateViRange textObjectInnerWord(); 00167 KateViRange textObjectAWORD(); 00168 KateViRange textObjectInnerWORD(); 00169 00170 KateViRange textObjectAQuoteDouble(); 00171 KateViRange textObjectInnerQuoteDouble(); 00172 00173 KateViRange textObjectAQuoteSingle(); 00174 KateViRange textObjectInnerQuoteSingle(); 00175 00176 KateViRange textObjectAParen(); 00177 KateViRange textObjectInnerParen(); 00178 00179 KateViRange textObjectABracket(); 00180 KateViRange textObjectInnerBracket(); 00181 00182 void addCurrentPositionToJumpList(); 00183 00184 protected: 00185 void resetParser(); 00186 virtual void reset(); 00187 void initializeCommands(); 00188 QRegExp generateMatchingItemRegex(); 00189 virtual void goToPos( const KateViRange &r ); 00190 void executeCommand( const KateViCommand* cmd ); 00191 00192 QString m_keys; 00193 unsigned int m_countTemp; 00194 bool m_findWaitingForChar; 00195 int m_waitingForMotionOrTextObject; 00196 00197 QVector<KateViCommand *> m_commands; 00198 QVector<KateViMotion *> m_motions; 00199 QVector<int> m_matchingCommands; 00200 QVector<int> m_matchingMotions; 00201 QStack<int> m_awaitingMotionOrTextObject; 00202 00203 int m_motionOperatorIndex; 00204 00205 // registers 00206 QChar m_defaultRegister; 00207 QString m_registerTemp; 00208 00209 // marks 00210 QMap<QChar, KTextEditor::SmartCursor*> *m_marks; 00211 00212 // item matching ('%' motion) 00213 QHash<QString, QString> m_matchingItems; 00214 QRegExp m_matchItemRegex; 00215 00216 KateViKeySequenceParser *m_keyParser; 00217 }; 00218 00219 #endif