1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from
// from gir-files (https://github.com/gtk-rs/gir-files.git)
// DO NOT EDIT

use crate::{ffi, GutterRendererAlignmentMode};
use glib::translate::*;

glib::wrapper! {
    /// Collected information about visible lines.
    ///
    /// The [`GutterLines`][crate::GutterLines] object is used to collect information about
    /// visible lines.
    ///
    /// Use this from your [`query-data`][struct@crate::GutterRenderer#query-data] to collect the
    /// necessary information on visible lines. Doing so reduces the number of
    /// passes through the text btree allowing GtkSourceView to reach more
    /// frames-per-second while performing kinetic scrolling.
    ///
    /// # Implements
    ///
    /// [`trait@glib::ObjectExt`]
    #[doc(alias = "GtkSourceGutterLines")]
    pub struct GutterLines(Object<ffi::GtkSourceGutterLines, ffi::GtkSourceGutterLinesClass>);

    match fn {
        type_ => || ffi::gtk_source_gutter_lines_get_type(),
    }
}

impl GutterLines {
    /// Adds the class @name to @line.
    ///
    /// @name will be converted to a `alias::GLib.Quark` as part of this process. A
    /// faster version of this function is available via
    /// [`add_qclass()`][Self::add_qclass()] for situations where the `alias::GLib.Quark` is
    /// known ahead of time.
    /// ## `line`
    /// a line number starting from zero
    /// ## `name`
    /// a class name
    #[doc(alias = "gtk_source_gutter_lines_add_class")]
    pub fn add_class(&self, line: u32, name: &str) {
        unsafe {
            ffi::gtk_source_gutter_lines_add_class(
                self.to_glib_none().0,
                line,
                name.to_glib_none().0,
            );
        }
    }

    /// Adds the class denoted by @qname to @line.
    ///
    /// You may check if a line has @qname by calling
    /// [`has_qclass()`][Self::has_qclass()].
    ///
    /// You can remove @qname by calling
    /// [`remove_qclass()`][Self::remove_qclass()].
    /// ## `line`
    /// a line number starting from zero
    /// ## `qname`
    /// a class name as a #GQuark
    #[doc(alias = "gtk_source_gutter_lines_add_qclass")]
    pub fn add_qclass(&self, line: u32, qname: glib::Quark) {
        unsafe {
            ffi::gtk_source_gutter_lines_add_qclass(self.to_glib_none().0, line, qname.into_glib());
        }
    }

    /// Gets the [`gtk::TextBuffer`][crate::gtk::TextBuffer] that the [`GutterLines`][crate::GutterLines] represents.
    ///
    /// # Returns
    ///
    /// a #GtkTextBuffer
    #[doc(alias = "gtk_source_gutter_lines_get_buffer")]
    #[doc(alias = "get_buffer")]
    pub fn buffer(&self) -> gtk::TextBuffer {
        unsafe {
            from_glib_none(ffi::gtk_source_gutter_lines_get_buffer(
                self.to_glib_none().0,
            ))
        }
    }

    /// Gets the line number (starting from 0) for the first line that is
    /// user visible.
    ///
    /// # Returns
    ///
    /// a line number starting from 0
    #[doc(alias = "gtk_source_gutter_lines_get_first")]
    #[doc(alias = "get_first")]
    pub fn first(&self) -> u32 {
        unsafe { ffi::gtk_source_gutter_lines_get_first(self.to_glib_none().0) }
    }

    /// Gets a #GtkTextIter for the current buffer at @line
    /// ## `line`
    /// the line number
    ///
    /// # Returns
    ///
    ///
    /// ## `iter`
    /// a location for a #GtkTextIter
    #[doc(alias = "gtk_source_gutter_lines_get_iter_at_line")]
    #[doc(alias = "get_iter_at_line")]
    pub fn iter_at_line(&self, line: u32) -> gtk::TextIter {
        unsafe {
            let mut iter = gtk::TextIter::uninitialized();
            ffi::gtk_source_gutter_lines_get_iter_at_line(
                self.to_glib_none().0,
                iter.to_glib_none_mut().0,
                line,
            );
            iter
        }
    }

    /// Gets the line number (starting from 0) for the last line that is
    /// user visible.
    ///
    /// # Returns
    ///
    /// a line number starting from 0
    #[doc(alias = "gtk_source_gutter_lines_get_last")]
    #[doc(alias = "get_last")]
    pub fn last(&self) -> u32 {
        unsafe { ffi::gtk_source_gutter_lines_get_last(self.to_glib_none().0) }
    }

    /// Gets the Y range for a line based on @mode.
    ///
    /// The value for @y is relative to the renderers widget coordinates.
    /// ## `line`
    /// a line number starting from zero
    /// ## `mode`
    /// a #GtkSourceGutterRendererAlignmentMode
    ///
    /// # Returns
    ///
    ///
    /// ## `y`
    /// a location for the Y position in widget coordinates
    ///
    /// ## `height`
    /// the line height based on @mode
    #[doc(alias = "gtk_source_gutter_lines_get_line_yrange")]
    #[doc(alias = "get_line_yrange")]
    pub fn line_yrange(&self, line: u32, mode: GutterRendererAlignmentMode) -> (i32, i32) {
        unsafe {
            let mut y = std::mem::MaybeUninit::uninit();
            let mut height = std::mem::MaybeUninit::uninit();
            ffi::gtk_source_gutter_lines_get_line_yrange(
                self.to_glib_none().0,
                line,
                mode.into_glib(),
                y.as_mut_ptr(),
                height.as_mut_ptr(),
            );
            (y.assume_init(), height.assume_init())
        }
    }

    /// Gets the [`gtk::TextView`][crate::gtk::TextView] that the [`GutterLines`][crate::GutterLines] represents.
    ///
    /// # Returns
    ///
    /// a #GtkTextView
    #[doc(alias = "gtk_source_gutter_lines_get_view")]
    #[doc(alias = "get_view")]
    pub fn view(&self) -> gtk::TextView {
        unsafe { from_glib_none(ffi::gtk_source_gutter_lines_get_view(self.to_glib_none().0)) }
    }

    /// Checks to see if the line has any GQuark classes set. This can be
    /// used to help renderer implementations avoid work if nothing has
    /// been set on the class.
    /// ## `line`
    /// a line contained within @self
    ///
    /// # Returns
    ///
    /// [`true`] if any quark was set for the line
    #[cfg(feature = "v5_6")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v5_6")))]
    #[doc(alias = "gtk_source_gutter_lines_has_any_class")]
    pub fn has_any_class(&self, line: u32) -> bool {
        unsafe {
            from_glib(ffi::gtk_source_gutter_lines_has_any_class(
                self.to_glib_none().0,
                line,
            ))
        }
    }

    /// Checks to see if [`add_class()`][Self::add_class()] was called with
    /// the @name for @line.
    ///
    /// A faster version of this function is provided via
    /// [`has_qclass()`][Self::has_qclass()] for situations where the quark
    /// is known ahead of time.
    /// ## `line`
    /// a line number starting from zero
    /// ## `name`
    /// a class name that may be converted, to a #GQuark
    ///
    /// # Returns
    ///
    /// [`true`] if @line contains @name
    #[doc(alias = "gtk_source_gutter_lines_has_class")]
    pub fn has_class(&self, line: u32, name: &str) -> bool {
        unsafe {
            from_glib(ffi::gtk_source_gutter_lines_has_class(
                self.to_glib_none().0,
                line,
                name.to_glib_none().0,
            ))
        }
    }

    /// Checks to see if [`add_qclass()`][Self::add_qclass()] was called with
    /// the quark denoted by @qname for @line.
    /// ## `line`
    /// a line number starting from zero
    /// ## `qname`
    /// a #GQuark containing the class name
    ///
    /// # Returns
    ///
    /// [`true`] if @line contains @qname
    #[doc(alias = "gtk_source_gutter_lines_has_qclass")]
    pub fn has_qclass(&self, line: u32, qname: glib::Quark) -> bool {
        unsafe {
            from_glib(ffi::gtk_source_gutter_lines_has_qclass(
                self.to_glib_none().0,
                line,
                qname.into_glib(),
            ))
        }
    }

    /// Checks to see if @line contains the insertion cursor.
    /// ## `line`
    /// a line number starting from zero
    ///
    /// # Returns
    ///
    /// [`true`] if the insertion cursor is on @line
    #[doc(alias = "gtk_source_gutter_lines_is_cursor")]
    pub fn is_cursor(&self, line: u32) -> bool {
        unsafe {
            from_glib(ffi::gtk_source_gutter_lines_is_cursor(
                self.to_glib_none().0,
                line,
            ))
        }
    }

    /// Checks to see if @line is marked as prelit. Generally, this means
    /// the mouse pointer is over the line within the gutter.
    /// ## `line`
    /// a line number starting from zero
    ///
    /// # Returns
    ///
    /// [`true`] if the line is prelit
    #[doc(alias = "gtk_source_gutter_lines_is_prelit")]
    pub fn is_prelit(&self, line: u32) -> bool {
        unsafe {
            from_glib(ffi::gtk_source_gutter_lines_is_prelit(
                self.to_glib_none().0,
                line,
            ))
        }
    }

    /// Checks to see if the view had a selection and if that selection overlaps
    /// @line in some way.
    /// ## `line`
    /// a line number starting from zero
    ///
    /// # Returns
    ///
    /// [`true`] if the line contains a selection
    #[doc(alias = "gtk_source_gutter_lines_is_selected")]
    pub fn is_selected(&self, line: u32) -> bool {
        unsafe {
            from_glib(ffi::gtk_source_gutter_lines_is_selected(
                self.to_glib_none().0,
                line,
            ))
        }
    }

    /// Removes the class matching @name from @line.
    ///
    /// A faster version of this function is available via
    /// [`remove_qclass()`][Self::remove_qclass()] for situations where the
    /// #GQuark is known ahead of time.
    /// ## `line`
    /// a line number starting from zero
    /// ## `name`
    /// a class name
    #[doc(alias = "gtk_source_gutter_lines_remove_class")]
    pub fn remove_class(&self, line: u32, name: &str) {
        unsafe {
            ffi::gtk_source_gutter_lines_remove_class(
                self.to_glib_none().0,
                line,
                name.to_glib_none().0,
            );
        }
    }

    /// Reverses a call to [`add_qclass()`][Self::add_qclass()] by removing
    /// the `alias::GLib.Quark` matching @qname.
    /// ## `line`
    /// a line number starting from zero
    /// ## `qname`
    /// a #GQuark to remove from @line
    #[doc(alias = "gtk_source_gutter_lines_remove_qclass")]
    pub fn remove_qclass(&self, line: u32, qname: glib::Quark) {
        unsafe {
            ffi::gtk_source_gutter_lines_remove_qclass(
                self.to_glib_none().0,
                line,
                qname.into_glib(),
            );
        }
    }
}