|
@@ -128,9 +128,9 @@ namespace Usm.Cli {
|
|
|
unowned string charset;
|
|
unowned string charset;
|
|
|
unicode = get_charset(out charset);
|
|
unicode = get_charset(out charset);
|
|
|
bar_filled_char = unicode ? "█" : "#";
|
|
bar_filled_char = unicode ? "█" : "#";
|
|
|
- bar_empty_char = unicode ? "░" : " ";
|
|
|
|
|
|
|
+ bar_empty_char = " ";
|
|
|
if(unicode) {
|
|
if(unicode) {
|
|
|
- partial_blocks = { "░", "▏", "▎", "▍", "▌", "▋", "▊", "▉", "█" };
|
|
|
|
|
|
|
+ partial_blocks = { " ", "▏", "▎", "▍", "▌", "▋", "▊", "▉", "█" };
|
|
|
}
|
|
}
|
|
|
else {
|
|
else {
|
|
|
partial_blocks = { " ", ".", ":", "-", "=", "+", "*", "#", "#" };
|
|
partial_blocks = { " ", ".", ":", "-", "=", "+", "*", "#", "#" };
|
|
@@ -349,7 +349,7 @@ namespace Usm.Cli {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private void draw_line() {
|
|
private void draw_line() {
|
|
|
- stderr.printf("\r\033[K%s%s%s", colour_for_task(current_task), line_text(), COLOUR_RESET);
|
|
|
|
|
|
|
+ stderr.printf("\r\033[K%s", line_text());
|
|
|
line_live = true;
|
|
line_live = true;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -367,11 +367,14 @@ namespace Usm.Cli {
|
|
|
private string line_text() {
|
|
private string line_text() {
|
|
|
var width = detect_terminal_width();
|
|
var width = detect_terminal_width();
|
|
|
var text_zone = int.max(14, width / 3);
|
|
var text_zone = int.max(14, width / 3);
|
|
|
|
|
+ var colour = colour_for_task(current_task);
|
|
|
|
|
|
|
|
var cells = new StringBuilder();
|
|
var cells = new StringBuilder();
|
|
|
|
|
+ cells.append(colour);
|
|
|
cells.append(zone_text(text_zone));
|
|
cells.append(zone_text(text_zone));
|
|
|
pad_to_zone(cells, text_zone);
|
|
pad_to_zone(cells, text_zone);
|
|
|
- cells.append(bar_text(width - text_zone, overall));
|
|
|
|
|
|
|
+ cells.append(COLOUR_RESET);
|
|
|
|
|
+ cells.append(bar_text(width - text_zone, overall, colour));
|
|
|
return cells.str;
|
|
return cells.str;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -387,7 +390,7 @@ namespace Usm.Cli {
|
|
|
var cells = new StringBuilder();
|
|
var cells = new StringBuilder();
|
|
|
cells.append(ellipsise(phase_label ?? "", text_zone));
|
|
cells.append(ellipsise(phase_label ?? "", text_zone));
|
|
|
pad_to_zone(cells, text_zone);
|
|
pad_to_zone(cells, text_zone);
|
|
|
- cells.append(bar_text(width - text_zone, phase_progress));
|
|
|
|
|
|
|
+ cells.append(bar_text(width - text_zone, phase_progress, null));
|
|
|
return cells.str;
|
|
return cells.str;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -400,14 +403,17 @@ namespace Usm.Cli {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * The bar zone proper — gap, `█`/`░` cells (`[#### ]` in the
|
|
|
|
|
- * ASCII fallback), gap and the fraction's percentage
|
|
|
|
|
- * right-aligned in a `100%`-wide field. The fixed percentage
|
|
|
|
|
- * field keeps the cell count constant from 0% to 100%, and the
|
|
|
|
|
- * fill uses + 0.5 rounding in plain arithmetic because the CLI
|
|
|
|
|
- * target does not link libm.
|
|
|
|
|
|
|
+ * The bar zone proper — gap, fill cells, gap and the fraction's
|
|
|
|
|
+ * percentage right-aligned in a `100%`-wide field.
|
|
|
|
|
+ *
|
|
|
|
|
+ * When {@link colour} is provided (transaction bar), filled cells
|
|
|
|
|
+ * render with identical foreground+background — a seamless solid
|
|
|
|
|
+ * bar with no inter-character gaps — and the partial cell carries
|
|
|
|
|
+ * a dim background so the bar's edge stays defined against the
|
|
|
|
|
+ * empty cells (plain spaces). Phase bars pass null and render
|
|
|
|
|
+ * partial-block characters on spaces.
|
|
|
*/
|
|
*/
|
|
|
- private string bar_text(int bar_zone, float fraction) {
|
|
|
|
|
|
|
+ private string bar_text(int bar_zone, float fraction, string? colour = null) {
|
|
|
var percent = (int)(fraction * 100);
|
|
var percent = (int)(fraction * 100);
|
|
|
var capacity = bar_zone - 6 - (unicode ? 0 : 2);
|
|
var capacity = bar_zone - 6 - (unicode ? 0 : 2);
|
|
|
|
|
|
|
@@ -423,15 +429,7 @@ namespace Usm.Cli {
|
|
|
if(eighths > 8) {
|
|
if(eighths > 8) {
|
|
|
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) {
|
|
|
|
|
|
|
+ if(eighths == 8) {
|
|
|
full++;
|
|
full++;
|
|
|
eighths = 0;
|
|
eighths = 0;
|
|
|
}
|
|
}
|
|
@@ -441,16 +439,39 @@ namespace Usm.Cli {
|
|
|
if(!unicode) {
|
|
if(!unicode) {
|
|
|
cells.append("[");
|
|
cells.append("[");
|
|
|
}
|
|
}
|
|
|
- for(var i = 0; i < full; i++) {
|
|
|
|
|
- cells.append(bar_filled_char);
|
|
|
|
|
- }
|
|
|
|
|
- if(full < capacity && eighths > 0) {
|
|
|
|
|
- cells.append(partial_blocks[eighths]);
|
|
|
|
|
- full++;
|
|
|
|
|
|
|
+
|
|
|
|
|
+ if(colour != null && unicode) {
|
|
|
|
|
+ var bg = colour.replace("[3", "[4");
|
|
|
|
|
+ cells.append(colour);
|
|
|
|
|
+ cells.append(bg);
|
|
|
|
|
+ for(var i = 0; i < full; i++) {
|
|
|
|
|
+ cells.append(" ");
|
|
|
|
|
+ }
|
|
|
|
|
+ if(full < capacity && eighths > 0) {
|
|
|
|
|
+ cells.append("\033[49m");
|
|
|
|
|
+ cells.append(colour);
|
|
|
|
|
+ cells.append("\033[100m");
|
|
|
|
|
+ cells.append(partial_blocks[eighths]);
|
|
|
|
|
+ full++;
|
|
|
|
|
+ }
|
|
|
|
|
+ cells.append("\033[0m");
|
|
|
|
|
+ for(var i = full; i < capacity; i++) {
|
|
|
|
|
+ cells.append(" ");
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
- for(var i = full; i < capacity; i++) {
|
|
|
|
|
- cells.append(bar_empty_char);
|
|
|
|
|
|
|
+ else {
|
|
|
|
|
+ for(var i = 0; i < full; i++) {
|
|
|
|
|
+ cells.append(bar_filled_char);
|
|
|
|
|
+ }
|
|
|
|
|
+ if(full < capacity && eighths > 0) {
|
|
|
|
|
+ cells.append(partial_blocks[eighths]);
|
|
|
|
|
+ full++;
|
|
|
|
|
+ }
|
|
|
|
|
+ for(var i = full; i < capacity; i++) {
|
|
|
|
|
+ cells.append(" ");
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
if(!unicode) {
|
|
if(!unicode) {
|
|
|
cells.append("]");
|
|
cells.append("]");
|
|
|
}
|
|
}
|