Move parsing of colors fully into C

Uses a perfect hash function for color name lookup
This commit is contained in:
Kovid Goyal
2025-12-31 14:19:10 +05:30
parent e14e34948e
commit 573bfb688a
11 changed files with 4709 additions and 790 deletions

View File

@@ -300,7 +300,7 @@ if you specify a program-to-run you can use the special placeholder
def write_color_names_table() -> None: # {{{
from kitty.rgb import color_names
from kitty.fast_data_types import all_color_names
def s(c: Any) -> str:
return f'{c.red:02x}/{c.green:02x}/{c.blue:02x}'
with open('generated/color-names.rst', 'w') as f:
@@ -308,7 +308,7 @@ def write_color_names_table() -> None: # {{{
p('=' * 50, '=' * 20)
p('Name'.ljust(50), 'RGB value')
p('=' * 50, '=' * 20)
for name, col in color_names.items():
for name, col in all_color_names():
p(name.ljust(50), s(col))
p('=' * 50, '=' * 20)
# }}}