Ver Fonte

feat: sub-character block rendering (▏▎▍▌▋▊▉ for 1/8-7/8 fill); listing refresh logs; strategising initial bump to avoid 0% during SPM query

clanker há 1 semana atrás
pai
commit
638a510207
4 ficheiros alterados com 46 adições e 797 exclusões
  1. 1 792
      installer/install-usm.sh
  2. 2 0
      src/cli/Install.vala
  3. 42 5
      src/cli/ProgressBar.vala
  4. 1 0
      src/cli/Update.vala

Diff do ficheiro suprimidas por serem muito extensas
+ 1 - 792
installer/install-usm.sh


+ 2 - 0
src/cli/Install.vala

@@ -42,6 +42,7 @@ private int install_main(string[] args) {
             state.refresh_list(repo, (f, c, t) => {
                 progress.update_phase(t > 0 ? (float)c / (float)t : 0.0f);
             });
+            progress.phase_log(@"Refreshed $(repo.name) listing");
             progress.end_phase();
             var listing = state.get_latest_list(repo);
             if(listing != null) {
@@ -67,6 +68,7 @@ private int install_main(string[] args) {
         // repositories/cache, with candidate-group selection
         var spm = new Usm.SystemPackageManager(state.config);
         progress.begin_phase("Resolving dependencies");
+        progress.update_phase(0.05f);
         resolver.resolution_progress = (fraction) => {
             progress.update_phase(fraction);
         };

+ 42 - 5
src/cli/ProgressBar.vala

@@ -73,6 +73,12 @@ namespace Usm.Cli {
 
         private string bar_filled_char;
         private string bar_empty_char;
+        /**
+         * Partial-block characters for sub-cell fill precision, from 1/8
+         * to 7/8: ▏▎▍▌▋▊▉. Index 0 is the empty cell, index 8 the full
+         * cell, so `partial_blocks[eighths]` covers the whole range.
+         */
+        private string[] partial_blocks;
         private string action_mark;
         private string success_mark;
         private string failure_mark;
@@ -123,6 +129,12 @@ namespace Usm.Cli {
             unicode = get_charset(out charset);
             bar_filled_char = unicode ? "█" : "#";
             bar_empty_char = unicode ? "░" : " ";
+            if(unicode) {
+                partial_blocks = { "░", "▏", "▎", "▍", "▌", "▋", "▊", "▉", "█" };
+            }
+            else {
+                partial_blocks = { " ", ".", ":", "-", "=", "+", "*", "#", "#" };
+            }
             action_mark = unicode ? "→" : ">";
             success_mark = unicode ? "✓" : "+";
             failure_mark = unicode ? "✗" : "x";
@@ -398,9 +410,30 @@ namespace Usm.Cli {
         private string bar_text(int bar_zone, float fraction) {
             var percent = (int)(fraction * 100);
             var capacity = bar_zone - 6 - (unicode ? 0 : 2);
-            var filled = (int)(fraction * capacity + 0.5f);
-            if(filled > capacity) {
-                filled = capacity;
+
+            var exact = fraction * capacity;
+            if(exact < 0.0f) {
+                exact = 0.0f;
+            }
+            if(exact > capacity) {
+                exact = capacity;
+            }
+            var full = (int)exact;
+            var eighths = (int)((exact - full) * 8.0f + 0.5f);
+            if(eighths > 8) {
+                eighths = 8;
+            }
+            if(eighths > 0 && full < capacity) {
+                // The partial cell absorbs the fraction — full cells plus
+                // one partial, eighths 8 collapses into a full cell
+                if(eighths == 8) {
+                    full++;
+                    eighths = 0;
+                }
+            }
+            else if(eighths == 8) {
+                full++;
+                eighths = 0;
             }
 
             var cells = new StringBuilder();
@@ -408,10 +441,14 @@ namespace Usm.Cli {
             if(!unicode) {
                 cells.append("[");
             }
-            for(var i = 0; i < filled; i++) {
+            for(var i = 0; i < full; i++) {
                 cells.append(bar_filled_char);
             }
-            for(var i = filled; i < capacity; i++) {
+            if(full < capacity && eighths > 0) {
+                cells.append(partial_blocks[eighths]);
+                full++;
+            }
+            for(var i = full; i < capacity; i++) {
                 cells.append(bar_empty_char);
             }
             if(!unicode) {

+ 1 - 0
src/cli/Update.vala

@@ -53,6 +53,7 @@ private int update_main(string[] args) {
             state.refresh_list(repo, (f, c, t) => {
                 progress.update_phase(t > 0 ? (float)c / (float)t : 0.0f);
             });
+            progress.phase_log(@"Refreshed $(repo.name) listing");
             progress.end_phase();
             var listing = state.get_latest_list(repo);
             if(listing != null) {

Alguns ficheiros não foram mostrados porque muitos ficheiros mudaram neste diff