From 9197a4b5d3ffafe4b9305db465da6ce6dc7616ac Mon Sep 17 00:00:00 2001 From: Wojciech Siewierski Date: Tue, 11 Oct 2016 19:02:31 +0200 Subject: urxvt previews: Allow the preview maximization --- ranger/ext/img_display.py | 26 ++++++++++++++++++++------ 1 file 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() -- cgit 1.4.1-2-gfad0