character input on the VAX
revans at voodoo.ucsb.edu
revans at voodoo.ucsb.edu
Fri Feb 23 05:09:37 AEST 1990
-Message-Text-Follows-
In article <2176 at rodan.acs.syr.edu>, tpschar at rodan.acs.syr.edu (Thomas Pschar) writes...
>Hi. I need to write a kind of editor in C on the VAX. Since it is to be
>a fullscreen editor, I need to grab one character at a time as it is typed
>without waiting for a carriage return. Does anyone know of a (relatively)
>painless way to do this?
Short answer : No
Long answer : We met this problem a few months ago, whilst porting some
RT-11 applications written in DECUS C to VMS. This was the best solution
we came up with ... enjoy!
Russ Evans e_gs18 at va.nmh.ac.uk / j.r.evans at edinburgh.ac.uk
British Geological Survey, West Mains Road, Edinburgh EH9 3LA UK
/***************************************************************************/
/*
* Author Phil Wild
* Date 24 July 1989
* Function macro definitions etc. particularly overridding those
* DECUS_C ones that are not VAX C
* Modified Russ Evans 6 Nov 1989
* EOS & min definitions moved to vt.c
* becomes vtvms.c as independent module
* Did not appear to work .. added SYS$ASSIGN code !
* Fixed kbinr to work as in RT-11 implementation
* Copyright Edinburgh Anisotropy Project,
* British Geological Survey, Edinburgh, UK
*/
/***************************************************************************/
#include <iodef>
#include <ssdef>
#include <descrip>
static int qioch_in = 0;
$DESCRIPTOR (input_stream, "SYS$INPUT");
typedef struct {
short cond_code;
short count;
int info;
} io_status_block;
typedef struct {
int type;
int mask;
} io_mask;
/***************************************************************************/
int kbin( )
/*
* Returns code for next character struck at keyboard .. WITHOUT
* waiting for a <return>.
*/
{
char c;
int stat_in;
io_mask mask = {0, 0};
io_status_block iosb;
if (qioch_in == 0) {
if ((stat_in = SYS$ASSIGN(&input_stream,
&qioch_in,
0,
0))
!= SS$_NORMAL) {
printf("Can't open connection\n");
LIB$STOP(stat_in);
}
}
if ((stat_in = SYS$QIOW(0,
qioch_in,
IO$_READVBLK | IO$M_NOECHO | IO$M_TRMNOECHO
| IO$M_NOFILTR,
&iosb,
0,
0,
&c,
1,
0,
&mask,
0,
0))
!= SS$_NORMAL) {
LIB$SIGNAL(stat_in);
}
return ((int)c);
}
/***************************************************************************/
int kbinr( )
/*
* Returns code for next character struck at keyboard .. WITHOUT
* waiting for a <return>. Returns (-1) if no character is available.
*/
{
char c;
int stat_in;
io_status_block iosb;
io_mask mask = {0, 0};
if (qioch_in == 0) {
if ((stat_in = SYS$ASSIGN(&input_stream,
&qioch_in,
0,
0))
!= SS$_NORMAL) {
printf("Can't open connection\n");
LIB$STOP(stat_in);
}
}
if ((stat_in = SYS$QIOW(0,
qioch_in,
IO$_READVBLK | IO$M_NOECHO | IO$M_TRMNOECHO |
IO$M_NOFILTR | IO$M_TIMED,
&iosb,
0,
0,
&c,
1,
1,
&mask,
0,
0))
!= SS$_NORMAL) {
LIB$SIGNAL(stat_in);
}
return ((iosb.count == 0) ? -1 : (int)c);
}
/***************************************************************************/
End of vtvms.c
More information about the Comp.lang.c
mailing list