gtktextsegment.inc 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. // included by gtk2.pas
  2. {$IFDEF read_forward_definitions}
  3. {$ENDIF read_forward_definitions}
  4. //------------------------------------------------------------------------------
  5. {$IFDEF read_interface_types}
  6. PGtkTextLineSegment = ^TGtkTextLineSegment;
  7. PGtkTextLineSegmentClass = ^TGtkTextLineSegmentClass;
  8. {
  9. Segments: each line is divided into one or more segments, where each
  10. segment is one of several things, such as a group of characters, a
  11. tag toggle, a mark, or an embedded widget. Each segment starts with
  12. a standard header followed by a body that varies from type to type.
  13. }
  14. { This header has the segment type, and two specific segments
  15. (character and toggle segments) }
  16. { Information a BTree stores about a tag. }
  17. { highest-level node containing the tag }
  18. { total toggles of this tag below tag_root }
  19. PGtkTextTagInfo = ^TGtkTextTagInfo;
  20. TGtkTextTagInfo = record
  21. tag : PGtkTextTag;
  22. tag_root : PGtkTextBTreeNode;
  23. toggle_count : gint;
  24. end;
  25. { Body of a segment that toggles a tag on or off }
  26. { Tag that starts or ends here. }
  27. { TRUE means this toggle has been
  28. accounted for in node toggle
  29. counts; FALSE means it hasn't, yet. }
  30. PGtkTextToggleBody = ^TGtkTextToggleBody;
  31. TGtkTextToggleBody = record
  32. info : PGtkTextTagInfo;
  33. inNodeCounts : gboolean;
  34. end;
  35. {
  36. The data structure below defines line segments.
  37. }
  38. { Pointer to record describing
  39. segment's type. }
  40. { Next in list of segments for this
  41. line, or NULL for theEnd of list. }
  42. { # of chars of index space occupied }
  43. { Size of this segment (# of bytes
  44. of index space it occupies). }
  45. { Characters that make up character
  46. info. Actual length varies to
  47. hold as many characters as needed. }
  48. { Information about tag toggle. }
  49. { Information about mark. }
  50. { Child pixbuf }
  51. { Child widget }
  52. TGtkTextLineSegment = record
  53. _type : PGtkTextLineSegmentClass;
  54. next : PGtkTextLineSegment;
  55. char_count : longint;
  56. byte_count : longint;
  57. body : record
  58. case longint of
  59. 0 : ( chars : array[0..3] of char );
  60. 1 : ( toggle : TGtkTextToggleBody );
  61. 2 : ( mark : TGtkTextMarkBody );
  62. 3 : ( pixbuf : TGtkTextPixbuf );
  63. 4 : ( child : TGtkTextChildBody );
  64. end;
  65. end;
  66. { Class struct for segments }
  67. { Split seg at index, returning list of two new segments, and freeing seg }
  68. PGtkTextSegSplitFunc = ^TGtkTextSegSplitFunc;
  69. TGtkTextSegSplitFunc = TGtkTextLineSegment;
  70. { Delete seg which is contained in line; if tree_gone, the tree is being
  71. freed in its entirety, which may matter for some reason (?)
  72. Return TRUE if the segment is not deleteable, e.g. a mark.
  73. }
  74. TGtkTextSegDeleteFunc = function (seg:PGtkTextLineSegment; line:PGtkTextLine; tree_gone:gboolean):gboolean; cdecl;
  75. { Called after segment structure of line changes, so segments can
  76. cleanup (e.g. merge with adjacent segments). Returns a segment list
  77. to replace the original segment list with. The line argument is
  78. the current line.
  79. }
  80. PGtkTextSegCleanupFunc = ^TGtkTextSegCleanupFunc;
  81. TGtkTextSegCleanupFunc = TGtkTextLineSegment;
  82. { Called when a segment moves from one line to another. CleanupFunc is also
  83. called in that case, so many segments just use CleanupFunc, I'm not sure
  84. what's up with that (this function may not be needed...)
  85. }
  86. TGtkTextSegLineChangeFunc = procedure (seg:PGtkTextLineSegment; line:PGtkTextLine); cdecl;
  87. { Called to do debug checks on the segment. }
  88. TGtkTextSegCheckFunc = procedure (seg:PGtkTextLineSegment; line:PGtkTextLine); cdecl;
  89. { Name of this kind of segment. }
  90. { If a segment has zero size (e.g. a
  91. mark or tag toggle), does it
  92. attach to character to its left
  93. or right? 1 means left, 0 means
  94. right. }
  95. { Procedure to split large segment
  96. into two smaller ones. }
  97. { Procedure to call to delete
  98. segment. }
  99. { After any change to a line, this
  100. procedure is invoked for all
  101. segments left in the line to
  102. perform any cleanup they wish
  103. (e.g. joining neighboring
  104. segments). }
  105. { Invoked when a segment is about
  106. to be moved from its current line
  107. to an earlier line because of
  108. a deletion. The line is that
  109. for the segment's old line.
  110. CleanupFunc will be invoked after
  111. the deletion is finished. }
  112. { Called during consistency checks
  113. to check internal consistency of
  114. segment. }
  115. TGtkTextLineSegmentClass = record
  116. name : Pchar;
  117. leftGravity : gboolean;
  118. splitFunc : TGtkTextSegSplitFunc;
  119. deleteFunc : TGtkTextSegDeleteFunc;
  120. cleanupFunc : TGtkTextSegCleanupFunc;
  121. lineChangeFunc : TGtkTextSegLineChangeFunc;
  122. checkFunc : TGtkTextSegCheckFunc;
  123. end;
  124. {$ENDIF read_interface_types}
  125. //------------------------------------------------------------------------------
  126. {$IFDEF read_interface_rest}
  127. function gtk_text_line_segment_split(iter:PGtkTextIter):PGtkTextLineSegment; cdecl; external gtklib;
  128. function _gtk_char_segment_new(text:Pgchar; len:guint):PGtkTextLineSegment; cdecl; external gtklib;
  129. function _gtk_char_segment_new_from_two_strings(text1:Pgchar; len1:guint; text2:Pgchar; len2:guint):PGtkTextLineSegment; cdecl; external gtklib;
  130. function _gtk_toggle_segment_new(info:PGtkTextTagInfo; StateOn:gboolean):PGtkTextLineSegment; cdecl; external gtklib;
  131. {$ENDIF read_interface_rest}