hare

[hare] The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

commit 30e96588966a2e71264de8fd1db3dfae949bfce8
parent b099691b1550f521f047962aaff48f8d5320e89f
Author: Nikola <nikola@radojevic.rs>
Date:   Mon,  9 May 2022 21:22:25 +0200

driver: make progress bar width fixed

Signed-off-by: Nikola <nikola@radojevic.rs>

Diffstat:
Mcmd/hare/plan.ha | 1+
Mcmd/hare/progress.ha | 4++--
Mcmd/hare/schedule.ha | 2++
3 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/cmd/hare/plan.ha b/cmd/hare/plan.ha @@ -65,6 +65,7 @@ type plan_progress = struct { complete: size, total: size, current_module: str, + maxwidth: size, }; fn mkplan(ctx: *module::context, libs: []str) plan = { diff --git a/cmd/hare/progress.ha b/cmd/hare/progress.ha @@ -13,7 +13,7 @@ fn progress_update(plan: *plan) void = { const width = match (tty::winsize(tty)) { case let ts: tty::ttysize => - yield if (ts.columns > 64 || ts.columns == 0) 64 else ts.columns; + yield if (ts.columns > 80 || ts.columns == 0) 80 else ts.columns; case => yield 64; }: size; @@ -24,7 +24,7 @@ fn progress_update(plan: *plan) void = { const total_width = math::ceilf64(math::log10f64(total: f64)): size; const counter_width = 1 + total_width + 1 + total_width + 3; - const progress_width = width - counter_width - 2 - len(current_module); + const progress_width = width - counter_width - 2 - plan.progress.maxwidth; fmt::fprintf(tty, "\r\x1b[K[{%}/{}] [", complete, &fmt::modifiers { diff --git a/cmd/hare/schedule.ha b/cmd/hare/schedule.ha @@ -169,6 +169,8 @@ fn sched_hare_object( const ns = unparse::identstr(namespace); const displayed_ns = if (len(ns) == 0) "(root)" else ns; + if (len(ns) > plan.progress.maxwidth) + plan.progress.maxwidth = len(ns); let ssa = mkfile(plan, ns, "ssa"); let harec = alloc(task {