From 66534af3fcf78af46d680066d8b4d1f5d5aa8c4f Mon Sep 17 00:00:00 2001 From: Bartek Kryza Date: Tue, 12 Dec 2023 11:37:22 +0100 Subject: [PATCH] Fixed progress indicator characters on Windows (#218) --- .clang-uml | 2 ++ src/CMakeLists.txt | 4 +++- src/common/generators/progress_indicator.cc | 20 ++++++++++++++++---- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/.clang-uml b/.clang-uml index 3d234d38..53fed4a6 100644 --- a/.clang-uml +++ b/.clang-uml @@ -1,6 +1,8 @@ compilation_database_dir: debug output_directory: docs/diagrams comment_parser: clang +add_compile_flags: + - -Wno-deprecated-declarations remove_compile_flags: - -Wno-class-memaccess - -Wno-dangling-reference diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f36f662d..e052d584 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -30,7 +30,9 @@ target_compile_options(clang-umllib PRIVATE $<$:/MP /W1 /bigobj /wd4291 /wd4624 /wd4244>) target_compile_definitions(clang-umllib PRIVATE $<$: - -DLLVM_FORCE_USE_OLD_TOOLCHAIN>) + -DLLVM_FORCE_USE_OLD_TOOLCHAIN + -DTERMCOLOR_USE_WINDOWS_API=1 + -DTERMCOLOR_TARGET_WINDOWS=1>) # # Define the target executable clang-uml diff --git a/src/common/generators/progress_indicator.cc b/src/common/generators/progress_indicator.cc index 55224a6b..6dbf48f9 100644 --- a/src/common/generators/progress_indicator.cc +++ b/src/common/generators/progress_indicator.cc @@ -39,7 +39,11 @@ void progress_indicator::add_progress_bar( indicators::option::BarWidth{kBarWidth}, indicators::option::ForegroundColor{color}, indicators::option::ShowElapsedTime{true}, +#if _MSC_VER + indicators::option::Fill{"="}, indicators::option::Lead{">"}, +#else indicators::option::Fill{"█"}, indicators::option::Lead{"█"}, +#endif indicators::option::Remainder{"-"}, indicators::option::PrefixText{ fmt::format("{:<25}", util::abbreviate(name, kPrefixTextWidth))}, @@ -104,8 +108,12 @@ void progress_indicator::complete(const std::string &name) bar.set_progress(kCompleteProgressPercent); - bar.set_option(indicators::option::PostfixText{ - fmt::format("{}/{} ✔", p.progress, p.max)}); +#if _MSC_VER + const auto postfix_text = fmt::format("{}/{} OK", p.progress, p.max); +#else + const auto postfix_text = fmt::format("{}/{} ✔", p.progress, p.max); +#endif + bar.set_option(indicators::option::PostfixText{postfix_text}); bar.set_option( indicators::option::ForegroundColor{indicators::Color::green}); bar.mark_as_completed(); @@ -118,9 +126,13 @@ void progress_indicator::fail(const std::string &name) auto &bar = progress_bars_[p.index]; progress_bars_mutex_.unlock(); +#if _MSC_VER + const auto postfix_text = fmt::format("{}/{} FAILED", p.progress, p.max); +#else + const auto postfix_text = fmt::format("{}/{} ✗", p.progress, p.max); +#endif bar.set_option(indicators::option::ForegroundColor{indicators::Color::red}); - bar.set_option(indicators::option::PostfixText{ - fmt::format("{}/{} ✗", p.progress, p.max)}); + bar.set_option(indicators::option::PostfixText{postfix_text}); bar.mark_as_completed(); }