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