jpayne@69: /* jpayne@69: * tkText.h -- jpayne@69: * jpayne@69: * Declarations shared among the files that implement text widgets. jpayne@69: * jpayne@69: * Copyright (c) 1992-1994 The Regents of the University of California. jpayne@69: * Copyright (c) 1994-1995 Sun Microsystems, Inc. jpayne@69: * jpayne@69: * See the file "license.terms" for information on usage and redistribution of jpayne@69: * this file, and for a DISCLAIMER OF ALL WARRANTIES. jpayne@69: */ jpayne@69: jpayne@69: #ifndef _TKTEXT jpayne@69: #define _TKTEXT jpayne@69: jpayne@69: #ifndef _TK jpayne@69: #include "tk.h" jpayne@69: #endif jpayne@69: jpayne@69: #ifndef _TKUNDO jpayne@69: #include "tkUndo.h" jpayne@69: #endif jpayne@69: jpayne@69: /* jpayne@69: * The data structure below defines a single logical line of text (from jpayne@69: * newline to newline, not necessarily what appears on one display line of the jpayne@69: * screen). jpayne@69: */ jpayne@69: jpayne@69: typedef struct TkTextLine { jpayne@69: struct Node *parentPtr; /* Pointer to parent node containing line. */ jpayne@69: struct TkTextLine *nextPtr; /* Next in linked list of lines with same jpayne@69: * parent node in B-tree. NULL means end of jpayne@69: * list. */ jpayne@69: struct TkTextSegment *segPtr; jpayne@69: /* First in ordered list of segments that make jpayne@69: * up the line. */ jpayne@69: int *pixels; /* Array containing two integers for each jpayne@69: * referring text widget. The first of these jpayne@69: * is the number of vertical pixels taken up jpayne@69: * by this line, whether currently displayed jpayne@69: * or not. This number is only updated jpayne@69: * asychronously. The second of these is the jpayne@69: * last epoch at which the pixel height was jpayne@69: * recalculated. */ jpayne@69: } TkTextLine; jpayne@69: jpayne@69: /* jpayne@69: * ----------------------------------------------------------------------- jpayne@69: * Segments: each line is divided into one or more segments, where each jpayne@69: * segment is one of several things, such as a group of characters, a tag jpayne@69: * toggle, a mark, or an embedded widget. Each segment starts with a standard jpayne@69: * header followed by a body that varies from type to type. jpayne@69: * ----------------------------------------------------------------------- jpayne@69: */ jpayne@69: jpayne@69: /* jpayne@69: * The data structure below defines the body of a segment that represents a jpayne@69: * tag toggle. There is one of these structures at both the beginning and end jpayne@69: * of each tagged range. jpayne@69: */ jpayne@69: jpayne@69: typedef struct TkTextToggle { jpayne@69: struct TkTextTag *tagPtr; /* Tag that starts or ends here. */ jpayne@69: int inNodeCounts; /* 1 means this toggle has been accounted for jpayne@69: * in node toggle counts; 0 means it hasn't, jpayne@69: * yet. */ jpayne@69: } TkTextToggle; jpayne@69: jpayne@69: /* jpayne@69: * The data structure below defines line segments that represent marks. There jpayne@69: * is one of these for each mark in the text. jpayne@69: */ jpayne@69: jpayne@69: typedef struct TkTextMark { jpayne@69: struct TkText *textPtr; /* Overall information about text widget. */ jpayne@69: TkTextLine *linePtr; /* Line structure that contains the jpayne@69: * segment. */ jpayne@69: Tcl_HashEntry *hPtr; /* Pointer to hash table entry for mark (in jpayne@69: * sharedTextPtr->markTable). */ jpayne@69: } TkTextMark; jpayne@69: jpayne@69: /* jpayne@69: * A structure of the following type holds information for each window jpayne@69: * embedded in a text widget. This information is only used by the file jpayne@69: * tkTextWind.c jpayne@69: */ jpayne@69: jpayne@69: typedef struct TkTextEmbWindowClient { jpayne@69: struct TkText *textPtr; /* Information about the overall text jpayne@69: * widget. */ jpayne@69: Tk_Window tkwin; /* Window for this segment. NULL means that jpayne@69: * the window hasn't been created yet. */ jpayne@69: int chunkCount; /* Number of display chunks that refer to this jpayne@69: * window. */ jpayne@69: int displayed; /* Non-zero means that the window has been jpayne@69: * displayed on the screen recently. */ jpayne@69: struct TkTextSegment *parent; jpayne@69: struct TkTextEmbWindowClient *next; jpayne@69: } TkTextEmbWindowClient; jpayne@69: jpayne@69: typedef struct TkTextEmbWindow { jpayne@69: struct TkSharedText *sharedTextPtr; jpayne@69: /* Information about the shared portion of the jpayne@69: * text widget. */ jpayne@69: Tk_Window tkwin; /* Window for this segment. This is just a jpayne@69: * temporary value, copied from 'clients', to jpayne@69: * make option table updating easier. NULL jpayne@69: * means that the window hasn't been created jpayne@69: * yet. */ jpayne@69: TkTextLine *linePtr; /* Line structure that contains this jpayne@69: * window. */ jpayne@69: char *create; /* Script to create window on-demand. NULL jpayne@69: * means no such script. Malloc-ed. */ jpayne@69: int align; /* How to align window in vertical space. See jpayne@69: * definitions in tkTextWind.c. */ jpayne@69: int padX, padY; /* Padding to leave around each side of jpayne@69: * window, in pixels. */ jpayne@69: int stretch; /* Should window stretch to fill vertical jpayne@69: * space of line (except for pady)? 0 or 1. */ jpayne@69: Tk_OptionTable optionTable; /* Token representing the configuration jpayne@69: * specifications. */ jpayne@69: TkTextEmbWindowClient *clients; jpayne@69: /* Linked list of peer-widget specific jpayne@69: * information for this embedded window. */ jpayne@69: } TkTextEmbWindow; jpayne@69: jpayne@69: /* jpayne@69: * A structure of the following type holds information for each image embedded jpayne@69: * in a text widget. This information is only used by the file tkTextImage.c jpayne@69: */ jpayne@69: jpayne@69: typedef struct TkTextEmbImage { jpayne@69: struct TkSharedText *sharedTextPtr; jpayne@69: /* Information about the shared portion of the jpayne@69: * text widget. This is used when the image jpayne@69: * changes or is deleted. */ jpayne@69: TkTextLine *linePtr; /* Line structure that contains this image. */ jpayne@69: char *imageString; /* Name of the image for this segment. */ jpayne@69: char *imageName; /* Name used by text widget to identify this jpayne@69: * image. May be unique-ified. */ jpayne@69: char *name; /* Name used in the hash table. Used by jpayne@69: * "image names" to identify this instance of jpayne@69: * the image. */ jpayne@69: Tk_Image image; /* Image for this segment. NULL means that the jpayne@69: * image hasn't been created yet. */ jpayne@69: int align; /* How to align image in vertical space. See jpayne@69: * definitions in tkTextImage.c. */ jpayne@69: int padX, padY; /* Padding to leave around each side of image, jpayne@69: * in pixels. */ jpayne@69: int chunkCount; /* Number of display chunks that refer to this jpayne@69: * image. */ jpayne@69: Tk_OptionTable optionTable; /* Token representing the configuration jpayne@69: * specifications. */ jpayne@69: } TkTextEmbImage; jpayne@69: jpayne@69: /* jpayne@69: * The data structure below defines line segments. jpayne@69: */ jpayne@69: jpayne@69: typedef struct TkTextSegment { jpayne@69: const struct Tk_SegType *typePtr; jpayne@69: /* Pointer to record describing segment's jpayne@69: * type. */ jpayne@69: struct TkTextSegment *nextPtr; jpayne@69: /* Next in list of segments for this line, or jpayne@69: * NULL for end of list. */ jpayne@69: int size; /* Size of this segment (# of bytes of index jpayne@69: * space it occupies). */ jpayne@69: union { jpayne@69: char chars[TCL_UTF_MAX]; /* Characters that make up character info. jpayne@69: * Actual length varies to hold as many jpayne@69: * characters as needed.*/ jpayne@69: TkTextToggle toggle; /* Information about tag toggle. */ jpayne@69: TkTextMark mark; /* Information about mark. */ jpayne@69: TkTextEmbWindow ew; /* Information about embedded window. */ jpayne@69: TkTextEmbImage ei; /* Information about embedded image. */ jpayne@69: } body; jpayne@69: } TkTextSegment; jpayne@69: jpayne@69: /* jpayne@69: * Data structures of the type defined below are used during the execution of jpayne@69: * Tcl commands to keep track of various interesting places in a text. An jpayne@69: * index is only valid up until the next modification to the character jpayne@69: * structure of the b-tree so they can't be retained across Tcl commands. jpayne@69: * However, mods to marks or tags don't invalidate indices. jpayne@69: */ jpayne@69: jpayne@69: typedef struct TkTextIndex { jpayne@69: TkTextBTree tree; /* Tree containing desired position. */ jpayne@69: TkTextLine *linePtr; /* Pointer to line containing position of jpayne@69: * interest. */ jpayne@69: int byteIndex; /* Index within line of desired character (0 jpayne@69: * means first one). */ jpayne@69: struct TkText *textPtr; /* May be NULL, but otherwise the text widget jpayne@69: * with which this index is associated. If not jpayne@69: * NULL, then we have a refCount on the jpayne@69: * widget. */ jpayne@69: } TkTextIndex; jpayne@69: jpayne@69: /* jpayne@69: * Types for procedure pointers stored in TkTextDispChunk strutures: jpayne@69: */ jpayne@69: jpayne@69: typedef struct TkTextDispChunk TkTextDispChunk; jpayne@69: jpayne@69: typedef void Tk_ChunkDisplayProc(struct TkText *textPtr, jpayne@69: TkTextDispChunk *chunkPtr, int x, int y, jpayne@69: int height, int baseline, Display *display, jpayne@69: Drawable dst, int screenY); jpayne@69: typedef void Tk_ChunkUndisplayProc(struct TkText *textPtr, jpayne@69: TkTextDispChunk *chunkPtr); jpayne@69: typedef int Tk_ChunkMeasureProc(TkTextDispChunk *chunkPtr, int x); jpayne@69: typedef void Tk_ChunkBboxProc(struct TkText *textPtr, jpayne@69: TkTextDispChunk *chunkPtr, int index, int y, jpayne@69: int lineHeight, int baseline, int *xPtr, jpayne@69: int *yPtr, int *widthPtr, int *heightPtr); jpayne@69: jpayne@69: /* jpayne@69: * The structure below represents a chunk of stuff that is displayed together jpayne@69: * on the screen. This structure is allocated and freed by generic display jpayne@69: * code but most of its fields are filled in by segment-type-specific code. jpayne@69: */ jpayne@69: jpayne@69: struct TkTextDispChunk { jpayne@69: /* jpayne@69: * The fields below are set by the type-independent code before calling jpayne@69: * the segment-type-specific layoutProc. They should not be modified by jpayne@69: * segment-type-specific code. jpayne@69: */ jpayne@69: jpayne@69: int x; /* X position of chunk, in pixels. This jpayne@69: * position is measured from the left edge of jpayne@69: * the logical line, not from the left edge of jpayne@69: * the window (i.e. it doesn't change under jpayne@69: * horizontal scrolling). */ jpayne@69: struct TkTextDispChunk *nextPtr; jpayne@69: /* Next chunk in the display line or NULL for jpayne@69: * the end of the list. */ jpayne@69: struct TextStyle *stylePtr; /* Display information, known only to jpayne@69: * tkTextDisp.c. */ jpayne@69: jpayne@69: /* jpayne@69: * The fields below are set by the layoutProc that creates the chunk. jpayne@69: */ jpayne@69: jpayne@69: Tk_ChunkDisplayProc *displayProc; jpayne@69: /* Procedure to invoke to draw this chunk on jpayne@69: * the display or an off-screen pixmap. */ jpayne@69: Tk_ChunkUndisplayProc *undisplayProc; jpayne@69: /* Procedure to invoke when segment ceases to jpayne@69: * be displayed on screen anymore. */ jpayne@69: Tk_ChunkMeasureProc *measureProc; jpayne@69: /* Procedure to find character under a given jpayne@69: * x-location. */ jpayne@69: Tk_ChunkBboxProc *bboxProc; /* Procedure to find bounding box of character jpayne@69: * in chunk. */ jpayne@69: int numBytes; /* Number of bytes that will be displayed in jpayne@69: * the chunk. */ jpayne@69: int minAscent; /* Minimum space above the baseline needed by jpayne@69: * this chunk. */ jpayne@69: int minDescent; /* Minimum space below the baseline needed by jpayne@69: * this chunk. */ jpayne@69: int minHeight; /* Minimum total line height needed by this jpayne@69: * chunk. */ jpayne@69: int width; /* Width of this chunk, in pixels. Initially jpayne@69: * set by chunk-specific code, but may be jpayne@69: * increased to include tab or extra space at jpayne@69: * end of line. */ jpayne@69: int breakIndex; /* Index within chunk of last acceptable jpayne@69: * position for a line (break just before this jpayne@69: * byte index). <= 0 means don't break during jpayne@69: * or immediately after this chunk. */ jpayne@69: ClientData clientData; /* Additional information for use of jpayne@69: * displayProc and undisplayProc. */ jpayne@69: }; jpayne@69: jpayne@69: /* jpayne@69: * One data structure of the following type is used for each tag in a text jpayne@69: * widget. These structures are kept in sharedTextPtr->tagTable and referred jpayne@69: * to in other structures. jpayne@69: */ jpayne@69: jpayne@69: typedef enum { jpayne@69: TEXT_WRAPMODE_CHAR, TEXT_WRAPMODE_NONE, TEXT_WRAPMODE_WORD, jpayne@69: TEXT_WRAPMODE_NULL jpayne@69: } TkWrapMode; jpayne@69: jpayne@69: typedef struct TkTextTag { jpayne@69: const char *name; /* Name of this tag. This field is actually a jpayne@69: * pointer to the key from the entry in jpayne@69: * sharedTextPtr->tagTable, so it needn't be jpayne@69: * freed explicitly. For 'sel' tags this is jpayne@69: * just a static string, so again need not be jpayne@69: * freed. */ jpayne@69: const struct TkText *textPtr; jpayne@69: /* If non-NULL, then this tag only applies to jpayne@69: * the given text widget (when there are peer jpayne@69: * widgets). */ jpayne@69: int priority; /* Priority of this tag within widget. 0 means jpayne@69: * lowest priority. Exactly one tag has each jpayne@69: * integer value between 0 and numTags-1. */ jpayne@69: struct Node *tagRootPtr; /* Pointer into the B-Tree at the lowest node jpayne@69: * that completely dominates the ranges of jpayne@69: * text occupied by the tag. At this node jpayne@69: * there is no information about the tag. One jpayne@69: * or more children of the node do contain jpayne@69: * information about the tag. */ jpayne@69: int toggleCount; /* Total number of tag toggles. */ jpayne@69: jpayne@69: /* jpayne@69: * Information for displaying text with this tag. The information belows jpayne@69: * acts as an override on information specified by lower-priority tags. jpayne@69: * If no value is specified, then the next-lower-priority tag on the text jpayne@69: * determins the value. The text widget itself provides defaults if no tag jpayne@69: * specifies an override. jpayne@69: */ jpayne@69: jpayne@69: Tk_3DBorder border; /* Used for drawing background. NULL means no jpayne@69: * value specified here. */ jpayne@69: int borderWidth; /* Width of 3-D border for background. */ jpayne@69: Tcl_Obj *borderWidthPtr; /* Width of 3-D border for background. */ jpayne@69: char *reliefString; /* -relief option string (malloc-ed). NULL jpayne@69: * means option not specified. */ jpayne@69: int relief; /* 3-D relief for background. */ jpayne@69: Pixmap bgStipple; /* Stipple bitmap for background. None means jpayne@69: * no value specified here. */ jpayne@69: XColor *fgColor; /* Foreground color for text. NULL means no jpayne@69: * value specified here. */ jpayne@69: Tk_Font tkfont; /* Font for displaying text. NULL means no jpayne@69: * value specified here. */ jpayne@69: Pixmap fgStipple; /* Stipple bitmap for text and other jpayne@69: * foreground stuff. None means no value jpayne@69: * specified here.*/ jpayne@69: char *justifyString; /* -justify option string (malloc-ed). NULL jpayne@69: * means option not specified. */ jpayne@69: Tk_Justify justify; /* How to justify text: TK_JUSTIFY_LEFT, jpayne@69: * TK_JUSTIFY_RIGHT, or TK_JUSTIFY_CENTER. jpayne@69: * Only valid if justifyString is non-NULL. */ jpayne@69: char *lMargin1String; /* -lmargin1 option string (malloc-ed). NULL jpayne@69: * means option not specified. */ jpayne@69: int lMargin1; /* Left margin for first display line of each jpayne@69: * text line, in pixels. Only valid if jpayne@69: * lMargin1String is non-NULL. */ jpayne@69: char *lMargin2String; /* -lmargin2 option string (malloc-ed). NULL jpayne@69: * means option not specified. */ jpayne@69: int lMargin2; /* Left margin for second and later display jpayne@69: * lines of each text line, in pixels. Only jpayne@69: * valid if lMargin2String is non-NULL. */ jpayne@69: Tk_3DBorder lMarginColor; /* Used for drawing background in left margins. jpayne@69: * This is used for both lmargin1 and lmargin2. jpayne@69: * NULL means no value specified here. */ jpayne@69: char *offsetString; /* -offset option string (malloc-ed). NULL jpayne@69: * means option not specified. */ jpayne@69: int offset; /* Vertical offset of text's baseline from jpayne@69: * baseline of line. Used for superscripts and jpayne@69: * subscripts. Only valid if offsetString is jpayne@69: * non-NULL. */ jpayne@69: char *overstrikeString; /* -overstrike option string (malloc-ed). NULL jpayne@69: * means option not specified. */ jpayne@69: int overstrike; /* Non-zero means draw horizontal line through jpayne@69: * middle of text. Only valid if jpayne@69: * overstrikeString is non-NULL. */ jpayne@69: XColor *overstrikeColor; /* Color for the overstrike. NULL means same jpayne@69: * color as foreground. */ jpayne@69: char *rMarginString; /* -rmargin option string (malloc-ed). NULL jpayne@69: * means option not specified. */ jpayne@69: int rMargin; /* Right margin for text, in pixels. Only jpayne@69: * valid if rMarginString is non-NULL. */ jpayne@69: Tk_3DBorder rMarginColor; /* Used for drawing background in right margin. jpayne@69: * NULL means no value specified here. */ jpayne@69: Tk_3DBorder selBorder; /* Used for drawing background for selected text. jpayne@69: * NULL means no value specified here. */ jpayne@69: XColor *selFgColor; /* Foreground color for selected text. NULL means jpayne@69: * no value specified here. */ jpayne@69: char *spacing1String; /* -spacing1 option string (malloc-ed). NULL jpayne@69: * means option not specified. */ jpayne@69: int spacing1; /* Extra spacing above first display line for jpayne@69: * text line. Only valid if spacing1String is jpayne@69: * non-NULL. */ jpayne@69: char *spacing2String; /* -spacing2 option string (malloc-ed). NULL jpayne@69: * means option not specified. */ jpayne@69: int spacing2; /* Extra spacing between display lines for the jpayne@69: * same text line. Only valid if jpayne@69: * spacing2String is non-NULL. */ jpayne@69: char *spacing3String; /* -spacing2 option string (malloc-ed). NULL jpayne@69: * means option not specified. */ jpayne@69: int spacing3; /* Extra spacing below last display line for jpayne@69: * text line. Only valid if spacing3String is jpayne@69: * non-NULL. */ jpayne@69: Tcl_Obj *tabStringPtr; /* -tabs option string. NULL means option not jpayne@69: * specified. */ jpayne@69: struct TkTextTabArray *tabArrayPtr; jpayne@69: /* Info about tabs for tag (malloc-ed) or jpayne@69: * NULL. Corresponds to tabString. */ jpayne@69: int tabStyle; /* One of TABULAR or WORDPROCESSOR or NONE (if jpayne@69: * not specified). */ jpayne@69: char *underlineString; /* -underline option string (malloc-ed). NULL jpayne@69: * means option not specified. */ jpayne@69: int underline; /* Non-zero means draw underline underneath jpayne@69: * text. Only valid if underlineString is jpayne@69: * non-NULL. */ jpayne@69: XColor *underlineColor; /* Color for the underline. NULL means same jpayne@69: * color as foreground. */ jpayne@69: TkWrapMode wrapMode; /* How to handle wrap-around for this tag. jpayne@69: * Must be TEXT_WRAPMODE_CHAR, jpayne@69: * TEXT_WRAPMODE_NONE, TEXT_WRAPMODE_WORD, or jpayne@69: * TEXT_WRAPMODE_NULL to use wrapmode for jpayne@69: * whole widget. */ jpayne@69: char *elideString; /* -elide option string (malloc-ed). NULL jpayne@69: * means option not specified. */ jpayne@69: int elide; /* Non-zero means that data under this tag jpayne@69: * should not be displayed. */ jpayne@69: int affectsDisplay; /* Non-zero means that this tag affects the jpayne@69: * way information is displayed on the screen jpayne@69: * (so need to redisplay if tag changes). */ jpayne@69: Tk_OptionTable optionTable; /* Token representing the configuration jpayne@69: * specifications. */ jpayne@69: int affectsDisplayGeometry; /* Non-zero means that this tag affects the jpayne@69: * size with which information is displayed on jpayne@69: * the screen (so need to recalculate line jpayne@69: * dimensions if tag changes). */ jpayne@69: } TkTextTag; jpayne@69: jpayne@69: #define TK_TAG_AFFECTS_DISPLAY 0x1 jpayne@69: #define TK_TAG_UNDERLINE 0x2 jpayne@69: #define TK_TAG_JUSTIFY 0x4 jpayne@69: #define TK_TAG_OFFSET 0x10 jpayne@69: jpayne@69: /* jpayne@69: * The data structure below is used for searching a B-tree for transitions on jpayne@69: * a single tag (or for all tag transitions). No code outside of tkTextBTree.c jpayne@69: * should ever modify any of the fields in these structures, but it's OK to jpayne@69: * use them for read-only information. jpayne@69: */ jpayne@69: jpayne@69: typedef struct TkTextSearch { jpayne@69: TkTextIndex curIndex; /* Position of last tag transition returned by jpayne@69: * TkBTreeNextTag, or index of start of jpayne@69: * segment containing starting position for jpayne@69: * search if TkBTreeNextTag hasn't been called jpayne@69: * yet, or same as stopIndex if search is jpayne@69: * over. */ jpayne@69: TkTextSegment *segPtr; /* Actual tag segment returned by last call to jpayne@69: * TkBTreeNextTag, or NULL if TkBTreeNextTag jpayne@69: * hasn't returned anything yet. */ jpayne@69: TkTextSegment *nextPtr; /* Where to resume search in next call to jpayne@69: * TkBTreeNextTag. */ jpayne@69: TkTextSegment *lastPtr; /* Stop search before just before considering jpayne@69: * this segment. */ jpayne@69: TkTextTag *tagPtr; /* Tag to search for (or tag found, if allTags jpayne@69: * is non-zero). */ jpayne@69: int linesLeft; /* Lines left to search (including curIndex jpayne@69: * and stopIndex). When this becomes <= 0 the jpayne@69: * search is over. */ jpayne@69: int allTags; /* Non-zero means ignore tag check: search for jpayne@69: * transitions on all tags. */ jpayne@69: } TkTextSearch; jpayne@69: jpayne@69: /* jpayne@69: * The following data structure describes a single tab stop. It must be kept jpayne@69: * in sync with the 'tabOptionStrings' array in the function 'TkTextGetTabs' jpayne@69: */ jpayne@69: jpayne@69: typedef enum {LEFT, RIGHT, CENTER, NUMERIC} TkTextTabAlign; jpayne@69: jpayne@69: /* jpayne@69: * The following are the supported styles of tabbing, used for the -tabstyle jpayne@69: * option of the text widget. The last element is only used for tag options. jpayne@69: */ jpayne@69: jpayne@69: typedef enum { jpayne@69: TK_TEXT_TABSTYLE_TABULAR, jpayne@69: TK_TEXT_TABSTYLE_WORDPROCESSOR, jpayne@69: TK_TEXT_TABSTYLE_NONE jpayne@69: } TkTextTabStyle; jpayne@69: jpayne@69: typedef struct TkTextTab { jpayne@69: int location; /* Offset in pixels of this tab stop from the jpayne@69: * left margin (lmargin2) of the text. */ jpayne@69: TkTextTabAlign alignment; /* Where the tab stop appears relative to the jpayne@69: * text. */ jpayne@69: } TkTextTab; jpayne@69: jpayne@69: typedef struct TkTextTabArray { jpayne@69: int numTabs; /* Number of tab stops. */ jpayne@69: double lastTab; /* The accurate fractional pixel position of jpayne@69: * the last tab. */ jpayne@69: double tabIncrement; /* The accurate fractional pixel increment jpayne@69: * between interpolated tabs we have to create jpayne@69: * when we exceed numTabs. */ jpayne@69: TkTextTab tabs[TKFLEXARRAY];/* Array of tabs. The actual size will be jpayne@69: * numTabs. THIS FIELD MUST BE THE LAST IN THE jpayne@69: * STRUCTURE. */ jpayne@69: } TkTextTabArray; jpayne@69: jpayne@69: /* jpayne@69: * Enumeration defining the edit modes of the widget. jpayne@69: */ jpayne@69: jpayne@69: typedef enum { jpayne@69: TK_TEXT_EDIT_INSERT, /* insert mode */ jpayne@69: TK_TEXT_EDIT_DELETE, /* delete mode */ jpayne@69: TK_TEXT_EDIT_REPLACE, /* replace mode */ jpayne@69: TK_TEXT_EDIT_OTHER /* none of the above */ jpayne@69: } TkTextEditMode; jpayne@69: jpayne@69: /* jpayne@69: * Enumeration defining the ways in which a text widget may be modified (for jpayne@69: * undo/redo handling). jpayne@69: */ jpayne@69: jpayne@69: typedef enum { jpayne@69: TK_TEXT_DIRTY_NORMAL, /* Normal behavior. */ jpayne@69: TK_TEXT_DIRTY_UNDO, /* Reverting a compound action. */ jpayne@69: TK_TEXT_DIRTY_REDO, /* Reapplying a compound action. */ jpayne@69: TK_TEXT_DIRTY_FIXED /* Forced to be dirty; can't be undone/redone jpayne@69: * by normal activity. */ jpayne@69: } TkTextDirtyMode; jpayne@69: jpayne@69: /* jpayne@69: * The following enum is used to define a type for the -state option of the jpayne@69: * Text widget. jpayne@69: */ jpayne@69: jpayne@69: typedef enum { jpayne@69: TK_TEXT_STATE_DISABLED, TK_TEXT_STATE_NORMAL jpayne@69: } TkTextState; jpayne@69: jpayne@69: /* jpayne@69: * A data structure of the following type is shared between each text widget jpayne@69: * that are peers. jpayne@69: */ jpayne@69: jpayne@69: typedef struct TkSharedText { jpayne@69: int refCount; /* Reference count this shared object. */ jpayne@69: TkTextBTree tree; /* B-tree representation of text and tags for jpayne@69: * widget. */ jpayne@69: Tcl_HashTable tagTable; /* Hash table that maps from tag names to jpayne@69: * pointers to TkTextTag structures. The "sel" jpayne@69: * tag does not feature in this table, since jpayne@69: * there's one of those for each text peer. */ jpayne@69: int numTags; /* Number of tags currently defined for jpayne@69: * widget; needed to keep track of jpayne@69: * priorities. */ jpayne@69: Tcl_HashTable markTable; /* Hash table that maps from mark names to jpayne@69: * pointers to mark segments. The special jpayne@69: * "insert" and "current" marks are not stored jpayne@69: * in this table, but directly accessed as jpayne@69: * fields of textPtr. */ jpayne@69: Tcl_HashTable windowTable; /* Hash table that maps from window names to jpayne@69: * pointers to window segments. If a window jpayne@69: * segment doesn't yet have an associated jpayne@69: * window, there is no entry for it here. */ jpayne@69: Tcl_HashTable imageTable; /* Hash table that maps from image names to jpayne@69: * pointers to image segments. If an image jpayne@69: * segment doesn't yet have an associated jpayne@69: * image, there is no entry for it here. */ jpayne@69: Tk_BindingTable bindingTable; jpayne@69: /* Table of all bindings currently defined for jpayne@69: * this widget. NULL means that no bindings jpayne@69: * exist, so the table hasn't been created. jpayne@69: * Each "object" used for this table is the jpayne@69: * name of a tag. */ jpayne@69: int stateEpoch; /* This is incremented each time the B-tree's jpayne@69: * contents change structurally, or when the jpayne@69: * start/end limits change, and means that any jpayne@69: * cached TkTextIndex objects are no longer jpayne@69: * valid. */ jpayne@69: jpayne@69: /* jpayne@69: * Information related to the undo/redo functionality. jpayne@69: */ jpayne@69: jpayne@69: TkUndoRedoStack *undoStack; /* The undo/redo stack. */ jpayne@69: int undo; /* Non-zero means the undo/redo behaviour is jpayne@69: * enabled. */ jpayne@69: int maxUndo; /* The maximum depth of the undo stack jpayne@69: * expressed as the maximum number of compound jpayne@69: * statements. */ jpayne@69: int autoSeparators; /* Non-zero means the separators will be jpayne@69: * inserted automatically. */ jpayne@69: int isDirty; /* Flag indicating the 'dirtyness' of the jpayne@69: * text widget. If the flag is not zero, jpayne@69: * unsaved modifications have been applied to jpayne@69: * the text widget. */ jpayne@69: TkTextDirtyMode dirtyMode; /* The nature of the dirtyness characterized jpayne@69: * by the isDirty flag. */ jpayne@69: TkTextEditMode lastEditMode;/* Keeps track of what the last edit mode jpayne@69: * was. */ jpayne@69: jpayne@69: /* jpayne@69: * Keep track of all the peers jpayne@69: */ jpayne@69: jpayne@69: struct TkText *peers; jpayne@69: } TkSharedText; jpayne@69: jpayne@69: /* jpayne@69: * The following enum is used to define a type for the -insertunfocussed jpayne@69: * option of the Text widget. jpayne@69: */ jpayne@69: jpayne@69: typedef enum { jpayne@69: TK_TEXT_INSERT_NOFOCUS_HOLLOW, jpayne@69: TK_TEXT_INSERT_NOFOCUS_NONE, jpayne@69: TK_TEXT_INSERT_NOFOCUS_SOLID jpayne@69: } TkTextInsertUnfocussed; jpayne@69: jpayne@69: /* jpayne@69: * A data structure of the following type is kept for each text widget that jpayne@69: * currently exists for this process: jpayne@69: */ jpayne@69: jpayne@69: typedef struct TkText { jpayne@69: /* jpayne@69: * Information related to and accessed by widget peers and the jpayne@69: * TkSharedText handling routines. jpayne@69: */ jpayne@69: jpayne@69: TkSharedText *sharedTextPtr;/* Shared section of all peers. */ jpayne@69: struct TkText *next; /* Next in list of linked peers. */ jpayne@69: TkTextLine *start; /* First B-tree line to show, or NULL to start jpayne@69: * at the beginning. */ jpayne@69: TkTextLine *end; /* Last B-tree line to show, or NULL for up to jpayne@69: * the end. */ jpayne@69: int pixelReference; /* Counter into the current tree reference jpayne@69: * index corresponding to this widget. */ jpayne@69: int abortSelections; /* Set to 1 whenever the text is modified in a jpayne@69: * way that interferes with selection jpayne@69: * retrieval: used to abort incremental jpayne@69: * selection retrievals. */ jpayne@69: jpayne@69: /* jpayne@69: * Standard Tk widget information and text-widget specific items jpayne@69: */ jpayne@69: jpayne@69: Tk_Window tkwin; /* Window that embodies the text. NULL means jpayne@69: * that the window has been destroyed but the jpayne@69: * data structures haven't yet been cleaned jpayne@69: * up.*/ jpayne@69: Display *display; /* Display for widget. Needed, among other jpayne@69: * things, to allow resources to be freed even jpayne@69: * after tkwin has gone away. */ jpayne@69: Tcl_Interp *interp; /* Interpreter associated with widget. Used to jpayne@69: * delete widget command. */ jpayne@69: Tcl_Command widgetCmd; /* Token for text's widget command. */ jpayne@69: int state; /* Either STATE_NORMAL or STATE_DISABLED. A jpayne@69: * text widget is read-only when disabled. */ jpayne@69: jpayne@69: /* jpayne@69: * Default information for displaying (may be overridden by tags applied jpayne@69: * to ranges of characters). jpayne@69: */ jpayne@69: jpayne@69: Tk_3DBorder border; /* Structure used to draw 3-D border and jpayne@69: * default background. */ jpayne@69: int borderWidth; /* Width of 3-D border to draw around entire jpayne@69: * widget. */ jpayne@69: int padX, padY; /* Padding between text and window border. */ jpayne@69: int relief; /* 3-d effect for border around entire widget: jpayne@69: * TK_RELIEF_RAISED etc. */ jpayne@69: int highlightWidth; /* Width in pixels of highlight to draw around jpayne@69: * widget when it has the focus. <= 0 means jpayne@69: * don't draw a highlight. */ jpayne@69: XColor *highlightBgColorPtr; jpayne@69: /* Color for drawing traversal highlight area jpayne@69: * when highlight is off. */ jpayne@69: XColor *highlightColorPtr; /* Color for drawing traversal highlight. */ jpayne@69: Tk_Cursor cursor; /* Current cursor for window, or NULL. */ jpayne@69: XColor *fgColor; /* Default foreground color for text. */ jpayne@69: Tk_Font tkfont; /* Default font for displaying text. */ jpayne@69: int charWidth; /* Width of average character in default jpayne@69: * font. */ jpayne@69: int charHeight; /* Height of average character in default jpayne@69: * font, including line spacing. */ jpayne@69: int spacing1; /* Default extra spacing above first display jpayne@69: * line for each text line. */ jpayne@69: int spacing2; /* Default extra spacing between display lines jpayne@69: * for the same text line. */ jpayne@69: int spacing3; /* Default extra spacing below last display jpayne@69: * line for each text line. */ jpayne@69: Tcl_Obj *tabOptionPtr; /* Value of -tabs option string. */ jpayne@69: TkTextTabArray *tabArrayPtr; jpayne@69: /* Information about tab stops (malloc'ed). jpayne@69: * NULL means perform default tabbing jpayne@69: * behavior. */ jpayne@69: int tabStyle; /* One of TABULAR or WORDPROCESSOR. */ jpayne@69: jpayne@69: /* jpayne@69: * Additional information used for displaying: jpayne@69: */ jpayne@69: jpayne@69: TkWrapMode wrapMode; /* How to handle wrap-around. Must be jpayne@69: * TEXT_WRAPMODE_CHAR, TEXT_WRAPMODE_NONE, or jpayne@69: * TEXT_WRAPMODE_WORD. */ jpayne@69: int width, height; /* Desired dimensions for window, measured in jpayne@69: * characters. */ jpayne@69: int setGrid; /* Non-zero means pass gridding information to jpayne@69: * window manager. */ jpayne@69: int prevWidth, prevHeight; /* Last known dimensions of window; used to jpayne@69: * detect changes in size. */ jpayne@69: TkTextIndex topIndex; /* Identifies first character in top display jpayne@69: * line of window. */ jpayne@69: struct TextDInfo *dInfoPtr; /* Information maintained by tkTextDisp.c. */ jpayne@69: jpayne@69: /* jpayne@69: * Information related to selection. jpayne@69: */ jpayne@69: jpayne@69: TkTextTag *selTagPtr; /* Pointer to "sel" tag. Used to tell when a jpayne@69: * new selection has been made. */ jpayne@69: Tk_3DBorder selBorder; /* Border and background for selected jpayne@69: * characters. This is a copy of information jpayne@69: * in *selTagPtr, so it shouldn't be jpayne@69: * explicitly freed. */ jpayne@69: Tk_3DBorder inactiveSelBorder; jpayne@69: /* Border and background for selected jpayne@69: * characters when they don't have the jpayne@69: * focus. */ jpayne@69: int selBorderWidth; /* Width of border around selection. */ jpayne@69: Tcl_Obj *selBorderWidthPtr; /* Width of border around selection. */ jpayne@69: XColor *selFgColorPtr; /* Foreground color for selected text. This is jpayne@69: * a copy of information in *selTagPtr, so it jpayne@69: * shouldn't be explicitly freed. */ jpayne@69: int exportSelection; /* Non-zero means tie "sel" tag to X jpayne@69: * selection. */ jpayne@69: TkTextIndex selIndex; /* Used during multi-pass selection jpayne@69: * retrievals. This index identifies the next jpayne@69: * character to be returned from the jpayne@69: * selection. */ jpayne@69: jpayne@69: /* jpayne@69: * Information related to insertion cursor: jpayne@69: */ jpayne@69: jpayne@69: TkTextSegment *insertMarkPtr; jpayne@69: /* Points to segment for "insert" mark. */ jpayne@69: Tk_3DBorder insertBorder; /* Used to draw vertical bar for insertion jpayne@69: * cursor. */ jpayne@69: int insertWidth; /* Total width of insert cursor. */ jpayne@69: int insertBorderWidth; /* Width of 3-D border around insert cursor */ jpayne@69: TkTextInsertUnfocussed insertUnfocussed; jpayne@69: /* How to display the insert cursor when the jpayne@69: * text widget does not have the focus. */ jpayne@69: int insertOnTime; /* Number of milliseconds cursor should spend jpayne@69: * in "on" state for each blink. */ jpayne@69: int insertOffTime; /* Number of milliseconds cursor should spend jpayne@69: * in "off" state for each blink. */ jpayne@69: Tcl_TimerToken insertBlinkHandler; jpayne@69: /* Timer handler used to blink cursor on and jpayne@69: * off. */ jpayne@69: jpayne@69: /* jpayne@69: * Information used for event bindings associated with tags: jpayne@69: */ jpayne@69: jpayne@69: TkTextSegment *currentMarkPtr; jpayne@69: /* Pointer to segment for "current" mark, or jpayne@69: * NULL if none. */ jpayne@69: XEvent pickEvent; /* The event from which the current character jpayne@69: * was chosen. Must be saved so that we can jpayne@69: * repick after modifications to the text. */ jpayne@69: int numCurTags; /* Number of tags associated with character at jpayne@69: * current mark. */ jpayne@69: TkTextTag **curTagArrayPtr; /* Pointer to array of tags for current mark, jpayne@69: * or NULL if none. */ jpayne@69: jpayne@69: /* jpayne@69: * Miscellaneous additional information: jpayne@69: */ jpayne@69: jpayne@69: char *takeFocus; /* Value of -takeFocus option; not used in the jpayne@69: * C code, but used by keyboard traversal jpayne@69: * scripts. Malloc'ed, but may be NULL. */ jpayne@69: char *xScrollCmd; /* Prefix of command to issue to update jpayne@69: * horizontal scrollbar when view changes. */ jpayne@69: char *yScrollCmd; /* Prefix of command to issue to update jpayne@69: * vertical scrollbar when view changes. */ jpayne@69: int flags; /* Miscellaneous flags; see below for jpayne@69: * definitions. */ jpayne@69: Tk_OptionTable optionTable; /* Token representing the configuration jpayne@69: * specifications. */ jpayne@69: int refCount; /* Number of cached TkTextIndex objects jpayne@69: * refering to us. */ jpayne@69: int insertCursorType; /* 0 = standard insertion cursor, 1 = block jpayne@69: * cursor. */ jpayne@69: jpayne@69: /* jpayne@69: * Copies of information from the shared section relating to the undo/redo jpayne@69: * functonality jpayne@69: */ jpayne@69: jpayne@69: int undo; /* Non-zero means the undo/redo behaviour is jpayne@69: * enabled. */ jpayne@69: int maxUndo; /* The maximum depth of the undo stack jpayne@69: * expressed as the maximum number of compound jpayne@69: * statements. */ jpayne@69: int autoSeparators; /* Non-zero means the separators will be jpayne@69: * inserted automatically. */ jpayne@69: Tcl_Obj *afterSyncCmd; /* Command to be executed when lines are up to jpayne@69: * date */ jpayne@69: } TkText; jpayne@69: jpayne@69: /* jpayne@69: * Flag values for TkText records: jpayne@69: * jpayne@69: * GOT_SELECTION: Non-zero means we've already claimed the jpayne@69: * selection. jpayne@69: * INSERT_ON: Non-zero means insertion cursor should be jpayne@69: * displayed on screen. jpayne@69: * GOT_FOCUS: Non-zero means this window has the input jpayne@69: * focus. jpayne@69: * BUTTON_DOWN: 1 means that a mouse button is currently down; jpayne@69: * this is used to implement grabs for the jpayne@69: * duration of button presses. jpayne@69: * UPDATE_SCROLLBARS: Non-zero means scrollbar(s) should be updated jpayne@69: * during next redisplay operation. jpayne@69: * NEED_REPICK This appears unused and should probably be jpayne@69: * ignored. jpayne@69: * OPTIONS_FREED The widget's options have been freed. jpayne@69: * DESTROYED The widget is going away. jpayne@69: */ jpayne@69: jpayne@69: #define GOT_SELECTION 1 jpayne@69: #define INSERT_ON 2 jpayne@69: #define GOT_FOCUS 4 jpayne@69: #define BUTTON_DOWN 8 jpayne@69: #define UPDATE_SCROLLBARS 0x10 jpayne@69: #define NEED_REPICK 0x20 jpayne@69: #define OPTIONS_FREED 0x40 jpayne@69: #define DESTROYED 0x80 jpayne@69: jpayne@69: /* jpayne@69: * Records of the following type define segment types in terms of a collection jpayne@69: * of procedures that may be called to manipulate segments of that type. jpayne@69: */ jpayne@69: jpayne@69: typedef TkTextSegment * Tk_SegSplitProc(struct TkTextSegment *segPtr, jpayne@69: int index); jpayne@69: typedef int Tk_SegDeleteProc(struct TkTextSegment *segPtr, jpayne@69: TkTextLine *linePtr, int treeGone); jpayne@69: typedef TkTextSegment * Tk_SegCleanupProc(struct TkTextSegment *segPtr, jpayne@69: TkTextLine *linePtr); jpayne@69: typedef void Tk_SegLineChangeProc(struct TkTextSegment *segPtr, jpayne@69: TkTextLine *linePtr); jpayne@69: typedef int Tk_SegLayoutProc(struct TkText *textPtr, jpayne@69: struct TkTextIndex *indexPtr, jpayne@69: TkTextSegment *segPtr, int offset, int maxX, jpayne@69: int maxChars, int noCharsYet, TkWrapMode wrapMode, jpayne@69: struct TkTextDispChunk *chunkPtr); jpayne@69: typedef void Tk_SegCheckProc(TkTextSegment *segPtr, jpayne@69: TkTextLine *linePtr); jpayne@69: jpayne@69: typedef struct Tk_SegType { jpayne@69: const char *name; /* Name of this kind of segment. */ jpayne@69: int leftGravity; /* If a segment has zero size (e.g. a mark or jpayne@69: * tag toggle), does it attach to character to jpayne@69: * its left or right? 1 means left, 0 means jpayne@69: * right. */ jpayne@69: Tk_SegSplitProc *splitProc; /* Procedure to split large segment into two jpayne@69: * smaller ones. */ jpayne@69: Tk_SegDeleteProc *deleteProc; jpayne@69: /* Procedure to call to delete segment. */ jpayne@69: Tk_SegCleanupProc *cleanupProc; jpayne@69: /* After any change to a line, this procedure jpayne@69: * is invoked for all segments left in the jpayne@69: * line to perform any cleanup they wish jpayne@69: * (e.g. joining neighboring segments). */ jpayne@69: Tk_SegLineChangeProc *lineChangeProc; jpayne@69: /* Invoked when a segment is about to be moved jpayne@69: * from its current line to an earlier line jpayne@69: * because of a deletion. The linePtr is that jpayne@69: * for the segment's old line. CleanupProc jpayne@69: * will be invoked after the deletion is jpayne@69: * finished. */ jpayne@69: Tk_SegLayoutProc *layoutProc; jpayne@69: /* Returns size information when figuring out jpayne@69: * what to display in window. */ jpayne@69: Tk_SegCheckProc *checkProc; /* Called during consistency checks to check jpayne@69: * internal consistency of segment. */ jpayne@69: } Tk_SegType; jpayne@69: jpayne@69: /* jpayne@69: * The following type and items describe different flags for text widget items jpayne@69: * to count. They are used in both tkText.c and tkTextIndex.c, in jpayne@69: * 'CountIndices', 'TkTextIndexBackChars', 'TkTextIndexForwChars', and jpayne@69: * 'TkTextIndexCount'. jpayne@69: */ jpayne@69: jpayne@69: typedef int TkTextCountType; jpayne@69: jpayne@69: #define COUNT_CHARS 0 jpayne@69: #define COUNT_INDICES 1 jpayne@69: #define COUNT_DISPLAY 2 jpayne@69: #define COUNT_DISPLAY_CHARS (COUNT_CHARS | COUNT_DISPLAY) jpayne@69: #define COUNT_DISPLAY_INDICES (COUNT_INDICES | COUNT_DISPLAY) jpayne@69: jpayne@69: /* jpayne@69: * The following structure is used to keep track of elided text taking account jpayne@69: * of different tag priorities, it is need for quick calculations of whether a jpayne@69: * single index is elided, and to start at a given index and maintain a jpayne@69: * correct elide state as we move or count forwards or backwards. jpayne@69: */ jpayne@69: jpayne@69: #define LOTSA_TAGS 1000 jpayne@69: typedef struct TkTextElideInfo { jpayne@69: int numTags; /* Total tags in widget. */ jpayne@69: int elide; /* Is the state currently elided. */ jpayne@69: int elidePriority; /* Tag priority controlling elide state. */ jpayne@69: TkTextSegment *segPtr; /* Segment to look at next. */ jpayne@69: int segOffset; /* Offset of segment within line. */ jpayne@69: int deftagCnts[LOTSA_TAGS]; jpayne@69: TkTextTag *deftagPtrs[LOTSA_TAGS]; jpayne@69: int *tagCnts; /* 0 or 1 depending if the tag with that jpayne@69: * priority is on or off. */ jpayne@69: TkTextTag **tagPtrs; /* Only filled with a tagPtr if the jpayne@69: * corresponding tagCnt is 1. */ jpayne@69: } TkTextElideInfo; jpayne@69: jpayne@69: /* jpayne@69: * The constant below is used to specify a line when what is really wanted is jpayne@69: * the entire text. For now, just use a very big number. jpayne@69: */ jpayne@69: jpayne@69: #define TK_END_OF_TEXT 1000000 jpayne@69: jpayne@69: /* jpayne@69: * The following definition specifies the maximum number of characters needed jpayne@69: * in a string to hold a position specifier. jpayne@69: */ jpayne@69: jpayne@69: #define TK_POS_CHARS 30 jpayne@69: jpayne@69: /* jpayne@69: * Mask used for those options which may impact the pixel height calculations jpayne@69: * of individual lines displayed in the widget. jpayne@69: */ jpayne@69: jpayne@69: #define TK_TEXT_LINE_GEOMETRY 1 jpayne@69: jpayne@69: /* jpayne@69: * Mask used for those options which may impact the start and end lines used jpayne@69: * in the widget. jpayne@69: */ jpayne@69: jpayne@69: #define TK_TEXT_LINE_RANGE 2 jpayne@69: jpayne@69: /* jpayne@69: * Used as 'action' values in calls to TkTextInvalidateLineMetrics jpayne@69: */ jpayne@69: jpayne@69: #define TK_TEXT_INVALIDATE_ONLY 0 jpayne@69: #define TK_TEXT_INVALIDATE_INSERT 1 jpayne@69: #define TK_TEXT_INVALIDATE_DELETE 2 jpayne@69: jpayne@69: /* jpayne@69: * Used as special 'pickPlace' values in calls to TkTextSetYView. Zero or jpayne@69: * positive values indicate a number of pixels. jpayne@69: */ jpayne@69: jpayne@69: #define TK_TEXT_PICKPLACE -1 jpayne@69: #define TK_TEXT_NOPIXELADJUST -2 jpayne@69: jpayne@69: /* jpayne@69: * Declarations for variables shared among the text-related files: jpayne@69: */ jpayne@69: jpayne@69: MODULE_SCOPE int tkBTreeDebug; jpayne@69: MODULE_SCOPE int tkTextDebug; jpayne@69: MODULE_SCOPE const Tk_SegType tkTextCharType; jpayne@69: MODULE_SCOPE const Tk_SegType tkTextLeftMarkType; jpayne@69: MODULE_SCOPE const Tk_SegType tkTextRightMarkType; jpayne@69: MODULE_SCOPE const Tk_SegType tkTextToggleOnType; jpayne@69: MODULE_SCOPE const Tk_SegType tkTextToggleOffType; jpayne@69: MODULE_SCOPE const Tk_SegType tkTextEmbWindowType; jpayne@69: MODULE_SCOPE const Tk_SegType tkTextEmbImageType; jpayne@69: jpayne@69: /* jpayne@69: * Convenience macros for use by B-tree clients which want to access pixel jpayne@69: * information on each line. Currently only used by TkTextDisp.c jpayne@69: */ jpayne@69: jpayne@69: #define TkBTreeLinePixelCount(text, line) \ jpayne@69: (line)->pixels[2*(text)->pixelReference] jpayne@69: #define TkBTreeLinePixelEpoch(text, line) \ jpayne@69: (line)->pixels[1+2*(text)->pixelReference] jpayne@69: jpayne@69: /* jpayne@69: * Declarations for procedures that are used by the text-related files but jpayne@69: * shouldn't be used anywhere else in Tk (or by Tk clients): jpayne@69: */ jpayne@69: jpayne@69: MODULE_SCOPE int TkBTreeAdjustPixelHeight(const TkText *textPtr, jpayne@69: TkTextLine *linePtr, int newPixelHeight, jpayne@69: int mergedLogicalLines); jpayne@69: MODULE_SCOPE int TkBTreeCharTagged(const TkTextIndex *indexPtr, jpayne@69: TkTextTag *tagPtr); jpayne@69: MODULE_SCOPE void TkBTreeCheck(TkTextBTree tree); jpayne@69: MODULE_SCOPE TkTextBTree TkBTreeCreate(TkSharedText *sharedTextPtr); jpayne@69: MODULE_SCOPE void TkBTreeAddClient(TkTextBTree tree, TkText *textPtr, jpayne@69: int defaultHeight); jpayne@69: MODULE_SCOPE void TkBTreeClientRangeChanged(TkText *textPtr, jpayne@69: int defaultHeight); jpayne@69: MODULE_SCOPE void TkBTreeRemoveClient(TkTextBTree tree, jpayne@69: TkText *textPtr); jpayne@69: MODULE_SCOPE void TkBTreeDestroy(TkTextBTree tree); jpayne@69: MODULE_SCOPE void TkBTreeDeleteIndexRange(TkTextBTree tree, jpayne@69: TkTextIndex *index1Ptr, TkTextIndex *index2Ptr); jpayne@69: MODULE_SCOPE int TkBTreeEpoch(TkTextBTree tree); jpayne@69: MODULE_SCOPE TkTextLine *TkBTreeFindLine(TkTextBTree tree, jpayne@69: const TkText *textPtr, int line); jpayne@69: MODULE_SCOPE TkTextLine *TkBTreeFindPixelLine(TkTextBTree tree, jpayne@69: const TkText *textPtr, int pixels, jpayne@69: int *pixelOffset); jpayne@69: MODULE_SCOPE TkTextTag **TkBTreeGetTags(const TkTextIndex *indexPtr, jpayne@69: const TkText *textPtr, int *numTagsPtr); jpayne@69: MODULE_SCOPE void TkBTreeInsertChars(TkTextBTree tree, jpayne@69: TkTextIndex *indexPtr, const char *string); jpayne@69: MODULE_SCOPE int TkBTreeLinesTo(const TkText *textPtr, jpayne@69: TkTextLine *linePtr); jpayne@69: MODULE_SCOPE int TkBTreePixelsTo(const TkText *textPtr, jpayne@69: TkTextLine *linePtr); jpayne@69: MODULE_SCOPE void TkBTreeLinkSegment(TkTextSegment *segPtr, jpayne@69: TkTextIndex *indexPtr); jpayne@69: MODULE_SCOPE TkTextLine *TkBTreeNextLine(const TkText *textPtr, jpayne@69: TkTextLine *linePtr); jpayne@69: MODULE_SCOPE int TkBTreeNextTag(TkTextSearch *searchPtr); jpayne@69: MODULE_SCOPE int TkBTreeNumPixels(TkTextBTree tree, jpayne@69: const TkText *textPtr); jpayne@69: MODULE_SCOPE TkTextLine *TkBTreePreviousLine(TkText *textPtr, jpayne@69: TkTextLine *linePtr); jpayne@69: MODULE_SCOPE int TkBTreePrevTag(TkTextSearch *searchPtr); jpayne@69: MODULE_SCOPE void TkBTreeStartSearch(TkTextIndex *index1Ptr, jpayne@69: TkTextIndex *index2Ptr, TkTextTag *tagPtr, jpayne@69: TkTextSearch *searchPtr); jpayne@69: MODULE_SCOPE void TkBTreeStartSearchBack(TkTextIndex *index1Ptr, jpayne@69: TkTextIndex *index2Ptr, TkTextTag *tagPtr, jpayne@69: TkTextSearch *searchPtr); jpayne@69: MODULE_SCOPE int TkBTreeTag(TkTextIndex *index1Ptr, jpayne@69: TkTextIndex *index2Ptr, TkTextTag *tagPtr, jpayne@69: int add); jpayne@69: MODULE_SCOPE void TkBTreeUnlinkSegment(TkTextSegment *segPtr, jpayne@69: TkTextLine *linePtr); jpayne@69: MODULE_SCOPE void TkTextBindProc(ClientData clientData, jpayne@69: XEvent *eventPtr); jpayne@69: MODULE_SCOPE void TkTextSelectionEvent(TkText *textPtr); jpayne@69: MODULE_SCOPE int TkTextIndexBbox(TkText *textPtr, jpayne@69: const TkTextIndex *indexPtr, int *xPtr, int *yPtr, jpayne@69: int *widthPtr, int *heightPtr, int *charWidthPtr); jpayne@69: MODULE_SCOPE int TkTextCharLayoutProc(TkText *textPtr, jpayne@69: TkTextIndex *indexPtr, TkTextSegment *segPtr, jpayne@69: int offset, int maxX, int maxChars, int noBreakYet, jpayne@69: TkWrapMode wrapMode, TkTextDispChunk *chunkPtr); jpayne@69: MODULE_SCOPE void TkTextCreateDInfo(TkText *textPtr); jpayne@69: MODULE_SCOPE int TkTextDLineInfo(TkText *textPtr, jpayne@69: const TkTextIndex *indexPtr, int *xPtr, int *yPtr, jpayne@69: int *widthPtr, int *heightPtr, int *basePtr); jpayne@69: MODULE_SCOPE void TkTextEmbWinDisplayProc(TkText *textPtr, jpayne@69: TkTextDispChunk *chunkPtr, int x, int y, jpayne@69: int lineHeight, int baseline, Display *display, jpayne@69: Drawable dst, int screenY); jpayne@69: MODULE_SCOPE TkTextTag *TkTextCreateTag(TkText *textPtr, jpayne@69: const char *tagName, int *newTag); jpayne@69: MODULE_SCOPE void TkTextFreeDInfo(TkText *textPtr); jpayne@69: MODULE_SCOPE void TkTextDeleteTag(TkText *textPtr, TkTextTag *tagPtr); jpayne@69: MODULE_SCOPE void TkTextFreeTag(TkText *textPtr, TkTextTag *tagPtr); jpayne@69: MODULE_SCOPE int TkTextGetObjIndex(Tcl_Interp *interp, TkText *textPtr, jpayne@69: Tcl_Obj *idxPtr, TkTextIndex *indexPtr); jpayne@69: MODULE_SCOPE int TkTextSharedGetObjIndex(Tcl_Interp *interp, jpayne@69: TkSharedText *sharedTextPtr, Tcl_Obj *idxPtr, jpayne@69: TkTextIndex *indexPtr); jpayne@69: MODULE_SCOPE const TkTextIndex *TkTextGetIndexFromObj(Tcl_Interp *interp, jpayne@69: TkText *textPtr, Tcl_Obj *objPtr); jpayne@69: MODULE_SCOPE TkTextTabArray *TkTextGetTabs(Tcl_Interp *interp, jpayne@69: TkText *textPtr, Tcl_Obj *stringPtr); jpayne@69: MODULE_SCOPE void TkTextFindDisplayLineEnd(TkText *textPtr, jpayne@69: TkTextIndex *indexPtr, int end, int *xOffset); jpayne@69: MODULE_SCOPE void TkTextIndexBackChars(const TkText *textPtr, jpayne@69: const TkTextIndex *srcPtr, int count, jpayne@69: TkTextIndex *dstPtr, TkTextCountType type); jpayne@69: MODULE_SCOPE int TkTextIndexCmp(const TkTextIndex *index1Ptr, jpayne@69: const TkTextIndex *index2Ptr); jpayne@69: MODULE_SCOPE int TkTextIndexCountBytes(const TkText *textPtr, jpayne@69: const TkTextIndex *index1Ptr, jpayne@69: const TkTextIndex *index2Ptr); jpayne@69: MODULE_SCOPE int TkTextIndexCount(const TkText *textPtr, jpayne@69: const TkTextIndex *index1Ptr, jpayne@69: const TkTextIndex *index2Ptr, jpayne@69: TkTextCountType type); jpayne@69: MODULE_SCOPE void TkTextIndexForwChars(const TkText *textPtr, jpayne@69: const TkTextIndex *srcPtr, int count, jpayne@69: TkTextIndex *dstPtr, TkTextCountType type); jpayne@69: MODULE_SCOPE void TkTextIndexOfX(TkText *textPtr, int x, jpayne@69: TkTextIndex *indexPtr); jpayne@69: MODULE_SCOPE int TkTextIndexYPixels(TkText *textPtr, jpayne@69: const TkTextIndex *indexPtr); jpayne@69: MODULE_SCOPE TkTextSegment *TkTextIndexToSeg(const TkTextIndex *indexPtr, jpayne@69: int *offsetPtr); jpayne@69: MODULE_SCOPE void TkTextLostSelection(ClientData clientData); jpayne@69: MODULE_SCOPE TkTextIndex *TkTextMakeCharIndex(TkTextBTree tree, TkText *textPtr, jpayne@69: int lineIndex, int charIndex, jpayne@69: TkTextIndex *indexPtr); jpayne@69: MODULE_SCOPE int TkTextMeasureDown(TkText *textPtr, jpayne@69: TkTextIndex *srcPtr, int distance); jpayne@69: MODULE_SCOPE void TkTextFreeElideInfo(TkTextElideInfo *infoPtr); jpayne@69: MODULE_SCOPE int TkTextIsElided(const TkText *textPtr, jpayne@69: const TkTextIndex *indexPtr, jpayne@69: TkTextElideInfo *infoPtr); jpayne@69: MODULE_SCOPE int TkTextMakePixelIndex(TkText *textPtr, jpayne@69: int pixelIndex, TkTextIndex *indexPtr); jpayne@69: MODULE_SCOPE void TkTextInvalidateLineMetrics( jpayne@69: TkSharedText *sharedTextPtr, TkText *textPtr, jpayne@69: TkTextLine *linePtr, int lineCount, int action); jpayne@69: MODULE_SCOPE int TkTextUpdateLineMetrics(TkText *textPtr, int lineNum, jpayne@69: int endLine, int doThisMuch); jpayne@69: MODULE_SCOPE int TkTextUpdateOneLine(TkText *textPtr, jpayne@69: TkTextLine *linePtr, int pixelHeight, jpayne@69: TkTextIndex *indexPtr, int partialCalc); jpayne@69: MODULE_SCOPE int TkTextMarkCmd(TkText *textPtr, Tcl_Interp *interp, jpayne@69: int objc, Tcl_Obj *const objv[]); jpayne@69: MODULE_SCOPE int TkTextMarkNameToIndex(TkText *textPtr, jpayne@69: const char *name, TkTextIndex *indexPtr); jpayne@69: MODULE_SCOPE void TkTextMarkSegToIndex(TkText *textPtr, jpayne@69: TkTextSegment *markPtr, TkTextIndex *indexPtr); jpayne@69: MODULE_SCOPE void TkTextEventuallyRepick(TkText *textPtr); jpayne@69: MODULE_SCOPE Bool TkTextPendingsync(TkText *textPtr); jpayne@69: MODULE_SCOPE void TkTextPickCurrent(TkText *textPtr, XEvent *eventPtr); jpayne@69: MODULE_SCOPE void TkTextPixelIndex(TkText *textPtr, int x, int y, jpayne@69: TkTextIndex *indexPtr, int *nearest); jpayne@69: MODULE_SCOPE Tcl_Obj * TkTextNewIndexObj(TkText *textPtr, jpayne@69: const TkTextIndex *indexPtr); jpayne@69: MODULE_SCOPE void TkTextRedrawRegion(TkText *textPtr, int x, int y, jpayne@69: int width, int height); jpayne@69: MODULE_SCOPE void TkTextRedrawTag(TkSharedText *sharedTextPtr, jpayne@69: TkText *textPtr, TkTextIndex *index1Ptr, jpayne@69: TkTextIndex *index2Ptr, TkTextTag *tagPtr, jpayne@69: int withTag); jpayne@69: MODULE_SCOPE void TkTextRelayoutWindow(TkText *textPtr, int mask); jpayne@69: MODULE_SCOPE int TkTextScanCmd(TkText *textPtr, Tcl_Interp *interp, jpayne@69: int objc, Tcl_Obj *const objv[]); jpayne@69: MODULE_SCOPE int TkTextSeeCmd(TkText *textPtr, Tcl_Interp *interp, jpayne@69: int objc, Tcl_Obj *const objv[]); jpayne@69: MODULE_SCOPE int TkTextSegToOffset(const TkTextSegment *segPtr, jpayne@69: const TkTextLine *linePtr); jpayne@69: MODULE_SCOPE void TkTextSetYView(TkText *textPtr, jpayne@69: TkTextIndex *indexPtr, int pickPlace); jpayne@69: MODULE_SCOPE int TkTextTagCmd(TkText *textPtr, Tcl_Interp *interp, jpayne@69: int objc, Tcl_Obj *const objv[]); jpayne@69: MODULE_SCOPE int TkTextImageCmd(TkText *textPtr, Tcl_Interp *interp, jpayne@69: int objc, Tcl_Obj *const objv[]); jpayne@69: MODULE_SCOPE int TkTextImageIndex(TkText *textPtr, jpayne@69: const char *name, TkTextIndex *indexPtr); jpayne@69: MODULE_SCOPE int TkTextWindowCmd(TkText *textPtr, Tcl_Interp *interp, jpayne@69: int objc, Tcl_Obj *const objv[]); jpayne@69: MODULE_SCOPE int TkTextWindowIndex(TkText *textPtr, const char *name, jpayne@69: TkTextIndex *indexPtr); jpayne@69: MODULE_SCOPE int TkTextYviewCmd(TkText *textPtr, Tcl_Interp *interp, jpayne@69: int objc, Tcl_Obj *const objv[]); jpayne@69: MODULE_SCOPE void TkTextWinFreeClient(Tcl_HashEntry *hPtr, jpayne@69: TkTextEmbWindowClient *client); jpayne@69: MODULE_SCOPE void TkTextRunAfterSyncCmd(ClientData clientData); jpayne@69: MODULE_SCOPE int TkTextIndexAdjustToStartEnd(TkText *textPtr, jpayne@69: TkTextIndex *indexPtr, int err); jpayne@69: #endif /* _TKTEXT */ jpayne@69: jpayne@69: /* jpayne@69: * Local Variables: jpayne@69: * mode: c jpayne@69: * c-basic-offset: 4 jpayne@69: * fill-column: 78 jpayne@69: * End: jpayne@69: */