/lenasys/trunk

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/lenasys/trunk
15.1.1 by galaxyAbstractor
Started implementation of a new codeviewer using Ace
1
<?php
2
15.1.2 by galaxyAbstractor
Split css and js to external files
3
function showfile($filename, $lang, $interestingrows = array()) {
15.1.1 by galaxyAbstractor
Started implementation of a new codeviewer using Ace
4
	echo "<strong>".$filename."</strong>";
15.1.2 by galaxyAbstractor
Split css and js to external files
5
	echo '<div id="ace_'.str_replace(".", "", $filename).'" class="ace">';
15.1.1 by galaxyAbstractor
Started implementation of a new codeviewer using Ace
6
	$handle = @fopen($filename, "r");
7
	if ($handle) {
8
9
		while (($buffer = fgets($handle, 4096)) !== false) {
10
11
			$buffer = str_replace("&", "&amp;", $buffer);
12
			$buffer = str_replace("<", "&lt;", $buffer);
13
			$buffer = str_replace(">", "&gt;", $buffer);
14
15
			echo $buffer;
16
		}
17
		if (!feof($handle)) {
18
			echo "Error: unexpected fgets() fail\n";
19
		}
20
		fclose($handle);
21
	}
22
	echo '</div>';
23
15.1.2 by galaxyAbstractor
Split css and js to external files
24
	echo  '<script type="text/javascript">
25
	var Range = require("ace/range").Range;
15.1.1 by galaxyAbstractor
Started implementation of a new codeviewer using Ace
26
	var editor = ace.edit("ace_'.str_replace(".", "", $filename).'");
15.1.2 by galaxyAbstractor
Split css and js to external files
27
	editor.setTheme("ace/theme/merbivore");
15.1.1 by galaxyAbstractor
Started implementation of a new codeviewer using Ace
28
	editor.getSession().setMode("ace/mode/'.$lang.'");
29
	editor.setReadOnly(true);
30
	editor.setShowPrintMargin(false);
31
	editor.setDisplayIndentGuides(false);
15.1.2 by galaxyAbstractor
Split css and js to external files
32
	editor.setHighlightSelectedWord(true);
33
	lines = editor.getSession().getLength();
34
	$("#ace_'.str_replace(".", "", $filename).'").height(Math.min(500,lines*16));
35
	aceeditors.push("ace_'.str_replace(".", "", $filename).'");';
36
	for($i = 0; $i < count($interestingrows); $i++) {
37
		echo 'editor.getSession().addMarker(new Range('.$interestingrows[$i][0].', 0, '
38
			.$interestingrows[$i][1].', Number.POSITIVE_INFINITY), "interesting", "text",false);';
15.1.1 by galaxyAbstractor
Started implementation of a new codeviewer using Ace
39
	}
15.1.2 by galaxyAbstractor
Split css and js to external files
40
	echo '</script>';
41
15.1.1 by galaxyAbstractor
Started implementation of a new codeviewer using Ace
42
}
43
?>