Size limit and protect edges in history
This commit is contained in:
parent
a38aaa64c9
commit
2de6c9c403
16
origami.el
16
origami.el
@ -273,30 +273,30 @@ with the current state and the current node at each iteration."
|
|||||||
|
|
||||||
;;; linear history structure
|
;;; linear history structure
|
||||||
|
|
||||||
;;; TODO: size-limiting of past and future
|
|
||||||
;;; TODO: check for nils
|
|
||||||
|
|
||||||
(defun origami-h-new (present)
|
(defun origami-h-new (present)
|
||||||
"Create a new history structure."
|
"Create a new history structure."
|
||||||
(vector nil present nil))
|
(vector nil present nil))
|
||||||
|
|
||||||
(defun origami-h-push (h new)
|
(defun origami-h-push (h new)
|
||||||
"Create a new history structure with new as the present value."
|
"Create a new history structure with new as the present value."
|
||||||
(let ((past (aref h 0))
|
(when new
|
||||||
(present (aref h 1)))
|
(let ((past (aref h 0))
|
||||||
(vector (cons present past) new nil)))
|
(present (aref h 1)))
|
||||||
|
(vector (cons present (-take 19 past)) new nil))))
|
||||||
|
|
||||||
(defun origami-h-undo (h)
|
(defun origami-h-undo (h)
|
||||||
(let ((past (aref h 0))
|
(let ((past (aref h 0))
|
||||||
(present (aref h 1))
|
(present (aref h 1))
|
||||||
(future (aref h 2)))
|
(future (aref h 2)))
|
||||||
(vector (cdr past) (car past) (cons present future))))
|
(if (null past) h
|
||||||
|
(vector (cdr past) (car past) (cons present future)))))
|
||||||
|
|
||||||
(defun origami-h-redo (h)
|
(defun origami-h-redo (h)
|
||||||
(let ((past (aref h 0))
|
(let ((past (aref h 0))
|
||||||
(present (aref h 1))
|
(present (aref h 1))
|
||||||
(future (aref h 2)))
|
(future (aref h 2)))
|
||||||
(vector (cons present past) (car future) (cdr future))))
|
(if (null future) h
|
||||||
|
(vector (cons present past) (car future) (cdr future)))))
|
||||||
|
|
||||||
(defun origami-h-present (h)
|
(defun origami-h-present (h)
|
||||||
(when h (aref h 1)))
|
(when h (aref h 1)))
|
||||||
|
Loading…
Reference in New Issue
Block a user