boxmein: Added clipboard support to Lua

This commit is contained in:
jacob1 2014-01-29 17:57:10 -05:00
parent cf503a29f4
commit 5b886fc51e
3 changed files with 20 additions and 0 deletions

View File

@ -9,6 +9,7 @@
#include "Format.h"
#include "LuaScriptInterface.h"
#include "LuaScriptHelper.h"
#include "PowderToy.h"
#include "gui/dialogues/ErrorMessage.h"
#include "gui/dialogues/InformationMessage.h"
@ -2053,4 +2054,18 @@ int luatpt_screenshot(lua_State* l)
lua_pushstring(l, filename.str().c_str());
return 1;
}
int luatpt_getclip (lua_State* l)
{
lua_pushstring(l, ClipboardPull());
return 1;
}
int luatpt_setclip (lua_State* l)
{
luaL_checktype(l, 1, LUA_TSTRING);
ClipboardPush((char*) std::string(luaL_optstring(l, 1, "")).c_str());
return 0;
}
#endif

View File

@ -129,5 +129,8 @@ int luatpt_getscript(lua_State* l);
int luatpt_setwindowsize(lua_State* l);
int luatpt_screenshot(lua_State* l);
int luatpt_getclip(lua_State* l);
int luatpt_setclip(lua_State* l);
#endif /* LUASCRIPTHELPER_H_ */

View File

@ -188,6 +188,8 @@ LuaScriptInterface::LuaScriptInterface(GameController * c, GameModel * m):
{"element",&luatpt_getelement},
{"element_func",&luatpt_element_func},
{"graphics_func",&luatpt_graphics_func},
{"get_clipboard", &luatpt_getclip},
{"set_clipboard", &luatpt_setclip},
{NULL,NULL}
};