- (sixel-image (sixel-process-data data-string)))
- (concat
- "/* XPM */"
- "static char * pixmap = {"
- (sixel-image-to-xpm-values sixel-image) ",\n"
- (sixel-image-to-xpm-colours sixel-image)
- ;; (sixel-data-to-XPM-pixels data)
- "};")))
-
-
-
-;; sixel.el ends here
+ (sixel-image (sixel-pad-rows (sixel-process-data data-string))))
+ (if (string-prefix-p "\eP" string)
+ (concat
+ "/* XPM */"
+ "static char * pixmap[] = {"
+ (sixel-image-to-xpm-values sixel-image) ",\n"
+ (sixel-image-to-xpm-colours sixel-image) ",\n"
+ (sixel-image-to-xpm-pixels sixel-image) "};")
+ (error "Incorrecly formatted sixel string"))))
+
+(defun sixel-render-images-in-buffer ()
+ "Find and render any sixel images in the current buffer."
+ (interactive)
+ (save-excursion
+ (goto-char (point-min))
+ (while (re-search-forward "\eP[[:ascii:]]*\e\\\\" nil t)
+ (let ((sixel-string (match-string 0))
+ (inhibit-read-only t))
+ (delete-region (match-beginning 0)
+ (match-end 0))
+ (insert-image
+ (create-image (sixel-to-xpm sixel-string) 'xpm t))
+ (insert "\n")))))
+
+;;; sixel.el ends here