;;; -*- Mode:Lisp; Readtable:ZL; Package:USER; Base:8; Patch-File:T -*-
;;; Patch file for System version 123.236
;;; Reason:
;;;  Sigh: (zwei:stream-immediate-output) really requires that you've already
;;;  inserted the text into the buffer.  This means that if immediate output
;;;  is preceded by **MORE** processing which you abort out of, the inserted
;;;  but undisplayed text will be displayed.  But if you haven't inserted the
;;;  text yet, worse weirdness occurs.
;;; Written 19-Apr-88 13:45:23 by pld at site Gigamos Cambridge
;;; while running on Jack Flanders from band 1
;;; with Experimental System 123.235, Experimental Local-File 73.4, Experimental FILE-Server 22.2, Experimental Unix-Interface 11.0, Experimental KERMIT 34.3, Experimental ZMail 71.0, Experimental Lambda-Diag 15.0, Experimental Tape 22.1, Experimental VERIFY 6.0, Experimental RPG-BENCHMARKS 6.0, Experimental Site Data Editor 9.0, microcode 1755, SDU Boot Tape 3.14, SDU ROM 8.



; From modified file DJ: L.ZWEI; STREAM.LISP#185 at 19-Apr-88 16:52:27
#8R ZWEI#: 
(COMPILER-LET ((*PACKAGE* (PKG-FIND-PACKAGE "ZWEI")))
  (COMPILER::PATCH-SOURCE-FILE "SYS: ZWEI; STREAM  "

(undefmethod (editor-stream-mixin :wrapper :string-out))

))

; From modified file DJ: L.ZWEI; STREAM.LISP#185 at 19-Apr-88 16:52:37
#8R ZWEI#: 
(COMPILER-LET ((*PACKAGE* (PKG-FIND-PACKAGE "ZWEI")))
  (COMPILER::PATCH-SOURCE-FILE "SYS: ZWEI; STREAM  "

(undefmethod (ztop-stream-mixin :string-out))

))

; From modified file DJ: L.ZWEI; STREAM.LISP#185 at 19-Apr-88 16:53:03
#8R ZWEI#: 
(COMPILER-LET ((*PACKAGE* (PKG-FIND-PACKAGE "ZWEI")))
  (COMPILER::PATCH-SOURCE-FILE "SYS: ZWEI; STREAM  "

(DEFMETHOD (EDITOR-STREAM-MIXIN :TYO) (CH)
  (LET ((*WINDOW* *STREAM-SHEET*))
    (INSERT-MOVING *STREAM-BP* CH)
    (STREAM-IMMEDIATE-OUTPUT
      (TV:SHEET-TYO *STREAM-SHEET* CH))))

))

; From modified file DJ: L.ZWEI; STREAM.LISP#185 at 19-Apr-88 16:53:07
#8R ZWEI#: 
(COMPILER-LET ((*PACKAGE* (PKG-FIND-PACKAGE "ZWEI")))
  (COMPILER::PATCH-SOURCE-FILE "SYS: ZWEI; STREAM  "

(defmethod (EDITOR-STREAM-MIXIN :STRING-OUT) (STR &OPTIONAL (START 0) END)
  (LET ((*WINDOW* *STREAM-SHEET*))
    (INSERT-MOVING *STREAM-BP* (IF (AND (ZEROP START) (NULL END)) STR
				 (NSUBSTRING STR START END)))
    (STREAM-IMMEDIATE-OUTPUT
      (tv:sheet-string-out *stream-sheet* str start end))))

))

; From modified file DJ: L.ZWEI; STREAM.LISP#185 at 19-Apr-88 16:53:11
#8R ZWEI#: 
(COMPILER-LET ((*PACKAGE* (PKG-FIND-PACKAGE "ZWEI")))
  (COMPILER::PATCH-SOURCE-FILE "SYS: ZWEI; STREAM  "

(DEFMETHOD (EDITOR-STREAM-MIXIN :LINE-OUT) (STR &OPTIONAL (START 0) END)
  (LET ((*WINDOW* *STREAM-SHEET*))
    (INSERT-MOVING *STREAM-BP* (IF (AND (ZEROP START) (NULL END)) STR
				 (NSUBSTRING STR START END)))
    (INSERT-MOVING *STREAM-BP* #/RETURN)
    (STREAM-IMMEDIATE-OUTPUT
      (TV:SHEET-STRING-OUT *STREAM-SHEET* STR START END)
      (TV:SHEET-CRLF *STREAM-SHEET*))))

))

; From modified file DJ: L.ZWEI; STREAM.LISP#185 at 19-Apr-88 16:53:22
#8R ZWEI#: 
(COMPILER-LET ((*PACKAGE* (PKG-FIND-PACKAGE "ZWEI")))
  (COMPILER::PATCH-SOURCE-FILE "SYS: ZWEI; STREAM  "

(DEFMETHOD (EDITOR-STREAM-MIXIN :STREAM-RUBOUT-HANDLER)
	   (&AUX (RUBOUT-HANDLER NIL) CHAR)
  ;; If there is a saved-up activation character, return it from :ANY-TYI now.
  ;; This happens at the end of a rescan of the input.
  (IF *SRE-ACTIVATION-CHARACTER*
      (PROG1 *SRE-ACTIVATION-CHARACTER*
	     (SETQ *SRE-ACTIVATION-CHARACTER* NIL))
    ;; We could just call the editor, but we must pass certain characters (editing-commands)
    ;; that the program doing the read is handling, and we also want to
    ;; save some time for alphabetic characters.
    (IF *SRE-INPUT-POINT*
	(MUST-REDISPLAY *STREAM-SHEET* DIS-BPS)
      (SETQ CHAR (FUNCALL-SELF ':ANY-TYI)))
    ;; Just type out and insert self-inserting printing characters
    ;; but not if they are the caller's editing-commands or activations or commands,
    ;; or if they have been redefined in the editor itself.
    (let ((editing-command (cdr (assq ':editing-command rubout-handler-options)))
	  (command-handler (cdr (assq ':command rubout-handler-options)))
	  (activation-handler (cdr (assq ':activation rubout-handler-options)))
	  (do-not-echo (cdr (assq ':do-not-echo rubout-handler-options)))
	  (pass-through (cdr (assq ':pass-though rubout-handler-options))))
      (IF (AND (NUMBERP CHAR)
	       (NOT (OR (MEMQ CHAR editing-command)
			(SI:ASSQ-CAREFUL CHAR editing-command)))
	       (NOT (AND command-handler
			 (APPLY (car command-handler)
				CHAR (cdr command-handler))))
	       (NOT (AND activation-handler
			 (APPLY (car activation-handler)
				CHAR (cdr activation-handler))))
	       (NOT (MEMQ CHAR DO-NOT-ECHO))
	       (OR (AND (graphic-char-p CHAR)
			(EQ 'COM-ORDINARILY-SELF-INSERT
			    (COMMAND-LOOKUP CHAR *STREAM-COMTAB*)))
		   (AND (< CHAR 400)
			(MEMQ CHAR pass-through))))
	  (LET ((*WINDOW* *STREAM-SHEET*))
	    (INSERT-MOVING *STREAM-BP* CHAR)
	    (STREAM-IMMEDIATE-OUTPUT
	      (TV:SHEET-TYO *STREAM-SHEET* CHAR))
	    CHAR)
	;; Otherwise, run the editor till COM-ACTIVATE throws to us,
	;; then throw to RUBOUT-HANDLER to restart the read using the buffer contents.
	;; Move editor point to where we are reading.
	(MOVE-BP *STREAM-BP*
		 (OR *SRE-INPUT-POINT* (INTERVAL-LAST-BP (WINDOW-INTERVAL *STREAM-SHEET*))))
	(SETQ *SRE-INPUT-POINT* NIL)
	;; Update buffer display and window data so editor gets consistent data.
	(STREAM-REDISPLAY T)
	;; Unread this character so editor will execute it.
	(WHEN CHAR (TV:IO-BUFFER-UNGET (SEND *STREAM-SHEET* ':IO-BUFFER) CHAR))
	;; Edit.
	(SET-IN-CLOSURE EDITOR-CLOSURE '*EDITOR-STREAM-ACTIVATION-NEEDED* NIL)
	;; PASS-ON characters throw here
	;; to return from the :ANY-TYI method.
	(CATCH 'RETURN-FROM-ANY-TYI
	  (LET ((*STREAM-IBEAM-SHOULD-BLINK* NIL)
		(*INSIDE-EDITOR-STREAM* NIL))
	    (SI:%BIND (LOCF (TV:SHEET-MORE-VPOS *STREAM-SHEET*)) NIL)
	    (UNLESS (BP-= *STREAM-BP* (INTERVAL-LAST-BP (WINDOW-INTERVAL *STREAM-SHEET*)))
	      (SEND SELF ':ENTER-EDITOR)
	      (send self :enable-ibeam))
	    (UNWIND-PROTECT
		(FUNCALL *STREAM-SHEET* ':EDIT EDITOR-CLOSURE)
	      (FUNCALL *STREAM-SHEET* ':EXIT-EDITOR)
	      (send self :disable-ibeam)
	      ;; Put blinker into ordinary stream mode instead of editor mode.
	      (MULTIPLE-VALUE-BIND (X Y) (TV:BLINKER-READ-CURSORPOS *STREAM-BLINKER*)
		(TV:SHEET-SET-CURSORPOS *STREAM-SHEET* X Y))
	      (FUNCALL *STREAM-BLINKER* ':SET-FOLLOW-P T)	;Make the blinker follow again
	      (TV:BLINKER-SET-VISIBILITY *STREAM-BLINKER*
					 (IF (EQ *STREAM-SHEET* TV:SELECTED-WINDOW)
					     ':BLINK ':ON)))
	    ;; Tell the :RUBOUT-HANDLER method to restart the read.
	    (THROW 'RUBOUT-HANDLER T)))))))

))
