|
FLTK 1.4.4
|
This is an internal class for Fl_Text_Buffer to manage text selections. More...
#include <Fl_Text_Buffer.H>
Public Member Functions | |
| int | end () const |
| Returns the byte offset to the character after the last selected character. | |
| int | includes (int pos) const |
Returns true if position pos is in the Fl_Text_Selection. | |
| int | length () const |
| Returns the size in bytes of the selection. | |
| int | position (int *startpos, int *endpos) const |
| bool | selected () const |
| Returns true if any text is selected. | |
| void | selected (bool b) |
| Modifies the 'selected' flag. | |
| int | selected (int *startpos, int *endpos) const |
| Returns the status and the positions of this selection. | |
| void | set (int startpos, int endpos) |
| Sets the selection range. | |
| int | start () const |
| Returns the byte offset to the first selected character. | |
| void | update (int pos, int nDeleted, int nInserted) |
| Updates a selection after text was modified. | |
Friends | |
| class | Fl_Text_Buffer |
This is an internal class for Fl_Text_Buffer to manage text selections.
All methods use byte (not UTF-8 character) offsets and start at 0. This class works correctly with UTF-8 strings assuming that the parameters for all calls are on character boundaries.
If the selection is inactive (not currently used), then selected() returns false and start() and end() return 0 (zero).
The stored offsets are in ascending order, hence the following conditions are true (pseudo code):
The selection size in bytes can always (unconditionally) be computed by
mStart and mEnd are not necessarily 0 (zero) if mSelected == false because they are not cleared when selected(false) is called (as of Jul 2017). This may be changed in the future.
|
inline |
Returns the byte offset to the character after the last selected character.
The returned offset is only valid if selected() returns true (non-zero). The offset is 0 if no text is selected (since FLTK 1.4.0).
| int Fl_Text_Selection::includes | ( | int | pos | ) | const |
Returns true if position pos is in the Fl_Text_Selection.
pos must be at a character boundary.
|
inline |
Returns the size in bytes of the selection.
This is a convenience method. It always returns the same as
and it returns 0 if selected() == false.
|
inline |
|
inline |
Returns true if any text is selected.
true if any text has been selected, or false if no text is selected.
|
inline |
Modifies the 'selected' flag.
| b | new flag |
| int Fl_Text_Selection::selected | ( | int * | startpos, |
| int * | endpos ) const |
Returns the status and the positions of this selection.
This method returns the same as selected() as an int (0 or 1) in its return value and the offsets to the start of the selection in startpos and to the byte after the last selected character in endpos, if selected() is true.
If selected() is false, both offsets are set to 0.
startpos and endpos were not modified if selected() was false.| startpos | return byte offset to first selected character |
| endpos | return byte offset pointing after last selected character |
| 0 | if not selected |
| 1 | if selected |
| void Fl_Text_Selection::set | ( | int | startpos, |
| int | endpos ) |
Sets the selection range.
startpos and endpos must be at a character boundary.
If startpos != endpos selected() is set to true, else to false.
If startpos is greater than endpos they are swapped so that startpos <= endpos.
| [in] | startpos | byte offset to first selected character |
| [in] | endpos | byte offset pointing after last selected character |
|
inline |
Returns the byte offset to the first selected character.
The returned offset is only valid if selected() returns true. If the selection is not valid the returned offset is 0 since FLTK 1.4.0.
| void Fl_Text_Selection::update | ( | int | pos, |
| int | nDeleted, | ||
| int | nInserted ) |
Updates a selection after text was modified.
Updates an individual selection for changes in the corresponding text.
| pos | byte offset into text buffer at which the change occurred |
| nDeleted | number of bytes deleted from the buffer |
| nInserted | number of bytes inserted into the buffer |