![]() |
|
High-precision calculations for one- and two-valence atomic systems
|
Live status line for iterative loops; overwrites itself on a TTY.
Construct before the loop, call operator() each iteration with the current status message, then call done() (optionally with a trailing annotation) when the loop finishes. The destructor calls done() automatically if it has not been called explicitly, so early returns and exceptions are handled cleanly.
Behaviour depends on whether stdout is a TTY:
\r{header}{msg} and flushes, overwriting the current line. done() prints \r{header}{last_msg}{post}\n.{last_msg}{post}\n. This gives one clean output line with no intermediate churn.If active is false all methods are no-ops (runtime print toggle).
Typical usage:
| header | Fixed prefix, always printed (on construction for non-TTY, or on every line for TTY). |
| active | If false, all methods are no-ops. Default true. |
#include <Widgets.hpp>
Public Member Functions | |
| LiveMessage (std::string_view header, bool active=true) | |
| LiveMessage (const LiveMessage &)=delete | |
| LiveMessage & | operator= (const LiveMessage &)=delete |
| void | update (std::string_view msg) |
| Update the status message. On TTY overwrites the current line; on non-TTY buffers silently until done() is called. | |
| void | operator() (std::string_view msg) |
| Update the status message. see update() | |
| void | done (std::string_view post={}) |
Finalise: print last message + optional post, then newline. Safe to call multiple times (only the first call has effect). | |
|
inline |
Update the status message. On TTY overwrites the current line; on non-TTY buffers silently until done() is called.
|
inline |
Update the status message. see update()
|
inline |
Finalise: print last message + optional post, then newline. Safe to call multiple times (only the first call has effect).