Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Lib/_pyrepl/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 +644,7 @@ def update_screen(self) -> None:

def refresh(self) -> None:
"""Recalculate and refresh the screen."""
self.console.height, self.console.width = self.console.getheightwidth()
# this call sets up self.cxy, so call it first.
self.screen = self.calc_screen()
self.console.refresh(self.screen, self.cxy)
Expand Down
1 change: 0 additions & 1 deletion Lib/_pyrepl/unix_console.py
Original file line number Diff line number Diff line change
Expand Up @@ -776,7 +776,6 @@ def __move_tall(self, x, y):
self.__write_code(self._cup, y - self.__offset, x)

def __sigwinch(self, signum, frame):
self.height, self.width = self.getheightwidth()
self.event_queue.insert(Event("resize", None))

def __hide_cursor(self):
Expand Down
2 changes: 2 additions & 0 deletions Lib/test/test_pyrepl/support.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ def prepare_console(events: Iterable[Event], **kwargs) -> MagicMock | Console:
console.get_event.side_effect = events
console.height = 100
console.width = 80
console.getheightwidth = MagicMock(side_effect=lambda: (console.height, console.width))

for key, val in kwargs.items():
setattr(console, key, val)
return console
Expand Down
1 change: 1 addition & 0 deletions Lib/test/test_pyrepl/test_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ def _prepare_console(events):
console.get_event.side_effect = events
console.height = 100
console.width = 80
console.getheightwidth = MagicMock(side_effect=lambda: (console.height, console.width))
console.input_hook = input_hook
return console

Expand Down
6 changes: 2 additions & 4 deletions Lib/test/test_pyrepl/test_unix_console.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,7 @@ def test_resize_bigger_on_multiline_function(self, _os_write):
events = itertools.chain(code_to_events(code))
reader, console = handle_events_short_unix_console(events)

console.height = 2
console.getheightwidth = MagicMock(lambda _: (2, 80))
console.getheightwidth = MagicMock(side_effect=lambda: (2, 80))

def same_reader(_):
return reader
Expand Down Expand Up @@ -286,8 +285,7 @@ def test_resize_smaller_on_multiline_function(self, _os_write):
events = itertools.chain(code_to_events(code))
reader, console = handle_events_unix_console_height_3(events)

console.height = 1
console.getheightwidth = MagicMock(lambda _: (1, 80))
console.getheightwidth = MagicMock(side_effect=lambda: (1, 80))

def same_reader(_):
return reader
Expand Down
14 changes: 4 additions & 10 deletions Lib/test/test_pyrepl/test_windows_console.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,7 @@ def test_resize_wider(self):
events = code_to_events(code)
reader, console = self.handle_events_narrow(events)

console.height = 20
console.width = 80
console.getheightwidth = MagicMock(lambda _: (20, 80))
console.getheightwidth = MagicMock(side_effect=lambda: (20, 80))

def same_reader(_):
return reader
Expand All @@ -157,9 +155,7 @@ def test_resize_narrower(self):
events = code_to_events(code)
reader, console = self.handle_events(events)

console.height = 20
console.width = 4
console.getheightwidth = MagicMock(lambda _: (20, 4))
console.getheightwidth = MagicMock(side_effect=lambda: (20, 4))

def same_reader(_):
return reader
Expand Down Expand Up @@ -292,8 +288,7 @@ def test_resize_bigger_on_multiline_function(self):
events = itertools.chain(code_to_events(code))
reader, console = self.handle_events_short(events)

console.height = 2
console.getheightwidth = MagicMock(lambda _: (2, 80))
console.getheightwidth = MagicMock(side_effect=lambda: (2, 80))

def same_reader(_):
return reader
Expand Down Expand Up @@ -330,8 +325,7 @@ def test_resize_smaller_on_multiline_function(self):
events = itertools.chain(code_to_events(code))
reader, console = self.handle_events_height_3(events)

console.height = 1
console.getheightwidth = MagicMock(lambda _: (1, 80))
console.getheightwidth = MagicMock(side_effect=lambda: (1, 80))

def same_reader(_):
return reader
Expand Down
Loading