-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Add italics and dim modifier to set_color #3650
Conversation
oh wow, I had no idea terminals could do this. |
@ridiculousfish Me neither, I only just found out about this last week. I have no idea how many terminal emulators implement these features; only tested in iTerm2 on macOS Sierra. |
I've requested review from @floam, since he did some work in set_color. He also previously used the italic and dim sequences in our Makefile, so he should be the most familiar. Please note that he's been a bit busy, so it might take a while before he gets to it. |
So cool! This has been on my TODO for a while. As of Sierra, Terminal.app also does italics. It's done dim for a couple releases. By using dim you can actually get 512 colors on Terminal.app. |
However - the |
This should be done by checking for |
If these are getting added, can we also add a reverse In case it's not obvious, this is the same as Also, the docs should probably mention that italics mode is not available on all terms / it will only work if your term supports it. |
I've added reverse as well to set_color as I think adding a test for Terminal.app in set_color is a good temporary fix. Maybe we can also identify other misconfigured terms and maybe also add a note about updating terminfo? |
During testing I just found out that Terminal.app does not do simulated italics, only if the typeface supports italics, will the mode work, which is why I thought it didn't work (I was using Fira Code) |
The reverse mode being added is nice. It's something we currently rely on |
Hmm, I just wrote a script to go through the capabilities of all the terms in the terminfo database. It looks like the majority of terms have reverse and standout mode set the same, and of those that are different the standout mode is pretty evenly split to being reverse AND bold or reverse AND dim. There are a few where standout mode is just bold (no reverse). BUT there are a not-insignificant number of terms that don't have a reverse set but DO have a standout mode set. There is only one (that I saw) that has a reverse set but no standout mode. So a proposed change: if
(Sorry to make a little more work for you @DivineGod) Here's the script I made to check it out (also shows if terms have an italics or dim capability): |
FWIW, if you download the ncurses sources and compile it, there are some rather handy test utilities in the |
(Also, your proposition does seem like a good idea to me. Standout mode is a decent fallback, and we want to prefer true reverse video mode which has no side effects.) |
I notice that these attributes don't seem to work when set on |
What @floam noticed here is that these options haven't been hooked up in the highlighter (highlight.cpp) yet. That means they won't be usable as values for $fish_color_* variables that are directly used by it, e.g. $fish_color_escape. |
Ok, since I really would like this PR added, here's a patch for you @DivineGod. It patches color.h, highlight.cpp, and output.cpp. It should fix the issue with the highlighter. You should be able to download it and Note for the devs: I added flags to Here's the patch: |
@Darkshadow2 I've added your patch in and it works nicely. |
I'm OK with this now. Maybe @ridiculousfish should look it over, but I'm OK with merging it. What's still left to be done is figuring out how to make it work for Apple_Terminal, or maybe other terminals out there with missing terminfo defintions, but I'm ok with deferring that to be a later PR. Thanks both of you, @DivineGod and @Darkshadow2. |
So, it was merged yesterday, all rejoice! Thanks folks. |
I finally did this: 635e714 (iTerm as well.) |
rgb_color_t was 5 bytes, now it's 4 again. big arrays holding colors are going to be smaller.
Description
I wanted to be able to use
(set_color -i)
and(set_color -d)
to display text as italics and dimmed respectively. In terminals supporting these the effect will be that text is either italic or dimmed.Make sure that the terminfo used contains the appropriate configuration. Here is an example terminfo file:
TODOs: