mirror of
https://github.com/MezzalunaWM/Mezzaluna.git
synced 2026-03-07 19:49:53 -05:00
basic add and del mousemaps work, drag is yet to be implemented
This commit is contained in:
parent
64dccb248d
commit
9d8463255c
5 changed files with 81 additions and 112 deletions
|
|
@ -6,43 +6,6 @@ mez.input.add_keymap("alt", "g", {
|
|||
end
|
||||
})
|
||||
|
||||
mez.input.add_keymap("alt", "i", {
|
||||
press = function ()
|
||||
local coroutine = require("coroutine")
|
||||
print(coroutine)
|
||||
local co = coroutine.create(function ()
|
||||
print("starting coroutine")
|
||||
local view_id = mez.view.get_focused_id()
|
||||
|
||||
local size = mez.view.get_size(view_id)
|
||||
local pos = mez.view.get_position(view_id)
|
||||
local res = mez.output.get_resolution(0)
|
||||
|
||||
local x_pos = pos.x
|
||||
local y_pos = pos.y
|
||||
local x_vel = 10
|
||||
local y_vel = 10
|
||||
|
||||
while true do
|
||||
x_pos = x_pos + x_vel
|
||||
y_pos = y_pos + y_vel
|
||||
|
||||
if x_pos + size.width > res.width or x_pos < 0 then
|
||||
x_vel = x_vel * -1
|
||||
end
|
||||
|
||||
if y_pos + size.height > res.height or y_pos < 0 then
|
||||
y_vel = y_vel * -1
|
||||
end
|
||||
|
||||
print("(" .. x_pos .. ", " .. y_pos .. ")")
|
||||
mez.view.set_position(view_id, x_pos, y_pos)
|
||||
end
|
||||
end)
|
||||
coroutine.resume(co)
|
||||
end
|
||||
})
|
||||
|
||||
local master = function()
|
||||
local config = {
|
||||
tag_count = 5,
|
||||
|
|
@ -310,32 +273,16 @@ local master = function()
|
|||
press = function() mez.api.change_vt(i) end
|
||||
})
|
||||
end
|
||||
|
||||
mez.input.add_mousemap("alt", "BTN_LEFT", {
|
||||
press = function()
|
||||
print("pressed mouse")
|
||||
mez.input.del_mousemap("alt", "BTN_LEFT");
|
||||
end,
|
||||
release = function() print("released mouse") end,
|
||||
drag = function() print("dragging mouse") end
|
||||
})
|
||||
|
||||
end
|
||||
|
||||
master()
|
||||
|
||||
function print_table(tbl, indent, seen)
|
||||
indent = indent or 0
|
||||
seen = seen or {}
|
||||
|
||||
-- Prevent infinite loops from circular references
|
||||
if seen[tbl] then
|
||||
print(string.rep(" ", indent) .. "...(circular reference)")
|
||||
return
|
||||
end
|
||||
seen[tbl] = true
|
||||
|
||||
for key, value in pairs(tbl) do
|
||||
local formatting = string.rep(" ", indent) .. tostring(key) .. ": "
|
||||
|
||||
if type(value) == "table" then
|
||||
print(formatting .. "{")
|
||||
print_table(value, indent + 1, seen)
|
||||
print(string.rep(" ", indent) .. "}")
|
||||
elseif type(value) == "string" then
|
||||
print(formatting .. '"' .. value .. '"')
|
||||
else
|
||||
print(formatting .. tostring(value))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue