X-Git-Url: https://git.hcoop.net/clinton/lisp-on-lines.git/blobdiff_plain/a4232a83263192fdd2ca2f33f1947fe6747d3bc3..db4fe3430ee9cc4190222e915e32d809928f64cb:/src/slot-presentations.lisp diff --git a/src/slot-presentations.lisp b/src/slot-presentations.lisp index 7827c37..d7e874d 100644 --- a/src/slot-presentations.lisp +++ b/src/slot-presentations.lisp @@ -16,10 +16,24 @@ (defslot-presentation text-slot-presentation () ((rows :initarg :rows :accessor rows :initform 5) (columns :initarg :columns :accessor columns :initform 40) - (escape-html-p :initarg :escape-html-p :accessor escape-html-p :initform nil)) + (escape-html-p :initarg :escape-html-p :accessor escape-html-p :initform nil) + (convert-newlines-p :initarg :convert-newlines-p :accessor convert-newlines-p :initform nil)) (:type-name text)) (defmethod present-slot ((slot text-slot-presentation) instance) + (flet ((maybe-convert-newline-and-escape-html-then-print () + (let ((string (if (convert-newlines-p slot) + (with-output-to-string (new-string) + (with-input-from-string + (s (presentation-slot-value slot instance)) + (loop for line = (read-line s nil) + while line + do (format new-string "~A~A" line "
")))) + (presentation-slot-value slot instance)))) + (if (escape-html-p slot) + (<:as-html string) + (<:as-is string))))) + (if (editablep slot) (