From 195691c43801343a82a8ea9cd118453153853cf7 Mon Sep 17 00:00:00 2001 From: shivers Date: Tue, 17 Oct 1995 04:33:40 +0000 Subject: [PATCH] *** empty log message *** --- scsh/tty-consts.scm | 185 +++++++++++++++++++++++++++++++++++++++++++- scsh/tty.scm | 48 ++++++------ 2 files changed, 209 insertions(+), 24 deletions(-) diff --git a/scsh/tty-consts.scm b/scsh/tty-consts.scm index 9bc149b..ac04eb6 100644 --- a/scsh/tty-consts.scm +++ b/scsh/tty-consts.scm @@ -1 +1,184 @@ -;;; Constant definitions for tty control code (POSIX termios). ;;; Copyright (c) 1995 by Brian Carlstrom. ;;; Largely rehacked by Olin. ;;; Special Control Characters ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Indices into the c_cc[] character array. ;;; Name Subscript Enabled by ;;; ---- --------- ---------- ;; POSIX (define ttychar/eof 0) ; icanon (define ttychar/eol 1) ; icanon (define ttychar/erase 2) ; icanon (define ttychar/kill 3) ; icanon (define ttychar/intr 4) ; isig (define ttychar/quit 5) ; isig (define ttychar/susp 6) ; isig (define ttychar/start 7) ; ixon, ixoff (define ttychar/stop 8) ; ixon, ixoff (define ttychar/min 9) ; !icanon ; Not exported (define ttychar/time 10) ; !icanon ; Not exported ;; NeXT (define ttychar/word-erase 11) ; icanon (define ttychar/reprint 12) ; icanon (define ttychar/lnext 13) ; iexten (Vas ist das?) (define ttychar/discard 14) ; iexten ('n das?) (define ttychar/dsusp 15) ; isig (define ttychar/quote 16) ; icanon ;; Number of Control Characters - *Not Exported* (define num-ttychars 17) ;;; Flags controllling input processing ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; POSIX (define ttyin/ignore-break #x00000001) ; ignbrk (define ttyin/interrupt-on-break #x00000002) ; brkint (define ttyin/ignore-bad-parity-chars #x00000004) ; ignpar (define ttyin/mark-parity-errors #x00000008) ; parmrk (define ttyin/enable-parity #x00000010) ; inpck (define ttyin/strip-8th #x00000020) ; istrip (define ttyin/nl->cr #x00000040) ; inlcr (define ttyin/ignore-cr #x00000080) ; igncr (define ttyin/cr->nl #x00000100) ; icrnl (define ttyin/output-flow-ctl #x00000200) ; ixon (define ttyin/input-flow-ctl #x00000400) ; ixoff ;;Next (define ttyin/xon-any #x00000800) ; ixany: Any char will restart after stop. (define ttyin/beep-on-overflow #x00002000) ; imaxbel: Ring bell on input queue full ;;; Flags controlling output processing ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; POSIX (define ttyout/process #x00000001) ; opost: enable output processing. ;; NeXT (define ttyout/nl->crnl #x00000002) ; onlcr: map nl to cr-nl (ala crmod) ; use the same bits as old delay flags (define ttyout/nl-delay #x00000300) ; \n delay (define ttyout/nl-delay0 #x00000000) (define ttyout/nl-delay1 #x00000100) ; tty 37 (define ttyout/nl-delay2 #x00000200) ; vt05 (define ttyout/nl-delay3 #x00000300) (define ttyout/tab-delay #x00000c00) ; horizontal tab delay (define ttyout/tab-delay0 #x00000000) (define ttyout/tab-delay1 #x00000400) ; tty 37 (define ttyout/tab-delay2 #x00000800) ;;; HEY -- This is identical to ttout/tab-delay! (define ttyout/expand-tabs #x00000c00) ; xtabs: expand tabs on output (define ttyout/cr-delay #x00003000) ; \r delay (define ttyout/cr-delay0 #x00000000) (define ttyout/cr-delay1 #x00001000) ; tn 300 (define ttyout/cr-delay2 #x00002000) ; tty 37 (define ttyout/cr-delay3 #x00003000) ; concept 100 (define ttyout/vtab-delay #x00004000) ; vertical tab delay (define ttyout/vtab-delay0 #x00000000) (define ttyout/vtab-delay1 #x00004000) ; tty 37 (define ttyout/bs-delay #x00008000) ; \b delay (define ttyout/bs-delay0 #x00000000) (define ttyout/bs-delay1 #x00008000) (define ttyout/all-delay (bitwise-ior (bitwise-ior (bitwise-ior ttyout/nl-delay ttyout/tab-delay) (bitwise-ior ttyout/cr-delay ttyout/vtab-delay)) ttyout/bsdelay)) ;;; Control flags - hardware control of terminal ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; POSIX (define ttyc/char-size #x00000300) ; csize: character size mask (define ttyc/char-size5 #x00000000) ; 5 bits (cs5) (define ttyc/char-size6 #x00000100) ; 6 bits (cs6) (define ttyc/char-size7 #x00000200) ; 7 bits (cs7) (define ttyc/char-size8 #x00000300) ; 8 bits (cs8) (define ttyc/2-stop-bits #x00000400) ; cstopb: Send 2 stop bits. (define ttyc/read #x00000800) ; cread: Enable receiver. (define ttyc/enable-parity #x00001000) ; parenb (define ttyc/odd-parity #x00002000) ; parodd (define ttyc/hup-on-close #x00004000) ; hupcl: Hang up on last close. (define ttyc/no-modem-sync #x00008000) ; local: Ignore modem lines. ;; NeXT (define ttyc/ignore #x00000001) ; ignore control flags (define ttyc/stopb110 #x00010000) ; VAS IST DAS? -Olin (define ttyc/mark-parity #x00020000) ; par1 (define ttyc/space-parity #x00040000) ; par0 ;;; "Local" flags - dumping ground for other state ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Warning: some flags in this structure begin with the ;; letter "I" and look like they belong in the input flag. ;; POSIX (define ttyl/echo-erase #x00000002) ; echoe: Visually erase chars. (define ttyl/echo-kill #x00000004) ; echok: Echo nl after line kill. (define ttyl/echo #x00000008) ; echo: Enable echoing. (define ttyl/echo-nl #x00000010) ; echonl: Echo nl even if echo is off. (define ttyl/icanon #x00000020) ; icanon: Canonicalize input. (define ttyl/enable-signals #x00000040) ; isig: Enable ^c, ^z signalling. (define ttyl/extended #x00000080) ; iexten: Enable extensions. (define ttyl/ttou-signal #x00400000) ; itostop: Send SIGTTOU on background output. (define ttyl/no-flush-on-interrupt #x80000000) ; noflsh: Don't flush after interrupt. ;; NeXT (define ttyl/visual-echo-kill #x00000001) ; echoke: visually erase line kill (define ttyl/echo-crt #x00000100) ; visual erase mode for crt (define ttyl/echo-printer #x00000200) ; visual erase mode for hardcopy (define ttyl/echo-ctl #x00000400) ; echo control chars as ^(char) (define ttyl/alt-word-erase #x00000800) ; use alternate werase algorithm (define ttyl/carrier-sync #x00100000) ; mdmbuf flow control output via carrier (define ttyl/xlcase #x04000000) ; VAS IST DAS? (define ttyl/xeucbksp #x08000000) ; VAS IST DAS? ;;; NOTE: altwerase xlcase and xeucbksp don't appear in the NeXT tty(4) man ;;; page. Where do they appear? ;;; Baud Rates (define baud/0 0) (define baud/50 1) (define baud/75 2) (define baud/110 3) (define baud/134 4) (define baud/150 5) (define baud/200 6) (define baud/300 7) (define baud/600 8) (define baud/1200 9) (define baud/1800 10) (define baud/2400 11) (define baud/4800 12) (define baud/9600 13) (define baud/19200 14) (define baud/38400 15) ;;; tcflush magic ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (define %flush-tty/input ...) ; TCIFLUSH (define %flush-tty/output ...) ; TCOFLUSH (define %flush-tty/both ...) ; TCIOFLUSH ;;; tcflow magic ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (define %tcflow/start-out ...) ; TCOON (define %tcflow/stop-out ...) ; TCOOFF (define %tcflow/start-in ...) ; TCION (define %tcflow/stop-in ...) ; TCIOFF \ No newline at end of file +;;; Constant definitions for tty control code (POSIX termios). +;;; Copyright (c) 1995 by Brian Carlstrom. +;;; Largely rehacked by Olin. + +;;; Values taken from HP-UX /usr/include/sys/termio.h. + +;;; Special Control Characters +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; Indices into the c_cc[] character array. + +;;; Name Subscript Enabled by +;;; ---- --------- ---------- +;; POSIX +(define ttychar/intr 0) ; isig +(define ttychar/quit 1) ; isig +(define ttychar/erase 2) ; icanon +(define ttychar/kill 3) ; icanon +(define ttychar/eof 4) ; icanon +(define ttychar/eol 5) ; icanon + +(define ttychar/min 11) ; !icanon ; Not exported +(define ttychar/time 12) ; !icanon ; Not exported +(define ttychar/susp 13) ; isig +(define ttychar/start 14) ; ixon, ixoff +(define ttychar/stop 15) ; ixon, ixoff + +;; Number of Control Characters - *Not Exported* +(define num-ttychars 16) + + +;;; Flags controllling input processing +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +;; POSIX +(define ttyin/ignore-break #x00000001) ; ignbrk +(define ttyin/interrupt-on-break #x00000002) ; brkint +(define ttyin/ignore-bad-parity-chars #x00000004) ; ignpar +(define ttyin/mark-parity-errors #x00000008) ; parmrk +(define ttyin/enable-parity #x00000010) ; inpck +(define ttyin/strip-8th #x00000020) ; istrip +(define ttyin/nl->cr #x00000040) ; inlcr +(define ttyin/ignore-cr #x00000080) ; igncr +(define ttyin/cr->nl #x00000100) ; icrnl +(define ttyin/output-flow-ctl #x00000400) ; ixon +(define ttyin/input-flow-ctl #x00001000) ; ixoff + +;; HP-UX +(define ttyin/xon-any #x00000800) ; _ixany: Any char will restart after stop. +(define ttyin/lowercase #x00002000) ; _iuclc: Map upper-case to lower-case. + + +;;; Flags controlling output processing +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; POSIX +(define ttyout/process #x00000001) ; opost: enable output processing. + +;; HP-UX +(define ttyout/nl->crnl #x00000002) ; onlcr: map nl to cr-nl +(define ttyout/uppercase ) ; olcuc +(define ttyout/cr->nl ) ; ocrnl +(define ttyout/no-col0-cr ) ; onocr +(define ttyout/nl-does-cr ) ; onlret +(define ttyout/delay-w/fill-char ) ; ofill +(define ttyout/fill-w/del ) ; ofdel + +; use the same bits as old delay flags +(define ttyout/nl-delay #x00000300) ; \n delay +(define ttyout/nl-delay0 #x00000000) +(define ttyout/nl-delay1 #x00000100) ; tty 37 +(define ttyout/nl-delay2 #x00000200) ; vt05 +(define ttyout/nl-delay3 #x00000300) + +(define ttyout/tab-delay #x00000c00) ; horizontal tab delay +(define ttyout/tab-delay0 #x00000000) +(define ttyout/tab-delay1 #x00000400) ; tty 37 +(define ttyout/tab-delay2 #x00000800) +(define ttyout/expand-tabs #x00000c00) ; xtabs: expand tabs on output + +(define ttyout/cr-delay #x00003000) ; \r delay +(define ttyout/cr-delay0 #x00000000) +(define ttyout/cr-delay1 #x00001000) ; tn 300 +(define ttyout/cr-delay2 #x00002000) ; tty 37 +(define ttyout/cr-delay3 #x00003000) ; concept 100 + +(define ttyout/vtab-delay #x00004000) ; vertical tab delay +(define ttyout/vtab-delay0 #x00000000) +(define ttyout/vtab-delay1 #x00004000) ; tty 37 + +(define ttyout/bs-delay #x00008000) ; \b delay +(define ttyout/bs-delay0 #x00000000) +(define ttyout/bs-delay1 #x00008000) + +(define ttyout/all-delay (bitwise-ior + (bitwise-ior + (bitwise-ior ttyout/nl-delay ttyout/tab-delay) + (bitwise-ior ttyout/cr-delay ttyout/vtab-delay)) + ttyout/bs-delay)) + + +;;; Control flags - hardware control of terminal +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +;; POSIX +(define ttyc/char-size #x00000300) ; csize: character size mask +(define ttyc/char-size5 #x00000000) ; 5 bits (cs5) +(define ttyc/char-size6 #x00000100) ; 6 bits (cs6) +(define ttyc/char-size7 #x00000200) ; 7 bits (cs7) +(define ttyc/char-size8 #x00000300) ; 8 bits (cs8) +(define ttyc/2-stop-bits #x00000400) ; cstopb: Send 2 stop bits. +(define ttyc/read #x00000800) ; cread: Enable receiver. +(define ttyc/enable-parity #x00001000) ; parenb +(define ttyc/odd-parity #x00002000) ; parodd +(define ttyc/hup-on-close #x00004000) ; hupcl: Hang up on last close. +(define ttyc/no-modem-sync #x00008000) ; local: Ignore modem lines. + +;; NeXT +(define ttyc/ignore #x00000001) ; ignore control flags +(define ttyc/stopb110 #x00010000) ; VAS IST DAS? -Olin +(define ttyc/mark-parity #x00020000) ; par1 +(define ttyc/space-parity #x00040000) ; par0 + + +;;; "Local" flags - dumping ground for other state +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; Warning: some flags in this structure begin with the +;; letter "I" and look like they belong in the input flag. + +;; POSIX +(define ttyl/echo-erase #x00000002) ; echoe: Visually erase chars. +(define ttyl/echo-kill #x00000004) ; echok: Echo nl after line kill. +(define ttyl/echo #x00000008) ; echo: Enable echoing. +(define ttyl/echo-nl #x00000010) ; echonl: Echo nl even if echo is off. +(define ttyl/icanon #x00000020) ; icanon: Canonicalize input. +(define ttyl/enable-signals #x00000040) ; isig: Enable ^c, ^z signalling. +(define ttyl/extended #x00000080) ; iexten: Enable extensions. +(define ttyl/ttou-signal #x00400000) ; itostop: Send SIGTTOU on background output. +(define ttyl/no-flush-on-interrupt #x80000000) ; noflsh: Don't flush after interrupt. + +;; NeXT +(define ttyl/visual-echo-kill #x00000001) ; echoke: visually erase line kill +(define ttyl/echo-crt #x00000100) ; visual erase mode for crt +(define ttyl/echo-printer #x00000200) ; visual erase mode for hardcopy +(define ttyl/echo-ctl #x00000400) ; echo control chars as ^(char) +(define ttyl/alt-word-erase #x00000800) ; use alternate werase algorithm +(define ttyl/carrier-sync #x00100000) ; mdmbuf flow control output via carrier +(define ttyl/xlcase #x04000000) ; VAS IST DAS? +(define ttyl/xeucbksp #x08000000) ; VAS IST DAS? + +;;; NOTE: altwerase xlcase and xeucbksp don't appear in the NeXT tty(4) man +;;; page. Where do they appear? + + +;;; Baud Rates +(define baud/0 0) +(define baud/50 1) +(define baud/75 2) +(define baud/110 3) +(define baud/134 4) +(define baud/150 5) +(define baud/200 6) +(define baud/300 7) +(define baud/600 8) +(define baud/1200 9) +(define baud/1800 10) +(define baud/2400 11) +(define baud/4800 12) +(define baud/9600 13) +(define baud/19200 14) +(define baud/38400 15) + +;;; tcflush magic +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(define %flush-tty/input 0) ; TCIFLUSH +(define %flush-tty/output 1) ; TCOFLUSH +(define %flush-tty/both 2) ; TCIOFLUSH + +;;; tcflow magic +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(define %tcflow/stop-out 0) ; TCOOFF +(define %tcflow/start-out 1) ; TCOON +(define %tcflow/stop-in 2) ; TCIOFF +(define %tcflow/start-in 3) ; TCION diff --git a/scsh/tty.scm b/scsh/tty.scm index 15f72e0..e9d7a8a 100644 --- a/scsh/tty.scm +++ b/scsh/tty.scm @@ -42,10 +42,10 @@ output-speed min time - ((disclose info) '(tty-info))) + ((disclose info) '("tty-info"))) (define tty-info? %tty-info?) -(define type/tty-info %type/tty-info) +(define type/tty-info type/%tty-info) (define tty-info:control-chars %tty-info:control-chars) (define tty-info:input-flags %tty-info:input-flags) @@ -55,6 +55,7 @@ (define tty-info:input-speed %tty-info:input-speed) (define tty-info:output-speed %tty-info:output-speed) (define tty-info:min %tty-info:min) +(define tty-info:time %tty-info:time) (define set-tty-info:control-chars set-%tty-info:control-chars) (define set-tty-info:input-flags set-%tty-info:input-flags) @@ -64,6 +65,7 @@ (define set-tty-info:input-speed set-%tty-info:input-speed) (define set-tty-info:output-speed set-%tty-info:output-speed) (define set-tty-info:min set-%tty-info:min) +(define set-tty-info:time set-%tty-info:time) (define (make-tty-info iflags oflags cflags lflags ispeed ospeed min time) (make-%tty-info (make-string num-ttychars (ascii->char 0)) @@ -108,8 +110,8 @@ ispeed ospeed) (define-foreign %tty-info/errno - (scheme_tty_info (integer fdes) - (string control-chars)) + (scheme_tcgetattr (integer fdes) + (string control-chars)) (to-scheme integer errno_or_false) integer integer integer integer @@ -164,21 +166,21 @@ %set-tty-info/errno) (define-foreign %set-tty-info/errno - (scheme_set_tty_info (integer fdes) - (integer option) - (string control-chars) - (integer iflag-hi8) - (integer iflag-lo24) - (integer oflag-hi8) - (integer oflag-lo24) - (integer cflag-hi8) - (integer cflag-lo24) - (integer lflag-hi8) - (integer lflag-lo24) - (integer ispeed) - (integer ospeed) - (integer min) - (integer time)) + (scheme_tcsetattr (integer fdes) + (integer option) + (string control-chars) + (integer iflag-hi8) + (integer iflag-lo24) + (integer oflag-hi8) + (integer oflag-lo24) + (integer cflag-hi8) + (integer cflag-lo24) + (integer lflag-hi8) + (integer lflag-lo24) + (integer ispeed) + (integer ospeed) + (integer min) + (integer time)) (to-scheme integer errno_or_false)) @@ -257,10 +259,10 @@ (lambda (fdport) (call/fdes fdport (lambda (fdes) (%tcflow fdes action))))) -(define start-tty-output (make-tty-flow-controller %tcflow/start-out)) -(define stop-tty-output (make-tty-flow-controller %tcflow/stop-out)))) -(define start-tty-input (make-tty-flow-controller %tcflow/start-in)) -(define stop-tty-input (make-tty-flow-controller %tcflow/stop-in)) +(define start-tty-output (make-flow-controller %tcflow/start-out)) +(define stop-tty-output (make-flow-controller %tcflow/stop-out)) +(define start-tty-input (make-flow-controller %tcflow/start-in)) +(define stop-tty-input (make-flow-controller %tcflow/stop-in)) (define-errno-syscall (%tcflow fdes action) %tcflow/errno)