X11 Work Bench Toolkit  1.0
text_object.c File Reference

Utilities for copying and drawing text, determining text extents, and so on. More...

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <memory.h>
#include <string.h>
#include <strings.h>
#include <errno.h>
#include <limits.h>
#include "draw_text.h"
#include "text_object.h"
#include "conf_help.h"

Go to the source code of this file.

Macros

#define UNDO_SELECT   0
 
#define UNDO_DELETE   1
 
#define UNDO_INSERT   2
 
#define UNDO_REPLACE   3 /* currently not used */
 
#define UNDO_INDENT   4
 
#define SEL_RECT_ALL(X)   ((X)->rctSel.left < 0)
 
#define SEL_RECT_EMPTY(X)   (!SEL_RECT_ALL(X) && ((X)->rctSel.left == (X)->rctSel.right && (X)->rctSel.bottom == (X)->rctSel.top))
 
#define NORMALIZE_SEL_RECT(X)
 
#define DEFAULT_TEXT_BUFFER_LINES   16384
 
#define UNDO_LIMIT   256
 
#define LOAD_COLOR(X, Y, Z)   if(CHGetResourceString(WBGetDefaultDisplay(), X, Y, sizeof(Y)) <= 0){ WB_WARN_PRINT("%s - WARNING: can't find color %s, using default value %s\n", __FUNCTION__, X, Z); strcpy(Y,Z); }
 

Functions

static void __internal_destroy (struct _text_object_ *pThis)
 
static void __internal_init (struct _text_object_ *pThis)
 
static void __internal_highlight_colors (struct _text_object_ *pThis, XColor clrHFG, XColor clrHBG)
 
static char * __internal_get_text (struct _text_object_ *pThis)
 
static void __internal_set_text (struct _text_object_ *pThis, const char *szText, unsigned long cbLen)
 
static int __internal_get_rows (const struct _text_object_ *pThis)
 
static int __internal_get_cols (struct _text_object_ *pThis)
 
static int __internal_get_filetype (const struct _text_object_ *pThis)
 
static void __internal_set_filetype (struct _text_object_ *pThis, int iFileType)
 
static int __internal_get_linefeed (const struct _text_object_ *pThis)
 
static void __internal_set_linefeed (struct _text_object_ *pThis, int iLineFeed)
 
static int __internal_get_insmode (const struct _text_object_ *pThis)
 
static void __internal_set_insmode (struct _text_object_ *pThis, int iInsMode)
 
static int __internal_get_selmode (const struct _text_object_ *pThis)
 
static void __internal_set_selmode (struct _text_object_ *pThis, int iSelMode)
 
static int __internal_get_tab (const struct _text_object_ *pThis)
 
static void __internal_set_tab (struct _text_object_ *pThis, int iTab)
 
static int __internal_get_scrollmode (const struct _text_object_ *pThis)
 
static void __internal_set_scrollmode (struct _text_object_ *pThis, int iScrollMode)
 
static void __internal_get_select (const struct _text_object_ *pThis, WB_RECT *pRct)
 
static void __internal_set_select (struct _text_object_ *pThis, const WB_RECT *pRct)
 
static int __internal_has_select (const struct _text_object_ *pThis)
 
static char * __internal_get_sel_text (const struct _text_object_ *pThis, const WB_RECT *pRct)
 
static int __internal_get_row (const struct _text_object_ *pThis)
 
static void __internal_set_row (struct _text_object_ *pThis, int iRow)
 
static int __internal_get_col (const struct _text_object_ *pThis)
 
static void __internal_set_col (struct _text_object_ *pThis, int iCol)
 
static void __internal_del_select (struct _text_object_ *pThis)
 
static void __internal_replace_select (struct _text_object_ *pThis, const char *szText, unsigned long cbLen)
 
static void __internal_del_chars (struct _text_object_ *pThis, int nChar)
 
static void __internal_ins_chars (struct _text_object_ *pThis, const char *pChar, int nChar)
 
static void __internal_indent (struct _text_object_ *pThis, int nCol)
 
static int __internal_can_undo (struct _text_object_ *pThis)
 
static void __internal_undo (struct _text_object_ *pThis)
 
static int __internal_can_redo (struct _text_object_ *pThis)
 
static void __internal_redo (struct _text_object_ *pThis)
 
static void __internal_get_view (const struct _text_object_ *pThis, WB_RECT *pRct)
 
static void __internal_set_view (struct _text_object_ *pThis, const WB_RECT *pRct)
 
static void __internal_begin_highlight (struct _text_object_ *pThis)
 
static void __internal_end_highlight (struct _text_object_ *pThis)
 
static void __internal_mouse_click (struct _text_object_ *pThis, int iMouseXDelta, int iMouseYDelta, int iType, int iACS)
 
static void __internal_begin_mouse_drag (struct _text_object_ *pThis)
 
static void __internal_end_mouse_drag (struct _text_object_ *pThis)
 
static void __internal_cursor_up (struct _text_object_ *pThis)
 
static void __internal_cursor_down (struct _text_object_ *pThis)
 
static void __internal_cursor_left (struct _text_object_ *pThis)
 
static void __internal_cursor_right (struct _text_object_ *pThis)
 
static void __internal_page_up (struct _text_object_ *pThis)
 
static void __internal_page_down (struct _text_object_ *pThis)
 
static void __internal_page_left (struct _text_object_ *pThis)
 
static void __internal_page_right (struct _text_object_ *pThis)
 
static void __internal_cursor_home (struct _text_object_ *pThis)
 
static void __internal_cursor_end (struct _text_object_ *pThis)
 
static void __internal_cursor_top (struct _text_object_ *pThis)
 
static void __internal_cursor_bottom (struct _text_object_ *pThis)
 
static void __internal_do_expose (struct _text_object_ *pThis, Display *pDisplay, Window wID, GC gc, const WB_GEOM *pPaintGeom, const WB_GEOM *pViewGeom, XFontSet rFontSet)
 
static void __internal_cursor_blink (struct _text_object_ *pThis, int bHasFocus)
 
static __inline__ const char * __internal_get_line_ending_text (enum _LineFeed_ iIndex)
 
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...
 
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...
 
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...
 
static void __internal_free_undo_redo_buffer (void *pBuffer)
 
static void __internal_add_undo (struct _text_object_ *pThis, int iOperation, int iSelMode, int iStartRow, int iStartCol, const WB_RECT *prctStartSel, const char *pStartText, int cbStartText, int iEndRow, int iEndCol, const WB_RECT *prctEndSel, const char *pEndText, int cbEndText)
 
static char * __internal_get_selected_text (const struct _text_object_ *pThis, int iRow, int iCol, int iEndRow, int iEndCol)
 
static void __internal_invalidate_cursor (const struct _text_object_ *pThis, int bPaintFlag)
 
static void __internal_invalidate_rect (const struct _text_object_ *pThis, WB_RECT *pRect, int bPaintFlag)
 
static void __internal_calc_rect (const struct _text_object_ *pThis, WB_RECT *pRect, int iStartRow, int iStartCol, int iEndRow, int iEndCol)
 
static void __internal_merge_rect (const struct _text_object_ *pThis, WB_RECT *pRect, int iStartRow, int iStartCol, int iEndRow, int iEndCol)
 
static int internal_IsMBCharValid (const char *pChar, int *piLen)
 
static int internal_MBstrlen (const char *pString)
 
static int internal_MBColIndex (const char *pString, int iCol)
 
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...
 

Variables

const TEXT_OBJECT_VTABLE WBDefaultTextObjectVTable
 

Detailed Description

Utilities for copying and drawing text, determining text extents, and so on.

X11 Work Bench Toolkit Toolkit API

Definition in file text_object.c.

Macro Definition Documentation

#define NORMALIZE_SEL_RECT (   X)
Value:
{if((X).top > (X).bottom || ((X).top == (X).bottom && (X).left > (X).right)) \
{ int i1 = (X).left; (X).left = (X).right; (X).right = i1; i1 = (X).top; (X).top = (X).bottom; (X).bottom = i1; }}

Definition at line 101 of file text_object.c.