Page 1 of 1

Code Syntax Highlighting

Posted: Sat Dec 04, 2010 8:00 pm
by Pazuzu156
I'm making my own syntax highlighter. colors are no problem, but as for line numbers, i'm having a difficult time. How do I do this? I'm Using Javascript for the line numbers.

This is what I've got:

Code: Select all

<?php

echo "<script>
window.sync = function(e) {
	var fieldset = document.getElementById('lines');
	var source = document.getElementById('some_text_area');
	fieldset.scrollTop = source.scrollTop;
}
window.populate = function populate() {
	if(populate.started){
		return;
	}
	
	populate.started = true;
	var fieldset = document.getElementById('lines');
	var str = '';
	for(var i=0;i < 100;i++){
		str = str + (i +'\r\n');
	}
	fieldset.value = str;
}
</script>";

echo "<textarea style='40px;overflow:hidden;height:40px;' readonly='true' id='lines'>Hello</textarea>";

echo "<textarea style='width:500px;height:40px;' id='some_test_area' onclick='populate()' onscroll='sync();'><legend>hello</legend>Hello</textarea>";

echo "<cite>Hello</cite>";

?>

Re: Code Syntax Highlighting

Posted: Sat Dec 04, 2010 8:04 pm
by Pazuzu156

Code: Select all

echo "<cite>Hello</cite>";
This has nothing to do with the boxes. This is me messing with stuff in HTML 5