[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Missing python curses functions?

On 20/05/2020 01:48, Cameron Simpson wrote:

> It may be that the person who wrote the curses module simply got tired.  

That was my assumption. Although the implementation includes some
functions that are a lot more obscure. Usually when one is missing there
is an alternative with the same effect, but in this case I can't find
any way of finding out the attributes of a piece of text. You can read
the text with instr() but it does not include the attributes.

I confess I've never needed this functionality and only realized it
was missing by working through the HOWO document. But I can see
where it might be useful, say to toggle from bold to dim or

> Or it predates the get_attr calls (not sure now old they are).

>From the man page it looks like its been there since SVR3 at least.

But in browsing the man pages I came across another function
that returns the attributes for a single character - inch().
That is supported in Python.

To get the current settings you would need to write a
character to the window(addch), fetch its attributes using
inch() then delete the character just written (delch).
Clunky but it should work. I'll try it and see if I
can create an attr_get(win)->int  function in Python...

Alan G
Author of the Learn to Program web site
Follow my photo-blog on Flickr at: