(module syntax-browser mzscheme
(require (lib "class.ss")
(lib "mred.ss" "mred")
(lib "framework.ss" "framework")
"private/interfaces.ss"
"private/prefs.ss"
"private/widget.ss")
(provide browse-syntax
browse-syntaxes
syntax-browser<%>
make-syntax-browser
syntax-snip
syntaxes-snip)
(define (browse-syntax stx)
(browse-syntaxes (list stx)))
(define (browse-syntaxes stxs)
(let ((w (make-syntax-browser)))
(for-each (lambda (stx)
(send w add-syntax stx)
(send w add-separator))
stxs)))
(define (make-syntax-browser)
(let* ([controller (new syntax-controller%)]
[view (new syntax-browser-frame% (controller controller))])
(send view show #t)
controller))
(define (syntax-snip stx)
(syntaxes-snip (list stx)))
(define (syntaxes-snip stxs)
(let* ([controller (new syntax-controller%)]
[view (new syntax-snip% (controller controller))])
(let loop ([stxs stxs])
(cond [(null? stxs) (void)]
[(null? (cdr stxs))
(send controller add-syntax (car stxs))]
[else
(send controller add-syntax (car stxs))
(send controller add-separator)
(loop (cdr stxs))]))
view))
)