X11workbench Toolkit  1.0
text_object.h File Reference

A 'C++'-like object for managing text, that can be overridden for custom behavior. More...

#include "window_helper.h"

Go to the source code of this file.

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...
 

Macros

#define HARD_TAB_CHAR   '\xa0'
 
#define DEFAULT_TAB_WIDTH   8
 
#define AUTO_HSCROLL_SIZE   8
 
#define MIN_LINE_SPACING   2
 
#define MIN_BORDER_SPACING   2
 
#define TEXT_OBJECT_TAG   (*((const unsigned int *)"WBTX"))
 The 'tag' for a TEXT_OBJECT structure.
 
#define TEXT_BUFFER_LINE_CACHE_SIZE   32
 

Typedefs

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

Enumerations

enum  e_FileType {
  FileType_PLAIN_TEXT = 0,
  FileType_PROGRAM = 1,
  FileType_RESOURCE = 2,
  FileType_XML = 3,
  FileType_MAKEFILE = 4,
  FileType_CUSTOM_FLAG = 0x80,
  FileType_MASK = 0xff,
  FileType_HARDTAB = 0x10000,
  FileType_RESERVED2 = 0x20000,
  FileType_RESERVED3 = 0x40000,
  FileType_RESERVED4 = 0x80000
}
 file types for TEXT_OBJECT More...
 
enum  e_LineFeed {
  LineFeed_NONE = -1,
  LineFeed_DEFAULT = 0,
  LineFeed_NEWLINE = 1,
  LineFeed_RETURN = 2,
  LineFeed_CRLF = 3,
  LineFeed_LFCR = 4,
  LineFeed_ENTRYCOUNT = 5
}
 line feed (line ending) types for TEXT_OBJECT More...
 
enum  e_SelectMode {
  SelectMode_DEFAULT = 0,
  SelectMode_CHAR = 1,
  SelectMode_LINE = 2,
  SelectMode_BOX = 3
}
 select mode types for TEXT_OBJECT More...
 
enum  e_InsertMode {
  InsertMode_DEFAULT = 0,
  InsertMode_INSERT = 1,
  InsertMode_OVERWRITE = 2
}
 Insert/Overwrite mode for TEXT_OBJECT. More...
 
enum  e_DragState {
  DragState_NONE = 0,
  DragState_CURSOR = 1,
  DragState_MOUSE = 2
}
 State flags for mouse/cursor 'drag' (i.e. selection) More...
 

Functions

static __inline__ const TEXT_OBJECT_VTABLEWBGetDefaultTextObjectVTable (void)
 returns the default vtable for a TEXT_OBJECT structure More...
 
static __inline__ int WBIsValidTextObject (const TEXT_OBJECT *pObj)
 'TEXT_OBJECT' validator More...
 
static __inline__ void WBInitializeInPlaceTextObject (TEXT_OBJECT *pTextObject, Window wIDOwner)
 initialize an 'in-place' TEXT_OBJECT structure More...
 
static __inline__ void WBDestroyInPlaceTextObject (TEXT_OBJECT *pTextObject)
 Destroy a previously initialized 'in-place' TEXT_OBJECT structure. More...
 
TEXT_BUFFERWBAllocTextBuffer (const char *pBuf, unsigned int cbBufSize)
 Generic constructor for a TEXT_BUFFER using defaults. More...
 
int WBCheckReAllocTextBuffer (TEXT_BUFFER **ppBuf, int nLinesToAdd)
 Re-allocator for TEXT_BUFFER object. More...
 
void WBFreeTextBuffer (TEXT_BUFFER *pBuf)
 Re-allocator for TEXT_BUFFER object, returns ZERO on success. Pointer may be modified (or not). More...
 
int WBTextBufferLineLength (TEXT_BUFFER *pBuf, unsigned long nLine)
 Text buffer 'cached information' query function indicating a line's cached length. More...
 
void WBTextBufferLineChange (TEXT_BUFFER *pBuf, unsigned long nLine, int nNewLen)
 Text buffer 'cached information' update function indicating a change to a line's length. More...
 
void WBTextBufferRefreshCache (TEXT_BUFFER *pBuf)
 Text buffer 'cached information' refresh function. More...
 
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 More...
 
TEXT_OBJECTWBTextObjectConstructor (unsigned long cbStructSize, const char *szText, unsigned long cbLen, Window wIDOwner)
 Generic constructor for a TEXT_OBJECT using defaults. More...
 
void WBTextObjectDestructor (TEXT_OBJECT *pObj)
 Generic detructor for a TEXT_OBJECT. More...
 
int WBTextObjectCalculateLineHeight (int iAscent, int iDescent)
 Calculate the correct per-line height (in pixels) for a specified font ascent and descent. More...
 
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. More...
 
char * WBSplitMBLine (char *pString, int iCol)
 Split a multi-byte characters into a WBAlloc'd string, at a specified column, terminating the original string at that column with a zero byte. More...
 
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 original string at that column with a zero byte. More...
 
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 column. More...
 
int WBGetMBLength (const char *pString)
 Obtain the length of a multi-byte character string in 'characters' (not bytes) More...
 
char * WBGetMBCharPtr (char *pString, int iCol, int *pcbLen)
 Obtain the pointer to a specific multi-byte character within a multi-byte character string, by specifying it's column. More...
 
int WBGetMBColIndex (const char *pString, const char *pChar)
 Obtain the column index from a pointer within a multi-byte character string. More...
 

Detailed Description

A 'C++'-like object for managing text, that can be overridden for custom behavior.

X11workbench Toolkit API 'text object' for copying and drawing text, determining text extents for rendering, managing edits and undo for a block of text, and so on. In short it encapsulates the core functionality for managing a block of editable and/or viewable text.

Definition in file text_object.h.