From:	CSBVAX::MRGATE!RELAY-INFO-VAX@CRVAX.SRI.COM@SMTP  3-NOV-1988 02:16
To:	ARISIA::EVERHART
Subj:	re: raw and/or cbreak mode


Received: From KL.SRI.COM by CRVAX.SRI.COM with TCP; Wed,  2 NOV 88 21:51:38 PDT
Received: from CUNYVM.CUNY.EDU by KL.SRI.COM with TCP; Wed, 2 Nov 88 21:33:02 PST
Received: from VAXF.COLORADO.EDU by CUNYVM.CUNY.EDU (IBM VM SMTP R1.1) with BSMTP id 9669; Thu, 03 Nov 88 00:21:07 EST
Date: Wed, 2 Nov 88 11:31 MDT
From: Pete Klammer 303/556-3915 <PKLAMMER%CUDNVR%VAXF.COLORADO.EDU@CUNYVM.CUNY.EDU>
Subject: re: raw and/or cbreak mode
To: sun.soe.clarkson.edu!gary@tgould.tn.CORNELL.EDU, INFO-VAX@KL.SRI.COM
X-VMS-To:
 IN::"sun.soe.clarkson.edu!gary@tgould.tn.cornell.edu",INFO-VAX,PKLAMMER

I think what you want, or the basis of it anyway, is the ability to read
a keystroke as it arrives, and to be able to make your own decisions about
echoing, waking up the caller, etc.  The following GETCH.C is with the help
of my buddy Ray Cadmus of Computerized Business Systems in Moberly, MO.
================================================================
/*      getch function - read 1 character without echo */

#include <descrip.h>
#include <stdio.h>
#include <ctype.h>
#include <iodef.h>
#include <ttdef.h>
#include <tt2def.h>

char    hc;     /* global hold character for ungetc */

struct  {       /* terminal mode buffers */
        int     page_width;
        int     basic_term;
        int     ext_term;
} modebuf, savemode;
int     getch_chan = 0;

getch()
{
static  $DESCRIPTOR(tname,"SYS$INPUT");

char    c;
int     stat;
int     sys$qiow();

        if (!getch_chan) {      /* if no channel - get one */
                stat = sys$assign(&tname,&getch_chan,0,0);      /* get channel f
or sys$input */
                stat = sys$qiow(0,getch_chan,IO$_SENSEMODE,0,0,0,&modebuf,12,0,0
,0,0);

                /* save original terminal mode */
                savemode = modebuf;

                /* set nowrap - kp = numeric - no edit on terminal */
                modebuf.basic_term = modebuf.basic_term & ~TT$M_WRAP;
                modebuf.ext_term = modebuf.ext_term & ~TT2$M_APP_KEYPAD;
                stat = sys$qiow(0,getch_chan,IO$_SETMODE,0,0,0,&modebuf,12,0,0,0
,0);
                printf("\033>"); /* set off application keypad mode */
                printf("\033[?1l"); /* reset cursor key mode */
        }

        if (hc) {       /* if had an ungot char - use it */
                c=hc;
                hc=0;
                return c;
        }

        stat = sys$qiow(
                0,
                getch_chan,
                IO$_READVBLK | IO$M_NOECHO | IO$M_NOFILTR,
                0,0,0,&c,1,0,0,0,0);
        if (c == EOF) {
                exit();
        }
        return c;
}

/***/
================================================================
/**
 * --poko       Pete Klammer, Systems Programmer, (303)556-3915
 *              CU-Denver Computing Services / Campus Box 169
 *              1200 Larimer St NC2506 / Denver CO 80204-5300
 *              BITNET%"PKLAMMER@CUDENVER"
 *              INTERNET%"PKLAMMER%CUDNVR@VAXF.COLORADO.EDU"
****************************************************************
Jeremy's fine!  Worth his weight in gold for flame deflection! ;-)
****************************************************************
**/

