Exploring terminfo
Alan Gauld
alan.gauld at yahoo.co.uk
Fri Jan 15 08:19:26 EST 2021
On 14/01/2021 16:12, Alan Gauld via Python-list wrote:
> #################
> 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 "Nice..." line isn't.
A bit more exploration and I've got a C version of the same program
to work (I'll spare you the #includes!):
int main(void){
char line[20];
int err = 0;
char *clr;
char *bold;
setupterm("xterm",1, &err);
clr = tigetstr("clear");
bold = tigetstr("bold");
putp(clr);
putp(bold);
printf("Enter a name: ");
fgets(line, sizeof(line),stdin);
printf("Hello %s\n", line);
exit(0);
}
So the native C functions work as expected.
Why does the Python wrapper not?
--
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