clarified signature: more robust and uniform out.flush (following b11587195c70);
authorwenzelm
Mon, 13 Oct 2025 14:24:27 +0200
changeset 83267 bcc69ca4ac10
parent 83266 2f75f2495e3e
child 83268 dcbd1abb742c
clarified signature: more robust and uniform out.flush (following b11587195c70);
src/Pure/General/output.scala
--- a/src/Pure/General/output.scala	Sun Oct 12 15:11:29 2025 +0200
+++ b/src/Pure/General/output.scala	Mon Oct 13 14:24:27 2025 +0200
@@ -6,8 +6,6 @@
 
 package isabelle
 
-import java.io.PrintStream
-
 
 object Output {
   def writeln_text(msg: String): String = Protocol_Message.clean_output(msg)
@@ -19,11 +17,14 @@
   def error_message_text(msg: String): String =
     error_message_prefix(Protocol_Message.clean_output(msg))
 
-  def stream(stdout: Boolean = false): PrintStream =
-    if (stdout) Console.out else Console.err
+  def print_stream(s: String, stdout: Boolean = false): Unit = {
+    val out = if (stdout) Console.out else Console.err
+    out.print(s)
+    out.flush()
+  }
 
   def output(s: String, stdout: Boolean = false, include_empty: Boolean = false): Unit =
-    if (s.nonEmpty || include_empty) stream(stdout = stdout).print(s + "\n")
+    if (s.nonEmpty || include_empty) print_stream(s + "\n", stdout = stdout)
 
   def writeln(msg: String, stdout: Boolean = false, include_empty: Boolean = false): Unit =
     output(writeln_text(msg), stdout = stdout, include_empty = include_empty)
@@ -34,11 +35,6 @@
   def error_message(msg: String, stdout: Boolean = false, include_empty: Boolean = false): Unit =
     output(error_message_text(msg), stdout = stdout, include_empty = include_empty)
 
-  def delete_lines(lines: Int, stdout: Boolean = false): Unit = {
-    if (lines > 0) {
-      val out = stream(stdout = stdout)
-      out.print("\u001b[" + lines + "F\u001b[J")
-      out.flush()
-    }
-  }
+  def delete_lines(lines: Int, stdout: Boolean = false): Unit =
+    if (lines > 0) print_stream("\u001b[" + lines + "F\u001b[J", stdout = stdout)
 }