Skip to content

Commit

Permalink
Fixed progress indicator characters on Windows (#218)
Browse files Browse the repository at this point in the history
  • Loading branch information
bkryza committed Dec 12, 2023
1 parent 8ae47dd commit 66534af
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
2 changes: 2 additions & 0 deletions .clang-uml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 3 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ target_compile_options(clang-umllib PRIVATE
$<$<CXX_COMPILER_ID:MSVC>:/MP /W1 /bigobj /wd4291 /wd4624 /wd4244>)
target_compile_definitions(clang-umllib PRIVATE
$<$<CXX_COMPILER_ID:MSVC>:
-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
Expand Down
20 changes: 16 additions & 4 deletions src/common/generators/progress_indicator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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))},
Expand Down Expand Up @@ -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();
Expand All @@ -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();
}

Expand Down

0 comments on commit 66534af

Please sign in to comment.