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
impl AttrList
Sourcepub fn as_ptr(&self) -> *mut PangoAttrList
pub fn as_ptr(&self) -> *mut PangoAttrList
Return the inner pointer to the underlying C value.
Sourcepub unsafe fn from_glib_ptr_borrow(ptr: &*mut PangoAttrList) -> &Self
pub unsafe fn from_glib_ptr_borrow(ptr: &*mut PangoAttrList) -> &Self
Borrows the underlying C value.
Source§impl AttrList
impl AttrList
pub fn copy(&self) -> Option<AttrList>
Sourcepub fn attributes(&self) -> Vec<Attribute>
Available on crate feature v1_44
only.
pub fn attributes(&self) -> Vec<Attribute>
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.
Sourcepub fn iterator(&self) -> AttrIterator<'_>
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()
Sourcepub fn splice(&self, other: &AttrList, pos: i32, len: i32)
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)
Sourcepub fn to_str(&self) -> GString
Available on crate feature v1_50
only.
pub fn to_str(&self) -> GString
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
Sourcepub fn update(&self, pos: i32, remove: i32, add: i32)
Available on crate feature v1_44
only.
pub fn update(&self, pos: i32, remove: i32, add: i32)
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§impl AttrList
impl AttrList
Sourcepub fn change(&self, attr: impl Into<Attribute>)
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
Trait Implementations§
Source§impl HasParamSpec for AttrList
impl HasParamSpec for AttrList
Source§impl StaticType for AttrList
impl StaticType for AttrList
Source§fn static_type() -> Type
fn static_type() -> Type
Self
.impl Eq for AttrList
v1_46
only.Auto Trait Implementations§
impl Freeze for AttrList
impl RefUnwindSafe for AttrList
impl !Send for AttrList
impl !Sync for AttrList
impl Unpin for AttrList
impl UnwindSafe for AttrList
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)