Xfce Foundation Classes
Main Page  | IndexNamespace List  |  Alphabetical List  |  Class List  |  File List


Xfc::Gtk::TextIter Class Reference

A GtkTextIter C++ wrapper class. More...

#include <xfc/gtk/textiter.hh>

Inheritance diagram for Xfc::Gtk::TextIter:

Xfc::G::Boxed Xfc::StackObject Xfc::Object Xfc::Trackable List of all members.

Public Types

Public Member Functions

Constructors
Accessors
Methods

Static Public Member Functions

Accessors
Methods

Detailed Description

A GtkTextIter C++ wrapper class.

Most text manipulation in a TextBuffer is accomplished with iterators, represented by a TextIter. An iterator represents a position between two characters in a text buffer. TextIter is a class designed to be allocated on the stack; it's guaranteed to be copiable by value and never contain any heap-allocated data. Iterators are not valid indefinitely; whenever the buffer is modified in a way that affects the number of characters in the buffer, all outstanding iterators become invalid. (Note that deleting 5 characters and then reinserting 5 still invalidates iterators, though you end up with the same number of characters you pass through a state with a different number). Because of this, iterators can't be used to preserve positions across buffer modifications. To preserve a position you would use the TextMark object. TextIter is a StackObject and can only be created on the stack.

See also: the TextView Widget HOWTO and example.


Member Typedef Documentation

typedef sigc::slot<bool, G::Unichar> Xfc::Gtk::TextIter::TextCharPredicate
 

Signature of the callback slot to be called on each character when searching a text buffer for characters with forward_find_char() and backward_find_char().

Example: Method signature for TextCharPredicate.

             bool method(G::UniChar ch);
            
             // ch: The Unicode character.


Constructor & Destructor Documentation

Xfc::Gtk::TextIter::TextIter GtkTextIter *  iter  )  [explicit]
 

Construct a new text iterator from an existing GtkTextIter.

Parameters:
iter A pointer to a GtkTextIter.
The iter can be a newly created GtkTextIter or an existing GtkTextIter. The TextIter object created is a temporary object. It doesn't take over the ownership of GtkTextIter and GtkTextIter is not freed by the destructor.

Xfc::Gtk::TextIter::TextIter GtkTextIter *  iter,
bool  copy
 

Construct a new text iterator from an existing GtkTextIter.

Parameters:
iter A pointer to a GtkTextIter.
copy Whether the TextIter object should make a copy of GtkTextIter or not.
The iter can be a newly created GtkTextIter or an existing GtkTextIter. If copy is true TextIter will make a copy of GtkTextIter. If copy is false TextIter wont make a copy but instead takes over the ownership of GtkTextIter. Either way, the destructor will free GtkTextIter when the TextIter object is destroyed. This constructor is used by G::Boxed::wrap() to wrap GtkTextIter objects in a C++ wrapper.

Xfc::Gtk::TextIter::TextIter const TextIter src  ) 
 

Copy constructor.

Parameters:
src The source iterator.


Member Function Documentation

bool Xfc::Gtk::TextIter::backward_char  ) 
 

Moves backward by one character offset.

Returns:
true if movement was possible.
If the iterator was the first in the buffer (character offset 0), backward_char() returns false for convenience when writing loops.

bool Xfc::Gtk::TextIter::backward_chars 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).

Parameters:
count The number of characters to move, may be negative.
Returns:
Whether the iterator moved and is dereferenceable.
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.

bool Xfc::Gtk::TextIter::backward_cursor_position  ) 
 

Like forward_cursor_position(), but moves backward.

Returns:
true if we moved.

bool Xfc::Gtk::TextIter::backward_cursor_positions int  count  ) 
 

Moves up to count cursor positions backwards (see forward_cursor_position() for details).

Parameters:
count The number of positions to move.
Returns:
true if we moved and the new position is dereferenceable.

bool Xfc::Gtk::TextIter::backward_find_char const TextCharPredicate predicate,
const TextIter limit = 0
 

Same as forward_find_char(), but goes backward from the iterator.

Parameters:
predicate A callback slot to be called on each character.
limit The search limit, or null for none.
Returns:
Whether a match was found.

bool Xfc::Gtk::TextIter::backward_line  ) 
 

Moves the iterator to the start of the previous line.

Returns:
Whether the iterator moved.
Returns true if the iterator could be moved; that is, if the iterator was at character offset 0, this method 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 method returns true. (Note that this implies that in a loop calling this method, the line number may not change on every iteration, if your first iteration is on line 0.)

bool Xfc::Gtk::TextIter::backward_lines 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).

Parameters:
count The number of lines to move backward.
Returns:
Whether iter moved and is dereferenceable.
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 method does nothing and returns false. If count is negative, moves forward by 0 - count lines.

bool Xfc::Gtk::TextIter::backward_search const String str,
TextSearchFlagsField  flags,
TextIter match_start,
TextIter match_end,
const TextIter limit = 0
 

Same as forward_search(), but moves backward.

Parameters:
str The search string.
flags The bitmask of Gtk::TextSearchFlags affecting the search.
match_start The return location for start of match, or null.
match_end The return location for end of match, or null.
limit The location of last possible match_start, or null for start of buffer.
Returns:
Whether a match was found.

bool Xfc::Gtk::TextIter::backward_search const String str,
TextIter match_start,
TextIter match_end,
const TextIter limit = 0
 

Same as forward_search(), but moves backward.

Parameters:
str The search string.
match_start The return location for start of match, or null.
match_end The return location for end of match, or null.
limit The location of last possible match_start, or null for start of buffer.
Returns:
Whether a match was found.
The TEXT_SEARCH_VISIBLE_ONLY flag is used so the match may have invisible text interspersed in str (i.e. str will be a possibly-noncontiguous subsequence of the matched range).

bool Xfc::Gtk::TextIter::backward_search const String str,
const TextIter limit = 0
 

Same as forward_search(), but moves backward.

Parameters:
str The search string.
limit The location of last possible match_start, or null for start of buffer.
Returns:
Whether a match was found.
The TEXT_SEARCH_VISIBLE_ONLY flag is used so the match may have invisible text interspersed in str (i.e. str will be a possibly-noncontiguous subsequence of the matched range).

bool Xfc::Gtk::TextIter::backward_sentence_start  ) 
 

Moves backward to the previous sentence start.

Returns:
true if the iterator moved and is not the end iterator.
If the iterator 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 (if not, the correct fix would be to the Pango text boundary algorithms).

bool Xfc::Gtk::TextIter::backward_sentence_starts int  count  ) 
 

Calls backward_sentence_start() up to count times, or until it returns false.

Parameters:
count The number of sentences to move.
Returns:
true if the iterator moved and is not the end iterator.
If count is negative, the iterator moves forward instead of backward.

bool Xfc::Gtk::TextIter::backward_to_tag_toggle const TextTag tag = 0  ) 
 

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

Parameters:
tag A TextTag, or null.
Returns:
Whether we found a tag toggle before the iterator.
If no matching tag toggles are found, returns false, otherwise true. Does not return toggles located at the iterator, only toggles before the iterator. Sets the iterator to the location of the toggle, or the start of the buffer if no toggle is found.

bool Xfc::Gtk::TextIter::backward_visible_cursor_position  ) 
 

Moves the iterator backward to the previous visible cursor position (see backward_cursor_position() for details).

Returns:
true if the iterator moved and the new position is dereferenceable.

bool Xfc::Gtk::TextIter::backward_visible_cursor_positions int  count  ) 
 

Moves the iterator up to count visible cursor positions (see forward_cursor_position() for details).

Parameters:
count The number of positions to move.
Returns:
true if the iterator moved and the new position is dereferenceable.

bool Xfc::Gtk::TextIter::backward_visible_word_start  ) 
 

Moves backward to the previous visible word start.

Returns:
true if the iterator moved and is not the end iterator.
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).

bool Xfc::Gtk::TextIter::backward_visible_word_starts int  count  ) 
 

Calls backward_visible_word_start() up to count times.

Parameters:
count The number of times to move.
Returns:
true if the iterator moved and is not the end iterator.

bool Xfc::Gtk::TextIter::backward_word_start  ) 
 

Moves backward to the previous word start.

Returns:
true if the iterator moved and is not the end iterator.
If iter 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).

bool Xfc::Gtk::TextIter::backward_word_starts int  count  ) 
 

Calls backward_word_start() up to count times.

Parameters:
count The number of times to move.
Returns:
true if the iterator moved and is not the end iterator.

bool Xfc::Gtk::TextIter::begins_tag const TextTag tag = 0  )  const
 

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

Parameters:
tag A TextTag, or null.
Returns:
Whether this iterator is the start of a range tagged with tag.
If tag is null, returns true if any tag is toggled on at this point. Note that the begins_tag() returns true if the iterator is the start of the tagged range; has_tag() tells you whether the iterator is within a tagged range.

bool Xfc::Gtk::TextIter::can_insert bool  default_editability  )  const
 

Considering the default editability of the buffer, and tags that affect editability, determines whether text inserted at this iterator would be editable.

Parameters:
default_editability true if text is editable by default.
Returns:
Whether text inserted at the iterator would be editable.
If text inserted at the iterator would be editable then the user should be allowed to insert text at the iterator. Gtk::TextBuffer::insert_interactive() uses this method to decide whether insertions are allowed at a given position.

int Xfc::Gtk::TextIter::compare const TextIter other  )  const
 

A qsort()-style method that returns negative if this iterator is less than other, positive if it's greater than other, and 0 it's equal to other.

Parameters:
other Another TextIter.
Returns:
-1 if this iterator is less than other, 1 if it's greater, 0 if they are equal.
Ordering is in character offset order, that is, the first character in the buffer is less than the second character in the buffer.

bool Xfc::Gtk::TextIter::editable bool  default_setting  )  const
 

Returns whether the character at the iterator is within an editable region of text.

Parameters:
default_setting true if text is editable by default.
Returns:
Whether the iterator is inside an editable range.
Non-editable text is "locked" and can't be changed by the user via TextView. This method is simply a convenience wrapper around get_attributes(). If no tags applied to this text affect editability, default_setting will be returned.

You don't want to use this method to decide whether text can be inserted at the iterator, because for insertion you don't want to know whether the char at the iterator is inside an editable range, you want to know whether a new character inserted at the iterator would be inside an editable range. Use can_insert() to handle this case.

bool Xfc::Gtk::TextIter::ends_line  )  const
 

Returns true if the iterator points to the start of the paragraph delimiter characters for a line.

Returns:
Whether the iterator is at the end of 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.

bool Xfc::Gtk::TextIter::ends_sentence  )  const
 

Determines whether the iterator ends a sentence.

Returns:
true if the iterator is at the end of a 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).

bool Xfc::Gtk::TextIter::ends_tag const TextTag tag = 0  )  const
 

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

Parameters:
tag A TextTag, or null.
Returns:
Whether this iterator is the end of a range tagged with tag.
If tag is null, returns true if any tag is toggled off at this point. Note that the ends_tag() returns true if iter is the end of the tagged range; has_tag() tells you whether an iterator is within a tagged range.

bool Xfc::Gtk::TextIter::ends_word  )  const
 

Determines whether the iterator ends a natural-language word.

Returns:
true if the iterator is at the end of a word.
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).

bool Xfc::Gtk::TextIter::equal const TextIter other  )  const
 

Tests whether two iterators are equal, using the fastest possible mechanism.

Parameters:
other Another TextIter.
Returns:
true if the iterators point to the same place in the buffer.
This method is very fast; you can expect it to perform better than for example, getting the character offset for each iterator and comparing the offsets yourself. Also, it's a bit faster than compare().

bool Xfc::Gtk::TextIter::forward_char  ) 
 

Moves the iterator forward by one character offset.

Returns:
Whether the iterator moved and is dereferenceable.
Note that images embedded in the buffer occupy 1 character slot, so forward_char() may actually move onto an image instead of a character, if you have images in your buffer. If the iterator is the end iterator or one character before it, the iterator will now point at the end iterator, and forward_char() returns false for convenience when writing loops.

bool Xfc::Gtk::TextIter::forward_chars 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).

Parameters:
count The number of characters to move, may be negative.
Returns:
Whether the iterator moved and is dereferenceable.
The return value indicates whether the new position of the iterator 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.

bool Xfc::Gtk::TextIter::forward_cursor_position  ) 
 

Moves the iterator forward by a single cursor position.

Returns:
true if we moved and the new position is dereferenceable.
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 PangoLogAttr structure and pango_break() function.

bool Xfc::Gtk::TextIter::forward_cursor_positions int  count  ) 
 

Moves up to count cursor positions (see forward_cursor_position() for details).

Parameters:
count The number of positions to move.
Returns:
true if we moved and the new position is dereferenceable.

bool Xfc::Gtk::TextIter::forward_find_char const TextCharPredicate predicate,
const TextIter limit = 0
 

Advances the iterator, calling predicate on each character.

Parameters:
predicate A callback slot to be called on each character.
limit The search limit, or null for none.
Returns:
Whether a match was found.
If predicate returns true, returns true and stops scanning. If predicate never returns true, the iterator is set to limit if limit is non-null, otherwise to the end iterator.

bool Xfc::Gtk::TextIter::forward_line  ) 
 

Moves the iterator to the start of the next line.

Returns:
Whether the iterator can be dereferenced.
Returns true if there was a next line to move to, and false if the iterator was simply moved to the end of the buffer and is now not dereferenceable, or if the iterator was already at the end of the buffer.

bool Xfc::Gtk::TextIter::forward_lines 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).

Parameters:
count The number of lines to move forward.
Returns:
Whether the iterator moved and is dereferenceable.
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 method does nothing and returns false. If count is negative, the iterator moves backward by 0 - count lines.

bool Xfc::Gtk::TextIter::forward_search const String str,
TextSearchFlagsField  flags,
TextIter match_start,
TextIter match_end,
const TextIter limit = 0
 

Searches forward for str.

Parameters:
str A search string.
flags The Gtk::TextSearchFlags affecting how the search is done.
match_start The return location for start of match, or null.
match_end The return location for end of match, or null.
limit The bound for the search, or null for the end of the buffer.
Returns:
Whether a match was found
Any match is returned by setting match_start to the first character of the match and match_end 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. If the TEXT_SEARCH_VISIBLE_ONLY flag is present, the match may have invisible text interspersed in str (i.e. str will be a possibly-noncontiguous subsequence of the matched range). Similarly, if you specify TEXT_SEARCH_TEXT_ONLY, the match may have pixbufs or child widgets mixed inside the matched range. If these flags are not given, the match must be exact; the special 0xFFFC character in str will match embedded pixbufs or child widgets.

bool Xfc::Gtk::TextIter::forward_search const String str,
TextIter match_start,
TextIter match_end,
const TextIter limit = 0
 

Searches forward for str.

Parameters:
str A search string.
match_start The return location for start of match, or null.
match_end The return location for end of match, or null.
limit The bound for the search, or null for the end of the buffer.
Returns:
Whether a match was found
Any match is returned by setting match_start to the first character of the match and match_end 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. The TEXT_SEARCH_VISIBLE_ONLY flag is used so the match may have invisible text interspersed in str (i.e. str will be a possibly-noncontiguous subsequence of the matched range).

bool Xfc::Gtk::TextIter::forward_search const String str,
const TextIter limit = 0
 

Searches forward for str.

Parameters:
str A search string.
limit The bound for the search, or null for the end of the buffer.
Returns:
Whether a match was found
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. The TEXT_SEARCH_VISIBLE_ONLY flag is used so the match may have invisible text interspersed in str (i.e. str will be a possibly-noncontiguous subsequence of the matched range).

bool Xfc::Gtk::TextIter::forward_sentence_end  ) 
 

Moves forward to the next sentence end.

Returns:
true if the iterator moved and is not the end iterator.
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).

bool Xfc::Gtk::TextIter::forward_sentence_ends int  count  ) 
 

Calls forward_sentence_end() count times (or until forward_sentence_end() returns false).

Parameters:
count The number of sentences to move.
Returns:
true if the iterator moved and is not the end iterator.
If count is negative, the iterator moves backward instead of forward.

void Xfc::Gtk::TextIter::forward_to_end  ) 
 

Moves the iterator forward to the "end iterator", which points one past the last valid character in the buffer.

Note get_char() called on the end iterator returns 0, which is convenient for writing loops.

bool Xfc::Gtk::TextIter::forward_to_line_end  ) 
 

Moves the iterator to point to the paragraph delimiter characters, which will be either a newline, a carriage return, a carriage return/newline in sequence, or the Unicode paragraph separator character.

Returns:
true if we moved and the new location is not the end iterator.
If the iterator is already at the paragraph delimiter characters, it moves to the paragraph delimiter characters for the next line. If the iterator is on the last line in the buffer, which does not end in paragraph delimiters, it moves to the end iterator (end of the last line), and returns false.

bool Xfc::Gtk::TextIter::forward_to_tag_toggle const TextTag tag = 0  ) 
 

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

Parameters:
tag A TextTag, or null.
Returns:
Whether we found a tag toggle after the iterator.
If no matching tag toggles are found, returns false, otherwise true. Does not return toggles located at the iterator, only toggles after the iterator. Sets the iterator to the location of the toggle, or to the end of the buffer if no toggle is found.

bool Xfc::Gtk::TextIter::forward_visible_cursor_position  ) 
 

Moves the iterator forward to the next visible cursor position (see forward_cursor_position() for details).

Returns:
true if the iterator moved and the new position is dereferenceable.

bool Xfc::Gtk::TextIter::forward_visible_cursor_positions int  count  ) 
 

Moves the iterator up to count visible cursor positions (see forward_cursor_position() for details).

Parameters:
count The number of positions to move.
Returns:
true if the iterator moved and the new position is dereferenceable.

bool Xfc::Gtk::TextIter::forward_visible_word_end  ) 
 

Moves forward to the next visible word end.

Returns:
true if the iterator moved and is not the end iterator.
If the iterator 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 (if not, the correct fix would be to the Pango word break algorithms).

bool Xfc::Gtk::TextIter::forward_visible_word_ends int  count  ) 
 

Calls forward_visible_word_end() up to count times.

Parameters:
count The number of times to move.
Returns:
true if the iterator moved and is not the end iterator.

bool Xfc::Gtk::TextIter::forward_word_end  ) 
 

Moves forward to the next word end.

Returns:
true if the iterator moved and is not the end iterator.
If the iterator is currently on a word end, it moves forward 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).

bool Xfc::Gtk::TextIter::forward_word_ends int  count  ) 
 

Calls forward_word_end() up to count times.

Parameters:
count The number of times to move.
Returns:
true if the iterator moved and is not the end iterator.

bool Xfc::Gtk::TextIter::get_attributes TextAttributes values  )  const
 

Computes the effect of any tags applied to this spot in the text.

Parameters:
values A TextAttributes to be filled in.
Returns:
true if values was modified.
The values parameter should be initialized to the default settings you wish to use if no tags are in effect. You'd typically obtain the defaults from Gtk::TextView::get_default_attributes().

get_attributes() will modify values, applying the effects of any tags present at the iterator. If any tags affected values, the function returns true.

G::Unichar Xfc::Gtk::TextIter::get_char  )  const
 

Returns the Unicode character at this iterator.

Returns:
A Unicode character, or 0 if the iterator is not dereferenceable.
Equivalent to using the dereference operator on the 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 get_char() returns 0.

PangoLanguage* Xfc::Gtk::TextIter::get_language  )  const
 

A convenience wrapper around get_attributes(), which returns the language in effect at this iterator.

Returns:
The language in effect at the iterator.
If no tags affecting language apply to the iterator, the return value is identical to that of gtk_get_default_language().

int Xfc::Gtk::TextIter::get_line  )  const
 

Returns the line number containing the iterator.

Lines in a TextBuffer are numbered beginning with 0 for the first line in the buffer.

int Xfc::Gtk::TextIter::get_line_index  )  const
 

Returns the byte index of the iterator, counting from the start of a newline-terminated line.

Returns:
The distance from start of line, in bytes.
Remember that TextBuffer encodes text in UTF-8, and that characters can require a variable number of bytes to represent them.

int Xfc::Gtk::TextIter::get_line_offset  )  const
 

Returns the character offset of the iterator, counting from the start of a newline-terminated line.

Returns:
The offset from start of line.
The first character on the line has offset 0.

bool Xfc::Gtk::TextIter::get_marks std::vector< TextMark * > &  marks  )  const
 

Retrieves a list of all TextMark at this location.

Parameters:
marks A reference to a vector of TextMark* to hold the marks.
Returns:
true if any marks were retrieved.
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 marks retrieved are not in any meaningful order.

int Xfc::Gtk::TextIter::get_offset  )  const
 

Returns the character offset of an iterator.

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

String Xfc::Gtk::TextIter::get_slice const TextIter start,
const TextIter end
[static]
 

Returns the text in the given range.

Parameters:
start The iterator at start of a range.
end The iterator at end of a range.
Returns:
A slice of text from the buffer.
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 String 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 pixbuf or widget is in the buffer.

bool Xfc::Gtk::TextIter::get_tags std::vector< TextTag * > &  tags  )  const
 

Retrieves a list of tags that apply to this iterator, in ascending order of priority (highest-priority tags are last).

Parameters:
tags A reference to a vector of TextTag* to hold the tags.
Returns:
true if any tags were retrieved.
The TextTag in the vector don't have a reference added.

String Xfc::Gtk::TextIter::get_text const TextIter start,
const TextIter end
[static]
 

Returns the text in the given range.

Parameters:
start The iterator at start of a range.
end The iterator at end of a range.
Returns:
A String containing the characters from the buffer.
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, get_slice().

bool Xfc::Gtk::TextIter::get_toggled_tags std::vector< TextTag * > &  tags,
bool  toggled_on
const
 

Retrieves a list of TextTag that are toggled on or off at this point.

Parameters:
tags A reference to a vector of TextTag* to hold the tags.
toggled_on true to get toggled-on tags.
Returns:
true if any tags are retrieved.
If toggled_on is true, the list contains tags that are toggled on. If a tag is toggled on at this iterator, then some non-empty range of characters following the iterator has that tag applied to it. If a tag is toggled off, then some non-empty range following the iterator does not have the tag applied to it.

int Xfc::Gtk::TextIter::get_visible_line_index  )  const
 

Returns the number of bytes from the start of the line to the iterator, not counting bytes that are invisible due to tags with the "invisible" flag toggled on.

Returns:
The byte index of iterator with respect to the start of the line.

int Xfc::Gtk::TextIter::get_visible_line_offset  )  const
 

Returns the offset in characters from the start of the line to the iterator, not counting characters that are invisible due to tags with the "invisible" flag toggled on.

Returns:
The offset in visible characters from the start of the line.

String Xfc::Gtk::TextIter::get_visible_slice const TextIter start,
const TextIter end
[static]
 

Like get_slice(), but invisible text is not included.

Parameters:
start The iterator at start of a range.
end The iterator at end of a range.
Returns:
A slice of text from the buffer.
Invisible text is usually invisible because a TextTag with the "invisible" attribute turned on has been applied to it.

String Xfc::Gtk::TextIter::get_visible_text const TextIter start,
const TextIter end
[static]
 

Like get_text(), but invisible text is not included.

Parameters:
start The iterator at start of a range.
end The iterator at end of a range.
Returns:
A String containing visible text in the range.
Invisible text is usually invisible because a TextTag with the "invisible" attribute turned on has been applied to it.

bool Xfc::Gtk::TextIter::has_tag const TextTag tag  )  const
 

Returns true if the iterator is within a range tagged with tag.

Parameters:
tag A TextTag.
Returns:
Whether this iterator is tagged with tag.

bool Xfc::Gtk::TextIter::in_range const TextIter start,
const TextIter end
 

Checks whether this iterator falls in the range (start, end); start and end must be in ascending order.

Parameters:
start The start of range.
end The end of range.
Returns:
true if this iterator is in the range.

bool Xfc::Gtk::TextIter::inside_sentence  )  const
 

Determines whether the iterator is inside a sentence (as opposed to in between two sentences, for example, after a period and before the first letter of the next sentence).

Returns:
true if the iterator is inside a 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).

bool Xfc::Gtk::TextIter::inside_word  )  const
 

Determines whether the iterator is inside a natural-language word (as opposed to say inside some whitespace).

Returns:
true if the iterator is inside a word.
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).

bool Xfc::Gtk::TextIter::is_cursor_position  )  const
 

Returns true if the cursor can be placed at this iterator.

See forward_cursor_position() or PangoLogAttr or pango_break() for details on what a cursor position is.

bool Xfc::Gtk::TextIter::is_end  )  const
 

Returns true if this iterator is the end iterator, that is, one past the last dereferenceable iterator in the buffer.

Returns:
Whether the iterator is the end iterator.
is_end() is the most efficient way to check whether an iterator is the end iterator.

bool Xfc::Gtk::TextIter::is_start  )  const
 

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

Returns:
Whether the iterator is the first in the buffer.

G::Unichar Xfc::Gtk::TextIter::operator *  )  const
 

The dereference operator returns the Unicode character at this iterator.

Returns:
A Unicode character, or 0 if iter is not dereferenceable.
Equivalent to calling get_char() on the 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 get_char() returns 0.

bool Xfc::Gtk::TextIter::operator!= const TextIter other  )  const
 

Returns true if this iterator is not equal to other.

Parameters:
other Another TextIter.

TextIter Xfc::Gtk::TextIter::operator+ int  chars  )  const
 

Returns a TextIter to the position chars characters from this iterator in a forward direction.

Parameters:
chars The number of characters from this iterator.
Returns:
A TextIter to the new position.

TextIter& Xfc::Gtk::TextIter::operator+= int  chars  ) 
 

Calls forward_chars() to move this iterator forward chars characters.

Parameters:
chars The number of characters to move this iterator.
Returns:
A reference to the iterator.

TextIter Xfc::Gtk::TextIter::operator- int  chars  )  const
 

Returns a TextIter to the position chars characters from this iterator in a backward direction.

Parameters:
chars The number of characters from this iterator.
Returns:
A TextIter to the new position.

TextIter& Xfc::Gtk::TextIter::operator-= int  chars  ) 
 

Calls backward_chars() to move this iterator backward chars characters.

Parameters:
chars The number of characters to move this iterator.
Returns:
A reference to the iterator.

bool Xfc::Gtk::TextIter::operator< const TextIter other  )  const
 

Returns true if this iterator is less than other.

Parameters:
other Another TextIter.

bool Xfc::Gtk::TextIter::operator<= const TextIter other  )  const
 

Returns true if this iterator is less than or equal to other.

Parameters:
other Another TextIter.

TextIter& Xfc::Gtk::TextIter::operator= const TextIter src  ) 
 

Assignment operator.

Parameters:
src The source iterator.

bool Xfc::Gtk::TextIter::operator== const TextIter other  )  const
 

Returns true if this iterator is equal to other.

Parameters:
other Another TextIter.

bool Xfc::Gtk::TextIter::operator> const TextIter other  )  const
 

Returns true if this iterator is greater than other.

Parameters:
other Another TextIter.

bool Xfc::Gtk::TextIter::operator>= const TextIter other  )  const
 

Returns true if this iterator is greater than or equal to other.

Parameters:
other Another TextIter.

void Xfc::Gtk::TextIter::order const TextIter first,
const TextIter second
[static]
 

Swaps the value of first and second if second comes before first in the buffer.

Parameters:
first A TextIter.
second Another TextIter.
This method ensures that first 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 in_range(), that expect a pre-sorted range.

void Xfc::Gtk::TextIter::set_line int  line_number  ) 
 

Moves the iterator to the start of the line line_number.

Parameters:
line_number The line number (counted from 0).
If line_number is negative or larger than the number of lines in the buffer, moves iter to the start of the last line in the buffer.

void Xfc::Gtk::TextIter::set_line_index int  byte_on_line  ) 
 

Same as set_line_offset(), but works with a byte index.

Parameters:
byte_on_line A byte index relative to the start of iter's current line.
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.

void Xfc::Gtk::TextIter::set_line_offset int  char_on_line  ) 
 

Moves the iterator within a line, to a new character (not byte) offset.

Parameters:
char_on_line A character offset relative to the start of iter's current line.
The given character offset must be less than or equal to the number of characters in the line; if equal, the iterator moves to the start of the next line. See set_line_index() if you have a byte index rather than a character offset.

void Xfc::Gtk::TextIter::set_offset int  char_offset  ) 
 

Sets the iterator to point to char_offset.

Parameters:
char_offset A character number.
char_offset counts from the start of the entire text buffer, starting with 0.

void Xfc::Gtk::TextIter::set_visible_line_index int  byte_on_line  ) 
 

Like set_line_index(), but the index is in visible bytes, that is, text with a tag making it invisible is not counted in the index.

Parameters:
byte_on_line A byte index.

void Xfc::Gtk::TextIter::set_visible_line_offset int  char_on_line  ) 
 

Like set_line_offset(), but the offset is in visible characters, that is, text with a tag making it invisible is not counted in the offset.

,

Parameters:
char_on_line A character offset.

bool Xfc::Gtk::TextIter::starts_line  )  const
 

Returns true if the iterator begins a paragraph, that is, if get_line_offset() would return 0.

Returns:
Whether the iterator begins a line.
This method is potentially more efficient than get_line_offset() because it doesn't have to compute the offset, it just has to see whether it's 0.

bool Xfc::Gtk::TextIter::starts_sentence  )  const
 

Determines whether the iterator begins a sentence.

Returns:
true if the iterator is at the start of a 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).

bool Xfc::Gtk::TextIter::starts_word  )  const
 

Determines whether the iterator begins a natural-language word.

Returns:
true if the iterator is at the start of a word.
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).

bool Xfc::Gtk::TextIter::toggles_tag const TextTag tag = 0  )  const
 

This is equivalent to (begins_tag() || ends_tag()), that is, it tells you whether a range with tag applied to it begins or ends at iter.

Parameters:
tag A TextTag, or null.
Returns:
Whether tag is toggled on or off at this iterator.


The documentation for this class was generated from the following file: Xfce Foundation Classes
Copyright © 2004-2005 The XFC Development Team XFC 4.3