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

Terminal default coloring with textual CSS #5452

Closed
friscorose opened this issue Jan 2, 2025 · 8 comments
Closed

Terminal default coloring with textual CSS #5452

friscorose opened this issue Jan 2, 2025 · 8 comments

Comments

@friscorose
Copy link
Contributor

Wishlist

When using Rich one can set "default on default" as a means to preserve the native terminal color presence. It would useful, especially for inline mode, to have a TCSS styling mechanism that maintains the same Rich default coloring behavior.

Possible Solution

A possible scenario that is somewhat semantically consistent might be to add as valid a 'none' value to both color and background styles.

Example

Widget_name {
  color: none;
  background: none;
}
Copy link

github-actions bot commented Jan 2, 2025

We found the following entry in the FAQ which you may find helpful:

Feel free to close this issue if you found an answer in the FAQ. Otherwise, please give us a little time to review.

This is an automated reply, generated by FAQtory

@TomJGooding
Copy link
Contributor

Perhaps I haven't understood what you mean by "default" colors, but you can preserve ANSI colors in inline apps?

This FAQ might be relevant here? https://textual.textualize.io/FAQ/#why-doesnt-textual-support-ansi-themes

@friscorose
Copy link
Contributor Author

Perhaps I haven't understood what you mean by "default" colors, but you can preserve ANSI colors in inline apps?

This FAQ might be relevant here? https://textual.textualize.io/FAQ/#why-doesnt-textual-support-ansi-themes

If I run> uv run --with textual t_test.py

from textual.app import App, ComposeResult
from textual.widgets import Label

class Test(App):
    def compose(self) -> ComposeResult:
        yield Label( "[on default]                " )
        yield Label( "[on default]   0123456789   " )
        yield Label( "[on default]                " )

if __name__ == "__main__":
    Test().run(ansi_color=True, inline=True, inline_no_clear=True)

I get different result in both foreground and background styling than > uv run --with rich r_test.py

from rich import print as rprint

rprint( "[on default]                " )
rprint( "[on default]   0123456789   " )
rprint( "[on default]                " )

@TomJGooding
Copy link
Contributor

ansi_color=True should be set in the App constructor rather than in the run method, so I think your first example will just crash?

Perhaps I'm still missing something, could you include some screenshots to help show what you mean?

@friscorose
Copy link
Contributor Author

I had edited the wrong test file arghh. You are correct, that technically resolves the issue in the app constructor.

Is it undesired UI or difficult to add this capability to TCSS as mentioned above? If so, I happily (or you may) close this request.

@TomJGooding
Copy link
Contributor

I'm not a maintainer, but this seems an intentional design decision based on the FAQ linked above

@friscorose
Copy link
Contributor Author

Closing as technically provided per discussion.

@friscorose friscorose closed this as not planned Won't fix, can't repro, duplicate, stale Jan 2, 2025
Copy link

github-actions bot commented Jan 2, 2025

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

2 participants