X11workbench Toolkit  1.0
Structures associated with Text Objects

Structures associated with Text Objects. More...

Data Structures

struct  s_text_object_vtable
 'vtable' structure for TEXT_OBJECT More...
 
struct  s_text_object
 'base class' structure for TEXT_OBJECT More...
 
struct  s_text_buffer
 'base class' structure for TEXT_OBJECT More...
 

Typedefs

typedef struct s_text_object_vtable TEXT_OBJECT_VTABLE
 'vtable' structure for TEXT_OBJECT More...
 
typedef struct s_text_object TEXT_OBJECT
 'base class' structure for TEXT_OBJECT More...
 
typedef struct s_text_buffer TEXT_BUFFER
 'base class' structure for TEXT_OBJECT More...
 

Detailed Description

Structures associated with Text Objects.

The structures associated with Text Objects, including the 'VTABLE' structure and associated Text Object 'member' functions

Typedef Documentation

◆ TEXT_BUFFER

typedef struct s_text_buffer TEXT_BUFFER

'base class' structure for TEXT_OBJECT

typedef struct s_text_buffer
{
unsigned long nArraySize; // allocated size of aLines array
unsigned long nEntries; // number of entries currently in the array
// cached information
unsigned int nMaxCol; // The maximum column number for any line, rounded up by 'DEFAULT_TAB_WIDTH'
unsigned int nMinMaxCol; // The 'smallest maximum' recorded in 'aLineCache'
unsigned long aLineCache[TEXT_BUFFER_LINE_CACHE_SIZE];
// An array of line indices, sorted longest to least, for the 'longest lines'
unsigned int aLineCacheLen[TEXT_BUFFER_LINE_CACHE_SIZE];
// The actual line lengths associated with 'aLineCache' (zero if unused)
char * aLines[2]; // array of 'lines' suballocated via WBAlloc()
};
typedef struct s_text_buffer TEXT_BUFFER;

The structure is assumed to have a variable length array 'aLines' at the end, which extends beyond the length of the base structure. 'nArraySize' indicates the maximum size of this array, and 'nEntries' indicates the (contiguous) actual size of the array, starting at element [0].
This is a simple array structure, and to insert a line in the middle you will need to use 'memmove()' following a call to WBCheckReAllocTextBuffer(), and then re-assign 'nEntries' as needed. New entries must be allocated via 'WBAlloc()'.
To allocate a new structure, call WBAllocTextBuffer(). To free an allocated structure, call WBFreeTextBuffer().
The 'cached information' data members are maintained internally. You should not alter them. You can re-evaluate them at any time by calling WBTextBufferLineChange() and WBTextBufferRefreshCache()

Definition at line 1139 of file text_object.h.

◆ TEXT_OBJECT

typedef struct s_text_object TEXT_OBJECT

'base class' structure for TEXT_OBJECT

typedef struct s_text_object
{
const TEXT_OBJECT_VTABLE *vtable; // method function pointers (similar to C++ virtual members)
unsigned int ulTag; // tag word, always assigned to TEXT_OBJECT_TAG
Window wIDOwner; // owner window (cached from paint/expose handling and/or cursor blink)
WB_RECT rctSel; // select boundary in characters
WB_RECT rctHighLight; // highlight rect
XColor clrHFG; // highlight FG color
XColor clrHBG; // highlight BG color
int iFileType; // file type - -1=Makefile, 0=plain text, others are 'file type' constants
enum e_LineFeed iLineFeed; // linefeed type (see enum)
int iInsMode; // insert mode - 0=overwrite, 1=insert
int iSelMode; // selection mode - 0=normal, 1=line, 2=box
int iScrollMode; // scroll mode - 0=normal, 1='scroll lock'
int iTab; // tab width in characters (0 = system default)
// cursor position
int iRow; // current row (cursor)
int iCol; // current col (cursor)
int iPos; // position within buffer
int iCursorX; // X position of cursor as last drawn in expose event
int iCursorY; // Y position of cursor as last drawn in expose event (top of cursor)
int iCursorHeight; // height of cursor as last drawn in expose event
int iBlinkState; // cursor blink state
int iDragState; // if '1' bit is set, cursor drag. if '2' bit is set, mouse drag
int iAsc; // font height ascension (cached)
int iDesc; // font height descension (cached)
int iFontWidth; // average width of font in pixels (mostly for fixed pitch) - cached by 'expose' handler
int iMaxFontWidth; // maximum width of font in pixels (mostly for proportional pitch) - cached by 'expose' handler
// viewport
WB_RECT rctView; // viewport, in characters
WB_RECT rctWinView; // viewport, in window coordinates, or 'empty' if unknown
// these are maintained internally - do not use
WB_RECT rctViewOld; // previous viewport [for invalidating window efficiently]
WB_RECT rctWinViewOld; // previous viewport, in window coordinates [for invalidating window efficiently]
// the data
void *pText; // pointer to (abstracted) object containing the text. void pointer
// allows abstraction. member functions must handle correctly
void *pUndo; // pointer to 'undo' buffer. NULL if empty.
void *pRedo; // pointer to 'redo' buffer. NULL if empty.
void *pColorContext; // a user-controlled 'color context' pointer - can be anything, however
unsigned long (*pColorContextCallback)(TEXT_OBJECT *,
int, int); // callback function to get the context color of a character. default is NULL.
};
typedef struct s_text_object TEXT_OBJECT;

Definition at line 209 of file text_object.h.

◆ TEXT_OBJECT_VTABLE

'vtable' structure for TEXT_OBJECT

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

Definition at line 866 of file text_object.h.