Package: gtk

Function gtk-text-iter-move

Lambda List

gtk-text-iter-move (iter &key count by direction)

Arguments

iter -- a gtk-text-iter instance
count -- an integer with the default value 1
by -- a keyword which determines the operation to perform, the default value is :char
direction -- a keyword for the direction, the default value is :forward

Details

This is a convenience function of the Lisp implementation, which replaces the functions to move the iterator in the text buffer.

The following operations are performed depending on the argument by:
:char
Moves count characters if possible in the given direction, which is :forward or :backward. If count would move past the start or end of the text buffer, moves to the start or end of the text buffer.

The return value indicates whether the new position of the iterator is different from its original position, and dereferenceable, the last iterator in the text buffer is not dereferenceable. If count is 0, the function does nothing and returns false.

This replaces the functions:
:line
Moves the iterator to the start of the next line for the :forward direction or to the start of the previous line for the :backward direction.

If the the iterator is already on the last line of the text buffer for a :forward direction, moves the iterator to the end of the current line. If after the operation, the iterator is at the end of the text buffer and not dereferencable, returns false. Otherwise, returns true.

For the :backward direction returns true if the iterator could be moved, i.e. if the iterator was at character offset 0, this function returns false. Therefore if the iterator was already on line 0, but not at the start of the line, the iterator 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.

This replaces the functions:
:word
Moves forward up to count times for the :forward direction to the next word end. If the iterator is currently on a word end, moves forward to the next one after that.

Moves backward up to count times for the :backward direction to the previous word start. If the iterator 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, if not, the correct fix would be to the Pango word break algorithms.

Returns true if the iterator moved and is not the end iterator.

This replaces the functions:
:cursor-position
Moves the iterator up to count cursor positions forward or backward.

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 cannot go between those two characters. See also the pango-log-attr structure and the pango-default-break function.

Returns true if we moved and the new position is dereferenceable.

This replaces the functions:
:sentence
Moves backward to the previous sentence start or forward to the next sentence end. If the iterator is already at the start of a sentence, moves backward to the next one. If the iterator 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, if not, the correct fix would be to the Pango text boundary algorithms.

This replaces the functions:
:visible-word
Moves forward to the next visible word end or backward to the previous visible word start.

If the iterator 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. If not, the correct fix would be to the Pango word break algorithms.

This replaces the functions:
:visible-line
Moves the iterator to the start of the next visible line or to the start of the previous visible line.

The return value indicates whether the iterator moved onto a dereferenceable position. If the iterator did not move, or moved onto the end iterator, then false is returned. If count is 0, the function does nothing and returns false.

This replaces the functions:
:visible-cursor-position
Moves the iterator forward to the next visible cursor position or forward to the previous visible cursor position.

Returns true if we moved and the new position is dereferenceable.

This replaces the functions:
 

See also

*2021-12-17