all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Danny Milosavljevic <dannym@scratchpost.org>
To: 27566@debbugs.gnu.org
Subject: [bug#27566] [PATCH] ui: spinner-port: New variable.  Export it.
Date: Mon,  3 Jul 2017 20:55:20 +0200	[thread overview]
Message-ID: <20170703185520.4475-1-dannym@scratchpost.org> (raw)

* 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")

             reply	other threads:[~2017-07-03 18:56 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-03 18:55 Danny Milosavljevic [this message]
2017-07-26  8:42 ` [bug#27566] [PATCH] ui: spinner-port: New variable. Export it Ludovic Courtès
2017-10-18 22:57   ` Ricardo Wurmus

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170703185520.4475-1-dannym@scratchpost.org \
    --to=dannym@scratchpost.org \
    --cc=27566@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.