Skip to content

Commit

Permalink
curses color initialization can fail on some platforms
Browse files Browse the repository at this point in the history
  • Loading branch information
totaam committed Nov 9, 2024
1 parent 129c5b1 commit fc8638d
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions xpra/client/base/top.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@
PAUSE_KEYS = (ord("p"), ord("P"))
SIGNAL_KEYS = {
3: signal.SIGINT,
26: signal.SIGSTOP,
}
if hasattr(signal, "SIGSTOP"):
SIGNAL_KEYS[26] = signal.SIGSTOP


def get_title() -> str:
Expand All @@ -57,13 +58,17 @@ def curses_init():
curses.noecho()
curses.raw()
curses.start_color()
curses.use_default_colors()
try:
curses.use_default_colors()
curses.init_pair(WHITE, curses.COLOR_WHITE, curses.COLOR_BLACK)
curses.init_pair(GREEN, curses.COLOR_GREEN, curses.COLOR_BLACK)
curses.init_pair(YELLOW, curses.COLOR_YELLOW, curses.COLOR_BLACK)
curses.init_pair(RED, curses.COLOR_RED, curses.COLOR_BLACK)
except Exception:
# this can fail on some terminals, ie: mingw
pass
# for i in range(0, curses.COLORS):
# curses.init_pair(i+1, i, -1)
curses.init_pair(WHITE, curses.COLOR_WHITE, curses.COLOR_BLACK)
curses.init_pair(GREEN, curses.COLOR_GREEN, curses.COLOR_BLACK)
curses.init_pair(YELLOW, curses.COLOR_YELLOW, curses.COLOR_BLACK)
curses.init_pair(RED, curses.COLOR_RED, curses.COLOR_BLACK)
return stdscr


Expand Down

0 comments on commit fc8638d

Please sign in to comment.