# # # patch "ChangeLog" # from [994e5c7216b572e797fb67652eecc6c3cfde7d09] # to [f92ab5a6ad615b29c1bab7d73dada3301543b899] # # patch "ui.cc" # from [b88a6344e7fc8bed1ca5b3a7ed0eef9d54015efe] # to [88bd082d78f7c8296dac0268ef6114200310207f] # ============================================================ --- ChangeLog 994e5c7216b572e797fb67652eecc6c3cfde7d09 +++ ChangeLog f92ab5a6ad615b29c1bab7d73dada3301543b899 @@ -1,3 +1,8 @@ +2006-01-15 Matt Johnston + + * ui.cc: make tickers saner (203 K vs 0.2 M). + Print full byte counts below 1 K. + 2006-01-14 Nathaniel Smith * lua.cc (hook_get_key_pair): Remove. ============================================================ --- ui.cc b88a6344e7fc8bed1ca5b3a7ed0eef9d54015efe +++ ui.cc 88bd082d78f7c8296dac0268ef6114200310207f @@ -17,6 +17,7 @@ #include #include +#include #include using namespace std; @@ -92,59 +93,65 @@ i != ui.tickers.end(); ++i) { string count; - if (i->second->kilocount) + ticker * tick = i->second; + if (tick->kilocount && tick->ticks) { // automatic unit conversion is enabled float div = 1.0; const char *message; - if (i->second->ticks >= 1073741824/10) + if (tick->ticks >= 1073741824) { div = 1073741824; // xgettext: gibibytes (2^30 bytes) message = N_("%.1f G"); } - else if (i->second->ticks >= 1048576/10) + else if (tick->ticks >= 1048576) { div = 1048576; // xgettext: mebibytes (2^20 bytes) message = N_("%.1f M"); } - else + else if (tick->ticks >= 1024) { div = 1024; // xgettext: kibibytes (2^10 bytes) message = N_("%.1f k"); } + else + { + div = 1; + message = "%.0f"; + } // We reset the mod to the divider, to avoid spurious screen updates. - i->second->mod = static_cast(div / 10.0); - count = (F(message) % (i->second->ticks / div)).str(); + tick->mod = max(static_cast(div / 10.0), 1); + count = (F(message) % (tick->ticks / div)).str(); } - else if (i->second->use_total) + else if (tick->use_total) { // We know that we're going to eventually have 'total' displayed // twice on screen, plus a slash. So we should pad out this field // to that eventual size to avoid spurious re-issuing of the // tick titles as we expand to the goal. - string complete = (F("%d/%d") % i->second->total % i->second->total).str(); + string complete = (F("%d/%d") % tick->total % tick->total).str(); // xgettext: bytes - string current = (F("%d/%d") % i->second->ticks % i->second->total).str(); + string current = (F("%d/%d") % tick->ticks % tick->total).str(); count.append(complete.size() - current.size(),' '); count.append(current); } else { // xgettext: bytes - count = (F("%d") % i->second->ticks).str(); + count = (F("%d") % tick->ticks).str(); } - size_t title_width = display_width(utf8(i->second->name)); + size_t title_width = display_width(utf8(tick->name)); size_t count_width = display_width(utf8(count)); size_t max_width = title_width > count_width ? title_width : count_width; string name; - name.append(max_width - i->second->name.size(), ' '); - name.append(i->second->name); + name.append(max_width - tick->name.size(), ' '); + name.append(tick->name); string count2; count2.append(max_width - count.size(), ' ');