diff --git a/nomadnet/NomadNetworkApp.py b/nomadnet/NomadNetworkApp.py index 5b24995..65a5e4f 100644 --- a/nomadnet/NomadNetworkApp.py +++ b/nomadnet/NomadNetworkApp.py @@ -32,6 +32,15 @@ class NomadNetworkApp: RNS.log("Saving directory...", RNS.LOG_VERBOSE) self.directory.save_to_disk() + + if hasattr(self.ui, "restore_ixon"): + if self.ui.restore_ixon: + try: + os.system("stty ixon") + + except Exception as e: + RNS.log("Could not restore flow control sequences. 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): diff --git a/nomadnet/ui/TextUI.py b/nomadnet/ui/TextUI.py index 34d9340..7ed1201 100644 --- a/nomadnet/ui/TextUI.py +++ b/nomadnet/ui/TextUI.py @@ -127,6 +127,21 @@ GLYPHS = { class TextUI: def __init__(self): + self.restore_ixon = False + + try: + rval = os.system("stty -a | grep \"\\-ixon\"") + if rval == 0: + pass + + else: + os.system("stty -ixon") + self.restore_ixon = True + + except Exception as e: + RNS.log("Could not configure terminal flow control sequences, some keybindings may not work.", RNS.LOG_WARNING) + RNS.log("The contained exception was: "+str(e)) + self.app = NomadNetworkApp.get_shared_instance() self.app.ui = self self.loop = None @@ -164,7 +179,7 @@ class TextUI: else: initial_widget = self.main_display.widget - self.loop = urwid.MainLoop(initial_widget, screen=self.screen, handle_mouse=mouse_enabled) + self.loop = urwid.MainLoop(initial_widget, unhandled_input=self.unhandled_input, screen=self.screen, handle_mouse=mouse_enabled) if intro_timeout > 0: self.loop.set_alarm_in(intro_timeout, self.display_main) @@ -194,5 +209,8 @@ class TextUI: self.screen.set_terminal_properties(colormode) self.screen.reset_default_terminal_palette() + def unhandled_input(self, key): + pass + def display_main(self, loop, user_data): self.loop.widget = self.main_display.widget diff --git a/nomadnet/ui/textui/Extras.py b/nomadnet/ui/textui/Extras.py index f0314df..75327d4 100644 --- a/nomadnet/ui/textui/Extras.py +++ b/nomadnet/ui/textui/Extras.py @@ -17,45 +17,3 @@ class IntroDisplay(): self.widget = urwid.Filler(intro) - -class DemoDisplay(): - def __init__(self, ui, app): - import urwid - - def color_mono(btn): - ui.set_colormode(nomadnet.ui.COLORMODE_MONO) - - def color_16(btn): - ui.set_colormode(nomadnet.ui.COLORMODE_16) - - def color_88(btn): - ui.set_colormode(nomadnet.ui.COLORMODE_88) - - def color_8bit(btn): - ui.set_colormode(nomadnet.ui.COLORMODE_256) - - def color_true(btn): - ui.set_colormode(nomadnet.ui.COLORMODE_TRUE) - - # pile = urwid.Pile([ - # urwid.Text(("heading", "This is a heading")), - # urwid.Text(("body_text", "Hello World \U0001F332")), - # urwid.Button(("buttons", "Monochrome"), color_mono), - # urwid.Button(("buttons", "16 color"), color_16), - # urwid.Button(("buttons", "88 color"), color_88), - # urwid.Button(("buttons", "256 color"), color_8bit), - # urwid.Button(("buttons", "True color"), color_true), - # ]) - - gf = urwid.GridFlow([ - urwid.Text(("heading", "This is a heading")), - urwid.Text(("body_text", "Hello World \U0001F332")), - urwid.Button(("buttons", "Monochrome"), color_mono), - urwid.Button(("buttons", "16 color"), color_16), - urwid.Button(("buttons", "88 color"), color_88), - urwid.Button(("buttons", "256 color"), color_8bit), - urwid.Button(("buttons", "True color"), color_true), - ], cell_width=20, h_sep=0, v_sep=0, align="left") - - self.widget = urwid.Filler(urwid.Padding((urwid.Text("Test"),urwid.Text("Test 2"))), 'top') - #self.widget = urwid.Filler(pile, 'top') \ No newline at end of file