mirror of
https://github.com/MezzalunaWM/Mezzaluna.git
synced 2026-03-09 13:07:32 -04:00
merged
This commit is contained in:
commit
3cf05f2d9a
5 changed files with 50 additions and 29 deletions
|
|
@ -22,7 +22,7 @@ pub fn add_keymap(L: *zlua.Lua) i32 {
|
|||
// ensure the first three agrs of the correct types
|
||||
L.checkType(1, .string);
|
||||
L.checkType(2, .string);
|
||||
L.checkType(3, .function);
|
||||
L.checkType(3, .table);
|
||||
|
||||
var keymap: Keymap = undefined;
|
||||
keymap.options = .{
|
||||
|
|
@ -63,24 +63,28 @@ pub fn add_keymap(L: *zlua.Lua) i32 {
|
|||
};
|
||||
keymap.keycode = xkb.Keysym.fromName(key, .no_flags);
|
||||
|
||||
L.checkType(3, .function);
|
||||
keymap.lua_ref_idx = L.ref(zlua.registry_index) catch {
|
||||
L.raiseErrorStr("Lua error check your config", .{});
|
||||
return 0;
|
||||
};
|
||||
|
||||
// FIXME: for som reason I can't seem to get this to validate that the 4th
|
||||
// argument exists unless there's a 5th argument. It doesn't seem to matter
|
||||
// what type the 5th is just that it's there.
|
||||
if (nargs == 4) {
|
||||
// L.checkType(4, .table);
|
||||
// _ = L.pushString("on_release");
|
||||
// _ = L.getTable(4);
|
||||
// const b = L.toBoolean(-1);
|
||||
// L.pop(-1);
|
||||
// L.pop(-1);
|
||||
_ = L.pushString("press");
|
||||
_ = L.getTable(3);
|
||||
if (L.isFunction(-1)) {
|
||||
keymap.lua_press_ref_idx = L.ref(zlua.registry_index) catch {
|
||||
L.raiseErrorStr("Lua error check your config", .{});
|
||||
return 0;
|
||||
};
|
||||
}
|
||||
|
||||
_ = L.pushString("release");
|
||||
_ = L.getTable(3);
|
||||
if (L.isFunction(-1)) {
|
||||
keymap.lua_release_ref_idx = L.ref(zlua.registry_index) catch {
|
||||
L.raiseErrorStr("Lua error check your config", .{});
|
||||
return 0;
|
||||
};
|
||||
}
|
||||
|
||||
_ = L.pushString("repeat");
|
||||
_ = L.getTable(3);
|
||||
keymap.options.repeat = L.isNil(-1) or L.toBoolean(-1);
|
||||
|
||||
const hash = Keymap.hash(keymap.modifier, keymap.keycode);
|
||||
server.keymaps.put(hash, keymap) catch |err| {
|
||||
std.log.err("Failed to add keymap to keymaps: {}", .{err});
|
||||
|
|
@ -6,7 +6,7 @@ const zlua = @import("zlua");
|
|||
|
||||
const Bridge = @import("bridge.zig");
|
||||
const Fs = @import("fs.zig");
|
||||
const Api = @import("api.zig");
|
||||
const Input = @import("input.zig");
|
||||
|
||||
const gpa = std.heap.c_allocator;
|
||||
|
||||
|
|
@ -59,9 +59,9 @@ pub fn init(self: *Lua) !void {
|
|||
self.state.setField(-2, "fs");
|
||||
}
|
||||
{
|
||||
const api_funcs = zlua.fnRegsFromType(Api);
|
||||
self.state.newLib(api_funcs);
|
||||
self.state.setField(-2, "api");
|
||||
const input_funcs = zlua.fnRegsFromType(Input);
|
||||
self.state.newLib(input_funcs);
|
||||
self.state.setField(-2, "input");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue