Browse Source

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 <psychon@znc.in>
Uli Schlachter 9 months ago
parent
commit
2afa5b5fae
3 changed files with 12 additions and 5 deletions
  1. 3
    3
      luaa.c
  2. 8
    1
      selection.c
  3. 1
    1
      selection.h

+ 3
- 3
luaa.c View File

@@ -385,9 +385,6 @@ luaA_fixups(lua_State *L)
385 385
     /* replace type */
386 386
     lua_pushcfunction(L, luaAe_type);
387 387
     lua_setglobal(L, "type");
388
-    /* set selection */
389
-    lua_pushcfunction(L, luaA_selection_get);
390
-    lua_setglobal(L, "selection");
391 388
 }
392 389
 
393 390
 static const char *
@@ -1043,6 +1040,9 @@ luaA_init(xdgHandle* xdg, string_array_t *searchpath)
1043 1040
     /* Export selection watcher */
1044 1041
     selection_watcher_class_setup(L);
1045 1042
 
1043
+    /* Setup the selection interface */
1044
+    selection_setup(L);
1045
+
1046 1046
     /* add Lua search paths */
1047 1047
     lua_getglobal(L, "package");
1048 1048
     if (LUA_TTABLE != lua_type(L, 1))

+ 8
- 1
selection.c View File

@@ -49,7 +49,7 @@ static xcb_window_t selection_window = XCB_NONE;
49 49
  * \luastack
50 50
  * \lreturn A string with the current X selection buffer.
51 51
  */
52
-int
52
+static int
53 53
 luaA_selection_get(lua_State *L)
54 54
 {
55 55
     if(selection_window == XCB_NONE)
@@ -132,4 +132,11 @@ luaA_selection_get(lua_State *L)
132 132
     return 0;
133 133
 }
134 134
 
135
+void
136
+selection_setup(lua_State *L)
137
+{
138
+    lua_pushcfunction(L, luaA_selection_get);
139
+    lua_setglobal(L, "selection");
140
+}
141
+
135 142
 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80

+ 1
- 1
selection.h View File

@@ -24,7 +24,7 @@
24 24
 
25 25
 #include <lua.h>
26 26
 
27
-int luaA_selection_get(lua_State *);
27
+void selection_setup(lua_State *);
28 28
 
29 29
 #endif
30 30
 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80

Loading…
Cancel
Save