11 { |
11 { |
12 /* document editing */ |
12 /* document editing */ |
13 |
13 |
14 object Assign |
14 object Assign |
15 { |
15 { |
16 def unapply(text: String): Option[(Document.Version_ID, Document.Assign)] = |
16 def unapply(text: String): Option[(Document_ID.Version, Document.Assign)] = |
17 try { |
17 try { |
18 import XML.Decode._ |
18 import XML.Decode._ |
19 val body = YXML.parse_body(text) |
19 val body = YXML.parse_body(text) |
20 Some(pair(long, list(pair(long, list(long))))(body)) |
20 Some(pair(long, list(pair(long, list(long))))(body)) |
21 } |
21 } |
84 |
84 |
85 /* command timing */ |
85 /* command timing */ |
86 |
86 |
87 object Command_Timing |
87 object Command_Timing |
88 { |
88 { |
89 def unapply(props: Properties.T): Option[(Document.ID, isabelle.Timing)] = |
89 def unapply(props: Properties.T): Option[(Document_ID.ID, isabelle.Timing)] = |
90 props match { |
90 props match { |
91 case (Markup.FUNCTION, Markup.COMMAND_TIMING) :: args => |
91 case (Markup.FUNCTION, Markup.COMMAND_TIMING) :: args => |
92 (args, args) match { |
92 (args, args) match { |
93 case (Position.Id(id), Markup.Timing_Properties(timing)) => Some((id, timing)) |
93 case (Position.Id(id), Markup.Timing_Properties(timing)) => Some((id, timing)) |
94 case _ => None |
94 case _ => None |
231 |
231 |
232 /* dialogs */ |
232 /* dialogs */ |
233 |
233 |
234 object Dialog_Args |
234 object Dialog_Args |
235 { |
235 { |
236 def unapply(props: Properties.T): Option[(Document.ID, Long, String)] = |
236 def unapply(props: Properties.T): Option[(Document_ID.ID, Long, String)] = |
237 (props, props, props) match { |
237 (props, props, props) match { |
238 case (Position.Id(id), Markup.Serial(serial), Markup.Result(result)) => |
238 case (Position.Id(id), Markup.Serial(serial), Markup.Result(result)) => |
239 Some((id, serial, result)) |
239 Some((id, serial, result)) |
240 case _ => None |
240 case _ => None |
241 } |
241 } |
242 } |
242 } |
243 |
243 |
244 object Dialog |
244 object Dialog |
245 { |
245 { |
246 def unapply(tree: XML.Tree): Option[(Document.ID, Long, String)] = |
246 def unapply(tree: XML.Tree): Option[(Document_ID.ID, Long, String)] = |
247 tree match { |
247 tree match { |
248 case XML.Elem(Markup(Markup.DIALOG, Dialog_Args(id, serial, result)), _) => |
248 case XML.Elem(Markup(Markup.DIALOG, Dialog_Args(id, serial, result)), _) => |
249 Some((id, serial, result)) |
249 Some((id, serial, result)) |
250 case _ => None |
250 case _ => None |
251 } |
251 } |
252 } |
252 } |
253 |
253 |
254 object Dialog_Result |
254 object Dialog_Result |
255 { |
255 { |
256 def apply(id: Document.ID, serial: Long, result: String): XML.Elem = |
256 def apply(id: Document_ID.ID, serial: Long, result: String): XML.Elem = |
257 { |
257 { |
258 val props = Position.Id(id) ::: Markup.Serial(serial) |
258 val props = Position.Id(id) ::: Markup.Serial(serial) |
259 XML.Elem(Markup(Markup.RESULT, props), List(XML.Text(result))) |
259 XML.Elem(Markup(Markup.RESULT, props), List(XML.Text(result))) |
260 } |
260 } |
261 |
261 |
307 { |
307 { |
308 /* commands */ |
308 /* commands */ |
309 |
309 |
310 def define_command(command: Command): Unit = |
310 def define_command(command: Command): Unit = |
311 input("Document.define_command", |
311 input("Document.define_command", |
312 Document.ID(command.id), encode(command.name), encode(command.source)) |
312 Document_ID.ID(command.id), encode(command.name), encode(command.source)) |
313 |
313 |
314 |
314 |
315 /* document versions */ |
315 /* document versions */ |
316 |
316 |
317 def discontinue_execution() { input("Document.discontinue_execution") } |
317 def discontinue_execution() { input("Document.discontinue_execution") } |
318 |
318 |
319 def cancel_execution() { input("Document.cancel_execution") } |
319 def cancel_execution() { input("Document.cancel_execution") } |
320 |
320 |
321 def update(old_id: Document.Version_ID, new_id: Document.Version_ID, |
321 def update(old_id: Document_ID.Version, new_id: Document_ID.Version, |
322 edits: List[Document.Edit_Command]) |
322 edits: List[Document.Edit_Command]) |
323 { |
323 { |
324 val edits_yxml = |
324 val edits_yxml = |
325 { import XML.Encode._ |
325 { import XML.Encode._ |
326 def id: T[Command] = (cmd => long(cmd.id)) |
326 def id: T[Command] = (cmd => long(cmd.id)) |
344 { |
344 { |
345 val (name, edit) = node_edit |
345 val (name, edit) = node_edit |
346 pair(string, encode_edit(name))(name.node, edit) |
346 pair(string, encode_edit(name))(name.node, edit) |
347 }) |
347 }) |
348 YXML.string_of_body(encode_edits(edits)) } |
348 YXML.string_of_body(encode_edits(edits)) } |
349 input("Document.update", Document.ID(old_id), Document.ID(new_id), edits_yxml) |
349 input("Document.update", Document_ID.ID(old_id), Document_ID.ID(new_id), edits_yxml) |
350 } |
350 } |
351 |
351 |
352 def remove_versions(versions: List[Document.Version]) |
352 def remove_versions(versions: List[Document.Version]) |
353 { |
353 { |
354 val versions_yxml = |
354 val versions_yxml = |