Text command classes

The Text Editing framework command classes derive from the command template class TCommandOn<ATarget> provided by the Basic Document framework, taking an MTextSelection as the target. The framework includes commands for editing text data, either programmatically or from keyboard input, and for applying and modifying style information.

Editing character data

TReplaceTextCommand and TTypingCommand provide the mechanism for editing character data. TReplaceTextCommand is designed to be used for programmatic editing, while TTypingCommand and its subclass TDocumentTypingCommand are designed to handle user editing through keyboard input. These commands use the selection to access the text representation object and then modify the text directly.


TReplaceTextCommand replaces the selected range of text with a text string you specify. You can also use this command to insert and delete text as follows:

TTypingCommand supports text editing from the keyboard. This command deletes any originally selected range of text, and then inserts input text at the resulting offset. TTypingCommand is an incremental command, processing multiple input keystrokes during execution of a single command.

TDocumentTypingCommand derives from TTypingCommand and supports editing over embedded components.

Modifying style data

The abstract protocol for changing the style information associated with the text in a text representation object is provided by the class TChangeStylesCommand. Derived classes implement the HandleChangeStyles function to perform the style modification. These classes can be used to modify both character and paragraph styles.


TAddStylesCommand applies the specified set of styles to each character in the selected text range. If the styles to add are paragraph styles, the styles are applied to all paragraphs that intersect the selected range.

TRemoveStylesCommand removes the specified set of styles from each character in the selected range, or from each paragraph intersecting the selected range if the styles are paragraph styles. This command compares style objects by name, but not by value, when determining which styles to remove. For example, if the set specifying the styles to remove contains a TTextColorStyle instance with the value red, all TTextColorStyle objects are removed, not just one with the value red.

TReplaceStylesCommand replaces the existing style set for each character in the selected text range, or paragraph intersecting the selected range, with the specified style set. Do not use this command to replace only a limited set of styles, as it first removes all existing styles regardless of whether particular types of styles are in the replacement set.

TAddLanguageStyleCommand is an additional style command that applies a language style to selected characters based on a particular typing configuration. The framework uses this command to associate text of different languages with the correct typing configurations. If the user inserts more text into a particular input area, the framework can activate the correct typing configuration. For example, if a user is typing in English but places the cursor in a section of text typed in Japanese, the framework activates the typing configuration originally used to enter the Japanese text.


[Contents] [Previous] [Next]
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.

Generated with WebMaker