1 diff -r -u poldek-0.18.3/vfile/vfprogress.c poldek-0.18.3-patrys/vfile/vfprogress.c
2 --- poldek-0.18.3/vfile/vfprogress.c 2004-04-02 13:15:40.450672496 +0200
3 +++ poldek-0.18.3-patrys/vfile/vfprogress.c 2004-04-02 13:27:30.161780008 +0200
6 float transfer_rate = 0.0;
8 + int screen_width = term_get_width();
10 if (bar->state == VF_PROGRESS_DISABLED)
13 bar->state = VF_PROGRESS_DISABLED;
17 + if (screen_width < 50) /* what kind of terminal is this?! */
21 + if (screen_width > 255) /* this might cause problems */
26 if (bar->state == VF_PROGRESS_VIRGIN) {
27 + /* calling progress bar for the first time */
28 + bar->width = screen_width - 48; /* calculate bar width = screen width - 8 - unit_line*/
30 if (total == amount || /* downloaded before progress() call */
31 total < 1024) { /* too small to show to */
36 - n_assert(bar->prev_n < 100);
37 +// n_assert(bar->prev_n <= bar_width); /* not needed */
49 - char unit_line[43], amount_str[16], total_str[16];
53 +// ........................................ 99.2% [999.9K of 999.9K] [999.9K/s] [999m00s]
55 + char unit_line[40], amount_str[16], total_str[16], transfer_str[16];
58 current_time = time(NULL);
59 if (current_time != bar->time_base)
61 - transfer_rate = amount / (current_time - bar->time_base) / 1024.0;
62 + transfer_rate = amount / (current_time - bar->time_base);
64 if (transfer_rate > 0)
66 - eta = 0.5 + (total - amount) / (transfer_rate * 1024);
67 + eta = 0.5 + (total - amount) / (transfer_rate);
70 nbytes2str(total_str, sizeof(total_str), total);
71 nbytes2str(amount_str, sizeof(amount_str), amount);
72 + nbytes2str(transfer_str, sizeof(transfer_str), transfer_rate);
75 - nn = n_snprintf(unit_line, sizeof(unit_line), "[%s] [%.1fK/s]",
76 - total_str, transfer_rate);
77 + nn = n_snprintf(unit_line, sizeof(unit_line), "[%7s] [%7s/s]",
78 + total_str, transfer_str);
80 - nn = n_snprintf(unit_line, sizeof(unit_line), "[%s of %s] [%.1fK/s] [%dm%s%ds]",
81 - amount_str, total_str, transfer_rate, (int)eta / 60,
82 + nn = n_snprintf(unit_line, sizeof(unit_line), "[%7s/%7s] [%7s/s] [%3dm%s%ds]",
83 + amount_str, total_str, transfer_str, (int)eta / 60,
84 ((int)eta % 60 < 10 ? "0" : ""), (int)eta % 60);
86 unit_n = sizeof(unit_line) - nn - 1;