home *** CD-ROM | disk | FTP | other *** search
/ Amiga MA Magazine 1998 #6 / amigamamagazinepolishissue1998.iso / coders / jËzyki_programowania / oberon / system1 / myui.mod (.txt) < prev    next >
Oberon Text  |  1977-12-31  |  49KB  |  1,173 lines

  1. Syntax10.Scn.Fnt
  2. InfoElems
  3. Alloc
  4. Syntax10.Scn.Fnt
  5. StampElems
  6. Alloc
  7. 2 Mar 95
  8. "Title": MyUI
  9. "Author": Christoph Steindl (CS)
  10. "Abstract": MyUI provides a user interface for the compile commands such as Compiler.Compile
  11.     and Folds.Compile, for Edit.Get and Edit.Set, for Edit.Print and for Edit.Search, Edit.Replace,
  12.     Edit.ReplaceAll and Edit.ClearReplaceBuffer
  13. "Keywords": user interface, Compiler.Compile, Folds.Compile, Edit.Get, Edit.Set, Edit.Print,
  14.     Edit.Search, Edit.Replace, Edit.ReplaceAll, Edit.ClearReplaceBuffer
  15. "Version": 1
  16. "From":  20.12.94 14:01:53
  17. "Until": 
  18. "Changes": no changes
  19. "Hints": 
  20.     Dialog.Open Insert.Dlg
  21.     Dialog.Edit Compiler.Dlg
  22.     Dialog.Open Compiler.Dlg
  23.     Dialog.Edit GetSet.Dlg
  24.     Dialog.Open GetSet.Dlg
  25.     Dialog.Edit Print.Dlg
  26.     Dialog.Open Print.Dlg
  27.     Dialog.Edit Search.Dlg
  28.     Dialog.Open Search.Dlg
  29. Syntax10i.Scn.Fnt
  30. StampElems
  31. Alloc
  32. 2 Mar 95
  33. Syntax10b.Scn.Fnt
  34. ParcElems
  35. Alloc
  36. FoldElems
  37. Syntax10.Scn.Fnt
  38. Syntax10b.Scn.Fnt
  39. CONST
  40.         OptionChar* = "/";
  41.         PrintOptionsFile* = "PrintOptions";
  42.         eps = 1.0D-9; eps0 = 0.5D-9;
  43. Syntax10.Scn.Fnt
  44. FoldElems
  45. Syntax10.Scn.Fnt
  46.             styleElem: StyleElems.Parc;
  47.             next: StyleElem
  48.         END;
  49. Syntax10.Scn.Fnt
  50.             name: ARRAY 32 OF CHAR;
  51.             value: LONGREAL;
  52.             next: Var
  53.         END;
  54.         StyleElem = POINTER TO StyleElemDesc;
  55.         StyleElemDesc = RECORD
  56.         Operation = ARRAY 10 OF CHAR;
  57.         Var = POINTER TO VarDesc;
  58.         VarDesc = RECORD
  59. Syntax10.Scn.Fnt
  60.         vwr: Viewers.Viewer; selbeg, selend: TextFrames.Location;    (* for StoreSelection and RestoreSelection *)
  61.         styleElems: StyleElem;
  62.         p: Dialogs.Panel; o: Dialogs.Object;
  63.         command: ARRAY 32 OF CHAR; par: Oberon.ParList;
  64.         oldLog, newLog: Texts.Text;
  65.         w: Texts.Writer;
  66.         res-: INTEGER;
  67.         doSearch: BOOLEAN;
  68.         oldValue, value: LONGREAL; (* global variables for Calc.Dlg *)
  69.         commaPos: LONGREAL; (* <= 1 if a comma has been entered (i.e. right of comma) *)
  70.         oldOp, op: Operation;
  71.         newNumber: BOOLEAN;
  72.         vars: Var;
  73. Syntax10.Scn.Fnt
  74. Syntax10b.Scn.Fnt
  75. FoldElems
  76. Syntax10.Scn.Fnt
  77.         VAR elem: StyleElem;
  78.     BEGIN 
  79.         elem := styleElems;
  80.         WHILE elem # NIL DO
  81.             Out.Ln; Out.String(elem.styleElem.name);
  82.             elem := elem.next
  83.         END;
  84.         HALT(90) 
  85.     END DoHALT;
  86. Syntax10.Scn.Fnt
  87.     BEGIN p := Dialogs.cmdPanel; NEW (par); par.text := TextFrames.Text("")
  88.     END InitPar;
  89. Syntax10.Scn.Fnt
  90.     BEGIN Texts.Append (par.text, w.buf); par.frame := Oberon.Par.frame; par.vwr := Oberon.Par.vwr; Oberon.Call (s, par, FALSE, res)
  91.     END Call;
  92. Syntax10.Scn.Fnt
  93.     BEGIN newLog := TextFrames.Text(""); oldLog := Oberon.Log; Oberon.Log := newLog
  94.     END StoreLog;
  95. Syntax10.Scn.Fnt
  96.         VAR o: Dialogs.Object;
  97.     BEGIN
  98.         o := p.NamedObject (s);
  99.         WITH o: DialogRadioButtons.Item DO RETURN o.on
  100.         | o: DialogCheckBoxes.Item DO RETURN o.on
  101.         ELSE RETURN FALSE
  102.         END
  103.     END On;
  104. Syntax10.Scn.Fnt
  105.         VAR o: Dialogs.Object;
  106.     BEGIN
  107.         o := p.NamedObject (s); 
  108.         IF o # NIL THEN 
  109.             WITH o: DialogRadioButtons.Item DO o.ChangeValue (on)
  110.             | o: DialogCheckBoxes.Item DO o.ChangeValue (on)
  111.             ELSE HALT (99)
  112.             END
  113.         END
  114.     END ChangeValue;
  115. Syntax10.Scn.Fnt
  116.     BEGIN IF On (s) THEN Texts.WriteString (w, s) END
  117.     END Write;
  118. Syntax10.Scn.Fnt
  119.     BEGIN IF On (s) THEN Texts.WriteString (w, "default") END
  120.     END WriteDefault;
  121. Syntax10.Scn.Fnt
  122.     BEGIN
  123.         Texts.OpenScanner (s, newLog, 0); Texts.Scan (s);
  124.         IF st = "int" THEN
  125.             WHILE (s.class # Texts.Int) & (~s.eot) DO Texts.Scan (s) END
  126.         ELSE
  127.             WHILE (~ s.eot) & (s.class # Texts.Name) & (s.s # st) DO Texts.Scan (s) END
  128.         END
  129.     END Scan;
  130. Syntax10.Scn.Fnt
  131.         VAR o: Dialogs.Object;
  132.     BEGIN o := p.NamedObject (s); txt := o(DialogTexts.Item).GetText(); Texts.Delete (txt, 0, txt.len)
  133.     END Delete;
  134. Syntax10.Scn.Fnt
  135.         VAR txt: Texts.Text; o: Dialogs.Object;
  136.     BEGIN o := p.NamedObject (s); txt := o(DialogTexts.Item).GetText(); Texts.Save (txt, 0, txt.len, w.buf)
  137.     END Save;
  138. PROCEDURE DoHALT*;
  139.     PROCEDURE InitPar;
  140.     PROCEDURE Call (s: ARRAY OF CHAR);
  141.     PROCEDURE StoreLog;
  142.     PROCEDURE On (s: ARRAY OF CHAR): BOOLEAN;
  143.     PROCEDURE ChangeValue (s: ARRAY OF CHAR; on: BOOLEAN);
  144.     PROCEDURE Write (s: ARRAY OF CHAR);
  145.     PROCEDURE WriteDefault (s: ARRAY OF CHAR);
  146.     PROCEDURE Scan (VAR s: Texts.Scanner; st: ARRAY OF CHAR);
  147.     PROCEDURE Delete (s: ARRAY OF CHAR; VAR txt: Texts.Text);
  148.     PROCEDURE Save (s: ARRAY OF CHAR);
  149. Syntax10.Scn.Fnt
  150. FoldElems
  151. Syntax10.Scn.Fnt
  152. FoldElems
  153. Syntax10.Scn.Fnt
  154.             VAR ch: CHAR; error: BOOLEAN; fbeg, fend, ftime, breakpc: LONGINT;
  155.             scanner, fs: Texts.Scanner; sourceR: Texts.Reader; line: INTEGER;  ft: Texts.Text;  fw: Texts.Writer;
  156.         BEGIN
  157.             error := FALSE;
  158.             Texts.OpenScanner(scanner, t, beg); Texts.Scan(scanner);
  159.             WHILE (scanner.class IN {Texts.Name, Texts.String}) & (Texts.Pos(scanner) - scanner.len <= end) & ~error DO
  160.                 Texts.OpenWriter(w);
  161.                 Texts.WriteString(w, scanner.s);
  162.                 line := scanner.line; opt[j] := 0X; i := j;
  163.                 Texts.Scan(scanner);
  164.                 IF (scanner.line = line) & (scanner.class = Texts.Char) & (scanner.c = OptionChar) THEN
  165.                     ch := scanner.nextCh;
  166.                     WHILE ((ch >= "0") & (ch <= "9") OR (ch >= "a") & (ch <= "z")) & (i < LEN(opt) - 1) DO
  167.                         opt[i] := ch; INC(i);
  168.                         IF ch = "f" THEN findPC := ~findPC END;
  169.                         Texts.Read(scanner, ch)
  170.                     END ;
  171.                     scanner.nextCh := ch;
  172.                     Texts.Scan(scanner)
  173.                 END;
  174.                 opt[i] := 0X;
  175.                 par.frame := Oberon.Par.frame; par.vwr := Oberon.Par.vwr;
  176.                 IF findPC THEN
  177.                     LOOP
  178.                         Oberon.GetSelection(ft, fbeg, fend, ftime);
  179.                         IF ftime >= 0 THEN
  180.                             Texts.OpenScanner(fs, ft, fbeg); Texts.Scan(fs);
  181.                             IF fs.class = Texts.Int THEN breakpc := fs.i; EXIT END
  182.                         END;
  183.                         Texts.WriteString(fw, "  pc not selected"); Texts.WriteLn(fw);
  184.                         Texts.Append(Oberon.Log, fw.buf); error := TRUE; RETURN
  185.                     END;
  186.                     Texts.OpenReader(sourceR, t, beg);
  187.                     Compiler.Module(sourceR, opt, breakpc, Oberon.Log, error);
  188.                 ELSE
  189.                     Texts.Write(w, OptionChar); Texts.WriteString(w, opt);
  190.                     Texts.Append(par.text, w.buf); Oberon.Call(command, par, FALSE, res)
  191.                 END
  192.             END
  193.         END Do;
  194.         VAR
  195.         t: Texts.Text;
  196.         opt: ARRAY 20 OF CHAR; res: INTEGER; beg, end, time: LONGINT;
  197.         findPC: BOOLEAN; i, j: INTEGER;
  198.         PROCEDURE Do;
  199.     BEGIN
  200.         InitPar; i := 0;
  201.         IF On ("idx") THEN opt[i] := "x"; INC(i) END; IF On ("type") THEN opt[i] := "t"; INC(i) END;
  202.         IF On ("nil") THEN opt[i] := "n"; INC(i) END; IF On ("init") THEN opt[i] := "p"; INC(i) END;
  203.         IF On ("assert") THEN opt[i] := "s"; INC(i) END;
  204.         IF On ("pc") THEN findPC := TRUE; opt[i] := "f"; INC(i) ELSE findPC := FALSE END;
  205.         opt[i] := 0X; j := i;
  206.         IF On ("mrs") THEN 
  207.             Oberon.GetSelection(t, beg, end, time); 
  208.             IF findPC THEN 
  209.                 o := p.NamedObject("tpc"); t := o(DialogTexts.Item).GetText(); o(DialogTexts.Item).SetSelection(0, t.len)
  210.             END;
  211.             IF time >= 0 THEN Do END 
  212.         END;
  213.         IF findPC THEN 
  214.             o := p.NamedObject("tpc"); t := o(DialogTexts.Item).GetText(); o(DialogTexts.Item).SetSelection(0, t.len)
  215.         END;
  216.         IF On ("marked") THEN 
  217.             Texts.Write(w, "*"); Texts.Write(w, OptionChar); Texts.WriteString(w, opt); 
  218.             Texts.Append(par.text, w.buf); par.vwr := Oberon.MarkedViewer(); 
  219.             IF (par.vwr # NIL) & (par.vwr.dsc # NIL) & (par.vwr.dsc.next IS TextFrames.Frame) THEN 
  220.                 par.frame := par.vwr.dsc.next(TextFrames.Frame)
  221.             ELSE
  222.                 par.frame := NIL
  223.             END;
  224.             Oberon.Call(command, par, FALSE, res)
  225.         END;
  226.         IF On ("list") THEN
  227.             o := p.NamedObject("files"); t := o(DialogTexts.Item).GetText();
  228.             IF t.len > 0 THEN beg := 0; end := t.len; Do END
  229.         END;
  230.         IF findPC THEN o := p.NamedObject("tpc"); o(DialogTexts.Item).RemoveSelection END
  231.     END Comp;
  232. Syntax10b.Scn.Fnt
  233. Syntax10.Scn.Fnt
  234.     BEGIN command := "Compiler.Compile"; Comp
  235.     END Compile;
  236. Syntax10.Scn.Fnt
  237.     BEGIN command := "Folds.Compile"; Comp
  238.     END FoldsCompile;
  239.     PROCEDURE Comp;
  240.     PROCEDURE Compile*;
  241.     PROCEDURE FoldsCompile*;
  242. Syntax10.Scn.Fnt
  243. FoldElems
  244. Syntax10.Scn.Fnt
  245.         VAR t: Texts.Text; beg, end, time: LONGINT;
  246.     BEGIN
  247.         XIn.GetSelectionViewer(vwr, t, beg, end, time);
  248.         IF (vwr.dsc # NIL) & (vwr.dsc.next # NIL) & (vwr.dsc.next IS TextFrames.Frame) THEN
  249. Out.String("$Storing selbeg and selend");
  250.             selbeg := vwr.dsc.next(TextFrames.Frame).selbeg;
  251.             selend := vwr.dsc.next(TextFrames.Frame).selend
  252.         END
  253.     END StoreSelection;
  254. Syntax10.Scn.Fnt
  255.     BEGIN
  256.         IF (vwr.dsc # NIL) & (vwr.dsc.next # NIL) & (vwr.dsc.next IS TextFrames.Frame) THEN
  257. Out.String("$Restoring selbeg and selend");
  258.             vwr.dsc.next(TextFrames.Frame).selbeg := selbeg;
  259.             vwr.dsc.next(TextFrames.Frame).selend := selend;
  260.             vwr.dsc.next(TextFrames.Frame).hasSel := TRUE
  261.         END
  262.     END RestoreSelection;
  263. Syntax10b.Scn.Fnt
  264. Syntax10.Scn.Fnt
  265.     BEGIN
  266.         InitPar; Texts.WriteString(w, "adjust "); Write ("block"); Write ("center"); Write ("left"); Write ("right"); 
  267.         Call ("Edit.Set");
  268.     END Adjust;
  269. Syntax10.Scn.Fnt
  270.         VAR s: Texts.Scanner; 
  271.     BEGIN
  272.         InitPar; StoreLog; Texts.WriteString(w, "adjust"); Call ("Edit.Get");
  273.         IF res = 0 THEN
  274.             Scan (s, "adjust"); Texts.Scan(s); Texts.Scan(s); ChangeValue (s.s, TRUE)
  275.         END; 
  276.         Oberon.Log := oldLog
  277.     END GetAdjust;
  278. Syntax10.Scn.Fnt
  279.     BEGIN InitPar; Texts.WriteString(w, "break "); Write ("before"); Write ("normal"); Call ("Edit.Set")
  280.     END Break;
  281. Syntax10.Scn.Fnt
  282.         VAR s: Texts.Scanner; 
  283.     BEGIN
  284.         InitPar; StoreLog; Texts.WriteString(w, "break"); Call ("Edit.Get");
  285.         IF res = 0 THEN
  286.             Scan (s, "break"); Texts.Scan(s); Texts.Scan(s); ChangeValue (s.s, TRUE)
  287.         END;
  288.         Oberon.Log := oldLog
  289.     END GetBreak;
  290. Syntax10.Scn.Fnt
  291.     BEGIN
  292.         InitPar; Texts.WriteString(w, "columns ");
  293.         IF On ("one") THEN Texts.WriteString(w, "1") ELSIF On ("two") THEN Texts.WriteString(w, "2") END;
  294.         Call ("Edit.Set")
  295.     END Columns;
  296. Syntax10.Scn.Fnt
  297.         VAR s: Texts.Scanner; 
  298.     BEGIN
  299.         InitPar; StoreLog; Texts.WriteString(w, "columns"); Call("Edit.Get");    
  300.         IF res = 0 THEN
  301.             Texts.OpenScanner(s, newLog, 0); Texts.Scan(s);
  302.             WHILE ~s.eot & (s.class # Texts.Int) DO Texts.Scan(s) END;
  303.             IF s.i = 1 THEN ChangeValue ("one", TRUE)
  304.             ELSIF s.i = 2 THEN ChangeValue ("two", TRUE)
  305.             END
  306.         END;
  307.         Oberon.Log := oldLog
  308.     END GetColumns;
  309. Syntax10.Scn.Fnt
  310.         VAR number: INTEGER; 
  311.     BEGIN
  312.         InitPar; Texts.WriteString(w, "first "); WriteDefault ("firstdefault");
  313.         IF On ("firstnumber") THEN In.Open; In.Int(number); Texts.WriteInt(w, number, 0) END;
  314.         Call ("Edit.Set")    
  315.     END First;
  316. Syntax10.Scn.Fnt
  317.         VAR s: Texts.Scanner; txt: Texts.Text;
  318.     BEGIN
  319.         InitPar; StoreLog; Texts.WriteString(w, "first"); Call("Edit.Get");    
  320.         IF res = 0 THEN
  321.             Scan (s, "int"); Delete ("tfirstnumber", txt);
  322.             IF s.class = Texts.Int THEN
  323.                 Texts.WriteInt(w, s.i, 0); Texts.Append(txt, w.buf); ChangeValue ("firstnumber", TRUE)
  324.             ELSE
  325.                 ChangeValue ("firstnumber", FALSE); ChangeValue ("firstdefault", FALSE);
  326.             END
  327.         END;
  328.         Oberon.Log := oldLog
  329.     END GetFirst;
  330. Syntax10.Scn.Fnt
  331.     BEGIN p := Dialogs.cmdPanel; ChangeValue ("firstnumber", FALSE)
  332.     END FirstReset;
  333. Syntax10.Scn.Fnt
  334.     BEGIN
  335.         InitPar; Texts.WriteString(w, "grid "); 
  336.         IF On ("grid") THEN Texts.WriteString(w, "on") ELSE Texts.WriteString(w, "off") END;
  337.         Call ("Edit.Set")    
  338.     END Grid;
  339. Syntax10.Scn.Fnt
  340.         VAR s: Texts.Scanner; 
  341.     BEGIN
  342.         InitPar; StoreLog; Texts.WriteString(w, "grid"); 
  343.         Call ("Edit.Get");    
  344.         IF res = 0 THEN
  345.             Texts.OpenScanner(s, newLog, 0); Texts.Scan(s);
  346.             WHILE ~s.eot & (s.s # "on") & (s.s # "off") DO Texts.Scan(s) END;
  347.             IF s.s = "on" THEN ChangeValue("grid", TRUE)
  348.             ELSE ChangeValue("grid", FALSE) END
  349.         END;
  350.         Oberon.Log := oldLog
  351.     END GetGrid;
  352. Syntax10.Scn.Fnt
  353.     BEGIN
  354.         InitPar; Texts.WriteString(w, "lead "); WriteDefault ("leaddef");
  355.         IF On ("leadnumber") THEN Save ("tleadnumber") END;
  356.         Call ("Edit.Set")
  357.     END Lead;
  358. Syntax10.Scn.Fnt
  359.         VAR s: Texts.Scanner; txt: Texts.Text;
  360.     BEGIN
  361.         InitPar; StoreLog; Texts.WriteString(w, "lead"); Call ("Edit.Get");
  362.         IF res = 0 THEN
  363.             Scan (s, "int"); Delete ("tleadnumber", txt);
  364.             IF s.class = Texts.Int THEN
  365.                 Texts.WriteInt(w, s.i, 0); Texts.Append(txt, w.buf); ChangeValue ("leadnumber", TRUE)
  366.             ELSE
  367.                 ChangeValue ("leadnumber", FALSE); ChangeValue ("leaddef", FALSE)
  368.             END
  369.         END;
  370.         Oberon.Log := oldLog
  371.     END GetLead;
  372. Syntax10.Scn.Fnt
  373.     BEGIN p := Dialogs.cmdPanel; ChangeValue ("leadnumber", FALSE);
  374.     END LeadReset;
  375. Syntax10.Scn.Fnt
  376.         VAR number: INTEGER; 
  377.     BEGIN
  378.         InitPar; Texts.WriteString(w, "left "); WriteDefault ("leftmargindef");
  379.         IF On ("leftmargin") THEN In.Open; In.Int(number); Texts.WriteInt(w, number, 0) END;
  380.         Call ("Edit.Set")    
  381.     END Left;
  382. Syntax10.Scn.Fnt
  383.         VAR txt: Texts.Text; s: Texts.Scanner; 
  384.     BEGIN
  385.         InitPar; StoreLog; Texts.WriteString(w, "left");
  386.         Call("Edit.Get");    
  387.         IF res = 0 THEN
  388.             Scan (s, "int"); Delete ("tleftmargin", txt);
  389.             IF s.class = Texts.Int THEN
  390.                 Texts.WriteInt(w, s.i, 0); Texts.Append(txt, w.buf); ChangeValue ("leftmargin", TRUE)
  391.             ELSE
  392.                 ChangeValue ("leftmargin", FALSE); ChangeValue ("leftmargindef", FALSE)
  393.             END
  394.         END;
  395.         Oberon.Log := oldLog
  396.     END GetLeft;
  397. Syntax10.Scn.Fnt
  398.     BEGIN p := Dialogs.cmdPanel; ChangeValue ("leftmargin", FALSE)
  399.     END LeftReset;
  400. Syntax10.Scn.Fnt
  401.     VAR number: INTEGER;
  402.     BEGIN
  403.         InitPar; Texts.WriteString(w, "right "); WriteDefault ("rightmargindef");
  404.         IF On ("rightmargin") THEN In.Open; In.Int(number); Texts.WriteInt(w, number, 0) END;
  405.         Call ("Edit.Set")    
  406.     END Right;
  407. Syntax10.Scn.Fnt
  408.         VAR txt: Texts.Text; s: Texts.Scanner; 
  409.     BEGIN
  410.         InitPar; StoreLog; Texts.WriteString(w, "right");
  411.         Call ("Edit.Get");
  412.         IF res = 0 THEN
  413.             Scan (s, "int"); Delete ("trightmargin", txt);
  414.             IF s.class = Texts.Int THEN
  415.                 Texts.WriteInt(w, s.i, 0); Texts.Append(txt, w.buf); ChangeValue ("rightmargin", TRUE)
  416.             ELSE
  417.                 ChangeValue ("rightmargin", FALSE); ChangeValue ("rightmargindef", FALSE);
  418.             END
  419.         END;
  420.         Oberon.Log := oldLog
  421.     END GetRight;
  422. Syntax10.Scn.Fnt
  423.     BEGIN p := Dialogs.cmdPanel; ChangeValue ("rightmargin", FALSE)
  424.     END RightReset;
  425. Syntax10.Scn.Fnt
  426.     BEGIN
  427.         InitPar; Texts.WriteString (w, "line"); WriteDefault ("linedef");
  428.         IF On ("linenumber") THEN Save ("tenum") END;            
  429.         Call("Edit.Set")    
  430.     END Line;
  431. Syntax10.Scn.Fnt
  432.         VAR txt: Texts.Text; s: Texts.Scanner; 
  433.     BEGIN
  434.         InitPar; StoreLog; Texts.WriteString(w, "line");
  435.         Call("Edit.Get");    
  436.         IF res = 0 THEN
  437.             Scan (s, "int"); Delete ("tlinenumber", txt);
  438.             IF s.class = Texts.Int THEN
  439.                 Texts.WriteInt(w, s.i, 0); Texts.Append(txt, w.buf); ChangeValue ("linenumber", TRUE)
  440.             ELSE
  441.                 ChangeValue ("linenumber", FALSE); ChangeValue ("linedef", FALSE)
  442.             END
  443.         END;
  444.         Oberon.Log := oldLog
  445.     END GetLine;
  446. Syntax10.Scn.Fnt
  447.     BEGIN p := Dialogs.cmdPanel; ChangeValue ("linenumber", FALSE)
  448.     END LineReset;
  449. Syntax10.Scn.Fnt
  450.         VAR number: INTEGER;
  451.     BEGIN
  452.         InitPar; Texts.WriteString(w, "tabs "); 
  453.         IF On ("every") THEN 
  454.             In.Open; In.Int(number); Texts.WriteString(w, "* "); Texts.WriteInt(w, number, 0);
  455.         ELSE
  456.             IF On ("enum") THEN
  457.                 In.Open; In.Int(number);
  458.                 REPEAT Texts.WriteInt(w, number, 0); Texts.Write(w, " "); In.Int(number) UNTIL ~In.Done;
  459.                 Texts.WriteString(w, " ~")
  460.             END
  461.         END;
  462.         Call ("Edit.Set")
  463.     END Tabs;
  464. Syntax10.Scn.Fnt
  465.         VAR txt: Texts.Text; s: Texts.Scanner; ch: CHAR; Star: BOOLEAN;
  466.     BEGIN
  467.         InitPar; StoreLog; Texts.WriteString(w, "tabs");
  468.         Call ("Edit.Get");
  469.         IF res = 0 THEN
  470.             Texts.OpenReader(s, newLog, 0); Texts.Read(s, ch);
  471.             WHILE ~s.eot & (ch # "*") DO Texts.Read(s, ch) END;
  472.             Star := ch = "*"; Scan (s, "int");
  473.             IF Star THEN Delete("tevery", txt) ELSE Delete("tenum", txt) END;
  474.             REPEAT 
  475.                 IF s.class = Texts.Int THEN Texts.WriteInt(w, s.i, 0); Texts.Write(w, " ") END; Texts.Scan(s)
  476.             UNTIL s.eot OR (s.class # Texts.Int);
  477.             Texts.Append(txt, w.buf);
  478.             IF Star THEN ChangeValue ("every", TRUE) ELSE ChangeValue ("enum", TRUE) END
  479.         END;
  480.         Oberon.Log := oldLog
  481.     END GetTabs;
  482. Syntax10.Scn.Fnt
  483.     BEGIN p := Dialogs.cmdPanel; ChangeValue("every", FALSE)
  484.     END TabsReset1;
  485. Syntax10.Scn.Fnt
  486.     BEGIN p := Dialogs.cmdPanel; ChangeValue("enum", FALSE)
  487.     END TabsReset2;
  488. Syntax10.Scn.Fnt
  489.         VAR number: INTEGER;
  490.     BEGIN
  491.         InitPar; Texts.WriteString(w, "width  ");
  492.         IF On ("widthdef") THEN Texts.WriteString(w, "default") END;
  493.         IF On ("width") THEN In.Open; In.Int(number); Texts.WriteInt(w, number, 0) END;
  494.         Call("Edit.Set")    
  495.     END Width;
  496. Syntax10.Scn.Fnt
  497.         VAR txt: Texts.Text; s: Texts.Scanner; 
  498.     BEGIN
  499.         InitPar; StoreLog; Texts.WriteString(w, "width");
  500.         Call ("Edit.Get");
  501.         IF res = 0 THEN
  502.             Scan (s, "int"); Delete ("twidth", txt);
  503.             IF s.class = Texts.Int THEN
  504.                 Texts.WriteInt(w, s.i, 0); Texts.Append(txt, w.buf); ChangeValue ("width", TRUE)
  505.             ELSE
  506.                 ChangeValue ("width", FALSE); ChangeValue ("widthdef", FALSE)
  507.             END
  508.         END;
  509.         Oberon.Log := oldLog
  510.     END GetWidth;
  511. Syntax10.Scn.Fnt
  512.     BEGIN p := Dialogs.cmdPanel; ChangeValue("width", FALSE)
  513.     END WidthReset;
  514. Syntax10.Scn.Fnt
  515.         VAR prev, next: StyleElem; new: StyleElems.Parc;
  516.     BEGIN
  517.         next := styleElems; prev := styleElems;
  518.         WHILE (next # NIL) & (next.styleElem.name # n) DO
  519.             prev := next; next := next.next
  520.         END;
  521.         IF next # NIL THEN
  522.             NEW(new); StyleElems.Copy(next.styleElem, new);
  523. (*            IF prev = next THEN styleElems := next.next ELSE prev.next := next.next END*)
  524.         END;
  525.         RETURN new
  526.     END ThisStyleElem;
  527. Syntax10.Scn.Fnt
  528. FoldElems
  529. Syntax10.Scn.Fnt
  530.             BEGIN
  531.                 Texts.Delete(t, Texts.Pos(r) - 1, Texts.Pos(r));
  532.                 Texts.WriteElem(w, styleElem);
  533.                 Texts.Insert(t, Texts.Pos(r) - 1, w.buf);
  534.             END Replace;
  535.         VAR t, title: Texts.Text; beg, end, time: LONGINT; r: Texts.Reader; elem: Texts.Elem;
  536.             s: Texts.Scanner; styleElem, newElem: StyleElems.Parc; f: TextFrames.Frame;
  537.             PROCEDURE Replace (VAR t: Texts.Text; VAR r: Texts.Reader; styleElem: StyleElems.Parc);
  538.     BEGIN
  539.         Oberon.GetSelection(t, beg, end, time);
  540.         f := XIn.FocusFrame(TRUE);
  541.         InitPar;
  542.         o := p.NamedObject("styles"); title := o(DialogComboBoxes.Item).GetTitle();
  543.         Texts.OpenScanner(s, title, 0); Texts.Scan(s);
  544.         IF time >= 0 THEN
  545.             Texts.OpenReader(r, t, beg); Texts.ReadElem(r);
  546.             IF (s.class IN {Texts.Name, Texts.String}) & ~r.eot THEN
  547.                 elem := r.elem;
  548.                 WITH elem: StyleElems.Parc DO
  549.                     styleElem := ThisStyleElem(s.s);
  550.                     IF styleElem = NIL THEN
  551.                         Texts.WriteString(w, s.s); Call("StyleElems.Rename") 
  552.                     ELSE 
  553.                         Replace(t, r, styleElem) 
  554.                     END;
  555.                 | elem: TextFrames.Parc DO
  556.                     styleElem := ThisStyleElem(s.s);
  557.                     IF styleElem = NIL THEN
  558.                         NEW(styleElem); ParcElems.CopyParc(elem, styleElem); 
  559.                         styleElem.handle := StyleElems.Handle; COPY(s.s, styleElem.name);
  560.                     END;
  561.                     Replace(t, r, styleElem)
  562.                 ELSE
  563.                 END
  564.             END;
  565.         ELSE (* insert a style elem of the selected type at the caret position *)
  566.             IF (s.class IN {Texts.Name, Texts.String}) & (f # NIL) THEN
  567.                 styleElem := ThisStyleElem(s.s); NEW(newElem);
  568.                 StyleElems.Copy(styleElem, newElem);
  569.                 Texts.WriteElem(w, newElem);
  570.                 Texts.Insert(f.text, f.carloc.pos, w.buf)                
  571.             END
  572.         END
  573.     END Style;
  574. Syntax10.Scn.Fnt
  575. FoldElems
  576. Syntax10.Scn.Fnt
  577.                 VAR elem, next: StyleElem;
  578.             BEGIN
  579.                 Texts.OpenReader(r, t, 0); Texts.ReadElem(r);
  580.                 WHILE ~r.eot DO
  581.                     IF r.elem IS StyleElems.Parc THEN
  582.                         next := styleElems;
  583.                         WHILE (next # NIL) & (next.styleElem.name # r.elem(StyleElems.Parc).name) DO
  584.                             next := next.next
  585.                         END;
  586.                         IF next = NIL THEN    (* not yet contained => insert *)
  587.                             Texts.WriteString(w, r.elem(StyleElems.Parc).name); Texts.Write(w, 0DX);
  588.                             NEW(elem); elem.styleElem := r.elem(StyleElems.Parc);
  589.                             elem.next := styleElems; styleElems := elem
  590.                         END    
  591.                     END;
  592.                     Texts.ReadElem(r)
  593.                 END
  594.             END AddStyles;
  595. Syntax10i.Scn.Fnt
  596.         VAR t, t2, t3, menu: Texts.Text; beg, end, time: LONGINT;r: Texts.Reader; 
  597.             PROCEDURE AddStyles (t: Texts.Text);
  598.     BEGIN
  599.         Oberon.GetSelection(t, beg, end, time);
  600.         IF time >= 0 THEN
  601.             p := Dialogs.cmdPanel; o := p.NamedObject ("styles"); 
  602.             menu := o(DialogComboBoxes.Item).menu; Texts.Delete(menu, 0, menu.len);
  603.             Texts.OpenReader(r, t, beg); Texts.ReadElem(r);
  604.             IF ~r.eot & (Texts.Pos(r) <= end) THEN
  605.                 IF r.elem IS StyleElems.Parc THEN 
  606.                     t2 := o(DialogComboBoxes.Item).GetTitle(); Texts.Delete(t2, 0, t2.len);
  607.                     Texts.WriteString(w, r.elem(StyleElems.Parc).name); Texts.Append(t2, w.buf);
  608. Out.Ln; Out.String("Setting title to: "); Out.String(r.elem(StyleElems.Parc).name);
  609.                 END
  610.             END;
  611.             styleElems := NIL; (* remember the styleElems in the text with the selection and in Styles.Text *)
  612.             AddStyles(t);
  613.             t := TextFrames.Text(""); Texts.Open(t, "Styles.Text"); AddStyles(t);
  614.             Texts.Append(menu, w.buf)
  615.         END
  616.     END GetStyles;
  617. Syntax10.Scn.Fnt
  618.     BEGIN 
  619.         GetAdjust; GetBreak; GetColumns; GetFirst; GetGrid; GetLeft; GetRight; 
  620.         GetWidth; GetTabs; GetLead; GetLine; GetStyles
  621.     END GetAll;
  622. (*TD    PROCEDURE StoreSelection;
  623.     PROCEDURE RestoreSelection;
  624.     PROCEDURE Adjust*;
  625.     PROCEDURE GetAdjust*;
  626.     PROCEDURE Break*;
  627.     PROCEDURE GetBreak*;
  628.     PROCEDURE Columns*;
  629.     PROCEDURE GetColumns*;
  630.     PROCEDURE First*;
  631.     PROCEDURE GetFirst*;
  632.     PROCEDURE FirstReset*;
  633.     PROCEDURE Grid*;
  634.     PROCEDURE GetGrid*;
  635.     PROCEDURE Lead*;
  636.     PROCEDURE GetLead*;
  637.     PROCEDURE LeadReset*;
  638.     PROCEDURE Left*;
  639.     PROCEDURE GetLeft*;
  640.     PROCEDURE LeftReset*;
  641.     PROCEDURE Right*;
  642.     PROCEDURE GetRight*;
  643.     PROCEDURE RightReset*;
  644.     PROCEDURE Line*; 
  645.     PROCEDURE GetLine*;
  646.     PROCEDURE LineReset*;
  647.     PROCEDURE Tabs*;
  648.     PROCEDURE GetTabs*;
  649.     PROCEDURE TabsReset1*;
  650.     PROCEDURE TabsReset2*;
  651.     PROCEDURE Width*;
  652.     PROCEDURE GetWidth*;
  653.     PROCEDURE WidthReset*;
  654.     PROCEDURE ThisStyleElem (VAR n: ARRAY OF CHAR): StyleElems.Parc;
  655.     PROCEDURE Style*;
  656.     PROCEDURE GetStyles*;
  657.     PROCEDURE GetAll*;
  658. Syntax10.Scn.Fnt
  659. Syntax10b.Scn.Fnt
  660. FoldElems
  661. Syntax10.Scn.Fnt
  662.             VAR t: Texts.Text;
  663.         BEGIN
  664.             t := o(DialogTexts.Item).GetText(); Texts.Delete(t, 0, t.len);
  665.             Texts.WriteInt(w, l, 0); Texts.Append(t, w.buf)
  666.         END WriteNumber;
  667. Syntax10.Scn.Fnt
  668.             VAR w: Texts.Writer; t: Texts.Text; i: INTEGER;
  669.         BEGIN
  670.             t := o(DialogTexts.Item).GetText(); Texts.Delete(t, 0, t.len);
  671.             i := 0; 
  672.             WHILE s[i] # 0X DO Texts.Write(w, s[i]); INC(i) END;
  673.         END WriteName;
  674. Syntax10.Scn.Fnt
  675. FoldElems
  676. Syntax10.Scn.Fnt
  677.                 VAR t: Texts.Text; l: LONGINT;
  678.             BEGIN
  679.                 Files.ReadLInt(r, l);
  680.                 t := o(DialogTexts.Item).GetText(); Texts.Delete(t, 0, t.len);
  681.                 Texts.WriteInt(w, l, 0); Texts.Append(t, w.buf)
  682.             END WriteNumber;
  683. Syntax10.Scn.Fnt
  684.                 VAR w: Texts.Writer; t: Texts.Text; ch: CHAR;
  685.             BEGIN
  686.                 t := o(DialogTexts.Item).GetText(); Texts.Delete(t, 0, t.len);
  687.                 Files.Read(r, ch); Texts.OpenWriter(w);
  688.                 WHILE ch # 0X DO Texts.Write(w, ch); Files.Read(r, ch) END;
  689.             END WriteName;
  690.         VAR r: Files.Rider; f: Files.File; b: BOOLEAN; o: Dialogs.Object;
  691.             PROCEDURE WriteNumber(o: Dialogs.Object);
  692.             PROCEDURE WriteName(o: Dialogs.Object);
  693.     BEGIN
  694.         f := Files.Old(PrintOptionsFile);
  695.         IF f # NIL THEN
  696.             p := Dialogs.cmdPanel; Files.Set(r, f, 0);
  697.             Files.ReadBool (r, b); ChangeValue ("alternate", b); Files.ReadBool (r, b); ChangeValue ("nopagenr", b);
  698.             Files.ReadBool (r, b); ChangeValue ("nopagenr1", b); Files.ReadBool (r, b); ChangeValue ("Romanum", b);
  699.             Files.ReadBool (r, b); ChangeValue ("draft", b);
  700.             o := p.NamedObject("tfirstpage"); WriteNumber(o); o := p.NamedObject("copies"); WriteNumber(o);
  701.             o := p.NamedObject("font"); WriteName(o);
  702.             Files.ReadBool (r, b); ChangeValue ("nohdr", b); Files.ReadBool (r, b); ChangeValue ("defhdr", b);
  703.             Files.ReadBool (r, b); ChangeValue ("header", b);
  704.             o := p.NamedObject("thdr"); WriteName(o);
  705.             Files.ReadBool (r, b); ChangeValue ("custom1", b); Files.ReadBool (r, b); ChangeValue ("default1", b);
  706.             o := p.NamedObject("postxtleft"); WriteNumber(o); o := p.NamedObject("postxtbottom"); WriteNumber(o);
  707.             o := p.NamedObject("txtwidth"); WriteNumber(o); o := p.NamedObject("txtheight"); WriteNumber(o);
  708.             Files.ReadBool (r, b); ChangeValue ("custom2", b); Files.ReadBool (r, b); ChangeValue ("default2", b);
  709.             o := p.NamedObject("poshdrleft"); WriteNumber(o); o := p.NamedObject("poshdrbottom"); WriteNumber(o);
  710.             o := p.NamedObject("hdrwidth"); WriteNumber(o);
  711.             Files.ReadBool (r, b); ChangeValue ("fromto", b); Files.ReadBool (r, b); ChangeValue ("all", b);
  712.             o := p.NamedObject("from"); WriteNumber(o); o := p.NamedObject("to"); WriteNumber(o)
  713.         ELSE SetDefaultOptions END;
  714.     END InitPrintDlg;
  715. Syntax10.Scn.Fnt
  716. FoldElems
  717. Syntax10.Scn.Fnt
  718.             VAR s: Texts.Scanner; t: Texts.Text; l: LONGINT;
  719.         BEGIN
  720.             t := o(DialogTexts.Item).GetText(); l := 0;
  721.             IF t.len > 0 THEN
  722.                 Texts.OpenScanner(s, t, 0); Texts.Scan(s); IF s.class = Texts.Int THEN l := s.i END
  723.             END;
  724.             Files.WriteLInt(r, l)        
  725.         END WriteNumber;
  726. Syntax10.Scn.Fnt
  727.             VAR rt: Texts.Reader; t: Texts.Text; ch: CHAR;
  728.         BEGIN
  729.             t := o(DialogTexts.Item).GetText();
  730.             Texts.OpenReader(rt, t, 0); Texts.Read(rt, ch);
  731.             WHILE ~rt.eot DO Files.Write(r, ch); Texts.Read(rt, ch) END;
  732.             Files.Write(r, 0X)        
  733.         END WriteName;
  734.     VAR r: Files.Rider; f: Files.File;
  735.         PROCEDURE WriteNumber(o: Dialogs.Object);
  736.         PROCEDURE WriteName(o: Dialogs.Object);
  737.     BEGIN
  738.         f := Files.New(PrintOptionsFile); Files.Set(r, f, 0);
  739.         p := Dialogs.cmdPanel;
  740.         o := p.NamedObject("alternate"); Files.WriteBool(r, o(DialogCheckBoxes.Item).on);
  741.         o := p.NamedObject("nopagenr"); Files.WriteBool(r, o(DialogCheckBoxes.Item).on);
  742.         o := p.NamedObject("nopagenr1"); Files.WriteBool(r, o(DialogCheckBoxes.Item).on);
  743.         o := p.NamedObject("Romannum"); Files.WriteBool(r, o(DialogCheckBoxes.Item).on);
  744.         o := p.NamedObject("draft"); Files.WriteBool(r, o(DialogCheckBoxes.Item).on);
  745.         o := p.NamedObject("tfirstpage"); WriteNumber(o);
  746.         o := p.NamedObject("copies"); WriteNumber(o);
  747.         o := p.NamedObject("font"); WriteName(o);
  748.         o := p.NamedObject("nohdr"); Files.WriteBool(r, o(DialogRadioButtons.Item).on);
  749.         o := p.NamedObject("defhdr"); Files.WriteBool(r, o(DialogRadioButtons.Item).on);
  750.         o := p.NamedObject("header"); Files.WriteBool(r, o(DialogRadioButtons.Item).on);
  751.         o := p.NamedObject("thdr"); WriteName(o);
  752.         o := p.NamedObject("custom1"); Files.WriteBool(r, o(DialogRadioButtons.Item).on);
  753.         o := p.NamedObject("default1"); Files.WriteBool(r, o(DialogRadioButtons.Item).on);
  754.         o := p.NamedObject("postxtleft"); WriteNumber(o);
  755.         o := p.NamedObject("postxtbottom"); WriteNumber(o);
  756.         o := p.NamedObject("txtwidth"); WriteNumber(o);
  757.         o := p.NamedObject("txtheight"); WriteNumber(o);
  758.         o := p.NamedObject("custom2"); Files.WriteBool(r, o(DialogRadioButtons.Item).on);
  759.         o := p.NamedObject("default2"); Files.WriteBool(r, o(DialogRadioButtons.Item).on);
  760.         o := p.NamedObject("poshdrleft"); WriteNumber(o);
  761.         o := p.NamedObject("poshdrbottom"); WriteNumber(o);
  762.         o := p.NamedObject("hdrwidth"); WriteNumber(o);
  763.         o := p.NamedObject("fromto"); Files.WriteBool(r, o(DialogRadioButtons.Item).on);
  764.         o := p.NamedObject("all"); Files.WriteBool(r, o(DialogRadioButtons.Item).on);
  765.         o := p.NamedObject("from"); WriteNumber(o);
  766.         o := p.NamedObject("to"); WriteNumber(o);
  767.         Files.Register(f)
  768.     END SaveOptions;
  769. Syntax10.Scn.Fnt
  770.         VAR t: Texts.Text; o: Dialogs.Object; 
  771.     BEGIN
  772.         InitPar; Texts.WriteString(w, "QuickDraw * ");
  773.         IF On ("draft") THEN Texts.WriteString(w, "% ") END;
  774.         IF On ("alternate") THEN Texts.Write(w, OptionChar); Texts.WriteString(w, "a ") END;
  775.         IF On ("nopagenr") THEN Texts.Write(w, OptionChar); Texts.WriteString(w, "p n ") END;
  776.         IF On ("nopagenr1") THEN Texts.Write(w, OptionChar); Texts.WriteString(w, "p f ") END;
  777.         IF On ("Romannum") THEN Texts.Write(w, OptionChar); Texts.WriteString(w, "p r ") END;
  778.         o := p.NamedObject("tfirstpage"); t := o(DialogTexts.Item).GetText();
  779.         IF t.len > 0 THEN Texts.Write(w, OptionChar); Texts.WriteString(w, "p ");Texts.Save(t, 0, t.len, w.buf); Texts.Write(w, " ") END;
  780.         o := p.NamedObject("font"); t := o(DialogTexts.Item).GetText();
  781.         IF t.len > 0 THEN Texts.Write(w, OptionChar); Texts.WriteString(w, "f "); Texts.Save(t, 0, t.len, w.buf); Texts.Write(w, " ") END;
  782.         o := p.NamedObject("copies"); t := o(DialogTexts.Item).GetText();
  783.         IF t.len > 0 THEN Texts.Write(w, OptionChar); Texts.WriteString(w, "c "); Texts.Save(t, 0, t.len, w.buf); Texts.Write(w, " ") END;
  784.         IF On ("defhdr") THEN Texts.Write(w, OptionChar); Texts.WriteString(w, "h ") END;
  785.         IF On ("header") THEN         
  786.             Texts.Write(w, OptionChar); Texts.WriteString(w, "h "); Save ("thdr"); Texts.Write(w, " ")
  787.         END;
  788.         IF On ("custom1") THEN 
  789.             Texts.Write(w, OptionChar); Texts.WriteString(w, "m b "); 
  790.             Save ("postxtleft"); Texts.Write(w, " "); Save ("postxtbottom"); Texts.Write(w, " ");
  791.             Save ("txtwidth"); Texts.Write(w, " "); Save ("txtheight"); Texts.Write(w, " ")
  792.         END;
  793.         IF On ("custom2") THEN 
  794.             Texts.Write(w, OptionChar); Texts.WriteString(w, "m h "); Save ("poshdrleft"); Texts.Write(w, " ");
  795.             Save ("poshdrbottom"); Texts.Write(w, " "); Save ("hdrwidth"); Texts.Write(w, " ")
  796.         END;
  797.         IF On ("fromto") THEN 
  798.             Texts.Write(w, OptionChar); Texts.WriteString(w, "s ");
  799.             o := p.NamedObject("from"); t := o(DialogTexts.Item).GetText(); IF t.len > 0 THEN Texts.Save(t, 0, t.len, w.buf) END;
  800.             Texts.Write(w, " ");
  801.             o := p.NamedObject("to"); t := o(DialogTexts.Item).GetText(); IF t.len > 0 THEN Texts.Save(t, 0, t.len, w.buf) END
  802.         END;
  803.         Call ("Edit.Print")
  804.     END Print;
  805.     PROCEDURE SetDefaultOptions*;
  806.         VAR o: Dialogs.Object;
  807.         PROCEDURE WriteNumber(o: Dialogs.Object; l: LONGINT);
  808.         PROCEDURE WriteName(o: Dialogs.Object; s: ARRAY OF CHAR);
  809.     BEGIN
  810.         p := Dialogs.cmdPanel;
  811.         ChangeValue ("alternate", FALSE); ChangeValue ("nopagenr", FALSE);
  812.         ChangeValue ("nopagenr1", FALSE); ChangeValue ("Romannum", FALSE);
  813.         ChangeValue ("draft", FALSE); 
  814.         o := p.NamedObject("tfirstpage"); WriteNumber(o, 0);
  815.         o := p.NamedObject("copies"); WriteNumber(o, 1);
  816.         o := p.NamedObject("font"); WriteName(o, "");
  817.         ChangeValue ("nohdr", FALSE); ChangeValue ("defhdr", TRUE);
  818.         ChangeValue ("header", FALSE); ChangeValue ("custom1", FALSE);
  819.         o := p.NamedObject("thdr"); WriteName(o, "");
  820.         ChangeValue ("default1", TRUE); ChangeValue ("custom2", FALSE);
  821.         o := p.NamedObject("postxtleft"); WriteNumber(o, 150);
  822.         o := p.NamedObject("postxtbottom"); WriteNumber(o, 150);
  823.         o := p.NamedObject("txtwidth"); WriteNumber(o, 1650);
  824.         o := p.NamedObject("txtheight"); WriteNumber(o, 2600);
  825.         o := p.NamedObject("poshdrleft"); WriteNumber(o, 150);
  826.         o := p.NamedObject("poshdrbottom"); WriteNumber(o, 2800);
  827.         o := p.NamedObject("hdrwidth"); WriteNumber(o, 1650);
  828.         ChangeValue ("default2", TRUE); ChangeValue ("fromto", FALSE); ChangeValue ("all", TRUE);
  829.         o := p.NamedObject("from"); WriteNumber(o, 0);
  830.         o := p.NamedObject("to"); WriteName(o, "");
  831.     END SetDefaultOptions;
  832.     PROCEDURE InitPrintDlg*;
  833.     PROCEDURE SaveOptions*;
  834.     PROCEDURE Print*;
  835. Syntax10.Scn.Fnt
  836. Syntax10b.Scn.Fnt
  837. FoldElems
  838. Syntax10.Scn.Fnt
  839.         VAR res: INTEGER; t: Texts.Text; o: Dialogs.Object;
  840.     BEGIN
  841.         p := Dialogs.cmdPanel; o := p.NamedObject("search"); t := o(DialogTexts.Item).GetText();
  842.         o(DialogTexts.Item).SetSelection(0, t.len);
  843.         IF On ("folds") THEN Oberon.Call("FoldElems.Search", Oberon.Par, FALSE, res)
  844.         ELSE Oberon.Call("Edit.Search", Oberon.Par, FALSE, res)
  845.         END;
  846.         o(DialogTexts.Item).RemoveSelection;
  847.         doSearch := FALSE
  848.     END Search;
  849. Syntax10.Scn.Fnt
  850.         VAR res: INTEGER; t: Texts.Text; o: Dialogs.Object; f: TextFrames.Frame;
  851.     BEGIN
  852.         f := XIn.FocusFrame(TRUE);
  853.         IF f # NIL THEN 
  854.             p := Dialogs.cmdPanel; 
  855.             IF doSearch THEN
  856.                 doSearch := FALSE;
  857.                 o := p.NamedObject("search"); t := o(DialogTexts.Item).GetText();
  858.                 o(DialogTexts.Item).SetSelection(0, t.len);
  859.                 IF On ("folds") THEN Oberon.Call("FoldElems.Search", Oberon.Par, FALSE, res)
  860.                 ELSE Oberon.Call("Edit.Search", Oberon.Par, FALSE, res)
  861.                 END;
  862.                 o(DialogTexts.Item).RemoveSelection;
  863.             END;
  864.             o := p.NamedObject("repl"); t := o(DialogTexts.Item).GetText();
  865.             IF t.len = 0 THEN 
  866.                 Oberon.Call("Edit.ClearReplaceBuffer", Oberon.Par, FALSE, res)
  867.             ELSE
  868.                 o(DialogTexts.Item).SetSelection(0, t.len)
  869.             END;
  870.             IF On ("all") THEN Oberon.Call("Edit.ReplaceAll", Oberon.Par, FALSE, res)
  871.             ELSE Oberon.Call("Edit.Replace", Oberon.Par, FALSE, res)
  872.             END;
  873.             o(DialogTexts.Item).RemoveSelection
  874.         END
  875.     END Replace;
  876. Syntax10.Scn.Fnt
  877.     BEGIN doSearch := TRUE
  878.     END SearchReset;
  879.     PROCEDURE Search*;
  880.     PROCEDURE Replace*;
  881.     PROCEDURE SearchReset*;
  882. Syntax10.Scn.Fnt
  883. FoldElems
  884. Syntax10.Scn.Fnt
  885.         VAR t: Texts.Text; beg, end, time: LONGINT; r: Texts.Reader; type: Types.Type;
  886.             s: ARRAY 64 OF CHAR; i, j: INTEGER;
  887.     BEGIN
  888.         Oberon.GetSelection(t, beg, end, time);
  889.         IF time >= 0 THEN
  890.             Texts.OpenReader(r, t, beg); Texts.ReadElem(r);
  891.             IF ~r.eot THEN
  892.                 type := Types.TypeOf(r.elem);
  893.                 p := Dialogs.cmdPanel; o := p.NamedObject("type");
  894.                 i := 0; WHILE type.module.name[i] # 0X DO s[i] := type.module.name[i]; INC(i) END; s[i] := "."; INC(i);
  895.                 j := i; WHILE type.name[j - i] # 0X DO s[j] := type.name[j - i]; INC(j) END; s[j] := 0X;
  896.                 o(DialogStaticTexts.Item).SetString(s)
  897.             END
  898.         END
  899.     END GetType;
  900. PROCEDURE GetType*;
  901. Syntax10.Scn.Fnt
  902. Syntax10b.Scn.Fnt
  903. FoldElems
  904. Syntax10.Scn.Fnt
  905.         VAR var: Var; txt: Texts.Text;
  906.     BEGIN
  907.         NEW(var); var.next := vars; vars := var; COPY(n, var.name); var.value := value;
  908.         p := Dialogs.cmdPanel; o := p.NamedObject("gset"); txt := o(DialogComboBoxes.Item).menu;
  909.         Texts.WriteString(w, n); Texts.Write(w, 0DX);
  910.         Texts.Append(txt, w.buf);
  911.     END AddVar;
  912. Syntax10.Scn.Fnt
  913. FoldElems
  914. Syntax10.Scn.Fnt
  915.             VAR x, y: LONGINT; i: INTEGER;
  916.                 a: ARRAY 10 OF CHAR;
  917.         BEGIN x := ENTIER(n + eps0);
  918.             i := 0; Texts.Write(w, " ");
  919.             REPEAT y := x MOD 10H;
  920.                 IF y < 10 THEN a[i] := CHR(y + 30H) ELSE a[i] := CHR(y + 37H) END;
  921.                 x := x DIV 10H; INC(i)
  922.             UNTIL i = 8;
  923.             REPEAT DEC(i) UNTIL (i = 0) OR (a[i] # "0");
  924.             IF a[i] >= "A" THEN Texts.Write(w, "0") END;
  925.             WHILE i >= 0 DO Texts.Write(w, a[i]); DEC(i) END;
  926.             Texts.Write(w, "H")
  927.         END WrHex; 
  928. Syntax10.Scn.Fnt
  929.             VAR x: LONGINT; i: INTEGER;
  930.                 a: ARRAY 30 OF CHAR;
  931.         BEGIN x := ENTIER(n + eps0);
  932.             i := 0; Texts.Write(w, " ");
  933.             REPEAT
  934.                 a[i] := CHR(ORD("0") + (x MOD 2));
  935.                 x := x DIV 2; INC(i)
  936.             UNTIL i = 28;
  937.             REPEAT DEC(i) UNTIL (i = 0) OR (a[i] # "0");
  938.             WHILE i >= 0 DO Texts.Write(w, a[i]); DEC(i) END;
  939.             Texts.Write(w, "B")
  940.         END WrBin;
  941. Syntax10.Scn.Fnt
  942.             VAR x, y: LONGINT; i: INTEGER;
  943.                 a: ARRAY 16 OF CHAR;
  944.         BEGIN x := ENTIER(n + eps0);
  945.             i := 0; Texts.Write(w, " ");
  946.             REPEAT y := x MOD 8;
  947.                 a[i] := CHR(y + 30H);
  948.                 x := x DIV 8; INC(i)
  949.             UNTIL i = 14;
  950.             REPEAT DEC(i) UNTIL (i = 0) OR (a[i] # "0");
  951.             WHILE i >= 0 DO Texts.Write(w, a[i]); DEC(i) END;
  952.             Texts.Write(w, "C")
  953.         END WrOct; 
  954. Syntax10.Scn.Fnt
  955.             BEGIN Texts.Write(w, " "); Texts.WriteInt(w, ENTIER(n + eps0), 0) END WrInt; 
  956. Syntax10.Scn.Fnt
  957. FoldElems
  958. Syntax10.Scn.Fnt
  959.                 BEGIN Texts.Write(w, ch) END Ch;
  960.             VAR ch: CHAR;
  961.             PROCEDURE Ch (ch: CHAR);
  962.         BEGIN ch := CHR(ENTIER(n + eps0));
  963.             IF (" " <= ch) & (ch < 7FX) OR (80X <= ch) & (ch < 0A0X) THEN Ch(" "); Ch(22X); Ch(ch); Ch(22X)
  964.             ELSE WrHex(ORD(ch))
  965.             END
  966.         END WrChar; 
  967. Syntax10.Scn.Fnt
  968. Syntax10b.Scn.Fnt
  969.             VAR x: LONGREAL;
  970.         BEGIN
  971.             IF (MIN(LONGINT) <= n) & (n <= MAX(LONGINT)) THEN 
  972.                 x := ABS(n - ENTIER(SHORT(n)));
  973.                 IF x < eps THEN WrInt(n); RETURN END
  974.             END;
  975.             IF (MIN(REAL) <= n) & (n <= MAX(REAL)) THEN x := ABS(n - SHORT(n));
  976.                 IF x < eps THEN
  977.                     IF (-10000 < n) & (n < 10000) THEN Texts.WriteRealFix(w, SHORT(n + eps0), 0, 6)
  978.                     ELSE Texts.WriteReal(w, SHORT(n + eps0), 14)
  979.                     END;
  980.                     RETURN
  981.                 END
  982.             END;
  983.             Texts.WriteLongReal(w, n, 23)
  984.         END WrReal; 
  985.         VAR r: Texts.Reader; txt: Texts.Text; i: INTEGER; str: ARRAY 32 OF CHAR;
  986.             s: Texts.Scanner;
  987.         PROCEDURE WrHex (n: LONGREAL);
  988.         PROCEDURE WrBin (n: LONGREAL);
  989.         PROCEDURE WrOct (n: LONGREAL);
  990.         PROCEDURE WrInt (n: LONGREAL);
  991.         PROCEDURE WrChar (n: LONGREAL);
  992.         PROCEDURE WrReal (n: LONGREAL);
  993.     BEGIN
  994.         p := Dialogs.cmdPanel; IF p = NIL THEN RETURN END;
  995.         o := p.NamedObject("mode"); IF o = NIL THEN RETURN END;
  996.         txt := o(DialogComboBoxes.Item).GetTitle();
  997.         Texts.OpenScanner(s, txt, 0); Texts.Scan(s);
  998.         IF s.s = "hex" THEN WrHex(value)
  999.         ELSIF s.s = "bin" THEN WrBin(value)
  1000.         ELSIF s.s = "oct" THEN WrOct(value)
  1001.         ELSIF s.s = "dec" THEN WrInt(value)
  1002.         ELSIF s.s = "char" THEN WrChar(value)
  1003.         ELSE WrReal(value) END;
  1004.         txt := TextFrames.Text(""); Texts.Append(txt, w.buf); Texts.OpenReader(r, txt, 0); i := 0;
  1005.         REPEAT
  1006.             Texts.Read(r, str[i]);
  1007.             INC(i)
  1008.         UNTIL r.eot;
  1009.         str[i - 1] := 0X;
  1010.         o := p.NamedObject("t1"); o(DialogStaticTexts.Item).SetString(str)
  1011.     END ShowNumber;
  1012. Syntax10.Scn.Fnt
  1013.     BEGIN 
  1014.         oldValue := 0; value := 0; commaPos := 10; 
  1015.         oldOp := "add";
  1016.         newNumber := TRUE;
  1017.         ShowNumber;
  1018.     END Clear;
  1019. Syntax10.Scn.Fnt
  1020.         VAR txt: Texts.Text;
  1021.     BEGIN 
  1022.         Clear; 
  1023.         p := Dialogs.cmdPanel; IF p = NIL THEN RETURN END;
  1024.         o := p.NamedObject("gset");  IF o = NIL THEN RETURN END;
  1025.         txt := o(DialogComboBoxes.Item).menu; Texts.Delete(txt, 0, txt.len);
  1026.         vars := NIL;
  1027.         AddVar("pi", MathL.pi);
  1028.         AddVar("e", MathL.e);
  1029.         o := p.NamedObject("gset");
  1030.         txt := TextFrames.Text(""); o(DialogComboBoxes.Item).SetTitle(txt)
  1031.     END Reset;
  1032. Syntax10.Scn.Fnt
  1033.         VAR i, base: INTEGER; txt: Texts.Text; s: Texts.Scanner;
  1034.     BEGIN
  1035.         In.Open; In.Int(i);
  1036.         p := Dialogs.cmdPanel; o := p.NamedObject("mode"); txt := o(DialogComboBoxes.Item).GetTitle();
  1037.         Texts.OpenScanner(s, txt, 0); Texts.Scan(s);
  1038.         IF s.s = "hex" THEN base := 16
  1039.         ELSIF s.s = "bin" THEN base := 2
  1040.         ELSIF s.s = "oct" THEN base := 8
  1041.         ELSE base := 10 END;
  1042.         IF newNumber THEN
  1043.             newNumber := FALSE;
  1044.             value := i
  1045.         ELSIF commaPos > 1 THEN
  1046.             value := base * value + i
  1047.         ELSE
  1048.             commaPos := commaPos / base;
  1049.             value := value + commaPos * i
  1050.         END;
  1051.         ShowNumber
  1052.     END Num;
  1053. Syntax10.Scn.Fnt
  1054.         BEGIN commaPos := 1 END Comma;
  1055. Syntax10.Scn.Fnt
  1056. FoldElems
  1057. Syntax10.Scn.Fnt
  1058.             VAR o: Dialogs.Object;
  1059.         BEGIN
  1060.             o := p.NamedObject("inv");
  1061.             RETURN o(DialogCheckBoxes.Item).on
  1062.         END Invers;
  1063. Syntax10.Scn.Fnt
  1064.         BEGIN
  1065.             IF op = "add" THEN value := oldValue + value; oldValue := value
  1066.             ELSIF op = "sub" THEN value := oldValue - value; oldValue := value
  1067.             ELSIF op = "mult" THEN value := oldValue * value; oldValue := value
  1068.             ELSIF op = "div" THEN value := oldValue / value; oldValue := value
  1069.             ELSIF op = "sign" THEN value := - value
  1070.             ELSIF op = "oneDivX" THEN value := 1 / value
  1071.             ELSIF op = "sqr" THEN IF ~Invers() THEN value := value * value ELSE value := MathL.sqrt(value) END
  1072.             ELSIF op = "sin" THEN IF ~Invers() THEN value := MathL.sin(value) ELSE value := MoreMathL.arcsin(value) END
  1073.             ELSIF op = "cos" THEN IF ~Invers() THEN value := MathL.cos(value) ELSE value := MoreMathL.arccos(value) END
  1074.             ELSIF op = "tan" THEN IF ~Invers() THEN value := MoreMathL.tan(value) ELSE value := MathL.arctan(value) END
  1075.             ELSIF op = "exp" THEN IF ~Invers() THEN value := MathL.exp(value) ELSE value := MathL.ln(value) END
  1076.             ELSE Out.Ln; Out.String("unexpected operator: "); Out.String(op) END;
  1077.         END OpLocal;
  1078.         PROCEDURE Invers(): BOOLEAN;
  1079.         PROCEDURE OpLocal(op: Operation);
  1080.     BEGIN
  1081.         In.Open; 
  1082.         In.Name(op);
  1083.         IF (op = "add") OR (op = "sub") OR (op = "mult") OR (op = "div") OR (op = "res") THEN 
  1084.             OpLocal(oldOp);
  1085.             IF op # "=" THEN oldOp := op END
  1086.         ELSE OpLocal(op) END;
  1087.         commaPos := 10; newNumber := TRUE;
  1088.         ShowNumber
  1089.     END Op;
  1090. Syntax10.Scn.Fnt
  1091.         VAR txt: Texts.Text; r: Texts.Reader; i: INTEGER; var: Var;
  1092.     BEGIN
  1093.         p := Dialogs.cmdPanel; o := p.NamedObject("set"); txt := o(DialogTexts.Item).GetText();
  1094.         NEW(var); var.next := NIL; var.value := value;
  1095.         Texts.OpenReader(r, txt, 0); i := 0; Texts.Read(r, var.name[i]);
  1096.         WHILE ~r.eot DO
  1097.             INC(i);
  1098.             Texts.Read(r, var.name[i])
  1099.         END;
  1100.         o := p.NamedObject("gset"); txt := o(DialogComboBoxes.Item).menu;
  1101.         Texts.WriteString(w, var.name); Texts.Write(w, 0DX);
  1102.         Texts.Append(txt, w.buf);
  1103.         var.next := vars; vars := var
  1104.     END SetVar;
  1105. Syntax10.Scn.Fnt
  1106.         VAR txt: Texts.Text; cur: Var; s: ARRAY 32 OF CHAR; r: Texts.Reader; i: INTEGER;
  1107.     BEGIN
  1108.         p := Dialogs.cmdPanel; o := p.NamedObject("gset"); txt := o(DialogComboBoxes.Item).GetTitle();
  1109.         Texts.OpenReader(r, txt, 0); i := 0; Texts.Read(r, s[i]);
  1110.         WHILE ~r.eot & (s[i] # 0DX) DO
  1111.             INC(i);
  1112.             Texts.Read(r, s[i])
  1113.         END;
  1114.         s[i] := 0X;
  1115.         cur := vars;
  1116.         WHILE (cur # NIL) & (cur.name # s) DO cur := cur.next END;
  1117.         IF (cur # NIL) & (cur.name = s) THEN value := cur.value; ShowNumber END
  1118.     END Variable;
  1119. Syntax10.Scn.Fnt
  1120.         VAR menu, title: Texts.Text;
  1121.     BEGIN
  1122.         Reset;
  1123.         p := Dialogs.cmdPanel; o := p.NamedObject("mode"); menu := o(DialogComboBoxes.Item).menu;
  1124.         Texts.WriteString(w, "dec"); Texts.Write(w, 0DX);
  1125.         Texts.WriteString(w, "bin"); Texts.Write(w, 0DX);
  1126.         Texts.WriteString(w, "oct"); Texts.Write(w, 0DX);
  1127.         Texts.WriteString(w, "hex"); Texts.Write(w, 0DX);
  1128.         Texts.WriteString(w, "real"); Texts.Write(w, 0DX);
  1129.         Texts.WriteString(w, "char"); Texts.Write(w, 0DX);
  1130.         Texts.Append(menu, w.buf);
  1131.         title := TextFrames.Text(""); Texts.WriteString(w, "dec"); Texts.Append(title, w.buf);
  1132.         o(DialogComboBoxes.Item).SetTitle(title)
  1133.     END InitCalc;
  1134.     PROCEDURE AddVar* (n: ARRAY OF CHAR; value: LONGREAL);
  1135.     PROCEDURE ShowNumber*;
  1136.     PROCEDURE Clear*;
  1137.     PROCEDURE Reset*;
  1138.     PROCEDURE Num*;
  1139.     PROCEDURE Comma*; 
  1140.     PROCEDURE Op*;
  1141.     PROCEDURE SetVar*;
  1142.     PROCEDURE Variable*;
  1143.     PROCEDURE InitCalc*;
  1144. MODULE MyUI;    
  1145.     (* Christoph Steindl 20 Dec 94 - 
  1146.     (* Folds.Compile XIn.Mod/s MoreMathL.Mod/s MyUI.Mod/s ~ *)
  1147. IMPORT Dialogs, Oberon, Texts, TextFrames, DialogCheckBoxes, DialogRadioButtons, DialogComboBoxes,
  1148.         DialogTexts, In, Out, Compiler, Files, MenuViewers, Viewers, Display, StyleElems, ParcElems, Types,
  1149.         DialogStaticTexts, MathL, MoreMathL, XIn;
  1150. Constants
  1151. Types
  1152. Global variables
  1153. common procedures
  1154. Commands for the dialogue Compiler.Dlg
  1155. Commands for the dialogue GetSet.Dlg
  1156. Commands for the dialogue Print.Dlg
  1157. Commands for the dialogue Search.Dlg
  1158. Commands for the dialogue Inspector.Dlg
  1159. Commands for the dialogue Calc.Dlg
  1160. BEGIN 
  1161.     doSearch := TRUE; Texts.OpenWriter (w);
  1162.     Reset
  1163. END MyUI.Unload    MyUI.DoHALT
  1164. Dialog.Open Insert.Dlg
  1165. Dialog.Open Compiler.Dlg
  1166. Dialog.Open GetSet.Dlg
  1167. Dialog.Open Print.Dlg
  1168. Dialog.Open Search.Dlg
  1169. Dialog.Open Inspector.Dlg
  1170. Dialog.Open Calc.Dlg
  1171. AsciiCoder.CodeFiles % MyUI.Mod MoreMathL.Mod XIn.Mod Insert.Dlg Compiler.Dlg 
  1172.     GetSet.Dlg Print.Dlg Search.Dlg Inspector.Dlg Calc.Dlg ~
  1173.