Prevent special keys to appear in the input when lagging

This commit is contained in:
mathieui 2012-09-27 19:48:28 +02:00
parent 020e6478e3
commit e480d8418a

View file

@ -354,14 +354,19 @@ class Core(object):
""" """
main loop waiting for the user to press a key main loop waiting for the user to press a key
""" """
def sanitize_input(key):
if key == '^J':
return '\n'
elif key == '^I':
return ' '
elif len(key) > 1:
return ''
return key
def replace_line_breaks(key): def replace_line_breaks(key):
if key == '^J': if key == '^J':
return '\n' return '\n'
return key return key
def replace_tabulation(key):
if key == '^I':
return ' '
return key
while self.running: while self.running:
if self.paused: continue if self.paused: continue
char_list = [common.replace_key_with_bound(key)\ char_list = [common.replace_key_with_bound(key)\
@ -393,7 +398,7 @@ class Core(object):
self.refresh_window() self.refresh_window()
else: else:
self.do_command(''.join(map( self.do_command(''.join(map(
lambda x: replace_line_breaks(replace_tabulation(x)), lambda x: sanitize_input(x),
char_list) char_list)
), True) ), True)
self.refresh_window() self.refresh_window()