parent
5fa5bf8142
commit
4189aa8f14
@ -384,7 +384,7 @@ def close_tab(boss, window, payload):
|
|||||||
'Open new window',
|
'Open new window',
|
||||||
'Open a new window in the specified tab. If you use the :option:`kitty @ new-window --match` option'
|
'Open a new window in the specified tab. If you use the :option:`kitty @ new-window --match` option'
|
||||||
' the first matching tab is used. Otherwise the currently active tab is used.'
|
' the first matching tab is used. Otherwise the currently active tab is used.'
|
||||||
' Prints out the id of the newly opened window. Any command line arguments'
|
' Prints out the id of the newly opened window (unless :option:`--no-response` is used). Any command line arguments'
|
||||||
' are assumed to be the command line used to run in the new window, if none'
|
' are assumed to be the command line used to run in the new window, if none'
|
||||||
' are provided, the default shell is run. For example:\n'
|
' are provided, the default shell is run. For example:\n'
|
||||||
':italic:`kitty @ new-window --title Email mutt`',
|
':italic:`kitty @ new-window --title Email mutt`',
|
||||||
@ -416,13 +416,23 @@ Open a new tab
|
|||||||
|
|
||||||
--tab-title
|
--tab-title
|
||||||
When using --new-tab set the title of the tab.
|
When using --new-tab set the title of the tab.
|
||||||
|
|
||||||
|
|
||||||
|
--no-response
|
||||||
|
type=bool-set
|
||||||
|
default=false
|
||||||
|
Dont wait for a response giving the id of the newly opened window. Note that
|
||||||
|
using this option means that you will not be notified of failures and that
|
||||||
|
the id of the new window will not be printed out.
|
||||||
''',
|
''',
|
||||||
argspec='[CMD ...]'
|
argspec='[CMD ...]'
|
||||||
)
|
)
|
||||||
def cmd_new_window(global_opts, opts, args):
|
def cmd_new_window(global_opts, opts, args):
|
||||||
|
if opts.no_response:
|
||||||
|
global_opts.no_command_response = True
|
||||||
return {'match': opts.match, 'title': opts.title, 'cwd': opts.cwd,
|
return {'match': opts.match, 'title': opts.title, 'cwd': opts.cwd,
|
||||||
'new_tab': opts.new_tab, 'tab_title': opts.tab_title,
|
'new_tab': opts.new_tab, 'tab_title': opts.tab_title,
|
||||||
'window_type': opts.window_type,
|
'window_type': opts.window_type, 'no_response': opts.no_response,
|
||||||
'keep_focus': opts.keep_focus, 'args': args or []}
|
'keep_focus': opts.keep_focus, 'args': args or []}
|
||||||
|
|
||||||
|
|
||||||
@ -437,7 +447,7 @@ def new_window(boss, window, payload):
|
|||||||
wid = boss.active_window.id
|
wid = boss.active_window.id
|
||||||
if payload['keep_focus'] and old_window:
|
if payload['keep_focus'] and old_window:
|
||||||
boss.set_active_window(old_window)
|
boss.set_active_window(old_window)
|
||||||
return str(wid)
|
return None if payload['no_response'] else str(wid)
|
||||||
|
|
||||||
if payload['window_type'] == 'os':
|
if payload['window_type'] == 'os':
|
||||||
boss._new_os_window(w)
|
boss._new_os_window(w)
|
||||||
@ -446,7 +456,7 @@ def new_window(boss, window, payload):
|
|||||||
os_window_id = boss.set_active_window(old_window)
|
os_window_id = boss.set_active_window(old_window)
|
||||||
if os_window_id:
|
if os_window_id:
|
||||||
focus_os_window(os_window_id)
|
focus_os_window(os_window_id)
|
||||||
return str(wid)
|
return None if payload['no_response'] else str(wid)
|
||||||
|
|
||||||
match = payload['match']
|
match = payload['match']
|
||||||
if match:
|
if match:
|
||||||
@ -459,7 +469,7 @@ def new_window(boss, window, payload):
|
|||||||
w = tab.new_special_window(w)
|
w = tab.new_special_window(w)
|
||||||
if payload['keep_focus'] and old_window:
|
if payload['keep_focus'] and old_window:
|
||||||
boss.set_active_window(old_window)
|
boss.set_active_window(old_window)
|
||||||
return str(w.id)
|
return None if payload['no_response'] else str(w.id)
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -19,6 +19,8 @@ def handle_cmd(boss, window, cmd):
|
|||||||
cmd = json.loads(cmd)
|
cmd = json.loads(cmd)
|
||||||
v = cmd['version']
|
v = cmd['version']
|
||||||
if tuple(v)[:2] > version[:2]:
|
if tuple(v)[:2] > version[:2]:
|
||||||
|
if cmd['no_response']:
|
||||||
|
return
|
||||||
return {'ok': False, 'error': 'The kitty client you are using to send remote commands is newer than this kitty instance. This is not supported.'}
|
return {'ok': False, 'error': 'The kitty client you are using to send remote commands is newer than this kitty instance. This is not supported.'}
|
||||||
c = cmap[cmd['cmd']]
|
c = cmap[cmd['cmd']]
|
||||||
func = partial(c.impl(), boss, window)
|
func = partial(c.impl(), boss, window)
|
||||||
@ -27,7 +29,7 @@ def handle_cmd(boss, window, cmd):
|
|||||||
response = {'ok': True}
|
response = {'ok': True}
|
||||||
if ans is not None:
|
if ans is not None:
|
||||||
response['data'] = ans
|
response['data'] = ans
|
||||||
if not c.no_response:
|
if not c.no_response and not cmd['no_response']:
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
|
||||||
@ -137,6 +139,7 @@ def parse_rc_args(args):
|
|||||||
|
|
||||||
def main(args):
|
def main(args):
|
||||||
global_opts, items = parse_rc_args(args)
|
global_opts, items = parse_rc_args(args)
|
||||||
|
global_opts.no_command_response = None
|
||||||
|
|
||||||
if not items:
|
if not items:
|
||||||
from kitty.shell import main
|
from kitty.shell import main
|
||||||
@ -156,7 +159,14 @@ def main(args):
|
|||||||
}
|
}
|
||||||
if payload is not None:
|
if payload is not None:
|
||||||
send['payload'] = payload
|
send['payload'] = payload
|
||||||
response = do_io(global_opts.to, send, func.no_response)
|
if global_opts.no_command_response is not None:
|
||||||
|
no_response = global_opts.no_command_response
|
||||||
|
else:
|
||||||
|
no_response = func.no_response
|
||||||
|
send['no_response'] = no_response
|
||||||
|
response = do_io(global_opts.to, send, no_response)
|
||||||
|
if no_response:
|
||||||
|
return
|
||||||
if not response.get('ok'):
|
if not response.get('ok'):
|
||||||
if response.get('tb'):
|
if response.get('tb'):
|
||||||
print(response['tb'], file=sys.stderr)
|
print(response['tb'], file=sys.stderr)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user