summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorLeLobster <nhoise@live.nl>2018-10-04 23:44:43 +0200
committerLeLobster <nhoise@live.nl>2018-10-04 23:44:43 +0200
commitf848c140c381e8ac8f9e248e96d1d3df50258093 (patch)
treef8c86bc1bf66aff64b20aeb7001e3bdc73787f68
parent036d2f312632b1a65876a7b56678a0828104b483 (diff)
downloadranger-f848c140c381e8ac8f9e248e96d1d3df50258093.tar.gz
Add option to set a border value for use with st term
-rw-r--r--ranger/config/rc.conf3
-rw-r--r--ranger/container/settings.py1
-rw-r--r--ranger/ext/img_display.py7
3 files changed, 9 insertions, 2 deletions
diff --git a/ranger/config/rc.conf b/ranger/config/rc.conf
index a32ab494..0e2af8cc 100644
--- a/ranger/config/rc.conf
+++ b/ranger/config/rc.conf
@@ -112,6 +112,9 @@ set preview_images_method w3m
 # Increase it in case of experiencing display corruption.
 set w3m_delay 0.02
 
+# Manually adjust the w3mimg offset when using a st terminal with a border value > 0
+set st_border_offset 0
+
 # Default iTerm2 font size (see: preview_images_method: iterm2)
 set iterm2_font_width 8
 set iterm2_font_height 11
diff --git a/ranger/container/settings.py b/ranger/container/settings.py
index 70a12b51..322bc11b 100644
--- a/ranger/container/settings.py
+++ b/ranger/container/settings.py
@@ -82,6 +82,7 @@ ALLOWED_SETTINGS = {
     'sort': str,
     'sort_unicode': bool,
     'status_bar_on_top': bool,
+    'st_border_offset': int,
     'tilde_in_titlebar': bool,
     'unicode_ellipsis': bool,
     'update_title': bool,
diff --git a/ranger/ext/img_display.py b/ranger/ext/img_display.py
index cd9b18d6..048775ef 100644
--- a/ranger/ext/img_display.py
+++ b/ranger/ext/img_display.py
@@ -219,9 +219,12 @@ class W3MImageDisplayer(ImageDisplayer, FileManagerAware):
             width = (width * max_height_pixels) // height
             height = max_height_pixels
 
+        posx=int(((start_x - 0.2) * fontw) + self.fm.settings.st_border_offset)
+        posy=(start_y * fonth) + self.fm.settings.st_border_offset
+
         return "0;1;{x};{y};{w};{h};;;;;{filename}\n4;\n3;\n".format(
-            x=int((start_x - 0.2) * fontw),
-            y=start_y * fonth,
+            x=posx,
+            y=posy,
             # y = (start_y + 1) * fonth, # (for tmux top status bar)
             w=width,
             h=height,