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