Console

API reference

Usage example

#include <rili/service/Console.cpp>
#include <rili/Color.hpp>

void colors(rili::service::Console & console) {
    console.clear(); // we will clear whole console
    for (int color = 0; color < 256; color++) {
        console << color << "\t["; // print color number in ANSI256 palete
        console << rili::service::console::bg(rili::color::ANSI256(static_cast<std::uint8_t>(color))) << "  "
                << rili::stream::flush; // set background to given color
        console << rili::service::console::bg(rili::color::ANSI256(static_cast<std::uint8_t>(color)).ansi16()) << "  "
                << rili::stream::flush; // convert to ansi16 palete and set background color
        console << rili::service::console::bg(); // reset background color to default
        console << "]" << rili::stream::endl;
    }
}
int main(int, char**) {
    auto& console = rili::service::Console::instance();
    if (!console.outputMode(rili::service::Console::OutputMode::VT100_216Colors)) {  // try set VT100 216 color console mode
        console.outputMode(rili::service::Console::OutputMode::WINDOWS_API); // if not avaliable try set WINDOWS_API as console mode
    }
    colors(console);
    return 0;
}