Kate
katecmd.h
Go to the documentation of this file.00001 /* This file is part of the KDE libraries 00002 Copyright (C) 2001, 2003 Christoph Cullmann <cullmann@kde.org> 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 version 2 as published by the Free Software Foundation. 00007 00008 This library is distributed in the hope that it will be useful, 00009 but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00011 Library General Public License for more details. 00012 00013 You should have received a copy of the GNU Library General Public License 00014 along with this library; see the file COPYING.LIB. If not, write to 00015 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00016 Boston, MA 02110-1301, USA. 00017 */ 00018 00019 #ifndef _KATE_CMD_H 00020 #define _KATE_CMD_H 00021 00022 #include <ktexteditor/commandinterface.h> 00023 00024 #include <kcompletion.h> 00025 00026 #include <QtCore/QHash> 00027 #include <QtCore/QStringList> 00028 00029 class KateCmd 00030 { 00031 public: 00032 KateCmd (); 00033 ~KateCmd (); 00034 00035 static KateCmd *self (); 00036 00037 bool registerCommand (KTextEditor::Command *cmd); 00038 bool unregisterCommand (KTextEditor::Command *cmd); 00039 KTextEditor::Command *queryCommand (const QString &cmd) const; 00040 QList<KTextEditor::Command*> commands() const; 00041 QStringList commandList() const; 00042 00043 QStringList cmds (); 00044 void appendHistory( const QString &cmd ); 00045 const QString fromHistory( int i ) const; 00046 uint historyLength() const { return m_history.count(); } 00047 00048 private: 00049 QHash<QString, KTextEditor::Command *> m_dict; 00050 QStringList m_cmds; 00051 QStringList m_history; 00052 }; 00053 00060 class KateCmdShellCompletion : public KCompletion 00061 { 00062 public: 00063 KateCmdShellCompletion(); 00064 00071 QString makeCompletion(const QString &text); 00072 00073 protected: 00074 // Called by KCompletion 00075 void postProcessMatch( QString *match ) const; 00076 void postProcessMatches( QStringList *matches ) const; 00077 void postProcessMatches( KCompletionMatches *matches ) const; 00078 00079 private: 00086 void splitText( const QString &text, QString &text_start, QString &text_compl ) const; 00087 00088 QChar m_word_break_char; 00089 QChar m_quote_char1; 00090 QChar m_quote_char2; 00091 QChar m_escape_char; 00092 00093 QString m_text_start; 00094 QString m_text_compl; 00095 00096 }; 00097 00098 #endif 00099 00100 // kate: space-indent on; indent-width 2; replace-tabs on;