Merge pull request #337 from TTimo/colorcodes
Enable support for ANSI color codes on Windows 10 and newer, without …
This commit is contained in:
commit
c9111b2a6c
|
|
@ -20,6 +20,7 @@
|
|||
#include <common/bspinfo.hh>
|
||||
#include <common/cmdlib.hh>
|
||||
#include <common/bspfile.hh>
|
||||
#include <common/log.hh>
|
||||
|
||||
#include <fstream>
|
||||
#include <fmt/ostream.h>
|
||||
|
|
@ -84,6 +85,8 @@ settings::common_settings bspinfo_options;
|
|||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
logging::preinitialize();
|
||||
|
||||
fmt::print("---- bspinfo / ericw-tools {} ----\n", ERICWTOOLS_VERSION);
|
||||
if (argc == 1) {
|
||||
printf("usage: bspinfo bspfile [bspfiles]\n");
|
||||
|
|
|
|||
|
|
@ -471,6 +471,8 @@ settings::common_settings bsputil_options;
|
|||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
logging::preinitialize();
|
||||
|
||||
bspdata_t bspdata;
|
||||
// FIXME: doesn't this get overwritten by ConvertBSPFormat below?
|
||||
mbsp_t &bsp = bspdata.bsp.emplace<mbsp_t>();
|
||||
|
|
|
|||
|
|
@ -54,6 +54,15 @@ namespace logging
|
|||
bitflags<flag> mask = bitflags<flag>(flag::ALL) & ~bitflags<flag>(flag::VERBOSE);
|
||||
bool enable_color_codes = true;
|
||||
|
||||
void preinitialize()
|
||||
{
|
||||
#ifdef _WIN32
|
||||
// enable processing of ANSI escape sequences on Windows
|
||||
HANDLE hOutput = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
SetConsoleMode(hOutput, ENABLE_PROCESSED_OUTPUT | ENABLE_VIRTUAL_TERMINAL_PROCESSING);
|
||||
#endif
|
||||
}
|
||||
|
||||
void init(const fs::path &filename, const settings::common_settings &settings)
|
||||
{
|
||||
if (settings.log.value()) {
|
||||
|
|
|
|||
|
|
@ -57,6 +57,9 @@ enum class flag : uint8_t
|
|||
extern bitflags<flag> mask;
|
||||
extern bool enable_color_codes;
|
||||
|
||||
// Windows: calls SetConsoleMode for ANSI escape sequence processing (so colors work)
|
||||
void preinitialize();
|
||||
|
||||
// initialize logging subsystem
|
||||
void init(const fs::path &filename, const settings::common_settings &settings);
|
||||
|
||||
|
|
|
|||
|
|
@ -19,9 +19,12 @@
|
|||
|
||||
#include <light/light.hh>
|
||||
#include <common/settings.hh>
|
||||
#include <common/log.hh>
|
||||
|
||||
int main(int argc, const char **argv)
|
||||
{
|
||||
logging::preinitialize();
|
||||
|
||||
try {
|
||||
return light_main(argc, argv);
|
||||
} catch (const settings::quit_after_help_exception &) {
|
||||
|
|
|
|||
|
|
@ -19,9 +19,12 @@
|
|||
|
||||
#include <qbsp/qbsp.hh>
|
||||
#include <common/settings.hh>
|
||||
#include <common/log.hh>
|
||||
|
||||
int main(int argc, const char **argv)
|
||||
{
|
||||
logging::preinitialize();
|
||||
|
||||
try {
|
||||
return qbsp_main(argc, argv);
|
||||
} catch (const settings::quit_after_help_exception &) {
|
||||
|
|
|
|||
|
|
@ -3,7 +3,10 @@
|
|||
|
||||
#include <common/log.hh>
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
logging::preinitialize();
|
||||
|
||||
// writing console colors within test case output breaks doctest/CLion integration
|
||||
logging::enable_color_codes = false;
|
||||
|
||||
|
|
|
|||
|
|
@ -19,9 +19,12 @@
|
|||
|
||||
#include <vis/vis.hh>
|
||||
#include <common/settings.hh>
|
||||
#include <common/log.hh>
|
||||
|
||||
int main(int argc, const char **argv)
|
||||
{
|
||||
logging::preinitialize();
|
||||
|
||||
try {
|
||||
return vis_main(argc, argv);
|
||||
} catch (const settings::quit_after_help_exception &) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue