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

Use ansi color terminal palette by default #28

Open
chtenb opened this issue Nov 21, 2024 · 16 comments
Open

Use ansi color terminal palette by default #28

chtenb opened this issue Nov 21, 2024 · 16 comments

Comments

@chtenb
Copy link

chtenb commented Nov 21, 2024

Describe the bug
The colors used by this app are not so readable on some terminal themes
image
If you would stick to the 8 basic ansi colors for the foreground, this issue should be resolved for everyone, and also adapt to their terminal color palette automatically.

@meowgorithm
Copy link
Member

meowgorithm commented Nov 22, 2024

Hi! Funny, we just opened a PR for a 4-bit ANSI color scheme: #22

But also, Sequin has a light background theme that should be automatically enabled when needed, so I'm curious why the detection isn't working.

What terminal, shell and operating system are you using?

@chtenb
Copy link
Author

chtenb commented Nov 22, 2024

Wezterm, nushell, windows

@mkotowski
Copy link
Contributor

mkotowski commented Nov 22, 2024

Edit 3: Correction, I ran WezTerm tests inside terminal multiplexer, it seems termenv on which lipgloss depends ignores tmux and screen based on $TERM for OSC queries like OSC 11 ; ? ST (https://github.com/muesli/termenv/blob/master/termenv_unix.go#L235). Outside it, detection seems to work as intended.

Faulty tests from inside multiplexer Hi, I can confirm that it seems to affect WezTerm + bash + Linux too. Confirmed by switching themes on single session in Konsole on the same system and it works OK. Verified Konsole's and WezTerm's support for background detection by simply running `echo -en '\x1b]11;?\a'`. Issue seems to affect even more closely white themes (tested '3024 Day (Gogh)' on WezTerm).

Screenshot_20241122_083444

Screenshot_20241122_083508

Edit 2:
Stranger still, it seems to work OK in WezTerm if run inside a docker image (same config as in screenshots above):
Screenshot_20241122_084814
Screenshot_20241122_084836

Edit:
Tested versions:

  • WezTerm: flatpak 20240203-110809-5046fc22
  • Konsole: 23.08.5

@chtenb
Copy link
Author

chtenb commented Nov 22, 2024

I'm not sure how the light/dark theme would be detected by applications? There is no env variable set, from what I can see. My terminal apps all use ANSI colors, and these are mapped by my wezterm config to certain colors, based on the system theme.

@aymanbagabas
Copy link
Member

Edit 3: Correction, I ran WezTerm tests inside terminal multiplexer, it seems termenv on which lipgloss depends ignores tmux and screen based on $TERM for OSC queries like OSC 11 ; ? ST (https://github.com/muesli/termenv/blob/master/termenv_unix.go#L235). Outside it, detection seems to work as intended.

@mkotowski Keep in mind that Sequin uses Lip Gloss v2 which doesn't depend on Termenv. See terminal.go for more details.

@caarlos0
Copy link
Member

@mkotowski also, you might want to add something like this to your tmux config:

https://github.com/caarlos0/dotfiles/blob/ce5c7d240c0fd440b61453f1466b7015376eeaba/modules/tmux/tmux.conf#L1-L2

make sure to set it to your actual terminal though, mine is ghostty so that's what I have there.

@meowgorithm
Copy link
Member

meowgorithm commented Nov 22, 2024

@chtenb We can auto-detect the background color either via OSC or environment variable depending on the terminal and system (@aymanbagas, correct me if I'm wrong here).

What it sounds like is that Windows isn't detecting the background color because input is a pipe. We're looking into this.

In the meantime we'll merge #22.

@ayman
Copy link

ayman commented Nov 22, 2024

@meowgorithm you tagged the wrong ayman...you want @aymanbagabas.

aymanbagabas added a commit to charmbracelet/lipgloss that referenced this issue Nov 22, 2024
…erminal

This change explicitly opens CONIN/CONOUT when either in/out files
is not a terminal. Otherwise, the background color query fails because
the streams are not console devices.

Fixes: charmbracelet/sequin#28
@aymanbagabas
Copy link
Member

I've opened charmbracelet/lipgloss#444 to fix this issue in Lip Gloss v2.

@meowgorithm
Copy link
Member

@ayman Sorry about that, though it's nice to meet the person behind the original Ayman handle. It looks like you're working on some cool stuff.

@mkotowski
Copy link
Contributor

@aymanbagabas Thanks! I missed that. 🙂

@caarlos0 Thanks for the tip, but I have both COLORTERM set to the truecolor and TERM set to xterm-256color and the issue is till present in my case:

And after exiting tmux in the same session:

@aymanbagabas
Copy link
Member

@mkotowski What's your Tmux version?

@mkotowski
Copy link
Contributor

@aymanbagabas tmux 3.2a, beyond setting COLORTERM and TERM no customization in my conf file, running inside ubuntu 22.04 image set-up using distrobox.

@aymanbagabas
Copy link
Member

@aymanbagabas tmux 3.2a, beyond setting COLORTERM and TERM no customization in my conf file, running inside ubuntu 22.04 image set-up using distrobox.

Sounds about right. Tmux added support to OSC10/11 query in 3.4 see https://github.com/tmux/tmux/blob/master/CHANGES#L152

@mkotowski
Copy link
Contributor

mkotowski commented Nov 22, 2024

Ah, I see 🤦, why did I thought it was introduced in an earlier version? Then sorry for a false alarm 😅

aymanbagabas added a commit to charmbracelet/lipgloss that referenced this issue Nov 22, 2024
…erminal

This change explicitly opens CONIN/CONOUT when either in/out files
is not a terminal. Otherwise, the background color query fails because
the streams are not console devices.

Fixes: charmbracelet/sequin#28
@aymanbagabas
Copy link
Member

Ah, I see 🤦, why did I thought it was introduced in an earlier version? Then sorry for a false alarm 😅

No worries, we should put a note somewhere about Tmux and GNU Screen.

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

6 participants