tkText.h 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173
  1. /*
  2. * tkText.h --
  3. *
  4. * Declarations shared among the files that implement text widgets.
  5. *
  6. * Copyright (c) 1992-1994 The Regents of the University of California.
  7. * Copyright (c) 1994-1995 Sun Microsystems, Inc.
  8. *
  9. * See the file "license.terms" for information on usage and redistribution of
  10. * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  11. */
  12. #ifndef _TKTEXT
  13. #define _TKTEXT
  14. #ifndef _TK
  15. #include "tk.h"
  16. #endif
  17. #ifndef _TKUNDO
  18. #include "tkUndo.h"
  19. #endif
  20. /*
  21. * The data structure below defines a single logical line of text (from
  22. * newline to newline, not necessarily what appears on one display line of the
  23. * screen).
  24. */
  25. typedef struct TkTextLine {
  26. struct Node *parentPtr; /* Pointer to parent node containing line. */
  27. struct TkTextLine *nextPtr; /* Next in linked list of lines with same
  28. * parent node in B-tree. NULL means end of
  29. * list. */
  30. struct TkTextSegment *segPtr;
  31. /* First in ordered list of segments that make
  32. * up the line. */
  33. int *pixels; /* Array containing two integers for each
  34. * referring text widget. The first of these
  35. * is the number of vertical pixels taken up
  36. * by this line, whether currently displayed
  37. * or not. This number is only updated
  38. * asychronously. The second of these is the
  39. * last epoch at which the pixel height was
  40. * recalculated. */
  41. } TkTextLine;
  42. /*
  43. * -----------------------------------------------------------------------
  44. * Segments: each line is divided into one or more segments, where each
  45. * segment is one of several things, such as a group of characters, a tag
  46. * toggle, a mark, or an embedded widget. Each segment starts with a standard
  47. * header followed by a body that varies from type to type.
  48. * -----------------------------------------------------------------------
  49. */
  50. /*
  51. * The data structure below defines the body of a segment that represents a
  52. * tag toggle. There is one of these structures at both the beginning and end
  53. * of each tagged range.
  54. */
  55. typedef struct TkTextToggle {
  56. struct TkTextTag *tagPtr; /* Tag that starts or ends here. */
  57. int inNodeCounts; /* 1 means this toggle has been accounted for
  58. * in node toggle counts; 0 means it hasn't,
  59. * yet. */
  60. } TkTextToggle;
  61. /*
  62. * The data structure below defines line segments that represent marks. There
  63. * is one of these for each mark in the text.
  64. */
  65. typedef struct TkTextMark {
  66. struct TkText *textPtr; /* Overall information about text widget. */
  67. TkTextLine *linePtr; /* Line structure that contains the
  68. * segment. */
  69. Tcl_HashEntry *hPtr; /* Pointer to hash table entry for mark (in
  70. * sharedTextPtr->markTable). */
  71. } TkTextMark;
  72. /*
  73. * A structure of the following type holds information for each window
  74. * embedded in a text widget. This information is only used by the file
  75. * tkTextWind.c
  76. */
  77. typedef struct TkTextEmbWindowClient {
  78. struct TkText *textPtr; /* Information about the overall text
  79. * widget. */
  80. Tk_Window tkwin; /* Window for this segment. NULL means that
  81. * the window hasn't been created yet. */
  82. int chunkCount; /* Number of display chunks that refer to this
  83. * window. */
  84. int displayed; /* Non-zero means that the window has been
  85. * displayed on the screen recently. */
  86. struct TkTextSegment *parent;
  87. struct TkTextEmbWindowClient *next;
  88. } TkTextEmbWindowClient;
  89. typedef struct TkTextEmbWindow {
  90. struct TkSharedText *sharedTextPtr;
  91. /* Information about the shared portion of the
  92. * text widget. */
  93. Tk_Window tkwin; /* Window for this segment. This is just a
  94. * temporary value, copied from 'clients', to
  95. * make option table updating easier. NULL
  96. * means that the window hasn't been created
  97. * yet. */
  98. TkTextLine *linePtr; /* Line structure that contains this
  99. * window. */
  100. char *create; /* Script to create window on-demand. NULL
  101. * means no such script. Malloc-ed. */
  102. int align; /* How to align window in vertical space. See
  103. * definitions in tkTextWind.c. */
  104. int padX, padY; /* Padding to leave around each side of
  105. * window, in pixels. */
  106. int stretch; /* Should window stretch to fill vertical
  107. * space of line (except for pady)? 0 or 1. */
  108. Tk_OptionTable optionTable; /* Token representing the configuration
  109. * specifications. */
  110. TkTextEmbWindowClient *clients;
  111. /* Linked list of peer-widget specific
  112. * information for this embedded window. */
  113. } TkTextEmbWindow;
  114. /*
  115. * A structure of the following type holds information for each image embedded
  116. * in a text widget. This information is only used by the file tkTextImage.c
  117. */
  118. typedef struct TkTextEmbImage {
  119. struct TkSharedText *sharedTextPtr;
  120. /* Information about the shared portion of the
  121. * text widget. This is used when the image
  122. * changes or is deleted. */
  123. TkTextLine *linePtr; /* Line structure that contains this image. */
  124. char *imageString; /* Name of the image for this segment. */
  125. char *imageName; /* Name used by text widget to identify this
  126. * image. May be unique-ified. */
  127. char *name; /* Name used in the hash table. Used by
  128. * "image names" to identify this instance of
  129. * the image. */
  130. Tk_Image image; /* Image for this segment. NULL means that the
  131. * image hasn't been created yet. */
  132. int align; /* How to align image in vertical space. See
  133. * definitions in tkTextImage.c. */
  134. int padX, padY; /* Padding to leave around each side of image,
  135. * in pixels. */
  136. int chunkCount; /* Number of display chunks that refer to this
  137. * image. */
  138. Tk_OptionTable optionTable; /* Token representing the configuration
  139. * specifications. */
  140. } TkTextEmbImage;
  141. /*
  142. * The data structure below defines line segments.
  143. */
  144. typedef struct TkTextSegment {
  145. const struct Tk_SegType *typePtr;
  146. /* Pointer to record describing segment's
  147. * type. */
  148. struct TkTextSegment *nextPtr;
  149. /* Next in list of segments for this line, or
  150. * NULL for end of list. */
  151. int size; /* Size of this segment (# of bytes of index
  152. * space it occupies). */
  153. union {
  154. char chars[TKFLEXARRAY]; /* Characters that make up character info.
  155. * Actual length varies to hold as many
  156. * characters as needed.*/
  157. TkTextToggle toggle; /* Information about tag toggle. */
  158. TkTextMark mark; /* Information about mark. */
  159. TkTextEmbWindow ew; /* Information about embedded window. */
  160. TkTextEmbImage ei; /* Information about embedded image. */
  161. } body;
  162. } TkTextSegment;
  163. /*
  164. * Data structures of the type defined below are used during the execution of
  165. * Tcl commands to keep track of various interesting places in a text. An
  166. * index is only valid up until the next modification to the character
  167. * structure of the b-tree so they can't be retained across Tcl commands.
  168. * However, mods to marks or tags don't invalidate indices.
  169. */
  170. typedef struct TkTextIndex {
  171. TkTextBTree tree; /* Tree containing desired position. */
  172. TkTextLine *linePtr; /* Pointer to line containing position of
  173. * interest. */
  174. int byteIndex; /* Index within line of desired character (0
  175. * means first one). */
  176. struct TkText *textPtr; /* May be NULL, but otherwise the text widget
  177. * with which this index is associated. If not
  178. * NULL, then we have a refCount on the
  179. * widget. */
  180. } TkTextIndex;
  181. /*
  182. * Types for procedure pointers stored in TkTextDispChunk strutures:
  183. */
  184. typedef struct TkTextDispChunk TkTextDispChunk;
  185. typedef void Tk_ChunkDisplayProc(struct TkText *textPtr,
  186. TkTextDispChunk *chunkPtr, int x, int y,
  187. int height, int baseline, Display *display,
  188. Drawable dst, int screenY);
  189. typedef void Tk_ChunkUndisplayProc(struct TkText *textPtr,
  190. TkTextDispChunk *chunkPtr);
  191. typedef int Tk_ChunkMeasureProc(TkTextDispChunk *chunkPtr, int x);
  192. typedef void Tk_ChunkBboxProc(struct TkText *textPtr,
  193. TkTextDispChunk *chunkPtr, int index, int y,
  194. int lineHeight, int baseline, int *xPtr,
  195. int *yPtr, int *widthPtr, int *heightPtr);
  196. /*
  197. * The structure below represents a chunk of stuff that is displayed together
  198. * on the screen. This structure is allocated and freed by generic display
  199. * code but most of its fields are filled in by segment-type-specific code.
  200. */
  201. struct TkTextDispChunk {
  202. /*
  203. * The fields below are set by the type-independent code before calling
  204. * the segment-type-specific layoutProc. They should not be modified by
  205. * segment-type-specific code.
  206. */
  207. int x; /* X position of chunk, in pixels. This
  208. * position is measured from the left edge of
  209. * the logical line, not from the left edge of
  210. * the window (i.e. it doesn't change under
  211. * horizontal scrolling). */
  212. struct TkTextDispChunk *nextPtr;
  213. /* Next chunk in the display line or NULL for
  214. * the end of the list. */
  215. struct TextStyle *stylePtr; /* Display information, known only to
  216. * tkTextDisp.c. */
  217. /*
  218. * The fields below are set by the layoutProc that creates the chunk.
  219. */
  220. Tk_ChunkDisplayProc *displayProc;
  221. /* Procedure to invoke to draw this chunk on
  222. * the display or an off-screen pixmap. */
  223. Tk_ChunkUndisplayProc *undisplayProc;
  224. /* Procedure to invoke when segment ceases to
  225. * be displayed on screen anymore. */
  226. Tk_ChunkMeasureProc *measureProc;
  227. /* Procedure to find character under a given
  228. * x-location. */
  229. Tk_ChunkBboxProc *bboxProc; /* Procedure to find bounding box of character
  230. * in chunk. */
  231. int numBytes; /* Number of bytes that will be displayed in
  232. * the chunk. */
  233. int minAscent; /* Minimum space above the baseline needed by
  234. * this chunk. */
  235. int minDescent; /* Minimum space below the baseline needed by
  236. * this chunk. */
  237. int minHeight; /* Minimum total line height needed by this
  238. * chunk. */
  239. int width; /* Width of this chunk, in pixels. Initially
  240. * set by chunk-specific code, but may be
  241. * increased to include tab or extra space at
  242. * end of line. */
  243. int breakIndex; /* Index within chunk of last acceptable
  244. * position for a line (break just before this
  245. * byte index). <= 0 means don't break during
  246. * or immediately after this chunk. */
  247. ClientData clientData; /* Additional information for use of
  248. * displayProc and undisplayProc. */
  249. };
  250. /*
  251. * One data structure of the following type is used for each tag in a text
  252. * widget. These structures are kept in sharedTextPtr->tagTable and referred
  253. * to in other structures.
  254. */
  255. typedef enum {
  256. TEXT_WRAPMODE_CHAR, TEXT_WRAPMODE_NONE, TEXT_WRAPMODE_WORD,
  257. TEXT_WRAPMODE_NULL
  258. } TkWrapMode;
  259. typedef struct TkTextTag {
  260. const char *name; /* Name of this tag. This field is actually a
  261. * pointer to the key from the entry in
  262. * sharedTextPtr->tagTable, so it needn't be
  263. * freed explicitly. For 'sel' tags this is
  264. * just a static string, so again need not be
  265. * freed. */
  266. const struct TkText *textPtr;
  267. /* If non-NULL, then this tag only applies to
  268. * the given text widget (when there are peer
  269. * widgets). */
  270. int priority; /* Priority of this tag within widget. 0 means
  271. * lowest priority. Exactly one tag has each
  272. * integer value between 0 and numTags-1. */
  273. struct Node *tagRootPtr; /* Pointer into the B-Tree at the lowest node
  274. * that completely dominates the ranges of
  275. * text occupied by the tag. At this node
  276. * there is no information about the tag. One
  277. * or more children of the node do contain
  278. * information about the tag. */
  279. int toggleCount; /* Total number of tag toggles. */
  280. /*
  281. * Information for displaying text with this tag. The information belows
  282. * acts as an override on information specified by lower-priority tags.
  283. * If no value is specified, then the next-lower-priority tag on the text
  284. * determins the value. The text widget itself provides defaults if no tag
  285. * specifies an override.
  286. */
  287. Tk_3DBorder border; /* Used for drawing background. NULL means no
  288. * value specified here. */
  289. int borderWidth; /* Width of 3-D border for background. */
  290. Tcl_Obj *borderWidthPtr; /* Width of 3-D border for background. */
  291. char *reliefString; /* -relief option string (malloc-ed). NULL
  292. * means option not specified. */
  293. int relief; /* 3-D relief for background. */
  294. Pixmap bgStipple; /* Stipple bitmap for background. None means
  295. * no value specified here. */
  296. XColor *fgColor; /* Foreground color for text. NULL means no
  297. * value specified here. */
  298. Tk_Font tkfont; /* Font for displaying text. NULL means no
  299. * value specified here. */
  300. Pixmap fgStipple; /* Stipple bitmap for text and other
  301. * foreground stuff. None means no value
  302. * specified here.*/
  303. char *justifyString; /* -justify option string (malloc-ed). NULL
  304. * means option not specified. */
  305. Tk_Justify justify; /* How to justify text: TK_JUSTIFY_LEFT,
  306. * TK_JUSTIFY_RIGHT, or TK_JUSTIFY_CENTER.
  307. * Only valid if justifyString is non-NULL. */
  308. char *lMargin1String; /* -lmargin1 option string (malloc-ed). NULL
  309. * means option not specified. */
  310. int lMargin1; /* Left margin for first display line of each
  311. * text line, in pixels. Only valid if
  312. * lMargin1String is non-NULL. */
  313. char *lMargin2String; /* -lmargin2 option string (malloc-ed). NULL
  314. * means option not specified. */
  315. int lMargin2; /* Left margin for second and later display
  316. * lines of each text line, in pixels. Only
  317. * valid if lMargin2String is non-NULL. */
  318. Tk_3DBorder lMarginColor; /* Used for drawing background in left margins.
  319. * This is used for both lmargin1 and lmargin2.
  320. * NULL means no value specified here. */
  321. char *offsetString; /* -offset option string (malloc-ed). NULL
  322. * means option not specified. */
  323. int offset; /* Vertical offset of text's baseline from
  324. * baseline of line. Used for superscripts and
  325. * subscripts. Only valid if offsetString is
  326. * non-NULL. */
  327. char *overstrikeString; /* -overstrike option string (malloc-ed). NULL
  328. * means option not specified. */
  329. int overstrike; /* Non-zero means draw horizontal line through
  330. * middle of text. Only valid if
  331. * overstrikeString is non-NULL. */
  332. XColor *overstrikeColor; /* Color for the overstrike. NULL means same
  333. * color as foreground. */
  334. char *rMarginString; /* -rmargin option string (malloc-ed). NULL
  335. * means option not specified. */
  336. int rMargin; /* Right margin for text, in pixels. Only
  337. * valid if rMarginString is non-NULL. */
  338. Tk_3DBorder rMarginColor; /* Used for drawing background in right margin.
  339. * NULL means no value specified here. */
  340. Tk_3DBorder selBorder; /* Used for drawing background for selected text.
  341. * NULL means no value specified here. */
  342. XColor *selFgColor; /* Foreground color for selected text. NULL means
  343. * no value specified here. */
  344. char *spacing1String; /* -spacing1 option string (malloc-ed). NULL
  345. * means option not specified. */
  346. int spacing1; /* Extra spacing above first display line for
  347. * text line. Only valid if spacing1String is
  348. * non-NULL. */
  349. char *spacing2String; /* -spacing2 option string (malloc-ed). NULL
  350. * means option not specified. */
  351. int spacing2; /* Extra spacing between display lines for the
  352. * same text line. Only valid if
  353. * spacing2String is non-NULL. */
  354. char *spacing3String; /* -spacing2 option string (malloc-ed). NULL
  355. * means option not specified. */
  356. int spacing3; /* Extra spacing below last display line for
  357. * text line. Only valid if spacing3String is
  358. * non-NULL. */
  359. Tcl_Obj *tabStringPtr; /* -tabs option string. NULL means option not
  360. * specified. */
  361. struct TkTextTabArray *tabArrayPtr;
  362. /* Info about tabs for tag (malloc-ed) or
  363. * NULL. Corresponds to tabString. */
  364. int tabStyle; /* One of TABULAR or WORDPROCESSOR or NONE (if
  365. * not specified). */
  366. char *underlineString; /* -underline option string (malloc-ed). NULL
  367. * means option not specified. */
  368. int underline; /* Non-zero means draw underline underneath
  369. * text. Only valid if underlineString is
  370. * non-NULL. */
  371. XColor *underlineColor; /* Color for the underline. NULL means same
  372. * color as foreground. */
  373. TkWrapMode wrapMode; /* How to handle wrap-around for this tag.
  374. * Must be TEXT_WRAPMODE_CHAR,
  375. * TEXT_WRAPMODE_NONE, TEXT_WRAPMODE_WORD, or
  376. * TEXT_WRAPMODE_NULL to use wrapmode for
  377. * whole widget. */
  378. char *elideString; /* -elide option string (malloc-ed). NULL
  379. * means option not specified. */
  380. int elide; /* Non-zero means that data under this tag
  381. * should not be displayed. */
  382. int affectsDisplay; /* Non-zero means that this tag affects the
  383. * way information is displayed on the screen
  384. * (so need to redisplay if tag changes). */
  385. Tk_OptionTable optionTable; /* Token representing the configuration
  386. * specifications. */
  387. int affectsDisplayGeometry; /* Non-zero means that this tag affects the
  388. * size with which information is displayed on
  389. * the screen (so need to recalculate line
  390. * dimensions if tag changes). */
  391. } TkTextTag;
  392. #define TK_TAG_AFFECTS_DISPLAY 0x1
  393. #define TK_TAG_UNDERLINE 0x2
  394. #define TK_TAG_JUSTIFY 0x4
  395. #define TK_TAG_OFFSET 0x10
  396. /*
  397. * The data structure below is used for searching a B-tree for transitions on
  398. * a single tag (or for all tag transitions). No code outside of tkTextBTree.c
  399. * should ever modify any of the fields in these structures, but it's OK to
  400. * use them for read-only information.
  401. */
  402. typedef struct TkTextSearch {
  403. TkTextIndex curIndex; /* Position of last tag transition returned by
  404. * TkBTreeNextTag, or index of start of
  405. * segment containing starting position for
  406. * search if TkBTreeNextTag hasn't been called
  407. * yet, or same as stopIndex if search is
  408. * over. */
  409. TkTextSegment *segPtr; /* Actual tag segment returned by last call to
  410. * TkBTreeNextTag, or NULL if TkBTreeNextTag
  411. * hasn't returned anything yet. */
  412. TkTextSegment *nextPtr; /* Where to resume search in next call to
  413. * TkBTreeNextTag. */
  414. TkTextSegment *lastPtr; /* Stop search before just before considering
  415. * this segment. */
  416. TkTextTag *tagPtr; /* Tag to search for (or tag found, if allTags
  417. * is non-zero). */
  418. int linesLeft; /* Lines left to search (including curIndex
  419. * and stopIndex). When this becomes <= 0 the
  420. * search is over. */
  421. int allTags; /* Non-zero means ignore tag check: search for
  422. * transitions on all tags. */
  423. } TkTextSearch;
  424. /*
  425. * The following data structure describes a single tab stop. It must be kept
  426. * in sync with the 'tabOptionStrings' array in the function 'TkTextGetTabs'
  427. */
  428. typedef enum {LEFT, RIGHT, CENTER, NUMERIC} TkTextTabAlign;
  429. /*
  430. * The following are the supported styles of tabbing, used for the -tabstyle
  431. * option of the text widget. The last element is only used for tag options.
  432. */
  433. typedef enum {
  434. TK_TEXT_TABSTYLE_TABULAR,
  435. TK_TEXT_TABSTYLE_WORDPROCESSOR,
  436. TK_TEXT_TABSTYLE_NONE
  437. } TkTextTabStyle;
  438. typedef struct TkTextTab {
  439. int location; /* Offset in pixels of this tab stop from the
  440. * left margin (lmargin2) of the text. */
  441. TkTextTabAlign alignment; /* Where the tab stop appears relative to the
  442. * text. */
  443. } TkTextTab;
  444. typedef struct TkTextTabArray {
  445. int numTabs; /* Number of tab stops. */
  446. double lastTab; /* The accurate fractional pixel position of
  447. * the last tab. */
  448. double tabIncrement; /* The accurate fractional pixel increment
  449. * between interpolated tabs we have to create
  450. * when we exceed numTabs. */
  451. TkTextTab tabs[TKFLEXARRAY];/* Array of tabs. The actual size will be
  452. * numTabs. THIS FIELD MUST BE THE LAST IN THE
  453. * STRUCTURE. */
  454. } TkTextTabArray;
  455. /*
  456. * Enumeration defining the edit modes of the widget.
  457. */
  458. typedef enum {
  459. TK_TEXT_EDIT_INSERT, /* insert mode */
  460. TK_TEXT_EDIT_DELETE, /* delete mode */
  461. TK_TEXT_EDIT_REPLACE, /* replace mode */
  462. TK_TEXT_EDIT_OTHER /* none of the above */
  463. } TkTextEditMode;
  464. /*
  465. * Enumeration defining the ways in which a text widget may be modified (for
  466. * undo/redo handling).
  467. */
  468. typedef enum {
  469. TK_TEXT_DIRTY_NORMAL, /* Normal behavior. */
  470. TK_TEXT_DIRTY_UNDO, /* Reverting a compound action. */
  471. TK_TEXT_DIRTY_REDO, /* Reapplying a compound action. */
  472. TK_TEXT_DIRTY_FIXED /* Forced to be dirty; can't be undone/redone
  473. * by normal activity. */
  474. } TkTextDirtyMode;
  475. /*
  476. * The following enum is used to define a type for the -state option of the
  477. * Text widget.
  478. */
  479. typedef enum {
  480. TK_TEXT_STATE_DISABLED, TK_TEXT_STATE_NORMAL
  481. } TkTextState;
  482. /*
  483. * A data structure of the following type is shared between each text widget
  484. * that are peers.
  485. */
  486. typedef struct TkSharedText {
  487. int refCount; /* Reference count this shared object. */
  488. TkTextBTree tree; /* B-tree representation of text and tags for
  489. * widget. */
  490. Tcl_HashTable tagTable; /* Hash table that maps from tag names to
  491. * pointers to TkTextTag structures. The "sel"
  492. * tag does not feature in this table, since
  493. * there's one of those for each text peer. */
  494. int numTags; /* Number of tags currently defined for
  495. * widget; needed to keep track of
  496. * priorities. */
  497. Tcl_HashTable markTable; /* Hash table that maps from mark names to
  498. * pointers to mark segments. The special
  499. * "insert" and "current" marks are not stored
  500. * in this table, but directly accessed as
  501. * fields of textPtr. */
  502. Tcl_HashTable windowTable; /* Hash table that maps from window names to
  503. * pointers to window segments. If a window
  504. * segment doesn't yet have an associated
  505. * window, there is no entry for it here. */
  506. Tcl_HashTable imageTable; /* Hash table that maps from image names to
  507. * pointers to image segments. If an image
  508. * segment doesn't yet have an associated
  509. * image, there is no entry for it here. */
  510. Tk_BindingTable bindingTable;
  511. /* Table of all bindings currently defined for
  512. * this widget. NULL means that no bindings
  513. * exist, so the table hasn't been created.
  514. * Each "object" used for this table is the
  515. * name of a tag. */
  516. int stateEpoch; /* This is incremented each time the B-tree's
  517. * contents change structurally, or when the
  518. * start/end limits change, and means that any
  519. * cached TkTextIndex objects are no longer
  520. * valid. */
  521. /*
  522. * Information related to the undo/redo functionality.
  523. */
  524. TkUndoRedoStack *undoStack; /* The undo/redo stack. */
  525. int undo; /* Non-zero means the undo/redo behaviour is
  526. * enabled. */
  527. int maxUndo; /* The maximum depth of the undo stack
  528. * expressed as the maximum number of compound
  529. * statements. */
  530. int autoSeparators; /* Non-zero means the separators will be
  531. * inserted automatically. */
  532. int isDirty; /* Flag indicating the 'dirtyness' of the
  533. * text widget. If the flag is not zero,
  534. * unsaved modifications have been applied to
  535. * the text widget. */
  536. TkTextDirtyMode dirtyMode; /* The nature of the dirtyness characterized
  537. * by the isDirty flag. */
  538. TkTextEditMode lastEditMode;/* Keeps track of what the last edit mode
  539. * was. */
  540. /*
  541. * Keep track of all the peers
  542. */
  543. struct TkText *peers;
  544. } TkSharedText;
  545. /*
  546. * The following enum is used to define a type for the -insertunfocussed
  547. * option of the Text widget.
  548. */
  549. typedef enum {
  550. TK_TEXT_INSERT_NOFOCUS_HOLLOW,
  551. TK_TEXT_INSERT_NOFOCUS_NONE,
  552. TK_TEXT_INSERT_NOFOCUS_SOLID
  553. } TkTextInsertUnfocussed;
  554. /*
  555. * A data structure of the following type is kept for each text widget that
  556. * currently exists for this process:
  557. */
  558. typedef struct TkText {
  559. /*
  560. * Information related to and accessed by widget peers and the
  561. * TkSharedText handling routines.
  562. */
  563. TkSharedText *sharedTextPtr;/* Shared section of all peers. */
  564. struct TkText *next; /* Next in list of linked peers. */
  565. TkTextLine *start; /* First B-tree line to show, or NULL to start
  566. * at the beginning. */
  567. TkTextLine *end; /* Last B-tree line to show, or NULL for up to
  568. * the end. */
  569. int pixelReference; /* Counter into the current tree reference
  570. * index corresponding to this widget. */
  571. int abortSelections; /* Set to 1 whenever the text is modified in a
  572. * way that interferes with selection
  573. * retrieval: used to abort incremental
  574. * selection retrievals. */
  575. /*
  576. * Standard Tk widget information and text-widget specific items
  577. */
  578. Tk_Window tkwin; /* Window that embodies the text. NULL means
  579. * that the window has been destroyed but the
  580. * data structures haven't yet been cleaned
  581. * up.*/
  582. Display *display; /* Display for widget. Needed, among other
  583. * things, to allow resources to be freed even
  584. * after tkwin has gone away. */
  585. Tcl_Interp *interp; /* Interpreter associated with widget. Used to
  586. * delete widget command. */
  587. Tcl_Command widgetCmd; /* Token for text's widget command. */
  588. int state; /* Either STATE_NORMAL or STATE_DISABLED. A
  589. * text widget is read-only when disabled. */
  590. /*
  591. * Default information for displaying (may be overridden by tags applied
  592. * to ranges of characters).
  593. */
  594. Tk_3DBorder border; /* Structure used to draw 3-D border and
  595. * default background. */
  596. int borderWidth; /* Width of 3-D border to draw around entire
  597. * widget. */
  598. int padX, padY; /* Padding between text and window border. */
  599. int relief; /* 3-d effect for border around entire widget:
  600. * TK_RELIEF_RAISED etc. */
  601. int highlightWidth; /* Width in pixels of highlight to draw around
  602. * widget when it has the focus. <= 0 means
  603. * don't draw a highlight. */
  604. XColor *highlightBgColorPtr;
  605. /* Color for drawing traversal highlight area
  606. * when highlight is off. */
  607. XColor *highlightColorPtr; /* Color for drawing traversal highlight. */
  608. Tk_Cursor cursor; /* Current cursor for window, or NULL. */
  609. XColor *fgColor; /* Default foreground color for text. */
  610. Tk_Font tkfont; /* Default font for displaying text. */
  611. int charWidth; /* Width of average character in default
  612. * font. */
  613. int charHeight; /* Height of average character in default
  614. * font, including line spacing. */
  615. int spacing1; /* Default extra spacing above first display
  616. * line for each text line. */
  617. int spacing2; /* Default extra spacing between display lines
  618. * for the same text line. */
  619. int spacing3; /* Default extra spacing below last display
  620. * line for each text line. */
  621. Tcl_Obj *tabOptionPtr; /* Value of -tabs option string. */
  622. TkTextTabArray *tabArrayPtr;
  623. /* Information about tab stops (malloc'ed).
  624. * NULL means perform default tabbing
  625. * behavior. */
  626. int tabStyle; /* One of TABULAR or WORDPROCESSOR. */
  627. /*
  628. * Additional information used for displaying:
  629. */
  630. TkWrapMode wrapMode; /* How to handle wrap-around. Must be
  631. * TEXT_WRAPMODE_CHAR, TEXT_WRAPMODE_NONE, or
  632. * TEXT_WRAPMODE_WORD. */
  633. int width, height; /* Desired dimensions for window, measured in
  634. * characters. */
  635. int setGrid; /* Non-zero means pass gridding information to
  636. * window manager. */
  637. int prevWidth, prevHeight; /* Last known dimensions of window; used to
  638. * detect changes in size. */
  639. TkTextIndex topIndex; /* Identifies first character in top display
  640. * line of window. */
  641. struct TextDInfo *dInfoPtr; /* Information maintained by tkTextDisp.c. */
  642. /*
  643. * Information related to selection.
  644. */
  645. TkTextTag *selTagPtr; /* Pointer to "sel" tag. Used to tell when a
  646. * new selection has been made. */
  647. Tk_3DBorder selBorder; /* Border and background for selected
  648. * characters. This is a copy of information
  649. * in *selTagPtr, so it shouldn't be
  650. * explicitly freed. */
  651. Tk_3DBorder inactiveSelBorder;
  652. /* Border and background for selected
  653. * characters when they don't have the
  654. * focus. */
  655. int selBorderWidth; /* Width of border around selection. */
  656. Tcl_Obj *selBorderWidthPtr; /* Width of border around selection. */
  657. XColor *selFgColorPtr; /* Foreground color for selected text. This is
  658. * a copy of information in *selTagPtr, so it
  659. * shouldn't be explicitly freed. */
  660. int exportSelection; /* Non-zero means tie "sel" tag to X
  661. * selection. */
  662. TkTextIndex selIndex; /* Used during multi-pass selection
  663. * retrievals. This index identifies the next
  664. * character to be returned from the
  665. * selection. */
  666. /*
  667. * Information related to insertion cursor:
  668. */
  669. TkTextSegment *insertMarkPtr;
  670. /* Points to segment for "insert" mark. */
  671. Tk_3DBorder insertBorder; /* Used to draw vertical bar for insertion
  672. * cursor. */
  673. int insertWidth; /* Total width of insert cursor. */
  674. int insertBorderWidth; /* Width of 3-D border around insert cursor */
  675. TkTextInsertUnfocussed insertUnfocussed;
  676. /* How to display the insert cursor when the
  677. * text widget does not have the focus. */
  678. int insertOnTime; /* Number of milliseconds cursor should spend
  679. * in "on" state for each blink. */
  680. int insertOffTime; /* Number of milliseconds cursor should spend
  681. * in "off" state for each blink. */
  682. Tcl_TimerToken insertBlinkHandler;
  683. /* Timer handler used to blink cursor on and
  684. * off. */
  685. /*
  686. * Information used for event bindings associated with tags:
  687. */
  688. TkTextSegment *currentMarkPtr;
  689. /* Pointer to segment for "current" mark, or
  690. * NULL if none. */
  691. XEvent pickEvent; /* The event from which the current character
  692. * was chosen. Must be saved so that we can
  693. * repick after modifications to the text. */
  694. int numCurTags; /* Number of tags associated with character at
  695. * current mark. */
  696. TkTextTag **curTagArrayPtr; /* Pointer to array of tags for current mark,
  697. * or NULL if none. */
  698. /*
  699. * Miscellaneous additional information:
  700. */
  701. char *takeFocus; /* Value of -takeFocus option; not used in the
  702. * C code, but used by keyboard traversal
  703. * scripts. Malloc'ed, but may be NULL. */
  704. char *xScrollCmd; /* Prefix of command to issue to update
  705. * horizontal scrollbar when view changes. */
  706. char *yScrollCmd; /* Prefix of command to issue to update
  707. * vertical scrollbar when view changes. */
  708. int flags; /* Miscellaneous flags; see below for
  709. * definitions. */
  710. Tk_OptionTable optionTable; /* Token representing the configuration
  711. * specifications. */
  712. int refCount; /* Number of cached TkTextIndex objects
  713. * refering to us. */
  714. int insertCursorType; /* 0 = standard insertion cursor, 1 = block
  715. * cursor. */
  716. /*
  717. * Copies of information from the shared section relating to the undo/redo
  718. * functonality
  719. */
  720. int undo; /* Non-zero means the undo/redo behaviour is
  721. * enabled. */
  722. int maxUndo; /* The maximum depth of the undo stack
  723. * expressed as the maximum number of compound
  724. * statements. */
  725. int autoSeparators; /* Non-zero means the separators will be
  726. * inserted automatically. */
  727. Tcl_Obj *afterSyncCmd; /* Command to be executed when lines are up to
  728. * date */
  729. } TkText;
  730. /*
  731. * Flag values for TkText records:
  732. *
  733. * GOT_SELECTION: Non-zero means we've already claimed the
  734. * selection.
  735. * INSERT_ON: Non-zero means insertion cursor should be
  736. * displayed on screen.
  737. * GOT_FOCUS: Non-zero means this window has the input
  738. * focus.
  739. * BUTTON_DOWN: 1 means that a mouse button is currently down;
  740. * this is used to implement grabs for the
  741. * duration of button presses.
  742. * UPDATE_SCROLLBARS: Non-zero means scrollbar(s) should be updated
  743. * during next redisplay operation.
  744. * NEED_REPICK This appears unused and should probably be
  745. * ignored.
  746. * OPTIONS_FREED The widget's options have been freed.
  747. * DESTROYED The widget is going away.
  748. */
  749. #define GOT_SELECTION 1
  750. #define INSERT_ON 2
  751. #define GOT_FOCUS 4
  752. #define BUTTON_DOWN 8
  753. #define UPDATE_SCROLLBARS 0x10
  754. #define NEED_REPICK 0x20
  755. #define OPTIONS_FREED 0x40
  756. #define DESTROYED 0x80
  757. /*
  758. * Records of the following type define segment types in terms of a collection
  759. * of procedures that may be called to manipulate segments of that type.
  760. */
  761. typedef TkTextSegment * Tk_SegSplitProc(struct TkTextSegment *segPtr,
  762. int index);
  763. typedef int Tk_SegDeleteProc(struct TkTextSegment *segPtr,
  764. TkTextLine *linePtr, int treeGone);
  765. typedef TkTextSegment * Tk_SegCleanupProc(struct TkTextSegment *segPtr,
  766. TkTextLine *linePtr);
  767. typedef void Tk_SegLineChangeProc(struct TkTextSegment *segPtr,
  768. TkTextLine *linePtr);
  769. typedef int Tk_SegLayoutProc(struct TkText *textPtr,
  770. struct TkTextIndex *indexPtr,
  771. TkTextSegment *segPtr, int offset, int maxX,
  772. int maxChars, int noCharsYet, TkWrapMode wrapMode,
  773. struct TkTextDispChunk *chunkPtr);
  774. typedef void Tk_SegCheckProc(TkTextSegment *segPtr,
  775. TkTextLine *linePtr);
  776. typedef struct Tk_SegType {
  777. const char *name; /* Name of this kind of segment. */
  778. int leftGravity; /* If a segment has zero size (e.g. a mark or
  779. * tag toggle), does it attach to character to
  780. * its left or right? 1 means left, 0 means
  781. * right. */
  782. Tk_SegSplitProc *splitProc; /* Procedure to split large segment into two
  783. * smaller ones. */
  784. Tk_SegDeleteProc *deleteProc;
  785. /* Procedure to call to delete segment. */
  786. Tk_SegCleanupProc *cleanupProc;
  787. /* After any change to a line, this procedure
  788. * is invoked for all segments left in the
  789. * line to perform any cleanup they wish
  790. * (e.g. joining neighboring segments). */
  791. Tk_SegLineChangeProc *lineChangeProc;
  792. /* Invoked when a segment is about to be moved
  793. * from its current line to an earlier line
  794. * because of a deletion. The linePtr is that
  795. * for the segment's old line. CleanupProc
  796. * will be invoked after the deletion is
  797. * finished. */
  798. Tk_SegLayoutProc *layoutProc;
  799. /* Returns size information when figuring out
  800. * what to display in window. */
  801. Tk_SegCheckProc *checkProc; /* Called during consistency checks to check
  802. * internal consistency of segment. */
  803. } Tk_SegType;
  804. /*
  805. * The following type and items describe different flags for text widget items
  806. * to count. They are used in both tkText.c and tkTextIndex.c, in
  807. * 'CountIndices', 'TkTextIndexBackChars', 'TkTextIndexForwChars', and
  808. * 'TkTextIndexCount'.
  809. */
  810. typedef int TkTextCountType;
  811. #define COUNT_CHARS 0
  812. #define COUNT_INDICES 1
  813. #define COUNT_DISPLAY 2
  814. #define COUNT_DISPLAY_CHARS (COUNT_CHARS | COUNT_DISPLAY)
  815. #define COUNT_DISPLAY_INDICES (COUNT_INDICES | COUNT_DISPLAY)
  816. /*
  817. * The following structure is used to keep track of elided text taking account
  818. * of different tag priorities, it is need for quick calculations of whether a
  819. * single index is elided, and to start at a given index and maintain a
  820. * correct elide state as we move or count forwards or backwards.
  821. */
  822. #define LOTSA_TAGS 1000
  823. typedef struct TkTextElideInfo {
  824. int numTags; /* Total tags in widget. */
  825. int elide; /* Is the state currently elided. */
  826. int elidePriority; /* Tag priority controlling elide state. */
  827. TkTextSegment *segPtr; /* Segment to look at next. */
  828. int segOffset; /* Offset of segment within line. */
  829. int deftagCnts[LOTSA_TAGS];
  830. TkTextTag *deftagPtrs[LOTSA_TAGS];
  831. int *tagCnts; /* 0 or 1 depending if the tag with that
  832. * priority is on or off. */
  833. TkTextTag **tagPtrs; /* Only filled with a tagPtr if the
  834. * corresponding tagCnt is 1. */
  835. } TkTextElideInfo;
  836. /*
  837. * The constant below is used to specify a line when what is really wanted is
  838. * the entire text. For now, just use a very big number.
  839. */
  840. #define TK_END_OF_TEXT 1000000
  841. /*
  842. * The following definition specifies the maximum number of characters needed
  843. * in a string to hold a position specifier.
  844. */
  845. #define TK_POS_CHARS 30
  846. /*
  847. * Mask used for those options which may impact the pixel height calculations
  848. * of individual lines displayed in the widget.
  849. */
  850. #define TK_TEXT_LINE_GEOMETRY 1
  851. /*
  852. * Mask used for those options which may impact the start and end lines used
  853. * in the widget.
  854. */
  855. #define TK_TEXT_LINE_RANGE 2
  856. /*
  857. * Used as 'action' values in calls to TkTextInvalidateLineMetrics
  858. */
  859. #define TK_TEXT_INVALIDATE_ONLY 0
  860. #define TK_TEXT_INVALIDATE_INSERT 1
  861. #define TK_TEXT_INVALIDATE_DELETE 2
  862. /*
  863. * Used as special 'pickPlace' values in calls to TkTextSetYView. Zero or
  864. * positive values indicate a number of pixels.
  865. */
  866. #define TK_TEXT_PICKPLACE -1
  867. #define TK_TEXT_NOPIXELADJUST -2
  868. /*
  869. * Declarations for variables shared among the text-related files:
  870. */
  871. MODULE_SCOPE int tkBTreeDebug;
  872. MODULE_SCOPE int tkTextDebug;
  873. MODULE_SCOPE const Tk_SegType tkTextCharType;
  874. MODULE_SCOPE const Tk_SegType tkTextLeftMarkType;
  875. MODULE_SCOPE const Tk_SegType tkTextRightMarkType;
  876. MODULE_SCOPE const Tk_SegType tkTextToggleOnType;
  877. MODULE_SCOPE const Tk_SegType tkTextToggleOffType;
  878. MODULE_SCOPE const Tk_SegType tkTextEmbWindowType;
  879. MODULE_SCOPE const Tk_SegType tkTextEmbImageType;
  880. /*
  881. * Convenience macros for use by B-tree clients which want to access pixel
  882. * information on each line. Currently only used by TkTextDisp.c
  883. */
  884. #define TkBTreeLinePixelCount(text, line) \
  885. (line)->pixels[2*(text)->pixelReference]
  886. #define TkBTreeLinePixelEpoch(text, line) \
  887. (line)->pixels[1+2*(text)->pixelReference]
  888. /*
  889. * Declarations for procedures that are used by the text-related files but
  890. * shouldn't be used anywhere else in Tk (or by Tk clients):
  891. */
  892. MODULE_SCOPE int TkBTreeAdjustPixelHeight(const TkText *textPtr,
  893. TkTextLine *linePtr, int newPixelHeight,
  894. int mergedLogicalLines);
  895. MODULE_SCOPE int TkBTreeCharTagged(const TkTextIndex *indexPtr,
  896. TkTextTag *tagPtr);
  897. MODULE_SCOPE void TkBTreeCheck(TkTextBTree tree);
  898. MODULE_SCOPE TkTextBTree TkBTreeCreate(TkSharedText *sharedTextPtr);
  899. MODULE_SCOPE void TkBTreeAddClient(TkTextBTree tree, TkText *textPtr,
  900. int defaultHeight);
  901. MODULE_SCOPE void TkBTreeClientRangeChanged(TkText *textPtr,
  902. int defaultHeight);
  903. MODULE_SCOPE void TkBTreeRemoveClient(TkTextBTree tree,
  904. TkText *textPtr);
  905. MODULE_SCOPE void TkBTreeDestroy(TkTextBTree tree);
  906. MODULE_SCOPE void TkBTreeDeleteIndexRange(TkTextBTree tree,
  907. TkTextIndex *index1Ptr, TkTextIndex *index2Ptr);
  908. MODULE_SCOPE int TkBTreeEpoch(TkTextBTree tree);
  909. MODULE_SCOPE TkTextLine *TkBTreeFindLine(TkTextBTree tree,
  910. const TkText *textPtr, int line);
  911. MODULE_SCOPE TkTextLine *TkBTreeFindPixelLine(TkTextBTree tree,
  912. const TkText *textPtr, int pixels,
  913. int *pixelOffset);
  914. MODULE_SCOPE TkTextTag **TkBTreeGetTags(const TkTextIndex *indexPtr,
  915. const TkText *textPtr, int *numTagsPtr);
  916. MODULE_SCOPE void TkBTreeInsertChars(TkTextBTree tree,
  917. TkTextIndex *indexPtr, const char *string);
  918. MODULE_SCOPE int TkBTreeLinesTo(const TkText *textPtr,
  919. TkTextLine *linePtr);
  920. MODULE_SCOPE int TkBTreePixelsTo(const TkText *textPtr,
  921. TkTextLine *linePtr);
  922. MODULE_SCOPE void TkBTreeLinkSegment(TkTextSegment *segPtr,
  923. TkTextIndex *indexPtr);
  924. MODULE_SCOPE TkTextLine *TkBTreeNextLine(const TkText *textPtr,
  925. TkTextLine *linePtr);
  926. MODULE_SCOPE int TkBTreeNextTag(TkTextSearch *searchPtr);
  927. MODULE_SCOPE int TkBTreeNumPixels(TkTextBTree tree,
  928. const TkText *textPtr);
  929. MODULE_SCOPE TkTextLine *TkBTreePreviousLine(TkText *textPtr,
  930. TkTextLine *linePtr);
  931. MODULE_SCOPE int TkBTreePrevTag(TkTextSearch *searchPtr);
  932. MODULE_SCOPE void TkBTreeStartSearch(TkTextIndex *index1Ptr,
  933. TkTextIndex *index2Ptr, TkTextTag *tagPtr,
  934. TkTextSearch *searchPtr);
  935. MODULE_SCOPE void TkBTreeStartSearchBack(TkTextIndex *index1Ptr,
  936. TkTextIndex *index2Ptr, TkTextTag *tagPtr,
  937. TkTextSearch *searchPtr);
  938. MODULE_SCOPE int TkBTreeTag(TkTextIndex *index1Ptr,
  939. TkTextIndex *index2Ptr, TkTextTag *tagPtr,
  940. int add);
  941. MODULE_SCOPE void TkBTreeUnlinkSegment(TkTextSegment *segPtr,
  942. TkTextLine *linePtr);
  943. MODULE_SCOPE void TkTextBindProc(ClientData clientData,
  944. XEvent *eventPtr);
  945. MODULE_SCOPE void TkTextSelectionEvent(TkText *textPtr);
  946. MODULE_SCOPE int TkTextIndexBbox(TkText *textPtr,
  947. const TkTextIndex *indexPtr, int *xPtr, int *yPtr,
  948. int *widthPtr, int *heightPtr, int *charWidthPtr);
  949. MODULE_SCOPE int TkTextCharLayoutProc(TkText *textPtr,
  950. TkTextIndex *indexPtr, TkTextSegment *segPtr,
  951. int offset, int maxX, int maxChars, int noBreakYet,
  952. TkWrapMode wrapMode, TkTextDispChunk *chunkPtr);
  953. MODULE_SCOPE void TkTextCreateDInfo(TkText *textPtr);
  954. MODULE_SCOPE int TkTextDLineInfo(TkText *textPtr,
  955. const TkTextIndex *indexPtr, int *xPtr, int *yPtr,
  956. int *widthPtr, int *heightPtr, int *basePtr);
  957. MODULE_SCOPE void TkTextEmbWinDisplayProc(TkText *textPtr,
  958. TkTextDispChunk *chunkPtr, int x, int y,
  959. int lineHeight, int baseline, Display *display,
  960. Drawable dst, int screenY);
  961. MODULE_SCOPE TkTextTag *TkTextCreateTag(TkText *textPtr,
  962. const char *tagName, int *newTag);
  963. MODULE_SCOPE void TkTextFreeDInfo(TkText *textPtr);
  964. MODULE_SCOPE void TkTextDeleteTag(TkText *textPtr, TkTextTag *tagPtr);
  965. MODULE_SCOPE void TkTextFreeTag(TkText *textPtr, TkTextTag *tagPtr);
  966. MODULE_SCOPE int TkTextGetObjIndex(Tcl_Interp *interp, TkText *textPtr,
  967. Tcl_Obj *idxPtr, TkTextIndex *indexPtr);
  968. MODULE_SCOPE int TkTextSharedGetObjIndex(Tcl_Interp *interp,
  969. TkSharedText *sharedTextPtr, Tcl_Obj *idxPtr,
  970. TkTextIndex *indexPtr);
  971. MODULE_SCOPE const TkTextIndex *TkTextGetIndexFromObj(Tcl_Interp *interp,
  972. TkText *textPtr, Tcl_Obj *objPtr);
  973. MODULE_SCOPE TkTextTabArray *TkTextGetTabs(Tcl_Interp *interp,
  974. TkText *textPtr, Tcl_Obj *stringPtr);
  975. MODULE_SCOPE void TkTextFindDisplayLineEnd(TkText *textPtr,
  976. TkTextIndex *indexPtr, int end, int *xOffset);
  977. MODULE_SCOPE void TkTextIndexBackChars(const TkText *textPtr,
  978. const TkTextIndex *srcPtr, int count,
  979. TkTextIndex *dstPtr, TkTextCountType type);
  980. MODULE_SCOPE int TkTextIndexCmp(const TkTextIndex *index1Ptr,
  981. const TkTextIndex *index2Ptr);
  982. MODULE_SCOPE int TkTextIndexCountBytes(const TkText *textPtr,
  983. const TkTextIndex *index1Ptr,
  984. const TkTextIndex *index2Ptr);
  985. MODULE_SCOPE int TkTextIndexCount(const TkText *textPtr,
  986. const TkTextIndex *index1Ptr,
  987. const TkTextIndex *index2Ptr,
  988. TkTextCountType type);
  989. MODULE_SCOPE void TkTextIndexForwChars(const TkText *textPtr,
  990. const TkTextIndex *srcPtr, int count,
  991. TkTextIndex *dstPtr, TkTextCountType type);
  992. MODULE_SCOPE void TkTextIndexOfX(TkText *textPtr, int x,
  993. TkTextIndex *indexPtr);
  994. MODULE_SCOPE int TkTextIndexYPixels(TkText *textPtr,
  995. const TkTextIndex *indexPtr);
  996. MODULE_SCOPE TkTextSegment *TkTextIndexToSeg(const TkTextIndex *indexPtr,
  997. int *offsetPtr);
  998. MODULE_SCOPE void TkTextLostSelection(ClientData clientData);
  999. MODULE_SCOPE TkTextIndex *TkTextMakeCharIndex(TkTextBTree tree, TkText *textPtr,
  1000. int lineIndex, int charIndex,
  1001. TkTextIndex *indexPtr);
  1002. MODULE_SCOPE int TkTextMeasureDown(TkText *textPtr,
  1003. TkTextIndex *srcPtr, int distance);
  1004. MODULE_SCOPE void TkTextFreeElideInfo(TkTextElideInfo *infoPtr);
  1005. MODULE_SCOPE int TkTextIsElided(const TkText *textPtr,
  1006. const TkTextIndex *indexPtr,
  1007. TkTextElideInfo *infoPtr);
  1008. MODULE_SCOPE int TkTextMakePixelIndex(TkText *textPtr,
  1009. int pixelIndex, TkTextIndex *indexPtr);
  1010. MODULE_SCOPE void TkTextInvalidateLineMetrics(
  1011. TkSharedText *sharedTextPtr, TkText *textPtr,
  1012. TkTextLine *linePtr, int lineCount, int action);
  1013. MODULE_SCOPE int TkTextUpdateLineMetrics(TkText *textPtr, int lineNum,
  1014. int endLine, int doThisMuch);
  1015. MODULE_SCOPE int TkTextUpdateOneLine(TkText *textPtr,
  1016. TkTextLine *linePtr, int pixelHeight,
  1017. TkTextIndex *indexPtr, int partialCalc);
  1018. MODULE_SCOPE int TkTextMarkCmd(TkText *textPtr, Tcl_Interp *interp,
  1019. int objc, Tcl_Obj *const objv[]);
  1020. MODULE_SCOPE int TkTextMarkNameToIndex(TkText *textPtr,
  1021. const char *name, TkTextIndex *indexPtr);
  1022. MODULE_SCOPE void TkTextMarkSegToIndex(TkText *textPtr,
  1023. TkTextSegment *markPtr, TkTextIndex *indexPtr);
  1024. MODULE_SCOPE void TkTextEventuallyRepick(TkText *textPtr);
  1025. MODULE_SCOPE Bool TkTextPendingsync(TkText *textPtr);
  1026. MODULE_SCOPE void TkTextPickCurrent(TkText *textPtr, XEvent *eventPtr);
  1027. MODULE_SCOPE void TkTextPixelIndex(TkText *textPtr, int x, int y,
  1028. TkTextIndex *indexPtr, int *nearest);
  1029. MODULE_SCOPE Tcl_Obj * TkTextNewIndexObj(TkText *textPtr,
  1030. const TkTextIndex *indexPtr);
  1031. MODULE_SCOPE void TkTextRedrawRegion(TkText *textPtr, int x, int y,
  1032. int width, int height);
  1033. MODULE_SCOPE void TkTextRedrawTag(TkSharedText *sharedTextPtr,
  1034. TkText *textPtr, TkTextIndex *index1Ptr,
  1035. TkTextIndex *index2Ptr, TkTextTag *tagPtr,
  1036. int withTag);
  1037. MODULE_SCOPE void TkTextRelayoutWindow(TkText *textPtr, int mask);
  1038. MODULE_SCOPE int TkTextScanCmd(TkText *textPtr, Tcl_Interp *interp,
  1039. int objc, Tcl_Obj *const objv[]);
  1040. MODULE_SCOPE int TkTextSeeCmd(TkText *textPtr, Tcl_Interp *interp,
  1041. int objc, Tcl_Obj *const objv[]);
  1042. MODULE_SCOPE int TkTextSegToOffset(const TkTextSegment *segPtr,
  1043. const TkTextLine *linePtr);
  1044. MODULE_SCOPE void TkTextSetYView(TkText *textPtr,
  1045. TkTextIndex *indexPtr, int pickPlace);
  1046. MODULE_SCOPE int TkTextTagCmd(TkText *textPtr, Tcl_Interp *interp,
  1047. int objc, Tcl_Obj *const objv[]);
  1048. MODULE_SCOPE int TkTextImageCmd(TkText *textPtr, Tcl_Interp *interp,
  1049. int objc, Tcl_Obj *const objv[]);
  1050. MODULE_SCOPE int TkTextImageIndex(TkText *textPtr,
  1051. const char *name, TkTextIndex *indexPtr);
  1052. MODULE_SCOPE int TkTextWindowCmd(TkText *textPtr, Tcl_Interp *interp,
  1053. int objc, Tcl_Obj *const objv[]);
  1054. MODULE_SCOPE int TkTextWindowIndex(TkText *textPtr, const char *name,
  1055. TkTextIndex *indexPtr);
  1056. MODULE_SCOPE int TkTextYviewCmd(TkText *textPtr, Tcl_Interp *interp,
  1057. int objc, Tcl_Obj *const objv[]);
  1058. MODULE_SCOPE void TkTextWinFreeClient(Tcl_HashEntry *hPtr,
  1059. TkTextEmbWindowClient *client);
  1060. MODULE_SCOPE void TkTextRunAfterSyncCmd(ClientData clientData);
  1061. MODULE_SCOPE int TkTextIndexAdjustToStartEnd(TkText *textPtr,
  1062. TkTextIndex *indexPtr, int err);
  1063. #endif /* _TKTEXT */
  1064. /*
  1065. * Local Variables:
  1066. * mode: c
  1067. * c-basic-offset: 4
  1068. * fill-column: 78
  1069. * End:
  1070. */