-
Notifications
You must be signed in to change notification settings - Fork 0
/
iostream.js
52 lines (45 loc) · 1.33 KB
/
iostream.js
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
/*
* iostream.js
* Maintains a refernce to the current input/output stream.
* Copyright 2010 Monther. All rights reserved.
*
* require 'shell.h.js'
* require 'keyboard.js'
*
*/
/* namespace for the std stuff **/
shell.module("shell.std");
shell.std.cout = function (data, parser){
// If nothing on the pipe, then print to the screen
// other wise deal with the pipe stuff
if (shell.pipe.callQueueEmpty()){
var parsed_data = (parser == null ? data : parser(data));
shell.std.print(parsed_data);
}else{
}
}
shell.std.echoInput = function (){
var out = "<div class='input sexy'><span class=''>";
out += shell.UI.getPrompt() + "</span><span class='commands'>";
out += shell.UI.inputField.val() + "</span></div>";
shell.std.print(out);
}
/* Standard Error **/
shell.std.cerr = function(data){
output = '<div class="error">' + shell.errors.errors[shell.errors.errindex] + data + "</div>";
shell.std.print(output);
shell.errors.errindex = null;
}
/* Standard Logging: Use the mighty firebug for debugging .... fb i luvvvv uuuuuuuuu **/
shell.std.clog = function(data){
if (console && typeof console.log == "function"){
console.log(data);
}
}
/* Clear the STD output **/
shell.std.clear = function (data){
shell.UI.outputElement.html('');
}
shell.std.print = function (data){
shell.UI.outputElement.append(data);
}