Code Folding #2284

Open
klonuo opened this Issue Aug 10, 2012 · 3 comments

Comments

Projects
None yet
3 participants
Contributor

klonuo commented Aug 10, 2012

Just discussing something related on mailing list, I thought about code folding as alternative to cell code collapsing.
First I looked if CodeMirror supports this feature and it seems it does but it's somewhat flaky from the demo.

OTOH SciTE export function to XHTML behaves great with just couple of lines code if folding point is known:

<script language="JavaScript" type="text/javascript">
<!--
function symbol(id, sym) {
 if (id.textContent==undefined) {
 id.innerText=sym; } else {
 id.textContent=sym; }
}
function toggle(id) {
var thislayer=document.getElementById('ln'+id);
id-=1;
var togline=document.getElementById('hd'+id);
var togsym=document.getElementById('bt'+id);
if (thislayer.style.display == 'none') {
 thislayer.style.display='block';
 togline.style.textDecoration='none';
 symbol(togsym,'- ');
} else {
 thislayer.style.display='none';
 togline.style.textDecoration='underline';
 symbol(togsym,'+ ');
}
}
//-->
</script>

Demonstration: http://db.tt/Kuj9gtFb

onclick event is toggled for whole line, but that can be changed easily as folding symbol characters.

I know that SciTE exported XHTML is for static viewing, but I don't know if it's difficult for implementation and useful to others, knowing that Notebook doesn't have option for line numbers AFAIK

Owner

fperez commented Aug 10, 2012

This is code folding of a static html page. I don't see how this can help us for editable code. Basically any solution we implement to improve editing must go through CodeMirror to be useful.

Owner

Carreau commented Aug 10, 2012

Notebook doesn't have option for line numbers AFAIK

C-m h says :
Ctrl-m l : toggle line numbers.

Contributor

klonuo commented Aug 10, 2012

C-m h says :
Ctrl-m l : toggle line numbers.

It is so beautiful, I had no idea...
Then if folding can resize cell it would be great
CodeMirror supports folding as shown in the first link. Would it be easy for implementation?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment