Class Item
- All Implemented Interfaces:
Proxy
PangoItem
structure stores information about a segment of text.
You typically obtain PangoItems
by itemizing a piece of text
with Pango.itemize(org.gnome.pango.Context, java.lang.String, int, int, org.gnome.pango.AttrList, org.gnome.pango.AttrIterator)
.
-
Constructor Summary
ConstructorDescriptionItem()
Creates a newPangoItem
structure initialized to default values.Item
(MemorySegment address) Create a Item proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionvoid
applyAttrs
(AttrIterator iter) Add attributes to aPangoItem
.copy()
Copy an existingPangoItem
structure.void
free()
Free aPangoItem
and all associated memory.int
Returns the character offset of the item from the beginning of the itemized text.static MemoryLayout
The memory layout of the native struct.static Type
getType()
Get the GType of the Item classRead the value of the fieldanalysis
.int
Read the value of the fieldlength
.int
Read the value of the fieldnum_chars
.int
Read the value of the fieldoffset
.split
(int splitIndex, int splitOffset) Modifies this Item to cover only the text aftersplitIndex
, and returns a new item that covers the text beforesplitIndex
that used to be in this Item.void
writeAnalysis
(Analysis analysis) Write a value in the fieldanalysis
.void
writeLength
(int length) Write a value in the fieldlength
.void
writeNumChars
(int numChars) Write a value in the fieldnum_chars
.void
writeOffset
(int offset) Write a value in the fieldoffset
.Methods inherited from class io.github.jwharm.javagi.base.ProxyInstance
equals, handle, hashCode
-
Constructor Details
-
Item
Create a Item proxy instance for the provided memory address.- Parameters:
address
- the memory address of the native object
-
Item
public Item()Creates a newPangoItem
structure initialized to default values.
-
-
Method Details
-
getType
-
getMemoryLayout
The memory layout of the native struct.- Returns:
- the memory layout
-
readOffset
public int readOffset()Read the value of the fieldoffset
.- Returns:
- The value of the field
offset
-
writeOffset
public void writeOffset(int offset) Write a value in the fieldoffset
.- Parameters:
offset
- The new value for the fieldoffset
-
readLength
public int readLength()Read the value of the fieldlength
.- Returns:
- The value of the field
length
-
writeLength
public void writeLength(int length) Write a value in the fieldlength
.- Parameters:
length
- The new value for the fieldlength
-
readNumChars
public int readNumChars()Read the value of the fieldnum_chars
.- Returns:
- The value of the field
num_chars
-
writeNumChars
public void writeNumChars(int numChars) Write a value in the fieldnum_chars
.- Parameters:
numChars
- The new value for the fieldnum_chars
-
readAnalysis
Read the value of the fieldanalysis
.- Returns:
- The value of the field
analysis
-
writeAnalysis
Write a value in the fieldanalysis
.- Parameters:
analysis
- The new value for the fieldanalysis
-
applyAttrs
Add attributes to aPangoItem
.The idea is that you have attributes that don't affect itemization, such as font features, so you filter them out using
AttrList.filter(org.gnome.pango.AttrFilterFunc)
, itemize your text, then reapply the attributes to the resulting items using this function.The
iter
should be positioned before the range of the item, and will be advanced past it. This function is meant to be called in a loop over the items resulting from itemization, while passing the iter to each call.- Parameters:
iter
- aPangoAttrIterator
-
copy
-
free
public void free()Free aPangoItem
and all associated memory. -
getCharOffset
public int getCharOffset()Returns the character offset of the item from the beginning of the itemized text.If the item has not been obtained from Pango's itemization machinery, then the character offset is not available. In that case, this function returns -1.
- Returns:
- the character offset of the item from the beginning of the itemized text, or -1
-
split
Modifies this Item to cover only the text aftersplitIndex
, and returns a new item that covers the text beforesplitIndex
that used to be in this Item.You can think of
splitIndex
as the length of the returned item.splitIndex
may not be 0, and it may not be greater than or equal to the length of this Item (that is, there must be at least one byte assigned to each item, you can't create a zero-length item).splitOffset
is the length of the first item in chars, and must be provided because the text used to generate the item isn't available, sopango_item_split()
can't count the char length of the split items itself.- Parameters:
splitIndex
- byte index of position to split item, relative to the start of the itemsplitOffset
- number of chars between start of this Item andsplitIndex
- Returns:
- new item representing text before
splitIndex
, which should be freed withfree()
.
-