/lenasys/trunk

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/lenasys/trunk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php

function showfile($filename, $lang, $interestingrows = array()) {
	echo "<strong>".$filename."</strong>";
	echo '<div id="ace_'.str_replace(".", "", $filename).'" class="ace">';
	$handle = @fopen($filename, "r");
	if ($handle) {

		while (($buffer = fgets($handle, 4096)) !== false) {

			$buffer = str_replace("&", "&amp;", $buffer);
			$buffer = str_replace("<", "&lt;", $buffer);
			$buffer = str_replace(">", "&gt;", $buffer);

			echo $buffer;
		}
		if (!feof($handle)) {
			echo "Error: unexpected fgets() fail\n";
		}
		fclose($handle);
	}
	echo '</div>';

	echo  '<script type="text/javascript">
	var Range = require("ace/range").Range;
	var editor = ace.edit("ace_'.str_replace(".", "", $filename).'");
	editor.setTheme("ace/theme/merbivore");
	editor.getSession().setMode("ace/mode/'.$lang.'");
	editor.setReadOnly(true);
	editor.setShowPrintMargin(false);
	editor.setDisplayIndentGuides(false);
	editor.setHighlightSelectedWord(true);
	lines = editor.getSession().getLength();
	$("#ace_'.str_replace(".", "", $filename).'").height(Math.min(500,lines*16));
	aceeditors.push("ace_'.str_replace(".", "", $filename).'");';
	for($i = 0; $i < count($interestingrows); $i++) {
		echo 'editor.getSession().addMarker(new Range('.$interestingrows[$i][0].', 0, '
			.$interestingrows[$i][1].', Number.POSITIVE_INFINITY), "interesting", "text",false);';
	}
	echo '</script>';

}
?>