[Urwid] palette container

Ian Ward ian at excess.org
Tue Aug 16 22:38:25 EDT 2011


Alain Leufroy wrote on 2011-08-16 07:11:
> Hi,
> 
> I'd like to use pygments to colorize source file data displayed in a Text
> widget.
> 
> To do so, I set a palette with names from pygments tokens. Here is a simple
> example::
> 
...
> 
> Running ``python test.py`` displays a highlighted source code. But it is not
> exactly what as I expect.
> 
> For example, *Foo* is not highlighted because pygments sets the "style" to
> *token.Token.Name.Class*. But I'd like that *Foo* is in "dark blue" because
> *token.Token.Name.Class* is a "sub-style" of *token.Token.Name* (instead of
> defining all "sub-style of "token.Token.Name" to the same style).
> 
> From now urwid stores the palette in a dictionary (ex: raw_display.py line 51
> changeset d6d6ae081dcf of https://excess.org/hg/urwid/).
> Is it possible to add a way to tune the palette container for a dict-like class
> that suite special needs?

Hi Alain,

I suppose you could replace the _palette dictionary in your screen with
your own dictionary-like object that does that sort of advanced lookup.

Ian



More information about the Urwid mailing list