/* get start of buffer; each insertion will revalidate the *iteratortopointtojustaftertheinsertedtext.
*/
gtk_text_buffer_get_iter_at_offset (buffer, &iter, 0);
gtk_text_buffer_begin_irreversible_action (buffer);
gtk_text_buffer_insert (buffer, &iter, "The text widget can display text with all kinds of nifty attributes. " "It also supports multiple views of the same buffer; this demo is " "showing the same buffer in two places.\n\n", -1);
gtk_text_buffer_insert (buffer, &iter, "For example, you can have ", -1);
gtk_text_buffer_insert_with_tags_by_name (buffer, &iter, "italic", -1, "italic", NULL);
gtk_text_buffer_insert (buffer, &iter, ", ", -1);
gtk_text_buffer_insert_with_tags_by_name (buffer, &iter, "bold", -1, "bold", NULL);
gtk_text_buffer_insert (buffer, &iter, ", or ", -1);
gtk_text_buffer_insert_with_tags_by_name (buffer, &iter, "monospace (typewriter)", -1, "monospace", NULL);
gtk_text_buffer_insert (buffer, &iter, ", or ", -1);
gtk_text_buffer_insert_with_tags_by_name (buffer, &iter, "big", -1, "big", NULL);
gtk_text_buffer_insert (buffer, &iter, " text. ", -1);
gtk_text_buffer_insert (buffer, &iter, "It's best not to hardcode specific text sizes; you can use relative " "sizes as with CSS, such as ", -1);
gtk_text_buffer_insert_with_tags_by_name (buffer, &iter, "xx-small", -1, "xx-small", NULL);
gtk_text_buffer_insert (buffer, &iter, " or ", -1);
gtk_text_buffer_insert_with_tags_by_name (buffer, &iter, "x-large", -1, "x-large", NULL);
gtk_text_buffer_insert (buffer, &iter, " to ensure that your program properly adapts if the user changes the " "default font size.\n\n", -1);
gtk_text_buffer_insert (buffer, &iter, "Colors such as ", -1);
gtk_text_buffer_insert_with_tags_by_name (buffer, &iter, "a blue foreground", -1, "blue_foreground", NULL);
gtk_text_buffer_insert (buffer, &iter, " or ", -1);
gtk_text_buffer_insert_with_tags_by_name (buffer, &iter, "a red background", -1, "red_background", NULL);
gtk_text_buffer_insert (buffer, &iter, " or even ", -1);
gtk_text_buffer_insert_with_tags_by_name (buffer, &iter, "a blue foreground on red background", -1, "blue_foreground", "red_background",
NULL);
gtk_text_buffer_insert (buffer, &iter, " (select that to read it) can be used.\n\n", -1);
gtk_text_buffer_insert (buffer, &iter, "You can adjust the amount of space before each line.\n", -1);
gtk_text_buffer_insert_with_tags_by_name (buffer, &iter, "This line has a whole lot of space before it.\n", -1, "big_gap_before_line", "wide_margins", NULL);
gtk_text_buffer_insert_with_tags_by_name (buffer, &iter, "You can also adjust the amount of space after each line; " "this line has a whole lot of space after it.\n", -1, "big_gap_after_line", "wide_margins", NULL);
gtk_text_buffer_insert_with_tags_by_name (buffer, &iter, "You can also adjust the amount of space between wrapped lines; " "this line has extra space between each wrapped line in the same " "paragraph. To show off wrapping, some filler text: the quick " "brown fox jumped over the lazy dog. Blah blah blah blah blah " "blah blah blah blah.\n", -1, "double_spaced_line", "wide_margins", NULL);
gtk_text_buffer_insert (buffer, &iter, "Also note that those lines have extra-wide margins.\n\n", -1);
gtk_text_buffer_insert_with_tags_by_name (buffer, &iter, "This line is 'locked down' and can't be edited by the user - just " "try it! You can't delete this line.\n\n", -1, "not_editable", NULL);
gtk_text_buffer_insert (buffer, &iter, "This line (and most of the others in this buffer) is word-wrapped, " "using the proper Unicode algorithm. Word wrap should work in all " "scripts and languages that GTK supports. Let's make this a long " "paragraph to demonstrate: blah blah blah blah blah blah blah blah " "blah blah blah blah blah blah blah blah blah blah blah\n\n", -1);
gtk_text_buffer_insert_with_tags_by_name (buffer, &iter, "This line has character-based wrapping, and can wrap between any two " "character glyphs. Let's make this a long paragraph to demonstrate: " "blah blah blah blah blah blah blah blah blah blah blah blah blah blah " "blah blah blah blah blah\n\n", -1, "char_wrap", NULL);
gtk_text_buffer_insert_with_tags_by_name (buffer, &iter, "This line has all wrapping turned off, so it makes the horizontal " "scrollbar appear.\n\n\n", -1, "no_wrap", NULL);
gtk_text_buffer_insert_with_tags_by_name (buffer, &iter, "\nThis line has center justification.\n", -1, "center", NULL);
gtk_text_buffer_insert_with_tags_by_name (buffer, &iter, "This line has right justification.\n", -1, "right_justify", NULL);
gtk_text_buffer_insert_with_tags_by_name (buffer, &iter, "\nThis line has big wide margins. Text text text text text text text " "text text text text text text text text text text text text text text " "text text text text text text text text text text text text text text " "text.\n", -1, "wide_margins", NULL);
gtk_text_buffer_insert (buffer, &iter, "You can put all sorts of Unicode text in the buffer.\n\nGerman " "(Deutsch S\303\274d) Gr\303\274\303\237 Gott\nGreek " "(\316\225\316\273\316\273\316\267\316\275\316\271\316\272\316\254) " "\316\223\316\265\316\271\316\254 \317\203\316\261\317\202\nHebrew " "\327\251\327\234\327\225\327\235\nJapanese " "(\346\227\245\346\234\254\350\252\236)\n\nThe widget properly handles " "bidirectional text, word wrapping, DOS/UNIX/Unicode paragraph separators, " "grapheme boundaries, and so on using the Pango internationalization " "framework.\n", -1);
gtk_text_buffer_insert (buffer, &iter, "You can put widgets in the buffer: Here's a button: ", -1);
gtk_text_buffer_create_child_anchor (buffer, &iter);
gtk_text_buffer_insert (buffer, &iter, " and a menu: ", -1);
gtk_text_buffer_create_child_anchor (buffer, &iter);
gtk_text_buffer_insert (buffer, &iter, " and a scale: ", -1);
gtk_text_buffer_create_child_anchor (buffer, &iter);
gtk_text_buffer_insert (buffer, &iter, " finally a text entry: ", -1);
gtk_text_buffer_create_child_anchor (buffer, &iter);
gtk_text_buffer_insert (buffer, &iter, ".\n", -1);
gtk_text_buffer_insert (buffer, &iter, "\n\nThis demo doesn't demonstrate all the GtkTextBuffer features; " "it leaves out, for example: invisible/hidden text, tab stops, " "application-drawn areas on the sides of the widget for displaying " "breakpoints and such...", -1);
/* Apply word_wrap tag to whole buffer */
gtk_text_buffer_get_bounds (buffer, &start, &end);
gtk_text_buffer_apply_tag_by_name (buffer, "word_wrap", &start, &end);
/* For convenience, we just use the autocreated buffer from *thefirsttextview;youcouldalsocreatethebuffer *byitselfwithgtk_text_buffer_new(),thenlatercreate *aviewwidget.
*/
view1 = gtk_text_view_new ();
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view1));
view2 = gtk_text_view_new_with_buffer (buffer);
if (window)
{
gtk_window_present (GTK_WINDOW (window)); return;
}
buffer = gtk_text_buffer_new (NULL);
gtk_text_buffer_get_start_iter (buffer, &iter);
gtk_text_buffer_insert (buffer, &iter, "This buffer is shared by a set of nested text views.\n Nested view:\n", -1);
anchor = gtk_text_buffer_create_child_anchor (buffer, &iter);
gtk_text_buffer_insert (buffer, &iter, "\nDon't do this in real applications, please.\n", -1);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.