Переглянути джерело

Colour events.

pull/248/head
Chris Smith 9 роки тому
джерело
коміт
78063df0b4

+ 2
- 2
src/com/dmdirc/events/DisplayPropertyMap.java Переглянути файл

@@ -24,7 +24,7 @@ package com.dmdirc.events;
24 24
 
25 25
 import java.util.Map;
26 26
 import java.util.Optional;
27
-import java.util.concurrent.ConcurrentSkipListMap;
27
+import java.util.concurrent.ConcurrentHashMap;
28 28
 
29 29
 /**
30 30
  * Provides a map of {@link DisplayProperty}s to values, maintaining type safety.
@@ -33,7 +33,7 @@ public class DisplayPropertyMap {
33 33
 
34 34
     public static final DisplayPropertyMap EMPTY = new ReadOnlyDisplayPropertyMap();
35 35
 
36
-    private final Map<DisplayProperty<?>, Object> properties = new ConcurrentSkipListMap<>();
36
+    private final Map<DisplayProperty<?>, Object> properties = new ConcurrentHashMap<>();
37 37
 
38 38
     /**
39 39
      * Gets the value of the specified property, if present.

+ 7
- 0
src/com/dmdirc/ui/messages/CachingDocument.java Переглянути файл

@@ -22,7 +22,11 @@
22 22
 
23 23
 package com.dmdirc.ui.messages;
24 24
 
25
+import com.dmdirc.events.DisplayProperty;
25 26
 import com.dmdirc.util.collections.RollingList;
27
+import com.dmdirc.util.colours.Colour;
28
+
29
+import java.util.Optional;
26 30
 
27 31
 /**
28 32
  * Wraps an {@link IRCDocument} and caches recent lines.
@@ -63,6 +67,9 @@ public class CachingDocument<T> {
63 67
         }
64 68
 
65 69
         if (styledLine == null) {
70
+            final Optional<Colour> foregroundColour =
71
+                    line.getDisplayableProperty(DisplayProperty.FOREGROUND_COLOUR);
72
+            foregroundColour.ifPresent(maker::setDefaultForeground);
66 73
             styledLine = line.getStyled(maker);
67 74
             cachedLines.add(line);
68 75
             cachedStrings.add(styledLine);

+ 7
- 1
src/com/dmdirc/ui/messages/Line.java Переглянути файл

@@ -22,9 +22,11 @@
22 22
 
23 23
 package com.dmdirc.ui.messages;
24 24
 
25
+import com.dmdirc.events.DisplayProperty;
25 26
 import com.dmdirc.events.DisplayPropertyMap;
26 27
 
27 28
 import java.util.Arrays;
29
+import java.util.Optional;
28 30
 
29 31
 /**
30 32
  * Represents a line of text in IRC.
@@ -129,10 +131,10 @@ public class Line {
129 131
      * @return AttributedString representing the specified StyledDocument
130 132
      */
131 133
     public <T> T getStyled(final StyledMessageMaker<T> maker) {
132
-        maker.clear();
133 134
         maker.setDefaultFont(fontName, fontSize);
134 135
         final T styledString = styliser.getStyledString(getLineParts(), maker);
135 136
         fontSize = maker.getMaximumFontSize();
137
+        maker.clear();
136 138
         return styledString;
137 139
     }
138 140
 
@@ -146,4 +148,8 @@ public class Line {
146 148
         return Arrays.hashCode(getLineParts());
147 149
     }
148 150
 
151
+    public <T> Optional<T> getDisplayableProperty(final DisplayProperty<T> property) {
152
+        return displayProperties.get(property);
153
+    }
154
+
149 155
 }

Завантаження…
Відмінити
Зберегти