<footnote>
<para>
If you want to place the cursor in response to a user action, be sure to use
-gtk_text_buffer_place_cursor(), which moves both at once without causing a
-temporary selection (moving one then the other temporarily selects the range in
-between the old and new positions).
+<function>gtk_text_buffer_place_cursor()</function>, which moves both at once
+without causing a temporary selection (moving one then the other temporarily
+selects the range in between the old and new positions).
</para>
</footnote>
</para>
<para>
-Text buffers always contain at least one line, but may be empty (that is,
-buffers can contain zero characters). The last line in the text buffer never
-ends in a line separator (such as newline); the other lines in the buffer always
-end in a line separator. Line separators count as characters when computing
-character counts and character offsets.
+Text buffers always contain at least one line, but may be empty (that
+is, buffers can contain zero characters). The last line in the text
+buffer never ends in a line separator (such as newline); the other
+lines in the buffer always end in a line separator. Line separators
+count as characters when computing character counts and character
+offsets. Note that some Unicode line separators are represented with
+multiple bytes in UTF-8, and the two-character sequence "\r\n" is also
+considered a line separator.
</para>
</refsect1>
<para>
The simplest usage of <link linkend="GtkTextView">GtkTextView</link>
might look like this:
-<programlisting>
+<informalexample><programlisting>
GtkWidget *view;
GtkTextBuffer *buffer;
* screen; when the user edits the text, signals on the buffer
* will be emitted, such as "changed", "insert_text", and so on.
*/
-</programlisting>
+</programlisting></informalexample>
In many cases it's also convenient to first create the buffer with
-gtk_text_buffer_new(), then create a widget for that buffer with
-gtk_text_view_new_with_buffer(). Or you can change the buffer the
-widget displays after the widget is created with
-gtk_text_view_set_buffer().
+<function>gtk_text_buffer_new()</function>, then create a widget for that
+buffer with <function>gtk_text_view_new_with_buffer()</function>. Or you can
+change the buffer the widget displays after the widget is created with
+<function>gtk_text_view_set_buffer()</function>.
</para>
</refsect1>
font and foreground color &mdash use standard
<link linkend="GtkWidget">GtkWidget</link>
functions such as
-<link linkend="gtk_widget_modify_font">gtk_widget_modify_font()</link>
+<link linkend="gtk-widget-modify-font">gtk_widget_modify_font()</link>
or
-<link linkend="gtk_widget_modify_fg">gtk_widget_modify_fg()</link>.
+<link linkend="gtk-widget-modify-fg">gtk_widget_modify_text()</link>.
For other attributes there are dedicated methods on
<link linkend="GtkTextView">GtkTextView</link> such as
-<link linkend="gtk_text_view_set_tabs">gtk_text_view_set_tabs()</link>.
+<link linkend="gtk-text-view-set-tabs">gtk_text_view_set_tabs()</link>.
-<programlisting>
+<informalexample><programlisting>
GtkWidget *view;
GtkTextBuffer *buffer;
+ GtkTextIter start, end;
PangoFontDescription *font_desc;
GdkColor color;
GtkTextTag *tag;
pango_font_description_free (font_desc);
/* Change default color throughout the widget */
- gdk_color_parse ("green", &color);
- gtk_widget_modify_fg (view, GTK_STATE_NORMAL, &color);
+ gdk_color_parse ("green", &color);
+ gtk_widget_modify_text (view, GTK_STATE_NORMAL, &color);
/* Change left margin throughout the widget */
gtk_text_view_set_left_margin (GTK_TEXT_VIEW (view), 30);
/* Use a tag to change the color for just one part of the widget */
tag = gtk_text_buffer_create_tag (buffer, "blue_foreground",
"foreground", "blue", NULL);
- gtk_text_buffer_get_iter_at_offset (buffer, &start, 7);
- gtk_text_buffer_get_iter_at_offset (buffer, &end, 12);
- gtk_text_buffer_apply_tag (buffer, tag, &start, &end);
-</programlisting>
+ gtk_text_buffer_get_iter_at_offset (buffer, &start, 7);
+ gtk_text_buffer_get_iter_at_offset (buffer, &end, 12);
+ gtk_text_buffer_apply_tag (buffer, tag, &start, &end);
+</programlisting></informalexample>
</para>