Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Right hand edge in Panel not vertically aligned when using content with ANSI chars #3422

Closed
2 tasks done
wabiloo opened this issue Jul 11, 2024 · 3 comments
Closed
2 tasks done

Comments

@wabiloo
Copy link

wabiloo commented Jul 11, 2024

Describe the bug

There seems to be an issue with the rendering of a Panel in which the content is a multi-line string with ANSI characters for colors. The right hand border is not vertically aligned

text = '\x1b[35mhttps://bpkio-test-adserver.herokuapp.com\x1b[0m\n\x1b[33m /api/v1/vast\x1b[0m\n \x1b[37m\x1b[2m?\x1b[0m \x1b[36mcoll\x1b[0m \x1b[37m\x1b[2m=\x1b[0m \x1b[34m\x1b[1mDAI_Ads\x1b[0m\n \x1b[37m\x1b[2m&\x1b[0m \x1b[36mdur\x1b[0m \x1b[37m\x1b[2m=\x1b[0m \x1b[31m\x1b[22m$_MMVAR_LIVEAR_SLOTDURATION\x1b[0m\n \x1b[37m\x1b[2m&\x1b[0m \x1b[36msessionid\x1b[0m \x1b[37m\x1b[2m=\x1b[0m \x1b[32m\x1b[22m$arg_sessionid\x1b[0m\n \x1b[37m\x1b[2m&\x1b[0m \x1b[36mserviceid\x1b[0m \x1b[37m\x1b[2m=\x1b[0m \x1b[32m\x1b[22m$arg_serviceid\x1b[0m\n \x1b[37m\x1b[2m&\x1b[0m \x1b[36muid$arg_sessionid\x1b[0m \x1b[37m\x1b[2m=\x1b[0m \x1b[34m\x1b[1mNone\x1b[0m'

panel = Panel(text, expand=False)
console.print(panel)

Screenshot 2024-07-11 at 20 11 22

Platform

Click to expand

What platform (Win/Linux/Mac) are you running on? What terminal software are you using?
Mac, in iTerm2

I may ask you to copy and paste the output of the following commands. It may save some time if you do it now.

If you're using Rich in a terminal:

python -m rich.diagnose
pip freeze | grep rich
╭───────────────────────── <class 'rich.console.Console'> ─────────────────────────╮
│ A high level console interface.                                                  │
│                                                                                  │
│ ╭──────────────────────────────────────────────────────────────────────────────╮ │
│ │ <console width=136 ColorSystem.TRUECOLOR>                                    │ │
│ ╰──────────────────────────────────────────────────────────────────────────────╯ │
│                                                                                  │
│     color_system = 'truecolor'                                                   │
│         encoding = 'utf-8'                                                       │
│             file = <_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'> │
│           height = 53                                                            │
│    is_alt_screen = False                                                         │
│ is_dumb_terminal = False                                                         │
│   is_interactive = True                                                          │
│       is_jupyter = False                                                         │
│      is_terminal = True                                                          │
│   legacy_windows = False                                                         │
│         no_color = False                                                         │
│          options = ConsoleOptions(                                               │
│                        size=ConsoleDimensions(width=136, height=53),             │
│                        legacy_windows=False,                                     │
│                        min_width=1,                                              │
│                        max_width=136,                                            │
│                        is_terminal=True,                                         │
│                        encoding='utf-8',                                         │
│                        max_height=53,                                            │
│                        justify=None,                                             │
│                        overflow=None,                                            │
│                        no_wrap=False,                                            │
│                        highlight=None,                                           │
│                        markup=None,                                              │
│                        height=None                                               │
│                    )                                                             │
│            quiet = False                                                         │
│           record = False                                                         │
│         safe_box = True                                                          │
│             size = ConsoleDimensions(width=136, height=53)                       │
│        soft_wrap = False                                                         │
│           stderr = False                                                         │
│            style = None                                                          │
│         tab_size = 8                                                             │
│            width = 136                                                           │
╰──────────────────────────────────────────────────────────────────────────────────╯
╭─── <class 'rich._windows.WindowsConsoleFeatures'> ────╮
│ Windows features available.                           │
│                                                       │
│ ╭───────────────────────────────────────────────────╮ │
│ │ WindowsConsoleFeatures(vt=False, truecolor=False) │ │
│ ╰───────────────────────────────────────────────────╯ │
│                                                       │
│ truecolor = False                                     │
│        vt = False                                     │
╰───────────────────────────────────────────────────────╯
╭────── Environment Variables ───────╮
│ {                                  │
│     'TERM': 'xterm-256color',      │
│     'COLORTERM': 'truecolor',      │
│     'CLICOLOR': None,              │
│     'NO_COLOR': None,              │
│     'TERM_PROGRAM': 'iTerm.app',   │
│     'COLUMNS': None,               │
│     'LINES': None,                 │
│     'JUPYTER_COLUMNS': None,       │
│     'JUPYTER_LINES': None,         │
│     'JPY_PARENT_PID': None,        │
│     'VSCODE_VERBOSE_LOGGING': None │
│ }                                  │
╰────────────────────────────────────╯
platform="Darwin"
rich==13.7.1
Copy link

Thank you for your issue. Give us a little time to review it.

PS. You might want to check the FAQ if you haven't done so already.

This is an automated reply, generated by FAQtory

@wabiloo
Copy link
Author

wabiloo commented Jul 11, 2024

Actually, it was in the FAQ. Sorry about that!

@wabiloo wabiloo closed this as completed Jul 11, 2024
Copy link

I hope we solved your problem.

If you like using Rich, you might also enjoy Textual

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant