From 6585810cc4b32625ae9cf101eb25c1b5f52fe6bc Mon Sep 17 00:00:00 2001 From: NI Date: Wed, 11 Sep 2019 11:31:08 +0800 Subject: [PATCH] Add on screen control for some hot keys. To toggle it, click/tap currently opened tab. --- ui/commands/common.js | 4 +- ui/common.css | 9 + ui/control/ssh.js | 2 +- ui/control/telnet.js | 2 +- ui/home.vue | 5 +- ui/widgets/screen_console.css | 112 ++++++ ui/widgets/screen_console.vue | 109 +++++- ui/widgets/screen_console_keys.js | 613 ++++++++++++++++++++++++++++++ ui/widgets/screens.vue | 6 +- 9 files changed, 843 insertions(+), 19 deletions(-) create mode 100644 ui/widgets/screen_console_keys.js diff --git a/ui/commands/common.js b/ui/commands/common.js index 36e56ca..ca55bff 100644 --- a/ui/commands/common.js +++ b/ui/commands/common.js @@ -99,7 +99,7 @@ const hostnameCharators = { * @returns {boolean} Return true if given string is all number, false otherwise * */ -function isNumber(d) { +export function isNumber(d) { for (let i = 0; i < d.length; i++) { if (!numCharators[d[i]]) { return false; @@ -117,7 +117,7 @@ function isNumber(d) { * @returns {boolean} Return true if given string is all hex, false otherwise * */ -function isHex(d) { +export function isHex(d) { let dd = d.toLowerCase(); for (let i = 0; i < dd.length; i++) { diff --git a/ui/common.css b/ui/common.css index fc14d57..ec0ac2e 100644 --- a/ui/common.css +++ b/ui/common.css @@ -276,6 +276,15 @@ body { content: "\25CF"; } +.icon.icon-keyboardkey1 { + background: #fff; + color: #999; + padding: 4px 6px; + display: inline-block; + border-radius: 3px; + box-shadow: 1px 1px 0 2px #0003; +} + /* Windows */ .window { position: absolute; diff --git a/ui/control/ssh.js b/ui/control/ssh.js index d9e268a..9ff320b 100644 --- a/ui/control/ssh.js +++ b/ui/control/ssh.js @@ -80,7 +80,7 @@ class Control { this.enable = false; } - retap() {} + retap(isOn) {} receive() { return this.subs.subscribe(); diff --git a/ui/control/telnet.js b/ui/control/telnet.js index d961ac4..e108279 100644 --- a/ui/control/telnet.js +++ b/ui/control/telnet.js @@ -399,7 +399,7 @@ class Control { this.enable = false; } - retap() {} + retap(isOn) {} receive() { return this.subs.subscribe(); diff --git a/ui/home.vue b/ui/home.vue index 9636e51..efe5687 100644 --- a/ui/home.vue +++ b/ui/home.vue @@ -448,6 +448,7 @@ export default { name: data.name, info: data.info, control: data.control, + toolbar: false, indicator: { error: "", updated: false @@ -475,7 +476,9 @@ export default { await this.tab.tabs[this.tab.current].control.enabled(); }, async retapTab(tab) { - await this.tab.tabs[tab].control.retap(); + this.tab.tabs[tab].toolbar = !this.tab.tabs[tab].toolbar; + + await this.tab.tabs[tab].control.retap(this.tab.tabs[tab].toolbar); }, async closeTab(index) { if (this.tab.tabs[index].status.closing) { diff --git a/ui/widgets/screen_console.css b/ui/widgets/screen_console.css index 89ca9f7..d73124b 100644 --- a/ui/widgets/screen_console.css +++ b/ui/widgets/screen_console.css @@ -20,4 +20,116 @@ @charset "utf-8"; #home-content > .screen > .screen-screen > .screen-console { + position: relative; +} + +#home-content > .screen > .screen-screen > .screen-console > .console-toolbar { + position: absolute; + top: 0; + left: 0; + right: 0; + width: 100%; + max-height: 100%; + overflow: auto; + background: #222; + color: #fff; + box-shadow: 0 0 5px #0006; +} + +#home-content + > .screen + > .screen-screen + > .screen-console + > .console-toolbar + > .console-toolbar-item { + padding: 15px; + float: left; +} + +#home-content + > .screen + > .screen-screen + > .screen-console + > .console-toolbar + > .console-toolbar-item + .tb-title { + font-size: 0.8em; + text-transform: uppercase; + margin: 0 0 5px 10px; + color: #fff9; + text-shadow: 1px 1px 1px #0005; +} + +#home-content + > .screen + > .screen-screen + > .screen-console + > .console-toolbar + > .console-toolbar-item + .tb-item { + display: block; + font-size: 0.7em; + padding: 10px; + text-decoration: none; + color: inherit; + border-radius: 3px; +} + +#home-content + > .screen + > .screen-screen + > .screen-console + > .console-toolbar + > .console-toolbar-item + .tb-item:active { + background: #fff3; +} + +#home-content + > .screen + > .screen-screen + > .screen-console + > .console-toolbar + > .console-toolbar-item + .tb-item + > .tb-key-icon { + margin: 0 5px; + background: #fff2; + color: #fff; +} + +#home-content + > .screen + > .screen-screen + > .screen-console + > .console-toolbar + > .console-toolbar-item + .tb-item + > .tb-key-icon:first-child { + margin-left: 0; +} + +#home-content + > .screen + > .screen-screen + > .screen-console + > .console-toolbar + > .console-toolbar-item + .tb-item + > .tb-key-icon:last-child { + margin-right: 0; +} + +#home-content + > .screen + > .screen-screen + > .screen-console + > .console-toolbar + > .console-toolbar-item + .tb-item:active + .tb-key-icon { + opacity: 0.5; +} + +#home-content > .screen > .screen-screen > .screen-console > .console-console { } diff --git a/ui/widgets/screen_console.vue b/ui/widgets/screen_console.vue index 36b59dd..07ba671 100644 --- a/ui/widgets/screen_console.vue +++ b/ui/widgets/screen_console.vue @@ -18,21 +18,58 @@ --> + +//
+//
+// + +export const consoleScreenKeys = [ + { + title: "Function Keys", + keys: [ + [ + "F1", + { + altKey: false, + charCode: 0, + code: "F1", + ctrlKey: false, + key: "F1", + keyCode: 112, + location: 0, + metaKey: false, + repeat: false, + shiftKey: false, + which: 112 + } + ], + [ + "F2", + { + altKey: false, + charCode: 0, + code: "F2", + ctrlKey: false, + key: "F2", + keyCode: 113, + location: 0, + metaKey: false, + repeat: false, + shiftKey: false, + which: 113 + } + ], + [ + "F3", + { + altKey: false, + charCode: 0, + code: "F3", + ctrlKey: false, + key: "F3", + keyCode: 114, + location: 0, + metaKey: false, + repeat: false, + shiftKey: false, + which: 114 + } + ], + [ + "F4", + { + altKey: false, + charCode: 0, + code: "F4", + ctrlKey: false, + key: "F4", + keyCode: 115, + location: 0, + metaKey: false, + repeat: false, + shiftKey: false, + which: 115 + } + ], + [ + "F5", + { + altKey: false, + charCode: 0, + code: "F5", + ctrlKey: false, + key: "F5", + keyCode: 116, + location: 0, + metaKey: false, + repeat: false, + shiftKey: false, + which: 116 + } + ], + [ + "F6", + { + altKey: false, + charCode: 0, + code: "F6", + ctrlKey: false, + key: "F6", + keyCode: 117, + location: 0, + metaKey: false, + repeat: false, + shiftKey: false, + which: 117 + } + ], + [ + "F7", + { + altKey: false, + charCode: 0, + code: "F7", + ctrlKey: false, + key: "F7", + keyCode: 118, + location: 0, + metaKey: false, + repeat: false, + shiftKey: false, + which: 118 + } + ], + [ + "F8", + { + altKey: false, + charCode: 0, + code: "F8", + ctrlKey: false, + key: "F8", + keyCode: 119, + location: 0, + metaKey: false, + repeat: false, + shiftKey: false, + which: 119 + } + ], + [ + "F9", + { + altKey: false, + charCode: 0, + code: "F9", + ctrlKey: false, + key: "F9", + keyCode: 120, + location: 0, + metaKey: false, + repeat: false, + shiftKey: false, + which: 120 + } + ], + [ + "F10", + { + altKey: false, + charCode: 0, + code: "F10", + ctrlKey: false, + key: "F10", + keyCode: 121, + location: 0, + metaKey: false, + repeat: false, + shiftKey: false, + which: 121 + } + ], + [ + "F11", + { + altKey: false, + charCode: 0, + code: "F11", + ctrlKey: false, + key: "F11", + keyCode: 122, + location: 0, + metaKey: false, + repeat: false, + shiftKey: false, + which: 122 + } + ], + [ + "F12", + { + altKey: false, + charCode: 0, + code: "F12", + ctrlKey: false, + key: "F12", + keyCode: 123, + location: 0, + metaKey: false, + repeat: false, + shiftKey: false, + which: 123 + } + ] + ] + }, + { + title: "Misc Keys", + keys: [ + [ + "Escape", + { + altKey: false, + charCode: 0, + code: "Escape", + ctrlKey: false, + key: "Escape", + keyCode: 27, + location: 0, + metaKey: false, + repeat: false, + shiftKey: false, + which: 27 + } + ], + [ + "Tab", + { + altKey: false, + charCode: 0, + code: "Tab", + ctrlKey: false, + key: "Tab", + keyCode: 9, + location: 0, + metaKey: false, + repeat: false, + shiftKey: false, + which: 9 + } + ], + [ + "Insert", + { + altKey: false, + charCode: 0, + code: "Insert", + ctrlKey: false, + key: "Insert", + keyCode: 45, + location: 0, + metaKey: false, + repeat: false, + shiftKey: false, + which: 45 + } + ], + [ + "Delete", + { + altKey: false, + charCode: 0, + code: "Delete", + ctrlKey: false, + key: "Delete", + keyCode: 46, + location: 0, + metaKey: false, + repeat: false, + shiftKey: false, + which: 46 + } + ] + ] + }, + { + title: "Navigation Keys", + keys: [ + [ + "Home", + { + altKey: false, + charCode: 0, + code: "Home", + ctrlKey: false, + key: "Home", + keyCode: 36, + location: 0, + metaKey: false, + repeat: false, + shiftKey: false, + which: 36 + } + ], + [ + "End", + { + altKey: false, + charCode: 0, + code: "End", + ctrlKey: false, + key: "End", + keyCode: 35, + location: 0, + metaKey: false, + repeat: false, + shiftKey: false, + which: 35 + } + ], + [ + "Up " + String.fromCharCode(8593), + { + altKey: false, + charCode: 0, + code: "ArrowUp", + ctrlKey: false, + key: "ArrowUp", + keyCode: 38, + location: 0, + metaKey: false, + repeat: false, + shiftKey: false, + which: 38 + } + ], + [ + "Down " + String.fromCharCode(8595), + { + altKey: false, + charCode: 0, + code: "ArrowDown", + ctrlKey: false, + key: "ArrowDown", + keyCode: 40, + location: 0, + metaKey: false, + repeat: false, + shiftKey: false, + which: 40 + } + ], + [ + "Left " + String.fromCharCode(8592), + { + altKey: false, + charCode: 0, + code: "ArrowLeft", + ctrlKey: false, + key: "ArrowLeft", + keyCode: 37, + location: 0, + metaKey: false, + repeat: false, + shiftKey: false, + which: 37 + } + ], + [ + "Right " + String.fromCharCode(8594), + { + altKey: false, + charCode: 0, + code: "ArrowRight", + ctrlKey: false, + key: "ArrowRight", + keyCode: 39, + location: 0, + metaKey: false, + repeat: false, + shiftKey: false, + which: 39 + } + ], + [ + "Page Up " + String.fromCharCode(9652), + { + altKey: false, + charCode: 0, + code: "PageUp", + ctrlKey: false, + key: "PageUp", + keyCode: 33, + location: 0, + metaKey: false, + repeat: false, + shiftKey: false, + which: 33 + } + ], + [ + "Page Down " + String.fromCharCode(9662), + { + altKey: false, + charCode: 0, + code: "PageDown", + ctrlKey: false, + key: "PageDown", + keyCode: 34, + location: 0, + metaKey: false, + repeat: false, + shiftKey: false, + which: 34 + } + ] + ] + }, + { + title: "Control Keys", + keys: [ + [ + "Ctrl+C", + { + altKey: false, + charCode: 0, + code: "KeyC", + ctrlKey: true, + key: "c", + keyCode: 67, + location: 0, + metaKey: false, + repeat: false, + shiftKey: false, + which: 67 + } + ], + [ + "Ctrl+Z", + { + altKey: false, + charCode: 0, + code: "KeyZ", + ctrlKey: true, + key: "z", + keyCode: 90, + location: 0, + metaKey: false, + repeat: false, + shiftKey: false, + which: 90 + } + ], + [ + "Ctrl+R", + { + altKey: false, + charCode: 0, + code: "KeyR", + ctrlKey: true, + key: "r", + keyCode: 82, + location: 0, + metaKey: false, + repeat: false, + shiftKey: false, + which: 82 + } + ], + [ + "Ctrl+L", + { + altKey: false, + charCode: 0, + code: "KeyL", + ctrlKey: true, + key: "l", + keyCode: 76, + location: 0, + metaKey: false, + repeat: false, + shiftKey: false, + which: 76 + } + ], + [ + "Ctrl+A", + { + altKey: false, + charCode: 0, + code: "KeyA", + ctrlKey: true, + key: "a", + keyCode: 65, + location: 0, + metaKey: false, + repeat: false, + shiftKey: false, + which: 65 + } + ], + [ + "Ctrl+E", + { + altKey: false, + charCode: 0, + code: "KeyE", + ctrlKey: true, + key: "e", + keyCode: 69, + location: 0, + metaKey: false, + repeat: false, + shiftKey: false, + which: 69 + } + ], + [ + "Ctrl+W", + { + altKey: false, + charCode: 0, + code: "KeyW", + ctrlKey: true, + key: "w", + keyCode: 87, + location: 0, + metaKey: false, + repeat: false, + shiftKey: false, + which: 87 + } + ], + [ + "Ctrl+U", + { + altKey: false, + charCode: 0, + code: "KeyU", + ctrlKey: true, + key: "u", + keyCode: 85, + location: 0, + metaKey: false, + repeat: false, + shiftKey: false, + which: 85 + } + ], + [ + "Ctrl+K", + { + altKey: false, + charCode: 0, + code: "KeyK", + ctrlKey: true, + key: "k", + keyCode: 75, + location: 0, + metaKey: false, + repeat: false, + shiftKey: false, + which: 75 + } + ] + ] + } +]; diff --git a/ui/widgets/screens.vue b/ui/widgets/screens.vue index 407b956..abcb0f7 100644 --- a/ui/widgets/screens.vue +++ b/ui/widgets/screens.vue @@ -23,12 +23,13 @@
+

Main Interface

+
{{ screenInfo.indicator.error }}
@@ -39,6 +40,9 @@ :active="screen === idx" :control="screenInfo.control" :change="screenInfo.indicator" + :toolbar="screenInfo.toolbar" + :style="'background-color: ' + screenInfo.control.activeColor()" + style="top: 0; right: 0; left: 0; bottom: 0; padding: 0; margin: 0; position: absolute; overflow: hidden" @stopped="stopped(idx, $event)" @updated="updated(idx)" >