Skip to content
Snippets Groups Projects
Commit f7a1e3e8 authored by deuce's avatar deuce
Browse files

Move common ANSI generation into ansi_console which is now load()ed from

jsexec_console and socket_console to avoid copy pasta.

Use 0/0 origin for all things.  Just because ANSI uses 1/1 origin doesn't
mean we have to.
parent 9152dd38
No related branches found
No related tags found
No related merge requests found
......@@ -486,7 +486,7 @@ Graphic.prototype.draw = function(xpos,ypos,width,height,xoff,yoff)
alert("Attempt to draw from outside of graphic: "+xoff+":"+yoff+" "+width+"x"+height+" "+this.width+"x"+this.height);
return(false);
}
if(xpos+width-1 > dk.console.cols || ypos+height-1 > dk.console.rows) {
if(xpos+width > dk.console.cols || ypos+height > dk.console.rows) {
alert("Attempt to draw outside of screen: " + (xpos+width-1) + "x" + (ypos+height-1));
return(false);
}
......
/*
* Clears the current screen and moves to location 1,1
*/
load("ansi_console.js");
dk.console.remote_io = {
clear:function() {
this.print("\x1b[2J\x1b[1;1H");
},
/*
* Clears to end of line.
* Not available witout ANSI (???)
*/
cleareol:function() {
if(dk.console.ansi)
this.print('\x1b[K');
},
/*
* Moves the cursor to the specified position.
* returns false on error.
* Not available without ANSI
*/
gotoxy:function(x,y) {
if(dk.console.ansi)
this.print(format("\x1b[%u;%uH", y, x));
},
/*
* Writes a string unmodified.
*/
print:function(string) {
write(string);
},
dk.console.remote_io.print = function(string) {
write(string);
};
var input_queue = load(true, "jsexec_input.js");
js.on_exit("input_queue.write(''); input_queue.poll(0x7fffffff);");
......@@ -27,7 +27,7 @@ dk.console.remote_io = {
* Not available without ANSI
*/
gotoxy:function(x,y) {
console.gotoxy(x,y);
console.gotoxy(x+1,y+1);
},
/*
......
/*
* Clears the current screen to black and moves to location 1,1
*/
load("ansi_console.js");
dk.console.remote_io = {
sock:new Socket(true, dk.connection.socket),
clear:function() {
this.print("\x0c");
},
/*
* Clears to end of line.
* Not available witout ANSI (???)
*/
cleareol:function() {
if(dk.console.ansi)
this.print('\x1b[K');
},
/*
* Moves the cursor to the specified position.
* returns false on error.
* Not available without ANSI
*/
gotoxy:function(x,y) {
if(dk.console.ansi)
this.print(format("\x1b[%u;%uH", y, x));
},
/*
* Writes a string unmodified.
*/
print:function(string) {
this.sock.write(string.replace(/\xff/g, "\xff\xff"));
},
};
dk.console.remote_io.sock = new Socket(true, dk.connection.socket);
if (!dk.console.remote_io.sock.is_connected)
throw("Unable to create socket object");
var input_queue = load(true, "socket_input.js", argv[0], argv[1]);
js.on_exit("input_queue.write(''); input_queue.poll(0x7fffffff);");
dk.console.remote_io.print = function(string) {
this.sock.write(string.replace(/\xff/g, "\xff\xff"));
};
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment