summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2010-01-11 21:41:26 +0100
committerhut <hut@lavabit.com>2010-01-11 21:41:26 +0100
commit6369406e64208b69a8847aef3b196640bdfc7190 (patch)
tree7b4cecb047d5c9cc7a6092da29cfc79ae36a6c4a
parenta82cc0eef46a063883347a9f0e1ab787d13f0853 (diff)
downloadranger-6369406e64208b69a8847aef3b196640bdfc7190.tar.gz
main: change interrupt handler to curses.ungetch(CTRL_C)
-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):
title='author Silvino Silva <silvino@bk.ru> 2018-04-03 02:28:13 +0100 committer Silvino Silva <silvino@bk.ru> 2018-04-03 02:28:13 +0100 tools iptables revision' href='/punk/doc/commit/tools/conf/etc/iptables/vlan.v4?id=b55489fd9dae3be02ae166051dc7e5adabb52166'>b55489f ^
5eeb7b4 ^
b55489f ^

5eeb7b4 ^
6516727 ^

5eeb7b4 ^
b55489f ^

5eeb7b4 ^

6516727 ^
5eeb7b4 ^
b55489f ^


































































































5eeb7b4 ^
b55489f ^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136