From 6fa5ab5eb2ccc0d7db551f1155eef4b1c4961a7e Mon Sep 17 00:00:00 2001 From: Eugene Pankov Date: Thu, 20 Sep 2018 12:12:57 +0200 Subject: [PATCH] scroll terminal to bottom on user input --- terminus-terminal/src/components/terminalTab.component.ts | 1 + terminus-terminal/src/frontends/frontend.ts | 1 + terminus-terminal/src/frontends/htermFrontend.ts | 4 ++++ terminus-terminal/src/frontends/xtermFrontend.ts | 4 ++++ 4 files changed, 10 insertions(+) diff --git a/terminus-terminal/src/components/terminalTab.component.ts b/terminus-terminal/src/components/terminalTab.component.ts index eedf4050..be7051e4 100644 --- a/terminus-terminal/src/components/terminalTab.component.ts +++ b/terminus-terminal/src/components/terminalTab.component.ts @@ -292,6 +292,7 @@ export class TerminalTabComponent extends BaseTabComponent { sendInput (data: string) { this.session.write(data) + this.frontend.scrollToBottom() } write (data: string) { diff --git a/terminus-terminal/src/frontends/frontend.ts b/terminus-terminal/src/frontends/frontend.ts index 253a9d3c..4e0550c5 100644 --- a/terminus-terminal/src/frontends/frontend.ts +++ b/terminus-terminal/src/frontends/frontend.ts @@ -52,6 +52,7 @@ export abstract class Frontend { abstract write (data: string): void abstract clear (): void abstract visualBell (): void + abstract scrollToBottom (): void abstract configure (configStore: any): void abstract setZoom (zoom: number): void diff --git a/terminus-terminal/src/frontends/htermFrontend.ts b/terminus-terminal/src/frontends/htermFrontend.ts index 5023cae2..829f807e 100644 --- a/terminus-terminal/src/frontends/htermFrontend.ts +++ b/terminus-terminal/src/frontends/htermFrontend.ts @@ -141,6 +141,10 @@ export class HTermFrontend extends Frontend { }, 125) } + scrollToBottom (): void { + this.term.scrollEnd() + } + private setFontSize () { preferenceManager.set('font-size', this.configuredFontSize * Math.pow(1.1, this.zoom)) } diff --git a/terminus-terminal/src/frontends/xtermFrontend.ts b/terminus-terminal/src/frontends/xtermFrontend.ts index 6f6cf129..f05cfac6 100644 --- a/terminus-terminal/src/frontends/xtermFrontend.ts +++ b/terminus-terminal/src/frontends/xtermFrontend.ts @@ -77,6 +77,10 @@ export class XTermFrontend extends Frontend { (this.xterm as any).bell() } + scrollToBottom (): void { + this.xterm.scrollToBottom() + } + configure (config: any): void { this.xterm.setOption('fontFamily', `"${config.terminal.font}", "monospace-fallback", monospace`) this.xterm.setOption('bellStyle', config.terminal.bell) -- GitLab