瀏覽代碼

Add formatting action highlights.

Closes #669.
pull/686/head
Chris Smith 8 年之前
父節點
當前提交
1c60f29cb9

+ 8
- 0
res/com/dmdirc/ui/messages/format.yml 查看文件

@@ -121,6 +121,10 @@ ChannelQuitEvent:
121 121
 ChannelActionEvent:
122 122
   format: "* {{client.modePrefixedNickname}} {{message}}"
123 123
   colour: 6
124
+ChannelActionHighlightEvent:
125
+  format: "* {{client.modePrefixedNickname}} {{message}}"
126
+  colour: 6
127
+  background: F9C4BB
124 128
 ChannelSelfActionEvent:
125 129
   format: "* {{client.modePrefixedNickname}} {{message}}"
126 130
   colour: 6
@@ -195,6 +199,10 @@ channelUserBackEvent:
195 199
 QueryActionEvent:
196 200
   format: "* {{user.nickname}} {{message}}"
197 201
   colour: 6
202
+QueryActionHighlightEvent:
203
+  format: "* {{user.nickname}} {{message}}"
204
+  colour: 6
205
+  background: F9C4BB
198 206
 QuerySelfActionEvent:
199 207
   format: "* {{user.nickname}} {{message}}"
200 208
   colour: 6

+ 45
- 0
src/com/dmdirc/events/ChannelActionHighlightEvent.java 查看文件

@@ -0,0 +1,45 @@
1
+/*
2
+ * Copyright (c) 2006-2015 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.events;
24
+
25
+import com.dmdirc.interfaces.GroupChat;
26
+import com.dmdirc.interfaces.GroupChatUser;
27
+
28
+import java.time.LocalDateTime;
29
+
30
+/**
31
+ * Event raised when a highlight is detected in an action in a channel.
32
+ */
33
+public class ChannelActionHighlightEvent extends ChannelActionEvent {
34
+
35
+    public ChannelActionHighlightEvent(final LocalDateTime timestamp, final GroupChat channel,
36
+            final GroupChatUser client, final String message) {
37
+        super(timestamp, channel, client, message);
38
+    }
39
+
40
+    public ChannelActionHighlightEvent(final GroupChat channel, final GroupChatUser client,
41
+            final String message) {
42
+        super(channel, client, message);
43
+    }
44
+
45
+}

+ 44
- 0
src/com/dmdirc/events/QueryActionHighlightEvent.java 查看文件

@@ -0,0 +1,44 @@
1
+/*
2
+ * Copyright (c) 2006-2015 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.events;
24
+
25
+import com.dmdirc.Query;
26
+import com.dmdirc.interfaces.User;
27
+
28
+import java.time.LocalDateTime;
29
+
30
+/**
31
+ * Event raised when a highlight is detected in an action query.
32
+ */
33
+public class QueryActionHighlightEvent extends QueryActionEvent {
34
+
35
+    public QueryActionHighlightEvent(final LocalDateTime timestamp, final Query query,
36
+            final User user, final String message) {
37
+        super(timestamp, query, user, message);
38
+    }
39
+
40
+    public QueryActionHighlightEvent(final Query query, final User user, final String message) {
41
+        super(query, user, message);
42
+    }
43
+
44
+}

+ 28
- 0
src/com/dmdirc/ui/messages/HighlightManager.java 查看文件

@@ -22,9 +22,13 @@
22 22
 
23 23
 package com.dmdirc.ui.messages;
24 24
 
25
+import com.dmdirc.events.ChannelActionEvent;
26
+import com.dmdirc.events.ChannelActionHighlightEvent;
25 27
 import com.dmdirc.events.ChannelHighlightEvent;
26 28
 import com.dmdirc.events.ChannelMessageEvent;
27 29
 import com.dmdirc.events.DisplayProperty;
30
+import com.dmdirc.events.QueryActionEvent;
31
+import com.dmdirc.events.QueryActionHighlightEvent;
28 32
 import com.dmdirc.events.QueryHighlightEvent;
29 33
 import com.dmdirc.events.QueryMessageEvent;
30 34
 import com.dmdirc.events.ServerConnectedEvent;
@@ -68,6 +72,18 @@ public class HighlightManager {
68 72
         }
69 73
     }
70 74
 
75
+    @Handler(rejectSubtypes = true)
76
+    void handleChannelAction(final ChannelActionEvent event) {
77
+        if (event.getChannel().getConnection().get().getWindowModel().equals(serverWindow)
78
+                && patterns.stream().anyMatch(p -> p.matcher(event.getMessage()).matches())) {
79
+            event.setDisplayProperty(DisplayProperty.DO_NOT_DISPLAY, true);
80
+            event.getChannel().getEventBus().publish(
81
+                    new ChannelActionHighlightEvent(
82
+                            event.getTimestamp(), event.getChannel(), event.getClient(),
83
+                            event.getMessage()));
84
+        }
85
+    }
86
+
71 87
     @Handler(rejectSubtypes = true)
72 88
     void handleQueryMessage(final QueryMessageEvent event) {
73 89
         if (event.getUser().getConnection().getWindowModel().equals(serverWindow)
@@ -80,6 +96,18 @@ public class HighlightManager {
80 96
         }
81 97
     }
82 98
 
99
+    @Handler(rejectSubtypes = true)
100
+    void handleQueryMessage(final QueryActionEvent event) {
101
+        if (event.getUser().getConnection().getWindowModel().equals(serverWindow)
102
+                && patterns.stream().anyMatch(p -> p.matcher(event.getMessage()).matches())) {
103
+            event.setDisplayProperty(DisplayProperty.DO_NOT_DISPLAY, true);
104
+            event.getQuery().getEventBus().publish(
105
+                    new QueryActionHighlightEvent(
106
+                            event.getTimestamp(), event.getQuery(), event.getUser(),
107
+                            event.getMessage()));
108
+        }
109
+    }
110
+
83 111
     @Handler
84 112
     void handleNickChange(final ServerNickChangeEvent event) {
85 113
         if (event.getConnection().getWindowModel().equals(serverWindow)) {

Loading…
取消
儲存