Developer

API Reference

ITextModel_GetSelText()

Brew Release
Brew MP 1.0.2
See Also
- ITextModel
- TextInfo
- ITextModel_SetSel
Description
This function retrieves the current text selection in the text model, returning the text stored within the selection range, as well as the length (in characters) of the selection.
Parameters
  • pif
    []:
    Pointer to the ITextModel interface object.
  • pwBuf
    []:
    Pointer to an AECHAR buffer into which ITextModel_GetSelText() will copy the current text selection.
  • cchBuf
    []:
    The length of the text to be returned, expressed in number of characters. Pass 0 to retrieve no text, with the selection size still being returned by the function.
Interface
Prototype
   int ITextModel_GetSelText(ITextModel *pif, AECHAR *pwBuf, int cchBuf); 
Return
ITextModel_GetSelText() returns the number of characters in the current selection range, or 0 if there are no characters selected. The text within the selection range is returned in 'pwBuf' and is terminated by a NULL character. At most, 'cchBuf' characters -- including the terminating NULL -- will be returned in 'pwBuf'. To illustrate, consider the text below.
                                              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

In the above example, ITextModel_GetSelText() would return 2, with 'pwBuf' containing "is" followed by a NULL character.
Side Effect
None
Comment
ITextModel_GetSelText() will copy into 'pwBuf', at most, 'cchBuf' characters. So, to retrieve the entire selected text, 'cchBuf' must be the length of the selection plus the terminating NULL character.
  • Follow