felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r1788071 - /felix/trunk/gogo/jline/src/main/java/org/apache/felix/gogo/jline/Highlighter.java
Date Wed, 22 Mar 2017 09:06:53 GMT
Author: gnodet
Date: Wed Mar 22 09:06:53 2017
New Revision: 1788071

URL: http://svn.apache.org/viewvc?rev=1788071&view=rev
Log:
[FELIX-5594][gogo][jline] Make sure the highlighter supports custom attributes containing
non color attributes

Modified:
    felix/trunk/gogo/jline/src/main/java/org/apache/felix/gogo/jline/Highlighter.java

Modified: felix/trunk/gogo/jline/src/main/java/org/apache/felix/gogo/jline/Highlighter.java
URL: http://svn.apache.org/viewvc/felix/trunk/gogo/jline/src/main/java/org/apache/felix/gogo/jline/Highlighter.java?rev=1788071&r1=1788070&r2=1788071&view=diff
==============================================================================
--- felix/trunk/gogo/jline/src/main/java/org/apache/felix/gogo/jline/Highlighter.java (original)
+++ felix/trunk/gogo/jline/src/main/java/org/apache/felix/gogo/jline/Highlighter.java Wed
Mar 22 09:06:53 2017
@@ -36,6 +36,7 @@ import org.jline.reader.LineReader.Regio
 import org.jline.reader.impl.DefaultHighlighter;
 import org.jline.utils.AttributedString;
 import org.jline.utils.AttributedStringBuilder;
+import org.jline.utils.AttributedStyle;
 import org.jline.utils.WCWidth;
 
 public class Highlighter extends DefaultHighlighter {
@@ -164,18 +165,15 @@ public class Highlighter extends Default
             }
 
             AttributedStringBuilder sb = new AttributedStringBuilder();
-            Type prevType = Type.Unknown;
             for (int i = 0; i < repaired.length(); i++) {
-                if (i == underlineStart) {
+                sb.style(AttributedStyle.DEFAULT);
+                applyStyle(sb, colors, types[i]);
+                if (i >= underlineStart && i <= underlineEnd) {
                     sb.style(sb.style().underline());
                 }
-                if (i == negativeStart) {
+                if (i >= negativeStart && i <= negativeEnd) {
                     sb.style(sb.style().inverse());
                 }
-                if (types[i] != prevType) {
-                    prevType = types[i];
-                    applyStyle(sb, colors, prevType);
-                }
                 char c = repaired.charAt(i);
                 if (c == '\t' || c == '\n') {
                     sb.append(c);
@@ -190,12 +188,6 @@ public class Highlighter extends Default
                         sb.append(c);
                     }
                 }
-                if (i == underlineEnd) {
-                    sb.style(sb.style().underlineOff());
-                }
-                if (i == negativeEnd) {
-                    sb.style(sb.style().inverseOff());
-                }
             }
 
             return sb.toAttributedString();
@@ -208,8 +200,6 @@ public class Highlighter extends Default
         String col = colors.get(type.color);
         if (col != null && !col.isEmpty()) {
             sb.appendAnsi("\033[" + col + "m");
-        } else {
-            sb.style(sb.style().foregroundDefault());
         }
     }
 



Mime
View raw message