MCPcopy Index your code
hub / github.com/RustPython/RustPython / handle1

Method handle1

Lib/_pyrepl/reader.py:745–786  ·  view source on GitHub ↗

Handle a single event. Wait as long as it takes if block is true (the default), otherwise return False if no event is pending.

(self, block: bool = True)

Source from the content-addressed store, hash-verified

743 pass
744
745 def handle1(self, block: bool = True) -> bool:
746 """Handle a single event. Wait as long as it takes if block
747 is true (the default), otherwise return False if no event is
748 pending."""
749
750 if self.msg:
751 self.msg = ""
752 self.dirty = True
753
754 while True:
755 # We use the same timeout as in readline.c: 100ms
756 self.run_hooks()
757 self.console.wait(100)
758 event = self.console.get_event(block=False)
759 if not event:
760 if block:
761 continue
762 return False
763
764 translate = True
765
766 if event.evt == "key":
767 self.input_trans.push(event)
768 elif event.evt == "scroll":
769 self.refresh()
770 elif event.evt == "resize":
771 self.refresh()
772 else:
773 translate = False
774
775 if translate:
776 cmd = self.input_trans.get()
777 else:
778 cmd = [event.evt, event.data]
779
780 if cmd is None:
781 if block:
782 continue
783 return False
784
785 self.do_cmd(cmd)
786 return True
787
788 def push_char(self, char: int | bytes) -> None:
789 self.console.push_char(char)

Callers 2

push_charMethod · 0.95
readlineMethod · 0.95

Calls 7

run_hooksMethod · 0.95
refreshMethod · 0.95
do_cmdMethod · 0.95
waitMethod · 0.45
get_eventMethod · 0.45
pushMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected