From 5832d5e8dc261e95b90aeb58e6be987f5b8f1ec2 Mon Sep 17 00:00:00 2001 From: hut Date: Wed, 14 Apr 2010 11:34:41 +0200 Subject: removed bad import --- ranger/core/actions.py | 1 - 1 file changed, 1 deletion(-) diff --git a/ranger/core/actions.py b/ranger/core/actions.py index e0f36104..029493b0 100644 --- a/ranger/core/actions.py +++ b/ranger/core/actions.py @@ -21,7 +21,6 @@ from inspect import cleandoc import ranger from ranger import fsobject -from ranger.ext.direction import Direction from ranger.shared import FileManagerAware, EnvironmentAware, SettingsAware from ranger.gui.widgets import console_mode as cmode from ranger.fsobject import File -- cgit 1.4.1-2-gfad0 From 337c6d63361dddc665cfcb133a045b27f331b479 Mon Sep 17 00:00:00 2001 From: hut Date: Wed, 14 Apr 2010 13:38:09 +0200 Subject: colorscheme.default: make sockets bold --- ranger/colorschemes/default.py | 1 + 1 file changed, 1 insertion(+) diff --git a/ranger/colorschemes/default.py b/ranger/colorschemes/default.py index ca8456e7..03173a33 100644 --- a/ranger/colorschemes/default.py +++ b/ranger/colorschemes/default.py @@ -49,6 +49,7 @@ class Default(ColorScheme): fg = green if context.socket: fg = magenta + attr |= bold if context.fifo: fg = yellow if context.link: -- cgit 1.4.1-2-gfad0 From 729286d7489f9a65550848935ebe65e3eaef095b Mon Sep 17 00:00:00 2001 From: hut Date: Wed, 14 Apr 2010 13:39:18 +0200 Subject: identify devices and handle them properly --- ranger/colorschemes/default.py | 4 +++- ranger/fsobject/fsobject.py | 5 ++++- ranger/gui/context.py | 2 +- ranger/gui/widgets/browsercolumn.py | 3 +++ 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/ranger/colorschemes/default.py b/ranger/colorschemes/default.py index 03173a33..335fdf53 100644 --- a/ranger/colorschemes/default.py +++ b/ranger/colorschemes/default.py @@ -50,8 +50,10 @@ class Default(ColorScheme): if context.socket: fg = magenta attr |= bold - if context.fifo: + if context.fifo or context.device: fg = yellow + if context.device: + attr |= bold if context.link: fg = context.good and cyan or magenta if context.tag_marker and not context.selected: diff --git a/ranger/fsobject/fsobject.py b/ranger/fsobject/fsobject.py index 1ab3addd..5dbad537 100644 --- a/ranger/fsobject/fsobject.py +++ b/ranger/fsobject/fsobject.py @@ -41,6 +41,7 @@ class FileSystemObject(MimeTypeAware, FileManagerAware): loaded = False runnable = False islink = False + is_device = False readlink = None stat = None infostring = None @@ -168,7 +169,9 @@ class FileSystemObject(MimeTypeAware, FileManagerAware): self.islink = False self.accessible = False else: - self.islink = stat.S_ISLNK(self.stat.st_mode) + mode = self.stat.st_mode + self.islink = stat.S_ISLNK(mode) + self.is_device = bool(stat.S_ISCHR(mode) or stat.S_ISBLK(mode)) self.accessible = True if self.accessible and os.access(self.path, os.F_OK): diff --git a/ranger/gui/context.py b/ranger/gui/context.py index d4c1c94d..585dd674 100644 --- a/ranger/gui/context.py +++ b/ranger/gui/context.py @@ -17,7 +17,7 @@ CONTEXT_KEYS = ['reset', 'error', 'in_browser', 'in_statusbar', 'in_titlebar', 'in_console', 'in_pager', 'in_taskview', 'directory', 'file', 'hostname', - 'executable', 'media', 'link', 'fifo', 'socket', + 'executable', 'media', 'link', 'fifo', 'socket', 'device', 'video', 'audio', 'image', 'media', 'document', 'container', 'selected', 'empty', 'main_column', 'message', 'background', 'good', 'bad', diff --git a/ranger/gui/widgets/browsercolumn.py b/ranger/gui/widgets/browsercolumn.py index 8301d26a..63bee33d 100644 --- a/ranger/gui/widgets/browsercolumn.py +++ b/ranger/gui/widgets/browsercolumn.py @@ -173,6 +173,7 @@ class BrowserColumn(Pager): and target.is_file \ and target.accessible \ and target.stat \ + and not target.is_device \ and not target.stat.st_mode & stat.S_IFIFO): return False @@ -280,6 +281,8 @@ class BrowserColumn(Pager): this_color.append('fifo') if stat.S_ISSOCK(mode): this_color.append('socket') + if drawn.is_device: + this_color.append('device') if self.env.copy and drawn in self.env.copy: this_color.append('cut' if self.env.cut else 'copied') -- cgit 1.4.1-2-gfad0 From 2025de1d05b61237efc9f85649c6f0045133723f Mon Sep 17 00:00:00 2001 From: hut Date: Wed, 14 Apr 2010 14:33:16 +0200 Subject: renamed fsobject.islink to fsobject.is_link --- ranger/defaults/commands.py | 2 +- ranger/fsobject/fsobject.py | 10 +++++----- ranger/gui/widgets/browsercolumn.py | 2 +- ranger/gui/widgets/statusbar.py | 2 +- ranger/gui/widgets/titlebar.py | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/ranger/defaults/commands.py b/ranger/defaults/commands.py index e69dcf90..2bb860bd 100644 --- a/ranger/defaults/commands.py +++ b/ranger/defaults/commands.py @@ -332,7 +332,7 @@ class delete(Command): cwd = self.fm.env.cwd cf = self.fm.env.cf - if cwd.marked_items or (cf.is_directory and not cf.islink \ + if cwd.marked_items or (cf.is_directory and not cf.is_link \ and len(os.listdir(cf.path)) > 0): # better ask for a confirmation, when attempting to # delete multiple files or a non-empty directory. diff --git a/ranger/fsobject/fsobject.py b/ranger/fsobject/fsobject.py index 5dbad537..3af494b4 100644 --- a/ranger/fsobject/fsobject.py +++ b/ranger/fsobject/fsobject.py @@ -40,7 +40,7 @@ class FileSystemObject(MimeTypeAware, FileManagerAware): tagged = False loaded = False runnable = False - islink = False + is_link = False is_device = False readlink = None stat = None @@ -166,11 +166,11 @@ class FileSystemObject(MimeTypeAware, FileManagerAware): self.stat = os.lstat(self.path) except OSError: self.stat = None - self.islink = False + self.is_link = False self.accessible = False else: mode = self.stat.st_mode - self.islink = stat.S_ISLNK(mode) + self.is_link = stat.S_ISLNK(mode) self.is_device = bool(stat.S_ISCHR(mode) or stat.S_ISBLK(mode)) self.accessible = True @@ -197,7 +197,7 @@ class FileSystemObject(MimeTypeAware, FileManagerAware): self.infostring = None else: - if self.islink: + if self.is_link: self.infostring = '->' else: self.infostring = None @@ -205,7 +205,7 @@ class FileSystemObject(MimeTypeAware, FileManagerAware): self.exists = False self.runnable = False - if self.islink: + if self.is_link: self.readlink = os.readlink(self.path) def get_permission_string(self): diff --git a/ranger/gui/widgets/browsercolumn.py b/ranger/gui/widgets/browsercolumn.py index 63bee33d..0ef37ef1 100644 --- a/ranger/gui/widgets/browsercolumn.py +++ b/ranger/gui/widgets/browsercolumn.py @@ -287,7 +287,7 @@ class BrowserColumn(Pager): if self.env.copy and drawn in self.env.copy: this_color.append('cut' if self.env.cut else 'copied') - if drawn.islink: + if drawn.is_link: this_color.append('link') this_color.append(drawn.exists and 'good' or 'bad') diff --git a/ranger/gui/widgets/statusbar.py b/ranger/gui/widgets/statusbar.py index caf5786e..db415129 100644 --- a/ranger/gui/widgets/statusbar.py +++ b/ranger/gui/widgets/statusbar.py @@ -159,7 +159,7 @@ class StatusBar(Widget): left.add_space() left.add(self._get_group(target), 'group') - if target.islink: + if target.is_link: how = target.exists and 'good' or 'bad' left.add(' -> ' + target.readlink, 'link', how) else: diff --git a/ranger/gui/widgets/titlebar.py b/ranger/gui/widgets/titlebar.py index b815a07e..a949df05 100644 --- a/ranger/gui/widgets/titlebar.py +++ b/ranger/gui/widgets/titlebar.py @@ -118,7 +118,7 @@ class TitleBar(Widget): bar.add('~/', 'directory', fixed=True) for path in pathway: - if path.islink: + if path.is_link: clr = 'link' else: clr = 'directory' -- cgit 1.4.1-2-gfad0 From 50d31c9d7956dc10e3684842cd083860956ac2b3 Mon Sep 17 00:00:00 2001 From: hut Date: Wed, 14 Apr 2010 14:55:26 +0200 Subject: fsobject.fsobject: cleanup --- ranger/fsobject/fsobject.py | 33 ++++++++++++++------------------- 1 file changed, 14 insertions(+), 19 deletions(-) diff --git a/ranger/fsobject/fsobject.py b/ranger/fsobject/fsobject.py index 3af494b4..e910a018 100644 --- a/ranger/fsobject/fsobject.py +++ b/ranger/fsobject/fsobject.py @@ -17,10 +17,15 @@ CONTAINER_EXTENSIONS = 'rar zip tar gz bz bz2 tgz 7z iso cab'.split() DOCUMENT_EXTENSIONS = 'pdf doc ppt odt'.split() DOCUMENT_BASENAMES = 'README TODO LICENSE COPYING INSTALL'.split() -import time +import stat +import os +from time import time +from subprocess import Popen, PIPE +from os.path import abspath, basename, dirname, realpath from . import T_FILE, T_DIRECTORY, T_UNKNOWN, T_NONEXISTANT, BAD_INFO from ranger.shared import MimeTypeAware, FileManagerAware from ranger.ext.shell_escape import shell_escape +from ranger.ext.human_readable import human_readable class FileSystemObject(MimeTypeAware, FileManagerAware): is_file = False @@ -63,10 +68,6 @@ class FileSystemObject(MimeTypeAware, FileManagerAware): def __init__(self, path): MimeTypeAware.__init__(self) - if type(self) == FileSystemObject: - raise TypeError("Cannot initialize abstract class FileSystemObject") - - from os.path import abspath, basename, dirname, realpath path = abspath(path) self.path = path @@ -76,7 +77,8 @@ class FileSystemObject(MimeTypeAware, FileManagerAware): self.realpath = realpath(path) try: - self.extension = self.basename[self.basename.rindex('.') + 1:].lower() + lastdot = self.basename.rindex('.') + 1 + self.extension = self.basename[lastdot:].lower() except ValueError: self.extension = None @@ -95,10 +97,9 @@ class FileSystemObject(MimeTypeAware, FileManagerAware): @property def filetype(self): if self._filetype is None: - import subprocess try: - got = subprocess.Popen(["file", '-Lb', '--mime-type',\ - self.path], stdout=subprocess.PIPE).communicate()[0] + got = Popen(["file", '-Lb', '--mime-type', self.path], + stdout=PIPE).communicate()[0] except OSError: self._filetype = '' else: @@ -114,13 +115,13 @@ class FileSystemObject(MimeTypeAware, FileManagerAware): def use(self): """mark the filesystem-object as used at the current time""" - self.last_used = time.time() + self.last_used = time() def is_older_than(self, seconds): """returns whether this object wasn't use()d in the last n seconds""" if seconds < 0: return True - return self.last_used + seconds < time.time() + return self.last_used + seconds < time() def set_mimetype(self): """assign attributes such as self.video according to the mimetype""" @@ -156,9 +157,6 @@ class FileSystemObject(MimeTypeAware, FileManagerAware): reads useful information about the filesystem-object from the filesystem and caches it for later use """ - import os - import stat - from ranger.ext.human_readable import human_readable self.loaded = True @@ -215,7 +213,6 @@ class FileSystemObject(MimeTypeAware, FileManagerAware): if self.accessible is False: return '----------' - import stat mode = self.stat.st_mode if stat.S_ISDIR(mode): @@ -253,9 +250,8 @@ class FileSystemObject(MimeTypeAware, FileManagerAware): Calls load() if the currently cached information is outdated or nonexistant. """ - if self.load_once(): return True - - import os + if self.load_once(): + return True try: real_mtime = os.lstat(self.path).st_mtime except OSError: @@ -264,7 +260,6 @@ class FileSystemObject(MimeTypeAware, FileManagerAware): cached_mtime = self.stat.st_mtime else: cached_mtime = 0 - if real_mtime != cached_mtime: self.load() return True -- cgit 1.4.1-2-gfad0 From 83832f33c4b69942a700702473917ea4baba83e5 Mon Sep 17 00:00:00 2001 From: hut Date: Wed, 14 Apr 2010 15:37:59 +0200 Subject: widgets.statusbar: better error detection --- ranger/gui/widgets/statusbar.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/ranger/gui/widgets/statusbar.py b/ranger/gui/widgets/statusbar.py index db415129..52425943 100644 --- a/ranger/gui/widgets/statusbar.py +++ b/ranger/gui/widgets/statusbar.py @@ -145,15 +145,18 @@ class StatusBar(Widget): target = self.column.target.pointed_obj else: target = self.env.at_level(0).pointed_obj - if target is None or not target.accessible: + try: + stat = target.stat + except: + return + if stat is None: return perms = target.get_permission_string() - how = getuid() == target.stat.st_uid and 'good' or 'bad' + how = getuid() == stat.st_uid and 'good' or 'bad' left.add(perms, 'permissions', how) - left.add_space() - left.add(str(target.stat.st_nlink), 'nlink') + left.add(str(stat.st_nlink), 'nlink') left.add_space() left.add(self._get_owner(target), 'owner') left.add_space() @@ -169,7 +172,7 @@ class StatusBar(Widget): left.add_space() left.add(strftime(self.timeformat, - localtime(target.stat.st_mtime)), 'mtime') + localtime(stat.st_mtime)), 'mtime') def _get_owner(self, target): uid = target.stat.st_uid -- cgit 1.4.1-2-gfad0 From 2f109a60fb6a7978b8259408ce8477824e4471e9 Mon Sep 17 00:00:00 2001 From: hut Date: Wed, 14 Apr 2010 15:41:17 +0200 Subject: fsobject.fsobject: get the stat() of link destinations --- ranger/fsobject/fsobject.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ranger/fsobject/fsobject.py b/ranger/fsobject/fsobject.py index e910a018..ada00bb0 100644 --- a/ranger/fsobject/fsobject.py +++ b/ranger/fsobject/fsobject.py @@ -167,8 +167,13 @@ class FileSystemObject(MimeTypeAware, FileManagerAware): self.is_link = False self.accessible = False else: + self.is_link = stat.S_ISLNK(self.stat.st_mode) + if self.is_link: + try: # try to resolve the link + self.stat = os.stat(self.path) + except: # it failed, so it must be a broken link + pass mode = self.stat.st_mode - self.is_link = stat.S_ISLNK(mode) self.is_device = bool(stat.S_ISCHR(mode) or stat.S_ISBLK(mode)) self.accessible = True -- cgit 1.4.1-2-gfad0 From 57435fbf56e83fe9b73d51771b853b34cd7f41db Mon Sep 17 00:00:00 2001 From: hut Date: Wed, 14 Apr 2010 15:53:02 +0200 Subject: fsobject.fsobject: display more information added attributes is_socket and is_fifo add special file info to infostring --- ranger/fsobject/fsobject.py | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/ranger/fsobject/fsobject.py b/ranger/fsobject/fsobject.py index ada00bb0..f2f440c1 100644 --- a/ranger/fsobject/fsobject.py +++ b/ranger/fsobject/fsobject.py @@ -47,6 +47,8 @@ class FileSystemObject(MimeTypeAware, FileManagerAware): runnable = False is_link = False is_device = False + is_socket = False + is_fifo = False readlink = None stat = None infostring = None @@ -175,6 +177,8 @@ class FileSystemObject(MimeTypeAware, FileManagerAware): pass mode = self.stat.st_mode self.is_device = bool(stat.S_ISCHR(mode) or stat.S_ISBLK(mode)) + self.is_socket = bool(stat.S_ISSOCK(mode)) + self.is_fifo = bool(stat.S_ISFIFO(mode)) self.accessible = True if self.accessible and os.access(self.path, os.F_OK): @@ -197,7 +201,14 @@ class FileSystemObject(MimeTypeAware, FileManagerAware): self.infostring = ' ' + human_readable(self.stat.st_size) else: self.type = T_UNKNOWN - self.infostring = None + if self.is_device: + self.infostring = 'dev' + elif self.is_fifo: + self.infostring = 'fifo' + elif self.is_socket: + self.infostring = 'sock' + else: + self.infostring = None else: if self.is_link: @@ -215,10 +226,10 @@ class FileSystemObject(MimeTypeAware, FileManagerAware): if self.permissions is not None: return self.permissions - if self.accessible is False: - return '----------' - - mode = self.stat.st_mode + try: + mode = self.stat.st_mode + except: + return '----??----' if stat.S_ISDIR(mode): perms = ['d'] -- cgit 1.4.1-2-gfad0 From 1cf19f8f7c2a386b574676b938c31b6f3c707d76 Mon Sep 17 00:00:00 2001 From: hut Date: Wed, 14 Apr 2010 15:54:38 +0200 Subject: fixed rarely occuring permission issue The case where you're not allowed to read the destination of a link was not handled properly. This happens namely in the procfs. --- ranger/fsobject/fsobject.py | 7 +++---- ranger/gui/widgets/statusbar.py | 3 ++- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ranger/fsobject/fsobject.py b/ranger/fsobject/fsobject.py index f2f440c1..516f02e6 100644 --- a/ranger/fsobject/fsobject.py +++ b/ranger/fsobject/fsobject.py @@ -76,7 +76,7 @@ class FileSystemObject(MimeTypeAware, FileManagerAware): self.basename = basename(path) self.basename_lower = self.basename.lower() self.dirname = dirname(path) - self.realpath = realpath(path) + self.realpath = self.path try: lastdot = self.basename.rindex('.') + 1 @@ -172,6 +172,8 @@ class FileSystemObject(MimeTypeAware, FileManagerAware): self.is_link = stat.S_ISLNK(self.stat.st_mode) if self.is_link: try: # try to resolve the link + self.readlink = os.readlink(self.path) + self.realpath = realpath(self.path) self.stat = os.stat(self.path) except: # it failed, so it must be a broken link pass @@ -219,9 +221,6 @@ class FileSystemObject(MimeTypeAware, FileManagerAware): self.exists = False self.runnable = False - if self.is_link: - self.readlink = os.readlink(self.path) - def get_permission_string(self): if self.permissions is not None: return self.permissions diff --git a/ranger/gui/widgets/statusbar.py b/ranger/gui/widgets/statusbar.py index 52425943..bff3d8ad 100644 --- a/ranger/gui/widgets/statusbar.py +++ b/ranger/gui/widgets/statusbar.py @@ -164,7 +164,8 @@ class StatusBar(Widget): if target.is_link: how = target.exists and 'good' or 'bad' - left.add(' -> ' + target.readlink, 'link', how) + dest = target.readlink if target.readlink is not None else '?' + left.add(' -> ' + dest, 'link', how) else: if self.settings.display_size_in_status_bar and target.infostring: left.add(target.infostring) -- cgit 1.4.1-2-gfad0 From 8c364ad44cfdba9ce2dd6d2dd7e1885b3e433f66 Mon Sep 17 00:00:00 2001 From: hut Date: Wed, 14 Apr 2010 15:58:47 +0200 Subject: fsobject: use a "?" if no infostring is available --- ranger/fsobject/__init__.py | 2 +- ranger/fsobject/fsobject.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/ranger/fsobject/__init__.py b/ranger/fsobject/__init__.py index 5f727c87..6796f252 100644 --- a/ranger/fsobject/__init__.py +++ b/ranger/fsobject/__init__.py @@ -21,7 +21,7 @@ T_DIRECTORY = 'directory' T_UNKNOWN = 'unknown' T_NONEXISTANT = 'nonexistant' -BAD_INFO = None +BAD_INFO = '?' class NotLoadedYet(Exception): pass diff --git a/ranger/fsobject/fsobject.py b/ranger/fsobject/fsobject.py index 516f02e6..94729b9a 100644 --- a/ranger/fsobject/fsobject.py +++ b/ranger/fsobject/fsobject.py @@ -16,6 +16,8 @@ CONTAINER_EXTENSIONS = 'rar zip tar gz bz bz2 tgz 7z iso cab'.split() DOCUMENT_EXTENSIONS = 'pdf doc ppt odt'.split() DOCUMENT_BASENAMES = 'README TODO LICENSE COPYING INSTALL'.split() +DOCUMENT_EXTENSIONS = () +DOCUMENT_BASENAMES = () import stat import os @@ -210,7 +212,7 @@ class FileSystemObject(MimeTypeAware, FileManagerAware): elif self.is_socket: self.infostring = 'sock' else: - self.infostring = None + self.infostring = BAD_INFO else: if self.is_link: -- cgit 1.4.1-2-gfad0 From 7327aab14542763cdd1e135ed5317fccab1d51d4 Mon Sep 17 00:00:00 2001 From: hut Date: Wed, 14 Apr 2010 16:34:34 +0200 Subject: widgets.browsercolumn: added sanity check when clicking on preview --- ranger/gui/widgets/browsercolumn.py | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/ranger/gui/widgets/browsercolumn.py b/ranger/gui/widgets/browsercolumn.py index 0ef37ef1..7d38576d 100644 --- a/ranger/gui/widgets/browsercolumn.py +++ b/ranger/gui/widgets/browsercolumn.py @@ -95,20 +95,21 @@ class BrowserColumn(Pager): pass elif self.target.type is T_DIRECTORY: - index = self.scroll_begin + event.y - self.y - - if event.pressed(1): - if not self.main_column: - self.fm.enter_dir(self.target.path) - - if index < len(self.target): - self.fm.move_pointer(absolute = index) - elif event.pressed(3): - try: - clicked_file = self.target.files[index] - self.fm.enter_dir(clicked_file.path) - except: - pass + if self.target.accessible and self.target.content_loaded: + index = self.scroll_begin + event.y - self.y + + if event.pressed(1): + if not self.main_column: + self.fm.enter_dir(self.target.path) + + if index < len(self.target): + self.fm.move_pointer(absolute = index) + elif event.pressed(3): + try: + clicked_file = self.target.files[index] + self.fm.enter_dir(clicked_file.path) + except: + pass else: if self.level > 0: -- cgit 1.4.1-2-gfad0 From 1d3d94aac68790581e1e4027d0ecc868c516fea1 Mon Sep 17 00:00:00 2001 From: hut Date: Wed, 14 Apr 2010 16:35:06 +0200 Subject: widget.browsercolumn: display "?" in info in a different color --- ranger/colorschemes/default.py | 5 +++++ ranger/gui/context.py | 2 +- ranger/gui/widgets/browsercolumn.py | 7 +++++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/ranger/colorschemes/default.py b/ranger/colorschemes/default.py index 335fdf53..317e8258 100644 --- a/ranger/colorschemes/default.py +++ b/ranger/colorschemes/default.py @@ -71,6 +71,11 @@ class Default(ColorScheme): if context.marked: attr |= bold fg = yellow + if context.badinfo: + if attr & reverse: + bg = magenta + else: + fg = magenta elif context.in_titlebar: attr |= bold diff --git a/ranger/gui/context.py b/ranger/gui/context.py index 585dd674..1e127a2e 100644 --- a/ranger/gui/context.py +++ b/ranger/gui/context.py @@ -13,7 +13,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -CONTEXT_KEYS = ['reset', 'error', +CONTEXT_KEYS = ['reset', 'error', 'badinfo', 'in_browser', 'in_statusbar', 'in_titlebar', 'in_console', 'in_pager', 'in_taskview', 'directory', 'file', 'hostname', diff --git a/ranger/gui/widgets/browsercolumn.py b/ranger/gui/widgets/browsercolumn.py index 7d38576d..c0b60a2e 100644 --- a/ranger/gui/widgets/browsercolumn.py +++ b/ranger/gui/widgets/browsercolumn.py @@ -20,6 +20,7 @@ from time import time from . import Widget from .pager import Pager +from ranger.fsobject import BAD_INFO # Don't even try to preview files which mach this regular expression: PREVIEW_BLACKLIST = re.compile(r""" @@ -252,6 +253,7 @@ class BrowserColumn(Pager): except IndexError: break + bad_info_color = None this_color = base_color + list(drawn.mimetype_tuple) text = drawn.basename tagged = self.fm.tags and drawn.realpath in self.fm.tags @@ -306,6 +308,8 @@ class BrowserColumn(Pager): and self.settings.display_size_in_main_column: info = drawn.infostring x = self.wid - 1 - len(info) + if info is BAD_INFO: + bad_info_color = (x, len(str(info))) if x > self.x: self.win.addstr(line, x, str(info) + ' ') except: @@ -314,6 +318,9 @@ class BrowserColumn(Pager): pass self.color_at(line, 0, self.wid, this_color) + if bad_info_color: + start, wid = bad_info_color + self.color_at(line, start, wid, this_color, 'badinfo') if self.main_column and tagged and self.wid > 2: this_color.append('tag_marker') -- cgit 1.4.1-2-gfad0