5 #include "lua/interface.h"
7 #include "module_awful-luatest.h"
10 #include "lua/lauxlib.h"
11 #include "lua/lualib.h"
12 #include "lua/luaconf.h"
15 using namespace luatestapp
;
17 LuaTestApp::LuaTestApp() throw( std::runtime_error
)
19 awful::LuaSetup
< awful::luatest::awful_tag
>();
21 luaL_openlibs( awful::LuaState::GetInstance()->get() );
24 LuaTestApp::~LuaTestApp()
28 void LuaTestApp::run()
30 //cout << "I see." << endl;
33 awful::LuaState
* pState
= awful::LuaState::GetInstance();
34 lua_State
* pLS
= pState
->get();
39 char* pCmdLine
= buffer
;
41 if( lua_readline( pLS
, pCmdLine
, "> " ) )
43 lua_pushstring( pLS
, pCmdLine
);
44 lua_saveline( pLS
, -1 );
45 lua_remove( pLS
, -1 );
47 if( !strcmp( pCmdLine
, "q" ) )
51 if( !luaL_loadstring( pLS
, pCmdLine
) )
53 switch( lua_pcall( pLS
, 0, 0, 0 ) )
57 const char* pErrMsg
= lua_tostring( pLS
, -1 );
58 std::cerr
<< pErrMsg
<< std::endl
;
63 std::cerr
<< "LUA_ERRMEM" << std::endl
;
67 std::cerr
<< "LUA_ERRERR" << std::endl
;
72 cerr
<< "Syntax error" << endl
;
75 lua_freeline( pState
->get(), pCmdLine
);
78 lua_settop( pState
->get(), 0 );