guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

02/02: guix: Properly compute progress bar width.


From: guix-commits
Subject: 02/02: guix: Properly compute progress bar width.
Date: Sat, 11 Nov 2023 05:09:28 -0500 (EST)

roptat pushed a commit to branch master
in repository guix.

commit 28ca80717da67f90a3b33491e9807a053cf09c2d
Author: Julien Lepiller <julien@lepiller.eu>
AuthorDate: Sat Nov 11 11:02:07 2023 +0100

    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
---
 guix/git.scm      | 4 +++-
 guix/progress.scm | 4 +++-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/guix/git.scm b/guix/git.scm
index b7182305cf..4377b27e00 100644
--- a/guix/git.scm
+++ b/guix/git.scm
@@ -33,6 +33,8 @@
   #:use-module (guix store)
   #:use-module (guix utils)
   #:use-module (guix records)
+  #:use-module ((guix build syscalls)
+                #:select (terminal-string-width))
   #:use-module (guix gexp)
   #:autoload   (guix git-download)
   (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.
   (define width
     (max (- (current-terminal-columns)
-            (string-length label) 7)
+            (terminal-string-width label) 7)
          3))
 
   (define grain
diff --git a/guix/progress.scm b/guix/progress.scm
index 33cf6f4a1a..13d3ddc171 100644
--- a/guix/progress.scm
+++ b/guix/progress.scm
@@ -21,6 +21,8 @@
 
 (define-module (guix progress)
   #:use-module (guix records)
+  #:use-module ((guix build syscalls)
+                #:select (terminal-string-width))
   #:use-module (srfi srfi-19)
   #:use-module (rnrs io ports)
   #:use-module (rnrs bytevectors)
@@ -307,7 +309,7 @@ tasks is performed.  Write PREFIX at the beginning of the 
line."
       (if (string-null? prefix)
           (display (progress-bar ratio (current-terminal-columns)) port)
           (let ((width (- (current-terminal-columns)
-                          (string-length prefix) 3)))
+                          (terminal-string-width prefix) 3)))
             (display prefix port)
             (display "  " port)
             (display (progress-bar ratio width) port)))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]