(DEFINE-FILE-INFO PACKAGE "INTERLISP" READTABLE "INTERLISP" BASE 10)
(FILECREATED "20-Jul-88 10:55:13" {ERIS}<LAFITE>SOURCES>LAFITETEDIT.;6 6737   

      changes to%:  (VARS LAFITETEDITCOMS)

      previous date%: " 8-Jun-88 15:02:46" {ERIS}<LAFITE>SOURCES>LAFITETEDIT.;5)


(* "
Copyright (c) 1988 by Xerox Corporation.  All rights reserved.
")

(PRETTYCOMPRINT LAFITETEDITCOMS)

(RPAQQ LAFITETEDITCOMS ((* ;; "Lafite's more explicit dependencies on %"internals%" of TEDIT") (FNS LA.ADJUST.FORMATTING LA.SKIP.LOOKS.LIST LA.DETACH.TEDIT LA.TEDIT.INCLUDE LA.WINDOW.FROM.TEXTSTREAM) (DECLARE%: EVAL@COMPILE DONTCOPY (* ;; "Need TEDIT internal declarations for LA.ADJUST.FORMATTING.  Can't just do (FILES (SOURCE) TEDITDECLS), because there is a compiled version that is already loaded that isn't enough.") (P (COND ((NOT (GET (QUOTE TEDITDECLS) (QUOTE FILE))) (LOAD (QUOTE TEDITDECLS)) (COND ((< (IDATE TEDITSYSTEMDATE) (IDATE "1-mar-88 00:00")) (* ; "Bug in older TEXTPROP--just compile it closed.") (REMPROP (QUOTE TEXTPROP) (QUOTE COMPILER:OPTIMIZER-LIST))))))) (FILES (SOURCE) LAFITEDECLS) (GLOBALVARS *TEDIT-FILE-READTABLE*) (LOCALVARS . T))))



(* ;; "Lafite's more explicit dependencies on %"internals%" of TEDIT")

(DEFINEQ

(LA.ADJUST.FORMATTING
(LAMBDA (FORMATSTREAM OUTSTREAM BYTE-LENGTHS) (* ; "Edited  3-Jun-88 18:24 by bvm") (* ;; "Adjusts the formatting info FORMATSTREAM to account for the prepending of one or more %"paragraphs%" of default looking text, whose lengths are given by BYTE-LENGTHS (or a single number if just one piece).  It then writes the resulting formatting to OUTSTREAM.") (PROG ((END (GETEOFPTR FORMATSTREAM)) NPIECES PIECEINFOCH# TYPECODE PCLEN PREFIXEND LOOKSINDEX) (COND ((<= END 8) (* ; "This can't be formatting.") (RETURN NIL))) (SETFILEPTR FORMATSTREAM (- END 8)) (SETQ PIECEINFOCH# (\DWIN FORMATSTREAM)) (* ; "Where the piece table starts relative to the whole file.  Since in our case TEXT is only the formatting, it will start at zero.") (SETQ NPIECES (\SMALLPIN FORMATSTREAM)) (* ; "Total number of pieces") (if (NEQ (\SMALLPIN FORMATSTREAM) 31418) then (* ; "Not the version of TEdit formatting we understand.  Throw it out.") (RETURN NIL)) (SETFILEPTR FORMATSTREAM 0) (do (SETQ PCLEN (\DWIN FORMATSTREAM)) (SETQ TYPECODE (\SMALLPIN FORMATSTREAM)) (* ; "What kind of piece is it?") (SELECTC TYPECODE (\PieceDescriptorPAGEFRAME (* ; "This is page layout info for the file, whose format is an s-expression") (SKREAD FORMATSTREAM NIL *TEDIT-FILE-READTABLE*)) (\PieceDescriptorCHARLOOKSLIST (* ; "This is the list of CHARLOOKSs used in this document.  This is a sequence of charlooks, ") (LA.SKIP.LOOKS.LIST FORMATSTREAM)) (\PieceDescriptorPARALOOKSLIST (* ; "This is the list of PARALOOKSs used in this document.  Similar to CHARLOOKS.") (LA.SKIP.LOOKS.LIST FORMATSTREAM)) (\PieceDescriptorPARA (* ; "Start a new paragraph with different looks.  We will want to insert our new piece before this.") (OR PREFIXEND (SETQ PREFIXEND (- (GETFILEPTR FORMATSTREAM) 6))) (* ; "Representation is just a paralooks index") (\SMALLPIN FORMATSTREAM)) (\PieceDescriptorLOOKS (* ; "Character looks for a new piece.  The piece is PCLEN bytes long, which means half that many chars if fat.") (OR PREFIXEND (SETQ PREFIXEND (- (GETFILEPTR FORMATSTREAM) 6))) (* ; "Peek ahead to see what the charlooks of the first piece are") (\BIN FORMATSTREAM) (* ; "FLAG byte.  1=NEW; 2 = FAT") (SETQ LOOKSINDEX (\SMALLPIN FORMATSTREAM)) (* ; "Charlooks index") (RETURN)) (PROGN (* ; "Either imageobj or unknown type piece--I hope we're finished") (RETURN)))) (* ;; "At this point we have read enough format info to know what to do.  Everything up to PREFIXEND is the preamble, which we can copy intact.  Then we insert our own first piece, consisting of the prepended text in a single piece.") (COPYBYTES FORMATSTREAM OUTSTREAM 0 (OR PREFIXEND (SETQ PREFIXEND (- (GETFILEPTR FORMATSTREAM) 6)))) (for PIECELEN inside BYTE-LENGTHS do (* ;; "This code is generalized to allow multiple inserted pieces, but unfortunately if the textstream already has any paragraph formatting, we can't make the pieces be different paragraphs without making them also have non-default paralooks.") (\DWOUT OUTSTREAM PIECELEN) (\SMALLPOUT OUTSTREAM \PieceDescriptorLOOKS) (BOUT OUTSTREAM 0) (* ; "Flag byte") (\SMALLPOUT OUTSTREAM (OR LOOKSINDEX 1)) (* ; "Char looks index--make it look like the first piece, or arbitrarily choose the first looks if the text started with an imageobj or some other ugliness") (add PIECEINFOCH# PIECELEN) (add NPIECES 1)) (COPYBYTES FORMATSTREAM OUTSTREAM PREFIXEND (- END 8)) (* ; "Copy rest of piece info") (\DWOUT OUTSTREAM PIECEINFOCH#) (* ; "New offset of start of formatting") (\SMALLPOUT OUTSTREAM NPIECES) (* ; "More pieces now") (\SMALLPOUT OUTSTREAM 31418) (* ; "Finally, the password") (RETURN OUTSTREAM)))
)

(LA.SKIP.LOOKS.LIST
(LAMBDA (FORMATSTREAM) (* ; "Edited  3-Jun-88 16:52 by bvm") (* ;; "Advance FORMATSTREAM past a sequence of CHAR/PARALOOKS.  Each elements starts with a word giving its byte length, so we can skip over it") (for I from 1 to (\SMALLPIN FORMATSTREAM) do (SETFILEPTR FORMATSTREAM (+ (GETFILEPTR FORMATSTREAM) (\SMALLPIN FORMATSTREAM)))))
)

(LA.DETACH.TEDIT
(LAMBDA (TEXTSTREAM) (* ; "Edited  3-Jun-88 17:27 by bvm") (* ;; "Removes the TEXTSTREAM from the window, if any, it is being edited in.") (* ;; "Yecch, TEdit ought to have a proper interface for this.") (replace (TEXTOBJ \WINDOW) of (TEXTOBJ TEXTSTREAM) with NIL))
)

(LA.TEDIT.INCLUDE
(LAMBDA (TEXTSTREAM FILE CH#) (* ; "Edited  3-Jun-88 17:49 by bvm") (* ;; "Do an Include of FILE into TEXTSTREAM at (i.e., in front of) character CH#.  Returns the length of the insertion.") (* ;; "This code assumes that TEDIT.INCLUDE makes selection be the insertion") (TEDIT.SETSEL TEXTSTREAM CH# 0 (QUOTE RIGHT)) (TEDIT.INCLUDE TEXTSTREAM FILE) (fetch (SELECTION DCH) of (TEDIT.GETSEL TEXTSTREAM)))
)

(LA.WINDOW.FROM.TEXTSTREAM
(LAMBDA (TEXTSTREAM) (* ; "Edited 23-Sep-87 15:36 by bvm:") (for W in (fetch (TEXTOBJ \WINDOW) of (TEXTOBJ TEXTSTREAM)) when (WINDOWPROP W (QUOTE TITLE)) do (* ; "Hairy loop because the window could be split") (RETURN W)))
)
)
(DECLARE%: EVAL@COMPILE DONTCOPY 

(COND ((NOT (GET (QUOTE TEDITDECLS) (QUOTE FILE))) (LOAD (QUOTE TEDITDECLS)) (COND ((< (IDATE TEDITSYSTEMDATE) (IDATE "1-mar-88 00:00")) (* ; "Bug in older TEXTPROP--just compile it closed.") (REMPROP (QUOTE TEXTPROP) (QUOTE COMPILER:OPTIMIZER-LIST))))))


(FILESLOAD (SOURCE) LAFITEDECLS)

(DECLARE%: DOEVAL@COMPILE DONTCOPY

(GLOBALVARS *TEDIT-FILE-READTABLE*)
)

(DECLARE%: DOEVAL@COMPILE DONTCOPY

(LOCALVARS . T)
)
)
(PUTPROPS LAFITETEDIT COPYRIGHT ("Xerox Corporation" 1988))
(DECLARE%: DONTCOPY
  (FILEMAP (NIL (1236 6197 (LA.ADJUST.FORMATTING 1246 . 4859) (LA.SKIP.LOOKS.LIST 4861 . 5221) (
LA.DETACH.TEDIT 5223 . 5511) (LA.TEDIT.INCLUDE 5513 . 5938) (LA.WINDOW.FROM.TEXTSTREAM 5940 . 6195))))
)
STOP