diff options
author | mathias <mathias> | 2006-06-22 07:46:12 (GMT) |
---|---|---|
committer | mathias <mathias> | 2006-06-22 07:46:12 (GMT) |
commit | dedbd7e46816ebce6628d9357cc7feee7a61ab57 (patch) | |
tree | ff8e90f26edffb6d579857e9f68d86c378a7320c /src/FbCommandFactory.cc | |
parent | 535a88ce907641ef5648787bfa5d507d2581b86f (diff) | |
download | fluxbox_pavel-dedbd7e46816ebce6628d9357cc7feee7a61ab57.zip fluxbox_pavel-dedbd7e46816ebce6628d9357cc7feee7a61ab57.tar.bz2 |
Added patch from Jim Ramsay (i dot am at jimramsay dot com) to freely
define the used modkey.
Added new action SetModKey too
Diffstat (limited to 'src/FbCommandFactory.cc')
-rw-r--r-- | src/FbCommandFactory.cc | 85 |
1 files changed, 48 insertions, 37 deletions
diff --git a/src/FbCommandFactory.cc b/src/FbCommandFactory.cc index 4e129af..b50118e 100644 --- a/src/FbCommandFactory.cc +++ b/src/FbCommandFactory.cc | |||
@@ -44,7 +44,10 @@ | |||
44 | #include <stdio.h> | 44 | #include <stdio.h> |
45 | #endif | 45 | #endif |
46 | 46 | ||
47 | using namespace std; | 47 | using std::string; |
48 | using std::vector; | ||
49 | using std::cerr; | ||
50 | using std::endl; | ||
48 | 51 | ||
49 | // autoregister this module to command parser | 52 | // autoregister this module to command parser |
50 | FbCommandFactory FbCommandFactory::s_autoreg; | 53 | FbCommandFactory FbCommandFactory::s_autoreg; |
@@ -60,7 +63,7 @@ FbCommandFactory::FbCommandFactory() { | |||
60 | "arrangewindows", | 63 | "arrangewindows", |
61 | "bindkey", | 64 | "bindkey", |
62 | "close", | 65 | "close", |
63 | "closeallwindows", | 66 | "closeallwindows", |
64 | "commanddialog", | 67 | "commanddialog", |
65 | "deiconify", | 68 | "deiconify", |
66 | "detachclient", | 69 | "detachclient", |
@@ -122,6 +125,7 @@ FbCommandFactory::FbCommandFactory() { | |||
122 | "sendtoprevworkspace", | 125 | "sendtoprevworkspace", |
123 | "setenv", | 126 | "setenv", |
124 | "sethead", | 127 | "sethead", |
128 | "setmodkey", | ||
125 | "setstyle", | 129 | "setstyle", |
126 | "setworkspacename", | 130 | "setworkspacename", |
127 | "setworkspacenamedialog", | 131 | "setworkspacenamedialog", |
@@ -186,17 +190,24 @@ FbTk::Command *FbCommandFactory::stringToCommand(const std::string &command, | |||
186 | return new ExitFluxboxCmd(); | 190 | return new ExitFluxboxCmd(); |
187 | else if (command == "setenv" || command == "export") { | 191 | else if (command == "setenv" || command == "export") { |
188 | 192 | ||
189 | std::string name = arguments; | 193 | string name = arguments; |
190 | FbTk::StringUtil::removeFirstWhitespace(name); | 194 | FbTk::StringUtil::removeFirstWhitespace(name); |
191 | FbTk::StringUtil::removeTrailingWhitespace(name); | 195 | FbTk::StringUtil::removeTrailingWhitespace(name); |
192 | size_t pos = name.find_first_of(command == "setenv" ? " \t" : "="); | 196 | size_t pos = name.find_first_of(command == "setenv" ? " \t" : "="); |
193 | if (pos == std::string::npos || pos == name.size()) | 197 | if (pos == string::npos || pos == name.size()) |
194 | return 0; | 198 | return 0; |
195 | 199 | ||
196 | std::string value = name.substr(pos + 1); | 200 | string value = name.substr(pos + 1); |
197 | name = name.substr(0, pos); | 201 | name = name.substr(0, pos); |
198 | return new ExportCmd(name, value); | 202 | return new ExportCmd(name, value); |
199 | } | 203 | } |
204 | else if (command == "setmodkey") { | ||
205 | string modkey(arguments); | ||
206 | FbTk::StringUtil::removeFirstWhitespace(modkey); | ||
207 | FbTk::StringUtil::removeTrailingWhitespace(modkey); | ||
208 | |||
209 | return new SetModKeyCmd(modkey); | ||
210 | } | ||
200 | else if (command == "quit") | 211 | else if (command == "quit") |
201 | return new FbTk::SimpleCommand<Fluxbox>(*Fluxbox::instance(), &Fluxbox::shutdown); | 212 | return new FbTk::SimpleCommand<Fluxbox>(*Fluxbox::instance(), &Fluxbox::shutdown); |
202 | else if (command == "commanddialog") // run specified fluxbox command | 213 | else if (command == "commanddialog") // run specified fluxbox command |
@@ -233,7 +244,7 @@ FbTk::Command *FbCommandFactory::stringToCommand(const std::string &command, | |||
233 | else if (command == "maximizehorizontal") | 244 | else if (command == "maximizehorizontal") |
234 | return new CurrentWindowCmd(&FluxboxWindow::maximizeHorizontal); | 245 | return new CurrentWindowCmd(&FluxboxWindow::maximizeHorizontal); |
235 | else if (command == "resize") { | 246 | else if (command == "resize") { |
236 | FbTk_istringstream is(arguments.c_str()); | 247 | FbTk_istringstream is(arguments.c_str()); |
237 | int dx = 0, dy = 0; | 248 | int dx = 0, dy = 0; |
238 | is >> dx >> dy; | 249 | is >> dx >> dy; |
239 | return new ResizeCmd(dx, dy); | 250 | return new ResizeCmd(dx, dy); |
@@ -249,19 +260,19 @@ FbTk::Command *FbCommandFactory::stringToCommand(const std::string &command, | |||
249 | else if (command == "resizevertical") | 260 | else if (command == "resizevertical") |
250 | return new ResizeCmd(0,atoi(arguments.c_str())); | 261 | return new ResizeCmd(0,atoi(arguments.c_str())); |
251 | else if (command == "moveto") { | 262 | else if (command == "moveto") { |
252 | typedef std::vector<std::string> StringTokens; | 263 | typedef vector<string> StringTokens; |
253 | StringTokens tokens; | 264 | StringTokens tokens; |
254 | FbTk::StringUtil::stringtok<StringTokens>(tokens, arguments); | 265 | FbTk::StringUtil::stringtok<StringTokens>(tokens, arguments); |
255 | 266 | ||
256 | if (tokens.size() < 2) { | 267 | if (tokens.size() < 2) { |
257 | cerr<<"*** WARNING: missing arguments for MoveTo\n"; | 268 | cerr<<"*** WARNING: missing arguments for MoveTo\n"; |
258 | return NULL; | 269 | return NULL; |
259 | } | 270 | } |
260 | 271 | ||
261 | unsigned int refc = MoveToCmd::UPPER|MoveToCmd::LEFT; | 272 | unsigned int refc = MoveToCmd::UPPER|MoveToCmd::LEFT; |
262 | int dx = 0; | 273 | int dx = 0; |
263 | int dy = 0; | 274 | int dy = 0; |
264 | 275 | ||
265 | if (tokens[0][0] == '*') | 276 | if (tokens[0][0] == '*') |
266 | refc |= MoveToCmd::IGNORE_X; | 277 | refc |= MoveToCmd::IGNORE_X; |
267 | else | 278 | else |
@@ -271,17 +282,17 @@ FbTk::Command *FbCommandFactory::stringToCommand(const std::string &command, | |||
271 | refc |= MoveToCmd::IGNORE_Y; | 282 | refc |= MoveToCmd::IGNORE_Y; |
272 | else | 283 | else |
273 | dy = atoi(tokens[1].c_str()); | 284 | dy = atoi(tokens[1].c_str()); |
274 | 285 | ||
275 | if (tokens.size() >= 3) { | 286 | if (tokens.size() >= 3) { |
276 | tokens[2] = FbTk::StringUtil::toLower(tokens[2]); | 287 | tokens[2] = FbTk::StringUtil::toLower(tokens[2]); |
277 | if (tokens[2] == "left" || tokens[2] == "upperleft" || tokens[2] == "lowerleft") { | 288 | if (tokens[2] == "left" || tokens[2] == "upperleft" || tokens[2] == "lowerleft") { |
278 | refc |= MoveToCmd::LEFT; | 289 | refc |= MoveToCmd::LEFT; |
279 | refc &= ~MoveToCmd::RIGHT; | 290 | refc &= ~MoveToCmd::RIGHT; |
280 | } else if (tokens[2] == "right" || tokens[2] == "upperright" || tokens[2] == "lowerright") { | 291 | } else if (tokens[2] == "right" || tokens[2] == "upperright" || tokens[2] == "lowerright") { |
281 | refc |= MoveToCmd::RIGHT; | 292 | refc |= MoveToCmd::RIGHT; |
282 | refc &= ~MoveToCmd::LEFT; | 293 | refc &= ~MoveToCmd::LEFT; |
283 | } | 294 | } |
284 | 295 | ||
285 | if (tokens[2] == "upper" || tokens[2] == "upperleft" || tokens[2] == "upperright") { | 296 | if (tokens[2] == "upper" || tokens[2] == "upperleft" || tokens[2] == "upperright") { |
286 | refc |= MoveToCmd::UPPER; | 297 | refc |= MoveToCmd::UPPER; |
287 | refc &= ~MoveToCmd::LOWER; | 298 | refc &= ~MoveToCmd::LOWER; |
@@ -290,8 +301,8 @@ FbTk::Command *FbCommandFactory::stringToCommand(const std::string &command, | |||
290 | refc &= ~MoveToCmd::UPPER; | 301 | refc &= ~MoveToCmd::UPPER; |
291 | } | 302 | } |
292 | } | 303 | } |
293 | 304 | ||
294 | return new MoveToCmd(dx, dy, refc); | 305 | return new MoveToCmd(dx, dy, refc); |
295 | } | 306 | } |
296 | else if (command == "move") { | 307 | else if (command == "move") { |
297 | FbTk_istringstream is(arguments.c_str()); | 308 | FbTk_istringstream is(arguments.c_str()); |
@@ -328,14 +339,14 @@ FbTk::Command *FbCommandFactory::stringToCommand(const std::string &command, | |||
328 | else if (command == "sethead") | 339 | else if (command == "sethead") |
329 | return new SetHeadCmd(atoi(arguments.c_str())); | 340 | return new SetHeadCmd(atoi(arguments.c_str())); |
330 | else if (command == "sendtoworkspace") | 341 | else if (command == "sendtoworkspace") |
331 | // workspaces appear 1-indexed to the user, hence the minus 1 | 342 | // workspaces appear 1-indexed to the user, hence the minus 1 |
332 | return new SendToWorkspaceCmd(getint(arguments.c_str(), 1) - 1); | 343 | return new SendToWorkspaceCmd(getint(arguments.c_str(), 1) - 1); |
333 | else if (command == "sendtonextworkspace") | 344 | else if (command == "sendtonextworkspace") |
334 | return new SendToNextWorkspaceCmd(getint(arguments.c_str(), 1)); | 345 | return new SendToNextWorkspaceCmd(getint(arguments.c_str(), 1)); |
335 | else if (command == "sendtoprevworkspace") | 346 | else if (command == "sendtoprevworkspace") |
336 | return new SendToPrevWorkspaceCmd(getint(arguments.c_str(), 1)); | 347 | return new SendToPrevWorkspaceCmd(getint(arguments.c_str(), 1)); |
337 | else if (command == "taketoworkspace") | 348 | else if (command == "taketoworkspace") |
338 | // workspaces appear 1-indexed to the user, hence the minus 1 | 349 | // workspaces appear 1-indexed to the user, hence the minus 1 |
339 | return new TakeToWorkspaceCmd(getint(arguments.c_str(), 1) - 1); | 350 | return new TakeToWorkspaceCmd(getint(arguments.c_str(), 1) - 1); |
340 | else if (command == "taketonextworkspace") | 351 | else if (command == "taketonextworkspace") |
341 | return new TakeToNextWorkspaceCmd(getint(arguments.c_str(), 1)); | 352 | return new TakeToNextWorkspaceCmd(getint(arguments.c_str(), 1)); |
@@ -357,7 +368,7 @@ FbTk::Command *FbCommandFactory::stringToCommand(const std::string &command, | |||
357 | return new CurrentWindowCmd(&FluxboxWindow::detachCurrentClient); | 368 | return new CurrentWindowCmd(&FluxboxWindow::detachCurrentClient); |
358 | else if (command == "windowmenu") | 369 | else if (command == "windowmenu") |
359 | return new CurrentWindowCmd(&FluxboxWindow::popupMenu); | 370 | return new CurrentWindowCmd(&FluxboxWindow::popupMenu); |
360 | // | 371 | // |
361 | // Workspace commands | 372 | // Workspace commands |
362 | // | 373 | // |
363 | else if (command == "nextworkspace") | 374 | else if (command == "nextworkspace") |
@@ -369,12 +380,12 @@ FbTk::Command *FbCommandFactory::stringToCommand(const std::string &command, | |||
369 | else if (command == "leftworkspace") | 380 | else if (command == "leftworkspace") |
370 | return new LeftWorkspaceCmd(getint(arguments.c_str(), 1)); | 381 | return new LeftWorkspaceCmd(getint(arguments.c_str(), 1)); |
371 | else if (command == "workspace") | 382 | else if (command == "workspace") |
372 | // workspaces appear 1-indexed to the user, hence the minus 1 | 383 | // workspaces appear 1-indexed to the user, hence the minus 1 |
373 | return new JumpToWorkspaceCmd(getint(arguments.c_str(), 1) - 1); | 384 | return new JumpToWorkspaceCmd(getint(arguments.c_str(), 1) - 1); |
374 | else if (command.substr(0, 9) == "workspace" && command[9] >= '0' && command[9] <= '9') { | 385 | else if (command.substr(0, 9) == "workspace" && command[9] >= '0' && command[9] <= '9') { |
375 | cerr<<"*** WARNING: 'Workspace<n>' actions are deprecated! Use 'Workspace <n>' instead"<<endl; | 386 | cerr<<"*** WARNING: 'Workspace<n>' actions are deprecated! Use 'Workspace <n>' instead"<<endl; |
376 | return new JumpToWorkspaceCmd(getint(command.substr(9).c_str(), 1) - 1); | 387 | return new JumpToWorkspaceCmd(getint(command.substr(9).c_str(), 1) - 1); |
377 | 388 | ||
378 | } else if (command == "nextwindow") | 389 | } else if (command == "nextwindow") |
379 | return new NextWindowCmd(atoi(arguments.c_str())); | 390 | return new NextWindowCmd(atoi(arguments.c_str())); |
380 | else if (command == "prevwindow") | 391 | else if (command == "prevwindow") |
@@ -421,7 +432,7 @@ FbTk::Command *FbCommandFactory::stringToCommand(const std::string &command, | |||
421 | if (iss.fail()) | 432 | if (iss.fail()) |
422 | mode="lastworkspace"; | 433 | mode="lastworkspace"; |
423 | mode= FbTk::StringUtil::toLower(mode); | 434 | mode= FbTk::StringUtil::toLower(mode); |
424 | 435 | ||
425 | iss >> d; | 436 | iss >> d; |
426 | if (iss.fail()) | 437 | if (iss.fail()) |
427 | d="current"; | 438 | d="current"; |
@@ -432,9 +443,9 @@ FbTk::Command *FbCommandFactory::stringToCommand(const std::string &command, | |||
432 | dest= DeiconifyCmd::ORIGINQUIET; | 443 | dest= DeiconifyCmd::ORIGINQUIET; |
433 | else | 444 | else |
434 | dest= DeiconifyCmd::CURRENT; | 445 | dest= DeiconifyCmd::CURRENT; |
435 | 446 | ||
436 | if ( mode == "all" ) | 447 | if ( mode == "all" ) |
437 | return new DeiconifyCmd(DeiconifyCmd::ALL, dest); | 448 | return new DeiconifyCmd(DeiconifyCmd::ALL, dest); |
438 | else if ( mode == "allworkspace" ) | 449 | else if ( mode == "allworkspace" ) |
439 | return new DeiconifyCmd(DeiconifyCmd::ALLWORKSPACE, dest); | 450 | return new DeiconifyCmd(DeiconifyCmd::ALLWORKSPACE, dest); |
440 | else if ( mode == "last" ) | 451 | else if ( mode == "last" ) |
@@ -443,23 +454,23 @@ FbTk::Command *FbCommandFactory::stringToCommand(const std::string &command, | |||
443 | return new DeiconifyCmd(DeiconifyCmd::LASTWORKSPACE, dest); | 454 | return new DeiconifyCmd(DeiconifyCmd::LASTWORKSPACE, dest); |
444 | 455 | ||
445 | } else if (command == "macrocmd") { | 456 | } else if (command == "macrocmd") { |
446 | std::string cmd; | 457 | string cmd; |
447 | int err= 0; | 458 | int err= 0; |
448 | int parse_pos= 0; | 459 | int parse_pos= 0; |
449 | FbTk::MacroCommand* macro= new FbTk::MacroCommand(); | 460 | FbTk::MacroCommand* macro= new FbTk::MacroCommand(); |
450 | 461 | ||
451 | while (true) { | 462 | while (true) { |
452 | parse_pos+= err; | 463 | parse_pos+= err; |
453 | err= FbTk::StringUtil::getStringBetween(cmd, arguments.c_str() + | 464 | err= FbTk::StringUtil::getStringBetween(cmd, arguments.c_str() + |
454 | parse_pos, | 465 | parse_pos, |
455 | '{', '}', " \t\n", true); | 466 | '{', '}', " \t\n", true); |
456 | if ( err > 0 ) { | 467 | if ( err > 0 ) { |
457 | std::string c, a; | 468 | string c, a; |
458 | std::string::size_type first_pos = | 469 | string::size_type first_pos = |
459 | FbTk::StringUtil::removeFirstWhitespace(cmd); | 470 | FbTk::StringUtil::removeFirstWhitespace(cmd); |
460 | std::string::size_type second_pos = | 471 | string::size_type second_pos = |
461 | cmd.find_first_of(" \t", first_pos); | 472 | cmd.find_first_of(" \t", first_pos); |
462 | if (second_pos != std::string::npos) { | 473 | if (second_pos != string::npos) { |
463 | a= cmd.substr(second_pos); | 474 | a= cmd.substr(second_pos); |
464 | FbTk::StringUtil::removeFirstWhitespace(a); | 475 | FbTk::StringUtil::removeFirstWhitespace(a); |
465 | cmd.erase(second_pos); | 476 | cmd.erase(second_pos); |
@@ -480,23 +491,23 @@ FbTk::Command *FbCommandFactory::stringToCommand(const std::string &command, | |||
480 | 491 | ||
481 | delete macro; | 492 | delete macro; |
482 | } else if (command == "togglecmd") { | 493 | } else if (command == "togglecmd") { |
483 | std::string cmd; | 494 | string cmd; |
484 | int err= 0; | 495 | int err= 0; |
485 | int parse_pos= 0; | 496 | int parse_pos= 0; |
486 | FbTk::ToggleCommand* macro= new FbTk::ToggleCommand(); | 497 | FbTk::ToggleCommand* macro= new FbTk::ToggleCommand(); |
487 | 498 | ||
488 | while (true) { | 499 | while (true) { |
489 | parse_pos+= err; | 500 | parse_pos+= err; |
490 | err= FbTk::StringUtil::getStringBetween(cmd, arguments.c_str() + | 501 | err= FbTk::StringUtil::getStringBetween(cmd, arguments.c_str() + |
491 | parse_pos, | 502 | parse_pos, |
492 | '{', '}', " \t\n", true); | 503 | '{', '}', " \t\n", true); |
493 | if ( err > 0 ) { | 504 | if ( err > 0 ) { |
494 | std::string c, a; | 505 | string c, a; |
495 | std::string::size_type first_pos = | 506 | string::size_type first_pos = |
496 | FbTk::StringUtil::removeFirstWhitespace(cmd); | 507 | FbTk::StringUtil::removeFirstWhitespace(cmd); |
497 | std::string::size_type second_pos= | 508 | string::size_type second_pos= |
498 | cmd.find_first_of(" \t", first_pos); | 509 | cmd.find_first_of(" \t", first_pos); |
499 | if (second_pos != std::string::npos) { | 510 | if (second_pos != string::npos) { |
500 | a= cmd.substr(second_pos); | 511 | a= cmd.substr(second_pos); |
501 | FbTk::StringUtil::removeFirstWhitespace(a); | 512 | FbTk::StringUtil::removeFirstWhitespace(a); |
502 | cmd.erase(second_pos); | 513 | cmd.erase(second_pos); |