diff --git a/src/main/java/com/rohitawate/everest/controllers/codearea/EverestCodeArea.java b/src/main/java/com/rohitawate/everest/controllers/codearea/EverestCodeArea.java index 4f93311..42759df 100644 --- a/src/main/java/com/rohitawate/everest/controllers/codearea/EverestCodeArea.java +++ b/src/main/java/com/rohitawate/everest/controllers/codearea/EverestCodeArea.java @@ -2,6 +2,7 @@ package com.rohitawate.everest.controllers.codearea; import com.rohitawate.everest.controllers.codearea.highlighters.Highlighter; import com.rohitawate.everest.controllers.codearea.highlighters.JSONHighlighter; +import com.rohitawate.everest.controllers.codearea.highlighters.PlaintextHighlighter; import com.rohitawate.everest.controllers.codearea.highlighters.XMLHighlighter; import com.rohitawate.everest.util.settings.Settings; import javafx.geometry.Insets; @@ -15,8 +16,10 @@ public class EverestCodeArea extends CodeArea { } private Highlighter highlighter; - private JSONHighlighter jsonHighlighter; - private XMLHighlighter xmlHighlighter; + + private static JSONHighlighter jsonHighlighter; + private static XMLHighlighter xmlHighlighter; + private static PlaintextHighlighter plaintextHighlighter; public EverestCodeArea() { this.getStylesheets().add(getClass().getResource("/css/syntax/Moondust.css").toString()); @@ -26,6 +29,7 @@ public class EverestCodeArea extends CodeArea { jsonHighlighter = new JSONHighlighter(); xmlHighlighter = new XMLHighlighter(); + plaintextHighlighter = new PlaintextHighlighter(); setMode(HighlightMode.PLAIN); @@ -39,9 +43,12 @@ public class EverestCodeArea extends CodeArea { case JSON: highlighter = jsonHighlighter; break; - default: + case XML: + case HTML: highlighter = xmlHighlighter; break; + default: + highlighter = plaintextHighlighter; } // Re-computes the highlighting for the new mode diff --git a/src/main/java/com/rohitawate/everest/controllers/codearea/highlighters/PlaintextHighlighter.java b/src/main/java/com/rohitawate/everest/controllers/codearea/highlighters/PlaintextHighlighter.java new file mode 100644 index 0000000..6eaa437 --- /dev/null +++ b/src/main/java/com/rohitawate/everest/controllers/codearea/highlighters/PlaintextHighlighter.java @@ -0,0 +1,18 @@ +package com.rohitawate.everest.controllers.codearea.highlighters; + +import org.fxmisc.richtext.model.StyleSpans; +import org.fxmisc.richtext.model.StyleSpansBuilder; + +import java.util.Collection; +import java.util.Collections; + +public class PlaintextHighlighter implements Highlighter { + @Override + public StyleSpans> computeHighlighting(String text) { + StyleSpansBuilder> spansBuilder + = new StyleSpansBuilder<>(); + + spansBuilder.add(Collections.singleton("plain-text"), text.length()); + return spansBuilder.create(); + } +} diff --git a/src/main/resources/css/syntax/Moondust.css b/src/main/resources/css/syntax/Moondust.css index 7346718..fe6d6b6 100644 --- a/src/main/resources/css/syntax/Moondust.css +++ b/src/main/resources/css/syntax/Moondust.css @@ -14,6 +14,10 @@ -fx-stroke: white; } +.plain-text { + -fx-fill: azure !important; +} + /*Common to JSON and XML*/ .xml_bracket,