From 0684e0587757020ffbc8ac0058c52d00ac749456 Mon Sep 17 00:00:00 2001 From: Exile Date: Mon, 16 Oct 2017 07:17:51 +0000 Subject: [PATCH 1/2] Smart Keyboard Arrows --- src/Terminal.ts | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/Terminal.ts b/src/Terminal.ts index 5ea01092..f6b9f637 100644 --- a/src/Terminal.ts +++ b/src/Terminal.ts @@ -1415,6 +1415,36 @@ export class Terminal extends EventEmitter implements ITerminal, IInputHandlingT }; const modifiers = (ev.shiftKey ? 1 : 0) | (ev.altKey ? 2 : 0) | (ev.ctrlKey ? 4 : 0) | (ev.metaKey ? 8 : 0); switch (ev.keyCode) { + case 0: + if (ev.key === "UIKeyInputUpArrow") { + if (this.applicationCursor) { + result.key = C0.ESC + 'OA'; + } else { + result.key = C0.ESC + '[A'; + } + } + else if (ev.key === "UIKeyInputLeftArrow") { + if (this.applicationCursor) { + result.key = C0.ESC + 'OD'; + } else { + result.key = C0.ESC + '[D'; + } + } + else if (ev.key === "UIKeyInputRightArrow") { + if (this.applicationCursor) { + result.key = C0.ESC + 'OC'; + } else { + result.key = C0.ESC + '[C'; + } + } + else if (ev.key === "UIKeyInputDownArrow") { + if (this.applicationCursor) { + result.key = C0.ESC + 'OB'; + } else { + result.key = C0.ESC + '[B'; + } + } + break; case 8: // backspace if (ev.shiftKey) { From 822b31f7b763a873c94f36d544b85893674b8844 Mon Sep 17 00:00:00 2001 From: Exile Date: Mon, 16 Oct 2017 08:02:03 +0000 Subject: [PATCH 2/2] Addressing linter errors --- src/Terminal.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Terminal.ts b/src/Terminal.ts index f6b9f637..6c68f23a 100644 --- a/src/Terminal.ts +++ b/src/Terminal.ts @@ -1416,28 +1416,28 @@ export class Terminal extends EventEmitter implements ITerminal, IInputHandlingT const modifiers = (ev.shiftKey ? 1 : 0) | (ev.altKey ? 2 : 0) | (ev.ctrlKey ? 4 : 0) | (ev.metaKey ? 8 : 0); switch (ev.keyCode) { case 0: - if (ev.key === "UIKeyInputUpArrow") { + if (ev.key === 'UIKeyInputUpArrow') { if (this.applicationCursor) { result.key = C0.ESC + 'OA'; } else { result.key = C0.ESC + '[A'; } } - else if (ev.key === "UIKeyInputLeftArrow") { + else if (ev.key === 'UIKeyInputLeftArrow') { if (this.applicationCursor) { result.key = C0.ESC + 'OD'; } else { result.key = C0.ESC + '[D'; } } - else if (ev.key === "UIKeyInputRightArrow") { + else if (ev.key === 'UIKeyInputRightArrow') { if (this.applicationCursor) { result.key = C0.ESC + 'OC'; } else { result.key = C0.ESC + '[C'; } } - else if (ev.key === "UIKeyInputDownArrow") { + else if (ev.key === 'UIKeyInputDownArrow') { if (this.applicationCursor) { result.key = C0.ESC + 'OB'; } else {