mirror of
https://github.com/wavetermdev/xterm.js.git
synced 2026-08-05 13:43:48 -07:00
Don't pass buffers to BufferApiView
This commit is contained in:
+13
-13
@@ -193,19 +193,16 @@ export class Terminal implements ITerminalApi {
|
||||
}
|
||||
|
||||
class BufferApiView implements IBufferApi {
|
||||
constructor(private _buffer: IBuffer, private _buffers: IBufferSet) { }
|
||||
constructor(
|
||||
private _buffer: IBuffer,
|
||||
public readonly type: 'normal' | 'alternate'
|
||||
) { }
|
||||
|
||||
init(buffer: IBuffer, buffers: IBufferSet): BufferApiView {
|
||||
public init(buffer: IBuffer): BufferApiView {
|
||||
this._buffer = buffer;
|
||||
this._buffers = buffers;
|
||||
return this;
|
||||
}
|
||||
|
||||
public get type(): 'normal' | 'alternate' {
|
||||
if (this._buffers.normal === this._buffer) { return 'normal'; }
|
||||
if (this._buffers.alt === this._buffer) { return 'alternate'; }
|
||||
throw new Error('Unknown buffer type');
|
||||
}
|
||||
public get cursorY(): number { return this._buffer.y; }
|
||||
public get cursorX(): number { return this._buffer.x; }
|
||||
public get viewportY(): number { return this._buffer.ydisp; }
|
||||
@@ -228,18 +225,21 @@ class BufferNamespaceApi implements IBufferNamespaceApi {
|
||||
public get onBufferChange(): IEvent<IBufferApi> { return this._onBufferChange.event; }
|
||||
|
||||
constructor(private _buffers: IBufferSet) {
|
||||
this._normal = new BufferApiView(this._buffers.normal, this._buffers);
|
||||
this._alternate = new BufferApiView(this._buffers.alt, this._buffers);
|
||||
this._normal = new BufferApiView(this._buffers.normal, 'normal');
|
||||
this._alternate = new BufferApiView(this._buffers.alt, 'alternate');
|
||||
this._buffers.onBufferActivate(() => this._onBufferChange.fire(this.active));
|
||||
}
|
||||
|
||||
public get active(): IBufferApi {
|
||||
if (this._buffers.active === this._buffers.normal) { return this.normal; }
|
||||
if (this._buffers.active === this._buffers.alt) { return this.alternate; }
|
||||
throw new Error('Active buffer is neither normal nor alternate');
|
||||
}
|
||||
public get normal(): IBufferApi { return this._normal.init(this._buffers.normal, this._buffers); }
|
||||
public get alternate(): IBufferApi { return this._alternate.init(this._buffers.alt, this._buffers); }
|
||||
public get normal(): IBufferApi {
|
||||
return this._normal.init(this._buffers.normal);
|
||||
}
|
||||
public get alternate(): IBufferApi {
|
||||
return this._alternate.init(this._buffers.alt);
|
||||
}
|
||||
}
|
||||
|
||||
class BufferLineApiView implements IBufferLineApi {
|
||||
|
||||
Reference in New Issue
Block a user