Skip to main content

atk/auto/
text.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
5#[cfg(feature = "v2_32")]
6#[cfg_attr(docsrs, doc(cfg(feature = "v2_32")))]
7use crate::ScrollType;
8use crate::{CoordType, TextBoundary, TextClipType, TextGranularity, TextRange, TextRectangle};
9use glib::{
10    prelude::*,
11    signal::{connect_raw, SignalHandlerId},
12    translate::*,
13};
14use std::{boxed::Box as Box_, fmt, mem, mem::transmute};
15
16glib::wrapper! {
17    /// The ATK interface implemented by components with text content.
18    ///
19    /// [`Text`][crate::Text] should be implemented by `AtkObjects` on behalf of widgets
20    /// that have text content which is either attributed or otherwise
21    /// non-trivial. `AtkObjects` whose text content is simple,
22    /// unattributed, and very brief may expose that content via
23    /// `atk_object_get_name` instead; however if the text is editable,
24    /// multi-line, typically longer than three or four words, attributed,
25    /// selectable, or if the object already uses the 'name' ATK property
26    /// for other information, the [`Text`][crate::Text] interface should be used to
27    /// expose the text content. In the case of editable text content,
28    /// [`EditableText`][crate::EditableText] (a subtype of the [`Text`][crate::Text] interface) should be
29    /// implemented instead.
30    ///
31    ///  [`Text`][crate::Text] provides not only traversal facilities and change
32    /// notification for text content, but also caret tracking and glyph
33    /// bounding box calculations. Note that the text strings are exposed
34    /// as UTF-8, and are therefore potentially multi-byte, and
35    /// caret-to-byte offset mapping makes no assumptions about the
36    /// character length; also bounding box glyph-to-offset mapping may be
37    /// complex for languages which use ligatures.
38    ///
39    /// ## Signals
40    ///
41    ///
42    /// #### `text-attributes-changed`
43    ///  The "text-attributes-changed" signal is emitted when the text
44    /// attributes of the text of an object which implements AtkText
45    /// changes.
46    ///
47    ///
48    ///
49    ///
50    /// #### `text-caret-moved`
51    ///  The "text-caret-moved" signal is emitted when the caret
52    /// position of the text of an object which implements AtkText
53    /// changes.
54    ///
55    ///
56    ///
57    ///
58    /// #### `text-changed`
59    ///  The "text-changed" signal is emitted when the text of the
60    /// object which implements the AtkText interface changes, This
61    /// signal will have a detail which is either "insert" or
62    /// "delete" which identifies whether the text change was an
63    /// insertion or a deletion.
64    ///
65    /// Detailed
66    ///
67    ///
68    /// #### `text-insert`
69    ///  The "text-insert" signal is emitted when a new text is
70    /// inserted. If the signal was not triggered by the user
71    /// (e.g. typing or pasting text), the "system" detail should be
72    /// included.
73    ///
74    /// Detailed
75    ///
76    ///
77    /// #### `text-remove`
78    ///  The "text-remove" signal is emitted when a new text is
79    /// removed. If the signal was not triggered by the user
80    /// (e.g. typing or pasting text), the "system" detail should be
81    /// included.
82    ///
83    /// Detailed
84    ///
85    ///
86    /// #### `text-selection-changed`
87    ///  The "text-selection-changed" signal is emitted when the
88    /// selected text of an object which implements AtkText changes.
89    ///
90    ///
91    ///
92    /// # Implements
93    ///
94    /// [`TextExt`][trait@crate::prelude::TextExt]
95    #[doc(alias = "AtkText")]
96    pub struct Text(Interface<ffi::AtkText, ffi::AtkTextIface>);
97
98    match fn {
99        type_ => || ffi::atk_text_get_type(),
100    }
101}
102
103impl Text {
104    pub const NONE: Option<&'static Text> = None;
105}
106
107mod sealed {
108    pub trait Sealed {}
109    impl<T: super::IsA<super::Text>> Sealed for T {}
110}
111
112/// Trait containing all [`struct@Text`] methods.
113///
114/// # Implementors
115///
116/// [`NoOpObject`][struct@crate::NoOpObject], [`Text`][struct@crate::Text]
117pub trait TextExt: IsA<Text> + sealed::Sealed + 'static {
118    /// Adds a selection bounded by the specified offsets.
119    /// ## `start_offset`
120    /// the starting character offset of the selected region
121    /// ## `end_offset`
122    /// the offset of the first character after the selected region.
123    ///
124    /// # Returns
125    ///
126    /// [`true`] if successful, [`false`] otherwise
127    #[doc(alias = "atk_text_add_selection")]
128    fn add_selection(&self, start_offset: i32, end_offset: i32) -> bool {
129        unsafe {
130            from_glib(ffi::atk_text_add_selection(
131                self.as_ref().to_glib_none().0,
132                start_offset,
133                end_offset,
134            ))
135        }
136    }
137
138    /// Get the ranges of text in the specified bounding box.
139    /// ## `rect`
140    /// An AtkTextRectangle giving the dimensions of the bounding box.
141    /// ## `coord_type`
142    /// Specify whether coordinates are relative to the screen or widget window.
143    /// ## `x_clip_type`
144    /// Specify the horizontal clip type.
145    /// ## `y_clip_type`
146    /// Specify the vertical clip type.
147    ///
148    /// # Returns
149    ///
150    /// Array of AtkTextRange. The last
151    ///  element of the array returned by this function will be NULL.
152    #[doc(alias = "atk_text_get_bounded_ranges")]
153    #[doc(alias = "get_bounded_ranges")]
154    fn bounded_ranges(
155        &self,
156        rect: &mut TextRectangle,
157        coord_type: CoordType,
158        x_clip_type: TextClipType,
159        y_clip_type: TextClipType,
160    ) -> Vec<TextRange> {
161        unsafe {
162            FromGlibPtrContainer::from_glib_full(ffi::atk_text_get_bounded_ranges(
163                self.as_ref().to_glib_none().0,
164                rect.to_glib_none_mut().0,
165                coord_type.into_glib(),
166                x_clip_type.into_glib(),
167                y_clip_type.into_glib(),
168            ))
169        }
170    }
171
172    /// Gets the offset of the position of the caret (cursor).
173    ///
174    /// # Returns
175    ///
176    /// the character offset of the position of the caret or -1 if
177    ///  the caret is not located inside the element or in the case of
178    ///  any other failure.
179    #[doc(alias = "atk_text_get_caret_offset")]
180    #[doc(alias = "get_caret_offset")]
181    fn caret_offset(&self) -> i32 {
182        unsafe { ffi::atk_text_get_caret_offset(self.as_ref().to_glib_none().0) }
183    }
184
185    /// Gets the specified text.
186    /// ## `offset`
187    /// a character offset within `self`
188    ///
189    /// # Returns
190    ///
191    /// the character at `offset` or 0 in the case of failure.
192    #[doc(alias = "atk_text_get_character_at_offset")]
193    #[doc(alias = "get_character_at_offset")]
194    fn character_at_offset(&self, offset: i32) -> char {
195        unsafe {
196            std::convert::TryFrom::try_from(ffi::atk_text_get_character_at_offset(
197                self.as_ref().to_glib_none().0,
198                offset,
199            ))
200            .expect("conversion from an invalid Unicode value attempted")
201        }
202    }
203
204    /// Gets the character count.
205    ///
206    /// # Returns
207    ///
208    /// the number of characters or -1 in case of failure.
209    #[doc(alias = "atk_text_get_character_count")]
210    #[doc(alias = "get_character_count")]
211    fn character_count(&self) -> i32 {
212        unsafe { ffi::atk_text_get_character_count(self.as_ref().to_glib_none().0) }
213    }
214
215    /// If the extent can not be obtained (e.g. missing support), all of x, y, width,
216    /// height are set to -1.
217    ///
218    /// Get the bounding box containing the glyph representing the character at
219    ///  a particular text offset.
220    /// ## `offset`
221    /// The offset of the text character for which bounding information is required.
222    /// ## `coords`
223    /// specify whether coordinates are relative to the screen or widget window
224    ///
225    /// # Returns
226    ///
227    ///
228    /// ## `x`
229    /// Pointer for the x coordinate of the bounding box
230    ///
231    /// ## `y`
232    /// Pointer for the y coordinate of the bounding box
233    ///
234    /// ## `width`
235    /// Pointer for the width of the bounding box
236    ///
237    /// ## `height`
238    /// Pointer for the height of the bounding box
239    #[doc(alias = "atk_text_get_character_extents")]
240    #[doc(alias = "get_character_extents")]
241    fn character_extents(&self, offset: i32, coords: CoordType) -> (i32, i32, i32, i32) {
242        unsafe {
243            let mut x = mem::MaybeUninit::uninit();
244            let mut y = mem::MaybeUninit::uninit();
245            let mut width = mem::MaybeUninit::uninit();
246            let mut height = mem::MaybeUninit::uninit();
247            ffi::atk_text_get_character_extents(
248                self.as_ref().to_glib_none().0,
249                offset,
250                x.as_mut_ptr(),
251                y.as_mut_ptr(),
252                width.as_mut_ptr(),
253                height.as_mut_ptr(),
254                coords.into_glib(),
255            );
256            (
257                x.assume_init(),
258                y.assume_init(),
259                width.assume_init(),
260                height.assume_init(),
261            )
262        }
263    }
264
265    //#[doc(alias = "atk_text_get_default_attributes")]
266    //#[doc(alias = "get_default_attributes")]
267    //fn default_attributes(&self) -> /*Ignored*/Option<AttributeSet> {
268    //    unsafe { TODO: call ffi:atk_text_get_default_attributes() }
269    //}
270
271    /// Gets the number of selected regions.
272    ///
273    /// # Returns
274    ///
275    /// The number of selected regions, or -1 in the case of failure.
276    #[doc(alias = "atk_text_get_n_selections")]
277    #[doc(alias = "get_n_selections")]
278    fn n_selections(&self) -> i32 {
279        unsafe { ffi::atk_text_get_n_selections(self.as_ref().to_glib_none().0) }
280    }
281
282    /// Gets the offset of the character located at coordinates `x` and `y`. `x` and `y`
283    /// are interpreted as being relative to the screen or this widget's window
284    /// depending on `coords`.
285    /// ## `x`
286    /// screen x-position of character
287    /// ## `y`
288    /// screen y-position of character
289    /// ## `coords`
290    /// specify whether coordinates are relative to the screen or
291    /// widget window
292    ///
293    /// # Returns
294    ///
295    /// the offset to the character which is located at the specified
296    ///  `x` and `y` coordinates of -1 in case of failure.
297    #[doc(alias = "atk_text_get_offset_at_point")]
298    #[doc(alias = "get_offset_at_point")]
299    fn offset_at_point(&self, x: i32, y: i32, coords: CoordType) -> i32 {
300        unsafe {
301            ffi::atk_text_get_offset_at_point(
302                self.as_ref().to_glib_none().0,
303                x,
304                y,
305                coords.into_glib(),
306            )
307        }
308    }
309
310    /// Get the bounding box for text within the specified range.
311    ///
312    /// If the extents can not be obtained (e.g. or missing support), the rectangle
313    /// fields are set to -1.
314    /// ## `start_offset`
315    /// The offset of the first text character for which boundary
316    ///  information is required.
317    /// ## `end_offset`
318    /// The offset of the text character after the last character
319    ///  for which boundary information is required.
320    /// ## `coord_type`
321    /// Specify whether coordinates are relative to the screen or widget window.
322    ///
323    /// # Returns
324    ///
325    ///
326    /// ## `rect`
327    /// A pointer to a AtkTextRectangle which is filled in by this function.
328    #[doc(alias = "atk_text_get_range_extents")]
329    #[doc(alias = "get_range_extents")]
330    fn range_extents(
331        &self,
332        start_offset: i32,
333        end_offset: i32,
334        coord_type: CoordType,
335    ) -> TextRectangle {
336        unsafe {
337            let mut rect = TextRectangle::uninitialized();
338            ffi::atk_text_get_range_extents(
339                self.as_ref().to_glib_none().0,
340                start_offset,
341                end_offset,
342                coord_type.into_glib(),
343                rect.to_glib_none_mut().0,
344            );
345            rect
346        }
347    }
348
349    //#[doc(alias = "atk_text_get_run_attributes")]
350    //#[doc(alias = "get_run_attributes")]
351    //fn run_attributes(&self, offset: i32) -> (/*Ignored*/AttributeSet, i32, i32) {
352    //    unsafe { TODO: call ffi:atk_text_get_run_attributes() }
353    //}
354
355    /// Gets the text from the specified selection.
356    /// ## `selection_num`
357    /// The selection number. The selected regions are
358    /// assigned numbers that correspond to how far the region is from the
359    /// start of the text. The selected region closest to the beginning
360    /// of the text region is assigned the number 0, etc. Note that adding,
361    /// moving or deleting a selected region can change the numbering.
362    ///
363    /// # Returns
364    ///
365    /// a newly allocated string containing the selected text. Use `g_free()`
366    ///  to free the returned string.
367    ///
368    /// ## `start_offset`
369    /// passes back the starting character offset of the selected region
370    ///
371    /// ## `end_offset`
372    /// passes back the ending character offset (offset immediately past)
373    /// of the selected region
374    #[doc(alias = "atk_text_get_selection")]
375    #[doc(alias = "get_selection")]
376    fn selection(&self, selection_num: i32) -> (glib::GString, i32, i32) {
377        unsafe {
378            let mut start_offset = mem::MaybeUninit::uninit();
379            let mut end_offset = mem::MaybeUninit::uninit();
380            let ret = from_glib_full(ffi::atk_text_get_selection(
381                self.as_ref().to_glib_none().0,
382                selection_num,
383                start_offset.as_mut_ptr(),
384                end_offset.as_mut_ptr(),
385            ));
386            (ret, start_offset.assume_init(), end_offset.assume_init())
387        }
388    }
389
390    /// Gets a portion of the text exposed through an [`Text`][crate::Text] according to a given `offset`
391    /// and a specific `granularity`, along with the start and end offsets defining the
392    /// boundaries of such a portion of text.
393    ///
394    /// If `granularity` is ATK_TEXT_GRANULARITY_CHAR the character at the
395    /// offset is returned.
396    ///
397    /// If `granularity` is ATK_TEXT_GRANULARITY_WORD the returned string
398    /// is from the word start at or before the offset to the word start after
399    /// the offset.
400    ///
401    /// The returned string will contain the word at the offset if the offset
402    /// is inside a word and will contain the word before the offset if the
403    /// offset is not inside a word.
404    ///
405    /// If `granularity` is ATK_TEXT_GRANULARITY_SENTENCE the returned string
406    /// is from the sentence start at or before the offset to the sentence
407    /// start after the offset.
408    ///
409    /// The returned string will contain the sentence at the offset if the offset
410    /// is inside a sentence and will contain the sentence before the offset
411    /// if the offset is not inside a sentence.
412    ///
413    /// If `granularity` is ATK_TEXT_GRANULARITY_LINE the returned string
414    /// is from the line start at or before the offset to the line
415    /// start after the offset.
416    ///
417    /// If `granularity` is ATK_TEXT_GRANULARITY_PARAGRAPH the returned string
418    /// is from the start of the paragraph at or before the offset to the start
419    /// of the following paragraph after the offset.
420    /// ## `offset`
421    /// position
422    /// ## `granularity`
423    /// An [`TextGranularity`][crate::TextGranularity]
424    ///
425    /// # Returns
426    ///
427    /// a newly allocated string containing the text at
428    ///  the `offset` bounded by the specified `granularity`. Use `g_free()`
429    ///  to free the returned string. Returns [`None`] if the offset is invalid
430    ///  or no implementation is available.
431    ///
432    /// ## `start_offset`
433    /// the starting character offset of the returned string, or -1
434    ///  in the case of error (e.g. invalid offset, not implemented)
435    ///
436    /// ## `end_offset`
437    /// the offset of the first character after the returned string,
438    ///  or -1 in the case of error (e.g. invalid offset, not implemented)
439    #[doc(alias = "atk_text_get_string_at_offset")]
440    #[doc(alias = "get_string_at_offset")]
441    fn string_at_offset(
442        &self,
443        offset: i32,
444        granularity: TextGranularity,
445    ) -> (Option<glib::GString>, i32, i32) {
446        unsafe {
447            let mut start_offset = mem::MaybeUninit::uninit();
448            let mut end_offset = mem::MaybeUninit::uninit();
449            let ret = from_glib_full(ffi::atk_text_get_string_at_offset(
450                self.as_ref().to_glib_none().0,
451                offset,
452                granularity.into_glib(),
453                start_offset.as_mut_ptr(),
454                end_offset.as_mut_ptr(),
455            ));
456            (ret, start_offset.assume_init(), end_offset.assume_init())
457        }
458    }
459
460    /// Gets the specified text.
461    /// ## `start_offset`
462    /// a starting character offset within `self`
463    /// ## `end_offset`
464    /// an ending character offset within `self`, or -1 for the end of the string.
465    ///
466    /// # Returns
467    ///
468    /// a newly allocated string containing the text from `start_offset` up
469    ///  to, but not including `end_offset`. Use `g_free()` to free the returned
470    ///  string.
471    #[doc(alias = "atk_text_get_text")]
472    #[doc(alias = "get_text")]
473    fn text(&self, start_offset: i32, end_offset: i32) -> Option<glib::GString> {
474        unsafe {
475            from_glib_full(ffi::atk_text_get_text(
476                self.as_ref().to_glib_none().0,
477                start_offset,
478                end_offset,
479            ))
480        }
481    }
482
483    /// Gets the specified text.
484    ///
485    /// If the boundary_type if ATK_TEXT_BOUNDARY_CHAR the character at the
486    /// offset is returned.
487    ///
488    /// If the boundary_type is ATK_TEXT_BOUNDARY_WORD_START the returned string
489    /// is from the word start at or before the offset to the word start after
490    /// the offset.
491    ///
492    /// The returned string will contain the word at the offset if the offset
493    /// is inside a word and will contain the word before the offset if the
494    /// offset is not inside a word.
495    ///
496    /// If the boundary type is ATK_TEXT_BOUNDARY_SENTENCE_START the returned
497    /// string is from the sentence start at or before the offset to the sentence
498    /// start after the offset.
499    ///
500    /// The returned string will contain the sentence at the offset if the offset
501    /// is inside a sentence and will contain the sentence before the offset
502    /// if the offset is not inside a sentence.
503    ///
504    /// If the boundary type is ATK_TEXT_BOUNDARY_LINE_START the returned
505    /// string is from the line start at or before the offset to the line
506    /// start after the offset.
507    ///
508    /// # Deprecated
509    ///
510    /// This method is deprecated since ATK version
511    /// 2.9.4. Please use [`string_at_offset()`][Self::string_at_offset()] instead.
512    /// ## `offset`
513    /// position
514    /// ## `boundary_type`
515    /// An [`TextBoundary`][crate::TextBoundary]
516    ///
517    /// # Returns
518    ///
519    /// a newly allocated string containing the text at `offset` bounded
520    ///  by the specified `boundary_type`. Use `g_free()` to free the returned
521    ///  string.
522    ///
523    /// ## `start_offset`
524    /// the starting character offset of the returned string
525    ///
526    /// ## `end_offset`
527    /// the offset of the first character after the
528    ///  returned substring
529    #[doc(alias = "atk_text_get_text_at_offset")]
530    #[doc(alias = "get_text_at_offset")]
531    fn text_at_offset(
532        &self,
533        offset: i32,
534        boundary_type: TextBoundary,
535    ) -> (glib::GString, i32, i32) {
536        unsafe {
537            let mut start_offset = mem::MaybeUninit::uninit();
538            let mut end_offset = mem::MaybeUninit::uninit();
539            let ret = from_glib_full(ffi::atk_text_get_text_at_offset(
540                self.as_ref().to_glib_none().0,
541                offset,
542                boundary_type.into_glib(),
543                start_offset.as_mut_ptr(),
544                end_offset.as_mut_ptr(),
545            ));
546            (ret, start_offset.assume_init(), end_offset.assume_init())
547        }
548    }
549
550    /// Removes the specified selection.
551    /// ## `selection_num`
552    /// The selection number. The selected regions are
553    /// assigned numbers that correspond to how far the region is from the
554    /// start of the text. The selected region closest to the beginning
555    /// of the text region is assigned the number 0, etc. Note that adding,
556    /// moving or deleting a selected region can change the numbering.
557    ///
558    /// # Returns
559    ///
560    /// [`true`] if successful, [`false`] otherwise
561    #[doc(alias = "atk_text_remove_selection")]
562    fn remove_selection(&self, selection_num: i32) -> bool {
563        unsafe {
564            from_glib(ffi::atk_text_remove_selection(
565                self.as_ref().to_glib_none().0,
566                selection_num,
567            ))
568        }
569    }
570
571    /// Makes a substring of `self` visible on the screen by scrolling all necessary parents.
572    /// ## `start_offset`
573    /// start offset in the `self`
574    /// ## `end_offset`
575    /// end offset in the `self`, or -1 for the end of the text.
576    /// ## `type_`
577    /// specify where the object should be made visible.
578    ///
579    /// # Returns
580    ///
581    /// whether scrolling was successful.
582    #[cfg(feature = "v2_32")]
583    #[cfg_attr(docsrs, doc(cfg(feature = "v2_32")))]
584    #[doc(alias = "atk_text_scroll_substring_to")]
585    fn scroll_substring_to(&self, start_offset: i32, end_offset: i32, type_: ScrollType) -> bool {
586        unsafe {
587            from_glib(ffi::atk_text_scroll_substring_to(
588                self.as_ref().to_glib_none().0,
589                start_offset,
590                end_offset,
591                type_.into_glib(),
592            ))
593        }
594    }
595
596    /// Move the top-left of a substring of `self` to a given position of the screen
597    /// by scrolling all necessary parents.
598    /// ## `start_offset`
599    /// start offset in the `self`
600    /// ## `end_offset`
601    /// end offset in the `self`, or -1 for the end of the text.
602    /// ## `coords`
603    /// specify whether coordinates are relative to the screen or to the
604    /// parent object.
605    /// ## `x`
606    /// x-position where to scroll to
607    /// ## `y`
608    /// y-position where to scroll to
609    ///
610    /// # Returns
611    ///
612    /// whether scrolling was successful.
613    #[cfg(feature = "v2_32")]
614    #[cfg_attr(docsrs, doc(cfg(feature = "v2_32")))]
615    #[doc(alias = "atk_text_scroll_substring_to_point")]
616    fn scroll_substring_to_point(
617        &self,
618        start_offset: i32,
619        end_offset: i32,
620        coords: CoordType,
621        x: i32,
622        y: i32,
623    ) -> bool {
624        unsafe {
625            from_glib(ffi::atk_text_scroll_substring_to_point(
626                self.as_ref().to_glib_none().0,
627                start_offset,
628                end_offset,
629                coords.into_glib(),
630                x,
631                y,
632            ))
633        }
634    }
635
636    /// Sets the caret (cursor) position to the specified `offset`.
637    ///
638    /// In the case of rich-text content, this method should either grab focus
639    /// or move the sequential focus navigation starting point (if the application
640    /// supports this concept) as if the user had clicked on the new caret position.
641    /// Typically, this means that the target of this operation is the node containing
642    /// the new caret position or one of its ancestors. In other words, after this
643    /// method is called, if the user advances focus, it should move to the first
644    /// focusable node following the new caret position.
645    ///
646    /// Calling this method should also scroll the application viewport in a way
647    /// that matches the behavior of the application's typical caret motion or tab
648    /// navigation as closely as possible. This also means that if the application's
649    /// caret motion or focus navigation does not trigger a scroll operation, this
650    /// method should not trigger one either. If the application does not have a caret
651    /// motion or focus navigation operation, this method should try to scroll the new
652    /// caret position into view while minimizing unnecessary scroll motion.
653    /// ## `offset`
654    /// the character offset of the new caret position
655    ///
656    /// # Returns
657    ///
658    /// [`true`] if successful, [`false`] otherwise.
659    #[doc(alias = "atk_text_set_caret_offset")]
660    fn set_caret_offset(&self, offset: i32) -> bool {
661        unsafe {
662            from_glib(ffi::atk_text_set_caret_offset(
663                self.as_ref().to_glib_none().0,
664                offset,
665            ))
666        }
667    }
668
669    /// Changes the start and end offset of the specified selection.
670    /// ## `selection_num`
671    /// The selection number. The selected regions are
672    /// assigned numbers that correspond to how far the region is from the
673    /// start of the text. The selected region closest to the beginning
674    /// of the text region is assigned the number 0, etc. Note that adding,
675    /// moving or deleting a selected region can change the numbering.
676    /// ## `start_offset`
677    /// the new starting character offset of the selection
678    /// ## `end_offset`
679    /// the new end position of (e.g. offset immediately past)
680    /// the selection
681    ///
682    /// # Returns
683    ///
684    /// [`true`] if successful, [`false`] otherwise
685    #[doc(alias = "atk_text_set_selection")]
686    fn set_selection(&self, selection_num: i32, start_offset: i32, end_offset: i32) -> bool {
687        unsafe {
688            from_glib(ffi::atk_text_set_selection(
689                self.as_ref().to_glib_none().0,
690                selection_num,
691                start_offset,
692                end_offset,
693            ))
694        }
695    }
696
697    /// The "text-attributes-changed" signal is emitted when the text
698    /// attributes of the text of an object which implements AtkText
699    /// changes.
700    #[doc(alias = "text-attributes-changed")]
701    fn connect_text_attributes_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
702        unsafe extern "C" fn text_attributes_changed_trampoline<
703            P: IsA<Text>,
704            F: Fn(&P) + 'static,
705        >(
706            this: *mut ffi::AtkText,
707            f: glib::ffi::gpointer,
708        ) {
709            let f: &F = &*(f as *const F);
710            f(Text::from_glib_borrow(this).unsafe_cast_ref())
711        }
712        unsafe {
713            let f: Box_<F> = Box_::new(f);
714            connect_raw(
715                self.as_ptr() as *mut _,
716                b"text-attributes-changed\0".as_ptr() as *const _,
717                Some(transmute::<_, unsafe extern "C" fn()>(
718                    text_attributes_changed_trampoline::<Self, F> as *const (),
719                )),
720                Box_::into_raw(f),
721            )
722        }
723    }
724
725    /// The "text-caret-moved" signal is emitted when the caret
726    /// position of the text of an object which implements AtkText
727    /// changes.
728    /// ## `arg1`
729    /// The new position of the text caret.
730    #[doc(alias = "text-caret-moved")]
731    fn connect_text_caret_moved<F: Fn(&Self, i32) + 'static>(&self, f: F) -> SignalHandlerId {
732        unsafe extern "C" fn text_caret_moved_trampoline<P: IsA<Text>, F: Fn(&P, i32) + 'static>(
733            this: *mut ffi::AtkText,
734            arg1: libc::c_int,
735            f: glib::ffi::gpointer,
736        ) {
737            let f: &F = &*(f as *const F);
738            f(Text::from_glib_borrow(this).unsafe_cast_ref(), arg1)
739        }
740        unsafe {
741            let f: Box_<F> = Box_::new(f);
742            connect_raw(
743                self.as_ptr() as *mut _,
744                b"text-caret-moved\0".as_ptr() as *const _,
745                Some(transmute::<_, unsafe extern "C" fn()>(
746                    text_caret_moved_trampoline::<Self, F> as *const (),
747                )),
748                Box_::into_raw(f),
749            )
750        }
751    }
752
753    /// The "text-insert" signal is emitted when a new text is
754    /// inserted. If the signal was not triggered by the user
755    /// (e.g. typing or pasting text), the "system" detail should be
756    /// included.
757    /// ## `arg1`
758    /// The position (character offset) of the insertion.
759    /// ## `arg2`
760    /// The length (in characters) of text inserted.
761    /// ## `arg3`
762    /// The new text inserted
763    #[doc(alias = "text-insert")]
764    fn connect_text_insert<F: Fn(&Self, i32, i32, &str) + 'static>(
765        &self,
766        detail: Option<&str>,
767        f: F,
768    ) -> SignalHandlerId {
769        unsafe extern "C" fn text_insert_trampoline<
770            P: IsA<Text>,
771            F: Fn(&P, i32, i32, &str) + 'static,
772        >(
773            this: *mut ffi::AtkText,
774            arg1: libc::c_int,
775            arg2: libc::c_int,
776            arg3: *mut libc::c_char,
777            f: glib::ffi::gpointer,
778        ) {
779            let f: &F = &*(f as *const F);
780            f(
781                Text::from_glib_borrow(this).unsafe_cast_ref(),
782                arg1,
783                arg2,
784                &glib::GString::from_glib_borrow(arg3),
785            )
786        }
787        unsafe {
788            let f: Box_<F> = Box_::new(f);
789            let detailed_signal_name = detail.map(|name| format!("text-insert::{name}\0"));
790            let signal_name: &[u8] = detailed_signal_name
791                .as_ref()
792                .map_or(&b"text-insert\0"[..], |n| n.as_bytes());
793            connect_raw(
794                self.as_ptr() as *mut _,
795                signal_name.as_ptr() as *const _,
796                Some(transmute::<_, unsafe extern "C" fn()>(
797                    text_insert_trampoline::<Self, F> as *const (),
798                )),
799                Box_::into_raw(f),
800            )
801        }
802    }
803
804    /// The "text-remove" signal is emitted when a new text is
805    /// removed. If the signal was not triggered by the user
806    /// (e.g. typing or pasting text), the "system" detail should be
807    /// included.
808    /// ## `arg1`
809    /// The position (character offset) of the removal.
810    /// ## `arg2`
811    /// The length (in characters) of text removed.
812    /// ## `arg3`
813    /// The old text removed
814    #[doc(alias = "text-remove")]
815    fn connect_text_remove<F: Fn(&Self, i32, i32, &str) + 'static>(
816        &self,
817        detail: Option<&str>,
818        f: F,
819    ) -> SignalHandlerId {
820        unsafe extern "C" fn text_remove_trampoline<
821            P: IsA<Text>,
822            F: Fn(&P, i32, i32, &str) + 'static,
823        >(
824            this: *mut ffi::AtkText,
825            arg1: libc::c_int,
826            arg2: libc::c_int,
827            arg3: *mut libc::c_char,
828            f: glib::ffi::gpointer,
829        ) {
830            let f: &F = &*(f as *const F);
831            f(
832                Text::from_glib_borrow(this).unsafe_cast_ref(),
833                arg1,
834                arg2,
835                &glib::GString::from_glib_borrow(arg3),
836            )
837        }
838        unsafe {
839            let f: Box_<F> = Box_::new(f);
840            let detailed_signal_name = detail.map(|name| format!("text-remove::{name}\0"));
841            let signal_name: &[u8] = detailed_signal_name
842                .as_ref()
843                .map_or(&b"text-remove\0"[..], |n| n.as_bytes());
844            connect_raw(
845                self.as_ptr() as *mut _,
846                signal_name.as_ptr() as *const _,
847                Some(transmute::<_, unsafe extern "C" fn()>(
848                    text_remove_trampoline::<Self, F> as *const (),
849                )),
850                Box_::into_raw(f),
851            )
852        }
853    }
854
855    /// The "text-selection-changed" signal is emitted when the
856    /// selected text of an object which implements AtkText changes.
857    #[doc(alias = "text-selection-changed")]
858    fn connect_text_selection_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
859        unsafe extern "C" fn text_selection_changed_trampoline<
860            P: IsA<Text>,
861            F: Fn(&P) + 'static,
862        >(
863            this: *mut ffi::AtkText,
864            f: glib::ffi::gpointer,
865        ) {
866            let f: &F = &*(f as *const F);
867            f(Text::from_glib_borrow(this).unsafe_cast_ref())
868        }
869        unsafe {
870            let f: Box_<F> = Box_::new(f);
871            connect_raw(
872                self.as_ptr() as *mut _,
873                b"text-selection-changed\0".as_ptr() as *const _,
874                Some(transmute::<_, unsafe extern "C" fn()>(
875                    text_selection_changed_trampoline::<Self, F> as *const (),
876                )),
877                Box_::into_raw(f),
878            )
879        }
880    }
881}
882
883impl<O: IsA<Text>> TextExt for O {}
884
885impl fmt::Display for Text {
886    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
887        f.write_str("Text")
888    }
889}