summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--lib/eos/jao-minibuffer.el59
1 files changed, 35 insertions, 24 deletions
diff --git a/lib/eos/jao-minibuffer.el b/lib/eos/jao-minibuffer.el
index c3c4506..e48e6ea 100644
--- a/lib/eos/jao-minibuffer.el
+++ b/lib/eos/jao-minibuffer.el
@@ -20,7 +20,7 @@
;;; Commentary:
-;; Simple asynchronous display of information in the minibuffer.
+;; Simple asynchronous display of information in the minibuffer and echo area.
;;; Code:
@@ -34,6 +34,31 @@
(defvar jao-minibuffer-inactive-buffer-line-color "grey25")
(defconst jao-minibuffer--name " *Minibuf-0*")
+(defvar jao-minibuffer--overlays nil)
+
+(defun jao-minibuffer--create-overlays ()
+ (dolist (buf '(" *Echo Area 0*" " *Echo Area 1*"))
+ (with-current-buffer buf
+ (remove-overlays (point-min) (point-max))
+ (push (make-overlay (point-min) (point-max) nil nil t)
+ jao-minibuffer--overlays))))
+
+(defun jao-minibuffer--remove-overlays ()
+ (mapc 'delete-overlay jao-minibuffer--overlays)
+ (setq jao-minibuffer--overlays nil))
+
+(defun jao-minibuffer--set-overlays (txt)
+ (let* ((wid (+ (string-width txt)))
+ (align `(space :align-to (- right-fringe ,wid)))
+ (spc (propertize " " 'cursor 1 'display align))
+ (txt (concat spc txt)))
+ ;; Remove any dead overlays from the minibuffer from the beginning of the list
+ (while (null (overlay-buffer (car jao-minibuffer--overlays)))
+ (pop jao-minibuffer--overlays))
+
+ ;; Add the correct text to each echo bar overlay
+ (dolist (o jao-minibuffer--overlays)
+ (when (overlay-buffer o) (overlay-put o 'after-string txt)))))
(defun jao-minibuffer--trim (s w)
(if (<= (string-width (or s "")) w)
@@ -54,8 +79,8 @@
(reverse (or info jao-minibuffer-info)))))
" "))
-(defun jao-minibuffer--aligned (&optional w)
- (let* ((msg (jao-minibuffer--format-info))
+(defun jao-minibuffer--aligned (&optional w msg)
+ (let* ((msg (or msg (jao-minibuffer--format-info)))
(msg (cond (jao-minibuffer-align-right-p (string-trim msg))
(t (string-trim-left msg))))
(msg (propertize msg :minibuffer-message t)))
@@ -77,20 +102,6 @@
(string-trim (substring msg 0 n))
msg))
-(defun jao-minibuffer--format-msg (msg)
- (let* ((msgs (mapcar #'jao-minibuffer--strip-prev (split-string msg "\n")))
- (prefix (when-let (p (string-join (butlast msgs) "\n"))
- (unless (string-blank-p p) (concat p "\n"))))
- (msg (car (last msgs)))
- (msg (if (string-blank-p msg) msg (concat msg " ")))
- (w (string-width msg)))
- (if jao-minibuffer-align-right-p
- (concat prefix msg (jao-minibuffer--aligned w))
- (concat prefix (jao-minibuffer--aligned (+ 3 w)) " " msg))))
-
-(defun jao-minibuffer--set-message (msg)
- (when jao-minibuffer-mode (jao-minibuffer--format-msg (or msg ""))))
-
(defvar exwm-class-name nil)
(defvar jao-minibuffer--mode-line-position
@@ -166,13 +177,11 @@
(if jao-minibuffer-mode
(progn (advice-add 'select-window :after #'jao-minibuffer-refresh)
(advice-add 'force-mode-line-update :after #'jao-minibuffer-refresh)
- (setq set-message-function #'jao-minibuffer--set-message)
- (setq clear-message-function #'jao-minibuffer-refresh)
+ (jao-minibuffer--create-overlays)
(jao-minibuffer-refresh))
(advice-remove 'select-window #'jao-minibuffer-refresh)
(advice-remove 'force-mode-line-update #'jao-minibuffer-refresh)
- (setq set-message-function nil)
- (setq clear-message-function nil)
+ (jao-minibuffer--remove-overlays)
(jao-minibuffer--insert "")))
;;;###autoload
@@ -181,9 +190,11 @@
(when jao-minibuffer-mode
(let* ((jao-minibuffer-mode nil)
(window-selection-change-functions nil)
- (msg (jao-minibuffer--format-info jao-minibuffer-msg-info))
- (msg (jao-minibuffer--format-msg (or msg ""))))
- (jao-minibuffer--insert (or msg "")))))
+ (msg (jao-minibuffer--format-info))
+ (msg-left (jao-minibuffer--format-info jao-minibuffer-msg-info))
+ (msg-right (jao-minibuffer--aligned (string-width msg-left) msg)))
+ (jao-minibuffer--set-overlays msg)
+ (jao-minibuffer--insert (concat msg-left msg-right)))))
;; (add-hook 'window-selection-change-functions #'jao-minibuffer-refresh)