Skip to content

Commit

Permalink
DRYer
Browse files Browse the repository at this point in the history
  • Loading branch information
kovidgoyal committed Dec 2, 2023
1 parent d63b852 commit 0d10ee1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion kitty/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ def set_cocoa_global_shortcuts(opts: Options) -> Dict[str, SingleKey]:
func_map = defaultdict(list)
for k, v in opts.keyboard_modes[''].keymap.items():
for kd in v:
if not kd.options.when_focus_on and not kd.options.mode and not kd.options.new_mode and not kd.is_sequence:
if kd.is_suitable_for_global_shortcut:
parts = tuple(kd.definition.split())
func_map[parts].append(k)

Expand Down
4 changes: 4 additions & 0 deletions kitty/options/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1175,6 +1175,10 @@ def __init__(
self.rest = rest
self.options = options

@property
def is_suitable_for_global_shortcut(self) -> bool:
return not self.options.when_focus_on and not self.options.mode and not self.options.new_mode and not self.is_sequence

def __repr__(self) -> str:
return self.pretty_repr('is_sequence', 'trigger', 'rest', 'options')

Expand Down

0 comments on commit 0d10ee1

Please sign in to comment.