/*
* tkText.h --
*
* Declarations shared among the files that implement text
* widgets.
*
* Copyright (c) 1992-1994 The Regents of the University of California.
* Copyright (c) 1994-1995 Sun Microsystems, Inc.
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
* SCCS: @(#) tkText.h 1.44 96/02/15 18:51:31
*/
#ifndef _TKTEXT
#define _TKTEXT
#ifndef _TK
#include "tk.h"
#endif
/*
* Opaque types for structures whose guts are only needed by a single
* file:
*/
/*
* The data structure below defines a single line of text (from newline
* to newline, not necessarily what appears on one line of the screen).
*/
typedef struct TkTextLine {
* line. */
* same parent node in B-tree. NULL
* means end of list. */
* that make up the line. */
} TkTextLine;
/*
* -----------------------------------------------------------------------
* Segments: each line is divided into one or more segments, where each
* segment is one of several things, such as a group of characters, a
* tag toggle, a mark, or an embedded widget. Each segment starts with
* a standard header followed by a body that varies from type to type.
* -----------------------------------------------------------------------
*/
/*
* The data structure below defines the body of a segment that represents
* a tag toggle. There is one of these structures at both the beginning
* and end of each tagged range.
*/
typedef struct TkTextToggle {
* accounted for in node toggle
* counts; 0 means it hasn't, yet. */
} TkTextToggle;
/*
* The data structure below defines line segments that represent
* marks. There is one of these for each mark in the text.
*/
typedef struct TkTextMark {
* widget. */
* segment. */
* (in textPtr->markTable). */
} TkTextMark;
/*
* A structure of the following type holds information for each window
* embedded in a text widget. This information is only used by the
* file tkTextWind.c
*/
typedef struct TkTextEmbWindow {
* widget. */
* window. */
* means that the window hasn't
* been created yet. */
* NULL means no such script.
* Malloc-ed. */
* space. See definitions in
* tkTextWind.c. */
* of window, in pixels. */
* vertical space of line (except for
* pady)? 0 or 1. */
* refer to this window. */
* has been displayed on the screen
* recently. */
/*
* The data structure below defines line segments.
*/
typedef struct TkTextSegment {
* segment's type. */
* line, or NULL for end of list. */
* of index space it occupies). */
union {
* info. Actual length varies to
* hold as many characters as needed.*/
* window. */
} body;
/*
* Data structures of the type defined below are used during the
* execution of Tcl commands to keep track of various interesting
* places in a text. An index is only valid up until the next
* modification to the character structure of the b-tree so they
* can't be retained across Tcl commands. However, mods to marks
* or tags don't invalidate indices.
*/
typedef struct TkTextIndex {
* of interest. */
* character (0 means first one). */
} TkTextIndex;
/*
* Types for procedure pointers stored in TkTextDispChunk strutures:
*/
TkTextDispChunk *chunkPtr, int x, int y,
TkTextDispChunk *chunkPtr, int x));
/*
* The structure below represents a chunk of stuff that is displayed
* together on the screen. This structure is allocated and freed by
* generic display code but most of its fields are filled in by
* segment-type-specific code.
*/
struct TkTextDispChunk {
/*
* The fields below are set by the type-independent code before
* calling the segment-type-specific layoutProc. They should not
* be modified by segment-type-specific code.
*/
int x; /* X position of chunk, in pixels.
* This position is measured from the
* left edge of the logical line,
* not from the left edge of the
* window (i.e. it doesn't change
* under horizontal scrolling). */
* or NULL for the end of the list. */
* to tkTextDisp.c. */
/*
* The fields below are set by the layoutProc that creates the
* chunk.
*/
* chunk on the display or an
* off-screen pixmap. */
/* Procedure to invoke when segment
* ceases to be displayed on screen
* anymore. */
* a given x-location. */
* of character in chunk. */
* displayed in the chunk. */
* needed by this chunk. */
* needed by this chunk. */
* by this chunk. */
* Initially set by chunk-specific
* code, but may be increased to
* include tab or extra space at end
* of line. */
* acceptable position for a line
* (break just before this character).
* <= 0 means don't break during or
* immediately after this chunk. */
* of displayProc and undisplayProc. */
};
/*
* One data structure of the following type is used for each tag in a
* text widget. These structures are kept in textPtr->tagTable and
* referred to in other structures.
*/
typedef struct TkTextTag {
* a pointer to the key from the entry in
* textPtr->tagTable, so it needn't be freed
* explicitly. */
* means lowest priority. Exactly one tag
* has each integer value between 0 and
* numTags-1. */
* node that completely dominates the ranges
* of text occupied by the tag. At this
* node there is no information about the
* tag. One or more children of the node
* do contain information about the tag. */
/*
* Information for displaying text with this tag. The information
* belows acts as an override on information specified by lower-priority
* tags. If no value is specified, then the next-lower-priority tag
* on the text determins the value. The text widget itself provides
* defaults if no tag specifies an override.
*/
* no value specified here. */
* NULL means option not specified. */
* NULL means option not specified. */
* means no value specified here. */
* no value specified here. */
* no value specified here. */
* foreground stuff. None means no value
* specified here.*/
* NULL means option not specified. */
* TK_JUSTIFY_RIGHT, or TK_JUSTIFY_CENTER.
* Only valid if justifyString is non-NULL. */
* NULL means option not specified. */
* each text line, in pixels. Only valid
* if lMargin1String is non-NULL. */
* NULL means option not specified. */
* lines of each text line, in pixels. Only
* valid if lMargin2String is non-NULL. */
* NULL means option not specified. */
* baseline of line. Used for superscripts
* and subscripts. Only valid if
* offsetString is non-NULL. */
* NULL means option not specified. */
* middle of text. Only valid if
* overstrikeString is non-NULL. */
* NULL means option not specified. */
* valid if rMarginString is non-NULL. */
* NULL means option not specified. */
* line for text line. Only valid if
* spacing1String is non-NULL. */
* NULL means option not specified. */
* lines for the same text line. Only valid
* if spacing2String is non-NULL. */
* NULL means option not specified. */
* line for text line. Only valid if
* spacing3String is non-NULL. */
* NULL means option not specified. */
/* Info about tabs for tag (malloc-ed)
* or NULL. Corresponds to tabString. */
* NULL means option not specified. */
* text. Only valid if underlineString is
* non-NULL. */
* Must be tkTextCharUid, tkTextNoneUid,
* tkTextWordUid, or NULL to use wrapMode
* for whole widget. */
* way information is displayed on the screen
* (so need to redisplay if tag changes). */
} TkTextTag;
/*
* The data structure below is used for searching a B-tree for transitions
* on a single tag (or for all tag transitions). No code outside of
* tkTextBTree.c should ever modify any of the fields in these structures,
* but it's OK to use them for read-only information.
*/
typedef struct TkTextSearch {
* returned by TkBTreeNextTag, or
* index of start of segment
* containing starting position for
* search if TkBTreeNextTag hasn't
* been called yet, or same as
* stopIndex if search is over. */
* call to TkBTreeNextTag, or NULL if
* TkBTreeNextTag hasn't returned
* anything yet. */
* call to TkBTreeNextTag. */
* considering this segment. */
* allTags is non-zero). */
* curIndex and stopIndex). When
* this becomes <= 0 the search is
* over. */
* search for transitions on all
* tags. */
} TkTextSearch;
/*
* The following data structure describes a single tab stop.
*/
typedef struct TkTextTab {
* from the left margin (lmargin2) of
* the text. */
* to the text. */
} TkTextTab;
typedef struct TkTextTabArray {
* will be numTabs. THIS FIELD MUST
* BE THE LAST IN THE STRUCTURE. */
/*
* A data structure of the following type is kept for each text widget that
* currently exists for this process:
*/
typedef struct TkText {
* means that the window has been destroyed
* but the data structures haven't yet been
* cleaned up.*/
* things, to allow resources to be freed
* even after tkwin has gone away. */
* to delete widget command. */
* widget. */
* pointers to TkTextTag structures. */
* widget; needed to keep track of
* priorities. */
* pointers to mark segments. */
* to pointers to window segments. If a
* window segment doesn't yet have an
* associated window, there is no entry for
* it here. */
* when disabled. */
/*
* Default information for displaying (may be overridden by tags
* applied to ranges of characters).
*/
* default background. */
* widget. */
* widget: TK_RELIEF_RAISED etc. */
* around widget when it has the focus.
* <= 0 means don't draw a highlight. */
/* Color for drawing traversal highlight
* area when highlight is off. */
* font. */
* line for each text line. */
* for the same text line. */
* line for each text line. */
/* Information about tab stops (malloc'ed).
* NULL means perform default tabbing
* behavior. */
/*
* Additional information used for displaying:
*/
* tkTextCharUid, tkTextNoneUid, or
* tkTextWordUid. */
* in characters. */
* to window manager. */
* detect changes in size. */
* line of window. */
/*
* Information related to selection.
*/
* a new selection has been made. */
* characters. This is a copy of information
* in *cursorTagPtr, so it shouldn't be
* explicitly freed. */
* if not specified (malloc'ed). */
* This is a copy of information in
* *cursorTagPtr, so it shouldn't be
* explicitly freed. */
* selection. */
* This index identifies the next character
* to be returned from the selection. */
* in a way that interferes with selection
* retrieval: used to abort incremental
* selection retrievals. */
* selLine and selCh. -1 means neither
* this information nor selIndex is of any
* use. */
/*
* Information related to insertion cursor:
*/
/* Points to segment for "insert" mark. */
* cursor. */
* in "on" state for each blink. */
* in "off" state for each blink. */
/* Timer handler used to blink cursor on and
* off. */
/*
* Information used for event bindings associated with tags:
*/
/* Table of all bindings currently defined
* for this widget. NULL means that no
* bindings exist, so the table hasn't been
* created. Each "object" used for this
* table is the address of a tag. */
/* Pointer to segment for "current" mark,
* or NULL if none. */
* was chosen. Must be saved so that we
* can repick after modifications to the
* text. */
* at current mark. */
* mark, or NULL if none. */
/*
* Miscellaneous additional information:
*/
* the C code, but used by keyboard traversal
* scripts. Malloc'ed, but may be NULL. */
* horizontal scrollbar when view changes. */
* vertical scrollbar when view changes. */
* definitions. */
} TkText;
/*
* Flag values for TkText records:
*
* GOT_SELECTION: Non-zero means we've already claimed the
* selection.
* INSERT_ON: Non-zero means insertion cursor should be
* displayed on screen.
* GOT_FOCUS: Non-zero means this window has the input
* focus.
* BUTTON_DOWN: 1 means that a mouse button is currently
* down; this is used to implement grabs
* for the duration of button presses.
* UPDATE_SCROLLBARS: Non-zero means scrollbar(s) should be updated
* during next redisplay operation.
*/
/*
* Records of the following type define segment types in terms of
* a collection of procedures that may be called to manipulate
* segments of that type.
*/
struct TkTextSegment *segPtr,
struct TkTextDispChunk *chunkPtr));
TkTextLine *linePtr));
typedef struct Tk_SegType {
* mark or tag toggle), does it
* attach to character to its left
* or right? 1 means left, 0 means
* right. */
* into two smaller ones. */
* segment. */
* procedure is invoked for all
* segments left in the line to
* perform any cleanup they wish
* (e.g. joining neighboring
* segments). */
/* Invoked when a segment is about
* to be moved from its current line
* to an earlier line because of
* a deletion. The linePtr is that
* for the segment's old line.
* CleanupProc will be invoked after
* the deletion is finished. */
* figuring out what to display in
* window. */
* to check internal consistency of
* segment. */
} Tk_SegType;
/*
* The constant below is used to specify a line when what is really
* wanted is the entire text. For now, just use a very big number.
*/
/*
* The following definition specifies the maximum number of characters
* needed in a string to hold a position specifier.
*/
/*
* Declarations for variables shared among the text-related files:
*/
extern int tkBTreeDebug;
extern int tkTextDebug;
extern Tk_SegType tkTextCharType;
extern Tk_Uid tkTextCharUid;
extern Tk_Uid tkTextDisabledUid;
extern Tk_SegType tkTextLeftMarkType;
extern Tk_Uid tkTextNoneUid;
extern Tk_Uid tkTextNormalUid;
extern Tk_SegType tkTextRightMarkType;
extern Tk_SegType tkTextToggleOnType;
extern Tk_SegType tkTextToggleOffType;
extern Tk_Uid tkTextWordUid;
/*
* Declarations for procedures that are used by the text-related files
* but shouldn't be used anywhere else in Tk (or by Tk clients):
*/
TkTextIndex *index2Ptr));
int line));
int *numTagsPtr));
char *string));
TkTextIndex *indexPtr));
int add));
char *tagName));
TkTextIndex *indexPtr));
TkTextIndex *index2Ptr));
int *offsetPtr));
extern void TkTextInsertDisplayProc _ANSI_ARGS_((
int screenY));
extern void TkTextLostSelection _ANSI_ARGS_((
TkTextIndex *indexPtr));
int x, int y, TkTextIndex *indexPtr));
char *string));
TkTextLine *linePtr));
TkTextIndex *indexPtr));
#endif /* _TKTEXT */