From 15dfe811124e3f1be7d9a802290372427dae5afb Mon Sep 17 00:00:00 2001 From: fluxgen Date: Mon, 29 Sep 2003 14:22:07 +0000 Subject: added MacroCmd action, thanks Mathias Gumz --- src/FbCommandFactory.cc | 46 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) 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 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: FbCommandFactory.cc,v 1.17 2003/09/29 13:01:01 rathnor Exp $ +// $Id: FbCommandFactory.cc,v 1.18 2003/09/29 14:22:07 fluxgen Exp $ #include "FbCommandFactory.hh" @@ -32,6 +32,10 @@ #include "SimpleCommand.hh" #include "Screen.hh" +#include "FbTk/StringUtil.hh" +#include "FbTk/MacroCommand.hh" + +#include #include // autoregister this module to command parser @@ -51,6 +55,7 @@ FbCommandFactory::FbCommandFactory() { "killwindow", "leftworkspace", "lower", + "macrocmd", "maximize", "maximizehorizontal", "maximizevertical", @@ -217,5 +222,44 @@ FbTk::Command *FbCommandFactory::stringToCommand(const std::string &command, return new ShowWorkspaceMenuCmd(); else if (command == "setworkspacename") return new SetWorkspaceNameCmd(); + // + // special commands + // + else if (command == "macrocmd") { + std::string cmd; + int err= 0; + int parse_pos= 0; + FbTk::MacroCommand* macro= new FbTk::MacroCommand(); + + while (true) { + parse_pos+= err; + err= FbTk::StringUtil::getStringBetween(cmd, arguments.c_str() + parse_pos, + '{', '}', " \t\n", true); + if ( err > 0 ) { + std::string c, a; + std::string::size_type first_pos = FbTk::StringUtil::removeFirstWhitespace(cmd); + std::string::size_type second_pos= cmd.find_first_of(" \t", first_pos); + if (second_pos != std::string::npos) { + a= cmd.substr(second_pos); + FbTk::StringUtil::removeFirstWhitespace(a); + cmd.erase(second_pos); + } + c= FbTk::StringUtil::toLower(cmd); + + FbTk::Command* fbcmd= stringToCommand(c,a); + if ( fbcmd ) { + FbTk::RefCount rfbcmd(fbcmd); + macro->add(rfbcmd); + } + } + else + break; + } + + if ( macro->size() > 0 ) + return macro; + + delete macro; + } return 0; } -- cgit v0.11.2