File indexing completed on 2024-04-21 04:02:54

0001 /***************************************************************************
0002                           ccmdprocessor.h  -  command processor
0003     This file is a part of KMuddy distribution.
0004                              -------------------
0005     begin                : Pi Jul 5 2002
0006     copyright            : (C) 2002 by Tomas Mecir
0007     email                : kmuddy@kmuddy.com
0008  ***************************************************************************/
0009 
0010 /***************************************************************************
0011  *                                                                         *
0012  *   This program is free software; you can redistribute it and/or modify  *
0013  *   it under the terms of the GNU General Public License as published by  *
0014  *   the Free Software Foundation; either version 2 of the License, or     *
0015  *   (at your option) any later version.                                   *
0016  *                                                                         *
0017  ***************************************************************************/
0018 
0019 #ifndef CCMDPROCESSOR_H
0020 #define CCMDPROCESSOR_H
0021 
0022 #include <cactionbase.h>
0023 #include <cvalue.h>
0024 #include <kmuddy_export.h>
0025 
0026 class cCmdQueue;
0027 class cExpCache;
0028 class cExpResolver;
0029 
0030 /**
0031 class cCmdProcessor expands internal scripting, variables, and also handles
0032  * macro calls by passing them to the cMacroManager class.
0033 
0034   *@author Tomas Mecir
0035   */
0036 
0037 class KMUDDY_EXPORT cCmdProcessor : public cActionBase {
0038 public: 
0039   cCmdProcessor (int sess);
0040   ~cCmdProcessor() override;
0041 
0042   void setFocusCommandString (QString str);
0043   
0044   void processCommand (const QString &command, cCmdQueue *queue);
0045   /** Evaluate macro <mname> with parameters <params> */
0046   void processMacro (const QString &name, const QString &params, cCmdQueue *queue);
0047   
0048   /** expand internal scripting sequences in a command */
0049   void expandInternalScripting (QString &command, cCmdQueue *queue = nullptr);
0050   /** expand variables in a command */
0051   void expandVariables (QString &command, cCmdQueue *queue = nullptr);
0052 
0053   cValue eval (const QString &exp, cCmdQueue *queue, bool &ok);
0054 protected:
0055   void eventNothingHandler (QString event, int session) override;
0056 
0057   /** Looks to see if this is a tab/window command call. If it is, the command
0058   is split into :window:mytext */
0059   int isFocusCommand (const QString &command);
0060   /** Send <command> to <window> */
0061   int processFocusCommand (const QString &command, int pos);
0062   
0063   QString focusstr;
0064   
0065   // variable and function resolver, used in internal scripting
0066   cExpResolver *resolver;
0067   cExpCache *expcache;
0068 };
0069 
0070   
0071 #endif