From a9d0ce3c43db35d90550343420b487848e0903b4 Mon Sep 17 00:00:00 2001 From: David Botton Date: Sun, 7 Apr 2024 02:43:04 -0400 Subject: [PATCH] allow eval to console --- tools/clog-builder-eval.lisp | 16 +++++++++------- tools/clog-builder-files.lisp | 19 ++++++++++++++++--- tools/clog-builder-settings.lisp | 2 ++ tools/preferences.lisp.sample | 10 +++++++++- 4 files changed, 36 insertions(+), 11 deletions(-) diff --git a/tools/clog-builder-eval.lisp b/tools/clog-builder-eval.lisp index 9b38da7..9f9a905 100644 --- a/tools/clog-builder-eval.lisp +++ b/tools/clog-builder-eval.lisp @@ -4,8 +4,10 @@ (let ((app (connection-data-item obj "builder-app-data"))) (if (console-win app) (window-focus (console-win app)) - (let* ((win (on-open-file obj :title "CLOG Builder Console"))) + (let* ((win (on-open-file obj :title "CLOG Builder Console" + :editor-use-console-for-evals t))) (set-on-window-close win (lambda (obj) + (declare (ignore obj)) (setf (console-win app) nil))) (setf (console-win app) win))))) @@ -25,13 +27,14 @@ provide an interactive console.)")) (setf (win stream) (on-open-console (clog-obj stream)))) (unless (ace stream) (setf (ace stream) (window-param (win stream)))) - (js-execute (ace stream) (format nil "~A.insert(String.fromCharCode(~A))" - (clog-ace::js-ace (ace stream)) - (char-code character))) (js-execute (ace stream) (format nil "~A.renderer.scrollToLine(Number.POSITIVE_INFINITY)" - (clog-ace::js-ace (ace stream))))) + (clog-ace::js-ace (ace stream)))) + (js-execute (ace stream) (format nil "~A.navigateFileEnd()" + (clog-ace::js-ace (ace stream)))) + (js-execute (ace stream) (format nil "~A.insert(String.fromCharCode(~A),true)" + (clog-ace::js-ace (ace stream)) + (char-code character)))) - (defmethod trivial-gray-streams:stream-line-column ((stream console-out-stream)) nil) @@ -138,4 +141,3 @@ provide an interactive console.)")) (open-browser :url (format nil "http://127.0.0.1:~A/test" *clog-port*)) (open-window (window (connection-body obj)) "/test"))) (on-open-file obj :title-class "w3-yellow" :title "test eval" :text result))) - diff --git a/tools/clog-builder-files.lisp b/tools/clog-builder-files.lisp index e6af75f..52ca49c 100644 --- a/tools/clog-builder-files.lisp +++ b/tools/clog-builder-files.lisp @@ -48,6 +48,7 @@ (title-class *builder-title-class*) lisp-package regex + (editor-use-console-for-evals *editor-use-console-for-evals*) maximized) "Open a new text editor" (let ((win (window-to-top-by-title obj open-file))) @@ -429,21 +430,33 @@ (when (> cp p) (return lf))) (when lf (let ((result (capture-eval lf + :capture-console (not editor-use-console-for-evals) + :capture-result (not editor-use-console-for-evals) :clog-obj (connection-body obj) :eval-in-package (text-value pac-line)))) - (on-open-file obj :title-class "w3-blue" :title "form eval" :text result))))) + (if editor-use-console-for-evals + (on-open-console obj) + (on-open-file obj :title-class "w3-blue" :title "form eval" :text result)))))) (eval-selection (obj) (let ((val (clog-ace:selected-text ace))) (unless (equal val "") (let ((result (capture-eval val :clog-obj obj + :capture-console (not editor-use-console-for-evals) + :capture-result (not editor-use-console-for-evals) :eval-in-package (text-value pac-line)))) - (on-open-file obj :title-class "w3-blue" :title "selection eval" :text result))))) + (if editor-use-console-for-evals + (on-open-console obj) + (on-open-file obj :title-class "w3-blue" :title "selection eval" :text result)))))) (eval-file (obj) (let ((val (text-value ace))) (unless (equal val "") (let ((result (capture-eval val :clog-obj obj + :capture-console (not editor-use-console-for-evals) + :capture-result (not editor-use-console-for-evals) :eval-in-package (text-value pac-line)))) - (on-open-file obj :title-class "w3-blue" :title "file eval" :text result)))))) + (if editor-use-console-for-evals + (on-open-console obj) + (on-open-file obj :title-class "w3-blue" :title "file eval" :text result))))))) (set-on-click btn-esel (lambda (obj) (eval-selection obj))) (set-on-click m-esel (lambda (obj) diff --git a/tools/clog-builder-settings.lisp b/tools/clog-builder-settings.lisp index ce54a23..6f1113e 100644 --- a/tools/clog-builder-settings.lisp +++ b/tools/clog-builder-settings.lisp @@ -18,6 +18,8 @@ (defparameter *open-external-panels-in-popup* nil) ;; Open panels as popups by default (defparameter *open-panels-as-popups* nil) +;; Use console for evals instead of capture +(defparameter *editor-use-console-for-evals* nil) ;; Use emacs instead of the source-editor when openning external (defparameter *open-external-with-emacs* nil) ;; Best Light Theme for Lisp diff --git a/tools/preferences.lisp.sample b/tools/preferences.lisp.sample index c8b5add..5439fed 100644 --- a/tools/preferences.lisp.sample +++ b/tools/preferences.lisp.sample @@ -1,7 +1,7 @@ (in-package :clog-tools) ;; Add directories to use custom directoires for storing projects -;; (pushnew #P"path/to/dir/of/projects" ql:*local-project-directories* :test #'equalp) +;; (pushnew #P"/path/of/projects" ql:*local-project-directories* :test #'equalp) ;; Preferences loaded on next call to clog-tools:clog-builder or [Eval All] @@ -9,10 +9,18 @@ (setf *open-external* nil) ;; Open files in browser popups instead of tabs if browser allows (setf *open-external-in-popup* nil) + +;; CLOG Panels + ;; Open panel editors in browser popus instead of tabs if browser allows (setf *open-external-panels-in-popup* nil) ;; Open panels as popups by default (setf *open-panels-as-popups* nil) + +;; CLOG Source Editor + +;; Use console for evals instead of capture +(setf *editor-use-console-for-evals* nil) ;; Use emacs instead of the source-editor when opening external ;; must start builder for slime in emacs (setf *open-external-with-emacs* nil)