3 "#0;2;0;0;0#1;2;100;100;0#2;2;0;100;0"
9 (defun sixel-get-params (string)
10 "Retrieve the sixel parameters."
11 (car (split-string string "q")))
13 (defun sixel-get-data (string)
14 "Retrieve data string."
15 (substring string (1+ (string-match "q" string))))
17 (defun sixel-compute-row-length (string)
24 (split-string substr "$"))))
25 (split-string string -))))
27 (defun sixel-tag-bits (sixel n tag)
28 "Set bits of SIXEL corresponding to N with to the value TAG."
34 (defun sixel-tag-sixel-in-row (row-variable index char tag)
35 "Tag the bits of the sixel at INDEX in the list identified by
36 the variable ROW-VARIABLE corresponding to input character CHAR
38 (while (not (< index (length (symbol-value row-variable))))
39 (add-to-list row-variable (make-vector 6 nil)))
40 (let ((sixel (elt (symbol-value row-variable) index)))
41 (sixel-tag-bits sixel (- char 63) tag)))
43 (defun sixel-process-data (string)
44 "Convert sixel string into a list of lists representing individual sixels."
47 (goto-char (point-min))
50 current-colour colour-map
54 ((looking-at "#\\([0-9]+\\);\\([0-9]+\\);\\([0-9]+\\);\\([0-9]+\\);\\([0-9]+\\)")
55 (let ((tag (intern (match-string 1)))
56 (mode (match-string 2))
57 (r (string-to-number (match-string 3)))
58 (g (string-to-number (match-string 4)))
59 (b (string-to-number (match-string 5))))
60 (push (list tag r g b) colour-map)))
62 ((looking-at "#\\([0-9]+\\)")
63 (let ((tag (intern (match-string 1 trunc-string))))
64 (setq current-colour tag)))
74 ((looking-at "^!\\([0-9]+\\)\\([?-~]\\)")
75 (let ((repeat-count (string-to-number (match-string 1)))
76 (char (elt (match-string 2 trunc-string) 0)))
77 (dotimes (i repeat-count)
78 (sixel-tag-sixel-in-row 'result idx-out char current-colour))))
80 ((looking-at "^\\([?-~]\\)")
81 (let ((char (elt (match-string 1 trunc-string) 0)))
82 (sixel-tag-sixel-in-row 'result idx-out char current-colour)))
84 ((= (point) (point-max))
87 (t (error "Invalid characters found in input string.")))
89 (goto-char (match-end 0)))
90 (push this-row 'rows))))