diff options
author | Hugo Hörnquist <hugo@lysator.liu.se> | 2020-06-28 23:31:29 +0200 |
---|---|---|
committer | Hugo Hörnquist <hugo@lysator.liu.se> | 2020-06-29 01:08:54 +0200 |
commit | 0279f9b45c7eb0a85da79f8083fb65da18e4ff55 (patch) | |
tree | dab6c9c4f75a5fc50e336ef97b17e03af7b21260 /module/vcomponent | |
parent | Add xcal tests. (diff) | |
download | calp-0279f9b45c7eb0a85da79f8083fb65da18e4ff55.tar.gz calp-0279f9b45c7eb0a85da79f8083fb65da18e4ff55.tar.xz |
Add describe procedure for vcomponents.
Diffstat (limited to '')
-rw-r--r-- | module/vcomponent/describe.scm | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/module/vcomponent/describe.scm b/module/vcomponent/describe.scm new file mode 100644 index 00000000..4e89f5e8 --- /dev/null +++ b/module/vcomponent/describe.scm @@ -0,0 +1,33 @@ +(define-module (vcomponent describe) + :use-module (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 (hash-map->list + (lambda (a _) (string-length (symbol->string a))) + (attributes vcomponent)))) + + (format #t "~aBEGIN ~a~%" ii (type vcomponent)) + + (hash-for-each (lambda (key 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 (properties vline) + (display " ;") + (for (key value) in it + (format #t " ~a=~a" key value))) + (newline)) + (attributes vcomponent)) + + (for child in (children vcomponent) + (describe child (+ indent 2))) + + (format #t "~aEND ~a~%" ii (type vcomponent))) |