| 1 |
/** |
| 2 |
* Copyright (c) 2021 The xterm.js authors. All rights reserved. |
| 3 |
* @license MIT |
| 4 |
*/ |
| 5 |
|
| 6 |
import { CellData } from 'common/buffer/CellData'; |
| 7 |
import { IBufferLine, ICellData } from 'common/Types'; |
| 8 |
import { IBufferCell as IBufferCellApi, IBufferLine as IBufferLineApi } from '@xterm/xterm'; |
| 9 |
|
| 10 |
export class BufferLineApiView implements IBufferLineApi { |
| 11 |
constructor(private _line: IBufferLine) { } |
| 12 |
|
| 13 |
public get isWrapped(): boolean { return this._line.isWrapped; } |
| 14 |
public get length(): number { return this._line.length; } |
| 15 |
public getCell(x: number, cell?: IBufferCellApi): IBufferCellApi | undefined { |
| 16 |
if (x < 0 || x >= this._line.length) { |
| 17 |
return undefined; |
| 18 |
} |
| 19 |
|
| 20 |
if (cell) { |
| 21 |
this._line.loadCell(x, cell as ICellData); |
| 22 |
return cell; |
| 23 |
} |
| 24 |
return this._line.loadCell(x, new CellData()); |
| 25 |
} |
| 26 |
public translateToString(trimRight?: boolean, startColumn?: number, endColumn?: number): string { |
| 27 |
return this._line.translateToString(trimRight, startColumn, endColumn); |
| 28 |
} |
| 29 |
} |