unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
* [bug#27566] [PATCH] ui: spinner-port: New variable.  Export it.
@ 2017-07-03 18:55 Danny Milosavljevic
  2017-07-26  8:42 ` Ludovic Courtès
  0 siblings, 1 reply; 3+ messages in thread
From: Danny Milosavljevic @ 2017-07-03 18:55 UTC (permalink / raw)
  To: 27566

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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [bug#27566] [PATCH] ui: spinner-port: New variable.  Export it.
  2017-07-03 18:55 [bug#27566] [PATCH] ui: spinner-port: New variable. Export it Danny Milosavljevic
@ 2017-07-26  8:42 ` Ludovic Courtès
  2017-10-18 22:57   ` Ricardo Wurmus
  0 siblings, 1 reply; 3+ messages in thread
From: Ludovic Courtès @ 2017-07-26  8:42 UTC (permalink / raw)
  To: Danny Milosavljevic; +Cc: 27566

Danny Milosavljevic <dannym@scratchpost.org> skribis:

> * guix/ui.scm (spinner-port): New variable.  Export it.

I’d like to see where we’d use it before committing it.  What would be
the first use?

Thanks,
Ludo’.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [bug#27566] [PATCH] ui: spinner-port: New variable.  Export it.
  2017-07-26  8:42 ` Ludovic Courtès
@ 2017-10-18 22:57   ` Ricardo Wurmus
  0 siblings, 0 replies; 3+ messages in thread
From: Ricardo Wurmus @ 2017-10-18 22:57 UTC (permalink / raw)
  To: Danny Milosavljevic; +Cc: 27566


Ludovic Courtès <ludo@gnu.org> writes:

> Danny Milosavljevic <dannym@scratchpost.org> skribis:
>
>> * guix/ui.scm (spinner-port): New variable.  Export it.
>
> I’d like to see where we’d use it before committing it.  What would be
> the first use?

Ping :)

-- 
Ricardo

GPG: BCA6 89B6 3655 3801 C3C6  2150 197A 5888 235F ACAC
https://elephly.net

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-10-19  2:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-03 18:55 [bug#27566] [PATCH] ui: spinner-port: New variable. Export it Danny Milosavljevic
2017-07-26  8:42 ` Ludovic Courtès
2017-10-18 22:57   ` Ricardo Wurmus

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).