1 /***********************************************************
3 Copyright 1987, 1988, 1994, 1998 The Open Group
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
11 The above copyright notice and this permission notice shall be included in
12 all copies or substantial portions of the Software.
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.
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.
26 Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts.
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.
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
46 ******************************************************************/
51 #include <X11/Xfuncproto.h>
53 #include <X11/Xaw/Text.h>
54 #include <X11/Xaw/SimpleP.h>
58 #define MAXCUT 30000 /* Maximum number of characters that can be cut */
60 #define XawTextGetLastPosition(ctx) \
61 XawTextSourceScan((ctx)->text.source, 0, \
62 XawstAll, XawsdRight, 1, True)
63 #define GETLASTPOS XawTextGetLastPosition(ctx)
65 #define zeroPosition ((XawTextPosition)0)
67 extern XtActionsRec _XawTextActionsTable[];
68 extern Cardinal _XawTextActionsTableCount;
70 extern char _XawDefaultTextTranslations[];
79 #define XawBSLASH '\\'
81 /* constants that subclasses may want to know */
82 #define DEFAULT_TEXT_HEIGHT ((Dimension)~0)
83 #define DEFAULT_TAB_SIZE 8
85 /* displayable text management data structures */
87 XawTextPosition position;
90 unsigned int textWidth;
94 } XawTextLineTableEntry, *XawTextLineTableEntryPtr;
97 XawTextPosition left, right;
98 XawTextSelectType type;
104 typedef struct _XawTextSelectionSalt {
105 struct _XawTextSelectionSalt *next;
108 * The element "contents" stores the CT string which is gotten in the
109 * function _XawTextSaltAwaySelection()
113 } XawTextSelectionSalt;
116 typedef struct _XawTextKillRing {
117 struct _XawTextKillRing *next;
121 unsigned long format;
124 extern XawTextKillRing *xaw_text_kill_ring;
127 /* Line Tables are n+1 long - last position displayed is in last lt entry */
129 XawTextPosition top; /* Top of the displayed text */
130 int lines; /* How many lines in this table */
132 int base_line; /* line number of first entry */
134 XawTextLineTableEntry *info; /* A dynamic array, one entry per line */
135 } XawTextLineTable, *XawTextLineTablePtr;
137 typedef struct _XawTextMargin {
138 Position left, right, top, bottom;
141 typedef struct _XmuScanline XmuTextUpdate;
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)
148 #define IsPositionVisible(ctx, pos) \
149 (pos >= ctx->text.lt.info[0].position && \
150 pos < ctx->text.lt.info[ctx->text.lt.lines].position)
153 * Search & Replace data structure
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 poppup widget that allows searches.*/
159 Widget label1; /* The label widgets for the search window. */
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. */
169 Widget case_sensitive; /* The "Case Sensitive" toggle */
173 /* New fields for the Text widget class record */
178 /* Full class record declaration */
179 typedef struct _TextClassRec {
180 CoreClassPart core_class;
181 SimpleClassPart simple_class;
182 TextClassPart text_class;
185 extern TextClassRec textClassRec;
187 /* New fields for the Text widget record */
188 typedef struct _TextPart {
191 XawTextPosition insertPos;
193 XawTextSelectType *sarray; /* Array to cycle for selections */
194 XawTextSelectionSalt *salt; /* salted away selections */
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 */
204 XtCallbackList position_callbacks;
210 XawTextMargin margin; /* The current margins */
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 */
224 unsigned char kill_ring;
225 Boolean selection_state;
230 int from_left; /* Cursor position */
231 XawTextPosition lastPos; /* Last position of source */
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 */
240 XawTextKillRing *kill_ring_ptr;
245 /* private state, shared w/Source and Sink */
246 Boolean redisplay_needed; /* in SetValues */
247 XawTextSelectionSalt *salt2; /* salted away selections */
252 Boolean overwrite; /* Overwrite mode */
254 /* new resources and states, for text edition
255 * Note: a fixed width font is required for these resources/states.
257 short left_column, right_column;
258 XawTextJustifyMode justify;
259 XtPointer pad[4]; /* for future use and keep binary compatability */
263 #define XtRWrapMode "WrapMode"
264 #define XtRScrollMode "ScrollMode"
265 #define XtRResizeMode "ResizeMode"
266 #define XtRJustifyMode "JustifyMode"
268 /* full instance record */
269 typedef struct _TextRec {
276 * Semi-private functions
277 * for use by other Xaw modules only
279 void _XawTextBuildLineTable
282 XawTextPosition top_pos,
283 _XtBoolean force_rebuild
286 char *_XawTextGetSTRING
289 XawTextPosition left,
290 XawTextPosition right
293 void _XawTextSaltAwaySelection
308 void _XawTextNeedsUpdating
311 XawTextPosition left,
312 XawTextPosition right
317 #endif /* _XawTextP_h */