Explorar el Código

Styliser now uses correct channel prefixes when linking channels

Fixes issue 2819

Change-Id: If417d9ebdcfe2bfcc790ab139eec403b0eb3ed96
Reviewed-on: http://gerrit.dmdirc.com/532
Automatic-Compile: Gregory Holmes <greboid@dmdirc.com>
Reviewed-by: Gregory Holmes <greboid@dmdirc.com>
tags/0.6.3b1
Chris Smith hace 14 años
padre
commit
376823bd4f
Se han modificado 2 ficheros con 17 adiciones y 3 borrados
  1. 11
    0
      src/com/dmdirc/Server.java
  2. 6
    3
      src/com/dmdirc/ui/messages/Styliser.java

+ 11
- 0
src/com/dmdirc/Server.java Ver fichero

@@ -895,6 +895,17 @@ public class Server extends WritableFrameContainer implements
895 895
         return profile;
896 896
     }
897 897
 
898
+    /**
899
+     * Retrieves the possible channel prefixes in use on this server.
900
+     *
901
+     * @return This server's possible channel prefixes
902
+     */
903
+    public String getChannelPrefixes() {
904
+        synchronized (parserLock) {
905
+            return parser == null ? "#&" : parser.getChannelPrefixes();
906
+        }
907
+    }
908
+
898 909
     /**
899 910
      * Retrieves the name of this server's network. The network name is
900 911
      * determined using the following rules:

+ 6
- 3
src/com/dmdirc/ui/messages/Styliser.java Ver fichero

@@ -121,7 +121,7 @@ public class Styliser implements ConfigChangeListener {
121 121
             + "[^" + CODE_HYPERLINK + "]+?)([" + URL_PUNCT + "]?)" + CODE_HYPERLINK;
122 122
     
123 123
     /** The regular expression to use for marking up channels. */
124
-    private static final String URL_CHANNEL = "(?i)(?<![^\\s\\+@\\-<>])([#&]" + RESERVED_CHARS + "+)";
124
+    private static final String URL_CHANNEL = "(?i)(?<![^\\s\\+@\\-<>])([\\Q%s\\E]" + RESERVED_CHARS + "+)";
125 125
     
126 126
     /** Whether or not we should style links. */
127 127
     private boolean styleLinks;
@@ -177,8 +177,11 @@ public class Styliser implements ConfigChangeListener {
177 177
                 int position = 0;
178 178
                 
179 179
                 String target = doSmilies(doLinks(new String(chars).replaceAll(INTERNAL_CHARS, "")));
180
-                
181
-                target = target.replaceAll(URL_CHANNEL, CODE_CHANNEL + "$0" + CODE_CHANNEL);
180
+
181
+                final String prefixes = owner.getServer() == null ? "#&"
182
+                        : owner.getServer().getChannelPrefixes();
183
+                target = target.replaceAll(String.format(URL_CHANNEL, prefixes),
184
+                        CODE_CHANNEL + "$0" + CODE_CHANNEL);
182 185
                 
183 186
                 attribs.addAttribute("DefaultFontFamily", UIManager.getFont("TextPane.font"));
184 187
                 

Loading…
Cancelar
Guardar