summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--ranger/__main__.py4
-rw-r--r--ranger/fm.py4
-rw-r--r--ranger/gui/ui.py3
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):