diff options
author | hut <hut@lavabit.com> | 2010-01-11 21:41:26 +0100 |
---|---|---|
committer | hut <hut@lavabit.com> | 2010-01-11 21:41:26 +0100 |
commit | 6369406e64208b69a8847aef3b196640bdfc7190 (patch) | |
tree | 7b4cecb047d5c9cc7a6092da29cfc79ae36a6c4a /ranger | |
parent | a82cc0eef46a063883347a9f0e1ab787d13f0853 (diff) | |
download | ranger-6369406e64208b69a8847aef3b196640bdfc7190.tar.gz |
main: change interrupt handler to curses.ungetch(CTRL_C)
Diffstat (limited to 'ranger')
-rw-r--r-- | ranger/__main__.py | 4 | ||||
-rw-r--r-- | ranger/fm.py | 4 | ||||
-rw-r--r-- | ranger/gui/ui.py | 3 |
3 files changed, 8 insertions, 3 deletions
diff --git a/ranger/__main__.py b/ranger/__main__.py index 9f46ac5a..892fc87e 100644 --- a/ranger/__main__.py +++ b/ranger/__main__.py @@ -17,6 +17,7 @@ import os import sys +from signal import signal, SIGINT def main(): """initialize objects and run the filemanager""" @@ -39,6 +40,9 @@ def main(): setlocale(LC_ALL, 'en_US.utf8') os.stat_float_times(True) + # push a Ctrl+C (ascii value 3) if a keyboard-interrupt occurs + # instead of raising KeyboardInterrupt and possibly breaking stuff + signal(SIGINT, lambda *_: curses.ungetch(3)) if not os.path.exists(CONFDIR): os.mkdir(CONFDIR) diff --git a/ranger/fm.py b/ranger/fm.py index 9bc7ee1b..df2cb15f 100644 --- a/ranger/fm.py +++ b/ranger/fm.py @@ -111,8 +111,8 @@ class FM(Actions): gc_tick = 0 self.env.garbage_collect() - except KeyboardInterrupt: - self.ui.handle_key(CTRL_C) + finally: + pass finally: self.bookmarks.remember(self.env.pwd) self.bookmarks.save() diff --git a/ranger/gui/ui.py b/ranger/gui/ui.py index 7b05db4f..771f0b2a 100644 --- a/ranger/gui/ui.py +++ b/ranger/gui/ui.py @@ -144,7 +144,8 @@ class UI(DisplayableContainer): def get_next_key(self): """Waits for key input and returns the pressed key""" key = self.win.getch() - curses.flushinp() + if key is not -1: + curses.flushinp() return key def setup(self): |