Re: Tags in Textview



HI Mike,
Text Tags are applied to the TextBuffer, once the text is loaded into it.  I use the Gtk::TextBuffer::create_tag() function, so the tag is created and added to the textbuffer immediately, which seems more convenient than constructing the tag and then adding it to the buffer separately.

some sample code:

    Gtk::TextView* AView = Gtk::manage(new Gtk::TextView());
    Glib::RefPtr< Gtk::TextBuffer > ABuff = AView->get_buffer();


    Glib::RefPtr<Gtk::TextBuffer::Tag> refTagBold = ABuff->create_tag();
    refTagBold->property_weight() = Pango::WEIGHT_ULTRABOLD;

    //set the text in the buffer, and identify what you want to apply a tag to; then:

    Gtk::TextBuffer::iterator start_it = ABuff->get_iter_at_offset(start_of_highlight);
    Gtk::TextBuffer::iterator end_it = ABuff->get_iter_at_offset(end_of_highlight);
    ABuff->apply_tag(refTagBold, start_it, end_it);


Ian.



On 25/07/14 18:20, mike lear wrote:
Hello,
As a fairly newcomer to gtkmm.
I wonder if someone could point me in the use of tags in a textview window.
I have a vector of strings that I wish to show in column form, similar to say
the unix ls command.
I have examined the  Textview::Tagtable in Dev help but I am still not sure
how  to place these tags in the intended buffer.
Thankyou
Mike Lear


_______________________________________________
gtkmm-list mailing list
gtkmm-list gnome org
https://mail.gnome.org/mailman/listinfo/gtkmm-list



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]