From f32bdbdeacef0b1fbcf53834acd189d9048953bf Mon Sep 17 00:00:00 2001 From: Eugene Pankov Date: Mon, 10 Dec 2018 11:57:13 +0100 Subject: [PATCH] make scroll-on-input behaviour configurable (fixes #543) --- .../src/components/terminalSettingsTab.component.pug | 9 +++++++++ .../src/components/terminalTab.component.ts | 8 +++++--- terminus-terminal/src/config.ts | 1 + terminus-terminal/src/frontends/htermFrontend.ts | 2 ++ 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/terminus-terminal/src/components/terminalSettingsTab.component.pug b/terminus-terminal/src/components/terminalSettingsTab.component.pug index f7bbd4ef..bee79326 100644 --- a/terminus-terminal/src/components/terminalSettingsTab.component.pug +++ b/terminus-terminal/src/components/terminalSettingsTab.component.pug @@ -82,6 +82,15 @@ h3.mb-3 Terminal [(ngModel)]='config.store.terminal.copyOnSelect', (ngModelChange)='config.save()', ) + +.form-line + .header + .title Scroll on input + .description Scrolls the terminal to the bottom on user input + toggle( + [(ngModel)]='config.store.terminal.scrollOnInput', + (ngModelChange)='config.save()', + ) .form-line .header diff --git a/terminus-terminal/src/components/terminalTab.component.ts b/terminus-terminal/src/components/terminalTab.component.ts index 4fa5b074..5dea3b57 100644 --- a/terminus-terminal/src/components/terminalTab.component.ts +++ b/terminus-terminal/src/components/terminalTab.component.ts @@ -264,9 +264,9 @@ export class TerminalTabComponent extends BaseTabComponent { let wheelDeltaY = 0 if ('wheelDeltaY' in event) { - wheelDeltaY = (event as MouseWheelEvent)["wheelDeltaY"] + wheelDeltaY = (event as MouseWheelEvent).wheelDeltaY } else { - wheelDeltaY = (event as MouseWheelEvent)["deltaY"] + wheelDeltaY = (event as MouseWheelEvent).deltaY } if (event.ctrlKey || event.metaKey) { @@ -300,7 +300,9 @@ export class TerminalTabComponent extends BaseTabComponent { sendInput (data: string) { this.session.write(data) - this.frontend.scrollToBottom() + if (this.config.store.terminal.scrollOnInput) { + this.frontend.scrollToBottom() + } } write (data: string) { diff --git a/terminus-terminal/src/config.ts b/terminus-terminal/src/config.ts index 6f3f9669..9adc7d93 100644 --- a/terminus-terminal/src/config.ts +++ b/terminus-terminal/src/config.ts @@ -21,6 +21,7 @@ export class TerminalConfigProvider extends ConfigProvider { customShell: '', rightClick: 'menu', copyOnSelect: false, + scrollOnInput: true, workingDirectory: '', altIsMeta: false, colorScheme: { diff --git a/terminus-terminal/src/frontends/htermFrontend.ts b/terminus-terminal/src/frontends/htermFrontend.ts index 7c1ea6a0..7803379d 100644 --- a/terminus-terminal/src/frontends/htermFrontend.ts +++ b/terminus-terminal/src/frontends/htermFrontend.ts @@ -72,6 +72,8 @@ export class HTermFrontend extends Frontend { preferenceManager.set('pass-alt-number', true) preferenceManager.set('cursor-blink', config.terminal.cursorBlink) preferenceManager.set('clear-selection-after-copy', true) + preferenceManager.set('scroll-on-output', false) + preferenceManager.set('scroll-on-keystroke', config.terminal.scrollOnInput) if (config.terminal.colorScheme.foreground) { preferenceManager.set('foreground-color', config.terminal.colorScheme.foreground)