tests: Add the capi.object miss handle support to the capi.mouse shim
This commit is contained in:
parent
1df44210c8
commit
2c8c274193
|
@ -3,7 +3,6 @@ local screen = require("screen")
|
||||||
local coords = {x=100,y=100}
|
local coords = {x=100,y=100}
|
||||||
|
|
||||||
local mouse = {
|
local mouse = {
|
||||||
screen = screen[1],
|
|
||||||
old_histories = {},
|
old_histories = {},
|
||||||
history = {},
|
history = {},
|
||||||
}
|
}
|
||||||
|
@ -17,11 +16,35 @@ function mouse.coords(args)
|
||||||
return coords
|
return coords
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function mouse.set_newindex_miss_handler(h)
|
||||||
|
rawset(mouse, "_ni_handler", h)
|
||||||
|
end
|
||||||
|
|
||||||
|
function mouse.set_index_miss_handler(h)
|
||||||
|
rawset(mouse, "_i_handler", h)
|
||||||
|
end
|
||||||
|
|
||||||
function mouse.push_history()
|
function mouse.push_history()
|
||||||
table.insert(mouse.old_histories, mouse.history)
|
table.insert(mouse.old_histories, mouse.history)
|
||||||
mouse.history = {}
|
mouse.history = {}
|
||||||
end
|
end
|
||||||
|
|
||||||
return mouse
|
return setmetatable(mouse, {
|
||||||
|
__index = function(self, key)
|
||||||
|
if key == "screen" then
|
||||||
|
return screen[1]
|
||||||
|
end
|
||||||
|
local h = rawget(mouse,"_i_handler")
|
||||||
|
if h then
|
||||||
|
return h(self, key)
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
__newindex = function(...)
|
||||||
|
local h = rawget(mouse,"_ni_handler")
|
||||||
|
if h then
|
||||||
|
h(...)
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80
|
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80
|
||||||
|
|
Loading…
Reference in New Issue