gtk4/accessible_text_range.rs
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
// Take a look at the license at the top of the repository in the LICENSE file.
use crate::ffi;
use glib::translate::*;
glib::wrapper! {
/// A range inside the text of an accessible object.
#[doc(alias = "GtkAccessibleTextRange")]
pub struct AccessibleTextRange(BoxedInline<ffi::GtkAccessibleTextRange>);
}
impl AccessibleTextRange {
pub fn new(start: usize, length: usize) -> Self {
skip_assert_initialized!();
unsafe { AccessibleTextRange::unsafe_from(ffi::GtkAccessibleTextRange { start, length }) }
}
pub fn start(&self) -> usize {
self.inner.start
}
pub fn set_start(&mut self, start: usize) {
self.inner.start = start;
}
pub fn length(&self) -> usize {
self.inner.length
}
pub fn set_length(&mut self, length: usize) {
self.inner.length = length
}
}
impl std::fmt::Debug for AccessibleTextRange {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.debug_struct("AccessibleTextRange")
.field("start", &self.start())
.field("length", &self.length())
.finish()
}
}