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

@@ -4,7 +4,6 @@
from kitty.config import defaults
from kitty.fast_data_types import DECAWM, DECCOLM, DECOM, IRM, VT_PARSER_BUFFER_SIZE, Color, ColorProfile, Cursor
from kitty.marks import marker_from_function, marker_from_regex
from kitty.rgb import color_names
from kitty.window import pagerhist
from . import BaseTest, draw_multicell, parse_bytes
@@ -1578,7 +1577,8 @@ class TestScreen(BaseTest):
q({k: '?' for k in 'background foreground 213 unknown'.split()}, {
'background': defaults.background, 'foreground': defaults.foreground, '213': defaults.color213, 'unknown': '?'})
q({'background':'aquamarine'})
q({'background':'?', 'selection_background': '?'}, {'background': color_names['aquamarine'], 'selection_background': s.color_profile.highlight_bg})
q({'background':'?', 'selection_background': '?'}, {
'background': Color.parse_color('Aquamarine'), 'selection_background': s.color_profile.highlight_bg})
q({'selection_background': ''})
self.assertIsNone(s.color_profile.highlight_bg)
q({'selection_background': '?'}, {'selection_background': ''})