diff options
author | Florent Le Coz <louiz@louiz.org> | 2014-08-07 23:20:21 +0200 |
---|---|---|
committer | Florent Le Coz <louiz@louiz.org> | 2014-08-07 23:20:21 +0200 |
commit | 3ef9228211df46ada9bb5b851682a9c7d833de56 (patch) | |
tree | 3bf40a1f43c97577f5cf317c937f55023c0bb186 /src/windows | |
parent | 0e2bba640e1ffcfaa7ce4bc6782f24b0f10b8c08 (diff) | |
download | poezio-3ef9228211df46ada9bb5b851682a9c7d833de56.tar.gz poezio-3ef9228211df46ada9bb5b851682a9c7d833de56.tar.bz2 poezio-3ef9228211df46ada9bb5b851682a9c7d833de56.tar.xz poezio-3ef9228211df46ada9bb5b851682a9c7d833de56.zip |
Continuation keys (like after M-j or Ctrl-c) are handled without blocking
Diffstat (limited to 'src/windows')
-rw-r--r-- | src/windows/input_placeholders.py | 13 | ||||
-rw-r--r-- | src/windows/inputs.py | 12 |
2 files changed, 15 insertions, 10 deletions
diff --git a/src/windows/input_placeholders.py b/src/windows/input_placeholders.py index 6fd7975a..0887cfc5 100644 --- a/src/windows/input_placeholders.py +++ b/src/windows/input_placeholders.py @@ -68,9 +68,12 @@ class YesNoInput(Win): def prompt(self): """Monopolizes the input while waiting for a recognized keypress""" - cl = [] - while self.value is None: - if len(cl) == 1 and cl[0] in self.key_func: - self.key_func[cl[0]]() - cl = self.core.read_keyboard() + def cb(key): + if key in self.key_func: + self.key_func[key]() + if self.value is None: + # We didn’t finish with this prompt, continue monopolizing + # it again until value is set + keyboard.continuation_keys_callback = cb + keyboard.continuation_keys_callback = cb diff --git a/src/windows/inputs.py b/src/windows/inputs.py index ff13a562..afce3dd8 100644 --- a/src/windows/inputs.py +++ b/src/windows/inputs.py @@ -8,6 +8,7 @@ log = logging.getLogger(__name__) import curses import string +import keyboard import common import poopt from . import Win @@ -655,11 +656,12 @@ class MessageInput(HistoryInput): """ Read one more char (c), add the corresponding char from formats_char to the text string """ - attr_char = self.core.read_keyboard()[0] - if attr_char in self.text_attributes: - char = format_chars[self.text_attributes.index(attr_char)] - self.do_command(char, False) - self.rewrite_text() + def cb(attr_char): + if attr_char in self.text_attributes: + char = format_chars[self.text_attributes.index(attr_char)] + self.do_command(char, False) + self.rewrite_text() + keyboard.continuation_keys_callback = cb def key_enter(self): if self.history_enter(): |