278 def convert(range: Text.Range): Text.Range |
278 def convert(range: Text.Range): Text.Range |
279 def revert(i: Text.Offset): Text.Offset |
279 def revert(i: Text.Offset): Text.Offset |
280 def revert(range: Text.Range): Text.Range |
280 def revert(range: Text.Range): Text.Range |
281 def eq_markup(other: Snapshot): Boolean |
281 def eq_markup(other: Snapshot): Boolean |
282 def cumulate_markup[A](range: Text.Range, info: A, elements: Option[Set[String]], |
282 def cumulate_markup[A](range: Text.Range, info: A, elements: Option[Set[String]], |
283 result: PartialFunction[(A, Text.Markup), A]): Stream[Text.Info[A]] |
283 result: Command.State => PartialFunction[(A, Text.Markup), A]): Stream[Text.Info[A]] |
284 def select_markup[A](range: Text.Range, elements: Option[Set[String]], |
284 def select_markup[A](range: Text.Range, elements: Option[Set[String]], |
285 result: PartialFunction[Text.Markup, A]): Stream[Text.Info[A]] |
285 result: Command.State => PartialFunction[Text.Markup, A]): Stream[Text.Info[A]] |
286 } |
286 } |
287 |
287 |
288 type Assign = List[(Document.Command_ID, Option[Document.Exec_ID])] // exec state assignment |
288 type Assign = List[(Document.Command_ID, Option[Document.Exec_ID])] // exec state assignment |
289 |
289 |
290 object State |
290 object State |
504 (state.command_state(version, cmd1).markup eq |
504 (state.command_state(version, cmd1).markup eq |
505 other.state.command_state(other.version, cmd2).markup) |
505 other.state.command_state(other.version, cmd2).markup) |
506 }) |
506 }) |
507 |
507 |
508 def cumulate_markup[A](range: Text.Range, info: A, elements: Option[Set[String]], |
508 def cumulate_markup[A](range: Text.Range, info: A, elements: Option[Set[String]], |
509 result: PartialFunction[(A, Text.Markup), A]): Stream[Text.Info[A]] = |
509 result: Command.State => PartialFunction[(A, Text.Markup), A]): Stream[Text.Info[A]] = |
510 { |
510 { |
511 val former_range = revert(range) |
511 val former_range = revert(range) |
512 for { |
512 for { |
513 (command, command_start) <- node.command_range(former_range).toStream |
513 (command, command_start) <- node.command_range(former_range).toStream |
514 Text.Info(r0, a) <- state.command_state(version, command).markup. |
514 st = state.command_state(version, command) |
|
515 res = result(st) |
|
516 Text.Info(r0, a) <- st.markup. |
515 cumulate[A]((former_range - command_start).restrict(command.range), info, elements, |
517 cumulate[A]((former_range - command_start).restrict(command.range), info, elements, |
516 { |
518 { |
517 case (a, Text.Info(r0, b)) |
519 case (a, Text.Info(r0, b)) |
518 if result.isDefinedAt((a, Text.Info(convert(r0 + command_start), b))) => |
520 if res.isDefinedAt((a, Text.Info(convert(r0 + command_start), b))) => |
519 result((a, Text.Info(convert(r0 + command_start), b))) |
521 res((a, Text.Info(convert(r0 + command_start), b))) |
520 }) |
522 }) |
521 } yield Text.Info(convert(r0 + command_start), a) |
523 } yield Text.Info(convert(r0 + command_start), a) |
522 } |
524 } |
523 |
525 |
524 def select_markup[A](range: Text.Range, elements: Option[Set[String]], |
526 def select_markup[A](range: Text.Range, elements: Option[Set[String]], |
525 result: PartialFunction[Text.Markup, A]): Stream[Text.Info[A]] = |
527 result: Command.State => PartialFunction[Text.Markup, A]): Stream[Text.Info[A]] = |
526 { |
528 { |
527 val result1 = |
529 def result1(st: Command.State) = |
|
530 { |
|
531 val res = result(st) |
528 new PartialFunction[(Option[A], Text.Markup), Option[A]] { |
532 new PartialFunction[(Option[A], Text.Markup), Option[A]] { |
529 def isDefinedAt(arg: (Option[A], Text.Markup)): Boolean = result.isDefinedAt(arg._2) |
533 def isDefinedAt(arg: (Option[A], Text.Markup)): Boolean = res.isDefinedAt(arg._2) |
530 def apply(arg: (Option[A], Text.Markup)): Option[A] = Some(result(arg._2)) |
534 def apply(arg: (Option[A], Text.Markup)): Option[A] = Some(res(arg._2)) |
531 } |
535 } |
|
536 } |
532 for (Text.Info(r, Some(x)) <- cumulate_markup(range, None, elements, result1)) |
537 for (Text.Info(r, Some(x)) <- cumulate_markup(range, None, elements, result1)) |
533 yield Text.Info(r, x) |
538 yield Text.Info(r, x) |
534 } |
539 } |
535 } |
540 } |
536 } |
541 } |