diff options
| author | Alexander Gavrilov | 2012-08-19 09:21:25 +0400 |
|---|---|---|
| committer | Alexander Gavrilov | 2012-08-19 09:21:25 +0400 |
| commit | fd0bf2ef929d3bc98570012b21e6e603c570a8f6 (patch) | |
| tree | e6339698fa55793c6aa7899fe3e2a8a5f5afd9e0 /library | |
| parent | 8ed219d4e0cbea19c8a9489294a975b81946bba2 (diff) | |
| download | dfhack-fd0bf2ef929d3bc98570012b21e6e603c570a8f6.tar.gz dfhack-fd0bf2ef929d3bc98570012b21e6e603c570a8f6.tar.bz2 dfhack-fd0bf2ef929d3bc98570012b21e6e603c570a8f6.tar.xz | |
Extract the color enum from color_ostream to toplevel.
Diffstat (limited to 'library')
| -rw-r--r-- | library/Console-darwin.cpp | 2 | ||||
| -rw-r--r-- | library/Console-linux.cpp | 2 | ||||
| -rw-r--r-- | library/Console-windows.cpp | 2 | ||||
| -rw-r--r-- | library/Core.cpp | 6 | ||||
| -rw-r--r-- | library/LuaTools.cpp | 2 | ||||
| -rw-r--r-- | library/include/ColorText.h | 44 | ||||
| -rw-r--r-- | library/modules/Job.cpp | 2 |
7 files changed, 31 insertions, 29 deletions
diff --git a/library/Console-darwin.cpp b/library/Console-darwin.cpp index c547f841..86cd657a 100644 --- a/library/Console-darwin.cpp +++ b/library/Console-darwin.cpp @@ -275,7 +275,7 @@ namespace DFHack /// Reset color to default void reset_color(void) { - color(Console::COLOR_RESET); + color(COLOR_RESET); if(!rawmode) fflush(dfout_C); } diff --git a/library/Console-linux.cpp b/library/Console-linux.cpp index 882d9527..f32fa1c2 100644 --- a/library/Console-linux.cpp +++ b/library/Console-linux.cpp @@ -277,7 +277,7 @@ namespace DFHack /// Reset color to default void reset_color(void) { - color(Console::COLOR_RESET); + color(COLOR_RESET); if(!rawmode) fflush(dfout_C); } diff --git a/library/Console-windows.cpp b/library/Console-windows.cpp index d4d47303..f0cdda38 100644 --- a/library/Console-windows.cpp +++ b/library/Console-windows.cpp @@ -179,7 +179,7 @@ namespace DFHack void color(int index) { HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE); - SetConsoleTextAttribute(hConsole, index == color_ostream::COLOR_RESET ? default_attributes : index); + SetConsoleTextAttribute(hConsole, index == COLOR_RESET ? default_attributes : index); } void reset_color( void ) diff --git a/library/Core.cpp b/library/Core.cpp index bf0b3be7..71c92afe 100644 --- a/library/Core.cpp +++ b/library/Core.cpp @@ -358,7 +358,7 @@ command_result Core::runCommand(color_ostream &con, const std::string &first, ve continue; if (pcmd.isHotkeyCommand()) - con.color(Console::COLOR_CYAN); + con.color(COLOR_CYAN); con.print("%s: %s\n",pcmd.name.c_str(), pcmd.description.c_str()); con.reset_color(); if (!pcmd.usage.empty()) @@ -481,7 +481,7 @@ command_result Core::runCommand(color_ostream &con, const std::string &first, ve { const PluginCommand & pcmd = (plug->operator[](j)); if (pcmd.isHotkeyCommand()) - con.color(Console::COLOR_CYAN); + con.color(COLOR_CYAN); con.print(" %-22s - %s\n",pcmd.name.c_str(), pcmd.description.c_str()); con.reset_color(); } @@ -519,7 +519,7 @@ command_result Core::runCommand(color_ostream &con, const std::string &first, ve for(auto iter = out.begin();iter != out.end();iter++) { if ((*iter).recolor) - con.color(Console::COLOR_CYAN); + con.color(COLOR_CYAN); con.print(" %-22s- %s\n",(*iter).name.c_str(), (*iter).description.c_str()); con.reset_color(); } diff --git a/library/LuaTools.cpp b/library/LuaTools.cpp index 28571a0f..75dfe23f 100644 --- a/library/LuaTools.cpp +++ b/library/LuaTools.cpp @@ -252,7 +252,7 @@ static int lua_dfhack_color(lua_State *S) { int cv = luaL_optint(S, 1, -1); - if (cv < -1 || cv > color_ostream::COLOR_MAX) + if (cv < -1 || cv > COLOR_MAX) luaL_argerror(S, 1, "invalid color value"); color_ostream *out = Lua::GetOutput(S); diff --git a/library/include/ColorText.h b/library/include/ColorText.h index 0cc286dc..50d1f362 100644 --- a/library/include/ColorText.h +++ b/library/include/ColorText.h @@ -41,30 +41,32 @@ namespace dfproto namespace DFHack { + enum color_value + { + COLOR_RESET = -1, + COLOR_BLACK = 0, + COLOR_BLUE, + COLOR_GREEN, + COLOR_CYAN, + COLOR_RED, + COLOR_MAGENTA, + COLOR_BROWN, + COLOR_GREY, + COLOR_DARKGREY, + COLOR_LIGHTBLUE, + COLOR_LIGHTGREEN, + COLOR_LIGHTCYAN, + COLOR_LIGHTRED, + COLOR_LIGHTMAGENTA, + COLOR_YELLOW, + COLOR_WHITE, + COLOR_MAX = COLOR_WHITE + }; + class DFHACK_EXPORT color_ostream : public std::ostream { public: - enum color_value - { - COLOR_RESET = -1, - COLOR_BLACK = 0, - COLOR_BLUE, - COLOR_GREEN, - COLOR_CYAN, - COLOR_RED, - COLOR_MAGENTA, - COLOR_BROWN, - COLOR_GREY, - COLOR_DARKGREY, - COLOR_LIGHTBLUE, - COLOR_LIGHTGREEN, - COLOR_LIGHTCYAN, - COLOR_LIGHTRED, - COLOR_LIGHTMAGENTA, - COLOR_YELLOW, - COLOR_WHITE, - COLOR_MAX = COLOR_WHITE - }; + typedef DFHack::color_value color_value; private: color_value cur_color; diff --git a/library/modules/Job.cpp b/library/modules/Job.cpp index 1207c97b..54b4eb27 100644 --- a/library/modules/Job.cpp +++ b/library/modules/Job.cpp @@ -189,7 +189,7 @@ void DFHack::Job::printJobDetails(color_ostream &out, df::job *job) { CHECK_NULL_POINTER(job); - out.color(job->flags.bits.suspend ? Console::COLOR_DARKGREY : Console::COLOR_GREY); + out.color(job->flags.bits.suspend ? COLOR_DARKGREY : COLOR_GREY); out << "Job " << job->id << ": " << ENUM_KEY_STR(job_type,job->job_type); if (job->flags.whole) out << " (" << bitfield_to_string(job->flags) << ")"; |
