mirror of
https://github.com/wavetermdev/xterm.js.git
synced 2026-08-05 13:43:48 -07:00
expose IBufferSet API
This commit is contained in:
+22
-2
@@ -3,10 +3,10 @@
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
import { Terminal as ITerminalApi, ITerminalOptions, IMarker, IDisposable, ILinkMatcherOptions, ITheme, ILocalizableStrings, ITerminalAddon, ISelectionPosition, IBuffer as IBufferApi, IBufferLine as IBufferLineApi, IBufferCell as IBufferCellApi, IParser, IFunctionIdentifier, ILinkProvider, IUnicodeHandling, IUnicodeVersionProvider } from 'xterm';
|
||||
import { Terminal as ITerminalApi, ITerminalOptions, IMarker, IDisposable, ILinkMatcherOptions, ITheme, ILocalizableStrings, ITerminalAddon, ISelectionPosition, IBuffer as IBufferApi, IBufferSet as IBufferSetApi, IBufferLine as IBufferLineApi, IBufferCell as IBufferCellApi, IParser, IFunctionIdentifier, ILinkProvider, IUnicodeHandling, IUnicodeVersionProvider } from 'xterm';
|
||||
import { ITerminal } from '../Types';
|
||||
import { IBufferLine, ICellData } from 'common/Types';
|
||||
import { IBuffer } from 'common/buffer/Types';
|
||||
import { IBuffer, IBufferSet } from 'common/buffer/Types';
|
||||
import { CellData } from 'common/buffer/CellData';
|
||||
import { Terminal as TerminalCore } from '../Terminal';
|
||||
import * as Strings from '../browser/LocalizableStrings';
|
||||
@@ -49,6 +49,7 @@ export class Terminal implements ITerminalApi {
|
||||
public get rows(): number { return this._core.rows; }
|
||||
public get cols(): number { return this._core.cols; }
|
||||
public get buffer(): IBufferApi { return new BufferApiView(this._core.buffer); }
|
||||
public get buffers(): IBufferSetApi { return new BufferSetApiView(this._core.buffers); }
|
||||
public get markers(): ReadonlyArray<IMarker> { return this._core.markers; }
|
||||
public blur(): void {
|
||||
this._core.blur();
|
||||
@@ -210,6 +211,25 @@ class BufferApiView implements IBufferApi {
|
||||
public getNullCell(): IBufferCellApi { return new CellData(); }
|
||||
}
|
||||
|
||||
class BufferSetApiView implements IBufferSetApi {
|
||||
constructor(private _buffers: IBufferSet) { }
|
||||
|
||||
public get alt(): IBufferApi { return new BufferApiView(this._buffers.alt); }
|
||||
public get active(): IBufferApi { return new BufferApiView(this._buffers.active); }
|
||||
public get normal(): IBufferApi { return new BufferApiView(this._buffers.normal); }
|
||||
|
||||
public get onBufferActivate(): IEvent<{ activeBuffer: IBufferApi, inactiveBuffer: IBufferApi }> {
|
||||
return (listener: (arg1: { activeBuffer: IBufferApi, inactiveBuffer: IBufferApi }, arg2: void) => any) => {
|
||||
return this._buffers.onBufferActivate((innerArg: { activeBuffer: IBuffer, inactiveBuffer: IBuffer }) => {
|
||||
listener({
|
||||
activeBuffer: new BufferApiView(innerArg.activeBuffer),
|
||||
inactiveBuffer: new BufferApiView(innerArg.inactiveBuffer)
|
||||
});
|
||||
});
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
class BufferLineApiView implements IBufferLineApi {
|
||||
constructor(private _line: IBufferLine) { }
|
||||
|
||||
|
||||
Vendored
+13
@@ -576,6 +576,11 @@ declare module 'xterm' {
|
||||
*/
|
||||
readonly buffer: IBuffer;
|
||||
|
||||
/**
|
||||
* (EXPERIMENTAL) The terminal's current bufferSet.
|
||||
*/
|
||||
readonly buffers: IBufferSet;
|
||||
|
||||
/**
|
||||
* (EXPERIMENTAL) Get all markers registered against the buffer. If the alt
|
||||
* buffer is active this will always return [].
|
||||
@@ -1217,6 +1222,14 @@ declare module 'xterm' {
|
||||
getNullCell(): IBufferCell;
|
||||
}
|
||||
|
||||
interface IBufferSet {
|
||||
readonly alt: IBuffer;
|
||||
readonly normal: IBuffer;
|
||||
readonly active: IBuffer;
|
||||
|
||||
onBufferActivate: IEvent<{ activeBuffer: IBuffer, inactiveBuffer: IBuffer }>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a line in the terminal's buffer.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user