Something went wrong. Try again.
Something went wrong. Try again.
819 B · 37 lines
at testing
1234567891011121314151617181920212223242526272829303132333435363738(defpackage :rex-md.sbuff (:use :cl))
(defclass sbuff () ((text :reader sbuff-text :initarg :text :type string :initform (error "text required") :documentation "hold the full text of the text buffer") (idx :reader sbuff-idx :initarg :idx :initform -1 :type integer :documentation "current index of the buffer")))
(defun limit (buf) (length (slot-value buf 'text)))
(defmethod next (buf) (with-slots (text idx) buf (unless (>= idx (- (limit buf) 1)) (incf idx) (char text idx))))
;;; TESTING (format t "hello world");
(defparameter *mybuff* (make-instance 'sbuff :text "bob"))(next *mybuff*)(format t "~a~%" (limit *mubuff*))
(loop for chr = (next *mybuff*) then (next *mybuff*) while (not (null chr)) do (format t "~a~%" chr))