The Lambda Lab
/
projects
/
sixel.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
0b50b88
)
Initial string processing function seems to work.
author
Tim Vaughan
<tgvaughan@gmail.com>
Sun, 19 May 2019 20:24:07 +0000
(22:24 +0200)
committer
Tim Vaughan
<tgvaughan@gmail.com>
Sun, 19 May 2019 20:24:07 +0000
(22:24 +0200)
sixel.el
patch
|
blob
|
history
diff --git
a/sixel.el
b/sixel.el
index
958a456
..
2539356
100644
(file)
--- a/
sixel.el
+++ b/
sixel.el
@@
-31,17
+31,18
@@
(aset sixel i tag))
(setq n (/ n 2))))
(aset sixel i tag))
(setq n (/ n 2))))
-(defun sixel-tag-sixel-in-row (row
-variable
index char tag)
+(defun sixel-tag-sixel-in-row (row index char tag)
"Tag the bits of the sixel at INDEX in the list identified by
the variable ROW-VARIABLE corresponding to input character CHAR
with TAG."
"Tag the bits of the sixel at INDEX in the list identified by
the variable ROW-VARIABLE corresponding to input character CHAR
with TAG."
- (while (not (< index (length (symbol-value row-variable))))
- (add-to-list row-variable (make-vector 6 nil)))
- (let ((sixel (elt (symbol-value row-variable) index)))
- (sixel-tag-bits sixel (- char 63) tag)))
+ (while (not (< index (length row)))
+ (push (make-vector 6 nil) row))
+ (let ((sixel (elt row (- (length row) 1 index))))
+ (sixel-tag-bits sixel (- char 63) tag))
+ row)
(defun sixel-process-data (string)
(defun sixel-process-data (string)
- "Convert
sixel string
into a list of lists representing individual sixels."
+ "Convert
STRING
into a list of lists representing individual sixels."
(with-temp-buffer
(insert string)
(goto-char (point-min))
(with-temp-buffer
(insert string)
(goto-char (point-min))
@@
-63,28
+64,30
@@
with TAG."
(let ((tag (intern (match-string 1))))
(setq current-colour tag)))
(let ((tag (intern (match-string 1))))
(setq current-colour tag)))
- ((looking-at "$")
+ ((looking-at "
\\
$")
(setq idx-out 0))
(setq idx-out 0))
- ((looking-at "
^
-")
- (push
this-row '
rows)
+ ((looking-at "-")
+ (push
(reverse this-row)
rows)
(setq this-row nil)
(setq idx-out 0))
(setq this-row nil)
(setq idx-out 0))
- ((looking-at "
^
!\\([0-9]+\\)\\([?-~]\\)")
+ ((looking-at "!\\([0-9]+\\)\\([?-~]\\)")
(let ((repeat-count (string-to-number (match-string 1)))
(char (elt (match-string 2) 0)))
(dotimes (i repeat-count)
(let ((repeat-count (string-to-number (match-string 1)))
(char (elt (match-string 2) 0)))
(dotimes (i repeat-count)
- (sixel-tag-sixel-in-row 'result idx-out char current-colour))))
+ (setq this-row
+ (sixel-tag-sixel-in-row this-row idx-out char current-colour))
+ (setq idx-out (1+ idx-out)))))
- ((looking-at "
^
\\([?-~]\\)")
+ ((looking-at "\\([?-~]\\)")
(let ((char (elt (match-string 1) 0)))
(let ((char (elt (match-string 1) 0)))
- (sixel-tag-sixel-in-row 'result idx-out char current-colour)))
+ (setq this-row
+ (sixel-tag-sixel-in-row this-row idx-out char current-colour))
+ (setq idx-out (1+ idx-out))))
- ((= (point) (point-max))
- (setq finished t))
-
- (t (error "Invalid characters found in input string.")))
+ (t (setq finished t)))
(goto-char (match-end 0)))
(goto-char (match-end 0)))
- (push this-row 'rows))))
+ (push (reverse this-row) rows)
+ (reverse rows))))