1 --- poldek-0.18.6/vfile/vfprogress.c 2004-06-08 15:57:03.000000000 +0200
2 +++ poldek-0.18.6-patrys/vfile/vfprogress.c 2004-07-07 18:36:25.262259864 +0200
5 static int eta2str(char *buf, int bufsize, struct vf_progress_bar *bar)
8 + int hh, mm, ss, n = 0;
9 float eta = bar->eta + 0.5;
12 - mm = (int)(eta / 60.0);
13 + hh = (int)(eta / 60.0 / 60.00);
14 + mm = (int)(eta / 60.0) % 60;
17 - n = n_snprintf(&buf[n], bufsize - n, "%.2d:%.2d ETA", mm, ss);
18 + n = n_snprintf(&buf[n], bufsize - n, "%.2d:%.2d:%.2d", hh, mm, ss);
23 bar->transfer_rate = (float)amount / (current_time - bar->time_base);
24 if (bar->transfer_rate > 0)
25 bar->eta = (total - amount) / bar->transfer_rate;
27 - bar->transfer_rate /= 1024.0;
32 char line[256], outline[256], fmt[40];
35 + int screen_width = term_get_width();
38 if (bar->state == VF_PROGRESS_DISABLED)
40 bar->state = VF_PROGRESS_DISABLED;
44 + if (screen_width < 50) /* what kind of terminal is this?! */
48 + if (screen_width > 255) /* this might cause problems */
53 if (bar->state == VF_PROGRESS_VIRGIN) {
54 + bar->width = screen_width - 49; /* calculate bar width = screen width - 8 - unit_line*/
56 if (total == amount || /* downloaded before progress() call */
57 total < 1024) { /* too small to show to */
61 calculate_tt(total, amount, bar);
62 - n_assert(bar->prev_n < 100);
63 +// n_assert(bar->prev_n < 100);
71 - char unit_line[45], amount_str[16], total_str[16];
72 + char unit_line[42], amount_str[16], total_str[16], transfer_str[16];
75 nbytes2str(total_str, sizeof(total_str), total);
76 nbytes2str(amount_str, sizeof(amount_str), amount);
77 + nbytes2str(transfer_str, sizeof(transfer_str), bar->transfer_rate);
79 if (total == amount) {
80 if (bar->time_base == bar->time_last) /* fetched in less than 1s */
81 bar->transfer_rate = total / 1024.0;
83 - nn = n_snprintf(unit_line, sizeof(unit_line), "[%s (%.1fK/s)]",
84 - total_str, bar->transfer_rate);
85 + nn = n_snprintf(unit_line, sizeof(unit_line), "[ %7s] [%7s/s]",
86 + total_str, transfer_str);
91 n = eta2str(eta_str, sizeof(eta_str), bar);
93 nn = n_snprintf(unit_line, sizeof(unit_line),
94 - "[%s of %s (%.1fK/s)%s%s]",
95 - amount_str, total_str, bar->transfer_rate,
98 + "[%7s/%7s] [%7s/s] [%8s]",
99 + amount_str, total_str, transfer_str,
100 + n ? eta_str : "--:--:--");
102 if (nn > bar->maxlen)