‹ n-bit Computers newscoolish ›

Speak Errors & Warnings

2010-11-24 01:55 supercollider

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 with SC 3.6 Cocoa or earlier I'm afraid. Put it in your startup file 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;
      });
    });
    ""
  });
}
)

/*
//--test
OOO.new
1.asd
1\2
11
s.quit
{SinOsc.ar}.play  //warns about localhost not running
*/

‹ n-bit Computers newscoolish ›