+Trace function, +Constants
[lineal.git] / src / webui / calcupage.lisp
blob2f8a2ceb1ae76e791068f41245fce91d8fdeefd2
2 ;V URL: /process-infix
3 ;V Receive user's calculation, return result.V
4 (defun receive-and-process
5 (&optional (infixp t)
6 &aux (text (parameter "text"))
7 (log-calcs (load-time-value
8 (boundp 'lineal.devvars::log-calcs))))
9 (when log-calcs (log-message* "parser receives: ~%~A" text))
10 (setq
11 text
12 (with-output-to-string (strm)
13 (over-format
14 (process-input-from-string text infixp)
15 strm)))
16 (when log-calcs (log-message* "parser replies: ~%~A" text))
17 text)
19 ;V URL: /process-prefix
20 (defun receive-and-process-prefix ()
21 (receive-and-process nil))
23 (defmacro htm-expand-known-if
24 (strm infixp s-expr)
25 `(princ
26 (if ,infixp
27 (load-time-value (,@s-expr t))
28 (load-time-value (,@s-expr nil)))
29 ,strm))
31 ;V URL: /calcupage-infix
32 (defun calcupage (&optional (infixp t))
33 (with-html-output-to-string
34 (s nil :prologue t)
35 (:html
36 (:head
37 (:title "Calculate things.")
38 (:link :rel "stylesheet" :href "calcupage.css")
39 (jsfile s "calcupage")
40 (jsfile s "connects"))
41 (:body
42 (:div (:a :href "/input_matrix" "Create and edit")
43 " vectors and matrices" :br
44 "Use "
45 (if infixp
46 (htm (:a :href "/calcupage-prefix" "prefix"))
47 (htm (:a :href "/calcupage-infix" "infix")))
48 " notation instead." :br
49 (:a :href "/" "Main") " Page")
50 (:table
51 :width "100%"
52 (:tr
53 (:th :rowspan "2" :class "linalg-buttons"
54 (htm-expand-known-if
55 s infixp (htm-linalg-buttons)))
56 (:th :rowspan "2" :class "stdmath-buttons"
57 ;V Show operator buttons on left.V
58 (htm-expand-known-if
59 s infixp (htm-standard-math-buttons)))
60 ;V Before variable names, show some easy-access buttons.V
61 (:td :class "quick-buttons"
62 (htm-expand-known-if
63 s infixp (memory-buttons))
64 (princ
65 (load-time-value
66 (concatenate
67 'string "<br/>"
68 (clear-button)
69 (htm-input-button
70 "&quot;" "fn1" "\\\"")
71 (ok-button)))
72 s))
73 ;V Show variables on the top.V
74 (:td
75 (do ((lvpairs-left
76 `(("Numbers: " ,*saved-numbers*)
77 ("Vectors: " ,*saved-tuples*)
78 ("Matrices: " ,*saved-matrices*))))
79 (nil)
80 (princ (caar lvpairs-left) s)
81 (dolist (k (cadar lvpairs-left))
82 (princ (simple-input-button k "varbutton") s))
83 (unless (setq lvpairs-left (cdr lvpairs-left))
84 (return (values)))
85 (princ "<br/>" s))))
86 ;V main textarea V
87 (:tr (:td :colspan "2"
88 (:textarea :id "calcIn" :spellcheck "false"))))
89 ;V Make a place to show results.V
90 (:pre :id "resultPre")
91 (if infixp (ps-tag s (setf process-loc "/process-infix"))
92 (ps-tag s (setf process-loc "/process-prefix")))
93 (ps-tag
94 s (setf calc-in (.get-element-by-id document "calcIn")))))))
96 ;V URL: /calcupage-prefix
97 (defun calcupage-prefix ()
98 (calcupage nil))