ccgus/jstalk — pull request #8 by jbrennan (2013-04-28 19:36:58+00:00)
Title: Textview number scrubbing

What it does
-----------------

This adds some of the number scrubbing features from [Super Debugger](https://github.com/jbrennan/superdb) to let you drag on numbers in a JSTalk script and have the script re-evaluate as you're dragging. This lets you quickly play around with values in a script and see the results in realtime. No more change -> run -> see. Just change + see.

To test
----------

You can test it with the following script as a good example:

```
var duckImage = [CIImage jstImageNamed:"duck"];
var filter = [CIFilter filterWithName:@"CIGaussianBlur"];
[filter setValue:duckImage forKey:@"inputImage"];
[filter setValue:[NSNumber numberWithFloat:16] forKey:@"inputRadius"];

var blurredImage = [filter outputImage];

[JSTImageTools viewCIImage:blurredImage inWindowNamed:@"Blur" extent:[duckImage extent]];
```

Move your cursor over the `16` in `-numberWithFloat:` and you'll see the cursor change to the resize mode. Click and drag the number to see the script run and re-evaluate as you drag. When you're done, just let go of the cursor.

Notes and known issues
----------------------------------

The biggest known issue is this only works for integer numbers. You can still drag a float but it'll only let you scrub through integers. An easy workaround for this is to just do `1/100` and then scrub on the `1`. A bit of a hack until I figure out decimals.

The other issue is performance. This code works by just re-running the script every time a number is dragged. This can be expensive if you're loading a large image in the script or doing anything else potentially expensive.

A good optimization would be to let it only execute whichever method the dragged number happens to be in, but I'm not familiar enough with JSTalk to do this yet. So for now, it's either smaller images or some lag.