diff options
author | nfnty <git@nfnty.se> | 2017-01-29 23:43:06 +0100 |
---|---|---|
committer | nfnty <git@nfnty.se> | 2017-01-29 23:43:06 +0100 |
commit | c494d4680bef0320ea89304dbf62d24e559488dd (patch) | |
tree | 8ee138567aa5360c75148c5e365a22f535a8fac1 /ranger | |
parent | aed063715b56b7ab080b48a07c60350fa61eaba3 (diff) | |
parent | 5fa47d6086b6dfccbd43dd48150fae8a5618afb3 (diff) | |
download | ranger-c494d4680bef0320ea89304dbf62d24e559488dd.tar.gz |
Merge remote-tracking branch 'Vifon/urxvt_preview_cleanup'
Diffstat (limited to 'ranger')
-rw-r--r-- | ranger/ext/img_display.py | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/ranger/ext/img_display.py b/ranger/ext/img_display.py index b4deaa39..d8d0b20b 100644 --- a/ranger/ext/img_display.py +++ b/ranger/ext/img_display.py @@ -317,6 +317,14 @@ class URXVTImageDisplayer(ImageDisplayer, FileManagerAware): """ + def __init__(self): + self.display_protocol = "\033" + self.close_protocol = "\a" + if "screen" in os.environ['TERM']: + self.display_protocol += "Ptmux;\033\033" + self.close_protocol += "\033\\" + self.display_protocol += "]20;" + @staticmethod def _get_max_sizes(): """Use the whole terminal.""" @@ -364,20 +372,25 @@ class URXVTImageDisplayer(ImageDisplayer, FileManagerAware): pct_width, pct_height = self._get_sizes() sys.stdout.write( - "\033]20;{path};{pct_width}x{pct_height}+{pct_x}+{pct_y}:op=keep-aspect\a".format( - path=path, pct_width=pct_width, pct_height=pct_height, - pct_x=pct_x, pct_y=pct_y, - ) + self.display_protocol + + path + + ";{pct_width}x{pct_height}+{pct_x}+{pct_y}:op=keep-aspect".format( + pct_width=pct_width, pct_height=pct_height, pct_x=pct_x, pct_y=pct_y + ) + + self.close_protocol ) sys.stdout.flush() def clear(self, start_x, start_y, width, height): - sys.stdout.write("\033]20;;100x100+1000+1000\a") + sys.stdout.write( + self.display_protocol + + ";100x100+1000+1000" + + self.close_protocol + ) sys.stdout.flush() def quit(self): - sys.stdout.write("\033]20;;100x100+1000+1000\a") - sys.stdout.flush() + self.clear(0, 0, 0, 0) # dummy assignments class URXVTImageFSDisplayer(URXVTImageDisplayer): |