From 2afa5b5faebf2f3ae0cf3304cf55e53bd534b26e Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Sat, 16 Feb 2019 15:44:42 +0100 Subject: [PATCH] Move setup of selection() to selection.c The function selection() is now registered in the Lua global table from selection.c instead of in luaa.c. This "feels cleaner" to me and is preparatory for later changes. Signed-off-by: Uli Schlachter --- luaa.c | 6 +++--- selection.c | 9 ++++++++- selection.h | 2 +- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/luaa.c b/luaa.c index 2473a6783..317f2cf0d 100644 --- a/luaa.c +++ b/luaa.c @@ -385,9 +385,6 @@ luaA_fixups(lua_State *L) /* replace type */ lua_pushcfunction(L, luaAe_type); lua_setglobal(L, "type"); - /* set selection */ - lua_pushcfunction(L, luaA_selection_get); - lua_setglobal(L, "selection"); } static const char * @@ -1043,6 +1040,9 @@ luaA_init(xdgHandle* xdg, string_array_t *searchpath) /* Export selection watcher */ selection_watcher_class_setup(L); + /* Setup the selection interface */ + selection_setup(L); + /* add Lua search paths */ lua_getglobal(L, "package"); if (LUA_TTABLE != lua_type(L, 1)) diff --git a/selection.c b/selection.c index 7f20f1bb0..36f1c20f7 100644 --- a/selection.c +++ b/selection.c @@ -49,7 +49,7 @@ static xcb_window_t selection_window = XCB_NONE; * \luastack * \lreturn A string with the current X selection buffer. */ -int +static int luaA_selection_get(lua_State *L) { if(selection_window == XCB_NONE) @@ -132,4 +132,11 @@ luaA_selection_get(lua_State *L) return 0; } +void +selection_setup(lua_State *L) +{ + lua_pushcfunction(L, luaA_selection_get); + lua_setglobal(L, "selection"); +} + // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80 diff --git a/selection.h b/selection.h index 07b8cbbd8..5af3dab87 100644 --- a/selection.h +++ b/selection.h @@ -24,7 +24,7 @@ #include -int luaA_selection_get(lua_State *); +void selection_setup(lua_State *); #endif // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80