author | wenzelm |
Mon, 21 Jul 2014 16:58:12 +0200 | |
changeset 57593 | 2f7d91242b99 |
parent 56999 | d926fc73b554 |
child 57594 | 037f3b251df5 |
permissions | -rw-r--r-- |
50450
358b6020f8b6
generalized notion of active area, where sendback is just one application;
wenzelm
parents:
50341
diff
changeset
|
1 |
/* Title: Tools/jEdit/src/active.scala |
49492 | 2 |
Author: Makarius |
3 |
||
50450
358b6020f8b6
generalized notion of active area, where sendback is just one application;
wenzelm
parents:
50341
diff
changeset
|
4 |
Active areas within the document. |
49492 | 5 |
*/ |
6 |
||
7 |
package isabelle.jedit |
|
8 |
||
9 |
||
10 |
import isabelle._ |
|
11 |
||
49493
db58490a68ac
more realistic sendback: pick exec_id from message position and text from buffer;
wenzelm
parents:
49492
diff
changeset
|
12 |
import org.gjt.sp.jedit.View |
49492 | 13 |
|
14 |
||
50450
358b6020f8b6
generalized notion of active area, where sendback is just one application;
wenzelm
parents:
50341
diff
changeset
|
15 |
object Active |
49492 | 16 |
{ |
50450
358b6020f8b6
generalized notion of active area, where sendback is just one application;
wenzelm
parents:
50341
diff
changeset
|
17 |
def action(view: View, text: String, elem: XML.Elem) |
49492 | 18 |
{ |
56662
f373fb77e0a4
avoid "Adaptation of argument list by inserting ()" -- deprecated in scala-2.11.0;
wenzelm
parents:
56428
diff
changeset
|
19 |
Swing_Thread.require {} |
49492 | 20 |
|
21 |
Document_View(view.getTextArea) match { |
|
22 |
case Some(doc_view) => |
|
23 |
doc_view.rich_text_area.robust_body() { |
|
50215 | 24 |
val text_area = doc_view.text_area |
49492 | 25 |
val model = doc_view.model |
26 |
val buffer = model.buffer |
|
27 |
val snapshot = model.snapshot() |
|
49493
db58490a68ac
more realistic sendback: pick exec_id from message position and text from buffer;
wenzelm
parents:
49492
diff
changeset
|
28 |
|
50164
77668b522ffe
some support for implicit senback, meaning that it uses the caret position instead of explicit command exec_id;
wenzelm
parents:
49493
diff
changeset
|
29 |
if (!snapshot.is_outdated) { |
50715
8cfd585b9162
prefer old graph browser in Isabelle/jEdit, which still produces better layout;
wenzelm
parents:
50500
diff
changeset
|
30 |
// FIXME avoid hard-wired stuff |
50450
358b6020f8b6
generalized notion of active area, where sendback is just one application;
wenzelm
parents:
50341
diff
changeset
|
31 |
elem match { |
50715
8cfd585b9162
prefer old graph browser in Isabelle/jEdit, which still produces better layout;
wenzelm
parents:
50500
diff
changeset
|
32 |
case XML.Elem(Markup(Markup.BROWSER, _), body) => |
56729 | 33 |
Future.fork { |
34 |
val graph_file = Isabelle_System.tmp_file("graph") |
|
35 |
File.write(graph_file, XML.content(body)) |
|
36 |
Isabelle_System.bash_env(null, |
|
37 |
Map("GRAPH_FILE" -> Isabelle_System.posix_path(graph_file)), |
|
38 |
"\"$ISABELLE_TOOL\" browser -c \"$GRAPH_FILE\" &") |
|
39 |
} |
|
50715
8cfd585b9162
prefer old graph browser in Isabelle/jEdit, which still produces better layout;
wenzelm
parents:
50500
diff
changeset
|
40 |
|
8cfd585b9162
prefer old graph browser in Isabelle/jEdit, which still produces better layout;
wenzelm
parents:
50500
diff
changeset
|
41 |
case XML.Elem(Markup(Markup.GRAPHVIEW, _), body) => |
56729 | 42 |
Future.fork { |
43 |
val graph = |
|
44 |
Exn.capture { |
|
45 |
isabelle.graphview.Model.decode_graph(body) |
|
46 |
.transitive_reduction_acyclic |
|
47 |
} |
|
48 |
Swing_Thread.later { Graphview_Dockable(view, snapshot, graph) } |
|
49 |
} |
|
50450
358b6020f8b6
generalized notion of active area, where sendback is just one application;
wenzelm
parents:
50341
diff
changeset
|
50 |
|
50500
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
51 |
case XML.Elem(Markup(Markup.SENDBACK, props), _) => |
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
52 |
props match { |
54640
bbd2fa353809
back to Status.FINISHED and immediate remove_overlay (reverting 6e69f9ca8f1c), which is important to avoid restart of print function after edits + re-assignment of located command;
wenzelm
parents:
53497
diff
changeset
|
53 |
case Position.Id(id) => |
53497 | 54 |
Isabelle.edit_command(snapshot, buffer, |
54640
bbd2fa353809
back to Status.FINISHED and immediate remove_overlay (reverting 6e69f9ca8f1c), which is important to avoid restart of print function after edits + re-assignment of located command;
wenzelm
parents:
53497
diff
changeset
|
55 |
props.exists(_ == Markup.PADDING_COMMAND), id, text) |
50500
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
56 |
case _ => |
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
57 |
if (props.exists(_ == Markup.PADDING_LINE)) |
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
58 |
Isabelle.insert_line_padding(text_area, text) |
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
59 |
else text_area.setSelectedText(text) |
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
60 |
} |
56999
d926fc73b554
re-focus target explicity, e.g. relevant for Sledgehammer panel;
wenzelm
parents:
56729
diff
changeset
|
61 |
text_area.requestFocus |
50500
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
62 |
|
52081
29566b6810f7
discontinued odd workaround for scala-2.9.2, which is hopefully obsolete in scala-2.10.x;
wenzelm
parents:
50715
diff
changeset
|
63 |
case Protocol.Dialog(id, serial, result) => |
29566b6810f7
discontinued odd workaround for scala-2.9.2, which is hopefully obsolete in scala-2.10.x;
wenzelm
parents:
50715
diff
changeset
|
64 |
model.session.dialog_result(id, serial, result) |
29566b6810f7
discontinued odd workaround for scala-2.9.2, which is hopefully obsolete in scala-2.10.x;
wenzelm
parents:
50715
diff
changeset
|
65 |
|
50215 | 66 |
case _ => |
50164
77668b522ffe
some support for implicit senback, meaning that it uses the caret position instead of explicit command exec_id;
wenzelm
parents:
49493
diff
changeset
|
67 |
} |
49492 | 68 |
} |
69 |
} |
|
70 |
case None => |
|
71 |
} |
|
72 |
} |
|
73 |
} |