[plt-scheme] DrScheme Printing of picts
On 19/05/06, Matthew Flatt <mflatt at cs.utah.edu> wrote:
> > I tried:
> > (let ([old-display-handler (port-display-handler (current-output-port))])
> > (port-display-handler (current-output-port)
> > (lambda (val port)
> > (if (is-a? val myobj<%>)
> > (old-display-handler (foo val) port)
> > (old-display-handler val port)))))
> >
> > but this is not working. It's printing the pict resulting of foo as
> > <struct:pict>. Any ideas?
>
> If I understand, this sort of strategy should work if you use `print'
> and if you set the print handler.
>
This works but not as I want it to work:
> (let ([old-print-handler (port-print-handler (current-output-port))])
(port-print-handler (current-output-port)
(lambda (val port)
(if (is-a? val myobj%)
(old-print-handler (foo val) port)
(old-print-handler val port)))))
> (new myobj% (val 15)) ;; foo would return a pict with number 15
<struct:pict>
> (print (new myobj% (val 15)))
|------|
| 1 5 |
|------|
Shows a pict with number 15 but I don't want the user to have to do
print. I was expecting this pict to show up as soon as the myobj% is
created.
Paulo Matos
> Matthew
>
>
--
Paulo Jorge Matos - pocm at sat inesc-id pt
Web: http://sat.inesc-id.pt/~pocm
Computer and Software Engineering
INESC-ID - SAT Group