summary refs log tree commit diff stats
path: root/ranger
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2010-04-14 13:39:18 +0200
committerhut <hut@lavabit.com>2010-04-14 13:39:18 +0200
commit729286d7489f9a65550848935ebe65e3eaef095b (patch)
tree289bd7266cf585ebe87ef0f6db35cb575e0e4bae /ranger
parent337c6d63361dddc665cfcb133a045b27f331b479 (diff)
downloadranger-729286d7489f9a65550848935ebe65e3eaef095b.tar.gz
identify devices and handle them properly
Diffstat (limited to 'ranger')
-rw-r--r--ranger/colorschemes/default.py4
-rw-r--r--ranger/fsobject/fsobject.py5
-rw-r--r--ranger/gui/context.py2
-rw-r--r--ranger/gui/widgets/browsercolumn.py3
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')