From: James Littlefield on
I need to change the foreground (or background) color to highlight only
specific words in a scrollable text widget. Is there a way to embed
formatting control codes (sort of like ansi escape codes) in the content
of a text widget to cause this?

Thanks
Jim

--- news://freenews.netfront.net/ - complaints: news(a)netfront.net ---
From: APN on
You can tag the range of characters/words and then use the -foreground
option on the tag. Read up the Tags section in the text widget man
page.

/Ashok

On Feb 25, 7:00 am, James Littlefield <jameslittlefi...(a)verizon.net>
wrote:
> I need to change the foreground (or background) color to highlight only
> specific words in a scrollable text widget.    Is there a way to embed
> formatting control codes (sort of like ansi escape codes) in the content
> of a text widget to cause this?
>
> Thanks
> Jim
>
> --- news://freenews.netfront.net/ - complaints: n...(a)netfront.net ---

From: Jeff Godfrey on
James Littlefield wrote:
> I need to change the foreground (or background) color to highlight only
> specific words in a scrollable text widget. Is there a way to embed
> formatting control codes (sort of like ansi escape codes) in the content
> of a text widget to cause this?
>
> Thanks
> Jim
>
> --- news://freenews.netfront.net/ - complaints: news(a)netfront.net ---

Hi Jim,

You'll want to look at the text widget's tagging ability. Basically,
you create tags, apply your formatting to the tags, and then apply the
tags to specific character ranges in the text widget.

Jeff
From: suchenwi on
On 25 Feb., 05:15, Jeff Godfrey <jeff_godf...(a)pobox.com> wrote:
> James Littlefield wrote:
> > I need to change the foreground (or background) color to highlight only
> > specific words in a scrollable text widget.    Is there a way to embed
> > formatting control codes (sort of like ansi escape codes) in the content
> > of a text widget to cause this?
> You'll want to look at the text widget's tagging ability.  Basically,
> you create tags, apply your formatting to the tags, and then apply the
> tags to specific character ranges in the text widget.

Simple example, in an interactive wish:
% pack [text .t]
% foreach i {red green blue} {.t tag configure $i -foreground $i}
% .t insert end "hello, " red world! green
From: Arjen Markus on
On 25 feb, 03:00, James Littlefield <jameslittlefi...(a)verizon.net>
wrote:
> I need to change the foreground (or background) color to highlight only
> specific words in a scrollable text widget.    Is there a way to embed
> formatting control codes (sort of like ansi escape codes) in the content
> of a text widget to cause this?
>
> Thanks
> Jim
>
> --- news://freenews.netfront.net/ - complaints: n...(a)netfront.net ---

You may also want to look at the ctext package in Tklib. This
automates
a lot of such tasks for you. It is geared at syntax highlighting
though,
so it is at its best with regular expressions.

As for formatting codes: you could use the -elide option for tags to
hide
the actual code from the display while analysing your input text.

Regards,

Arjen