diff options
Diffstat (limited to 'src/config/lua/bindings/LuaBindingsToplevel.cpp')
| -rw-r--r-- | src/config/lua/bindings/LuaBindingsToplevel.cpp | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/src/config/lua/bindings/LuaBindingsToplevel.cpp b/src/config/lua/bindings/LuaBindingsToplevel.cpp index 2d54a7b3..1b345cde 100644 --- a/src/config/lua/bindings/LuaBindingsToplevel.cpp +++ b/src/config/lua/bindings/LuaBindingsToplevel.cpp @@ -132,13 +132,12 @@ static int hlBind(lua_State* L) { if (auto res = parseKeyString(kb, keys); !res) return Internal::configError(L, std::format("hl.bind: failed to parse key string: {}", res.error())); - if (!lua_isfunction(L, 2)) + if (!Internal::pushDispatcherFunction(L, 2)) return Internal::configError(L, "hl.bind: dispatcher must be a dispatcher (e.g. hl.dsp.window.close()) or a lua function"); if (kb.catchAll && mgr->m_currentSubmap.empty()) return Internal::configError(L, "hl.bind: catchall keybinds are only allowed in submaps."); - lua_pushvalue(L, 2); int ref = luaL_ref(L, LUA_REGISTRYINDEX); kb.handler = "__lua"; kb.arg = std::to_string(ref); @@ -293,10 +292,9 @@ static int hlExecCmd(lua_State* L) { } static int hlDispatch(lua_State* L) { - if (!lua_isfunction(L, 1)) - return Internal::configError(L, "hl.dispatch: expected a dispatcher function (e.g. hl.dsp.window.close())"); + if (!Internal::pushDispatcherFunction(L, 1)) + return Internal::configError(L, "hl.dispatch: expected a dispatcher (e.g. hl.dsp.window.close())"); - lua_pushvalue(L, 1); int status = LUA_OK; if (auto* mgr = CConfigManager::fromLuaState(L); mgr) status = mgr->guardedPCall(0, 1, 0, CConfigManager::LUA_TIMEOUT_DISPATCH_MS, "hl.dispatch"); |
