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

Prototype: Detect dark/light asynchronously #12238

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

bash
Copy link

@bash bash commented Dec 11, 2024

No description provided.

@the-mikedavis
Copy link
Member

the-mikedavis commented Dec 27, 2024

https://github.com/contour-terminal/contour/blob/master/docs/vt-extensions/color-palette-update-notifications.md sounds like a good approach to me. We should be able to add support for enabling mode 2031 and receiving colorscheme change events in crossterm. With that there's no need to add any extra dependencies (especially platform-specific ones like in dark-light) - we can vendor or reimplement the perceived lightness function from terminal-colorsaurus instead.

Your patch to crossterm is small but for a proper implementation I think we should be adding a crossterm event which exposes the changed color(s) (similar to the resize event for example). Crossterm should ideally not be exposing escape sequences to consuming applications. I can take a look at writing a patch like that in the new year unless you'd like to give it a go.

edit: I actually took a swing at this already in #12362

@bash
Copy link
Author

bash commented Jan 2, 2025

The contour extension is amazing 😍—and it's even supported by Kitty and Ghostty.

Your patch to crossterm is small but for a proper implementation I think we should be adding a crossterm event which exposes the changed color(s) (similar to the resize event for example).

Agreed, exposing the OSC String directly was the easiest way for me to experiment :)

Regarding terminal-colorsaurus: My goal with bash/terminal-colorsaurus#30 was to expose xparsecolor in a way such that if you depend on colorsaurus with default-features = false you get no extra dependencies. So vendoring should not be necessary :)

edit: I decided to publish the xparsecolor stuff as a separate mini-crate: https://docs.rs/xterm-color/

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

Successfully merging this pull request may close these issues.

2 participants