@@ -88,6 +88,8 @@ public class REDUCEPanel extends BorderPane {
8888 private static final String SYMBOLIC_OUTPUT_CSS_CLASS = "symbolic-output" ;
8989 private static final String ALGEBRAIC_INPUT_CSS_CLASS = "algebraic-input" ;
9090 private static final String SYMBOLIC_INPUT_CSS_CLASS = "symbolic-input" ;
91+ private static final String WARNING_CSS_CLASS = "warning" ;
92+ private static final String ERROR_CSS_CLASS = "error" ;
9193 private String inputCSSClass ;
9294 private String outputCSSClass ;
9395 private HTMLElement fontSizeStyle ;
@@ -222,7 +224,9 @@ private void outputWebViewAvailable() {
222224 colorStyle = (HTMLElement ) doc .createElement ("style" );
223225 colorStyle .appendChild (doc .createTextNode (
224226 ".algebraic-output{color:blue}.symbolic-output{color:#800080}" +
225- ".algebraic-input{color:red}.symbolic-input{color:#800000}" ));
227+ ".algebraic-input{color:red}.symbolic-input{color:#800000}" +
228+ ".warning{background-color:#ffa50040}" + // orange, quarter opaque
229+ ".error{background-color:#ff000040}" )); // red, quarter opaque
226230 if (colouredIOState != RRPreferences .ColouredIO .NONE ) head .appendChild (colorStyle );
227231
228232 // Auto-run REDUCE if appropriate:
@@ -627,14 +631,22 @@ private void outputHeaderText(String text) {
627631 body .appendChild (outputElement );
628632 }
629633
634+ private static final Pattern WARNING_ERROR_PATTERN = Pattern .compile ("^\n (\\ *{3,5})" );
635+
630636 /**
631637 * Append output text to the WebView control with the specified CSS class.
632638 */
633639 private void outputText (String text , String cssClass ) {
640+ if (colouredIOState != RRPreferences .ColouredIO .NONE ) {
641+ Matcher matcher = WARNING_ERROR_PATTERN .matcher (text );
642+ if (matcher .find ()) {
643+ outputPlainText (text , matcher .group (1 ).equals ("***" ) ? WARNING_CSS_CLASS : ERROR_CSS_CLASS );
644+ return ;
645+ }
646+ }
634647 if (typesetMathsState ) {
635- if (RunREDUCE .runREDUCEFrame .showTeXMarkupCheckMenuItem .isSelected ()) {
648+ if (RunREDUCE .runREDUCEFrame .showTeXMarkupCheckMenuItem .isSelected ())
636649 outputPlainText (text , cssClass );
637- }
638650 outputTypesetMaths (text , cssClass );
639651 } else outputPlainText (text , cssClass );
640652 }
0 commit comments