summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorfluxgen <fluxgen>2003-09-29 14:22:07 (GMT)
committerfluxgen <fluxgen>2003-09-29 14:22:07 (GMT)
commit15dfe811124e3f1be7d9a802290372427dae5afb (patch)
tree9fec3fc339fe56a65729a88986d9177efe670fb9 /src
parent75b3606424a27dafeb0958450bffa841ae463c2d (diff)
downloadfluxbox_lack-15dfe811124e3f1be7d9a802290372427dae5afb.zip
fluxbox_lack-15dfe811124e3f1be7d9a802290372427dae5afb.tar.bz2
added MacroCmd action, thanks Mathias Gumz
Diffstat (limited to 'src')
-rw-r--r--src/FbCommandFactory.cc46
1 files changed, 45 insertions, 1 deletions
diff --git a/src/FbCommandFactory.cc b/src/FbCommandFactory.cc
index d82e72b..8e0a1fd 100644
--- a/src/FbCommandFactory.cc
+++ b/src/FbCommandFactory.cc
@@ -20,7 +20,7 @@
20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21// DEALINGS IN THE SOFTWARE. 21// DEALINGS IN THE SOFTWARE.
22 22
23// $Id: FbCommandFactory.cc,v 1.17 2003/09/29 13:01:01 rathnor Exp $ 23// $Id: FbCommandFactory.cc,v 1.18 2003/09/29 14:22:07 fluxgen Exp $
24 24
25#include "FbCommandFactory.hh" 25#include "FbCommandFactory.hh"
26 26
@@ -32,6 +32,10 @@
32#include "SimpleCommand.hh" 32#include "SimpleCommand.hh"
33#include "Screen.hh" 33#include "Screen.hh"
34 34
35#include "FbTk/StringUtil.hh"
36#include "FbTk/MacroCommand.hh"
37
38#include <string>
35#include <sstream> 39#include <sstream>
36 40
37// autoregister this module to command parser 41// autoregister this module to command parser
@@ -51,6 +55,7 @@ FbCommandFactory::FbCommandFactory() {
51 "killwindow", 55 "killwindow",
52 "leftworkspace", 56 "leftworkspace",
53 "lower", 57 "lower",
58 "macrocmd",
54 "maximize", 59 "maximize",
55 "maximizehorizontal", 60 "maximizehorizontal",
56 "maximizevertical", 61 "maximizevertical",
@@ -217,5 +222,44 @@ FbTk::Command *FbCommandFactory::stringToCommand(const std::string &command,
217 return new ShowWorkspaceMenuCmd(); 222 return new ShowWorkspaceMenuCmd();
218 else if (command == "setworkspacename") 223 else if (command == "setworkspacename")
219 return new SetWorkspaceNameCmd(); 224 return new SetWorkspaceNameCmd();
225 //
226 // special commands
227 //
228 else if (command == "macrocmd") {
229 std::string cmd;
230 int err= 0;
231 int parse_pos= 0;
232 FbTk::MacroCommand* macro= new FbTk::MacroCommand();
233
234 while (true) {
235 parse_pos+= err;
236 err= FbTk::StringUtil::getStringBetween(cmd, arguments.c_str() + parse_pos,
237 '{', '}', " \t\n", true);
238 if ( err > 0 ) {
239 std::string c, a;
240 std::string::size_type first_pos = FbTk::StringUtil::removeFirstWhitespace(cmd);
241 std::string::size_type second_pos= cmd.find_first_of(" \t", first_pos);
242 if (second_pos != std::string::npos) {
243 a= cmd.substr(second_pos);
244 FbTk::StringUtil::removeFirstWhitespace(a);
245 cmd.erase(second_pos);
246 }
247 c= FbTk::StringUtil::toLower(cmd);
248
249 FbTk::Command* fbcmd= stringToCommand(c,a);
250 if ( fbcmd ) {
251 FbTk::RefCount<FbTk::Command> rfbcmd(fbcmd);
252 macro->add(rfbcmd);
253 }
254 }
255 else
256 break;
257 }
258
259 if ( macro->size() > 0 )
260 return macro;
261
262 delete macro;
263 }
220 return 0; 264 return 0;
221} 265}