scsh-0.5/scsh/next/tty-consts.scm

273 lines
9.3 KiB
Scheme

;;; Constant definitions for tty control code (POSIX termios).
;;; Copyright (c) 1995 by Brian Carlstrom.
;;; Largely rehacked by Olin.
;;; These constants are for NeXTSTEP 3.x,
;;; and are taken from /usr/include/bsd/sys/termios.h and
;;; /usr/include/bsd/sys/ttydev.h
;;; Non-standard (POSIX, SVR4, 4.3+BSD) things:
;;; - Useless ttychar/quote char.
;;; - Two extra newline delay values
;;; - Some control and local flags:
;;; ttyc/2-stop-bits-when-110-baud stopb110
;;; ttyc/parity0 par0
;;; ttyc/parity1 par1
;;; ttyl/crt-delete echocrt
;;; ttyl/xlcase xlcase Vas ist das?
;;; ttyl/xeucbksp xeucbksp 'n das?
;;; - Some baud rates
;;; Special Control Characters
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Indices into the c_cc[] character array.
;;; Name Subscript Enabled by
;;; ---- --------- ----------
;;; POSIX
(define ttychar/eof 0) ; ^d icanon
(define ttychar/eol 1) ; icanon
(define ttychar/delete-char 2) ; ^? icanon
(define ttychar/delete-line 3) ; ^u icanon
(define ttychar/interrupt 4) ; ^c isig
(define ttychar/quit 5) ; ^\ isig
(define ttychar/suspend 6) ; ^z isig
(define ttychar/start 7) ; ^q ixon, ixoff
(define ttychar/stop 8) ; ^s ixon, ixoff
(define ttychar/min 9) ; !icanon ; Not exported
(define ttychar/time 10) ; !icanon ; Not exported
;;; SVR4 & 4.3+BSD
(define ttychar/delete-word 11) ; ^w icanon
(define ttychar/reprint 12) ; ^r icanon
(define ttychar/literal-next 13) ; ^v iexten
(define ttychar/discard 14) ; ^o iexten
(define ttychar/delayed-suspend 15) ; ^y isig
(define ttychar/eol2 #f) ; icanon
;;; 4.3+BSD
(define ttychar/status #f) ; ^t icanon
;;; NeXT
(define ttychar/quote 16) ; icanon
;;; Length of control-char string -- *Not Exported*
(define num-ttychars 17)
;;; Magic "disable feature" tty character
(define disable-tty-char (ascii->char #xff))
;;; Flags controllling input processing
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; POSIX
(define ttyin/ignore-break #x0001) ; ignbrk
(define ttyin/interrupt-on-break #x0002) ; brkint
(define ttyin/ignore-bad-parity-chars #x0004) ; ignpar
(define ttyin/mark-parity-errors #x0008) ; parmrk
(define ttyin/check-parity #x0010) ; inpck
(define ttyin/7bits #x0020) ; istrip
(define ttyin/nl->cr #x0040) ; inlcr
(define ttyin/ignore-cr #x0080) ; igncr
(define ttyin/cr->nl #x0100) ; icrnl
(define ttyin/output-flow-ctl #x0200) ; ixon
(define ttyin/input-flow-ctl #x0400) ; ixoff
;;; SVR4 & 4.3+BSD
(define ttyin/xon-any #x0800) ; ixany: Any char restarts after stop
(define ttyin/beep-on-overflow #x2000) ; imaxbel: queue full => ring bell
;;; SVR4
(define ttyin/lowercase #f) ; iuclc: Map upper-case to lower case
;;; Flags controlling output processing
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; POSIX
(define ttyout/enable #x0001) ; opost: enable output processing
;;; SVR4 & 4.3+BSD
(define ttyout/nl->crnl #x0002) ; onlcr: map nl to cr-nl
;;; 4.3+BSD
(define ttyout/discard-eot #f) ; onoeot
(define ttyout/expand-tabs #f) ; oxtabs (NOT xtabs)
;;; SVR4
(define ttyout/cr->nl #f) ; ocrnl
(define ttyout/fill-w/del #f) ; ofdel
(define ttyout/delay-w/fill-char #f) ; ofill
(define ttyout/uppercase #f) ; olcuc
(define ttyout/nl-does-cr #f) ; onlret
(define ttyout/no-col0-cr #f) ; onocr
;;; Newline delay
(define ttyout/nl-delay #x0300) ; mask (nldly)
(define ttyout/nl-delay0 #x0000)
(define ttyout/nl-delay1 #x0100) ; tty 37
(define ttyout/nl-delay2 #x0200) ; vt05 Non-standard
(define ttyout/nl-delay3 #x0300) ; Non-standard
;;; Horizontal-tab delay
(define ttyout/tab-delay #x0c00) ; mask (tabdly)
(define ttyout/tab-delay0 #x0000)
(define ttyout/tab-delay1 #x0400) ; tty 37
(define ttyout/tab-delay2 #x0800)
(define ttyout/tab-delayx #x0c00) ; Expand tabs (xtabs, tab3)
;;; Carriage-return delay
(define ttyout/cr-delay #x3000) ; mask (crdly)
(define ttyout/cr-delay0 #x0000)
(define ttyout/cr-delay1 #x1000) ; tn 300
(define ttyout/cr-delay2 #x2000) ; tty 37
(define ttyout/cr-delay3 #x3000) ; concept 100
;;; Vertical tab delay
(define ttyout/vtab-delay #x4000) ; mask (vtdly)
(define ttyout/vtab-delay0 #x0000)
(define ttyout/vtab-delay1 #x4000) ; tty 37
;;; Backspace delay
(define ttyout/bs-delay #x8000) ; mask (bsldy)
(define ttyout/bs-delay0 #x0000)
(define ttyout/bs-delay1 #x8000)
;;; Form-feed delay -- appears to be rolled into the vertical-tab delay.
(define ttyout/ff-delay ttyout/vtab-delay) ; mask (ffdly)
(define ttyout/ff-delay0 ttyout/vtab-delay0)
(define ttyout/ff-delay1 ttyout/vtab-delay1)
(define ttyout/all-delay
(bitwise-ior (bitwise-ior (bitwise-ior ttyout/nl-delay ttyout/tab-delay)
(bitwise-ior ttyout/cr-delay ttyout/vtab-delay))
(bitwise-ior ttyout/bs-delay ttyout/ff-delay)))
;;; Control flags - hacking the serial-line.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; POSIX
(define ttyc/char-size #x0300) ; csize: character size mask
(define ttyc/char-size5 #x0000) ; 5 bits (cs5)
(define ttyc/char-size6 #x0100) ; 6 bits (cs6)
(define ttyc/char-size7 #x0200) ; 7 bits (cs7)
(define ttyc/char-size8 #x0300) ; 8 bits (cs8)
(define ttyc/2-stop-bits #x0400) ; cstopb: Send 2 stop bits.
(define ttyc/enable-read #x0800) ; cread: Enable receiver.
(define ttyc/enable-parity #x1000) ; parenb
(define ttyc/odd-parity #x2000) ; parodd
(define ttyc/hup-on-close #x4000) ; hupcl: Hang up on last close.
(define ttyc/no-modem-sync #x8000) ; clocal: Ignore modem lines.
;;; 4.3+BSD
(define ttyc/ignore-flags #x0001); cignore: ignore control flags
(define ttyc/CTS-output-flow-ctl #f) ; ccts_oflow: CTS flow control of output
(define ttyc/RTS-input-flow-ctl #f) ; crts_iflow: RTS flow control of input
(define ttyc/carrier-flow-ctl #f) ; mdmbuf
;;; NeXT
(define ttyc/2-stop-bits-when-110-baud #x010000) ; stopb110
(define ttyc/parity0 #x20000) ; par0
(define ttyc/parity1 #x40000) ; par1
;;; Local flags -- hacking the tty driver / user interface.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; POSIX
(define ttyl/visual-delete #x000002) ; echoe: Visually erase chars
(define ttyl/echo-delete-line #x000004) ; echok: Echo nl after line kill
(define ttyl/echo #x000008) ; echo: Enable echoing
(define ttyl/echo-nl #x000010) ; echonl: Echo nl even if echo is off
(define ttyl/canonical #x000020) ; icanon: Canonicalize input
(define ttyl/enable-signals #x000040) ; isig: Enable ^c, ^z signalling
(define ttyl/extended #x000080) ; iexten: Enable extensions
(define ttyl/ttou-signal #x400000) ; tostop: SIGTTOU on background output
(define ttyl/no-flush-on-interrupt #x80000000) ; noflsh
;;; SVR4 & 4.3+BSD
(define ttyl/visual-delete-line #x001) ; echoke: visually erase a line-kill
(define ttyl/hardcopy-delete #x200) ; echoprt: visual erase for hardcopy
(define ttyl/echo-ctl #x400) ; echoctl: echo control chars as "^X"
(define ttyl/flush-output #f) ; flusho: output is being flushed
(define ttyl/reprint-unread-chars #f) ; pendin: retype pending input
;;; 4.3+BSD
(define ttyl/alt-delete-word #x800) ; altwerase
(define ttyl/no-kernel-status #f) ; nokerninfo: no kernel status on ^T
;;; SVR4
(define ttyl/case-map #f) ; xcase: canonical upper/lower presentation
;;; NeXT
(define ttyl/crt-delete #x00000100) ; visual erase does "\b \b"
(define ttyl/xlcase #x04000000) ; Vas ist das?
(define ttyl/xeucbksp #x08000000) ; 'n das?
;;; NOTE: xlcase and xeucbksp are in the NeXT <termios.h>, but don't appear
;;; in the tty(4) or termios(4) man pages. Where are they documented?
;;; 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)
(define baud/exta baud/19200) ; Non-standard
(define baud/extb baud/38400) ; Non-standard
(define baud/14400 16) ; Non-standard
(define baud/28800 17) ; Non-standard
(define baud/43200 18) ; Non-standard
(define baud/57600 19) ; Non-standard
;;; Rather cheesy mechanism here.
;;; Vector of lists because some OS's define EXTA and EXTB to be
;;; the same code as 19.2k and 38.4k baud.
(define baud-rates '#((0) (50) (75) (110) (134) (150)
(200) (300) (600) (1200) (1800) (2400)
(4800) (9600) (19200 exta) (38400 extb)
(14400) (28800) (43200) (57600)))
;;; tcflush() constants
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(define %flush-tty/input 0) ; TCIFLUSH
(define %flush-tty/output 1) ; TCOFLUSH
(define %flush-tty/both 2) ; TCIOFLUSH
;;; tcflow() constants
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(define %tcflow/stop-out 1) ; TCOOFF
(define %tcflow/start-out 2) ; TCOON
(define %tcflow/stop-in 3) ; TCIOFF
(define %tcflow/start-in 4) ; TCION
;;; tcsetattr() constants
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(define %set-tty-info/now 0) ; TCSANOW Make change immediately.
(define %set-tty-info/drain 1) ; TCSADRAIN Drain output, then change.
(define %set-tty-info/flush 2) ; TCSAFLUSH Drain output, flush input.