src/Tools/jEdit/src/rendering.scala
changeset 56354 a6f8c3566560
parent 56352 abdc524db8b4
child 56359 bca016a9a18d
equal deleted inserted replaced
56353:ecbdfe30bf7f 56354:a6f8c3566560
   378 
   378 
   379 
   379 
   380   /* active elements */
   380   /* active elements */
   381 
   381 
   382   def active(range: Text.Range): Option[Text.Info[XML.Elem]] =
   382   def active(range: Text.Range): Option[Text.Info[XML.Elem]] =
   383     snapshot.select(range, Rendering.active_elements, command_results =>
   383     snapshot.select(range, Rendering.active_elements, command_states =>
   384       {
   384       {
   385         case Text.Info(info_range, elem) =>
   385         case Text.Info(info_range, elem) =>
   386           if (elem.name == Markup.DIALOG) {
   386           if (elem.name == Markup.DIALOG) {
   387             elem match {
   387             elem match {
   388               case Protocol.Dialog(_, serial, _)
   388               case Protocol.Dialog(_, serial, _)
   389               if !command_results.defined(serial) =>
   389               if !command_states.exists(st => st.results.defined(serial)) =>
   390                 Some(Text.Info(snapshot.convert(info_range), elem))
   390                 Some(Text.Info(snapshot.convert(info_range), elem))
   391               case _ => None
   391               case _ => None
   392             }
   392             }
   393           }
   393           }
   394           else Some(Text.Info(snapshot.convert(info_range), elem))
   394           else Some(Text.Info(snapshot.convert(info_range), elem))
   395       }).headOption.map(_.info)
   395       }).headOption.map(_.info)
   396 
   396 
   397   def command_results(range: Text.Range): Command.Results =
   397   def command_results(range: Text.Range): Command.Results =
   398   {
   398     Command.State.merge_results(
   399     val results =
   399       snapshot.select[List[Command.State]](range, Document.Elements.full, command_states =>
   400       snapshot.select[Command.Results](range, Document.Elements.full, command_results =>
   400         { case _ => Some(command_states) }).flatMap(_.info))
   401         { case _ => Some(command_results) }).map(_.info)
       
   402     (Command.Results.empty /: results)(_ ++ _)
       
   403   }
       
   404 
   401 
   405 
   402 
   406   /* tooltip messages */
   403   /* tooltip messages */
   407 
   404 
   408   def tooltip_message(range: Text.Range): Option[Text.Info[XML.Body]] =
   405   def tooltip_message(range: Text.Range): Option[Text.Info[XML.Body]] =
   604     else
   601     else
   605       for {
   602       for {
   606         Text.Info(r, result) <-
   603         Text.Info(r, result) <-
   607           snapshot.cumulate[(List[Markup], Option[Color])](
   604           snapshot.cumulate[(List[Markup], Option[Color])](
   608             range, (List(Markup.Empty), None), Rendering.background_elements,
   605             range, (List(Markup.Empty), None), Rendering.background_elements,
   609             command_results =>
   606             command_states =>
   610               {
   607               {
   611                 case (((status, color), Text.Info(_, XML.Elem(markup, _))))
   608                 case (((status, color), Text.Info(_, XML.Elem(markup, _))))
   612                 if !status.isEmpty && Protocol.command_status_elements(markup.name) =>
   609                 if !status.isEmpty && Protocol.command_status_elements(markup.name) =>
   613                   Some((markup :: status, color))
   610                   Some((markup :: status, color))
   614                 case (_, Text.Info(_, XML.Elem(Markup(Markup.BAD, _), _))) =>
   611                 case (_, Text.Info(_, XML.Elem(Markup(Markup.BAD, _), _))) =>
   615                   Some((Nil, Some(bad_color)))
   612                   Some((Nil, Some(bad_color)))
   616                 case (_, Text.Info(_, XML.Elem(Markup(Markup.INTENSIFY, _), _))) =>
   613                 case (_, Text.Info(_, XML.Elem(Markup(Markup.INTENSIFY, _), _))) =>
   617                   Some((Nil, Some(intensify_color)))
   614                   Some((Nil, Some(intensify_color)))
   618                 case (acc, Text.Info(_, Protocol.Dialog(_, serial, result))) =>
   615                 case (acc, Text.Info(_, Protocol.Dialog(_, serial, result))) =>
   619                   command_results.get(serial) match {
   616                   command_states.collectFirst(
       
   617                     { case st if st.results.defined(serial) => st.results.get(serial).get }) match
       
   618                   {
   620                     case Some(Protocol.Dialog_Result(res)) if res == result =>
   619                     case Some(Protocol.Dialog_Result(res)) if res == result =>
   621                       Some((Nil, Some(active_result_color)))
   620                       Some((Nil, Some(active_result_color)))
   622                     case _ =>
   621                     case _ =>
   623                       Some((Nil, Some(active_color)))
   622                       Some((Nil, Some(active_color)))
   624                   }
   623                   }