kitten_alias is also an is_multiple option
This commit is contained in:
@@ -23,8 +23,8 @@ from .constants import cache_dir, defconf, is_macos
|
|||||||
from .options_stub import Options as OptionsStub
|
from .options_stub import Options as OptionsStub
|
||||||
from .options_types import (
|
from .options_types import (
|
||||||
FuncArgsType, KeyDefinition, KeyMap, MouseMap, MouseMapping, SequenceMap,
|
FuncArgsType, KeyDefinition, KeyMap, MouseMap, MouseMapping, SequenceMap,
|
||||||
env, font_features, func_with_args, parse_map, parse_key_action,
|
env, font_features, func_with_args, kitten_alias, parse_key_action,
|
||||||
parse_mouse_map, symbol_map
|
parse_map, parse_mouse_map, symbol_map
|
||||||
)
|
)
|
||||||
from .typing import TypedDict
|
from .typing import TypedDict
|
||||||
from .utils import log_error
|
from .utils import log_error
|
||||||
@@ -390,9 +390,8 @@ def handle_font_features(key: str, val: str, ans: Dict[str, Any]) -> None:
|
|||||||
|
|
||||||
@special_handler
|
@special_handler
|
||||||
def handle_kitten_alias(key: str, val: str, ans: Dict[str, Any]) -> None:
|
def handle_kitten_alias(key: str, val: str, ans: Dict[str, Any]) -> None:
|
||||||
parts = val.split(maxsplit=2)
|
for k, v in kitten_alias(val):
|
||||||
if len(parts) >= 2:
|
ans['kitten_alias'][k] = v
|
||||||
ans['kitten_aliases'][parts[0]] = parts[1:]
|
|
||||||
|
|
||||||
|
|
||||||
@special_handler
|
@special_handler
|
||||||
@@ -457,7 +456,7 @@ 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': {}, 'key_definitions': [],
|
||||||
'env': {}, 'kitten_aliases': {}, 'font_features': {}, 'mouse_mappings': [],
|
'env': {}, 'kitten_alias': {}, 'font_features': {}, 'mouse_mappings': [],
|
||||||
'mousemap': {}
|
'mousemap': {}
|
||||||
}
|
}
|
||||||
defs: Optional[FrozenSet] = None
|
defs: Optional[FrozenSet] = None
|
||||||
@@ -575,11 +574,10 @@ def finalize_keys(opts: OptionsStub) -> None:
|
|||||||
defns = []
|
defns = []
|
||||||
else:
|
else:
|
||||||
defns.append(d)
|
defns.append(d)
|
||||||
kitten_aliases: List[Dict[str, Sequence[str]]] = getattr(opts, 'kitten_aliases')
|
|
||||||
for d in defns:
|
for d in defns:
|
||||||
d.resolve(opts.kitty_mod)
|
d.resolve(opts.kitty_mod)
|
||||||
if kitten_aliases and d.action.func == 'kitten':
|
if opts.kitten_alias and d.action.func == 'kitten':
|
||||||
d.resolve_kitten_aliases(kitten_aliases)
|
d.resolve_kitten_aliases(opts.kitten_alias)
|
||||||
keymap: KeyMap = {}
|
keymap: KeyMap = {}
|
||||||
sequence_map: SequenceMap = {}
|
sequence_map: SequenceMap = {}
|
||||||
|
|
||||||
@@ -611,7 +609,7 @@ def finalize_mouse_mappings(opts: OptionsStub) -> None:
|
|||||||
defns = []
|
defns = []
|
||||||
else:
|
else:
|
||||||
defns.append(d)
|
defns.append(d)
|
||||||
kitten_aliases: List[Dict[str, Sequence[str]]] = getattr(opts, 'kitten_aliases')
|
kitten_aliases: List[Dict[str, Sequence[str]]] = getattr(opts, 'kitten_alias')
|
||||||
for d in defns:
|
for d in defns:
|
||||||
d.resolve(opts.kitty_mod)
|
d.resolve(opts.kitty_mod)
|
||||||
if kitten_aliases and d.action.func == 'kitten':
|
if kitten_aliases and d.action.func == 'kitten':
|
||||||
@@ -635,7 +633,7 @@ def load_config(*paths: str, overrides: Optional[Iterable[str]] = None, accumula
|
|||||||
finalize_keys(opts)
|
finalize_keys(opts)
|
||||||
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_aliases', {})
|
setattr(opts, 'kitten_alias', {})
|
||||||
setattr(opts, 'mouse_mappings', [])
|
setattr(opts, 'mouse_mappings', [])
|
||||||
setattr(opts, 'key_definitions', [])
|
setattr(opts, 'key_definitions', [])
|
||||||
if opts.background_opacity < 1.0 and opts.macos_titlebar_color:
|
if opts.background_opacity < 1.0 and opts.macos_titlebar_color:
|
||||||
|
|||||||
@@ -18,12 +18,13 @@ from .options_types import (
|
|||||||
allow_remote_control, box_drawing_scale, clipboard_control,
|
allow_remote_control, box_drawing_scale, clipboard_control,
|
||||||
config_or_absolute_path, copy_on_select, cursor_text_color,
|
config_or_absolute_path, copy_on_select, cursor_text_color,
|
||||||
default_tab_separator, disable_ligatures, edge_width, env, font_features,
|
default_tab_separator, disable_ligatures, edge_width, env, font_features,
|
||||||
hide_window_decorations, macos_option_as_alt, macos_titlebar_color,
|
hide_window_decorations, kitten_alias, macos_option_as_alt,
|
||||||
optional_edge_width, resize_draw_strategy, scrollback_lines,
|
macos_titlebar_color, optional_edge_width, resize_draw_strategy,
|
||||||
scrollback_pager_history_size, symbol_map, tab_activity_symbol,
|
scrollback_lines, scrollback_pager_history_size, symbol_map,
|
||||||
tab_bar_edge, tab_bar_min_tabs, tab_fade, tab_font_style, tab_separator,
|
tab_activity_symbol, tab_bar_edge, tab_bar_min_tabs, tab_fade,
|
||||||
tab_title_template, to_cursor_shape, to_font_size, to_layout_names,
|
tab_font_style, tab_separator, tab_title_template, to_cursor_shape,
|
||||||
to_modifiers, url_prefixes, url_style, window_border_width, window_size
|
to_font_size, to_layout_names, to_modifiers, url_prefixes, url_style,
|
||||||
|
window_border_width, window_size
|
||||||
)
|
)
|
||||||
from .rgb import color_as_sharp, color_from_int
|
from .rgb import color_as_sharp, color_from_int
|
||||||
|
|
||||||
@@ -1068,7 +1069,7 @@ o('clear_all_shortcuts', False, long_text=_('''
|
|||||||
You can have kitty remove all shortcut definition seen up to this point. Useful, for
|
You can have kitty remove all shortcut definition seen up to this point. Useful, for
|
||||||
instance, to remove the default shortcuts.'''))
|
instance, to remove the default shortcuts.'''))
|
||||||
|
|
||||||
o('kitten_alias', 'hints hints --hints-offset=0', add_to_default=False, long_text=_('''
|
o('+kitten_alias', 'hints hints --hints-offset=0', option_type=kitten_alias, add_to_default=False, long_text=_('''
|
||||||
You can create aliases for kitten names, this allows overriding the defaults
|
You can create aliases for kitten names, this allows overriding the defaults
|
||||||
for kitten options and can also be used to shorten repeated mappings of the same
|
for kitten options and can also be used to shorten repeated mappings of the same
|
||||||
kitten with a specific group of options. For example, the above alias
|
kitten with a specific group of options. For example, the above alias
|
||||||
|
|||||||
@@ -389,6 +389,13 @@ def env(val: str, current_val: Dict[str, str]) -> Iterable[Tuple[str, str]]:
|
|||||||
yield key, expandvars(val, current_val)
|
yield key, expandvars(val, current_val)
|
||||||
|
|
||||||
|
|
||||||
|
def kitten_alias(val: str) -> Iterable[Tuple[str, List[str]]]:
|
||||||
|
parts = val.split(maxsplit=2)
|
||||||
|
if len(parts) >= 2:
|
||||||
|
name = parts.pop(0)
|
||||||
|
yield name, parts
|
||||||
|
|
||||||
|
|
||||||
def symbol_map(val: str) -> Iterable[Tuple[Tuple[int, int], str]]:
|
def symbol_map(val: str) -> Iterable[Tuple[Tuple[int, int], str]]:
|
||||||
parts = val.split()
|
parts = val.split()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user