mirror of
https://github.com/kovidgoyal/kitty.git
synced 2024-09-21 11:39:57 +03:00
More work on porting rc commands
This commit is contained in:
parent
a4b2e2a196
commit
192eccc6cc
@ -126,14 +126,27 @@ def build_go_code(name: str, cmd: RemoteCommand, seq: OptionSpecSeq, template: s
|
||||
handled_fields: Set[str] = set()
|
||||
jc.extend(cmd.args.as_go_code(name, field_types, handled_fields))
|
||||
|
||||
unhandled = {}
|
||||
used_options = set()
|
||||
for field in json_fields:
|
||||
if field.field in option_map:
|
||||
o = option_map[field.field]
|
||||
oq = (cmd.field_to_option_map or {}).get(field.field, field.field)
|
||||
if oq in option_map:
|
||||
o = option_map[oq]
|
||||
used_options.add(oq)
|
||||
jc.append(f'payload.{field.struct_field_name} = options_{name}.{o.go_var_name}')
|
||||
elif field.field in handled_fields:
|
||||
pass
|
||||
else:
|
||||
print(f'Cant map field: {field.field} for cmd: {name}', file=sys.stderr)
|
||||
unhandled[field.field] = field
|
||||
for x in tuple(unhandled):
|
||||
if x == 'match_window' and 'match' in option_map and 'match' not in used_options:
|
||||
used_options.add('match')
|
||||
o = option_map['match']
|
||||
field = unhandled[x]
|
||||
jc.append(f'payload.{field.struct_field_name} = options_{name}.{o.go_var_name}')
|
||||
del unhandled[x]
|
||||
if unhandled:
|
||||
raise SystemExit(f'Cant map fields: {", ".join(unhandled)} for cmd: {name}')
|
||||
|
||||
argspec = cmd.args.spec
|
||||
if argspec:
|
||||
@ -228,7 +241,7 @@ def update_at_commands() -> None:
|
||||
os.remove(dest)
|
||||
with open(dest, 'w') as f:
|
||||
f.write(code)
|
||||
print('TODO: test set_window_logo, set_window_background, set_font_size, send_text, env, scroll_window', file=sys.stderr)
|
||||
print('\x1b[31mTODO\x1b[m: test set_window_logo, set_window_background, set_font_size, send_text, env, scroll_window', file=sys.stderr)
|
||||
|
||||
|
||||
def main() -> None:
|
||||
|
@ -261,6 +261,7 @@ class RemoteCommand:
|
||||
options_class: Type[RCOptions] = RCOptions
|
||||
protocol_spec: str = ''
|
||||
argspec = args_count = args_completion = ArgsHandling()
|
||||
field_to_option_map: Optional[Dict[str, str]] = None
|
||||
|
||||
def __init__(self) -> None:
|
||||
self.desc = self.desc or self.short_desc
|
||||
|
@ -69,6 +69,8 @@ class GetText(RemoteCommand):
|
||||
Get text from the window this command is run in, rather than the active window.
|
||||
'''
|
||||
|
||||
field_to_option_map = {'wrap_markers': 'add_wrap_markers', 'cursor': 'add_cursor'}
|
||||
|
||||
def message_to_kitty(self, global_opts: RCOptions, opts: 'CLIOptions', args: ArgsType) -> PayloadType:
|
||||
return {
|
||||
'match': opts.match,
|
||||
|
@ -47,6 +47,11 @@ class Launch(RemoteCommand):
|
||||
logo_position/str: Window logo position as string or empty string to use default
|
||||
logo_alpha/float: Window logo alpha or -1 to use default
|
||||
self/bool: Boolean, if True use tab the command was run in
|
||||
os_window_title/str: Title for OS Window
|
||||
os_window_name/str: WM_NAME for OS Window
|
||||
os_window_class/str: WM_CLASS for OS Window
|
||||
color/list.str: list of color specifications such as foreground=red
|
||||
watcher/list.str: list of paths to watcher files
|
||||
'''
|
||||
|
||||
short_desc = 'Run an arbitrary process in a new window/tab'
|
||||
|
Loading…
Reference in New Issue
Block a user