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

Consider switching from terminal-light to terminal-colorsaurus #151

Open
zeenix opened this issue Aug 10, 2024 · 3 comments
Open

Consider switching from terminal-light to terminal-colorsaurus #151

zeenix opened this issue Aug 10, 2024 · 3 comments

Comments

@zeenix
Copy link
Owner

zeenix commented Aug 10, 2024

@bash While reviewing your zbus PR, I looked at your profile (standard practice after the xz fiasco 😆) and found your terminal-colorsaurus project. In gimoji, I've been using terminal-light (based on xterm-query). I wonder if there would be some advantages of switching to terminal-colorsaurus? For one, it seems you've already been aware of the "polling of /dev/tty on MacOs" issue (and I assume you've it addressed?) so if I had used termina-colorsaurus from the beginning, it would have saved me a lot of time, debugging and then fixing that. But I wonder if there is an advantage still? 🤔

@bash
Copy link
Contributor

bash commented Aug 11, 2024

Edit: I re-read my original comment and felt that a rewrite was appropriate as I feel that I came across as defeatist. That's not how I want to interact with people!

It's really cool to see you interested in my profile and terminal-colorsaurus in particular :))

Although a lot of passion and sweat went into the library I would
generally recommend trying other things first before reaching for a tool such as terminal-colorsaurus.

Detecting the background color from the terminal comes with some pitfalls (one of these you have already
experienced with the polling issue on macOS), namely:

Advantages of terminal-colorsaurus:
I think the biggest advantage of terminal-colorsaurus over other libraries is that it doesn't use a fixed timeout for queries. This is most noticeable when querying for the bg color is not supported.

One or two terminals out there respond with a different format and terminal-colorsaurus knows how to handle that.
terminal-colorsaurus is also careful to not query the terminal when the TERM env var is not set or set to TERM=dumb.

My recommendation: The differences between dark and light mode in your case could probably be solved by using the default foreground color (instead of black or white). The green color should be fine as the 16 ANSI Colors are usually adapted for dark and light mode (or any other theme).

Making the color "grayed out" could be achieved by using the dimmed style. Support and implementation vary a bit between terminals but are always in the spirit of "dimmed".

If you like, I can open a PR that includes screenshots of dark and light mode in different terminals :)

@bash
Copy link
Contributor

bash commented Aug 11, 2024

Totally forgot to address the /dev/tty thing on macOS 😆
Yes, colorsaurus deals with that by using pselect instead of poll.
Most of the time this isn't relevant because I try to re-use one of the open file descriptors (either stdout, stderr or stdin).

@zeenix
Copy link
Owner Author

zeenix commented Sep 19, 2024

@bash Thank you so much for your very detailed answer and recommendation. I have to appologise for not responding for so long but I wanted to find the right relaxed moment to properly think about everything and write a thorough response but that moment never came. 😢

My recommendation: The differences between dark and light mode in your case could probably be solved by using the default foreground color (instead of black or white). The green color should be fine as the 16 ANSI Colors are usually adapted for dark and light mode (or any other theme).

I appreciate that your very unbiased recommendation (people usually push for using their libraries and you had the perfect opportunity here 😄). 👍 Which color would you recommend?

Making the color "grayed out" could be achieved by using the dimmed style. Support and implementation vary a bit between terminals but are always in the spirit of "dimmed".

Hmm.. I'm not sure what's your suggestion here. 🤔 Are you suggesting that I dim all the text?

If you like, I can open a PR that includes screenshots of dark and light mode in different terminals :)

That would be most welcome!

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