diff --git a/gen-config.py b/gen-config.py index e2cc725ce..73b46660b 100755 --- a/gen-config.py +++ b/gen-config.py @@ -3,12 +3,28 @@ # License: GPLv3 Copyright: 2021, Kovid Goyal +import re from kitty.conf.generate import write_output def main() -> None: from kitty.options.definition import definition write_output('kitty', definition) + nullable_colors = [] + for opt in definition.iter_all_options(): + if callable(opt.parser_func) and opt.parser_func.__name__ in ('to_color_or_none', 'cursor_text_color'): + nullable_colors.append(opt.name) + with open('kitty/rc/set_colors.py', 'r+') as f: + raw = f.read() + nraw = re.sub( + r'(# NULLABLE_COLORS_START).+?(\s+# NULLABLE_COLORS_END)', + r'\1' + '\n ' + '\n '.join(map(lambda x: f'{x!r},', sorted(nullable_colors))) + r'\2', + raw, flags=re.DOTALL | re.MULTILINE) + if nraw != raw: + f.seek(0) + f.truncate() + f.write(nraw) + from kittens.diff.options.definition import definition as kd write_output('kittens.diff', kd) diff --git a/kitty/rc/set_colors.py b/kitty/rc/set_colors.py index 6a7de869b..3ae1c1dda 100644 --- a/kitty/rc/set_colors.py +++ b/kitty/rc/set_colors.py @@ -18,8 +18,15 @@ if TYPE_CHECKING: nullable_colors = ( - 'cursor', 'cursor_text_color', 'tab_bar_background', 'tab_bar_margin_color', - 'selection_foreground', 'selection_background', 'active_border_color' + # NULLABLE_COLORS_START + 'active_border_color', + 'cursor', + 'cursor_text_color', + 'selection_background', + 'selection_foreground', + 'tab_bar_background', + 'tab_bar_margin_color', + # NULLABLE_COLORS_END )