DIRECTORY TEditDisplay USING [EstablishLine], TEditDocument USING [LineTable, Selection, SelectionRec, SpinAndLock, TEditDocumentData, Unlock], TEditOps USING [CopyLoadHistory, CopyPositionHistory], TEditSplit, TextNode USING [Location, pZone], ViewerClasses USING [Viewer], ViewerOps USING [AddProp, ComputeColumn, CreateViewer, DestroyViewer, FetchProp, MoveBelowViewer, OpenIcon, SetMenu]; TEditSplitImpl: CEDAR PROGRAM IMPORTS TEditDisplay, TEditDocument, TEditOps, TextNode, ViewerOps EXPORTS TEditSplit SHARES ViewerClasses = BEGIN OPEN ViewerClasses; Split: PUBLIC PROC [old: Viewer] = BEGIN tddNew, tddOld: TEditDocument.TEditDocumentData; new: Viewer; selectionHistory: TEditDocument.Selection; lines: TEditDocument.LineTable; loc: TextNode.Location; tddOld _ NARROW[old.data]; IF tddOld = NIL THEN RETURN; new _ ViewerOps.CreateViewer[flavor: old.class.flavor, info: [name: old.name, column: old.column, iconic: TRUE], paint: FALSE]; ViewerOps.OpenIcon[icon: new, paint: FALSE]; ViewerOps.MoveBelowViewer[altered: new, static: old, paint: FALSE]; tddNew _ NARROW[new.data]; IF tddNew = NIL THEN RETURN; -- How this could happen is beyond me, but paranoia is cheap. selectionHistory _ NARROW[ViewerOps.FetchProp[old, $SelectionHistory]]; new.link _ old; IF old.link=NIL THEN old.link _ new ELSE FOR v: Viewer _ old.link, v.link UNTIL v.link=old DO REPEAT FINISHED => v.link _ new; ENDLOOP; new.newVersion _ old.newVersion; new.newFile _ old.newFile; new.file _ old.file; ViewerOps.ComputeColumn[column: new.column, paint: FALSE]; -- to find new height [] _ TEditDocument.SpinAndLock[tddOld, "Split"]; -- must ComputeColumn before lock tdd tddNew.text _ tddOld.text; tddNew.tsInfo _ tddOld.tsInfo; tddNew.clipLevel _ tddOld.clipLevel; tddNew.commentFilter _ tddOld.commentFilter; ViewerOps.SetMenu[new, old.menu, FALSE]; IF selectionHistory # NIL THEN { -- copy it newSelectionHistory: TEditDocument.Selection _ TextNode.pZone.NEW[TEditDocument.SelectionRec]; newSelectionHistory^ _ selectionHistory^; ViewerOps.AddProp[new, $SelectionHistory, newSelectionHistory] }; TEditOps.CopyPositionHistory[from: old, to: new]; TEditOps.CopyLoadHistory[from: old, to: new]; lines _ tddOld.lineTable; loc _ lines[lines.lastLine].pos; -- in case loop doesn't find anything FOR n: INTEGER IN [0..lines.lastLine] DO -- find line that goes past new bottom IF lines[n].yOffset+lines[n].descent >= old.ch THEN { loc _ lines[n].pos; EXIT }; ENDLOOP; TEditDocument.Unlock[tddOld]; TEditDisplay.EstablishLine[tddNew, loc]; ViewerOps.ComputeColumn[column: new.column, paint: TRUE]; -- now do the painting FOR v: Viewer _ new.link, v.link UNTIL v=new DO IF v.iconic THEN { -- get rid of it -- ViewerOps.DestroyViewer[v]; EXIT }; ENDLOOP; END; END. ~-- TEditSplitImpl.mesa, Edited by Paxton on October 19, 1982 10:09 am -- Edited by McGregor on August 27, 1982 2:38 pm ʘ˜JšÏcE™EJš0™0J˜šÏk ˜ Jšœ žœ˜#JšœžœN˜aJšœ žœ(˜6J˜ Jšœ žœ˜!Jšœžœ ˜šœ žœA˜PJšœ$˜$J˜——šœž ˜Jšžœ;˜BJšžœ ˜Jšžœ˜J˜—Jšžœžœ˜J˜šÏnœžœžœž˜(J˜0J˜ J˜*J˜J˜Jšœ žœ ˜Jšžœ žœžœžœ˜˜MJšœžœ žœ˜1—Jšœ%žœ˜,Jšœ<žœ˜CJšœ žœ ˜Jš žœ žœžœžœ=˜ZJšœžœ.˜GJ˜Jšžœ žœžœ˜#šžœžœžœ ž˜9Jšžœžœ˜ Jšžœ˜—J˜ J˜J˜Jšœ3žœ˜PJšœ1%˜VJ˜J˜J˜$J˜,Jšœ!žœ˜(šžœžœžœ ˜+˜.Jšœžœ˜/—J˜)J˜A—J˜1J˜-J˜Jšœ!%˜Fš žœžœžœžœ&˜Ošžœ-žœ˜5Jšœžœ˜—Jšžœ˜—J˜J˜(Jšœ3žœ˜Pšžœžœž˜/Jšžœ žœœ žœ˜JJšžœ˜—Jšžœ˜J˜—Jšžœ˜J˜—…— ¶ Ì