Skip to content

Commit 7173d3b

Browse files
committed
Move parsing of colors fully into C
Uses a perfect hash function for color name lookup
1 parent e14e349 commit 7173d3b

File tree

11 files changed

+4728
-790
lines changed

11 files changed

+4728
-790
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ kitty/rgb.py linguist-generated=true
1111
kitty/srgb_gamma.* linguist-generated=true
1212
kitty/gl-wrapper.* linguist-generated=true
1313
kitty/glfw-wrapper.* linguist-generated=true
14+
kitty/color-names.h linguist-generated=true
1415
kitty/parse-graphics-command.h linguist-generated=true
1516
kitty/parse-multicell-command.h linguist-generated=true
1617
kitty/options/types.py linguist-generated=true

docs/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,15 +300,15 @@ def write_cli_docs(all_kitten_names: Iterable[str]) -> None:
300300

301301

302302
def write_color_names_table() -> None: # {{{
303-
from kitty.rgb import color_names
303+
from kitty.fast_data_types import all_color_names
304304
def s(c: Any) -> str:
305305
return f'{c.red:02x}/{c.green:02x}/{c.blue:02x}'
306306
with open('generated/color-names.rst', 'w') as f:
307307
p = partial(print, file=f)
308308
p('=' * 50, '=' * 20)
309309
p('Name'.ljust(50), 'RGB value')
310310
p('=' * 50, '=' * 20)
311-
for name, col in color_names.items():
311+
for name, col in all_color_names():
312312
p(name.ljust(50), s(col))
313313
p('=' * 50, '=' * 20)
314314
# }}}

gen/__main__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ def main(args: list[str]=sys.argv) -> None:
3434
elif which == 'cursors':
3535
from gen.cursors import main
3636
main(args)
37+
elif which == 'color-names':
38+
from gen.color_names import main
39+
main(args)
3740
else:
3841
raise SystemExit(f'Unknown which: {which}')
3942

0 commit comments

Comments
 (0)