sharkdp / dbg-macro

A dbg(…) macro for C++
MIT License
2.97k stars 257 forks source link

Colorized output support for Windows. #99

Open gwankyun opened 3 years ago

gwankyun commented 3 years ago
  1. Use SetConsoleTextAttribute to support Colorized output on Windows.
  2. Must set NOMINMAX when use std::min on Windows.
  3. __cplusplus is not enough to check MSVC standard.
sharkdp commented 3 years ago

Thank you very much for your contribution!

Happy to take a look when the builds are green.

sharkdp commented 3 years ago

I have updated our CI system to GitHub Actions, see #104. It would be great if you could rebase your branch to run the new set of tests.

gwankyun commented 3 years ago

The checks have passed, Please review it.^_^

gwankyun commented 3 years ago

I learning to solve #97 .

sharkdp commented 3 years ago

Thank you for your contribution. A few things are included here. It would be great if we could split them into separate PRs. As for part 2 (Must set NOMINMAX when use std::min on Windows.), have you seen https://github.com/sharkdp/dbg-macro/pull/100?

As for the main change here (colorized support for Windows): I would prefer if we could keep the complexity somewhat limited and only support ANSI-escape sequence based terminals. This should work just fine on Windows 10, if the support is enabled (https://docs.microsoft.com/de-de/windows/console/console-virtual-terminal-sequences).

gwankyun commented 3 years ago

I defined a DBG_ANSI_TYPE marco in dbg.h, for optional support Classic Console API on Windows 7 in example.cpp.

bl-ue commented 3 years ago

cc @sharkdp

sharkdp commented 3 years ago

cc @sharkdp

?

bl-ue commented 3 years ago

Sorry, that wasn't very clear. 😄

I was using my own macro on a project, but I recently came upon this library, which I immediately preferred and attempted to use, but I found that it doesn't support the platform I'm developing for, Windows. I can easily checkout this PR, but I'd love to see it merged into master (which maybe should be renamed to main?)

sharkdp commented 3 years ago

To be honest, I have lost track of what this PR does. There are a lot of changes, especially to the CMake config. As I said above: I'm happy to integrate this, but only for terminals that support ANSI escape sequences. I don't want to add (and maintain) a lot of code for legacy Windows terminals.

niXman commented 1 year ago

Must set NOMINMAX when use std::min on Windows.

just wrap it in parenthesis =)

(std::min)(...)

gwankyun commented 1 year ago

Must set NOMINMAX when use std::min on Windows.

just wrap it in parenthesis =)

(std::min)(...)

Thank you but >_<