Better terminal palette handling. Fixes #8.

This commit is contained in:
Mark Qvist 2022-09-28 16:00:09 +02:00
parent 4a935cb500
commit 4da00e57f3
2 changed files with 12 additions and 1 deletions

View File

@ -47,6 +47,14 @@ class NomadNetworkApp:
except Exception as e:
RNS.log("Could not restore flow control sequences. The contained exception was: "+str(e), RNS.LOG_WARNING)
if hasattr(self.ui, "restore_palette"):
if self.ui.restore_palette:
try:
self.ui.screen.write("\x1b]104\x07")
except Exception as e:
RNS.log("Could not restore terminal color palette. The contained exception was: "+str(e), RNS.LOG_WARNING)
RNS.log("Nomad Network Client exiting now", RNS.LOG_VERBOSE)
def exception_handler(self, e_type, e_value, e_traceback):

View File

@ -207,7 +207,10 @@ class TextUI:
def set_colormode(self, colormode):
self.colormode = colormode
self.screen.set_terminal_properties(colormode)
self.screen.reset_default_terminal_palette()
if self.colormode < 256:
self.screen.reset_default_terminal_palette()
self.restore_palette = True
def unhandled_input(self, key):
if key == "ctrl q":