mirror of
https://github.com/gbdev/rgbds.git
synced 2026-08-20 22:04:32 +00:00
Factor out verboseDo to encapsulate magenta output color
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user