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

Add jsexec support. This is likely problematical on Win32, since you can't

select() a file on that OS.  Also, opening the "CON" file may not do what
I expect.
parent ec89b19e
Branches
Tags
No related merge requests found
/*
* Clears the current screen to black and moves to location 1,1
* sets the current attribute to 7
*/
dk.console.remote_io = {
clear:function() {
this.attr.value=7;
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) {
write(string);
},
};
var input_queue = load(true, "jsexec_input.js");
js.on_exit("input_queue.write(''); input_queue.poll(0x7fffffff);");
js.load_path_list.unshift(js.exec_dir+"/dorkit/");
js.load_path_list.unshift(system.exec_dir+"/dorkit/");
load('ansi_input.js');
var q = new Queue("dorkit_input");
var k;
var f;
if(system.platform == 'Win32') {
f = new File('CON');
if(!f.open('rb', false, 0))
throw("Unable to open CON device!");
}
else {
f = new File('/dev/stdin');
if(!f.open('rb', false, 0))
throw("Unable to open /dev/stdin!");
}
while(!js.terminated) {
if (parent_queue.poll(0))
break;
// Can't select() files on Win32.
if(system.platform == 'Win32') {
k = f.read(1);
}
else {
k = undefined;
if (socket_select([f.descriptor], 0.1).length == 1)
k = f.read(1);
}
if (k != undefined && k.length)
ai.add(k);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment