Browse Source

Styliser no longer takes a context (that was a stupid idea!)

Channel now marks up nicknames

git-svn-id: http://svn.dmdirc.com/trunk@2453 00569f92-eb28-0410-84fd-f71c24880f
tags/0.5.5
Chris Smith 17 years ago
parent
commit
c1c692db54

+ 3
- 2
src/com/dmdirc/Channel.java View File

@@ -695,13 +695,14 @@ public final class Channel extends MessageTarget implements
695 695
     private String[] getDetails(final ChannelClientInfo client) {
696 696
         if (client == null) {
697 697
             // WTF?
698
-            Logger.appError(ErrorLevel.HIGH, "Channel.getDetails called with null ChannelClientInfo",
698
+            Logger.appError(ErrorLevel.HIGH,
699
+                    "Channel.getDetails called with null ChannelClientInfo",
699 700
                     new UnsupportedOperationException());
700 701
             return new String[]{"null", "null", "nullity.dmdirc.com"};
701 702
         }
702 703
         
703 704
         final String[] res = new String[3];
704
-        res[0] = client.getNickname();
705
+        res[0] = Styliser.CODE_NICKNAME + client.getNickname() + Styliser.CODE_NICKNAME;
705 706
         res[1] = client.getClient().getIdent();
706 707
         res[2] = client.getClient().getHost();
707 708
         

+ 15
- 10
src/com/dmdirc/ui/messages/Styliser.java View File

@@ -22,7 +22,6 @@
22 22
 
23 23
 package com.dmdirc.ui.messages;
24 24
 
25
-import com.dmdirc.FrameContainer;
26 25
 import com.dmdirc.config.ConfigChangeListener;
27 26
 import com.dmdirc.config.IdentityManager;
28 27
 import com.dmdirc.logger.ErrorLevel;
@@ -101,12 +100,15 @@ public final class Styliser {
101 100
     private static final String URL_CHANNEL = "(?i)(?<![^\\s])([#&]" + RESERVED_CHARS + "+)";
102 101
     
103 102
     /** Whether or not we should style links. */
104
-    private static boolean styleLinks = IdentityManager.getGlobalConfig().getOptionBool("ui", "stylelinks");
103
+    private static boolean styleLinks
104
+            = IdentityManager.getGlobalConfig().getOptionBool("ui", "stylelinks");
105 105
     
106 106
     static {
107
-        IdentityManager.getGlobalConfig().addChangeListener("ui", "stylelinks",new ConfigChangeListener() {
107
+        IdentityManager.getGlobalConfig().addChangeListener("ui", "stylelinks",
108
+                new ConfigChangeListener() {
108 109
             public void configChanged(final String domain, final String key) {
109
-                Styliser.styleLinks = IdentityManager.getGlobalConfig().getOptionBool("ui", "stylelinks");
110
+                Styliser.styleLinks
111
+                        = IdentityManager.getGlobalConfig().getOptionBool("ui", "stylelinks");
110 112
             }
111 113
         });
112 114
     }
@@ -119,11 +121,10 @@ public final class Styliser {
119 121
      * Stylises the specified string.
120 122
      *
121 123
      * @param strings The line to be stylised
122
-     * @param context The context of the string to be styled
123 124
      *
124 125
      * @return StyledDocument for the inputted strings
125 126
      */
126
-    public static StyledDocument getStyledString(final String[] strings, final FrameContainer context) {
127
+    public static StyledDocument getStyledString(final String[] strings) {
127 128
         final StyledDocument styledDoc = new DefaultStyledDocument();
128 129
         
129 130
         for (int i = 0; i < strings.length; i++) {
@@ -289,7 +290,8 @@ public final class Styliser {
289 290
             toggleLink(attribs);
290 291
             
291 292
             if (attribs.getAttribute(IRCTextAttribute.HYPERLINK) == null) {
292
-                attribs.addAttribute(IRCTextAttribute.HYPERLINK, readUntilControl(string.substring(1)));
293
+                attribs.addAttribute(IRCTextAttribute.HYPERLINK,
294
+                        readUntilControl(string.substring(1)));
293 295
             } else {
294 296
                 attribs.removeAttribute(IRCTextAttribute.HYPERLINK);
295 297
             }
@@ -299,7 +301,8 @@ public final class Styliser {
299 301
         // Channel links
300 302
         if (string.charAt(0) == CODE_CHANNEL) {
301 303
             if (attribs.getAttribute(IRCTextAttribute.CHANNEL) == null) {
302
-                attribs.addAttribute(IRCTextAttribute.CHANNEL, readUntilControl(string.substring(1)));
304
+                attribs.addAttribute(IRCTextAttribute.CHANNEL,
305
+                        readUntilControl(string.substring(1)));
303 306
             } else {
304 307
                 attribs.removeAttribute(IRCTextAttribute.CHANNEL);
305 308
             }
@@ -310,7 +313,8 @@ public final class Styliser {
310 313
         // Nickname links
311 314
         if (string.charAt(0) == CODE_NICKNAME) {
312 315
             if (attribs.getAttribute(IRCTextAttribute.NICKNAME) == null) {
313
-                attribs.addAttribute(IRCTextAttribute.NICKNAME, readUntilControl(string.substring(1)));
316
+                attribs.addAttribute(IRCTextAttribute.NICKNAME,
317
+                        readUntilControl(string.substring(1)));
314 318
             } else {
315 319
                 attribs.removeAttribute(IRCTextAttribute.NICKNAME);
316 320
             }
@@ -389,7 +393,8 @@ public final class Styliser {
389 393
                     count++;
390 394
                     setBackground(attribs, string.substring(count, count + 6).toUpperCase());
391 395
                     if (isStart) {
392
-                        setDefaultBackground(attribs, string.substring(count, count + 6).toUpperCase());
396
+                        setDefaultBackground(attribs, 
397
+                                string.substring(count, count + 6).toUpperCase());
393 398
                     }
394 399
                     count += 6;
395 400
                 }

+ 1
- 1
src/com/dmdirc/ui/swing/textpane/TextPane.java View File

@@ -143,7 +143,7 @@ public final class TextPane extends JComponent implements AdjustmentListener,
143 143
      */
144 144
     public void addStyledString(final String[] strings) {
145 145
         final AttributedString text = styledDocumentToAttributedString(
146
-                Styliser.getStyledString(strings, frame));
146
+                Styliser.getStyledString(strings));
147 147
         
148 148
         if (text.getIterator().getEndIndex() == 0) {
149 149
             addText(new AttributedString("\n"));

Loading…
Cancel
Save