diff --git a/source/clog-system.lisp b/source/clog-system.lisp index 1ee1d33..86d45d8 100644 --- a/source/clog-system.lisp +++ b/source/clog-system.lisp @@ -180,6 +180,19 @@ BOOT-FILE will be used. If BOOT-FILE is nil path is removed." "Turn on browser console debugging for OBJ's connection." (clog-connection:debug-mode (connection-id obj))) +;;;;;;;;;;;;;;;;;;;;;;; +;; open-file-with-os ;; +;;;;;;;;;;;;;;;;;;;;;;; + +(defun open-file-with-os (path) + "Open PATH using OS" + #+windows + (uiop:launch-program (list "explorer.exe" (uiop:native-namestring path))) + #+linux + (uiop:launch-program (list "xdg-open" (uiop:native-namestring path))) + #+darwin + (uiop:launch-program (list "open" (uiop:native-namestring path)))) + ;;;;;;;;;;;;;;;;;; ;; open-browser ;; ;;;;;;;;;;;;;;;;;; @@ -187,7 +200,10 @@ BOOT-FILE will be used. If BOOT-FILE is nil path is removed." (defun open-browser (&key (url (format nil "http://127.0.0.1:~A" *clog-port*))) "Launch on os a web browser on local machine to URL. See OPEN-WINDOW for openning windows on remote machines." - (handler-case - (trivial-open-browser:open-browser url) - (error (c) - (format t "Unable to open browser.~%~%~A" c)))) + #+windows + (uiop:launch-program (list "rundll32" "url.dll,FileProtocolHandler" url)) + #+linux + (uiop:launch-program (list "xdg-open" url)) + #+darwin + (uiop:launch-program (list "open" url))) + diff --git a/source/clog.lisp b/source/clog.lisp index c3252f2..5f3c7c2 100644 --- a/source/clog.lisp +++ b/source/clog.lisp @@ -83,6 +83,7 @@ embedded in a native template application.)" (is-running-p function) (shutdown function) (debug-mode function) + (open-file-with-os function) (open-browser function)) (defsection @clog-utilities (:title "CLOG Utilities") diff --git a/tools/clog-builder-project-tree.lisp b/tools/clog-builder-project-tree.lisp index e0d6a46..70710ca 100644 --- a/tools/clog-builder-project-tree.lisp +++ b/tools/clog-builder-project-tree.lisp @@ -1,28 +1,32 @@ (in-package :clog-tools) -(defun project-tree-select (panel item) +(defun project-tree-select (panel item &key method) (unless (equal item "") (cond ((and (> (length item) 5) (equal (subseq item (- (length item) 5)) ".clog")) - (if *open-external* + (if (or (eq method :tab) + (and (not (eq method :here)) *open-external*)) (on-new-builder-panel-ext panel :open-file item) ;; need ext for both (on-new-builder-panel panel :open-file item))) (t - (if *open-external* - (on-open-file-ext panel :open-file item) - (progn - (let ((win (on-open-file panel :open-file item))) - (when *project-tree-sticky-open* - (when win - (set-geometry win - :top (menu-bar-height win) - :left 300 - :height "" :width "" - :bottom 5 :right 0) - (clog-ace:resize (window-param win)) - (set-on-window-move win (lambda (obj) - (setf (width obj) (width obj)) - (setf (height obj) (height obj))))))))))))) + (if (eq method :emacs) + (swank:ed-in-emacs item) + (if (or (eq method :tab) + (and (not (eq method :here)) *open-external*)) + (on-open-file-ext panel :open-file item) + (progn + (let ((win (on-open-file panel :open-file item))) + (when *project-tree-sticky-open* + (when win + (set-geometry win + :top (menu-bar-height win) + :left 300 + :height "" :width "" + :bottom 5 :right 0) + (clog-ace:resize (window-param win)) + (set-on-window-move win (lambda (obj) + (setf (width obj) (width obj)) + (setf (height obj) (height obj)))))))))))))) (defun on-project-tree (obj &key project) (let ((app (connection-data-item obj "builder-app-data"))) @@ -123,12 +127,32 @@ :class *builder-window-desktop-class*)) (title (create-div menu :content disp)) (op (create-div menu :content "Open" :class *builder-menu-context-item-class*)) + (oph (create-div menu :content "Open this tab" :class *builder-menu-context-item-class*)) + (opt (create-div menu :content "Open new tab" :class *builder-menu-context-item-class*)) + (ope (create-div menu :content "Open emacs" :class *builder-menu-context-item-class*)) + (opo (create-div menu :content "Open OS default" :class *builder-menu-context-item-class*)) (del (create-div menu :content "Delete" :class *builder-menu-context-item-class*))) (declare (ignore title op)) (set-on-click menu (lambda (i) (declare (ignore i)) (project-tree-select obj (format nil "~A" item))) :cancel-event t) + (set-on-click oph (lambda (i) + (declare (ignore i)) + (project-tree-select obj (format nil "~A" item) :method :here)) + :cancel-event t) + (set-on-click opt (lambda (i) + (declare (ignore i)) + (project-tree-select obj (format nil "~A" item) :method :tab)) + :cancel-event t) + (set-on-click ope (lambda (i) + (declare (ignore i)) + (project-tree-select obj (format nil "~A" item) :method :emacs)) + :cancel-event t) + (set-on-click opo (lambda (i) + (declare (ignore i)) + (open-file-with-os item)) + :cancel-event t) (set-on-click del (lambda (i) (confirm-dialog i (format nil "Delete ~A?" disp) (lambda (result)