nano color yellow

Hello.
I make syntax highlighting in nginx.
I choose a yellow color.
After that, I look at the syntax highlight in nginx.conf and it appears more likely red / brown than yellow.
Who has the same problem?
Code:
cat /usr/local/share/nano/nginx.nanorc
syntax "nginx" "nginx.*\.conf$" "\.nginx$"
comment "#"

## Comments:
color green "#.*"
#
color yellow "(server|http|events) \{"
color yellow "}"
color yellow "location (.+)\{$"
Code:
nano -V
 GNU nano, version 4.9.2

Code:
uname -rms
FreeBSD 11.3-RELEASE-p9 amd64

On a Linux system, checked in nano yellow is displayed as yellow.
Linux system nano version 4.6
Screenshot attached to the topic.
 

Attachments

  • 000000.png
    000000.png
    58.4 KB · Views: 154
It looks like it might be your WM/DE's theme or the color scheme of the terminal app that's changing the actual color of the color code. Have a look on a plain console (not a terminal app) to see if it's really yellow there.
 
It looks like it might be your WM/DE's theme or the color scheme of the terminal app that's changing the actual color of the color code. Have a look on a plain console (not a terminal app) to see if it's really yellow there.
Server is remote.
I don’t want to get into KVM for this.
Why, then, on Linux, the server shows yellow, but does not want to show on the FreeBSD.
Through one and the same console I open.
 
You are using a command-line application here. Those typically use the ANSI color selection mechanism, which comes from the 1970s or 1980s, and was intended for serial-port connected terminals (starting with the VT2xx series of terminals). Today it is implemented in terminal emulators. They have only 8 colors they can select, including foreground and background (typically black on white, or white on black). That makes for 6 independent colors, which are red, green, blue, yellow, magenta, and cyan. In addition, each of the colors can be selected to be "bold". Bold can be implemented by using a heavier font (more foreground pixels), or by brighter colors; typically terminal emulators running on a full-function GUI use heavier fonts. Typically, terminal emulators have a way to configure what color you want to see for each of the 8 (or 2*8) colors.

The color yellow is particularly problematic. If we select a really bright yellow (full red and green, little blue), that color is hard to distinguish from white for the human eye. Terminal emulators don't know whether you are using a black background or white background. They often select a brownish or orangish color for yellow, so it is clearly visible on both a dark and light background. Different terminal emulators are more or less extreme in these choices. The Linux and FreeBSD consoles are intended to run with a black background, so they tend to pick very bright colors for yellow, that's why Sir Dice's advice above.

The same problem exists to some extent with cyan, which is also very bright; less so for magenta, which (due to the lack of green) is more easily distinguishable from white. The problem becomes extreme for the two shades of black and white, which on some emulators and some settings are not distinguishable from the background at all.

In reality, you have two choices: The easy one is to simply stay away from yellow, and use only the default foreground color, plus the five that are usually well visible (red, green, blue, cyan, magenta). The second one is to go into the configuration of your particular terminal emulator and adjust the definition of "yellow" in there to be to your taste, in particular to your choice of dark or light background.
 
And how then to redefine color in csh?
Code:
.cshrc
set yellow="%{\033[1;33m%}"
cannot redefine color.
 
Code:
#!/bin/csh
colred ()
{
printf '\033[1;33m'
}
colnormal ()
{
  printf '\033[1;93m'
}

# begin

printf "This is "
colred
printf "yellow"
colnormal
printf ", Bright Yellow?\n"

printf '\033[0m'

The screenshot attached to the message.
Yellow is displayed normally.
How now to achieve that in nano it is also displayed?
 

Attachments

  • 000000.png
    000000.png
    3.3 KB · Views: 119
OK, it's getting more complicated. You have demonstrated that if you select yellow (33) it is reasonably bright. And I had forgotten that modern ANSI includes bright yellow (code 93), which is distinct from bold yellow (1;33). That means that nano is not using those.

Now, in theory some terminal emulators allow full 8-bit and 24-bit color. It could be that this is what nano is using. I don't know which terminal emulators support that. Here's my suggestion: Run nano with tracing of all system calls turned on (using truss), then read the output to see what escape sequences nano is really using. At this point, this becomes a seriously heavyweight task.
 
OK, it's getting more complicated. You have demonstrated that if you select yellow (33) it is reasonably bright. And I had forgotten that modern ANSI includes bright yellow (code 93), which is distinct from bold yellow (1;33). That means that nano is not using those.

Now, in theory some terminal emulators allow full 8-bit and 24-bit color. It could be that this is what nano is using. I don't know which terminal emulators support that. Here's my suggestion: Run nano with tracing of all system calls turned on (using truss), then read the output to see what escape sequences nano is really using. At this point, this becomes a seriously heavyweight task.
So color 33 is fine in my system console is displayed.
Both colors 33 and 93 in the csh terminal are displayed normally (yellow traditional)).

'\033[1;33m'
'\033[1;93m'

Wrote a ticket to nano developers.
 
Solved the problem with a crutch.
For some reason, in xfce4-terminal, when opening nano, the color chosen was not yellow, but brown-yellow.
In the terminal settings, xfce4-terminal changed the color palette / gamut, brown yellow to a gamut closer to yellow.
Yellow is now shining in nano. )
 
Back
Top