libcvd-members
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[libcvd-members] gvars3 gvars3/GUI.h src/GUI.cc


From: Georg Klein
Subject: [libcvd-members] gvars3 gvars3/GUI.h src/GUI.cc
Date: Thu, 17 May 2007 12:01:57 +0000

CVSROOT:        /cvsroot/libcvd
Module name:    gvars3
Changes by:     Georg Klein <georgklein>        07/05/17 12:01:57

Modified files:
        gvars3         : GUI.h 
        src            : GUI.cc 

Log message:
        Added `queue', `runqueue', `runqueue_noclear' internal commands.
        
        Example:
        > queue myqueue echo hello world!
        > queue myqueue echo hello world..
        > runqueue_noclear myqueue
        hello world!
        hello world..
        > runqueue myqueue
        hello world!
        hello world..
        > runqueue myqueue
        >
        
        Main use is to not instantiate GUI elements before their respective
        variables have been set to sensible default values by the application, 
but
        the _noclear variant lets you abuse the whole thing to create 
procedures.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gvars3/gvars3/GUI.h?cvsroot=libcvd&r1=1.5&r2=1.6
http://cvs.savannah.gnu.org/viewcvs/gvars3/src/GUI.cc?cvsroot=libcvd&r1=1.14&r2=1.15

Patches:
Index: gvars3/GUI.h
===================================================================
RCS file: /cvsroot/libcvd/gvars3/gvars3/GUI.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- gvars3/GUI.h        13 Feb 2007 00:22:03 -0000      1.5
+++ gvars3/GUI.h        17 May 2007 12:01:57 -0000      1.6
@@ -83,8 +83,11 @@
 
          std::map<std::string, CallbackVector > mmCallBackMap;
          std::set<std::string> builtins;
+         std::map<std::string, std::vector<std::string> > mmQueues;
 
          friend void builtin_commandlist(void* ptr, std::string sCommand, 
std::string sParams);
+         friend void builtin_queue(void* ptr, std::string sCommand, 
std::string sParams);
+         friend void builtin_runqueue(void* ptr, std::string sCommand, 
std::string sParams);
        };
 }
 

Index: src/GUI.cc
===================================================================
RCS file: /cvsroot/libcvd/gvars3/src/GUI.cc,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -b -r1.14 -r1.15
--- src/GUI.cc  30 Apr 2007 21:27:59 -0000      1.14
+++ src/GUI.cc  17 May 2007 12:01:57 -0000      1.15
@@ -626,6 +626,50 @@
                          cout << "    " << i->first << endl;
 }
 
+void builtin_queue(void* ptr, string sCommand, string sParams)
+{
+       vector<string> vs = ChopAndUnquoteString(sParams);
+       if(vs.size() < 2)
+         {
+           cout << "? GUI Internal queue command syntax: queue queue-name 
line-to-enqueue" << endl;
+           return;
+         }
+       string &sQueueName = vs[0];
+       sParams.erase(sParams.find(sQueueName), sQueueName.length());
+       
+       GUI* pGUI = (GUI*)ptr;
+       pGUI->mmQueues[sQueueName].push_back(sParams);
+}
+
+void builtin_runqueue(void* ptr, string sCommand, string sParams)
+{
+       GUI* pGUI = (GUI*)ptr;
+       vector<string> vs = ChopAndUnquoteString(sParams);
+       if(vs.size() != 1)
+         {
+           cout << "? GUI Internal " << sCommand << " command syntax: runqueue 
queue-name " << endl;
+           int nQueues = pGUI->mmQueues.size();
+           
+           cout << "  Currently there are " << nQueues << " queues 
registered." << endl;
+           if(nQueues > 0)
+             {
+               cout << "  They are: ";
+               for(map<string,vector<string> >::iterator 
it=pGUI->mmQueues.begin(); 
+                   it!=pGUI->mmQueues.end(); 
+                   it++)
+                 cout << ((it==pGUI->mmQueues.begin())?"":", ") << it->first;
+               cout << endl;
+             }
+           return;
+         }
+       string &sQueueName = vs[0];
+       vector<string> &vQueue = pGUI->mmQueues[sQueueName];
+       for(int i=0; i<vQueue.size(); i++)
+         pGUI->ParseLine(vQueue[i]);
+       if(sCommand=="runqueue")
+         vQueue.clear();   // do not clear the queue if the command was 
runqueue_noclear!
+}
+
 ///////////////////////////////////////
 ///////////////////////////////////////
 ////////     Readline stuff:
@@ -763,7 +807,10 @@
        RegisterBuiltin("gvarlist", builtin_gvarlist);
        RegisterBuiltin("printvar", builtin_printvar);
        RegisterBuiltin("commandlist", builtin_commandlist);
-}
+       RegisterBuiltin("queue",  builtin_queue);
+       RegisterBuiltin("runqueue", builtin_runqueue);
+       RegisterBuiltin("runqueue_noclear", builtin_runqueue);
+};
 
+}
 
-};




reply via email to

[Prev in Thread] Current Thread [Next in Thread]