Document a couple more commands

This commit is contained in:
Kovid Goyal 2019-06-12 13:33:12 +05:30
parent d34e0b325e
commit a662dace9c
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -459,7 +459,7 @@ If specified close the window this command is run in, rather than the active win
) )
def cmd_close_window(global_opts, opts, args): def cmd_close_window(global_opts, opts, args):
''' '''
match: Which window to change the layout of match: Which window to close
self: Boolean indicating whether to close the window the command is run in self: Boolean indicating whether to close the window the command is run in
''' '''
return {'match': opts.match, 'self': opts.self} return {'match': opts.match, 'self': opts.self}
@ -508,22 +508,29 @@ If specified resize the window this command is run in, rather than the active wi
string_return_is_error=True string_return_is_error=True
) )
def cmd_resize_window(global_opts, opts, args): def cmd_resize_window(global_opts, opts, args):
'''
match: Which window to resize
self: Boolean indicating whether to close the window the command is run in
increment: Integer specifying the resize increment
axis: One of :code:`horizontal, vertical` or :code:`reset`
'''
return {'match': opts.match, 'increment': opts.increment, 'axis': opts.axis, 'self': opts.self} return {'match': opts.match, 'increment': opts.increment, 'axis': opts.axis, 'self': opts.self}
def resize_window(boss, window, payload): def resize_window(boss, window, payload):
match = payload['match'] pg = cmd_resize_window.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)
else: else:
windows = [window if window and payload['self'] else boss.active_window] windows = [window if window and pg(payload, 'self') else boss.active_window]
resized = False resized = False
if windows and windows[0]: if windows and windows[0]:
resized = boss.resize_layout_window( resized = boss.resize_layout_window(
windows[0], increment=payload['increment'], is_horizontal=payload['axis'] == 'horizontal', windows[0], increment=pg(payload, 'increment'), is_horizontal=pg(payload, 'axis') == 'horizontal',
reset=payload['axis'] == 'reset' reset=pg(payload, 'axis') == 'reset'
) )
return resized return resized
# }}} # }}}
@ -540,17 +547,22 @@ If specified close the tab this command is run in, rather than the active tab.
argspec='' argspec=''
) )
def cmd_close_tab(global_opts, opts, args): def cmd_close_tab(global_opts, opts, args):
'''
match: Which tab to close
self: Boolean indicating whether to close the window the command is run in
'''
return {'match': opts.match, 'self': opts.self} return {'match': opts.match, 'self': opts.self}
def close_tab(boss, window, payload): def close_tab(boss, window, payload):
match = payload['match'] pg = cmd_close_tab.payload_get
match = pg(payload, 'match')
if match: if match:
tabs = tuple(boss.match_tabs(match)) tabs = tuple(boss.match_tabs(match))
if not tabs: if not tabs:
raise MatchError(match, 'tabs') raise MatchError(match, 'tabs')
else: else:
tabs = [boss.tab_for_window(window) if window and payload['self'] else boss.active_tab] tabs = [boss.tab_for_window(window) if window and pg(payload, 'self') else boss.active_tab]
for tab in tabs: for tab in tabs:
if window: if window:
if tab: if tab: