| 49 | |
| 50 | |
| 51 | export class ImageAddon implements ITerminalAddon , IImageApi { |
| 52 | private _opts: IImageAddonOptions; |
| 53 | private _defaultOpts: IImageAddonOptions; |
| 54 | private _storage: ImageStorage | undefined; |
| 55 | private _renderer: ImageRenderer | undefined; |
| 56 | private _disposables: IDisposable[] = []; |
| 57 | private _terminal: ITerminalExt | undefined; |
| 58 | private _handlers: Map<String, IResetHandler> = new Map(); |
| 59 | |
| 60 | constructor(opts?: Partial<IImageAddonOptions>) { |
| 61 | this._opts = Object.assign({}, DEFAULT_OPTIONS, opts); |
| 62 | this._defaultOpts = Object.assign({}, DEFAULT_OPTIONS, opts); |
| 63 | } |
| 64 | |
| 65 | public dispose(): void { |
| 66 | for (const obj of this._disposables) { |
| 67 | obj.dispose(); |
| 68 | } |
| 69 | this._disposables.length = 0; |
| 70 | this._handlers.clear(); |
| 71 | } |
| 72 | |
| 73 | private _disposeLater(...args: IDisposable[]): void { |
| 74 | for (const obj of args) { |
| 75 | this._disposables.push(obj); |
| 76 | } |
| 77 | } |
| 78 | |
| 79 | public activate(terminal: ITerminalExt): void { |
| 80 | this._terminal = terminal; |
| 81 | |
| 82 | // internal data structures |
| 83 | this._renderer = new ImageRenderer(terminal); |
| 84 | this._storage = new ImageStorage(terminal, this._renderer, this._opts); |
| 85 | |
| 86 | // enable size reports |
| 87 | if (this._opts.enableSizeReports) { |
| 88 | // const windowOptions = terminal.getOption('windowOptions'); |
| 89 | // windowOptions.getWinSizePixels = true; |
| 90 | // windowOptions.getCellSizePixels = true; |
| 91 | // windowOptions.getWinSizeChars = true; |
| 92 | // terminal.setOption('windowOptions', windowOptions); |
| 93 | const windowOps = terminal.options.windowOptions || {}; |
| 94 | windowOps.getWinSizePixels = true; |
| 95 | windowOps.getCellSizePixels = true; |
| 96 | windowOps.getWinSizeChars = true; |
| 97 | terminal.options.windowOptions = windowOps; |
| 98 | } |
| 99 | |
| 100 | this._disposeLater( |
| 101 | this._renderer, |
| 102 | this._storage, |
| 103 | |
| 104 | // DECSET/DECRST/DA1/XTSMGRAPHICS handlers |
| 105 | terminal.parser.registerCsiHandler({ prefix: '?', final: 'h' }, params => this._decset(params)), |
| 106 | terminal.parser.registerCsiHandler({ prefix: '?', final: 'l' }, params => this._decrst(params)), |
| 107 | terminal.parser.registerCsiHandler({ final: 'c' }, params => this._da1(params)), |
| 108 | terminal.parser.registerCsiHandler({ prefix: '?', final: 'S' }, params => this._xtermGraphicsAttributes(params)), |
nothing calls this directly
no outgoing calls
no test coverage detected