1234567891011121314151617181920212223242526272829303132333435363738394041 |
- import { Output } from "./../io/output";
- export class OutputTest extends Output {
- constructor () {
- super();
- this.list = [];
- this.currentLine = null;
- }
- write (text, newLine = false) {
- if (this.currentLine == null) {
- this.currentLine = this.list.push("") - 1;
- }
- this.list[this.currentLine] += text;
- if (newLine) {
- this.currentLine = null;
- }
- }
- sendOutput (text) {
- const output = "" + text;
- if (output.indexOf("\n") !== -1) {
- const outputList = output.split("\n");
- const last = outputList.pop();
- outputList.forEach((t) => {
- //t = t.replace(/\t/g, '  ');
- //t = t.replace(/\s/g, " ");
- if (t.length == 0) this.currentLine = null;
- else this.write(t, true);
- });
- //last = last.replace(/\t/g, '  ');
- //last = last.replace(/\s/g, " ");
- if (last.length != 0) this.write(last);
- } else {
- //output = output.replace(/\t/g, '  ');
- //output = output.replace(/\s/g, " ");
- this.write(output);
- }
- }
- }
|