From 5d431fa9cf2cf5e0ce7cdb288fc62710e58a68fe Mon Sep 17 00:00:00 2001 From: Eugene Pankov Date: Wed, 25 Mar 2020 22:59:44 +0100 Subject: [PATCH] disable progress detection when alt buffer is active --- terminus-terminal/src/api/baseTerminalTab.component.ts | 10 ++++++++-- terminus-terminal/src/frontends/xtermFrontend.ts | 5 +++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/terminus-terminal/src/api/baseTerminalTab.component.ts b/terminus-terminal/src/api/baseTerminalTab.component.ts index a646a2b0..83057029 100644 --- a/terminus-terminal/src/api/baseTerminalTab.component.ts +++ b/terminus-terminal/src/api/baseTerminalTab.component.ts @@ -68,6 +68,8 @@ export class BaseTerminalTabComponent extends BaseTabComponent implements OnInit */ enableDynamicTitle = true + alternateScreenActive = false + // Deps start config: ConfigService element: ElementRef @@ -210,6 +212,10 @@ export class BaseTerminalTabComponent extends BaseTabComponent implements OnInit this.session.releaseInitialDataBuffer() }) + this.alternateScreenActive$.subscribe(x => { + this.alternateScreenActive = x + }) + if (this.savedState) { this.frontend.restoreState(this.savedState) this.frontend.write('\r\n\r\n') @@ -279,7 +285,7 @@ export class BaseTerminalTabComponent extends BaseTabComponent implements OnInit */ write (data: string): void { const percentageMatch = /(^|[^\d])(\d+(\.\d+)?)%([^\d]|$)/.exec(data) - if (percentageMatch) { + if (!this.alternateScreenActive && percentageMatch) { const percentage = percentageMatch[3] ? parseFloat(percentageMatch[2]) : parseInt(percentageMatch[2]) if (percentage > 0 && percentage <= 100) { this.setProgress(percentage) @@ -302,7 +308,7 @@ export class BaseTerminalTabComponent extends BaseTabComponent implements OnInit data = data.replace(/\n/g, '\r') } - if (data.includes('\r')) { + if (!this.alternateScreenActive && data.includes('\r')) { const canTrim = !data.trim().includes('\r') const buttons = canTrim ? ['Paste', 'Trim whitespace and paste', 'Cancel'] : ['Paste', 'Cancel'] const result = (await this.electron.showMessageBox( diff --git a/terminus-terminal/src/frontends/xtermFrontend.ts b/terminus-terminal/src/frontends/xtermFrontend.ts index 879e21c2..6ae39e5a 100644 --- a/terminus-terminal/src/frontends/xtermFrontend.ts +++ b/terminus-terminal/src/frontends/xtermFrontend.ts @@ -121,6 +121,11 @@ export class XTermFrontend extends Frontend { this.xtermCore.updateCursorStyle(e) keyboardEventHandler('keyup', e) } + + this.xtermCore._bufferService.buffers.onBufferActivate(e => { + const altBufferActive = e.activeBuffer === this.xtermCore._bufferService.buffers.alt + this.alternateScreenActive.next(altBufferActive) + }) } attach (host: HTMLElement): void {