- Notifications
You must be signed in to change notification settings - Fork 440
/
Copy pathresponse-service-impl.ts
45 lines (38 loc) · 1.42 KB
/
response-service-impl.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import{inject,injectable}from'@theia/core/shared/inversify';
import{Emitter}from'@theia/core/lib/common/event';
import{
OutputChannelManager,
OutputChannelSeverity,
}from'@theia/output/lib/browser/output-channel';
import{
OutputMessage,
ProgressMessage,
ResponseServiceClient,
}from'../common/protocol/response-service';
@injectable()
exportclassResponseServiceImplimplementsResponseServiceClient{
@inject(OutputChannelManager)
privatereadonlyoutputChannelManager: OutputChannelManager;
privatereadonlyprogressDidChangeEmitter=newEmitter<ProgressMessage>();
readonlyonProgressDidChange=this.progressDidChangeEmitter.event;
clearOutput(): void{
this.outputChannelManager.getChannel('Arduino').clear();
}
appendToOutput(message: OutputMessage): void{
const{ chunk, severity }=message;
constchannel=this.outputChannelManager.getChannel('Arduino');
channel.show({preserveFocus: true});
channel.append(chunk,mapSeverity(severity));
}
reportProgress(progress: ProgressMessage): void{
this.progressDidChangeEmitter.fire(progress);
}
}
functionmapSeverity(severity?: OutputMessage.Severity): OutputChannelSeverity{
if(severity===OutputMessage.Severity.Error){
returnOutputChannelSeverity.Error;
}elseif(severity===OutputMessage.Severity.Warning){
returnOutputChannelSeverity.Warning;
}
returnOutputChannelSeverity.Info;
}