Skip to main content

gtk4/auto/
text_iter.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// DO NOT EDIT
4
5use crate::{TextBuffer, TextChildAnchor, TextMark, TextSearchFlags, TextTag, ffi};
6use glib::{prelude::*, translate::*};
7
8glib::wrapper! {
9    /// Iterates over the contents of a [`TextBuffer`][crate::TextBuffer].
10    ///
11    /// You may wish to begin by reading the
12    /// [text widget conceptual overview](section-text-widget.html),
13    /// which gives an overview of all the objects and data types
14    /// related to the text widget and how they work together.
15    #[derive(Debug)]
16    pub struct TextIter(BoxedInline<ffi::GtkTextIter>);
17
18    match fn {
19        copy => |ptr| ffi::gtk_text_iter_copy(ptr),
20        free => |ptr| ffi::gtk_text_iter_free(ptr),
21        type_ => || ffi::gtk_text_iter_get_type(),
22    }
23}
24
25impl TextIter {
26    /// Assigns the value of @other to @self.
27    ///
28    /// This function is not useful in applications, because
29    /// iterators can be assigned with `GtkTextIter i = j;`.
30    ///
31    /// The function is used by language bindings.
32    /// ## `other`
33    /// another [`TextIter`][crate::TextIter]
34    #[doc(alias = "gtk_text_iter_assign")]
35    pub fn assign(&mut self, other: &TextIter) {
36        unsafe {
37            ffi::gtk_text_iter_assign(self.to_glib_none_mut().0, other.to_glib_none().0);
38        }
39    }
40
41    /// Moves backward by one character offset.
42    ///
43    /// Returns [`true`] if movement was possible; if @self was the first
44    /// in the buffer (character offset 0), this function returns [`false`]
45    /// for convenience when writing loops.
46    ///
47    /// # Returns
48    ///
49    /// whether movement was possible
50    #[doc(alias = "gtk_text_iter_backward_char")]
51    pub fn backward_char(&mut self) -> bool {
52        unsafe { from_glib(ffi::gtk_text_iter_backward_char(self.to_glib_none_mut().0)) }
53    }
54
55    /// t move, or
56    /// moved onto the end iterator, then [`false`] is returned. If @count is 0,
57    /// the function does nothing and returns [`false`].
58    /// ## `count`
59    /// number of characters to move
60    ///
61    /// # Returns
62    ///
63    /// whether @self moved and is dereferenceable
64    #[doc(alias = "gtk_text_iter_backward_chars")]
65    pub fn backward_chars(&mut self, count: i32) -> bool {
66        unsafe {
67            from_glib(ffi::gtk_text_iter_backward_chars(
68                self.to_glib_none_mut().0,
69                count,
70            ))
71        }
72    }
73
74    /// Like [`forward_cursor_position()`][Self::forward_cursor_position()], but moves backward.
75    ///
76    /// # Returns
77    ///
78    /// [`true`] if we moved
79    #[doc(alias = "gtk_text_iter_backward_cursor_position")]
80    pub fn backward_cursor_position(&mut self) -> bool {
81        unsafe {
82            from_glib(ffi::gtk_text_iter_backward_cursor_position(
83                self.to_glib_none_mut().0,
84            ))
85        }
86    }
87
88    /// Moves up to @count cursor positions.
89    ///
90    /// See [`forward_cursor_position()`][Self::forward_cursor_position()] for details.
91    /// ## `count`
92    /// number of positions to move
93    ///
94    /// # Returns
95    ///
96    /// [`true`] if we moved and the new position is dereferenceable
97    #[doc(alias = "gtk_text_iter_backward_cursor_positions")]
98    pub fn backward_cursor_positions(&mut self, count: i32) -> bool {
99        unsafe {
100            from_glib(ffi::gtk_text_iter_backward_cursor_positions(
101                self.to_glib_none_mut().0,
102                count,
103            ))
104        }
105    }
106
107    /// Same as [`forward_find_char()`][Self::forward_find_char()],
108    /// but goes backward from @self.
109    /// ## `pred`
110    /// function to be called on each character
111    /// ## `limit`
112    /// search limit
113    ///
114    /// # Returns
115    ///
116    /// whether a match was found
117    #[doc(alias = "gtk_text_iter_backward_find_char")]
118    pub fn backward_find_char<P: FnMut(char) -> bool>(
119        &mut self,
120        pred: P,
121        limit: Option<&TextIter>,
122    ) -> bool {
123        let mut pred_data: P = pred;
124        unsafe extern "C" fn pred_func<P: FnMut(char) -> bool>(
125            ch: u32,
126            user_data: glib::ffi::gpointer,
127        ) -> glib::ffi::gboolean {
128            unsafe {
129                let ch = std::convert::TryFrom::try_from(ch)
130                    .expect("conversion from an invalid Unicode value attempted");
131                let callback = user_data as *mut P;
132                (*callback)(ch).into_glib()
133            }
134        }
135        let pred = Some(pred_func::<P> as _);
136        let super_callback0: &mut P = &mut pred_data;
137        unsafe {
138            from_glib(ffi::gtk_text_iter_backward_find_char(
139                self.to_glib_none_mut().0,
140                pred,
141                super_callback0 as *mut _ as *mut _,
142                limit.to_glib_none().0,
143            ))
144        }
145    }
146
147    /// Moves @self to the start of the previous line.
148    ///
149    /// Returns [`true`] if @self could be moved; i.e. if @self was at
150    /// character offset 0, this function returns [`false`]. Therefore,
151    /// if @self was already on line 0, but not at the start of the line,
152    /// @self is snapped to the start of the line and the function returns
153    /// [`true`]. (Note that this implies that
154    /// in a loop calling this function, the line number may not change on
155    /// every iteration, if your first iteration is on line 0.)
156    ///
157    /// # Returns
158    ///
159    /// whether @self moved
160    #[doc(alias = "gtk_text_iter_backward_line")]
161    pub fn backward_line(&mut self) -> bool {
162        unsafe { from_glib(ffi::gtk_text_iter_backward_line(self.to_glib_none_mut().0)) }
163    }
164
165    /// t move, or
166    /// moved onto the end iterator, then [`false`] is returned. If @count is 0,
167    /// the function does nothing and returns [`false`]. If @count is negative,
168    /// moves forward by 0 - @count lines.
169    /// ## `count`
170    /// number of lines to move backward
171    ///
172    /// # Returns
173    ///
174    /// whether @self moved and is dereferenceable
175    #[doc(alias = "gtk_text_iter_backward_lines")]
176    pub fn backward_lines(&mut self, count: i32) -> bool {
177        unsafe {
178            from_glib(ffi::gtk_text_iter_backward_lines(
179                self.to_glib_none_mut().0,
180                count,
181            ))
182        }
183    }
184
185    /// Same as [`forward_search()`][Self::forward_search()], but moves backward.
186    ///
187    /// @match_end will never be set to a [`TextIter`][crate::TextIter] located after @self,
188    /// even if there is a possible @match_start before or at @self.
189    /// ## `str`
190    /// search string
191    /// ## `flags`
192    /// bitmask of flags affecting the search
193    /// ## `limit`
194    /// location of last possible @match_start, or [`None`] for start of buffer
195    ///
196    /// # Returns
197    ///
198    /// whether a match was found
199    ///
200    /// ## `match_start`
201    /// return location for start of match
202    ///
203    /// ## `match_end`
204    /// return location for end of match
205    #[doc(alias = "gtk_text_iter_backward_search")]
206    pub fn backward_search(
207        &self,
208        str: &str,
209        flags: TextSearchFlags,
210        limit: Option<&TextIter>,
211    ) -> Option<(TextIter, TextIter)> {
212        unsafe {
213            let mut match_start = TextIter::uninitialized();
214            let mut match_end = TextIter::uninitialized();
215            let ret = from_glib(ffi::gtk_text_iter_backward_search(
216                self.to_glib_none().0,
217                str.to_glib_none().0,
218                flags.into_glib(),
219                match_start.to_glib_none_mut().0,
220                match_end.to_glib_none_mut().0,
221                limit.to_glib_none().0,
222            ));
223            if ret {
224                Some((match_start, match_end))
225            } else {
226                None
227            }
228        }
229    }
230
231    /// Moves backward to the previous sentence start.
232    ///
233    /// If @self is already at the start of a sentence, moves backward
234    /// to the next one.
235    ///
236    /// Sentence boundaries are determined by Pango and should
237    /// be correct for nearly any language.
238    ///
239    /// # Returns
240    ///
241    /// [`true`] if @self moved and is not the end iterator
242    #[doc(alias = "gtk_text_iter_backward_sentence_start")]
243    pub fn backward_sentence_start(&mut self) -> bool {
244        unsafe {
245            from_glib(ffi::gtk_text_iter_backward_sentence_start(
246                self.to_glib_none_mut().0,
247            ))
248        }
249    }
250
251    /// Calls [`backward_sentence_start()`][Self::backward_sentence_start()] up to @count times.
252    ///
253    /// If @count is negative, moves forward instead of backward.
254    /// ## `count`
255    /// number of sentences to move
256    ///
257    /// # Returns
258    ///
259    /// [`true`] if @self moved and is not the end iterator
260    #[doc(alias = "gtk_text_iter_backward_sentence_starts")]
261    pub fn backward_sentence_starts(&mut self, count: i32) -> bool {
262        unsafe {
263            from_glib(ffi::gtk_text_iter_backward_sentence_starts(
264                self.to_glib_none_mut().0,
265                count,
266            ))
267        }
268    }
269
270    /// Moves backward to the next toggle (on or off) of the
271    /// @tag, or to the next toggle of any tag if
272    /// @tag is [`None`].
273    ///
274    /// If no matching tag toggles are found,
275    /// returns [`false`], otherwise [`true`]. Does not return toggles
276    /// located at @self, only toggles before @self. Sets @self
277    /// to the location of the toggle, or the start of the buffer
278    /// if no toggle is found.
279    /// ## `tag`
280    /// a [`TextTag`][crate::TextTag]
281    ///
282    /// # Returns
283    ///
284    /// whether we found a tag toggle before @self
285    #[doc(alias = "gtk_text_iter_backward_to_tag_toggle")]
286    pub fn backward_to_tag_toggle(&mut self, tag: Option<&impl IsA<TextTag>>) -> bool {
287        unsafe {
288            from_glib(ffi::gtk_text_iter_backward_to_tag_toggle(
289                self.to_glib_none_mut().0,
290                tag.map(|p| p.as_ref()).to_glib_none().0,
291            ))
292        }
293    }
294
295    /// Moves @self backward to the previous visible cursor position.
296    ///
297    /// See [`backward_cursor_position()`][Self::backward_cursor_position()] for details.
298    ///
299    /// # Returns
300    ///
301    /// [`true`] if we moved and the new position is dereferenceable
302    #[doc(alias = "gtk_text_iter_backward_visible_cursor_position")]
303    pub fn backward_visible_cursor_position(&mut self) -> bool {
304        unsafe {
305            from_glib(ffi::gtk_text_iter_backward_visible_cursor_position(
306                self.to_glib_none_mut().0,
307            ))
308        }
309    }
310
311    /// Moves up to @count visible cursor positions.
312    ///
313    /// See [`backward_cursor_position()`][Self::backward_cursor_position()] for details.
314    /// ## `count`
315    /// number of positions to move
316    ///
317    /// # Returns
318    ///
319    /// [`true`] if we moved and the new position is dereferenceable
320    #[doc(alias = "gtk_text_iter_backward_visible_cursor_positions")]
321    pub fn backward_visible_cursor_positions(&mut self, count: i32) -> bool {
322        unsafe {
323            from_glib(ffi::gtk_text_iter_backward_visible_cursor_positions(
324                self.to_glib_none_mut().0,
325                count,
326            ))
327        }
328    }
329
330    /// Moves @self to the start of the previous visible line.
331    ///
332    /// Returns [`true`] if
333    /// @self could be moved; i.e. if @self was at character offset 0, this
334    /// function returns [`false`]. Therefore if @self was already on line 0,
335    /// but not at the start of the line, @self is snapped to the start of
336    /// the line and the function returns [`true`]. (Note that this implies that
337    /// in a loop calling this function, the line number may not change on
338    /// every iteration, if your first iteration is on line 0.)
339    ///
340    /// # Returns
341    ///
342    /// whether @self moved
343    #[doc(alias = "gtk_text_iter_backward_visible_line")]
344    pub fn backward_visible_line(&mut self) -> bool {
345        unsafe {
346            from_glib(ffi::gtk_text_iter_backward_visible_line(
347                self.to_glib_none_mut().0,
348            ))
349        }
350    }
351
352    /// t move, or
353    /// moved onto the end iterator, then [`false`] is returned. If @count is 0,
354    /// the function does nothing and returns [`false`]. If @count is negative,
355    /// moves forward by 0 - @count lines.
356    /// ## `count`
357    /// number of lines to move backward
358    ///
359    /// # Returns
360    ///
361    /// whether @self moved and is dereferenceable
362    #[doc(alias = "gtk_text_iter_backward_visible_lines")]
363    pub fn backward_visible_lines(&mut self, count: i32) -> bool {
364        unsafe {
365            from_glib(ffi::gtk_text_iter_backward_visible_lines(
366                self.to_glib_none_mut().0,
367                count,
368            ))
369        }
370    }
371
372    /// Moves backward to the previous visible word start.
373    ///
374    /// If @self is currently on a word start, moves backward to the
375    /// next one after that.
376    ///
377    /// Word breaks are determined by Pango and should be correct
378    /// for nearly any language.
379    ///
380    /// # Returns
381    ///
382    /// [`true`] if @self moved and is not the end iterator
383    #[doc(alias = "gtk_text_iter_backward_visible_word_start")]
384    pub fn backward_visible_word_start(&mut self) -> bool {
385        unsafe {
386            from_glib(ffi::gtk_text_iter_backward_visible_word_start(
387                self.to_glib_none_mut().0,
388            ))
389        }
390    }
391
392    /// Calls [`backward_visible_word_start()`][Self::backward_visible_word_start()] up to @count times.
393    /// ## `count`
394    /// number of times to move
395    ///
396    /// # Returns
397    ///
398    /// [`true`] if @self moved and is not the end iterator
399    #[doc(alias = "gtk_text_iter_backward_visible_word_starts")]
400    pub fn backward_visible_word_starts(&mut self, count: i32) -> bool {
401        unsafe {
402            from_glib(ffi::gtk_text_iter_backward_visible_word_starts(
403                self.to_glib_none_mut().0,
404                count,
405            ))
406        }
407    }
408
409    /// Moves backward to the previous word start.
410    ///
411    /// If @self is currently on a word start, moves backward to the
412    /// next one after that.
413    ///
414    /// Word breaks are determined by Pango and should be correct
415    /// for nearly any language
416    ///
417    /// # Returns
418    ///
419    /// [`true`] if @self moved and is not the end iterator
420    #[doc(alias = "gtk_text_iter_backward_word_start")]
421    pub fn backward_word_start(&mut self) -> bool {
422        unsafe {
423            from_glib(ffi::gtk_text_iter_backward_word_start(
424                self.to_glib_none_mut().0,
425            ))
426        }
427    }
428
429    /// Calls [`backward_word_start()`][Self::backward_word_start()] up to @count times.
430    /// ## `count`
431    /// number of times to move
432    ///
433    /// # Returns
434    ///
435    /// [`true`] if @self moved and is not the end iterator
436    #[doc(alias = "gtk_text_iter_backward_word_starts")]
437    pub fn backward_word_starts(&mut self, count: i32) -> bool {
438        unsafe {
439            from_glib(ffi::gtk_text_iter_backward_word_starts(
440                self.to_glib_none_mut().0,
441                count,
442            ))
443        }
444    }
445
446    /// Considering the default editability of the buffer, and tags that
447    /// affect editability, determines whether text inserted at @self would
448    /// be editable.
449    ///
450    /// If text inserted at @self would be editable then the
451    /// user should be allowed to insert text at @self.
452    /// [`TextBufferExt::insert_interactive()`][crate::prelude::TextBufferExt::insert_interactive()] uses this function
453    /// to decide whether insertions are allowed at a given position.
454    /// ## `default_editability`
455    /// [`true`] if text is editable by default
456    ///
457    /// # Returns
458    ///
459    /// whether text inserted at @self would be editable
460    #[doc(alias = "gtk_text_iter_can_insert")]
461    pub fn can_insert(&self, default_editability: bool) -> bool {
462        unsafe {
463            from_glib(ffi::gtk_text_iter_can_insert(
464                self.to_glib_none().0,
465                default_editability.into_glib(),
466            ))
467        }
468    }
469
470    #[doc(alias = "gtk_text_iter_compare")]
471    fn compare(&self, rhs: &TextIter) -> i32 {
472        unsafe { ffi::gtk_text_iter_compare(self.to_glib_none().0, rhs.to_glib_none().0) }
473    }
474
475    /// t want to know
476    /// whether the char at @self is inside an editable range, you want to
477    /// know whether a new character inserted at @self would be inside an
478    /// editable range. Use [`can_insert()`][Self::can_insert()] to handle this
479    /// case.
480    /// ## `default_setting`
481    /// [`true`] if text is editable by default
482    ///
483    /// # Returns
484    ///
485    /// whether @self is inside an editable range
486    #[doc(alias = "gtk_text_iter_editable")]
487    pub fn editable(&self, default_setting: bool) -> bool {
488        unsafe {
489            from_glib(ffi::gtk_text_iter_editable(
490                self.to_glib_none().0,
491                default_setting.into_glib(),
492            ))
493        }
494    }
495
496    /// Returns [`true`] if @self points to the start of the paragraph
497    /// delimiter characters for a line.
498    ///
499    /// Delimiters will be either a newline, a carriage return, a carriage
500    /// return followed by a newline, or a Unicode paragraph separator
501    /// character.
502    ///
503    /// Note that an iterator pointing to the \n of a \r\n pair will not be
504    /// counted as the end of a line, the line ends before the \r. The end
505    /// iterator is considered to be at the end of a line, even though there
506    /// are no paragraph delimiter chars there.
507    ///
508    /// # Returns
509    ///
510    /// whether @self is at the end of a line
511    #[doc(alias = "gtk_text_iter_ends_line")]
512    pub fn ends_line(&self) -> bool {
513        unsafe { from_glib(ffi::gtk_text_iter_ends_line(self.to_glib_none().0)) }
514    }
515
516    /// Determines whether @self ends a sentence.
517    ///
518    /// Sentence boundaries are determined by Pango and should
519    /// be correct for nearly any language.
520    ///
521    /// # Returns
522    ///
523    /// [`true`] if @self is at the end of a sentence.
524    #[doc(alias = "gtk_text_iter_ends_sentence")]
525    pub fn ends_sentence(&self) -> bool {
526        unsafe { from_glib(ffi::gtk_text_iter_ends_sentence(self.to_glib_none().0)) }
527    }
528
529    /// Returns [`true`] if @tag is toggled off at exactly this point.
530    ///
531    /// If @tag is [`None`], returns [`true`] if any tag is toggled off at this point.
532    ///
533    /// Note that if this function returns [`true`], it means that
534    /// @self is at the end of the tagged range, but that the character
535    /// at @self is outside the tagged range. In other words,
536    /// unlike [`starts_tag()`][Self::starts_tag()], if this function
537    /// returns [`true`], [`has_tag()`][Self::has_tag()] will return
538    /// [`false`] for the same parameters.
539    /// ## `tag`
540    /// a [`TextTag`][crate::TextTag]
541    ///
542    /// # Returns
543    ///
544    /// whether @self is the end of a range tagged with @tag
545    #[doc(alias = "gtk_text_iter_ends_tag")]
546    pub fn ends_tag(&self, tag: Option<&impl IsA<TextTag>>) -> bool {
547        unsafe {
548            from_glib(ffi::gtk_text_iter_ends_tag(
549                self.to_glib_none().0,
550                tag.map(|p| p.as_ref()).to_glib_none().0,
551            ))
552        }
553    }
554
555    /// Determines whether @self ends a natural-language word.
556    ///
557    /// Word breaks are determined by Pango and should be correct
558    /// for nearly any language.
559    ///
560    /// # Returns
561    ///
562    /// [`true`] if @self is at the end of a word
563    #[doc(alias = "gtk_text_iter_ends_word")]
564    pub fn ends_word(&self) -> bool {
565        unsafe { from_glib(ffi::gtk_text_iter_ends_word(self.to_glib_none().0)) }
566    }
567
568    #[doc(alias = "gtk_text_iter_equal")]
569    fn equal(&self, rhs: &TextIter) -> bool {
570        unsafe {
571            from_glib(ffi::gtk_text_iter_equal(
572                self.to_glib_none().0,
573                rhs.to_glib_none().0,
574            ))
575        }
576    }
577
578    /// Moves @self forward by one character offset.
579    ///
580    /// Note that images embedded in the buffer occupy 1 character slot, so
581    /// this function may actually move onto an image instead of a character,
582    /// if you have images in your buffer. If @self is the end iterator or
583    /// one character before it, @self will now point at the end iterator,
584    /// and this function returns [`false`] for convenience when writing loops.
585    ///
586    /// # Returns
587    ///
588    /// whether @self moved and is dereferenceable
589    #[doc(alias = "gtk_text_iter_forward_char")]
590    pub fn forward_char(&mut self) -> bool {
591        unsafe { from_glib(ffi::gtk_text_iter_forward_char(self.to_glib_none_mut().0)) }
592    }
593
594    /// Moves @count characters if possible.
595    ///
596    /// If @count would move past the start or end of the buffer,
597    /// moves to the start or end of the buffer.
598    ///
599    /// The return value indicates whether the new position of
600    /// @self is different from its original position, and dereferenceable
601    /// (the last iterator in the buffer is not dereferenceable). If @count
602    /// is 0, the function does nothing and returns [`false`].
603    /// ## `count`
604    /// number of characters to move, may be negative
605    ///
606    /// # Returns
607    ///
608    /// whether @self moved and is dereferenceable
609    #[doc(alias = "gtk_text_iter_forward_chars")]
610    pub fn forward_chars(&mut self, count: i32) -> bool {
611        unsafe {
612            from_glib(ffi::gtk_text_iter_forward_chars(
613                self.to_glib_none_mut().0,
614                count,
615            ))
616        }
617    }
618
619    /// t go between those two characters.
620    ///
621    /// See also the `Pango::LogAttr` struct and the `break()`
622    /// function.
623    ///
624    /// # Returns
625    ///
626    /// [`true`] if we moved and the new position is dereferenceable
627    #[doc(alias = "gtk_text_iter_forward_cursor_position")]
628    pub fn forward_cursor_position(&mut self) -> bool {
629        unsafe {
630            from_glib(ffi::gtk_text_iter_forward_cursor_position(
631                self.to_glib_none_mut().0,
632            ))
633        }
634    }
635
636    /// Moves up to @count cursor positions.
637    ///
638    /// See [`forward_cursor_position()`][Self::forward_cursor_position()] for details.
639    /// ## `count`
640    /// number of positions to move
641    ///
642    /// # Returns
643    ///
644    /// [`true`] if we moved and the new position is dereferenceable
645    #[doc(alias = "gtk_text_iter_forward_cursor_positions")]
646    pub fn forward_cursor_positions(&mut self, count: i32) -> bool {
647        unsafe {
648            from_glib(ffi::gtk_text_iter_forward_cursor_positions(
649                self.to_glib_none_mut().0,
650                count,
651            ))
652        }
653    }
654
655    /// Advances @self, calling @pred on each character.
656    ///
657    /// If @pred returns [`true`], returns [`true`] and stops scanning.
658    /// If @pred never returns [`true`], @self is set to @limit if
659    /// @limit is non-[`None`], otherwise to the end iterator.
660    /// ## `pred`
661    /// a function to be called on each character
662    /// ## `limit`
663    /// search limit
664    ///
665    /// # Returns
666    ///
667    /// whether a match was found
668    #[doc(alias = "gtk_text_iter_forward_find_char")]
669    pub fn forward_find_char<P: FnMut(char) -> bool>(
670        &mut self,
671        pred: P,
672        limit: Option<&TextIter>,
673    ) -> bool {
674        let mut pred_data: P = pred;
675        unsafe extern "C" fn pred_func<P: FnMut(char) -> bool>(
676            ch: u32,
677            user_data: glib::ffi::gpointer,
678        ) -> glib::ffi::gboolean {
679            unsafe {
680                let ch = std::convert::TryFrom::try_from(ch)
681                    .expect("conversion from an invalid Unicode value attempted");
682                let callback = user_data as *mut P;
683                (*callback)(ch).into_glib()
684            }
685        }
686        let pred = Some(pred_func::<P> as _);
687        let super_callback0: &mut P = &mut pred_data;
688        unsafe {
689            from_glib(ffi::gtk_text_iter_forward_find_char(
690                self.to_glib_none_mut().0,
691                pred,
692                super_callback0 as *mut _ as *mut _,
693                limit.to_glib_none().0,
694            ))
695        }
696    }
697
698    /// Moves @self to the start of the next line.
699    ///
700    /// If the iter is already on the last line of the buffer,
701    /// moves the iter to the end of the current line. If after
702    /// the operation, the iter is at the end of the buffer and not
703    /// dereferenceable, returns [`false`]. Otherwise, returns [`true`].
704    ///
705    /// # Returns
706    ///
707    /// whether @self can be dereferenced
708    #[doc(alias = "gtk_text_iter_forward_line")]
709    pub fn forward_line(&mut self) -> bool {
710        unsafe { from_glib(ffi::gtk_text_iter_forward_line(self.to_glib_none_mut().0)) }
711    }
712
713    /// t move, or
714    /// moved onto the end iterator, then [`false`] is returned. If @count is 0,
715    /// the function does nothing and returns [`false`]. If @count is negative,
716    /// moves backward by 0 - @count lines.
717    /// ## `count`
718    /// number of lines to move forward
719    ///
720    /// # Returns
721    ///
722    /// whether @self moved and is dereferenceable
723    #[doc(alias = "gtk_text_iter_forward_lines")]
724    pub fn forward_lines(&mut self, count: i32) -> bool {
725        unsafe {
726            from_glib(ffi::gtk_text_iter_forward_lines(
727                self.to_glib_none_mut().0,
728                count,
729            ))
730        }
731    }
732
733    /// Searches forward for @str.
734    ///
735    /// Any match is returned by setting @match_start to the first character
736    /// of the match and @match_end to the first character after the match.
737    /// The search will not continue past @limit. Note that a search is a
738    /// linear or O(n) operation, so you may wish to use @limit to avoid
739    /// locking up your UI on large buffers.
740    ///
741    /// @match_start will never be set to a [`TextIter`][crate::TextIter] located before @self,
742    /// even if there is a possible @match_end after or at @self.
743    /// ## `str`
744    /// a search string
745    /// ## `flags`
746    /// flags affecting how the search is done
747    /// ## `limit`
748    /// location of last possible @match_end, or [`None`] for the end of the buffer
749    ///
750    /// # Returns
751    ///
752    /// whether a match was found
753    ///
754    /// ## `match_start`
755    /// return location for start of match
756    ///
757    /// ## `match_end`
758    /// return location for end of match
759    #[doc(alias = "gtk_text_iter_forward_search")]
760    pub fn forward_search(
761        &self,
762        str: &str,
763        flags: TextSearchFlags,
764        limit: Option<&TextIter>,
765    ) -> Option<(TextIter, TextIter)> {
766        unsafe {
767            let mut match_start = TextIter::uninitialized();
768            let mut match_end = TextIter::uninitialized();
769            let ret = from_glib(ffi::gtk_text_iter_forward_search(
770                self.to_glib_none().0,
771                str.to_glib_none().0,
772                flags.into_glib(),
773                match_start.to_glib_none_mut().0,
774                match_end.to_glib_none_mut().0,
775                limit.to_glib_none().0,
776            ));
777            if ret {
778                Some((match_start, match_end))
779            } else {
780                None
781            }
782        }
783    }
784
785    /// Moves forward to the next sentence end.
786    ///
787    /// If @self is at the end of a sentence, moves to the next
788    /// end of sentence.
789    ///
790    /// Sentence boundaries are determined by Pango and should
791    /// be correct for nearly any language.
792    ///
793    /// # Returns
794    ///
795    /// [`true`] if @self moved and is not the end iterator
796    #[doc(alias = "gtk_text_iter_forward_sentence_end")]
797    pub fn forward_sentence_end(&mut self) -> bool {
798        unsafe {
799            from_glib(ffi::gtk_text_iter_forward_sentence_end(
800                self.to_glib_none_mut().0,
801            ))
802        }
803    }
804
805    /// Calls [`forward_sentence_end()`][Self::forward_sentence_end()] @count times.
806    ///
807    /// If @count is negative, moves backward instead of forward.
808    /// ## `count`
809    /// number of sentences to move
810    ///
811    /// # Returns
812    ///
813    /// [`true`] if @self moved and is not the end iterator
814    #[doc(alias = "gtk_text_iter_forward_sentence_ends")]
815    pub fn forward_sentence_ends(&mut self, count: i32) -> bool {
816        unsafe {
817            from_glib(ffi::gtk_text_iter_forward_sentence_ends(
818                self.to_glib_none_mut().0,
819                count,
820            ))
821        }
822    }
823
824    /// , which points
825    /// one past the last valid character in the buffer.
826    ///
827    /// [`char()`][Self::char()] called on the end iterator
828    /// returns 0, which is convenient for writing loops.
829    #[doc(alias = "gtk_text_iter_forward_to_end")]
830    pub fn forward_to_end(&mut self) {
831        unsafe {
832            ffi::gtk_text_iter_forward_to_end(self.to_glib_none_mut().0);
833        }
834    }
835
836    /// Moves the iterator to point to the paragraph delimiter characters.
837    ///
838    /// The possible characters are either a newline, a carriage return,
839    /// a carriage return/newline in sequence, or the Unicode paragraph
840    /// separator character.
841    ///
842    /// If the iterator is already at the paragraph delimiter
843    /// characters, moves to the paragraph delimiter characters for the
844    /// next line. If @self is on the last line in the buffer, which does
845    /// not end in paragraph delimiters, moves to the end iterator (end of
846    /// the last line), and returns [`false`].
847    ///
848    /// # Returns
849    ///
850    /// [`true`] if we moved and the new location is not the end iterator
851    #[doc(alias = "gtk_text_iter_forward_to_line_end")]
852    pub fn forward_to_line_end(&mut self) -> bool {
853        unsafe {
854            from_glib(ffi::gtk_text_iter_forward_to_line_end(
855                self.to_glib_none_mut().0,
856            ))
857        }
858    }
859
860    /// Moves forward to the next toggle (on or off) of the
861    /// @tag, or to the next toggle of any tag if
862    /// @tag is [`None`].
863    ///
864    /// If no matching tag toggles are found,
865    /// returns [`false`], otherwise [`true`]. Does not return toggles
866    /// located at @self, only toggles after @self. Sets @self to
867    /// the location of the toggle, or to the end of the buffer
868    /// if no toggle is found.
869    /// ## `tag`
870    /// a [`TextTag`][crate::TextTag]
871    ///
872    /// # Returns
873    ///
874    /// whether we found a tag toggle after @self
875    #[doc(alias = "gtk_text_iter_forward_to_tag_toggle")]
876    pub fn forward_to_tag_toggle(&mut self, tag: Option<&impl IsA<TextTag>>) -> bool {
877        unsafe {
878            from_glib(ffi::gtk_text_iter_forward_to_tag_toggle(
879                self.to_glib_none_mut().0,
880                tag.map(|p| p.as_ref()).to_glib_none().0,
881            ))
882        }
883    }
884
885    /// Moves @self forward to the next visible cursor position.
886    ///
887    /// See [`forward_cursor_position()`][Self::forward_cursor_position()] for details.
888    ///
889    /// # Returns
890    ///
891    /// [`true`] if we moved and the new position is dereferenceable
892    #[doc(alias = "gtk_text_iter_forward_visible_cursor_position")]
893    pub fn forward_visible_cursor_position(&mut self) -> bool {
894        unsafe {
895            from_glib(ffi::gtk_text_iter_forward_visible_cursor_position(
896                self.to_glib_none_mut().0,
897            ))
898        }
899    }
900
901    /// Moves up to @count visible cursor positions.
902    ///
903    /// See [`forward_cursor_position()`][Self::forward_cursor_position()] for details.
904    /// ## `count`
905    /// number of positions to move
906    ///
907    /// # Returns
908    ///
909    /// [`true`] if we moved and the new position is dereferenceable
910    #[doc(alias = "gtk_text_iter_forward_visible_cursor_positions")]
911    pub fn forward_visible_cursor_positions(&mut self, count: i32) -> bool {
912        unsafe {
913            from_glib(ffi::gtk_text_iter_forward_visible_cursor_positions(
914                self.to_glib_none_mut().0,
915                count,
916            ))
917        }
918    }
919
920    /// Moves @self to the start of the next visible line.
921    ///
922    /// Returns [`true`] if there
923    /// was a next line to move to, and [`false`] if @self was simply moved to
924    /// the end of the buffer and is now not dereferenceable, or if @self was
925    /// already at the end of the buffer.
926    ///
927    /// # Returns
928    ///
929    /// whether @self can be dereferenced
930    #[doc(alias = "gtk_text_iter_forward_visible_line")]
931    pub fn forward_visible_line(&mut self) -> bool {
932        unsafe {
933            from_glib(ffi::gtk_text_iter_forward_visible_line(
934                self.to_glib_none_mut().0,
935            ))
936        }
937    }
938
939    /// t move, or
940    /// moved onto the end iterator, then [`false`] is returned. If @count is 0,
941    /// the function does nothing and returns [`false`]. If @count is negative,
942    /// moves backward by 0 - @count lines.
943    /// ## `count`
944    /// number of lines to move forward
945    ///
946    /// # Returns
947    ///
948    /// whether @self moved and is dereferenceable
949    #[doc(alias = "gtk_text_iter_forward_visible_lines")]
950    pub fn forward_visible_lines(&mut self, count: i32) -> bool {
951        unsafe {
952            from_glib(ffi::gtk_text_iter_forward_visible_lines(
953                self.to_glib_none_mut().0,
954                count,
955            ))
956        }
957    }
958
959    /// Moves forward to the next visible word end.
960    ///
961    /// If @self is currently on a word end, moves forward to the
962    /// next one after that.
963    ///
964    /// Word breaks are determined by Pango and should be correct
965    /// for nearly any language
966    ///
967    /// # Returns
968    ///
969    /// [`true`] if @self moved and is not the end iterator
970    #[doc(alias = "gtk_text_iter_forward_visible_word_end")]
971    pub fn forward_visible_word_end(&mut self) -> bool {
972        unsafe {
973            from_glib(ffi::gtk_text_iter_forward_visible_word_end(
974                self.to_glib_none_mut().0,
975            ))
976        }
977    }
978
979    /// Calls [`forward_visible_word_end()`][Self::forward_visible_word_end()] up to @count times.
980    /// ## `count`
981    /// number of times to move
982    ///
983    /// # Returns
984    ///
985    /// [`true`] if @self moved and is not the end iterator
986    #[doc(alias = "gtk_text_iter_forward_visible_word_ends")]
987    pub fn forward_visible_word_ends(&mut self, count: i32) -> bool {
988        unsafe {
989            from_glib(ffi::gtk_text_iter_forward_visible_word_ends(
990                self.to_glib_none_mut().0,
991                count,
992            ))
993        }
994    }
995
996    /// Moves forward to the next word end.
997    ///
998    /// If @self is currently on a word end, moves forward to the
999    /// next one after that.
1000    ///
1001    /// Word breaks are determined by Pango and should be correct
1002    /// for nearly any language.
1003    ///
1004    /// # Returns
1005    ///
1006    /// [`true`] if @self moved and is not the end iterator
1007    #[doc(alias = "gtk_text_iter_forward_word_end")]
1008    pub fn forward_word_end(&mut self) -> bool {
1009        unsafe {
1010            from_glib(ffi::gtk_text_iter_forward_word_end(
1011                self.to_glib_none_mut().0,
1012            ))
1013        }
1014    }
1015
1016    /// Calls [`forward_word_end()`][Self::forward_word_end()] up to @count times.
1017    /// ## `count`
1018    /// number of times to move
1019    ///
1020    /// # Returns
1021    ///
1022    /// [`true`] if @self moved and is not the end iterator
1023    #[doc(alias = "gtk_text_iter_forward_word_ends")]
1024    pub fn forward_word_ends(&mut self, count: i32) -> bool {
1025        unsafe {
1026            from_glib(ffi::gtk_text_iter_forward_word_ends(
1027                self.to_glib_none_mut().0,
1028                count,
1029            ))
1030        }
1031    }
1032
1033    /// Returns the [`TextBuffer`][crate::TextBuffer] this iterator is associated with.
1034    ///
1035    /// # Returns
1036    ///
1037    /// the buffer
1038    #[doc(alias = "gtk_text_iter_get_buffer")]
1039    #[doc(alias = "get_buffer")]
1040    pub fn buffer(&self) -> TextBuffer {
1041        unsafe { from_glib_none(ffi::gtk_text_iter_get_buffer(self.to_glib_none().0)) }
1042    }
1043
1044    /// Returns the number of bytes in the line containing @self,
1045    /// including the paragraph delimiters.
1046    ///
1047    /// # Returns
1048    ///
1049    /// number of bytes in the line
1050    #[doc(alias = "gtk_text_iter_get_bytes_in_line")]
1051    #[doc(alias = "get_bytes_in_line")]
1052    pub fn bytes_in_line(&self) -> i32 {
1053        unsafe { ffi::gtk_text_iter_get_bytes_in_line(self.to_glib_none().0) }
1054    }
1055
1056    ///  character 0xFFFC
1057    /// is returned. If invoked on the end iterator, zero is returned;
1058    /// zero is not a valid Unicode character.
1059    ///
1060    /// So you can write a loop which ends when this function returns 0.
1061    ///
1062    /// # Returns
1063    ///
1064    /// a Unicode character, or 0 if @self is not dereferenceable
1065    #[doc(alias = "gtk_text_iter_get_char")]
1066    #[doc(alias = "get_char")]
1067    pub fn char(&self) -> char {
1068        unsafe {
1069            std::convert::TryFrom::try_from(ffi::gtk_text_iter_get_char(self.to_glib_none().0))
1070                .expect("conversion from an invalid Unicode value attempted")
1071        }
1072    }
1073
1074    /// Returns the number of characters in the line containing @self,
1075    /// including the paragraph delimiters.
1076    ///
1077    /// # Returns
1078    ///
1079    /// number of characters in the line
1080    #[doc(alias = "gtk_text_iter_get_chars_in_line")]
1081    #[doc(alias = "get_chars_in_line")]
1082    pub fn chars_in_line(&self) -> i32 {
1083        unsafe { ffi::gtk_text_iter_get_chars_in_line(self.to_glib_none().0) }
1084    }
1085
1086    /// If the location at @self contains a child anchor, the
1087    /// anchor is returned.
1088    ///
1089    /// Otherwise, [`None`] is returned.
1090    ///
1091    /// # Returns
1092    ///
1093    /// the anchor at @self
1094    #[doc(alias = "gtk_text_iter_get_child_anchor")]
1095    #[doc(alias = "get_child_anchor")]
1096    pub fn child_anchor(&self) -> Option<TextChildAnchor> {
1097        unsafe { from_glib_none(ffi::gtk_text_iter_get_child_anchor(self.to_glib_none().0)) }
1098    }
1099
1100    /// Returns the language in effect at @self.
1101    ///
1102    /// If no tags affecting language apply to @self, the return
1103    /// value is identical to that of [`default_language()`][crate::default_language()].
1104    ///
1105    /// # Returns
1106    ///
1107    /// language in effect at @self
1108    #[doc(alias = "gtk_text_iter_get_language")]
1109    #[doc(alias = "get_language")]
1110    pub fn language(&self) -> pango::Language {
1111        unsafe { from_glib_full(ffi::gtk_text_iter_get_language(self.to_glib_none().0)) }
1112    }
1113
1114    /// Returns the line number containing the iterator.
1115    ///
1116    /// Lines in a [`TextBuffer`][crate::TextBuffer] are numbered beginning
1117    /// with 0 for the first line in the buffer.
1118    ///
1119    /// # Returns
1120    ///
1121    /// a line number
1122    #[doc(alias = "gtk_text_iter_get_line")]
1123    #[doc(alias = "get_line")]
1124    pub fn line(&self) -> i32 {
1125        unsafe { ffi::gtk_text_iter_get_line(self.to_glib_none().0) }
1126    }
1127
1128    /// Returns the byte index of the iterator, counting
1129    /// from the start of a newline-terminated line.
1130    ///
1131    /// Remember that [`TextBuffer`][crate::TextBuffer] encodes text in
1132    /// UTF-8, and that characters can require a variable
1133    /// number of bytes to represent.
1134    ///
1135    /// # Returns
1136    ///
1137    /// distance from start of line, in bytes
1138    #[doc(alias = "gtk_text_iter_get_line_index")]
1139    #[doc(alias = "get_line_index")]
1140    pub fn line_index(&self) -> i32 {
1141        unsafe { ffi::gtk_text_iter_get_line_index(self.to_glib_none().0) }
1142    }
1143
1144    /// Returns the character offset of the iterator,
1145    /// counting from the start of a newline-terminated line.
1146    ///
1147    /// The first character on the line has offset 0.
1148    ///
1149    /// # Returns
1150    ///
1151    /// offset from start of line
1152    #[doc(alias = "gtk_text_iter_get_line_offset")]
1153    #[doc(alias = "get_line_offset")]
1154    pub fn line_offset(&self) -> i32 {
1155        unsafe { ffi::gtk_text_iter_get_line_offset(self.to_glib_none().0) }
1156    }
1157
1158    /// t take up any "space"
1159    /// in the buffer, they are just marks in between iterable locations),
1160    /// multiple marks can exist in the same place.
1161    ///
1162    /// The returned list is not in any meaningful order.
1163    ///
1164    /// # Returns
1165    ///
1166    ///
1167    ///   list of [`TextMark`][crate::TextMark]
1168    #[doc(alias = "gtk_text_iter_get_marks")]
1169    #[doc(alias = "get_marks")]
1170    pub fn marks(&self) -> Vec<TextMark> {
1171        unsafe {
1172            FromGlibPtrContainer::from_glib_container(ffi::gtk_text_iter_get_marks(
1173                self.to_glib_none().0,
1174            ))
1175        }
1176    }
1177
1178    /// Returns the character offset of an iterator.
1179    ///
1180    /// Each character in a [`TextBuffer`][crate::TextBuffer] has an offset,
1181    /// starting with 0 for the first character in the buffer.
1182    /// Use [`TextBufferExt::iter_at_offset()`][crate::prelude::TextBufferExt::iter_at_offset()] to convert
1183    /// an offset back into an iterator.
1184    ///
1185    /// # Returns
1186    ///
1187    /// a character offset
1188    #[doc(alias = "gtk_text_iter_get_offset")]
1189    #[doc(alias = "get_offset")]
1190    pub fn offset(&self) -> i32 {
1191        unsafe { ffi::gtk_text_iter_get_offset(self.to_glib_none().0) }
1192    }
1193
1194    /// If the element at @self is a paintable, the paintable is returned.
1195    ///
1196    /// Otherwise, [`None`] is returned.
1197    ///
1198    /// # Returns
1199    ///
1200    /// the paintable at @self
1201    #[doc(alias = "gtk_text_iter_get_paintable")]
1202    #[doc(alias = "get_paintable")]
1203    pub fn paintable(&self) -> Option<gdk::Paintable> {
1204        unsafe { from_glib_none(ffi::gtk_text_iter_get_paintable(self.to_glib_none().0)) }
1205    }
1206
1207    ///  character 0xFFFC for iterable
1208    /// non-character elements in the buffer, such as images.
1209    /// Because images are encoded in the slice, byte and
1210    /// character offsets in the returned array will correspond to byte
1211    /// offsets in the text buffer. Note that 0xFFFC can occur in normal
1212    /// text as well, so it is not a reliable indicator that a paintable or
1213    /// widget is in the buffer.
1214    /// ## `end`
1215    /// iterator at end of a range
1216    ///
1217    /// # Returns
1218    ///
1219    /// slice of text from the buffer
1220    #[doc(alias = "gtk_text_iter_get_slice")]
1221    #[doc(alias = "get_slice")]
1222    pub fn slice(&self, end: &TextIter) -> glib::GString {
1223        unsafe {
1224            from_glib_full(ffi::gtk_text_iter_get_slice(
1225                self.to_glib_none().0,
1226                end.to_glib_none().0,
1227            ))
1228        }
1229    }
1230
1231    /// t have a reference added,
1232    /// but you have to free the list itself.
1233    ///
1234    /// # Returns
1235    ///
1236    /// list of
1237    ///   [`TextTag`][crate::TextTag]
1238    #[doc(alias = "gtk_text_iter_get_tags")]
1239    #[doc(alias = "get_tags")]
1240    pub fn tags(&self) -> Vec<TextTag> {
1241        unsafe {
1242            FromGlibPtrContainer::from_glib_container(ffi::gtk_text_iter_get_tags(
1243                self.to_glib_none().0,
1244            ))
1245        }
1246    }
1247
1248    /// Returns text in the given range.
1249    ///
1250    /// If the range
1251    /// contains non-text elements such as images, the character and byte
1252    /// offsets in the returned string will not correspond to character and
1253    /// byte offsets in the buffer. If you want offsets to correspond, see
1254    /// [`slice()`][Self::slice()].
1255    /// ## `end`
1256    /// iterator at end of a range
1257    ///
1258    /// # Returns
1259    ///
1260    /// array of characters from the buffer
1261    #[doc(alias = "gtk_text_iter_get_text")]
1262    #[doc(alias = "get_text")]
1263    pub fn text(&self, end: &TextIter) -> glib::GString {
1264        unsafe {
1265            from_glib_full(ffi::gtk_text_iter_get_text(
1266                self.to_glib_none().0,
1267                end.to_glib_none().0,
1268            ))
1269        }
1270    }
1271
1272    /// Returns a list of [`TextTag`][crate::TextTag] that are toggled on or off at this
1273    /// point.
1274    ///
1275    /// If @toggled_on is [`true`], the list contains tags that are
1276    /// toggled on. If a tag is toggled on at @self, then some non-empty
1277    /// range of characters following @self has that tag applied to it.  If
1278    /// a tag is toggled off, then some non-empty range following @self
1279    /// does not have the tag applied to it.
1280    /// ## `toggled_on`
1281    /// [`true`] to get toggled-on tags
1282    ///
1283    /// # Returns
1284    ///
1285    /// tags
1286    ///   toggled at this point
1287    #[doc(alias = "gtk_text_iter_get_toggled_tags")]
1288    #[doc(alias = "get_toggled_tags")]
1289    pub fn toggled_tags(&self, toggled_on: bool) -> Vec<TextTag> {
1290        unsafe {
1291            FromGlibPtrContainer::from_glib_container(ffi::gtk_text_iter_get_toggled_tags(
1292                self.to_glib_none().0,
1293                toggled_on.into_glib(),
1294            ))
1295        }
1296    }
1297
1298    ///  flag
1299    /// toggled on.
1300    ///
1301    /// # Returns
1302    ///
1303    /// byte index of @self with respect to the start of the line
1304    #[doc(alias = "gtk_text_iter_get_visible_line_index")]
1305    #[doc(alias = "get_visible_line_index")]
1306    pub fn visible_line_index(&self) -> i32 {
1307        unsafe { ffi::gtk_text_iter_get_visible_line_index(self.to_glib_none().0) }
1308    }
1309
1310    ///  flag
1311    /// toggled on.
1312    ///
1313    /// # Returns
1314    ///
1315    /// offset in visible characters from the start of the line
1316    #[doc(alias = "gtk_text_iter_get_visible_line_offset")]
1317    #[doc(alias = "get_visible_line_offset")]
1318    pub fn visible_line_offset(&self) -> i32 {
1319        unsafe { ffi::gtk_text_iter_get_visible_line_offset(self.to_glib_none().0) }
1320    }
1321
1322    ///  attribute turned on has
1323    /// been applied to it.
1324    /// ## `end`
1325    /// iterator at end of range
1326    ///
1327    /// # Returns
1328    ///
1329    /// slice of text from the buffer
1330    #[doc(alias = "gtk_text_iter_get_visible_slice")]
1331    #[doc(alias = "get_visible_slice")]
1332    pub fn visible_slice(&self, end: &TextIter) -> glib::GString {
1333        unsafe {
1334            from_glib_full(ffi::gtk_text_iter_get_visible_slice(
1335                self.to_glib_none().0,
1336                end.to_glib_none().0,
1337            ))
1338        }
1339    }
1340
1341    ///  attribute turned on has
1342    /// been applied to it.
1343    /// ## `end`
1344    /// iterator at end of range
1345    ///
1346    /// # Returns
1347    ///
1348    /// string containing visible text in the
1349    /// range
1350    #[doc(alias = "gtk_text_iter_get_visible_text")]
1351    #[doc(alias = "get_visible_text")]
1352    pub fn visible_text(&self, end: &TextIter) -> glib::GString {
1353        unsafe {
1354            from_glib_full(ffi::gtk_text_iter_get_visible_text(
1355                self.to_glib_none().0,
1356                end.to_glib_none().0,
1357            ))
1358        }
1359    }
1360
1361    /// Returns [`true`] if @self points to a character that is part
1362    /// of a range tagged with @tag.
1363    ///
1364    /// See also [`starts_tag()`][Self::starts_tag()] and
1365    /// [`ends_tag()`][Self::ends_tag()].
1366    /// ## `tag`
1367    /// a [`TextTag`][crate::TextTag]
1368    ///
1369    /// # Returns
1370    ///
1371    /// whether @self is tagged with @tag
1372    #[doc(alias = "gtk_text_iter_has_tag")]
1373    pub fn has_tag(&self, tag: &impl IsA<TextTag>) -> bool {
1374        unsafe {
1375            from_glib(ffi::gtk_text_iter_has_tag(
1376                self.to_glib_none().0,
1377                tag.as_ref().to_glib_none().0,
1378            ))
1379        }
1380    }
1381
1382    /// Checks whether @self falls in the range [@start, @end).
1383    ///
1384    /// @start and @end must be in ascending order.
1385    /// ## `start`
1386    /// start of range
1387    /// ## `end`
1388    /// end of range
1389    ///
1390    /// # Returns
1391    ///
1392    /// [`true`] if @self is in the range
1393    #[doc(alias = "gtk_text_iter_in_range")]
1394    pub fn in_range(&self, start: &TextIter, end: &TextIter) -> bool {
1395        unsafe {
1396            from_glib(ffi::gtk_text_iter_in_range(
1397                self.to_glib_none().0,
1398                start.to_glib_none().0,
1399                end.to_glib_none().0,
1400            ))
1401        }
1402    }
1403
1404    /// Determines whether @self is inside a sentence (as opposed to in
1405    /// between two sentences, e.g. after a period and before the first
1406    /// letter of the next sentence).
1407    ///
1408    /// Sentence boundaries are determined by Pango and should be correct
1409    /// for nearly any language.
1410    ///
1411    /// # Returns
1412    ///
1413    /// [`true`] if @self is inside a sentence.
1414    #[doc(alias = "gtk_text_iter_inside_sentence")]
1415    pub fn inside_sentence(&self) -> bool {
1416        unsafe { from_glib(ffi::gtk_text_iter_inside_sentence(self.to_glib_none().0)) }
1417    }
1418
1419    /// Determines whether the character pointed by @self is part of a
1420    /// natural-language word (as opposed to say inside some whitespace).
1421    ///
1422    /// Word breaks are determined by Pango and should be correct
1423    /// for nearly any language.
1424    ///
1425    /// Note that if [`starts_word()`][Self::starts_word()] returns [`true`],
1426    /// then this function returns [`true`] too, since @self points to
1427    /// the first character of the word.
1428    ///
1429    /// # Returns
1430    ///
1431    /// [`true`] if @self is inside a word
1432    #[doc(alias = "gtk_text_iter_inside_word")]
1433    pub fn inside_word(&self) -> bool {
1434        unsafe { from_glib(ffi::gtk_text_iter_inside_word(self.to_glib_none().0)) }
1435    }
1436
1437    /// Determine if @self is at a cursor position.
1438    ///
1439    /// See [`forward_cursor_position()`][Self::forward_cursor_position()] or
1440    /// `Pango::LogAttr` or `break()` for details
1441    /// on what a cursor position is.
1442    ///
1443    /// # Returns
1444    ///
1445    /// [`true`] if the cursor can be placed at @self
1446    #[doc(alias = "gtk_text_iter_is_cursor_position")]
1447    pub fn is_cursor_position(&self) -> bool {
1448        unsafe { from_glib(ffi::gtk_text_iter_is_cursor_position(self.to_glib_none().0)) }
1449    }
1450
1451    /// Returns [`true`] if @self is the end iterator.
1452    ///
1453    /// This means it is one past the last dereferenceable iterator
1454    /// in the buffer. [`is_end()`][Self::is_end()] is the most efficient
1455    /// way to check whether an iterator is the end iterator.
1456    ///
1457    /// # Returns
1458    ///
1459    /// whether @self is the end iterator
1460    #[doc(alias = "gtk_text_iter_is_end")]
1461    pub fn is_end(&self) -> bool {
1462        unsafe { from_glib(ffi::gtk_text_iter_is_end(self.to_glib_none().0)) }
1463    }
1464
1465    /// Returns [`true`] if @self is the first iterator in the buffer.
1466    ///
1467    /// # Returns
1468    ///
1469    /// whether @self is the first in the buffer
1470    #[doc(alias = "gtk_text_iter_is_start")]
1471    pub fn is_start(&self) -> bool {
1472        unsafe { from_glib(ffi::gtk_text_iter_is_start(self.to_glib_none().0)) }
1473    }
1474
1475    /// s no real reason to
1476    /// call it yourself in those cases. There are some exceptions,
1477    /// such as [`in_range()`][Self::in_range()], that expect a
1478    /// pre-sorted range.
1479    /// ## `second`
1480    /// another [`TextIter`][crate::TextIter]
1481    #[doc(alias = "gtk_text_iter_order")]
1482    pub fn order(&mut self, second: &mut TextIter) {
1483        unsafe {
1484            ffi::gtk_text_iter_order(self.to_glib_none_mut().0, second.to_glib_none_mut().0);
1485        }
1486    }
1487
1488    /// Moves iterator @self to the start of the line @line_number.
1489    ///
1490    /// If @line_number is negative or larger than or equal to the number of lines
1491    /// in the buffer, moves @self to the start of the last line in the buffer.
1492    /// ## `line_number`
1493    /// line number (counted from 0)
1494    #[doc(alias = "gtk_text_iter_set_line")]
1495    pub fn set_line(&mut self, line_number: i32) {
1496        unsafe {
1497            ffi::gtk_text_iter_set_line(self.to_glib_none_mut().0, line_number);
1498        }
1499    }
1500
1501    /// t be in the middle of a UTF-8
1502    /// encoded character.
1503    /// ## `byte_on_line`
1504    /// s current line
1505    #[doc(alias = "gtk_text_iter_set_line_index")]
1506    pub fn set_line_index(&mut self, byte_on_line: i32) {
1507        unsafe {
1508            ffi::gtk_text_iter_set_line_index(self.to_glib_none_mut().0, byte_on_line);
1509        }
1510    }
1511
1512    /// Moves @self within a line, to a new character (not byte) offset.
1513    ///
1514    /// The given character offset must be less than or equal to the number
1515    /// of characters in the line; if equal, @self moves to the start of the
1516    /// next line. See [`set_line_index()`][Self::set_line_index()] if you have a byte
1517    /// index rather than a character offset.
1518    /// ## `char_on_line`
1519    /// s current line
1520    #[doc(alias = "gtk_text_iter_set_line_offset")]
1521    pub fn set_line_offset(&mut self, char_on_line: i32) {
1522        unsafe {
1523            ffi::gtk_text_iter_set_line_offset(self.to_glib_none_mut().0, char_on_line);
1524        }
1525    }
1526
1527    /// Sets @self to point to @char_offset.
1528    ///
1529    /// @char_offset counts from the start
1530    /// of the entire text buffer, starting with 0.
1531    /// ## `char_offset`
1532    /// a character number
1533    #[doc(alias = "gtk_text_iter_set_offset")]
1534    pub fn set_offset(&mut self, char_offset: i32) {
1535        unsafe {
1536            ffi::gtk_text_iter_set_offset(self.to_glib_none_mut().0, char_offset);
1537        }
1538    }
1539
1540    /// Like [`set_line_index()`][Self::set_line_index()], but the index is in visible
1541    /// bytes, i.e. text with a tag making it invisible is not counted
1542    /// in the index.
1543    /// ## `byte_on_line`
1544    /// a byte index
1545    #[doc(alias = "gtk_text_iter_set_visible_line_index")]
1546    pub fn set_visible_line_index(&mut self, byte_on_line: i32) {
1547        unsafe {
1548            ffi::gtk_text_iter_set_visible_line_index(self.to_glib_none_mut().0, byte_on_line);
1549        }
1550    }
1551
1552    /// Like [`set_line_offset()`][Self::set_line_offset()], but the offset is in visible
1553    /// characters, i.e. text with a tag making it invisible is not
1554    /// counted in the offset.
1555    /// ## `char_on_line`
1556    /// a character offset
1557    #[doc(alias = "gtk_text_iter_set_visible_line_offset")]
1558    pub fn set_visible_line_offset(&mut self, char_on_line: i32) {
1559        unsafe {
1560            ffi::gtk_text_iter_set_visible_line_offset(self.to_glib_none_mut().0, char_on_line);
1561        }
1562    }
1563
1564    /// s 0.
1565    ///
1566    /// # Returns
1567    ///
1568    /// whether @self begins a line
1569    #[doc(alias = "gtk_text_iter_starts_line")]
1570    pub fn starts_line(&self) -> bool {
1571        unsafe { from_glib(ffi::gtk_text_iter_starts_line(self.to_glib_none().0)) }
1572    }
1573
1574    /// Determines whether @self begins a sentence.
1575    ///
1576    /// Sentence boundaries are determined by Pango and
1577    /// should be correct for nearly any language.
1578    ///
1579    /// # Returns
1580    ///
1581    /// [`true`] if @self is at the start of a sentence.
1582    #[doc(alias = "gtk_text_iter_starts_sentence")]
1583    pub fn starts_sentence(&self) -> bool {
1584        unsafe { from_glib(ffi::gtk_text_iter_starts_sentence(self.to_glib_none().0)) }
1585    }
1586
1587    /// Returns [`true`] if @tag is toggled on at exactly this point.
1588    ///
1589    /// If @tag is [`None`], returns [`true`] if any tag is toggled on at this point.
1590    ///
1591    /// Note that if this function returns [`true`], it means that
1592    /// @self is at the beginning of the tagged range, and that the
1593    /// character at @self is inside the tagged range. In other
1594    /// words, unlike [`ends_tag()`][Self::ends_tag()], if
1595    /// this function returns [`true`], [`has_tag()`][Self::has_tag()]
1596    /// will also return [`true`] for the same parameters.
1597    /// ## `tag`
1598    /// a [`TextTag`][crate::TextTag]
1599    ///
1600    /// # Returns
1601    ///
1602    /// whether @self is the start of a range tagged with @tag
1603    #[doc(alias = "gtk_text_iter_starts_tag")]
1604    pub fn starts_tag(&self, tag: Option<&impl IsA<TextTag>>) -> bool {
1605        unsafe {
1606            from_glib(ffi::gtk_text_iter_starts_tag(
1607                self.to_glib_none().0,
1608                tag.map(|p| p.as_ref()).to_glib_none().0,
1609            ))
1610        }
1611    }
1612
1613    /// Determines whether @self begins a natural-language word.
1614    ///
1615    /// Word breaks are determined by Pango and should be correct
1616    /// for nearly any language.
1617    ///
1618    /// # Returns
1619    ///
1620    /// [`true`] if @self is at the start of a word
1621    #[doc(alias = "gtk_text_iter_starts_word")]
1622    pub fn starts_word(&self) -> bool {
1623        unsafe { from_glib(ffi::gtk_text_iter_starts_word(self.to_glib_none().0)) }
1624    }
1625
1626    /// Gets whether a range with @tag applied to it begins
1627    /// or ends at @self.
1628    ///
1629    /// This is equivalent to (gtk_text_iter_starts_tag() ||
1630    /// gtk_text_iter_ends_tag())
1631    /// ## `tag`
1632    /// a [`TextTag`][crate::TextTag]
1633    ///
1634    /// # Returns
1635    ///
1636    /// whether @tag is toggled on or off at @self
1637    #[doc(alias = "gtk_text_iter_toggles_tag")]
1638    pub fn toggles_tag(&self, tag: Option<&impl IsA<TextTag>>) -> bool {
1639        unsafe {
1640            from_glib(ffi::gtk_text_iter_toggles_tag(
1641                self.to_glib_none().0,
1642                tag.map(|p| p.as_ref()).to_glib_none().0,
1643            ))
1644        }
1645    }
1646}
1647
1648impl PartialOrd for TextIter {
1649    #[inline]
1650    fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
1651        Some(self.cmp(other))
1652    }
1653}
1654
1655impl Ord for TextIter {
1656    #[inline]
1657    fn cmp(&self, other: &Self) -> std::cmp::Ordering {
1658        self.compare(other).cmp(&0)
1659    }
1660}
1661
1662impl PartialEq for TextIter {
1663    #[inline]
1664    fn eq(&self, other: &Self) -> bool {
1665        self.equal(other)
1666    }
1667}
1668
1669impl Eq for TextIter {}