Longtime thought impossible, but now an undeniable fact: linenumbers with a textarea.
The script...
function scrollit() {
var o = document.getElementById( 'dyna' );
o.style.top = '-' + tt.scrollTop + 'px';
o.style.clip =
'rect(' + ( tt.scrollTop + 1 ) + 'px ' + o.scrollWidth + 'px ' + ( tt.scrollTop + tt.offsetHeight - 1 ) + 'px 0)';
}
function linenumbers() {
var d = document,
o = d.createElement( 'div' ),
p = o.cloneNode( false ), q = o.cloneNode( false ),
i, max = 10 + tt.value.split(/\n/).length;
o.id = 'stat';
p.id = 'dyna';
q.appendChild( d.createTextNode( 'c' ) );
for( i = 1; i<max; i++ ) {
r = q.cloneNode( true );
r.firstChild.nodeValue = i;
p.appendChild( r );
}
o.appendChild( p );
o.style.fontFamily = getstyle( tt, 'font-family' );
o.style.lineHeight = getstyle( tt, 'line-height' );
o.style.paddingTop = getstyle( tt, 'padding-top' );
//o.style.borderRight = '2px outset white';
o.style.top = getpos( tt ).y + 'px';
tt.parentNode.insertBefore( o, tt );
w = p.scrollWidth;
if( ff.wrp.checked ) { o.className = 'hid'; }
o.style.width = w + 'px';
o.style.height = tt.offsetHeight + 'px';
o.style.left = getpos( tt ).x - w * 2 + 'px';
}
function wrapta() {
tt.wrap = ff.wrp.checked ? 'soft' : 'off';
document.getElementById( 'stat' ).className = ff.wrp.checked ? 'hid' : 'lit';
scrollit();
}
var ff = document.forms.f, tt = ff.elements.txt;
tt.onscroll = scrollit;
linenumbers();