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