src/Tools/jEdit/src/rendering.scala
changeset 52890 36e2c0c308eb
parent 52889 ea3338812e67
child 52900 d29bf6db8a2d
     1.1 --- a/src/Tools/jEdit/src/rendering.scala	Wed Aug 07 13:46:32 2013 +0200
     1.2 +++ b/src/Tools/jEdit/src/rendering.scala	Wed Aug 07 14:13:59 2013 +0200
     1.3 @@ -154,11 +154,11 @@
     1.4          snapshot.cumulate_markup[(Protocol.Status, Int)](
     1.5            range, (Protocol.Status.init, 0), Some(overview_include), _ =>
     1.6            {
     1.7 -            case ((status, pri), Text.Info(_, XML.Elem(markup, _))) =>
     1.8 -              if (markup.name == Markup.WARNING || markup.name == Markup.ERROR)
     1.9 -                Some((status, pri max Rendering.message_pri(markup.name)))
    1.10 -              else if (overview_include(markup.name))
    1.11 -                Some((Protocol.command_status(status, markup), pri))
    1.12 +            case ((status, pri), Text.Info(_, elem)) =>
    1.13 +              if (elem.name == Markup.WARNING || elem.name == Markup.ERROR)
    1.14 +                Some((status, pri max Rendering.message_pri(elem.name)))
    1.15 +              else if (overview_include(elem.name))
    1.16 +                Some((Protocol.command_status(status, elem.markup), pri))
    1.17                else None
    1.18            })
    1.19        if (results.isEmpty) None
    1.20 @@ -189,8 +189,8 @@
    1.21    {
    1.22      snapshot.select_markup(range, Some(highlight_include), _ =>
    1.23          {
    1.24 -          case Text.Info(info_range, XML.Elem(markup, _)) =>
    1.25 -            if (highlight_include(markup.name))
    1.26 +          case Text.Info(info_range, elem) =>
    1.27 +            if (highlight_include(elem.name))
    1.28                Some(Text.Info(snapshot.convert(info_range), highlight_color))
    1.29              else None
    1.30          }) match { case Text.Info(_, info) #:: _ => Some(info) case _ => None }
    1.31 @@ -257,8 +257,10 @@
    1.32            case Text.Info(info_range, elem @ Protocol.Dialog(_, serial, _))
    1.33            if !command_state.results.defined(serial) =>
    1.34              Some(Text.Info(snapshot.convert(info_range), elem))
    1.35 -          case Text.Info(info_range, elem @ XML.Elem(Markup(name, _), _)) =>
    1.36 -            if (name == Markup.BROWSER || name == Markup.GRAPHVIEW || name == Markup.SENDBACK)
    1.37 +          case Text.Info(info_range, elem) =>
    1.38 +            if (elem.name == Markup.BROWSER ||
    1.39 +                elem.name == Markup.GRAPHVIEW ||
    1.40 +                elem.name == Markup.SENDBACK)
    1.41                Some(Text.Info(snapshot.convert(info_range), elem))
    1.42              else None
    1.43          }) match { case Text.Info(_, info) #:: _ => Some(info) case _ => None }
    1.44 @@ -427,11 +429,11 @@
    1.45      val results =
    1.46        snapshot.cumulate_markup[Int](range, 0, Some(squiggly_include), _ =>
    1.47          {
    1.48 -          case (pri, Text.Info(_, msg @ XML.Elem(markup, _))) =>
    1.49 -            if (Protocol.is_information(msg))
    1.50 +          case (pri, Text.Info(_, elem)) =>
    1.51 +            if (Protocol.is_information(elem))
    1.52                Some(pri max Rendering.information_pri)
    1.53 -            else if (squiggly_include.contains(markup.name))
    1.54 -              Some(pri max Rendering.message_pri(markup.name))
    1.55 +            else if (squiggly_include.contains(elem.name))
    1.56 +              Some(pri max Rendering.message_pri(elem.name))
    1.57              else None
    1.58          })
    1.59      for {
    1.60 @@ -457,11 +459,12 @@
    1.61      val results =
    1.62        snapshot.cumulate_markup[Int](range, 0, Some(line_background_elements), _ =>
    1.63          {
    1.64 -          case (pri, Text.Info(_, XML.Elem(Markup(Markup.INFORMATION, _), _))) =>
    1.65 -            Some(pri max Rendering.information_pri)
    1.66 -          case (pri, Text.Info(_, XML.Elem(Markup(name, _), _))) =>
    1.67 -            if (name == Markup.WRITELN_MESSAGE || name == Markup.TRACING_MESSAGE ||
    1.68 -                name == Markup.WARNING_MESSAGE || name == Markup.ERROR_MESSAGE)
    1.69 +          case (pri, Text.Info(_, elem)) =>
    1.70 +            val name = elem.name
    1.71 +            if (name == Markup.INFORMATION)
    1.72 +              Some(pri max Rendering.information_pri)
    1.73 +            else if (name == Markup.WRITELN_MESSAGE || name == Markup.TRACING_MESSAGE ||
    1.74 +                elem.name == Markup.WARNING_MESSAGE || name == Markup.ERROR_MESSAGE)
    1.75                Some(pri max Rendering.message_pri(name))
    1.76              else None
    1.77          })
    1.78 @@ -470,8 +473,8 @@
    1.79      val is_separator = pri > 0 &&
    1.80        snapshot.cumulate_markup[Boolean](range, false, Some(Set(Markup.SEPARATOR)), _ =>
    1.81          {
    1.82 -          case (_, Text.Info(_, XML.Elem(Markup(Markup.SEPARATOR, _), _))) => Some(true)
    1.83 -          case _ => None
    1.84 +          case (_, Text.Info(_, elem)) =>
    1.85 +            if (elem.name == Markup.SEPARATOR) Some(true) else None
    1.86          }).exists(_.info)
    1.87  
    1.88      message_colors.get(pri).map((_, is_separator))
    1.89 @@ -512,8 +515,8 @@
    1.90                    case _ =>
    1.91                      Some((None, Some(active_color)))
    1.92                  }
    1.93 -              case (_, Text.Info(_, XML.Elem(markup, _))) =>
    1.94 -                if (active_include(markup.name)) Some((None, Some(active_color)))
    1.95 +              case (_, Text.Info(_, elem)) =>
    1.96 +                if (active_include(elem.name)) Some((None, Some(active_color)))
    1.97                  else None
    1.98              })
    1.99          color <-
   1.100 @@ -531,30 +534,29 @@
   1.101    def background2(range: Text.Range): Stream[Text.Info[Color]] =
   1.102      snapshot.select_markup(range, Some(Set(Markup.TOKEN_RANGE)), _ =>
   1.103        {
   1.104 -        case Text.Info(_, XML.Elem(Markup(Markup.TOKEN_RANGE, _), _)) => Some(light_color)
   1.105 -        case _ => None
   1.106 +        case Text.Info(_, elem) =>
   1.107 +          if (elem.name == Markup.TOKEN_RANGE) Some(light_color) else None
   1.108        })
   1.109  
   1.110  
   1.111    def bullet(range: Text.Range): Stream[Text.Info[Color]] =
   1.112      snapshot.select_markup(range, Some(Set(Markup.BULLET)), _ =>
   1.113        {
   1.114 -        case Text.Info(_, XML.Elem(Markup(Markup.BULLET, _), _)) => Some(bullet_color)
   1.115 -        case _ => None
   1.116 +        case Text.Info(_, elem) =>
   1.117 +          if (elem.name == Markup.BULLET) Some(bullet_color) else None
   1.118        })
   1.119  
   1.120  
   1.121 -  private val foreground_elements =
   1.122 +  private val foreground_include =
   1.123      Set(Markup.STRING, Markup.ALTSTRING, Markup.VERBATIM, Markup.ANTIQ)
   1.124  
   1.125    def foreground(range: Text.Range): Stream[Text.Info[Color]] =
   1.126 -    snapshot.select_markup(range, Some(foreground_elements), _ =>
   1.127 +    snapshot.select_markup(range, Some(foreground_include), _ =>
   1.128        {
   1.129 -        case Text.Info(_, XML.Elem(Markup(Markup.STRING, _), _)) => Some(quoted_color)
   1.130 -        case Text.Info(_, XML.Elem(Markup(Markup.ALTSTRING, _), _)) => Some(quoted_color)
   1.131 -        case Text.Info(_, XML.Elem(Markup(Markup.VERBATIM, _), _)) => Some(quoted_color)
   1.132 -        case Text.Info(_, XML.Elem(Markup(Markup.ANTIQ, _), _)) => Some(antiquoted_color)
   1.133 -        case _ => None
   1.134 +        case Text.Info(_, elem) =>
   1.135 +          if (elem.name == Markup.ANTIQ) Some(antiquoted_color)
   1.136 +          else if (foreground_include.contains(elem.name)) Some(quoted_color)
   1.137 +          else None
   1.138        })
   1.139  
   1.140  
   1.141 @@ -591,7 +593,7 @@
   1.142      else
   1.143        snapshot.cumulate_markup(range, color, Some(text_color_elements), _ =>
   1.144          {
   1.145 -          case (_, Text.Info(_, XML.Elem(markup, _))) => text_colors.get(markup.name)
   1.146 +          case (_, Text.Info(_, elem)) => text_colors.get(elem.name)
   1.147          })
   1.148    }
   1.149  
   1.150 @@ -603,7 +605,7 @@
   1.151    def fold_depth(range: Text.Range): Stream[Text.Info[Int]] =
   1.152      snapshot.cumulate_markup[Int](range, 0, Some(fold_depth_include), _ =>
   1.153        {
   1.154 -        case (depth, Text.Info(_, XML.Elem(markup, _))) =>
   1.155 -          if (fold_depth_include(markup.name)) Some(depth + 1) else None
   1.156 +        case (depth, Text.Info(_, elem)) =>
   1.157 +          if (fold_depth_include(elem.name)) Some(depth + 1) else None
   1.158        })
   1.159  }