X Tutup
Skip to content

Commit ffcea04

Browse files
resizing working much better, copying out code nicer too
1 parent 7c1f889 commit ffcea04

File tree

2 files changed

+5
-16
lines changed

2 files changed

+5
-16
lines changed

bpython/curtsies.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,13 @@ def process_event(e):
6868
repl.process_event(e)
6969
except (SystemExitFromCodeGreenlet, SystemExit) as err:
7070
array, cursor_pos = repl.paint(about_to_exit=True, user_quit=isinstance(err, SystemExitFromCodeGreenlet))
71-
term.render_to_terminal(array, cursor_pos)
71+
scrolled = term.render_to_terminal(array, cursor_pos)
72+
repl.scroll_offset += scrolled
7273
raise
7374
else:
7475
array, cursor_pos = repl.paint()
75-
term.render_to_terminal(array, cursor_pos)
76+
scrolled = term.render_to_terminal(array, cursor_pos)
77+
repl.scroll_offset += scrolled
7678

7779
if paste:
7880
repl.process_event(term.get_annotated_event()) #first event will always be a window size set

bpython/curtsiesfrontend/repl.py

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,6 @@ def process_event(self, e):
263263
self.run_code_and_maybe_finish()
264264
elif isinstance(e, events.WindowChangeEvent):
265265
logging.debug('window change to %d %d', e.width, e.height)
266-
#TODO when window gets larger, history is eaten up
267266
self.scroll_offset -= e.cursor_dy
268267
self.width, self.height = e.width, e.height
269268

@@ -554,7 +553,7 @@ def unhighlight_paren(self):
554553
logging.debug('trying to unhighlight a paren on line %r', lineno)
555554
logging.debug('with these tokens: %r', saved_tokens)
556555
new = bpythonparse(format(saved_tokens, self.formatter))
557-
self.display_buffer[lineno] = self.display_buffer[lineno].setslice(0, len(new), new)
556+
self.display_buffer[lineno] = self.display_buffer[lineno].setslice_with_length(0, len(new), new, len(self.display_buffer[lineno]))
558557

559558
def clear_current_block(self, remove_from_history=True):
560559
self.display_buffer = []
@@ -691,17 +690,6 @@ def current_output_line(self, value):
691690
def paint(self, about_to_exit=False, user_quit=False):
692691
"""Returns an array of min_height or more rows and width columns, plus cursor position
693692
694-
Also increments self.scroll_offset by the amount the terminal must have scrolled
695-
to display the entire array.
696-
"""
697-
arr, (row, col) = self._paint(about_to_exit=about_to_exit, user_quit=user_quit)
698-
if arr.height > self.height:
699-
self.scroll_offset += arr.height - self.height
700-
return arr, (row, col)
701-
702-
def _paint(self, about_to_exit=False, user_quit=False):
703-
"""Returns an array of min_height or more rows and width columns, plus cursor position
704-
705693
Paints the entire screen - ideally the terminal display layer will take a diff and only
706694
write to the screen in portions that have changed, but the idea is that we don't need
707695
to worry about that here, instead every frame is completely redrawn because
@@ -717,7 +705,6 @@ def _paint(self, about_to_exit=False, user_quit=False):
717705
if show_status_bar:
718706
min_height -= 1
719707

720-
721708
current_line_start_row = len(self.lines_for_display) - max(0, self.scroll_offset)
722709
if self.request_paint_to_clear_screen: # or show_status_bar and about_to_exit ?
723710
self.request_paint_to_clear_screen = False

0 commit comments

Comments
 (0)
X Tutup