code folding for Stata
Posted: Fri May 08, 2009 10:16 pm
Hi jussij,
I just installed Zeus and liking it very much so far. But since I plan to use it mostly for "non-standard" language, found the need to do lot's of customizations, code folding being one of them. I'd appreciate much if you can add the support for it. Stata is a statistical analysis software and has it's own scripting language, here's example:
Thanks a lot,
zura
I just installed Zeus and liking it very much so far. But since I plan to use it mostly for "non-standard" language, found the need to do lot's of customizations, code folding being one of them. I'd appreciate much if you can add the support for it. Stata is a statistical analysis software and has it's own scripting language, here's example:
Code: Select all
Extension: .do; .ado; .class
Line Comment1: //
Line Comment2: *
Block Comment: /* */
Case Sensitive: yes
Begin: program
End: end
Begin: class
End: }
Begin: if
End: }
Begin: else
End: }
Begin: forvalues
End: }
Begin: foreach
End: }
Begin: while
End: }
Begin: quietly
End: }
Begin: noisily
End: }
Begin: capture
End: }
stata has two types of end-line delimiters cr and ";" so it would be nice if a multiline commands can be folded as well (more examples below)
Some sample Code:
program define matrix_capp
version 8
syntax anything [, miss(str) cons ts sort]
local b12 : word 1 of `anything'
local colon : word 2 of `anything'
local b1 : word 3 of `anything'
local b2 : word 4 of `anything'
if `"`colon'"' != ":" {
// example of a command spaning multiple lines
display as err ///
`"colon expected, `colon' found"'
// this is the same as - display as err `"colon expected, `colon' found"'
exit 198
}
// will use this part later
tempname TMP
local cnames
forvalues j = 1/2 {
forvalues i = 1/`=colsof(`b`j'')' {
matrix `TMP' = `b`j''[....,`i']
local cnames `"`cnames' "`: colfullnames `TMP''""'
}
}
if ~missing("`sort'") {
tempname TMP bb
local rfullb1
local rfullb2
forvalues i=1/`=rowsof(`b1')' {
matrix `TMP' = `b1'[`i', ....]
local rfullb1 `"`rfullb1' "`: rowfullnames `TMP''" "' // we can't trust rowfullnames for multi-word names
}
forvalues i=1/`=rowsof(`b2')' {
matrix `TMP' = `b2'[`i', ....]
local rfullb2 `"`rfullb2' "`: rowfullnames `TMP''" "'
}
local rfullb : list rfullb1 | rfullb2
matrix `bb' = J(`nr', `nc1' + `nc2', `miss')
forvalues i=1/`nr' {
local ii = rownumb(matrix(`b1'), `"`: word `i' of `rfullb''"')
local ii = rownumb(matrix(`b2'), `"`: word `i' of `rfullb''"')
if ~missing(`ii') matrix `bb'[`i', `nc1' + 1] = `b2'[`ii', 1...]
}
matrix rownames `bb' = `rfullb'
matrix colnames `bb' = `cnames'
matrix `b12' = `bb'
exit
}
matrix colnames `bb'=`cnames'
matrix `b12' = `bb'
end
// example with ";" delimiter
#delimit ;
graph combine gic_total gic_urban gic_rural,
imargin(0 1 0 0) ysize(6) xsize(8) iscale(0.8)
graphregion(color(white) style(none) margin(0 0 0 0) lstyle(none))
plotregion (color(white) style(none));
zura