mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-25 09:48:09 +02:00
Make get_all_actions() work in binary builds
This commit is contained in:
@@ -26,6 +26,7 @@ from .fast_data_types import (
|
||||
from .layout.base import Layout, Rect
|
||||
from .layout.interface import create_layout_object_for, evict_cached_layouts
|
||||
from .tab_bar import TabBar, TabBarData
|
||||
from .types import ac
|
||||
from .typing import EdgeLiteral, SessionTab, SessionType, TypedDict
|
||||
from .utils import log_error, platform_window_id, resolved_shell
|
||||
from .window import Watchers, Window, WindowDict
|
||||
@@ -222,8 +223,8 @@ class Tab: # {{{
|
||||
def create_layout_object(self, name: str) -> Layout:
|
||||
return create_layout_object_for(name, self.os_window_id, self.id)
|
||||
|
||||
@ac('lay', 'Go to the next enabled layout')
|
||||
def next_layout(self) -> None:
|
||||
'@ac:lay: Go to the next enabled layout'
|
||||
if len(self.enabled_layouts) > 1:
|
||||
for i, layout_name in enumerate(self.enabled_layouts):
|
||||
if layout_name == self.current_layout.full_name:
|
||||
@@ -235,20 +236,20 @@ class Tab: # {{{
|
||||
self._set_current_layout(nl)
|
||||
self.relayout()
|
||||
|
||||
@ac('lay', 'Go to the previously used layout')
|
||||
def last_used_layout(self) -> None:
|
||||
'@ac:lay: Go to the previously used layout'
|
||||
if len(self.enabled_layouts) > 1 and self._last_used_layout and self._last_used_layout != self._current_layout_name:
|
||||
self._set_current_layout(self._last_used_layout)
|
||||
self.relayout()
|
||||
|
||||
def goto_layout(self, layout_name: str, raise_exception: bool = False) -> None:
|
||||
'''
|
||||
@ac:lay: Switch to the named layout
|
||||
@ac('lay', '''
|
||||
Switch to the named layout
|
||||
|
||||
For example::
|
||||
|
||||
map f1 goto_layout tall
|
||||
'''
|
||||
''')
|
||||
def goto_layout(self, layout_name: str, raise_exception: bool = False) -> None:
|
||||
layout_name = layout_name.lower()
|
||||
if layout_name not in self.enabled_layouts:
|
||||
if raise_exception:
|
||||
@@ -258,16 +259,16 @@ class Tab: # {{{
|
||||
self._set_current_layout(layout_name)
|
||||
self.relayout()
|
||||
|
||||
def toggle_layout(self, layout_name: str) -> None:
|
||||
'''
|
||||
@ac:lay: Toggle the named layout
|
||||
@ac('lay', '''
|
||||
Toggle the named layout
|
||||
|
||||
Switches to the named layout if another layout is current, otherwise
|
||||
switches to the last used layout. Useful to "zoom" a window temporarily
|
||||
by switching to the stack layout. For example::
|
||||
|
||||
map f1 toggle_layout stack
|
||||
'''
|
||||
''')
|
||||
def toggle_layout(self, layout_name: str) -> None:
|
||||
if self._current_layout_name == layout_name:
|
||||
self.last_used_layout()
|
||||
else:
|
||||
@@ -280,12 +281,12 @@ class Tab: # {{{
|
||||
return None
|
||||
return 'Could not resize'
|
||||
|
||||
def resize_window(self, quality: str, increment: int) -> None:
|
||||
'''
|
||||
@ac:win: Resize the active window by the specified amount
|
||||
@ac('win', '''
|
||||
Resize the active window by the specified amount
|
||||
|
||||
See :ref:`window_resizing` for details.
|
||||
'''
|
||||
''')
|
||||
def resize_window(self, quality: str, increment: int) -> None:
|
||||
if increment < 1:
|
||||
raise ValueError(increment)
|
||||
is_horizontal = quality in ('wider', 'narrower')
|
||||
@@ -296,13 +297,13 @@ class Tab: # {{{
|
||||
if get_options().enable_audio_bell:
|
||||
ring_bell()
|
||||
|
||||
@ac('win', 'Reset window sizes undoing any dynamic resizing of windows')
|
||||
def reset_window_sizes(self) -> None:
|
||||
'@ac:win:Reset window sizes undoing any dynamic resizing of windows'
|
||||
if self.current_layout.remove_all_biases():
|
||||
self.relayout()
|
||||
|
||||
@ac('lay', 'Perform a layout specific action. See :doc:`layouts` for details')
|
||||
def layout_action(self, action_name: str, args: Sequence[str]) -> None:
|
||||
'@ac:lay: Perform a layout specific action. See :doc:`layouts` for details'
|
||||
ret = self.current_layout.layout_action(action_name, args, self.windows)
|
||||
if ret is None:
|
||||
ring_bell()
|
||||
@@ -424,14 +425,14 @@ class Tab: # {{{
|
||||
allow_remote_control=allow_remote_control, watchers=special_window.watchers
|
||||
)
|
||||
|
||||
@ac('win', 'Close the currently active window')
|
||||
def close_window(self) -> None:
|
||||
'@ac:win: Close the currently active window'
|
||||
w = self.active_window
|
||||
if w is not None:
|
||||
self.remove_window(w)
|
||||
|
||||
@ac('win', 'Close all windows in the tab other than the currently active window')
|
||||
def close_other_windows_in_tab(self) -> None:
|
||||
'@ac:win: Close all windows in the tab other than the currently active window'
|
||||
if len(self.windows) > 1:
|
||||
active_window = self.active_window
|
||||
for window in tuple(self.windows):
|
||||
@@ -469,14 +470,14 @@ class Tab: # {{{
|
||||
if self.windows:
|
||||
return self.current_layout.nth_window(self.windows, n)
|
||||
|
||||
def nth_window(self, num: int = 0) -> None:
|
||||
'''
|
||||
@ac:win: Focus the nth window if positive or the previously active windows if negative
|
||||
@ac('win', '''
|
||||
Focus the nth window if positive or the previously active windows if negative
|
||||
|
||||
For example, to ficus the previously active window::
|
||||
|
||||
map ctrl+p nth_window -1
|
||||
'''
|
||||
''')
|
||||
def nth_window(self, num: int = 0) -> None:
|
||||
if self.windows:
|
||||
if num < 0:
|
||||
self.windows.make_previous_group_active(-num)
|
||||
@@ -489,12 +490,12 @@ class Tab: # {{{
|
||||
self.current_layout.next_window(self.windows, delta)
|
||||
self.relayout_borders()
|
||||
|
||||
@ac('win', 'Focus the next window in the current tab')
|
||||
def next_window(self) -> None:
|
||||
'@ac:win: Focus the next window in the current tab'
|
||||
self._next_window()
|
||||
|
||||
@ac('win', 'Focus the previous window in the current tab')
|
||||
def previous_window(self) -> None:
|
||||
'@ac:win: Focus the previous window in the current tab'
|
||||
self._next_window(-1)
|
||||
|
||||
prev_window = previous_window
|
||||
@@ -516,28 +517,28 @@ class Tab: # {{{
|
||||
if candidates:
|
||||
return self.most_recent_group(candidates)
|
||||
|
||||
def neighboring_window(self, which: EdgeLiteral) -> None:
|
||||
'''
|
||||
@ac:win: Focus the neighboring window in the current tab
|
||||
@ac('win', '''
|
||||
Focus the neighboring window in the current tab
|
||||
|
||||
For example::
|
||||
|
||||
map ctrl+left neighboring_window left
|
||||
map ctrl+down neighboring_window bottom
|
||||
'''
|
||||
''')
|
||||
def neighboring_window(self, which: EdgeLiteral) -> None:
|
||||
neighbor = self.neighboring_group_id(which)
|
||||
if neighbor:
|
||||
self.windows.set_active_group(neighbor)
|
||||
|
||||
def move_window(self, delta: Union[EdgeLiteral, int] = 1) -> None:
|
||||
'''
|
||||
@ac:win: Move the window in the specified direction
|
||||
@ac('win', '''
|
||||
Move the window in the specified direction
|
||||
|
||||
For example::
|
||||
|
||||
map ctrl+left move_window left
|
||||
map ctrl+down move_window bottom
|
||||
'''
|
||||
''')
|
||||
def move_window(self, delta: Union[EdgeLiteral, int] = 1) -> None:
|
||||
if isinstance(delta, int):
|
||||
if self.current_layout.move_window(self.windows, delta):
|
||||
self.relayout()
|
||||
@@ -547,18 +548,18 @@ class Tab: # {{{
|
||||
if self.current_layout.move_window_to_group(self.windows, neighbor):
|
||||
self.relayout()
|
||||
|
||||
@ac('win', 'Move active window to the top (make it the first window)')
|
||||
def move_window_to_top(self) -> None:
|
||||
'@ac:win: Move active window to the top (make it the first window)'
|
||||
n = self.windows.active_group_idx
|
||||
if n > 0:
|
||||
self.move_window(-n)
|
||||
|
||||
@ac('win', 'Move active window forward (swap it with the next window)')
|
||||
def move_window_forward(self) -> None:
|
||||
'@ac:win: Move active window forward (swap it with the next window)'
|
||||
self.move_window()
|
||||
|
||||
@ac('win', 'Move active window backward (swap it with the previous window)')
|
||||
def move_window_backward(self) -> None:
|
||||
'@ac:win: Move active window backward (swap it with the previous window)'
|
||||
self.move_window(-1)
|
||||
|
||||
def list_windows(self, active_window: Optional[Window], self_window: Optional[Window] = None) -> Generator[WindowDict, None, None]:
|
||||
|
||||
Reference in New Issue
Block a user