correction of [x;yH ANSI code

This commit is contained in:
overflowerror 2013-07-20 21:58:19 +02:00
parent 8fb7da7044
commit 0dd143053a
4 changed files with 20 additions and 16 deletions

View file

@ -51,7 +51,7 @@ Emulator.kill = function() {
Emulator.shutdown = function() { Emulator.shutdown = function() {
Emulator.running = false; Emulator.running = false;
Emulator.startable = true; Emulator.startable = true;
Emulator.output("\033[0m\033[2J\033[0:0H"); Emulator.output("\033[0m\033[2J\033[0;0H");
Emulator.Output.cursorOff() Emulator.Output.cursorOff()
} }
Emulator.addEventHandlers = function() { Emulator.addEventHandlers = function() {
@ -158,7 +158,7 @@ Emulator.ANSISequences.output = function(text) {
break; break;
} }
if (specialText.length < 1) { if (specialText.length < 1) {
normalText += " [" + ((specialText2.length > 0) ? (specialText2 + ":") : "") + specialText; normalText += " [" + ((specialText2.length > 0) ? (specialText2 + ";") : "") + specialText;
state = 0; state = 0;
break; break;
} }
@ -238,7 +238,7 @@ Emulator.ANSISequences.output = function(text) {
specialText2 = ""; specialText2 = "";
state = 0; state = 0;
break; break;
case ':': case ';':
// TODO Wrong! // TODO Wrong!
specialText2 = specialText; specialText2 = specialText;
specialText = ""; specialText = "";
@ -306,7 +306,7 @@ Emulator.ANSISequences.output = function(text) {
Emulator.Output.cursorOn(); Emulator.Output.cursorOn();
break; break;
default: default:
normalText = " [" + ((specialText2.length > 0) ? (specialText2 + ":") : "") + specialText; normalText = " [" + ((specialText2.length > 0) ? (specialText2 + ";") : "") + specialText;
break; break;
} }
specialText = ""; specialText = "";
@ -377,7 +377,7 @@ Emulator.ANSISequences.output = function(text) {
Emulator.Output.backgroundColor = "#fff"; Emulator.Output.backgroundColor = "#fff";
break; break;
default: default:
normalText += " [" + ((specialText2.length > 0) ? (specialText2 + ":") : "") + specialText; normalText += " [" + ((specialText2.length > 0) ? (specialText2 + ";") : "") + specialText;
state = 0; state = 0;
break; break;
} }
@ -386,7 +386,7 @@ Emulator.ANSISequences.output = function(text) {
state = 0; state = 0;
break; break;
default: default:
normalText += " [" + ((specialText2.length > 0) ? (specialText2 + ":") : "") + specialText; normalText += " [" + ((specialText2.length > 0) ? (specialText2 + ";") : "") + specialText;
state = 0; state = 0;
break; break;
} }
@ -426,7 +426,7 @@ Emulator.ANSISequences.output = function(text) {
} }
} }
if ((specialText2.length || specialText.length) > 0) if ((specialText2.length || specialText.length) > 0)
normalText += " [" + ((specialText2.length > 0) ? (specialText2 + ":") : "") + specialText; normalText += " [" + ((specialText2.length > 0) ? (specialText2 + ";") : "") + specialText;
Emulator.Output.normalOutput(normalText); Emulator.Output.normalOutput(normalText);
} }

View file

@ -26,7 +26,7 @@ Loader.main = function(device) {
console.log("Loader: register key interrupt"); console.log("Loader: register key interrupt");
Emulator.interrupts['key'] = Loader.key; Emulator.interrupts['key'] = Loader.key;
Loader.device = device; Loader.device = device;
var text = "\033[2J\033[0:0H\033[?25l" + Loader.logo + "\033[s"; var text = "\033[2J\033[0;0H\033[?25l" + Loader.logo + "\033[s";
Emulator.output(text); Emulator.output(text);
Loader.state = 0; Loader.state = 0;
} }

View file

@ -49,7 +49,7 @@ Kernel.machine = function() {
switch(Kernel.state) { switch(Kernel.state) {
case 0: case 0:
Emulator.Output.shiftKey = OS.staticShift; Emulator.Output.shiftKey = OS.staticShift;
Emulator.output("\033[2J\033[0:0H" + OS.logo); Emulator.output("\033[2J\033[0;0H" + OS.logo);
Kernel.msgOut("reseting kernel timer", true); Kernel.msgOut("reseting kernel timer", true);
Kernel.time = 0; Kernel.time = 0;
Kernel.msgOut("register main timer (100ms)", true); // pre Kernel.msgOut("register main timer (100ms)", true); // pre
@ -356,22 +356,26 @@ Kernel.Filesystem.update = function(path) {
Kernel.Filesystem.files[path] = file; Kernel.Filesystem.files[path] = file;
return file; return file;
} }
Kernel.Filesystem.getRealPath = function(name) { Kernel.Filesystem.shortenPath = function(name) {
var index; var index;
while ((index = name.indexOf("/../")) != -1) { while ((index = name.indexOf("/../")) != -1) {
name = name.replace("/../", "/"); name = name.replace("/../", "/");
var index2 = 0; var index2 = 0;
var index3 = 0; var index3 = -1;
while(index2 < index) { while(index2 < index) {
index3 = index2; index3 = index2;
index2 = name.indexOf("/", index3); index2 = name.indexOf("/", index3 + 1);
} }
if (!index3) if (index3 == -1)
return undefined; return undefined;
name = name.substring(index3, index); name = name.substring(0, index3) + name.substring(index);
} }
while ((index = name.indexOf("/./")) != -1) while ((index = name.indexOf("/./")) != -1)
name = name.replace("/./", "/"); name = name.replace("/./", "/");
return name;
}
Kernel.Filesystem.getRealPath = function(name) {
name = Kernel.Filesystem.shortenPath(name);
return Kernel.Filesystem.root + name; return Kernel.Filesystem.root + name;
} }
Kernel.Filesystem.addTTY = function(path, output, input) { Kernel.Filesystem.addTTY = function(path, output, input) {
@ -411,7 +415,7 @@ Kernel.Filesystem.getDirectory = function(path) {
response = JSON.parse(response); response = JSON.parse(response);
if (response.error) { if (response.error) {
console.log("Kernel: error on reading: " + response.error); console.log("Kernel: error on reading: " + response.error);
return response.error; return response;
} }
return response; return response;

View file

@ -20,7 +20,7 @@ LoginClass.prototype.tick = function() {
var stdin = this.files['stdin']; var stdin = this.files['stdin'];
switch(this.state) { switch(this.state) {
case 0: case 0:
stdout.write("\033[?25h\033[0:0H"); stdout.write("\033[?25h\033[0;0H");
if (OS.staticShift) if (OS.staticShift)
stdout.write("\033[0:" + (OS.staticShift - 1) + "H"); stdout.write("\033[0:" + (OS.staticShift - 1) + "H");
stdout.write("\033[0J"); stdout.write("\033[0J");