about summary refs log tree commit diff stats
path: root/code
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2009-07-15 16:15:55 +0200
committerhut <hut@lavabit.com>2009-07-15 16:15:55 +0200
commitedea80531a5a2730a8b7afa1e2bcfa8447a2150d (patch)
treebe0ea9cc35400f194ca030b34c4fb2c3fbc1bc43 /code
parent9ef3aa8e00690863aae5702066d10278dd2c1a02 (diff)
downloadranger-edea80531a5a2730a8b7afa1e2bcfa8447a2150d.tar.gz
added mouse support
Diffstat (limited to 'code')
-rw-r--r--code/keys.rb46
1 files changed, 46 insertions, 0 deletions
diff --git a/code/keys.rb b/code/keys.rb
index 81876019..7ab65603 100644
--- a/code/keys.rb
+++ b/code/keys.rb
@@ -482,6 +482,52 @@ module Fm
 
 		## }}}
 
+		## Mouse {{{
+		when '<mouse>'
+			log mouse.bstate
+			if mouse.click3? or mouse.click1? or mouse.doubleclick1?
+				log "yes"
+				if mouse.y == 0
+				elsif mouse.y >= CLI.lines - @bars.size
+				else
+					boundaries = (0..3).map { |x| get_boundaries(x) }
+
+					ranges = boundaries.map { |x| x.first .. x.first + x.last }
+
+					case mouse.x
+					when ranges[0]
+						log "a"
+						descend
+						descend
+						if mouse.click3?
+							@pwd.pos = get_offset( @path[-1], lines ) + mouse.y - 1
+						end
+					when ranges[1]
+						log "b"
+						descend
+						if mouse.click1?
+							@pwd.pos = get_offset( @path[-1], lines ) + mouse.y - 1
+						end
+					when ranges[2]
+						log "c"
+						@pwd.pos = get_offset( @path[-1], lines ) + mouse.y - 1
+						if mouse.doubleclick1?
+							@buffer = ''
+							if mouse.ctrl? then press('L') else press('l') end
+						end
+					when ranges[3]
+						log "d"
+						@buffer = ''
+						if mouse.ctrl? then press('L') else press('l') end
+						if mouse.click1? and currentfile.dir?
+							@pwd.pos = get_offset( @path[-1], lines ) + mouse.y - 1
+						end
+					end
+				end
+			end
+
+		## }}}
+
 		end
 
 		@buffer = '' unless @buffer == '' or @buffer =~ key_regexp