# [color]How to change the default color set (for dialog and others ) ?



## Hakaba (May 3, 2020)

I am aware about the .dialogrc option to change the color

```
form_text_color = (WHITE,CYAN,ON)
```

But where can I change the value of CYAN or add my own colors ?

In the man page of dialog, I see :


> 0 through 7 are the ANSI used in curses: black, red,
> green, yellow, blue, magenta, cyan and white respectively.



Is there a link between this color and the 
	
	



```
kern.vt.color.<colornum>.rgb="<colorspec>"
```
(As I see vt in the option, it is maybe reserved to vt)

My final goal is to merge all my color definition through vt / dialog / dwm / st/ ... in one place.
Maybe you know a simplier way with a tool that already do that ?

Thanks


----------



## ralphbsz (May 3, 2020)

Layers ... ogres have layers    <- Quote from a movie.

Dialog is a command-line or shell tool. It uses a terminal, which these days in practice means a terminal emulator. Communication with terminals is text-based, not graphics: programs display characters, you type characters. Today, the set of characters one can display is pretty rich, for example "8.9°C χ²ₙ=0.35" (with special symbols for degree, chi, square, and subscript n). You can also display line drawing characters to make boxes.

Traditionally, command-line IO was a single color; typically white on a black background, or the other way around. Then in the 1980s came the first color terminals, and in particular Digital's trend-setting VT100 and VT200 terminals. They allowed changing the graphical rendering of characters to be bold, underlined, blinking, and particularly for this discussion, also color. That is done by sending a few extra control characters along, which say "print the next few characters in red" or "move the cursor to this place on the screen". Those control sequences are called the ANSI sequences, or escape sequences, or the VTxxx sequences. On a Linux machine, you can get a pretty complete list (with historic discussion) of them by doing "man console_codes"; I don't know any place in FreeBSD that documents them, but they're easy to find on the web.

The traditional set of ANSI sequences either is black and white, or uses 8 colors. And it allows displaying characters in reverse (on a bright or colored background) for highlighting. That's really easy to do, just to "echo esc [ 31 ; 42 m hallo esc [ 0 m" (with no spaces and an actual escape character), and you'll get red text on a green background. The 8 colors are pretty standardized, with 0 being the normal foreground color, 1 red, 2 green, 3 yellow, 4 blue, and then my memory gets foggy about magenta and cyan. Color 7 is the background color, and colors 0 and 7 are a bit problematic to use (because the definition of black/white gets often confused with the definition of foreground/background).

So far for traditional, 40-year old ANSI codes. This is what dialog, ncurses, emacs and vi and such programs use. Some of these programs can be configured as to what colors they use for what (for example, you found .dialogrc, which I've never heard of), some can not.

The next layer is the following: How are these 8 colors mapped to real RGB values? And this is where it gets complicated. That depends on how you are accessing the virtual terminal. On a non-virtual terminal, that mapping is done by the terminal hardware. I don't have any color terminal at home, but I still have two VT200 (clones), and 40 years ago, we were happy to get 8 colors, and didn't worry about exact color mapping. Different terminal emulators have different way of adjusting the 8 colors. You already found the sysctl settings for the FreeBSD vt console; I don't know how that's done in the sc console (both console terminal emulators exist, and you can switch between them). For the Linux console, that adjustment is done by ANSI sequences, and I think on modern VGA hardware, that will always work. If you are using a desktop with Xwindows, the adjustment depends on your exact emulator; I remember adjusting the colors for xterm in .Xresources, but these days there are way more terminal emulators. If you are accessing your FreeBSD machine remotely (like I do, from a Mac using iTerm), you need to look at the terminal emulator for color adjustment.

So the answer to your question is: it depends.


----------



## Hakaba (May 4, 2020)

Thanks for the detailled response. I found a lot of usefull information.
My goal is really to have a place to change color for all tools.

The dialog way is very bad: if I redefine the value of CYAN, I can have a red CYAN. Disturbing...

The vt way is maybe better and closer that I want to do.
The problem is that we don't know"what mean color #12"

I start a little project with a definition list associated to a RGB color and conversion tools.
The color names are based on https://tools.ietf.org/html/rfc5424. (Maybe I will change that idea)
Eg.

```
[name]                [id]        [RGB Value]
Backgound              1            #000000         // Default BG color
Background_alt          2            #333333         // Less contrasted BG color
[...]
Critical                  3            #990000         // Normal Critical color
Critical_strong          22        #ff0000         // Strong Critical color
[...]
```

So, assuming that vt only handle 15 colors, I will arrange the set to be usable with :
2,7,15 or more colors.
That mean ID1 is default background, id2 is default foreground, id3 is reserved to "Critical" (see Linguistic relativity and the color naming debate and I associated red to Critical...) and so on...

The id/color match in FreeBSD can be handle with the vt config. But how an I get the kern.vt.color configuration ? (It is not in dmesg -a)

I test to add more than 15 colors and nothing bad appends. So if I can get the configured value, I found a place to store id/code...



ralphbsz said:


> Layers ... ogres have layers


Like ognon, but you know, not everybody like onions.


----------

