Exploring terminfo

Alan Gauld alan.gauld at yahoo.co.uk
Thu Jan 14 11:12:24 EST 2021


During lockdown I've been digging deeper into the curses module
and lately into the tiXXXX family of functions that reside there.

I've written a short program that is supposed to
- *clear the screen*,
- read some input
- display the result in a message *highlighted in bold*.
- get input to end the program

The parts marked with ** use terminfo, or they should.
My problem is that while the clear-screen part works the
bold bit only appears in the final input(), not in the
output message.

Here is the code:

#################
import curses as cur
cur.setupterm()

bold = cur.tigetstr('bold')
cls = cur.tigetstr('clear')

cur.putp(cls)
name = input("Hello, what's your name? ")

cur.putp(bold)
print("Nice to meet you ", name)

input("\nHit enter to exit")
###############

I've tried variations on flush both inside and outside
the print() - both before and after.
I've tried writing to stdout instead of print, but nothing is working.
The Hit enter... message is in bold but the Hello... line isn't.

Does anyone know what's going on and how to fix it.

I could, of course, jump into full curses but I wanted to
see if I could use the terminfo stuff directly to retain
use of regular input() and print() functions.

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos




More information about the Python-list mailing list