/Syntax10.Scn.FntpVersionElemsAllocBeg#Syntax10.Scn.FntPowerMac Windows WindowsPowerMac#Syntax10.Scn.FntPOPTWindows pVersionElemsAllocEnd8FoldElemsNew#Syntax10.Scn.Fnt END NoNotify;8`8#Syntax10.Scn.Fnt END NoTreeNotify;8CJ8#Syntax10.Scn.Fnt BEGIN IF scope # NIL THEN Traverse (t, scope.right, action); action (t, scope); Traverse (t, scope.left, action); END END Traverse;848#Syntax10.Scn.Fnt VAR t1: Tree; e: HierElems.Elem; BEGIN IF (obj.mode >=6) & (obj.mode<=10) OR (obj.mode=13) THEN NEW(e); IF obj.vis = 0 THEN HierElems.Init(e, internal); ELSIF obj.vis = 2 THEN HierElems.Init(e, external); ELSE HierElems.Init(e, externalR); END; e.col:= 3; NEW (t1); Trees.InitTree(t1); t1.setName(obj.name); t1.txtPos:= obj.scope.adr; t1.setElem(e); t.children.insert(t1); Traverse (t1, obj.scope.right, CollectProcs); END; END CollectProcs;868#Syntax10.Scn.Fnt VAR t1: Tree; e: HierElems.Elem; BEGIN IF obj.mode=5 THEN NEW (t1); Trees.InitTree(t1); t1.setName(obj.name); t1.txtPos:= obj.typ.txtpos; NEW(e); IF obj.vis = 0 THEN HierElems.Init(e, internal); ELSIF obj.vis = 2 THEN HierElems.Init(e, external); ELSE HierElems.Init(e, externalR); END; t1.setElem(e); e.col:= 8; t.children.insert(t1); Traverse (t1, obj.typ.link, CollectProcs) END END CollectTypes;848#Syntax10.Scn.Fnt VAR orgTrNotify: Trees.NotifyProc; BEGIN orgTrNotify:= f.proc.notify; f.proc.notify:= NoTreeNotify; Traverse (f.proc, scope.right, CollectProcs); orgTrNotify(f.tree, f.proc, f.proc, TreeFrames.replace); f.proc.notify:= orgTrNotify; orgTrNotify:= f.type.notify; f.type.notify:= NoTreeNotify; Traverse (f.type, scope.right, CollectTypes); orgTrNotify(f.tree, f.type, f.type, TreeFrames.replace); f.type.notify:= orgTrNotify; END ScanAST;818#Syntax10.Scn.Fnt VAR en: Trees.Enumerator; tn: Trees.TreeNode; BEGIN en:= t.enumerate(); WHILE en.hasMoreElems DO tn:= en.nextElem(); IF tn IS Trees.Tree THEN tn(Trees.Tree).deleteAllChildren(); END; END; END DelAllGrandChildren; 8M8#Syntax10.Scn.Fnt VAR r: Texts.Reader; err: BOOLEAN; orgNotify: Texts.Notifier; BEGIN DelAllGrandChildren(hFr.tree); orgNotify:= f.text.notify; f.text.notify:= NoNotify; FoldElems.ExpandAll(f.text, 0, TRUE); Texts.OpenReader(r, f.text, 0); Compiler.Module(r, "f", 0, TextFrames.Text(""), err); FoldElems.CollapseAll(f.text, {FoldElems.tempLeft}); f.text.notify:= orgNotify; ScanAST(hFr, Compiler.mainMod); Compiler.mainMod:= NIL; f.text(Text).changed:= FALSE; END BuildTree;8[8#Syntax10.Scn.Fnt VAR r: Texts.Reader; pos: LONGINT; BEGIN pos:= Texts.ElemPos(e); BuildTree(main, hierFr, hierFr.tree.name); Texts.OpenReader(r, hierFr.text, pos); Texts.ReadElem(r); e:= r.elem(TreeFrames.FolderElem); END Rebuild;8J8#Syntax10.Scn.Fnt VAR beg, end, delta: LONGINT; BEGIN delta := 200; LOOP beg := F.org; end := TextFrames.Pos(F, F.X + F.W, F.Y); IF (beg <= pos) & (pos < end) OR (delta = 0) THEN EXIT END ; TextFrames.Show(F, pos - delta); delta := delta DIV 2 END END ShowPos;8;:8#Syntax10.Scn.Fnt VAR r: Texts.Reader; fold, twin: FoldElems.Elem; pos: LONGINT; t: Texts.Text; orgNotify: Texts.Notifier; BEGIN t:= f.text; orgNotify:= t.notify; t.notify:= NoNotify; FoldElems.ExpandAll(t, 0, TRUE); Texts.OpenReader (r, t, txtPos); Texts.ReadPrevElem (r); WHILE r.elem # NIL DO IF r.elem IS FoldElems.Elem THEN fold := r.elem(FoldElems.Elem); IF fold.mode = FoldElems.tempLeft THEN twin := FoldElems.Twin(fold); IF Texts.ElemPos(twin) < txtPos THEN pos:= Texts.ElemPos(twin); FoldElems.Switch (twin); DEC(txtPos, pos - Texts.ElemPos(twin)) ELSE fold.mode := FoldElems.expLeft END END END; Texts.ReadPrevElem (r) END; FoldElems.CollapseAll(t, {FoldElems.tempLeft}); t.notify:= orgNotify; t.notify(t, Texts.replace, 0, t.len); ShowPos (f, txtPos); Oberon.PassFocus(Viewers.This(f.X, f.Y)); TextFrames.SetCaret(f, txtPos) END Exec;8F8#Syntax10.Scn.Fnt VAR Menu, Main: Display.Frame; SubFr: Frame; M: Oberon.CopyMsg; fr: Frame; BEGIN Menu:= V.dsc; Main:= V.dsc.next; SubFr:= V.dsc.next.next(Frame); NEW(V1); V1^:= V^; V1.state:= 0; M.F:= NIL; Menu.handle(Menu, M); V1.dsc:= M.F; M.F:= NIL; Main.handle(Main, M); V1.dsc.next:= M.F; NEW(fr); M.F:= fr; SubFr.handle(SubFr, M); V1.dsc.next.next:= M.F; fr.proc:= SubFr.proc; fr.type:= SubFr.type; fr.parseAble:= SubFr.parseAble; END Copy;8C81Syntax10.Scn.Fnti A VAR menu: Display.Frame; main: TextFrames.Frame; hierFr: Frame; v1: HierViewers.Viewer; BEGIN WITH v: HierViewers.Viewer DO menu:= v.dsc; main:= v.dsc.next(TextFrames.Frame); hierFr:= main.next(Frame); WITH msg: TreeFrames.SelectMsg DO IF msg.root = hierFr.tree THEN IF (msg.node.parent = NIL) OR (msg.node.parent.parent = NIL) THEN IF (msg.root = hierFr.tree) & main.text(Text).changed THEN BuildTree(main, hierFr, hierFr.tree.name); END; TreeFrames.ExpandAll(msg.node(Trees.Tree), hierFr); ELSE main.text(Text).changed:= TRUE; (* to avoid a 'TreeFrames.CollapseAll' call *) IF msg.node IS Node THEN Exec(msg.node(Node).txtPos, main); ELSE Exec(msg.node(Tree).txtPos, main); END; main.text(Text).changed:= FALSE; END; END; | msg: Oberon.CopyMsg DO Copy(v(HierViewers.Viewer), v1); msg.F:= v1 | msg: Oberon.InputMsg DO IF msg.id = Oberon.track THEN IF (msg.Y < v.Y + v.H - v.menuH) & (msg.X < main.X + main.W) THEN IF ~main.text(Text).changed & (middleKey IN msg.keys) THEN main.text(Text).changed:= TRUE; (* to avoid a 'TreeFrames.CollapseAll' call *) main.handle(main, msg); main.text(Text).changed:= FALSE; ELSE main.handle(main, msg); END; ELSE HierViewers.Handle(v, msg); END; ELSE HierViewers.Handle(v, msg); END; | msg: TextFrames.UpdateMsg DO IF (main.text = msg.text) & ~main.text(Text).changed THEN main.text(Text).changed:= TRUE; TreeFrames.CollapseAll(hierFr.tree, hierFr); END; HierViewers.Handle(v, msg); ELSE HierViewers.Handle(v, msg); END; ELSE END; END Handle;8b8#Syntax10.Scn.FntBB VAR text: Texts.Text; beg, time: LONGINT; BEGIN Texts.Scan(S); end := MAX(LONGINT); IF (S.class = Texts.Char) & (S.c = "^") THEN Oberon.GetSelection(text, beg, end, time); IF time >= 0 THEN Texts.OpenScanner(S, text, beg); Texts.Scan(S) END END ; IF S.line # 0 THEN S.class := Texts.Inval END END GetMainArg;88#Syntax10.Scn.FntDD BEGIN Texts.Write(w, ch); Texts.Append(Oberon.Log, w.buf) END Ch;8$8#Syntax10.Scn.FntJJ BEGIN Texts.WriteString(w, s); Texts.Append(Oberon.Log, w.buf) END Str;88#Syntax10.Scn.Fnt__ BEGIN Texts.Write(w, " "); Texts.WriteInt(w, n, 0); Texts.Append(Oberon.Log, w.buf) END Int;88#Syntax10.Scn.FntBB BEGIN Texts.WriteLn(w); Texts.Append(Oberon.Log, w.buf) END Ln;8)8#Syntax10.Scn.Fnt]] VAR R: Texts.Reader; identify: Texts.IdentifyMsg; mod: Modules.Module; cmd: Modules.Command; BEGIN Texts.OpenReader(R, t, 0); Texts.ReadElem(R); WHILE ~R.eot DO R.elem.handle(R.elem, identify); mod := Modules.ThisMod(identify.mod); IF mod # NIL THEN cmd := Modules.ThisCommand(mod, identify.proc) ELSE cmd := NIL END ; IF cmd = NIL THEN Ln; Str("pos"); Int(Texts.Pos(R) - 1); Str(" unknown element allocator: "); Str(identify.mod); Ch("."); Str(identify.proc); END ; Texts.ReadElem(R) END ; IF w.buf.len > 0 THEN Ln; Texts.Append(Oberon.Log, w.buf) END END ShowAliens;8Bh81Syntax10.Scn.FntQ h VAR hierFr: Frame; main: TextFrames.Frame; v: Viewers.Viewer; BEGIN WITH e: TreeFrames.FolderElem DO WITH msg: TextFrames.TrackMsg DO v:= Viewers.This(msg.X0, msg.Y0); main:= v.dsc.next(TextFrames.Frame); hierFr:= v.dsc.next.next(Frame); IF main.text(Text).changed & ~e.exp & (msg.keys = {middleKey} ) & (e.node.parent = hierFr.tree) THEN Rebuild(e, main, hierFr); TreeFrames.NodeElemHandle(e, msg); ELSE TreeFrames.NodeElemHandle(e, msg); END; ELSE TreeFrames.NodeElemHandle(e, msg); END; ELSE TreeFrames.NodeElemHandle(e, msg); END; END ElemHandler;8H+8#Syntax10.Scn.Fnt VAR ok: BOOLEAN; i, endLen, strLen: INTEGER; BEGIN ok:= LEN(str) > LEN(end); end[LEN(end) - 1]:= 0X; endLen:= 0; WHILE end[endLen] # 0X DO INC(endLen); END; DEC(endLen); str[LEN(str) - 1]:= 0X; strLen:= 0; WHILE str[strLen] # 0X DO INC(strLen); END; DEC(strLen); strLen:= strLen - endLen; i:= 0; WHILE ok & (i < endLen) DO ok:= end[i] = str[strLen + i]; INC(i); END; RETURN ok; END EndsWith;8k8#Syntax10.Scn.Fnt VAR V: HierViewers.Viewer; F, M: TextFrames.Frame; i, x, y: INTEGER; subFr: Frame; e: HierElems.Elem; BEGIN IF class = Texts.String THEN i := 0; WHILE name[i] # 0X DO INC(i) END ; name[i] := 22X; INC(i); name[i] := 0X; WHILE i >= 0 DO name[i+1] := name[i]; DEC(i) END ; name[0] := 22X END ; Oberon.AllocateUserViewer(Oberon.Mouse.X, x, y); M := TextFrames.NewMenu(name, "^Edit.Menu.Text"); (* Main Frame *) F := TextFrames.NewText(T, org); (* Hierarchy Frame *) NEW(subFr); TreeFrames.Open(subFr, TreeFrames.Tree()); subFr.neHandler:= ElemHandler; subFr.showEmptyTr:= TRUE; subFr.tree.setName(name); subFr.tree.notify:= NIL; subFr.parseAble:= EndsWith(name, ".Mod"); NEW(e); IF subFr.parseAble THEN HierElems.Init(e, HierElems.oDoc); ELSE HierElems.Init(e, HierElems.doc); END; subFr.tree.setElem(e); NEW(subFr.type); Trees.InitTree(subFr.type); subFr.type.notify:= TreeFrames.NotifyDisplay; subFr.type.setName("TYPE"); NEW(e); HierElems.Init(e, HierElems.cube); e.col:= 8; subFr.type.setElem(e); subFr.tree.addChild(subFr.type); NEW(subFr.proc); Trees.InitTree(subFr.proc); subFr.proc.notify:= TreeFrames.NotifyDisplay; subFr.proc.setName("PROCEDURE"); NEW(e); HierElems.Init(e, HierElems.cube); e.col:= 3; subFr.proc.setElem(e); subFr.tree.addChild(subFr.proc); (* Hierarchy Viewer *) V := HierViewers.New(M, F, subFr, TextFrames.menuH, x, y); V.handle:= Handle; ShowPos(F, org); BuildTree(F, subFr, name); RETURN F; END NewView;82C8#Syntax10.Scn.Fnt VAR text: Text; BEGIN NEW(text); Texts.Open(text, name); text.notify:= TextFrames.NotifyDisplay; text.changed:= TRUE; RETURN text; END NewText;88#Syntax10.Scn.Fnt&& VAR S: Texts.Scanner; F: TextFrames.Frame; end: LONGINT; BEGIN Texts.OpenScanner(S, Oberon.Par.text, Oberon.Par.pos); GetMainArg(S, end); IF (S.class = Texts.Name) OR (S.class = Texts.String) THEN F := NewView(S.s, S.class, NewText(S.s), 0); ShowAliens(F.text); END END Open;8 MODULE HierEdit; (* EK 98 *) IMPORT TreeFrames, Edit, Texts, HierViewers, TextFrames, Oberon, Modules, Display, Compiler, FoldElems, OPT := iOPT, Trees, HierElems, Viewers; CONST leftKey= 2; middleKey= 1; rightKey= 0; internal= HierElems.cLock; external= HierElems.key; externalR= HierElems.oLock; TYPE Node= POINTER TO NodeDesc; NodeDesc= RECORD (Trees.TreeNodeDesc) txtPos: LONGINT; END; Tree= POINTER TO TreeDesc; TreeDesc= RECORD (Trees.TreeDesc) txtPos: LONGINT; END; Frame= POINTER TO FrameDesc; FrameDesc= RECORD (TreeFrames.FrameDesc) proc, type: Tree; parseAble: BOOLEAN; END; Action= PROCEDURE(t:Tree; obj: OPT.Object); Text* = POINTER TO TextDesc; TextDesc* = RECORD (Texts.TextDesc) changed*: BOOLEAN; END ; VAR w: Texts.Writer; PROCEDURE NoNotify(t: Texts.Text; op: INTEGER; beg, end: LONGINT); (* Tree *) PROCEDURE NoTreeNotify (t: Trees.Tree; new, old: Trees.TreeNode; op: INTEGER); PROCEDURE Traverse (t: Tree; scope: OPT.Object; action: Action); PROCEDURE CollectProcs(t: Tree; obj: OPT.Object); PROCEDURE CollectTypes (t: Tree; obj: OPT.Object); PROCEDURE ScanAST (f: Frame; scope: OPT.Object); PROCEDURE DelAllGrandChildren(t: Trees.Tree); PROCEDURE BuildTree(f: TextFrames.Frame; hFr: Frame; name: ARRAY OF CHAR); PROCEDURE Rebuild(VAR e: TreeFrames.FolderElem; main: TextFrames.Frame; hierFr: Frame); (* Editor *) PROCEDURE ShowPos (F: TextFrames.Frame; pos: LONGINT); PROCEDURE Exec (txtPos: LONGINT; f: TextFrames.Frame); PROCEDURE Copy (V: HierViewers.Viewer; VAR V1: HierViewers.Viewer); PROCEDURE Handle* (v: Display.Frame; VAR msg: Display.FrameMsg); PROCEDURE GetMainArg (VAR S: Texts.Scanner; VAR end: LONGINT); (*takes recent selection if ^*) PROCEDURE Ch (ch: CHAR); PROCEDURE Str (s: ARRAY OF CHAR); PROCEDURE Int (n: LONGINT); PROCEDURE Ln; PROCEDURE ShowAliens (t: Texts.Text); PROCEDURE ElemHandler*(e: Texts.Elem; VAR msg: Texts.ElemMsg); PROCEDURE EndsWith(str: ARRAY OF CHAR; end: ARRAY OF CHAR): BOOLEAN; PROCEDURE NewView (name: ARRAY OF CHAR; class: INTEGER; T: Texts.Text; org: LONGINT): TextFrames.Frame; PROCEDURE NewText* (name: ARRAY OF CHAR): Text; PROCEDURE Open*; BEGIN Texts.OpenWriter(w); END HierEdit. Order of compilation: 1 Trees.Mod HierElems.Mod 2 TreeFrames.Mod 3 HierViewers.Mod 4 HierEdit.Mod HierEdit.Open Trees.Mod