Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT sources DOT redhat DOT com Delivered-To: mailing list cygwin AT sources DOT redhat DOT com Message-ID: <61F573D3AC04D311956000A0CC2691C2072615@ENTERPRISE> From: Adam Rosenberg To: "'cygwin AT sourceware DOT cygnus DOT com'" Subject: FW: KBHIT and GETCH Date: Wed, 19 Jul 2000 17:37:47 -0500 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2448.0) Content-Type: multipart/mixed; boundary="----_=_NextPart_000_01BFF1D1.F6950DC0" ------_=_NextPart_000_01BFF1D1.F6950DC0 Content-Type: text/plain; charset="iso-8859-1" I thought I would mention that "gcc -o g2_term g2_term.c" does what I want on my RedHat Linux box. The arrow keys are seen as arrow keys and other keys still work. That's what I am trying to get on CygWin and I think I'm close but I have no idea what to try next. -----Original Message----- From: Adam Rosenberg Sent: Wednesday, July 19, 2000 5:13 PM To: 'cygwin AT sourceware DOT cygnus DOT com' Cc: 'adam AT psionic DOT mn DOT org' Subject: KBHIT and GETCH I found that most of my funky stuff from LINUX works just fine in CYGWIN on my Windows NT box, but one area which doesn't work is my KBHIT function. My compile command line is "gcc -g -o g2_cyg.exe g2_cyg.c" and then I can run g2_cyg from the command line. It tells me all my characters except for the arrow keys where it times out on the [A part of ESCAPE[A for the up arrow key. My KBHIT function isn't seeing the left bracket, but it does just fine if I hand type ESCAPE, [, and A. Any ideas? I'm kind of confused here and do not myself make a career of programming at this level. I'm a math guy who does nasty algorithms and want my arrow keys to work, so I really appreciate any help you can give me here. Adam N. Rosenberg 6751 Rufe Snow Drive, Suite 350 Watauga, Texas 76148-2331 1-817-281-8225 ext. 205 1-817-281-1512 FAX ------_=_NextPart_000_01BFF1D1.F6950DC0 Content-Type: application/octet-stream; name="g2_cyg.c" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="g2_cyg.c" #include #include #include #include #if 0 #define DPRINT(x) #define DPRIN2(x,y) #define DPRIN3(x,y,z) #else #define DPRINT(x) fprintf (stderr, x) #define DPRIN2(x,y) fprintf (stderr, x, y) #define DPRIN3(x,y,z) fprintf (stderr, x, y, z) #endif #include "g2_term.h" static int i1 =3D 0; static int i2 =3D 0; static int i3 =3D 0; static int i4 =3D 0; int erase_char, kill_char, werase_char; /* ***** RAW_MODE ***** */ void raw_mode (int on) { /* 27-73 */ #if G2_WINAPI =3D=3D 0 static int curr_on =3D 0; static struct termio current_io; static struct termio original_io; int result; if (on =3D=3D curr_on) return; if (on) { /* 37-58 */ /* get original Terminal settings to restore */ /* mode when we are finished */ result =3D ioctl (0, TCGETA, &original_io); if (result =3D=3D -1) { /* 42-45 */ perror ("ioctl(): TIOCGETD"); exit (1); } /* 42-45 */ memcpy (¤t_io, &original_io, sizeof (struct termio)); current_io.c_cc[VMIN] =3D 1; /* wait for one character */ current_io.c_cc[VTIME] =3D 0; /* and don't wait to return it */ current_io.c_lflag &=3D ~ICANON; /* unbuffered input */ current_io.c_lflag &=3D ~ECHO; /* turn off local display */ /* set new input mode */ result =3D ioctl (0, TCSETA, ¤t_io); if (result =3D=3D -1) { /* 54-57 */ perror ("ioctl(): TIOCSETP"); exit (1); } /* 54-57 */ } /* 37-58 */ else { /* 60-68 */ /* reset original terminal mode */ result =3D ioctl (0, TCSETA, &original_io); if (result =3D=3D -1) { /* 64-67 */ perror ("ioctl(): TIOCSETP to reset original io"); exit (1); } /* 64-67 */ } /* 60-68 */ curr_on =3D on; #endif return; } /* 27-73 */ /* ***** GETCHR ***** */ int getchr (void) { /* 77-81 */ int j; j =3D fgetc (stdin); return (j); } /* 77-81 */ /* ***** KBHIT ***** */ int kbhit (void) { /* 85-110 */ #if G2_WINAPI int i; i =3D g_kbhit (); return (i); #else fd_set rfds; struct timeval tv; if (i1 !=3D 0) return (1); FD_ZERO (&rfds); FD_SET (0, &rfds); tv.tv_sec =3D 0; tv.tv_usec =3D 0; #if 1 if (select (1, &rfds, NULL, NULL, &tv)) return (1); return (0); #else select (1, &rfds, NULL, NULL, &tv); if (FD_ISSET(0, &rfds)) return (1); #endif #endif return (0); } /* 85-110 */ /* ***** TIME_CHAR ***** */ int time_char (void) { /* 114-132 */ int j; clock_t iclock, jclock; iclock =3D jclock =3D clock (); while (jclock-iclock < CLOCKS_PER_SEC) { /* 120-124 */ j =3D kbhit (); if (j) break; jclock =3D clock (); } /* 120-124 */ if (j =3D=3D 0) DPRINT ("\t\t\t\t\tTime out.\n"); if (j =3D=3D 0) return (0); j =3D getchr (); if (j > 31) DPRIN3 ("\t\t\t\t\tchar is %d (%c).\n", j, j); else DPRIN2 ("\t\t\t\t\tchar is %d.\n", j); return (j); } /* 114-132 */ /* **** GETCH ***** */ int getch (void) { /* 136-487 */ int c, j; #if G2_WINAPI c =3D g_getch (); #else if (i1 !=3D 0) { /* 143-147 */ c =3D i1, i1 =3D i2, i2 =3D i3, i3 =3D i4, i4 =3D 0; DPRINT ("\t\t\t\tNextchar.\n"); return (c); } /* 143-147 */ c =3D getchr (); if (c !=3D ESCAPE) return (c); DPRINT ("\t\t\t\tEscape\n"); /* Okay, here's the deal. If the character is an */ /* ESCAPE character (27), then it *could* be the */ /* start of an arrow-key sequence and should be */ /* processed as such. On the other hand, since it */ /* could also be a naked ESCAPE, we're going to */ /* wait a half second for another character. */ /* If the other character comes along and it is not */ /* a special character ([ or O), then we keep it */ /* here and send it immediately the next time */ /* this function is called. */ i1 =3D time_char (); if (i1 =3D=3D 0) return (c); DPRINT ("\t\t\t\tKbhit\n"); /* Left bracket case. */ if (i1 =3D=3D '[') { /* 173-399 */ DPRINT ("\t\t\t\tSpecial [\n"); i2 =3D time_char (); if (i2 =3D=3D 0) return (c); if (i2 =3D=3D 'A') { /* 179-182 */ i1 =3D i2 =3D 0; return (UP_ARROW); } /* 179-182 */ if (i2 =3D=3D 'B') { /* 184-187 */ i1 =3D i2 =3D 0; return (DOWN_ARROW); } /* 184-187 */ if (i2 =3D=3D 'C') { /* 189-192 */ i1 =3D i2 =3D 0; return (RIGHT_ARROW); } /* 189-192 */ if (i2 =3D=3D 'D') { /* 194-197 */ i1 =3D i2 =3D 0; return (LEFT_ARROW); } /* 194-197 */ if (i2 =3D=3D 'G') { /* 199-202 */ i1 =3D i2 =3D 0; return (CENTER); } /* 199-202 */ if (i2 =3D=3D '1') { /* 204-256 */ DPRINT ("\t\t\t\tSpecial [ 1\n"); i3 =3D time_char (); if (i3 =3D=3D 0) return (c); if (i3 =3D=3D TWIDDLE) { /* 209-213 */ DPRINT ("\t\t\t\tSpecial [ 1 ~\n"); i1 =3D i2 =3D i3 =3D 0; return (HOME); } /* 209-213 */ if (i3 =3D=3D CARROT) { /* 215-219 */ DPRINT ("\t\t\t\tSpecial [ 1 ^\n"); i1 =3D i2 =3D i3 =3D 0; return (CNTL_HOME); } /* 215-219 */ if (isdigit (i3) =3D=3D 0) return (c); i4 =3D time_char (); if (i4 =3D=3D 0) return (c); if (i4 =3D=3D TWIDDLE) { /* 223-238 */ DPRINT ("\t\t\t\tSpecial [ 1 * ~\n"); switch (i3) { /* 226-237 */ case '0': return (c); case '1': i1 =3D i2 =3D i3 =3D i4 =3D 0; return (F_ONE); case '2': i1 =3D i2 =3D i3 =3D i4 =3D 0; return = (F_ONE-1); case '3': i1 =3D i2 =3D i3 =3D i4 =3D 0; return = (F_ONE-2); case '4': i1 =3D i2 =3D i3 =3D i4 =3D 0; return = (F_ONE-3); case '5': i1 =3D i2 =3D i3 =3D i4 =3D 0; return = (F_ONE-4); case '6': return (c); case '7': i1 =3D i2 =3D i3 =3D i4 =3D 0; return = (F_ONE-5); case '8': i1 =3D i2 =3D i3 =3D i4 =3D 0; return = (F_ONE-6); case '9': i1 =3D i2 =3D i3 =3D i4 =3D 0; return = (F_ONE-7); } /* 226-237 */ } /* 223-238 */ else if (i4 =3D=3D CARROT) { /* 240-255 */ DPRINT ("\t\t\t\tSpecial [ 1 * ^\n"); switch (i3) { /* 243-254 */ case '0': return (c); case '1': i1 =3D i2 =3D i3 =3D i4 =3D 0; return = (CNTL_F_ONE); case '2': i1 =3D i2 =3D i3 =3D i4 =3D 0; return = (CNTL_F_ONE-1); case '3': i1 =3D i2 =3D i3 =3D i4 =3D 0; return = (CNTL_F_ONE-2); case '4': i1 =3D i2 =3D i3 =3D i4 =3D 0; return = (CNTL_F_ONE-3); case '5': i1 =3D i2 =3D i3 =3D i4 =3D 0; return = (CNTL_F_ONE-4); case '6': return (c); case '7': i1 =3D i2 =3D i3 =3D i4 =3D 0; return = (CNTL_F_ONE-5); case '8': i1 =3D i2 =3D i3 =3D i4 =3D 0; return = (CNTL_F_ONE-6); case '9': i1 =3D i2 =3D i3 =3D i4 =3D 0; return = (CNTL_F_ONE-7); } /* 243-254 */ } /* 240-255 */ } /* 204-256 */ else if (i2 =3D=3D '2') { /* 258-318 */ DPRINT ("\t\t\t\tSpecial [ 2\n"); i3 =3D time_char (); if (i3 =3D=3D 0) return (c); if (i3 =3D=3D TWIDDLE) { /* 263-266 */ i1 =3D i2 =3D i3 =3D 0; return (INSERT); } /* 263-266 */ if (i3 =3D=3D CARROT) { /* 268-272 */ DPRINT ("\t\t\t\tSpecial [ 2 ^\n"); i1 =3D i2 =3D i3 =3D 0; return (CNTL_INSERT); } /* 268-272 */ if (isdigit (i3) =3D=3D 0) return (c); i4 =3D time_char (); if (i4 =3D=3D 0) return (c); if (i4 =3D=3D TWIDDLE) { /* 276-291 */ DPRINT ("\t\t\t\tSpecial [ 2 * ~\n"); switch (i3) { /* 279-290 */ case '0': i1 =3D i2 =3D i3 =3D i4 =3D 0; return = (F_ONE-8); case '1': i1 =3D i2 =3D i3 =3D i4 =3D 0; return (F_TEN); case '2': return (c); case '3': i1 =3D i2 =3D i3 =3D i4 =3D 0; return = (SHIFT_F_ONE); case '4': i1 =3D i2 =3D i3 =3D i4 =3D 0; return = (SHIFT_F_ONE-1); case '5': i1 =3D i2 =3D i3 =3D i4 =3D 0; return = (SHIFT_F_ONE-2); case '6': i1 =3D i2 =3D i3 =3D i4 =3D 0; return = (SHIFT_F_ONE-3); case '7': return (c); case '8': i1 =3D i2 =3D i3 =3D i4 =3D 0; return = (SHIFT_F_ONE-4); case '9': i1 =3D i2 =3D i3 =3D i4 =3D 0; return = (SHIFT_F_ONE-5); } /* 279-290 */ } /* 276-291 */ else if (i4 =3D=3D CARROT) { /* 293-304 */ DPRINT ("\t\t\t\tSpecial [ 2 * ^\n"); switch (i3) { /* 296-303 */ case '0': i1 =3D i2 =3D i3 =3D i4 =3D 0; return = (CNTL_F_ONE-8); case '1': i1 =3D i2 =3D i3 =3D i4 =3D 0; return = (CNTL_F_TEN); case '2': return (c); case '3': i1 =3D i2 =3D i3 =3D i4 =3D 0; return = (CNTL_F_TEN-1); case '4': i1 =3D i2 =3D i3 =3D i4 =3D 0; return = (CNTL_F_TEN-2); default: return (c); } /* 296-303 */ } /* 293-304 */ else if (i4 =3D=3D DOLLAR) { /* 306-317 */ DPRINT ("\t\t\t\tSpecial [ 2 * $\n"); switch (i3) { /* 309-316 */ case '0': return (c); case '1': return (c); case '2': return (c); case '3': i1 =3D i2 =3D i3 =3D i4 =3D 0; return = (SHIFT_F_TEN-1); case '4': i1 =3D i2 =3D i3 =3D i4 =3D 0; return = (SHIFT_F_TEN-2); default: return (c); } /* 309-316 */ } /* 306-317 */ } /* 258-318 */ else if (i2 =3D=3D '3') { /* 320-344 */ DPRINT ("\t\t\t\tSpecial [ 3\n"); i3 =3D time_char (); if (i3 =3D=3D 0) return (c); if (i3 =3D=3D TWIDDLE) { /* 325-328 */ i1 =3D i2 =3D i3 =3D 0; return (DEL); } /* 325-328 */ if (isdigit (i3) =3D=3D 0) return (c); i4 =3D time_char (); if (i4 =3D=3D 0) return (c); if (i4 =3D=3D TWIDDLE) { /* 332-343 */ DPRINT ("\t\t\t\tSpecial [ 3 * ~\n"); switch (i3) { /* 335-342 */ case '0': return (c); case '1': i1 =3D i2 =3D i3 =3D i4 =3D 0; return = (SHIFT_F_ONE-6); case '2': i1 =3D i2 =3D i3 =3D i4 =3D 0; return = (SHIFT_F_ONE-7); case '3': i1 =3D i2 =3D i3 =3D i4 =3D 0; return = (SHIFT_F_ONE-8); case '4': i1 =3D i2 =3D i3 =3D i4 =3D 0; return = (SHIFT_F_TEN); default: return (c); } /* 335-342 */ } /* 332-343 */ } /* 320-344 */ else if (i2 =3D=3D '4') { /* 346-362 */ DPRINT ("\t\t\t\tSpecial [ 4\n"); i3 =3D time_char (); if (i3 =3D=3D 0) return (c); if (i3 =3D=3D TWIDDLE) { /* 351-355 */ DPRINT ("\t\t\t\tSpecial [ 4 ~\n"); i1 =3D i2 =3D i3 =3D 0; return (END); } /* 351-355 */ if (i3 =3D=3D CARROT) { /* 357-361 */ DPRINT ("\t\t\t\tSpecial [ 2 ^\n"); i1 =3D i2 =3D i3 =3D 0; return (CNTL_END); } /* 357-361 */ } /* 346-362 */ else if (i2 =3D=3D '5') { /* 364-380 */ DPRINT ("\t\t\t\tSpecial [ 5\n"); i3 =3D time_char (); if (i3 =3D=3D 0) return (c); if (i3 =3D=3D TWIDDLE) { /* 369-373 */ DPRINT ("\t\t\t\tSpecial [ 5 ~\n"); i1 =3D i2 =3D i3 =3D 0; return (PAGE_UP); } /* 369-373 */ if (i3 =3D=3D CARROT) { /* 375-379 */ DPRINT ("\t\t\t\tSpecial [ 2 ^\n"); i1 =3D i2 =3D i3 =3D 0; return (CNTL_PGUP); } /* 375-379 */ } /* 364-380 */ else if (i2 =3D=3D '6') { /* 382-398 */ DPRINT ("\t\t\t\tSpecial [ 6\n"); i3 =3D time_char (); if (i3 =3D=3D 0) return (c); if (i3 =3D=3D TWIDDLE) { /* 387-391 */ DPRINT ("\t\t\t\tSpecial [ 6 ~\n"); i1 =3D i2 =3D i3 =3D 0; return (PAGE_DOWN); } /* 387-391 */ if (i3 =3D=3D CARROT) { /* 393-397 */ DPRINT ("\t\t\t\tSpecial [ 2 ^\n"); i1 =3D i2 =3D i3 =3D 0; return (CNTL_PGDN); } /* 393-397 */ } /* 382-398 */ } /* 173-399 */ /* Capital O case. */ else if (i1 =3D=3D 'O') { /* 403-483 */ DPRINT ("\t\t\t\tSpecial O\n"); i2 =3D time_char (); if (i2 =3D=3D 0) return (c); if (i2 =3D=3D 'a') { /* 409-412 */ i1 =3D i2 =3D 0; return (CNTL_UP); } /* 409-412 */ if (i2 =3D=3D 'b') { /* 414-417 */ i1 =3D i2 =3D 0; return (CNTL_DOWN); } /* 414-417 */ if (i2 =3D=3D 'c') { /* 419-422 */ i1 =3D i2 =3D 0; return (CNTL_RIGHT); } /* 419-422 */ if (i2 =3D=3D 'd') { /* 424-427 */ i1 =3D i2 =3D 0; return (CNTL_LEFT); } /* 424-427 */ if (i2 =3D=3D 'n') { /* 429-432 */ i1 =3D i2 =3D 0; return (DEL); } /* 429-432 */ if (i2 =3D=3D 'p') { /* 434-437 */ i1 =3D i2 =3D 0; return (INSERT); } /* 434-437 */ if (i2 =3D=3D 'q') { /* 439-442 */ i1 =3D i2 =3D 0; return (END); } /* 439-442 */ if (i2 =3D=3D 'r') { /* 444-447 */ i1 =3D i2 =3D 0; return (DOWN_ARROW); } /* 444-447 */ if (i2 =3D=3D 's') { /* 449-452 */ i1 =3D i2 =3D 0; return (PAGE_DOWN); } /* 449-452 */ if (i2 =3D=3D 't') { /* 454-457 */ i1 =3D i2 =3D 0; return (LEFT_ARROW); } /* 454-457 */ if (i2 =3D=3D 'u') { /* 459-462 */ i1 =3D i2 =3D 0; return (CENTER); } /* 459-462 */ if (i2 =3D=3D 'v') { /* 464-467 */ i1 =3D i2 =3D 0; return (RIGHT_ARROW); } /* 464-467 */ if (i2 =3D=3D 'w') { /* 469-472 */ i1 =3D i2 =3D 0; return (HOME); } /* 469-472 */ if (i2 =3D=3D 'x') { /* 474-477 */ i1 =3D i2 =3D 0; return (UP_ARROW); } /* 474-477 */ if (i2 =3D=3D 'y') { /* 479-482 */ i1 =3D i2 =3D 0; return (PAGE_UP); } /* 479-482 */ } /* 403-483 */ #endif return (c); } /* 136-487 */ /* ***** MAIN0 ***** */ int main () { /* 491-566 */ int c, j; time_t itime, jtime, ktime; clock_t iclock, jclock, kclock; printf ("clocks per second =3D %d\n", CLOCKS_PER_SEC); raw_mode (1); /* open_getchr () was here */ while (1) { /* 501-563 */ c =3D getch (), printf ("The character is "); if (c > 31) printf ("%d (%c).\n", c, c); else if (c >=3D 0) printf ("%d.\n", c); else { /* 506-538 */ if (c =3D=3D HOME) printf ("HOME.\n"); else if (c =3D=3D UP_ARROW) printf ("UP_ARROW.\n"); else if (c =3D=3D PAGE_UP) printf ("PAGE_UP.\n"); else if (c =3D=3D LEFT_ARROW) printf ("LEFT_ARROW.\n"); else if (c =3D=3D RIGHT_ARROW) printf ("RIGHT_ARROW.\n"); else if (c =3D=3D END) printf ("END.\n"); else if (c =3D=3D DOWN_ARROW) printf ("DOWN_ARROW.\n"); else if (c =3D=3D PAGE_DOWN) printf ("PAGE_DOWN.\n"); else if (c =3D=3D INSERT) printf ("INSERT.\n"); else if (c =3D=3D DEL) printf ("DELETE.\n"); else if (c =3D=3D CENTER) printf ("CENTER.\n"); else if (c =3D=3D CNTL_HOME) printf ("CNTL_HOME.\n"); else if (c =3D=3D CNTL_END) printf ("CNTL_END.\n"); else if (c =3D=3D CNTL_PGUP) printf ("CNTL_PAGE_UP.\n"); else if (c =3D=3D CNTL_PGDN) printf ("CNTL_PAGE_DOWN.\n"); else if (c =3D=3D CNTL_UP) printf ("CNTL_UP.\n"); else if (c =3D=3D CNTL_DOWN) printf ("CNTL_DOWN.\n"); else if (c =3D=3D CNTL_LEFT) printf ("CNTL_LEFT.\n"); else if (c =3D=3D CNTL_RIGHT) printf ("CNTL_RIGHT.\n"); else if (c =3D=3D CNTL_INSERT) printf ("CNTL_INSERT.\n"); else if (c =3D=3D CNTL_CENTER) printf ("CNTL_CENTER.\n"); else if (c <=3D F_ONE && c >=3D F_TEN) printf ("Function Key %d\n", F_ONE+1-c); else if (c <=3D SHIFT_F_ONE && c >=3D SHIFT_F_TEN-2) printf ("Shift Fcn Key %d\n", SHIFT_F_ONE+1-c); else if (c <=3D CNTL_F_ONE && c >=3D CNTL_F_TEN-2) printf ("Ctrl Fcn Key %d\n", CNTL_F_ONE+1-c); else printf ("unknown.\n"); } /* 506-538 */ if (c =3D=3D 'k') { /* 540-561 */ itime =3D time (NULL), iclock =3D clock (); printf ("Waiting . . ."), fflush (stdout); for (c =3D 1; c <=3D 100000; c++) { /* 544-547 */ j =3D kbhit (); if (j) break; } /* 544-547 */ printf ("\n"); jtime =3D time (NULL), jclock =3D clock ();; printf ("Waiting . . ."), fflush (stdout); for (c =3D 1; c <=3D 100000; c++) { /* 552-556 */ j =3D kbhit (); j =3D kbhit (); if (j) break; } /* 552-556 */ ktime =3D time (NULL), kclock =3D clock (); printf ("%d %d\n", jtime-itime, ktime-jtime); printf ("%g %g\n", (double) (jclock-iclock)/CLOCKS_PER_SEC, (double) (kclock-jclock)/CLOCKS_PER_SEC); } /* 540-561 */ if (c =3D=3D 'q') break; } /* 501-563 */ raw_mode (0); return (0); } /* 491-566 */ ------_=_NextPart_000_01BFF1D1.F6950DC0 Content-Type: application/octet-stream; name="G2_TERM.H" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="G2_TERM.H" /* ***** G2_TERM.H ***** */=0A= #ifndef G2_TERM=0A= #define G2_TERM=0A= =0A= #define DOLLAR ('$')=0A= #define TWIDDLE ('~')=0A= #define CARROT ('^')=0A= =0A= #define HOME (-71)=0A= #define UP_ARROW (-72)=0A= #define PAGE_UP (-73)=0A= #define LEFT_ARROW (-75)=0A= #define RIGHT_ARROW (-77)=0A= #define END (-79)=0A= #define DOWN_ARROW (-80)=0A= #define PAGE_DOWN (-81)=0A= #define INSERT (-82)=0A= #define DEL (-83)=0A= #define CENTER (-76)=0A= =0A= #define F_ONE (-59)=0A= #define F_TEN (-68)=0A= =0A= #define SHIFT_F_ONE (-84)=0A= #define SHIFT_F_TEN (-93)=0A= =0A= #define CNTL_LEFT (-115)=0A= #define CNTL_RIGHT (-116)=0A= =0A= #define CNTL_UP (-141)=0A= #define CNTL_DOWN (-145)=0A= =0A= #define CNTL_HOME (-119)=0A= #define CNTL_END (-117)=0A= =0A= #define CNTL_PGUP (-132)=0A= #define CNTL_PGDN (-118)=0A= =0A= #define CNTL_INSERT (-146)=0A= #define CNTL_CENTER (-143)=0A= =0A= #define CNTL_F_ONE (-201)=0A= #define CNTL_F_TEN (-210)=0A= =0A= #ifndef ESCAPE=0A= #define ESCAPE (27)=0A= #endif=0A= #endif=0A= ------_=_NextPart_000_01BFF1D1.F6950DC0 Content-Type: application/octet-stream; name="G2_TERM.C" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="G2_TERM.C" #include =0A= #include =0A= #include =0A= #include =0A= =0A= #if 1=0A= #define DPRINT(x)=0A= #define DPRIN2(x,y)=0A= #define DPRIN3(x,y,z)=0A= #else=0A= #define DPRINT(x) fprintf (stderr, x)=0A= #define DPRIN2(x,y) fprintf (stderr, x, y)=0A= #define DPRIN3(x,y,z) fprintf (stderr, x, y, z)=0A= #endif=0A= =0A= #include "g2_term.h"=0A= =0A= static int i1 =3D 0;=0A= static int i2 =3D 0;=0A= static int i3 =3D 0;=0A= static int i4 =3D 0;=0A= =0A= int erase_char, kill_char, werase_char;=0A= =0A= /* ***** RAW_MODE ***** */=0A= void raw_mode (int on)=0A= { /* 27-73 */=0A= static int curr_on =3D 0;=0A= struct termios s;=0A= static struct termios save_term;=0A= =0A= if (on =3D=3D curr_on) return;=0A= =0A= if (on)=0A= { /* 35-65 */=0A= tcgetattr(2, &s);=0A= =0A= save_term =3D s;=0A= =0A= erase_char =3D s.c_cc[2];=0A= kill_char =3D s.c_cc[3];=0A= werase_char =3D s.c_cc[14];=0A= =0A= s.c_lflag &=3D ~(0=0A= | 0000002=0A= | 0000010=0A= | 0000020=0A= | 0000040=0A= | 0000100=0A= );=0A= s.c_oflag |=3D (0=0A= | 0014000=0A= | 0000001=0A= | 0000004=0A= );=0A= s.c_oflag &=3D ~(0=0A= | 0000010=0A= | 0000020=0A= | 0000040=0A= );=0A= s.c_cc[6 ] =3D 1;=0A= s.c_cc[5 ] =3D 0;=0A= s.c_cc[15 ] =3D 0;=0A= =0A= } /* 35-65 */=0A= else=0A= s =3D save_term;=0A= =0A= tcsetattr (2, 1 , &s);=0A= =0A= curr_on =3D on;=0A= return;=0A= } /* 27-73 */=0A= =0A= static jmp_buf read_label;=0A= int reading;=0A= =0A= /* ***** IREAD ***** */=0A= int iread (int fd, char *buf, unsigned int len)=0A= { /* 80-96 */=0A= register int n;=0A= =0A= if (__sigsetjmp ((read_label ), 0))=0A= { /* 84-88 */=0A= reading =3D 0;=0A= sigsetmask (0);=0A= return (-2);=0A= } /* 84-88 */=0A= =0A= /* flush () was here */=0A= reading =3D 1;=0A= n =3D read (fd, buf, len);=0A= reading =3D 0;=0A= if (n < 0) return (-1);=0A= return (n);=0A= } /* 80-96 */=0A= =0A= static int tty;=0A= =0A= /* ***** OPEN_GETCHR ***** */=0A= void open_getchr (void)=0A= { /* 102-106 */=0A= tty =3D open ("/dev/tty", 0) ;=0A= if (tty < 0) tty =3D 2;=0A= return;=0A= } /* 102-106 */=0A= =0A= /* ***** CLOSE_GETCHR ***** */=0A= void close_getchr (void)=0A= { /* 110-112 */=0A= return;=0A= } /* 110-112 */=0A= =0A= /* ***** GETCHR ***** */=0A= int getchr (void)=0A= { /* 116-130 */=0A= char c;=0A= int result;=0A= /* CTEST_IGNORE E160 */=0A= do=0A= { /* 121-126 */=0A= result =3D iread (tty, &c, sizeof (char));=0A= if (result =3D=3D (-2)) return (-2);=0A= if (result < 0) return (0);=0A= if (c =3D=3D '\0') c =3D '\340';=0A= } /* 121-126 */=0A= while (result !=3D 1);=0A= =0A= return (c & 0377);=0A= } /* 116-130 */=0A= =0A= /* ***** KBHIT ***** */=0A= int kbhit (void)=0A= { /* 134-146 */=0A= fd_set rfds;=0A= struct timeval tv;=0A= =0A= if (i1 !=3D 0) return (1);=0A= =0A= FD_ZERO (&rfds);=0A= FD_SET (0, &rfds);=0A= tv.tv_sec =3D 0;=0A= tv.tv_usec =3D 0;=0A= if (select (1, &rfds, NULL, NULL, &tv)) return (1);=0A= return (0);=0A= } /* 134-146 */=0A= =0A= /* ***** TIME_CHAR ***** */=0A= int time_char (void)=0A= { /* 150-168 */=0A= int j;=0A= clock_t iclock, jclock;=0A= =0A= iclock =3D jclock =3D clock ();=0A= while (jclock-iclock < CLOCKS_PER_SEC/2)=0A= { /* 156-160 */=0A= j =3D kbhit ();=0A= if (j) break;=0A= jclock =3D clock ();=0A= } /* 156-160 */=0A= if (j =3D=3D 0) DPRINT ("\t\t\t\t\tTime out.\n");=0A= if (j =3D=3D 0) return (0);=0A= =0A= j =3D getchr ();=0A= if (j > 31) DPRIN3 ("\t\t\t\t\tchar is %d (%c).\n", j, j);=0A= else DPRIN2 ("\t\t\t\t\tchar is %d.\n", j);=0A= return (j);=0A= } /* 150-168 */=0A= =0A= /* **** GETCH ***** */=0A= int getch (void)=0A= { /* 172-518 */=0A= int c, j;=0A= if (i1 !=3D 0)=0A= { /* 175-179 */=0A= c =3D i1, i1 =3D i2, i2 =3D i3, i3 =3D i4, i4 =3D 0;=0A= DPRINT ("\t\t\t\tNextchar.\n");=0A= return (c);=0A= } /* 175-179 */=0A= =0A= c =3D getchr ();=0A= =0A= if (c !=3D ESCAPE) return (c);=0A= =0A= DPRINT ("\t\t\t\tEscape\n");=0A= =0A= /* Okay, here's the deal. If the character is an */=0A= /* ESCAPE character (27), then it *could* be the */=0A= /* start of an arrow-key sequence and should be */=0A= /* processed as such. On the other hand, since it */=0A= /* could also be a naked ESCAPE, we're going to */=0A= /* wait a half second for another character. */=0A= =0A= /* If the other character comes along and it is not */=0A= /* a special character ([ or O), then we keep it */=0A= /* here and send it immediately the next time */=0A= /* this function is called. */=0A= =0A= i1 =3D time_char (); if (i1 =3D=3D 0) return (c);=0A= =0A= DPRINT ("\t\t\t\tKbhit\n");=0A= =0A= /* Left bracket case. */=0A= if (i1 =3D=3D '[')=0A= { /* 205-431 */=0A= DPRINT ("\t\t\t\tSpecial [\n");=0A= =0A= i2 =3D time_char (); if (i2 =3D=3D 0) return (c);=0A= =0A= if (i2 =3D=3D 'A')=0A= { /* 211-214 */=0A= i1 =3D i2 =3D 0;=0A= return (UP_ARROW);=0A= } /* 211-214 */=0A= if (i2 =3D=3D 'B')=0A= { /* 216-219 */=0A= i1 =3D i2 =3D 0;=0A= return (DOWN_ARROW);=0A= } /* 216-219 */=0A= if (i2 =3D=3D 'C')=0A= { /* 221-224 */=0A= i1 =3D i2 =3D 0;=0A= return (RIGHT_ARROW);=0A= } /* 221-224 */=0A= if (i2 =3D=3D 'D')=0A= { /* 226-229 */=0A= i1 =3D i2 =3D 0;=0A= return (LEFT_ARROW);=0A= } /* 226-229 */=0A= if (i2 =3D=3D 'G')=0A= { /* 231-234 */=0A= i1 =3D i2 =3D 0;=0A= return (CENTER);=0A= } /* 231-234 */=0A= if (i2 =3D=3D '1')=0A= { /* 236-288 */=0A= DPRINT ("\t\t\t\tSpecial [ 1\n");=0A= =0A= i3 =3D time_char (); if (i3 =3D=3D 0) return (c);=0A= if (i3 =3D=3D TWIDDLE)=0A= { /* 241-245 */=0A= DPRINT ("\t\t\t\tSpecial [ 1 ~\n");=0A= i1 =3D i2 =3D i3 =3D 0;=0A= return (HOME);=0A= } /* 241-245 */=0A= if (i3 =3D=3D CARROT)=0A= { /* 247-251 */=0A= DPRINT ("\t\t\t\tSpecial [ 1 ^\n");=0A= i1 =3D i2 =3D i3 =3D 0;=0A= return (CNTL_HOME);=0A= } /* 247-251 */=0A= if (isdigit (i3) =3D=3D 0) return (c);=0A= i4 =3D time_char (); if (i4 =3D=3D 0) return (c);=0A= if (i4 =3D=3D TWIDDLE)=0A= { /* 255-270 */=0A= DPRINT ("\t\t\t\tSpecial [ 1 * ~\n");=0A= switch (i3)=0A= { /* 258-269 */=0A= case '0': return (c);=0A= case '1': i1 =3D i2 =3D i3 =3D i4 =3D 0; return (F_ONE);=0A= case '2': i1 =3D i2 =3D i3 =3D i4 =3D 0; return = (F_ONE-1);=0A= case '3': i1 =3D i2 =3D i3 =3D i4 =3D 0; return = (F_ONE-2);=0A= case '4': i1 =3D i2 =3D i3 =3D i4 =3D 0; return = (F_ONE-3);=0A= case '5': i1 =3D i2 =3D i3 =3D i4 =3D 0; return = (F_ONE-4);=0A= case '6': return (c);=0A= case '7': i1 =3D i2 =3D i3 =3D i4 =3D 0; return = (F_ONE-5);=0A= case '8': i1 =3D i2 =3D i3 =3D i4 =3D 0; return = (F_ONE-6);=0A= case '9': i1 =3D i2 =3D i3 =3D i4 =3D 0; return = (F_ONE-7);=0A= } /* 258-269 */=0A= } /* 255-270 */=0A= else if (i4 =3D=3D CARROT)=0A= { /* 272-287 */=0A= DPRINT ("\t\t\t\tSpecial [ 1 * ^\n");=0A= switch (i3)=0A= { /* 275-286 */=0A= case '0': return (c);=0A= case '1': i1 =3D i2 =3D i3 =3D i4 =3D 0; return = (CNTL_F_ONE);=0A= case '2': i1 =3D i2 =3D i3 =3D i4 =3D 0; return = (CNTL_F_ONE-1);=0A= case '3': i1 =3D i2 =3D i3 =3D i4 =3D 0; return = (CNTL_F_ONE-2);=0A= case '4': i1 =3D i2 =3D i3 =3D i4 =3D 0; return = (CNTL_F_ONE-3);=0A= case '5': i1 =3D i2 =3D i3 =3D i4 =3D 0; return = (CNTL_F_ONE-4);=0A= case '6': return (c);=0A= case '7': i1 =3D i2 =3D i3 =3D i4 =3D 0; return = (CNTL_F_ONE-5);=0A= case '8': i1 =3D i2 =3D i3 =3D i4 =3D 0; return = (CNTL_F_ONE-6);=0A= case '9': i1 =3D i2 =3D i3 =3D i4 =3D 0; return = (CNTL_F_ONE-7);=0A= } /* 275-286 */=0A= } /* 272-287 */=0A= } /* 236-288 */=0A= else if (i2 =3D=3D '2')=0A= { /* 290-350 */=0A= DPRINT ("\t\t\t\tSpecial [ 2\n");=0A= =0A= i3 =3D time_char (); if (i3 =3D=3D 0) return (c);=0A= if (i3 =3D=3D TWIDDLE)=0A= { /* 295-298 */=0A= i1 =3D i2 =3D i3 =3D 0;=0A= return (INSERT);=0A= } /* 295-298 */=0A= if (i3 =3D=3D CARROT)=0A= { /* 300-304 */=0A= DPRINT ("\t\t\t\tSpecial [ 2 ^\n");=0A= i1 =3D i2 =3D i3 =3D 0;=0A= return (CNTL_INSERT);=0A= } /* 300-304 */=0A= if (isdigit (i3) =3D=3D 0) return (c);=0A= i4 =3D time_char (); if (i4 =3D=3D 0) return (c);=0A= if (i4 =3D=3D TWIDDLE)=0A= { /* 308-323 */=0A= DPRINT ("\t\t\t\tSpecial [ 2 * ~\n");=0A= switch (i3)=0A= { /* 311-322 */=0A= case '0': i1 =3D i2 =3D i3 =3D i4 =3D 0; return = (F_ONE-8);=0A= case '1': i1 =3D i2 =3D i3 =3D i4 =3D 0; return (F_TEN);=0A= case '2': return (c);=0A= case '3': i1 =3D i2 =3D i3 =3D i4 =3D 0; return = (SHIFT_F_ONE);=0A= case '4': i1 =3D i2 =3D i3 =3D i4 =3D 0; return = (SHIFT_F_ONE-1);=0A= case '5': i1 =3D i2 =3D i3 =3D i4 =3D 0; return = (SHIFT_F_ONE-2);=0A= case '6': i1 =3D i2 =3D i3 =3D i4 =3D 0; return = (SHIFT_F_ONE-3);=0A= case '7': return (c);=0A= case '8': i1 =3D i2 =3D i3 =3D i4 =3D 0; return = (SHIFT_F_ONE-4);=0A= case '9': i1 =3D i2 =3D i3 =3D i4 =3D 0; return = (SHIFT_F_ONE-5);=0A= } /* 311-322 */=0A= } /* 308-323 */=0A= else if (i4 =3D=3D CARROT)=0A= { /* 325-336 */=0A= DPRINT ("\t\t\t\tSpecial [ 2 * ^\n");=0A= switch (i3)=0A= { /* 328-335 */=0A= case '0': i1 =3D i2 =3D i3 =3D i4 =3D 0; return = (CNTL_F_ONE-8);=0A= case '1': i1 =3D i2 =3D i3 =3D i4 =3D 0; return = (CNTL_F_TEN);=0A= case '2': return (c);=0A= case '3': i1 =3D i2 =3D i3 =3D i4 =3D 0; return = (CNTL_F_TEN-1);=0A= case '4': i1 =3D i2 =3D i3 =3D i4 =3D 0; return = (CNTL_F_TEN-2);=0A= default: return (c);=0A= } /* 328-335 */=0A= } /* 325-336 */=0A= else if (i4 =3D=3D DOLLAR)=0A= { /* 338-349 */=0A= DPRINT ("\t\t\t\tSpecial [ 2 * $\n");=0A= switch (i3)=0A= { /* 341-348 */=0A= case '0': return (c);=0A= case '1': return (c);=0A= case '2': return (c);=0A= case '3': i1 =3D i2 =3D i3 =3D i4 =3D 0; return = (SHIFT_F_TEN-1);=0A= case '4': i1 =3D i2 =3D i3 =3D i4 =3D 0; return = (SHIFT_F_TEN-2);=0A= default: return (c);=0A= } /* 341-348 */=0A= } /* 338-349 */=0A= } /* 290-350 */=0A= else if (i2 =3D=3D '3')=0A= { /* 352-376 */=0A= DPRINT ("\t\t\t\tSpecial [ 3\n");=0A= =0A= i3 =3D time_char (); if (i3 =3D=3D 0) return (c);=0A= if (i3 =3D=3D TWIDDLE)=0A= { /* 357-360 */=0A= i1 =3D i2 =3D i3 =3D 0;=0A= return (DEL);=0A= } /* 357-360 */=0A= if (isdigit (i3) =3D=3D 0) return (c);=0A= i4 =3D time_char (); if (i4 =3D=3D 0) return (c);=0A= if (i4 =3D=3D TWIDDLE)=0A= { /* 364-375 */=0A= DPRINT ("\t\t\t\tSpecial [ 3 * ~\n");=0A= switch (i3)=0A= { /* 367-374 */=0A= case '0': return (c);=0A= case '1': i1 =3D i2 =3D i3 =3D i4 =3D 0; return = (SHIFT_F_ONE-6);=0A= case '2': i1 =3D i2 =3D i3 =3D i4 =3D 0; return = (SHIFT_F_ONE-7);=0A= case '3': i1 =3D i2 =3D i3 =3D i4 =3D 0; return = (SHIFT_F_ONE-8);=0A= case '4': i1 =3D i2 =3D i3 =3D i4 =3D 0; return = (SHIFT_F_TEN);=0A= default: return (c);=0A= } /* 367-374 */=0A= } /* 364-375 */=0A= } /* 352-376 */=0A= else if (i2 =3D=3D '4')=0A= { /* 378-394 */=0A= DPRINT ("\t\t\t\tSpecial [ 4\n");=0A= =0A= i3 =3D time_char (); if (i3 =3D=3D 0) return (c);=0A= if (i3 =3D=3D TWIDDLE)=0A= { /* 383-387 */=0A= DPRINT ("\t\t\t\tSpecial [ 4 ~\n");=0A= i1 =3D i2 =3D i3 =3D 0;=0A= return (END);=0A= } /* 383-387 */=0A= if (i3 =3D=3D CARROT)=0A= { /* 389-393 */=0A= DPRINT ("\t\t\t\tSpecial [ 2 ^\n");=0A= i1 =3D i2 =3D i3 =3D 0;=0A= return (CNTL_END);=0A= } /* 389-393 */=0A= } /* 378-394 */=0A= else if (i2 =3D=3D '5')=0A= { /* 396-412 */=0A= DPRINT ("\t\t\t\tSpecial [ 5\n");=0A= =0A= i3 =3D time_char (); if (i3 =3D=3D 0) return (c);=0A= if (i3 =3D=3D TWIDDLE)=0A= { /* 401-405 */=0A= DPRINT ("\t\t\t\tSpecial [ 5 ~\n");=0A= i1 =3D i2 =3D i3 =3D 0;=0A= return (PAGE_UP);=0A= } /* 401-405 */=0A= if (i3 =3D=3D CARROT)=0A= { /* 407-411 */=0A= DPRINT ("\t\t\t\tSpecial [ 2 ^\n");=0A= i1 =3D i2 =3D i3 =3D 0;=0A= return (CNTL_PGUP);=0A= } /* 407-411 */=0A= } /* 396-412 */=0A= else if (i2 =3D=3D '6')=0A= { /* 414-430 */=0A= DPRINT ("\t\t\t\tSpecial [ 6\n");=0A= =0A= i3 =3D time_char (); if (i3 =3D=3D 0) return (c);=0A= if (i3 =3D=3D TWIDDLE)=0A= { /* 419-423 */=0A= DPRINT ("\t\t\t\tSpecial [ 6 ~\n");=0A= i1 =3D i2 =3D i3 =3D 0;=0A= return (PAGE_DOWN);=0A= } /* 419-423 */=0A= if (i3 =3D=3D CARROT)=0A= { /* 425-429 */=0A= DPRINT ("\t\t\t\tSpecial [ 2 ^\n");=0A= i1 =3D i2 =3D i3 =3D 0;=0A= return (CNTL_PGDN);=0A= } /* 425-429 */=0A= } /* 414-430 */=0A= } /* 205-431 */=0A= =0A= /* Capital O case. */=0A= else if (i1 =3D=3D 'O')=0A= { /* 435-515 */=0A= DPRINT ("\t\t\t\tSpecial O\n");=0A= =0A= i2 =3D time_char (); if (i2 =3D=3D 0) return (c);=0A= =0A= if (i2 =3D=3D 'a')=0A= { /* 441-444 */=0A= i1 =3D i2 =3D 0;=0A= return (CNTL_UP);=0A= } /* 441-444 */=0A= if (i2 =3D=3D 'b')=0A= { /* 446-449 */=0A= i1 =3D i2 =3D 0;=0A= return (CNTL_DOWN);=0A= } /* 446-449 */=0A= if (i2 =3D=3D 'c')=0A= { /* 451-454 */=0A= i1 =3D i2 =3D 0;=0A= return (CNTL_RIGHT);=0A= } /* 451-454 */=0A= if (i2 =3D=3D 'd')=0A= { /* 456-459 */=0A= i1 =3D i2 =3D 0;=0A= return (CNTL_LEFT);=0A= } /* 456-459 */=0A= if (i2 =3D=3D 'n')=0A= { /* 461-464 */=0A= i1 =3D i2 =3D 0;=0A= return (DEL);=0A= } /* 461-464 */=0A= if (i2 =3D=3D 'p')=0A= { /* 466-469 */=0A= i1 =3D i2 =3D 0;=0A= return (INSERT);=0A= } /* 466-469 */=0A= if (i2 =3D=3D 'q')=0A= { /* 471-474 */=0A= i1 =3D i2 =3D 0;=0A= return (END);=0A= } /* 471-474 */=0A= if (i2 =3D=3D 'r')=0A= { /* 476-479 */=0A= i1 =3D i2 =3D 0;=0A= return (DOWN_ARROW);=0A= } /* 476-479 */=0A= if (i2 =3D=3D 's')=0A= { /* 481-484 */=0A= i1 =3D i2 =3D 0;=0A= return (PAGE_DOWN);=0A= } /* 481-484 */=0A= if (i2 =3D=3D 't')=0A= { /* 486-489 */=0A= i1 =3D i2 =3D 0;=0A= return (LEFT_ARROW);=0A= } /* 486-489 */=0A= if (i2 =3D=3D 'u')=0A= { /* 491-494 */=0A= i1 =3D i2 =3D 0;=0A= return (CENTER);=0A= } /* 491-494 */=0A= if (i2 =3D=3D 'v')=0A= { /* 496-499 */=0A= i1 =3D i2 =3D 0;=0A= return (RIGHT_ARROW);=0A= } /* 496-499 */=0A= if (i2 =3D=3D 'w')=0A= { /* 501-504 */=0A= i1 =3D i2 =3D 0;=0A= return (HOME);=0A= } /* 501-504 */=0A= if (i2 =3D=3D 'x')=0A= { /* 506-509 */=0A= i1 =3D i2 =3D 0;=0A= return (UP_ARROW);=0A= } /* 506-509 */=0A= if (i2 =3D=3D 'y')=0A= { /* 511-514 */=0A= i1 =3D i2 =3D 0;=0A= return (PAGE_UP);=0A= } /* 511-514 */=0A= } /* 435-515 */=0A= =0A= return (c);=0A= } /* 172-518 */=0A= =0A= /* ***** MAIN ***** */=0A= int main ()=0A= { /* 522-597 */=0A= int c, j;=0A= time_t itime, jtime, ktime;=0A= clock_t iclock, jclock, kclock;=0A= =0A= printf ("clocks per second =3D %d\n", CLOCKS_PER_SEC);=0A= =0A= raw_mode (1);=0A= /* open_getchr () was here */=0A= while (1)=0A= { /* 532-594 */=0A= c =3D getch (), printf ("The character is ");=0A= if (c > 31) printf ("%d (%c).\n", c, c);=0A= else if (c >=3D 0) printf ("%d.\n", c);=0A= else=0A= { /* 537-569 */=0A= if (c =3D=3D HOME) printf ("HOME.\n");=0A= else if (c =3D=3D UP_ARROW) printf ("UP_ARROW.\n");=0A= else if (c =3D=3D PAGE_UP) printf ("PAGE_UP.\n");=0A= else if (c =3D=3D LEFT_ARROW) printf ("LEFT_ARROW.\n");=0A= else if (c =3D=3D RIGHT_ARROW) printf ("RIGHT_ARROW.\n");=0A= else if (c =3D=3D END) printf ("END.\n");=0A= else if (c =3D=3D DOWN_ARROW) printf ("DOWN_ARROW.\n");=0A= else if (c =3D=3D PAGE_DOWN) printf ("PAGE_DOWN.\n");=0A= else if (c =3D=3D INSERT) printf ("INSERT.\n");=0A= else if (c =3D=3D DEL) printf ("DELETE.\n");=0A= else if (c =3D=3D CENTER) printf ("CENTER.\n");=0A= =0A= else if (c =3D=3D CNTL_HOME) printf ("CNTL_HOME.\n");=0A= else if (c =3D=3D CNTL_END) printf ("CNTL_END.\n");=0A= else if (c =3D=3D CNTL_PGUP) printf ("CNTL_PAGE_UP.\n");=0A= else if (c =3D=3D CNTL_PGDN) printf ("CNTL_PAGE_DOWN.\n");=0A= else if (c =3D=3D CNTL_UP) printf ("CNTL_UP.\n");=0A= else if (c =3D=3D CNTL_DOWN) printf ("CNTL_DOWN.\n");=0A= else if (c =3D=3D CNTL_LEFT) printf ("CNTL_LEFT.\n");=0A= else if (c =3D=3D CNTL_RIGHT) printf ("CNTL_RIGHT.\n");=0A= else if (c =3D=3D CNTL_INSERT) printf ("CNTL_INSERT.\n");=0A= else if (c =3D=3D CNTL_CENTER) printf ("CNTL_CENTER.\n");=0A= =0A= else if (c <=3D F_ONE && c >=3D F_TEN)=0A= printf ("Function Key %d\n", F_ONE+1-c);=0A= else if (c <=3D SHIFT_F_ONE && c >=3D SHIFT_F_TEN-2)=0A= printf ("Shift Fcn Key %d\n", SHIFT_F_ONE+1-c);=0A= else if (c <=3D CNTL_F_ONE && c >=3D CNTL_F_TEN-2)=0A= printf ("Ctrl Fcn Key %d\n", CNTL_F_ONE+1-c);=0A= else=0A= printf ("unknown.\n");=0A= } /* 537-569 */=0A= if (c =3D=3D 'k')=0A= { /* 571-592 */=0A= itime =3D time (NULL), iclock =3D clock ();=0A= printf ("Waiting . . ."), fflush (stdout);=0A= for (c =3D 1; c <=3D 100000; c++)=0A= { /* 575-578 */=0A= j =3D kbhit ();=0A= if (j) break;=0A= } /* 575-578 */=0A= printf ("\n");=0A= jtime =3D time (NULL), jclock =3D clock ();;=0A= printf ("Waiting . . ."), fflush (stdout);=0A= for (c =3D 1; c <=3D 100000; c++)=0A= { /* 583-587 */=0A= j =3D kbhit ();=0A= j =3D kbhit ();=0A= if (j) break;=0A= } /* 583-587 */=0A= ktime =3D time (NULL), kclock =3D clock ();=0A= printf ("%d %d\n", jtime-itime, ktime-jtime);=0A= printf ("%g %g\n", (double) (jclock-iclock)/CLOCKS_PER_SEC,=0A= (double) (kclock-jclock)/CLOCKS_PER_SEC);=0A= } /* 571-592 */=0A= if (c =3D=3D 'q') break;=0A= } /* 532-594 */=0A= raw_mode (0);=0A= return (0);=0A= } /* 522-597 */=0A= ------_=_NextPart_000_01BFF1D1.F6950DC0 Content-Type: text/plain; charset=us-ascii -- Want to unsubscribe from this list? Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com ------_=_NextPart_000_01BFF1D1.F6950DC0--