From 049d0abd09a5ded59aaf73306031cb0153b79efc Mon Sep 17 00:00:00 2001 From: Chris Hanson Date: Mon, 7 Jan 1991 23:57:29 +0000 Subject: [PATCH] Change terminal-interface code to handle ^S/^Q (and several related problems) on Ultrix and BSD. --- v7/src/microcode/ux.c | 6 ++-- v7/src/microcode/ux.h | 4 +-- v7/src/microcode/uxctty.c | 49 +++++++++++++++++++++------- v7/src/microcode/uxterm.c | 67 +++++++++++++++++++++++++-------------- v7/src/microcode/uxterm.h | 9 +++--- v7/src/microcode/uxutil.c | 6 ++-- 6 files changed, 93 insertions(+), 48 deletions(-) diff --git a/v7/src/microcode/ux.c b/v7/src/microcode/ux.c index 93c675142..7272a2cfb 100644 --- a/v7/src/microcode/ux.c +++ b/v7/src/microcode/ux.c @@ -1,6 +1,6 @@ /* -*-C-*- -$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/ux.c,v 1.4 1990/11/01 04:33:22 cph Exp $ +$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/ux.c,v 1.5 1991/01/07 23:56:50 cph Rel $ Copyright (c) 1990 Massachusetts Institute of Technology @@ -50,7 +50,7 @@ DEFUN (UX_terminal_get_state, (fd, s), int fd AND Ttty_state * s) { return ((((tcgetattr (fd, (& (s -> tio)))) < 0) -#ifdef HAVE_BSD_JOB_CONTROL +#ifdef _HPUX || ((UX_ioctl (fd, TIOCGLTC, (& (s -> ltc)))) < 0) #endif ) ? (-1) : 0); @@ -61,7 +61,7 @@ DEFUN (UX_terminal_set_state, (fd, s), int fd AND Ttty_state * s) { return ((((tcsetattr (fd, TCSANOW, (& (s -> tio)))) < 0) -#ifdef HAVE_BSD_JOB_CONTROL +#ifdef _HPUX || ((UX_ioctl (fd, TIOCSLTC, (& (s -> ltc)))) < 0) #endif ) ? (-1) : 0); diff --git a/v7/src/microcode/ux.h b/v7/src/microcode/ux.h index 7332a24b0..66440e7b6 100644 --- a/v7/src/microcode/ux.h +++ b/v7/src/microcode/ux.h @@ -1,6 +1,6 @@ /* -*-C-*- -$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/ux.h,v 1.15 1990/12/29 20:42:04 cph Exp $ +$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/ux.h,v 1.16 1991/01/07 23:56:58 cph Rel $ Copyright (c) 1988, 1989, 1990 Massachusetts Institute of Technology @@ -541,7 +541,7 @@ extern void EXFUN (UX_prim_check_errno, (CONST char * name)); typedef struct { struct termios tio; -#ifdef HAVE_BSD_JOB_CONTROL +#ifdef _HPUX struct ltchars ltc; #endif } Ttty_state; diff --git a/v7/src/microcode/uxctty.c b/v7/src/microcode/uxctty.c index 2c7d32c91..2ff5b4cf1 100644 --- a/v7/src/microcode/uxctty.c +++ b/v7/src/microcode/uxctty.c @@ -1,6 +1,6 @@ /* -*-C-*- -$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/uxctty.c,v 1.5 1990/11/11 00:25:13 cph Exp $ +$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/uxctty.c,v 1.6 1991/01/07 23:57:07 cph Rel $ Copyright (c) 1990 Massachusetts Institute of Technology @@ -256,39 +256,47 @@ DEFUN (ctty_get_interrupt_chars, (ic), Tinterrupt_chars * ic) (ic -> quit) = ((s . tio . c_cc) [VQUIT]); (ic -> intrpt) = ((s . tio . c_cc) [VINTR]); (ic -> tstp) = ((s . tio . c_cc) [VSUSP]); -#ifdef HAVE_BSD_JOB_CONTROL + +#ifdef _HPUX (ic -> dtstp) = (s . ltc . t_dsuspc); -#else - (ic -> dtstp) = (UX_PC_VDISABLE (ctty_fildes)); -#endif +#else /* not _HPUX */ +#ifdef _ULTRIX + (ic -> dtstp) = ((s . tio . c_cc) [VDSUSP]); +#endif /* _ULTRIX */ +#endif /* not _HPUX */ + #else /* not HAVE_TERMIOS */ #ifdef HAVE_TERMIO + (ic -> quit) = ((s . tio . c_cc) [VQUIT]); (ic -> intrpt) = ((s . tio . c_cc) [VINTR]); #ifdef HAVE_BSD_JOB_CONTROL (ic -> tstp) = (s . ltc . t_suspc); (ic -> dtstp) = (s . ltc . t_dsuspc); -#else +#else /* not HAVE_BSD_JOB_CONTROL */ { cc_t disabled_char = (UX_PC_VDISABLE (ctty_fildes)); (ic -> tstp) = disabled_char; (ic -> dtstp) = disabled_char; } -#endif +#endif /* not HAVE_BSD_JOB_CONTROL */ + #else /* not HAVE_TERMIO */ #ifdef HAVE_BSD_TTY_DRIVER + (ic -> quit) = (s . tc . t_quitc); (ic -> intrpt) = (s . tc . t_intrc); #ifdef HAVE_BSD_JOB_CONTROL (ic -> tstp) = (s . ltc . t_suspc); (ic -> dtstp) = (s . ltc . t_dsuspc); -#else +#else /* not HAVE_BSD_JOB_CONTROL */ { cc_t disabled_char = (UX_PC_VDISABLE (ctty_fildes)); (ic -> tstp) = disabled_char; (ic -> dtstp) = disabled_char; } -#endif +#endif /* not HAVE_BSD_JOB_CONTROL */ + #endif /* HAVE_BSD_TTY_DRIVER */ #endif /* HAVE_TERMIO */ #endif /* HAVE_TERMIOS */ @@ -314,21 +322,38 @@ DEFUN (ctty_set_interrupt_chars, (ic), Tinterrupt_chars * ic) ((s . tio . c_cc) [VQUIT]) = (ic -> quit); ((s . tio . c_cc) [VINTR]) = (ic -> intrpt); ((s . tio . c_cc) [VSUSP]) = (ic -> tstp); +#ifdef _HPUX + (s . ltc . t_suspc) = (ic -> tstp); + (s . ltc . t_dsuspc) = (ic -> dtstp); +#else /* not _HPUX */ +#ifdef _ULTRIX + ((s . tio . c_cc) [VDSUSP]) = (ic -> dtstp); +#endif /* _ULTRIX */ +#endif /* not _HPUX */ + #else /* not HAVE_TERMIOS */ #ifdef HAVE_TERMIO + ((s . tio . c_cc) [VQUIT]) = (ic -> quit); ((s . tio . c_cc) [VINTR]) = (ic -> intrpt); +#ifdef HAVE_BSD_JOB_CONTROL + (s . ltc . t_suspc) = (ic -> tstp); + (s . ltc . t_dsuspc) = (ic -> dtstp); +#endif + #else /* not HAVE_TERMIO */ #ifdef HAVE_BSD_TTY_DRIVER + (s . tc . t_quitc) = (ic -> quit); (s . tc . t_intrc) = (ic -> intrpt); -#endif /* HAVE_BSD_TTY_DRIVER */ -#endif /* HAVE_TERMIO */ -#endif /* HAVE_TERMIOS */ #ifdef HAVE_BSD_JOB_CONTROL (s . ltc . t_suspc) = (ic -> tstp); (s . ltc . t_dsuspc) = (ic -> dtstp); #endif + +#endif /* HAVE_BSD_TTY_DRIVER */ +#endif /* HAVE_TERMIO */ +#endif /* HAVE_TERMIOS */ UX_terminal_set_state (ctty_fildes, (&s)); } } diff --git a/v7/src/microcode/uxterm.c b/v7/src/microcode/uxterm.c index 0213f29a1..df1b6d61f 100644 --- a/v7/src/microcode/uxterm.c +++ b/v7/src/microcode/uxterm.c @@ -1,8 +1,8 @@ /* -*-C-*- -$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/uxterm.c,v 1.9 1991/01/05 23:09:06 cph Exp $ +$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/uxterm.c,v 1.10 1991/01/07 23:57:14 cph Rel $ -Copyright (c) 1990 Massachusetts Institute of Technology +Copyright (c) 1990, 1991 Massachusetts Institute of Technology This material was developed by the Scheme project at the Massachusetts Institute of Technology, Department of Electrical Engineering and @@ -205,11 +205,17 @@ DEFUN (terminal_state_buffered_p, (s), Ttty_state * s) } void -DEFUN (terminal_state_nonbuffered, (s, polling), - Ttty_state * s AND int polling) +DEFUN (terminal_state_nonbuffered, (s, fd, polling), + Ttty_state * s AND + int fd AND + int polling) { #if defined(HAVE_TERMIOS) || defined(HAVE_TERMIO) + ((TIO (s)) -> c_lflag) &=~ (ICANON | ECHO); +#ifdef IEXTEN + ((TIO (s)) -> c_lflag) &=~ IEXTEN; +#endif ((TIO (s)) -> c_lflag) |= ISIG; ((TIO (s)) -> c_iflag) |= IGNBRK; ((TIO (s)) -> c_iflag) &=~ (ICRNL | IXON | ISTRIP); @@ -217,8 +223,17 @@ DEFUN (terminal_state_nonbuffered, (s, polling), ((TIO (s)) -> c_cflag) &=~ PARENB; (((TIO (s)) -> c_cc) [VMIN]) = (polling ? 0 : 1); (((TIO (s)) -> c_cc) [VTIME]) = 0; +#ifdef HAVE_TERMIOS + { + cc_t disable = (UX_PC_VDISABLE (fd)); + (((TIO (s)) -> c_cc) [VSTOP]) = disable; + (((TIO (s)) -> c_cc) [VSTART]) = disable; + } +#endif + #else /* not HAVE_TERMIOS nor HAVE_TERMIO */ #ifdef HAVE_BSD_TTY_DRIVER + (s -> sg . sg_flags) &=~ (ECHO | CRMOD); (s -> sg . sg_flags) |= (ANYP | CBREAK); (s -> lmode) |= (LPASS8 | LNOFLSH); @@ -232,40 +247,32 @@ DEFUN (terminal_state_nonbuffered, (s, polling), (s -> ltc . t_werasc) = (-1); (s -> ltc . t_lnextc) = (-1); #endif /* HAVE_BSD_JOB_CONTROL */ + #endif /* HAVE_BSD_TTY_DRIVER */ #endif /* HAVE_TERMIOS or HAVE_TERMIO */ } void -DEFUN (terminal_state_raw, (s), Ttty_state * s) +DEFUN (terminal_state_raw, (s, fd), Ttty_state * s AND int fd) { + terminal_state_nonbuffered (s, fd, 0); + #if defined(HAVE_TERMIOS) || defined(HAVE_TERMIO) - ((TIO (s)) -> c_lflag) &=~ (ICANON | ECHO | ISIG); - ((TIO (s)) -> c_iflag) |= IGNBRK; - ((TIO (s)) -> c_iflag) &=~ (ICRNL | IXON | ISTRIP); - ((TIO (s)) -> c_cflag) |= CS8; - ((TIO (s)) -> c_cflag) &=~ PARENB; - (((TIO (s)) -> c_cc) [VMIN]) = 1; - (((TIO (s)) -> c_cc) [VTIME]) = 0; + + ((TIO (s)) -> c_lflag) &=~ ISIG; + #else /* not HAVE_TERMIOS nor HAVE_TERMIO */ #ifdef HAVE_BSD_TTY_DRIVER - (s -> sg . sg_flags) &=~ (ECHO | CRMOD); - (s -> sg . sg_flags) |= (ANYP | RAW); - (s -> lmode) |= (LPASS8 | LNOFLSH); + + (s -> sg . sg_flags) &=~ CBREAK; + (s -> sg . sg_flags) |= RAW; (s -> tc . t_intrc) = (-1); (s -> tc . t_quitc) = (-1); - (s -> tc . t_startc) = (-1); - (s -> tc . t_stopc) = (-1); - (s -> tc . t_eofc) = (-1); - (s -> tc . t_brkc) = (-1); #ifdef HAVE_BSD_JOB_CONTROL (s -> ltc . t_suspc) = (-1); (s -> ltc . t_dsuspc) = (-1); - (s -> ltc . t_rprntc) = (-1); - (s -> ltc . t_flushc) = (-1); - (s -> ltc . t_werasc) = (-1); - (s -> ltc . t_lnextc) = (-1); #endif /* HAVE_BSD_JOB_CONTROL */ + #endif /* HAVE_BSD_TTY_DRIVER */ #endif /* HAVE_TERMIOS or HAVE_TERMIO */ } @@ -276,16 +283,27 @@ DEFUN (terminal_state_buffered, (s, channel), Tchannel channel) { Ttty_state * os = (& (TERMINAL_ORIGINAL_STATE (channel))); + #if defined(HAVE_TERMIOS) || defined(HAVE_TERMIO) + ((TIO (s)) -> c_lflag) |= (ICANON | ISIG); ((TIO (s)) -> c_lflag) |= (((TIO (os)) -> c_lflag) & ECHO); +#ifdef IEXTEN + ((TIO (s)) -> c_lflag) |= (((TIO (os)) -> c_lflag) & IEXTEN); +#endif ((TIO (s)) -> c_iflag) = ((TIO (os)) -> c_iflag); ((TIO (s)) -> c_cflag) |= CS8; ((TIO (s)) -> c_cflag) &=~ PARENB; (((TIO (s)) -> c_cc) [VMIN]) = (((TIO (os)) -> c_cc) [VMIN]); (((TIO (s)) -> c_cc) [VTIME]) = (((TIO (os)) -> c_cc) [VTIME]); +#ifdef HAVE_TERMIOS + (((TIO (s)) -> c_cc) [VSTOP]) = (((TIO (os)) -> c_cc) [VSTOP]); + (((TIO (s)) -> c_cc) [VSTART]) = (((TIO (os)) -> c_cc) [VSTART]); +#endif + #else /* not HAVE_TERMIOS nor HAVE_TERMIO */ #ifdef HAVE_BSD_TTY_DRIVER + (s -> sg . sg_flags) &=~ (CBREAK | RAW); (s -> sg . sg_flags) |= ANYP; (s -> sg . sg_flags) |= ((os -> sg . sg_flags) & (ECHO | CRMOD)); @@ -305,6 +323,7 @@ DEFUN (terminal_state_buffered, (s, channel), (s -> ltc . t_werasc) = (os -> ltc . t_werasc); (s -> ltc . t_lnextc) = (os -> ltc . t_lnextc); #endif /* HAVE_BSD_JOB_CONTROL */ + #endif /* HAVE_BSD_TTY_DRIVER */ #endif /* HAVE_TERMIOS or HAVE_TERMIO */ } @@ -434,7 +453,7 @@ DEFUN (OS_terminal_nonbuffered, (channel), Tchannel channel) { Ttty_state s; get_terminal_state (channel, (&s)); - terminal_state_nonbuffered ((&s), 0); + terminal_state_nonbuffered ((&s), (CHANNEL_DESCRIPTOR (channel)), 0); set_terminal_state (channel, (&s)); } diff --git a/v7/src/microcode/uxterm.h b/v7/src/microcode/uxterm.h index fea0d8ca0..5e3377f8f 100644 --- a/v7/src/microcode/uxterm.h +++ b/v7/src/microcode/uxterm.h @@ -1,8 +1,8 @@ /* -*-C-*- -$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/uxterm.h,v 1.2 1990/11/05 11:55:34 cph Exp $ +$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/uxterm.h,v 1.3 1991/01/07 23:57:22 cph Rel $ -Copyright (c) 1990 Massachusetts Institute of Technology +Copyright (c) 1990, 1991 Massachusetts Institute of Technology This material was developed by the Scheme project at the Massachusetts Institute of Technology, Department of Electrical Engineering and @@ -40,8 +40,9 @@ MIT in each case. */ extern int EXFUN (terminal_state_buffered_p, (Ttty_state * s)); extern void EXFUN (terminal_state_buffered, (Ttty_state * s, Tchannel channel)); -extern void EXFUN (terminal_state_nonbuffered, (Ttty_state * s, int polling)); -extern void EXFUN (terminal_state_raw, (Ttty_state * s)); +extern void EXFUN + (terminal_state_nonbuffered, (Ttty_state * s, int fd, int polling)); +extern void EXFUN (terminal_state_raw, (Ttty_state * s, int fd)); extern void EXFUN (get_terminal_state, (Tchannel channel, Ttty_state * s)); extern void EXFUN (set_terminal_state, (Tchannel channel, Ttty_state * s)); diff --git a/v7/src/microcode/uxutil.c b/v7/src/microcode/uxutil.c index 53f718ec6..64bd3c92f 100644 --- a/v7/src/microcode/uxutil.c +++ b/v7/src/microcode/uxutil.c @@ -1,8 +1,8 @@ /* -*-C-*- -$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/uxutil.c,v 1.1 1990/06/20 19:38:07 cph Exp $ +$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/uxutil.c,v 1.2 1991/01/07 23:57:29 cph Rel $ -Copyright (c) 1990 Massachusetts Institute of Technology +Copyright (c) 1990, 1991 Massachusetts Institute of Technology This material was developed by the Scheme project at the Massachusetts Institute of Technology, Department of Electrical Engineering and @@ -153,7 +153,7 @@ DEFUN_VOID (userio_read_char_raw) do not permit aggregate initializers. */ Ttty_state state; state = (* (save_input_state ())); - terminal_state_raw (&state); + terminal_state_raw ((&state), STDIN_FILENO); UX_terminal_set_state (STDIN_FILENO, (&state)); } { -- 2.25.1