;; -*-theme-d-*-

;; Copyright (C) 2008-2013 Tommi Höynälänmaa
;; Distributed under GNU Lesser General Public License version 3,
;; see file doc/LGPL-3.

(define-body (standard-library console-io)

  (import (standard-library text-file-io))

  (define _console-display
    (unchecked-prim-proc
     theme-prim-console-display (<object>) <none> nonpure))

  (define console-display-string
    (lambda (((str <string>)) <none> nonpure)
      (_console-display str)))

  (define console-display-character
    (lambda (((char <character>)) <none> nonpure)
      (_console-display char)))

  (define console-newline
    (unchecked-prim-proc theme-console-newline () <none> nonpure))

  (define console-read-character
    (prim-proc theme-console-read-character
			 ()
			 (:union <character> <eof>)
			 nonpure))

  (define console-read
    (prim-proc theme-console-read
	       ()
	       <object>
	       nonpure))

  (define console-character-ready?
    (prim-proc theme-console-char-ready? () <boolean> pure))

  (define console-display
    (lambda (((obj <object>)) <none> nonpure)
      (display (current-output-port) obj)))

  (define console-display-line
    (lambda (((obj <object>)) <none> nonpure)
      (display-line (current-output-port) obj)))

  (define console-write
    (lambda (((obj <object>)) <none> nonpure)
      (write (current-output-port) obj)))

  (define console-write-line
    (lambda (((obj <object>)) <none> nonpure)
      (write-line (current-output-port) obj))))
