Developer

API Reference

TextInfo

Brew Release
Brew MP 1.0.2
See Also
ITextModel Interface
Description
This data structure defines the characteristics and attributes of a block of text stored in a text model. The structure includes information about the current selection and a pointer to the text itself. Each character within the text is indexed by a character position value, based at 0. Position 0 corresponds to the first character stored in the text model. The selection defined in TextInfo identifies a range of characters, marked by the position of the first character and the position that is one beyond the final character enclosed in that range. The selection also identifies where the next operation on the text will take place. When the range is zero (i.e. the first and last characters are the same), the range identifies the caret position -- the place at which new text would be inserted.
To illustrate, consider the following text in which "Astroboy" is the current selection.
                                              1   1   1   1   1   1   1   1   1   1
      0   1   2   3   4   5   6   7   8   9   0   1   2   3   4   5   6   7   8   9
       ---------------------------------------------------------------------------
      | A | s | t | r | o | b | o | y |   | i | s |   | a |   | r | o | b | o | t |
       ---------------------------------------------------------------------------
      ^                               ^
    start                             end

The range in the above example would be from positions 0 through 8, consisting of 8 characters. Any text operation (a deletion, replacement, etc) would act on the characters within the selection.
Likewise, consider the following example.
                                              1   1   1   1   1   1   1   1   1   1
      0   1   2   3   4   5   6   7   8   9   0   1   2   3   4   5   6   7   8   9
       ---------------------------------------------------------------------------
      | A | s | t | r | o | b | o | y |   | i | s |   | a |   | r | o | b | o | t |
       ---------------------------------------------------------------------------
                                                              ^
                                                            start
                                                             end

Here, the start and end of the selection range are equal, set to character position 14. Any subsequent text operation would take place at this position in the stored text, immediately before the word "robot" (so you could type "Astroboy is a very powerful futuristic robot").
Members
  • pwText:        Pointer to the text stored in the text model, stored as an AECHAR.
  • cchText:       Indicates the length of the text, expressed as the number of characters.
  • nSelStart:     Indicates the position of the character at the start of the text selection.
  • nSelEndCaret:  Indicates the position of the character at the end of the text selection.
    
Definition
   typedef struct {
      const AECHAR * pwText;
      int            cchText;
      int            nSelStart;
      int            nSelEndCaret;
   } TextInfo;
Comment
Both 'nSelStart' and 'nSelEnd' are zero-based.
  • Follow