--- lbbs/src/io.c 2004/10/23 18:41:41 1.2 +++ lbbs/src/io.c 2004/11/30 07:10:32 1.3 @@ -25,7 +25,7 @@ outc(char c) { int retval; - retval = printf("%c",c); + retval = fprintf(stdout, "%c", c); return retval; } @@ -56,10 +56,10 @@ iflush() int igetch () { - char c, tmp[256]; static char buf[256]; - int out = 0, loop = 1, in_esc = 0, in_ascii = 0, i = 0, j; - static int len =0 , pos = 0; + unsigned char c, tmp[256]; + int out = 0, loop = 1, in_esc = 0, in_ascii = 0, in_control = 0, i = 0, j; + static int len = 0 , pos = 0; if (pos >= len) { @@ -68,7 +68,7 @@ igetch () //For debug //for (j = 0; j < len; j++) - // log_std ("[%d]\n", buf[j]); + // log_std ("<--[%u]\n", (buf[j] + 256) % 256); } while (pos < len) @@ -81,6 +81,28 @@ igetch () break; } + if (c == KEY_CONTROL) + { + if (in_control == 0) + { + in_control = 1; + i = 0; + continue; + } + } + + if (in_control) + { + tmp[i++] = c; + if (i >= 2) + { + out = (int)tmp[0] * 256 + tmp[1]; + in_control = 0; + break; + } + continue; + } + if (c == ESC_KEY) { if (in_esc == 0) @@ -156,7 +178,7 @@ igetch () } //for debug - //log_std ("[%d]\n", out); + //log_std ("-->[%u]\n", out); return out; }