1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- 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)
- t = " ";
- 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);
- }
- }
- }
|