Skip to content

Commit eb94d34

Browse files
split up process_event
1 parent cb74f11 commit eb94d34

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

bpython/curtsiesfrontend/repl.py

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -372,14 +372,18 @@ def clean_up_current_line_for_exit(self):
372372
def process_event(self, e):
373373
"""Returns True if shutting down, otherwise returns None.
374374
Mostly mutates state of Repl object"""
375-
# event names uses here are curses compatible, or the full names
376-
# for a full list of what should have pretty names, see curtsies.events.CURSES_TABLE
375+
# for a full list of what should have pretty names, try python -m curtsies.events
377376

378-
if not isinstance(e, events.Event):
377+
logger.debug("processing event %r", e)
378+
if isinstance(e, events.Event):
379+
return self.proccess_control_event(e)
380+
else:
379381
self.last_events.append(e)
380382
self.last_events.pop(0)
383+
return self.process_key_event(e)
384+
385+
def proccess_control_event(self, e):
381386

382-
logger.debug("processing event %r", e)
383387
if isinstance(e, events.RefreshRequestEvent):
384388
if e.when != 'now':
385389
pass # This is a scheduled refresh - it's really just a refresh (so nop)
@@ -388,6 +392,7 @@ def process_event(self, e):
388392
else:
389393
assert self.coderunner.code_is_waiting
390394
self.run_code_and_maybe_finish()
395+
391396
elif self.status_bar.has_focus:
392397
return self.status_bar.process_event(e)
393398

@@ -419,6 +424,17 @@ def process_event(self, e):
419424
self.update_completion()
420425
self.status_bar.message('Reloaded at ' + time.strftime('%H:%M:%S') + ' because ' + ' & '.join(e.files_modified) + ' modified')
421426

427+
else:
428+
raise ValueError("don't know how to handle this event type: %r" % e)
429+
430+
def process_key_event(self, e):
431+
432+
if self.status_bar.has_focus:
433+
return self.status_bar.process_event(e)
434+
435+
elif self.stdin.has_focus:
436+
return self.stdin.process_event(e)
437+
422438
elif e in key_dispatch[self.config.toggle_file_watch_key]:
423439
if self.watcher:
424440
msg = "Auto-reloading active, watching for file changes..."

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy