| 1 |
/** |
| 2 |
* Copyright (c) 2021 The xterm.js authors. All rights reserved. |
| 3 |
* @license MIT |
| 4 |
*/ |
| 5 |
|
| 6 |
import { IBuffer as IBufferApi, IBufferLine as IBufferLineApi, IBufferCell as IBufferCellApi } from '@xterm/xterm'; |
| 7 |
import { IBuffer } from 'common/buffer/Types'; |
| 8 |
import { BufferLineApiView } from 'common/public/BufferLineApiView'; |
| 9 |
import { CellData } from 'common/buffer/CellData'; |
| 10 |
|
| 11 |
export class BufferApiView implements IBufferApi { |
| 12 |
constructor( |
| 13 |
private _buffer: IBuffer, |
| 14 |
public readonly type: 'normal' | 'alternate' |
| 15 |
) { } |
| 16 |
|
| 17 |
public init(buffer: IBuffer): BufferApiView { |
| 18 |
this._buffer = buffer; |
| 19 |
return this; |
| 20 |
} |
| 21 |
|
| 22 |
public get cursorY(): number { return this._buffer.y; } |
| 23 |
public get cursorX(): number { return this._buffer.x; } |
| 24 |
public get viewportY(): number { return this._buffer.ydisp; } |
| 25 |
public get baseY(): number { return this._buffer.ybase; } |
| 26 |
public get length(): number { return this._buffer.lines.length; } |
| 27 |
public getLine(y: number): IBufferLineApi | undefined { |
| 28 |
const line = this._buffer.lines.get(y); |
| 29 |
if (!line) { |
| 30 |
return undefined; |
| 31 |
} |
| 32 |
return new BufferLineApiView(line); |
| 33 |
} |
| 34 |
public getNullCell(): IBufferCellApi { return new CellData(); } |
| 35 |
} |