# File gtk/sample/gtk-demo/textview.rb, line 181
    def insert_text(buffer)

      ##
      #  Demo.find_file looks in the the current directory first,
      # so you can run gtk-demo without installing GTK, then looks
      # in the location where the file is installed.
      # 

      filename = Demo.find_file("gtk-logo-rgb.gif")
      pixbuf = Gdk::Pixbuf.new(filename) if filename

      unless pixbuf
        $stderr.print "Failed to load image file gtk-logo-rgb.gif\n"
        exit 1
      end

      scaled = pixbuf.scale(32, 32, Gdk::Pixbuf::INTERP_BILINEAR)
      pixbuf = scaled

      ##
      #  get start of buffer; each insertion will revalidate the
      #  iterator to point to just after the inserted text.
      #  

      iter = buffer.get_iter_at_offset(0)

      buffer.insert(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")

      buffer.insert(iter, "Font styles. ", 'heading')
      
      buffer.insert(iter, "For example, you can have ")
      buffer.insert(iter, "italic", "italic")
      buffer.insert(iter, ", ")
      buffer.insert(iter, "bold", "bold")
      buffer.insert(iter, ", or ")
      buffer.insert(iter, "monospace(typewriter)", "monospace")
      buffer.insert(iter, ", or ")
      buffer.insert(iter, "big", "big")
      buffer.insert(iter, " text. ")
      buffer.insert(iter, "It's best not to hardcode specific text sizes; you can use relative sizes as with CSS, such as ")
      buffer.insert(iter, "xx-small", "xx-small")
      buffer.insert(iter, " or ")
      buffer.insert(iter, "x-large", "x-large")
      buffer.insert(iter, " to ensure that your program properly adapts if the user changes the default font size.\n\n")
      
      buffer.insert(iter, "Colors. ", "heading")
      
      buffer.insert(iter, "Colors such as ")
      buffer.insert(iter, "a blue foreground", "blue_foreground")
      buffer.insert(iter, " or ")
      buffer.insert(iter, "a red background", "red_background")
      buffer.insert(iter, " or even ")
      buffer.insert(iter, "a stippled red background",
                    "red_background", "background_stipple")

      buffer.insert(iter, " or ")
      buffer.insert(iter, "a stippled blue foreground on solid red background",
                    "blue_foreground", "red_background", "foreground_stipple")

      buffer.insert(iter, "(select that to read it) can be used.\n\n")

      buffer.insert(iter, "Underline, strikethrough, and rise. ", "heading")
      
      buffer.insert(iter, "Strikethrough", "strikethrough")
      buffer.insert(iter, ", ")
      buffer.insert(iter, "underline", "underline")
      buffer.insert(iter, ", ")
      buffer.insert(iter, "double underline", "double_underline")
      buffer.insert(iter, ", ")
      buffer.insert(iter, "superscript", "superscript")
      buffer.insert(iter, ", and ")
      buffer.insert(iter, "subscript", "subscript")
      buffer.insert(iter, " are all supported.\n\n")

      buffer.insert(iter, "Images. ", "heading")
      
      buffer.insert(iter, "The buffer can have images in it: ")
      buffer.insert(iter, pixbuf)
      buffer.insert(iter, pixbuf)
      buffer.insert(iter, pixbuf)
      buffer.insert(iter, " for example.\n\n")

      buffer.insert(iter, "Spacing. ", "heading")

      buffer.insert(iter, "You can adjust the amount of space before each line.\n")
      
      buffer.insert(iter, "This line has a whole lot of space before it.\n",
                    "big_gap_before_line", "wide_margins")
      buffer.insert(iter, "You can also adjust the amount of space after each line; this line has a whole lot of space after it.\n",
                    "big_gap_after_line", "wide_margins")
      
      buffer.insert(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",
                    "double_spaced_line", "wide_margins")

      buffer.insert(iter, "Also note that those lines have extra-wide margins.\n\n")

      buffer.insert(iter, "Editability. ", "heading")
      
      buffer.insert(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",
                    "not_editable")

      buffer.insert(iter, "Wrapping. ", "heading")

      buffer.insert(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")
      
      buffer.insert(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", "char_wrap")
      
      buffer.insert(iter, "This line has all wrapping turned off, so it makes the horizontal scrollbar appear.\n\n\n", "no_wrap")

      buffer.insert(iter, "Justification. ", "heading")
      
      buffer.insert(iter, "\nThis line has center justification.\n", "center")

      buffer.insert(iter, "This line has right justification.\n",
                    "right_justify")

      buffer.insert(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", "wide_margins")

      buffer.insert(iter, "Internationalization. ", "heading")

      buffer.insert(iter, "You can put all sorts of Unicode text in the buffer.\n\nGerman(Deutsch Süd) Grüß Gott\nGreek(Ελληνικά) Γειά σας\nHebrew    שלום\nJapanese(日本語)\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")

      buffer.insert(iter, "Here's a word-wrapped quote in a right-to-left language:\n")
      buffer.insert(iter, "??? ??? ???? ?? ???? ???????? ????? ?? ???? ?????? ??????? ??????? ?? ???? ?????? ?? ????? ?? ??????? ????? ??????? ??? ?????? ????? ?????? ????? ???? ?? ?????? ?????? ?? ???????? ?????? ????? ?? ???? ???? ????????? ???????. ???? ???? ??? ???????? ????? ?? »????????« ?? ???????.\n\n", "rtl_quote")
      
      buffer.insert(iter, "You can put widgets in the buffer: Here's a button: ")
      anchor = buffer.create_child_anchor(iter)
      buffer.insert(iter, " and a menu: ")
      anchor = buffer.create_child_anchor(iter)
      buffer.insert(iter, " and a scale: ")
      anchor = buffer.create_child_anchor(iter)
      buffer.insert(iter, " and an animation: ")
      anchor = buffer.create_child_anchor(iter)
      buffer.insert(iter, " finally a text entry: ")
      anchor = buffer.create_child_anchor(iter)
      buffer.insert(iter, ".\n")
      
      buffer.insert(iter, "\n\nThis demo doesn't demonstrate all the Gtk::TextBuffer features; it leaves out, for example: invisible/hidden text(doesn't work in GTK 2, but planned), tab stops, application-drawn areas on the sides of the widget for displaying breakpoints and such...")

      #  Apply word_wrap tag to whole buffer 

      buf_start, buf_end = buffer.bounds
      buffer.apply_tag("word_wrap", buf_start, buf_end)
    end