;;; -*- Mode:Lisp; Readtable:ZL; Package:USER; Base:8; Patch-File:T -*-
;;; Patch file for System version 124.42
;;; Reason:
;;;  SUPDUP command <Network> Control-Y to send most recently killed string
;;;  through connection used to require you to type <Network Control-Shift-Y
;;; Written 9-Jun-88 12:41:00 by pld (Peter L. DeWolf) at site Gigamos Cambridge
;;; while running on Cthulhu from band 1
;;; with Experimental System 124.41, Experimental Local-File 74.1, Experimental File-Server 23.1, Experimental Unix-Interface 12.0, Experimental ZMail 72.0, Experimental Tape 23.6, Experimental Lambda-Diag 16.1, microcode 1756, SDU Boot Tape 3.14, SDU ROM 8, the old ones.



; From modified file DJ: L.NETWORK; SUPDUP.LISP#321 at 9-Jun-88 12:41:01
#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)))))
	(#/c-sh-Y	;similar to Y, but send it directly to the net instead of via KBD buffering.
	 (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 :net-output-translated (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.
c-Y  -- Similar to Y, but send it directly to net instead of via typin loop.
"
		   (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))))

))
