gtk4/accessible_text_range.rs
1// Take a look at the license at the top of the repository in the LICENSE file.
2
3use crate::ffi;
4use glib::translate::*;
5
6glib::wrapper! {
7 /// A range inside the text of an accessible object.
8 #[doc(alias = "GtkAccessibleTextRange")]
9 pub struct AccessibleTextRange(BoxedInline<ffi::GtkAccessibleTextRange>);
10}
11
12impl AccessibleTextRange {
13 pub fn new(start: usize, length: usize) -> Self {
14 skip_assert_initialized!();
15 unsafe { AccessibleTextRange::unsafe_from(ffi::GtkAccessibleTextRange { start, length }) }
16 }
17
18 pub fn start(&self) -> usize {
19 self.inner.start
20 }
21
22 pub fn set_start(&mut self, start: usize) {
23 self.inner.start = start;
24 }
25
26 pub fn length(&self) -> usize {
27 self.inner.length
28 }
29
30 pub fn set_length(&mut self, length: usize) {
31 self.inner.length = length
32 }
33}
34
35impl std::fmt::Debug for AccessibleTextRange {
36 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
37 f.debug_struct("AccessibleTextRange")
38 .field("start", &self.start())
39 .field("length", &self.length())
40 .finish()
41 }
42}