| author | wenzelm | 
| Wed, 06 Jan 2016 00:04:15 +0100 | |
| changeset 62075 | ea3360245939 | 
| parent 61590 | 94ab348eaab2 | 
| child 65213 | 51c0f094dc02 | 
| 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: 
56864diff
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 | |
| 25 | def get: List[(String, String)] = print_operations.value | |
| 26 | ||
| 27 | private def put(prover: Prover, msg: Prover.Protocol_Output): Boolean = | |
| 28 |     {
 | |
| 29 | val ops = | |
| 30 |       {
 | |
| 31 | import XML.Decode._ | |
| 32 | list(pair(string, string))(YXML.parse_body(msg.text)) | |
| 33 | } | |
| 34 | print_operations.change(_ => ops) | |
| 35 | true | |
| 36 | } | |
| 37 | ||
| 38 | override def start(prover: Prover): Unit = | |
| 39 | prover.protocol_command(Markup.PRINT_OPERATIONS) | |
| 40 | ||
| 41 | val functions = Map(Markup.PRINT_OPERATIONS -> put _) | |
| 42 | } | |
| 43 | } |