mirror of
https://github.com/rabbibotton/clog.git
synced 2025-12-15 15:00:24 -08:00
load and save preferences file
This commit is contained in:
parent
f3abaa1884
commit
f22f0bf966
3 changed files with 46 additions and 16 deletions
|
|
@ -2,10 +2,10 @@
|
|||
|
||||
;; Local file utilities
|
||||
|
||||
(defun read-file (infile &key clog-obj)
|
||||
(defun read-file (infile &key clog-obj if-does-not-exist)
|
||||
"Read local file named INFILE"
|
||||
(handler-case
|
||||
(with-open-file (instream infile :direction :input :if-does-not-exist nil)
|
||||
(with-open-file (instream infile :direction :input :if-does-not-exist if-does-not-exist)
|
||||
(when instream
|
||||
(let* ((len (file-length instream))
|
||||
(string (make-string len))
|
||||
|
|
@ -104,7 +104,8 @@
|
|||
(lisp-file t)
|
||||
(is-dirty nil)
|
||||
(last-date nil)
|
||||
(file-name ""))
|
||||
(file-name (or open-file
|
||||
"")))
|
||||
(declare (ignore spacer1 spacer2))
|
||||
(add-class menu "w3-small")
|
||||
(setf (overflow (top-panel box)) :visible) ; let menus leave the top panel
|
||||
|
|
@ -197,8 +198,9 @@
|
|||
(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))))
|
||||
(unless text
|
||||
(alert-toast obj "File Error" (format nil "Error: ~A" condition))
|
||||
(format t "Error: ~A" condition)))))
|
||||
(load-file (obj)
|
||||
(server-file-dialog obj "Load Source" (directory-namestring (if (equal file-name "")
|
||||
(current-project-dir app)
|
||||
|
|
@ -246,7 +248,8 @@
|
|||
(remove-class btn-save "w3-animate-top"))
|
||||
:initial-filename file-name)))
|
||||
(t
|
||||
(cond ((eql last-date (file-write-date file-name))
|
||||
(cond ((or (not (probe-file file-name))
|
||||
(eql last-date (file-write-date file-name)))
|
||||
(add-class btn-save "w3-animate-top")
|
||||
(write-file (text-value ace) file-name :clog-obj obj)
|
||||
(setf is-dirty nil)
|
||||
|
|
|
|||
|
|
@ -58,6 +58,7 @@ replaced. (Exported)"
|
|||
clog-builder window.")
|
||||
(defparameter *clogframe-mode* nil
|
||||
"If *clogframe-mode* is t no popup or tabs possible.")
|
||||
(defparameter *preferances-file* nil "Location of the preferance file")
|
||||
|
||||
(defparameter *start-project* nil "Set the project to start with")
|
||||
(defparameter *start-dir* nil "Set the directory the dir win should start with")
|
||||
|
|
@ -206,6 +207,7 @@ clog-builder window.")
|
|||
:width 220
|
||||
:height 230
|
||||
:hidden t)))
|
||||
(add-class about "w3-animate-opacity")
|
||||
(window-center about)
|
||||
(setf (visiblep about) t)
|
||||
(set-on-window-can-size about (lambda (obj)
|
||||
|
|
@ -309,6 +311,14 @@ clog-builder window.")
|
|||
(when dir
|
||||
(populate-dir-win d dir))))
|
||||
|
||||
(defun on-opts-edit (body)
|
||||
(let ((pref (read-file (format nil "~A.sample" *preferances-file*))))
|
||||
(unless pref
|
||||
(setf pref ";; No sample preferances file found"))
|
||||
(on-open-file body :open-file *preferances-file*
|
||||
:text pref
|
||||
:title *preferances-file*)))
|
||||
|
||||
(defun on-open-file-window (body)
|
||||
(on-new-builder body))
|
||||
|
||||
|
|
@ -337,11 +347,12 @@ clog-builder window.")
|
|||
(file (create-gui-menu-drop-down menu :content "Builder"))
|
||||
(src (create-gui-menu-drop-down menu :content "Project"))
|
||||
(tools (create-gui-menu-drop-down menu :content "Tools"))
|
||||
(opts (create-gui-menu-drop-down menu :content "Options"))
|
||||
(win (create-gui-menu-drop-down menu :content "Window"))
|
||||
(help (create-gui-menu-drop-down menu :content "Help")))
|
||||
(declare (ignore icon))
|
||||
(add-class menu "w3-small")
|
||||
(let ((exter (create-button file :content "-" :class "w3-input")))
|
||||
(let ((exter (create-button file :content "-" :class "w3-input w3-button w3-ripple")))
|
||||
(flet ((exter-text ()
|
||||
(if *open-external*
|
||||
"open external tab"
|
||||
|
|
@ -380,6 +391,7 @@ clog-builder window.")
|
|||
(lambda (obj)
|
||||
(declare (ignore obj))
|
||||
(open-window (window body) "/dbadmin")))
|
||||
(create-gui-menu-item opts :content "Edit preferences.lisp" :on-click 'on-opts-edit)
|
||||
(create-gui-menu-item win :content "Maximize" :on-click
|
||||
(lambda (obj)
|
||||
(when (current-window obj)
|
||||
|
|
@ -479,9 +491,11 @@ 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. if DIR then the directory window
|
||||
instead of the project window will be displayed."
|
||||
(load (format nil "~A/preferences.lisp"
|
||||
(merge-pathnames "./tools/"
|
||||
(asdf:system-source-directory :clog)))
|
||||
(setf *preferances-file*
|
||||
(format nil "~A/preferences.lisp"
|
||||
(merge-pathnames "tools"
|
||||
(asdf:system-source-directory :clog))))
|
||||
(load *preferances-file*
|
||||
:if-does-not-exist nil
|
||||
:verbose t)
|
||||
(setf *start-project* nil)
|
||||
|
|
|
|||
25
tools/preferences.lisp.sample
vendored
25
tools/preferences.lisp.sample
vendored
|
|
@ -1,13 +1,26 @@
|
|||
(in-package :clog-tools)
|
||||
|
||||
(setf *open-external* t)
|
||||
(setf *open-external-with-emacs* nil)
|
||||
;; Open panels and files in new browser tabs by default
|
||||
(setf *open-external* nil)
|
||||
;; Open files in browser popups instead of tabs if browser allows
|
||||
(setf *open-external-in-popup* nil)
|
||||
(setf *open-external-panels-in-popup* t)
|
||||
(setf *editor-theme* "ace/theme/terminal")
|
||||
(setf *editor-keybinding* "ace/keyboard/emacs")
|
||||
;; 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)
|
||||
;; Use emacs instead of the source-editor when openning external
|
||||
(setf *open-external-with-emacs* nil)
|
||||
;; Best Light Theme for Lisp
|
||||
(setf *editor-theme* "ace/theme/iplastic")
|
||||
;; Best Dark Theme for Lisp
|
||||
;;(setf *editor-theme* "ace/theme/terminal")
|
||||
(setf *editor-mode* "ace/mode/lisp")
|
||||
;;(setf *editor-keybinding* "ace/keyboard/emacs")
|
||||
(setf *editor-keybinding* "ace/keyboard/ace")
|
||||
(setf *editor-tab-size* 2)
|
||||
;; See https://github.com/ajaxorg/ace/wiki/Configuring-Ace
|
||||
(setf *editor-renderer-options*
|
||||
"fontSize : 16,
|
||||
"fontSize : 14,
|
||||
showInvisibles : false,
|
||||
displayIndentGuides : true,
|
||||
printMarginColumn : 80,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue