Skip to content

Commit a8136bb

Browse files
susinmotionthomasballinger
authored andcommitted
rewinding some of our changes.
1 parent f721c1d commit a8136bb

File tree

2 files changed

+25
-14
lines changed

2 files changed

+25
-14
lines changed

bpython/curtsies.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ def main(args=None, locals_=None, banner=None):
3333
]))
3434
if options.log:
3535
handler = logging.FileHandler(filename='bpython.log')
36-
logging.getLogger('curtsies').setLevel(logging.DEBUG)
36+
logging.getLogger('curtsies').setLevel(logging.WARNING)
3737
logging.getLogger('curtsies').addHandler(handler)
3838
logging.getLogger('curtsies').propagate = False
39-
logging.getLogger('bpython').setLevel(logging.DEBUG)
39+
logging.getLogger('bpython').setLevel(logging.WARNING)
4040
logging.getLogger('bpython').addHandler(handler)
4141
logging.getLogger('bpython').propagate = False
4242
else:

bpython/curtsiesfrontend/repl.py

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,15 +1021,23 @@ def paint(self, about_to_exit=False, user_quit=False):
10211021
else:
10221022
arr = FSArray(0, width)
10231023
#TODO test case of current line filling up the whole screen (there aren't enough rows to show it)
1024-
if self.inconsistent_history == True:
1025-
msg = "#<---History inconsistent with output shown--->"
1026-
arr[0, 0:min(len(msg), width)] = [msg[:width]]
1027-
self.inconsistent_history = False
1028-
"""FIX THE THING This if may need to go after the second one, but the while applies to both"""
1029-
if current_line_start_row < 0: #if current line trying to be drawn off the top of the screen
1030-
logger.debug('#<---History contiguity broken by rewind--->')
1031-
msg = "#<---History contiguity broken by rewind--->"
1032-
arr[0, 0:min(len(msg), width)] = [msg[:width]]
1024+
if self.inconsistent_history == False & current_line_start_row >= 0:
1025+
history = paint.paint_history(current_line_start_row, width, self.lines_for_display)
1026+
arr[:history.height,:history.width] = history
1027+
1028+
else:
1029+
if self.inconsistent_history == True:
1030+
logger.debug("#<---History inconsistent with output shown--->")
1031+
msg = "#<---History inconsistent with output shown--->"
1032+
arr[0, 0:min(len(msg), width)] = [msg[:width]]
1033+
self.inconsistent_history = False
1034+
# self.scroll_offset -= 1
1035+
current_line_start_row = len(self.lines_for_display )- max(-1, self.scroll_offset)
1036+
1037+
if current_line_start_row < 0: #if current line trying to be drawn off the top of the screen
1038+
logger.debug('#<---History contiguity broken by rewind--->')
1039+
msg = "#<---History contiguity broken by rewind--->"
1040+
arr[0, 0:min(len(msg), width)] = [msg[:width]]
10331041

10341042
# move screen back up a screen minus a line
10351043
while current_line_start_row < 0:
@@ -1041,9 +1049,7 @@ def paint(self, about_to_exit=False, user_quit=False):
10411049

10421050
if arr.height <= min_height:
10431051
arr[min_height, 0] = ' ' # force scroll down to hide broken history message
1044-
else:
1045-
history = paint.paint_history(current_line_start_row, width, self.lines_for_display)
1046-
arr[:history.height,:history.width] = history
1052+
10471053

10481054
current_line = paint.paint_current_line(min_height, width, self.current_cursor_line)
10491055
if user_quit: # quit() or exit() in interp
@@ -1252,7 +1258,12 @@ def reevaluate(self, insert_into_history=False):
12521258
self.reevaluating = False
12531259
num_lines_onscreen=len(self.lines_for_display)-max(0, self.scroll_offset)
12541260
if old_display_lines[:len(self.display_lines)-num_lines_onscreen]!=self.display_lines:
1261+
old_display_lines_offscreen=old_display_lines[:len(self.display_lines)-num_lines_onscreen]
1262+
display_lines_offscreen=self.display_lines[:-num_lines_onscreen]
1263+
1264+
if old_display_lines_offscreen!=display_lines_offscreen:
12551265
self.inconsistent_history = True
1266+
self.scroll_offset=self.scroll_offset-max(-1,(len(old_display_lines_offscreen)-len(display_lines_offscreen)+1))
12561267
self.cursor_offset = 0
12571268
self.current_line = ''
12581269

0 commit comments

Comments
 (0)