diff options
-rw-r--r-- | code/directory.rb | 10 | ||||
-rw-r--r-- | code/draw.rb | 14 | ||||
-rw-r--r-- | code/fm.rb | 11 | ||||
-rw-r--r-- | code/keys.rb | 31 | ||||
-rw-r--r-- | ranger.conf | 9 | ||||
-rwxr-xr-x | ranger.rb | 19 |
6 files changed, 53 insertions, 41 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' diff --git a/ranger.conf b/ranger.conf new file mode 100644 index 00000000..ed72113d --- /dev/null +++ b/ranger.conf @@ -0,0 +1,9 @@ +Option.show_hidden = false +Option.sort = :name +Option.dir_first = true +Option.sort_reverse = false +Option.colorscheme = 'default' +Option.wide_bar = true +Option.file_preview = true +Option.preview = true + diff --git a/ranger.rb b/ranger.rb index 797e978c..36b9656d 100755 --- a/ranger.rb +++ b/ranger.rb @@ -28,9 +28,26 @@ for file in Dir.glob "#{MYDIR}/code/**/*.rb" require file [MYDIR.size + 1 ... -3] end +## default options +opt = { + :show_hidden => false, + :sort => :name, + :dir_first => true, + :sort_reverse => false, + :colorscheme => true, + :wide_bar => true, + :file_preview => true, + :preview => true, + :colorscheme => 'default' +} + +Option = Struct.new(*opt.keys).new(*opt.values) +opt = nil + +load 'ranger.conf' load 'data/types.rb' load 'data/apps.rb' -load 'data/colorscheme/default.rb' +load 'data/colorscheme/' + Option.colorscheme + '.rb' load 'data/screensaver/clock.rb' include Debug |