equal
deleted
inserted
replaced
90 register_document(Document.init) |
90 register_document(Document.init) |
91 |
91 |
92 |
92 |
93 /* document changes */ |
93 /* document changes */ |
94 |
94 |
95 def handle_change(change: Change) |
95 def handle_change(change: Document.Change) |
96 //{{{ |
96 //{{{ |
97 { |
97 { |
98 require(change.parent.isDefined) |
98 require(change.parent.isDefined) |
99 |
99 |
100 val (node_edits, doc) = change.result.join |
100 val (node_edits, doc) = change.result.join |
242 if (prover != null) { |
242 if (prover != null) { |
243 prover.kill |
243 prover.kill |
244 prover = null |
244 prover = null |
245 } |
245 } |
246 |
246 |
247 case change: Change if prover != null => |
247 case change: Document.Change if prover != null => |
248 handle_change(change) |
248 handle_change(change) |
249 |
249 |
250 case result: Isabelle_Process.Result => |
250 case result: Isabelle_Process.Result => |
251 handle_result(result.cache(xml_cache)) |
251 handle_result(result.cache(xml_cache)) |
252 |
252 |
313 |
313 |
314 private case class Edit_Document(edits: List[Document.Node_Text_Edit]) |
314 private case class Edit_Document(edits: List[Document.Node_Text_Edit]) |
315 |
315 |
316 private val editor_history = new Actor |
316 private val editor_history = new Actor |
317 { |
317 { |
318 @volatile private var history = Change.init |
318 @volatile private var history = Document.Change.init |
319 def current_change(): Change = history |
319 def current_change(): Document.Change = history |
320 |
320 |
321 def act |
321 def act |
322 { |
322 { |
323 loop { |
323 loop { |
324 react { |
324 react { |
329 isabelle.Future.fork { |
329 isabelle.Future.fork { |
330 val old_doc = old_change.join_document |
330 val old_doc = old_change.join_document |
331 old_doc.await_assignment |
331 old_doc.await_assignment |
332 Document.text_edits(Session.this, old_doc, new_id, edits) |
332 Document.text_edits(Session.this, old_doc, new_id, edits) |
333 } |
333 } |
334 val new_change = new Change(new_id, Some(old_change), edits, result) |
334 val new_change = new Document.Change(new_id, Some(old_change), edits, result) |
335 history = new_change |
335 history = new_change |
336 new_change.result.map(_ => session_actor ! new_change) |
336 new_change.result.map(_ => session_actor ! new_change) |
337 |
337 |
338 case bad => System.err.println("editor_model: ignoring bad message " + bad) |
338 case bad => System.err.println("editor_model: ignoring bad message " + bad) |
339 } |
339 } |
349 def started(timeout: Int, args: List[String]): Option[String] = |
349 def started(timeout: Int, args: List[String]): Option[String] = |
350 (session_actor !? Started(timeout, args)).asInstanceOf[Option[String]] |
350 (session_actor !? Started(timeout, args)).asInstanceOf[Option[String]] |
351 |
351 |
352 def stop() { session_actor ! Stop } |
352 def stop() { session_actor ! Stop } |
353 |
353 |
354 def current_change(): Change = editor_history.current_change() |
354 def current_change(): Document.Change = editor_history.current_change() |
355 def edit_document(edits: List[Document.Node_Text_Edit]) { editor_history ! Edit_Document(edits) } |
355 def edit_document(edits: List[Document.Node_Text_Edit]) { editor_history ! Edit_Document(edits) } |
356 } |
356 } |