Show the overlay in the bottom of the window too

This is useful when point overlaps the overlay at the top of the
window, making it difficult to read the label.

Fixes #129.
Fixes #132.
old-master
Wilfred Hughes 8 years ago committed by Oleh Krehel
parent d4066b1de0
commit 702bc2767a
  1. 62
      ace-window.el

@ -138,6 +138,13 @@ Its value is a (width . height) pair in pixels or nil for the default frame size
(0 . 0) is special and means make the frame size the same as the last selected frame size." (0 . 0) is special and means make the frame size the same as the last selected frame size."
:type '(cons integer integer)) :type '(cons integer integer))
(defcustom aw-char-position 'top-left
"Window positions of the character overlay.
Consider changing this if the overlay tends to overlap with other things."
:type '(choice
(const :tag "top left corner only" 'top-left)
(const :tag "both left corners" 'left)))
;; Must be defined before `aw-make-frame-char' since its :set function references this. ;; Must be defined before `aw-make-frame-char' since its :set function references this.
(defvar aw-dispatch-alist (defvar aw-dispatch-alist
'((?x aw-delete-window "Delete Window") '((?x aw-delete-window "Delete Window")
@ -264,23 +271,14 @@ Modify them back eventually.")
(delete-region (point-min) (point-max)))))) (delete-region (point-min) (point-max))))))
(setq aw-empty-buffers-list nil)) (setq aw-empty-buffers-list nil))
(defun aw--lead-overlay (path leaf) (defun aw--overlay-str (wnd pos path)
"Create an overlay using PATH at LEAF. "Return the replacement text for an overlay in WND at POS,
LEAF is (PT . WND)." accessible by typing PATH."
(let ((wnd (cdr leaf))) (let ((old-str (or
(with-selected-window wnd
(when (= 0 (buffer-size))
(push (current-buffer) aw-empty-buffers-list)
(let ((inhibit-read-only t))
(insert " ")))
(let* ((pt (car leaf))
(ol (make-overlay pt (1+ pt) (window-buffer wnd)))
(old-str (or
(ignore-errors (ignore-errors
(with-selected-window wnd (with-selected-window wnd
(buffer-substring pt (1+ pt)))) (buffer-substring pos (1+ pos))))
"")) "")))
(new-str
(concat (concat
(cl-case aw-leading-char-style (cl-case aw-leading-char-style
(char (char
@ -301,10 +299,40 @@ LEAF is (PT . WND)."
(make-string (make-string
(max 0 (1- (string-width old-str))) (max 0 (1- (string-width old-str)))
?\ )))))) ?\ ))))))
(defun aw--lead-overlay (path leaf)
"Create an overlay using PATH at LEAF.
LEAF is (PT . WND)."
(let ((wnd (cdr leaf)))
(with-selected-window wnd
(when (= 0 (buffer-size))
(push (current-buffer) aw-empty-buffers-list)
(let ((inhibit-read-only t))
(insert " ")))
(let* ((pt (car leaf))
(ol (make-overlay pt (1+ pt) (window-buffer wnd))))
(overlay-put ol 'display (aw--overlay-str wnd pt path))
(overlay-put ol 'face 'aw-leading-char-face)
(overlay-put ol 'window wnd)
(push ol avy--overlays-lead))
(when (eq aw-char-position 'left)
(let* ((pt
(save-excursion
;; Move to the start of the last visible line in the buffer.
(move-to-window-line -1)
(move-beginning-of-line nil)
;; If this line is empty, use the previous line so we
;; have space for the overlay.
(when (equal (point) (point-max))
(previous-line))
(point)))
(ol (make-overlay pt (1+ pt) (window-buffer wnd))))
(overlay-put ol 'display (aw--overlay-str wnd pt path))
(overlay-put ol 'face 'aw-leading-char-face) (overlay-put ol 'face 'aw-leading-char-face)
(overlay-put ol 'window wnd) (overlay-put ol 'window wnd)
(overlay-put ol 'display new-str) (push ol avy--overlays-lead))))))
(push ol avy--overlays-lead)))))
(defun aw--make-backgrounds (wnd-list) (defun aw--make-backgrounds (wnd-list)
"Create a dim background overlay for each window on WND-LIST." "Create a dim background overlay for each window on WND-LIST."

Loading…
Cancel
Save