Removed Console module from dfusion.

develop
Warmist 2012-07-18 21:07:27 +03:00
parent aee15db75f
commit 9f53f6296d
6 changed files with 5 additions and 156 deletions

@ -1,5 +1,4 @@
#include "Core.h" #include "Core.h"
#include "Console.h"
#include "Export.h" #include "Export.h"
#include "PluginManager.h" #include "PluginManager.h"
#include "MemAccess.h" #include "MemAccess.h"
@ -12,7 +11,6 @@
#include "luamain.h" #include "luamain.h"
#include "lua_Console.h"
#include "lua_Process.h" #include "lua_Process.h"
#include "lua_Hexsearch.h" #include "lua_Hexsearch.h"
#include "lua_Misc.h" #include "lua_Misc.h"
@ -50,7 +48,6 @@ DFhackCExport command_result plugin_init (color_ostream &out, std::vector <Plugi
//maybe remake it to run automaticaly //maybe remake it to run automaticaly
Lua::Open(out, st); Lua::Open(out, st);
lua::RegisterConsole(st);
lua::RegisterProcess(st); lua::RegisterProcess(st);
lua::RegisterHexsearch(st); lua::RegisterHexsearch(st);
lua::RegisterMisc(st); lua::RegisterMisc(st);

@ -1,13 +0,0 @@
#ifndef LUA_CONSOLE_H
#define LUA_CONSOLE_H
#include <Console.h>
#include "luamain.h"
namespace lua
{
void RegisterConsole(lua::state &st);
}
#endif

@ -8,7 +8,7 @@ DOUBLE=5
FLOAT=6 FLOAT=6
getline=function (inp) getline=function (inp)
return Console.lineedit(inp or "") return dfhack.lineedit(inp or "")
end end
io.stdin=nil io.stdin=nil

@ -127,7 +127,7 @@ function EditDF()
tbl[i]={k,getTypename(v)} tbl[i]={k,getTypename(v)}
i=i+1 i=i+1
end end
number=Console.lineedit("select item to edit (q to quit):") number=dfhack.lineedit("select item to edit (q to quit):")
if number and tonumber(number) then if number and tonumber(number) then
local entry=tbl[tonumber(number)] local entry=tbl[tonumber(number)]
if entry==nil then if entry==nil then

@ -1,7 +1,3 @@
Console.print = dfhack.print
Console.println = dfhack.println
Console.printerr = dfhack.printerr
function err(msg) --make local maybe... function err(msg) --make local maybe...
print(msg) print(msg)
print(debug.traceback()) print(debug.traceback())
@ -30,13 +26,13 @@ function loadall(t1) --loads all non interactive plugin parts, so that later the
end end
end end
function mainmenu(t1) function mainmenu(t1)
--Console.clear()
while true do while true do
print("No. Name Desc") print("No. Name Desc")
for k,v in pairs(t1) do for k,v in pairs(t1) do
print(string.format("%3d %15s %s",k,v[1],v[2])) print(string.format("%3d %15s %s",k,v[1],v[2]))
end end
local q=Console.lineedit("Select plugin to run (q to quit):") local q=dfhack.lineedit("Select plugin to run (q to quit):")
if q=='q' then return end if q=='q' then return end
q=tonumber(q) q=tonumber(q)
if q~=nil then if q~=nil then
@ -92,7 +88,7 @@ local f,err=load(table.concat(args,' '))
if f then if f then
f() f()
else else
Console.printerr(err) dfhack.printerr(err)
end end
if not INIT then if not INIT then

@ -1,131 +0,0 @@
#include "LuaTools.h"
#include "lua_Console.h"
#include <sstream>
//TODO error management. Using lua error? or something other?
static DFHack::color_ostream* GetConsolePtr(lua::state &st)
{
return DFHack::Lua::GetOutput(st);
}
static int lua_Console_clear(lua_State *S)
{
lua::state st(S);
DFHack::color_ostream* c=GetConsolePtr(st);
c->clear();
return 0;
}
static int lua_Console_gotoxy(lua_State *S)
{
lua::state st(S);
DFHack::color_ostream* c=GetConsolePtr(st);
if(c->is_console())
{
DFHack::Console* con=static_cast<DFHack::Console*>(c);
con->gotoxy(st.as<int>(1,1),st.as<int>(1,2));
}
return 0;
}
static int lua_Console_color(lua_State *S)
{
lua::state st(S);
DFHack::color_ostream* c=GetConsolePtr(st);
c->color( static_cast<DFHack::Console::color_value>(st.as<int>(-1,1)) );
return 0;
}
static int lua_Console_reset_color(lua_State *S)
{
lua::state st(S);
DFHack::color_ostream* c=GetConsolePtr(st);
c->reset_color();
return 0;
}
static int lua_Console_cursor(lua_State *S)
{
lua::state st(S);
DFHack::color_ostream* c=GetConsolePtr(st);
if(c->is_console())
{
DFHack::Console* con=static_cast<DFHack::Console*>(c);
con->cursor(st.as<bool>(1));
}
return 0;
}
static int lua_Console_msleep(lua_State *S)
{
lua::state st(S);
DFHack::color_ostream* c=GetConsolePtr(st);
if(c->is_console())
{
DFHack::Console* con=static_cast<DFHack::Console*>(c);
con->msleep(st.as<unsigned>(1));
}
return 0;
}
static int lua_Console_get_columns(lua_State *S)
{
lua::state st(S);
DFHack::color_ostream* c=GetConsolePtr(st);
if(c->is_console())
{
DFHack::Console* con=static_cast<DFHack::Console*>(c);
st.push(con->get_columns());
}
return 1;
}
static int lua_Console_get_rows(lua_State *S)
{
lua::state st(S);
DFHack::color_ostream* c=GetConsolePtr(st);
if(c->is_console())
{
DFHack::Console* con=static_cast<DFHack::Console*>(c);
st.push(con->get_rows());
}
return 1;
}
static int lua_Console_lineedit(lua_State *S)
{
lua::state st(S);
DFHack::color_ostream* c=GetConsolePtr(st);
if(c->is_console())
{
DFHack::Console* con=static_cast<DFHack::Console*>(c);
string ret;
DFHack::CommandHistory hist;
int i=con->lineedit(st.as<string>(1),ret,hist);
st.push(ret);
st.push(i);
return 2;// dunno if len is needed...
}
else
return 0;
}
const luaL_Reg lua_console_func[]=
{
{"clear",lua_Console_clear},
{"gotoxy",lua_Console_gotoxy},
{"color",lua_Console_color},
{"reset_color",lua_Console_reset_color},
{"cursor",lua_Console_cursor},
{"msleep",lua_Console_msleep},
{"get_columns",lua_Console_get_columns},
{"get_rows",lua_Console_get_rows},
{"lineedit",lua_Console_lineedit},
{NULL,NULL}
};
void lua::RegisterConsole(lua::state &st)
{
st.getglobal("Console");
if(st.is<lua::nil>())
{
st.pop();
st.newtable();
}
lua::RegFunctionsLocal(st, lua_console_func);
//TODO add color consts
st.setglobal("Console");
}