Reload for keys, fonts and colors now working

This commit is contained in:
Kovid Goyal 2021-06-06 14:31:22 +05:30
parent 3ab417e291
commit 7148f262c0
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C
2 changed files with 14 additions and 5 deletions

View file

@ -1436,9 +1436,19 @@ def patch_colors(self, spec: Dict[str, int], cursor_text_color: Union[bool, int,
patch_global_colors(spec, configured)
def apply_new_options(self, opts: Options) -> None:
# Update options storage
set_options(opts, is_wayland(), self.args.debug_rendering, self.args.debug_font_fallback)
# Update font data
from .fonts.render import set_font_family
set_font_family(opts, debug_font_matching=self.args.debug_font_fallback)
for os_window_id, tm in self.os_window_map.items():
if tm is not None:
os_window_font_size(os_window_id, opts.font_size, True)
tm.resize()
# Update key bindings
self.update_keymap()
spec = opts._asdict()
# Update colors
spec = {k: int(v) if isinstance(v, Color) else v for k, v in opts._asdict().items()}
for tm in self.all_tab_managers:
tm.tab_bar.patch_colors(spec)
profiles = tuple(w.screen.color_profile for w in self.all_windows)
@ -1456,8 +1466,7 @@ def load_config(self, *paths: str, apply_overrides: bool = True) -> None:
opts = load_config(*paths, overrides=old_opts.config_overrides if apply_overrides else None, accumulate_bad_lines=bad_lines)
if bad_lines:
self.show_bad_config_lines(bad_lines)
else:
self.apply_new_options(opts)
self.apply_new_options(opts)
def safe_delete_temp_file(self, path: str) -> None:
if is_path_in_temp_dir(path):

View file

@ -309,8 +309,6 @@ def patch_colors(self, spec: Dict[str, Any]) -> None:
self.draw_data = self.draw_data._replace(active_bg=color_from_int(spec['active_tab_background']))
if 'inactive_tab_background' in spec:
self.draw_data = self.draw_data._replace(inactive_bg=color_from_int(spec['inactive_tab_background']))
if 'tab_bar_background' in spec:
self.draw_data = self.draw_data._replace(default_bg=color_from_int(spec['tab_bar_background']))
opts = get_options()
fg = spec.get('inactive_tab_foreground', color_as_int(opts.inactive_tab_foreground))
bg = spec.get('tab_bar_background', False)
@ -318,6 +316,8 @@ def patch_colors(self, spec: Dict[str, Any]) -> None:
bg = color_as_int(opts.background)
elif bg is False:
bg = color_as_int(opts.tab_bar_background or opts.background)
if 'tab_bar_background' in spec:
self.draw_data = self.draw_data._replace(default_bg=color_from_int(bg))
self.screen.color_profile.set_configured_colors(fg, bg)
def layout(self) -> None: