From e480d8418ab396bddabebca1802c9bcf443e07b4 Mon Sep 17 00:00:00 2001 From: mathieui Date: Thu, 27 Sep 2012 19:48:28 +0200 Subject: Prevent special keys to appear in the input when lagging --- src/core.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/core.py b/src/core.py index f3a0046e..2accb4c4 100644 --- a/src/core.py +++ b/src/core.py @@ -354,14 +354,19 @@ class Core(object): """ main loop waiting for the user to press a key """ - def replace_line_breaks(key): + def sanitize_input(key): if key == '^J': return '\n' - return key - def replace_tabulation(key): - if key == '^I': + elif key == '^I': return ' ' + elif len(key) > 1: + return '' return key + def replace_line_breaks(key): + if key == '^J': + return '\n' + return key + while self.running: if self.paused: continue char_list = [common.replace_key_with_bound(key)\ @@ -393,7 +398,7 @@ class Core(object): self.refresh_window() else: self.do_command(''.join(map( - lambda x: replace_line_breaks(replace_tabulation(x)), + lambda x: sanitize_input(x), char_list) ), True) self.refresh_window() -- cgit v1.2.3