Class AttrList

All Implemented Interfaces:
Proxy

@Generated("org.javagi.JavaGI") public class AttrList extends ProxyInstance

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

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

Since the PangoAttrList 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 PangoAttrList for more than one paragraph of text.

  • Constructor Summary

    Constructors
    Constructor
    Description
    Create a new empty attribute list with a reference count of one.
    Create a AttrList proxy instance for the provided memory address.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Insert the given attribute into the PangoAttrList.
    @Nullable AttrList
    Copy this AttrList and return an identical new list.
    boolean
    equal(AttrList otherList)
    Checks whether this AttrList and otherList contain the same attributes and whether those attributes apply to the same ranges.
    @Nullable AttrList
    filter(@Nullable AttrFilterFunc func)
    Given a PangoAttrList and callback function, removes any elements of this AttrList for which func returns true and inserts them into a new list.
    static @Nullable AttrList
    Deserializes a PangoAttrList from a string.
    Gets a list of all attributes in list.
    Create a iterator initialized to the beginning of the list.
    The memory layout of the native struct.
    static @Nullable Type
    Get the GType of the AttrList class.
    void
    Insert the given attribute into the PangoAttrList.
    void
    Insert the given attribute into the PangoAttrList.
    ref()
    Increase the reference count of the given attribute list by one.
    void
    splice(AttrList other, int pos, int len)
    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.
    Serializes a PangoAttrList to a string.
    void
    Decrease the reference count of the given attribute list by one.
    void
    update(int pos, int remove, int add)
    Update indices of attributes in this AttrList for a change in the text they refer to.

    Methods inherited from class ProxyInstance

    equals, handle, hashCode

    Methods inherited from class Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • AttrList

      public AttrList(MemorySegment address)
      Create a AttrList proxy instance for the provided memory address.
      Parameters:
      address - the memory address of the native object
    • AttrList

      public AttrList()
      Create a new empty attribute list with a reference count of one.
  • Method Details

    • getType

      public static @Nullable Type getType()
      Get the GType of the AttrList class.
      Returns:
      the GType
    • getMemoryLayout

      public static MemoryLayout getMemoryLayout()
      The memory layout of the native struct.
      Returns:
      the memory layout
    • fromString

      public static @Nullable AttrList fromString(String text)

      Deserializes a PangoAttrList from a string.

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

      Parameters:
      text - a string
      Returns:
      a new PangoAttrList
      Since:
      1.50
    • change

      public void change(Attribute attr)

      Insert the given attribute into the PangoAttrList.

      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(Attribute) for creating an attribute list in order (potentially much slower for large lists). However, insert(Attribute) is not suitable for continually changing a set of attributes since it never removes or combines existing attributes.

      Parameters:
      attr - the attribute to insert
    • copy

      public @Nullable AttrList copy()
      Copy this AttrList and return an identical new list.
      Returns:
      the newly allocated PangoAttrList, with a reference count of one, which should be freed with unref(). Returns null if this AttrList was null.
    • equal

      public boolean equal(AttrList otherList)

      Checks whether this AttrList and otherList contain the same attributes and whether those attributes apply to the same ranges.

      Beware that this will return wrong values if any list contains duplicates.

      Parameters:
      otherList - the other PangoAttrList
      Returns:
      true if the lists are equal, false if they aren't
      Since:
      1.46
    • filter

      public @Nullable AttrList filter(@Nullable AttrFilterFunc func)
      Given a PangoAttrList and callback function, removes any elements of this AttrList for which func returns true and inserts them into a new list.
      Parameters:
      func - callback function; returns true if an attribute should be filtered out
      Returns:
      the new PangoAttrList or null if no attributes of the given types were found
      Since:
      1.2
    • getAttributes

      public SList<Attribute> getAttributes()
      Gets a list of all attributes in list.
      Returns:
      a list of all attributes in list. To free this value, call Attribute.destroy() on each value and g_slist_free() on the list.
      Since:
      1.44
    • getIterator

      public AttrIterator getIterator()

      Create a iterator initialized to the beginning of the list.

      this AttrList must not be modified until this iterator is freed.

      Returns:
      the newly allocated PangoAttrIterator, which should be freed with AttrIterator.destroy()
    • insert

      public void insert(Attribute attr)

      Insert the given attribute into the PangoAttrList.

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

      Parameters:
      attr - the attribute to insert
    • insertBefore

      public void insertBefore(Attribute attr)

      Insert the given attribute into the PangoAttrList.

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

      Parameters:
      attr - the attribute to insert
    • ref

      public AttrList ref()
      Increase the reference count of the given attribute list by one.
      Returns:
      The attribute list passed in
      Since:
      1.10
    • splice

      public void splice(AttrList other, int pos, int len)

      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 this AttrList by an amount len, and then calling change(Attribute) 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 list.

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

      Parameters:
      other - another PangoAttrList
      pos - the position in this AttrList 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)
    • toString

      public String toString()

      Serializes a PangoAttrList 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

      `Pango.FontDescription.to_string`, quoted
      

      Examples:

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

      To parse the returned value, use fromString(String).

      Note that shape attributes can not be serialized.

      Overrides:
      toString in class Object
      Returns:
      a newly allocated string
      Since:
      1.50
    • unref

      public void unref()

      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.

    • update

      public void update(int pos, int remove, int add)

      Update indices of attributes in this AttrList 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.

      Parameters:
      pos - the position of the change
      remove - the number of removed bytes
      add - the number of added bytes
      Since:
      1.44