From patchwork Fri Feb 3 11:56:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Lepiller X-Patchwork-Id: 46629 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id A130727BBEB; Fri, 3 Feb 2023 11:57:51 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-3.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 37E8927BBE9 for ; Fri, 3 Feb 2023 11:57:50 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pNugi-0005G1-2s; Fri, 03 Feb 2023 06:57:04 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pNugg-0005F2-Ls for guix-patches@gnu.org; Fri, 03 Feb 2023 06:57:02 -0500 Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pNugg-0007M1-DM for guix-patches@gnu.org; Fri, 03 Feb 2023 06:57:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pNugg-0000gL-92 for guix-patches@gnu.org; Fri, 03 Feb 2023 06:57:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#59975] [PATCH v3 1/2] gnu: Use unifont by default in TTYs. Resent-From: Julien Lepiller Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 03 Feb 2023 11:57:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 59975 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 59975@debbugs.gnu.org Received: via spool by 59975-submit@debbugs.gnu.org id=B59975.16754253902569 (code B ref 59975); Fri, 03 Feb 2023 11:57:02 +0000 Received: (at 59975) by debbugs.gnu.org; 3 Feb 2023 11:56:30 +0000 Received: from localhost ([127.0.0.1]:36624 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pNug9-0000fD-OP for submit@debbugs.gnu.org; Fri, 03 Feb 2023 06:56:30 -0500 Received: from lepiller.eu ([89.234.186.109]:46082) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pNug8-0000es-0X for 59975@debbugs.gnu.org; Fri, 03 Feb 2023 06:56:28 -0500 Received: from lepiller.eu (localhost [127.0.0.1]) by lepiller.eu (OpenSMTPD) with ESMTP id 6307fa18 for <59975@debbugs.gnu.org>; Fri, 3 Feb 2023 11:56:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=lepiller.eu; h=from:to :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; s=dkim; bh=3rAkWM31cpLJM1lru/vmcL7/m oiClVSo353VBZqmq18=; b=UkrnvMI7ohfi0RtS+bD5mfaYLzZAdp3xgNh7esKND 4Gintm4JxVsxjGHoc21sPesLrpJ6jdIZSuaLaWGr7xMgnNqL2Uok7pWjdVOTjfrc KN3UssYt7vrP60gEO/uqisAR/FX1w5PqRvQa9VfYsSmQ7O5lyXA8cUEUyFW4rF3w 1hqwtZhYIwHxiHcgO5qW4SyfjV2cnmop/y72diiovsk6Mi8ungi7cchTWt5EUUoQ nmWgc3zeUtMLHrvDr1MRP+rkA3/PNKu2z3zJBdurQisgssV/mPxl47analH/GNPK FzmBFHQw2dbdmLWrFTtBaVPD3udUp1C+Awn/DgSM3i+uQ== Received: by lepiller.eu (OpenSMTPD) with ESMTPSA id 86d43e64 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO) for <59975@debbugs.gnu.org>; Fri, 3 Feb 2023 11:56:24 +0000 (UTC) From: Julien Lepiller Date: Fri, 3 Feb 2023 12:56:02 +0100 Message-Id: <7ed43a449e8d598e316c649454363f5a2e7d7d7b.1675425118.git.julien@lepiller.eu> X-Mailer: git-send-email 2.38.1 In-Reply-To: References: MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches 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." From patchwork Fri Feb 3 11:56:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Lepiller X-Patchwork-Id: 46628 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 8AD3827BBEB; Fri, 3 Feb 2023 11:57:39 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-3.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 6939E27BBE9 for ; Fri, 3 Feb 2023 11:57:37 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pNugi-0005G9-Gl; Fri, 03 Feb 2023 06:57:04 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pNugh-0005Fr-9Q for guix-patches@gnu.org; Fri, 03 Feb 2023 06:57:03 -0500 Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pNugg-0007NX-RG for guix-patches@gnu.org; Fri, 03 Feb 2023 06:57:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pNugg-0000gS-O9 for guix-patches@gnu.org; Fri, 03 Feb 2023 06:57:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#59975] [PATCH v3 2/2] guix: Show better progress bars. Resent-From: Julien Lepiller Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 03 Feb 2023 11:57:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 59975 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 59975@debbugs.gnu.org Received: via spool by 59975-submit@debbugs.gnu.org id=B59975.16754253952581 (code B ref 59975); Fri, 03 Feb 2023 11:57:02 +0000 Received: (at 59975) by debbugs.gnu.org; 3 Feb 2023 11:56:35 +0000 Received: from localhost ([127.0.0.1]:36626 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pNugD-0000fX-6h for submit@debbugs.gnu.org; Fri, 03 Feb 2023 06:56:35 -0500 Received: from lepiller.eu ([89.234.186.109]:46082) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pNug9-0000es-3G for 59975@debbugs.gnu.org; Fri, 03 Feb 2023 06:56:29 -0500 Received: from lepiller.eu (localhost [127.0.0.1]) by lepiller.eu (OpenSMTPD) with ESMTP id fd846c3c for <59975@debbugs.gnu.org>; Fri, 3 Feb 2023 11:56:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=lepiller.eu; h=from:to :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; s=dkim; bh=nx7qSxU2/i4xCOUJZpgvmthrF 0UgB5d+wEWDvlDEFUA=; b=cV9rK/6qpeOZd7tugcc9jgEcqyvyjIvwMIWjT2iwt /gTkTxi0KjJLL92lE5UFaioBgPEztn3mBjlKfzdZR26fJuwNZqNmvFdWr4Ei6Ov3 qe/OgsYygxAjCCiSPwFhVxJhEx1UIQ6no3UOpZ2v4qw9Y6yRKPlhTjyFyIXMdqdl p72XtEDSuXllCaZihNzkDyaKZS0V6j6A0c2BVX3Ukjy4bLjSprJmkYOlWUfs2Tp1 ry6knESUb9/Ese1e/JEaH8OA/e79bHQnaU3XCE+775rOEnaKMoyEN8JsMkDDjN/g JZouTkCqUeFQlOAHcneycJBqbB8aFfYWKARpCisEJwpSg== Received: by lepiller.eu (OpenSMTPD) with ESMTPSA id 61da51f6 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO) for <59975@debbugs.gnu.org>; Fri, 3 Feb 2023 11:56:24 +0000 (UTC) From: Julien Lepiller Date: Fri, 3 Feb 2023 12:56:03 +0100 Message-Id: <11508dcf7a46f6570d329f6c3b98e73198842ca4.1675425118.git.julien@lepiller.eu> X-Mailer: git-send-email 2.38.1 In-Reply-To: References: MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches 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 (): 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 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