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
// Take a look at the license at the top of the repository in the LICENSE file.
use crate::TextAttributes;
use crate::TextIter;
use glib::translate::*;
use std::convert::TryFrom;
impl TextIter {
    /// Computes the effect of any tags applied to this spot in the
    /// text. The `values` parameter should be initialized to the default
    /// settings you wish to use if no tags are in effect. You’d typically
    /// obtain the defaults from [`TextViewExt::default_attributes()`][crate::prelude::TextViewExt::default_attributes()].
    ///
    /// [`is_attributes()`][Self::is_attributes()] will modify `values`, applying the
    /// effects of any tags present at `self`. If any tags affected `values`,
    /// the function returns [`true`].
    ///
    /// # Returns
    ///
    /// [`true`] if `values` was modified
    ///
    /// ## `values`
    /// a [`TextAttributes`][crate::TextAttributes] to be filled in
    #[doc(alias = "gtk_text_iter_get_attributes")]
    #[doc(alias = "get_attributes")]
    pub fn is_attributes(&self, values: &TextAttributes) -> bool {
        unsafe {
            from_glib(ffi::gtk_text_iter_get_attributes(
                self.to_glib_none().0,
                mut_override(values.to_glib_none().0),
            ))
        }
    }
    /// The Unicode character at this iterator is returned. (Equivalent to
    /// operator* on a C++ iterator.) If the element at this iterator is a
    /// non-character element, such as an image embedded in the buffer, the
    /// Unicode “unknown” character 0xFFFC is returned. If invoked on
    /// the end iterator, zero is returned; zero is not a valid Unicode character.
    /// So you can write a loop which ends when [`char()`][Self::char()]
    /// returns 0.
    ///
    /// # Returns
    ///
    /// a Unicode character, or 0 if `self` is not dereferenceable
    #[doc(alias = "gtk_text_iter_get_char")]
    #[doc(alias = "get_char")]
    pub fn char(&self) -> Option<char> {
        let ret = unsafe { ffi::gtk_text_iter_get_char(self.to_glib_none().0) };
        if ret == 0 {
            return None;
        }
        Some(TryFrom::try_from(ret).expect("conversion from an invalid Unicode value attempted"))
    }
}