74dd5e81619b3e38bedc341f43aac0dc8ed4ef9e
[myslice.git] / third-party / codemirror-3.15 / mode / vb / index.html
1 <html>
2   <head>
3     <meta charset="utf-8">
4     <title>CodeMirror: VB.NET mode</title>
5     <link rel="stylesheet" href="../../lib/codemirror.css">
6     <script src="../../lib/codemirror.js"></script>
7     <script src="vb.js"></script>
8     <link rel="stylesheet" href="../../doc/docs.css">
9     <link href="http://fonts.googleapis.com/css?family=Inconsolata" rel="stylesheet" type="text/css">
10     <style>
11       .CodeMirror {border: 1px solid #aaa; height:210px; height: auto;}
12       .CodeMirror-scroll { overflow-x: auto; overflow-y: hidden;}
13       .CodeMirror pre { font-family: Inconsolata; font-size: 14px}
14     </style> 
15     <script type="text/javascript" src="../../addon/runmode/runmode.js"></script>
16   </head>
17   <body onload="init()">
18     <h1>CodeMirror: VB.NET mode</h1>
19 <script type="text/javascript">
20 function test(golden, text) {
21   var ok = true;
22   var i = 0;
23   function callback(token, style, lineNo, pos){
24                 //console.log(String(token) + " " + String(style) + " " + String(lineNo) + " " + String(pos));
25     var result = [String(token), String(style)];
26     if (golden[i][0] != result[0] || golden[i][1] != result[1]){
27       return "Error, expected: " + String(golden[i]) + ", got: " + String(result);
28       ok = false;
29     }
30     i++;
31   }
32   CodeMirror.runMode(text, "text/x-vb",callback); 
33
34   if (ok) return "Tests OK";
35 }
36 function testTypes() {
37   var golden = [['Integer','keyword'],[' ','null'],['Float','keyword']]
38   var text =  "Integer Float";
39   return test(golden,text);
40 }
41 function testIf(){
42   var golden = [['If','keyword'],[' ','null'],['True','keyword'],[' ','null'],['End','keyword'],[' ','null'],['If','keyword']];
43   var text = 'If True End If';
44   return test(golden, text);
45 }
46 function testDecl(){
47    var golden = [['Dim','keyword'],[' ','null'],['x','variable'],[' ','null'],['as','keyword'],[' ','null'],['Integer','keyword']];
48    var text = 'Dim x as Integer';
49    return test(golden, text);
50 }
51 function testAll(){
52   var result = "";
53
54   result += testTypes() + "\n";
55   result += testIf() + "\n";
56   result += testDecl() + "\n";
57   return result;
58
59 }
60 function initText(editor) {
61   var content = 'Class rocket\nPrivate quality as Double\nPublic Sub launch() as String\nif quality > 0.8\nlaunch = "Successful"\nElse\nlaunch = "Failed"\nEnd If\nEnd sub\nEnd class\n';
62   editor.setValue(content);
63   for (var i =0; i< editor.lineCount(); i++) editor.indentLine(i);
64 }
65 function init() {
66     editor = CodeMirror.fromTextArea(document.getElementById("solution"), {
67         lineNumbers: true,
68         mode: "text/x-vb",
69         readOnly: false,
70         tabMode: "shift"
71     });
72     runTest();
73 }
74 function runTest() {
75         document.getElementById('testresult').innerHTML = testAll();
76   initText(editor);
77         
78 }
79 </script>
80
81
82   <div id="edit">
83   <textarea style="width:95%;height:200px;padding:5px;" name="solution" id="solution" ></textarea>
84   </div>
85   <pre id="testresult"></pre>
86   <p>MIME type defined: <code>text/x-vb</code>.</p>
87
88 </body></html>