From 3c4647a746e64208d7d8a7079e3de8cc877acb8d Mon Sep 17 00:00:00 2001 From: David Botton Date: Fri, 19 Apr 2024 13:00:51 -0400 Subject: [PATCH] repl playground --- tools/clog-builder-ace.lisp | 4 ++-- tools/clog-builder-files.lisp | 6 +++++- tools/clog-builder-repl.lisp | 17 ++++++++++++++++- tools/clog-builder-settings.lisp | 4 ++-- tools/panel-clog-builder-repl.clog | 2 +- tools/panel-clog-builder-repl.lisp | 22 +++++++++++++++------- tools/preferences.lisp.sample | 4 ++-- 7 files changed, 43 insertions(+), 16 deletions(-) diff --git a/tools/clog-builder-ace.lisp b/tools/clog-builder-ace.lisp index 577a52f..e4b74b3 100644 --- a/tools/clog-builder-ace.lisp +++ b/tools/clog-builder-ace.lisp @@ -1,6 +1,6 @@ (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"))) ;; currently there is only one auto complete event for page (unless (auto-complete-configured app) @@ -259,7 +259,7 @@ var endRange = ~:*~A.session.doc.indexToPosition(endIndex); (setf r (swank::autodoc `(,ms swank::%CURSOR-MARKER%)))) (if r (setf r (car r)) - (setf r (swank:operator-arglist ms package))) + (setf r (swank:operator-arglist ms *PACKAGE*))) (when status (setf (advisory-title status) (documentation (find-symbol ms) 'function))) (when r diff --git a/tools/clog-builder-files.lisp b/tools/clog-builder-files.lisp index 5cb96fe..1a7c4e0 100644 --- a/tools/clog-builder-files.lisp +++ b/tools/clog-builder-files.lisp @@ -163,6 +163,10 @@ (window-maximize win)) (when 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 (lambda (obj) (declare (ignore obj)) @@ -205,7 +209,7 @@ (if lisp-package (setf (text-value pac-line) lisp-package) (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 "" :top "22px" :bottom "20px" :left "0px" :right "0px") (clog-ace:resize ace) diff --git a/tools/clog-builder-repl.lisp b/tools/clog-builder-repl.lisp index 8f0033d..359ba87 100644 --- a/tools/clog-builder-repl.lisp +++ b/tools/clog-builder-repl.lisp @@ -12,7 +12,8 @@ (defun on-repl (obj) "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*) (win (create-gui-window obj :title "CLOG Builder REPL" :top 40 :left 225 @@ -27,6 +28,14 @@ (window-close pcon)))) (window-focus win)) (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") (set-geometry repl :units "%" :width 100 :height 100))) @@ -35,6 +44,12 @@ (when *clog-repl-open-console-on-start* (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) (cond ((or (equalp data ":e") (equalp data ":q")) diff --git a/tools/clog-builder-settings.lisp b/tools/clog-builder-settings.lisp index c244e0e..e28d218 100644 --- a/tools/clog-builder-settings.lisp +++ b/tools/clog-builder-settings.lisp @@ -23,7 +23,7 @@ ;; Use console for evals instead of capture (defparameter *editor-use-console-for-evals* nil) ;; 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 (defparameter *open-external-with-emacs* nil) ;; Best Light Theme for Lisp @@ -49,7 +49,7 @@ (defparameter *clog-repl-use-console* t) (defparameter *clog-repl-open-console-on-start* nil) (defparameter *clog-repl-send-result-to-console* nil) -(defparameter *clog-repl-private-console* nil) +(defparameter *clog-repl-private-console* t) ;; Panel Builder diff --git a/tools/panel-clog-builder-repl.clog b/tools/panel-clog-builder-repl.clog index ec1e5c6..26da17e 100644 --- a/tools/panel-clog-builder-repl.clog +++ b/tools/panel-clog-builder-repl.clog @@ -1 +1 @@ -
status
\ No newline at end of file +
status
\ No newline at end of file diff --git a/tools/panel-clog-builder-repl.lisp b/tools/panel-clog-builder-repl.lisp index 8a0e400..4960ff1 100644 --- a/tools/panel-clog-builder-repl.lisp +++ b/tools/panel-clog-builder-repl.lisp @@ -1,28 +1,32 @@ ;;;; CLOG Builder generated code - modify original .clog file and rerender (in-package :clog-tools) (defclass clog-builder-repl (clog:clog-panel) - ((status :reader status) (playground :reader playground) - (terminal :reader terminal) (package-div :reader package-div))) + ((send-to-repl :reader send-to-repl) (status :reader status) + (playground :reader playground) (terminal :reader terminal) + (package-div :reader package-div))) (defun create-clog-builder-repl (clog-obj &key (hidden nil) (class nil) (html-id nil) (auto-place t)) (let ((panel (change-class (clog:create-div clog-obj :content - "
status
" + "
status
" :hidden hidden :class class :html-id html-id :auto-place auto-place) '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) - (attach-as-child clog-obj "CLOGB39225178996" :clog-type + (attach-as-child clog-obj "CLOGB3922519803" :clog-type 'clog:clog-div :new-id t)) (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)) (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)) (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)) (let ((target (terminal panel))) (declare (ignorable target)) @@ -40,4 +44,8 @@ (lambda (target data) (declare (ignorable 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)) \ No newline at end of file diff --git a/tools/preferences.lisp.sample b/tools/preferences.lisp.sample index 41d4672..bdcc215 100644 --- a/tools/preferences.lisp.sample +++ b/tools/preferences.lisp.sample @@ -26,7 +26,7 @@ ;; Use console for evals instead of capture (setf *editor-use-console-for-evals* nil) ;; 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 ;; must start builder for slime in emacs (setf *open-external-with-emacs* nil) @@ -57,7 +57,7 @@ (setf *clog-repl-use-console* t) (setf *clog-repl-open-console-on-start* nil) (setf *clog-repl-send-result-to-console* nil) -(setf *clog-repl-private-console* nil) +(setf *clog-repl-private-console* t) ;; Panel Builder (setf *builder-render-right-margin* 80)