XOberon10.Scn.Fnt InfoElemsAllocVOberon10.Scn.FntzStampElemsAlloc12 Aug 96c"Title": TeX - Printing facility "Author": RLI "Abstract": The TeX - Module formats a text file using the TeX system. "Keywords": Printing "Version": 0.80 "From": 12 Aug 96 "Until":  "Changes": "Hints": Use TeX.Print (* | ^ | filename) [printCmd] where printCmd can be a name or string containing command to print a .dvi file. If printCmd is not specified, a file tmp.dvi is created. To use this module tex must be installed correctly and the font cmss8 must be available. If it's not you can change initString in the CONST section. Oberon10i.Scn.FntCma d8FoldElemsNewOberon10.Scn.FntE$  VAR v: Viewers.Viewer; BEGIN v := Oberon.MarkedViewer(); IF (v # NIL) & (v.dsc # NIL) & (v.dsc.next IS TextFrames.Frame) THEN RETURN v.dsc.next(TextFrames.Frame) ELSE RETURN NIL END END MarkedViewer; 858;Oberon10.Scn.Fnt*Oberon10i.Scn.Fnt$11(-6; VAR beg, end, time: LONGINT; f: TextFrames.Frame; par: Oberon.ParList; s: Texts.Scanner; t: Texts.Text; BEGIN par := Oberon.Par; Texts.OpenScanner(s, par.text, par.pos); (* File to print *) Texts.Scan(s); IF s.class = Texts.Name THEN (* Called by filename *) NEW(t); Texts.Open(t, s.s) ELSIF (s.class = Texts.Char) & (s.c = "*") THEN (* Called by selected viewer *) f := MarkedViewer() ELSIF (s.class = Texts.Char) & (s.c = "^") THEN (* Called by selection *) Oberon.GetSelection(t, beg, end, time); IF time >= 0 THEN (* Selection found *) Texts.OpenScanner(s, t, beg); Texts.Scan(s); IF s.class = Texts.Name THEN NEW(t); Texts.Open(t, s.s) END END END; IF f # NIL THEN bText := f.text ELSE bText := t END; (* Print command *) Texts.Scan(s); IF (s.class = Texts.Name) OR (s.class = Texts.String) THEN COPY(s.s, printCmd) ELSE COPY("", printCmd) END; END ParseCmdLine; 8u8_Oberon10.Scn.Fnt9Oberon10i.Scn.Fnt1>!R VAR ch: CHAR; BEGIN noProc := FALSE; Texts.Scan(s); (* --- Type-bound procedures can have Receiver *) WHILE ~s.eot & (s.class = Texts.Char) & (s.c = Texts.ElemChar) DO Texts.Scan(s) END; IF (s.class = Texts.Char) & (s.c = "(") THEN REPEAT Texts.Scan(s) UNTIL (s.class = Texts.Char) & (s.c = ")") OR s.eot; Texts.Scan(s) END; WHILE ~s.eot & (s.class = Texts.Char) & (s.c = Texts.ElemChar) DO Texts.Scan(s) END; (* --- Check name of procedure *) IF s.class # Texts.Name THEN noProc := TRUE; RETURN END; COPY(s.s, procName); (* --- Formal parameters *) Texts.OpenScanner(s, bText, Texts.Pos(s) - 1); Texts.Read(s, ch); WHILE ~s.eot & (ch # ";") DO IF ch = "(" THEN WHILE ~s.eot & (ch # ")") DO Texts.Read(s, ch) END ELSE Texts.Read(s, ch) END END END passProcHead; 8&8Oberon10.Scn.FntOberon10i.Scn.Fnt$ + >4 VAR fontname: ARRAY 32 OF CHAR; i: INTEGER; BEGIN (* --- Get the fontname *) COPY(r.fnt.name, fontname); (* --- Get fonts *) i := Strings.Pos(".", fontname, 0); IF fontname[i - 1] = 'i' THEN INCL(fntAttrib, italic) END; IF fontname[i - 1] = 'b' THEN INCL(fntAttrib, bold) END END GetFontsFromText; 878COberon10.Scn.FntOberon10i.Scn.Fnt+ BEGIN CASE ch OF "A".. "Z": Files.Write(w, ch); | "(" .. ";": Files.Write(w, ch); | "=": Files.Write(w, ch); | "a" .. "z": Files.Write(w, ch); | " ": Files.Write(w, ch); | '"': Files.Write(w, ch); | "'": Files.Write(w, ch); | "?": Files.Write(w, ch); | "!": Files.Write(w, ch); | "": Files.WriteString(w, '\"a'); | "": Files.WriteString(w, '\"o'); | "": Files.WriteString(w, '\"u'); | "": Files.WriteString(w, '\"A'); | "": Files.WriteString(w, '\"O'); | "": Files.WriteString(w, '\"U'); | "<": Files.WriteString(w, "$<$"); | ">": Files.WriteString(w, "$>$"); | "|": Files.WriteString(w, "$|$"); | "#": Files.WriteString(w, "\#"); | "$": Files.WriteString(w, "\$"); | "%": Files.WriteString(w, "\%"); | "&": Files.WriteString(w, "\&"); | "\": Files.WriteString(w, "$\backslash$") | "[": Files.Write(w, ch); | "]": Files.Write(w, ch); | "^": Files.WriteString(w, "$\uparrow$"); | "{": Files.WriteString(w, "$\{$"); | "}": Files.WriteString(w, "$\}$"); | "~": Files.WriteString(w, "\~{}"); | 0DX: Files.WriteString(w, " ~ \par"); Files.Write(w, 0AX); INC(linC); | 09X: Files.WriteString(w, "~ ~") | Texts.ElemChar: (* Ignore Elements *) ELSE Out.Char(ch) END END AppendChar; 8 Oberon10b.Scn.Fnt8Oberon10.Scn.FntOberon10i.Scn.Fnt8&) I' VAR t: Texts.Text; r: Texts.Reader; ch: CHAR; actFnt: Fonts.Font; printCmd: ARRAY 512 OF CHAR; s: Texts.Scanner; noProc: BOOLEAN; procName: ARRAY 32 OF CHAR; at, oldAt: SET; f: Files.File; rd: Files.Rider; BEGIN ParseCmdLine(t, printCmd); ASSERT(t # NIL); f := Files.New("tmp.tex"); Files.Set(rd, f, 0); Files.WriteString(rd, initString); Texts.OpenReader(r, t, 0); Texts.Read(r, ch); actFnt := r.fnt; WHILE ~r.eot DO IF ch = 'P' THEN Texts.OpenScanner(s, t, Texts.Pos(r) - 1); Texts.Scan(s) (* IF (s.class = Texts.Name) & (s.s = "PROCEDURE") THEN passProcHead(s, t, noProc, procName); IF ~noProc & (linC > 50) THEN Files.WriteString(rd, "\vfill \eject "); linC := 0; END; END; *) END; oldAt := at; at := {}; GetFontsFromText(r, at); IF (at # oldAt) & (at = {bold}) THEN Files.WriteString(rd, "{\bf ") END; IF (at # oldAt) & (at = {italic}) THEN Files.WriteString(rd, "{\it ") END; AppendChar(rd, ch); IF (at # oldAt) & (at = {}) THEN Files.WriteString(rd, "}") END; Texts.Read(r, ch) END; Files.WriteString(rd, "} \bye"); Files.Register(f); (* Calling TeX *) Out.String("Calling "); Out.String(texCmd); Out.Ln; system(texCmd); (* Executing print command, if given *) IF printCmd # "" THEN Strings.Append(" tmp.dvi &" , printCmd); Out.String("Calling "); Out.String(printCmd); Out.Ln; system(printCmd) ELSE Out.String("tmp.dvi created.$") END; END Print; 88#Oberon10.Scn.FntBB Kernel.dlsym(Kernel.libc, "system", SYSTEM.VAL(LONGINT, system))8"DMODULE TeX;  (* ToDo: PROCEDURES gruppieren und dazwischen einen VFILL machen *) IMPORT Files, Fonts, Kernel, MenuViewers, Oberon, Out, Strings, TextFrames, Texts, Viewers, SYSTEM; CONST initString = "\baselineskip=10 pt \font\sf = cmss8 \font\it = cmssi8 \font\bf = cmssbx8 \sf{"; texCmd = "tex tmp.tex"; italic = 1; bold = 2; VAR linC: INTEGER; system: PROCEDURE (cmd: ARRAY OF CHAR); PROCEDURE MarkedViewer (): TextFrames.Frame;  PROCEDURE ParseCmdLine (VAR bText: Texts.Text; VAR printCmd: ARRAY OF CHAR);  PROCEDURE passProcHead (VAR s: Texts.Scanner; bText: Texts.Text; VAR noProc: BOOLEAN; VAR procName: ARRAY OF CHAR);  PROCEDURE GetFontsFromText (r: Texts.Reader; VAR fntAttrib: SET);  PROCEDURE AppendChar (VAR w: Files.Rider; ch: CHAR);  PROCEDURE Print*;  BEGIN END TeX. Paginating strategy: