/lenasys/trunk

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/lenasys/trunk

« back to all changes in this revision

Viewing changes to codehighlighterimpl/showcode.php

  • Committer: Gustav Hartvigsson
  • Date: 2013-04-05 15:54:35 UTC
  • mfrom: (19.1.4 lenasys)
  • Revision ID: gustav.hartvigsson@gmail.com-20130405155435-lf76rf1vwcacin4p
Merged from implementation group 1's team branch into trunk, 20130405 end of
day.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
<?php
2
2
 
3
 
function showfile($filename, $lang) {
 
3
function showfile($filename, $lang, $interestingrows = array()) {
4
4
        echo "<strong>".$filename."</strong>";
5
 
        echo '<div id="ace_'.str_replace(".", "", $filename).'"" class="ace">';
 
5
        echo '<div id="ace_'.str_replace(".", "", $filename).'" class="ace">';
6
6
        $handle = @fopen($filename, "r");
7
7
        if ($handle) {
8
8
 
11
11
                        $buffer = str_replace("&", "&amp;", $buffer);
12
12
                        $buffer = str_replace("<", "&lt;", $buffer);
13
13
                        $buffer = str_replace(">", "&gt;", $buffer);
14
 
                        
15
14
 
16
15
                        echo $buffer;
17
16
                }
22
21
        }
23
22
        echo '</div>';
24
23
 
25
 
        echo  '
26
 
<script type="text/javascript">
 
24
        echo  '<script type="text/javascript">
 
25
        var Range = require("ace/range").Range;
27
26
        var editor = ace.edit("ace_'.str_replace(".", "", $filename).'");
28
 
        editor.setTheme("ace/theme/monokai");
 
27
        editor.setTheme("ace/theme/merbivore");
29
28
        editor.getSession().setMode("ace/mode/'.$lang.'");
30
29
        editor.setReadOnly(true);
31
30
        editor.setShowPrintMargin(false);
32
31
        editor.setDisplayIndentGuides(false);
33
 
        aceeditors.push("ace_'.str_replace(".", "", $filename).'");
34
 
        </script>
35
 
';
36
 
 
37
 
}
38
 
 
39
 
function showdoc($filename) {
40
 
 
41
 
        $handle = @fopen($filename, "r");
42
 
        if ($handle) {
43
 
 
44
 
 
45
 
                while (($buffer = fgets($handle, 4096)) !== false) {
46
 
                        echo $buffer;
47
 
                }
48
 
                if (!feof($handle)) {
49
 
                        echo "Error: unexpected fgets() fail\n";
50
 
                }
51
 
                fclose($handle);
 
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);';
52
39
        }
 
40
        echo '</script>';
 
41
 
53
42
}
54
43
?>
 
 
b'\\ No newline at end of file'