From f953c1c29de70ed54e43629222a3a170b08a42ac Mon Sep 17 00:00:00 2001 From: siikamiika Date: Thu, 25 Jul 2019 23:37:13 +0300 Subject: add update_icon_title option resolves #1637 --- doc/ranger.1 | 3 +++ doc/ranger.pod | 4 ++++ examples/rc_emacs.conf | 3 +++ ranger/config/rc.conf | 3 +++ ranger/container/settings.py | 1 + ranger/gui/ui.py | 26 ++++++++++++++++++-------- 6 files changed, 32 insertions(+), 8 deletions(-) diff --git a/doc/ranger.1 b/doc/ranger.1 index 5a29f6e1..2f233c95 100644 --- a/doc/ranger.1 +++ b/doc/ranger.1 @@ -1083,6 +1083,9 @@ Requires the python-bidi pip package. .IP "update_title [bool]" 4 .IX Item "update_title [bool]" Set a window title? +.IP "update_icon_title [bool]" 4 +.IX Item "update_icon_title [bool]" +Set an icon title? .IP "update_tmux_title [bool]" 4 .IX Item "update_tmux_title [bool]" Set the title to \*(L"ranger\*(R" in the tmux program? diff --git a/doc/ranger.pod b/doc/ranger.pod index fadd4cba..3b59c9e5 100644 --- a/doc/ranger.pod +++ b/doc/ranger.pod @@ -1124,6 +1124,10 @@ Requires the python-bidi pip package. Set a window title? +=item update_icon_title [bool] + +Set an icon title? + =item update_tmux_title [bool] Set the title to "ranger" in the tmux program? diff --git a/examples/rc_emacs.conf b/examples/rc_emacs.conf index 0462282e..ac3937bf 100644 --- a/examples/rc_emacs.conf +++ b/examples/rc_emacs.conf @@ -131,6 +131,9 @@ set display_tags_in_all_columns true # Set a title for the window? set update_title false +# Set a title for the icon? +set update_icon_title false + # Set the title to "ranger" in the tmux program? set update_tmux_title true diff --git a/ranger/config/rc.conf b/ranger/config/rc.conf index f559290d..b4bb4bfc 100644 --- a/ranger/config/rc.conf +++ b/ranger/config/rc.conf @@ -179,6 +179,9 @@ set display_tags_in_all_columns true # Set a title for the window? set update_title false +# Set a title for the icon? +set update_icon_title false + # Set the title to "ranger" in the tmux program? set update_tmux_title true diff --git a/ranger/container/settings.py b/ranger/container/settings.py index 478f6124..3075aadf 100644 --- a/ranger/container/settings.py +++ b/ranger/container/settings.py @@ -86,6 +86,7 @@ ALLOWED_SETTINGS = { 'tilde_in_titlebar': bool, 'unicode_ellipsis': bool, 'update_title': bool, + 'update_icon_title': bool, 'update_tmux_title': bool, 'use_preview_script': bool, 'vcs_aware': bool, diff --git a/ranger/gui/ui.py b/ranger/gui/ui.py index 2874ee97..207061ce 100644 --- a/ranger/gui/ui.py +++ b/ranger/gui/ui.py @@ -368,7 +368,9 @@ class UI( # pylint: disable=too-many-instance-attributes,too-many-public-method """Draw all objects in the container""" self.win.touchwin() DisplayableContainer.draw(self) - if self._draw_title and self.settings.update_title: + if self._draw_title \ + and (self.settings.update_title + or self.settings.update_icon_title): cwd = self.fm.thisdir.path if self.settings.tilde_in_titlebar \ and (cwd == self.fm.home_path @@ -381,16 +383,24 @@ 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 = ( - curses.tigetstr('tsl').decode('latin-1'), - fixed_cwd, - curses.tigetstr('fsl').decode('latin-1'), - ) + escapes = [ + ( + curses.tigetstr('tsl').decode('latin-1'), + self.settings.update_title, + ), + ( + '\x1b]1;', + self.settings.update_icon_title, + ), + ] + bel = curses.tigetstr('fsl').decode('latin-1') + fmt_tups = [(e, fixed_cwd, bel) for e, s in escapes if s] 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() -- cgit 1.4.1-2-gfad0 From 05e7e2c502a07d9b38ca0c8f055445c38b10d049 Mon Sep 17 00:00:00 2001 From: siikamiika Date: Tue, 30 Jul 2019 21:08:39 +0300 Subject: store escape sequence in a constant for clarity Escape character is also represented with octal notation to be consistent with prior usage --- ranger/gui/ui.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ranger/gui/ui.py b/ranger/gui/ui.py index 207061ce..38065182 100644 --- a/ranger/gui/ui.py +++ b/ranger/gui/ui.py @@ -20,6 +20,11 @@ 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 instead of the window title. +ESCAPE_ICON_TITLE = '\033]1;' + _ASCII = ''.join(chr(c) for c in range(32, 127)) @@ -389,7 +394,7 @@ class UI( # pylint: disable=too-many-instance-attributes,too-many-public-method self.settings.update_title, ), ( - '\x1b]1;', + ESCAPE_ICON_TITLE, self.settings.update_icon_title, ), ] -- cgit 1.4.1-2-gfad0 From 1c4c46c3f62023df361044715840c0ce1225af45 Mon Sep 17 00:00:00 2001 From: toonn Date: Sun, 22 Dec 2019 20:14:04 +0100 Subject: Merge the title settings Upon further consideration we've reconsidered and decided to merge the seperate title update settings. --- doc/ranger.1 | 11 ++++------- doc/ranger.pod | 8 ++------ examples/rc_emacs.conf | 8 +++----- ranger/config/rc.conf | 5 +++-- ranger/container/settings.py | 1 - ranger/gui/ui.py | 19 ++++++------------- 6 files changed, 18 insertions(+), 34 deletions(-) diff --git a/doc/ranger.1 b/doc/ranger.1 index a6e20b4c..84ef458f 100644 --- a/doc/ranger.1 +++ b/doc/ranger.1 @@ -1,4 +1,4 @@ -.\" Automatically generated by Pod::Man 4.10 (Pod::Simple 3.35) +.\" Automatically generated by Pod::Man 4.11 (Pod::Simple 3.35) .\" .\" Standard preamble: .\" ======================================================================== @@ -133,7 +133,7 @@ .\" ======================================================================== .\" .IX Title "RANGER 1" -.TH RANGER 1 "ranger-1.9.2" "2019-10-02" "ranger manual" +.TH RANGER 1 "ranger-1.9.2" "2019-12-22" "ranger manual" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l @@ -1105,13 +1105,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? -.IP "update_icon_title [bool]" 4 -.IX Item "update_icon_title [bool]" -Set an icon 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] " 4 .IX Item "use_preview_script [bool] " Use the preview script defined in the setting \fIpreview_script\fR? diff --git a/doc/ranger.pod b/doc/ranger.pod index 852afcdc..fda1cbc6 100644 --- a/doc/ranger.pod +++ b/doc/ranger.pod @@ -1148,15 +1148,11 @@ Requires the python-bidi pip package. =item update_title [bool] -Set a window title? - -=item update_icon_title [bool] - -Set an icon title? +Set a window title? Updates both the I and I properties. =item update_tmux_title [bool] -Set the title to "ranger" in the tmux program? +Set the tmux I to "ranger"? =item use_preview_script [bool] diff --git a/examples/rc_emacs.conf b/examples/rc_emacs.conf index ba8eaaeb..3b086efd 100644 --- a/examples/rc_emacs.conf +++ b/examples/rc_emacs.conf @@ -131,13 +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 a title for the icon? -set update_icon_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 23601fb6..4a1b14e9 100644 --- a/ranger/config/rc.conf +++ b/ranger/config/rc.conf @@ -182,10 +182,11 @@ set display_tags_in_all_columns true # Set a title for the window? set update_title false -# Set a title for the icon? +# Set a title for the window? Updates both `WM_NAME` and `WM_ICON_NAME` +# properties. set update_icon_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/container/settings.py b/ranger/container/settings.py index 5f0c528b..6fc2da5e 100644 --- a/ranger/container/settings.py +++ b/ranger/container/settings.py @@ -87,7 +87,6 @@ ALLOWED_SETTINGS = { 'tilde_in_titlebar': bool, 'unicode_ellipsis': bool, 'update_title': bool, - 'update_icon_title': bool, 'update_tmux_title': bool, 'use_preview_script': bool, 'vcs_aware': bool, diff --git a/ranger/gui/ui.py b/ranger/gui/ui.py index 38065182..f2cd1715 100644 --- a/ranger/gui/ui.py +++ b/ranger/gui/ui.py @@ -22,7 +22,8 @@ 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 instead of the window title. +# 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)) @@ -373,9 +374,7 @@ class UI( # pylint: disable=too-many-instance-attributes,too-many-public-method """Draw all objects in the container""" self.win.touchwin() DisplayableContainer.draw(self) - if self._draw_title \ - and (self.settings.update_title - or self.settings.update_icon_title): + if self._draw_title and self.settings.update_title: cwd = self.fm.thisdir.path if self.settings.tilde_in_titlebar \ and (cwd == self.fm.home_path @@ -389,17 +388,11 @@ class UI( # pylint: disable=too-many-instance-attributes,too-many-public-method fixed_cwd = cwd.encode('utf-8', 'surrogateescape'). \ decode('utf-8', 'replace') escapes = [ - ( - curses.tigetstr('tsl').decode('latin-1'), - self.settings.update_title, - ), - ( - ESCAPE_ICON_TITLE, - self.settings.update_icon_title, - ), + curses.tigetstr('tsl').decode('latin-1'), + ESCAPE_ICON_TITLE ] bel = curses.tigetstr('fsl').decode('latin-1') - fmt_tups = [(e, fixed_cwd, bel) for e, s in escapes if s] + fmt_tups = [(e, fixed_cwd, bel) for e in escapes] except UnicodeError: pass else: -- cgit 1.4.1-2-gfad0