[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [sc-dev] autoindent method in sctextview

i was thinking of adding to that some functionality where, let's say, the user types a left bracket and then return, the next line should indent one more level. Then, typing a righ bracket would bring the indent level up one.

But one thing I've noticed is that SC programming blocks don't quite follow a C / Java look and feel, so it would help to get a better understanding of the canonical form - does it derive directly from anything or is is only discernible in code examples in the help? Any information here would be appreciated.

For myself, I tend to make the code look like blocks of c as much as possible, which, for me, makes it easier to read. For example:

"granSampScanner",{ arg bufnum=0, rate=1, startPos=0, endPos=1.0,
windowSize=0.01, scanSpeed=1;
var thisRate, thisDur, loopFrq, env, dir, saw, start;
/* a sawtooth wave is a factor in computing an increment to the startPos, to scan the file - its speed is related to the duration of the part of the file to be scanned, times its scanSpeed */
saw = BufDur.kr(bufnum)
0,0.5,1); // note 'mul' and 'add' args, which put output range = 0->1.0
// instead of starting at -1, we start at 0
dir = (endPos-startPos).sign;
start = startPos+((endPos-startPos)*saw);
thisRate = BufRateScale.kr(bufnum)*rate*dir;
thisDur = (windowSize*BufDur.kr(bufnum))/rate;
loopFrq = (1.0/thisDur).min(100); // guard against Infinite frequency
env = Env.sine(1,0.90);
timeScale: thisDur.max(BufRateScale.kr(bufnum)*0.01))*
PlayBuf.ar(1,bufnum,thisRate, Impulse.kr( loopFrq),
start*BufFrames.kr(bufnum), // startPos
1), 0, 1.0))
ControlSpec(0, 1, \linear),
ControlSpec(0, 1, \linear),
ControlSpec(0, 1, \linear),
ControlSpec(0.0025, 0.1, \linear),
ControlSpec(0.01, 2.0, \linear)

On Dec 25, 2004, at 12:37 AM, James McCartney wrote:

On Dec 24, 2004, at 7:19 PM, b a r t o n wrote:

OK, I've had a chance to look at the code now and it looks like it
goes back to the last tab stop and matches it on a return. Is that a
correct assessment?

it goes back to the previous newline and reproduces the white space
beginning that line.

sc-dev mailing list