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