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 KateView; 00027 class KateViewInternal; 00028 class KateViNormalMode; 00029 class KateViInsertMode; 00030 class KateViVisualMode; 00031 class KateViKeySequenceParser; 00032 class QString; 00033 00037 enum ViMode { 00038 NormalMode, 00039 InsertMode, 00040 VisualMode, 00041 VisualLineMode 00042 }; 00043 00044 class KateViInputModeManager 00045 { 00046 public: 00047 KateViInputModeManager(KateView* view, KateViewInternal* viewInternal); 00048 ~KateViInputModeManager(); 00049 00054 bool handleKeypress(const QKeyEvent *e); 00055 00059 void feedKeyPresses(const QString &keyPresses) const; 00060 00064 ViMode getCurrentViMode() const; 00065 00066 const QString getVerbatimKeys() const; 00067 00071 void changeViMode(ViMode newMode); 00072 00076 void viEnterNormalMode(); 00077 00081 void viEnterInsertMode(); 00082 00087 void viEnterVisualMode(bool visualLine = false); 00088 00092 KateViNormalMode* getViNormalMode(); 00093 00097 KateViInsertMode* getViInsertMode(); 00098 00102 KateViVisualMode* getViVisualMode(); 00103 00107 bool isRunningMacro() const { return m_runningMacro; } 00108 00112 void appendKeyEventToLog(const QKeyEvent &e); 00113 00117 void clearLog() { m_keyEventsLog.clear(); } 00118 00122 void storeChangeCommand(); 00123 00127 void repeatLastChange(); 00128 00129 private: 00130 KateViNormalMode* m_viNormalMode; 00131 KateViInsertMode* m_viInsertMode; 00132 KateViVisualMode* m_viVisualMode; 00133 00134 ViMode m_currentViMode; 00135 00136 KateView *m_view; 00137 KateViewInternal *m_viewInternal; 00138 KateViKeySequenceParser *m_keyParser; 00139 00143 bool m_runningMacro; 00144 00149 QList<QKeyEvent> m_keyEventsLog; 00150 00154 QString m_lastChange; 00155 }; 00156 00157 #endif