diff options
-rw-r--r-- | code/keys.rb | 20 | ||||
-rw-r--r-- | code/search.rb | 5 | ||||
-rwxr-xr-x | ranger | 34 | ||||
-rw-r--r-- | ranger.conf | 8 |
4 files changed, 48 insertions, 19 deletions
diff --git a/code/keys.rb b/code/keys.rb index 4d7aa2f7..3784c7d0 100644 --- a/code/keys.rb +++ b/code/keys.rb @@ -142,7 +142,7 @@ module Fm # end log str if str =~ /^\s?(.*)(<cr>|<esc>)$/ - @buffer = '' + @buffer.clear if $2 == '<cr>' files = selection if files.size == 1 @@ -246,7 +246,7 @@ module Fm when /^cd(.+)$/ str = $1 if str =~ /^\s?(.*)(<cr>|<esc>)$/ - @buffer = '' + @buffer.clear if $2 == '<cr>' remember_dir enter_dir_safely($1) @@ -285,17 +285,17 @@ module Fm str = $1 Option.search_method = :regexp if str =~ /^\s?(.*)(L|;|<cr>|<esc>)$/ - @buffer = '' + @buffer.clear @search_string = $1 unless $1.empty? press('l') if $2 == ';' or $2 == 'L' else test = hints(str) if test == 1 - @buffer = '' + @buffer.clear press('l') ignore_keys_for 0.5 elsif test == 0 - @buffer = '' + @buffer.clear ignore_keys_for 1 end end @@ -303,7 +303,7 @@ module Fm when /^\/(.+)$/ str = $1 if str =~ /^\s?(.*)(L|;|<cr>|<esc>)$/ - @buffer = '' + @buffer.clear Option.search_method = :regexp @search_string = $1 @@ -359,7 +359,7 @@ module Fm when /^!(.+)$/ str = $1 if str =~ /^(\!?)(.*)(<cr>|<esc>)$/ - @buffer = '' + @buffer.clear if $3 == '<cr>' externally do system("bash", "-c", $2) @@ -643,22 +643,20 @@ module Fm if key == '<bs>' if @buffer.empty? @buffer = key - elsif @buffer == 'F' - descend elsif @buffer[-1] == ?> @buffer.slice!(/(<.*)?>$/) else @buffer.slice!(-1) end elsif key == '<c-u>' - @buffer = '' + @buffer.clear else @buffer << key end eval_keybuffer - @buffer = '' unless @buffer == '' or @buffer =~ key_regexp + @buffer.clear unless @buffer.empty? or @buffer =~ key_regexp end ## go down 1 directory diff --git a/code/search.rb b/code/search.rb index 2952f59a..27ea4044 100644 --- a/code/search.rb +++ b/code/search.rb @@ -22,16 +22,19 @@ module Fm FIND_KEY_REGEXP = /f([#{ FIND_PROPERTIES.keys.join("") }])/ def quicksearch(n) - log Option.search_method case Option.search_method when *FIND_PROPERTIES.values quicksearch_by_property(n, Option.search_method) + when :handler quicksearch_by_handler(n) + when :regexp quicksearch_by_regexp(n) + else raise "Wrong search method!" + end rescue lograise end diff --git a/ranger b/ranger index 77409233..0cdc9674 100755 --- a/ranger +++ b/ranger @@ -3,7 +3,8 @@ # these lines allow the use of "source ranger ranger" # to change to the last directory after exiting ranger -if false; then +if false +then =begin fi cd "`$1 --workaround $@ 3>&1 1>&2`" @@ -17,7 +18,9 @@ end version = '0.2.5' require 'pathname' -$: << MYDIR = File.dirname(Pathname(__FILE__).realpath) + +MYDIR = File.dirname( Pathname.new( __FILE__ ).realpath ) +$LOAD_PATH.unshift( MYDIR ) ##-------------------------------------------------- # parse arguments @@ -49,8 +52,11 @@ end ##-------------------------------------------------- # require files -for file in Dir.glob "#{MYDIR}/code/**/*.rb" - require file [MYDIR.size + 1 ... -3] +pattern = File.join( MYDIR, 'code', '**', '*.rb' ) +extract = MYDIR.size+1 .. -4 + +for file in Dir.glob( pattern ) + require file [ extract ] # keep the names like "code/action" end ##-------------------------------------------------- @@ -82,14 +88,26 @@ opt = { # initialization class OptionClass < Struct.new(*opt.keys) - def confirm_string; confirm ? super : "" end + def confirm_string + confirm ? super : "" + end end Option = OptionClass.new(*opt.values) opt = nil -load File.exists?( x = File.expand_path( '~/.rangerrc' ) ) ? x : 'ranger.conf' -load 'data/colorscheme/' + Option.colorscheme + '.rb' +begin + load File.exists?( x = File.expand_path( '~/.rangerrc' ) ) ? x : 'ranger.conf' +rescue LoadError +end + +begin + path = File.join(MYDIR, 'data', 'colorscheme', Option.colorscheme + '.rb') + load path +rescue LoadError + abort "Can't find colorscheme at #{path}" +end + include Debug @@ -97,6 +115,7 @@ Debug.setup( :name => 'ranger', :file => Option.debug_file, :level => Option.debug_level ) +## run the file in arg1 and exit if pwd and !ARGV.empty? and !File.directory?(pwd) Fm.reload_types file = Directory::Entry.new(pwd) @@ -119,6 +138,7 @@ CLI.init_mouse( Option.mouse_interval ) begin Fm.initialize( pwd ) Fm.main_loop + ensure log "exiting!\n\n" diff --git a/ranger.conf b/ranger.conf index 63fc5165..9df90ac8 100644 --- a/ranger.conf +++ b/ranger.conf @@ -4,6 +4,9 @@ # options are in this format: Option.<name> = <value> # if an option is not defined, the default value is used. # this file is treated as ruby code, text after # is ignored +# +# all of this is not required!! You can even use an empty +# config file, in which case the defaults will be used. ##-------------------------------------------------- # should all non-ascii characters be replaced with stars? @@ -43,6 +46,11 @@ Option.debug_file = '/tmp/errorlog' Option.confirm_string = "yes I am!" Option.confirm = true +# what to search for with the n-key? You can specify it later with +# [f*] or [/], but I need a default value. Use one of: +# :ctime, :mtime, :size, :handler, :regexp +Option.search_method = :ctime + # these options are obvious Option.bookmark_file = '~/.ranger_bookmarks' Option.show_hidden = false |