diff --git a/tools/clog-builder-dir-win.lisp b/tools/clog-builder-dir-win.lisp index cba6e34..5ebadca 100644 --- a/tools/clog-builder-dir-win.lisp +++ b/tools/clog-builder-dir-win.lisp @@ -22,9 +22,13 @@ (unless (equal item "") (cond ((and (> (length item) 5) (equal (subseq item (- (length item) 5)) ".clog")) - (on-new-builder-panel panel :open-file item)) + (if (checkedp (open-file-ext panel)) + (on-new-builder-panel-ext panel :open-file item) + (on-new-builder-panel panel :open-file item))) (t - (on-open-file panel :open-file item)))))) + (if (checkedp (open-file-ext panel)) + (on-open-file-ext panel :open-file item) + (on-open-file panel :open-file item))))))) (defun on-delete-dir-win (panel) (let ((item (value (files panel)))) diff --git a/tools/clog-builder-projects.lisp b/tools/clog-builder-projects.lisp index 662fdb3..4fcc43c 100644 --- a/tools/clog-builder-projects.lisp +++ b/tools/clog-builder-projects.lisp @@ -332,7 +332,7 @@ (pprint n s))))) (projects-load system)) -(defun open-projects-component (target system list) +(defun open-projects-component (target panel system list) (let ((disp (select-text target)) (item (text-value target))) (cond ((equal item "") @@ -348,6 +348,10 @@ (add-select-option list path name)))) ((and (> (length item) 5) (equal (subseq item (- (length item) 5)) ".clog")) - (on-new-builder-panel target :open-file item)) + (if (checkedp (open-ext panel)) + (on-new-builder-panel-ext target :open-file item) + (on-new-builder-panel target :open-file item))) (t - (on-open-file target :open-file item))))) + (if (checkedp (open-ext panel)) + (on-open-file-ext target :open-file item) + (on-open-file target :open-file item)))))) diff --git a/tools/clog-builder.lisp b/tools/clog-builder.lisp index 7f25e7f..c74181a 100644 --- a/tools/clog-builder.lisp +++ b/tools/clog-builder.lisp @@ -8,6 +8,7 @@ (in-package :clog-tools) (defparameter *start-project* nil) +(defparameter *start-dir* nil) (defparameter *client-side-movement* nil) @@ -1779,6 +1780,17 @@ It parse the string TEXT without using READ functions." (setf (hiddenp (right-panel app)) (not bool)) (setf (hiddenp (left-panel app)) (not bool)))) +(defun on-new-builder-panel-ext (obj &key open-file popup) + (open-window (window (connection-body obj)) + (if open-file + (format nil "/panel-editor?open-file=~A" + open-file) + "/source-editor") + :specs (if popup + "width=645,height-430" + "") + :name "_blank")) + (defun on-new-builder-panel (obj &key (open-file nil)) "Open new panel" (unless (and open-file @@ -2599,12 +2611,24 @@ It parse the string TEXT without using READ functions." (defun on-open-file-window (body) (set-html-on-close body "Connection Lost") - (let ((app (make-instance 'builder-app-data))) + (let ((app (make-instance 'builder-app-data)) + (file (form-data-item (form-get-data body) "open-file"))) (setf (connection-data-item body "builder-app-data") app) (setf (title (html-document body)) "CLOG Builder - Source Editor") (clog-gui-initialize body) (add-class body "w3-blue-grey") - (on-open-file body :maximized t))) + (on-open-file body :open-file file :maximized t))) + +(defun on-open-file-ext (obj &key open-file popup) + (open-window (window (connection-body obj)) + (if open-file + (format nil "/source-editor?open-file=~A" + open-file) + "/source-editor") + :specs (if popup + "width=645,height-430" + "") + :name "_blank")) (defun on-open-file (obj &key open-file (title "New Source Editor") @@ -2715,22 +2739,26 @@ It parse the string TEXT without using READ functions." (clog-ace:resize ace))) (flet ((open-file-name (fname) (window-focus win) - (when fname - (setf last-date (file-write-date fname)) - (setf file-name fname) - (setf (window-title win) fname) - (let ((c (or (read-file fname) "" :clog-obj obj))) - (cond ((or (equalp (pathname-type fname) "lisp") - (equalp (pathname-type fname) "asd")) - (setf (clog-ace:mode ace) "ace/mode/lisp") - (setf (text-value pac-line) (get-package-from-string c)) - (setf lisp-file t) - (setf (current-editor-is-lisp app) (text-value pac-line))) - (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))))) + (handler-case + (when fname + (setf last-date (file-write-date fname)) + (setf file-name fname) + (setf (window-title win) fname) + (let ((c (or (read-file fname) "" :clog-obj obj))) + (cond ((or (equalp (pathname-type fname) "lisp") + (equalp (pathname-type fname) "asd")) + (setf (clog-ace:mode ace) "ace/mode/lisp") + (setf (text-value pac-line) (get-package-from-string c)) + (setf lisp-file t) + (setf (current-editor-is-lisp app) (text-value pac-line))) + (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))) + (error (condition) + (alert-toast obj "File Error" (format nil "Error: ~A" condition)) + (format t "Error: ~A" condition))))) (when open-file (open-file-name open-file)) (set-on-click btn-load (lambda (obj) @@ -2888,9 +2916,10 @@ It parse the string TEXT without using READ functions." :title-class "w3-red" :text c))))))) -(defun on-dir-win (obj &key dir) +(defun on-dir-win (obj &key dir top left) "Open dir window" (let* ((win (create-gui-window obj :title "Directory Window" + :top top :left left :width 600 :height 400 :client-movement *client-side-movement*)) (d (create-dir-view (window-content win)))) @@ -2898,10 +2927,14 @@ It parse the string TEXT without using READ functions." (when dir (populate-dir-win d dir)))) +(defun on-open-panel-window (body) + (on-new-builder body)) + (defun on-new-builder (body) "Launch instance of the CLOG Builder" (set-html-on-close body "Connection Lost") - (let ((app (make-instance 'builder-app-data))) + (let ((app (make-instance 'builder-app-data)) + (open-file (form-data-item (form-get-data body) "open-file"))) (setf (connection-data-item body "builder-app-data") app) (setf (title (html-document body)) "CLOG Builder") (clog-gui-initialize body :body-left-offset 10 :body-right-offset 10) @@ -2926,12 +2959,13 @@ It parse the string TEXT without using READ functions." (create-gui-menu-item file :content "New Custom Boot Page" :on-click 'on-new-builder-custom) (create-gui-menu-item file :content "New Application Template" :on-click 'on-new-app-template) (create-gui-menu-item src :content "Project Window" :on-click 'on-show-project) + (create-gui-menu-item src :content "Directory Window" :on-click 'on-dir-win) (create-gui-menu-item src :content "New Source Editor" :on-click 'on-open-file) (create-gui-menu-item src :content "New Source Editor (New Tab)" :on-click (lambda (obj) (declare (ignore obj)) (open-window (window body) "/source-editor"))) - (Create-gui-menu-item src :content "New System Browser" :on-click 'on-new-sys-browser) + (create-gui-menu-item src :content "New System Browser" :on-click 'on-new-sys-browser) (create-gui-menu-item src :content "New ASDF System Browser" :on-click 'on-new-asdf-browser) (create-gui-menu-item tools :content "Control Events" :on-click 'on-show-control-events-win) (create-gui-menu-item tools :content "Directory Window" :on-click 'on-dir-win) @@ -2991,7 +3025,13 @@ It parse the string TEXT without using READ functions." (on-show-control-properties-win body) (on-show-control-list-win body) (on-show-copy-history-win body) - (on-show-project body :project *start-project*) + (cond + (open-file + (on-new-builder-panel body :open-file open-file)) + (*start-dir* + (on-dir-win body :dir *start-dir* :top 60 :left 232)) + (t + (on-show-project body :project *start-project*))) (set-on-before-unload (window body) (lambda(obj) (declare (ignore obj)) ;; return empty string to prevent nav off page @@ -3006,15 +3046,17 @@ It parse the string TEXT without using READ functions." clog-builder window.") (defun clog-builder (&key (port 8080) (start-browser t) - app project static-root system clogframe) + app project dir static-root system clogframe) "Start clog-builder. When PORT is 0 choose a random port. When APP is t, shutdown applicatoin on termination of first window. If APP eq :BATCH then must specific default project :PROJECT and it will be batch rerendered and shutdown application. You can set the specific STATIC-ROOT or set SYSTEM -to use that asdf system's static root." +to use that asdf system's static root. if DIR then the directory window +instead of the project window will be displayed." (if project (setf *start-project* (string-downcase (format nil "~A" project))) (setf *start-project* nil)) + (setf *start-dir* dir) (when system (setf static-root (merge-pathnames "./www/" (asdf:system-source-directory system)))) @@ -3028,6 +3070,7 @@ to use that asdf system's static root." (set-on-new-window 'on-new-db-admin :path "/dbadmin") (set-on-new-window 'on-attach-builder-page :path "/builder-page") (set-on-new-window 'on-convert-image :path "/image-to-data") + (set-on-new-window 'on-open-panel-window :path "/panel-editor") (set-on-new-window 'on-open-file-window :path "/source-editor") (when clogframe (uiop:run-program (list "./clogframe" diff --git a/tools/dir-view.clog b/tools/dir-view.clog index 86a83dd..065b28e 100644 --- a/tools/dir-view.clog +++ b/tools/dir-view.clog @@ -1 +1 @@ -
\ No newline at end of file + \ No newline at end of file diff --git a/tools/dir-view.lisp b/tools/dir-view.lisp index ea3b030..9123c60 100644 --- a/tools/dir-view.lisp +++ b/tools/dir-view.lisp @@ -1,7 +1,9 @@ -;;;; CLOG Builder generated code - modify original clog file +;;;; CLOG Builder generated code - modify original .clog file and rerender (in-package :clog-tools) (defclass dir-view (clog:clog-panel) - ((rename-button :reader rename-button) + ((open-ext-label :reader open-ext-label) + (open-file-ext :reader open-file-ext) + (rename-button :reader rename-button) (del-button :reader del-button) (open-button :reader open-button) (rename-dir-button :reader rename-dir-button) (del-dir-button :reader del-dir-button) @@ -14,43 +16,54 @@ (let ((panel (change-class (clog:create-div clog-obj :content - "" + "" :hidden hidden :class class :html-id html-id :auto-place auto-place) 'dir-view))) + (setf (slot-value panel 'open-ext-label) + (attach-as-child clog-obj "CLOGB3918824378" :clog-type + 'clog:clog-label :new-id t)) + (setf (slot-value panel 'open-file-ext) + (attach-as-child clog-obj "CLOGB3918824377" :clog-type + 'clog:clog-form-element :new-id t)) (setf (slot-value panel 'rename-button) - (attach-as-child clog-obj "CLOGB387211077419" :clog-type + (attach-as-child clog-obj "CLOGB3918824376" :clog-type 'clog:clog-form-element :new-id t)) (setf (slot-value panel 'del-button) - (attach-as-child clog-obj "CLOGB3872109096" :clog-type + (attach-as-child clog-obj "CLOGB3918824375" :clog-type 'clog:clog-form-element :new-id t)) (setf (slot-value panel 'open-button) - (attach-as-child clog-obj "CLOGB3872109095" :clog-type + (attach-as-child clog-obj "CLOGB3918824374" :clog-type 'clog:clog-form-element :new-id t)) (setf (slot-value panel 'rename-dir-button) - (attach-as-child clog-obj "CLOGB387211008317" :clog-type + (attach-as-child clog-obj "CLOGB3918824373" :clog-type 'clog:clog-form-element :new-id t)) (setf (slot-value panel 'del-dir-button) - (attach-as-child clog-obj "CLOGB387210909815" :clog-type + (attach-as-child clog-obj "CLOGB3918824372" :clog-type 'clog:clog-form-element :new-id t)) (setf (slot-value panel 'new-dir-button) - (attach-as-child clog-obj "CLOGB3872109094" :clog-type + (attach-as-child clog-obj "CLOGB3918824371" :clog-type 'clog:clog-form-element :new-id t)) (setf (slot-value panel 'open-dir-button) - (attach-as-child clog-obj "CLOGB3872109093" :clog-type + (attach-as-child clog-obj "CLOGB3918824370" :clog-type 'clog:clog-form-element :new-id t)) (setf (slot-value panel 'files) - (attach-as-child clog-obj "CLOGB3872109092" :clog-type + (attach-as-child clog-obj "CLOGB3918824369" :clog-type 'clog:clog-select :new-id t)) (setf (slot-value panel 'divider) - (attach-as-child clog-obj "CLOGB3872109091" :clog-type + (attach-as-child clog-obj "CLOGB3918824368" :clog-type 'clog:clog-div :new-id t)) (setf (slot-value panel 'folders) - (attach-as-child clog-obj "CLOGB3872109090" :clog-type + (attach-as-child clog-obj "CLOGB3918824367" :clog-type 'clog:clog-select :new-id t)) (let ((target (folders panel))) (declare (ignorable target)) (populate-dir-win panel "./")) + (let ((target (open-ext-label panel))) + (declare (ignorable target)) + (setf (attribute target "for") + (clog:js-query target + "$('[data-clog-name=\\'open-file-ext\\']').attr('id')"))) (clog:set-on-mouse-double-click (folders panel) (lambda (target data) (declare (ignorable target data)) diff --git a/tools/projects.clog b/tools/projects.clog index c950e9b..3ebfb3b 100644 --- a/tools/projects.clog +++ b/tools/projects.clog @@ -1,4 +1,4 @@ -