find and set packages for evals

This commit is contained in:
David Botton 2022-08-03 23:45:44 -04:00
parent a70e84a062
commit 74cd1a58f5
4 changed files with 35 additions and 21 deletions

View file

@ -1,6 +1,6 @@
<data id="I3867358318" data-in-package="clog-tools" data-custom-slots="" data-clog-next-id="4" data-clog-title="clog-builder-repl"></data><div style="--pixel-density:0.994318; --char-width:7.20312; box-sizing: content-box; position: absolute; inset: 30px 0px 0px;" class="terminal" data-clog-type="clog-terminal" data-clog-composite-control="t" data-clog-terminal-prompt="> " data-clog-terminal-greetings="CLOG Builder REPL" data-clog-name="terminal" data-on-command="(multiple-value-bind (result new-package)
<data id="I3868568770" data-in-package="clog-tools" data-custom-slots="" data-clog-next-id="4" data-clog-title="clog-builder-repl"></data><div style="--pixel-density:0.994318; --char-width:7.24432; box-sizing: content-box; position: absolute; inset: 30px 0px 0px;" class="terminal" data-clog-type="clog-terminal" data-clog-composite-control="t" data-clog-terminal-prompt="> " data-clog-terminal-greetings="CLOG Builder REPL" data-clog-name="terminal" data-on-command="(multiple-value-bind (result new-package)
(capture-eval data :clog-obj panel
:eval-in-package (text-value (package-div panel)))
(setf (text-value (package-div panel))
(string-downcase (package-name new-package)))
(clog-terminal:echo target result))"></div><input type="TEXT" value="clog-user" data-clog-type="input" data-clog-name="package-div" style="box-sizing: content-box; position: absolute; inset: 0px 0px 338.5px; height: 25px;" placeholder="" class="w3-black">
(clog-terminal:echo target result))"></div><input type="TEXT" value="clog-user" data-clog-type="input" data-clog-name="package-div" style="box-sizing: content-box; position: absolute; inset: 0px 0px 338.5px; height: 25px;" placeholder="Current Package" class="w3-black">

View file

@ -6,15 +6,15 @@
(let ((panel
(change-class
(clog:create-div clog-obj :content
"<div style=\"--pixel-density:0.994318; --char-width:7.24432; box-sizing: content-box; position: absolute; inset: 30px 0px 0px;\" class=\"terminal\" id=\"CLOGB3868051526\" data-clog-name=\"terminal\"></div><input type=\"TEXT\" value=\"clog-user\" style=\"box-sizing: content-box; position: absolute; inset: 0px 0px 338.5px; height: 25px;\" placeholder=\"\" class=\"w3-black\" id=\"CLOGB3868051527\" data-clog-name=\"package-div\">"
"<div style=\"--pixel-density:0.994318; --char-width:7.24432; box-sizing: content-box; position: absolute; inset: 30px 0px 0px;\" class=\"terminal\" id=\"CLOGB3868568690\" data-clog-name=\"terminal\"></div><input type=\"TEXT\" value=\"clog-user\" style=\"box-sizing: content-box; position: absolute; inset: 0px 0px 338.5px; height: 25px;\" placeholder=\"Current Package\" class=\"w3-black\" id=\"CLOGB3868568691\" data-clog-name=\"package-div\">"
:hidden hidden :class class :html-id html-id
:auto-place auto-place)
'clog-builder-repl)))
(setf (slot-value panel 'package-div)
(attach-as-child clog-obj "CLOGB3868051527" :clog-type
(attach-as-child clog-obj "CLOGB3868568691" :clog-type
'clog:clog-form-element :new-id t))
(setf (slot-value panel 'terminal)
(attach-as-child clog-obj "CLOGB3868051526" :clog-type
(attach-as-child clog-obj "CLOGB3868568690" :clog-type
'clog-terminal:clog-terminal-element :new-id t))
(let ((target (terminal panel)))
(declare (ignorable target))

View file

@ -2147,6 +2147,7 @@ of controls and double click to select control."
(btn-esel (create-button tool-bar :content "Eval Sel" :class (format nil "w3-tiny ~A" btn-class)))
(btn-test (create-button tool-bar :content "Eval" :class (format nil "w3-tiny ~A" btn-class)))
(content (center-panel box))
(pac-line (create-form-element content :text :class "w3-black"))
(ace (clog-ace:create-clog-ace-element content))
(status (create-div content :class "w3-tiny w3-border"))
(lisp-file t)
@ -2180,8 +2181,12 @@ of controls and double click to select control."
(setf (width btn-test) "40px")
(setf (positioning ace) :absolute)
(setf (positioning status) :absolute)
(set-geometry pac-line :units "" :top "20px" :left "0px"
:right "0px" :height "22px" :width "100%")
(setf (place-holder pac-line) "Current Package")
(setf (text-value pac-line) "clog-user")
(set-geometry ace :units "" :width "" :height ""
:top "0px" :bottom "20px" :left "0px" :right "0px")
:top "22px" :bottom "20px" :left "0px" :right "0px")
(clog-ace:resize ace)
(set-geometry status :units "" :width "" :height "20px"
:bottom "0px" :left "0px" :right "0px")
@ -2193,19 +2198,29 @@ of controls and double click to select control."
(flet ((open-file-name (fname)
(window-focus win)
(when fname
(cond ((or (equalp (pathname-type fname) "lisp")
(equalp (pathname-type fname) "asd"))
(setf (clog-ace:mode ace) "ace/mode/lisp")
(setf lisp-file t)
(setf (current-editor-is-lisp app) t))
(t
(setf lisp-file nil)
(setf (current-editor-is-lisp app) nil)
(setf (clog-ace:mode ace) (clog-ace:get-mode-from-extension ace fname))))
(setf file-name fname)
(setf (window-title win) fname)
(setf (clog-ace:text-value ace)
(or (read-file fname) "")))))
(let ((c (or (read-file fname) ""))
loc)
(cond ((or (equalp (pathname-type fname) "lisp")
(equalp (pathname-type fname) "asd"))
(setf (clog-ace:mode ace) "ace/mode/lisp")
(setf lisp-file t)
(setf (current-editor-is-lisp app) t)
;; set package
(with-input-from-string (ins c)
(loop
(let ((form (read ins nil)))
(unless form (return))
(unless (consp form) (return))
(when (eq (car form) 'in-package)
(setf (text-value pac-line) (string-downcase (second form)))
(return))))))
(t
(setf lisp-file nil)
(setf (current-editor-is-lisp app) nil)
(setf (clog-ace:mode ace) (clog-ace:get-mode-from-extension ace fname))))
(setf (clog-ace:text-value ace) c)))))
(when open-file
(open-file-name open-file))
(set-on-click btn-load (lambda (obj)
@ -2243,7 +2258,7 @@ of controls and double click to select control."
(let ((val (clog-ace:selected-text ace)))
(unless (equal val "")
(let ((result (capture-eval val :clog-obj obj
:eval-in-package "CLOG-USER")))
:eval-in-package (text-value pac-line))))
(clog-web-alert (connection-body obj) "Result"
(format nil "~&result: ~A" result)
:color-class "w3-green"
@ -2252,7 +2267,7 @@ of controls and double click to select control."
(let ((val (text-value ace)))
(unless (equal val "")
(let ((result (capture-eval val :clog-obj obj
:eval-in-package "CLOG-USER")))
:eval-in-package (text-value pac-line))))
(clog-web-alert (connection-body obj) "Result"
(format nil "~&result: ~A" result)
:color-class "w3-green"

View file

@ -1,4 +1,3 @@
(in-package "CLOG-TOOLS")
(defclass projects (clog:clog-panel)
((reload-project-button :reader reload-project-button)