X11 Work Bench Toolkit  1.0
_text_object_vtable_ Struct Reference

'vtable' structure for TEXT_OBJECT More...

#include <text_object.h>

Data Fields

void(* destroy )(struct _text_object_ *pThis)
 Call this prior to de-allocating memory to free up any internal objects or storage. More...
 
void(* init )(struct _text_object_ *pThis)
 Call this to initialize or re-initialize an object. Must call 'destroy' first for an existing object. More...
 
void(* highlight_colors )(struct _text_object_ *pThis, XColor clrHFG, XColor clrHBG)
 Call this to assign the highlight colors. Default colors are GC's BG and FG. More...
 
char *(* get_text )(struct _text_object_ *pThis)
 Call this function to get all text, formatted so that it can be saved to a file. More...
 
void(* set_text )(struct _text_object_ *pThis, const char *szText, unsigned long cbLen)
 Call this function to re-assign all text in the control. More...
 
int(* get_rows )(const struct _text_object_ *pThis)
 Call this function to obtain the total number of rows for display purposes. More...
 
int(* get_cols )(struct _text_object_ *pThis)
 Call this function to obtain the estimated column extent of the document. More...
 
int(* get_filetype )(const struct _text_object_ *pThis)
 Get the current linefeed type for the object. More...
 
void(* set_filetype )(struct _text_object_ *pThis, int iLineFeed)
 Set the current file type for the object. More...
 
int(* get_linefeed )(const struct _text_object_ *pThis)
 Get the current linefeed type for the object. More...
 
void(* set_linefeed )(struct _text_object_ *pThis, int iLineFeed)
 Set the current linefeed type for the object. More...
 
int(* get_insmode )(const struct _text_object_ *pThis)
 Get the current insert mode for the object. More...
 
void(* set_insmode )(struct _text_object_ *pThis, int iInsMode)
 Set the current insert mode for the object. More...
 
int(* get_selmode )(const struct _text_object_ *pThis)
 Get the current selection mode for the object. More...
 
void(* set_selmode )(struct _text_object_ *pThis, int iSelMode)
 Set the current selection mode for the object. More...
 
int(* get_tab )(const struct _text_object_ *pThis)
 Get the current tab type for the object. More...
 
void(* set_tab )(struct _text_object_ *pThis, int iTab)
 Set the current tab type for the object. More...
 
int(* get_scrollmode )(const struct _text_object_ *pThis)
 Get the current scroll mode for the object. More...
 
void(* set_scrollmode )(struct _text_object_ *pThis, int iScrollMode)
 Set the current scroll mode for the object. More...
 
void(* get_select )(const struct _text_object_ *pThis, WB_RECT *pRct)
 Get the current selection rectangle as WB_RECT. More...
 
void(* set_select )(struct _text_object_ *pThis, const WB_RECT *pRct)
 Set the current selection rectangle as WB_RECT. More...
 
int(* has_select )(const struct _text_object_ *pThis)
 Returns a non-zero value if there is currently a 'selection'. More...
 
char *(* get_sel_text )(const struct _text_object_ *pThis, const WB_RECT *pRct)
 get the current selection rectangle as WB_RECT More...
 
int(* get_row )(const struct _text_object_ *pThis)
 Get the current row cursor for the object. More...
 
void(* set_row )(struct _text_object_ *pThis, int iRow)
 Set the current row cursor for the object. More...
 
int(* get_col )(const struct _text_object_ *pThis)
 Get the current column cursor for the object. More...
 
void(* set_col )(struct _text_object_ *pThis, int iCol)
 Set the current column cursor for the object. More...
 
void(* del_select )(struct _text_object_ *pThis)
 Delete the current selection assigned via 'set_select'. More...
 
void(* replace_select )(struct _text_object_ *pThis, const char *szText, unsigned long cbLen)
 Replace the current selection assigned via 'set_select' with new text. More...
 
void(* del_chars )(struct _text_object_ *pThis, int nChar)
 Delete 'n' characters from the current cursor. Negative deletes BEFORE the cursor. 'newline' counts as 1 character. More...
 
void(* ins_chars )(struct _text_object_ *pThis, const char *pChar, int nChar)
 Insert 'n' characters (including new lines) from the current cursor. More...
 
void(* indent )(struct _text_object_ *pThis, int nCol)
 Indent selected text by 'n' columns. More...
 
int(* can_undo )(struct _text_object_ *pThis)
 Indicate whether an 'undo' operation is possible (mostly for menu UI) More...
 
void(* undo )(struct _text_object_ *pThis)
 Perform a single 'undo' operation. More...
 
int(* can_redo )(struct _text_object_ *pThis)
 Indicate whether a 'redo' operation is possible (mostly for menu UI) More...
 
void(* redo )(struct _text_object_ *pThis)
 Perform a single 'redo' operation. More...
 
void(* get_view )(const struct _text_object_ *pThis, WB_RECT *pRct)
 Get the current viewport (in characters). The return value is not relevant if the expose method has not (yet) been called. More...
 
void(* set_view )(struct _text_object_ *pThis, const WB_RECT *pRct)
 Set the current viewport (in characters). Only 'left' and 'top' are relevant if the expose method has not (yet) been called. More...
 
void(* begin_highlight )(struct _text_object_ *pThis)
 Begin a highlight block. More...
 
void(* end_highlight )(struct _text_object_ *pThis)
 End a highlight block. More...
 
void(* mouse_click )(struct _text_object_ *pThis, int iMouseXDelta, int iMouseYDelta, int iType, int iACS)
 Translate mouse cursor position into actual row/column. This function is irrelevant if the expose method has not (yet) been called. More...
 
void(* begin_mouse_drag )(struct _text_object_ *pThis)
 Begin a mouse 'drag' operation. More...
 
void(* end_mouse_drag )(struct _text_object_ *pThis)
 End a mouse 'drag' operation. More...
 
void(* cursor_up )(struct _text_object_ *pThis)
 Move the current cursor position up one line. More...
 
void(* cursor_down )(struct _text_object_ *pThis)
 Move the current cursor position down one line. More...
 
void(* cursor_left )(struct _text_object_ *pThis)
 Move the current cursor position left one column. More...
 
void(* cursor_right )(struct _text_object_ *pThis)
 Move the current cursor position right one column. More...
 
void(* page_up )(struct _text_object_ *pThis)
 Move the current cursor position up one page. More...
 
void(* page_down )(struct _text_object_ *pThis)
 Move the current cursor position down one page. More...
 
void(* page_left )(struct _text_object_ *pThis)
 Move the current cursor position left one page. More...
 
void(* page_right )(struct _text_object_ *pThis)
 Move the current cursor position right one page. More...
 
void(* cursor_home )(struct _text_object_ *pThis)
 Move the cursor 'home' (left or BOL) More...
 
void(* cursor_end )(struct _text_object_ *pThis)
 Move the cursor to 'end' (full doc width or EOL) More...
 
void(* cursor_top )(struct _text_object_ *pThis)
 Move the cursor to the top line. More...
 
void(* cursor_bottom )(struct _text_object_ *pThis)
 Move the cursor to the last line. More...
 
void(* do_expose )(struct _text_object_ *pThis, Display *pDisplay, Window wID, GC gc, const WB_GEOM *pPaintGeom, const WB_GEOM *pViewGeom, XFontSet rFontSet)
 Member function to properly render the text in a window (Expose event) More...
 
void(* cursor_blink )(struct _text_object_ *pThis, int bHasFocus)
 Periodic callback to 'blink' the cursor. More...
 

Detailed Description

'vtable' structure for TEXT_OBJECT

typedef struct _text_object_vtable_
{
void (* destroy)(struct _text_object_ *pThis);
void (* init)(struct _text_object_ *pThis);
void (* highlight_colors)(struct _text_object_ *pThis, XColor clrHFG, XColor clrHBG);
char * (* get_text)(struct _text_object_ *pThis);
void (* set_text)(struct _text_object_ *pThis, const char *szText, unsigned long cbLen);
int (* get_rows)(const struct _text_object_ *pThis);
int (* get_cols)(struct _text_object_ *pThis);
int (* get_filetype)(const struct _text_object_ *pThis);
void (* set_filetype)(struct _text_object_ *pThis, int iLineFeed);
int (* get_linefeed)(const struct _text_object_ *pThis);
void (* set_linefeed)(struct _text_object_ *pThis, int iLineFeed);
int (* get_insmode)(const struct _text_object_ *pThis);
void (* set_insmode)(struct _text_object_ *pThis, int iInsMode);
int (* get_selmode)(const struct _text_object_ *pThis);
void (* set_selmode)(struct _text_object_ *pThis, int iSelMode);
int (* get_tab)(const struct _text_object_ *pThis);
void (* set_tab)(struct _text_object_ *pThis, int iTab);
int (* get_scrollmode)(const struct _text_object_ *pThis);
void (* set_scrollmode)(struct _text_object_ *pThis, int iScrollMode);
void (* get_select)(const struct _text_object_ *pThis, WB_RECT *pRct);
void (* set_select)(struct _text_object_ *pThis, const WB_RECT *pRct);
int (* has_select)(struct _text_object_ *pThis);
char* (* get_sel_text)(const struct _text_object_ *pThis, const WB_RECT *pRct);
int (* get_row)(const struct _text_object_ *pThis);
void (* set_row)(struct _text_object_ *pThis, int iRow);
int (* get_col)(const struct _text_object_ *pThis);
void (* set_col)(struct _text_object_ *pThis, int iCol);
void (* del_select)(struct _text_object_ *pThis);
void (* replace_select)(struct _text_object_ *pThis, const char *szText, unsigned long cbLen);
void (* del_chars)(struct _text_object_ *pThis, int nChar);
void (* ins_chars)(struct _text_object_ *pThis, const char *pChar, int nChar);
void (* indent)(struct _text_object_ *pThis, int nCol);
int (* can_undo)(struct _text_object_ *pThis);
void (* undo)(struct _text_object_ *pThis);
int (* can_redo)(struct _text_object_ *pThis);
void (* redo)(struct _text_object_ *pThis);
void (* get_view)(const struct _text_object_ *pThis, WB_RECT *pRct);
void (* set_view)(struct _text_object_ *pThis, const WB_RECT *pRct);
void (* begin_highlight)(struct _text_object_ *pThis);
void (* end_highlight)(struct _text_object_ *pThis);
// mouse conversion
void (* mouse_click)(struct _text_object_ *pThis, int iMouseXDelta, int iMouseYDelta, int iType, int iACS);
void (* begin_mouse_drag)(struct _text_object_ *pThis);
void (* end_mouse_drag)(struct _text_object_ *pThis);
// cursor motion
void (* cursor_up)(struct _text_object_ *pThis);
void (* cursor_down)(struct _text_object_ *pThis);
void (* cursor_left)(struct _text_object_ *pThis);
void (* cursor_right)(struct _text_object_ *pThis);
void (* page_up)(struct _text_object_ *pThis);
void (* page_down)(struct _text_object_ *pThis);
void (* page_left)(struct _text_object_ *pThis);
void (* page_right)(struct _text_object_ *pThis);
void (* cursor_home)(struct _text_object_ *pThis);
void (* cursor_end)(struct _text_object_ *pThis);
void (* cursor_top)(struct _text_object_ *pThis);
void (* cursor_bottom)(struct _text_object_ *pThis);
// handling expose events for the text area
void (* do_expose)(const struct _text_object_ *pThis, Display *pDisplay, Window wID,
GC gc, const WB_GEOM *pPaintGeom, const WB_GEOM *pViewGeom,
XFontSet rFontSet);
void (* cursor_blink)(struct _text_object_ *pThis, int bHasFocus);

Definition at line 267 of file text_object.h.

Field Documentation

void(* begin_highlight)(struct _text_object_ *pThis)

Begin a highlight block.

Parameters
pThisA pointer to the TEXT_OBJECT structure
pRctA const pointer to a WB_RECT structure that contains the new highlight block (in characters), or NULL to remove the highlight block
Returns
void

This function is essentially a UI helper for cursor select. When a cursor keystroke should cause a highlight to occur, call this function to start a highlight block. The current cursor will become the anchor, and subsequent cursor motion will extend the highlight block. A begin_highlight() will effectively do an end_mouse_drag() but will not clear the current selection. It is safe to call this function multiple times while selecting with cursor keys from the keyboard; hence, a 'shift' cursor should call this every time to avoid state flag checks.

Definition at line 602 of file text_object.h.

void(* begin_mouse_drag)(struct _text_object_ *pThis)

Begin a mouse 'drag' operation.

Parameters
pThisA pointer to the TEXT_OBJECT structure

This function is essentially a UI helper for mouse drag-select. Call this function in response to a WB_POINTER_DRAG notification, then call mouse_click() with the WB_POINTER_MOVE notifications. When the WB_POINTER_DROP notification arrives, call end_mouse_drag() to complete the operation.

Definition at line 640 of file text_object.h.

int(* can_redo)(struct _text_object_ *pThis)

Indicate whether a 'redo' operation is possible (mostly for menu UI)

Parameters
pThisA pointer to the TEXT_OBJECT structure
Returns
An integer indicating whether 'undo' is possible. A non-zero value is 'TRUE', zero 'FALSE.

Definition at line 564 of file text_object.h.

int(* can_undo)(struct _text_object_ *pThis)

Indicate whether an 'undo' operation is possible (mostly for menu UI)

Parameters
pThisA pointer to the TEXT_OBJECT structure
Returns
An integer indicating whether 'undo' is possible. A non-zero value is 'TRUE', zero 'FALSE.

Definition at line 552 of file text_object.h.

void(* cursor_blink)(struct _text_object_ *pThis, int bHasFocus)

Periodic callback to 'blink' the cursor.

Parameters
pThisA pointer to the TEXT_OBJECT structure
bHasFocusA non-zero value if the window has focus (cursor blinks), else zero (no cursor)

This function will alter the 'blink' state of the cursor, generating Expose events as needed to re-paint it within the window. An owning window should call this function using the time period specified by the system settings, but ONLY AFTER at least one 'do_expose' call.

Definition at line 761 of file text_object.h.

void(* cursor_bottom)(struct _text_object_ *pThis)

Move the cursor to the last line.

Parameters
pThisA pointer to the TEXT_OBJECT structure

Definition at line 710 of file text_object.h.

void(* cursor_down)(struct _text_object_ *pThis)

Move the current cursor position down one line.

Parameters
pThisA pointer to the TEXT_OBJECT structure

Definition at line 660 of file text_object.h.

void(* cursor_end)(struct _text_object_ *pThis)

Move the cursor to 'end' (full doc width or EOL)

Parameters
pThisA pointer to the TEXT_OBJECT structure

Definition at line 700 of file text_object.h.

void(* cursor_home)(struct _text_object_ *pThis)

Move the cursor 'home' (left or BOL)

Parameters
pThisA pointer to the TEXT_OBJECT structure

Definition at line 695 of file text_object.h.

void(* cursor_left)(struct _text_object_ *pThis)

Move the current cursor position left one column.

Parameters
pThisA pointer to the TEXT_OBJECT structure

Definition at line 665 of file text_object.h.

void(* cursor_right)(struct _text_object_ *pThis)

Move the current cursor position right one column.

Parameters
pThisA pointer to the TEXT_OBJECT structure

Definition at line 670 of file text_object.h.

void(* cursor_top)(struct _text_object_ *pThis)

Move the cursor to the top line.

Parameters
pThisA pointer to the TEXT_OBJECT structure

Definition at line 705 of file text_object.h.

void(* cursor_up)(struct _text_object_ *pThis)

Move the current cursor position up one line.

Parameters
pThisA pointer to the TEXT_OBJECT structure

Definition at line 655 of file text_object.h.

void(* del_chars)(struct _text_object_ *pThis, int nChar)

Delete 'n' characters from the current cursor. Negative deletes BEFORE the cursor. 'newline' counts as 1 character.

Parameters
pThisA pointer to the TEXT_OBJECT structure
nCharThe number of characters to delete. Negative values delete BEFORE the cursor. Zero does nothing.
Returns
void

Definition at line 520 of file text_object.h.

void(* del_select)(struct _text_object_ *pThis)

Delete the current selection assigned via 'set_select'.

Parameters
pThisA pointer to the TEXT_OBJECT structure
Returns
void

Definition at line 505 of file text_object.h.

void(* destroy)(struct _text_object_ *pThis)

Call this prior to de-allocating memory to free up any internal objects or storage.

Parameters
pThisA pointer to the TEXT_OBJECT structure
Returns
void

Definition at line 273 of file text_object.h.

void(* do_expose)(struct _text_object_ *pThis, Display *pDisplay, Window wID, GC gc, const WB_GEOM *pPaintGeom, const WB_GEOM *pViewGeom, XFontSet rFontSet)

Member function to properly render the text in a window (Expose event)

Parameters
pThisA pointer to the TEXT_OBJECT structure
pDisplayA pointer to the Display for the window (NULL to use Default)
wIDThe Window ID for the window to be painted
gcThe graphics context to use when painting
pPaintGeomA const pointer to a WB_GEOM structure bounding the invalid area (NULL implies ALL)
pViewGeomA const pointer to a WB_GEOM structure bounding the paintable area within the window (NULL implies entire window)
rFontSetAn 'XFontSet' to use in lieu of the font assigned to the Window (None if the Window's default font is used)

Use this function in the Expose event callback for the window in order to properly render the edit text. Prior to calling this function you will need to assign the correct foreground color, and background color to the GC. If 'rFontSet' is None, then the font must also be already assigned to the GC or to the Window; otherwise, the specified font will be used to render the text. Note that all fonts will be treate as if they are 'fixed pitch' and so a variable pitch font will be rendered "centered" within the character's position.

The 'pViewGeom' member represents the bounding rectangle of the window 'wID' within which to render the text, excluding any scroll bars. Changes to this value may require re-calculating the current 'view' area, which will attempt to preserve the relevant area with respect to the current cursor position and/or visible text.

This function will cache the Window ID as 'wIDOwner' for subsequent use by a number of internal operations. This ensures the most efficient expose handling. Callers should only invalidate areas handled by the TEXT_OBJECT when absolutely necessary.

NOTE: text color may be adjusted based on the type of buffer data being stored. Some buffered text data might have color information associated with it and as such the text will be rendered using the appropriate color. Color information is object-specific.

TODO: a 'context text color' callback function that can be assigned either to the vtable, or as a function pointer, in which the default text color would be the GC foreground color.

Definition at line 749 of file text_object.h.

void(* end_highlight)(struct _text_object_ *pThis)

End a highlight block.

Parameters
pThisA pointer to the TEXT_OBJECT structure
pRctA const pointer to a WB_RECT structure that contains the new highlight block (in characters), or NULL to remove the highlight block
Returns
void

This function is essentially a UI helper for cursor select. Normally a keystroke that is NOT a cursor motion will automatically end the highlighting. Calling this function does not affect the highlighted area. It is safe to call this function at any time, whether highlighting is taking place or not.

Definition at line 612 of file text_object.h.

void(* end_mouse_drag)(struct _text_object_ *pThis)

End a mouse 'drag' operation.

Parameters
pThisA pointer to the TEXT_OBJECT structure

This function is essentially a UI helper for mouse drag-select. It is safe to call this function at any time, whether highlighting is taking place or not.

Definition at line 648 of file text_object.h.

int(* get_col)(const struct _text_object_ *pThis)

Get the current column cursor for the object.

Parameters
pThisA pointer to the TEXT_OBJECT structure
Returns
an integer indicating the current column (independent of hard tabs or end of line)

Definition at line 488 of file text_object.h.

int(* get_cols)(struct _text_object_ *pThis)

Call this function to obtain the estimated column extent of the document.

Parameters
pThisA pointer to the TEXT_OBJECT structure
Returns
The total column extent, estimated and periodically re-calculated. If the text is empty, the value is zero

This function returns the estimated column count, the maximum extent of any line within the text object. While editing, if the column count of a single line exceeds the current 'maximum', a new maximum will be calculated in "tab widths". Periodically this value will be re-estimated as needed to accomodate changes to the text.
NOTE: the pointer to the TEXT_OBJECT cannot be a 'const' in this case, since cached values may need to be re-evaluated as part of the process of obtaining the desired information.

Definition at line 335 of file text_object.h.

int(* get_filetype)(const struct _text_object_ *pThis)

Get the current linefeed type for the object.

Parameters
pThisA pointer to the TEXT_OBJECT structure
Returns
an integer indicating the current file type, one of the 'file type' definitions

A file type of 0 is 'plain text'. A file type of '-1' is 'Makefile' and by default, preserves hard tabs. Other file types are defined as one of the 'file type' constants

Definition at line 344 of file text_object.h.

int(* get_insmode)(const struct _text_object_ *pThis)

Get the current insert mode for the object.

Parameters
pThisA pointer to the TEXT_OBJECT structure
Returns
an integer indicating the current insert mode

Definition at line 377 of file text_object.h.

int(* get_linefeed)(const struct _text_object_ *pThis)

Get the current linefeed type for the object.

Parameters
pThisA pointer to the TEXT_OBJECT structure
Returns
an integer indicating the current 'linefeed' type for end of line

iLineFeed values: 0 (single line) 1 (newline) 2 (return) 3 (crlf) 4 (lfcr)

Definition at line 362 of file text_object.h.

int(* get_row)(const struct _text_object_ *pThis)

Get the current row cursor for the object.

Parameters
pThisA pointer to the TEXT_OBJECT structure
Returns
an integer indicating the current row

Definition at line 475 of file text_object.h.

int(* get_rows)(const struct _text_object_ *pThis)

Call this function to obtain the total number of rows for display purposes.

Parameters
pThisA const pointer to the TEXT_OBJECT structure
Returns
The total row count including the last row, even if it is blank. If the text is empty, the return value is zero

This function returns the row count. If the final line is blank, the row count will still include it. The return value is intended to assist scrolling the viewable area, so a final blank line must still be counted. Single-line text always returns a 1 unless the text is empty. A zero is always returned whenever there is no text in the object. This allows you to detect an 'empty' text object.

Definition at line 321 of file text_object.h.

int(* get_scrollmode)(const struct _text_object_ *pThis)

Get the current scroll mode for the object.

Parameters
pThisA pointer to the TEXT_OBJECT structure
Returns
an integer indicating the current scroll mode

Definition at line 428 of file text_object.h.

char*(* get_sel_text)(const struct _text_object_ *pThis, const WB_RECT *pRct)

get the current selection rectangle as WB_RECT

Parameters
pThisA pointer to the TEXT_OBJECT structure
pRctA const pointer to the source WB_RECT containing the selection rectangle. NULL uses the current selection.
Returns
A 'WBAlloc'd pointer to the selected text.

This function returns a 'WBAlloc'd pointer, or NULL on error. If the returned pointer is not NULL, the caller must free it.
If the select mode is 'block', individual lines will always end in <LF>, and tabs will expand to <space> characters except for the 'special case' noted below
In the special case of *pRct == {0,0,0,0}, all of the text will be copied, regardless of the select mode, in a format consistent with saving the text as a file, using the assigned line ending.

Definition at line 469 of file text_object.h.

void(* get_select)(const struct _text_object_ *pThis, WB_RECT *pRct)

Get the current selection rectangle as WB_RECT.

Parameters
pThisA pointer to the TEXT_OBJECT structure
pRctA pointer to the destination WB_RECT, receives the return value. 'No select' returns {0,0,0,0}
Returns
void

Definition at line 442 of file text_object.h.

int(* get_selmode)(const struct _text_object_ *pThis)

Get the current selection mode for the object.

Parameters
pThisA pointer to the TEXT_OBJECT structure
Returns
an integer indicating the current selection mode

Definition at line 390 of file text_object.h.

int(* get_tab)(const struct _text_object_ *pThis)

Get the current tab type for the object.

Parameters
pThisA pointer to the TEXT_OBJECT structure
Returns
an integer indicating the current tab type

A positive tab type is the column width for a 'hard tab' character. A negative tab type indicates the tab column width but substitutes spaces for hard tabs.
NOTE: Existing hard tabs within the text will be preserved even if a negative tab type is selected, so long as the white space covered by the tab is not modified.
A tab type of zero uses the 'default' behavior for the application and file type.

Definition at line 409 of file text_object.h.

char*(* get_text)(struct _text_object_ *pThis)

Call this function to get all text, formatted so that it can be saved to a file.

Parameters
pThisA pointer to the TEXT_OBJECT structure
Returns
A 'WBAlloc'd pointer to the selected text.

This function allocates a buffer, then copies all of the text to the buffer using the specified line endings and other information.

Definition at line 296 of file text_object.h.

void(* get_view)(const struct _text_object_ *pThis, WB_RECT *pRct)

Get the current viewport (in characters). The return value is not relevant if the expose method has not (yet) been called.

Parameters
pThisA pointer to the TEXT_OBJECT structure
pRctA pointer to a WB_RECT structure that receives the current viewport (in characters)
Returns
void

The 'viewport' is the currently visible area (in characters). It is independent of the cursor's row and column.

Definition at line 580 of file text_object.h.

int(* has_select)(const struct _text_object_ *pThis)

Returns a non-zero value if there is currently a 'selection'.

Parameters
pThisA pointer to the TEXT_OBJECT structure
Returns
A non-zero integer if the selection rectangle is valid and not empty, otherwise zero.

Definition at line 455 of file text_object.h.

void(* highlight_colors)(struct _text_object_ *pThis, XColor clrHFG, XColor clrHBG)

Call this to assign the highlight colors. Default colors are GC's BG and FG.

Parameters
pThisA pointer to the TEXT_OBJECT structure
clrHFGThe XColor for the highlighted foreground
clrHBGThe XColor for the highlighted background
Returns
void

Definition at line 287 of file text_object.h.

void(* indent)(struct _text_object_ *pThis, int nCol)

Indent selected text by 'n' columns.

Parameters
pThisA pointer to the TEXT_OBJECT structure
nCharThe number of characters to indent by. negative indents left, positive right. Zero does nothing.
Returns
void

indents the selected text by 'n' columns. Indent starts at the cursor and continues for each line within the selected text.

Definition at line 546 of file text_object.h.

void(* init)(struct _text_object_ *pThis)

Call this to initialize or re-initialize an object. Must call 'destroy' first for an existing object.

Parameters
pThisA pointer to the TEXT_OBJECT structure
Returns
void

Definition at line 279 of file text_object.h.

void(* ins_chars)(struct _text_object_ *pThis, const char *pChar, int nChar)

Insert 'n' characters (including new lines) from the current cursor.

Parameters
pThisA pointer to the TEXT_OBJECT structure
pCharA pointer to the text to insert. NULL effectively does nothing.
nCharThe number of characters in the buffer pointed to by 'pChar', or 0 to indicate '0-byte terminated string'
Returns
void

The behavior of multi-line insert depends upon the selection mode. If 'char' or 'line' mode is selected, a 'newline' inserts a new line following the newline character. "\r\n", "\r", "\n", and "\n\r" are all treated the same. Multiple LF and CR combinations that vary in order/construct may produce unexpected results. if 'box' mode is selected, each subsequent line will be inserted at the next line's 'col' position. Hard tabs will be evaluated during insertion and converted to white space. It is assumed that the length of each line in 'box' select mode will be identical, but if it is not, the results will follow the length of the actual text. If the 'box' select length exceeds the last line of the file, the additional lines will be added as if in 'line' mode.

Definition at line 536 of file text_object.h.

void(* mouse_click)(struct _text_object_ *pThis, int iMouseXDelta, int iMouseYDelta, int iType, int iACS)

Translate mouse cursor position into actual row/column. This function is irrelevant if the expose method has not (yet) been called.

Parameters
pThisA pointer to the TEXT_OBJECT structure
iMouseXDeltaThe delta X position of the mouse cursor from the upper left corner of the viewport window
iMouseYDeltaThe delta Y position of the mouse cursor from the upper left corner of the viewport window
iTypeA bit mask indicating the mouse button (typically WB_POINTER_BUTTON1, or 0 for mouse motion during drag)
iACSA bit mask indicating ALT+CONTROL+SHIFT state (typically 0)
Returns
void

Call this function to process mouse clicks properly. It will cause the cursor to move, or a highlighted area to be extended, depending on the nature of the mouse click. Use begin_mouse_drag() and end_mouse_drag() to indicate if a mouse drag operation (highlight an area) is in progress.
Mouse clicks automatically do an end_highlight() and clear the highlight area if a 'drag' is not in progress.

Definition at line 630 of file text_object.h.

void(* page_down)(struct _text_object_ *pThis)

Move the current cursor position down one page.

Parameters
pThisA pointer to the TEXT_OBJECT structure

Definition at line 680 of file text_object.h.

void(* page_left)(struct _text_object_ *pThis)

Move the current cursor position left one page.

Parameters
pThisA pointer to the TEXT_OBJECT structure

Definition at line 685 of file text_object.h.

void(* page_right)(struct _text_object_ *pThis)

Move the current cursor position right one page.

Parameters
pThisA pointer to the TEXT_OBJECT structure

Definition at line 690 of file text_object.h.

void(* page_up)(struct _text_object_ *pThis)

Move the current cursor position up one page.

Parameters
pThisA pointer to the TEXT_OBJECT structure

Definition at line 675 of file text_object.h.

void(* redo)(struct _text_object_ *pThis)

Perform a single 'redo' operation.

Parameters
pThisA pointer to the TEXT_OBJECT structure
Returns
void

Definition at line 570 of file text_object.h.

void(* replace_select)(struct _text_object_ *pThis, const char *szText, unsigned long cbLen)

Replace the current selection assigned via 'set_select' with new text.

Parameters
pThisA pointer to the TEXT_OBJECT structure
szTextA pointer to the text to replace the selection with (NULL or "" effectively performs 'del_select')
cbLenThe length of the text to replace the selection with (zero implies 'zero-byte terminated string' for szText)
Returns
void

Definition at line 513 of file text_object.h.

void(* set_col)(struct _text_object_ *pThis, int iCol)

Set the current column cursor for the object.

Parameters
pThisA pointer to the TEXT_OBJECT structure
iColThe column position, where 0 is the left-most column (independent of hard tabs or end of line).
Returns
void

Passing '-1' for the 'iCol' parameter will place the cursor on the first non-white-space character on the line (if any).
Passing '-2' for the 'iCol' parameter will place the cursor at the end of the line, excluding any trailing white space.
Passing any other negative value is the same as passing '0'.

Definition at line 499 of file text_object.h.

void(* set_filetype)(struct _text_object_ *pThis, int iLineFeed)

Set the current file type for the object.

Parameters
pThisA pointer to the TEXT_OBJECT structure
iInsModeAn integer indicating the new file type, one of the 'file type' definitions
Returns
void

A file type of 0 is 'plain text'. A file type of '-1' is 'Makefile' and by default, preserves hard tabs. Other file types are defined as one of the 'file type' constants

Definition at line 354 of file text_object.h.

void(* set_insmode)(struct _text_object_ *pThis, int iInsMode)

Set the current insert mode for the object.

Parameters
pThisA pointer to the TEXT_OBJECT structure
iInsModeAn integer indicating the new insert mode
Returns
void

Definition at line 384 of file text_object.h.

void(* set_linefeed)(struct _text_object_ *pThis, int iLineFeed)

Set the current linefeed type for the object.

Parameters
pThisA pointer to the TEXT_OBJECT structure
iInsModeAn integer indicating the new 'linefeed' type for end of line
Returns
void

iLineFeed values: 0 (single line) 1 (newline) 2 (return) 3 (crlf) 4 (lfcr)

Definition at line 371 of file text_object.h.

void(* set_row)(struct _text_object_ *pThis, int iRow)

Set the current row cursor for the object.

Parameters
pThisA pointer to the TEXT_OBJECT structure
iRowThe row position, where 0 is the top row
Returns
void

Definition at line 482 of file text_object.h.

void(* set_scrollmode)(struct _text_object_ *pThis, int iScrollMode)

Set the current scroll mode for the object.

Parameters
pThisA pointer to the TEXT_OBJECT structure
iScrollModeAn integer indicating the new scroll mode
Returns
void

Definition at line 435 of file text_object.h.

void(* set_select)(struct _text_object_ *pThis, const WB_RECT *pRct)

Set the current selection rectangle as WB_RECT.

Parameters
pThisA pointer to the TEXT_OBJECT structure
pRctA const pointer to the source WB_RECT containing the new selection rectangle, or NULL for 'no selection'
Returns
void

Definition at line 449 of file text_object.h.

void(* set_selmode)(struct _text_object_ *pThis, int iSelMode)

Set the current selection mode for the object.

Parameters
pThisA pointer to the TEXT_OBJECT structure
iSelModeAn integer indicating the new selection mode
Returns
void

Definition at line 397 of file text_object.h.

void(* set_tab)(struct _text_object_ *pThis, int iTab)

Set the current tab type for the object.

Parameters
pThisA pointer to the TEXT_OBJECT structure
iTabAn integer indicating the new tab type
Returns
void

A positive tab type is the column width for a 'hard tab' character. A negative tab type indicates the tab column width but substitutes spaces for hard tabs.
NOTE: Existing hard tabs within the text will be preserved even if a negative tab type is selected, so long as the white space covered by the tab is not modified.
A tab type of zero uses the 'default' behavior for the application and file type.

Definition at line 422 of file text_object.h.

void(* set_text)(struct _text_object_ *pThis, const char *szText, unsigned long cbLen)

Call this function to re-assign all text in the control.

Parameters
pThisA pointer to the TEXT_OBJECT structure
szTextA pointer to the text to replace the selection with (NULL or "" effectively empties the buffer)
cbLenThe length of the text to replace the selection with (zero implies 'zero-byte terminated string' for szText)
Returns
void

Typically this is called when a file is (re)loaded or when the 'caption' is changed for the control. Calling this function will perform a number of related functions, such as cursor positioning.
You should manually force a re-draw of the control displaying the text. It will not happen automatically.

Definition at line 309 of file text_object.h.

void(* set_view)(struct _text_object_ *pThis, const WB_RECT *pRct)

Set the current viewport (in characters). Only 'left' and 'top' are relevant if the expose method has not (yet) been called.

Parameters
pThisA pointer to the TEXT_OBJECT structure
pRctA const pointer to a WB_RECT structure that contains the new viewport (in characters)
Returns
void

The 'viewport' is the currently visible area (in characters). It is independent of the cursor's row and column.

Definition at line 589 of file text_object.h.

void(* undo)(struct _text_object_ *pThis)

Perform a single 'undo' operation.

Parameters
pThisA pointer to the TEXT_OBJECT structure
Returns
void

Definition at line 558 of file text_object.h.


The documentation for this struct was generated from the following file: