me
/
guix
Archived
1
0
Fork 0

guix: Properly compute progress bar width.

* guix/progress.scm (progress-reporter/bar): Take font width into account to
compute progress bar width.
* guix/git.scm (show-progress): Take font width into account to compute
progress bar width.

Change-Id: I946e447c1ea7c6eb4ff805400280f39e8f1a7c02
master
Julien Lepiller 2023-11-11 11:02:07 +01:00
parent fd11d7fbf8
commit 28ca80717d
No known key found for this signature in database
GPG Key ID: 53D457B2D636EE82
2 changed files with 6 additions and 2 deletions

View File

@ -33,6 +33,8 @@
#:use-module (guix store) #:use-module (guix store)
#:use-module (guix utils) #:use-module (guix utils)
#:use-module (guix records) #:use-module (guix records)
#:use-module ((guix build syscalls)
#:select (terminal-string-width))
#:use-module (guix gexp) #:use-module (guix gexp)
#:autoload (guix git-download) #:autoload (guix git-download)
(git-reference-url git-reference-commit git-reference-recursive?) (git-reference-url git-reference-commit git-reference-recursive?)
@ -154,7 +156,7 @@ the 'SSL_CERT_FILE' and 'SSL_CERT_DIR' environment variables."
;; TODO: Both should be handled & exposed by the PROGRESS-BAR API instead. ;; TODO: Both should be handled & exposed by the PROGRESS-BAR API instead.
(define width (define width
(max (- (current-terminal-columns) (max (- (current-terminal-columns)
(string-length label) 7) (terminal-string-width label) 7)
3)) 3))
(define grain (define grain

View File

@ -21,6 +21,8 @@
(define-module (guix progress) (define-module (guix progress)
#:use-module (guix records) #:use-module (guix records)
#:use-module ((guix build syscalls)
#:select (terminal-string-width))
#:use-module (srfi srfi-19) #:use-module (srfi srfi-19)
#:use-module (rnrs io ports) #:use-module (rnrs io ports)
#:use-module (rnrs bytevectors) #:use-module (rnrs bytevectors)
@ -307,7 +309,7 @@ tasks is performed. Write PREFIX at the beginning of the line."
(if (string-null? prefix) (if (string-null? prefix)
(display (progress-bar ratio (current-terminal-columns)) port) (display (progress-bar ratio (current-terminal-columns)) port)
(let ((width (- (current-terminal-columns) (let ((width (- (current-terminal-columns)
(string-length prefix) 3))) (terminal-string-width prefix) 3)))
(display prefix port) (display prefix port)
(display " " port) (display " " port)
(display (progress-bar ratio width) port))) (display (progress-bar ratio width) port)))