12 |
12 |
13 object Progress |
13 object Progress |
14 { |
14 { |
15 def theory_message(session: String, theory: String): String = |
15 def theory_message(session: String, theory: String): String = |
16 if (session == "") "theory " + theory else session + ": theory " + theory |
16 if (session == "") "theory " + theory else session + ": theory " + theory |
|
17 |
|
18 def theory_percentage_message(session: String, theory: String, percentage: Int): String = |
|
19 theory_message(session, theory) + ": " + percentage + "%" |
17 } |
20 } |
18 |
21 |
19 class Progress |
22 class Progress |
20 { |
23 { |
21 def echo(msg: String) {} |
24 def echo(msg: String) {} |
51 |
54 |
52 object No_Progress extends Progress |
55 object No_Progress extends Progress |
53 |
56 |
54 class Console_Progress(verbose: Boolean = false, stderr: Boolean = false) extends Progress |
57 class Console_Progress(verbose: Boolean = false, stderr: Boolean = false) extends Progress |
55 { |
58 { |
56 override def echo(msg: String) |
59 override def echo(msg: String): Unit = |
57 { |
|
58 Output.writeln(msg, stdout = !stderr) |
60 Output.writeln(msg, stdout = !stderr) |
59 } |
|
60 |
61 |
61 override def theory(session: String, theory: String): Unit = |
62 override def theory(session: String, theory: String): Unit = |
62 if (verbose) echo(Progress.theory_message(session, theory)) |
63 if (verbose) echo(Progress.theory_message(session, theory)) |
|
64 |
|
65 override def theory_percentage(session: String, theory: String, percentage: Int): Unit = |
|
66 if (verbose) echo(Progress.theory_percentage_message(session, theory, percentage)) |
63 |
67 |
64 @volatile private var is_stopped = false |
68 @volatile private var is_stopped = false |
65 override def interrupt_handler[A](e: => A): A = |
69 override def interrupt_handler[A](e: => A): A = |
66 POSIX_Interrupt.handler { is_stopped = true } { e } |
70 POSIX_Interrupt.handler { is_stopped = true } { e } |
67 override def stopped: Boolean = |
71 override def stopped: Boolean = |
77 File.append(path, msg + "\n") |
81 File.append(path, msg + "\n") |
78 |
82 |
79 override def theory(session: String, theory: String): Unit = |
83 override def theory(session: String, theory: String): Unit = |
80 if (verbose) echo(Progress.theory_message(session, theory)) |
84 if (verbose) echo(Progress.theory_message(session, theory)) |
81 |
85 |
|
86 override def theory_percentage(session: String, theory: String, percentage: Int): Unit = |
|
87 if (verbose) echo(Progress.theory_percentage_message(session, theory, percentage)) |
|
88 |
82 override def toString: String = path.toString |
89 override def toString: String = path.toString |
83 } |
90 } |