mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-22 08:18:08 +02:00
Add layout name completion to @ goto-layout
This commit is contained in:
@@ -4,8 +4,8 @@
|
||||
|
||||
from contextlib import suppress
|
||||
from typing import (
|
||||
TYPE_CHECKING, Any, Callable, Dict, FrozenSet, Generator, List, NoReturn,
|
||||
Optional, Tuple, Type, Union, cast
|
||||
TYPE_CHECKING, Any, Callable, Dict, FrozenSet, Generator, Iterable, List,
|
||||
NoReturn, Optional, Tuple, Type, Union, cast
|
||||
)
|
||||
|
||||
from kitty.cli import get_defaults_from_seq, parse_args, parse_option_spec
|
||||
@@ -14,8 +14,8 @@ from kitty.constants import appname, running_in_kitty
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from kitty.boss import Boss as B
|
||||
from kitty.window import Window as W
|
||||
from kitty.tabs import Tab
|
||||
from kitty.window import Window as W
|
||||
Window = W
|
||||
Boss = B
|
||||
Tab
|
||||
@@ -110,7 +110,7 @@ class RemoteCommand:
|
||||
no_response: bool = False
|
||||
string_return_is_error: bool = False
|
||||
args_count: Optional[int] = None
|
||||
args_completion: Optional[Dict[str, Tuple[str, Tuple[str, ...]]]] = None
|
||||
args_completion: Optional[Dict[str, Tuple[str, Union[Callable[[], Iterable[str]], Tuple[str, ...]]]]] = None
|
||||
defaults: Optional[Dict[str, Any]] = None
|
||||
options_class: Type = RCOptions
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# vim:fileencoding=utf-8
|
||||
# License: GPLv3 Copyright: 2020, Kovid Goyal <kovid at kovidgoyal.net>
|
||||
|
||||
from typing import TYPE_CHECKING, Optional
|
||||
from typing import TYPE_CHECKING, Optional, Iterable
|
||||
|
||||
from .base import (
|
||||
MATCH_TAB_OPTION, ArgsType, Boss, PayloadGetType, PayloadType, RCOptions,
|
||||
@@ -13,6 +13,11 @@ if TYPE_CHECKING:
|
||||
from kitty.cli_stub import GotoLayoutRCOptions as CLIOptions
|
||||
|
||||
|
||||
def layout_names() -> Iterable[str]:
|
||||
from kitty.layout.interface import all_layouts
|
||||
return all_layouts.keys()
|
||||
|
||||
|
||||
class GotoLayout(RemoteCommand):
|
||||
|
||||
'''
|
||||
@@ -27,6 +32,8 @@ class GotoLayout(RemoteCommand):
|
||||
)
|
||||
options_spec = MATCH_TAB_OPTION
|
||||
argspec = 'LAYOUT_NAME'
|
||||
args_count = 1
|
||||
args_completion = {'names': ('Layouts', layout_names)}
|
||||
|
||||
def message_to_kitty(self, global_opts: RCOptions, opts: 'CLIOptions', args: ArgsType) -> PayloadType:
|
||||
if len(args) != 1:
|
||||
|
||||
Reference in New Issue
Block a user