mirror of
https://github.com/sigmasternchen/webcli
synced 2025-03-15 22:28:54 +00:00
some errors
This commit is contained in:
parent
863b9e2ded
commit
3dc3a68ba9
1 changed files with 94 additions and 8 deletions
|
@ -1,8 +1,8 @@
|
||||||
const TERM_X_MIN = 60;
|
const TERM_X_MIN = 60;
|
||||||
const TERM_Y_MIN = 10;
|
const TERM_Y_MIN = 10;
|
||||||
// the following 2 values are empirical determined in chromium
|
// the following 2 values are empirical determined in chromium
|
||||||
const TERM_CELL_HEIGHT = 24;
|
const TERM_CELL_HEIGHT = 16;
|
||||||
const TERM_CELL_WIDTH = 10;
|
const TERM_CELL_WIDTH = 8;
|
||||||
|
|
||||||
const ANSI_NO = 0;
|
const ANSI_NO = 0;
|
||||||
const ANSI_ESC = 1;
|
const ANSI_ESC = 1;
|
||||||
|
@ -22,6 +22,8 @@ const ANSI_EL = 14;
|
||||||
const ANSI_SCP = 15;
|
const ANSI_SCP = 15;
|
||||||
const ANSI_RCP = 16;
|
const ANSI_RCP = 16;
|
||||||
const ANSI_DECTCEM = 17;
|
const ANSI_DECTCEM = 17;
|
||||||
|
const ANSI_DSR = 18;
|
||||||
|
const ANSI_SGR = 19;
|
||||||
|
|
||||||
var Terminal = function() {
|
var Terminal = function() {
|
||||||
}
|
}
|
||||||
|
@ -80,11 +82,11 @@ Terminal.prototype.tick = function() {
|
||||||
|
|
||||||
}
|
}
|
||||||
Terminal.prototype.globalLineFeed = function() {
|
Terminal.prototype.globalLineFeed = function() {
|
||||||
for (var i = this.staticNoShift; i < this.ySize; i++) {
|
for (var i = this.staticNoShift + 1; i < this.ySize; i++) {
|
||||||
for (var j = 0; j < this.xSize; j++) {
|
for (var j = 0; j < this.xSize; j++) {
|
||||||
var to = document.getElementsByClassName((i - 1) + "c" + j)[0];
|
var to = document.getElementsByClassName((i - 1) + "c" + j)[0];
|
||||||
var from = document.getElementsByClassName(i + "c" + j)[0];
|
var from = document.getElementsByClassName(i + "c" + j)[0];
|
||||||
to.innerHTML = form.innerHTML;
|
to.innerHTML = from.innerHTML;
|
||||||
to.style.color = from.style.color;
|
to.style.color = from.style.color;
|
||||||
to.style.fontWeight = from.style.fontWeight;
|
to.style.fontWeight = from.style.fontWeight;
|
||||||
to.style.backgroundColor = from.style.backgroundColor;
|
to.style.backgroundColor = from.style.backgroundColor;
|
||||||
|
@ -162,7 +164,7 @@ Terminal.prototype.output = function(text) {
|
||||||
if (text[i] == "\033")
|
if (text[i] == "\033")
|
||||||
state = ANSI_ESC; // maybe a ANSI-sequence
|
state = ANSI_ESC; // maybe a ANSI-sequence
|
||||||
else
|
else
|
||||||
this.normalOutputChar(text.charAt(i));
|
this.normalOutputChar(text[i]);
|
||||||
break;
|
break;
|
||||||
case ANSI_ESC:
|
case ANSI_ESC:
|
||||||
if (text[i] == "[")
|
if (text[i] == "[")
|
||||||
|
@ -184,10 +186,12 @@ Terminal.prototype.output = function(text) {
|
||||||
}
|
}
|
||||||
if (param1.length > 0) {
|
if (param1.length > 0) {
|
||||||
state = ANSI_CSI3;
|
state = ANSI_CSI3;
|
||||||
|
i--;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (text[i] == "?") {
|
if (text[i] == "?") {
|
||||||
state = ANSI_DECTCEM;
|
state = ANSI_DECTCEM;
|
||||||
|
i--;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (text[i] == "s") {
|
if (text[i] == "s") {
|
||||||
|
@ -258,6 +262,12 @@ Terminal.prototype.output = function(text) {
|
||||||
case "K":
|
case "K":
|
||||||
state = ANSI_EL;
|
state = ANSI_EL;
|
||||||
break;
|
break;
|
||||||
|
case "m":
|
||||||
|
state = ANSI_SGR;
|
||||||
|
break;
|
||||||
|
case "n":
|
||||||
|
state = ANSI_DSR;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
state = ANSI_NO;
|
state = ANSI_NO;
|
||||||
this.normalOutput("\033[" + param1 + tmp + param2 + text[++i]);
|
this.normalOutput("\033[" + param1 + tmp + param2 + text[++i]);
|
||||||
|
@ -540,21 +550,97 @@ Terminal.prototype.output = function(text) {
|
||||||
this.yPosition = this.yPositionSaved;
|
this.yPosition = this.yPositionSaved;
|
||||||
break;
|
break;
|
||||||
case ANSI_DECTCEM:
|
case ANSI_DECTCEM:
|
||||||
if (tmp.length < 3)
|
tmp += text[i];
|
||||||
|
if (tmp.length < 4)
|
||||||
break;
|
break;
|
||||||
if (tmp == "25l") {
|
if (tmp == "?25l") {
|
||||||
this.displayCursor = false;
|
this.displayCursor = false;
|
||||||
tmp = "";
|
tmp = "";
|
||||||
state = ANSI_NO;
|
state = ANSI_NO;
|
||||||
}
|
}
|
||||||
if (tmp == "25h") {
|
if (tmp == "?25h") {
|
||||||
this.displayCursor = true;
|
this.displayCursor = true;
|
||||||
tmp = "";
|
tmp = "";
|
||||||
state = ANSI_NO;
|
state = ANSI_NO;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case ANSI_SGR:
|
||||||
|
if (tmp != "") {
|
||||||
|
state = ANSI_NO;
|
||||||
|
this.normalOutput("\033[" + param1 + tmp + param2 + text[i]);
|
||||||
|
param1 = "";
|
||||||
|
param2 = "";
|
||||||
|
tmp = "";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
switch(param1) {
|
||||||
|
case "0":
|
||||||
|
this.color = "white";
|
||||||
|
this.backgroundColor = "black";
|
||||||
|
this.bold = false;
|
||||||
|
break;
|
||||||
|
case "1":
|
||||||
|
this.bold = true;
|
||||||
|
break;
|
||||||
|
case "30":
|
||||||
|
this.color = "black";
|
||||||
|
break;
|
||||||
|
case "31":
|
||||||
|
this.color = "red";
|
||||||
|
break;
|
||||||
|
case "32":
|
||||||
|
this.color = "green";
|
||||||
|
break;
|
||||||
|
case "33":
|
||||||
|
this.color = "yellow";
|
||||||
|
break;
|
||||||
|
case "34":
|
||||||
|
this.color = "blue";
|
||||||
|
break;
|
||||||
|
case "35":
|
||||||
|
this.color = "magenta";
|
||||||
|
break;
|
||||||
|
case "36":
|
||||||
|
this.color = "cyan";
|
||||||
|
break;
|
||||||
|
case "37":
|
||||||
|
this.color = "white";
|
||||||
|
break;
|
||||||
|
case "40":
|
||||||
|
this.backgroundColor = "black";
|
||||||
|
break;
|
||||||
|
case "41":
|
||||||
|
this.backgroundColor = "red";
|
||||||
|
break;
|
||||||
|
case "42":
|
||||||
|
this.backgroundColor = "green";
|
||||||
|
break;
|
||||||
|
case "43":
|
||||||
|
this.backgroundColor = "yellow";
|
||||||
|
break;
|
||||||
|
case "44":
|
||||||
|
this.backgroundColor = "blue";
|
||||||
|
break;
|
||||||
|
case "45":
|
||||||
|
this.backgroundColor = "magenta";
|
||||||
|
break;
|
||||||
|
case "46":
|
||||||
|
this.backgroundColor = "cyan";
|
||||||
|
break;
|
||||||
|
case "47":
|
||||||
|
this.backgroundColor = "white";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
this.normalOutput("\033[" + param1 + tmp + param2 + text[i]);
|
||||||
|
}
|
||||||
|
state = ANSI_NO;
|
||||||
|
param1 = "";
|
||||||
|
param2 = "";
|
||||||
|
tmp = "";
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
console.log(state);
|
||||||
if (tmp.length || param1.length || param2.length)
|
if (tmp.length || param1.length || param2.length)
|
||||||
this.normalOutput("\033[" + param1 + tmp + param2);
|
this.normalOutput("\033[" + param1 + tmp + param2);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue