578 |
578 |
579 private sealed case class Tooltip_Info( |
579 private sealed case class Tooltip_Info( |
580 range: Text.Range, |
580 range: Text.Range, |
581 timing: Timing = Timing.zero, |
581 timing: Timing = Timing.zero, |
582 messages: List[(Long, XML.Tree)] = Nil, |
582 messages: List[(Long, XML.Tree)] = Nil, |
583 rev_infos: List[(Boolean, XML.Tree)] = Nil |
583 rev_infos: List[(Boolean, Int, XML.Tree)] = Nil |
584 ) { |
584 ) { |
585 def add_timing(t: Timing): Tooltip_Info = copy(timing = timing + t) |
585 def add_timing(t: Timing): Tooltip_Info = copy(timing = timing + t) |
586 def add_message(r0: Text.Range, serial: Long, tree: XML.Tree): Tooltip_Info = { |
586 def add_message(r0: Text.Range, serial: Long, tree: XML.Tree): Tooltip_Info = { |
587 val r = snapshot.convert(r0) |
587 val r = snapshot.convert(r0) |
588 if (range == r) copy(messages = (serial -> tree) :: messages) |
588 if (range == r) copy(messages = (serial -> tree) :: messages) |
589 else copy(range = r, messages = List(serial -> tree)) |
589 else copy(range = r, messages = List(serial -> tree)) |
590 } |
590 } |
591 def add_info(r0: Text.Range, tree: XML.Tree, important: Boolean = true): Tooltip_Info = { |
591 def add_info(r0: Text.Range, tree: XML.Tree, important: Boolean = true, ord: Int = 0): Tooltip_Info = { |
592 val r = snapshot.convert(r0) |
592 val r = snapshot.convert(r0) |
593 if (range == r) copy(rev_infos = (important -> tree) :: rev_infos) |
593 val entry = (important, ord, tree) |
594 else copy (range = r, rev_infos = List(important -> tree)) |
594 if (range == r) copy(rev_infos = entry :: rev_infos) |
|
595 else copy (range = r, rev_infos = List(entry)) |
595 } |
596 } |
596 |
597 |
597 def timing_info(tree: XML.Tree): Option[XML.Tree] = |
598 def timing_info(tree: XML.Tree): Option[XML.Tree] = |
598 tree match { |
599 tree match { |
599 case XML.Elem(Markup(Markup.TIMING, _), _) => |
600 case XML.Elem(Markup(Markup.TIMING, _), _) => |
600 if (timing.elapsed.seconds >= timing_threshold) Some(XML.Text(timing.message)) else None |
601 if (timing.elapsed.seconds >= timing_threshold) Some(XML.Text(timing.message)) else None |
601 case _ => Some(tree) |
602 case _ => Some(tree) |
602 } |
603 } |
603 def infos(important: Boolean = true): List[XML.Tree] = |
604 def infos(important: Boolean = true): List[XML.Tree] = |
604 for { |
605 for { |
605 (is_important, tree) <- rev_infos.reverse if is_important == important |
606 (is_important, _, tree) <- rev_infos.reverse.sortBy(_._2) if is_important == important |
606 tree1 <- timing_info(tree) |
607 tree1 <- timing_info(tree) |
607 } yield tree1 |
608 } yield tree1 |
608 } |
609 } |
609 |
610 |
610 def perhaps_append_file(node_name: Document.Node.Name, name: String): String = |
611 def perhaps_append_file(node_name: Document.Node.Name, name: String): String = |
630 val kind1 = Word.implode(Word.explode('_', kind)) |
631 val kind1 = Word.implode(Word.explode('_', kind)) |
631 val txt1 = |
632 val txt1 = |
632 if (name == "") kind1 |
633 if (name == "") kind1 |
633 else if (kind1 == "") quote(name) |
634 else if (kind1 == "") quote(name) |
634 else kind1 + " " + quote(name) |
635 else kind1 + " " + quote(name) |
635 val info1 = info.add_info(r0, XML.Text(txt1)) |
636 val info1 = info.add_info(r0, XML.Text(txt1), ord = 2) |
636 Some(if (kind == Markup.COMMAND) info1.add_info(r0, XML.elem(Markup.TIMING)) else info1) |
637 Some(if (kind == Markup.COMMAND) info1.add_info(r0, XML.elem(Markup.TIMING)) else info1) |
637 |
638 |
638 case (info, Text.Info(r0, XML.Elem(Markup.Path(name), _))) => |
639 case (info, Text.Info(r0, XML.Elem(Markup.Path(name), _))) => |
639 val file = perhaps_append_file(snapshot.node_name, name) |
640 val file = perhaps_append_file(snapshot.node_name, name) |
640 val text = |
641 val text = |
649 case (info, Text.Info(r0, XML.Elem(Markup.Url(name), _))) => |
650 case (info, Text.Info(r0, XML.Elem(Markup.Url(name), _))) => |
650 Some(info.add_info(r0, XML.Text("URL " + quote(name)))) |
651 Some(info.add_info(r0, XML.Text("URL " + quote(name)))) |
651 |
652 |
652 case (info, Text.Info(r0, XML.Elem(Markup(name, _), body))) |
653 case (info, Text.Info(r0, XML.Elem(Markup(name, _), body))) |
653 if name == Markup.SORTING || name == Markup.TYPING => |
654 if name == Markup.SORTING || name == Markup.TYPING => |
654 Some(info.add_info(r0, Pretty.block(XML.Text("::") :: Pretty.brk(1) :: body))) |
655 Some(info.add_info(r0, Pretty.block(XML.Text("::") :: Pretty.brk(1) :: body), ord = 3)) |
655 |
656 |
656 case (info, Text.Info(r0, XML.Elem(Markup(Markup.CLASS_PARAMETER, _), body))) => |
657 case (info, Text.Info(r0, XML.Elem(Markup(Markup.CLASS_PARAMETER, _), body))) => |
657 Some(info.add_info(r0, Pretty.block(body, indent = 0))) |
658 Some(info.add_info(r0, Pretty.block(body, indent = 0))) |
658 |
659 |
659 case (info, Text.Info(r0, XML.Elem(Markup(Markup.ML_TYPING, _), body))) => |
660 case (info, Text.Info(r0, XML.Elem(Markup(Markup.ML_TYPING, _), body))) => |
673 val b = name.nonEmpty |
674 val b = name.nonEmpty |
674 val k = Word.implode(Word.explode('_', kind)) |
675 val k = Word.implode(Word.explode('_', kind)) |
675 val description = |
676 val description = |
676 if (!a && !b) "notation" |
677 if (!a && !b) "notation" |
677 else "notation: " + k + if_proper(a && b, " ") + if_proper(b, quote(name)) |
678 else "notation: " + k + if_proper(a && b, " ") + if_proper(b, quote(name)) |
678 Some(info.add_info(r0, XML.Text(description))) |
679 Some(info.add_info(r0, XML.Text(description), ord = 1)) |
679 |
680 |
680 case (info, Text.Info(r0, XML.Elem(Markup.Expression(kind), _))) => |
681 case (info, Text.Info(r0, XML.Elem(Markup.Expression(kind), _))) => |
681 val description = |
682 val description = |
682 if (kind.isEmpty) "expression" |
683 if (kind.isEmpty) "expression" |
683 else "expression: " + Word.implode(Word.explode('_', kind)) |
684 else "expression: " + Word.implode(Word.explode('_', kind)) |
684 Some(info.add_info(r0, XML.Text(description))) |
685 Some(info.add_info(r0, XML.Text(description), ord = 1)) |
685 |
686 |
686 case (info, Text.Info(r0, XML.Elem(Markup(Markup.MARKDOWN_PARAGRAPH, _), _))) => |
687 case (info, Text.Info(r0, XML.Elem(Markup(Markup.MARKDOWN_PARAGRAPH, _), _))) => |
687 Some(info.add_info(r0, XML.Text("Markdown: paragraph"))) |
688 Some(info.add_info(r0, XML.Text("Markdown: paragraph"))) |
688 case (info, Text.Info(r0, XML.Elem(Markup(Markup.MARKDOWN_ITEM, _), _))) => |
689 case (info, Text.Info(r0, XML.Elem(Markup(Markup.MARKDOWN_ITEM, _), _))) => |
689 Some(info.add_info(r0, XML.Text("Markdown: item"))) |
690 Some(info.add_info(r0, XML.Text("Markdown: item"))) |