From b772ab634dea65d71a681721c2f61d56e6027e33 Mon Sep 17 00:00:00 2001 From: Sameer Rahmani Date: Sun, 25 Jun 2023 23:40:24 +0100 Subject: [PATCH] Disable the default modeline and replace it by Noether --- core/cubes/editor.el | 7 +++- core/cubes/fg42.el | 1 + core/cubes/modeline.el | 90 ++++++++++++++++++++++++++++-------------- core/cubes/noether.el | 42 ++++++++++++++++++++ core/fg42/status.el | 73 ++++++++++++++++++++++++++++++++++ core/fpkg.el | 9 +++-- 6 files changed, 187 insertions(+), 35 deletions(-) create mode 100644 core/cubes/noether.el create mode 100644 core/fg42/status.el diff --git a/core/cubes/editor.el b/core/cubes/editor.el index b539054..e3f7e7b 100644 --- a/core/cubes/editor.el +++ b/core/cubes/editor.el @@ -299,6 +299,7 @@ https://emacsthemes.com/themes/badwolf-theme.html" :title "Editor cube" :no-flag t + (fg42/disable-modeline-cube) (fpkg/use rainbow-delimiters ;; It doesn't work due to a problem/conflict in rainbow-delimiters ;; But we use it any way they might fix it @@ -357,11 +358,13 @@ https://emacsthemes.com/themes/badwolf-theme.html" ;; Call the editor related cubes. They will be run only if ;; their flag is active otherwise they will be skipped + (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/modeline-cube) + ;; (fg42/setup-modeline-format mline) + )) (provide 'cubes/editor) diff --git a/core/cubes/fg42.el b/core/cubes/fg42.el index e6d6cfa..afffc6c 100644 --- a/core/cubes/fg42.el +++ b/core/cubes/fg42.el @@ -53,6 +53,7 @@ (require 'cubes/proof) (require 'cubes/agda) (require 'cubes/notifications) +(require 'cubes/noether) (defcube fg42/editor diff --git a/core/cubes/modeline.el b/core/cubes/modeline.el index d64952d..d3b03b2 100644 --- a/core/cubes/modeline.el +++ b/core/cubes/modeline.el @@ -29,17 +29,49 @@ "modeline/statusbar-default.el" "The default StatusBar modeline.") +(defface fg42/-disabled-modeline-active-border + '((t + :background "#bd93f9" :height 0.1 :box nil)) + "A new face for modeline in active state." + :group 'fg42) -(->cube smart-mode-line +(defface fg42/-disabled-modeline-dective-border + '((t + :background "#44475a" :height 0.1 :box nil)) + "A new face for modeline in active state." + :group 'fg42) + + +(defcube fg42/disable-modeline-cube + "This cube disables the default modeline and replaces it with a thin border" + :title "Disable Mode line" + :flag disable-modeline + :flag-default nil + (setq-default mode-line-format "") + (let ((face-remaps (default-value 'face-remapping-alist))) + (setf (alist-get 'mode-line face-remaps) + 'fg42/-disabled-modeline-active-border + (alist-get 'mode-line-inactive face-remaps) + 'fg42/-disabled-modeline-dective-border + (default-value 'face-remapping-alist) face-remaps))) + + +(defcube fg42/smart-mode-line-cube "Smart mode line is a pretty simple yet fantastic alternative to Emacs modeline." - :straight (smart-mode-line :source melpa) - :defer nil - :init - (progn - (setq sml/theme 'respectful) - (setq sml/no-confirm-load-theme t) - (sml/setup))) + :title "Smart modeline cube" + :flag smart-mode-line + :flag-default nil + + (fpkg/use smart-mode-line + :straight (smart-mode-line :source melpa) + :defer nil + :init + (progn + (setq sml/theme 'respectful) + (setq sml/no-confirm-load-theme t) + (sml/setup)))) + ;; TODO: Break this into two cubes (defcube fg42/modeline-cube @@ -47,7 +79,7 @@ to Emacs modeline." :title "Mini modeline" :flag mini-mode-line :group modeline - :flag-default t + :flag-default nil (defun fg42/mini-modeline-setter (def) (if (null def) @@ -67,30 +99,30 @@ to Emacs modeline." mode-line-buffer-identification mode-line-position evil-mode-line-tag - (:eval (string-trim (format-mode-line mode-line-modes))) + ;; (:eval (string-trim (format-mode-line mode-line-modes))) mode-line-misc-info )))) (fpkg/use mini-modeline - :straight (mini-modeline :repo "kiennq/emacs-mini-modeline" - :host github - :type git) - :after smart-mode-line - :init - (progn - (setq mini-modeline-enhance-visual nil) - (setq fg42/modeline-setter #'fg42/mini-modeline-setter)) - :defer nil - :config - (add-hook 'fg42/after-init-hook #'mini-modeline-mode) - (add-hook 'fg42/after-initializing-theme-hook - (lambda () - (custom-set-faces - '(mini-modeline-mode-line - ((((background light)) - :background "#aa0000" :height 0.1 :box nil) - (t - :background "#bd93f9" :height 0.1 :box nil)))))))) + :straight (mini-modeline :repo "kiennq/emacs-mini-modeline" + :host github + :type git) + :after smart-mode-line + :init + (progn + (setq mini-modeline-enhance-visual nil) + (setq fg42/modeline-setter #'fg42/mini-modeline-setter)) + :defer nil + :config + (add-hook 'fg42/after-init-hook #'mini-modeline-mode) + (add-hook 'fg42/after-initializing-theme-hook + (lambda () + (custom-set-faces + '(mini-modeline-mode-line + ((((background light)) + :background "#aa0000" :height 0.1 :box nil) + (t + :background "#bd93f9" :height 0.1 :box nil)))))))) (defcube fg42/statusbar-cube diff --git a/core/cubes/noether.el b/core/cubes/noether.el new file mode 100644 index 0000000..e2aeeeb --- /dev/null +++ b/core/cubes/noether.el @@ -0,0 +1,42 @@ +;;; ModelineCubes --- The modeline related cubes for FG42 -*- lexical-binding: t; -*- +;; +;; Copyright (c) 2010-2023 Sameer Rahmani & Contributors +;; +;; Author: Sameer Rahmani +;; URL: https://devheroes.codes/FG42/FG42 +;; Version: 3.0.0 +;; +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. +;; +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. +;; +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see . +;; +;;; Commentary: +;;; Code: +(require 'fpkg) +(require 'fg42/cube) +(require 'cubes/icons) + + +(->cube noether-mode + "Smart mode line is a pretty simple yet fantastic alternative +to Emacs modeline." + :straight (noether-mode :repo "https://devheroes.codes/lxsameer/noether.git") + :init + (require 'noether) + (require 'noether-views) + (let ((views (or (plist-get fg42/noether-mode-cube-params :views) (list noether-minimal-mode-line)))) + (setq noether-views views) + (noether-global-mode))) + + +(provide 'cubes/noether) +;;; noether.el ends here diff --git a/core/fg42/status.el b/core/fg42/status.el new file mode 100644 index 0000000..f8b1124 --- /dev/null +++ b/core/fg42/status.el @@ -0,0 +1,73 @@ +;;; FG42 --- The mighty editor for the emacsians -*- lexical-binding: t; -*- +;; +;; Copyright (c) 2010-2023 Sameer Rahmani +;; +;; Author: Sameer Rahmani +;; URL: https://devheroes.codes/FG42/FG42 +;; Version: 3.0.0 +;; +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. +;; +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. +;; +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see . +;; +;;; Commentary: +;;; Code: + +;; Some of the functions in this module are borrowed from `mini-modeline' +;; at https://github.com/kiennq/emacs-mini-modeline (GPL). I modified to +;; fit my needs. + +;;; Require +(require 'fpkg) +(fpkg/require 'all-the-icons) +(fpkg/require 'posframe) + +(defvar fg42/status-buffer "*status-buffer*" + "The name of the status buffer to use.") + + +(defun fg42/status-show () + (interactive) + (with-current-buffer fg42/status-buffer + (erase-buffer) + (insert (propertize (all-the-icons-octicon "package") + 'face `(:family ,(all-the-icons-octicon-family) :height 1) + ;; 'display '(raise -0.1) + ) ) + (insert "| A | B | C")) + + (posframe-show + fg42/status-buffer + :min-height 1 + :min-width 10 + :position (cons (- (frame-outer-width) 10) (- (frame-outer-height) 10)) + + ;;:poshandler #'posframe-poshandler-frame-bottom-right-corner + ;;:border-width 1 + :border-color "#aa00bb" + :accept-focus nil + :timeout 5 + :refresh 1)) + + +(posframe-delete-all) +(define-minor-mode fg42/global-statue-mode + "A minor mode that keep tracks of different status blocks. +It reports them back in a status bar like frame." + :global t + :lighter " ST42" + :keymap (let ((map (make-sparse-keymap))))) + +(fg42/global-statue-mode) + +(provide 'status.el) +;;; status.el ends here diff --git a/core/fpkg.el b/core/fpkg.el index 58ef1a8..3f2f327 100644 --- a/core/fpkg.el +++ b/core/fpkg.el @@ -52,11 +52,12 @@ `(use-package ,pkg :straight t :defer t))) -(defun fpkg/require (pkg) +(defmacro fpkg/require (pkg) "Work like require but make sure that PKG is installed first." - (fpkg/use pkg - :init - (require pkg))) + (let ((pkg-name (intern (symbol-name `,(cadr pkg))))) + `(fpkg/use ,pkg-name + :init + (require ,pkg)))) (provide 'fpkg) ;;; fpkg.el ends here