Last active
February 20, 2020 22:06
-
-
Save gonewest818/42b14e2dac632857b871754d6f6b9614 to your computer and use it in GitHub Desktop.
elisp animated spinner generator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; to generate an animated spinner | |
;; | |
;; starting from from this: | |
;; ".oO@Oo." | |
;; | |
;; and producing this: | |
;; ["[ ]" | |
;; "[. ]" | |
;; "[o. ]" | |
;; "[Oo. ]" | |
;; "[@Oo.]" | |
;; "[O@O.]" | |
;; "[oO@O]" | |
;; "[.oO@]" | |
;; "[ .oO]" | |
;; "[ .o]" | |
;; "[ .]"] | |
;; | |
;; suitable for passing into `spinner-start' | |
(require 'spinner) | |
(defun generate (body left right width) | |
(let* ((pad (concat (make-string width ? ) body)) | |
(wrap (concat pad pad)) | |
(result nil)) | |
(dolist (i (number-sequence (1- (length pad)) 0 -1)) | |
(push (format "%s%s%s" | |
left | |
(substring wrap i (+ i width)) | |
right) | |
result)) | |
(vconcat result))) | |
;; single character looks like it "pulses" | |
;; (spinner-start (generate ".:+*O*+:." "[" "]" 1)) | |
;; (spinner-stop) | |
;; rolling string is a "breather" | |
;; (spinner-start (generate ".oO@Oo." "[" "]" 4)) | |
;; (spinner-stop) | |
;; can also be a rolling marquee with text | |
;; (spinner-start (generate "Gathering results..." "[" "]" 5)) | |
;; (spinner-stop) | |
;; easy to reverse the direction | |
;; (spinner-start (nreverse (generate "<(O)>" "{" "}" 20))) | |
;; (spinner-stop) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment