summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2010-02-25 16:41:25 +0100
committerhut <hut@lavabit.com>2010-02-25 20:37:11 +0100
commit7a268c8be8896d3ec71952a6fd261012e39c1c1a (patch)
tree101d930825a43be2ba53e37ae301d4a38111996e
parent0c2c782dd8ff7cfc74fc46dd68eda0b94d540058 (diff)
downloadranger-7a268c8be8896d3ec71952a6fd261012e39c1c1a.tar.gz
todo: finished #63: limit filesize in previews
-rw-r--r--TODO3
-rw-r--r--ranger/defaults/options.py3
-rw-r--r--ranger/gui/widgets/browsercolumn.py4
-rw-r--r--ranger/shared/settings.py1
4 files changed, 9 insertions, 2 deletions
diff --git a/TODO b/TODO
index 78aaeb97..bbf59c37 100644
--- a/TODO
+++ b/TODO
@@ -44,7 +44,8 @@ General
    ( ) #57  10/01/30  warn before deleting unseen marked files
    (X) #58  10/02/04  change the title of the terminal
    (X) #61  10/02/09  show sum of size of marked files
-   ( ) #63  10/02/15  limit filesize in previews
+   (X) #63  10/02/15  limit filesize in previews
+   ( ) #64  10/02/25  scroll in previews
 
 
 Bugs
diff --git a/ranger/defaults/options.py b/ranger/defaults/options.py
index 1f564eb0..6a1ae862 100644
--- a/ranger/defaults/options.py
+++ b/ranger/defaults/options.py
@@ -6,9 +6,12 @@ intact and the type of the value stays the same.
 
 from ranger.api.options import *
 
+one_kb = 1024
+
 colorscheme = colorschemes.default
 
 max_history_size = 20
+max_filesize_for_preview = 300 * one_kb
 scroll_offset = 2
 preview_files = True
 flushinput = True
diff --git a/ranger/gui/widgets/browsercolumn.py b/ranger/gui/widgets/browsercolumn.py
index 956fd301..b07d86ed 100644
--- a/ranger/gui/widgets/browsercolumn.py
+++ b/ranger/gui/widgets/browsercolumn.py
@@ -137,8 +137,10 @@ class BrowserColumn(Pager, Widget):
 			self.last_redraw_time = time()
 
 	def _preview_this_file(self, target):
+		maxsize = self.settings.max_filesize_for_preview
 		return self.settings.preview_files \
-				and not PREVIEW_BLACKLIST.search(target.basename)
+				and not PREVIEW_BLACKLIST.search(target.basename) \
+				and (maxsize is None or maxsize >= target.size)
 
 	def _draw_file(self):
 		"""Draw a preview of the file, if the settings allow it"""
diff --git a/ranger/shared/settings.py b/ranger/shared/settings.py
index 4ae97e03..152dfbd1 100644
--- a/ranger/shared/settings.py
+++ b/ranger/shared/settings.py
@@ -19,6 +19,7 @@ preview_files max_history_size colorscheme
 collapse_preview update_title
 hidden_filter flushinput
 autosave_bookmarks
+max_filesize_for_preview
 """.split()
 
 # -- globalize the settings --