Keep the list of nullable colors up to date automatically
This commit is contained in:
parent
4839cbe9d0
commit
1251f9ec80
@ -3,12 +3,28 @@
|
||||
# License: GPLv3 Copyright: 2021, Kovid Goyal <kovid at kovidgoyal.net>
|
||||
|
||||
|
||||
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)
|
||||
|
||||
|
||||
@ -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
|
||||
)
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user