filter ansi

This commit is contained in:
iceman1001 2020-02-04 17:39:59 +01:00
commit 3e3dc83789

View file

@ -13,6 +13,7 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include <ctype.h>
#include "ui.h" #include "ui.h"
#include "elf.h" #include "elf.h"
@ -534,6 +535,9 @@ int flash_write(flash_file_t *ctx) {
int len = 0; int len = 0;
PrintAndLogEx(SUCCESS, "Writing segments for file: %s", ctx->filename); PrintAndLogEx(SUCCESS, "Writing segments for file: %s", ctx->filename);
bool filter_ansi = !session.supports_colors;
for (int i = 0; i < ctx->num_segs; i++) { for (int i = 0; i < ctx->num_segs; i++) {
flash_seg_t *seg = &ctx->segments[i]; flash_seg_t *seg = &ctx->segments[i];
@ -561,11 +565,15 @@ int flash_write(flash_file_t *ctx) {
baddr += block_size; baddr += block_size;
length -= block_size; length -= block_size;
block++; block++;
if ( len < strlen(ice) ) if ( len < strlen(ice) ) {
fprintf(stdout, "%c", ice[len++]); if (filter_ansi && !isalpha(ice[len]) ) {
else len++;
} else {
fprintf(stdout, "%c", ice[len++]);
}
} else {
fprintf(stdout, "."); fprintf(stdout, ".");
}
fflush(stdout); fflush(stdout);
} }
PrintAndLogEx(NORMAL, " " _GREEN_("OK")); PrintAndLogEx(NORMAL, " " _GREEN_("OK"));