diff options
author | toonn <toonn@toonn.io> | 2019-12-22 22:43:38 +0100 |
---|---|---|
committer | toonn <toonn@toonn.io> | 2019-12-22 22:43:38 +0100 |
commit | 604b2970964c9d3159807a29a690e03c8d796127 (patch) | |
tree | f83ce9c166a2c1ea72351fe8a7b05a7aaa519897 | |
parent | 3f8e7c14103a6570b0e55fbcf84242c86f42a7cb (diff) | |
parent | 1c4c46c3f62023df361044715840c0ce1225af45 (diff) | |
download | ranger-604b2970964c9d3159807a29a690e03c8d796127.tar.gz |
Merge branch 'siikamiika-feat-update-icon-title'
-rw-r--r-- | doc/ranger.1 | 4 | ||||
-rw-r--r-- | doc/ranger.pod | 4 | ||||
-rw-r--r-- | examples/rc_emacs.conf | 5 | ||||
-rw-r--r-- | ranger/config/rc.conf | 6 | ||||
-rw-r--r-- | ranger/gui/ui.py | 20 |
5 files changed, 26 insertions, 13 deletions
diff --git a/doc/ranger.1 b/doc/ranger.1 index 6b23bbfb..0d3efc16 100644 --- a/doc/ranger.1 +++ b/doc/ranger.1 @@ -1166,10 +1166,10 @@ a \s-1BIDI\s0 algorithm to reverse the relevant parts of the text. Requires the python-bidi pip package. .IP "update_title [bool]" 4 .IX Item "update_title [bool]" -Set a window title? +Set a window title? Updates both the \fI\s-1WM_NAME\s0\fR and \fI\s-1WM_ICON_NAME\s0\fR properties. .IP "update_tmux_title [bool]" 4 .IX Item "update_tmux_title [bool]" -Set the title to \*(L"ranger\*(R" in the tmux program? +Set the tmux \fIwindow-name\fR to \*(L"ranger\*(R"? .IP "use_preview_script [bool] <zv>" 4 .IX Item "use_preview_script [bool] <zv>" Use the preview script defined in the setting \fIpreview_script\fR? diff --git a/doc/ranger.pod b/doc/ranger.pod index 4f53ae35..5d6f9b01 100644 --- a/doc/ranger.pod +++ b/doc/ranger.pod @@ -1249,11 +1249,11 @@ Requires the python-bidi pip package. =item update_title [bool] -Set a window title? +Set a window title? Updates both the I<WM_NAME> and I<WM_ICON_NAME> properties. =item update_tmux_title [bool] -Set the title to "ranger" in the tmux program? +Set the tmux I<window-name> to "ranger"? =item use_preview_script [bool] <zv> diff --git a/examples/rc_emacs.conf b/examples/rc_emacs.conf index a69d68fe..3b086efd 100644 --- a/examples/rc_emacs.conf +++ b/examples/rc_emacs.conf @@ -131,10 +131,11 @@ set display_free_space_in_status_bar true # Display files tags in all columns or only in main column? set display_tags_in_all_columns true -# Set a title for the window? +# Set a title for the window? Updates both `WM_NAME` and `WM_ICON_NAME` +# properties. set update_title false -# Set the title to "ranger" in the tmux program? +# Set the tmux window-name to "ranger"? set update_tmux_title true # Shorten the title if it gets long? The number defines how many diff --git a/ranger/config/rc.conf b/ranger/config/rc.conf index e557d4de..4a1b14e9 100644 --- a/ranger/config/rc.conf +++ b/ranger/config/rc.conf @@ -182,7 +182,11 @@ set display_tags_in_all_columns true # Set a title for the window? set update_title false -# Set the title to "ranger" in the tmux program? +# Set a title for the window? Updates both `WM_NAME` and `WM_ICON_NAME` +# properties. +set update_icon_title false + +# Set the tmux window-name to "ranger"? set update_tmux_title true # Shorten the title if it gets long? The number defines how many diff --git a/ranger/gui/ui.py b/ranger/gui/ui.py index 03a43c57..b6ea0886 100644 --- a/ranger/gui/ui.py +++ b/ranger/gui/ui.py @@ -20,6 +20,12 @@ from .mouse_event import MouseEvent MOUSEMASK = curses.ALL_MOUSE_EVENTS | curses.REPORT_MOUSE_POSITION +# This escape is not available with a capname from terminfo unlike +# tsl (to_status_line), so it's hardcoded here. It's used just like tsl, +# but it sets the icon title (WM_ICON_NAME) instead of the window title +# (WM_NAME). +ESCAPE_ICON_TITLE = '\033]1;' + _ASCII = ''.join(chr(c) for c in range(32, 127)) @@ -384,16 +390,18 @@ class UI( # pylint: disable=too-many-instance-attributes,too-many-public-method try: fixed_cwd = cwd.encode('utf-8', 'surrogateescape'). \ decode('utf-8', 'replace') - fmt_tup = ( + escapes = [ curses.tigetstr('tsl').decode('latin-1'), - fixed_cwd, - curses.tigetstr('fsl').decode('latin-1'), - ) + ESCAPE_ICON_TITLE + ] + bel = curses.tigetstr('fsl').decode('latin-1') + fmt_tups = [(e, fixed_cwd, bel) for e in escapes] except UnicodeError: pass else: - sys.stdout.write("%sranger:%s%s" % fmt_tup) - sys.stdout.flush() + for fmt_tup in fmt_tups: + sys.stdout.write("%sranger:%s%s" % fmt_tup) + sys.stdout.flush() self.win.refresh() |