Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ANSI Escape Codes #2509

Merged
merged 1 commit into from
Dec 3, 2021
Merged

ANSI Escape Codes #2509

merged 1 commit into from
Dec 3, 2021

Conversation

WeiqunZhang
Copy link
Member

Add commonly used ANSI escape codes to AMReX_ANSIEscCode.H. They can be
used to print colored output. For example,

amrex::Print() << Font::Bold << FGColor::Red << "Hello world from AMReX\n"
               << ResetDisplay << Font::Faint << FGColor::BrightCyan
               << Font::Underline << "Hello world again from AMReX "
               << ResetDisplay << BGColor::White << FGColor::Black << amrex::Version()
               << ResetDisplay << std::endl;

Summary

Additional background

Checklist

The proposed changes:

  • fix a bug or incorrect behavior in AMReX
  • add new capabilities to AMReX
  • changes answers in the test suite to more than roundoff level
  • are likely to significantly affect the results of downstream AMReX users
  • include documentation in the code and/or rst files, if appropriate

Add commonly used ANSI escape codes to AMReX_ANSIEscCode.H.  They can be
used to print colored output.  For example,

    amrex::Print() << Font::Bold << FGColor::Red << "Hello world from AMReX\n"
                   << ResetDisplay << Font::Faint << FGColor::BrightCyan
                   << Font::Underline << "Hello world again from AMReX "
                   << ResetDisplay << BGColor::White << FGColor::Black << amrex::Version()
                   << ResetDisplay << std::endl;
@cgilet
Copy link
Contributor

cgilet commented Dec 3, 2021

Question @WeiqunZhang : what happens if I don't do the intermediate ResetDisplay and, say, just try to change the font color with FGColor::BrightCyan?

@zingale
Copy link
Member

zingale commented Dec 3, 2021

it will persist with that color setting until you change it next. So if you want to do a block of output in a color, you can change it once, do all of the std::cout, and then reset.

@WeiqunZhang WeiqunZhang merged commit e2af96c into AMReX-Codes:development Dec 3, 2021
@WeiqunZhang WeiqunZhang deleted the color branch December 3, 2021 16:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants