;;; -*- mode: Lisp; Syntax: Common-Lisp; -*- ;;; ;;; Copyright (c) 2009 by the authors. ;;; ;;; See LICENCE for details. (in-package :hu.dwim.projectional-editor) ;;;;;; ;;; Projection (def (projection e) list->string () ()) ;;;;;; ;;; Construction (def (function e) make-projection/list->string () (make-projection 'list->string)) ;;;;;; ;;; Construction (def (macro e) list->string () '(make-projection/list->string)) ;;;;;; ;;; Printer (def printer list->string (projection recursion input input-reference output-reference) (declare (ignore projection recursion)) (bind ((child-iomaps nil) (width (list/width input)) (typed-input-reference `(the ,(form-type input) ,input-reference)) (output (with-output-to-string (stream) (iter (for element-index :from 0) (for element :in-sequence (elements-of input)) (for content = (content-of element)) (for list-reference = `(content-of (the list/element (elt (the list (elements-of (the list/list ,input-reference))) ,element-index)))) (push (make-iomap/string* input `(the string (border-of ,typed-input-reference)) 0 nil `(the string ,output-reference) (file-position stream) (+ 2 width)) child-iomaps) (if (first-iteration-p) (progn (write-char #\U250C stream) (iter (repeat width) (write-char #\U2500 stream)) (write-char #\U2510 stream)) (progn (write-char #\U251C stream) (iter (repeat width) (write-char #\U2500 stream)) (write-char #\U2524 stream))) (terpri stream) (push (make-iomap/string* input `(the string (border-of ,typed-input-reference)) 0 nil `(the string ,output-reference) (file-position stream) 1) child-iomaps) (write-char #\U2502 stream) (write-string (content-of element) stream) (write-string (make-string-of-spaces (- width (length content))) stream) (push (make-iomap/string* input `(the string (border-of ,typed-input-reference)) 0 nil `(the string ,output-reference) (file-position stream) 1) child-iomaps) (write-char #\U2502 stream) (terpri stream)) (push (make-iomap/string* input `(the string (border-of ,typed-input-reference)) 0 nil `(the string ,output-reference) (file-position stream) (+ 2 width)) child-iomaps) (write-char #\U2514 stream) (iter (repeat width) (write-char #\U2500 stream)) (write-char #\U2518 stream)))) (make-iomap/recursive input output (list* (make-iomap/object input input-reference output output-reference) (nreverse child-iomaps))))) ;;;;;; ;;; Reader (def reader list->string (projection recursion input input-reference output-reference) (declare (ignore projection recursion input input-reference output-reference)) nil)