gtk4/auto/
text_buffer.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::{ffi, TextChildAnchor, TextIter, TextMark, TextTag, TextTagTable};
6use glib::{
7    object::ObjectType as _,
8    prelude::*,
9    signal::{connect_raw, SignalHandlerId},
10    translate::*,
11};
12use std::boxed::Box as Box_;
13
14glib::wrapper! {
15    /// Stores text and attributes for display in a [`TextView`][crate::TextView].
16    ///
17    /// You may wish to begin by reading the
18    /// [text widget conceptual overview](section-text-widget.html),
19    /// which gives an overview of all the objects and data types
20    /// related to the text widget and how they work together.
21    ///
22    /// GtkTextBuffer can support undoing changes to the buffer
23    /// content, see [`TextBufferExt::set_enable_undo()`][crate::prelude::TextBufferExt::set_enable_undo()].
24    ///
25    /// ## Properties
26    ///
27    ///
28    /// #### `can-redo`
29    ///  Denotes that the buffer can reapply the last undone action.
30    ///
31    /// Readable
32    ///
33    ///
34    /// #### `can-undo`
35    ///  Denotes that the buffer can undo the last applied action.
36    ///
37    /// Readable
38    ///
39    ///
40    /// #### `cursor-position`
41    ///  The position of the insert mark.
42    ///
43    /// This is an offset from the beginning of the buffer.
44    /// It is useful for getting notified when the cursor moves.
45    ///
46    /// Readable
47    ///
48    ///
49    /// #### `enable-undo`
50    ///  Denotes if support for undoing and redoing changes to the buffer is allowed.
51    ///
52    /// Readable | Writeable
53    ///
54    ///
55    /// #### `has-selection`
56    ///  Whether the buffer has some text currently selected.
57    ///
58    /// Readable
59    ///
60    ///
61    /// #### `tag-table`
62    ///  The GtkTextTagTable for the buffer.
63    ///
64    /// Readable | Writeable | Construct Only
65    ///
66    ///
67    /// #### `text`
68    ///  The text content of the buffer.
69    ///
70    /// Without child widgets and images,
71    /// see [`TextBufferExt::text()`][crate::prelude::TextBufferExt::text()] for more information.
72    ///
73    /// Readable | Writeable
74    ///
75    /// ## Signals
76    ///
77    ///
78    /// #### `apply-tag`
79    ///  Emitted to apply a tag to a range of text in a [`TextBuffer`][crate::TextBuffer].
80    ///
81    /// Applying actually occurs in the default handler.
82    ///
83    /// Note that if your handler runs before the default handler
84    /// it must not invalidate the @start and @end iters (or has to
85    /// revalidate them).
86    ///
87    /// See also:
88    /// [`TextBufferExt::apply_tag()`][crate::prelude::TextBufferExt::apply_tag()],
89    /// [`TextBufferExtManual::insert_with_tags()`][crate::prelude::TextBufferExtManual::insert_with_tags()],
90    /// [`TextBufferExt::insert_range()`][crate::prelude::TextBufferExt::insert_range()].
91    ///
92    ///
93    ///
94    ///
95    /// #### `begin-user-action`
96    ///  Emitted at the beginning of a single user-visible
97    /// operation on a [`TextBuffer`][crate::TextBuffer].
98    ///
99    /// See also:
100    /// [`TextBufferExt::begin_user_action()`][crate::prelude::TextBufferExt::begin_user_action()],
101    /// [`TextBufferExt::insert_interactive()`][crate::prelude::TextBufferExt::insert_interactive()],
102    /// [`TextBufferExt::insert_range_interactive()`][crate::prelude::TextBufferExt::insert_range_interactive()],
103    /// [`TextBufferExt::delete_interactive()`][crate::prelude::TextBufferExt::delete_interactive()],
104    /// [`TextBufferExt::backspace()`][crate::prelude::TextBufferExt::backspace()],
105    /// [`TextBufferExt::delete_selection()`][crate::prelude::TextBufferExt::delete_selection()].
106    ///
107    ///
108    ///
109    ///
110    /// #### `changed`
111    ///  Emitted when the content of a [`TextBuffer`][crate::TextBuffer] has changed.
112    ///
113    ///
114    ///
115    ///
116    /// #### `delete-range`
117    ///  Emitted to delete a range from a [`TextBuffer`][crate::TextBuffer].
118    ///
119    /// Note that if your handler runs before the default handler
120    /// it must not invalidate the @start and @end iters (or has
121    /// to revalidate them). The default signal handler revalidates
122    /// the @start and @end iters to both point to the location
123    /// where text was deleted. Handlers which run after the default
124    /// handler (see g_signal_connect_after()) do not have access to
125    /// the deleted text.
126    ///
127    /// See also: [`TextBufferExt::delete()`][crate::prelude::TextBufferExt::delete()].
128    ///
129    ///
130    ///
131    ///
132    /// #### `end-user-action`
133    ///  Emitted at the end of a single user-visible
134    /// operation on the [`TextBuffer`][crate::TextBuffer].
135    ///
136    /// See also:
137    /// [`TextBufferExt::end_user_action()`][crate::prelude::TextBufferExt::end_user_action()],
138    /// [`TextBufferExt::insert_interactive()`][crate::prelude::TextBufferExt::insert_interactive()],
139    /// [`TextBufferExt::insert_range_interactive()`][crate::prelude::TextBufferExt::insert_range_interactive()],
140    /// [`TextBufferExt::delete_interactive()`][crate::prelude::TextBufferExt::delete_interactive()],
141    /// [`TextBufferExt::backspace()`][crate::prelude::TextBufferExt::backspace()],
142    /// [`TextBufferExt::delete_selection()`][crate::prelude::TextBufferExt::delete_selection()],
143    /// [`TextBufferExt::backspace()`][crate::prelude::TextBufferExt::backspace()].
144    ///
145    ///
146    ///
147    ///
148    /// #### `insert-child-anchor`
149    ///  Emitted to insert a [`TextChildAnchor`][crate::TextChildAnchor] in a [`TextBuffer`][crate::TextBuffer].
150    ///
151    /// Insertion actually occurs in the default handler.
152    ///
153    /// Note that if your handler runs before the default handler
154    /// it must not invalidate the @location iter (or has to
155    /// revalidate it). The default signal handler revalidates
156    /// it to be placed after the inserted @anchor.
157    ///
158    /// See also: [`TextBufferExt::insert_child_anchor()`][crate::prelude::TextBufferExt::insert_child_anchor()].
159    ///
160    ///
161    ///
162    ///
163    /// #### `insert-paintable`
164    ///  Emitted to insert a [`gdk::Paintable`][crate::gdk::Paintable] in a [`TextBuffer`][crate::TextBuffer].
165    ///
166    /// Insertion actually occurs in the default handler.
167    ///
168    /// Note that if your handler runs before the default handler
169    /// it must not invalidate the @location iter (or has to
170    /// revalidate it). The default signal handler revalidates
171    /// it to be placed after the inserted @paintable.
172    ///
173    /// See also: [`TextBufferExt::insert_paintable()`][crate::prelude::TextBufferExt::insert_paintable()].
174    ///
175    ///
176    ///
177    ///
178    /// #### `insert-text`
179    ///  Emitted to insert text in a [`TextBuffer`][crate::TextBuffer].
180    ///
181    /// Insertion actually occurs in the default handler.
182    ///
183    /// Note that if your handler runs before the default handler
184    /// it must not invalidate the @location iter (or has to
185    /// revalidate it). The default signal handler revalidates
186    /// it to point to the end of the inserted text.
187    ///
188    /// See also: [`TextBufferExt::insert()`][crate::prelude::TextBufferExt::insert()],
189    /// [`TextBufferExt::insert_range()`][crate::prelude::TextBufferExt::insert_range()].
190    ///
191    ///
192    ///
193    ///
194    /// #### `mark-deleted`
195    ///  Emitted as notification after a [`TextMark`][crate::TextMark] is deleted.
196    ///
197    /// See also: [`TextBufferExt::delete_mark()`][crate::prelude::TextBufferExt::delete_mark()].
198    ///
199    ///
200    ///
201    ///
202    /// #### `mark-set`
203    ///  Emitted as notification after a [`TextMark`][crate::TextMark] is set.
204    ///
205    /// See also:
206    /// [`TextBufferExt::create_mark()`][crate::prelude::TextBufferExt::create_mark()],
207    /// [`TextBufferExt::move_mark()`][crate::prelude::TextBufferExt::move_mark()].
208    ///
209    ///
210    ///
211    ///
212    /// #### `modified-changed`
213    ///  Emitted when the modified bit of a [`TextBuffer`][crate::TextBuffer] flips.
214    ///
215    /// See also: [`TextBufferExt::set_modified()`][crate::prelude::TextBufferExt::set_modified()].
216    ///
217    ///
218    ///
219    ///
220    /// #### `paste-done`
221    ///  Emitted after paste operation has been completed.
222    ///
223    /// This is useful to properly scroll the view to the end
224    /// of the pasted text. See [`TextBufferExt::paste_clipboard()`][crate::prelude::TextBufferExt::paste_clipboard()]
225    /// for more details.
226    ///
227    ///
228    ///
229    ///
230    /// #### `redo`
231    ///  Emitted when a request has been made to redo the
232    /// previously undone operation.
233    ///
234    ///
235    ///
236    ///
237    /// #### `remove-tag`
238    ///  Emitted to remove all occurrences of @tag from a range
239    /// of text in a [`TextBuffer`][crate::TextBuffer].
240    ///
241    /// Removal actually occurs in the default handler.
242    ///
243    /// Note that if your handler runs before the default handler
244    /// it must not invalidate the @start and @end iters (or has
245    /// to revalidate them).
246    ///
247    /// See also: [`TextBufferExt::remove_tag()`][crate::prelude::TextBufferExt::remove_tag()].
248    ///
249    ///
250    ///
251    ///
252    /// #### `undo`
253    ///  Emitted when a request has been made to undo the
254    /// previous operation or set of operations that have
255    /// been grouped together.
256    ///
257    ///
258    ///
259    /// # Implements
260    ///
261    /// [`TextBufferExt`][trait@crate::prelude::TextBufferExt], [`trait@glib::ObjectExt`], [`TextBufferExtManual`][trait@crate::prelude::TextBufferExtManual]
262    #[doc(alias = "GtkTextBuffer")]
263    pub struct TextBuffer(Object<ffi::GtkTextBuffer, ffi::GtkTextBufferClass>);
264
265    match fn {
266        type_ => || ffi::gtk_text_buffer_get_type(),
267    }
268}
269
270impl TextBuffer {
271    pub const NONE: Option<&'static TextBuffer> = None;
272
273    /// Creates a new text buffer.
274    /// ## `table`
275    /// a tag table, or [`None`] to create a new one
276    ///
277    /// # Returns
278    ///
279    /// a new text buffer
280    #[doc(alias = "gtk_text_buffer_new")]
281    pub fn new(table: Option<&TextTagTable>) -> TextBuffer {
282        assert_initialized_main_thread!();
283        unsafe { from_glib_full(ffi::gtk_text_buffer_new(table.to_glib_none().0)) }
284    }
285
286    // rustdoc-stripper-ignore-next
287    /// Creates a new builder-pattern struct instance to construct [`TextBuffer`] objects.
288    ///
289    /// This method returns an instance of [`TextBufferBuilder`](crate::builders::TextBufferBuilder) which can be used to create [`TextBuffer`] objects.
290    pub fn builder() -> TextBufferBuilder {
291        TextBufferBuilder::new()
292    }
293}
294
295impl Default for TextBuffer {
296    fn default() -> Self {
297        glib::object::Object::new::<Self>()
298    }
299}
300
301// rustdoc-stripper-ignore-next
302/// A [builder-pattern] type to construct [`TextBuffer`] objects.
303///
304/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
305#[must_use = "The builder must be built to be used"]
306pub struct TextBufferBuilder {
307    builder: glib::object::ObjectBuilder<'static, TextBuffer>,
308}
309
310impl TextBufferBuilder {
311    fn new() -> Self {
312        Self {
313            builder: glib::object::Object::builder(),
314        }
315    }
316
317    /// Denotes if support for undoing and redoing changes to the buffer is allowed.
318    pub fn enable_undo(self, enable_undo: bool) -> Self {
319        Self {
320            builder: self.builder.property("enable-undo", enable_undo),
321        }
322    }
323
324    /// The GtkTextTagTable for the buffer.
325    pub fn tag_table(self, tag_table: &TextTagTable) -> Self {
326        Self {
327            builder: self.builder.property("tag-table", tag_table.clone()),
328        }
329    }
330
331    /// The text content of the buffer.
332    ///
333    /// Without child widgets and images,
334    /// see [`TextBufferExt::text()`][crate::prelude::TextBufferExt::text()] for more information.
335    pub fn text(self, text: impl Into<glib::GString>) -> Self {
336        Self {
337            builder: self.builder.property("text", text.into()),
338        }
339    }
340
341    // rustdoc-stripper-ignore-next
342    /// Build the [`TextBuffer`].
343    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
344    pub fn build(self) -> TextBuffer {
345        assert_initialized_main_thread!();
346        self.builder.build()
347    }
348}
349
350mod sealed {
351    pub trait Sealed {}
352    impl<T: super::IsA<super::TextBuffer>> Sealed for T {}
353}
354
355/// Trait containing all [`struct@TextBuffer`] methods.
356///
357/// # Implementors
358///
359/// [`TextBuffer`][struct@crate::TextBuffer]
360pub trait TextBufferExt: IsA<TextBuffer> + sealed::Sealed + 'static {
361    /// Adds the mark at position @where_.
362    ///
363    /// The mark must not be added to another buffer, and if its name
364    /// is not [`None`] then there must not be another mark in the buffer
365    /// with the same name.
366    ///
367    /// Emits the [`mark-set`][struct@crate::TextBuffer#mark-set] signal as notification
368    /// of the mark's initial placement.
369    /// ## `mark`
370    /// the mark to add
371    /// ## `where_`
372    /// location to place mark
373    #[doc(alias = "gtk_text_buffer_add_mark")]
374    fn add_mark(&self, mark: &impl IsA<TextMark>, where_: &TextIter) {
375        unsafe {
376            ffi::gtk_text_buffer_add_mark(
377                self.as_ref().to_glib_none().0,
378                mark.as_ref().to_glib_none().0,
379                where_.to_glib_none().0,
380            );
381        }
382    }
383
384    /// Adds @clipboard to the list of clipboards in which the selection
385    /// contents of @self are available.
386    ///
387    /// In most cases, @clipboard will be the [`gdk::Clipboard`][crate::gdk::Clipboard] returned by
388    /// [`WidgetExt::primary_clipboard()`][crate::prelude::WidgetExt::primary_clipboard()] for a view of @self.
389    /// ## `clipboard`
390    /// a [`gdk::Clipboard`][crate::gdk::Clipboard]
391    #[doc(alias = "gtk_text_buffer_add_selection_clipboard")]
392    fn add_selection_clipboard(&self, clipboard: &gdk::Clipboard) {
393        unsafe {
394            ffi::gtk_text_buffer_add_selection_clipboard(
395                self.as_ref().to_glib_none().0,
396                clipboard.to_glib_none().0,
397            );
398        }
399    }
400
401    /// Emits the “apply-tag” signal on @self.
402    ///
403    /// The default handler for the signal applies
404    /// @tag to the given range. @start and @end do
405    /// not have to be in order.
406    /// ## `tag`
407    /// a [`TextTag`][crate::TextTag]
408    /// ## `start`
409    /// one bound of range to be tagged
410    /// ## `end`
411    /// other bound of range to be tagged
412    #[doc(alias = "gtk_text_buffer_apply_tag")]
413    fn apply_tag(&self, tag: &impl IsA<TextTag>, start: &TextIter, end: &TextIter) {
414        unsafe {
415            ffi::gtk_text_buffer_apply_tag(
416                self.as_ref().to_glib_none().0,
417                tag.as_ref().to_glib_none().0,
418                start.to_glib_none().0,
419                end.to_glib_none().0,
420            );
421        }
422    }
423
424    /// Emits the “apply-tag” signal on @self.
425    ///
426    /// Calls [`TextTagTable::lookup()`][crate::TextTagTable::lookup()] on the buffer’s
427    /// tag table to get a [`TextTag`][crate::TextTag], then calls
428    /// [`apply_tag()`][Self::apply_tag()].
429    /// ## `name`
430    /// name of a named [`TextTag`][crate::TextTag]
431    /// ## `start`
432    /// one bound of range to be tagged
433    /// ## `end`
434    /// other bound of range to be tagged
435    #[doc(alias = "gtk_text_buffer_apply_tag_by_name")]
436    fn apply_tag_by_name(&self, name: &str, start: &TextIter, end: &TextIter) {
437        unsafe {
438            ffi::gtk_text_buffer_apply_tag_by_name(
439                self.as_ref().to_glib_none().0,
440                name.to_glib_none().0,
441                start.to_glib_none().0,
442                end.to_glib_none().0,
443            );
444        }
445    }
446
447    /// Performs the appropriate action as if the user hit the delete
448    /// key with the cursor at the position specified by @iter.
449    ///
450    /// In the normal case a single character will be deleted, but when
451    /// combining accents are involved, more than one character can
452    /// be deleted, and when precomposed character and accent combinations
453    /// are involved, less than one character will be deleted.
454    ///
455    /// Because the buffer is modified, all outstanding iterators become
456    /// invalid after calling this function; however, the @iter will be
457    /// re-initialized to point to the location where text was deleted.
458    /// ## `iter`
459    /// a position in @self
460    /// ## `interactive`
461    /// whether the deletion is caused by user interaction
462    /// ## `default_editable`
463    /// whether the buffer is editable by default
464    ///
465    /// # Returns
466    ///
467    /// [`true`] if the buffer was modified
468    #[doc(alias = "gtk_text_buffer_backspace")]
469    fn backspace(&self, iter: &mut TextIter, interactive: bool, default_editable: bool) -> bool {
470        unsafe {
471            from_glib(ffi::gtk_text_buffer_backspace(
472                self.as_ref().to_glib_none().0,
473                iter.to_glib_none_mut().0,
474                interactive.into_glib(),
475                default_editable.into_glib(),
476            ))
477        }
478    }
479
480    /// Denotes the beginning of an action that may not be undone.
481    ///
482    /// This will cause any previous operations in the undo/redo queue
483    /// to be cleared.
484    ///
485    /// This should be paired with a call to
486    /// [`end_irreversible_action()`][Self::end_irreversible_action()] after the irreversible
487    /// action has completed.
488    ///
489    /// You may nest calls to gtk_text_buffer_begin_irreversible_action()
490    /// and gtk_text_buffer_end_irreversible_action() pairs.
491    #[doc(alias = "gtk_text_buffer_begin_irreversible_action")]
492    fn begin_irreversible_action(&self) {
493        unsafe {
494            ffi::gtk_text_buffer_begin_irreversible_action(self.as_ref().to_glib_none().0);
495        }
496    }
497
498    /// Called to indicate that the buffer operations between here and a
499    /// call to gtk_text_buffer_end_user_action() are part of a single
500    /// user-visible operation.
501    ///
502    /// The operations between gtk_text_buffer_begin_user_action() and
503    /// gtk_text_buffer_end_user_action() can then be grouped when creating
504    /// an undo stack. [`TextBuffer`][crate::TextBuffer] maintains a count of calls to
505    /// gtk_text_buffer_begin_user_action() that have not been closed with
506    /// a call to gtk_text_buffer_end_user_action(), and emits the
507    /// “begin-user-action” and “end-user-action” signals only for the
508    /// outermost pair of calls. This allows you to build user actions
509    /// from other user actions.
510    ///
511    /// The “interactive” buffer mutation functions, such as
512    /// [`insert_interactive()`][Self::insert_interactive()], automatically call
513    /// begin/end user action around the buffer operations they perform,
514    /// so there's no need to add extra calls if you user action consists
515    /// solely of a single call to one of those functions.
516    #[doc(alias = "gtk_text_buffer_begin_user_action")]
517    fn begin_user_action(&self) {
518        unsafe {
519            ffi::gtk_text_buffer_begin_user_action(self.as_ref().to_glib_none().0);
520        }
521    }
522
523    /// Copies the currently-selected text to a clipboard.
524    /// ## `clipboard`
525    /// the [`gdk::Clipboard`][crate::gdk::Clipboard] object to copy to
526    #[doc(alias = "gtk_text_buffer_copy_clipboard")]
527    fn copy_clipboard(&self, clipboard: &gdk::Clipboard) {
528        unsafe {
529            ffi::gtk_text_buffer_copy_clipboard(
530                self.as_ref().to_glib_none().0,
531                clipboard.to_glib_none().0,
532            );
533        }
534    }
535
536    /// Creates and inserts a child anchor.
537    ///
538    /// This is a convenience function which simply creates a child anchor
539    /// with [`TextChildAnchor::new()`][crate::TextChildAnchor::new()] and inserts it into the buffer
540    /// with [`insert_child_anchor()`][Self::insert_child_anchor()].
541    ///
542    /// The new anchor is owned by the buffer; no reference count is
543    /// returned to the caller of this function.
544    /// ## `iter`
545    /// location in the buffer
546    ///
547    /// # Returns
548    ///
549    /// the created child anchor
550    #[doc(alias = "gtk_text_buffer_create_child_anchor")]
551    fn create_child_anchor(&self, iter: &mut TextIter) -> TextChildAnchor {
552        unsafe {
553            from_glib_none(ffi::gtk_text_buffer_create_child_anchor(
554                self.as_ref().to_glib_none().0,
555                iter.to_glib_none_mut().0,
556            ))
557        }
558    }
559
560    /// Creates a mark at position @where_.
561    ///
562    /// If @mark_name is [`None`], the mark is anonymous; otherwise, the mark
563    /// can be retrieved by name using [`mark()`][Self::mark()].
564    /// If a mark has left gravity, and text is inserted at the mark’s
565    /// current location, the mark will be moved to the left of the
566    /// newly-inserted text. If the mark has right gravity
567    /// (@left_gravity = [`false`]), the mark will end up on the right of
568    /// newly-inserted text. The standard left-to-right cursor is a mark
569    /// with right gravity (when you type, the cursor stays on the right
570    /// side of the text you’re typing).
571    ///
572    /// The caller of this function does not own a
573    /// reference to the returned [`TextMark`][crate::TextMark], so you can ignore the
574    /// return value if you like. Marks are owned by the buffer and go
575    /// away when the buffer does.
576    ///
577    /// Emits the [`mark-set`][struct@crate::TextBuffer#mark-set] signal as notification
578    /// of the mark's initial placement.
579    /// ## `mark_name`
580    /// name for mark
581    /// ## `where_`
582    /// location to place mark
583    /// ## `left_gravity`
584    /// whether the mark has left gravity
585    ///
586    /// # Returns
587    ///
588    /// the new [`TextMark`][crate::TextMark] object
589    #[doc(alias = "gtk_text_buffer_create_mark")]
590    fn create_mark(
591        &self,
592        mark_name: Option<&str>,
593        where_: &TextIter,
594        left_gravity: bool,
595    ) -> TextMark {
596        unsafe {
597            from_glib_none(ffi::gtk_text_buffer_create_mark(
598                self.as_ref().to_glib_none().0,
599                mark_name.to_glib_none().0,
600                where_.to_glib_none().0,
601                left_gravity.into_glib(),
602            ))
603        }
604    }
605
606    /// Copies the currently-selected text to a clipboard,
607    /// then deletes said text if it’s editable.
608    /// ## `clipboard`
609    /// the [`gdk::Clipboard`][crate::gdk::Clipboard] object to cut to
610    /// ## `default_editable`
611    /// default editability of the buffer
612    #[doc(alias = "gtk_text_buffer_cut_clipboard")]
613    fn cut_clipboard(&self, clipboard: &gdk::Clipboard, default_editable: bool) {
614        unsafe {
615            ffi::gtk_text_buffer_cut_clipboard(
616                self.as_ref().to_glib_none().0,
617                clipboard.to_glib_none().0,
618                default_editable.into_glib(),
619            );
620        }
621    }
622
623    /// Deletes text between @start and @end.
624    ///
625    /// The order of @start and @end is not actually relevant;
626    /// gtk_text_buffer_delete() will reorder them.
627    ///
628    /// This function actually emits the “delete-range” signal, and
629    /// the default handler of that signal deletes the text. Because the
630    /// buffer is modified, all outstanding iterators become invalid after
631    /// calling this function; however, the @start and @end will be
632    /// re-initialized to point to the location where text was deleted.
633    /// ## `start`
634    /// a position in @self
635    /// ## `end`
636    /// another position in @self
637    #[doc(alias = "gtk_text_buffer_delete")]
638    fn delete(&self, start: &mut TextIter, end: &mut TextIter) {
639        unsafe {
640            ffi::gtk_text_buffer_delete(
641                self.as_ref().to_glib_none().0,
642                start.to_glib_none_mut().0,
643                end.to_glib_none_mut().0,
644            );
645        }
646    }
647
648    /// Deletes all editable text in the given range.
649    ///
650    /// Calls [`delete()`][Self::delete()] for each editable
651    /// sub-range of [@start,@end). @start and @end are revalidated
652    /// to point to the location of the last deleted range, or left
653    /// untouched if no text was deleted.
654    /// ## `start_iter`
655    /// start of range to delete
656    /// ## `end_iter`
657    /// end of range
658    /// ## `default_editable`
659    /// whether the buffer is editable by default
660    ///
661    /// # Returns
662    ///
663    /// whether some text was actually deleted
664    #[doc(alias = "gtk_text_buffer_delete_interactive")]
665    fn delete_interactive(
666        &self,
667        start_iter: &mut TextIter,
668        end_iter: &mut TextIter,
669        default_editable: bool,
670    ) -> bool {
671        unsafe {
672            from_glib(ffi::gtk_text_buffer_delete_interactive(
673                self.as_ref().to_glib_none().0,
674                start_iter.to_glib_none_mut().0,
675                end_iter.to_glib_none_mut().0,
676                default_editable.into_glib(),
677            ))
678        }
679    }
680
681    /// Deletes @mark, so that it’s no longer located anywhere in the
682    /// buffer.
683    ///
684    /// Removes the reference the buffer holds to the mark, so if
685    /// you haven’t called g_object_ref() on the mark, it will be freed.
686    /// Even if the mark isn’t freed, most operations on @mark become
687    /// invalid, until it gets added to a buffer again with
688    /// [`add_mark()`][Self::add_mark()]. Use [`TextMarkExt::is_deleted()`][crate::prelude::TextMarkExt::is_deleted()]
689    /// to find out if a mark has been removed from its buffer.
690    ///
691    /// The [`mark-deleted`][struct@crate::TextBuffer#mark-deleted] signal will be emitted as
692    /// notification after the mark is deleted.
693    /// ## `mark`
694    /// a [`TextMark`][crate::TextMark] in @self
695    #[doc(alias = "gtk_text_buffer_delete_mark")]
696    fn delete_mark(&self, mark: &impl IsA<TextMark>) {
697        unsafe {
698            ffi::gtk_text_buffer_delete_mark(
699                self.as_ref().to_glib_none().0,
700                mark.as_ref().to_glib_none().0,
701            );
702        }
703    }
704
705    /// Deletes the mark named @name; the mark must exist.
706    ///
707    /// See [`delete_mark()`][Self::delete_mark()] for details.
708    /// ## `name`
709    /// name of a mark in @self
710    #[doc(alias = "gtk_text_buffer_delete_mark_by_name")]
711    fn delete_mark_by_name(&self, name: &str) {
712        unsafe {
713            ffi::gtk_text_buffer_delete_mark_by_name(
714                self.as_ref().to_glib_none().0,
715                name.to_glib_none().0,
716            );
717        }
718    }
719
720    /// Deletes the range between the “insert” and “selection_bound” marks,
721    /// that is, the currently-selected text.
722    ///
723    /// If @interactive is [`true`], the editability of the selection will be
724    /// considered (users can’t delete uneditable text).
725    /// ## `interactive`
726    /// whether the deletion is caused by user interaction
727    /// ## `default_editable`
728    /// whether the buffer is editable by default
729    ///
730    /// # Returns
731    ///
732    /// whether there was a non-empty selection to delete
733    #[doc(alias = "gtk_text_buffer_delete_selection")]
734    fn delete_selection(&self, interactive: bool, default_editable: bool) -> bool {
735        unsafe {
736            from_glib(ffi::gtk_text_buffer_delete_selection(
737                self.as_ref().to_glib_none().0,
738                interactive.into_glib(),
739                default_editable.into_glib(),
740            ))
741        }
742    }
743
744    /// Denotes the end of an action that may not be undone.
745    ///
746    /// This will cause any previous operations in the undo/redo
747    /// queue to be cleared.
748    ///
749    /// This should be called after completing modifications to the
750    /// text buffer after [`begin_irreversible_action()`][Self::begin_irreversible_action()]
751    /// was called.
752    ///
753    /// You may nest calls to gtk_text_buffer_begin_irreversible_action()
754    /// and gtk_text_buffer_end_irreversible_action() pairs.
755    #[doc(alias = "gtk_text_buffer_end_irreversible_action")]
756    fn end_irreversible_action(&self) {
757        unsafe {
758            ffi::gtk_text_buffer_end_irreversible_action(self.as_ref().to_glib_none().0);
759        }
760    }
761
762    /// Ends a user-visible operation.
763    ///
764    /// Should be paired with a call to
765    /// [`begin_user_action()`][Self::begin_user_action()].
766    /// See that function for a full explanation.
767    #[doc(alias = "gtk_text_buffer_end_user_action")]
768    fn end_user_action(&self) {
769        unsafe {
770            ffi::gtk_text_buffer_end_user_action(self.as_ref().to_glib_none().0);
771        }
772    }
773
774    /// Retrieves the first and last iterators in the buffer, i.e. the
775    /// entire buffer lies within the range [@start,@end).
776    ///
777    /// # Returns
778    ///
779    ///
780    /// ## `start`
781    /// iterator to initialize with first position in the buffer
782    ///
783    /// ## `end`
784    /// iterator to initialize with the end iterator
785    #[doc(alias = "gtk_text_buffer_get_bounds")]
786    #[doc(alias = "get_bounds")]
787    fn bounds(&self) -> (TextIter, TextIter) {
788        unsafe {
789            let mut start = TextIter::uninitialized();
790            let mut end = TextIter::uninitialized();
791            ffi::gtk_text_buffer_get_bounds(
792                self.as_ref().to_glib_none().0,
793                start.to_glib_none_mut().0,
794                end.to_glib_none_mut().0,
795            );
796            (start, end)
797        }
798    }
799
800    /// Gets whether there is a redoable action in the history.
801    ///
802    /// # Returns
803    ///
804    /// [`true`] if there is a redoable action
805    #[doc(alias = "gtk_text_buffer_get_can_redo")]
806    #[doc(alias = "get_can_redo")]
807    #[doc(alias = "can-redo")]
808    fn can_redo(&self) -> bool {
809        unsafe {
810            from_glib(ffi::gtk_text_buffer_get_can_redo(
811                self.as_ref().to_glib_none().0,
812            ))
813        }
814    }
815
816    /// Gets whether there is an undoable action in the history.
817    ///
818    /// # Returns
819    ///
820    /// [`true`] if there is an undoable action
821    #[doc(alias = "gtk_text_buffer_get_can_undo")]
822    #[doc(alias = "get_can_undo")]
823    #[doc(alias = "can-undo")]
824    fn can_undo(&self) -> bool {
825        unsafe {
826            from_glib(ffi::gtk_text_buffer_get_can_undo(
827                self.as_ref().to_glib_none().0,
828            ))
829        }
830    }
831
832    /// Gets the number of characters in the buffer.
833    ///
834    /// Note that characters and bytes are not the same, you can’t e.g.
835    /// expect the contents of the buffer in string form to be this
836    /// many bytes long.
837    ///
838    /// The character count is cached, so this function is very fast.
839    ///
840    /// # Returns
841    ///
842    /// number of characters in the buffer
843    #[doc(alias = "gtk_text_buffer_get_char_count")]
844    #[doc(alias = "get_char_count")]
845    fn char_count(&self) -> i32 {
846        unsafe { ffi::gtk_text_buffer_get_char_count(self.as_ref().to_glib_none().0) }
847    }
848
849    /// Gets whether the buffer is saving modifications to the buffer
850    /// to allow for undo and redo actions.
851    ///
852    /// See [`begin_irreversible_action()`][Self::begin_irreversible_action()] and
853    /// [`end_irreversible_action()`][Self::end_irreversible_action()] to create
854    /// changes to the buffer that cannot be undone.
855    ///
856    /// # Returns
857    ///
858    /// [`true`] if undoing and redoing changes to the buffer is allowed.
859    #[doc(alias = "gtk_text_buffer_get_enable_undo")]
860    #[doc(alias = "get_enable_undo")]
861    #[doc(alias = "enable-undo")]
862    fn enables_undo(&self) -> bool {
863        unsafe {
864            from_glib(ffi::gtk_text_buffer_get_enable_undo(
865                self.as_ref().to_glib_none().0,
866            ))
867        }
868    }
869
870    /// Initializes @iter with the “end iterator,” one past the last valid
871    /// character in the text buffer.
872    ///
873    /// If dereferenced with [`TextIter::char()`][crate::TextIter::char()], the end
874    /// iterator has a character value of 0.
875    /// The entire buffer lies in the range from the first position in
876    /// the buffer (call [`start_iter()`][Self::start_iter()] to get
877    /// character position 0) to the end iterator.
878    ///
879    /// # Returns
880    ///
881    ///
882    /// ## `iter`
883    /// iterator to initialize
884    #[doc(alias = "gtk_text_buffer_get_end_iter")]
885    #[doc(alias = "get_end_iter")]
886    fn end_iter(&self) -> TextIter {
887        unsafe {
888            let mut iter = TextIter::uninitialized();
889            ffi::gtk_text_buffer_get_end_iter(
890                self.as_ref().to_glib_none().0,
891                iter.to_glib_none_mut().0,
892            );
893            iter
894        }
895    }
896
897    /// Indicates whether the buffer has some text currently selected.
898    ///
899    /// # Returns
900    ///
901    /// [`true`] if the there is text selected
902    #[doc(alias = "gtk_text_buffer_get_has_selection")]
903    #[doc(alias = "get_has_selection")]
904    #[doc(alias = "has-selection")]
905    fn has_selection(&self) -> bool {
906        unsafe {
907            from_glib(ffi::gtk_text_buffer_get_has_selection(
908                self.as_ref().to_glib_none().0,
909            ))
910        }
911    }
912
913    /// Returns the mark that represents the cursor (insertion point).
914    ///
915    /// Equivalent to calling [`mark()`][Self::mark()]
916    /// to get the mark named “insert”, but very slightly more
917    /// efficient, and involves less typing.
918    ///
919    /// # Returns
920    ///
921    /// insertion point mark
922    #[doc(alias = "gtk_text_buffer_get_insert")]
923    fn get_insert(&self) -> TextMark {
924        unsafe {
925            from_glib_none(ffi::gtk_text_buffer_get_insert(
926                self.as_ref().to_glib_none().0,
927            ))
928        }
929    }
930
931    /// Obtains the location of @anchor within @self.
932    /// ## `anchor`
933    /// a child anchor that appears in @self
934    ///
935    /// # Returns
936    ///
937    ///
938    /// ## `iter`
939    /// an iterator to be initialized
940    #[doc(alias = "gtk_text_buffer_get_iter_at_child_anchor")]
941    #[doc(alias = "get_iter_at_child_anchor")]
942    fn iter_at_child_anchor(&self, anchor: &impl IsA<TextChildAnchor>) -> TextIter {
943        unsafe {
944            let mut iter = TextIter::uninitialized();
945            ffi::gtk_text_buffer_get_iter_at_child_anchor(
946                self.as_ref().to_glib_none().0,
947                iter.to_glib_none_mut().0,
948                anchor.as_ref().to_glib_none().0,
949            );
950            iter
951        }
952    }
953
954    /// Initializes @iter to the start of the given line.
955    ///
956    /// If @line_number is greater than or equal to the number of lines
957    /// in the @self, the end iterator is returned.
958    /// ## `line_number`
959    /// line number counting from 0
960    ///
961    /// # Returns
962    ///
963    /// whether the exact position has been found
964    ///
965    /// ## `iter`
966    /// iterator to initialize
967    #[doc(alias = "gtk_text_buffer_get_iter_at_line")]
968    #[doc(alias = "get_iter_at_line")]
969    fn iter_at_line(&self, line_number: i32) -> Option<TextIter> {
970        unsafe {
971            let mut iter = TextIter::uninitialized();
972            let ret = from_glib(ffi::gtk_text_buffer_get_iter_at_line(
973                self.as_ref().to_glib_none().0,
974                iter.to_glib_none_mut().0,
975                line_number,
976            ));
977            if ret {
978                Some(iter)
979            } else {
980                None
981            }
982        }
983    }
984
985    /// Obtains an iterator pointing to @byte_index within the given line.
986    ///
987    /// @byte_index must be the start of a UTF-8 character. Note bytes, not
988    /// characters; UTF-8 may encode one character as multiple bytes.
989    ///
990    /// If @line_number is greater than or equal to the number of lines in the @self,
991    /// the end iterator is returned. And if @byte_index is off the
992    /// end of the line, the iterator at the end of the line is returned.
993    /// ## `line_number`
994    /// line number counting from 0
995    /// ## `byte_index`
996    /// byte index from start of line
997    ///
998    /// # Returns
999    ///
1000    /// whether the exact position has been found
1001    ///
1002    /// ## `iter`
1003    /// iterator to initialize
1004    #[doc(alias = "gtk_text_buffer_get_iter_at_line_index")]
1005    #[doc(alias = "get_iter_at_line_index")]
1006    fn iter_at_line_index(&self, line_number: i32, byte_index: i32) -> Option<TextIter> {
1007        unsafe {
1008            let mut iter = TextIter::uninitialized();
1009            let ret = from_glib(ffi::gtk_text_buffer_get_iter_at_line_index(
1010                self.as_ref().to_glib_none().0,
1011                iter.to_glib_none_mut().0,
1012                line_number,
1013                byte_index,
1014            ));
1015            if ret {
1016                Some(iter)
1017            } else {
1018                None
1019            }
1020        }
1021    }
1022
1023    /// Obtains an iterator pointing to @char_offset within the given line.
1024    ///
1025    /// Note characters, not bytes; UTF-8 may encode one character as multiple
1026    /// bytes.
1027    ///
1028    /// If @line_number is greater than or equal to the number of lines in the @self,
1029    /// the end iterator is returned. And if @char_offset is off the
1030    /// end of the line, the iterator at the end of the line is returned.
1031    /// ## `line_number`
1032    /// line number counting from 0
1033    /// ## `char_offset`
1034    /// char offset from start of line
1035    ///
1036    /// # Returns
1037    ///
1038    /// whether the exact position has been found
1039    ///
1040    /// ## `iter`
1041    /// iterator to initialize
1042    #[doc(alias = "gtk_text_buffer_get_iter_at_line_offset")]
1043    #[doc(alias = "get_iter_at_line_offset")]
1044    fn iter_at_line_offset(&self, line_number: i32, char_offset: i32) -> Option<TextIter> {
1045        unsafe {
1046            let mut iter = TextIter::uninitialized();
1047            let ret = from_glib(ffi::gtk_text_buffer_get_iter_at_line_offset(
1048                self.as_ref().to_glib_none().0,
1049                iter.to_glib_none_mut().0,
1050                line_number,
1051                char_offset,
1052            ));
1053            if ret {
1054                Some(iter)
1055            } else {
1056                None
1057            }
1058        }
1059    }
1060
1061    /// Initializes @iter with the current position of @mark.
1062    /// ## `mark`
1063    /// a [`TextMark`][crate::TextMark] in @self
1064    ///
1065    /// # Returns
1066    ///
1067    ///
1068    /// ## `iter`
1069    /// iterator to initialize
1070    #[doc(alias = "gtk_text_buffer_get_iter_at_mark")]
1071    #[doc(alias = "get_iter_at_mark")]
1072    fn iter_at_mark(&self, mark: &impl IsA<TextMark>) -> TextIter {
1073        unsafe {
1074            let mut iter = TextIter::uninitialized();
1075            ffi::gtk_text_buffer_get_iter_at_mark(
1076                self.as_ref().to_glib_none().0,
1077                iter.to_glib_none_mut().0,
1078                mark.as_ref().to_glib_none().0,
1079            );
1080            iter
1081        }
1082    }
1083
1084    /// Initializes @iter to a position @char_offset chars from the start
1085    /// of the entire buffer.
1086    ///
1087    /// If @char_offset is -1 or greater than the number
1088    /// of characters in the buffer, @iter is initialized to the end iterator,
1089    /// the iterator one past the last valid character in the buffer.
1090    /// ## `char_offset`
1091    /// char offset from start of buffer, counting from 0, or -1
1092    ///
1093    /// # Returns
1094    ///
1095    ///
1096    /// ## `iter`
1097    /// iterator to initialize
1098    #[doc(alias = "gtk_text_buffer_get_iter_at_offset")]
1099    #[doc(alias = "get_iter_at_offset")]
1100    fn iter_at_offset(&self, char_offset: i32) -> TextIter {
1101        unsafe {
1102            let mut iter = TextIter::uninitialized();
1103            ffi::gtk_text_buffer_get_iter_at_offset(
1104                self.as_ref().to_glib_none().0,
1105                iter.to_glib_none_mut().0,
1106                char_offset,
1107            );
1108            iter
1109        }
1110    }
1111
1112    /// Obtains the number of lines in the buffer.
1113    ///
1114    /// This value is cached, so the function is very fast.
1115    ///
1116    /// # Returns
1117    ///
1118    /// number of lines in the buffer
1119    #[doc(alias = "gtk_text_buffer_get_line_count")]
1120    #[doc(alias = "get_line_count")]
1121    fn line_count(&self) -> i32 {
1122        unsafe { ffi::gtk_text_buffer_get_line_count(self.as_ref().to_glib_none().0) }
1123    }
1124
1125    /// Returns the mark named @name in buffer @self, or [`None`] if no such
1126    /// mark exists in the buffer.
1127    /// ## `name`
1128    /// a mark name
1129    ///
1130    /// # Returns
1131    ///
1132    /// a [`TextMark`][crate::TextMark]
1133    #[doc(alias = "gtk_text_buffer_get_mark")]
1134    #[doc(alias = "get_mark")]
1135    fn mark(&self, name: &str) -> Option<TextMark> {
1136        unsafe {
1137            from_glib_none(ffi::gtk_text_buffer_get_mark(
1138                self.as_ref().to_glib_none().0,
1139                name.to_glib_none().0,
1140            ))
1141        }
1142    }
1143
1144    /// Gets the maximum number of undo levels to perform.
1145    ///
1146    /// If 0, unlimited undo actions may be performed. Note that this may
1147    /// have a memory usage impact as it requires storing an additional
1148    /// copy of the inserted or removed text within the text buffer.
1149    ///
1150    /// # Returns
1151    ///
1152    /// The max number of undo levels allowed (0 indicates unlimited).
1153    #[doc(alias = "gtk_text_buffer_get_max_undo_levels")]
1154    #[doc(alias = "get_max_undo_levels")]
1155    fn max_undo_levels(&self) -> u32 {
1156        unsafe { ffi::gtk_text_buffer_get_max_undo_levels(self.as_ref().to_glib_none().0) }
1157    }
1158
1159    /// Indicates whether the buffer has been modified since the last call
1160    /// to [`set_modified()`][Self::set_modified()] set the modification flag to
1161    /// [`false`].
1162    ///
1163    /// Used for example to enable a “save” function in a text editor.
1164    ///
1165    /// # Returns
1166    ///
1167    /// [`true`] if the buffer has been modified
1168    #[doc(alias = "gtk_text_buffer_get_modified")]
1169    #[doc(alias = "get_modified")]
1170    fn is_modified(&self) -> bool {
1171        unsafe {
1172            from_glib(ffi::gtk_text_buffer_get_modified(
1173                self.as_ref().to_glib_none().0,
1174            ))
1175        }
1176    }
1177
1178    /// Returns the mark that represents the selection bound.
1179    ///
1180    /// Equivalent to calling [`mark()`][Self::mark()]
1181    /// to get the mark named “selection_bound”, but very slightly
1182    /// more efficient, and involves less typing.
1183    ///
1184    /// The currently-selected text in @self is the region between the
1185    /// “selection_bound” and “insert” marks. If “selection_bound” and
1186    /// “insert” are in the same place, then there is no current selection.
1187    /// [`selection_bounds()`][Self::selection_bounds()] is another convenient
1188    /// function for handling the selection, if you just want to know whether
1189    /// there’s a selection and what its bounds are.
1190    ///
1191    /// # Returns
1192    ///
1193    /// selection bound mark
1194    #[doc(alias = "gtk_text_buffer_get_selection_bound")]
1195    #[doc(alias = "get_selection_bound")]
1196    fn selection_bound(&self) -> TextMark {
1197        unsafe {
1198            from_glib_none(ffi::gtk_text_buffer_get_selection_bound(
1199                self.as_ref().to_glib_none().0,
1200            ))
1201        }
1202    }
1203
1204    /// Returns [`true`] if some text is selected; places the bounds
1205    /// of the selection in @start and @end.
1206    ///
1207    /// If the selection has length 0, then @start and @end are filled
1208    /// in with the same value. @start and @end will be in ascending order.
1209    /// If @start and @end are [`None`], then they are not filled in, but the
1210    /// return value still indicates whether text is selected.
1211    ///
1212    /// # Returns
1213    ///
1214    /// whether the selection has nonzero length
1215    ///
1216    /// ## `start`
1217    /// iterator to initialize with selection start
1218    ///
1219    /// ## `end`
1220    /// iterator to initialize with selection end
1221    #[doc(alias = "gtk_text_buffer_get_selection_bounds")]
1222    #[doc(alias = "get_selection_bounds")]
1223    fn selection_bounds(&self) -> Option<(TextIter, TextIter)> {
1224        unsafe {
1225            let mut start = TextIter::uninitialized();
1226            let mut end = TextIter::uninitialized();
1227            let ret = from_glib(ffi::gtk_text_buffer_get_selection_bounds(
1228                self.as_ref().to_glib_none().0,
1229                start.to_glib_none_mut().0,
1230                end.to_glib_none_mut().0,
1231            ));
1232            if ret {
1233                Some((start, end))
1234            } else {
1235                None
1236            }
1237        }
1238    }
1239
1240    /// Get a content provider for this buffer.
1241    ///
1242    /// It can be used to make the content of @self available
1243    /// in a [`gdk::Clipboard`][crate::gdk::Clipboard], see [`Clipboard::set_content()`][crate::gdk::Clipboard::set_content()].
1244    ///
1245    /// # Returns
1246    ///
1247    /// a new [`gdk::ContentProvider`][crate::gdk::ContentProvider].
1248    #[doc(alias = "gtk_text_buffer_get_selection_content")]
1249    #[doc(alias = "get_selection_content")]
1250    fn selection_content(&self) -> gdk::ContentProvider {
1251        unsafe {
1252            from_glib_full(ffi::gtk_text_buffer_get_selection_content(
1253                self.as_ref().to_glib_none().0,
1254            ))
1255        }
1256    }
1257
1258    /// Returns the text in the range [@start,@end).
1259    ///
1260    /// Excludes undisplayed text (text marked with tags that set the
1261    /// invisibility attribute) if @include_hidden_chars is [`false`].
1262    /// The returned string includes a 0xFFFC character whenever the
1263    /// buffer contains embedded images, so byte and character indexes
1264    /// into the returned string do correspond to byte and character
1265    /// indexes into the buffer. Contrast with [`text()`][Self::text()].
1266    /// Note that 0xFFFC can occur in normal text as well, so it is not a
1267    /// reliable indicator that a paintable or widget is in the buffer.
1268    /// ## `start`
1269    /// start of a range
1270    /// ## `end`
1271    /// end of a range
1272    /// ## `include_hidden_chars`
1273    /// whether to include invisible text
1274    ///
1275    /// # Returns
1276    ///
1277    /// an allocated UTF-8 string
1278    #[doc(alias = "gtk_text_buffer_get_slice")]
1279    #[doc(alias = "get_slice")]
1280    fn slice(&self, start: &TextIter, end: &TextIter, include_hidden_chars: bool) -> glib::GString {
1281        unsafe {
1282            from_glib_full(ffi::gtk_text_buffer_get_slice(
1283                self.as_ref().to_glib_none().0,
1284                start.to_glib_none().0,
1285                end.to_glib_none().0,
1286                include_hidden_chars.into_glib(),
1287            ))
1288        }
1289    }
1290
1291    /// Initialized @iter with the first position in the text buffer.
1292    ///
1293    /// This is the same as using [`iter_at_offset()`][Self::iter_at_offset()]
1294    /// to get the iter at character offset 0.
1295    ///
1296    /// # Returns
1297    ///
1298    ///
1299    /// ## `iter`
1300    /// iterator to initialize
1301    #[doc(alias = "gtk_text_buffer_get_start_iter")]
1302    #[doc(alias = "get_start_iter")]
1303    fn start_iter(&self) -> TextIter {
1304        unsafe {
1305            let mut iter = TextIter::uninitialized();
1306            ffi::gtk_text_buffer_get_start_iter(
1307                self.as_ref().to_glib_none().0,
1308                iter.to_glib_none_mut().0,
1309            );
1310            iter
1311        }
1312    }
1313
1314    /// Get the [`TextTagTable`][crate::TextTagTable] associated with this buffer.
1315    ///
1316    /// # Returns
1317    ///
1318    /// the buffer’s tag table
1319    #[doc(alias = "gtk_text_buffer_get_tag_table")]
1320    #[doc(alias = "get_tag_table")]
1321    #[doc(alias = "tag-table")]
1322    fn tag_table(&self) -> TextTagTable {
1323        unsafe {
1324            from_glib_none(ffi::gtk_text_buffer_get_tag_table(
1325                self.as_ref().to_glib_none().0,
1326            ))
1327        }
1328    }
1329
1330    /// Returns the text in the range [@start,@end).
1331    ///
1332    /// Excludes undisplayed text (text marked with tags that set the
1333    /// invisibility attribute) if @include_hidden_chars is [`false`].
1334    /// Does not include characters representing embedded images, so
1335    /// byte and character indexes into the returned string do not
1336    /// correspond to byte and character indexes into the buffer.
1337    /// Contrast with [`slice()`][Self::slice()].
1338    /// ## `start`
1339    /// start of a range
1340    /// ## `end`
1341    /// end of a range
1342    /// ## `include_hidden_chars`
1343    /// whether to include invisible text
1344    ///
1345    /// # Returns
1346    ///
1347    /// an allocated UTF-8 string
1348    #[doc(alias = "gtk_text_buffer_get_text")]
1349    #[doc(alias = "get_text")]
1350    fn text(&self, start: &TextIter, end: &TextIter, include_hidden_chars: bool) -> glib::GString {
1351        unsafe {
1352            from_glib_full(ffi::gtk_text_buffer_get_text(
1353                self.as_ref().to_glib_none().0,
1354                start.to_glib_none().0,
1355                end.to_glib_none().0,
1356                include_hidden_chars.into_glib(),
1357            ))
1358        }
1359    }
1360
1361    /// Inserts @len bytes of @text at position @iter.
1362    ///
1363    /// If @len is -1, @text must be nul-terminated and will be inserted in its
1364    /// entirety. Emits the “insert-text” signal; insertion actually occurs
1365    /// in the default handler for the signal. @iter is invalidated when
1366    /// insertion occurs (because the buffer contents change), but the
1367    /// default signal handler revalidates it to point to the end of the
1368    /// inserted text.
1369    /// ## `iter`
1370    /// a position in the buffer
1371    /// ## `text`
1372    /// text in UTF-8 format
1373    /// ## `len`
1374    /// length of text in bytes, or -1
1375    #[doc(alias = "gtk_text_buffer_insert")]
1376    fn insert(&self, iter: &mut TextIter, text: &str) {
1377        let len = text.len() as _;
1378        unsafe {
1379            ffi::gtk_text_buffer_insert(
1380                self.as_ref().to_glib_none().0,
1381                iter.to_glib_none_mut().0,
1382                text.to_glib_none().0,
1383                len,
1384            );
1385        }
1386    }
1387
1388    /// Inserts @text in @self.
1389    ///
1390    /// Simply calls [`insert()`][Self::insert()],
1391    /// using the current cursor position as the insertion point.
1392    /// ## `text`
1393    /// text in UTF-8 format
1394    /// ## `len`
1395    /// length of text, in bytes
1396    #[doc(alias = "gtk_text_buffer_insert_at_cursor")]
1397    fn insert_at_cursor(&self, text: &str) {
1398        let len = text.len() as _;
1399        unsafe {
1400            ffi::gtk_text_buffer_insert_at_cursor(
1401                self.as_ref().to_glib_none().0,
1402                text.to_glib_none().0,
1403                len,
1404            );
1405        }
1406    }
1407
1408    /// Inserts a child widget anchor into the text buffer at @iter.
1409    ///
1410    /// The anchor will be counted as one character in character counts, and
1411    /// when obtaining the buffer contents as a string, will be represented
1412    /// by the Unicode “object replacement character” 0xFFFC. Note that the
1413    /// “slice” variants for obtaining portions of the buffer as a string
1414    /// include this character for child anchors, but the “text” variants do
1415    /// not. E.g. see [`slice()`][Self::slice()] and
1416    /// [`text()`][Self::text()].
1417    ///
1418    /// Consider [`create_child_anchor()`][Self::create_child_anchor()] as a more
1419    /// convenient alternative to this function. The buffer will add a
1420    /// reference to the anchor, so you can unref it after insertion.
1421    /// ## `iter`
1422    /// location to insert the anchor
1423    /// ## `anchor`
1424    /// a [`TextChildAnchor`][crate::TextChildAnchor]
1425    #[doc(alias = "gtk_text_buffer_insert_child_anchor")]
1426    fn insert_child_anchor(&self, iter: &mut TextIter, anchor: &impl IsA<TextChildAnchor>) {
1427        unsafe {
1428            ffi::gtk_text_buffer_insert_child_anchor(
1429                self.as_ref().to_glib_none().0,
1430                iter.to_glib_none_mut().0,
1431                anchor.as_ref().to_glib_none().0,
1432            );
1433        }
1434    }
1435
1436    /// Inserts @text in @self.
1437    ///
1438    /// Like [`insert()`][Self::insert()], but the insertion will not occur
1439    /// if @iter is at a non-editable location in the buffer. Usually you
1440    /// want to prevent insertions at ineditable locations if the insertion
1441    /// results from a user action (is interactive).
1442    ///
1443    /// @default_editable indicates the editability of text that doesn't
1444    /// have a tag affecting editability applied to it. Typically the
1445    /// result of [`TextViewExt::is_editable()`][crate::prelude::TextViewExt::is_editable()] is appropriate here.
1446    /// ## `iter`
1447    /// a position in @self
1448    /// ## `text`
1449    /// some UTF-8 text
1450    /// ## `len`
1451    /// length of text in bytes, or -1
1452    /// ## `default_editable`
1453    /// default editability of buffer
1454    ///
1455    /// # Returns
1456    ///
1457    /// whether text was actually inserted
1458    #[doc(alias = "gtk_text_buffer_insert_interactive")]
1459    fn insert_interactive(&self, iter: &mut TextIter, text: &str, default_editable: bool) -> bool {
1460        let len = text.len() as _;
1461        unsafe {
1462            from_glib(ffi::gtk_text_buffer_insert_interactive(
1463                self.as_ref().to_glib_none().0,
1464                iter.to_glib_none_mut().0,
1465                text.to_glib_none().0,
1466                len,
1467                default_editable.into_glib(),
1468            ))
1469        }
1470    }
1471
1472    /// Inserts @text in @self.
1473    ///
1474    /// Calls [`insert_interactive()`][Self::insert_interactive()]
1475    /// at the cursor position.
1476    ///
1477    /// @default_editable indicates the editability of text that doesn't
1478    /// have a tag affecting editability applied to it. Typically the
1479    /// result of [`TextViewExt::is_editable()`][crate::prelude::TextViewExt::is_editable()] is appropriate here.
1480    /// ## `text`
1481    /// text in UTF-8 format
1482    /// ## `len`
1483    /// length of text in bytes, or -1
1484    /// ## `default_editable`
1485    /// default editability of buffer
1486    ///
1487    /// # Returns
1488    ///
1489    /// whether text was actually inserted
1490    #[doc(alias = "gtk_text_buffer_insert_interactive_at_cursor")]
1491    fn insert_interactive_at_cursor(&self, text: &str, default_editable: bool) -> bool {
1492        let len = text.len() as _;
1493        unsafe {
1494            from_glib(ffi::gtk_text_buffer_insert_interactive_at_cursor(
1495                self.as_ref().to_glib_none().0,
1496                text.to_glib_none().0,
1497                len,
1498                default_editable.into_glib(),
1499            ))
1500        }
1501    }
1502
1503    /// Inserts the text in @markup at position @iter.
1504    ///
1505    /// @markup will be inserted in its entirety and must be nul-terminated
1506    /// and valid UTF-8. Emits the [`insert-text`][struct@crate::TextBuffer#insert-text] signal,
1507    /// possibly multiple times; insertion actually occurs in the default handler
1508    /// for the signal. @iter will point to the end of the inserted text on return.
1509    /// ## `iter`
1510    /// location to insert the markup
1511    /// ## `markup`
1512    /// a nul-terminated UTF-8 string containing Pango markup
1513    /// ## `len`
1514    /// length of @markup in bytes, or -1
1515    #[doc(alias = "gtk_text_buffer_insert_markup")]
1516    fn insert_markup(&self, iter: &mut TextIter, markup: &str) {
1517        let len = markup.len() as _;
1518        unsafe {
1519            ffi::gtk_text_buffer_insert_markup(
1520                self.as_ref().to_glib_none().0,
1521                iter.to_glib_none_mut().0,
1522                markup.to_glib_none().0,
1523                len,
1524            );
1525        }
1526    }
1527
1528    /// Inserts an image into the text buffer at @iter.
1529    ///
1530    /// The image will be counted as one character in character counts,
1531    /// and when obtaining the buffer contents as a string, will be
1532    /// represented by the Unicode “object replacement character” 0xFFFC.
1533    /// Note that the “slice” variants for obtaining portions of the buffer
1534    /// as a string include this character for paintable, but the “text”
1535    /// variants do not. e.g. see [`slice()`][Self::slice()] and
1536    /// [`text()`][Self::text()].
1537    /// ## `iter`
1538    /// location to insert the paintable
1539    /// ## `paintable`
1540    /// a [`gdk::Paintable`][crate::gdk::Paintable]
1541    #[doc(alias = "gtk_text_buffer_insert_paintable")]
1542    fn insert_paintable(&self, iter: &mut TextIter, paintable: &impl IsA<gdk::Paintable>) {
1543        unsafe {
1544            ffi::gtk_text_buffer_insert_paintable(
1545                self.as_ref().to_glib_none().0,
1546                iter.to_glib_none_mut().0,
1547                paintable.as_ref().to_glib_none().0,
1548            );
1549        }
1550    }
1551
1552    /// Copies text, tags, and paintables between @start and @end
1553    /// and inserts the copy at @iter.
1554    ///
1555    /// The order of @start and @end doesn’t matter.
1556    ///
1557    /// Used instead of simply getting/inserting text because it preserves
1558    /// images and tags. If @start and @end are in a different buffer from
1559    /// @self, the two buffers must share the same tag table.
1560    ///
1561    /// Implemented via emissions of the ::insert-text and ::apply-tag signals,
1562    /// so expect those.
1563    /// ## `iter`
1564    /// a position in @self
1565    /// ## `start`
1566    /// a position in a [`TextBuffer`][crate::TextBuffer]
1567    /// ## `end`
1568    /// another position in the same buffer as @start
1569    #[doc(alias = "gtk_text_buffer_insert_range")]
1570    fn insert_range(&self, iter: &mut TextIter, start: &TextIter, end: &TextIter) {
1571        unsafe {
1572            ffi::gtk_text_buffer_insert_range(
1573                self.as_ref().to_glib_none().0,
1574                iter.to_glib_none_mut().0,
1575                start.to_glib_none().0,
1576                end.to_glib_none().0,
1577            );
1578        }
1579    }
1580
1581    /// Copies text, tags, and paintables between @start and @end
1582    /// and inserts the copy at @iter.
1583    ///
1584    /// Same as [`insert_range()`][Self::insert_range()], but does nothing
1585    /// if the insertion point isn’t editable. The @default_editable
1586    /// parameter indicates whether the text is editable at @iter if
1587    /// no tags enclosing @iter affect editability. Typically the result
1588    /// of [`TextViewExt::is_editable()`][crate::prelude::TextViewExt::is_editable()] is appropriate here.
1589    /// ## `iter`
1590    /// a position in @self
1591    /// ## `start`
1592    /// a position in a [`TextBuffer`][crate::TextBuffer]
1593    /// ## `end`
1594    /// another position in the same buffer as @start
1595    /// ## `default_editable`
1596    /// default editability of the buffer
1597    ///
1598    /// # Returns
1599    ///
1600    /// whether an insertion was possible at @iter
1601    #[doc(alias = "gtk_text_buffer_insert_range_interactive")]
1602    fn insert_range_interactive(
1603        &self,
1604        iter: &mut TextIter,
1605        start: &TextIter,
1606        end: &TextIter,
1607        default_editable: bool,
1608    ) -> bool {
1609        unsafe {
1610            from_glib(ffi::gtk_text_buffer_insert_range_interactive(
1611                self.as_ref().to_glib_none().0,
1612                iter.to_glib_none_mut().0,
1613                start.to_glib_none().0,
1614                end.to_glib_none().0,
1615                default_editable.into_glib(),
1616            ))
1617        }
1618    }
1619
1620    /// Moves @mark to the new location @where_.
1621    ///
1622    /// Emits the [`mark-set`][struct@crate::TextBuffer#mark-set] signal
1623    /// as notification of the move.
1624    /// ## `mark`
1625    /// a [`TextMark`][crate::TextMark]
1626    /// ## `where_`
1627    /// new location for @mark in @self
1628    #[doc(alias = "gtk_text_buffer_move_mark")]
1629    fn move_mark(&self, mark: &impl IsA<TextMark>, where_: &TextIter) {
1630        unsafe {
1631            ffi::gtk_text_buffer_move_mark(
1632                self.as_ref().to_glib_none().0,
1633                mark.as_ref().to_glib_none().0,
1634                where_.to_glib_none().0,
1635            );
1636        }
1637    }
1638
1639    /// Moves the mark named @name (which must exist) to location @where_.
1640    ///
1641    /// See [`move_mark()`][Self::move_mark()] for details.
1642    /// ## `name`
1643    /// name of a mark
1644    /// ## `where_`
1645    /// new location for mark
1646    #[doc(alias = "gtk_text_buffer_move_mark_by_name")]
1647    fn move_mark_by_name(&self, name: &str, where_: &TextIter) {
1648        unsafe {
1649            ffi::gtk_text_buffer_move_mark_by_name(
1650                self.as_ref().to_glib_none().0,
1651                name.to_glib_none().0,
1652                where_.to_glib_none().0,
1653            );
1654        }
1655    }
1656
1657    /// Pastes the contents of a clipboard.
1658    ///
1659    /// If @override_location is [`None`], the pasted text will be inserted
1660    /// at the cursor position, or the buffer selection will be replaced
1661    /// if the selection is non-empty.
1662    ///
1663    /// Note: pasting is asynchronous, that is, we’ll ask for the paste data
1664    /// and return, and at some point later after the main loop runs, the paste
1665    /// data will be inserted.
1666    /// ## `clipboard`
1667    /// the [`gdk::Clipboard`][crate::gdk::Clipboard] to paste from
1668    /// ## `override_location`
1669    /// location to insert pasted text
1670    /// ## `default_editable`
1671    /// whether the buffer is editable by default
1672    #[doc(alias = "gtk_text_buffer_paste_clipboard")]
1673    fn paste_clipboard(
1674        &self,
1675        clipboard: &gdk::Clipboard,
1676        override_location: Option<&TextIter>,
1677        default_editable: bool,
1678    ) {
1679        unsafe {
1680            ffi::gtk_text_buffer_paste_clipboard(
1681                self.as_ref().to_glib_none().0,
1682                clipboard.to_glib_none().0,
1683                mut_override(override_location.to_glib_none().0),
1684                default_editable.into_glib(),
1685            );
1686        }
1687    }
1688
1689    /// This function moves the “insert” and “selection_bound” marks
1690    /// simultaneously.
1691    ///
1692    /// If you move them to the same place in two steps with
1693    /// [`move_mark()`][Self::move_mark()], you will temporarily select a
1694    /// region in between their old and new locations, which can be pretty
1695    /// inefficient since the temporarily-selected region will force stuff
1696    /// to be recalculated. This function moves them as a unit, which can
1697    /// be optimized.
1698    /// ## `where_`
1699    /// where to put the cursor
1700    #[doc(alias = "gtk_text_buffer_place_cursor")]
1701    fn place_cursor(&self, where_: &TextIter) {
1702        unsafe {
1703            ffi::gtk_text_buffer_place_cursor(
1704                self.as_ref().to_glib_none().0,
1705                where_.to_glib_none().0,
1706            );
1707        }
1708    }
1709
1710    /// Redoes the next redoable action on the buffer, if there is one.
1711    #[doc(alias = "gtk_text_buffer_redo")]
1712    fn redo(&self) {
1713        unsafe {
1714            ffi::gtk_text_buffer_redo(self.as_ref().to_glib_none().0);
1715        }
1716    }
1717
1718    /// Removes all tags in the range between @start and @end.
1719    ///
1720    /// Be careful with this function; it could remove tags added in code
1721    /// unrelated to the code you’re currently writing. That is, using this
1722    /// function is probably a bad idea if you have two or more unrelated
1723    /// code sections that add tags.
1724    /// ## `start`
1725    /// one bound of range to be untagged
1726    /// ## `end`
1727    /// other bound of range to be untagged
1728    #[doc(alias = "gtk_text_buffer_remove_all_tags")]
1729    fn remove_all_tags(&self, start: &TextIter, end: &TextIter) {
1730        unsafe {
1731            ffi::gtk_text_buffer_remove_all_tags(
1732                self.as_ref().to_glib_none().0,
1733                start.to_glib_none().0,
1734                end.to_glib_none().0,
1735            );
1736        }
1737    }
1738
1739    /// Removes the `GtkTextBufferCommitNotify` handler previously registered
1740    /// with [`TextBufferExtManual::add_commit_notify()`][crate::prelude::TextBufferExtManual::add_commit_notify()].
1741    ///
1742    /// This may result in the `user_data_destroy` being called that was passed when registering
1743    /// the commit notify functions.
1744    /// ## `commit_notify_handler`
1745    /// the notify handler identifier returned from
1746    ///   [`TextBufferExtManual::add_commit_notify()`][crate::prelude::TextBufferExtManual::add_commit_notify()].
1747    #[cfg(feature = "v4_16")]
1748    #[cfg_attr(docsrs, doc(cfg(feature = "v4_16")))]
1749    #[doc(alias = "gtk_text_buffer_remove_commit_notify")]
1750    fn remove_commit_notify(&self, commit_notify_handler: u32) {
1751        unsafe {
1752            ffi::gtk_text_buffer_remove_commit_notify(
1753                self.as_ref().to_glib_none().0,
1754                commit_notify_handler,
1755            );
1756        }
1757    }
1758
1759    /// Removes a [`gdk::Clipboard`][crate::gdk::Clipboard] added with
1760    /// [`add_selection_clipboard()`][Self::add_selection_clipboard()]
1761    /// ## `clipboard`
1762    /// a [`gdk::Clipboard`][crate::gdk::Clipboard] added to @self by
1763    ///   [`add_selection_clipboard()`][Self::add_selection_clipboard()]
1764    #[doc(alias = "gtk_text_buffer_remove_selection_clipboard")]
1765    fn remove_selection_clipboard(&self, clipboard: &gdk::Clipboard) {
1766        unsafe {
1767            ffi::gtk_text_buffer_remove_selection_clipboard(
1768                self.as_ref().to_glib_none().0,
1769                clipboard.to_glib_none().0,
1770            );
1771        }
1772    }
1773
1774    /// Emits the “remove-tag” signal.
1775    ///
1776    /// The default handler for the signal removes all occurrences
1777    /// of @tag from the given range. @start and @end don’t have
1778    /// to be in order.
1779    /// ## `tag`
1780    /// a [`TextTag`][crate::TextTag]
1781    /// ## `start`
1782    /// one bound of range to be untagged
1783    /// ## `end`
1784    /// other bound of range to be untagged
1785    #[doc(alias = "gtk_text_buffer_remove_tag")]
1786    fn remove_tag(&self, tag: &impl IsA<TextTag>, start: &TextIter, end: &TextIter) {
1787        unsafe {
1788            ffi::gtk_text_buffer_remove_tag(
1789                self.as_ref().to_glib_none().0,
1790                tag.as_ref().to_glib_none().0,
1791                start.to_glib_none().0,
1792                end.to_glib_none().0,
1793            );
1794        }
1795    }
1796
1797    /// Emits the “remove-tag” signal.
1798    ///
1799    /// Calls [`TextTagTable::lookup()`][crate::TextTagTable::lookup()] on the buffer’s
1800    /// tag table to get a [`TextTag`][crate::TextTag], then calls
1801    /// [`remove_tag()`][Self::remove_tag()].
1802    /// ## `name`
1803    /// name of a [`TextTag`][crate::TextTag]
1804    /// ## `start`
1805    /// one bound of range to be untagged
1806    /// ## `end`
1807    /// other bound of range to be untagged
1808    #[doc(alias = "gtk_text_buffer_remove_tag_by_name")]
1809    fn remove_tag_by_name(&self, name: &str, start: &TextIter, end: &TextIter) {
1810        unsafe {
1811            ffi::gtk_text_buffer_remove_tag_by_name(
1812                self.as_ref().to_glib_none().0,
1813                name.to_glib_none().0,
1814                start.to_glib_none().0,
1815                end.to_glib_none().0,
1816            );
1817        }
1818    }
1819
1820    /// This function moves the “insert” and “selection_bound” marks
1821    /// simultaneously.
1822    ///
1823    /// If you move them in two steps with
1824    /// [`move_mark()`][Self::move_mark()], you will temporarily select a
1825    /// region in between their old and new locations, which can be pretty
1826    /// inefficient since the temporarily-selected region will force stuff
1827    /// to be recalculated. This function moves them as a unit, which can
1828    /// be optimized.
1829    /// ## `ins`
1830    /// where to put the “insert” mark
1831    /// ## `bound`
1832    /// where to put the “selection_bound” mark
1833    #[doc(alias = "gtk_text_buffer_select_range")]
1834    fn select_range(&self, ins: &TextIter, bound: &TextIter) {
1835        unsafe {
1836            ffi::gtk_text_buffer_select_range(
1837                self.as_ref().to_glib_none().0,
1838                ins.to_glib_none().0,
1839                bound.to_glib_none().0,
1840            );
1841        }
1842    }
1843
1844    /// Sets whether or not to enable undoable actions in the text buffer.
1845    ///
1846    /// Undoable actions in this context are changes to the text content of
1847    /// the buffer. Changes to tags and marks are not tracked.
1848    ///
1849    /// If enabled, the user will be able to undo the last number of actions
1850    /// up to [`max_undo_levels()`][Self::max_undo_levels()].
1851    ///
1852    /// See [`begin_irreversible_action()`][Self::begin_irreversible_action()] and
1853    /// [`end_irreversible_action()`][Self::end_irreversible_action()] to create
1854    /// changes to the buffer that cannot be undone.
1855    /// ## `enable_undo`
1856    /// [`true`] to enable undo
1857    #[doc(alias = "gtk_text_buffer_set_enable_undo")]
1858    #[doc(alias = "enable-undo")]
1859    fn set_enable_undo(&self, enable_undo: bool) {
1860        unsafe {
1861            ffi::gtk_text_buffer_set_enable_undo(
1862                self.as_ref().to_glib_none().0,
1863                enable_undo.into_glib(),
1864            );
1865        }
1866    }
1867
1868    /// Sets the maximum number of undo levels to perform.
1869    ///
1870    /// If 0, unlimited undo actions may be performed. Note that this may
1871    /// have a memory usage impact as it requires storing an additional
1872    /// copy of the inserted or removed text within the text buffer.
1873    /// ## `max_undo_levels`
1874    /// the maximum number of undo actions to perform
1875    #[doc(alias = "gtk_text_buffer_set_max_undo_levels")]
1876    fn set_max_undo_levels(&self, max_undo_levels: u32) {
1877        unsafe {
1878            ffi::gtk_text_buffer_set_max_undo_levels(
1879                self.as_ref().to_glib_none().0,
1880                max_undo_levels,
1881            );
1882        }
1883    }
1884
1885    /// Used to keep track of whether the buffer has been
1886    /// modified since the last time it was saved.
1887    ///
1888    /// Whenever the buffer is saved to disk, call
1889    /// `gtk_text_buffer_set_modified (@self, FALSE)`.
1890    /// When the buffer is modified, it will automatically
1891    /// toggle on the modified bit again. When the modified
1892    /// bit flips, the buffer emits the
1893    /// [`modified-changed`][struct@crate::TextBuffer#modified-changed] signal.
1894    /// ## `setting`
1895    /// modification flag setting
1896    #[doc(alias = "gtk_text_buffer_set_modified")]
1897    fn set_modified(&self, setting: bool) {
1898        unsafe {
1899            ffi::gtk_text_buffer_set_modified(self.as_ref().to_glib_none().0, setting.into_glib());
1900        }
1901    }
1902
1903    /// Deletes current contents of @self, and inserts @text instead. This is
1904    /// automatically marked as an irreversible action in the undo stack. If you
1905    /// wish to mark this action as part of a larger undo operation, call
1906    /// [`delete()`][Self::delete()] and [`insert()`][Self::insert()] directly instead.
1907    ///
1908    /// If @len is -1, @text must be nul-terminated.
1909    /// @text must be valid UTF-8.
1910    /// ## `text`
1911    /// UTF-8 text to insert
1912    /// ## `len`
1913    /// length of @text in bytes
1914    #[doc(alias = "gtk_text_buffer_set_text")]
1915    #[doc(alias = "text")]
1916    fn set_text(&self, text: &str) {
1917        let len = text.len() as _;
1918        unsafe {
1919            ffi::gtk_text_buffer_set_text(
1920                self.as_ref().to_glib_none().0,
1921                text.to_glib_none().0,
1922                len,
1923            );
1924        }
1925    }
1926
1927    /// Undoes the last undoable action on the buffer, if there is one.
1928    #[doc(alias = "gtk_text_buffer_undo")]
1929    fn undo(&self) {
1930        unsafe {
1931            ffi::gtk_text_buffer_undo(self.as_ref().to_glib_none().0);
1932        }
1933    }
1934
1935    /// The position of the insert mark.
1936    ///
1937    /// This is an offset from the beginning of the buffer.
1938    /// It is useful for getting notified when the cursor moves.
1939    #[doc(alias = "cursor-position")]
1940    fn cursor_position(&self) -> i32 {
1941        ObjectExt::property(self.as_ref(), "cursor-position")
1942    }
1943
1944    /// Emitted to apply a tag to a range of text in a [`TextBuffer`][crate::TextBuffer].
1945    ///
1946    /// Applying actually occurs in the default handler.
1947    ///
1948    /// Note that if your handler runs before the default handler
1949    /// it must not invalidate the @start and @end iters (or has to
1950    /// revalidate them).
1951    ///
1952    /// See also:
1953    /// [`apply_tag()`][Self::apply_tag()],
1954    /// [`TextBufferExtManual::insert_with_tags()`][crate::prelude::TextBufferExtManual::insert_with_tags()],
1955    /// [`insert_range()`][Self::insert_range()].
1956    /// ## `tag`
1957    /// the applied tag
1958    /// ## `start`
1959    /// the start of the range the tag is applied to
1960    /// ## `end`
1961    /// the end of the range the tag is applied to
1962    #[doc(alias = "apply-tag")]
1963    fn connect_apply_tag<F: Fn(&Self, &TextTag, &TextIter, &TextIter) + 'static>(
1964        &self,
1965        f: F,
1966    ) -> SignalHandlerId {
1967        unsafe extern "C" fn apply_tag_trampoline<
1968            P: IsA<TextBuffer>,
1969            F: Fn(&P, &TextTag, &TextIter, &TextIter) + 'static,
1970        >(
1971            this: *mut ffi::GtkTextBuffer,
1972            tag: *mut ffi::GtkTextTag,
1973            start: *mut ffi::GtkTextIter,
1974            end: *mut ffi::GtkTextIter,
1975            f: glib::ffi::gpointer,
1976        ) {
1977            let f: &F = &*(f as *const F);
1978            f(
1979                TextBuffer::from_glib_borrow(this).unsafe_cast_ref(),
1980                &from_glib_borrow(tag),
1981                &from_glib_borrow(start),
1982                &from_glib_borrow(end),
1983            )
1984        }
1985        unsafe {
1986            let f: Box_<F> = Box_::new(f);
1987            connect_raw(
1988                self.as_ptr() as *mut _,
1989                b"apply-tag\0".as_ptr() as *const _,
1990                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1991                    apply_tag_trampoline::<Self, F> as *const (),
1992                )),
1993                Box_::into_raw(f),
1994            )
1995        }
1996    }
1997
1998    /// Emitted at the beginning of a single user-visible
1999    /// operation on a [`TextBuffer`][crate::TextBuffer].
2000    ///
2001    /// See also:
2002    /// [`begin_user_action()`][Self::begin_user_action()],
2003    /// [`insert_interactive()`][Self::insert_interactive()],
2004    /// [`insert_range_interactive()`][Self::insert_range_interactive()],
2005    /// [`delete_interactive()`][Self::delete_interactive()],
2006    /// [`backspace()`][Self::backspace()],
2007    /// [`delete_selection()`][Self::delete_selection()].
2008    #[doc(alias = "begin-user-action")]
2009    fn connect_begin_user_action<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2010        unsafe extern "C" fn begin_user_action_trampoline<
2011            P: IsA<TextBuffer>,
2012            F: Fn(&P) + 'static,
2013        >(
2014            this: *mut ffi::GtkTextBuffer,
2015            f: glib::ffi::gpointer,
2016        ) {
2017            let f: &F = &*(f as *const F);
2018            f(TextBuffer::from_glib_borrow(this).unsafe_cast_ref())
2019        }
2020        unsafe {
2021            let f: Box_<F> = Box_::new(f);
2022            connect_raw(
2023                self.as_ptr() as *mut _,
2024                b"begin-user-action\0".as_ptr() as *const _,
2025                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2026                    begin_user_action_trampoline::<Self, F> as *const (),
2027                )),
2028                Box_::into_raw(f),
2029            )
2030        }
2031    }
2032
2033    /// Emitted when the content of a [`TextBuffer`][crate::TextBuffer] has changed.
2034    #[doc(alias = "changed")]
2035    fn connect_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2036        unsafe extern "C" fn changed_trampoline<P: IsA<TextBuffer>, F: Fn(&P) + 'static>(
2037            this: *mut ffi::GtkTextBuffer,
2038            f: glib::ffi::gpointer,
2039        ) {
2040            let f: &F = &*(f as *const F);
2041            f(TextBuffer::from_glib_borrow(this).unsafe_cast_ref())
2042        }
2043        unsafe {
2044            let f: Box_<F> = Box_::new(f);
2045            connect_raw(
2046                self.as_ptr() as *mut _,
2047                b"changed\0".as_ptr() as *const _,
2048                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2049                    changed_trampoline::<Self, F> as *const (),
2050                )),
2051                Box_::into_raw(f),
2052            )
2053        }
2054    }
2055
2056    /// Emitted to delete a range from a [`TextBuffer`][crate::TextBuffer].
2057    ///
2058    /// Note that if your handler runs before the default handler
2059    /// it must not invalidate the @start and @end iters (or has
2060    /// to revalidate them). The default signal handler revalidates
2061    /// the @start and @end iters to both point to the location
2062    /// where text was deleted. Handlers which run after the default
2063    /// handler (see g_signal_connect_after()) do not have access to
2064    /// the deleted text.
2065    ///
2066    /// See also: [`delete()`][Self::delete()].
2067    /// ## `start`
2068    /// the start of the range to be deleted
2069    /// ## `end`
2070    /// the end of the range to be deleted
2071    #[doc(alias = "delete-range")]
2072    fn connect_delete_range<F: Fn(&Self, &TextIter, &TextIter) + 'static>(
2073        &self,
2074        f: F,
2075    ) -> SignalHandlerId {
2076        unsafe extern "C" fn delete_range_trampoline<
2077            P: IsA<TextBuffer>,
2078            F: Fn(&P, &TextIter, &TextIter) + 'static,
2079        >(
2080            this: *mut ffi::GtkTextBuffer,
2081            start: *mut ffi::GtkTextIter,
2082            end: *mut ffi::GtkTextIter,
2083            f: glib::ffi::gpointer,
2084        ) {
2085            let f: &F = &*(f as *const F);
2086            f(
2087                TextBuffer::from_glib_borrow(this).unsafe_cast_ref(),
2088                &from_glib_borrow(start),
2089                &from_glib_borrow(end),
2090            )
2091        }
2092        unsafe {
2093            let f: Box_<F> = Box_::new(f);
2094            connect_raw(
2095                self.as_ptr() as *mut _,
2096                b"delete-range\0".as_ptr() as *const _,
2097                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2098                    delete_range_trampoline::<Self, F> as *const (),
2099                )),
2100                Box_::into_raw(f),
2101            )
2102        }
2103    }
2104
2105    /// Emitted at the end of a single user-visible
2106    /// operation on the [`TextBuffer`][crate::TextBuffer].
2107    ///
2108    /// See also:
2109    /// [`end_user_action()`][Self::end_user_action()],
2110    /// [`insert_interactive()`][Self::insert_interactive()],
2111    /// [`insert_range_interactive()`][Self::insert_range_interactive()],
2112    /// [`delete_interactive()`][Self::delete_interactive()],
2113    /// [`backspace()`][Self::backspace()],
2114    /// [`delete_selection()`][Self::delete_selection()],
2115    /// [`backspace()`][Self::backspace()].
2116    #[doc(alias = "end-user-action")]
2117    fn connect_end_user_action<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2118        unsafe extern "C" fn end_user_action_trampoline<P: IsA<TextBuffer>, F: Fn(&P) + 'static>(
2119            this: *mut ffi::GtkTextBuffer,
2120            f: glib::ffi::gpointer,
2121        ) {
2122            let f: &F = &*(f as *const F);
2123            f(TextBuffer::from_glib_borrow(this).unsafe_cast_ref())
2124        }
2125        unsafe {
2126            let f: Box_<F> = Box_::new(f);
2127            connect_raw(
2128                self.as_ptr() as *mut _,
2129                b"end-user-action\0".as_ptr() as *const _,
2130                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2131                    end_user_action_trampoline::<Self, F> as *const (),
2132                )),
2133                Box_::into_raw(f),
2134            )
2135        }
2136    }
2137
2138    /// Emitted to insert a [`TextChildAnchor`][crate::TextChildAnchor] in a [`TextBuffer`][crate::TextBuffer].
2139    ///
2140    /// Insertion actually occurs in the default handler.
2141    ///
2142    /// Note that if your handler runs before the default handler
2143    /// it must not invalidate the @location iter (or has to
2144    /// revalidate it). The default signal handler revalidates
2145    /// it to be placed after the inserted @anchor.
2146    ///
2147    /// See also: [`insert_child_anchor()`][Self::insert_child_anchor()].
2148    /// ## `location`
2149    /// position to insert @anchor in @textbuffer
2150    /// ## `anchor`
2151    /// the [`TextChildAnchor`][crate::TextChildAnchor] to be inserted
2152    #[doc(alias = "insert-child-anchor")]
2153    fn connect_insert_child_anchor<F: Fn(&Self, &TextIter, &TextChildAnchor) + 'static>(
2154        &self,
2155        f: F,
2156    ) -> SignalHandlerId {
2157        unsafe extern "C" fn insert_child_anchor_trampoline<
2158            P: IsA<TextBuffer>,
2159            F: Fn(&P, &TextIter, &TextChildAnchor) + 'static,
2160        >(
2161            this: *mut ffi::GtkTextBuffer,
2162            location: *mut ffi::GtkTextIter,
2163            anchor: *mut ffi::GtkTextChildAnchor,
2164            f: glib::ffi::gpointer,
2165        ) {
2166            let f: &F = &*(f as *const F);
2167            f(
2168                TextBuffer::from_glib_borrow(this).unsafe_cast_ref(),
2169                &from_glib_borrow(location),
2170                &from_glib_borrow(anchor),
2171            )
2172        }
2173        unsafe {
2174            let f: Box_<F> = Box_::new(f);
2175            connect_raw(
2176                self.as_ptr() as *mut _,
2177                b"insert-child-anchor\0".as_ptr() as *const _,
2178                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2179                    insert_child_anchor_trampoline::<Self, F> as *const (),
2180                )),
2181                Box_::into_raw(f),
2182            )
2183        }
2184    }
2185
2186    /// Emitted to insert a [`gdk::Paintable`][crate::gdk::Paintable] in a [`TextBuffer`][crate::TextBuffer].
2187    ///
2188    /// Insertion actually occurs in the default handler.
2189    ///
2190    /// Note that if your handler runs before the default handler
2191    /// it must not invalidate the @location iter (or has to
2192    /// revalidate it). The default signal handler revalidates
2193    /// it to be placed after the inserted @paintable.
2194    ///
2195    /// See also: [`insert_paintable()`][Self::insert_paintable()].
2196    /// ## `location`
2197    /// position to insert @paintable in @textbuffer
2198    /// ## `paintable`
2199    /// the [`gdk::Paintable`][crate::gdk::Paintable] to be inserted
2200    #[doc(alias = "insert-paintable")]
2201    fn connect_insert_paintable<F: Fn(&Self, &TextIter, &gdk::Paintable) + 'static>(
2202        &self,
2203        f: F,
2204    ) -> SignalHandlerId {
2205        unsafe extern "C" fn insert_paintable_trampoline<
2206            P: IsA<TextBuffer>,
2207            F: Fn(&P, &TextIter, &gdk::Paintable) + 'static,
2208        >(
2209            this: *mut ffi::GtkTextBuffer,
2210            location: *mut ffi::GtkTextIter,
2211            paintable: *mut gdk::ffi::GdkPaintable,
2212            f: glib::ffi::gpointer,
2213        ) {
2214            let f: &F = &*(f as *const F);
2215            f(
2216                TextBuffer::from_glib_borrow(this).unsafe_cast_ref(),
2217                &from_glib_borrow(location),
2218                &from_glib_borrow(paintable),
2219            )
2220        }
2221        unsafe {
2222            let f: Box_<F> = Box_::new(f);
2223            connect_raw(
2224                self.as_ptr() as *mut _,
2225                b"insert-paintable\0".as_ptr() as *const _,
2226                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2227                    insert_paintable_trampoline::<Self, F> as *const (),
2228                )),
2229                Box_::into_raw(f),
2230            )
2231        }
2232    }
2233
2234    /// Emitted as notification after a [`TextMark`][crate::TextMark] is deleted.
2235    ///
2236    /// See also: [`delete_mark()`][Self::delete_mark()].
2237    /// ## `mark`
2238    /// The mark that was deleted
2239    #[doc(alias = "mark-deleted")]
2240    fn connect_mark_deleted<F: Fn(&Self, &TextMark) + 'static>(&self, f: F) -> SignalHandlerId {
2241        unsafe extern "C" fn mark_deleted_trampoline<
2242            P: IsA<TextBuffer>,
2243            F: Fn(&P, &TextMark) + 'static,
2244        >(
2245            this: *mut ffi::GtkTextBuffer,
2246            mark: *mut ffi::GtkTextMark,
2247            f: glib::ffi::gpointer,
2248        ) {
2249            let f: &F = &*(f as *const F);
2250            f(
2251                TextBuffer::from_glib_borrow(this).unsafe_cast_ref(),
2252                &from_glib_borrow(mark),
2253            )
2254        }
2255        unsafe {
2256            let f: Box_<F> = Box_::new(f);
2257            connect_raw(
2258                self.as_ptr() as *mut _,
2259                b"mark-deleted\0".as_ptr() as *const _,
2260                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2261                    mark_deleted_trampoline::<Self, F> as *const (),
2262                )),
2263                Box_::into_raw(f),
2264            )
2265        }
2266    }
2267
2268    /// Emitted as notification after a [`TextMark`][crate::TextMark] is set.
2269    ///
2270    /// See also:
2271    /// [`create_mark()`][Self::create_mark()],
2272    /// [`move_mark()`][Self::move_mark()].
2273    /// ## `location`
2274    /// The location of @mark in @textbuffer
2275    /// ## `mark`
2276    /// The mark that is set
2277    #[doc(alias = "mark-set")]
2278    fn connect_mark_set<F: Fn(&Self, &TextIter, &TextMark) + 'static>(
2279        &self,
2280        f: F,
2281    ) -> SignalHandlerId {
2282        unsafe extern "C" fn mark_set_trampoline<
2283            P: IsA<TextBuffer>,
2284            F: Fn(&P, &TextIter, &TextMark) + 'static,
2285        >(
2286            this: *mut ffi::GtkTextBuffer,
2287            location: *mut ffi::GtkTextIter,
2288            mark: *mut ffi::GtkTextMark,
2289            f: glib::ffi::gpointer,
2290        ) {
2291            let f: &F = &*(f as *const F);
2292            f(
2293                TextBuffer::from_glib_borrow(this).unsafe_cast_ref(),
2294                &from_glib_borrow(location),
2295                &from_glib_borrow(mark),
2296            )
2297        }
2298        unsafe {
2299            let f: Box_<F> = Box_::new(f);
2300            connect_raw(
2301                self.as_ptr() as *mut _,
2302                b"mark-set\0".as_ptr() as *const _,
2303                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2304                    mark_set_trampoline::<Self, F> as *const (),
2305                )),
2306                Box_::into_raw(f),
2307            )
2308        }
2309    }
2310
2311    /// Emitted when the modified bit of a [`TextBuffer`][crate::TextBuffer] flips.
2312    ///
2313    /// See also: [`set_modified()`][Self::set_modified()].
2314    #[doc(alias = "modified-changed")]
2315    fn connect_modified_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2316        unsafe extern "C" fn modified_changed_trampoline<
2317            P: IsA<TextBuffer>,
2318            F: Fn(&P) + 'static,
2319        >(
2320            this: *mut ffi::GtkTextBuffer,
2321            f: glib::ffi::gpointer,
2322        ) {
2323            let f: &F = &*(f as *const F);
2324            f(TextBuffer::from_glib_borrow(this).unsafe_cast_ref())
2325        }
2326        unsafe {
2327            let f: Box_<F> = Box_::new(f);
2328            connect_raw(
2329                self.as_ptr() as *mut _,
2330                b"modified-changed\0".as_ptr() as *const _,
2331                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2332                    modified_changed_trampoline::<Self, F> as *const (),
2333                )),
2334                Box_::into_raw(f),
2335            )
2336        }
2337    }
2338
2339    /// Emitted after paste operation has been completed.
2340    ///
2341    /// This is useful to properly scroll the view to the end
2342    /// of the pasted text. See [`paste_clipboard()`][Self::paste_clipboard()]
2343    /// for more details.
2344    /// ## `clipboard`
2345    /// the [`gdk::Clipboard`][crate::gdk::Clipboard] pasted from
2346    #[doc(alias = "paste-done")]
2347    fn connect_paste_done<F: Fn(&Self, &gdk::Clipboard) + 'static>(&self, f: F) -> SignalHandlerId {
2348        unsafe extern "C" fn paste_done_trampoline<
2349            P: IsA<TextBuffer>,
2350            F: Fn(&P, &gdk::Clipboard) + 'static,
2351        >(
2352            this: *mut ffi::GtkTextBuffer,
2353            clipboard: *mut gdk::ffi::GdkClipboard,
2354            f: glib::ffi::gpointer,
2355        ) {
2356            let f: &F = &*(f as *const F);
2357            f(
2358                TextBuffer::from_glib_borrow(this).unsafe_cast_ref(),
2359                &from_glib_borrow(clipboard),
2360            )
2361        }
2362        unsafe {
2363            let f: Box_<F> = Box_::new(f);
2364            connect_raw(
2365                self.as_ptr() as *mut _,
2366                b"paste-done\0".as_ptr() as *const _,
2367                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2368                    paste_done_trampoline::<Self, F> as *const (),
2369                )),
2370                Box_::into_raw(f),
2371            )
2372        }
2373    }
2374
2375    /// Emitted when a request has been made to redo the
2376    /// previously undone operation.
2377    #[doc(alias = "redo")]
2378    fn connect_redo<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2379        unsafe extern "C" fn redo_trampoline<P: IsA<TextBuffer>, F: Fn(&P) + 'static>(
2380            this: *mut ffi::GtkTextBuffer,
2381            f: glib::ffi::gpointer,
2382        ) {
2383            let f: &F = &*(f as *const F);
2384            f(TextBuffer::from_glib_borrow(this).unsafe_cast_ref())
2385        }
2386        unsafe {
2387            let f: Box_<F> = Box_::new(f);
2388            connect_raw(
2389                self.as_ptr() as *mut _,
2390                b"redo\0".as_ptr() as *const _,
2391                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2392                    redo_trampoline::<Self, F> as *const (),
2393                )),
2394                Box_::into_raw(f),
2395            )
2396        }
2397    }
2398
2399    /// Emitted to remove all occurrences of @tag from a range
2400    /// of text in a [`TextBuffer`][crate::TextBuffer].
2401    ///
2402    /// Removal actually occurs in the default handler.
2403    ///
2404    /// Note that if your handler runs before the default handler
2405    /// it must not invalidate the @start and @end iters (or has
2406    /// to revalidate them).
2407    ///
2408    /// See also: [`remove_tag()`][Self::remove_tag()].
2409    /// ## `tag`
2410    /// the tag to be removed
2411    /// ## `start`
2412    /// the start of the range the tag is removed from
2413    /// ## `end`
2414    /// the end of the range the tag is removed from
2415    #[doc(alias = "remove-tag")]
2416    fn connect_remove_tag<F: Fn(&Self, &TextTag, &TextIter, &TextIter) + 'static>(
2417        &self,
2418        f: F,
2419    ) -> SignalHandlerId {
2420        unsafe extern "C" fn remove_tag_trampoline<
2421            P: IsA<TextBuffer>,
2422            F: Fn(&P, &TextTag, &TextIter, &TextIter) + 'static,
2423        >(
2424            this: *mut ffi::GtkTextBuffer,
2425            tag: *mut ffi::GtkTextTag,
2426            start: *mut ffi::GtkTextIter,
2427            end: *mut ffi::GtkTextIter,
2428            f: glib::ffi::gpointer,
2429        ) {
2430            let f: &F = &*(f as *const F);
2431            f(
2432                TextBuffer::from_glib_borrow(this).unsafe_cast_ref(),
2433                &from_glib_borrow(tag),
2434                &from_glib_borrow(start),
2435                &from_glib_borrow(end),
2436            )
2437        }
2438        unsafe {
2439            let f: Box_<F> = Box_::new(f);
2440            connect_raw(
2441                self.as_ptr() as *mut _,
2442                b"remove-tag\0".as_ptr() as *const _,
2443                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2444                    remove_tag_trampoline::<Self, F> as *const (),
2445                )),
2446                Box_::into_raw(f),
2447            )
2448        }
2449    }
2450
2451    /// Emitted when a request has been made to undo the
2452    /// previous operation or set of operations that have
2453    /// been grouped together.
2454    #[doc(alias = "undo")]
2455    fn connect_undo<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2456        unsafe extern "C" fn undo_trampoline<P: IsA<TextBuffer>, F: Fn(&P) + 'static>(
2457            this: *mut ffi::GtkTextBuffer,
2458            f: glib::ffi::gpointer,
2459        ) {
2460            let f: &F = &*(f as *const F);
2461            f(TextBuffer::from_glib_borrow(this).unsafe_cast_ref())
2462        }
2463        unsafe {
2464            let f: Box_<F> = Box_::new(f);
2465            connect_raw(
2466                self.as_ptr() as *mut _,
2467                b"undo\0".as_ptr() as *const _,
2468                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2469                    undo_trampoline::<Self, F> as *const (),
2470                )),
2471                Box_::into_raw(f),
2472            )
2473        }
2474    }
2475
2476    #[doc(alias = "can-redo")]
2477    fn connect_can_redo_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2478        unsafe extern "C" fn notify_can_redo_trampoline<P: IsA<TextBuffer>, F: Fn(&P) + 'static>(
2479            this: *mut ffi::GtkTextBuffer,
2480            _param_spec: glib::ffi::gpointer,
2481            f: glib::ffi::gpointer,
2482        ) {
2483            let f: &F = &*(f as *const F);
2484            f(TextBuffer::from_glib_borrow(this).unsafe_cast_ref())
2485        }
2486        unsafe {
2487            let f: Box_<F> = Box_::new(f);
2488            connect_raw(
2489                self.as_ptr() as *mut _,
2490                b"notify::can-redo\0".as_ptr() as *const _,
2491                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2492                    notify_can_redo_trampoline::<Self, F> as *const (),
2493                )),
2494                Box_::into_raw(f),
2495            )
2496        }
2497    }
2498
2499    #[doc(alias = "can-undo")]
2500    fn connect_can_undo_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2501        unsafe extern "C" fn notify_can_undo_trampoline<P: IsA<TextBuffer>, F: Fn(&P) + 'static>(
2502            this: *mut ffi::GtkTextBuffer,
2503            _param_spec: glib::ffi::gpointer,
2504            f: glib::ffi::gpointer,
2505        ) {
2506            let f: &F = &*(f as *const F);
2507            f(TextBuffer::from_glib_borrow(this).unsafe_cast_ref())
2508        }
2509        unsafe {
2510            let f: Box_<F> = Box_::new(f);
2511            connect_raw(
2512                self.as_ptr() as *mut _,
2513                b"notify::can-undo\0".as_ptr() as *const _,
2514                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2515                    notify_can_undo_trampoline::<Self, F> as *const (),
2516                )),
2517                Box_::into_raw(f),
2518            )
2519        }
2520    }
2521
2522    #[doc(alias = "cursor-position")]
2523    fn connect_cursor_position_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2524        unsafe extern "C" fn notify_cursor_position_trampoline<
2525            P: IsA<TextBuffer>,
2526            F: Fn(&P) + 'static,
2527        >(
2528            this: *mut ffi::GtkTextBuffer,
2529            _param_spec: glib::ffi::gpointer,
2530            f: glib::ffi::gpointer,
2531        ) {
2532            let f: &F = &*(f as *const F);
2533            f(TextBuffer::from_glib_borrow(this).unsafe_cast_ref())
2534        }
2535        unsafe {
2536            let f: Box_<F> = Box_::new(f);
2537            connect_raw(
2538                self.as_ptr() as *mut _,
2539                b"notify::cursor-position\0".as_ptr() as *const _,
2540                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2541                    notify_cursor_position_trampoline::<Self, F> as *const (),
2542                )),
2543                Box_::into_raw(f),
2544            )
2545        }
2546    }
2547
2548    #[doc(alias = "enable-undo")]
2549    fn connect_enable_undo_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2550        unsafe extern "C" fn notify_enable_undo_trampoline<
2551            P: IsA<TextBuffer>,
2552            F: Fn(&P) + 'static,
2553        >(
2554            this: *mut ffi::GtkTextBuffer,
2555            _param_spec: glib::ffi::gpointer,
2556            f: glib::ffi::gpointer,
2557        ) {
2558            let f: &F = &*(f as *const F);
2559            f(TextBuffer::from_glib_borrow(this).unsafe_cast_ref())
2560        }
2561        unsafe {
2562            let f: Box_<F> = Box_::new(f);
2563            connect_raw(
2564                self.as_ptr() as *mut _,
2565                b"notify::enable-undo\0".as_ptr() as *const _,
2566                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2567                    notify_enable_undo_trampoline::<Self, F> as *const (),
2568                )),
2569                Box_::into_raw(f),
2570            )
2571        }
2572    }
2573
2574    #[doc(alias = "has-selection")]
2575    fn connect_has_selection_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2576        unsafe extern "C" fn notify_has_selection_trampoline<
2577            P: IsA<TextBuffer>,
2578            F: Fn(&P) + 'static,
2579        >(
2580            this: *mut ffi::GtkTextBuffer,
2581            _param_spec: glib::ffi::gpointer,
2582            f: glib::ffi::gpointer,
2583        ) {
2584            let f: &F = &*(f as *const F);
2585            f(TextBuffer::from_glib_borrow(this).unsafe_cast_ref())
2586        }
2587        unsafe {
2588            let f: Box_<F> = Box_::new(f);
2589            connect_raw(
2590                self.as_ptr() as *mut _,
2591                b"notify::has-selection\0".as_ptr() as *const _,
2592                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2593                    notify_has_selection_trampoline::<Self, F> as *const (),
2594                )),
2595                Box_::into_raw(f),
2596            )
2597        }
2598    }
2599
2600    #[doc(alias = "text")]
2601    fn connect_text_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2602        unsafe extern "C" fn notify_text_trampoline<P: IsA<TextBuffer>, F: Fn(&P) + 'static>(
2603            this: *mut ffi::GtkTextBuffer,
2604            _param_spec: glib::ffi::gpointer,
2605            f: glib::ffi::gpointer,
2606        ) {
2607            let f: &F = &*(f as *const F);
2608            f(TextBuffer::from_glib_borrow(this).unsafe_cast_ref())
2609        }
2610        unsafe {
2611            let f: Box_<F> = Box_::new(f);
2612            connect_raw(
2613                self.as_ptr() as *mut _,
2614                b"notify::text\0".as_ptr() as *const _,
2615                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2616                    notify_text_trampoline::<Self, F> as *const (),
2617                )),
2618                Box_::into_raw(f),
2619            )
2620        }
2621    }
2622}
2623
2624impl<O: IsA<TextBuffer>> TextBufferExt for O {}