Newer
Older
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
(defun indenting-out (stream char)
(let ((sub-stream (indenting-stream-stream stream)))
(funcall (stream-out sub-stream) sub-stream char)
(if (char= char #\newline)
(indenting-indent stream sub-stream))))
;;; Indenting-Sout writes a string to an indenting stream.
(defun indenting-sout (stream string start end)
(declare (simple-string string) (fixnum start end))
(do ((i start)
(sub-stream (indenting-stream-stream stream)))
((= i end))
(let ((newline (position #\newline string :start i :end end)))
(cond (newline
(funcall (stream-sout sub-stream) sub-stream string i (1+ newline))
(indenting-indent stream sub-stream)
(setq i (+ newline 1)))
(t
(funcall (stream-sout sub-stream) sub-stream string i end)
(setq i end))))))
;;; Indenting-Misc just treats just the :Line-Length message differently.
;;; Indenting-Charpos says the charpos is the charpos of the base stream minus
;;; the stream's indentation.
(defun indenting-misc (stream operation &optional arg1 arg2)
(let* ((sub-stream (indenting-stream-stream stream))
(method (stream-misc sub-stream)))
(case operation
(:line-length
(let ((line-length (funcall method sub-stream operation)))
(if line-length
(- line-length (indenting-stream-indentation stream)))))
(:charpos
(let* ((sub-stream (indenting-stream-stream stream))
(charpos (funcall method sub-stream operation)))
(if charpos
(- charpos (indenting-stream-indentation stream)))))
(t
(funcall method sub-stream operation arg1 arg2)))))
(proclaim '(notinline read-char unread-char read-byte listen))