| 25 |
{ |
{ |
| 26 |
int retval; |
int retval; |
| 27 |
|
|
| 28 |
retval = printf("%c",c); |
retval = fprintf(stdout, "%c", c); |
| 29 |
|
|
| 30 |
return retval; |
return retval; |
| 31 |
} |
} |
| 56 |
int |
int |
| 57 |
igetch () |
igetch () |
| 58 |
{ |
{ |
|
char c, tmp[256]; |
|
| 59 |
static char buf[256]; |
static char buf[256]; |
| 60 |
int out = 0, loop = 1, in_esc = 0, in_ascii = 0, i = 0, j; |
unsigned char c, tmp[256]; |
| 61 |
static int len =0 , pos = 0; |
int out = 0, loop = 1, in_esc = 0, in_ascii = 0, in_control = 0, i = 0, j; |
| 62 |
|
static int len = 0 , pos = 0; |
| 63 |
|
|
| 64 |
if (pos >= len) |
if (pos >= len) |
| 65 |
{ |
{ |
| 68 |
|
|
| 69 |
//For debug |
//For debug |
| 70 |
//for (j = 0; j < len; j++) |
//for (j = 0; j < len; j++) |
| 71 |
// log_std ("[%d]\n", buf[j]); |
// log_std ("<--[%u]\n", (buf[j] + 256) % 256); |
| 72 |
} |
} |
| 73 |
|
|
| 74 |
while (pos < len) |
while (pos < len) |
| 81 |
break; |
break; |
| 82 |
} |
} |
| 83 |
|
|
| 84 |
|
if (c == KEY_CONTROL) |
| 85 |
|
{ |
| 86 |
|
if (in_control == 0) |
| 87 |
|
{ |
| 88 |
|
in_control = 1; |
| 89 |
|
i = 0; |
| 90 |
|
continue; |
| 91 |
|
} |
| 92 |
|
} |
| 93 |
|
|
| 94 |
|
if (in_control) |
| 95 |
|
{ |
| 96 |
|
tmp[i++] = c; |
| 97 |
|
if (i >= 2) |
| 98 |
|
{ |
| 99 |
|
out = (int)tmp[0] * 256 + tmp[1]; |
| 100 |
|
in_control = 0; |
| 101 |
|
break; |
| 102 |
|
} |
| 103 |
|
continue; |
| 104 |
|
} |
| 105 |
|
|
| 106 |
if (c == ESC_KEY) |
if (c == ESC_KEY) |
| 107 |
{ |
{ |
| 108 |
if (in_esc == 0) |
if (in_esc == 0) |
| 178 |
} |
} |
| 179 |
|
|
| 180 |
//for debug |
//for debug |
| 181 |
//log_std ("[%d]\n", out); |
//log_std ("-->[%u]\n", out); |
| 182 |
|
|
| 183 |
return out; |
return out; |
| 184 |
} |
} |