RE: doubt on usage of textview
- From: martyn 2 russell bt com
- To: johnson cyberbabies com, gtk-app-devel-list gnome org
- Subject: RE: doubt on usage of textview
- Date: Thu, 18 Sep 2003 09:56:25 +0100
i displayed the hex dump of a file in the text view
using the following functions
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (lblControl));
gtk_text_buffer_set_text (buffer, text,-1);
You probably want to set up TAGS. These are described here:
http://developer.gnome.org/doc/API/2.0/gtk/GtkTextTag.html
You can create these like this:
gtk_text_buffer_create_tag(buffer, "bold",
"weight", PANGO_WEIGHT_BOLD,
NULL);
gtk_text_buffer_create_tag(buffer, "italic",
"style", PANGO_STYLE_ITALIC,
NULL);
gtk_text_buffer_create_tag(buffer, "blue_foreground",
"foreground", "darkblue",
NULL);
Where "bold", "italic", "blue_foreground" are the names of the tags.
Then when you insert text, you can use:
gtk_text_buffer_insert_with_tags_by_name(buffer, &iter,
text, -1,
"blue_foreground",
"bold",
NULL);
my doubt is
1.I want to highlight some of the characters in the textview using
different color or making it bold..all the characters with
value FF have to
be highlighted..
There are two ways to approach this. You can either insert the whole text,
and on the "insert" signal for the GtkTextBuffer go through the text just
entered and highlight the parts you want to; OR, you can insert bit by bit
the text using which ever tags you want for that segment of text.
2.I have to retrieve back the changed hex dump into the file...
So you need to load/save the content from/to a file? For this, consider
looking into GIOChannels here:
http://developer.gnome.org/doc/API/2.0/glib/glib-IO-Channels.html
Regards,
Martyn
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]