From a7d62b0234b904ef683c2ef34895d15db2acb595 Mon Sep 17 00:00:00 2001 From: Eugene Pankov Date: Mon, 18 Mar 2019 22:00:43 +0100 Subject: [PATCH] fixed home/end keys with conpty (fixes #587) --- .../components/baseTerminalTab.component.ts | 6 ----- .../src/components/terminalTab.component.ts | 24 +++++++++++++++++++ 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/terminus-terminal/src/components/baseTerminalTab.component.ts b/terminus-terminal/src/components/baseTerminalTab.component.ts index 784e7c0e..19b9b145 100644 --- a/terminus-terminal/src/components/baseTerminalTab.component.ts +++ b/terminus-terminal/src/components/baseTerminalTab.component.ts @@ -110,12 +110,6 @@ export class BaseTerminalTabComponent extends BaseTabComponent implements OnInit case 'reset-zoom': this.resetZoom() break - case 'home': - this.sendInput('\x1bOH') - break - case 'end': - this.sendInput('\x1bOF') - break case 'previous-word': this.sendInput('\x1bb') break diff --git a/terminus-terminal/src/components/terminalTab.component.ts b/terminus-terminal/src/components/terminalTab.component.ts index a99f852e..4f516be7 100644 --- a/terminus-terminal/src/components/terminalTab.component.ts +++ b/terminus-terminal/src/components/terminalTab.component.ts @@ -1,9 +1,11 @@ import { Component, Input } from '@angular/core' +import { Subscription } from 'rxjs' import { first } from 'rxjs/operators' import { BaseTabProcess } from 'terminus-core' import { BaseTerminalTabComponent } from './baseTerminalTab.component' import { SessionOptions } from '../api' import { Session } from '../services/sessions.service' +import { WIN_BUILD_CONPTY_SUPPORTED, isWindowsBuild } from '../utils' /** @hidden */ @Component({ @@ -13,11 +15,28 @@ import { Session } from '../services/sessions.service' }) export class TerminalTabComponent extends BaseTerminalTabComponent { @Input() sessionOptions: SessionOptions + private homeEndSubscription: Subscription ngOnInit () { this.logger = this.log.create('terminalTab') this.session = new Session(this.config) + let isConPTY = isWindowsBuild(WIN_BUILD_CONPTY_SUPPORTED) && this.config.store.terminal.useConPTY + + this.homeEndSubscription = this.hotkeys.matchedHotkey.subscribe(hotkey => { + if (!this.hasFocus) { + return + } + switch (hotkey) { + case 'home': + this.sendInput(isConPTY ? '\x1b[H' : '\x1bOH') + break + case 'end': + this.sendInput(isConPTY ? '\x1b[F' : '\x1bOF') + break + } + }) + this.frontendReady$.pipe(first()).subscribe(() => { this.initializeSession(this.size.columns, this.size.rows) }) @@ -73,4 +92,9 @@ export class TerminalTabComponent extends BaseTerminalTabComponent { } )).response === 1 } + + ngOnDestroy () { + this.homeEndSubscription.unsubscribe() + super.ngOnDestroy() + } }