download: Add 'current-terminal-columns' parameter.
* guix/build/download.scm (current-terminal-columns): New variable. (progress-proc): Use it instead of the hard-coded "80".
This commit is contained in:
parent
8a2154fefa
commit
4d276c6403
|
@ -39,6 +39,7 @@
|
||||||
maybe-expand-mirrors
|
maybe-expand-mirrors
|
||||||
url-fetch
|
url-fetch
|
||||||
byte-count->string
|
byte-count->string
|
||||||
|
current-terminal-columns
|
||||||
progress-proc
|
progress-proc
|
||||||
uri-abbreviation
|
uri-abbreviation
|
||||||
store-path-abbreviation))
|
store-path-abbreviation))
|
||||||
|
@ -53,6 +54,10 @@
|
||||||
;; Size of the HTTP receive buffer.
|
;; Size of the HTTP receive buffer.
|
||||||
65536)
|
65536)
|
||||||
|
|
||||||
|
(define current-terminal-columns
|
||||||
|
;; Number of columns of the terminal.
|
||||||
|
(make-parameter 80))
|
||||||
|
|
||||||
(define (nearest-exact-integer x)
|
(define (nearest-exact-integer x)
|
||||||
"Given a real number X, return the nearest exact integer, with ties going to
|
"Given a real number X, return the nearest exact integer, with ties going to
|
||||||
the nearest exact even integer."
|
the nearest exact even integer."
|
||||||
|
@ -166,9 +171,10 @@ used to shorten FILE for display."
|
||||||
(byte-count->string throughput)
|
(byte-count->string throughput)
|
||||||
(seconds->string elapsed)
|
(seconds->string elapsed)
|
||||||
(progress-bar %) %)))
|
(progress-bar %) %)))
|
||||||
;; TODO: Make this adapt to the actual terminal width.
|
|
||||||
(display "\r\x1b[K" log-port)
|
(display "\r\x1b[K" log-port)
|
||||||
(display (string-pad-middle left right 80) log-port)
|
(display (string-pad-middle left right
|
||||||
|
(current-terminal-columns))
|
||||||
|
log-port)
|
||||||
(flush-output-port log-port)
|
(flush-output-port log-port)
|
||||||
(cont))))
|
(cont))))
|
||||||
(lambda (transferred cont)
|
(lambda (transferred cont)
|
||||||
|
@ -182,9 +188,10 @@ used to shorten FILE for display."
|
||||||
(byte-count->string throughput)
|
(byte-count->string throughput)
|
||||||
(seconds->string elapsed)
|
(seconds->string elapsed)
|
||||||
(byte-count->string transferred))))
|
(byte-count->string transferred))))
|
||||||
;; TODO: Make this adapt to the actual terminal width.
|
|
||||||
(display "\r\x1b[K" log-port)
|
(display "\r\x1b[K" log-port)
|
||||||
(display (string-pad-middle left right 80) log-port)
|
(display (string-pad-middle left right
|
||||||
|
(current-terminal-columns))
|
||||||
|
log-port)
|
||||||
(flush-output-port log-port)
|
(flush-output-port log-port)
|
||||||
(cont))))))))
|
(cont))))))))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue