| 71 | } |
| 72 | |
| 73 | std::string rightText(const ScriptConsole::Layer& layer) |
| 74 | { |
| 75 | if (layer.bytes) { |
| 76 | std::string out; |
| 77 | if (layer.total > 0) { |
| 78 | out = std::to_string((int)(fraction(layer) * 100.0f)) + "%"; |
| 79 | } |
| 80 | else if (layer.done > 0) { |
| 81 | // No known total (a stream): the amount moved so far is the |
| 82 | // only real figure. |
| 83 | out = bytes(layer.done); |
| 84 | } |
| 85 | if (layer.rate > 0.0) { |
| 86 | if (!out.empty()) { |
| 87 | out += " "; |
| 88 | } |
| 89 | out += bytes((long long)layer.rate) + "/s"; |
| 90 | } |
| 91 | return out; |
| 92 | } |
| 93 | |
| 94 | // An item bar: the count the script is keeping, verbatim. Shown for an |
| 95 | // idle bar too — it finished at that count, and blanking it would make |
| 96 | // a finished row indistinguishable from one that never ran. |
| 97 | if (layer.total > 0) { |
| 98 | return std::to_string(layer.done) + "/" + std::to_string(layer.total); |
| 99 | } |
| 100 | if (layer.done > 0 || layer.active) { |
| 101 | return std::to_string(layer.done); |
| 102 | } |
| 103 | return std::string(); |
| 104 | } |
| 105 | } |