📄 tktext.h
字号:
/* * 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.46 96/11/25 11:26:12 */#ifndef _TKTEXT#define _TKTEXT#ifndef _TK#include "tk.h"#endif/* * Opaque types for structures whose guts are only needed by a single * file: */typedef struct TkTextBTree *TkTextBTree;/* * 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 { struct Node *parentPtr; /* Pointer to parent node containing * line. */ struct TkTextLine *nextPtr; /* Next in linked list of lines with * same parent node in B-tree. NULL * means end of list. */ struct TkTextSegment *segPtr; /* First in ordered list of segments * 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 { struct TkTextTag *tagPtr; /* Tag that starts or ends here. */ int inNodeCounts; /* 1 means this toggle has been * 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 { struct TkText *textPtr; /* Overall information about text * widget. */ TkTextLine *linePtr; /* Line structure that contains the * segment. */ Tcl_HashEntry *hPtr; /* Pointer to hash table entry for mark * (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 { struct TkText *textPtr; /* Information about the overall text * widget. */ TkTextLine *linePtr; /* Line structure that contains this * window. */ Tk_Window tkwin; /* Window for this segment. NULL * means that the window hasn't * been created yet. */ char *create; /* Script to create window on-demand. * NULL means no such script. * Malloc-ed. */ int align; /* How to align window in vertical * space. See definitions in * tkTextWind.c. */ int padX, padY; /* Padding to leave around each side * of window, in pixels. */ int stretch; /* Should window stretch to fill * vertical space of line (except for * pady)? 0 or 1. */ int chunkCount; /* Number of display chunks that * refer to this window. */ int displayed; /* Non-zero means that the window * has been displayed on the screen * recently. */} TkTextEmbWindow;/* * A structure of the following type holds information for each image * embedded in a text widget. This information is only used by the * file tkTextImage.c */typedef struct TkTextEmbImage { struct TkText *textPtr; /* Information about the overall text * widget. */ TkTextLine *linePtr; /* Line structure that contains this * image. */ char *imageString; /* Name of the image for this segment */ char *imageName; /* Name used by text widget to identify * this image. May be unique-ified */ char *name; /* Name used in the hash table. * used by "image names" to identify * this instance of the image */ Tk_Image image; /* Image for this segment. NULL * means that the image hasn't * been created yet. */ int align; /* How to align image in vertical * space. See definitions in * tkTextImage.c. */ int padX, padY; /* Padding to leave around each side * of image, in pixels. */ int chunkCount; /* Number of display chunks that * refer to this image. */} TkTextEmbImage;/* * The data structure below defines line segments. */typedef struct TkTextSegment { struct Tk_SegType *typePtr; /* Pointer to record describing * segment's type. */ struct TkTextSegment *nextPtr; /* Next in list of segments for this * line, or NULL for end of list. */ int size; /* Size of this segment (# of bytes * of index space it occupies). */ union { char chars[4]; /* Characters that make up character * info. Actual length varies to * hold as many characters as needed.*/ TkTextToggle toggle; /* Information about tag toggle. */ TkTextMark mark; /* Information about mark. */ TkTextEmbWindow ew; /* Information about embedded * window. */ TkTextEmbImage ei; /* Information about embedded * image. */ } body;} TkTextSegment;/* * 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 { TkTextBTree tree; /* Tree containing desired position. */ TkTextLine *linePtr; /* Pointer to line containing position * of interest. */ int charIndex; /* Index within line of desired * character (0 means first one). */} TkTextIndex;/* * Types for procedure pointers stored in TkTextDispChunk strutures: */typedef struct TkTextDispChunk TkTextDispChunk;typedef void Tk_ChunkDisplayProc _ANSI_ARGS_(( TkTextDispChunk *chunkPtr, int x, int y, int height, int baseline, Display *display, Drawable dst, int screenY));typedef void Tk_ChunkUndisplayProc _ANSI_ARGS_(( struct TkText *textPtr, TkTextDispChunk *chunkPtr));typedef int Tk_ChunkMeasureProc _ANSI_ARGS_(( TkTextDispChunk *chunkPtr, int x));typedef void Tk_ChunkBboxProc _ANSI_ARGS_(( TkTextDispChunk *chunkPtr, int index, int y, int lineHeight, int baseline, int *xPtr, int *yPtr, int *widthPtr, int *heightPtr));/* * 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). */ struct TkTextDispChunk *nextPtr; /* Next chunk in the display line * or NULL for the end of the list. */ struct TextStyle *stylePtr; /* Display information, known only * to tkTextDisp.c. */ /* * The fields below are set by the layoutProc that creates the * chunk. */ Tk_ChunkDisplayProc *displayProc; /* Procedure to invoke to draw this * chunk on the display or an * off-screen pixmap. */ Tk_ChunkUndisplayProc *undisplayProc; /* Procedure to invoke when segment * ceases to be displayed on screen * anymore. */ Tk_ChunkMeasureProc *measureProc; /* Procedure to find character under * a given x-location. */ Tk_ChunkBboxProc *bboxProc; /* Procedure to find bounding box * of character in chunk. */ int numChars; /* Number of characters that will be * displayed in the chunk. */ int minAscent; /* Minimum space above the baseline * needed by this chunk. */ int minDescent; /* Minimum space below the baseline * needed by this chunk. */ int minHeight; /* Minimum total line height needed * by this chunk. */ int width; /* Width of this chunk, in pixels. * Initially set by chunk-specific * code, but may be increased to * include tab or extra space at end * of line. */ int breakIndex; /* Index within chunk of last * acceptable position for a line * (break just before this character). * <= 0 means don't break during or * immediately after this chunk. */ ClientData clientData; /* Additional information for use * 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 { char *name; /* Name of this tag. This field is actually * a pointer to the key from the entry in * textPtr->tagTable, so it needn't be freed * explicitly. */ int priority; /* Priority of this tag within widget. 0 * means lowest priority. Exactly one tag * has each integer value between 0 and * numTags-1. */ struct Node *tagRootPtr; /* Pointer into the B-Tree at the lowest * node that completely dominates the ranges * of text occupied by the tag. At this
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -