Programmatical Access to a Text
A Text can be manipulated using procedures in the Texts module; visible for ETH Oberon and for V5. Also summarized for ETH Oberon in DEFINITION Texts.
To read a Text programmatically, a RECORD termed a Reader is opened on the Text at a specified offset. (A Reader is a RECORD; not a procedure.) With reader open, the Read(reader, ch) procedure retrieves a character each time it is executed. The font of a character is referenced in the Objects.Library of the Reader. The Reader also has fields, col, the color of the character and voff, vertical offset of the character. After an execution of Read(reader, ch), the freshly read character is available in ch and attributes are in the components of reader. This assumes that the object read was a character as evidenced by (reader.lib IS Fonts.Font) being TRUE. Each execution of Read() advances reader through the Text by one character until the end is reached and reader.eot becomes TRUE.
How Text Works
These tables show the structure of records in memory representing a Text. When Texts.Store() records a Text in a file for a storage medium, the information in the record structure is serialized. In the inverse process, Texts.Load() deserializes the information to the record structure of the Text in memory.
Click on a hyperlink to see the module where a type is defined.
In Oberon V2
Type | Fields of TextDesc | Types of Fields | Notes |
---|---|---|---|
Texts.Text, a pointer to a Texts.TextDesc | len | LONGINT | Length of text, in bytes. |
changed | BOOLEAN | Flag indicating a revision. | |
notify | Texts.Notifier | Pointer to a method to notify interested clients of state changes. | |
trailer | Texts.Piece | Pointer to the Sentinel node in the list of pieces. | |
pce | Texts.Piece | Last found piece. | |
org | LONGINT | Offset in [0,len) of first character in last found piece. |
Type | Fields of PieceDesc | Types of Fields | Notes |
---|---|---|---|
Texts.Piece, a pointer to a Texts.PieceDesc | f | Files.File | Pointer, to file. |
off | LONGINT | Integer offset in Text of first character in Piece. | |
len | LONGINT | Number of bytes in Piece. | |
fnt | Fonts.Font | Pointer to a font. | |
col | INTEGER | ||
voff | INTEGER | Vertical offset of characters in pixels. | |
prev | Texts.Piece | Pointer to previous piece of Text. | |
next | Texts.Piece | Pointer to next piece of Text. |
In ETH Oberon
TextDesc is an extension of Objects.ObjDesc. The fields added to make TextDesc are distinguished from the fields inherited from ObjDesc by a differing background color.
Type | Fields of TextDesc | Types of Fields | Notes |
---|---|---|---|
Texts.Text, a pointer to a Texts.TextDesc | stamp | LONGINT | Integer |
dlink | Objects.Object | Pointer | |
slink | Objects.Object | Pointer | |
lib | Objects.Library | Pointer | |
ref | INTEGER | ||
handle | Objects.Handler | Pointer | |
len | LONGINT | Length of text. | |
obs | Objects.Library | Pointer | |
trailer | Texts.Piece | Pointer to Sentinel node in list of pieces. | |
org | LONGINT | Offset in [0,len) of first character in last found piece. | |
pce | Texts.Piece | Last found piece. |
Type | Fields of LibDesc | Types of Fields | Notes |
---|---|---|---|
Objects.Library, a pointer to a LibDesc | next | Objects.Library | Pointer |
ind | Objects.Index | Pointer | |
f | Files.File | Pointer | |
R | Files.Rider | Pointer | |
name | Objects.Name | ||
dict | Objects.Dictionary | Pointer | |
maxref | INTEGER | ||
GName | POINTER |
Type | Fields of PieceDesc | Types of Fields | Notes |
---|---|---|---|
Texts.Piece, a pointer to a Texts.PieceDesc | f | Files.File | Pointer |
off | LONGINT | Integer | |
len | LONGINT | ||
obj | Objects.Object | Pointer | |
lib | Objects.Library | Pointer | |
ref | INTEGER | ||
col | SHORTINT | ||
voff | SHORTINT | ||
prev | Piece | Pointer | |
next | Piece | Pointer |
In the Oberon Subsystem of A2
TextDesc is an extension of Objects.ObjDesc. The fields added to make TextDesc are distinguished from the fields inherited from ObjDesc by differing background colors.
Type | Fields of TextDesc | Types of Fields | Notes |
---|---|---|---|
Texts.Text, a pointer to a Texts.TextDesc | stamp | LONGINT | Integer |
dlink | Objects.Object | Pointer | |
slink | Objects.Object | Pointer | |
lib | Objects.Library | Pointer | |
ref | INTEGER | ||
handle | Objects.Handler | Pointer | |
len | LONGINT | Length of text. | |
obs | Objects.Library | Pointer | |
trailer | Texts.Piece | Pointer to Sentinel node in list of pieces. | |
org | LONGINT | Offset in [0,len) of first character in last found piece. | |
pce | Texts.Piece | Last found piece. |
Type | Fields of LibDesc | Types of Fields | Notes |
---|---|---|---|
Objects.Library, a pointer to a LibDesc | next | Objects.Library | Pointer |
ind | Objects.Index | Pointer | |
f | Files.File | Pointer | |
R | Files.Rider | Pointer | |
name | Objects.Name | ||
dict | Objects.Dictionary | Pointer | |
maxref | INTEGER | ||
GName | POINTER |
Type | Fields of PieceDesc | Types of Fields | Notes |
---|---|---|---|
Texts.Piece, a pointer to a Texts.PieceDesc | f | Files.File | Pointer |
off | LONGINT | Integer | |
len | LONGINT | ||
obj | Objects.Object | Pointer | |
lib | Objects.Library | Pointer | |
ref | INTEGER | ||
col | SHORTINT | ||
voff | SHORTINT | ||
prev | Piece | Pointer | |
next | Piece | Pointer |
In Oberon V5
Type | Fields of TextDesc | Types of Fields | Notes |
---|---|---|---|
Texts.Text, a pointer to a Texts.TextDesc | len | INTEGER[1] | Length of text, in bytes. |
changed | BOOLEAN | Flag indicating a revision. | |
notify | Texts.Notifier | Pointer to a method to notify interested clients of state changes. | |
trailer | Texts.Piece | Pointer to the Sentinel node in the list of pieces. | |
pce | Texts.Piece | Last found piece. | |
org | INTEGER | Offset in [0,len) of first character in last found piece. |
Type | Fields of PieceDesc | Types of Fields | Notes |
---|---|---|---|
Texts.Piece, a pointer to a Texts.PieceDesc | f | Files.File | Pointer, to file. |
off | INTEGER | Integer offset in Text of first character in Piece. | |
len | INTEGER | Number of bytes in Piece. | |
fnt | Fonts.Font | Pointer to a font. | |
col | INTEGER | ||
voff | INTEGER | Vertical offset of characters in pixels. | |
prev | Texts.Piece | Pointer to previous piece of Text. | |
next | Texts.Piece | Pointer to next piece of Text. |
Texts.FindPiece and the cache
For a given Text, T, and offset pos in [0, T.len), procedure Texts.FindPiece has the task of locating the piece containing pos. At each execution, FindPiece could begin at offset 0 and add lengths of pieces until the piece containing pos is located. A cache based upon T.pce and T.org allows better efficiency. When FindPiece completes a search, the pointer to the found piece is recorded in T.pce; the offset of the first character of that piece is recorded in T.org. The next execution of FindPiece begins at that cached location. With a result from FindPiece often being near the preceeding result, this strategy avoids repeated summation of lengths from the beginning of the first piece.
References
- ↑ In V5 the only integer type is INTEGER. Cf. LONGINT in V2.