Function: corfu--popup-show
corfu--popup-show is a byte-compiled function defined in corfu.el.
Signature
(corfu--popup-show POS OFF WIDTH LINES &optional CURR LO BAR)
Documentation
Show LINES as popup at POS - OFF.
WIDTH is the width of the popup. The current candidate CURR is highlighted. A scroll bar is displayed from LO to LO+BAR.
Implementations
:around (corfu--popup-show POS OFF WIDTH LINES (ARG4 ((&context . corfu-mouse-mode) eql t)) &rest ARGS) in `corfu-mouse.el'.
Undocumented
(corfu--popup-show POS OFF WIDTH LINES &optional CURR LO BAR) in `corfu.el'.
Undocumented
Source Code
;; Defined in ~/.emacs.d/elpa/corfu-20260813.950/corfu.el
(cl-defgeneric corfu--popup-show (pos off width lines &optional curr lo bar)
"Show LINES as popup at POS - OFF.
WIDTH is the width of the popup.
The current candidate CURR is highlighted.
A scroll bar is displayed from LO to LO+BAR."
(let ((lh (max (default-line-height) (cdr (posn-object-width-height pos)))))
(with-current-buffer (corfu--make-buffer " *corfu*")
(let* ((ch (default-line-height))
(cw (default-font-width))
;; bug#74214, bug#37755, bug#37689: Even for larger fringes, fringe
;; bitmaps can only have a width between 1 and 16. Therefore we
;; restrict the fringe width to 16 pixel. This restriction may
;; cause problem on HDPi systems. Hopefully Emacs will adopt
;; larger fringe bitmaps in the future and lift the restriction.
(ml (min 16 (ceiling (* cw corfu-left-margin-width))))
(mr (min 16 (ceiling (* cw corfu-right-margin-width))))
(bw (min mr (ceiling (* cw corfu-bar-width))))
(graphic (display-graphic-p))
(marginl (and (not graphic) (propertize " " 'display `(space :width (,ml)))))
(sbar (if graphic
#(" " 0 1 (display (right-fringe corfu--bar corfu--bar)))
(concat
(propertize " " 'display `(space :align-to (- right (,bw))))
(propertize " " 'face 'corfu-bar 'display `(space :width (,bw))))))
(cbar (if graphic
#(" " 0 1 (display (left-fringe corfu--nil corfu-current))
1 2 (display (right-fringe corfu--bar corfu--cbar)))
sbar))
(cmargin (and graphic
#(" " 0 1 (display (left-fringe corfu--nil corfu-current))
1 2 (display (right-fringe corfu--nil corfu-current)))))
(pos (posn-x-y pos))
(width (+ (* width cw) (if graphic 0 (+ ml mr))))
;; XXX HACK: Minimum popup height must be at least 1 line of the
;; parent frame (gh:minad/corfu#261).
(height (max lh (* (length lines) ch)))
(edge (window-inside-pixel-edges))
(border (if graphic corfu-border-width 0))
(x (max 0 (min (+ (car edge) (- (or (car pos) 0) ml (* cw off) border))
(- (frame-pixel-width) width
(if graphic (+ ml mr (* 2 border)) 0)))))
(yb (+ (cadr edge) (or (cdr pos) 0) lh
(static-if (< emacs-major-version 31) (window-tab-line-height) 0)))
(y (if (> (+ yb (* corfu-count ch) lh lh) (frame-pixel-height))
(- yb height lh border border)
yb))
(bmp (logxor (1- (ash 1 mr)) (1- (ash 1 bw)))))
(setq left-fringe-width (if graphic ml 0) right-fringe-width (if graphic mr 0))
;; Define an inverted corfu--bar face
(unless (equal (and (facep 'corfu--bar) (face-attribute 'corfu--bar :foreground))
(face-attribute 'corfu-bar :background))
(set-face-attribute (make-face 'corfu--bar) nil
:foreground (face-attribute 'corfu-bar :background)))
(unless (or (= right-fringe-width 0) (eq (get 'corfu--bar 'corfu--bmp) bmp))
(put 'corfu--bar 'corfu--bmp bmp)
(define-fringe-bitmap 'corfu--bar (vector (lognot bmp)) 1 mr '(top periodic))
(define-fringe-bitmap 'corfu--nil [0] 1 1)
;; Fringe bitmaps require symbol face specification, define internal face.
(set-face-attribute (make-face 'corfu--cbar) nil
:inherit '(corfu--bar corfu-current)))
(with-silent-modifications
(delete-region (point-min) (point-max))
(apply #'insert
(cl-loop for row from 0 for line in lines collect
(let ((str (concat marginl line
(if (and lo (<= lo row (+ lo bar)))
(if (eq row curr) cbar sbar)
(and (eq row curr) cmargin))
"\n")))
(when (eq row curr)
(add-face-text-property
0 (length str) 'corfu-current 'append str))
str)))
(goto-char (point-min)))
(setq corfu--frame (corfu--make-frame corfu--frame x y width height))))))