aware views that, if embedded in a text, affect the text setting. A ruler supports interactive and program controlled adjustment of paragraph and limited page formatting. However, the ruler does not perform the actual setting of the text according to the format defined by the ruler. Text setters are used to actually set a text (cf. Section 6.4).
Signals that the named field of a Prop property is known, valid, or readOnly.
CONST leftAdjust, rightAdjust
Possible elements of Attributes.opts. If none is included, request centered lines; if leftAdjust is included alone, request left flushed lines; if rightAdjust is included alone, request right flushed lines; if both are included, request fully adjusted lines.
CONST noBreakInside, pageBreak, parJoin
Possible elements of Attributes.opts, where the inclusion of pageBreak overrides a possible inclusion of parJoin. If noBreakInside is included, request setting of the following paragraphs (up to the next ruler or the end of text) such that no page break is crossed by any of the paragraphs; a page break may be inserted between the paragraphs, but see parJoin below. (This may not be possible, or lead to unacceptably large white space, in which case a setter's heuristics may insert page breaks anyways.) If pageBreak is included, request setting to continue on the next fresh page. (If already at the top of a new page, the request is ignored.) If parJoin is included, the paragraph following the ruler is requested to be set on the same page as the paragraph preceding the ruler. (This may cause insertion of a page break in or before the preceding paragraph.)
TYPE Attributes
Extension
The style of a ruler holds an attributes object.
Once created and initialized, attributes objects can no longer be modified, and hence can be freely shared among many ruler styles. Changing the attributes of a style is done by changing the whole attributes object attached to the style. (Styles in turn may be shared by multiple rulers, causing all these rulers to change in synch when changing the attributes of the style.)
first-, left-, right-: LONGINT [units]
First line indentation of every following paragraph, left margin (other than for first line of a paragraph), and right margin. All measured from the left margin of the view displaying the set text.
lead-: LONGINT [units]
Vertical lead space inserted before every following paragraph, unless the paragraph happens to start a new page.
asc-, dsc-: LONGINT [units]
Lower bounds on the ascender and descender of the lines of the following paragraphs.
grid-: LONGINT [units] 1 <= grid < Views.infinite
Grid spacing (if 1: no grid). Each line of the following paragraphs is set such that its base line falls on a grid line. (Depending on the setter used, this may cause overlaps of high lines, or it may cause higher lines to be moved to the next possible grid line in order to avoid overlaps.)
opts-: SET
Formatting options, drawn from the set {leftAdjust, rightAdjust, noBreakInside, pageBreak, parJoin}. The options noBreakInside and parJoin are requests that, depending on the setter's heuristics, may or may not be followed.
tabs-: INTEGER 0 <= tabs <= 32
tab-: ARRAY 32 OF LONGINT [units] tab[0 .. tabs) valid
Tabulator stops measured from the left margin of the view displaying the set text.
Initialize new attributes object to attributes of a source object, but modified according to the property list. (Values valid in the property list are taken from it, others from the source attributes object.)
Each property field corresponds to the attribute field of same name. (Property field tabs corresponds to (tab, tabs) in Attributes.)
TYPE UpdateMsg
Message notifying of a change of attributes attached to a certain style. The message is domaincast and typically interpreted by all text views which display a text that contains a ruler that shares the changed style.
style: Style
The style that has changed.
oldAttr: Attributes
The attributes that were attached to style previously.
TYPE Directory
Directory for rulers and styles.
attr-: Attributes attr # NIL & attr.init
Default attributes used when initializing new style.
Return new ruler object with style attributes initialized from give property list, using d.attr for default values.
Except for performance, equivalent to:
VAR a: Attributes;
a := d.attr.Clone(); a.ModifyFrom(d.attr, p);
RETURN d.New(d.NewStyle(a))
PROCEDURE (d: Directory) StdNew (): Ruler
Default
Return new ruler with default style and attributes.
Except for performance, equivalent to:
RETURN d.New(d.NewStyle(d.attr))
VAR dir-, stdDir-: Directory dir # NIL, stdDir # NIL, stable stdDir = d
Directory and standard directory objects for rulers and styles.
PROCEDURE ReadAttr (VAR rd: Stores.Reader; VAR a: Attributes)
Read an attributes object; in case the reader returns an alien store, the store is wrapped into an alien attributes object and the wrapper is returned.
Read an attributes object; in case the reader returns an alien store, the store is wrapped into an alien attributes object and the wrapper is returned.
a # NIL 20
a.init 21
Except for performance, equivalent to:
WITH a: AlienAttributes DO wr.WriteStore(a.store) ELSE wr.WriteStore(a) END
Locate the ruler in text that dominates position pos. If a ruler position is known, it can be passed as a hint: (ruler, rpos) is first ruler before hint. Otherwise, pass hint = -1. On return, either the dominating ruler is returned as (ruler, rpos), or ruler and rpos remain unchanged.
hint < 0 OR rpos = Pos(ruler) & no ruler in (rpos, hint] & 0 <= pos <= t.Length()
hint < rpos <= pos & rpos = Pos(ruler) & no ruler in (rpos, pos] OR (ruler, rpos) unmodified
Except for performance, equivalent to:
VAR view: Views.View; rd: TextModels.Reader;
IF pos < text.Length() THEN INC(pos) END; (* let a ruler dominate its own position! *)
IF pos < hint THEN hint := -1 END;
rd := text.NewReader(rd); rd.SetPos(pos);
REPEAT
rd.ReadPrevView(view)
UNTIL rd.eot OR (view IS Ruler) OR (rd.Pos() < hint);