diff options
author | hut <hut@lavabit.com> | 2009-07-04 21:47:15 +0200 |
---|---|---|
committer | hut <hut@lavabit.com> | 2009-07-04 21:47:15 +0200 |
commit | b1855df62ae954142ca7bbc5888212bc75081303 (patch) | |
tree | e77c1d24f0a58476def55d3442363267e19be054 /code | |
parent | f0c18d64739e496cf943ea794fa937cff0a7916d (diff) | |
download | ranger-b1855df62ae954142ca7bbc5888212bc75081303.tar.gz |
request a confirmation on deletion
Diffstat (limited to 'code')
-rw-r--r-- | code/draw.rb | 7 | ||||
-rw-r--r-- | code/keys.rb | 67 |
2 files changed, 50 insertions, 24 deletions
diff --git a/code/draw.rb b/code/draw.rb index b493c846..1b40d47d 100644 --- a/code/draw.rb +++ b/code/draw.rb @@ -281,13 +281,14 @@ module Fm btm = lines - 1 case @buffer - when 'seriouslydd', 'dd' - puti btm, "Are you serious? Please press y to confirm." + when /^delete/, /^dd/ + puti btm, "#@buffer ".rjust(cols) + puti btm, 'Are you serious? (' + Option.confirm_string + ')' 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 (f)ilepreview (p)review (w)idebar" + puti btm, "Toggle (h)idden_files (d)irs_first (f)ilepreview (p)review (w)idebar (c)d (!)confirm" else attr_set(Color.base) attr_set(Color.info) diff --git a/code/keys.rb b/code/keys.rb index 5a549d5c..86a6f235 100644 --- a/code/keys.rb +++ b/code/keys.rb @@ -1,22 +1,39 @@ module Fm # ALL combinations of multiple keys (but without the last letter) # or regexps which match combinations need to be in here! - COMBS = %w( - g dd seriouslydd y c Z delet cu - ter ta S ?? ?g ?f ?m ?l ?c ?o ?z - o m ` ' go - - um - - /:[^<]*/ - /[fF/!].*/ - /r\d*\w*[^r]/ - /(cw|cd|mv).*/ - /b(l(o(c(k(.*)?)?)?)?)?/ - /m(k(d(i(r(.*)?)?)?)?)?/ - /t(o(u(c(h(.*)?)?)?)?)?/ - /r(e(n(a(m(e(.*)?)?)?)?)?)?/ - ) + def key_combinations + return @@key_combinations if @@key_combinations + + @@key_combinations = %w[ + g y c Z cu + ter ta S ?? ?g ?f ?m ?l ?c ?o ?z + o m ` ' go + deleteI\ am ddI\ am + + um + + /:[^<]*/ + /[fF/!].*/ + /r\d*\w*[^r]/ + /(cw|cd|mv).*/ + /b(l(o(c(k(.*)?)?)?)?)?/ + /m(k(d(i(r(.*)?)?)?)?)?/ + /t(o(u(c(h(.*)?)?)?)?)?/ + /r(e(n(a(m(e(.*)?)?)?)?)?)?/ + ] + + need_confirmation = %w[ + delete + dd + ] + + + for str in need_confirmation + @@key_combinations << (str + Option.confirm_string).chop + end + + return @@key_combinations + end def self.press(key) return if @ignore_until and Time.now < @ignore_until @@ -95,7 +112,7 @@ module Fm ## Destructive {{{ - when 'ddy' + when 'dd' + Option.confirm_string new_path = move_to_trash(currentfile) if new_path new_path = Directory::Entry.new(new_path) @@ -105,14 +122,14 @@ module Fm end @pwd.schedule - when 'seriouslyddy' + when 'dfd' + Option.confirm_string cf = currrentfile if cf and cf.exists? cf.delete! @pwd.schedule end - when 'delete' + when 'delete' + Option.confirm_string files = selection @marked = [] for f in files @@ -442,6 +459,9 @@ module Fm end @pwd.schedule + when 't!' + Option.confirm ^= true + when 'tw' Option.wide_bar ^= true @@ -560,13 +580,18 @@ module Fm end - @@key_regexp = nil + def self.recalculate_key_combinations + @@key_combinations = nil + @@key_regexp = nil + end + recalculate_key_combinations + def key_regexp return @@key_regexp if @@key_regexp # Create a regular expression which detects combos ary = [] - for token in COMBS + for token in key_combinations if token =~ /^\/(.*)\/$/ ary << $1 elsif token.size > 0 |