Update column width, CHANGELOG, CONTRIBUTORS

This commit is contained in:
Antony Milne 2022-06-09 23:07:28 +01:00
parent da10ca92fc
commit d4f9f6dc50
4 changed files with 19 additions and 4 deletions

View file

@ -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

View file

@ -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)

View file

@ -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)

View file

@ -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)
console = Console(
width=40, _environ={"JUPYTER_LINES": "broken"}, force_jupyter=True
)