home · contact · privacy
Add escape key "panic button" to return to play mode, whatever.
[plomrogue2] / rogue_chat_curses.py
index 6f136387b33f5353c1216fb13163cdb10da1ba93..8fc2817cbaf45dd1582a84d83e630f38e2cabb5a 100755 (executable)
@@ -1086,15 +1086,20 @@ class TUI:
                 self.do_refresh = True
             except curses.error:
                 continue
-            self.show_help = False
+            keycode = None
+            if len(key) == 1:
+                keycode = ord(key)
             if key == 'KEY_RESIZE':
                 reset_screen_size()
             elif self.mode.has_input_prompt and key == 'KEY_BACKSPACE':
                 self.input_ = self.input_[:-1]
-            elif self.mode.has_input_prompt and key == '\n' and self.input_ == ''\
-                 and self.mode.name in {'chat', 'command_thing', 'take_thing',
-                                        'drop_thing', 'admin_enter'}:
-                if self.mode.name != 'chat':
+            elif (((not self.mode.is_intro) and keycode == 27)  # Escape
+                  or (self.mode.has_input_prompt and key == '\n'
+                      and self.input_ == ''\
+                      and self.mode.name in {'chat', 'command_thing',
+                                             'take_thing', 'drop_thing',
+                                             'admin_enter'})):
+                if self.mode.name not in {'chat', 'play', 'study', 'edit'}:
                     self.log_msg('@ aborted')
                 self.switch_mode('play')
             elif self.mode.has_input_prompt and key == '\n' and self.input_ == '/help':