TextP.h revision 775e7de9
17a84e134Smrg/*
27a84e134Smrg* $Xorg: TextP.h,v 1.4 2001/02/09 02:03:46 xorgcvs Exp $
37a84e134Smrg*/
47a84e134Smrg
57a84e134Smrg
67a84e134Smrg/***********************************************************
77a84e134Smrg
87a84e134SmrgCopyright 1987, 1988, 1994, 1998  The Open Group
97a84e134Smrg
107a84e134SmrgPermission to use, copy, modify, distribute, and sell this software and its
117a84e134Smrgdocumentation for any purpose is hereby granted without fee, provided that
127a84e134Smrgthe above copyright notice appear in all copies and that both that
137a84e134Smrgcopyright notice and this permission notice appear in supporting
147a84e134Smrgdocumentation.
157a84e134Smrg
167a84e134SmrgThe above copyright notice and this permission notice shall be included in
177a84e134Smrgall copies or substantial portions of the Software.
187a84e134Smrg
197a84e134SmrgTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
207a84e134SmrgIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
217a84e134SmrgFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
227a84e134SmrgOPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
237a84e134SmrgAN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
247a84e134SmrgCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
257a84e134Smrg
267a84e134SmrgExcept as contained in this notice, the name of The Open Group shall not be
277a84e134Smrgused in advertising or otherwise to promote the sale, use or other dealings
287a84e134Smrgin this Software without prior written authorization from The Open Group.
297a84e134Smrg
307a84e134Smrg
317a84e134SmrgCopyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts.
327a84e134Smrg
337a84e134Smrg                        All Rights Reserved
347a84e134Smrg
357a84e134SmrgPermission to use, copy, modify, and distribute this software and its
367a84e134Smrgdocumentation for any purpose and without fee is hereby granted,
377a84e134Smrgprovided that the above copyright notice appear in all copies and that
387a84e134Smrgboth that copyright notice and this permission notice appear in
397a84e134Smrgsupporting documentation, and that the name of Digital not be
407a84e134Smrgused in advertising or publicity pertaining to distribution of the
417a84e134Smrgsoftware without specific, written prior permission.
427a84e134Smrg
437a84e134SmrgDIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
447a84e134SmrgALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
457a84e134SmrgDIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
467a84e134SmrgANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
477a84e134SmrgWHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
487a84e134SmrgARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
497a84e134SmrgSOFTWARE.
507a84e134Smrg
517a84e134Smrg******************************************************************/
527a84e134Smrg/* $XFree86: xc/lib/Xaw/TextP.h,v 3.21 2001/12/14 19:54:44 dawes Exp $ */
537a84e134Smrg
547a84e134Smrg#ifndef _XawTextP_h
557a84e134Smrg#define _XawTextP_h
567a84e134Smrg
577a84e134Smrg#include <X11/Xfuncproto.h>
587a84e134Smrg
597a84e134Smrg#include <X11/Xaw/Text.h>
607a84e134Smrg#include <X11/Xaw/SimpleP.h>
617a84e134Smrg
627a84e134Smrg_XFUNCPROTOBEGIN
637a84e134Smrg
647a84e134Smrg#define MAXCUT	30000	/* Maximum number of characters that can be cut */
657a84e134Smrg
667a84e134Smrg#define XawTextGetLastPosition(ctx)				\
677a84e134Smrg	XawTextSourceScan((ctx)->text.source, 0,		\
687a84e134Smrg			  XawstAll, XawsdRight, 1, True)
697a84e134Smrg#define GETLASTPOS	XawTextGetLastPosition(ctx)
707a84e134Smrg
717a84e134Smrg#define zeroPosition ((XawTextPosition)0)
727a84e134Smrg
737a84e134Smrgextern XtActionsRec _XawTextActionsTable[];
747a84e134Smrgextern Cardinal _XawTextActionsTableCount;
757a84e134Smrg
76775e7de9Smrgextern char _XawDefaultTextTranslations[];
77775e7de9Smrg
787a84e134Smrg#define XawLF	  0x0a
797a84e134Smrg#define XawCR	  0x0d
807a84e134Smrg#define XawTAB	  0x09
817a84e134Smrg#define XawBS	  0x08
827a84e134Smrg#define XawSP	  0x20
837a84e134Smrg#define XawDEL	  0x7f
847a84e134Smrg#define XawESC	  0x1b
857a84e134Smrg#define XawBSLASH '\\'
867a84e134Smrg
877a84e134Smrg/* constants that subclasses may want to know */
887a84e134Smrg#define DEFAULT_TEXT_HEIGHT ((Dimension)~0)
897a84e134Smrg#define DEFAULT_TAB_SIZE	8
907a84e134Smrg
917a84e134Smrg/* displayable text management data structures */
927a84e134Smrgtypedef struct {
937a84e134Smrg    XawTextPosition position;
947a84e134Smrg    Position y;
957a84e134Smrg#ifndef OLDXAW
967a84e134Smrg    unsigned int textWidth;
977a84e134Smrg#else
987a84e134Smrg    Dimension textWidth;
997a84e134Smrg#endif
1007a84e134Smrg} XawTextLineTableEntry, *XawTextLineTableEntryPtr;
1017a84e134Smrg
1027a84e134Smrgtypedef struct {
1037a84e134Smrg    XawTextPosition left, right;
1047a84e134Smrg    XawTextSelectType type;
1057a84e134Smrg    Atom *selections;
1067a84e134Smrg    int atom_count;
1077a84e134Smrg    int array_size;
1087a84e134Smrg} XawTextSelection;
1097a84e134Smrg
1107a84e134Smrgtypedef struct _XawTextSelectionSalt {
1117a84e134Smrg    struct _XawTextSelectionSalt *next;
1127a84e134Smrg    XawTextSelection	s;
1137a84e134Smrg    /*
1147a84e134Smrg     * The element "contents" stores the CT string which is gotten in the
1157a84e134Smrg     * function _XawTextSaltAwaySelection()
1167a84e134Smrg    */
1177a84e134Smrg    char		*contents;
1187a84e134Smrg    int			length;
1197a84e134Smrg} XawTextSelectionSalt;
1207a84e134Smrg
1217a84e134Smrg#ifndef OLDXAW
1227a84e134Smrgtypedef struct _XawTextKillRing {
1237a84e134Smrg    struct _XawTextKillRing *next;
1247a84e134Smrg    char *contents;
1257a84e134Smrg    int length;
1267a84e134Smrg    unsigned refcount;
1277a84e134Smrg    unsigned long format;
1287a84e134Smrg} XawTextKillRing;
1297a84e134Smrg
1307a84e134Smrgextern XawTextKillRing *xaw_text_kill_ring;
1317a84e134Smrg#endif
1327a84e134Smrg
1337a84e134Smrg/* Line Tables are n+1 long - last position displayed is in last lt entry */
1347a84e134Smrgtypedef struct {
1357a84e134Smrg    XawTextPosition top;	 /* Top of the displayed text */
1367a84e134Smrg    int lines;			 /* How many lines in this table */
1377a84e134Smrg#ifndef OLDXAW
1387a84e134Smrg    int base_line;		 /* line number of first entry */
1397a84e134Smrg#endif
1407a84e134Smrg    XawTextLineTableEntry *info; /* A dynamic array, one entry per line  */
1417a84e134Smrg} XawTextLineTable, *XawTextLineTablePtr;
1427a84e134Smrg
1437a84e134Smrgtypedef struct _XawTextMargin {
1447a84e134Smrg    Position left, right, top, bottom;
1457a84e134Smrg} XawTextMargin;
1467a84e134Smrg
1477a84e134Smrgtypedef struct _XmuScanline XmuTextUpdate;
1487a84e134Smrg
1497a84e134Smrg#define VMargins(ctx)  ((ctx)->text.margin.top + (ctx)->text.margin.bottom)
1507a84e134Smrg#define HMargins(ctx)  ((ctx)->text.left_margin + (ctx)->text.margin.right)
1517a84e134Smrg#define RVMargins(ctx) ((ctx)->text.r_margin.top + (ctx)->text.r_margin.bottom)
1527a84e134Smrg#define RHMargins(ctx) ((ctx)->text.r_margin.left + (ctx)->text.r_margin.right)
1537a84e134Smrg
1547a84e134Smrg#define IsPositionVisible(ctx, pos) \
1557a84e134Smrg(pos >= ctx->text.lt.info[0].position && \
1567a84e134Smrg		 pos < ctx->text.lt.info[ctx->text.lt.lines].position)
1577a84e134Smrg
1587a84e134Smrg/*
1597a84e134Smrg * Search & Replace data structure
1607a84e134Smrg */
1617a84e134Smrgstruct SearchAndReplace {
1627a84e134Smrg    Boolean selection_changed;	/* flag so that the selection cannot be
1637a84e134Smrg				   changed out from underneath query-replace.*/
1647a84e134Smrg    Widget search_popup;	/* The poppup widget that allows searches.*/
1657a84e134Smrg    Widget label1;		/* The label widgets for the search window. */
1667a84e134Smrg    Widget label2;
1677a84e134Smrg    Widget left_toggle; 	/* The left search toggle radioGroup. */
1687a84e134Smrg    Widget right_toggle;	/* The right search toggle radioGroup. */
1697a84e134Smrg    Widget rep_label;		/* The Replace label string. */
1707a84e134Smrg    Widget rep_text;		/* The Replace text field. */
1717a84e134Smrg    Widget search_text; 	/* The Search text field. */
1727a84e134Smrg    Widget rep_one;		/* The Replace one button. */
1737a84e134Smrg    Widget rep_all;		/* The Replace all button. */
1747a84e134Smrg#ifndef OLDXAW
1757a84e134Smrg    Widget case_sensitive;	/* The "Case Sensitive" toggle */
1767a84e134Smrg#endif
1777a84e134Smrg};
1787a84e134Smrg
1797a84e134Smrg/* New fields for the Text widget class record */
1807a84e134Smrgtypedef struct {
1817a84e134Smrg  XtPointer extension;
1827a84e134Smrg} TextClassPart;
1837a84e134Smrg
1847a84e134Smrg/* Full class record declaration */
1857a84e134Smrgtypedef struct _TextClassRec {
1867a84e134Smrg    CoreClassPart	core_class;
1877a84e134Smrg    SimpleClassPart	simple_class;
1887a84e134Smrg    TextClassPart	text_class;
1897a84e134Smrg} TextClassRec;
1907a84e134Smrg
1917a84e134Smrgextern TextClassRec textClassRec;
1927a84e134Smrg
1937a84e134Smrg/* New fields for the Text widget record */
1947a84e134Smrgtypedef struct _TextPart {
1957a84e134Smrg    /* resources */
1967a84e134Smrg    Widget source, sink;
1977a84e134Smrg    XawTextPosition insertPos;
1987a84e134Smrg    XawTextSelection s;
1997a84e134Smrg    XawTextSelectType *sarray;		     /* Array to cycle for selections */
2007a84e134Smrg    XawTextSelectionSalt *salt;		     /* salted away selections */
2017a84e134Smrg    int left_margin;
2027a84e134Smrg    int dialog_horiz_offset, dialog_vert_offset; /* position for popup dialog */
2037a84e134Smrg    Boolean display_caret;		     /* insertion pt visible iff T */
2047a84e134Smrg    Boolean auto_fill;			     /* Auto fill mode? */
2057a84e134Smrg    XawTextScrollMode scroll_vert, scroll_horiz;
2067a84e134Smrg    XawTextWrapMode wrap;		     /* The type of wrapping */
2077a84e134Smrg    XawTextResizeMode resize;
2087a84e134Smrg    XawTextMargin r_margin;		     /* The real margins */
2097a84e134Smrg#ifndef OLDXAW
2107a84e134Smrg    XtCallbackList position_callbacks;
2117a84e134Smrg#else
2127a84e134Smrg    XtPointer pad1;
2137a84e134Smrg#endif
2147a84e134Smrg
2157a84e134Smrg    /* private state */
2167a84e134Smrg    XawTextMargin margin;		     /* The current margins */
2177a84e134Smrg    XawTextLineTable lt;
2187a84e134Smrg    XawTextScanDirection extendDir;
2197a84e134Smrg    XawTextSelection origSel;		     /* the selection being modified */
2207a84e134Smrg    Time lasttime;			     /* timestamp of last processed action */
2217a84e134Smrg    Time time;				     /* time of last key or button action */
2227a84e134Smrg    Position ev_x, ev_y;		     /* x, y coords for key or button action */
2237a84e134Smrg    Widget vbar, hbar;			     /* The scroll bars (none = NULL) */
2247a84e134Smrg    struct SearchAndReplace *search;	     /* Search and replace structure */
2257a84e134Smrg    Widget file_insert;			     /* The file insert popup widget */
2267a84e134Smrg    XmuTextUpdate *update;		     /* Position intervals to update */
2277a84e134Smrg#ifndef OLDXAW
2287a84e134Smrg    int line_number;
2297a84e134Smrg    short column_number;
2307a84e134Smrg    unsigned char kill_ring;
2317a84e134Smrg    Boolean selection_state;
2327a84e134Smrg#else
2337a84e134Smrg    XtPointer pad2;
2347a84e134Smrg    int pad3;
2357a84e134Smrg#endif
2367a84e134Smrg    int from_left;			     /* Cursor position */
2377a84e134Smrg    XawTextPosition lastPos;		     /* Last position of source */
2387a84e134Smrg    GC gc;
2397a84e134Smrg    Boolean showposition;		     /* True if we need to show the position */
2407a84e134Smrg    Boolean hasfocus;			     /* TRUE if we currently have input focus*/
2417a84e134Smrg    Boolean update_disabled;		     /* TRUE if display updating turned off */
2427a84e134Smrg    Boolean clear_to_eol;		     /* Clear to eol when painting text? */
2437a84e134Smrg    XawTextPosition old_insert;		     /* Last insertPos for batched updates */
2447a84e134Smrg    short mult;				     /* Multiplier */
2457a84e134Smrg#ifndef OLDXAW
2467a84e134Smrg    XawTextKillRing *kill_ring_ptr;
2477a84e134Smrg#else
2487a84e134Smrg    XtPointer pad4;
2497a84e134Smrg#endif
2507a84e134Smrg
2517a84e134Smrg    /* private state, shared w/Source and Sink */
2527a84e134Smrg    Boolean redisplay_needed;		     /* in SetValues */
2537a84e134Smrg    XawTextSelectionSalt *salt2;	     /* salted away selections */
2547a84e134Smrg
2557a84e134Smrg#ifndef OLDXAW
2567a84e134Smrg    char numeric;
2577a84e134Smrg    char source_changed;
2587a84e134Smrg    Boolean overwrite;                      /* Overwrite mode */
2597a84e134Smrg
2607a84e134Smrg    /* new resources and states, for text edition
2617a84e134Smrg     * Note: a fixed width font is required for these resources/states.
2627a84e134Smrg     */
2637a84e134Smrg    short left_column, right_column;
2647a84e134Smrg    XawTextJustifyMode justify;
2657a84e134Smrg    XtPointer pad[4];	/* for future use and keep binary compatability */
2667a84e134Smrg#endif
2677a84e134Smrg} TextPart;
2687a84e134Smrg
2697a84e134Smrg#define XtRWrapMode	"WrapMode"
2707a84e134Smrg#define XtRScrollMode	"ScrollMode"
2717a84e134Smrg#define XtRResizeMode	"ResizeMode"
2727a84e134Smrg#define XtRJustifyMode	"JustifyMode"
2737a84e134Smrg
2747a84e134Smrg/* full instance record */
2757a84e134Smrgtypedef struct _TextRec {
2767a84e134Smrg    CorePart	core;
2777a84e134Smrg    SimplePart	simple;
2787a84e134Smrg    TextPart	text;
2797a84e134Smrg} TextRec;
2807a84e134Smrg
2817a84e134Smrg/*
2827a84e134Smrg * Semi-private functions
2837a84e134Smrg * for use by other Xaw modules only
2847a84e134Smrg */
2857a84e134Smrgvoid _XawTextBuildLineTable
2867a84e134Smrg(
2877a84e134Smrg TextWidget		ctx,
2887a84e134Smrg XawTextPosition	top_pos,
2897a84e134Smrg _XtBoolean		force_rebuild
2907a84e134Smrg );
2917a84e134Smrg
2927a84e134Smrgchar *_XawTextGetSTRING
2937a84e134Smrg(
2947a84e134Smrg TextWidget		ctx,
2957a84e134Smrg XawTextPosition	left,
2967a84e134Smrg XawTextPosition	right
2977a84e134Smrg );
2987a84e134Smrg
2997a84e134Smrgvoid _XawTextSaltAwaySelection
3007a84e134Smrg(
3017a84e134Smrg TextWidget		ctx,
3027a84e134Smrg Atom			*selections,
3037a84e134Smrg int			num_atoms
3047a84e134Smrg );
3057a84e134Smrg
3067a84e134Smrgvoid _XawTextPosToXY
3077a84e134Smrg(
3087a84e134Smrg Widget			w,
3097a84e134Smrg XawTextPosition	pos,
3107a84e134Smrg Position		*x,
3117a84e134Smrg Position		*y
3127a84e134Smrg );
3137a84e134Smrg
3147a84e134Smrgvoid _XawTextNeedsUpdating
3157a84e134Smrg(
3167a84e134Smrg TextWidget		ctx,
3177a84e134Smrg XawTextPosition	left,
3187a84e134Smrg XawTextPosition	right
3197a84e134Smrg );
3207a84e134Smrg
3217a84e134Smrg_XFUNCPROTOEND
3227a84e134Smrg
3237a84e134Smrg#endif /* _XawTextP_h */
324