From 50bc3f465e6df54f27a5b0c2a541e85264ff2ee5 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 5 Mar 2026 11:19:40 +0530 Subject: [PATCH] Cleanup previous PR Also fix ask kitten not setting window title in modes other than choose --- docs/changelog.rst | 2 ++ docs/overview.rst | 3 ++- kittens/ask/main.go | 12 ++++++++---- kitty/boss.py | 7 +++++-- kitty/tabs.py | 1 + 5 files changed, 18 insertions(+), 7 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index b8fc72276..7d99d7988 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -267,6 +267,8 @@ Detailed list of changes - Make shift+left click extend the current selection instead of starting a new selection when the mouse is not grabbed by the TUI application (:disc:`9608`) +- Allow double clicking on a tab to rename it (:pull:`9609`) + 0.45.0 [2025-12-24] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/overview.rst b/docs/overview.rst index a098aa741..ccbd85ff2 100644 --- a/docs/overview.rst +++ b/docs/overview.rst @@ -182,7 +182,8 @@ Additionally, various bits of the kitty UI itself work with the mouse. You can drag and drop tabs in the tab bar to re-order them or move them from one OS Window to another, or even pop them out into a new OS Window. You can drag window borders to resize windows. You can double click on empty regions -of the tab bar to create new tabs. +of the tab bar to create new tabs or double click on an existing tab to rename +it. .. toctree:: :hidden: diff --git a/kittens/ask/main.go b/kittens/ask/main.go index 46f966d83..ead778c9e 100644 --- a/kittens/ask/main.go +++ b/kittens/ask/main.go @@ -9,6 +9,7 @@ import ( "github.com/kovidgoyal/kitty/tools/cli" "github.com/kovidgoyal/kitty/tools/cli/markup" "github.com/kovidgoyal/kitty/tools/tui" + "github.com/kovidgoyal/kitty/tools/tui/loop" ) var _ = fmt.Print @@ -18,7 +19,10 @@ type Response struct { Response string `json:"response"` } -func show_message(msg string) { +func show_message(msg, title string) { + if title != "" { + fmt.Printf("%s", loop.EscapeCodeToSetWindowTitle(title)) + } if msg != "" { m := markup.New(true) fmt.Println(m.Bold(msg)) @@ -38,7 +42,7 @@ func main(_ *cli.Command, o *Options, args []string) (rc int, err error) { return 1, err } case "password": - show_message(o.Message) + show_message(o.Message, o.Title) pw, err := tui.ReadPassword(o.Prompt, false) if err != nil { if errors.Is(err, tui.Canceled) { @@ -49,13 +53,13 @@ func main(_ *cli.Command, o *Options, args []string) (rc int, err error) { } result.Response = pw case "line": - show_message(o.Message) + show_message(o.Message, o.Title) result.Response, err = get_line(o, false) if err != nil { return 1, err } case "file": - show_message(o.Message) + show_message(o.Message, o.Title) result.Response, err = get_line(o, true) if err != nil { return 1, err diff --git a/kitty/boss.py b/kitty/boss.py index 4dea95323..0d3c97013 100644 --- a/kitty/boss.py +++ b/kitty/boss.py @@ -1228,7 +1228,8 @@ class Boss: window: Window | None = None, # the window associated with the confirmation prompt: str = '> ', is_password: bool = False, - initial_value: str = '' + initial_value: str = '', + window_title: str = '', ) -> None: result: str = '' @@ -1242,6 +1243,8 @@ class Boss: cmd = ['--type', 'password' if is_password else 'line', '--message', msg, '--prompt', prompt] if initial_value: cmd.append('--default=' + initial_value) + if window_title: + cmd.append(f'--title={window_title}') self.run_kitten_with_metadata( 'ask', cmd, window=window, custom_callback=callback_, default_data={'response': ''}, action_on_removal=on_popup_overlay_removal ) @@ -2340,7 +2343,7 @@ class Boss: prefilled = '' self.get_line( _('Enter the new title for this tab below. An empty title will cause the default title to be used.'), - tab.set_title, window=tab.active_window, initial_value=prefilled) + tab.set_title, window=tab.active_window, initial_value=prefilled, window_title=_('Rename tab')) def create_special_window_for_show_error(self, title: str, msg: str, overlay_for: int | None = None) -> SpecialWindowInstance: ec = sys.exc_info() diff --git a/kitty/tabs.py b/kitty/tabs.py index b02e29c18..7cb3bdf07 100644 --- a/kitty/tabs.py +++ b/kitty/tabs.py @@ -1734,6 +1734,7 @@ class TabManager: # {{{ prev.tab_id == tab.id and prev2.tab_id == tab.id and now - prev.at <= ci and now - prev2.at <= 2 * ci ): # double click on tab + self.set_active_tab(tab) get_boss().set_tab_title() self.recent_mouse_events.clear() set_tab_being_dragged()