#include "text-art/selftests.h"
#include "text-art/types.h"
#include "color-macros.h"
+#include "diagnostic-color.h"
using namespace text_art;
}
}
+/* Look up the current SGR codes for a color capability NAME
+ (from GCC_COLORS or the defaults), and convert them to
+ a text_art::style. */
+
+style
+text_art::get_style_from_color_cap_name (const char *name)
+{
+ const char *sgr_codes = colorize_start (true, name);
+ gcc_assert (sgr_codes);
+
+ /* Parse the sgr codes. We expect the resulting styled_string to be
+ empty; we're interested in the final style created during parsing. */
+ style_manager sm;
+ styled_string styled_str (sm, sgr_codes);
+ return sm.get_style (sm.get_num_styles () - 1);
+}
+
/* class text_art::style_manager. */
style_manager::style_manager ()