about summary refs log tree commit diff stats
path: root/code
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2009-06-12 03:19:54 +0200
committerhut <hut@lavabit.com>2009-06-12 03:19:54 +0200
commit14ae8304cd976a6ecf55fe5f5c53ef513278da4b (patch)
treedec57bd038c52997a2c26a8f808df40c10cf1d3a /code
parent8f8b66aa27050f29b06ee66ed9c86308089fae4a (diff)
downloadranger-14ae8304cd976a6ecf55fe5f5c53ef513278da4b.tar.gz
completed colorscheme support
Diffstat (limited to 'code')
-rw-r--r--code/color.rb7
-rw-r--r--code/draw.rb80
-rw-r--r--code/fm/fm.rb1
3 files changed, 24 insertions, 64 deletions
diff --git a/code/color.rb b/code/color.rb
index 244ec127..e131656b 100644
--- a/code/color.rb
+++ b/code/color.rb
@@ -81,8 +81,8 @@ module Color
 	use %w{file}
 
 	use %w{link file}
-	use %w{badlink file}
-	use %w{goodlink file}
+	use %w{badlink link file}
+	use %w{goodlink link file}
 	use %w{directory file}
 	use %w{forbidden directory file}
 
@@ -95,8 +95,6 @@ module Color
 	use %w{script executable file}
 	use %w{binary executable file}
 
-	def content!() @content end
-
 	module Type
 		include Color
 
@@ -104,6 +102,7 @@ module Color
 			base file directory media executable
 			video sound image
 			script binary
+			link goodlink badlink
 
 			terminal_cursor error info
 		]
diff --git a/code/draw.rb b/code/draw.rb
index 8efc5135..a2f167f3 100644
--- a/code/draw.rb
+++ b/code/draw.rb
@@ -35,17 +35,20 @@ module Fm
 
 	def put_directory(c, d)
 		l = 1
-		return column_clear(c, l) unless d
+		return column_clear(c, 0) unless d
 
 		infos = (c == COLUMNS - 2)
 		left, wid = get_boundaries(c)
+		right = left + wid
 		
 		if not d.read?
 			puti l, left, 'reading...'.ljust(wid+1)
 			Scheduler << d
+			column_clear(c, 1)
 			return
 		elsif d.read? and d.empty?
 			puti l, left, 'empty'.ljust(wid+1)
+			column_clear(c, 1)
 			return
 		end
 
@@ -53,7 +56,8 @@ module Fm
 		offset = get_offset(d, lines)
 		(lines - 1).times do |l|
 			lpo = l + offset
-			bg = -1
+			l += 1
+
 			break if (f = d.files[lpo]) == nil
 
 			mycolor = if lpo == d.pos
@@ -66,28 +70,27 @@ module Fm
 
 			dir = false
 
-			clr = if f.symlink?
+			clrname = if f.symlink?
 				dir = f.dir?
 				if f.broken_symlink?
-					mycolor.badlink
+					:badlink
 				else
-					mycolor.goodlink
+					:goodlink
 				end
 			elsif f.dir?
 				dir = true
-				mycolor.directory
+				:directory
 			elsif f.movie?
-				mycolor.video
+				:video
 			elsif f.executable?
-				mycolor.executable
+				:executable
 			else
-				mycolor.file
+				:file
 			end
 
 			fn = f.basename
-			if f.marked?
-				fn = "* #{fn}"
-			end
+			fn = "* #{fn}" if f.marked?
+
 
 			if infos
 				myinfo = " #{f.infostring}  "
@@ -98,57 +101,16 @@ module Fm
 				else
 					yes = false
 				end
-				puti l+1, left, str
-				if dir and yes
-					args = l+1, left+wid-myinfo.size, myinfo.size, *clr
-#							color_bold_at(*args)
-					attr_at(l+1, left+wid-myinfo.size, myinfo.size, Color.directory)
-				end
+				puti l, left, str
+				attr_at(l, right-myinfo.size, myinfo.size, Color.normal.send(clrname))
 			else
-				puti l+1, left, fn[0, wid-1].ljust(wid+1)
+				puti l, left, fn[0, wid-1].ljust(wid+1)
 			end
 
-			args = l+1, left, fn.size.limit(wid-1), *clr
-
-			if d.pos == lpo
-				if c == COLUMNS - 2
-#							puti l+1, left-1, '^'
-#							puti l+1, left+args[2], '$'
-
-					args[4] = 0
-#							args[1] -= 1
-#							if args[2] < 5
-#								args[2] = 7
-#							else
-#								args[2] += 1
-#							end
-#							color_bold_at(l+1, left-1, 1, 0, 0)
-#							color_bold_at(l+1, left+args[2], 1, 0, 0)
-
-#							color_reverse_bold_at(*args)
-					attr_at(args[0], args[1], args[2], Color.selected.base)
-
-					# ...
-#							args[1] -= 1; args[2] += 2
-#							color_bold_at(*args)
-					args[1] += 1; args[2] -= 2
-
-#							color_reverse_bold_at(*args)
-					attr_at(args[0], args[1], args[2], Color.selected.base)
-				else
-					attr_at(args[0], args[1], args[2], Color.selected.base)
-#							color_reverse_at(*args)
-				end
-#						if f.marked?
-#							args[1] += 1
-#							args[2] = 1
-#							args[3] = 1
-#							color_reverse_at(*args)
-#						end
-			else
-				attr_at(args[0], args[1], args[2], Color.media)
-			end
+			attr_at(l, left, fn.size.limit(wid-1), mycolor.send(clrname))
 		end
+
+		column_clear(c, l-1)
 	end
 
 	def self.column_clear(n, from=0)
diff --git a/code/fm/fm.rb b/code/fm/fm.rb
index 8e60286b..a6054052 100644
--- a/code/fm/fm.rb
+++ b/code/fm/fm.rb
@@ -124,7 +124,6 @@ module Fm
 			end
 
 			begin
-				log "drawing"
 				draw()
 			rescue Interrupt
 				on_interrupt