123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- 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) {
- let output = '' + text;
- if (output.indexOf('\n') !== -1) {
- const outputList = output.split('\n');
- let 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);
- }
- }
- }
|