X11workbench Toolkit  1.0
text_object.h
Go to the documentation of this file.
1 // //
3 // _ _ _ _ _ _ //
4 // | |_ ___ __ __| |_ ___ | |__ (_) ___ ___ | |_ | |__ //
5 // | __|/ _ \\ \/ /| __| / _ \ | '_ \ | | / _ \ / __|| __| | '_ \ //
6 // | |_| __/ > < | |_ | (_) || |_) || || __/| (__ | |_ _ | | | | //
7 // \__|\___|/_/\_\ \__|_____\___/ |_.__/_/ | \___| \___| \__|(_)|_| |_| //
8 // |_____| |__/ //
9 // //
10 // //
12 
13 /*****************************************************************************
14 
15  X11workbench - X11 programmer's 'work bench' application and toolkit
16  Copyright (c) 2010-2019 by Bob Frazier (aka 'Big Bad Bombastic Bob')
17 
18 
19  DISCLAIMER: The X11workbench application and toolkit software are supplied
20  'as-is', with no warranties, either implied or explicit.
21  Any claims to alleged functionality or features should be
22  considered 'preliminary', and might not function as advertised.
23 
24  MIT-like license:
25 
26  There is no restriction as to what you can do with this software, so long
27  as you include the above copyright notice and DISCLAIMER for any distributed
28  work that is equal to or derived from this one, along with this paragraph
29  that explains the terms of the license if the source is also being made
30  available. A "derived work" describes a work that uses a significant portion
31  of the source files or algorithms that are included with this one.
32  Specifically excluded from this are files that were generated by the software,
33  or anything that is included with the software that is part of another package
34  (such as files that were created or added during the 'configure' process).
35  Specifically included is the use of part or all of any of the X11 workbench
36  toolkit source or header files in your distributed application. If you do not
37  ship the source, the above copyright statement is still required to be placed
38  in a reasonably prominent place, such as documentation, splash screens, and/or
39  'about the application' dialog boxes.
40 
41  Use and distribution are in accordance with GPL, LGPL, and/or the above
42  MIT-like license. See COPYING and README files for more information.
43 
44 
45  Additional information at http://sourceforge.net/projects/X11workbench
46 
47 ******************************************************************************/
48 
49 
92 #ifndef _TEXT_OBJECT_H_INCLUDED_
93 #define _TEXT_OBJECT_H_INCLUDED_
94 
95 #include "window_helper.h"
96 
97 #ifdef __cplusplus
98 extern "C" {
99 #endif // __cplusplus
100 
101 
102 // FILE TYPE CONSTANTS
103 
111 {
117 
119 
120  FileType_MASK = 0xff,
121 
122  // additional bits are reserved (for now)
123 
124  // and now the bit flags
125  FileType_HARDTAB = 0x10000,
126  FileType_RESERVED2 = 0x20000,
127  FileType_RESERVED3 = 0x40000,
129 };
130 
137 {
145 };
146 
153 {
158 };
159 
166 {
170 };
171 
179 {
183 };
184 
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
207 
208 //struct s_text_object; // forward declaration
209 typedef struct s_text_object TEXT_OBJECT; // forward declaration
210 
215 {
220  void (* destroy)(TEXT_OBJECT *pThis);
221 
226  void (* init)(TEXT_OBJECT *pThis);
227 
234  void (* highlight_colors)(TEXT_OBJECT *pThis, XColor clrHFG, XColor clrHBG);
235 
243  char * (* get_text)(TEXT_OBJECT *pThis);
244 
256  void (* set_text)(TEXT_OBJECT *pThis, const char *szText, unsigned long cbLen);
257 
268  int (* get_rows)(const TEXT_OBJECT *pThis);
269 
282  int (* get_cols)(TEXT_OBJECT *pThis);
283 
291  int (* get_filetype)(const TEXT_OBJECT *pThis);
292 
301  void (* set_filetype)(TEXT_OBJECT *pThis, int iLineFeed);
302 
309  int (* get_linefeed)(const TEXT_OBJECT *pThis);
310 
318  void (* set_linefeed)(TEXT_OBJECT *pThis, int iLineFeed);
319 
324  int (* get_insmode)(const TEXT_OBJECT *pThis);
325 
331  void (* set_insmode)(TEXT_OBJECT *pThis, int iInsMode);
332 
337  int (* get_selmode)(const TEXT_OBJECT *pThis);
338 
344  void (* set_selmode)(TEXT_OBJECT *pThis, int iSelMode);
345 
356  int (* get_tab)(const TEXT_OBJECT *pThis);
357 
369  void (* set_tab)(TEXT_OBJECT *pThis, int iTab);
370 
375  int (* get_scrollmode)(const TEXT_OBJECT *pThis);
376 
382  void (* set_scrollmode)(TEXT_OBJECT *pThis, int iScrollMode);
383 
389  void (* get_select)(const TEXT_OBJECT *pThis, WB_RECT *pRct);
390 
396  void (* set_select)(TEXT_OBJECT *pThis, const WB_RECT *pRct);
397 
402  int (* has_select)(const TEXT_OBJECT *pThis);
403 
416  char* (* get_sel_text)(const TEXT_OBJECT *pThis, const WB_RECT *pRct);
417 
422  int (* get_row)(const TEXT_OBJECT *pThis);
423 
429  void (* set_row)(TEXT_OBJECT *pThis, int iRow);
430 
435  int (* get_col)(const TEXT_OBJECT *pThis);
436 
446  void (* set_col)(TEXT_OBJECT *pThis, int iCol);
447 
452  void (* del_select)(TEXT_OBJECT *pThis);
453 
460  void (* replace_select)(TEXT_OBJECT *pThis, const char *szText, unsigned long cbLen);
461 
467  void (* del_chars)(TEXT_OBJECT *pThis, int nChar); // delete 1 or more chars, negative deletes BEFORE cursor, 0 does nothing
468 
483  void (* ins_chars)(TEXT_OBJECT *pThis, const char *pChar, int nChar);
484 
493  void (* indent)(TEXT_OBJECT *pThis, int nCol);
494 
499  int (* can_undo)(TEXT_OBJECT *pThis);
500 
505  void (* undo)(TEXT_OBJECT *pThis);
506 
511  int (* can_redo)(TEXT_OBJECT *pThis);
512 
517  void (* redo)(TEXT_OBJECT *pThis);
518 
527  void (* get_view)(const TEXT_OBJECT *pThis, WB_RECT *pRct);
539  void (* set_view_orig)(TEXT_OBJECT *pThis, const WB_POINT *pOrig);
540 
552  void (* begin_highlight)(TEXT_OBJECT *pThis);
562  void (* end_highlight)(TEXT_OBJECT *pThis);
563 
564  // mouse conversion
565 
580  void (* mouse_click)(TEXT_OBJECT *pThis, int iMouseXDelta, int iMouseYDelta, int iType, int iACS);
581 
590  void (* begin_mouse_drag)(TEXT_OBJECT *pThis);
598  void (* end_mouse_drag)(TEXT_OBJECT *pThis);
599 
600  // cursor motion
601 
605  void (* cursor_up)(TEXT_OBJECT *pThis);
606 
610  void (* cursor_down)(TEXT_OBJECT *pThis);
611 
615  void (* cursor_left)(TEXT_OBJECT *pThis);
616 
620  void (* cursor_right)(TEXT_OBJECT *pThis);
621 
625  void (* page_up)(TEXT_OBJECT *pThis);
626 
630  void (* page_down)(TEXT_OBJECT *pThis);
631 
635  void (* page_left)(TEXT_OBJECT *pThis);
636 
640  void (* page_right)(TEXT_OBJECT *pThis);
641 
645  void (* cursor_home)(TEXT_OBJECT *pThis);
646 
650  void (* cursor_end)(TEXT_OBJECT *pThis);
651 
655  void (* cursor_top)(TEXT_OBJECT *pThis);
656 
660  void (* cursor_bottom)(TEXT_OBJECT *pThis);
661 
666  void (* scroll_vertical)(TEXT_OBJECT *pThis, int nRows);
667 
672  void (* scroll_horizontal)(TEXT_OBJECT *pThis, int nCols);
673 
674 
675  // handling expose events for the text area
676 
710  void (* do_expose)(TEXT_OBJECT *pThis, Display *pDisplay, Window wID,
711  WBGC gc, const WB_GEOM *pPaintGeom, const WB_GEOM *pViewGeom,
712  WB_FONTC pFont);
713 
722  void (* cursor_blink)(TEXT_OBJECT *pThis, int bHasFocus);
723 
736  void (* set_save_point)(TEXT_OBJECT *pThis);
737 
751  int (* get_modified)(TEXT_OBJECT *pThis);
752 
753 
754 };
755 
867 
868 
869 
876 static __inline__ const TEXT_OBJECT_VTABLE *WBGetDefaultTextObjectVTable(void)
877 {
878 extern const TEXT_OBJECT_VTABLE WBDefaultTextObjectVTable;
879 
880  return &WBDefaultTextObjectVTable;
881 }
882 
883 
887 #define TEXT_OBJECT_TAG (*((const unsigned int *)"WBTX"))
888 
889 
894 {
896 
897  unsigned int ulTag;
898  Window wIDOwner;
901 
902  XColor clrHFG;
903  XColor clrHBG;
904 
905  int iFileType;
907  int iInsMode;
908  int iSelMode;
910  int iTab;
911 
912  // cursor position
913  int iRow;
914  int iCol;
915  int iPos;
916 
917  int iCursorX;
918  int iCursorY;
920 
923 
924  int iAsc;
925  int iDesc;
928 
929  // viewport
930 
933 
934  // these are maintained internally - do not use
937 
938  // the data
939 
940  void *pText;
941 
942  void *pUndo;
943  void *pRedo;
944 
945  // special callback entries
947  unsigned long (*pColorContextCallback)(TEXT_OBJECT *,
948  int, int);
949 };
950 
1019 typedef struct s_text_object TEXT_OBJECT;
1020 
1028 static __inline__ int WBIsValidTextObject(const TEXT_OBJECT *pObj)
1029 {
1030  return pObj && pObj->ulTag == TEXT_OBJECT_TAG;
1031 }
1032 
1045 static __inline__ void WBInitializeInPlaceTextObject(TEXT_OBJECT *pTextObject, Window wIDOwner)
1046 {
1047  if(pTextObject)
1048  {
1049  bzero(pTextObject, sizeof(*pTextObject)); // most contained things will accept 'nulling' as "unassigned"
1050 
1051  pTextObject->vtable = WBGetDefaultTextObjectVTable();
1052  pTextObject->vtable->init(pTextObject);
1053 
1054  pTextObject->wIDOwner = wIDOwner;
1055  }
1056 }
1057 
1070 static __inline__ void WBDestroyInPlaceTextObject(TEXT_OBJECT *pTextObject)
1071 {
1072  if(pTextObject &&
1073  WBIsValidTextObject(pTextObject) &&
1074  pTextObject->vtable &&
1075  pTextObject->vtable->destroy)
1076  {
1077  pTextObject->vtable->destroy(pTextObject);
1078  }
1079 }
1080 
1081 #define TEXT_BUFFER_LINE_CACHE_SIZE 32
1082 
1088 {
1089  unsigned long nArraySize;
1090  unsigned long nEntries;
1091 
1092  // cached information
1093  unsigned int nMaxCol;
1094  unsigned int nMinMaxCol;
1095  unsigned long aLineCache[TEXT_BUFFER_LINE_CACHE_SIZE];
1097  unsigned int aLineCacheLen[TEXT_BUFFER_LINE_CACHE_SIZE];
1099 
1100  char * aLines[2];
1101 
1102 };
1103 
1140 
1141 
1151 TEXT_BUFFER * WBAllocTextBuffer(const char *pBuf, unsigned int cbBufSize);
1152 
1162 int WBCheckReAllocTextBuffer(TEXT_BUFFER **ppBuf, int nLinesToAdd);
1163 
1172 void WBFreeTextBuffer(TEXT_BUFFER *pBuf);
1173 
1187 int WBTextBufferLineLength(TEXT_BUFFER *pBuf, unsigned long nLine);
1188 
1204 void WBTextBufferLineChange(TEXT_BUFFER *pBuf, unsigned long nLine, int nNewLen);
1205 
1222 
1259  unsigned long (*callback)(TEXT_OBJECT *pThis, int nRow, int nCol),
1260  void *pColorContextPointer);
1261 
1262 
1277 TEXT_OBJECT *WBTextObjectConstructor(unsigned long cbStructSize, const char *szText, unsigned long cbLen, Window wIDOwner);
1278 
1279 
1291 
1292 
1307 int WBTextObjectCalculateLineHeight(int iAscent, int iDescent);
1308 
1309 
1310 
1311 // MBCS-related utilities
1312 
1342 char * WBInsertMBChars(char *pString, int iCol, const char *pszMBString, int cbString,
1343  int fTab, int fOverwrite, int *piNewCol, char **ppInserted);
1344 
1345 
1360 char * WBSplitMBLine(char *pString, int iCol);
1361 
1362 
1378 char * WBJoinMBLine(char *pString, int iCol, const char *pJoin);
1379 
1380 
1405 int WBDelMBChars(char *pString, int iCol, int nDel, int *piNewCol, char **ppDeleted);
1406 
1407 
1416 int WBGetMBLength(const char *pString);
1417 
1418 
1429 char * WBGetMBCharPtr(char *pString, int iCol, int *pcbLen);
1430 
1440 int WBGetMBColIndex(const char *pString, const char *pChar);
1441 
1442 
1443 #ifdef __cplusplus
1444 };
1445 #endif // __cplusplus
1446 
1447 #endif // _TEXT_OBJECT_H_INCLUDED_
1448 
1449 
no drag in progress
Definition: text_object.h:180
'base class' structure for TEXT_OBJECT
Definition: text_object.h:1087
e_DragState
State flags for mouse/cursor 'drag' (i.e. selection)
Definition: text_object.h:178
WB_RECT rctWinViewOld
previous viewport, in window coordinates [for invalidating window efficiently]
Definition: text_object.h:936
void(* begin_mouse_drag)(TEXT_OBJECT *pThis)
Begin a mouse 'drag' operation.
Definition: text_object.h:590
int WBGetMBColIndex(const char *pString, const char *pChar)
Obtain the column index from a pointer within a multi-byte character string.
Definition: text_object.c:7026
char * WBGetMBCharPtr(char *pString, int iCol, int *pcbLen)
Obtain the pointer to a specific multi-byte character within a multi-byte character string,...
Definition: text_object.c:6994
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)
Definition: text_object.h:710
'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.
Definition: text_object.c:826
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.
Definition: text_object.h:625
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...
Definition: text_object.h:580
void(* destroy)(TEXT_OBJECT *pThis)
Call this prior to de-allocating memory to free up any internal objects or storage.
Definition: text_object.h:220
int iMaxFontWidth
maximum width of font in pixels (mostly for proportional pitch) - cached by 'expose' handler
Definition: text_object.h:927
int iFontWidth
average width of font in pixels (mostly for fixed pitch) - cached by 'expose' handler
Definition: text_object.h:926
int iFileType
file type - -1=Makefile, 0=plain text, others are 'file type' constants, bit flags to preserve hard t...
Definition: text_object.h:905
void WBTextBufferLineChange(TEXT_BUFFER *pBuf, unsigned long nLine, int nNewLen)
Text buffer 'cached information' update function indicating a change to a line's length.
Definition: text_object.c:516
int(* get_insmode)(const TEXT_OBJECT *pThis)
Get the current insert mode for the object.
Definition: text_object.h:324
OVERWRITE mode, character inserted on top of character to the right of the cursor (if any),...
Definition: text_object.h:169
int iScrollMode
scroll mode - 0=normal, 1='scroll lock'
Definition: text_object.h:909
char * aLines[2]
array of 'lines'. each pointer is suballocated via WBAlloc()
Definition: text_object.h:1100
BOX (selects a 'box' using virtual spacing)
Definition: text_object.h:157
void(* set_insmode)(TEXT_OBJECT *pThis, int iInsMode)
Set the current insert mode for the object.
Definition: text_object.h:331
void(* del_select)(TEXT_OBJECT *pThis)
Delete the current selection assigned via 'set_select'.
Definition: text_object.h:452
void(* redo)(TEXT_OBJECT *pThis)
Perform a single 'redo' operation.
Definition: text_object.h:517
void(* set_text)(TEXT_OBJECT *pThis, const char *szText, unsigned long cbLen)
Call this function to re-assign all text in the control.
Definition: text_object.h:256
char * WBSplitMBLine(char *pString, int iCol)
Split a multi-byte characters into a WBAlloc'd string, at a specified column, terminating the origina...
Definition: text_object.c:6746
WB_RECT rctHighLight
highlight rect {0,0,0,0} implies NONE
Definition: text_object.h:900
e_FileType
file types for TEXT_OBJECT
Definition: text_object.h:110
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...
Definition: text_object.h:527
static __inline__ void WBInitializeInPlaceTextObject(TEXT_OBJECT *pTextObject, Window wIDOwner)
initialize an 'in-place' TEXT_OBJECT structure
Definition: text_object.h:1045
OSX return 0DH.
Definition: text_object.h:141
POSIX newline 0AH.
Definition: text_object.h:140
void(* set_select)(TEXT_OBJECT *pThis, const WB_RECT *pRct)
Set the current selection rectangle as WB_RECT.
Definition: text_object.h:396
int(* can_redo)(TEXT_OBJECT *pThis)
Indicate whether a 'redo' operation is possible (mostly for menu UI)
Definition: text_object.h:511
int(* get_col)(const TEXT_OBJECT *pThis)
Get the current column cursor for the object.
Definition: text_object.h:435
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 ...
Definition: text_object.c:6820
int iCursorX
X position of cursor as last drawn in expose event.
Definition: text_object.h:917
unsigned int aLineCacheLen[TEXT_BUFFER_LINE_CACHE_SIZE]
The actual line lengths associated with 'aLineCache' (zero if unused)
Definition: text_object.h:1097
void(* set_filetype)(TEXT_OBJECT *pThis, int iLineFeed)
Set the current file type for the object.
Definition: text_object.h:301
int WBGetMBLength(const char *pString)
Obtain the length of a multi-byte character string in 'characters' (not bytes)
Definition: text_object.c:6984
int(* get_linefeed)(const TEXT_OBJECT *pThis)
Get the current linefeed type for the object.
Definition: text_object.h:309
a bitmask for the various file types. Perform a logical 'and' of the file type value with this,...
Definition: text_object.h:120
unsigned long(* pColorContextCallback)(TEXT_OBJECT *, int, int)
callback function to get the context color of a character. default is NULL.
Definition: text_object.h:947
mouse 'drag' (select mode)
Definition: text_object.h:182
WB_RECT rctSel
select boundary in characters, {0,0,0,0} implies NONE, {-1,x,x,x} implies ALL. if top == bottom,...
Definition: text_object.h:899
int WBTextObjectCalculateLineHeight(int iAscent, int iDescent)
Calculate the correct per-line height (in pixels) for a specified font ascent and descent.
Definition: text_object.c:864
void(* end_highlight)(TEXT_OBJECT *pThis)
End a highlight block.
Definition: text_object.h:562
internal wrapper struct for X11 'geometry' definition
void(* undo)(TEXT_OBJECT *pThis)
Perform a single 'undo' operation.
Definition: text_object.h:505
int iInsMode
insert mode - 0=overwrite, 1=insert
Definition: text_object.h:907
int iSelMode
selection mode - 0=normal, 1=line, 2=box
Definition: text_object.h:908
unsigned long nArraySize
allocated size of aLines array
Definition: text_object.h:1089
int WBCheckReAllocTextBuffer(TEXT_BUFFER **ppBuf, int nLinesToAdd)
Re-allocator for TEXT_BUFFER object.
Definition: text_object.c:436
void(* get_select)(const TEXT_OBJECT *pThis, WB_RECT *pRct)
Get the current selection rectangle as WB_RECT.
Definition: text_object.h:389
system default, usually 'insert'
Definition: text_object.h:167
void(* page_right)(TEXT_OBJECT *pThis)
Move the current cursor position right one page.
Definition: text_object.h:640
void(* page_down)(TEXT_OBJECT *pThis)
Move the current cursor position down one page.
Definition: text_object.h:630
void(* set_tab)(TEXT_OBJECT *pThis, int iTab)
Set the current tab type for the object.
Definition: text_object.h:369
LINE (always selects entire line when spanning multiple lines)
Definition: text_object.h:156
int(* get_rows)(const TEXT_OBJECT *pThis)
Call this function to obtain the total number of rows for display purposes.
Definition: text_object.h:268
void(* set_save_point)(TEXT_OBJECT *pThis)
Set the 'save point' with respect to the undo/redo buffer.
Definition: text_object.h:736
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...
Definition: text_object.c:6783
void(* set_col)(TEXT_OBJECT *pThis, int iCol)
Set the current column cursor for the object.
Definition: text_object.h:446
WB_RECT rctViewOld
previous viewport [for invalidating window efficiently]
Definition: text_object.h:935
unsigned int nMinMaxCol
The 'smallest maximum' recorded in 'aLineCache'.
Definition: text_object.h:1094
'base class' structure for TEXT_OBJECT
Definition: text_object.h:893
void * pText
pointer to (abstracted) object containing the text. void pointer allows abstraction....
Definition: text_object.h:940
CRLF 0DH,0AH.
Definition: text_object.h:142
int iCol
current col (cursor)
Definition: text_object.h:914
'custom' file types - 'or' with custom definition (0-0x7f)
Definition: text_object.h:118
program source
Definition: text_object.h:113
void(* cursor_home)(TEXT_OBJECT *pThis)
Move the cursor 'home' (left or BOL)
Definition: text_object.h:645
int iCursorHeight
height of cursor as last drawn in expose event (always 1 if 'overwrite' cursor)
Definition: text_object.h:919
int iPos
position within buffer (reserved, MBCS may require it)
Definition: text_object.h:915
reserved - specifies custom array, indicating the size of the array containing the character values,...
Definition: text_object.h:144
int iCursorY
Y position of cursor as last drawn in expose event (top of cursor)
Definition: text_object.h:918
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.
Definition: text_object.c:6726
void(* cursor_right)(TEXT_OBJECT *pThis)
Move the current cursor position right one column.
Definition: text_object.h:620
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...
Definition: text_object.h:539
void * pUndo
pointer to 'undo' buffer. NULL if empty.
Definition: text_object.h:942
void * pRedo
pointer to 'redo' buffer. NULL if empty.
Definition: text_object.h:943
int(* get_row)(const TEXT_OBJECT *pThis)
Get the current row cursor for the object.
Definition: text_object.h:422
'resource' file, text-based format
Definition: text_object.h:114
void(* cursor_up)(TEXT_OBJECT *pThis)
Move the current cursor position up one line.
Definition: text_object.h:605
int(* has_select)(const TEXT_OBJECT *pThis)
Returns a non-zero value if there is currently a 'selection'.
Definition: text_object.h:402
void WBTextObjectDestructor(TEXT_OBJECT *pObj)
Generic detructor for a TEXT_OBJECT.
Definition: text_object.c:848
unsigned int nMaxCol
The maximum column number for any line, rounded up by 'DEFAULT_TAB_WIDTH'.
Definition: text_object.h:1093
int(* can_undo)(TEXT_OBJECT *pThis)
Indicate whether an 'undo' operation is possible (mostly for menu UI)
Definition: text_object.h:499
void(* replace_select)(TEXT_OBJECT *pThis, const char *szText, unsigned long cbLen)
Replace the current selection assigned via 'set_select' with new text.
Definition: text_object.h:460
int(* get_modified)(TEXT_OBJECT *pThis)
Set the 'save point' with respect to the undo/redo buffer.
Definition: text_object.h:751
XColor clrHFG
highlight FG color
Definition: text_object.h:902
e_InsertMode
Insert/Overwrite mode for TEXT_OBJECT.
Definition: text_object.h:165
void(* set_linefeed)(TEXT_OBJECT *pThis, int iLineFeed)
Set the current linefeed type for the object.
Definition: text_object.h:318
int iBlinkState
cursor blink state
Definition: text_object.h:921
INSERT mode, character inserted at cursor.
Definition: text_object.h:168
WB_RECT rctView
viewport, in characters (rctView.top is the top visible line, always)
Definition: text_object.h:931
unsigned long nEntries
number of entries currently in the array - call WBCheckReAllocTextBuffer() before increasing
Definition: text_object.h:1090
const TEXT_OBJECT_VTABLE * vtable
method function pointers (similar to C++ virtual member functions)
Definition: text_object.h:895
void(* set_scrollmode)(TEXT_OBJECT *pThis, int iScrollMode)
Set the current scroll mode for the object.
Definition: text_object.h:382
e_LineFeed
line feed (line ending) types for TEXT_OBJECT
Definition: text_object.h:136
void(* scroll_vertical)(TEXT_OBJECT *pThis, int nRows)
Scroll the viewport up/down by the specified number of rows.
Definition: text_object.h:666
unsigned long aLineCache[TEXT_BUFFER_LINE_CACHE_SIZE]
An array of line indices, sorted longest to least, for the 'longest lines'.
Definition: text_object.h:1095
int WBTextBufferLineLength(TEXT_BUFFER *pBuf, unsigned long nLine)
Text buffer 'cached information' query function indicating a line's cached length.
Definition: text_object.c:494
int(* get_tab)(const TEXT_OBJECT *pThis)
Get the current tab type for the object.
Definition: text_object.h:356
void(* del_chars)(TEXT_OBJECT *pThis, int nChar)
Delete 'n' characters from the current cursor. Negative deletes BEFORE the cursor....
Definition: text_object.h:467
CHAR (i.e. stream)
Definition: text_object.h:155
e_SelectMode
select mode types for TEXT_OBJECT
Definition: text_object.h:152
void(* end_mouse_drag)(TEXT_OBJECT *pThis)
End a mouse 'drag' operation.
Definition: text_object.h:598
no special handling, no source decorations
Definition: text_object.h:112
void(* init)(TEXT_OBJECT *pThis)
Call this to initialize or re-initialize an object. Must call 'destroy' first for an existing object.
Definition: text_object.h:226
XColor clrHBG
highlight BG color
Definition: text_object.h:903
internal wrapper struct for 'rectangle' definition
void(* set_row)(TEXT_OBJECT *pThis, int iRow)
Set the current row cursor for the object.
Definition: text_object.h:429
XML data (includes HTML)
Definition: text_object.h:115
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.
Definition: text_object.h:234
int(* get_scrollmode)(const TEXT_OBJECT *pThis)
Get the current scroll mode for the object.
Definition: text_object.h:375
void(* cursor_end)(TEXT_OBJECT *pThis)
Move the cursor to 'end' (full doc width or EOL)
Definition: text_object.h:650
void(* cursor_bottom)(TEXT_OBJECT *pThis)
Move the cursor to the last line.
Definition: text_object.h:660
WB_RECT rctWinView
viewport, in window coordinates, or 'empty' if unknown
Definition: text_object.h:932
void(* ins_chars)(TEXT_OBJECT *pThis, const char *pChar, int nChar)
Insert 'n' characters (including new lines) from the current cursor.
Definition: text_object.h:483
void * pColorContext
a user-controlled 'color context' pointer - can be anything, however
Definition: text_object.h:946
int(* get_selmode)(const TEXT_OBJECT *pThis)
Get the current selection mode for the object.
Definition: text_object.h:337
void(* indent)(TEXT_OBJECT *pThis, int nCol)
Indent selected text by 'n' columns.
Definition: text_object.h:493
void(* cursor_left)(TEXT_OBJECT *pThis)
Move the current cursor position left one column.
Definition: text_object.h:615
void WBFreeTextBuffer(TEXT_BUFFER *pBuf)
Re-allocator for TEXT_BUFFER object, returns ZERO on success. Pointer may be modified (or not).
Definition: text_object.c:471
static __inline__ int WBIsValidTextObject(const TEXT_OBJECT *pObj)
'TEXT_OBJECT' validator
Definition: text_object.h:1028
Window wIDOwner
owner window (cached from paint/expose handling and/or cursor blink)
Definition: text_object.h:898
void(* set_selmode)(TEXT_OBJECT *pThis, int iSelMode)
Set the current selection mode for the object.
Definition: text_object.h:344
static __inline__ const TEXT_OBJECT_VTABLE * WBGetDefaultTextObjectVTable(void)
returns the default vtable for a TEXT_OBJECT structure
Definition: text_object.h:876
int iAsc
font height ascension
Definition: text_object.h:924
DEFAULT (typically CHAR)
Definition: text_object.h:154
default for OS
Definition: text_object.h:139
LFCR 0AH,0DH.
Definition: text_object.h:143
enum e_LineFeed iLineFeed
linefeed type (see enum). LineFeed_NONE implies SINGLE LINE
Definition: text_object.h:906
An allocated structure containing XFontStruct, XFontInfo, and XftFont [as applicable] for a specified...
Definition: font_helper.h:152
void(* page_left)(TEXT_OBJECT *pThis)
Move the current cursor position left one page.
Definition: text_object.h:635
void(* cursor_blink)(TEXT_OBJECT *pThis, int bHasFocus)
Periodic callback to 'blink' the cursor.
Definition: text_object.h:722
int iTab
tab width in characters (0 = system default)
Definition: text_object.h:910
Make Files with special handling (implies 'hard tab', always)
Definition: text_object.h:116
#define TEXT_OBJECT_TAG
The 'tag' for a TEXT_OBJECT structure.
Definition: text_object.h:887
internal wrapper struct for 'point' definition
single line
Definition: text_object.h:138
internal wrapper struct for GC with local cache
static __inline__ void WBDestroyInPlaceTextObject(TEXT_OBJECT *pTextObject)
Destroy a previously initialized 'in-place' TEXT_OBJECT structure.
Definition: text_object.h:1070
int iDesc
font height descension
Definition: text_object.h:925
void(* begin_highlight)(TEXT_OBJECT *pThis)
Begin a highlight block.
Definition: text_object.h:552
'vtable' structure for TEXT_OBJECT
Definition: text_object.h:214
int iDragState
if '1' bit is set, cursor drag. if '2' bit is set, mouse drag
Definition: text_object.h:922
int(* get_cols)(TEXT_OBJECT *pThis)
Call this function to obtain the estimated column extent of the document.
Definition: text_object.h:282
void(* cursor_top)(TEXT_OBJECT *pThis)
Move the cursor to the top line.
Definition: text_object.h:655
int(* get_filetype)(const TEXT_OBJECT *pThis)
Get the current linefeed type for the object.
Definition: text_object.h:291
unsigned int ulTag
tag word, always assigned to TEXT_OBJECT_TAG
Definition: text_object.h:897
hard tabs - implied by 'FileType_MAKEFILE', otherwise explicit
Definition: text_object.h:125
int iRow
current row (cursor)
Definition: text_object.h:913
void(* cursor_down)(TEXT_OBJECT *pThis)
Move the current cursor position down one line.
Definition: text_object.h:610
cursor 'drag' (select mode)
Definition: text_object.h:181
void WBTextBufferRefreshCache(TEXT_BUFFER *pBuf)
Text buffer 'cached information' refresh function.
Definition: text_object.c:691
void(* scroll_horizontal)(TEXT_OBJECT *pThis, int nCols)
Scroll the cursor to the right/left a specified number of columns.
Definition: text_object.h:672
TEXT_BUFFER * WBAllocTextBuffer(const char *pBuf, unsigned int cbBufSize)
Generic constructor for a TEXT_BUFFER using defaults.
Definition: text_object.c:320