diff options
Diffstat (limited to 'src/FbCommandFactory.cc')
-rw-r--r-- | src/FbCommandFactory.cc | 47 |
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()); |