Copyright | Will Thompson Iñaki García Etxebarria and Jonas Platte |
---|---|
License | LGPL-2.1 |
Maintainer | Iñaki García Etxebarria (inaki@blueleaf.cc) |
Safe Haskell | None |
Language | Haskell2010 |
The AttrList
structure represents a list of attributes
that apply to a section of text. The attributes are, in general,
allowed to overlap in an arbitrary fashion, however, if the
attributes are manipulated only through attrListChange
,
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.
Synopsis
- newtype AttrList = AttrList (ManagedPtr AttrList)
- noAttrList :: Maybe AttrList
- attrListChange :: (HasCallStack, MonadIO m) => AttrList -> Attribute -> m ()
- attrListCopy :: (HasCallStack, MonadIO m) => AttrList -> m (Maybe AttrList)
- attrListFilter :: (HasCallStack, MonadIO m) => AttrList -> AttrFilterFunc -> m (Maybe AttrList)
- attrListInsert :: (HasCallStack, MonadIO m) => AttrList -> Attribute -> m ()
- attrListInsertBefore :: (HasCallStack, MonadIO m) => AttrList -> Attribute -> m ()
- attrListNew :: (HasCallStack, MonadIO m) => m AttrList
- attrListRef :: (HasCallStack, MonadIO m) => AttrList -> m AttrList
- attrListSplice :: (HasCallStack, MonadIO m) => AttrList -> AttrList -> Int32 -> Int32 -> m ()
- attrListUnref :: (HasCallStack, MonadIO m) => AttrList -> m ()
Exported types
Memory-managed wrapper type.
Instances
BoxedObject AttrList Source # | |
Methods
change
:: (HasCallStack, MonadIO m) | |
=> AttrList |
|
-> Attribute |
|
-> m () |
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 attrListInsert
for
creating a attribute list in order (potentially much slower
for large lists). However, attrListInsert
is not
suitable for continually changing a set of attributes
since it never removes or combines existing attributes.
copy
:: (HasCallStack, MonadIO m) | |
=> AttrList | |
-> m (Maybe AttrList) | Returns: the newly allocated |
Copy list
and return an identical new list.
filter
:: (HasCallStack, MonadIO m) | |
=> AttrList |
|
-> AttrFilterFunc |
|
-> m (Maybe AttrList) | Returns: the new |
insert
:: (HasCallStack, MonadIO m) | |
=> AttrList |
|
-> Attribute |
|
-> m () |
Insert the given attribute into the AttrList
. It will
be inserted after all other attributes with a matching
startIndex
.
insertBefore
:: (HasCallStack, MonadIO m) | |
=> AttrList |
|
-> Attribute |
|
-> m () |
Insert the given attribute into the AttrList
. It will
be inserted before all other attributes with a matching
startIndex
.
new
:: (HasCallStack, MonadIO m) | |
=> m AttrList | Returns: the newly allocated |
Create a new empty attribute list with a reference count of one.
ref
:: (HasCallStack, MonadIO m) | |
=> AttrList | |
-> m AttrList | Returns: The attribute list passed in |
Increase the reference count of the given attribute list by one.
Since: 1.10
splice
:: (HasCallStack, MonadIO m) | |
=> AttrList |
|
-> AttrList |
|
-> Int32 |
|
-> Int32 |
|
-> m () |
This function opens up a hole in list
, 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 list
by an amount len
,
and then calling attrListChange
with a copy
of each attribute in other
in sequence (offset in position by pos
).
This operation proves useful for, for instance, inserting a pre-edit string in the middle of an edit buffer.
unref
:: (HasCallStack, MonadIO m) | |
=> AttrList | |
-> m () |
Decrease the reference count of the given attribute list by one. If the result is zero, free the attribute list and the attributes it contains.