Skip to content

Commit 63128cf

Browse files
committed
[docs] mention semantic() color
Related to #1653
1 parent 762cace commit 63128cf

6 files changed

Lines changed: 28 additions & 18 deletions

docs/schemas/config-v1.schema.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1400,17 +1400,18 @@
14001400
},
14011401
"color": {
14021402
"title": "/color",
1403-
"description": "The foreground color value for this style. The value can be the name of an xterm color, the hexadecimal value, or a theme variable reference.",
1403+
"description": "The foreground color value for this style. The value can be the name of an xterm color, the hexadecimal value, a theme variable reference, or 'semantic()' to derive the color from a hash of the matched text.",
14041404
"type": "string",
14051405
"examples": [
14061406
"#fff",
14071407
"Green",
1408-
"$black"
1408+
"$black",
1409+
"semantic()"
14091410
]
14101411
},
14111412
"background-color": {
14121413
"title": "/background-color",
1413-
"description": "The background color value for this style. The value can be the name of an xterm color, the hexadecimal value, or a theme variable reference.",
1414+
"description": "The background color value for this style. The value can be the name of an xterm color, the hexadecimal value, a theme variable reference, or 'semantic()' to derive the color from a hash of the matched text.",
14141415
"type": "string",
14151416
"examples": [
14161417
"#2d2a2e",

docs/schemas/format-v1.schema.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -965,17 +965,18 @@
965965
},
966966
"color": {
967967
"title": "/color",
968-
"description": "The foreground color value for this style. The value can be the name of an xterm color, the hexadecimal value, or a theme variable reference.",
968+
"description": "The foreground color value for this style. The value can be the name of an xterm color, the hexadecimal value, a theme variable reference, or 'semantic()' to derive the color from a hash of the matched text.",
969969
"type": "string",
970970
"examples": [
971971
"#fff",
972972
"Green",
973-
"$black"
973+
"$black",
974+
"semantic()"
974975
]
975976
},
976977
"background-color": {
977978
"title": "/background-color",
978-
"description": "The background color value for this style. The value can be the name of an xterm color, the hexadecimal value, or a theme variable reference.",
979+
"description": "The background color value for this style. The value can be the name of an xterm color, the hexadecimal value, a theme variable reference, or 'semantic()' to derive the color from a hash of the matched text.",
979980
"type": "string",
980981
"examples": [
981982
"#2d2a2e",

docs/source/config.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,9 @@ the values from the :code:`styles/text` definition.
143143
picked based on the `CIEDE2000 <https://en.wikipedia.org/wiki/Color_difference#CIEDE2000>`_
144144
color difference algorithm.
145145

146+
The special value :code:`semantic()` can also be used in place of a color.
147+
The displayed color is derived from a hash of the text to create a stable,
148+
distinguishable color.
146149

147150

148151
Example

src/styling.cc

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,21 +72,24 @@ const json_path_container style_config_handlers =
7272
.with_description("How to align text within a cell")
7373
.for_field(&style_config::sc_text_align),
7474
yajlpp::property_handler("color")
75-
.with_synopsis("#hex|color_name")
75+
.with_synopsis("#hex|color_name|semantic()")
7676
.with_description(
7777
"The foreground color value for this style. The value can be "
78-
"the name of an xterm color, the hexadecimal value, or a theme "
79-
"variable reference.")
78+
"the name of an xterm color, the hexadecimal value, a theme "
79+
"variable reference, or 'semantic()' to derive the color from "
80+
"a hash of the matched text.")
8081
.with_example("#fff"_frag)
8182
.with_example("Green"_frag)
8283
.with_example("$black"_frag)
84+
.with_example("semantic()"_frag)
8385
.for_field(&style_config::sc_color),
8486
yajlpp::property_handler("background-color")
85-
.with_synopsis("#hex|color_name")
87+
.with_synopsis("#hex|color_name|semantic()")
8688
.with_description(
8789
"The background color value for this style. The value can be "
88-
"the name of an xterm color, the hexadecimal value, or a theme "
89-
"variable reference.")
90+
"the name of an xterm color, the hexadecimal value, a theme "
91+
"variable reference, or 'semantic()' to derive the color from "
92+
"a hash of the matched text.")
9093
.with_example("#2d2a2e"_frag)
9194
.with_example("Green"_frag)
9295
.for_field(&style_config::sc_background_color),

test/expected/test_config.sh_a0907769aba112d628e7ebe39c4ec252e5e0bc69.err

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
 |  "bad-property": "abc"
44
 = help: Available Properties
55
text-align start|center|end
6-
color #hex|color_name
7-
background-color #hex|color_name
6+
color #hex|color_name|semantic()
7+
background-color #hex|color_name|semantic()
88
underline
99
bold
1010
italic
@@ -78,13 +78,14 @@
7878
 |  reason: Unknown color: 'InvalidColor'. See https://jonasjacek.github.io/colors/ for a list of supported color names
7979
 --> {test_dir}/bad-config2/configs/invalid-theme/config.json:8
8080
 = help: Property Synopsis
81-
/ui/theme-defs/invalid-theme/styles/text/color #hex|color_name
81+
/ui/theme-defs/invalid-theme/styles/text/color #hex|color_name|semantic()
8282
Description
83-
The foreground color value for this style. The value can be the name of an xterm color, the hexadecimal value, or a theme variable reference.
83+
The foreground color value for this style. The value can be the name of an xterm color, the hexadecimal value, a theme variable reference, or 'semantic()' to derive the color from a hash of the matched text.
8484
Examples
8585
#fff
8686
Green
8787
$black
88+
semantic()
8889
✘ error: invalid value for property “/ui/theme”
8990
reason: unknown theme -- “foo”
9091
 |   = help: The available themes are: default, dracula, eldar, grayscale, invalid-theme, modus-operandi, monocai, night-owl, solarized-dark, solarized-light

test/expected/test_config.sh_d622658dc98327b1b2fd346802d24bc633e34ac7.err

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
 |  reason: Could not parse color: #f
44
 --> command-option:1
55
 = help: Property Synopsis
6-
/ui/theme-defs/default/styles/text/color #hex|color_name
6+
/ui/theme-defs/default/styles/text/color #hex|color_name|semantic()
77
Description
8-
The foreground color value for this style. The value can be the name of an xterm color, the hexadecimal value, or a theme variable reference.
8+
The foreground color value for this style. The value can be the name of an xterm color, the hexadecimal value, a theme variable reference, or 'semantic()' to derive the color from a hash of the matched text.
99
Examples
1010
#fff
1111
Green
1212
$black
13+
semantic()

0 commit comments

Comments
 (0)