Use the new get_options() function

Nicer than carrying around opts objects everywhere
This commit is contained in:
Kovid Goyal
2021-05-24 12:29:11 +05:30
parent 253b219d67
commit c827a29a7b
11 changed files with 129 additions and 119 deletions

View File

@@ -40,7 +40,9 @@ configured colors.
return {'configured': opts.configured, 'match': opts.match}
def response_from_kitty(self, boss: Boss, window: Optional[Window], payload_get: PayloadGetType) -> ResponseType:
ans = {k: getattr(boss.opts, k) for k in boss.opts if isinstance(getattr(boss.opts, k), Color)}
from kitty.fast_data_types import get_options
opts = get_options()
ans = {k: getattr(opts, k) for k in opts if isinstance(getattr(opts, k), Color)}
if not payload_get('configured'):
windows = self.windows_for_match_payload(boss, window, payload_get)
ans.update({k: color_from_int(v) for k, v in windows[0].current_colors.items()})

View File

@@ -48,7 +48,8 @@ cause colors to be changed in all windows.
}
def response_from_kitty(self, boss: Boss, window: Optional[Window], payload_get: PayloadGetType) -> ResponseType:
if not boss.opts.dynamic_background_opacity:
from kitty.fast_data_types import get_options
if not get_options().dynamic_background_opacity:
raise OpacityError('You must turn on the dynamic_background_opacity option in kitty.conf to be able to set background opacity')
windows = self.windows_for_payload(boss, window, payload_get)
for os_window_id in {w.os_window_id for w in windows}:

View File

@@ -108,8 +108,9 @@ windows).
windows = self.windows_for_payload(boss, window, payload_get)
settings: Dict[str, Optional[float]] = payload_get('settings')
dirtied_tabs = {}
from kitty.fast_data_types import get_options
if payload_get('configured'):
patch_configured_edges(boss.opts, settings)
patch_configured_edges(get_options(), settings)
for w in windows:
patch_window_edges(w, settings)