Gtk.TextIter


Gtk.TextIter — Text buffer iterator

Object Hierarchy:

    GBoxed
    ╰── Gtk.TextIter

Functions:

Description:

You may wish to begin by reading the [text widget conceptual overview][TextWidget] which gives an overview of all the objects and data types related to the text widget and how they work together.


Function Details:

get_buffer()

get_buffer (self) -> Gtk.TextBuffer

Returns the Gtk.TextBuffer this iterator is associated with.

  • Returns: the buffer.

copy()

copy (self) -> Gtk.TextIter

Creates a dynamically-allocated copy of an iterator. This functionis not useful in applications, because iterators can be copied with asimple assignment (`Gtk.TextIter i = j;`). Thefunction is used by language bindings.

  • Returns: a copy of the iter, free with Gtk.TextIter:free()

assign()

assign (self, other:Gtk.TextIter)

Assigns the value of other to iter. This functionis not useful in applications, because iterators can be assignedwith `Gtk.TextIter i = j;`. Thefunction is used by language bindings.

  • Since: 3.2

free()

free (self)

Free an iterator allocated on the heap. This functionis intended for use in language bindings, and is notespecially useful for applications, because iterators cansimply be allocated on the stack.


get_offset()

get_offset (self) -> int

Returns the character offset of an iterator.Each character in a Gtk.TextBuffer has an offset,starting with 0 for the first character in the buffer.Use `Gtk.TextBuffer:get_iter_at_offset()` to convert anoffset back into an iterator.

  • Returns: a character offset

get_line()

get_line (self) -> int

Returns the line number containing the iterator. Lines ina Gtk.TextBuffer are numbered beginning with 0 for the firstline in the buffer.

  • Returns: a line number

get_line_offset()

get_line_offset (self) -> int

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

get_line_index()

get_line_index (self) -> int

Returns the byte index of the iterator, countingfrom the start of a newline-terminated line.Remember that Gtk.TextBuffer encodes text inUTF-8, and that characters can require a variablenumber of bytes to represent.

  • Returns: distance from start of line, in bytes

get_visible_line_index()

get_visible_line_index (self) -> int

Returns the number of bytes from the start of theline to the given iter, not counting bytes thatare invisible due to tags with the “invisible” flagtoggled on.

  • Returns: byte index of iterwith respect to the start of the line

get_visible_line_offset()

get_visible_line_offset (self) -> int

Returns the offset in characters from the start of theline to the given iter, not counting characters thatare invisible due to tags with the “invisible” flagtoggled on.

  • Returns: offset in visible characters from the start of the line

get_char()

get_char (self) -> str

The Unicode character at this iterator is returned. (Equivalent tooperator* on a C++ iterator.) If the element at this iterator is anon-character element, such as an image embedded in the buffer, theUnicode “unknown” character 0xFFFC is returned. If invoked onthe end iterator, zero is returned; zero is not a valid Unicode character.So you can write a loop which ends when Gtk.TextIter:get_char()returns 0.

  • Returns: a Unicode character, or 0 if iteris not dereferenceable

get_slice()

get_slice (self, end:Gtk.TextIter) -> str

Returns the text in the given range. A “slice” is an array ofcharacters 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 andcharacter offsets in the returned array will correspond to byteoffsets in the text buffer. Note that 0xFFFC can occur in normaltext as well, so it is not a reliable indicator that a pixbuf orwidget is in the buffer.

  • Returns: slice of text from the buffer.

get_text()

get_text (self, end:Gtk.TextIter) -> str

Returns text in the given range. If the rangecontains non-text elements such as images, the character and byteoffsets in the returned string will not correspond to character andbyte offsets in the buffer. If you want offsets to correspond, seeGtk.TextIter:get_slice().

  • Returns: array of characters from the buffer.

get_visible_slice()

get_visible_slice (self, end:Gtk.TextIter) -> str

Like Gtk.TextIter:get_slice(), but invisible text is not included.Invisible text is usually invisible because a Gtk.TextTag with the“invisible” attribute turned on has been applied to it.

  • Returns: slice of text from the buffer.

get_visible_text()

get_visible_text (self, end:Gtk.TextIter) -> str

Like Gtk.TextIter:get_text(), but invisible text is not included.Invisible text is usually invisible because a Gtk.TextTag with the“invisible” attribute turned on has been applied to it.

  • Returns: string containing visible text in therange.

get_pixbuf()

get_pixbuf (self) -> GdkPixbuf.Pixbuf

If the element at iter is a pixbuf, the pixbuf is returned(with no new reference count added). Otherwise,None is returned.

  • Returns: the pixbuf at iter.

get_marks()

get_marks (self) -> list

Returns a list of all Gtk.TextMark at this location. Because marksare not iterable (they don’t take up any "space" in the buffer,they are just marks in between iterable locations), multiple markscan exist in the same place. The returned list is not in anymeaningful order.

  • Returns: list of Gtk.TextMark.

get_toggled_tags()

get_toggled_tags (self, toggled_on:bool) -> list

Returns a list of Gtk.TextTag that are toggled on or off at thispoint. (If toggled_on is True, the list contains tags that aretoggled on.) If a tag is toggled on at iter, then some non-emptyrange of characters following iter has that tag applied to it. Ifa tag is toggled off, then some non-empty range following iterdoes not have the tag applied to it.

  • Returns: tags toggled at this point.

get_child_anchor()

get_child_anchor (self) -> Gtk.TextChildAnchor

If the location at iter contains a child anchor, theanchor is returned (with no new reference count added). Otherwise,None is returned.

  • Returns: the anchor at iter.

begins_tag()

begins_tag (self, tag:Gtk.TextTag=None) -> bool

Returns True if tag is toggled on at exactly this point. If tagis None, returns True if any tag is toggled on at this point. Note that if Gtk.TextIter:begins_tag() returns True, it means that iter isat the beginning of the tagged range, and that thecharacter at iter is inside the tagged range. In otherwords, unlike Gtk.TextIter:ends_tag(), if Gtk.TextIter:begins_tag() returnsTrue, Gtk.TextIter:has_tag() will also return True for the sameparameters.

  • Returns: whether iteris the start of a range tagged with tag

ends_tag()

ends_tag (self, tag:Gtk.TextTag=None) -> bool

Returns True if tag is toggled off at exactly this point. If tagis None, returns True if any tag is toggled off at this point. Note that if Gtk.TextIter:ends_tag() returns True, it means that iter isat the end of the tagged range, but that the characterat iter is outside the tagged range. In other words,unlike Gtk.TextIter:begins_tag(), if Gtk.TextIter:ends_tag() returns True,Gtk.TextIter:has_tag() will return FALSE for the same parameters.

  • Returns: whether iteris the end of a range tagged with tag

toggles_tag()

toggles_tag (self, tag:Gtk.TextTag=None) -> bool

This is equivalent to (Gtk.TextIter:begins_tag() ||Gtk.TextIter:ends_tag()), i.e. it tells you whether a range withtag applied to it begins or ends at iter.

  • Returns: whether tagis toggled on or off at iter

has_tag()

has_tag (self, tag:Gtk.TextTag) -> bool

Returns True if iter points to a character that is part of a range taggedwith tag. See also Gtk.TextIter:begins_tag() and Gtk.TextIter:ends_tag().

  • Returns: whether iteris tagged with tag

get_tags()

get_tags (self) -> list

Returns a list of tags that apply to iter, in ascending order ofpriority (highest-priority tags are last). The Gtk.TextTag in thelist don’t have a reference added, but you have to free the listitself.

  • Returns: list of Gtk.TextTag.

editable()

editable (self, default_setting:bool) -> bool

Returns whether the character at iter is within an editable regionof text. Non-editable text is “locked” and can’t be changed by theuser via Gtk.TextView. This function is simply a conveniencewrapper around Gtk.TextIter:get_attributes(). If no tags appliedto this text affect editability, default_setting will be returned. You don’t want to use this function to decide whether text can beinserted at iter, because for insertion you don’t want to knowwhether the char at iter is inside an editable range, you want toknow whether a new character inserted at iter would be inside aneditable range. Use Gtk.TextIter:can_insert() to handle thiscase.

  • Returns: whether iteris inside an editable range

can_insert()

can_insert (self, default_editability:bool) -> bool

Considering the default editability of the buffer, and tags thataffect editability, determines whether text inserted at iter wouldbe editable. If text inserted at iter would be editable then theuser should be allowed to insert text at iter.`Gtk.TextBuffer:insert_interactive()` uses this function to decidewhether insertions are allowed at a given position.

  • Returns: whether text inserted at iterwould be editable

starts_word()

starts_word (self) -> bool

Determines whether iter begins a natural-language word. Wordbreaks are determined by Pango and should be correct for nearly anylanguage (if not, the correct fix would be to the Pango word breakalgorithms).

  • Returns: True if iteris at the start of a word

ends_word()

ends_word (self) -> bool

Determines whether iter ends a natural-language word. Word breaksare determined by Pango and should be correct for nearly anylanguage (if not, the correct fix would be to the Pango word breakalgorithms).

  • Returns: True if iteris at the end of a word

inside_word()

inside_word (self) -> bool

Determines whether the character pointed by iter is part of anatural-language word (as opposed to say inside some whitespace). Wordbreaks are determined by Pango and should be correct for nearly any language(if not, the correct fix would be to the Pango word break algorithms). Note that if Gtk.TextIter:starts_word() returns True, then this functionreturns True too, since iter points to the first character of the word.

  • Returns: True if iteris inside a word

starts_line()

starts_line (self) -> bool

Returns True if iter begins a paragraph,i.e. if Gtk.TextIter:get_line_offset() would return 0.However this function is potentially more efficient thanGtk.TextIter:get_line_offset() because it doesn’t have to computethe offset, it just has to see whether it’s 0.

  • Returns: whether iterbegins a line

ends_line()

ends_line (self) -> bool

Returns True if iter points to the start of the paragraphdelimiter characters for a line (delimiters will be either anewline, a carriage return, a carriage return followed by anewline, or a Unicode paragraph separator character). Note that aniterator pointing to the \n of a \r\n pair will not be counted asthe end of a line, the line ends before the \r. The end iterator isconsidered to be at the end of a line, even though there are noparagraph delimiter chars there.

  • Returns: whether iteris at the end of a line

starts_sentence()

starts_sentence (self) -> bool

Determines whether iter begins a sentence. Sentence boundaries aredetermined by Pango and should be correct for nearly any language(if not, the correct fix would be to the Pango text boundaryalgorithms).

  • Returns: True if iteris at the start of a sentence.

ends_sentence()

ends_sentence (self) -> bool

Determines whether iter ends a sentence. Sentence boundaries aredetermined by Pango and should be correct for nearly any language(if not, the correct fix would be to the Pango text boundaryalgorithms).

  • Returns: True if iteris at the end of a sentence.

inside_sentence()

inside_sentence (self) -> bool

Determines whether iter is inside a sentence (as opposed to inbetween two sentences, e.g. after a period and before the firstletter of the next sentence). Sentence boundaries are determinedby Pango and should be correct for nearly any language (if not, thecorrect fix would be to the Pango text boundary algorithms).

  • Returns: True if iteris inside a sentence.

is_cursor_position()

is_cursor_position (self) -> bool

See Gtk.TextIter:forward_cursor_position() or PangoLogAttr orpango_break() for details on what a cursor position is.

  • Returns: True if the cursor can be placed at iter

get_chars_in_line()

get_chars_in_line (self) -> int

Returns the number of characters in the line containing iter,including the paragraph delimiters.

  • Returns: number of characters in the line

get_bytes_in_line()

get_bytes_in_line (self) -> int

Returns the number of bytes in the line containing iter,including the paragraph delimiters.

  • Returns: number of bytes in the line

get_attributes()

get_attributes (self) -> bool, values:Gtk.TextAttributes

Computes the effect of any tags applied to this spot in thetext. The values parameter should be initialized to the defaultsettings you wish to use if no tags are in effect. You’d typicallyobtain the defaults from `Gtk.TextView:get_default_attributes(). Gtk.TextIter:get_attributes() will modifyvalues, applying theeffects of any tags present atiter. If any tags affectedvalues,the function returnsTrue`.

  • Returns: True if valueswas modified

get_language()

get_language (self) -> Pango.Language

A convenience wrapper around Gtk.TextIter:get_attributes(),which returns the language in effect at iter. If no tags affectinglanguage apply to iter, the return value is identical to that of`Gtk.get_default_language()`.

  • Returns: language in effect at iter.

is_end()

is_end (self) -> bool

Returns True if iter is the end iterator, i.e. one past the lastdereferenceable iterator in the buffer. Gtk.TextIter:is_end() isthe most efficient way to check whether an iterator is the enditerator.

  • Returns: whether iteris the end iterator

is_start()

is_start (self) -> bool

Returns True if iter is the first iterator in the buffer, that isif iter has a character offset of 0.

  • Returns: whether iteris the first in the buffer

forward_char()

forward_char (self) -> bool

Moves iter forward by one character offset. Note that imagesembedded in the buffer occupy 1 character slot, soGtk.TextIter:forward_char() may actually move onto an image insteadof a character, if you have images in your buffer. If iter is theend iterator or one character before it, iter will now point atthe end iterator, and Gtk.TextIter:forward_char() returns FALSE forconvenience when writing loops.

  • Returns: whether itermoved and is dereferenceable

backward_char()

backward_char (self) -> bool

Moves backward by one character offset. Returns True if movementwas possible; if iter was the first in the buffer (characteroffset 0), Gtk.TextIter:backward_char() returns FALSE for convenience whenwriting loops.

  • Returns: whether movement was possible

forward_chars()

forward_chars (self, count:int) -> bool

Moves count characters if possible (if count would move past thestart or end of the buffer, moves to the start or end of thebuffer). The return value indicates whether the new position ofiter 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 returns FALSE.

  • Returns: whether itermoved and is dereferenceable

backward_chars()

backward_chars (self, count:int) -> bool

Moves count characters backward, if possible (if count would movepast the start or end of the buffer, moves to the start or end ofthe buffer). The return value indicates whether the iterator movedonto a dereferenceable position; if the iterator didn’t move, ormoved onto the end iterator, then FALSE is returned. If count is 0,the function does nothing and returns FALSE.

  • Returns: whether itermoved and is dereferenceable

forward_line()

forward_line (self) -> bool

Moves iter to the start of the next line. If the iter is already on thelast 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 notdereferencable, returns FALSE. Otherwise, returns True.

  • Returns: whether itercan be dereferenced

backward_line()

backward_line (self) -> bool

Moves iter to the start of the previous line. Returns True ifiter could be moved; i.e. if iter was at character offset 0, thisfunction returns FALSE. Therefore if iter was already on line 0,but not at the start of the line, iter is snapped to the start ofthe line and the function returns True. (Note that this implies thatin a loop calling this function, the line number may not change onevery iteration, if your first iteration is on line 0.)

  • Returns: whether itermoved

forward_lines()

forward_lines (self, count:int) -> bool

Moves count lines forward, if possible (if count would movepast the start or end of the buffer, moves to the start or end ofthe buffer). The return value indicates whether the iterator movedonto a dereferenceable position; if the iterator didn’t move, ormoved 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.

  • Returns: whether itermoved and is dereferenceable

backward_lines()

backward_lines (self, count:int) -> bool

Moves count lines backward, if possible (if count would movepast the start or end of the buffer, moves to the start or end ofthe buffer). The return value indicates whether the iterator movedonto a dereferenceable position; if the iterator didn’t move, ormoved 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.

  • Returns: whether itermoved and is dereferenceable

forward_word_ends()

forward_word_ends (self, count:int) -> bool

Calls Gtk.TextIter:forward_word_end() up to count times.

  • Returns: True if itermoved and is not the end iterator

backward_word_starts()

backward_word_starts (self, count:int) -> bool

Calls Gtk.TextIter:backward_word_start() up to count times.

  • Returns: True if itermoved and is not the end iterator

forward_word_end()

forward_word_end (self) -> bool

Moves forward to the next word end. (If iter is currently on aword end, moves forward to the next one after that.) Word breaksare determined by Pango and should be correct for nearly anylanguage (if not, the correct fix would be to the Pango word breakalgorithms).

  • Returns: True if itermoved and is not the end iterator

backward_word_start()

backward_word_start (self) -> bool

Moves backward to the previous word start. (If iter is currently on aword start, moves backward to the next one after that.) Word breaksare determined by Pango and should be correct for nearly anylanguage (if not, the correct fix would be to the Pango word breakalgorithms).

  • Returns: True if itermoved and is not the end iterator

forward_cursor_position()

forward_cursor_position (self) -> bool

Moves iter forward by a single cursor position. Cursor positionsare (unsurprisingly) positions where the cursor can appear. Perhapssurprisingly, there may not be a cursor position between allcharacters. The most common example for European languages would bea carriage return/newline sequence. For some Unicode characters,the equivalent of say the letter “a” with an accent mark will berepresented as two characters, first the letter then a "combiningmark" that causes the accent to be rendered; so the cursor can’t gobetween those two characters. See also the PangoLogAttr andpango_break() function.

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

backward_cursor_position()

backward_cursor_position (self) -> bool

Like Gtk.TextIter:forward_cursor_position(), but moves backward.

  • Returns: True if we moved

forward_cursor_positions()

forward_cursor_positions (self, count:int) -> bool

Moves up to count cursor positions. SeeGtk.TextIter:forward_cursor_position() for details.

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

backward_cursor_positions()

backward_cursor_positions (self, count:int) -> bool

Moves up to count cursor positions. SeeGtk.TextIter:forward_cursor_position() for details.

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

backward_sentence_start()

backward_sentence_start (self) -> bool

Moves backward to the previous sentence start; if iter is already atthe start of a sentence, moves backward to the next one. Sentenceboundaries are determined by Pango and should be correct for nearlyany language (if not, the correct fix would be to the Pango textboundary algorithms).

  • Returns: True if itermoved and is not the end iterator

backward_sentence_starts()

backward_sentence_starts (self, count:int) -> bool

Calls Gtk.TextIter:backward_sentence_start() up to count times,or until it returns FALSE. If count is negative, moves forwardinstead of backward.

  • Returns: True if itermoved and is not the end iterator

forward_sentence_end()

forward_sentence_end (self) -> bool

Moves forward to the next sentence end. (If iter is at the end ofa sentence, moves to the next end of sentence.) Sentenceboundaries are determined by Pango and should be correct for nearlyany language (if not, the correct fix would be to the Pango textboundary algorithms).

  • Returns: True if itermoved and is not the end iterator

forward_sentence_ends()

forward_sentence_ends (self, count:int) -> bool

Calls Gtk.TextIter:forward_sentence_end() count times (or untilGtk.TextIter:forward_sentence_end() returns FALSE). If count isnegative, moves backward instead of forward.

  • Returns: True if itermoved and is not the end iterator

forward_visible_word_ends()

forward_visible_word_ends (self, count:int) -> bool

Calls Gtk.TextIter:forward_visible_word_end() up to count times.

  • Returns: True if itermoved and is not the end iterator

  • Since: 2.4


backward_visible_word_starts()

backward_visible_word_starts (self, count:int) -> bool

Calls Gtk.TextIter:backward_visible_word_start() up to count times.

  • Returns: True if itermoved and is not the end iterator

  • Since: 2.4


forward_visible_word_end()

forward_visible_word_end (self) -> bool

Moves forward to the next visible word end. (If iter is currently on aword end, moves forward to the next one after that.) Word breaksare determined by Pango and should be correct for nearly anylanguage (if not, the correct fix would be to the Pango word breakalgorithms).

  • Returns: True if itermoved and is not the end iterator

  • Since: 2.4


backward_visible_word_start()

backward_visible_word_start (self) -> bool

Moves backward to the previous visible word start. (If iter is currently on a word start, moves backward to the next one after that.) Word breaksare determined by Pango and should be correct for nearly anylanguage (if not, the correct fix would be to the Pango word breakalgorithms).

  • Returns: True if itermoved and is not the end iterator

  • Since: 2.4


forward_visible_cursor_position()

forward_visible_cursor_position (self) -> bool

Moves iter forward to the next visible cursor position. See Gtk.TextIter:forward_cursor_position() for details.

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

  • Since: 2.4


backward_visible_cursor_position()

backward_visible_cursor_position (self) -> bool

Moves iter forward to the previous visible cursor position. See Gtk.TextIter:backward_cursor_position() for details.

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

  • Since: 2.4


forward_visible_cursor_positions()

forward_visible_cursor_positions (self, count:int) -> bool

Moves up to count visible cursor positions. SeeGtk.TextIter:forward_cursor_position() for details.

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

  • Since: 2.4


backward_visible_cursor_positions()

backward_visible_cursor_positions (self, count:int) -> bool

Moves up to count visible cursor positions. SeeGtk.TextIter:backward_cursor_position() for details.

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

  • Since: 2.4


forward_visible_line()

forward_visible_line (self) -> bool

Moves iter to the start of the next visible line. Returns True if therewas a next line to move to, and FALSE if iter was simply moved tothe end of the buffer and is now not dereferenceable, or if iter wasalready at the end of the buffer.

  • Returns: whether itercan be dereferenced

  • Since: 2.8


backward_visible_line()

backward_visible_line (self) -> bool

Moves iter to the start of the previous visible line. Returns True ifiter could be moved; i.e. if iter was at character offset 0, thisfunction returns FALSE. Therefore if iter was already on line 0,but not at the start of the line, iter is snapped to the start ofthe line and the function returns True. (Note that this implies thatin a loop calling this function, the line number may not change onevery iteration, if your first iteration is on line 0.)

  • Returns: whether itermoved

  • Since: 2.8


forward_visible_lines()

forward_visible_lines (self, count:int) -> bool

Moves count visible lines forward, if possible (if count would movepast the start or end of the buffer, moves to the start or end ofthe buffer). The return value indicates whether the iterator movedonto a dereferenceable position; if the iterator didn’t move, ormoved 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.

  • Returns: whether itermoved and is dereferenceable

  • Since: 2.8


backward_visible_lines()

backward_visible_lines (self, count:int) -> bool

Moves count visible lines backward, if possible (if count would movepast the start or end of the buffer, moves to the start or end ofthe buffer). The return value indicates whether the iterator movedonto a dereferenceable position; if the iterator didn’t move, ormoved 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.

  • Returns: whether itermoved and is dereferenceable

  • Since: 2.8


set_offset()

set_offset (self, char_offset:int)

Sets iter to point to char_offset. char_offset counts from the startof the entire text buffer, starting with 0.


set_line()

set_line (self, line_number:int)

Moves iterator iter to the start of the line line_number. Ifline_number is negative or larger than the number of lines in thebuffer, moves iter to the start of the last line in the buffer.


set_line_offset()

set_line_offset (self, char_on_line:int)

Moves iter within a line, to a new character(not byte) offset. The given character offset must be less than orequal to the number of characters in the line; if equal, itermoves to the start of the next line. SeeGtk.TextIter:set_line_index() if you have a byte index rather thana character offset.


set_line_index()

set_line_index (self, byte_on_line:int)

Same as Gtk.TextIter:set_line_offset(), but works with abyte index. The given byte index must be atthe start of a character, it can’t be in the middle of a UTF-8encoded character.


set_visible_line_index()

set_visible_line_index (self, byte_on_line:int)

Like Gtk.TextIter:set_line_index(), but the index is in visiblebytes, i.e. text with a tag making it invisible is not countedin the index.


set_visible_line_offset()

set_visible_line_offset (self, char_on_line:int)

Like Gtk.TextIter:set_line_offset(), but the offset is in visiblecharacters, i.e. text with a tag making it invisible is notcounted in the offset.


forward_to_end()

forward_to_end (self)

Moves iter forward to the “end iterator,” which points one past the lastvalid character in the buffer. Gtk.TextIter:get_char() called on theend iterator returns 0, which is convenient for writing loops.


forward_to_line_end()

forward_to_line_end (self) -> bool

Moves the iterator to point to the paragraph delimiter characters,which will be either a newline, a carriage return, a carriagereturn/newline in sequence, or the Unicode paragraph separatorcharacter. If the iterator is already at the paragraph delimitercharacters, moves to the paragraph delimiter characters for thenext line. If iter is on the last line in the buffer, which doesnot end in paragraph delimiters, moves to the end iterator (end ofthe last line), and returns FALSE.

  • Returns: True if we moved and the new location is not the end iterator

forward_to_tag_toggle()

forward_to_tag_toggle (self, tag:Gtk.TextTag=None) -> bool

Moves forward to the next toggle (on or off) of theGtk.TextTag tag, or to the next toggle of any tag iftag is None. If no matching tag toggles are found,returns FALSE, otherwise True. Does not return toggleslocated at iter, only toggles after iter. Sets iter tothe location of the toggle, or to the end of the bufferif no toggle is found.

  • Returns: whether we found a tag toggle after iter

backward_to_tag_toggle()

backward_to_tag_toggle (self, tag:Gtk.TextTag=None) -> bool

Moves backward to the next toggle (on or off) of theGtk.TextTag tag, or to the next toggle of any tag iftag is None. If no matching tag toggles are found,returns FALSE, otherwise True. Does not return toggleslocated at iter, only toggles before iter. Sets iterto the location of the toggle, or the start of the bufferif no toggle is found.

  • Returns: whether we found a tag toggle before iter

forward_find_char()

forward_find_char (self, pred:Gtk.TextCharPredicate, user_data=None, limit:Gtk.TextIter=None) -> bool

Advances iter, calling pred on each character. Ifpred returns True, returns True and stops scanning.If pred never returns True, iter is set to limit iflimit is non-None, otherwise to the end iterator.

  • Returns: whether a match was found

backward_find_char()

backward_find_char (self, pred:Gtk.TextCharPredicate, user_data=None, limit:Gtk.TextIter=None) -> bool

Same as Gtk.TextIter:forward_find_char(), but goes backward from iter.

  • Returns: whether a match was found

equal()

equal (self, rhs:Gtk.TextIter) -> bool

Tests whether two iterators are equal, using the fastest possiblemechanism. This function is very fast; you can expect it to performbetter than e.g. getting the character offset for each iterator andcomparing the offsets yourself. Also, it’s a bit faster thanGtk.TextIter:compare().

  • Returns: True if the iterators point to the same place in the buffer

compare()

compare (self, rhs:Gtk.TextIter) -> int

A qsort()-style function that returns negative if lhs is less thanrhs, positive if lhs is greater than rhs, and 0 if they’re equal.Ordering is in character offset order, i.e. the first character in the bufferis less than the second character in the buffer.

  • Returns: -1 if lhsis less than rhs, 1 if lhsis greater, 0 if they are equal

in_range()

in_range (self, start:Gtk.TextIter, end:Gtk.TextIter) -> bool

Checks whether iter falls in the range [start, end).start and end must be in ascending order.

  • Returns: True if iteris in the range

order()

order (self, second:Gtk.TextIter)

Swaps the value of first and second if second comes beforefirst in the buffer. That is, ensures that first and second arein sequence. Most text buffer functions that take a range call thisautomatically on your behalf, so there’s no real reason to call it yourselfin those cases. There are some exceptions, such as Gtk.TextIter:in_range(),that expect a pre-sorted range.


results matching ""

    No results matching ""