about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--code/keys.rb246
1 files changed, 126 insertions, 120 deletions
diff --git a/code/keys.rb b/code/keys.rb
index 285614df..339b3f29 100644
--- a/code/keys.rb
+++ b/code/keys.rb
@@ -128,9 +128,6 @@ module Fm
 			closei
 			starti
 
-		when 'j', '<down>'
-			@pwd.pos += 1
-
 		when 's'
 			closei
 			system('clear')
@@ -142,7 +139,6 @@ module Fm
 			@pwd.schedule
 			starti
 
-
 		when /^S(.)$/
 			Option.sort_reverse = $1.ord.between?(65, 90)
 
@@ -178,12 +174,6 @@ module Fm
 			@bars.last.kill unless @bars.empty?
 
 
-		when 'J'
-			@pwd.pos += lines/2
-
-		when 'K'
-			@pwd.pos -= lines/2
-
 		when 'cp', 'yy'
 			@copy = selection
 			@cut = false
@@ -311,66 +301,6 @@ module Fm
 
 		when /^block.*stop$/
 			@buffer = ''
-			
-		when /^!(.+)$/
-			str = $1
-			if str =~ /^(\!?)(.*)(<cr>|<esc>)$/
-				@buffer = ''
-				if $3 == '<cr>'
-					closei
-					system("bash", "-c", $2)
-					Action.wait_for_enter unless $1.empty?
-					starti
-					@pwd.schedule
-				end
-			end
-
-		when /^cd(.+)$/
-			str = $1
-			if str =~ /^\s?(.*)(<cr>|<esc>)$/
-				@buffer = ''
-				if $2 == '<cr>'
-					remember_dir
-					enter_dir_safely($1)
-				end
-			end
-
-		when /^(mv|cw|rename)(.+)$/
-			str = $2
-#			if $1 == 'mv'
-#				if str =~ /['`"]([\w\d])/
-#					if path = @memory[$1]
-#						str = ''
-#						@buffer.clear
-#						if File.exists?(path) and File.directory?(path)
-#							Action.move(selection, path)
-#						end
-#					end
-#				end
-#			end
-			log str
-			if str =~ /^\s?(.*)(<cr>|<esc>)$/
-				@buffer = ''
-				if $2 == '<cr>'
-					files = selection
-					if files.size == 1
-						fn = $1
-						log "!!! #{fn}"
-						unless fn.include? '.'
-							if ext = files.first.basename.from_last('.')
-								fn << ".#{ext}"
-							end
-							log "??? #{ext}"
-						end
-						Action.move(files, fn)
-						@pwd.refresh!
-						@pwd.find_file(fn)
-					else
-						Action.move(files, $1)
-						@pwd.refresh!
-					end
-				end
-			end
 
 		when 'tw'
 			Option.wide_bar ^= true
@@ -392,34 +322,11 @@ module Fm
 			Option.dir_first ^= true
 			@pwd.schedule
 
-		when 'delete'
-			files = selection
-			@marked = []
-			for f in files
-				if f and f.exists? and f.dir?
-					system('rm', '-r', f.to_s)
-					@pwd.schedule
-				end
-			end
-
-		when 'p'
-			if @cut
-				Action.move(@copy, @pwd.path)
-				@cut = false
-			else
-				Action.copy(@copy, @pwd.path)
-			end
-			@pwd.refresh!
-			if @copy.size == 1
-				@pwd.find_file(@copy[0].basename)
-			end
-
 		when 'P'
 			for f in @copy
 				File.symlink(f.path, File.expand_path(f.basename))
 			end
 
-
 		when /^(?:`|'|go)(.)$/
 			if dir = @memory[$1] and not @pwd.path == dir
 				remember_dir
@@ -451,12 +358,6 @@ module Fm
 		when /^m(.)$/
 			@memory[$1] = @pwd.path
 
-		when /^o(.)$/
-			if @memory[$1]
-				Action.move(selection, @memory[$1])
-			end
-			@pwd.refresh!
-
 		when /^um(.)$/
 			@memory.delete($1)
 
@@ -488,9 +389,7 @@ module Fm
 			end
 			@marked = []
 
-
-		when 'gg'
-			@pwd.pos = 0
+		## Destructive {{{
 
 		when 'dd'
 			new_path = move_to_trash(currentfile)
@@ -502,16 +401,81 @@ module Fm
 			end
 			@pwd.schedule
 
-		when 'dfd'
-			cf = currentfile
+		when 'seriouslydd'
+			cf = currrentfile
 			if cf and cf.exists?
 				cf.delete!
 				@pwd.schedule
 			end
 
-		when 'term'
-			fork do exec 'x-terminal-emulator' end
+		when 'delete'
+			files = selection
+			@marked = []
+			for f in files
+				if f and f.exists? and f.dir?
+					system('rm', '-r', f.to_s)
+					@pwd.schedule
+				end
+			end
+
+		when 'p'
+			if @cut
+				Action.move(@copy, @pwd.path)
+				@cut = false
+			else
+				Action.copy(@copy, @pwd.path)
+			end
+			@pwd.refresh!
+			if @copy.size == 1
+				@pwd.find_file(@copy[0].basename)
+			end
+
+		when /^o(.)$/
+			if @memory[$1]
+				Action.move(selection, @memory[$1])
+			end
+			@pwd.refresh!
 
+		when /^(mv|cw|rename)(.+)$/
+			str = $2
+#			if $1 == 'mv'
+#				if str =~ /['`"]([\w\d])/
+#					if path = @memory[$1]
+#						str = ''
+#						@buffer.clear
+#						if File.exists?(path) and File.directory?(path)
+#							Action.move(selection, path)
+#						end
+#					end
+#				end
+#			end
+			log str
+			if str =~ /^\s?(.*)(<cr>|<esc>)$/
+				@buffer = ''
+				if $2 == '<cr>'
+					files = selection
+					if files.size == 1
+						fn = $1
+						log "!!! #{fn}"
+						unless fn.include? '.'
+							if ext = files.first.basename.from_last('.')
+								fn << ".#{ext}"
+							end
+							log "??? #{ext}"
+						end
+						Action.move(files, fn)
+						@pwd.refresh!
+						@pwd.find_file(fn)
+					else
+						Action.move(files, $1)
+						@pwd.refresh!
+					end
+				end
+			end
+
+		## }}}
+
+		## gX {{{
 		when 'g0'
 			remember_dir
 			enter_dir('/')
@@ -543,6 +507,11 @@ module Fm
 		when 'gs'
 			remember_dir
 			enter_dir('/srv')
+		## }}}
+
+		## Movement {{{
+		when 'gg'
+			@pwd.pos = 0
 
 		when 'G'
 			@pwd.pos = @pwd.size - 1
@@ -550,16 +519,17 @@ module Fm
 		when 'k', '<up>'
 			@pwd.pos -= 1
 
+		when 'j', '<down>'
+			@pwd.pos += 1
+
 		when '<bs>', 'h', 'H', '<left>'
 			descend
 
-		when 'E'
-			cf = currentfile.path
-			unless cf.nil? or enter_dir_safely(cf)
-				closei
-				system VI % cf
-				starti
-			end
+		when 'J'
+			@pwd.pos += lines/2
+
+		when 'K'
+			@pwd.pos -= lines/2
 
 		when '<cr>', 'l', 'L', '<right>'
 			if currentfile.dir?
@@ -569,9 +539,52 @@ module Fm
 				Action.run(RunContext.new(getfiles, mode, 'a'))
 			end
 
+		when /^cd(.+)$/
+			str = $1
+			if str =~ /^\s?(.*)(<cr>|<esc>)$/
+				@buffer = ''
+				if $2 == '<cr>'
+					remember_dir
+					enter_dir_safely($1)
+				end
+			end
+		## }}}
+
+		## Launching applications {{{
+			
+		when /^!(.+)$/
+			str = $1
+			if str =~ /^(\!?)(.*)(<cr>|<esc>)$/
+				@buffer = ''
+				if $3 == '<cr>'
+					closei
+					system("bash", "-c", $2)
+					Action.wait_for_enter unless $1.empty?
+					starti
+					@pwd.schedule
+				end
+			end
+
+		when 'term'
+			fork do exec 'x-terminal-emulator' end
+
+		when 'E'
+			cf = currentfile.path
+			unless cf.nil? or enter_dir_safely(cf)
+				closei
+				system VI % cf
+				starti
+			end
+
 		when /^[ri](\d*)([adetw]*)[ri]$/
 			run_context = RunContext.new(getfiles, $1, $2)
 			Action.run(run_context)
+
+		when "-", "="
+			val = "2#{key=='-' ? '-' : '+'}"
+			system("amixer", "-q", "set", "PCM", val, "unmute")
+
+		## }}}
 		
 		when 'ZZ', '<c-d>', ':q<cr>', 'Q'
 			exit
@@ -583,13 +596,6 @@ module Fm
 		when '<c-r>'
 			Fm.boot_up
 
-		when "-", "="
-			val = "2#{key=='-' ? '-' : '+'}"
-			system("amixer", "-q", "set", "PCM", val, "unmute")
-
-		else
-#			log key.ord
-
 		end
 
 		@buffer = '' unless @buffer == '' or @buffer =~ REGX