From 027094e6c1db56e5cd22f280059a137c772d777a Mon Sep 17 00:00:00 2001 From: ZitRos Date: Mon, 23 Jan 2017 14:53:16 +0200 Subject: [PATCH] Function and arrow keys support (test) --- package.json | 2 +- src/client/js/input/index.js | 9 ++++++++- src/client/js/input/keyMappings.js | 18 ++++++++++++++++++ src/cls/WebTerminal/Handlers.cls | 7 +++++++ 4 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 src/client/js/input/keyMappings.js diff --git a/package.json b/package.json index 9fb5f11..fc1bbb0 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "printableName": "Cache Web Terminal", "description": "Web-based terminal emulator for Caché administering.", "author": "ZitRo", - "version": "4.1.3", + "version": "4.1.4", "gaID": "UA-83005064-2", "releaseNumber": 26, "scripts": { diff --git a/src/client/js/input/index.js b/src/client/js/input/index.js index edbd80a..e8af459 100644 --- a/src/client/js/input/index.js +++ b/src/client/js/input/index.js @@ -10,6 +10,7 @@ import { send } from "../server"; import * as config from "../config"; import handlers from "./handlers"; import hint from "../autocomplete/hint"; +import keyMappings from "./keyMappings"; export let ENABLED = false, PROMPT_CLEARED = false; @@ -150,7 +151,7 @@ export function getKey (options = {}, callback) { caret.hide(); let inp = (e) => { - if (handleKeyPress(e, callback) === false) + if (!e.cancelled && handleKeyPress(e, callback) === false) return; window.removeEventListener(`keydown`, inp); }; @@ -196,6 +197,12 @@ function keyDown (e) { send("Interrupt", {}); e.cancelBubble = true; } + if (keyMappings.hasOwnProperty(e.keyCode)) { + e.cancelled = true; + send("i", keyMappings[e.keyCode]); + e.preventDefault(); + return; + } if (!ENABLED || e.cancelBubble) return; e.cancelBubble = true; diff --git a/src/client/js/input/keyMappings.js b/src/client/js/input/keyMappings.js new file mode 100644 index 0000000..c6ca91c --- /dev/null +++ b/src/client/js/input/keyMappings.js @@ -0,0 +1,18 @@ +export default { + 37: "\x1bD", + 38: "\x1bA", + 39: "\x1bC", + 40: "\x1bB", + 112: "\x1b[OP", + 113: "\x1b[OQ", + 114: "\x1b[OR", + 115: "\x1b[OS", + 116: "\x1b[[15~", + 117: "\x1b[[17~", + 118: "\x1b[[18~", + 119: "\x1b[[19~", + 120: "\x1b[[20~", + 121: "\x1b[[21~", + 122: "\x1b[[23~", + 123: "\x1b[[24~" +} diff --git a/src/cls/WebTerminal/Handlers.cls b/src/cls/WebTerminal/Handlers.cls index 44cf48f..8075718 100644 --- a/src/cls/WebTerminal/Handlers.cls +++ b/src/cls/WebTerminal/Handlers.cls @@ -255,4 +255,11 @@ ClassMethod Interrupt (client As WebTerminal.Engine, data As %ZEN.proxyObject = return $$$OK } +/// Handles input, which does not correspond to any read (like occasional character press). +ClassMethod i (client As WebTerminal.Engine, data As %ZEN.proxyObject = "") As %Status +{ + // do *nothing* + return $$$OK +} + } \ No newline at end of file