Created
December 3, 2010 03:35
-
-
Save mason-larobina/726550 to your computer and use it in GitHub Desktop.
Autoscrolling script for luakit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
---------------------------------------------------------------- | |
-- Simple autoscroll script for luakit (luakit.org) -- | |
-- Install instructions: -- | |
-- 1. Add to rc.lua before window spawning code. -- | |
-- 2. Or: save to $XDG_CONFIG_HOME/luakit/autoscroll.lua and -- | |
-- add `require "autoscroll"` to your rc.lua -- | |
---------------------------------------------------------------- | |
local buf, key = lousy.bind.buf, lousy.bind.key | |
add_binds("normal", { | |
-- Start autoscroll with ,a | |
buf("^,a$", function (w) w:set_mode("autoscroll") end), | |
}) | |
add_binds("autoscroll", { | |
-- Increase scrolling speed | |
key({}, "+", function (w) | |
w.autoscroll_timer:stop() | |
w.autoscroll_timer.interval = math.max(5, w.autoscroll_timer.interval - 5) | |
w.autoscroll_timer:start() | |
end), | |
-- Decrease scrolling speed | |
key({}, "-", function (w) | |
w.autoscroll_timer:stop() | |
w.autoscroll_timer.interval = w.autoscroll_timer.interval + 5 | |
w.autoscroll_timer:start() | |
end), | |
}) | |
new_mode("autoscroll", { | |
-- Start autoscroll timer | |
enter = function (w) | |
local t = timer{interval=50} | |
t:add_signal("timeout", function () | |
w:scroll_vert("+1px") | |
end) | |
w.autoscroll_timer = t | |
t:start() | |
end, | |
-- Stop autoscroll timer | |
leave = function (w) | |
if w.autoscroll_timer then | |
w.autoscroll_timer:stop() | |
w.autoscroll_timer = nil | |
end | |
end, | |
}) |
As of luakit 0d5f4ab
, this doesn't work.
Apparently scroll_vert
is not a valid function.
I've made some changes:
- Replaced
scroll_vert
forscroll
- Added default scroll keybindings.
Link's here
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nice mode!
Just a suggestion, could you set the prompt when the mode starts?
w:set_prompt("-- AUTOSCROLL MODE --")
or something like that.