parent
da15477aaf
commit
007f377f16
3 changed files with 37 additions and 3 deletions
|
|
@ -22,6 +22,8 @@ Changelog
|
|||
- Remote control: Allow matching windows by the environment variables of their
|
||||
child process as well
|
||||
|
||||
- Allow running kitten via the remote control system (:iss:`738`)
|
||||
|
||||
0.11.3 [2018-07-10]
|
||||
------------------------------
|
||||
|
||||
|
|
|
|||
|
|
@ -582,9 +582,14 @@ def get_output(self, source_window, num_lines=1):
|
|||
output += str(s.linebuf.line(i))
|
||||
return output
|
||||
|
||||
def _run_kitten(self, kitten, args=(), input_data=None):
|
||||
w = self.active_window
|
||||
tab = self.active_tab
|
||||
def _run_kitten(self, kitten, args=(), input_data=None, window=None):
|
||||
if window is None:
|
||||
w = self.active_window
|
||||
tab = self.active_tab
|
||||
else:
|
||||
w = window
|
||||
tab = w.tabref()
|
||||
|
||||
if w is not None and tab is not None and w.overlay_for is None:
|
||||
orig_args, args = list(args), list(args)
|
||||
from kittens.runner import create_kitten_handler
|
||||
|
|
|
|||
|
|
@ -682,6 +682,33 @@ def set_background_opacity(boss, window, payload):
|
|||
# }}}
|
||||
|
||||
|
||||
# kitten {{{
|
||||
@cmd(
|
||||
'Run a kitten',
|
||||
'Run a kitten over the specified window (active window by default)',
|
||||
options_spec=MATCH_WINDOW_OPTION,
|
||||
argspec='kitten_name',
|
||||
)
|
||||
def cmd_kitten(global_opts, opts, args):
|
||||
if len(args) < 1:
|
||||
raise SystemExit('Must specify kitten name')
|
||||
return {'match': opts.match, 'args': list(args)[1:], 'kitten': args[0]}
|
||||
|
||||
|
||||
def kitten(boss, window, payload):
|
||||
windows = [window or boss.active_window]
|
||||
match = payload['match']
|
||||
if match:
|
||||
windows = tuple(boss.match_windows(match))
|
||||
if not windows:
|
||||
raise MatchError(match)
|
||||
for window in windows:
|
||||
if window:
|
||||
boss._run_kitten(payload['kitten'], args=tuple(payload['args']), window=window)
|
||||
break
|
||||
# }}}
|
||||
|
||||
|
||||
cmap = {v.name: v for v in globals().values() if hasattr(v, 'is_cmd')}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue