Finish documenting commands

This commit is contained in:
Kovid Goyal 2019-06-12 15:30:26 +05:30
parent 29f637c19a
commit da3e1a3730
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -931,24 +931,23 @@ cause colors to be changed in all windows.
args_count=1 args_count=1
) )
def cmd_set_background_opacity(global_opts, opts, args): def cmd_set_background_opacity(global_opts, opts, args):
'''
opacity+: A number between 0.1 and 1
match_window: Window to change opacity in
match_tab: Tab to change opacity in
all: Boolean indicating operate on all windows
'''
opacity = max(0.1, min(float(args[0]), 1.0)) opacity = max(0.1, min(float(args[0]), 1.0))
return { return {
'opacity': opacity, 'match_window': opts.match, 'opacity': opacity, 'match_window': opts.match,
'all': opts.all, 'all': opts.all, 'match_tab': opts.match_tab
} }
def set_background_opacity(boss, window, payload): def set_background_opacity(boss, window, payload):
if not boss.opts.dynamic_background_opacity: if not boss.opts.dynamic_background_opacity:
raise OpacityError('You must turn on the dynamic_background_opacity option in kitty.conf to be able to set background opacity') raise OpacityError('You must turn on the dynamic_background_opacity option in kitty.conf to be able to set background opacity')
if payload['all']: windows = windows_for_payload(payload)
windows = tuple(boss.all_windows)
else:
windows = (window or boss.active_window,)
if payload['match_window']:
windows = tuple(boss.match_windows(payload['match_window']))
if not windows:
raise MatchError(payload['match_window'])
for os_window_id in {w.os_window_id for w in windows}: for os_window_id in {w.os_window_id for w in windows}:
boss._set_os_window_background_opacity(os_window_id, payload['opacity']) boss._set_os_window_background_opacity(os_window_id, payload['opacity'])
# }}} # }}}
@ -969,6 +968,12 @@ cause ligatures to be changed in all windows.
argspec='STRATEGY' argspec='STRATEGY'
) )
def cmd_disable_ligatures(global_opts, opts, args): def cmd_disable_ligatures(global_opts, opts, args):
'''
strategy+: One of :code:`never`, :code:`always` or :code:`cursor`
match_window: Window to change opacity in
match_tab: Tab to change opacity in
all: Boolean indicating operate on all windows
'''
strategy = args[0] strategy = args[0]
if strategy not in ('never', 'always', 'cursor'): if strategy not in ('never', 'always', 'cursor'):
raise ValueError('{} is not a valid disable_ligatures strategy'.format('strategy')) raise ValueError('{} is not a valid disable_ligatures strategy'.format('strategy'))
@ -995,6 +1000,11 @@ def disable_ligatures(boss, window, payload):
argspec='kitten_name', argspec='kitten_name',
) )
def cmd_kitten(global_opts, opts, args): def cmd_kitten(global_opts, opts, args):
'''
kitten+: The name of the kitten to run
args: Arguments to pass to the kitten as a list
match: The window to run the kitten over
'''
if len(args) < 1: if len(args) < 1:
raise SystemExit('Must specify kitten name') raise SystemExit('Must specify kitten name')
return {'match': opts.match, 'args': list(args)[1:], 'kitten': args[0]} return {'match': opts.match, 'args': list(args)[1:], 'kitten': args[0]}
@ -1002,14 +1012,15 @@ def cmd_kitten(global_opts, opts, args):
def kitten(boss, window, payload): def kitten(boss, window, payload):
windows = [window or boss.active_window] windows = [window or boss.active_window]
match = payload['match'] pg = cmd_kitten.payload_get
match = pg(payload, 'match')
if match: if match:
windows = tuple(boss.match_windows(match)) windows = tuple(boss.match_windows(match))
if not windows: if not windows:
raise MatchError(match) raise MatchError(match)
for window in windows: for window in windows:
if window: if window:
boss._run_kitten(payload['kitten'], args=tuple(payload['args']), window=window) boss._run_kitten(payload['kitten'], args=tuple(payload.get('args', ())), window=window)
break break
# }}} # }}}