SerializeAddon: move test util into seperate file

This commit is contained in:
Mmis1000
2021-01-23 12:26:30 +08:00
parent a2480bae51
commit 079702282c
4 changed files with 36 additions and 26 deletions
@@ -0,0 +1,27 @@
/**
* Copyright (c) 2021 The xterm.js authors. All rights reserved.
* @license MIT
*/
import { IBuffer } from 'xterm';
export class SerializeAddonTestUtil {
// this is a util used only for test
public static inspectBuffer(buffer: IBuffer): { x: number, y: number, data: any[][] } {
const lines: any[] = [];
for (let i = 0; i < buffer.length; i++) {
/**
* Do this intentionally to get content of underlining source
*/
const bufferLine = (buffer.getLine(i)! as any)._line;
lines.push(JSON.stringify(bufferLine));
}
return {
x: buffer.cursorX,
y: buffer.cursorY,
data: lines
};
}
}