* [bug#59975] [PATCH] guix: Show better progress bars.
@ 2022-12-11 18:00 Julien Lepiller
2022-12-21 16:20 ` Julien Lepiller
` (2 more replies)
0 siblings, 3 replies; 12+ messages in thread
From: Julien Lepiller @ 2022-12-11 18:00 UTC (permalink / raw)
To: 59975
[-- Attachment #1: Type: text/plain, Size: 603 bytes --]
Hi Guix!
The attached patch is a small improvement on our progress bars. Instead
of our cute ASCII art:
1.2MiB/s 00:04 [### ] 18.5%
We get something a little more smooth:
1.1MiB/s 00:04 ▕███ ▏ 17.1%
1.2MiB/s 00:05 ▕███▋ ▏ 20.7%
Using unicode characters that can represent 1/8 of a character width.
I used port-encoding to detect when the output supports unicode, but
maybe there's something more dedicated to figuring that out? When the
port encoding is not UTF-8, we fall back to the ASCII version.
Thoughts?
[-- Attachment #2: 0001-guix-Show-better-progress-bars.patch --]
[-- Type: text/x-patch, Size: 2794 bytes --]
From c428c80fd628797ae80029a0a22678ef55c68d6c Mon Sep 17 00:00:00 2001
From: Julien Lepiller <julien@lepiller.eu>
Date: Sun, 11 Dec 2022 18:51:13 +0100
Subject: [PATCH] guix: Show better progress bars.
* guix/progress.scm (progress-bar): When supported, use unicode variant.
---
guix/progress.scm | 43 ++++++++++++++++++++++++++++++++++++-------
1 file changed, 36 insertions(+), 7 deletions(-)
diff --git a/guix/progress.scm b/guix/progress.scm
index 4f8e98edc0..527bf72839 100644
--- a/guix/progress.scm
+++ b/guix/progress.scm
@@ -166,16 +166,45 @@ (define current-terminal-columns
;; Number of columns of the terminal.
(make-parameter 80))
+(define-record-type* <progress-bar-style>
+ progress-bar-style make-progress-bar-style progress-bar-style?
+ (start progress-bar-style-start
+ (default #\x2595))
+ (stop progress-bar-style-stop
+ (default #\x258f))
+ (filled progress-bar-style-filled
+ (default #\x2588))
+ (steps progress-bar-style-steps
+ (default '(#\x258F #\x258E #\x258D #\x258C #\x258B #\x258A #\x2589))))
+
+(define unicode-bar-style (progress-bar-style))
+(define ascii-bar-style
+ (progress-bar-style
+ (start #\[)
+ (stop #\])
+ (filled #\#)
+ (steps '())))
+
(define* (progress-bar % #:optional (bar-width 20))
"Return % as a string representing an ASCII-art progress bar. The total
width of the bar is BAR-WIDTH."
- (let* ((bar-width (max 3 (- bar-width 2)))
- (fraction (/ % 100))
- (filled (inexact->exact (floor (* fraction bar-width))))
- (empty (- bar-width filled)))
- (format #f "[~a~a]"
- (make-string filled #\#)
- (make-string empty #\space))))
+ (let* ((bar-style (if (equal? (port-encoding (current-output-port)) "UTF-8")
+ unicode-bar-style
+ ascii-bar-style))
+ (bar-width (max 3 (- bar-width 2)))
+ (intermediates (+ (length (progress-bar-style-steps bar-style)) 1))
+ (step (inexact->exact (floor (/ (* % bar-width intermediates) 100))))
+ (filled (quotient step intermediates))
+ (intermediate
+ (list-ref (cons #f (progress-bar-style-steps bar-style))
+ (modulo step intermediates)))
+ (empty (- bar-width filled (if intermediate 1 0))))
+ (format #f "~a~a~a~a~a"
+ (string (progress-bar-style-start bar-style))
+ (make-string filled (progress-bar-style-filled bar-style))
+ (if intermediate (string intermediate) "")
+ (make-string empty #\space)
+ (string (progress-bar-style-stop bar-style)))))
(define (erase-current-line port)
"Write an ANSI erase-current-line sequence to PORT to erase the whole line and
--
2.38.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [bug#59975] [PATCH] guix: Show better progress bars.
2022-12-11 18:00 [bug#59975] [PATCH] guix: Show better progress bars Julien Lepiller
@ 2022-12-21 16:20 ` Julien Lepiller
2023-01-06 17:45 ` Simon Tournier
2023-01-13 17:07 ` Ludovic Courtès
2023-02-03 11:56 ` [bug#59975] [PATCH v3 0/2] " Julien Lepiller
2 siblings, 1 reply; 12+ messages in thread
From: Julien Lepiller @ 2022-12-21 16:20 UTC (permalink / raw)
To: 59975
[-- Attachment #1: Type: text/plain, Size: 813 bytes --]
Hi Guix!
The patch is pretty simple, but I'm surprised nobody bikeshedded yet :)
Thoughts?
Le 11 décembre 2022 19:00:59 GMT+01:00, Julien Lepiller <julien@lepiller.eu> a écrit :
>Hi Guix!
>
>The attached patch is a small improvement on our progress bars. Instead
>of our cute ASCII art:
>
>1.2MiB/s 00:04 [### ] 18.5%
>
>We get something a little more smooth:
>
>1.1MiB/s 00:04 ▕███ ▏ 17.1%
>1.2MiB/s 00:05 ▕███▋ ▏ 20.7%
>
>Using unicode characters that can represent 1/8 of a character width.
>
>I used port-encoding to detect when the output supports unicode, but
>maybe there's something more dedicated to figuring that out? When the
>port encoding is not UTF-8, we fall back to the ASCII version.
>
>Thoughts?
[-- Attachment #2: Type: text/html, Size: 1103 bytes --]
^ permalink raw reply [flat|nested] 12+ messages in thread
* [bug#59975] [PATCH] guix: Show better progress bars.
2022-12-21 16:20 ` Julien Lepiller
@ 2023-01-06 17:45 ` Simon Tournier
0 siblings, 0 replies; 12+ messages in thread
From: Simon Tournier @ 2023-01-06 17:45 UTC (permalink / raw)
To: Julien Lepiller, 59975
Hi Julien,
> Le 11 décembre 2022 19:00:59 GMT+01:00, Julien Lepiller <julien@lepiller.eu> a écrit :
>>1.1MiB/s 00:04 ▕███ ▏ 17.1%
>>1.2MiB/s 00:05 ▕███▋ ▏ 20.7%
On Wed, 21 Dec 2022 at 17:20, Julien Lepiller <julien@lepiller.eu> wrote:
> The patch is pretty simple, but I'm surprised nobody bikeshedded yet :)
Personally, I am not fan of fancy Unicode. :-) But the patch LGTM.
Well, if there is no strong objection and since it is more than 25 days,
maybe you could apply it after waiting a couple more of days. :-)
Cheers,
simon
^ permalink raw reply [flat|nested] 12+ messages in thread
* [bug#59975] [PATCH] guix: Show better progress bars.
2022-12-11 18:00 [bug#59975] [PATCH] guix: Show better progress bars Julien Lepiller
2022-12-21 16:20 ` Julien Lepiller
@ 2023-01-13 17:07 ` Ludovic Courtès
2023-01-15 10:12 ` Julien Lepiller
2023-02-03 11:56 ` [bug#59975] [PATCH v3 0/2] " Julien Lepiller
2 siblings, 1 reply; 12+ messages in thread
From: Ludovic Courtès @ 2023-01-13 17:07 UTC (permalink / raw)
To: Julien Lepiller; +Cc: 59975
Hello!
Julien Lepiller <julien@lepiller.eu> skribis:
> Hi Guix!
>
> The attached patch is a small improvement on our progress bars. Instead
> of our cute ASCII art:
>
> 1.2MiB/s 00:04 [### ] 18.5%
>
> We get something a little more smooth:
>
> 1.1MiB/s 00:04 ▕███ ▏ 17.1%
> 1.2MiB/s 00:05 ▕███▋ ▏ 20.7%
>
> Using unicode characters that can represent 1/8 of a character width.
Woow, fancy! Love it!! Too bad I was too late to have it under the
Newtonmas tree. 🎄
> I used port-encoding to detect when the output supports unicode, but
> maybe there's something more dedicated to figuring that out? When the
> port encoding is not UTF-8, we fall back to the ASCII version.
One question: how likely is it that people won’t have a font with those
glyphs to display it correctly?
It would be good to check in xterm, Linux console with some default
font, and GNOME/Xfce terminals with defaults.
(Works for me in xterm and in Emacs, FWIW.)
>>From c428c80fd628797ae80029a0a22678ef55c68d6c Mon Sep 17 00:00:00 2001
> From: Julien Lepiller <julien@lepiller.eu>
> Date: Sun, 11 Dec 2022 18:51:13 +0100
> Subject: [PATCH] guix: Show better progress bars.
>
> * guix/progress.scm (progress-bar): When supported, use unicode variant.
Please describe all the changes.
> +(define-record-type* <progress-bar-style>
> + progress-bar-style make-progress-bar-style progress-bar-style?
> + (start progress-bar-style-start
> + (default #\x2595))
> + (stop progress-bar-style-stop
> + (default #\x258f))
> + (filled progress-bar-style-filled
> + (default #\x2588))
> + (steps progress-bar-style-steps
> + (default '(#\x258F #\x258E #\x258D #\x258C #\x258B #\x258A #\x2589))))
> +
> +(define unicode-bar-style (progress-bar-style))
How about just dropping the ‘default’ bits and being explicit here?
> + (let* ((bar-style (if (equal? (port-encoding (current-output-port)) "UTF-8")
> + unicode-bar-style
> + ascii-bar-style))
In theory you want to check for Unicode-capable, not UTF-8-encoded.
There are ways to do that (see ‘right-arrow’ in (guix ui)), but it’s
more expensive and trickier, so what you’re doing here is good enough
IMO (I actually did that in (guix scripts weather) too).
> + (bar-width (max 3 (- bar-width 2)))
> + (intermediates (+ (length (progress-bar-style-steps bar-style)) 1))
> + (step (inexact->exact (floor (/ (* % bar-width intermediates) 100))))
> + (filled (quotient step intermediates))
> + (intermediate
> + (list-ref (cons #f (progress-bar-style-steps bar-style))
> + (modulo step intermediates)))
> + (empty (- bar-width filled (if intermediate 1 0))))
> + (format #f "~a~a~a~a~a"
s/format/simple-format/ for slightly better performance.
Otherwise LGTM, thanks!
Ludo’.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [bug#59975] [PATCH] guix: Show better progress bars.
2023-01-13 17:07 ` Ludovic Courtès
@ 2023-01-15 10:12 ` Julien Lepiller
2023-01-17 9:06 ` Ludovic Courtès
0 siblings, 1 reply; 12+ messages in thread
From: Julien Lepiller @ 2023-01-15 10:12 UTC (permalink / raw)
To: Ludovic Courtès; +Cc: 59975
[-- Attachment #1: Type: text/plain, Size: 1483 bytes --]
Le Fri, 13 Jan 2023 18:07:42 +0100,
Ludovic Courtès <ludo@gnu.org> a écrit :
> Hello!
>
> Julien Lepiller <julien@lepiller.eu> skribis:
>
> > Hi Guix!
> >
> > The attached patch is a small improvement on our progress bars.
> > Instead of our cute ASCII art:
> >
> > 1.2MiB/s 00:04 [### ] 18.5%
> >
> > We get something a little more smooth:
> >
> > 1.1MiB/s 00:04 ▕███ ▏ 17.1%
> > 1.2MiB/s 00:05 ▕███▋ ▏ 20.7%
> >
> > Using unicode characters that can represent 1/8 of a character
> > width.
>
> Woow, fancy! Love it!! Too bad I was too late to have it under the
> Newtonmas tree. 🎄
>
> > I used port-encoding to detect when the output supports unicode, but
> > maybe there's something more dedicated to figuring that out? When
> > the port encoding is not UTF-8, we fall back to the ASCII version.
>
> One question: how likely is it that people won’t have a font with
> those glyphs to display it correctly?
>
> It would be good to check in xterm, Linux console with some default
> font, and GNOME/Xfce terminals with defaults.
>
> (Works for me in xterm and in Emacs, FWIW.)
I think it's pretty common to have these characters, since they are
used by many other projects. However, testing on a tty, I can only see
the filled characters, but not the semi-filled ones, so I get something
like:
?███? ?
What do you think?
Attached v2.
[-- Attachment #2: 0001-guix-Show-better-progress-bars.patch --]
[-- Type: text/x-patch, Size: 3267 bytes --]
From 7e4c8fbcc49068ce5a9a592d8daf7b0039ce6680 Mon Sep 17 00:00:00 2001
From: Julien Lepiller <julien@lepiller.eu>
Date: Sun, 11 Dec 2022 18:51:13 +0100
Subject: [PATCH] guix: Show better progress bars.
Style provides information on the characters to use before and after the
progress bar content (`[` and `]` for the ascii style), as well as the
character for filled step (`#` for ascii style). When supported, it
provides intermediate steps. This is used for unicode style, to show
better precision.
* guix/progress.scm (<progress-bar-style>): New record type.
(ascii-bar-style, unicode-bar-style): New variables.
(progress-bar): Draw progress depending on style. When supported, use
unicode style. Fall back to ascii style.
---
guix/progress.scm | 45 ++++++++++++++++++++++++++++++++++++++-------
1 file changed, 38 insertions(+), 7 deletions(-)
diff --git a/guix/progress.scm b/guix/progress.scm
index 4f8e98edc0..33cf6f4a1a 100644
--- a/guix/progress.scm
+++ b/guix/progress.scm
@@ -166,16 +166,47 @@ (define current-terminal-columns
;; Number of columns of the terminal.
(make-parameter 80))
+(define-record-type* <progress-bar-style>
+ progress-bar-style make-progress-bar-style progress-bar-style?
+ (start progress-bar-style-start)
+ (stop progress-bar-style-stop)
+ (filled progress-bar-style-filled)
+ (steps progress-bar-style-steps))
+
+(define ascii-bar-style
+ (progress-bar-style
+ (start #\[)
+ (stop #\])
+ (filled #\#)
+ (steps '())))
+
+(define unicode-bar-style
+ (progress-bar-style
+ (start #\x2595)
+ (stop #\x258f)
+ (filled #\x2588)
+ (steps '(#\x258F #\x258E #\x258D #\x258C #\x258B #\x258A #\x2589))))
+
(define* (progress-bar % #:optional (bar-width 20))
"Return % as a string representing an ASCII-art progress bar. The total
width of the bar is BAR-WIDTH."
- (let* ((bar-width (max 3 (- bar-width 2)))
- (fraction (/ % 100))
- (filled (inexact->exact (floor (* fraction bar-width))))
- (empty (- bar-width filled)))
- (format #f "[~a~a]"
- (make-string filled #\#)
- (make-string empty #\space))))
+ (let* ((bar-style (if (equal? (port-encoding (current-output-port)) "UTF-8")
+ unicode-bar-style
+ ascii-bar-style))
+ (bar-width (max 3 (- bar-width 2)))
+ (intermediates (+ (length (progress-bar-style-steps bar-style)) 1))
+ (step (inexact->exact (floor (/ (* % bar-width intermediates) 100))))
+ (filled (quotient step intermediates))
+ (intermediate
+ (list-ref (cons #f (progress-bar-style-steps bar-style))
+ (modulo step intermediates)))
+ (empty (- bar-width filled (if intermediate 1 0))))
+ (simple-format #f "~a~a~a~a~a"
+ (string (progress-bar-style-start bar-style))
+ (make-string filled (progress-bar-style-filled bar-style))
+ (if intermediate (string intermediate) "")
+ (make-string empty #\space)
+ (string (progress-bar-style-stop bar-style)))))
(define (erase-current-line port)
"Write an ANSI erase-current-line sequence to PORT to erase the whole line and
--
2.38.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [bug#59975] [PATCH] guix: Show better progress bars.
2023-01-15 10:12 ` Julien Lepiller
@ 2023-01-17 9:06 ` Ludovic Courtès
2023-01-27 18:05 ` Simon Tournier
0 siblings, 1 reply; 12+ messages in thread
From: Ludovic Courtès @ 2023-01-17 9:06 UTC (permalink / raw)
To: Julien Lepiller; +Cc: 59975
Hi,
Julien Lepiller <julien@lepiller.eu> skribis:
> Le Fri, 13 Jan 2023 18:07:42 +0100,
> Ludovic Courtès <ludo@gnu.org> a écrit :
[...]
>> It would be good to check in xterm, Linux console with some default
>> font, and GNOME/Xfce terminals with defaults.
>>
>> (Works for me in xterm and in Emacs, FWIW.)
>
> I think it's pretty common to have these characters, since they are
> used by many other projects. However, testing on a tty, I can only see
> the filled characters, but not the semi-filled ones, so I get something
> like:
>
> ?███? ?
>
> What do you think?
Maybe use ASCII when $TERM is “linux”?
Though again that probably depends on the font, not on the terminal
type, and that you cannot guess.
> Attached v2.
>
> From 7e4c8fbcc49068ce5a9a592d8daf7b0039ce6680 Mon Sep 17 00:00:00 2001
> From: Julien Lepiller <julien@lepiller.eu>
> Date: Sun, 11 Dec 2022 18:51:13 +0100
> Subject: [PATCH] guix: Show better progress bars.
>
> Style provides information on the characters to use before and after the
> progress bar content (`[` and `]` for the ascii style), as well as the
> character for filled step (`#` for ascii style). When supported, it
> provides intermediate steps. This is used for unicode style, to show
> better precision.
>
> * guix/progress.scm (<progress-bar-style>): New record type.
> (ascii-bar-style, unicode-bar-style): New variables.
> (progress-bar): Draw progress depending on style. When supported, use
> unicode style. Fall back to ascii style.
LGTM.
Maybe send a heads-up on guix-devel to see if someone has something to
say about the ability to display those glyphs, wait a few more days, and
push if there are no objections?
Thanks,
Ludo’.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [bug#59975] [PATCH] guix: Show better progress bars.
2023-01-17 9:06 ` Ludovic Courtès
@ 2023-01-27 18:05 ` Simon Tournier
0 siblings, 0 replies; 12+ messages in thread
From: Simon Tournier @ 2023-01-27 18:05 UTC (permalink / raw)
To: Ludovic Courtès, Julien Lepiller; +Cc: 59975
Hi,
On mar., 17 janv. 2023 at 10:06, Ludovic Courtès <ludo@gnu.org> wrote:
> LGTM.
And it LGTM too [1]. :-)
1: <https://issues.guix.gnu.org/msgid/87358nh7zn.fsf@gmail.com>
> Maybe send a heads-up on guix-devel to see if someone has something to
> say about the ability to display those glyphs, wait a few more days, and
> push if there are no objections?
What is the status of this patch? I am sure people will find it
nice. :-)
Cheers,
simon
^ permalink raw reply [flat|nested] 12+ messages in thread
* [bug#59975] [PATCH v3 0/2] guix: Show better progress bars.
2022-12-11 18:00 [bug#59975] [PATCH] guix: Show better progress bars Julien Lepiller
2022-12-21 16:20 ` Julien Lepiller
2023-01-13 17:07 ` Ludovic Courtès
@ 2023-02-03 11:56 ` Julien Lepiller
2023-02-03 11:56 ` [bug#59975] [PATCH v3 1/2] gnu: Use unifont by default in TTYs Julien Lepiller
` (2 more replies)
2 siblings, 3 replies; 12+ messages in thread
From: Julien Lepiller @ 2023-02-03 11:56 UTC (permalink / raw)
To: 59975
Hi Guix!
Here's the new version, it's now a small series. The first patch sets
unifont as default, so we can see the fancy bars in a TTY :) The second
hasn't changed.
Julien Lepiller (2):
gnu: Use unifont by default in TTYs.
guix: Show better progress bars.
gnu/services/base.scm | 7 +++----
guix/progress.scm | 45 ++++++++++++++++++++++++++++++++++++-------
2 files changed, 41 insertions(+), 11 deletions(-)
base-commit: 92755c6352fd967bc74d8e5354aad057d779b717
--
2.38.1
^ permalink raw reply [flat|nested] 12+ messages in thread
* [bug#59975] [PATCH v3 1/2] gnu: Use unifont by default in TTYs.
2023-02-03 11:56 ` [bug#59975] [PATCH v3 0/2] " Julien Lepiller
@ 2023-02-03 11:56 ` Julien Lepiller
2023-02-03 11:56 ` [bug#59975] [PATCH v3 2/2] guix: Show better progress bars Julien Lepiller
2023-02-12 10:02 ` [bug#59975] [PATCH v3 0/2] " Christopher Baines
2 siblings, 0 replies; 12+ messages in thread
From: Julien Lepiller @ 2023-02-03 11:56 UTC (permalink / raw)
To: 59975
It has even better language support than LatGrkCyr-8x16 and can show
fancy progress bars.
* gnu/services/base.scm (%default-console-font): Use unifont.
---
gnu/services/base.scm | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/gnu/services/base.scm b/gnu/services/base.scm
index 9e799445d2..b062e445f2 100644
--- a/gnu/services/base.scm
+++ b/gnu/services/base.scm
@@ -64,6 +64,7 @@ (define-module (gnu services base)
#:select (coreutils glibc glibc-utf8-locales tar
canonical-package))
#:use-module ((gnu packages compression) #:select (gzip))
+ #:use-module (gnu packages fonts)
#:autoload (gnu packages guile-xyz) (guile-netlink)
#:autoload (gnu packages hurd) (hurd)
#:use-module (gnu packages package-management)
@@ -749,10 +750,8 @@ (define console-keymap-service-type
of console keymaps with @command{loadkeys}.")))
(define %default-console-font
- ;; Note: 'LatGrkCyr-8x16' has the advantage of providing three common
- ;; scripts as well as glyphs for em dash, quotation marks, and other Unicode
- ;; codepoints notably found in the UTF-8 manual.
- "LatGrkCyr-8x16")
+ #~(string-append #$font-gnu-unifont:psf
+ "/share/consolefonts/Unifont-APL8x16.psf.gz"))
(define (console-font-shepherd-services tty+font)
"Return a list of Shepherd services for each pair in TTY+FONT."
--
2.38.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [bug#59975] [PATCH v3 2/2] guix: Show better progress bars.
2023-02-03 11:56 ` [bug#59975] [PATCH v3 0/2] " Julien Lepiller
2023-02-03 11:56 ` [bug#59975] [PATCH v3 1/2] gnu: Use unifont by default in TTYs Julien Lepiller
@ 2023-02-03 11:56 ` Julien Lepiller
2023-02-12 10:02 ` [bug#59975] [PATCH v3 0/2] " Christopher Baines
2 siblings, 0 replies; 12+ messages in thread
From: Julien Lepiller @ 2023-02-03 11:56 UTC (permalink / raw)
To: 59975
Style provides information on the characters to use before and after the
progress bar content (`[` and `]` for the ascii style), as well as the
character for filled step (`#` for ascii style). When supported, it
provides intermediate steps. This is used for unicode style, to show
better precision.
* guix/progress.scm (<progress-bar-style>): New record type.
(ascii-bar-style, unicode-bar-style): New variables.
(progress-bar): Draw progress depending on style. When supported, use
unicode style. Fall back to ascii style.
---
guix/progress.scm | 45 ++++++++++++++++++++++++++++++++++++++-------
1 file changed, 38 insertions(+), 7 deletions(-)
diff --git a/guix/progress.scm b/guix/progress.scm
index 4f8e98edc0..33cf6f4a1a 100644
--- a/guix/progress.scm
+++ b/guix/progress.scm
@@ -166,16 +166,47 @@ (define current-terminal-columns
;; Number of columns of the terminal.
(make-parameter 80))
+(define-record-type* <progress-bar-style>
+ progress-bar-style make-progress-bar-style progress-bar-style?
+ (start progress-bar-style-start)
+ (stop progress-bar-style-stop)
+ (filled progress-bar-style-filled)
+ (steps progress-bar-style-steps))
+
+(define ascii-bar-style
+ (progress-bar-style
+ (start #\[)
+ (stop #\])
+ (filled #\#)
+ (steps '())))
+
+(define unicode-bar-style
+ (progress-bar-style
+ (start #\x2595)
+ (stop #\x258f)
+ (filled #\x2588)
+ (steps '(#\x258F #\x258E #\x258D #\x258C #\x258B #\x258A #\x2589))))
+
(define* (progress-bar % #:optional (bar-width 20))
"Return % as a string representing an ASCII-art progress bar. The total
width of the bar is BAR-WIDTH."
- (let* ((bar-width (max 3 (- bar-width 2)))
- (fraction (/ % 100))
- (filled (inexact->exact (floor (* fraction bar-width))))
- (empty (- bar-width filled)))
- (format #f "[~a~a]"
- (make-string filled #\#)
- (make-string empty #\space))))
+ (let* ((bar-style (if (equal? (port-encoding (current-output-port)) "UTF-8")
+ unicode-bar-style
+ ascii-bar-style))
+ (bar-width (max 3 (- bar-width 2)))
+ (intermediates (+ (length (progress-bar-style-steps bar-style)) 1))
+ (step (inexact->exact (floor (/ (* % bar-width intermediates) 100))))
+ (filled (quotient step intermediates))
+ (intermediate
+ (list-ref (cons #f (progress-bar-style-steps bar-style))
+ (modulo step intermediates)))
+ (empty (- bar-width filled (if intermediate 1 0))))
+ (simple-format #f "~a~a~a~a~a"
+ (string (progress-bar-style-start bar-style))
+ (make-string filled (progress-bar-style-filled bar-style))
+ (if intermediate (string intermediate) "")
+ (make-string empty #\space)
+ (string (progress-bar-style-stop bar-style)))))
(define (erase-current-line port)
"Write an ANSI erase-current-line sequence to PORT to erase the whole line and
--
2.38.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [bug#59975] [PATCH v3 0/2] guix: Show better progress bars.
2023-02-03 11:56 ` [bug#59975] [PATCH v3 0/2] " Julien Lepiller
2023-02-03 11:56 ` [bug#59975] [PATCH v3 1/2] gnu: Use unifont by default in TTYs Julien Lepiller
2023-02-03 11:56 ` [bug#59975] [PATCH v3 2/2] guix: Show better progress bars Julien Lepiller
@ 2023-02-12 10:02 ` Christopher Baines
2023-02-19 9:11 ` bug#59975: " Julien Lepiller
2 siblings, 1 reply; 12+ messages in thread
From: Christopher Baines @ 2023-02-12 10:02 UTC (permalink / raw)
To: Julien Lepiller; +Cc: 59975
[-- Attachment #1: Type: text/plain, Size: 620 bytes --]
Julien Lepiller <julien@lepiller.eu> writes:
> Here's the new version, it's now a small series. The first patch sets
> unifont as default, so we can see the fancy bars in a TTY :) The second
> hasn't changed.
>
> Julien Lepiller (2):
> gnu: Use unifont by default in TTYs.
> guix: Show better progress bars.
>
> gnu/services/base.scm | 7 +++----
> guix/progress.scm | 45 ++++++++++++++++++++++++++++++++++++-------
> 2 files changed, 41 insertions(+), 11 deletions(-)
>
>
> base-commit: 92755c6352fd967bc74d8e5354aad057d779b717
I haven't tried this out, but the changes look good to me :)
Thanks,
Chris
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 987 bytes --]
^ permalink raw reply [flat|nested] 12+ messages in thread
* bug#59975: [PATCH v3 0/2] guix: Show better progress bars.
2023-02-12 10:02 ` [bug#59975] [PATCH v3 0/2] " Christopher Baines
@ 2023-02-19 9:11 ` Julien Lepiller
0 siblings, 0 replies; 12+ messages in thread
From: Julien Lepiller @ 2023-02-19 9:11 UTC (permalink / raw)
To: Christopher Baines; +Cc: 59975-done
[-- Attachment #1: Type: text/plain, Size: 901 bytes --]
Finally pushed to master as 01334a61c7541d8ae29c5252e2e5b3ed7a59c552
and 189525412e3d803f3f77e15ec4a62aaa57f65a2d.
Le Sun, 12 Feb 2023 10:02:50 +0000,
Christopher Baines <mail@cbaines.net> a écrit :
> Julien Lepiller <julien@lepiller.eu> writes:
>
> > Here's the new version, it's now a small series. The first patch
> > sets unifont as default, so we can see the fancy bars in a TTY :)
> > The second hasn't changed.
> >
> > Julien Lepiller (2):
> > gnu: Use unifont by default in TTYs.
> > guix: Show better progress bars.
> >
> > gnu/services/base.scm | 7 +++----
> > guix/progress.scm | 45
> > ++++++++++++++++++++++++++++++++++++------- 2 files changed, 41
> > insertions(+), 11 deletions(-)
> >
> >
> > base-commit: 92755c6352fd967bc74d8e5354aad057d779b717
>
> I haven't tried this out, but the changes look good to me :)
>
> Thanks,
>
> Chris
[-- Attachment #2: Signature digitale OpenPGP --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2023-02-19 9:14 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-12-11 18:00 [bug#59975] [PATCH] guix: Show better progress bars Julien Lepiller
2022-12-21 16:20 ` Julien Lepiller
2023-01-06 17:45 ` Simon Tournier
2023-01-13 17:07 ` Ludovic Courtès
2023-01-15 10:12 ` Julien Lepiller
2023-01-17 9:06 ` Ludovic Courtès
2023-01-27 18:05 ` Simon Tournier
2023-02-03 11:56 ` [bug#59975] [PATCH v3 0/2] " Julien Lepiller
2023-02-03 11:56 ` [bug#59975] [PATCH v3 1/2] gnu: Use unifont by default in TTYs Julien Lepiller
2023-02-03 11:56 ` [bug#59975] [PATCH v3 2/2] guix: Show better progress bars Julien Lepiller
2023-02-12 10:02 ` [bug#59975] [PATCH v3 0/2] " Christopher Baines
2023-02-19 9:11 ` bug#59975: " Julien Lepiller
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.