;;; Constant definitions for tty control code (POSIX termios).
  Copyright ( c ) 1995 by   . See file COPYING .
  Largely rehacked by Olin .

  These constants are for IRIX ,
;;; and are taken from /usr/include/sys/termio.h
;;; 		   and /usr/include/sys/termios.h
;;; 		   and /usr/include/sys/ttydev.h (baud rates).

  Non - standard ( POSIX ,  , 4.3+BSD ) things :
;;; - Some of the baud rates.


;;; Special Control Characters 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;  Indices into the c_cc[] character array.

;;;	Name	     		Subscript	Enabled by 
;;;     ----         		---------	----------
;;;  POSIX
  ^d icanon
     icanon
  ^ ? icanon
(define ttychar/delete-line	3)		; ^u icanon
(define ttychar/interrupt	0)		; ^c isig
  ^\ isig
(define ttychar/suspend		10)		; ^z isig
  ^q ixon , ixoff
  ^s ixon , ixoff
(define ttychar/min		4)		;    !icanon	; Not exported
(define ttychar/time		5)		;    !icanon	; Not exported

  SVR4 & 4.3+BSD
   
(define ttychar/reprint 	12)		; ^r icanon
(define ttychar/literal-next	15)		; ^v iexten
(define ttychar/discard		13)		; ^o iexten
(define ttychar/delayed-suspend	11)		; ^y isig
     icanon

  4.3+BSD
(define ttychar/status		#f)		; ^t icanon 

;;; Length of control-char string -- *Not Exported*
(define	num-ttychars		23)

  Magic " disable feature " tty character
(define disable-tty-char (ascii->char #x00))	; _POSIX_VDISABLE

;;; Flags controllling input processing
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;  POSIX
(define ttyin/ignore-break		#o00001)	; ignbrk
(define ttyin/interrupt-on-break	#o00002)	; brkint
(define ttyin/ignore-bad-parity-chars	#o00004)	; ignpar
(define ttyin/mark-parity-errors	#o00010)	; parmrk
(define ttyin/check-parity		#o00020)	; inpck
(define ttyin/7bits			#o00040)	; istrip
(define ttyin/nl->cr			#o00100)	; inlcr
(define ttyin/ignore-cr			#o00200)	; igncr
(define ttyin/cr->nl			#o00400)	; icrnl
  ixon
(define ttyin/input-flow-ctl		#o10000)	; ixoff

  SVR4 & 4.3+BSD
(define ttyin/xon-any	       #o4000)	; ixany: Any char restarts after stop
(define ttyin/beep-on-overflow #o20000)	; imaxbel: queue full => ring bell

;;; SVR4
(define ttyin/lowercase	       #o1000)	; iuclc: Map upper-case to lower case


;;; Flags controlling output processing
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;  POSIX 
(define	ttyout/enable		 #o000001)  ; opost: enable output processing

  SVR4 & 4.3+BSD
  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		 #o000010)	; ocrnl
(define ttyout/fill-w/del	 #o000200)	; ofdel
(define ttyout/delay-w/fill-char #o000100)	; ofill
(define ttyout/uppercase	 #o000002)	; olcuc
(define ttyout/nl-does-cr	 #o000040)	; onlret
(define ttyout/no-col0-cr	 #o000020)	; onocr

;;; Newline delay
(define	ttyout/nl-delay		#o000400)	; mask (nldly)
(define	 ttyout/nl-delay0	#o000000)
  tty 37

;;; Horizontal-tab delay
(define	ttyout/tab-delay	#o014000)	; mask (tabdly)
(define	 ttyout/tab-delay0	#o000000)
  tty 37
(define	 ttyout/tab-delay2	#o010000)
(define	 ttyout/tab-delayx	#o014000)	; Expand tabs (xtabs, tab3)

;;; Carriage-return delay
(define	ttyout/cr-delay		#o003000)	; mask (crdly)
(define	 ttyout/cr-delay0	#o000000)
  tn 300
  tty 37
  concept 100

;;; Vertical tab delay 
  mask ( vtdly )
(define	 ttyout/vtab-delay0	#o000000)
  tty 37

;;; Backspace delay
  mask ( bsdly )
(define	 ttyout/bs-delay0	#o000000)
(define	 ttyout/bs-delay1	#o020000)

;;; Form-feed delay
(define ttyout/ff-delay		#o100000)	; mask (ffdly)
(define	 ttyout/ff-delay0	#o000000)
(define	 ttyout/ff-delay1	#o100000)

(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		#o00060)	; csize: character size mask 
  5 bits ( cs5 )
  6 bits (  )
  7 bits ( cs7 )
  8 bits ( cs8 )
  cstopb : Send 2 stop bits .
(define ttyc/enable-read	#o00200)	; cread: Enable receiver.
  parenb
  parodd
(define ttyc/hup-on-close	#o02000)	; hupcl: Hang up on last close.
(define ttyc/no-modem-sync	#o04000)	; clocal: Ignore modem lines.

   4.3+BSD
(define	ttyc/ignore-flags	 #f)	; 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

;;; Local flags -- hacking the tty driver / user interface.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;  POSIX
(define ttyl/visual-delete    #o020)	; echoe: Visually erase chars
  echok : Echo nl after line kill
(define ttyl/echo	      #o010)	; echo:  Enable echoing
  echonl : Echo nl even if echo is off
  icanon :  input
(define ttyl/enable-signals   #o001)	; isig: Enable ^c, ^z signalling
(define ttyl/extended	      #o400)	; iexten:  Enable extensions
  tostop : SIGTTOU on background output
(define ttyl/no-flush-on-interrupt #o200) ; noflsh

  SVR4 & 4.3+BSD
(define ttyl/visual-delete-line	#o04000) ; echoke: visually erase a line-kill 
(define ttyl/hardcopy-delete	#o02000) ; echoprt: visual erase for hardcopy 
(define ttyl/echo-ctl		#o01000) ; echoctl: echo control chars as "^X" 
(define ttyl/flush-output	#o20000) ; flusho: output is being flushed
(define ttyl/reprint-unread-chars #o40000) ; pendin: retype pending input

  4.3+BSD
(define ttyl/alt-delete-word	#f)	; altwerase
(define ttyl/no-kernel-status	#f)	; nokerninfo: no kernel status on ^T

;;; SVR4
(define ttyl/case-map #o4)	; xcase: canonical upper/lower presentation

;;; Vector of (speed . code) pairs.

(define baud-rates '#((0  . 0)		(1  . 50)	(2  .    75)
		      (3  . 110)	(4  . 134)	(5  .   150)
		      (6  . 200)	(7  . 300)	(8  .   600)
		      (9  . 1200)	(10 . 1800)     (11 .  2400)	
		      (12 . 4800)       (13 . 9600)	(14 .  19200)
		      (15 . 38400)	(14 . exta)     (15 .  extb)))

;;; tcflush() constants
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(define %flush-tty/input  0)	; TCIFLUSH
  TCOFLUSH
(define %flush-tty/both	  2)	; TCIOFLUSH


;;; tcflow() constants
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(define %tcflow/start-out 1)	; TCOON
(define %tcflow/stop-out  0)	; TCOOFF
(define %tcflow/start-in  3)	; TCION
(define %tcflow/stop-in   2)	; TCIOFF


;;; tcsetattr() constants
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

  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.

 Constant definitions for tty control code (POSIX termios).
 and are taken from /usr/include/sys/termio.h
 		   and /usr/include/sys/termios.h
 		   and /usr/include/sys/ttydev.h (baud rates).
 - Some of the baud rates.
 Special Control Characters 

  Indices into the c_cc[] character array.
	Name	     		Subscript	Enabled by 
     ----         		---------	----------
  POSIX
 ^u icanon
 ^c isig
 ^z isig
    !icanon	; Not exported
    !icanon	; Not exported
 ^r icanon
 ^v iexten
 ^o iexten
 ^y isig
 ^t icanon 
 Length of control-char string -- *Not Exported*
 _POSIX_VDISABLE
 Flags controllling input processing

  POSIX
 ignbrk
 brkint
 ignpar
 parmrk
 inpck
 istrip
 inlcr
 igncr
 icrnl
 ixoff
 ixany: Any char restarts after stop
 imaxbel: queue full => ring bell
 SVR4
 iuclc: Map upper-case to lower case
 Flags controlling output processing

  POSIX 
 opost: enable output processing
 onoeot
 oxtabs (NOT xtabs)
 SVR4
 ocrnl
 ofdel
 ofill
 olcuc
 onlret
 onocr
 Newline delay
 mask (nldly)
 Horizontal-tab delay
 mask (tabdly)
 Expand tabs (xtabs, tab3)
 Carriage-return delay
 mask (crdly)
 Vertical tab delay 
 Backspace delay
 Form-feed delay
 mask (ffdly)
 Control flags - hacking the serial-line.

  POSIX
 csize: character size mask 
 cread: Enable receiver.
 hupcl: Hang up on last close.
 clocal: Ignore modem lines.
 cignore: ignore control flags 
 ccts_oflow: CTS flow control of output
 crts_iflow: RTS flow control of input
 mdmbuf
 Local flags -- hacking the tty driver / user interface.

  POSIX
 echoe: Visually erase chars
 echo:  Enable echoing
 isig: Enable ^c, ^z signalling
 iexten:  Enable extensions
 noflsh
 echoke: visually erase a line-kill 
 echoprt: visual erase for hardcopy 
 echoctl: echo control chars as "^X" 
 flusho: output is being flushed
 pendin: retype pending input
 altwerase
 nokerninfo: no kernel status on ^T
 SVR4
 xcase: canonical upper/lower presentation
 Vector of (speed . code) pairs.
 tcflush() constants

 TCIFLUSH
 TCIOFLUSH
 tcflow() constants

 TCOON
 TCOOFF
 TCION
 TCIOFF
 tcsetattr() constants

 TCSADRAIN Drain output, then change.
 TCSAFLUSH Drain output, flush input.
  Copyright ( c ) 1995 by   . See file COPYING .
  Largely rehacked by Olin .

  These constants are for IRIX ,

  Non - standard ( POSIX ,  , 4.3+BSD ) things :



  ^d icanon
     icanon
  ^ ? icanon
  ^\ isig
  ^q ixon , ixoff
  ^s ixon , ixoff

  SVR4 & 4.3+BSD
   
     icanon

  4.3+BSD

(define	num-ttychars		23)

  Magic " disable feature " tty character


  ixon

  SVR4 & 4.3+BSD





  SVR4 & 4.3+BSD
  onlcr : map nl to cr - nl

  4.3+BSD


(define	 ttyout/nl-delay0	#o000000)
  tty 37

(define	 ttyout/tab-delay0	#o000000)
  tty 37
(define	 ttyout/tab-delay2	#o010000)

(define	 ttyout/cr-delay0	#o000000)
  tn 300
  tty 37
  concept 100

  mask ( vtdly )
(define	 ttyout/vtab-delay0	#o000000)
  tty 37

  mask ( bsdly )
(define	 ttyout/bs-delay0	#o000000)
(define	 ttyout/bs-delay1	#o020000)

(define	 ttyout/ff-delay0	#o000000)
(define	 ttyout/ff-delay1	#o100000)

(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)))



  5 bits ( cs5 )
  6 bits (  )
  7 bits ( cs7 )
  8 bits ( cs8 )
  cstopb : Send 2 stop bits .
  parenb
  parodd

   4.3+BSD


  echok : Echo nl after line kill
  echonl : Echo nl even if echo is off
  icanon :  input
  tostop : SIGTTOU on background output

  SVR4 & 4.3+BSD

  4.3+BSD



(define baud-rates '#((0  . 0)		(1  . 50)	(2  .    75)
		      (3  . 110)	(4  . 134)	(5  .   150)
		      (6  . 200)	(7  . 300)	(8  .   600)
		      (9  . 1200)	(10 . 1800)     (11 .  2400)	
		      (12 . 4800)       (13 . 9600)	(14 .  19200)
		      (15 . 38400)	(14 . exta)     (15 .  extb)))


  TCOFLUSH






  TCSANOW    Make change immediately .
