简体   繁体   中英

Change terminal tab name with ncurses in python

I use to change terminal tab names in python using:

sys.stdout.write('\x1b]2;' + name + '\x07')

Can this can be achieved while using ncurses? If not, is there any workaround?

That's outside the scope of ncurses.

You can write the text as shown, but...

By default (using initscr ) ncurses writes to the standard output . You can change that to a different stream using newterm , but in either case, ncurses buffers its output to the screen separately from the <stdio.h> (standard I/O) streams. If you happen to use the same output as ncurses, you should do a refresh in ncurses first, and flush the output from your write before resuming ncurses.

For your example, there's no complicating factors (such as printing newlines), but those could be addressed with the calls that save/restore program/shell mode.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM