You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by pa...@apache.org on 2026/04/16 21:07:17 UTC

(groovy) branch master updated: minor refactor: groovyConsole tweak - remove one hard-coded color

This is an automated email from the ASF dual-hosted git repository.

paulk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git


The following commit(s) were added to refs/heads/master by this push:
     new 6a393833d3 minor refactor: groovyConsole tweak - remove one hard-coded color
6a393833d3 is described below

commit 6a393833d3683816f1290c42ea652b35fb0444f6
Author: Paul King <pa...@asert.com.au>
AuthorDate: Fri Apr 17 07:07:00 2026 +1000

    minor refactor: groovyConsole tweak - remove one hard-coded color
---
 .../src/main/groovy/groovy/console/ui/text/GroovyFilter.java   | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/subprojects/groovy-console/src/main/groovy/groovy/console/ui/text/GroovyFilter.java b/subprojects/groovy-console/src/main/groovy/groovy/console/ui/text/GroovyFilter.java
index 1c9140dfb2..bb63787f6e 100644
--- a/subprojects/groovy-console/src/main/groovy/groovy/console/ui/text/GroovyFilter.java
+++ b/subprojects/groovy-console/src/main/groovy/groovy/console/ui/text/GroovyFilter.java
@@ -62,10 +62,6 @@ public class GroovyFilter extends StructuredSyntaxDocumentFilter {
     public static final String OPERATION = "[\\w\\$&&[\\D]][\\w\\$]* *\\(";
     public static final String LEFT_PARENS = "\\(";
 
-    private static final Color COMMENT_COLOR =
-            Color.LIGHT_GRAY.darker().darker();
-
-
     public static final String RESERVED_WORD = "reserved";
     public static final String[] RESERVED_WORDS = {"\\babstract\\b",
             "\\bassert\\b",
@@ -138,7 +134,7 @@ public class GroovyFilter extends StructuredSyntaxDocumentFilter {
         Style defaultStyle = styleContext.getStyle(StyleContext.DEFAULT_STYLE);
 
         Style comment = styleContext.addStyle(COMMENT, defaultStyle);
-        StyleConstants.setForeground(comment, COMMENT_COLOR);
+        StyleConstants.setForeground(comment, Color.LIGHT_GRAY.darker().darker());
         StyleConstants.setItalic(comment, true);
 
         Style quotes = styleContext.addStyle(QUOTES, defaultStyle);
@@ -240,7 +236,9 @@ public class GroovyFilter extends StructuredSyntaxDocumentFilter {
                 Element el = doc.getCharacterElement(offset);
                 Object color =
                         el.getAttributes().getAttribute(StyleConstants.Foreground);
-                if (!COMMENT_COLOR.equals(color)) {
+                Color commentColor = StyleConstants.getForeground(
+                        StyleContext.getDefaultStyleContext().getStyle(COMMENT));
+                if (!commentColor.equals(color)) {
                     cont = segment.array[offset] != '{' &&
                             segment.array[offset] != '}';
                 }