From eb8d0fb6e7c3e0b7feef1e372d17c3f10c3bd98b Mon Sep 17 00:00:00 2001 From: Alex Klinkhamer Date: Sun, 22 Jun 2008 23:13:58 -0400 Subject: [PATCH] +CSS formatting The damn thing looked terrible in Konqueror. --- http_root/calcupage.css | 103 ++++++++++++++++ src/webui/calcupage-buttons.lisp | 127 +++++++++++++++++++ src/webui/calcupage.lisp | 208 ++++++++++++++++---------------- src/webui/compile-ps.lisp | 2 - src/webui/devvars.lisp | 3 +- src/webui/psfiles/calcupage-infix.lisp | 28 ----- src/webui/psfiles/calcupage-prefix.lisp | 26 ---- 7 files changed, 336 insertions(+), 161 deletions(-) create mode 100644 http_root/calcupage.css create mode 100644 src/webui/calcupage-buttons.lisp rewrite src/webui/calcupage.lisp (61%) delete mode 100644 src/webui/psfiles/calcupage-infix.lisp delete mode 100644 src/webui/psfiles/calcupage-prefix.lisp diff --git a/http_root/calcupage.css b/http_root/calcupage.css new file mode 100644 index 0000000..7a2560b --- /dev/null +++ b/http_root/calcupage.css @@ -0,0 +1,103 @@ + +body +{ + font-size:1.2em; +} + +th.linalg-buttons +{ + width:12em; +} + +th.stdmath-buttons +{ + width:7em; +} + +td.quick-buttons +{ + width:7em; +} + +#calcIn +{ + width:100%; + height:15em; + font-family:monospace; + spellcheck:"false"; + wrap:hard; +} + +input +{ + color:#000000; + background-color:#D3D3D3; + border-top-width:1px; + border-bottom-width:1px; + border-left-width:1px; + border-right-width:1px; +} + +#varbutton +{ + +} + +#digit +{ + width:1.75em; + color:#EEEEEE; + background-color:#000000; +} + +#zerodigit +{ + width:3.5em; + color:#EEEEEE; + background-color:#000000; +} + +#recall +{ + width:4.0em; + color:#EEEEEE; + background-color:#2F4F4F; +} + +#store +{ + width:3.5em; + color:#EEEEEE; + background-color:#6A5ACD +} + +#ok +{ + color:#EEEEEE; + background-color:#009900; +} + +#clear +{ + color:#EEEEEE; + background-color:#AA0000; +} + +#fn1 +{ + width:1.75em; +} + +#fn2 +{ + width:3.0em; +} + +#fn3 +{ + width:3.5em; +} + + + + diff --git a/src/webui/calcupage-buttons.lisp b/src/webui/calcupage-buttons.lisp new file mode 100644 index 0000000..69325df --- /dev/null +++ b/src/webui/calcupage-buttons.lisp @@ -0,0 +1,127 @@ +(in-package :lineal.webui) + +(defun htm-button + (text id action) + (with-html-output-to-string + (strm) + (:input :type "button" + :id id + :onclick action + :value text))) + +(defun htm-input-button (name id tosend) + (htm-button + name id + (concatenate 'string "uinput(\"" tosend "\")"))) + +(defun opern-button + (name infixp &key (id "fn1") (input name)) + (htm-input-button + name id + (if infixp input + (concatenate + 'string "(" input " ")))) + +(defun htm-fnbut + (name id infix multi-param-p + &optional (fntext name)) + (htm-input-button + name id + (if infix + (concatenate + 'string fntext + (if multi-param-p "(" " ")) + (concatenate + 'string "(" fntext " ")))) + +(defun htm-linalg-buttons (infix) + (let + ((linalg-fnlis + `("ref" "det" + nil "transpose" "inverse" + nil ("dot") ("cross") + ("proj") ("orth") + nil ("cat") ("vcat") ("crop") ("vcrop")))) + (with-output-to-string (strm) + (mapc + (lambda (args) + (princ + (cond + ((not args) "
") + ((stringp args) + (htm-fnbut + args + (format nil "fn~A" (length args)) + infix nil)) + (t (destructuring-bind + (name &optional id) args + (htm-fnbut + name + (if id id + (format nil "fn~A" (length name))) + infix t)))) + strm)) + linalg-fnlis)))) + + +; (show-a-button "ok" elem "sendCalc()" 25 "white" "green")) +;(show-a-button "clear" elem "cleartext()" 45 "white" "darkred")) + +;-- BEGIN SPECIAL BUTTON CREATORS -- + +;V Use the button operation as a name.V +(defun simple-input-button (name &optional (id "fn1")) + (htm-input-button name id name)) + +(defun clear-button () + (htm-button "clear" "clear" "cleartext()")) + + +(defun ok-button () + (htm-button "ok" "ok" "sendCalc()")) + + +(defun memory-buttons (infix) + (concatenate + 'string + (htm-input-button + "recall" "recall" + (if infix "recall(\\\"" "(recall \\\"")) + (htm-input-button + "store" "store" + (if infix "store(\\\"" "(store \\\"")))) + +;-- END SPECIAL BUTTON CREATORS -- + +(defun htm-standard-math-buttons (infixp) + (labels + ((htm-3digits + (x) + (with-output-to-string (strm) + (dotimes (i 3) + (princ + (simple-input-button + (princ-to-string (+ i x)) + "digit") + strm))))) + (concatenate + 'string + (htm-fnbut "√" "fn1" infixp nil "sqrt") + (if infixp + (opern-button "^" t) + (opern-button "^" nil :input "expt")) + (simple-input-button "(") + (simple-input-button ")") + "
" (htm-3digits 7) + (opern-button "/" infixp) + "
" (htm-3digits 4) + (opern-button "×" infixp :input "*") + "
" (htm-3digits 1) + (opern-button "-" infixp) + "
" + (simple-input-button "0" "zerodigit") + (simple-input-button "." "digit") + (opern-button "+" infixp) + "
" + (memory-buttons infixp)))) + diff --git a/src/webui/calcupage.lisp b/src/webui/calcupage.lisp dissimilarity index 61% index 427f3bc..c8e1dd4 100644 --- a/src/webui/calcupage.lisp +++ b/src/webui/calcupage.lisp @@ -1,104 +1,104 @@ - -(in-package :lineal.webui) - -;V URL: /process-infix -;V Receive user's calculation, return result.V -(defun receive-and-process - (&optional prefix-style - &aux (text (parameter "text")) - (log-calcs (load-time-value - (boundp 'lineal.devvars::log-calcs)))) - (when log-calcs (log-message* "parser receives: ~%~A" text)) - (setq - text - (if prefix-style - (process-input-from-string text) - (with-output-to-string (strm) - (over-format - (process-infix-from-string text) - strm)))) - (when log-calcs (log-message* "parser replies: ~%~A" text)) - text) - -;V URL: /process-prefix -(defun receive-and-process-prefix () - (receive-and-process t)) - -;V URL: /calcupage-infix -(defun calcupage (&optional prefix-style) - (with-html-output-to-string - (s nil :prologue t) - (:html - (:head - (:title "Calculate things.") - (:style - :type "text/css" - (mapc (lambda (line) - (princ line s) - (terpri s)) - '(""))) - (jsfile s "calcupage") - (if prefix-style - (jsfile s "calcupage-prefix") - (jsfile s "calcupage-infix")) - (jsfile s "connects")) - (:body - (:div (:a :href "/input_matrix" "Create and edit") - " vectors and matrices" :br - "Use " - (if prefix-style - (with-html-output - (s) (:a :href "/calcupage-infix" "infix")) - (with-html-output - (s) (:a :href "/calcupage-prefix" "prefix"))) - " notation instead." :br - (:a :href "/" "Main") " Page") - (:table - :width "100%" - (:tr - (:th :rowspan "2" :width "170" - (:div :id "linopdiv") - (ps-tag s (show-linops (.get-element-by-id document "linopdiv")))) - (:th :rowspan "2" :width "110" - ;V Show operator buttons on left.V - (:div :id "opdiv" - (ps-tag s (show-standops (.get-element-by-id document "opdiv"))))) - ;V Before variable names, show some easy-access buttons.V - (:td :width "100" - (:div :id "leftvardiv" - (ps-tag s (defvar leftvardiv (.get-element-by-id document "leftvardiv")) - (memory-buttons leftvardiv) - (.append-child leftvardiv (.create-element document "br")) - (clear-button leftvardiv) - (show-input-button """ leftvardiv "\\\"") - (ok-button leftvardiv)))) - ;V Show variables on the top.V - (:td (:div :id "vardiv" - (format - s - (concatenate - 'string "~{~{~A: " - "~{~}" - "~#[
~:;~]~}~}") - `(("Numbers" ,*saved-numbers*) - ("Vectors" ,*saved-tuples*) - ("Matrices" ,*saved-matrices*)))))) - ;V main textarea V - (:tr (:td :colspan "2" - (:textarea :style "font-family: monospace; width: 100%" :rows "12" - :wrap "hard" :id "calcIn" :spellcheck "false")))) - ;V Make a place to show results.V - (:pre :id "resultPre") - (ps-tag - s (setf calc-in (.get-element-by-id document "calcIn"))))))) - -;V URL: /calcupage-prefix -(defun calcupage-prefix () - (calcupage t)) - - + +(in-package :lineal.webui) + +;V URL: /process-infix +;V Receive user's calculation, return result.V +(defun receive-and-process + (&optional (infixp t) + &aux (text (parameter "text")) + (log-calcs (load-time-value + (boundp 'lineal.devvars::log-calcs)))) + (when log-calcs (log-message* "parser receives: ~%~A" text)) + (setq + text + (if infixp + (with-output-to-string (strm) + (over-format + (process-infix-from-string text) + strm)) + (process-input-from-string text))) + (when log-calcs (log-message* "parser replies: ~%~A" text)) + text) + +;V URL: /process-prefix +(defun receive-and-process-prefix () + (receive-and-process nil)) + +(defmacro htm-expand-known-if + (strm infixp s-expr) + `(princ + (if ,infixp + (load-time-value (,@s-expr t)) + (load-time-value (,@s-expr nil))) + ,strm)) + +;V URL: /calcupage-infix +(defun calcupage (&optional (infixp t)) + (with-html-output-to-string + (s nil :prologue t) + (:html + (:head + (:title "Calculate things.") + (:link :rel "stylesheet" :href "calcupage.css") + (jsfile s "calcupage") + (jsfile s "connects")) + (:body + (:div (:a :href "/input_matrix" "Create and edit") + " vectors and matrices" :br + "Use " + (if infixp + (htm (:a :href "/calcupage-prefix" "prefix")) + (htm (:a :href "/calcupage-infix" "infix"))) + " notation instead." :br + (:a :href "/" "Main") " Page") + (:table + :width "100%" + (:tr + (:th :rowspan "2" :class "linalg-buttons" + (htm-expand-known-if + s infixp (htm-linalg-buttons))) + (:th :rowspan "2" :class "stdmath-buttons" + ;V Show operator buttons on left.V + (htm-expand-known-if + s infixp (htm-standard-math-buttons))) + ;V Before variable names, show some easy-access buttons.V + (:td :class "quick-buttons" + (htm-expand-known-if + s infixp (memory-buttons)) + (princ + (load-time-value + (concatenate + 'string "
" + (clear-button) + (htm-input-button + """ "fn1" "\\\"") + (ok-button))) + s)) + ;V Show variables on the top.V + (:td + (do ((lvpairs-left + `(("Numbers: " ,*saved-numbers*) + ("Vectors: " ,*saved-tuples*) + ("Matrices: " ,*saved-matrices*)))) + (nil) + (princ (caar lvpairs-left) s) + (dolist (k (cadar lvpairs-left)) + (princ (simple-input-button k "varbutton") s)) + (unless (setq lvpairs-left (cdr lvpairs-left)) + (return (values))) + (princ "
" s)))) + ;V main textarea V + (:tr (:td :colspan "2" + (:textarea :id "calcIn" :spellcheck "false")))) + ;V Make a place to show results.V + (:pre :id "resultPre") + (if infixp (ps-tag s (setf process-loc "/process-infix")) + (ps-tag s (setf process-loc "/process-prefix"))) + (ps-tag + s (setf calc-in (.get-element-by-id document "calcIn"))))))) + +;V URL: /calcupage-prefix +(defun calcupage-prefix () + (calcupage nil)) + + diff --git a/src/webui/compile-ps.lisp b/src/webui/compile-ps.lisp index 4aaba39..630a06b 100644 --- a/src/webui/compile-ps.lisp +++ b/src/webui/compile-ps.lisp @@ -30,8 +30,6 @@ :directory '(:relative "http_root" "jsfiles") :name name :type "js"))) '("calcupage" - "calcupage-infix" - "calcupage-prefix" "connects" "matrix-edit"))) diff --git a/src/webui/devvars.lisp b/src/webui/devvars.lisp index cb0e118..38ba2b5 100644 --- a/src/webui/devvars.lisp +++ b/src/webui/devvars.lisp @@ -15,7 +15,8 @@ "save-restore" ("overload" "client-fns") ("webui" "webvars" "compile-ps" "index" "matrixui" - "calcupage" "save-restore" "reload"))) + "calcupage-buttons" "calcupage" + "save-restore" "reload"))) (defun compile-if-new (name src-dir &key (fasl-dir src-dir) diff --git a/src/webui/psfiles/calcupage-infix.lisp b/src/webui/psfiles/calcupage-infix.lisp deleted file mode 100644 index e9b30db..0000000 --- a/src/webui/psfiles/calcupage-infix.lisp +++ /dev/null @@ -1,28 +0,0 @@ - -(defvar process-loc "/process-infix") - -(defun show-func (name elem width fcolor bcolor) - (show-input-button name elem (+ name " ") - width fcolor bcolor)) - -(defun show-binop (name elem width fcolor bcolor) - (show-input-button - name elem name width fcolor bcolor)) - -(defun show-multi-func (name elem width fcolor bcolor) - (show-input-button name elem (+ name "(") - width fcolor bcolor)) - -(defun memory-buttons (elem) - (show-input-button "recall" elem "recall(\\\"" 50 "white" "DarkSlateGray") - (show-input-button "store" elem "store(\\\"" 50 "white" "SlateBlue")) - -(defun sqrt-button (elem) - (show-input-button "√" elem "sqrt ")) - -(defun expt-button (elem) - (show-binop "^" elem)) - -(defun times-button (elem) - (show-input-button "×" elem "*")) - diff --git a/src/webui/psfiles/calcupage-prefix.lisp b/src/webui/psfiles/calcupage-prefix.lisp deleted file mode 100644 index 4dd611c..0000000 --- a/src/webui/psfiles/calcupage-prefix.lisp +++ /dev/null @@ -1,26 +0,0 @@ - -(defvar process-loc "/process-prefix") - -(defun show-func (name elem width fcolor bcolor) - (show-input-button name elem (+ "(" name " ") - width fcolor bcolor)) - -(defun show-binop (name elem width fcolor bcolor) - (show-func name elem width fcolor bcolor)) - -(defun show-multi-func (name elem width fcolor bcolor) - (show-func name elem width fcolor bcolor)) - -(defun memory-buttons (elem) - (show-input-button "recall" elem "(recall \\\"" 50 "white" "DarkSlateGray") - (show-input-button "store" elem "(store \\\"" 50 "white" "SlateBlue")) - -(defun sqrt-button (elem) - (show-input-button "√" elem "(sqrt ")) - -(defun expt-button (elem) - (show-input-button "^" elem "(expt ")) - -(defun times-button (elem) - (show-input-button "×" elem "(* ")) - -- 2.11.4.GIT