/***************************************************************
** I/O subsystem for PForth based on 'C'
** Copyright 1994 3DO, Phil Burk, Larry Polansky, David Rosenboom
** The pForth software code is dedicated to the public domain,
** and any third party may reproduce, distribute and modify
** the pForth software code or any derivative works thereof
** without any compensation or license. The pForth software
** code is provided on an "as is" basis without any warranty
** of any kind, including, without limitation, the implied
** warranties of merchantability and fitness for a particular
** purpose and their equivalents under the laws of any jurisdiction.
****************************************************************
** 941004 PLB Extracted IO calls from pforth_main.c
***************************************************************/
/* Configure console so that characters are not buffered.
* This allows KEY to work and also HISTORY.ON
* Thanks to Ralf Baechle and David Feuer for contributing this.
#include <sys/int_types.h> /* Needed on Solaris for uint32_t in termio.h */
static struct termios save_termios
;
/* Default portable terminal I/O. */
int sdTerminalOut( char c
)
/* We don't need to echo because getchar() echos. */
int sdTerminalEcho( char c
)
int sdTerminalFlush( void )
return fflush(PF_STDOUT
);
/****************************************************/
int sdQueryTerminal( void )
return poll( &pfd
, 1, 0 );
/****************************************************/
void sdTerminalInit(void)
stdin_is_tty
= isatty(stdin_fd
);
/* Get current terminal attributes and save them so we can restore them. */
tcgetattr(stdin_fd
, &term
);
/* ICANON says to wait upon read until a character is received,
* and then to return it immediately (or soon enough....)
* ECHOCTL says not to echo backspaces and other control chars as ^H */
term
.c_lflag
&= ~( ECHO
| ECHONL
| ECHOCTL
| ICANON
);
tcsetattr(stdin_fd
, TCSANOW
, &term
);
/****************************************************/
void sdTerminalTerm(void)
tcsetattr(stdin_fd
, TCSANOW
, &save_termios
);