Skip to content

Commit bace621

Browse files
fix display of keyboard events
1 parent f446b2f commit bace621

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

bpython/curtsiesfrontend/repl.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1154,6 +1154,12 @@ def move_screen_up(current_line_start_row):
11541154
else:
11551155
arr[statusbar_row, :] = paint.paint_statusbar(1, width, self.status_bar.current_line, self.config)
11561156

1157+
if self.presentation_mode:
1158+
rows = arr.height
1159+
columns = arr.width
1160+
last_key_box = paint.paint_last_events(rows, columns, [events.pp_event(x) for x in self.last_events if x], self.config)
1161+
arr[arr.height-last_key_box.height:arr.height, arr.width-last_key_box.width:arr.width] = last_key_box
1162+
11571163
if self.config.color_scheme['background'] not in ('d', 'D'):
11581164
for r in range(arr.height):
11591165
arr[r] = fmtstr(arr[r], bg=color_for_letter(self.config.color_scheme['background']))

bpython/curtsiesfrontend/replpainter.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,8 @@ def paint_last_events(rows, columns, names, config):
177177
return fsarray([])
178178
width = min(max(len(name) for name in names), columns-2)
179179
output_lines = []
180-
output_lines.append(config.left_top_corner+config.top_border*(width+2)+config.right_top_corner)
181-
for name in names[-(rows-2):]:
180+
output_lines.append(config.left_top_corner+config.top_border*(width)+config.right_top_corner)
181+
for name in names[max(0, len(names)-(rows-2)):]:
182182
output_lines.append(config.left_border+name[:width].center(width)+config.right_border)
183183
output_lines.append(config.left_bottom_corner+config.bottom_border*width+config.right_bottom_corner)
184184
return fsarray(output_lines)

bpython/test/test_curtsies_painting.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,18 @@ def foo(x, y, z=10):
9393

9494
def test_formatted_docstring(self):
9595
actual = replpainter.formatted_docstring(
96-
'Returns the results\n\n' 'Also has side effects',
97-
40, config=setup_config())
96+
'Returns the results\n\n' 'Also has side effects',
97+
40, config=setup_config())
9898
expected = fsarray(['Returns the results', '', 'Also has side effects'])
9999
self.assertFSArraysEqualIgnoringFormatting(actual, expected)
100100

101-
101+
def test_paint_lasts_events(self):
102+
actual = replpainter.paint_last_events(4, 100, ['a', 'b', 'c'], config=setup_config())
103+
expected = fsarray(["┌─┐",
104+
"│b│",
105+
"│c│",
106+
"└─┘"])
107+
self.assertFSArraysEqualIgnoringFormatting(actual, expected)
102108

103109
@contextmanager
104110
def output_to_repl(repl):

0 commit comments

Comments
 (0)