Merge branch 'fix-tty-colors' into 'master'
Don't use custom colors on unsupported screens, fixes #67 Closes #67 See merge request ynerant/squirrel-battle!61
This commit is contained in:
commit
5b5180d44a
@ -124,15 +124,24 @@ class Display:
|
||||
return pad.addstr(y, x, msg, attr)
|
||||
|
||||
def init_pair(self, number: int, foreground: int, background: int) -> None:
|
||||
foreground = foreground if self.screen and curses.can_change_color() \
|
||||
and foreground < curses.COLORS \
|
||||
else curses.COLOR_WHITE
|
||||
background = background if self.screen and curses.can_change_color() \
|
||||
and background < curses.COLORS \
|
||||
else curses.COLOR_WHITE
|
||||
return curses.init_pair(number, foreground, background) \
|
||||
if self.screen else None
|
||||
if self.screen and curses.can_change_color() \
|
||||
and number < curses.COLOR_PAIRS else None
|
||||
|
||||
def color_pair(self, number: int) -> int:
|
||||
return curses.color_pair(number) if self.screen else 0
|
||||
return curses.color_pair(number) if self.screen \
|
||||
and number < curses.COLOR_PAIRS else 0
|
||||
|
||||
def init_color(self, number: int, red: int, green: int, blue: int) -> None:
|
||||
return curses.init_color(number, red, green, blue) \
|
||||
if self.screen else None
|
||||
if self.screen and curses.can_change_color() \
|
||||
and number < curses.COLORS else None
|
||||
|
||||
def resize(self, y: int, x: int, height: int, width: int,
|
||||
resize_pad: bool = True) -> None:
|
||||
|
Loading…
Reference in New Issue
Block a user