|
21 | 21 | from fmtstr.fmtstr import fmtstr, FmtStr |
22 | 22 | from fmtstr.bpythonparse import parse as bpythonparse |
23 | 23 | from fmtstr.bpythonparse import func_for_letter, color_for_letter |
24 | | -from fmtstr.events import pp_event, SigIntEvent |
25 | 24 |
|
26 | 25 | from bpython.scrollfrontend.manual_readline import char_sequences as rl_char_sequences |
27 | 26 | from bpython.scrollfrontend.manual_readline import get_updated_char_sequences |
@@ -201,6 +200,7 @@ def process_event(self, e): |
201 | 200 | if isinstance(e, events.SigIntEvent): |
202 | 201 | logging.debug('received sigint event') |
203 | 202 | self.keyboard_interrupt() |
| 203 | + self.update_completion() |
204 | 204 | return |
205 | 205 | if isinstance(e, events.WindowChangeEvent): |
206 | 206 | logging.debug('window change to %d %d', e.width, e.height) |
@@ -454,8 +454,16 @@ def run_code_and_maybe_finish(self, for_code=None): |
454 | 454 | self.done = not unfinished |
455 | 455 |
|
456 | 456 | def keyboard_interrupt(self): |
| 457 | + #TODO factor out the common cleanup from running a line |
| 458 | + #TODO make rewind work properly with ctrl-c somehow |
| 459 | + self.cursor_offset_in_line = -1 |
| 460 | + self.unhighlight_paren() |
| 461 | + self.display_lines.extend(self.display_buffer_lines) |
457 | 462 | self.display_lines.extend(paint.display_linize(self.current_cursor_line, self.width)) |
458 | 463 | self.display_lines.extend(paint.display_linize("KeyboardInterrupt", self.width)) |
| 464 | + self.display_buffer = [] |
| 465 | + self.buffer = [] |
| 466 | + self.cursor_offset_in_line = 0 |
459 | 467 | self.saved_indent = 0 |
460 | 468 | self._current_line = '' |
461 | 469 | self.cursor_offset_in_line = len(self._current_line) |
@@ -641,7 +649,7 @@ def paint(self, about_to_exit=False): |
641 | 649 | if self.presentation_mode: |
642 | 650 | rows = arr.height |
643 | 651 | columns = arr.width |
644 | | - last_key_box = paint.paint_last_events(rows, columns, [pp_event(x) for x in self.last_events if x]) |
| 652 | + last_key_box = paint.paint_last_events(rows, columns, [events.pp_event(x) for x in self.last_events if x]) |
645 | 653 | arr[arr.height-last_key_box.height:arr.height, arr.width-last_key_box.width:arr.width] = last_key_box |
646 | 654 | else: |
647 | 655 | statusbar_row = min_height + 1 if arr.height == min_height else arr.height |
|
0 commit comments