1
>
/*---------------------------------------------------------------------------------------------
terminalRecorder.ts
2
>
* Copyright (c) Microsoft Corporation. All rights reserved.
3
>
* Licensed under the MIT License. See License.txt in the project root for license information.
4
>
*--------------------------------------------------------------------------------------------*/
5
>
6
>
import { IPtyHostProcessReplayEvent } from './capabilities/capabilities.js';
7
>
import { ReplayEntry } from './terminalProcess.js';
8
>
9
>
const enum Constants {
10
>
MaxRecorderDataSize = 10 * 1024 * 1024 // 10MB
11
>
}
12
>
13
>
interface RecorderEntry {
14
>
cols: number;
15
>
rows: number;
16
>
data: string[];
17
>
}
18
>
19
>
export interface IRemoteTerminalProcessReplayEvent {
20
>
events: ReplayEntry[];
21
>
}
22
>
23
>
export class TerminalRecorder {
24
>
25
>
private _entries: RecorderEntry[];
26
>
private _totalDataLength: number = 0;
27
>
28
>
constructor(cols: number, rows: number) {
29
>
this._entries = [{ cols, rows, data: [] }];
30
>
}
31
>
32
>
handleResize(cols: number, rows: number): void {
33
>
if (this._entries.length > 0) {
34
>
const lastEntry = this._entries[this._entries.length - 1];
35
>
if (lastEntry.data.length === 0) {
36
// last entry is just a resize, so just remove it
37
this._entries.pop();
38
}
40
>
41
>
if (this._entries.length > 0) {
42
const lastEntry = this._entries[this._entries.length - 1];
43
if (lastEntry.cols === cols && lastEntry.rows === rows) {