about summary refs log tree commit diff stats
path: root/code
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2009-07-03 14:16:24 +0200
committerhut <hut@lavabit.com>2009-07-03 14:16:24 +0200
commit01104f4a929dbbf37366f40e5f45227304f3d7d6 (patch)
treecd62dff6e9015a396c0efa606603110fd30a3014 /code
parent2800fd920b9c400ba178c94c77ae77c999f28849 (diff)
downloadranger-01104f4a929dbbf37366f40e5f45227304f3d7d6.tar.gz
put options where they belong. in a config file
Diffstat (limited to 'code')
-rw-r--r--code/directory.rb10
-rw-r--r--code/draw.rb14
-rw-r--r--code/fm.rb11
-rw-r--r--code/keys.rb31
4 files changed, 26 insertions, 40 deletions
diff --git a/code/directory.rb b/code/directory.rb
index 01634ca0..c738b995 100644
--- a/code/directory.rb
+++ b/code/directory.rb
@@ -27,7 +27,7 @@ class Directory
 		@mtime = File.mtime(@path)
 		log @path
 		@files = Dir.new(@path).to_a rescue []
-		if OPTIONS['hidden']
+		if Option.show_hidden
 			@files -= ['.', '..', 'lost+found']
 		else
 			@files.reject!{|x| x[0] == ?. or x == 'lost+found'}
@@ -160,7 +160,7 @@ class Directory
 
 #	def refresh()
 #		@files = Dir.new(@path).to_a
-#		if OPTIONS['hidden']
+#		if Option.hidden
 #			@files -= ['.', '..', 'lost+found']
 #		else
 #			@files.reject!{|x| x[0] == ?. or x == 'lost+found'}
@@ -203,7 +203,7 @@ class Directory
 	end
 
 	def sort_sub(x, y)
-		case OPTIONS['sort']
+		case Option.sort
 		when :name
 			x.basename <=> y.basename
 		when :ext
@@ -223,7 +223,7 @@ class Directory
 
 	def sort()
 		@files = @files.sort {|x,y|
-			if OPTIONS['dir_first']
+			if Option.dir_first
 				if x.dir?
 					if y.dir? then sort_sub(x, y) else -1 end
 				else
@@ -233,7 +233,7 @@ class Directory
 				sort_sub(x, y)
 			end
 		}
-		@files.reverse! if OPTIONS['sort_reverse']
+		@files.reverse! if Option.sort_reverse
 		@files_raw = @files.map{|x| x.to_s}
 	end
 end
diff --git a/code/draw.rb b/code/draw.rb
index 75f54a88..aaca6253 100644
--- a/code/draw.rb
+++ b/code/draw.rb
@@ -5,7 +5,7 @@ module Fm
 
 	def column_put_file(n, file)
 		i = 0
-		if OPTIONS['preview'] and OPTIONS['filepreview'] and file.path !~ DONT_PREVIEW_THESE_FILES
+		if Option.preview and Option.file_preview and file.path !~ DONT_PREVIEW_THESE_FILES
 			m = lines - 2
 			attr_set(Color.base)
 			left, wid = get_boundaries(n)
@@ -122,7 +122,7 @@ module Fm
 				puti l, left, fn[0, wid-1].ljust(wid+1)
 			end
 
-			if infos and OPTIONS['wide_bar']
+			if infos and Option.wide_bar
 				attr_at(l, left-1, wid+1, mycolor.send(clrname))
 			else
 				attr_at(l, left, fn.size.limit(wid-1), mycolor.send(clrname))
@@ -161,7 +161,7 @@ module Fm
 			
 		when 1
 			q = cols / 8
-			if !OPTIONS['preview']# or (!OPTIONS['filepreview'] and !currentfile.dir?)
+			if !Option.preview# or (!Option.filepreview and !currentfile.dir?)
 				return q, 2*q
 #			elsif currentfile.path != DONT_PREVIEW_THESE_FILES
 #				return q, 2*q
@@ -170,10 +170,10 @@ module Fm
 			end
 
 		when 2
-			if !OPTIONS['preview']
+			if !Option.preview
 				q = cols * 0.375 - 1
 				w = @path.last.width.limit(cols * 0.625, cols/8)
-#			elsif currentfile.path =~ DONT_PREVIEW_THESE_FILES or (!OPTIONS['filepreview'] and !currentfile.dir?)
+#			elsif currentfile.path =~ DONT_PREVIEW_THESE_FILES or (!Option.filepreview and !currentfile.dir?)
 #				q = cols / 4
 #				w = @path.last.width.limit(cols * 0.75, cols/8)
 			else
@@ -250,7 +250,7 @@ module Fm
 #			bold false
 
 			begin
-				if OPTIONS['preview']
+				if Option.preview
 					if cf.dir?
 						put_directory(3, @dirs[cf.path])
 					elsif cf.file?
@@ -284,7 +284,7 @@ module Fm
 			when 'S'
 				puti btm, "Sort by (n)ame (s)ize (m)time (c)time (CAPITAL:reversed)"
 			when 't'
-				puti btm, "Toggle (h)idden_files (d)irs_first (c)olor (f)ilepreview (p)review (w)idebar"
+				puti btm, "Toggle (h)idden_files (d)irs_first (f)ilepreview (p)review (w)idebar"
 			else
 				attr_set(Color.base)
 				attr_set(Color.info)
diff --git a/code/fm.rb b/code/fm.rb
index c69cefb1..f172840f 100644
--- a/code/fm.rb
+++ b/code/fm.rb
@@ -1,16 +1,5 @@
 require 'thread'
 
-OPTIONS = {
-	'hidden' => false,
-	'sort' => :name,
-	'dir_first' => true,
-	'sort_reverse' => false,
-	'color' => true,
-	'wide_bar' => true,
-	'filepreview' => true,
-	'preview' => true,
-}
-
 ## methods:
 ## initialize(pwd=nil)
 ## refresh
diff --git a/code/keys.rb b/code/keys.rb
index 0498f6f6..b652ff92 100644
--- a/code/keys.rb
+++ b/code/keys.rb
@@ -134,8 +134,8 @@ module Fm
 			closei
 			system('clear')
 			ls = ['ls']
-			ls << '--color=auto' if OPTIONS['color']
-			ls << '--group-directories-first' if OPTIONS['color']
+			ls << '--color=auto' if Option.color
+			ls << '--group-directories-first' if Option.color
 			system(*ls)
 			system('bash')
 			@pwd.schedule
@@ -143,21 +143,21 @@ module Fm
 
 
 		when /^S(.)$/
-			OPTIONS['sort_reverse'] = $1.ord.between?(65, 90)
+			Option.sort_reverse = $1.ord.between?(65, 90)
 
 			case $1
 			when 'n'
-				OPTIONS['sort'] = :name
+				Option.sort = :name
 			when 'e'
-				OPTIONS['sort'] = :ext
+				Option.sort = :ext
 			when 't'
-				OPTIONS['sort'] = :type
+				Option.sort = :type
 			when 's'
-				OPTIONS['sort'] = :size
+				Option.sort = :size
 			when 'm'
-				OPTIONS['sort'] = :mtime
+				Option.sort = :mtime
 			when 'c'
-				OPTIONS['sort'] = :ctime
+				Option.sort = :ctime
 			end
 			@pwd.schedule
 
@@ -379,23 +379,20 @@ module Fm
 			end
 
 		when 'tw'
-			OPTIONS['wide_bar'] ^= true
+			Option.wide_bar ^= true
 
 		when 'tp'
-			OPTIONS['preview'] ^= true
-
-		when 'tc'
-			OPTIONS['color'] ^= true
+			Option.preview ^= true
 
 		when 'tf'
-			OPTIONS['filepreview'] ^= true
+			Option.file_preview ^= true
 
 		when 'th'
-			OPTIONS['hidden'] ^= true
+			Option.show_hidden ^= true
 			@pwd.refresh!
 
 		when 'td'
-			OPTIONS['dir_first'] ^= true
+			Option.dir_first ^= true
 			@pwd.schedule
 
 		when 'delete'