Kate
katevicommand.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 #include "katevinormalmode.h" 00022 #include "katevikeyparser.h" 00023 00024 #ifndef KATE_VI_COMMAND_H 00025 #define KATE_VI_COMMAND_H 00026 00027 class KateViNormalMode; 00028 00029 enum KateViCommandFlags { 00030 REGEX_PATTERN = 0x1, // the pattern is a regex 00031 NEEDS_MOTION = 0x2, // the command needs a motion before it can be executed 00032 SHOULD_NOT_RESET = 0x4, // the command should not cause the current mode to be left 00033 IS_CHANGE = 0x8 // the command changes the buffer 00034 }; 00035 00036 class KateViCommand { 00037 public: 00038 KateViCommand( KateViNormalMode *parent, QString pattern, 00039 bool ( KateViNormalMode::*pt2Func)(), unsigned int flags = 0 ); 00040 ~KateViCommand(); 00041 00042 bool matches( const QString &pattern ) const; 00043 bool matchesExact( const QString &pattern ) const; 00044 bool execute() const; 00045 const QString pattern() const { return m_pattern; } 00046 bool isRegexPattern() const { return m_flags & REGEX_PATTERN; } 00047 bool needsMotion() const { return m_flags & NEEDS_MOTION; } 00048 bool shouldReset() const { return !( m_flags & SHOULD_NOT_RESET ); } 00049 bool isChange() const { return m_flags & IS_CHANGE; } 00050 00051 protected: 00052 KateViNormalMode *m_parent; 00053 QString m_pattern; 00054 unsigned int m_flags; 00055 bool ( KateViNormalMode::*m_ptr2commandMethod)(); 00056 KateViKeyParser *m_keyParser; 00057 }; 00058 00059 #endif
KDE 4.6 API Reference