Function: ghostel--kitty-display-virtual
ghostel--kitty-display-virtual is a natively compiled function defined
in ghostel-kitty.el.
Signature
(ghostel--kitty-display-virtual DATA ROW-UP NTH IMG-ROW IMG-COL WIDTH GRID-COLS GRID-ROWS)
Documentation
Display one placeholder run of a virtual kitty placement.
DATA is a unibyte PPM string. ROW-UP is the run's row counted up from the last screen row (0 = last row); its first cell is the NTH (0-based) U+10EEEE placeholder on that row. IMG-ROW and IMG-COL are the image cell it starts at, WIDTH its length in cells, GRID-COLS and GRID-ROWS the whole image. Cells are located by counting placeholders, since their combining diacritics make buffer width differ from cell width.
Source Code
;; Defined in /nix/store/1252krff0gb2kisjcpp45m50cpdskfrl-emacs-packages-deps/share/emacs/site-lisp/ghostel-kitty.el
(defun ghostel--kitty-display-virtual (data row-up nth img-row img-col
width grid-cols grid-rows)
"Display one placeholder run of a virtual kitty placement.
DATA is a unibyte PPM string. ROW-UP is the run's row counted up from
the last screen row (0 = last row); its first cell is the NTH (0-based)
U+10EEEE placeholder on that row. IMG-ROW and IMG-COL are the image
cell it starts at, WIDTH its length in cells, GRID-COLS and GRID-ROWS
the whole image. Cells are located by counting placeholders, since
their combining diacritics make buffer width differ from cell width."
(when (display-graphic-p)
(condition-case err
(let* ((cw (default-font-width))
(ch (default-font-height))
(img (create-image data 'pbm t
:width (* grid-cols cw)
:height (* grid-rows ch)
:scale 1
:ascent 'center)))
(save-excursion
;; The last screen row is the line before the final newline.
(goto-char (point-max))
(let ((ph (string #x10EEEE)))
(when (and (zerop (forward-line (- (1+ row-up))))
(search-forward ph (line-end-position) t (1+ nth)))
(let ((start (1- (point)))
(eol (line-end-position)))
(when (or (= width 1)
(search-forward ph eol t (1- width)))
(while (and (< (point) eol)
(eq (get-char-code-property
(char-after) 'general-category)
'Mn))
(forward-char))
(add-text-properties
start (point)
(list 'display (list (list 'slice (* img-col cw) (* img-row ch)
(* width cw) ch)
img)
'ghostel-kitty t))
;; Clamp the line to `ch' so the slice tiles flush; the
;; placeholder fallback font would otherwise grow the line.
(add-text-properties eol (1+ eol)
(list 'line-height ch
'ghostel-kitty t))
(setq ghostel--kitty-active t)))))))
(error
(setq ghostel--kitty-last-error err)
(message "ghostel: kitty virtual image error: %S" err)))))