Kate
kateviinputmodemanager.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 Erlend Hamberg <ehamberg@gmail.com> 00004 * 00005 * This library is free software; you can redistribute it and/or 00006 * modify it under the terms of the GNU Library General Public 00007 * License as published by the Free Software Foundation; either 00008 * version 2 of the License, or (at your option) any later version. 00009 * 00010 * This library is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 * Library General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU Library General Public License 00016 * along with this library; see the file COPYING.LIB. If not, write to 00017 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00018 * Boston, MA 02110-1301, USA. 00019 */ 00020 00021 #ifndef KATE_VI_INPUT_MODE_MANAGER_INCLUDED 00022 #define KATE_VI_INPUT_MODE_MANAGER_INCLUDED 00023 00024 #include <QKeyEvent> 00025 #include <QList> 00026 00027 class KConfigGroup; 00028 class KateView; 00029 class KateViewInternal; 00030 class KateViNormalMode; 00031 class KateViInsertMode; 00032 class KateViVisualMode; 00033 class KateViReplaceMode; 00034 class KateViKeyParser; 00035 class QString; 00036 00040 enum ViMode { 00041 NormalMode, 00042 InsertMode, 00043 VisualMode, 00044 VisualLineMode, 00045 VisualBlockMode, 00046 ReplaceMode 00047 }; 00048 00049 class KateViInputModeManager 00050 { 00051 public: 00052 KateViInputModeManager(KateView* view, KateViewInternal* viewInternal); 00053 ~KateViInputModeManager(); 00054 00059 bool handleKeypress(const QKeyEvent *e); 00060 00064 void feedKeyPresses(const QString &keyPresses) const; 00065 00069 ViMode getCurrentViMode() const; 00070 00071 const QString getVerbatimKeys() const; 00072 00076 void changeViMode(ViMode newMode); 00077 00081 void viEnterNormalMode(); 00082 00086 void viEnterInsertMode(); 00087 00091 void viEnterVisualMode( ViMode visualMode = VisualMode ); 00092 00096 void viEnterReplaceMode(); 00097 00101 KateViNormalMode* getViNormalMode(); 00102 00106 KateViInsertMode* getViInsertMode(); 00107 00111 KateViVisualMode* getViVisualMode(); 00112 00116 KateViReplaceMode* getViReplaceMode(); 00117 00121 bool isRunningMacro() const { return m_runningMacro; } 00122 00126 void appendKeyEventToLog(const QKeyEvent &e); 00127 00131 void clearLog() { m_keyEventsLog.clear(); } 00132 00136 void storeChangeCommand(); 00137 00141 void repeatLastChange(); 00142 00146 const QString getLastSearchPattern() const { return m_lastSearchPattern; } 00147 00151 void setLastSearchPattern( const QString &p ) { m_lastSearchPattern = p; } 00152 00156 bool lastSearchBackwards() const { return m_lastSearchBackwards; } 00157 00161 void setLastSearchBackwards( bool b ) { m_lastSearchBackwards = b; } 00162 00163 // session stuff 00164 void readSessionConfig( const KConfigGroup& config ); 00165 void writeSessionConfig( KConfigGroup& config ); 00166 00167 private: 00168 KateViNormalMode* m_viNormalMode; 00169 KateViInsertMode* m_viInsertMode; 00170 KateViVisualMode* m_viVisualMode; 00171 KateViReplaceMode* m_viReplaceMode; 00172 00173 ViMode m_currentViMode; 00174 00175 KateView *m_view; 00176 KateViewInternal *m_viewInternal; 00177 KateViKeyParser *m_keyParser; 00178 00182 bool m_runningMacro; 00183 00188 QList<QKeyEvent> m_keyEventsLog; 00189 00193 QString m_lastChange; 00194 00198 QString m_lastSearchPattern; 00199 00203 bool m_lastSearchBackwards; 00204 }; 00205 00206 #endif
KDE 4.6 API Reference