jquast / blessed

Blessed is an easy, practical library for making python terminal apps

Home Page:http://pypi.python.org/pypi/blessed

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Side effects of `Terminal`

wookayin opened this issue · comments

It seems that many operations being done inside the constructor of blessed.Terminal causes some weird side effects on ncurses side.

For example:

from blessed import Terminal
#from blessings import Terminal

import os
assert os.environ['TERM'] == 'xterm-256color'

# t1 = Terminal()                          <- (*)
t2 = Terminal(kind='linux')

import pudb; pudb.set_trace()

If the very first initialization/instantiation of Terminal is done with some unexpected kind or term settings, it blows all colors away from ncurse. As a result the pudb screen (pudb uses ncurses for its UI) becomes ALL black.

image

However, if the very first instantiation is done with a standard option, say, for example, uncomment the line (*), then it works OK (pudb works in color). This hypothesizes that there is some side effects during initialization. Actually this is a problem of blessing as well.

I think this is expected, please read,

https://github.com/jquast/blessed/blob/master/blessed/terminal.py#L1316-L1335
https://github.com/jquast/blessed/blob/master/blessed/terminal.py#L231-L245

Especially phrase,

it is unsupported by the 'curses' module to change the terminal type again.

Thanks for the clarification!