From 7a36ebaf635a8ca8b3b45e900ac593bab5900c54 Mon Sep 17 00:00:00 2001 From: Charlotte Meyer Date: Tue, 10 Aug 2021 19:26:34 +0000 Subject: [PATCH] Add view:id() --- kiwmi/luak/kiwmi_view.c | 18 ++++++++++++++++++ lua_docs.md | 4 ++++ 2 files changed, 22 insertions(+) diff --git a/kiwmi/luak/kiwmi_view.c b/kiwmi/luak/kiwmi_view.c index 5fe8c6a..9a2fe0f 100644 --- a/kiwmi/luak/kiwmi_view.c +++ b/kiwmi/luak/kiwmi_view.c @@ -143,6 +143,23 @@ l_kiwmi_view_hide(lua_State *L) return 0; } +static int +l_kiwmi_view_id(lua_State *L) +{ + struct kiwmi_object *obj = + *(struct kiwmi_object **)luaL_checkudata(L, 1, "kiwmi_view"); + + if (!obj->valid) { + return luaL_error(L, "kiwmi_view no longer valid"); + } + + struct kiwmi_view *view = obj->object; + + lua_pushnumber(L, (lua_Number)(size_t)view); + + return 1; +} + static int l_kiwmi_view_imove(lua_State *L) { @@ -411,6 +428,7 @@ static const luaL_Reg kiwmi_view_methods[] = { {"focus", l_kiwmi_view_focus}, {"hidden", l_kiwmi_view_hidden}, {"hide", l_kiwmi_view_hide}, + {"id", l_kiwmi_view_id}, {"imove", l_kiwmi_view_imove}, {"iresize", l_kiwmi_view_iresize}, {"move", l_kiwmi_view_move}, diff --git a/lua_docs.md b/lua_docs.md index 7dc7930..3e8fb34 100644 --- a/lua_docs.md +++ b/lua_docs.md @@ -279,6 +279,10 @@ Returns `true` if the view is hidden, `false` otherwise. Hides the view. +#### view:id() + +Returns an ID unique to the view. + #### view:imove() Starts an interactive move.