Kate
kateviinputmodemanager.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_INPUT_MODE_MANAGER_INCLUDED 00021 #define KATE_VI_INPUT_MODE_MANAGER_INCLUDED 00022 00023 #include <QKeyEvent> 00024 #include <QList> 00025 00026 class KConfigGroup; 00027 class KateView; 00028 class KateViewInternal; 00029 class KateViNormalMode; 00030 class KateViInsertMode; 00031 class KateViVisualMode; 00032 class KateViReplaceMode; 00033 class KateViKeyParser; 00034 class QString; 00035 00039 enum ViMode { 00040 NormalMode, 00041 InsertMode, 00042 VisualMode, 00043 VisualLineMode, 00044 VisualBlockMode, 00045 ReplaceMode 00046 }; 00047 00048 class KateViInputModeManager 00049 { 00050 public: 00051 KateViInputModeManager(KateView* view, KateViewInternal* viewInternal); 00052 ~KateViInputModeManager(); 00053 00058 bool handleKeypress(const QKeyEvent *e); 00059 00063 void feedKeyPresses(const QString &keyPresses) const; 00064 00068 ViMode getCurrentViMode() const; 00069 00070 const QString getVerbatimKeys() const; 00071 00075 void changeViMode(ViMode newMode); 00076 00080 void viEnterNormalMode(); 00081 00085 void viEnterInsertMode(); 00086 00090 void viEnterVisualMode( ViMode visualMode = VisualMode ); 00091 00095 void viEnterReplaceMode(); 00096 00100 KateViNormalMode* getViNormalMode(); 00101 00105 KateViInsertMode* getViInsertMode(); 00106 00110 KateViVisualMode* getViVisualMode(); 00111 00115 KateViReplaceMode* getViReplaceMode(); 00116 00120 bool isRunningMacro() const { return m_runningMacro; } 00121 00125 void appendKeyEventToLog(const QKeyEvent &e); 00126 00130 void clearLog() { m_keyEventsLog.clear(); } 00131 00135 void storeChangeCommand(); 00136 00140 void repeatLastChange(); 00141 00142 // session stuff 00143 void readSessionConfig( const KConfigGroup& config ); 00144 void writeSessionConfig( KConfigGroup& config ); 00145 00146 private: 00147 KateViNormalMode* m_viNormalMode; 00148 KateViInsertMode* m_viInsertMode; 00149 KateViVisualMode* m_viVisualMode; 00150 KateViReplaceMode* m_viReplaceMode; 00151 00152 ViMode m_currentViMode; 00153 00154 KateView *m_view; 00155 KateViewInternal *m_viewInternal; 00156 KateViKeyParser *m_keyParser; 00157 00161 bool m_runningMacro; 00162 00167 QList<QKeyEvent> m_keyEventsLog; 00168 00172 QString m_lastChange; 00173 }; 00174 00175 #endif
KDE 4.4 API Reference