Allow changing panel CLI defaults
This commit is contained in:
parent
e65031184a
commit
83bb1553f7
4 changed files with 15 additions and 13 deletions
|
|
@ -29,7 +29,7 @@
|
|||
toggle_os_window_visibility,
|
||||
)
|
||||
from kitty.os_window_size import WindowSizeData, edge_spacing
|
||||
from kitty.simple_cli_definitions import panel_kitten_options_spec
|
||||
from kitty.simple_cli_definitions import build_panel_cli_spec
|
||||
from kitty.types import LayerShellConfig
|
||||
from kitty.typing_compat import BossType, EdgeLiteral
|
||||
from kitty.utils import log_error
|
||||
|
|
@ -47,6 +47,12 @@
|
|||
usage = '[cmdline-to-run ...]'
|
||||
|
||||
|
||||
def panel_kitten_options_spec() -> str:
|
||||
if not hasattr(panel_kitten_options_spec, 'ans'):
|
||||
setattr(panel_kitten_options_spec, 'ans', build_panel_cli_spec({}))
|
||||
ans: str = getattr(panel_kitten_options_spec, 'ans')
|
||||
return ans
|
||||
|
||||
def parse_panel_args(args: list[str]) -> tuple[PanelCLIOptions, list[str]]:
|
||||
return parse_args(args, panel_kitten_options_spec, usage, help_text, 'kitty +kitten panel', result_class=PanelCLIOptions)
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ def __repr__(self) -> str:
|
|||
def generate_stub() -> None:
|
||||
from .cli import as_type_stub
|
||||
from .conf.utils import save_type_stub
|
||||
from .simple_cli_definitions import panel_kitten_options_spec, parse_option_spec
|
||||
from .simple_cli_definitions import parse_option_spec
|
||||
text = 'import typing\n\n\n'
|
||||
|
||||
def do(otext: str | None = None, cls: str = 'CLIOptions', extra_fields: Sequence[str] = ()) -> None:
|
||||
|
|
@ -59,6 +59,7 @@ def do(otext: str | None = None, cls: str = 'CLIOptions', extra_fields: Sequence
|
|||
from kittens.icat.main import OPTIONS as OS
|
||||
do(OS, 'IcatCLIOptions')
|
||||
|
||||
from kittens.panel.main import panel_kitten_options_spec
|
||||
do(panel_kitten_options_spec(), 'PanelCLIOptions')
|
||||
|
||||
from kittens.resize_window.main import OPTIONS
|
||||
|
|
|
|||
|
|
@ -471,7 +471,6 @@ def kitty_main(called_from_panel: bool = False) -> None:
|
|||
'Run kitty and open the specified files or URLs in it, using launch-actions.conf. For details'
|
||||
' see https://sw.kovidgoyal.net/kitty/open_actions/#scripting-the-opening-of-files-with-kitty-on-macos'
|
||||
'\n\nAll the normal kitty options can be used.')
|
||||
cli_flags = None
|
||||
else:
|
||||
if not called_from_panel:
|
||||
cli_flags = getattr(sys, 'kitty_run_data', {}).get('cli_flags', None)
|
||||
|
|
|
|||
|
|
@ -303,7 +303,7 @@ def generate_c_parsers() -> Iterator[str]:
|
|||
yield from generate_c_parser_for('kitty', kitty_options_spec())
|
||||
yield ''
|
||||
yield ''
|
||||
yield from generate_c_parser_for('panel_kitten', panel_kitten_options_spec())
|
||||
yield from generate_c_parser_for('panel_kitten', build_panel_cli_spec({}))
|
||||
yield ''
|
||||
|
||||
|
||||
|
|
@ -524,9 +524,8 @@ def kitty_options_spec() -> str:
|
|||
|
||||
|
||||
# panel CLI spec {{{
|
||||
def panel_kitten_options_spec() -> str:
|
||||
if not hasattr(panel_kitten_options_spec, 'ans'):
|
||||
OPTIONS = r'''
|
||||
def build_panel_cli_spec(defaults: dict[str, str]) -> str:
|
||||
return r'''
|
||||
--lines
|
||||
default=1
|
||||
The number of lines shown in the panel. Ignored for background, centered, and vertical panels.
|
||||
|
|
@ -689,10 +688,7 @@ def panel_kitten_options_spec() -> str:
|
|||
--debug-rendering
|
||||
type=bool-set
|
||||
For internal debugging use.
|
||||
'''
|
||||
setattr(panel_kitten_options_spec, 'ans', OPTIONS.format(
|
||||
appname=appname, listen_on_defn=listen_on_defn,
|
||||
))
|
||||
ans: str = getattr(panel_kitten_options_spec, 'ans')
|
||||
return ans
|
||||
'''.format(appname=appname, listen_on_defn=listen_on_defn, **defaults)
|
||||
|
||||
|
||||
# }}}
|
||||
|
|
|
|||
Loading…
Reference in a new issue