92 #ifndef _TEXT_OBJECT_H_INCLUDED_ 93 #define _TEXT_OBJECT_H_INCLUDED_ 187 #define HARD_TAB_CHAR '\xa0' 191 #define DEFAULT_TAB_WIDTH 8 195 #define AUTO_HSCROLL_SIZE 8 199 #define MIN_LINE_SPACING 2 203 #define MIN_BORDER_SPACING 2 206 // define the interface for the object 880 return &WBDefaultTextObjectVTable;
887 #define TEXT_OBJECT_TAG (*((const unsigned int *)"WBTX")) 1049 bzero(pTextObject,
sizeof(*pTextObject));
1081 #define TEXT_BUFFER_LINE_CACHE_SIZE 32 1259 unsigned long (*callback)(
TEXT_OBJECT *pThis,
int nRow,
int nCol),
1260 void *pColorContextPointer);
1342 char *
WBInsertMBChars(
char *pString,
int iCol,
const char *pszMBString,
int cbString,
1343 int fTab,
int fOverwrite,
int *piNewCol,
char **ppInserted);
1378 char *
WBJoinMBLine(
char *pString,
int iCol,
const char *pJoin);
1405 int WBDelMBChars(
char *pString,
int iCol,
int nDel,
int *piNewCol,
char **ppDeleted);
1445 #endif // __cplusplus 1447 #endif // _TEXT_OBJECT_H_INCLUDED_
'base class' structure for TEXT_OBJECT
e_DragState
State flags for mouse/cursor 'drag' (i.e. selection)
WB_RECT rctWinViewOld
previous viewport, in window coordinates [for invalidating window efficiently]
void(* begin_mouse_drag)(TEXT_OBJECT *pThis)
Begin a mouse 'drag' operation.
int WBGetMBColIndex(const char *pString, const char *pChar)
Obtain the column index from a pointer within a multi-byte character string.
char * WBGetMBCharPtr(char *pString, int iCol, int *pcbLen)
Obtain the pointer to a specific multi-byte character within a multi-byte character string,...
void(* do_expose)(TEXT_OBJECT *pThis, Display *pDisplay, Window wID, WBGC gc, const WB_GEOM *pPaintGeom, const WB_GEOM *pViewGeom, WB_FONTC pFont)
Member function to properly render the text in a window (Expose event)
'window helper' main header file for the X11workbench Toolkit API
TEXT_OBJECT * WBTextObjectConstructor(unsigned long cbStructSize, const char *szText, unsigned long cbLen, Window wIDOwner)
Generic constructor for a TEXT_OBJECT using defaults.
void WBTextObjectSetColorContextCallback(TEXT_OBJECT *pThis, unsigned long(*callback)(TEXT_OBJECT *pThis, int nRow, int nCol), void *pColorContextPointer)
assign callback function for 'color context' for a given character
void(* page_up)(TEXT_OBJECT *pThis)
Move the current cursor position up one page.
void(* mouse_click)(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 met...
void(* destroy)(TEXT_OBJECT *pThis)
Call this prior to de-allocating memory to free up any internal objects or storage.
int iMaxFontWidth
maximum width of font in pixels (mostly for proportional pitch) - cached by 'expose' handler
int iFontWidth
average width of font in pixels (mostly for fixed pitch) - cached by 'expose' handler
int iFileType
file type - -1=Makefile, 0=plain text, others are 'file type' constants, bit flags to preserve hard t...
void WBTextBufferLineChange(TEXT_BUFFER *pBuf, unsigned long nLine, int nNewLen)
Text buffer 'cached information' update function indicating a change to a line's length.
int(* get_insmode)(const TEXT_OBJECT *pThis)
Get the current insert mode for the object.
OVERWRITE mode, character inserted on top of character to the right of the cursor (if any),...
int iScrollMode
scroll mode - 0=normal, 1='scroll lock'
char * aLines[2]
array of 'lines'. each pointer is suballocated via WBAlloc()
BOX (selects a 'box' using virtual spacing)
void(* set_insmode)(TEXT_OBJECT *pThis, int iInsMode)
Set the current insert mode for the object.
void(* del_select)(TEXT_OBJECT *pThis)
Delete the current selection assigned via 'set_select'.
void(* redo)(TEXT_OBJECT *pThis)
Perform a single 'redo' operation.
void(* set_text)(TEXT_OBJECT *pThis, const char *szText, unsigned long cbLen)
Call this function to re-assign all text in the control.
char * WBSplitMBLine(char *pString, int iCol)
Split a multi-byte characters into a WBAlloc'd string, at a specified column, terminating the origina...
WB_RECT rctHighLight
highlight rect {0,0,0,0} implies NONE
e_FileType
file types for TEXT_OBJECT
void(* get_view)(const TEXT_OBJECT *pThis, WB_RECT *pRct)
Get the current viewport (in characters). The return value is not relevant if the expose method has n...
static __inline__ void WBInitializeInPlaceTextObject(TEXT_OBJECT *pTextObject, Window wIDOwner)
initialize an 'in-place' TEXT_OBJECT structure
void(* set_select)(TEXT_OBJECT *pThis, const WB_RECT *pRct)
Set the current selection rectangle as WB_RECT.
int(* can_redo)(TEXT_OBJECT *pThis)
Indicate whether a 'redo' operation is possible (mostly for menu UI)
int(* get_col)(const TEXT_OBJECT *pThis)
Get the current column cursor for the object.
int WBDelMBChars(char *pString, int iCol, int nDel, int *piNewCol, char **ppDeleted)
Delete a specified number of multi-byte characters from a string 'in place', starting at a specified ...
int iCursorX
X position of cursor as last drawn in expose event.
unsigned int aLineCacheLen[TEXT_BUFFER_LINE_CACHE_SIZE]
The actual line lengths associated with 'aLineCache' (zero if unused)
void(* set_filetype)(TEXT_OBJECT *pThis, int iLineFeed)
Set the current file type for the object.
int WBGetMBLength(const char *pString)
Obtain the length of a multi-byte character string in 'characters' (not bytes)
int(* get_linefeed)(const TEXT_OBJECT *pThis)
Get the current linefeed type for the object.
a bitmask for the various file types. Perform a logical 'and' of the file type value with this,...
unsigned long(* pColorContextCallback)(TEXT_OBJECT *, int, int)
callback function to get the context color of a character. default is NULL.
mouse 'drag' (select mode)
WB_RECT rctSel
select boundary in characters, {0,0,0,0} implies NONE, {-1,x,x,x} implies ALL. if top == bottom,...
int WBTextObjectCalculateLineHeight(int iAscent, int iDescent)
Calculate the correct per-line height (in pixels) for a specified font ascent and descent.
void(* end_highlight)(TEXT_OBJECT *pThis)
End a highlight block.
internal wrapper struct for X11 'geometry' definition
void(* undo)(TEXT_OBJECT *pThis)
Perform a single 'undo' operation.
int iInsMode
insert mode - 0=overwrite, 1=insert
int iSelMode
selection mode - 0=normal, 1=line, 2=box
unsigned long nArraySize
allocated size of aLines array
int WBCheckReAllocTextBuffer(TEXT_BUFFER **ppBuf, int nLinesToAdd)
Re-allocator for TEXT_BUFFER object.
void(* get_select)(const TEXT_OBJECT *pThis, WB_RECT *pRct)
Get the current selection rectangle as WB_RECT.
system default, usually 'insert'
void(* page_right)(TEXT_OBJECT *pThis)
Move the current cursor position right one page.
void(* page_down)(TEXT_OBJECT *pThis)
Move the current cursor position down one page.
void(* set_tab)(TEXT_OBJECT *pThis, int iTab)
Set the current tab type for the object.
LINE (always selects entire line when spanning multiple lines)
int(* get_rows)(const TEXT_OBJECT *pThis)
Call this function to obtain the total number of rows for display purposes.
void(* set_save_point)(TEXT_OBJECT *pThis)
Set the 'save point' with respect to the undo/redo buffer.
char * WBJoinMBLine(char *pString, int iCol, const char *pJoin)
Split a multi-byte characters into a WBAlloc'd string, at a specified column, terminating the origina...
void(* set_col)(TEXT_OBJECT *pThis, int iCol)
Set the current column cursor for the object.
WB_RECT rctViewOld
previous viewport [for invalidating window efficiently]
unsigned int nMinMaxCol
The 'smallest maximum' recorded in 'aLineCache'.
'base class' structure for TEXT_OBJECT
void * pText
pointer to (abstracted) object containing the text. void pointer allows abstraction....
int iCol
current col (cursor)
'custom' file types - 'or' with custom definition (0-0x7f)
void(* cursor_home)(TEXT_OBJECT *pThis)
Move the cursor 'home' (left or BOL)
int iCursorHeight
height of cursor as last drawn in expose event (always 1 if 'overwrite' cursor)
int iPos
position within buffer (reserved, MBCS may require it)
reserved - specifies custom array, indicating the size of the array containing the character values,...
int iCursorY
Y position of cursor as last drawn in expose event (top of cursor)
char * WBInsertMBChars(char *pString, int iCol, const char *pszMBString, int cbString, int fTab, int fOverwrite, int *piNewCol, char **ppInserted)
Insert multi-byte characters into a WBAlloc'd string, at a specified column.
void(* cursor_right)(TEXT_OBJECT *pThis)
Move the current cursor position right one column.
void(* set_view_orig)(TEXT_OBJECT *pThis, const WB_POINT *pOrig)
Set the current viewport (in characters). Only 'left' and 'top' are relevant if the expose method has...
void * pUndo
pointer to 'undo' buffer. NULL if empty.
void * pRedo
pointer to 'redo' buffer. NULL if empty.
int(* get_row)(const TEXT_OBJECT *pThis)
Get the current row cursor for the object.
'resource' file, text-based format
void(* cursor_up)(TEXT_OBJECT *pThis)
Move the current cursor position up one line.
int(* has_select)(const TEXT_OBJECT *pThis)
Returns a non-zero value if there is currently a 'selection'.
void WBTextObjectDestructor(TEXT_OBJECT *pObj)
Generic detructor for a TEXT_OBJECT.
unsigned int nMaxCol
The maximum column number for any line, rounded up by 'DEFAULT_TAB_WIDTH'.
int(* can_undo)(TEXT_OBJECT *pThis)
Indicate whether an 'undo' operation is possible (mostly for menu UI)
void(* replace_select)(TEXT_OBJECT *pThis, const char *szText, unsigned long cbLen)
Replace the current selection assigned via 'set_select' with new text.
int(* get_modified)(TEXT_OBJECT *pThis)
Set the 'save point' with respect to the undo/redo buffer.
XColor clrHFG
highlight FG color
e_InsertMode
Insert/Overwrite mode for TEXT_OBJECT.
void(* set_linefeed)(TEXT_OBJECT *pThis, int iLineFeed)
Set the current linefeed type for the object.
int iBlinkState
cursor blink state
INSERT mode, character inserted at cursor.
WB_RECT rctView
viewport, in characters (rctView.top is the top visible line, always)
unsigned long nEntries
number of entries currently in the array - call WBCheckReAllocTextBuffer() before increasing
const TEXT_OBJECT_VTABLE * vtable
method function pointers (similar to C++ virtual member functions)
void(* set_scrollmode)(TEXT_OBJECT *pThis, int iScrollMode)
Set the current scroll mode for the object.
e_LineFeed
line feed (line ending) types for TEXT_OBJECT
void(* scroll_vertical)(TEXT_OBJECT *pThis, int nRows)
Scroll the viewport up/down by the specified number of rows.
unsigned long aLineCache[TEXT_BUFFER_LINE_CACHE_SIZE]
An array of line indices, sorted longest to least, for the 'longest lines'.
int WBTextBufferLineLength(TEXT_BUFFER *pBuf, unsigned long nLine)
Text buffer 'cached information' query function indicating a line's cached length.
int(* get_tab)(const TEXT_OBJECT *pThis)
Get the current tab type for the object.
void(* del_chars)(TEXT_OBJECT *pThis, int nChar)
Delete 'n' characters from the current cursor. Negative deletes BEFORE the cursor....
e_SelectMode
select mode types for TEXT_OBJECT
void(* end_mouse_drag)(TEXT_OBJECT *pThis)
End a mouse 'drag' operation.
no special handling, no source decorations
void(* init)(TEXT_OBJECT *pThis)
Call this to initialize or re-initialize an object. Must call 'destroy' first for an existing object.
XColor clrHBG
highlight BG color
internal wrapper struct for 'rectangle' definition
void(* set_row)(TEXT_OBJECT *pThis, int iRow)
Set the current row cursor for the object.
void(* highlight_colors)(TEXT_OBJECT *pThis, XColor clrHFG, XColor clrHBG)
Call this to assign the highlight colors. Default colors are WBGC's BG and FG.
int(* get_scrollmode)(const TEXT_OBJECT *pThis)
Get the current scroll mode for the object.
void(* cursor_end)(TEXT_OBJECT *pThis)
Move the cursor to 'end' (full doc width or EOL)
void(* cursor_bottom)(TEXT_OBJECT *pThis)
Move the cursor to the last line.
WB_RECT rctWinView
viewport, in window coordinates, or 'empty' if unknown
void(* ins_chars)(TEXT_OBJECT *pThis, const char *pChar, int nChar)
Insert 'n' characters (including new lines) from the current cursor.
void * pColorContext
a user-controlled 'color context' pointer - can be anything, however
int(* get_selmode)(const TEXT_OBJECT *pThis)
Get the current selection mode for the object.
void(* indent)(TEXT_OBJECT *pThis, int nCol)
Indent selected text by 'n' columns.
void(* cursor_left)(TEXT_OBJECT *pThis)
Move the current cursor position left one column.
void WBFreeTextBuffer(TEXT_BUFFER *pBuf)
Re-allocator for TEXT_BUFFER object, returns ZERO on success. Pointer may be modified (or not).
static __inline__ int WBIsValidTextObject(const TEXT_OBJECT *pObj)
'TEXT_OBJECT' validator
Window wIDOwner
owner window (cached from paint/expose handling and/or cursor blink)
void(* set_selmode)(TEXT_OBJECT *pThis, int iSelMode)
Set the current selection mode for the object.
static __inline__ const TEXT_OBJECT_VTABLE * WBGetDefaultTextObjectVTable(void)
returns the default vtable for a TEXT_OBJECT structure
int iAsc
font height ascension
enum e_LineFeed iLineFeed
linefeed type (see enum). LineFeed_NONE implies SINGLE LINE
An allocated structure containing XFontStruct, XFontInfo, and XftFont [as applicable] for a specified...
void(* page_left)(TEXT_OBJECT *pThis)
Move the current cursor position left one page.
void(* cursor_blink)(TEXT_OBJECT *pThis, int bHasFocus)
Periodic callback to 'blink' the cursor.
int iTab
tab width in characters (0 = system default)
Make Files with special handling (implies 'hard tab', always)
#define TEXT_OBJECT_TAG
The 'tag' for a TEXT_OBJECT structure.
internal wrapper struct for 'point' definition
internal wrapper struct for GC with local cache
static __inline__ void WBDestroyInPlaceTextObject(TEXT_OBJECT *pTextObject)
Destroy a previously initialized 'in-place' TEXT_OBJECT structure.
int iDesc
font height descension
void(* begin_highlight)(TEXT_OBJECT *pThis)
Begin a highlight block.
'vtable' structure for TEXT_OBJECT
int iDragState
if '1' bit is set, cursor drag. if '2' bit is set, mouse drag
int(* get_cols)(TEXT_OBJECT *pThis)
Call this function to obtain the estimated column extent of the document.
void(* cursor_top)(TEXT_OBJECT *pThis)
Move the cursor to the top line.
int(* get_filetype)(const TEXT_OBJECT *pThis)
Get the current linefeed type for the object.
unsigned int ulTag
tag word, always assigned to TEXT_OBJECT_TAG
hard tabs - implied by 'FileType_MAKEFILE', otherwise explicit
int iRow
current row (cursor)
void(* cursor_down)(TEXT_OBJECT *pThis)
Move the current cursor position down one line.
cursor 'drag' (select mode)
void WBTextBufferRefreshCache(TEXT_BUFFER *pBuf)
Text buffer 'cached information' refresh function.
void(* scroll_horizontal)(TEXT_OBJECT *pThis, int nCols)
Scroll the cursor to the right/left a specified number of columns.
TEXT_BUFFER * WBAllocTextBuffer(const char *pBuf, unsigned int cbBufSize)
Generic constructor for a TEXT_BUFFER using defaults.