diff options
author | hut <hut@lepus.uberspace.de> | 2016-11-04 14:58:37 -0400 |
---|---|---|
committer | hut <hut@lepus.uberspace.de> | 2016-11-04 14:58:37 -0400 |
commit | cd074b321a94edcd0c6715f10b46c2465fae309e (patch) | |
tree | d6aaeb97c425aebc9de6632e5f52a7fa2f4008e5 /ranger | |
parent | a5d6fbd7354c2f02af5cb1e21f781cf9e2939946 (diff) | |
parent | 9197a4b5d3ffafe4b9305db465da6ce6dc7616ac (diff) | |
download | ranger-cd074b321a94edcd0c6715f10b46c2465fae309e.tar.gz |
Merge branch 'urxvt_preview' of https://github.com/Vifon/ranger
Diffstat (limited to 'ranger')
-rw-r--r-- | ranger/ext/img_display.py | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/ranger/ext/img_display.py b/ranger/ext/img_display.py index a7e2f511..0e6b08fe 100644 --- a/ranger/ext/img_display.py +++ b/ranger/ext/img_display.py @@ -305,11 +305,26 @@ class URXVTImageDisplayer(ImageDisplayer, FileManagerAware): """ + def _get_max_sizes(self): + """Use the whole terminal.""" + w = 100 + h = 100 + return w, h + + def _get_centered_offsets(self): + """Center the image.""" + x = 50 + y = 50 + return x, y + def _get_sizes(self): """Return the width and height of the preview pane in relation to the whole terminal window. """ + if self.fm.ui.pager.visible: + return self._get_max_sizes() + total_columns_ratio = sum(self.fm.settings.column_ratios) preview_column_ratio = self.fm.settings.column_ratios[-1] w = int((100 * preview_column_ratio) / total_columns_ratio) @@ -318,6 +333,9 @@ class URXVTImageDisplayer(ImageDisplayer, FileManagerAware): def _get_offsets(self): """Return the offsets of the image center.""" + if self.fm.ui.pager.visible: + return self._get_centered_offsets() + x = 100 # Right-aligned. y = 2 # TODO: Use the font size to calculate this offset. return x, y @@ -348,12 +366,8 @@ class URXVTImageFSDisplayer(URXVTImageDisplayer): def _get_sizes(self): """Use the whole terminal.""" - w = 100 - h = 100 - return w, h + return self._get_max_sizes() def _get_offsets(self): """Center the image.""" - x = 50 - y = 50 - return x, y + return self._get_centered_offsets() |