mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-neutrino.git
synced 2025-08-27 07:22:57 +02:00
lua: add stand-alone stringinput; set lua api version to 1.56
Origin commit data
------------------
Commit: 0fa4486077
Author: vanhofen <vanhofen@gmx.de>
Date: 2016-09-05 (Mon, 05 Sep 2016)
Origin message was:
------------------
- lua: add stand-alone stringinput; set lua api version to 1.56
This commit is contained in:
@@ -37,6 +37,7 @@ libneutrino_gui_lua_a_SOURCES = \
|
|||||||
lua_menue.cpp \
|
lua_menue.cpp \
|
||||||
lua_messagebox.cpp \
|
lua_messagebox.cpp \
|
||||||
lua_misc.cpp \
|
lua_misc.cpp \
|
||||||
|
lua_stringinput.cpp \
|
||||||
lua_threads.cpp \
|
lua_threads.cpp \
|
||||||
lua_threads_copy.cpp \
|
lua_threads_copy.cpp \
|
||||||
lua_threads_functions.cpp \
|
lua_threads_functions.cpp \
|
||||||
|
@@ -4,4 +4,4 @@
|
|||||||
* to luainstance.h changes
|
* to luainstance.h changes
|
||||||
*/
|
*/
|
||||||
#define LUA_API_VERSION_MAJOR 1
|
#define LUA_API_VERSION_MAJOR 1
|
||||||
#define LUA_API_VERSION_MINOR 55
|
#define LUA_API_VERSION_MINOR 56
|
||||||
|
106
src/gui/lua/lua_stringinput.cpp
Normal file
106
src/gui/lua/lua_stringinput.cpp
Normal file
@@ -0,0 +1,106 @@
|
|||||||
|
/*
|
||||||
|
* lua stringinput
|
||||||
|
*
|
||||||
|
* (C) 2016 Sven Hoefer (svenhoefer)
|
||||||
|
* (C) 2016 M. Liebmann (micha-bbg)
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <config.h>
|
||||||
|
#include <cstdio>
|
||||||
|
#include <cstdlib>
|
||||||
|
#include <cstring>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include <global.h>
|
||||||
|
#include <system/debug.h>
|
||||||
|
#include <gui/widget/stringinput.h>
|
||||||
|
#include <neutrino.h>
|
||||||
|
|
||||||
|
#include "luainstance.h"
|
||||||
|
#include "lua_stringinput.h"
|
||||||
|
|
||||||
|
CLuaInstStringInput* CLuaInstStringInput::getInstance()
|
||||||
|
{
|
||||||
|
static CLuaInstStringInput* LuaInstStringInput = NULL;
|
||||||
|
|
||||||
|
if (!LuaInstStringInput)
|
||||||
|
LuaInstStringInput = new CLuaInstStringInput();
|
||||||
|
return LuaInstStringInput;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CLuaInstStringInput::StringInputRegister(lua_State *L)
|
||||||
|
{
|
||||||
|
luaL_Reg meth[] = {
|
||||||
|
{ "exec", CLuaInstStringInput::StringInputExec },
|
||||||
|
{ NULL, NULL }
|
||||||
|
};
|
||||||
|
|
||||||
|
luaL_newmetatable(L, "stringinput");
|
||||||
|
luaL_setfuncs(L, meth, 0);
|
||||||
|
lua_pushvalue(L, -1);
|
||||||
|
lua_setfield(L, -1, "__index");
|
||||||
|
lua_setglobal(L, "stringinput");
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
local return_value = stringinput.exec{
|
||||||
|
caption="Title",
|
||||||
|
value="value",
|
||||||
|
icon="settings",
|
||||||
|
valid_chars="0123456789",
|
||||||
|
size=4
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
int CLuaInstStringInput::StringInputExec(lua_State *L)
|
||||||
|
{
|
||||||
|
lua_assert(lua_istable(L,1));
|
||||||
|
|
||||||
|
std::string name;
|
||||||
|
tableLookup(L, "name", name) || tableLookup(L, "title", name) || tableLookup(L, "caption", name);
|
||||||
|
|
||||||
|
std::string value;
|
||||||
|
tableLookup(L, "value", value);
|
||||||
|
|
||||||
|
lua_Integer size = 30;
|
||||||
|
tableLookup(L, "size", size);
|
||||||
|
|
||||||
|
// TODO: Locales?
|
||||||
|
|
||||||
|
std::string valid_chars = "abcdefghijklmnopqrstuvwxyz0123456789!\"<EFBFBD>$%&/()=?-.@,_: ";
|
||||||
|
tableLookup(L, "valid_chars", valid_chars);
|
||||||
|
|
||||||
|
// TODO: CChangeObserver?
|
||||||
|
|
||||||
|
std::string icon = std::string(NEUTRINO_ICON_INFO);
|
||||||
|
tableLookup(L, "icon", icon);
|
||||||
|
|
||||||
|
lua_Integer sms = 0;
|
||||||
|
tableLookup(L, "sms", sms);
|
||||||
|
|
||||||
|
CStringInput *i;
|
||||||
|
if (sms)
|
||||||
|
i = new CStringInputSMS(name, &value, size,
|
||||||
|
NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, valid_chars.c_str(), NULL, icon.c_str());
|
||||||
|
else
|
||||||
|
i = new CStringInput(name, &value, size,
|
||||||
|
NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, valid_chars.c_str(), NULL, icon.c_str());
|
||||||
|
i->exec(NULL, "");
|
||||||
|
delete i;
|
||||||
|
|
||||||
|
lua_pushstring(L, value.c_str());
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
44
src/gui/lua/lua_stringinput.h
Normal file
44
src/gui/lua/lua_stringinput.h
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
/*
|
||||||
|
* lua stringinput
|
||||||
|
*
|
||||||
|
* (C) 2016 Sven Hoefer (svenhoefer)
|
||||||
|
* (C) 2016 M. Liebmann (micha-bbg)
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _LUASTRINGINPUT_H
|
||||||
|
#define _LUASTRINGINPUT_H
|
||||||
|
|
||||||
|
class CLuaStringInput
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CStringInput *b;
|
||||||
|
CLuaStringInput();
|
||||||
|
~CLuaStringInput();
|
||||||
|
};
|
||||||
|
|
||||||
|
class CLuaInstStringInput
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CLuaInstStringInput() {};
|
||||||
|
~CLuaInstStringInput() {};
|
||||||
|
static CLuaInstStringInput* getInstance();
|
||||||
|
static void StringInputRegister(lua_State *L);
|
||||||
|
|
||||||
|
private:
|
||||||
|
static int StringInputExec(lua_State *L);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //_LUASTRINGINPUT_H
|
@@ -49,6 +49,7 @@
|
|||||||
#include "lua_menue.h"
|
#include "lua_menue.h"
|
||||||
#include "lua_messagebox.h"
|
#include "lua_messagebox.h"
|
||||||
#include "lua_misc.h"
|
#include "lua_misc.h"
|
||||||
|
#include "lua_stringinput.h"
|
||||||
#include "lua_threads.h"
|
#include "lua_threads.h"
|
||||||
#include "lua_video.h"
|
#include "lua_video.h"
|
||||||
|
|
||||||
@@ -626,6 +627,7 @@ void LuaInstRegisterFunctions(lua_State *L, bool fromThreads/*=false*/)
|
|||||||
CLuaInstHintbox::getInstance()->HintboxRegister(L);
|
CLuaInstHintbox::getInstance()->HintboxRegister(L);
|
||||||
CLuaInstMenu::getInstance()->MenuRegister(L);
|
CLuaInstMenu::getInstance()->MenuRegister(L);
|
||||||
CLuaInstMessagebox::getInstance()->MessageboxRegister(L);
|
CLuaInstMessagebox::getInstance()->MessageboxRegister(L);
|
||||||
|
CLuaInstStringInput::getInstance()->StringInputRegister(L);
|
||||||
CLuaInstMisc::getInstance()->LuaMiscRegister(L);
|
CLuaInstMisc::getInstance()->LuaMiscRegister(L);
|
||||||
CLuaInstVideo::getInstance()->LuaVideoRegister(L);
|
CLuaInstVideo::getInstance()->LuaVideoRegister(L);
|
||||||
if (!fromThreads)
|
if (!fromThreads)
|
||||||
|
Reference in New Issue
Block a user