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::{TextChildAnchor, TextIter, TextMark, TextTag, TextTagTable, ffi};
6use glib::{
7 object::ObjectType as _,
8 prelude::*,
9 signal::{SignalHandlerId, connect_raw},
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 { Some(iter) } else { None }
973 }
974 }
975
976 /// Obtains an iterator pointing to @byte_index within the given line.
977 ///
978 /// @byte_index must be the start of a UTF-8 character. Note bytes, not
979 /// characters; UTF-8 may encode one character as multiple bytes.
980 ///
981 /// If @line_number is greater than or equal to the number of lines in the @self,
982 /// the end iterator is returned. And if @byte_index is off the
983 /// end of the line, the iterator at the end of the line is returned.
984 /// ## `line_number`
985 /// line number counting from 0
986 /// ## `byte_index`
987 /// byte index from start of line
988 ///
989 /// # Returns
990 ///
991 /// whether the exact position has been found
992 ///
993 /// ## `iter`
994 /// iterator to initialize
995 #[doc(alias = "gtk_text_buffer_get_iter_at_line_index")]
996 #[doc(alias = "get_iter_at_line_index")]
997 fn iter_at_line_index(&self, line_number: i32, byte_index: i32) -> Option<TextIter> {
998 unsafe {
999 let mut iter = TextIter::uninitialized();
1000 let ret = from_glib(ffi::gtk_text_buffer_get_iter_at_line_index(
1001 self.as_ref().to_glib_none().0,
1002 iter.to_glib_none_mut().0,
1003 line_number,
1004 byte_index,
1005 ));
1006 if ret { Some(iter) } else { None }
1007 }
1008 }
1009
1010 /// Obtains an iterator pointing to @char_offset within the given line.
1011 ///
1012 /// Note characters, not bytes; UTF-8 may encode one character as multiple
1013 /// bytes.
1014 ///
1015 /// If @line_number is greater than or equal to the number of lines in the @self,
1016 /// the end iterator is returned. And if @char_offset is off the
1017 /// end of the line, the iterator at the end of the line is returned.
1018 /// ## `line_number`
1019 /// line number counting from 0
1020 /// ## `char_offset`
1021 /// char offset from start of line
1022 ///
1023 /// # Returns
1024 ///
1025 /// whether the exact position has been found
1026 ///
1027 /// ## `iter`
1028 /// iterator to initialize
1029 #[doc(alias = "gtk_text_buffer_get_iter_at_line_offset")]
1030 #[doc(alias = "get_iter_at_line_offset")]
1031 fn iter_at_line_offset(&self, line_number: i32, char_offset: i32) -> Option<TextIter> {
1032 unsafe {
1033 let mut iter = TextIter::uninitialized();
1034 let ret = from_glib(ffi::gtk_text_buffer_get_iter_at_line_offset(
1035 self.as_ref().to_glib_none().0,
1036 iter.to_glib_none_mut().0,
1037 line_number,
1038 char_offset,
1039 ));
1040 if ret { Some(iter) } else { None }
1041 }
1042 }
1043
1044 /// Initializes @iter with the current position of @mark.
1045 /// ## `mark`
1046 /// a [`TextMark`][crate::TextMark] in @self
1047 ///
1048 /// # Returns
1049 ///
1050 ///
1051 /// ## `iter`
1052 /// iterator to initialize
1053 #[doc(alias = "gtk_text_buffer_get_iter_at_mark")]
1054 #[doc(alias = "get_iter_at_mark")]
1055 fn iter_at_mark(&self, mark: &impl IsA<TextMark>) -> TextIter {
1056 unsafe {
1057 let mut iter = TextIter::uninitialized();
1058 ffi::gtk_text_buffer_get_iter_at_mark(
1059 self.as_ref().to_glib_none().0,
1060 iter.to_glib_none_mut().0,
1061 mark.as_ref().to_glib_none().0,
1062 );
1063 iter
1064 }
1065 }
1066
1067 /// Initializes @iter to a position @char_offset chars from the start
1068 /// of the entire buffer.
1069 ///
1070 /// If @char_offset is -1 or greater than the number
1071 /// of characters in the buffer, @iter is initialized to the end iterator,
1072 /// the iterator one past the last valid character in the buffer.
1073 /// ## `char_offset`
1074 /// char offset from start of buffer, counting from 0, or -1
1075 ///
1076 /// # Returns
1077 ///
1078 ///
1079 /// ## `iter`
1080 /// iterator to initialize
1081 #[doc(alias = "gtk_text_buffer_get_iter_at_offset")]
1082 #[doc(alias = "get_iter_at_offset")]
1083 fn iter_at_offset(&self, char_offset: i32) -> TextIter {
1084 unsafe {
1085 let mut iter = TextIter::uninitialized();
1086 ffi::gtk_text_buffer_get_iter_at_offset(
1087 self.as_ref().to_glib_none().0,
1088 iter.to_glib_none_mut().0,
1089 char_offset,
1090 );
1091 iter
1092 }
1093 }
1094
1095 /// Obtains the number of lines in the buffer.
1096 ///
1097 /// This value is cached, so the function is very fast.
1098 ///
1099 /// # Returns
1100 ///
1101 /// number of lines in the buffer
1102 #[doc(alias = "gtk_text_buffer_get_line_count")]
1103 #[doc(alias = "get_line_count")]
1104 fn line_count(&self) -> i32 {
1105 unsafe { ffi::gtk_text_buffer_get_line_count(self.as_ref().to_glib_none().0) }
1106 }
1107
1108 /// Returns the mark named @name in buffer @self, or [`None`] if no such
1109 /// mark exists in the buffer.
1110 /// ## `name`
1111 /// a mark name
1112 ///
1113 /// # Returns
1114 ///
1115 /// a [`TextMark`][crate::TextMark]
1116 #[doc(alias = "gtk_text_buffer_get_mark")]
1117 #[doc(alias = "get_mark")]
1118 fn mark(&self, name: &str) -> Option<TextMark> {
1119 unsafe {
1120 from_glib_none(ffi::gtk_text_buffer_get_mark(
1121 self.as_ref().to_glib_none().0,
1122 name.to_glib_none().0,
1123 ))
1124 }
1125 }
1126
1127 /// Gets the maximum number of undo levels to perform.
1128 ///
1129 /// If 0, unlimited undo actions may be performed. Note that this may
1130 /// have a memory usage impact as it requires storing an additional
1131 /// copy of the inserted or removed text within the text buffer.
1132 ///
1133 /// # Returns
1134 ///
1135 /// The max number of undo levels allowed (0 indicates unlimited).
1136 #[doc(alias = "gtk_text_buffer_get_max_undo_levels")]
1137 #[doc(alias = "get_max_undo_levels")]
1138 fn max_undo_levels(&self) -> u32 {
1139 unsafe { ffi::gtk_text_buffer_get_max_undo_levels(self.as_ref().to_glib_none().0) }
1140 }
1141
1142 /// Indicates whether the buffer has been modified since the last call
1143 /// to [`set_modified()`][Self::set_modified()] set the modification flag to
1144 /// [`false`].
1145 ///
1146 /// Used for example to enable a “save” function in a text editor.
1147 ///
1148 /// # Returns
1149 ///
1150 /// [`true`] if the buffer has been modified
1151 #[doc(alias = "gtk_text_buffer_get_modified")]
1152 #[doc(alias = "get_modified")]
1153 fn is_modified(&self) -> bool {
1154 unsafe {
1155 from_glib(ffi::gtk_text_buffer_get_modified(
1156 self.as_ref().to_glib_none().0,
1157 ))
1158 }
1159 }
1160
1161 /// Returns the mark that represents the selection bound.
1162 ///
1163 /// Equivalent to calling [`mark()`][Self::mark()]
1164 /// to get the mark named “selection_bound”, but very slightly
1165 /// more efficient, and involves less typing.
1166 ///
1167 /// The currently-selected text in @self is the region between the
1168 /// “selection_bound” and “insert” marks. If “selection_bound” and
1169 /// “insert” are in the same place, then there is no current selection.
1170 /// [`selection_bounds()`][Self::selection_bounds()] is another convenient
1171 /// function for handling the selection, if you just want to know whether
1172 /// there’s a selection and what its bounds are.
1173 ///
1174 /// # Returns
1175 ///
1176 /// selection bound mark
1177 #[doc(alias = "gtk_text_buffer_get_selection_bound")]
1178 #[doc(alias = "get_selection_bound")]
1179 fn selection_bound(&self) -> TextMark {
1180 unsafe {
1181 from_glib_none(ffi::gtk_text_buffer_get_selection_bound(
1182 self.as_ref().to_glib_none().0,
1183 ))
1184 }
1185 }
1186
1187 /// Returns [`true`] if some text is selected; places the bounds
1188 /// of the selection in @start and @end.
1189 ///
1190 /// If the selection has length 0, then @start and @end are filled
1191 /// in with the same value. @start and @end will be in ascending order.
1192 /// If @start and @end are [`None`], then they are not filled in, but the
1193 /// return value still indicates whether text is selected.
1194 ///
1195 /// # Returns
1196 ///
1197 /// whether the selection has nonzero length
1198 ///
1199 /// ## `start`
1200 /// iterator to initialize with selection start
1201 ///
1202 /// ## `end`
1203 /// iterator to initialize with selection end
1204 #[doc(alias = "gtk_text_buffer_get_selection_bounds")]
1205 #[doc(alias = "get_selection_bounds")]
1206 fn selection_bounds(&self) -> Option<(TextIter, TextIter)> {
1207 unsafe {
1208 let mut start = TextIter::uninitialized();
1209 let mut end = TextIter::uninitialized();
1210 let ret = from_glib(ffi::gtk_text_buffer_get_selection_bounds(
1211 self.as_ref().to_glib_none().0,
1212 start.to_glib_none_mut().0,
1213 end.to_glib_none_mut().0,
1214 ));
1215 if ret { Some((start, end)) } else { None }
1216 }
1217 }
1218
1219 /// Get a content provider for this buffer.
1220 ///
1221 /// It can be used to make the content of @self available
1222 /// in a [`gdk::Clipboard`][crate::gdk::Clipboard], see [`Clipboard::set_content()`][crate::gdk::Clipboard::set_content()].
1223 ///
1224 /// # Returns
1225 ///
1226 /// a new [`gdk::ContentProvider`][crate::gdk::ContentProvider].
1227 #[doc(alias = "gtk_text_buffer_get_selection_content")]
1228 #[doc(alias = "get_selection_content")]
1229 fn selection_content(&self) -> gdk::ContentProvider {
1230 unsafe {
1231 from_glib_full(ffi::gtk_text_buffer_get_selection_content(
1232 self.as_ref().to_glib_none().0,
1233 ))
1234 }
1235 }
1236
1237 /// Returns the text in the range [@start,@end).
1238 ///
1239 /// Excludes undisplayed text (text marked with tags that set the
1240 /// invisibility attribute) if @include_hidden_chars is [`false`].
1241 /// The returned string includes a 0xFFFC character whenever the
1242 /// buffer contains embedded images, so byte and character indexes
1243 /// into the returned string do correspond to byte and character
1244 /// indexes into the buffer. Contrast with [`text()`][Self::text()].
1245 /// Note that 0xFFFC can occur in normal text as well, so it is not a
1246 /// reliable indicator that a paintable or widget is in the buffer.
1247 /// ## `start`
1248 /// start of a range
1249 /// ## `end`
1250 /// end of a range
1251 /// ## `include_hidden_chars`
1252 /// whether to include invisible text
1253 ///
1254 /// # Returns
1255 ///
1256 /// an allocated UTF-8 string
1257 #[doc(alias = "gtk_text_buffer_get_slice")]
1258 #[doc(alias = "get_slice")]
1259 fn slice(&self, start: &TextIter, end: &TextIter, include_hidden_chars: bool) -> glib::GString {
1260 unsafe {
1261 from_glib_full(ffi::gtk_text_buffer_get_slice(
1262 self.as_ref().to_glib_none().0,
1263 start.to_glib_none().0,
1264 end.to_glib_none().0,
1265 include_hidden_chars.into_glib(),
1266 ))
1267 }
1268 }
1269
1270 /// Initialized @iter with the first position in the text buffer.
1271 ///
1272 /// This is the same as using [`iter_at_offset()`][Self::iter_at_offset()]
1273 /// to get the iter at character offset 0.
1274 ///
1275 /// # Returns
1276 ///
1277 ///
1278 /// ## `iter`
1279 /// iterator to initialize
1280 #[doc(alias = "gtk_text_buffer_get_start_iter")]
1281 #[doc(alias = "get_start_iter")]
1282 fn start_iter(&self) -> TextIter {
1283 unsafe {
1284 let mut iter = TextIter::uninitialized();
1285 ffi::gtk_text_buffer_get_start_iter(
1286 self.as_ref().to_glib_none().0,
1287 iter.to_glib_none_mut().0,
1288 );
1289 iter
1290 }
1291 }
1292
1293 /// Get the [`TextTagTable`][crate::TextTagTable] associated with this buffer.
1294 ///
1295 /// # Returns
1296 ///
1297 /// the buffer’s tag table
1298 #[doc(alias = "gtk_text_buffer_get_tag_table")]
1299 #[doc(alias = "get_tag_table")]
1300 #[doc(alias = "tag-table")]
1301 fn tag_table(&self) -> TextTagTable {
1302 unsafe {
1303 from_glib_none(ffi::gtk_text_buffer_get_tag_table(
1304 self.as_ref().to_glib_none().0,
1305 ))
1306 }
1307 }
1308
1309 /// Returns the text in the range [@start,@end).
1310 ///
1311 /// Excludes undisplayed text (text marked with tags that set the
1312 /// invisibility attribute) if @include_hidden_chars is [`false`].
1313 /// Does not include characters representing embedded images, so
1314 /// byte and character indexes into the returned string do not
1315 /// correspond to byte and character indexes into the buffer.
1316 /// Contrast with [`slice()`][Self::slice()].
1317 /// ## `start`
1318 /// start of a range
1319 /// ## `end`
1320 /// end of a range
1321 /// ## `include_hidden_chars`
1322 /// whether to include invisible text
1323 ///
1324 /// # Returns
1325 ///
1326 /// an allocated UTF-8 string
1327 #[doc(alias = "gtk_text_buffer_get_text")]
1328 #[doc(alias = "get_text")]
1329 fn text(&self, start: &TextIter, end: &TextIter, include_hidden_chars: bool) -> glib::GString {
1330 unsafe {
1331 from_glib_full(ffi::gtk_text_buffer_get_text(
1332 self.as_ref().to_glib_none().0,
1333 start.to_glib_none().0,
1334 end.to_glib_none().0,
1335 include_hidden_chars.into_glib(),
1336 ))
1337 }
1338 }
1339
1340 /// Inserts @len bytes of @text at position @iter.
1341 ///
1342 /// If @len is -1, @text must be nul-terminated and will be inserted in its
1343 /// entirety. Emits the “insert-text” signal; insertion actually occurs
1344 /// in the default handler for the signal. @iter is invalidated when
1345 /// insertion occurs (because the buffer contents change), but the
1346 /// default signal handler revalidates it to point to the end of the
1347 /// inserted text.
1348 /// ## `iter`
1349 /// a position in the buffer
1350 /// ## `text`
1351 /// text in UTF-8 format
1352 /// ## `len`
1353 /// length of text in bytes, or -1
1354 #[doc(alias = "gtk_text_buffer_insert")]
1355 fn insert(&self, iter: &mut TextIter, text: &str) {
1356 let len = text.len() as _;
1357 unsafe {
1358 ffi::gtk_text_buffer_insert(
1359 self.as_ref().to_glib_none().0,
1360 iter.to_glib_none_mut().0,
1361 text.to_glib_none().0,
1362 len,
1363 );
1364 }
1365 }
1366
1367 /// Inserts @text in @self.
1368 ///
1369 /// Simply calls [`insert()`][Self::insert()],
1370 /// using the current cursor position as the insertion point.
1371 /// ## `text`
1372 /// text in UTF-8 format
1373 /// ## `len`
1374 /// length of text, in bytes
1375 #[doc(alias = "gtk_text_buffer_insert_at_cursor")]
1376 fn insert_at_cursor(&self, text: &str) {
1377 let len = text.len() as _;
1378 unsafe {
1379 ffi::gtk_text_buffer_insert_at_cursor(
1380 self.as_ref().to_glib_none().0,
1381 text.to_glib_none().0,
1382 len,
1383 );
1384 }
1385 }
1386
1387 /// Inserts a child widget anchor into the text buffer at @iter.
1388 ///
1389 /// The anchor will be counted as one character in character counts, and
1390 /// when obtaining the buffer contents as a string, will be represented
1391 /// by the Unicode “object replacement character” 0xFFFC. Note that the
1392 /// “slice” variants for obtaining portions of the buffer as a string
1393 /// include this character for child anchors, but the “text” variants do
1394 /// not. E.g. see [`slice()`][Self::slice()] and
1395 /// [`text()`][Self::text()].
1396 ///
1397 /// Consider [`create_child_anchor()`][Self::create_child_anchor()] as a more
1398 /// convenient alternative to this function. The buffer will add a
1399 /// reference to the anchor, so you can unref it after insertion.
1400 /// ## `iter`
1401 /// location to insert the anchor
1402 /// ## `anchor`
1403 /// a [`TextChildAnchor`][crate::TextChildAnchor]
1404 #[doc(alias = "gtk_text_buffer_insert_child_anchor")]
1405 fn insert_child_anchor(&self, iter: &mut TextIter, anchor: &impl IsA<TextChildAnchor>) {
1406 unsafe {
1407 ffi::gtk_text_buffer_insert_child_anchor(
1408 self.as_ref().to_glib_none().0,
1409 iter.to_glib_none_mut().0,
1410 anchor.as_ref().to_glib_none().0,
1411 );
1412 }
1413 }
1414
1415 /// Inserts @text in @self.
1416 ///
1417 /// Like [`insert()`][Self::insert()], but the insertion will not occur
1418 /// if @iter is at a non-editable location in the buffer. Usually you
1419 /// want to prevent insertions at ineditable locations if the insertion
1420 /// results from a user action (is interactive).
1421 ///
1422 /// @default_editable indicates the editability of text that doesn't
1423 /// have a tag affecting editability applied to it. Typically the
1424 /// result of [`TextViewExt::is_editable()`][crate::prelude::TextViewExt::is_editable()] is appropriate here.
1425 /// ## `iter`
1426 /// a position in @self
1427 /// ## `text`
1428 /// some UTF-8 text
1429 /// ## `len`
1430 /// length of text in bytes, or -1
1431 /// ## `default_editable`
1432 /// default editability of buffer
1433 ///
1434 /// # Returns
1435 ///
1436 /// whether text was actually inserted
1437 #[doc(alias = "gtk_text_buffer_insert_interactive")]
1438 fn insert_interactive(&self, iter: &mut TextIter, text: &str, default_editable: bool) -> bool {
1439 let len = text.len() as _;
1440 unsafe {
1441 from_glib(ffi::gtk_text_buffer_insert_interactive(
1442 self.as_ref().to_glib_none().0,
1443 iter.to_glib_none_mut().0,
1444 text.to_glib_none().0,
1445 len,
1446 default_editable.into_glib(),
1447 ))
1448 }
1449 }
1450
1451 /// Inserts @text in @self.
1452 ///
1453 /// Calls [`insert_interactive()`][Self::insert_interactive()]
1454 /// at the cursor position.
1455 ///
1456 /// @default_editable indicates the editability of text that doesn't
1457 /// have a tag affecting editability applied to it. Typically the
1458 /// result of [`TextViewExt::is_editable()`][crate::prelude::TextViewExt::is_editable()] is appropriate here.
1459 /// ## `text`
1460 /// text in UTF-8 format
1461 /// ## `len`
1462 /// length of text in bytes, or -1
1463 /// ## `default_editable`
1464 /// default editability of buffer
1465 ///
1466 /// # Returns
1467 ///
1468 /// whether text was actually inserted
1469 #[doc(alias = "gtk_text_buffer_insert_interactive_at_cursor")]
1470 fn insert_interactive_at_cursor(&self, text: &str, default_editable: bool) -> bool {
1471 let len = text.len() as _;
1472 unsafe {
1473 from_glib(ffi::gtk_text_buffer_insert_interactive_at_cursor(
1474 self.as_ref().to_glib_none().0,
1475 text.to_glib_none().0,
1476 len,
1477 default_editable.into_glib(),
1478 ))
1479 }
1480 }
1481
1482 /// Inserts the text in @markup at position @iter.
1483 ///
1484 /// @markup will be inserted in its entirety and must be nul-terminated
1485 /// and valid UTF-8. Emits the [`insert-text`][struct@crate::TextBuffer#insert-text] signal,
1486 /// possibly multiple times; insertion actually occurs in the default handler
1487 /// for the signal. @iter will point to the end of the inserted text on return.
1488 /// ## `iter`
1489 /// location to insert the markup
1490 /// ## `markup`
1491 /// a nul-terminated UTF-8 string containing Pango markup
1492 /// ## `len`
1493 /// length of @markup in bytes, or -1
1494 #[doc(alias = "gtk_text_buffer_insert_markup")]
1495 fn insert_markup(&self, iter: &mut TextIter, markup: &str) {
1496 let len = markup.len() as _;
1497 unsafe {
1498 ffi::gtk_text_buffer_insert_markup(
1499 self.as_ref().to_glib_none().0,
1500 iter.to_glib_none_mut().0,
1501 markup.to_glib_none().0,
1502 len,
1503 );
1504 }
1505 }
1506
1507 /// Inserts an image into the text buffer at @iter.
1508 ///
1509 /// The image will be counted as one character in character counts,
1510 /// and when obtaining the buffer contents as a string, will be
1511 /// represented by the Unicode “object replacement character” 0xFFFC.
1512 /// Note that the “slice” variants for obtaining portions of the buffer
1513 /// as a string include this character for paintable, but the “text”
1514 /// variants do not. e.g. see [`slice()`][Self::slice()] and
1515 /// [`text()`][Self::text()].
1516 /// ## `iter`
1517 /// location to insert the paintable
1518 /// ## `paintable`
1519 /// a [`gdk::Paintable`][crate::gdk::Paintable]
1520 #[doc(alias = "gtk_text_buffer_insert_paintable")]
1521 fn insert_paintable(&self, iter: &mut TextIter, paintable: &impl IsA<gdk::Paintable>) {
1522 unsafe {
1523 ffi::gtk_text_buffer_insert_paintable(
1524 self.as_ref().to_glib_none().0,
1525 iter.to_glib_none_mut().0,
1526 paintable.as_ref().to_glib_none().0,
1527 );
1528 }
1529 }
1530
1531 /// Copies text, tags, and paintables between @start and @end
1532 /// and inserts the copy at @iter.
1533 ///
1534 /// The order of @start and @end doesn’t matter.
1535 ///
1536 /// Used instead of simply getting/inserting text because it preserves
1537 /// images and tags. If @start and @end are in a different buffer from
1538 /// @self, the two buffers must share the same tag table.
1539 ///
1540 /// Implemented via emissions of the ::insert-text and ::apply-tag signals,
1541 /// so expect those.
1542 /// ## `iter`
1543 /// a position in @self
1544 /// ## `start`
1545 /// a position in a [`TextBuffer`][crate::TextBuffer]
1546 /// ## `end`
1547 /// another position in the same buffer as @start
1548 #[doc(alias = "gtk_text_buffer_insert_range")]
1549 fn insert_range(&self, iter: &mut TextIter, start: &TextIter, end: &TextIter) {
1550 unsafe {
1551 ffi::gtk_text_buffer_insert_range(
1552 self.as_ref().to_glib_none().0,
1553 iter.to_glib_none_mut().0,
1554 start.to_glib_none().0,
1555 end.to_glib_none().0,
1556 );
1557 }
1558 }
1559
1560 /// Copies text, tags, and paintables between @start and @end
1561 /// and inserts the copy at @iter.
1562 ///
1563 /// Same as [`insert_range()`][Self::insert_range()], but does nothing
1564 /// if the insertion point isn’t editable. The @default_editable
1565 /// parameter indicates whether the text is editable at @iter if
1566 /// no tags enclosing @iter affect editability. Typically the result
1567 /// of [`TextViewExt::is_editable()`][crate::prelude::TextViewExt::is_editable()] is appropriate here.
1568 /// ## `iter`
1569 /// a position in @self
1570 /// ## `start`
1571 /// a position in a [`TextBuffer`][crate::TextBuffer]
1572 /// ## `end`
1573 /// another position in the same buffer as @start
1574 /// ## `default_editable`
1575 /// default editability of the buffer
1576 ///
1577 /// # Returns
1578 ///
1579 /// whether an insertion was possible at @iter
1580 #[doc(alias = "gtk_text_buffer_insert_range_interactive")]
1581 fn insert_range_interactive(
1582 &self,
1583 iter: &mut TextIter,
1584 start: &TextIter,
1585 end: &TextIter,
1586 default_editable: bool,
1587 ) -> bool {
1588 unsafe {
1589 from_glib(ffi::gtk_text_buffer_insert_range_interactive(
1590 self.as_ref().to_glib_none().0,
1591 iter.to_glib_none_mut().0,
1592 start.to_glib_none().0,
1593 end.to_glib_none().0,
1594 default_editable.into_glib(),
1595 ))
1596 }
1597 }
1598
1599 /// Moves @mark to the new location @where_.
1600 ///
1601 /// Emits the [`mark-set`][struct@crate::TextBuffer#mark-set] signal
1602 /// as notification of the move.
1603 /// ## `mark`
1604 /// a [`TextMark`][crate::TextMark]
1605 /// ## `where_`
1606 /// new location for @mark in @self
1607 #[doc(alias = "gtk_text_buffer_move_mark")]
1608 fn move_mark(&self, mark: &impl IsA<TextMark>, where_: &TextIter) {
1609 unsafe {
1610 ffi::gtk_text_buffer_move_mark(
1611 self.as_ref().to_glib_none().0,
1612 mark.as_ref().to_glib_none().0,
1613 where_.to_glib_none().0,
1614 );
1615 }
1616 }
1617
1618 /// Moves the mark named @name (which must exist) to location @where_.
1619 ///
1620 /// See [`move_mark()`][Self::move_mark()] for details.
1621 /// ## `name`
1622 /// name of a mark
1623 /// ## `where_`
1624 /// new location for mark
1625 #[doc(alias = "gtk_text_buffer_move_mark_by_name")]
1626 fn move_mark_by_name(&self, name: &str, where_: &TextIter) {
1627 unsafe {
1628 ffi::gtk_text_buffer_move_mark_by_name(
1629 self.as_ref().to_glib_none().0,
1630 name.to_glib_none().0,
1631 where_.to_glib_none().0,
1632 );
1633 }
1634 }
1635
1636 /// Pastes the contents of a clipboard.
1637 ///
1638 /// If @override_location is [`None`], the pasted text will be inserted
1639 /// at the cursor position, or the buffer selection will be replaced
1640 /// if the selection is non-empty.
1641 ///
1642 /// Note: pasting is asynchronous, that is, we’ll ask for the paste data
1643 /// and return, and at some point later after the main loop runs, the paste
1644 /// data will be inserted.
1645 /// ## `clipboard`
1646 /// the [`gdk::Clipboard`][crate::gdk::Clipboard] to paste from
1647 /// ## `override_location`
1648 /// location to insert pasted text
1649 /// ## `default_editable`
1650 /// whether the buffer is editable by default
1651 #[doc(alias = "gtk_text_buffer_paste_clipboard")]
1652 fn paste_clipboard(
1653 &self,
1654 clipboard: &gdk::Clipboard,
1655 override_location: Option<&TextIter>,
1656 default_editable: bool,
1657 ) {
1658 unsafe {
1659 ffi::gtk_text_buffer_paste_clipboard(
1660 self.as_ref().to_glib_none().0,
1661 clipboard.to_glib_none().0,
1662 mut_override(override_location.to_glib_none().0),
1663 default_editable.into_glib(),
1664 );
1665 }
1666 }
1667
1668 /// This function moves the “insert” and “selection_bound” marks
1669 /// simultaneously.
1670 ///
1671 /// If you move them to the same place in two steps with
1672 /// [`move_mark()`][Self::move_mark()], you will temporarily select a
1673 /// region in between their old and new locations, which can be pretty
1674 /// inefficient since the temporarily-selected region will force stuff
1675 /// to be recalculated. This function moves them as a unit, which can
1676 /// be optimized.
1677 /// ## `where_`
1678 /// where to put the cursor
1679 #[doc(alias = "gtk_text_buffer_place_cursor")]
1680 fn place_cursor(&self, where_: &TextIter) {
1681 unsafe {
1682 ffi::gtk_text_buffer_place_cursor(
1683 self.as_ref().to_glib_none().0,
1684 where_.to_glib_none().0,
1685 );
1686 }
1687 }
1688
1689 /// Redoes the next redoable action on the buffer, if there is one.
1690 #[doc(alias = "gtk_text_buffer_redo")]
1691 fn redo(&self) {
1692 unsafe {
1693 ffi::gtk_text_buffer_redo(self.as_ref().to_glib_none().0);
1694 }
1695 }
1696
1697 /// Removes all tags in the range between @start and @end.
1698 ///
1699 /// Be careful with this function; it could remove tags added in code
1700 /// unrelated to the code you’re currently writing. That is, using this
1701 /// function is probably a bad idea if you have two or more unrelated
1702 /// code sections that add tags.
1703 /// ## `start`
1704 /// one bound of range to be untagged
1705 /// ## `end`
1706 /// other bound of range to be untagged
1707 #[doc(alias = "gtk_text_buffer_remove_all_tags")]
1708 fn remove_all_tags(&self, start: &TextIter, end: &TextIter) {
1709 unsafe {
1710 ffi::gtk_text_buffer_remove_all_tags(
1711 self.as_ref().to_glib_none().0,
1712 start.to_glib_none().0,
1713 end.to_glib_none().0,
1714 );
1715 }
1716 }
1717
1718 /// Removes the `GtkTextBufferCommitNotify` handler previously registered
1719 /// with [`TextBufferExtManual::add_commit_notify()`][crate::prelude::TextBufferExtManual::add_commit_notify()].
1720 ///
1721 /// This may result in the `user_data_destroy` being called that was passed when registering
1722 /// the commit notify functions.
1723 /// ## `commit_notify_handler`
1724 /// the notify handler identifier returned from
1725 /// [`TextBufferExtManual::add_commit_notify()`][crate::prelude::TextBufferExtManual::add_commit_notify()].
1726 #[cfg(feature = "v4_16")]
1727 #[cfg_attr(docsrs, doc(cfg(feature = "v4_16")))]
1728 #[doc(alias = "gtk_text_buffer_remove_commit_notify")]
1729 fn remove_commit_notify(&self, commit_notify_handler: u32) {
1730 unsafe {
1731 ffi::gtk_text_buffer_remove_commit_notify(
1732 self.as_ref().to_glib_none().0,
1733 commit_notify_handler,
1734 );
1735 }
1736 }
1737
1738 /// Removes a [`gdk::Clipboard`][crate::gdk::Clipboard] added with
1739 /// [`add_selection_clipboard()`][Self::add_selection_clipboard()]
1740 /// ## `clipboard`
1741 /// a [`gdk::Clipboard`][crate::gdk::Clipboard] added to @self by
1742 /// [`add_selection_clipboard()`][Self::add_selection_clipboard()]
1743 #[doc(alias = "gtk_text_buffer_remove_selection_clipboard")]
1744 fn remove_selection_clipboard(&self, clipboard: &gdk::Clipboard) {
1745 unsafe {
1746 ffi::gtk_text_buffer_remove_selection_clipboard(
1747 self.as_ref().to_glib_none().0,
1748 clipboard.to_glib_none().0,
1749 );
1750 }
1751 }
1752
1753 /// Emits the “remove-tag” signal.
1754 ///
1755 /// The default handler for the signal removes all occurrences
1756 /// of @tag from the given range. @start and @end don’t have
1757 /// to be in order.
1758 /// ## `tag`
1759 /// a [`TextTag`][crate::TextTag]
1760 /// ## `start`
1761 /// one bound of range to be untagged
1762 /// ## `end`
1763 /// other bound of range to be untagged
1764 #[doc(alias = "gtk_text_buffer_remove_tag")]
1765 fn remove_tag(&self, tag: &impl IsA<TextTag>, start: &TextIter, end: &TextIter) {
1766 unsafe {
1767 ffi::gtk_text_buffer_remove_tag(
1768 self.as_ref().to_glib_none().0,
1769 tag.as_ref().to_glib_none().0,
1770 start.to_glib_none().0,
1771 end.to_glib_none().0,
1772 );
1773 }
1774 }
1775
1776 /// Emits the “remove-tag” signal.
1777 ///
1778 /// Calls [`TextTagTable::lookup()`][crate::TextTagTable::lookup()] on the buffer’s
1779 /// tag table to get a [`TextTag`][crate::TextTag], then calls
1780 /// [`remove_tag()`][Self::remove_tag()].
1781 /// ## `name`
1782 /// name of a [`TextTag`][crate::TextTag]
1783 /// ## `start`
1784 /// one bound of range to be untagged
1785 /// ## `end`
1786 /// other bound of range to be untagged
1787 #[doc(alias = "gtk_text_buffer_remove_tag_by_name")]
1788 fn remove_tag_by_name(&self, name: &str, start: &TextIter, end: &TextIter) {
1789 unsafe {
1790 ffi::gtk_text_buffer_remove_tag_by_name(
1791 self.as_ref().to_glib_none().0,
1792 name.to_glib_none().0,
1793 start.to_glib_none().0,
1794 end.to_glib_none().0,
1795 );
1796 }
1797 }
1798
1799 /// This function moves the “insert” and “selection_bound” marks
1800 /// simultaneously.
1801 ///
1802 /// If you move them in two steps with
1803 /// [`move_mark()`][Self::move_mark()], you will temporarily select a
1804 /// region in between their old and new locations, which can be pretty
1805 /// inefficient since the temporarily-selected region will force stuff
1806 /// to be recalculated. This function moves them as a unit, which can
1807 /// be optimized.
1808 /// ## `ins`
1809 /// where to put the “insert” mark
1810 /// ## `bound`
1811 /// where to put the “selection_bound” mark
1812 #[doc(alias = "gtk_text_buffer_select_range")]
1813 fn select_range(&self, ins: &TextIter, bound: &TextIter) {
1814 unsafe {
1815 ffi::gtk_text_buffer_select_range(
1816 self.as_ref().to_glib_none().0,
1817 ins.to_glib_none().0,
1818 bound.to_glib_none().0,
1819 );
1820 }
1821 }
1822
1823 /// Sets whether or not to enable undoable actions in the text buffer.
1824 ///
1825 /// Undoable actions in this context are changes to the text content of
1826 /// the buffer. Changes to tags and marks are not tracked.
1827 ///
1828 /// If enabled, the user will be able to undo the last number of actions
1829 /// up to [`max_undo_levels()`][Self::max_undo_levels()].
1830 ///
1831 /// See [`begin_irreversible_action()`][Self::begin_irreversible_action()] and
1832 /// [`end_irreversible_action()`][Self::end_irreversible_action()] to create
1833 /// changes to the buffer that cannot be undone.
1834 /// ## `enable_undo`
1835 /// [`true`] to enable undo
1836 #[doc(alias = "gtk_text_buffer_set_enable_undo")]
1837 #[doc(alias = "enable-undo")]
1838 fn set_enable_undo(&self, enable_undo: bool) {
1839 unsafe {
1840 ffi::gtk_text_buffer_set_enable_undo(
1841 self.as_ref().to_glib_none().0,
1842 enable_undo.into_glib(),
1843 );
1844 }
1845 }
1846
1847 /// Sets the maximum number of undo levels to perform.
1848 ///
1849 /// If 0, unlimited undo actions may be performed. Note that this may
1850 /// have a memory usage impact as it requires storing an additional
1851 /// copy of the inserted or removed text within the text buffer.
1852 /// ## `max_undo_levels`
1853 /// the maximum number of undo actions to perform
1854 #[doc(alias = "gtk_text_buffer_set_max_undo_levels")]
1855 fn set_max_undo_levels(&self, max_undo_levels: u32) {
1856 unsafe {
1857 ffi::gtk_text_buffer_set_max_undo_levels(
1858 self.as_ref().to_glib_none().0,
1859 max_undo_levels,
1860 );
1861 }
1862 }
1863
1864 /// Used to keep track of whether the buffer has been
1865 /// modified since the last time it was saved.
1866 ///
1867 /// Whenever the buffer is saved to disk, call
1868 /// `gtk_text_buffer_set_modified (@self, FALSE)`.
1869 /// When the buffer is modified, it will automatically
1870 /// toggle on the modified bit again. When the modified
1871 /// bit flips, the buffer emits the
1872 /// [`modified-changed`][struct@crate::TextBuffer#modified-changed] signal.
1873 /// ## `setting`
1874 /// modification flag setting
1875 #[doc(alias = "gtk_text_buffer_set_modified")]
1876 fn set_modified(&self, setting: bool) {
1877 unsafe {
1878 ffi::gtk_text_buffer_set_modified(self.as_ref().to_glib_none().0, setting.into_glib());
1879 }
1880 }
1881
1882 /// Deletes current contents of @self, and inserts @text instead. This is
1883 /// automatically marked as an irreversible action in the undo stack. If you
1884 /// wish to mark this action as part of a larger undo operation, call
1885 /// [`delete()`][Self::delete()] and [`insert()`][Self::insert()] directly instead.
1886 ///
1887 /// If @len is -1, @text must be nul-terminated.
1888 /// @text must be valid UTF-8.
1889 /// ## `text`
1890 /// UTF-8 text to insert
1891 /// ## `len`
1892 /// length of @text in bytes
1893 #[doc(alias = "gtk_text_buffer_set_text")]
1894 #[doc(alias = "text")]
1895 fn set_text(&self, text: &str) {
1896 let len = text.len() as _;
1897 unsafe {
1898 ffi::gtk_text_buffer_set_text(
1899 self.as_ref().to_glib_none().0,
1900 text.to_glib_none().0,
1901 len,
1902 );
1903 }
1904 }
1905
1906 /// Undoes the last undoable action on the buffer, if there is one.
1907 #[doc(alias = "gtk_text_buffer_undo")]
1908 fn undo(&self) {
1909 unsafe {
1910 ffi::gtk_text_buffer_undo(self.as_ref().to_glib_none().0);
1911 }
1912 }
1913
1914 /// The position of the insert mark.
1915 ///
1916 /// This is an offset from the beginning of the buffer.
1917 /// It is useful for getting notified when the cursor moves.
1918 #[doc(alias = "cursor-position")]
1919 fn cursor_position(&self) -> i32 {
1920 ObjectExt::property(self.as_ref(), "cursor-position")
1921 }
1922
1923 /// Emitted to apply a tag to a range of text in a [`TextBuffer`][crate::TextBuffer].
1924 ///
1925 /// Applying actually occurs in the default handler.
1926 ///
1927 /// Note that if your handler runs before the default handler
1928 /// it must not invalidate the @start and @end iters (or has to
1929 /// revalidate them).
1930 ///
1931 /// See also:
1932 /// [`apply_tag()`][Self::apply_tag()],
1933 /// [`TextBufferExtManual::insert_with_tags()`][crate::prelude::TextBufferExtManual::insert_with_tags()],
1934 /// [`insert_range()`][Self::insert_range()].
1935 /// ## `tag`
1936 /// the applied tag
1937 /// ## `start`
1938 /// the start of the range the tag is applied to
1939 /// ## `end`
1940 /// the end of the range the tag is applied to
1941 #[doc(alias = "apply-tag")]
1942 fn connect_apply_tag<F: Fn(&Self, &TextTag, &TextIter, &TextIter) + 'static>(
1943 &self,
1944 f: F,
1945 ) -> SignalHandlerId {
1946 unsafe extern "C" fn apply_tag_trampoline<
1947 P: IsA<TextBuffer>,
1948 F: Fn(&P, &TextTag, &TextIter, &TextIter) + 'static,
1949 >(
1950 this: *mut ffi::GtkTextBuffer,
1951 tag: *mut ffi::GtkTextTag,
1952 start: *mut ffi::GtkTextIter,
1953 end: *mut ffi::GtkTextIter,
1954 f: glib::ffi::gpointer,
1955 ) {
1956 unsafe {
1957 let f: &F = &*(f as *const F);
1958 f(
1959 TextBuffer::from_glib_borrow(this).unsafe_cast_ref(),
1960 &from_glib_borrow(tag),
1961 &from_glib_borrow(start),
1962 &from_glib_borrow(end),
1963 )
1964 }
1965 }
1966 unsafe {
1967 let f: Box_<F> = Box_::new(f);
1968 connect_raw(
1969 self.as_ptr() as *mut _,
1970 c"apply-tag".as_ptr() as *const _,
1971 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1972 apply_tag_trampoline::<Self, F> as *const (),
1973 )),
1974 Box_::into_raw(f),
1975 )
1976 }
1977 }
1978
1979 /// Emitted at the beginning of a single user-visible
1980 /// operation on a [`TextBuffer`][crate::TextBuffer].
1981 ///
1982 /// See also:
1983 /// [`begin_user_action()`][Self::begin_user_action()],
1984 /// [`insert_interactive()`][Self::insert_interactive()],
1985 /// [`insert_range_interactive()`][Self::insert_range_interactive()],
1986 /// [`delete_interactive()`][Self::delete_interactive()],
1987 /// [`backspace()`][Self::backspace()],
1988 /// [`delete_selection()`][Self::delete_selection()].
1989 #[doc(alias = "begin-user-action")]
1990 fn connect_begin_user_action<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1991 unsafe extern "C" fn begin_user_action_trampoline<
1992 P: IsA<TextBuffer>,
1993 F: Fn(&P) + 'static,
1994 >(
1995 this: *mut ffi::GtkTextBuffer,
1996 f: glib::ffi::gpointer,
1997 ) {
1998 unsafe {
1999 let f: &F = &*(f as *const F);
2000 f(TextBuffer::from_glib_borrow(this).unsafe_cast_ref())
2001 }
2002 }
2003 unsafe {
2004 let f: Box_<F> = Box_::new(f);
2005 connect_raw(
2006 self.as_ptr() as *mut _,
2007 c"begin-user-action".as_ptr() as *const _,
2008 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2009 begin_user_action_trampoline::<Self, F> as *const (),
2010 )),
2011 Box_::into_raw(f),
2012 )
2013 }
2014 }
2015
2016 /// Emitted when the content of a [`TextBuffer`][crate::TextBuffer] has changed.
2017 #[doc(alias = "changed")]
2018 fn connect_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2019 unsafe extern "C" fn changed_trampoline<P: IsA<TextBuffer>, F: Fn(&P) + 'static>(
2020 this: *mut ffi::GtkTextBuffer,
2021 f: glib::ffi::gpointer,
2022 ) {
2023 unsafe {
2024 let f: &F = &*(f as *const F);
2025 f(TextBuffer::from_glib_borrow(this).unsafe_cast_ref())
2026 }
2027 }
2028 unsafe {
2029 let f: Box_<F> = Box_::new(f);
2030 connect_raw(
2031 self.as_ptr() as *mut _,
2032 c"changed".as_ptr() as *const _,
2033 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2034 changed_trampoline::<Self, F> as *const (),
2035 )),
2036 Box_::into_raw(f),
2037 )
2038 }
2039 }
2040
2041 /// Emitted to delete a range from a [`TextBuffer`][crate::TextBuffer].
2042 ///
2043 /// Note that if your handler runs before the default handler
2044 /// it must not invalidate the @start and @end iters (or has
2045 /// to revalidate them). The default signal handler revalidates
2046 /// the @start and @end iters to both point to the location
2047 /// where text was deleted. Handlers which run after the default
2048 /// handler (see g_signal_connect_after()) do not have access to
2049 /// the deleted text.
2050 ///
2051 /// See also: [`delete()`][Self::delete()].
2052 /// ## `start`
2053 /// the start of the range to be deleted
2054 /// ## `end`
2055 /// the end of the range to be deleted
2056 #[doc(alias = "delete-range")]
2057 fn connect_delete_range<F: Fn(&Self, &TextIter, &TextIter) + 'static>(
2058 &self,
2059 f: F,
2060 ) -> SignalHandlerId {
2061 unsafe extern "C" fn delete_range_trampoline<
2062 P: IsA<TextBuffer>,
2063 F: Fn(&P, &TextIter, &TextIter) + 'static,
2064 >(
2065 this: *mut ffi::GtkTextBuffer,
2066 start: *mut ffi::GtkTextIter,
2067 end: *mut ffi::GtkTextIter,
2068 f: glib::ffi::gpointer,
2069 ) {
2070 unsafe {
2071 let f: &F = &*(f as *const F);
2072 f(
2073 TextBuffer::from_glib_borrow(this).unsafe_cast_ref(),
2074 &from_glib_borrow(start),
2075 &from_glib_borrow(end),
2076 )
2077 }
2078 }
2079 unsafe {
2080 let f: Box_<F> = Box_::new(f);
2081 connect_raw(
2082 self.as_ptr() as *mut _,
2083 c"delete-range".as_ptr() as *const _,
2084 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2085 delete_range_trampoline::<Self, F> as *const (),
2086 )),
2087 Box_::into_raw(f),
2088 )
2089 }
2090 }
2091
2092 /// Emitted at the end of a single user-visible
2093 /// operation on the [`TextBuffer`][crate::TextBuffer].
2094 ///
2095 /// See also:
2096 /// [`end_user_action()`][Self::end_user_action()],
2097 /// [`insert_interactive()`][Self::insert_interactive()],
2098 /// [`insert_range_interactive()`][Self::insert_range_interactive()],
2099 /// [`delete_interactive()`][Self::delete_interactive()],
2100 /// [`backspace()`][Self::backspace()],
2101 /// [`delete_selection()`][Self::delete_selection()],
2102 /// [`backspace()`][Self::backspace()].
2103 #[doc(alias = "end-user-action")]
2104 fn connect_end_user_action<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2105 unsafe extern "C" fn end_user_action_trampoline<P: IsA<TextBuffer>, F: Fn(&P) + 'static>(
2106 this: *mut ffi::GtkTextBuffer,
2107 f: glib::ffi::gpointer,
2108 ) {
2109 unsafe {
2110 let f: &F = &*(f as *const F);
2111 f(TextBuffer::from_glib_borrow(this).unsafe_cast_ref())
2112 }
2113 }
2114 unsafe {
2115 let f: Box_<F> = Box_::new(f);
2116 connect_raw(
2117 self.as_ptr() as *mut _,
2118 c"end-user-action".as_ptr() as *const _,
2119 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2120 end_user_action_trampoline::<Self, F> as *const (),
2121 )),
2122 Box_::into_raw(f),
2123 )
2124 }
2125 }
2126
2127 /// Emitted to insert a [`TextChildAnchor`][crate::TextChildAnchor] in a [`TextBuffer`][crate::TextBuffer].
2128 ///
2129 /// Insertion actually occurs in the default handler.
2130 ///
2131 /// Note that if your handler runs before the default handler
2132 /// it must not invalidate the @location iter (or has to
2133 /// revalidate it). The default signal handler revalidates
2134 /// it to be placed after the inserted @anchor.
2135 ///
2136 /// See also: [`insert_child_anchor()`][Self::insert_child_anchor()].
2137 /// ## `location`
2138 /// position to insert @anchor in @textbuffer
2139 /// ## `anchor`
2140 /// the [`TextChildAnchor`][crate::TextChildAnchor] to be inserted
2141 #[doc(alias = "insert-child-anchor")]
2142 fn connect_insert_child_anchor<F: Fn(&Self, &TextIter, &TextChildAnchor) + 'static>(
2143 &self,
2144 f: F,
2145 ) -> SignalHandlerId {
2146 unsafe extern "C" fn insert_child_anchor_trampoline<
2147 P: IsA<TextBuffer>,
2148 F: Fn(&P, &TextIter, &TextChildAnchor) + 'static,
2149 >(
2150 this: *mut ffi::GtkTextBuffer,
2151 location: *mut ffi::GtkTextIter,
2152 anchor: *mut ffi::GtkTextChildAnchor,
2153 f: glib::ffi::gpointer,
2154 ) {
2155 unsafe {
2156 let f: &F = &*(f as *const F);
2157 f(
2158 TextBuffer::from_glib_borrow(this).unsafe_cast_ref(),
2159 &from_glib_borrow(location),
2160 &from_glib_borrow(anchor),
2161 )
2162 }
2163 }
2164 unsafe {
2165 let f: Box_<F> = Box_::new(f);
2166 connect_raw(
2167 self.as_ptr() as *mut _,
2168 c"insert-child-anchor".as_ptr() as *const _,
2169 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2170 insert_child_anchor_trampoline::<Self, F> as *const (),
2171 )),
2172 Box_::into_raw(f),
2173 )
2174 }
2175 }
2176
2177 /// Emitted to insert a [`gdk::Paintable`][crate::gdk::Paintable] in a [`TextBuffer`][crate::TextBuffer].
2178 ///
2179 /// Insertion actually occurs in the default handler.
2180 ///
2181 /// Note that if your handler runs before the default handler
2182 /// it must not invalidate the @location iter (or has to
2183 /// revalidate it). The default signal handler revalidates
2184 /// it to be placed after the inserted @paintable.
2185 ///
2186 /// See also: [`insert_paintable()`][Self::insert_paintable()].
2187 /// ## `location`
2188 /// position to insert @paintable in @textbuffer
2189 /// ## `paintable`
2190 /// the [`gdk::Paintable`][crate::gdk::Paintable] to be inserted
2191 #[doc(alias = "insert-paintable")]
2192 fn connect_insert_paintable<F: Fn(&Self, &TextIter, &gdk::Paintable) + 'static>(
2193 &self,
2194 f: F,
2195 ) -> SignalHandlerId {
2196 unsafe extern "C" fn insert_paintable_trampoline<
2197 P: IsA<TextBuffer>,
2198 F: Fn(&P, &TextIter, &gdk::Paintable) + 'static,
2199 >(
2200 this: *mut ffi::GtkTextBuffer,
2201 location: *mut ffi::GtkTextIter,
2202 paintable: *mut gdk::ffi::GdkPaintable,
2203 f: glib::ffi::gpointer,
2204 ) {
2205 unsafe {
2206 let f: &F = &*(f as *const F);
2207 f(
2208 TextBuffer::from_glib_borrow(this).unsafe_cast_ref(),
2209 &from_glib_borrow(location),
2210 &from_glib_borrow(paintable),
2211 )
2212 }
2213 }
2214 unsafe {
2215 let f: Box_<F> = Box_::new(f);
2216 connect_raw(
2217 self.as_ptr() as *mut _,
2218 c"insert-paintable".as_ptr() as *const _,
2219 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2220 insert_paintable_trampoline::<Self, F> as *const (),
2221 )),
2222 Box_::into_raw(f),
2223 )
2224 }
2225 }
2226
2227 /// Emitted as notification after a [`TextMark`][crate::TextMark] is deleted.
2228 ///
2229 /// See also: [`delete_mark()`][Self::delete_mark()].
2230 /// ## `mark`
2231 /// The mark that was deleted
2232 #[doc(alias = "mark-deleted")]
2233 fn connect_mark_deleted<F: Fn(&Self, &TextMark) + 'static>(&self, f: F) -> SignalHandlerId {
2234 unsafe extern "C" fn mark_deleted_trampoline<
2235 P: IsA<TextBuffer>,
2236 F: Fn(&P, &TextMark) + 'static,
2237 >(
2238 this: *mut ffi::GtkTextBuffer,
2239 mark: *mut ffi::GtkTextMark,
2240 f: glib::ffi::gpointer,
2241 ) {
2242 unsafe {
2243 let f: &F = &*(f as *const F);
2244 f(
2245 TextBuffer::from_glib_borrow(this).unsafe_cast_ref(),
2246 &from_glib_borrow(mark),
2247 )
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 unsafe {
2287 let f: &F = &*(f as *const F);
2288 f(
2289 TextBuffer::from_glib_borrow(this).unsafe_cast_ref(),
2290 &from_glib_borrow(location),
2291 &from_glib_borrow(mark),
2292 )
2293 }
2294 }
2295 unsafe {
2296 let f: Box_<F> = Box_::new(f);
2297 connect_raw(
2298 self.as_ptr() as *mut _,
2299 c"mark-set".as_ptr() as *const _,
2300 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2301 mark_set_trampoline::<Self, F> as *const (),
2302 )),
2303 Box_::into_raw(f),
2304 )
2305 }
2306 }
2307
2308 /// Emitted when the modified bit of a [`TextBuffer`][crate::TextBuffer] flips.
2309 ///
2310 /// See also: [`set_modified()`][Self::set_modified()].
2311 #[doc(alias = "modified-changed")]
2312 fn connect_modified_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2313 unsafe extern "C" fn modified_changed_trampoline<
2314 P: IsA<TextBuffer>,
2315 F: Fn(&P) + 'static,
2316 >(
2317 this: *mut ffi::GtkTextBuffer,
2318 f: glib::ffi::gpointer,
2319 ) {
2320 unsafe {
2321 let f: &F = &*(f as *const F);
2322 f(TextBuffer::from_glib_borrow(this).unsafe_cast_ref())
2323 }
2324 }
2325 unsafe {
2326 let f: Box_<F> = Box_::new(f);
2327 connect_raw(
2328 self.as_ptr() as *mut _,
2329 c"modified-changed".as_ptr() as *const _,
2330 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2331 modified_changed_trampoline::<Self, F> as *const (),
2332 )),
2333 Box_::into_raw(f),
2334 )
2335 }
2336 }
2337
2338 /// Emitted after paste operation has been completed.
2339 ///
2340 /// This is useful to properly scroll the view to the end
2341 /// of the pasted text. See [`paste_clipboard()`][Self::paste_clipboard()]
2342 /// for more details.
2343 /// ## `clipboard`
2344 /// the [`gdk::Clipboard`][crate::gdk::Clipboard] pasted from
2345 #[doc(alias = "paste-done")]
2346 fn connect_paste_done<F: Fn(&Self, &gdk::Clipboard) + 'static>(&self, f: F) -> SignalHandlerId {
2347 unsafe extern "C" fn paste_done_trampoline<
2348 P: IsA<TextBuffer>,
2349 F: Fn(&P, &gdk::Clipboard) + 'static,
2350 >(
2351 this: *mut ffi::GtkTextBuffer,
2352 clipboard: *mut gdk::ffi::GdkClipboard,
2353 f: glib::ffi::gpointer,
2354 ) {
2355 unsafe {
2356 let f: &F = &*(f as *const F);
2357 f(
2358 TextBuffer::from_glib_borrow(this).unsafe_cast_ref(),
2359 &from_glib_borrow(clipboard),
2360 )
2361 }
2362 }
2363 unsafe {
2364 let f: Box_<F> = Box_::new(f);
2365 connect_raw(
2366 self.as_ptr() as *mut _,
2367 c"paste-done".as_ptr() as *const _,
2368 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2369 paste_done_trampoline::<Self, F> as *const (),
2370 )),
2371 Box_::into_raw(f),
2372 )
2373 }
2374 }
2375
2376 /// Emitted when a request has been made to redo the
2377 /// previously undone operation.
2378 #[doc(alias = "redo")]
2379 fn connect_redo<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2380 unsafe extern "C" fn redo_trampoline<P: IsA<TextBuffer>, F: Fn(&P) + 'static>(
2381 this: *mut ffi::GtkTextBuffer,
2382 f: glib::ffi::gpointer,
2383 ) {
2384 unsafe {
2385 let f: &F = &*(f as *const F);
2386 f(TextBuffer::from_glib_borrow(this).unsafe_cast_ref())
2387 }
2388 }
2389 unsafe {
2390 let f: Box_<F> = Box_::new(f);
2391 connect_raw(
2392 self.as_ptr() as *mut _,
2393 c"redo".as_ptr() as *const _,
2394 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2395 redo_trampoline::<Self, F> as *const (),
2396 )),
2397 Box_::into_raw(f),
2398 )
2399 }
2400 }
2401
2402 /// Emitted to remove all occurrences of @tag from a range
2403 /// of text in a [`TextBuffer`][crate::TextBuffer].
2404 ///
2405 /// Removal actually occurs in the default handler.
2406 ///
2407 /// Note that if your handler runs before the default handler
2408 /// it must not invalidate the @start and @end iters (or has
2409 /// to revalidate them).
2410 ///
2411 /// See also: [`remove_tag()`][Self::remove_tag()].
2412 /// ## `tag`
2413 /// the tag to be removed
2414 /// ## `start`
2415 /// the start of the range the tag is removed from
2416 /// ## `end`
2417 /// the end of the range the tag is removed from
2418 #[doc(alias = "remove-tag")]
2419 fn connect_remove_tag<F: Fn(&Self, &TextTag, &TextIter, &TextIter) + 'static>(
2420 &self,
2421 f: F,
2422 ) -> SignalHandlerId {
2423 unsafe extern "C" fn remove_tag_trampoline<
2424 P: IsA<TextBuffer>,
2425 F: Fn(&P, &TextTag, &TextIter, &TextIter) + 'static,
2426 >(
2427 this: *mut ffi::GtkTextBuffer,
2428 tag: *mut ffi::GtkTextTag,
2429 start: *mut ffi::GtkTextIter,
2430 end: *mut ffi::GtkTextIter,
2431 f: glib::ffi::gpointer,
2432 ) {
2433 unsafe {
2434 let f: &F = &*(f as *const F);
2435 f(
2436 TextBuffer::from_glib_borrow(this).unsafe_cast_ref(),
2437 &from_glib_borrow(tag),
2438 &from_glib_borrow(start),
2439 &from_glib_borrow(end),
2440 )
2441 }
2442 }
2443 unsafe {
2444 let f: Box_<F> = Box_::new(f);
2445 connect_raw(
2446 self.as_ptr() as *mut _,
2447 c"remove-tag".as_ptr() as *const _,
2448 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2449 remove_tag_trampoline::<Self, F> as *const (),
2450 )),
2451 Box_::into_raw(f),
2452 )
2453 }
2454 }
2455
2456 /// Emitted when a request has been made to undo the
2457 /// previous operation or set of operations that have
2458 /// been grouped together.
2459 #[doc(alias = "undo")]
2460 fn connect_undo<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2461 unsafe extern "C" fn undo_trampoline<P: IsA<TextBuffer>, F: Fn(&P) + 'static>(
2462 this: *mut ffi::GtkTextBuffer,
2463 f: glib::ffi::gpointer,
2464 ) {
2465 unsafe {
2466 let f: &F = &*(f as *const F);
2467 f(TextBuffer::from_glib_borrow(this).unsafe_cast_ref())
2468 }
2469 }
2470 unsafe {
2471 let f: Box_<F> = Box_::new(f);
2472 connect_raw(
2473 self.as_ptr() as *mut _,
2474 c"undo".as_ptr() as *const _,
2475 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2476 undo_trampoline::<Self, F> as *const (),
2477 )),
2478 Box_::into_raw(f),
2479 )
2480 }
2481 }
2482
2483 #[doc(alias = "can-redo")]
2484 fn connect_can_redo_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2485 unsafe extern "C" fn notify_can_redo_trampoline<P: IsA<TextBuffer>, F: Fn(&P) + 'static>(
2486 this: *mut ffi::GtkTextBuffer,
2487 _param_spec: glib::ffi::gpointer,
2488 f: glib::ffi::gpointer,
2489 ) {
2490 unsafe {
2491 let f: &F = &*(f as *const F);
2492 f(TextBuffer::from_glib_borrow(this).unsafe_cast_ref())
2493 }
2494 }
2495 unsafe {
2496 let f: Box_<F> = Box_::new(f);
2497 connect_raw(
2498 self.as_ptr() as *mut _,
2499 c"notify::can-redo".as_ptr() as *const _,
2500 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2501 notify_can_redo_trampoline::<Self, F> as *const (),
2502 )),
2503 Box_::into_raw(f),
2504 )
2505 }
2506 }
2507
2508 #[doc(alias = "can-undo")]
2509 fn connect_can_undo_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2510 unsafe extern "C" fn notify_can_undo_trampoline<P: IsA<TextBuffer>, F: Fn(&P) + 'static>(
2511 this: *mut ffi::GtkTextBuffer,
2512 _param_spec: glib::ffi::gpointer,
2513 f: glib::ffi::gpointer,
2514 ) {
2515 unsafe {
2516 let f: &F = &*(f as *const F);
2517 f(TextBuffer::from_glib_borrow(this).unsafe_cast_ref())
2518 }
2519 }
2520 unsafe {
2521 let f: Box_<F> = Box_::new(f);
2522 connect_raw(
2523 self.as_ptr() as *mut _,
2524 c"notify::can-undo".as_ptr() as *const _,
2525 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2526 notify_can_undo_trampoline::<Self, F> as *const (),
2527 )),
2528 Box_::into_raw(f),
2529 )
2530 }
2531 }
2532
2533 #[doc(alias = "cursor-position")]
2534 fn connect_cursor_position_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2535 unsafe extern "C" fn notify_cursor_position_trampoline<
2536 P: IsA<TextBuffer>,
2537 F: Fn(&P) + 'static,
2538 >(
2539 this: *mut ffi::GtkTextBuffer,
2540 _param_spec: glib::ffi::gpointer,
2541 f: glib::ffi::gpointer,
2542 ) {
2543 unsafe {
2544 let f: &F = &*(f as *const F);
2545 f(TextBuffer::from_glib_borrow(this).unsafe_cast_ref())
2546 }
2547 }
2548 unsafe {
2549 let f: Box_<F> = Box_::new(f);
2550 connect_raw(
2551 self.as_ptr() as *mut _,
2552 c"notify::cursor-position".as_ptr() as *const _,
2553 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2554 notify_cursor_position_trampoline::<Self, F> as *const (),
2555 )),
2556 Box_::into_raw(f),
2557 )
2558 }
2559 }
2560
2561 #[doc(alias = "enable-undo")]
2562 fn connect_enable_undo_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2563 unsafe extern "C" fn notify_enable_undo_trampoline<
2564 P: IsA<TextBuffer>,
2565 F: Fn(&P) + 'static,
2566 >(
2567 this: *mut ffi::GtkTextBuffer,
2568 _param_spec: glib::ffi::gpointer,
2569 f: glib::ffi::gpointer,
2570 ) {
2571 unsafe {
2572 let f: &F = &*(f as *const F);
2573 f(TextBuffer::from_glib_borrow(this).unsafe_cast_ref())
2574 }
2575 }
2576 unsafe {
2577 let f: Box_<F> = Box_::new(f);
2578 connect_raw(
2579 self.as_ptr() as *mut _,
2580 c"notify::enable-undo".as_ptr() as *const _,
2581 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2582 notify_enable_undo_trampoline::<Self, F> as *const (),
2583 )),
2584 Box_::into_raw(f),
2585 )
2586 }
2587 }
2588
2589 #[doc(alias = "has-selection")]
2590 fn connect_has_selection_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2591 unsafe extern "C" fn notify_has_selection_trampoline<
2592 P: IsA<TextBuffer>,
2593 F: Fn(&P) + 'static,
2594 >(
2595 this: *mut ffi::GtkTextBuffer,
2596 _param_spec: glib::ffi::gpointer,
2597 f: glib::ffi::gpointer,
2598 ) {
2599 unsafe {
2600 let f: &F = &*(f as *const F);
2601 f(TextBuffer::from_glib_borrow(this).unsafe_cast_ref())
2602 }
2603 }
2604 unsafe {
2605 let f: Box_<F> = Box_::new(f);
2606 connect_raw(
2607 self.as_ptr() as *mut _,
2608 c"notify::has-selection".as_ptr() as *const _,
2609 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2610 notify_has_selection_trampoline::<Self, F> as *const (),
2611 )),
2612 Box_::into_raw(f),
2613 )
2614 }
2615 }
2616
2617 #[doc(alias = "text")]
2618 fn connect_text_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2619 unsafe extern "C" fn notify_text_trampoline<P: IsA<TextBuffer>, F: Fn(&P) + 'static>(
2620 this: *mut ffi::GtkTextBuffer,
2621 _param_spec: glib::ffi::gpointer,
2622 f: glib::ffi::gpointer,
2623 ) {
2624 unsafe {
2625 let f: &F = &*(f as *const F);
2626 f(TextBuffer::from_glib_borrow(this).unsafe_cast_ref())
2627 }
2628 }
2629 unsafe {
2630 let f: Box_<F> = Box_::new(f);
2631 connect_raw(
2632 self.as_ptr() as *mut _,
2633 c"notify::text".as_ptr() as *const _,
2634 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2635 notify_text_trampoline::<Self, F> as *const (),
2636 )),
2637 Box_::into_raw(f),
2638 )
2639 }
2640 }
2641}
2642
2643impl<O: IsA<TextBuffer>> TextBufferExt for O {}