-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve mouse support #31
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1041,6 +1041,24 @@ function onCursorUp(view) | |
selectline_if_tree(view) | ||
end | ||
|
||
--scroll cursor when mousewheel is scrolled | ||
function onScrollDown(view) | ||
if view == tree_view then | ||
tree_view.Buf.Cursor:Down() | ||
select_line() | ||
-- not sure if return false is required, I'm new to this | ||
return false | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
end | ||
end | ||
|
||
function onScrollUp(view) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Again, |
||
if view == tree_view then | ||
tree_view.Buf.Cursor:Up() | ||
select_line() | ||
return false | ||
end | ||
end | ||
|
||
-- Alt-Shift-{ | ||
-- Go to target's parent directory (if exists) | ||
function preParagraphPrevious(view) | ||
|
@@ -1095,9 +1113,13 @@ function preMousePress(view, event) | |
local x, y = event:Position() | ||
-- Fixes the y because softwrap messes with it | ||
local new_x, new_y = tree_view:GetMouseClickLocation(x, y) | ||
-- Try to open whatever is at the click's y index | ||
-- Will go into/back dirs based on what's clicked, nothing gets expanded | ||
try_open_at_y(new_y) | ||
|
||
--open item if it is selected, otherwise select it. | ||
if tree_view.Buf.Cursor.Loc.Y == new_y then | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this chunk really necessary? I feel having to double-click to open is kind of pointless, although I am used to single-click's on my linux DE. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I personally prefer double click but it also solves the problem that if you use a mouse click to switch to the tree pane it will enter whatever directory the cursor is on There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That problem could be solved without requiring double-click, I think? Possibly by adding in a section to the But I'm not exactly sure how you'd get the xy of the tree. Probably possible.. |
||
try_open_at_y(new_y) | ||
else | ||
select_line(new_y) | ||
end | ||
-- Don't actually allow the mousepress to trigger, so we avoid highlighting stuff | ||
return false | ||
end | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This &
onScrollUp
should bepre
instead ofon
. This is because apre
action is triggered before performing the action, whileon
means it's triggered after the action occurs.Think of it in the sequence of actions:
preScrollDown
, but not actually performing the action.preScrollDown
hasreturn false
in it, the scroll down action is canceled, stopping here. Otherwise, it continues to 3.onScrollDown
callback is triggered. This doesn't listen for anyreturn
's