1
0
mirror of git://projects.qi-hardware.com/cae-tools.git synced 2025-01-09 01:50:15 +02:00

cngt/cngt.c (do_key): merge common x/y positioning code

This commit is contained in:
Werner Almesberger 2011-08-31 14:52:34 -03:00
parent 26a0f4cf2b
commit daa355461f

View File

@ -1,8 +1,8 @@
/* /*
* cngt.c - Tool change utility for MDX-15/20 * cngt.c - Tool change utility for MDX-15/20
* *
* Written 2010 by Werner Almesberger * Written 2010-2011 by Werner Almesberger
* Copyright 2010 Werner Almesberger * Copyright 2010-2011 Werner Almesberger
* *
* This program is free software; you can redistribute it and/or modify * 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 * 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) static int do_key(char c)
{ {
/* Anything but x/y positioning */
switch (c) { switch (c) {
case 'u': case 'u':
up(); up();
break; return 0;
case 'd': case 'd':
down(); down();
break; return 0;
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;
case 'q': case 'q':
return 1; 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: default:
if (c < '0' || c > '9') if (c < '0' || c > '9')
break; return 0;
up();
cx = pos_x[c-'0']; cx = pos_x[c-'0'];
cy = pos_y[c-'0']; cy = pos_y[c-'0'];
move();
} }
move();
return 0; return 0;
} }