-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathicconsole.jn
More file actions
95 lines (78 loc) · 3.12 KB
/
icconsole.jn
File metadata and controls
95 lines (78 loc) · 3.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
// LICENSE: GPL v.3 or later (C) 2010 Andrew Gryaznov realgrandrew@gmail.com, a.gryaznov@svoyaset.ru
/*
iclib: ic# console - compatibility library
parts:
iclib/run - methods to launch programs
iclib/closebox - draw a 'close button box' around the launched program
*/
object.ipc["__ic_main"] = function(rq, argv) {
// execute main thread in blocking mode; destroy instance after that DOC
delete object.ipc["__ic_main"]; // hence only one single IPC allowed; race conditions may still occur but are not taken into account
if(!main(argv)) object.destroy();
// TODO: detach DOM first
// or it will be deleted with object destroy!
// a little messy here' but should work -> deleting ourself actually before returning the value
}
function printDOM( txt ) {
var x = document.createElement("DIV");
x.style.display = "inline";
x.style.fontFamily = "courier";
var t = document.createTextNode(txt);
x.appendChild(t);
document.body.appendChild(x);
window.scrollTo(0,1000000);
}
function preDOM( txt ) {
var x = document.createElement("PRE");
var t = document.createTextNode(txt);
x.appendChild(t);
document.body.appendChild(x);
window.scrollTo(0,1000000);
}
function brDOM() {
var x = document.createElement("DIV");
document.body.appendChild(x);
window.scrollTo(0,1000000);
}
function inputDOM(txt) {
var x = document.createElement("DIV");
x.style.display = "inline";
x.style.fontFamily = "courier";
x.contentEditable = true;
var t = document.createTextNode(txt);
x.appendChild(t);
document.body.appendChild(x);
x.focus();
do {
e = x.waitEvent("keypress"); // will temporarily bind an event to the node and wait for it (bind_dom method)
// this should be used with caution: there is no event queue for the object and it may miss some events
} while (e.keyCode != 13)
x.contentEditable = false;
return x.innerHTML;
}
function editDOM(text) {
// var text = text || "";
if(typeof text == "undefined") text = "";
var x = document.createElement("PRE");
//x.style.display = "inline"; // only BLOCKed elements support innerText
x.style.fontFamily = "courier";
x.contentEditable = true;
//var t = document.createTextNode(text);
//x.appendChild(t);
x.textContent=text;
document.body.appendChild(x);
x.focus();
do {
e = x.waitEvent("keydown"); // will temporarily bind an event to the node and wait for it (bind_dom method)
// this should be used with caution: there is no event queue for the object and it may miss some events
} while ( !( e.keyCode == 13 && e.ctrlKey == true) )
x.contentEditable=false;
var s = x.innerHTML;
s = s.replace(/<br>|<\/p>/g, "\n"); // no other tags are allowed
s = s.replace(/>/g, ">"); // no other special chars allowed
s = s.replace(/</g, "<");
s = s.replace(/ |<p>/g, " "); // TABs are auto converted to nbsp's at least in FF
s = s.replace(/&/g, "&");
return s;
}
initIPCLock.release();// = false; // XXX