From d00fea566004e67161ee45246b239fff5d416b0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Tue, 21 Dec 2021 16:17:28 +0100 Subject: Cleanup modules. Primarly this moves all vcompenent input and output code to clearly labeled modules, instead of being spread out. At the same time it also removes a handfull of unused procedures. --- module/vcomponent/util/describe.scm | 44 +++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 module/vcomponent/util/describe.scm (limited to 'module/vcomponent/util/describe.scm') diff --git a/module/vcomponent/util/describe.scm b/module/vcomponent/util/describe.scm new file mode 100644 index 00000000..5c3afd30 --- /dev/null +++ b/module/vcomponent/util/describe.scm @@ -0,0 +1,44 @@ +(define-module (vcomponent util describe) + :use-module (calp util) + :use-module (vcomponent base) + :use-module (text util)) + +(define*-public (describe vcomponent optional: (indent 0)) + (define ii (make-string indent #\space)) + (define iii (make-string (1+ indent) #\space)) + + (define maxlen (find-max (map + (lambda (a) (string-length (symbol->string a))) + (map car (properties vcomponent))))) + + (format #t "~aBEGIN ~a~%" ii (type vcomponent)) + + (for-each (lambda (kv) + (let* (((key . values) kv)) + (define (out vline) + (format #t "~a~a = ~a" + iii + (trim-to-width (symbol->string key) maxlen) + (trim-to-width + (format #f "~a" (value vline)) + (- 80 indent maxlen))) + (awhen (vline-source vline) + (display ((@@ (vcomponent formats ical parse) get-line) it))) + (unless (null? (parameters vline)) + (display " ;") + (for (key value) in (parameters vline) + (format #t " ~a=~a" key value))) + (newline)) + (if (list? values) + (for-each out values) + (out values)))) + (sort* (properties vcomponent) + stringstring car))) + + (for child in (children vcomponent) + + (describe child (+ indent 2))) + + (format #t "~aEND ~a~%" ii (type vcomponent))) -- cgit v1.2.3