src/Tools/jEdit/src/rendering.scala
changeset 50500 c94bba7906d2
parent 50499 f496b2b7bafb
child 50501 6f41f1646617
     1.1 --- a/src/Tools/jEdit/src/rendering.scala	Wed Dec 12 23:36:07 2012 +0100
     1.2 +++ b/src/Tools/jEdit/src/rendering.scala	Thu Dec 13 13:52:18 2012 +0100
     1.3 @@ -165,7 +165,7 @@
     1.4        val results =
     1.5          snapshot.cumulate_markup[(Protocol.Status, Int)](
     1.6            range, (Protocol.Status.init, 0),
     1.7 -          Some(Protocol.command_status_markup + Markup.WARNING + Markup.ERROR),
     1.8 +          Some(Protocol.command_status_markup + Markup.WARNING + Markup.ERROR), _ =>
     1.9            {
    1.10              case ((status, pri), Text.Info(_, XML.Elem(markup, _))) =>
    1.11                if (markup.name == Markup.WARNING || markup.name == Markup.ERROR)
    1.12 @@ -198,7 +198,7 @@
    1.13  
    1.14    def highlight(range: Text.Range): Option[Text.Info[Color]] =
    1.15    {
    1.16 -    snapshot.select_markup(range, Some(highlight_include),
    1.17 +    snapshot.select_markup(range, Some(highlight_include), _ =>
    1.18          {
    1.19            case Text.Info(info_range, XML.Elem(Markup(name, _), _)) if highlight_include(name) =>
    1.20              Text.Info(snapshot.convert(info_range), highlight_color)
    1.21 @@ -210,7 +210,7 @@
    1.22  
    1.23    def hyperlink(range: Text.Range): Option[Text.Info[Hyperlink]] =
    1.24    {
    1.25 -    snapshot.cumulate_markup[List[Text.Info[Hyperlink]]](range, Nil, Some(hyperlink_include),
    1.26 +    snapshot.cumulate_markup[List[Text.Info[Hyperlink]]](range, Nil, Some(hyperlink_include), _ =>
    1.27          {
    1.28            case (links, Text.Info(info_range, XML.Elem(Markup.Path(name), _)))
    1.29            if Path.is_ok(name) =>
    1.30 @@ -250,11 +250,11 @@
    1.31    }
    1.32  
    1.33  
    1.34 -  private val active_include = Set(Markup.SENDBACK, Markup.DIALOG, Markup.GRAPHVIEW)
    1.35 +  private val active_include = Set(Markup.GRAPHVIEW, Markup.SENDBACK, Markup.DIALOG)
    1.36  
    1.37    def active(range: Text.Range): Option[Text.Info[XML.Elem]] =
    1.38 -    snapshot.select_markup(range, Some(active_include),
    1.39 -        {
    1.40 +    snapshot.select_markup(range, Some(active_include), command_state =>
    1.41 +        {  // FIXME inactive dialog
    1.42            case Text.Info(info_range, elem @ XML.Elem(markup, _))
    1.43            if active_include(markup.name) => Text.Info(snapshot.convert(info_range), elem)
    1.44          }) match { case Text.Info(_, info) #:: _ => Some(info) case _ => None }
    1.45 @@ -264,7 +264,7 @@
    1.46    {
    1.47      val msgs =
    1.48        snapshot.cumulate_markup[SortedMap[Long, XML.Tree]](range, SortedMap.empty,
    1.49 -        Some(Set(Markup.WRITELN, Markup.WARNING, Markup.ERROR, Markup.BAD)),
    1.50 +        Some(Set(Markup.WRITELN, Markup.WARNING, Markup.ERROR, Markup.BAD)), _ =>
    1.51          {
    1.52            case (msgs, Text.Info(_, XML.Elem(Markup(name, props @ Markup.Serial(serial)), body)))
    1.53            if name == Markup.WRITELN ||
    1.54 @@ -308,7 +308,7 @@
    1.55  
    1.56      val tips =
    1.57        snapshot.cumulate_markup[Text.Info[(List[(Boolean, XML.Tree)])]](
    1.58 -        range, Text.Info(range, Nil), Some(tooltip_elements),
    1.59 +        range, Text.Info(range, Nil), Some(tooltip_elements), _ =>
    1.60          {
    1.61            case (prev, Text.Info(r, XML.Elem(Markup.Entity(kind, name), _))) =>
    1.62              val kind1 = space_explode('_', kind).mkString(" ")
    1.63 @@ -335,7 +335,7 @@
    1.64    def gutter_message(range: Text.Range): Option[Icon] =
    1.65    {
    1.66      val results =
    1.67 -      snapshot.cumulate_markup[Int](range, 0, Some(Set(Markup.WARNING, Markup.ERROR)),
    1.68 +      snapshot.cumulate_markup[Int](range, 0, Some(Set(Markup.WARNING, Markup.ERROR)), _ =>
    1.69          {
    1.70            case (pri, Text.Info(_, XML.Elem(Markup(Markup.WARNING, _), body))) =>
    1.71              body match {
    1.72 @@ -360,7 +360,7 @@
    1.73    {
    1.74      val results =
    1.75        snapshot.cumulate_markup[Int](range, 0,
    1.76 -        Some(Set(Markup.WRITELN, Markup.WARNING, Markup.ERROR)),
    1.77 +        Some(Set(Markup.WRITELN, Markup.WARNING, Markup.ERROR)), _ =>
    1.78          {
    1.79            case (pri, Text.Info(_, XML.Elem(Markup(name, _), _)))
    1.80            if name == Markup.WRITELN ||
    1.81 @@ -386,7 +386,7 @@
    1.82    def line_background(range: Text.Range): Option[(Color, Boolean)] =
    1.83    {
    1.84      val results =
    1.85 -      snapshot.cumulate_markup[Int](range, 0, Some(messages_include),
    1.86 +      snapshot.cumulate_markup[Int](range, 0, Some(messages_include), _ =>
    1.87          {
    1.88            case (pri, Text.Info(_, XML.Elem(Markup(name, _), _)))
    1.89            if name == Markup.WRITELN_MESSAGE ||
    1.90 @@ -397,7 +397,7 @@
    1.91      val pri = (0 /: results) { case (p1, Text.Info(_, p2)) => p1 max p2 }
    1.92  
    1.93      val is_separator = pri > 0 &&
    1.94 -      snapshot.cumulate_markup[Boolean](range, false, Some(Set(Markup.SEPARATOR)),
    1.95 +      snapshot.cumulate_markup[Boolean](range, false, Some(Set(Markup.SEPARATOR)), _ =>
    1.96          {
    1.97            case (_, Text.Info(_, XML.Elem(Markup(Markup.SEPARATOR, _), _))) => true
    1.98          }).exists(_.info)
    1.99 @@ -406,10 +406,16 @@
   1.100    }
   1.101  
   1.102  
   1.103 +  def output_messages(st: Command.State): List[XML.Tree] =
   1.104 +  {
   1.105 +    st.results.iterator.map(_._2).filterNot(Protocol.is_result(_)).toList
   1.106 +  }
   1.107 +
   1.108 +
   1.109    private val background1_include =
   1.110      Protocol.command_status_markup + Markup.WRITELN_MESSAGE + Markup.TRACING_MESSAGE +
   1.111 -      Markup.WARNING_MESSAGE + Markup.ERROR_MESSAGE + Markup.BAD + Markup.INTENSIFY +
   1.112 -      Markup.DIALOG_RESULT ++ active_include
   1.113 +      Markup.WARNING_MESSAGE + Markup.ERROR_MESSAGE + Markup.BAD + Markup.INTENSIFY ++
   1.114 +      active_include
   1.115  
   1.116    def background1(range: Text.Range): Stream[Text.Info[Color]] =
   1.117    {
   1.118 @@ -417,49 +423,47 @@
   1.119      else
   1.120        for {
   1.121          Text.Info(r, result) <-
   1.122 -          snapshot.cumulate_markup[(Map[String, String], Option[Protocol.Status], Option[Color])](
   1.123 -            range, (Map.empty, Some(Protocol.Status.init), None), Some(background1_include),
   1.124 +          snapshot.cumulate_markup[(Option[Protocol.Status], Option[Color])](
   1.125 +            range, (Some(Protocol.Status.init), None), Some(background1_include), command_state =>
   1.126              {
   1.127 -              case (((dialogs, Some(status), color), Text.Info(_, XML.Elem(markup, _))))
   1.128 +              case (((Some(status), color), Text.Info(_, XML.Elem(markup, _))))
   1.129                if (Protocol.command_status_markup(markup.name)) =>
   1.130 -                (dialogs, Some(Protocol.command_status(status, markup)), color)
   1.131 -              case ((dialogs, _, _), Text.Info(_, XML.Elem(Markup(Markup.BAD, _), _))) =>
   1.132 -                (dialogs, None, Some(bad_color))
   1.133 -              case ((dialogs, _, _), Text.Info(_, XML.Elem(Markup(Markup.INTENSIFY, _), _))) =>
   1.134 -                (dialogs, None, Some(intensify_color))
   1.135 -              case ((dialogs, status, color), Text.Info(_,
   1.136 -                XML.Elem(Markup(Markup.DIALOG_RESULT, Markup.Dialog_Args(name, result)), _))) =>
   1.137 -                (dialogs + (name -> result), status, color)
   1.138 -              case ((dialogs, _, _), Text.Info(_,
   1.139 -                XML.Elem(Markup(Markup.DIALOG, Markup.Dialog_Args(name, result)), _))) =>
   1.140 -                  if (dialogs.get(name) == Some(result))
   1.141 -                    (dialogs, None, Some(active_result_color))
   1.142 -                  else (dialogs, None, Some(active_color))
   1.143 -              case ((dialogs, _, _), Text.Info(_, XML.Elem(Markup(name, _), _)))
   1.144 -              if active_include(name) =>
   1.145 -                (dialogs, None, Some(active_color))
   1.146 +                (Some(Protocol.command_status(status, markup)), color)
   1.147 +              case (_, Text.Info(_, XML.Elem(Markup(Markup.BAD, _), _))) =>
   1.148 +                (None, Some(bad_color))
   1.149 +              case (_, Text.Info(_, XML.Elem(Markup(Markup.INTENSIFY, _), _))) =>
   1.150 +                (None, Some(intensify_color))
   1.151 +              case (_, Text.Info(_, Protocol.Dialog(_, serial, result))) =>
   1.152 +                command_state.results.get(serial) match {
   1.153 +                  case Some(Protocol.Dialog_Result(_, res)) if res == result =>
   1.154 +                    (None, Some(active_result_color))
   1.155 +                  case _ =>
   1.156 +                    (None, Some(active_color))
   1.157 +                }
   1.158 +              case (_, Text.Info(_, XML.Elem(markup, _))) if active_include(markup.name) =>
   1.159 +                (None, Some(active_color))
   1.160              })
   1.161          color <-
   1.162            (result match {
   1.163 -            case (_, Some(status), opt_color) =>
   1.164 +            case (Some(status), opt_color) =>
   1.165                if (status.is_unprocessed) Some(unprocessed1_color)
   1.166                else if (status.is_running) Some(running1_color)
   1.167                else opt_color
   1.168 -            case (_, _, opt_color) => opt_color
   1.169 +            case (_, opt_color) => opt_color
   1.170            })
   1.171        } yield Text.Info(r, color)
   1.172    }
   1.173  
   1.174  
   1.175    def background2(range: Text.Range): Stream[Text.Info[Color]] =
   1.176 -    snapshot.select_markup(range, Some(Set(Markup.TOKEN_RANGE)),
   1.177 +    snapshot.select_markup(range, Some(Set(Markup.TOKEN_RANGE)), _ =>
   1.178        {
   1.179          case Text.Info(_, XML.Elem(Markup(Markup.TOKEN_RANGE, _), _)) => light_color
   1.180        })
   1.181  
   1.182  
   1.183    def foreground(range: Text.Range): Stream[Text.Info[Color]] =
   1.184 -    snapshot.select_markup(range, Some(Set(Markup.STRING, Markup.ALTSTRING, Markup.VERBATIM)),
   1.185 +    snapshot.select_markup(range, Some(Set(Markup.STRING, Markup.ALTSTRING, Markup.VERBATIM)), _ =>
   1.186        {
   1.187          case Text.Info(_, XML.Elem(Markup(Markup.STRING, _), _)) => quoted_color
   1.188          case Text.Info(_, XML.Elem(Markup(Markup.ALTSTRING, _), _)) => quoted_color
   1.189 @@ -499,7 +503,7 @@
   1.190    {
   1.191      if (color == Token_Markup.hidden_color) Stream(Text.Info(range, color))
   1.192      else
   1.193 -      snapshot.cumulate_markup(range, color, Some(text_color_elements),
   1.194 +      snapshot.cumulate_markup(range, color, Some(text_color_elements), _ =>
   1.195          {
   1.196            case (_, Text.Info(_, XML.Elem(Markup(m, _), _)))
   1.197            if text_colors.isDefinedAt(m) => text_colors(m)