Class TextIter

All Implemented Interfaces:
Proxy

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

Iterates over the contents of a 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 Details

    • TextIter

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

      public TextIter(Arena arena)
      Allocate a new TextIter.
      Parameters:
      arena - to control the memory allocation scope
    • TextIter

      public TextIter()
      Allocate a new TextIter. The memory is allocated with Arena.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 field dummy1
      dummy2 - value for the field dummy2
      dummy3 - value for the field dummy3
      dummy4 - value for the field dummy4
      dummy5 - value for the field dummy5
      dummy6 - value for the field dummy6
      dummy7 - value for the field dummy7
      dummy8 - value for the field dummy8
      dummy9 - value for the field dummy9
      dummy10 - value for the field dummy10
      dummy11 - value for the field dummy11
      dummy12 - value for the field dummy12
      dummy13 - value for the field dummy13
      dummy14 - value for the field dummy14
      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 with Arena.ofAuto().
      Parameters:
      dummy1 - value for the field dummy1
      dummy2 - value for the field dummy2
      dummy3 - value for the field dummy3
      dummy4 - value for the field dummy4
      dummy5 - value for the field dummy5
      dummy6 - value for the field dummy6
      dummy7 - value for the field dummy7
      dummy8 - value for the field dummy8
      dummy9 - value for the field dummy9
      dummy10 - value for the field dummy10
      dummy11 - value for the field dummy11
      dummy12 - value for the field dummy12
      dummy13 - value for the field dummy13
      dummy14 - value for the field dummy14
  • Method Details

    • getType

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

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

      public MemorySegment readDummy1()
      Read the value of the field dummy1.
      Returns:
      The value of the field dummy1
    • writeDummy1

      public void writeDummy1(MemorySegment dummy1)
      Write a value in the field dummy1.
      Parameters:
      dummy1 - The new value for the field dummy1
    • readDummy2

      public MemorySegment readDummy2()
      Read the value of the field dummy2.
      Returns:
      The value of the field dummy2
    • writeDummy2

      public void writeDummy2(MemorySegment dummy2)
      Write a value in the field dummy2.
      Parameters:
      dummy2 - The new value for the field dummy2
    • readDummy3

      public int readDummy3()
      Read the value of the field dummy3.
      Returns:
      The value of the field dummy3
    • writeDummy3

      public void writeDummy3(int dummy3)
      Write a value in the field dummy3.
      Parameters:
      dummy3 - The new value for the field dummy3
    • readDummy4

      public int readDummy4()
      Read the value of the field dummy4.
      Returns:
      The value of the field dummy4
    • writeDummy4

      public void writeDummy4(int dummy4)
      Write a value in the field dummy4.
      Parameters:
      dummy4 - The new value for the field dummy4
    • readDummy5

      public int readDummy5()
      Read the value of the field dummy5.
      Returns:
      The value of the field dummy5
    • writeDummy5

      public void writeDummy5(int dummy5)
      Write a value in the field dummy5.
      Parameters:
      dummy5 - The new value for the field dummy5
    • readDummy6

      public int readDummy6()
      Read the value of the field dummy6.
      Returns:
      The value of the field dummy6
    • writeDummy6

      public void writeDummy6(int dummy6)
      Write a value in the field dummy6.
      Parameters:
      dummy6 - The new value for the field dummy6
    • readDummy7

      public int readDummy7()
      Read the value of the field dummy7.
      Returns:
      The value of the field dummy7
    • writeDummy7

      public void writeDummy7(int dummy7)
      Write a value in the field dummy7.
      Parameters:
      dummy7 - The new value for the field dummy7
    • readDummy8

      public int readDummy8()
      Read the value of the field dummy8.
      Returns:
      The value of the field dummy8
    • writeDummy8

      public void writeDummy8(int dummy8)
      Write a value in the field dummy8.
      Parameters:
      dummy8 - The new value for the field dummy8
    • readDummy9

      public MemorySegment readDummy9()
      Read the value of the field dummy9.
      Returns:
      The value of the field dummy9
    • writeDummy9

      public void writeDummy9(MemorySegment dummy9)
      Write a value in the field dummy9.
      Parameters:
      dummy9 - The new value for the field dummy9
    • readDummy10

      public MemorySegment readDummy10()
      Read the value of the field dummy10.
      Returns:
      The value of the field dummy10
    • writeDummy10

      public void writeDummy10(MemorySegment dummy10)
      Write a value in the field dummy10.
      Parameters:
      dummy10 - The new value for the field dummy10
    • readDummy11

      public int readDummy11()
      Read the value of the field dummy11.
      Returns:
      The value of the field dummy11
    • writeDummy11

      public void writeDummy11(int dummy11)
      Write a value in the field dummy11.
      Parameters:
      dummy11 - The new value for the field dummy11
    • readDummy12

      public int readDummy12()
      Read the value of the field dummy12.
      Returns:
      The value of the field dummy12
    • writeDummy12

      public void writeDummy12(int dummy12)
      Write a value in the field dummy12.
      Parameters:
      dummy12 - The new value for the field dummy12
    • readDummy13

      public int readDummy13()
      Read the value of the field dummy13.
      Returns:
      The value of the field dummy13
    • writeDummy13

      public void writeDummy13(int dummy13)
      Write a value in the field dummy13.
      Parameters:
      dummy13 - The new value for the field dummy13
    • readDummy14

      public MemorySegment readDummy14()
      Read the value of the field dummy14.
      Returns:
      The value of the field dummy14
    • writeDummy14

      public void writeDummy14(MemorySegment dummy14)
      Write a value in the field dummy14.
      Parameters:
      dummy14 - The new value for the field dummy14
    • assign

      public void assign(TextIter other)

      Assigns the value of other to iter.

      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 - another GtkTextIter
    • 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 returns false for convenience when writing loops.

      Returns:
      whether movement was possible
    • backwardChars

      public boolean backwardChars(int count)

      Moves count 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. If count is 0, the function does nothing and returns false.

      Parameters:
      count - number of characters to move
      Returns:
      whether this TextIter moved and is dereferenceable
    • backwardCursorPosition

      public boolean backwardCursorPosition()
      Like forwardCursorPosition(), but moves backward.
      Returns:
      true if we moved
    • backwardCursorPositions

      public boolean backwardCursorPositions(int count)

      Moves up to count 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

      public boolean backwardFindChar(@Nullable TextCharPredicate pred, @Nullable TextIter limit)
      Same as forwardFindChar(TextCharPredicate, TextIter), but goes backward from iter.
      Parameters:
      pred - function to be called on each character
      limit - 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 returns false. 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 returns true. (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)

      Moves count 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. If count is 0, the function does nothing and returns false. If count 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 TextIter matchStart, @Nullable TextIter matchEnd, @Nullable TextIter limit)

      Same as forwardSearch(String, Set, TextIter, TextIter, TextIter), but moves backward.

      matchEnd will never be set to a GtkTextIter located after iter, even if there is a possible matchStart before or at iter.

      Parameters:
      str - search string
      flags - bitmask of flags affecting the search
      matchStart - return location for start of match
      matchEnd - return location for end of match
      limit - location of last possible matchStart, or null for 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 as forwardSearch(String, Set, TextIter, TextIter, TextIter), but moves backward.

      matchEnd will never be set to a GtkTextIter located after iter, even if there is a possible matchStart before or at iter.

      Parameters:
      str - search string
      flags - bitmask of flags affecting the search
      matchStart - return location for start of match
      matchEnd - return location for end of match
      limit - location of last possible matchStart, or null 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)

      Calls backwardSentenceStart() up to count 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

      public boolean backwardToTagToggle(@Nullable TextTag tag)

      Moves backward to the next toggle (on or off) of the tag, or to the next toggle of any tag if tag is null.

      If no matching tag toggles are found, returns false, otherwise true. Does not return toggles located at iter, only toggles before iter. Sets this TextIter to the location of the toggle, or the start of the buffer if no toggle is found.

      Parameters:
      tag - a GtkTextTag
      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 to count 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 returns false. 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 returns true. (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)

      Moves count 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. If count is 0, the function does nothing and returns false. If count 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)
      Calls backwardVisibleWordStart() up to count 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)
      Calls backwardWordStart() up to count 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 iter. TextBuffer.insertInteractive(TextIter, 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

      public int compare(TextIter rhs)

      A qsort()-style function that returns negative if this TextIter is less than rhs, positive if this TextIter is greater than rhs, 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 - another GtkTextIter
      Returns:
      -1 if this TextIter is less than rhs, 1 if this TextIter is greater, 0 if they are equal
    • copy

      public TextIter copy()

      Creates a dynamically-allocated copy of an iterator.

      This function is not useful in applications, because iterators can be copied with a simple assignment (GtkTextIter i = j;).

      The function is used by language bindings.

      Returns:
      a copy of the iter, free with free()
    • 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 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. 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()

      Returns true 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

      public boolean endsTag(@Nullable TextTag tag)

      Returns true if tag is toggled off at exactly this point.

      If tag is null, returns true 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, unlike startsTag(TextTag), if this function returns true, hasTag(TextTag) will return false for the same parameters.

      Parameters:
      tag - a GtkTextTag
      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

      public boolean equal(TextIter rhs)

      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(TextIter).

      Parameters:
      rhs - another GtkTextIter
      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)

      Moves count 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 returns false.

      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 the Pango#break_ function.

      Returns:
      true if we moved and the new position is dereferenceable
    • forwardCursorPositions

      public boolean forwardCursorPositions(int count)

      Moves up to count 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

      public boolean forwardFindChar(@Nullable TextCharPredicate pred, @Nullable TextIter limit)

      Advances iter, calling pred on each character.

      If pred returns true, returns true and stops scanning. If pred never returns true, this TextIter is set to limit if limit is non-null, otherwise to the end iterator.

      Parameters:
      pred - a function to be called on each character
      limit - 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, returns true.

      Returns:
      whether this TextIter can be dereferenced
    • forwardLines

      public boolean forwardLines(int count)

      Moves count 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. If count is 0, the function does nothing and returns false. If count 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 TextIter matchStart, @Nullable TextIter matchEnd, @Nullable TextIter limit)

      Searches forward for str.

      Any match is returned by setting matchStart to the first character of the match and matchEnd to the first character after the match. The search will not continue past limit. Note that a search is a linear or O(n) operation, so you may wish to use limit to avoid locking up your UI on large buffers.

      matchStart will never be set to a GtkTextIter located before iter, even if there is a possible matchEnd after or at iter.

      Parameters:
      str - a search string
      flags - flags affecting how the search is done
      matchStart - return location for start of match
      matchEnd - return location for end of match
      limit - location of last possible matchEnd, or null for 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 for str.

      Any match is returned by setting matchStart to the first character of the match and matchEnd to the first character after the match. The search will not continue past limit. Note that a search is a linear or O(n) operation, so you may wish to use limit to avoid locking up your UI on large buffers.

      matchStart will never be set to a GtkTextIter located before iter, even if there is a possible matchEnd after or at iter.

      Parameters:
      str - a search string
      flags - flags affecting how the search is done
      matchStart - return location for start of match
      matchEnd - return location for end of match
      limit - location of last possible matchEnd, or null 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)

      Calls forwardSentenceEnd() count times.

      If count is negative, moves backward instead of forward.

      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

      public boolean forwardToTagToggle(@Nullable TextTag tag)

      Moves forward to the next toggle (on or off) of the tag, or to the next toggle of any tag if tag is null.

      If no matching tag toggles are found, returns false, otherwise true. Does not return toggles located at iter, only toggles after iter. Sets this TextIter to the location of the toggle, or to the end of the buffer if no toggle is found.

      Parameters:
      tag - a GtkTextTag
      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 to count 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, and false 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)

      Moves count 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. If count is 0, the function does nothing and returns false. If count 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)
      Calls forwardVisibleWordEnd() up to count 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)
      Calls forwardWordEnd() up to count 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

      public TextBuffer getBuffer()
      Returns the GtkTextBuffer this iterator is associated with.
      Returns:
      the buffer
    • getBytesInLine

      public int getBytesInLine()
      Returns the number of bytes in the line containing iter, 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 iter, including the paragraph delimiters.
      Returns:
      number of characters in the line
    • getChildAnchor

      public @Nullable TextChildAnchor 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

      public Language getLanguage()

      Returns the language in effect at iter.

      If no tags affecting language apply to iter, 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

      public SList<TextMark> getMarks()

      Returns a list of all GtkTextMark 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. Use TextBuffer.getIterAtOffset(TextIter, int) to convert an offset back into an iterator.

      Returns:
      a character offset
    • getPaintable

      public @Nullable Paintable 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

      public String getSlice(TextIter end)

      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

      public SList<TextTag> getTags()

      Returns a list of tags that apply to iter, in ascending order of priority.

      The highest-priority tags are last.

      The GtkTextTags in the list don’t have a reference added, but you have to free the list itself.

      Returns:
      list of GtkTextTag
    • getText

      public String getText(TextIter end)

      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(TextIter).

      Parameters:
      end - iterator at end of a range
      Returns:
      array of characters from the buffer
    • getToggledTags

      public SList<TextTag> getToggledTags(boolean toggledOn)

      Returns a list of GtkTextTag that are toggled on or off at this point.

      If toggledOn is true, the list contains tags that are toggled on. If a tag is toggled on at iter, 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 iter, 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 iter, 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

      public String getVisibleSlice(TextIter end)

      Returns visible text in the given range.

      Like getSlice(TextIter), but invisible text is not included. Invisible text is usually invisible because a GtkTextTag 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

      public String getVisibleText(TextIter end)

      Returns visible text in the given range.

      Like getText(TextIter), but invisible text is not included. Invisible text is usually invisible because a GtkTextTag 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

      public boolean hasTag(TextTag tag)

      Returns true if this TextIter points to a character that is part of a range tagged with tag.

      See also startsTag(TextTag) and endsTag(TextTag).

      Parameters:
      tag - a GtkTextTag
      Returns:
      whether this TextIter is tagged with tag
    • inRange

      public boolean inRange(TextIter start, TextIter end)

      Checks whether this TextIter falls in the range [start, end).

      start and end must be in ascending order.

      Parameters:
      start - start of range
      end - end of range
      Returns:
      true if this TextIter is in the range
    • 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() returns true, then this function returns true 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() or Pango.LogAttr or Pango#break_ for details on what a cursor position is.

      Returns:
      true if the cursor can be placed at this TextIter
    • isEnd

      public boolean isEnd()

      Returns true 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()
      Returns true if this TextIter is the first iterator in the buffer.
      Returns:
      whether this TextIter is the first in the buffer
    • order

      public void order(TextIter second)

      Swaps the value of this TextIter and second if second 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 as inRange(TextIter, TextIter), that expect a pre-sorted range.

      Parameters:
      second - another GtkTextIter
    • setLine

      public void setLine(int lineNumber)

      Moves iterator this TextIter to the start of the line lineNumber.

      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 as setLineOffset(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 iter’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 iter’s current line
    • setOffset

      public void setOffset(int charOffset)

      Sets this TextIter to point to charOffset.

      charOffset counts from the start of the entire text buffer, starting with 0.

      Parameters:
      charOffset - a character number
    • setVisibleLineIndex

      public void setVisibleLineIndex(int byteOnLine)
      Like setLineIndex(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)
      Like setLineOffset(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()

      Returns true if this TextIter begins a paragraph.

      This is the case if getLineOffset() would return 0. However this function is potentially more efficient than getLineOffset(), 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

      public boolean startsTag(@Nullable TextTag tag)

      Returns true if tag is toggled on at exactly this point.

      If tag is null, returns true 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, unlike endsTag(TextTag), if this function returns true, hasTag(TextTag) will also return true for the same parameters.

      Parameters:
      tag - a GtkTextTag
      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

      public boolean togglesTag(@Nullable TextTag tag)

      Gets whether a range with tag applied to it begins or ends at iter.

      This is equivalent to (gtk_text_iter_starts_tag() || gtk_text_iter_ends_tag())

      Parameters:
      tag - a GtkTextTag
      Returns:
      whether tag is toggled on or off at this TextIter