home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
rtsi.com
/
2014.01.www.rtsi.com.tar
/
www.rtsi.com
/
OS9
/
OSK
/
CMDS
/
beav.1.40.lzh
/
BEAV140
/
termio_osk.c
< prev
next >
Wrap
Text File
|
1995-06-14
|
3KB
|
119 lines
/*
* The functions in this file negotiate with the operating system for
* characters, and write characters in a barely buffered fashion on the display.
* All operating systems.
*/
#include <sys/types.h> /* 1.13 */
#include "def.h"
#ifdef OSK
#include <signal.h>
#include <errno.h>
#include <sgstat.h>
int kbdflgs; /* saved keyboard fd flags */
int kbdpoll; /* in O_NDELAY mode */
unsigned int kbdqp; /* there is a char in kbdq */
unsigned char kbdq; /* char we've already read */
struct sgbuf otermio; /* original terminal characteristics */
struct sgbuf ntermio; /* charactoristics to use inside */
int nrow; /* Terminal size, rows. */
int ncol; /* Terminal size, columns. */
/*
* This function is called once to set up the terminal device streams.
* On VMS, it translates TT until it finds the terminal, then assigns
* a channel to it and sets it raw. On CPM it is a no-op.
*/
ttopen()
{
_gs_opt(0,&otermio);
_gs_opt(0,&ntermio);
ntermio.sg_pause = 0;
ntermio.sg_kbich = 0;
ntermio.sg_kbach = 0;
ntermio.sg_eofch = 0;
ntermio.sg_psch = 0;
ntermio.sg_dulnch = 0;
ntermio.sg_rlnch = 0;
ntermio.sg_dlnch = 0;
ntermio.sg_echo = 0;
_ss_opt(0,&ntermio);
kbdflgs = 0; /*fcntl( 0, F_GETFL, 0 );*/
kbdpoll = FALSE;
/* on all screens we are not sure of the initial position
of the cursor */
ttrow = 999;
ttcol = 999;
nrow = NROW;
ncol = NCOL;
}
/*
* This function gets called just before we go back home to the command
* interpreter. On VMS it puts the terminal back in a reasonable state.
* Another no-operation on CPM.
*/
ttclose()
{
_ss_opt(0,&otermio);
}
/*
* Write a character to the display. On VMS, terminal output is buffered, and
* we just put the characters in the big array, after checking for overflow.
* On CPM terminal I/O unbuffered, so we just write the byte out. Ditto on
* MS-DOS (use the very very raw console output routine).
*/
ttputc(c)
{
putc(c, stdout);
}
/*
* Flush terminal buffer. Does real work where the terminal output is buffered
* up. A no-operation on systems where byte at a time terminal I/O is done.
*/
ttflush()
{
fflush(stdout);
}
/*
* Read a character from the terminal, performing no editing and doing no echo
* at all. More complex in VMS that almost anyplace else, which figures. Very
* simple on CPM, because the system can do exactly what you want.
*/
ttgetc()
{
if( kbdqp )
kbdqp = FALSE;
else
{
if( kbdpoll) /* && fcntl( 0, F_SETFL, kbdflgs ) < 0 ) */
return FALSE;
kbdpoll = FALSE;
while (read(0, &kbdq, 1) != 1)
;
}
return ( kbdq );
}
/* typahead(): Check to see if any characters are already in the
keyboard buffer
*/
ttkeyready ()
{
if( !kbdqp )
{
if( !kbdpoll && (_gs_rdy(0) < 0) )
return(FALSE);
kbdpoll = TRUE; /* fix in 1.13 */
kbdqp = (1 == read( 0, &kbdq, 1 ));
}
return ( kbdqp );
}
#endif