Re: Caret position of a GtkTextView
- From: "Dov Grobgeld" <dov grobgeld gmail com>
- To: gtk-list gnome org
- Subject: Re: Caret position of a GtkTextView
- Date: Sat, 26 Apr 2008 21:40:14 +0300
The insert position is a special mark called "insert". Just move it and you will move the insert position.
Here's an example of how to move the insert position to the end of the buffer:
void insert_to_end_of_buffer()
{
GtkTextIter iter_end;
GtkTextBuffer *text_buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(w_text_v
iew));
gtk_text_buffer_get_end_iter(text_buffer,
&iter_end);
gtk_text_buffer_move_mark_by_name(text_buffer, "insert", &iter_end);
gtk_text_buffer_move_mark_by_name(text_buffer, "selection_bound", &iter_end);
}
Note that you will also need to scroll the buffer manually if you want to see the caret. This may e.g. be done through the followin code:
void scroll_insert_into_viewer()
{
GtkTextBuffer *text_buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(w_text_view));
GtkTextMark *mark = gtk_text_buffer_get_insert(text_buffer);
// Get the complete line on screen
gtk_text_view_scroll_to_mark(GTK_TEXT_VIEW(w_text_view),
mark,
0.3,
FALSE,
0,
1);
}
Hope this helps.
Dov
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]