Extract the color enum from color_ostream to toplevel.

develop
Alexander Gavrilov 2012-08-19 09:21:25 +04:00
parent 8ed219d4e0
commit fd0bf2ef92
11 changed files with 46 additions and 44 deletions

@ -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);
}

@ -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);
}

@ -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 )

@ -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();
}

@ -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);

@ -41,9 +41,6 @@ namespace dfproto
namespace DFHack
{
class DFHACK_EXPORT color_ostream : public std::ostream
{
public:
enum color_value
{
COLOR_RESET = -1,
@ -66,6 +63,11 @@ namespace DFHack
COLOR_MAX = COLOR_WHITE
};
class DFHACK_EXPORT color_ostream : public std::ostream
{
public:
typedef DFHack::color_value color_value;
private:
color_value cur_color;

@ -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) << ")";

@ -462,7 +462,7 @@ void joinCounts(std::map<df::coord, int> &counts)
static void printCompanionHeader(color_ostream &out, size_t i, df::unit *unit)
{
out.color(Console::COLOR_GREY);
out.color(COLOR_GREY);
if (i < 28)
out << char('a'+i);

@ -257,7 +257,7 @@ command_result kittens (color_ostream &out, vector <string> & parameters)
};
con.cursor(false);
con.clear();
Console::color_value color = Console::COLOR_BLUE;
Console::color_value color = COLOR_BLUE;
while(1)
{
if(shutdown_flag)
@ -282,7 +282,7 @@ command_result kittens (color_ostream &out, vector <string> & parameters)
con.flush();
con.msleep(60);
((int&)color) ++;
if(color > Console::COLOR_MAX)
color = Console::COLOR_BLUE;
if(color > COLOR_MAX)
color = COLOR_BLUE;
}
}

@ -73,7 +73,7 @@ void outputHex(uint8_t *buf,uint8_t *lbuf,size_t len,size_t start,color_ostream
con.reset_color();
if(isAddr((uint32_t *)(buf+j+i),ranges))
con.color(Console::COLOR_LIGHTRED); //coloring in the middle does not work
con.color(COLOR_LIGHTRED); //coloring in the middle does not work
//TODO make something better?
}
if(lbuf[j+i]!=buf[j+i])

@ -1380,15 +1380,15 @@ static void print_constraint(color_ostream &out, ItemConstraint *cv, bool no_job
{
Console::color_value color;
if (cv->request_resume)
color = Console::COLOR_GREEN;
color = COLOR_GREEN;
else if (cv->request_suspend)
color = Console::COLOR_CYAN;
color = COLOR_CYAN;
else
color = Console::COLOR_DARKGREY;
color = COLOR_DARKGREY;
out.color(color);
out << prefix << "Constraint " << flush;
out.color(Console::COLOR_GREY);
out.color(COLOR_GREY);
out << cv->config.val() << " " << flush;
out.color(color);
out << (cv->goalByCount() ? "count " : "amount ")
@ -1437,18 +1437,18 @@ static void print_constraint(color_ostream &out, ItemConstraint *cv, bool no_job
{
if (pj->want_resumed)
{
out.color(Console::COLOR_YELLOW);
out.color(COLOR_YELLOW);
out << start << " (delayed)" << endl;
}
else
{
out.color(Console::COLOR_BLUE);
out.color(COLOR_BLUE);
out << start << " (suspended)" << endl;
}
}
else
{
out.color(Console::COLOR_GREEN);
out.color(COLOR_GREEN);
out << start << endl;
}
@ -1472,11 +1472,11 @@ static void print_job(color_ostream &out, ProtectedJob *pj)
isOptionEnabled(CF_AUTOMELT))
{
if (meltable_count <= 0)
out.color(Console::COLOR_CYAN);
out.color(COLOR_CYAN);
else if (pj->want_resumed && !pj->isActuallyResumed())
out.color(Console::COLOR_YELLOW);
out.color(COLOR_YELLOW);
else
out.color(Console::COLOR_GREEN);
out.color(COLOR_GREEN);
out << " Meltable: " << meltable_count << " objects." << endl;
out.reset_color();
}