diff --git a/src/browser/Terminal.ts b/src/browser/Terminal.ts index edbeccf2..4afca04c 100644 --- a/src/browser/Terminal.ts +++ b/src/browser/Terminal.ts @@ -164,6 +164,7 @@ export class Terminal extends CoreTerminal implements ITerminal { // Setup InputHandler listeners this.register(this._inputHandler.onRequestBell(() => this.bell())); this.register(this._inputHandler.onRequestRefreshRows((start, end) => this.refresh(start, end))); + this.register(this._inputHandler.onRequestSendFocus(() => this._reportFocus())); this.register(this._inputHandler.onRequestReset(() => this.reset())); this.register(this._inputHandler.onRequestWindowsOptionsReport(type => this._reportWindowsOptions(type))); this.register(this._inputHandler.onAnsiColorChange((event) => this._changeAnsiColor(event))); @@ -1296,6 +1297,14 @@ export class Terminal extends CoreTerminal implements ITerminal { this._renderService?.clearTextureAtlas(); } + private _reportFocus(): void { + if (this.element?.classList.contains('focus')) { + this.coreService.triggerDataEvent(C0.ESC + '[I'); + } else { + this.coreService.triggerDataEvent(C0.ESC + '[O'); + } + } + private _reportWindowsOptions(type: WindowsOptionsReportType): void { if (!this._renderService) { return; diff --git a/src/common/InputHandler.ts b/src/common/InputHandler.ts index f2f0d0ce..9371e5f5 100644 --- a/src/common/InputHandler.ts +++ b/src/common/InputHandler.ts @@ -243,6 +243,8 @@ export class InputHandler extends Disposable implements IInputHandler { public get onRequestRefreshRows(): IEvent { return this._onRequestRefreshRows.event; } private _onRequestReset = new EventEmitter(); public get onRequestReset(): IEvent { return this._onRequestReset.event; } + private _onRequestSendFocus = new EventEmitter(); + public get onRequestSendFocus(): IEvent { return this._onRequestSendFocus.event; } private _onRequestSyncScrollBar = new EventEmitter(); public get onRequestSyncScrollBar(): IEvent { return this._onRequestSyncScrollBar.event; } private _onRequestWindowsOptionsReport = new EventEmitter(); @@ -1956,6 +1958,7 @@ export class InputHandler extends Disposable implements IInputHandler { // focusin: ^[[I // focusout: ^[[O this._coreService.decPrivateModes.sendFocus = true; + this._onRequestSendFocus.fire(); break; case 1005: // utf8 ext mode mouse - removed in #2507 this._logService.debug('DECSET 1005 not supported (see #2507)');