Skip to content

Commit

Permalink
Indenting-output-stream now uses stream-write-string rather than stre…
Browse files Browse the repository at this point in the history
…am-write-char.
  • Loading branch information
Andy Hefner committed Apr 15, 2003
1 parent 5231dbd commit eca9fbf
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions text-formatting.lisp
Expand Up @@ -133,6 +133,22 @@ SUPPRESS-SPACE-AFTER-CONJUNCTION are non-standard."
(stream-increment-cursor-position under-stream (indentation stream) nil))
(call-next-method)))

(defmethod stream-write-string :around ((stream indenting-output-stream)
string &optional (start 0) end)
(let ((under-stream (encapsulating-stream-stream stream))
(end (or end (length string))))
(flet ((foo (start end)
(when (stream-start-line-p under-stream)
(stream-increment-cursor-position under-stream (indentation stream) nil))
(stream-write-string under-stream string start end)))
(let ((seg-start start))
(loop for i from start below end do
(when (char= #\Newline
(char string i))
(foo seg-start (1+ i))
(setq seg-start (1+ i))))
(foo seg-start end)))))

(defmethod stream-write-string :around ((stream indenting-output-stream)
string &optional (start 0) end)
(loop for i from start below end
Expand Down

0 comments on commit eca9fbf

Please sign in to comment.