Types
Text object
(* Length of the text file in bytes (not characters!). *)
(* TRUE if the text has been changed *)
(* TRUE if end of text has been reached *)
(* Color. Not used. *)
A rider on a text object to read it one character at a time
(* A read-ahead character value *)
(* Current line number *)
(* One of the scanner class constants (see above) *)
(* If class = Int, i = the value of the scanned integer *)
(* If class = Real, x = the value of the scanned real number *)
(* If class = Char, c = the value of the scanned character *)
(* If class = String, len holds the string length *)
(* If class = String, s holds the string *)
A rider on a text object to read and parse (scan) it in small pieces
Buffer of a piece of text
The idea is to write a piece of text first into a Buffer, and thereafter insert or append it to a Text. This is done for reasons of efficiency, because the possibly needed rendering of the text, for example on a display, can be done once upon insertion of the buffered piece of text rather than after generating each character.
(* The Writer's internal buffer *)
(* Color. Not used. *)
An obeject that is used to write a piece of text in a Buffer
Variables
Procedures
Appends the contents of buffer B into the end of text T
Changes the color of the piece of T at [bef; end) to col.
Does not work.
Store text T on a storage medium as a file with the given name
Copies the contents of the source buffer SB to the destination buffer DB
Copies a piece of text T from position beg (inclusive) to position end (exclusive) to buffer B and deletes this piece from text T. The previous content of B is deleted.
Puts in col the color of a character in T at position pos
Inserts the contents of buffer B into text T at position pos
Loads text T from file via rider r attached to the file
Initialize Text T.
If name is non-empty, open file with name name and load it in T.
If name is an empty string, create a new empty Text.
Initialize buffer B as an empty buffer
Initializes Reader R by setting it to position pos of text T
Initializes Scanner S by setting it to position pos of text T
Initializes Writer W by setting it to position pos of text T
Returns the current position of R in bytes (not characters!).
Reads a character fro the text attached the reader R and puts it in ch. Reader R is advanced (moved forward) by 1-4 bytes, because the encoding is UTF-8.
Saves piece of text T from beg (inclusive) to end (exclusive) to buffer B. The previous content of B is deleted.
Scans the text attached to S and reads whatever is in the text. Stores the scanned value in S. S.class is set to one of the possbile constants
(see above).
The options are: an integer (Int), a real value (Real), a string in quotes (String), a sequence of non-space characters (Name), a single
(otherwise unrecognized) character (Char) or an invalid value (Inval, also means end of text).
The integer result is stored in S.i, real — in S.x, character — in S.c, string — in S.s (the string) and S.len (the length of the string).
The line number in S.line is the line number of the next character that is always held in a S.nextCh.
Call OpenScanner, then Scan, then check the value of S.class.
Sets the color of the Writer.
Does not work.
Write text T into a file via rider r attached to the file
Writes character ch into the internal buffer of Writer W
Writes x as a hexadecimal integer into the internal buffer of Writer W.
Writes integer x into the internal buffer of Writer W.
n means the minimum number of characters to write
(the number gets prefixed with spaces).
Writes next line character (or CRLF pair on Windows) into the internal buffer of Writer W
Writes real number x into the internal buffer of Writer W.
n means the minimum number of characters to write
(the number gets prefixed with spaces).
Writes real number x into the internal buffer of Writer W.
n means the minimum number of characters to write
(the number gets prefixed with spaces)
k means the number of digits after a decimal point.
Writes string s into the internal buffer of Writer W
Module for reading and writing text files