# HG changeset patch # User wenzelm # Date 1443544795 -7200 # Node ID 11c1bf92d61d5d900b5b2593c6f528e126ee63d5 # Parent 12f9ab87a06de7db624fe33c7d1d0652572e5b32 tuned; diff -r 12f9ab87a06d -r 11c1bf92d61d src/Pure/GUI/system_dialog.scala --- a/src/Pure/GUI/system_dialog.scala Tue Sep 29 16:58:33 2015 +0200 +++ b/src/Pure/GUI/system_dialog.scala Tue Sep 29 18:39:55 2015 +0200 @@ -9,7 +9,6 @@ import java.awt.event.{WindowEvent, WindowAdapter} import javax.swing.{WindowConstants, JFrame, JDialog} -import java.io.{File => JFile, BufferedReader, InputStreamReader} import scala.swing.{ScrollPane, Button, CheckBox, FlowPanel, BorderPanel, Frame, TextArea, Component, Label} @@ -186,25 +185,4 @@ @volatile private var is_stopped = false override def stopped: Boolean = is_stopped - - - /* system operations */ - - def execute(cwd: JFile, env: Map[String, String], args: String*): Int = - { - val proc = Isabelle_System.raw_execute(cwd, env, true, args: _*) - proc.getOutputStream.close - - val stdout = new BufferedReader(new InputStreamReader(proc.getInputStream, UTF8.charset)) - try { - var line = stdout.readLine - while (line != null) { - echo(line) - line = stdout.readLine - } - } - finally { stdout.close } - - proc.waitFor - } } diff -r 12f9ab87a06d -r 11c1bf92d61d src/Pure/System/isabelle_system.scala --- a/src/Pure/System/isabelle_system.scala Tue Sep 29 16:58:33 2015 +0200 +++ b/src/Pure/System/isabelle_system.scala Tue Sep 29 18:39:55 2015 +0200 @@ -8,10 +8,12 @@ package isabelle -import java.io.{File => JFile, IOException} +import java.io.{File => JFile, IOException, BufferedReader, InputStreamReader} import java.nio.file.{Path => JPath, Files, SimpleFileVisitor, FileVisitResult} import java.nio.file.attribute.BasicFileAttributes +import scala.collection.mutable + object Isabelle_System { @@ -58,7 +60,10 @@ (2) ISABELLE_HOME process environment variable (e.g. inherited from running isabelle tool) (3) isabelle.home system property (e.g. via JVM application boot process) */ - def init(isabelle_home: String = "", cygwin_root: String = ""): Unit = synchronized { + def init( + isabelle_home: String = "", + cygwin_root: String = "", + progress: Progress = Ignore_Progress): Unit = synchronized { if (_settings.isEmpty) { import scala.collection.JavaConversions._ @@ -114,7 +119,7 @@ else Nil val cmdline = shell_prefix ::: List(system_home + "/bin/isabelle", "getenv", "-d", dump.toString) - val (output, rc) = process_output(raw_execute(null, env, true, cmdline: _*)) + val (output, rc) = process_output(progress, raw_execute(null, env, true, cmdline: _*)) if (rc != 0) error(output) val entries = @@ -194,10 +199,28 @@ proc.start } - private def process_output(proc: Process): (String, Int) = + def process_output(progress: Progress, proc: Process): (String, Int) = { proc.getOutputStream.close - val output = File.read_stream(proc.getInputStream) + + val output = + { + val lines = new mutable.ListBuffer[String] + + val stdout = new BufferedReader(new InputStreamReader(proc.getInputStream, UTF8.charset)) + try { + var line = stdout.readLine + while (line != null) { + progress.echo(line) + lines += line + line = stdout.readLine + } + } + finally { stdout.close } + + cat_lines(lines.toList) + } + val rc = try { proc.waitFor } finally { @@ -206,6 +229,7 @@ proc.destroy Thread.interrupted } + (output, rc) } @@ -298,7 +322,7 @@ if (Platform.is_windows) List(get_cygwin_root() + "\\bin\\bash.exe") else List("/usr/bin/env", "bash") val cmdline = bash ::: List("-c", "kill -" + signal + " -" + group_pid) - process_output(raw_execute(null, null, true, cmdline: _*)) + process_output(Ignore_Progress, raw_execute(null, null, true, cmdline: _*)) } @@ -364,7 +388,7 @@ } match { case Some(dir) => val file = File.standard_path(dir + Path.basic(name)) - process_output(execute(true, (List(file) ::: args.toList): _*)) + process_output(Ignore_Progress, execute(true, (List(file) ::: args.toList): _*)) case None => ("Unknown Isabelle tool: " + name, 2) } } diff -r 12f9ab87a06d -r 11c1bf92d61d src/Pure/Tools/main.scala --- a/src/Pure/Tools/main.scala Tue Sep 29 16:58:33 2015 +0200 +++ b/src/Pure/Tools/main.scala Tue Sep 29 18:39:55 2015 +0200 @@ -131,7 +131,8 @@ { val cwd = new JFile(isabelle_home) val env = Map("CYGWIN" -> "nodosfilewarning") - system_dialog.execute(cwd, env, args: _*) + val proc = Isabelle_System.raw_execute(cwd, env, true, args: _*) + Isabelle_System.process_output(system_dialog, proc)._2 } system_dialog.echo("symlinks ...")