summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorhut <hut@hut.pm>2017-12-20 01:56:47 +0100
committerhut <hut@hut.pm>2017-12-20 01:56:47 +0100
commit9fb497e90ceb6a66b5944b0f443464b5a28f5be1 (patch)
tree239db4f1ba1b820d1bf6b0a1fdd60d1c2c83d91b
parent64f2d2c8538a430d284c9f486d785c108e328a8b (diff)
parent538986719e81987d7a08aa083757f345fa9acaee (diff)
downloadranger-9fb497e90ceb6a66b5944b0f443464b5a28f5be1.tar.gz
Merge branch 'master' of https://github.com/jgreco/ranger
-rw-r--r--doc/ranger.14
-rw-r--r--doc/ranger.pod4
-rw-r--r--ranger/config/rc.conf8
-rw-r--r--ranger/container/settings.py2
-rw-r--r--ranger/ext/img_display.py6
5 files changed, 20 insertions, 4 deletions
diff --git a/doc/ranger.1 b/doc/ranger.1
index 50b83bdf..bb7114a2 100644
--- a/doc/ranger.1
+++ b/doc/ranger.1
@@ -296,6 +296,10 @@ ssh.
 .PP
 To enable this feature, set the option \f(CW\*(C`preview_images_method\*(C'\fR to iterm2.
 .PP
+This feature relies on the dimensions of the terminal's font.  By default, a
+width of 8 and height of 11 are used.  To use other values, set the options
+\&\f(CW\*(C`iterm2_font_width\*(C'\fR and \f(CW\*(C`iterm2_font_height\*(C'\fR to the desired values.
+.PP
 \fIurxvt\fR
 .IX Subsection "urxvt"
 .PP
diff --git a/doc/ranger.pod b/doc/ranger.pod
index 310ab1fd..43926f46 100644
--- a/doc/ranger.pod
+++ b/doc/ranger.pod
@@ -201,6 +201,10 @@ ssh.
 
 To enable this feature, set the option C<preview_images_method> to iterm2.
 
+This feature relies on the dimensions of the terminal's font.  By default, a
+width of 8 and height of 11 are used.  To use other values, set the options
+C<iterm2_font_width> and C<iterm2_font_height> to the desired values.
+
 =head3 urxvt
 
 This only works in urxvt compiled with pixbuf support. Does not work over ssh.
diff --git a/ranger/config/rc.conf b/ranger/config/rc.conf
index d7f61550..6bb8f0d0 100644
--- a/ranger/config/rc.conf
+++ b/ranger/config/rc.conf
@@ -80,6 +80,10 @@ set preview_images false
 #   (http://iterm2.com/images.html). This requires using iTerm2 compiled
 #   with image preview support.
 #
+#   This feature relies on the dimensions of the terminal's font.  By default, a
+#   width of 8 and height of 11 are used.  To use other values, set the options
+#   iterm2_font_width and iterm2_font_height to the desired values.
+#
 # * urxvt:
 #   Preview images in full color using urxvt image backgrounds. This
 #   requires using urxvt compiled with pixbuf support.
@@ -89,6 +93,10 @@ set preview_images false
 #   whole terminal window.
 set preview_images_method w3m
 
+# Default iTerm2 font size (see: preview_images_method: iterm2)
+set iterm2_font_width 8
+set iterm2_font_height 11
+
 # Use a unicode "..." character to mark cut-off filenames?
 set unicode_ellipsis false
 
diff --git a/ranger/container/settings.py b/ranger/container/settings.py
index bb902f9d..2f38a2b6 100644
--- a/ranger/container/settings.py
+++ b/ranger/container/settings.py
@@ -47,6 +47,8 @@ ALLOWED_SETTINGS = {
     'hidden_filter': str,
     'hostname_in_titlebar': bool,
     'idle_delay': int,
+    'iterm2_font_width': int,
+    'iterm2_font_height': int,
     'line_numbers': str,
     'max_console_history_size': (int, type(None)),
     'max_history_size': (int, type(None)),
diff --git a/ranger/ext/img_display.py b/ranger/ext/img_display.py
index 5c1ba3d1..01c739d3 100644
--- a/ranger/ext/img_display.py
+++ b/ranger/ext/img_display.py
@@ -208,8 +208,6 @@ class ITerm2ImageDisplayer(ImageDisplayer, FileManagerAware):
 
     Ranger must be running in iTerm2 for this to work.
     """
-    _minimum_font_width = 8
-    _minimum_font_height = 11
 
     def draw(self, path, start_x, start_y, width, height):
         curses.putp(curses.tigetstr("sc"))
@@ -249,8 +247,8 @@ class ITerm2ImageDisplayer(ImageDisplayer, FileManagerAware):
         return text
 
     def _fit_width(self, width, height, max_cols, max_rows):
-        max_width = self._minimum_font_width * max_cols
-        max_height = self._minimum_font_height * max_rows
+        max_width = self.fm.settings.iterm2_font_width * max_cols
+        max_height = self.fm.settings.iterm2_font_height * max_rows
         if height > max_height:
             if width > max_width:
                 width_scale = max_width / width