@@ -397,13 +397,9 @@ namespace vix::cli::build
397397 if (quiet || !progressVisible)
398398 return ;
399399
400- const std::size_t width = terminal_width ();
401-
402400 std::string clear;
403- clear += " \r " ;
404- clear.append (width, ' ' );
405- clear += " \n\r " ;
406- clear.append (width, ' ' );
401+ clear += " \r\033 [2K" ;
402+ clear += " \n\r\033 [2K" ;
407403 clear += " \033 [1A\r " ;
408404
409405 write_all_fd (STDOUT_FILENO , clear.data (), clear.size ());
@@ -417,22 +413,12 @@ namespace vix::cli::build
417413 if (quiet || !progressVisible)
418414 return ;
419415
420- const std::size_t width = terminal_width ();
421-
422416 std::string clear;
423417
424- // Cursor is below the 2-line progress block.
425- // Move to the first progress line.
426418 clear += " \033 [2A\r " ;
427-
428- // Clear first line.
429- clear.append (width, ' ' );
430-
431- // Move to second progress line and clear it.
419+ clear += " \033 [2K" ;
432420 clear += " \n\r " ;
433- clear.append (width, ' ' );
434-
435- // Return to the first progress line before rendering again.
421+ clear += " \033 [2K" ;
436422 clear += " \033 [1A\r " ;
437423
438424 write_all_fd (STDOUT_FILENO , clear.data (), clear.size ());
@@ -485,10 +471,20 @@ namespace vix::cli::build
485471 }
486472
487473 const std::size_t width = terminal_width ();
488- const int barWidth = width > 90 ? 28 : 18 ;
474+
475+ int barWidth = 28 ;
476+
477+ if (width < 90 )
478+ barWidth = 18 ;
479+
480+ if (width < 60 )
481+ barWidth = 10 ;
482+
483+ if (width < 45 )
484+ barWidth = 0 ;
489485
490486 const int filled =
491- total > 0
487+ total > 0 && barWidth > 0
492488 ? std::clamp (
493489 static_cast <int >(
494490 (static_cast <double >(current) / static_cast <double >(total)) *
@@ -498,26 +494,33 @@ namespace vix::cli::build
498494 : 0 ;
499495
500496 std::string bar;
501- bar += style::GRAY ;
502- bar += " [" ;
503- bar += style::CYAN ;
504- bar.append (static_cast <std::size_t >(filled), ' =' );
505- bar += style::GRAY ;
506- bar.append (static_cast <std::size_t >(barWidth - filled), ' -' );
507- bar += " ]" ;
508- bar += style::RESET ;
497+
498+ if (barWidth > 0 )
499+ {
500+ bar += style::GRAY ;
501+ bar += " [" ;
502+ bar += style::CYAN ;
503+ bar.append (static_cast <std::size_t >(filled), ' =' );
504+ bar += style::GRAY ;
505+ bar.append (static_cast <std::size_t >(barWidth - filled), ' -' );
506+ bar += " ]" ;
507+ bar += style::RESET ;
508+ }
509509
510510 const std::string action =
511511 truncate_progress_text (
512512 rest,
513- width > 6 ? width - 6 : width);
513+ width > 8 ? width - 8 : width);
514514
515515 std::ostringstream lineOut;
516+
516517 lineOut << " "
517- << style::CYAN << " build " << style::RESET
518- << bar
519- << " "
520- << style::CYAN << current << " /" << total << style::RESET
518+ << style::CYAN << " build " << style::RESET ;
519+
520+ if (!bar.empty ())
521+ lineOut << bar << " " ;
522+
523+ lineOut << style::CYAN << current << " /" << total << style::RESET
521524 << " \n "
522525 << " "
523526 << style::CYAN << " › " << style::RESET
@@ -540,18 +543,32 @@ namespace vix::cli::build
540543 return ;
541544
542545 const std::size_t width = terminal_width ();
543- const int barWidth = width > 90 ? 28 : 18 ;
546+
547+ int barWidth = 28 ;
548+
549+ if (width < 90 )
550+ barWidth = 18 ;
551+
552+ if (width < 60 )
553+ barWidth = 10 ;
554+
555+ if (width < 45 )
556+ barWidth = 0 ;
544557
545558 clear_rendered_progress_lines ();
546559
547560 std::string out;
548561 out += " " ;
549562 out += style::CYAN ;
550563 out += " build " ;
551- out += " [" ;
552- out.append (static_cast <std::size_t >(barWidth), ' =' );
553- out += " ]" ;
554- out += " done" ;
564+ if (barWidth > 0 )
565+ {
566+ out += " [" ;
567+ out.append (static_cast <std::size_t >(barWidth), ' =' );
568+ out += " ] " ;
569+ }
570+
571+ out += " done" ;
555572 out += style::RESET ;
556573 out += " \n " ;
557574
0 commit comments