From 74a6dfb19779ecc13b52483e15634b0e5f49b416 Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Mon, 29 Jan 2018 11:28:48 -0800 Subject: [PATCH] Send arrow events on mouse wheel in alt buffer Fixes #426 --- src/Terminal.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/Terminal.ts b/src/Terminal.ts index 6e501d03b..e1452f442 100644 --- a/src/Terminal.ts +++ b/src/Terminal.ts @@ -991,7 +991,20 @@ export class Terminal extends EventEmitter implements ITerminal, IInputHandlingT // } on(el, 'wheel', (ev: WheelEvent) => { - if (!this.mouseEvents) return; + if (!this.mouseEvents) { + // Convert wheel events into up/down events when the buffer does not have scrollback, this + // enables scrolling in apps hosted in the alt buffer such as vim or tmux. + if (!this.buffer.hasScrollback) { + let sequence = C0.ESC + (this.applicationCursor ? 'O' : '['); + if (ev.wheelDeltaY > 0) { + sequence += 'A'; + } else { + sequence += 'B'; + } + this.send(sequence); + } + return; + } if (this.x10Mouse || this.vt300Mouse || this.decLocator) return; sendButton(ev); ev.preventDefault();