p4Syntax10.Scn.FntpSyntax10b.Scn.Fnt`=P4PopupElemsAllocCompile#Syntax10.Scn.Fnt Folds.Compile AccessElems.Mod/s~` P4AsciiCoder#Syntax10.Scn.Fnt))AsciiCoder.CodeFiles % AccessElems.Mod ~ 8FoldElemsNew#Syntax10.Scn.FntLL blue = 3; black = 15; IsDir = 0; IsFile = 1; IsCommand = 2; IsError = 3; 8 8Syntax10.Scn.FntSyntax10b.Scn.Fnt 8FoldElemsNewCSyntax10.Scn.FntSyntax10b.Scn.Fnt%6 AccessElemDesc* = RECORD (PopupElems.ElemDesc) END;8;8#Syntax10.Scn.FntOO EntryDesc = RECORD pat: ARRAY 10 OF CHAR; cmd: Str64; next: Entry END;8k AccessElem* = POINTER TO AccessElemDesc;  Str64 = ARRAY 64 OF CHAR; Entry = POINTER TO EntryDesc;  8s8#Syntax10.Scn.Fntkk w, wp: Texts.Writer; map: Entry; pattern: ARRAY 32 OF CHAR; cnt: INTEGER; subDir: ARRAY 256 OF CHAR; 88#Syntax10.Scn.Fnt::PROCEDURE ^Handle* (e: Texts.Elem; VAR m: Texts.ElemMsg); Syntax10i.Scn.Fnt8;f8#Syntax10.Scn.Fntxx VAR cmds: AccessElem; m: TextFrames.DisplayMsg; BEGIN NEW (cmds); COPY (name, cmds.name); cmds.small := TRUE; cmds.menu := TextFrames.Text (""); cmds.handle := Handle; m.fnt := w.fnt; m.col := 0; m.pos := 0; m.frame := NIL; m.X0 := 0; m.Y0 := 0; m.elemFrame := NIL; m.prepare := TRUE; cmds.handle(cmds, m); PopupElems.MeasureMenu (cmds); RETURN cmds END CreatePopup; 8Qc8#Syntax10.Scn.Fnt{{ VAR d0: Directories.Directory; i, j: INTEGER; BEGIN d0 := Directories.Startup(); i := 0; WHILE (d0.path [i] # 0X) & (CAP(d0.path [i]) = CAP(path [i])) DO INC (i) END; IF (d0.path[i] = 0X) & ((path [i] = 0X) OR (path [i] = Directories.delimiter)) THEN IF path [i] = Directories.delimiter THEN collPath [0] := "$"; j := 0; INC (i); REPEAT INC(j); collPath [j] := path [i]; INC(i) UNTIL collPath[j] = 0X ELSE COPY ("$", collPath) END; ELSE COPY (path, collPath) END; IF collPath [Strings.Length (collPath) - 1] # Directories.delimiter THEN Strings.Append (Directories.delimiter, collPath) END END CollapseRootPath; 8U.8Syntax10.Scn.FntSyntax10b.Scn.Fnt #% "J VAR s: Texts.Scanner; ch: CHAR; elem: PopupElems.Elem; col: INTEGER; BEGIN Texts.OpenReader (s, t, pos); Texts.Read (s, ch); col := s.col; IF s.elem # NIL THEN IF s.elem IS PopupElems.Elem THEN elem := s.elem(PopupElems.Elem); Texts.OpenScanner (s, t, 0); Texts.Scan (s); IF (s.class = Texts.Name) OR (s.class = Texts.String) THEN COPY (s.s, name); ELSE name [0] := 0X END; Strings.Append (Directories.delimiter, name); Strings.Append (elem.name, name); IF col = blue THEN RETURN IsDir ELSE RETURN IsFile END ELSE name [0] := 0X; RETURN IsError END ELSE Texts.OpenScanner (s, t, pos); Texts.Scan (s); IF (s.class = Texts.Name) OR (s.class = Texts.String) THEN COPY (s.s, name) ELSE name [0] := 0X; RETURN IsError END; IF col = blue THEN RETURN IsFile ELSE RETURN IsCommand END END END ReadName; 8;8Syntax10.Scn.Fnt7L8FoldElemsNew#Syntax10.Scn.Fntlength := Strings.Length (subDir); j := 0; FOR i := 0 TO length DO IF subDir [i] # '"' THEN subDir [j] := subDir [i]; INC (j) END END;Syntax10i.Scn.Fnt8S8#Syntax10.Scn.FntWHILE (subDir [j] = Directories.delimiter) & (subDir [j + 1] = '.') DO IF (subDir [j + 2] = 0X) OR (subDir [j + 2] = Directories.delimiter) THEN Strings.Delete (subDir, j, 2) ELSIF (subDir [j + 2] = '.') & ((subDir [j + 3] = 0X) OR (subDir [j + 3] = Directories.delimiter)) THEN pos := Strings.Length (path) - 1; WHILE (pos >= 0) & (path [pos] # Directories.delimiter) DO DEC (pos) END; IF pos >= 0 THEN path [pos] := 0X END; INC (j, 3) END; pos := j END;88#Syntax10.Scn.FntIIREPEAT pos := Strings.Pos (Directories.delimiter, subDir, pos + 1) UNTIL (pos = -1) OR (subDir [pos + 1] = '.'); IF (pos # -1) & (subDir [pos + 1] = '.') THEN IF (subDir [pos + 2] = 0X) OR (subDir [pos + 2] = Directories.delimiter) THEN Strings.Delete (subDir, 0, 2) ELSIF (subDir [pos + 2] = '.') & ((subDir [pos + 3] = 0X) OR (subDir [pos + 3] = Directories.delimiter)) THEN i := pos - 1; WHILE (i >= j) & (subDir [i] # Directories.delimiter) DO DEC (i) END; Strings.Delete (subDir, i, pos - i + 3) END; end := FALSE; pos := j + 1 END84 VAR i, j, pos, length: INTEGER; end: BOOLEAN; BEGIN  Remove quotes  j := 0; end := FALSE; pos := 0; WHILE ~end & (j < Strings.Length (subDir)) DO  end := TRUE;  END; pos := Strings.Length (path); IF path [pos - 1] # Directories.delimiter THEN Strings.Append (Directories.delimiter, path); INC (pos) END; FOR i := j + 1 TO Strings.Length (subDir) DO path [pos] := subDir [i]; INC (pos) END; (* IF path [pos - 1] = Directories.delimiter THEN path [pos] := Directories.delimiter; path [pos - 1 (* + 1 *)] := 0X; END;*) END SetDirectory; 8A8Syntax10.Scn.Fnt$8FoldElemsNew#Syntax10.Scn.Fnt VAR m: TextFrames.UpdateMsg; BEGIN m.id := TextFrames.replace; m.text := Texts.ElemBase (e); m.beg := Texts.ElemPos (e); m.end := m.beg + 1; Viewers.Broadcast (m) END Update; 8Q8#Syntax10.Scn.Fnt BEGIN Texts.SetColor (w, black); Texts.WriteString (w, " -- failed"); Texts.WriteLn (w); Texts.Append (Oberon.Log, w.buf) END Failed; 80 8#Syntax10.Scn.Fnt JJTexts.SetColor (w, black); IF type = IsDir THEN Texts.WriteString (w, "Dir: ") ELSIF type = IsFile THEN Texts.WriteString (w, "File: ") ELSIF type = IsCommand THEN Texts.WriteString (w, "Command: ") ELSE Texts.WriteString (w, "Error: "); END; Texts.WriteString (w, name); Texts.WriteLn (w); Texts.Append (Oberon.Log, w.buf);Syntax10i.Scn.Fnt8yl VAR res, type: INTEGER; name: ARRAY 256 OF CHAR; par: Oberon.ParList; dir: Directories.Directory; txt: Texts.Text; PROCEDURE Update ();  PROCEDURE Failed ();  BEGIN type := ReadName (e.menu, pos, name); (*  For debugging purposes  *) IF type = IsDir THEN dir := Directories.This (name); IF dir # NIL THEN Directories.Change (dir.path) END ELSIF type = IsFile THEN NEW (par); par.frame := f; txt := TextFrames.Text (""); Texts.WriteString (w, name); Texts.WriteString (w, " ~"); Texts.Append (txt, w.buf); par.text := txt; par.pos := 0; Oberon.Call ("Documents.Open", par, FALSE, res); IF res = 0 THEN Update () ELSE Failed () END ELSIF type = IsCommand THEN NEW (par); par.frame := f; par.text := e.menu; par.pos := 0; Oberon.Call (name, par, FALSE, res); IF res = 0 THEN Update () ELSE Failed () END ELSE Failed () END END Exec; 8l08#Syntax10.Scn.Fnt VAR pos: INTEGER; BEGIN IF Strings.Match (name, pattern) OR isDir THEN IF isDir THEN Texts.SetColor(w, blue) ELSE Texts.SetColor(w, Display.white) END; pos := Strings.Pos (" ", name, 0); IF pos # -1 THEN Strings.Insert ('"', 0, name); Strings.Append ('"', name) END; IF Strings.Length (name) > 31 THEN name [31] := 0X END; Texts.WriteElem (w, CreatePopup (name)); Texts.WriteLn (w); INC(cnt) END END ListProc; 8)8#Syntax10.Scn.Fnt99 VAR directory: Directories.Directory; pos: INTEGER; collPath: ARRAY 128 OF CHAR; BEGIN e.menu := TextFrames.Text (""); cnt := 0; directory := Directories.Current (); COPY (directory.path, collPath); SetDirectory (collPath, subDir); CollapseRootPath (collPath, collPath); directory := Directories.This (collPath); IF directory = NIL THEN Texts.SetColor (w, black); Texts.WriteString (w, "Change into subdirectory "); Texts.WriteString (w, collPath); Texts.WriteString (w, " failed !"); Texts.WriteLn (w); Texts.Append (Oberon.Log, w.buf) ELSE Texts.SetColor (w, blue); pos := Strings.Length (collPath) - 1; IF collPath [pos] = Directories.delimiter THEN collPath [pos] := 0X END; Texts.WriteString (w, collPath); Texts.WriteLn (w); Texts.SetColor (w, black); Directories.Enumerate (directory, ListProc); IF cnt = 1 THEN Texts.WriteLn (w); Texts.WriteLn (w) END; IF w.buf.len = 0 THEN Texts.WriteString (w, "no files found"); Texts.WriteLn (w); Texts.WriteLn (w) END END; Texts.Append (e.menu, w.buf); PopupElems.MeasureMenu (e) END CollectFiles; 8)8#Syntax10.Scn.Fnt   VAR directory: Directories.Directory; file: ARRAY 256 OF CHAR; BEGIN e.menu := TextFrames.Text (""); cnt := 0; directory := Directories.Current(); file := ""; COPY (directory.path, file); SetDirectory (file, subDir); CollapseRootPath (file, file); IF file [Strings.Length (file) - 1] # Directories.delimiter THEN Strings.Append (Directories.delimiter, file) END; Strings.Append (e.name, file); Texts.SetColor (w, blue); Texts.WriteString (w, file); Texts.WriteString (w, " ~"); Texts.WriteLn (w); Texts.SetColor (w, black); Texts.WriteString (w, "Edit.Open"); Texts.WriteLn (w); Texts.WriteString (w, "System.Open"); Texts.WriteLn (w); (* Texts.WriteString (w, "Browser.ShowDef"); Texts.WriteLn (w); (* Doesn't work *)*) Texts.WriteString (w, "Dialogs.Edit"); Texts.WriteLn (w); Texts.WriteString (w, "Dialogs.Open"); Texts.WriteLn (w); Texts.WriteString (w, "-------------------"); Texts.WriteLn (w); Texts.WriteString (w, "System.DeleteFiles"); Texts.WriteLn (w); Texts.Append(e.menu, w.buf) END ShowCommands; 8 )8QSyntax10.Scn.FntSyntax10b.Scn.Fnt" VAR e1: AccessElem; r: Texts.Reader; ch: CHAR; pos, lastPos: INTEGER; BEGIN WITH e: AccessElem DO WITH m: Texts.CopyMsg DO IF m.e = NIL THEN NEW (e1); m.e := e1 END ; PopupElems.Handle (e, m) | m: Texts.IdentifyMsg DO m.mod := "AccessElems"; m.proc := "Alloc" | m: PopupElems.SelectMsg DO IF m.id = 0 (* PopupElems.IDSelect *) THEN Texts.OpenReader (r, m.elem.menu, m.pos); Texts.Read (r, ch); IF (r.elem = NIL) OR (~(r.elem IS AccessElem)) THEN RETURN ELSIF ~(m.elem IS AccessElem) THEN IF 1 IN m.keys THEN COPY (e.name, pattern); subDir := ""; CollectFiles (e); PopupElems.Handle (e, m) ELSE RETURN END ELSIF r.col = blue THEN e1 := r.elem(AccessElem); Strings.Append (Directories.delimiter, subDir); Strings.Append (e1.name, subDir); CollectFiles (e1); PopupElems.Handle (e, m) ELSE; e1 := r.elem(AccessElem); ShowCommands (e1); PopupElems.Handle (e, m) END; pos := 0; REPEAT lastPos := pos; pos := Strings.Pos (Directories.delimiter, subDir, pos + 1) UNTIL pos = -1; Strings.Delete (subDir, lastPos, Strings.Length (subDir) - lastPos); PopupElems.Handle (e, m) END | m: TextFrames.TrackMsg DO IF 1 IN m.keys THEN COPY (e.name, pattern); subDir := ""; CollectFiles (e); PopupElems.Handle (e, m) END | m: PopupElems.ExecMsg DO Exec (e, m.frame, m.pos) ELSE PopupElems.Handle(e, m) END END END Handle; 8 8#Syntax10.Scn.FntRR VAR e: AccessElem; BEGIN NEW(e); e.handle := Handle; Texts.new := e END Alloc; 8 s8#Syntax10.Scn.Fntkk VAR e: AccessElem; insert: TextFrames.InsertElemMsg; BEGIN NEW(e); e.handle := Handle; e.small := TRUE; In.Open (); IF In.Next () = In.name THEN In.Name (e.name) ELSIF In.Next () = In.string THEN In.String (e.name) ELSE e.name := "*" END; e.menu := TextFrames.Text (""); PopupElems.MeasureMenu (e); insert.e := e; Viewers.Broadcast (insert) END Insert; 83D8#Syntax10.Scn.Fnt VAR e: Entry; BEGIN NEW(e); COPY(pattern, e.pat); COPY(cmd, e.cmd); IF (e.pat # "") & (e.cmd # "") THEN e.next := map; map := e END END AddEntry; 8E8#Syntax10.Scn.Fnt END NoNotify; 8+8#Syntax10.Scn.Fnt VAR cmd, pattern: Str64; scratch: Texts.Text; s: Texts.Scanner; BEGIN NEW(scratch); Texts.Open(scratch, " Dir.Menu.Text "); scratch.notify := NoNotify; Texts.OpenScanner(s, scratch, 0); REPEAT Texts.Scan(s) UNTIL s.eot OR (s.line # 0); WHILE s.class = Texts.String DO COPY(s.s, pattern); Texts.Scan(s); IF s.class IN {Texts.Name, Texts.String} THEN COPY(s.s, cmd); Texts.Scan(s) END ; AddEntry(pattern, cmd) END END Init; 88#Syntax10.Scn.Fnt44 Texts.OpenWriter (w); Texts.OpenWriter (wp); Init8,MODULE AccessElems; IMPORT PopupElems, Texts, Directories, Strings, Display, Oberon, Viewers, TextFrames, In;   CONST  TYPE  VAR   Forward declarations  PROCEDURE CreatePopup (name: ARRAY OF CHAR): AccessElem;  PROCEDURE CollapseRootPath (path: ARRAY OF CHAR; VAR collPath: ARRAY OF CHAR);  PROCEDURE ReadName (t: Texts.Text; pos: LONGINT; VAR name: ARRAY OF CHAR): INTEGER;  PROCEDURE SetDirectory (VAR path, subDir: ARRAY OF CHAR);  PROCEDURE Exec (e: AccessElem; f: Display.Frame; pos: LONGINT);  PROCEDURE ListProc (d: Directories.Directory; name: ARRAY OF CHAR; isDir: BOOLEAN; VAR continue: BOOLEAN);  PROCEDURE CollectFiles (e: AccessElem);  PROCEDURE ShowCommands (e: AccessElem);  PROCEDURE Handle* (e: Texts.Elem; VAR m: Texts.ElemMsg);  PROCEDURE Alloc*;  PROCEDURE Insert*;  PROCEDURE AddEntry (pattern, cmd: ARRAY OF CHAR);  PROCEDURE NoNotify (t: Texts.Text; op: INTEGER; beg, end: LONGINT);  PROCEDURE Init;  BEGIN  END AccessElems. System.Free AccessElems ~