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