mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-25 09:48:09 +02:00
Merge branch 'hints-add-trailing-space' of https://github.com/maximbaz/kitty
This commit is contained in:
@@ -29,6 +29,10 @@ Changelog
|
|||||||
- icat kitten: Implement reading image data from STDIN, if STDIN is not
|
- icat kitten: Implement reading image data from STDIN, if STDIN is not
|
||||||
connected to a terminal (:iss:`1130`)
|
connected to a terminal (:iss:`1130`)
|
||||||
|
|
||||||
|
- hints kitten: Insert trailing spaces after matches when using the
|
||||||
|
``--multiple`` option. Also add a separate ``--add-traling-space``
|
||||||
|
option to control this behavior (:pull:`1132`)
|
||||||
|
|
||||||
- Fix the ``*_with_cwd`` actions using the cwd of the overlay window rather
|
- Fix the ``*_with_cwd`` actions using the cwd of the overlay window rather
|
||||||
than the underlying window's cwd (:iss:`1045`)
|
than the underlying window's cwd (:iss:`1045`)
|
||||||
|
|
||||||
|
|||||||
@@ -84,9 +84,17 @@ class Hints(Handler):
|
|||||||
self.args = args
|
self.args = args
|
||||||
self.window_title = _('Choose URL') if args.type == 'url' else _('Choose text')
|
self.window_title = _('Choose URL') if args.type == 'url' else _('Choose text')
|
||||||
self.multiple = args.multiple
|
self.multiple = args.multiple
|
||||||
|
self.match_suffix = self.get_match_suffix(args)
|
||||||
self.chosen = []
|
self.chosen = []
|
||||||
self.reset()
|
self.reset()
|
||||||
|
|
||||||
|
def get_match_suffix(self, args):
|
||||||
|
if args.add_trailing_space == 'always':
|
||||||
|
return ' '
|
||||||
|
if args.add_trailing_space == 'never':
|
||||||
|
return ''
|
||||||
|
return ' ' if args.multiple else ''
|
||||||
|
|
||||||
def reset(self):
|
def reset(self):
|
||||||
self.current_input = ''
|
self.current_input = ''
|
||||||
self.current_text = None
|
self.current_text = None
|
||||||
@@ -112,7 +120,7 @@ class Hints(Handler):
|
|||||||
if encode_hint(idx).startswith(self.current_input)
|
if encode_hint(idx).startswith(self.current_input)
|
||||||
]
|
]
|
||||||
if len(matches) == 1:
|
if len(matches) == 1:
|
||||||
self.chosen.append(matches[0].text)
|
self.chosen.append(matches[0].text + self.match_suffix)
|
||||||
if self.multiple:
|
if self.multiple:
|
||||||
self.ignore_mark_indices.add(matches[0].index)
|
self.ignore_mark_indices.add(matches[0].index)
|
||||||
self.reset()
|
self.reset()
|
||||||
@@ -130,7 +138,7 @@ class Hints(Handler):
|
|||||||
elif key_event is enter_key and self.current_input:
|
elif key_event is enter_key and self.current_input:
|
||||||
try:
|
try:
|
||||||
idx = decode_hint(self.current_input)
|
idx = decode_hint(self.current_input)
|
||||||
self.chosen.append(self.index_map[idx].text)
|
self.chosen.append(self.index_map[idx].text + self.match_suffix)
|
||||||
self.ignore_mark_indices.add(idx)
|
self.ignore_mark_indices.add(idx)
|
||||||
except Exception:
|
except Exception:
|
||||||
self.current_input = ''
|
self.current_input = ''
|
||||||
@@ -363,6 +371,13 @@ The minimum number of characters to consider a match.
|
|||||||
type=bool-set
|
type=bool-set
|
||||||
Select multiple matches and perform the action on all of them together at the end.
|
Select multiple matches and perform the action on all of them together at the end.
|
||||||
In this mode, press :kbd:`Esc` to finish selecting.
|
In this mode, press :kbd:`Esc` to finish selecting.
|
||||||
|
|
||||||
|
|
||||||
|
--add-trailing-space
|
||||||
|
default=auto
|
||||||
|
choices=auto,always,never
|
||||||
|
Add trailing space after matched text. Defaults to auto, which adds the space
|
||||||
|
when used together with --multiple.
|
||||||
'''.format(','.join(sorted(URL_PREFIXES))).format
|
'''.format(','.join(sorted(URL_PREFIXES))).format
|
||||||
help_text = 'Select text from the screen using the keyboard. Defaults to searching for URLs.'
|
help_text = 'Select text from the screen using the keyboard. Defaults to searching for URLs.'
|
||||||
usage = ''
|
usage = ''
|
||||||
|
|||||||
Reference in New Issue
Block a user