emacs-framebuffer

Emacs library to show images and documents in console using Linux framebuffer
Log | Files | Refs

commit cbb6544cebcc6a74502c0a0c26a754a909e52fdb
parent 40b79bd3cf6f3325d995624e296327250f105ef9
Author: Tomas Hlavaty <tom@logand.com>
Date:   Sun, 11 Sep 2022 17:50:11 +0200

factor out framebuffer-w3mimgdisplay

Diffstat:
Memacs-framebuffer.el | 45++++++++++++++++++++++++---------------------
1 file changed, 24 insertions(+), 21 deletions(-)

diff --git a/emacs-framebuffer.el b/emacs-framebuffer.el @@ -211,6 +211,29 @@ (framebuffer-file-exists-p "/usr/lib/w3m/w3mimgdisplay") ;; debian10 "w3mimgdisplay")) +(defun framebuffer-w3mimgdisplay (x y w h sx sy sw sh file) + (with-temp-buffer + (insert (format "0;1;%d;%d;%d;%d;%s;%s;%s;%s;%s\n" x y w h + (or sx "") (or sy "") (or sw "") (or sh "") + (expand-file-name file))) + (let ((z (call-process-region (point-min) + (point-max) + (framebuffer-w3mimgdisplay-program)))) + (unless (zerop z) + (if (getenv "W3M_TTY") + (error "w3mimgdisplay failed with code %d" z) + (let ((tty (framebuffer-tty))) + (cond + (tty + (setenv "W3M_TTY" tty) + (let ((z (call-process-region (point-min) + (point-max) + (framebuffer-w3mimgdisplay-program)))) + (unless (zerop z) + (error "w3mimgdisplay failed with code %d, try setting W3M_TTY=$(tty)" z)))) + (t + (error "w3mimgdisplay failed with code %d, try setting W3M_TTY=$(tty)" z))))))))) + (defun framebuffer-draw (x y w h sx sy sw sh file) (setq file (framebuffer-cache-remote file)) (let ((format (framebuffer-file-format file))) @@ -224,27 +247,7 @@ (setq file (framebuffer-cache-pdf-to-png file framebuffer-image-mode-current-page)))) - (with-temp-buffer - (insert (format "0;1;%d;%d;%d;%d;%s;%s;%s;%s;%s\n" x y w h - (or sx "") (or sy "") (or sw "") (or sh "") - (expand-file-name file))) - (let ((z (call-process-region (point-min) - (point-max) - (framebuffer-w3mimgdisplay-program)))) - (unless (zerop z) - (if (getenv "W3M_TTY") - (error "w3mimgdisplay failed with code %d" z) - (let ((tty (framebuffer-tty))) - (cond - (tty - (setenv "W3M_TTY" tty) - (let ((z (call-process-region (point-min) - (point-max) - (framebuffer-w3mimgdisplay-program)))) - (unless (zerop z) - (error "w3mimgdisplay failed with code %d, try setting W3M_TTY=$(tty)" z)))) - (t - (error "w3mimgdisplay failed with code %d, try setting W3M_TTY=$(tty)" z))))))))) + (framebuffer-w3mimgdisplay x y w h sx sy sw sh file)) (defun framebuffer-buffer-brook () (lambda ()