summaryrefslogtreecommitdiff
path: root/src/FbCommandFactory.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/FbCommandFactory.cc')
-rw-r--r--src/FbCommandFactory.cc52
1 files changed, 46 insertions, 6 deletions
diff --git a/src/FbCommandFactory.cc b/src/FbCommandFactory.cc
index 50f0fef..4e129af 100644
--- a/src/FbCommandFactory.cc
+++ b/src/FbCommandFactory.cc
@@ -136,6 +136,7 @@ FbCommandFactory::FbCommandFactory() {
136 "taketoworkspace", 136 "taketoworkspace",
137 "taketonextworkspace", 137 "taketonextworkspace",
138 "taketoprevworkspace", 138 "taketoprevworkspace",
139 "togglecmd",
139 "toggledecor", 140 "toggledecor",
140 "windowmenu", 141 "windowmenu",
141 "workspace", 142 "workspace",
@@ -449,12 +450,15 @@ FbTk::Command *FbCommandFactory::stringToCommand(const std::string &command,
449 450
450 while (true) { 451 while (true) {
451 parse_pos+= err; 452 parse_pos+= err;
452 err= FbTk::StringUtil::getStringBetween(cmd, arguments.c_str() + parse_pos, 453 err= FbTk::StringUtil::getStringBetween(cmd, arguments.c_str() +
453 '{', '}', " \t\n", true); 454 parse_pos,
455 '{', '}', " \t\n", true);
454 if ( err > 0 ) { 456 if ( err > 0 ) {
455 std::string c, a; 457 std::string c, a;
456 std::string::size_type first_pos = FbTk::StringUtil::removeFirstWhitespace(cmd); 458 std::string::size_type first_pos =
457 std::string::size_type second_pos= cmd.find_first_of(" \t", first_pos); 459 FbTk::StringUtil::removeFirstWhitespace(cmd);
460 std::string::size_type second_pos =
461 cmd.find_first_of(" \t", first_pos);
458 if (second_pos != std::string::npos) { 462 if (second_pos != std::string::npos) {
459 a= cmd.substr(second_pos); 463 a= cmd.substr(second_pos);
460 FbTk::StringUtil::removeFirstWhitespace(a); 464 FbTk::StringUtil::removeFirstWhitespace(a);
@@ -467,8 +471,44 @@ FbTk::Command *FbCommandFactory::stringToCommand(const std::string &command,
467 FbTk::RefCount<FbTk::Command> rfbcmd(fbcmd); 471 FbTk::RefCount<FbTk::Command> rfbcmd(fbcmd);
468 macro->add(rfbcmd); 472 macro->add(rfbcmd);
469 } 473 }
470 } 474 } else
471 else 475 break;
476 }
477
478 if ( macro->size() > 0 )
479 return macro;
480
481 delete macro;
482 } else if (command == "togglecmd") {
483 std::string cmd;
484 int err= 0;
485 int parse_pos= 0;
486 FbTk::ToggleCommand* macro= new FbTk::ToggleCommand();
487
488 while (true) {
489 parse_pos+= err;
490 err= FbTk::StringUtil::getStringBetween(cmd, arguments.c_str() +
491 parse_pos,
492 '{', '}', " \t\n", true);
493 if ( err > 0 ) {
494 std::string c, a;
495 std::string::size_type first_pos =
496 FbTk::StringUtil::removeFirstWhitespace(cmd);
497 std::string::size_type second_pos=
498 cmd.find_first_of(" \t", first_pos);
499 if (second_pos != std::string::npos) {
500 a= cmd.substr(second_pos);
501 FbTk::StringUtil::removeFirstWhitespace(a);
502 cmd.erase(second_pos);
503 }
504 c= FbTk::StringUtil::toLower(cmd);
505
506 FbTk::Command* fbcmd= stringToCommand(c,a);
507 if (fbcmd) {
508 FbTk::RefCount<FbTk::Command> rfbcmd(fbcmd);
509 macro->add(rfbcmd);
510 }
511 } else
472 break; 512 break;
473 } 513 }
474 514