Skip to content

Commit 030b2cd

Browse files
use events instead of hardcoded keypress
1 parent 7c89493 commit 030b2cd

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

bpython/curtsies.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def mainloop(config, locals_, banner, interp=None, paste=None, interactive=True)
7777

7878
reload_requests = []
7979
def request_reload(desc):
80-
reload_requests.append(desc)
80+
reload_requests.append(curtsies.events.ReloadEvent([desc]))
8181
refresh_requests = []
8282
def request_refresh():
8383
refresh_requests.append(curtsies.events.RefreshRequestEvent())
@@ -100,9 +100,7 @@ def event_or_refresh(timeout=None):
100100
else:
101101
while True:
102102
if reload_requests:
103-
desc = ' & '.join(set(reload_requests))
104-
del reload_requests[:]
105-
e = '<F6>:' + desc
103+
e = reload_requests.pop()
106104
else:
107105
e = input_generator.send(.2)
108106
if e is not None:

bpython/curtsiesfrontend/repl.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,14 @@ def process_event(self, e):
358358
self.update_completion()
359359
return
360360

361+
elif isinstance(e, events.ReloadEvent) or e in key_dispatch[self.config.reimport_key]:
362+
self.clear_modules_and_reevaluate()
363+
self.update_completion()
364+
if isinstance(e, events.ReloadEvent):
365+
self.status_bar.message('Reloaded at ' + time.strftime('%H:%M:%S') + ' because ' + ' & '.join(e.files_modified) + ' modified')
366+
else:
367+
self.status_bar.message('Reloaded at ' + time.strftime('%H:%M:%S') + ' by user')
368+
361369
elif (e in ("<RIGHT>", '<Ctrl-f>') and self.config.curtsies_right_arrow_completion
362370
and self.cursor_offset == len(self.current_line)):
363371
self.current_line += self.current_suggestion
@@ -423,10 +431,6 @@ def process_event(self, e):
423431
elif e in ("<Shift-TAB>",):
424432
self.on_tab(back=True)
425433
self.rl_history.reset()
426-
elif e in key_dispatch[self.config.reimport_key] or e.startswith('<F6>:'):
427-
self.clear_modules_and_reevaluate()
428-
self.update_completion()
429-
self.status_bar.message('Reloaded ' + e[5:] + ' at '+time.strftime('%H:%M:%S'))
430434
elif e in key_dispatch[self.config.undo_key]: #ctrl-r for undo
431435
self.undo()
432436
self.update_completion()

0 commit comments

Comments
 (0)