make style
This commit is contained in:
@@ -632,7 +632,7 @@ void print_progress(size_t count, uint64_t max, barMode_t style) {
|
||||
static int prev_cols = 0;
|
||||
int rows;
|
||||
rl_reset_screen_size(); // refresh Readline idea of the actual screen width
|
||||
rl_get_screen_size (&rows, &cols);
|
||||
rl_get_screen_size(&rows, &cols);
|
||||
(void) rows;
|
||||
if (prev_cols > cols) {
|
||||
PrintAndLogEx(NORMAL, _CLEAR_ _TOP_ "");
|
||||
@@ -640,9 +640,9 @@ void print_progress(size_t count, uint64_t max, barMode_t style) {
|
||||
prev_cols = cols;
|
||||
#endif
|
||||
int width = cols - 35;
|
||||
#define PERCENTAGE(V, T) ((V * width) / T)
|
||||
#define PERCENTAGE(V, T) ((V * width) / T)
|
||||
// x/8 fractional part of the percentage
|
||||
#define PERCENTAGEFRAC(V, T) ((int)(((((float)V * width) / T) - ((V * width) / T)) * 8))
|
||||
#define PERCENTAGEFRAC(V, T) ((int)(((((float)V * width) / T) - ((V * width) / T)) * 8))
|
||||
|
||||
const char *smoothtable[] = {
|
||||
"\xe2\x80\x80",
|
||||
@@ -662,13 +662,13 @@ void print_progress(size_t count, uint64_t max, barMode_t style) {
|
||||
const char *space[] = {" ", "\xe2\x80\x80"};
|
||||
uint8_t unit = strlen(block[mode]);
|
||||
// +1 for \0
|
||||
char *bar = calloc(unit*width + 1, sizeof(uint8_t));
|
||||
char *bar = calloc(unit * width + 1, sizeof(uint8_t));
|
||||
|
||||
uint8_t value = PERCENTAGE(count, max);
|
||||
|
||||
int i = 0;
|
||||
// prefix is added already.
|
||||
for (; i < unit*value; i+=unit) {
|
||||
for (; i < unit * value; i += unit) {
|
||||
memcpy(bar + i, block[mode], unit);
|
||||
}
|
||||
// add last block
|
||||
@@ -679,7 +679,7 @@ void print_progress(size_t count, uint64_t max, barMode_t style) {
|
||||
}
|
||||
i += unit;
|
||||
// add spaces
|
||||
for (; i < unit*width; i+=unit) {
|
||||
for (; i < unit * width; i += unit) {
|
||||
memcpy(bar + i, space[mode], unit);
|
||||
}
|
||||
// color buffer
|
||||
@@ -687,24 +687,24 @@ void print_progress(size_t count, uint64_t max, barMode_t style) {
|
||||
char *cbar = calloc(collen, sizeof(uint8_t));
|
||||
|
||||
// Add colors
|
||||
int p60 = unit*(width*60/100);
|
||||
int p20 = unit*(width*20/100);
|
||||
int p60 = unit * (width * 60 / 100);
|
||||
int p20 = unit * (width * 20 / 100);
|
||||
snprintf(cbar, collen, _GREEN_("%.*s"), p60, bar);
|
||||
snprintf(cbar + strlen(cbar), collen - strlen(cbar), _CYAN_("%.*s"), p20, bar + p60);
|
||||
snprintf(cbar + strlen(cbar), collen - strlen(cbar), _YELLOW_("%.*s"), unit*width - p60 - p20, bar + p60 + p20);
|
||||
snprintf(cbar + strlen(cbar), collen - strlen(cbar), _YELLOW_("%.*s"), unit * width - p60 - p20, bar + p60 + p20);
|
||||
|
||||
size_t len = strlen(cbar) + 32;
|
||||
char *buffer = calloc(len, sizeof(uint8_t));
|
||||
|
||||
switch(style) {
|
||||
switch (style) {
|
||||
case STYLE_BAR: {
|
||||
sprintf(buffer, "%s", cbar);
|
||||
sprintf(buffer, "%s", cbar);
|
||||
printf("\b%c[2K\r[" _YELLOW_("=")"] %s", 27, buffer);
|
||||
break;
|
||||
}
|
||||
case STYLE_MIXED: {
|
||||
sprintf(buffer, "%s [ %zu mV / %3u V ]", cbar, count, (uint32_t)(count / 1000));
|
||||
printf("\b%c[2K\r[" _YELLOW_("=")"] %s ", 27, buffer);
|
||||
printf("\b%c[2K\r[" _YELLOW_("=")"] %s ", 27, buffer);
|
||||
break;
|
||||
}
|
||||
case STYLE_VALUE: {
|
||||
|
||||
Reference in New Issue
Block a user