mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-24 09:18:08 +02:00
Provide access to the current keyboard mode in the tab_title_template
This commit is contained in:
@@ -67,6 +67,10 @@ class Mappings:
|
|||||||
self.keyboard_mode_stack: List[KeyboardMode] = []
|
self.keyboard_mode_stack: List[KeyboardMode] = []
|
||||||
self.update_keymap(global_shortcuts)
|
self.update_keymap(global_shortcuts)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def current_keyboard_mode_name(self) -> str:
|
||||||
|
return self.keyboard_mode_stack[-1].name if self.keyboard_mode_stack else ''
|
||||||
|
|
||||||
def update_keymap(self, global_shortcuts:Optional[Dict[str, SingleKey]] = None) -> None:
|
def update_keymap(self, global_shortcuts:Optional[Dict[str, SingleKey]] = None) -> None:
|
||||||
if global_shortcuts is None:
|
if global_shortcuts is None:
|
||||||
global_shortcuts = self.set_cocoa_global_shortcuts(self.get_options()) if is_macos else {}
|
global_shortcuts = self.set_cocoa_global_shortcuts(self.get_options()) if is_macos else {}
|
||||||
|
|||||||
@@ -1364,6 +1364,8 @@ use :code:`{sup.index}`. All data available is:
|
|||||||
:code:`active_oldest_exe` for the oldest foreground process.
|
:code:`active_oldest_exe` for the oldest foreground process.
|
||||||
:code:`max_title_length`
|
:code:`max_title_length`
|
||||||
The maximum title length available.
|
The maximum title length available.
|
||||||
|
:code:`keyboard_mode`
|
||||||
|
The name of the current :ref:`keyboard mode <modal_mappings>` or the empty string if no keyboard mode is active.
|
||||||
|
|
||||||
Note that formatting is done by Python's string formatting machinery, so you can
|
Note that formatting is done by Python's string formatting machinery, so you can
|
||||||
use, for instance, :code:`{layout_name[:2].upper()}` to show only the first two
|
use, for instance, :code:`{layout_name[:2].upper()}` to show only the first two
|
||||||
|
|||||||
@@ -240,6 +240,7 @@ def draw_title(draw_data: DrawData, screen: Screen, tab: TabBarData, index: int,
|
|||||||
max_title_length = min(max_title_length, draw_data.max_tab_title_length)
|
max_title_length = min(max_title_length, draw_data.max_tab_title_length)
|
||||||
ColorFormatter.draw_data = draw_data
|
ColorFormatter.draw_data = draw_data
|
||||||
ColorFormatter.tab_data = tab
|
ColorFormatter.tab_data = tab
|
||||||
|
boss = get_boss()
|
||||||
eval_locals = {
|
eval_locals = {
|
||||||
'index': index,
|
'index': index,
|
||||||
'layout_name': tab.layout_name,
|
'layout_name': tab.layout_name,
|
||||||
@@ -253,6 +254,7 @@ def draw_title(draw_data: DrawData, screen: Screen, tab: TabBarData, index: int,
|
|||||||
'bell_symbol': draw_data.bell_on_tab if tab.needs_attention else '',
|
'bell_symbol': draw_data.bell_on_tab if tab.needs_attention else '',
|
||||||
'activity_symbol': draw_data.tab_activity_symbol if tab.has_activity_since_last_focus else '',
|
'activity_symbol': draw_data.tab_activity_symbol if tab.has_activity_since_last_focus else '',
|
||||||
'max_title_length': max_title_length,
|
'max_title_length': max_title_length,
|
||||||
|
'keyboard_mode': boss.mappings.current_keyboard_mode_name,
|
||||||
}
|
}
|
||||||
template = draw_data.title_template
|
template = draw_data.title_template
|
||||||
if tab.is_active and draw_data.active_title_template is not None:
|
if tab.is_active and draw_data.active_title_template is not None:
|
||||||
|
|||||||
Reference in New Issue
Block a user