If the source is available, the compiler could be tweaked to obey a protocol, putting delimiters around collapsable output (possibly non-printing control sequences??)
I believe both emacs and vim have folding submodes which operate based on comments containing {{{ / }}} to bracket foldable regions.
-- brandon s allbery allbery.b@gmail.com
wandering unix systems administrator (available) (412) 475-9364 vm/sms