Skip to content

Commit 757e029

Browse files
committed
v2.25 Highlight warnings and errors with an appropriate background colour.
1 parent e9fe773 commit 757e029

3 files changed

Lines changed: 17 additions & 4 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,3 +259,4 @@ selected.
259259
clean restart of the last-run REDUCE command.
260260
* Give sqrt a width of 3 but remove the width of the n in an nth root.
261261
The output from "int.tst" is now reasonable.
262+
* v2.25 Highlight warnings and errors with an appropriate background colour.

src/fjwright/runreduce/REDUCEPanel.java

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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
}

src/fjwright/runreduce/RunREDUCEFrame.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,7 @@ private void sourceForgeMenuItemAction() {
668668
RunREDUCE.hostServices.showDocument("https://sourceforge.net/projects/reduce-algebra/");
669669
}
670670

671-
static final String VERSION = "2.24";
671+
static final String VERSION = "2.25";
672672

673673
@FXML
674674
private void aboutMenuItemAction() {

0 commit comments

Comments
 (0)