MCPcopy Index your code
hub / github.com/bpython/bpython / process_control_event

Method process_control_event

bpython/curtsiesfrontend/repl.py:648–718  ·  view source on GitHub ↗
(self, e: events.Event)

Source from the content-addressed store, hash-verified

646 return None
647
648 def process_control_event(self, e: events.Event) -> bool | None:
649 if isinstance(e, bpythonevents.ScheduledRefreshRequestEvent):
650 # This is a scheduled refresh - it's really just a refresh (so nop)
651 pass
652
653 elif isinstance(e, bpythonevents.RefreshRequestEvent):
654 logger.info("received ASAP refresh request event")
655 if self.status_bar.has_focus:
656 self.status_bar.process_event(e)
657 else:
658 assert self.coderunner.code_is_waiting
659 self.run_code_and_maybe_finish()
660
661 elif self.status_bar.has_focus:
662 self.status_bar.process_event(e)
663
664 # handles paste events for both stdin and repl
665 elif isinstance(e, events.PasteEvent):
666 ctrl_char = compress_paste_event(e)
667 if ctrl_char is not None:
668 return self.process_event(ctrl_char)
669 with self.in_paste_mode():
670 # Might not really be a paste, UI might just be lagging
671 if len(e.events) <= MAX_EVENTS_POSSIBLY_NOT_PASTE and any(
672 not is_simple_event(ee) for ee in e.events
673 ):
674 for ee in e.events:
675 if self.stdin.has_focus:
676 self.stdin.process_event(ee)
677 else:
678 self.process_event(ee)
679 else:
680 simple_events = just_simple_events(e.events)
681 source = preprocess(
682 "".join(simple_events), self.interp.compile
683 )
684 for ee in source:
685 if self.stdin.has_focus:
686 self.stdin.process_event(ee)
687 else:
688 self.process_simple_keypress(ee)
689
690 elif isinstance(e, bpythonevents.RunStartupFileEvent):
691 try:
692 self.startup()
693 except OSError as err:
694 self.status_bar.message(
695 _("Executing PYTHONSTARTUP failed: %s") % (err,)
696 )
697
698 elif isinstance(e, bpythonevents.UndoEvent):
699 self.undo(n=e.n)
700
701 elif self.stdin.has_focus:
702 self.stdin.process_event(e)
703
704 elif isinstance(e, events.SigIntEvent):
705 logger.debug("received sigint event")

Callers 1

process_eventMethod · 0.95

Calls 14

process_eventMethod · 0.95
in_paste_modeMethod · 0.95
keyboard_interruptMethod · 0.95
preprocessFunction · 0.90
_Function · 0.90
compress_paste_eventFunction · 0.85
is_simple_eventFunction · 0.85
just_simple_eventsFunction · 0.85
startupMethod · 0.80

Tested by

no test coverage detected