From 95f91fc6338438a33dbe7596d445ecb12a12912b Mon Sep 17 00:00:00 2001 From: hut Date: Mon, 20 Jul 2009 05:06:48 +0200 Subject: renamed ranger.rb to ranger --- ranger | 113 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ranger.rb | 113 -------------------------------------------------------------- 2 files changed, 113 insertions(+), 113 deletions(-) create mode 100755 ranger delete mode 100755 ranger.rb diff --git a/ranger b/ranger new file mode 100755 index 00000000..cc95c619 --- /dev/null +++ b/ranger @@ -0,0 +1,113 @@ +#!/usr/bin/ruby -Ku +##-------------------------------------------------- +# Ignore the following lines + +if false; then +=begin +fi; cd "`ranger --cd $@ 3>&1 1>&2`"; return +=end +end + +version = '0.2.4' + +require 'pathname' +$: << MYDIR = File.dirname(Pathname(__FILE__).realpath) + +ARGV.delete('--cd') if cd = ARGV.include?('--cd') +if ARGV.size > 0 + case ARGV.first + when '-k' + exec "killall -9 #{File.basename($0)}" + end + pwd = ARGV.first + if pwd =~ /^file:\/\// + pwd = $' + end + + unless File.exists?(pwd) + pwd = nil + end + +else + pwd = nil +end + +for file in Dir.glob "#{MYDIR}/code/**/*.rb" + require file [MYDIR.size + 1 ... -3] +end + +## default options +opt = { + :show_hidden => false, + :sort => :name, + :list_dir_first => true, + :sort_reverse => false, + :bookmark_file => '~/.ranger_bookmarks', + :ascii_only => true, + :wide_bar => true, + :confirm_string => "yes I am!", + :confirm => true, + :file_preview => true, + :preview => true, + :mouse => true, + :mouse_interval => 200, + :debug_level => 0, + :debug_file => '/tmp/errorlog', + :colorscheme => 'default', + :cd => cd, + :evil => false +} + +class OptionClass < Struct.new(*opt.keys) + def confirm_string; confirm ? super : "" end +end + +Option = OptionClass.new(*opt.values) +opt = nil + +load 'ranger.conf' +load 'data/colorscheme/' + Option.colorscheme + '.rb' +load 'data/screensaver/clock.rb' + +include Debug + +Debug.setup( :name => 'ranger', + :file => Option.debug_file, + :level => Option.debug_level ) + +if pwd and !ARGV.empty? and !File.directory?(pwd) + Fm.reload_types + file = Directory::Entry.new(pwd) + file.get_data + Action.run(RunContext.new(file, 0, 'ca')) + exit +end + +include CLI + +Signal.trap(Scheduler::UPDATE_SIGNAL) do + Fm.refresh +end + +CLI.init_mouse( Option.mouse_interval ) + +begin + Fm.initialize( pwd ) + Fm.main_loop +ensure + log "exiting!\n\n" + + closei if CLI.running? + CLI.stop_mouse + Fm.dump + + Fm.dump_pwd_to_3 if Option.cd rescue nil + + # Kill all other threads + for thr in Thread.list + unless thr == Thread.current + thr.kill + end + end +end + diff --git a/ranger.rb b/ranger.rb deleted file mode 100755 index cc95c619..00000000 --- a/ranger.rb +++ /dev/null @@ -1,113 +0,0 @@ -#!/usr/bin/ruby -Ku -##-------------------------------------------------- -# Ignore the following lines - -if false; then -=begin -fi; cd "`ranger --cd $@ 3>&1 1>&2`"; return -=end -end - -version = '0.2.4' - -require 'pathname' -$: << MYDIR = File.dirname(Pathname(__FILE__).realpath) - -ARGV.delete('--cd') if cd = ARGV.include?('--cd') -if ARGV.size > 0 - case ARGV.first - when '-k' - exec "killall -9 #{File.basename($0)}" - end - pwd = ARGV.first - if pwd =~ /^file:\/\// - pwd = $' - end - - unless File.exists?(pwd) - pwd = nil - end - -else - pwd = nil -end - -for file in Dir.glob "#{MYDIR}/code/**/*.rb" - require file [MYDIR.size + 1 ... -3] -end - -## default options -opt = { - :show_hidden => false, - :sort => :name, - :list_dir_first => true, - :sort_reverse => false, - :bookmark_file => '~/.ranger_bookmarks', - :ascii_only => true, - :wide_bar => true, - :confirm_string => "yes I am!", - :confirm => true, - :file_preview => true, - :preview => true, - :mouse => true, - :mouse_interval => 200, - :debug_level => 0, - :debug_file => '/tmp/errorlog', - :colorscheme => 'default', - :cd => cd, - :evil => false -} - -class OptionClass < Struct.new(*opt.keys) - def confirm_string; confirm ? super : "" end -end - -Option = OptionClass.new(*opt.values) -opt = nil - -load 'ranger.conf' -load 'data/colorscheme/' + Option.colorscheme + '.rb' -load 'data/screensaver/clock.rb' - -include Debug - -Debug.setup( :name => 'ranger', - :file => Option.debug_file, - :level => Option.debug_level ) - -if pwd and !ARGV.empty? and !File.directory?(pwd) - Fm.reload_types - file = Directory::Entry.new(pwd) - file.get_data - Action.run(RunContext.new(file, 0, 'ca')) - exit -end - -include CLI - -Signal.trap(Scheduler::UPDATE_SIGNAL) do - Fm.refresh -end - -CLI.init_mouse( Option.mouse_interval ) - -begin - Fm.initialize( pwd ) - Fm.main_loop -ensure - log "exiting!\n\n" - - closei if CLI.running? - CLI.stop_mouse - Fm.dump - - Fm.dump_pwd_to_3 if Option.cd rescue nil - - # Kill all other threads - for thr in Thread.list - unless thr == Thread.current - thr.kill - end - end -end - -- cgit 1.4.1-2-gfad0