From 1dc9adebb4dc8872b5c58b01034d4b2f1706b16c Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 1 Jun 2018 06:49:47 +0530 Subject: [PATCH] Add an option to @set-window-title to make the change overridable --- kitty/cmds.py | 17 ++++++++++++++--- kitty/window.py | 2 ++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/kitty/cmds.py b/kitty/cmds.py index cd24f9d64..1d11c9722 100644 --- a/kitty/cmds.py +++ b/kitty/cmds.py @@ -206,11 +206,17 @@ def send_text(boss, window, payload): ' the title will be set for all matched windows. By default, only the window' ' in which the command is run is affected. If you do not specify a title, the' ' last title set by the child process running in the window will be used.', - options_spec=MATCH_WINDOW_OPTION, + options_spec=''' +--temporary +type=bool-set +By default, if you use :italic:`set-window-title` the title will be permanently changed +and programs running in the window will not be able to change it again. If you +want to allow other programs to change it afterwards, use this option. + ''' + '\n\n' + MATCH_WINDOW_OPTION, argspec='TITLE ...' ) def cmd_set_window_title(global_opts, opts, args): - return {'title': ' '.join(args), 'match': opts.match} + return {'title': ' '.join(args), 'match': opts.match, 'temporary': opts.temporary} def set_window_title(boss, window, payload): @@ -222,7 +228,12 @@ def set_window_title(boss, window, payload): raise MatchError(match) for window in windows: if window: - window.set_title(payload['title']) + if payload['temporary']: + window.override_title = None + window.title_changed(payload['title']) + else: + window.set_title(payload['title']) + # }}} diff --git a/kitty/window.py b/kitty/window.py index 65ddf01eb..97294dd4e 100644 --- a/kitty/window.py +++ b/kitty/window.py @@ -211,6 +211,8 @@ class Window: glfw_post_empty_event() def set_title(self, title): + if title: + title = sanitize_title(title) self.override_title = title or None self.title_updated()