Console
authorDavid Vazquez <davazp@gmail.com>
Sat, 22 Dec 2012 15:42:53 +0000 (15:42 +0000)
committerDavid Vazquez <davazp@gmail.com>
Sat, 22 Dec 2012 15:42:53 +0000 (15:42 +0000)
.gitignore
lispstrack.lisp
test.html
test.lisp

index 61c0db2..8b097cd 100644 (file)
@@ -1,3 +1,5 @@
 test.js
 *~
 *.fasl
+/jqconsole.min.js
+/jquery.js
index 94f5a37..3b76ca4 100644 (file)
   (and (symbolp x) (eq (binding-type (lookup-function x *fenv*)) 'macro)))
 
 (defun ls-macroexpand-1 (form env fenv)
-  (when (macrop (car form))
-    (let ((binding (lookup-function (car form) *env*)))
-      (if (eq (binding-type binding) 'macro)
-          (apply (eval (binding-translation binding)) (cdr form))
-          form))))
+  (if (macrop (car form))
+      (let ((binding (lookup-function (car form) *env*)))
+        (if (eq (binding-type binding) 'macro)
+            (apply (eval (binding-translation binding)) (cdr form))
+            form))
+      form))
 
 (defun compile-funcall (function args env fenv)
   (cond
index 7ef4cf5..322ccbf 100644 (file)
--- a/test.html
+++ b/test.html
@@ -1,6 +1,74 @@
 <!doctype html>
 <html>
+  <head>
+    <style>
+     /* The console container element */
+    body { background-color: black; font-size: 16px; font-family: Courier; }
+
+    #console {
+      position: absolute;
+      width: 100%;
+      height: 100%;
+      background-color:black;
+    }
+    /* The inner console element. */
+    .jqconsole {
+        padding: 10px;
+    }
+    /* The cursor. */
+    .jqconsole-cursor {
+        background-color: gray;
+    }
+    /* The cursor color when the console looses focus. */
+    .jqconsole-blurred .jqconsole-cursor {
+        background-color: #666;
+    }
+    /* The current prompt text color */
+    .jqconsole-prompt {
+        color: White;
+    }
+    /* The command history */
+    .jqconsole-old-prompt {
+        color: White;
+        font-weight: normal;
+    }
+    /* The text color when in input mode. */
+    .jqconsole-input {
+        color: White;
+    }
+    /* Previously entered input. */
+    .jqconsole-old-input {
+        color: White;
+        font-weight: normal;
+    }
+    /* The text color of the output. */
+    .jqconsole-output {
+        color: gray;
+    }
+    </style>
+  </head>
+
   <body>
-    <script type="text/javascript" src="test.js"></script>
+    <div id="console"></div>
+    <script src="test.js" type="text/javascript"></script>
+    <script src="jquery.js" type="text/javascript" charset="utf-8"></script>
+    <script src="jqconsole.min.js" type="text/javascript" charset="utf-8"></script>
+    <script>
+      $(function () {
+        var jqconsole = $('#console').jqconsole('Hi\n', '> ');
+        var startPrompt = function () {
+          // Start the prompt with history enabled.
+          jqconsole.Prompt(true, function (input) {
+            // Output input with the class jqconsole-output.
+            if (input[0] == ',')
+                jqconsole.Write(JSON.stringify(lisp.evalString(input)) + '\n', 'jqconsole-output');
+                jqconsole.Write(JSON.stringify(lisp.compileString(input)) + '\n', 'jqconsole-output');
+            // Restart the prompt.
+            startPrompt();
+          });
+        };
+        startPrompt();
+      });
+    </script>
   </body>
 </html>
index 7652409..2333621 100644 (file)
--- a/test.lisp
+++ b/test.lisp
@@ -964,11 +964,12 @@ c(defmacro eval-when-compile (&body body)
   (and (symbolp x) (eq (binding-type (lookup-function x *fenv*)) 'macro)))
 
 (defun ls-macroexpand-1 (form env fenv)
-  (when (macrop (car form))
-    (let ((binding (lookup-function (car form) *env*)))
-      (if (eq (binding-type binding) 'macro)
-          (apply (eval (binding-translation binding)) (cdr form))
-          form))))
+  (if (macrop (car form))
+      (let ((binding (lookup-function (car form) *env*)))
+        (if (eq (binding-type binding) 'macro)
+            (apply (eval (binding-translation binding)) (cdr form))
+            form))
+      form))
 
 (defun compile-funcall (function args env fenv)
   (cond