From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59903) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dS6Vx-0007Lj-Hy for guix-patches@gnu.org; Mon, 03 Jul 2017 14:56:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dS6Vu-0005qi-Vl for guix-patches@gnu.org; Mon, 03 Jul 2017 14:56:05 -0400 Received: from debbugs.gnu.org ([208.118.235.43]:48041) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dS6Vu-0005qe-Rj for guix-patches@gnu.org; Mon, 03 Jul 2017 14:56:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1dS6Vu-0007jw-LB for guix-patches@gnu.org; Mon, 03 Jul 2017 14:56:02 -0400 Subject: [bug#27566] [PATCH] ui: spinner-port: New variable. Export it. Resent-Message-ID: Received: from eggs.gnu.org ([2001:4830:134:3::10]:59766) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dS6VO-0006vb-6N for guix-patches@gnu.org; Mon, 03 Jul 2017 14:55:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dS6VL-0005FC-Kx for guix-patches@gnu.org; Mon, 03 Jul 2017 14:55:30 -0400 Received: from dd1012.kasserver.com ([85.13.128.8]:37362) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dS6VL-0005Cd-Ek for guix-patches@gnu.org; Mon, 03 Jul 2017 14:55:27 -0400 From: Danny Milosavljevic Date: Mon, 3 Jul 2017 20:55:20 +0200 Message-Id: <20170703185520.4475-1-dannym@scratchpost.org> List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: 27566@debbugs.gnu.org * guix/ui.scm (spinner-port): New variable. Export it. --- guix/ui.scm | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/guix/ui.scm b/guix/ui.scm index 4bad00e8c..0930ed2b7 100644 --- a/guix/ui.scm +++ b/guix/ui.scm @@ -102,7 +102,8 @@ guix-warning-port warning info - guix-main)) + guix-main + spinner-port)) ;;; Commentary: ;;; @@ -110,6 +111,26 @@ ;;; ;;; Code: +(define spinner-port + (let ((index 0) + (spinner-chars "|\\-/")) + (define previous-output-port (current-error-port)) + (define (spin) + (set! index (+ index 1)) + (if (>= index (string-length spinner-chars)) + (set! index 0)) + (display (array-ref spinner-chars index) previous-output-port) + (display #\backspace previous-output-port) + (force-output previous-output-port)) + (make-soft-port + (vector + (lambda (c) (if (char=? c #\newline) (spin))) ; putc + (lambda (s) (if (string-contains s "\n") (spin))) ; puts + (lambda () #t) ; flusher + (lambda () #f) ; getc + (lambda () #t)) ; close + "w"))) + (define %gettext-domain ;; Text domain for strings used in the tools. "guix")