Every now and then I need to live with an ugly kludge.
-
Every now and then I need to live with an ugly kludge.
(defmacro with-tentative-fresh-line ((stream cursor) &body body)
(check-type stream symbol)
(check-type cursor symbol)
(with-gensyms (prev-x prev-y old-x old-y new-x new-y)
`(multiple-value-bind (,prev-x ,prev-y) (cursor-position ,cursor)
(fresh-line ,stream)
(multiple-value-bind (,old-x ,old-y) (cursor-position ,cursor)
(multiple-value-prog1 (progn ,@body)
(multiple-value-bind (,new-x ,new-y) (cursor-position ,cursor)
(if (and (= ,old-x ,new-x) (= ,old-y ,new-y))
(setf (cursor-position ,cursor)
(values ,prev-x ,prev-y))
(fresh-line ,stream))))))))Quiz: what's the purpose of this macro?
-
Every now and then I need to live with an ugly kludge.
(defmacro with-tentative-fresh-line ((stream cursor) &body body)
(check-type stream symbol)
(check-type cursor symbol)
(with-gensyms (prev-x prev-y old-x old-y new-x new-y)
`(multiple-value-bind (,prev-x ,prev-y) (cursor-position ,cursor)
(fresh-line ,stream)
(multiple-value-bind (,old-x ,old-y) (cursor-position ,cursor)
(multiple-value-prog1 (progn ,@body)
(multiple-value-bind (,new-x ,new-y) (cursor-position ,cursor)
(if (and (= ,old-x ,new-x) (= ,old-y ,new-y))
(setf (cursor-position ,cursor)
(values ,prev-x ,prev-y))
(fresh-line ,stream))))))))Quiz: what's the purpose of this macro?
@jackdaniel Does it work similarly to the
~&direcctive offormat?