summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYang Cheng <cheng.c.yang@linux.intel.com>2019-02-27 11:16:24 +0800
committerGunnar Mills <gmills@us.ibm.com>2019-03-04 19:09:41 +0000
commit6d1d6005abc6cb48144ad5be9cd8fb094f8ff3c2 (patch)
tree764cf55df5e90830e1025dd9c3123847f2de2066
parent129779dd26a38981b416b812c6761da79831db12 (diff)
downloadphosphor-webui-6d1d6005abc6cb48144ad5be9cd8fb094f8ff3c2.tar.gz
phosphor-webui-6d1d6005abc6cb48144ad5be9cd8fb094f8ff3c2.zip
Add Custom Key for SOL on webui
To support VT100+ extensions for SOL on webui, add custom key into xtermjs to handle key Backspace, DEL, HOME, END, INSERT, PAGE UP, PAGE DOWN, F1 - F12. Tested By: After added item "customKeyEnable": true, "keyType" : "VT100+" into iconfig.json. Under EFI SHELL: Backspace, DEL, HOME, END, INSERT, PAGE UP, PAGE DOWN, F1 - F12 keys can work as local keyboard in Web SOL. Under linux with $TERM=vt100+: Backspace, DEL, HOME, END, INSERT, PAGE UP, PAGE DOWN, F1 - F12 keys can work as local keyboard in Web SOL. If not add "customKeyEnable" or "keyType", into config.json, Backspace, DEL, HOME, END, INSERT, PAGE UP, PAGE DOWN, F1 - F12 keys can work correctly in linux OS with $TERM=vt220 in SOL. Other keys such as a-z can always work in SOL no matter "customKeyEnable" or "keyType" is inserted into config.json. Change-Id: Ifb196ec37080781033c0d6a3b0688baa7d0080b5 Signed-off-by: Cheng C Yang <cheng.c.yang@linux.intel.com>
-rw-r--r--app/common/directives/serial-console.js13
-rw-r--r--app/common/directives/vt100plus.js126
2 files changed, 139 insertions, 0 deletions
diff --git a/app/common/directives/serial-console.js b/app/common/directives/serial-console.js
index 71340df..8227e18 100644
--- a/app/common/directives/serial-console.js
+++ b/app/common/directives/serial-console.js
@@ -2,7 +2,17 @@ import {Terminal} from 'xterm';
import style from 'xterm/dist/xterm.css';
import * as attach from 'xterm/lib/addons/attach/attach';
import * as fit from 'xterm/lib/addons/fit/fit';
+var configJSON = require('../../../config.json');
+if (configJSON.keyType == 'VT100+') {
+ var vt100PlusKey = require('./vt100plus');
+}
+var customKeyHandlers = function(ev) {
+ if (configJSON.keyType == 'VT100+') {
+ return vt100PlusKey.customVT100PlusKey(ev, this);
+ }
+ return true;
+};
window.angular && (function(angular) {
'use strict';
@@ -27,6 +37,9 @@ window.angular && (function(angular) {
var term = new Terminal();
term.open(document.getElementById('terminal'));
term.fit();
+ if (configJSON.customKeyEnable == true) {
+ term.attachCustomKeyEventHandler(customKeyHandlers);
+ }
var SOL_THEME = {
background: '#19273c',
cursor: 'rgba(83, 146, 255, .5)',
diff --git a/app/common/directives/vt100plus.js b/app/common/directives/vt100plus.js
new file mode 100644
index 0000000..5433b2a
--- /dev/null
+++ b/app/common/directives/vt100plus.js
@@ -0,0 +1,126 @@
+'use strict';
+
+var EscapeSequences = require('xterm/lib/common/data/EscapeSequences');
+
+var BACKSPACE = 8;
+var PAGE_UP = 33;
+var PAGE_DOWN = 34;
+var END = 35;
+var HOME = 36;
+var INSERT = 45;
+var DEL = 46;
+var F1 = 112;
+var F2 = 113;
+var F3 = 114;
+var F4 = 115;
+var F5 = 116;
+var F6 = 117;
+var F7 = 118;
+var F8 = 119;
+var F9 = 120;
+var F10 = 121;
+var F11 = 122;
+var F12 = 123;
+
+/*
+VT100+ Character and Key Extensions
+
+Character or key | Character sequence
+---------------------------------------
+HOME key | <ESC>h
+END key | <ESC>k
+INSERT key | <ESC>+
+DELETE key | <ESC>-
+PAGE UP key | <ESC>?
+PAGE DOWN key | <ESC>/
+F1 key | <ESC>1
+F2 key | <ESC>2
+F3 key | <ESC>3
+F4 key | <ESC>4
+F5 key | <ESC>5
+F6 key | <ESC>6
+F7 key | <ESC>7
+F8 key | <ESC>8
+F9 key | <ESC>9
+F10 key | <ESC>0
+F11 key | <ESC>!
+F12 key | <ESC>@
+
+*/
+
+function customVT100PlusKey(ev, term) {
+ var modifiers = (ev.shiftKey ? 1 : 0) | (ev.altKey ? 2 : 0) |
+ (ev.ctrlKey ? 4 : 0) | (ev.metaKey ? 8 : 0);
+ if (((modifiers) && (ev.keyCode != BACKSPACE)) || (ev.type != 'keydown')) {
+ return true;
+ }
+ switch (ev.keyCode) {
+ case BACKSPACE:
+ if (ev.altKey) {
+ return true;
+ } else if (!ev.shiftKey) {
+ term.handler(EscapeSequences.C0.BS); // Backspace
+ } else {
+ term.handler(EscapeSequences.C0.DEL); // Delete
+ }
+ break;
+ case PAGE_UP:
+ term.handler(EscapeSequences.C0.ESC + '?');
+ break;
+ case PAGE_DOWN:
+ term.handler(EscapeSequences.C0.ESC + '/');
+ break;
+ case END:
+ term.handler(EscapeSequences.C0.ESC + 'k');
+ break;
+ case HOME:
+ term.handler(EscapeSequences.C0.ESC + 'h');
+ break;
+ case INSERT:
+ term.handler(EscapeSequences.C0.ESC + '+');
+ break;
+ case DEL:
+ term.handler(EscapeSequences.C0.ESC + '-');
+ break;
+ case F1:
+ term.handler(EscapeSequences.C0.ESC + '1');
+ break;
+ case F2:
+ term.handler(EscapeSequences.C0.ESC + '2');
+ break;
+ case F3:
+ term.handler(EscapeSequences.C0.ESC + '3');
+ break;
+ case F4:
+ term.handler(EscapeSequences.C0.ESC + '4');
+ break;
+ case F5:
+ term.handler(EscapeSequences.C0.ESC + '5');
+ break;
+ case F6:
+ term.handler(EscapeSequences.C0.ESC + '6');
+ break;
+ case F7:
+ term.handler(EscapeSequences.C0.ESC + '7');
+ break;
+ case F8:
+ term.handler(EscapeSequences.C0.ESC + '8');
+ break;
+ case F9:
+ term.handler(EscapeSequences.C0.ESC + '9');
+ break;
+ case F10:
+ term.handler(EscapeSequences.C0.ESC + '0');
+ break;
+ case F11:
+ term.handler(EscapeSequences.C0.ESC + '!');
+ break;
+ case F12:
+ term.handler(EscapeSequences.C0.ESC + '@');
+ break;
+ default:
+ return true;
+ }
+ return false;
+}
+exports.customVT100PlusKey = customVT100PlusKey;
OpenPOWER on IntegriCloud