| 2144 | } |
| 2145 | |
| 2146 | std::pair<std::string, int> get_postfix_text() { |
| 2147 | std::stringstream os; |
| 2148 | const auto max_progress = |
| 2149 | get_value<details::ProgressBarOption::max_progress>(); |
| 2150 | |
| 2151 | if (get_value<details::ProgressBarOption::show_percentage>()) { |
| 2152 | os << " " |
| 2153 | << (std::min)(static_cast<size_t>(static_cast<float>(progress_) / |
| 2154 | max_progress * 100), |
| 2155 | size_t(100)) |
| 2156 | << "%"; |
| 2157 | } |
| 2158 | |
| 2159 | auto &saved_start_time = |
| 2160 | get_value<details::ProgressBarOption::saved_start_time>(); |
| 2161 | |
| 2162 | if (get_value<details::ProgressBarOption::show_elapsed_time>()) { |
| 2163 | os << " ["; |
| 2164 | if (saved_start_time) |
| 2165 | details::write_duration(os, elapsed_); |
| 2166 | else |
| 2167 | os << "00:00s"; |
| 2168 | } |
| 2169 | |
| 2170 | if (get_value<details::ProgressBarOption::show_remaining_time>()) { |
| 2171 | if (get_value<details::ProgressBarOption::show_elapsed_time>()) |
| 2172 | os << "<"; |
| 2173 | else |
| 2174 | os << " ["; |
| 2175 | |
| 2176 | if (saved_start_time) { |
| 2177 | auto eta = std::chrono::nanoseconds( |
| 2178 | progress_ > 0 |
| 2179 | ? static_cast<long long>(std::ceil(float(elapsed_.count()) * |
| 2180 | max_progress / progress_)) |
| 2181 | : 0); |
| 2182 | auto remaining = eta > elapsed_ ? (eta - elapsed_) : (elapsed_ - eta); |
| 2183 | details::write_duration(os, remaining); |
| 2184 | } else { |
| 2185 | os << "00:00s"; |
| 2186 | } |
| 2187 | |
| 2188 | os << "]"; |
| 2189 | } else { |
| 2190 | if (get_value<details::ProgressBarOption::show_elapsed_time>()) |
| 2191 | os << "]"; |
| 2192 | } |
| 2193 | |
| 2194 | os << " " << get_value<details::ProgressBarOption::postfix_text>(); |
| 2195 | |
| 2196 | const auto result = os.str(); |
| 2197 | const auto result_size = unicode::display_width(result); |
| 2198 | return {result, result_size}; |
| 2199 | } |
| 2200 | |
| 2201 | public: |
| 2202 | void print_progress(bool from_multi_progress = false) { |
nothing calls this directly
no test coverage detected