OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [insight/] [tk/] [generic/] [tkText.h] - Blame information for rev 1778

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 578 markom
/*
2
 * tkText.h --
3
 *
4
 *      Declarations shared among the files that implement text
5
 *      widgets.
6
 *
7
 * Copyright (c) 1992-1994 The Regents of the University of California.
8
 * Copyright (c) 1994-1995 Sun Microsystems, Inc.
9
 *
10
 * See the file "license.terms" for information on usage and redistribution
11
 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
12
 *
13
 * RCS: @(#) $Id: tkText.h,v 1.1.1.1 2002-01-16 10:25:53 markom Exp $
14
 */
15
 
16
#ifndef _TKTEXT
17
#define _TKTEXT
18
 
19
#ifndef _TK
20
#include "tk.h"
21
#endif
22
 
23
/*
24
 * Opaque types for structures whose guts are only needed by a single
25
 * file:
26
 */
27
 
28
typedef struct TkTextBTree *TkTextBTree;
29
 
30
/*
31
 * The data structure below defines a single line of text (from newline
32
 * to newline, not necessarily what appears on one line of the screen).
33
 */
34
 
35
typedef struct TkTextLine {
36
    struct Node *parentPtr;             /* Pointer to parent node containing
37
                                         * line. */
38
    struct TkTextLine *nextPtr;         /* Next in linked list of lines with
39
                                         * same parent node in B-tree.  NULL
40
                                         * means end of list. */
41
    struct TkTextSegment *segPtr;       /* First in ordered list of segments
42
                                         * that make up the line. */
43
} TkTextLine;
44
 
45
/*
46
 * -----------------------------------------------------------------------
47
 * Segments: each line is divided into one or more segments, where each
48
 * segment is one of several things, such as a group of characters, a
49
 * tag toggle, a mark, or an embedded widget.  Each segment starts with
50
 * a standard header followed by a body that varies from type to type.
51
 * -----------------------------------------------------------------------
52
 */
53
 
54
/*
55
 * The data structure below defines the body of a segment that represents
56
 * a tag toggle.  There is one of these structures at both the beginning
57
 * and end of each tagged range.
58
 */
59
 
60
typedef struct TkTextToggle {
61
    struct TkTextTag *tagPtr;           /* Tag that starts or ends here. */
62
    int inNodeCounts;                   /* 1 means this toggle has been
63
                                         * accounted for in node toggle
64
                                         * counts; 0 means it hasn't, yet. */
65
} TkTextToggle;
66
 
67
/*
68
 * The data structure below defines line segments that represent
69
 * marks.  There is one of these for each mark in the text.
70
 */
71
 
72
typedef struct TkTextMark {
73
    struct TkText *textPtr;             /* Overall information about text
74
                                         * widget. */
75
    TkTextLine *linePtr;                /* Line structure that contains the
76
                                         * segment. */
77
    Tcl_HashEntry *hPtr;                /* Pointer to hash table entry for mark
78
                                         * (in textPtr->markTable). */
79
} TkTextMark;
80
 
81
/*
82
 * A structure of the following type holds information for each window
83
 * embedded in a text widget.  This information is only used by the
84
 * file tkTextWind.c
85
 */
86
 
87
typedef struct TkTextEmbWindow {
88
    struct TkText *textPtr;             /* Information about the overall text
89
                                         * widget. */
90
    TkTextLine *linePtr;                /* Line structure that contains this
91
                                         * window. */
92
    Tk_Window tkwin;                    /* Window for this segment.  NULL
93
                                         * means that the window hasn't
94
                                         * been created yet. */
95
    char *create;                       /* Script to create window on-demand.
96
                                         * NULL means no such script.
97
                                         * Malloc-ed. */
98
    int align;                          /* How to align window in vertical
99
                                         * space.  See definitions in
100
                                         * tkTextWind.c. */
101
    int padX, padY;                     /* Padding to leave around each side
102
                                         * of window, in pixels. */
103
    int stretch;                        /* Should window stretch to fill
104
                                         * vertical space of line (except for
105
                                         * pady)?  0 or 1. */
106
    int chunkCount;                     /* Number of display chunks that
107
                                         * refer to this window. */
108
    int displayed;                      /* Non-zero means that the window
109
                                         * has been displayed on the screen
110
                                         * recently. */
111
} TkTextEmbWindow;
112
 
113
/*
114
 * A structure of the following type holds information for each image
115
 * embedded in a text widget.  This information is only used by the
116
 * file tkTextImage.c
117
 */
118
 
119
typedef struct TkTextEmbImage {
120
    struct TkText *textPtr;             /* Information about the overall text
121
                                         * widget. */
122
    TkTextLine *linePtr;                /* Line structure that contains this
123
                                         * image. */
124
    char *imageString;                  /* Name of the image for this segment */
125
    char *imageName;                    /* Name used by text widget to identify
126
                                         * this image.  May be unique-ified */
127
    char *name;                         /* Name used in the hash table.
128
                                         * used by "image names" to identify
129
                                         * this instance of the image */
130
    Tk_Image image;                     /* Image for this segment.  NULL
131
                                         * means that the image hasn't
132
                                         * been created yet. */
133
    int align;                          /* How to align image in vertical
134
                                         * space.  See definitions in
135
                                         * tkTextImage.c. */
136
    int padX, padY;                     /* Padding to leave around each side
137
                                         * of image, in pixels. */
138
    int chunkCount;                     /* Number of display chunks that
139
                                         * refer to this image. */
140
} TkTextEmbImage;
141
 
142
/*
143
 * The data structure below defines line segments.
144
 */
145
 
146
typedef struct TkTextSegment {
147
    struct Tk_SegType *typePtr;         /* Pointer to record describing
148
                                         * segment's type. */
149
    struct TkTextSegment *nextPtr;      /* Next in list of segments for this
150
                                         * line, or NULL for end of list. */
151
    int size;                           /* Size of this segment (# of bytes
152
                                         * of index space it occupies). */
153
    union {
154
        char chars[4];                  /* Characters that make up character
155
                                         * info.  Actual length varies to
156
                                         * hold as many characters as needed.*/
157
        TkTextToggle toggle;            /* Information about tag toggle. */
158
        TkTextMark mark;                /* Information about mark. */
159
        TkTextEmbWindow ew;             /* Information about embedded
160
                                         * window. */
161
        TkTextEmbImage ei;              /* Information about embedded
162
                                         * image. */
163
    } body;
164
} TkTextSegment;
165
 
166
/*
167
 * Data structures of the type defined below are used during the
168
 * execution of Tcl commands to keep track of various interesting
169
 * places in a text.  An index is only valid up until the next
170
 * modification to the character structure of the b-tree so they
171
 * can't be retained across Tcl commands.  However, mods to marks
172
 * or tags don't invalidate indices.
173
 */
174
 
175
typedef struct TkTextIndex {
176
    TkTextBTree tree;                   /* Tree containing desired position. */
177
    TkTextLine *linePtr;                /* Pointer to line containing position
178
                                         * of interest. */
179
    int charIndex;                      /* Index within line of desired
180
                                         * character (0 means first one). */
181
} TkTextIndex;
182
 
183
/*
184
 * Types for procedure pointers stored in TkTextDispChunk strutures:
185
 */
186
 
187
typedef struct TkTextDispChunk TkTextDispChunk;
188
 
189
typedef void            Tk_ChunkDisplayProc _ANSI_ARGS_((
190
                            TkTextDispChunk *chunkPtr, int x, int y,
191
                            int height, int baseline, Display *display,
192
                            Drawable dst, int screenY));
193
typedef void            Tk_ChunkUndisplayProc _ANSI_ARGS_((
194
                            struct TkText *textPtr,
195
                            TkTextDispChunk *chunkPtr));
196
typedef int             Tk_ChunkMeasureProc _ANSI_ARGS_((
197
                            TkTextDispChunk *chunkPtr, int x));
198
typedef void            Tk_ChunkBboxProc _ANSI_ARGS_((
199
                            TkTextDispChunk *chunkPtr, int index, int y,
200
                            int lineHeight, int baseline, int *xPtr,
201
                            int *yPtr, int *widthPtr, int *heightPtr));
202
 
203
/*
204
 * The structure below represents a chunk of stuff that is displayed
205
 * together on the screen.  This structure is allocated and freed by
206
 * generic display code but most of its fields are filled in by
207
 * segment-type-specific code.
208
 */
209
 
210
struct TkTextDispChunk {
211
    /*
212
     * The fields below are set by the type-independent code before
213
     * calling the segment-type-specific layoutProc.  They should not
214
     * be modified by segment-type-specific code.
215
     */
216
 
217
    int x;                              /* X position of chunk, in pixels.
218
                                         * This position is measured from the
219
                                         * left edge of the logical line,
220
                                         * not from the left edge of the
221
                                         * window (i.e. it doesn't change
222
                                         * under horizontal scrolling). */
223
    struct TkTextDispChunk *nextPtr;    /* Next chunk in the display line
224
                                         * or NULL for the end of the list. */
225
    struct TextStyle *stylePtr;         /* Display information, known only
226
                                         * to tkTextDisp.c. */
227
 
228
    /*
229
     * The fields below are set by the layoutProc that creates the
230
     * chunk.
231
     */
232
 
233
    Tk_ChunkDisplayProc *displayProc;   /* Procedure to invoke to draw this
234
                                         * chunk on the display or an
235
                                         * off-screen pixmap. */
236
    Tk_ChunkUndisplayProc *undisplayProc;
237
                                        /* Procedure to invoke when segment
238
                                         * ceases to be displayed on screen
239
                                         * anymore. */
240
    Tk_ChunkMeasureProc *measureProc;   /* Procedure to find character under
241
                                         * a given x-location. */
242
    Tk_ChunkBboxProc *bboxProc;         /* Procedure to find bounding box
243
                                         * of character in chunk. */
244
    int numChars;                       /* Number of characters that will be
245
                                         * displayed in the chunk. */
246
    int minAscent;                      /* Minimum space above the baseline
247
                                         * needed by this chunk. */
248
    int minDescent;                     /* Minimum space below the baseline
249
                                         * needed by this chunk. */
250
    int minHeight;                      /* Minimum total line height needed
251
                                         * by this chunk. */
252
    int width;                          /* Width of this chunk, in pixels.
253
                                         * Initially set by chunk-specific
254
                                         * code, but may be increased to
255
                                         * include tab or extra space at end
256
                                         * of line. */
257
    int breakIndex;                     /* Index within chunk of last
258
                                         * acceptable position for a line
259
                                         * (break just before this character).
260
                                         * <= 0 means don't break during or
261
                                         * immediately after this chunk. */
262
    ClientData clientData;              /* Additional information for use
263
                                         * of displayProc and undisplayProc. */
264
};
265
 
266
/*
267
 * One data structure of the following type is used for each tag in a
268
 * text widget.  These structures are kept in textPtr->tagTable and
269
 * referred to in other structures.
270
 */
271
 
272
typedef struct TkTextTag {
273
    char *name;                 /* Name of this tag.  This field is actually
274
                                 * a pointer to the key from the entry in
275
                                 * textPtr->tagTable, so it needn't be freed
276
                                 * explicitly. */
277
    int priority;               /* Priority of this tag within widget.  0
278
                                 * means lowest priority.  Exactly one tag
279
                                 * has each integer value between 0 and
280
                                 * numTags-1. */
281
    struct Node *tagRootPtr;    /* Pointer into the B-Tree at the lowest
282
                                 * node that completely dominates the ranges
283
                                 * of text occupied by the tag.  At this
284
                                 * node there is no information about the
285
                                 * tag.  One or more children of the node
286
                                 * do contain information about the tag. */
287
    int toggleCount;            /* Total number of tag toggles */
288
 
289
    /*
290
     * Information for displaying text with this tag.  The information
291
     * belows acts as an override on information specified by lower-priority
292
     * tags.  If no value is specified, then the next-lower-priority tag
293
     * on the text determins the value.  The text widget itself provides
294
     * defaults if no tag specifies an override.
295
     */
296
 
297
    Tk_3DBorder border;         /* Used for drawing background.  NULL means
298
                                 * no value specified here. */
299
    char *bdString;             /* -borderwidth option string (malloc-ed).
300
                                 * NULL means option not specified. */
301
    int borderWidth;            /* Width of 3-D border for background. */
302
    char *reliefString;         /* -relief option string (malloc-ed).
303
                                 * NULL means option not specified. */
304
    int relief;                 /* 3-D relief for background. */
305
    Pixmap bgStipple;           /* Stipple bitmap for background.  None
306
                                 * means no value specified here. */
307
    XColor *fgColor;            /* Foreground color for text.  NULL means
308
                                 * no value specified here. */
309
    Tk_Font tkfont;             /* Font for displaying text.  NULL means
310
                                 * no value specified here. */
311
    Pixmap fgStipple;           /* Stipple bitmap for text and other
312
                                 * foreground stuff.   None means no value
313
                                 * specified here.*/
314
    char *justifyString;        /* -justify option string (malloc-ed).
315
                                 * NULL means option not specified. */
316
    Tk_Justify justify;         /* How to justify text: TK_JUSTIFY_LEFT,
317
                                 * TK_JUSTIFY_RIGHT, or TK_JUSTIFY_CENTER.
318
                                 * Only valid if justifyString is non-NULL. */
319
    char *lMargin1String;       /* -lmargin1 option string (malloc-ed).
320
                                 * NULL means option not specified. */
321
    int lMargin1;               /* Left margin for first display line of
322
                                 * each text line, in pixels.  Only valid
323
                                 * if lMargin1String is non-NULL. */
324
    char *lMargin2String;       /* -lmargin2 option string (malloc-ed).
325
                                 * NULL means option not specified. */
326
    int lMargin2;               /* Left margin for second and later display
327
                                 * lines of each text line, in pixels.  Only
328
                                 * valid if lMargin2String is non-NULL. */
329
    char *offsetString;         /* -offset option string (malloc-ed).
330
                                 * NULL means option not specified. */
331
    int offset;                 /* Vertical offset of text's baseline from
332
                                 * baseline of line.  Used for superscripts
333
                                 * and subscripts.  Only valid if
334
                                 * offsetString is non-NULL. */
335
    char *overstrikeString;     /* -overstrike option string (malloc-ed).
336
                                 * NULL means option not specified. */
337
    int overstrike;             /* Non-zero means draw horizontal line through
338
                                 * middle of text.  Only valid if
339
                                 * overstrikeString is non-NULL. */
340
    char *rMarginString;        /* -rmargin option string (malloc-ed).
341
                                 * NULL means option not specified. */
342
    int rMargin;                /* Right margin for text, in pixels.  Only
343
                                 * valid if rMarginString is non-NULL. */
344
    char *spacing1String;       /* -spacing1 option string (malloc-ed).
345
                                 * NULL means option not specified. */
346
    int spacing1;               /* Extra spacing above first display
347
                                 * line for text line.  Only valid if
348
                                 * spacing1String is non-NULL. */
349
    char *spacing2String;       /* -spacing2 option string (malloc-ed).
350
                                 * NULL means option not specified. */
351
    int spacing2;               /* Extra spacing between display
352
                                 * lines for the same text line.  Only valid
353
                                 * if spacing2String is non-NULL. */
354
    char *spacing3String;       /* -spacing2 option string (malloc-ed).
355
                                 * NULL means option not specified. */
356
    int spacing3;               /* Extra spacing below last display
357
                                 * line for text line.  Only valid if
358
                                 * spacing3String is non-NULL. */
359
    char *tabString;            /* -tabs option string (malloc-ed).
360
                                 * NULL means option not specified. */
361
    struct TkTextTabArray *tabArrayPtr;
362
                                /* Info about tabs for tag (malloc-ed)
363
                                 * or NULL.  Corresponds to tabString. */
364
    char *underlineString;      /* -underline option string (malloc-ed).
365
                                 * NULL means option not specified. */
366
    int underline;              /* Non-zero means draw underline underneath
367
                                 * text.  Only valid if underlineString is
368
                                 * non-NULL. */
369
    Tk_Uid wrapMode;            /* How to handle wrap-around for this tag.
370
                                 * Must be tkTextCharUid, tkTextNoneUid,
371
                                 * tkTextWordUid, or NULL to use wrapMode
372
                                 * for whole widget. */
373
    int affectsDisplay;         /* Non-zero means that this tag affects the
374
                                 * way information is displayed on the screen
375
                                 * (so need to redisplay if tag changes). */
376
} TkTextTag;
377
 
378
#define TK_TAG_AFFECTS_DISPLAY  0x1
379
#define TK_TAG_UNDERLINE        0x2
380
#define TK_TAG_JUSTIFY          0x4
381
#define TK_TAG_OFFSET           0x10
382
 
383
/*
384
 * The data structure below is used for searching a B-tree for transitions
385
 * on a single tag (or for all tag transitions).  No code outside of
386
 * tkTextBTree.c should ever modify any of the fields in these structures,
387
 * but it's OK to use them for read-only information.
388
 */
389
 
390
typedef struct TkTextSearch {
391
    TkTextIndex curIndex;               /* Position of last tag transition
392
                                         * returned by TkBTreeNextTag, or
393
                                         * index of start of segment
394
                                         * containing starting position for
395
                                         * search if TkBTreeNextTag hasn't
396
                                         * been called yet, or same as
397
                                         * stopIndex if search is over. */
398
    TkTextSegment *segPtr;              /* Actual tag segment returned by last
399
                                         * call to TkBTreeNextTag, or NULL if
400
                                         * TkBTreeNextTag hasn't returned
401
                                         * anything yet. */
402
    TkTextSegment *nextPtr;             /* Where to resume search in next
403
                                         * call to TkBTreeNextTag. */
404
    TkTextSegment *lastPtr;             /* Stop search before just before
405
                                         * considering this segment. */
406
    TkTextTag *tagPtr;                  /* Tag to search for (or tag found, if
407
                                         * allTags is non-zero). */
408
    int linesLeft;                      /* Lines left to search (including
409
                                         * curIndex and stopIndex).  When
410
                                         * this becomes <= 0 the search is
411
                                         * over. */
412
    int allTags;                        /* Non-zero means ignore tag check:
413
                                         * search for transitions on all
414
                                         * tags. */
415
} TkTextSearch;
416
 
417
/*
418
 * The following data structure describes a single tab stop.
419
 */
420
 
421
typedef enum {LEFT, RIGHT, CENTER, NUMERIC} TkTextTabAlign;
422
 
423
typedef struct TkTextTab {
424
    int location;                       /* Offset in pixels of this tab stop
425
                                         * from the left margin (lmargin2) of
426
                                         * the text. */
427
    TkTextTabAlign alignment;           /* Where the tab stop appears relative
428
                                         * to the text. */
429
} TkTextTab;
430
 
431
typedef struct TkTextTabArray {
432
    int numTabs;                        /* Number of tab stops. */
433
    TkTextTab tabs[1];                  /* Array of tabs.  The actual size
434
                                         * will be numTabs.  THIS FIELD MUST
435
                                         * BE THE LAST IN THE STRUCTURE. */
436
} TkTextTabArray;
437
 
438
/*
439
 * A data structure of the following type is kept for each text widget that
440
 * currently exists for this process:
441
 */
442
 
443
typedef struct TkText {
444
    Tk_Window tkwin;            /* Window that embodies the text.  NULL
445
                                 * means that the window has been destroyed
446
                                 * but the data structures haven't yet been
447
                                 * cleaned up.*/
448
    Display *display;           /* Display for widget.  Needed, among other
449
                                 * things, to allow resources to be freed
450
                                 * even after tkwin has gone away. */
451
    Tcl_Interp *interp;         /* Interpreter associated with widget.  Used
452
                                 * to delete widget command.  */
453
    Tcl_Command widgetCmd;      /* Token for text's widget command. */
454
    TkTextBTree tree;           /* B-tree representation of text and tags for
455
                                 * widget. */
456
    Tcl_HashTable tagTable;     /* Hash table that maps from tag names to
457
                                 * pointers to TkTextTag structures. */
458
    int numTags;                /* Number of tags currently defined for
459
                                 * widget;  needed to keep track of
460
                                 * priorities. */
461
    Tcl_HashTable markTable;    /* Hash table that maps from mark names to
462
                                 * pointers to mark segments. */
463
    Tcl_HashTable windowTable;  /* Hash table that maps from window names
464
                                 * to pointers to window segments.  If a
465
                                 * window segment doesn't yet have an
466
                                 * associated window, there is no entry for
467
                                 * it here. */
468
    Tcl_HashTable imageTable;   /* Hash table that maps from image names
469
                                 * to pointers to image segments.  If an
470
                                 * image segment doesn't yet have an
471
                                 * associated image, there is no entry for
472
                                 * it here. */
473
    Tk_Uid state;               /* Normal or disabled.  Text is read-only
474
                                 * when disabled. */
475
 
476
    /*
477
     * Default information for displaying (may be overridden by tags
478
     * applied to ranges of characters).
479
     */
480
 
481
    Tk_3DBorder border;         /* Structure used to draw 3-D border and
482
                                 * default background. */
483
    int borderWidth;            /* Width of 3-D border to draw around entire
484
                                 * widget. */
485
    int padX, padY;             /* Padding between text and window border. */
486
    int relief;                 /* 3-d effect for border around entire
487
                                 * widget: TK_RELIEF_RAISED etc. */
488
    int highlightWidth;         /* Width in pixels of highlight to draw
489
                                 * around widget when it has the focus.
490
                                 * <= 0 means don't draw a highlight. */
491
    XColor *highlightBgColorPtr;
492
                                /* Color for drawing traversal highlight
493
                                 * area when highlight is off. */
494
    XColor *highlightColorPtr;  /* Color for drawing traversal highlight. */
495
    Tk_Cursor cursor;           /* Current cursor for window, or None. */
496
    XColor *fgColor;            /* Default foreground color for text. */
497
    Tk_Font tkfont;             /* Default font for displaying text. */
498
    int charWidth;              /* Width of average character in default
499
                                 * font. */
500
    int spacing1;               /* Default extra spacing above first display
501
                                 * line for each text line. */
502
    int spacing2;               /* Default extra spacing between display lines
503
                                 * for the same text line. */
504
    int spacing3;               /* Default extra spacing below last display
505
                                 * line for each text line. */
506
    char *tabOptionString;      /* Value of -tabs option string (malloc'ed). */
507
    TkTextTabArray *tabArrayPtr;
508
                                /* Information about tab stops (malloc'ed).
509
                                 * NULL means perform default tabbing
510
                                 * behavior. */
511
 
512
    int tabsize;                /* "-tabs" reconize only fixed placed tabs, but
513
                                 * we need to have the behavior of a normal plain
514
                                 * text editor (default is 8)
515
                                 */
516
 
517
    /*
518
     * Additional information used for displaying:
519
     */
520
 
521
    Tk_Uid wrapMode;            /* How to handle wrap-around.  Must be
522
                                 * tkTextCharUid, tkTextNoneUid, or
523
                                 * tkTextWordUid. */
524
    int width, height;          /* Desired dimensions for window, measured
525
                                 * in characters. */
526
    int setGrid;                /* Non-zero means pass gridding information
527
                                 * to window manager. */
528
    int prevWidth, prevHeight;  /* Last known dimensions of window;  used to
529
                                 * detect changes in size. */
530
    TkTextIndex topIndex;       /* Identifies first character in top display
531
                                 * line of window. */
532
    struct TextDInfo *dInfoPtr; /* Information maintained by tkTextDisp.c. */
533
 
534
    /*
535
     * Information related to selection.
536
     */
537
 
538
    TkTextTag *selTagPtr;       /* Pointer to "sel" tag.  Used to tell when
539
                                 * a new selection has been made. */
540
    Tk_3DBorder selBorder;      /* Border and background for selected
541
                                 * characters.  This is a copy of information
542
                                 * in *cursorTagPtr, so it shouldn't be
543
                                 * explicitly freed. */
544
    char *selBdString;          /* Value of -selectborderwidth option, or NULL
545
                                 * if not specified (malloc'ed). */
546
    XColor *selFgColorPtr;      /* Foreground color for selected text.
547
                                 * This is a copy of information in
548
                                 * *cursorTagPtr, so it shouldn't be
549
                                 * explicitly freed. */
550
    int exportSelection;        /* Non-zero means tie "sel" tag to X
551
                                 * selection. */
552
    TkTextIndex selIndex;       /* Used during multi-pass selection retrievals.
553
                                 * This index identifies the next character
554
                                 * to be returned from the selection. */
555
    int abortSelections;        /* Set to 1 whenever the text is modified
556
                                 * in a way that interferes with selection
557
                                 * retrieval:  used to abort incremental
558
                                 * selection retrievals. */
559
    int selOffset;              /* Offset in selection corresponding to
560
                                 * selLine and selCh.  -1 means neither
561
                                 * this information nor selIndex is of any
562
                                 * use. */
563
 
564
    /*
565
     * Information related to insertion cursor:
566
     */
567
 
568
    TkTextSegment *insertMarkPtr;
569
                                /* Points to segment for "insert" mark. */
570
    Tk_3DBorder insertBorder;   /* Used to draw vertical bar for insertion
571
                                 * cursor. */
572
    int insertWidth;            /* Total width of insert cursor. */
573
    int insertBorderWidth;      /* Width of 3-D border around insert cursor. */
574
    int insertOnTime;           /* Number of milliseconds cursor should spend
575
                                 * in "on" state for each blink. */
576
    int insertOffTime;          /* Number of milliseconds cursor should spend
577
                                 * in "off" state for each blink. */
578
    Tcl_TimerToken insertBlinkHandler;
579
                                /* Timer handler used to blink cursor on and
580
                                 * off. */
581
 
582
    /*
583
     * Information used for event bindings associated with tags:
584
     */
585
 
586
    Tk_BindingTable bindingTable;
587
                                /* Table of all bindings currently defined
588
                                 * for this widget.  NULL means that no
589
                                 * bindings exist, so the table hasn't been
590
                                 * created.  Each "object" used for this
591
                                 * table is the address of a tag. */
592
    TkTextSegment *currentMarkPtr;
593
                                /* Pointer to segment for "current" mark,
594
                                 * or NULL if none. */
595
    XEvent pickEvent;           /* The event from which the current character
596
                                 * was chosen.  Must be saved so that we
597
                                 * can repick after modifications to the
598
                                 * text. */
599
    int numCurTags;             /* Number of tags associated with character
600
                                 * at current mark. */
601
    TkTextTag **curTagArrayPtr; /* Pointer to array of tags for current
602
                                 * mark, or NULL if none. */
603
 
604
    /*
605
     * Miscellaneous additional information:
606
     */
607
 
608
    char *takeFocus;            /* Value of -takeFocus option;  not used in
609
                                 * the C code, but used by keyboard traversal
610
                                 * scripts.  Malloc'ed, but may be NULL. */
611
    char *xScrollCmd;           /* Prefix of command to issue to update
612
                                 * horizontal scrollbar when view changes. */
613
    char *yScrollCmd;           /* Prefix of command to issue to update
614
                                 * vertical scrollbar when view changes. */
615
    /* KHAMIS */
616
    char *SyncCmd;              /* Used to synchronize more than editor with the
617
                                 * same file*/
618
 
619
    int flags;                  /* Miscellaneous flags;  see below for
620
                                 * definitions. */
621
} TkText;
622
 
623
/*
624
 * Flag values for TkText records:
625
 *
626
 * GOT_SELECTION:               Non-zero means we've already claimed the
627
 *                              selection.
628
 * INSERT_ON:                   Non-zero means insertion cursor should be
629
 *                              displayed on screen.
630
 * GOT_FOCUS:                   Non-zero means this window has the input
631
 *                              focus.
632
 * BUTTON_DOWN:                 1 means that a mouse button is currently
633
 *                              down;  this is used to implement grabs
634
 *                              for the duration of button presses.
635
 * UPDATE_SCROLLBARS:           Non-zero means scrollbar(s) should be updated
636
 *                              during next redisplay operation.
637
 */
638
 
639
#define GOT_SELECTION           1
640
#define INSERT_ON               2
641
#define GOT_FOCUS               4
642
#define BUTTON_DOWN             8
643
#define UPDATE_SCROLLBARS       0x10
644
#define NEED_REPICK             0x20
645
 
646
/*
647
 * Records of the following type define segment types in terms of
648
 * a collection of procedures that may be called to manipulate
649
 * segments of that type.
650
 */
651
 
652
typedef TkTextSegment * Tk_SegSplitProc _ANSI_ARGS_((
653
                            struct TkTextSegment *segPtr, int index));
654
typedef int             Tk_SegDeleteProc _ANSI_ARGS_((
655
                            struct TkTextSegment *segPtr,
656
                            TkTextLine *linePtr, int treeGone));
657
typedef TkTextSegment * Tk_SegCleanupProc _ANSI_ARGS_((
658
                            struct TkTextSegment *segPtr, TkTextLine *linePtr));
659
typedef void            Tk_SegLineChangeProc _ANSI_ARGS_((
660
                            struct TkTextSegment *segPtr, TkTextLine *linePtr));
661
typedef int             Tk_SegLayoutProc _ANSI_ARGS_((struct TkText *textPtr,
662
                            struct TkTextIndex *indexPtr, TkTextSegment *segPtr,
663
                            int offset, int maxX, int maxChars,
664
                            int noCharsYet, Tk_Uid wrapMode,
665
                            struct TkTextDispChunk *chunkPtr));
666
typedef void            Tk_SegCheckProc _ANSI_ARGS_((TkTextSegment *segPtr,
667
                            TkTextLine *linePtr));
668
 
669
typedef struct Tk_SegType {
670
    char *name;                         /* Name of this kind of segment. */
671
    int leftGravity;                    /* If a segment has zero size (e.g. a
672
                                         * mark or tag toggle), does it
673
                                         * attach to character to its left
674
                                         * or right?  1 means left, 0 means
675
                                         * right. */
676
    Tk_SegSplitProc *splitProc;         /* Procedure to split large segment
677
                                         * into two smaller ones. */
678
    Tk_SegDeleteProc *deleteProc;       /* Procedure to call to delete
679
                                         * segment. */
680
    Tk_SegCleanupProc *cleanupProc;     /* After any change to a line, this
681
                                         * procedure is invoked for all
682
                                         * segments left in the line to
683
                                         * perform any cleanup they wish
684
                                         * (e.g. joining neighboring
685
                                         * segments). */
686
    Tk_SegLineChangeProc *lineChangeProc;
687
                                        /* Invoked when a segment is about
688
                                         * to be moved from its current line
689
                                         * to an earlier line because of
690
                                         * a deletion.  The linePtr is that
691
                                         * for the segment's old line.
692
                                         * CleanupProc will be invoked after
693
                                         * the deletion is finished. */
694
    Tk_SegLayoutProc *layoutProc;       /* Returns size information when
695
                                         * figuring out what to display in
696
                                         * window. */
697
    Tk_SegCheckProc *checkProc;         /* Called during consistency checks
698
                                         * to check internal consistency of
699
                                         * segment. */
700
} Tk_SegType;
701
 
702
/*
703
 * The constant below is used to specify a line when what is really
704
 * wanted is the entire text.  For now, just use a very big number.
705
 */
706
 
707
#define TK_END_OF_TEXT 1000000
708
 
709
/*
710
 * The following definition specifies the maximum number of characters
711
 * needed in a string to hold a position specifier.
712
 */
713
 
714
#define TK_POS_CHARS 30
715
 
716
/*
717
 * Declarations for variables shared among the text-related files:
718
 */
719
 
720
extern int              tkBTreeDebug;
721
extern int              tkTextDebug;
722
extern Tk_SegType       tkTextCharType;
723
extern Tk_Uid           tkTextCharUid;
724
extern Tk_Uid           tkTextDisabledUid;
725
extern Tk_SegType       tkTextLeftMarkType;
726
extern Tk_Uid           tkTextNoneUid;
727
extern Tk_Uid           tkTextNormalUid;
728
extern Tk_SegType       tkTextRightMarkType;
729
extern Tk_SegType       tkTextToggleOnType;
730
extern Tk_SegType       tkTextToggleOffType;
731
extern Tk_Uid           tkTextWordUid;
732
 
733
/*
734
 * Declarations for procedures that are used by the text-related files
735
 * but shouldn't be used anywhere else in Tk (or by Tk clients):
736
 */
737
 
738
extern int              TkBTreeCharTagged _ANSI_ARGS_((TkTextIndex *indexPtr,
739
                            TkTextTag *tagPtr));
740
extern void             TkBTreeCheck _ANSI_ARGS_((TkTextBTree tree));
741
extern int              TkBTreeCharsInLine _ANSI_ARGS_((TkTextLine *linePtr));
742
extern TkTextBTree      TkBTreeCreate _ANSI_ARGS_((TkText *textPtr));
743
extern void             TkBTreeDestroy _ANSI_ARGS_((TkTextBTree tree));
744
extern void             TkBTreeDeleteChars _ANSI_ARGS_((TkTextIndex *index1Ptr,
745
                            TkTextIndex *index2Ptr));
746
extern TkTextLine *     TkBTreeFindLine _ANSI_ARGS_((TkTextBTree tree,
747
                            int line));
748
extern TkTextTag **     TkBTreeGetTags _ANSI_ARGS_((TkTextIndex *indexPtr,
749
                            int *numTagsPtr));
750
extern void             TkBTreeInsertChars _ANSI_ARGS_((TkTextIndex *indexPtr,
751
                            char *string));
752
extern int              TkBTreeLineIndex _ANSI_ARGS_((TkTextLine *linePtr));
753
extern void             TkBTreeLinkSegment _ANSI_ARGS_((TkTextSegment *segPtr,
754
                            TkTextIndex *indexPtr));
755
extern TkTextLine *     TkBTreeNextLine _ANSI_ARGS_((TkTextLine *linePtr));
756
extern int              TkBTreeNextTag _ANSI_ARGS_((TkTextSearch *searchPtr));
757
extern int              TkBTreeNumLines _ANSI_ARGS_((TkTextBTree tree));
758
extern TkTextLine *     TkBTreePreviousLine _ANSI_ARGS_((TkTextLine *linePtr));
759
extern int              TkBTreePrevTag _ANSI_ARGS_((TkTextSearch *searchPtr));
760
extern void             TkBTreeStartSearch _ANSI_ARGS_((TkTextIndex *index1Ptr,
761
                            TkTextIndex *index2Ptr, TkTextTag *tagPtr,
762
                            TkTextSearch *searchPtr));
763
extern void             TkBTreeStartSearchBack _ANSI_ARGS_((TkTextIndex *index1Ptr,
764
                            TkTextIndex *index2Ptr, TkTextTag *tagPtr,
765
                            TkTextSearch *searchPtr));
766
extern void             TkBTreeTag _ANSI_ARGS_((TkTextIndex *index1Ptr,
767
                            TkTextIndex *index2Ptr, TkTextTag *tagPtr,
768
                            int add));
769
extern void             TkBTreeUnlinkSegment _ANSI_ARGS_((TkTextBTree tree,
770
                            TkTextSegment *segPtr, TkTextLine *linePtr));
771
extern void             TkTextBindProc _ANSI_ARGS_((ClientData clientData,
772
                            XEvent *eventPtr));
773
extern void             TkTextChanged _ANSI_ARGS_((TkText *textPtr,
774
                            TkTextIndex *index1Ptr, TkTextIndex *index2Ptr));
775
extern int              TkTextCharBbox _ANSI_ARGS_((TkText *textPtr,
776
                            TkTextIndex *indexPtr, int *xPtr, int *yPtr,
777
                            int *widthPtr, int *heightPtr));
778
extern int              TkTextCharLayoutProc _ANSI_ARGS_((TkText *textPtr,
779
                            TkTextIndex *indexPtr, TkTextSegment *segPtr,
780
                            int offset, int maxX, int maxChars, int noBreakYet,
781
                            Tk_Uid wrapMode, TkTextDispChunk *chunkPtr));
782
extern void             TkTextCreateDInfo _ANSI_ARGS_((TkText *textPtr));
783
extern int              TkTextDLineInfo _ANSI_ARGS_((TkText *textPtr,
784
                            TkTextIndex *indexPtr, int *xPtr, int *yPtr,
785
                            int *widthPtr, int *heightPtr, int *basePtr));
786
extern TkTextTag *      TkTextCreateTag _ANSI_ARGS_((TkText *textPtr,
787
                            char *tagName));
788
extern void             TkTextFreeDInfo _ANSI_ARGS_((TkText *textPtr));
789
extern void             TkTextFreeTag _ANSI_ARGS_((TkText *textPtr,
790
                            TkTextTag *tagPtr));
791
extern int              TkTextGetIndex _ANSI_ARGS_((Tcl_Interp *interp,
792
                            TkText *textPtr, char *string,
793
                            TkTextIndex *indexPtr));
794
extern TkTextTabArray * TkTextGetTabs _ANSI_ARGS_((Tcl_Interp *interp,
795
                            Tk_Window tkwin, char *string));
796
extern void             TkTextIndexBackChars _ANSI_ARGS_((TkTextIndex *srcPtr,
797
                            int count, TkTextIndex *dstPtr));
798
extern int              TkTextIndexCmp _ANSI_ARGS_((TkTextIndex *index1Ptr,
799
                            TkTextIndex *index2Ptr));
800
extern void             TkTextIndexForwChars _ANSI_ARGS_((TkTextIndex *srcPtr,
801
                            int count, TkTextIndex *dstPtr));
802
extern TkTextSegment *  TkTextIndexToSeg _ANSI_ARGS_((TkTextIndex *indexPtr,
803
                            int *offsetPtr));
804
extern void             TkTextInsertDisplayProc _ANSI_ARGS_((
805
                            TkTextDispChunk *chunkPtr, int x, int y, int height,
806
                            int baseline, Display *display, Drawable dst,
807
                            int screenY));
808
extern void             TkTextLostSelection _ANSI_ARGS_((
809
                            ClientData clientData));
810
extern TkTextIndex *    TkTextMakeIndex _ANSI_ARGS_((TkTextBTree tree,
811
                            int lineIndex, int charIndex,
812
                            TkTextIndex *indexPtr));
813
extern int              TkTextMarkCmd _ANSI_ARGS_((TkText *textPtr,
814
                            Tcl_Interp *interp, int argc, char **argv));
815
extern int              TkTextMarkNameToIndex _ANSI_ARGS_((TkText *textPtr,
816
                            char *name, TkTextIndex *indexPtr));
817
extern void             TkTextMarkSegToIndex _ANSI_ARGS_((TkText *textPtr,
818
                            TkTextSegment *markPtr, TkTextIndex *indexPtr));
819
extern void             TkTextEventuallyRepick _ANSI_ARGS_((TkText *textPtr));
820
extern void             TkTextPickCurrent _ANSI_ARGS_((TkText *textPtr,
821
                            XEvent *eventPtr));
822
extern void             TkTextPixelIndex _ANSI_ARGS_((TkText *textPtr,
823
                            int x, int y, TkTextIndex *indexPtr));
824
extern void             TkTextPrintIndex _ANSI_ARGS_((TkTextIndex *indexPtr,
825
                            char *string));
826
extern void             TkTextRedrawRegion _ANSI_ARGS_((TkText *textPtr,
827
                            int x, int y, int width, int height));
828
extern void             TkTextRedrawTag _ANSI_ARGS_((TkText *textPtr,
829
                            TkTextIndex *index1Ptr, TkTextIndex *index2Ptr,
830
                            TkTextTag *tagPtr, int withTag));
831
extern void             TkTextRelayoutWindow _ANSI_ARGS_((TkText *textPtr));
832
extern int              TkTextScanCmd _ANSI_ARGS_((TkText *textPtr,
833
                            Tcl_Interp *interp, int argc, char **argv));
834
extern int              TkTextSeeCmd _ANSI_ARGS_((TkText *textPtr,
835
                            Tcl_Interp *interp, int argc, char **argv));
836
extern int              TkTextSegToOffset _ANSI_ARGS_((TkTextSegment *segPtr,
837
                            TkTextLine *linePtr));
838
extern TkTextSegment *  TkTextSetMark _ANSI_ARGS_((TkText *textPtr, char *name,
839
                            TkTextIndex *indexPtr));
840
extern void             TkTextSetYView _ANSI_ARGS_((TkText *textPtr,
841
                            TkTextIndex *indexPtr, int pickPlace));
842
extern int              TkTextTagCmd _ANSI_ARGS_((TkText *textPtr,
843
                            Tcl_Interp *interp, int argc, char **argv));
844
extern int              TkTextImageCmd _ANSI_ARGS_((TkText *textPtr,
845
                            Tcl_Interp *interp, int argc, char **argv));
846
extern int              TkTextImageIndex _ANSI_ARGS_((TkText *textPtr,
847
                            char *name, TkTextIndex *indexPtr));
848
extern int              TkTextWindowCmd _ANSI_ARGS_((TkText *textPtr,
849
                            Tcl_Interp *interp, int argc, char **argv));
850
extern int              TkTextWindowIndex _ANSI_ARGS_((TkText *textPtr,
851
                            char *name, TkTextIndex *indexPtr));
852
extern int              TkTextXviewCmd _ANSI_ARGS_((TkText *textPtr,
853
                            Tcl_Interp *interp, int argc, char **argv));
854
extern int              TkTextYviewCmd _ANSI_ARGS_((TkText *textPtr,
855
                            Tcl_Interp *interp, int argc, char **argv));
856
 
857
#endif /* _TKTEXT */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.