speak errors&warnings

clean-up #9:

here's a little tool originally made for visually impaired supercollider users. press the 'esc' key and the built-in computer voice will read the last error message posted. hold down 'alt' and press 'esc' and it will read the last warning message posted. if there are no errors or warnings it won't say anything.
this will only work on osx i'm afraid. put it in your startup.rtf document to make it to load by default.

//redFrik 2007
//find last posted error or warning and speak it using the built in computer voice (osx only).
//'esc'     - to speak last error
//'alt+esc' - to speak last warning
Document.globalKeyDownAction_{|doc, key, mod, code|
        var d, i;
        if(code==27, {                          //esc
                d= Document.listener.string;
                if(mod&524288==524288, {        //esc+alt
                        i= d.findBackwards("WARNING:");
                        if(i.notNil, {
                                ("warning"+(d.copyRange(i, i+200).split($\r)[1])).speak;
                }, {                                            //plain esc
                        i= d.findBackwards("ERROR:");
                        if(i.notNil, {
                                d.copyRange(i, i+100).split($\r)[0].speak;

{SinOsc.ar}.play        //warns about localhost not running