diff options
Diffstat (limited to 'code/fm')
-rw-r--r-- | code/fm/fm.rb | 49 | ||||
-rw-r--r-- | code/fm/keys.rb | 47 |
2 files changed, 33 insertions, 63 deletions
diff --git a/code/fm/fm.rb b/code/fm/fm.rb index 5033c161..91b17f2d 100644 --- a/code/fm/fm.rb +++ b/code/fm/fm.rb @@ -1,3 +1,5 @@ +require 'thread' + OPTIONS = { 'hidden' => false, 'sort' => :name, @@ -18,6 +20,8 @@ module Fm def self.initialize(pwd=nil) @bars = [] @bars_thread = nil + + @entering_directory = true @buffer = '' @pwd = nil @@ -27,33 +31,28 @@ module Fm @trash = File.expand_path('~/.trash') pwd ||= Dir.getwd - # `' and `` are the original PWD unless overwritten by .fmrc + # `' and `` are the original PWD unless overwritten by .rangerrc @memory = { '`' => pwd, '\'' => pwd } - # Read the .fmrc - @fmrc = File.expand_path('~/.fmrc') - if (File.exists?(@fmrc)) - loaded = Marshal.load(File.read(@fmrc)) rescue nil - if Hash === loaded - @memory.update(loaded) + # Read the .rangerrc + @rangerrc = File.expand_path('~/.rangerrc') + if (File.exists?(@rangerrc)) + content = File.read(@rangerrc) + unless content.empty? + loaded = Marshal.load() rescue nil + if Hash === loaded + @memory.update(loaded) + end end end + @dump_config_on_exit = true # `0 is always the original PWD @memory['0'] = pwd - # Give me some way to redraw screen while waiting for - # input from CLI.geti - -# for i in 1..20 -# eval "Signal.trap(#{i}) do -# log #{i} -# exit if #{i} == 9 end" -# end - boot_up(pwd) end @@ -90,10 +89,15 @@ module Fm end def dump - remember_dir - dumped = Marshal.dump(@memory) - File.open(@fmrc, 'w') do |f| - f.write(dumped) + if defined? @dump_config_on_exit + begin + remember_dir + dumped = Marshal.dump(@memory) + File.open(@rangerrc, 'w') do |f| + f.write(dumped) + end + rescue Exception + end end end @@ -198,6 +202,7 @@ module Fm end end + @entering_directory = true Dir.chdir(@pwd.path) end @@ -270,5 +275,9 @@ module Fm @bars_thread = nil end end + + def getfiles() + @marked.empty? ? [currentfile] : @marked + end end diff --git a/code/fm/keys.rb b/code/fm/keys.rb index c7abea17..4e3af766 100644 --- a/code/fm/keys.rb +++ b/code/fm/keys.rb @@ -305,7 +305,7 @@ module Fm if $3 == '<cr>' closei system("bash", "-c", $2) - gets unless $1.empty? + Action.wait_for_enter unless $1.empty? starti @pwd.schedule end @@ -522,47 +522,8 @@ module Fm # w = wait for <enter> after execution # capital letter inverts when /^[ri](\d*)([adetw]*)[ri]$/ - if $2.empty? - f = @marked.empty?? currentfile : @marked.first - flags = get_default_flags(f) - else - flags = $2 - end - opt = OpenStruct.new - opt.newway = true - - opt.mode = $1.to_i unless $1.empty? - - # Set options based on flags - - if flags =~ /a/ - opt.all = true - end - if flags =~ /[de]/ - opt.detach = true - end - if flags =~ /t/ - opt.new_term = true - opt.detach = true - end - if flags =~ /w/ - opt.wait = true - end - - if flags =~ /A/ - opt.all = false - end - if flags =~ /[DE]/ - opt.detach = false - end - if flags =~ /T/ - opt.new_term = false - end - if flags =~ /W/ - opt.wait = false - end - - Action.run(opt.__table__) + run_context = RunContext.new(getfiles, $1, $2) + Action.run(run_context) # when 'ra' # unless File.directory?(currentfile.path) @@ -598,7 +559,7 @@ module Fm cf = currentfile enter = enter_dir_safely(cf.path) unless enter - return Action.run(:detach=>false) + return Action.run(RunContext.new(getfiles)) end return false end |