Rename parsing placeholders for actions
This commit is contained in:
parent
43acf3c5b1
commit
dd5715ce79
@ -840,7 +840,7 @@ def compare_opts(opts: OptionsStub) -> None:
|
|||||||
from .config import defaults, load_config
|
from .config import defaults, load_config
|
||||||
print('\nConfig options different from defaults:')
|
print('\nConfig options different from defaults:')
|
||||||
default_opts = load_config()
|
default_opts = load_config()
|
||||||
ignored = ('key_definitions', 'keymap', 'sequence_map', 'mousemap', 'mouse_mappings')
|
ignored = ('keymap', 'sequence_map', 'mousemap', 'map', 'mouse_map')
|
||||||
changed_opts = [
|
changed_opts = [
|
||||||
f for f in sorted(defaults._fields) # type: ignore
|
f for f in sorted(defaults._fields) # type: ignore
|
||||||
if f not in ignored and getattr(opts, f) != getattr(defaults, f)
|
if f not in ignored and getattr(opts, f) != getattr(defaults, f)
|
||||||
|
|||||||
@ -48,13 +48,13 @@ def deprecated_handler(*names: str) -> Callable[[SpecialHandlerFunc], SpecialHan
|
|||||||
@special_handler
|
@special_handler
|
||||||
def handle_map(key: str, val: str, ans: Dict[str, Any]) -> None:
|
def handle_map(key: str, val: str, ans: Dict[str, Any]) -> None:
|
||||||
for k in parse_map(val):
|
for k in parse_map(val):
|
||||||
ans['key_definitions'].append(k)
|
ans['map'].append(k)
|
||||||
|
|
||||||
|
|
||||||
@special_handler
|
@special_handler
|
||||||
def handle_mouse_map(key: str, val: str, ans: Dict[str, Any]) -> None:
|
def handle_mouse_map(key: str, val: str, ans: Dict[str, Any]) -> None:
|
||||||
for ma in parse_mouse_map(val):
|
for ma in parse_mouse_map(val):
|
||||||
ans['mouse_mappings'].append(ma)
|
ans['mouse_map'].append(ma)
|
||||||
|
|
||||||
|
|
||||||
@special_handler
|
@special_handler
|
||||||
@ -84,7 +84,7 @@ def handle_send_text(key: str, val: str, ans: Dict[str, Any]) -> None:
|
|||||||
@special_handler
|
@special_handler
|
||||||
def handle_clear_all_shortcuts(key: str, val: str, ans: Dict[str, Any]) -> None:
|
def handle_clear_all_shortcuts(key: str, val: str, ans: Dict[str, Any]) -> None:
|
||||||
if to_bool(val):
|
if to_bool(val):
|
||||||
ans['key_definitions'] = [None]
|
ans['map'] = [None]
|
||||||
|
|
||||||
|
|
||||||
@deprecated_handler('x11_hide_window_decorations', 'macos_hide_titlebar')
|
@deprecated_handler('x11_hide_window_decorations', 'macos_hide_titlebar')
|
||||||
@ -117,8 +117,8 @@ def option_names_for_completion() -> Generator[str, None, None]:
|
|||||||
|
|
||||||
def parse_config(lines: Iterable[str], check_keys: bool = True, accumulate_bad_lines: Optional[List[BadLine]] = None) -> Dict[str, Any]:
|
def parse_config(lines: Iterable[str], check_keys: bool = True, accumulate_bad_lines: Optional[List[BadLine]] = None) -> Dict[str, Any]:
|
||||||
ans: Dict[str, Any] = {
|
ans: Dict[str, Any] = {
|
||||||
'symbol_map': {}, 'keymap': {}, 'sequence_map': {}, 'key_definitions': [],
|
'symbol_map': {}, 'keymap': {}, 'sequence_map': {}, 'map': [],
|
||||||
'env': {}, 'kitten_alias': {}, 'font_features': {}, 'mouse_mappings': [],
|
'env': {}, 'kitten_alias': {}, 'font_features': {}, 'mouse_map': [],
|
||||||
'mousemap': {}
|
'mousemap': {}
|
||||||
}
|
}
|
||||||
defs: Optional[FrozenSet] = None
|
defs: Optional[FrozenSet] = None
|
||||||
@ -152,7 +152,7 @@ def merge_configs(defaults: Dict, vals: Dict) -> Dict:
|
|||||||
if isinstance(v, dict):
|
if isinstance(v, dict):
|
||||||
newvals = vals.get(k, {})
|
newvals = vals.get(k, {})
|
||||||
ans[k] = merge_dicts(v, newvals)
|
ans[k] = merge_dicts(v, newvals)
|
||||||
elif k in ('key_definitions', 'mouse_mappings'):
|
elif k in ('map', 'mouse_map'):
|
||||||
ans[k] = v + vals.get(k, [])
|
ans[k] = v + vals.get(k, [])
|
||||||
else:
|
else:
|
||||||
ans[k] = vals.get(k, v)
|
ans[k] = vals.get(k, v)
|
||||||
@ -231,7 +231,7 @@ def prepare_config_file_for_editing() -> str:
|
|||||||
|
|
||||||
def finalize_keys(opts: OptionsStub) -> None:
|
def finalize_keys(opts: OptionsStub) -> None:
|
||||||
defns: List[KeyDefinition] = []
|
defns: List[KeyDefinition] = []
|
||||||
for d in getattr(opts, 'key_definitions'):
|
for d in getattr(opts, 'map'):
|
||||||
if d is None: # clear_all_shortcuts
|
if d is None: # clear_all_shortcuts
|
||||||
defns = []
|
defns = []
|
||||||
else:
|
else:
|
||||||
@ -262,7 +262,7 @@ def finalize_keys(opts: OptionsStub) -> None:
|
|||||||
|
|
||||||
def finalize_mouse_mappings(opts: OptionsStub) -> None:
|
def finalize_mouse_mappings(opts: OptionsStub) -> None:
|
||||||
defns: List[MouseMapping] = []
|
defns: List[MouseMapping] = []
|
||||||
for d in getattr(opts, 'mouse_mappings'):
|
for d in getattr(opts, 'mouse_map'):
|
||||||
if d is None: # clear_all_shortcuts
|
if d is None: # clear_all_shortcuts
|
||||||
defns = []
|
defns = []
|
||||||
else:
|
else:
|
||||||
@ -287,8 +287,8 @@ def load_config(*paths: str, overrides: Optional[Iterable[str]] = None, accumula
|
|||||||
finalize_mouse_mappings(opts)
|
finalize_mouse_mappings(opts)
|
||||||
# delete no longer needed definitions, replacing with empty placeholders
|
# delete no longer needed definitions, replacing with empty placeholders
|
||||||
setattr(opts, 'kitten_alias', {})
|
setattr(opts, 'kitten_alias', {})
|
||||||
setattr(opts, 'mouse_mappings', [])
|
setattr(opts, 'mouse_map', [])
|
||||||
setattr(opts, 'key_definitions', [])
|
setattr(opts, 'map', [])
|
||||||
if opts.background_opacity < 1.0 and opts.macos_titlebar_color:
|
if opts.background_opacity < 1.0 and opts.macos_titlebar_color:
|
||||||
log_error('Cannot use both macos_titlebar_color and background_opacity')
|
log_error('Cannot use both macos_titlebar_color and background_opacity')
|
||||||
opts.macos_titlebar_color = 0
|
opts.macos_titlebar_color = 0
|
||||||
|
|||||||
@ -949,4 +949,4 @@ def deprecated_send_text(key: str, val: str, ans: Dict[str, Any]) -> None:
|
|||||||
text = ' '.join(parts[2:])
|
text = ' '.join(parts[2:])
|
||||||
key_str = '{} send_text {} {}'.format(sc, mode, text)
|
key_str = '{} send_text {} {}'.format(sc, mode, text)
|
||||||
for k in parse_map(key_str):
|
for k in parse_map(key_str):
|
||||||
ans['key_definitions'].append(k)
|
ans['map'].append(k)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user