Public Member Functions | |
TextBuffer (int requestedsize=0) | |
~TextBuffer () | |
int | length () const |
const char * | text () |
void | text (const char *text) |
char | character (int pos) |
char * | text_range (int start, int end) |
char * | text_in_rectangle (int start, int end, int rectStart, int rectEnd) |
void | insert (int pos, const char *text) |
void | append (const char *t) |
void | remove (int start, int end) |
void | replace (int start, int end, const char *text) |
void | copy (TextBuffer *from_buf, int from_start, int from_end, int to_pos) |
int | undo (int *cp=0) |
void | canUndo (char flag=1) |
int | insertfile (const char *file, int pos, int buflen=128 *1024) |
int | appendfile (const char *file, int buflen=128 *1024) |
int | loadfile (const char *file, int buflen=128 *1024) |
int | outputfile (const char *file, int start, int end, int buflen=128 *1024) |
int | savefile (const char *file, int buflen=128 *1024) |
void | insert_column (int column, int startpos, const char *text, int *chars_inserted, int *chars_deleted) |
void | replace_rectangular (int start, int end, int rectstart, int rectend, const char *text) |
void | overlay_rectangular (int startpos, int rectStart, int rectEnd, const char *text, int *charsInserted, int *charsDeleted) |
void | remove_rectangular (int start, int end, int rectStart, int rectEnd) |
void | clear_rectangular (int start, int end, int rectStart, int rectEnd) |
int | tab_distance () const |
void | tab_distance (int tabDist) |
void | select (int start, int end) |
bool | selected () const |
void | unselect () |
void | select_rectangular (int start, int end, int rectStart, int rectEnd) |
int | selection_position (int *start, int *end) |
int | selection_position (int *start, int *end, int *isRect, int *rectStart, int *rectEnd) |
char * | selection_text () |
void | remove_selection () |
void | replace_selection (const char *text) |
void | secondary_select (int start, int end) |
void | secondary_unselect () |
void | secondary_select_rectangular (int start, int end, int rectStart, int rectEnd) |
int | secondary_selection_position (int *start, int *end, int *isRect, int *rectStart, int *rectEnd) |
char * | secondary_selection_text () |
void | remove_secondary_selection () |
void | replace_secondary_selection (const char *text) |
void | highlight (int start, int end) |
void | unhighlight () |
void | highlight_rectangular (int start, int end, int rectStart, int rectEnd) |
int | highlight_position (int *start, int *end, int *isRect, int *rectStart, int *rectEnd) |
char * | highlight_text () |
void | add_modify_callback (Text_Modify_Cb bufModifiedCB, void *cbArg) |
void | remove_modify_callback (Text_Modify_Cb bufModifiedCB, void *cbArg) |
void | call_modify_callbacks () |
void | add_predelete_callback (Text_Predelete_Cb bufPredelCB, void *cbArg) |
void | remove_predelete_callback (Text_Predelete_Cb predelCB, void *cbArg) |
void | call_predelete_callbacks () |
char * | line_text (int pos) |
int | line_start (int pos) |
int | line_end (int pos) |
int | word_start (int pos) |
int | word_end (int pos) |
int | expand_character (int pos, int indent, char *outStr) |
int | count_displayed_characters (int lineStartPos, int targetPos) |
int | count_displayed_characters_utf (int lineStartPos, int targetPos) |
int | skip_displayed_characters (int lineStartPos, int nChars) |
int | skip_displayed_characters_utf (int lineStartPos, int nChars) |
int | count_lines (int startPos, int endPos) |
int | skip_lines (int startPos, int nLines) |
int | rewind_lines (int startPos, int nLines) |
bool | findchar_forward (int startPos, char searchChar, int *foundPos) |
bool | findchar_backward (int startPos, char searchChar, int *foundPos) |
bool | findchars_forward (int startpos, const char *searchChars, int *foundPos) |
bool | findchars_backward (int startpos, const char *searchChars, int *foundPos) |
bool | search_forward (int startPos, const char *searchString, int *foundPos, bool matchCase=false) |
bool | search_backward (int startPos, const char *searchString, int *foundPos, bool matchCase=false) |
char | null_substitution_character () |
TextSelection * | primary_selection () |
TextSelection * | secondary_selection () |
TextSelection * | highlight_selection () |
Static Public Member Functions | |
int | expand_character (char c, int indent, char *outStr, int tabDist, char nullSubsChar) |
int | character_width (char c, int indent, int tabDist, char nullSubsChar) |
Protected Member Functions | |
void | call_modify_callbacks (int pos, int nDeleted, int nInserted, int nRestyled, const char *deletedText) |
void | call_predelete_callbacks (int pos, int nDeleted) |
int | insert_ (int pos, const char *text) |
void | remove_ (int start, int end) |
void | remove_rectangular_ (int start, int end, int rectStart, int rectEnd, int *replaceLen, int *endPos) |
void | insert_column_ (int column, int startPos, const char *insText, int *nDeleted, int *nInserted, int *endPos) |
void | overlay_rectangular_ (int startPos, int rectStart, int rectEnd, const char *insText, int *nDeleted, int *nInserted, int *endPos) |
void | redisplay_selection (TextSelection *oldSelection, TextSelection *newSelection) |
void | move_gap (int pos) |
void | reallocate_with_gap (int newGapStart, int newGapLen) |
char * | selection_text_ (TextSelection *sel) |
void | remove_selection_ (TextSelection *sel) |
void | replace_selection_ (TextSelection *sel, const char *text) |
void | rectangular_selection_boundaries (int lineStartPos, int rectStart, int rectEnd, int *selStart, int *selEnd) |
void | update_selections (int pos, int nDeleted, int nInserted) |
Protected Attributes | |
TextSelection | primary_ |
TextSelection | secondary_ |
TextSelection | highlight_ |
int | length_ |
char * | buf_ |
int | gapstart_ |
int | gapend_ |
int | tabdist_ |
bool | usetabs_ |
int | nmodifyprocs_ |
Text_Modify_Cb * | modifyprocs_ |
void ** | modifycbargs_ |
int | npredeleteprocs_ |
Text_Predelete_Cb * | predeleteprocs_ |
void ** | prepeletecbargs_ |
int | cursorposhint_ |
char | nullsubschar_ |
char | mCanUndo |
|
Create an empty text buffer of a pre-determined size (use this to avoid unnecessary re-allocation if you know exactly how much the buffer will need to hold. |
|
Free a text buffer |
|
Add a callback routine to be called when the buffer is modified |
|
Add a callback routine to be called before text is deleted from the buffer. |
|
Call the stored modify callback procedure(s) for this buffer to update the changed area(s) on the screen and any other listeners. |
|
Call the stored pre-delete callback procedure(s) for this buffer to update the changed area(s) on the screen and any other listeners. |
|
Let the undo system know if we can undo changes. |
|
Return the character at buffer position "pos". Positions start at 0. |
|
Return the length in displayed characters of character "c" expanded for display (as discussed above in BufGetExpandedChar). If the buffer for which the character width is being measured is doing null substitution, nullSubsChar should be passed as that character (or nul to ignore). |
|
Clear a rectangular "hole" out of the buffer between character positions start and end and horizontal displayed-character offsets rectstart and rectend. |
|
Count the number of displayed characters between buffer position "linestartpos" and "targetpos". (displayed characters are the characters shown on the screen to represent characters in the buffer, where tabs and control characters are expanded) |
|
Count the number of newlines between startpos and endpos in buffer "buf". The character at position "endpos" is not counted. |
|
Expand a single character from the text buffer into it's screen representation (which may be several characters for a tab or a control code). Returns the number of characters added to "out_str". "indent" is the number of characters from the start of the line for figuring tabs. Output string is guranteed to be shorter or equal in length to TEXT_MAX_EXP_CHAR_LEN |
|
Get a character from the text buffer expanded into it's screen representation (which may be several characters for a tab or a control code). Returns the number of characters written to "out_str". "indent" is the number of characters from the start of the line for figuring tabs. Output string is guranteed to be shorter or equal in length to TEXT_MAX_EXP_CHAR_LEN |
|
Search backwards in buffer "buf" for character "searchChar", starting with the character BEFORE "startpos", returning the result in "foundPos" returns 1 if found, 0 if not. (The difference between this and BufSearchBackward is that it's optimized for single characters. The overall performance of the text widget is dependent on its ability to count lines quickly, hence searching for a single character: newline) |
|
Search forwards in buffer "buf" for character "searchChar", starting with the character "startpos", and returning the result in "foundPos" returns 1 if found, 0 if not. (The difference between this and BufSearchForward is that it's optimized for single characters. The overall performance of the text widget is dependent on its ability to count lines quickly, hence searching for a single character: newline) |
|
Search backwards in buffer "buf" for characters in "searchChars", starting with the character BEFORE "startpos", returning the result in "foundPos" returns True if found, False if not. |
|
Search forwards in buffer for string "searchString", starting with the character "startpos", and returning the result in "foundPos" returns 1 if found, 0 if not. |
|
Insert null-terminated string "s" at position "pos" in "buf" |
|
Internal (non-redisplaying) version of BufInsert. Returns the length of text inserted (this is just strlen(text), however this calculation can be expensive and the length will be required by any caller who will continue on to call redisplay). pos must be contiguous with the existing text in the buffer (i.e. not past the end). |
|
Insert "text" columnwise into buffer starting at displayed character position "column" on the line beginning at "startpos". Opens a rectangular space the width and height of "text", by moving all text to the right of "column" right. If chars_inserted and chars_deleted are not NULL, the number of characters inserted and deleted in the operation (beginning at startpos) are returned in these arguments. |
|
Insert a column of text without calling the modify callbacks. Note that in some pathological cases, inserting can actually decrease the size of the buffer because of spaces being coalesced into tabs. "ndeleted" and "ninserted" return the number of characters deleted and inserted beginning at the start of the line containing "startpos". "endpos" returns buffer position of the lower left edge of the inserted column (as a hint for routines which need to set a cursor position). |
|
Find the position of the end of the line containing position "pos" (which is either a pointer to the newline character ending the line, or a pointer to one character beyond the end of the buffer) |
|
Find the position of the start of the line containing position "pos" |
|
Return the text from the entire line containing position "pos" |
|
Overlay "text" between displayed character positions "rectstart" and "rectend" on the line beginning at "startpos". If chars_inserted and chars_deleted are not NULL, the number of characters inserted and deleted in the operation (beginning at startpos) are returned in these arguments. |
|
Overlay a rectangular area of text without calling the modify callbacks. "ndeleted" and "ninserted" return the number of characters deleted and inserted beginning at the start of the line containing "startpos". "endpos" returns buffer position of the lower left edge of the inserted column (as a hint for routines which need to set a cursor position). |
|
reallocate the text storage in "buf" to have a gap starting at "newGapStart" and a gap size of "newGapLen", preserving the buffer's current contents. |
|
Find the first and last character position in a line within a rectangular selection (for copying). Includes tabs which cross rectstart, but not control characters which do so. Leaves off tabs which cross rectend. Technically, the calling routine should convert tab characters which cross the right boundary of the selection to spaces which line up with the edge of the selection. Unfortunately, the additional memory management required in the parent routine to allow for the changes in string size is not worth all the extra work just for a couple of shifted characters, so if a tab protrudes, just lop it off and hope that there are other characters in the selection to establish the right margin for subsequent columnar pastes of this data. |
|
Call the stored redisplay procedure(s) for this buffer to update the screen for a change in a selection. |
|
Internal (non-redisplaying) version of BufRemove. Removes the contents of the buffer between start and end (and moves the gap to the site of the delete). |
|
Remove a rectangular swath of characters between character positions start and end and horizontal displayed-character offsets rectstart and rectend. |
|
Delete a rectangle of text without calling the modify callbacks. Returns the number of characters replacing those between start and end. Note that in some pathological cases, deleting can actually increase the size of the buffer because of tab expansions. "endpos" returns the buffer position of the point in the last line where the text was removed (as a hint for routines which need to position the cursor after a delete operation) |
|
Delete the characters between "start" and "end", and insert the null-terminated string "text" in their place in in "buf" |
|
Replace a rectangular area in buf, given by "start", "end", "rectstart", and "rectend", with "text". If "text" is vertically longer than the rectangle, add extra lines to make room for it. |
|
Find the position of the first character of the line "nlines" backwards from "startpos" (not counting the character pointed to by "startpos" if that is a newline) in "buf". nlines == 0 means find the beginning of the line |
|
Count forward from buffer position "startpos" in displayed characters (displayed characters are the characters shown on the screen to represent characters in the buffer, where tabs and control characters are expanded) |
|
Find the first character of the line "nlines" forward from "startpos" in "buf" and return its position |
|
Set the hardware tab distance used by all displays for this buffer, and used in computing offsets for rectangular selection operations. |
|
Replace the entire contents of the text buffer |
|
Return the entire contents of the text buffer. Returned memory is temporary and will only be usable until the next time the text is altered. Unlike previous versions of fltk, DO NOT FREE THE RETURNED RESULT! |
|
Return a copy of the text between "start" and "end" character positions from text buffer "buf". Positions start at 0, and the range does not include the character pointed to by "end" |
|
Remove text according to the undo variables or insert text from the undo buffer. |
|
Update all of the selections in "buf" for changes in the buffer's text |
|
allocated memory where the text is stored |
|
hint for reasonable cursor position after a buffer modification operation |
|
points to the first char after the gap |
|
points to the first character of the gap |
|
length of the text in the buffer (the length of the buffer itself must be calculated: gapend - gapstart + length) |
|
if this buffer is used for attributes, it must not do any undo calls |
|
caller arguments for modifyprocs_ above |
|
number of modify-redisplay procs attached |
|
number of pre-delete procs attached |
|
TextBuffer is based on C null-terminated strings, so ascii-nul characters must be substituted with something else. This is the else, but of course, things get quite messy when you use it |
|
caller argument for pre-delete proc above |
|
equiv. number of characters in a tab |
|
True if buffer routines are allowed to use tabs for padding in rectangular operations |