You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
On some consoles the output width seems to be calculated one character too wide. See the following example:
>>> from rich.console import Console
>>> from rich.table import Table
>>> c = Console()
>>> t = Table("Yo!", "Tables!")
>>> t.add_row("a", "row")
>>> t.add_row("another", "row")
>>> c.print(t)
┏━━━━━━━━━┳━━━━━━━━━┓
┃ Yo! ┃ Tables! ┃
┡━━━━━━━━━╇━━━━━━━━━┩
│ a │ row │
│ another │ row │
└─────────┴─────────┘
>>> c = Console(width=c.width-1)
>>> c.print(t)
┏━━━━━━━━━┳━━━━━━━━━┓
┃ Yo! ┃ Tables! ┃
┡━━━━━━━━━╇━━━━━━━━━┩
│ a │ row │
│ another │ row │
└─────────┴─────────┘
I played around a bit and tested some combinations, some seem fine, others not:
ssh terminal in vscode: OK
ssh terminal in ConEmu: one too wide
ssh terminal in Windows command interpreter (Win+R, cmd): one too wide
Source System is Win10, the system the console runs on was either Ubuntu 18 or Oracle Linux
A possible workaround is as shown above: get a Console, and then get another one which is one narrower than the first one.
Looking ath the code, i understand that you are retrieving the terminal size via shutil.get_terminal_size(), so maybe that issue is beyond the reach of the lib.
The text was updated successfully, but these errors were encountered:
I've noticed this on Windows terminal. I think the issue is that the Windows terminal treats a new line character has having width of 1. On Linux terminal emulators the new line has no width.
The master branch does width-1 for windows, but it doesn't feel like a good solution, so I'm investigating alternatives.
I just tried it with the code at the master branch with no luck. I think it is because the code does not run on Windows, i just connect to the terminal from a windows machine.
I'll stick with the workaround for the moment, i think i can spare that one character even if it is not necessary to cut it. Besides of this little issue, rich is a great lib!
With a bit of experimentation, it appears as though Windows inserts new lines for you when the text reaches the right of the terminal, MacOS and Linux doesn't. I think the only option is to always subtract 1, as you did. v0.3.3 has that fix.
On some consoles the output width seems to be calculated one character too wide. See the following example:
I played around a bit and tested some combinations, some seem fine, others not:
Source System is Win10, the system the console runs on was either Ubuntu 18 or Oracle Linux
A possible workaround is as shown above: get a Console, and then get another one which is one narrower than the first one.
Looking ath the code, i understand that you are retrieving the terminal size via
shutil.get_terminal_size()
, so maybe that issue is beyond the reach of the lib.The text was updated successfully, but these errors were encountered: