hints: optionally add trailing space
This commit is contained in:
parent
160fbd2071
commit
a57e96500a
@ -84,9 +84,19 @@ 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 ''
|
||||||
|
if args.multiple and args.program == '-':
|
||||||
|
return ' '
|
||||||
|
return ''
|
||||||
|
|
||||||
def reset(self):
|
def reset(self):
|
||||||
self.current_input = ''
|
self.current_input = ''
|
||||||
self.current_text = None
|
self.current_text = None
|
||||||
@ -112,7 +122,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 +140,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 +373,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 and pasting match into the terminal window.
|
||||||
'''.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 = ''
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user