;;; -*- Mode:Lisp; Readtable:ZL; Package:USER; Base:8; Patch-File:T -*-
;;; Patch file for System version 123.183
;;; Reason:
;;;  Change Telnet window to allow sending of all meaningful telnet commands:
;;;    <Network> A  --> Abort Output
;;;    <Network> <Clear-input>  --> Erase Line
;;;    <Network> <Delete>  --> Erase Character
;;;    <Network> P  --> Interrupt Process
;;;    <Network> <Status>  --> Are You There
;;; Written 13-Jan-87 16:50:50 by pld at site Gigamos Cambridge
;;; while running on Jack Flanders from band 2
;;; with Experimental System 123.182, Experimental Local-File 73.3, Experimental FILE-Server 22.1, Experimental Unix-Interface 11.0, Experimental Tape 18.0, Experimental KERMIT 34.3, Experimental ZMail 71.0, Experimental Lambda-Diag 15.0, microcode 1754, SDU Boot Tape 3.12, SDU ROM 8.



; From modified file DJ: L.NETWORK; SUPDUP.LISP#313 at 13-Jan-87 16:53:12
#8R SUPDUP#: 
(COMPILER-LET ((*PACKAGE* (PKG-FIND-PACKAGE "SUPDUP")))
  (COMPILER::PATCH-SOURCE-FILE "SYS: NETWORK; SUPDUP  "

(defmethod (basic-nvt :handle-escape) (&aux ch xpos ypos command)
  (unwind-protect
    (progn
      (multiple-value (xpos ypos) (tv:sheet-read-cursorpos self))
      (put-down-string self "CMND-->")
      (setq ch (char-upcase (send self :tyi)))
      (selectq ch
	((#/Call #/End)
	 (tv:deselect-and-maybe-bury-window self))
	(#/A
	 (unless (null connection)
	   (setq command '(send self :send-if-handles :send-ao))))
	((#/B #/Break)
	 (send self :set-super-image-mode nil)
	 (break "BREAK")
	 (send self :set-super-image-mode t))
	(#/Clear-input
	 (unless (null connection)
	   (setq command '(send self :send-if-handles :send-el))))
	(#/C			      ;C = Change escape character.
	 (put-down-string self "Change escape character to -->")
	 (send self :set-super-image-mode nil)
	 (setq escape-char (char-upcase (send self :tyi)))
	 (send self :set-super-image-mode t))
	(#/Delete
	 (unless (null connection)
	   (setq command '(send self :send-if-handles :send-ec))))
	(#/D                         ;D = Disconnect, ask for new host to connect to.
	 (if (null connection)
	     (throw 'nvt-done "(Already disconnected.)")
	   (send self :disconnect)
	   (throw 'nvt-done "Disconnected")))
	(#/E
	 (unless (null connection)
	   (setq command '(send self :send-if-handles :toggle-local-echo))))
	(#/Control-shift-e
	 (unless (null connection)
	   (setq command '(send self :send-if-handles :toggle-remote-echo))))
	(#/I			      ;I = Imlac.
	 (if (not (null connection))
	     (send self :send-if-handles :toggle-imlac-simulation)))
	(#/L			      ;L = Logout.
	 (if (null connection)
	     (quit)
	   (setq command '(progn
			    (send self :logout)
			    (quit "Logout")))))
	(#/M			      ;M = More.
	 (if (not (null connection))
	     (send self :send-if-handles :user-set-more-p (not (send self :more-p)))))
;	(#/N
;	 (send self :set-super-image-mode nil))
	(#/O
	 (send self :send-if-handles :toggle-overprinting))
	(#/P
	 (unless (null connection)
	   (setq command '(send self :send-if-handles :send-ip))))
	(#/Q			      ;Q = Quit.
	 (quit))
	(#/Status
	 (unless (null connection)
	   (setq command '(send self :send-if-handles :send-ayt))))
	(#/V
	 (send self :send-if-handles :toggle-verbose-mode))
	(#/Y
	 (let* ((node (zwei:history-latest-element zwei:*kill-history*))
		(string (if (arrayp node) node (zwei:string-interval node nil nil t))))
	   (dotimes (i (array-length string))
	     (send self :force-kbd-input (aref string i)))))

	((#/Help #/?)		      ;<HELP> or ? = Help
	 (si:with-help-stream (window :label "Help for Network commands")
	   (send window :clear-window)
	   (format window "After typing the Escape character, which is ~:C,
you can type these commands:~%" escape-char)
	   (format window "
CALL -- Do a local CALL (return to top window).
BREAK-- Enter a breakpoint.
~:[~;A    -- Send an AO (Abort Output)
~]~
~:[~;Clear Input    -- Send an EL (Erase Line)
~]~
C    -- Change the ~A escape character.
~:[~;Delete    -- Send an EC (Erase Character)
~]~
D    -- Disconnect and connect to new host.
End  -- Return to top window, but don't break connection.
~:[~;E    -- Toggle local echo
~]~
~:[~;C-E  -- Toggle remote echo
~]~
Help -- Type this message.
~:[~;I    -- Toggle imlac simulation.
~]~
L    -- Log out of remote host, and break the connection.
~:[~;M    -- Toggle more processing.
~]~
~:[~;O    -- Toggle overprinting (for servers that expect non-overprinting terminals).
~]~
~:[~;P    -- Send an IP (Interrupt Process)
~]~
Q    -- Disconnect and return to top window.
~:[~;Status -- Send an AYT (Are You There)
~]~
~:[~;V    -- Toggle verbose mode
~]~
Y    -- Send the most recently killed string through the connection.
"
		   (get-handler-for self :send-ao)
		   (get-handler-for self :send-el)
		   program-name
		   (get-handler-for self :send-ec)
		   (get-handler-for self :toggle-local-echo)
		   (get-handler-for self :toggle-remote-echo)
		   (get-handler-for self :toggle-imlac-simulation)
		   (get-handler-for self :user-set-more-p)
		   (get-handler-for self :toggle-overprinting)
		   (get-handler-for self :send-ip)
		   (get-handler-for self :send-ayt)
		   (get-handler-for self :toggle-verbose-mode))
	   (format window "~4A -- Send ~:C through~%"
		   (format nil "~:C" escape-char)
		   escape-char)))
	(#/Rubout)				;<RUBOUT> = Do nothing.
	(otherwise
	  (cond ((= ch escape-char)
		 (send self :net-output-translated ch)
		 (lock-output
		   (send stream :force-output)))
		(t (tv:beep))))))
    (tv:sheet-force-access (self t)
      (put-down-string self "")      ;Clear the bottom line.
      (tv:sheet-set-cursorpos self xpos ypos))
    (when command
      (eval command))))

))

; From modified file DJ: L.NETWORK; SUPDUP.LISP#313 at 13-Jan-87 16:53:23
#8R SUPDUP#: 
(COMPILER-LET ((*PACKAGE* (PKG-FIND-PACKAGE "SUPDUP")))
  (COMPILER::PATCH-SOURCE-FILE "SYS: NETWORK; SUPDUP  "

(defconstant nvt-subnegotiation-end 360)
(defconstant nvt-nop 361)
(defconstant nvt-dm 362)
(defconstant nvt-break 363)
(defconstant nvt-ip 364)
(defconstant nvt-ao 365)
(defconstant nvt-ayt 366)
(defconstant nvt-ec 367)
(defconstant nvt-el 370)
(defconstant nvt-go-ahead 371)
(defconstant nvt-subnegotiation-begin 372)
(defconstant nvt-will 373)
(defconstant nvt-wont 374)
(defconstant nvt-do 375)
(defconstant nvt-dont 376)
(defconstant nvt-iac 377)

))

; From modified file DJ: L.NETWORK; SUPDUP.LISP#313 at 13-Jan-87 16:53:36
#8R SUPDUP#: 
(COMPILER-LET ((*PACKAGE* (PKG-FIND-PACKAGE "SUPDUP")))
  (COMPILER::PATCH-SOURCE-FILE "SYS: NETWORK; SUPDUP  "


(defmethod (basic-telnet :send-ao) ()
  ;; Send a New Telnet "Abort Output".
  (lock-output
    (send stream :force-output))
  (send stream :set-urgent-output t)
  (telnet-send-command nvt-ao)
  (telnet-send-command nvt-dm)
  (send stream :set-urgent-output nil))

))

; From modified file DJ: L.NETWORK; SUPDUP.LISP#313 at 13-Jan-87 16:53:38
#8R SUPDUP#: 
(COMPILER-LET ((*PACKAGE* (PKG-FIND-PACKAGE "SUPDUP")))
  (COMPILER::PATCH-SOURCE-FILE "SYS: NETWORK; SUPDUP  "


(defmethod (basic-telnet :send-ayt) ()
  (telnet-send-command nvt-ayt))

))

; From modified file DJ: L.NETWORK; SUPDUP.LISP#313 at 13-Jan-87 16:53:38
#8R SUPDUP#: 
(COMPILER-LET ((*PACKAGE* (PKG-FIND-PACKAGE "SUPDUP")))
  (COMPILER::PATCH-SOURCE-FILE "SYS: NETWORK; SUPDUP  "


(defmethod (basic-telnet :send-ec) ()
  (telnet-send-command nvt-ec))

))

; From modified file DJ: L.NETWORK; SUPDUP.LISP#313 at 13-Jan-87 16:53:39
#8R SUPDUP#: 
(COMPILER-LET ((*PACKAGE* (PKG-FIND-PACKAGE "SUPDUP")))
  (COMPILER::PATCH-SOURCE-FILE "SYS: NETWORK; SUPDUP  "


(defmethod (basic-telnet :send-el) ()
  (telnet-send-command nvt-el))

))
