-
-
Notifications
You must be signed in to change notification settings - Fork 66
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
Using the user's terminal colors #181
Comments
I believe this how to do with how tcell (low-level terminal library, used by Amfora and the TUI middle-layer library called cview) works. In a normal terminal it can check for truecolor support and attempt to display the original color. Over SSH, tcell thinks truecolor isn't supported, and it will fallback to the regular color codes, which the terminal will then display using the built-in palette. That's my guess, anyway. IIRC the reason Amfora doesn't try to use default terminal colors is that it's hard to get both light and dark terminals to work correctly. There's not really a way to know whether to use white text or black text for example, and I believe that just trying to use terminal colors will mess up in certain situations, like put white text on the default white terminal background. I might be wrong about that, and it's worth looking into. But it's easier to just use truecolor and provide support for themeing. For example, there is a Nord theme. But I understand that's annoying to create for other terminal setups. I leave this open as a question for now, something that should be tested more. Currently I am updating tcell in #107, and right now I've set things up so truecolor is forced whenever possible, ignoring the user's terminal colors. |
I second the request for respecting the terminal's color scheme, but I agree that doing so is not without some limitations.
It's slightly annoying for users to go to each application's config and tweak the color scheme to match the rest of their systems. Especially so if they have set up some kind of automation like with pywal.
I don't think that will be a problem since you're setting a background color anyway, so might as well use one that fits the user's color scheme. tcell can take color names for 4bit colors which will then be rendered by the terminal according to the terminal's settings. The default theme in Amfora could simply be changed to use color names instead of hex codes and look consistent (i.e. no white text on white bg) as long as the user has their terminal colors configured properly. The only problem is that there is no reliable way to tell whether the user would prefer a dark or light color scheme (but that problem exists with the current schemes anyway). But including a light and a dark default scheme using color names seems an easy solution. (A more advanced approach might be to peak at some common terminal config files to deduce the user's preference, but that is an optional improvement). Does this make sense? Oh and in any case: Changing the default colorscheme - or any default for that matter - tends to make people angry. But at least additionally bundling a light and dark scheme defined using color names could be convenient. |
Likely sounds like a good idea. I'll experiment and see when I can and report back here. |
I looked a bit into how tcell handles colors and the tldr is that this does not seem easily possible with tcell v1 but will be possible with v2 (which is part of the cview-update to Amfora which is being worked on afaict). While you can give tcell color names, it does map them to 24bit colors in a predefined manner and communicates them to the terminal in truecolor mode (if supported by the terminal). They changed this behavior with v2 so that using color names should cause the proper escape codes to be sent that don't use truecolor. A quick little test that I did with tcell v2 confirmed that it behaved as expected. |
Related: #116 |
From some quick tests I made with tcell, I had good results simply by exporting |
Note: This should also allow for transparent terminals to stay transparent, if possible. |
#245 by @m-mcdonagh will allow for using the terminal's default background color, including transparent backgrounds. The next step after this PR would be figuring out how to make the |
With 2e1049b this issue is basically complete. I'm leaving it open because I think I can solve the issue of light and dark themes, and get those to be detected too, changing the text to be legible. |
Light terminal backgrounds handled in 6666ef2. Would appreciate testing of these features! cc @m-mcdonagh |
I'm using Amfora on a default light terminal theme (without any theme configuration in the amfora TOML file) and although it mostly looks fine, the background and foreground color of selected links aren't accessible. Here's an image of a non-Gemini link when it's selected: And here's an image of a Gemini link: I'd rather not create a theme for amfora which would just add another configuration file I have to consider changing when changing my theme globally. Which terminal colors is Amfora choosing for the foreground and background of links when they are highlighted? EDIT: I suspect that the foreground color is the default foreground color of text and the background color is magenta and blue, respectively. Am I correct? |
Thank you for making Amfora, it is quite a nice browser!
I saw you mention that you were having trouble using the users terminal colors. It seems that when launching the terminal over SSH, it properly uses the users terminal colors. Maybe this can uncover some way that it can be done an easier way.
Both terminals are here are Alacritty, using the Nord colors. The left is using ssh to open Amfora, the right is not.

The text was updated successfully, but these errors were encountered: