Преглед на файлове

Extract an interface for Styliser.

pull/724/head
Chris Smith преди 7 години
родител
ревизия
483306c022
променени са 2 файла, в които са добавени 63 реда и са изтрити 25 реда
  1. 59
    0
      src/main/java/com/dmdirc/ui/messages/StyleApplier.java
  2. 4
    25
      src/main/java/com/dmdirc/ui/messages/Styliser.java

+ 59
- 0
src/main/java/com/dmdirc/ui/messages/StyleApplier.java Целия файл

@@ -0,0 +1,59 @@
1
+/*
2
+ * Copyright (c) 2006-2016 DMDirc Developers
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.ui.messages;
24
+
25
+/**
26
+ * The styliser applies IRC styles to text. Styles are indicated by various control codes which are
27
+ * a de-facto IRC standard.
28
+ */
29
+public interface StyleApplier {
30
+
31
+    /** Character used to indicate hyperlinks. */
32
+    char CODE_HYPERLINK = 5;
33
+    /** Character used to indicate channel links. */
34
+    char CODE_CHANNEL = 6;
35
+    /** Character used to indicate smilies. */
36
+    char CODE_SMILIE = 7;
37
+    /** Character used to indicate nickname links. */
38
+    char CODE_NICKNAME = 16;
39
+    /** The character used for tooltips. */
40
+    char CODE_TOOLTIP = 19;
41
+
42
+    /**
43
+     * Stylises the specified strings and adds them to the specified maker.
44
+     *
45
+     * @param maker   The message maker to add styling to.
46
+     * @param strings The lines to be stylised
47
+     */
48
+    void addStyledString(StyledMessageMaker<?> maker, String... strings);
49
+
50
+    /**
51
+     * Applies the hyperlink styles and intelligent linking regexps to the target.
52
+     *
53
+     * @param string The string to be linked
54
+     *
55
+     * @return A copy of the string with hyperlinks marked up
56
+     */
57
+    String doLinks(String string);
58
+
59
+}

+ 4
- 25
src/main/java/com/dmdirc/ui/messages/Styliser.java Целия файл

@@ -35,18 +35,8 @@ import javax.annotation.Nullable;
35 35
  * The styliser applies IRC styles to text. Styles are indicated by various control codes which are
36 36
  * a de-facto IRC standard.
37 37
  */
38
-public class Styliser implements ConfigChangeListener {
39
-
40
-    /** Character used to indicate hyperlinks. */
41
-    public static final char CODE_HYPERLINK = 5;
42
-    /** Character used to indicate channel links. */
43
-    public static final char CODE_CHANNEL = 6;
44
-    /** Character used to indicate smilies. */
45
-    public static final char CODE_SMILIE = 7;
46
-    /** Character used to indicate nickname links. */
47
-    public static final char CODE_NICKNAME = 16;
48
-    /** The character used for tooltips. */
49
-    public static final char CODE_TOOLTIP = 19;
38
+public class Styliser implements ConfigChangeListener, StyleApplier {
39
+
50 40
     /** Internal chars. */
51 41
     private static final String INTERNAL_CHARS = String.valueOf(CODE_HYPERLINK)
52 42
             + CODE_NICKNAME + CODE_CHANNEL + CODE_SMILIE + CODE_TOOLTIP;
@@ -136,12 +126,7 @@ public class Styliser implements ConfigChangeListener {
136 126
                 configManager.getOptionString("ui", "channelcolour"), null);
137 127
     }
138 128
 
139
-    /**
140
-     * Stylises the specified strings and adds them to the specified maker.
141
-     *
142
-     * @param maker   The message maker to add styling to.
143
-     * @param strings The lines to be stylised
144
-     */
129
+    @Override
145 130
     public void addStyledString(final StyledMessageMaker<?> maker, final String... strings) {
146 131
         maker.resetAllStyles();
147 132
 
@@ -173,13 +158,7 @@ public class Styliser implements ConfigChangeListener {
173 158
         }
174 159
     }
175 160
 
176
-    /**
177
-     * Applies the hyperlink styles and intelligent linking regexps to the target.
178
-     *
179
-     * @param string The string to be linked
180
-     *
181
-     * @return A copy of the string with hyperlinks marked up
182
-     */
161
+    @Override
183 162
     public String doLinks(final String string) {
184 163
         String target = string;
185 164
         final String prefixes = connection == null ? null

Loading…
Отказ
Запис