diff options
author | hut <hut@lavabit.com> | 2010-04-07 19:42:45 +0200 |
---|---|---|
committer | hut <hut@lavabit.com> | 2010-04-07 19:42:45 +0200 |
commit | be7c282c2d73472254946f5043bf835f6bbb038a (patch) | |
tree | 6862f682b6fdddd5b104e0b127735f56307cf1cb /ranger | |
parent | 7626fd1d08ccb597ef25eaebf37ffc7be33c6df2 (diff) | |
download | ranger-be7c282c2d73472254946f5043bf835f6bbb038a.tar.gz |
gui.ui: improvements in handling of special keys
Diffstat (limited to 'ranger')
-rw-r--r-- | ranger/core/fm.py | 6 | ||||
-rw-r--r-- | ranger/gui/ui.py | 22 |
2 files changed, 24 insertions, 4 deletions
diff --git a/ranger/core/fm.py b/ranger/core/fm.py index a408139a..ae815fbf 100644 --- a/ranger/core/fm.py +++ b/ranger/core/fm.py @@ -19,7 +19,6 @@ The File Manager, putting the pieces together from time import time from collections import deque -from curses import KEY_MOUSE, KEY_RESIZE import os import sys @@ -105,6 +104,11 @@ class FM(Actions, SignalDispatcher): self.input_blocked = sec != 0 self.input_blocked_until = time() + sec + def input_is_blocked(self): + if self.input_blocked and time() > self.input_blocked_until: + self.input_blocked = False + return self.input_blocked + def loop(self): """ The main loop consists of: diff --git a/ranger/gui/ui.py b/ranger/gui/ui.py index c1a4bb60..8d355665 100644 --- a/ranger/gui/ui.py +++ b/ranger/gui/ui.py @@ -127,6 +127,10 @@ class UI(DisplayableContainer): if hasattr(self, 'hint'): self.hint() + if key < 0: + self.env.keybuffer.clear() + return + self.env.key_append(key) if DisplayableContainer.press(self, key): @@ -157,22 +161,34 @@ class UI(DisplayableContainer): def handle_input(self): key = self.win.getch() - if key in (27, 195): # 27: alt+X, 195: unicode + if key is 27 or key >= 128 and key < 256: + # Handle special keys like ALT+X or unicode here: keys = [key] previous_load_mode = self.load_mode self.set_load_mode(True) - for n in range(8): + for n in range(4): getkey = self.win.getch() if getkey is not -1: keys.append(getkey) + if len(keys) == 1: + keys.append(-1) for key in keys: self.handle_key(key) self.set_load_mode(previous_load_mode) + if self.settings.flushinput: + curses.flushinp() else: + # Handle simple key presses, CTRL+X, etc here: if self.settings.flushinput: curses.flushinp() if key > 0: - self.handle_key(key) + if key == curses.KEY_MOUSE: + self.handle_mouse() + elif key == curses.KEY_RESIZE: + self.update_size() + else: + if not self.fm.input_is_blocked(): + self.handle_key(key) def setup(self): """ |