emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/ace-window b2cc22a164 1/3: Provide ace-window-posframe-


From: ELPA Syncer
Subject: [elpa] externals/ace-window b2cc22a164 1/3: Provide ace-window-posframe-mode
Date: Tue, 6 Sep 2022 14:57:15 -0400 (EDT)

branch: externals/ace-window
commit b2cc22a164829c788d3b6b3016e81cd97c94852d
Author: Mark Skilbeck <mark.skilbeck@rigetti.com>
Commit: Oleh Krehel <ohwoeowho@gmail.com>

    Provide ace-window-posframe-mode
    
    Use posframes for overlays.
---
 ace-window-posframe.el | 37 +++++++++++++++++++++++++++++++++++++
 ace-window.el          | 13 +++++++++++--
 2 files changed, 48 insertions(+), 2 deletions(-)

diff --git a/ace-window-posframe.el b/ace-window-posframe.el
new file mode 100644
index 0000000000..d7153183f2
--- /dev/null
+++ b/ace-window-posframe.el
@@ -0,0 +1,37 @@
+(defvar aw--posframe-frames '())
+
+(defun aw--lead-overlay-posframe (path leaf)
+  (let* ((wnd (cdr leaf))
+         (str (apply #'string path))
+         (bufname (format "*aw-posframe-buffer-%s*" (gensym))))
+    (with-selected-window wnd
+      (push bufname aw--posframe-frames)
+      (posframe-show bufname
+                     :string str
+                     :poshandler 'posframe-poshandler-window-center
+                     :font (face-font 'aw-leading-char-face)
+                     :foreground-color (face-foreground 'aw-leading-char-face)
+                     :background-color (face-background 
'aw-leading-char-face)))))
+
+(defun aw--remove-leading-chars-posframe ()
+  (map nil #'posframe-delete aw--posframe-frames))
+
+(defun ace-window-posframe-enable ()
+  (setq aw--lead-overlay-fn #'aw--lead-overlay-posframe
+        aw--remove-leading-chars-fn #'aw--remove-leading-chars-posframe))
+
+(defun ace-window-posframe-disable ()
+  (setq aw--lead-overlay-fn #'aw--lead-overlay
+        aw--remove-leading-chars-fn #'aw--remove-leading))
+
+;;;###autoload
+(define-minor-mode ace-window-posframe-mode
+  ""
+  :global t
+  :require 'ace-window
+  :init-value nil
+  (if ace-window-posframe-mode
+      (ace-window-posframe-enable)
+    (ace-window-posframe-disable)))
+
+(provide 'ace-window-posframe)
diff --git a/ace-window.el b/ace-window.el
index 3c99ccdddf..6657f3a5b4 100644
--- a/ace-window.el
+++ b/ace-window.el
@@ -407,6 +407,15 @@ LEAF is (PT . WND)."
         (overlay-put ol 'window wnd)
         (push ol avy--overlays-lead)))))
 
+(defvar aw--lead-overlay-fn #'aw--lead-overlay
+  "Function used to display the lead chars.")
+
+(defun aw--remove-leading-chars ()
+  (avy--remove-leading-chars))
+
+(defvar aw--remove-leading-chars-fn #'aw--remove-leading-chars
+  "Function used to cleanup lead chars.")
+
 (defun aw--make-backgrounds (wnd-list)
   "Create a dim background overlay for each window on WND-LIST."
   (when aw-background
@@ -571,8 +580,8 @@ Amend MODE-LINE to the mode line for the duration of the 
selection."
                                               (if (and ace-window-display-mode
                                                        (null 
aw-display-mode-overlay))
                                                   (lambda (_path _leaf))
-                                                #'aw--lead-overlay)
-                                              #'avy--remove-leading-chars)))
+                                                aw--lead-overlay-fn)
+                                              aw--remove-leading-chars-fn)))
                           (if (eq res 'exit)
                               (setq aw-action nil)
                             (or (cdr res)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]