filter ansi

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

View file

@ -13,6 +13,7 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#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"));