@@ -235,24 +235,16 @@ def get_key(self, window):
235
235
# TODO: Check issue #163
236
236
return window .getch ()
237
237
238
- def __catch_key (self , return_to_browser = False ):
239
- # Catch the pressed key
240
- self .pressedkey = self .get_key (self .term_window )
241
- if self .pressedkey == - 1 :
242
- return - 1
243
-
244
- # Actions (available in the global hotkey dict)...
245
- logger .debug (f"Keypressed (code: { self .pressedkey } )" )
246
- for hotkey in self ._hotkeys :
247
- if self .pressedkey == ord (hotkey ) and 'switch' in self ._hotkeys [hotkey ]:
248
- self ._handle_switch (hotkey )
249
- elif self .pressedkey == ord (hotkey ) and 'sort_key' in self ._hotkeys [hotkey ]:
250
- self ._handle_sort_key (hotkey )
251
- if self .pressedkey == ord (hotkey ) and 'handler' in self ._hotkeys [hotkey ]:
252
- action = getattr (self , self ._hotkeys [hotkey ]['handler' ])
253
- action ()
254
-
255
- # Other actions with key > 255 (ord will not work) and/or additional test...
238
+ def catch_actions_from_hotkey (self , hotkey ):
239
+ if self .pressedkey == ord (hotkey ) and 'switch' in self ._hotkeys [hotkey ]:
240
+ self ._handle_switch (hotkey )
241
+ elif self .pressedkey == ord (hotkey ) and 'sort_key' in self ._hotkeys [hotkey ]:
242
+ self ._handle_sort_key (hotkey )
243
+ if self .pressedkey == ord (hotkey ) and 'handler' in self ._hotkeys [hotkey ]:
244
+ action = getattr (self , self ._hotkeys [hotkey ]['handler' ])
245
+ action ()
246
+
247
+ def catch_other_actions_maybe_return_to_browser (self , return_to_browser ):
256
248
if self .pressedkey == ord ('e' ) and not self .args .programs :
257
249
self ._handle_process_extended ()
258
250
elif self .pressedkey == ord ('k' ) and not self .args .disable_cursor :
@@ -270,6 +262,19 @@ def __catch_key(self, return_to_browser=False):
270
262
elif self .pressedkey == curses .KEY_F5 or self .pressedkey == 18 :
271
263
self ._handle_refresh ()
272
264
265
+ def __catch_key (self , return_to_browser = False ):
266
+ # Catch the pressed key
267
+ self .pressedkey = self .get_key (self .term_window )
268
+ if self .pressedkey == - 1 :
269
+ return self .pressedkey
270
+
271
+ # Actions (available in the global hotkey dict)...
272
+ logger .debug (f"Keypressed (code: { self .pressedkey } )" )
273
+ [self .catch_actions_from_hotkey (hotkey ) for hotkey in self ._hotkeys ]
274
+
275
+ # Other actions with key > 255 (ord will not work) and/or additional test...
276
+ self .catch_other_actions_maybe_return_to_browser (return_to_browser )
277
+
273
278
# Return the key code
274
279
return self .pressedkey
275
280
0 commit comments