Exploring terminfo

Grant Edwards grant.b.edwards at gmail.com
Fri Jan 15 22:09:53 EST 2021


On 2021-01-16, Cameron Simpson <cs at cskk.id.au> wrote:
> On 15Jan2021 18:36, Alan Gauld <alan.gauld at yahoo.co.uk> wrote:
>>> One difference is that the name prompt is being written to stdout in
>>> the C version and stderr in the Python version. But I don't see why
>>> that would matter.
>>
>>That could make a big difference, the putp() function specifically
>>states that it writes to stdout.
>
> If you want an example of code using the curses.ti* functions with 
> arbitrary Python files, have a gander at this:
>
>     https://hg.sr.ht/~cameron-simpson/css/browse/lib/python/cs/upd.py?rev=tip

I don't see how it deals with terminfo strings that have delay
specifiers in them (e.g. vt100). Those delay specifiers need to be
replaced by 0 or more 'pad' characters (default is NUL, but that too
can be specified in the terminfo file).

My initial plan was to call ncurses tputs() function and pass it a
'putchar' callback that passes the output bytes to
sys.stdout.buffer.write(). I haven't gotten that working yet (it's
going to require some cytyptes magic).


--
Grant





More information about the Python-list mailing list