From: Chris Hanson Date: Tue, 16 Oct 1990 20:57:29 +0000 (+0000) Subject: * Flush curses support, add new primitives for termcap and terminfo. X-Git-Tag: 20090517-FFI~11127 X-Git-Url: https://birchwood-abbey.net/git?a=commitdiff_plain;h=25faaea5e7d2cbbe6bf249c9eab5f10ffac50a3d;p=mit-scheme.git * Flush curses support, add new primitives for termcap and terminfo. * Add new primitives to control terminals: TERMINAL-GET-ISPEED TERMINAL-GET-OSPEED BAUD-INDEX->RATE BAUD-RATE->INDEX TERMINAL-COOKED-OUTPUT? TERMINAL-COOKED-OUTPUT TERMINAL-RAW-OUTPUT * Change X line scrolling so that it does not clear the region that the lines are being scrolled out of. The update optimizer will take care of this if it needs to. --- diff --git a/v7/src/microcode/osterm.h b/v7/src/microcode/osterm.h index 0d685d155..97fa86af9 100644 --- a/v7/src/microcode/osterm.h +++ b/v7/src/microcode/osterm.h @@ -1,6 +1,6 @@ /* -*-C-*- -$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/osterm.h,v 1.1 1990/06/20 19:36:43 cph Exp $ +$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/osterm.h,v 1.2 1990/10/16 20:53:21 cph Exp $ Copyright (c) 1990 Massachusetts Institute of Technology @@ -39,6 +39,14 @@ MIT in each case. */ extern int EXFUN (OS_terminal_read_char, (Tchannel channel)); extern int EXFUN (OS_terminal_char_ready_p, (Tchannel channel, clock_t delay)); +extern unsigned int EXFUN (OS_terminal_get_ispeed, (Tchannel channel)); +extern unsigned int EXFUN (OS_terminal_get_ospeed, (Tchannel channel)); +extern unsigned int EXFUN (arg_baud_index, (unsigned int argument)); +extern unsigned int EXFUN (OS_baud_index_to_rate, (unsigned int index)); +extern int EXFUN (OS_baud_rate_to_index, (unsigned int rate)); +extern int EXFUN (OS_terminal_cooked_output_p, (Tchannel channel)); +extern void EXFUN (OS_terminal_raw_output, (Tchannel channel)); +extern void EXFUN (OS_terminal_cooked_output, (Tchannel channel)); extern int EXFUN (OS_terminal_buffered_p, (Tchannel channel)); extern void EXFUN (OS_terminal_buffered, (Tchannel channel)); extern void EXFUN (OS_terminal_nonbuffered, (Tchannel channel)); diff --git a/v7/src/microcode/prosterm.c b/v7/src/microcode/prosterm.c index a0e398ab9..3fbbc25c3 100644 --- a/v7/src/microcode/prosterm.c +++ b/v7/src/microcode/prosterm.c @@ -1,6 +1,6 @@ /* -*-C-*- -$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/prosterm.c,v 1.1 1990/06/20 19:38:35 cph Exp $ +$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/prosterm.c,v 1.2 1990/10/16 20:53:32 cph Exp $ Copyright (c) 1990 Massachusetts Institute of Technology @@ -70,6 +70,62 @@ Second arg DELAY says how long to wait for one to arrive, in milliseconds.") (arg_nonnegative_integer (2))))); } +DEFINE_PRIMITIVE ("TERMINAL-GET-ISPEED", Prim_terminal_get_ispeed, 1, 1, 0) +{ + PRIMITIVE_HEADER (1); + PRIMITIVE_RETURN + (long_to_integer (OS_terminal_get_ispeed (arg_terminal (1)))); +} + +DEFINE_PRIMITIVE ("TERMINAL-GET-OSPEED", Prim_terminal_get_ospeed, 1, 1, 0) +{ + PRIMITIVE_HEADER (1); + PRIMITIVE_RETURN + (long_to_integer (OS_terminal_get_ospeed (arg_terminal (1)))); +} + +DEFINE_PRIMITIVE ("BAUD-INDEX->RATE", Prim_baud_index_to_rate, 1, 1, 0) +{ + PRIMITIVE_HEADER (1); + PRIMITIVE_RETURN + (long_to_integer (OS_baud_index_to_rate [arg_baud_index (1)])); +} + +DEFINE_PRIMITIVE ("BAUD-RATE->INDEX", Prim_baud_rate_to_index, 1, 1, 0) +{ + PRIMITIVE_HEADER (1); + { + int index = (OS_baud_rate_to_index (arg_nonnegative_integer (1))); + if (index < 0) + error_bad_range_arg (1); + PRIMITIVE_RETURN (long_to_integer (index)); + } +} + +DEFINE_PRIMITIVE ("TERMINAL-COOKED-OUTPUT?", Prim_terminal_cooked_output_p, 1, 1, + "Return #F iff TERMINAL is not in cooked output mode.") +{ + PRIMITIVE_HEADER (1); + PRIMITIVE_RETURN + (BOOLEAN_TO_OBJECT (OS_terminal_cooked_output_p (arg_terminal (1)))); +} + +DEFINE_PRIMITIVE ("TERMINAL-RAW-OUTPUT", Prim_terminal_raw_output, 1, 1, + "Put TERMINAL into raw output mode.") +{ + PRIMITIVE_HEADER (1); + OS_terminal_raw_output (arg_terminal (1)); + PRIMITIVE_RETURN (UNSPECIFIC); +} + +DEFINE_PRIMITIVE ("TERMINAL-COOKED-OUTPUT", Prim_terminal_cooked_output, 1, 1, + "Put TERMINAL into cooked output mode.") +{ + PRIMITIVE_HEADER (1); + OS_terminal_cooked_output (arg_terminal (1)); + PRIMITIVE_RETURN (UNSPECIFIC); +} + DEFINE_PRIMITIVE ("TERMINAL-BUFFERED?", Prim_terminal_buffered_p, 1, 1, "Return #F iff TERMINAL is not in buffered mode.") { @@ -117,7 +173,7 @@ DEFINE_PRIMITIVE ("TERMINAL-DRAIN-OUTPUT", Prim_terminal_drain_output, 1, 1, OS_terminal_drain_output (arg_terminal (1)); PRIMITIVE_RETURN (UNSPECIFIC); } - + DEFINE_PRIMITIVE ("OPEN-PTY-MASTER", Prim_open_pty_master, 0, 0, "Open a PTY master, returning the master's channel and the slave's name.\n\ The result is a pair whose car is a channel and whose cdr is a filename.\n\ diff --git a/v7/src/microcode/s/bsd4-2.h b/v7/src/microcode/s/bsd4-2.h index 57543ebca..094284cdc 100644 --- a/v7/src/microcode/s/bsd4-2.h +++ b/v7/src/microcode/s/bsd4-2.h @@ -1,9 +1,9 @@ /* -*-C-*- System file for BSD4.2 -$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/s/Attic/bsd4-2.h,v 1.4 1990/06/20 19:54:52 cph Exp $ +$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/s/Attic/bsd4-2.h,v 1.5 1990/10/16 20:56:47 cph Rel $ -Copyright (c) 1989 Massachusetts Institute of Technology +Copyright (c) 1989, 1990 Massachusetts Institute of Technology This material was developed by the Scheme project at the Massachusetts Institute of Technology, Department of Electrical Engineering and @@ -33,11 +33,8 @@ Technology nor of any adaptation thereof in any advertising, promotional, or sales literature without prior written consent from MIT in each case. */ -/* This says we have curses terminal support for Edwin. */ -#define HAVE_CURSES - #define C_SWITCH_SYSTEM -D_BSD4_2 -#define LIBS_SYSTEM -ltermcap +#define LIBS_TERMCAP -ltermcap #define ALTERNATE_M4 s/ultrix.m4 diff --git a/v7/src/microcode/s/bsd4-3.h b/v7/src/microcode/s/bsd4-3.h index e73f73f96..d9aa85e05 100644 --- a/v7/src/microcode/s/bsd4-3.h +++ b/v7/src/microcode/s/bsd4-3.h @@ -1,7 +1,7 @@ /* -*-C-*- System file for BSD4.3 -$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/s/Attic/bsd4-3.h,v 1.1 1990/06/20 19:55:31 cph Exp $ +$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/s/Attic/bsd4-3.h,v 1.2 1990/10/16 20:56:53 cph Rel $ Copyright (c) 1990 Massachusetts Institute of Technology @@ -33,11 +33,8 @@ Technology nor of any adaptation thereof in any advertising, promotional, or sales literature without prior written consent from MIT in each case. */ -/* This says we have curses terminal support for Edwin. */ -#define HAVE_CURSES - #define C_SWITCH_SYSTEM -D_BSD4_3 -#define LIBS_SYSTEM -ltermcap +#define LIBS_TERMCAP -ltermcap #define ALTERNATE_M4 s/ultrix.m4 diff --git a/v7/src/microcode/s/hpux.h b/v7/src/microcode/s/hpux.h index b82e4b007..960325e54 100644 --- a/v7/src/microcode/s/hpux.h +++ b/v7/src/microcode/s/hpux.h @@ -1,7 +1,7 @@ /* -*-C-*- System file for HP-UX -$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/s/Attic/hpux.h,v 1.6 1990/06/20 19:54:58 cph Exp $ +$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/s/Attic/hpux.h,v 1.7 1990/10/16 20:57:00 cph Exp $ Copyright (c) 1989, 1990 Massachusetts Institute of Technology @@ -33,8 +33,7 @@ Technology nor of any adaptation thereof in any advertising, promotional, or sales literature without prior written consent from MIT in each case. */ -/* This says we have curses terminal support for Edwin. */ -#define HAVE_CURSES +#define HAVE_TERMINFO /* Define HAVE_STARBASE_GRAPHICS if you want Starbase graphics support. */ /* #define HAVE_STARBASE_GRAPHICS */ @@ -42,10 +41,6 @@ MIT in each case. */ /* No special libraries are needed for debugging. */ #define LIB_DEBUG -#ifndef HAVE_CURSES -#define LIBS_SYSTEM -lcurses -#endif - #ifndef INSTALL_PROGRAM #define INSTALL_PROGRAM cp #endif diff --git a/v7/src/microcode/s/nextos.h b/v7/src/microcode/s/nextos.h index 0622f72e3..9f0a9a604 100644 --- a/v7/src/microcode/s/nextos.h +++ b/v7/src/microcode/s/nextos.h @@ -1,7 +1,7 @@ /* -*-C-*- System file for NeXT running Mach -$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/s/Attic/nextos.h,v 1.1 1990/09/06 18:57:34 cph Exp $ +$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/s/Attic/nextos.h,v 1.2 1990/10/16 20:57:07 cph Rel $ Copyright (c) 1990 Massachusetts Institute of Technology @@ -33,9 +33,6 @@ Technology nor of any adaptation thereof in any advertising, promotional, or sales literature without prior written consent from MIT in each case. */ -/* This says we have curses terminal support for Edwin. */ -#define HAVE_CURSES - #define C_SWITCH_SYSTEM -bsd -fwritable-strings -D_BSD4_3 -#define LIBS_SYSTEM -ltermcap +#define LIBS_TERMCAP -ltermcap diff --git a/v7/src/microcode/s/sunos3.h b/v7/src/microcode/s/sunos3.h index 4d5f129fe..165b6a045 100644 --- a/v7/src/microcode/s/sunos3.h +++ b/v7/src/microcode/s/sunos3.h @@ -1,7 +1,7 @@ /* -*-C-*- System file for SUNOS -$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/s/Attic/sunos3.h,v 1.1 1990/06/20 19:55:45 cph Exp $ +$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/s/Attic/sunos3.h,v 1.2 1990/10/16 20:57:13 cph Rel $ Copyright (c) 1990 Massachusetts Institute of Technology @@ -33,15 +33,12 @@ Technology nor of any adaptation thereof in any advertising, promotional, or sales literature without prior written consent from MIT in each case. */ -/* This says we have curses terminal support for Edwin. */ -#define HAVE_CURSES - #ifndef ALTERNATE_CC #define C_SWITCH_SYSTEM -D_SUNOS3 -DCAST_FUNCTION_TO_INT_BUG #else #define C_SWITCH_SYSTEM -D_SUNOS3 #endif -#define LIBS_SYSTEM -ltermcap +#define LIBS_TERMCAP -ltermcap #define ALTERNATE_M4 s/ultrix.m4 diff --git a/v7/src/microcode/s/sunos4.h b/v7/src/microcode/s/sunos4.h index 518bade0c..1634b0c2c 100644 --- a/v7/src/microcode/s/sunos4.h +++ b/v7/src/microcode/s/sunos4.h @@ -1,7 +1,7 @@ /* -*-C-*- System file for SUNOS -$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/s/Attic/sunos4.h,v 1.1 1990/06/20 19:56:08 cph Exp $ +$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/s/Attic/sunos4.h,v 1.2 1990/10/16 20:57:19 cph Rel $ Copyright (c) 1990 Massachusetts Institute of Technology @@ -33,11 +33,8 @@ Technology nor of any adaptation thereof in any advertising, promotional, or sales literature without prior written consent from MIT in each case. */ -/* This says we have curses terminal support for Edwin. */ -#define HAVE_CURSES - #define C_SWITCH_SYSTEM -D_SUNOS4 -#define LIBS_SYSTEM -ltermcap +#define LIBS_TERMCAP -ltermcap #define ALTERNATE_M4 s/ultrix.m4 diff --git a/v7/src/microcode/s/ultrix.h b/v7/src/microcode/s/ultrix.h index 2c2d53b73..690166acb 100644 --- a/v7/src/microcode/s/ultrix.h +++ b/v7/src/microcode/s/ultrix.h @@ -1,7 +1,7 @@ /* -*-C-*- System file for Ultrix -$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/s/Attic/ultrix.h,v 1.10 1990/10/10 02:36:36 cph Exp $ +$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/s/Attic/ultrix.h,v 1.11 1990/10/16 20:57:25 cph Exp $ Copyright (c) 1989, 1990 Massachusetts Institute of Technology @@ -36,15 +36,12 @@ MIT in each case. */ /* Why? -- ask JMiller */ #undef ultrix -/* This says we have curses terminal support for Edwin. */ -#define HAVE_CURSES - /* This is in mips.h for some reason. */ /* #define LIB_DEBUG */ #define C_SWITCH_SYSTEM -D_ULTRIX -YPOSIX -#define LIBS_SYSTEM -ltermcap +#define LIBS_TERMCAP -ltermcap /* Fix random bug in Ultrix "libX11.a"; I quote: diff --git a/v7/src/microcode/s/umax.h b/v7/src/microcode/s/umax.h index 53e49164f..327925d84 100644 --- a/v7/src/microcode/s/umax.h +++ b/v7/src/microcode/s/umax.h @@ -1,9 +1,9 @@ /* -*-C-*- System file for Encore UMAX42 and Mach -$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/s/Attic/umax.h,v 1.2 1990/06/20 19:55:07 cph Exp $ +$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/s/Attic/umax.h,v 1.3 1990/10/16 20:57:29 cph Rel $ -Copyright (c) 1989 Massachusetts Institute of Technology +Copyright (c) 1989, 1990 Massachusetts Institute of Technology This material was developed by the Scheme project at the Massachusetts Institute of Technology, Department of Electrical Engineering and @@ -33,9 +33,6 @@ Technology nor of any adaptation thereof in any advertising, promotional, or sales literature without prior written consent from MIT in each case. */ -/* This says we have curses terminal support for Edwin. */ -#define HAVE_CURSES - #define C_SWITCH_SYSTEM -D_BSD4_2 -Dumax -#define LIBS_SYSTEM -ltermcap +#define LIBS_TERMCAP -ltermcap diff --git a/v7/src/microcode/unxutl/ymkfile b/v7/src/microcode/unxutl/ymkfile index 96fcb84c6..a4bb8c472 100644 --- a/v7/src/microcode/unxutl/ymkfile +++ b/v7/src/microcode/unxutl/ymkfile @@ -1,6 +1,6 @@ /* -*-C-*- -$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/unxutl/Attic/ymkfile,v 1.29 1990/10/02 22:52:47 cph Exp $ +$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/unxutl/Attic/ymkfile,v 1.30 1990/10/16 20:54:17 cph Exp $ Copyright (c) 1989, 1990 Massachusetts Institute of Technology @@ -127,6 +127,22 @@ MIT in each case. */ #define LIBX11_SYSTEM #endif +#ifdef HAVE_TERMINFO +#ifndef LIBS_TERMCAP +#define LIBS_TERMCAP -lcurses +#endif +TERMCAP_OBJECTS = terminfo.o tterm.o +#else /* not HAVE_TERMINFO */ +#ifndef LIBS_TERMCAP +#define LIBS_TERMCAP +TERMCAP_OBJECTS = termcap.o tparam.o tterm.o +#else /* LIBS_TERMCAP */ +TERMCAP_OBJECTS = tparam.o tterm.o +#endif /* LIBS_TERMCAP */ +#endif /* not HAVE_TERMINFO */ +TERMCAP_SOURCES = tterm.c +TERMCAP_LIBS = LIBS_TERMCAP + #ifdef HAVE_X_WINDOWS X_SOURCES = x11base.c x11term.c x11graph.c X_OBJECTS = x11base.o x11term.o x11graph.o @@ -143,16 +159,6 @@ GRAPHICS_OBJECTS = GRAPHICS_LIBS = #endif /* HAVE_STARBASE_GRAPHICS */ -#ifdef HAVE_CURSES -CTERM_SOURCES = cterm.c -CTERM_OBJECTS = cterm.o -CTERM_LIB = -lcurses -#else /* not HAVE_CURSES */ -CTERM_SOURCES = -CTERM_OBJECTS = -CTERM_LIB = -#endif /* HAVE_CURSES */ - #if (PROC_TYPE == PROC_TYPE_68020) #define PROC_TYPE_KNOWN MACHINE_SWITCHES = -DMC68020 -DHAS_COMPILER_SUPPORT @@ -270,9 +276,9 @@ CFLAGS = -DMIT_SCHEME C_OPTIMIZE_SWITCH C_DEBUG_SWITCH C_SWITCH_MACHINE C_SWITCH /* Source and object files */ -SCHEME_SOURCES = $(X_SOURCES) $(CTERM_SOURCES) $(GRAPHICS_SOURCES) SOURCES_SYSTEM SOURCES_MACHINE $(USER_PRIM_SOURCES) missing.c -SCHEME_OBJECTS = $(X_OBJECTS) $(CTERM_OBJECTS) $(GRAPHICS_OBJECTS) OBJECTS_SYSTEM OBJECTS_MACHINE $(USER_PRIM_OBJECTS) missing.o usrdef.o -SCHEME_LIB = $(USER_LIBS) $(GRAPHICS_LIBS) $(X_LIB) $(CTERM_LIB) LIB_MATH LIBS_SYSTEM LIBS_MACHINE LIB_DEBUG LIB_STANDARD +SCHEME_SOURCES = $(X_SOURCES) $(TERMCAP_SOURCES) $(GRAPHICS_SOURCES) SOURCES_SYSTEM SOURCES_MACHINE $(USER_PRIM_SOURCES) missing.c +SCHEME_OBJECTS = $(X_OBJECTS) $(TERMCAP_OBJECTS) $(GRAPHICS_OBJECTS) OBJECTS_SYSTEM OBJECTS_MACHINE $(USER_PRIM_OBJECTS) missing.o usrdef.o +SCHEME_LIB = $(USER_LIBS) $(GRAPHICS_LIBS) $(X_LIB) $(TERMCAP_LIBS) LIB_MATH LIBS_SYSTEM LIBS_MACHINE LIB_DEBUG LIB_STANDARD SOURCES = \ $(MACHINE_SOURCES) \ @@ -576,6 +582,7 @@ fixnum.o : scheme.touch prims.h mul.c storage.o : scheme.touch gctype.c char.o string.o : scheme.touch prims.h +tterm.o : scheme.touch prims.h osterm.h boot.o : scheme.touch prims.h version.h paths.h ostop.h term.o : scheme.touch @@ -598,7 +605,6 @@ dmpwrld.o : unexec.c getpagesize.h x11base.o x11graph.o x11term.o starbasex.o : scheme.touch prims.h x11.h x11base.o : ux.h -cterm.o : scheme.touch prims.h starbase.o : scheme.touch prims.h Sgraph.o Sgraph_xt.o SgX.o : scheme.touch prims.h Sgraph.h diff --git a/v7/src/microcode/ux.c b/v7/src/microcode/ux.c index 6ce4ec89d..83ffa0b71 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.2 1990/08/16 22:33:42 cph Exp $ +$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/ux.c,v 1.3 1990/10/16 20:53:43 cph Exp $ Copyright (c) 1990 Massachusetts Institute of Technology @@ -130,7 +130,8 @@ DEFUN (UX_terminal_get_state, (fd, s), int fd AND Ttty_state * s) #ifdef HAVE_BSD_JOB_CONTROL || ((UX_ioctl (fd, TIOCGLTC, (& (s -> ltc)))) < 0) #endif - ) ? (-1) : 0); + || ((UX_ioctl (fd, TIOCLGET, (& (s -> lmode)))) < 0)) + ? (-1) : 0); } int @@ -142,7 +143,8 @@ DEFUN (UX_terminal_set_state, (fd, s), int fd AND Ttty_state * s) #ifdef HAVE_BSD_JOB_CONTROL || ((UX_ioctl (fd, TIOCSLTC, (& (s -> ltc)))) < 0) #endif - ) ? (-1) : 0); + || ((UX_ioctl (fd, TIOCLSET, (& (s -> lmode)))) < 0)) + ? (-1) : 0); } #endif /* HAVE_BSD_TTY_DRIVER */ diff --git a/v7/src/microcode/ux.h b/v7/src/microcode/ux.h index 245e41b65..23ed3969c 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.10 1990/08/17 20:05:32 markf Exp $ +$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/ux.h,v 1.11 1990/10/16 20:53:48 cph Exp $ Copyright (c) 1988, 1989, 1990 Massachusetts Institute of Technology @@ -571,6 +571,7 @@ typedef struct #ifdef HAVE_BSD_JOB_CONTROL struct ltchars ltc; #endif + int lmode; } Ttty_state; #endif /* HAVE_BSD_TTY_DRIVER */ diff --git a/v7/src/microcode/uxterm.c b/v7/src/microcode/uxterm.c index 533a46efa..55dbf0b25 100644 --- a/v7/src/microcode/uxterm.c +++ b/v7/src/microcode/uxterm.c @@ -1,6 +1,6 @@ /* -*-C-*- -$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/uxterm.c,v 1.3 1990/07/28 18:57:03 jinx Exp $ +$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/uxterm.c,v 1.4 1990/10/16 20:53:55 cph Exp $ Copyright (c) 1990 Massachusetts Institute of Technology @@ -35,23 +35,46 @@ MIT in each case. */ #include "ux.h" #include "uxterm.h" #include "uxio.h" + +#if defined(HAVE_TERMIOS) || defined(HAVE_TERMIO) + +#ifndef ISTRIP +#define ISTRIP 0 +#endif +#ifndef CS8 +#define CS8 0 +#endif +#ifndef PARENB +#define PARENB 0 +#endif + +#else +#ifdef HAVE_BSD_TTY_DRIVER + +/* LPASS8 is new in 4.3, and makes cbreak mode provide all 8 bits. */ +#ifndef LPASS8 +#define LPASS8 0 +#endif + +#endif /* HAVE_BSD_TTY_DRIVER */ +#endif /* not HAVE_TERMIOS nor HAVE_TERMIO */ struct terminal_state { int buffer; -#if defined(HAVE_TERMIOS) || defined(HAVE_TERMIO) - char saved_echo; - cc_t saved_vmin; - cc_t saved_vtime; -#endif + Ttty_state state; }; static struct terminal_state * terminal_table; #define TERMINAL_BUFFER(channel) ((terminal_table[(channel)]) . buffer) -#if defined(HAVE_TERMIOS) || defined(HAVE_TERMIO) -#define TERMINAL_ECHO(channel) ((terminal_table[(channel)]) . saved_echo) -#define TERMINAL_VMIN(channel) ((terminal_table[(channel)]) . saved_vmin) -#define TERMINAL_VTIME(channel) ((terminal_table[(channel)]) . saved_vtime) +#define TERMINAL_ORIGINAL_STATE(channel) ((terminal_table[(channel)]) . state) + +#ifdef HAVE_TERMIOS +#define TIO(s) (s) +#else +#ifdef HAVE_TERMIO +#define TIO(s) (& ((s) -> tio)) +#endif #endif void @@ -79,20 +102,7 @@ void DEFUN (terminal_open, (channel), Tchannel channel) { (TERMINAL_BUFFER (channel)) = (-1); -#if defined(HAVE_TERMIOS) || defined(HAVE_TERMIO) - { - Ttty_state s; -#ifdef HAVE_TERMIOS - struct termios * tio = (&s); -#else - struct termio * tio = (& (s . tio)); -#endif - get_terminal_state (channel, (&s)); - (TERMINAL_ECHO (channel)) = (((tio -> c_lflag) & ECHO) != 0); - (TERMINAL_VMIN (channel)) = ((tio -> c_cc) [VMIN]); - (TERMINAL_VTIME (channel)) = ((tio -> c_cc) [VTIME]); - } -#endif + get_terminal_state (channel, (& (TERMINAL_ORIGINAL_STATE (channel)))); } int @@ -113,42 +123,87 @@ DEFUN (OS_terminal_read_char, (channel), Tchannel channel) } } -int -DEFUN (terminal_state_buffered_p, (s), Ttty_state * s) +unsigned int +DEFUN (terminal_state_get_ospeed, (s), Ttty_state * s) { -#if defined(HAVE_TERMIOS) || defined(HAVE_TERMIO) #ifdef HAVE_TERMIOS - struct termios * tio = s; + return (cfgetospeed (s)); #else - struct termio * tio = (& (s -> tio)); -#endif - return (((tio -> c_lflag) & ICANON) != 0); +#ifdef HAVE_TERMIO + return (((TIO (s)) -> c_cflag) & CBAUD); +#else +#ifdef HAVE_BSD_TTY_DRIVER + return (s -> sg . sg_ospeed); +#endif /* HAVE_BSD_TTY_DRIVER */ +#endif /* not HAVE_TERMIO */ +#endif /* not HAVE_TERMIOS */ +} + +unsigned int +DEFUN (terminal_state_get_ispeed, (s), Ttty_state * s) +{ +#ifdef HAVE_TERMIOS + return (cfgetispeed (s)); +#else +#ifdef HAVE_TERMIO + return (((TIO (s)) -> c_cflag) & CBAUD); +#else +#ifdef HAVE_BSD_TTY_DRIVER + return (s -> sg . sg_ispeed); +#endif /* HAVE_BSD_TTY_DRIVER */ +#endif /* not HAVE_TERMIO */ +#endif /* not HAVE_TERMIOS */ +} + +int +DEFUN (terminal_state_cooked_output_p, (s), Ttty_state * s) +{ +#if defined(HAVE_TERMIOS) || defined(HAVE_TERMIO) + return ((((TIO (s)) -> c_oflag) & OPOST) != 0); #else /* not HAVE_TERMIOS nor HAVE_TERMIO */ #ifdef HAVE_BSD_TTY_DRIVER - return (((s -> sg . sg_flags) & CBREAK) == 0); + return (((s -> sg . sg_flags) & LLITOUT) == 0); #endif /* HAVE_BSD_TTY_DRIVER */ #endif /* HAVE_TERMIOS or HAVE_TERMIO */ } void -DEFUN (terminal_state_buffered, (s, channel), - Ttty_state * s AND - Tchannel channel) +DEFUN (terminal_state_raw_output, (s), Ttty_state * s) { #if defined(HAVE_TERMIOS) || defined(HAVE_TERMIO) -#ifdef HAVE_TERMIOS - struct termios * tio = s; -#else - struct termio * tio = (& (s -> tio)); -#endif - (tio -> c_lflag) |= ICANON; - if (TERMINAL_ECHO (channel)) - (tio -> c_lflag) |= ECHO; - ((tio -> c_cc) [VMIN]) = (TERMINAL_VMIN (channel)); - ((tio -> c_cc) [VTIME]) = (TERMINAL_VTIME (channel)); + ((TIO (s)) -> c_oflag) &=~ OPOST; #else /* not HAVE_TERMIOS nor HAVE_TERMIO */ #ifdef HAVE_BSD_TTY_DRIVER - (s -> sg . sg_flags) &=~ CBREAK; + (s -> sg . sg_flags) &=~ ALLDELAY; + (s -> lmode) |= LLITOUT; +#endif /* HAVE_BSD_TTY_DRIVER */ +#endif /* HAVE_TERMIOS or HAVE_TERMIO */ +} + +void +DEFUN (terminal_state_cooked_output, (s, channel), + Ttty_state * s AND Tchannel channel) +{ + Ttty_state * os = (& (TERMINAL_ORIGINAL_STATE (channel))); +#if defined(HAVE_TERMIOS) || defined(HAVE_TERMIO) + ((TIO (s)) -> c_oflag) = ((TIO (os)) -> c_oflag); +#else /* not HAVE_TERMIOS nor HAVE_TERMIO */ +#ifdef HAVE_BSD_TTY_DRIVER + (s -> sg . sg_flags) = + (((s -> sg . sg_flags) &~ ALLDELAY) | ((os -> sg . sg_flags) & ALLDELAY)); + (s -> lmode) = (((s -> lmode) &~ LLITOUT) | ((os -> lmode) & LLITOUT)); +#endif /* HAVE_BSD_TTY_DRIVER */ +#endif /* HAVE_TERMIOS or HAVE_TERMIO */ +} + +int +DEFUN (terminal_state_buffered_p, (s), Ttty_state * s) +{ +#if defined(HAVE_TERMIOS) || defined(HAVE_TERMIO) + return ((((TIO (s)) -> c_lflag) & ICANON) != 0); +#else /* not HAVE_TERMIOS nor HAVE_TERMIO */ +#ifdef HAVE_BSD_TTY_DRIVER + return (((s -> sg . sg_flags) & (CBREAK | RAW)) == 0); #endif /* HAVE_BSD_TTY_DRIVER */ #endif /* HAVE_TERMIOS or HAVE_TERMIO */ } @@ -158,17 +213,19 @@ DEFUN (terminal_state_nonbuffered, (s, polling), Ttty_state * s AND int polling) { #if defined(HAVE_TERMIOS) || defined(HAVE_TERMIO) -#ifdef HAVE_TERMIOS - struct termios * tio = s; -#else - struct termio * tio = (& (s -> tio)); -#endif - (tio -> c_lflag) &=~ (ICANON | ECHO); - ((tio -> c_cc) [VMIN]) = (polling ? 0 : 1); - ((tio -> c_cc) [VTIME]) = 0; + ((TIO (s)) -> c_lflag) &=~ (ICANON | ECHO); + ((TIO (s)) -> c_lflag) |= 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]) = (polling ? 0 : 1); + (((TIO (s)) -> c_cc) [VTIME]) = 0; #else /* not HAVE_TERMIOS nor HAVE_TERMIO */ #ifdef HAVE_BSD_TTY_DRIVER - (s -> sg . sg_flags) |= CBREAK; + (s -> sg . sg_flags) &=~ (ECHO | CRMOD); + (s -> sg . sg_flags) |= (ANYP | CBREAK); + (s -> lmode) |= (LPASS8 | LNOFLSH); #endif /* HAVE_BSD_TTY_DRIVER */ #endif /* HAVE_TERMIOS or HAVE_TERMIO */ } @@ -177,17 +234,40 @@ void DEFUN (terminal_state_raw, (s), Ttty_state * s) { #if defined(HAVE_TERMIOS) || defined(HAVE_TERMIO) -#ifdef HAVE_TERMIOS - struct termios * tio = s; -#else - struct termio * tio = (& (s -> tio)); -#endif - (tio -> c_lflag) &=~ (ICANON | ECHO | ISIG); - ((tio -> c_cc) [VMIN]) = 1; - ((tio -> c_cc) [VTIME]) = 0; + ((TIO (s)) -> c_lflag) &=~ (ICANON | ECHO | ISIG); + ((TIO (s)) -> c_iflag) |= IGNBRK; + ((TIO (s)) -> c_iflag) &=~ (ICRNL | IXON | ISTRIP); + (((TIO (s)) -> c_cc) [VMIN]) = 1; + (((TIO (s)) -> c_cc) [VTIME]) = 0; #else /* not HAVE_TERMIOS nor HAVE_TERMIO */ #ifdef HAVE_BSD_TTY_DRIVER - (s -> sg . sg_flags) |= RAW; + (s -> sg . sg_flags) &=~ (ECHO | CRMOD); + (s -> sg . sg_flags) |= (ANYP | RAW); + (s -> lmode) |= (LPASS8 | LNOFLSH); +#endif /* HAVE_BSD_TTY_DRIVER */ +#endif /* HAVE_TERMIOS or HAVE_TERMIO */ +} + +void +DEFUN (terminal_state_buffered, (s, channel), + Ttty_state * s AND + Tchannel channel) +{ + Ttty_state * os = (& (TERMINAL_ORIGINAL_STATE (channel))); +#if defined(HAVE_TERMIOS) || defined(HAVE_TERMIO) + ((TIO (s)) -> c_lflag) = ((TIO (os)) -> c_lflag); + ((TIO (s)) -> c_iflag) = ((TIO (os)) -> c_iflag); + ((TIO (s)) -> c_cflag) = ((TIO (os)) -> c_cflag); + (((TIO (s)) -> c_cc) [VMIN]) = (((TIO (os)) -> c_cc) [VMIN]); + (((TIO (s)) -> c_cc) [VTIME]) = (((TIO (os)) -> c_cc) [VTIME]); +#else /* not HAVE_TERMIOS nor HAVE_TERMIO */ +#ifdef HAVE_BSD_TTY_DRIVER + (s -> sg . sg_flags) = + (((s -> sg . sg_flags) &~ (ECHO | CRMOD | ANYP | CBREAK | RAW)) + | ((os -> sg . sg_flags) & (ECHO | CRMOD | ANYP | CBREAK | RAW))); + (s -> lmode) = + (((s -> lmode) &~ (LPASS8 | LNOFLSH)) + | ((os -> lmode) & (LPASS8 | LNOFLSH))); #endif /* HAVE_BSD_TTY_DRIVER */ #endif /* HAVE_TERMIOS or HAVE_TERMIO */ } @@ -301,6 +381,87 @@ DEFUN (OS_terminal_char_ready_p, (channel, delay), #endif /* HAVE_TERMIO or HAVE_TERMIOS */ #endif /* HAVE_FIONREAD */ +unsigned int +DEFUN (OS_terminal_get_ispeed, (channel), Tchannel channel) +{ + Ttty_state s; + get_terminal_state (channel, (&s)); + return (terminal_state_get_ispeed (&s)); +} + +unsigned int +DEFUN (OS_terminal_get_ospeed, (channel), Tchannel channel) +{ + Ttty_state s; + get_terminal_state (channel, (&s)); + return (terminal_state_get_ospeed (&s)); +} + +static unsigned int baud_convert [] = +#ifdef _HPUX + { + 0, 50, 75, 110, 135, 150, 200, 300, 600, 900, 1200, + 1800, 2400, 3600, 4800, 7200, 9600, 19200, 38400 + }; +#else + { + 0, 50, 75, 110, 135, 150, 200, 300, 600, 1200, + 1800, 2400, 4800, 9600, 19200, 38400 + }; +#endif + +#define BAUD_CONVERT_LENGTH \ + ((sizeof (baud_convert)) / (sizeof (baud_convert[0]))) + +unsigned int +DEFUN (arg_baud_index, (argument), unsigned int argument) +{ + return (arg_index_integer (argument, BAUD_CONVERT_LENGTH)); +} + +unsigned int +DEFUN (OS_baud_index_to_rate, (index), unsigned int index) +{ + return (baud_convert [index]); +} + +int +DEFUN (OS_baud_rate_to_index, (rate), unsigned int rate) +{ + unsigned int * scan = baud_convert; + unsigned int * end = (scan + BAUD_CONVERT_LENGTH); + while (scan < end) + if ((*scan++) = rate) + return ((scan - 1) - baud_convert); + return (-1); +} + +int +DEFUN (OS_terminal_cooked_output_p, (channel), Tchannel channel) +{ + Ttty_state s; + get_terminal_state (channel, (&s)); + return (terminal_state_cooked_output_p (&s)); +} + +void +DEFUN (OS_terminal_raw_output, (channel), Tchannel channel) +{ + Ttty_state s; + get_terminal_state (channel, (&s)); + terminal_state_raw_output (&s); + set_terminal_state (channel, (&s)); +} + +void +DEFUN (OS_terminal_cooked_output, (channel), Tchannel channel) +{ + Ttty_state s; + get_terminal_state (channel, (&s)); + terminal_state_cooked_output ((&s), channel); + set_terminal_state (channel, (&s)); +} + int DEFUN (OS_terminal_buffered_p, (channel), Tchannel channel) { diff --git a/v7/src/microcode/version.h b/v7/src/microcode/version.h index b38e38487..f8b8940f0 100644 --- a/v7/src/microcode/version.h +++ b/v7/src/microcode/version.h @@ -1,6 +1,6 @@ /* -*-C-*- -$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/Attic/version.h,v 11.48 1990/10/07 13:34:49 cph Exp $ +$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/Attic/version.h,v 11.49 1990/10/16 20:54:01 cph Exp $ Copyright (c) 1988, 1989, 1990 Massachusetts Institute of Technology @@ -46,7 +46,7 @@ MIT in each case. */ #define VERSION 11 #endif #ifndef SUBVERSION -#define SUBVERSION 48 +#define SUBVERSION 49 #endif #ifndef UCODE_TABLES_FILENAME diff --git a/v7/src/microcode/x11term.c b/v7/src/microcode/x11term.c index 69d9f2c52..7043fe078 100644 --- a/v7/src/microcode/x11term.c +++ b/v7/src/microcode/x11term.c @@ -1,6 +1,6 @@ /* -*-C-*- -$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/x11term.c,v 1.11 1990/10/07 13:34:08 cph Exp $ +$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/x11term.c,v 1.12 1990/10/16 20:54:09 cph Exp $ Copyright (c) 1989, 1990 Massachusetts Institute of Technology @@ -690,15 +690,13 @@ DEFINE_PRIMITIVE ("XTERM-CLEAR-RECTANGLE!", Prim_xterm_clear_rectangle, 6, 6, 0) } static void -DEFUN (xterm_scroll_lines_up, - (xw, x_start, x_end, y_start, y_end, lines, hl), +DEFUN (xterm_scroll_lines_up, (xw, x_start, x_end, y_start, y_end, lines), struct xwindow * xw AND unsigned int x_start AND unsigned int x_end AND unsigned int y_start AND unsigned int y_end AND - unsigned int lines AND - unsigned int hl) + unsigned int lines) { { unsigned int y_to = y_start; @@ -716,14 +714,13 @@ DEFUN (xterm_scroll_lines_up, (((y_end - y_start) - lines) * (FONT_HEIGHT (XW_FONT (xw)))), (XTERM_X_PIXEL (xw, x_start)), (XTERM_Y_PIXEL (xw, y_start))); - xterm_clear_rectangle (xw, x_start, x_end, (y_end - lines), y_end, hl); } -DEFINE_PRIMITIVE ("XTERM-SCROLL-LINES-UP", Prim_xterm_scroll_lines_up, 7, 7, - "(XTERM-SCROLL-LINES-UP XTERM X-START X-END Y-START Y-END LINES HL)\n\ -Scroll the contents of the region up by LINES, clearing with HL.") +DEFINE_PRIMITIVE ("XTERM-SCROLL-LINES-UP", Prim_xterm_scroll_lines_up, 6, 6, + "(XTERM-SCROLL-LINES-UP XTERM X-START X-END Y-START Y-END LINES)\n\ +Scroll the contents of the region up by LINES.") { - PRIMITIVE_HEADER (7); + PRIMITIVE_HEADER (6); { struct xwindow * xw = (x_window_arg (1)); unsigned int x_end = (arg_index_integer (3, ((XW_X_CSIZE (xw)) + 1))); @@ -731,21 +728,18 @@ Scroll the contents of the region up by LINES, clearing with HL.") unsigned int y_end = (arg_index_integer (5, ((XW_Y_CSIZE (xw)) + 1))); unsigned int y_start = (arg_index_integer (4, (y_end + 1))); unsigned int lines = (arg_index_integer (6, ((y_end - y_start) + 1))); - unsigned int hl = (HL_ARG (7)); if ((lines > 0) && (x_start < x_end) && (y_start < y_end)) { unsigned int y_mid = (y_start + lines); if (CURSOR_IN_RECTANGLE (xw, x_start, x_end, y_mid, y_end)) { xterm_erase_cursor (xw); - xterm_scroll_lines_up - (xw, x_start, x_end, y_start, y_end, lines, hl); + xterm_scroll_lines_up (xw, x_start, x_end, y_start, y_end, lines); xterm_draw_cursor (xw); } else { - xterm_scroll_lines_up - (xw, x_start, x_end, y_start, y_end, lines, hl); + xterm_scroll_lines_up (xw, x_start, x_end, y_start, y_end, lines); if (CURSOR_IN_RECTANGLE (xw, x_start, x_end, y_start, y_mid)) { (XW_CURSOR_VISIBLE_P (xw)) = 0; @@ -758,15 +752,13 @@ Scroll the contents of the region up by LINES, clearing with HL.") } static void -DEFUN (xterm_scroll_lines_down, - (xw, x_start, x_end, y_start, y_end, lines, hl), +DEFUN (xterm_scroll_lines_down, (xw, x_start, x_end, y_start, y_end, lines), struct xwindow * xw AND unsigned int x_start AND unsigned int x_end AND unsigned int y_start AND unsigned int y_end AND - unsigned int lines AND - unsigned int hl) + unsigned int lines) { { unsigned int y_to = y_end; @@ -784,14 +776,13 @@ DEFUN (xterm_scroll_lines_down, (((y_end - y_start) - lines) * (FONT_HEIGHT (XW_FONT (xw)))), (XTERM_X_PIXEL (xw, x_start)), (XTERM_Y_PIXEL (xw, (y_start + lines)))); - xterm_clear_rectangle (xw, x_start, x_end, y_start, (y_start + lines), hl); } -DEFINE_PRIMITIVE ("XTERM-SCROLL-LINES-DOWN", Prim_xterm_scroll_lines_down, 7, 7, - "(XTERM-SCROLL-LINES-DOWN XTERM X-START X-END Y-START Y-END LINES HL)\n\ -Scroll the contents of the region down by LINES, clearing with HL.") +DEFINE_PRIMITIVE ("XTERM-SCROLL-LINES-DOWN", Prim_xterm_scroll_lines_down, 6, 6, + "(XTERM-SCROLL-LINES-DOWN XTERM X-START X-END Y-START Y-END LINES)\n\ +Scroll the contents of the region down by LINES.") { - PRIMITIVE_HEADER (7); + PRIMITIVE_HEADER (6); { struct xwindow * xw = (x_window_arg (1)); unsigned int x_end = (arg_index_integer (3, ((XW_X_CSIZE (xw)) + 1))); @@ -799,7 +790,6 @@ Scroll the contents of the region down by LINES, clearing with HL.") unsigned int y_end = (arg_index_integer (5, ((XW_Y_CSIZE (xw)) + 1))); unsigned int y_start = (arg_index_integer (4, (y_end + 1))); unsigned int lines = (arg_index_integer (6, ((y_end - y_start) + 1))); - unsigned int hl = (HL_ARG (7)); if ((lines > 0) && (x_start < x_end) && (y_start < y_end)) { unsigned int y_mid = (y_end - lines); @@ -807,13 +797,13 @@ Scroll the contents of the region down by LINES, clearing with HL.") { xterm_erase_cursor (xw); xterm_scroll_lines_down - (xw, x_start, x_end, y_start, y_end, lines, hl); + (xw, x_start, x_end, y_start, y_end, lines); xterm_draw_cursor (xw); } else { xterm_scroll_lines_down - (xw, x_start, x_end, y_start, y_end, lines, hl); + (xw, x_start, x_end, y_start, y_end, lines); if (CURSOR_IN_RECTANGLE (xw, x_start, x_end, y_mid, y_end)) { (XW_CURSOR_VISIBLE_P (xw)) = 0; diff --git a/v8/src/microcode/version.h b/v8/src/microcode/version.h index e64dc250f..48bf2ac26 100644 --- a/v8/src/microcode/version.h +++ b/v8/src/microcode/version.h @@ -1,6 +1,6 @@ /* -*-C-*- -$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v8/src/microcode/version.h,v 11.48 1990/10/07 13:34:49 cph Exp $ +$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v8/src/microcode/version.h,v 11.49 1990/10/16 20:54:01 cph Exp $ Copyright (c) 1988, 1989, 1990 Massachusetts Institute of Technology @@ -46,7 +46,7 @@ MIT in each case. */ #define VERSION 11 #endif #ifndef SUBVERSION -#define SUBVERSION 48 +#define SUBVERSION 49 #endif #ifndef UCODE_TABLES_FILENAME