aboutsummaryrefslogtreecommitdiff
path: root/src/FbCommandFactory.cc
diff options
context:
space:
mode:
authormathias <mathias>2005-06-15 15:17:48 (GMT)
committermathias <mathias>2005-06-15 15:17:48 (GMT)
commitd69e300376db05642730792f34e38712f52efbc2 (patch)
tree97afcfc41bc49aaa05bbd0e7feb4b826f96c074f /src/FbCommandFactory.cc
parent93b295a1587f91366d16a0d8c7514a4cd841cd38 (diff)
downloadfluxbox_pavel-d69e300376db05642730792f34e38712f52efbc2.zip
fluxbox_pavel-d69e300376db05642730792f34e38712f52efbc2.tar.bz2
Enhanced MoveTo, fixes #1074568
MoveTo <int|*> <int|*> <Reference Corner> - * means "use current value" - Reference Corner is one of: - UpperLeft, Upper, UpperRight - Left, Right - LowerLeft, Lower, Right examples: MoveTo 0 * Left -> snap to left workspace edge MoveTo * 0 Lower -> snap to lower workspace edge MoveTo 0 0 UpperRight -> snap to upper right workspace corner TODO: perhaps add some "aliases" to make it more userfriendly
Diffstat (limited to 'src/FbCommandFactory.cc')
-rw-r--r--src/FbCommandFactory.cc47
1 files changed, 43 insertions, 4 deletions
diff --git a/src/FbCommandFactory.cc b/src/FbCommandFactory.cc
index f3c6f51..8ac4d69 100644
--- a/src/FbCommandFactory.cc
+++ b/src/FbCommandFactory.cc
@@ -239,10 +239,49 @@ FbTk::Command *FbCommandFactory::stringToCommand(const std::string &command,
239 else if (command == "resizevertical") 239 else if (command == "resizevertical")
240 return new ResizeCmd(0,atoi(arguments.c_str())); 240 return new ResizeCmd(0,atoi(arguments.c_str()));
241 else if (command == "moveto") { 241 else if (command == "moveto") {
242 FbTk_istringstream is(arguments.c_str()); 242 typedef std::vector<std::string> StringTokens;
243 int dx = 0, dy = 0; 243 StringTokens tokens;
244 is >> dx >> dy; 244 FbTk::StringUtil::stringtok<StringTokens>(tokens, arguments);
245 return new MoveToCmd(dx,dy); 245
246 if (tokens.size() < 2) {
247 cerr<<"*** WARNING: missing arguments for MoveTo\n";
248 return NULL;
249 }
250
251 unsigned int refc = MoveToCmd::UPPER|MoveToCmd::LEFT;
252 int dx = 0;
253 int dy = 0;
254
255 if (tokens[0][0] == '*')
256 refc |= MoveToCmd::IGNORE_X;
257 else
258 dx = atoi(tokens[0].c_str());
259
260 if (tokens[1][0] == '*' && ! (refc & MoveToCmd::IGNORE_X))
261 refc |= MoveToCmd::IGNORE_Y;
262 else
263 dy = atoi(tokens[1].c_str());
264
265 if (tokens.size() >= 3) {
266 tokens[2] = FbTk::StringUtil::toLower(tokens[2]);
267 if (tokens[2] == "left" || tokens[2] == "upperleft" || tokens[2] == "lowerleft") {
268 refc |= MoveToCmd::LEFT;
269 refc &= ~MoveToCmd::RIGHT;
270 } else if (tokens[2] == "right" || tokens[2] == "upperright" || tokens[2] == "lowerright") {
271 refc |= MoveToCmd::RIGHT;
272 refc &= ~MoveToCmd::LEFT;
273 }
274
275 if (tokens[2] == "upper" || tokens[2] == "upperleft" || tokens[2] == "upperright") {
276 refc |= MoveToCmd::UPPER;
277 refc &= ~MoveToCmd::LOWER;
278 } else if (tokens[2] == "lower" || tokens[2] == "lowerleft" || tokens[2] == "lowerright") {
279 refc |= MoveToCmd::LOWER;
280 refc &= ~MoveToCmd::UPPER;
281 }
282 }
283
284 return new MoveToCmd(dx, dy, refc);
246 } 285 }
247 else if (command == "move") { 286 else if (command == "move") {
248 FbTk_istringstream is(arguments.c_str()); 287 FbTk_istringstream is(arguments.c_str());