From 13f6f77ddee9e3e23c43d29ede5f1b39364b451f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Wed, 13 Sep 2023 12:58:36 +0200 Subject: Made displayln into a library export. --- doc/ref/general/io.texi | 4 ++++ module/calp/terminal.scm | 5 +---- module/hnh/util/io.scm | 5 +++++ 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/doc/ref/general/io.texi b/doc/ref/general/io.texi index 3f67700b..178df749 100644 --- a/doc/ref/general/io.texi +++ b/doc/ref/general/io.texi @@ -29,3 +29,7 @@ the file, and @code{#f} otherwise. @defun read-file path Open file at path, and return its content as a string. @end defun + +@defun displayln x [port] +Calls @code{display}, followed by @code{newline}. +@end defun diff --git a/module/calp/terminal.scm b/module/calp/terminal.scm index 316421eb..c4b30a54 100644 --- a/module/calp/terminal.scm +++ b/module/calp/terminal.scm @@ -6,6 +6,7 @@ :use-module ((srfi srfi-41) :select (stream-car)) :use-module (srfi srfi-88) :use-module (hnh util) + :use-module ((hnh util io) :select (displayln)) :use-module (vulgar) :use-module (vulgar info) :use-module (vulgar color) @@ -84,10 +85,6 @@ (displayln (box-top #\┴ #\─ date-width (+ summary-width 2) (1+ location-width)))) -(define (displayln a) - (display a) (newline)) - - (define-class () (event-set getter: get-event-set init-keyword: event-set:) (active-element accessor: active-element diff --git a/module/hnh/util/io.scm b/module/hnh/util/io.scm index 09900f8d..f6f97ef9 100644 --- a/module/hnh/util/io.scm +++ b/module/hnh/util/io.scm @@ -6,6 +6,7 @@ read-lines with-atomic-output-to-file call-with-tmpfile + displayln ->port)) (define (open-input-port str) @@ -74,6 +75,10 @@ (proc port filename) (close-port port)))))) +(define displayln + (case-lambda ((x) (display x) (newline)) + ((x p) (display x p) (newline p)))) + (define (->port port-or-string) (cond ((port? port-or-string) port-or-string) ((string? port-or-string) (open-input-string port-or-string)) -- cgit v1.2.3