mirror of https://github.com/Hilbis/Hilbish
feat(greenhouse): add functions for custom keybinds
parent
60f267260b
commit
713f24aa3e
|
@ -18,6 +18,12 @@ function Greenhouse:new(sink)
|
||||||
self.sink = sink
|
self.sink = sink
|
||||||
self.pages = {}
|
self.pages = {}
|
||||||
self.curPage = 1
|
self.curPage = 1
|
||||||
|
self.keybinds = {
|
||||||
|
['Up'] = function(self) self:scroll 'up' end,
|
||||||
|
['Down'] = function(self) self:scroll 'down' end,
|
||||||
|
['Ctrl-Left'] = self.previous,
|
||||||
|
['Ctrl-Right'] = self.next
|
||||||
|
}
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
@ -85,6 +91,10 @@ function Greenhouse:previous()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function Greenhouse:keybind(key, callback)
|
||||||
|
self.keybinds[key] = callback
|
||||||
|
end
|
||||||
|
|
||||||
function Greenhouse:initUi()
|
function Greenhouse:initUi()
|
||||||
local ansikit = require 'ansikit'
|
local ansikit = require 'ansikit'
|
||||||
local bait = require 'bait'
|
local bait = require 'bait'
|
||||||
|
@ -114,15 +124,9 @@ function Greenhouse:initUi()
|
||||||
done = true
|
done = true
|
||||||
end
|
end
|
||||||
|
|
||||||
if c == 'Up' then
|
if self.keybinds[c] then
|
||||||
self:scroll 'up'
|
self.keybinds[c](self)
|
||||||
end
|
end
|
||||||
if c == 'Down' then
|
|
||||||
self:scroll 'down'
|
|
||||||
end
|
|
||||||
|
|
||||||
if c == 'Ctrl-Right' then self:next() end
|
|
||||||
if c == 'Ctrl-Left' then self:previous() end
|
|
||||||
|
|
||||||
--[[
|
--[[
|
||||||
if c == 27 then
|
if c == 27 then
|
||||||
|
|
Loading…
Reference in New Issue