author | wenzelm |
Sat, 09 Apr 2016 16:16:05 +0200 | |
changeset 62930 | 51ac6bc389e8 |
parent 62553 | d2e0d626fb96 |
child 62938 | 79f41fbdf74a |
permissions | -rw-r--r-- |
57453 | 1 |
/* Title: Pure/General/output.scala |
2 |
Module: PIDE |
|
56782
433cf57550fa
more systematic Isabelle output, like in classic Isabelle/ML (without markup);
wenzelm
parents:
diff
changeset
|
3 |
Author: Makarius |
433cf57550fa
more systematic Isabelle output, like in classic Isabelle/ML (without markup);
wenzelm
parents:
diff
changeset
|
4 |
|
62930
51ac6bc389e8
shared output primitives of physical/virtual Pure;
wenzelm
parents:
62553
diff
changeset
|
5 |
Isabelle output channels. |
56782
433cf57550fa
more systematic Isabelle output, like in classic Isabelle/ML (without markup);
wenzelm
parents:
diff
changeset
|
6 |
*/ |
433cf57550fa
more systematic Isabelle output, like in classic Isabelle/ML (without markup);
wenzelm
parents:
diff
changeset
|
7 |
|
433cf57550fa
more systematic Isabelle output, like in classic Isabelle/ML (without markup);
wenzelm
parents:
diff
changeset
|
8 |
package isabelle |
433cf57550fa
more systematic Isabelle output, like in classic Isabelle/ML (without markup);
wenzelm
parents:
diff
changeset
|
9 |
|
433cf57550fa
more systematic Isabelle output, like in classic Isabelle/ML (without markup);
wenzelm
parents:
diff
changeset
|
10 |
|
433cf57550fa
more systematic Isabelle output, like in classic Isabelle/ML (without markup);
wenzelm
parents:
diff
changeset
|
11 |
object Output |
433cf57550fa
more systematic Isabelle output, like in classic Isabelle/ML (without markup);
wenzelm
parents:
diff
changeset
|
12 |
{ |
59671
9715eb8e9408
more precise position information in Isabelle/Scala, with YXML markup as in Isabelle/ML;
wenzelm
parents:
57453
diff
changeset
|
13 |
def clean_yxml(msg: String): String = |
9715eb8e9408
more precise position information in Isabelle/Scala, with YXML markup as in Isabelle/ML;
wenzelm
parents:
57453
diff
changeset
|
14 |
try { XML.content(YXML.parse_body(msg)) } |
9715eb8e9408
more precise position information in Isabelle/Scala, with YXML markup as in Isabelle/ML;
wenzelm
parents:
57453
diff
changeset
|
15 |
catch { case ERROR(_) => msg } |
56782
433cf57550fa
more systematic Isabelle output, like in classic Isabelle/ML (without markup);
wenzelm
parents:
diff
changeset
|
16 |
|
59671
9715eb8e9408
more precise position information in Isabelle/Scala, with YXML markup as in Isabelle/ML;
wenzelm
parents:
57453
diff
changeset
|
17 |
def writeln_text(msg: String): String = clean_yxml(msg) |
9715eb8e9408
more precise position information in Isabelle/Scala, with YXML markup as in Isabelle/ML;
wenzelm
parents:
57453
diff
changeset
|
18 |
def warning_text(msg: String): String = cat_lines(split_lines(clean_yxml(msg)).map("### " + _)) |
9715eb8e9408
more precise position information in Isabelle/Scala, with YXML markup as in Isabelle/ML;
wenzelm
parents:
57453
diff
changeset
|
19 |
def error_text(msg: String): String = cat_lines(split_lines(clean_yxml(msg)).map("*** " + _)) |
9715eb8e9408
more precise position information in Isabelle/Scala, with YXML markup as in Isabelle/ML;
wenzelm
parents:
57453
diff
changeset
|
20 |
|
62553 | 21 |
def writeln(msg: String, stdout: Boolean = false) |
22 |
{ |
|
23 |
if (msg != "") { |
|
24 |
if (stdout) Console.println(writeln_text(msg)) |
|
25 |
else Console.err.println(writeln_text(msg)) |
|
26 |
} |
|
27 |
} |
|
28 |
||
29 |
def warning(msg: String, stdout: Boolean = false) |
|
30 |
{ |
|
31 |
if (msg != "") { |
|
32 |
if (stdout) Console.println(warning_text(msg)) |
|
33 |
else Console.err.println(warning_text(msg)) |
|
34 |
} |
|
35 |
} |
|
36 |
||
37 |
def error_message(msg: String, stdout: Boolean = false) |
|
38 |
{ |
|
39 |
if (msg != "") { |
|
40 |
if (stdout) Console.println(error_text(msg)) |
|
41 |
else Console.err.println(error_text(msg)) |
|
42 |
} |
|
43 |
} |
|
56782
433cf57550fa
more systematic Isabelle output, like in classic Isabelle/ML (without markup);
wenzelm
parents:
diff
changeset
|
44 |
} |