Skip to content

Commit 19afe96

Browse files
committed
Controller log fancy print
1 parent 8eb0637 commit 19afe96

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

src/app/panels/controller/controller.component.ts

+17-2
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,28 @@ export default class ControllerPanel {
2323
protected emulatorService: EmulatorService,
2424
destroyRef: DestroyRef,
2525
) {
26+
emulatorService.receivedInput
27+
.pipe(
28+
takeUntilDestroyed(destroyRef),
29+
filter(([port]) => port === Port.Controller),
30+
)
31+
.subscribe(([, value]) =>
32+
this.terminal.write(
33+
value.replaceAll(/\x00/g, '\n---\n< ').replaceAll('\n', '\r\n'),
34+
),
35+
);
2636
emulatorService.receivedOutput
2737
.pipe(
2838
takeUntilDestroyed(destroyRef),
2939
filter(([port]) => port === Port.Controller),
30-
) //TODO: need feature parity with the old version for controller pretty print
40+
)
3141
.subscribe(([, value]) =>
32-
this.terminal.write(value.replace(/[\u0000\n]/, '\r\n')),
42+
this.terminal.write(
43+
value
44+
.replaceAll('\n', '\n< ')
45+
.replaceAll('\x00', '\n---\n> ')
46+
.replaceAll('\n', '\r\n'),
47+
),
3348
);
3449
}
3550
}

src/vm/emulator.service.ts

+3
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ export class EmulatorService {
2323
public readonly resetOutputConsole = new EventEmitter<void>();
2424
@Output()
2525
public readonly receivedOutput = new EventEmitter<[Port, string]>();
26+
@Output()
27+
public readonly receivedInput = new EventEmitter<[Port, string]>();
2628

2729
private readonly worker;
2830

@@ -90,6 +92,7 @@ export class EmulatorService {
9092
}
9193

9294
public sendPort(...data: MsgSendPort['data']) {
95+
this.receivedInput.emit(data);
9396
this.sendCommand({ command: 'sendPort', data });
9497
}
9598
public resizePort(...data: MsgResizePort['data']) {

0 commit comments

Comments
 (0)