mirror of
https://github.com/kovidgoyal/kitty.git
synced 2024-11-11 01:28:19 +03:00
add clear_all_mouse_shortcuts
option to clear mouse_maps
This commit is contained in:
parent
4849e07c26
commit
db5a2d2141
@ -123,9 +123,12 @@ def finalize_keys(opts: Options) -> None:
|
||||
def finalize_mouse_mappings(opts: Options) -> None:
|
||||
defns: List[MouseMapping] = []
|
||||
for d in opts.mouse_map:
|
||||
defns.append(d.resolve_and_copy(opts.kitty_mod, opts.kitten_alias))
|
||||
|
||||
if d is None: # clear_all_mouse_shortcuts
|
||||
defns = [] # type: ignore
|
||||
else:
|
||||
defns.append(d.resolve_and_copy(opts.kitty_mod, opts.kitten_alias))
|
||||
mousemap: MouseMap = {}
|
||||
|
||||
for defn in defns:
|
||||
is_no_op = defn.action.func in no_op_actions
|
||||
if is_no_op:
|
||||
|
@ -499,6 +499,14 @@ of URLs with a plain click::
|
||||
automatically end it and no release event will be dispatched.
|
||||
''')
|
||||
|
||||
opt('clear_all_mouse_shortcuts', 'no',
|
||||
option_type='clear_all_mouse_shortcuts',
|
||||
long_text='''
|
||||
You can have kitty remove all mouse shortcut definition seen up to this point.
|
||||
Useful, for instance, to remove the default mouse shortcuts.
|
||||
'''
|
||||
)
|
||||
|
||||
mma('Click the link under the mouse cursor when no selection is created',
|
||||
'click_url_or_select left click ungrabbed mouse_click_url_or_select',
|
||||
)
|
||||
|
7
kitty/options/parse.py
generated
7
kitty/options/parse.py
generated
@ -8,8 +8,8 @@ from kitty.conf.utils import (
|
||||
)
|
||||
from kitty.options.utils import (
|
||||
active_tab_title_template, adjust_baseline, adjust_line_height, allow_hyperlinks,
|
||||
allow_remote_control, box_drawing_scale, clear_all_shortcuts, clipboard_control,
|
||||
config_or_absolute_path, copy_on_select, cursor_text_color,
|
||||
allow_remote_control, box_drawing_scale, clear_all_mouse_shortcuts, clear_all_shortcuts,
|
||||
clipboard_control, config_or_absolute_path, copy_on_select, cursor_text_color,
|
||||
deprecated_hide_window_decorations_aliases, deprecated_macos_show_window_title_in_menubar_alias,
|
||||
deprecated_send_text, disable_ligatures, edge_width, env, font_features, hide_window_decorations,
|
||||
kitten_alias, macos_option_as_alt, macos_titlebar_color, optional_edge_width, parse_map,
|
||||
@ -93,6 +93,9 @@ class Parser:
|
||||
def clear_all_shortcuts(self, val: str, ans: typing.Dict[str, typing.Any]) -> None:
|
||||
clear_all_shortcuts(val, ans)
|
||||
|
||||
def clear_all_mouse_shortcuts(self, val: str, ans: typing.Dict[str, typing.Any]) -> None:
|
||||
clear_all_mouse_shortcuts(val, ans)
|
||||
|
||||
def click_interval(self, val: str, ans: typing.Dict[str, typing.Any]) -> None:
|
||||
ans['click_interval'] = float(val)
|
||||
|
||||
|
2
kitty/options/types.py
generated
2
kitty/options/types.py
generated
@ -61,6 +61,7 @@ option_names = ( # {{{
|
||||
'bold_font',
|
||||
'bold_italic_font',
|
||||
'box_drawing_scale',
|
||||
'clear_all_mouse_shortcuts',
|
||||
'clear_all_shortcuts',
|
||||
'click_interval',
|
||||
'clipboard_control',
|
||||
@ -453,6 +454,7 @@ class Options:
|
||||
bold_font: str = 'auto'
|
||||
bold_italic_font: str = 'auto'
|
||||
box_drawing_scale: typing.Tuple[float, float, float, float] = (0.001, 1.0, 1.5, 2.0)
|
||||
clear_all_mouse_shortcuts: bool = False
|
||||
clear_all_shortcuts: bool = False
|
||||
click_interval: float = -1.0
|
||||
clipboard_control: typing.Tuple[str, ...] = ('write-clipboard', 'write-primary')
|
||||
|
@ -696,6 +696,13 @@ def tab_bar_margin_height(x: str) -> TabBarMarginHeight:
|
||||
return TabBarMarginHeight(next(ans), next(ans))
|
||||
|
||||
|
||||
def clear_all_mouse_shortcuts(val: str, dict_with_parse_results: Optional[Dict[str, Any]] = None) -> bool:
|
||||
ans = to_bool(val)
|
||||
if ans and dict_with_parse_results is not None:
|
||||
dict_with_parse_results['mouse_map'] = [None]
|
||||
return ans
|
||||
|
||||
|
||||
def clear_all_shortcuts(val: str, dict_with_parse_results: Optional[Dict[str, Any]] = None) -> bool:
|
||||
ans = to_bool(val)
|
||||
if ans and dict_with_parse_results is not None:
|
||||
|
@ -41,6 +41,8 @@ class TestConfParsing(BaseTest):
|
||||
self.assertFalse(opts.keymap)
|
||||
opts = p('clear_all_shortcuts y', 'map f1 next_window')
|
||||
self.ae(len(opts.keymap), 1)
|
||||
opts = p('clear_all_mouse_shortcuts y', 'mouse_map left click ungrabbed mouse_click_url_or_select')
|
||||
self.ae(len(opts.mousemap), 1)
|
||||
opts = p('strip_trailing_spaces always')
|
||||
self.ae(opts.strip_trailing_spaces, 'always')
|
||||
self.assertFalse(bad_lines)
|
||||
|
Loading…
Reference in New Issue
Block a user