Class TextIter
- All Implemented Interfaces:
Proxy
GtkTextBuffer
.
You may wish to begin by reading the text widget conceptual overview, which gives an overview of all the objects and data types related to the text widget and how they work together.
-
Constructor Summary
ConstructorDescriptionTextIter()
Allocate a new TextIter.Allocate a new TextIter.TextIter
(MemorySegment address) Create a TextIter proxy instance for the provided memory address.TextIter
(MemorySegment dummy1, MemorySegment dummy2, int dummy3, int dummy4, int dummy5, int dummy6, int dummy7, int dummy8, MemorySegment dummy9, MemorySegment dummy10, int dummy11, int dummy12, int dummy13, MemorySegment dummy14) Allocate a new TextIter with the fields set to the provided values.TextIter
(MemorySegment dummy1, MemorySegment dummy2, int dummy3, int dummy4, int dummy5, int dummy6, int dummy7, int dummy8, MemorySegment dummy9, MemorySegment dummy10, int dummy11, int dummy12, int dummy13, MemorySegment dummy14, Arena arena) Allocate a new TextIter with the fields set to the provided values. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Assigns the value ofother
to this TextIter.boolean
Moves backward by one character offset.boolean
backwardChars
(int count) Movescount
characters backward, if possible.boolean
LikeforwardCursorPosition()
, but moves backward.boolean
backwardCursorPositions
(int count) Moves up tocount
cursor positions.boolean
backwardFindChar
(TextCharPredicate pred, @Nullable TextIter limit) Same asforwardFindChar(org.gnome.gtk.TextCharPredicate, org.gnome.gtk.TextIter)
, but goes backward from this TextIter.boolean
Moves this TextIter to the start of the previous line.boolean
backwardLines
(int count) Movescount
lines backward, if possible.boolean
backwardSearch
(String str, Set<TextSearchFlags> flags, @Nullable TextIter matchStart, @Nullable TextIter matchEnd, @Nullable TextIter limit) boolean
backwardSearch
(String str, TextSearchFlags flags, @Nullable TextIter matchStart, @Nullable TextIter matchEnd, @Nullable TextIter limit) boolean
Moves backward to the previous sentence start.boolean
backwardSentenceStarts
(int count) CallsbackwardSentenceStart()
up tocount
times.boolean
backwardToTagToggle
(@Nullable TextTag tag) Moves backward to the next toggle (on or off) of thetag
, or to the next toggle of any tag iftag
isnull
.boolean
Moves this TextIter backward to the previous visible cursor position.boolean
backwardVisibleCursorPositions
(int count) Moves up tocount
visible cursor positions.boolean
Moves this TextIter to the start of the previous visible line.boolean
backwardVisibleLines
(int count) Movescount
visible lines backward, if possible.boolean
Moves backward to the previous visible word start.boolean
backwardVisibleWordStarts
(int count) CallsbackwardVisibleWordStart()
up tocount
times.boolean
Moves backward to the previous word start.boolean
backwardWordStarts
(int count) CallsbackwardWordStart()
up tocount
times.boolean
canInsert
(boolean defaultEditability) Considering the default editability of the buffer, and tags that affect editability, determines whether text inserted at this TextIter would be editable.int
A qsort()-style function that returns negative if this TextIter is less thanrhs
, positive if this TextIter is greater thanrhs
, and 0 if they’re equal.copy()
Creates a dynamically-allocated copy of an iterator.boolean
editable
(boolean defaultSetting) Returns whether the character at this TextIter is within an editable region of text.boolean
endsLine()
Returnstrue
if this TextIter points to the start of the paragraph delimiter characters for a line.boolean
Determines whether this TextIter ends a sentence.boolean
Returnstrue
iftag
is toggled off at exactly this point.boolean
endsWord()
Determines whether this TextIter ends a natural-language word.boolean
Tests whether two iterators are equal, using the fastest possible mechanism.boolean
Moves this TextIter forward by one character offset.boolean
forwardChars
(int count) Movescount
characters if possible.boolean
Moves this TextIter forward by a single cursor position.boolean
forwardCursorPositions
(int count) Moves up tocount
cursor positions.boolean
forwardFindChar
(TextCharPredicate pred, @Nullable TextIter limit) Advances this TextIter, callingpred
on each character.boolean
Moves this TextIter to the start of the next line.boolean
forwardLines
(int count) Movescount
lines forward, if possible.boolean
forwardSearch
(String str, Set<TextSearchFlags> flags, @Nullable TextIter matchStart, @Nullable TextIter matchEnd, @Nullable TextIter limit) Searches forward forstr
.boolean
forwardSearch
(String str, TextSearchFlags flags, @Nullable TextIter matchStart, @Nullable TextIter matchEnd, @Nullable TextIter limit) Searches forward forstr
.boolean
Moves forward to the next sentence end.boolean
forwardSentenceEnds
(int count) CallsforwardSentenceEnd()
count
times.void
Moves this TextIter forward to the “end iterator”, which points one past the last valid character in the buffer.boolean
Moves the iterator to point to the paragraph delimiter characters.boolean
forwardToTagToggle
(@Nullable TextTag tag) Moves forward to the next toggle (on or off) of thetag
, or to the next toggle of any tag iftag
isnull
.boolean
Moves this TextIter forward to the next visible cursor position.boolean
forwardVisibleCursorPositions
(int count) Moves up tocount
visible cursor positions.boolean
Moves this TextIter to the start of the next visible line.boolean
forwardVisibleLines
(int count) Movescount
visible lines forward, if possible.boolean
Moves forward to the next visible word end.boolean
forwardVisibleWordEnds
(int count) CallsforwardVisibleWordEnd()
up tocount
times.boolean
Moves forward to the next word end.boolean
forwardWordEnds
(int count) CallsforwardWordEnd()
up tocount
times.void
free()
Free an iterator allocated on the heap.Returns theGtkTextBuffer
this iterator is associated with.int
Returns the number of bytes in the line containing this TextIter, including the paragraph delimiters.int
getChar()
The Unicode character at this iterator is returned.int
Returns the number of characters in the line containing this TextIter, including the paragraph delimiters.If the location at this TextIter contains a child anchor, the anchor is returned.Returns the language in effect at this TextIter.int
getLine()
Returns the line number containing the iterator.int
Returns the byte index of the iterator, counting from the start of a newline-terminated line.int
Returns the character offset of the iterator, counting from the start of a newline-terminated line.getMarks()
Returns a list of allGtkTextMark
at this location.static MemoryLayout
The memory layout of the native struct.int
Returns the character offset of an iterator.If the element at this TextIter is a paintable, the paintable is returned.Returns the text in the given range.getTags()
Returns a list of tags that apply to this TextIter, in ascending order of priority.Returns text in the given range.getToggledTags
(boolean toggledOn) Returns a list ofGtkTextTag
that are toggled on or off at this point.static Type
getType()
Get the GType of the TextIter classint
Returns the number of bytes from the start of the line to the given this TextIter, not counting bytes that are invisible due to tags with the “invisible” flag toggled on.int
Returns the offset in characters from the start of the line to the given this TextIter, not counting characters that are invisible due to tags with the “invisible” flag toggled on.getVisibleSlice
(TextIter end) Returns visible text in the given range.getVisibleText
(TextIter end) Returns visible text in the given range.boolean
Returnstrue
if this TextIter points to a character that is part of a range tagged withtag
.boolean
Checks whether this TextIter falls in the range [start
,end
).boolean
Determines whether this TextIter is inside a sentence (as opposed to in between two sentences, e.g.boolean
Determines whether the character pointed by this TextIter is part of a natural-language word (as opposed to say inside some whitespace).boolean
Determine if this TextIter is at a cursor position.boolean
isEnd()
Returnstrue
if this TextIter is the end iterator.boolean
isStart()
Returnstrue
if this TextIter is the first iterator in the buffer.void
Swaps the value of this TextIter andsecond
ifsecond
comes before this TextIter in the buffer.Read the value of the fielddummy1
.Read the value of the fielddummy10
.int
Read the value of the fielddummy11
.int
Read the value of the fielddummy12
.int
Read the value of the fielddummy13
.Read the value of the fielddummy14
.Read the value of the fielddummy2
.int
Read the value of the fielddummy3
.int
Read the value of the fielddummy4
.int
Read the value of the fielddummy5
.int
Read the value of the fielddummy6
.int
Read the value of the fielddummy7
.int
Read the value of the fielddummy8
.Read the value of the fielddummy9
.void
setLine
(int lineNumber) Moves iterator this TextIter to the start of the linelineNumber
.void
setLineIndex
(int byteOnLine) Same assetLineOffset(int)
, but works with a byte index.void
setLineOffset
(int charOnLine) Moves this TextIter within a line, to a new character (not byte) offset.void
setOffset
(int charOffset) Sets this TextIter to point tocharOffset
.void
setVisibleLineIndex
(int byteOnLine) LikesetLineIndex(int)
, but the index is in visible bytes, i.e.void
setVisibleLineOffset
(int charOnLine) LikesetLineOffset(int)
, but the offset is in visible characters, i.e.boolean
Returnstrue
if this TextIter begins a paragraph.boolean
Determines whether this TextIter begins a sentence.boolean
Returnstrue
iftag
is toggled on at exactly this point.boolean
Determines whether this TextIter begins a natural-language word.boolean
togglesTag
(@Nullable TextTag tag) Gets whether a range withtag
applied to it begins or ends at this TextIter.void
writeDummy1
(MemorySegment dummy1) Write a value in the fielddummy1
.void
writeDummy10
(MemorySegment dummy10) Write a value in the fielddummy10
.void
writeDummy11
(int dummy11) Write a value in the fielddummy11
.void
writeDummy12
(int dummy12) Write a value in the fielddummy12
.void
writeDummy13
(int dummy13) Write a value in the fielddummy13
.void
writeDummy14
(MemorySegment dummy14) Write a value in the fielddummy14
.void
writeDummy2
(MemorySegment dummy2) Write a value in the fielddummy2
.void
writeDummy3
(int dummy3) Write a value in the fielddummy3
.void
writeDummy4
(int dummy4) Write a value in the fielddummy4
.void
writeDummy5
(int dummy5) Write a value in the fielddummy5
.void
writeDummy6
(int dummy6) Write a value in the fielddummy6
.void
writeDummy7
(int dummy7) Write a value in the fielddummy7
.void
writeDummy8
(int dummy8) Write a value in the fielddummy8
.void
writeDummy9
(MemorySegment dummy9) Write a value in the fielddummy9
.Methods inherited from class io.github.jwharm.javagi.base.ProxyInstance
equals, handle, hashCode
-
Constructor Details
-
TextIter
Create a TextIter proxy instance for the provided memory address.- Parameters:
address
- the memory address of the native object
-
TextIter
Allocate a new TextIter.- Parameters:
arena
- to control the memory allocation scope
-
TextIter
public TextIter()Allocate a new TextIter. The memory is allocated withArena.ofAuto()
. -
TextIter
public TextIter(MemorySegment dummy1, MemorySegment dummy2, int dummy3, int dummy4, int dummy5, int dummy6, int dummy7, int dummy8, MemorySegment dummy9, MemorySegment dummy10, int dummy11, int dummy12, int dummy13, MemorySegment dummy14, Arena arena) Allocate a new TextIter with the fields set to the provided values.- Parameters:
dummy1
- value for the fielddummy1
dummy2
- value for the fielddummy2
dummy3
- value for the fielddummy3
dummy4
- value for the fielddummy4
dummy5
- value for the fielddummy5
dummy6
- value for the fielddummy6
dummy7
- value for the fielddummy7
dummy8
- value for the fielddummy8
dummy9
- value for the fielddummy9
dummy10
- value for the fielddummy10
dummy11
- value for the fielddummy11
dummy12
- value for the fielddummy12
dummy13
- value for the fielddummy13
dummy14
- value for the fielddummy14
arena
- to control the memory allocation scope
-
TextIter
public TextIter(MemorySegment dummy1, MemorySegment dummy2, int dummy3, int dummy4, int dummy5, int dummy6, int dummy7, int dummy8, MemorySegment dummy9, MemorySegment dummy10, int dummy11, int dummy12, int dummy13, MemorySegment dummy14) Allocate a new TextIter with the fields set to the provided values. The memory is allocated withArena.ofAuto()
.- Parameters:
dummy1
- value for the fielddummy1
dummy2
- value for the fielddummy2
dummy3
- value for the fielddummy3
dummy4
- value for the fielddummy4
dummy5
- value for the fielddummy5
dummy6
- value for the fielddummy6
dummy7
- value for the fielddummy7
dummy8
- value for the fielddummy8
dummy9
- value for the fielddummy9
dummy10
- value for the fielddummy10
dummy11
- value for the fielddummy11
dummy12
- value for the fielddummy12
dummy13
- value for the fielddummy13
dummy14
- value for the fielddummy14
-
-
Method Details
-
getType
-
getMemoryLayout
The memory layout of the native struct.- Returns:
- the memory layout
-
readDummy1
Read the value of the fielddummy1
.- Returns:
- The value of the field
dummy1
-
writeDummy1
Write a value in the fielddummy1
.- Parameters:
dummy1
- The new value for the fielddummy1
-
readDummy2
Read the value of the fielddummy2
.- Returns:
- The value of the field
dummy2
-
writeDummy2
Write a value in the fielddummy2
.- Parameters:
dummy2
- The new value for the fielddummy2
-
readDummy3
public int readDummy3()Read the value of the fielddummy3
.- Returns:
- The value of the field
dummy3
-
writeDummy3
public void writeDummy3(int dummy3) Write a value in the fielddummy3
.- Parameters:
dummy3
- The new value for the fielddummy3
-
readDummy4
public int readDummy4()Read the value of the fielddummy4
.- Returns:
- The value of the field
dummy4
-
writeDummy4
public void writeDummy4(int dummy4) Write a value in the fielddummy4
.- Parameters:
dummy4
- The new value for the fielddummy4
-
readDummy5
public int readDummy5()Read the value of the fielddummy5
.- Returns:
- The value of the field
dummy5
-
writeDummy5
public void writeDummy5(int dummy5) Write a value in the fielddummy5
.- Parameters:
dummy5
- The new value for the fielddummy5
-
readDummy6
public int readDummy6()Read the value of the fielddummy6
.- Returns:
- The value of the field
dummy6
-
writeDummy6
public void writeDummy6(int dummy6) Write a value in the fielddummy6
.- Parameters:
dummy6
- The new value for the fielddummy6
-
readDummy7
public int readDummy7()Read the value of the fielddummy7
.- Returns:
- The value of the field
dummy7
-
writeDummy7
public void writeDummy7(int dummy7) Write a value in the fielddummy7
.- Parameters:
dummy7
- The new value for the fielddummy7
-
readDummy8
public int readDummy8()Read the value of the fielddummy8
.- Returns:
- The value of the field
dummy8
-
writeDummy8
public void writeDummy8(int dummy8) Write a value in the fielddummy8
.- Parameters:
dummy8
- The new value for the fielddummy8
-
readDummy9
Read the value of the fielddummy9
.- Returns:
- The value of the field
dummy9
-
writeDummy9
Write a value in the fielddummy9
.- Parameters:
dummy9
- The new value for the fielddummy9
-
readDummy10
Read the value of the fielddummy10
.- Returns:
- The value of the field
dummy10
-
writeDummy10
Write a value in the fielddummy10
.- Parameters:
dummy10
- The new value for the fielddummy10
-
readDummy11
public int readDummy11()Read the value of the fielddummy11
.- Returns:
- The value of the field
dummy11
-
writeDummy11
public void writeDummy11(int dummy11) Write a value in the fielddummy11
.- Parameters:
dummy11
- The new value for the fielddummy11
-
readDummy12
public int readDummy12()Read the value of the fielddummy12
.- Returns:
- The value of the field
dummy12
-
writeDummy12
public void writeDummy12(int dummy12) Write a value in the fielddummy12
.- Parameters:
dummy12
- The new value for the fielddummy12
-
readDummy13
public int readDummy13()Read the value of the fielddummy13
.- Returns:
- The value of the field
dummy13
-
writeDummy13
public void writeDummy13(int dummy13) Write a value in the fielddummy13
.- Parameters:
dummy13
- The new value for the fielddummy13
-
readDummy14
Read the value of the fielddummy14
.- Returns:
- The value of the field
dummy14
-
writeDummy14
Write a value in the fielddummy14
.- Parameters:
dummy14
- The new value for the fielddummy14
-
assign
Assigns the value ofother
to this TextIter.This function is not useful in applications, because iterators can be assigned with
GtkTextIter i = j;
.The function is used by language bindings.
- Parameters:
other
- anotherGtkTextIter
-
backwardChar
public boolean backwardChar()Moves backward by one character offset.Returns
true
if movement was possible; if this TextIter was the first in the buffer (character offset 0), this function returnsfalse
for convenience when writing loops.- Returns:
- whether movement was possible
-
backwardChars
public boolean backwardChars(int count) Movescount
characters backward, if possible.If
count
would move past the start or end of the buffer, moves to the start or end of the buffer.The return value indicates whether the iterator moved onto a dereferenceable position; if the iterator didn’t move, or moved onto the end iterator, then
false
is returned. Ifcount
is 0, the function does nothing and returnsfalse
.- Parameters:
count
- number of characters to move- Returns:
- whether this TextIter moved and is dereferenceable
-
backwardCursorPosition
public boolean backwardCursorPosition()LikeforwardCursorPosition()
, but moves backward.- Returns:
true
if we moved
-
backwardCursorPositions
public boolean backwardCursorPositions(int count) Moves up tocount
cursor positions.See
forwardCursorPosition()
for details.- Parameters:
count
- number of positions to move- Returns:
true
if we moved and the new position is dereferenceable
-
backwardFindChar
Same asforwardFindChar(org.gnome.gtk.TextCharPredicate, org.gnome.gtk.TextIter)
, but goes backward from this TextIter.- Parameters:
pred
- function to be called on each characterlimit
- search limit- Returns:
- whether a match was found
-
backwardLine
public boolean backwardLine()Moves this TextIter to the start of the previous line.Returns
true
if this TextIter could be moved; i.e. if this TextIter was at character offset 0, this function returnsfalse
. Therefore, if this TextIter was already on line 0, but not at the start of the line, this TextIter is snapped to the start of the line and the function returnstrue
. (Note that this implies that in a loop calling this function, the line number may not change on every iteration, if your first iteration is on line 0.)- Returns:
- whether this TextIter moved
-
backwardLines
public boolean backwardLines(int count) Movescount
lines backward, if possible.If
count
would move past the start or end of the buffer, moves to the start or end of the buffer.The return value indicates whether the iterator moved onto a dereferenceable position; if the iterator didn’t move, or moved onto the end iterator, then
false
is returned. Ifcount
is 0, the function does nothing and returnsfalse
. Ifcount
is negative, moves forward by 0 -count
lines.- Parameters:
count
- number of lines to move backward- Returns:
- whether this TextIter moved and is dereferenceable
-
backwardSearch
public boolean backwardSearch(String str, Set<TextSearchFlags> flags, @Nullable @Nullable TextIter matchStart, @Nullable @Nullable TextIter matchEnd, @Nullable @Nullable TextIter limit) Same asforwardSearch(java.lang.String, java.util.Set<org.gnome.gtk.TextSearchFlags>, org.gnome.gtk.TextIter, org.gnome.gtk.TextIter, org.gnome.gtk.TextIter)
, but moves backward.matchEnd
will never be set to aGtkTextIter
located after this TextIter, even if there is a possiblematchStart
before or at this TextIter.- Parameters:
str
- search stringflags
- bitmask of flags affecting the searchmatchStart
- return location for start of matchmatchEnd
- return location for end of matchlimit
- location of last possiblematchStart
, ornull
for start of buffer- Returns:
- whether a match was found
-
backwardSearch
public boolean backwardSearch(String str, TextSearchFlags flags, @Nullable @Nullable TextIter matchStart, @Nullable @Nullable TextIter matchEnd, @Nullable @Nullable TextIter limit) Same asforwardSearch(java.lang.String, java.util.Set<org.gnome.gtk.TextSearchFlags>, org.gnome.gtk.TextIter, org.gnome.gtk.TextIter, org.gnome.gtk.TextIter)
, but moves backward.matchEnd
will never be set to aGtkTextIter
located after this TextIter, even if there is a possiblematchStart
before or at this TextIter.- Parameters:
str
- search stringflags
- bitmask of flags affecting the searchmatchStart
- return location for start of matchmatchEnd
- return location for end of matchlimit
- location of last possiblematchStart
, ornull
for start of buffer- Returns:
- whether a match was found
-
backwardSentenceStart
public boolean backwardSentenceStart()Moves backward to the previous sentence start.If this TextIter is already at the start of a sentence, moves backward to the next one.
Sentence boundaries are determined by Pango and should be correct for nearly any language.
- Returns:
true
if this TextIter moved and is not the end iterator
-
backwardSentenceStarts
public boolean backwardSentenceStarts(int count) CallsbackwardSentenceStart()
up tocount
times.If
count
is negative, moves forward instead of backward.- Parameters:
count
- number of sentences to move- Returns:
true
if this TextIter moved and is not the end iterator
-
backwardToTagToggle
Moves backward to the next toggle (on or off) of thetag
, or to the next toggle of any tag iftag
isnull
.If no matching tag toggles are found, returns
false
, otherwisetrue
. Does not return toggles located at this TextIter, only toggles before this TextIter. Sets this TextIter to the location of the toggle, or the start of the buffer if no toggle is found.- Parameters:
tag
- aGtkTextTag
- Returns:
- whether we found a tag toggle before this TextIter
-
backwardVisibleCursorPosition
public boolean backwardVisibleCursorPosition()Moves this TextIter backward to the previous visible cursor position.See
backwardCursorPosition()
for details.- Returns:
true
if we moved and the new position is dereferenceable
-
backwardVisibleCursorPositions
public boolean backwardVisibleCursorPositions(int count) Moves up tocount
visible cursor positions.See
backwardCursorPosition()
for details.- Parameters:
count
- number of positions to move- Returns:
true
if we moved and the new position is dereferenceable
-
backwardVisibleLine
public boolean backwardVisibleLine()Moves this TextIter to the start of the previous visible line.Returns
true
if this TextIter could be moved; i.e. if this TextIter was at character offset 0, this function returnsfalse
. Therefore if this TextIter was already on line 0, but not at the start of the line, this TextIter is snapped to the start of the line and the function returnstrue
. (Note that this implies that in a loop calling this function, the line number may not change on every iteration, if your first iteration is on line 0.)- Returns:
- whether this TextIter moved
-
backwardVisibleLines
public boolean backwardVisibleLines(int count) Movescount
visible lines backward, if possible.If
count
would move past the start or end of the buffer, moves to the start or end of the buffer.The return value indicates whether the iterator moved onto a dereferenceable position; if the iterator didn’t move, or moved onto the end iterator, then
false
is returned. Ifcount
is 0, the function does nothing and returnsfalse
. Ifcount
is negative, moves forward by 0 -count
lines.- Parameters:
count
- number of lines to move backward- Returns:
- whether this TextIter moved and is dereferenceable
-
backwardVisibleWordStart
public boolean backwardVisibleWordStart()Moves backward to the previous visible word start.If this TextIter is currently on a word start, moves backward to the next one after that.
Word breaks are determined by Pango and should be correct for nearly any language.
- Returns:
true
if this TextIter moved and is not the end iterator
-
backwardVisibleWordStarts
public boolean backwardVisibleWordStarts(int count) CallsbackwardVisibleWordStart()
up tocount
times.- Parameters:
count
- number of times to move- Returns:
true
if this TextIter moved and is not the end iterator
-
backwardWordStart
public boolean backwardWordStart()Moves backward to the previous word start.If this TextIter is currently on a word start, moves backward to the next one after that.
Word breaks are determined by Pango and should be correct for nearly any language
- Returns:
true
if this TextIter moved and is not the end iterator
-
backwardWordStarts
public boolean backwardWordStarts(int count) CallsbackwardWordStart()
up tocount
times.- Parameters:
count
- number of times to move- Returns:
true
if this TextIter moved and is not the end iterator
-
canInsert
public boolean canInsert(boolean defaultEditability) Considering the default editability of the buffer, and tags that affect editability, determines whether text inserted at this TextIter would be editable.If text inserted at this TextIter would be editable then the user should be allowed to insert text at this TextIter.
TextBuffer.insertInteractive(org.gnome.gtk.TextIter, java.lang.String, int, boolean)
uses this function to decide whether insertions are allowed at a given position.- Parameters:
defaultEditability
-true
if text is editable by default- Returns:
- whether text inserted at this TextIter would be editable
-
compare
A qsort()-style function that returns negative if this TextIter is less thanrhs
, positive if this TextIter is greater thanrhs
, and 0 if they’re equal.Ordering is in character offset order, i.e. the first character in the buffer is less than the second character in the buffer.
- Parameters:
rhs
- anotherGtkTextIter
- Returns:
- -1 if this TextIter is less than
rhs
, 1 if this TextIter is greater, 0 if they are equal
-
copy
-
editable
public boolean editable(boolean defaultSetting) Returns whether the character at this TextIter is within an editable region of text.Non-editable text is “locked” and can’t be changed by the user via
GtkTextView
. If no tags applied to this text affect editability,defaultSetting
will be returned.You don’t want to use this function to decide whether text can be inserted at this TextIter, because for insertion you don’t want to know whether the char at this TextIter is inside an editable range, you want to know whether a new character inserted at this TextIter would be inside an editable range. Use
canInsert(boolean)
to handle this case.- Parameters:
defaultSetting
-true
if text is editable by default- Returns:
- whether this TextIter is inside an editable range
-
endsLine
public boolean endsLine()Returnstrue
if this TextIter points to the start of the paragraph delimiter characters for a line.Delimiters will be either a newline, a carriage return, a carriage return followed by a newline, or a Unicode paragraph separator character.
Note that an iterator pointing to the \\n of a \\r\\n pair will not be counted as the end of a line, the line ends before the \\r. The end iterator is considered to be at the end of a line, even though there are no paragraph delimiter chars there.
- Returns:
- whether this TextIter is at the end of a line
-
endsSentence
public boolean endsSentence()Determines whether this TextIter ends a sentence.Sentence boundaries are determined by Pango and should be correct for nearly any language.
- Returns:
true
if this TextIter is at the end of a sentence.
-
endsTag
Returnstrue
iftag
is toggled off at exactly this point.If
tag
isnull
, returnstrue
if any tag is toggled off at this point.Note that if this function returns
true
, it means that this TextIter is at the end of the tagged range, but that the character at this TextIter is outside the tagged range. In other words, unlikestartsTag(org.gnome.gtk.TextTag)
, if this function returnstrue
,hasTag(org.gnome.gtk.TextTag)
will returnfalse
for the same parameters.- Parameters:
tag
- aGtkTextTag
- Returns:
- whether this TextIter is the end of a range tagged with
tag
-
endsWord
public boolean endsWord()Determines whether this TextIter ends a natural-language word.Word breaks are determined by Pango and should be correct for nearly any language.
- Returns:
true
if this TextIter is at the end of a word
-
equal
Tests whether two iterators are equal, using the fastest possible mechanism.This function is very fast; you can expect it to perform better than e.g. getting the character offset for each iterator and comparing the offsets yourself. Also, it’s a bit faster than
compare(org.gnome.gtk.TextIter)
.- Parameters:
rhs
- anotherGtkTextIter
- Returns:
true
if the iterators point to the same place in the buffer
-
forwardChar
public boolean forwardChar()Moves this TextIter forward by one character offset.Note that images embedded in the buffer occupy 1 character slot, so this function may actually move onto an image instead of a character, if you have images in your buffer. If this TextIter is the end iterator or one character before it, this TextIter will now point at the end iterator, and this function returns
false
for convenience when writing loops.- Returns:
- whether this TextIter moved and is dereferenceable
-
forwardChars
public boolean forwardChars(int count) Movescount
characters if possible.If
count
would move past the start or end of the buffer, moves to the start or end of the buffer.The return value indicates whether the new position of this TextIter is different from its original position, and dereferenceable (the last iterator in the buffer is not dereferenceable). If
count
is 0, the function does nothing and returnsfalse
.- Parameters:
count
- number of characters to move, may be negative- Returns:
- whether this TextIter moved and is dereferenceable
-
forwardCursorPosition
public boolean forwardCursorPosition()Moves this TextIter forward by a single cursor position.Cursor positions are (unsurprisingly) positions where the cursor can appear. Perhaps surprisingly, there may not be a cursor position between all characters. The most common example for European languages would be a carriage return/newline sequence.
For some Unicode characters, the equivalent of say the letter “a” with an accent mark will be represented as two characters, first the letter then a "combining mark" that causes the accent to be rendered; so the cursor can’t go between those two characters.
See also the
Pango.LogAttr
struct and thePango.break_(java.lang.String, int, org.gnome.pango.Analysis, org.gnome.pango.LogAttr[])
function.- Returns:
true
if we moved and the new position is dereferenceable
-
forwardCursorPositions
public boolean forwardCursorPositions(int count) Moves up tocount
cursor positions.See
forwardCursorPosition()
for details.- Parameters:
count
- number of positions to move- Returns:
true
if we moved and the new position is dereferenceable
-
forwardFindChar
Advances this TextIter, callingpred
on each character.If
pred
returnstrue
, returnstrue
and stops scanning. Ifpred
never returnstrue
, this TextIter is set tolimit
iflimit
is non-null
, otherwise to the end iterator.- Parameters:
pred
- a function to be called on each characterlimit
- search limit- Returns:
- whether a match was found
-
forwardLine
public boolean forwardLine()Moves this TextIter to the start of the next line.If the iter is already on the last line of the buffer, moves the iter to the end of the current line. If after the operation, the iter is at the end of the buffer and not dereferenceable, returns
false
. Otherwise, returnstrue
.- Returns:
- whether this TextIter can be dereferenced
-
forwardLines
public boolean forwardLines(int count) Movescount
lines forward, if possible.If
count
would move past the start or end of the buffer, moves to the start or end of the buffer.The return value indicates whether the iterator moved onto a dereferenceable position; if the iterator didn’t move, or moved onto the end iterator, then
false
is returned. Ifcount
is 0, the function does nothing and returnsfalse
. Ifcount
is negative, moves backward by 0 -count
lines.- Parameters:
count
- number of lines to move forward- Returns:
- whether this TextIter moved and is dereferenceable
-
forwardSearch
public boolean forwardSearch(String str, Set<TextSearchFlags> flags, @Nullable @Nullable TextIter matchStart, @Nullable @Nullable TextIter matchEnd, @Nullable @Nullable TextIter limit) Searches forward forstr
.Any match is returned by setting
matchStart
to the first character of the match andmatchEnd
to the first character after the match. The search will not continue pastlimit
. Note that a search is a linear or O(n) operation, so you may wish to uselimit
to avoid locking up your UI on large buffers.matchStart
will never be set to aGtkTextIter
located before this TextIter, even if there is a possiblematchEnd
after or at this TextIter.- Parameters:
str
- a search stringflags
- flags affecting how the search is donematchStart
- return location for start of matchmatchEnd
- return location for end of matchlimit
- location of last possiblematchEnd
, ornull
for the end of the buffer- Returns:
- whether a match was found
-
forwardSearch
public boolean forwardSearch(String str, TextSearchFlags flags, @Nullable @Nullable TextIter matchStart, @Nullable @Nullable TextIter matchEnd, @Nullable @Nullable TextIter limit) Searches forward forstr
.Any match is returned by setting
matchStart
to the first character of the match andmatchEnd
to the first character after the match. The search will not continue pastlimit
. Note that a search is a linear or O(n) operation, so you may wish to uselimit
to avoid locking up your UI on large buffers.matchStart
will never be set to aGtkTextIter
located before this TextIter, even if there is a possiblematchEnd
after or at this TextIter.- Parameters:
str
- a search stringflags
- flags affecting how the search is donematchStart
- return location for start of matchmatchEnd
- return location for end of matchlimit
- location of last possiblematchEnd
, ornull
for the end of the buffer- Returns:
- whether a match was found
-
forwardSentenceEnd
public boolean forwardSentenceEnd()Moves forward to the next sentence end.If this TextIter is at the end of a sentence, moves to the next end of sentence.
Sentence boundaries are determined by Pango and should be correct for nearly any language.
- Returns:
true
if this TextIter moved and is not the end iterator
-
forwardSentenceEnds
public boolean forwardSentenceEnds(int count) - Parameters:
count
- number of sentences to move- Returns:
true
if this TextIter moved and is not the end iterator
-
forwardToEnd
public void forwardToEnd()Moves this TextIter forward to the “end iterator”, which points one past the last valid character in the buffer.getChar()
called on the end iterator returns 0, which is convenient for writing loops. -
forwardToLineEnd
public boolean forwardToLineEnd()Moves the iterator to point to the paragraph delimiter characters.The possible characters are either a newline, a carriage return, a carriage return/newline in sequence, or the Unicode paragraph separator character.
If the iterator is already at the paragraph delimiter characters, moves to the paragraph delimiter characters for the next line. If this TextIter is on the last line in the buffer, which does not end in paragraph delimiters, moves to the end iterator (end of the last line), and returns
false
.- Returns:
true
if we moved and the new location is not the end iterator
-
forwardToTagToggle
Moves forward to the next toggle (on or off) of thetag
, or to the next toggle of any tag iftag
isnull
.If no matching tag toggles are found, returns
false
, otherwisetrue
. Does not return toggles located at this TextIter, only toggles after this TextIter. Sets this TextIter to the location of the toggle, or to the end of the buffer if no toggle is found.- Parameters:
tag
- aGtkTextTag
- Returns:
- whether we found a tag toggle after this TextIter
-
forwardVisibleCursorPosition
public boolean forwardVisibleCursorPosition()Moves this TextIter forward to the next visible cursor position.See
forwardCursorPosition()
for details.- Returns:
true
if we moved and the new position is dereferenceable
-
forwardVisibleCursorPositions
public boolean forwardVisibleCursorPositions(int count) Moves up tocount
visible cursor positions.See
forwardCursorPosition()
for details.- Parameters:
count
- number of positions to move- Returns:
true
if we moved and the new position is dereferenceable
-
forwardVisibleLine
public boolean forwardVisibleLine()Moves this TextIter to the start of the next visible line.Returns
true
if there was a next line to move to, andfalse
if this TextIter was simply moved to the end of the buffer and is now not dereferenceable, or if this TextIter was already at the end of the buffer.- Returns:
- whether this TextIter can be dereferenced
-
forwardVisibleLines
public boolean forwardVisibleLines(int count) Movescount
visible lines forward, if possible.If
count
would move past the start or end of the buffer, moves to the start or end of the buffer.The return value indicates whether the iterator moved onto a dereferenceable position; if the iterator didn’t move, or moved onto the end iterator, then
false
is returned. Ifcount
is 0, the function does nothing and returnsfalse
. Ifcount
is negative, moves backward by 0 -count
lines.- Parameters:
count
- number of lines to move forward- Returns:
- whether this TextIter moved and is dereferenceable
-
forwardVisibleWordEnd
public boolean forwardVisibleWordEnd()Moves forward to the next visible word end.If this TextIter is currently on a word end, moves forward to the next one after that.
Word breaks are determined by Pango and should be correct for nearly any language
- Returns:
true
if this TextIter moved and is not the end iterator
-
forwardVisibleWordEnds
public boolean forwardVisibleWordEnds(int count) CallsforwardVisibleWordEnd()
up tocount
times.- Parameters:
count
- number of times to move- Returns:
true
if this TextIter moved and is not the end iterator
-
forwardWordEnd
public boolean forwardWordEnd()Moves forward to the next word end.If this TextIter is currently on a word end, moves forward to the next one after that.
Word breaks are determined by Pango and should be correct for nearly any language.
- Returns:
true
if this TextIter moved and is not the end iterator
-
forwardWordEnds
public boolean forwardWordEnds(int count) CallsforwardWordEnd()
up tocount
times.- Parameters:
count
- number of times to move- Returns:
true
if this TextIter moved and is not the end iterator
-
free
public void free()Free an iterator allocated on the heap.This function is intended for use in language bindings, and is not especially useful for applications, because iterators can simply be allocated on the stack.
-
getBuffer
Returns theGtkTextBuffer
this iterator is associated with.- Returns:
- the buffer
-
getBytesInLine
public int getBytesInLine()Returns the number of bytes in the line containing this TextIter, including the paragraph delimiters.- Returns:
- number of bytes in the line
-
getChar
public int getChar()The Unicode character at this iterator is returned.Equivalent to operator* on a C++ iterator. If the element at this iterator is a non-character element, such as an image embedded in the buffer, the Unicode “unknown” character 0xFFFC is returned. If invoked on the end iterator, zero is returned; zero is not a valid Unicode character.
So you can write a loop which ends when this function returns 0.
- Returns:
- a Unicode character, or 0 if this TextIter is not dereferenceable
-
getCharsInLine
public int getCharsInLine()Returns the number of characters in the line containing this TextIter, including the paragraph delimiters.- Returns:
- number of characters in the line
-
getChildAnchor
If the location at this TextIter contains a child anchor, the anchor is returned.Otherwise,
null
is returned.- Returns:
- the anchor at this TextIter
-
getLanguage
Returns the language in effect at this TextIter.If no tags affecting language apply to this TextIter, the return value is identical to that of
Gtk.getDefaultLanguage()
.- Returns:
- language in effect at this TextIter
-
getLine
public int getLine()Returns the line number containing the iterator.Lines in a
GtkTextBuffer
are numbered beginning with 0 for the first line in the buffer.- Returns:
- a line number
-
getLineIndex
public int getLineIndex()Returns the byte index of the iterator, counting from the start of a newline-terminated line.Remember that
GtkTextBuffer
encodes text in UTF-8, and that characters can require a variable number of bytes to represent.- Returns:
- distance from start of line, in bytes
-
getLineOffset
public int getLineOffset()Returns the character offset of the iterator, counting from the start of a newline-terminated line.The first character on the line has offset 0.
- Returns:
- offset from start of line
-
getMarks
Returns a list of allGtkTextMark
at this location.Because marks are not iterable (they don’t take up any "space" in the buffer, they are just marks in between iterable locations), multiple marks can exist in the same place.
The returned list is not in any meaningful order.
- Returns:
- list of
GtkTextMark
-
getOffset
public int getOffset()Returns the character offset of an iterator.Each character in a
GtkTextBuffer
has an offset, starting with 0 for the first character in the buffer. UseTextBuffer.getIterAtOffset(org.gnome.gtk.TextIter, int)
to convert an offset back into an iterator.- Returns:
- a character offset
-
getPaintable
If the element at this TextIter is a paintable, the paintable is returned.Otherwise,
null
is returned.- Returns:
- the paintable at this TextIter
-
getSlice
Returns the text in the given range.A “slice” is an array of characters encoded in UTF-8 format, including the Unicode “unknown” character 0xFFFC for iterable non-character elements in the buffer, such as images. Because images are encoded in the slice, byte and character offsets in the returned array will correspond to byte offsets in the text buffer. Note that 0xFFFC can occur in normal text as well, so it is not a reliable indicator that a paintable or widget is in the buffer.
- Parameters:
end
- iterator at end of a range- Returns:
- slice of text from the buffer
-
getTags
-
getText
Returns text in the given range.If the range contains non-text elements such as images, the character and byte offsets in the returned string will not correspond to character and byte offsets in the buffer. If you want offsets to correspond, see
getSlice(org.gnome.gtk.TextIter)
.- Parameters:
end
- iterator at end of a range- Returns:
- array of characters from the buffer
-
getToggledTags
Returns a list ofGtkTextTag
that are toggled on or off at this point.If
toggledOn
istrue
, the list contains tags that are toggled on. If a tag is toggled on at this TextIter, then some non-empty range of characters following this TextIter has that tag applied to it. If a tag is toggled off, then some non-empty range following this TextIter does not have the tag applied to it.- Parameters:
toggledOn
-true
to get toggled-on tags- Returns:
- tags toggled at this point
-
getVisibleLineIndex
public int getVisibleLineIndex()Returns the number of bytes from the start of the line to the given this TextIter, not counting bytes that are invisible due to tags with the “invisible” flag toggled on.- Returns:
- byte index of this TextIter with respect to the start of the line
-
getVisibleLineOffset
public int getVisibleLineOffset()Returns the offset in characters from the start of the line to the given this TextIter, not counting characters that are invisible due to tags with the “invisible” flag toggled on.- Returns:
- offset in visible characters from the start of the line
-
getVisibleSlice
Returns visible text in the given range.Like
getSlice(org.gnome.gtk.TextIter)
, but invisible text is not included. Invisible text is usually invisible because aGtkTextTag
with the “invisible” attribute turned on has been applied to it.- Parameters:
end
- iterator at end of range- Returns:
- slice of text from the buffer
-
getVisibleText
Returns visible text in the given range.Like
getText(org.gnome.gtk.TextIter)
, but invisible text is not included. Invisible text is usually invisible because aGtkTextTag
with the “invisible” attribute turned on has been applied to it.- Parameters:
end
- iterator at end of range- Returns:
- string containing visible text in the range
-
hasTag
Returnstrue
if this TextIter points to a character that is part of a range tagged withtag
.See also
startsTag(org.gnome.gtk.TextTag)
andendsTag(org.gnome.gtk.TextTag)
.- Parameters:
tag
- aGtkTextTag
- Returns:
- whether this TextIter is tagged with
tag
-
inRange
-
insideSentence
public boolean insideSentence()Determines whether this TextIter is inside a sentence (as opposed to in between two sentences, e.g. after a period and before the first letter of the next sentence).Sentence boundaries are determined by Pango and should be correct for nearly any language.
- Returns:
true
if this TextIter is inside a sentence.
-
insideWord
public boolean insideWord()Determines whether the character pointed by this TextIter is part of a natural-language word (as opposed to say inside some whitespace).Word breaks are determined by Pango and should be correct for nearly any language.
Note that if
startsWord()
returnstrue
, then this function returnstrue
too, since this TextIter points to the first character of the word.- Returns:
true
if this TextIter is inside a word
-
isCursorPosition
public boolean isCursorPosition()Determine if this TextIter is at a cursor position.See
forwardCursorPosition()
orPango.LogAttr
orPango.break_(java.lang.String, int, org.gnome.pango.Analysis, org.gnome.pango.LogAttr[])
for details on what a cursor position is.- Returns:
true
if the cursor can be placed at this TextIter
-
isEnd
public boolean isEnd()Returnstrue
if this TextIter is the end iterator.This means it is one past the last dereferenceable iterator in the buffer.
isEnd()
is the most efficient way to check whether an iterator is the end iterator.- Returns:
- whether this TextIter is the end iterator
-
isStart
public boolean isStart()Returnstrue
if this TextIter is the first iterator in the buffer.- Returns:
- whether this TextIter is the first in the buffer
-
order
Swaps the value of this TextIter andsecond
ifsecond
comes before this TextIter in the buffer.That is, ensures that this TextIter and
second
are in sequence. Most text buffer functions that take a range call this automatically on your behalf, so there’s no real reason to call it yourself in those cases. There are some exceptions, such asinRange(org.gnome.gtk.TextIter, org.gnome.gtk.TextIter)
, that expect a pre-sorted range.- Parameters:
second
- anotherGtkTextIter
-
setLine
public void setLine(int lineNumber) Moves iterator this TextIter to the start of the linelineNumber
.If
lineNumber
is negative or larger than or equal to the number of lines in the buffer, moves this TextIter to the start of the last line in the buffer.- Parameters:
lineNumber
- line number (counted from 0)
-
setLineIndex
public void setLineIndex(int byteOnLine) Same assetLineOffset(int)
, but works with a byte index. The given byte index must be at the start of a character, it can’t be in the middle of a UTF-8 encoded character.- Parameters:
byteOnLine
- a byte index relative to the start of this TextIter’s current line
-
setLineOffset
public void setLineOffset(int charOnLine) Moves this TextIter within a line, to a new character (not byte) offset.The given character offset must be less than or equal to the number of characters in the line; if equal, this TextIter moves to the start of the next line. See
setLineIndex(int)
if you have a byte index rather than a character offset.- Parameters:
charOnLine
- a character offset relative to the start of this TextIter’s current line
-
setOffset
public void setOffset(int charOffset) Sets this TextIter to point tocharOffset
.charOffset
counts from the start of the entire text buffer, starting with 0.- Parameters:
charOffset
- a character number
-
setVisibleLineIndex
public void setVisibleLineIndex(int byteOnLine) LikesetLineIndex(int)
, but the index is in visible bytes, i.e. text with a tag making it invisible is not counted in the index.- Parameters:
byteOnLine
- a byte index
-
setVisibleLineOffset
public void setVisibleLineOffset(int charOnLine) LikesetLineOffset(int)
, but the offset is in visible characters, i.e. text with a tag making it invisible is not counted in the offset.- Parameters:
charOnLine
- a character offset
-
startsLine
public boolean startsLine()Returnstrue
if this TextIter begins a paragraph.This is the case if
getLineOffset()
would return 0. However this function is potentially more efficient thangetLineOffset()
, because it doesn’t have to compute the offset, it just has to see whether it’s 0.- Returns:
- whether this TextIter begins a line
-
startsSentence
public boolean startsSentence()Determines whether this TextIter begins a sentence.Sentence boundaries are determined by Pango and should be correct for nearly any language.
- Returns:
true
if this TextIter is at the start of a sentence.
-
startsTag
Returnstrue
iftag
is toggled on at exactly this point.If
tag
isnull
, returnstrue
if any tag is toggled on at this point.Note that if this function returns
true
, it means that this TextIter is at the beginning of the tagged range, and that the character at this TextIter is inside the tagged range. In other words, unlikeendsTag(org.gnome.gtk.TextTag)
, if this function returnstrue
,hasTag(org.gnome.gtk.TextTag)
will also returntrue
for the same parameters.- Parameters:
tag
- aGtkTextTag
- Returns:
- whether this TextIter is the start of a range tagged with
tag
-
startsWord
public boolean startsWord()Determines whether this TextIter begins a natural-language word.Word breaks are determined by Pango and should be correct for nearly any language.
- Returns:
true
if this TextIter is at the start of a word
-
togglesTag
Gets whether a range withtag
applied to it begins or ends at this TextIter.This is equivalent to (gtk_text_iter_starts_tag() || gtk_text_iter_ends_tag())
- Parameters:
tag
- aGtkTextTag
- Returns:
- whether
tag
is toggled on or off at this TextIter
-