diff options
author | hut <hut@lepus.uberspace.de> | 2014-02-16 20:45:47 +0100 |
---|---|---|
committer | hut <hut@lepus.uberspace.de> | 2014-02-16 20:45:47 +0100 |
commit | c32ca19711501ae299f081cf07ac8eddb46dfbf5 (patch) | |
tree | 456893997f21e39791c8c461dd2e4efd882e29a6 | |
parent | ab90d5bb637c0ecf90eb3bb3f5a9c696f3b43a13 (diff) | |
download | ranger-c32ca19711501ae299f081cf07ac8eddb46dfbf5.tar.gz |
ext.image_display: new _get_font_dimensions implementation (broken)
This allows drawing of images in gnome_terminal and tmux. It is currently broken, since the image is drawn at the wrong place. Thanks to CasperVector, joehillen, majutsushi and progandy for the patch and corrections. See https://github.com/hut/ranger/issues/109 and https://savannah.nongnu.org/bugs/?40888
-rw-r--r-- | ranger/ext/img_display.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/ranger/ext/img_display.py b/ranger/ext/img_display.py index 3d710837..77f8acaa 100644 --- a/ranger/ext/img_display.py +++ b/ranger/ext/img_display.py @@ -116,5 +116,14 @@ def _get_font_dimensions(): fd_stdout = sys.stdout.fileno() x = fcntl.ioctl(fd_stdout, termios.TIOCGWINSZ, s) rows, cols, xpixels, ypixels = struct.unpack("HHHH", x) + if xpixels == 0 and ypixels == 0: + binary_path = os.environ.get("W3MIMGDISPLAY_PATH", None) + if not binary_path: + binary_path = W3MIMGDISPLAY_PATH + process = Popen([binary_path, "-test"], + stdout=PIPE, universal_newlines=True) + output, _ = process.communicate() + output = output.split() + xpixels, ypixels = int(output[0]), int(output[1]) return (xpixels // cols), (ypixels // rows) |