From 1ae39fb23a9962c944c2f73258b57fe1e2a59e78 Mon Sep 17 00:00:00 2001 From: jao Date: Fri, 4 Mar 2022 03:57:37 +0000 Subject: jao-minibuffer-mode-line -> jao-mode-line --- lib/eos/jao-minibuffer-mode-line.el | 106 -------------------------- lib/eos/jao-mode-line.el | 147 ++++++++++++++++++++++++++++++++++++ 2 files changed, 147 insertions(+), 106 deletions(-) delete mode 100644 lib/eos/jao-minibuffer-mode-line.el create mode 100644 lib/eos/jao-mode-line.el (limited to 'lib') diff --git a/lib/eos/jao-minibuffer-mode-line.el b/lib/eos/jao-minibuffer-mode-line.el deleted file mode 100644 index 6f69630..0000000 --- a/lib/eos/jao-minibuffer-mode-line.el +++ /dev/null @@ -1,106 +0,0 @@ -;;; jao-minibuffer-mode-line.el --- mode-line info in the minibuffer -*- lexical-binding: t; -*- - -;; Copyright (C) 2022 jao - -;; Author: jao -;; Keywords: convenience - -;; 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: - -;; Using jao-minibuffer to display mode-line info in the minibuffer. - -;;; Code: - -(require 'jao-minibuffer) - -(defvar exwm-class-name nil) - -(defvar jao-minibuffer--mode-line-position - '(exwm-class-name - ("") - ("%n %2c %l " (:eval (format "%d" (line-number-at-pos (point-max))))))) - -(defvar jao-minibuffer--mode-line-bid - '(:eval (cond ((derived-mode-p 'gnus-group-mode - 'gnus-article-mode - 'gnus-summary-mode) - mode-line-buffer-identification) - ((derived-mode-p 'circe-channel-mode) - (format "%s [%d]" (buffer-name) (length (circe-channel-nicks)))) - (t "%b")))) - -(defvar jao-minibuffer--mode-line-format - `("%[" (:propertize ,jao-minibuffer--mode-line-bid face jao-themes-f00) "%]" - (:propertize " (" face jao-themes-dimm) - (:propertize mode-name face jao-themes-f00) - (:propertize ("" minor-mode-alist) face jao-themes-f11) - (:propertize ")" face jao-themes-dimm) - (:propertize (vc-mode vc-mode) face jao-themes-f10) - (:propertize mode-line-position face jao-themes-f12) - " " - global-mode-string - (:propertize (" %Z%*%+ " (current-input-method current-input-method-title)) - face jao-themes-warning) - (:propertize "·" display ""))) - -(defvar jao-minibuffer--original-modeline nil) -(defvar jao-minibuffer--original-line-face nil) -(defvar jao-minibuffer--original-line-inactive-face nil) - -(defun jao-minibuffer-mode-line-adjust-faces () - (let ((bg (frame-parameter nil 'background-color))) - (set-face-attribute 'mode-line nil :box nil :height 1 - :background bg :foreground bg - :overline jao-minibuffer-active-buffer-line-color - :underline jao-minibuffer-inactive-buffer-line-color - :extend t) - (set-face-attribute 'mode-line-inactive nil :box nil :height 1 - :background bg :foreground bg - :overline bg - :underline jao-minibuffer-inactive-buffer-line-color - :extend t))) - -;;;###autoload -(defun jao-minibuffer-add-mode-line (&optional order) - (interactive) - (setq jao-minibuffer--original-line-face - (get 'mode-line 'saved-face)) - (setq jao-minibuffer--original-line-inactive-face - (get 'mode-line-inactive 'saved-face)) - (setq jao-minibuffer--original-modeline mode-line-format) - (setq-default mode-line-format '(" ")) - (setq-default mode-line-position jao-minibuffer--mode-line-position) - (dolist (b (buffer-list)) - (with-current-buffer b (setq-local mode-line-format '(" ")))) - (jao-minibuffer-add-variable 'jao-minibuffer--mode-line-format (or order 90)) - (jao-minibuffer-mode-line-adjust-faces)) - -;;;###autoload -(defun jao-minibuffer-remove-mode-line () - (interactive) - (face-spec-set 'mode-line jao-minibuffer--original-line-face) - (face-spec-set 'mode-line-inactive jao-minibuffer--original-line-inactive-face) - (setq-default mode-line-format jao-minibuffer--original-modeline) - (dolist (b (buffer-list)) - (with-current-buffer b (setq-local mode-line-format - jao-minibuffer--original-modeline))) - (setq jao-minibuffer-info - (remove '(:eval jao-minibuffer--mode-line-format) - jao-minibuffer-info))) - - -(provide 'jao-minibuffer-mode-line) -;;; jao-minibuffer-mode-line.el ends here diff --git a/lib/eos/jao-mode-line.el b/lib/eos/jao-mode-line.el new file mode 100644 index 0000000..566fdf1 --- /dev/null +++ b/lib/eos/jao-mode-line.el @@ -0,0 +1,147 @@ +;;; jao-mode-line.el --- mode-line info -*- lexical-binding: t; -*- + +;; Copyright (C) 2022 jao + +;; Author: jao +;; Keywords: convenience + +;; 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: + +;; Using jao-minibuffer to display mode-line info in the minibuffer, +;; or toggle it off in non-active windows. + +;;; Code: + +(require 'jao-minibuffer) + + +;;;; mode line toggle +(defun jao-mode-line--face-height (face &optional all) + (let* ((h (face-attribute face :height (window-frame))) + (nh (if (eq 'unspecified h) 1 'unspecified))) + (set-face-attribute face (when (not all) (window-frame)) :height nh))) + +(defun jao-mode-line--set-inactive-face (x frame) + (unless (eq x (face-attribute 'mode-line-inactive :height frame)) + (set-face-attribute 'mode-line-inactive frame :height x))) + +;;;###autoload +(defun jao-mode-line-toggle (&optional all) + (interactive "P") + (jao-mode-line--face-height 'mode-line all)) + +;;;###autoload +(defun jao-mode-line-toggle-inactive (&optional all) + (interactive "P") + (jao-mode-line--face-height 'mode-line-inactive all)) + +;;;###autoload +(defun jao-mode-line-echo () + (interactive) + (message "%s" (format-mode-line mode-line-format))) + +;;;###autoload +(defun jao-mode-line-hide-inactive (frame) + (jao-mode-line--set-inactive-face 1 frame)) + +;;;###autoload +(defun jao-mode-line-show-inactive (frame) + (jao-mode-line--set-inactive-face 'unspecified frame)) + + +;;;; mode line format + +(defvar exwm-class-name nil) + +(defvar jao-mode-line--position + '(exwm-class-name + ("") + ("%n %2c %l " (:eval (format "%d" (line-number-at-pos (point-max))))))) + +(defvar jao-mode-line--bid + '(:eval (cond ((derived-mode-p 'gnus-group-mode + 'gnus-article-mode + 'gnus-summary-mode) + mode-line-buffer-identification) + ((derived-mode-p 'circe-channel-mode) + (format "%s [%d]" (buffer-name) (length (circe-channel-nicks)))) + (t "%b")))) + +(defvar jao-minibuffer--mode-line-format + `("%[" (:propertize ,jao-mode-line--bid face jao-themes-f00) "%]" + (:propertize " (" face jao-themes-dimm) + (:propertize mode-name face jao-themes-f00) + (:propertize ("" minor-mode-alist) face jao-themes-f11) + (:propertize ")" face jao-themes-dimm) + (:propertize (vc-mode vc-mode) face jao-themes-f10) + (:propertize mode-line-position face jao-themes-f12) + " " + global-mode-string + (:propertize (" %Z%*%+ " (current-input-method current-input-method-title)) + face jao-themes-warning) + (:propertize "·" display ""))) + + +;;;; mode line in minibuffer + +(defvar jao-mode-line--original-modeline nil) +(defvar jao-mode-line--original-line-face nil) +(defvar jao-mode-line--original-line-inactive-face nil) + +(defun jao-mode-line-adjust-faces () + (let ((bg (frame-parameter nil 'background-color))) + (set-face-attribute 'mode-line nil :box nil :height 1 + :background bg :foreground bg + :overline jao-minibuffer-active-buffer-line-color + :underline jao-minibuffer-inactive-buffer-line-color + :extend t) + (set-face-attribute 'mode-line-inactive nil :box nil :height 1 + :background bg :foreground bg + :overline bg + :underline jao-minibuffer-inactive-buffer-line-color + :extend t))) + +;;;###autoload +(defun jao-mode-line-add-to-minibuffer (&optional order) + (interactive) + (setq jao-mode-line--original-line-face + (get 'mode-line 'saved-face)) + (setq jao-mode-line--original-line-inactive-face + (get 'mode-line-inactive 'saved-face)) + (setq jao-mode-line--original-modeline mode-line-format) + (setq-default mode-line-format '(" ")) + (setq-default mode-line-position jao-mode-line--position) + (dolist (b (buffer-list)) + (with-current-buffer b (setq-local mode-line-format '(" ")))) + (jao-minibuffer-add-variable 'jao-mode-line--mode-line-format (or order 90)) + (jao-mode-line-adjust-faces)) + +;;;###autoload +(defun jao-mode-line-remove-from-minibuffer () + (interactive) + (face-spec-set 'mode-line jao-mode-line--original-line-face) + (face-spec-set 'mode-line-inactive jao-mode-line--original-line-inactive-face) + (setq-default mode-line-format jao-mode-line--original-modeline) + (dolist (b (buffer-list)) + (with-current-buffer b (setq-local mode-line-format + jao-mode-line--original-modeline))) + (setq jao-minibuffer-info + (remove '(:eval jao-mode-line--mode-line-format) + jao-minibuffer-info))) + + +(provide 'jao-mode-line) +;;; jao-mode-line.el ends here -- cgit v1.2.3