summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2013-02-16 17:01:18 +0100
committerhut <hut@lavabit.com>2013-02-16 17:02:09 +0100
commit323d2742b488da9ff720e478cb5dec6145c10e54 (patch)
tree3f4394334ee4c743047638d9627e2cadc5e720fb
parent89a1a316c8b3d95ff10db6c8ac349853f80f3faa (diff)
downloadranger-323d2742b488da9ff720e478cb5dec6145c10e54.tar.gz
ext.img_display: moved code to generate input to separate function
-rw-r--r--ranger/ext/img_display.py17
1 files changed, 12 insertions, 5 deletions
diff --git a/ranger/ext/img_display.py b/ranger/ext/img_display.py
index 307c7b75..9dcd276b 100644
--- a/ranger/ext/img_display.py
+++ b/ranger/ext/img_display.py
@@ -43,9 +43,9 @@ def _w3mimgdisplay(commands):
 
     return output
 
-def draw(path, start_x, start_y, max_width, max_height):
+def generate_w3m_input(path, start_x, start_y, max_width, max_height):
     """
-    Draw an image file in the terminal.
+    Prepare the input string for w3mimgpreview
 
     start_x, start_y, max_height and max_width specify the drawing area.
     They are expressed in number of characters.
@@ -75,14 +75,21 @@ def draw(path, start_x, start_y, max_width, max_height):
         width = (width * max_height_pixels) // height
         height = max_height_pixels
 
-    # draw
-    cmd = "0;1;{x};{y};{w};{h};;;;;{filename}\n4;\n3;".format(
+    return "0;1;{x};{y};{w};{h};;;;;{filename}\n4;\n3;".format(
             x = start_x * fontw,
             y = start_y * fonth,
             w = width,
             h = height,
             filename = path)
-    _w3mimgdisplay(cmd)
+
+def draw(path, start_x, start_y, max_width, max_height):
+    """
+    Draw an image file in the terminal.
+
+    start_x, start_y, max_height and max_width specify the drawing area.
+    They are expressed in number of characters.
+    """
+    _w3mimgdisplay(generate_w3m_input(path, start_x, start_y, max_width, max_height))
 
 def clear(start_x, start_y, width, height):
     """