diff options
author | hut <hut@lavabit.com> | 2009-07-15 16:15:55 +0200 |
---|---|---|
committer | hut <hut@lavabit.com> | 2009-07-15 16:15:55 +0200 |
commit | edea80531a5a2730a8b7afa1e2bcfa8447a2150d (patch) | |
tree | be0ea9cc35400f194ca030b34c4fb2c3fbc1bc43 | |
parent | 9ef3aa8e00690863aae5702066d10278dd2c1a02 (diff) | |
download | ranger-edea80531a5a2730a8b7afa1e2bcfa8447a2150d.tar.gz |
added mouse support
-rw-r--r-- | code/keys.rb | 46 | ||||
-rwxr-xr-x | ranger.rb | 2 |
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 |