Dont show multiple keys bindings in debug output when their focus on conditions are the same
This commit is contained in:
parent
90e1ba7781
commit
2f7b0d1d94
2 changed files with 14 additions and 3 deletions
|
|
@ -10,7 +10,7 @@
|
|||
from contextlib import suppress
|
||||
from functools import partial
|
||||
from pprint import pformat
|
||||
from typing import IO, Callable, Dict, Iterable, Iterator, Optional, Set, TypeVar
|
||||
from typing import IO, Callable, Dict, Iterator, Optional, Sequence, Set, TypeVar
|
||||
|
||||
from kittens.tui.operations import colored, styled
|
||||
|
||||
|
|
@ -109,8 +109,15 @@ def as_sc(k: SingleKey, v: KeyDefinition) -> Shortcut:
|
|||
return Shortcut((v.trigger,) + v.rest)
|
||||
return Shortcut((k,))
|
||||
|
||||
def as_str(defns: Iterable[KeyDefinition]) -> str:
|
||||
return ', '.join(d.human_repr() for d in defns)
|
||||
def as_str(defns: Sequence[KeyDefinition]) -> str:
|
||||
seen = set()
|
||||
uniq = []
|
||||
for d in reversed(defns):
|
||||
key = d.full_key_sequence_to_trigger, d.options.when_focus_on
|
||||
if key not in seen:
|
||||
seen.add(key)
|
||||
uniq.append(d)
|
||||
return ', '.join(d.human_repr() for d in uniq)
|
||||
|
||||
for kmn, initial_ in default_opts.keyboard_modes.items():
|
||||
initial = {as_sc(k, v[0]): as_str(v) for k, v in initial_.keymap.items()}
|
||||
|
|
|
|||
|
|
@ -1207,6 +1207,10 @@ def __init__(
|
|||
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
|
||||
|
||||
@property
|
||||
def full_key_sequence_to_trigger(self) -> Tuple[SingleKey, ...]:
|
||||
return (self.trigger,) + self.rest
|
||||
|
||||
def __repr__(self) -> str:
|
||||
return self.pretty_repr('is_sequence', 'trigger', 'rest', 'options')
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue