Open
Description
- I've checked docs and closed issues for possible solutions.
- I can't find my issue in the FAQ.
Describe the bug
There is no need to subtract self.legacy_windows from self._width in the size getter (link) because the self._width field already contains a value that takes legacy_windows into account (link).
For example, you can't directly get the size value from one console and assign it to another. The width of the second console will be 1 character smaller.
from rich import get_console
from rich.console import Console
console = get_console()
econsole = Console(stderr=True)
print("Before:\nconsole.size =", console.size, "\neconsole.size =", econsole.size)
econsole.size = console.size
print("After:\nconsole.size =", console.size, "\neconsole.size =", econsole.size)
Output:
Before:
console.size = ConsoleDimensions(width=182, height=26)
econsole.size = ConsoleDimensions(width=182, height=26)
After:
console.size = ConsoleDimensions(width=182, height=26)
econsole.size = ConsoleDimensions(width=181, height=26)
Platform
Click to expand
OS: Windows 10 22H2
Terminal: ConEmu
$ python -m rich.diagnose
┌───────────────────────── <class 'rich.console.Console'> ─────────────────────────┐
│ A high level console interface. │
│ │
│ ┌──────────────────────────────────────────────────────────────────────────────┐ │
│ │ <console width=182 ColorSystem.WINDOWS> │ │
│ └──────────────────────────────────────────────────────────────────────────────┘ │
│ │
│ color_system = 'windows' │
│ encoding = 'utf-8' │
│ file = <_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'> │
│ height = 26 │
│ is_alt_screen = False │
│ is_dumb_terminal = False │
│ is_interactive = True │
│ is_jupyter = False │
│ is_terminal = True │
│ legacy_windows = True │
│ no_color = False │
│ options = ConsoleOptions( │
│ size=ConsoleDimensions(width=182, height=26), │
│ legacy_windows=True, │
│ min_width=1, │
│ max_width=182, │
│ is_terminal=True, │
│ encoding='utf-8', │
│ max_height=26, │
│ justify=None, │
│ overflow=None, │
│ no_wrap=False, │
│ highlight=None, │
│ markup=None, │
│ height=None │
│ ) │
│ quiet = False │
│ record = False │
│ safe_box = True │
│ size = ConsoleDimensions(width=182, height=26) │
│ soft_wrap = False │
│ stderr = False │
│ style = None │
│ tab_size = 8 │
│ width = 182 │
└──────────────────────────────────────────────────────────────────────────────────┘
┌─── <class 'rich._windows.WindowsConsoleFeatures'> ────┐
│ Windows features available. │
│ │
│ ┌───────────────────────────────────────────────────┐ │
│ │ WindowsConsoleFeatures(vt=False, truecolor=False) │ │
│ └───────────────────────────────────────────────────┘ │
│ │
│ truecolor = False │
│ vt = False │
└───────────────────────────────────────────────────────┘
┌────── Environment Variables ───────┐
│ { │
│ 'TERM': None, │
│ 'COLORTERM': None, │
│ 'CLICOLOR': None, │
│ 'NO_COLOR': None, │
│ 'TERM_PROGRAM': None, │
│ 'COLUMNS': '184', │
│ 'LINES': '26', │
│ 'JUPYTER_COLUMNS': None, │
│ 'JUPYTER_LINES': None, │
│ 'JPY_PARENT_PID': None, │
│ 'VSCODE_VERBOSE_LOGGING': None │
│ } │
└────────────────────────────────────┘
platform="Windows"
$ pip freeze | rg rich
rich==13.7.1
Activity