From d4f9f6dc50e3dc94fbb0af12341b0d77dcc065db Mon Sep 17 00:00:00 2001 From: Antony Milne Date: Thu, 9 Jun 2022 23:07:28 +0100 Subject: [PATCH] Update column width, CHANGELOG, CONTRIBUTORS --- CHANGELOG.md | 8 ++++++++ CONTRIBUTORS.md | 1 + rich/console.py | 4 +++- tests/test_jupyter.py | 10 +++++++--- 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 70652e14..02f49528 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added + +- Environment variables `JUPYTER_COLUMNS` and `JUPYTER_LINES` to control width and height of console in Jupyter + +### Changed + +- Default width of Jupyter console size is increased to 115 + ### Fixed - Fix text wrapping edge case https://github.com/Textualize/rich/pull/2296 diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index c24f21b1..0c150113 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -24,6 +24,7 @@ The following people have contributed to the development of Rich: - [Alexander Mancevice](https://github.com/amancevice) - [Will McGugan](https://github.com/willmcgugan) - [Paul McGuire](https://github.com/ptmcg) +- [Antony Milne](https://github.com/AntonyMilneQB) - [Nathan Page](https://github.com/nathanrpage97) - [Avi Perl](https://github.com/avi-perl) - [Laurent Peuch](https://github.com/psycojoker) diff --git a/rich/console.py b/rich/console.py index e42053c3..1ea40faf 100644 --- a/rich/console.py +++ b/rich/console.py @@ -657,7 +657,9 @@ class Console: self.is_jupyter = _is_jupyter() if force_jupyter is None else force_jupyter if self.is_jupyter: jupyter_columns = self._environ.get("JUPYTER_COLUMNS", "") - width = width or (int(jupyter_columns) if jupyter_columns.isdigit() else 93) + width = width or ( + int(jupyter_columns) if jupyter_columns.isdigit() else 115 + ) jupyter_lines = self._environ.get("JUPYTER_LINES", "") height = height or (int(jupyter_lines) if jupyter_lines.isdigit() else 100) diff --git a/tests/test_jupyter.py b/tests/test_jupyter.py index df244060..7c327e62 100644 --- a/tests/test_jupyter.py +++ b/tests/test_jupyter.py @@ -3,7 +3,7 @@ from rich.console import Console def test_jupyter(): console = Console(force_jupyter=True) - assert console.width == 93 + assert console.width == 115 assert console.height == 100 assert console.color_system == "truecolor" @@ -15,7 +15,9 @@ def test_jupyter_columns_env(): console = Console(width=40, _environ={"JUPYTER_COLUMNS": "314"}, force_jupyter=True) assert console.width == 40 # Should not fail - console = Console(width=40, _environ={"JUPYTER_COLUMNS": "broken"}, force_jupyter=True) + console = Console( + width=40, _environ={"JUPYTER_COLUMNS": "broken"}, force_jupyter=True + ) def test_jupyter_lines_env(): @@ -25,4 +27,6 @@ def test_jupyter_lines_env(): console = Console(height=40, _environ={"JUPYTER_LINES": "220"}, force_jupyter=True) assert console.height == 40 # Should not fail - console = Console(width=40, _environ={"JUPYTER_LINES": "broken"}, force_jupyter=True) \ No newline at end of file + console = Console( + width=40, _environ={"JUPYTER_LINES": "broken"}, force_jupyter=True + )