diff options
| author | Warmist | 2012-07-18 21:07:27 +0300 |
|---|---|---|
| committer | Warmist | 2012-07-18 21:07:27 +0300 |
| commit | 9f53f6296d77db6dace5a9d429b621513b0fe106 (patch) | |
| tree | 3dc5820e9067db194be77e41ef6a264d5e6f4175 /plugins/Dfusion | |
| parent | aee15db75fdb4cb812788e13db4c83da6672d951 (diff) | |
| download | dfhack-9f53f6296d77db6dace5a9d429b621513b0fe106.tar.gz dfhack-9f53f6296d77db6dace5a9d429b621513b0fe106.tar.bz2 dfhack-9f53f6296d77db6dace5a9d429b621513b0fe106.tar.xz | |
Removed Console module from dfusion.
Diffstat (limited to 'plugins/Dfusion')
| -rw-r--r-- | plugins/Dfusion/dfusion.cpp | 3 | ||||
| -rw-r--r-- | plugins/Dfusion/include/lua_Console.h | 13 | ||||
| -rw-r--r-- | plugins/Dfusion/luafiles/common.lua | 2 | ||||
| -rw-r--r-- | plugins/Dfusion/luafiles/editor.lua | 2 | ||||
| -rw-r--r-- | plugins/Dfusion/luafiles/init.lua | 10 | ||||
| -rw-r--r-- | plugins/Dfusion/src/lua_Console.cpp | 131 |
6 files changed, 5 insertions, 156 deletions
diff --git a/plugins/Dfusion/dfusion.cpp b/plugins/Dfusion/dfusion.cpp index 2b36a974..78c3fa8d 100644 --- a/plugins/Dfusion/dfusion.cpp +++ b/plugins/Dfusion/dfusion.cpp @@ -1,5 +1,4 @@ #include "Core.h" -#include "Console.h" #include "Export.h" #include "PluginManager.h" #include "MemAccess.h" @@ -12,7 +11,6 @@ #include "luamain.h" -#include "lua_Console.h" #include "lua_Process.h" #include "lua_Hexsearch.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 Lua::Open(out, st); - lua::RegisterConsole(st); lua::RegisterProcess(st); lua::RegisterHexsearch(st); lua::RegisterMisc(st); diff --git a/plugins/Dfusion/include/lua_Console.h b/plugins/Dfusion/include/lua_Console.h deleted file mode 100644 index c6ac5011..00000000 --- a/plugins/Dfusion/include/lua_Console.h +++ /dev/null @@ -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
\ No newline at end of file diff --git a/plugins/Dfusion/luafiles/common.lua b/plugins/Dfusion/luafiles/common.lua index 752d07cf..7e621c4e 100644 --- a/plugins/Dfusion/luafiles/common.lua +++ b/plugins/Dfusion/luafiles/common.lua @@ -8,7 +8,7 @@ DOUBLE=5 FLOAT=6 getline=function (inp) -return Console.lineedit(inp or "") +return dfhack.lineedit(inp or "") end io.stdin=nil diff --git a/plugins/Dfusion/luafiles/editor.lua b/plugins/Dfusion/luafiles/editor.lua index 1f004b2d..06b07ce5 100644 --- a/plugins/Dfusion/luafiles/editor.lua +++ b/plugins/Dfusion/luafiles/editor.lua @@ -127,7 +127,7 @@ function EditDF() tbl[i]={k,getTypename(v)} i=i+1 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 local entry=tbl[tonumber(number)] if entry==nil then diff --git a/plugins/Dfusion/luafiles/init.lua b/plugins/Dfusion/luafiles/init.lua index 6fa86d7a..19f63d60 100644 --- a/plugins/Dfusion/luafiles/init.lua +++ b/plugins/Dfusion/luafiles/init.lua @@ -1,7 +1,3 @@ -Console.print = dfhack.print -Console.println = dfhack.println -Console.printerr = dfhack.printerr - function err(msg) --make local maybe... print(msg) print(debug.traceback()) @@ -30,13 +26,13 @@ function loadall(t1) --loads all non interactive plugin parts, so that later the end end function mainmenu(t1) - --Console.clear() + while true do print("No. Name Desc") for k,v in pairs(t1) do print(string.format("%3d %15s %s",k,v[1],v[2])) 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 q=tonumber(q) if q~=nil then @@ -92,7 +88,7 @@ local f,err=load(table.concat(args,' ')) if f then f() else - Console.printerr(err) + dfhack.printerr(err) end if not INIT then diff --git a/plugins/Dfusion/src/lua_Console.cpp b/plugins/Dfusion/src/lua_Console.cpp deleted file mode 100644 index 1d52d615..00000000 --- a/plugins/Dfusion/src/lua_Console.cpp +++ /dev/null @@ -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"); -} |
