/src/wrappers/gtk/library/gtk_text_buffer.e

http://github.com/tybor/Liberty · Specman e · 1308 lines · 569 code · 189 blank · 550 comment · 6 complexity · a0b19406b7d755e12c87847e01c18eaa MD5 · raw file

  1. indexing
  2. description: "Formatted text buffer; GtkTextBuffer stores attributed text for display in a GtkTextView "
  3. copyright: "[
  4. Copyright (C) 2006 eiffel-libraries team, GTK+ team
  5. This library is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU Lesser General Public License
  7. as published by the Free Software Foundation; either version 2.1 of
  8. the License, or (at your option) any later version.
  9. This library is distributed in the hope that it will be useful, but
  10. WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. Lesser General Public License for more details.
  13. You should have received a copy of the GNU Lesser General Public
  14. License along with this library; if not, write to the Free Software
  15. Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  16. 02110-1301 USA
  17. ]"
  18. date: "$Date:$"
  19. revision: "$Revision:$"
  20. class GTK_TEXT_BUFFER
  21. -- A text buffer.
  22. -- Conceptual Overview:
  23. -- GTK+ has an extremely powerful framework for multiline text
  24. -- editing. The primary objects involved in the process are
  25. -- GTK_TEXT_BUFFER, which represents the text being edited, and
  26. -- GTK_TEXT_VIEW, a widget which can display a
  27. -- GTK_TEXT_BUFFER. Each buffer can be displayed by any number of
  28. -- views.
  29. -- One of the important things to remember about text in GTK+ is
  30. -- that it's in the UTF-8 encoding. This means that one character
  31. -- can be encoded as multiple bytes. Character counts are usually
  32. -- referred to as offsets, while byte counts are called indexes. If
  33. -- you confuse these two, things will work fine with ASCII, but as
  34. -- soon as your buffer contains multibyte characters, bad things
  35. -- will happen.
  36. -- Text in a buffer can be marked with tags. A tag is an attribute
  37. -- that can be applied to some range of text. For example, a tag
  38. -- might be called "bold" and make the text inside the tag
  39. -- bold. However, the tag concept is more general than that; tags
  40. -- don't have to affect appearance. They can instead affect the
  41. -- behavior of mouse and key presses, "lock" a range of text so the
  42. -- user can't edit it, or countless other things. A tag is
  43. -- represented by a GtkTextTag object. One GtkTextTag can be
  44. -- applied to any number of text ranges in any number of buffers.
  45. -- Each tag is stored in a GTK_TEXT_TAG_TABLE. A tag table defines
  46. -- a set of tags that can be used together. Each buffer has one tag
  47. -- table associated with it; only tags from that tag table can be
  48. -- used with the buffer. A single tag table can be shared between
  49. -- multiple buffers, however.
  50. -- Tags can have names, which is convenient sometimes (for example,
  51. -- you can name your tag that makes things bold "bold"), but they
  52. -- can also be anonymous (which is convenient if you're creating
  53. -- tags on-the-fly).
  54. -- TODO: the following paragraph uncover details that the Eiffel
  55. -- wrapper library should actuall hide from the end-user of the
  56. -- library. Make sure that GTK_TEXT_ITER behaviour mimicks it
  57. -- efficiently. Paolo 2008-04-06
  58. -- Most text manipulation is accomplished with iterators,
  59. -- represented by a GTK_TEXT_ITER. An iterator represents a position
  60. -- between two characters in the text buffer. GTK_TEXT_ITER is a
  61. -- struct designed to be allocated on the stack; it's guaranteed to
  62. -- be copiable by value and never contain any heap-allocated
  63. -- data. Iterators are not valid indefinitely; whenever the buffer
  64. -- is modified in a way that affects the number of characters in
  65. -- the buffer, all outstanding iterators become invalid. (Note that
  66. -- deleting 5 characters and then reinserting 5 still invalidates
  67. -- iterators, though you end up with the same number of characters
  68. -- you pass through a state with a different number).
  69. -- Because of this, iterators can't be used to preserve positions
  70. -- across buffer modifications. To preserve a position, the
  71. -- GTK_TEXT_MARK object is ideal. You can think of a mark as an
  72. -- invisible cursor or insertion point; it floats in the buffer,
  73. -- saving a position. If the text surrounding the mark is deleted,
  74. -- the mark remains in the position the text once occupied; if text
  75. -- is inserted at the mark, the mark ends up either to the left or
  76. -- to the right of the new text, depending on its gravity. The
  77. -- standard text cursor in left-to-right languages is a mark with
  78. -- right gravity, because it stays to the right of inserted text.
  79. -- Like tags, marks can be either named or anonymous. There are two
  80. -- marks built-in to GTK_TEXT_BUFFER; these are named "insert" and
  81. -- "selection_bound" and refer to the insertion point and the
  82. -- boundary of the selection which is not the insertion point,
  83. -- respectively. If no text is selected, these two marks will be in
  84. -- the same position. You can manipulate what is selected and where
  85. -- the cursor appears by moving these marks around.
  86. -- Text buffers always contain at least one line, but may be empty
  87. -- (that is, buffers can contain zero characters). The last line in
  88. -- the text buffer never ends in a line separator (such as
  89. -- newline); the other lines in the buffer always end in a line
  90. -- separator. Line separators count as characters when computing
  91. -- character counts and character offsets. Note that some Unicode
  92. -- line separators are represented with multiple bytes in UTF-8,
  93. -- and the two-character sequence "\r\n" is also considered a line
  94. -- separator.
  95. inherit G_OBJECT
  96. insert
  97. GTK
  98. GTK_TEXT_BUFFER_EXTERNALS
  99. G_SIGNALS
  100. creation
  101. make, from_external_pointer, with_tag_table
  102. feature {} -- Creation
  103. make is
  104. -- Creates a new text buffer.
  105. require
  106. gtk_initialized: gtk.is_initialized
  107. do
  108. from_external_pointer (gtk_text_buffer_new (default_pointer))
  109. -- TODO: Support GTK_TEXT_TAG_TABLEs. For now, creating a
  110. -- new one every time.
  111. end
  112. with_tag_table (a_tag_table: GTK_TEXT_TAG_TABLE) is
  113. require
  114. gtk_initialized: gtk.is_initialized
  115. non_void_table: a_tag_table/=Void
  116. do
  117. from_external_pointer (gtk_text_buffer_new(a_tag_table.handle))
  118. end
  119. feature -- Operations
  120. set_text(a_text: STRING) is
  121. -- Deletes current contents of buffer, and inserts `a_text'
  122. -- instead. `a_text' must be valid UTF-8.
  123. -- `a_text': UTF-8 text to insert
  124. require
  125. text_not_void: a_text /= Void
  126. text_is_utf8: -- TODO: a_text should be valid UTF-8!
  127. do
  128. gtk_text_buffer_set_text(handle, a_text.to_external, a_text.count)
  129. end
  130. feature -- Access
  131. text (a_start, an_end: GTK_TEXT_ITER; include_hidden_chars: BOOLEAN): STRING is
  132. -- the text in the range [`a_start',`an_end'). Excludes
  133. -- undisplayed text (text marked with tags that set the
  134. -- invisibility attribute) if `include_hidden_chars' is
  135. -- False. Does not include characters representing embedded
  136. -- images, so byte and character indexes into the returned
  137. -- string do not correspond to byte and character indexes
  138. -- into the buffer. Contrast with `slice'
  139. -- `a_start' : start of a range
  140. -- `an_end' : end of a range
  141. -- include_hidden_chars : whether to include invisible text
  142. --obsolete "Result's type will be changed to UTF8_STRING when this class will be available"
  143. require
  144. start_not_void: a_start /= Void
  145. end_not_void: an_end /= Void
  146. start_in_current_buffer: a_start.buffer = Current
  147. end_in_current_buffer: an_end.buffer = Current
  148. local
  149. p: POINTER
  150. do
  151. p := gtk_text_buffer_get_text (handle, a_start.handle, an_end.handle, include_hidden_chars.to_integer)
  152. check not p.is_null end
  153. create Result.from_external (p)
  154. ensure
  155. not_void: Result /= Void
  156. end
  157. line_count: INTEGER is
  158. -- the number of lines in the buffer. This value is cached,
  159. -- so the function is very fast.
  160. do
  161. Result:=gtk_text_buffer_get_line_count (handle)
  162. end
  163. char_count: INTEGER is
  164. -- the number of characters in the buffer; note that
  165. -- characters and bytes are not the same, you can't
  166. -- e.g. expect the contents of the buffer in string form to
  167. -- be this many bytes long. The character count is cached, so
  168. -- this function is very fast.
  169. do
  170. Result := gtk_text_buffer_get_char_count (handle)
  171. end
  172. tag_table: GTK_TEXT_TAG_TABLE is
  173. -- the GtkTextTagTable associated with this buffer.
  174. local factory: G_OBJECT_EXPANDED_FACTORY [GTK_TEXT_TAG_TABLE]
  175. do
  176. if hidden_tag_table = Void then
  177. hidden_tag_table := factory.wrapper (gtk_text_buffer_get_tag_table (handle))
  178. end
  179. Result := hidden_tag_table
  180. end
  181. insert_at (an_iter: GTK_TEXT_ITER; some_text: STRING) is
  182. -- Inserts `a_length' bytes of text at `an_iter' position. Emits the
  183. -- "insert_text" signal; insertion actually occurs in the default
  184. -- handler for the signal. iter is invalidated when insertion occurs
  185. -- (because the buffer contents change), but the default signal handler
  186. -- revalidates it to point to the end of the inserted text.
  187. -- Note: C API has also a lenght argument, put at -1 for
  188. -- nul-terminated that will be inserted entirely.
  189. require
  190. valid_iter: an_iter /= Void
  191. some_text: some_text /= Void
  192. -- valid_length: a_length >= -1
  193. do
  194. gtk_text_buffer_insert (handle, an_iter.handle, some_text.to_external, -1)
  195. end
  196. insert_at_cursor (some_text: STRING; a_length: INTEGER) is
  197. -- calls `insert_at', using the current cursor position as the
  198. -- insertion point.
  199. do
  200. gtk_text_buffer_insert_at_cursor (handle, some_text.to_external, a_length)
  201. end
  202. is_successful: BOOLEAN
  203. -- Have the last operation been successful? Typically updated
  204. -- by insertion commands
  205. insert_interactive (an_iter: GTK_TEXT_ITER; a_text: STRING;
  206. a_length: INTEGER; default_editable: BOOLEAN) is
  207. -- Like `insert_at', but the insertion will not occur if
  208. -- `an_iter' is at a non-editable location in the
  209. -- buffer. Usually you want to prevent insertions at
  210. -- ineditable locations if the insertion results from a user
  211. -- action (is interactive).
  212. -- `default_editable' indicates the editability of text that
  213. -- doesn't have a tag affecting editability applied to
  214. -- it. Typically the result of GTK_TEXT_VIEW's `is_editable'
  215. -- is appropriate here.
  216. -- `an_iter': a position in buffer
  217. -- `a_text': some UTF-8 text
  218. -- `a_length': length of text in bytes, or -1
  219. -- `default_editable': default editability of buffer
  220. -- `is_successful' is set to True whether text was actually inserted
  221. do
  222. is_successful := (gtk_text_buffer_insert_interactive
  223. (handle, an_iter.handle,
  224. a_text.to_external, a_length,
  225. default_editable.to_integer)).to_boolean
  226. end
  227. insert_interactive_at_cursor (a_text: STRING; a_length: INTEGER; default_editable: BOOLEAN) is
  228. -- Calls `insert_interactive' at the cursor position.
  229. -- `default_editable' indicates the editability of text that
  230. -- doesn't have a tag affecting editability applied to
  231. -- it. Typically the result of GTK_TEXT_VIEW's `is_editable'
  232. -- is appropriate here.
  233. -- `a_text': text in UTF-8 format
  234. -- `a_length': length of text in bytes, or -1
  235. -- `default_editable': default editability of buffer
  236. -- `is_successful' is updated (i.e. True whether text was
  237. -- actually inserted, false otherwise).
  238. do
  239. is_successful:=(gtk_text_buffer_insert_interactive_at_cursor
  240. (handle, a_text.to_external, a_length,
  241. default_editable.to_integer)).to_boolean
  242. end
  243. insert_range (an_iter, a_start, an_end: GTK_TEXT_ITER) is
  244. -- Copies text, tags, and pixbufs between `a_start' and
  245. -- `an_end' (the order of start and end doesn't matter) and
  246. -- inserts the copy at `an_iter'. Used instead of simply
  247. -- getting/inserting text because it preserves images and
  248. -- tags. If start and end are in a different buffer from
  249. -- buffer, the two buffers must share the same tag table.
  250. -- Implemented via emissions of the `insert_text' and
  251. -- `apply_tag' signals, so expect those.
  252. -- `a_start' and `an_end' are positions in the same
  253. -- GtkTextBuffer
  254. -- `is_successful' *not* is updated. Use `insert_range_interactive'
  255. -- if you need that.
  256. require
  257. iter_not_void: an_iter /= Void
  258. start_not_void: a_start /= Void
  259. end_not_void: an_end /= Void
  260. start_and_end_in_the_same_buffer: a_start.buffer = an_end.buffer
  261. do
  262. gtk_text_buffer_insert_range (handle, an_iter.handle,
  263. a_start.handle, an_end.handle)
  264. end
  265. insert_range_interactive (an_iter, a_start, an_end: GTK_TEXT_ITER;
  266. default_editable: BOOLEAN) is
  267. -- Same as `insert_range', but does nothing if the insertion
  268. -- point isn't editable. The `default_editable' parameter
  269. -- indicates whether the text is editable at iter if no tags
  270. -- enclosing `an_iter' affect editability. Typically the result of
  271. -- GTK_TEXT_VIEW's `is_editable' is appropriate here.
  272. -- `is_successful' is updated (i.e. True whether text was
  273. -- actually inserted, false otherwise).
  274. require
  275. iter_not_void: an_iter /= Void
  276. start_not_void: a_start /= Void
  277. end_not_void: an_end /= Void
  278. start_and_end_in_the_same_buffer: a_start.buffer = an_end.buffer
  279. do
  280. is_successful := (gtk_text_buffer_insert_range_interactive
  281. (handle, an_iter.handle,
  282. a_start.handle, an_end.handle,
  283. default_editable.to_integer)).to_boolean
  284. end
  285. insert_with_tags (an_iter: GTK_TEXT_ITER; some_text: STRING;
  286. some_tags: COLLECTION[GTK_TEXT_TAG]) is
  287. -- Inserts `some_text' into buffer at `an_iter', applying the
  288. -- list of tags to the newly-inserted text. Equivalent to
  289. -- calling `insert_at', then `apply_tag' on the inserted
  290. -- text; this is just a convenience feature.
  291. -- `an_iter': an iterator in buffer
  292. -- `some_text': UTF-8 text
  293. -- `some_tags' : collection of tags to apply to text
  294. require
  295. iter_not_void: an_iter /= Void
  296. text_not_void: some_text /= Void
  297. tags_not_void: some_tags /= Void
  298. local
  299. tags: ITERATOR[GTK_TEXT_TAG];
  300. a_start_offset: INTEGER
  301. a_start_iter: GTK_TEXT_ITER
  302. do
  303. -- Note: this code is a more or less direct traduction from C
  304. -- to Eiffel of the "internal" GTK implementation.
  305. a_start_offset := an_iter.offset
  306. insert_at (an_iter, some_text)
  307. -- Now an_iter points to the end of the inserted text
  308. a_start_iter := iter_at_offset (a_start_offset)
  309. tags := some_tags.get_new_iterator
  310. from tags.start until tags.is_off
  311. loop
  312. apply_tag (tags.item, a_start_iter, an_iter)
  313. tags.next
  314. end
  315. end
  316. insert_with_tags_by_name (an_iter: GTK_TEXT_ITER; some_text: STRING;
  317. some_tag_names: COLLECTION[STRING]) is
  318. -- Inserts `some_text' into buffer at `an_iter', applying the
  319. -- list of tags to the newly-inserted text. Same as
  320. -- `insert_with_tags', but allows you to pass in tag names
  321. -- instead of tag objects.
  322. -- `an_iter': an iterator in buffer
  323. -- `some_text': UTF-8 text
  324. -- `some_tags_name' : collection of names of tags to apply to text
  325. require
  326. iter_not_void: an_iter /= Void
  327. text_not_void: some_text /= Void
  328. tag_names_not_void: some_tag_names /= Void
  329. local
  330. tag_names: ITERATOR[STRING]; tag: GTK_TEXT_TAG
  331. a_start_offset: INTEGER
  332. a_start_iter: GTK_TEXT_ITER
  333. do
  334. -- Note: this code is a more or less direct traduction from C
  335. -- to Eiffel of the "internal" GTK implementation.
  336. a_start_offset := an_iter.offset
  337. insert_at (an_iter, some_text)
  338. -- Now an_iter points to the end of the inserted text
  339. a_start_iter := iter_at_offset (a_start_offset)
  340. tag_names := some_tag_names.get_new_iterator
  341. from tag_names.start until tag_names.is_off
  342. loop
  343. tag := tag_table.lookup (tag_names.item)
  344. check tag_not_void: tag /= Void end
  345. apply_tag (tag, a_start_iter, an_iter)
  346. tag_names.next
  347. end
  348. end
  349. delete (a_start, an_end: GTK_TEXT_ITER) is
  350. -- Deletes text between `a_start' and `an_end'. The order of
  351. -- start and end is not actually relevant; `delete' will
  352. -- reorder them. This function actually emits the
  353. -- "delete_range" signal, and the default handler of that
  354. -- signal deletes the text. Because the buffer is modified,
  355. -- all outstanding iterators become invalid after calling
  356. -- this function; however, the start and end will be
  357. -- re-initialized to point to the location where text was
  358. -- deleted.
  359. require
  360. start_not_void: a_start /= Void
  361. end_not_void: an_end /= Void
  362. start_in_current_buffer: a_start.buffer = Current
  363. end_in_current_buffer: an_end.buffer = Current
  364. do
  365. gtk_text_buffer_delete(handle, a_start.handle, an_end.handle)
  366. ensure
  367. ordered_iterators: a_start <= an_end
  368. ordering_could_have_changed_iterators: (((old a_start) >= (old an_end)) implies
  369. (a_start.is_equal(old an_end) and
  370. (an_end.is_equal(old a_start))))
  371. end
  372. delete_interactive (a_start, an_end: GTK_TEXT_ITER;
  373. default_editable: BOOLEAN) is
  374. -- Deletes all editable text in the given range. Calls
  375. -- `buffer_delete' for each editable sub-range of [`a_start',
  376. -- `an_end'). `a_start' and `an_end' are revalidated to point to the
  377. -- location of the last deleted range, or left untouched if
  378. -- no text was deleted.
  379. -- `a_start': start of range to delete
  380. -- `an_end': end of range
  381. -- `default_editable': whether the buffer is editable by default
  382. -- `is_successful' is set to True whether some text was
  383. -- actually deleted, False otherwise.
  384. do
  385. is_successful:=(gtk_text_buffer_delete_interactive
  386. (handle, a_start.handle, an_end.handle,
  387. default_editable.to_integer)).to_boolean
  388. end
  389. backspace (an_iter: GTK_TEXT_ITER; interactive, default_editable: BOOLEAN) is
  390. -- Performs the appropriate action as if the user hit the
  391. -- delete key with the cursor at the position specified by
  392. -- iter. In the normal case a single character will be
  393. -- deleted, but when combining accents are involved, more
  394. -- than one character can be deleted, and when precomposed
  395. -- character and accent combinations are involved, less than
  396. -- one character will be deleted.
  397. -- Because the buffer is modified, all outstanding iterators
  398. -- become invalid after calling this function; however, the
  399. -- iter will be re-initialized to point to the location where
  400. -- text was deleted.
  401. -- `an_iter': a position in buffer
  402. -- `interactive': whether the deletion is caused by user
  403. -- interaction
  404. -- `default_editable': whether the buffer is editable by
  405. -- default
  406. -- `is_successful' is set to True if the buffer was modified,
  407. -- False otherwise.
  408. require
  409. iter_not_void: an_iter /= Void
  410. iter_in_current_buffer: an_iter.buffer = Current
  411. do
  412. is_successful:=(gtk_text_buffer_backspace
  413. (handle, an_iter.handle,
  414. interactive.to_integer,
  415. default_editable.to_integer)).to_boolean
  416. end
  417. slice (a_start, an_end: GTK_TEXT_ITER;
  418. include_hidden_chars: BOOLEAN): STRING is
  419. -- the text in the range [`a_start,' `an_end'). Excludes
  420. -- undisplayed text (text marked with tags that set the
  421. -- invisibility attribute) if `include_hidden_chars' is
  422. -- FALSE. The string includes a 0xFFFC character whenever the
  423. -- buffer contains embedded images, so byte and character
  424. -- indexes into Result do correspond to byte and character
  425. -- indexes into the buffer. Contrast with `text'. Note that
  426. -- 0xFFFC can occur in normal text as well, so it is not a
  427. -- reliable indicator that a pixbuf or widget is in the
  428. -- buffer.
  429. -- `a_start' : start of a range
  430. -- `an_end' : end of a range
  431. -- include_hidden_chars : whether to include invisible text
  432. obsolete "Result will be changed to UTF8_STRING when this class will be available"
  433. require
  434. start_not_void: a_start /= Void
  435. end_not_void: an_end /= Void
  436. start_in_current_buffer: a_start.buffer = Current
  437. end_in_current_buffer: an_end.buffer = Current
  438. do
  439. create Result.from_external
  440. (gtk_text_buffer_get_slice (handle,
  441. a_start.handle, an_end.handle,
  442. include_hidden_chars.to_integer))
  443. end
  444. insert_pixbuf (an_iter: GTK_TEXT_ITER; an_image: GDK_PIXBUF) is
  445. -- Inserts `an_image' into the text buffer at `an_iter'. The
  446. -- image will be counted as one character in character
  447. -- counts, and when obtaining the buffer contents as a
  448. -- string, will be represented by the Unicode "object
  449. -- replacement character" 0xFFFC. Note that the "slice"
  450. -- variants for obtaining portions of the buffer as a string
  451. -- include this character for pixbufs, but the "text"
  452. -- variants do not. e.g. see `slice' and `text'.
  453. -- `an_iter' : location to insert the pixbuf
  454. require
  455. iter_not_void: an_iter /= Void
  456. image_not_void: an_image /= Void
  457. iter_in_current_buffer: an_iter.buffer = Current
  458. do
  459. gtk_text_buffer_insert_pixbuf (handle, an_iter.handle, an_image.handle)
  460. end
  461. insert_child_anchor (an_iter: GTK_TEXT_ITER; an_anchor: GTK_TEXT_CHILD_ANCHOR) is
  462. -- Inserts a child widget anchor (`an_anchor') into the text
  463. -- buffer at `an_iter'. The anchor will be counted as one
  464. -- character in character counts, and when obtaining the
  465. -- buffer contents as a string, will be represented by the
  466. -- Unicode "object replacement character" 0xFFFC. Note that
  467. -- the `slice' feature- used to obtain portions of the buffer
  468. -- as a string - include this character for child anchors,
  469. -- but the `text' feature do not. Consider
  470. -- `create_child_anchor' as a more convenient alternative to
  471. -- this function. The buffer will add a reference to the
  472. -- anchor, so you can `unref' it after insertion.
  473. -- `an_iter' : location to insert the anchor
  474. require
  475. iter_not_void: an_iter /= Void
  476. anchor_not_void: an_anchor /= Void
  477. iter_in_current_buffer: an_iter.buffer = Current
  478. do
  479. gtk_text_buffer_insert_child_anchor(handle, an_iter.handle, an_anchor.handle)
  480. end
  481. child_anchor_at (an_iter: GTK_TEXT_ITER): GTK_TEXT_CHILD_ANCHOR is
  482. -- A newly created child anchor, inserted into the buffer at `an_iter'.
  483. require
  484. iter_not_void: an_iter /= Void
  485. iter_in_current_buffer: an_iter.buffer = Current
  486. do
  487. create Result.from_external_pointer (gtk_text_buffer_create_child_anchor (handle, an_iter.handle))
  488. -- Note: C documentation says "The new anchor is owned by the
  489. -- buffer; no reference count is returned to the caller of
  490. -- gtk_text_buffer_create_child_anchor()"; so we have to
  491. Result.unref
  492. -- because the from_external_pointer ref-ed it.
  493. end
  494. create_mark (a_mark_name: STRING; a_place: GTK_TEXT_ITER; left_gravity: BOOLEAN): GTK_TEXT_MARK is
  495. -- Creates a mark at `a_place'. If mark_name is NULL, the
  496. -- mark is anonymous; otherwise, the mark can be retrieved by
  497. -- name using `mark'. If a mark has left gravity, and text is
  498. -- inserted at the mark's current location, the mark will be
  499. -- moved to the left of the newly-inserted text. If the mark
  500. -- has right gravity (`left_gravity' = False), the mark will
  501. -- end up on the right of newly-inserted text. The standard
  502. -- left-to-right cursor is a mark with right gravity (when
  503. -- you type, the cursor stays on the right side of the text
  504. -- you're typing).
  505. -- Emits the "mark_set" signal as notification of the mark's
  506. -- initial placement.
  507. require
  508. name_not_void: a_mark_name /= Void
  509. iter_not_void: a_place /= Void
  510. iter_in_current_buffer: a_place.buffer = Current
  511. do
  512. create Result.from_external_pointer
  513. (gtk_text_buffer_create_mark (handle, a_mark_name.to_external,
  514. a_place.handle, left_gravity.to_integer))
  515. -- The caller of this function does not own a reference to
  516. -- the returned GtkTextMark, so you can ignore the return
  517. -- value if you like. Marks are owned by the buffer and go
  518. -- away when the buffer does.
  519. end
  520. move_mark (a_mark: GTK_TEXT_MARK; a_new_location: GTK_TEXT_ITER) is
  521. -- Moves `a_mark' to `a_new_location'. Emits the "mark_set"
  522. -- signal as notification of the move.
  523. require
  524. mark_not_void: a_mark /= Void
  525. iter_not_void: a_new_location /= Void
  526. iter_in_current_buffer: a_new_location.buffer = Current
  527. do
  528. gtk_text_buffer_move_mark (handle, a_mark.handle, a_new_location.handle)
  529. end
  530. move_mark_by_name (a_name: STRING; a_new_location: GTK_TEXT_ITER) is
  531. -- Moves the mark named `a_name' (which must exist) to
  532. -- `a_new_location' where. See `move_mark' for details.
  533. require
  534. name_not_void: a_name /= Void
  535. named_mark_exists: mark (a_name) /= Void
  536. -- Note: the above precondition is not a monster of
  537. -- efficiency... it could have been made faster
  538. do
  539. gtk_text_buffer_move_mark_by_name (handle, a_name.to_external, a_new_location.handle)
  540. end
  541. delete_mark (a_mark: GTK_TEXT_MARK) is
  542. -- Deletes `a_mark,' so that it's no longer located anywhere
  543. -- in the buffer. Removes the reference the buffer holds to
  544. -- the mark, so if you haven't called g_object_ref() on the
  545. -- mark, it will be freed. Even if the mark isn't freed, most
  546. -- operations on mark become invalid. There is no way to
  547. -- undelete a mark.
  548. -- The "mark_deleted" signal will be emitted as notification
  549. -- after the mark is deleted.
  550. require mark_not_void: a_mark /= Void
  551. do
  552. gtk_text_buffer_delete_mark (handle, a_mark.handle)
  553. ensure mark_deleted: a_mark.is_deleted
  554. end
  555. delete_mark_by_name (a_name: STRING) is
  556. -- Deletes the mark named `a_name'; the mark must exist. See
  557. -- `delete_mark' for details.
  558. require
  559. name_not_void: a_name /= Void
  560. named_mark_exists: mark (a_name) /= Void
  561. do
  562. gtk_text_buffer_delete_mark_by_name (handle, a_name.to_external)
  563. end
  564. mark (a_name: STRING): GTK_TEXT_MARK is
  565. -- the mark named `a_name' in Current buffer, or Void if no
  566. -- such mark exists in the buffer.
  567. require
  568. name_not_void: a_name /= Void
  569. do
  570. create Result.from_external_pointer (gtk_text_buffer_get_mark (handle, a_name.to_external))
  571. -- Note: text mark are not cached because AFAIK once
  572. -- invalidated they can't be re-used and must be freed. Paolo
  573. -- 2007-01-05
  574. end
  575. insert_mark: GTK_TEXT_MARK is
  576. -- the mark that represents the cursor (insertion
  577. -- point). Equivalent to calling `mark(once "insert")' but very
  578. -- slightly more efficient, and involves less typing.
  579. local
  580. mark_ptr: POINTER
  581. mark_factory: G_OBJECT_EXPANDED_FACTORY [GTK_TEXT_MARK]
  582. do
  583. Result := mark_factory.wrapper (gtk_text_buffer_get_insert(handle))
  584. end
  585. selection_bound: GTK_TEXT_MARK is
  586. -- the mark that represents the selection bound. Equivalent
  587. -- to calling `mark(once "selection_bound")', but very slightly
  588. -- more efficient, and involves less typing.
  589. -- The currently-selected text in buffer is the region
  590. -- between the "selection_bound" and "insert" marks. If
  591. -- "selection_bound" and "insert" are in the same place, then
  592. -- there is no current selection. `selection_bounds' is
  593. -- another convenient function for handling the selection, if
  594. -- you just want to know whether there's a selection and what
  595. -- its bounds are.
  596. do
  597. create Result.from_external_pointer(gtk_text_buffer_get_selection_bound(handle))
  598. -- Note: text mark are not cached because AFAIK once
  599. -- invalidated they can't be re-used and must be freed. Paolo
  600. -- 2007-01-05
  601. end
  602. place_cursor (where: GTK_TEXT_ITER) is
  603. -- Moves the "insert" and "selection_bound" marks
  604. -- simultaneously. If you move them to the same place in two
  605. -- steps with `move_mark', you will temporarily select a
  606. -- region in between their old and new locations, which can
  607. -- be pretty inefficient since the temporarily-selected
  608. -- region will force stuff to be recalculated. This function
  609. -- moves them as a unit, which can be optimized.
  610. require
  611. where_not_void: where /= Void
  612. where_in_current_buffer: where.buffer = Current
  613. do
  614. gtk_text_buffer_place_cursor(handle, where.handle)
  615. ensure
  616. insert_mark_moved: iter_at_mark(insert_mark).is_equal(where)
  617. selection_bound_moved: iter_at_mark(selection_bound).is_equal(where)
  618. selection_bound_equal_insert: selection_bound.is_equal(insert_mark)
  619. end
  620. select_range (an_insert_mark, a_bound: GTK_TEXT_ITER) is
  621. -- moves the "insert" and "selection_bound" marks
  622. -- simultaneously. If you move them in two steps with
  623. -- `move_mark'), you will temporarily select a region in
  624. -- between their old and new locations, which can be pretty
  625. -- inefficient since the temporarily-selected region will
  626. -- force stuff to be recalculated. This function moves them
  627. -- as a unit, which can be optimized.
  628. -- `an_insert_mark': where to put the "insert" mark
  629. -- `a_bound': where to put the "selection_bound" mark
  630. do
  631. gtk_text_buffer_select_range (handle, an_insert_mark.handle, a_bound.handle)
  632. end
  633. apply_tag (a_tag: GTK_TEXT_TAG; a_start, an_end: GTK_TEXT_ITER) is
  634. -- Emits the "apply_tag" signal on buffer. The default
  635. -- handler for the signal applies tag to the given
  636. -- range. start and end do not have to be in order.
  637. -- `a_tag' : a GtkTextTag
  638. -- `a_start' : one bound of range to be tagged
  639. -- `an_end' : other bound of range to be tagged
  640. require
  641. tag_not_void: a_tag /= Void
  642. start_not_void: a_start /= Void
  643. end_not_void: an_end /= Void
  644. do
  645. gtk_text_buffer_apply_tag (handle, a_tag.handle, a_start.handle, an_end.handle)
  646. end
  647. remove_tag (a_tag: GTK_TEXT_TAG; a_start, an_end: GTK_TEXT_ITER) is
  648. -- Emits the "remove_tag" signal. The default handler for the
  649. -- signal removes all occurrences of tag from the given
  650. -- range. start and end don't have to be in order.
  651. -- `a_tag' : a GtkTextTag
  652. -- `a_start' : one bound of range to be tagged
  653. -- `an_end' : other bound of range to be tagged
  654. require
  655. tag_not_void: a_tag /= Void
  656. start_not_void: a_start /= Void
  657. end_not_void: an_end /= Void
  658. do
  659. gtk_text_buffer_remove_tag (handle, a_tag.handle,
  660. a_start.handle, an_end.handle)
  661. end
  662. apply_tag_by_name (a_tag_name: STRING; a_start, an_end: GTK_TEXT_ITER) is
  663. -- Calls ` gtk_text_tag_table_lookup' on the buffer's tag
  664. -- table to get a GtkTextTag, then calls `apply_tag'.
  665. -- `a_tag_name' : the name of a tag
  666. -- `a_start' : one bound of range to be tagged
  667. -- `an_end' : other bound of range to be tagged
  668. require
  669. tag_name_not_void: a_tag_name /= Void
  670. start_not_void: a_start /= Void
  671. end_not_void: an_end /= Void
  672. do
  673. gtk_text_buffer_apply_tag_by_name (handle,
  674. a_tag_name.to_external,
  675. a_start.handle, an_end.handle)
  676. end
  677. remove_tag_by_name (a_tag_name: STRING; a_start, an_end: GTK_TEXT_ITER) is
  678. -- Calls `gtk_text_tag_table_lookup' on the buffer's tag
  679. -- table to get a GtkTextTag, then calls `remove_tag'.
  680. -- `a_tag_name' : the name of a tag
  681. -- `a_start' : one bound of range to be tagged
  682. -- `an_end' : other bound of range to be tagged
  683. require
  684. tag_name_not_void: a_tag_name /= Void
  685. start_not_void: a_start /= Void
  686. end_not_void: an_end /= Void
  687. do
  688. gtk_text_buffer_remove_tag_by_name (handle,
  689. a_tag_name.to_external,
  690. a_start.handle, an_end.handle)
  691. end
  692. remove_all_tags (a_start, an_end: GTK_TEXT_ITER) is
  693. -- Removes all tags in the range between `a_start' and
  694. -- `an_end'. Be careful with this function; it could remove
  695. -- tags added in code unrelated to the code you're currently
  696. -- writing. That is, using this function is probably a bad
  697. -- idea if you have two or more unrelated code sections that
  698. -- add tags.
  699. -- `a_start' : one bound of range to be tagged
  700. -- `an_end' : other bound of range to be tagged
  701. require
  702. start_not_void: a_start /= Void
  703. end_not_void: an_end /= Void
  704. do
  705. gtk_text_buffer_remove_all_tags (handle, a_start.handle,an_end.handle)
  706. end
  707. create_tag (a_tag_name: STRING; some_properties: COLLECTION[TUPLE[STRING,G_VALUE]]): GTK_TEXT_TAG is
  708. -- Creates a tag and adds it to the tag table for
  709. -- buffer. Equivalent to calling `GTK_TEXT_TAG.make' and then
  710. -- adding the tag to the buffer's tag table. The tag is owned
  711. -- by the buffer's tag table, so the ref count will be equal
  712. -- to one.
  713. -- If a_tag_name is Void, the tag is anonymous.
  714. -- If tag_name is non-Void, a tag called tag_name must not
  715. -- already exist in the tag table for this buffer.
  716. -- The first_property_name argument and subsequent arguments
  717. -- are a list of properties to set on the tag, as with
  718. -- G_OBJECT's `set'.
  719. -- `a_tag_name': name of the new tag, or Void
  720. local
  721. iterator: ITERATOR[TUPLE[STRING,G_VALUE]]
  722. a_name: STRING
  723. a_value: G_VALUE
  724. do
  725. if a_tag_name /= Void then
  726. create Result.with_name (a_tag_name)
  727. else
  728. create Result.make
  729. end
  730. tag_table.add (Result)
  731. iterator := some_properties.get_new_iterator
  732. from
  733. iterator.start
  734. until
  735. iterator.is_off
  736. loop
  737. a_name := iterator.item.item_1
  738. a_value := iterator.item.item_2
  739. check
  740. name_not_void: a_name /= Void
  741. value_not_void: a_value /= Void
  742. end
  743. Result.set_property (a_name, a_value)
  744. iterator.next
  745. end
  746. end
  747. iter_at_line_offset (a_line_number, a_char_offset: INTEGER): GTK_TEXT_ITER is
  748. -- an iterator pointing to `a_char_offset' (offset from start
  749. -- of line) within `a_line_number' (counting from 0). The
  750. -- `a_char_offset' must exist, offsets off the end of the
  751. -- line are not allowed. Note characters, not bytes; UTF-8
  752. -- may encode one character as multiple bytes.
  753. do
  754. create Result.make
  755. gtk_text_buffer_get_iter_at_line_offset (handle, Result.handle,
  756. a_line_number, a_char_offset)
  757. end
  758. iter_at_offset (an_offset: INTEGER): GTK_TEXT_ITER is
  759. -- The iterator pointing to a position `an_offset' chars from
  760. -- the start of the entire buffer. If `an_offset' is -1 or
  761. -- greater than the number of characters in the buffer, iter
  762. -- is initialized to the end iterator, the iterator one past
  763. -- the last valid character in the buffer.
  764. -- `an_offset': char offset from start of buffer, counting
  765. -- from 0, or -1
  766. do
  767. create Result.make
  768. gtk_text_buffer_get_iter_at_offset (handle, Result.handle, an_offset)
  769. end
  770. iter_at_line (a_line_number: INTEGER): GTK_TEXT_ITER is
  771. -- an iterator to the start of the given line (counting from
  772. -- 0).
  773. do
  774. create Result.make
  775. gtk_text_buffer_get_iter_at_line(handle, Result.handle, a_line_number)
  776. end
  777. iter_at_line_index (a_line_number, a_byte_index: INTEGER): GTK_TEXT_ITER is
  778. -- Obtains an iterator pointing to `a_byte_index' within the
  779. -- `a_line_number' (counting from 0). `a_byte_index' must be
  780. -- the start of a UTF-8 character, and must not be beyond the
  781. -- end of the line. Note bytes, not characters; UTF-8 may
  782. -- encode one character as multiple bytes.
  783. -- buffer : a GtkTextBuffer
  784. -- iter : iterator to initialize
  785. -- byte_index : byte index from start of line
  786. do
  787. create Result.make
  788. gtk_text_buffer_get_iter_at_line_index (handle, Result.handle,
  789. a_line_number, a_byte_index)
  790. ensure not_void: Result /= Void
  791. end
  792. iter_at_mark (a_mark: GTK_TEXT_MARK): GTK_TEXT_ITER is
  793. -- A newly allocated iterator with the current position of `a_mark'.
  794. require mark_not_void: a_mark /= Void
  795. do
  796. create Result.make
  797. gtk_text_buffer_get_iter_at_mark(handle, Result.handle, a_mark.handle)
  798. ensure not_void: Result /= Void
  799. end
  800. iter_at_child_anchor (an_anchor: GTK_TEXT_CHILD_ANCHOR): GTK_TEXT_ITER is
  801. -- the location of anchor within buffer.
  802. require anchor_not_void: an_anchor /= Void
  803. do
  804. create Result.make
  805. gtk_text_buffer_get_iter_at_child_anchor(handle,Result.handle, an_anchor.handle)
  806. ensure not_void: Result /= Void
  807. end
  808. start_iter: GTK_TEXT_ITER is
  809. -- A newly created iterator with the first position in the
  810. -- text buffer. This is the same as using
  811. -- `get_iter_at_offset' to get the iter at character offset
  812. -- 0.
  813. do
  814. --create Result.make
  815. Result := iter_at_offset (0)
  816. gtk_text_buffer_get_start_iter(handle, Result.handle)
  817. ensure not_void: Result /= Void
  818. end
  819. end_iter: GTK_TEXT_ITER is
  820. -- A newly created iterator with the "end iterator," one past
  821. -- the last valid character in the text buffer. If
  822. -- dereferenced with `char', the end iterator has a
  823. -- character value of 0. The entire buffer lies in the range
  824. -- from the first position in the buffer (call
  825. -- gtk_text_buffer_get_start_iter() to get character position
  826. -- 0) to the end iterator.
  827. do
  828. create Result.make
  829. gtk_text_buffer_get_end_iter (handle, Result.handle)
  830. ensure
  831. not_void: Result /= Void
  832. is_off: Result.is_off
  833. end
  834. bounds: TUPLE[GTK_TEXT_ITER, GTK_TEXT_ITER] is
  835. -- the first and last iterators in the buffer; the entire buffer lies within the range.
  836. local a_start, an_end: GTK_TEXT_ITER
  837. do
  838. create a_start.make; create an_end.make
  839. gtk_text_buffer_get_bounds(handle, a_start.handle, an_end.handle)
  840. create Result.make_2(a_start, an_end)
  841. end
  842. is_modified: BOOLEAN is
  843. -- Has the buffer been modified after the last call to
  844. -- `set_modified' set it to False. Used for example to enable
  845. -- a "save" function in a text editor.
  846. do
  847. Result := gtk_text_buffer_get_modified(handle).to_boolean
  848. end
  849. set_modified (a_setting: BOOLEAN) is
  850. -- Used to keep track of whether the buffer has been modified
  851. -- since the last time it was saved. Whenever the buffer is
  852. -- saved to disk, call `set_modified(False)'. When the buffer
  853. -- is modified, it will automatically toggled on the modified
  854. -- bit again. When the modified bit flips, the buffer emits a
  855. -- "modified_changed" signal.
  856. do
  857. gtk_text_buffer_set_modified (handle, a_setting.to_integer)
  858. end
  859. delete_selection (interactive, default_editable: BOOLEAN) is
  860. -- Deletes the range between the "insert" and
  861. -- "selection_bound" marks, that is, the currently-selected
  862. -- text. If `interactive' is True, the editability of the
  863. -- selection will be considered (users can't delete
  864. -- uneditable text).
  865. -- `interactive': whether the deletion is caused by user
  866. -- interaction
  867. -- `default_editable': whether the buffer is editable by
  868. -- default
  869. -- `is_successful' will be True if there was a non-empty
  870. -- selection to delete.
  871. do
  872. is_successful:=(gtk_text_buffer_delete_selection(handle,
  873. interactive.to_integer,
  874. default_editable.to_integer).to_boolean)
  875. end
  876. paste_clipboard (a_clipboard: GTK_CLIPBOARD; an_override_location: GTK_TEXT_ITER; default_editable: BOOLEAN) is
  877. -- Pastes the contents of `a_clipboard' at the insertion
  878. -- point, or at `override_location' (if it is not
  879. -- Void). (Note: pasting is asynchronous, that is, we'll ask
  880. -- for the paste data and return, and at some point later
  881. -- after the main loop runs, the paste data will be
  882. -- inserted.)
  883. -- `an_override_location': location to insert pasted text, or
  884. -- Void for at the cursor
  885. -- `default_editable' : whether the buffer is editable by default
  886. require
  887. clipboard_not_void: a_clipboard /= Void
  888. location_not_void: an_override_location /= Void
  889. do
  890. gtk_text_buffer_paste_clipboard (handle, a_clipboard.handle,
  891. an_override_location.handle, default_editable.to_integer)
  892. end
  893. copy_clipboard (a_clipboard: GTK_CLIPBOARD) is
  894. -- Copies the currently-selected text to `a_clipboard'.
  895. require
  896. clipboard_not_void: a_clipboard /= Void
  897. do
  898. gtk_text_buffer_copy_clipboard (handle, a_clipboard.handle)
  899. end
  900. cut_clipboard (a_clipboard: GTK_CLIPBOARD; default_editable: BOOLEAN) is
  901. -- Copies the currently-selected text to `a_clipboard,' then
  902. -- deletes said text if it's editable. `default_editable' is
  903. -- the default editability of the buffer.
  904. require
  905. clipboard_not_void: a_clipboard /= Void
  906. do
  907. gtk_text_buffer_cut_clipboard (handle, a_clipboard.handle, default_editable.to_integer)
  908. end
  909. selection_bounds: TUPLE[GTK_TEXT_ITER, GTK_TEXT_ITER] is
  910. -- the selection start and end; Void if there is no selection
  911. local a_start, an_end: GTK_TEXT_ITER; is_some_text_selected: BOOLEAN
  912. do
  913. create a_start.make; create an_end.make
  914. is_some_text_selected:=(gtk_text_buffer_get_selection_bounds
  915. (handle,a_start.handle, an_end.handle).to_boolean)
  916. if is_some_text_selected then
  917. create Result.make_2(a_start, an_end)
  918. end
  919. end
  920. begin_user_action is
  921. -- Called to indicate that the buffer operations between here
  922. -- and a call to `end_user_action' are part of a single
  923. -- user-visible operation. The operations between
  924. -- `begin_user_action' and `end_user_action' can then be
  925. -- grouped when creating an undo stack. GtkTextBuffer
  926. -- maintains a count of calls to `begin_user_action' that
  927. -- have not been closed with a call to `end_user_action', and
  928. -- emits the "begin_user_action" and "end_user_action"
  929. -- signals only for the outermost pair of calls. This allows
  930. -- you to build user actions from other user actions.
  931. -- The "interactive" buffer mutation functions, such as
  932. -- insert_interactive, automatically call begin/end user
  933. -- action around the buffer operations they perform, so
  934. -- there's no need to add extra calls if you user action
  935. -- consists solely of a single call to one of those
  936. -- functions.
  937. do
  938. gtk_text_buffer_begin_user_action(handle)
  939. end
  940. end_user_action is
  941. -- See `begin_user_action' function for a full explanation.--
  942. -- Both calls should be paired.
  943. do
  944. gtk_text_buffer_end_user_action (handle)
  945. end
  946. -- gtk_text_buffer_add_selection_clipboard ()
  947. -- void gtk_text_buffer_add_selection_clipboard
  948. -- (GtkTextBuffer *buffer,
  949. -- GtkClipboard *clipboard);
  950. -- Adds clipboard to the list of clipboards in which the selection contents of buffer are available. In most cases, clipboard will be the GtkClipboard of type GDK_SELECTION_PRIMARY for a view of buffer.
  951. -- buffer : a GtkTextBuffer
  952. -- clipboard : a GtkClipboard
  953. -- gtk_text_buffer_remove_selection_clipboard ()
  954. -- void gtk_text_buffer_remove_selection_clipboard
  955. -- (GtkTextBuffer *buffer,
  956. -- GtkClipboard *clipboard);
  957. -- Removes a GtkClipboard added with gtk_text_buffer_add_selection_clipboard()
  958. -- buffer : a GtkTextBuffer
  959. -- clipboard : a GtkClipboard added to buffer by gtk_text_buffer_add_selection_clipboard().
  960. -- Property Details
  961. -- The "tag-table" property
  962. -- "tag-table" GtkTextTagTable : Read / Write / Construct Only
  963. -- Text Tag Table.
  964. -- The "text" property
  965. -- "text" gchararray : Read / Write
  966. -- The text content of the buffer. Without child widgets and images, see gtk_text_buffer_get_text() for more information.
  967. -- Default value: ""
  968. -- Since 2.8
  969. -- Signal Details
  970. feature -- TODO: The "apply-tag" signal
  971. -- void user_function (GtkTextBuffer *textbuffer,
  972. -- GtkTextTag *arg1,
  973. -- GtkTextIter *arg2,
  974. -- GtkTextIter *arg3,
  975. -- gpointer user_data) : Run last
  976. -- textbuffer : the object which received the signal.
  977. -- arg1 :
  978. -- arg2 :
  979. -- arg3 :
  980. -- user_data : user data set when the signal handler was connected.
  981. feature -- The "begin-user-action" signal
  982. begin_user_action_signal_name: STRING is "begin-user-action"
  983. -- void user_function (GtkTextBuffer *textbuffer,
  984. -- gpointer user_data) : Run last
  985. enable_on_begin_user_action is
  986. -- Connects "begin_user_action" signal to `on_begin_user_action' feature.
  987. do
  988. connect (Current, begin_user_action_signal_name, $on_begin_user_action)
  989. end
  990. on_begin_user_action is
  991. -- Built-in begin_user_action signal handler; empty by design; redefine it.
  992. -- Indicates that the user has begin_user_action the contents of the widget.
  993. do
  994. end
  995. connect_agent_to_begin_user_action_signal (a_procedure: PROCEDURE [ANY, TUPLE[like Current]]) is
  996. -- textbuffer : the object which received the signal.
  997. require valid_procedure: a_procedure /= Void
  998. local begin_user_action_callback: BEGIN_USER_ACTION_CALLBACK
  999. do
  1000. create begin_user_action_callback.make
  1001. begin_user_action_callback.connect (Current, a_procedure)
  1002. end
  1003. feature -- The "changed" signal
  1004. changed_signal_name: STRING is "changed"
  1005. enable_on_changed is
  1006. -- Connects "changed" signal to `on_changed' feature.
  1007. do
  1008. connect (Current, changed_signal_name, $on_changed)
  1009. end
  1010. on_changed is
  1011. -- Built-in changed signal handler; empty by design; redefine it.
  1012. -- Indicates that the user has changed the contents of the widget.
  1013. do
  1014. end
  1015. connect_agent_to_changed_signal (a_procedure: PROCEDURE [ANY, TUPLE[like Current]]) is
  1016. require valid_procedure: a_procedure /= Void
  1017. local changed_callback: CHANGED_CALLBACK [like Current]
  1018. do
  1019. create changed_callback.make
  1020. changed_callback.connect (Current, a_procedure)
  1021. end
  1022. feature -- TODO: The "delete-range" signal
  1023. -- void user_function (GtkTextBuffer *textbuffer,
  1024. -- GtkTextIter *arg1,
  1025. -- GtkTextIter *arg2,
  1026. -- gpointer user_data) : Run last
  1027. -- textbuffer : the object which received the signal.
  1028. -- arg1 :
  1029. -- arg2 :
  1030. -- user_data : user data set when the signal handler was connected.
  1031. feature -- The "end-user-action" signal
  1032. end_user_action_signal_name: STRING is "end-user-action"
  1033. -- void user_function (GtkTextBuffer *textbuffer,
  1034. -- gpointer user_data) : Run last
  1035. enable_on_end_user_action is
  1036. -- Connects "end_user_action" signal to `on_end_user_action' feature.
  1037. do
  1038. connect (Current, end_user_action_signal_name, $on_end_user_action)
  1039. end
  1040. on_end_user_action is
  1041. -- Built-in end_user_action signal handler; empty by design; redefine it.
  1042. -- Indicates that the user has end_user_action the contents of the widget.
  1043. do
  1044. end
  1045. connect_agent_to_end_user_action_signal (a_procedure: PROCEDURE [ANY, TUPLE[like Current]]) is
  1046. -- textbuffer : the object which received the signal.
  1047. require valid_procedure: a_procedure /= Void
  1048. local end_user_action_callback: END_USER_ACTION_CALLBACK
  1049. do
  1050. create end_user_action_callback.make
  1051. end_user_action_callback.connect (Current, a_procedure)
  1052. end
  1053. feature -- TODO: The "insert-child-anchor" signal
  1054. -- void user_function (GtkTextBuffer *textbuffer,
  1055. -- GtkTextIter *arg1,
  1056. -- GtkTextChildAnchor *arg2,
  1057. -- gpointer user_data) : Run last
  1058. -- textbuffer : the object which received the signal.
  1059. -- arg1 :
  1060. -- arg2 :
  1061. -- user_data : user data set when the signal handler was connected.
  1062. feature -- TODO: The "insert-pixbuf" signal
  1063. -- void user_function (GtkTextBuffer *textbuffer, GtkTextIter
  1064. -- *arg1, GdkPixbuf *arg2, gpointer user_data) : Run last
  1065. -- textbuffer : the object which received the signal.
  1066. -- arg1 :
  1067. -- arg2 :
  1068. -- user_data : user data set when the signal handler was connected.
  1069. feature -- The "insert-text" signal
  1070. connect_agent_to_insert_text_signal (a_procedure: PROCEDURE [ANY, TUPLE[GTK_TEXT_ITER, STRING, GTK_TEXT_BUFFER]]) is
  1071. -- textbuffer : the object which received the signal.
  1072. -- arg1 :
  1073. -- arg2 :
  1074. -- arg3 :
  1075. require
  1076. valid_procedure: a_procedure /= Void
  1077. local
  1078. insert_text_callback: BUFFER_INSERT_TEXT_CALLBACK
  1079. do
  1080. create insert_text_callback.make
  1081. insert_text_callback.connect (Current, a_procedure)
  1082. end
  1083. feature -- TODO: -- The "mark-deleted" signal
  1084. -- void user_function (GtkTextBuffer *textbuffer, GtkTextMark
  1085. -- *arg1, gpointer user_data) : Run last
  1086. -- textbuffer : the object which received the signal.
  1087. -- arg1 :
  1088. -- user_data : user data set when the signal handler was connected.
  1089. feature -- TODO: -- The "mark-set" signal
  1090. -- void user_function (GtkTextBuffer *textbuffer, GtkTextIter
  1091. -- *arg1, GtkTextMark *arg2, gpointer user_data) : Run last
  1092. -- textbuffer : the object which received the signal.
  1093. -- arg1 :
  1094. -- arg2 :
  1095. -- user_data : user data set when the signal handler was connected.
  1096. feature -- TODO: -- The "modified-changed" signal
  1097. -- void user_function (GtkTextBuffer *textbuffer, gpointer
  1098. -- user_data) : Run last
  1099. -- textbuffer : the object which received the signal.
  1100. -- user_data : user data set when the signal handler was connected.
  1101. feature -- TODO: -- The "remove-tag" signal
  1102. -- void user_function (GtkTextBuffer *textbuffer, GtkTextTag *arg1,
  1103. -- GtkTextIter *arg2, GtkTextIter *arg3, gpointer user_data) : Run
  1104. -- last
  1105. -- textbuffer : the object which received the signal.
  1106. -- arg1 :
  1107. -- arg2 :
  1108. -- arg3 :
  1109. -- user_data : user data set when the signal handler was connected.
  1110. feature {} -- Implementation
  1111. hidden_tag_table: GTK_TEXT_TAG_TABLE
  1112. -- Hidden reference to the Eiffel wrapper of the
  1113. -- GtkTextTagTable of Current. Handled by `tag_table'.
  1114. feature -- struct size
  1115. struct_size: INTEGER is
  1116. external "C inline use <gtk/gtk.h>"
  1117. alias "sizeof(GtkTextBuffer)"
  1118. end
  1119. end -- class GTK_TEXT_BUFFER