mirror of
https://github.com/NuSkooler/enigma-bbs.git
synced 2025-06-09 22:24:35 +02:00
Pardon the noise. More tab to space conversion!
This commit is contained in:
parent
c3635bb26b
commit
1d8be6b014
128 changed files with 8017 additions and 8017 deletions
414
core/client.js
414
core/client.js
|
@ -2,69 +2,69 @@
|
|||
'use strict';
|
||||
|
||||
/*
|
||||
Portions of this code for key handling heavily inspired from the following:
|
||||
https://github.com/chjj/blessed/blob/master/lib/keys.js
|
||||
Portions of this code for key handling heavily inspired from the following:
|
||||
https://github.com/chjj/blessed/blob/master/lib/keys.js
|
||||
|
||||
chji's blessed is MIT licensed:
|
||||
chji's blessed is MIT licensed:
|
||||
|
||||
----/snip/----------------------
|
||||
The MIT License (MIT)
|
||||
----/snip/----------------------
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) <year> <copyright holders>
|
||||
Copyright (c) <year> <copyright holders>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
----/snip/----------------------
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
----/snip/----------------------
|
||||
*/
|
||||
// ENiGMA½
|
||||
const term = require('./client_term.js');
|
||||
const ansi = require('./ansi_term.js');
|
||||
const User = require('./user.js');
|
||||
const Config = require('./config.js').get;
|
||||
const MenuStack = require('./menu_stack.js');
|
||||
const ACS = require('./acs.js');
|
||||
const Events = require('./events.js');
|
||||
// ENiGMA½
|
||||
const term = require('./client_term.js');
|
||||
const ansi = require('./ansi_term.js');
|
||||
const User = require('./user.js');
|
||||
const Config = require('./config.js').get;
|
||||
const MenuStack = require('./menu_stack.js');
|
||||
const ACS = require('./acs.js');
|
||||
const Events = require('./events.js');
|
||||
|
||||
// deps
|
||||
const stream = require('stream');
|
||||
const assert = require('assert');
|
||||
const _ = require('lodash');
|
||||
// deps
|
||||
const stream = require('stream');
|
||||
const assert = require('assert');
|
||||
const _ = require('lodash');
|
||||
|
||||
exports.Client = Client;
|
||||
exports.Client = Client;
|
||||
|
||||
// :TODO: Move all of the key stuff to it's own module
|
||||
// :TODO: Move all of the key stuff to it's own module
|
||||
|
||||
//
|
||||
// Resources & Standards:
|
||||
// * http://www.ansi-bbs.org/ansi-bbs-core-server.html
|
||||
// Resources & Standards:
|
||||
// * http://www.ansi-bbs.org/ansi-bbs-core-server.html
|
||||
//
|
||||
const RE_DSR_RESPONSE_ANYWHERE = /(?:\u001b\[)([0-9;]+)(R)/;
|
||||
const RE_DEV_ATTR_RESPONSE_ANYWHERE = /(?:\u001b\[)[=?]([0-9a-zA-Z;]+)(c)/;
|
||||
const RE_META_KEYCODE_ANYWHERE = /(?:\u001b)([a-zA-Z0-9])/;
|
||||
const RE_META_KEYCODE = new RegExp('^' + RE_META_KEYCODE_ANYWHERE.source + '$');
|
||||
const RE_FUNCTION_KEYCODE_ANYWHERE = new RegExp('(?:\u001b+)(O|N|\\[|\\[\\[)(?:' + [
|
||||
const RE_DSR_RESPONSE_ANYWHERE = /(?:\u001b\[)([0-9;]+)(R)/;
|
||||
const RE_DEV_ATTR_RESPONSE_ANYWHERE = /(?:\u001b\[)[=?]([0-9a-zA-Z;]+)(c)/;
|
||||
const RE_META_KEYCODE_ANYWHERE = /(?:\u001b)([a-zA-Z0-9])/;
|
||||
const RE_META_KEYCODE = new RegExp('^' + RE_META_KEYCODE_ANYWHERE.source + '$');
|
||||
const RE_FUNCTION_KEYCODE_ANYWHERE = new RegExp('(?:\u001b+)(O|N|\\[|\\[\\[)(?:' + [
|
||||
'(\\d+)(?:;(\\d+))?([~^$])',
|
||||
'(?:M([@ #!a`])(.)(.))', // mouse stuff
|
||||
'(?:M([@ #!a`])(.)(.))', // mouse stuff
|
||||
'(?:1;)?(\\d+)?([a-zA-Z@])'
|
||||
].join('|') + ')');
|
||||
|
||||
const RE_FUNCTION_KEYCODE = new RegExp('^' + RE_FUNCTION_KEYCODE_ANYWHERE.source);
|
||||
const RE_ESC_CODE_ANYWHERE = new RegExp( [
|
||||
const RE_FUNCTION_KEYCODE = new RegExp('^' + RE_FUNCTION_KEYCODE_ANYWHERE.source);
|
||||
const RE_ESC_CODE_ANYWHERE = new RegExp( [
|
||||
RE_FUNCTION_KEYCODE_ANYWHERE.source,
|
||||
RE_META_KEYCODE_ANYWHERE.source,
|
||||
RE_DSR_RESPONSE_ANYWHERE.source,
|
||||
|
@ -76,14 +76,14 @@ const RE_ESC_CODE_ANYWHERE = new RegExp( [
|
|||
function Client(/*input, output*/) {
|
||||
stream.call(this);
|
||||
|
||||
const self = this;
|
||||
const self = this;
|
||||
|
||||
this.user = new User();
|
||||
this.currentTheme = { info : { name : 'N/A', description : 'None' } };
|
||||
this.lastKeyPressMs = Date.now();
|
||||
this.menuStack = new MenuStack(this);
|
||||
this.acs = new ACS(this);
|
||||
this.mciCache = {};
|
||||
this.user = new User();
|
||||
this.currentTheme = { info : { name : 'N/A', description : 'None' } };
|
||||
this.lastKeyPressMs = Date.now();
|
||||
this.menuStack = new MenuStack(this);
|
||||
this.acs = new ACS(this);
|
||||
this.mciCache = {};
|
||||
|
||||
this.clearMciCache = function() {
|
||||
this.mciCache = {};
|
||||
|
@ -119,34 +119,34 @@ function Client(/*input, output*/) {
|
|||
|
||||
|
||||
//
|
||||
// Peek at incoming |data| and emit events for any special
|
||||
// handling that may include:
|
||||
// * Keyboard input
|
||||
// * ANSI CSR's and the like
|
||||
// Peek at incoming |data| and emit events for any special
|
||||
// handling that may include:
|
||||
// * Keyboard input
|
||||
// * ANSI CSR's and the like
|
||||
//
|
||||
// References:
|
||||
// * http://www.ansi-bbs.org/ansi-bbs-core-server.html
|
||||
// * Christopher Jeffrey's Blessed library @ https://github.com/chjj/blessed/
|
||||
// References:
|
||||
// * http://www.ansi-bbs.org/ansi-bbs-core-server.html
|
||||
// * Christopher Jeffrey's Blessed library @ https://github.com/chjj/blessed/
|
||||
//
|
||||
this.getTermClient = function(deviceAttr) {
|
||||
let termClient = {
|
||||
//
|
||||
// See http://www.fbl.cz/arctel/download/techman.pdf
|
||||
// See http://www.fbl.cz/arctel/download/techman.pdf
|
||||
//
|
||||
// Known clients:
|
||||
// * Irssi ConnectBot (Android)
|
||||
// Known clients:
|
||||
// * Irssi ConnectBot (Android)
|
||||
//
|
||||
'63;1;2' : 'arctel',
|
||||
'50;86;84;88' : 'vtx',
|
||||
'63;1;2' : 'arctel',
|
||||
'50;86;84;88' : 'vtx',
|
||||
}[deviceAttr];
|
||||
|
||||
if(!termClient) {
|
||||
if(_.startsWith(deviceAttr, '67;84;101;114;109')) {
|
||||
//
|
||||
// See https://github.com/protomouse/synchronet/blob/master/src/conio/cterm.txt
|
||||
// See https://github.com/protomouse/synchronet/blob/master/src/conio/cterm.txt
|
||||
//
|
||||
// Known clients:
|
||||
// * SyncTERM
|
||||
// Known clients:
|
||||
// * SyncTERM
|
||||
//
|
||||
termClient = 'cterm';
|
||||
}
|
||||
|
@ -156,18 +156,18 @@ function Client(/*input, output*/) {
|
|||
};
|
||||
|
||||
this.isMouseInput = function(data) {
|
||||
return /\x1b\[M/.test(data) || // eslint-disable-line no-control-regex
|
||||
/\u001b\[M([\x00\u0020-\uffff]{3})/.test(data) || // eslint-disable-line no-control-regex
|
||||
/\u001b\[(\d+;\d+;\d+)M/.test(data) ||
|
||||
/\u001b\[<(\d+;\d+;\d+)([mM])/.test(data) ||
|
||||
/\u001b\[<(\d+;\d+;\d+;\d+)&w/.test(data) ||
|
||||
/\u001b\[24([0135])~\[(\d+),(\d+)\]\r/.test(data) ||
|
||||
/\u001b\[(O|I)/.test(data);
|
||||
return /\x1b\[M/.test(data) || // eslint-disable-line no-control-regex
|
||||
/\u001b\[M([\x00\u0020-\uffff]{3})/.test(data) || // eslint-disable-line no-control-regex
|
||||
/\u001b\[(\d+;\d+;\d+)M/.test(data) ||
|
||||
/\u001b\[<(\d+;\d+;\d+)([mM])/.test(data) ||
|
||||
/\u001b\[<(\d+;\d+;\d+;\d+)&w/.test(data) ||
|
||||
/\u001b\[24([0135])~\[(\d+),(\d+)\]\r/.test(data) ||
|
||||
/\u001b\[(O|I)/.test(data);
|
||||
};
|
||||
|
||||
this.getKeyComponentsFromCode = function(code) {
|
||||
return {
|
||||
// xterm/gnome
|
||||
// xterm/gnome
|
||||
'OP' : { name : 'f1' },
|
||||
'OQ' : { name : 'f2' },
|
||||
'OR' : { name : 'f3' },
|
||||
|
@ -181,93 +181,93 @@ function Client(/*input, output*/) {
|
|||
'OF' : { name : 'end' },
|
||||
'OH' : { name : 'home' },
|
||||
|
||||
// xterm/rxvt
|
||||
'[11~' : { name : 'f1' },
|
||||
'[12~' : { name : 'f2' },
|
||||
'[13~' : { name : 'f3' },
|
||||
'[14~' : { name : 'f4' },
|
||||
// xterm/rxvt
|
||||
'[11~' : { name : 'f1' },
|
||||
'[12~' : { name : 'f2' },
|
||||
'[13~' : { name : 'f3' },
|
||||
'[14~' : { name : 'f4' },
|
||||
|
||||
'[1~' : { name : 'home' },
|
||||
'[2~' : { name : 'insert' },
|
||||
'[3~' : { name : 'delete' },
|
||||
'[4~' : { name : 'end' },
|
||||
'[5~' : { name : 'page up' },
|
||||
'[6~' : { name : 'page down' },
|
||||
'[1~' : { name : 'home' },
|
||||
'[2~' : { name : 'insert' },
|
||||
'[3~' : { name : 'delete' },
|
||||
'[4~' : { name : 'end' },
|
||||
'[5~' : { name : 'page up' },
|
||||
'[6~' : { name : 'page down' },
|
||||
|
||||
// Cygwin & libuv
|
||||
'[[A' : { name : 'f1' },
|
||||
'[[B' : { name : 'f2' },
|
||||
'[[C' : { name : 'f3' },
|
||||
'[[D' : { name : 'f4' },
|
||||
'[[E' : { name : 'f5' },
|
||||
// Cygwin & libuv
|
||||
'[[A' : { name : 'f1' },
|
||||
'[[B' : { name : 'f2' },
|
||||
'[[C' : { name : 'f3' },
|
||||
'[[D' : { name : 'f4' },
|
||||
'[[E' : { name : 'f5' },
|
||||
|
||||
// Common impls
|
||||
'[15~' : { name : 'f5' },
|
||||
'[17~' : { name : 'f6' },
|
||||
'[18~' : { name : 'f7' },
|
||||
'[19~' : { name : 'f8' },
|
||||
'[20~' : { name : 'f9' },
|
||||
'[21~' : { name : 'f10' },
|
||||
'[23~' : { name : 'f11' },
|
||||
'[24~' : { name : 'f12' },
|
||||
// Common impls
|
||||
'[15~' : { name : 'f5' },
|
||||
'[17~' : { name : 'f6' },
|
||||
'[18~' : { name : 'f7' },
|
||||
'[19~' : { name : 'f8' },
|
||||
'[20~' : { name : 'f9' },
|
||||
'[21~' : { name : 'f10' },
|
||||
'[23~' : { name : 'f11' },
|
||||
'[24~' : { name : 'f12' },
|
||||
|
||||
// xterm
|
||||
'[A' : { name : 'up arrow' },
|
||||
'[B' : { name : 'down arrow' },
|
||||
'[C' : { name : 'right arrow' },
|
||||
'[D' : { name : 'left arrow' },
|
||||
'[E' : { name : 'clear' },
|
||||
'[F' : { name : 'end' },
|
||||
'[H' : { name : 'home' },
|
||||
// xterm
|
||||
'[A' : { name : 'up arrow' },
|
||||
'[B' : { name : 'down arrow' },
|
||||
'[C' : { name : 'right arrow' },
|
||||
'[D' : { name : 'left arrow' },
|
||||
'[E' : { name : 'clear' },
|
||||
'[F' : { name : 'end' },
|
||||
'[H' : { name : 'home' },
|
||||
|
||||
// PuTTY
|
||||
'[[5~' : { name : 'page up' },
|
||||
'[[6~' : { name : 'page down' },
|
||||
// PuTTY
|
||||
'[[5~' : { name : 'page up' },
|
||||
'[[6~' : { name : 'page down' },
|
||||
|
||||
// rvxt
|
||||
'[7~' : { name : 'home' },
|
||||
'[8~' : { name : 'end' },
|
||||
// rvxt
|
||||
'[7~' : { name : 'home' },
|
||||
'[8~' : { name : 'end' },
|
||||
|
||||
// rxvt with modifiers
|
||||
'[a' : { name : 'up arrow', shift : true },
|
||||
'[b' : { name : 'down arrow', shift : true },
|
||||
'[c' : { name : 'right arrow', shift : true },
|
||||
'[d' : { name : 'left arrow', shift : true },
|
||||
'[e' : { name : 'clear', shift : true },
|
||||
// rxvt with modifiers
|
||||
'[a' : { name : 'up arrow', shift : true },
|
||||
'[b' : { name : 'down arrow', shift : true },
|
||||
'[c' : { name : 'right arrow', shift : true },
|
||||
'[d' : { name : 'left arrow', shift : true },
|
||||
'[e' : { name : 'clear', shift : true },
|
||||
|
||||
'[2$' : { name : 'insert', shift : true },
|
||||
'[3$' : { name : 'delete', shift : true },
|
||||
'[5$' : { name : 'page up', shift : true },
|
||||
'[6$' : { name : 'page down', shift : true },
|
||||
'[7$' : { name : 'home', shift : true },
|
||||
'[8$' : { name : 'end', shift : true },
|
||||
'[2$' : { name : 'insert', shift : true },
|
||||
'[3$' : { name : 'delete', shift : true },
|
||||
'[5$' : { name : 'page up', shift : true },
|
||||
'[6$' : { name : 'page down', shift : true },
|
||||
'[7$' : { name : 'home', shift : true },
|
||||
'[8$' : { name : 'end', shift : true },
|
||||
|
||||
'Oa' : { name : 'up arrow', ctrl : true },
|
||||
'Ob' : { name : 'down arrow', ctrl : true },
|
||||
'Oc' : { name : 'right arrow', ctrl : true },
|
||||
'Od' : { name : 'left arrow', ctrl : true },
|
||||
'Oe' : { name : 'clear', ctrl : true },
|
||||
'Oa' : { name : 'up arrow', ctrl : true },
|
||||
'Ob' : { name : 'down arrow', ctrl : true },
|
||||
'Oc' : { name : 'right arrow', ctrl : true },
|
||||
'Od' : { name : 'left arrow', ctrl : true },
|
||||
'Oe' : { name : 'clear', ctrl : true },
|
||||
|
||||
'[2^' : { name : 'insert', ctrl : true },
|
||||
'[3^' : { name : 'delete', ctrl : true },
|
||||
'[5^' : { name : 'page up', ctrl : true },
|
||||
'[6^' : { name : 'page down', ctrl : true },
|
||||
'[7^' : { name : 'home', ctrl : true },
|
||||
'[8^' : { name : 'end', ctrl : true },
|
||||
'[2^' : { name : 'insert', ctrl : true },
|
||||
'[3^' : { name : 'delete', ctrl : true },
|
||||
'[5^' : { name : 'page up', ctrl : true },
|
||||
'[6^' : { name : 'page down', ctrl : true },
|
||||
'[7^' : { name : 'home', ctrl : true },
|
||||
'[8^' : { name : 'end', ctrl : true },
|
||||
|
||||
// SyncTERM / EtherTerm
|
||||
'[K' : { name : 'end' },
|
||||
'[@' : { name : 'insert' },
|
||||
'[V' : { name : 'page up' },
|
||||
'[U' : { name : 'page down' },
|
||||
// SyncTERM / EtherTerm
|
||||
'[K' : { name : 'end' },
|
||||
'[@' : { name : 'insert' },
|
||||
'[V' : { name : 'page up' },
|
||||
'[U' : { name : 'page down' },
|
||||
|
||||
// other
|
||||
'[Z' : { name : 'tab', shift : true },
|
||||
// other
|
||||
'[Z' : { name : 'tab', shift : true },
|
||||
}[code];
|
||||
};
|
||||
|
||||
this.on('data', function clientData(data) {
|
||||
// create a uniform format that can be parsed below
|
||||
// create a uniform format that can be parsed below
|
||||
if(data[0] > 127 && undefined === data[1]) {
|
||||
data[0] -= 128;
|
||||
data = '\u001b' + data.toString('utf-8');
|
||||
|
@ -287,15 +287,15 @@ function Client(/*input, output*/) {
|
|||
data = data.slice(m.index + m[0].length);
|
||||
}
|
||||
|
||||
buf = buf.concat(data.split('')); // remainder
|
||||
buf = buf.concat(data.split('')); // remainder
|
||||
|
||||
buf.forEach(function bufPart(s) {
|
||||
var key = {
|
||||
seq : s,
|
||||
name : undefined,
|
||||
ctrl : false,
|
||||
meta : false,
|
||||
shift : false,
|
||||
seq : s,
|
||||
name : undefined,
|
||||
ctrl : false,
|
||||
meta : false,
|
||||
shift : false,
|
||||
};
|
||||
|
||||
var parts;
|
||||
|
@ -325,55 +325,55 @@ function Client(/*input, output*/) {
|
|||
key.name = 'tab';
|
||||
} else if('\x7f' === s) {
|
||||
//
|
||||
// Backspace vs delete is a crazy thing, especially in *nix.
|
||||
// - ANSI-BBS uses 0x7f for DEL
|
||||
// - xterm et. al clients send 0x7f for backspace... ugg.
|
||||
// Backspace vs delete is a crazy thing, especially in *nix.
|
||||
// - ANSI-BBS uses 0x7f for DEL
|
||||
// - xterm et. al clients send 0x7f for backspace... ugg.
|
||||
//
|
||||
// See http://www.hypexr.org/linux_ruboff.php
|
||||
// And a great discussion @ https://lists.debian.org/debian-i18n/1998/04/msg00015.html
|
||||
// See http://www.hypexr.org/linux_ruboff.php
|
||||
// And a great discussion @ https://lists.debian.org/debian-i18n/1998/04/msg00015.html
|
||||
//
|
||||
if(self.term.isNixTerm()) {
|
||||
key.name = 'backspace';
|
||||
key.name = 'backspace';
|
||||
} else {
|
||||
key.name = 'delete';
|
||||
key.name = 'delete';
|
||||
}
|
||||
} else if ('\b' === s || '\x1b\x7f' === s || '\x1b\b' === s) {
|
||||
// backspace, CTRL-H
|
||||
key.name = 'backspace';
|
||||
key.meta = ('\x1b' === s.charAt(0));
|
||||
// backspace, CTRL-H
|
||||
key.name = 'backspace';
|
||||
key.meta = ('\x1b' === s.charAt(0));
|
||||
} else if('\x1b' === s || '\x1b\x1b' === s) {
|
||||
key.name = 'escape';
|
||||
key.meta = (2 === s.length);
|
||||
key.name = 'escape';
|
||||
key.meta = (2 === s.length);
|
||||
} else if (' ' === s || '\x1b ' === s) {
|
||||
// rather annoying that space can come in other than just " "
|
||||
key.name = 'space';
|
||||
key.meta = (2 === s.length);
|
||||
// rather annoying that space can come in other than just " "
|
||||
key.name = 'space';
|
||||
key.meta = (2 === s.length);
|
||||
} else if(1 === s.length && s <= '\x1a') {
|
||||
// CTRL-<letter>
|
||||
key.name = String.fromCharCode(s.charCodeAt(0) + 'a'.charCodeAt(0) - 1);
|
||||
key.ctrl = true;
|
||||
// CTRL-<letter>
|
||||
key.name = String.fromCharCode(s.charCodeAt(0) + 'a'.charCodeAt(0) - 1);
|
||||
key.ctrl = true;
|
||||
} else if(1 === s.length && s >= 'a' && s <= 'z') {
|
||||
// normal, lowercased letter
|
||||
key.name = s;
|
||||
// normal, lowercased letter
|
||||
key.name = s;
|
||||
} else if(1 === s.length && s >= 'A' && s <= 'Z') {
|
||||
key.name = s.toLowerCase();
|
||||
key.shift = true;
|
||||
key.name = s.toLowerCase();
|
||||
key.shift = true;
|
||||
} else if ((parts = RE_META_KEYCODE.exec(s))) {
|
||||
// meta with character key
|
||||
key.name = parts[1].toLowerCase();
|
||||
key.meta = true;
|
||||
key.shift = /^[A-Z]$/.test(parts[1]);
|
||||
// meta with character key
|
||||
key.name = parts[1].toLowerCase();
|
||||
key.meta = true;
|
||||
key.shift = /^[A-Z]$/.test(parts[1]);
|
||||
} else if((parts = RE_FUNCTION_KEYCODE.exec(s))) {
|
||||
var code =
|
||||
(parts[1] || '') + (parts[2] || '') +
|
||||
(parts[4] || '') + (parts[9] || '');
|
||||
(parts[1] || '') + (parts[2] || '') +
|
||||
(parts[4] || '') + (parts[9] || '');
|
||||
|
||||
var modifier = (parts[3] || parts[8] || 1) - 1;
|
||||
|
||||
key.ctrl = !!(modifier & 4);
|
||||
key.meta = !!(modifier & 10);
|
||||
key.shift = !!(modifier & 1);
|
||||
key.code = code;
|
||||
key.ctrl = !!(modifier & 4);
|
||||
key.meta = !!(modifier & 10);
|
||||
key.shift = !!(modifier & 1);
|
||||
key.code = code;
|
||||
|
||||
_.assign(key, self.getKeyComponentsFromCode(code));
|
||||
}
|
||||
|
@ -382,7 +382,7 @@ function Client(/*input, output*/) {
|
|||
if(1 === s.length) {
|
||||
ch = s;
|
||||
} else if('space' === key.name) {
|
||||
// stupid hack to always get space as a regular char
|
||||
// stupid hack to always get space as a regular char
|
||||
ch = ' ';
|
||||
}
|
||||
|
||||
|
@ -390,18 +390,18 @@ function Client(/*input, output*/) {
|
|||
key = undefined;
|
||||
} else {
|
||||
//
|
||||
// Adjust name for CTRL/Shift/Meta modifiers
|
||||
// Adjust name for CTRL/Shift/Meta modifiers
|
||||
//
|
||||
key.name =
|
||||
(key.ctrl ? 'ctrl + ' : '') +
|
||||
(key.meta ? 'meta + ' : '') +
|
||||
(key.shift ? 'shift + ' : '') +
|
||||
key.name;
|
||||
(key.ctrl ? 'ctrl + ' : '') +
|
||||
(key.meta ? 'meta + ' : '') +
|
||||
(key.shift ? 'shift + ' : '') +
|
||||
key.name;
|
||||
}
|
||||
|
||||
if(key || ch) {
|
||||
if(Config().logging.traceUserKeyboardInput) {
|
||||
self.log.trace( { key : key, ch : escape(ch) }, 'User keyboard input'); // jshint ignore:line
|
||||
self.log.trace( { key : key, ch : escape(ch) }, 'User keyboard input'); // jshint ignore:line
|
||||
}
|
||||
|
||||
self.lastKeyPressMs = Date.now();
|
||||
|
@ -417,15 +417,15 @@ function Client(/*input, output*/) {
|
|||
require('util').inherits(Client, stream);
|
||||
|
||||
Client.prototype.setInputOutput = function(input, output) {
|
||||
this.input = input;
|
||||
this.output = output;
|
||||
this.input = input;
|
||||
this.output = output;
|
||||
|
||||
this.term = new term.ClientTerminal(this.output);
|
||||
this.term = new term.ClientTerminal(this.output);
|
||||
};
|
||||
|
||||
Client.prototype.setTermType = function(termType) {
|
||||
this.term.env.TERM = termType;
|
||||
this.term.termType = termType;
|
||||
this.term.env.TERM = termType;
|
||||
this.term.termType = termType;
|
||||
|
||||
this.log.debug( { termType : termType }, 'Set terminal type');
|
||||
};
|
||||
|
@ -434,10 +434,10 @@ Client.prototype.startIdleMonitor = function() {
|
|||
this.lastKeyPressMs = Date.now();
|
||||
|
||||
//
|
||||
// Every 1m, check for idle.
|
||||
// Every 1m, check for idle.
|
||||
//
|
||||
this.idleCheck = setInterval( () => {
|
||||
const nowMs = Date.now();
|
||||
const nowMs = Date.now();
|
||||
|
||||
const idleLogoutSeconds = this.user.isAuthenticated() ?
|
||||
Config().misc.idleLogoutSeconds :
|
||||
|
@ -468,12 +468,12 @@ Client.prototype.end = function () {
|
|||
|
||||
try {
|
||||
//
|
||||
// We can end up calling 'end' before TTY/etc. is established, e.g. with SSH
|
||||
// We can end up calling 'end' before TTY/etc. is established, e.g. with SSH
|
||||
//
|
||||
// :TODO: is this OK?
|
||||
// :TODO: is this OK?
|
||||
return this.output.end.apply(this.output, arguments);
|
||||
} catch(e) {
|
||||
// TypeError
|
||||
// TypeError
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -492,15 +492,15 @@ Client.prototype.waitForKeyPress = function(cb) {
|
|||
};
|
||||
|
||||
Client.prototype.isLocal = function() {
|
||||
// :TODO: Handle ipv6 better
|
||||
// :TODO: Handle ipv6 better
|
||||
return [ '127.0.0.1', '::ffff:127.0.0.1' ].includes(this.remoteAddress);
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Default error handlers
|
||||
// Default error handlers
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// :TODO: getDefaultHandler(name) -- handlers in default_handlers.js or something
|
||||
// :TODO: getDefaultHandler(name) -- handlers in default_handlers.js or something
|
||||
Client.prototype.defaultHandlerMissingMod = function() {
|
||||
var self = this;
|
||||
|
||||
|
@ -516,7 +516,7 @@ Client.prototype.defaultHandlerMissingMod = function() {
|
|||
//self.term.write(err);
|
||||
|
||||
//if(miscUtil.isDevelopment() && err.stack) {
|
||||
// self.term.write('\n' + err.stack + '\n');
|
||||
// self.term.write('\n' + err.stack + '\n');
|
||||
//}
|
||||
|
||||
self.end();
|
||||
|
@ -530,7 +530,7 @@ Client.prototype.terminalSupports = function(query) {
|
|||
|
||||
switch(query) {
|
||||
case 'vtx_audio' :
|
||||
// https://github.com/codewar65/VTX_ClientServer/blob/master/vtx.txt
|
||||
// https://github.com/codewar65/VTX_ClientServer/blob/master/vtx.txt
|
||||
return 'vtx' === termClient;
|
||||
|
||||
case 'vtx_hyperlink' :
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue