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
ConstructorsConstructorDescriptionTextIter()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 TypeMethodDescriptionvoidAssigns the value ofothertoiter.booleanMoves backward by one character offset.booleanbackwardChars(int count) Movescountcharacters backward, if possible.booleanLikeforwardCursorPosition(), but moves backward.booleanbackwardCursorPositions(int count) Moves up tocountcursor positions.booleanbackwardFindChar(@Nullable TextCharPredicate pred, @Nullable TextIter limit) Same asforwardFindChar(org.gnome.gtk.TextCharPredicate, org.gnome.gtk.TextIter), but goes backward fromiter.booleanMoves this TextIter to the start of the previous line.booleanbackwardLines(int count) Movescountlines backward, if possible.booleanbackwardSearch(String str, Set<TextSearchFlags> flags, @Nullable TextIter matchStart, @Nullable TextIter matchEnd, @Nullable TextIter limit) booleanbackwardSearch(String str, TextSearchFlags flags, @Nullable TextIter matchStart, @Nullable TextIter matchEnd, @Nullable TextIter limit) booleanMoves backward to the previous sentence start.booleanbackwardSentenceStarts(int count) CallsbackwardSentenceStart()up tocounttimes.booleanbackwardToTagToggle(@Nullable TextTag tag) Moves backward to the next toggle (on or off) of thetag,or to the next toggle of any tag iftagisnull.booleanMoves this TextIter backward to the previous visible cursor position.booleanbackwardVisibleCursorPositions(int count) Moves up tocountvisible cursor positions.booleanMoves this TextIter to the start of the previous visible line.booleanbackwardVisibleLines(int count) Movescountvisible lines backward, if possible.booleanMoves backward to the previous visible word start.booleanbackwardVisibleWordStarts(int count) CallsbackwardVisibleWordStart()up tocounttimes.booleanMoves backward to the previous word start.booleanbackwardWordStarts(int count) CallsbackwardWordStart()up tocounttimes.booleancanInsert(boolean defaultEditability) Considering the default editability of the buffer, and tags that affect editability, determines whether text inserted at this TextIter would be editable.intA 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.booleaneditable(boolean defaultSetting) Returns whether the character at this TextIter is within an editable region of text.booleanendsLine()Returnstrueif this TextIter points to the start of the paragraph delimiter characters for a line.booleanDetermines whether this TextIter ends a sentence.booleanReturnstrueiftagis toggled off at exactly this point.booleanendsWord()Determines whether this TextIter ends a natural-language word.booleanTests whether two iterators are equal, using the fastest possible mechanism.booleanMoves this TextIter forward by one character offset.booleanforwardChars(int count) Movescountcharacters if possible.booleanMoves this TextIter forward by a single cursor position.booleanforwardCursorPositions(int count) Moves up tocountcursor positions.booleanforwardFindChar(@Nullable TextCharPredicate pred, @Nullable TextIter limit) Advancesiter,callingpredon each character.booleanMoves this TextIter to the start of the next line.booleanforwardLines(int count) Movescountlines forward, if possible.booleanforwardSearch(String str, Set<TextSearchFlags> flags, @Nullable TextIter matchStart, @Nullable TextIter matchEnd, @Nullable TextIter limit) Searches forward forstr.booleanforwardSearch(String str, TextSearchFlags flags, @Nullable TextIter matchStart, @Nullable TextIter matchEnd, @Nullable TextIter limit) Searches forward forstr.booleanMoves forward to the next sentence end.booleanforwardSentenceEnds(int count) CallsforwardSentenceEnd()counttimes.voidMoves this TextIter forward to the “end iterator”, which points one past the last valid character in the buffer.booleanMoves the iterator to point to the paragraph delimiter characters.booleanforwardToTagToggle(@Nullable TextTag tag) Moves forward to the next toggle (on or off) of thetag,or to the next toggle of any tag iftagisnull.booleanMoves this TextIter forward to the next visible cursor position.booleanforwardVisibleCursorPositions(int count) Moves up tocountvisible cursor positions.booleanMoves this TextIter to the start of the next visible line.booleanforwardVisibleLines(int count) Movescountvisible lines forward, if possible.booleanMoves forward to the next visible word end.booleanforwardVisibleWordEnds(int count) CallsforwardVisibleWordEnd()up tocounttimes.booleanMoves forward to the next word end.booleanforwardWordEnds(int count) CallsforwardWordEnd()up tocounttimes.voidfree()Free an iterator allocated on the heap.Returns theGtkTextBufferthis iterator is associated with.intReturns the number of bytes in the line containingiter,including the paragraph delimiters.intgetChar()The Unicode character at this iterator is returned.intReturns the number of characters in the line containingiter,including the paragraph delimiters.@Nullable TextChildAnchorIf the location at this TextIter contains a child anchor, the anchor is returned.Returns the language in effect atiter.intgetLine()Returns the line number containing the iterator.intReturns the byte index of the iterator, counting from the start of a newline-terminated line.intReturns the character offset of the iterator, counting from the start of a newline-terminated line.getMarks()Returns a list of allGtkTextMarkat this location.static MemoryLayoutThe memory layout of the native struct.intReturns the character offset of an iterator.@Nullable PaintableIf 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 toiter,in ascending order of priority.Returns text in the given range.getToggledTags(boolean toggledOn) Returns a list ofGtkTextTagthat are toggled on or off at this point.static @Nullable TypegetType()Get the GType of the TextIter classintReturns the number of bytes from the start of the line to the giveniter,not counting bytes that are invisible due to tags with the “invisible” flag toggled on.intReturns the offset in characters from the start of the line to the giveniter,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.booleanReturnstrueif this TextIter points to a character that is part of a range tagged withtag.booleanChecks whether this TextIter falls in the range [start,end).booleanDetermines whether this TextIter is inside a sentence (as opposed to in between two sentences, e.g.booleanDetermines whether the character pointed by this TextIter is part of a natural-language word (as opposed to say inside some whitespace).booleanDetermine if this TextIter is at a cursor position.booleanisEnd()Returnstrueif this TextIter is the end iterator.booleanisStart()Returnstrueif this TextIter is the first iterator in the buffer.voidSwaps the value of this TextIter andsecondifsecondcomes before this TextIter in the buffer.Read the value of the fielddummy1.Read the value of the fielddummy10.intRead the value of the fielddummy11.intRead the value of the fielddummy12.intRead the value of the fielddummy13.Read the value of the fielddummy14.Read the value of the fielddummy2.intRead the value of the fielddummy3.intRead the value of the fielddummy4.intRead the value of the fielddummy5.intRead the value of the fielddummy6.intRead the value of the fielddummy7.intRead the value of the fielddummy8.Read the value of the fielddummy9.voidsetLine(int lineNumber) Moves iterator this TextIter to the start of the linelineNumber.voidsetLineIndex(int byteOnLine) Same assetLineOffset(int), but works with a byte index.voidsetLineOffset(int charOnLine) Moves this TextIter within a line, to a new character (not byte) offset.voidsetOffset(int charOffset) Sets this TextIter to point tocharOffset.voidsetVisibleLineIndex(int byteOnLine) LikesetLineIndex(int), but the index is in visible bytes, i.e.voidsetVisibleLineOffset(int charOnLine) LikesetLineOffset(int), but the offset is in visible characters, i.e.booleanReturnstrueif this TextIter begins a paragraph.booleanDetermines whether this TextIter begins a sentence.booleanReturnstrueiftagis toggled on at exactly this point.booleanDetermines whether this TextIter begins a natural-language word.booleantogglesTag(@Nullable TextTag tag) Gets whether a range withtagapplied to it begins or ends atiter.voidwriteDummy1(MemorySegment dummy1) Write a value in the fielddummy1.voidwriteDummy10(MemorySegment dummy10) Write a value in the fielddummy10.voidwriteDummy11(int dummy11) Write a value in the fielddummy11.voidwriteDummy12(int dummy12) Write a value in the fielddummy12.voidwriteDummy13(int dummy13) Write a value in the fielddummy13.voidwriteDummy14(MemorySegment dummy14) Write a value in the fielddummy14.voidwriteDummy2(MemorySegment dummy2) Write a value in the fielddummy2.voidwriteDummy3(int dummy3) Write a value in the fielddummy3.voidwriteDummy4(int dummy4) Write a value in the fielddummy4.voidwriteDummy5(int dummy5) Write a value in the fielddummy5.voidwriteDummy6(int dummy6) Write a value in the fielddummy6.voidwriteDummy7(int dummy7) Write a value in the fielddummy7.voidwriteDummy8(int dummy8) Write a value in the fielddummy8.voidwriteDummy9(MemorySegment dummy9) Write a value in the fielddummy9.Methods inherited from class org.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 fielddummy1dummy2- value for the fielddummy2dummy3- value for the fielddummy3dummy4- value for the fielddummy4dummy5- value for the fielddummy5dummy6- value for the fielddummy6dummy7- value for the fielddummy7dummy8- value for the fielddummy8dummy9- value for the fielddummy9dummy10- value for the fielddummy10dummy11- value for the fielddummy11dummy12- value for the fielddummy12dummy13- value for the fielddummy13dummy14- value for the fielddummy14arena- 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 fielddummy1dummy2- value for the fielddummy2dummy3- value for the fielddummy3dummy4- value for the fielddummy4dummy5- value for the fielddummy5dummy6- value for the fielddummy6dummy7- value for the fielddummy7dummy8- value for the fielddummy8dummy9- value for the fielddummy9dummy10- value for the fielddummy10dummy11- value for the fielddummy11dummy12- value for the fielddummy12dummy13- value for the fielddummy13dummy14- 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 ofothertoiter.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
trueif movement was possible; if this TextIter was the first in the buffer (character offset 0), this function returnsfalsefor convenience when writing loops.- Returns:
- whether movement was possible
-
backwardChars
public boolean backwardChars(int count) Movescountcharacters backward, if possible.If
countwould 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
falseis returned. Ifcountis 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:
trueif we moved
-
backwardCursorPositions
public boolean backwardCursorPositions(int count) Moves up tocountcursor positions.See
forwardCursorPosition()for details.- Parameters:
count- number of positions to move- Returns:
trueif we moved and the new position is dereferenceable
-
backwardFindChar
Same asforwardFindChar(org.gnome.gtk.TextCharPredicate, org.gnome.gtk.TextIter), but goes backward fromiter.- 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
trueif 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) Movescountlines backward, if possible.If
countwould 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
falseis returned. Ifcountis 0, the function does nothing and returnsfalse. Ifcountis negative, moves forward by 0 -countlines.- 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 TextIter matchStart, @Nullable TextIter matchEnd, @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.matchEndwill never be set to aGtkTextIterlocated afteriter,even if there is a possiblematchStartbefore or atiter.- 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,ornullfor start of buffer- Returns:
- whether a match was found
-
backwardSearch
public boolean backwardSearch(String str, TextSearchFlags flags, @Nullable TextIter matchStart, @Nullable TextIter matchEnd, @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.matchEndwill never be set to aGtkTextIterlocated afteriter,even if there is a possiblematchStartbefore or atiter.- 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,ornullfor 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:
trueif this TextIter moved and is not the end iterator
-
backwardSentenceStarts
public boolean backwardSentenceStarts(int count) CallsbackwardSentenceStart()up tocounttimes.If
countis negative, moves forward instead of backward.- Parameters:
count- number of sentences to move- Returns:
trueif 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 iftagisnull.If no matching tag toggles are found, returns
false, otherwisetrue. Does not return toggles located atiter,only toggles beforeiter.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:
trueif we moved and the new position is dereferenceable
-
backwardVisibleCursorPositions
public boolean backwardVisibleCursorPositions(int count) Moves up tocountvisible cursor positions.See
backwardCursorPosition()for details.- Parameters:
count- number of positions to move- Returns:
trueif we moved and the new position is dereferenceable
-
backwardVisibleLine
public boolean backwardVisibleLine()Moves this TextIter to the start of the previous visible line.Returns
trueif 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) Movescountvisible lines backward, if possible.If
countwould 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
falseis returned. Ifcountis 0, the function does nothing and returnsfalse. Ifcountis negative, moves forward by 0 -countlines.- 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:
trueif this TextIter moved and is not the end iterator
-
backwardVisibleWordStarts
public boolean backwardVisibleWordStarts(int count) CallsbackwardVisibleWordStart()up tocounttimes.- Parameters:
count- number of times to move- Returns:
trueif 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:
trueif this TextIter moved and is not the end iterator
-
backwardWordStarts
public boolean backwardWordStarts(int count) CallsbackwardWordStart()up tocounttimes.- Parameters:
count- number of times to move- Returns:
trueif 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
iter.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-trueif 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,defaultSettingwill be returned.You don’t want to use this function to decide whether text can be inserted at
iter,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. UsecanInsert(boolean)to handle this case.- Parameters:
defaultSetting-trueif text is editable by default- Returns:
- whether this TextIter is inside an editable range
-
endsLine
public boolean endsLine()Returnstrueif 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:
trueif this TextIter is at the end of a sentence.
-
endsTag
Returnstrueiftagis toggled off at exactly this point.If
tagisnull, returnstrueif 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 returnfalsefor 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:
trueif 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:
trueif 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
falsefor convenience when writing loops.- Returns:
- whether this TextIter moved and is dereferenceable
-
forwardChars
public boolean forwardChars(int count) Movescountcharacters if possible.If
countwould 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
countis 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.LogAttrstruct and thePango.break_(java.lang.String, int, org.gnome.pango.Analysis, org.javagi.base.Out<org.gnome.pango.LogAttr[]>)function.- Returns:
trueif we moved and the new position is dereferenceable
-
forwardCursorPositions
public boolean forwardCursorPositions(int count) Moves up tocountcursor positions.See
forwardCursorPosition()for details.- Parameters:
count- number of positions to move- Returns:
trueif we moved and the new position is dereferenceable
-
forwardFindChar
Advancesiter,callingpredon each character.If
predreturnstrue, returnstrueand stops scanning. Ifprednever returnstrue, this TextIter is set tolimitiflimitis 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) Movescountlines forward, if possible.If
countwould 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
falseis returned. Ifcountis 0, the function does nothing and returnsfalse. Ifcountis negative, moves backward by 0 -countlines.- 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 TextIter matchStart, @Nullable TextIter matchEnd, @Nullable TextIter limit) Searches forward forstr.Any match is returned by setting
matchStartto the first character of the match andmatchEndto 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 uselimitto avoid locking up your UI on large buffers.matchStartwill never be set to aGtkTextIterlocated beforeiter,even if there is a possiblematchEndafter or atiter.- 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,ornullfor the end of the buffer- Returns:
- whether a match was found
-
forwardSearch
public boolean forwardSearch(String str, TextSearchFlags flags, @Nullable TextIter matchStart, @Nullable TextIter matchEnd, @Nullable TextIter limit) Searches forward forstr.Any match is returned by setting
matchStartto the first character of the match andmatchEndto 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 uselimitto avoid locking up your UI on large buffers.matchStartwill never be set to aGtkTextIterlocated beforeiter,even if there is a possiblematchEndafter or atiter.- 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,ornullfor 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:
trueif this TextIter moved and is not the end iterator
-
forwardSentenceEnds
public boolean forwardSentenceEnds(int count) - Parameters:
count- number of sentences to move- Returns:
trueif 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:
trueif 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 iftagisnull.If no matching tag toggles are found, returns
false, otherwisetrue. Does not return toggles located atiter,only toggles afteriter.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:
trueif we moved and the new position is dereferenceable
-
forwardVisibleCursorPositions
public boolean forwardVisibleCursorPositions(int count) Moves up tocountvisible cursor positions.See
forwardCursorPosition()for details.- Parameters:
count- number of positions to move- Returns:
trueif we moved and the new position is dereferenceable
-
forwardVisibleLine
public boolean forwardVisibleLine()Moves this TextIter to the start of the next visible line.Returns
trueif there was a next line to move to, andfalseif 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) Movescountvisible lines forward, if possible.If
countwould 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
falseis returned. Ifcountis 0, the function does nothing and returnsfalse. Ifcountis negative, moves backward by 0 -countlines.- 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:
trueif this TextIter moved and is not the end iterator
-
forwardVisibleWordEnds
public boolean forwardVisibleWordEnds(int count) CallsforwardVisibleWordEnd()up tocounttimes.- Parameters:
count- number of times to move- Returns:
trueif 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:
trueif this TextIter moved and is not the end iterator
-
forwardWordEnds
public boolean forwardWordEnds(int count) CallsforwardWordEnd()up tocounttimes.- Parameters:
count- number of times to move- Returns:
trueif 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 theGtkTextBufferthis iterator is associated with.- Returns:
- the buffer
-
getBytesInLine
public int getBytesInLine()Returns the number of bytes in the line containingiter,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 containingiter,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,
nullis returned.- Returns:
- the anchor at this TextIter
-
getLanguage
Returns the language in effect atiter.If no tags affecting language apply to
iter,the return value is identical to that ofGtk.getDefaultLanguage().- Returns:
- language in effect at this TextIter
-
getLine
public int getLine()Returns the line number containing the iterator.Lines in a
GtkTextBufferare 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
GtkTextBufferencodes 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 allGtkTextMarkat 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
GtkTextBufferhas 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,
nullis 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 ofGtkTextTagthat are toggled on or off at this point.If
toggledOnistrue, the list contains tags that are toggled on. If a tag is toggled on atiter,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-trueto 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 giveniter,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 giveniter,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 aGtkTextTagwith 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 aGtkTextTagwith 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
Returnstrueif 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:
trueif 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 returnstruetoo, since this TextIter points to the first character of the word.- Returns:
trueif this TextIter is inside a word
-
isCursorPosition
public boolean isCursorPosition()Determine if this TextIter is at a cursor position.See
forwardCursorPosition()orPango.LogAttrorPango.break_(java.lang.String, int, org.gnome.pango.Analysis, org.javagi.base.Out<org.gnome.pango.LogAttr[]>)for details on what a cursor position is.- Returns:
trueif the cursor can be placed at this TextIter
-
isEnd
public boolean isEnd()Returnstrueif 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()Returnstrueif 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 andsecondifsecondcomes before this TextIter in the buffer.That is, ensures that this TextIter and
secondare 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
lineNumberis 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 ofiter’scurrent 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 ofiter’scurrent line
-
setOffset
public void setOffset(int charOffset) Sets this TextIter to point tocharOffset.charOffsetcounts 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()Returnstrueif 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:
trueif this TextIter is at the start of a sentence.
-
startsTag
Returnstrueiftagis toggled on at exactly this point.If
tagisnull, returnstrueif 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 returntruefor 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:
trueif this TextIter is at the start of a word
-
togglesTag
Gets whether a range withtagapplied to it begins or ends atiter.This is equivalent to (gtk_text_iter_starts_tag() || gtk_text_iter_ends_tag())
- Parameters:
tag- aGtkTextTag- Returns:
- whether
tagis toggled on or off at this TextIter
-