repl playground

This commit is contained in:
David Botton 2024-04-19 13:00:51 -04:00
parent bcf4ff7e55
commit 3c4647a746
7 changed files with 43 additions and 16 deletions

View file

@ -1,6 +1,6 @@
(in-package :clog-tools) (in-package :clog-tools)
(defun setup-lisp-ace (editor status &key (package "CLOG-USER")) (defun setup-lisp-ace (editor status)
(let ((app (connection-data-item editor "builder-app-data"))) (let ((app (connection-data-item editor "builder-app-data")))
;; currently there is only one auto complete event for page ;; currently there is only one auto complete event for page
(unless (auto-complete-configured app) (unless (auto-complete-configured app)
@ -259,7 +259,7 @@ var endRange = ~:*~A.session.doc.indexToPosition(endIndex);
(setf r (swank::autodoc `(,ms swank::%CURSOR-MARKER%)))) (setf r (swank::autodoc `(,ms swank::%CURSOR-MARKER%))))
(if r (if r
(setf r (car r)) (setf r (car r))
(setf r (swank:operator-arglist ms package))) (setf r (swank:operator-arglist ms *PACKAGE*)))
(when status (when status
(setf (advisory-title status) (documentation (find-symbol ms) 'function))) (setf (advisory-title status) (documentation (find-symbol ms) 'function)))
(when r (when r

View file

@ -163,6 +163,10 @@
(window-maximize win)) (window-maximize win))
(when text (when text
(setf (text-value ace) text)) (setf (text-value ace) text))
(set-on-change pac-line
(lambda (obj)
(declare (ignore obj))
(setf (current-editor-is-lisp app) (text-value pac-line))))
(set-on-window-focus win (set-on-window-focus win
(lambda (obj) (lambda (obj)
(declare (ignore obj)) (declare (ignore obj))
@ -205,7 +209,7 @@
(if lisp-package (if lisp-package
(setf (text-value pac-line) lisp-package) (setf (text-value pac-line) lisp-package)
(setf (text-value pac-line) "clog-user")) (setf (text-value pac-line) "clog-user"))
(setf (current-editor-is-lisp app) "clog-user") (setf (current-editor-is-lisp app) (text-value pac-line))
(set-geometry ace :units "" :width "" :height "" (set-geometry ace :units "" :width "" :height ""
:top "22px" :bottom "20px" :left "0px" :right "0px") :top "22px" :bottom "20px" :left "0px" :right "0px")
(clog-ace:resize ace) (clog-ace:resize ace)

View file

@ -12,7 +12,8 @@
(defun on-repl (obj) (defun on-repl (obj)
"Open a REPL" "Open a REPL"
(let* ((*default-title-class* *builder-title-class*) (let* ((app (connection-data-item obj "builder-app-data"))
(*default-title-class* *builder-title-class*)
(*default-border-class* *builder-border-class*) (*default-border-class* *builder-border-class*)
(win (create-gui-window obj :title "CLOG Builder REPL" (win (create-gui-window obj :title "CLOG Builder REPL"
:top 40 :left 225 :top 40 :left 225
@ -27,6 +28,14 @@
(window-close pcon)))) (window-close pcon))))
(window-focus win)) (window-focus win))
(setup-lisp-ace (playground repl) (status repl)) (setup-lisp-ace (playground repl) (status repl))
(setf (advisory-title (send-to-repl repl))
"Click to send the editor contents to the REPL.")
(flet ((update-pac (obj)
(declare (ignore obj))
(setf (current-editor-is-lisp app) (text-value (package-div repl)))))
(set-on-window-focus win #'update-pac)
(set-on-change (package-div repl) #'update-pac)
(update-pac nil))
(setf (clog-ace:theme (playground repl)) "ace/theme/terminal") (setf (clog-ace:theme (playground repl)) "ace/theme/terminal")
(set-geometry repl :units "%" :width 100 :height 100))) (set-geometry repl :units "%" :width 100 :height 100)))
@ -35,6 +44,12 @@
(when *clog-repl-open-console-on-start* (when *clog-repl-open-console-on-start*
(on-open-console panel))) (on-open-console panel)))
(defun repl-on-send-to-repl (panel target)
(declare (ignore target))
(let ((cmd (text-value (playground panel))))
(clog-terminal:echo (terminal panel) cmd)
(repl-on-commmand panel (terminal panel) cmd)))
(defun repl-on-commmand (panel target data) (defun repl-on-commmand (panel target data)
(cond ((or (equalp data ":e") (cond ((or (equalp data ":e")
(equalp data ":q")) (equalp data ":q"))

View file

@ -23,7 +23,7 @@
;; Use console for evals instead of capture ;; Use console for evals instead of capture
(defparameter *editor-use-console-for-evals* nil) (defparameter *editor-use-console-for-evals* nil)
;; Use TAB key as in emacs (can always use ctl/alt-t) ;; Use TAB key as in emacs (can always use ctl/alt-t)
(defparameter *editor-use-tab-as-tabbify* nil) (defparameter *editor-use-tab-as-tabbify* t)
;; Use emacs instead of the source-editor when openning external ;; Use emacs instead of the source-editor when openning external
(defparameter *open-external-with-emacs* nil) (defparameter *open-external-with-emacs* nil)
;; Best Light Theme for Lisp ;; Best Light Theme for Lisp
@ -49,7 +49,7 @@
(defparameter *clog-repl-use-console* t) (defparameter *clog-repl-use-console* t)
(defparameter *clog-repl-open-console-on-start* nil) (defparameter *clog-repl-open-console-on-start* nil)
(defparameter *clog-repl-send-result-to-console* nil) (defparameter *clog-repl-send-result-to-console* nil)
(defparameter *clog-repl-private-console* nil) (defparameter *clog-repl-private-console* t)
;; Panel Builder ;; Panel Builder

View file

@ -1 +1 @@
<data id="I3922518133" data-in-package="clog-tools" data-custom-slots="" data-clog-next-id="7" data-clog-title="clog-builder-repl"></data><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"><div style="--pixel-density: 1; --char-width: 6.60156; box-sizing: content-box; position: absolute; top: 30px; right: 0px; left: 0px; height: 170px;" class="terminal" data-clog-type="clog-terminal" data-clog-composite-control="t" data-clog-terminal-prompt="> " data-clog-terminal-greetings="CLOG Builder REPL - (clog-repl) or (clog-builder-repl) for GUI using *body*" data-clog-name="terminal" data-on-command="(repl-on-commmand panel target data)" data-on-create="(repl-on-create panel target)"></div><div style="border: thin solid black; box-sizing: content-box; position: absolute; inset: 200px 0px 20px;" class=" ace_editor ace_hidpi ace-terminal-theme ace-tm" data-clog-type="clog-ace" data-clog-composite-control="t" data-clog-ace-theme="ace/theme/terminal" data-clog-ace-mode="ace/mode/lisp" data-clog-ace-tab-size="2" data-clog-name="playground"></div><div data-clog-type="div" data-clog-name="status" style="box-sizing: content-box; position: absolute; left: 0px; bottom: 0px; right: 0px; height: 20px;" class="w3-black w3-tiny w3-border">status</div> <data id="I3922520302" data-in-package="clog-tools" data-custom-slots="" data-clog-next-id="8" data-clog-title="clog-builder-repl"></data><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"><div style="--pixel-density: 1; --char-width: 6.60156; box-sizing: content-box; position: absolute; top: 30px; right: 0px; left: 0px; height: 170px;" class="terminal" data-clog-type="clog-terminal" data-clog-composite-control="t" data-clog-terminal-prompt="> " data-clog-terminal-greetings="CLOG Builder REPL - (clog-repl) or (clog-builder-repl) for GUI using *body*" data-clog-name="terminal" data-on-command="(repl-on-commmand panel target data)" data-on-create="(repl-on-create panel target)"></div><div style="border: thin solid black; box-sizing: content-box; position: absolute; inset: 200px 0px 22px;" class=" ace_editor ace_hidpi ace-terminal-theme ace-tm" data-clog-type="clog-ace" data-clog-composite-control="t" data-clog-ace-theme="ace/theme/terminal" data-clog-ace-mode="ace/mode/lisp" data-clog-ace-tab-size="2" data-clog-name="playground"></div><div data-clog-type="div" data-clog-name="status" style="box-sizing: content-box; position: absolute; left: 0px; bottom: 0px; right: 0px; height: 20px;" class="w3-black w3-tiny w3-border">status</div><button data-clog-type="button" data-clog-name="send-to-repl" style="box-sizing: content-box; position: absolute; top: 185px; width: 10px; height: 18px; right: 0px;" class="w3-tiny" data-on-click="(repl-on-send-to-repl panel target)">&gt;</button>

View file

@ -1,28 +1,32 @@
;;;; CLOG Builder generated code - modify original .clog file and rerender ;;;; CLOG Builder generated code - modify original .clog file and rerender
(in-package :clog-tools) (in-package :clog-tools)
(defclass clog-builder-repl (clog:clog-panel) (defclass clog-builder-repl (clog:clog-panel)
((status :reader status) (playground :reader playground) ((send-to-repl :reader send-to-repl) (status :reader status)
(terminal :reader terminal) (package-div :reader package-div))) (playground :reader playground) (terminal :reader terminal)
(package-div :reader package-div)))
(defun create-clog-builder-repl (defun create-clog-builder-repl
(clog-obj &key (hidden nil) (class nil) (html-id nil) (auto-place t)) (clog-obj &key (hidden nil) (class nil) (html-id nil) (auto-place t))
(let ((panel (let ((panel
(change-class (change-class
(clog:create-div clog-obj :content (clog:create-div clog-obj :content
"<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=\"CLOGB3922517769\" data-clog-name=\"package-div\"><div style=\"--pixel-density: 1; --char-width: 6.60156; box-sizing: content-box; position: absolute; top: 30px; right: 0px; left: 0px; height: 170px;\" class=\"terminal\" id=\"CLOGB3922517770\" data-clog-name=\"terminal\"></div><div style=\"border: thin solid black; box-sizing: content-box; position: absolute; inset: 200px 0px 22px;\" class=\" ace_editor ace_hidpi ace-terminal-theme ace-tm\" id=\"CLOGB3922517771\" data-clog-name=\"playground\"></div><div id=\"CLOGB39225178996\" style=\"box-sizing: content-box; position: absolute; left: 0px; bottom: 0px; right: 0px; height: 20px;\" class=\"w3-black w3-tiny w3-border\" data-clog-name=\"status\">status</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=\"CLOGB3922519800\" data-clog-name=\"package-div\"><div style=\"--pixel-density: 1; --char-width: 6.60156; box-sizing: content-box; position: absolute; top: 30px; right: 0px; left: 0px; height: 170px;\" class=\"terminal\" id=\"CLOGB3922519801\" data-clog-name=\"terminal\"></div><div style=\"border: thin solid black; box-sizing: content-box; position: absolute; inset: 200px 0px 22px;\" class=\" ace_editor ace_hidpi ace-terminal-theme ace-tm\" id=\"CLOGB3922519802\" data-clog-name=\"playground\"></div><div style=\"box-sizing: content-box; position: absolute; left: 0px; bottom: 0px; right: 0px; height: 20px;\" class=\"w3-black w3-tiny w3-border\" id=\"CLOGB3922519803\" data-clog-name=\"status\">status</div><button id=\"CLOGB39225198357\" style=\"box-sizing: content-box; position: absolute; top: 185px; width: 10px; height: 18px; right: 0px;\" class=\"w3-tiny\" data-clog-name=\"send-to-repl\">&gt;</button>"
:hidden hidden :class class :html-id html-id :hidden hidden :class class :html-id html-id
:auto-place auto-place) :auto-place auto-place)
'clog-builder-repl))) 'clog-builder-repl)))
(setf (slot-value panel 'send-to-repl)
(attach-as-child clog-obj "CLOGB39225198357" :clog-type
'clog:clog-button :new-id t))
(setf (slot-value panel 'status) (setf (slot-value panel 'status)
(attach-as-child clog-obj "CLOGB39225178996" :clog-type (attach-as-child clog-obj "CLOGB3922519803" :clog-type
'clog:clog-div :new-id t)) 'clog:clog-div :new-id t))
(setf (slot-value panel 'playground) (setf (slot-value panel 'playground)
(attach-as-child clog-obj "CLOGB3922517771" :clog-type (attach-as-child clog-obj "CLOGB3922519802" :clog-type
'clog-ace:clog-ace-element :new-id t)) 'clog-ace:clog-ace-element :new-id t))
(setf (slot-value panel 'terminal) (setf (slot-value panel 'terminal)
(attach-as-child clog-obj "CLOGB3922517770" :clog-type (attach-as-child clog-obj "CLOGB3922519801" :clog-type
'clog-terminal:clog-terminal-element :new-id t)) 'clog-terminal:clog-terminal-element :new-id t))
(setf (slot-value panel 'package-div) (setf (slot-value panel 'package-div)
(attach-as-child clog-obj "CLOGB3922517769" :clog-type (attach-as-child clog-obj "CLOGB3922519800" :clog-type
'clog:clog-form-element :new-id t)) 'clog:clog-form-element :new-id t))
(let ((target (terminal panel))) (let ((target (terminal panel)))
(declare (ignorable target)) (declare (ignorable target))
@ -40,4 +44,8 @@
(lambda (target data) (lambda (target data)
(declare (ignorable target data)) (declare (ignorable target data))
(repl-on-commmand panel target data))) (repl-on-commmand panel target data)))
(clog:set-on-click (send-to-repl panel)
(lambda (target)
(declare (ignorable target))
(repl-on-send-to-repl panel target)))
panel)) panel))

View file

@ -26,7 +26,7 @@
;; Use console for evals instead of capture ;; Use console for evals instead of capture
(setf *editor-use-console-for-evals* nil) (setf *editor-use-console-for-evals* nil)
;; Use TAB key as in emacs (can always use ctl/alt-t) ;; Use TAB key as in emacs (can always use ctl/alt-t)
(setf *editor-use-tab-as-tabbify* nil) (setf *editor-use-tab-as-tabbify* t)
;; Use emacs instead of the source-editor when opening external ;; Use emacs instead of the source-editor when opening external
;; must start builder for slime in emacs ;; must start builder for slime in emacs
(setf *open-external-with-emacs* nil) (setf *open-external-with-emacs* nil)
@ -57,7 +57,7 @@
(setf *clog-repl-use-console* t) (setf *clog-repl-use-console* t)
(setf *clog-repl-open-console-on-start* nil) (setf *clog-repl-open-console-on-start* nil)
(setf *clog-repl-send-result-to-console* nil) (setf *clog-repl-send-result-to-console* nil)
(setf *clog-repl-private-console* nil) (setf *clog-repl-private-console* t)
;; Panel Builder ;; Panel Builder
(setf *builder-render-right-margin* 80) (setf *builder-render-right-margin* 80)