[Urwid] A proper way to clear the screen?
Ian Ward
ian at excess.org
Fri Feb 20 20:51:52 EST 2009
Max E. Kuznecov wrote:
> Hi, I wonder what is the proper way to clear the screen after
> urwid is initialzed?
> What I need is something like mc does - the panels are displayed on the
> screen but before command execution the screen must be cleared.
>
> As for now I switch back to saved termios settings using tcsetattr and
> then write "\x1b[H\x1b[2J" to stdout (a cl property from termcap for
> xterm). It works but I worry about different terminal types with
> (possibly) different cl codes.
>
> Maybe it would be more portable if I first clear the screen using urwid
> facilities and then go to shell mode, but I've found none in docs.
Once Urwid's not controlling the screen you're on your own. You said
you're running a shell, presumably calling screen.stop() first, so there
aren't any Urwid functions that will help.
If the python curses module is available you could use it to query the
cl termcap property on the system and send that, failing that send the
one you have.
Ian
BTW, that would be more than what the raw_display module currently does.
raw_display just assumes a set of escape sequences will work.. It
really should also try to query the termcap, but I haven't gotten to
that yet.
More information about the Urwid
mailing list