# nano color yellow



## bagas (May 18, 2020)

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?

```
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 (.+)\{$"
```


```
nano -V
 GNU nano, version 4.9.2
```


```
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.


----------



## SirDice (May 18, 2020)

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.


----------



## bagas (May 18, 2020)

SirDice said:


> 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.


----------



## SirDice (May 18, 2020)

It's not "yellow" color you select, you select the ANSI color code for yellow.

Look at the brownish color of "yellow" here: https://en.wikipedia.org/wiki/ANSI_escape_code#3/4_bit


----------



## bagas (May 18, 2020)

SirDice said:


> It's not "yellow" color you select, you select the ANSI color code for yellow.
> 
> Look at the brownish color of "yellow" here: https://en.wikipedia.org/wiki/ANSI_escape_code#3/4_bit




```
color brightyellow "(server|http|events) \{"
color brightyellow "}"
color brightyellow "location (.+)\{$"
```
Redid for color brightyellow, the color is still the same.


----------



## ralphbsz (May 18, 2020)

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.


----------



## bagas (May 19, 2020)

And how then to redefine color in csh?

```
.cshrc
set yellow="%{\033[1;33m%}"
```
cannot redefine color.


----------



## bagas (May 19, 2020)

```
#!/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?


----------



## ralphbsz (May 19, 2020)

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.


----------



## bagas (May 19, 2020)

ralphbsz said:


> 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.


----------



## bagas (May 19, 2020)

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. )


----------

