Bladeren bron

Merge pull request #447 from csmith/master

Switch some more plugins to use new events.
pull/448/head
Greg Holmes 8 jaren geleden
bovenliggende
commit
5246454515

+ 5
- 4
debug/src/com/dmdirc/addons/debug/commands/Benchmark.java Bestand weergeven

@@ -26,6 +26,7 @@ import com.dmdirc.addons.debug.Debug;
26 26
 import com.dmdirc.addons.debug.DebugCommand;
27 27
 import com.dmdirc.commandparser.CommandArguments;
28 28
 import com.dmdirc.commandparser.commands.context.CommandContext;
29
+import com.dmdirc.events.CommandOutputEvent;
29 30
 import com.dmdirc.interfaces.WindowModel;
30 31
 
31 32
 import javax.annotation.Nonnull;
@@ -67,8 +68,8 @@ public class Benchmark extends DebugCommand {
67 68
             final long start = System.nanoTime();
68 69
 
69 70
             for (int j = 0; j < 5000; j++) {
70
-                origin.addLine(FORMAT_OUTPUT,
71
-                        "This is a benchmark. Lorem ipsum doler...");
71
+                origin.getEventBus().publishAsync(new CommandOutputEvent(origin,
72
+                        "This is a benchmark. Lorem ipsum doler..."));
72 73
             }
73 74
 
74 75
             final long end = System.nanoTime();
@@ -77,8 +78,8 @@ public class Benchmark extends DebugCommand {
77 78
         }
78 79
 
79 80
         for (int i = 0; i < results.length; i++) {
80
-            origin.addLine(FORMAT_OUTPUT, "Iteration " + i + ": " + results[i]
81
-                    + " nanoseconds.");
81
+            origin.getEventBus().publishAsync(new CommandOutputEvent(origin,
82
+                    "Iteration " + i + ": " + results[i] + " nanoseconds."));
82 83
         }
83 84
     }
84 85
 

+ 6
- 2
debug/src/com/dmdirc/addons/debug/commands/EventBusViewer.java Bestand weergeven

@@ -30,7 +30,9 @@ import com.dmdirc.addons.debug.DebugCommand;
30 30
 import com.dmdirc.commandparser.CommandArguments;
31 31
 import com.dmdirc.commandparser.commands.context.CommandContext;
32 32
 import com.dmdirc.events.ClientLineAddedEvent;
33
+import com.dmdirc.events.CommandOutputEvent;
33 34
 import com.dmdirc.events.DMDircEvent;
35
+import com.dmdirc.events.DisplayableEvent;
34 36
 import com.dmdirc.events.FrameClosingEvent;
35 37
 import com.dmdirc.interfaces.WindowModel;
36 38
 import com.dmdirc.interfaces.config.AggregateConfigProvider;
@@ -128,7 +130,9 @@ public class EventBusViewer extends DebugCommand {
128 130
         @Handler
129 131
         public void handleEvent(final DMDircEvent event) {
130 132
             if (event instanceof ClientLineAddedEvent
131
-                    && ((ClientLineAddedEvent) event).getFrameContainer() == target) {
133
+                    && ((ClientLineAddedEvent) event).getFrameContainer() == target
134
+                    || event instanceof CommandOutputEvent
135
+                    && ((DisplayableEvent) event).getSource() == target) {
132 136
                 // Don't add a line every time we add a line to our output window.
133 137
                 // Things will explode otherwise.
134 138
                 return;
@@ -154,7 +158,7 @@ public class EventBusViewer extends DebugCommand {
154 158
                 }
155 159
             }
156 160
 
157
-            target.addLine(FORMAT_OUTPUT, output.toString());
161
+            target.getEventBus().publishAsync(new CommandOutputEvent(target, output.toString()));
158 162
         }
159 163
 
160 164
     }

+ 4
- 0
tabcompletion_bash/res/META-INF/format.yml Bestand weergeven

@@ -0,0 +1,4 @@
1
+---
2
+BashDisambiguationEvent:
3
+  format: "Multiple possibilities: {{matches}}."
4
+  colour: 14

+ 50
- 0
tabcompletion_bash/src/com/dmdirc/addons/tabcompletion_bash/BashDisambiguationEvent.java Bestand weergeven

@@ -0,0 +1,50 @@
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.addons.tabcompletion_bash;
24
+
25
+import com.dmdirc.events.BaseDisplayableEvent;
26
+import com.dmdirc.interfaces.WindowModel;
27
+
28
+/**
29
+ * Event raised when multiple potential results match a bash-style completion attempt.
30
+ */
31
+public class BashDisambiguationEvent extends BaseDisplayableEvent {
32
+
33
+    private final String matches;
34
+
35
+    public BashDisambiguationEvent(final long timestamp, final WindowModel source,
36
+            final String matches) {
37
+        super(timestamp, source);
38
+        this.matches = matches;
39
+    }
40
+
41
+    public BashDisambiguationEvent(final WindowModel source, final String matches) {
42
+        super(source);
43
+        this.matches = matches;
44
+    }
45
+
46
+    public String getMatches() {
47
+        return matches;
48
+    }
49
+
50
+}

+ 2
- 2
tabcompletion_bash/src/com/dmdirc/addons/tabcompletion_bash/BashStyle.java Bestand weergeven

@@ -88,8 +88,8 @@ public class BashStyle implements TabCompletionStyle {
88 88
 
89 89
             final String sub = getBestSubstring(res);
90 90
             if (sub.equalsIgnoreCase(word) && tabCount >= 2) {
91
-                window.addLine("tabCompletion", res.toString());
92
-
91
+                window.getEventBus().publishAsync(
92
+                        new BashDisambiguationEvent(window, res.toString()));
93 93
                 return null;
94 94
             } else {
95 95
                 return new TabCompletionResult(

Laden…
Annuleren
Opslaan