Skip to content

Commit

Permalink
Controller log fancy print
Browse files Browse the repository at this point in the history
  • Loading branch information
alexkar598 committed Jun 24, 2024
1 parent 8eb0637 commit 19afe96
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/app/panels/controller/controller.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,28 @@ export default class ControllerPanel {
protected emulatorService: EmulatorService,
destroyRef: DestroyRef,
) {
emulatorService.receivedInput
.pipe(
takeUntilDestroyed(destroyRef),
filter(([port]) => port === Port.Controller),
)
.subscribe(([, value]) =>
this.terminal.write(
value.replaceAll(/\x00/g, '\n---\n< ').replaceAll('\n', '\r\n'),
),
);
emulatorService.receivedOutput
.pipe(
takeUntilDestroyed(destroyRef),
filter(([port]) => port === Port.Controller),
) //TODO: need feature parity with the old version for controller pretty print
)
.subscribe(([, value]) =>
this.terminal.write(value.replace(/[\u0000\n]/, '\r\n')),
this.terminal.write(
value
.replaceAll('\n', '\n< ')
.replaceAll('\x00', '\n---\n> ')
.replaceAll('\n', '\r\n'),
),
);
}
}
3 changes: 3 additions & 0 deletions src/vm/emulator.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ export class EmulatorService {
public readonly resetOutputConsole = new EventEmitter<void>();
@Output()
public readonly receivedOutput = new EventEmitter<[Port, string]>();
@Output()
public readonly receivedInput = new EventEmitter<[Port, string]>();

private readonly worker;

Expand Down Expand Up @@ -90,6 +92,7 @@ export class EmulatorService {
}

public sendPort(...data: MsgSendPort['data']) {
this.receivedInput.emit(data);
this.sendCommand({ command: 'sendPort', data });
}
public resizePort(...data: MsgResizePort['data']) {
Expand Down

0 comments on commit 19afe96

Please sign in to comment.