Add a macro to display a progress indicator to looping process
This commit is contained in:
parent
a26b19be1b
commit
7ba21e011c
1 changed files with 15 additions and 0 deletions
|
|
@ -11,6 +11,7 @@
|
|||
:safe-first :safe-list
|
||||
:group
|
||||
:restartable
|
||||
:loop-with-progress
|
||||
:add-hook :remove-hook :run-hook
|
||||
:update-current-time :get-delta-time
|
||||
:make-clock :clock-time :clock-delta
|
||||
|
|
@ -63,6 +64,20 @@
|
|||
,@body)
|
||||
(continue () :report "Continue"))))
|
||||
|
||||
(defmacro loop-with-progress (msg &body body)
|
||||
"Allow a looping process to display feedback."
|
||||
`(macrolet ((progress-step ()
|
||||
`(progn
|
||||
(when (> progress-index progress-max-columns)
|
||||
(format t "~%")
|
||||
(setf progress-index 0))
|
||||
(format t "."))))
|
||||
(let ((progress-max-columns 80))
|
||||
(format t ,msg)
|
||||
(loop for progress-index upfrom ,(length msg)
|
||||
,@body)
|
||||
(format t "~%"))))
|
||||
|
||||
(defmacro add-hook (hook fun &optional append)
|
||||
"Setup `fun' to be called within specified `hook'."
|
||||
`(unless (member ,fun ,hook)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue