Improve scrolling in the console
[jscl.git] / lispstrack.html
1 <!doctype html>
2 <html>
3   <head>
4     <style>
5      /* The console container element */
6     body { background-color: black; font-size: 16px; font-family: Courier; overflow: hidden; padding: 0 0 0 0;}
7     #console {
8       position: absolute;
9       top: 0px;
10       bottom: 0px;
11       left: 0px;
12       right: 0px;
13       background-color:black;
14     }
15     /* The inner console element. */
16     .jqconsole {
17         padding: 10px;
18     }
19     /* The cursor. */
20     .jqconsole-cursor {
21         background-color: gray;
22     }
23     /* The cursor color when the console looses focus. */
24     .jqconsole-blurred .jqconsole-cursor {
25         background-color: #666;
26     }
27     /* The current prompt text color */
28     .jqconsole-prompt {
29         color: White;
30     }
31     /* The command history */
32     .jqconsole-old-prompt {
33         color: White;
34         font-weight: normal;
35     }
36     /* The text color when in input mode. */
37     .jqconsole-input {
38         color: White;
39     }
40     /* Previously entered input. */
41     .jqconsole-old-input {
42         color: White;
43         font-weight: normal;
44     }
45     /* The text color of the output. */
46     .jqconsole-output, .jqconsole-header {
47         color: gray;
48     }
49     .jqconsole-error {
50         color: red;
51     }
52 </style>
53   </head>
54
55   <body>
56     <div id="console"></div>
57     <script src="lispstrack.js" type="text/javascript"></script>
58     <script src="jquery.js" type="text/javascript" charset="utf-8"></script>
59     <script src="jqconsole.min.js" type="text/javascript" charset="utf-8"></script>
60     <script>
61       $(function () {
62         var jqconsole = $('#console').jqconsole('Welcome to Lisptrack!\n\n', '> ');
63         jqconsole.RegisterMatching('(', ')', 'parents');
64
65         var startPrompt = function () {
66           // Start the prompt with history enabled.
67           jqconsole.Prompt(true, function (input) {
68             // Output input with the class jqconsole-output.
69             if (input[0] != ','){
70                 try {
71                     jqconsole.Write(JSON.stringify(lisp.evalString(input)) + '\n', 'jqconsole-output');
72                 } catch(error) {
73                     jqconsole.Write('ERROR: ' + error + '\n', 'jqconsole-error');
74                 }
75             } else {
76                 jqconsole.Write(JSON.stringify(lisp.compileString(input.slice(1))) + '\n', 'jqconsole-output');
77             }
78             // Restart the prompt.
79             startPrompt();
80           }, function(input){
81             try {
82                 lisp.read(input[0]==','? input.slice(1): input);
83             } catch(error) {
84                 return 0;
85             }
86             return false;
87           });
88         };
89         startPrompt();
90       });
91     </script>
92   </body>
93 </html>