;;; -*- Mode:Lisp; Readtable:ZL; Package:USER; Base:8; Patch-File:T -*-
;;; Patch file for System version 123.209
;;; Reason:
;;;  Add <net>c-Y command to supdup.  This is similar to <net>Y command, but sends stuff directly
;;;  to net, avoiding typin loop.  This prevents BUFFER-FULL if killed string is long.
;;; Written 5-Mar-88 22:20:42 by rg (Richard Greenblatt) at site Gigamos Cambridge
;;; while running on Djinn from band 2
;;; with Experimental System 123.208, Experimental Local-File 73.3, Experimental FILE-Server 22.1, Experimental Unix-Interface 11.0, Experimental Tape 18.2, Experimental KERMIT 34.3, Experimental ZMail 71.0, Experimental Lambda-Diag 15.0, microcode 1754, SDU ROM 8.



; From modified file DJ: L.NETWORK; SUPDUP.LISP#319 at 5-Mar-88 22:20:43
#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-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))))

))
