-
Notifications
You must be signed in to change notification settings - Fork 245
Colors
Alexandre Bury edited this page Jul 1, 2016
·
2 revisions
Cursive has a flexible coloring module, to allow easy customization while keeping a unified look.
To achieve this, a theme will define a palette of colors to be used through the entire application. These colors are:
-
background
: used to color the application background (around views). Defaults to blue. -
shadow
: used to color shadow around views. Defaults to black. -
view
: used to color the background for views. Defaults to white. -
primary
: used to print primary text. Defaults to black. -
secondary
: used to print secondary text. Defaults to blue. -
tertiary
: used to print tertiary text. Defaults to white. -
title_primary
: used to print primary titles. Defaults to red. -
title_secondary
: used to print secondary titles. Defaults to yellow. -
highlight
: used to highlight selected items. Defaults to red. -
highlight_inactive
: used to highlight selected but inactive items. Defaults to blue.
These colors are then used in pairs (foreground and background) to define some color styles:
-
Background
: style used to print the application background.- Its background color is
background
. - Its foreground color is unimportant as no characters are ever printed in the background.
- Its background color is
-
Shadow
: style used to print shadows behind views.- Its background color is
shadow
. - Here again, the foreground color is unimportant.
- Its background color is
-
Primary
: style used to print primary text.- Its background color is
view
. - Its foreground color is
primary
.
- Its background color is
-
Secondary
: style used to print secondary text.- Its background color is
view
. - Its foreground color is
secondary
.
- Its background color is
-
Tertiary
: style used to print tertiary text.- Its background color is
view
. - Its foreground color is
tertiary
.
- Its background color is
-
TitlePrimary
: style used to print titles.- Its background color is
view
. - Its foreground color is
title_primary
.
- Its background color is
-
TitleSecondary
: style used to print secondary titles.- Its background color is
view
. - Its foreground color is
title_secondary
.
- Its background color is
-
Highlight
: style used to print selected items.- Its background color is
highlight
. - Its foreground color is
view
.
- Its background color is
-
HighlightInactive
: style used to print selected, but inactive items.- Its background color is
highlight_inactive
. - Its foreground color is
view
.
- Its background color is
On top of a color style, some effects can be applied, like Reverse
, which swaps the foreground and background colors.
Users then simply select the color style and effects they want to use for each part of the application, and the corresponding colors from the theme are applied.
- The color palette is read from the configuration file (or the default one is used).
- At this point, colors are downcasted to the best compatible one.
- This mean stick to 8 colors on TTY
- Ideally, this also means trying true colors, or sticking to 256 colors.
- At this point, colors are downcasted to the best compatible one.
- When text is printed on the screen, the printer is given a color role.
- ncurses only needs this color pair, as it saves a mapping to colors internally
- termion wants the foreground/background color everytime.
- solution: have the termion wrapper save its own map of roles to color pairs?