浏览代码

More BackBuffer work.

- Only show each event once, don't propagate to servers.
- Use a setting to control whether it's enabled or not.
pull/214/head
Chris Smith 9 年前
父节点
当前提交
d76d5e3ce3
共有 2 个文件被更改,包括 11 次插入3 次删除
  1. 2
    0
      src/com/dmdirc/events/DisplayProperty.java
  2. 9
    3
      src/com/dmdirc/ui/messages/BackBuffer.java

+ 2
- 0
src/com/dmdirc/events/DisplayProperty.java 查看文件

@@ -33,5 +33,7 @@ public final class DisplayProperty<T> {
33 33
     public static final DisplayProperty<Colour> FOREGROUND_COLOUR = new DisplayProperty<>();
34 34
     /** The background colour of text relating to the event. */
35 35
     public static final DisplayProperty<Colour> BACKGROUND_COLOUR = new DisplayProperty<>();
36
+    /** Indicates the event has been successfully handled. */
37
+    public static final DisplayProperty<Boolean> HANDLED = new DisplayProperty<>();
36 38
 
37 39
 }

+ 9
- 3
src/com/dmdirc/ui/messages/BackBuffer.java 查看文件

@@ -24,6 +24,8 @@ package com.dmdirc.ui.messages;
24 24
 
25 25
 import com.dmdirc.DMDircMBassador;
26 26
 import com.dmdirc.FrameContainer;
27
+import com.dmdirc.config.ConfigBinding;
28
+import com.dmdirc.events.DisplayProperty;
27 29
 import com.dmdirc.events.DisplayableEvent;
28 30
 import com.dmdirc.interfaces.config.AggregateConfigProvider;
29 31
 
@@ -36,14 +38,15 @@ import net.engio.mbassy.listener.Handler;
36 38
  */
37 39
 public class BackBuffer {
38 40
 
39
-    private static final boolean ENABLED = false;
40
-
41 41
     private final IRCDocument document;
42 42
     private final Styliser styliser;
43 43
     private final DMDircMBassador eventBus;
44 44
     private final EventFormatter formatter;
45 45
     private final AggregateConfigProvider configProvider;
46 46
 
47
+    @ConfigBinding(domain="dev", key="enableNewEvents")
48
+    private boolean enabled;
49
+
47 50
     public BackBuffer(
48 51
             final FrameContainer owner,
49 52
             final ColourManagerFactory colourManagerFactory,
@@ -64,6 +67,7 @@ public class BackBuffer {
64 67
      */
65 68
     public void startAddingEvents() {
66 69
         eventBus.subscribe(this);
70
+        configProvider.getBinder().bind(this, BackBuffer.class);
67 71
     }
68 72
 
69 73
     /**
@@ -71,6 +75,7 @@ public class BackBuffer {
71 75
      */
72 76
     public void stopAddingEvents() {
73 77
         eventBus.unsubscribe(this);
78
+        configProvider.getBinder().unbind(this);
74 79
     }
75 80
 
76 81
     /**
@@ -80,10 +85,11 @@ public class BackBuffer {
80 85
      */
81 86
     @Handler
82 87
     public void handleDisplayableEvent(final DisplayableEvent event) {
83
-        if (ENABLED) {
88
+        if (enabled && !event.getDisplayProperty(DisplayProperty.HANDLED).isPresent()) {
84 89
             formatter.format(event)
85 90
                     .map(l -> new String[]{getTimestamp(event), l})
86 91
                     .ifPresent(document::addText);
92
+            event.setDisplayProperty(DisplayProperty.HANDLED, Boolean.TRUE);
87 93
         }
88 94
     }
89 95
 

正在加载...
取消
保存