当前位置: 首页>>代码示例>>C++>>正文


C++ color_ostream::color方法代码示例

本文整理汇总了C++中color_ostream::color方法的典型用法代码示例。如果您正苦于以下问题:C++ color_ostream::color方法的具体用法?C++ color_ostream::color怎么用?C++ color_ostream::color使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在color_ostream的用法示例。


在下文中一共展示了color_ostream::color方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: print_job

static void print_job(color_ostream &out, ProtectedJob *pj)
{
    if (!pj)
        return;

    df::job *job = pj->isLive() ? pj->actual_job : pj->job_copy;

    Job::printJobDetails(out, job);

    if (job->job_type == job_type::MeltMetalObject &&
        isOptionEnabled(CF_AUTOMELT))
    {
        if (meltable_count <= 0)
            out.color(COLOR_CYAN);
        else if (pj->want_resumed && !pj->isActuallyResumed())
            out.color(COLOR_YELLOW);
        else
            out.color(COLOR_GREEN);
        out << "  Meltable: " << meltable_count << " objects." << endl;
        out.reset_color();
    }

    for (size_t i = 0; i < pj->constraints.size(); i++)
        print_constraint(out, pj->constraints[i], true, "  ");
}
开发者ID:Reag,项目名称:dfhack,代码行数:25,代码来源:workflow.cpp

示例2: plugin_init

DFhackCExport command_result plugin_init(color_ostream &out, vector <PluginCommand> &commands)
{
    auto dflags = init->display.flag;
    if (dflags.is_set(init_display_flags::TEXT)) {
        out.color(COLOR_RED);
        out << "Error: For Webfort, PRINT_MODE needs to not be TEXT" << std::endl;
        out.color(COLOR_RESET);
        return CR_OK;
    }
    s_hdl = new WFServer(out);

    hook();

    return CR_OK;
}
开发者ID:Ankoku,项目名称:df-webfort,代码行数:15,代码来源:webfort.cpp

示例3: outputHex

void outputHex(uint8_t *buf,uint8_t *lbuf,size_t len,size_t start,color_ostream &con,vector<t_memrange> & ranges)
{
    const size_t page_size=16;

    for(size_t i=0;i<len;i+=page_size)
    {
        //con.gotoxy(1,i/page_size+1);
        con.print("0x%08X ",i+start);
        for(size_t j=0;(j<page_size) && (i+j<len);j++)
            {
                if(j%4==0)
                {
                    con.reset_color();

                    if(isAddr((uint32_t *)(buf+j+i),ranges))
                        con.color(COLOR_LIGHTRED); //coloring in the middle does not work
                    //TODO make something better?
                }
                if(lbuf[j+i]!=buf[j+i])
                    con.print("*%02X",buf[j+i]); //if modfied show a star
                else
                    con.print(" %02X",buf[j+i]);
            }
        con.reset_color();
        con.print(" | ");
        for(size_t j=0;(j<page_size) && (i+j<len);j++)
            if((buf[j+i]>31)&&(buf[j+i]<128)) //only printable ascii
                con.print("%c",buf[j+i]);
            else
                con.print(".");
        //con.print("\n");
    }
    con.print("\n");
}
开发者ID:AlexanderStarr,项目名称:dfhack,代码行数:34,代码来源:memview.cpp

示例4: printCompanionHeader

static void printCompanionHeader(color_ostream &out, size_t i, df::unit *unit)
{
    out.color(COLOR_GREY);

    if (i < 28)
        out << char('a'+i);
    else
        out << i;

    out << ": " << getUnitNameProfession(unit);
    if (unit->flags1.bits.dead)
        out << " (DEAD)";
    if (unit->flags3.bits.ghostly)
        out << " (GHOST)";
    out << endl;

    out.reset_color();
}
开发者ID:AlexanderStarr,项目名称:dfhack,代码行数:18,代码来源:advtools.cpp

示例5: mat

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 << "Job " << job->id << ": " << ENUM_KEY_STR(job_type,job->job_type);
    if (job->flags.whole)
           out << " (" << bitfield_to_string(job->flags) << ")";
    out << endl;
    out.reset_color();

    df::item_type itype = ENUM_ATTR(job_type, item, job->job_type);

    MaterialInfo mat(job);
    if (itype == item_type::FOOD)
        mat.decode(-1);

    if (mat.isValid() || job->material_category.whole)
    {
        out << "    material: " << mat.toString();
        if (job->material_category.whole)
            out << " (" << bitfield_to_string(job->material_category) << ")";
        out << endl;
    }

    if (job->item_subtype >= 0 || job->item_category.whole)
    {
        ItemTypeInfo iinfo(itype, job->item_subtype);

        out << "    item: " << iinfo.toString()
               << " (" << bitfield_to_string(job->item_category) << ")" << endl;
    }

    if (job->hist_figure_id >= 0)
        out << "    figure: " << job->hist_figure_id << endl;

    if (!job->reaction_name.empty())
        out << "    reaction: " << job->reaction_name << endl;

    for (size_t i = 0; i < job->job_items.size(); i++)
        printItemDetails(out, job->job_items[i], i);
}
开发者ID:Elvang,项目名称:dfhack,代码行数:42,代码来源:Job.cpp

示例6: print_constraint

static void print_constraint(color_ostream &out, ItemConstraint *cv, bool no_job = false, std::string prefix = "")
{
    Console::color_value color;
    if (cv->request_resume)
        color = COLOR_GREEN;
    else if (cv->request_suspend)
        color = COLOR_CYAN;
    else
        color = COLOR_DARKGREY;

    out.color(color);
    out << prefix << "Constraint " << flush;
    out.color(COLOR_GREY);
    out << cv->config.val() << " " << flush;
    out.color(color);
    out << (cv->goalByCount() ? "count " : "amount ")
           << cv->goalCount() << " (gap " << cv->goalGap() << ")" << endl;
    out.reset_color();

    if (cv->item_count || cv->item_inuse)
        out << prefix << "  items: amount " << cv->item_amount << "; "
                         << cv->item_count << " stacks available, "
                         << cv->item_inuse << " in use." << endl;

    if (no_job) return;

    if (cv->jobs.empty())
        out.printerr("  (no jobs)\n");

    std::vector<ProtectedJob*> unique_jobs;
    std::vector<int> unique_counts;

    for (size_t i = 0; i < cv->jobs.size(); i++)
    {
        ProtectedJob *pj = cv->jobs[i];
        for (size_t j = 0; j < unique_jobs.size(); j++)
        {
            if (unique_jobs[j]->building_id == pj->building_id &&
                *unique_jobs[j]->actual_job == *pj->actual_job)
            {
                unique_counts[j]++;
                goto next_job;
            }
        }

        unique_jobs.push_back(pj);
        unique_counts.push_back(1);
    next_job:;
    }

    for (size_t i = 0; i < unique_jobs.size(); i++)
    {
        ProtectedJob *pj = unique_jobs[i];
        df::job *job = pj->actual_job;

        std::string start = prefix + "  " + shortJobDescription(job);

        if (!pj->isActuallyResumed())
        {
            if (pj->want_resumed)
            {
                out.color(COLOR_YELLOW);
                out << start << " (delayed)" << endl;
            }
            else
            {
                out.color(COLOR_BLUE);
                out << start << " (suspended)" << endl;
            }
        }
        else
        {
            out.color(COLOR_GREEN);
            out << start << endl;
        }

        out.reset_color();

        if (unique_counts[i] > 1)
            out << prefix << "    (" << unique_counts[i] << " copies)" << endl;
    }
}
开发者ID:Reag,项目名称:dfhack,代码行数:82,代码来源:workflow.cpp

示例7: runCommand

command_result Core::runCommand(color_ostream &con, const std::string &first, vector<string> &parts)
{
    if (!first.empty())
    {
        // let's see what we actually got
        if(first=="help" || first == "?" || first == "man")
        {
            if(!parts.size())
            {
                if (con.is_console())
                {
                    con.print("This is the DFHack console. You can type commands in and manage DFHack plugins from it.\n"
                              "Some basic editing capabilities are included (single-line text editing).\n"
                              "The console also has a command history - you can navigate it with Up and Down keys.\n"
                              "On Windows, you may have to resize your console window. The appropriate menu is accessible\n"
                              "by clicking on the program icon in the top bar of the window.\n\n");
                }
                con.print("Basic commands:\n"
                          "  help|?|man            - This text.\n"
                          "  help COMMAND          - Usage help for the given command.\n"
                          "  ls|dir [PLUGIN]       - List available commands. Optionally for single plugin.\n"
                          "  cls                   - Clear the console.\n"
                          "  fpause                - Force DF to pause.\n"
                          "  die                   - Force DF to close immediately\n"
                          "  keybinding            - Modify bindings of commands to keys\n"
                          "Plugin management (useful for developers):\n"
                          "  plug [PLUGIN|v]       - List plugin state and description.\n"
                          "  load PLUGIN|all       - Load a plugin by name or load all possible plugins.\n"
                          "  unload PLUGIN|all     - Unload a plugin or all loaded plugins.\n"
                          "  reload PLUGIN|all     - Reload a plugin or all loaded plugins.\n"
                         );
            }
            else if (parts.size() == 1)
            {
                Plugin *plug = plug_mgr->getPluginByCommand(parts[0]);
                if (plug) {
                    for (size_t j = 0; j < plug->size(); j++)
                    {
                        const PluginCommand & pcmd = (plug->operator[](j));
                        if (pcmd.name != parts[0])
                            continue;

                        if (pcmd.isHotkeyCommand())
                            con.color(COLOR_CYAN);
                        con.print("%s: %s\n",pcmd.name.c_str(), pcmd.description.c_str());
                        con.reset_color();
                        if (!pcmd.usage.empty())
                            con << "Usage:\n" << pcmd.usage << flush;
                        return CR_OK;
                    }
                }
                auto filename = getHackPath() + "scripts/" + parts[0];
                if (fileExists(filename + ".lua"))
                {
                    string help = getScriptHelp(filename + ".lua", "-- ");
                    con.print("%s: %s\n", parts[0].c_str(), help.c_str());
                    return CR_OK;
                }
                if (plug_mgr->eval_ruby && fileExists(filename + ".rb"))
                {
                    string help = getScriptHelp(filename + ".rb", "# ");
                    con.print("%s: %s\n", parts[0].c_str(), help.c_str());
                    return CR_OK;
                }
                con.printerr("Unknown command: %s\n", parts[0].c_str());
            }
            else
            {
                con.printerr("not implemented yet\n");
            }
        }
        else if( first == "load" )
        {
            if(parts.size())
            {
                string & plugname = parts[0];
                if(plugname == "all")
                {
                    for(size_t i = 0; i < plug_mgr->size(); i++)
                    {
                        Plugin * plug = (plug_mgr->operator[](i));
                        plug->load(con);
                    }
                }
                else
                {
                    Plugin * plug = plug_mgr->getPluginByName(plugname);
                    if(!plug)
                    {
                        con.printerr("No such plugin\n");
                    }
                    else
                    {
                        plug->load(con);
                    }
                }
            }
        }
        else if( first == "reload" )
        {
//.........这里部分代码省略.........
开发者ID:mokerjoke,项目名称:dfhack,代码行数:101,代码来源:Core.cpp


注:本文中的color_ostream::color方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。