[Gtk-sharp-list] Re:TextBuffer and TextTags

Muthiah Annamalai ec10130@nitt.edu
Sun, 18 Jul 2004 16:46:58 +0530


Hello  there!

> I'm trying to format text within a TextView. Things like bolding,
> changing font etc, but for specific areas of the buffer, not for all the
> textview.

The `gtk-demo` program that comes with most GNU/Linux
distributions has a example GTK text widget that does
push it to extreme limits. It also has example code
and 'tags' for the text table to be put into the gtk
text tagtable. 
 The tags are generally like [key,value] pairs.
We have many tags {but not limited to} 
  ["background"=>{"#ff0000"|"red"}]
  ["foreground"=>{"#00ff00"|"green"}]
  ["size"=>{/* in pango units, as integer */}] //font size
  ["weight"=>{PANGO_WEIGHT_}] //use these enums for [BOLD/ITALIC etc..]
  ["variant"=>{PANGO_VARIANT_*}] //small caps, all caps, etc 
  ["editable"=>{TRUE|FALSE}]  // ;-)
  ["font_desc"=>{/*pointer to pango font description */}] //different fonts
  ... and many more. Please lookinto the GTK+ sources within the file
  /gtk+/gtk/gtktexttag.c in function gtk_text_tag_class_init(...)

Populate the tagtables.
Then fix the tagtable onto a textbuffer.
Then set the tags between the given points
on the text iters.

My 2 cents,
Cheers
Muthu.


Life is beautiful.
http://cybernetics.freewebspace.com

-------------------------------------------------
This mail sent through IMP(http://www.nitt.edu)