"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "shellinabox/vt100.jspp" between
shellinabox-2.19.tar.gz and shellinabox-2.20.tar.gz

About: shellinabox implements a web server that can export arbitrary command line tools to a web based terminal emulator. This emulator is accessible to any JavaScript and CSS enabled web browser. Fork of the no longer maintained original version on https://shellinabox.com/ respectively https://code.google.com/archive/p/shellinabox/.

vt100.jspp  (shellinabox-2.19):vt100.jspp  (shellinabox-2.20)
skipping to change at line 86 skipping to change at line 86
#define ESsetG2 10 #define ESsetG2 10
#define ESsetG3 11 #define ESsetG3 11
#define ESbang 12 #define ESbang 12
#define ESpercent 13 #define ESpercent 13
#define ESignore 14 #define ESignore 14
#define ESnonstd 15 #define ESnonstd 15
#define ESpalette 16 #define ESpalette 16
#define EStitle 17 #define EStitle 17
#define ESss2 18 #define ESss2 18
#define ESss3 19 #define ESss3 19
#define ESVTEtitle 20
#define ATTR_DEFAULT 0x60F0 #define ATTR_DEFAULT 0x60F0
#define ATTR_REVERSE 0x0100 #define ATTR_REVERSE 0x0100
#define ATTR_UNDERLINE 0x0200 #define ATTR_UNDERLINE 0x0200
#define ATTR_DIM 0x0400 #define ATTR_DIM 0x0400
#define ATTR_BRIGHT 0x0800 #define ATTR_BRIGHT 0x0800
#define ATTR_BLINK 0x1000 #define ATTR_BLINK 0x1000
#define ATTR_DEF_FG 0x2000 #define ATTR_DEF_FG 0x2000
#define ATTR_DEF_BG 0x4000 #define ATTR_DEF_BG 0x4000
skipping to change at line 1606 skipping to change at line 1607
if (this.cursorWidth <= 0) { if (this.cursorWidth <= 0) {
if (this.cursor.clientWidth <= 0) { if (this.cursor.clientWidth <= 0) {
// Rats, this.cursor.clientWidth is zero too. Best guess? // Rats, this.cursor.clientWidth is zero too. Best guess?
this.terminalWidth = 80; this.terminalWidth = 80;
} else { } else {
// update the size. // update the size.
this.cursorWidth = this.cursor.clientWidth; this.cursorWidth = this.cursor.clientWidth;
this.terminalWidth = Math.floor(this.console[this.currentScreen].offsetWid th/this.cursorWidth*this.scale); this.terminalWidth = Math.floor(this.console[this.currentScreen].offsetWid th/this.cursorWidth*this.scale);
} }
} else { } else {
this.terminalWidth = Math.floor(this.console[this.currentScreen].offsetWidth if ("ActiveXObject" in window)
/this.cursorWidth*this.scale); this.terminalWidth = Math.floor(this.console[this.currentScreen].offsetWid
th/this.cursorWidth*this.scale*0.95);
else
this.terminalWidth = Math.floor(this.console[this.currentScreen].offsetWid
th/this.cursorWidth*this.scale);
} }
return this.terminalWidth; return this.terminalWidth;
}; };
VT100.prototype.updateHeight = function() { VT100.prototype.updateHeight = function() {
// We want to be able to display either a terminal window that fills the // We want to be able to display either a terminal window that fills the
// entire browser window, or a terminal window that is contained in a // entire browser window, or a terminal window that is contained in a
// <div> which is embededded somewhere in the web page. // <div> which is embededded somewhere in the web page.
if (this.isEmbedded) { if (this.isEmbedded) {
skipping to change at line 2842 skipping to change at line 2846
part1 += ';'; part1 += ';';
} }
} else if (start == '\u001BO') { } else if (start == '\u001BO') {
part1 = start; part1 = start;
part2 = ch.substr(2); part2 = ch.substr(2);
} }
if (part1 != undefined) { if (part1 != undefined) {
ch = part1 + ch = part1 +
((event.shiftKey ? 1 : 0) + ((event.shiftKey ? 1 : 0) +
(event.altKey|event.metaKey ? 2 : 0) + (event.altKey|event.metaKey ? 2 : 0) +
(event.ctrlKey ? 4 : 0)) + (event.ctrlKey ? 4 : 0) + 1 ) +
part2; part2;
} else if (ch.length == 1 && (event.altKey || event.metaKey) } else if (ch.length == 1 && (event.altKey || event.metaKey)
&& !this.disableAlt) { && !this.disableAlt) {
ch = '\u001B' + ch; ch = '\u001B' + ch;
} }
} }
if (this.menu.style.visibility == 'hidden') { if (this.menu.style.visibility == 'hidden') {
// this.vt100('R: c='); // this.vt100('R: c=');
// for (var i = 0; i < ch.length; i++) // for (var i = 0; i < ch.length; i++)
skipping to change at line 2912 skipping to change at line 2916
fake.ctrlKey = false; fake.ctrlKey = false;
fake.shiftKey = event.shiftKey; fake.shiftKey = event.shiftKey;
fake.altKey = false; fake.altKey = false;
fake.metaKey = event.metaKey; fake.metaKey = event.metaKey;
return fake; return fake;
} }
// Some browsers fail to translate keys, if both shift and alt/meta is // Some browsers fail to translate keys, if both shift and alt/meta is
// pressed at the same time. We try to translate those cases, but that // pressed at the same time. We try to translate those cases, but that
// only works for US keyboard layouts. // only works for US keyboard layouts.
var u = undefined;
var s = undefined;
if (event.shiftKey) { if (event.shiftKey) {
var u = undefined;
var s = undefined;
switch (this.lastNormalKeyDownEvent.keyCode) { switch (this.lastNormalKeyDownEvent.keyCode) {
case 39: /* ' -> " */ u = 39; s = 34; break; case 39: /* ' -> " */ u = 39; s = 34; break;
case 44: /* , -> < */ u = 44; s = 60; break; case 44: /* , -> < */ u = 44; s = 60; break;
case 45: /* - -> _ */ u = 45; s = 95; break; case 45: /* - -> _ */ u = 45; s = 95; break;
case 46: /* . -> > */ u = 46; s = 62; break; case 46: /* . -> > */ u = 46; s = 62; break;
case 47: /* / -> ? */ u = 47; s = 63; break; case 47: /* / -> ? */ u = 47; s = 63; break;
case 48: /* 0 -> ) */ u = 48; s = 41; break; case 48: /* 0 -> ) */ u = 48; s = 41; break;
case 49: /* 1 -> ! */ u = 49; s = 33; break; case 49: /* 1 -> ! */ u = 49; s = 33; break;
case 50: /* 2 -> @ */ u = 50; s = 64; break; case 50: /* 2 -> @ */ u = 50; s = 64; break;
skipping to change at line 2955 skipping to change at line 2959
case 189: /* - -> _ */ u = 45; s = 95; break; case 189: /* - -> _ */ u = 45; s = 95; break;
case 190: /* . -> > */ u = 46; s = 62; break; case 190: /* . -> > */ u = 46; s = 62; break;
case 191: /* / -> ? */ u = 47; s = 63; break; case 191: /* / -> ? */ u = 47; s = 63; break;
case 192: /* ` -> ~ */ u = 96; s = 126; break; case 192: /* ` -> ~ */ u = 96; s = 126; break;
case 219: /* [ -> { */ u = 91; s = 123; break; case 219: /* [ -> { */ u = 91; s = 123; break;
case 220: /* \ -> | */ u = 92; s = 124; break; case 220: /* \ -> | */ u = 92; s = 124; break;
case 221: /* ] -> } */ u = 93; s = 125; break; case 221: /* ] -> } */ u = 93; s = 125; break;
case 222: /* ' -> " */ u = 39; s = 34; break; case 222: /* ' -> " */ u = 39; s = 34; break;
default: break; default: break;
} }
if (s && (event.charCode == u || event.charCode == 0)) { } else {
var fake = [ ]; var c = this.lastNormalKeyDownEvent.keyCode;
fake.charCode = s; if (c >= 65 && c <= 90) {
fake.keyCode = event.keyCode; u = c;
fake.ctrlKey = event.ctrlKey; s = u | 32;
fake.shiftKey = event.shiftKey;
fake.altKey = event.altKey;
fake.metaKey = event.metaKey;
return fake;
} }
} }
if (s && (event.charCode == u || event.charCode == 0)) {
var fake = [ ];
fake.charCode = s;
fake.keyCode = event.keyCode;
fake.ctrlKey = event.ctrlKey;
fake.shiftKey = event.shiftKey;
fake.altKey = event.altKey;
fake.metaKey = event.metaKey;
return fake;
}
return event; return event;
}; };
VT100.prototype.keyDown = function(event) { VT100.prototype.keyDown = function(event) {
// this.vt100('D: c=' + event.charCode + ', k=' + event.keyCode + // this.vt100('D: c=' + event.charCode + ', k=' + event.keyCode +
// (event.shiftKey || event.ctrlKey || event.altKey || // (event.shiftKey || event.ctrlKey || event.altKey ||
// event.metaKey ? ', ' + // event.metaKey ? ', ' +
// (event.shiftKey ? 'S' : '') + (event.ctrlKey ? 'C' : '') + // (event.shiftKey ? 'S' : '') + (event.ctrlKey ? 'C' : '') +
// (event.altKey ? 'A' : '') + (event.metaKey ? 'M' : '') : '') + // (event.altKey ? 'A' : '') + (event.metaKey ? 'M' : '') : '') +
// '\r\n'); // '\r\n');
skipping to change at line 3050 skipping to change at line 3060
fake.ctrlKey = event.ctrlKey; fake.ctrlKey = event.ctrlKey;
fake.shiftKey = event.shiftKey; fake.shiftKey = event.shiftKey;
fake.altKey = event.altKey; fake.altKey = event.altKey;
fake.metaKey = event.metaKey; fake.metaKey = event.metaKey;
if (asciiKey) { if (asciiKey) {
fake.charCode = event.keyCode; fake.charCode = event.keyCode;
fake.keyCode = 0; fake.keyCode = 0;
} else { } else {
fake.charCode = 0; fake.charCode = 0;
fake.keyCode = event.keyCode; fake.keyCode = event.keyCode;
if (!alphNumKey && event.shiftKey) {
fake = this.fixEvent(fake);
}
} }
fake = this.fixEvent(fake);
this.handleKey(fake); this.handleKey(fake);
this.lastNormalKeyDownEvent = undefined; this.lastNormalKeyDownEvent = undefined;
try { try {
// For non-IE browsers // For non-IE browsers
event.stopPropagation(); event.stopPropagation();
event.preventDefault(); event.preventDefault();
} catch (e) { } catch (e) {
} }
skipping to change at line 3168 skipping to change at line 3176
fake.ctrlKey = event.ctrlKey; fake.ctrlKey = event.ctrlKey;
fake.shiftKey = event.shiftKey; fake.shiftKey = event.shiftKey;
fake.altKey = event.altKey; fake.altKey = event.altKey;
fake.metaKey = event.metaKey; fake.metaKey = event.metaKey;
if (asciiKey) { if (asciiKey) {
fake.charCode = event.keyCode; fake.charCode = event.keyCode;
fake.keyCode = 0; fake.keyCode = 0;
} else { } else {
fake.charCode = 0; fake.charCode = 0;
fake.keyCode = event.keyCode; fake.keyCode = event.keyCode;
if (!alphNumKey && (event.ctrlKey || event.altKey || event.metaKey)) { }
fake = this.fixEvent(fake); if (event.ctrlKey || event.altKey || event.metaKey) {
} fake = this.fixEvent(fake);
} }
this.lastNormalKeyDownEvent = undefined; this.lastNormalKeyDownEvent = undefined;
this.handleKey(fake); this.handleKey(fake);
} }
} }
try { try {
// For IE // For IE
event.cancelBubble = true; event.cancelBubble = true;
event.returnValue = false; event.returnValue = false;
skipping to change at line 3901 skipping to change at line 3909
this.dispCtrl = true; this.dispCtrl = true;
this.toggleMeta = true; this.toggleMeta = true;
break; break;
case 21: case 21:
case 22: this.attr &= ~(ATTR_BRIGHT|ATTR_DIM); break; case 22: this.attr &= ~(ATTR_BRIGHT|ATTR_DIM); break;
case 24: this.attr &= ~ ATTR_UNDERLINE; break; case 24: this.attr &= ~ ATTR_UNDERLINE; break;
case 25: this.attr &= ~ ATTR_BLINK; break; case 25: this.attr &= ~ ATTR_BLINK; break;
case 27: this.attr &= ~ ATTR_REVERSE; break; case 27: this.attr &= ~ ATTR_REVERSE; break;
case 38: case 38:
if (this.npar >= (i+2) && this.par[i+1] == 5) { if (this.npar >= (i+2) && this.par[i+1] == 5) {
// Foreground color for extended color mode (256 colors). Escape code is formated // Foreground color for extended color mode (256 colors). Escape code is formatted
// as: ESC 38; 5; 0-255. Last parameter is color code in range [0-255]. This is // as: ESC 38; 5; 0-255. Last parameter is color code in range [0-255]. This is
// not VT100 standard. // not VT100 standard.
this.attrFg = (this.par[i+2] >= 0 && this.par[i+2] <= 255) ? this.pa r[i+2] : false; this.attrFg = (this.par[i+2] >= 0 && this.par[i+2] <= 255) ? this.pa r[i+2] : false;
i += 2; i += 2;
} else { } else {
// Default VT100 behaviour. // Default VT100 behaviour.
this.attr = (this.attr & ~(ATTR_DIM|ATTR_BRIGHT|0x0F))|ATTR_UNDERL INE | ATTR_DEF_FG; this.attr = (this.attr & ~(ATTR_DIM|ATTR_BRIGHT|0x0F))|ATTR_UNDERL INE | ATTR_DEF_FG;
} }
break; break;
case 39: case 39:
this.attr = (this.attr & ~(ATTR_DIM|ATTR_BRIGHT|ATTR_UNDERLINE|0x0 F)) | ATTR_DEF_FG; this.attr = (this.attr & ~(ATTR_DIM|ATTR_BRIGHT|ATTR_UNDERLINE|0x0 F)) | ATTR_DEF_FG;
this.attrFg = false; this.attrFg = false;
break; break;
case 48: case 48:
if (this.npar >= (i+2) && this.par[i+1] == 5) { if (this.npar >= (i+2) && this.par[i+1] == 5) {
// Background color for extended color mode (256 colors). Escape code is formated // Background color for extended color mode (256 colors). Escape code is formatted
// as: ESC 48; 5; 0-255. Last parameter is color code in range [0-255]. This is // as: ESC 48; 5; 0-255. Last parameter is color code in range [0-255]. This is
// not VT100 standard. // not VT100 standard.
this.attrBg = (this.par[i+2] >= 0 && this.par[i+2] <= 255) ? this.pa r[i+2] : false; this.attrBg = (this.par[i+2] >= 0 && this.par[i+2] <= 255) ? this.pa r[i+2] : false;
i += 2; i += 2;
} }
break; break;
case 49: case 49:
this.attr |= (0xF0|ATTR_DEF_BG); this.attr |= (0xF0|ATTR_DEF_BG);
this.attrBg = false; this.attrBg = false;
break; break;
skipping to change at line 4047 skipping to change at line 4055
/*c*/ case 0x63: this.reset(); break; /*c*/ case 0x63: this.reset(); break;
/*g*/ case 0x67: this.flashScreen(); break; /*g*/ case 0x67: this.flashScreen(); break;
default: break; default: break;
} }
break; break;
case ESnonstd: case ESnonstd:
switch (ch) { switch (ch) {
/*0*/ case 0x30: /*0*/ case 0x30:
/*1*/ case 0x31: /*1*/ case 0x31:
/*2*/ case 0x32: this.isEsc = EStitle; this.titleString = ''; break; /*2*/ case 0x32: this.isEsc = EStitle; this.titleString = ''; break;
/*6*/ case 0x36: this.isEsc = ESVTEtitle; break;
/*7*/ case 0x37: this.isEsc = ESVTEtitle; break;
/*P*/ case 0x50: this.npar = 0; this.par = [ 0, 0, 0, 0, 0, 0, 0 ]; /*P*/ case 0x50: this.npar = 0; this.par = [ 0, 0, 0, 0, 0, 0, 0 ];
this.isEsc = ESpalette; break; this.isEsc = ESpalette; break;
/*R*/ case 0x52: // Palette support is not implemented /*R*/ case 0x52: // Palette support is not implemented
this.isEsc = ESnormal; break; this.isEsc = ESnormal; break;
default: this.isEsc = ESnormal; break; default: this.isEsc = ESnormal; break;
} }
break; break;
case ESpalette: case ESpalette:
if ((ch >= 0x30 /*0*/ && ch <= 0x39 /*9*/) || if ((ch >= 0x30 /*0*/ && ch <= 0x39 /*9*/) ||
(ch >= 0x41 /*A*/ && ch <= 0x46 /*F*/) || (ch >= 0x41 /*A*/ && ch <= 0x46 /*F*/) ||
skipping to change at line 4274 skipping to change at line 4284
[this.toggleMeta ? (ch | 0x80) : ch]; [this.toggleMeta ? (ch | 0x80) : ch];
if ((ch & 0xFF00) == 0xF000) { if ((ch & 0xFF00) == 0xF000) {
ch = ch & 0xFF; ch = ch & 0xFF;
} else if (ch == 0xFEFF || (ch >= 0x200A && ch <= 0x200F)) { } else if (ch == 0xFEFF || (ch >= 0x200A && ch <= 0x200F)) {
this.isEsc = ESnormal; break; this.isEsc = ESnormal; break;
} }
} }
this.lastCharacter = String.fromCharCode(ch); this.lastCharacter = String.fromCharCode(ch);
lineBuf += this.lastCharacter; lineBuf += this.lastCharacter;
this.isEsc = ESnormal; break; this.isEsc = ESnormal; break;
case ESVTEtitle:
// Ignores VTE escape sequences for current directory (OSC6) and current
// file (OSC7).
if (ch == 0x07 || ch == 0x5C) {
this.isEsc = ESnormal;
}
break;
default: default:
this.isEsc = ESnormal; break; this.isEsc = ESnormal; break;
} }
break; break;
} }
return lineBuf; return lineBuf;
}; };
VT100.prototype.renderString = function(s, showCursor) { VT100.prototype.renderString = function(s, showCursor) {
if (this.printing) { if (this.printing) {
 End of changes. 14 change blocks. 
22 lines changed or deleted 40 lines changed or added

Home  |  About  |  All  |  Newest  |  Fossies Dox  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTPS