Improved terminal.

This commit is contained in:
Ylian Saint-Hilaire 2019-04-05 10:53:57 -07:00
parent 1e930c60f2
commit af46798c16
3 changed files with 17 additions and 11 deletions

View File

@ -41,7 +41,7 @@ var CreateAmtRemoteTerminal = function (divid) {
var _VTREVERSE = 2; var _VTREVERSE = 2;
var _backSpaceErase = false; var _backSpaceErase = false;
var _cursorVisible = true; var _cursorVisible = true;
var _scrollRegion = [0, 25]; var _scrollRegion = [0, 24];
obj.Start = function () { } obj.Start = function () { }
@ -308,6 +308,11 @@ var CreateAmtRemoteTerminal = function (divid) {
break; break;
case 'r': // Set the scroll region case 'r': // Set the scroll region
if (argslen == 2) { _scrollRegion = [args[0] - 1, args[1] - 1]; } if (argslen == 2) { _scrollRegion = [args[0] - 1, args[1] - 1]; }
if (_scrollRegion[0] < 0) { _scrollRegion[0] = 0; }
if (_scrollRegion[0] > 24) { _scrollRegion[0] = 24; }
if (_scrollRegion[1] < 0) { _scrollRegion[1] = 0; }
if (_scrollRegion[1] > 24) { _scrollRegion[1] = 24; }
if (_scrollRegion[0] > _scrollRegion[1]) { _scrollRegion[0] = _scrollRegion[1]; }
break; break;
case 'S': // Scroll up the scroll region X lines, default 1 case 'S': // Scroll up the scroll region X lines, default 1
var x = 1; var x = 1;
@ -472,12 +477,12 @@ var CreateAmtRemoteTerminal = function (divid) {
break; break;
case '\n': // Linefeed case '\n': // Linefeed
_termy++; _termy++;
if (_termy > (_scrollRegion[1] - 1)) { if (_termy > _scrollRegion[1]) {
// Move everything up one line // Move everything up one line
_TermMoveUp(1); _TermMoveUp(1);
_termy = (obj.height - 1); _termy = _scrollRegion[1];
} }
if (obj.lineFeed = '\n') { _termx = 0; } // *** If we are in Linux mode, \n will also return the cursor to the first col if (obj.lineFeed = '\r') { _termx = 0; } // *** If we are in Linux mode, \n will also return the cursor to the first col
break; break;
case '\r': // Carriage Return case '\r': // Carriage Return
_termx = 0; _termx = 0;
@ -513,9 +518,10 @@ var CreateAmtRemoteTerminal = function (divid) {
_TermCurrentReverse = 0; _TermCurrentReverse = 0;
_TermCurrentFColor = 7; _TermCurrentFColor = 7;
_TermCurrentBColor = 0; _TermCurrentBColor = 0;
_TermLineWrap = true; _TermLineWrap = _cursorVisible = true;
_termx = 0; _termx = _termy = 0;
_termy = 0; _backSpaceErase = false;
_scrollRegion = [0, 24];
obj.TermClear(7 << 6); obj.TermClear(7 << 6);
} }
@ -565,7 +571,7 @@ var CreateAmtRemoteTerminal = function (divid) {
obj.TermHandleKeys = function (e) { obj.TermHandleKeys = function (e) {
if (!e.ctrlKey) { if (!e.ctrlKey) {
if (e.which == 127) obj.TermSendKey(8); if (e.which == 127) obj.TermSendKey(8);
else if (e.which == 13) obj.TermSendKeys(obj.lineFeed); else if (e.which == 13) { obj.TermSendKeys(obj.lineFeed); }
else if (e.which != 0) obj.TermSendKey(e.which); else if (e.which != 0) obj.TermSendKey(e.which);
return false; return false;
} }
@ -635,7 +641,7 @@ var CreateAmtRemoteTerminal = function (divid) {
buf += closetag; buf += closetag;
closetag = ''; closetag = '';
x1 = 6; x2 = 12; x1 = 6; x2 = 12;
if (newat & _VTREVERSE) { x1 = 12; x2 = 6;} if (newat & _VTREVERSE) { x1 = 12; x2 = 6; }
buf += '<span style="color:#' + _TermColors[(newat >> x1) & 0x3F] + ';background-color:#' + _TermColors[(newat >> x2) & 0x3F]; buf += '<span style="color:#' + _TermColors[(newat >> x1) & 0x3F] + ';background-color:#' + _TermColors[(newat >> x2) & 0x3F];
if (newat & _VTUNDERLINE) buf += ';text-decoration:underline'; if (newat & _VTUNDERLINE) buf += ';text-decoration:underline';
buf += ';">'; buf += ';">';

File diff suppressed because one or more lines are too long

View File

@ -4849,7 +4849,7 @@
terminal = CreateAgentRedirect(meshserver, CreateAmtRemoteTerminal('Term'), serverPublicNamePort, authCookie); terminal = CreateAgentRedirect(meshserver, CreateAmtRemoteTerminal('Term'), serverPublicNamePort, authCookie);
terminal.debugmode = debugmode; terminal.debugmode = debugmode;
terminal.m.debugmode = debugmode; terminal.m.debugmode = debugmode;
terminal.m.lineFeed = ([1,2,3,4,21,22].indexOf(currentNode.agent.id) >= 0)?'\r\n':'\n'; // On windows, send \r\n, on Linux only \n terminal.m.lineFeed = ([1, 2, 3, 4, 21, 22].indexOf(currentNode.agent.id) >= 0) ? '\r\n' : '\r'; // On windows, send \r\n, on Linux only \r
terminal.attemptWebRTC = attemptWebRTC; terminal.attemptWebRTC = attemptWebRTC;
terminal.onStateChanged = onTerminalStateChange; terminal.onStateChanged = onTerminalStateChange;
terminal.Start(terminalNode._id); terminal.Start(terminalNode._id);