X Tutup
Skip to content

Commit 3a1a92b

Browse files
committed
Made all keys configurable
1 parent 2a4bc48 commit 3a1a92b

File tree

2 files changed

+19
-9
lines changed

2 files changed

+19
-9
lines changed

bpython/cli.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1480,15 +1480,15 @@ def p_key(self):
14801480
self.print_line(self.s)
14811481
return ''
14821482

1483-
elif self.c in key_dispatch['C-r']: # C-r
1483+
elif self.c in key_dispatch[OPTS.undo_key]: # C-r
14841484
self.undo()
14851485
return ''
14861486

1487-
elif self.c in ('KEY_UP', ) + key_dispatch['C-p']: # Cursor Up/C-p
1487+
elif self.c in ('KEY_UP', ) + key_dispatch[OPTS.up_one_line_key]: # Cursor Up/C-p
14881488
self.back()
14891489
return ''
14901490

1491-
elif self.c in ('KEY_DOWN', ) + key_dispatch['C-n']: # Cursor Down/C-n
1491+
elif self.c in ('KEY_DOWN', ) + key_dispatch[OPTS.down_one_line_key]: # Cursor Down/C-n
14921492
self.fwd()
14931493
return ''
14941494

@@ -1512,30 +1512,30 @@ def p_key(self):
15121512
# Redraw (as there might have been highlighted parens)
15131513
self.print_line(self.s)
15141514

1515-
elif self.c in key_dispatch['C-k']: # cut to buffer
1515+
elif self.c in key_dispatch[OPTS.cut_to_buffer_key]: # cut to buffer
15161516
self.cut_to_buffer()
15171517
return ''
15181518

1519-
elif self.c in key_dispatch['C-y']: # yank from buffer
1519+
elif self.c in key_dispatch[OPTS.yank_from_buffer_key]: # yank from buffer
15201520
self.yank_from_buffer()
15211521
return ''
15221522

1523-
elif self.c in key_dispatch['C-w']:
1523+
elif self.c in key_dispatch[OPTS.clear_word_key]:
15241524
self.bs_word()
15251525
self.complete()
15261526
return ''
15271527

1528-
elif self.c in key_dispatch['C-u']:
1528+
elif self.c in key_dispatch[OPTS.clear_line_key]:
15291529
self.clrtobol()
15301530
return ''
15311531

1532-
elif self.c in key_dispatch['C-l']:
1532+
elif self.c in key_dispatch[OPTS.clear_screen_key]:
15331533
self.s_hist = [self.s_hist[-1]]
15341534
self.highlighted_paren = None
15351535
self.redraw()
15361536
return ''
15371537

1538-
elif self.c in key_dispatch['C-d']:
1538+
elif self.c in key_dispatch[OPTS.exit_key]:
15391539
if not self.s:
15401540
self.do_exit = True
15411541
return None

bpython/config.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,16 @@ def loadini(struct, configfile):
6161
struct.flush_output = config.safeget('general', 'flush_output', True)
6262
struct.pastebin_key = config.safeget('keyboard', 'pastebin', 'F8')
6363
struct.save_key = config.safeget('keyboard', 'save', 'C-s')
64+
struct.undo_key = config.safeget('keyboard', 'undo', 'C-r')
65+
struct.up_one_line_key = config.safeget('keyboard', 'up_one_line', 'C-p')
66+
struct.down_one_line_key = config.safeget('keyboard', 'down_one_line', 'C-n')
67+
struct.cut_to_buffer_key = config.safeget('keyboard', 'cut_to_buffer', 'C-k')
68+
struct.yank_from_buffer_key = config.safeget('keybard', 'yank_from_buffer', 'C-y')
69+
struct.clear_word_key = config.safeget('keyboard', 'clear_word', 'C-w')
70+
struct.clear_line_key = config.safeget('keyboard', 'clear_line', 'C-u')
71+
struct.clear_screen_key = config.safeget('keyboard', 'clear_screen', 'C-l')
72+
struct.exit_key = config.safeget('keyboard', 'exit', 'C-d')
73+
6474
color_scheme_name = config.safeget('general', 'color_scheme', 'default')
6575

6676
if color_scheme_name == 'default':

0 commit comments

Comments
 (0)
X Tutup