Coloring text in a GtkText
- From: James Moody <james cr836502-a slnt1 on wave home com>
- To: gtk-list redhat com
- Subject: Coloring text in a GtkText
- Date: Sun, 24 Oct 1999 22:03:38 -0400 (EDT)
I'm interested in being able to set the color or font of a given interval
of text in a GtkText. Am I correct that the following code is the only
way to do this?
gtk_text_freeze(text);
/* Remember position to restore it later */
pos = gtk_text_get_point(text);
/* Go to beginning of desired text */
gtk_text_set_point(text, start);
/* Get desired text */
chars = gtk_editable_get_chars(text, start, end);
/* Then delete it... */
gtk_editable_delete_text(text, start, end);
/* ...and reinsert it with the right attributes */
gtk_text_insert(text, font, fore_color, back_color, chars, end - start);
/* Restore the position */
gtk_text_set_point(text, pos);
gtk_text_thaw(text);
This seems like quite a kludge. I seem to recall someone mentioning that
the text widget was one of the areas for improvement in 1.4; is this one
of the things being improved upon?
Thanks for any comments or suggestions...
james
P.S. I'm aware of the Gtkextext widget mikeh@bahnhof.se has written.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]