Files
NapCatQQ/.pnpm-store/v3/files/80/ee8ab1d2302f68a628bf8dfaa9277e7fbcfbfc83229aca1a62b6072fe1138d7958ee994faf51c3c9f605f49527a602b4b4afe00fd1acd3f05efd6ba3e732e0
TanTan e311ca3275
Build NapCat Artifacts / Windows Loader Test (push) Canceled after 0s
Build NapCat Artifacts / Type Check & Test (push) Canceled after 0s
Build NapCat Artifacts / Build NapCat.Framework (push) Canceled after 0s
Build NapCat Artifacts / Build NapCat.Shell (push) Canceled after 0s
docs: 仓库链接指向本镜像仓库
2026-11-13 09:25:58 +08:00

37 lines
1.5 KiB
Plaintext

/**
* Copyright (c) 2021 The xterm.js authors. All rights reserved.
* @license MIT
*/
import { IBuffer as IBufferApi, IBufferNamespace as IBufferNamespaceApi } from '@xterm/xterm';
import { BufferApiView } from 'common/public/BufferApiView';
import { EventEmitter } from 'common/EventEmitter';
import { ICoreTerminal } from 'common/Types';
import { Disposable } from 'common/Lifecycle';
export class BufferNamespaceApi extends Disposable implements IBufferNamespaceApi {
private _normal: BufferApiView;
private _alternate: BufferApiView;
private readonly _onBufferChange = this.register(new EventEmitter<IBufferApi>());
public readonly onBufferChange = this._onBufferChange.event;
constructor(private _core: ICoreTerminal) {
super();
this._normal = new BufferApiView(this._core.buffers.normal, 'normal');
this._alternate = new BufferApiView(this._core.buffers.alt, 'alternate');
this._core.buffers.onBufferActivate(() => this._onBufferChange.fire(this.active));
}
public get active(): IBufferApi {
if (this._core.buffers.active === this._core.buffers.normal) { return this.normal; }
if (this._core.buffers.active === this._core.buffers.alt) { return this.alternate; }
throw new Error('Active buffer is neither normal nor alternate');
}
public get normal(): IBufferApi {
return this._normal.init(this._core.buffers.normal);
}
public get alternate(): IBufferApi {
return this._alternate.init(this._core.buffers.alt);
}
}