Store the paths from which config data is read on the created options object

This commit is contained in:
Kovid Goyal 2021-06-05 12:55:00 +05:30
parent 33e63f000a
commit a1b87f445b
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
6 changed files with 256 additions and 123 deletions

View File

@ -177,6 +177,8 @@ def generate_class(defn: Definition, loc: str) -> Tuple[str, str]:
a(' ' + ', '.join(grp) + ',') a(' ' + ', '.join(grp) + ',')
a(' ))') a(' ))')
a(' config_paths: typing.Tuple[str, ...] = ()')
a(' config_overrides: typing.Tuple[str, ...] = ()')
a('') a('')
a(' def __init__(self, options_dict: typing.Optional[typing.Dict[str, typing.Any]] = None) -> None:') a(' def __init__(self, options_dict: typing.Optional[typing.Dict[str, typing.Any]] = None) -> None:')
a(' if options_dict is not None:') a(' if options_dict is not None:')
@ -272,7 +274,8 @@ def generate_class(defn: Definition, loc: str) -> Tuple[str, str]:
only.setdefault(sc.only, []).append((text, func)) only.setdefault(sc.only, []).append((text, func))
else: else:
for val in func(text): for val in func(text):
a(f' {val!r}, # {sc.name}') a(f' # {sc.name}')
a(f' {val!r},')
a(']') a(']')
if only: if only:
imports.add(('kitty.constants', 'is_macos')) imports.add(('kitty.constants', 'is_macos'))

View File

@ -55,8 +55,11 @@ def load_config(*paths: str, overrides: Optional[Iterable[str]] = None) -> DiffO
) )
return ans return ans
opts_dict = _load_config(defaults, parse_config, merge_result_dicts, *paths, overrides=overrides) overrides = tuple(overrides) if overrides is not None else ()
opts_dict, paths = _load_config(defaults, parse_config, merge_result_dicts, *paths, overrides=overrides)
opts = DiffOptions(opts_dict) opts = DiffOptions(opts_dict)
opts.config_paths = paths
opts.config_overrides = overrides
return opts return opts

View File

@ -67,6 +67,8 @@ class Options:
title_fg: Color = Color(red=0, green=0, blue=0) title_fg: Color = Color(red=0, green=0, blue=0)
map: typing.List[typing.Tuple[kitty.types.ParsedShortcut, kitty.conf.utils.KeyAction]] = [] map: typing.List[typing.Tuple[kitty.types.ParsedShortcut, kitty.conf.utils.KeyAction]] = []
key_definitions: KittensKeyMap = {} key_definitions: KittensKeyMap = {}
config_paths: typing.Tuple[str, ...] = ()
config_overrides: typing.Tuple[str, ...] = ()
def __init__(self, options_dict: typing.Optional[typing.Dict[str, typing.Any]] = None) -> None: def __init__(self, options_dict: typing.Optional[typing.Dict[str, typing.Any]] = None) -> None:
if options_dict is not None: if options_dict is not None:
@ -113,29 +115,54 @@ class Options:
defaults = Options() defaults = Options()
defaults.map = [ defaults.map = [
(ParsedShortcut(mods=0, key_name='q'), KeyAction('quit')), # quit # quit
(ParsedShortcut(mods=0, key_name='ESCAPE'), KeyAction('quit')), # quit (ParsedShortcut(mods=0, key_name='q'), KeyAction('quit')),
(ParsedShortcut(mods=0, key_name='j'), KeyAction('scroll_by', (1,))), # scroll_down # quit
(ParsedShortcut(mods=0, key_name='DOWN'), KeyAction('scroll_by', (1,))), # scroll_down (ParsedShortcut(mods=0, key_name='ESCAPE'), KeyAction('quit')),
(ParsedShortcut(mods=0, key_name='k'), KeyAction('scroll_by', (-1,))), # scroll_up # scroll_down
(ParsedShortcut(mods=0, key_name='UP'), KeyAction('scroll_by', (-1,))), # scroll_up (ParsedShortcut(mods=0, key_name='j'), KeyAction('scroll_by', (1,))),
(ParsedShortcut(mods=0, key_name='HOME'), KeyAction('scroll_to', ('start',))), # scroll_top # scroll_down
(ParsedShortcut(mods=0, key_name='END'), KeyAction('scroll_to', ('end',))), # scroll_bottom (ParsedShortcut(mods=0, key_name='DOWN'), KeyAction('scroll_by', (1,))),
(ParsedShortcut(mods=0, key_name='PAGE_DOWN'), KeyAction('scroll_to', ('next-page',))), # scroll_page_down # scroll_up
(ParsedShortcut(mods=0, key_name=' '), KeyAction('scroll_to', ('next-page',))), # scroll_page_down (ParsedShortcut(mods=0, key_name='k'), KeyAction('scroll_by', (-1,))),
(ParsedShortcut(mods=0, key_name='PAGE_UP'), KeyAction('scroll_to', ('prev-page',))), # scroll_page_up # scroll_up
(ParsedShortcut(mods=0, key_name='n'), KeyAction('scroll_to', ('next-change',))), # next_change (ParsedShortcut(mods=0, key_name='UP'), KeyAction('scroll_by', (-1,))),
(ParsedShortcut(mods=0, key_name='p'), KeyAction('scroll_to', ('prev-change',))), # prev_change # scroll_top
(ParsedShortcut(mods=0, key_name='a'), KeyAction('change_context', ('all',))), # all_context (ParsedShortcut(mods=0, key_name='HOME'), KeyAction('scroll_to', ('start',))),
(ParsedShortcut(mods=0, key_name='='), KeyAction('change_context', ('default',))), # default_context # scroll_bottom
(ParsedShortcut(mods=0, key_name='+'), KeyAction('change_context', (5,))), # increase_context (ParsedShortcut(mods=0, key_name='END'), KeyAction('scroll_to', ('end',))),
(ParsedShortcut(mods=0, key_name='-'), KeyAction('change_context', (-5,))), # decrease_context # scroll_page_down
(ParsedShortcut(mods=0, key_name='/'), KeyAction('start_search', (True, False))), # search_forward (ParsedShortcut(mods=0, key_name='PAGE_DOWN'), KeyAction('scroll_to', ('next-page',))),
(ParsedShortcut(mods=0, key_name='?'), KeyAction('start_search', (True, True))), # search_backward # scroll_page_down
(ParsedShortcut(mods=0, key_name='.'), KeyAction('scroll_to', ('next-match',))), # next_match (ParsedShortcut(mods=0, key_name=' '), KeyAction('scroll_to', ('next-page',))),
(ParsedShortcut(mods=0, key_name='>'), KeyAction('scroll_to', ('next-match',))), # next_match # scroll_page_up
(ParsedShortcut(mods=0, key_name=','), KeyAction('scroll_to', ('prev-match',))), # prev_match (ParsedShortcut(mods=0, key_name='PAGE_UP'), KeyAction('scroll_to', ('prev-page',))),
(ParsedShortcut(mods=0, key_name='<'), KeyAction('scroll_to', ('prev-match',))), # prev_match # next_change
(ParsedShortcut(mods=0, key_name='f'), KeyAction('start_search', (False, False))), # search_forward_simple (ParsedShortcut(mods=0, key_name='n'), KeyAction('scroll_to', ('next-change',))),
(ParsedShortcut(mods=0, key_name='b'), KeyAction('start_search', (False, True))), # search_backward_simple # prev_change
(ParsedShortcut(mods=0, key_name='p'), KeyAction('scroll_to', ('prev-change',))),
# all_context
(ParsedShortcut(mods=0, key_name='a'), KeyAction('change_context', ('all',))),
# default_context
(ParsedShortcut(mods=0, key_name='='), KeyAction('change_context', ('default',))),
# increase_context
(ParsedShortcut(mods=0, key_name='+'), KeyAction('change_context', (5,))),
# decrease_context
(ParsedShortcut(mods=0, key_name='-'), KeyAction('change_context', (-5,))),
# search_forward
(ParsedShortcut(mods=0, key_name='/'), KeyAction('start_search', (True, False))),
# search_backward
(ParsedShortcut(mods=0, key_name='?'), KeyAction('start_search', (True, True))),
# next_match
(ParsedShortcut(mods=0, key_name='.'), KeyAction('scroll_to', ('next-match',))),
# next_match
(ParsedShortcut(mods=0, key_name='>'), KeyAction('scroll_to', ('next-match',))),
# prev_match
(ParsedShortcut(mods=0, key_name=','), KeyAction('scroll_to', ('prev-match',))),
# prev_match
(ParsedShortcut(mods=0, key_name='<'), KeyAction('scroll_to', ('prev-match',))),
# search_forward_simple
(ParsedShortcut(mods=0, key_name='f'), KeyAction('start_search', (False, False))),
# search_backward_simple
(ParsedShortcut(mods=0, key_name='b'), KeyAction('start_search', (False, True))),
] ]

View File

@ -212,8 +212,9 @@ def load_config(
merge_configs: Callable[[Dict, Dict], Dict], merge_configs: Callable[[Dict, Dict], Dict],
*paths: str, *paths: str,
overrides: Optional[Iterable[str]] = None overrides: Optional[Iterable[str]] = None
) -> Dict[str, Any]: ) -> Tuple[Dict[str, Any], Tuple[str, ...]]:
ans = defaults._asdict() ans = defaults._asdict()
found_paths = []
for path in paths: for path in paths:
if not path: if not path:
continue continue
@ -222,11 +223,12 @@ def load_config(
vals = parse_config(f) vals = parse_config(f)
except (FileNotFoundError, PermissionError): except (FileNotFoundError, PermissionError):
continue continue
found_paths.append(path)
ans = merge_configs(ans, vals) ans = merge_configs(ans, vals)
if overrides is not None: if overrides is not None:
vals = parse_config(overrides) vals = parse_config(overrides)
ans = merge_configs(ans, vals) ans = merge_configs(ans, vals)
return ans return ans, tuple(found_paths)
def key_func() -> Tuple[Callable[..., Callable], Dict[str, Callable]]: def key_func() -> Tuple[Callable[..., Callable], Dict[str, Callable]]:

View File

@ -150,7 +150,8 @@ def parse_config(lines: Iterable[str], accumulate_bad_lines: Optional[List[BadLi
def load_config(*paths: str, overrides: Optional[Iterable[str]] = None, accumulate_bad_lines: Optional[List[BadLine]] = None) -> Options: def load_config(*paths: str, overrides: Optional[Iterable[str]] = None, accumulate_bad_lines: Optional[List[BadLine]] = None) -> Options:
from .options.parse import merge_result_dicts from .options.parse import merge_result_dicts
opts_dict = _load_config(defaults, partial(parse_config, accumulate_bad_lines=accumulate_bad_lines), merge_result_dicts, *paths, overrides=overrides) overrides = tuple(overrides) if overrides is not None else ()
opts_dict, paths = _load_config(defaults, partial(parse_config, accumulate_bad_lines=accumulate_bad_lines), merge_result_dicts, *paths, overrides=overrides)
opts = Options(opts_dict) opts = Options(opts_dict)
finalize_keys(opts) finalize_keys(opts)
@ -162,6 +163,8 @@ def load_config(*paths: str, overrides: Optional[Iterable[str]] = None, accumula
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
opts.config_paths = paths
opts.config_overrides = overrides
return opts return opts

281
kitty/options/types.py generated
View File

@ -598,6 +598,8 @@ class Options:
0x585858, 0x626262, 0x6c6c6c, 0x767676, 0x808080, 0x8a8a8a, 0x949494, 0x9e9e9e, 0x585858, 0x626262, 0x6c6c6c, 0x767676, 0x808080, 0x8a8a8a, 0x949494, 0x9e9e9e,
0xa8a8a8, 0xb2b2b2, 0xbcbcbc, 0xc6c6c6, 0xd0d0d0, 0xdadada, 0xe4e4e4, 0xeeeeee, 0xa8a8a8, 0xb2b2b2, 0xbcbcbc, 0xc6c6c6, 0xd0d0d0, 0xdadada, 0xe4e4e4, 0xeeeeee,
)) ))
config_paths: typing.Tuple[str, ...] = ()
config_overrides: typing.Tuple[str, ...] = ()
def __init__(self, options_dict: typing.Optional[typing.Dict[str, typing.Any]] = None) -> None: def __init__(self, options_dict: typing.Optional[typing.Dict[str, typing.Any]] = None) -> None:
if options_dict is not None: if options_dict is not None:
@ -668,73 +670,140 @@ defaults.font_features = {}
defaults.kitten_alias = {} defaults.kitten_alias = {}
defaults.symbol_map = {} defaults.symbol_map = {}
defaults.map = [ defaults.map = [
KeyDefinition(False, KeyAction('copy_to_clipboard'), 1024, False, 99, ()), # copy_to_clipboard # copy_to_clipboard
KeyDefinition(False, KeyAction('paste_from_clipboard'), 1024, False, 118, ()), # paste_from_clipboard KeyDefinition(False, KeyAction('copy_to_clipboard'), 1024, False, 99, ()),
KeyDefinition(False, KeyAction('paste_from_selection'), 1024, False, 115, ()), # paste_from_selection # paste_from_clipboard
KeyDefinition(False, KeyAction('paste_from_selection'), 1, False, 57348, ()), # paste_from_selection KeyDefinition(False, KeyAction('paste_from_clipboard'), 1024, False, 118, ()),
KeyDefinition(False, KeyAction('pass_selection_to_program'), 1024, False, 111, ()), # pass_selection_to_program # paste_from_selection
KeyDefinition(False, KeyAction('scroll_line_up'), 1024, False, 57352, ()), # scroll_line_up KeyDefinition(False, KeyAction('paste_from_selection'), 1024, False, 115, ()),
KeyDefinition(False, KeyAction('scroll_line_up'), 1024, False, 107, ()), # scroll_line_up # paste_from_selection
KeyDefinition(False, KeyAction('scroll_line_down'), 1024, False, 57353, ()), # scroll_line_down KeyDefinition(False, KeyAction('paste_from_selection'), 1, False, 57348, ()),
KeyDefinition(False, KeyAction('scroll_line_down'), 1024, False, 106, ()), # scroll_line_down # pass_selection_to_program
KeyDefinition(False, KeyAction('scroll_page_up'), 1024, False, 57354, ()), # scroll_page_up KeyDefinition(False, KeyAction('pass_selection_to_program'), 1024, False, 111, ()),
KeyDefinition(False, KeyAction('scroll_page_down'), 1024, False, 57355, ()), # scroll_page_down # scroll_line_up
KeyDefinition(False, KeyAction('scroll_home'), 1024, False, 57356, ()), # scroll_home KeyDefinition(False, KeyAction('scroll_line_up'), 1024, False, 57352, ()),
KeyDefinition(False, KeyAction('scroll_end'), 1024, False, 57357, ()), # scroll_end # scroll_line_up
KeyDefinition(False, KeyAction('show_scrollback'), 1024, False, 104, ()), # show_scrollback KeyDefinition(False, KeyAction('scroll_line_up'), 1024, False, 107, ()),
KeyDefinition(False, KeyAction('new_window'), 1024, False, 57345, ()), # new_window # scroll_line_down
KeyDefinition(False, KeyAction('new_os_window'), 1024, False, 110, ()), # new_os_window KeyDefinition(False, KeyAction('scroll_line_down'), 1024, False, 57353, ()),
KeyDefinition(False, KeyAction('close_window'), 1024, False, 119, ()), # close_window # scroll_line_down
KeyDefinition(False, KeyAction('next_window'), 1024, False, 93, ()), # next_window KeyDefinition(False, KeyAction('scroll_line_down'), 1024, False, 106, ()),
KeyDefinition(False, KeyAction('previous_window'), 1024, False, 91, ()), # previous_window # scroll_page_up
KeyDefinition(False, KeyAction('move_window_forward'), 1024, False, 102, ()), # move_window_forward KeyDefinition(False, KeyAction('scroll_page_up'), 1024, False, 57354, ()),
KeyDefinition(False, KeyAction('move_window_backward'), 1024, False, 98, ()), # move_window_backward # scroll_page_down
KeyDefinition(False, KeyAction('move_window_to_top'), 1024, False, 96, ()), # move_window_to_top KeyDefinition(False, KeyAction('scroll_page_down'), 1024, False, 57355, ()),
KeyDefinition(False, KeyAction('start_resizing_window'), 1024, False, 114, ()), # start_resizing_window # scroll_home
KeyDefinition(False, KeyAction('first_window'), 1024, False, 49, ()), # first_window KeyDefinition(False, KeyAction('scroll_home'), 1024, False, 57356, ()),
KeyDefinition(False, KeyAction('second_window'), 1024, False, 50, ()), # second_window # scroll_end
KeyDefinition(False, KeyAction('third_window'), 1024, False, 51, ()), # third_window KeyDefinition(False, KeyAction('scroll_end'), 1024, False, 57357, ()),
KeyDefinition(False, KeyAction('fourth_window'), 1024, False, 52, ()), # fourth_window # show_scrollback
KeyDefinition(False, KeyAction('fifth_window'), 1024, False, 53, ()), # fifth_window KeyDefinition(False, KeyAction('show_scrollback'), 1024, False, 104, ()),
KeyDefinition(False, KeyAction('sixth_window'), 1024, False, 54, ()), # sixth_window # new_window
KeyDefinition(False, KeyAction('seventh_window'), 1024, False, 55, ()), # seventh_window KeyDefinition(False, KeyAction('new_window'), 1024, False, 57345, ()),
KeyDefinition(False, KeyAction('eighth_window'), 1024, False, 56, ()), # eighth_window # new_os_window
KeyDefinition(False, KeyAction('ninth_window'), 1024, False, 57, ()), # ninth_window KeyDefinition(False, KeyAction('new_os_window'), 1024, False, 110, ()),
KeyDefinition(False, KeyAction('tenth_window'), 1024, False, 48, ()), # tenth_window # close_window
KeyDefinition(False, KeyAction('next_tab'), 1024, False, 57351, ()), # next_tab KeyDefinition(False, KeyAction('close_window'), 1024, False, 119, ()),
KeyDefinition(False, KeyAction('next_tab'), 4, False, 57346, ()), # next_tab # next_window
KeyDefinition(False, KeyAction('previous_tab'), 1024, False, 57350, ()), # previous_tab KeyDefinition(False, KeyAction('next_window'), 1024, False, 93, ()),
KeyDefinition(False, KeyAction('previous_tab'), 5, False, 57346, ()), # previous_tab # previous_window
KeyDefinition(False, KeyAction('new_tab'), 1024, False, 116, ()), # new_tab KeyDefinition(False, KeyAction('previous_window'), 1024, False, 91, ()),
KeyDefinition(False, KeyAction('close_tab'), 1024, False, 113, ()), # close_tab # move_window_forward
KeyDefinition(False, KeyAction('move_tab_forward'), 1024, False, 46, ()), # move_tab_forward KeyDefinition(False, KeyAction('move_window_forward'), 1024, False, 102, ()),
KeyDefinition(False, KeyAction('move_tab_backward'), 1024, False, 44, ()), # move_tab_backward # move_window_backward
KeyDefinition(False, KeyAction('set_tab_title'), 1026, False, 116, ()), # set_tab_title KeyDefinition(False, KeyAction('move_window_backward'), 1024, False, 98, ()),
KeyDefinition(False, KeyAction('next_layout'), 1024, False, 108, ()), # next_layout # move_window_to_top
KeyDefinition(False, KeyAction('change_font_size', (True, '+', 2.0)), 1024, False, 61, ()), # increase_font_size KeyDefinition(False, KeyAction('move_window_to_top'), 1024, False, 96, ()),
KeyDefinition(False, KeyAction('change_font_size', (True, '+', 2.0)), 1024, False, 43, ()), # increase_font_size # start_resizing_window
KeyDefinition(False, KeyAction('change_font_size', (True, '+', 2.0)), 1024, False, 57413, ()), # increase_font_size KeyDefinition(False, KeyAction('start_resizing_window'), 1024, False, 114, ()),
KeyDefinition(False, KeyAction('change_font_size', (True, '-', 2.0)), 1024, False, 45, ()), # decrease_font_size # first_window
KeyDefinition(False, KeyAction('change_font_size', (True, '-', 2.0)), 1024, False, 57412, ()), # decrease_font_size KeyDefinition(False, KeyAction('first_window'), 1024, False, 49, ()),
KeyDefinition(False, KeyAction('change_font_size', (True, None, 0.0)), 1024, False, 57347, ()), # reset_font_size # second_window
KeyDefinition(False, KeyAction('kitten', ('hints',)), 1024, False, 101, ()), # open_url KeyDefinition(False, KeyAction('second_window'), 1024, False, 50, ()),
KeyDefinition(True, KeyAction('kitten', ('hints', '--type path --program -')), 1024, False, 112, (SingleKey(mods=0, is_native=False, key=102),)), # insert_selected_path # third_window
KeyDefinition(True, KeyAction('kitten', ('hints', '--type path')), 1024, False, 112, (SingleKey(mods=1, is_native=False, key=102),)), # open_selected_path KeyDefinition(False, KeyAction('third_window'), 1024, False, 51, ()),
KeyDefinition(True, KeyAction('kitten', ('hints', '--type line --program -')), 1024, False, 112, (SingleKey(mods=0, is_native=False, key=108),)), # insert_selected_line # fourth_window
KeyDefinition(True, KeyAction('kitten', ('hints', '--type word --program -')), 1024, False, 112, (SingleKey(mods=0, is_native=False, key=119),)), # insert_selected_word KeyDefinition(False, KeyAction('fourth_window'), 1024, False, 52, ()),
KeyDefinition(True, KeyAction('kitten', ('hints', '--type hash --program -')), 1024, False, 112, (SingleKey(mods=0, is_native=False, key=104),)), # insert_selected_hash # fifth_window
KeyDefinition(True, KeyAction('kitten', ('hints', '--type linenum')), 1024, False, 112, (SingleKey(mods=0, is_native=False, key=110),)), # goto_file_line KeyDefinition(False, KeyAction('fifth_window'), 1024, False, 53, ()),
KeyDefinition(True, KeyAction('kitten', ('hints', '--type hyperlink')), 1024, False, 112, (SingleKey(mods=0, is_native=False, key=121),)), # open_selected_hyperlink # sixth_window
KeyDefinition(False, KeyAction('toggle_fullscreen'), 1024, False, 57374, ()), # toggle_fullscreen KeyDefinition(False, KeyAction('sixth_window'), 1024, False, 54, ()),
KeyDefinition(False, KeyAction('toggle_maximized'), 1024, False, 57373, ()), # toggle_maximized # seventh_window
KeyDefinition(False, KeyAction('kitten', ('unicode_input',)), 1024, False, 117, ()), # input_unicode_character KeyDefinition(False, KeyAction('seventh_window'), 1024, False, 55, ()),
KeyDefinition(False, KeyAction('edit_config_file'), 1024, False, 57365, ()), # edit_config_file # eighth_window
KeyDefinition(False, KeyAction('kitty_shell', ('window',)), 1024, False, 57344, ()), # kitty_shell KeyDefinition(False, KeyAction('eighth_window'), 1024, False, 56, ()),
KeyDefinition(True, KeyAction('set_background_opacity', ('+0.1',)), 1024, False, 97, (SingleKey(mods=0, is_native=False, key=109),)), # increase_background_opacity # ninth_window
KeyDefinition(True, KeyAction('set_background_opacity', ('-0.1',)), 1024, False, 97, (SingleKey(mods=0, is_native=False, key=108),)), # decrease_background_opacity KeyDefinition(False, KeyAction('ninth_window'), 1024, False, 57, ()),
KeyDefinition(True, KeyAction('set_background_opacity', ('1',)), 1024, False, 97, (SingleKey(mods=0, is_native=False, key=49),)), # full_background_opacity # tenth_window
KeyDefinition(True, KeyAction('set_background_opacity', ('default',)), 1024, False, 97, (SingleKey(mods=0, is_native=False, key=100),)), # reset_background_opacity KeyDefinition(False, KeyAction('tenth_window'), 1024, False, 48, ()),
KeyDefinition(False, KeyAction('clear_terminal', ('reset', True)), 1024, False, 57349, ()), # reset_terminal # next_tab
KeyDefinition(False, KeyAction('next_tab'), 1024, False, 57351, ()),
# next_tab
KeyDefinition(False, KeyAction('next_tab'), 4, False, 57346, ()),
# previous_tab
KeyDefinition(False, KeyAction('previous_tab'), 1024, False, 57350, ()),
# previous_tab
KeyDefinition(False, KeyAction('previous_tab'), 5, False, 57346, ()),
# new_tab
KeyDefinition(False, KeyAction('new_tab'), 1024, False, 116, ()),
# close_tab
KeyDefinition(False, KeyAction('close_tab'), 1024, False, 113, ()),
# move_tab_forward
KeyDefinition(False, KeyAction('move_tab_forward'), 1024, False, 46, ()),
# move_tab_backward
KeyDefinition(False, KeyAction('move_tab_backward'), 1024, False, 44, ()),
# set_tab_title
KeyDefinition(False, KeyAction('set_tab_title'), 1026, False, 116, ()),
# next_layout
KeyDefinition(False, KeyAction('next_layout'), 1024, False, 108, ()),
# increase_font_size
KeyDefinition(False, KeyAction('change_font_size', (True, '+', 2.0)), 1024, False, 61, ()),
# increase_font_size
KeyDefinition(False, KeyAction('change_font_size', (True, '+', 2.0)), 1024, False, 43, ()),
# increase_font_size
KeyDefinition(False, KeyAction('change_font_size', (True, '+', 2.0)), 1024, False, 57413, ()),
# decrease_font_size
KeyDefinition(False, KeyAction('change_font_size', (True, '-', 2.0)), 1024, False, 45, ()),
# decrease_font_size
KeyDefinition(False, KeyAction('change_font_size', (True, '-', 2.0)), 1024, False, 57412, ()),
# reset_font_size
KeyDefinition(False, KeyAction('change_font_size', (True, None, 0.0)), 1024, False, 57347, ()),
# open_url
KeyDefinition(False, KeyAction('kitten', ('hints',)), 1024, False, 101, ()),
# insert_selected_path
KeyDefinition(True, KeyAction('kitten', ('hints', '--type path --program -')), 1024, False, 112, (SingleKey(mods=0, is_native=False, key=102),)),
# open_selected_path
KeyDefinition(True, KeyAction('kitten', ('hints', '--type path')), 1024, False, 112, (SingleKey(mods=1, is_native=False, key=102),)),
# insert_selected_line
KeyDefinition(True, KeyAction('kitten', ('hints', '--type line --program -')), 1024, False, 112, (SingleKey(mods=0, is_native=False, key=108),)),
# insert_selected_word
KeyDefinition(True, KeyAction('kitten', ('hints', '--type word --program -')), 1024, False, 112, (SingleKey(mods=0, is_native=False, key=119),)),
# insert_selected_hash
KeyDefinition(True, KeyAction('kitten', ('hints', '--type hash --program -')), 1024, False, 112, (SingleKey(mods=0, is_native=False, key=104),)),
# goto_file_line
KeyDefinition(True, KeyAction('kitten', ('hints', '--type linenum')), 1024, False, 112, (SingleKey(mods=0, is_native=False, key=110),)),
# open_selected_hyperlink
KeyDefinition(True, KeyAction('kitten', ('hints', '--type hyperlink')), 1024, False, 112, (SingleKey(mods=0, is_native=False, key=121),)),
# toggle_fullscreen
KeyDefinition(False, KeyAction('toggle_fullscreen'), 1024, False, 57374, ()),
# toggle_maximized
KeyDefinition(False, KeyAction('toggle_maximized'), 1024, False, 57373, ()),
# input_unicode_character
KeyDefinition(False, KeyAction('kitten', ('unicode_input',)), 1024, False, 117, ()),
# edit_config_file
KeyDefinition(False, KeyAction('edit_config_file'), 1024, False, 57365, ()),
# kitty_shell
KeyDefinition(False, KeyAction('kitty_shell', ('window',)), 1024, False, 57344, ()),
# increase_background_opacity
KeyDefinition(True, KeyAction('set_background_opacity', ('+0.1',)), 1024, False, 97, (SingleKey(mods=0, is_native=False, key=109),)),
# decrease_background_opacity
KeyDefinition(True, KeyAction('set_background_opacity', ('-0.1',)), 1024, False, 97, (SingleKey(mods=0, is_native=False, key=108),)),
# full_background_opacity
KeyDefinition(True, KeyAction('set_background_opacity', ('1',)), 1024, False, 97, (SingleKey(mods=0, is_native=False, key=49),)),
# reset_background_opacity
KeyDefinition(True, KeyAction('set_background_opacity', ('default',)), 1024, False, 97, (SingleKey(mods=0, is_native=False, key=100),)),
# reset_terminal
KeyDefinition(False, KeyAction('clear_terminal', ('reset', True)), 1024, False, 57349, ()),
] ]
if is_macos: if is_macos:
defaults.map.append(KeyDefinition(False, KeyAction('copy_to_clipboard'), 8, False, 99, ())) defaults.map.append(KeyDefinition(False, KeyAction('copy_to_clipboard'), 8, False, 99, ()))
@ -776,30 +845,56 @@ if is_macos:
defaults.map.append(KeyDefinition(False, KeyAction('edit_config_file'), 8, False, 44, ())) defaults.map.append(KeyDefinition(False, KeyAction('edit_config_file'), 8, False, 44, ()))
defaults.map.append(KeyDefinition(False, KeyAction('clear_terminal', ('reset', True)), 10, False, 114, ())) defaults.map.append(KeyDefinition(False, KeyAction('clear_terminal', ('reset', True)), 10, False, 114, ()))
defaults.mouse_map = [ defaults.mouse_map = [
MouseMapping(0, 0, -2, False, KeyAction('mouse_click_url_or_select')), # click_url_or_select # click_url_or_select
MouseMapping(0, 1, -2, True, KeyAction('mouse_click_url_or_select')), # click_url_or_select_grabbed MouseMapping(0, 0, -2, False, KeyAction('mouse_click_url_or_select')),
MouseMapping(0, 1, -2, False, KeyAction('mouse_click_url_or_select')), # click_url_or_select_grabbed # click_url_or_select_grabbed
MouseMapping(0, 5, -1, True, KeyAction('mouse_click_url')), # click_url MouseMapping(0, 1, -2, True, KeyAction('mouse_click_url_or_select')),
MouseMapping(0, 5, -1, False, KeyAction('mouse_click_url')), # click_url # click_url_or_select_grabbed
MouseMapping(2, 0, -1, False, KeyAction('paste_selection')), # paste_selection MouseMapping(0, 1, -2, False, KeyAction('mouse_click_url_or_select')),
MouseMapping(0, 0, 1, False, KeyAction('mouse_selection', (0,))), # start_simple_selection # click_url
MouseMapping(0, 6, 1, False, KeyAction('mouse_selection', (2,))), # start_rectangle_selection MouseMapping(0, 5, -1, True, KeyAction('mouse_click_url')),
MouseMapping(0, 0, 2, False, KeyAction('mouse_selection', (3,))), # select_word # click_url
MouseMapping(0, 0, 3, False, KeyAction('mouse_selection', (4,))), # select_line MouseMapping(0, 5, -1, False, KeyAction('mouse_click_url')),
MouseMapping(0, 6, 3, False, KeyAction('mouse_selection', (5,))), # select_line_from_point # paste_selection
MouseMapping(1, 0, 1, False, KeyAction('mouse_selection', (1,))), # extend_selection MouseMapping(2, 0, -1, False, KeyAction('paste_selection')),
MouseMapping(2, 1, -1, True, KeyAction('paste_selection')), # paste_selection_grabbed # start_simple_selection
MouseMapping(2, 1, -1, False, KeyAction('paste_selection')), # paste_selection_grabbed MouseMapping(0, 0, 1, False, KeyAction('mouse_selection', (0,))),
MouseMapping(0, 1, 1, True, KeyAction('mouse_selection', (0,))), # start_simple_selection_grabbed # start_rectangle_selection
MouseMapping(0, 1, 1, False, KeyAction('mouse_selection', (0,))), # start_simple_selection_grabbed MouseMapping(0, 6, 1, False, KeyAction('mouse_selection', (2,))),
MouseMapping(0, 7, 1, True, KeyAction('mouse_selection', (2,))), # start_rectangle_selection_grabbed # select_word
MouseMapping(0, 7, 1, False, KeyAction('mouse_selection', (2,))), # start_rectangle_selection_grabbed MouseMapping(0, 0, 2, False, KeyAction('mouse_selection', (3,))),
MouseMapping(0, 1, 2, True, KeyAction('mouse_selection', (3,))), # select_word_grabbed # select_line
MouseMapping(0, 1, 2, False, KeyAction('mouse_selection', (3,))), # select_word_grabbed MouseMapping(0, 0, 3, False, KeyAction('mouse_selection', (4,))),
MouseMapping(0, 1, 3, True, KeyAction('mouse_selection', (4,))), # select_line_grabbed # select_line_from_point
MouseMapping(0, 1, 3, False, KeyAction('mouse_selection', (4,))), # select_line_grabbed MouseMapping(0, 6, 3, False, KeyAction('mouse_selection', (5,))),
MouseMapping(0, 7, 3, True, KeyAction('mouse_selection', (5,))), # select_line_from_point_grabbed # extend_selection
MouseMapping(0, 7, 3, False, KeyAction('mouse_selection', (5,))), # select_line_from_point_grabbed MouseMapping(1, 0, 1, False, KeyAction('mouse_selection', (1,))),
MouseMapping(1, 1, 1, True, KeyAction('mouse_selection', (1,))), # extend_selection_grabbed # paste_selection_grabbed
MouseMapping(1, 1, 1, False, KeyAction('mouse_selection', (1,))), # extend_selection_grabbed MouseMapping(2, 1, -1, True, KeyAction('paste_selection')),
# paste_selection_grabbed
MouseMapping(2, 1, -1, False, KeyAction('paste_selection')),
# start_simple_selection_grabbed
MouseMapping(0, 1, 1, True, KeyAction('mouse_selection', (0,))),
# start_simple_selection_grabbed
MouseMapping(0, 1, 1, False, KeyAction('mouse_selection', (0,))),
# start_rectangle_selection_grabbed
MouseMapping(0, 7, 1, True, KeyAction('mouse_selection', (2,))),
# start_rectangle_selection_grabbed
MouseMapping(0, 7, 1, False, KeyAction('mouse_selection', (2,))),
# select_word_grabbed
MouseMapping(0, 1, 2, True, KeyAction('mouse_selection', (3,))),
# select_word_grabbed
MouseMapping(0, 1, 2, False, KeyAction('mouse_selection', (3,))),
# select_line_grabbed
MouseMapping(0, 1, 3, True, KeyAction('mouse_selection', (4,))),
# select_line_grabbed
MouseMapping(0, 1, 3, False, KeyAction('mouse_selection', (4,))),
# select_line_from_point_grabbed
MouseMapping(0, 7, 3, True, KeyAction('mouse_selection', (5,))),
# select_line_from_point_grabbed
MouseMapping(0, 7, 3, False, KeyAction('mouse_selection', (5,))),
# extend_selection_grabbed
MouseMapping(1, 1, 1, True, KeyAction('mouse_selection', (1,))),
# extend_selection_grabbed
MouseMapping(1, 1, 1, False, KeyAction('mouse_selection', (1,))),
] ]