(self, more)
| 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, |
no test coverage detected