mirror of
git://projects.qi-hardware.com/cae-tools.git
synced 2024-12-23 04:23:55 +02:00
cngt/cngt.c (do_key): merge common x/y positioning code
This commit is contained in:
parent
26a0f4cf2b
commit
daa355461f
56
cngt/cngt.c
56
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:
|
||||
if (c < '0' || c > '9')
|
||||
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')
|
||||
return 0;
|
||||
cx = pos_x[c-'0'];
|
||||
cy = pos_y[c-'0'];
|
||||
move();
|
||||
}
|
||||
|
||||
move();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user