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 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 row)))
39 (push (make-vector 6 nil) row))
40 (let ((sixel (elt row (- (length row) 1 index))))
41 (sixel-tag-bits sixel (- char 63) tag))
44 (defun sixel-process-data (string)
45 "Convert STRING into a list of lists representing individual sixels."
48 (goto-char (point-min))
51 current-colour colour-map
55 ((looking-at "#\\([0-9]+\\);\\([0-9]+\\);\\([0-9]+\\);\\([0-9]+\\);\\([0-9]+\\)")
56 (let ((tag (intern (match-string 1)))
57 (mode (match-string 2))
58 (r (string-to-number (match-string 3)))
59 (g (string-to-number (match-string 4)))
60 (b (string-to-number (match-string 5))))
61 (push (list tag r g b) colour-map)))
63 ((looking-at "#\\([0-9]+\\)")
64 (let ((tag (intern (match-string 1))))
65 (setq current-colour tag)))
71 (push (reverse this-row) rows)
75 ((looking-at "!\\([0-9]+\\)\\([?-~]\\)")
76 (let ((repeat-count (string-to-number (match-string 1)))
77 (char (elt (match-string 2) 0)))
78 (dotimes (i repeat-count)
80 (sixel-tag-sixel-in-row this-row idx-out char current-colour))
81 (setq idx-out (1+ idx-out)))))
83 ((looking-at "\\([?-~]\\)")
84 (let ((char (elt (match-string 1) 0)))
86 (sixel-tag-sixel-in-row this-row idx-out char current-colour))
87 (setq idx-out (1+ idx-out))))
89 (t (setq finished t)))
91 (goto-char (match-end 0)))
92 (push (reverse this-row) rows)