home *** CD-ROM | disk | FTP | other *** search
/ CD Actual Thematic 7: Programming / CDAT7.iso / Share / Editores / Perl5 / perl / lib / site / Tk / pTk / tkText.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-08-10  |  32.4 KB  |  808 lines

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