Fix TUI debug output and GPU bar rendering
ober
3076787eec54cb5605504598edcf8b966a93992a
--- a/src/jcode/core/debug-repl.ss +++ b/src/jcode/core/debug-repl.ss @@ -188,16 +188,19 @@ e)) op) (flush-output-port op)]) - (call-with-values - (lambda () (eval expr (interaction-environment))) - (lambda results - (for-each - (lambda (v) - (unless (eq? v (void)) - (write v op) - (newline op))) - results) - (flush-output-port op)))) + (parameterize ((current-input-port ip) + (current-output-port op) + (current-error-port op)) + (call-with-values + (lambda () (eval expr (interaction-environment))) + (lambda results + (for-each + (lambda (v) + (unless (eq? v (void)) + (write v op) + (newline op))) + results) + (flush-output-port op))))) (loop))))))) (lambda () (guard (e [#t (void)]) (close-port ip)) --- a/src/jcode/ui/tui-sidebar.ss +++ b/src/jcode/ui/tui-sidebar.ss @@ -235,12 +235,18 @@ (let* ((label-w 4) (pct-w 5) (bar-w (max 1 (- total-width label-w pct-w))) - (filled (if pct - (max 0 (min bar-w (exact (round (* bar-w (/ pct 100.0)))))) - 0)) + (clamped-pct (and pct (max 0.0 (min 100.0 pct)))) + (display-pct (if clamped-pct (exact (round clamped-pct)) 0)) + (raw-filled (if clamped-pct + (exact (round (* bar-w (/ clamped-pct 100.0)))) + 0)) + (filled (cond + ((not clamped-pct) 0) + ((and (> display-pct 0) (= raw-filled 0)) 1) + (else (max 0 (min bar-w raw-filled))))) (empty (- bar-w filled)) - (fill-face (cond ((not pct) 'horizontal-rule) - ((>= pct 85) 'error) + (fill-face (cond ((not clamped-pct) 'horizontal-rule) + ((>= clamped-pct 85) 'error) (#t 'tool-name))) (label-padded (pad-right (truncate-string label 3) 4)) (pct-str (format-pct pct)))