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

Method prompt

bpython/urwid.py:969–998  ·  view source on GitHub ↗
(self, more)

Source from the content-addressed store, hash-verified

967 self.echo("KeyboardInterrupt")
968
969 def prompt(self, more):
970 # Clear current output here, or output resulting from the
971 # current prompt run will end up appended to the edit widget
972 # sitting above this prompt:
973 self.current_output = None
974 # XXX is this the right place?
975 self.rl_history.reset()
976
977 # We need the caption to use unicode as urwid normalizes later
978 # input to be the same type, using ascii as encoding. If the
979 # caption is bytes this breaks typing non-ascii into bpython.
980 if not more:
981 caption = ("prompt", self.ps1)
982 self.stdout_hist += self.ps1
983 else:
984 caption = ("prompt_more", self.ps2)
985 self.stdout_hist += self.ps2
986 self.edit = BPythonEdit(self.config, caption=caption)
987
988 urwid.connect_signal(self.edit, "change", self.on_input_change)
989 urwid.connect_signal(
990 self.edit, "edit-pos-changed", self.on_edit_pos_changed
991 )
992 # Do this after connecting the change signal handler:
993 self.edit.insert_text(4 * self.next_indentation() * " ")
994 self.edits.append(self.edit)
995 self.listbox.body.append(self.edit)
996 self.listbox.set_focus(len(self.listbox.body) - 1)
997 # Hide the tooltip
998 self.frame.body = self.listbox
999
1000 def on_input_change(self, edit, text):
1001 # TODO: we get very confused here if "text" contains newlines,

Callers 4

reevaluateMethod · 0.95
startMethod · 0.95
keyboard_interruptMethod · 0.95
handle_inputMethod · 0.95

Calls 4

BPythonEditClass · 0.85
next_indentationMethod · 0.80
appendMethod · 0.80
resetMethod · 0.45

Tested by

no test coverage detected