improved defaulting of int args in commands (thanks Jonas Koelker)
This commit is contained in:
parent
4d0a0c9e11
commit
a92c131710
2 changed files with 35 additions and 31 deletions
|
@ -1,6 +1,11 @@
|
||||||
(Format: Year/Month/Day)
|
(Format: Year/Month/Day)
|
||||||
Changes for 0.9.16:
|
Changes for 0.9.16:
|
||||||
*06/04/16:
|
*06/04/16:
|
||||||
|
* Set (take|send)to(next|prev)workspace offset default value to 1
|
||||||
|
instead of the current 0 (which makes them look non-functional).
|
||||||
|
Similarly for tab and (|next|prev|left|right)workspace.
|
||||||
|
- Thanks Jonas Koelker (sf.net 1467926)
|
||||||
|
FbCommandFactory.cc
|
||||||
* Add "CloseAllWindows" key binding
|
* Add "CloseAllWindows" key binding
|
||||||
(thanks Adriano Dal Bosco - adbosco at users.sourceforge.net)
|
(thanks Adriano Dal Bosco - adbosco at users.sourceforge.net)
|
||||||
- Useful to trigger all "close" actions before flux exit (or other)
|
- Useful to trigger all "close" actions before flux exit (or other)
|
||||||
|
|
|
@ -38,12 +38,21 @@
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#ifdef HAVE_CSTDIO
|
||||||
|
#include <cstdio>
|
||||||
|
#else
|
||||||
|
#include <stdio.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
// autoregister this module to command parser
|
// autoregister this module to command parser
|
||||||
FbCommandFactory FbCommandFactory::s_autoreg;
|
FbCommandFactory FbCommandFactory::s_autoreg;
|
||||||
|
|
||||||
|
static int getint(const char *str, int defaultvalue) {
|
||||||
|
sscanf(str, "%d", &defaultvalue);
|
||||||
|
return defaultvalue;
|
||||||
|
}
|
||||||
|
|
||||||
FbCommandFactory::FbCommandFactory() {
|
FbCommandFactory::FbCommandFactory() {
|
||||||
// setup commands that we can handle
|
// setup commands that we can handle
|
||||||
|
@ -148,12 +157,8 @@ FbCommandFactory::FbCommandFactory() {
|
||||||
0
|
0
|
||||||
};
|
};
|
||||||
|
|
||||||
for (int i=0;; ++i) {
|
for (int i=0; commands[i]; ++i)
|
||||||
if (commands[i] == 0)
|
|
||||||
break;
|
|
||||||
addCommand(commands[i]);
|
addCommand(commands[i]);
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FbTk::Command *FbCommandFactory::stringToCommand(const std::string &command,
|
FbTk::Command *FbCommandFactory::stringToCommand(const std::string &command,
|
||||||
|
@ -322,26 +327,24 @@ FbTk::Command *FbCommandFactory::stringToCommand(const std::string &command,
|
||||||
else if (command == "sethead")
|
else if (command == "sethead")
|
||||||
return new SetHeadCmd(atoi(arguments.c_str()));
|
return new SetHeadCmd(atoi(arguments.c_str()));
|
||||||
else if (command == "sendtoworkspace")
|
else if (command == "sendtoworkspace")
|
||||||
return new SendToWorkspaceCmd(atoi(arguments.c_str()) - 1); // make 1-indexed to user
|
// workspaces appear 1-indexed to the user, hence the minus 1
|
||||||
|
return new SendToWorkspaceCmd(getint(arguments.c_str(), 1) - 1);
|
||||||
else if (command == "sendtonextworkspace")
|
else if (command == "sendtonextworkspace")
|
||||||
return new SendToNextWorkspaceCmd(atoi(arguments.c_str()));
|
return new SendToNextWorkspaceCmd(getint(arguments.c_str(), 1));
|
||||||
else if (command == "sendtoprevworkspace")
|
else if (command == "sendtoprevworkspace")
|
||||||
return new SendToPrevWorkspaceCmd(atoi(arguments.c_str()));
|
return new SendToPrevWorkspaceCmd(getint(arguments.c_str(), 1));
|
||||||
else if (command == "taketoworkspace")
|
else if (command == "taketoworkspace")
|
||||||
return new TakeToWorkspaceCmd(atoi(arguments.c_str()) - 1);
|
// workspaces appear 1-indexed to the user, hence the minus 1
|
||||||
|
return new TakeToWorkspaceCmd(getint(arguments.c_str(), 1) - 1);
|
||||||
else if (command == "taketonextworkspace")
|
else if (command == "taketonextworkspace")
|
||||||
return new TakeToNextWorkspaceCmd(atoi(arguments.c_str()));
|
return new TakeToNextWorkspaceCmd(getint(arguments.c_str(), 1));
|
||||||
else if (command == "taketoprevworkspace")
|
else if (command == "taketoprevworkspace")
|
||||||
return new TakeToPrevWorkspaceCmd(atoi(arguments.c_str()));
|
return new TakeToPrevWorkspaceCmd(getint(arguments.c_str(), 1));
|
||||||
else if (command == "killwindow" || command == "kill")
|
else if (command == "killwindow" || command == "kill")
|
||||||
return new KillWindowCmd();
|
return new KillWindowCmd();
|
||||||
else if (command == "tab") {
|
else if (command == "tab")
|
||||||
// XXX
|
return new GoToTabCmd(getint(arguments.c_str(), 1));
|
||||||
int num = 1;
|
else if (command == "nexttab")
|
||||||
if (!arguments.empty())
|
|
||||||
num = atoi(arguments.c_str());
|
|
||||||
return new GoToTabCmd(num);
|
|
||||||
} else if (command == "nexttab")
|
|
||||||
return new CurrentWindowCmd(&FluxboxWindow::nextClient);
|
return new CurrentWindowCmd(&FluxboxWindow::nextClient);
|
||||||
else if (command == "prevtab")
|
else if (command == "prevtab")
|
||||||
return new CurrentWindowCmd(&FluxboxWindow::prevClient);
|
return new CurrentWindowCmd(&FluxboxWindow::prevClient);
|
||||||
|
@ -357,23 +360,19 @@ FbTk::Command *FbCommandFactory::stringToCommand(const std::string &command,
|
||||||
// Workspace commands
|
// Workspace commands
|
||||||
//
|
//
|
||||||
else if (command == "nextworkspace")
|
else if (command == "nextworkspace")
|
||||||
return new NextWorkspaceCmd(atoi(arguments.c_str()));
|
return new NextWorkspaceCmd(getint(arguments.c_str(), 1));
|
||||||
else if (command == "prevworkspace")
|
else if (command == "prevworkspace")
|
||||||
return new PrevWorkspaceCmd(atoi(arguments.c_str()));
|
return new PrevWorkspaceCmd(getint(arguments.c_str(), 1));
|
||||||
else if (command == "rightworkspace")
|
else if (command == "rightworkspace")
|
||||||
return new RightWorkspaceCmd(atoi(arguments.c_str()));
|
return new RightWorkspaceCmd(getint(arguments.c_str(), 1));
|
||||||
else if (command == "leftworkspace")
|
else if (command == "leftworkspace")
|
||||||
return new LeftWorkspaceCmd(atoi(arguments.c_str()));
|
return new LeftWorkspaceCmd(getint(arguments.c_str(), 1));
|
||||||
else if (command == "workspace") {
|
else if (command == "workspace")
|
||||||
int num = 1; // workspaces appear 1-indexed to the user
|
// workspaces appear 1-indexed to the user, hence the minus 1
|
||||||
if (!arguments.empty())
|
return new JumpToWorkspaceCmd(getint(arguments.c_str(), 1) - 1);
|
||||||
num = atoi(arguments.c_str());
|
else if (command.substr(0, 9) == "workspace" && command[9] >= '0' && command[9] <= '9') {
|
||||||
return new JumpToWorkspaceCmd(num-1);
|
|
||||||
} if (command.substr(0, 9) == "workspace" && command[9] >= '0' && command[9] <= '9') {
|
|
||||||
cerr<<"*** WARNING: 'Workspace<n>' actions are deprecated! Use 'Workspace <n>' instead"<<endl;
|
cerr<<"*** WARNING: 'Workspace<n>' actions are deprecated! Use 'Workspace <n>' instead"<<endl;
|
||||||
int num = 1;
|
return new JumpToWorkspaceCmd(getint(command.substr(9).c_str(), 1) - 1);
|
||||||
num = atoi(command.substr(9).c_str());
|
|
||||||
return new JumpToWorkspaceCmd(num-1);
|
|
||||||
|
|
||||||
} else if (command == "nextwindow")
|
} else if (command == "nextwindow")
|
||||||
return new NextWindowCmd(atoi(arguments.c_str()));
|
return new NextWindowCmd(atoi(arguments.c_str()));
|
||||||
|
|
Loading…
Reference in a new issue