Lines 390-395
void mutt_progress_init (progress_t* progress, const char *msg,
Link Here
|
390 |
mutt_progress_update (progress, 0, 0); |
390 |
mutt_progress_update (progress, 0, 0); |
391 |
} |
391 |
} |
392 |
|
392 |
|
|
|
393 |
static void message_bar (int percent, const char *fmt, ...) |
394 |
{ |
395 |
va_list ap; |
396 |
char buf[STRING], buf2[STRING]; |
397 |
int w = percent * COLS / 100; |
398 |
size_t l; |
399 |
|
400 |
va_start (ap, fmt); |
401 |
vsnprintf (buf, sizeof (buf), fmt, ap); |
402 |
l = mutt_strwidth (buf); |
403 |
va_end (ap); |
404 |
|
405 |
mutt_format_string(buf2, sizeof (buf2), |
406 |
0, COLS-2, FMT_LEFT, 0, buf, sizeof (buf), 0); |
407 |
|
408 |
move (LINES - 1, 0); |
409 |
|
410 |
if (l < w) |
411 |
{ |
412 |
SETCOLOR(MT_COLOR_PROGRESS); |
413 |
addstr (buf2); |
414 |
w -= l; |
415 |
while (w--) |
416 |
addch(' '); |
417 |
SETCOLOR(MT_COLOR_NORMAL); |
418 |
clrtoeol (); |
419 |
mutt_refresh(); |
420 |
} |
421 |
else |
422 |
{ |
423 |
size_t bw; |
424 |
char ch; |
425 |
int off = mutt_wstr_trunc (buf2, sizeof (buf2), w, &bw); |
426 |
|
427 |
ch = buf2[off]; |
428 |
buf2[off] = 0; |
429 |
SETCOLOR(MT_COLOR_PROGRESS); |
430 |
addstr (buf2); |
431 |
buf2[off] = ch; |
432 |
SETCOLOR(MT_COLOR_NORMAL); |
433 |
addstr (&buf2[off]); |
434 |
clrtoeol (); |
435 |
mutt_refresh(); |
436 |
} |
437 |
} |
438 |
|
393 |
void mutt_progress_update (progress_t* progress, long pos, int percent) |
439 |
void mutt_progress_update (progress_t* progress, long pos, int percent) |
394 |
{ |
440 |
{ |
395 |
char posstr[SHORT_STRING]; |
441 |
char posstr[SHORT_STRING]; |
Lines 440-455
void mutt_progress_update (progress_t* progress, long pos, int percent)
Link Here
|
440 |
|
486 |
|
441 |
if (progress->size > 0) |
487 |
if (progress->size > 0) |
442 |
{ |
488 |
{ |
443 |
mutt_message ("%s %s/%s (%d%%)", progress->msg, posstr, progress->sizestr, |
489 |
message_bar (percent > 0 ? percent : (int) (100.0 * (double) progress->pos / progress->size), |
444 |
percent > 0 ? percent : |
490 |
"%s %s/%s (%d%%)", progress->msg, posstr, progress->sizestr, |
445 |
(int) (100.0 * (double) progress->pos / progress->size)); |
491 |
percent > 0 ? percent : (int) (100.0 * (double) progress->pos / progress->size)); |
446 |
} |
492 |
} |
447 |
else |
493 |
else |
448 |
{ |
494 |
{ |
449 |
if (percent > 0) |
495 |
if (percent > 0) |
450 |
mutt_message ("%s %s (%d%%)", progress->msg, posstr, percent); |
496 |
message_bar (percent, "%s %s (%d%%)", progress->msg, posstr, percent); |
451 |
else |
497 |
else |
452 |
mutt_message ("%s %s", progress->msg, posstr); |
498 |
mutt_message ("%s %s", progress->msg, posstr); |
453 |
} |
499 |
} |
454 |
} |
500 |
} |
455 |
|
501 |
|