diff --git a/core/cubes/editor.el b/core/cubes/editor.el index deb7f71..ca1ad33 100644 --- a/core/cubes/editor.el +++ b/core/cubes/editor.el @@ -246,10 +246,9 @@ (let ((mline (or (plist-get fg42/editor-cube-params :modeline) #'fg42/default-modeline))) - (fg42/statusbar-cube) - ;; (fg42/modeline-cube) - (fg42/setup-modeline-format mline) - ) + ;;(fg42/statusbar-cube) + (fg42/modeline-cube) + (fg42/setup-modeline-format mline)) (fg42/font-cube) (fg42/pinentry-cube) diff --git a/core/cubes/modeline.el b/core/cubes/modeline.el index a2eccd6..64c1927 100644 --- a/core/cubes/modeline.el +++ b/core/cubes/modeline.el @@ -39,10 +39,25 @@ :flag-default t) (defun fg42/mini-modeline-setter (def) - (let ((def-list (func def))) - (setq-default mini-modeline-l-format (plist-get def-list :long)) - (setq-default mini-modeline-r-format (plist-get def-list :brief)))) + (if (null def) + (let ((def-list (funcall def))) + (setq-default mini-modeline-l-format (plist-get def-list :long)) + (setq-default mini-modeline-r-format (plist-get def-list :brief))) + (setq-default + mini-modeline-r-format + '("%e" + mode-line-front-space + mode-line-mule-info + mode-line-client + mode-line-modified + mode-line-remote + mode-line-frame-identification + mode-line-buffer-identification + mode-line-position + evil-mode-line-tag + (:eval (string-trim (format-mode-line mode-line-modes))) + mode-line-misc-info )))) (fpkg/use smart-mode-line :straight (smart-mode-line :source melpa) diff --git a/core/cubes/modeline/statusbar-default.el b/core/cubes/modeline/statusbar-default.el index 6fd3584..8d6e7f6 100644 --- a/core/cubes/modeline/statusbar-default.el +++ b/core/cubes/modeline/statusbar-default.el @@ -53,24 +53,90 @@ thresholds ERR adn WARN" (propertize (format "%02d" m) 'face (fg42/percentage-face m 90 75)) (propertize (format "%02d" s) 'face (fg42/percentage-face s 90 75))))) -;; The default modeline for FG42 that is compatible with -;; the FG42's status bar only -(defmode-line fg42/statusbar-default - (if (display-graphic-p) - (progn - ;; We are in the graphical world - (require 'all-the-icons) - (list - :brief (list - 'fg42/statusbar-battery - 'fg42/statusbar-memory - "|" '(buffer-name) "|" '(format-mode-line "%l:%c") "|" '(format-time-string "%m-%d %H:%M")) - :long " ")) +(defface fg42/statusbar-project-face + '((t :inherit font-lock-type-face :bold t)) + "Project name face on status bar" + :group 'fg42/statusbar) + +(defface fg42/statusbar-buffer-name-face + '((t :inherit font-lock-variable-name-face)) + "Buffer name face on status line" + :group 'fg42/statusbar) + + +(defun fg42/statusbar-project-name () + (when-flag projectile + (projectile-project-name))) + + +(defun fg42/statusbar-buffer-and-project () + (format "%s:%s" + (propertize (fg42/statusbar-project-name) 'face 'fg42/statusbar-project-face) + (propertize (buffer-name) 'face 'fg42/statusbar-buffer-name-face))) + +;; (defvar fg42/statusbar-git-branch "-") +;; (defvar fg42/statusbar--last-branch "-") + + +;; (defun fg42/statusbar-update-git-branch() +;; (message "eeoeeeeee") +;; (setq fg42/statusbar-git-branch +;; (shell-command-to-string "git symbolic-ref --short HEAD"))) + +;; (defun fg42/statusbar-setup-git-branch-updater () +;; ;;(add-function :after after-focus-change-function #'fg42/statusbar-update-git-branch) +;; (advice-add :after 'ace-select-window #'fg42/statusbar-update-git-branch) + +;; 'fg42/statusbar-git-branch) + + +(defmode-line fg42/statusbar-default + (list + :brief (list + ;;'(buffer-name) + ;;'fg42/statusbar-battery + + "|" + '(substring-no-properties (vc-mode vc-mode)) + "|" + '(fg42/statusbar-buffer-and-project) + "|" + 'fg42/statusbar-memory + "|" + '(format-mode-line "%03l:%02c") + + ;;'(format-time-string "%m-%d %H:%M") + ;; (let ((bar (format "%s" fg42/statusbar-memory))) (add-text-properties 0 (string-width bar) (cons 'face (cons '(:size 0.3) (or (get-text-property 0 'face bar) 'default-face))) bar) + ;; bar) + ) + :long " ") ;; No GUI + + ) +;; The default modeline for FG42 WM that is compatible with +;; the FG42's status bar only +(defmode-line fg42/statusbar-default-wm + (progn + ;; We are in the graphical world + (require 'all-the-icons) + ;;(format "%s|%s|%s|%s|%s") (list - :brief (list) - :long ""))) + :brief (list + ;;'(buffer-name) + ;;'fg42/statusbar-battery + + 'fg42/statusbar-memory + '(format-mode-line "%03l:%02c") + + ;;'(format-time-string "%m-%d %H:%M") + ;; (let ((bar (format "%s" fg42/statusbar-memory))) (add-text-properties 0 (string-width bar) (cons 'face (cons '(:size 0.3) (or (get-text-property 0 'face bar) 'default-face))) bar) + ;; bar) + ) + :long " ")) + ;; No GUI + + ) (provide 'fg42/modeline/statusbar-default) diff --git a/core/fg42/modeline.el b/core/fg42/modeline.el index 73cbe1a..4e5da3a 100644 --- a/core/fg42/modeline.el +++ b/core/fg42/modeline.el @@ -47,7 +47,5 @@ (funcall fg42/modeline-setter definition)) - - (provide 'fg42/modeline) ;;; modeline.el ends here diff --git a/core/fg42/statusbar.el b/core/fg42/statusbar.el index 1a0c44e..998bae5 100644 --- a/core/fg42/statusbar.el +++ b/core/fg42/statusbar.el @@ -78,6 +78,8 @@ Nil means current selected frame." :group 'fg42/statusbar) +(defvar fg42/statusbar-height 4) + (defcustom fg42/statusbar-face-attr `(:background ,(face-attribute 'mode-line :background)) "Plist of face attribute/value pair for fg42/statusbar." :type '(plist) @@ -89,21 +91,27 @@ Nil means current selected frame." (defface fg42/statusbar-mode-line '((((background light)) - :background "#55ced1" :height 0.14 :box nil) + :background "#55ced1" :height 0.1 :box nil) (t - :background "#008b8b" :height 0.14 :box nil)) + :background "#3f3f3f" :height 0.2 :box nil)) + + "Modeline face for active window." + :group 'fg42/statusbar) + +(defface fg42/statusbar-components + '((t :inherit t :height 0.7)) "Modeline face for active window." :group 'fg42/statusbar) (defface fg42/statusbar-mode-line-inactive - '((((background light)) - :background "#dddddd" :height 0.1 :box nil) - (t - :background "#333333" :height 0.1 :box nil)) - "Modeline face for inactive window." - :group 'fg42/statusbar) + '((((background light)) + :background "#dddddd" :height 0.1 :box nil) + (t + :background "#333333" :height 0.1 :box nil)) + "Modeline face for inactive window." + :group 'fg42/statusbar) ;; ============================================================================ @@ -360,7 +368,7 @@ that runs the given BODY at the given INTERVAL." (when (> (length result) 0) result))) fg42/statusbar-components - " ")) + "")) (defun fg42/statusbar-get-frame-width () @@ -410,61 +418,61 @@ as `snails'." When ARG is: - `force', force update the minibuffer. - `clear', clear the minibuffer. This implies `force'." -(save-match-data - (let ((bar-info (fg42/statusbar-build-active-info))) - (condition-case err + (save-match-data + (let ((bar-info (fg42/statusbar-build-active-info))) + (condition-case err - (cl-letf (((symbol-function 'completion-all-completions) #'ignore)) - (unless (or (active-minibuffer-window) - (input-pending-p)) - (setq fg42/statusbar--minibuffer - (window-buffer (minibuffer-window fg42/statusbar-frame))) - (with-current-buffer fg42/statusbar--minibuffer - (let ((truncate-lines fg42/statusbar-truncate-p) - (inhibit-read-only t) - (inhibit-redisplay t) - (buffer-undo-list t) - modeline-content) - (when (or (memq arg '(force clear)) - (fg42/statusbar--overduep fg42/statusbar--last-update - fg42/statusbar-refresh-idle-delay)) - (when-let ((msg (or fg42/statusbar--msg-message (current-message)))) - ;; Clear echo area and start new timer for echo message - (message nil) - (setq fg42/statusbar--last-echoed (current-time)) - ;; we proritize the message from `message' - ;; or the message when we're not in middle of a command running. - (when (or fg42/statusbar--msg-message - (eq fg42/statusbar-command-state 'begin)) - (setq fg42/statusbar-command-state 'exec) - ;; Don't echo keystrokes when in middle of command - (setq echo-keystrokes 0)) - (setq fg42/statusbar--msg msg)) - ;; Reset echo message when timeout and not in middle of command - (when (and fg42/statusbar--msg - (not (memq fg42/statusbar-command-state '(exec exec-read))) - (fg42/statusbar--overduep fg42/statusbar--last-echoed - fg42/statusbar-echo-duration)) - (setq fg42/statusbar--msg nil)) - ;; Showing fg42/statusbar - (if (eq arg 'clear) - (setq modeline-content nil) - (setq modeline-content - (fg42/statusbar-get-echo-format-string bar-info fg42/statusbar--msg)) - (setq fg42/statusbar--last-update (current-time))) + (cl-letf (((symbol-function 'completion-all-completions) #'ignore)) + (unless (or (active-minibuffer-window) + (input-pending-p)) + (setq fg42/statusbar--minibuffer + (window-buffer (minibuffer-window fg42/statusbar-frame))) + (with-current-buffer fg42/statusbar--minibuffer + (let ((truncate-lines fg42/statusbar-truncate-p) + (inhibit-read-only t) + (inhibit-redisplay t) + (buffer-undo-list t) + modeline-content) + (when (or (memq arg '(force clear)) + (fg42/statusbar--overduep fg42/statusbar--last-update + fg42/statusbar-refresh-idle-delay)) + (when-let ((msg (or fg42/statusbar--msg-message (current-message)))) + ;; Clear echo area and start new timer for echo message + (message nil) + (setq fg42/statusbar--last-echoed (current-time)) + ;; we proritize the message from `message' + ;; or the message when we're not in middle of a command running. + (when (or fg42/statusbar--msg-message + (eq fg42/statusbar-command-state 'begin)) + (setq fg42/statusbar-command-state 'exec) + ;; Don't echo keystrokes when in middle of command + (setq echo-keystrokes 0)) + (setq fg42/statusbar--msg msg)) + ;; Reset echo message when timeout and not in middle of command + (when (and fg42/statusbar--msg + (not (memq fg42/statusbar-command-state '(exec exec-read))) + (fg42/statusbar--overduep fg42/statusbar--last-echoed + fg42/statusbar-echo-duration)) + (setq fg42/statusbar--msg nil)) + ;; Showing fg42/statusbar + (if (eq arg 'clear) + (setq modeline-content nil) + (setq modeline-content + (fg42/statusbar-get-echo-format-string bar-info fg42/statusbar--msg)) + (setq fg42/statusbar--last-update (current-time))) - ;; write to minibuffer - (unless (equal modeline-content - fg42/statusbar--cache)) - (setq fg42/statusbar--cache modeline-content) - (erase-buffer) - (when fg42/statusbar--cache - (let ( - ;;let fg42/statusbar take control of mini-buffer size - (resize-mini-windows t)) - (insert fg42/statusbar--cache)))))))) - ((error debug) - (fg42/statusbar--log "fg42/statusbar: %s\n" err)))))) + ;; write to minibuffer + (unless (equal modeline-content + fg42/statusbar--cache)) + (setq fg42/statusbar--cache modeline-content) + (erase-buffer) + (when fg42/statusbar--cache + (let ( + ;;let fg42/statusbar take control of mini-buffer size + (resize-mini-windows t)) + (insert fg42/statusbar--cache)))))))) + ((error debug) + (fg42/statusbar--log "fg42/statusbar: %s\n" err)))))) (defun fg42/statusbar-message-advice (f &rest args)