Struct pango::AttrList

source ·
#[repr(transparent)]
pub struct AttrList { /* private fields */ }
Expand description

A AttrList represents a list of attributes that apply to a section of text.

The attributes in a AttrList are, in general, allowed to overlap in an arbitrary fashion. However, if the attributes are manipulated only through change(), the overlap between properties will meet stricter criteria.

Since the AttrList structure is stored as a linear list, it is not suitable for storing attributes for large amounts of text. In general, you should not use a single AttrList for more than one paragraph of text.

Implementations§

source§

impl AttrList

source

pub fn as_ptr(&self) -> *mut PangoAttrList

Return the inner pointer to the underlying C value.

source§

impl AttrList

source

pub fn new() -> AttrList

Create a new empty attribute list with a reference count of one.

Returns

the newly allocated AttrList, which should be freed with Pango::AttrList::unref()

source

pub fn copy(&self) -> Option<AttrList>

source

pub fn filter<P: FnMut(&Attribute) -> bool>(&self, func: P) -> Option<AttrList>

Given a AttrList and callback function, removes any elements of @self for which @func returns true and inserts them into a new list.

func

callback function; returns true if an attribute should be filtered out

Returns

the new AttrList or None if no attributes of the given types were found

source

pub fn attributes(&self) -> Vec<Attribute>

Available on crate feature v1_44 only.

Gets a list of all attributes in @self.

Returns

a list of all attributes in @self. To free this value, call Pango::Attribute::destroy() on each value and g_slist_free() on the list.

source

pub fn iterator(&self) -> AttrIterator<'_>

Create a iterator initialized to the beginning of the list.

@self must not be modified until this iterator is freed.

Returns

the newly allocated AttrIterator, which should be freed with Pango::AttrIterator::destroy()

source

pub fn splice(&self, other: &AttrList, pos: i32, len: i32)

This function opens up a hole in @self, fills it in with attributes from the left, and then merges @other on top of the hole.

This operation is equivalent to stretching every attribute that applies at position @pos in @self by an amount @len, and then calling change() with a copy of each attribute in @other in sequence (offset in position by @pos, and limited in length to @len).

This operation proves useful for, for instance, inserting a pre-edit string in the middle of an edit buffer.

For backwards compatibility, the function behaves differently when @len is 0. In this case, the attributes from @other are not imited to @len, and are just overlayed on top of @self.

This mode is useful for merging two lists of attributes together.

other

another AttrList

pos

the position in @self at which to insert @other

len

the length of the spliced segment. (Note that this must be specified since the attributes in @other may only be present at some subsection of this range)

source

pub fn to_str(&self) -> GString

Available on crate feature v1_50 only.

Serializes a AttrList to a string.

No guarantees are made about the format of the string, it may change between Pango versions.

The intended use of this function is testing and debugging. The format is not meant as a permanent storage format.

Returns

a newly allocated string

source

pub fn update(&self, pos: i32, remove: i32, add: i32)

Available on crate feature v1_44 only.

Update indices of attributes in @self for a change in the text they refer to.

The change that this function applies is removing @remove bytes at position @pos and inserting @add bytes instead.

Attributes that fall entirely in the (@pos, @pos + @remove) range are removed.

Attributes that start or end inside the (@pos, @pos + @remove) range are shortened to reflect the removal.

Attributes start and end positions are updated if they are behind @pos + @remove.

pos

the position of the change

remove

the number of removed bytes

add

the number of added bytes

source

pub fn from_string(text: &str) -> Result<AttrList, BoolError>

Available on crate feature v1_50 only.

Deserializes a AttrList from a string.

This is the counterpart to to_str(). See that functions for details about the format.

text

a string

Returns

a new AttrList

source§

impl AttrList

source

pub fn change(&self, attr: impl Into<Attribute>)

Insert the given attribute into the AttrList.

It will replace any attributes of the same type on that segment and be merged with any adjoining attributes that are identical.

This function is slower than insert() for creating an attribute list in order (potentially much slower for large lists). However, insert() is not suitable for continually changing a set of attributes since it never removes or combines existing attributes.

attr

the attribute to insert

source

pub fn insert(&self, attr: impl Into<Attribute>)

Insert the given attribute into the AttrList.

It will be inserted after all other attributes with a matching @start_index.

attr

the attribute to insert

source

pub fn insert_before(&self, attr: impl Into<Attribute>)

Insert the given attribute into the AttrList.

It will be inserted before all other attributes with a matching @start_index.

attr

the attribute to insert

Trait Implementations§

source§

impl Clone for AttrList

source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for AttrList

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for AttrList

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl Display for AttrList

Available on crate feature v1_50 only.
source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl FromStr for AttrList

§

type Err = BoolError

The associated error which can be returned from parsing.
source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
source§

impl PartialEq<AttrList> for AttrList

source§

fn eq(&self, other: &Self) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl StaticType for AttrList

source§

fn static_type() -> Type

Returns the type identifier of Self.
source§

impl Eq for AttrList

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GList> for Twhere T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,

source§

impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GPtrArray> for Twhere T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,

source§

unsafe fn from_glib_none_num_as_vec( ptr: *const GPtrArray, num: usize ) -> Vec<T, Global>

source§

unsafe fn from_glib_container_num_as_vec( _: *const GPtrArray, _: usize ) -> Vec<T, Global>

source§

unsafe fn from_glib_full_num_as_vec( _: *const GPtrArray, _: usize ) -> Vec<T, Global>

source§

impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GSList> for Twhere T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,

source§

unsafe fn from_glib_none_num_as_vec( ptr: *const GSList, num: usize ) -> Vec<T, Global>

source§

unsafe fn from_glib_container_num_as_vec( _: *const GSList, _: usize ) -> Vec<T, Global>

source§

unsafe fn from_glib_full_num_as_vec( _: *const GSList, _: usize ) -> Vec<T, Global>

source§

impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GList> for Twhere T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,

source§

unsafe fn from_glib_none_num_as_vec( ptr: *mut GList, num: usize ) -> Vec<T, Global>

source§

unsafe fn from_glib_container_num_as_vec( ptr: *mut GList, num: usize ) -> Vec<T, Global>

source§

unsafe fn from_glib_full_num_as_vec( ptr: *mut GList, num: usize ) -> Vec<T, Global>

source§

impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GPtrArray> for Twhere T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,

source§

unsafe fn from_glib_none_num_as_vec( ptr: *mut GPtrArray, num: usize ) -> Vec<T, Global>

source§

unsafe fn from_glib_container_num_as_vec( ptr: *mut GPtrArray, num: usize ) -> Vec<T, Global>

source§

unsafe fn from_glib_full_num_as_vec( ptr: *mut GPtrArray, num: usize ) -> Vec<T, Global>

source§

impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GSList> for Twhere T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,

source§

unsafe fn from_glib_none_num_as_vec( ptr: *mut GSList, num: usize ) -> Vec<T, Global>

source§

unsafe fn from_glib_container_num_as_vec( ptr: *mut GSList, num: usize ) -> Vec<T, Global>

source§

unsafe fn from_glib_full_num_as_vec( ptr: *mut GSList, num: usize ) -> Vec<T, Global>

source§

impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GList> for Twhere T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,

source§

impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GPtrArray> for Twhere T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,

source§

unsafe fn from_glib_none_as_vec(ptr: *const GPtrArray) -> Vec<T, Global>

source§

unsafe fn from_glib_container_as_vec(_: *const GPtrArray) -> Vec<T, Global>

source§

unsafe fn from_glib_full_as_vec(_: *const GPtrArray) -> Vec<T, Global>

source§

impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GSList> for Twhere T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,

source§

impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GList> for Twhere T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,

source§

unsafe fn from_glib_none_as_vec(ptr: *mut GList) -> Vec<T, Global>

source§

unsafe fn from_glib_container_as_vec(ptr: *mut GList) -> Vec<T, Global>

source§

unsafe fn from_glib_full_as_vec(ptr: *mut GList) -> Vec<T, Global>

source§

impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GPtrArray> for Twhere T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,

source§

unsafe fn from_glib_none_as_vec(ptr: *mut GPtrArray) -> Vec<T, Global>

source§

unsafe fn from_glib_container_as_vec(ptr: *mut GPtrArray) -> Vec<T, Global>

source§

unsafe fn from_glib_full_as_vec(ptr: *mut GPtrArray) -> Vec<T, Global>

source§

impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GSList> for Twhere T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,

source§

unsafe fn from_glib_none_as_vec(ptr: *mut GSList) -> Vec<T, Global>

source§

unsafe fn from_glib_container_as_vec(ptr: *mut GSList) -> Vec<T, Global>

source§

unsafe fn from_glib_full_as_vec(ptr: *mut GSList) -> Vec<T, Global>

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> StaticTypeExt for Twhere T: StaticType,

source§

fn ensure_type()

Ensures that the type has been registered with the type system.
source§

impl<T> ToClosureReturnValue for Twhere T: ToValue,

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T> TryFromClosureReturnValue for Twhere T: for<'a> FromValue<'a> + StaticType + 'static,

source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<'a, T, C, E> FromValueOptional<'a> for Twhere T: FromValue<'a, Checker = C>, C: ValueTypeChecker<Error = ValueTypeMismatchOrNoneError<E>>, E: Error + Send + 'static,