X Tutup
Skip to content

Commit ecc3fb5

Browse files
fix unhighlight paren bug
--HG-- branch : scroll-frontend
1 parent 5fb01ad commit ecc3fb5

File tree

1 file changed

+26
-17
lines changed

1 file changed

+26
-17
lines changed

bpython/scrollfrontend/repl.py

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ def __init__(self):
176176

177177
self.paste_mode = False
178178
self.request_paint_to_clear_screen = False
179-
self.last_events = [None] * 20
179+
self.last_events = [None] * 50
180180
self.presentation_mode = False
181181

182182
self.width = None # will both be set by a window resize event
@@ -305,6 +305,7 @@ def process_event(self, e):
305305
def on_enter(self, insert_into_history=True):
306306
self.cursor_offset_in_line = -1 # so the cursor isn't touching a paren
307307
self.unhighlight_paren() # in unhighlight_paren
308+
self.highlighted_paren = None
308309

309310
self.rl_history.append(self._current_line)
310311
self.rl_history.last()
@@ -466,7 +467,10 @@ def runsource(self, line):
466467
logging.debug('sent output info')
467468

468469
def unhighlight_paren(self):
469-
"""modify line in self.display_buffer to unhighlight a paren if possible"""
470+
"""modify line in self.display_buffer to unhighlight a paren if possible
471+
472+
self.highlighted_paren should be a line in ?
473+
"""
470474
if self.highlighted_paren is not None and self.config.syntax:
471475
lineno, saved_tokens = self.highlighted_paren
472476
if lineno == len(self.display_buffer):
@@ -487,7 +491,8 @@ def current_line_formatted(self):
487491
else:
488492
fs = fmtstr(self._current_line)
489493
if hasattr(self, 'old_fs') and str(fs) != str(self.old_fs):
490-
logging.debug('calculating current formatted line: %r', repr(fs))
494+
pass
495+
#logging.debug('calculating current formatted line: %r', repr(fs))
491496
self.old_fs = fs
492497
return fs
493498

@@ -521,6 +526,7 @@ def current_word(self, value):
521526

522527
@property
523528
def display_buffer_lines(self):
529+
"""The lines build from the display buffer"""
524530
lines = []
525531
for display_line in self.display_buffer:
526532
display_line = (func_for_letter(self.config.color_scheme['prompt_more'])(self.ps2)
@@ -554,7 +560,7 @@ def paint(self, about_to_exit=False):
554560
min_height -= 1
555561

556562
current_line_start_row = len(self.lines_for_display) - max(0, self.scroll_offset)
557-
if self.request_paint_to_clear_screen:
563+
if self.request_paint_to_clear_screen: # or show_status_bar and about_to_exit ?
558564
self.request_paint_to_clear_screen = False
559565
arr = FSArray(self.height - 1 + current_line_start_row, width)
560566
else:
@@ -605,19 +611,22 @@ def paint(self, about_to_exit=False):
605611
arr[current_line_start_row - infobox.height:current_line_start_row, 0:infobox.width] = infobox
606612
else:
607613
arr[cursor_row + 1:cursor_row + 1 + infobox.height, 0:infobox.width] = infobox
608-
logging.debug('slamming infobox of shape %r into arr', infobox.shape)
609-
610-
if show_status_bar and not about_to_exit:
611-
arr[max(arr.height, min_height), :] = paint.paint_statusbar(1, width, self.status_bar.current_line, self.config)
612-
613-
if self.presentation_mode:
614-
logging.debug('last key box code running')
615-
rows = arr.height - 4
616-
columns = arr.width
617-
last_key_box = paint.paint_last_events(rows, columns, [pp_event(x) for x in self.last_events if x])
618-
arr[arr.height-last_key_box.height:arr.height, arr.width-last_key_box.width:arr.width] = last_key_box
619-
logging.debug(last_key_box[:])
620-
logging.debug(arr[:])
614+
#logging.debug('slamming infobox of shape %r into arr', infobox.shape)
615+
616+
logging.debug('about to exit: %r', about_to_exit)
617+
if show_status_bar:
618+
if about_to_exit:
619+
arr[max(arr.height, min_height), :] = FSArray(1, width)
620+
else:
621+
arr[max(arr.height, min_height), :] = paint.paint_statusbar(1, width, self.status_bar.current_line, self.config)
622+
623+
if self.presentation_mode:
624+
rows = arr.height
625+
columns = arr.width
626+
last_key_box = paint.paint_last_events(rows, columns, [pp_event(x) for x in self.last_events if x])
627+
arr[arr.height-last_key_box.height:arr.height, arr.width-last_key_box.width:arr.width] = last_key_box
628+
#logging.debug(last_key_box[:])
629+
#logging.debug(arr[:])
621630

622631
if self.config.color_scheme['background'] not in ('d', 'D'):
623632
for r in range(arr.height):

0 commit comments

Comments
 (0)
X Tutup