aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJukka Jylänki <jujjyl@gmail.com>2014-04-10 16:02:20 +0300
committerJukka Jylänki <jujjyl@gmail.com>2014-04-10 16:02:20 +0300
commit577f405c425e131600180611c04efd95032f58f6 (patch)
tree5d2991731a51bb1651efb123745b19ae4c2b15d1
parent022873c12ec07fab6fbd72d04f7a2616b8f0abc9 (diff)
In default-provided shells, make standard C stdout always print out to console.log(), and C stderr print out to console.error(). Make the presence of a html page output textbox optional. These changes make the default shells more friendly for Firefox for Android and Firefox OS devices.
-rw-r--r--src/shell.html11
-rw-r--r--src/shell_minimal.html11
2 files changed, 14 insertions, 8 deletions
diff --git a/src/shell.html b/src/shell.html
index cbf8c0d8..226f12b9 100644
--- a/src/shell.html
+++ b/src/shell.html
@@ -1222,7 +1222,7 @@
postRun: [],
print: (function() {
var element = document.getElementById('output');
- element.value = ''; // clear browser cache
+ if (element) element.value = ''; // clear browser cache
return function(text) {
text = Array.prototype.slice.call(arguments).join(' ');
// These replacements are necessary if you render to raw HTML
@@ -1230,8 +1230,11 @@
//text = text.replace(/</g, "&lt;");
//text = text.replace(/>/g, "&gt;");
//text = text.replace('\n', '<br>', 'g');
- element.value += text + "\n";
- element.scrollTop = element.scrollHeight; // focus on bottom
+ console.log(text);
+ if (element) {
+ element.value += text + "\n";
+ element.scrollTop = element.scrollHeight; // focus on bottom
+ }
};
})(),
printErr: function(text) {
@@ -1239,7 +1242,7 @@
if (0) { // XXX disabled for safety typeof dump == 'function') {
dump(text + '\n'); // fast, straight to the real console
} else {
- console.log(text);
+ console.error(text);
}
},
canvas: document.getElementById('canvas'),
diff --git a/src/shell_minimal.html b/src/shell_minimal.html
index 7a3a8d08..6f483719 100644
--- a/src/shell_minimal.html
+++ b/src/shell_minimal.html
@@ -78,7 +78,7 @@
postRun: [],
print: (function() {
var element = document.getElementById('output');
- element.value = ''; // clear browser cache
+ if (element) element.value = ''; // clear browser cache
return function(text) {
text = Array.prototype.slice.call(arguments).join(' ');
// These replacements are necessary if you render to raw HTML
@@ -86,8 +86,11 @@
//text = text.replace(/</g, "&lt;");
//text = text.replace(/>/g, "&gt;");
//text = text.replace('\n', '<br>', 'g');
- element.value += text + "\n";
- element.scrollTop = element.scrollHeight; // focus on bottom
+ console.log(text);
+ if (element) {
+ element.value += text + "\n";
+ element.scrollTop = element.scrollHeight; // focus on bottom
+ }
};
})(),
printErr: function(text) {
@@ -95,7 +98,7 @@
if (0) { // XXX disabled for safety typeof dump == 'function') {
dump(text + '\n'); // fast, straight to the real console
} else {
- console.log(text);
+ console.error(text);
}
},
canvas: document.getElementById('canvas'),