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

Broken output on old windows cmd #3378

Closed
Dobatymo opened this issue Sep 22, 2023 · 8 comments
Closed

Broken output on old windows cmd #3378

Dobatymo opened this issue Sep 22, 2023 · 8 comments

Comments

@Dobatymo
Copy link

Dobatymo commented Sep 22, 2023

Windows 7 x64, cmd.exe
Python 3.8.10 x64
textual==0.38.1
rich==13.5.3

Colors are working fine with rich, however textual output is full of ANSI(?) sequences.

grafik
grafik

It is working on a Windows 10 machine with otherwise same environment. I remember in the past it worked on Windows 7 as well (maybe when colorama was still used?)

The issue template mentions a textual diagnose command which I cannot find anywhere...
EDIT: maybe you meant py -m rich.diagnose?

┌───────────────────────── <class 'rich.console.Console'> ─────────────────────────┐
│ A high level console interface.                                                  │
│                                                                                  │
│ ┌──────────────────────────────────────────────────────────────────────────────┐ │
│ │ <console width=159 ColorSystem.WINDOWS>                                      │ │
│ └──────────────────────────────────────────────────────────────────────────────┘ │
│                                                                                  │
│     color_system = 'windows'                                                     │
│         encoding = 'utf-8'                                                       │
│             file = <_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'> │
│           height = 41                                                            │
│    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=159, height=41),             │
│                        legacy_windows=True,                                      │
│                        min_width=1,                                              │
│                        max_width=159,                                            │
│                        is_terminal=True,                                         │
│                        encoding='utf-8',                                         │
│                        max_height=41,                                            │
│                        justify=None,                                             │
│                        overflow=None,                                            │
│                        no_wrap=False,                                            │
│                        highlight=None,                                           │
│                        markup=None,                                              │
│                        height=None                                               │
│                    )                                                             │
│            quiet = False                                                         │
│           record = False                                                         │
│         safe_box = True                                                          │
│             size = ConsoleDimensions(width=159, height=41)                       │
│        soft_wrap = False                                                         │
│           stderr = False                                                         │
│            style = None                                                          │
│         tab_size = 8                                                             │
│            width = 159                                                           │
└──────────────────────────────────────────────────────────────────────────────────┘
┌─── <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': None,               │
│     'LINES': None,                 │
│     'JUPYTER_COLUMNS': None,       │
│     'JUPYTER_LINES': None,         │
│     'JPY_PARENT_PID': None,        │
│     'VSCODE_VERBOSE_LOGGING': None │
│ }                                  │
└────────────────────────────────────┘
platform="Windows"

EDIT: after installing textual-dev

Textual Diagnostics

Versions

Name Value
Textual 0.38.1
Rich 13.5.3

Python

Name Value
Version 3.8.10
Implementation CPython
Compiler MSC v.1928 64 bit (AMD64)
Executable C:\Program Files\Python38\python.exe

Operating System

Name Value
System Windows
Release 7
Version 6.1.7601

Terminal

Name Value
Terminal Application Unknown
TERM Not set
COLORTERM Not set
FORCE_COLOR Not set
NO_COLOR Not set

Rich Console options

Name Value
size width=159, height=41
legacy_windows True
min_width 1
max_width 159
is_terminal True
encoding utf-8
max_height 41
justify None
overflow None
no_wrap False
highlight None
markup None
height None
@github-actions
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

@davep
Copy link
Contributor

davep commented Sep 22, 2023

The issue template mentions a textual diagnose command which I cannot find anywhere...
EDIT: maybe you meant py -m rich.diagnose?

The reason for this is you're reporting this issue in the Textual repository.

[Edit to add] The textual command is provided by textual-dev.

@TomJGooding
Copy link
Contributor

I found lots of references to legacy_windows in Rich for its rendering, but searching Textual the only code I could find sets this to false in the App. I might be completely off base as I haven't spent much time yet looking into this, but might this explain the difference?

@Dobatymo
Copy link
Author

Dobatymo commented Sep 24, 2023

The issue template mentions a textual diagnose command which I cannot find anywhere...
EDIT: maybe you meant py -m rich.diagnose?

The reason for this is you're reporting this issue in the Textual repository.

I report it here because rich is working as expected but textual is not even though the rendering should be based on rich.

[Edit to add] The textual command is provided by textual-dev.

Thanks. I didn't find this before.

I found lots of references to legacy_windows in Rich for its rendering, but searching Textual the only code I could find sets this to false in the App. I might be completely off base as I haven't spent much time yet looking into this, but might this explain the difference?

I tried setting it to True but it didn't change the behavior. I saw that textual is calling some additional WinAPI function which might not be support by Windows 7. I am not sure why it doesn't let rich do all that work.

@willmcgugan
Copy link
Collaborator

I'm afraid Textual is unlikely to work in Windows 7. Microsoft introduce better terminal support in Windows 10. Prior to that it was abysmal.

It would be possible to get it kind of working, but with disturbing visual glitches and it would be too slow to be useable.

One option (other than upgrading) would be to use textual-web which runs a terminal in the browser.

@Dobatymo
Copy link
Author

Dobatymo commented Sep 25, 2023

I'm afraid Textual is unlikely to work in Windows 7. Microsoft introduce better terminal support in Windows 10. Prior to that it was abysmal.

@willmcgugan What features did not work in Windows 7? I know that ANSI sequence support was added in Windows 10. But can they do anything which wasn't supported before by the Windows API? I thought that's exactly the thing colorama solved in the past before rich stopped using it. Or maybe I should ask: What terminal support is required for textual to work, but not required for rich? Since rich seems to work perfectly on Windows 7.

Sorry, I don't want to sound impatient in the paragraph above. But sometimes I am annoyed by developers treating Windows as second class for development simply because the API is a different one compared to Linux/POSIX. Async development is similar, Windows had superior support for async for a long time compared to Linux (see I/O completion ports), just most developers didn't bother to learn it and tried to make the POSIX style work on Windows (which of course didn't work well).

Please ignore the rant paragraph. rich and textual are great libraries and I am grateful for the hard work!

@willmcgugan
Copy link
Collaborator

Sorry for the slow response.

The approach colorama and Rich takes for older Windows versions just wouldn't work for Textual apps. You only get 16 ugly colors and there is no explicit full screen support. You can't turn the cursor off. Even if you can tolerate those issues, the legacy terminal is incredibly slow. Until a few years ago Microsoft didn't consider the terminal to be a priority...

Copy link

github-actions bot commented Apr 8, 2024

Don't forget to star the repository!

Follow @textualizeio for Textual updates.

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

No branches or pull requests

4 participants