| author | blanchet |
| Thu, 30 Jan 2014 14:37:53 +0100 | |
| changeset 55183 | 17ec4a29ef71 |
| parent 54562 | 301a721af68b |
| child 55431 | e0f20a44ff9d |
| permissions | -rw-r--r-- |
| 36676 | 1 |
/* Title: Pure/PIDE/document.scala |
2 |
Author: Makarius |
|
3 |
||
|
38150
67fc24df3721
simplified/refined document model: collection of named nodes, without proper dependencies yet;
wenzelm
parents:
37849
diff
changeset
|
4 |
Document as collection of named nodes, each consisting of an editable |
|
38418
9a7af64d71bb
more explicit / functional ML version of document model;
wenzelm
parents:
38417
diff
changeset
|
5 |
list of commands, associated with asynchronous execution process. |
| 36676 | 6 |
*/ |
| 34407 | 7 |
|
|
34871
e596a0b71f3c
incorporate "proofdocument" part into main Isabelle/Pure.jar -- except for html_panel.scala, which depends on external library (Lobo/Cobra browser);
wenzelm
parents:
34868
diff
changeset
|
8 |
package isabelle |
|
34318
c13e168a8ae6
original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff
changeset
|
9 |
|
| 34760 | 10 |
|
|
38150
67fc24df3721
simplified/refined document model: collection of named nodes, without proper dependencies yet;
wenzelm
parents:
37849
diff
changeset
|
11 |
import scala.collection.mutable |
| 37073 | 12 |
|
13 |
||
| 34823 | 14 |
object Document |
| 34483 | 15 |
{
|
| 38424 | 16 |
/** document structure **/ |
17 |
||
|
52977
15254e32d299
central management of Document.Overlays, independent of Document_Model;
wenzelm
parents:
52976
diff
changeset
|
18 |
/* overlays -- print functions with arguments */ |
|
15254e32d299
central management of Document.Overlays, independent of Document_Model;
wenzelm
parents:
52976
diff
changeset
|
19 |
|
|
15254e32d299
central management of Document.Overlays, independent of Document_Model;
wenzelm
parents:
52976
diff
changeset
|
20 |
object Overlays |
|
15254e32d299
central management of Document.Overlays, independent of Document_Model;
wenzelm
parents:
52976
diff
changeset
|
21 |
{
|
|
15254e32d299
central management of Document.Overlays, independent of Document_Model;
wenzelm
parents:
52976
diff
changeset
|
22 |
val empty = new Overlays(Map.empty) |
|
15254e32d299
central management of Document.Overlays, independent of Document_Model;
wenzelm
parents:
52976
diff
changeset
|
23 |
} |
|
15254e32d299
central management of Document.Overlays, independent of Document_Model;
wenzelm
parents:
52976
diff
changeset
|
24 |
|
|
15254e32d299
central management of Document.Overlays, independent of Document_Model;
wenzelm
parents:
52976
diff
changeset
|
25 |
final class Overlays private(rep: Map[Node.Name, Node.Overlays]) |
|
15254e32d299
central management of Document.Overlays, independent of Document_Model;
wenzelm
parents:
52976
diff
changeset
|
26 |
{
|
|
15254e32d299
central management of Document.Overlays, independent of Document_Model;
wenzelm
parents:
52976
diff
changeset
|
27 |
def apply(name: Document.Node.Name): Node.Overlays = |
|
15254e32d299
central management of Document.Overlays, independent of Document_Model;
wenzelm
parents:
52976
diff
changeset
|
28 |
rep.getOrElse(name, Node.Overlays.empty) |
|
15254e32d299
central management of Document.Overlays, independent of Document_Model;
wenzelm
parents:
52976
diff
changeset
|
29 |
|
|
15254e32d299
central management of Document.Overlays, independent of Document_Model;
wenzelm
parents:
52976
diff
changeset
|
30 |
private def update(name: Node.Name, f: Node.Overlays => Node.Overlays): Overlays = |
|
15254e32d299
central management of Document.Overlays, independent of Document_Model;
wenzelm
parents:
52976
diff
changeset
|
31 |
{
|
|
15254e32d299
central management of Document.Overlays, independent of Document_Model;
wenzelm
parents:
52976
diff
changeset
|
32 |
val node_overlays = f(apply(name)) |
|
15254e32d299
central management of Document.Overlays, independent of Document_Model;
wenzelm
parents:
52976
diff
changeset
|
33 |
new Overlays(if (node_overlays.is_empty) rep - name else rep + (name -> node_overlays)) |
|
15254e32d299
central management of Document.Overlays, independent of Document_Model;
wenzelm
parents:
52976
diff
changeset
|
34 |
} |
|
15254e32d299
central management of Document.Overlays, independent of Document_Model;
wenzelm
parents:
52976
diff
changeset
|
35 |
|
|
15254e32d299
central management of Document.Overlays, independent of Document_Model;
wenzelm
parents:
52976
diff
changeset
|
36 |
def insert(command: Command, fn: String, args: List[String]): Overlays = |
|
15254e32d299
central management of Document.Overlays, independent of Document_Model;
wenzelm
parents:
52976
diff
changeset
|
37 |
update(command.node_name, _.insert(command, fn, args)) |
|
15254e32d299
central management of Document.Overlays, independent of Document_Model;
wenzelm
parents:
52976
diff
changeset
|
38 |
|
|
15254e32d299
central management of Document.Overlays, independent of Document_Model;
wenzelm
parents:
52976
diff
changeset
|
39 |
def remove(command: Command, fn: String, args: List[String]): Overlays = |
|
15254e32d299
central management of Document.Overlays, independent of Document_Model;
wenzelm
parents:
52976
diff
changeset
|
40 |
update(command.node_name, _.remove(command, fn, args)) |
|
15254e32d299
central management of Document.Overlays, independent of Document_Model;
wenzelm
parents:
52976
diff
changeset
|
41 |
} |
|
15254e32d299
central management of Document.Overlays, independent of Document_Model;
wenzelm
parents:
52976
diff
changeset
|
42 |
|
|
15254e32d299
central management of Document.Overlays, independent of Document_Model;
wenzelm
parents:
52976
diff
changeset
|
43 |
|
| 46723 | 44 |
/* individual nodes */ |
| 38424 | 45 |
|
| 44615 | 46 |
type Edit[A, B] = (Node.Name, Node.Edit[A, B]) |
| 44384 | 47 |
type Edit_Text = Edit[Text.Edit, Text.Perspective] |
| 52849 | 48 |
type Edit_Command = Edit[Command.Edit, Command.Perspective] |
| 38151 | 49 |
|
|
54521
744ea0025e11
clarified Document.Blobs environment vs. actual edits of auxiliary files;
wenzelm
parents:
54519
diff
changeset
|
50 |
type Blobs = Map[Node.Name, Bytes] |
|
744ea0025e11
clarified Document.Blobs environment vs. actual edits of auxiliary files;
wenzelm
parents:
54519
diff
changeset
|
51 |
|
| 38151 | 52 |
object Node |
53 |
{
|
|
| 52887 | 54 |
val empty: Node = new Node() |
55 |
||
56 |
||
57 |
/* header and name */ |
|
58 |
||
|
48707
ba531af91148
simplified Document.Node.Header -- internalized errors;
wenzelm
parents:
48706
diff
changeset
|
59 |
sealed case class Header( |
|
46938
cda018294515
some support for outer syntax keyword declarations within theory header;
wenzelm
parents:
46814
diff
changeset
|
60 |
imports: List[Name], |
| 48706 | 61 |
keywords: Thy_Header.Keywords, |
|
48707
ba531af91148
simplified Document.Node.Header -- internalized errors;
wenzelm
parents:
48706
diff
changeset
|
62 |
errors: List[String] = Nil) |
|
ba531af91148
simplified Document.Node.Header -- internalized errors;
wenzelm
parents:
48706
diff
changeset
|
63 |
{
|
|
ba531af91148
simplified Document.Node.Header -- internalized errors;
wenzelm
parents:
48706
diff
changeset
|
64 |
def error(msg: String): Header = copy(errors = errors ::: List(msg)) |
|
54549
2a3053472ec3
actually expose errors of cumulative theory dependencies;
wenzelm
parents:
54530
diff
changeset
|
65 |
|
|
2a3053472ec3
actually expose errors of cumulative theory dependencies;
wenzelm
parents:
54530
diff
changeset
|
66 |
def cat_errors(msg2: String): Header = |
|
2a3053472ec3
actually expose errors of cumulative theory dependencies;
wenzelm
parents:
54530
diff
changeset
|
67 |
copy(errors = errors.map(msg1 => Library.cat_message(msg1, msg2))) |
|
48707
ba531af91148
simplified Document.Node.Header -- internalized errors;
wenzelm
parents:
48706
diff
changeset
|
68 |
} |
|
ba531af91148
simplified Document.Node.Header -- internalized errors;
wenzelm
parents:
48706
diff
changeset
|
69 |
|
|
51294
0850d43cb355
discontinued obsolete header "files" -- these are loaded explicitly after exploring dependencies;
wenzelm
parents:
51293
diff
changeset
|
70 |
def bad_header(msg: String): Header = Header(Nil, Nil, List(msg)) |
| 46737 | 71 |
|
|
54509
1f77110c94ef
maintain document model for all files, with document view for theory only, and special blob for non-theory files;
wenzelm
parents:
54462
diff
changeset
|
72 |
val no_header = bad_header("No theory header")
|
|
1f77110c94ef
maintain document model for all files, with document view for theory only, and special blob for non-theory files;
wenzelm
parents:
54462
diff
changeset
|
73 |
|
|
44957
098dd95349e7
more elaborate Node_Renderer, which paints node_name.theory only;
wenzelm
parents:
44676
diff
changeset
|
74 |
object Name |
|
098dd95349e7
more elaborate Node_Renderer, which paints node_name.theory only;
wenzelm
parents:
44676
diff
changeset
|
75 |
{
|
| 54515 | 76 |
val empty = Name("")
|
| 46723 | 77 |
|
78 |
object Ordering extends scala.math.Ordering[Name] |
|
79 |
{
|
|
80 |
def compare(name1: Name, name2: Name): Int = name1.node compare name2.node |
|
81 |
} |
|
|
44957
098dd95349e7
more elaborate Node_Renderer, which paints node_name.theory only;
wenzelm
parents:
44676
diff
changeset
|
82 |
} |
| 52887 | 83 |
|
| 54515 | 84 |
sealed case class Name(node: String, master_dir: String = "", theory: String = "") |
| 44615 | 85 |
{
|
86 |
override def hashCode: Int = node.hashCode |
|
87 |
override def equals(that: Any): Boolean = |
|
88 |
that match {
|
|
89 |
case other: Name => node == other.node |
|
90 |
case _ => false |
|
91 |
} |
|
|
54509
1f77110c94ef
maintain document model for all files, with document view for theory only, and special blob for non-theory files;
wenzelm
parents:
54462
diff
changeset
|
92 |
|
|
1f77110c94ef
maintain document model for all files, with document view for theory only, and special blob for non-theory files;
wenzelm
parents:
54462
diff
changeset
|
93 |
def is_theory: Boolean = !theory.isEmpty |
| 54510 | 94 |
override def toString: String = if (is_theory) theory else node |
| 44615 | 95 |
} |
96 |
||
| 52887 | 97 |
|
|
52977
15254e32d299
central management of Document.Overlays, independent of Document_Model;
wenzelm
parents:
52976
diff
changeset
|
98 |
/* node overlays */ |
| 52887 | 99 |
|
100 |
object Overlays |
|
101 |
{
|
|
| 52976 | 102 |
val empty = new Overlays(Multi_Map.empty) |
| 52887 | 103 |
} |
104 |
||
|
52977
15254e32d299
central management of Document.Overlays, independent of Document_Model;
wenzelm
parents:
52976
diff
changeset
|
105 |
final class Overlays private(rep: Multi_Map[Command, (String, List[String])]) |
| 52887 | 106 |
{
|
107 |
def commands: Set[Command] = rep.keySet |
|
108 |
def is_empty: Boolean = rep.isEmpty |
|
|
52977
15254e32d299
central management of Document.Overlays, independent of Document_Model;
wenzelm
parents:
52976
diff
changeset
|
109 |
def dest: List[(Command, (String, List[String]))] = rep.iterator.toList |
|
15254e32d299
central management of Document.Overlays, independent of Document_Model;
wenzelm
parents:
52976
diff
changeset
|
110 |
def insert(cmd: Command, fn: String, args: List[String]): Overlays = |
|
15254e32d299
central management of Document.Overlays, independent of Document_Model;
wenzelm
parents:
52976
diff
changeset
|
111 |
new Overlays(rep.insert(cmd, (fn, args))) |
|
15254e32d299
central management of Document.Overlays, independent of Document_Model;
wenzelm
parents:
52976
diff
changeset
|
112 |
def remove(cmd: Command, fn: String, args: List[String]): Overlays = |
|
15254e32d299
central management of Document.Overlays, independent of Document_Model;
wenzelm
parents:
52976
diff
changeset
|
113 |
new Overlays(rep.remove(cmd, (fn, args))) |
| 52887 | 114 |
} |
115 |
||
116 |
||
117 |
/* edits */ |
|
118 |
||
| 44384 | 119 |
sealed abstract class Edit[A, B] |
| 44156 | 120 |
{
|
| 44383 | 121 |
def foreach(f: A => Unit) |
122 |
{
|
|
| 44156 | 123 |
this match {
|
| 44383 | 124 |
case Edits(es) => es.foreach(f) |
125 |
case _ => |
|
| 44156 | 126 |
} |
| 44383 | 127 |
} |
| 44156 | 128 |
} |
| 44384 | 129 |
case class Clear[A, B]() extends Edit[A, B] |
|
54562
301a721af68b
clarified node edits sent to prover -- Clear/Blob only required for text edits within editor;
wenzelm
parents:
54549
diff
changeset
|
130 |
case class Blob[A, B]() extends Edit[A, B] |
|
301a721af68b
clarified node edits sent to prover -- Clear/Blob only required for text edits within editor;
wenzelm
parents:
54549
diff
changeset
|
131 |
|
| 44384 | 132 |
case class Edits[A, B](edits: List[A]) extends Edit[A, B] |
|
48707
ba531af91148
simplified Document.Node.Header -- internalized errors;
wenzelm
parents:
48706
diff
changeset
|
133 |
case class Deps[A, B](header: Header) extends Edit[A, B] |
| 52849 | 134 |
case class Perspective[A, B](required: Boolean, visible: B, overlays: Overlays) extends Edit[A, B] |
|
52808
143f225e50f5
allow explicit indication of required node: full eval, no prints;
wenzelm
parents:
52568
diff
changeset
|
135 |
type Perspective_Text = Perspective[Text.Edit, Text.Perspective] |
| 52849 | 136 |
type Perspective_Command = Perspective[Command.Edit, Command.Perspective] |
| 44156 | 137 |
|
| 52887 | 138 |
|
139 |
/* commands */ |
|
140 |
||
|
52901
8be75f53db82
maintain commands together with index -- avoid redundant reconstruction of full_index;
wenzelm
parents:
52900
diff
changeset
|
141 |
object Commands |
|
8be75f53db82
maintain commands together with index -- avoid redundant reconstruction of full_index;
wenzelm
parents:
52900
diff
changeset
|
142 |
{
|
|
8be75f53db82
maintain commands together with index -- avoid redundant reconstruction of full_index;
wenzelm
parents:
52900
diff
changeset
|
143 |
def apply(commands: Linear_Set[Command]): Commands = new Commands(commands) |
|
8be75f53db82
maintain commands together with index -- avoid redundant reconstruction of full_index;
wenzelm
parents:
52900
diff
changeset
|
144 |
val empty: Commands = apply(Linear_Set.empty) |
|
8be75f53db82
maintain commands together with index -- avoid redundant reconstruction of full_index;
wenzelm
parents:
52900
diff
changeset
|
145 |
|
|
8be75f53db82
maintain commands together with index -- avoid redundant reconstruction of full_index;
wenzelm
parents:
52900
diff
changeset
|
146 |
def starts(commands: Iterator[Command], offset: Text.Offset = 0) |
|
8be75f53db82
maintain commands together with index -- avoid redundant reconstruction of full_index;
wenzelm
parents:
52900
diff
changeset
|
147 |
: Iterator[(Command, Text.Offset)] = |
|
8be75f53db82
maintain commands together with index -- avoid redundant reconstruction of full_index;
wenzelm
parents:
52900
diff
changeset
|
148 |
{
|
|
8be75f53db82
maintain commands together with index -- avoid redundant reconstruction of full_index;
wenzelm
parents:
52900
diff
changeset
|
149 |
var i = offset |
|
8be75f53db82
maintain commands together with index -- avoid redundant reconstruction of full_index;
wenzelm
parents:
52900
diff
changeset
|
150 |
for (command <- commands) yield {
|
|
8be75f53db82
maintain commands together with index -- avoid redundant reconstruction of full_index;
wenzelm
parents:
52900
diff
changeset
|
151 |
val start = i |
|
8be75f53db82
maintain commands together with index -- avoid redundant reconstruction of full_index;
wenzelm
parents:
52900
diff
changeset
|
152 |
i += command.length |
|
8be75f53db82
maintain commands together with index -- avoid redundant reconstruction of full_index;
wenzelm
parents:
52900
diff
changeset
|
153 |
(command, start) |
|
8be75f53db82
maintain commands together with index -- avoid redundant reconstruction of full_index;
wenzelm
parents:
52900
diff
changeset
|
154 |
} |
|
8be75f53db82
maintain commands together with index -- avoid redundant reconstruction of full_index;
wenzelm
parents:
52900
diff
changeset
|
155 |
} |
|
8be75f53db82
maintain commands together with index -- avoid redundant reconstruction of full_index;
wenzelm
parents:
52900
diff
changeset
|
156 |
|
|
8be75f53db82
maintain commands together with index -- avoid redundant reconstruction of full_index;
wenzelm
parents:
52900
diff
changeset
|
157 |
private val block_size = 1024 |
|
8be75f53db82
maintain commands together with index -- avoid redundant reconstruction of full_index;
wenzelm
parents:
52900
diff
changeset
|
158 |
} |
|
8be75f53db82
maintain commands together with index -- avoid redundant reconstruction of full_index;
wenzelm
parents:
52900
diff
changeset
|
159 |
|
|
8be75f53db82
maintain commands together with index -- avoid redundant reconstruction of full_index;
wenzelm
parents:
52900
diff
changeset
|
160 |
final class Commands private(val commands: Linear_Set[Command]) |
|
38227
6bbb42843b6e
concentrate structural document notions in document.scala;
wenzelm
parents:
38220
diff
changeset
|
161 |
{
|
| 54462 | 162 |
lazy val thy_load_commands: List[Command] = |
| 54513 | 163 |
commands.iterator.filter(cmd => !cmd.blobs.isEmpty).toList |
| 54462 | 164 |
|
|
52901
8be75f53db82
maintain commands together with index -- avoid redundant reconstruction of full_index;
wenzelm
parents:
52900
diff
changeset
|
165 |
private lazy val full_index: (Array[(Command, Text.Offset)], Text.Range) = |
|
8be75f53db82
maintain commands together with index -- avoid redundant reconstruction of full_index;
wenzelm
parents:
52900
diff
changeset
|
166 |
{
|
|
8be75f53db82
maintain commands together with index -- avoid redundant reconstruction of full_index;
wenzelm
parents:
52900
diff
changeset
|
167 |
val blocks = new mutable.ListBuffer[(Command, Text.Offset)] |
|
8be75f53db82
maintain commands together with index -- avoid redundant reconstruction of full_index;
wenzelm
parents:
52900
diff
changeset
|
168 |
var next_block = 0 |
|
8be75f53db82
maintain commands together with index -- avoid redundant reconstruction of full_index;
wenzelm
parents:
52900
diff
changeset
|
169 |
var last_stop = 0 |
|
8be75f53db82
maintain commands together with index -- avoid redundant reconstruction of full_index;
wenzelm
parents:
52900
diff
changeset
|
170 |
for ((command, start) <- Commands.starts(commands.iterator)) {
|
|
8be75f53db82
maintain commands together with index -- avoid redundant reconstruction of full_index;
wenzelm
parents:
52900
diff
changeset
|
171 |
last_stop = start + command.length |
|
8be75f53db82
maintain commands together with index -- avoid redundant reconstruction of full_index;
wenzelm
parents:
52900
diff
changeset
|
172 |
while (last_stop + 1 > next_block) {
|
|
8be75f53db82
maintain commands together with index -- avoid redundant reconstruction of full_index;
wenzelm
parents:
52900
diff
changeset
|
173 |
blocks += (command -> start) |
|
8be75f53db82
maintain commands together with index -- avoid redundant reconstruction of full_index;
wenzelm
parents:
52900
diff
changeset
|
174 |
next_block += Commands.block_size |
|
8be75f53db82
maintain commands together with index -- avoid redundant reconstruction of full_index;
wenzelm
parents:
52900
diff
changeset
|
175 |
} |
|
8be75f53db82
maintain commands together with index -- avoid redundant reconstruction of full_index;
wenzelm
parents:
52900
diff
changeset
|
176 |
} |
|
8be75f53db82
maintain commands together with index -- avoid redundant reconstruction of full_index;
wenzelm
parents:
52900
diff
changeset
|
177 |
(blocks.toArray, Text.Range(0, last_stop)) |
|
8be75f53db82
maintain commands together with index -- avoid redundant reconstruction of full_index;
wenzelm
parents:
52900
diff
changeset
|
178 |
} |
|
8be75f53db82
maintain commands together with index -- avoid redundant reconstruction of full_index;
wenzelm
parents:
52900
diff
changeset
|
179 |
|
|
8be75f53db82
maintain commands together with index -- avoid redundant reconstruction of full_index;
wenzelm
parents:
52900
diff
changeset
|
180 |
private def full_range: Text.Range = full_index._2 |
|
8be75f53db82
maintain commands together with index -- avoid redundant reconstruction of full_index;
wenzelm
parents:
52900
diff
changeset
|
181 |
|
|
8be75f53db82
maintain commands together with index -- avoid redundant reconstruction of full_index;
wenzelm
parents:
52900
diff
changeset
|
182 |
def range(i: Text.Offset = 0): Iterator[(Command, Text.Offset)] = |
|
8be75f53db82
maintain commands together with index -- avoid redundant reconstruction of full_index;
wenzelm
parents:
52900
diff
changeset
|
183 |
{
|
|
8be75f53db82
maintain commands together with index -- avoid redundant reconstruction of full_index;
wenzelm
parents:
52900
diff
changeset
|
184 |
if (!commands.isEmpty && full_range.contains(i)) {
|
|
8be75f53db82
maintain commands together with index -- avoid redundant reconstruction of full_index;
wenzelm
parents:
52900
diff
changeset
|
185 |
val (cmd0, start0) = full_index._1(i / Commands.block_size) |
|
8be75f53db82
maintain commands together with index -- avoid redundant reconstruction of full_index;
wenzelm
parents:
52900
diff
changeset
|
186 |
Node.Commands.starts(commands.iterator(cmd0), start0) dropWhile {
|
|
8be75f53db82
maintain commands together with index -- avoid redundant reconstruction of full_index;
wenzelm
parents:
52900
diff
changeset
|
187 |
case (cmd, start) => start + cmd.length <= i } |
|
8be75f53db82
maintain commands together with index -- avoid redundant reconstruction of full_index;
wenzelm
parents:
52900
diff
changeset
|
188 |
} |
|
8be75f53db82
maintain commands together with index -- avoid redundant reconstruction of full_index;
wenzelm
parents:
52900
diff
changeset
|
189 |
else Iterator.empty |
|
38227
6bbb42843b6e
concentrate structural document notions in document.scala;
wenzelm
parents:
38220
diff
changeset
|
190 |
} |
|
6bbb42843b6e
concentrate structural document notions in document.scala;
wenzelm
parents:
38220
diff
changeset
|
191 |
} |
| 38151 | 192 |
} |
193 |
||
| 46712 | 194 |
final class Node private( |
|
48707
ba531af91148
simplified Document.Node.Header -- internalized errors;
wenzelm
parents:
48706
diff
changeset
|
195 |
val header: Node.Header = Node.bad_header("Bad theory header"),
|
| 52849 | 196 |
val perspective: Node.Perspective_Command = |
| 52887 | 197 |
Node.Perspective(false, Command.Perspective.empty, Node.Overlays.empty), |
|
52901
8be75f53db82
maintain commands together with index -- avoid redundant reconstruction of full_index;
wenzelm
parents:
52900
diff
changeset
|
198 |
_commands: Node.Commands = Node.Commands.empty) |
| 38151 | 199 |
{
|
| 46680 | 200 |
def clear: Node = new Node(header = header) |
201 |
||
|
48707
ba531af91148
simplified Document.Node.Header -- internalized errors;
wenzelm
parents:
48706
diff
changeset
|
202 |
def update_header(new_header: Node.Header): Node = |
| 54513 | 203 |
new Node(new_header, perspective, _commands) |
| 46680 | 204 |
|
| 52849 | 205 |
def update_perspective(new_perspective: Node.Perspective_Command): Node = |
| 54513 | 206 |
new Node(header, new_perspective, _commands) |
| 46680 | 207 |
|
| 52849 | 208 |
def same_perspective(other_perspective: Node.Perspective_Command): Boolean = |
209 |
perspective.required == other_perspective.required && |
|
210 |
perspective.visible.same(other_perspective.visible) && |
|
211 |
perspective.overlays == other_perspective.overlays |
|
|
52808
143f225e50f5
allow explicit indication of required node: full eval, no prints;
wenzelm
parents:
52568
diff
changeset
|
212 |
|
|
52901
8be75f53db82
maintain commands together with index -- avoid redundant reconstruction of full_index;
wenzelm
parents:
52900
diff
changeset
|
213 |
def commands: Linear_Set[Command] = _commands.commands |
| 54462 | 214 |
def thy_load_commands: List[Command] = _commands.thy_load_commands |
|
43697
77ce24aa1770
explicit Document.Node.Header, with master_dir and thy_name;
wenzelm
parents:
43662
diff
changeset
|
215 |
|
|
52901
8be75f53db82
maintain commands together with index -- avoid redundant reconstruction of full_index;
wenzelm
parents:
52900
diff
changeset
|
216 |
def update_commands(new_commands: Linear_Set[Command]): Node = |
|
52918
038458a4d11b
proper low-level comparison -- heed warning by Scala compiler;
wenzelm
parents:
52901
diff
changeset
|
217 |
if (new_commands eq _commands.commands) this |
| 54513 | 218 |
else new Node(header, perspective, Node.Commands(new_commands)) |
| 38151 | 219 |
|
| 38569 | 220 |
def command_range(i: Text.Offset = 0): Iterator[(Command, Text.Offset)] = |
|
52901
8be75f53db82
maintain commands together with index -- avoid redundant reconstruction of full_index;
wenzelm
parents:
52900
diff
changeset
|
221 |
_commands.range(i) |
| 38151 | 222 |
|
| 38569 | 223 |
def command_range(range: Text.Range): Iterator[(Command, Text.Offset)] = |
224 |
command_range(range.start) takeWhile { case (_, start) => start < range.stop }
|
|
| 38151 | 225 |
|
|
38879
dde403450419
Document.Node: significant speedup of command_range etc. via lazy full_index;
wenzelm
parents:
38872
diff
changeset
|
226 |
def command_start(cmd: Command): Option[Text.Offset] = |
|
52901
8be75f53db82
maintain commands together with index -- avoid redundant reconstruction of full_index;
wenzelm
parents:
52900
diff
changeset
|
227 |
Node.Commands.starts(commands.iterator).find(_._1 == cmd).map(_._2) |
| 38151 | 228 |
} |
229 |
||
230 |
||
| 46723 | 231 |
/* development graph */ |
232 |
||
233 |
object Nodes |
|
234 |
{
|
|
235 |
val empty: Nodes = new Nodes(Graph.empty(Node.Name.Ordering)) |
|
236 |
} |
|
237 |
||
238 |
final class Nodes private(graph: Graph[Node.Name, Node]) |
|
239 |
{
|
|
240 |
def get_name(s: String): Option[Node.Name] = |
|
241 |
graph.keys.find(name => name.node == s) |
|
242 |
||
243 |
def apply(name: Node.Name): Node = |
|
244 |
graph.default_node(name, Node.empty).get_node(name) |
|
245 |
||
246 |
def + (entry: (Node.Name, Node)): Nodes = |
|
247 |
{
|
|
248 |
val (name, node) = entry |
|
|
48707
ba531af91148
simplified Document.Node.Header -- internalized errors;
wenzelm
parents:
48706
diff
changeset
|
249 |
val imports = node.header.imports |
| 46723 | 250 |
val graph1 = |
|
46739
6024353549ca
clarified document nodes (full import graph) vs. node_status (non-preloaded theories);
wenzelm
parents:
46737
diff
changeset
|
251 |
(graph.default_node(name, Node.empty) /: imports)((g, p) => g.default_node(p, Node.empty)) |
| 46723 | 252 |
val graph2 = (graph1 /: graph1.imm_preds(name))((g, dep) => g.del_edge(dep, name)) |
|
46739
6024353549ca
clarified document nodes (full import graph) vs. node_status (non-preloaded theories);
wenzelm
parents:
46737
diff
changeset
|
253 |
val graph3 = (graph2 /: imports)((g, dep) => g.add_edge(dep, name)) |
| 46723 | 254 |
new Nodes(graph3.map_node(name, _ => node)) |
255 |
} |
|
256 |
||
257 |
def entries: Iterator[(Node.Name, Node)] = |
|
258 |
graph.entries.map({ case (name, (node, _)) => (name, node) })
|
|
259 |
||
| 54528 | 260 |
def thy_load_commands(file_name: Node.Name): List[Command] = |
261 |
(for {
|
|
262 |
(_, node) <- entries |
|
263 |
cmd <- node.thy_load_commands.iterator |
|
|
54530
2c1440f70028
ranges of thy_load commands count as visible within perspective;
wenzelm
parents:
54528
diff
changeset
|
264 |
name <- cmd.blobs_names.iterator |
| 54528 | 265 |
if name == file_name |
266 |
} yield cmd).toList |
|
267 |
||
|
46942
f5c2d66faa04
basic support for outer syntax keywords in theory header;
wenzelm
parents:
46941
diff
changeset
|
268 |
def descendants(names: List[Node.Name]): List[Node.Name] = graph.all_succs(names) |
| 46723 | 269 |
def topological_order: List[Node.Name] = graph.topological_order |
270 |
} |
|
271 |
||
272 |
||
| 38424 | 273 |
|
274 |
/** versioning **/ |
|
275 |
||
276 |
/* particular document versions */ |
|
| 34485 | 277 |
|
| 38417 | 278 |
object Version |
279 |
{
|
|
| 46681 | 280 |
val init: Version = new Version() |
281 |
||
| 46941 | 282 |
def make(syntax: Outer_Syntax, nodes: Nodes): Version = |
|
52530
99dd8b4ef3fe
explicit module Document_ID as source of globally unique identifiers across ML/Scala;
wenzelm
parents:
52527
diff
changeset
|
283 |
new Version(Document_ID.make(), syntax, nodes) |
| 38417 | 284 |
} |
285 |
||
| 46712 | 286 |
final class Version private( |
|
52530
99dd8b4ef3fe
explicit module Document_ID as source of globally unique identifiers across ML/Scala;
wenzelm
parents:
52527
diff
changeset
|
287 |
val id: Document_ID.Version = Document_ID.none, |
| 46941 | 288 |
val syntax: Outer_Syntax = Outer_Syntax.empty, |
| 46723 | 289 |
val nodes: Nodes = Nodes.empty) |
| 46941 | 290 |
{
|
|
52530
99dd8b4ef3fe
explicit module Document_ID as source of globally unique identifiers across ML/Scala;
wenzelm
parents:
52527
diff
changeset
|
291 |
def is_init: Boolean = id == Document_ID.none |
| 46941 | 292 |
} |
| 34660 | 293 |
|
| 34859 | 294 |
|
| 38424 | 295 |
/* changes of plain text, eventually resulting in document edits */ |
|
38227
6bbb42843b6e
concentrate structural document notions in document.scala;
wenzelm
parents:
38220
diff
changeset
|
296 |
|
|
6bbb42843b6e
concentrate structural document notions in document.scala;
wenzelm
parents:
38220
diff
changeset
|
297 |
object Change |
|
6bbb42843b6e
concentrate structural document notions in document.scala;
wenzelm
parents:
38220
diff
changeset
|
298 |
{
|
| 46678 | 299 |
val init: Change = new Change() |
300 |
||
301 |
def make(previous: Future[Version], edits: List[Edit_Text], version: Future[Version]): Change = |
|
302 |
new Change(Some(previous), edits, version) |
|
|
38227
6bbb42843b6e
concentrate structural document notions in document.scala;
wenzelm
parents:
38220
diff
changeset
|
303 |
} |
|
6bbb42843b6e
concentrate structural document notions in document.scala;
wenzelm
parents:
38220
diff
changeset
|
304 |
|
| 46712 | 305 |
final class Change private( |
| 46677 | 306 |
val previous: Option[Future[Version]] = Some(Future.value(Version.init)), |
307 |
val edits: List[Edit_Text] = Nil, |
|
308 |
val version: Future[Version] = Future.value(Version.init)) |
|
|
38227
6bbb42843b6e
concentrate structural document notions in document.scala;
wenzelm
parents:
38220
diff
changeset
|
309 |
{
|
| 44672 | 310 |
def is_finished: Boolean = |
311 |
(previous match { case None => true case Some(future) => future.is_finished }) &&
|
|
312 |
version.is_finished |
|
313 |
||
| 46678 | 314 |
def truncate: Change = new Change(None, Nil, version) |
|
38227
6bbb42843b6e
concentrate structural document notions in document.scala;
wenzelm
parents:
38220
diff
changeset
|
315 |
} |
|
6bbb42843b6e
concentrate structural document notions in document.scala;
wenzelm
parents:
38220
diff
changeset
|
316 |
|
|
6bbb42843b6e
concentrate structural document notions in document.scala;
wenzelm
parents:
38220
diff
changeset
|
317 |
|
|
38841
4df7b76249a0
include Document.History in Document.State -- just one universal session state maintained by main actor;
wenzelm
parents:
38569
diff
changeset
|
318 |
/* history navigation */ |
|
4df7b76249a0
include Document.History in Document.State -- just one universal session state maintained by main actor;
wenzelm
parents:
38569
diff
changeset
|
319 |
|
|
4df7b76249a0
include Document.History in Document.State -- just one universal session state maintained by main actor;
wenzelm
parents:
38569
diff
changeset
|
320 |
object History |
|
4df7b76249a0
include Document.History in Document.State -- just one universal session state maintained by main actor;
wenzelm
parents:
38569
diff
changeset
|
321 |
{
|
| 46679 | 322 |
val init: History = new History() |
|
38841
4df7b76249a0
include Document.History in Document.State -- just one universal session state maintained by main actor;
wenzelm
parents:
38569
diff
changeset
|
323 |
} |
|
4df7b76249a0
include Document.History in Document.State -- just one universal session state maintained by main actor;
wenzelm
parents:
38569
diff
changeset
|
324 |
|
| 46712 | 325 |
final class History private( |
| 46679 | 326 |
val undo_list: List[Change] = List(Change.init)) // non-empty list |
|
38841
4df7b76249a0
include Document.History in Document.State -- just one universal session state maintained by main actor;
wenzelm
parents:
38569
diff
changeset
|
327 |
{
|
| 46679 | 328 |
def tip: Change = undo_list.head |
329 |
def + (change: Change): History = new History(change :: undo_list) |
|
|
38841
4df7b76249a0
include Document.History in Document.State -- just one universal session state maintained by main actor;
wenzelm
parents:
38569
diff
changeset
|
330 |
|
| 46679 | 331 |
def prune(check: Change => Boolean, retain: Int): Option[(List[Change], History)] = |
332 |
{
|
|
333 |
val n = undo_list.iterator.zipWithIndex.find(p => check(p._1)).get._2 + 1 |
|
334 |
val (retained, dropped) = undo_list.splitAt(n max retain) |
|
335 |
||
336 |
retained.splitAt(retained.length - 1) match {
|
|
337 |
case (prefix, List(last)) => Some(dropped, new History(prefix ::: List(last.truncate))) |
|
338 |
case _ => None |
|
339 |
} |
|
340 |
} |
|
|
38841
4df7b76249a0
include Document.History in Document.State -- just one universal session state maintained by main actor;
wenzelm
parents:
38569
diff
changeset
|
341 |
} |
|
4df7b76249a0
include Document.History in Document.State -- just one universal session state maintained by main actor;
wenzelm
parents:
38569
diff
changeset
|
342 |
|
|
4df7b76249a0
include Document.History in Document.State -- just one universal session state maintained by main actor;
wenzelm
parents:
38569
diff
changeset
|
343 |
|
|
4df7b76249a0
include Document.History in Document.State -- just one universal session state maintained by main actor;
wenzelm
parents:
38569
diff
changeset
|
344 |
|
|
4df7b76249a0
include Document.History in Document.State -- just one universal session state maintained by main actor;
wenzelm
parents:
38569
diff
changeset
|
345 |
/** global state -- document structure, execution process, editing history **/ |
| 38424 | 346 |
|
| 52972 | 347 |
object Snapshot |
348 |
{
|
|
349 |
val init = State.init.snapshot() |
|
350 |
} |
|
351 |
||
| 38424 | 352 |
abstract class Snapshot |
353 |
{
|
|
| 44582 | 354 |
val state: State |
| 38424 | 355 |
val version: Version |
356 |
val is_outdated: Boolean |
|
| 38427 | 357 |
def convert(i: Text.Offset): Text.Offset |
|
52889
ea3338812e67
more tight interface for markup cumulate/select: avoid duplicate application, allow to defer decision about definedness;
wenzelm
parents:
52887
diff
changeset
|
358 |
def revert(i: Text.Offset): Text.Offset |
|
39177
0468964aec11
simplified Markup_Tree.select: Stream instead of Iterator (again), explicit Option instead of default;
wenzelm
parents:
38976
diff
changeset
|
359 |
def convert(range: Text.Range): Text.Range |
|
0468964aec11
simplified Markup_Tree.select: Stream instead of Iterator (again), explicit Option instead of default;
wenzelm
parents:
38976
diff
changeset
|
360 |
def revert(range: Text.Range): Text.Range |
| 52972 | 361 |
|
362 |
val node_name: Node.Name |
|
363 |
val node: Node |
|
| 51494 | 364 |
def eq_content(other: Snapshot): Boolean |
| 52508 | 365 |
def cumulate_markup[A]( |
366 |
range: Text.Range, |
|
367 |
info: A, |
|
368 |
elements: Option[Set[String]], |
|
|
52900
d29bf6db8a2d
more elementary list structures for markup tree traversal;
wenzelm
parents:
52889
diff
changeset
|
369 |
result: Command.State => (A, Text.Markup) => Option[A]): List[Text.Info[A]] |
| 52508 | 370 |
def select_markup[A]( |
371 |
range: Text.Range, |
|
372 |
elements: Option[Set[String]], |
|
|
52900
d29bf6db8a2d
more elementary list structures for markup tree traversal;
wenzelm
parents:
52889
diff
changeset
|
373 |
result: Command.State => Text.Markup => Option[A]): List[Text.Info[A]] |
| 38424 | 374 |
} |
375 |
||
| 52563 | 376 |
type Assign_Update = |
377 |
List[(Document_ID.Command, List[Document_ID.Exec])] // update of exec state assignment |
|
|
44476
e8a87398f35d
propagate information about last command with exec state assignment through document model;
wenzelm
parents:
44475
diff
changeset
|
378 |
|
|
38370
8b15d0f98962
explicit Document.State value, instead of individual state variables in Session, Command, Document;
wenzelm
parents:
38367
diff
changeset
|
379 |
object State |
|
8b15d0f98962
explicit Document.State value, instead of individual state variables in Session, Command, Document;
wenzelm
parents:
38367
diff
changeset
|
380 |
{
|
| 38373 | 381 |
class Fail(state: State) extends Exception |
382 |
||
|
44479
9a04e7502e22
refined document state assignment: observe perspective, more explicit assignment message;
wenzelm
parents:
44477
diff
changeset
|
383 |
object Assignment |
|
9a04e7502e22
refined document state assignment: observe perspective, more explicit assignment message;
wenzelm
parents:
44477
diff
changeset
|
384 |
{
|
| 46683 | 385 |
val init: Assignment = new Assignment() |
|
44479
9a04e7502e22
refined document state assignment: observe perspective, more explicit assignment message;
wenzelm
parents:
44477
diff
changeset
|
386 |
} |
|
38370
8b15d0f98962
explicit Document.State value, instead of individual state variables in Session, Command, Document;
wenzelm
parents:
38367
diff
changeset
|
387 |
|
| 46712 | 388 |
final class Assignment private( |
|
52530
99dd8b4ef3fe
explicit module Document_ID as source of globally unique identifiers across ML/Scala;
wenzelm
parents:
52527
diff
changeset
|
389 |
val command_execs: Map[Document_ID.Command, List[Document_ID.Exec]] = Map.empty, |
| 46677 | 390 |
val is_finished: Boolean = false) |
|
38370
8b15d0f98962
explicit Document.State value, instead of individual state variables in Session, Command, Document;
wenzelm
parents:
38367
diff
changeset
|
391 |
{
|
| 44477 | 392 |
def check_finished: Assignment = { require(is_finished); this }
|
|
47388
fe4b245af74c
discontinued obsolete last_execs (cf. cd3ab7625519);
wenzelm
parents:
46997
diff
changeset
|
393 |
def unfinished: Assignment = new Assignment(command_execs, false) |
|
44479
9a04e7502e22
refined document state assignment: observe perspective, more explicit assignment message;
wenzelm
parents:
44477
diff
changeset
|
394 |
|
| 52563 | 395 |
def assign(update: Assign_Update): Assignment = |
|
38370
8b15d0f98962
explicit Document.State value, instead of individual state variables in Session, Command, Document;
wenzelm
parents:
38367
diff
changeset
|
396 |
{
|
|
38976
a4a465dc89d9
Document.State.Assignment: eliminated promise in favour of plain values -- signalling is done via event bus in Session;
wenzelm
parents:
38885
diff
changeset
|
397 |
require(!is_finished) |
|
44479
9a04e7502e22
refined document state assignment: observe perspective, more explicit assignment message;
wenzelm
parents:
44477
diff
changeset
|
398 |
val command_execs1 = |
| 52563 | 399 |
(command_execs /: update) {
|
400 |
case (res, (command_id, exec_ids)) => |
|
401 |
if (exec_ids.isEmpty) res - command_id |
|
402 |
else res + (command_id -> exec_ids) |
|
|
44479
9a04e7502e22
refined document state assignment: observe perspective, more explicit assignment message;
wenzelm
parents:
44477
diff
changeset
|
403 |
} |
|
47388
fe4b245af74c
discontinued obsolete last_execs (cf. cd3ab7625519);
wenzelm
parents:
46997
diff
changeset
|
404 |
new Assignment(command_execs1, true) |
|
38150
67fc24df3721
simplified/refined document model: collection of named nodes, without proper dependencies yet;
wenzelm
parents:
37849
diff
changeset
|
405 |
} |
|
38370
8b15d0f98962
explicit Document.State value, instead of individual state variables in Session, Command, Document;
wenzelm
parents:
38367
diff
changeset
|
406 |
} |
| 46682 | 407 |
|
408 |
val init: State = |
|
| 52563 | 409 |
State().define_version(Version.init, Assignment.init).assign(Version.init.id, Nil)._2 |
|
38370
8b15d0f98962
explicit Document.State value, instead of individual state variables in Session, Command, Document;
wenzelm
parents:
38367
diff
changeset
|
410 |
} |
|
8b15d0f98962
explicit Document.State value, instead of individual state variables in Session, Command, Document;
wenzelm
parents:
38367
diff
changeset
|
411 |
|
| 46712 | 412 |
final case class State private( |
|
52530
99dd8b4ef3fe
explicit module Document_ID as source of globally unique identifiers across ML/Scala;
wenzelm
parents:
52527
diff
changeset
|
413 |
val versions: Map[Document_ID.Version, Version] = Map.empty, |
|
54519
5fed81762406
maintain blobs within document state: digest + text in ML, digest-only in Scala;
wenzelm
parents:
54515
diff
changeset
|
414 |
val blobs: Set[SHA1.Digest] = Set.empty, // inlined files |
|
52530
99dd8b4ef3fe
explicit module Document_ID as source of globally unique identifiers across ML/Scala;
wenzelm
parents:
52527
diff
changeset
|
415 |
val commands: Map[Document_ID.Command, Command.State] = Map.empty, // static markup from define_command |
|
99dd8b4ef3fe
explicit module Document_ID as source of globally unique identifiers across ML/Scala;
wenzelm
parents:
52527
diff
changeset
|
416 |
val execs: Map[Document_ID.Exec, Command.State] = Map.empty, // dynamic markup from execution |
|
99dd8b4ef3fe
explicit module Document_ID as source of globally unique identifiers across ML/Scala;
wenzelm
parents:
52527
diff
changeset
|
417 |
val assignments: Map[Document_ID.Version, State.Assignment] = Map.empty, |
|
38841
4df7b76249a0
include Document.History in Document.State -- just one universal session state maintained by main actor;
wenzelm
parents:
38569
diff
changeset
|
418 |
val history: History = History.init) |
|
38370
8b15d0f98962
explicit Document.State value, instead of individual state variables in Session, Command, Document;
wenzelm
parents:
38367
diff
changeset
|
419 |
{
|
| 38373 | 420 |
private def fail[A]: A = throw new State.Fail(this) |
|
38370
8b15d0f98962
explicit Document.State value, instead of individual state variables in Session, Command, Document;
wenzelm
parents:
38367
diff
changeset
|
421 |
|
|
44479
9a04e7502e22
refined document state assignment: observe perspective, more explicit assignment message;
wenzelm
parents:
44477
diff
changeset
|
422 |
def define_version(version: Version, assignment: State.Assignment): State = |
|
38370
8b15d0f98962
explicit Document.State value, instead of individual state variables in Session, Command, Document;
wenzelm
parents:
38367
diff
changeset
|
423 |
{
|
| 38417 | 424 |
val id = version.id |
425 |
copy(versions = versions + (id -> version), |
|
|
44479
9a04e7502e22
refined document state assignment: observe perspective, more explicit assignment message;
wenzelm
parents:
44477
diff
changeset
|
426 |
assignments = assignments + (id -> assignment.unfinished)) |
|
38370
8b15d0f98962
explicit Document.State value, instead of individual state variables in Session, Command, Document;
wenzelm
parents:
38367
diff
changeset
|
427 |
} |
|
8b15d0f98962
explicit Document.State value, instead of individual state variables in Session, Command, Document;
wenzelm
parents:
38367
diff
changeset
|
428 |
|
|
54519
5fed81762406
maintain blobs within document state: digest + text in ML, digest-only in Scala;
wenzelm
parents:
54515
diff
changeset
|
429 |
def define_blob(digest: SHA1.Digest): State = copy(blobs = blobs + digest) |
|
5fed81762406
maintain blobs within document state: digest + text in ML, digest-only in Scala;
wenzelm
parents:
54515
diff
changeset
|
430 |
def defined_blob(digest: SHA1.Digest): Boolean = blobs.contains(digest) |
|
5fed81762406
maintain blobs within document state: digest + text in ML, digest-only in Scala;
wenzelm
parents:
54515
diff
changeset
|
431 |
|
| 38373 | 432 |
def define_command(command: Command): State = |
433 |
{
|
|
434 |
val id = command.id |
|
| 49414 | 435 |
copy(commands = commands + (id -> command.init_state)) |
| 38373 | 436 |
} |
437 |
||
|
52530
99dd8b4ef3fe
explicit module Document_ID as source of globally unique identifiers across ML/Scala;
wenzelm
parents:
52527
diff
changeset
|
438 |
def defined_command(id: Document_ID.Command): Boolean = commands.isDefinedAt(id) |
| 44582 | 439 |
|
| 52531 | 440 |
def find_command(version: Version, id: Document_ID.Generic): Option[(Node, Command)] = |
| 44582 | 441 |
commands.get(id) orElse execs.get(id) match {
|
442 |
case None => None |
|
443 |
case Some(st) => |
|
444 |
val command = st.command |
|
| 46681 | 445 |
val node = version.nodes(command.node_name) |
|
54328
ffa4e0b1701e
more strict find_command -- avoid invalid hyperlink_command;
wenzelm
parents:
52978
diff
changeset
|
446 |
if (node.commands.contains(command)) Some((node, command)) else None |
| 44582 | 447 |
} |
| 38373 | 448 |
|
|
52530
99dd8b4ef3fe
explicit module Document_ID as source of globally unique identifiers across ML/Scala;
wenzelm
parents:
52527
diff
changeset
|
449 |
def the_version(id: Document_ID.Version): Version = versions.getOrElse(id, fail) |
|
52564
4e855c120f6a
tuned signature -- NB: Command.read is actually part of Command.eval;
wenzelm
parents:
52563
diff
changeset
|
450 |
def the_static_state(id: Document_ID.Command): Command.State = commands.getOrElse(id, fail) |
|
4e855c120f6a
tuned signature -- NB: Command.read is actually part of Command.eval;
wenzelm
parents:
52563
diff
changeset
|
451 |
def the_dynamic_state(id: Document_ID.Exec): Command.State = execs.getOrElse(id, fail) |
| 52563 | 452 |
def the_assignment(version: Version): State.Assignment = assignments.getOrElse(version.id, fail) |
|
38370
8b15d0f98962
explicit Document.State value, instead of individual state variables in Session, Command, Document;
wenzelm
parents:
38367
diff
changeset
|
453 |
|
| 52531 | 454 |
def accumulate(id: Document_ID.Generic, message: XML.Elem): (Command.State, State) = |
|
38370
8b15d0f98962
explicit Document.State value, instead of individual state variables in Session, Command, Document;
wenzelm
parents:
38367
diff
changeset
|
455 |
execs.get(id) match {
|
| 44446 | 456 |
case Some(st) => |
| 49527 | 457 |
val new_st = st + (id, message) |
| 44446 | 458 |
(new_st, copy(execs = execs + (id -> new_st))) |
|
38370
8b15d0f98962
explicit Document.State value, instead of individual state variables in Session, Command, Document;
wenzelm
parents:
38367
diff
changeset
|
459 |
case None => |
|
8b15d0f98962
explicit Document.State value, instead of individual state variables in Session, Command, Document;
wenzelm
parents:
38367
diff
changeset
|
460 |
commands.get(id) match {
|
|
8b15d0f98962
explicit Document.State value, instead of individual state variables in Session, Command, Document;
wenzelm
parents:
38367
diff
changeset
|
461 |
case Some(st) => |
| 49527 | 462 |
val new_st = st + (id, message) |
|
38370
8b15d0f98962
explicit Document.State value, instead of individual state variables in Session, Command, Document;
wenzelm
parents:
38367
diff
changeset
|
463 |
(new_st, copy(commands = commands + (id -> new_st))) |
|
8b15d0f98962
explicit Document.State value, instead of individual state variables in Session, Command, Document;
wenzelm
parents:
38367
diff
changeset
|
464 |
case None => fail |
|
8b15d0f98962
explicit Document.State value, instead of individual state variables in Session, Command, Document;
wenzelm
parents:
38367
diff
changeset
|
465 |
} |
|
8b15d0f98962
explicit Document.State value, instead of individual state variables in Session, Command, Document;
wenzelm
parents:
38367
diff
changeset
|
466 |
} |
|
8b15d0f98962
explicit Document.State value, instead of individual state variables in Session, Command, Document;
wenzelm
parents:
38367
diff
changeset
|
467 |
|
| 52563 | 468 |
def assign(id: Document_ID.Version, update: Assign_Update): (List[Command], State) = |
|
38370
8b15d0f98962
explicit Document.State value, instead of individual state variables in Session, Command, Document;
wenzelm
parents:
38367
diff
changeset
|
469 |
{
|
| 38417 | 470 |
val version = the_version(id) |
|
38370
8b15d0f98962
explicit Document.State value, instead of individual state variables in Session, Command, Document;
wenzelm
parents:
38367
diff
changeset
|
471 |
|
|
52566
52a0eacf04d1
more formal type assign_update: avoid duplicate results and redundant update of global State.execs;
wenzelm
parents:
52564
diff
changeset
|
472 |
def upd(exec_id: Document_ID.Exec, st: Command.State) |
|
52a0eacf04d1
more formal type assign_update: avoid duplicate results and redundant update of global State.execs;
wenzelm
parents:
52564
diff
changeset
|
473 |
: Option[(Document_ID.Exec, Command.State)] = |
|
52a0eacf04d1
more formal type assign_update: avoid duplicate results and redundant update of global State.execs;
wenzelm
parents:
52564
diff
changeset
|
474 |
if (execs.isDefinedAt(exec_id)) None else Some(exec_id -> st) |
|
52a0eacf04d1
more formal type assign_update: avoid duplicate results and redundant update of global State.execs;
wenzelm
parents:
52564
diff
changeset
|
475 |
|
| 44543 | 476 |
val (changed_commands, new_execs) = |
| 52563 | 477 |
((Nil: List[Command], execs) /: update) {
|
|
52566
52a0eacf04d1
more formal type assign_update: avoid duplicate results and redundant update of global State.execs;
wenzelm
parents:
52564
diff
changeset
|
478 |
case ((commands1, execs1), (command_id, exec)) => |
|
52a0eacf04d1
more formal type assign_update: avoid duplicate results and redundant update of global State.execs;
wenzelm
parents:
52564
diff
changeset
|
479 |
val st = the_static_state(command_id) |
|
52a0eacf04d1
more formal type assign_update: avoid duplicate results and redundant update of global State.execs;
wenzelm
parents:
52564
diff
changeset
|
480 |
val command = st.command |
|
52527
dbac84eab3bc
separate exec_id assignment for Command.print states, without affecting result of eval;
wenzelm
parents:
52508
diff
changeset
|
481 |
val commands2 = command :: commands1 |
| 44543 | 482 |
val execs2 = |
483 |
exec match {
|
|
|
52527
dbac84eab3bc
separate exec_id assignment for Command.print states, without affecting result of eval;
wenzelm
parents:
52508
diff
changeset
|
484 |
case Nil => execs1 |
|
dbac84eab3bc
separate exec_id assignment for Command.print states, without affecting result of eval;
wenzelm
parents:
52508
diff
changeset
|
485 |
case eval_id :: print_ids => |
|
52566
52a0eacf04d1
more formal type assign_update: avoid duplicate results and redundant update of global State.execs;
wenzelm
parents:
52564
diff
changeset
|
486 |
execs1 ++ upd(eval_id, st) ++ |
|
52a0eacf04d1
more formal type assign_update: avoid duplicate results and redundant update of global State.execs;
wenzelm
parents:
52564
diff
changeset
|
487 |
(for (id <- print_ids; up <- upd(id, command.empty_state)) yield up) |
| 44543 | 488 |
} |
489 |
(commands2, execs2) |
|
|
38370
8b15d0f98962
explicit Document.State value, instead of individual state variables in Session, Command, Document;
wenzelm
parents:
38367
diff
changeset
|
490 |
} |
| 52563 | 491 |
val new_assignment = the_assignment(version).assign(update) |
| 43722 | 492 |
val new_state = copy(assignments = assignments + (id -> new_assignment), execs = new_execs) |
|
44476
e8a87398f35d
propagate information about last command with exec state assignment through document model;
wenzelm
parents:
44475
diff
changeset
|
493 |
|
| 44543 | 494 |
(changed_commands, new_state) |
|
38370
8b15d0f98962
explicit Document.State value, instead of individual state variables in Session, Command, Document;
wenzelm
parents:
38367
diff
changeset
|
495 |
} |
|
8b15d0f98962
explicit Document.State value, instead of individual state variables in Session, Command, Document;
wenzelm
parents:
38367
diff
changeset
|
496 |
|
| 38417 | 497 |
def is_assigned(version: Version): Boolean = |
| 43722 | 498 |
assignments.get(version.id) match {
|
|
38370
8b15d0f98962
explicit Document.State value, instead of individual state variables in Session, Command, Document;
wenzelm
parents:
38367
diff
changeset
|
499 |
case Some(assgn) => assgn.is_finished |
|
8b15d0f98962
explicit Document.State value, instead of individual state variables in Session, Command, Document;
wenzelm
parents:
38367
diff
changeset
|
500 |
case None => false |
|
8b15d0f98962
explicit Document.State value, instead of individual state variables in Session, Command, Document;
wenzelm
parents:
38367
diff
changeset
|
501 |
} |
|
8b15d0f98962
explicit Document.State value, instead of individual state variables in Session, Command, Document;
wenzelm
parents:
38367
diff
changeset
|
502 |
|
|
44436
546adfa8a6fc
update_perspective without actual edits, bypassing the full state assignment protocol;
wenzelm
parents:
44385
diff
changeset
|
503 |
def is_stable(change: Change): Boolean = |
|
546adfa8a6fc
update_perspective without actual edits, bypassing the full state assignment protocol;
wenzelm
parents:
44385
diff
changeset
|
504 |
change.is_finished && is_assigned(change.version.get_finished) |
|
546adfa8a6fc
update_perspective without actual edits, bypassing the full state assignment protocol;
wenzelm
parents:
44385
diff
changeset
|
505 |
|
|
46944
9fc22eb6408c
more recent recent_syntax, e.g. relevant for document rendering during startup;
wenzelm
parents:
46942
diff
changeset
|
506 |
def recent_finished: Change = history.undo_list.find(_.is_finished) getOrElse fail |
| 44672 | 507 |
def recent_stable: Change = history.undo_list.find(is_stable) getOrElse fail |
|
44436
546adfa8a6fc
update_perspective without actual edits, bypassing the full state assignment protocol;
wenzelm
parents:
44385
diff
changeset
|
508 |
def tip_stable: Boolean = is_stable(history.tip) |
| 44475 | 509 |
def tip_version: Version = history.tip.version.get_finished |
|
44436
546adfa8a6fc
update_perspective without actual edits, bypassing the full state assignment protocol;
wenzelm
parents:
44385
diff
changeset
|
510 |
|
| 44446 | 511 |
def continue_history( |
512 |
previous: Future[Version], |
|
| 40479 | 513 |
edits: List[Edit_Text], |
| 43722 | 514 |
version: Future[Version]): (Change, State) = |
|
38841
4df7b76249a0
include Document.History in Document.State -- just one universal session state maintained by main actor;
wenzelm
parents:
38569
diff
changeset
|
515 |
{
|
| 46678 | 516 |
val change = Change.make(previous, edits, version) |
|
38841
4df7b76249a0
include Document.History in Document.State -- just one universal session state maintained by main actor;
wenzelm
parents:
38569
diff
changeset
|
517 |
(change, copy(history = history + change)) |
|
4df7b76249a0
include Document.History in Document.State -- just one universal session state maintained by main actor;
wenzelm
parents:
38569
diff
changeset
|
518 |
} |
|
4df7b76249a0
include Document.History in Document.State -- just one universal session state maintained by main actor;
wenzelm
parents:
38569
diff
changeset
|
519 |
|
| 44672 | 520 |
def prune_history(retain: Int = 0): (List[Version], State) = |
521 |
{
|
|
| 46679 | 522 |
history.prune(is_stable, retain) match {
|
523 |
case Some((dropped, history1)) => |
|
| 44672 | 524 |
val dropped_versions = dropped.map(change => change.version.get_finished) |
| 46679 | 525 |
val state1 = copy(history = history1) |
| 44672 | 526 |
(dropped_versions, state1) |
| 46679 | 527 |
case None => fail |
| 44672 | 528 |
} |
529 |
} |
|
530 |
||
|
52530
99dd8b4ef3fe
explicit module Document_ID as source of globally unique identifiers across ML/Scala;
wenzelm
parents:
52527
diff
changeset
|
531 |
def removed_versions(removed: List[Document_ID.Version]): State = |
| 44676 | 532 |
{
|
533 |
val versions1 = versions -- removed |
|
534 |
val assignments1 = assignments -- removed |
|
|
54519
5fed81762406
maintain blobs within document state: digest + text in ML, digest-only in Scala;
wenzelm
parents:
54515
diff
changeset
|
535 |
var blobs1 = Set.empty[SHA1.Digest] |
|
52530
99dd8b4ef3fe
explicit module Document_ID as source of globally unique identifiers across ML/Scala;
wenzelm
parents:
52527
diff
changeset
|
536 |
var commands1 = Map.empty[Document_ID.Command, Command.State] |
|
99dd8b4ef3fe
explicit module Document_ID as source of globally unique identifiers across ML/Scala;
wenzelm
parents:
52527
diff
changeset
|
537 |
var execs1 = Map.empty[Document_ID.Exec, Command.State] |
| 44676 | 538 |
for {
|
539 |
(version_id, version) <- versions1.iterator |
|
| 46997 | 540 |
command_execs = assignments1(version_id).command_execs |
| 46723 | 541 |
(_, node) <- version.nodes.entries |
| 44676 | 542 |
command <- node.commands.iterator |
543 |
} {
|
|
|
54519
5fed81762406
maintain blobs within document state: digest + text in ML, digest-only in Scala;
wenzelm
parents:
54515
diff
changeset
|
544 |
for (digest <- command.blobs_digests; if !blobs1.contains(digest)) |
|
5fed81762406
maintain blobs within document state: digest + text in ML, digest-only in Scala;
wenzelm
parents:
54515
diff
changeset
|
545 |
blobs1 += digest |
|
5fed81762406
maintain blobs within document state: digest + text in ML, digest-only in Scala;
wenzelm
parents:
54515
diff
changeset
|
546 |
|
| 52568 | 547 |
if (!commands1.isDefinedAt(command.id)) |
548 |
commands.get(command.id).foreach(st => commands1 += (command.id -> st)) |
|
|
54519
5fed81762406
maintain blobs within document state: digest + text in ML, digest-only in Scala;
wenzelm
parents:
54515
diff
changeset
|
549 |
|
| 52568 | 550 |
for (exec_id <- command_execs.getOrElse(command.id, Nil)) {
|
|
52527
dbac84eab3bc
separate exec_id assignment for Command.print states, without affecting result of eval;
wenzelm
parents:
52508
diff
changeset
|
551 |
if (!execs1.isDefinedAt(exec_id)) |
|
dbac84eab3bc
separate exec_id assignment for Command.print states, without affecting result of eval;
wenzelm
parents:
52508
diff
changeset
|
552 |
execs.get(exec_id).foreach(st => execs1 += (exec_id -> st)) |
| 44676 | 553 |
} |
554 |
} |
|
|
54519
5fed81762406
maintain blobs within document state: digest + text in ML, digest-only in Scala;
wenzelm
parents:
54515
diff
changeset
|
555 |
copy(versions = versions1, blobs = blobs1, commands = commands1, execs = execs1, |
|
5fed81762406
maintain blobs within document state: digest + text in ML, digest-only in Scala;
wenzelm
parents:
54515
diff
changeset
|
556 |
assignments = assignments1) |
| 44676 | 557 |
} |
558 |
||
| 44613 | 559 |
def command_state(version: Version, command: Command): Command.State = |
560 |
{
|
|
561 |
require(is_assigned(version)) |
|
562 |
try {
|
|
|
52527
dbac84eab3bc
separate exec_id assignment for Command.print states, without affecting result of eval;
wenzelm
parents:
52508
diff
changeset
|
563 |
the_assignment(version).check_finished.command_execs.getOrElse(command.id, Nil) |
|
52564
4e855c120f6a
tuned signature -- NB: Command.read is actually part of Command.eval;
wenzelm
parents:
52563
diff
changeset
|
564 |
.map(the_dynamic_state(_)) match {
|
|
52527
dbac84eab3bc
separate exec_id assignment for Command.print states, without affecting result of eval;
wenzelm
parents:
52508
diff
changeset
|
565 |
case eval_state :: print_states => (eval_state /: print_states)(_ ++ _) |
|
dbac84eab3bc
separate exec_id assignment for Command.print states, without affecting result of eval;
wenzelm
parents:
52508
diff
changeset
|
566 |
case Nil => fail |
|
dbac84eab3bc
separate exec_id assignment for Command.print states, without affecting result of eval;
wenzelm
parents:
52508
diff
changeset
|
567 |
} |
| 44613 | 568 |
} |
|
47395
e6261a493f04
added static command status markup, to emphasize accepted but unassigned/unparsed commands (notably in overview panel);
wenzelm
parents:
47388
diff
changeset
|
569 |
catch {
|
|
e6261a493f04
added static command status markup, to emphasize accepted but unassigned/unparsed commands (notably in overview panel);
wenzelm
parents:
47388
diff
changeset
|
570 |
case _: State.Fail => |
|
52564
4e855c120f6a
tuned signature -- NB: Command.read is actually part of Command.eval;
wenzelm
parents:
52563
diff
changeset
|
571 |
try { the_static_state(command.id) }
|
| 49414 | 572 |
catch { case _: State.Fail => command.init_state }
|
|
47395
e6261a493f04
added static command status markup, to emphasize accepted but unassigned/unparsed commands (notably in overview panel);
wenzelm
parents:
47388
diff
changeset
|
573 |
} |
| 44613 | 574 |
} |
575 |
||
| 49645 | 576 |
def markup_to_XML(version: Version, node: Node, filter: XML.Elem => Boolean): XML.Body = |
577 |
node.commands.toList.map(cmd => command_state(version, cmd).markup_to_XML(filter)).flatten |
|
|
38841
4df7b76249a0
include Document.History in Document.State -- just one universal session state maintained by main actor;
wenzelm
parents:
38569
diff
changeset
|
578 |
|
|
4df7b76249a0
include Document.History in Document.State -- just one universal session state maintained by main actor;
wenzelm
parents:
38569
diff
changeset
|
579 |
// persistent user-view |
| 49346 | 580 |
def snapshot(name: Node.Name = Node.Name.empty, pending_edits: List[Text.Edit] = Nil) |
581 |
: Snapshot = |
|
|
38370
8b15d0f98962
explicit Document.State value, instead of individual state variables in Session, Command, Document;
wenzelm
parents:
38367
diff
changeset
|
582 |
{
|
| 44672 | 583 |
val stable = recent_stable |
|
44436
546adfa8a6fc
update_perspective without actual edits, bypassing the full state assignment protocol;
wenzelm
parents:
44385
diff
changeset
|
584 |
val latest = history.tip |
|
38841
4df7b76249a0
include Document.History in Document.State -- just one universal session state maintained by main actor;
wenzelm
parents:
38569
diff
changeset
|
585 |
|
| 44156 | 586 |
// FIXME proper treatment of removed nodes |
|
38841
4df7b76249a0
include Document.History in Document.State -- just one universal session state maintained by main actor;
wenzelm
parents:
38569
diff
changeset
|
587 |
val edits = |
|
4df7b76249a0
include Document.History in Document.State -- just one universal session state maintained by main actor;
wenzelm
parents:
38569
diff
changeset
|
588 |
(pending_edits /: history.undo_list.takeWhile(_ != stable))((edits, change) => |
| 44156 | 589 |
(for ((a, Node.Edits(es)) <- change.edits if a == name) yield es).flatten ::: edits) |
|
38841
4df7b76249a0
include Document.History in Document.State -- just one universal session state maintained by main actor;
wenzelm
parents:
38569
diff
changeset
|
590 |
lazy val reverse_edits = edits.reverse |
|
4df7b76249a0
include Document.History in Document.State -- just one universal session state maintained by main actor;
wenzelm
parents:
38569
diff
changeset
|
591 |
|
|
4df7b76249a0
include Document.History in Document.State -- just one universal session state maintained by main actor;
wenzelm
parents:
38569
diff
changeset
|
592 |
new Snapshot |
|
4df7b76249a0
include Document.History in Document.State -- just one universal session state maintained by main actor;
wenzelm
parents:
38569
diff
changeset
|
593 |
{
|
| 52972 | 594 |
/* global information */ |
595 |
||
| 44582 | 596 |
val state = State.this |
| 39698 | 597 |
val version = stable.version.get_finished |
|
38841
4df7b76249a0
include Document.History in Document.State -- just one universal session state maintained by main actor;
wenzelm
parents:
38569
diff
changeset
|
598 |
val is_outdated = !(pending_edits.isEmpty && latest == stable) |
|
4df7b76249a0
include Document.History in Document.State -- just one universal session state maintained by main actor;
wenzelm
parents:
38569
diff
changeset
|
599 |
|
|
4df7b76249a0
include Document.History in Document.State -- just one universal session state maintained by main actor;
wenzelm
parents:
38569
diff
changeset
|
600 |
def convert(offset: Text.Offset) = (offset /: edits)((i, edit) => edit.convert(i)) |
|
4df7b76249a0
include Document.History in Document.State -- just one universal session state maintained by main actor;
wenzelm
parents:
38569
diff
changeset
|
601 |
def revert(offset: Text.Offset) = (offset /: reverse_edits)((i, edit) => edit.revert(i)) |
| 43425 | 602 |
def convert(range: Text.Range) = (range /: edits)((r, edit) => edit.convert(r)) |
603 |
def revert(range: Text.Range) = (range /: reverse_edits)((r, edit) => edit.revert(r)) |
|
|
39177
0468964aec11
simplified Markup_Tree.select: Stream instead of Iterator (again), explicit Option instead of default;
wenzelm
parents:
38976
diff
changeset
|
604 |
|
| 52972 | 605 |
|
606 |
/* local node content */ |
|
607 |
||
608 |
val node_name = name |
|
609 |
val node = version.nodes(name) |
|
610 |
||
| 51494 | 611 |
def eq_content(other: Snapshot): Boolean = |
| 49346 | 612 |
!is_outdated && !other.is_outdated && |
613 |
node.commands.size == other.node.commands.size && |
|
614 |
((node.commands.iterator zip other.node.commands.iterator) forall {
|
|
615 |
case (cmd1, cmd2) => |
|
| 51494 | 616 |
state.command_state(version, cmd1) eq_content |
617 |
other.state.command_state(other.version, cmd2) |
|
| 49346 | 618 |
}) |
619 |
||
|
46178
1c5c88f6feb5
clarified Isabelle_Rendering vs. physical painting;
wenzelm
parents:
46152
diff
changeset
|
620 |
def cumulate_markup[A](range: Text.Range, info: A, elements: Option[Set[String]], |
|
52900
d29bf6db8a2d
more elementary list structures for markup tree traversal;
wenzelm
parents:
52889
diff
changeset
|
621 |
result: Command.State => (A, Text.Markup) => Option[A]): List[Text.Info[A]] = |
| 45459 | 622 |
{
|
| 45467 | 623 |
val former_range = revert(range) |
|
52900
d29bf6db8a2d
more elementary list structures for markup tree traversal;
wenzelm
parents:
52889
diff
changeset
|
624 |
(for {
|
|
d29bf6db8a2d
more elementary list structures for markup tree traversal;
wenzelm
parents:
52889
diff
changeset
|
625 |
(command, command_start) <- node.command_range(former_range) |
|
50500
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50204
diff
changeset
|
626 |
st = state.command_state(version, command) |
|
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50204
diff
changeset
|
627 |
res = result(st) |
|
52889
ea3338812e67
more tight interface for markup cumulate/select: avoid duplicate application, allow to defer decision about definedness;
wenzelm
parents:
52887
diff
changeset
|
628 |
Text.Info(r0, a) <- st.markup.cumulate[A]( |
|
ea3338812e67
more tight interface for markup cumulate/select: avoid duplicate application, allow to defer decision about definedness;
wenzelm
parents:
52887
diff
changeset
|
629 |
(former_range - command_start).restrict(command.range), info, elements, |
|
52900
d29bf6db8a2d
more elementary list structures for markup tree traversal;
wenzelm
parents:
52889
diff
changeset
|
630 |
{ case (a, Text.Info(r0, b)) => res(a, Text.Info(convert(r0 + command_start), b)) }
|
|
d29bf6db8a2d
more elementary list structures for markup tree traversal;
wenzelm
parents:
52889
diff
changeset
|
631 |
).iterator |
|
d29bf6db8a2d
more elementary list structures for markup tree traversal;
wenzelm
parents:
52889
diff
changeset
|
632 |
} yield Text.Info(convert(r0 + command_start), a)).toList |
| 45459 | 633 |
} |
634 |
||
|
46178
1c5c88f6feb5
clarified Isabelle_Rendering vs. physical painting;
wenzelm
parents:
46152
diff
changeset
|
635 |
def select_markup[A](range: Text.Range, elements: Option[Set[String]], |
|
52900
d29bf6db8a2d
more elementary list structures for markup tree traversal;
wenzelm
parents:
52889
diff
changeset
|
636 |
result: Command.State => Text.Markup => Option[A]): List[Text.Info[A]] = |
|
38845
a9e37daf5bd0
added Document.Snapshot.select_markup, which includes command iteration, range conversion etc.;
wenzelm
parents:
38841
diff
changeset
|
637 |
{
|
|
52889
ea3338812e67
more tight interface for markup cumulate/select: avoid duplicate application, allow to defer decision about definedness;
wenzelm
parents:
52887
diff
changeset
|
638 |
def result1(st: Command.State): (Option[A], Text.Markup) => Option[Option[A]] = |
|
50500
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50204
diff
changeset
|
639 |
{
|
|
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50204
diff
changeset
|
640 |
val res = result(st) |
|
52889
ea3338812e67
more tight interface for markup cumulate/select: avoid duplicate application, allow to defer decision about definedness;
wenzelm
parents:
52887
diff
changeset
|
641 |
(_: Option[A], x: Text.Markup) => |
|
ea3338812e67
more tight interface for markup cumulate/select: avoid duplicate application, allow to defer decision about definedness;
wenzelm
parents:
52887
diff
changeset
|
642 |
res(x) match {
|
|
ea3338812e67
more tight interface for markup cumulate/select: avoid duplicate application, allow to defer decision about definedness;
wenzelm
parents:
52887
diff
changeset
|
643 |
case None => None |
|
ea3338812e67
more tight interface for markup cumulate/select: avoid duplicate application, allow to defer decision about definedness;
wenzelm
parents:
52887
diff
changeset
|
644 |
case some => Some(some) |
|
ea3338812e67
more tight interface for markup cumulate/select: avoid duplicate application, allow to defer decision about definedness;
wenzelm
parents:
52887
diff
changeset
|
645 |
} |
|
50500
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50204
diff
changeset
|
646 |
} |
|
46198
cd040c5772de
improved select_markup: include filtering of defined results;
wenzelm
parents:
46178
diff
changeset
|
647 |
for (Text.Info(r, Some(x)) <- cumulate_markup(range, None, elements, result1)) |
|
cd040c5772de
improved select_markup: include filtering of defined results;
wenzelm
parents:
46178
diff
changeset
|
648 |
yield Text.Info(r, x) |
|
38845
a9e37daf5bd0
added Document.Snapshot.select_markup, which includes command iteration, range conversion etc.;
wenzelm
parents:
38841
diff
changeset
|
649 |
} |
|
38841
4df7b76249a0
include Document.History in Document.State -- just one universal session state maintained by main actor;
wenzelm
parents:
38569
diff
changeset
|
650 |
} |
|
38150
67fc24df3721
simplified/refined document model: collection of named nodes, without proper dependencies yet;
wenzelm
parents:
37849
diff
changeset
|
651 |
} |
| 34485 | 652 |
} |
|
34840
6c5560d48561
more precise treatment of document/state assigment;
wenzelm
parents:
34838
diff
changeset
|
653 |
} |
|
6c5560d48561
more precise treatment of document/state assigment;
wenzelm
parents:
34838
diff
changeset
|
654 |