-
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
set_color updates for bright colors, fixes for low/no-color terminals #3260
Conversation
return str | ||
str = str.toLowerCase(); | ||
if (str == 'black') return '000000'; | ||
if (str == 'red') return '800000'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't it be nice here to be consistent with other programs, particularly terminals?
From wikipedia, it seems X will use F00 for red, but 008000 for green and 00F for blue, like we currently do. Xterm is a bit weirder.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are good arguments for matching another terminal or some tangible standard. However if we might ever do something like let set_color red
apply a 24bit color code instead of one of these 16 colors, I think there are better arguments for very carefully picking out a great set of preferred colors that work well on both dark and light terminals to make the color contrasts a bit easier on the eyes.
In the case above though, I was just going by this table, except for the colors which I left in for the sake of compatibility at their prior values that do not actually exist as named colors in ANSI (brown, purple, grey). I'm happy with using any values we can agree on.
http://www.calmar.ws/vim/256-xterm-24bit-rgb-color-chart.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Huh, those few colors in the bright column for X are surprising (in a good way.) They're actually quite near what I end up using in my terminal configurations instead of full blast green and blue.
The documentation changes are a definite ACK, and I think I'm okay with white->grey. I'd prefer it if we still accepted "grey" as an alternative name - I'll have to test this a bit, particularly in a VT. |
ACK? |
We do. What I decided to do was remove them from the documentation and hide them from the color list but make sure |
http://www.catb.org/jargon/html/A/ACK.html, meaning 4. You really need to grow your beard 😃. Okay, in a VT this seems to "just work" - In a monochrome TERM=vt100, this hits #2951 in full force.
Sorry, I should have tried before. I'm not sure if we shouldn't stick a note in the docs - "For compatibility, 'grey' is accepted as a synonym for white". Not having it in the list is probably right, though. |
@@ -37,15 +37,20 @@ static int (*out)(char c) = writeb_internal; | |||
/// Whether term256 and term24bit are supported. | |||
static color_support_t color_support = 0; | |||
|
|||
|
|||
/// Set the function used for writing in move_cursor, writespace and set_color and all other output |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's up with the three "/" here? I see they've been here before, but why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are HeaderDoc comments.
What result does the monochrome terminal give for |
"-1".
It prints nothing, which is annoying in combination with the cartesian product - (Also I've noticed that, when I give |
Hm, set_color probably shouldn't print a newline, any character that isn't whitespace? What would be a good one that would effectively be a NOP and not take a column or cause a linebreak on a vt100? |
Why not?
Which do you have in mind? I'm leaning towards a '\n' because that's the most-used character at the end of a programs output, so it seems to be the least likely to cause issues. Also it'd work (by being eliminated) in a command substitution, which is how Compare: echo (printf '\n')banana | od -t x1z
echo (printf '\r')banana | od -t x1z And non-ASCII characters are right out here (haven't seen a vt100 with emoji support yet). |
Isn't that going to... add a spurious linebreak scripts were not expecting when there isn't the cartesian product thing happening? |
I was thinking something like an escape sequence that does nothing. |
You're right. I was under the impression we'd reset the terminal mode between commands, but we only do that for the prompt (which is why running
Maybe the "reset" sequence ( |
|
@@ -299,26 +299,6 @@ function __fish_config_interactive -d "Initializations that should be performed | |||
set -g fish_pager_color_description yellow | |||
set -g fish_pager_color_progress cyan | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do I understand correctly that what this deleted function used to do (per commit f71e877 ) is now handled by the builtin set_color? That seems good if so.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not exactly. It does not mask off certain arguments for TERM=linux
(or TERM=vt100
), but the goal is it will work on a VT by not throwing escapes at it that are problematic. It silently might just do something other than try to set the color they asked for.
OK, I think 6d12fbe should stop causing the empty output with |
Is that OK? (Because that's only set when you're actually in Konsole?) |
0115a6a
to
ecb40a4
Compare
.... should make the #3260 diff shorter.
20e7f08
to
7276eff
Compare
e360c0b
to
464db16
Compare
Ok, merging this. Hopefully we can shake out any bugs prior to release. The final TODO I'm hammering on to be committed later, brights for "8" color terminals.
|
4d50178
to
63046c6
Compare
Adds a color reset thing, to ensure fish tries to use hard colors during testing. Also, work on a discrepancy (not introduced by my changes, afaik) when with some combinations of color settings, and usage of --bold, caused super flakey color paninting in the pager. Downwards movements that trigger scrolling vs. upwards movement in the pager would only apply bold to selections when moving upwards. The bold state of the command completions in the pager was flipping flops on and off, depending on if there is a description on the preceding line. Implement a lame fix by reseting the color to normal and applying a different style on the rightmost ')' which seems to be what was influencing it. Makes fish use terminfo for coloring the newline glich char.
set -U fish_greeting $line1\n$line2 | ||
# | ||
if not set -q __fish_init_2_39_8 # bump this to 2_4_0 when rolling release if anything changes after 9/10/2016 | ||
set -g colors_backup "$HOME/fish_previous_colors-(date).txt" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does not properly insert the date. The file is literally named fish_previous_colors-\(date\).txt
. I don't think this was indented, was it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not only that but even if we supported command substitution inside quoted strings it is generally a bad idea to use the user locale for formatting the date in this type of context. It's almost always a better to use a fixed format such as ISO 8601. I'll take care of it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why? it's just intended to be manually noticed by a developer with ls
and not clobber old backups (hmm, I forgot noclobber and it bit me!) - not automatically restored or anything. Don't invest too much time in it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could also just put (random) in there. The file birth date will keep the needed information.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for fixing it.
What we should probably just do is keep an init routine that will run on upgrade to 2.4.0, but what it does instead of "normalizing" colors (sorry, was a joke) by deleting them is replace previous names it encounters with the correct names. grey -> white That should prevent us from "teaching" deprecated color names through our defaults, and fix it so that colors display like how they did before this patch. |
Actually, I should check: did we adjust the defaults after doing our "white now refers to bright white/FF FF FF, normal white is called 'grey' now" change which this PR walked back? If no, then we could just leave those as is and they'll return to the behavior as designed finally. edit: Looks like no |
Description
In #3176 I noticed that the reason the addition of bright colors was also causing issues with
TERM=xterm
(on modern terminals), was that fish would generate invalid ANSI:We assumed that it we could use tparm to emit color escapes as long as the color was under 16 or
max_colors
from terminfo was 256:But if a terminal has
max_colors
(terminfo) of, say, 8, here is what will occur as it is asked for a number higher than that (excepttparm
did the same thing in output.cpp):The first escape is good, that second escape is not valid. Bright colors should start at
\e[90m
:This is what caused "white" not to work in #3176 in Terminal.app. (On real 8-color terminals the bigger issue was that
white
should cause color 7, not color 15, addressed below)So we replace the
< 16 || term256_support_is_native()
, with the latter function just checking ifmax_colors
is 256 or not, with a function that takes anint
and checks terminfo for the. colors supported by the terminal (really, we care thattparm
can be expected not to output garbage.)If terminfo can't do it, the "forced" escapes no longer use the fancy format when handling colors under 16, as this is not going to be compatible with low color terminals. The code before used:
I added an intermediate format for colors 0-15:
The PR also fixes the definition of color white, fixes color values for all colors. The non-brights were defined with the bright values and brights had something invented by fish. e.g.
FF0000
for red (instead of800000
) andFF5555
for brred (instead ofFF0000
).I got rid of the hack in config.fish. For #2951, one thing we should do is decide if we really want to send ANSI at terminals with
max_colors <= 8
, if no, solve it in C++?Fixes #3176, #2951
TODOs: