From 3e3dc83789d4a45a35d78dabee32847e0faa77c7 Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Tue, 4 Feb 2020 17:39:59 +0100 Subject: [PATCH] filter ansi --- client/flash.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/client/flash.c b/client/flash.c index a3d438757..1f898f9d3 100644 --- a/client/flash.c +++ b/client/flash.c @@ -13,6 +13,7 @@ #include #include #include +#include #include "ui.h" #include "elf.h" @@ -534,6 +535,9 @@ int flash_write(flash_file_t *ctx) { int len = 0; PrintAndLogEx(SUCCESS, "Writing segments for file: %s", ctx->filename); + + bool filter_ansi = !session.supports_colors; + for (int i = 0; i < ctx->num_segs; i++) { flash_seg_t *seg = &ctx->segments[i]; @@ -561,11 +565,15 @@ int flash_write(flash_file_t *ctx) { baddr += block_size; length -= block_size; block++; - if ( len < strlen(ice) ) - fprintf(stdout, "%c", ice[len++]); - else + if ( len < strlen(ice) ) { + if (filter_ansi && !isalpha(ice[len]) ) { + len++; + } else { + fprintf(stdout, "%c", ice[len++]); + } + } else { fprintf(stdout, "."); - + } fflush(stdout); } PrintAndLogEx(NORMAL, " " _GREEN_("OK"));