Browse Source

Support optional colours for links in Styliser

Fixes issue 3909
Issue 3910

Change-Id: I516c80c198865bc69e85671a67298d7033402319
Reviewed-on: http://gerrit.dmdirc.com/1065
Automatic-Compile: DMDirc Local Commits <dmdirc@googlemail.com>
Reviewed-by: Gregory Holmes <greg@dmdirc.com>
tags/0.6.4rc1
Chris Smith 14 years ago
parent
commit
9f48468088
1 changed files with 16 additions and 11 deletions
  1. 16
    11
      src/com/dmdirc/ui/messages/Styliser.java

+ 16
- 11
src/com/dmdirc/ui/messages/Styliser.java View File

@@ -685,14 +685,17 @@ public class Styliser implements ConfigChangeListener {
685 685
                 attribs.addAttribute(StyleConstants.FontConstants.Underline, Boolean.TRUE);
686 686
             }
687 687
 
688
-            final Object foreground = attribs.getAttribute(StyleConstants.FontConstants.Foreground);
688
+            if (colour != null) {
689
+                final Object foreground = attribs.getAttribute(
690
+                        StyleConstants.FontConstants.Foreground);
689 691
 
690
-            if (foreground != null) {
691
-                attribs.addAttribute("restoreColour", foreground);
692
-                attribs.removeAttribute(StyleConstants.FontConstants.Foreground);
693
-            }
692
+                if (foreground != null) {
693
+                    attribs.addAttribute("restoreColour", foreground);
694
+                    attribs.removeAttribute(StyleConstants.FontConstants.Foreground);
695
+                }
694 696
 
695
-            attribs.addAttribute(StyleConstants.FontConstants.Foreground, colour);
697
+                attribs.addAttribute(StyleConstants.FontConstants.Foreground, colour);
698
+            }
696 699
 
697 700
         } else {
698 701
             // Remove the hyperlink style
@@ -703,11 +706,13 @@ public class Styliser implements ConfigChangeListener {
703 706
                 attribs.removeAttribute(StyleConstants.FontConstants.Underline);
704 707
             }
705 708
 
706
-            attribs.removeAttribute(StyleConstants.FontConstants.Foreground);
707
-            final Object foreground = attribs.getAttribute("restoreColour");
708
-            if (foreground != null) {
709
-                attribs.addAttribute(StyleConstants.FontConstants.Foreground, foreground);
710
-                attribs.removeAttribute("restoreColour");
709
+            if (colour != null) {
710
+                attribs.removeAttribute(StyleConstants.FontConstants.Foreground);
711
+                final Object foreground = attribs.getAttribute("restoreColour");
712
+                if (foreground != null) {
713
+                    attribs.addAttribute(StyleConstants.FontConstants.Foreground, foreground);
714
+                    attribs.removeAttribute("restoreColour");
715
+                }
711 716
             }
712 717
         }
713 718
     }

Loading…
Cancel
Save