diff --git a/cngt/cngt.c b/cngt/cngt.c index 0011ac6..ccbe42e 100644 --- a/cngt/cngt.c +++ b/cngt/cngt.c @@ -1,8 +1,8 @@ /* * cngt.c - Tool change utility for MDX-15/20 * - * Written 2010 by Werner Almesberger - * Copyright 2010 Werner Almesberger + * Written 2010-2011 by Werner Almesberger + * Copyright 2010-2011 Werner Almesberger * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -54,43 +54,47 @@ static void down(void) static int do_key(char c) { + /* Anything but x/y positioning */ + switch (c) { case 'u': up(); - break; + return 0; case 'd': down(); - break; - case 'h': - up(); - cx -= STEP; - move(); - break; - case 'j': - up(); - cy -= STEP; - move(); - break; - case 'k': - up(); - cy += STEP; - move(); - break; - case 'l': - up(); - cx += STEP; - move(); - break; + return 0; case 'q': return 1; + default: + break; + } + + /* Only x/y positioning */ + + up(); + + switch (c) { + case 'h': + cx -= STEP; + break; + case 'j': + cy -= STEP; + break; + case 'k': + cy += STEP; + break; + case 'l': + cx += STEP; + break; default: if (c < '0' || c > '9') - break; - up(); + return 0; cx = pos_x[c-'0']; cy = pos_y[c-'0']; - move(); } + + move(); + return 0; }