Also changed docview mousewheel into a scroll command.

This commit is contained in:
Adam Harrison 2021-11-07 15:42:03 -05:00
parent 7babed1e6b
commit 50c0659445
3 changed files with 12 additions and 6 deletions

View File

@ -3,6 +3,7 @@ local style = require "core.style"
local DocView = require "core.docview" local DocView = require "core.docview"
local command = require "core.command" local command = require "core.command"
local common = require "core.common" local common = require "core.common"
local config = require "core.config"
local t = { local t = {
@ -77,6 +78,14 @@ local t = {
local n = (parent.a == node) and 0.1 or -0.1 local n = (parent.a == node) and 0.1 or -0.1
parent.divider = common.clamp(parent.divider + n, 0.1, 0.9) parent.divider = common.clamp(parent.divider + n, 0.1, 0.9)
end, 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
} }

View File

@ -92,7 +92,7 @@ end
local click_prefixes = { "s", "d", "t" } local click_prefixes = { "s", "d", "t" }
function keymap.on_mouse_pressed(button, x, y, clicks) 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) keymap.on_key_pressed(button:sub(1,1) .. "click", x, y, clicks)
end end
@ -143,6 +143,7 @@ keymap.add_direct {
["alt+7"] = "root:switch-to-tab-7", ["alt+7"] = "root:switch-to-tab-7",
["alt+8"] = "root:switch-to-tab-8", ["alt+8"] = "root:switch-to-tab-8",
["alt+9"] = "root:switch-to-tab-9", ["alt+9"] = "root:switch-to-tab-9",
["wheel"] = "root:scroll",
["ctrl+f"] = "find-replace:find", ["ctrl+f"] = "find-replace:find",
["ctrl+r"] = "find-replace:replace", ["ctrl+r"] = "find-replace:replace",

View File

@ -102,13 +102,9 @@ function View:on_text_input(text)
-- no-op -- no-op
end end
function View:on_mouse_wheel(y) 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() function View:get_content_bounds()
local x = self.scroll.x local x = self.scroll.x