ncurses: friendly colors
It was a lot easier than I thought. English color names such as green and red can be converted to their constant names (thanks to Sup):
Using this simple line of code, one may maintain a hash containing color_pairs for whatever colors are in use. Whenever, a color is requested, one returns it from the hash , or creates a new one.
Thus, as may be seen in these samples, we can set or modify a widgets foreground or background color using:
color "green" bgcolor "red"
In example 1, the password field has a red foreground and blue background set at startup. “show” means that for every character entered an asterisk will be displayed.
@form.by_name["password"].show '*' @form.by_name["password"].color 'red' @form.by_name["password"].bgcolor 'blue'
Notice also that “Select a color” is cyan, and red and green radio buttons are .. red and green.
In example 2, I have checked the checkbox and selected red. The label “Select a color” has become bold and red.
In example 3, I have checked our new CheckBoxMenuItem, and doing so has made the label reverse-video.