about summary refs log tree commit diff stats
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
parent9ef3aa8e00690863aae5702066d10278dd2c1a02 (diff)
downloadranger-edea80531a5a2730a8b7afa1e2bcfa8447a2150d.tar.gz
added mouse support
-rw-r--r--code/keys.rb46
-rwxr-xr-xranger.rb2
2 files changed, 48 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
diff --git a/ranger.rb b/ranger.rb
index 6aa75a9e..6bb88d11 100755
--- a/ranger.rb
+++ b/ranger.rb
@@ -77,12 +77,14 @@ Signal.trap(Scheduler::UPDATE_SIGNAL) do
 end
 
 begin
+	CLI.init_mouse
 	Fm.initialize( pwd )
 	Fm.main_loop
 ensure
 	log "exiting!"
 	log ""
 	closei if CLI.running?
+	CLI.stop_mouse
 	Fm.dump
 
 	Fm.dump_pwd_to_3 if Option.cd
tik/mu/blame/generic.mu?h=hlt&id=ac32d9d197c6fb45849b13e5affd0e5999c5cd09'>^
d4b4d018 ^
7d2c2d55 ^
4b62edd8 ^
7d2c2d55 ^
f184c95e ^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30