- EscapeSequenceParser: ESC ST is ESC backslash (0x1B 0x5C), not ESC plus a double-quote character; align @vt metadata with C1 ST on the following line. - Color.contrastRatio: document l2 as the second luminance argument. - Marker.dispose: fix "change" -> "chance" in dispose listener comment. - Buffer.clear: fix possessive "it's" -> "its" in JSDoc. Co-authored-by: Cursor <cursoragent@cursor.com>
44 lines
1.1 KiB
TypeScript
44 lines
1.1 KiB
TypeScript
/**
|
|
* Copyright (c) 2018 The xterm.js authors. All rights reserved.
|
|
* @license MIT
|
|
*/
|
|
|
|
import { dispose, IDisposable } from '../Lifecycle';
|
|
import { IMarker } from './Types';
|
|
import { Emitter } from '../Event';
|
|
|
|
export class Marker implements IMarker {
|
|
private static _nextId = 1;
|
|
|
|
public isDisposed: boolean = false;
|
|
private readonly _disposables: IDisposable[] = [];
|
|
|
|
private readonly _id: number = Marker._nextId++;
|
|
public get id(): number { return this._id; }
|
|
|
|
private readonly _onDispose = this.register(new Emitter<void>());
|
|
public readonly onDispose = this._onDispose.event;
|
|
|
|
constructor(
|
|
public line: number
|
|
) {
|
|
}
|
|
|
|
public dispose(): void {
|
|
if (this.isDisposed) {
|
|
return;
|
|
}
|
|
this.isDisposed = true;
|
|
this.line = -1;
|
|
// Emit before super.dispose such that dispose listeners get a chance to react
|
|
this._onDispose.fire();
|
|
dispose(this._disposables);
|
|
this._disposables.length = 0;
|
|
}
|
|
|
|
public register<T extends IDisposable>(disposable: T): T {
|
|
this._disposables.push(disposable);
|
|
return disposable;
|
|
}
|
|
}
|