|
|
@@ -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) {
|