equal
deleted
inserted
replaced
85 /* header and name */ |
85 /* header and name */ |
86 |
86 |
87 sealed case class Header( |
87 sealed case class Header( |
88 imports: List[Name], |
88 imports: List[Name], |
89 keywords: Thy_Header.Keywords, |
89 keywords: Thy_Header.Keywords, |
90 errors: List[String] = Nil) |
90 errors: List[String]) |
91 { |
91 { |
92 def error(msg: String): Header = copy(errors = errors ::: List(msg)) |
92 def error(msg: String): Header = copy(errors = errors ::: List(msg)) |
93 |
93 |
94 def cat_errors(msg2: String): Header = |
94 def cat_errors(msg2: String): Header = |
95 copy(errors = errors.map(msg1 => Library.cat_message(msg1, msg2))) |
95 copy(errors = errors.map(msg1 => Library.cat_message(msg1, msg2))) |
96 } |
96 } |
97 |
97 |
|
98 val no_header = Header(Nil, Nil, Nil) |
98 def bad_header(msg: String): Header = Header(Nil, Nil, List(msg)) |
99 def bad_header(msg: String): Header = Header(Nil, Nil, List(msg)) |
99 |
|
100 val no_header = bad_header("No theory header") |
|
101 |
100 |
102 object Name |
101 object Name |
103 { |
102 { |
104 val empty = Name("") |
103 val empty = Name("") |
105 |
104 |
169 /* perspective */ |
168 /* perspective */ |
170 |
169 |
171 type Perspective_Text = Perspective[Text.Edit, Text.Perspective] |
170 type Perspective_Text = Perspective[Text.Edit, Text.Perspective] |
172 type Perspective_Command = Perspective[Command.Edit, Command.Perspective] |
171 type Perspective_Command = Perspective[Command.Edit, Command.Perspective] |
173 |
172 |
174 val empty_perspective_text: Perspective_Text = |
173 val no_perspective_text: Perspective_Text = |
175 Perspective(false, Text.Perspective.empty, Overlays.empty) |
174 Perspective(false, Text.Perspective.empty, Overlays.empty) |
176 |
175 |
177 val empty_perspective_command: Perspective_Command = |
176 val no_perspective_command: Perspective_Command = |
178 Perspective(false, Command.Perspective.empty, Overlays.empty) |
177 Perspective(false, Command.Perspective.empty, Overlays.empty) |
|
178 |
|
179 def is_no_perspective_command(perspective: Perspective_Command): Boolean = |
|
180 !perspective.required && |
|
181 perspective.visible.is_empty && |
|
182 perspective.overlays.is_empty |
179 |
183 |
180 |
184 |
181 /* commands */ |
185 /* commands */ |
182 |
186 |
183 object Commands |
187 object Commands |
235 val empty: Node = new Node() |
239 val empty: Node = new Node() |
236 } |
240 } |
237 |
241 |
238 final class Node private( |
242 final class Node private( |
239 val get_blob: Option[Document.Blob] = None, |
243 val get_blob: Option[Document.Blob] = None, |
240 val header: Node.Header = Node.bad_header("Bad theory header"), |
244 val header: Node.Header = Node.no_header, |
241 val perspective: Node.Perspective_Command = Node.empty_perspective_command, |
245 val perspective: Node.Perspective_Command = Node.no_perspective_command, |
242 _commands: Node.Commands = Node.Commands.empty) |
246 _commands: Node.Commands = Node.Commands.empty) |
243 { |
247 { |
|
248 def is_empty: Boolean = |
|
249 get_blob.isEmpty && |
|
250 header == Node.no_header && |
|
251 Node.is_no_perspective_command(perspective) && |
|
252 commands.isEmpty |
|
253 |
|
254 def commands: Linear_Set[Command] = _commands.commands |
|
255 def load_commands: List[Command] = _commands.load_commands |
|
256 |
244 def clear: Node = new Node(header = header) |
257 def clear: Node = new Node(header = header) |
245 |
258 |
246 def init_blob(blob: Document.Blob): Node = new Node(Some(blob.unchanged)) |
259 def init_blob(blob: Document.Blob): Node = new Node(Some(blob.unchanged)) |
247 |
260 |
248 def update_header(new_header: Node.Header): Node = |
261 def update_header(new_header: Node.Header): Node = |
253 |
266 |
254 def same_perspective(other_perspective: Node.Perspective_Command): Boolean = |
267 def same_perspective(other_perspective: Node.Perspective_Command): Boolean = |
255 perspective.required == other_perspective.required && |
268 perspective.required == other_perspective.required && |
256 perspective.visible.same(other_perspective.visible) && |
269 perspective.visible.same(other_perspective.visible) && |
257 perspective.overlays == other_perspective.overlays |
270 perspective.overlays == other_perspective.overlays |
258 |
|
259 def commands: Linear_Set[Command] = _commands.commands |
|
260 def load_commands: List[Command] = _commands.load_commands |
|
261 |
271 |
262 def update_commands(new_commands: Linear_Set[Command]): Node = |
272 def update_commands(new_commands: Linear_Set[Command]): Node = |
263 if (new_commands eq _commands.commands) this |
273 if (new_commands eq _commands.commands) this |
264 else new Node(get_blob, header, perspective, Node.Commands(new_commands)) |
274 else new Node(get_blob, header, perspective, Node.Commands(new_commands)) |
265 |
275 |