Write the OSC title to the window's title instead of the status bar.

Most modern browsers no longer have status bars. Additionally,
using the window's title makes it seem more like a conventional
terminal application.
This commit is contained in:
Jay Weisskopf 2011-12-31 19:46:44 -06:00 committed by Marc Singer
parent 4ce287e217
commit a0fac8a8db
3 changed files with 39 additions and 27 deletions

View file

@ -80,7 +80,7 @@
// #define ESignore 14 // #define ESignore 14
// #define ESnonstd 15 // #define ESnonstd 15
// #define ESpalette 16 // #define ESpalette 16
// #define ESstatus 17 // #define EStitle 17
// #define ESss2 18 // #define ESss2 18
// #define ESss3 19 // #define ESss3 19
@ -187,7 +187,7 @@ function VT100(container) {
this.CodePage437Map, this.DirectToFontMap ]; this.CodePage437Map, this.DirectToFontMap ];
this.savedValid = [ ]; this.savedValid = [ ];
this.respondString = ''; this.respondString = '';
this.statusString = ''; this.titleString = '';
this.internalClipboard = undefined; this.internalClipboard = undefined;
this.reset(true); this.reset(true);
} }
@ -3846,7 +3846,7 @@ VT100.prototype.doControl = function(ch) {
case 0x8F: this.isEsc = 19 /* ESss3 */; break; case 0x8F: this.isEsc = 19 /* ESss3 */; break;
case 0x9A: this.respondID(); break; case 0x9A: this.respondID(); break;
case 0x9B: this.isEsc = 2 /* ESsquare */; break; case 0x9B: this.isEsc = 2 /* ESsquare */; break;
case 0x07: if (this.isEsc != 17 /* ESstatus */) { case 0x07: if (this.isEsc != 17 /* EStitle */) {
this.beep(); break; this.beep(); break;
} }
/* fall thru */ /* fall thru */
@ -3885,7 +3885,7 @@ VT100.prototype.doControl = function(ch) {
switch (ch) { switch (ch) {
/*0*/ case 0x30: /*0*/ case 0x30:
/*1*/ case 0x31: /*1*/ case 0x31:
/*2*/ case 0x32: this.statusString = ''; this.isEsc = 17 /* ESstatus */; break; /*2*/ case 0x32: this.isEsc = 17 /* EStitle */; this.titleString = ''; 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 = 16 /* ESpalette */; break; this.isEsc = 16 /* ESpalette */; break;
/*R*/ case 0x52: // Palette support is not implemented /*R*/ case 0x52: // Palette support is not implemented
@ -4081,18 +4081,22 @@ VT100.prototype.doControl = function(ch) {
this.translate = this.GMap[g]; this.translate = this.GMap[g];
} }
break; break;
case 17 /* ESstatus */: case 17 /* EStitle */:
if (ch == 0x07) { if (ch == 0x07) {
if (this.statusString && this.statusString.charAt(0) == ';') { if (this.titleString && this.titleString.charAt(0) == ';') {
this.statusString = this.statusString.substr(1); this.titleString = this.titleString.substr(1);
if (this.titleString != '') {
this.titleString += ' - ';
}
this.titleString += 'Shell In A Box'
} }
try { try {
window.status = this.statusString; window.document.title = this.titleString;
} catch (e) { } catch (e) {
} }
this.isEsc = 0 /* ESnormal */; this.isEsc = 0 /* ESnormal */;
} else { } else {
this.statusString += String.fromCharCode(ch); this.titleString += String.fromCharCode(ch);
} }
break; break;
case 18 /* ESss2 */: case 18 /* ESss2 */:

View file

@ -80,7 +80,7 @@
// #define ESignore 14 // #define ESignore 14
// #define ESnonstd 15 // #define ESnonstd 15
// #define ESpalette 16 // #define ESpalette 16
// #define ESstatus 17 // #define EStitle 17
// #define ESss2 18 // #define ESss2 18
// #define ESss3 19 // #define ESss3 19
@ -187,7 +187,7 @@ function VT100(container) {
this.CodePage437Map, this.DirectToFontMap ]; this.CodePage437Map, this.DirectToFontMap ];
this.savedValid = [ ]; this.savedValid = [ ];
this.respondString = ''; this.respondString = '';
this.statusString = ''; this.titleString = '';
this.internalClipboard = undefined; this.internalClipboard = undefined;
this.reset(true); this.reset(true);
} }
@ -3846,7 +3846,7 @@ VT100.prototype.doControl = function(ch) {
case 0x8F: this.isEsc = 19 /* ESss3 */; break; case 0x8F: this.isEsc = 19 /* ESss3 */; break;
case 0x9A: this.respondID(); break; case 0x9A: this.respondID(); break;
case 0x9B: this.isEsc = 2 /* ESsquare */; break; case 0x9B: this.isEsc = 2 /* ESsquare */; break;
case 0x07: if (this.isEsc != 17 /* ESstatus */) { case 0x07: if (this.isEsc != 17 /* EStitle */) {
this.beep(); break; this.beep(); break;
} }
/* fall thru */ /* fall thru */
@ -3885,7 +3885,7 @@ VT100.prototype.doControl = function(ch) {
switch (ch) { switch (ch) {
/*0*/ case 0x30: /*0*/ case 0x30:
/*1*/ case 0x31: /*1*/ case 0x31:
/*2*/ case 0x32: this.statusString = ''; this.isEsc = 17 /* ESstatus */; break; /*2*/ case 0x32: this.isEsc = 17 /* EStitle */; this.titleString = ''; 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 = 16 /* ESpalette */; break; this.isEsc = 16 /* ESpalette */; break;
/*R*/ case 0x52: // Palette support is not implemented /*R*/ case 0x52: // Palette support is not implemented
@ -4081,18 +4081,22 @@ VT100.prototype.doControl = function(ch) {
this.translate = this.GMap[g]; this.translate = this.GMap[g];
} }
break; break;
case 17 /* ESstatus */: case 17 /* EStitle */:
if (ch == 0x07) { if (ch == 0x07) {
if (this.statusString && this.statusString.charAt(0) == ';') { if (this.titleString && this.titleString.charAt(0) == ';') {
this.statusString = this.statusString.substr(1); this.titleString = this.titleString.substr(1);
if (this.titleString != '') {
this.titleString += ' - ';
}
this.titleString += 'Shell In A Box'
} }
try { try {
window.status = this.statusString; window.document.title = this.titleString;
} catch (e) { } catch (e) {
} }
this.isEsc = 0 /* ESnormal */; this.isEsc = 0 /* ESnormal */;
} else { } else {
this.statusString += String.fromCharCode(ch); this.titleString += String.fromCharCode(ch);
} }
break; break;
case 18 /* ESss2 */: case 18 /* ESss2 */:

22
shellinabox/vt100.jspp Normal file → Executable file
View file

@ -80,7 +80,7 @@
#define ESignore 14 #define ESignore 14
#define ESnonstd 15 #define ESnonstd 15
#define ESpalette 16 #define ESpalette 16
#define ESstatus 17 #define EStitle 17
#define ESss2 18 #define ESss2 18
#define ESss3 19 #define ESss3 19
@ -187,7 +187,7 @@ function VT100(container) {
this.CodePage437Map, this.DirectToFontMap ]; this.CodePage437Map, this.DirectToFontMap ];
this.savedValid = [ ]; this.savedValid = [ ];
this.respondString = ''; this.respondString = '';
this.statusString = ''; this.titleString = '';
this.internalClipboard = undefined; this.internalClipboard = undefined;
this.reset(true); this.reset(true);
} }
@ -3846,7 +3846,7 @@ VT100.prototype.doControl = function(ch) {
case 0x8F: this.isEsc = ESss3; break; case 0x8F: this.isEsc = ESss3; break;
case 0x9A: this.respondID(); break; case 0x9A: this.respondID(); break;
case 0x9B: this.isEsc = ESsquare; break; case 0x9B: this.isEsc = ESsquare; break;
case 0x07: if (this.isEsc != ESstatus) { case 0x07: if (this.isEsc != EStitle) {
this.beep(); break; this.beep(); break;
} }
/* fall thru */ /* fall thru */
@ -3885,7 +3885,7 @@ VT100.prototype.doControl = function(ch) {
switch (ch) { switch (ch) {
/*0*/ case 0x30: /*0*/ case 0x30:
/*1*/ case 0x31: /*1*/ case 0x31:
/*2*/ case 0x32: this.statusString = ''; this.isEsc = ESstatus; break; /*2*/ case 0x32: this.isEsc = EStitle; this.titleString = ''; 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
@ -4081,18 +4081,22 @@ VT100.prototype.doControl = function(ch) {
this.translate = this.GMap[g]; this.translate = this.GMap[g];
} }
break; break;
case ESstatus: case EStitle:
if (ch == 0x07) { if (ch == 0x07) {
if (this.statusString && this.statusString.charAt(0) == ';') { if (this.titleString && this.titleString.charAt(0) == ';') {
this.statusString = this.statusString.substr(1); this.titleString = this.titleString.substr(1);
if (this.titleString != '') {
this.titleString += ' - ';
}
this.titleString += 'Shell In A Box'
} }
try { try {
window.status = this.statusString; window.document.title = this.titleString;
} catch (e) { } catch (e) {
} }
this.isEsc = ESnormal; this.isEsc = ESnormal;
} else { } else {
this.statusString += String.fromCharCode(ch); this.titleString += String.fromCharCode(ch);
} }
break; break;
case ESss2: case ESss2: