Last active
April 17, 2025 17:06
-
-
Save Oldes/bdf4a6fede49f7f043af823a292be902 to your computer and use it in GitHub Desktop.
[CLI] Animated wait
This file contains hidden or 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
Rebol [ | |
title: "Wait with a dot animation as a progress" | |
needs: 3.6.0 ;; https://github.com/Oldes/Rebol3/releases | |
usage: [anim-wait 0:0:10] | |
note: [ | |
;; all "dot" chars can be resolved using: | |
for i 10241 10495 1 [print [i to char! i]] | |
] | |
] | |
anim-wait: function [ | |
"Waits for a duration with a dot animation as a progress" | |
duration [time! integer! decimal! date!] "Duration or end date" | |
][ | |
str: {⠁⠉⠙⠹⢹⣹⣽⣿⡿⠿⠟⠛⠋⠉⠒⠤⣀⣤⣶⣿⠿⠛⠉⠁⠃⠇⡇⣆⣤⣰⢸⠹⠙⠉} | |
i: 0 | |
n: length? str | |
unless date? duration [ | |
duration: now/precise + to time! duration | |
] | |
prin "^[[?25l" ;; hides cursor | |
while [now/precise < duration] [ | |
prin pickz str i | |
prin "^M" | |
wait 0.1 | |
i: (i + 1) // n | |
] | |
prin " ^M^[[?25h" ;; clears and shows cursor | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment