From dcc4b91b35e48d93dd773e267a3f9a23be2cf763 Mon Sep 17 00:00:00 2001 From: Markus Triska Date: Sat, 25 Jul 2020 09:47:59 +0200 Subject: [PATCH] ENHANCED: flush output for impure I/O (format/[2,3], portray_clause/1 etc.) Without this, we do not get a (timely) prompt in cases like: ?- format("press a key: ", []), get_single_char(C). whereas for example write/1 already works in such cases: ?- write('press a key: '), get_single_char(C). press a key: --- src/lib/format.pl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lib/format.pl b/src/lib/format.pl index 95a1a1da..31abe57c 100644 --- a/src/lib/format.pl +++ b/src/lib/format.pl @@ -377,7 +377,8 @@ format(Stream, Fs, Args) :- % we use a specialised internal predicate that uses only a % single "write" operation for efficiency. It is equivalent to % maplist(put_char(Stream), Cs). It also works for binary streams. - '$put_chars'(Stream, Cs). + '$put_chars'(Stream, Cs), + flush_output(Stream). /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ?- phrase(cells("hello", [], 0, []), Cs). -- 2.54.0