author | wenzelm |
Sat, 01 Apr 2017 19:17:15 +0200 | |
changeset 65344 | b99283eed13c |
parent 65220 | 420f55912b3e |
child 71601 | 97ccf48c2f0c |
permissions | -rw-r--r-- |
59720 | 1 |
/* Title: Pure/Tools/print_operation.scala |
56864 | 2 |
Author: Makarius |
3 |
||
4 |
Print operations as asynchronous query. |
|
5 |
*/ |
|
6 |
||
7 |
package isabelle |
|
8 |
||
9 |
||
10 |
object Print_Operation |
|
11 |
{ |
|
12 |
def print_operations(session: Session): List[(String, String)] = |
|
59366
e94df7f6b608
clarified build_theories: proper protocol handler;
wenzelm
parents:
56864
diff
changeset
|
13 |
session.get_protocol_handler("isabelle.Print_Operation$Handler") match { |
56864 | 14 |
case Some(handler: Handler) => handler.get |
15 |
case _ => Nil |
|
16 |
} |
|
17 |
||
18 |
||
19 |
/* protocol handler */ |
|
20 |
||
21 |
class Handler extends Session.Protocol_Handler |
|
22 |
{ |
|
61590 | 23 |
private val print_operations = Synchronized[List[(String, String)]](Nil) |
56864 | 24 |
|
65220 | 25 |
override def init(session: Session): Unit = |
26 |
session.protocol_command(Markup.PRINT_OPERATIONS) |
|
27 |
||
56864 | 28 |
def get: List[(String, String)] = print_operations.value |
29 |
||
65219 | 30 |
private def put(msg: Prover.Protocol_Output): Boolean = |
56864 | 31 |
{ |
32 |
val ops = |
|
33 |
{ |
|
34 |
import XML.Decode._ |
|
65344
b99283eed13c
clarified YXML vs. symbol encoding: operate on whole message;
wenzelm
parents:
65220
diff
changeset
|
35 |
list(pair(string, string))(Symbol.decode_yxml(msg.text)) |
56864 | 36 |
} |
37 |
print_operations.change(_ => ops) |
|
38 |
true |
|
39 |
} |
|
40 |
||
65219 | 41 |
val functions = List(Markup.PRINT_OPERATIONS -> put _) |
56864 | 42 |
} |
43 |
} |