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">
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}
15 <script type="text/javascript" src="../../addon/runmode/runmode.js"></script>
17 <body onload="init()">
18 <h1>CodeMirror: VB.NET mode</h1>
19 <script type="text/javascript">
20 function test(golden, text) {
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);
32 CodeMirror.runMode(text, "text/x-vb",callback);
34 if (ok) return "Tests OK";
36 function testTypes() {
37 var golden = [['Integer','keyword'],[' ','null'],['Float','keyword']]
38 var text = "Integer Float";
39 return test(golden,text);
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);
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);
54 result += testTypes() + "\n";
55 result += testIf() + "\n";
56 result += testDecl() + "\n";
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);
66 editor = CodeMirror.fromTextArea(document.getElementById("solution"), {
75 document.getElementById('testresult').innerHTML = testAll();
83 <textarea style="width:95%;height:200px;padding:5px;" name="solution" id="solution" ></textarea>
85 <pre id="testresult"></pre>
86 <p>MIME type defined: <code>text/x-vb</code>.</p>