]> git.pld-linux.org Git - packages/poldek.git/blob - poldek-progress2.patch
- version 0.18.7, removed -{pkorder,sigsegv,caplookup} patches (applied)
[packages/poldek.git] / poldek-progress2.patch
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
3 @@ -60,14 +60,15 @@
4  
5  static int eta2str(char *buf, int bufsize, struct vf_progress_bar *bar) 
6  {
7 -    int mm, ss, n = 0;
8 +    int hh, mm, ss, n = 0;
9      float eta = bar->eta + 0.5;
10  
11      
12 -    mm = (int)(eta / 60.0);
13 +    hh = (int)(eta / 60.0 / 60.00);
14 +    mm = (int)(eta / 60.0) % 60;
15      ss = (int)eta % 60;
16      if (mm || ss)
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);
19      return n;
20  }
21  
22 @@ -84,8 +85,6 @@
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;
26 -
27 -    bar->transfer_rate /= 1024.0;
28  }
29  
30  
31 @@ -95,6 +94,7 @@
32      char                    line[256], outline[256], fmt[40];
33      float                   frac, percent;
34      long                    n;
35 +    int                            screen_width = term_get_width();
36   
37      
38      if (bar->state == VF_PROGRESS_DISABLED)
39 @@ -107,8 +107,18 @@
40          bar->state = VF_PROGRESS_DISABLED;
41          return;
42      }
43 +
44 +    if (screen_width < 50) /* what kind of terminal is this?! */
45 +    {
46 +       screen_width = 50;
47 +    }
48 +    if (screen_width > 255) /* this might cause problems */
49 +    {
50 +       screen_width = 255;
51 +    }
52      
53      if (bar->state == VF_PROGRESS_VIRGIN) {
54 +       bar->width = screen_width - 49; /* calculate bar width = screen width - 8 - unit_line*/
55          if (total > 0) {
56              if (total == amount ||   /* downloaded before progress() call */
57                  total < 1024) {       /* too small to show to */
58 @@ -142,7 +152,7 @@
59          return;
60      }
61      calculate_tt(total, amount, bar);
62 -    n_assert(bar->prev_n < 100);
63 +//    n_assert(bar->prev_n < 100);
64      if (!bar->is_tty) {
65          int k;
66          
67 @@ -159,18 +169,19 @@
68          }
69          
70      } else {
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];
73          int nn;
74              
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);
78  
79          if (total == amount) {
80              if (bar->time_base == bar->time_last) /* fetched in less than 1s */
81                  bar->transfer_rate = total / 1024.0;
82                      
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);
87          } else {
88              int n = 0;
89              char eta_str[64];
90 @@ -178,10 +189,9 @@
91              n = eta2str(eta_str, sizeof(eta_str), bar);
92              
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,
96 -                            n ? ", ": "",
97 -                            n ? eta_str : "");
98 +                            "[%7s/%7s] [%7s/s] [%8s]",
99 +                            amount_str, total_str, transfer_str,
100 +                            n ? eta_str : "--:--:--");
101          }
102          if (nn > bar->maxlen)
103              bar->maxlen = nn;
This page took 0.075279 seconds and 3 git commands to generate.