diff --git a/data/core/commands/root.lua b/data/core/commands/root.lua index e41c723d..7ebb0e60 100644 --- a/data/core/commands/root.lua +++ b/data/core/commands/root.lua @@ -3,6 +3,7 @@ local style = require "core.style" local DocView = require "core.docview" local command = require "core.command" local common = require "core.common" +local config = require "core.config" local t = { @@ -77,6 +78,14 @@ local t = { local n = (parent.a == node) and 0.1 or -0.1 parent.divider = common.clamp(parent.divider + n, 0.1, 0.9) end, + + ["root:scroll"] = function(delta) + if core.active_view and core.active_view.scrollable then + core.active_view.scroll.to.y = core.active_view.scroll.to.y + delta * -config.mouse_wheel_scroll + return true + end + return false + end } diff --git a/data/core/keymap.lua b/data/core/keymap.lua index e3fe15a4..2c60f8d9 100644 --- a/data/core/keymap.lua +++ b/data/core/keymap.lua @@ -92,7 +92,7 @@ end local click_prefixes = { "s", "d", "t" } function keymap.on_mouse_pressed(button, x, y, clicks) - return not keymap.on_key_pressed(click_prefixes[((clicks - 1) % 3) + 1] .. button:sub(1,1) .. "click", x, y, clicks) + return not keymap.on_key_pressed(click_prefixes[((clicks - 1) % 3) + 1] .. button:sub(1,1) .. "click", x, y, clicks) and keymap.on_key_pressed(button:sub(1,1) .. "click", x, y, clicks) end @@ -143,6 +143,7 @@ keymap.add_direct { ["alt+7"] = "root:switch-to-tab-7", ["alt+8"] = "root:switch-to-tab-8", ["alt+9"] = "root:switch-to-tab-9", + ["wheel"] = "root:scroll", ["ctrl+f"] = "find-replace:find", ["ctrl+r"] = "find-replace:replace", diff --git a/data/core/view.lua b/data/core/view.lua index d1374ee4..d6d1bcbc 100644 --- a/data/core/view.lua +++ b/data/core/view.lua @@ -102,13 +102,9 @@ function View:on_text_input(text) -- no-op end - function View:on_mouse_wheel(y) - if self.scrollable then - self.scroll.to.y = self.scroll.to.y + y * -config.mouse_wheel_scroll - end -end +end function View:get_content_bounds() local x = self.scroll.x