some debug for lua that got me to where I don't think I need lua.
- thanks to debugging and seeing variables internally
This commit is contained in:
parent
f164ada948
commit
2da61079de
2 changed files with 26 additions and 2 deletions
|
|
@ -1,9 +1,9 @@
|
||||||
-- Lua test file
|
-- Lua test file
|
||||||
|
|
||||||
function ithecolors( c )
|
function ithecolors( c )
|
||||||
a = 5
|
|
||||||
b = 7
|
|
||||||
io.write("some shit from lua\n")
|
io.write("some shit from lua\n")
|
||||||
|
-- io.write(c)
|
||||||
|
io.write("\n")
|
||||||
end
|
end
|
||||||
|
|
||||||
ithecolors()
|
ithecolors()
|
||||||
|
|
|
||||||
24
st.c
24
st.c
|
|
@ -589,6 +589,11 @@ int dothatLua(void) {
|
||||||
luaL_openlibs(L); /* Load Lua libraries */
|
luaL_openlibs(L); /* Load Lua libraries */
|
||||||
if (luaL_loadfile(L, "color.lua")) /* Load but don't run the Lua script */
|
if (luaL_loadfile(L, "color.lua")) /* Load but don't run the Lua script */
|
||||||
bail(L, "luaL_loadfile() failed"); /* Error out if file can't be read */
|
bail(L, "luaL_loadfile() failed"); /* Error out if file can't be read */
|
||||||
|
|
||||||
|
// for (int i = 0; i < sizeof(colorname); ++i) {
|
||||||
|
// lua_pushstring(L,colorname[i]);
|
||||||
|
// }
|
||||||
|
|
||||||
printf("In C, calling Lua\n");
|
printf("In C, calling Lua\n");
|
||||||
if (lua_pcall(L, 0, 0, 0)) /* Run the loaded Lua script */
|
if (lua_pcall(L, 0, 0, 0)) /* Run the loaded Lua script */
|
||||||
bail(L, "lua_pcall() failed"); /* Error out if Lua file has an error */
|
bail(L, "lua_pcall() failed"); /* Error out if Lua file has an error */
|
||||||
|
|
@ -597,6 +602,24 @@ int dothatLua(void) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int luaInterpreter(void) {
|
||||||
|
char buff[256];
|
||||||
|
int error;
|
||||||
|
lua_State *L = luaL_newstate(); /* opens Lua */
|
||||||
|
luaL_openlibs(L); /* opens the standard libraries */
|
||||||
|
|
||||||
|
while (fgets(buff, sizeof(buff), stdin) != NULL) {
|
||||||
|
error = luaL_loadstring(L, buff) || lua_pcall(L, 0, 0, 0);
|
||||||
|
if (error) {
|
||||||
|
fprintf(stderr, "%s\n", lua_tostring(L, -1));
|
||||||
|
lua_pop(L, 1); /* pop error message from the stack */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
lua_close(L);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
ssize_t
|
ssize_t
|
||||||
xwrite(int fd, const char *s, size_t len)
|
xwrite(int fd, const char *s, size_t len)
|
||||||
|
|
@ -4529,6 +4552,7 @@ run:
|
||||||
opt_title = basename(xstrdup(argv[0]));
|
opt_title = basename(xstrdup(argv[0]));
|
||||||
}
|
}
|
||||||
dothatLua();
|
dothatLua();
|
||||||
|
// luaInterpreter();
|
||||||
setlocale(LC_CTYPE, "");
|
setlocale(LC_CTYPE, "");
|
||||||
XSetLocaleModifiers("");
|
XSetLocaleModifiers("");
|
||||||
tnew(MAX(cols, 1), MAX(rows, 1));
|
tnew(MAX(cols, 1), MAX(rows, 1));
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue