Implement @focus-window

This commit is contained in:
Kovid Goyal
2018-01-10 13:23:04 +05:30
parent 88523b2692
commit 3cd744b247
2 changed files with 26 additions and 1 deletions

View File

@@ -328,6 +328,27 @@ def new_window(boss, window, payload):
return str(w.id)
@cmd(
'Focus the specified window',
options_spec=MATCH_WINDOW_OPTION
)
def cmd_focus_window(global_opts, opts, args):
return {'match': opts.match}
def focus_window(boss, window, payload):
windows = [window or boss.active_window]
match = payload['match']
if match:
windows = tuple(boss.match_windows(match))
if not windows:
raise ValueError('No matching windows for expression: {}'.format(match))
for window in windows:
if window:
boss.set_active_window(window)
break
@cmd(
'Get text from the specified window',
options_spec=MATCH_WINDOW_OPTION + '''\n