home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 August / macformat-027.iso / mac / Shareware City / Developers / Oberon⁄F / Text / Docu / Models (.txt) < prev    next >
Encoding:
Oberon Document  |  1994-06-07  |  28.6 KB  |  613 lines  |  [oODC/obnF]

  1. Documents.StdDocumentDesc
  2. Documents.DocumentDesc
  3. Containers.ViewDesc
  4. Views.ViewDesc
  5. Stores.StoreDesc
  6. Documents.ModelDesc
  7. Containers.ModelDesc
  8. Models.ModelDesc
  9. Stores.ElemDesc
  10. TextViews.StdViewDesc
  11. TextViews.ViewDesc
  12. TextModels.StdModelDesc
  13. TextModels.ModelDesc
  14. TextModels.AttributesDesc
  15. Geneva
  16. TextRulers.StdRulerDesc
  17. TextRulers.RulerDesc
  18. TextRulers.StdStyleDesc
  19. TextRulers.StyleDesc
  20. TextRulers.AttributesDesc
  21. Geneva
  22. Geneva
  23. Geneva
  24. Geneva
  25. Geneva
  26. 6 The Text Subsystem
  27. 6.1 TextModels
  28. DEFINITION TextModels;
  29.     IMPORT Fonts, Ports, Stores, Models, Views, Dialog, Properties, Containers;
  30.     CONST
  31.         unicode = 1X; viewcode = 2X;
  32.         tab = 9X; line = 0DX; para = 0EX;
  33.         zwspace = 8BX; nbspace = 0A0X; digitspace = 8FX;
  34.         hyphen = 90X; nbhyphen = 91X; softhyphen = 0ADX;
  35.         maskChar = 0; hideable = 1;
  36.         offset = 0; code = 1;
  37.         store = 0;
  38.         replace = 0; insert = 1; delete = 2;
  39.         char = 0; lchar = 1; view = 2;
  40.     TYPE
  41.         LONGCHAR = INTEGER;
  42.         Model = POINTER TO ModelDesc;
  43.         ModelDesc = RECORD (Containers.ModelDesc)
  44.             PROCEDURE (m: Model) Clone (): Model;
  45.             PROCEDURE (m: Model) Length (): LONGINT;
  46.             PROCEDURE (m: Model) NewReader (old: Reader): Reader;
  47.             PROCEDURE (m: Model) NewWriter (old: Writer): Writer;
  48.             PROCEDURE (m: Model) CopyFrom (pos: LONGINT; m0: Model; beg, end: LONGINT);
  49.             PROCEDURE (m: Model) CopyAllFrom (source: Containers.Model);
  50.             PROCEDURE (m: Model) MoveFrom (pos: LONGINT; m0: Model; beg, end: LONGINT);
  51.             PROCEDURE (m: Model) Append (m0: Model);
  52.             PROCEDURE (m: Model) Delete (beg, end: LONGINT);
  53.             PROCEDURE (m: Model) SetAttr (beg, end: LONGINT; attr: Attributes);
  54.             PROCEDURE (m: Model) Prop (beg, end: LONGINT): Properties.Property;
  55.             PROCEDURE (m: Model) Modify (beg, end: LONGINT; old, p: Properties.Property);
  56.             PROCEDURE (m: Model) ReplaceView (old, new: Views.View)
  57.         END;
  58.         Attributes = POINTER TO AttributesDesc;
  59.         AttributesDesc = RECORD (Stores.StoreDesc)
  60.             color-: Ports.Color;
  61.             font-: Fonts.Font;
  62.             offset-: LONGINT;
  63.             PROCEDURE (a: Attributes) Clone (): Attributes;
  64.             PROCEDURE (a: Attributes) CopyFrom (source: Attributes);
  65.             PROCEDURE (a: Attributes) Equals (b: Attributes): BOOLEAN;
  66.             PROCEDURE (a: Attributes) Prop (): Properties.Property;
  67.             PROCEDURE (a: Attributes) ModifyFrom (source: Attributes; p: Properties.Property);
  68.             PROCEDURE (a: Attributes) InitFromProp (p: Properties.Property)
  69.         END;
  70.         AlienAttributes = POINTER TO AlienAttributesDesc;
  71.         AlienAttributesDesc = RECORD (AttributesDesc)
  72.             store-: Stores.Alien
  73.         END;
  74.         Prop = POINTER TO PropDesc;
  75.         PropDesc = RECORD (Properties.PropertyDesc)
  76.             offset: Dialog.Units;
  77.             code: LONGCHAR
  78.         END;
  79.         Context = POINTER TO ContextDesc;
  80.         ContextDesc = RECORD (Models.ContextDesc)
  81.             PROCEDURE (c: Context) ThisModel (): Model
  82.             PROCEDURE (c: Context) Attr (): Attributes;
  83.             PROCEDURE (c: Context) Pos (): LONGINT
  84.         END;
  85.         Pref = RECORD (Properties.Preference)
  86.             opts: SET;
  87.             mask: LONGCHAR
  88.         END;
  89.         Reader = POINTER TO ReaderDesc;
  90.         ReaderDesc = RECORD
  91.             eot: BOOLEAN;
  92.             type: SET;
  93.             attr: Attributes;
  94.             char: CHAR;
  95.             lchar: LONGCHAR;
  96.             view: Views.View;
  97.             w, h: LONGINT;
  98.             PROCEDURE (rd: Reader) Base (): Model;
  99.             PROCEDURE (rd: Reader) Pos (): LONGINT;
  100.             PROCEDURE (rd: Reader) SetPos (pos: LONGINT);
  101.             PROCEDURE (rd: Reader) Read;
  102.             PROCEDURE (rd: Reader) ReadPrev;
  103.             PROCEDURE (rd: Reader) ReadChar (VAR ch: CHAR);
  104.             PROCEDURE (rd: Reader) ReadPrevChar (VAR ch: CHAR);
  105.             PROCEDURE (rd: Reader) ReadLChar (VAR ch: INTEGER);
  106.             PROCEDURE (rd: Reader) ReadPrevLChar (VAR ch: INTEGER);
  107.             PROCEDURE (rd: Reader) ReadView (VAR v: Views.View);
  108.             PROCEDURE (rd: Reader) ReadPrevView (VAR v: Views.View);
  109.             PROCEDURE (rd: Reader) ReadRun (VAR attr: Attributes);
  110.             PROCEDURE (rd: Reader) ReadPrevRun (VAR attr: Attributes)
  111.         END;
  112.         Writer = POINTER TO WriterDesc;
  113.         WriterDesc = RECORD
  114.             attr-: Attributes;
  115.             PROCEDURE (wr: Writer) Base (): Model;
  116.             PROCEDURE (wr: Writer) Pos (): LONGINT;
  117.             PROCEDURE (wr: Writer) SetPos (pos: LONGINT);
  118.             PROCEDURE (wr: Writer) SetAttr (attr: Attributes);
  119.             PROCEDURE (wr: Writer) WriteChar (ch: CHAR);
  120.             PROCEDURE (wr: Writer) WriteLChar (ch: INTEGER);
  121.             PROCEDURE (wr: Writer) WriteView (view: Views.View; w, h: LONGINT)
  122.         END;
  123.         InfoMsg = RECORD (Models.Message)
  124.             op: INTEGER
  125.         END;
  126.         UpdateMsg = RECORD (Models.UpdateMsg)
  127.             op: INTEGER;
  128.             beg, end, delta: LONGINT
  129.         END;
  130.         Directory = POINTER TO DirectoryDesc;
  131.         DirectoryDesc = RECORD
  132.             fonts: Fonts.Directory;
  133.             attr: Attributes;
  134.             PROCEDURE (d: Directory) New (): Model;
  135.             PROCEDURE (d: Directory) SetAttr (attr: Attributes)
  136.         END;
  137.     VAR dir-, stdDir-: Directory;
  138.     PROCEDURE  NewColor (a: Attributes; color: Ports.Color): Attributes;
  139.     PROCEDURE  NewTypeface (a: Attributes; typeface: Fonts.Typeface): Attributes;
  140.     PROCEDURE  NewSize (a: Attributes; size: LONGINT): Attributes;
  141.     PROCEDURE  NewStyle (a: Attributes; style: SET): Attributes;
  142.     PROCEDURE  NewWeight (a: Attributes; weight: INTEGER): Attributes;
  143.     PROCEDURE  NewOffset (a: Attributes; offset: LONGINT): Attributes;
  144.     PROCEDURE  NewFont (a: Attributes; font: Fonts.Font): Attributes;
  145.     PROCEDURE  ReadAttr (VAR rd: Stores.Reader; VAR a: Attributes);
  146.     PROCEDURE  WriteAttr (VAR wr: Stores.Writer; a: Attributes);
  147.     PROCEDURE  SetDir (d: Directory);
  148. END TextModels.
  149. TextModels are container models which contain sequences of attributed characters and embedded views. Characters may be drawn from the Oberon/F character set, conforming to the Unicode specification. However, the current implementation supports the ASCII character set and its Latin-1 extension, only.
  150. CONST unicode
  151. Signals that the read character is actually drawn from the Non-Latin-1 Unicode pages. unicode is used as a general projection value when reading a true Unicode character as a CHAR.
  152. CONST viewcode
  153. Signals that the read character is actually an embedded view. viewcode is used as a general projection value when reading an embedded view as a CHAR.
  154. CONST tab
  155. The tabulation character. When encountered by a text formatter, formatting continues at the next tab stop as defined by some tabulation raster used by the formatter (usually some kind of ruler).
  156. CONST line
  157. The line separation character. When encountered by a text setter, setting continues on the next line. However, line does not introduce a new paragraph (cf. para below).
  158. CONST para
  159. The paragraph separation character. When encountered by a text setter, setting continues on the next line and a new paragraph is opened (cf. line above).
  160. CONST zwspace
  161. The zero
  162. width space character. Separates words, but takes no space in its own right.
  163. CONST nbspace
  164. The non
  165. breaking space character. Has the same width as a normal space character. When encountered by a text setter, nbspace does not separate words.
  166. CONST digitspace
  167. A digit space has the width of digit zero (0) which is equivalent to the width of all digits in most fonts, thus can be used for number formatting. When encountered by a text setter, digitspace does not separate words.
  168. CONST hyphen
  169. The hyphen character. To be used for explicit and visible hyphenation. A text setter may choose to break lines just after a hyphen.
  170. CONST nbhyphen
  171. The non
  172. breaking hyphen. Just as hyphen, but a text setter will not break lines just after an nbhyphen.
  173. CONST softhyphen
  174. The soft
  175. hyphen. Just as hyphen, but rendered as a zero
  176. width character unless actually used to break a line. softhyphen can be used to give hints to a text setter on where to break longer words.
  177. CONST maskChar
  178. Option element
  179. Can be used as a set element of Pref.opts. Signals that the embedded view prefers to be masked to a normal character, making it behave like that character in most situations. The primary purpose of masking is to simplify the task for text scanning applications. (For example, a text ruler might be masked to behave like a para character. This would allow a text scanner to count the number of paragraphs in a text simply by counting the number of returned para characters while scanning the text.)
  180. CONST hideable
  181. Option element
  182. Can be used as a set element of Pref.opts. Signals that the embedded view accepts to be hidden or revealed depending on a mode of the text view. (For example, text rulers might be hideable enabling the the user to hide or reveal the rulers in a displayed text.)
  183. CONST offset, code
  184. Property field selectors
  185. Signals that the indicated field of a Prop property is known, valid, or readOnly.
  186. CONST store
  187. Possible value of InfoMsg.op, signalling the completed storing of the broadcasting text. This is the only value currently defined for this field.
  188. CONST replace
  189. Possible value of UpdateMsg.op, signalling the successful replacement of a stretch in the broadcasting text.
  190. CONST insert
  191. Possible value of UpdateMsg.op, signalling the successful insertion of a stretch in the broadcasting text.
  192. CONST delete
  193. Possible value of UpdateMsg.op, signalling the successful deletion of a stretch in the broadcasting text.
  194. CONST char
  195. Possible element of Reader.type. If present, it signals that the read value can be interpreted as a CHAR. (Note that this is the usual case, while long characters and embedded views have defined projection values unicode and view, respectively.)
  196. CONST lchar
  197. Possible element of Reader.type. If present, it signals that the read value can be interpreted as a LONGCHAR.
  198. CONST view
  199. Possible element of Reader.type. If present, it signals that the read value is an embedded view.
  200. TYPE LONGCHAR
  201. The set of all Unicode characters.
  202. TYPE Model
  203. Interface, Extension
  204. Text models are container models, containing sequences of attributed characters and embedded views.
  205. PROCEDURE (m: Model) Clone (): Model
  206. Extension
  207. Result type is narrowed.
  208. PROCEDURE (m: Model) Length (): LONGINT
  209. Length of the text m, where each character (CHAR or LONGCHAR) and each embedded view counts as one.
  210. result >= 0
  211. PROCEDURE (m: Model) NewReader (old: Reader): Reader
  212. Interface
  213. Returns a reader connected to m. An old reader may be passed as input parameter, if it isn't in use anymore. Note that NewReader does not reposition old if old is reused and its position is in the valid range. (NewReader may or may not use the old reader, depending on internal compatibility criteria.)
  214. result # NIL
  215. result = old  &  old'.Base() = m  &  old'.Pos() <= m.Length()
  216.     result.Pos() = old'.Pos()
  217. ~(result = old  &  old'.Base() = m  &  old'.Pos() <= m.Length())
  218.     result.Pos() = 0
  219. PROCEDURE (m: Model) NewWriter (old: Writer): Writer
  220. Interface
  221. Returns a writer connected to m. An old writer may be passed as input parameter, if it isn't in use anymore. Note that NewWriter does not reposition old if old is reused and its position is in the valid range. (NewWriter may or may not use the old reader, depending on internal compatibility criteria.)
  222. result # NIL
  223. result.attr = dir.attr
  224. result = old  &  old'.Base() = m  &  old'.Pos() <= m.Length()
  225.     result.Pos() = old'.Pos()
  226. ~(result = old  &  old'.Base() = m  &  old'.Pos() <= m.Length())
  227.     result.Pos() = m.Length()
  228. PROCEDURE (m: Model) CopyFrom (pos: LONGINT; m0: Model; beg, end: LONGINT)
  229. Interface, Operation
  230. Copy the stretch [beg, end) from text m0 and insert it into text m at position pos. In case that m0 is of a foreign implementation, rider conversion is used to project the stretch from m0 into m's implementation.
  231. m0.init    20
  232. 0 <= pos    21
  233. pos <= Length(m)    22
  234. 0 <= beg    23
  235. beg <= end    24
  236. end <= Length(m0)    25
  237. m.init
  238. Length(m) = Length(m') + (end - beg)
  239. m0 = m
  240.     Length(m0) = Length(m)
  241. m0 # m
  242.     Length(m0) = Length(m0')
  243. PROCEDURE (m: Model) CopyAllFrom (source: Containers.Model)
  244. Interface, Extension
  245. Copies the contents of source and uses it to initialize m.
  246. ~m.init    20
  247. source # NIL    21
  248. source.init    22
  249. TypeOf(source) = TypeOf(m)    23
  250. m.init
  251. PROCEDURE (m: Model) MoveFrom (pos: LONGINT; m0: Model; beg, end: LONGINT)
  252. Interface, Operation
  253. Extract the stretch [beg, end) from m0 and insert it into m at position pos. In case that m0 is of a foreign implementation, rider conversion is used to project the stretch from m0 into m's implementation.
  254. m0.init    20
  255. 0 <= pos    21
  256. pos <= Length(m)    22
  257. 0 <= beg    23
  258. beg <= end    24
  259. end <= Length(m0)    25
  260. m.init
  261. m = m0
  262.     Length(m) = Length(m0) = Length(m') = Length(m0')
  263. m # m0
  264.     Length(m) = Length(m') + (end - beg)
  265.     Length(m0) = Length(m0') - (end - beg)
  266. PROCEDURE (m: Model) Append (m0: Model)
  267. Default, Operation
  268. Append m0 to m.
  269. Except for performance, equivalent to:
  270.     m.MoveFrom(m.Length(), m0, 0, m0.Length())
  271. PROCEDURE (m: Model) Delete (beg, end: LONGINT);
  272. Interface, Operation
  273. Delete the stretch [beg, end) from m.
  274. 0 <= beg    20
  275. beg <= end    21
  276. end <= Length(m)    22
  277. Length(m) = Length(m') - (end - beg)
  278. PROCEDURE (m: Model) SetAttr (beg, end: LONGINT; attr: Attributes)
  279. Interface, Operation
  280. Set the attributes of all items in the stretch [beg, end) of m to attr.
  281. 0 <= beg    20
  282. beg <= end    21
  283. end <= Length(m)    22
  284. PROCEDURE (m: Model) Prop (beg, end: LONGINT): Properties.Property
  285. Interface
  286. Return a property structure describing the properties of the items in the stretch [beg, end) of m. Only properties returned by encountered attributes and those captured by Prop are considered. There is no recursion into embedded views.
  287. The result is the intersection of the attribute
  288. describing properties of the homogeneous substretches of [beg, end). For example, if the first half of the stretch is "bold & italic", while the second half is "italic", then Prop returns a property "italic", i.e. the homogeneous subset.
  289. 0 <= beg    20
  290. beg <= end    21
  291. end <= Length(m)    22
  292. PROCEDURE (m: Model) Modify (beg, end: LONGINT; old, p: Properties.Property)
  293. Interface, Operation
  294. Modify the stretch [beg, end) of m according to the property structure p. If old is given, modification takes place only if the stretch is homogeneous in the properties specified in old, and if the stretch carries exactly the same property values as those specified in old.
  295. 0 <= beg    20
  296. beg <= end    21
  297. end <= Length(m)    22
  298. old = NIL  OR  old = Intersect(m'.Prop(beg, end), old)
  299.     m.Prop(beg, end) = p
  300. PROCEDURE (m: Model) ReplaceView (old, new: Views.View)
  301. Interface, Operation
  302. Retain the context of old, but replace old by new.
  303. old # NIL    20
  304. new # NIL    21
  305. old.context # NIL    22
  306. new.context = NIL OR new.context = old.context    23
  307. new.init    24
  308. new.context = old.context
  309. TYPE Attributes
  310. Extension
  311. Every character or embedded view that forms part of a text carries a set of attributes. Such attributes are described by objects of type Attributes. The base type carries the standard attributes of every element of a text: A color, a font, and a vertical offset (in universal units).
  312. Once created and initialized, attributes objects can no longer be modified, and hence can be freely shared among many attributed objects. Changing the attributes of an attributed object is done by changing the whole attributes object attached to the attributed object.
  313. color-: Ports.Color
  314. Persistent
  315. The color to be used to render the attributed object. For characters, this is the foreground color; for embedded views, this attribute is either ignored, or used in a view
  316. specific way by text
  317. aware views.
  318. font-: Fonts.Font
  319. Persistent
  320. The font to be used to render the attributed object. For characters, this is the font carrying the glyph to be used; for embedded views, this attribute is either ignored, or used in a view
  321. specific way by text
  322. aware views.
  323. offset-: LONGINT
  324. Persistent
  325. The vertical offset from the base line (value in universal units) to be used for the attributed object.
  326. PROCEDURE (a: Attributes) Clone (): Attributes
  327. Default, Extension
  328. Result type is narrowed.
  329. PROCEDURE (a: Attributes) CopyFrom (source: Attributes)
  330. Copy attributes from an initialized to a new attributes object.
  331. ~a.init    20
  332. source.init    21
  333. a.init
  334. a.color = source.color
  335. a.font = source.font
  336. a.offset = source.offset
  337. PROCEDURE (a: Attributes) Equals (b: Attributes): BOOLEAN
  338. Compare two attributes objects for attribute equality.
  339. a.init    20
  340. b.init    21
  341. result = (TypeOf(a) = TypeOf(b)) & (a.color = b.color) & (a.font = b.font) & (a.offset = b.offset)
  342. PROCEDURE (a: Attributes) Prop (): Properties.Property
  343. Return property list reflecting attribute values.
  344. a.init    20
  345. result # NIL
  346. PROCEDURE (a: Attributes) ModifyFrom (source: Attributes; p: Properties.Property)
  347. 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.)
  348. a.init    20
  349. source.init    21
  350. PROCEDURE (a: Attributes) InitFromProp (p: Properties.Property)
  351. Initialize according to property list.
  352. ~a.init    20
  353. a.init
  354. TYPE AlienAttributes
  355. Extension, Leaf
  356. Type of alien attributes objects, as returned by ReadAttr.
  357. store-: Stores.Alien
  358. The alien store enclosed by an alien attributes objects.
  359. TYPE Prop
  360. Text specific properties: Vertical offsets and character codes.
  361. offset: Dialog.Unit
  362. Vertical offset property.
  363. code: LONGCHAR
  364. Character code, drawn from the Unicode character set.
  365. TYPE Context
  366. Interface, Extension
  367. Context for views embedded in texts.
  368. PROCEDURE (c: Context) ThisModel (): Model
  369. Interface, Extension
  370. Result type is narrowed.
  371. PROCEDURE (c: Context) Attr (): Attributes
  372. Interface
  373. Attributes valid for the embedded view.
  374. PROCEDURE (c: Context) Pos (): LONGINT
  375. Interface
  376. Position of the embedded view in the text.
  377. TYPE Pref
  378. Extension
  379. Preferences a view may have when embedded in a text.
  380. opts: SET
  381. Option set, preset to {}. Possible values are from {maskChar, hideable}.
  382. mask: LONGCHAR
  383. If maskChar IN opts, mask is the desired masking character code.
  384. TYPE Reader
  385. Interface
  386. A rider to read characters and embedded views from a text.
  387. eot: BOOLEAN
  388. Last read was tried at the end of the text.
  389. type: SET
  390. Characteristics of last element read. Values are from {char, lchar, view} and determine the validity of the reader fields char, lchar, view, w, and h.
  391. attr: Attributes    ~eot => attr # NIL
  392. The attributes of the most recently read element.
  393. char: CHAR    valid if char IN type
  394. Character read most recently.
  395. lchar: LONGCHAR    valid if lchar IN type
  396. Long character most recently.
  397. view: Views.View    valid if view IN type
  398. Embedded view most recently.
  399. w, h: LONGINT    valid if view IN type
  400. Width and height of view most recently.
  401. PROCEDURE (rd: Reader) Base (): Model
  402. Interface
  403. The rider base: The text the reader is attached to.
  404. PROCEDURE (rd: Reader) Pos (): LONGINT
  405. Interface
  406. Position of the reader in the text.
  407. 0 <= result
  408. result <= rd.Base().Length()
  409. PROCEDURE (rd: Reader) SetPos (pos: LONGINT)
  410. Interface
  411. Reposition the reader.
  412. 0 <= pos    20
  413. rd.Base() # NIL    21
  414. pos <= rd.Base().Length()    22
  415. rd.Pos() = pos
  416. PROCEDURE (rd: Reader) Read
  417. Interface
  418. Read the next element of the text.
  419. ~rd.eot
  420.     rd.Pos() = rd'.Pos() + 1
  421.     rd.type # {}, rd.attr # NIL
  422.     view IN rd.type
  423.         maskChar IN Prefs(view).opts, ch = Prefs(view).mask
  424.             ch IS CHAR
  425.                 char IN rd.type
  426.                 ~(lchar IN rd.type)
  427.                 rd.char = ch
  428.             ~(ch IS CHAR)
  429.                 ~(char IN rd.type)
  430.                 lchar IN rd.type
  431.         ~(maskChar IN Prefs(view).opts)
  432.             ~(char IN rd.type)
  433.             rd.char = unicode
  434. rd.eot
  435.     rd.type = {}, rd.attr = NIL, rd.char = 0X, rd.lchar = 0, rd.view = NIL
  436. PROCEDURE (rd: Reader) ReadPrev
  437. Interface
  438. Read the previous element of the text: First, decrements rd.Pos(), then reads element at rd.Pos().
  439. ~rd.eot
  440.     rd.Pos() = rd'.Pos() - 1
  441.     (otherwise as for rd.Read)
  442. rd.eot
  443.     rd.type = {}, rd.attr = NIL, rd.char = 0X, rd.lchar = 0, rd.view = NIL
  444. PROCEDURE (rd: Reader) ReadChar (VAR ch: CHAR)
  445. Default
  446. Read the next character or projection value of the next long character or embedded view.
  447. Except for performance, equivalent to:
  448.     rd.Read;
  449.     IF char IN rd.type THEN ch := rd.char
  450.     ELSIF lchar IN rd.type THEN ch := unicode
  451.     ELSIF view IN rd.type THEN ch := viewcode
  452.     ELSE ch := 0X
  453. PROCEDURE (rd: Reader) ReadPrevChar (VAR ch: CHAR)
  454. Default
  455. Read the previous character or projection value of the previous long character or embedded view.
  456. Except for performance, equivalent to:
  457.     rd.ReadPrev;
  458.     IF char IN rd.type THEN ch := rd.char
  459.     ELSIF lchar IN rd.type THEN ch := unicode
  460.     ELSIF view IN rd.type THEN ch := viewcode
  461.     ELSE ch := 0X
  462. PROCEDURE (rd: Reader) ReadLChar (VAR ch: LONGCHAR)
  463. Default
  464. Read the next long character or projection value of the next character or embedded view.
  465. Except for performance, equivalent to:
  466.     rd.Read;
  467.     IF char IN rd.type THEN ch := ORD(rd.char)
  468.     ELSIF lchar IN rd.type THEN ch := rd.lchar
  469.     ELSIF view IN rd.type THEN ch := ORD(viewcode)
  470.     ELSE ch := 0
  471. END ReadLChar;
  472. PROCEDURE (rd: Reader) ReadPrevLChar (VAR ch: LONGCHAR)
  473. Default
  474. Read the previous long character or projection value of the previous character or embedded view.
  475. Except for performance, equivalent to:
  476.     rd.ReadPrev;
  477.     IF char IN rd.type THEN ch := ORD(rd.char)
  478.     ELSIF lchar IN rd.type THEN ch := rd.lchar
  479.     ELSIF view IN rd.type THEN ch := ORD(viewcode)
  480.     ELSE ch := 0
  481. PROCEDURE (rd: Reader) ReadView (VAR v: Views.View)
  482. Default
  483. Read next view or projection value of next character or long character.
  484. Except for performance, equivalent to:
  485.     REPEAT rd.Read UNTIL (view IN rd.type) OR rd.eot;
  486.     IF rd.eot THEN v := NIL ELSE v := rd.view END
  487. PROCEDURE (rd: Reader) ReadPrevView (VAR v: Views.View)
  488. Default
  489. Read previous view or projection value of previous character or long character.
  490. Except for performance, equivalent to:
  491.     REPEAT rd.ReadPrev UNTIL (view IN rd.type) OR rd.eot;
  492.     IF rd.eot THEN v := NIL ELSE v := rd.view END
  493. PROCEDURE (rd: Reader) ReadRun (VAR attr: Attributes)
  494. Default
  495. Read next attribute run, stops at next view.
  496. Except for performance, equivalent to:
  497.     VAR a: Attributes;
  498.     a := rd.attr;
  499.     REPEAT rd.Read UNTIL (rd.attr # a) OR (rd.view # NIL) OR rd.eot;
  500.     IF rd.eot THEN attr := NIL ELSE attr := rd.attr END
  501. ~rd.eot
  502.     attr # NIL
  503.     rd.view = ViewAt(rd.Pos() - 1)
  504. PROCEDURE (rd: Reader) ReadPrevRun (VAR attr: Attributes)
  505. Default
  506. Read next attribute run, stops at next view.
  507. Except for performance, equivalent to:
  508.     VAR a: Attributes;
  509.     a := rd.attr;
  510.     REPEAT rd.ReadPrev UNTIL (rd.attr # a) OR (rd.view # NIL) OR rd.eot;
  511.     IF rd.eot THEN attr := NIL ELSE attr := rd.attr END
  512. ~rd.eot
  513.     attr # NIL
  514.     rd.view = ViewAt(rd.Pos())
  515. TYPE Writer
  516. Interface
  517. Write characters, long characters, or embed views into a text.
  518. attr-: Attributes
  519. The attributes object to attach to the next written element. (Attributes are immutable, thus they can be shared and need not be copied if used somewhere else.)
  520. PROCEDURE (wr: Writer) Base (): Model
  521. Interface
  522. Return the rider base, i.e. the text the writer is currently attached to.
  523. PROCEDURE (wr: Writer) Pos (): LONGINT
  524. Interface
  525. Position of the writer in the text.
  526. 0 <= result
  527. result <= rd.Base().Length()
  528. PROCEDURE (wr: Writer) SetPos (pos: LONGINT)
  529. Interface
  530. Reposition the writer.
  531. 0 <= pos    20
  532. wr.Base() # NIL    21
  533. pos <= wr.Base.Length()    22
  534. wr.Pos() = pos
  535. PROCEDURE (wr: Writer) WriteChar (ch: CHAR)
  536. Interface, Operation
  537. Write character with attributes wr.attr.
  538. wr.Pos() = wr.Pos'() + 1
  539. PROCEDURE (wr: Writer) WriteLChar (ch: LONGCHAR)
  540. Not yet implemented.
  541. PROCEDURE (wr: Writer) WriteView (view: Views.View; w, h: LONGINT)
  542. Write view with width w, height h, and attributes wr.attr.
  543. view # NIL    20
  544. view.context = NIL    21
  545. TYPE InfoMsg
  546. Extension
  547. Message notifying about a non
  548. destructive operation on a text.
  549. op: INTEGER
  550. For standard texts, there is only one op code defined: store.
  551. TYPE UpdateMsg
  552. Extension
  553. Message notifying about a destructive operation on a text.
  554. op: INTEGER
  555. Kind of operation performed. For standard texts, op IN {replace, insert, delete}.
  556. beg, end, delta: LONGINT
  557. The operation was performed on the stretch [beg, end) measured in the text after the operation took place, and caused changed the length of the text by delta. For deletions of length len, end = beg + 1, delta = -l; for insertions of length l, end = beg + l, delta = l; for replacements of length l but not changing the text length, end = beg = l, delta = 0.
  558. TYPE Directory
  559. Interface
  560. Directory for text models.
  561. attr: Attributes
  562. Default attributes, used when opening a writer on a text.
  563. PROCEDURE (d: Directory) New (): Model;
  564. Interface
  565. Return a new text model.
  566. PROCEDURE (d: Directory) SetAttr (attr: Attributes)
  567. Set the default attributes.
  568. attr # NIL    20
  569. attr.init    21
  570. VAR dir-, stdDir-: Directory    dir # NIL, stdDir # NIL, stable stdDir = d
  571. Directory and standard directory for text models.
  572. PROCEDURE  NewColor (a: Attributes; color: Ports.Color): Attributes
  573. PROCEDURE  NewTypeface (a: Attributes; typeface: Fonts.Typeface): Attributes
  574. PROCEDURE  NewSize (a: Attributes; size: LONGINT): Attributes
  575. PROCEDURE  NewStyle (a: Attributes; style: SET): Attributes
  576. PROCEDURE  NewWeight (a: Attributes; weight: INTEGER): Attributes
  577. PROCEDURE  NewOffset (a: Attributes; offset: LONGINT): Attributes
  578. Take an existing attributes object and return a new one with equal attributes except for the specified one.
  579. a # NIL    20
  580. a.init    21
  581. result # NIL
  582. PROCEDURE  NewFont (a: Attributes; font: Fonts.Font): Attributes
  583. Changes the entire font attribute.
  584. Except for performance, equivalent to:
  585.     NewTypeface(NewSize(NewStyle(NewWeight(a, font.weight), font.style),
  586.                                                 font.size), font.typeface)
  587. PROCEDURE  ReadAttr (VAR rd: Stores.Reader; VAR a: Attributes)
  588. 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.
  589. ~rd.rider.eof
  590. NextStore(rd) IS Attributes
  591. a # NIL
  592. ~MapsToAlien(NextStore(rd'))
  593.     a = NextStore(rd')
  594. MapsToAlien(NextStore(rd'))
  595.     a IS AlienAttributes
  596.     a.store = NextStore(rd')
  597. PROCEDURE  WriteAttr (VAR wr: Stores.Writer; a: Attributes)
  598. 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.
  599. a # NIL    20
  600. a.init    21
  601. Except for performance, equivalent to:
  602.     WITH a: AlienAttributes DO wr.WriteStore(a.store) ELSE wr.WriteStore(a) END
  603. PROCEDURE  SetDir (d: Directory)
  604. Set model directory.
  605. d # NIL    20
  606. d.attr # NIL    21
  607. TextControllers.StdCtrlDesc
  608. TextControllers.ControllerDesc
  609. Containers.ControllerDesc
  610. Controllers.ControllerDesc
  611. Geneva
  612. Documents.ControllerDesc
  613.