Curses background color not working in iTerm2 with TERM=xterm

回眸只為那壹抹淺笑 提交于 2019-12-11 02:14:15

问题


I have the following code that draws a small window with a message using curses.

import curses
import time

screen = curses.initscr()
curses.start_color()
curses.init_pair(1, curses.COLOR_WHITE, curses.COLOR_BLUE)
window = curses.newwin(15, 60)
window.bkgd(' ', curses.color_pair(1))
window.addstr(7, 1, 'Hello')
window.refresh()
time.sleep(2)
curses.endwin()

I expect the background color to be blue, but the behavior is not consistent in iTerm2. With TERM=screen, I get the expected output:

When TERM=xterm though, spaces are not painted:

If I use a different character for the background, it's painted correctly. What could be the issue?

I'm using Python 3 and iTerm2 3.0.


回答1:


The problem is that tmux does not support the "back color erase" feature assumed in the xterm terminal description.

Further reading:

  • My terminal shows some uncolored spaces (ncurses FAQ)

  • Why do Vim colors look different inside and outside of tmux?



来源:https://stackoverflow.com/questions/43214987/curses-background-color-not-working-in-iterm2-with-term-xterm

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!