Finish new progress.
This commit is contained in:
parent
08ad923f6a
commit
a21de657d0
3 changed files with 25 additions and 8 deletions
15
progress.scm
15
progress.scm
|
@ -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)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue