Finish new progress.

This commit is contained in:
Dominik Pantůček 2023-03-20 16:34:44 +01:00
parent 08ad923f6a
commit a21de657d0
3 changed files with 25 additions and 8 deletions

View file

@ -31,6 +31,8 @@
run-with-progress
progress-advance
with-progress
run-progress-break
progress-break
)
(import scheme
@ -63,12 +65,25 @@
(print post-msg))
result)))
;; Allows printing output when progress is advancing.
(define (run-progress-break thunk)
(when (*current-progress*)
(display "\r\x1b[K"))
(thunk)
(print-current-progress))
;; Friendly syntax wrapper.
(define-syntax with-progress
(syntax-rules ()
((_ echo? pre post body ...)
(run-with-progress echo? pre post (lambda () body ...)))))
;; Evaluate some expressions without progress.
(define-syntax progress-break
(syntax-rules ()
((_ body ...)
(run-progress-break (lambda () body ...)))))
;; If the program uses progress module, disable buffering
(set-buffering-mode! (current-output-port) #:none)