pretty-print-gestalt

This commit is contained in:
Tony Garnock-Jones 2014-05-14 00:02:33 -04:00
parent c01d4f09bd
commit 63010dc1db
1 changed files with 11 additions and 1 deletions

View File

@ -24,7 +24,8 @@
gestalt-filter
gestalt-match
strip-gestalt-label
label-gestalt)
label-gestalt
pretty-print-gestalt)
;; A Gestalt is a (gestalt (Listof (Listof (Pairof Matcher
;; Matcher)))), representing the total interests of a process or group
@ -183,6 +184,15 @@
(define (label-gestalt g pid)
(gestalt-matcher-transform g (lambda (m) (matcher-relabel m (lambda (old) (set pid))))))
(define (pretty-print-gestalt g [port (current-output-port)])
(for [(metalevel (in-naturals)) (ls (in-list (gestalt-metalevels g)))]
(for [(level (in-naturals)) (l (in-list ls))]
(match-define (cons subs advs) l)
(when (or subs advs)
(fprintf port "GESTALT metalevel ~v level ~v:\n" metalevel level)
(when subs (fprintf port " - subs:") (pretty-print-matcher subs port #:indent 9))
(when advs (fprintf port " - advs:") (pretty-print-matcher advs port #:indent 9))))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(module+ test