Text objects

Four classes provide increasing levels of support for text content:

  • CEditableText provides just text content, no formatting

  • CPlainText supports characters and paragraphs, fields and a page table. It can be manipulated and stored (using either a flat or segmented memory buffer), but has no formatting information and cannot be displayed. Examples of possible uses are spell checking and for explicit text handling buffers.

  • CGlobalText has a global format for all characters and all paragraphs

    This is the lowest-specification text class that can be laid out and displayed on the screen or printer. This is because layout and display require paragraph and character formats, however primitive.

  • CRichText all characters and paragraphs may have individually set format attributes; pictures are supported

    This provides fully general formatting.

A text object has any number of characters, and always ends with a paragraph mark, which is not included in the length. The shortest document contains zero characters. The characters in a text object are contained in a dynamic buffer, usually a CBufSeg but, for short text objects of bounded length, a CBufFlat may be more appropriate.

Manipulating text objects

Text objects provide functions to insert and delete text, and to exchange text with descriptors. Definitions for special characters are also provided.

Facilities to count characters, words and paragraphs are provided, and also to find the beginning of the next or previous word or paragraph. When scanning words, various types of delimiters may be used. For example picture characters and punctuation delimiters may be set, which is useful for spell checking. Delimeters, such as EScanPictureIsDelimiter, are set in a scan mask parameter to the ScanWords() functions of the CEditableText and CPlainText classes.

Addressable document positions

Characters are addressed by a document position, which may range from zero through to the length of the buffer. A document position is considered to mark the point between two adjacent characters. Thus document position 2 is located between the second and third characters. Document position 0 is located before the first character in the text object. Inserting text at position 5 will insert text immediately after the fifth character. Special elements such as paragraph marks, non-breaking spaces etc. are assigned to their Unicode character codes.