File tree Expand file tree Collapse file tree 2 files changed +6
-10
lines changed
Expand file tree Collapse file tree 2 files changed +6
-10
lines changed Original file line number Diff line number Diff line change 2626
2727class KeyMap :
2828
29- def __init__ (self ):
29+ def __init__ (self , default = '' ):
3030 self .map = {}
31+ self .default = default
3132
3233 def __getitem__ (self , key ):
3334 if not key :
3435 # Unbound key
35- return str ()
36+ return self . default
3637 elif key in self .map :
3738 return self .map [key ]
3839 else :
@@ -45,8 +46,8 @@ def __delitem__(self, key):
4546 def __setitem__ (self , key , value ):
4647 self .map [key ] = value
4748
48- cli_key_dispatch = KeyMap ()
49- urwid_key_dispatch = KeyMap ()
49+ cli_key_dispatch = KeyMap (tuple () )
50+ urwid_key_dispatch = KeyMap ('' )
5051
5152# fill dispatch with letters
5253for c in string .ascii_lowercase :
Original file line number Diff line number Diff line change @@ -307,11 +307,6 @@ def add_normal_character(self, char):
307307 def process_event (self , e ):
308308 """Returns True if shutting down, otherwise mutates state of Repl object"""
309309
310- # shim for weird key_dispatch #TODO patch bpython
311- def tint (x ):
312- """Tuple if not tuple - returns one-item tuple if x isn't a tuple"""
313- return x if isinstance (x , tuple ) else tuple (x )
314-
315310 #logging.debug("processing event %r", e)
316311 if isinstance (e , events .WindowChangeEvent ):
317312 logging .debug ('window change to %d %d' , e .width , e .height )
@@ -356,7 +351,7 @@ def tint(x):
356351 raise SystemExit ()
357352 elif e == "" :
358353 raise KeyboardInterrupt ()
359- elif e in ("" ,) + tint ( key_dispatch [self .config .exit_key ]) :
354+ elif e in ("" ,) + key_dispatch [self .config .exit_key ]:
360355 raise SystemExit ()
361356 elif e in ("\n " , "\r " , "PAD_ENTER" ):
362357 self .on_enter ()
You can’t perform that action at this time.
0 commit comments