|
65 | 65 | (require 'avy) |
66 | 66 | (require 'ring) |
67 | 67 | (require 'subr-x) |
| 68 | +(require 'posframe) |
68 | 69 |
|
69 | 70 | ;;* Customization |
70 | 71 | (defgroup ace-window nil |
@@ -407,6 +408,32 @@ LEAF is (PT . WND)." |
407 | 408 | (overlay-put ol 'window wnd) |
408 | 409 | (push ol avy--overlays-lead))))) |
409 | 410 |
|
| 411 | +(defvar aw--posframes-lead nil |
| 412 | + "List of posframe buffer names currently shown on screen") |
| 413 | + |
| 414 | +(defun aw--lead-posframe (path leaf) |
| 415 | + "Create a posframe using PATH at LEAF. |
| 416 | +LEAF is (PT . WND)." |
| 417 | + (let* ((wnd (cdr leaf)) |
| 418 | + (s (aw--overlay-str wnd (point-min) path)) |
| 419 | + (posframe-name (format "*avy-window %s*" s))) |
| 420 | + ;; Add a posframe to every window and it won't interfere with buffer contents. |
| 421 | + (push posframe-name aw--posframes-lead) |
| 422 | + (with-selected-window wnd |
| 423 | + (posframe-show posframe-name |
| 424 | + :string s |
| 425 | + ;; Show the hint in the center of each window. |
| 426 | + :poshandler 'posframe-poshandler-window-center |
| 427 | + :foreground-color (face-attribute 'aw-leading-char-face :foreground nil t) |
| 428 | + :override-parameters aw-posframe-parameters |
| 429 | + ;; :font "18" |
| 430 | + :font (face-font 'aw-leading-char-face) |
| 431 | + )))) |
| 432 | + |
| 433 | +(defun aw--remove-leading-posframes nil |
| 434 | + (mapc #'posframe-hide aw--posframes-lead) |
| 435 | + (setq aw--posframes-lead nil)) |
| 436 | + |
410 | 437 | (defun aw--make-backgrounds (wnd-list) |
411 | 438 | "Create a dim background overlay for each window on WND-LIST." |
412 | 439 | (when aw-background |
@@ -516,9 +543,15 @@ The new frame is set to the same size as the previous frame, offset by |
516 | 543 | (let ((avy-dispatch-alist)) |
517 | 544 | (avy-handler-default char))))))) |
518 | 545 |
|
519 | | -(defcustom aw-display-mode-overlay t |
520 | | - "When nil, don't display overlays. Rely on the mode line instead." |
521 | | - :type 'boolean) |
| 546 | +(defcustom aw-display-style 'overlay |
| 547 | + "Display ace-window navigation markers either as an overlay or posframe. When nil, rely on the mode line instead." |
| 548 | + :type '(choice (const :tag "Overlay" overlay) |
| 549 | + (const :tag "Child Frame" posframe) |
| 550 | + (const :tag "None" nil))) |
| 551 | + |
| 552 | +(defcustom aw-posframe-parameters nil |
| 553 | + "The frame parameters used when aw-display-style is 'posframe" |
| 554 | + :type 'string) |
522 | 555 |
|
523 | 556 | (defvar ace-window-display-mode) |
524 | 557 |
|
@@ -564,19 +597,23 @@ Amend MODE-LINE to the mode line for the duration of the selection." |
564 | 597 | ;; turn off helm transient map |
565 | 598 | (remove-hook 'post-command-hook 'helm--maybe-update-keymap) |
566 | 599 | (unwind-protect |
567 | | - (let* ((avy-handler-function aw-dispatch-function) |
568 | | - (avy-translate-char-function aw-translate-char-function) |
569 | | - (transient-mark-mode nil) |
570 | | - (res (avy-read (avy-tree candidate-list aw-keys) |
571 | | - (if (and ace-window-display-mode |
572 | | - (null aw-display-mode-overlay)) |
573 | | - (lambda (_path _leaf)) |
574 | | - #'aw--lead-overlay) |
575 | | - #'avy--remove-leading-chars))) |
576 | | - (if (eq res 'exit) |
577 | | - (setq aw-action nil) |
578 | | - (or (cdr res) |
579 | | - start-window))) |
| 600 | + (let* ((avy-handler-function aw-dispatch-function) |
| 601 | + (avy-translate-char-function aw-translate-char-function) |
| 602 | + (transient-mark-mode nil) |
| 603 | + (res (avy-read (avy-tree candidate-list aw-keys) |
| 604 | + (if (and ace-window-display-mode |
| 605 | + aw-display-style) |
| 606 | + (lambda (_path _leaf)) |
| 607 | + (pcase aw-display-style |
| 608 | + ('overlay #'aw--lead-overlay) |
| 609 | + ('posframe #'aw--lead-posframe))) |
| 610 | + (pcase aw-display-style |
| 611 | + ('overlay #'avy--remove-leading-chars) |
| 612 | + ('posframe #'aw--remove-leading-posframes))))) |
| 613 | + (if (eq res 'exit) |
| 614 | + (setq aw-action nil) |
| 615 | + (or (cdr res) |
| 616 | + start-window))) |
580 | 617 | (aw--done)))))) |
581 | 618 | (if aw-action |
582 | 619 | (funcall aw-action window) |
@@ -954,3 +991,8 @@ window list." |
954 | 991 | (provide 'ace-window) |
955 | 992 |
|
956 | 993 | ;;; ace-window.el ends here |
| 994 | + |
| 995 | + |
| 996 | + |
| 997 | +;; from https://github.com/loafofpiecrust/ace-window/tree/posframe |
| 998 | +;; https://github.com/abo-abo/ace-window/pull/204 |
0 commit comments