[lua] Split luaA_parserc into luaA_init/parserc
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
35d1bc283f
commit
4af0791499
15
awesome.c
15
awesome.c
|
@ -361,12 +361,6 @@ main(int argc, char **argv)
|
||||||
xcolor_new(globalconf.connection, globalconf.default_screen, "black", &globalconf.colors.fg);
|
xcolor_new(globalconf.connection, globalconf.default_screen, "black", &globalconf.colors.fg);
|
||||||
xcolor_new(globalconf.connection, globalconf.default_screen, "white", &globalconf.colors.bg);
|
xcolor_new(globalconf.connection, globalconf.default_screen, "white", &globalconf.colors.bg);
|
||||||
|
|
||||||
/* parse config */
|
|
||||||
if(!confpath)
|
|
||||||
confpath = config_file();
|
|
||||||
if (!luaA_parserc(confpath))
|
|
||||||
eprint("failed to load/parse configuration file %s", confpath);
|
|
||||||
|
|
||||||
/* init cursors */
|
/* init cursors */
|
||||||
globalconf.cursor[CurNormal] = xutil_cursor_new(globalconf.connection, CURSOR_LEFT_PTR);
|
globalconf.cursor[CurNormal] = xutil_cursor_new(globalconf.connection, CURSOR_LEFT_PTR);
|
||||||
globalconf.cursor[CurResize] = xutil_cursor_new(globalconf.connection, CURSOR_SIZING);
|
globalconf.cursor[CurResize] = xutil_cursor_new(globalconf.connection, CURSOR_SIZING);
|
||||||
|
@ -378,6 +372,15 @@ main(int argc, char **argv)
|
||||||
globalconf.cursor[CurBotRight] = xutil_cursor_new(globalconf.connection, CURSOR_BOTTOM_RIGHT_CORNER);
|
globalconf.cursor[CurBotRight] = xutil_cursor_new(globalconf.connection, CURSOR_BOTTOM_RIGHT_CORNER);
|
||||||
globalconf.cursor[CurBotLeft] = xutil_cursor_new(globalconf.connection, CURSOR_BOTTOM_LEFT_CORNER);
|
globalconf.cursor[CurBotLeft] = xutil_cursor_new(globalconf.connection, CURSOR_BOTTOM_LEFT_CORNER);
|
||||||
|
|
||||||
|
/* init lua */
|
||||||
|
luaA_init();
|
||||||
|
|
||||||
|
/* parse config */
|
||||||
|
if(!confpath)
|
||||||
|
confpath = config_file();
|
||||||
|
if (!luaA_parserc(confpath))
|
||||||
|
eprint("failed to load/parse configuration file %s", confpath);
|
||||||
|
|
||||||
/* select for events */
|
/* select for events */
|
||||||
const uint32_t change_win_vals[] =
|
const uint32_t change_win_vals[] =
|
||||||
{
|
{
|
||||||
|
|
22
lua.c
22
lua.c
|
@ -402,11 +402,12 @@ luaA_openlib(lua_State *L, const char *name,
|
||||||
luaL_register(L, name, methods);
|
luaL_register(L, name, methods);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
/** Initialize the Lua VM
|
||||||
luaA_parserc(const char *rcfile)
|
*/
|
||||||
|
void
|
||||||
|
luaA_init(void)
|
||||||
{
|
{
|
||||||
lua_State *L;
|
lua_State *L;
|
||||||
int screen;
|
|
||||||
|
|
||||||
static const struct luaL_reg awesome_lib[] =
|
static const struct luaL_reg awesome_lib[] =
|
||||||
{
|
{
|
||||||
|
@ -480,10 +481,21 @@ luaA_parserc(const char *rcfile)
|
||||||
lua_settable(L, LUA_GLOBALSINDEX);
|
lua_settable(L, LUA_GLOBALSINDEX);
|
||||||
|
|
||||||
luaA_dostring(L, "package.path = package.path .. \";" AWESOME_LUA_LIB_PATH "/?.lua\"");
|
luaA_dostring(L, "package.path = package.path .. \";" AWESOME_LUA_LIB_PATH "/?.lua\"");
|
||||||
|
}
|
||||||
|
|
||||||
if(luaL_dofile(L, rcfile))
|
/** Load a configuration file
|
||||||
|
*
|
||||||
|
* \param rcfile The configuration file to load.
|
||||||
|
* \return True on succes, false on failure.
|
||||||
|
*/
|
||||||
|
bool
|
||||||
|
luaA_parserc(const char* rcfile)
|
||||||
|
{
|
||||||
|
int screen;
|
||||||
|
|
||||||
|
if(luaL_dofile(globalconf.L, rcfile))
|
||||||
{
|
{
|
||||||
fprintf(stderr, "%s\n", lua_tostring(L, -1));
|
fprintf(stderr, "%s\n", lua_tostring(globalconf.L, -1));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
1
lua.h
1
lua.h
|
@ -133,6 +133,7 @@ luaA_checkboolean(lua_State *L, int n)
|
||||||
return lua_toboolean(L, n);
|
return lua_toboolean(L, n);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void luaA_init(void);
|
||||||
bool luaA_parserc(const char *);
|
bool luaA_parserc(const char *);
|
||||||
void luaA_docmd(char *);
|
void luaA_docmd(char *);
|
||||||
void luaA_pushpointer(void *, awesome_type_t);
|
void luaA_pushpointer(void *, awesome_type_t);
|
||||||
|
|
Loading…
Reference in New Issue