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

@ -115,7 +115,7 @@ ansi.import.scm: $(ANSI-SOURCES)
MEMBER-FILE-SOURCES=member-file.scm dictionary.import.scm \
ansi.import.scm month.import.scm period.import.scm \
listing.import.scm testing.import.scm \
configuration.import.scm
configuration.import.scm progress.import.scm
member-file.so: member-file.o
member-file.o: member-file.import.scm

View file

@ -46,7 +46,8 @@
testing
listing
ansi
configuration)
configuration
progress)
;; Specification of known keys for various types of parsing
(define known-keys '(nick mail phone name born joined destroyed
@ -92,12 +93,13 @@
;; *member-file-check-syntax* parameter.
(define (report-line-error file-name lines highlight message)
(when (not (eq? (*member-file-check-syntax*) 'quiet))
(print "Error in " file-name ": " message)
(newline)
(print-source-listing lines (list highlight)
(*member-file-context*)
a:error a:default
"" "" "..."))
(progress-break
(print "Error in " file-name ": " message)
(newline)
(print-source-listing lines (list highlight)
(*member-file-context*)
a:error a:default
"" "" "...")))
(if (eq? (*member-file-check-syntax*) 'error)
(exit 1)
(list member-file-error-symbol

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)