pango

Struct AttrList

Source
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.

GLib type: Shared boxed type with reference counted clone semantics.

Implementations§

Source§

impl AttrList

Source

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

Return the inner pointer to the underlying C value.

Source

pub unsafe fn from_glib_ptr_borrow(ptr: &*mut PangoAttrList) -> &Self

Borrows 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.

In the resulting string, serialized attributes are separated by newlines or commas. Individual attributes are serialized to a string of the form

START END TYPE VALUE

Where START and END are the indices (with -1 being accepted in place of MAXUINT), TYPE is the nickname of the attribute value type, e.g. weight or stretch, and the value is serialized according to its type:

  • enum values as nick or numeric value
  • boolean values as true or false
  • integers and floats as numbers
  • strings as string, optionally quoted
  • font features as quoted string
  • PangoLanguage as string
  • PangoFontDescription as serialized by FontDescription::to_str(), quoted
  • PangoColor as serialized by Color::to_str()

Examples:

0 10 foreground red, 5 15 weight bold, 0 200 font-desc "Sans 10"
0 -1 weight 700
0 100 family Times

To parse the returned value, use from_string().

Note that shape attributes can not be serialized.

§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

Makes a clone of this shared reference.

This increments the strong reference count of the reference. Dropping the reference will decrement it again.

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 From<AttrList> for Value

Source§

fn from(s: AttrList) -> Self

Converts to this type from the input type.
Source§

impl FromStr for AttrList

Available on crate feature v1_50 only.
Source§

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 HasParamSpec for AttrList

Source§

type ParamSpec = ParamSpecBoxed

Source§

type SetValue = AttrList

Preferred value to be used as setter for the associated ParamSpec.
Source§

type BuilderFn = fn(_: &str) -> ParamSpecBoxedBuilder<'_, AttrList>

Source§

fn param_spec_builder() -> Self::BuilderFn

Source§

impl PartialEq for AttrList

Available on crate feature v1_46 only.
Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

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

Available on crate feature v1_46 only.

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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 T

Source§

impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GPtrArray> for T

Source§

impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GSList> for T

Source§

impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GList> for T

Source§

impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GPtrArray> for T

Source§

impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GSList> for T

Source§

impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GList> for T

Source§

impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GPtrArray> for T

Source§

impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GSList> for T

Source§

impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GList> for T

Source§

impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GPtrArray> for T

Source§

impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GSList> for T

Source§

impl<T, U> Into<U> for T
where 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> IntoClosureReturnValue for T
where T: Into<Value>,

Source§

impl<T> Property for T
where T: HasParamSpec,

Source§

type Value = T

Source§

impl<T> PropertyGet for T
where T: HasParamSpec,

Source§

type Value = T

Source§

fn get<R, F>(&self, f: F) -> R
where F: Fn(&<T as PropertyGet>::Value) -> R,

Source§

impl<T> StaticTypeExt for T
where T: StaticType,

Source§

fn ensure_type()

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

impl<T> ToOwned for T
where T: Clone,

Source§

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 T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

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

impl<T> TransparentType for T

Source§

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

Source§

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 T
where T: for<'a> FromValue<'a> + StaticType + 'static,

Source§

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

Source§

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 T
where T: FromValue<'a, Checker = C>, C: ValueTypeChecker<Error = ValueTypeMismatchOrNoneError<E>>, E: Error + Send + 'static,