mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-19 15:04:50 +02:00
Add a new mappable action open_url
This commit is contained in:
@@ -91,6 +91,20 @@ def kitten_parse(func: str, rest: str) -> FuncArgsType:
|
||||
return func, [args[0]] + (to_cmdline(args[1]) if len(args) > 1 else [])
|
||||
|
||||
|
||||
@func_with_args('open_url')
|
||||
def open_url_parse(func: str, rest: str) -> FuncArgsType:
|
||||
from urllib.parse import urlparse
|
||||
url = ''
|
||||
try:
|
||||
url = python_string(rest)
|
||||
tokens = urlparse(url)
|
||||
if not all((tokens.scheme, tokens.netloc,)):
|
||||
raise ValueError('Invalid URL')
|
||||
except Exception:
|
||||
log_error('Ignoring invalid URL string: ' + rest)
|
||||
return func, (url,)
|
||||
|
||||
|
||||
@func_with_args('goto_tab')
|
||||
def goto_tab_parse(func: str, rest: str) -> FuncArgsType:
|
||||
args = (max(0, int(rest)), )
|
||||
|
||||
Reference in New Issue
Block a user