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

Method process_event

bpython/curtsiesfrontend/interaction.py:81–113  ·  view source on GitHub ↗

Returns True if shutting down

(self, e)

Source from the content-addressed store, hash-verified

79 self._message = ""
80
81 def process_event(self, e) -> None:
82 """Returns True if shutting down"""
83 assert self.in_prompt or self.in_confirm or self.waiting_for_refresh
84 if isinstance(e, RefreshRequestEvent):
85 self.waiting_for_refresh = False
86 self.request_context.switch()
87 elif isinstance(e, events.PasteEvent):
88 for ee in e.events:
89 # strip control seq
90 self.add_normal_character(ee if len(ee) == 1 else ee[-1])
91 elif e == "<ESC>" or isinstance(e, events.SigIntEvent):
92 self.request_context.switch(False)
93 self.escape()
94 elif e in edit_keys:
95 self.cursor_offset_in_line, self._current_line = edit_keys[e](
96 self.cursor_offset_in_line, self._current_line
97 )
98 elif e == "<Ctrl-c>": # TODO can this be removed?
99 raise KeyboardInterrupt()
100 elif e == "<Ctrl-d>": # TODO this isn't a very intuitive behavior
101 raise SystemExit()
102 elif self.in_prompt and e in ("\n", "\r", "<Ctrl-j>", "Ctrl-m>"):
103 line = self._current_line
104 self.escape()
105 self.request_context.switch(line)
106 elif self.in_confirm:
107 if e.lower() == _("y"):
108 self.request_context.switch(True)
109 else:
110 self.request_context.switch(False)
111 self.escape()
112 else: # add normal character
113 self.add_normal_character(e)
114
115 def add_normal_character(self, e):
116 if e == "<SPACE>":

Callers

nothing calls this directly

Calls 3

add_normal_characterMethod · 0.95
escapeMethod · 0.95
_Function · 0.90

Tested by

no test coverage detected