Factor out verboseDo to encapsulate magenta output color

This commit is contained in:
Rangi
2026-07-13 18:05:55 -04:00
parent ea3a8ee171
commit 304cbb464f
8 changed files with 59 additions and 95 deletions
+11
View File
@@ -6,6 +6,9 @@
#include <stdarg.h>
#include <stdio.h>
#include "helpers.hpp" // Procedure
#include "style.hpp"
// This macro does not evaluate its arguments unless the condition is true.
#define verbosePrint(level, ...) \
do { \
@@ -30,6 +33,14 @@ bool checkVerbosity(Verbosity level);
[[gnu::format(printf, 1, 2)]]
void printVerbosely(char const *fmt, ...);
void verboseDo(Verbosity level, Procedure<> auto callback) {
if (checkVerbosity(level)) {
style_Set(stderr, STYLE_MAGENTA, false);
callback();
style_Reset(stderr);
}
}
void printVVVVVVerbosity();
#endif // RGBDS_VERBOSITY_HPP