X11workbench Toolkit  1.0

'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_orig )(struct _text_object_ *pThis, const WB_POINT *pOrig)
 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(* scroll_vertical )(struct _text_object_ *pThis, int nRows)
 Scroll the viewport up/down by the specified number of rows. More...
 
void(* scroll_horizontal )(struct _text_object_ *pThis, int nCols)
 Scroll the cursor to the right/left a specified number of columns. 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...
 
void(* set_save_point )(struct _text_object_ *pThis)
 Set the 'save point' with respect to the undo/redo buffer. More...
 
int(* get_modified )(struct _text_object_ *pThis)
 Set the 'save point' with respect to the undo/redo buffer. 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_orig)(struct _text_object_ *pThis, const WB_POINT *pOrig);
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);
void (* scroll_vertical)(struct _text_object_ *pThis, int nRows);
void (* scroll_horizontal)(struct _text_object_ *pThis, int nCols);
// 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);
void (* set_save_point)(struct _text_object_ *pThis);
int (* get_modified)(struct _text_object_ *pThis);

Definition at line 317 of file text_object.h.

Field Documentation

◆ begin_highlight

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 655 of file text_object.h.

◆ begin_mouse_drag

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 693 of file text_object.h.

◆ can_redo

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 614 of file text_object.h.

◆ can_undo

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 602 of file text_object.h.

◆ cursor_blink

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 825 of file text_object.h.

◆ cursor_bottom

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 763 of file text_object.h.

◆ cursor_down

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 713 of file text_object.h.

◆ cursor_end

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 753 of file text_object.h.

◆ cursor_home

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 748 of file text_object.h.

◆ cursor_left

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 718 of file text_object.h.

◆ cursor_right

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 723 of file text_object.h.

◆ cursor_top

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 758 of file text_object.h.

◆ cursor_up

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 708 of file text_object.h.

◆ del_chars

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 570 of file text_object.h.

◆ del_select

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 555 of file text_object.h.

◆ destroy

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 323 of file text_object.h.

◆ do_expose

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.
See Also: WBTextObjectSetColorContextCallback()

Definition at line 813 of file text_object.h.

◆ end_highlight

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 665 of file text_object.h.

◆ end_mouse_drag

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 701 of file text_object.h.

◆ get_col

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 538 of file text_object.h.

◆ get_cols

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 385 of file text_object.h.

◆ get_filetype

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 394 of file text_object.h.

◆ get_insmode

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 427 of file text_object.h.

◆ get_linefeed

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 412 of file text_object.h.

◆ get_modified

int(* get_modified) (struct _text_object_ *pThis)

Set the 'save point' with respect to the undo/redo buffer.

Parameters
pThisA pointer to the TEXT_OBJECT structure
Returns
A non-zero value if the text object has been 'modified' since the last 'save' operation

Use this function to obtain the 'changed' status of the text object. A text object that has been saved (or was just created) is considered to be 'unmodified'. Otherwise, anything that writes to the undo buffer/redo buffer that has not directly reverted back to the 'as saved' content is considered "modified".

use set_save_point() to mark a file as 'saved' and set it to 'unmodified'

Definition at line 854 of file text_object.h.

◆ get_row

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 525 of file text_object.h.

◆ get_rows

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 371 of file text_object.h.

◆ get_scrollmode

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 478 of file text_object.h.

◆ get_sel_text

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 519 of file text_object.h.

◆ get_select

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 492 of file text_object.h.

◆ get_selmode

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 440 of file text_object.h.

◆ get_tab

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 459 of file text_object.h.

◆ get_text

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 346 of file text_object.h.

◆ get_view

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 630 of file text_object.h.

◆ has_select

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 505 of file text_object.h.

◆ highlight_colors

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 337 of file text_object.h.

◆ indent

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 596 of file text_object.h.

◆ init

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 329 of file text_object.h.

◆ ins_chars

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 586 of file text_object.h.

◆ mouse_click

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 683 of file text_object.h.

◆ page_down

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 733 of file text_object.h.

◆ page_left

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 738 of file text_object.h.

◆ page_right

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 743 of file text_object.h.

◆ page_up

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 728 of file text_object.h.

◆ redo

void(* redo) (struct _text_object_ *pThis)

Perform a single 'redo' operation.

Parameters
pThisA pointer to the TEXT_OBJECT structure
Returns
void

Definition at line 620 of file text_object.h.

◆ replace_select

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 563 of file text_object.h.

◆ scroll_horizontal

void(* scroll_horizontal) (struct _text_object_ *pThis, int nCols)

Scroll the cursor to the right/left a specified number of columns.

Parameters
pThisA pointer to the TEXT_OBJECT structure
nColsThe number of columns to scroll by; negative scrolls left, positive right

Definition at line 775 of file text_object.h.

◆ scroll_vertical

void(* scroll_vertical) (struct _text_object_ *pThis, int nRows)

Scroll the viewport up/down by the specified number of rows.

Parameters
pThisA pointer to the TEXT_OBJECT structure
nRowsThe number of rows to scroll by; negative scrolls up, positive down

Definition at line 769 of file text_object.h.

◆ set_col

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 549 of file text_object.h.

◆ set_filetype

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 404 of file text_object.h.

◆ set_insmode

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 434 of file text_object.h.

◆ set_linefeed

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 421 of file text_object.h.

◆ set_row

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 532 of file text_object.h.

◆ set_save_point

void(* set_save_point) (struct _text_object_ *pThis)

Set the 'save point' with respect to the undo/redo buffer.

Parameters
pThisA pointer to the TEXT_OBJECT structure

Use this function to inform the text object when you have saved the file, and it is no longer 'modified'. In conjuction with undo/redo, this helps to maintain the 'modified' state for the text object.

use get_modified() to determine whether or not a file has been modified since the last call to set_save_point().

Definition at line 839 of file text_object.h.

◆ set_scrollmode

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 485 of file text_object.h.

◆ set_select

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 499 of file text_object.h.

◆ set_selmode

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 447 of file text_object.h.

◆ set_tab

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 472 of file text_object.h.

◆ set_text

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 359 of file text_object.h.

◆ set_view_orig

void(* set_view_orig) (struct _text_object_ *pThis, const WB_POINT *pOrig)

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
pOrigA const pointer to a WB_POINT structure that contains the new viewport origin (in characters)
Returns
void

The 'viewport' is the currently visible area (in characters). It is independent of the cursor's row and column. You cannot assign the viewport size directly using this function. It is derived from things like the font size and the size of the display window. You can assign the origin this way, to force the display window to display an area of the text data beginning with the origin point. This is useful for scrollbar handling.

Definition at line 642 of file text_object.h.

◆ undo

void(* undo) (struct _text_object_ *pThis)

Perform a single 'undo' operation.

Parameters
pThisA pointer to the TEXT_OBJECT structure
Returns
void

Definition at line 608 of file text_object.h.


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