PageRenderTime 59ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 1ms

/src/wrappers/gtk/library/gtk_text_iter.e

http://github.com/tybor/Liberty
Specman e | 1614 lines | 835 code | 253 blank | 526 comment | 19 complexity | d00fda745daa79704a9689ba9edf16be MD5 | raw file
Possible License(s): GPL-3.0, LGPL-2.1, GPL-2.0
  1. indexing
  2. description: "GtkTextIter -- Text buffer iterator."
  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. gtk_documentation: "[
  19. You may wish to begin by reading the text widget conceptual
  20. overview which gives an overview of all the objects and data
  21. types related to the text widget and how they work together.
  22. ]"
  23. class GTK_TEXT_ITER
  24. inherit
  25. C_STRUCT
  26. -- Note: This class isn't really shared, but we need to make it
  27. -- conform to SHARED_C_STRUCT to be able to create G_SLISTs with
  28. -- it. It should be expanded, if Smarteiffel implements
  29. -- disposing expanded objects.
  30. redefine
  31. allocate, copy, is_equal
  32. end
  33. COMPARABLE
  34. redefine
  35. copy, is_equal, -- infix "<",
  36. infix "<=", infix ">", infix ">=", in_range, compare, three_way_comparison
  37. end
  38. insert
  39. GTK
  40. GTK_TEXT_SEARCH_FLAGS
  41. creation make, from_external_pointer, copy, from_external_copy
  42. feature {} -- Creation
  43. make is
  44. require gtk_initialized: gtk.is_initialized
  45. do
  46. allocate
  47. end
  48. feature {} -- Allocating
  49. allocate is
  50. require
  51. handle.is_null
  52. do
  53. -- The semantic of an GTK_TEXT_ITER is akin to an expanded
  54. -- object as they are usually allocated on the stack as
  55. -- locally declared variables. So they usually rely on the
  56. -- automatic memory handling of the stack.
  57. -- In our case there is no need to allocate a dummy object and then copy it.
  58. handle := calloc (1, struct_size)
  59. -- Different versions of GTK wrap either g_free or g_slice_free in gtk_text_iter_free.
  60. -- Also, there is no malloc-like function in GTK to allocate iterators.
  61. -- Therefore, we allocate iterators using gtk_text_iter_copy()
  62. -- handle := gtk_text_iter_copy (dummy_iter)
  63. if handle.is_null then
  64. raise_exception (No_more_memory)
  65. end
  66. end
  67. feature {} -- Disposing
  68. dispose is
  69. -- Free an iterator allocated on the heap. This function is
  70. -- intended for use in language bindings, and is not
  71. -- especially useful for applications, because iterators can
  72. -- simply be allocated on the stack.
  73. do
  74. -- There's an invariant that provides handle.is_not_null, but C_STRUCT
  75. -- calls dispose from within the constructor from_external_copy, which
  76. -- is certain to reach this code with a Void handle. Nothing breaks
  77. -- if you call gtk_text_iter_free here, but noisy Gtk warnings would
  78. -- ensue.
  79. if handle.is_not_null then free (handle) end
  80. handle := default_pointer
  81. end
  82. feature
  83. buffer: GTK_TEXT_BUFFER is
  84. -- the GtkTextBuffer this iterator is associated with.
  85. local factory: G_OBJECT_EXPANDED_FACTORY[GTK_TEXT_BUFFER]; buffer_ptr: POINTER
  86. do
  87. Result := factory.wrapper (gtk_text_iter_get_buffer (handle))
  88. end
  89. copy (another: like Current) is
  90. -- Copy `another' into Current. A new dynamically-allocated
  91. -- copy of the underlying iterator is made.
  92. require else
  93. another /= Void
  94. do
  95. -- Using `gtk_text_iter_copy', a function used by language
  96. -- bindings. It is not useful in applications, because
  97. -- iterators can be copied with a simple assignment
  98. -- (GtkTextIter i=j;).
  99. if handle.is_not_null then dispose end -- Frees any previously used resource
  100. handle := gtk_text_iter_copy (another.handle)
  101. if handle.is_null then
  102. raise_exception (No_more_memory)
  103. end
  104. end
  105. offset: INTEGER is
  106. -- the character offset of an iterator. Each character in a
  107. -- GtkTextBuffer has an offset, starting with 0 for the first
  108. -- character in the buffer. Use `iter_at_offset' to convert
  109. -- an offset back into an iterator.
  110. do
  111. Result := gtk_text_iter_get_offset (handle)
  112. end
  113. line: INTEGER is
  114. -- the line number containing the iterator. Lines in a
  115. -- GtkTextBuffer are numbered beginning with 0 for the first
  116. -- line in the buffer.
  117. do
  118. Result := gtk_text_iter_get_line (handle)
  119. end
  120. line_offset: INTEGER is
  121. -- the character offset of the iterator, counting from the
  122. -- start of a newline-terminated line. The first character on
  123. -- the line has offset 0.
  124. do
  125. Result := gtk_text_iter_get_line_offset (handle)
  126. end
  127. line_index: INTEGER is
  128. -- The byte index of the iterator, counting from the start of
  129. -- a newline-terminated line. Remember that GtkTextBuffer
  130. -- encodes text in UTF-8, and that characters can require a
  131. -- variable number of bytes to represent.
  132. do
  133. Result := gtk_text_iter_get_line_index (handle)
  134. end
  135. visible_line_index: INTEGER is
  136. -- the number of bytes from the start of the line to the
  137. -- given iter, not counting bytes that are invisible due to
  138. -- tags with the "invisible" flag toggled on.
  139. do
  140. Result := gtk_text_iter_get_visible_line_index (handle)
  141. end
  142. visible_line_offset: INTEGER is
  143. -- the offset in characters from the start of the line to the
  144. -- given iter, not counting characters that are invisible due
  145. -- to tags with the "invisible" flag toggled on.
  146. do
  147. Result:=gtk_text_iter_get_visible_line_offset(handle)
  148. end
  149. char: INTEGER is
  150. -- the Unicode character at this iterator. If the element at
  151. -- this iterator is a non-character element, such as an image
  152. -- embedded in the buffer, the Unicode "unknown" character
  153. -- 0xFFFC is returned. If invoked on the end iterator, zero
  154. -- is returned; zero is not a valid Unicode character. So you
  155. -- can write a loop which ends when `char' is 0.
  156. do
  157. Result := gtk_text_iter_get_char (handle)
  158. end
  159. slice (an_end: GTK_TREE_ITER): STRING is
  160. -- the text from current to `an_end'. A "slice" is an array
  161. -- of characters encoded in UTF-8 format, including the
  162. -- Unicode "unknown" character 0xFFFC for iterable
  163. -- non-character elements in the buffer, such as
  164. -- images. Because images are encoded in the slice, byte and
  165. -- character offsets in the returned array will correspond to
  166. -- byte offsets in the text buffer. Note that 0xFFFC can
  167. -- occur in normal text as well, so it is not a reliable
  168. -- indicator that a pixbuf or widget is in the buffer.
  169. obsolete "this is wrong! should be UNICODE_STRING!"
  170. require valid_end: an_end /= Void
  171. do
  172. create Result.from_external_copy (gtk_text_iter_get_slice (handle,
  173. an_end.handle))
  174. end
  175. text (an_end: GTK_TREE_ITER): STRING is
  176. -- text from Current to `an_end'. If the range contains
  177. -- non-text elements such as images, the character and byte
  178. -- offsets in the returned string will not correspond to
  179. -- character and byte offsets in the buffer. If you want
  180. -- offsets to correspond, see `slice'.
  181. obsolete "this is wrong! should be UNICODE_STRING!"
  182. require valid_end: an_end /= Void
  183. do
  184. create Result.from_external_copy(gtk_text_iter_get_text(handle,
  185. an_end.handle))
  186. end
  187. visible_slice (an_end: GTK_TEXT_ITER): STRING is
  188. -- Like `slice', but invisible text is not
  189. -- included. Invisible text is usually invisible because a
  190. -- GtkTextTag with the "invisible" attribute turned on has
  191. -- been applied to it.
  192. require valid_end: an_end /= Void
  193. do
  194. create Result.from_external_copy (gtk_text_iter_get_visible_slice (handle,
  195. an_end.handle))
  196. end
  197. visible_text (an_end: GTK_TEXT_ITER): STRING is
  198. -- Like `text', but invisible text is not included. Invisible
  199. -- text is usually invisible because a GtkTextTag with the
  200. -- "invisible" attribute turned on has been applied to it.
  201. require valid_end: an_end /= Void
  202. do
  203. create Result.from_external_copy (gtk_text_iter_get_visible_text (handle, an_end.handle))
  204. end
  205. pixbuf: GDK_PIXBUF is
  206. -- The pixbuf at Current iter position, if any. Otherwise Void
  207. local retriever: G_OBJECT_EXPANDED_FACTORY [GDK_PIXBUF]
  208. do
  209. Result := retriever.wrapper (gtk_text_iter_get_pixbuf (handle))
  210. end
  211. marks: G_SLIST [GTK_TEXT_MARK] is
  212. -- All the GTK_TEXT_MARK at Current location. Because marks
  213. -- are not iterable (they don't take up any "space" in the
  214. -- buffer, they are just marks in between iterable
  215. -- locations), multiple marks can exist in the same
  216. -- place. The list is not in any meaningful order.
  217. do
  218. create {G_OBJECT_SLIST [GTK_TEXT_MARK]} Result.from_external_pointer (gtk_text_iter_get_marks(handle))
  219. ensure result_not_void: Result /= Void
  220. end
  221. toggled_tags (toggled_on: BOOLEAN): G_SLIST [GTK_TEXT_TAG] is
  222. -- The GTK_TEXT_TAGs that are toggled on or off at this
  223. -- point. (If toggled_on is TRUE, the list contains tags that
  224. -- are toggled on.) If a tag is toggled on at iter, then some
  225. -- non-empty range of characters following iter has that tag
  226. -- applied to it. If a tag is toggled off, then some
  227. -- non-empty range following iter does not have the tag
  228. -- applied to it.
  229. do
  230. create {G_OBJECT_SLIST [GTK_TEXT_TAG]} Result.from_external_pointer
  231. (gtk_text_iter_get_toggled_tags (handle, toggled_on.to_integer))
  232. end
  233. child_anchor: GTK_TEXT_CHILD_ANCHOR is
  234. -- The anchor (with no new reference count added) at
  235. -- Current's location, if it exists . Void otherwise.
  236. local ptr: POINTER
  237. do
  238. ptr := gtk_text_iter_get_child_anchor (handle)
  239. if ptr.is_not_null then create Result.from_external_pointer (ptr) end
  240. end
  241. tag_begins (a_tag: GTK_TEXT_TAG): BOOLEAN is
  242. -- Is `a_tag' is toggled on at exactly this point? If `a_tag'
  243. -- is Void, returns TRUE if any tag is toggled on at this
  244. -- point. Note that this feature is True if iter is the start
  245. -- of the tagged range; `has_tag' tells you whether an
  246. -- iterator is within a tagged range.
  247. do
  248. Result := gtk_text_iter_begins_tag (handle, a_tag.handle).to_boolean
  249. end
  250. tag_ends (a_tag: GTK_TEXT_TAG): BOOLEAN is
  251. -- Is `a_tag' toggled off at exactly this point? Note that
  252. -- the `tag_ends' returns True if iter is the end of the
  253. -- tagged range; `has_tag' tells you whether an iterator is
  254. -- within a tagged range.
  255. require tag_not_void: a_tag /= Void
  256. do
  257. Result := (gtk_text_iter_ends_tag(handle, a_tag.handle).to_boolean)
  258. end
  259. is_any_tag_toggled: BOOLEAN is
  260. -- Is if any tag toggled off at this point?
  261. do
  262. Result := (gtk_text_iter_ends_tag(handle, default_pointer).to_boolean)
  263. end
  264. toggles_tag (a_tag: GTK_TEXT_TAG): BOOLEAN is
  265. -- Is `a_tag' toggled on or off at Current iterator? This is
  266. -- equivalent to (tag_begins or tag_ends), i.e. it tells you
  267. -- whether a range with tag applied to it begins or ends at
  268. -- iter.
  269. -- TODO: the C implementation allow a NULL tag. Check if it
  270. -- means "toggles_any_tag"?
  271. local tp: POINTER
  272. do
  273. if a_tag/=Void then tp:=a_tag.handle end
  274. Result:=(gtk_text_iter_toggles_tag(handle, a_tag.handle).to_boolean)
  275. end
  276. has_tag (a_tag: GTK_TEXT_TAG): BOOLEAN is
  277. -- Is Current iterator within a range tagged with `a_tag'?
  278. require tag_not_void: a_tag /= Void
  279. do
  280. Result := gtk_text_iter_has_tag(handle,a_tag.handle).to_boolean
  281. end
  282. tags: G_SLIST [GTK_TEXT_TAG] is
  283. -- a list of tags that apply to iter, in ascending order of
  284. -- priority (highest-priority tags are last).
  285. -- TODO: Gtk docs says" The GtkTextTag in the list don't have
  286. -- a reference added, but you have to free the list
  287. -- itself". Check if this should be translated into a
  288. -- particular Eiffel implementation
  289. do
  290. create {G_OBJECT_SLIST [GTK_TEXT_TAG]} Result.from_external_pointer (gtk_text_iter_get_tags (handle))
  291. end
  292. is_editable (a_default_setting: BOOLEAN): BOOLEAN is
  293. -- Is the character at iter within an editable region of
  294. -- text? Non-editable text is "locked" and can't be changed
  295. -- by the user via GtkTextView. This feature is simply a
  296. -- convenience wrapper around `attributes'
  297. -- gtk_text_iter_get_attributes(). If no tags applied to this
  298. -- text affect editability, default_setting will be returned.
  299. -- You don't want to use this function to decide whether text
  300. -- can be inserted at iter, because for insertion you don't
  301. -- want to know whether the char at iter is inside an
  302. -- editable range, you want to know whether a new character
  303. -- inserted at iter would be inside an editable range. Use
  304. -- `can_insert'to handle this case.
  305. -- Set `a_default_setting' to True if text is editable by
  306. -- default.
  307. -- TODO: original C documentation pretty unclear.
  308. do
  309. Result:= gtk_text_iter_editable (handle, a_default_setting.to_integer).to_boolean
  310. end
  311. can_insert (a_default_editability: BOOLEAN): BOOLEAN is
  312. -- Would the text inserted at Current iter be editable?
  313. -- Considering the default editability of the buffer, and
  314. -- tags that affect editability, determines whether text
  315. -- inserted at iter would be editable. If text inserted at
  316. -- iter would be editable then the user should be allowed to
  317. -- insert text at iter. GTK_TEXT_BUFFER's
  318. -- `insert_interactive' uses this function to decide whether
  319. -- insertions are allowed at a given position.
  320. -- Set `a_default_editability' to True if text is editable by
  321. -- default.
  322. do
  323. Result:=gtk_text_iter_can_insert(handle, a_default_editability.to_integer).to_boolean
  324. end
  325. starts_word: BOOLEAN is
  326. -- Is Current iter at the start of a (natural-language) word?
  327. -- Word breaks are determined by Pango and should be correct
  328. -- for nearly any language (if not, the correct fix would be
  329. -- to the Pango word break algorithms).
  330. do
  331. Result:=gtk_text_iter_starts_word(handle).to_boolean
  332. end
  333. ends_word: BOOLEAN is
  334. -- Is Current iter is at the end of a (natural-language)
  335. -- word? Word breaks are determined by Pango and should be
  336. -- correct for nearly any language (if not, the correct fix
  337. -- would be to the Pango word break algorithms).
  338. do
  339. Result:=gtk_text_iter_ends_word(handle).to_boolean
  340. end
  341. inside_word: BOOLEAN is
  342. -- Is Current iter inside a (natural-language) word? This is
  343. -- the opposite of "inside some whitespace". Word breaks are
  344. -- determined by Pango and should be correct for nearly any
  345. -- language (if not, the correct fix would be to the Pango
  346. -- word break algorithms).
  347. do
  348. Result:=gtk_text_iter_inside_word(handle).to_boolean
  349. end
  350. starts_line: BOOLEAN is
  351. -- Does Current iter begin a paragraph? If True `line_offset'
  352. -- would be 0. However this function is potentially more
  353. -- efficient than `line_offset' because it doesn't have to
  354. -- compute the offset, it just has to see whether it's 0.
  355. do
  356. Result:=gtk_text_iter_starts_line(handle).to_boolean
  357. end
  358. ends_line: BOOLEAN is
  359. -- Does iter point to the start of the paragraph delimiter
  360. -- characters for a line? Delimiters will be either a
  361. -- newline, a carriage return, a carriage return followed by
  362. -- a newline, or a Unicode paragraph separator
  363. -- character. Note that an iterator pointing to the \n ("%N")
  364. -- of a \r\n ("%R%N") pair will not be counted as the end of
  365. -- a line, the line ends before the \r ("%N"). The end
  366. -- iterator is considered to be at the end of a line, even
  367. -- though there are no paragraph delimiter chars there.
  368. do
  369. Result:=gtk_text_iter_ends_line(handle).to_boolean
  370. end
  371. starts_sentence: BOOLEAN is
  372. -- Does Current iter begin a sentence? Sentence boundaries
  373. -- are determined by Pango and should be correct for nearly
  374. -- any language (if not, the correct fix would be to the
  375. -- Pango text boundary algorithms).
  376. do
  377. Result:= gtk_text_iter_starts_sentence (handle).to_boolean
  378. end
  379. ends_sentence: BOOLEAN is
  380. -- Does Curret iter end a sentence? Sentence boundaries are
  381. -- determined by Pango and should be correct for nearly any
  382. -- language (if not, the correct fix would be to the Pango
  383. -- text boundary algorithms).
  384. do
  385. Result:=gtk_text_iter_ends_sentence (handle).to_boolean
  386. end
  387. is_inside_sentence: BOOLEAN is
  388. -- Is Current iter inside a sentence? This is the opposite of
  389. -- in between two sentences, e.g. after a period and before
  390. -- the first letter of the next sentence. Sentence boundaries
  391. -- are determined by Pango and should be correct for nearly
  392. -- any language (if not, the correct fix would be to the
  393. -- Pango text boundary algorithms).
  394. do
  395. Result := gtk_text_iter_inside_sentence (handle).to_boolean
  396. end
  397. is_cursor_position: BOOLEAN is
  398. -- Can the cursor be placed at Current iter? See
  399. -- `forward_cursor_position' or PangoLogAttr or pango_break()
  400. -- for details on what a cursor position is.
  401. do
  402. Result:=gtk_text_iter_is_cursor_position(handle).to_boolean
  403. end
  404. chars_in_line: INTEGER is
  405. -- the number of characters in the line containing iter,
  406. -- including the paragraph delimiters.
  407. do
  408. Result:=gtk_text_iter_get_chars_in_line (handle)
  409. end
  410. bytes_inline: INTEGER is
  411. -- the number of bytes in the line containing iter, including
  412. -- the paragraph delimiters.
  413. do
  414. Result:=gtk_text_iter_get_bytes_in_line (handle)
  415. end
  416. attributes: GTK_TEXT_ATTRIBUTES is
  417. -- the effect of any tags applied to this spot in the
  418. -- text. This is computed modifying a copy of `default_attributes'.
  419. -- Void if no changes occours.
  420. -- Note: the behaviour of this feature is quite different
  421. -- from the C function that it wraps
  422. -- (gtk_text_iter_get_attributes). If you need to apply the
  423. -- effets of tags from a different starting point please
  424. -- notify Paolo. 2006-12-31.
  425. local values_modified: BOOLEAN
  426. do
  427. -- Result := default_attributes
  428. -- values_modified := gtk_text_iter_get_attributes (handle,
  429. -- Result.handle).to_boolean
  430. -- gtk_text_iter_get_attributes() will modify values,
  431. -- applying the effects of any tags present at iter. If any
  432. -- tags affected values, the function returns TRUE.
  433. -- if not values_modified then Result := Void end
  434. ensure implemented: False
  435. end
  436. language: PANGO_LANGUAGE is
  437. -- The language in effect at iter.
  438. do
  439. -- Note: This is convenience wrapper around
  440. -- `gtk_text_iter_get_attributes', which returns - if no
  441. -- tags affecting language apply to iter - the return value
  442. -- is identical to that of gtk_get_default_language()
  443. -- (TODO).
  444. create Result.from_external_pointer(gtk_text_iter_get_language(handle))
  445. end
  446. feature -- Iterator-like
  447. is_off: BOOLEAN is
  448. -- Is iter the end iterator? End iterator is one past the
  449. -- last dereferenceable iterator in the buffer. This feature
  450. -- is the most efficient way to check whether an iterator is
  451. -- the end iterator.
  452. -- Note: this features wraps gtk_text_iter_is_end. I have
  453. -- changed name to conform to the iterator pattern. Paolo
  454. -- 2006-12-31
  455. do
  456. Result:= gtk_text_iter_is_end(handle).to_boolean
  457. end
  458. is_valid: BOOLEAN
  459. -- Have the iter being moved and dereferenceable?
  460. is_start: BOOLEAN is
  461. -- Is Current iter the first iterator in the buffer, that is
  462. -- if iter has a character offset of 0?.
  463. do
  464. Result := gtk_text_iter_is_start(handle).to_boolean
  465. end
  466. next, forward_char is
  467. -- Moves iter forward by one character offset. Note that
  468. -- images embedded in the buffer occupy 1 character slot, so
  469. -- `forward_char' may actually move onto an image instead of
  470. -- a character, if you have images in your buffer. If iter is
  471. -- the end iterator or one character before it, iter will now
  472. -- point at the end iterator, and
  473. -- gtk_text_iter_forward_char() returns FALSE for convenience
  474. -- when writing loops.
  475. do
  476. is_valid:=gtk_text_iter_forward_char(handle).to_boolean
  477. end
  478. backward_char is
  479. -- Moves backward by one character offset. `is_valid' will be
  480. -- True if movement was possible; if iter was the first in
  481. -- the buffer (character offset 0), `is_valid' will be False
  482. -- for convenience when writing loops.
  483. do
  484. is_valid:=gtk_text_iter_backward_char(handle).to_boolean
  485. end
  486. forward_chars (a_count: INTEGER) is
  487. -- Moves `a_count' characters if possible (if `a_count' would
  488. -- move past the start or end of the buffer, moves to the
  489. -- start or end of the buffer). `is_valid' indicates whether
  490. -- the new position of iter is different from its original
  491. -- position, and dereferenceable (the last iterator in the
  492. -- buffer is not dereferenceable). If `a_count' is 0, the
  493. -- function does nothing and `is_valid' is False. `a_count'
  494. -- is number of characters to move, may be negative.
  495. do
  496. is_valid:=gtk_text_iter_forward_chars(handle, a_count).to_boolean
  497. ensure a_count = 0 implies is_valid = False
  498. end
  499. backward_chars (a_count: INTEGER) is
  500. -- Moves `a_count' characters backward, if possible (if
  501. -- `a_count' would move past the start or end of the buffer,
  502. -- moves to the start or end of the buffer). `is_valid'
  503. -- indicates whether the iterator moved onto a
  504. -- dereferenceable position; if the iterator didn't move, or
  505. -- moved onto the end iterator, then False is returned. If
  506. -- `a_count' is 0, nothing is done and `is_valid' is False.
  507. do
  508. is_valid:=gtk_text_iter_backward_chars(handle,a_count).to_boolean
  509. end
  510. forward_line is
  511. -- Moves iter to the start of the next line. `is_valid' is
  512. -- True if there was a next line to move to, and False if
  513. -- iter was simply moved to the end of the buffer and is now
  514. -- not dereferenceable, or if iter was already at the end of
  515. -- the buffer.
  516. do
  517. is_valid:=gtk_text_iter_forward_line(handle).to_boolean
  518. end
  519. backward_line is
  520. -- Moves iter to the start of the previous line. `is_valid'
  521. -- is True if iter could be moved; i.e. if iter was at
  522. -- character offset 0, `is_valid' is False. Therefore if iter
  523. -- was already on line 0, but not at the start of the line,
  524. -- iter is snapped to the start of the line and `is_valid' is
  525. -- True. (Note that this implies that in a loop calling this
  526. -- function, the line number may not change on every
  527. -- iteration, if your first iteration is on line 0.)
  528. do
  529. is_valid:=gtk_text_iter_backward_line(handle).to_boolean
  530. end
  531. forward_lines (a_count: INTEGER) is
  532. -- Moves `a_count' lines forward, if possible (if `a_count'
  533. -- would move past the start or end of the buffer, moves to
  534. -- the start or end of the buffer). `is_valid' indicates
  535. -- whether the iterator moved onto a dereferenceable
  536. -- position; if the iterator didn't move, or moved onto the
  537. -- end iterator, then `is_valid' will be False. If `a_count'
  538. -- is 0, the function does nothing and `is_valid' is
  539. -- False. If `a_count' is negative, moves backward by
  540. -- `0-a_count' lines.
  541. do
  542. is_valid:=gtk_text_iter_forward_lines(handle, a_count).to_boolean
  543. end
  544. backward_lines (a_count: INTEGER) is
  545. -- Moves `a_count' lines backward, if possible (if `a_count'
  546. -- would move past the start or end of the buffer, moves to
  547. -- the start or end of the buffer). `is_valid' indicates
  548. -- whether the iterator moved onto a dereferenceable
  549. -- position; if the iterator didn't move, or moved onto the
  550. -- end iterator, then `is_valid' is False. If `a_count' is 0,
  551. -- the function does nothing and `is_valid' is False. If
  552. -- `a_count' is negative, moves forward by 0 - count lines.
  553. do
  554. is_valid:=gtk_text_iter_backward_lines(handle, a_count).to_boolean
  555. end
  556. forward_word_ends (a_count: INTEGER) is
  557. -- Calls `forward_word_end' up to `a_count' times. Then
  558. -- `is_valid' is True if iter moved and is not the end
  559. -- iterator.
  560. do
  561. is_valid:=gtk_text_iter_forward_word_ends(handle, a_count).to_boolean
  562. end
  563. backward_word_starts (a_count: INTEGER) is
  564. -- Calls `backward_word_start' up to `a_count'
  565. -- times. `is_valid' will be True if iter moved and is not
  566. -- the end iterator.
  567. do
  568. is_valid:=gtk_text_iter_backward_word_starts(handle,a_count).to_boolean
  569. end
  570. forward_word_end is
  571. -- Moves forward to the next word end. (If iter is currently
  572. -- on a word end, moves forward to the next one after that.)
  573. -- Word breaks are determined by Pango and should be correct
  574. -- for nearly any language (if not, the correct fix would be
  575. -- to the Pango word break algorithms).
  576. -- `is_valid' will be True if iter moved and is not the end
  577. -- iterator.
  578. do
  579. is_valid:=gtk_text_iter_forward_word_end(handle).to_boolean
  580. end
  581. backward_word_start is
  582. -- Moves backward to the previous word start. (If iter is
  583. -- currently on a word start, moves backward to the next one
  584. -- after that). Word breaks are determined by Pango and
  585. -- should be correct for nearly any language (if not, the
  586. -- correct fix would be to the Pango word break algorithms).
  587. -- `is_valid' will be True if iter moved and is not the end
  588. -- iterator.
  589. do
  590. is_valid:=gtk_text_iter_backward_word_start(handle).to_boolean
  591. end
  592. forward_cursor_position is
  593. -- Moves iter forward by a single cursor position. Cursor
  594. -- positions are (unsurprisingly) positions where the cursor
  595. -- can appear. Perhaps surprisingly, there may not be a
  596. -- cursor position between all characters. The most common
  597. -- example for European languages would be a carriage
  598. -- return/newline sequence. For some Unicode characters, the
  599. -- equivalent of say the letter "a" with an accent mark will
  600. -- be represented as two characters, first the letter then a
  601. -- "combining mark" that causes the accent to be rendered; so
  602. -- the cursor can't go between those two characters. See also
  603. -- the PangoLogAttr structure and pango_break() function.
  604. -- `is_valid' will be True if we moved and the new position
  605. -- is dereferenceable
  606. do
  607. is_valid:=gtk_text_iter_forward_cursor_position(handle).to_boolean
  608. end
  609. backward_cursor_position is
  610. -- Like `forward_cursor_position', but moves backward.
  611. -- `is_valid' will be True if we moved
  612. do
  613. is_valid:=gtk_text_iter_backward_cursor_position(handle).to_boolean
  614. end
  615. forward_cursor_positions (a_count: INTEGER) is
  616. -- Moves up to `a_count' cursor positions. See
  617. -- `forward_cursor_position' for details.
  618. -- `is_valid' will be True if we moved and the new position
  619. -- is dereferenceable.
  620. do
  621. is_valid:=gtk_text_iter_forward_cursor_positions(handle, a_count).to_boolean
  622. end
  623. backward_cursor_positions (a_count: INTEGER) is
  624. -- Moves up to `a_count' cursor positions. See
  625. -- `forward_cursor_position' for details.
  626. -- `is_valid' will be True if we moved and the new position
  627. -- is dereferenceable.
  628. do
  629. is_valid:=gtk_text_iter_backward_cursor_positions(handle, a_count).to_boolean
  630. end
  631. backward_sentence_start is
  632. -- Moves backward to the previous sentence start; if iter is
  633. -- already at the start of a sentence, moves backward to the
  634. -- next one. Sentence boundaries are determined by Pango and
  635. -- should be correct for nearly any language (if not, the
  636. -- correct fix would be to the Pango text boundary
  637. -- algorithms).
  638. -- `is_valid' will be True if iter moved and is not the end
  639. -- iterator.
  640. do
  641. is_valid:=gtk_text_iter_backward_sentence_start(handle).to_boolean
  642. end
  643. backward_sentence_starts (a_count: INTEGER) is
  644. -- Calls `backward_sentence_start' up to count times, or
  645. -- until `is_valid' will be False. If `a_count' is negative,
  646. -- moves forward instead of backward.
  647. -- `is_valid' will be True if iter moved and is not the end
  648. -- iterator.
  649. do
  650. is_valid:=gtk_text_iter_backward_sentence_starts(handle,a_count).to_boolean
  651. end
  652. forward_sentence_end is
  653. -- Moves forward to the next sentence end. (If iter is at the
  654. -- end of a sentence, moves to the next end of sentence.)
  655. -- Sentence boundaries are determined by Pango and should be
  656. -- correct for nearly any language (if not, the correct fix
  657. -- would be to the Pango text boundary algorithms).
  658. -- `is_valid' will be True if iter moved and is not the end
  659. -- iterator.
  660. do
  661. is_valid:=gtk_text_iter_forward_sentence_end(handle).to_boolean
  662. end
  663. forward_sentence_ends (a_count: INTEGER) is
  664. -- Calls `forward_sentence_end' `a_count' times (or until
  665. -- `forward_sentence_end' sets `is_valid' to False). If
  666. -- `a_count' is negative, moves backward instead of forward.
  667. -- `is_valid' will be set to True if iter moved and is not
  668. -- the end iterator.
  669. do
  670. is_valid:=gtk_text_iter_forward_sentence_ends(handle,a_count).to_boolean
  671. end
  672. forward_visible_word_ends (a_count: INTEGER) is
  673. -- Calls `forward_visible_word_end' up to `a_count' times.
  674. -- `is_valid' will be set to True if iter moved and is not
  675. -- the end iterator.
  676. do
  677. is_valid:=gtk_text_iter_forward_visible_word_ends(handle, a_count).to_boolean
  678. end
  679. backward_visible_word_starts (a_count: INTEGER) is
  680. -- Calls `backward_visible_word_start' up to `a_count' times.
  681. -- `is_valid' will be True if iter moved and is not the end
  682. -- iterator.
  683. do
  684. is_valid:=gtk_text_iter_backward_visible_word_starts(handle, a_count).to_boolean
  685. end
  686. forward_visible_word_end is
  687. -- Moves forward to the next visible word end. (If iter is
  688. -- currently on a word end, moves forward to the next one
  689. -- after that.) Word breaks are determined by Pango and
  690. -- should be correct for nearly any language (if not, the
  691. -- correct fix would be to the Pango word break algorithms).
  692. -- `is_valid' will be set to True if iter moved and is not
  693. -- the end iterator.
  694. do
  695. is_valid:=gtk_text_iter_forward_visible_word_end(handle).to_boolean
  696. end
  697. backward_visible_word_start is
  698. -- Moves backward to the previous visible word start. (If
  699. -- iter is currently on a word start, moves backward to the
  700. -- next one after that.) Word breaks are determined by Pango
  701. -- and should be correct for nearly any language (if not, the
  702. -- correct fix would be to the Pango word break algorithms).
  703. -- `is_valid' will be set to True if iter moved and is not
  704. -- the end iterator.
  705. do
  706. is_valid:=gtk_text_iter_backward_visible_word_start(handle).to_boolean
  707. end
  708. forward_visible_cursor_position is
  709. -- Moves iter forward to the next visible cursor
  710. -- position. See `forward_cursor_position' for details.
  711. -- `is_valid' will be set to True if we moved and the new
  712. -- position is dereferenceable.
  713. do
  714. is_valid:=gtk_text_iter_forward_visible_cursor_position(handle).to_boolean
  715. end
  716. backward_visible_cursor_position is
  717. -- Moves iter forward to the previous visible cursor
  718. -- position. See `backward_cursor_position' for details.
  719. -- `is_valid' will be set to True if we moved and the new
  720. -- position is dereferenceable
  721. do
  722. is_valid:=gtk_text_iter_backward_visible_cursor_position(handle).to_boolean
  723. end
  724. forward_visible_cursor_positions (a_count: INTEGER) is
  725. -- Moves up to `a_count' visible cursor positions. See
  726. -- `forward_cursor_position' for details.
  727. -- `is_valid' will be set to True if we moved and the new
  728. -- position is dereferenceable.
  729. do
  730. is_valid:=gtk_text_iter_forward_visible_cursor_positions(handle, a_count).to_boolean
  731. end
  732. backward_visible_cursor_positions (a_count: INTEGER) is
  733. -- Moves up to `a_count' visible cursor positions. See
  734. -- `forward_cursor_position' for details.
  735. -- `is_valid' will be set to True if we moved and the new
  736. -- position is dereferenceable.
  737. do
  738. is_valid:=gtk_text_iter_backward_visible_cursor_positions(handle,a_count).to_boolean
  739. end
  740. forward_visible_line is
  741. -- Moves iter to the start of the next visible line.
  742. -- `is_valid' is set to True if there was a next line to move
  743. -- to, and False if iter was simply moved to the end of the
  744. -- buffer and is now not dereferenceable, or if iter was
  745. -- already at the end of the buffer.
  746. do
  747. is_valid:=gtk_text_iter_forward_visible_line(handle).to_boolean
  748. end
  749. iter_backward_visible_line is
  750. -- Moves iter to the start of the previous visible line.
  751. -- `is_valid' is seto to True if iter could be moved; i.e. if
  752. -- iter was at character offset 0, this function returns
  753. -- FALSE. Therefore if iter was already on line 0, but not at
  754. -- the start of the line, iter is snapped to the start of the
  755. -- line and the function returns TRUE. (Note that this
  756. -- implies that in a loop calling this function, the line
  757. -- number may not change on every iteration, if your first
  758. -- iteration is on line 0.)
  759. do
  760. is_valid:=gtk_text_iter_backward_visible_line(handle).to_boolean
  761. end
  762. forward_visible_lines (a_count: INTEGER) is
  763. -- Moves `a_count' visible lines forward, if possible (if
  764. -- count would move past the start or end of the buffer,
  765. -- moves to the start or end of the buffer). `is_valid'
  766. -- indicates whether the iterator moved onto a
  767. -- dereferenceable position; if the iterator didn't move, or
  768. -- moved onto the end iterator, then `is_valid' is False. If
  769. -- `a_count' is 0, the function does nothing and `is_valid'
  770. -- is set to False. If `a_count' is negative, moves backward
  771. -- by 0 - count lines.
  772. do
  773. is_valid:=gtk_text_iter_forward_visible_lines(handle, a_count).to_boolean
  774. end
  775. backward_visible_lines (a_count: INTEGER) is
  776. -- Moves `a_count' visible lines backward, if possible (if
  777. -- `a_count' would move past the start or end of the buffer,
  778. -- moves to the start or end of the buffer). `is_valid'
  779. -- indicates whether the iterator moved onto a
  780. -- dereferenceable position; if the iterator didn't move, or
  781. -- moved onto the end iterator, then `is_valid' is False. If
  782. -- `a_count' is 0, nothing is done and `is_valid' is
  783. -- False. If `a_count' is negative, moves forward by 0 -
  784. -- count lines.
  785. do
  786. is_valid:=gtk_text_iter_backward_visible_lines(handle,a_count).to_boolean
  787. end
  788. set_offset (a_char_offset: INTEGER) is
  789. -- Sets iter to point to `a_char_offset'. `a_char_offset'
  790. -- counts from the start of the entire text buffer, starting
  791. -- with 0.
  792. do
  793. gtk_text_iter_set_offset(handle,a_char_offset)
  794. end
  795. set_line (a_line_number: INTEGER) is
  796. -- Moves iterator iter to the start of the line
  797. -- `a_line_number' (counted from 0). If `a_line_number' is
  798. -- negative or larger than the number of lines in the buffer,
  799. -- moves iter to the start of the last line in the buffer.
  800. do
  801. gtk_text_iter_set_line(handle, a_line_number)
  802. end
  803. set_line_offset (a_char_on_line: INTEGER) is
  804. -- Moves iter within a line, to a new character (not byte)
  805. -- offset. The given character offset must be less than or
  806. -- equal to the number of characters in the line; if equal,
  807. -- iter moves to the start of the next line. See
  808. -- `set_line_index' if you have a byte index rather than a
  809. -- character offset.
  810. do
  811. gtk_text_iter_set_line_offset (handle,a_char_on_line)
  812. end
  813. set_line_index (a_byte_on_line: INTEGER) is
  814. -- Same as `set_line_offset', but works with a byte
  815. -- index. The given byte index must be at the start of a
  816. -- character, it can't be in the middle of a UTF-8 encoded
  817. -- character (TODO: turn it into a precondition).
  818. -- `a_byte_on_line' is the byte index relative to the start
  819. -- of iter's current line.
  820. do
  821. gtk_text_iter_set_line_index (handle, a_byte_on_line)
  822. end
  823. set_visible_line_index (a_byte_on_line: INTEGER) is
  824. -- Like `set_line_index', but the index is in visible bytes,
  825. -- i.e. text with a tag making it invisible is not counted in
  826. -- the index.
  827. do
  828. gtk_text_iter_set_visible_line_index(handle, a_byte_on_line)
  829. end
  830. set_visible_line_offset (a_char_on_line: INTEGER) is
  831. -- Like `set_line_offset', but the offset is in visible
  832. -- characters, i.e. text with a tag making it invisible is
  833. -- not counted in the offset.
  834. do
  835. gtk_text_iter_set_visible_line_offset(handle,a_char_on_line)
  836. end
  837. forward_to_end is
  838. -- Moves iter forward to the "end iterator," which points one
  839. -- past the last valid character in the
  840. -- buffer.
  841. do
  842. gtk_text_iter_forward_to_end(handle)
  843. is_valid:=False
  844. ensure
  845. not_valid: not is_valid
  846. -- TODO: `char' called on the end iterator is 0, which is
  847. -- convenient for writing loops (when writing C code).
  848. end
  849. forward_to_line_end is
  850. -- Moves the iterator to point to the paragraph delimiter
  851. -- characters, which will be either a newline, a carriage
  852. -- return, a carriage return/newline in sequence, or the
  853. -- Unicode paragraph separator character. If the iterator is
  854. -- already at the paragraph delimiter characters, moves to
  855. -- the paragraph delimiter characters for the next line. If
  856. -- iter is on the last line in the buffer, which does not end
  857. -- in paragraph delimiters, moves to the end iterator (end of
  858. -- the last line), and `is_valid' is set to False.
  859. -- `is_valid' is set to True if we moved and the new location
  860. -- is not the end iterator.
  861. do
  862. is_valid:=gtk_text_iter_forward_to_line_end(handle).to_boolean
  863. end
  864. forward_to_tag_toggle (a_tag: GTK_TEXT_TAG) is
  865. -- Moves forward to the next toggle (on or off) of `a_tag,'
  866. -- or to the next toggle of any tag if `a_tag' is Void. If no
  867. -- matching tag toggles are found `is_valid' is set to False,
  868. -- otherwise to True. Does not return toggles located at
  869. -- iter, only toggles after iter. Sets iter to the location
  870. -- of the toggle, or to the end of the buffer if no toggle is
  871. -- found.
  872. do
  873. if a_tag=Void then
  874. is_valid:=gtk_text_iter_forward_to_tag_toggle(handle,default_pointer).to_boolean
  875. else
  876. is_valid:=gtk_text_iter_forward_to_tag_toggle(handle,a_tag.handle).to_boolean
  877. end
  878. end
  879. backward_to_tag_toggle (a_tag: GTK_TEXT_TAG) is
  880. -- Moves backward to the next toggle (on or off) of `a_tag,'
  881. -- or to the next toggle of any tag if `a_tag' is Void. If no
  882. -- matching tag toggles are found, `is_valid' is set to
  883. -- False, otherwise to True. Toggles located at iter are not
  884. -- counted, only toggles before iter. Sets iter to the
  885. -- location of the toggle, or the start of the buffer if no
  886. -- toggle is found.
  887. do
  888. if a_tag = Void then
  889. is_valid := gtk_text_iter_backward_to_tag_toggle(handle,default_pointer).to_boolean
  890. else
  891. is_valid := gtk_text_iter_backward_to_tag_toggle(handle,a_tag.handle).to_boolean
  892. end
  893. end
  894. is_found: BOOLEAN
  895. -- Have the last search/scan been successful?
  896. forward_find_char (a_predicate: PREDICATE[TUPLE[INTEGER_32]]; a_limit: GTK_TEXT_ITER) is
  897. -- Advances iter, calling `a_predicate' on each character. If
  898. -- `a_predicate' is True, scanning is stopped and `is_found'
  899. -- TRUE and stops scanning. If `a_predicate' is never True,
  900. -- iter is set to `a_limit' if limit is non-Void, otherwise
  901. -- to the end iterator.
  902. local ca: POINTER
  903. do
  904. ca := callback_array($callback)
  905. if a_limit = Void then
  906. is_found := gtk_text_iter_forward_find_char (handle, $hidden_callback,
  907. ca, -- i.e.: user_data,
  908. default_pointer -- i.e. no limit
  909. ).to_boolean
  910. else
  911. is_found := gtk_text_iter_forward_find_char (handle, $hidden_callback,
  912. ca, -- i.e.: user_data,
  913. a_limit.handle -- i.e. no limit
  914. ).to_boolean
  915. end
  916. end
  917. backward_find_char (a_predicate: PREDICATE[TUPLE[INTEGER_32]]; a_limit: GTK_TEXT_ITER) is
  918. -- Same as `forward_find_char', but goes backward from iter.
  919. local ca: POINTER
  920. do
  921. ca:=callback_array($callback)
  922. if a_limit=Void
  923. then is_found:=gtk_text_iter_backward_find_char
  924. (handle, $hidden_callback,
  925. ca, -- i.e.: user_data,
  926. default_pointer -- i.e. no limit
  927. ).to_boolean
  928. else is_found:=gtk_text_iter_backward_find_char
  929. (handle, $hidden_callback,
  930. ca, -- i.e.: user_data,
  931. a_limit.handle -- i.e. no limit
  932. ).to_boolean
  933. end
  934. end
  935. forward_search (a_string: STRING; some_flags: INTEGER;
  936. a_start_match, an_end_match, a_limit: GTK_TEXT_ITER) is
  937. -- Searches forward for `a_string'. Any match is returned by
  938. -- setting `a_match_start' to the first character of the
  939. -- match and `a_match_end' to the first character after the
  940. -- match. The search will not continue past `a_limit'. Note
  941. -- that a search is a linear or O(n) operation, so you may
  942. -- wish to use limit to avoid locking up your UI on large
  943. -- buffers.
  944. -- If the `gtk_text_search_visible_only' flag is present, the
  945. -- match may have invisible text interspersed in
  946. -- `a_string'. i.e. it will be a possibly-noncontiguous
  947. -- subsequence of the matched range. similarly, if you
  948. -- specify `gtk_text_search_text_only,' the match may have
  949. -- pixbufs or child widgets mixed inside the matched
  950. -- range. If these flags are not given, the match must be
  951. -- exact; the special 0xFFFC character in `a_string' will match
  952. -- embedded pixbufs or child widgets.
  953. -- `a_string': a search string
  954. -- `some_flags': flags affecting how the search is done
  955. -- `a_match_start' is set to the location for start of match,
  956. -- if not Void NULL
  957. -- `a_match_end' is set to the location for end of match, if
  958. -- it is not Void.
  959. -- `a_limit' is the bound for the search; Void to indicate
  960. -- the end of the buffer.
  961. -- `is_found' is set whether a match was found.
  962. -- TODO: match start and end iterators passed as arguments
  963. -- does not strictly follow the no-side-effects requirement
  964. -- usually expected in Eiffel design. Check for a best way to
  965. -- wrap this feature.
  966. require
  967. string_not_void: a_string /= Void
  968. valid_flags: are_valid_search_flags(some_flags)
  969. local smp, emp, lp: POINTER
  970. do
  971. if a_start_match/=Void then smp:=a_start_match.handle end
  972. if an_end_match/=Void then emp:=an_end_match.handle end
  973. if a_limit/=Void then lp:=a_limit.handle end
  974. is_found:=gtk_text_iter_forward_search(handle,a_string.to_external,
  975. some_flags,
  976. smp, emp, lp).to_boolean
  977. end
  978. backward_search (a_string: STRING; some_flags: INTEGER;
  979. a_start_match, an_end_match, a_limit: GTK_TEXT_ITER) is
  980. -- Same as `forward_search', but moves backward.
  981. require
  982. string_not_void: a_string /= Void
  983. valid_flags: are_valid_search_flags(some_flags)
  984. local smp, emp, lp: POINTER
  985. do
  986. if a_start_match/=Void then smp:=a_start_match.handle end
  987. if an_end_match/=Void then emp:=an_end_match.handle end
  988. if a_limit/=Void then lp:=a_limit.handle end
  989. is_found:=gtk_text_iter_backward_search(handle,a_string.to_external,
  990. some_flags,
  991. smp, emp, lp).to_boolean
  992. end
  993. order (another: GTK_TEXT_ITER) is
  994. -- Swaps the value of Current and `another' if `another'
  995. -- comes before Current in the buffer. That is, ensures that
  996. -- Current and `another' are in sequence. Most text buffer
  997. -- functions that take a range call this automatically on
  998. -- your behalf, so there's no real reason to call it yourself
  999. -- in those cases. There are some exceptions, such as
  1000. -- `in_range', that expect a pre-sorted range.
  1001. require another_not_void: another /= Void
  1002. do
  1003. gtk_text_iter_order (handle, another.handle)
  1004. ensure ordered: Current <= another
  1005. end
  1006. feature -- Comparability
  1007. is_equal (another: like Current): BOOLEAN is
  1008. -- Tests whether two iterators (Current and `another') are
  1009. -- equal, using the fastest possible mechanism. This function
  1010. -- is very fast; you can expect it to perform better than
  1011. -- e.g. getting the character offset for each iterator and
  1012. -- comparing the offsets yourself. Also, it's a bit faster
  1013. -- than `compare'.
  1014. do
  1015. Result := (gtk_text_iter_equal (handle, another.handle)).to_boolean
  1016. end
  1017. infix "<" (other: like Current): BOOLEAN is
  1018. do
  1019. Result:= compare(other)<0
  1020. end
  1021. infix "<=" (other: like Current): BOOLEAN is
  1022. do
  1023. Result:= compare(other)<=0
  1024. end
  1025. infix ">" (other: like Current): BOOLEAN is
  1026. do
  1027. Result:= compare(other)>0
  1028. end
  1029. infix ">=" (other: like Current): BOOLEAN is
  1030. do
  1031. Result:= compare(other)>=0
  1032. end
  1033. in_range (lower, upper: like Current): BOOLEAN is
  1034. -- Does Current fall in the range [lower, upper).
  1035. require
  1036. ascending_order: lower <= upper
  1037. do
  1038. Result:=gtk_text_iter_in_range(handle, lower.handle, upper.handle).to_boolean
  1039. end
  1040. three_way_comparison (other: like Current): INTEGER is
  1041. obsolete "Please use compare"
  1042. do
  1043. Result:=compare(other)
  1044. end
  1045. compare (another: like Current): INTEGER is
  1046. -- A qsort()-style function that returns negative if Current
  1047. -- is less than `another,' positive if Current is greater
  1048. -- than `another,' and 0 if they're equal. Ordering is in
  1049. -- character offset order, i.e. the first character in the
  1050. -- buffer is less than the second character in the buffer.
  1051. do
  1052. Result:=gtk_text_iter_compare(handle, another.handle)
  1053. end
  1054. feature -- size
  1055. struct_size: INTEGER is
  1056. external "C inline use <gtk/gtk.h>"
  1057. alias "sizeof(GtkTextIter)"
  1058. end
  1059. feature {} -- External call
  1060. gtk_text_iter_get_buffer (an_iter: POINTER): POINTER is -- GtkTextBuffer*
  1061. external "C use <gtk/gtk.h>"
  1062. end
  1063. gtk_text_iter_copy (an_iter: POINTER): POINTER is -- GtkTextIter*
  1064. external "C use <gtk/gtk.h>"
  1065. end
  1066. gtk_text_iter_free (an_iter: POINTER) is
  1067. external "C use <gtk/gtk.h>"
  1068. end
  1069. gtk_text_iter_get_offset (an_iter: POINTER): INTEGER is -- gint
  1070. external "C use <gtk/gtk.h>"
  1071. end
  1072. gtk_text_iter_get_line (an_iter: POINTER): INTEGER is -- gint
  1073. external "C use <gtk/gtk.h>"
  1074. end
  1075. gtk_text_iter_get_line_offset (an_iter: POINTER): INTEGER is -- gint
  1076. external "C use <gtk/gtk.h>"
  1077. end
  1078. gtk_text_iter_get_line_index (an_iter: POINTER): INTEGER is -- gint
  1079. external "C use <gtk/gtk.h>"
  1080. end
  1081. gtk_text_iter_get_visible_line_index (an_iter: POINTER): INTEGER is -- gint
  1082. external "C use <gtk/gtk.h>"
  1083. end
  1084. gtk_text_iter_get_visible_line_offset (an_iter: POINTER): INTEGER is -- gint
  1085. external "C use <gtk/gtk.h>"
  1086. end
  1087. gtk_text_iter_get_char (an_iter: POINTER): INTEGER is -- gunichar
  1088. external "C use <gtk/gtk.h>"
  1089. end
  1090. gtk_text_iter_get_slice (an_start: POINTER; an_end: POINTER): POINTER is -- gchar*
  1091. external "C use <gtk/gtk.h>"
  1092. end
  1093. gtk_text_iter_get_text (an_start: POINTER; an_end: POINTER): POINTER is -- gchar*
  1094. external "C use <gtk/gtk.h>"
  1095. end
  1096. gtk_text_iter_get_visible_slice (an_start: POINTER; an_end: POINTER): POINTER is -- gchar*
  1097. external "C use <gtk/gtk.h>"
  1098. end
  1099. gtk_text_iter_get_visible_text (an_start: POINTER; an_end: POINTER): POINTER is -- gchar*
  1100. external "C use <gtk/gtk.h>"
  1101. end
  1102. gtk_text_iter_get_pixbuf (an_iter: POINTER): POINTER is -- GdkPixbuf*
  1103. external "C use <gtk/gtk.h>"
  1104. end
  1105. gtk_text_iter_get_marks (an_iter: POINTER): POINTER is -- GSList*
  1106. external "C use <gtk/gtk.h>"
  1107. end
  1108. gtk_text_iter_get_toggled_tags (an_iter: POINTER; toggled_on: INTEGER): POINTER is -- GSList*
  1109. external "C use <gtk/gtk.h>"
  1110. end
  1111. gtk_text_iter_get_child_anchor (an_iter: POINTER): POINTER is -- GtkTextChildAnchor*
  1112. external "C use <gtk/gtk.h>"
  1113. end
  1114. gtk_text_iter_begins_tag (an_iter: POINTER; a_tag: POINTER): INTEGER is -- gboolean
  1115. external "C use <gtk/gtk.h>"
  1116. end
  1117. gtk_text_iter_ends_tag (an_iter: POINTER; a_tag: POINTER): INTEGER is -- gboolean
  1118. external "C use <gtk/gtk.h>"
  1119. end
  1120. gtk_text_iter_toggles_tag (an_iter: POINTER; a_tag: POINTER): INTEGER is -- gboolean
  1121. external "C use <gtk/gtk.h>"
  1122. end
  1123. gtk_text_iter_has_tag (an_iter: POINTER; a_tag: POINTER): INTEGER is -- gboolean
  1124. external "C use <gtk/gtk.h>"
  1125. end
  1126. gtk_text_iter_get_tags (an_iter: POINTER): POINTER is -- GSList*
  1127. external "C use <gtk/gtk.h>"
  1128. end
  1129. gtk_text_iter_editable (an_iter: POINTER; default_setting: INTEGER): INTEGER is -- gboolean
  1130. external "C use <gtk/gtk.h>"
  1131. end
  1132. gtk_text_iter_can_insert (an_iter: POINTER; default_editability: INTEGER): INTEGER is -- gboolean
  1133. external "C use <gtk/gtk.h>"
  1134. end
  1135. gtk_text_iter_starts_word (an_iter: POINTER): INTEGER is -- gboolean
  1136. external "C use <gtk/gtk.h>"
  1137. end
  1138. gtk_text_iter_ends_word (an_iter: POINTER): INTEGER is -- gboolean
  1139. external "C use <gtk/gtk.h>"
  1140. end
  1141. gtk_text_iter_inside_word (an_iter: POINTER): INTEGER is -- gboolean
  1142. external "C use <gtk/gtk.h>"
  1143. end
  1144. gtk_text_iter_starts_line (an_iter: POINTER): INTEGER is -- gboolean
  1145. external "C use <gtk/gtk.h>"
  1146. end
  1147. gtk_text_iter_ends_line (an_iter: POINTER): INTEGER is -- gboolean
  1148. external "C use <gtk/gtk.h>"
  1149. end
  1150. gtk_text_iter_starts_sentence (an_iter: POINTER): INTEGER is -- gboolean
  1151. external "C use <gtk/gtk.h>"
  1152. end
  1153. gtk_text_iter_ends_sentence (an_iter: POINTER): INTEGER is -- gboolean
  1154. external "C use <gtk/gtk.h>"
  1155. end
  1156. gtk_text_iter_inside_sentence (an_iter: POINTER): INTEGER is -- gboolean
  1157. external "C use <gtk/gtk.h>"
  1158. end
  1159. gtk_text_iter_is_cursor_position (an_iter: POINTER): INTEGER is -- gboolean
  1160. external "C use <gtk/gtk.h>"
  1161. end
  1162. gtk_text_iter_get_chars_in_line (an_iter: POINTER): INTEGER is -- gint
  1163. external "C use <gtk/gtk.h>"
  1164. end
  1165. gtk_text_iter_get_bytes_in_line (an_iter: POINTER): INTEGER is -- gint
  1166. external "C use <gtk/gtk.h>"
  1167. end
  1168. gtk_text_iter_get_attributes (an_iter: POINTER; gtktextattributes: POINTER): INTEGER is -- gboolean
  1169. external "C use <gtk/gtk.h>"
  1170. end
  1171. gtk_text_iter_get_language (an_iter: POINTER): POINTER is -- PangoLanguage*
  1172. external "C use <gtk/gtk.h>"
  1173. end
  1174. gtk_text_iter_is_end (an_iter: POINTER): INTEGER is -- gboolean
  1175. external "C use <gtk/gtk.h>"
  1176. end
  1177. gtk_text_iter_is_start (an_iter: POINTER): INTEGER is -- gboolean
  1178. external "C use <gtk/gtk.h>"
  1179. end
  1180. gtk_text_iter_forward_char (an_iter: POINTER): INTEGER is -- gboolean
  1181. external "C use <gtk/gtk.h>"
  1182. end
  1183. gtk_text_iter_backward_char (an_iter: POINTER): INTEGER is -- gboolean
  1184. external "C use <gtk/gtk.h>"
  1185. end
  1186. gtk_text_iter_forward_chars (an_iter: POINTER; a_count: INTEGER): INTEGER is -- gboolean
  1187. external "C use <gtk/gtk.h>"
  1188. end
  1189. gtk_text_iter_backward_chars (an_iter: POINTER; a_count: INTEGER): INTEGER is -- gboolean
  1190. external "C use <gtk/gtk.h>"
  1191. end
  1192. gtk_text_iter_forward_line (an_iter: POINTER): INTEGER is -- gboolean
  1193. external "C use <gtk/gtk.h>"
  1194. end
  1195. gtk_text_iter_backward_line (an_iter: POINTER): INTEGER is -- gboolean
  1196. external "C use <gtk/gtk.h>"
  1197. end
  1198. gtk_text_iter_forward_lines (an_iter: POINTER; a_count: INTEGER): INTEGER is -- gboolean
  1199. external "C use <gtk/gtk.h>"
  1200. end
  1201. gtk_text_iter_backward_lines (an_iter: POINTER; a_count: INTEGER): INTEGER is -- gboolean
  1202. external "C use <gtk/gtk.h>"
  1203. end
  1204. gtk_text_iter_forward_word_ends (an_iter: POINTER; a_count: INTEGER): INTEGER is -- gboolean
  1205. external "C use <gtk/gtk.h>"
  1206. end
  1207. gtk_text_iter_backward_word_starts (an_iter: POINTER; a_count: INTEGER): INTEGER is -- gboolean
  1208. external "C use <gtk/gtk.h>"
  1209. end
  1210. gtk_text_iter_forward_word_end (an_iter: POINTER): INTEGER is -- gboolean
  1211. external "C use <gtk/gtk.h>"
  1212. end
  1213. gtk_text_iter_backward_word_start (an_iter: POINTER): INTEGER is -- gboolean
  1214. external "C use <gtk/gtk.h>"
  1215. end
  1216. gtk_text_iter_forward_cursor_position (an_iter: POINTER): INTEGER is -- gboolean
  1217. external "C use <gtk/gtk.h>"
  1218. end
  1219. gtk_text_iter_backward_cursor_position (an_iter: POINTER): INTEGER is -- gboolean
  1220. external "C use <gtk/gtk.h>"
  1221. end
  1222. gtk_text_iter_forward_cursor_positions (an_iter: POINTER; a_count: INTEGER): INTEGER is -- gboolean
  1223. external "C use <gtk/gtk.h>"
  1224. end
  1225. gtk_text_iter_backward_cursor_positions (an_iter: POINTER; a_count: INTEGER): INTEGER is -- gboolean
  1226. external "C use <gtk/gtk.h>"
  1227. end
  1228. gtk_text_iter_backward_sentence_start (an_iter: POINTER): INTEGER is -- gboolean
  1229. external "C use <gtk/gtk.h>"
  1230. end
  1231. gtk_text_iter_backward_sentence_starts (an_iter: POINTER; a_count: INTEGER): INTEGER is -- gboolean
  1232. external "C use <gtk/gtk.h>"
  1233. end
  1234. gtk_text_iter_forward_sentence_end (an_iter: POINTER): INTEGER is -- gboolean
  1235. external "C use <gtk/gtk.h>"
  1236. end
  1237. gtk_text_iter_forward_sentence_ends (an_iter: POINTER; a_count: INTEGER): INTEGER is -- gboolean
  1238. external "C use <gtk/gtk.h>"
  1239. end
  1240. gtk_text_iter_forward_visible_word_ends (an_iter: POINTER; a_count: INTEGER): INTEGER is -- gboolean
  1241. external "C use <gtk/gtk.h>"
  1242. end
  1243. gtk_text_iter_backward_visible_word_starts (an_iter: POINTER; a_count: INTEGER): INTEGER is -- gboolean
  1244. external "C use <gtk/gtk.h>"
  1245. end
  1246. gtk_text_iter_forward_visible_word_end (an_iter: POINTER): INTEGER is -- gboolean
  1247. external "C use <gtk/gtk.h>"
  1248. end
  1249. gtk_text_iter_backward_visible_word_start (an_iter: POINTER): INTEGER is -- gboolean
  1250. external "C use <gtk/gtk.h>"
  1251. end
  1252. gtk_text_iter_forward_visible_cursor_position (an_iter: POINTER): INTEGER is -- gboolean
  1253. external "C use <gtk/gtk.h>"
  1254. end
  1255. gtk_text_iter_backward_visible_cursor_position (an_iter: POINTER): INTEGER is -- gboolean
  1256. external "C use <gtk/gtk.h>"
  1257. end
  1258. gtk_text_iter_forward_visible_cursor_positions (an_iter: POINTER; a_count: INTEGER): INTEGER is -- gboolean
  1259. external "C use <gtk/gtk.h>"
  1260. end
  1261. gtk_text_iter_backward_visible_cursor_positions (an_iter: POINTER; a_count: INTEGER): INTEGER is -- gboolean
  1262. external "C use <gtk/gtk.h>"
  1263. end
  1264. gtk_text_iter_forward_visible_line (an_iter: POINTER): INTEGER is -- gboolean
  1265. external "C use <gtk/gtk.h>"
  1266. end
  1267. gtk_text_iter_backward_visible_line (an_iter: POINTER): INTEGER is -- gboolean
  1268. external "C use <gtk/gtk.h>"
  1269. end
  1270. gtk_text_iter_forward_visible_lines (an_iter: POINTER; a_count: INTEGER): INTEGER is -- gboolean
  1271. external "C use <gtk/gtk.h>"
  1272. end
  1273. gtk_text_iter_backward_visible_lines (an_iter: POINTER; a_count: INTEGER): INTEGER is -- gboolean
  1274. external "C use <gtk/gtk.h>"
  1275. end
  1276. gtk_text_iter_set_offset (an_iter: POINTER; a_char_offset: INTEGER) is
  1277. external "C use <gtk/gtk.h>"
  1278. end
  1279. gtk_text_iter_set_line (an_iter: POINTER; a_line_number: INTEGER) is
  1280. external "C use <gtk/gtk.h>"
  1281. end
  1282. gtk_text_iter_set_line_offset (an_iter: POINTER; a_char_on_line: INTEGER) is
  1283. external "C use <gtk/gtk.h>"
  1284. end
  1285. gtk_text_iter_set_line_index (an_iter: POINTER; a_byte_on_line: INTEGER) is
  1286. external "C use <gtk/gtk.h>"
  1287. end
  1288. gtk_text_iter_set_visible_line_index (an_iter: POINTER; a_byte_on_line: INTEGER) is
  1289. external "C use <gtk/gtk.h>"
  1290. end
  1291. gtk_text_iter_set_visible_line_offset (an_iter: POINTER; a_char_on_line: INTEGER) is
  1292. external "C use <gtk/gtk.h>"
  1293. end
  1294. gtk_text_iter_forward_to_end (an_iter: POINTER) is
  1295. external "C use <gtk/gtk.h>"
  1296. end
  1297. gtk_text_iter_forward_to_line_end (an_iter: POINTER): INTEGER is -- gboolean
  1298. external "C use <gtk/gtk.h>"
  1299. end
  1300. gtk_text_iter_forward_to_tag_toggle (an_iter: POINTER; a_tag: POINTER): INTEGER is -- gboolean
  1301. external "C use <gtk/gtk.h>"
  1302. end
  1303. gtk_text_iter_backward_to_tag_toggle (an_iter: POINTER; a_tag: POINTER): INTEGER is -- gboolean
  1304. external "C use <gtk/gtk.h>"
  1305. end
  1306. --(*GtkTextCharPredicate) (gunichar ch; gpointer user_data): INTEGER
  1307. gtk_text_iter_forward_find_char (an_iter: POINTER; a_predicate, user_data: POINTER; a_limit: POINTER): INTEGER is -- gboolean
  1308. external "C use <gtk/gtk.h>"
  1309. end
  1310. gtk_text_iter_backward_find_char (an_iter: POINTER; a_predicate, user_data: POINTER; a_limit: POINTER): INTEGER is -- gboolean
  1311. external "C use <gtk/gtk.h>"
  1312. end
  1313. gtk_text_iter_forward_search (an_iter: POINTER; a_string: POINTER; some_flags: INTEGER; an_match_start: POINTER; an_match_end: POINTER; a_limit: POINTER): INTEGER is -- gboolean
  1314. require --valid_flags: are_valid_search_flags (some_flags)
  1315. external "C use <gtk/gtk.h>"
  1316. end
  1317. gtk_text_iter_backward_search (an_iter: POINTER; a_string: POINTER; some_flags: INTEGER; a_match_start: POINTER; a_match_end: POINTER; a_limit: POINTER): INTEGER is -- gboolean
  1318. require --valid_flags: are_valid_search_flags (some_flags)
  1319. external "C use <gtk/gtk.h>"
  1320. end
  1321. gtk_text_iter_equal (an_lhs: POINTER; an_rhs: POINTER): INTEGER is -- gboolean
  1322. external "C use <gtk/gtk.h>"
  1323. end
  1324. gtk_text_iter_compare (an_lhs: POINTER; an_rhs: POINTER): INTEGER is -- gint
  1325. external "C use <gtk/gtk.h>"
  1326. end
  1327. gtk_text_iter_in_range (an_iter: POINTER; an_start: POINTER; an_end: POINTER): INTEGER is -- gboolean
  1328. external "C use <gtk/gtk.h>"
  1329. end
  1330. gtk_text_iter_order (first: POINTER; an_second: POINTER) is
  1331. external "C use <gtk/gtk.h>"
  1332. end
  1333. feature {} -- GtkTextCharPredicate callback
  1334. hidden_callback (a_gunichar: INTEGER_32; data: POINTER): INTEGER is
  1335. external "C inline use <gtk/gtk.h>"
  1336. alias "$Result = ((*GtkTextCharPredicate)($data[0]) ($a_gunichar, $data[1]));"
  1337. end
  1338. callback_array (a_callback_pointer: POINTER): POINTER is
  1339. -- This call is required because we need to build an array
  1340. -- with the address of an Eiffel feature (namely
  1341. -- callback). `$' operator thought can be used only in a
  1342. -- feature call. Hence this.
  1343. do
  1344. Result:= {NATIVE_ARRAY[POINTER]
  1345. <<a_callback_pointer ,Current.to_pointer>>
  1346. }.to_external
  1347. end
  1348. feature {}
  1349. callback (a_unicode_character: INTEGER_32): BOOLEAN is
  1350. do
  1351. debug
  1352. print ("Gtk text char predicate function callback:")
  1353. print (" a_unicode_character=") print(a_unicode_character.to_string)
  1354. print ("%N")
  1355. end
  1356. Result:=(predicate.item([a_unicode_character]).to_integer).to_boolean
  1357. end
  1358. predicate: PREDICATE[TUPLE[INTEGER_32]]
  1359. invariant
  1360. handle.is_not_null
  1361. end