From 118da225e40d190822b6264a12c163cb912265bc Mon Sep 17 00:00:00 2001 From: David Botton Date: Mon, 24 Jun 2024 19:52:47 -0400 Subject: [PATCH 1/3] reduce need to reload properties amd control-list --- tools/clog-builder-control-events.lisp | 6 +++--- tools/clog-builder-control-list.lisp | 4 ++-- tools/clog-builder-control-properties.lisp | 3 ++- tools/clog-builder-panels.lisp | 25 +++++++++++----------- tools/clog-builder.lisp | 4 ++++ 5 files changed, 24 insertions(+), 18 deletions(-) diff --git a/tools/clog-builder-control-events.lisp b/tools/clog-builder-control-events.lisp index eaf92a7..68485b1 100644 --- a/tools/clog-builder-control-events.lisp +++ b/tools/clog-builder-control-events.lisp @@ -8,7 +8,7 @@ (let* ((*default-title-class* *builder-title-class*) (*default-border-class* *builder-border-class*) (win (create-gui-window obj :title "Control CLOG Events" - :left 225 + :left (+ *builder-left-panel-size* 5) :height 200 :width 645 :has-pinner t :client-movement *client-side-movement*)) (content (window-content win)) @@ -59,7 +59,7 @@ (let* ((*default-title-class* *builder-title-class*) (*default-border-class* *builder-border-class*) (win (create-gui-window obj :title "Control Client JavaScript Events" - :left 225 + :left (+ *builder-left-panel-size* 5) :height 200 :width 645 :has-pinner t :client-movement *client-side-movement*)) (content (window-content win)) @@ -112,7 +112,7 @@ (let* ((*default-title-class* *builder-title-class*) (*default-border-class* *builder-border-class*) (win (create-gui-window obj :title "Control Client ParenScript Events" - :left 225 + :left (+ *builder-left-panel-size* 5) :height 200 :width 645 :has-pinner t :client-movement *client-side-movement*)) (content (window-content win)) diff --git a/tools/clog-builder-control-list.lisp b/tools/clog-builder-control-list.lisp index cd17c6b..4d3f3e9 100644 --- a/tools/clog-builder-control-list.lisp +++ b/tools/clog-builder-control-list.lisp @@ -49,10 +49,9 @@ (win (create-gui-window obj :title "Controls" :has-pinner t :keep-on-top t - :width 220)) + :width *builder-left-panel-size*)) (content (window-content win)) (sheight (floor (/ (height content) 2))) - (swidth (floor (width content))) (divider (create-panel content :top sheight :height 10 :left 0 :right 10 :class *builder-title-class*)) (control-list (create-panel content :height (- sheight 10) :left 0 :bottom 0 :right 10)) @@ -63,6 +62,7 @@ (setf (control-list-win app) control-list) (setf (select-tool app) pallete) (set-on-window-close win (lambda (obj) + (declare (ignore obj)) (setf (controls-win app) nil) (setf (select-tool app) nil) (setf (control-list-win app) nil))) diff --git a/tools/clog-builder-control-properties.lisp b/tools/clog-builder-control-properties.lisp index 039bc71..e67ea9e 100644 --- a/tools/clog-builder-control-properties.lisp +++ b/tools/clog-builder-control-properties.lisp @@ -87,7 +87,7 @@ (p (attribute (parent-element v) "data-clog-name"))) (unless (or (equal cname n) (equal cname p)) - (push n panel-controls)))) + (push n panel-controls)))) (get-control-list app panel-id)) (push (attribute panel "data-clog-name") panel-controls) (push @@ -128,6 +128,7 @@ (when (equal (subseq vname 0 1) "(") (setf vname (format nil "|~A|" vname))) (setf (attribute control "data-clog-name") vname) + (on-populate-control-list-win panel :win win) (when (equal (getf info :name) "clog-data") (when win (setf (window-title win) vname))))))) diff --git a/tools/clog-builder-panels.lisp b/tools/clog-builder-panels.lisp index 57e0af9..7cc79aa 100644 --- a/tools/clog-builder-panels.lisp +++ b/tools/clog-builder-panels.lisp @@ -510,7 +510,7 @@ not a temporarily attached one when using select-control." (*default-title-class* *builder-title-class*) (*default-border-class* *builder-border-class*) ext-panel - (win (create-gui-window obj :top 40 :left 225 + (win (create-gui-window obj :top 40 :left (+ *builder-left-panel-size* 5) :width 645 :height 430 :client-movement *client-side-movement*)) (box (create-panel-box-layout (window-content win) @@ -536,15 +536,14 @@ not a temporarily attached one when using select-control." (m-lisp (create-gui-menu-drop-down menu :content "Lisp")) (m-rndr (create-gui-menu-item m-lisp :content "render form to lisp")) (m-rndras (create-gui-menu-item m-lisp :content "render form to lisp as...")) - (m-rndr (create-gui-menu-item m-lisp :content "render form to lisp")) (m-eval (create-gui-menu-item m-lisp :content "evaluate")) (m-test (create-gui-menu-item m-lisp :content "evaluate and test")) (m-events (create-gui-menu-drop-down menu :content "controls")) - (tmp (create-gui-menu-item m-events :content "show control properties" :on-click 'on-show-control-properties-win)) - (tmp (create-gui-menu-item m-events :content "show controls window" :on-click 'on-show-control-list-win)) - (tmp (create-gui-menu-item m-events :content "show CLOG events" :on-click 'on-show-control-events-win)) - (tmp (create-gui-menu-item m-events :content "show JavaScript events" :on-click 'on-show-control-js-events-win)) - (tmp (create-gui-menu-item m-events :content "show ParenScript events" :on-click 'on-show-control-ps-events-win)) + (tmp1 (create-gui-menu-item m-events :content "show control properties" :on-click 'on-show-control-properties-win)) + (tmp2 (create-gui-menu-item m-events :content "show controls window" :on-click 'on-show-control-list-win)) + (tmp3 (create-gui-menu-item m-events :content "show CLOG events" :on-click 'on-show-control-events-win)) + (tmp4 (create-gui-menu-item m-events :content "show JavaScript events" :on-click 'on-show-control-js-events-win)) + (tmp5 (create-gui-menu-item m-events :content "show ParenScript events" :on-click 'on-show-control-ps-events-win)) (m-help (create-gui-menu-drop-down menu :content "Help")) (m-helpk (create-gui-menu-item m-help :content "quick start")) (tool-bar (create-div (top-panel box) :class *builder-title-class*)) @@ -564,7 +563,6 @@ not a temporarily attached one when using select-control." (spacer (create-span tool-bar :content "   ")) (btn-help (create-span tool-bar :content "?" :class "w3-tiny w3-ripple")) (content (center-panel box)) - (in-simulation nil) (undo-chain nil) (redo-chain nil) (is-dirty nil) @@ -572,7 +570,7 @@ not a temporarily attached one when using select-control." (file-name "") (render-file-name "") (panel-id (html-id content))) - (declare (ignore spacer)) + (declare (ignore spacer tmp1 tmp2 tmp3 tmp4 tmp5)) (add-class menu "w3-small") (setf (overflow (top-panel box)) :visible) ; let menus leave the top panel (add-class (top-panel box) *builder-title-class*) @@ -644,7 +642,7 @@ not a temporarily attached one when using select-control." (on-populate-control-properties-win content :win win :clear t) (setf content nil) (setf ext-panel nil) - (Window-close win))) + (window-close win))) (set-on-click (create-gui-menu-item m-file :content "export as a boot html") (lambda (obj) (server-file-dialog obj "Export as a Boot HTML" "./" @@ -685,8 +683,11 @@ not a temporarily attached one when using select-control." (set-on-window-focus win (lambda (obj) (declare (ignore obj)) - (on-populate-control-properties-win content :win win) - (on-populate-control-list-win content :win win))) + (unless (eq (last-panel-editor app) win) + (progn + (on-populate-control-properties-win content :win win) + (on-populate-control-list-win content :win win) + (setf (last-panel-editor app) win))))) (set-on-window-close win (lambda (obj) (declare (ignore obj)) diff --git a/tools/clog-builder.lisp b/tools/clog-builder.lisp index b655d73..b7b428a 100644 --- a/tools/clog-builder.lisp +++ b/tools/clog-builder.lisp @@ -137,6 +137,10 @@ clog-builder window.") :accessor control-list-win :initform nil :documentation "Current control list window") + (last-panel-editor + :accessor last-panel-editor + :initform nil + :documentation "Last editor panel focused, to avoid recalculations") (control-pallete-win :accessor control-pallete-win :initform nil From 754fab359ca4552be53ce2f1bf7479178c1d45da Mon Sep 17 00:00:00 2001 From: David Botton Date: Mon, 24 Jun 2024 21:25:00 -0400 Subject: [PATCH 2/3] fix panel naming issues and residual properties on close --- tools/clog-builder-api.lisp | 4 +--- tools/clog-builder-control-properties.lisp | 22 +++++++++++++++++++--- tools/clog-builder-panels.lisp | 3 ++- 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/tools/clog-builder-api.lisp b/tools/clog-builder-api.lisp index 249f478..621ccc3 100644 --- a/tools/clog-builder-api.lisp +++ b/tools/clog-builder-api.lisp @@ -8,9 +8,7 @@ `(:name "clog-data" :description "Panel Properties" :events nil - :properties ((:name "panel name" - :attr "data-clog-name") - (:name "in-package" + :properties ((:name "in-package" :attr "data-in-package") (:name "custom slots" :attr "data-custom-slots") diff --git a/tools/clog-builder-control-properties.lisp b/tools/clog-builder-control-properties.lisp index e67ea9e..e5be835 100644 --- a/tools/clog-builder-control-properties.lisp +++ b/tools/clog-builder-control-properties.lisp @@ -43,6 +43,10 @@ obj)) (placer (when control (get-placer control))) + (panel-id (attribute placer "data-panel-id")) + (panel (if (current-control app) + (attach-as-child obj panel-id) + obj)) (table (properties-list app))) (when prop-win (setf (inner-html table) "") @@ -75,12 +79,24 @@ (setf (attribute control (getf prop :attr)) (text obj)))) props)) (t (print "Configuration error.")))) + (when (equal (getf info :name) "clog-data") + (push + `("panel name" ,(attribute control "data-clog-name") + nil + ,(lambda (obj) + (let ((vname (text obj))) + (unless (equal vname "") + (when (equal (subseq vname 0 1) "(") + (setf vname (format nil "|~A|" vname))) + (setf (attribute control "data-clog-name") vname) + (on-populate-control-list-win panel :win win) + (when win + (setf (window-title win) vname)))))) + props)) (when (current-control app) (let* (panel-controls (cname (attribute control "data-clog-name")) - (ctype (attribute control "data-clog-type")) - (panel-id (attribute placer "data-panel-id")) - (panel (attach-as-child obj panel-id))) + (ctype (attribute control "data-clog-type"))) (maphash (lambda (k v) (declare (ignore k)) (let ((n (attribute v "data-clog-name")) diff --git a/tools/clog-builder-panels.lisp b/tools/clog-builder-panels.lisp index 7cc79aa..3f27682 100644 --- a/tools/clog-builder-panels.lisp +++ b/tools/clog-builder-panels.lisp @@ -829,10 +829,11 @@ not a temporarily attached one when using select-control." (setf is-dirty nil) (clrhash (get-control-list app panel-id)) (on-populate-loaded-window content :win win) - (setf (window-title win) (attribute content "data-clog-name")) (when ext-panel (setf (title (html-document ext-panel)) (attribute content "data-clog-name"))) (setf (window-param win) fname) + (setf (window-title win) (attribute content "data-clog-name")) + (on-populate-control-properties-win content :win win) (on-populate-control-list-win content :win win)) (load-file (obj) (server-file-dialog obj "Load Panel" (directory-namestring (if (equal file-name "") From 6ce44d64187a7379a0225f0fc25ab43a9cf6b271 Mon Sep 17 00:00:00 2001 From: David Botton Date: Tue, 25 Jun 2024 19:08:20 -0400 Subject: [PATCH 3/3] network fixes --- LINUX.md | 10 ++++++++++ README.md | 10 ++++++++-- tools/clog-builder.lisp | 6 +++--- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/LINUX.md b/LINUX.md index 7bc846e..1c4fc49 100644 --- a/LINUX.md +++ b/LINUX.md @@ -29,3 +29,13 @@ sbcl --eval '(ql:quickload :clog/tools)' --eval '(clog-tools:clog-builder)' - [Learn about CLOG](README.md) - [Learn Common-Lisp](LEARN.md) + +TIPS: +Install "sudo apt install xdg-utils wslu" to install xdg-open so that wsl +uses the windows browser. Also create or add to your %UserProfile% (home dir) a +file .wslconfig with below or networking though nat and even localhost access +is dog slow. (Windows 11 on) +``` +[wsl2] +networkingMode=mirrored +``` diff --git a/README.md b/README.md index 0b9747f..164e03a 100644 --- a/README.md +++ b/README.md @@ -132,8 +132,14 @@ CL-USER> (ql:quickload :clog) ; if not already loaded CL-USER> (clog:run-tutorial 1) ``` -Tip for Windows WSL linux user. Install "sudo apt install xdg-utils wslu" to -install xdg-open so that run-tutorial uses the windows browser. +_Tips for Windows WSL linux_ Install "sudo apt install xdg-utils wslu" to +install xdg-open so that run-tutorial uses the windows browser. Also create +or add to your %UserProfile% (home dir) a file .wslconfig with +``` +[wsl2] +networkingMode=mirrored +``` + To see where the source, tutorial and demo files are: diff --git a/tools/clog-builder.lisp b/tools/clog-builder.lisp index b7b428a..b1d836c 100644 --- a/tools/clog-builder.lisp +++ b/tools/clog-builder.lisp @@ -579,7 +579,7 @@ clog-builder window.") (format t "~%If browser does not start go to http://127.0.0.1:~A~A" clog:*clog-port* open-url) (open-browser :url (format nil "http://127.0.0.1:~A~A" clog:*clog-port* open-url)))) -(defun clog-builder (&key (port 8080) (start-browser t) +(defun clog-builder (&key (host "0.0.0.0") (port 8080) (start-browser t) app project dir static-root system clogframe) "Start clog-builder. :PROJECT - load ASDF Project, start its static root and set as current @@ -613,8 +613,8 @@ clog-builder window.") (unless *app-mode* (setf *app-mode* 0))) (if static-root - (initialize nil :port port :static-root static-root) - (initialize nil :port port)) + (initialize nil :host host :port port :static-root static-root) + (initialize nil :host host :port port)) (setf port clog:*clog-port*) (set-on-new-window 'on-new-builder :path "/builder") (set-on-new-window 'on-open-panel-window :path "/panel-editor")