| 1265 | } |
| 1266 | |
| 1267 | void ui_progress( |
| 1268 | const std::string& task_name, index_t val, index_t percent, |
| 1269 | bool clear |
| 1270 | ) { |
| 1271 | if(Logger::instance()->is_quiet() || is_redirected()) { |
| 1272 | return; |
| 1273 | } |
| 1274 | |
| 1275 | working_index++; |
| 1276 | |
| 1277 | std::ostringstream os; |
| 1278 | |
| 1279 | if(percent != val) { |
| 1280 | os << ui_feature(task_name) |
| 1281 | << "(" |
| 1282 | << working[(working_index % sizeof(working))] |
| 1283 | << ")-[" |
| 1284 | << std::setw(3) << percent |
| 1285 | << "%]-[" |
| 1286 | << std::setw(3) << val |
| 1287 | << "]--["; |
| 1288 | } else { |
| 1289 | os << ui_feature(task_name) |
| 1290 | << "(" |
| 1291 | << working[(working_index % sizeof(working))] |
| 1292 | << ")-[" |
| 1293 | << std::setw(3) << percent |
| 1294 | << "%]--------["; |
| 1295 | } |
| 1296 | |
| 1297 | size_t max_L = |
| 1298 | sub(ui_terminal_width(), 43 + ui_left_margin + ui_right_margin); |
| 1299 | |
| 1300 | max_L -= size_t(std::log10(std::max(double(val),1.0))); |
| 1301 | max_L += 2; |
| 1302 | |
| 1303 | if(val > max_L) { |
| 1304 | // No space enough to expand the progress bar |
| 1305 | // Do some animation... |
| 1306 | for(index_t i = 0; i < max_L; i++) { |
| 1307 | os << waves[((val - i + working_index) % sizeof(waves))]; |
| 1308 | } |
| 1309 | } else { |
| 1310 | for(index_t i = 0; i < val; i++) { |
| 1311 | os << "o"; |
| 1312 | } |
| 1313 | } |
| 1314 | os << " ]"; |
| 1315 | |
| 1316 | if(clear) { |
| 1317 | ui_clear_line(); |
| 1318 | } |
| 1319 | ui_message(os.str()); |
| 1320 | } |
| 1321 | |
| 1322 | void ui_progress_time( |
| 1323 | const std::string& task_name, double elapsed, bool clear |
no test coverage detected