Make it possible to inject tab via cmdutils.Value
This commit is contained in:
parent
4ce8a6eaf6
commit
c0d4fe0ab5
@ -483,6 +483,7 @@ The following arguments are supported for `@cmdutils.argument`:
|
||||
- `value`: Tell qutebrowser to fill the argument with special values:
|
||||
- `value=cmdutils.Value.count`: The `count` given by the user to the command.
|
||||
- `value=cmdutils.Value.win_id`: The window ID of the current window.
|
||||
- `value=cmdutils.Value.tab`: The tab object which is currently focused.
|
||||
- `completion`: A completion function (see `qutebrowser.completions.models.*`)
|
||||
to use when completing arguments for the given command.
|
||||
- `choices`: The allowed string choices for the argument.
|
||||
|
@ -193,7 +193,7 @@ class Command:
|
||||
raise TypeError("{}: handler has count parameter "
|
||||
"without default!".format(self.name))
|
||||
return True
|
||||
elif arg_info.value == usertypes.CommandValue.win_id:
|
||||
elif isinstance(arg_info.value, usertypes.CommandValue):
|
||||
return True
|
||||
else:
|
||||
raise TypeError("{}: Invalid value={!r} for argument '{}'!"
|
||||
@ -441,6 +441,11 @@ class Command:
|
||||
self._add_special_arg(value=win_id, param=param,
|
||||
args=args, kwargs=kwargs)
|
||||
continue
|
||||
elif arg_info.value == usertypes.CommandValue.tab:
|
||||
tab = self._get_objreg(win_id=win_id, name='tab', scope='tab')
|
||||
self._add_special_arg(value=tab, param=param,
|
||||
args=args, kwargs=kwargs)
|
||||
continue
|
||||
elif arg_info.value is None:
|
||||
pass
|
||||
else:
|
||||
|
@ -262,6 +262,7 @@ class CommandValue(enum.Enum):
|
||||
|
||||
count = 1
|
||||
win_id = 2
|
||||
tab = 3
|
||||
|
||||
|
||||
class Question(QObject):
|
||||
|
Loading…
Reference in New Issue
Block a user