kate Library API Documentation

katecmd.cpp

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., 59 Temple Place - Suite 330,
00016    Boston, MA 02111-1307, USA.
00017 */
00018 
00019 #include "katecmd.h"
00020 
00021 #include <kstaticdeleter.h>
00022 
00023 KateCmd *KateCmd::s_self = 0;
00024 
00025 KateCmd::KateCmd ()
00026 {
00027 }
00028 
00029 KateCmd::~KateCmd ()
00030 {
00031 }
00032 
00033 bool KateCmd::registerCommand (Kate::Command *cmd)
00034 {
00035   QStringList l = cmd->cmds ();
00036 
00037   for (uint z=0; z<l.count(); z++)
00038     if (m_dict[l[z]])
00039       return false;
00040 
00041   for (uint z=0; z<l.count(); z++)
00042     m_dict.insert (l[z], cmd);
00043 
00044   m_cmds += l;
00045 
00046   return true;
00047 }
00048 
00049 bool KateCmd::unregisterCommand (Kate::Command *)
00050 {
00051   return true;
00052 }
00053 
00054 Kate::Command *KateCmd::queryCommand (const QString &cmd)
00055 {
00056   uint f = 0;
00057   while ( ! cmd[f].isSpace() && f < cmd.length() )
00058     f++;
00059 
00060   return m_dict[cmd.left(f)];
00061 }
00062 
00063 QStringList KateCmd::cmds ()
00064 {
00065   return m_cmds;
00066 }
00067 
00068 static KStaticDeleter<KateCmd> sdCmd;
00069 
00070 KateCmd *KateCmd::self ()
00071 {
00072   if (!s_self)
00073     sdCmd.setObject(s_self, new KateCmd ());
00074     
00075   return s_self;
00076 } 
KDE Logo
This file is part of the documentation for kate Library Version 3.2.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Thu Mar 3 19:25:01 2005 by doxygen 1.3.6 written by Dimitri van Heesch, © 1997-2003