Change terminal-interface code to handle ^S/^Q (and several related
authorChris Hanson <org/chris-hanson/cph>
Mon, 7 Jan 1991 23:57:29 +0000 (23:57 +0000)
committerChris Hanson <org/chris-hanson/cph>
Mon, 7 Jan 1991 23:57:29 +0000 (23:57 +0000)
problems) on Ultrix and BSD.

v7/src/microcode/ux.c
v7/src/microcode/ux.h
v7/src/microcode/uxctty.c
v7/src/microcode/uxterm.c
v7/src/microcode/uxterm.h
v7/src/microcode/uxutil.c

index 93c6751427e546eddd14d3a3c89016325a66bfa2..7272a2cfbf341bafc4a7b76ee690ad0631a7db2f 100644 (file)
@@ -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);
index 7332a24b0d32c7073f9057d59bbbd387939e195f..66440e7b60cca13c521fe7c9807d9e33938a2aa4 100644 (file)
@@ -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;
index 2c7d32c9155272f337c5f0dc0fa83a93192f0724..2ff5b4cf14d93ed50a6ba14dca415c36db2ff8d5 100644 (file)
@@ -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));
     }
 }
index 0213f29a125846e36e462481b8e54008354b7d61..df1b6d61f0d463b9ce20975c531363502bb9f427 100644 (file)
@@ -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));
 }
 
index fea0d8ca06b0c99eebe2ba788e1c195cdd26101e..5e3377f8f13a94a88043d7d7f0f0074482c29954 100644 (file)
@@ -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));
 
index 53f718ec612a1f4696bc15f86a3ea37c805d3def..64bd3c92f2220b94962fd97b42fdf6e375f1c506 100644 (file)
@@ -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));
   }
   {