summary refs log tree commit diff stats
path: root/code
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2009-06-13 02:12:18 +0200
committerhut <hut@lavabit.com>2009-06-13 02:12:18 +0200
commit325ec37f65172b5b640d998eba300d86d1ddbfa5 (patch)
treec79d62778129368d3341be11c72d612f6fb230b5 /code
parent888a5ad315f0c6b6178e3ece3996cd495eb44705 (diff)
downloadranger-325ec37f65172b5b640d998eba300d86d1ddbfa5.tar.gz
expanded color scheme support
Diffstat (limited to 'code')
-rw-r--r--code/color.rb23
-rw-r--r--code/fm/draw.rb26
2 files changed, 36 insertions, 13 deletions
diff --git a/code/color.rb b/code/color.rb
index e131656b..3eb30977 100644
--- a/code/color.rb
+++ b/code/color.rb
@@ -8,11 +8,11 @@ module Color
 	def load_colorscheme(name)
 		## colorschemes are located in data/colorscheme/
 		fname = File.join(COLORSCHEMEDIR, "#{name}.rb")
-#		assert File.exists?(fname), "No such colorscheme: #{fname}"
+		assert File.exists?(fname), "No such colorscheme: #{fname}"
 		
 		clear_all
 		load fname
-		::Console.write("Colorscheme #{name} loaded.")
+#		::Console.write("Colorscheme #{name} loaded.")
 	end
 
 	def clear_all()
@@ -86,6 +86,10 @@ module Color
 	use %w{directory file}
 	use %w{forbidden directory file}
 
+	use %w{top}
+	use %w{hostname top}
+	use %w{currentdir top}
+	use %w{currentfile top}
 
 	use %w{media file}
 	use %w{video media file}
@@ -124,17 +128,20 @@ module Color
 	module Marked;   extend Type end
 	module Console;  extend Type end
 
+	module SelectedCurrentRow; extend Type end
+
+	def [](x)      TYPES[x] end
+
 	TYPES = {
 		:normal   => Normal,
 		:selected => Selected,
 		:marked   => Marked,
-		:console  => Console
+		:console  => Console,
+		:selected_current_row => SelectedCurrentRow
 	}
 
-	def [](x)      TYPES[x] end
-	def selected() Selected end
-	def normal()   Normal   end
-	def marked()   Marked   end
-	def console()  Console  end
+	for key, val in TYPES
+		eval "def #{key}() #{val} end"
+	end
 end
 
diff --git a/code/fm/draw.rb b/code/fm/draw.rb
index b07eb31c..0b5b520a 100644
--- a/code/fm/draw.rb
+++ b/code/fm/draw.rb
@@ -1,3 +1,5 @@
+require 'socket'
+
 module Fm
 	DONT_PREVIEW_THESE_FILES = /\.(avi|[mj]pe?g|iso|mp\d|og[gmv]|wm[av]|mkv|torrent|so|class|flv|png|bmp|vob|divx?)$/i
 
@@ -42,9 +44,13 @@ module Fm
 		right = left + wid
 		
 		if not d.read?
-#			puti l, left, "" * (wid + 1)
+			if (c == COLUMNS - 1) and @entering_directory
+#				puti l, left, "reading...".ljust(wid+1)
+				puti l, left, " " * (wid+1)
+				column_clear(c, 1)
+				@entering_directory = false
+			end
 			Scheduler << d
-#			column_clear(c, 1)
 			return
 		elsif d.read? and d.empty?
 			puti l, left, 'empty'.ljust(wid+1)
@@ -61,7 +67,11 @@ module Fm
 			break if (f = d.files[lpo]) == nil
 
 			mycolor = if lpo == d.pos
-				Color.selected
+				if infos
+					Color.selected_current_row
+				else
+					Color.selected
+				end
 			elsif f.marked?
 				Color.marked
 			else
@@ -159,7 +169,8 @@ module Fm
 	end
 
 	def self.draw
-#		bold false
+		attr_set(Color.base)
+
 		@cur_y = get_boundaries(COLUMNS-2)[0]
 
 		if @buffer =~ /^block/
@@ -208,7 +219,9 @@ module Fm
 				puti 0, cols-s0.size, s0
 			end
 
-			s1 = "  "
+			s1 = ""
+			s1 << Socket.gethostname
+			s1 << ":"
 			s2 = "#{@path.last.path}#{"/" unless @path.size == 1}"
 			s3 = "#{cf ? cf.basename : ''}"
 			
@@ -219,6 +232,9 @@ module Fm
 			end
 
 			bg = -1
+			attr_at(0, 0, s1.size, *Color.hostname)
+			attr_at(0, s1.size, s2.size, *Color.currentdir)
+			attr_at(0, s1.size + s2.size, s3.size, *Color.currentfile)
 #			color_at 0, 0, -1, 7, bg
 #			color_at 0, 0, s1.size, 7, bg
 #			color_at 0, s1.size, s2.size, 6, bg