152 else { |
152 else { |
153 val results = |
153 val results = |
154 snapshot.cumulate_markup[(Protocol.Status, Int)]( |
154 snapshot.cumulate_markup[(Protocol.Status, Int)]( |
155 range, (Protocol.Status.init, 0), Some(overview_include), _ => |
155 range, (Protocol.Status.init, 0), Some(overview_include), _ => |
156 { |
156 { |
157 case ((status, pri), Text.Info(_, XML.Elem(markup, _))) => |
157 case ((status, pri), Text.Info(_, elem)) => |
158 if (markup.name == Markup.WARNING || markup.name == Markup.ERROR) |
158 if (elem.name == Markup.WARNING || elem.name == Markup.ERROR) |
159 Some((status, pri max Rendering.message_pri(markup.name))) |
159 Some((status, pri max Rendering.message_pri(elem.name))) |
160 else if (overview_include(markup.name)) |
160 else if (overview_include(elem.name)) |
161 Some((Protocol.command_status(status, markup), pri)) |
161 Some((Protocol.command_status(status, elem.markup), pri)) |
162 else None |
162 else None |
163 }) |
163 }) |
164 if (results.isEmpty) None |
164 if (results.isEmpty) None |
165 else { |
165 else { |
166 val (status, pri) = |
166 val (status, pri) = |
187 |
187 |
188 def highlight(range: Text.Range): Option[Text.Info[Color]] = |
188 def highlight(range: Text.Range): Option[Text.Info[Color]] = |
189 { |
189 { |
190 snapshot.select_markup(range, Some(highlight_include), _ => |
190 snapshot.select_markup(range, Some(highlight_include), _ => |
191 { |
191 { |
192 case Text.Info(info_range, XML.Elem(markup, _)) => |
192 case Text.Info(info_range, elem) => |
193 if (highlight_include(markup.name)) |
193 if (highlight_include(elem.name)) |
194 Some(Text.Info(snapshot.convert(info_range), highlight_color)) |
194 Some(Text.Info(snapshot.convert(info_range), highlight_color)) |
195 else None |
195 else None |
196 }) match { case Text.Info(_, info) #:: _ => Some(info) case _ => None } |
196 }) match { case Text.Info(_, info) #:: _ => Some(info) case _ => None } |
197 } |
197 } |
198 |
198 |
255 snapshot.select_markup(range, Some(active_include), command_state => |
255 snapshot.select_markup(range, Some(active_include), command_state => |
256 { |
256 { |
257 case Text.Info(info_range, elem @ Protocol.Dialog(_, serial, _)) |
257 case Text.Info(info_range, elem @ Protocol.Dialog(_, serial, _)) |
258 if !command_state.results.defined(serial) => |
258 if !command_state.results.defined(serial) => |
259 Some(Text.Info(snapshot.convert(info_range), elem)) |
259 Some(Text.Info(snapshot.convert(info_range), elem)) |
260 case Text.Info(info_range, elem @ XML.Elem(Markup(name, _), _)) => |
260 case Text.Info(info_range, elem) => |
261 if (name == Markup.BROWSER || name == Markup.GRAPHVIEW || name == Markup.SENDBACK) |
261 if (elem.name == Markup.BROWSER || |
|
262 elem.name == Markup.GRAPHVIEW || |
|
263 elem.name == Markup.SENDBACK) |
262 Some(Text.Info(snapshot.convert(info_range), elem)) |
264 Some(Text.Info(snapshot.convert(info_range), elem)) |
263 else None |
265 else None |
264 }) match { case Text.Info(_, info) #:: _ => Some(info) case _ => None } |
266 }) match { case Text.Info(_, info) #:: _ => Some(info) case _ => None } |
265 |
267 |
266 |
268 |
425 def squiggly_underline(range: Text.Range): Stream[Text.Info[Color]] = |
427 def squiggly_underline(range: Text.Range): Stream[Text.Info[Color]] = |
426 { |
428 { |
427 val results = |
429 val results = |
428 snapshot.cumulate_markup[Int](range, 0, Some(squiggly_include), _ => |
430 snapshot.cumulate_markup[Int](range, 0, Some(squiggly_include), _ => |
429 { |
431 { |
430 case (pri, Text.Info(_, msg @ XML.Elem(markup, _))) => |
432 case (pri, Text.Info(_, elem)) => |
431 if (Protocol.is_information(msg)) |
433 if (Protocol.is_information(elem)) |
432 Some(pri max Rendering.information_pri) |
434 Some(pri max Rendering.information_pri) |
433 else if (squiggly_include.contains(markup.name)) |
435 else if (squiggly_include.contains(elem.name)) |
434 Some(pri max Rendering.message_pri(markup.name)) |
436 Some(pri max Rendering.message_pri(elem.name)) |
435 else None |
437 else None |
436 }) |
438 }) |
437 for { |
439 for { |
438 Text.Info(r, pri) <- results |
440 Text.Info(r, pri) <- results |
439 color <- squiggly_colors.get(pri) |
441 color <- squiggly_colors.get(pri) |
455 def line_background(range: Text.Range): Option[(Color, Boolean)] = |
457 def line_background(range: Text.Range): Option[(Color, Boolean)] = |
456 { |
458 { |
457 val results = |
459 val results = |
458 snapshot.cumulate_markup[Int](range, 0, Some(line_background_elements), _ => |
460 snapshot.cumulate_markup[Int](range, 0, Some(line_background_elements), _ => |
459 { |
461 { |
460 case (pri, Text.Info(_, XML.Elem(Markup(Markup.INFORMATION, _), _))) => |
462 case (pri, Text.Info(_, elem)) => |
461 Some(pri max Rendering.information_pri) |
463 val name = elem.name |
462 case (pri, Text.Info(_, XML.Elem(Markup(name, _), _))) => |
464 if (name == Markup.INFORMATION) |
463 if (name == Markup.WRITELN_MESSAGE || name == Markup.TRACING_MESSAGE || |
465 Some(pri max Rendering.information_pri) |
464 name == Markup.WARNING_MESSAGE || name == Markup.ERROR_MESSAGE) |
466 else if (name == Markup.WRITELN_MESSAGE || name == Markup.TRACING_MESSAGE || |
|
467 elem.name == Markup.WARNING_MESSAGE || name == Markup.ERROR_MESSAGE) |
465 Some(pri max Rendering.message_pri(name)) |
468 Some(pri max Rendering.message_pri(name)) |
466 else None |
469 else None |
467 }) |
470 }) |
468 val pri = (0 /: results) { case (p1, Text.Info(_, p2)) => p1 max p2 } |
471 val pri = (0 /: results) { case (p1, Text.Info(_, p2)) => p1 max p2 } |
469 |
472 |
470 val is_separator = pri > 0 && |
473 val is_separator = pri > 0 && |
471 snapshot.cumulate_markup[Boolean](range, false, Some(Set(Markup.SEPARATOR)), _ => |
474 snapshot.cumulate_markup[Boolean](range, false, Some(Set(Markup.SEPARATOR)), _ => |
472 { |
475 { |
473 case (_, Text.Info(_, XML.Elem(Markup(Markup.SEPARATOR, _), _))) => Some(true) |
476 case (_, Text.Info(_, elem)) => |
474 case _ => None |
477 if (elem.name == Markup.SEPARATOR) Some(true) else None |
475 }).exists(_.info) |
478 }).exists(_.info) |
476 |
479 |
477 message_colors.get(pri).map((_, is_separator)) |
480 message_colors.get(pri).map((_, is_separator)) |
478 } |
481 } |
479 |
482 |
510 case Some(Protocol.Dialog_Result(res)) if res == result => |
513 case Some(Protocol.Dialog_Result(res)) if res == result => |
511 Some((None, Some(active_result_color))) |
514 Some((None, Some(active_result_color))) |
512 case _ => |
515 case _ => |
513 Some((None, Some(active_color))) |
516 Some((None, Some(active_color))) |
514 } |
517 } |
515 case (_, Text.Info(_, XML.Elem(markup, _))) => |
518 case (_, Text.Info(_, elem)) => |
516 if (active_include(markup.name)) Some((None, Some(active_color))) |
519 if (active_include(elem.name)) Some((None, Some(active_color))) |
517 else None |
520 else None |
518 }) |
521 }) |
519 color <- |
522 color <- |
520 (result match { |
523 (result match { |
521 case (Some(status), opt_color) => |
524 case (Some(status), opt_color) => |
529 |
532 |
530 |
533 |
531 def background2(range: Text.Range): Stream[Text.Info[Color]] = |
534 def background2(range: Text.Range): Stream[Text.Info[Color]] = |
532 snapshot.select_markup(range, Some(Set(Markup.TOKEN_RANGE)), _ => |
535 snapshot.select_markup(range, Some(Set(Markup.TOKEN_RANGE)), _ => |
533 { |
536 { |
534 case Text.Info(_, XML.Elem(Markup(Markup.TOKEN_RANGE, _), _)) => Some(light_color) |
537 case Text.Info(_, elem) => |
535 case _ => None |
538 if (elem.name == Markup.TOKEN_RANGE) Some(light_color) else None |
536 }) |
539 }) |
537 |
540 |
538 |
541 |
539 def bullet(range: Text.Range): Stream[Text.Info[Color]] = |
542 def bullet(range: Text.Range): Stream[Text.Info[Color]] = |
540 snapshot.select_markup(range, Some(Set(Markup.BULLET)), _ => |
543 snapshot.select_markup(range, Some(Set(Markup.BULLET)), _ => |
541 { |
544 { |
542 case Text.Info(_, XML.Elem(Markup(Markup.BULLET, _), _)) => Some(bullet_color) |
545 case Text.Info(_, elem) => |
543 case _ => None |
546 if (elem.name == Markup.BULLET) Some(bullet_color) else None |
544 }) |
547 }) |
545 |
548 |
546 |
549 |
547 private val foreground_elements = |
550 private val foreground_include = |
548 Set(Markup.STRING, Markup.ALTSTRING, Markup.VERBATIM, Markup.ANTIQ) |
551 Set(Markup.STRING, Markup.ALTSTRING, Markup.VERBATIM, Markup.ANTIQ) |
549 |
552 |
550 def foreground(range: Text.Range): Stream[Text.Info[Color]] = |
553 def foreground(range: Text.Range): Stream[Text.Info[Color]] = |
551 snapshot.select_markup(range, Some(foreground_elements), _ => |
554 snapshot.select_markup(range, Some(foreground_include), _ => |
552 { |
555 { |
553 case Text.Info(_, XML.Elem(Markup(Markup.STRING, _), _)) => Some(quoted_color) |
556 case Text.Info(_, elem) => |
554 case Text.Info(_, XML.Elem(Markup(Markup.ALTSTRING, _), _)) => Some(quoted_color) |
557 if (elem.name == Markup.ANTIQ) Some(antiquoted_color) |
555 case Text.Info(_, XML.Elem(Markup(Markup.VERBATIM, _), _)) => Some(quoted_color) |
558 else if (foreground_include.contains(elem.name)) Some(quoted_color) |
556 case Text.Info(_, XML.Elem(Markup(Markup.ANTIQ, _), _)) => Some(antiquoted_color) |
559 else None |
557 case _ => None |
|
558 }) |
560 }) |
559 |
561 |
560 |
562 |
561 private val text_colors: Map[String, Color] = Map( |
563 private val text_colors: Map[String, Color] = Map( |
562 Markup.KEYWORD1 -> keyword1_color, |
564 Markup.KEYWORD1 -> keyword1_color, |
589 { |
591 { |
590 if (color == Token_Markup.hidden_color) Stream(Text.Info(range, color)) |
592 if (color == Token_Markup.hidden_color) Stream(Text.Info(range, color)) |
591 else |
593 else |
592 snapshot.cumulate_markup(range, color, Some(text_color_elements), _ => |
594 snapshot.cumulate_markup(range, color, Some(text_color_elements), _ => |
593 { |
595 { |
594 case (_, Text.Info(_, XML.Elem(markup, _))) => text_colors.get(markup.name) |
596 case (_, Text.Info(_, elem)) => text_colors.get(elem.name) |
595 }) |
597 }) |
596 } |
598 } |
597 |
599 |
598 |
600 |
599 /* nested text structure -- folds */ |
601 /* nested text structure -- folds */ |
601 private val fold_depth_include = Set(Markup.TEXT_FOLD, Markup.GOAL, Markup.SUBGOAL) |
603 private val fold_depth_include = Set(Markup.TEXT_FOLD, Markup.GOAL, Markup.SUBGOAL) |
602 |
604 |
603 def fold_depth(range: Text.Range): Stream[Text.Info[Int]] = |
605 def fold_depth(range: Text.Range): Stream[Text.Info[Int]] = |
604 snapshot.cumulate_markup[Int](range, 0, Some(fold_depth_include), _ => |
606 snapshot.cumulate_markup[Int](range, 0, Some(fold_depth_include), _ => |
605 { |
607 { |
606 case (depth, Text.Info(_, XML.Elem(markup, _))) => |
608 case (depth, Text.Info(_, elem)) => |
607 if (fold_depth_include(markup.name)) Some(depth + 1) else None |
609 if (fold_depth_include(elem.name)) Some(depth + 1) else None |
608 }) |
610 }) |
609 } |
611 } |