[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/corfu-doc d051b8e0b1 23/95: Place doc frame at top or b
From: |
ELPA Syncer |
Subject: |
[elpa] externals/corfu-doc d051b8e0b1 23/95: Place doc frame at top or bottom of the completion popup frame |
Date: |
Tue, 19 Jul 2022 15:58:01 -0400 (EDT) |
branch: externals/corfu-doc
commit d051b8e0b173b3f9e9c1620be9022dbf122a29cf
Author: Yuwei Tian <ibluefocus@outlook.com>
Commit: Yuwei Tian <ibluefocus@outlook.com>
Place doc frame at top or bottom of the completion popup frame
---
corfu-doc.el | 70 ++++++++++++++++++++++++++++++++++++++----------------------
1 file changed, 45 insertions(+), 25 deletions(-)
diff --git a/corfu-doc.el b/corfu-doc.el
index bd4d4575b2..dce9c60633 100644
--- a/corfu-doc.el
+++ b/corfu-doc.el
@@ -210,6 +210,7 @@ If this is nil, do not resize corfu doc frame
automatically."
(cf-frame-x (car cf-frame--pos)) ;; corfu--frame x pos
(cf-frame-y (cdr cf-frame--pos))
(cf-frame-width (frame-pixel-width corfu--frame))
+ (cf-frame-height (frame-pixel-height corfu--frame))
(cf-parent-frame-x ;; corfu parent frame x pos
;; Get inner frame left top edge for corfu frame's parent frame
;; See "(elisp) Frame Layout" in Emacs manual
@@ -217,11 +218,11 @@ If this is nil, do not resize corfu doc frame
automatically."
(cf-parent-frame-width (frame-pixel-width cf-parent-frame))
(cf-doc-frame-width
(if (not corfu-doc-resize-frame)
- ;; left border + left margin + inner width + right margin +
right-border
- (+ 1
- (alist-get 'left-fringe corfu-doc--frame-parameters 0)
- (* (frame-char-width) corfu-doc-max-width)
- (alist-get 'right-fringe corfu-doc--frame-parameters 0)
+ ;; left border + left margin + inner width + right margin +
right-border
+ (+ 1
+ (alist-get 'left-fringe corfu-doc--frame-parameters 0)
+ (* (frame-char-width) corfu-doc-max-width)
+ (alist-get 'right-fringe corfu-doc--frame-parameters 0)
1)
(fit-frame-to-buffer corfu-doc--frame
corfu-doc-max-height nil
@@ -246,26 +247,45 @@ If this is nil, do not resize corfu doc frame
automatically."
cf-parent-frame-rel-x)))
(display-space-left (- (+ cf-frame-x cf-parent-frame-rel-x)
space)))
- (setq x (or
- (and (> cf-doc-frame-width display-space-right)
- (> display-space-left cf-doc-frame-width)
- ;; space that right edge of the DOC-FRAME
- ;; to the right edge of the parent frame
- ;; calculation:
- ;; (- (+ cf-frame-x cf-parent-frame-x)
- ;; space
- ;; (+ cf-parent-frame-x cf-parent-frame-width))
- (- cf-frame-x space cf-parent-frame-width))
- (let* ((x-on-left-side-of-cp-frame
- (- cf-frame-x space cf-doc-frame-width)))
- (or
- ;; still positioned in completion frame's parent frame
- (and (> x-on-left-side-of-cp-frame 0)
- ;; and x point is visible in display
- (> (+ x-on-left-side-of-cp-frame cf-parent-frame-x) 0)
- x-on-left-side-of-cp-frame)
- (+ cf-frame-x cf-frame-width space))))
- y cf-frame-y)
+ (let ((_x-on-left-side-of-cf-frame
+ (- cf-frame-x space cf-doc-frame-width))
+ (x-on-right-side-of-cf-frame
+ (+ cf-frame-x cf-frame-width space)))
+ (cond
+ ((> display-space-right cf-doc-frame-width)
+ (setq x x-on-right-side-of-cf-frame
+ y cf-frame-y))
+ ((and (< display-space-right cf-doc-frame-width)
+ (> display-space-left cf-doc-frame-width))
+ (setq x
+ ;; space that right edge of the DOC-FRAME
+ ;; to the right edge of the parent frame
+ ;; calculation:
+ ;; (- (+ cf-frame-x cf-parent-frame-x)
+ ;; space
+ ;; (+ cf-parent-frame-x cf-parent-frame-width))
+ (- cf-frame-x space cf-parent-frame-width)
+ y cf-frame-y))
+ (t
+ (setq x cf-frame-x)
+ (let* ((beg (+ (nth 0 completion-in-region--data)
+ corfu--base))
+ (cf-frame-y-b
+ (+ (cadr (window-inside-pixel-edges))
+ (window-tab-line-height)
+ (or (cdr (posn-x-y (posn-at-point beg))) 0)
+ (default-line-height)))
+ (y-on-top-side-of-cf-frame
+ (- cf-frame-y space cf-doc-frame-height))
+ (y-on-bottom-side-of-cf-frame
+ (+ cf-frame-y cf-frame-height space)))
+ (cond
+ ((> cf-frame-y-b cf-frame-y)
+ (setq y (max 1 y-on-top-side-of-cf-frame))
+ (if (< y-on-top-side-of-cf-frame 0)
+ (setq cf-doc-frame-height
+ (- cf-frame-y y 1 1 space))))
+ (t (setq y y-on-bottom-side-of-cf-frame)))))))
(list x y cf-doc-frame-width cf-doc-frame-height)))
(defun corfu-doc--show ()
- [elpa] externals/corfu-doc c6b54c923e 14/95: Add command to quickly toggle documentation popup on or off, (continued)
- [elpa] externals/corfu-doc c6b54c923e 14/95: Add command to quickly toggle documentation popup on or off, ELPA Syncer, 2022/07/19
- [elpa] externals/corfu-doc 98398c61fa 15/95: Fix wrong argument type error when calling frame-visible-p, ELPA Syncer, 2022/07/19
- [elpa] externals/corfu-doc e18aea61e7 10/95: Version 0.0.3, ELPA Syncer, 2022/07/19
- [elpa] externals/corfu-doc 98509cbe29 44/95: Decrease auto delay to 0.1, ELPA Syncer, 2022/07/19
- [elpa] externals/corfu-doc 0741012875 26/95: Fix typo in comment, ELPA Syncer, 2022/07/19
- [elpa] externals/corfu-doc 8c30a44d67 41/95: Fix #7: change the behavior of the corfu-doc-toggle command, ELPA Syncer, 2022/07/19
- [elpa] externals/corfu-doc f83307a233 09/95: Update doc frame when corfu frame coordinates changed, ELPA Syncer, 2022/07/19
- [elpa] externals/corfu-doc 488da67753 13/95: Revert previous commit, ELPA Syncer, 2022/07/19
- [elpa] externals/corfu-doc ef1edadb4f 29/95: README: Document `corfu-doc-delay`, ELPA Syncer, 2022/07/19
- [elpa] externals/corfu-doc 5d08342a82 28/95: Fix #6: do not show the documentation popup immediately, ELPA Syncer, 2022/07/19
- [elpa] externals/corfu-doc d051b8e0b1 23/95: Place doc frame at top or bottom of the completion popup frame,
ELPA Syncer <=
- [elpa] externals/corfu-doc 7926ff406c 47/95: Avoid using map-merge, ELPA Syncer, 2022/07/19
- [elpa] externals/corfu-doc a8835a6540 43/95: Version 0.4.0, ELPA Syncer, 2022/07/19
- [elpa] externals/corfu-doc 75faa58328 21/95: Version 0.0.5, ELPA Syncer, 2022/07/19
- [elpa] externals/corfu-doc d7d7c27703 70/95: Version 0.6.2, ELPA Syncer, 2022/07/19
- [elpa] externals/corfu-doc d5224ad109 30/95: Decrease popup displaying delay to 0.2 seconds, ELPA Syncer, 2022/07/19
- [elpa] externals/corfu-doc 4ff6f35c18 64/95: Fix #12: make the popup functions more overrideable, ELPA Syncer, 2022/07/19
- [elpa] externals/corfu-doc 95a1a1731d 51/95: Add contributions note, ELPA Syncer, 2022/07/19
- [elpa] externals/corfu-doc 122e1f5900 32/95: Only record candidate that has displayed the doc popup, ELPA Syncer, 2022/07/19
- [elpa] externals/corfu-doc 1c99932d33 57/95: Support displaying the doc frame within the parent frame, ELPA Syncer, 2022/07/19
- [elpa] externals/corfu-doc 6706526c0d 72/95: Require emacs 27.1, ELPA Syncer, 2022/07/19