1
0
mirror of git://projects.qi-hardware.com/cae-tools.git synced 2024-12-22 23:16:27 +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
*
* 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;
}