delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2000/07/19/18:11:34

Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT sources DOT redhat DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT sources DOT redhat DOT com>
List-Help: <mailto:cygwin-help AT sources DOT redhat DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT sources DOT redhat DOT com
Delivered-To: mailing list cygwin AT sources DOT redhat DOT com
Message-ID: <61F573D3AC04D311956000A0CC2691C2072614@ENTERPRISE>
From: Adam Rosenberg <adam DOT rosenberg AT sourceprose DOT com>
To: "'cygwin AT sourceware DOT cygnus DOT com'" <cygwin AT sourceware DOT cygnus DOT com>
Cc: "'adam AT psionic DOT mn DOT org'" <adam AT psionic DOT mn DOT org>
Subject: KBHIT and GETCH
Date: Wed, 19 Jul 2000 17:12:53 -0500
MIME-Version: 1.0
X-Mailer: Internet Mail Service (5.5.2448.0)

------_=_NextPart_000_01BFF1CE.7C27D1A0
Content-Type: text/plain;
	charset="iso-8859-1"

    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_01BFF1CE.7C27D1A0
Content-Type: application/octet-stream;
	name="g2_cyg.c"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="g2_cyg.c"

#include <setjmp.h>
#include <stdio.h>
#include <termios.h>
#include <sys/time.h>

#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 (&current_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, &current_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_01BFF1CE.7C27D1A0
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_01BFF1CE.7C27D1A0
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_01BFF1CE.7C27D1A0--

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019