TextP.h revision 775e7de9
1/* 2* $Xorg: TextP.h,v 1.4 2001/02/09 02:03:46 xorgcvs Exp $ 3*/ 4 5 6/*********************************************************** 7 8Copyright 1987, 1988, 1994, 1998 The Open Group 9 10Permission to use, copy, modify, distribute, and sell this software and its 11documentation for any purpose is hereby granted without fee, provided that 12the above copyright notice appear in all copies and that both that 13copyright notice and this permission notice appear in supporting 14documentation. 15 16The above copyright notice and this permission notice shall be included in 17all copies or substantial portions of the Software. 18 19THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 23AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 24CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 25 26Except as contained in this notice, the name of The Open Group shall not be 27used in advertising or otherwise to promote the sale, use or other dealings 28in this Software without prior written authorization from The Open Group. 29 30 31Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts. 32 33 All Rights Reserved 34 35Permission to use, copy, modify, and distribute this software and its 36documentation for any purpose and without fee is hereby granted, 37provided that the above copyright notice appear in all copies and that 38both that copyright notice and this permission notice appear in 39supporting documentation, and that the name of Digital not be 40used in advertising or publicity pertaining to distribution of the 41software without specific, written prior permission. 42 43DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING 44ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL 45DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR 46ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, 47WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 48ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS 49SOFTWARE. 50 51******************************************************************/ 52/* $XFree86: xc/lib/Xaw/TextP.h,v 3.21 2001/12/14 19:54:44 dawes Exp $ */ 53 54#ifndef _XawTextP_h 55#define _XawTextP_h 56 57#include <X11/Xfuncproto.h> 58 59#include <X11/Xaw/Text.h> 60#include <X11/Xaw/SimpleP.h> 61 62_XFUNCPROTOBEGIN 63 64#define MAXCUT 30000 /* Maximum number of characters that can be cut */ 65 66#define XawTextGetLastPosition(ctx) \ 67 XawTextSourceScan((ctx)->text.source, 0, \ 68 XawstAll, XawsdRight, 1, True) 69#define GETLASTPOS XawTextGetLastPosition(ctx) 70 71#define zeroPosition ((XawTextPosition)0) 72 73extern XtActionsRec _XawTextActionsTable[]; 74extern Cardinal _XawTextActionsTableCount; 75 76extern char _XawDefaultTextTranslations[]; 77 78#define XawLF 0x0a 79#define XawCR 0x0d 80#define XawTAB 0x09 81#define XawBS 0x08 82#define XawSP 0x20 83#define XawDEL 0x7f 84#define XawESC 0x1b 85#define XawBSLASH '\\' 86 87/* constants that subclasses may want to know */ 88#define DEFAULT_TEXT_HEIGHT ((Dimension)~0) 89#define DEFAULT_TAB_SIZE 8 90 91/* displayable text management data structures */ 92typedef struct { 93 XawTextPosition position; 94 Position y; 95#ifndef OLDXAW 96 unsigned int textWidth; 97#else 98 Dimension textWidth; 99#endif 100} XawTextLineTableEntry, *XawTextLineTableEntryPtr; 101 102typedef struct { 103 XawTextPosition left, right; 104 XawTextSelectType type; 105 Atom *selections; 106 int atom_count; 107 int array_size; 108} XawTextSelection; 109 110typedef struct _XawTextSelectionSalt { 111 struct _XawTextSelectionSalt *next; 112 XawTextSelection s; 113 /* 114 * The element "contents" stores the CT string which is gotten in the 115 * function _XawTextSaltAwaySelection() 116 */ 117 char *contents; 118 int length; 119} XawTextSelectionSalt; 120 121#ifndef OLDXAW 122typedef struct _XawTextKillRing { 123 struct _XawTextKillRing *next; 124 char *contents; 125 int length; 126 unsigned refcount; 127 unsigned long format; 128} XawTextKillRing; 129 130extern XawTextKillRing *xaw_text_kill_ring; 131#endif 132 133/* Line Tables are n+1 long - last position displayed is in last lt entry */ 134typedef struct { 135 XawTextPosition top; /* Top of the displayed text */ 136 int lines; /* How many lines in this table */ 137#ifndef OLDXAW 138 int base_line; /* line number of first entry */ 139#endif 140 XawTextLineTableEntry *info; /* A dynamic array, one entry per line */ 141} XawTextLineTable, *XawTextLineTablePtr; 142 143typedef struct _XawTextMargin { 144 Position left, right, top, bottom; 145} XawTextMargin; 146 147typedef struct _XmuScanline XmuTextUpdate; 148 149#define VMargins(ctx) ((ctx)->text.margin.top + (ctx)->text.margin.bottom) 150#define HMargins(ctx) ((ctx)->text.left_margin + (ctx)->text.margin.right) 151#define RVMargins(ctx) ((ctx)->text.r_margin.top + (ctx)->text.r_margin.bottom) 152#define RHMargins(ctx) ((ctx)->text.r_margin.left + (ctx)->text.r_margin.right) 153 154#define IsPositionVisible(ctx, pos) \ 155(pos >= ctx->text.lt.info[0].position && \ 156 pos < ctx->text.lt.info[ctx->text.lt.lines].position) 157 158/* 159 * Search & Replace data structure 160 */ 161struct SearchAndReplace { 162 Boolean selection_changed; /* flag so that the selection cannot be 163 changed out from underneath query-replace.*/ 164 Widget search_popup; /* The poppup widget that allows searches.*/ 165 Widget label1; /* The label widgets for the search window. */ 166 Widget label2; 167 Widget left_toggle; /* The left search toggle radioGroup. */ 168 Widget right_toggle; /* The right search toggle radioGroup. */ 169 Widget rep_label; /* The Replace label string. */ 170 Widget rep_text; /* The Replace text field. */ 171 Widget search_text; /* The Search text field. */ 172 Widget rep_one; /* The Replace one button. */ 173 Widget rep_all; /* The Replace all button. */ 174#ifndef OLDXAW 175 Widget case_sensitive; /* The "Case Sensitive" toggle */ 176#endif 177}; 178 179/* New fields for the Text widget class record */ 180typedef struct { 181 XtPointer extension; 182} TextClassPart; 183 184/* Full class record declaration */ 185typedef struct _TextClassRec { 186 CoreClassPart core_class; 187 SimpleClassPart simple_class; 188 TextClassPart text_class; 189} TextClassRec; 190 191extern TextClassRec textClassRec; 192 193/* New fields for the Text widget record */ 194typedef struct _TextPart { 195 /* resources */ 196 Widget source, sink; 197 XawTextPosition insertPos; 198 XawTextSelection s; 199 XawTextSelectType *sarray; /* Array to cycle for selections */ 200 XawTextSelectionSalt *salt; /* salted away selections */ 201 int left_margin; 202 int dialog_horiz_offset, dialog_vert_offset; /* position for popup dialog */ 203 Boolean display_caret; /* insertion pt visible iff T */ 204 Boolean auto_fill; /* Auto fill mode? */ 205 XawTextScrollMode scroll_vert, scroll_horiz; 206 XawTextWrapMode wrap; /* The type of wrapping */ 207 XawTextResizeMode resize; 208 XawTextMargin r_margin; /* The real margins */ 209#ifndef OLDXAW 210 XtCallbackList position_callbacks; 211#else 212 XtPointer pad1; 213#endif 214 215 /* private state */ 216 XawTextMargin margin; /* The current margins */ 217 XawTextLineTable lt; 218 XawTextScanDirection extendDir; 219 XawTextSelection origSel; /* the selection being modified */ 220 Time lasttime; /* timestamp of last processed action */ 221 Time time; /* time of last key or button action */ 222 Position ev_x, ev_y; /* x, y coords for key or button action */ 223 Widget vbar, hbar; /* The scroll bars (none = NULL) */ 224 struct SearchAndReplace *search; /* Search and replace structure */ 225 Widget file_insert; /* The file insert popup widget */ 226 XmuTextUpdate *update; /* Position intervals to update */ 227#ifndef OLDXAW 228 int line_number; 229 short column_number; 230 unsigned char kill_ring; 231 Boolean selection_state; 232#else 233 XtPointer pad2; 234 int pad3; 235#endif 236 int from_left; /* Cursor position */ 237 XawTextPosition lastPos; /* Last position of source */ 238 GC gc; 239 Boolean showposition; /* True if we need to show the position */ 240 Boolean hasfocus; /* TRUE if we currently have input focus*/ 241 Boolean update_disabled; /* TRUE if display updating turned off */ 242 Boolean clear_to_eol; /* Clear to eol when painting text? */ 243 XawTextPosition old_insert; /* Last insertPos for batched updates */ 244 short mult; /* Multiplier */ 245#ifndef OLDXAW 246 XawTextKillRing *kill_ring_ptr; 247#else 248 XtPointer pad4; 249#endif 250 251 /* private state, shared w/Source and Sink */ 252 Boolean redisplay_needed; /* in SetValues */ 253 XawTextSelectionSalt *salt2; /* salted away selections */ 254 255#ifndef OLDXAW 256 char numeric; 257 char source_changed; 258 Boolean overwrite; /* Overwrite mode */ 259 260 /* new resources and states, for text edition 261 * Note: a fixed width font is required for these resources/states. 262 */ 263 short left_column, right_column; 264 XawTextJustifyMode justify; 265 XtPointer pad[4]; /* for future use and keep binary compatability */ 266#endif 267} TextPart; 268 269#define XtRWrapMode "WrapMode" 270#define XtRScrollMode "ScrollMode" 271#define XtRResizeMode "ResizeMode" 272#define XtRJustifyMode "JustifyMode" 273 274/* full instance record */ 275typedef struct _TextRec { 276 CorePart core; 277 SimplePart simple; 278 TextPart text; 279} TextRec; 280 281/* 282 * Semi-private functions 283 * for use by other Xaw modules only 284 */ 285void _XawTextBuildLineTable 286( 287 TextWidget ctx, 288 XawTextPosition top_pos, 289 _XtBoolean force_rebuild 290 ); 291 292char *_XawTextGetSTRING 293( 294 TextWidget ctx, 295 XawTextPosition left, 296 XawTextPosition right 297 ); 298 299void _XawTextSaltAwaySelection 300( 301 TextWidget ctx, 302 Atom *selections, 303 int num_atoms 304 ); 305 306void _XawTextPosToXY 307( 308 Widget w, 309 XawTextPosition pos, 310 Position *x, 311 Position *y 312 ); 313 314void _XawTextNeedsUpdating 315( 316 TextWidget ctx, 317 XawTextPosition left, 318 XawTextPosition right 319 ); 320 321_XFUNCPROTOEND 322 323#endif /* _XawTextP_h */ 324