[util] Allow HB_CHAFA=2/3 to enable wedges/all symbols in Chafa

This commit is contained in:
Behdad Esfahbod 2022-07-18 10:22:19 -06:00
parent b4e95965c8
commit faa8cdc898
1 changed files with 7 additions and 6 deletions

View File

@ -41,7 +41,7 @@
# define CELL_H (2 * CELL_W) # define CELL_H (2 * CELL_W)
static void static void
chafa_print_image_rgb24 (const void *data, int width, int height, int stride) chafa_print_image_rgb24 (const void *data, int width, int height, int stride, int level)
{ {
ChafaTermInfo *term_info; ChafaTermInfo *term_info;
ChafaSymbolMap *symbol_map; ChafaSymbolMap *symbol_map;
@ -85,7 +85,8 @@ chafa_print_image_rgb24 (const void *data, int width, int height, int stride)
chafa_symbol_map_add_by_tags (symbol_map, chafa_symbol_map_add_by_tags (symbol_map,
(ChafaSymbolTags) (CHAFA_SYMBOL_TAG_BLOCK (ChafaSymbolTags) (CHAFA_SYMBOL_TAG_BLOCK
| CHAFA_SYMBOL_TAG_SPACE | CHAFA_SYMBOL_TAG_SPACE
//| CHAFA_SYMBOL_TAG_WEDGE | (level >= 2 ? CHAFA_SYMBOL_TAG_WEDGE : 0)
| (level >= 3 ? CHAFA_SYMBOL_TAG_ALL : 0)
)); ));
config = chafa_canvas_config_new (); config = chafa_canvas_config_new ();
@ -204,11 +205,11 @@ helper_cairo_surface_write_to_ansi_stream (cairo_surface_t *surface,
{ {
#ifdef HAVE_CHAFA #ifdef HAVE_CHAFA
const char *env = getenv ("HB_CHAFA"); const char *env = getenv ("HB_CHAFA");
bool chafa = true; int chafa_level = 1;
if (env) if (env)
chafa = atoi (env); chafa_level = atoi (env);
if (chafa) if (chafa_level)
chafa_print_image_rgb24 (data, width, height, stride); chafa_print_image_rgb24 (data, width, height, stride, chafa_level);
else else
#endif #endif
ansi_print_image_rgb24 (data, width, height, stride / 4); ansi_print_image_rgb24 (data, width, height, stride / 4);