summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--ranger/core/actions.py2
-rwxr-xr-xranger/data/scope.sh16
-rw-r--r--ranger/fsobject/file.py8
-rw-r--r--ranger/gui/widgets/browsercolumn.py2
4 files changed, 18 insertions, 10 deletions
diff --git a/ranger/core/actions.py b/ranger/core/actions.py
index 743d82c5..44061aca 100644
--- a/ranger/core/actions.py
+++ b/ranger/core/actions.py
@@ -471,7 +471,7 @@ class Actions(FileManagerAware, EnvironmentAware, SettingsAware):
 			return
 
 		pager = self.ui.open_embedded_pager()
-		pager.set_source(self.env.cf.get_preview_source())
+		pager.set_source(self.env.cf.get_preview_source(pager))
 
 	# --------------------------
 	# -- Tabs
diff --git a/ranger/data/scope.sh b/ranger/data/scope.sh
index ef5f8ff4..80fd2ea7 100755
--- a/ranger/data/scope.sh
+++ b/ranger/data/scope.sh
@@ -3,12 +3,22 @@
 # This script is called whenever you preview a file.
 # Its output is used as the preview.  ANSI color codes are supported.
 
-# Meaning of exit codes:
+# NOTE: This is considered to be a configuration file.  If you upgrade
+# ranger, it will be left untouched. (You must update it yourself)
+
+# Meanings of arguments:
+# name | meaning
+# -----+--------------------------------------------------------
+# $1   | Full filename of the selected file
+# $2   | Width of the preview pane (number of fitting characters)
+# $3   | Height of the preview pane (number of fitting characters)
+
+# Meanings of exit codes:
 # code | meaning    | action of ranger
 # -----+------------+-------------------------------------------
 # 0    | success    | display stdout as preview
 # 1    | no preview | display no preview at all
-
+# 2    | plain text | display the plain content of the file
 
 mimetype=$(file --mime-type -Lb "$1")
 extension=$(echo "$1" | grep '\.' | grep -o '[^.]\+$')
@@ -32,7 +42,7 @@ case "$mimetype" in
 		exit 0;;
 	# Ascii-previews of images:
 	image/*)
-		img2txt "$1" || exit 1
+		img2txt -W "$2" "$1" || exit 1
 		exit 0;;
 esac
 
diff --git a/ranger/fsobject/file.py b/ranger/fsobject/file.py
index 216b4754..4acad100 100644
--- a/ranger/fsobject/file.py
+++ b/ranger/fsobject/file.py
@@ -14,7 +14,6 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 import re
-import zipfile
 from ranger.fsobject import FileSystemObject
 from subprocess import Popen, PIPE
 from ranger.core.runner import devnull
@@ -35,8 +34,6 @@ PREVIEW_BLACKLIST = re.compile(r"""
 				| vob | wav | mpc | flac | divx? | xcf | pdf
 			# binary files:
 				| torrent | class | so | img | py[co] | dmg
-			# containers:
-				| iso | rar | 7z | tar | gz | bz2 | tgz
 		)
 		# ignore filetype-independent suffixes:
 			(\.part|\.bak|~)?
@@ -93,10 +90,11 @@ class File(FileSystemObject):
 			return False
 		return True
 
-	def get_preview_source(self):
+	def get_preview_source(self, widget):
 		if self.fm.settings.preview_script:
 			try:
-				p = Popen([self.fm.settings.preview_script, self.path],
+				p = Popen([self.fm.settings.preview_script, self.path,
+						str(widget.wid), str(widget.hei)],
 						stdout=PIPE, stderr=devnull)
 				if p.poll():  # nonzero exit code
 					return None
diff --git a/ranger/gui/widgets/browsercolumn.py b/ranger/gui/widgets/browsercolumn.py
index d617e64e..5585bccc 100644
--- a/ranger/gui/widgets/browsercolumn.py
+++ b/ranger/gui/widgets/browsercolumn.py
@@ -155,7 +155,7 @@ class BrowserColumn(Pager):
 			return
 
 		try:
-			f = self.target.get_preview_source()
+			f = self.target.get_preview_source(self)
 		except:
 			Pager.close(self)
 		else: