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

  1. Syntax10.Scn.Fnt
  2. Syntax10b.Scn.Fnt
  3. InfoElems
  4. Alloc
  5. Syntax10.Scn.Fnt
  6. StampElems
  7. Alloc
  8. 10 Feb 95
  9. "Title": XIn.Mod - Extended In
  10. "Author": Christoph Steindl (CS)
  11. "Abstract": Extended In provides some often needed procedures in order to read parameters (marked viewer,
  12.     focus viewer, scanner for arguments, viewer with selection)
  13. "Keywords": marked viewer, focus frame, arguments
  14. "Version": 1.0
  15. "From":  17.01.95 15:17:52
  16. "Until": 
  17. "Changes": no changes
  18. "Hints": 
  19. Syntax10i.Scn.Fnt
  20. StampElems
  21. Alloc
  22. 10 Feb 95
  23. Syntax8i.Scn.Fnt
  24. FoldElems
  25. Syntax8i.Scn.Fnt
  26. Returns the marked text frame.
  27. Syntax8i.Scn.Fnt
  28. Returns the text frame with the input focus. 
  29.         If needsCaret is TRUE the frame only is returned if it shows the caret.
  30. Syntax8.Scn.Fnt
  31. Syntax8i.Scn.Fnt
  32. If last command was executed from a menuviewer, 
  33.         TargetFrame returns the menu viewers body, otherwise the FocusFrame(needsCaret).
  34. Syntax8i.Scn.Fnt
  35. Returns the scanner for the arguments after the command or (^) at the 
  36.         selection (most recent selection).
  37. Syntax8i.Scn.Fnt
  38. Returs the scanner for the arguments after the command or (^) at the 
  39.         selection in the command frame
  40. Syntax8i.Scn.Fnt
  41. Opens and returns a temporary viewer.
  42. Syntax8i.Scn.Fnt
  43. Removes the exclamation mark from the menu frame of the viewer.
  44. Syntax8i.Scn.Fnt
  45. Like Oberon.GetSelection, additionally it returns the viewer which contains the selection.
  46. MODULE XIn;    
  47.     (* Christoph Steindl (CS), 17.01.95 - 
  48. IMPORT TextFrames, Texts, Viewers, Oberon, MenuViewers, Display;
  49.     PROCEDURE MarkedFrame* (): TextFrames.Frame;
  50.         VAR v: Viewers.Viewer;
  51.     BEGIN v := Oberon.MarkedViewer();
  52.         IF (v # NIL) & (v IS MenuViewers.Viewer) & (v.dsc.next IS TextFrames.Frame) THEN
  53.             RETURN v.dsc.next(TextFrames.Frame)
  54.         ELSE RETURN NIL
  55.         END
  56.     END MarkedFrame;
  57.     PROCEDURE FocusFrame* (needsCaret: BOOLEAN): TextFrames.Frame;
  58.         VAR v: Viewers.Viewer; f: TextFrames.Frame;
  59.     BEGIN v := Oberon.FocusViewer;
  60.         IF (v # NIL) & (v IS MenuViewers.Viewer) & (v.dsc # NIL) & (v.dsc.next # NIL) & (v.dsc.next IS TextFrames.Frame) THEN
  61.             f := v.dsc.next(TextFrames.Frame);
  62.             IF needsCaret THEN 
  63.                 IF f.hasCar THEN RETURN f ELSE RETURN NIL END 
  64.             ELSE RETURN f 
  65.             END
  66.         ELSE RETURN NIL
  67.         END
  68.     END FocusFrame;
  69.     PROCEDURE TargetFrame* (needsCaret: BOOLEAN): TextFrames.Frame;
  70.         VAR f: Display.Frame;
  71.     BEGIN
  72.         IF Oberon.Par.vwr.dsc = Oberon.Par.frame THEN f := Oberon.Par.frame.next;
  73.             IF (f # NIL) & (f IS TextFrames.Frame) THEN RETURN f(TextFrames.Frame) ELSE RETURN NIL END
  74.         ELSE RETURN FocusFrame(needsCaret)
  75.         END
  76.     END TargetFrame;
  77.     PROCEDURE GetMainArg* (VAR S: Texts.Scanner);
  78.         VAR text: Texts.Text; beg, end, time: LONGINT;
  79.     BEGIN Texts.Scan(S);
  80.         IF (S.class = Texts.Char) & (S.c = "^") THEN Oberon.GetSelection(text, beg, end, time);
  81.             IF time >= 0 THEN Texts.OpenScanner(S, text, beg); Texts.Scan(S) END
  82.         END;
  83.         IF S.line # 0 THEN S.class := Texts.Inval END
  84.     END GetMainArg;
  85.     PROCEDURE GetArg* (VAR S: Texts.Scanner);
  86.         VAR F: TextFrames.Frame;
  87.     BEGIN Texts.OpenScanner(S, Oberon.Par.text, Oberon.Par.pos); Texts.Scan(S);
  88.         IF (S.class = Texts.Char) & (S.c = "^") THEN F := Oberon.Par.frame(TextFrames.Frame);
  89.             IF F.hasSel THEN Texts.OpenScanner(S, F.text, F.selbeg.pos); Texts.Scan(S); F.time := 0 END
  90.         END
  91.     END GetArg;
  92.     PROCEDURE OpenTempViewer* (t: Texts.Text; VAR v: MenuViewers.Viewer);
  93.         VAR x, y, h: INTEGER;
  94.     BEGIN y := Display.Bottom; x := Display.Width-1; h := Viewers.minH; Viewers.minH := 1;
  95.         v := MenuViewers.New(TextFrames.NewMenu("", ""), TextFrames.NewText(t, 0), TextFrames.menuH, x, y);
  96.         Oberon.Pointer.X := x; Oberon.Pointer.Y := y;
  97.         Viewers.minH := h
  98.     END OpenTempViewer;
  99.     PROCEDURE UnmarkMenu* (V: Viewers.Viewer);
  100.         VAR R: Texts.Reader; T: Texts.Text; ch: CHAR;
  101.     BEGIN T := V.dsc(TextFrames.Frame).text;
  102.         Texts.OpenReader(R, T, T.len - 1); Texts.Read(R, ch);
  103.         IF ch = "!" THEN Texts.Delete(T, T.len - 1, T.len) END
  104.     END UnmarkMenu;
  105.     PROCEDURE GetSelectionViewer* (VAR vwr: Viewers.Viewer; VAR text: Texts.Text; 
  106.         VAR time, beg, end: LONGINT);
  107.         CONST filler = 1; (* state of the filler viewer *)
  108.         VAR selText, t2: Texts.Text; selBeg, selEnd, selTime, beg2, end2, time2: LONGINT;
  109.             left: INTEGER; cur: Viewers.Viewer;
  110.             m: Oberon.SelectionMsg;
  111.     BEGIN
  112.         Oberon.GetSelection(selText, selBeg, selEnd, selTime);
  113.         m.time := -1; m.text := NIL;
  114.         IF selTime >= 0 THEN
  115.             left := 0;
  116.             WHILE left < Display.Width DO    (* for all tracks *)
  117.                 cur := Viewers.This(left, 0);
  118.                 WHILE cur.state # filler DO    (* for all viewers in the track *)
  119.                     cur.handle(cur, m);
  120.                     IF (m.time = selTime) & (m.text = selText) & (m.beg = selBeg) & (m.end = selEnd) THEN
  121.                         text := selText; time := selTime; beg := selBeg; end := selEnd; vwr := cur;
  122.                         RETURN
  123.                     END;
  124.                     cur := Viewers.Next(cur)
  125.                 END;
  126.                 left := left + cur.W
  127.             END
  128.         END;
  129.         vwr := NIL; text := NIL; time := -1; beg := 0; end := 0
  130.     END GetSelectionViewer;
  131. END XIn.
  132.