Skip to content

Commit 55425e2

Browse files
committed
Show secure input indicator on active tab
1 parent 4ca6a20 commit 55425e2

4 files changed

Lines changed: 20 additions & 2 deletions

File tree

docs/changelog.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,11 @@ consumption to do the same tasks.
173173
Detailed list of changes
174174
-------------------------------------
175175

176+
0.50.0 [future]
177+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
178+
179+
- macOS: Show a key symbol on the active tab if the macOS Secure Input feature is enabled
180+
176181
0.47.2 [2026-06-07]
177182
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
178183

kitty/cocoa_window.m

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1412,6 +1412,12 @@ - (void)drawRect:(NSRect)dirtyRect {
14121412

14131413
// }}}
14141414

1415+
static PyObject*
1416+
cocoa_is_secure_input_enabled(PyObject *self UNUSED, PyObject *args UNUSED) {
1417+
SecureKeyboardEntryController *k = [SecureKeyboardEntryController sharedInstance];
1418+
return Py_NewRef(k.isDesired ? Py_True : Py_False);
1419+
}
1420+
14151421
static PyObject*
14161422
cocoa_get_machine_id(PyObject *self UNUSED, PyObject *args UNUSED) {
14171423
static char ans[1024] = {0};
@@ -1439,6 +1445,7 @@ - (void)drawRect:(NSRect)dirtyRect {
14391445
{"cocoa_play_system_sound_by_id_async", play_system_sound_by_id_async, METH_O, ""},
14401446
{"cocoa_get_lang", (PyCFunction)cocoa_get_lang, METH_NOARGS, ""},
14411447
{"cocoa_get_machine_id", (PyCFunction)cocoa_get_machine_id, METH_NOARGS, ""},
1448+
{"cocoa_is_secure_input_enabled", (PyCFunction)cocoa_is_secure_input_enabled, METH_NOARGS, ""},
14421449
{"cocoa_set_global_shortcut", (PyCFunction)cocoa_set_global_shortcut, METH_VARARGS, ""},
14431450
{"cocoa_send_notification", (PyCFunction)(void(*)(void))cocoa_send_notification, METH_VARARGS | METH_KEYWORDS, ""},
14441451
{"cocoa_remove_delivered_notification", (PyCFunction)cocoa_remove_delivered_notification, METH_O, ""},

kitty/options/definition.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1753,7 +1753,7 @@
17531753
'''
17541754
)
17551755

1756-
opt('tab_title_template', '"{fmt.fg.red}{bell_symbol}{activity_symbol}{fmt.fg.tab}{tab.last_focused_progress_percent}{title}"',
1756+
opt('tab_title_template', '"{fmt.fg.red}{bell_symbol}{activity_symbol}{secure_input_symbol}{fmt.fg.tab}{tab.last_focused_progress_percent}{title}"',
17571757
option_type='tab_title_template',
17581758
long_text='''
17591759
A template to render the tab title. The default just renders the title with
@@ -1776,6 +1776,8 @@
17761776
The number of windows in the tab.
17771777
:code:`num_window_groups`
17781778
The number of window groups (a window group is a window and all of its overlay windows) in the tab.
1779+
:code:`secure_input_symbol`
1780+
A key symbol when secure input is enabled on macOS and the tab is the active tab, empty otherwise.
17791781
:code:`tab.active_wd`
17801782
The working directory of the currently active window in the tab
17811783
(expensive, requires syscall). Use :code:`tab.active_oldest_wd` to get

kitty/tab_bar.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
)
1313

1414
from .borders import Border, BorderColor
15-
from .constants import config_dir
15+
from .constants import config_dir, is_macos
1616
from .fast_data_types import (
1717
BOTTOM_EDGE,
1818
DECAWM,
@@ -35,6 +35,8 @@
3535
from .typing_compat import EdgeLiteral, PowerlineStyle
3636
from .utils import color_as_int, log_error, sgr_sanitizer_pat
3737

38+
if is_macos:
39+
from .fast_data_types import cocoa_is_secure_input_enabled # type: ignore
3840

3941
class TabBarData(NamedTuple):
4042
title: str
@@ -268,11 +270,13 @@ def apply_title_template(draw_data: DrawData, tab: TabBarData, index: int, max_t
268270
if tab.tab_id < 0:
269271
return tab.title # synthetic tab — render title literally, skip user template
270272
ta = TabAccessor(tab.tab_id)
273+
si = ('🔑' if cocoa_is_secure_input_enabled() else '') if is_macos and tab.is_active else ''
271274
data = {
272275
'index': index,
273276
'layout_name': tab.layout_name,
274277
'num_windows': tab.num_windows,
275278
'num_window_groups': tab.num_window_groups,
279+
'secure_input_symbol': si,
276280
'title': tab.title,
277281
'tab': ta,
278282
}

0 commit comments

Comments
 (0)