pnacl: remove target and related projects
authorLucas Bajolet <lucas.bajolet@gmail.com>
Mon, 7 May 2018 16:39:12 +0000 (12:39 -0400)
committerLucas Bajolet <lucas.bajolet@gmail.com>
Mon, 7 May 2018 18:35:50 +0000 (14:35 -0400)
Since PNaCl is now deprecated for all targets, and since nobody use the
platform or the contributed online_ide, we remove the packages from the
repo.

Signed-off-by: Lucas Bajolet <lucas.bajolet@gmail.com>

33 files changed:
contrib/online_ide/.gitignore [deleted file]
contrib/online_ide/Makefile [deleted file]
contrib/online_ide/README.md [deleted file]
contrib/online_ide/package.ini [deleted file]
contrib/online_ide/setup/mode-nit.js [deleted file]
contrib/online_ide/setup/nit.js [deleted file]
contrib/online_ide/sources/nit/pnacl_nit.nit [deleted file]
contrib/online_ide/sources/nit_mode_for_ace/lib_ace_mode/nit.js [deleted file]
contrib/online_ide/sources/nit_mode_for_ace/lib_ace_mode/nit_highlight_rules.js [deleted file]
contrib/online_ide/www/css/jquery.terminal.css [deleted file]
contrib/online_ide/www/css/style.css [deleted file]
contrib/online_ide/www/favicon.ico [deleted file]
contrib/online_ide/www/index.html [deleted file]
contrib/online_ide/www/js/FileSaver.js [deleted file]
contrib/online_ide/www/js/editor_configuration.js [deleted file]
contrib/online_ide/www/js/functions.js [deleted file]
contrib/online_ide/www/js/jquery.terminal-0.8.7.js [deleted file]
contrib/online_ide/www/js/pnacl_js.js [deleted file]
contrib/online_ide/www/pnacl/pnacl_nit.nmf [deleted file]
lib/core/text/native.nit
lib/pnacl/examples/converter/Makefile [deleted file]
lib/pnacl/examples/converter/README.md [deleted file]
lib/pnacl/examples/converter/converter.nit [deleted file]
lib/pnacl/examples/converter/converter/index.html [deleted file]
lib/pnacl/examples/converter/converter/js/functions.js [deleted file]
lib/pnacl/examples/converter/converter/js/pnacl_js.js [deleted file]
lib/pnacl/package.ini [deleted file]
lib/pnacl/pnacl.nit [deleted file]
share/man/nitc.md
src/compiler/abstract_compiler.nit
src/compiler/compiler.nit
src/platform/pnacl.nit [deleted file]
tests/turing.skip

diff --git a/contrib/online_ide/.gitignore b/contrib/online_ide/.gitignore
deleted file mode 100644 (file)
index 99a1b95..0000000
+++ /dev/null
@@ -1 +0,0 @@
-pnacl_nit.pexe
diff --git a/contrib/online_ide/Makefile b/contrib/online_ide/Makefile
deleted file mode 100644 (file)
index efc07ba..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-
-ACE_BUILDS ?= ../../../ace-builds/
-
-default:
-       nitc --semi-global sources/nit/pnacl_nit.nit
-       cp pnacl_nit/pnacl_nit.pexe www/pnacl/ -f
-       rm -rf pnacl_nit/
-
-build-www:
-       rm -rf www/src
-       cp -r $(ACE_BUILDS)/src www/
-       cp setup/mode-nit.js www/src/
-       cp setup/nit.js www/src/snippets/
-
-HTTPD_PY := python $(NACL_SDK_ROOT)/tools/httpd.py
-serve:
-       cd www/; \
-        $(HTTPD_PY) -C . --no-dir-check
-
-.PHONY: serve
diff --git a/contrib/online_ide/README.md b/contrib/online_ide/README.md
deleted file mode 100644 (file)
index 5294e6e..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-This file contains all the informations about the Nit online IDE.
-
-I. SETUP
-
-0.a. Install the native client SDK if needed(https://developer.chrome.com/native-client/sdk/download).
-
-0.b. Declare the environment variable NACL_SDK_ROOT as the root of the target platform within the SDK (ex: ~/nacl_sdk/pepper_34/) :
-       $ export NACL_SDK_ROOT=/path/to/nacl_sdk/pepper_[your_version]
-
-1. Run the Makefile with 'make' (this will compile the pnacl module for the interpreter and place it in the right folder).
-
-2. Search for the Ace sources, go to 'https://github.com/ajaxorg/ace-builds/' and get the 'src' folder,
-put it in 'www/'.
-
-NOTE: The application has been developped with a package from 03.02.2014,
-in case of any problem, you can find it here :
-'https://github.com/Djomanix/ace-build-for-nit'.
--> If you get this one, you can skip 3. and 4.
-
-3. Copy 'mode-nit.js' from folder 'setup' to folder 'www/src'.
-
-4. Copy 'nit.js' from folder 'setup' to folder 'www/src/snippets'.
-
-
-II. GETTING STARTED
-
-1. Run 'make serve', this will host the application on 'http://localhost:5103/'.
-
-NOTE:
-1. The application only works in Google Chrome or Chromium.
-2. It is recommended to open the Chrome console while using the application
-(to see what's going on).
-3. The application is ready when the terminal appears in the page
-and when the message :
-'Nit library loaded (... files), ready to go.' is displayed in the Chrome console.
-4. Loading may take some time when the browser loads a pnacl module for the first time.
-
-
-III. FEATURES
-       - CTRL+E: this shortcut launches the interpretation of the code written in the editor.
-       - CTRL+S: this shortcut enables you to download the file you have been writting.
-       - By clicking on the file name you can change it.
-       - The editor has some auto-completion and research features.
-
-
-IV. HOW TO EDIT
-
-1. The folder 'sources/nit' contains the file 'pnacl_nit.nit' which is the source
-of the pnacl module. You can edit the module directly here, and run 'make' to compile it (it will be placed automatically where needed).
-
-2. The folder 'sources/nit_mode_for_ace' contains the source files necessary to
-generate the Ace mode for Nit.
-You can also edit them if you need to improve the Nit support, see :
-- 'http://ace.c9.io/#nav=higlighter'
-
-
-V. HOSTING
-
-1. To host the application, just copy the 'www' folder where you want.
-
-NOTE: The application has been successfully tested on a python server and an apache server.
diff --git a/contrib/online_ide/package.ini b/contrib/online_ide/package.ini
deleted file mode 100644 (file)
index 841f552..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-[package]
-name=online_ide
-tags=devel,web
-maintainer=Johan Kayser <johan.kayser@viacesi.fr>
-license=Apache-2.0
-[upstream]
-browse=https://github.com/nitlang/nit/tree/master/contrib/online_ide/
-git=https://github.com/nitlang/nit.git
-git.directory=contrib/online_ide/
-homepage=http://nitlanguage.org
-issues=https://github.com/nitlang/nit/issues
-tryit=http://nitlanguage.org/online_ide/
diff --git a/contrib/online_ide/setup/mode-nit.js b/contrib/online_ide/setup/mode-nit.js
deleted file mode 100644 (file)
index f9cb1ab..0000000
+++ /dev/null
@@ -1,554 +0,0 @@
-define('ace/mode/nit', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text', 'ace/tokenizer', 'ace/mode/matching_brace_outdent', 'ace/mode/behaviour/cstyle', 'ace/mode/nit_highlight_rules'], function(require, exports, module) {
-
-
-var oop = require("../lib/oop");
-var TextMode = require("./text").Mode;
-var Tokenizer = require("../tokenizer").Tokenizer;
-var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
-var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour;
-var NitHighlightRules = require("./nit_highlight_rules").NitHighlightRules;
-
-var Mode = function() {
-    this.HighlightRules = NitHighlightRules;
-    this.$outdent = new MatchingBraceOutdent();
-    this.$behaviour = new CstyleBehaviour();
-};
-oop.inherits(Mode, TextMode);
-
-(function() {
-    this.lineCommentStart = "#";
-    this.getNextLineIndent = function(state, line, tab) {
-        var indent = this.$getIndent(line);
-        
-        var tokenizedLine = this.getTokenizer().getLineTokens(line, state);
-        var tokens = tokenizedLine.tokens;
-  
-        if (tokens.length && tokens[tokens.length-1].type == "comment") {
-            return indent;
-        }
-    
-        if (state == "start") {
-            var match = line.match(/(^class| class | if | else | else|do$)/);
-            if (match) {
-                indent += tab + tab;
-            }
-        }
-        return indent;
-    };
-    this.checkOutdent = function(state, line, input) {
-        return this.$outdent.checkOutdent(line, input);
-    };
-    this.autoOutdent = function(state, doc, row) {
-        this.$outdent.autoOutdent(doc, row);
-    };
-    this.createWorker = function(session) {
-       return null;
-    };
-    
-       this.$id = "ace/mode/nit";
-}).call(Mode.prototype);
-
-exports.Mode = Mode;
-});
-
-define('ace/mode/matching_brace_outdent', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) {
-
-
-var Range = require("../range").Range;
-
-var MatchingBraceOutdent = function() {};
-
-(function() {
-
-    this.checkOutdent = function(line, input) {
-        if (! /^\s+$/.test(line))
-            return false;
-
-        return /^\s*\}/.test(input);
-    };
-
-    this.autoOutdent = function(doc, row) {
-        var line = doc.getLine(row);
-        var match = line.match(/^(\s*\})/);
-
-        if (!match) return 0;
-
-        var column = match[1].length;
-        var openBracePos = doc.findMatchingBracket({row: row, column: column});
-
-        if (!openBracePos || openBracePos.row == row) return 0;
-
-        var indent = this.$getIndent(doc.getLine(openBracePos.row));
-        doc.replace(new Range(row, 0, row, column-1), indent);
-    };
-
-    this.$getIndent = function(line) {
-        return line.match(/^\s*/)[0];
-    };
-
-}).call(MatchingBraceOutdent.prototype);
-
-exports.MatchingBraceOutdent = MatchingBraceOutdent;
-});
-
-define('ace/mode/behaviour/cstyle', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/behaviour', 'ace/token_iterator', 'ace/lib/lang'], function(require, exports, module) {
-
-
-var oop = require("../../lib/oop");
-var Behaviour = require("../behaviour").Behaviour;
-var TokenIterator = require("../../token_iterator").TokenIterator;
-var lang = require("../../lib/lang");
-
-var SAFE_INSERT_IN_TOKENS =
-    ["text", "paren.rparen", "punctuation.operator"];
-var SAFE_INSERT_BEFORE_TOKENS =
-    ["text", "paren.rparen", "punctuation.operator", "comment"];
-
-
-var autoInsertedBrackets = 0;
-var autoInsertedRow = -1;
-var autoInsertedLineEnd = "";
-var maybeInsertedBrackets = 0;
-var maybeInsertedRow = -1;
-var maybeInsertedLineStart = "";
-var maybeInsertedLineEnd = "";
-
-var CstyleBehaviour = function () {
-    
-    CstyleBehaviour.isSaneInsertion = function(editor, session) {
-        var cursor = editor.getCursorPosition();
-        var iterator = new TokenIterator(session, cursor.row, cursor.column);
-        if (!this.$matchTokenType(iterator.getCurrentToken() || "text", SAFE_INSERT_IN_TOKENS)) {
-            var iterator2 = new TokenIterator(session, cursor.row, cursor.column + 1);
-            if (!this.$matchTokenType(iterator2.getCurrentToken() || "text", SAFE_INSERT_IN_TOKENS))
-                return false;
-        }
-        iterator.stepForward();
-        return iterator.getCurrentTokenRow() !== cursor.row ||
-            this.$matchTokenType(iterator.getCurrentToken() || "text", SAFE_INSERT_BEFORE_TOKENS);
-    };
-    
-    CstyleBehaviour.$matchTokenType = function(token, types) {
-        return types.indexOf(token.type || token) > -1;
-    };
-    
-    CstyleBehaviour.recordAutoInsert = function(editor, session, bracket) {
-        var cursor = editor.getCursorPosition();
-        var line = session.doc.getLine(cursor.row);
-        if (!this.isAutoInsertedClosing(cursor, line, autoInsertedLineEnd[0]))
-            autoInsertedBrackets = 0;
-        autoInsertedRow = cursor.row;
-        autoInsertedLineEnd = bracket + line.substr(cursor.column);
-        autoInsertedBrackets++;
-    };
-    
-    CstyleBehaviour.recordMaybeInsert = function(editor, session, bracket) {
-        var cursor = editor.getCursorPosition();
-        var line = session.doc.getLine(cursor.row);
-        if (!this.isMaybeInsertedClosing(cursor, line))
-            maybeInsertedBrackets = 0;
-        maybeInsertedRow = cursor.row;
-        maybeInsertedLineStart = line.substr(0, cursor.column) + bracket;
-        maybeInsertedLineEnd = line.substr(cursor.column);
-        maybeInsertedBrackets++;
-    };
-    
-    CstyleBehaviour.isAutoInsertedClosing = function(cursor, line, bracket) {
-        return autoInsertedBrackets > 0 &&
-            cursor.row === autoInsertedRow &&
-            bracket === autoInsertedLineEnd[0] &&
-            line.substr(cursor.column) === autoInsertedLineEnd;
-    };
-    
-    CstyleBehaviour.isMaybeInsertedClosing = function(cursor, line) {
-        return maybeInsertedBrackets > 0 &&
-            cursor.row === maybeInsertedRow &&
-            line.substr(cursor.column) === maybeInsertedLineEnd &&
-            line.substr(0, cursor.column) == maybeInsertedLineStart;
-    };
-    
-    CstyleBehaviour.popAutoInsertedClosing = function() {
-        autoInsertedLineEnd = autoInsertedLineEnd.substr(1);
-        autoInsertedBrackets--;
-    };
-    
-    CstyleBehaviour.clearMaybeInsertedClosing = function() {
-        maybeInsertedBrackets = 0;
-        maybeInsertedRow = -1;
-    };
-
-    this.add("braces", "insertion", function (state, action, editor, session, text) {
-        var cursor = editor.getCursorPosition();
-        var line = session.doc.getLine(cursor.row);
-        if (text == '{') {
-            var selection = editor.getSelectionRange();
-            var selected = session.doc.getTextRange(selection);
-            if (selected !== "" && selected !== "{" && editor.getWrapBehavioursEnabled()) {
-                return {
-                    text: '{' + selected + '}',
-                    selection: false
-                };
-            } else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
-                if (/[\]\}\)]/.test(line[cursor.column]) || editor.inMultiSelectMode) {
-                    CstyleBehaviour.recordAutoInsert(editor, session, "}");
-                    return {
-                        text: '{}',
-                        selection: [1, 1]
-                    };
-                } else {
-                    CstyleBehaviour.recordMaybeInsert(editor, session, "{");
-                    return {
-                        text: '{',
-                        selection: [1, 1]
-                    };
-                }
-            }
-        } else if (text == '}') {
-            var rightChar = line.substring(cursor.column, cursor.column + 1);
-            if (rightChar == '}') {
-                var matching = session.$findOpeningBracket('}', {column: cursor.column + 1, row: cursor.row});
-                if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) {
-                    CstyleBehaviour.popAutoInsertedClosing();
-                    return {
-                        text: '',
-                        selection: [1, 1]
-                    };
-                }
-            }
-        } else if (text == "\n" || text == "\r\n") {
-            var closing = "";
-            if (CstyleBehaviour.isMaybeInsertedClosing(cursor, line)) {
-                closing = lang.stringRepeat("}", maybeInsertedBrackets);
-                CstyleBehaviour.clearMaybeInsertedClosing();
-            }
-            var rightChar = line.substring(cursor.column, cursor.column + 1);
-            if (rightChar === '}') {
-                var openBracePos = session.findMatchingBracket({row: cursor.row, column: cursor.column+1}, '}');
-                if (!openBracePos)
-                     return null;
-                var next_indent = this.$getIndent(session.getLine(openBracePos.row));
-            } else if (closing) {
-                var next_indent = this.$getIndent(line);
-            } else {
-                return;
-            }
-            var indent = next_indent + session.getTabString();
-
-            return {
-                text: '\n' + indent + '\n' + next_indent + closing,
-                selection: [1, indent.length, 1, indent.length]
-            };
-        } else {
-            CstyleBehaviour.clearMaybeInsertedClosing();
-        }
-    });
-
-    this.add("braces", "deletion", function (state, action, editor, session, range) {
-        var selected = session.doc.getTextRange(range);
-        if (!range.isMultiLine() && selected == '{') {
-            var line = session.doc.getLine(range.start.row);
-            var rightChar = line.substring(range.end.column, range.end.column + 1);
-            if (rightChar == '}') {
-                range.end.column++;
-                return range;
-            } else {
-                maybeInsertedBrackets--;
-            }
-        }
-    });
-
-    this.add("parens", "insertion", function (state, action, editor, session, text) {
-        if (text == '(') {
-            var selection = editor.getSelectionRange();
-            var selected = session.doc.getTextRange(selection);
-            if (selected !== "" && editor.getWrapBehavioursEnabled()) {
-                return {
-                    text: '(' + selected + ')',
-                    selection: false
-                };
-            } else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
-                CstyleBehaviour.recordAutoInsert(editor, session, ")");
-                return {
-                    text: '()',
-                    selection: [1, 1]
-                };
-            }
-        } else if (text == ')') {
-            var cursor = editor.getCursorPosition();
-            var line = session.doc.getLine(cursor.row);
-            var rightChar = line.substring(cursor.column, cursor.column + 1);
-            if (rightChar == ')') {
-                var matching = session.$findOpeningBracket(')', {column: cursor.column + 1, row: cursor.row});
-                if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) {
-                    CstyleBehaviour.popAutoInsertedClosing();
-                    return {
-                        text: '',
-                        selection: [1, 1]
-                    };
-                }
-            }
-        }
-    });
-
-    this.add("parens", "deletion", function (state, action, editor, session, range) {
-        var selected = session.doc.getTextRange(range);
-        if (!range.isMultiLine() && selected == '(') {
-            var line = session.doc.getLine(range.start.row);
-            var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
-            if (rightChar == ')') {
-                range.end.column++;
-                return range;
-            }
-        }
-    });
-
-    this.add("brackets", "insertion", function (state, action, editor, session, text) {
-        if (text == '[') {
-            var selection = editor.getSelectionRange();
-            var selected = session.doc.getTextRange(selection);
-            if (selected !== "" && editor.getWrapBehavioursEnabled()) {
-                return {
-                    text: '[' + selected + ']',
-                    selection: false
-                };
-            } else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
-                CstyleBehaviour.recordAutoInsert(editor, session, "]");
-                return {
-                    text: '[]',
-                    selection: [1, 1]
-                };
-            }
-        } else if (text == ']') {
-            var cursor = editor.getCursorPosition();
-            var line = session.doc.getLine(cursor.row);
-            var rightChar = line.substring(cursor.column, cursor.column + 1);
-            if (rightChar == ']') {
-                var matching = session.$findOpeningBracket(']', {column: cursor.column + 1, row: cursor.row});
-                if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) {
-                    CstyleBehaviour.popAutoInsertedClosing();
-                    return {
-                        text: '',
-                        selection: [1, 1]
-                    };
-                }
-            }
-        }
-    });
-
-    this.add("brackets", "deletion", function (state, action, editor, session, range) {
-        var selected = session.doc.getTextRange(range);
-        if (!range.isMultiLine() && selected == '[') {
-            var line = session.doc.getLine(range.start.row);
-            var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
-            if (rightChar == ']') {
-                range.end.column++;
-                return range;
-            }
-        }
-    });
-
-    this.add("string_dquotes", "insertion", function (state, action, editor, session, text) {
-        if (text == '"' || text == "'") {
-            var quote = text;
-            var selection = editor.getSelectionRange();
-            var selected = session.doc.getTextRange(selection);
-            if (selected !== "" && selected !== "'" && selected != '"' && editor.getWrapBehavioursEnabled()) {
-                return {
-                    text: quote + selected + quote,
-                    selection: false
-                };
-            } else {
-                var cursor = editor.getCursorPosition();
-                var line = session.doc.getLine(cursor.row);
-                var leftChar = line.substring(cursor.column-1, cursor.column);
-                if (leftChar == '\\') {
-                    return null;
-                }
-                var tokens = session.getTokens(selection.start.row);
-                var col = 0, token;
-                var quotepos = -1; // Track whether we're inside an open quote.
-
-                for (var x = 0; x < tokens.length; x++) {
-                    token = tokens[x];
-                    if (token.type == "string") {
-                      quotepos = -1;
-                    } else if (quotepos < 0) {
-                      quotepos = token.value.indexOf(quote);
-                    }
-                    if ((token.value.length + col) > selection.start.column) {
-                        break;
-                    }
-                    col += tokens[x].value.length;
-                }
-                if (!token || (quotepos < 0 && token.type !== "comment" && (token.type !== "string" || ((selection.start.column !== token.value.length+col-1) && token.value.lastIndexOf(quote) === token.value.length-1)))) {
-                    if (!CstyleBehaviour.isSaneInsertion(editor, session))
-                        return;
-                    return {
-                        text: quote + quote,
-                        selection: [1,1]
-                    };
-                } else if (token && token.type === "string") {
-                    var rightChar = line.substring(cursor.column, cursor.column + 1);
-                    if (rightChar == quote) {
-                        return {
-                            text: '',
-                            selection: [1, 1]
-                        };
-                    }
-                }
-            }
-        }
-    });
-
-    this.add("string_dquotes", "deletion", function (state, action, editor, session, range) {
-        var selected = session.doc.getTextRange(range);
-        if (!range.isMultiLine() && (selected == '"' || selected == "'")) {
-            var line = session.doc.getLine(range.start.row);
-            var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
-            if (rightChar == selected) {
-                range.end.column++;
-                return range;
-            }
-        }
-    });
-
-};
-
-oop.inherits(CstyleBehaviour, Behaviour);
-
-exports.CstyleBehaviour = CstyleBehaviour;
-});
-define('ace/mode/nit_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/doc_comment_highlight_rules', 'ace/mode/text_highlight_rules'], function(require, exports, module) {
-
-
-var oop = require("../lib/oop");
-var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules;
-var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
-
-var NitHighlightRules = function() {
-
-    var keywords = (
-               "package|module|import|class|abstract|interface|universal|enum|end|fun|" +
-               "type|init|redef|is|do|readable|writable|var|intern|extern|protected|private|" +
-               "intrude|if|then|else|while|loop|for|in|and|or|not|implies|return|continue|" +
-               "break|abort|assert|new|isa|once|super|self|true|false|null|as|nullable|isset|label|__debug__"
-    );
-
-    var keywordMapper = this.createKeywordMapper({
-        "keyword": keywords,
-        "variable.language": "self",
-        "constant.language": "null|true|false"
-    }, "identifier");
-   this.$rules = {
-        "start" : [
-            {
-                       token : "comment",
-                       regex : "#.*$"
-            },
-            {
-                       token : "support.class",
-                       regex : /[A-Z]{1}[a-z]+/
-            },
-            DocCommentHighlightRules.getStartRule("doc-start"),
-            {
-                token : "string.regexp",
-                regex : "[/](?:(?:\\[(?:\\\\]|[^\\]])+\\])|(?:\\\\/|[^\\]/]))*[/]\\w*\\s*(?=[).,;]|$)"
-            }, {
-                token : "string", // character
-                regex : /'(?:.|\\(:?u[\da-fA-F]+|x[\da-fA-F]+|[tbrf'"n]))'/
-            }, {
-                token : "string", start : '"', end : '"|$', next: [
-                    {token: "constant.language.escape", regex: /\\(:?u[\da-fA-F]+|x[\da-fA-F]+|[tbrf'"n])/},
-                    {token: "invalid", regex: /\\./}
-                ]
-            }, {
-                token : "string", start : '@"', end : '"', next:[
-                    {token: "constant.language.escape", regex: '""'}
-                ]
-            }, {
-                       token : "constant.numeric", // hex
-                       regex : "0[xX][0-9a-fA-F]+\\b"
-            }, {
-                       token : "constant.numeric", // float
-                       regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
-            }, {
-                       token : "constant.language.boolean",
-                       regex : "(?:true|false)\\b"
-            }, {
-                       token : keywordMapper,
-                       regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
-            }, {
-                       token : "keyword.operator",
-                       regex : "@|!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\::|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|instanceof|new|delete|typeof|void)"
-            }, {
-                       token : "keyword",
-                       regex : "^\\s*#(if|else|elif|endif|define|undef|warning|error|line|region|endregion|pragma)"
-            }, {
-                       token : "punctuation.operator",
-                       regex : "\\?|\\:|\\,|\\;|\\."
-            }, {
-                       token : "paren.lparen",
-                       regex : "[[({]"
-            }, {
-                       token : "paren.rparen",
-                       regex : "[\\])}]"
-            }, {
-                       token : "text",
-                       regex : "\\s+"
-            }
-        ]
-    };
-       this.embedRules(DocCommentHighlightRules, "doc-",
-       [ DocCommentHighlightRules.getEndRule("start") ]);
-       this.normalizeRules();
-};
-
-oop.inherits(NitHighlightRules, TextHighlightRules);
-
-exports.NitHighlightRules = NitHighlightRules;
-
-});
-
-define('ace/mode/doc_comment_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text_highlight_rules'], function(require, exports, module) {
-
-
-var oop = require("../lib/oop");
-var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
-
-var DocCommentHighlightRules = function() {
-
-    this.$rules = {
-        "start" : [ {
-            token : "comment.doc.tag",
-            regex : "@[\\w\\d_]+" // TODO: fix email addresses
-        }, {
-            token : "comment.doc.tag",
-            regex : "\\bTODO\\b"
-        }, {
-            defaultToken : "comment.doc"
-        }]
-    };
-};
-
-oop.inherits(DocCommentHighlightRules, TextHighlightRules);
-
-DocCommentHighlightRules.getStartRule = function(start) {
-    return {
-        token : "comment.doc", // doc comment
-        regex : "\\/\\*(?=\\*)",
-        next  : start
-    };
-};
-
-DocCommentHighlightRules.getEndRule = function (start) {
-    return {
-        token : "comment.doc", // closing comment
-        regex : "\\*\\/",
-        next  : start
-    };
-};
-
-
-exports.DocCommentHighlightRules = DocCommentHighlightRules;
-
-});
diff --git a/contrib/online_ide/setup/nit.js b/contrib/online_ide/setup/nit.js
deleted file mode 100644 (file)
index ee8952b..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-define('ace/snippets/nit', ['require', 'exports', 'module' ], function(require, exports, module) {
-
-
-exports.snippetText = "";
-exports.scope = "nit";
-
-});
diff --git a/contrib/online_ide/sources/nit/pnacl_nit.nit b/contrib/online_ide/sources/nit/pnacl_nit.nit
deleted file mode 100644 (file)
index 4062c78..0000000
+++ /dev/null
@@ -1,193 +0,0 @@
-# This file is part of NIT ( http://www.nitlanguage.org ).
-#
-# Copyright 2014 Johan Kayser <kayser.johan@gmail.com>
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-# A version of the naive Nit interpreter for PNaCl.
-module pnacl_nit
-
-import nitc::naive_interpreter
-import pnacl
-intrude import nitc::toolcontext
-intrude import nitc::loader
-intrude import core::file
-
-# We redefine exit to start a new thread before killing the one that called exit.
-redef fun exit(exit_value: Int)
-do
-       var dictionary = new PepperDictionary
-       dictionary["exit"] = exit_value
-       dictionary["exit_thread"] = "A new thread has been made available for Nit."
-       create_thread
-       app.post_dictionary dictionary
-       exit_thread exit_value
-end
-
-#hack realpath.
-redef class String
-       redef fun realpath do return self
-
-       # file_exists looks in the 'files' HashMap.
-       redef fun file_exists: Bool
-       do
-               if sys.files.has_key(self) then return true
-               return false
-       end
-end
-
-redef class Sys
-       # We add two HashMap for temporary file storage.
-       # 'lib' stores the lib files.
-       var lib = new HashMap[String, String]
-       # 'files' stores the "file(s)" you want to interpret + the lib files.
-       var files = new HashMap[String, String]
-end
-
-redef class ToolContext
-       # We don't need 'the locate_nit_dir'.
-       redef fun locate_nit_dir
-       do
-               return "/pnacl"
-       end
-end
-
-# We have to redef some FileReader methods because we don't use NativeFiles anymore.
-redef class FileReader
-
-       # Looks in the 'files' HashMap.
-       redef init open(path: String)
-       do
-               self.path = path
-               var file = sys.files[path]
-               prepare_buffer(file.length)
-               path.copy_to_native(_buffer, file.length, 0, 0)
-       end
-
-       redef fun close
-       do
-               end_reached = true
-       end
-
-       redef fun fill_buffer
-       do
-               buffer_reset
-               end_reached = true
-       end
-
-       redef fun reopen
-       do
-               _buffer_pos = 0
-       end
-end
-
-redef class ModelBuilder
-       # We don't use paths as the interpreter, so just return the argument.
-       redef fun module_absolute_path(path: String): String do return path
-
-       # We don't use paths as the interpreter, so we don't use location or lookpaths args (see the default implementation).
-       redef fun search_module_in_paths(location: nullable Location, name: String, lookpaths: Collection[String]): nullable MModule
-       do
-               var candidate: nullable String = null
-               var try_file = "{name}.nit"
-               if try_file.file_exists then
-                       if candidate == null then
-                               candidate = try_file
-                       else if candidate != try_file then
-                               # try to disambiguate conflicting modules
-                               var abs_candidate = module_absolute_path(candidate)
-                               var abs_try_file = module_absolute_path(try_file)
-                               if abs_candidate != abs_try_file then
-                                       toolcontext.error(location, "Error: conflicting module file for {name}: {candidate} {try_file}")
-                               end
-                       end
-               end
-               if candidate == null then return null
-               return identify_module(candidate)
-       end
-end
-
-class Pnacl_nit
-       super PnaclApp
-
-       # In handle_dictionary we search for the 'operation' key in dictionaries,
-       # 'load' means that we are loading the Nit library,
-       # 'interpret' launches the interpreter code.
-       redef fun handle_dictionary(dictionary: PepperDictionary)
-       do
-               var d = dictionary.copy
-               var operation = d["operation"]
-
-               # If operation = 'intepret' we want to interpret some Nit code, so we execute the same code as in nit.nit.
-               if operation == "interpret" then
-                       var args = d["args"].to_s.split(' ')
-                       # Create a tool context to handle options and paths
-                       var toolcontext = new ToolContext
-                       toolcontext.tooldescription = "Usage: nit [OPTION]... <file.nit>...\nInterprets and debbugs Nit programs."
-                       # Add an option "-o" to enable compatibilit with the tests.sh script
-                       var opt = new OptionString("compatibility (does noting)", "-o")
-                       toolcontext.option_context.add_option(opt)
-                       var opt_mixins = new OptionArray("Additionals module to min-in", "-m")
-                       toolcontext.option_context.add_option(opt_mixins)
-                       # We do not add other options, so process them now!
-                       toolcontext.process_options(args)
-
-                       # We need a model to collect stufs
-                       var model = new Model
-                       # An a model builder to parse files
-                       var modelbuilder = new ModelBuilder(model, toolcontext)
-
-                       var arguments = toolcontext.option_context.rest
-                       var progname = arguments.first
-                       sys.files[progname] = d["content"].to_s
-
-                       # Here we load an process all modules passed on the command line
-                       var mmodules = modelbuilder.parse([progname])
-                       mmodules.add_all modelbuilder.parse(opt_mixins.value)
-                       modelbuilder.run_phases
-
-                       if toolcontext.opt_only_metamodel.value then exit(0)
-
-                       var mainmodule: nullable MModule
-
-                       # Here we launch the interpreter on the main module
-                       if mmodules.length == 1 then
-                               mainmodule = mmodules.first
-                       else
-                               mainmodule = new MModule(model, null, mmodules.first.name, mmodules.first.location)
-                               mainmodule.set_imported_mmodules(mmodules)
-                       end
-
-                       var self_mm = mainmodule
-                       var self_args = arguments
-
-                       modelbuilder.run_naive_interpreter(self_mm, self_args)
-               # If operation = 'load', we are loading lib files, so we store them into HashMaps and send a response to JS.
-               else if operation == "load" then
-                       var filename = d["filename"]
-                       var content = d["content"]
-                       if filename isa String and content isa String then
-                               sys.lib[filename] = content
-                               sys.files[filename] = content
-                       end
-                       var response = new PepperDictionary
-                       response["operation"] = "load_response"
-                       response["files_number"] = sys.lib.length.to_s
-                       post_dictionary response
-               end
-       end
-end
-
-redef fun app do return once new Pnacl_nit
-app.initialize # Needed to correctly set up Nit control over the Pepper API.
-app.run # Wait for dictionaries.
diff --git a/contrib/online_ide/sources/nit_mode_for_ace/lib_ace_mode/nit.js b/contrib/online_ide/sources/nit_mode_for_ace/lib_ace_mode/nit.js
deleted file mode 100644 (file)
index fb1e3dc..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-define(function(require, exports, module) {
-"use strict";
-
-var oop = require("../lib/oop");
-// defines the parent mode
-var TextMode = require("./text").Mode;
-var Tokenizer = require("../tokenizer").Tokenizer;
-var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
-var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour;
-
-// defines the language specific highlighters and folding rules
-var NitHighlightRules = require("./nit_highlight_rules").NitHighlightRules;
-//var NitFoldMode = require("./folding/nit").NitFoldMode;
-
-var Mode = function() {
-    // set everything up
-    this.HighlightRules = NitHighlightRules;
-    this.$outdent = new MatchingBraceOutdent();
-    this.$behaviour = new CstyleBehaviour();
-    //this.foldingRules = new NitFoldMode();
-};
-oop.inherits(Mode, TextMode);
-
-(function() {
-    // configure comment start/end characters
-    this.lineCommentStart = "#";
-    //this.blockComment = {start: "/*", end: "*/"};
-    
-    // special logic for indent/outdent. 
-    // By default ace keeps indentation of previous line
-    this.getNextLineIndent = function(state, line, tab) {
-        var indent = this.$getIndent(line);
-        
-        var tokenizedLine = this.getTokenizer().getLineTokens(line, state);
-        var tokens = tokenizedLine.tokens;
-  
-        if (tokens.length && tokens[tokens.length-1].type == "comment") {
-            return indent;
-        }
-    
-        if (state == "start") {
-            //var match = line.match(/^.*[\{\(\[]\s*$/);
-            var match = line.match(/(^class| class | if | else | else|do$)/);
-            if (match) {
-                indent += tab + tab;
-            }
-        }
-        return indent;
-    };
-    this.checkOutdent = function(state, line, input) {
-        return this.$outdent.checkOutdent(line, input);
-    };
-    this.autoOutdent = function(state, doc, row) {
-        this.$outdent.autoOutdent(doc, row);
-    };
-    
-    // create worker for live syntax checking
-    this.createWorker = function(session) {
-        /*var worker = new WorkerClient(["ace"], "ace/mode/nit_worker", "NitWorker");
-        worker.attachToDocument(session.getDocument());
-        worker.on("errors", function(e) {
-            session.setAnnotations(e.data);
-        });
-        return worker;*/
-       return null;
-    };
-    
-       this.$id = "ace/mode/nit";
-}).call(Mode.prototype);
-
-exports.Mode = Mode;
-}); 
diff --git a/contrib/online_ide/sources/nit_mode_for_ace/lib_ace_mode/nit_highlight_rules.js b/contrib/online_ide/sources/nit_mode_for_ace/lib_ace_mode/nit_highlight_rules.js
deleted file mode 100644 (file)
index 32d9a04..0000000
+++ /dev/null
@@ -1,93 +0,0 @@
-define(function(require, exports, module) {
-"use strict";
-
-var oop = require("../lib/oop");
-var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules;
-var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
-
-var NitHighlightRules = function() {
-
-    var keywords = (
-               "package|module|import|class|abstract|interface|universal|enum|end|fun|" +
-               "type|init|redef|is|do|readable|writable|var|intern|extern|protected|private|" +
-               "intrude|if|then|else|while|loop|for|in|and|or|not|implies|return|continue|" +
-               "break|abort|assert|new|isa|once|super|self|true|false|null|as|nullable|isset|label|__debug__"
-    );
-
-    var keywordMapper = this.createKeywordMapper({
-        "keyword": keywords,
-        "variable.language": "self",
-        "constant.language": "null|true|false"
-    }, "identifier");
-
-    // regexp must not have capturing parentheses. Use (?:) instead.
-    // regexps are ordered -> the first match is used
-   this.$rules = {
-        "start" : [
-            {
-                       token : "comment",
-                       regex : "#.*$"
-            },
-            {
-                       token : "support.class",
-                       regex : /[A-Z]{1}[a-z]+/
-            },
-            DocCommentHighlightRules.getStartRule("doc-start"),
-            {
-                token : "string.regexp",
-                regex : "[/](?:(?:\\[(?:\\\\]|[^\\]])+\\])|(?:\\\\/|[^\\]/]))*[/]\\w*\\s*(?=[).,;]|$)"
-            }, {
-                token : "string", // character
-                regex : /'(?:.|\\(:?u[\da-fA-F]+|x[\da-fA-F]+|[tbrf'"n]))'/
-            }, {
-                token : "string", start : '"', end : '"|$', next: [
-                    {token: "constant.language.escape", regex: /\\(:?u[\da-fA-F]+|x[\da-fA-F]+|[tbrf'"n])/},
-                    {token: "invalid", regex: /\\./}
-                ]
-            }, {
-                token : "string", start : '@"', end : '"', next:[
-                    {token: "constant.language.escape", regex: '""'}
-                ]
-            }, {
-                       token : "constant.numeric", // hex
-                       regex : "0[xX][0-9a-fA-F]+\\b"
-            }, {
-                       token : "constant.numeric", // float
-                       regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
-            }, {
-                       token : "constant.language.boolean",
-                       regex : "(?:true|false)\\b"
-            }, {
-                       token : keywordMapper,
-                       regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
-            }, {
-                       token : "keyword.operator",
-                       regex : "@|!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\::|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|instanceof|new|delete|typeof|void)"
-            }, {
-                       token : "keyword",
-                       regex : "^\\s*#(if|else|elif|endif|define|undef|warning|error|line|region|endregion|pragma)"
-            }, {
-                       token : "punctuation.operator",
-                       regex : "\\?|\\:|\\,|\\;|\\."
-            }, {
-                       token : "paren.lparen",
-                       regex : "[[({]"
-            }, {
-                       token : "paren.rparen",
-                       regex : "[\\])}]"
-            }, {
-                       token : "text",
-                       regex : "\\s+"
-            }
-        ]
-    };
-       this.embedRules(DocCommentHighlightRules, "doc-",
-       [ DocCommentHighlightRules.getEndRule("start") ]);
-       this.normalizeRules();
-};
-
-oop.inherits(NitHighlightRules, TextHighlightRules);
-
-exports.NitHighlightRules = NitHighlightRules;
-
-});
diff --git a/contrib/online_ide/www/css/jquery.terminal.css b/contrib/online_ide/www/css/jquery.terminal.css
deleted file mode 100644 (file)
index 6db2df5..0000000
+++ /dev/null
@@ -1,189 +0,0 @@
-/*
- *       __ _____                     ________                              __
- *      / // _  /__ __ _____ ___ __ _/__  ___/__ ___ ______ __ __  __ ___  / /
- *  __ / // // // // // _  // _// // / / // _  // _//     // //  \/ // _ \/ /
- * /  / // // // // // ___// / / // / / // ___// / / / / // // /\  // // / /__
- * \___//____ \\___//____//_/ _\_  / /_//____//_/ /_/ /_//_//_/ /_/ \__\_\___/
- *           \/              /____/
- * http://terminal.jcubic.pl
- *
- * Copyright (c) 2011-2014 Jakub Jankiewicz <http://jcubic.pl>
- *
- * This file is part of jQuery Terminal.
- *
- * jQuery Terminal is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * jQuery Terminal is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Foobar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
- *
- */
-.terminal .terminal-output .format, .cmd .format,
-.cmd .prompt, .cmd .prompt div, .terminal .terminal-output div div{
-    display: inline-block;
-}
-.cmd .clipboard {
-    position: absolute;
-    bottom: 0;
-    left: 0;
-    /*clip: rect(0,0,0,0);*/
-    /*
-    opacity: 0.01;
-    filter: alpha(opacity = 0.01);
-    filter: progid:DXImageTransform.Microsoft.Alpha(opacity=0.01);
-    */
-    width: 5px;
-    /*
-    outline: none;
-    border: none;
-    background-color: black;
-    */
-}
-/*
-.cmd > .clipboard {
-    position: fixed;
-}
-*/
-.cmd input {
-    height: 1.3em;
-    width: 0.5em;
-    padding: 0;
-    border: none;
-}
-.terminal {
-    padding: 10px;
-    position: relative;
-    overflow: hidden;
-}
-.cmd {
-    padding: 0;
-    margin: 0;
-    height: 1.3em;
-    /*margin-top: 3px; */
-}
-.cmd .cursor.blink {
-    -webkit-animation: blink 1s infinite steps(1, start);
-       -moz-animation: blink 1s infinite steps(1, start);
-        -ms-animation: blink 1s infinite steps(1, start);
-            animation: blink 1s infinite steps(1, start);
-}
-@keyframes blink {
-  0%, 100% {
-        background-color: #000;
-        color: #aaa;
-  }
-  50% {
-        background-color: #bbb; /* not #aaa because it's seem there is Google Chrome bug */
-        color: #000;
-  }
-}
-@-webkit-keyframes blink {
-  0%, 100% {
-        background-color: #000;
-        color: #aaa;
-  }
-  50% {
-        background-color: #bbb;
-        color: #000;
-  }
-}
-@-ms-keyframes blink {
-  0%, 100% {
-        background-color: #000;
-        color: #aaa;
-  }
-  50% {
-        background-color: #bbb;
-        color: #000;
-  }
-}
-@-moz-keyframes blink {
-  0%, 100% {
-        background-color: #000;
-        color: #aaa;
-  }
-  50% {
-        background-color: #bbb;
-        color: #000;
-  }
-}
-.terminal .terminal-output div div, .cmd .prompt {
-    display: block;
-    line-height: 14px;
-    height: auto;
-}
-.cmd .prompt {
-    float: left;
-}
-.terminal, .cmd {
-    font-family: FreeMono, monospace;
-    color: white;
-    background-color: #000;
-    font-size: 12px;
-    line-height: 14px;
-}
-/* Android hack */
-@media screen and (max-device-width: 480px) {
-    .terminal, .cmd {
-        font-family: monospace;
-    }
-}
-.terminal-output > div {
-    /*padding-top: 3px;*/
-    min-height: 14px;
-}
-.terminal .terminal-output div span {
-    display: inline-block;
-}
-.cmd span {
-    float: left;
-    /*display: inline-block; */
-}
-.terminal .inverted, .cmd .inverted, .cmd .cursor.blink {
-    background-color: #aaa;
-    color: #000;
-}
-.terminal .terminal-output div div::-moz-selection,
-.terminal .terminal-output div span::-moz-selection,
-.terminal .terminal-output div div a::-moz-selection {
-    background-color: #aaa;
-    color: #000;
-}
-.terminal .terminal-output div div::selection,
-.terminal .terminal-output div div a::selection,
-.terminal .terminal-output div span::selection,
-.cmd > span::selection,
-.cmd .prompt span::selection {
-    background-color: #aaa;
-    color: #000;
-}
-.terminal .terminal-output div.error, .terminal .terminal-output div.error div {
-    color: red;
-}
-.tilda {
-    position: fixed;
-    top: 0;
-    left: 0;
-    width: 100%;
-    z-index: 1100;
-}
-.clear {
-    clear: both;
-}
-.terminal a {
-    color: #0F60FF;
-}
-.terminal a:hover {
-    color: red;
-}
-textarea.clipboard {
-       visibility: hidden;
-}
diff --git a/contrib/online_ide/www/css/style.css b/contrib/online_ide/www/css/style.css
deleted file mode 100644 (file)
index 0716f53..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-body {
-       margin: 0;
-       margin-top: 0px;
-       padding: 0;
-       background-color: #f8f8f8;
-        font-size: 14px;
-       font-family: "Helvetica Neue", Helvetica, Tahoma, sans-serif;
-}
-#pageheader {
-       position: relative;
-       background-color: #292929;
-       color: #6c6c6c;
-       overflow: hidden;
-}
-#pageheader_title {
-       position: relative;
-       width: 125px;
-       height: 19px;
-       background-color: #f8f8f8;
-       padding: 2px;
-       text-align: center;
-       float: left;
-}
-#pageheader_title h1 {
-       margin: 0;
-       font-size: 14px;
-}
-#pageheader_title h1 span {
-       color:#0D8921;
-}
-#navigation {
-       margin: 0 ;
-       padding: 0 ;
-       list-style: none ;
-}
-#navigation li {
-       display: inline;
-       float: left ;
-       width: 125px;
-       height: 19px;
-       padding: 2px;
-       background-color: #f8f8f8;
-       color: #0D8921;
-       font-size: 12px;
-       text-align: center;     
-       border: 1px #0D8921;
-       border-style: none none none dashed;
-}
-#navigation li button{
-       margin-top: -1px;
-}
-#filename {
-       color:#6c6c6c;
-}
-#editor {
-        position: relative;
-        left: 0;
-        width: 100%;
-        height: 460px;
-}
-#terminal
-{
-       position: relative;
-       left: 0;
-       width: 100%;
-       height: 230px;
-       overflow: auto;
-       padding: 0;
-}
-#listener
-{
-       height: 0;
-}
diff --git a/contrib/online_ide/www/favicon.ico b/contrib/online_ide/www/favicon.ico
deleted file mode 100644 (file)
index 0f66f25..0000000
Binary files a/contrib/online_ide/www/favicon.ico and /dev/null differ
diff --git a/contrib/online_ide/www/index.html b/contrib/online_ide/www/index.html
deleted file mode 100644 (file)
index e46b0e9..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-<!DOCTYPE html>
-<html>
-       <head>
-               <meta charset="UTF-8">
-               <title>Nit - IDE</title>
-               <link rel="stylesheet" type="text/css" href="css/style.css">
-               <link rel="stylesheet" type="text/css" href="css/jquery.terminal.css">
-               <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
-               <script src="src/ace.js" type="text/javascript" charset="utf-8"></script>
-               <script src="src/ext-language_tools.js"></script>
-               <script src="js/pnacl_js.js"></script>
-               <script src="js/jquery.terminal-0.8.7.js"></script>
-       </head>
-       <body>
-               <div id="pageheader">
-                       <div id="pageheader_title"><h1><span>Nit</span> - Online IDE</h1></div>
-                       <ul id="navigation">
-                               <li>
-                                       <span id="filename">Untitled</span>.nit
-                               </li>
-                               <li>
-                                       <button type="button" onclick="save()">Save</button>
-                               </li>
-                               <li>
-                                       <button type="button" onclick="interpret()">Run</button>
-                               </li>
-                       </ul>
-               </div>
-               <div style="clear:both;"></div>
-               <div id="editor">print "Hello World !"</div>
-               <div id="terminal"></div>
-               <div id="listener">
-                       <!-- Listeners calling functions in pnacl_js.js -->
-                       <script type="text/javascript">
-                               var listener = document.getElementById('listener');
-                               listener.addEventListener('load', moduleDidLoad, true);
-                               listener.addEventListener('message', handleMessage, true);
-                               listener.addEventListener('crash', handleCrash, true);
-                       </script>
-                       <!-- Embed bloc referencing to the manifest -->
-                       <embed id="pnacl_nit"
-                               width=0 height=0
-                               src="pnacl/pnacl_nit.nmf"
-                               type="application/x-pnacl" />
-               </div>
-               <script src="js/editor_configuration.js"></script>
-               <script src="js/FileSaver.js"></script>
-               <script src="js/functions.js"></script>
-       </body>
-</html>
diff --git a/contrib/online_ide/www/js/FileSaver.js b/contrib/online_ide/www/js/FileSaver.js
deleted file mode 100644 (file)
index 6095017..0000000
+++ /dev/null
@@ -1,241 +0,0 @@
-/* FileSaver.js
- *  A saveAs() FileSaver implementation.
- *  2014-05-27
- *
- *  By Eli Grey, http://eligrey.com
- *  License: X11/MIT
- *    See https://github.com/eligrey/FileSaver.js/blob/master/LICENSE.md
- */
-
-/*global self */
-/*jslint bitwise: true, indent: 4, laxbreak: true, laxcomma: true, smarttabs: true, plusplus: true */
-
-/*! @source http://purl.eligrey.com/github/FileSaver.js/blob/master/FileSaver.js */
-
-var saveAs = saveAs
-  // IE 10+ (native saveAs)
-  || (typeof navigator !== "undefined" &&
-      navigator.msSaveOrOpenBlob && navigator.msSaveOrOpenBlob.bind(navigator))
-  // Everyone else
-  || (function(view) {
-       "use strict";
-       // IE <10 is explicitly unsupported
-       if (typeof navigator !== "undefined" &&
-           /MSIE [1-9]\./.test(navigator.userAgent)) {
-               return;
-       }
-       var
-                 doc = view.document
-                 // only get URL when necessary in case Blob.js hasn't overridden it yet
-               , get_URL = function() {
-                       return view.URL || view.webkitURL || view;
-               }
-               , save_link = doc.createElementNS("http://www.w3.org/1999/xhtml", "a")
-               , can_use_save_link = !view.externalHost && "download" in save_link
-               , click = function(node) {
-                       var event = doc.createEvent("MouseEvents");
-                       event.initMouseEvent(
-                               "click", true, false, view, 0, 0, 0, 0, 0
-                               , false, false, false, false, 0, null
-                       );
-                       node.dispatchEvent(event);
-               }
-               , webkit_req_fs = view.webkitRequestFileSystem
-               , req_fs = view.requestFileSystem || webkit_req_fs || view.mozRequestFileSystem
-               , throw_outside = function(ex) {
-                       (view.setImmediate || view.setTimeout)(function() {
-                               throw ex;
-                       }, 0);
-               }
-               , force_saveable_type = "application/octet-stream"
-               , fs_min_size = 0
-               , deletion_queue = []
-               , process_deletion_queue = function() {
-                       var i = deletion_queue.length;
-                       while (i--) {
-                               var file = deletion_queue[i];
-                               if (typeof file === "string") { // file is an object URL
-                                       get_URL().revokeObjectURL(file);
-                               } else { // file is a File
-                                       file.remove();
-                               }
-                       }
-                       deletion_queue.length = 0; // clear queue
-               }
-               , dispatch = function(filesaver, event_types, event) {
-                       event_types = [].concat(event_types);
-                       var i = event_types.length;
-                       while (i--) {
-                               var listener = filesaver["on" + event_types[i]];
-                               if (typeof listener === "function") {
-                                       try {
-                                               listener.call(filesaver, event || filesaver);
-                                       } catch (ex) {
-                                               throw_outside(ex);
-                                       }
-                               }
-                       }
-               }
-               , FileSaver = function(blob, name) {
-                       // First try a.download, then web filesystem, then object URLs
-                       var
-                                 filesaver = this
-                               , type = blob.type
-                               , blob_changed = false
-                               , object_url
-                               , target_view
-                               , get_object_url = function() {
-                                       var object_url = get_URL().createObjectURL(blob);
-                                       deletion_queue.push(object_url);
-                                       return object_url;
-                               }
-                               , dispatch_all = function() {
-                                       dispatch(filesaver, "writestart progress write writeend".split(" "));
-                               }
-                               // on any filesys errors revert to saving with object URLs
-                               , fs_error = function() {
-                                       // don't create more object URLs than needed
-                                       if (blob_changed || !object_url) {
-                                               object_url = get_object_url(blob);
-                                       }
-                                       if (target_view) {
-                                               target_view.location.href = object_url;
-                                       } else {
-                                               window.open(object_url, "_blank");
-                                       }
-                                       filesaver.readyState = filesaver.DONE;
-                                       dispatch_all();
-                               }
-                               , abortable = function(func) {
-                                       return function() {
-                                               if (filesaver.readyState !== filesaver.DONE) {
-                                                       return func.apply(this, arguments);
-                                               }
-                                       };
-                               }
-                               , create_if_not_found = {create: true, exclusive: false}
-                               , slice
-                       ;
-                       filesaver.readyState = filesaver.INIT;
-                       if (!name) {
-                               name = "download";
-                       }
-                       if (can_use_save_link) {
-                               object_url = get_object_url(blob);
-                               save_link.href = object_url;
-                               save_link.download = name;
-                               click(save_link);
-                               filesaver.readyState = filesaver.DONE;
-                               dispatch_all();
-                               return;
-                       }
-                       // Object and web filesystem URLs have a problem saving in Google Chrome when
-                       // viewed in a tab, so I force save with application/octet-stream
-                       // http://code.google.com/p/chromium/issues/detail?id=91158
-                       if (view.chrome && type && type !== force_saveable_type) {
-                               slice = blob.slice || blob.webkitSlice;
-                               blob = slice.call(blob, 0, blob.size, force_saveable_type);
-                               blob_changed = true;
-                       }
-                       // Since I can't be sure that the guessed media type will trigger a download
-                       // in WebKit, I append .download to the filename.
-                       // https://bugs.webkit.org/show_bug.cgi?id=65440
-                       if (webkit_req_fs && name !== "download") {
-                               name += ".download";
-                       }
-                       if (type === force_saveable_type || webkit_req_fs) {
-                               target_view = view;
-                       }
-                       if (!req_fs) {
-                               fs_error();
-                               return;
-                       }
-                       fs_min_size += blob.size;
-                       req_fs(view.TEMPORARY, fs_min_size, abortable(function(fs) {
-                               fs.root.getDirectory("saved", create_if_not_found, abortable(function(dir) {
-                                       var save = function() {
-                                               dir.getFile(name, create_if_not_found, abortable(function(file) {
-                                                       file.createWriter(abortable(function(writer) {
-                                                               writer.onwriteend = function(event) {
-                                                                       target_view.location.href = file.toURL();
-                                                                       deletion_queue.push(file);
-                                                                       filesaver.readyState = filesaver.DONE;
-                                                                       dispatch(filesaver, "writeend", event);
-                                                               };
-                                                               writer.onerror = function() {
-                                                                       var error = writer.error;
-                                                                       if (error.code !== error.ABORT_ERR) {
-                                                                               fs_error();
-                                                                       }
-                                                               };
-                                                               "writestart progress write abort".split(" ").forEach(function(event) {
-                                                                       writer["on" + event] = filesaver["on" + event];
-                                                               });
-                                                               writer.write(blob);
-                                                               filesaver.abort = function() {
-                                                                       writer.abort();
-                                                                       filesaver.readyState = filesaver.DONE;
-                                                               };
-                                                               filesaver.readyState = filesaver.WRITING;
-                                                       }), fs_error);
-                                               }), fs_error);
-                                       };
-                                       dir.getFile(name, {create: false}, abortable(function(file) {
-                                               // delete file if it already exists
-                                               file.remove();
-                                               save();
-                                       }), abortable(function(ex) {
-                                               if (ex.code === ex.NOT_FOUND_ERR) {
-                                                       save();
-                                               } else {
-                                                       fs_error();
-                                               }
-                                       }));
-                               }), fs_error);
-                       }), fs_error);
-               }
-               , FS_proto = FileSaver.prototype
-               , saveAs = function(blob, name) {
-                       return new FileSaver(blob, name);
-               }
-       ;
-       FS_proto.abort = function() {
-               var filesaver = this;
-               filesaver.readyState = filesaver.DONE;
-               dispatch(filesaver, "abort");
-       };
-       FS_proto.readyState = FS_proto.INIT = 0;
-       FS_proto.WRITING = 1;
-       FS_proto.DONE = 2;
-
-       FS_proto.error =
-       FS_proto.onwritestart =
-       FS_proto.onprogress =
-       FS_proto.onwrite =
-       FS_proto.onabort =
-       FS_proto.onerror =
-       FS_proto.onwriteend =
-               null;
-
-       view.addEventListener("unload", process_deletion_queue, false);
-       saveAs.unload = function() {
-               process_deletion_queue();
-               view.removeEventListener("unload", process_deletion_queue, false);
-       };
-       return saveAs;
-}(
-          typeof self !== "undefined" && self
-       || typeof window !== "undefined" && window
-       || this.content
-));
-// `self` is undefined in Firefox for Android content script context
-// while `this` is nsIContentFrameMessageManager
-// with an attribute `content` that corresponds to the window
-
-if (typeof module !== "undefined" && module !== null) {
-  module.exports = saveAs;
-} else if ((typeof define !== "undefined" && define !== null) && (define.amd != null)) {
-  define([], function() {
-    return saveAs;
-  });
-}
diff --git a/contrib/online_ide/www/js/editor_configuration.js b/contrib/online_ide/www/js/editor_configuration.js
deleted file mode 100644 (file)
index 0d67ad5..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-// This file is part of NIT ( http://www.nitlanguage.org )
-//
-// Copyright 2014 Johan Kayser <kayser.johan@gmail.com>
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//     http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-// Sets up the editor.
-
-ace.require("ace/ext/language_tools");
-var editor = ace.edit("editor");
-editor.setTheme("ace/theme/chrome");
-editor.getSession().setMode("ace/mode/nit");
-editor.setOptions({
-       enableBasicAutocompletion: true
-});
-// Custom commands
-
-// We launch the interpreter on CTRL+E shortcut.
-editor.commands.addCommand({
-       name: 'interpret',
-       bindKey: {win: 'Ctrl-E', mac: 'Command-E'},
-       exec: function(editor) {
-               interpret();
-       },
-       readOnly: true // false if this command should not apply in readOnly mode
-});
-
-// We download the current file in editor on CTRL+S shortcut.
-editor.commands.addCommand({
-       name: 'save',
-       bindKey: {win: 'Ctrl-S', mac: 'Command-S'},
-       exec: function(editor) {
-               save();
-       },
-       readOnly: true // false if this command should not apply in readOnly mode
-});
diff --git a/contrib/online_ide/www/js/functions.js b/contrib/online_ide/www/js/functions.js
deleted file mode 100644 (file)
index 688da9b..0000000
+++ /dev/null
@@ -1,192 +0,0 @@
-// This file is part of NIT ( http://www.nitlanguage.org )
-//
-// Copyright 2014 Johan Kayser <kayser.johan@gmail.com>
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//     http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-// Initializes the terminal, set it to send messages to PNaCl.
-function init_terminal() {
-       terminal = $('#terminal').terminal(function(command, term) {
-               pnacl_nitModule.postMessage(command + '\n');
-       }, { greetings: false, name: 'terminal' });
-}
-
-// Edit current file name.
-$('#filename').bind('click', function() {
-       $(this).attr('contentEditable', true);
-}).blur(
-       function() {
-               $(this).attr('contentEditable', false);
-        });
-
-// To launch the interpret process.
-function interpret() {
-       var dictionary = {
-               operation: 'interpret',
-               args: /*"-v -v " + */document.getElementById('filename').innerText + ".nit",
-               content: editor.getValue()
-       }
-       pnacl_nitModule.postMessage(dictionary);
-}
-
-// To save the current editor lines in a file.
-function save() {
-       var blob = new Blob([editor.getValue()], {type: "text/plain;charset=utf-8"});
-       saveAs(blob, document.getElementById('filename').innerText + ".nit");
-}
-
-// To load nit lib
-function load_nit_lib() {
-       if (!lib_files_loaded)
-       {
-               // We get the 'nit' folder content on github.
-               $.get("https://api.github.com/repos/nitlang/nit/contents/?access_token=" + github_acces_token, function(data) {
-                       for (var i = 0; i < data.length; i++) {
-                               if (data[i].name == "lib") {
-                                       // We get the list of all files in the 'lib' folder.
-                                       $.get("https://api.github.com/repos/nitlang/nit/git/trees/" + data[i].sha + "?recursive=1&access_token=" + github_acces_token, function(data) {
-                                               for (var i = 0; i < data.tree.length; i++) {
-                                                       if (data.tree[i].type == "blob") {
-                                                               lib_files_number++;
-                                                               sha_filename_map[data.tree[i].sha] = data.tree[i].path.split("/").pop();
-                                                       
-                                                               // We get the content of each file and send it to PNaCl.
-                                                               $.get(data.tree[i].url + "?access_token=" + github_acces_token, function(data) {
-                                                                       var dictionary = {
-                                                                               operation: 'load',
-                                                                               filename: sha_filename_map[data.sha],
-                                                                               content: Base64.decode(data.content),
-                                                                       }
-                                                                       pnacl_nitModule.postMessage(dictionary);
-                                                                       lib_files.push(dictionary);
-                                                               });
-                                                       }
-                                               }               
-                                       });
-                               }
-                       }
-               });
-        }
-        else {
-               // If we already have the files stored in JS, we just send them.
-               for (var i = 0; i < lib_files.length; i++) {
-                       pnacl_nitModule.postMessage(lib_files[i]);
-               }
-        }
-}
-
-// To code/decode base64
-var Base64 = {
-    _keyStr: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
-
-    encode: function(input) {
-        var output = "";
-        var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
-        var i = 0;
-
-        input = Base64._utf8_encode(input);
-        while (i < input.length) {
-            chr1 = input.charCodeAt(i++);
-            chr2 = input.charCodeAt(i++);
-            chr3 = input.charCodeAt(i++);
-            enc1 = chr1 >> 2;
-            enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
-            enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
-            enc4 = chr3 & 63;
-            if (isNaN(chr2)) {
-                enc3 = enc4 = 64;
-            } else if (isNaN(chr3)) {
-                enc4 = 64;
-            }
-            output = output + this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) + this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4);
-        }
-        return output;
-    },
-
-
-    decode: function(input) {
-        var output = "";
-        var chr1, chr2, chr3;
-        var enc1, enc2, enc3, enc4;
-        var i = 0;
-        
-        input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
-        while (i < input.length) {
-            enc1 = this._keyStr.indexOf(input.charAt(i++));
-            enc2 = this._keyStr.indexOf(input.charAt(i++));
-            enc3 = this._keyStr.indexOf(input.charAt(i++));
-            enc4 = this._keyStr.indexOf(input.charAt(i++));
-            chr1 = (enc1 << 2) | (enc2 >> 4);
-            chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
-            chr3 = ((enc3 & 3) << 6) | enc4;
-            output = output + String.fromCharCode(chr1);
-            if (enc3 != 64) {
-                output = output + String.fromCharCode(chr2);
-            }
-            if (enc4 != 64) {
-                output = output + String.fromCharCode(chr3);
-            }
-        }
-        output = Base64._utf8_decode(output);
-        return output;
-    },
-
-    _utf8_encode: function(string) {
-        string = string.replace(/\r\n/g, "\n");
-        var utftext = "";
-
-        for (var n = 0; n < string.length; n++) {
-            var c = string.charCodeAt(n);
-
-            if (c < 128) {
-                utftext += String.fromCharCode(c);
-            }
-            else if ((c > 127) && (c < 2048)) {
-                utftext += String.fromCharCode((c >> 6) | 192);
-                utftext += String.fromCharCode((c & 63) | 128);
-            }
-            else {
-                utftext += String.fromCharCode((c >> 12) | 224);
-                utftext += String.fromCharCode(((c >> 6) & 63) | 128);
-                utftext += String.fromCharCode((c & 63) | 128);
-            }
-        }
-        return utftext;
-    },
-
-    _utf8_decode: function(utftext) {
-        var string = "";
-        var i = 0;
-        var c = c1 = c2 = 0;
-        
-        while (i < utftext.length) {
-            c = utftext.charCodeAt(i);
-            if (c < 128) {
-                string += String.fromCharCode(c);
-                i++;
-            }
-            else if ((c > 191) && (c < 224)) {
-                c2 = utftext.charCodeAt(i + 1);
-                string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
-                i += 2;
-            }
-            else {
-                c2 = utftext.charCodeAt(i + 1);
-                c3 = utftext.charCodeAt(i + 2);
-                string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
-                i += 3;
-            }
-        }
-        return string;
-    }
-}
diff --git a/contrib/online_ide/www/js/jquery.terminal-0.8.7.js b/contrib/online_ide/www/js/jquery.terminal-0.8.7.js
deleted file mode 100644 (file)
index 5d145f3..0000000
+++ /dev/null
@@ -1,4328 +0,0 @@
-/**@license
- *       __ _____                     ________                              __
- *      / // _  /__ __ _____ ___ __ _/__  ___/__ ___ ______ __ __  __ ___  / /
- *  __ / // // // // // _  // _// // / / // _  // _//     // //  \/ // _ \/ /
- * /  / // // // // // ___// / / // / / // ___// / / / / // // /\  // // / /__
- * \___//____ \\___//____//_/ _\_  / /_//____//_/ /_/ /_//_//_/ /_/ \__\_\___/
- *           \/              /____/                              version 0.8.7
- * http://terminal.jcubic.pl
- *
- * Licensed under GNU LGPL Version 3 license
- * Copyright (c) 2011-2013 Jakub Jankiewicz <http://jcubic.pl>
- *
- * Includes:
- *
- * Storage plugin Distributed under the MIT License
- * Copyright (c) 2010 Dave Schindler
- *
- * jQuery Timers licenced with the WTFPL
- * <http://jquery.offput.ca/every/>
- *
- * Cross-Browser Split 1.1.1
- * Copyright 2007-2012 Steven Levithan <stevenlevithan.com>
- * Available under the MIT License
- *
- * sprintf.js
- * Copyright (c) 2007-2013 Alexandru Marasteanu <hello at alexei dot ro>
- * licensed under 3 clause BSD license
- *
- * Date: Sat, 22 Mar 2014 13:32:26 +0000
- *
- */
-
-(function(ctx) {
-    var sprintf = function() {
-        if (!sprintf.cache.hasOwnProperty(arguments[0])) {
-            sprintf.cache[arguments[0]] = sprintf.parse(arguments[0]);
-        }
-        return sprintf.format.call(null, sprintf.cache[arguments[0]], arguments);
-    };
-
-    sprintf.format = function(parse_tree, argv) {
-        var cursor = 1, tree_length = parse_tree.length, node_type = '', arg, output = [], i, k, match, pad, pad_character, pad_length;
-        for (i = 0; i < tree_length; i++) {
-            node_type = get_type(parse_tree[i]);
-            if (node_type === 'string') {
-                output.push(parse_tree[i]);
-            }
-            else if (node_type === 'array') {
-                match = parse_tree[i]; // convenience purposes only
-                if (match[2]) { // keyword argument
-                    arg = argv[cursor];
-                    for (k = 0; k < match[2].length; k++) {
-                        if (!arg.hasOwnProperty(match[2][k])) {
-                            throw(sprintf('[sprintf] property "%s" does not exist', match[2][k]));
-                        }
-                        arg = arg[match[2][k]];
-                    }
-                }
-                else if (match[1]) { // positional argument (explicit)
-                    arg = argv[match[1]];
-                }
-                else { // positional argument (implicit)
-                    arg = argv[cursor++];
-                }
-
-                if (/[^s]/.test(match[8]) && (get_type(arg) != 'number')) {
-                    throw(sprintf('[sprintf] expecting number but found %s', get_type(arg)));
-                }
-                switch (match[8]) {
-                    case 'b': arg = arg.toString(2); break;
-                    case 'c': arg = String.fromCharCode(arg); break;
-                    case 'd': arg = parseInt(arg, 10); break;
-                    case 'e': arg = match[7] ? arg.toExponential(match[7]) : arg.toExponential(); break;
-                    case 'f': arg = match[7] ? parseFloat(arg).toFixed(match[7]) : parseFloat(arg); break;
-                    case 'o': arg = arg.toString(8); break;
-                    case 's': arg = ((arg = String(arg)) && match[7] ? arg.substring(0, match[7]) : arg); break;
-                    case 'u': arg = arg >>> 0; break;
-                    case 'x': arg = arg.toString(16); break;
-                    case 'X': arg = arg.toString(16).toUpperCase(); break;
-                }
-                arg = (/[def]/.test(match[8]) && match[3] && arg >= 0 ? '+'+ arg : arg);
-                pad_character = match[4] ? match[4] == '0' ? '0' : match[4].charAt(1) : ' ';
-                pad_length = match[6] - String(arg).length;
-                pad = match[6] ? str_repeat(pad_character, pad_length) : '';
-                output.push(match[5] ? arg + pad : pad + arg);
-            }
-        }
-        return output.join('');
-    };
-
-    sprintf.cache = {};
-
-    sprintf.parse = function(fmt) {
-        var _fmt = fmt, match = [], parse_tree = [], arg_names = 0;
-        while (_fmt) {
-            if ((match = /^[^\x25]+/.exec(_fmt)) !== null) {
-                parse_tree.push(match[0]);
-            }
-            else if ((match = /^\x25{2}/.exec(_fmt)) !== null) {
-                parse_tree.push('%');
-            }
-            else if ((match = /^\x25(?:([1-9]\d*)\$|\(([^\)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-fosuxX])/.exec(_fmt)) !== null) {
-                if (match[2]) {
-                    arg_names |= 1;
-                    var field_list = [], replacement_field = match[2], field_match = [];
-                    if ((field_match = /^([a-z_][a-z_\d]*)/i.exec(replacement_field)) !== null) {
-                        field_list.push(field_match[1]);
-                        while ((replacement_field = replacement_field.substring(field_match[0].length)) !== '') {
-                            if ((field_match = /^\.([a-z_][a-z_\d]*)/i.exec(replacement_field)) !== null) {
-                                field_list.push(field_match[1]);
-                            }
-                            else if ((field_match = /^\[(\d+)\]/.exec(replacement_field)) !== null) {
-                                field_list.push(field_match[1]);
-                            }
-                            else {
-                                throw('[sprintf] huh?');
-                            }
-                        }
-                    }
-                    else {
-                        throw('[sprintf] huh?');
-                    }
-                    match[2] = field_list;
-                }
-                else {
-                    arg_names |= 2;
-                }
-                if (arg_names === 3) {
-                    throw('[sprintf] mixing positional and named placeholders is not (yet) supported');
-                }
-                parse_tree.push(match);
-            }
-            else {
-                throw('[sprintf] huh?');
-            }
-            _fmt = _fmt.substring(match[0].length);
-        }
-        return parse_tree;
-    };
-
-    var vsprintf = function(fmt, argv, _argv) {
-        _argv = argv.slice(0);
-        _argv.splice(0, 0, fmt);
-        return sprintf.apply(null, _argv);
-    };
-
-    /**
-     * helpers
-     */
-    function get_type(variable) {
-        return Object.prototype.toString.call(variable).slice(8, -1).toLowerCase();
-    }
-
-    function str_repeat(input, multiplier) {
-        for (var output = []; multiplier > 0; output[--multiplier] = input) {/* do nothing */}
-        return output.join('');
-    }
-
-    /**
-     * export to either browser or node.js
-     */
-    ctx.sprintf = sprintf;
-    ctx.vsprintf = vsprintf;
-})(typeof exports != "undefined" ? exports : window);
-
-(function($, undefined) {
-    "use strict";
-    // -----------------------------------------------------------------------
-    // :: map object to object
-    // -----------------------------------------------------------------------
-    $.omap = function(o, fn) {
-        var result = {};
-        $.each(o, function(k, v) {
-            result[k] = fn.call(o, k, v);
-        });
-        return result;
-    };
-    // -----------------------------------------------------------------------
-    // :: Storage plugin
-    // -----------------------------------------------------------------------
-    // Private data
-    var isLS = typeof window.localStorage !== 'undefined';
-    // Private functions
-    function wls(n, v) {
-        var c;
-        if (typeof n === 'string' && typeof v === 'string') {
-            localStorage[n] = v;
-            return true;
-        } else if (typeof n === 'object' && typeof v === 'undefined') {
-            for (c in n) {
-                if (n.hasOwnProperty(c)) {
-                    localStorage[c] = n[c];
-                }
-            }
-            return true;
-        }
-        return false;
-    }
-    function wc(n, v) {
-        var dt, e, c;
-        dt = new Date();
-        dt.setTime(dt.getTime() + 31536000000);
-        e = '; expires=' + dt.toGMTString();
-        if (typeof n === 'string' && typeof v === 'string') {
-            document.cookie = n + '=' + v + e + '; path=/';
-            return true;
-        } else if (typeof n === 'object' && typeof v === 'undefined') {
-            for (c in n) {
-                if (n.hasOwnProperty(c)) {
-                    document.cookie = c + '=' + n[c] + e + '; path=/';
-                }
-            }
-            return true;
-        }
-        return false;
-    }
-    function rls(n) {
-        return localStorage[n];
-    }
-    function rc(n) {
-        var nn, ca, i, c;
-        nn = n + '=';
-        ca = document.cookie.split(';');
-        for (i = 0; i < ca.length; i++) {
-            c = ca[i];
-            while (c.charAt(0) === ' ') {
-                c = c.substring(1, c.length);
-            }
-            if (c.indexOf(nn) === 0) {
-                return c.substring(nn.length, c.length);
-            }
-        }
-        return null;
-    }
-    function dls(n) {
-        return delete localStorage[n];
-    }
-    function dc(n) {
-        return wc(n, '', -1);
-    }
-    /**
-    * Public API
-    * $.Storage.set("name", "value")
-    * $.Storage.set({"name1":"value1", "name2":"value2", etc})
-    * $.Storage.get("name")
-    * $.Storage.remove("name")
-    */
-    $.extend({
-        Storage: {
-            set: isLS ? wls : wc,
-            get: isLS ? rls : rc,
-            remove: isLS ? dls : dc
-        }
-    });
-    // -----------------------------------------------------------------------
-    // :: jQuery Timers
-    // -----------------------------------------------------------------------
-    jQuery.fn.extend({
-        everyTime: function(interval, label, fn, times, belay) {
-            return this.each(function() {
-                jQuery.timer.add(this, interval, label, fn, times, belay);
-            });
-        },
-        oneTime: function(interval, label, fn) {
-            return this.each(function() {
-                jQuery.timer.add(this, interval, label, fn, 1);
-            });
-        },
-        stopTime: function(label, fn) {
-            return this.each(function() {
-                jQuery.timer.remove(this, label, fn);
-            });
-        }
-    });
-
-    jQuery.extend({
-        timer: {
-            guid: 1,
-            global: {},
-            regex: /^([0-9]+)\s*(.*s)?$/,
-            powers: {
-                // Yeah this is major overkill...
-                'ms': 1,
-                'cs': 10,
-                'ds': 100,
-                's': 1000,
-                'das': 10000,
-                'hs': 100000,
-                'ks': 1000000
-            },
-            timeParse: function(value) {
-                if (value === undefined || value === null) {
-                    return null;
-                }
-                var result = this.regex.exec(jQuery.trim(value.toString()));
-                if (result[2]) {
-                    var num = parseInt(result[1], 10);
-                    var mult = this.powers[result[2]] || 1;
-                    return num * mult;
-                } else {
-                    return value;
-                }
-            },
-            add: function(element, interval, label, fn, times, belay) {
-                var counter = 0;
-
-                if (jQuery.isFunction(label)) {
-                    if (!times) {
-                        times = fn;
-                    }
-                    fn = label;
-                    label = interval;
-                }
-
-                interval = jQuery.timer.timeParse(interval);
-
-                if (typeof interval !== 'number' ||
-                    isNaN(interval) ||
-                    interval <= 0) {
-                    return;
-                }
-                if (times && times.constructor !== Number) {
-                    belay = !!times;
-                    times = 0;
-                }
-
-                times = times || 0;
-                belay = belay || false;
-
-                if (!element.$timers) {
-                    element.$timers = {};
-                }
-                if (!element.$timers[label]) {
-                    element.$timers[label] = {};
-                }
-                fn.$timerID = fn.$timerID || this.guid++;
-
-                var handler = function() {
-                    if (belay && handler.inProgress) {
-                        return;
-                    }
-                    handler.inProgress = true;
-                    if ((++counter > times && times !== 0) ||
-                        fn.call(element, counter) === false) {
-                        jQuery.timer.remove(element, label, fn);
-                    }
-                    handler.inProgress = false;
-                };
-
-                handler.$timerID = fn.$timerID;
-
-                if (!element.$timers[label][fn.$timerID]) {
-                    element.$timers[label][fn.$timerID] = window.setInterval(handler, interval);
-                }
-
-                if (!this.global[label]) {
-                    this.global[label] = [];
-                }
-                this.global[label].push(element);
-
-            },
-            remove: function(element, label, fn) {
-                var timers = element.$timers, ret;
-
-                if (timers) {
-
-                    if (!label) {
-                        for (var lab in timers) {
-                            if (timers.hasOwnProperty(lab)) {
-                                this.remove(element, lab, fn);
-                            }
-                        }
-                    } else if (timers[label]) {
-                        if (fn) {
-                            if (fn.$timerID) {
-                                window.clearInterval(timers[label][fn.$timerID]);
-                                delete timers[label][fn.$timerID];
-                            }
-                        } else {
-                            for (var _fn in timers[label]) {
-                                if (timers[label].hasOwnProperty(_fn)) {
-                                    window.clearInterval(timers[label][_fn]);
-                                    delete timers[label][_fn];
-                                }
-                            }
-                        }
-
-                        for (ret in timers[label]) {
-                            if (timers[label].hasOwnProperty(ret)) {
-                                break;
-                            }
-                        }
-                        if (!ret) {
-                            ret = null;
-                            delete timers[label];
-                        }
-                    }
-
-                    for (ret in timers) {
-                        if (timers.hasOwnProperty(ret)) {
-                            break;
-                        }
-                    }
-                    if (!ret) {
-                        element.$timers = null;
-                    }
-                }
-            }
-        }
-    });
-
-    if (/(msie) ([\w.]+)/.exec(navigator.userAgent.toLowerCase())) {
-        jQuery(window).one('unload', function() {
-            var global = jQuery.timer.global;
-            for (var label in global) {
-                if (global.hasOwnProperty(label)) {
-                    var els = global[label], i = els.length;
-                    while (--i) {
-                        jQuery.timer.remove(els[i], label);
-                    }
-                }
-            }
-        });
-    }
-    // -----------------------------------------------------------------------
-    // :: CROSS BROWSER SPLIT
-    // -----------------------------------------------------------------------
-
-    (function(undef) {
-
-        // prevent double include
-
-        if (!String.prototype.split.toString().match(/\[native/)) {
-            return;
-        }
-
-        var nativeSplit = String.prototype.split,
-        compliantExecNpcg = /()??/.exec("")[1] === undef, // NPCG: nonparticipating capturing group
-        self;
-
-        self = function (str, separator, limit) {
-            // If `separator` is not a regex, use `nativeSplit`
-            if (Object.prototype.toString.call(separator) !== "[object RegExp]") {
-                return nativeSplit.call(str, separator, limit);
-            }
-            var output = [],
-            flags = (separator.ignoreCase ? "i" : "") +
-                (separator.multiline  ? "m" : "") +
-                (separator.extended   ? "x" : "") + // Proposed for ES6
-                (separator.sticky     ? "y" : ""), // Firefox 3+
-                lastLastIndex = 0,
-            // Make `global` and avoid `lastIndex` issues by working with a copy
-            separator2, match, lastIndex, lastLength;
-            separator = new RegExp(separator.source, flags + "g");
-            str += ""; // Type-convert
-            if (!compliantExecNpcg) {
-                // Doesn't need flags gy, but they don't hurt
-                separator2 = new RegExp("^" + separator.source + "$(?!\\s)", flags);
-            }
-            /* Values for `limit`, per the spec:
-         * If undefined: 4294967295 // Math.pow(2, 32) - 1
-         * If 0, Infinity, or NaN: 0
-         * If positive number: limit = Math.floor(limit); if (limit > 4294967295) limit -= 4294967296;
-         * If negative number: 4294967296 - Math.floor(Math.abs(limit))
-         * If other: Type-convert, then use the above rules
-         */
-            // ? Math.pow(2, 32) - 1 : ToUint32(limit)
-            limit = limit === undef ? -1 >>> 0 : limit >>> 0;
-            while (match = separator.exec(str)) {
-                    // `separator.lastIndex` is not reliable cross-browser
-                    lastIndex = match.index + match[0].length;
-                    if (lastIndex > lastLastIndex) {
-                        output.push(str.slice(lastLastIndex, match.index));
-                        // Fix browsers whose `exec` methods don't consistently return `undefined` for
-                        // nonparticipating capturing groups
-                        if (!compliantExecNpcg && match.length > 1) {
-                            match[0].replace(separator2, function () {
-                                for (var i = 1; i < arguments.length - 2; i++) {
-                                    if (arguments[i] === undef) {
-                                        match[i] = undef;
-                                    }
-                                }
-                            });
-                        }
-                        if (match.length > 1 && match.index < str.length) {
-                            Array.prototype.push.apply(output, match.slice(1));
-                        }
-                        lastLength = match[0].length;
-                        lastLastIndex = lastIndex;
-                        if (output.length >= limit) {
-                            break;
-                        }
-                    }
-                    if (separator.lastIndex === match.index) {
-                        separator.lastIndex++; // Avoid an infinite loop
-                    }
-                }
-            if (lastLastIndex === str.length) {
-                if (lastLength || !separator.test("")) {
-                    output.push("");
-                }
-            } else {
-                output.push(str.slice(lastLastIndex));
-            }
-            return output.length > limit ? output.slice(0, limit) : output;
-        };
-
-        // For convenience
-        String.prototype.split = function (separator, limit) {
-            return self(this, separator, limit);
-        };
-
-        return self;
-
-    })();
-    // -----------------------------------------------------------------------
-    // :: Split string to array of strings with the same length
-    // -----------------------------------------------------------------------
-    function str_parts(str, length) {
-        var result = [];
-        var len = str.length;
-        if (len < length) {
-            return [str];
-        }
-        for (var i = 0; i < len; i += length) {
-            result.push(str.substring(i, i + length));
-        }
-        return result;
-    }
-    // -----------------------------------------------------------------------
-    // :: CYCLE DATA STRUCTURE
-    // -----------------------------------------------------------------------
-    function Cycle(init) {
-        var data = init ? [init] : [];
-        var pos = 0;
-        $.extend(this, {
-            get: function() {
-                return data;
-            },
-            rotate: function() {
-                if (data.length === 1) {
-                    return data[0];
-                } else {
-                    if (pos === data.length - 1) {
-                        pos = 0;
-                    } else {
-                        ++pos;
-                    }
-                    return data[pos];
-                }
-            },
-            length: function() {
-                return data.length;
-            },
-            set: function(item) {
-                for (var i = data.length; i--;) {
-                    if (data[i] === item) {
-                        pos = i;
-                        return;
-                    }
-                }
-                this.append(item);
-            },
-            front: function() {
-                return data[pos];
-            },
-            append: function(item) {
-                data.push(item);
-            }
-        });
-    }
-    // -----------------------------------------------------------------------
-    // :: STACK DATA STRUCTURE
-    // -----------------------------------------------------------------------
-    function Stack(init) {
-        var data = init ? [init] : [];
-        $.extend(this, {
-            map: function(fn) {
-                return $.map(data, fn);
-            },
-            size: function() {
-                return data.length;
-            },
-            pop: function() {
-                if (data.length === 0) {
-                    return null;
-                } else {
-                    var value = data[data.length - 1];
-                    data = data.slice(0, data.length - 1);
-                    return value;
-                }
-            },
-            push: function(value) {
-                data = data.concat([value]);
-                return value;
-            },
-            top: function() {
-                return data.length > 0 ? data[data.length - 1] : null;
-            }
-        });
-    }
-    // -----------------------------------------------------------------------
-    // :: Serialize object myself (biwascheme or prototype library do something
-    // :: wicked with JSON serialization for Arrays)
-    // -----------------------------------------------------------------------
-    $.json_stringify = function(object, level) {
-        var result = '', i;
-        level = level === undefined ? 1 : level;
-        var type = typeof object;
-        switch (type) {
-        case 'function':
-            result += object;
-            break;
-        case 'boolean':
-            result += object ? 'true' : 'false';
-            break;
-        case 'object':
-            if (object === null) {
-                result += 'null';
-            } else if (object instanceof Array) {
-                result += '[';
-                var len = object.length;
-                for (i = 0; i < len - 1; ++i) {
-                    result += $.json_stringify(object[i], level + 1);
-                }
-                result += $.json_stringify(object[len - 1], level + 1) + ']';
-            } else {
-                result += '{';
-                for (var property in object) {
-                    if (object.hasOwnProperty(property)) {
-                        result += '"' + property + '":' +
-                            $.json_stringify(object[property], level + 1);
-                    }
-                }
-                result += '}';
-            }
-            break;
-        case 'string':
-            var str = object;
-            var repl = {
-                '\\\\': '\\\\',
-                '"': '\\"',
-                '/': '\\/',
-                '\\n': '\\n',
-                '\\r': '\\r',
-                '\\t': '\\t'};
-            for (i in repl) {
-                if (repl.hasOwnProperty(i)) {
-                    str = str.replace(new RegExp(i, 'g'), repl[i]);
-                }
-            }
-            result += '"' + str + '"';
-            break;
-        case 'number':
-            result += String(object);
-            break;
-        }
-        result += (level > 1 ? ',' : '');
-        // quick hacks below
-        if (level === 1) {
-            // fix last comma
-            result = result.replace(/,([\]}])/g, '$1');
-        }
-        // fix comma before array or object
-        return result.replace(/([\[{]),/g, '$1');
-    };
-    // -----------------------------------------------------------------------
-    // :: HISTORY CLASS
-    // -----------------------------------------------------------------------
-    function History(name, size) {
-        var enabled = true;
-        var storage_key = '';
-        if (typeof name === 'string' && name !== '') {
-            storage_key = name + '_';
-        }
-        storage_key += 'commands';
-        var data = $.Storage.get(storage_key);
-        data = data ? $.parseJSON(data) : [];
-        var pos = data.length-1;
-        $.extend(this, {
-            append: function(item) {
-                if (enabled) {
-                    if (data[data.length-1] !== item) {
-                        data.push(item);
-                        if (size && data.length > size) {
-                            data = data.slice(-size);
-                        }
-                        pos = data.length-1;
-                        $.Storage.set(storage_key, $.json_stringify(data));
-                    }
-                }
-            },
-            data: function() {
-                return data;
-            },
-            reset: function() {
-                pos = data.length-1;
-            },
-            last: function() {
-                return data[length-1];
-            },
-            end: function() {
-                return pos === data.length-1;
-            },
-            position: function() {
-                return pos;
-            },
-            current: function() {
-                return data[pos];
-            },
-            next: function() {
-                if (pos < data.length-1) {
-                    ++pos;
-                }
-                if (pos !== -1) {
-                    return data[pos];
-                }
-            },
-            previous: function() {
-                var old = pos;
-                if (pos > 0) {
-                    --pos;
-                }
-                if (old !== -1) {
-                    return data[pos];
-                }
-            },
-            clear: function() {
-                data = [];
-                this.purge();
-            },
-            enabled: function() {
-                return enabled;
-            },
-            enable: function() {
-                enabled = true;
-            },
-            purge: function() {
-                $.Storage.remove(storage_key);
-            },
-            disable: function() {
-                enabled = false;
-            }
-        });
-    }
-    // -----------------------------------------------------------------------
-    // :: COMMAND LINE PLUGIN
-    // -----------------------------------------------------------------------
-    $.fn.cmd = function(options) {
-        var self = this;
-        var maybe_data = self.data('cmd');
-        if (maybe_data) {
-            return maybe_data;
-        }
-        self.addClass('cmd');
-        self.append('<span class="prompt"></span><span></span>' +
-                    '<span class="cursor">&nbsp;</span><span></span>');
-        var clip = $('<textarea/>').addClass('clipboard').appendTo(self);
-        if (options.width) {
-            self.width(options.width);
-        }
-        var num_chars; // calculated by draw_prompt
-        var prompt_len;
-        var reverse_search = false;
-        var reverse_search_string = '';
-        var reverse_search_position = null;
-        var backup_prompt;
-        var mask = options.mask || false;
-        var command = '';
-        var selected_text = ''; // text from selection using CTRL+SHIFT+C (as in Xterm)
-        var kill_text = ''; // text from command that kill part of the command
-        var position = 0;
-        var prompt;
-        var enabled = options.enabled;
-        var historySize = options.historySize || 60;
-        var name, history;
-        var cursor = self.find('.cursor');
-        var animation;
-        if (supportAnimations()) {
-            animation = function(toggle) {
-                if (toggle) {
-                    cursor.addClass('blink');
-                } else {
-                    cursor.removeClass('blink');
-                }
-            };
-        } else {
-            animation = function(toggle) {
-                if (toggle && !enabled) {
-                    cursor.addClass('inverted');
-                    self.everyTime(500, 'blink', blink);
-                } else if (enabled) {
-                    self.stopTime('blink', blink);
-                    cursor.removeClass('inverted');
-                }
-            };
-        }
-        // -----------------------------------------------------------------------
-        // :: Blinking cursor function
-        // -----------------------------------------------------------------------
-        function blink(i) {
-            cursor.toggleClass('inverted');
-        }
-        // -----------------------------------------------------------------------
-        // :: Set prompt for reverse search
-        // -----------------------------------------------------------------------
-        function draw_reverse_prompt() {
-            prompt = "(reverse-i-search)`" + reverse_search_string + "': ";
-            draw_prompt();
-        }
-        // -----------------------------------------------------------------------
-        // :: Disable reverse search
-        // -----------------------------------------------------------------------
-        function clear_reverse_state() {
-            prompt = backup_prompt;
-            reverse_search = false;
-            reverse_search_position = null;
-            reverse_search_string = '';
-        }
-        // -----------------------------------------------------------------------
-        // :: Search through command line history. If next is not defined or false
-        // :: it searches for the first item from the end. If true it search for 
-        // :: the next item
-        // -----------------------------------------------------------------------
-        function reverse_history_search(next) {
-            var history_data = history.data();
-            var regex, save_string;
-            var len = history_data.length;
-            if (next && reverse_search_position > 0) {
-                len -= reverse_search_position;
-            }
-            if (reverse_search_string.length > 0) {
-                for (var j=reverse_search_string.length; j>0; j--) {
-                    save_string = reverse_search_string.substring(0, j).
-                        replace(/([.*+{}\[\]?])/g, '\\$1');
-                    regex = new RegExp(save_string);
-                    for (var i=len; i--;) {
-                        if (regex.test(history_data[i])) {
-                            reverse_search_position = history_data.length - i;
-                            position = 0;
-                            self.set(history_data[i], true);
-                            redraw();
-                            if (reverse_search_string.length !== j) {
-                                reverse_search_string = reverse_search_string.substring(0, j);
-                                draw_reverse_prompt();
-                            }
-                            return;
-                        }
-                    }
-                }
-            }
-            reverse_search_string = ''; // clear if not found any
-        }
-        // -----------------------------------------------------------------------
-        // :: Recalculate number of characters in command line
-        // -----------------------------------------------------------------------
-        function change_num_chars() {
-            var W = self.width();
-            var w = cursor.innerWidth();
-            num_chars = Math.floor(W / w);
-        }
-        // -----------------------------------------------------------------------
-        // :: Return string repeated n times
-        // -----------------------------------------------------------------------
-        function str_repeat(str, n) {
-            var result = '';
-            for (var i = n; i--;) {
-                result += str;
-            }
-            return result;
-        }
-        // -----------------------------------------------------------------------
-        // :: Split String that fit into command line where first line need to
-        // :: fit next to prompt (need to have less characters)
-        // -----------------------------------------------------------------------
-        function get_splited_command_line(string) {
-            var first = string.substring(0, num_chars - prompt_len);
-            var rest = string.substring(num_chars - prompt_len);
-            return [first].concat(str_parts(rest, num_chars));
-        }
-        // -----------------------------------------------------------------------
-        // :: Function that displays the command line. Split long lines and place
-        // :: cursor in the right place
-        // -----------------------------------------------------------------------
-        var redraw = (function(self) {
-            var before = cursor.prev();
-            var after = cursor.next();
-            // -----------------------------------------------------------------------
-            // :: Draw line with the cursor
-            // -----------------------------------------------------------------------
-            function draw_cursor_line(string, position) {
-                var len = string.length;
-                if (position === len) {
-                    before.html($.terminal.encode(string, true));
-                    cursor.html('&nbsp;');
-                    after.html('');
-                } else if (position === 0) {
-                    before.html('');
-                    //fix for tilda in IE
-                    cursor.html($.terminal.encode(string.slice(0, 1), true));
-                    //cursor.html($.terminal.encode(string[0]));
-                    after.html($.terminal.encode(string.slice(1), true));
-                } else {
-                    var before_str = $.terminal.encode(string.slice(0, position), true);
-                    before.html(before_str);
-                    //fix for tilda in IE
-                    var c = string.slice(position, position + 1);
-                    //cursor.html(string[position]));
-                    cursor.html(c === ' ' ? '&nbsp;' : $.terminal.encode(c, true));
-                    if (position === string.length - 1) {
-                        after.html('');
-                    } else {
-                        after.html($.terminal.encode(string.slice(position + 1), true));
-                    }
-                }
-            }
-            function div(string) {
-                return '<div>' + $.terminal.encode(string, true) + '</div>';
-            }
-            // -----------------------------------------------------------------------
-            // :: Display lines after the cursor
-            // -----------------------------------------------------------------------
-            function lines_after(lines) {
-                var last_ins = after;
-                $.each(lines, function(i, line) {
-                    last_ins = $(div(line)).insertAfter(last_ins).
-                        addClass('clear');
-                });
-            }
-            // -----------------------------------------------------------------------
-            // :: Display lines before the cursor
-            // -----------------------------------------------------------------------
-            function lines_before(lines) {
-                $.each(lines, function(i, line) {
-                    before.before(div(line));
-                });
-            }
-            var count = 0;
-            // -----------------------------------------------------------------------
-            // :: Redraw function
-            // -----------------------------------------------------------------------
-            return function() {
-                var string = mask ? command.replace(/./g, '*') : command;
-                var i, first_len;
-                self.find('div').remove();
-                before.html('');
-                // long line
-                if (string.length > num_chars - prompt_len - 1 ||
-                    string.match(/\n/)) {
-                    var array;
-                    var tabs = string.match(/\t/g);
-                    var tabs_rm = tabs ? tabs.length * 3 : 0;
-                    //quick tabulation hack
-                    if (tabs) {
-                        string = string.replace(/\t/g, '\x00\x00\x00\x00');
-                    }
-                    // command contains new line characters
-                    if (string.match(/\n/)) {
-                        var tmp = string.split("\n");
-                        first_len = num_chars - prompt_len - 1;
-                        // empty character after each line
-                        for (i=0; i<tmp.length-1; ++i) {
-                            tmp[i] += ' ';
-                        }
-                        // split first line
-                        if (tmp[0].length > first_len) {
-                            array = [tmp[0].substring(0, first_len)];
-                            array = array.concat(str_parts(tmp[0].substring(first_len), num_chars));
-                        } else {
-                            array = [tmp[0]];
-                        }
-                        // process rest of the lines
-                        for (i=1; i<tmp.length; ++i) {
-                            if (tmp[i].length > num_chars) {
-                                array = array.concat(str_parts(tmp[i], num_chars));
-                            } else {
-                                array.push(tmp[i]);
-                            }
-                        }
-                    } else {
-                        array = get_splited_command_line(string);
-                    }
-                    if (tabs) {
-                        array = $.map(array, function(line) {
-                            return line.replace(/\x00\x00\x00\x00/g, '\t');
-                        });
-                    }
-                    first_len = array[0].length;
-                    //cursor in first line
-                    if (first_len === 0 && array.length === 1) {
-                        // skip empty line
-                    } else if (position < first_len) {
-                        draw_cursor_line(array[0], position);
-                        lines_after(array.slice(1));
-                    } else if (position === first_len) {
-                        before.before(div(array[0]));
-                        draw_cursor_line(array[1], 0);
-                        lines_after(array.slice(2));
-                    } else {
-                        var num_lines = array.length;
-                        var offset = 0;
-                        if (position < first_len) {
-                            draw_cursor_line(array[0], position);
-                            lines_after(array.slice(1));
-                        } else if (position === first_len) {
-                            before.before(div(array[0]));
-                            draw_cursor_line(array[1], 0);
-                            lines_after(array.slice(2));
-                        } else {
-                            var last = array.slice(-1)[0];
-                            var from_last = string.length - position;
-                            var last_len = last.length;
-                            var pos = 0;
-                            if (from_last <= last_len) {
-                                lines_before(array.slice(0, -1));
-                                pos = last_len === from_last ? 0 : last_len-from_last;
-                                draw_cursor_line(last, pos+tabs_rm);
-                            } else {
-                                // in the middle
-                                if (num_lines === 3) {
-                                    before.before('<div>' + $.terminal.encode(array[0], true) +
-                                                  '</div>');
-                                    draw_cursor_line(array[1], position-first_len-1);
-                                    after.after('<div class="clear">' +
-                                                $.terminal.encode(array[2], true) +
-                                                '</div>');
-                                } else {
-                                    // more lines, cursor in the middle
-                                    var line_index;
-                                    var current;
-                                    pos = position;
-                                    for (i=0; i<array.length; ++i) {
-                                        var current_len = array[i].length;
-                                        if (pos > current_len) {
-                                            pos -= current_len;
-                                        } else {
-                                            break;
-                                        }
-                                    }
-                                    current = array[i];
-                                    line_index = i;
-                                    // cursor on first character in line
-                                    if (pos === current.length) {
-                                        pos = 0;
-                                        current = array[++line_index];
-                                    }
-                                    draw_cursor_line(current, pos);
-                                    lines_before(array.slice(0, line_index));
-                                    lines_after(array.slice(line_index+1));
-                                }
-                            }
-                        }
-                    }
-                } else {
-                     if (string === '') {
-                         before.html('');
-                         cursor.html('&nbsp;');
-                         after.html('');
-                     } else {
-                         draw_cursor_line(string, position);
-                     }
-                }
-            };
-        })(self);
-        var last_command;
-        // -----------------------------------------------------------------------
-        // :: Draw prompt that can be a function or a string
-        // -----------------------------------------------------------------------
-        var draw_prompt = (function() {
-            var prompt_node = self.find('.prompt');
-            function set(prompt) {
-                prompt_len = skipFormattingCount(prompt);
-                prompt_node.html($.terminal.format($.terminal.encode(prompt)));
-            }
-            return function() {
-                switch (typeof prompt) {
-                case 'string':
-                    set(prompt);
-                    break;
-                case 'function':
-                    prompt(set);
-                    break;
-                }
-            };
-        })();
-        // -----------------------------------------------------------------------
-        // :: Paste content to terminal using hidden textarea
-        // -----------------------------------------------------------------------
-        function paste() {
-            clip.focus();
-            //wait until Browser insert text to textarea
-            self.oneTime(1, function() {
-                self.insert(clip.val());
-                clip.blur().val('');
-            });
-        }
-        var first_up_history = true;
-        //var prevent_keypress = false;
-        // -----------------------------------------------------------------------
-        // :: Keydown Event Handler
-        // -----------------------------------------------------------------------
-        function keydown_event(e) {
-            var result, pos, len;
-            if (typeof options.keydown == 'function') {
-                result = options.keydown(e);
-                if (result !== undefined) {
-                    //prevent_keypress = true;
-                    return result;
-                }
-            }
-            if (enabled) {
-                if (e.which !== 38 &&
-                    !(e.which === 80 && e.ctrlKey)) {
-                    first_up_history = true;
-                }
-                // arrows / Home / End / ENTER
-                if (reverse_search && (e.which === 35 || e.which === 36 ||
-                                       e.which === 37 || e.which === 38 ||
-                                       e.which === 39 || e.which === 40 ||
-                                       e.which === 13 || e.which === 27)) {
-                    clear_reverse_state();
-                    draw_prompt();
-                    if (e.which === 27) { // ESC
-                        command = '';
-                    }
-                    redraw();
-                    // finish reverse search and execute normal event handler
-                    keydown_event.call(this, e);
-                } else if (e.altKey) {
-                    // Chrome on Windows sets ctrlKey and altKey for alt
-                    // need to check for alt first
-                    //if (e.which === 18) { // press ALT
-                    if (e.which === 68) { //ALT+D
-                        self.set(command.slice(0, position) +
-                                 command.slice(position).replace(/[^ ]+ |[^ ]+$/, ''),
-                                 true);
-                        // chrome jump to address bar
-                        return false;
-                    }
-                    return true;
-                } else if (e.keyCode === 13) { //enter
-                    if (e.shiftKey) {
-                        self.insert('\n');
-                    } else {
-                        if (history && command && !mask &&
-                            ((typeof options.historyFilter == 'function' &&
-                              options.historyFilter(command)) ||
-                             !options.historyFilter)) {
-                            history.append(command);
-                        }
-                        var tmp = command;
-                        history.reset();
-                        self.set('');
-                        if (options.commands) {
-                            options.commands(tmp);
-                        }
-                        if (typeof prompt === 'function') {
-                            draw_prompt();
-                        }
-                    }
-                } else if (e.which === 8) { //backspace
-                    if (reverse_search) {
-                        reverse_search_string = reverse_search_string.slice(0, -1);
-                        draw_reverse_prompt();
-                    } else {
-                        if (command !== '' && position > 0) {
-                            command = command.slice(0, position - 1) +
-                                command.slice(position, command.length);
-                            --position;
-                            redraw();
-                        }
-                    }
-                } else if (e.which === 67 && e.ctrlKey && e.shiftKey) { // CTRL+SHIFT+C
-                    selected_text = getSelectedText();
-                } else if (e.which === 86 && e.ctrlKey && e.shiftKey) {
-                    if (selected_text !== '') {
-                        self.insert(selected_text);
-                    }
-                } else if (e.which === 9 && !(e.ctrlKey || e.altKey)) { // TAB
-                    self.insert('\t');
-                } else if (e.which === 46) {
-                    //DELETE
-                    if (command !== '' && position < command.length) {
-                        command = command.slice(0, position) +
-                            command.slice(position + 1, command.length);
-                        redraw();
-                    }
-                    return true;
-                } else if (history && e.which === 38 ||
-                           (e.which === 80 && e.ctrlKey)) {
-                    //UP ARROW or CTRL+P
-                    if (first_up_history) {
-                        last_command = command;
-                        self.set(history.current());
-                    } else {
-                        self.set(history.previous());
-                    }
-                    first_up_history = false;
-                } else if (history && e.which === 40 ||
-                           (e.which === 78 && e.ctrlKey)) {
-                    //DOWN ARROW or CTRL+N
-                    self.set(history.end() ? last_command : history.next());
-                } else if (e.which === 37 ||
-                           (e.which === 66 && e.ctrlKey)) {
-                    //CTRL+LEFT ARROW or CTRL+B
-                    if (e.ctrlKey && e.which !== 66) {
-                        len = position - 1;
-                        pos = 0;
-                        if (command[len] === ' ') {
-                            --len;
-                        }
-                        for (var i = len; i > 0; --i) {
-                            if (command[i] === ' ' && command[i+1] !== ' ') {
-                                pos = i + 1;
-                                break;
-                            } else if (command[i] === '\n' && command[i+1] !== '\n') {
-                                pos = i;
-                                break;
-                            }
-                        }
-                        self.position(pos);
-                    } else {
-                        //LEFT ARROW or CTRL+B
-                        if (position > 0) {
-                            --position;
-                            redraw();
-                        }
-                    }
-                } else if (e.which === 82 && e.ctrlKey) { // CTRL+R
-                    if (reverse_search) {
-                        reverse_history_search(true);
-                    } else {
-                        backup_prompt = prompt;
-                        draw_reverse_prompt();
-                        last_command = command;
-                        command = '';
-                        redraw();
-                        reverse_search = true;
-                    }
-                } else if (e.which == 71 && e.ctrlKey) { // CTRL+G
-                    if (reverse_search) {
-                        prompt = backup_prompt;
-                        draw_prompt();
-                        command = last_command;
-                        redraw();
-                        reverse_search = false;
-                        reverse_search_string = '';
-                    }
-                } else if (e.which === 39 ||
-                           (e.which === 70 && e.ctrlKey)) {
-                    //RIGHT ARROW OR CTRL+F
-                    if (e.ctrlKey && e.which !== 70) {
-                        // jump to beginning or end of the word
-                        if (command[position] === ' ') {
-                            ++position;
-                        }
-                        var re = /\S[\n\s]{2,}|[\n\s]+\S?/;
-                        var match = command.slice(position).match(re);
-                        if (!match || match[0].match(/^\s+$/)) {
-                            position = command.length;
-                        } else {
-                            if (match[0][0] !== ' ') {
-                                position += match.index + 1;
-                            } else {
-                                position += match.index + match[0].length - 1;
-                                if (match[0][match[0].length-1] !== ' ') {
-                                    --position;
-                                }
-                            }
-                        }
-                        redraw();
-                    } else {
-                        if (position < command.length) {
-                            ++position;
-                            redraw();
-                        }
-                    }
-                } else if (e.which === 123) { //F12 - Allow Firebug
-                    return true;
-                } else if (e.which === 36) { //HOME
-                    self.position(0);
-                } else if (e.which === 35) {
-                    //END
-                    self.position(command.length);
-                } else if (e.shiftKey && e.which == 45) { // Shift+Insert
-                    paste();
-                    return true;
-                } else if (e.ctrlKey || e.metaKey) {
-                    if (e.which === 192) { // CMD+` switch browser window on Mac
-                        return true;
-                    }
-                    if (e.metaKey) {
-                        if(e.which === 82) { // CMD+r page reload in Chrome Mac
-                            return true;
-                        } else if(e.which === 76) {
-                            return true; // CMD+l jump into Omnibox on Chrome Mac
-                        }
-                    }
-                    if (e.shiftKey) { // CTRL+SHIFT+??
-                        if (e.which === 84) {
-                            //CTRL+SHIFT+T open closed tab
-                            return true;
-                        }
-                    //} else if (e.altKey) { //ALT+CTRL+??
-                    } else {
-                        if (e.which === 81) { // CTRL+W
-                            // don't work in Chromium (can't prevent close tab)
-                            if (command !== '' && position !== 0) {
-                                var first = command.slice(0, position);
-                                var last = command.slice(position+1);
-                                var m = first.match(/([^ ]+ *$)/);
-                                position = first.length-m[0].length;
-                                kill_text = first.slice(position);
-                                command = first.slice(0, position) + last;
-                                redraw();
-                            }
-                            return false;
-                        } else if (e.which === 72) { // CTRL+H
-                            if (command !== '' && position > 0) {
-                                command = command.slice(0, --position);
-                                if (position < command.length-1) {
-                                    command += command.slice(position);
-                                }
-                                redraw();
-                            }
-                            return false;
-                        //NOTE: in opera charCode is undefined
-                        } else if (e.which === 65) {
-                            //CTRL+A
-                            self.position(0);
-                        } else if (e.which === 69) {
-                            //CTRL+E
-                            self.position(command.length);
-                        } else if (e.which === 88 || e.which === 67 || e.which === 84) {
-                            //CTRL+X CTRL+C CTRL+W CTRL+T
-                            return true;
-                        } else if (e.which === 89) { // CTRL+Y
-                            if (kill_text !== '') {
-                                self.insert(kill_text);
-                            }
-                        } else if (e.which === 86) {
-                            //CTRL+V
-                            paste();
-                            return true;
-                        } else if (e.which === 75) {
-                            //CTRL+K
-                            if (position === 0) {
-                                kill_text = command;
-                                self.set('');
-                            } else if (position !== command.length) {
-                                kill_text = command.slice(position);
-                                self.set(command.slice(0, position));
-                            }
-                        } else if (e.which === 85) { // CTRL+U
-                            if (command !== '' && position !== 0) {
-                                kill_text = command.slice(0, position);
-                                self.set(command.slice(position, command.length));
-                                self.position(0);
-                            }
-                        } else if (e.which === 17) { //CTRL+TAB switch tab
-                            return false;
-                        }
-                    }
-                } else {
-                    return true;
-                }
-                return false;
-            } /*else {
-                if ((e.altKey && e.which === 68) ||
-                    (e.ctrlKey &&
-                     $.inArray(e.which, [65, 66, 68, 69, 80, 78, 70]) > -1) ||
-                    // 68 === D
-                    [35, 36, 37, 38, 39, 40].has(e.which)) {
-                    return false;
-                }
-            } */
-        }
-        var history_list = [];
-        // -----------------------------------------------------------------------
-        // :: Command Line Methods
-        // -----------------------------------------------------------------------
-        $.extend(self, {
-            name: function(string) {
-                if (string !== undefined) {
-                    name = string;
-                    var enabled = history && history.enabled() || !history;
-                    history = new History(string, historySize);
-                    // disable new history if old was disabled
-                    if (!enabled) {
-                        history.disable();
-                    }
-                    return self;
-                } else {
-                    return name;
-                }
-            },
-            purge: function() {
-                history.clear();
-                return self;
-            },
-            history: function() {
-                return history;
-            },
-            set: function(string, stay) {
-                if (string !== undefined) {
-                    command = string;
-                    if (!stay) {
-                        position = command.length;
-                    }
-                    redraw();
-                    if (typeof options.onCommandChange === 'function') {
-                        options.onCommandChange(command);
-                    }
-                }
-                return self;
-            },
-            insert: function(string, stay) {
-                if (position === command.length) {
-                    command += string;
-                } else if (position === 0) {
-                    command = string + command;
-                } else {
-                    command = command.slice(0, position) +
-                        string + command.slice(position);
-                }
-                if (!stay) {
-                    position += string.length;
-                }
-                redraw();
-                if (typeof options.onCommandChange === 'function') {
-                    options.onCommandChange(command);
-                }
-                return self;
-            },
-            get: function() {
-                return command;
-            },
-            commands: function(commands) {
-                if (commands) {
-                    options.commands = commands;
-                    return self;
-                } else {
-                    return commands;
-                }
-            },
-            destroy: function() {
-                $(document.documentElement || window).unbind('.cmd');
-                self.stopTime('blink', blink);
-                self.find('.cursor').next().remove().end().prev().remove().end().remove();
-                self.find('.prompt, .clipboard').remove();
-                self.removeClass('cmd').removeData('cmd');
-                return self;
-            },
-            prompt: function(user_prompt) {
-                if (user_prompt === undefined) {
-                    return prompt;
-                } else {
-                    if (typeof user_prompt === 'string' ||
-                        typeof user_prompt === 'function') {
-                        prompt = user_prompt;
-                    } else {
-                        throw 'prompt must be a function or string';
-                    }
-                    draw_prompt();
-                    // we could check if command is longer then numchars-new prompt
-                    redraw();
-                    return self;
-                }
-            },
-            kill_text: function() {
-                return kill_text;
-            },
-            position: function(n) {
-                if (typeof n === 'number') {
-                    position = n < 0 ? 0 : n > command.length ? command.length : n;
-                    redraw();
-                    return self;
-                } else {
-                    return position;
-                }
-            },
-            visible: (function() {
-                var visible = self.visible;
-                return function() {
-                    visible.apply(self, []);
-                    redraw();
-                    draw_prompt();
-                };
-            })(),
-            show: (function() {
-                var show = self.show;
-                return function() {
-                    show.apply(self, []);
-                    redraw();
-                    draw_prompt();
-                };
-            })(),
-            resize: function(num) {
-                if (num) {
-                    num_chars = num;
-                } else {
-                    change_num_chars();
-                }
-                redraw();
-                return self;
-            },
-            enable: function() {
-                enabled = true;
-                animation(true);
-                return self;
-            },
-            isenabled: function() {
-                return enabled;
-            },
-            disable: function() {
-                enabled = false;
-                animation(false);
-                return self;
-            },
-            mask: function(display) {
-                if (typeof display === 'boolean') {
-                    mask = display;
-                    redraw();
-                    return self;
-                } else {
-                    return mask;
-                }
-            }
-        });
-        // -----------------------------------------------------------------------
-        // :: INIT
-        // -----------------------------------------------------------------------
-        self.name(options.name || options.prompt || '');
-        prompt = options.prompt || '> ';
-        draw_prompt();
-        if (options.enabled === undefined || options.enabled === true) {
-            self.enable();
-        }
-        // Keystrokes
-        var object;
-        $(document.documentElement || window).bind('keypress.cmd', function(e) {
-            var result;
-            if (e.ctrlKey && e.which === 99) { // CTRL+C
-                return true;
-            }
-            if (!reverse_search && typeof options.keypress === 'function') {
-                result = options.keypress(e);
-            }
-            if (result === undefined || result) {
-                if (enabled) {
-                    if ($.inArray(e.which, [38, 13, 0, 8]) > -1 &&
-                        e.keyCode !== 123 && // for F12 which === 0
-                        //!(e.which === 40 && e.shiftKey ||
-                        !(e.which === 38 && e.shiftKey)) {
-                        return false;
-                    } else if (!e.ctrlKey && !(e.altKey && e.which === 100) || e.altKey) { // ALT+D
-                        // TODO: this should be in one statement
-                        if (reverse_search) {
-                            reverse_search_string += String.fromCharCode(e.which);
-                            reverse_history_search();
-                            draw_reverse_prompt();
-                        } else {
-                            self.insert(String.fromCharCode(e.which));
-                        }
-                        return false;
-                    }
-                }
-            } else {
-                return result;
-            }
-        }).bind('keydown.cmd', keydown_event);
-        // characters
-        self.data('cmd', self);
-        return self;
-    }; // cmd plugin
-
-    // -------------------------------------------------------------------------
-    // :: TOOLS
-    // -------------------------------------------------------------------------
-    function skipFormattingCount(string) {
-        // this will covert html entities to single characters
-        return $('<div>' + $.terminal.strip(string) + '</div>').text().length;
-    }
-    // -------------------------------------------------------------------------
-    function formattingCount(string) {
-        return string.length - skipFormattingCount(string);
-    }
-    // -------------------------------------------------------------------------
-    // taken from https://hacks.mozilla.org/2011/09/detecting-and-generating-css-animations-in-javascript/
-    function supportAnimations() {
-        var animation = false,
-        animationstring = 'animation',
-        keyframeprefix = '',
-        domPrefixes = 'Webkit Moz O ms Khtml'.split(' '),
-        pfx  = '',
-        elm = document.createElement('div');
-        if (elm.style.animationName) { animation = true; }
-        if (animation === false) {
-            for (var i = 0; i < domPrefixes.length; i++) {
-                if (elm.style[ domPrefixes[i] + 'AnimationName' ] !== undefined) {
-                    pfx = domPrefixes[i];
-                    animationstring = pfx + 'Animation';
-                    keyframeprefix = '-' + pfx.toLowerCase() + '-';
-                    animation = true;
-                    break;
-                }
-            }
-        }
-        return animation;
-    }
-    // -------------------------------------------------------------------------
-    function processCommand(string, fn) {
-        var args = string.replace(/^\s+|\s+$/g, '').split(/(\s+)/);
-        var rest = string.replace(/^[^\s]+\s*/, '');
-        return {
-            name: args[0],
-            args: fn(rest),
-            rest: rest
-        };
-    }
-    // colors from http://www.w3.org/wiki/CSS/Properties/color/keywords
-    var color_names = [
-        'black', 'silver', 'gray', 'white', 'maroon', 'red', 'purple',
-        'fuchsia', 'green', 'lime', 'olive', 'yellow', 'navy', 'blue', 'teal',
-        'aqua', 'aliceblue', 'antiquewhite', 'aqua', 'aquamarine', 'azure',
-        'beige', 'bisque', 'black', 'blanchedalmond', 'blue', 'blueviolet',
-        'brown', 'burlywood', 'cadetblue', 'chartreuse', 'chocolate', 'coral',
-        'cornflowerblue', 'cornsilk', 'crimson', 'cyan', 'darkblue', 'darkcyan',
-        'darkgoldenrod', 'darkgray', 'darkgreen', 'darkgrey', 'darkkhaki',
-        'darkmagenta', 'darkolivegreen', 'darkorange', 'darkorchid', 'darkred',
-        'darksalmon', 'darkseagreen', 'darkslateblue', 'darkslategray',
-        'darkslategrey', 'darkturquoise', 'darkviolet', 'deeppink',
-        'deepskyblue', 'dimgray', 'dimgrey', 'dodgerblue', 'firebrick',
-        'floralwhite', 'forestgreen', 'fuchsia', 'gainsboro', 'ghostwhite',
-        'gold', 'goldenrod', 'gray', 'green', 'greenyellow', 'grey', 'honeydew',
-        'hotpink', 'indianred', 'indigo', 'ivory', 'khaki', 'lavender',
-        'lavenderblush', 'lawngreen', 'lemonchiffon', 'lightblue', 'lightcoral',
-        'lightcyan', 'lightgoldenrodyellow', 'lightgray', 'lightgreen',
-        'lightgrey', 'lightpink', 'lightsalmon', 'lightseagreen',
-        'lightskyblue', 'lightslategray', 'lightslategrey', 'lightsteelblue',
-        'lightyellow', 'lime', 'limegreen', 'linen', 'magenta', 'maroon',
-        'mediumaquamarine', 'mediumblue', 'mediumorchid', 'mediumpurple',
-        'mediumseagreen', 'mediumslateblue', 'mediumspringgreen',
-        'mediumturquoise', 'mediumvioletred', 'midnightblue', 'mintcream',
-        'mistyrose', 'moccasin', 'navajowhite', 'navy', 'oldlace', 'olive',
-        'olivedrab', 'orange', 'orangered', 'orchid', 'palegoldenrod',
-        'palegreen', 'paleturquoise', 'palevioletred', 'papayawhip',
-        'peachpuff', 'peru', 'pink', 'plum', 'powderblue', 'purple', 'red',
-        'rosybrown', 'royalblue', 'saddlebrown', 'salmon', 'sandybrown',
-        'seagreen', 'seashell', 'sienna', 'silver', 'skyblue', 'slateblue',
-        'slategray', 'slategrey', 'snow', 'springgreen', 'steelblue', 'tan',
-        'teal', 'thistle', 'tomato', 'turquoise', 'violet', 'wheat', 'white',
-        'whitesmoke', 'yellow', 'yellowgreen'];
-    // -------------------------------------------------------------------------
-    var format_split_re = /(\[\[[gbiuso]*;[^;]*;[^\]]*\](?:[^\]]*\\\][^\]]*|[^\]]*|[^\[]*\[[^\]]*)\]?)/i;
-    var format_parts_re = /\[\[([gbiuso]*);([^;]*);([^;\]]*);?([^;\]]*);?([^\]]*)\]([^\]]*\\\][^\]]*|[^\]]*|[^\[]*\[[^\]]*)\]?/gi;
-    var format_re = /\[\[([gbiuso]*;[^;\]]*;[^;\]]*(?:;|[^\]()]*);?[^\]]*)\]([^\]]*\\\][^\]]*|[^\]]*|[^\[]*\[[^\]]*)\]?/gi;
-    var format_full_re = /^\[\[([gbiuso]*;[^;\]]*;[^;\]]*(?:;|[^\]()]*);?[^\]]*)\]([^\]]*\\\][^\]]*|[^\]]*|[^\[]*\[[^\]]*)\]$/gi;
-    var color_hex_re = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i;
-    //var url_re = /https?:\/\/(?:(?!&[^;]+;)[^\s:"'<>)])+/g;
-    var url_re = /\bhttps?:\/\/(?:(?!&[^;]+;)[^\s"'<>)])+\b/g;
-    var email_re = /((([^<>('")[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,})))/g;
-    var command_re = /('[^']*'|"(\\"|[^"])*"|\/(\\\/|[^\/])+\/[gimy]*|(\\ |[^ ])+|[\w-]+)/g;
-    var format_begin_re = /(\[\[[gbiuso]*;[^;]*;[^\]]*\])/i;
-    var format_last_re = /\[\[[gbiuso]*;[^;]*;[^\]]*\]?$/i;
-    $.terminal = {
-        // -----------------------------------------------------------------------
-        // :: Validate html color (it can be name or hex)
-        // -----------------------------------------------------------------------
-        valid_color: function(color) {
-            return color.match(color_hex_re) || $.inArray(color.toLowerCase(), color_names) !== -1;
-        },
-        // -----------------------------------------------------------------------
-        // :: Escape all special regex characters, so it can be use as regex to
-        // :: match exact string that contain those characters
-        // -----------------------------------------------------------------------
-        escape_regex: function(string) {
-            var special = /([\^\$\[\]\(\)\+\*\.\|])/g;
-            return string.replace(special, '\\$1');
-        },
-        // -----------------------------------------------------------------------
-        // :: test if string contain formatting
-        // -----------------------------------------------------------------------
-        have_formatting: function(str) {
-            return str.match(format_re);
-        },
-        is_formatting: function(str) {
-            return str.match(format_full_re);
-        },
-        // -----------------------------------------------------------------------
-        // :: return array of formatting and text between them
-        // -----------------------------------------------------------------------
-        format_split: function(str) {
-            return str.split(format_split_re);
-        },
-        // -----------------------------------------------------------------------
-        // :: split text into lines with equal length so each line can be rendered
-        // :: separately (text formatting can be longer then a line).
-        // -----------------------------------------------------------------------
-        split_equal: function(str, length) {
-            var formatting = false;
-            var in_text = false;
-            var braket = 0;
-            var prev_format = '';
-            var result = [];
-            // add format text as 5th paramter to formatting it's used for
-            // data attribute in format function
-            var array = str.replace(format_re, function(_, format, text) {
-                var semicolons = format.match(/;/g).length;
-                // missing semicolons
-                if (semicolons == 2) {
-                    semicolons = ';;';
-                } else if (semicolons == 3) {
-                    semicolons = ';';
-                } else {
-                    semicolons = '';
-                }
-                // return '[[' + format + ']' + text + ']';
-                // closing braket will break formatting so we need to escape those using
-                // html entity equvalent
-                return '[[' + format + semicolons +
-                    text.replace(/\\\]/g, '&#93;').replace(/\n/g, '\\n') + ']' +
-                    text + ']';
-            }).split(/\n/g);
-            for (var i = 0, len = array.length; i < len; ++i) {
-                if (array[i] === '') {
-                    result.push('');
-                    continue;
-                }
-                var line = array[i];
-                var first_index = 0;
-                var count = 0;
-                for (var j=0, jlen=line.length; j<jlen; ++j) {
-                    if (line[j] === '[' && line[j+1] === '[') {
-                        formatting = true;
-                    } else if (formatting && line[j] === ']') {
-                        if (in_text) {
-                            formatting = false;
-                            in_text = false;
-                        } else {
-                            in_text = true;
-                        }
-                    } else if ((formatting && in_text) || !formatting) {
-                        if (line[j] === '&') { // treat entity as one character
-                            var m = line.substring(j).match(/^(&[^;]+;)/);
-                            if (!m) {
-                                // should never happen if used by terminal, because
-                                // it always calls $.terminal.encode before this function
-                                throw "Unclosed html entity in line " + (i+1) + ' at char ' + (j+1);
-                            }
-                            j+=m[1].length-2; // because continue adds 1 to j
-                            // if entity is at the end there is no next loop - issue #77
-                            if (j === jlen-1) {
-                                result.push(output_line + m[1]);
-                            }
-                            continue;
-                        } else if (line[j] === ']' && line[j-1] === '\\') {
-                            // escape \] counts as one character
-                            --count;
-                        } else {
-                            ++count;
-                        }
-                    }
-                    if (count === length || j === jlen-1) {
-                        var output_line = line.substring(first_index, j+1);
-                        if (prev_format) {
-                            output_line = prev_format + output_line;
-                            if (output_line.match(']')) {
-                                prev_format = '';
-                            }
-                        }
-                        first_index = j+1;
-                        count = 0;
-                        // Fix output_line if formatting not closed
-                        var matched = output_line.match(format_re);
-                        if (matched) {
-                            var last = matched[matched.length-1];
-                            if (last[last.length-1] !== ']') {
-                                prev_format = last.match(format_begin_re)[1];
-                                output_line += ']';
-                            } else if (output_line.match(format_last_re)) {
-                                var line_len = output_line.length;
-                                var f_len = line_len - last[last.length-1].length;
-                                output_line = output_line.replace(format_last_re, '');
-                                prev_format = last.match(format_begin_re)[1];
-                            }
-                        }
-                        result.push(output_line);
-                    }
-                }
-            }
-            return result;
-        },
-        // -----------------------------------------------------------------------
-        // :: Encode formating as html for insertion into DOM
-        // -----------------------------------------------------------------------
-        encode: function(str, full) {
-            // don't escape entities
-            if (full) {
-                str = str.replace(/&(?![^=]+=)/g, '&amp;');
-            } else {
-                str = str.replace(/&(?!#[0-9]+;|[a-zA-Z]+;|[^= "]+=[^=])/g, '&amp;');
-            }
-            return str.replace(/</g, '&lt;').replace(/>/g, '&gt;')
-                      .replace(/ /g, '&nbsp;')
-                      .replace(/\t/g, '&nbsp;&nbsp;&nbsp;&nbsp;');
-        },
-        // -----------------------------------------------------------------------
-        // :: Replace terminal formatting with html
-        // -----------------------------------------------------------------------
-        format: function(str, options) {
-            var settings = $.extend({}, {
-                linksNoReferrer: false
-            }, options || {});
-            if (typeof str === 'string') {
-                //support for formating foo[[u;;]bar]baz[[b;#fff;]quux]zzz
-                var splited = $.terminal.format_split(str);
-                if (splited && splited.length > 1) {
-                    str = $.map(splited, function(text) {
-                        if (text === '') {
-                            return text;
-                        } else if (text.substring(0,1) === '[') {
-                            // use substring for IE quirks mode - [0] don't work
-                            return text.replace(format_parts_re, function(s,
-                                                                    style,
-                                                                    color,
-                                                                    background,
-                                                                    _class,
-                                                                    data_text,
-                                                                    text) {
-                                if (text === '') {
-                                    return ''; //'<span>&nbsp;</span>';
-                                }
-                                text = text.replace(/\\]/g, ']');
-                                var style_str = '';
-                                if (style.indexOf('b') !== -1) {
-                                    style_str += 'font-weight:bold;';
-                                }
-                                var text_decoration = [];
-                                if (style.indexOf('u') !== -1) {
-                                    text_decoration.push('underline');
-                                }
-                                if (style.indexOf('s') !== -1) {
-                                    text_decoration.push('line-through');
-                                }
-                                if (style.indexOf('o') !== -1) {
-                                    text_decoration.push('overline');
-                                }
-                                if (text_decoration.length) {
-                                    style_str += 'text-decoration:' +
-                                        text_decoration.join(' ') + ';';
-                                }
-                                if (style.indexOf('i') !== -1) {
-                                    style_str += 'font-style:italic;';
-                                }
-                                if ($.terminal.valid_color(color)) {
-                                    style_str += 'color:' + color + ';';
-                                    if (style.indexOf('g') !== -1) {
-                                        style_str += 'text-shadow:0 0 5px ' + color + ';';
-                                    }
-                                }
-                                if ($.terminal.valid_color(background)) {
-                                    style_str += 'background-color:' + background;
-                                }
-                                var data;
-                                if (data_text === '') {
-                                    data = text;
-                                } else {
-                                    data = data_text.replace(/&#93;/g, ']');
-                                }
-                                var result = '<span style="' + style_str + '"' +
-                                    (_class !== '' ? ' class="' + _class + '"' : '') +
-                                    ' data-text="'+ data.replace('"', '&quote;') +
-                                    '">' + text + '</span>';
-                                return result;
-                            });
-                        } else {
-                            return '<span>' + text + '</span>';
-                        }
-                    }).join('');
-                }
-                return $.map(str.split(/(<\/?span[^>]*>)/g), function(string) {
-                    if (!string.match(/span/)) {
-                        return string.replace(url_re, function(link) {
-                            var comma = link.match(/\.$/);
-                            link = link.replace(/\.$/, '');
-                            return '<a target="_blank" ' +
-                                (settings.linksNoReferer ? ' rel="noreferrer" ' : '') +
-                                'href="' + link + '">' + link + '</a>' +
-                                (comma ? '.' : '');
-                        }).replace(email_re, '<a href="mailto:$1">$1</a>');
-                    } else {
-                        return string;
-                    }
-                }).join('').replace(/<span><br\/?><\/span>/g, '<br/>');
-            } else {
-                return '';
-            }
-        },
-        // -----------------------------------------------------------------------
-        // :: Replace brackets with html entities
-        // -----------------------------------------------------------------------
-        escape_brackets: function(string) {
-            return string.replace(/\[/g, '&#91;').replace(/\]/g, '&#93;');
-        },
-        // -----------------------------------------------------------------------
-        // :: Remove formatting from text
-        // -----------------------------------------------------------------------
-        strip: function(str) {
-            return str.replace(format_parts_re, '$6');
-        },
-        // -----------------------------------------------------------------------
-        // :: Return active terminal
-        // -----------------------------------------------------------------------
-        active: function() {
-            return terminals.front();
-        },
-        // -----------------------------------------------------------------------
-        // :: Replace overtyping (from man) formatting with terminal formatting
-        // -----------------------------------------------------------------------
-        overtyping: function(string) {
-            return string.replace(/((?:_\x08.|.\x08_)+)/g, function(full, g) {
-                return '[[u;;]' + full.replace(/_x08|\x08_|_\u0008|\u0008_/g, '') + ']';
-            }).replace(/((?:.\x08.)+)/g, function(full, g) {
-                return '[[b;#fff;]' + full.replace(/(.)(?:\x08|\u0008)(.)/g,
-                                                   function(full, g1, g2) {
-                                                       return g2;
-                                                   }) + ']';
-            });
-        },
-        // -----------------------------------------------------------------------
-        // :: Html colors taken from ANSI formatting in Linux Terminal
-        // -----------------------------------------------------------------------
-        ansi_colors: {
-            normal: {
-                black: '#000',
-                red: '#A00',
-                green: '#008400',
-                yellow: '#A50',
-                blue: '#00A',
-                magenta: '#A0A',
-                cyan: '#0AA',
-                white: '#AAA'
-            },
-            faited: {
-                black: '#000',
-                red: '#640000',
-                green: '#006100',
-                yellow: '#737300',
-                blue: '#000087',
-                magenta: '#650065',
-                cyan: '#008787',
-                white: '#818181'
-            },
-            bold: {
-                black: '#000',
-                red: '#F55',
-                green: '#44D544',
-                yellow: '#FF5',
-                blue: '#55F',
-                magenta: '#F5F',
-                cyan: '#5FF',
-                white: '#FFF'
-            },
-            // XTerm 8-bit pallete
-            palette: [
-                '#000000', '#AA0000', '#00AA00', '#AA5500', '#0000AA',
-                '#AA00AA', '#00AAAA', '#AAAAAA', '#555555', '#FF5555',
-                '#55FF55', '#FFFF55', '#5555FF', '#FF55FF', '#55FFFF',
-                '#FFFFFF', '#000000', '#00005F', '#000087', '#0000AF',
-                '#0000D7', '#0000FF', '#005F00', '#005F5F', '#005F87',
-                '#005FAF', '#005FD7', '#005FFF', '#008700', '#00875F',
-                '#008787', '#0087AF', '#0087D7', '#00AF00', '#00AF5F',
-                '#00AF87', '#00AFAF', '#00AFD7', '#00AFFF', '#00D700',
-                '#00D75F', '#00D787', '#00D7AF', '#00D7D7', '#00D7FF',
-                '#00FF00', '#00FF5F', '#00FF87', '#00FFAF', '#00FFD7',
-                '#00FFFF', '#5F0000', '#5F005F', '#5F0087', '#5F00AF',
-                '#5F00D7', '#5F00FF', '#5F5F00', '#5F5F5F', '#5F5F87',
-                '#5F5FAF', '#5F5FD7', '#5F5FFF', '#5F8700', '#5F875F',
-                '#5F8787', '#5F87AF', '#5F87D7', '#5F87FF', '#5FAF00',
-                '#5FAF5F', '#5FAF87', '#5FAFAF', '#5FAFD7', '#5FAFFF',
-                '#5FD700', '#5FD75F', '#5FD787', '#5FD7AF', '#5FD7D7',
-                '#5FD7FF', '#5FFF00', '#5FFF5F', '#5FFF87', '#5FFFAF',
-                '#5FFFD7', '#5FFFFF', '#870000', '#87005F', '#870087',
-                '#8700AF', '#8700D7', '#8700FF', '#875F00', '#875F5F',
-                '#875F87', '#875FAF', '#875FD7', '#875FFF', '#878700',
-                '#87875F', '#878787', '#8787AF', '#8787D7', '#8787FF',
-                '#87AF00', '#87AF5F', '#87AF87', '#87AFAF', '#87AFD7',
-                '#87AFFF', '#87D700', '#87D75F', '#87D787', '#87D7AF',
-                '#87D7D7', '#87D7FF', '#87FF00', '#87FF5F', '#87FF87',
-                '#87FFAF', '#87FFD7', '#87FFFF', '#AF0000', '#AF005F',
-                '#AF0087', '#AF00AF', '#AF00D7', '#AF00FF', '#AF5F00',
-                '#AF5F5F', '#AF5F87', '#AF5FAF', '#AF5FD7', '#AF5FFF',
-                '#AF8700', '#AF875F', '#AF8787', '#AF87AF', '#AF87D7',
-                '#AF87FF', '#AFAF00', '#AFAF5F', '#AFAF87', '#AFAFAF',
-                '#AFAFD7', '#AFAFFF', '#AFD700', '#AFD75F', '#AFD787',
-                '#AFD7AF', '#AFD7D7', '#AFD7FF', '#AFFF00', '#AFFF5F',
-                '#AFFF87', '#AFFFAF', '#AFFFD7', '#AFFFFF', '#D70000',
-                '#D7005F', '#D70087', '#D700AF', '#D700D7', '#D700FF',
-                '#D75F00', '#D75F5F', '#D75F87', '#D75FAF', '#D75FD7',
-                '#D75FFF', '#D78700', '#D7875F', '#D78787', '#D787AF',
-                '#D787D7', '#D787FF', '#D7AF00', '#D7AF5F', '#D7AF87',
-                '#D7AFAF', '#D7AFD7', '#D7AFFF', '#D7D700', '#D7D75F',
-                '#D7D787', '#D7D7AF', '#D7D7D7', '#D7D7FF', '#D7FF00',
-                '#D7FF5F', '#D7FF87', '#D7FFAF', '#D7FFD7', '#D7FFFF',
-                '#FF0000', '#FF005F', '#FF0087', '#FF00AF', '#FF00D7',
-                '#FF00FF', '#FF5F00', '#FF5F5F', '#FF5F87', '#FF5FAF',
-                '#FF5FD7', '#FF5FFF', '#FF8700', '#FF875F', '#FF8787',
-                '#FF87AF', '#FF87D7', '#FF87FF', '#FFAF00', '#FFAF5F',
-                '#FFAF87', '#FFAFAF', '#FFAFD7', '#FFAFFF', '#FFD700',
-                '#FFD75F', '#FFD787', '#FFD7AF', '#FFD7D7', '#FFD7FF',
-                '#FFFF00', '#FFFF5F', '#FFFF87', '#FFFFAF', '#FFFFD7',
-                '#FFFFFF', '#080808', '#121212', '#1C1C1C', '#262626',
-                '#303030', '#3A3A3A', '#444444', '#4E4E4E', '#585858',
-                '#626262', '#6C6C6C', '#767676', '#808080', '#8A8A8A',
-                '#949494', '#9E9E9E', '#A8A8A8', '#B2B2B2', '#BCBCBC',
-                '#C6C6C6', '#D0D0D0', '#DADADA', '#E4E4E4', '#EEEEEE'
-            ]
-        },
-        // -----------------------------------------------------------------------
-        // :: Replace ANSI formatting with terminal formatting
-        // -----------------------------------------------------------------------
-        from_ansi: (function() {
-            var color = {
-                30: 'black',
-                31: 'red',
-                32: 'green',
-                33: 'yellow',
-                34: 'blue',
-                35: 'magenta',
-                36: 'cyan',
-                37: 'white',
-
-                39: 'white' // default color
-            };
-            var background = {
-                40: 'black',
-                41: 'red',
-                42: 'green',
-                43: 'yellow',
-                44: 'blue',
-                45: 'magenta',
-                46: 'cyan',
-                47: 'white',
-
-                49: 'black' // default background
-            };
-            function format_ansi(code) {
-                var controls = code.split(';');
-                var num;
-                var faited = false;
-                var reverse = false;
-                var bold = false;
-                var styles = [];
-                var output_color = '';
-                var output_background = '';
-                var _8bit_color = false;
-                var _8bit_background = false;
-                var process_8bit = false;
-                var palette = $.terminal.ansi_colors.palette;
-                for(var i in controls) {
-                    num = parseInt(controls[i], 10);
-                    switch(num) {
-                    case 1:
-                        styles.push('b');
-                        bold = true;
-                        faited = false;
-                        break;
-                    case 4:
-                        styles.push('u');
-                        break;
-                    case 3:
-                        styles.push('i');
-                        break;
-                    case 5:
-                        process_8bit = true;
-                        break;
-                    case 38:
-                        _8bit_color = true;
-                        break;
-                    case 48:
-                        _8bit_background = true;
-                        break;
-                    case 2:
-                        faited = true;
-                        bold = false;
-                        break;
-                    case 7:
-                        reverse = true;
-                        break;
-                    default:
-                        if (_8bit_color && process_8bit && palette[num-1]) {
-                            output_color = palette[num-1];
-                        } else if (color[num]) {
-                            output_color = color[num];
-                        }
-                        if (_8bit_background && process_8bit && palette[num-1]) {
-                            output_background = palette[num-1];
-                        } else if (background[num]) {
-                            output_background = background[num];
-                        }
-                    }
-                    if (num !== 5) {
-                        process_8bit = false;
-                    }
-                }
-                if (reverse) {
-                    if (output_color && output_background) {
-                        var tmp = output_background;
-                        output_background = output_color;
-                        output_color = tmp;
-                    } else {
-                        output_color = 'black';
-                        output_background = 'white';
-                    }
-                }
-                var colors, backgrounds;
-                if (bold) {
-                    colors = backgrounds = $.terminal.ansi_colors.bold;
-                } else if (faited) {
-                    colors = backgrounds = $.terminal.ansi_colors.faited;
-                } else {
-                    colors = backgrounds = $.terminal.ansi_colors.normal;
-                }
-                return [styles.join(''),
-                        _8bit_color ? output_color : colors[output_color],
-                        _8bit_background ? output_background : backgrounds[output_background]
-                       ];
-            }
-            return function(input) {
-                var splitted = input.split(/(\x1B\[[0-9;]*[A-Za-z])/g);
-                if (splitted.length == 1) {
-                    return input;
-                }
-                var output = [];
-                //skip closing at the begining
-                if (splitted.length > 3 && splitted.slice(0,3).join('') == '[0m') {
-                    splitted = splitted.slice(3);
-                }
-                var inside = false, next, prev_color, prev_background, code, match;
-                for (var i=0; i<splitted.length; ++i) {
-                    match = splitted[i].match(/^\x1B\[([0-9;]*)([A-Za-z])$/);
-                    if (match) {
-                        switch (match[2]) {
-                        case 'm':
-                            if (match[1] === '') {
-                                continue;
-                            }
-                            if (match[1] !== '0') {
-                                code = format_ansi(match[1]);
-                            }
-                            if (inside) {
-                                output.push(']');
-                                if (match[1] == '0') {
-                                    //just closing
-                                    inside = false;
-                                    prev_color = prev_background = '';
-                                } else {
-                                    // someone forget to close - move to next
-                                    code[1] = code[1] || prev_color;
-                                    code[2] = code[2] || prev_background;
-                                    output.push('[[' + code.join(';') + ']');
-                                    // store colors to next use
-                                    if (code[1]) {
-                                        prev_color = code[1];
-                                    }
-                                    if (code[2]) {
-                                        prev_background = code[2];
-                                    }
-                                }
-                            } else {
-                                if (match[1] != '0') {
-                                    inside = true;
-                                    output.push('[[' + code.join(';') + ']');
-                                    // store colors to next use
-                                    if (code[1]) {
-                                        prev_color = code[1];
-                                    }
-                                    if (code[2]) {
-                                        prev_background = code[2];
-                                    }
-                                }
-                            }
-                            break;
-                        }
-                    } else {
-                        output.push(splitted[i]);
-                    }
-                }
-                if (inside) {
-                    output.push(']');
-                }
-                return output.join(''); //.replace(/\[\[[^\]]+\]\]/g, '');
-            };
-        })(),
-        // -----------------------------------------------------------------------
-        // :: Function splits arguments and works with strings like
-        // :: 'asd' 'asd\' asd' "asd asd" asd\ 123 -n -b / [^ ]+ / /\s+/ asd\ asd
-        // :: it creates a regex and numbers and replaces escape characters in double
-        // :: quotes
-        // -----------------------------------------------------------------------
-        parseArguments: function(string) {
-            return $.map(string.match(command_re) || [], function(arg) {
-                if (arg[0] === "'" && arg[arg.length-1] === "'") {
-                    return arg.replace(/^'|'$/g, '');
-                } else if (arg[0] === '"' && arg[arg.length-1] === '"') {
-                    arg = arg.replace(/^"|"$/g, '').replace(/\\([" ])/g, '$1');
-                    return arg.replace(/\\\\|\\t|\\n/g, function(string) {
-                        if (string[1] === 't') {
-                            return '\t';
-                        } else if (string[1] === 'n') {
-                            return '\n';
-                        } else {
-                            return '\\';
-                        }
-                    }).replace(/\\x([0-9a-f]+)/gi, function(_, hex) {
-                        return String.fromCharCode(parseInt(hex, 16));
-                    }).replace(/\\0([0-7]+)/g, function(_, oct) {
-                        return String.fromCharCode(parseInt(oct, 8));
-                    });
-                } else if (arg.match(/^\/(\\\/|[^\/])+\/[gimy]*$/)) {
-                    var m = arg.match(/^\/([^\/]+)\/([^\/]*)$/);
-                    return new RegExp(m[1], m[2]);
-                } else if (arg.match(/^-?[0-9]+$/)) {
-                    return parseInt(arg, 10);
-                } else if (arg.match(/^[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?$/)) {
-                    return parseFloat(arg);
-                } else {
-                    return arg.replace(/\\ /g, ' ');
-                }
-            });
-        },
-        // -----------------------------------------------------------------------
-        // :: Split arguments: it only strips single and double quotes and escapes
-        // :: spaces
-        // -----------------------------------------------------------------------
-        splitArguments: function(string) {
-            return $.map(string.match(command_re) || [], function(arg) {
-                if (arg[0] === "'" && arg[arg.length-1] === "'") {
-                    return arg.replace(/^'|'$/g, '');
-                } else if (arg[0] === '"' && arg[arg.length-1] === '"') {
-                    return arg.replace(/^"|"$/g, '').replace(/\\([" ])/g, '$1');
-                } else if (arg[0] === '/' && arg[arg.length-1] == '/') {
-                    return arg;
-                } else {
-                    return arg.replace(/\\ /g, ' ');
-                }
-            });
-        },
-        // -----------------------------------------------------------------------
-        // :: Function that returns an object {name,args}. Arguments are parsed
-        // :: using the function parseArguments
-        // -----------------------------------------------------------------------
-        parseCommand: function(string) {
-            return processCommand(string, $.terminal.parseArguments);
-        },
-        // -----------------------------------------------------------------------
-        // :: Same as parseCommand but arguments are parsed using splitArguments
-        // -----------------------------------------------------------------------
-        splitCommand: function(string) {
-            return processCommand(string, $.terminal.splitArguments);
-        },
-        // -----------------------------------------------------------------------
-        // :: Test $.terminal functions using terminal
-        // -----------------------------------------------------------------------
-        test: function() {
-            var term = $.terminal.active();
-            if (!term) {
-                term = $('body').terminal($.noop).css('margin', 0);
-                var margin = term.outerHeight() - term.height();
-                var $win = $(window);
-                $win.resize(function() {
-                    term.css('height', $(window).height()-20);
-                }).resize();
-            }
-            term.echo('Testing...');
-            function assert(cond, msg) {
-                term.echo(msg + ' &#91;' + (cond ? '[[b;#44D544;]PASS]' : '[[b;#FF5555;]FAIL]') + '&#93;');
-            }
-            var string = 'name "foo bar" baz /^asd [x]/ str\\ str 10 1e10';
-            var cmd = $.terminal.splitCommand(string);
-            assert(cmd.name === 'name' && cmd.args[0] === 'foo bar' &&
-                  cmd.args[1] === 'baz' && cmd.args[2] === '/^asd [x]/' &&
-                  cmd.args[3] === 'str str' && cmd.args[4] === '10' &&
-                  cmd.args[5] === '1e10', '$.terminal.splitCommand');
-            cmd = $.terminal.parseCommand(string);
-            assert(cmd.name === 'name' && cmd.args[0] === 'foo bar' &&
-                  cmd.args[1] === 'baz' && $.type(cmd.args[2]) === 'regexp' &&
-                  cmd.args[2].source === '^asd [x]' &&
-                  cmd.args[3] === 'str str' && cmd.args[4] === 10 &&
-                  cmd.args[5] === 1e10, '$.terminal.parseCommand');
-            string = '\x1b[2;31;46mFoo\x1b[1;3;4;32;45mBar\x1b[0m\x1b[7mBaz';
-            assert($.terminal.from_ansi(string) ===
-                  '[[;#640000;#008787]Foo][[biu;#44D544;#F5F]Bar][[;#000;#AAA]Baz]',
-                   '$.terminal.from_ansi');
-            string = '[[biugs;#fff;#000]Foo][[i;;;foo]Bar][[ous;;]Baz]';
-            term.echo('$.terminal.format');
-            assert($.terminal.format(string) === '<span style="font-weight:bold;text-decoration:underline line-through;font-style:italic;color:#fff;text-shadow:0 0 5px #fff;background-color:#000" data-text="Foo">Foo</span><span style="font-style:italic;" class="foo" data-text="Bar">Bar</span><span style="text-decoration:underline line-through overline;" data-text="Baz">Baz</span>', '\tformatting');
-            string = 'http://terminal.jcubic.pl/examples.php https://www.google.com/?q=jquery%20terminal';
-            assert($.terminal.format(string) === '<a target="_blank" href="http://terminal.jcubic.pl/examples.php">http://terminal.jcubic.pl/examples.php</a> <a target="_blank" href="https://www.google.com/?q=jquery%20terminal">https://www.google.com/?q=jquery%20terminal</a>', '\turls');
-            string = 'foo@bar.com baz.quux@example.com';
-            assert($.terminal.format(string) === '<a href="mailto:foo@bar.com">foo@bar.com</a> <a href="mailto:baz.quux@example.com">baz.quux@example.com</a>', '\temails');
-            string = '-_-[[biugs;#fff;#000]Foo]-_-[[i;;;foo]Bar]-_-[[ous;;]Baz]-_-';
-            assert($.terminal.strip(string) === '-_-Foo-_-Bar-_-Baz-_-', '$.terminal.strip');
-            string = '[[bui;#fff;]Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla sed dolor nisl, in suscipit justo. Donec a enim et est porttitor semper at vitae augue. Proin at nulla at dui mattis mattis. Nam a volutpat ante. Aliquam consequat dui eu sem convallis ullamcorper. Nulla suscipit, massa vitae suscipit ornare, tellus] est [[b;;#f00]consequat nunc, quis blandit elit odio eu arcu. Nam a urna nec nisl varius sodales. Mauris iaculis tincidunt orci id commodo. Aliquam] non magna quis [[i;;]tortor malesuada aliquam] eget ut lacus. Nam ut vestibulum est. Praesent volutpat tellus in eros dapibus elementum. Nam laoreet risus non nulla mollis ac luctus [[ub;#fff;]felis dapibus. Pellentesque mattis elementum augue non sollicitudin. Nullam lobortis fermentum elit ac mollis. Nam ac varius risus. Cras faucibus euismod nulla, ac auctor diam rutrum sit amet. Nulla vel odio erat], ac mattis enim.';
-            term.echo('$.terminal.split_equal');
-            var cols = [10, 40, 60, 400];
-            for (var i=cols.length; i--;) {
-                var lines = $.terminal.split_equal(string, cols[i]);
-                var success = true;
-                for (var j=0; j<lines.length; ++j) {
-                    if ($.terminal.strip(lines[j]).length > cols[i]) {
-                        success = false;
-                        break;
-                    }
-                }
-                assert(success, '\tsplit ' + cols[i]);
-            }
-        }
-    };
-
-    // -----------------------------------------------------------------------
-    // Helper plugins
-    // -----------------------------------------------------------------------
-    $.fn.visible = function() {
-        return this.css('visibility', 'visible');
-    };
-    $.fn.hidden = function() {
-        return this.css('visibility', 'hidden');
-    };
-    // -----------------------------------------------------------------------
-    // JSON-RPC CALL
-    // -----------------------------------------------------------------------
-    var ids = {};
-    $.jrpc = function(url, method, params, success, error) {
-        ids[url] = ids[url] || 0;
-        var request = $.json_stringify({
-           'jsonrpc': '2.0', 'method': method,
-            'params': params, 'id': ++ids[url]});
-        return $.ajax({
-            url: url,
-            data: request,
-            success: function(result, status, jqXHR) {
-                var content_type = jqXHR.getResponseHeader('Content-Type');
-                if (!content_type.match(/application\/json/)) {
-                    if (console && console.warn) {
-                        console.warn('Response Content-Type is not application/json');
-                    } else {
-                        throw new Error('WARN: Response Content-Type is not application/json');
-                    }
-                }
-                var json;
-                try {
-                    json = $.parseJSON(result);
-                } catch (e) {
-                    if (error) {
-                        error(jqXHR, 'Invalid JSON', e);
-                    } else {
-                        throw new Error('Invalid JSON');
-                    }
-                    return;
-                }
-                // don't catch errors in success callback
-                success(json, status, jqXHR);
-            },
-            error: error,
-            contentType: 'application/json',
-            dataType: 'text',
-            async: true,
-            cache: false,
-            //timeout: 1,
-            type: 'POST'});
-    };
-
-    // -----------------------------------------------------------------------
-    function is_scrolled_into_view(elem) {
-        var docViewTop = $(window).scrollTop();
-        var docViewBottom = docViewTop + $(window).height();
-
-        var elemTop = $(elem).offset().top;
-        var elemBottom = elemTop + $(elem).height();
-
-        return ((elemBottom >= docViewTop) && (elemTop <= docViewBottom));
-    }
-    // -----------------------------------------------------------------------
-    // :: Create fake terminal to calcualte the dimention of one character
-    // :: this will make terminal work if terminal div is not added to the
-    // :: DOM at init like with:
-    // :: $('<div/>').terminal().echo('foo bar').appendTo('body');
-    // -----------------------------------------------------------------------
-    function char_size() {
-        var temp = $('<div class="terminal"><div class="cmd"><span>&nbsp;' +
-                     '</span></div></div>').appendTo('body');
-        var span = temp.find('span');
-        var result = {
-            width: span.width(),
-            height: span.outerHeight()
-        };
-        temp.remove();
-        return result;
-    }
-    // -----------------------------------------------------------------------
-    // :: calculate numbers of characters
-    // -----------------------------------------------------------------------
-    function get_num_chars(terminal) {
-        var width = char_size().width;
-        var result = Math.floor(terminal.width() / width);
-        if (have_scrollbars(terminal)) {
-            var SCROLLBAR_WIDTH = 20;
-            // assume that scrollbars are 20px - in my Laptop with
-            // Linux/Chrome they are 16px
-            var margins = terminal.innerWidth() - terminal.width();
-            result -= Math.ceil((SCROLLBAR_WIDTH - margins / 2) / (width-1));
-        }
-        return result;
-    }
-    // -----------------------------------------------------------------------
-    // :: Calculate number of lines that fit without scroll
-    // -----------------------------------------------------------------------
-    function get_num_rows(terminal) {
-        return Math.floor(terminal.height() / char_size().height);
-    }
-    // -----------------------------------------------------------------------
-    // :: Get Selected Text (this is internal because it return text even if
-    // :: it's outside of terminal, is used to paste text to the terminal)
-    // -----------------------------------------------------------------------
-    function getSelectedText() {
-        if (window.getSelection || document.getSelection) {
-            var selection = (window.getSelection || document.getSelection)();
-            if (selection.text) {
-                return selection.text;
-            } else {
-                return selection.toString();
-            }
-        } else if (document.selection) {
-            return document.selection.createRange().text;
-        }
-    }
-    // -----------------------------------------------------------------------
-    // :: check if div have scrollbars (need to have overflow auto or always)
-    // -----------------------------------------------------------------------
-    function have_scrollbars(div) {
-        return div.get(0).scrollHeight > div.innerHeight();
-    }
-    // -----------------------------------------------------------------------
-    // :: TERMINAL PLUGIN CODE
-    // -----------------------------------------------------------------------
-    var version = '0.8.7';
-    var version_set = !version.match(/^\{\{/);
-    var copyright = 'Copyright (c) 2011-2013 Jakub Jankiewicz <http://jcubic.pl>';
-    var version_string = version_set ? ' version ' + version : ' ';
-    //regex is for placing version string aligned to the right
-    var reg = new RegExp(" {" + version_string.length + "}$");
-    // -----------------------------------------------------------------------
-    // :: Terminal Signatures
-    // -----------------------------------------------------------------------
-    var signatures = [
-        ['jQuery Terminal', '(c) 2011-2013 jcubic'],
-        ['jQuery Terminal Emulator' + (version_set ? ' v. ' + version : ''),
-         copyright.replace(/ *<.*>/, '')],
-        ['jQuery Terminal Emulator' + (version_set ? version_string : ''),
-         copyright.replace(/^Copyright /, '')],
-        ['      _______                 ________                        __',
-         '     / / _  /_ ____________ _/__  ___/______________  _____  / /',
-         ' __ / / // / // / _  / _/ // / / / _  / _/     / /  \\/ / _ \\/ /',
-         '/  / / // / // / ___/ // // / / / ___/ // / / / / /\\  / // / /__',
-         '\\___/____ \\\\__/____/_/ \\__ / /_/____/_//_/ /_/ /_/  \\/\\__\\_\\___/',
-         '         \\/          /____/                                   '.replace(reg, ' ') +
-         version_string,
-         copyright],
-        ['      __ _____                     ________                              __',
-         '     / // _  /__ __ _____ ___ __ _/__  ___/__ ___ ______ __ __  __ ___  / /',
-         ' __ / // // // // // _  // _// // / / // _  // _//     // //  \\/ // _ \\/ /',
-         '/  / // // // // // ___// / / // / / // ___// / / / / // // /\\  // // / /__',
-         '\\___//____ \\\\___//____//_/ _\\_  / /_//____//_/ /_/ /_//_//_/ /_/ \\__\\_\\___/',
-         '          \\/              /____/                                          '.replace(reg, '') +
-         version_string,
-         copyright]
-    ];
-    // -----------------------------------------------------------------------
-    // :: Default options
-    // -----------------------------------------------------------------------
-    $.terminal.defaults = {
-        prompt: '> ',
-        history: true,
-        exit: true,
-        clear: true,
-        enabled: true,
-        historySize: 60,
-        checkArity: true,
-        exceptionHandler: null,
-        cancelableAjax: true,
-        processArguments: true,
-        linksNoReferrer: false,
-        login: null,
-        outputLimit: -1,
-        onAjaxError: null,
-        onRPCError: null,
-        completion: false,
-        historyFilter: null,
-        onInit: $.noop,
-        onClear: $.noop,
-        onBlur: $.noop,
-        onFocus: $.noop,
-        onTerminalChange: $.noop,
-        onExit: $.noop,
-        keypress: $.noop,
-        keydown: $.noop,
-        strings: {
-            wrongPasswordTryAgain: "Wrong password try again!",
-            wrongPassword: "Wrong password!",
-            ajaxAbortError: "Error while aborting ajax call!",
-            wrongArity: "Wrong number of arguments. Function '%s' expect %s got %s!",
-            commandNotFound: "Command '%s' Not Found!",
-            oneRPCWithIgnore: "You can use only one rpc with ignoreSystemDescribe",
-            oneInterpreterFunction: "You can't use more then one function (rpc with " +
-                "ignoreSystemDescribe is count as one)",
-            loginFunctionMissing: "You don't have login function",
-            noTokenError: "Access denied (no token)",
-            serverResponse: "Server reponse is",
-            wrongGreetings: "Wrong value of greetings parameter",
-            notWhileLogin: "You can't call that function while in login",
-            loginIsNotAFunction: "Authenticate must be a function",
-            canExitError: "You can't exit from main interpeter",
-            invalidCompletion: "Invalid completion",
-            login: "login",
-            password: "password"
-        }
-    };
-    // -----------------------------------------------------------------------
-    // :: All terminal globals
-    // -----------------------------------------------------------------------
-    var requests = []; // for canceling on CTRL+D
-    var terminals = new Cycle(); // list of terminals global in this scope
-    $.fn.terminal = function(init_interpreter, options) {
-        // -----------------------------------------------------------------------
-        // :: helper function
-        // -----------------------------------------------------------------------
-        function get_processed_command(command) {
-            if (typeof settings.processArguments === 'function') {
-                return processCommand(command, settings.processArguments);
-            } else if (settings.processArguments) {
-                return $.terminal.parseCommand(command);
-            } else {
-                return $.terminal.splitCommand(command);
-            }
-        }
-        // -----------------------------------------------------------------------
-        // :: Display object on terminal
-        // -----------------------------------------------------------------------
-        function display_object(object) {
-            if (typeof object === 'string') {
-                self.echo(object);
-            } else if (object instanceof Array) {
-                self.echo($.map(object, function(object) {
-                    return $.json_stringify(object);
-                }).join(' '));
-            } else if (typeof object === 'object') {
-                self.echo($.json_stringify(object));
-            } else {
-                self.echo(object);
-            }
-        }
-        // -----------------------------------------------------------------------
-        // :: Helper function
-        // -----------------------------------------------------------------------
-        function display_json_rpc_error(error) {
-            if (typeof settings.onRPCError === 'function') {
-                settings.onRPCError.call(self, error);
-            } else {
-                self.error('&#91;RPC&#93; ' + error.message);
-            }
-        }
-        // -----------------------------------------------------------------------
-        // :: Create interpreter function from url string
-        // -----------------------------------------------------------------------
-        function make_basic_json_rpc_interpreter(url) {
-            var service = function(method, params) {
-                self.pause();
-                $.jrpc(url, method, params, function(json) {
-                    if (!json.error) {
-                        if (typeof settings.processRPCResponse === 'function') {
-                            settings.processRPCResponse.call(self, json.result);
-                        } else {
-                            display_object(json.result);
-                        }
-                    } else {
-                        display_json_rpc_error(json.error);
-                    }
-                    self.resume();
-                }, ajax_error);
-            };
-            //this is the interpreter function
-            return function(command, terminal) {
-                if (command === '') {
-                    return;
-                }
-                command = get_processed_command(command);
-                if (!settings.login || command.name === 'help') {
-                    // allows to call help without a token
-                    service(command.name, command.args);
-                } else {
-                    var token = terminal.token();
-                    if (token) {
-                        service(command.name, [token].concat(command.args));
-                    } else {
-                        //should never happen
-                        terminal.error('&#91;AUTH&#93; ' +
-                                       strings.noTokenError);
-                    }
-                }
-            };
-        }
-        // -----------------------------------------------------------------------
-        // :: Create interpreter function from Object. If the value is object
-        // :: it will create nested interpreters
-        // -----------------------------------------------------------------------
-        function make_object_interpreter(object, arity, fallback) {
-            // function that maps commands to object methods
-            // it keeps terminal context
-            return function(user_command, terminal) {
-                if (user_command === '') {
-                    return;
-                }
-                //command = split_command_line(command);
-                var command = get_processed_command(user_command);
-                var val = object[command.name];
-                var type = $.type(val);
-                if (type === 'function') {
-                    if (arity && val.length !== command.args.length) {
-                        self.error("&#91;Arity&#93; " +
-                                   sprintf(strings.wrongArity,
-                                           command.name,
-                                           val.length,
-                                           command.args.length));
-                    } else {
-                        return val.apply(self, command.args);
-                    }
-                } else if (type === 'object' || type === 'string') {
-                    var commands = [];
-                    if (type === 'object') {
-                        commands = Object.keys(val);
-                        val = make_object_interpreter(val, arity);
-                    }
-                    terminal.push(val, {
-                        prompt: command.name + '> ',
-                        name: command.name,
-                        completion: type === 'object' ? function(term, string, callback) {
-                            callback(commands);
-                        } : undefined
-                    });
-                } else {
-                    if ($.type(fallback) === 'function') {
-                        fallback(user_command, self);
-                    } else if ($.type(settings.onCommandNotFound) === 'function') {
-                        settings.onCommandNotFound(user_command, self);
-                    } else {
-                        terminal.error(sprintf(strings.commandNotFound, command.name));
-                    }
-                }
-            };
-        }
-        // -----------------------------------------------------------------------
-        function ajax_error(xhr, status, error) {
-            self.resume(); // onAjaxError can use pause/resume call it first
-            if (typeof settings.onAjaxError == 'function') {
-                settings.onAjaxError.call(self, xhr, status, error);
-            } else if (status !== 'abort') {
-                self.error('&#91;AJAX&#93; ' + status + ' - ' +
-                           strings.serverResponse +
-                           ': \n' + xhr.responseText);
-            }
-        }
-        // -----------------------------------------------------------------------
-        function make_json_rpc_object(url, success) {
-            $.jrpc(url, 'system.describe', [], function(ret) {
-                var commands = [];
-                if (ret.procs) {
-                    var interpreter_object = {};
-                    $.each(ret.procs, function(_, proc) {
-                        interpreter_object[proc.name] = function() {
-                            var args = Array.prototype.slice.call(arguments);
-                            if (settings.checkArity && proc.params &&
-                                proc.params.length !== args.length) {
-                                self.error("&#91;Arity&#93; " +
-                                           sprintf(strings.wrongArity,
-                                                   proc.name,
-                                                   proc.params.length,
-                                                   args.length));
-                            } else {
-                                self.pause();
-                                $.jrpc(url, proc.name, args, function(json) {
-                                    if (json.error) {
-                                        display_json_rpc_error(json.error);
-                                    } else {
-                                        display_object(json.result);
-                                    }
-                                    self.resume();
-                                }, ajax_error);
-                            }
-                        };
-                    });
-                    success(interpreter_object);
-                } else {
-                    success(null);
-                }
-            }, function() {
-                success(null);
-            });
-        }
-        // -----------------------------------------------------------------------
-        function make_interpreter(user_interpreter, finalize) {
-            finalize = finalize || $.noop;
-            var type = $.type(user_interpreter);
-            var result = {};
-            var commands;
-            var rpc_count = 0; // only one rpc can be use for array
-            var function_interpreter;
-            if (type === 'array') {
-                var object = {};
-                // recur will be called when previous acync call is finished
-                (function recur(interpreters, success) {
-                    if (interpreters.length) {
-                        var first = interpreters[0];
-                        var rest = interpreters.slice(1);
-                        var type = $.type(first);
-                        if (type === 'string') {
-                            rpc_count++;
-                            self.pause();
-                            if (settings.ignoreSystemDescribe) {
-                                if (rpc_count === 1) {
-                                    function_interpreter = make_basic_json_rpc_interpreter(first);
-                                } else {
-                                    self.error(strings.oneRPCWithIgnore);
-                                }
-                                recur(rest, success);
-                            } else {
-                                make_json_rpc_object(first, function(new_object) {
-                                    // will ignore rpc in array that don't have system.describe
-                                    if (new_object) {
-                                        $.extend(object, new_object);
-                                    }
-                                    self.resume();
-                                    recur(rest, success);
-                                });
-                            }
-                        } else if (type === 'function') {
-                            if (function_interpreter) {
-                                self.error(strings.oneInterpreterFunction);
-                            } else {
-                                function_interpreter = first;
-                            }
-                        } else if (type === 'object') {
-                            $.extend(object, first);
-                            recur(rest, success);
-                        }
-                    } else {
-                        success();
-                    }
-                })(user_interpreter, function() {
-                    commands = Object.keys(object);
-                    result.interpreter = make_object_interpreter(object, false, function_interpreter);
-                    result.completion = function(term, string, callback) {
-                        callback(commands);
-                    };
-                    finalize(result);
-                });
-            } else if (type === 'string') {
-                if (settings.ignoreSystemDescribe) {
-                    finalize({
-                        interpreter: make_basic_json_rpc_interpreter(user_interpreter),
-                        completion: settings.completion
-                    });
-                } else {
-                    self.pause();
-                    make_json_rpc_object(user_interpreter, function(object) {
-                        if (object) {
-                            result.interpreter = make_object_interpreter(object, false);
-                            result.completion = function(term, string, callback) {
-                                callback(commands);
-                            };
-                        } else {
-                            // no procs in system.describe
-                            result.interpreter = make_basic_json_rpc_interpreter(user_interpreter);
-                            result.completion = settings.completion;
-                        }
-                        self.resume();
-                        finalize(result);
-                    });
-                }
-            } else if (type === 'object') {
-                commands = Object.keys(user_interpreter);
-                result.interpreter = make_object_interpreter(user_interpreter, settings.checkArity);
-                result.completion = function(term, string, callback) {
-                    callback(commands);
-                };
-                finalize(result);
-            } else {
-                // allow $('<div/>).terminal();
-                if (type === 'undefined') {
-                    user_interpreter = $.noop;
-                } else if (type !== 'function') {
-                    throw type + " is invalid interpreter value";
-                }
-                finalize({
-                    interpreter: user_interpreter,
-                    completion: settings.completion
-                });
-            }
-        }
-        // -----------------------------------------------------------------------
-        // :: Create JSON-RPC authentication function
-        // -----------------------------------------------------------------------
-        function make_json_rpc_login(url, login) {
-            var method = $.type(login) === 'boolean' ? 'login' : login;
-            return function(user, passwd, callback, term) {
-                self.pause();
-                $.jrpc(url,
-                       method,
-                       [user, passwd],
-                       function(response) {
-                           self.resume();
-                           if (!response.error && response.result) {
-                               callback(response.result);
-                           } else {
-                               // null will trigger message that login fail
-                               callback(null);
-                           }
-                       }, ajax_error);
-            };
-            //default name is login so you can pass true
-        }
-        // -----------------------------------------------------------------------
-        // :: Return exception message as string
-        // -----------------------------------------------------------------------
-        function exception_message(e) {
-            if (typeof e === 'string') {
-                return e;
-            } else if (typeof e.fileName === 'string') {
-                return e.fileName + ': ' + e.message;
-            } else {
-                return e.message;
-            }
-        }
-        // -----------------------------------------------------------------------
-        // :: display Exception on terminal
-        // -----------------------------------------------------------------------
-        function display_exception(e, label) {
-            if (typeof settings.exceptionHandler == 'function') {
-                settings.exceptionHandler.call(self, e);
-            } else {
-                self.exception(e, label);
-            }
-        }
-        // -----------------------------------------------------------------------
-        function scroll_to_bottom() {
-            var scrollHeight = scroll_object.prop ? scroll_object.prop('scrollHeight') :
-                scroll_object.attr('scrollHeight');
-            scroll_object.scrollTop(scrollHeight);
-        }
-        // -----------------------------------------------------------------------
-        // :: validating if object is a string or a function, call that function
-        // :: and display the exeption if any
-        // -----------------------------------------------------------------------
-        function validate(label, object) {
-            try {
-                if (typeof object === 'function') {
-                    object(function() {
-                        // don't care
-                    });
-                } else if (typeof object !== 'string') {
-                    var msg = label + ' must be string or function';
-                    throw msg;
-                }
-            } catch (e) {
-                display_exception(e, label.toUpperCase());
-                return false;
-            }
-            return true;
-        }
-        // -----------------------------------------------------------------------
-        // :: Draw line - can have line breaks and be longer than the width of
-        // :: the terminal, there are 2 options raw and finalize
-        // :: raw - will not encode the string and finalize if a function that
-        // :: will have div container of the line as first argument
-        // :: NOTE: it formats and appends lines to output_buffer. The actual
-        // :: append to terminal output happens in the flush function
-        // -----------------------------------------------------------------------
-        var output_buffer = [];
-        var NEW_LINE = 1;
-        function draw_line(string, options) {
-            // prevent exception in display exception
-            try {
-                var line_settings = $.extend({
-                    raw: false,
-                    finalize: $.noop
-                }, options || {});
-                string = $.type(string) === "function" ? string() : string;
-                string = $.type(string) === "string" ? string : String(string);
-                var i, len;
-                if (!line_settings.raw) {
-                    string = $.terminal.encode(string);
-                }
-                string = $.terminal.overtyping(string);
-                string = $.terminal.from_ansi(string);
-                output_buffer.push(NEW_LINE);
-                if (!line_settings.raw && (string.length > num_chars || string.match(/\n/))) {
-                    var array = $.terminal.split_equal(string, num_chars);
-                    for (i = 0, len = array.length; i < len; ++i) {
-                        if (array[i] === '' || array[i] === '\r') {
-                            output_buffer.push('&nbsp;');
-                        } else {
-                            if (line_settings.raw) {
-                                output_buffer.push(array[i]);
-                            } else {
-                                output_buffer.push($.terminal.format(array[i], {
-                                    linksNoReferer: settings.linksNoReferer
-                                }));
-                            }
-                        }
-                    }
-                } else {
-                    if (!line_settings.raw) {
-                        string = $.terminal.format(string, {
-                            linksNoReferer: settings.linksNoReferer
-                        });
-                    }
-                    output_buffer.push(string);
-                }
-                output_buffer.push(line_settings.finalize);
-            } catch (e) {
-                output_buffer = [];
-                // don't display exception if exception throw in terminal
-                alert('[Internal Exception(draw_line)]:' + exception_message(e) + '\n' +
-                      e.stack);
-            }
-        }
-        // -----------------------------------------------------------------------
-        // Redraw all lines
-        // -----------------------------------------------------------------------
-        function redraw() {
-            command_line.resize(num_chars);
-            var o = output.empty().detach();
-            var lines_to_show;
-            if (settings.outputLimit >= 0) {
-                // flush will limit lines but if there is lot of
-                // lines we don't need to show them and then remove
-                // them from terminal
-                var limit = settings.outputLimit === 0 ?
-                    self.rows() :
-                    settings.outputLimit;
-                lines_to_show = lines.slice(lines.length-limit-1);
-            } else {
-                lines_to_show = lines;
-            }
-            $.each(lines_to_show, function(i, line) {
-                draw_line.apply(null, line); // line is an array
-            });
-            command_line.before(o);
-            self.flush();
-        }
-        // -----------------------------------------------------------------------
-        // :: Display user greetings or terminal signature
-        // -----------------------------------------------------------------------
-        function show_greetings() {
-            if (settings.greetings === undefined) {
-                self.echo(self.signature);
-            } else if (settings.greetings) {
-                var type = typeof settings.greetings;
-                if (type === 'string') {
-                    self.echo(settings.greetings);
-                } else if (type === 'function') {
-                    settings.greetings.call(self, self.echo);
-                } else {
-                    self.error(strings.wrongGreetings);
-                }
-            }
-        }
-        // -----------------------------------------------------------------------
-        // :: Display prompt and last command
-        // -----------------------------------------------------------------------
-        function echo_command(command) {
-            command = $.terminal.escape_brackets($.terminal.encode(command, true));
-            var prompt = command_line.prompt();
-            if (command_line.mask()) {
-                command = command.replace(/./g, '*');
-            }
-            if (typeof prompt === 'function') {
-                prompt(function(string) {
-                    self.echo(string + command);
-                });
-            } else {
-                self.echo(prompt + command);
-            }
-        }
-        // -----------------------------------------------------------------------
-        // :: Wrapper over interpreter, it implements exit and catches all exeptions
-        // :: from user code and displays them on the terminal
-        // -----------------------------------------------------------------------
-        function commands(command, silent, exec) {
-            try {
-                if (!ghost()) {
-                    prev_command = $.terminal.splitCommand(command).name;
-                    if (exec && typeof settings.historyFilter == 'function' &&
-                        settings.historyFilter(command) || !settings.historyFilter) {
-                        command_line.history().append(command);
-                    }
-                }
-                var interpreter = interpreters.top();
-                if (command === 'exit' && settings.exit) {
-                    var count = interpreters.size();
-                        self.token();
-                    if (count == 1 && self.token() || count > 1) {
-                        if (!silent) {
-                            echo_command(command);
-                        }
-                        self.pop();
-                    }
-                } else {
-                    if (!silent) {
-                        echo_command(command);
-                    }
-                    var position = lines.length-1;
-                    if (command === 'clear' && settings.clear) {
-                        self.clear();
-                    } else {
-                        // Execute command from the interpreter
-                        var result = interpreter.interpreter(command, self);
-                        if (result !== undefined) {
-                            // was lines after echo_command (by interpreter)
-                            if (position === lines.length-1) {
-                                lines.pop();
-                                if (result !== false) {
-                                    self.echo(result);
-                                }
-                            } else {
-                                if (result === false) {
-                                    lines = lines.slice(0, position).
-                                        concat(lines.slice(position+1));
-                                } else {
-                                    lines = lines.slice(0, position).
-                                        concat([result]).
-                                        concat(lines.slice(position+1));
-                                }
-                            }
-                            self.resize();
-                        }
-                    }
-                }
-            } catch (e) {
-                display_exception(e, 'USER');
-                self.resume();
-                throw e;
-            }
-        }
-        // -----------------------------------------------------------------------
-        // :: The logout function removes Storage, disables history and runs
-        // :: the login function. This function is called only when options.login
-        // :: function is defined. The check for this is in the self.pop method
-        // -----------------------------------------------------------------------
-        function global_logout() {
-            if (typeof settings.onBeforeLogout === 'function') {
-                try {
-                    if (settings.onBeforeLogout(self) === false) {
-                        return;
-                    }
-                } catch (e) {
-                    display_exception(e, 'onBeforeLogout');
-                    throw e;
-                }
-            }
-            logout();
-            if (typeof settings.onAfterLogout === 'function') {
-                try {
-                    settings.onAfterLogout(self);
-                } catch (e) {
-                    display_exception(e, 'onAfterlogout');
-                    throw e;
-                }
-            }
-            self.login(settings.login, true, initialize);
-        }
-        // -----------------------------------------------------------------------
-        function logout() {
-            var name = self.prefix_name(true) + '_';
-            $.Storage.remove(name + 'token');
-            $.Storage.remove(name + 'login');
-        }
-        // -----------------------------------------------------------------------
-        // :: Save the interpreter name for use with purge
-        // -----------------------------------------------------------------------
-        function maybe_append_name(interpreter_name) {
-            var storage_key = self.prefix_name() + '_interpreters';
-            var names = $.Storage.get(storage_key);
-            if (names) {
-                names = $.parseJSON(names);
-            } else {
-                names = [];
-            }
-            if ($.inArray(interpreter_name, names) == -1) {
-                names.push(interpreter_name);
-                $.Storage.set(storage_key, $.json_stringify(names));
-            }
-        }
-        // -----------------------------------------------------------------------
-        // :: Function enables history, sets prompt, runs interpreter function
-        // -----------------------------------------------------------------------
-        function prepare_top_interpreter(silent) {
-            var interpreter = interpreters.top();
-            var name = self.prefix_name(true);
-            if (!ghost()) {
-                maybe_append_name(name);
-            }
-            command_line.name(name);
-            if (typeof interpreter.prompt == 'function') {
-                command_line.prompt(function(command) {
-                    interpreter.prompt(command, self);
-                });
-            } else {
-                command_line.prompt(interpreter.prompt);
-            }
-            command_line.set('');
-            if (!silent && typeof interpreter.onStart === 'function') {
-                interpreter.onStart(self);
-            }
-        }
-        // ---------------------------------------------------------------------
-        function initialize() {
-            prepare_top_interpreter();
-            show_greetings();
-            // was_paused flag is workaround for case when user call exec before
-            // login and pause in onInit, 3rd exec will have proper timing (will
-            // execute after onInit resume)
-            var was_paused = false;
-            if (typeof settings.onInit === 'function') {
-                onPause = function() { // local in terminal
-                    was_paused = true;
-                };
-                try {
-                    settings.onInit(self);
-                } catch (e) {
-                    display_exception(e, 'OnInit');
-                    throw e;
-                } finally {
-                    onPause = $.noop;
-                    if (!was_paused) {
-                        // resume login if user didn't call pause in onInit
-                        // if user pause in onInit wait with exec until it resume
-                        self.resume();
-                    }
-                }
-            }
-        }
-        // ---------------------------------------------------------------------
-        // :: function complete the command
-        // ---------------------------------------------------------------------
-        function complete_helper(command, string, commands) {
-            var test = command_line.get().substring(0, command_line.position());
-            if (test !== command) {
-                // command line changed between TABS - ignore
-                return;
-            }
-            var regex = new RegExp('^' + $.terminal.escape_regex(string));
-            var matched = [];
-            for (var i=commands.length; i--;) {
-                if (regex.test(commands[i])) {
-                    matched.push(commands[i]);
-                }
-            }
-            if (matched.length === 1) {
-                self.insert(matched[0].replace(regex, '') + ' ');
-            } else if (matched.length > 1) {
-                if (tab_count >= 2) {
-                    echo_command(command);
-                    self.echo(matched.join('\t'));
-                    tab_count = 0;
-                } else {
-                    var found = false;
-                    var found_index;
-                    var j;
-                    loop:
-                    for (j=string.length; j<matched[0].length; ++j) {
-                        for (i=1; i<matched.length; ++i) {
-                            if (matched[0].charAt(j) !== matched[i].charAt(j)) {
-                                break loop;
-                            }
-                        }
-                        found = true;
-                    }
-                    if (found) {
-                        self.insert(matched[0].slice(0, j).replace(regex, ''));
-                    }
-                }
-            }
-        }
-        // ---------------------------------------------------------------------
-        // :: IF Ghost don't store anything in localstorage
-        // ---------------------------------------------------------------------
-        function ghost() {
-            return in_login || command_line.mask();
-        }
-        // ---------------------------------------------------------------------
-        // :: Keydown event handler
-        // ---------------------------------------------------------------------
-        function key_down(e) {
-            // Prevent to be executed by cmd: CTRL+D, TAB, CTRL+TAB (if more then
-            // one terminal)
-            var result, i, top = interpreters.top();
-            if ($.type(top.keydown) === 'function') {
-                result = top.keydown(e, self);
-                if (result !== undefined) {
-                    return result;
-                }
-            }
-            var completion;
-            if ((settings.completion && $.type(settings.completion) != 'boolean') &&
-                !top.completion) {
-                completion = settings.completion;
-            } else {
-                completion = top.completion;
-            }
-            // after text pasted into textarea in cmd plugin
-            self.oneTime(10, function() {
-                on_scrollbar_show_resize();
-            });
-            if ($.type(settings.keydown) === 'function') {
-                result = settings.keydown(e, self);
-                if (result !== undefined) {
-                    return result;
-                }
-            }
-            if (!self.paused()) {
-                if (e.which !== 9) { // not a TAB
-                    tab_count = 0;
-                }
-                if (e.which === 68 && e.ctrlKey) { // CTRL+D
-                    if (!in_login) {
-                        if (command_line.get() === '') {
-                            if (interpreters.size() > 1 ||
-                                settings.login !== undefined) {
-                                self.pop('');
-                            } else {
-                                self.resume();
-                                self.echo('');
-                            }
-                        } else {
-                            self.set_command('');
-                        }
-                    }
-                    return false;
-                } else if (e.which === 76 && e.ctrlKey) { // CTRL+L
-                    self.clear();
-                } else if (completion && e.which === 9) { // TAB
-                    // TODO: move this to cmd plugin
-                    //       add completion = array | function
-                    ++tab_count;
-                    // cursor can be in the middle of the command
-                    // so we need to get the text before the cursor
-                    var command = command_line.get().substring(0, command_line.position());
-                    var strings = command.split(' ');
-                    var string; // string before cursor that will be completed
-                    if (strings.length == 1) {
-                        string = strings[0];
-                    } else {
-                        string = strings[strings.length-1];
-                        for (i=strings.length-1; i>0; i--) {
-                            // treat escape space as part of the string
-                            if (strings[i-1][strings[i-1].length-1] == '\\') {
-                                string = strings[i-1] + ' ' + string;
-                            } else {
-                                break;
-                            }
-                        }
-                    }
-                    switch ($.type(completion)) {
-                    case 'function':
-                        completion(self, string, function(commands) {
-                            complete_helper(command, string, commands);
-                        });
-                        break;
-                    case 'array':
-                        complete_helper(command, string, completion);
-                        break;
-                    default:
-                        // terminal will not catch this because it's an event
-                        throw new Error($.terminal.defaults.strings.invalidCompletion);
-                    }
-                    return false;
-                } else if (e.which === 86 && e.ctrlKey) { // CTRL+V
-                    self.oneTime(1, function() {
-                        scroll_to_bottom();
-                    });
-                    return;
-                } else if (e.which === 9 && e.ctrlKey) { // CTRL+TAB
-                    if (terminals.length() > 1) {
-                        self.focus(false);
-                        return false;
-                    }
-                } else if (e.which === 34) { // PAGE DOWN
-                    self.scroll(self.height());
-                } else if (e.which === 33) { // PAGE UP
-                    self.scroll(-self.height());
-                } else {
-                    self.attr({scrollTop: self.attr('scrollHeight')});
-                }
-            } else if (e.which === 68 && e.ctrlKey) { // CTRL+D (if paused)
-                if (requests.length) {
-                    for (i=requests.length; i--;) {
-                        var r = requests[i];
-                        if (4 !== r.readyState) {
-                            try {
-                                r.abort();
-                            } catch (error) {
-                                self.error(strings.ajaxAbortError);
-                            }
-                        }
-                    }
-                    requests = [];
-                    // only resume if there are ajax calls
-                    self.resume();
-                }
-                return false;
-            }
-        }
-        // -----------------------------------------------------------------------
-        var self = this;
-        if (this.length > 1) {
-            return this.each(function() {
-                $.fn.terminal.call($(this),
-                                   init_interpreter,
-                                   $.extend({name: self.selector}, options));
-            });
-        } else {
-            // terminal already exists
-            if (self.data('terminal')) {
-                return self.data('terminal');
-            }
-            if (self.length === 0) {
-                throw 'Sorry, but terminal said that "' + self.selector +
-                    '" is not valid selector!';
-            }
-            //var names = []; // stack if interpeter names
-            var scroll_object;
-            var prev_command; // used for name on the terminal if not defined
-            var loged_in = false;
-            var tab_count = 0; // for tab completion
-            // array of line objects:
-            // - function (called whenever necessary, result is printed)
-            // - array (expected form: [line, settings])
-            // - anything else (cast to string when painted)
-            var lines = [];
-            var output; // .terminal-output jquery object
-            var terminal_id = terminals.length();
-            var num_chars; // numer of chars in line
-            var num_rows; // number of lines that fit without scrollbar
-            var command_list = []; // for tab completion
-            var url;
-            var in_login = false; // some Methods should not be called when login
-            // TODO: Try to use mutex like counter for pause/resume
-            var onPause = $.noop; // used to indicate that user call pause onInit
-            var old_width, old_height;
-            var dalyed_commands = []; // used when exec commands with pause
-            var settings = $.extend({},
-                                    $.terminal.defaults,
-                                    {name: self.selector},
-                                    options || {});
-            var strings = $.terminal.defaults.strings;
-            var enabled = settings.enabled;
-            var paused = false;
-            // -----------------------------------------------------------------------
-            // TERMINAL METHODS
-            // -----------------------------------------------------------------------
-            $.extend(self, $.omap({
-                // -----------------------------------------------------------------------
-                // :: Clear the output
-                // -----------------------------------------------------------------------
-                clear: function() {
-                    output.html('');
-                    command_line.set('');
-                    lines = [];
-                    try {
-                        settings.onClear(self);
-                    } catch (e) {
-                        display_exception(e, 'onClear');
-                        throw e;
-                    }
-                    self.attr({ scrollTop: 0});
-                    return self;
-                },
-                // -----------------------------------------------------------------------
-                // :: Return an object that can be used with import_view to restore the state
-                // -----------------------------------------------------------------------
-                export_view: function() {
-                    if (in_login) {
-                        throw new Exception(strings.notWhileLogin);
-                    }
-                    return {
-                        prompt: self.get_prompt(),
-                        command: self.get_command(),
-                        position: command_line.position(),
-                        lines: lines.slice(0)
-                    };
-                },
-                // -----------------------------------------------------------------------
-                // :: Restore the state of the previous exported view
-                // -----------------------------------------------------------------------
-                import_view: function(view) {
-                    if (in_login) {
-                        throw new Exception(strings.notWhileLogin);
-                    }
-                    self.set_prompt(view.prompt);
-                    self.set_command(view.command);
-                    command_line.position(view.position);
-                    lines = view.lines;
-                    redraw();
-                    return self;
-                },
-                // -----------------------------------------------------------------------
-                // :: Execute a command, it will handle commands that do AJAX calls
-                // :: and have delays, if the second argument is set to true it will not
-                // :: echo executed command
-                // -----------------------------------------------------------------------
-                exec: function(command, silent) {
-                    // both commands executed here (resume will call Terminal::exec)
-                    if (paused) {
-                        dalyed_commands.push([command, silent]);
-                    } else {
-                        commands(command, silent, true);
-                    }
-                    return self;
-                },
-                // -----------------------------------------------------------------------
-                // :: Function changes the prompt of the command line to login
-                // :: with a password and calls the user login function with
-                // :: the callback that expects a token. The login is successful
-                // :: if the user calls it with value that is truthy
-                // -----------------------------------------------------------------------
-                login: function(auth, infinite, success, error) {
-                    if (in_login) {
-                        throw new Error(strings.notWhileLogin);
-                    }
-                    if (typeof auth !== 'function') {
-                        throw new Error(strings.loginIsNotAFunction);
-                    }
-                    if (self.token(true) && self.login_name(true)) {
-                        if (typeof success == 'function') {
-                            success();
-                        }
-                        return self;
-                    }
-                    var user = null;
-                    // don't store login data in history
-                    if (settings.history) {
-                        command_line.history().disable();
-                    }
-                    in_login = true;
-                    return self.push(function(user) {
-                        self.set_mask(true).push(function(pass) {
-                            try {
-                                auth.call(self, user, pass, function(token, silent) {
-                                    if (token) {
-                                        self.pop().pop();
-                                        if (settings.history) {
-                                            command_line.history().enable();
-                                        }
-                                        var name = self.prefix_name(true) + '_';
-                                        $.Storage.set(name + 'token', token);
-                                        $.Storage.set(name + 'login', user);
-                                        in_login = false;
-                                        if (typeof success == 'function') {
-                                            // will be used internaly since users know
-                                            // when login success (they decide when
-                                            // it happen by calling the callback -
-                                            // this funtion)
-                                            success();
-                                        }
-                                    } else {
-                                        if (infinite) {
-                                            if (!silent) {
-                                                self.error(strings.wrongPasswordTryAgain);
-                                            }
-                                            self.pop().set_mask(false);
-                                        } else {
-                                            in_login = false;
-                                            if (!silent) {
-                                                self.error(strings.wrongPassword);
-                                            }
-                                            self.pop().pop();
-                                        }
-                                        // used only to call pop in push
-                                        if (typeof error == 'function') {
-                                            error();
-                                        }
-                                    }
-                                });
-                            } catch(e) {
-                                display_exception(e, 'USER(authentication)');
-                            }
-                        }, {
-                            prompt: strings.password + ': '
-                        });
-                    }, {
-                        prompt: strings.login + ': '
-                    });
-                },
-                // -----------------------------------------------------------------------
-                // :: User defined settings and defaults as well
-                // -----------------------------------------------------------------------
-                settings: settings,
-                // -----------------------------------------------------------------------
-                // :: Return commands function from top interpreter
-                // -----------------------------------------------------------------------
-                commands: function() {
-                    return interpreters.top().interpreter;
-                },
-                // -----------------------------------------------------------------------
-                // :: Low Level method that overwrites interpreter
-                // -----------------------------------------------------------------------
-                setInterpreter: function(user_interpreter, login) {
-                    function overwrite_interpreter() {
-                        self.pause();
-                        make_interpreter(user_interpreter, function(result) {
-                            self.resume();
-                            var top = interpreters.top();
-                            $.extend(top, result);
-                            prepare_top_interpreter(true);
-                        });
-                    }
-                    if ($.type(user_interpreter) == 'string' && login) {
-                        self.login(make_json_rpc_login(user_interpreter, login),
-                                   true,
-                                   overwrite_interpreter);
-                    } else {
-                        overwrite_interpreter();
-                    }
-                },
-                // -----------------------------------------------------------------------
-                // :: Show user greetings or terminal signature
-                // -----------------------------------------------------------------------
-                greetings: function() {
-                    show_greetings();
-                    return self;
-                },
-                // -----------------------------------------------------------------------
-                // :: Return true if terminal is paused false otherwise
-                // -----------------------------------------------------------------------
-                paused: function() {
-                    return paused;
-                },
-                // -----------------------------------------------------------------------
-                // :: Pause the terminal, it should be used for ajax calls
-                // -----------------------------------------------------------------------
-                pause: function() {
-                    onPause();
-                    if (!paused && command_line) {
-                        paused = true;
-                        self.disable();
-                        command_line.hidden();
-                    }
-                    return self;
-                },
-                // -----------------------------------------------------------------------
-                // :: Resume the previously paused terminal
-                // -----------------------------------------------------------------------
-                resume: function() {
-                    if (paused && command_line) {
-                        paused = false;
-                        self.enable();
-                        command_line.visible();
-                        var original = dalyed_commands;
-                        dalyed_commands = [];
-                        while (original.length) {
-                            self.exec.apply(self, original.shift());
-                        }
-                        scroll_to_bottom();
-                    }
-                    return self;
-                },
-                // -----------------------------------------------------------------------
-                // :: Return the number of characters that fit into the width of the terminal
-                // -----------------------------------------------------------------------
-                cols: function() {
-                    return num_chars;
-                },
-                // -----------------------------------------------------------------------
-                // :: Return the number of lines that fit into the height of the terminal
-                // -----------------------------------------------------------------------
-                rows: function() {
-                    return num_rows;
-                },
-                // -----------------------------------------------------------------------
-                // :: Return the History object
-                // -----------------------------------------------------------------------
-                history: function() {
-                    return command_line.history();
-                },
-                // -----------------------------------------------------------------------
-                // :: Switch to the next terminal
-                // -----------------------------------------------------------------------
-                next: function() {
-                    if (terminals.length() === 1) {
-                        return self;
-                    } else {
-                        var offsetTop = self.offset().top;
-                        var height = self.height();
-                        var scrollTop = self.scrollTop();
-                        if (!is_scrolled_into_view(self)) {
-                            self.enable();
-                            $('html,body').animate({scrollTop: offsetTop-50}, 500);
-                            return self;
-                        } else {
-                            terminals.front().disable();
-                            var next = terminals.rotate().enable();
-                            // 100 provides buffer in viewport
-                            var x = next.offset().top - 50;
-                            $('html,body').animate({scrollTop: x}, 500);
-                            try {
-                                settings.onTerminalChange(next);
-                            } catch (e) {
-                                display_exception(e, 'onTerminalChange');
-                                throw e;
-                            }
-                            return next;
-                        }
-                    }
-                },
-                // -----------------------------------------------------------------------
-                // :: Make the terminal in focus or blur depending on the first argument.
-                // :: If there is more then one terminal it will switch to next one, 
-                // :: if the second argument is set to true the events will be not fired.
-                // :: Used on init
-                // -----------------------------------------------------------------------
-                focus: function(toggle, silent) {
-                    self.oneTime(1, function() {
-                        if (terminals.length() === 1) {
-                            if (toggle === false) {
-                                try {
-                                    if (!silent && settings.onBlur(self) !== false) {
-                                        self.disable();
-                                    }
-                                } catch (e) {
-                                    display_exception(e, 'onBlur');
-                                    throw e;
-                                }
-                            } else {
-                                try {
-                                    if (!silent && settings.onFocus(self) !== false) {
-                                        self.enable();
-                                    }
-                                } catch (e) {
-                                    display_exception(e, 'onFocus');
-                                    throw e;
-                                }
-                            }
-                        } else {
-                            if (toggle === false) {
-                                self.next();
-                            } else {
-                                var front = terminals.front();
-                                if (front != self) {
-                                    front.disable();
-                                    if (!silent) {
-                                        try {
-                                            settings.onTerminalChange(self);
-                                        } catch (e) {
-                                            display_exception(e, 'onTerminalChange');
-                                            throw e;
-                                        }
-                                    }
-                                }
-                                terminals.set(self);
-                                self.enable();
-                            }
-                        }
-                    });
-                    return self;
-                },
-                // -----------------------------------------------------------------------
-                // :: Enable the terminal
-                // -----------------------------------------------------------------------
-                enable: function() {
-                    if (num_chars === undefined) {
-                        //enabling first time
-                        self.resize();
-                    }
-                    if (command_line) {
-                        command_line.enable();
-                        enabled = true;
-                    }
-                    return self;
-                },
-                // -----------------------------------------------------------------------
-                // :: Disable the terminal
-                // -----------------------------------------------------------------------
-                disable: function() {
-                    if (command_line) {
-                        enabled = false;
-                        command_line.disable();
-                    }
-                    return self;
-                },
-                // -----------------------------------------------------------------------
-                // :: return true if the terminal is enabled
-                // -----------------------------------------------------------------------
-                enabled: function() {
-                    return enabled;
-                },
-                // -----------------------------------------------------------------------
-                // :: Return the terminal signature depending on the size of the terminal
-                // -----------------------------------------------------------------------
-                signature: function() {
-                    var cols = self.cols();
-                    var i = cols < 15 ? null : cols < 35 ? 0 : cols < 55 ? 1 : cols < 64 ? 2 : cols < 75 ? 3 : 4;
-                    if (i !== null) {
-                        return signatures[i].join('\n') + '\n';
-                    } else {
-                        return '';
-                    }
-                },
-                // -----------------------------------------------------------------------
-                // :: Return the version number
-                // -----------------------------------------------------------------------
-                version: function() {
-                    return version;
-                },
-                // -----------------------------------------------------------------------
-                // :: Return actual command line object (jquery object with cmd methods)
-                // -----------------------------------------------------------------------
-                cmd: function() {
-                    return command_line;
-                },
-                // -----------------------------------------------------------------------
-                // :: Return the current command entered by terminal
-                // -----------------------------------------------------------------------
-                get_command: function() {
-                    return command_line.get();
-                },
-                // -----------------------------------------------------------------------
-                // :: Change the command line to the new one
-                // -----------------------------------------------------------------------
-                set_command: function(command) {
-                    command_line.set(command);
-                    return self;
-                },
-                // -----------------------------------------------------------------------
-                // :: Insert text into the command line after the cursor
-                // -----------------------------------------------------------------------
-                insert: function(string) {
-                    if (typeof string === 'string') {
-                        command_line.insert(string);
-                        return self;
-                    } else {
-                        throw "insert function argument is not a string";
-                    }
-                },
-                // -----------------------------------------------------------------------
-                // :: Set the prompt of the command line
-                // -----------------------------------------------------------------------
-                set_prompt: function(prompt) {
-                    if (validate('prompt', prompt)) {
-                        if (typeof prompt == 'function') {
-                            command_line.prompt(function(command) {
-                                prompt(command, self);
-                            });
-                        } else {
-                            command_line.prompt(prompt);
-                        }
-                        interpreters.top().prompt = prompt;
-                    }
-                    return self;
-                },
-                // -----------------------------------------------------------------------
-                // :: Return the prompt used by the terminal
-                // -----------------------------------------------------------------------
-                get_prompt: function() {
-                    return interpreters.top().prompt;
-                    // command_line.prompt(); - can be a wrapper
-                    //return command_line.prompt();
-                },
-                // -----------------------------------------------------------------------
-                // :: Enable or Disable mask depedning on the passed argument
-                // -----------------------------------------------------------------------
-                set_mask: function(display) {
-                    command_line.mask(display);
-                    return self;
-                },
-                // -----------------------------------------------------------------------
-                // :: Return the ouput of the terminal as text
-                // -----------------------------------------------------------------------
-                get_output: function(raw) {
-                    if (raw) {
-                        return lines;
-                    } else {
-                        return $.map(lines, function(item) {
-                            return typeof item[0] == 'function' ? item[0]() : item[0];
-                        }).join('\n');
-                    }
-                },
-                // -----------------------------------------------------------------------
-                // :: Recalculate and redraw everything
-                // -----------------------------------------------------------------------
-                resize: function(width, height) {
-                    if (width && height) {
-                        self.width(width);
-                        self.height(height);
-                    }
-                    width = self.width();
-                    height = self.height();
-                    var new_num_chars = get_num_chars(self);
-                    var new_num_rows = get_num_rows(self);
-                    // only if number of chars changed
-                    if (new_num_chars !== num_chars || new_num_rows !== num_rows) {
-                        num_chars = new_num_chars;
-                        num_rows = new_num_rows;
-                        redraw();
-                        if (typeof settings.onResize === 'function' &&
-                            (old_height !== height || old_width !== width)) {
-                            settings.onResize(self);
-                        }
-                        if (old_height !== height || old_width !== width) {
-                            old_height = height;
-                            old_width = width;
-                        }
-                    }
-                    return self;
-                },
-                // -----------------------------------------------------------------------
-                // :: Flush the output to the terminal
-                // -----------------------------------------------------------------------
-                flush: function() {
-                    try {
-                        var wrapper;
-                        // print all lines
-                        $.each(output_buffer, function(i, line) {
-                            if (line === NEW_LINE) {
-                                wrapper = $('<div></div>');
-                            } else if (typeof line === 'function') {
-                                wrapper.appendTo(output);
-                                try {
-                                    line(wrapper);
-                                } catch (e) {
-                                    display_exception(e, 'USER:echo(finalize)');
-                                }
-                            } else {
-                                $('<div/>').html(line).appendTo(wrapper).width('100%');
-                            }
-                        });
-                        if (settings.outputLimit >= 0) {
-                            var limit = settings.outputLimit === 0 ?
-                                self.rows() :
-                                settings.outputLimit;
-                            var $lines = output.find('div div');
-                            if ($lines.length > limit) {
-                                var for_remove = $lines.slice(0, lines.length-limit+1);
-                                // you can't get parent if you remove the element so
-                                // we first get the parent
-                                var parents = for_remove.parent();
-                                for_remove.remove();
-                                parents.each(function() {
-                                    var self = $(this);
-                                    if (self.is(':empty')) {
-                                        self.remove();
-                                    }
-                                });
-                            }
-                        }
-                        scroll_to_bottom();
-                        output_buffer = [];
-                    } catch (e) {
-                        alert('[Flush] ' + exception_message(e) + '\n' +
-                              e.stack);
-                    }
-                    return self;
-                },
-                // -----------------------------------------------------------------------
-                // :: Print data to the terminal output. It can have two options:
-                // :: a function that is called with the container div that holds the
-                // :: output (as a jquery object) every time the output is printed
-                // :: (including resize and scrolling)
-                // :: If the line is a function it will be called for every redraw.
-                // -----------------------------------------------------------------------
-                echo: function(string, options) {
-                    try {
-                        string = string || '';
-                        var settings = $.extend({
-                            flush: true,
-                            raw: false,
-                            finalize: $.noop
-                        }, options || {});
-                        output_buffer = [];
-                        draw_line(string, settings);
-                        lines.push([string, settings]);
-                        if (settings.flush) {
-                            self.flush();
-                        }
-                        on_scrollbar_show_resize();
-                    } catch (e) {
-                        // if echo throw exception we can't use error to display that
-                        // exception
-                        alert('[Terminal.echo] ' + exception_message(e) + '\n' +
-                              e.stack);
-                    }
-                    return self;
-                },
-                // -----------------------------------------------------------------------
-                // :: echo red text
-                // -----------------------------------------------------------------------
-                error: function(message, finalize) {
-                    //quick hack to fix trailing back slash
-                    return self.echo('[[;#f00;]' + $.terminal.escape_brackets(message).
-                                     replace(/\\$/, '&#92;') + ']', finalize);
-                },
-                // -----------------------------------------------------------------------
-                // :: Display Exception on terminal
-                // -----------------------------------------------------------------------
-                exception: function(e, label) {
-                    var message = exception_message(e);
-                    if (label) {
-                        message = '&#91;' + label + '&#93;: ' + message;
-                    }
-                    if (message) {
-                        self.error(message, {
-                            finalize: function(div) {
-                                div.addClass('exception message');
-                            }
-                        });
-                    }
-                    if (typeof e.fileName === 'string') {
-                        //display filename and line which throw exeption
-                        self.pause();
-                        $.get(e.fileName, function(file) {
-                            self.resume();
-                            var num = e.lineNumber - 1;
-                            var line = file.split('\n')[num];
-                            if (line) {
-                                self.error('&#91;' + e.lineNumber + '&#93;: ' + line);
-                            }
-                        });
-                    }
-                    if (e.stack) {
-                        self.error(e.stack, {
-                            finalize: function(div) {
-                                div.addClass('exception stack-trace');
-                            }
-                        });
-                    }
-                },
-                // -----------------------------------------------------------------------
-                // :: Scroll Div that holds the terminal
-                // -----------------------------------------------------------------------
-                scroll: function(amount) {
-                    var pos;
-                    amount = Math.round(amount);
-                    if (scroll_object.prop) { // work with jQuery > 1.6
-                        if (amount > scroll_object.prop('scrollTop') && amount > 0) {
-                            scroll_object.prop('scrollTop', 0);
-                        }
-                        pos = scroll_object.prop('scrollTop');
-                        scroll_object.scrollTop(pos + amount);
-                    } else {
-                        if (amount > scroll_object.attr('scrollTop') && amount > 0) {
-                            scroll_object.attr('scrollTop', 0);
-                        }
-                        pos = scroll_object.attr('scrollTop');
-                        scroll_object.scrollTop(pos + amount);
-                    }
-                    return self;
-                },
-                // -----------------------------------------------------------------------
-                // :: Exit all interpreters and logout. The function will throw exception
-                // :: if there is no login provided
-                // -----------------------------------------------------------------------
-                logout: settings.login ? function() {
-                    while (interpreters.size() > 1) {
-                        self.pop();
-                    }
-                    return self.pop();
-                } : function() {
-                    self.error(strings.loginFunctionMissing);
-                },
-                // -----------------------------------------------------------------------
-                // :: Function returns the token returned by callback function in login
-                // :: function. It does nothing (return undefined) if there is no login
-                // -----------------------------------------------------------------------
-                token: settings.login ? function(local) {
-                    return $.Storage.get(self.prefix_name(local) + '_token');
-                } : $.noop,
-                // -----------------------------------------------------------------------
-                // :: Function return Login name entered by the user
-                // -----------------------------------------------------------------------
-                login_name: settings.login ? function(local) {
-                    return $.Storage.get(self.prefix_name(local) + '_login');
-                } : $.noop,
-                // -----------------------------------------------------------------------
-                // :: Function returns the name of current interpreter
-                // -----------------------------------------------------------------------
-                name: function() {
-                    return interpreters.top().name;
-                },
-                // -----------------------------------------------------------------------
-                // :: Function return prefix name for login/token
-                // -----------------------------------------------------------------------
-                prefix_name: function(local) {
-                    var name = (settings.name ? settings.name + '_' : '') + terminal_id;
-                    if (local && interpreters.size() > 1) {
-                        name += '_' + interpreters.map(function(intrp) {
-                            return intrp.name;
-                        }).slice(1).join('_');
-                    }
-                    return name;
-                },
-                // -----------------------------------------------------------------------
-                // :: Push a new interenter on the Stack
-                // -----------------------------------------------------------------------
-                push: function(interpreter, options) {
-                    options = options || {};
-                    options.name = options.name || prev_command;
-                    options.prompt = options.prompt || options.name + ' ';
-                    //names.push(options.name);
-                    var top = interpreters.top();
-                    if (top) {
-                        top.mask = command_line.mask();
-                    }
-                    make_interpreter(interpreter, function(result) {
-                        // result is object with interpreter and completion properties
-                        interpreters.push($.extend({}, result, options));
-                        if (options.login) {
-                            var type = $.type(options.login);
-                            if (type == 'function') {
-                                // self.pop on error
-                                self.login(options.login,
-                                           false,
-                                           prepare_top_interpreter,
-                                           self.pop);
-                            } else if ($.type(interpreter) == 'string' &&
-                                       type == 'string' || type == 'boolean') {
-                                self.login(make_json_rpc_login(interpreter, options.login),
-                                           false,
-                                           prepare_top_interpreter,
-                                           self.pop);
-                            }
-                        } else {
-                            prepare_top_interpreter();
-                        }
-                    });
-                    return self;
-                },
-                // -----------------------------------------------------------------------
-                // :: Remove the last interpreter from the Stack
-                // -----------------------------------------------------------------------
-                pop: function(string) {
-                    if (string !== undefined) {
-                        echo_command(string);
-                    }
-                    var token = self.token(true);
-                    if (interpreters.size() == 1) {
-                        if (settings.login) {
-                            global_logout();
-                            if ($.type(settings.onExit) === 'function') {
-                                try {
-                                    settings.onExit(self);
-                                } catch (e) {
-                                    display_exception(e, 'onExit');
-                                    throw e;
-                                }
-                            }
-                        } else {
-                            self.error(strings.canExitError);
-                        }
-                    } else {
-                        if (token) {
-                            logout();
-                        }
-                        var current = interpreters.pop();
-                        prepare_top_interpreter();
-                        if ($.type(current.onExit) === 'function') {
-                            try {
-                                current.onExit(self);
-                            } catch (e) {
-                                display_exception(e, 'onExit');
-                                throw e;
-                            }
-                        }
-                        // restore mask
-                        self.set_mask(interpreters.top().mask);
-                    }
-                    return self;
-                },
-                // -----------------------------------------------------------------------
-                // :: Return how deep you are in nested interpreters
-                // -----------------------------------------------------------------------
-                level: function() {
-                    return interpreters.size();
-                },
-                // -----------------------------------------------------------------------
-                // :: Reinitialize the terminal
-                // -----------------------------------------------------------------------
-                reset: function() {
-                    self.clear();
-                    while(interpreters.size() > 1) {
-                        interpreters.pop();
-                    }
-                    initialize();
-                    return self;
-                },
-                // -----------------------------------------------------------------------
-                // :: Remove all local storage left by terminal, it will not logout you
-                // :: until you refresh the browser
-                // -----------------------------------------------------------------------
-                purge: function() {
-                    var prefix = self.prefix_name() + '_';
-                    var names = $.Storage.get(prefix + 'interpreters');
-                    $.each($.parseJSON(names), function(_, name) {
-                        $.Storage.remove(name + '_commands');
-                        $.Storage.remove(name + '_token');
-                        $.Storage.remove(name + '_login');
-                    });
-                    command_line.purge();
-                    $.Storage.remove(prefix + 'interpreters');
-                    return self;
-                },
-                // -----------------------------------------------------------------------
-                // :: Remove all events and DOM nodes left by terminal, it will not purge
-                // :: the terminal so you will have the same state when you refresh the
-                // :: browser
-                // -----------------------------------------------------------------------
-                destroy: function() {
-                    command_line.destroy().remove();
-                    output.remove();
-                    $(document).unbind('.terminal');
-                    $(window).unbind('.terminal');
-                    self.unbind('click, mousewheel');
-                    self.removeData('terminal').removeClass('terminal');
-                    if (settings.width) {
-                        self.css('width', '');
-                    }
-                    if (settings.height) {
-                        self.css('height', '');
-                    }
-                    return self;
-                }
-            }, function(_, fun) {
-                // wrap all functions and display execptions
-                return function() {
-                    try {
-                        return fun.apply(this, Array.prototype.slice.apply(arguments));
-                    } catch (e) {
-                        // exec catch by command (resume call exec)
-                        if (_ !== 'exec' && _ !== 'resume') {
-                            display_exception(e, 'TERMINAL');
-                        }
-                        throw e;
-                    }
-                };
-            }));
-
-            // ---------------------------------------------------------------------
-            var on_scrollbar_show_resize = (function() {
-                var scroll_bars = have_scrollbars(self);
-                return function() {
-                    if (scroll_bars !== have_scrollbars(self)) {
-                        // if the scollbar appearance changes we will have a different
-                        // number of chars
-                        self.resize();
-                        scroll_bars = have_scrollbars(self);
-                    }
-                };
-            })();
-
-            // ---------------------------------------------------------------------
-            // INIT CODE
-            // ---------------------------------------------------------------------
-            if (settings.width) {
-                self.width(settings.width);
-            }
-            if (settings.height) {
-                self.height(settings.height);
-            }
-            if (!navigator.userAgent.toLowerCase().match(/(webkit)[ \/]([\w.]+)/) &&
-                self[0].tagName.toLowerCase() == 'body') {
-                scroll_object = $('html');
-            } else {
-                scroll_object = self;
-            }
-            // register ajaxSend for cancel requests on CTRL+D
-            $(document).bind('ajaxSend.terminal', function(e, xhr, opt) {
-                requests.push(xhr);
-            });
-            output = $('<div>').addClass('terminal-output').appendTo(self);
-            self.addClass('terminal');
-            // keep focus in clipboard textarea in mobile
-            if (('ontouchstart' in window) || window.DocumentTouch &&
-                document instanceof DocumentTouch) {
-                self.click(function() {
-                    self.find('textarea').focus();
-                });
-                self.find('textarea').focus();
-            }
-            /*
-              self.bind('touchstart.touchScroll', function() {
-
-              });
-              self.bind('touchmove.touchScroll', function() {
-
-              });
-            */
-            //$('<input type="text"/>').hide().focus().appendTo(self);
-
-            // before login event
-            if (settings.login && typeof settings.onBeforeLogin === 'function') {
-                try {
-                    settings.onBeforeLogin(self);
-                } catch (e) {
-                    display_exception(e, 'onBeforeLogin');
-                    throw e;
-                }
-            }
-            // create json-rpc authentication function
-            if (typeof init_interpreter === 'string' &&
-                (typeof settings.login === 'string' || settings.login)) {
-                settings.login = make_json_rpc_login(init_interpreter, settings.login);
-            }
-            terminals.append(self);
-            var interpreters;
-            var command_line;
-            make_interpreter(init_interpreter, function(interpreter) {
-                interpreters = new Stack($.extend({
-                    name: settings.name,
-                    prompt: settings.prompt,
-                    greetings: settings.greetings
-                }, interpreter));
-                // CREATE COMMAND LINE
-                command_line = $('<div/>').appendTo(self).cmd({
-                    prompt: settings.prompt,
-                    history: settings.history,
-                    historyFilter: settings.historyFilter,
-                    historySize: settings.historySize,
-                    width: '100%',
-                    keydown: key_down,
-                    keypress: settings.keypress ? function(e) {
-                        return settings.keypress(e, self);
-                    } : null,
-                    onCommandChange: function(command) {
-                        if ($.type(settings.onCommandChange) === 'function') {
-                            try {
-                                settings.onCommandChange(command, self);
-                            } catch (e) {
-                                display_exception(e, 'onCommandChange');
-                                throw e;
-                            }
-                        }
-                        scroll_to_bottom();
-                    },
-                    commands: commands
-                });
-                if (enabled) {
-                    self.focus(undefined, true);
-                } else {
-                    self.disable();
-                }
-                $(document).bind('click.terminal', function(e) {
-                    if (!$(e.target).closest('.terminal').hasClass('terminal') &&
-                        settings.onBlur(self) !== false) {
-                        self.disable();
-                    }
-                });
-                self.click(function(e) {
-                    if (!self.enabled()) {
-                        self.focus();
-                    }
-                }).mousedown(function(e) {
-                    if (e.which == 2) {
-                        self.insert(getSelectedText());
-                    }
-                });
-                // ------------------------------------------------
-                // Run Login
-                if (settings.login) {
-                    self.login(settings.login, true, initialize);
-                } else {
-                    initialize();
-                }
-                if (self.is(':visible')) {
-                    num_chars = get_num_chars(self);
-                    command_line.resize(num_chars);
-                    num_rows = get_num_rows(self);
-                }
-                self.oneTime(100, function() {
-                    $(window).bind('resize.terminal', function() {
-                        if (self.is(':visible')) {
-                            var width = self.width();
-                            var height = self.height();
-                            // prevent too many calculations in IE
-                            if (old_height !== height || old_width !== width) {
-                                self.resize();
-                            }
-                        }
-                    });
-                });
-                if ($.event.special.mousewheel) {
-                    var shift = false;
-                    $(document).bind('keydown.terminal', function(e) {
-                        if (e.shiftKey) {
-                            shift = true;
-                        }
-                    }).bind('keyup.terminal', function(e) {
-                        // in Google Chromium/Linux shiftKey is false
-                        if (e.shiftKey || e.which == 16) {
-                            shift = false;
-                        }
-                    });
-                    self.mousewheel(function(event, delta) {
-                        if (!shift) {
-                            if (delta > 0) {
-                                self.scroll(-40);
-                            } else {
-                                self.scroll(40);
-                            }
-                            //event.preventDefault();
-                        }
-                    });
-                }
-            });
-            self.data('terminal', self);
-            return self;
-        }
-    }; //terminal plugin
-})(jQuery);
diff --git a/contrib/online_ide/www/js/pnacl_js.js b/contrib/online_ide/www/js/pnacl_js.js
deleted file mode 100644 (file)
index 1ebcd0b..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-// This file is part of pnacl_nit ( http://www.pnacl_nitlanguage.org )
-//
-// Copyright 2014 Johan Kayser <kayser.johan@gmail.com>
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//     http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-pnacl_nitModule = null;  // Global application object.
-var github_acces_token = '9d9412ce7f8223348287aac676b2835baa8f0cfc'; // Github API token.
-var lib_files = []; // Stores the Nit lib files in JS.
-var lib_files_number = 0;
-var sha_filename_map = {}; // Map that stores files with their 'sha' as key and 'name' as value
-var lib_files_loaded = false;
-var terminal = null; //terminal object.
-
-// Indicate load success.
-function moduleDidLoad() {
-       pnacl_nitModule = document.getElementById('pnacl_nit');
-       if (pnacl_nitModule != null) {
-               // When the module is loaded, we load the lib and init the terminal.
-               console.log('pnacl_nitModule loaded.');
-               load_nit_lib();
-               init_terminal();
-       }
-}
-
-// The 'message' event handler. This handler is fired when the NaCl module
-// posts a message to the browser by calling PPB_Messaging.PostMessage()
-// (in C) or pp::Instance.PostMessage() (in C++).  This implementation
-// displays the result in the JS console, puts the result in the '#rez' input and make it visible.
-function handleMessage(message_event) {
-       if (message_event.data.hasOwnProperty('exit')){
-               // If the code exited, shows the error code and reloads Nit lib after the launch of a new thread.
-               console.log('Nit code exited with value: ' + message_event.data.exit + '.');
-               console.log(message_event.data.exit_thread);
-               load_nit_lib();
-       }
-       else if (!message_event.data.hasOwnProperty('operation'))
-       {
-               if(message_event.data == "\n") {
-                       // Do nothing.
-               }
-               else {
-                       terminal.echo(message_event.data);
-               }
-       }
-       else if (message_event.data.operation == 'load_response'){
-               // We use this to count how many files were loaded for the lib in PNaCl,
-               // if the number matches the number of files loaded from Github,
-               // we know we have all the files.
-               if (message_event.data.files_number == lib_files_number) {
-                       console.log('Nit library loaded (' + message_event.data.files_number + ' files), ready to go.');
-                       lib_files_loaded = true;
-               }
-       }
-}
-
-// Called if the application calls exit(n), abort(), or crashes.
-function handleCrash() {
-       // We remove the modules and add a new one.
-       $( "#pnacl_nit" ).remove();
-       $( "#listener" ).append("<embed id='pnacl_nit' width=0 height=0 src='/pnacl/pnacl_nit.nmf' type='application/x-pnacl' />");
-}
diff --git a/contrib/online_ide/www/pnacl/pnacl_nit.nmf b/contrib/online_ide/www/pnacl/pnacl_nit.nmf
deleted file mode 100644 (file)
index a252fef..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-{
-       "program": {
-               "portable": {
-                       "pnacl-translate": {
-                               "url": "pnacl_nit.pexe"
-                       }
-               }
-       }
-}
-               
index 0469a7d..f23b604 100644 (file)
@@ -27,10 +27,6 @@ in "C" `{
        #define be32toh(val) _byteswap_ulong(val)
 #endif
 
-#ifdef __pnacl__
-       #define be16toh(val) (((val) >> 8) | ((val) << 8))
-       #define be32toh(val) ((be16toh((val) << 16) | (be16toh((val) >> 16))))
-#endif
 #ifndef be32toh
        #define be32toh(val) betoh32(val)
 #endif
diff --git a/lib/pnacl/examples/converter/Makefile b/lib/pnacl/examples/converter/Makefile
deleted file mode 100644 (file)
index 8c9dbd7..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-default:
-       ../../../bin/nitc --semi-global converter.nit
-
-HTTPD_PY := python $(NACL_SDK_ROOT)/tools/httpd.py
-serve:
-       $(HTTPD_PY) -C . --no-dir-check
-
-.PHONY: serve
diff --git a/lib/pnacl/examples/converter/README.md b/lib/pnacl/examples/converter/README.md
deleted file mode 100644 (file)
index bc2a555..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-Steps to make the example work :
-
-1. Install the native client SDK (https://developer.chrome.com/native-client/sdk/download).
-
-2. Declare the environment variable NACL_SDK_ROOT as the root of the target platform within the SDK (ex: ~/nacl_sdk/pepper_34/) :
-       $ export NACL_SDK_ROOT=/path/to/nacl_sdk/pepper_[your_version]
-
-3. Compile the Nit code with: `nitc --semi-global converter.nit` or `make`.
-
-You must use the '--semi-global' (or `--global`) option. Some features in the standard library are not supported by the NaCL platform, the global compiler do not try to compile them.
-
-4. Start a local server using: `make serve`.
-
-5. Set up the Chrome browser :
- - PNaCl is enabled by default in Chrome version 31 and later.
- - For a better development experience, it’s also recommended to disable the Chrome cache :
-       - Open Chrome’s developer tools by clicking the menu icon menu-icon and choosing Tools > Developer tools.
-       - Click the gear icon gear-icon in the bottom right corner of the Chrome window.
-       - Under the “General” settings, check the box next to “Disable cache (while DevTools is open)”.
-       - Keep the Developer Tools pane open while developing Native Client applications.
-
-6. You can now access the application in Chrome at the address `http://localhost:5103/`.
diff --git a/lib/pnacl/examples/converter/converter.nit b/lib/pnacl/examples/converter/converter.nit
deleted file mode 100644 (file)
index cda360e..0000000
+++ /dev/null
@@ -1,128 +0,0 @@
-# This file is part of NIT ( http://www.nitlanguage.org )
-#
-# Copyright 2014 Johan Kayser <kayser.johan@gmail.com>
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-# Example of a currency converter using PNaCl with Nit
-#
-# First imports the pnacl module
-# Then redefines the 'handle_dictionary' method
-# Creates a converter and initializes it
-# Finally checks for dictionaries
-
-import pnacl is example
-
-class Converter
-       super PnaclApp
-
-       # We have to redefine the method to do what we want when receiving a dictionary from JS
-       redef fun handle_dictionary(dictionary) do
-               # Getting values from the dictionary
-               var from = dictionary["from"]
-               var to = dictionary["to"]
-               var value = dictionary["value"]
-
-               # If conversion to the same currency return the same value
-               if from isa String and to isa String then
-                       if from == "EUR" and to == "EUR" then
-                               if value isa String then
-                                       var rez = value.to_f
-                                       var d = new PepperDictionary
-                                       d["value"] = rez
-                                       post_dictionary d
-                               end
-                       end
-               end
-               # If conversion to the same currency return the same value
-               if from isa String and to isa String then
-                       if from == "CAD" and to == "CAD" then
-                               if value isa String then
-                                       var rez = value.to_f
-                                       var d = new PepperDictionary
-                                       d["value"] = rez
-                                       post_dictionary d
-                               end
-                       end
-               end
-               # If conversion to the same currency return the same value
-               if from isa String and to isa String then
-                       if from == "USD" and to == "USD" then
-                               if value isa String then
-                                       var rez = value.to_f
-                                       var d = new PepperDictionary
-                                       d["value"] = rez
-                                       post_dictionary d
-                               end
-                       end
-               end
-               # Converts EUR to CAD
-               if from == "EUR" and to == "CAD" then
-                       if value isa String then
-                               var rez = (value.to_f * 1.52) # April 30 2014
-                               var d = new PepperDictionary
-                               d["value"] = rez
-                               post_dictionary d
-                       end
-               end
-               # Converts EUR to USD
-               if from == "EUR" and to == "USD" then
-                       if value isa String then
-                               var rez = (value.to_f * 1.38640) # April 30 2014
-                               var d = new PepperDictionary
-                               d["value"] = rez
-                               post_dictionary d
-                       end
-               end
-               # Converts CAD to EUR
-               if from == "CAD" and to == "EUR" then
-                       if value isa String then
-                               var rez = (value.to_f * 0.65840) # April 30 2014
-                               var d = new PepperDictionary
-                               d["value"] = rez
-                               post_dictionary d
-                       end
-               end
-               # Converts CAD to USD
-               if from == "CAD" and to == "USD" then
-                       if value isa String then
-                               var rez = (value.to_f * 0.91240) # April 30 2014
-                               var d = new PepperDictionary
-                               d["value"] = rez
-                               post_dictionary d
-                       end
-               end
-               # Converts USD to EUR
-               if from == "USD" and to == "EUR" then
-                       if value isa String then
-                               var rez = (value.to_f * 0.721) # April 30 2014
-                               var d = new PepperDictionary
-                               d["value"] = rez
-                               post_dictionary d
-                       end
-               end
-               # Converts USD to CAD
-               if from == "USD" and to == "CAD" then
-                       if value isa String then
-                               var rez = (value.to_f * 1.095) # April 30 2014
-                               var d = new PepperDictionary
-                               d["value"] = rez
-                               post_dictionary d
-                       end
-               end
-       end
-end
-
-redef fun app do return once new Converter
-app.initialize # Needed to correctly set up Nit control over the Pepper API
-app.run # Launches an infinite loop in order to check for dictionaries
diff --git a/lib/pnacl/examples/converter/converter/index.html b/lib/pnacl/examples/converter/converter/index.html
deleted file mode 100644 (file)
index 4143033..0000000
+++ /dev/null
@@ -1,89 +0,0 @@
-<!--# This file is part of NIT ( http://www.nitlanguage.org )
-#
-# Copyright 2014 Johan Kayser <kayser.johan@gmail.com>
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
--->
-<!DOCTYPE html>
-<html>
-<head>
-       <title>Converter</title>
-       <script src="js/pnacl_js.js"></script>
-       <link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">
-</head>
-<body>
-       <h1>Currency converter<small> with PNaCl and Nit</small></h1>
-       <form class="form-horizontal bg-success" role="form" style="padding-top:15px;padding-bottom:1px;">
-         <div class="form-group">
-           <label for="inputConvert" class="col-sm-2 control-label">Convert</label>
-           <div class="col-sm-9">
-               <div class="row">
-                 <div id="pre-input" class="col-xs-2">
-                   <input id="input" type="text" class="form-control" placeholder="ex: 300" required>
-                 </div>
-                 <div class="col-xs-3">
-                   <select id="from" class="form-control" required>
-                         <option selected="selected" disabled="disabled">Currency</option>
-                         <option>EUR</option>
-                         <option>CAD</option>
-                         <option>USD</option>
-                   </select>
-                 </div>
-               </div>
-           </div>
-         </div>
-         <div class="form-group">
-           <label for="inputTo" class="col-sm-2 control-label">to</label>
-           <div class="col-sm-9">
-                   <div class="row">
-                         <div class="col-xs-2">
-                           <input id="rez" type="text" class="form-control" placeholder=".col-xs-2" disabled="disabled" style="visibility: hidden">
-                         </div>
-                         <div class="col-xs-3">
-                           <select id="to" class="form-control" required>
-                               <option selected="selected" disabled="disabled">Currency</option>
-                               <option>EUR</option>
-                               <option>CAD</option>
-                               <option>USD</option>
-                           </select>
-                         </div>
-                       </div>
-                   </div>
-           </div>
-         </div>
-         <div class="form-group">
-           <div class="col-sm-offset-2 col-sm-10">
-             <button id="button" type="button" class="btn btn-success">Convert</button>
-           </div>
-         </div>
-       </form>
-       <p>
-               <div id="listener">
-                       <!-- Listeners calling functions in pnacl_js.js -->
-                       <script type="text/javascript">
-                               var listener = document.getElementById('listener');
-                               listener.addEventListener('load', moduleDidLoad, true);
-                               listener.addEventListener('message', handleMessage, true);
-                       </script>
-                       <!-- Embed bloc referencing to the manifest -->
-                       <embed id="converter"
-                               width=0 height=0
-                               src="converter.nmf"
-                               type="application/x-pnacl" />
-               </div>
-       </p>
-       <script src="//code.jquery.com/jquery-1.11.0.min.js"></script>
-       <script src="//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>
-       <script src="js/functions.js"></script>
-</body>
-</html>
diff --git a/lib/pnacl/examples/converter/converter/js/functions.js b/lib/pnacl/examples/converter/converter/js/functions.js
deleted file mode 100644 (file)
index cd7f506..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-// This file is part of NIT ( http://www.nitlanguage.org )
-//
-// Copyright 2014 Johan Kayser <kayser.johan@gmail.com>
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//     http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-// Checks that the text in the input is numeric and not null
-// and then if two currencies where chosen sends a dictionary to Nit.
-$( "#button" ).click(function() {
-       $("#pre-input").removeClass("has-error");
-       if (($('#input').val() == "")||($.isNumeric($('#input').val()) == false)) {
-               $("#pre-input").addClass("has-error");
-       }
-       else
-       {
-               if (($('#from').val() != null) && ($('#to').val() != null)) {
-                       var dictionary = {
-                               value: parseFloat($('#input').val()).toFixed(2),
-                               from: $('#from').val(),
-                               to: $('#to').val(),
-                       }
-                       converterModule.postMessage(dictionary);
-               }
-       }
-});
diff --git a/lib/pnacl/examples/converter/converter/js/pnacl_js.js b/lib/pnacl/examples/converter/converter/js/pnacl_js.js
deleted file mode 100644 (file)
index da29a31..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-// This file is part of NIT ( http://www.nitlanguage.org )
-//
-// Copyright 2014 Johan Kayser <kayser.johan@gmail.com>
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//     http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-converterModule = null;  // Global application object.
-
-// Indicate load success.
-function moduleDidLoad() {
-       converterModule = document.getElementById('converter');
-       // Send a message to the Native Client module.
-       if (converterModule != null) {
-               console.log('converterModule loaded.');
-       }
-}
-
-// The 'message' event handler. This handler is fired when the NaCl module
-// posts a message to the browser by calling PPB_Messaging.PostMessage()
-// (in C) or pp::Instance.PostMessage() (in C++).  This implementation
-// displays the result in the JS console, puts the result in the '#rez' input and make it visible.
-function handleMessage(message_event) {
-       if (message_event.data.hasOwnProperty('exit')){
-               console.log('Nit code exited with value: ' + message_event.data.exit + '.');
-       }
-       else {
-               console.log(message_event.data.value.valueOf());
-               $('#rez').val(message_event.data.value.valueOf().toFixed(2));
-               $('#rez').css('visibility', 'visible');
-       }
-}
diff --git a/lib/pnacl/package.ini b/lib/pnacl/package.ini
deleted file mode 100644 (file)
index c3e650b..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-[package]
-name=pnacl
-tags=platform,lib
-maintainer=Johan Kayser <johan.kayser@viacesi.fr>
-license=Apache-2.0
-[upstream]
-browse=https://github.com/nitlang/nit/tree/master/lib/pnacl
-git=https://github.com/nitlang/nit.git
-git.directory=lib/pnacl
-homepage=http://nitlanguage.org
-issues=https://github.com/nitlang/nit/issues
diff --git a/lib/pnacl/pnacl.nit b/lib/pnacl/pnacl.nit
deleted file mode 100644 (file)
index 71c87e4..0000000
+++ /dev/null
@@ -1,763 +0,0 @@
-# This file is part of NIT ( http://www.nitlanguage.org ).
-#
-# Copyright 2014 Johan Kayser <kayser.johan@gmail.com>
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-# Provides PNaCl support for Nit.
-#
-# To use this module and compile for PNaCl, you must install the
-# NaCl SDK (This file is based on Pepper 33).
-# If NACL_SDK_ROOT is not set in your PATH, you have to work in
-# 'nacl_sdk/pepper_your_pepper_version/getting_started/your_project_folder'.
-module pnacl is platform
-
-import core
-intrude import core::stream
-
-in "C Header" `{
-       #include "ppapi/c/pp_errors.h"
-       #include "ppapi/c/ppp.h"
-       #include "ppapi/c/ppp_instance.h"
-       #include "ppapi/c/pp_bool.h"
-       #include "ppapi/c/ppb_var.h"
-       #include "ppapi/c/ppb_messaging.h"
-       #include "ppapi/c/ppp_messaging.h"
-       #include "ppapi/c/ppb_var_dictionary.h"
-       #include "ppapi/c/ppb_var_array.h"
-`}
-
-`{
-       #include <unistd.h>
-       #include <stddef.h>
-       #include <stdio.h>
-       #include <string.h>
-       #include <stdlib.h>
-       #include <pthread.h>
-       #include <poll.h>
-
-       #define MAX_DICTIONARY_QUEUE_SIZE 200
-       #define MAX_MESSAGE_QUEUE_SIZE 10
-
-       extern int nit_main(int, char**);
-
-       /* A working thread for Nit. */
-       static pthread_t g_nit_thread;
-
-       /* Mutex that guards the queues. */
-       static pthread_mutex_t g_dictionary_queue_mutex;
-       static pthread_mutex_t g_message_queue_mutex;
-
-       /* Condition variables that are signalled when the queues are not empty. */
-       static pthread_cond_t g_dictionary_queue_not_empty_cond;
-       static pthread_cond_t g_message_queue_not_empty_cond;
-
-       /** Circular queues of dictionaries and messages from JavaScript to be handled.
-        *
-        * If g_queue_start < g_queue_end:
-        *   all elements in the range [g_queue_start, g_queue_end) are valid.
-        * If g_queue_start > g_queue_end:
-        *   all elements in the ranges [0, g_queue_end) and
-        *   [g_queue_start, MAX_QUEUE_SIZE) are valid.
-        * If g_queue_start == g_queue_end, and g_queue_size > 0:
-        *   all elements in the g_queue are valid.
-        * If g_queue_start == g_queue_end, and g_queue_size == 0:
-        *   No elements are valid. */
-       static struct PP_Var g_dictionary_queue[MAX_DICTIONARY_QUEUE_SIZE];
-       static char* g_message_queue[MAX_MESSAGE_QUEUE_SIZE];
-
-       /* The index of the head of the queues. */
-       static int g_dictionary_queue_start = 0;
-       static int g_message_queue_start = 0;
-
-       /* The index of the tail of the queues, non-inclusive. */
-       static int g_dictionary_queue_end = 0;
-       static int g_message_queue_end = 0;
-
-       /* The size of the queues. */
-       static int g_dictionary_queue_size = 0;
-       static int g_message_queue_size = 0;
-
-       /* PNaCl interfaces. */
-       const PPB_Messaging* g_varMessagingInterface;
-       const PPB_Var* g_varInterface;
-       const PPB_VarDictionary* g_varDictionaryInterface;
-       const PPB_VarArray* g_varArrayInterface;
-
-       PP_Instance g_instance;
-       PnaclApp app;
-
-       /* A wrapper to launch the Nit main on a new thread. */
-       void* WrapperNitMain(void* arg) {
-               nit_main(0, NULL);
-               return NULL;
-       }
-
-       /** Return whether the queues are empty.
-        *
-        * NOTE: this function assumes g_queue_mutex lock is held.
-        * @return non-zero if the queue is empty. */
-       static int IsDictionaryQueueEmpty() { return g_dictionary_queue_size == 0; }
-       static int IsMessageQueueEmpty() { return g_message_queue_size == 0; }
-
-       /** Return whether the queues are full.
-        *
-        * NOTE: this function assumes g_queue_mutex lock is held.
-        * @return non-zero if the queue is full. */
-       static int IsDictionaryQueueFull() { return g_dictionary_queue_size == MAX_DICTIONARY_QUEUE_SIZE; }
-       static int IsMessageQueueFull() { return g_message_queue_size == MAX_MESSAGE_QUEUE_SIZE; }
-
-       /* Initialize the queues. */
-       void InitializeQueues() {
-           pthread_mutex_init(&g_dictionary_queue_mutex, NULL);
-           pthread_cond_init(&g_dictionary_queue_not_empty_cond, NULL);
-           pthread_mutex_init(&g_message_queue_mutex, NULL);
-           pthread_cond_init(&g_message_queue_not_empty_cond, NULL);
-       }
-
-       /** Enqueue a dictionary (i.e. add to the end)
-        *
-        * If the queue is full, the dictionary will be dropped.
-        *
-        * NOTE: this function assumes g_dictionary_queue_mutex is _NOT_ held.
-        * @param[in] dictionary, the dictionary to enqueue.
-        * @return non-zero if the dictionary was added to the queue. */
-       int EnqueueDictionary(struct PP_Var dictionary) {
-           pthread_mutex_lock(&g_dictionary_queue_mutex);
-
-         /* We shouldn't block the main thread waiting for the queue to not be full,
-          * so just drop the dictionary. */
-           if (IsDictionaryQueueFull()) {
-               pthread_mutex_unlock(&g_dictionary_queue_mutex);
-               return 0;
-           }
-
-           g_dictionary_queue[g_dictionary_queue_end] = dictionary;
-           g_dictionary_queue_end = (g_dictionary_queue_end + 1) % MAX_DICTIONARY_QUEUE_SIZE;
-           g_dictionary_queue_size++;
-
-           pthread_cond_signal(&g_dictionary_queue_not_empty_cond);
-
-           pthread_mutex_unlock(&g_dictionary_queue_mutex);
-
-           return 1;
-       }
-
-       /** Enqueue a message (i.e. add to the end)
-        *
-        * If the queue is full, the message will be dropped.
-        *
-        * NOTE: this function assumes g_message_queue_mutex is _NOT_ held.
-        * @param[in] message The message to enqueue.
-        * @return non-zero if the message was added to the queue. */
-       int EnqueueMessage(char* message) {
-           pthread_mutex_lock(&g_message_queue_mutex);
-
-         /* We shouldn't block the main thread waiting for the queue to not be full,
-          * so just drop the message. */
-           if (IsMessageQueueFull()) {
-               pthread_mutex_unlock(&g_message_queue_mutex);
-               return 0;
-           }
-
-           g_message_queue[g_message_queue_end] = message;
-           g_message_queue_end = (g_message_queue_end + 1) % MAX_MESSAGE_QUEUE_SIZE;
-           g_message_queue_size++;
-
-           pthread_cond_signal(&g_message_queue_not_empty_cond);
-
-           pthread_mutex_unlock(&g_message_queue_mutex);
-
-           return 1;
-       }
-
-       /** Dequeue a dictionary and return it.
-        *
-        * This function blocks until a dictionary is available. It should not be called
-        * on the main thread.
-        *
-        * NOTE: this function assumes g_dictionary_queue_mutex is _NOT_ held.
-        * @return The dictionary at the head of the queue. */
-       struct PP_Var DequeueDictionary() {
-           struct PP_Var dictionary = g_varDictionaryInterface->Create();
-
-           pthread_mutex_lock(&g_dictionary_queue_mutex);
-
-           while (IsDictionaryQueueEmpty()) {
-               pthread_cond_wait(&g_dictionary_queue_not_empty_cond, &g_dictionary_queue_mutex);
-           }
-
-           dictionary = g_dictionary_queue[g_dictionary_queue_start];
-           g_dictionary_queue_start = (g_dictionary_queue_start + 1) % MAX_DICTIONARY_QUEUE_SIZE;
-           g_dictionary_queue_size--;
-
-           pthread_mutex_unlock(&g_dictionary_queue_mutex);
-
-           return dictionary;
-       }
-
-       /** Dequeue a message and return it.
-        *
-        * This function blocks until a message is available. It should not be called
-        * on the main thread.
-        *
-        * NOTE: this function assumes g_queue_mutex is _NOT_ held.
-        * @return The message at the head of the queue. */
-       char* DequeueMessage() {
-           char* message = NULL;
-
-           pthread_mutex_lock(&g_message_queue_mutex);
-
-           while (IsMessageQueueEmpty()) {
-               pthread_cond_wait(&g_message_queue_not_empty_cond, &g_message_queue_mutex);
-           }
-
-           message = g_message_queue[g_message_queue_start];
-           g_message_queue_start = (g_message_queue_start + 1) % MAX_MESSAGE_QUEUE_SIZE;
-           g_message_queue_size--;
-
-           pthread_mutex_unlock(&g_message_queue_mutex);
-
-           return message;
-       }
-
-       /* Posts a string message to JS. */
-       void PostMessage(char* message) {
-           /* Create PP_Var containing the message body. */
-           struct PP_Var varString = g_varInterface->VarFromUtf8(message, strlen(message));
-
-           /* Post message to the JavaScript layer. */
-           g_varMessagingInterface->PostMessage(g_instance, varString);
-       }
-
-       /* Posts a Dictionary (JS like object) to JS. */
-       void PostDictionary(struct PP_Var dictionary) {
-           g_varMessagingInterface->PostMessage(g_instance, dictionary);
-       }
-
-       /* Posts a Variable (aka PepperVar) to JS.
-          Should only be used for testing, conventional conversation is made
-          with Strings or Dictionaries. */
-       void PostVar(struct PP_Var v) {
-           g_varMessagingInterface->PostMessage(g_instance, v);
-       }
-
-       /* char* to PP_Var. */
-       static struct PP_Var CStrToVar(const char* str) {
-           if (g_varInterface != NULL) {
-               return g_varInterface->VarFromUtf8(str, strlen(str));
-           }
-           return PP_MakeUndefined();
-       }
-
-       static PP_Bool Instance_DidCreate(PP_Instance instance, uint32_t argc, const char* argn[], const char* argv[]) {
-           g_instance = instance;
-
-           /* Initialization of the queues and creation of the thread for Nit. */
-           InitializeQueues();
-           pthread_create(&g_nit_thread, NULL, &WrapperNitMain, NULL);
-
-           return PP_TRUE;
-       }
-
-       static void Instance_DidDestroy(PP_Instance instance) {
-               // TODO
-       }
-
-       static void Instance_DidChangeView(PP_Instance pp_instance, PP_Resource view) {
-               // TODO
-       }
-
-       static void Instance_DidChangeFocus(PP_Instance pp_instance, PP_Bool has_focus) {
-               // TODO
-       }
-
-       static PP_Bool Instance_HandleDocumentLoad(PP_Instance pp_instance, PP_Resource pp_url_loader) {
-               // TODO
-               return PP_FALSE;
-       }
-
-       /* Called when JS sends something, is set to accept Strings or Dictionaries,
-          returns an error if received object is not a String or Dictionary. */
-       void Messaging_HandleMessage(PP_Instance instance, struct PP_Var varMessage) {
-           if(varMessage.type == PP_VARTYPE_DICTIONARY) {
-               if(!EnqueueDictionary(varMessage)) {
-                       struct PP_Var errorMessage = CStrToVar("QueueFull : dropped dictionary because the queue was full.");
-                       g_varMessagingInterface->PostMessage(g_instance, errorMessage);
-               }
-           }
-           else if(varMessage.type == PP_VARTYPE_STRING) {
-               uint32_t len;
-               char* message = (char*)g_varInterface->VarToUtf8(varMessage, &len);
-               if(!EnqueueMessage(message)) {
-                       struct PP_Var errorMessage = CStrToVar("QueueFull : dropped message because the queue was full.");
-                       g_varMessagingInterface->PostMessage(g_instance, errorMessage);
-               }
-           }
-           else {
-               struct PP_Var errorMessage = CStrToVar("TypeError : only accepts JS objects or Strings");
-               g_varMessagingInterface->PostMessage(g_instance, errorMessage);
-           }
-       }
-
-       /* This function is called by Nit when using check_dictionary,
-       returns the dictionary at the head of the queue. */
-       void* NitHandleDictionary() {
-               struct PP_Var dictionary = DequeueDictionary();
-               PnaclApp_handle_dictionary(app, &dictionary);
-               return 0;
-       }
-
-       /* This function is called By Nit when waiting for a user input. */
-       char* NitHandleMessage() {
-               return DequeueMessage();
-       }
-
-       /* Entry point */
-       PP_EXPORT int32_t PPP_InitializeModule(PP_Module module_id, PPB_GetInterface get_browser_interface) {
-           /* Initializing global pointers. */
-           g_varMessagingInterface = (const PPB_Messaging*) get_browser_interface(PPB_MESSAGING_INTERFACE);
-           g_varInterface = (const PPB_Var*) get_browser_interface(PPB_VAR_INTERFACE);
-           g_varDictionaryInterface = (const PPB_VarDictionary*) get_browser_interface(PPB_VAR_DICTIONARY_INTERFACE);
-           g_varArrayInterface = (const PPB_VarArray*) get_browser_interface(PPB_VAR_ARRAY_INTERFACE);
-           return PP_OK;
-       }
-
-       PP_EXPORT void PPP_ShutdownModule() {
-               // TODO
-       }
-
-       PP_EXPORT const void* PPP_GetInterface(const char* interface_name) {
-           if (strcmp(interface_name, PPP_INSTANCE_INTERFACE) == 0)
-           {
-               static PPP_Instance instance_interface = {
-                   &Instance_DidCreate,
-                   &Instance_DidDestroy,
-                   &Instance_DidChangeView,
-                   &Instance_DidChangeFocus,
-                   &Instance_HandleDocumentLoad
-               };
-               return &instance_interface;
-           }
-           else if (strcmp(interface_name, PPP_MESSAGING_INTERFACE) == 0) {
-               static PPP_Messaging messaging_interface = {
-                       &Messaging_HandleMessage
-               };
-               return &messaging_interface;
-           }
-           return NULL;
-       }
-
-       /* Hack in order to avoid the problem with file. */
-       int poll(struct pollfd* fds, nfds_t nfds, int timeout) { return 0; }
-`}
-
-# Nit class representing a Pepper C API PP_Var typed as a Dictionary.
-extern class PepperDictionary `{ struct PP_Var* `}
-
-       new `{
-               struct PP_Var* self = malloc( sizeof( struct PP_Var ) );
-               *self = g_varDictionaryInterface->Create();
-               return self;
-       `}
-
-       # Get fonction using PepperVars.
-       #
-       # Returns the value that is associated with 'key'.
-       # If 'key' is not a String typed PepperVar, or doesn't exist in the Dictionary, an undefined PepperVar is returned.
-       fun native_get(key: PepperVar): PepperVar `{
-               struct PP_Var* value = malloc( sizeof ( struct PP_Var ) );
-               *value = g_varDictionaryInterface->Get(*self, *key);
-               return value;
-       `}
-
-       # Returns the value associated with 'key'.
-       #
-       # 'key' must be a String.
-       # If 'key' is not a String or doesn't exist in the Dictionary, 'null' is returned.
-       fun [](key: nullable Pepperable): nullable Pepperable
-       do
-               var native_key = key.to_pepper
-               var native_value = native_get(native_key)
-               return native_value.to_nit
-       end
-
-       # Set function using PepperVars.
-       #
-       # Sets the value associated with the specified key.
-       # 'key' must be a String typed PepperVar.
-       # If 'key' hasn't existed in the Dictionary, it is added and associated with 'value'.
-       # Otherwise, the previous value is replaced with 'value'.
-       # Returns a Boolean indicating whether the operation succeeds.
-       fun native_set(key: PepperVar, value: PepperVar): Bool `{
-               PP_Bool b;
-               b = g_varDictionaryInterface->Set(*self, *key, *value);
-               return b;
-       `}
-
-       # Sets the value associated with the specified key.
-       #
-       # 'key' must be a String.
-       # If 'key' hasn't existed in the Dictionary, it is added and associated with 'value'.
-       # Otherwise, the previous value is replaced with 'value'.
-       # Returns a Boolean indicating whether the operation succeeds.
-       fun []=(key: nullable Pepperable, value: nullable Pepperable): Bool
-       do
-               var native_key = key.to_pepper
-               var native_value = value.to_pepper
-               return native_set(native_key, native_value)
-       end
-
-       # Deletes the specified key and its associated value, if the key exists.
-       #
-       # Takes a String typed PepperVar.
-       fun native_delete(key: PepperVar) `{
-               g_varDictionaryInterface->Delete(*self, *key);
-       `}
-
-       # Deletes the specified key and its associated value, if the key exists.
-       #
-       # Takes a String.
-       fun delete(key: String)
-       do
-               var native_key = key.to_pepper
-               native_delete native_key
-       end
-
-       # Checks whether a key exists.
-       #
-       # Takes a String typed PepperVar.
-       fun native_has_key(key: PepperVar): Bool `{
-               PP_Bool b;
-               b = g_varDictionaryInterface->HasKey(*self, *key);
-               return b;
-       `}
-
-       # Checks whether a key exists.
-        #
-       # Takes a String.
-       fun has_key(key: String): Bool
-       do
-               var native_key = key.to_pepper
-               return native_has_key(native_key)
-       end
-
-       # Gets all the keys in a dictionary.
-       #
-       # Returns a PepperArray which contains all the keys of the Dictionary. The elements are string vars.
-       fun get_keys: PepperArray `{
-               struct PP_Var* array = malloc( sizeof( struct PP_Var ) );
-               *array = g_varDictionaryInterface->GetKeys(*self);
-               return array;
-       `}
-
-       # Use this function to copy a dictionary.
-       fun copy: PepperDictionary `{
-               struct PP_Var* varDictionary = malloc( sizeof( struct PP_Var ) );
-               *varDictionary = g_varDictionaryInterface->Create();
-               *varDictionary = *self;
-               return varDictionary;
-       `}
-end
-
-# Nit class representing a Pepper C API PP_Var typed as an Array.
-extern class PepperArray `{ struct PP_Var* `}
-
-       new `{
-               struct PP_Var* self = malloc( sizeof( struct PP_Var ) );
-               *self = g_varArrayInterface->Create();
-               return self;
-       `}
-
-       # Returns the element at the specified position as a PepperVar.
-       #
-       # If 'index' is larger than or equal to the array length, an undefined PepperVar is returned.
-       fun native_get(index: Int): PepperVar `{
-               struct PP_Var* value = malloc( sizeof( struct PP_Var ) );
-               *value = g_varArrayInterface->Get(*self, index);
-               return value;
-       `}
-
-       # Returns the element at the specified position.
-       #
-       # If 'index' is larger than or equal to the array length, 'null' is returned.
-       fun [](index: Int): nullable Pepperable
-       do
-               var native_value = native_get(index)
-               return native_value.to_nit
-       end
-
-       # Returns an int containing the length of the PepperArray.
-       fun length: Int `{
-               int length = g_varArrayInterface->GetLength(*self);
-               return length;
-       `}
-
-       # Takes a PepperVar for the 'value' param.
-       #
-       # Sets the value of an element in the array at indicated index.
-       # If 'index' is larger than or equal to the array length, the length is updated to be 'index' + 1.
-       # Any position in the array that hasn't been set before is set to undefined, i.e., PepperVar of C type PP_VARTYPE_UNDEFINED.
-       # Returns a Boolean indicating whether the operation succeeds.
-       fun native_set(index: Int, value: PepperVar): Bool `{
-               PP_Bool b;
-               b = g_varArrayInterface->Set(*self, index, *value);
-               return b;
-       `}
-
-       # Sets the value of an element in the array at indicated index.
-       #
-       # If 'index' is larger than or equal to the array length, the length is updated to be 'index' + 1.
-       # Any position in the array that hasn't been set before is set to undefined, i.e., PepperVar of C type PP_VARTYPE_UNDEFINED.
-       # Returns a Boolean indicating whether the operation succeeds.
-       fun []=(index: Int, value: nullable Pepperable): Bool
-       do
-               var native_value = value.to_pepper
-               return native_set(index, native_value)
-       end
-
-       # Sets the array length.
-       #
-       # If 'length' is smaller than its current value, the array is truncated to the new length.
-       # Any elements that no longer fit are removed and the references to them will be released.
-       # If 'length' is larger than its current value, undefined PepperVars are appended to increase the array to the specified length.
-       # Returns a Boolean indicating whether the operation succeeds.
-       fun length=(length: Int): Bool `{
-               PP_Bool b;
-               b = g_varArrayInterface->SetLength(*self, length);
-               return b;
-       `}
-end
-
-# Nit class representing a Pepper C API PP_Var.
-extern class PepperVar `{ struct PP_Var* `}
-
-       new `{
-               return malloc( sizeof( struct PP_Var ) );
-       `}
-
-       # Converts PepperVar to standard types.
-       #
-       # Actually supports bools, ints, floats, strings. To be used with 'isa'.
-       fun to_nit: nullable Pepperable
-       do
-               if isa_null then return null
-               if isa_bool then return as_bool
-               if isa_int then return as_int
-               if isa_float then return as_float
-               if isa_string then return as_string
-               if is_undefined then return null
-
-               return null
-       end
-
-       private fun isa_null: Bool `{ return self->type == PP_VARTYPE_NULL; `}
-       private fun isa_bool: Bool `{ return self->type == PP_VARTYPE_BOOL; `}
-       private fun isa_int: Bool `{ return self->type == PP_VARTYPE_INT32; `}
-       private fun isa_float: Bool `{ return self->type == PP_VARTYPE_DOUBLE; `}
-       private fun isa_string: Bool `{ return self->type == PP_VARTYPE_STRING; `}
-       private fun is_undefined: Bool `{ return self->type == PP_VARTYPE_UNDEFINED; `}
-
-       private fun as_bool: Bool `{ return self->value.as_bool; `}
-       private fun as_int: Int `{ return self->value.as_int; `}
-       private fun as_float: Float `{ return self->value.as_double; `}
-       private fun as_string: String import CString.to_s_with_length `{
-               uint32_t len;
-               char* str = (char*)g_varInterface->VarToUtf8(*self, &len);
-               return CString_to_s_with_length(str, len);
-       `}
-end
-
-# Provides a method to convert in PepperVars.
-interface Pepperable
-       fun to_pepper: PepperVar is abstract
-end
-
-redef class Int
-       super Pepperable
-
-       # Converts a Int into a PepperVar with Int type.
-       redef fun to_pepper `{
-               struct PP_Var* var = malloc( sizeof( struct PP_Var ) );
-               *var = PP_MakeInt32(self);
-               return var;
-       `}
-end
-
-redef class Float
-       super Pepperable
-
-       # Converts a Float into a PepperVar with Float type.
-       redef fun to_pepper `{
-               struct PP_Var* var = malloc( sizeof( struct PP_Var ) );
-               *var = PP_MakeDouble(self);
-               return var;
-       `}
-end
-
-redef class Bool
-       super Pepperable
-
-       # Converts a Bool into a PepperVar with Bool type.
-       redef fun to_pepper `{
-               struct PP_Var* var = malloc( sizeof( struct PP_Var ) );
-               *var = PP_MakeBool(self);
-               return var;
-       `}
-end
-
-redef class String
-       super Pepperable
-
-       # Converts a String into a PepperVar with String type.
-       redef fun to_pepper: PepperVar import String.to_cstring, String.length `{
-               char *str = String_to_cstring(self);
-               struct PP_Var* var = malloc( sizeof( struct PP_Var ) );
-               *var = g_varInterface->VarFromUtf8(str, String_length(self));
-               return var;
-       `}
-end
-
-# A stream for PNaCl, redefines basic input and output methods.
-class PnaclStream
-       super PollableReader
-       super Writer
-       super BufferedReader
-
-       init do prepare_buffer(10)
-
-       redef var end_reached: Bool = false
-
-       redef fun eof do return end_reached
-
-       # Redefintion of 'write' to send messages to the browser.
-       redef fun write(s: Text) do app.post_message s.to_s
-
-       redef fun is_writable: Bool do return true
-
-       # Checks if there is a message in the queue, and if so the message is handled automatically.
-       fun check_message: CString `{
-               return NitHandleMessage();
-       `}
-
-       # fill_buffer now checks for a message in the message queue which is filled by user inputs.
-       redef fun fill_buffer
-       do
-               _buffer_pos = 0
-               var nns = check_message
-               var nslen = nns.cstring_length
-               _buffer_length = nslen
-               nns.copy_to(buffer, nslen, 0, 0)
-       end
-end
-
-# For a PNaCl app, Sys uses PnaclStreams.
-redef class Sys
-       fun pnacl_stdstr: PnaclStream do return once new PnaclStream
-
-       # NaCl input.
-       redef fun stdin do return pnacl_stdstr
-
-       # NaCl output.
-       redef fun stdout do return pnacl_stdstr
-
-       # NaCl output for errors.
-       redef fun stderr do return pnacl_stdstr
-end
-
-# Class that provides the tools to interact with PNaCl.
-class PnaclApp
-
-       # Sets everything up to work, need to be called at first.
-       fun initialize import PnaclApp.handle_message, PnaclApp.handle_dictionary, CString.to_s_with_length `{
-               app = self;
-       `}
-
-       # Posts a message to JS.
-       fun post_message(message: String) import String.to_cstring `{
-               char* str = String_to_cstring(message);
-               PostMessage(str);
-       `}
-
-       # Posts a dictionary to JS.
-       fun post_dictionary(dictionary: PepperDictionary) `{
-               PostDictionary(*dictionary);
-       `}
-
-       # Posts a PepperVar to JS.
-       #
-       # Should be used for testing, not recommanded for conventional conversation.
-       private fun post_var(v: PepperVar) `{
-               PostVar(*v);
-       `}
-
-       # Is called when a message is received from JS.
-       #
-       # Is set to be redefined in your application to handle like you want.
-       fun handle_message(message: String)
-       do
-               # To be Implemented by user.
-       end
-
-       # Is called when a Dictionary is received from JS.
-       #
-       # Is set to be redefined in your application to handle like you want.
-       # The dictionary is freed after this method returns.
-       fun handle_dictionary(dictionary: PepperDictionary)
-       do
-               # To be Implemented by user.
-       end
-
-       # Checks if there is a dictionary in the queue, and if so the dictionary is handled automatically.
-       fun check_dictionary `{
-               NitHandleDictionary();
-       `}
-
-       # Infinite loop on check_dictionary
-       fun run
-       do
-               loop
-                       check_dictionary
-               end
-       end
-end
-
-# Creates a new thread for Nit.
-#
-# This function launches the Nit main on a new thread.
-# Its purpose is to allow Nit to be still operational after an exit when needed,
-# because reloading the page may not be an option.
-#
-# Should only be used within the 'exit' before stopping the current thread
-# when the Nit execution causes a crash.
-#
-# REQUIRE: g_nit_thread and WrapperNitMain are set.
-fun create_thread `{
-       pthread_create(&g_nit_thread, NULL, &WrapperNitMain, NULL);
-`}
-
-# Calls 'pthread_exit on current thread.
-fun exit_thread(exit_value: Int) `{
-       pthread_exit((void*) exit_value);
-`}
-
-# Redef of exit in order to avoid the module to crash by terminating only the Nit thread.
-redef fun exit(exit_value: Int)
-do
-       var dictionary = new PepperDictionary
-       dictionary["exit"] = exit_value
-       app.post_dictionary dictionary
-       exit_thread exit_value
-end
-
-fun app: PnaclApp do return once new PnaclApp
index c241573..243c83a 100644 (file)
@@ -38,7 +38,7 @@ To combine files into a single program, use the `-m` option.
     $ nitc prog1.nit -m other_module.nit
 
 nitc can produces executables for various platforms when specific modules are used.
-Currently, android, pnacl and emscripten are supported.
+Currently, android and emscripten are supported.
 See the documentation of these specific modules for details.
 
 
index ac6edce..ea4adde 100644 (file)
@@ -715,10 +715,6 @@ abstract class AbstractCompiler
                self.header.add_decl("#ifdef _WIN32")
                self.header.add_decl("  #define be32toh(val) _byteswap_ulong(val)")
                self.header.add_decl("#endif")
-               self.header.add_decl("#ifdef __pnacl__")
-               self.header.add_decl("  #define be16toh(val) (((val) >> 8) | ((val) << 8))")
-               self.header.add_decl("  #define be32toh(val) ((be16toh((val) << 16) | (be16toh((val) >> 16))))")
-               self.header.add_decl("#endif")
                self.header.add_decl("#ifdef ANDROID")
                self.header.add_decl("  #ifndef be32toh")
                self.header.add_decl("          #define be32toh(val) betoh32(val)")
index 4dce71a..befc8b6 100644 (file)
@@ -22,6 +22,5 @@ import memory_logger
 import compiler_serialization
 
 import platform::android
-import platform::pnacl
 import platform::emscripten
 import platform::ios
diff --git a/src/platform/pnacl.nit b/src/platform/pnacl.nit
deleted file mode 100644 (file)
index f994c45..0000000
+++ /dev/null
@@ -1,251 +0,0 @@
-# This file is part of NIT ( http://www.nitlanguage.org )
-#
-# Copyright 2014 Johan Kayser <kayser.johan@gmail.com>
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-# Compile program for the PNaCl platform
-module pnacl
-
-import platform
-import compiler::abstract_compiler
-
-redef class ToolContext
-       redef fun platform_from_name(name)
-       do
-               if name == "pnacl" then return new PnaclPlatform
-               return super
-       end
-end
-
-class PnaclPlatform
-       super Platform
-
-       redef fun name do return "pnacl"
-
-       redef fun supports_libunwind do return false
-
-       redef fun no_main do return true
-
-       redef fun toolchain(toolcontext, compiler) do return new PnaclToolchain(toolcontext, compiler)
-end
-
-class PnaclToolchain
-       super MakefileToolchain
-
-       redef fun write_files(compile_dir, cfiles)
-       do
-               var app_name = compiler.mainmodule.name
-
-               # create compile_dir
-               var dir = compile_dir
-               if not dir.file_exists then dir.mkdir
-
-               # compile normal C files
-               super
-
-               # Gather extra C files generated elsewhere than in super
-               for f in compiler.extern_bodies do
-                       if f isa ExternCFile then cfiles.add(f.filename.basename)
-               end
-
-               # Outname
-               var outname = toolcontext.opt_output.value
-               if outname == null then outname = "{compiler.mainmodule.name}"
-
-               var ofiles = new Array[String]
-               for cfile in cfiles do ofiles.add(cfile.substring(0, cfile.length-2) + ".o")
-
-               ## Generate makefile
-               var file = "{dir}/Makefile"
-               """
-# This file was generated by Nit, any modification will be lost.
-
-# Get pepper directory for toolchain and includes.
-#
-# If NACL_SDK_ROOT is not set, then assume it can be found five directories up.
-#
-THIS_MAKEFILE := $(abspath $(lastword $(MAKEFILE_LIST)))
-NACL_SDK_ROOT ?= $(abspath $(dir $(THIS_MAKEFILE))../../../..)
-
-# Project Build flags
-WARNINGS := -Wno-long-long -Wno-unused-value -Wno-unused-label -Wno-duplicate-decl-specifier -Wno-switch -Wno-embedded-directive
-CXXFLAGS := -pthread $(WARNINGS)
-
-CXXFLAGS += -g -O0 # Debug
-# CXXFLAGS += -O3  # Release
-
-#
-# Compute tool paths
-#
-GETOS := python $(NACL_SDK_ROOT)/tools/getos.py
-OSHELPERS = python $(NACL_SDK_ROOT)/tools/oshelpers.py
-OSNAME := $(shell $(GETOS))
-
-PNACL_TC_PATH := $(abspath $(NACL_SDK_ROOT)/toolchain/$(OSNAME)_pnacl)
-PNACL_CXX := $(PNACL_TC_PATH)/bin/pnacl-clang
-PNACL_FINALIZE := $(PNACL_TC_PATH)/bin/pnacl-finalize
-CXXFLAGS += -I$(NACL_SDK_ROOT)/include -I$(NACL_SDK_ROOT)/include/pnacl
-LDFLAGS := -L$(NACL_SDK_ROOT)/lib/pnacl/Release -lppapi_cpp -lppapi -lm
-
-#
-# Disable DOS PATH warning when using Cygwin based tools Windows
-#
-CYGWIN ?= nodosfilewarning
-export CYGWIN
-
-# Declare the ALL target first, to make the 'all' target the default build
-all: ../{{{outname}}}/{{{app_name}}}.pexe
-
-.c.o:
-       $(PNACL_CXX) -c $< -g -O0 $(CXXFLAGS)
-
-{{{app_name}}}.pexe: {{{ofiles.join(" ")}}}
-       $(PNACL_CXX) -o $@ $^ $(LDFLAGS)
-
-../{{{outname}}}/{{{app_name}}}.pexe: {{{app_name}}}.pexe
-       $(PNACL_FINALIZE) -o $@ $<
-               """.write_to_file(file)
-
-               ### generate the minimal index.html
-               if not outname.file_exists then outname.mkdir
-               file = "{outname}/index.html"
-
-               if not file.file_exists then """
-<!DOCTYPE html>
-<html>
-  <!--
-  This file was generated by Nit, any modification will be lost.
-  -->
-<head>
-       <title>{{{app_name}}}</title>
-       <script src="js/pnacl_js.js"></script>
-</head>
-<body onload="pageDidLoad()">
-       <h1>PNaCl : Minimal HTML for {{{app_name}}}</h1>
-       <p>
-  <!--
-  Load the published pexe.
-  Note: Since this module does not use any real-estate in the browser, its
-  width and height are set to 0.
-
-  Note: The <embed> element is wrapped inside a <div>, which has both a 'load'
-  and a 'message' event listener attached.  This wrapping method is used
-  instead of attaching the event listeners directly to the <embed> element to
-  ensure that the listeners are active before the NaCl module 'load' event
-  fires.  This also allows you to use PPB_Messaging.PostMessage() (in C) or
-  pp::Instance.PostMessage() (in C++) from within the initialization code in
-  your module.
-  -->
-               <div id="listener">
-                       <script type="text/javascript">
-                               var listener = document.getElementById('listener');
-                               listener.addEventListener('load', moduleDidLoad, true);
-                               listener.addEventListener('message', handleMessage, true);
-                       </script>
-
-                       <embed id="{{{app_name}}}"
-                               width=0 height=0
-                               src="{{{app_name}}}.nmf"
-                               type="application/x-pnacl" />
-               </div>
-               </p>
-               <h2>Status <code id="statusField">NO-STATUS</code></h2>
-</body>
-</html>
-               """.write_to_file(file)
-
-               ### generate pnacl_js.js in a folder named 'js'
-               dir = "{outname}/js/"
-               if not dir.file_exists then dir.mkdir
-               file = "{dir}/pnacl_js.js"
-               if not file.file_exists then """
-// This file was generated by Nit, any modification will be lost.
-
-{{{app_name}}}Module = null;  // Global application object.
-statusText = 'NO-STATUS';
-
-// Indicate load success.
-function moduleDidLoad() {
-       {{{app_name}}}Module = document.getElementById('{{{app_name}}}');
-       updateStatus('SUCCESS');
-       // Send a message to the Native Client module like that
-       //{{{app_name}}}Module.postMessage('Hello World');
-}
-
-// The 'message' event handler.  This handler is fired when the NaCl module
-// posts a message to the browser by calling PPB_Messaging.PostMessage()
-// (in C) or pp::Instance.PostMessage() (in C++).  This implementation
-// simply displays the content of the message in an alert panel.
-function handleMessage(message_event) {
-       console.log(message_event.data);
-}
-
-// If the page loads before the Native Client module loads, then set the
-// status message indicating that the module is still loading.  Otherwise,
-// do not change the status message.
-function pageDidLoad() {
-       if ({{{app_name}}}Module == null) {
-               updateStatus('LOADING...');
-       } else {
-               // It's possible that the Native Client module onload event fired
-               // before the page's onload event.  In this case, the status message
-               // will reflect 'SUCCESS', but won't be displayed.  This call will
-               // display the current message.
-               updateStatus();
-       }
-}
-
-// Set the global status message.  If the element with id 'statusField'
-// exists, then set its HTML to the status message as well.
-// opt_message The message test.  If this is null or undefined, then
-// attempt to set the element with id 'statusField' to the value of
-// |statusText|.
-function updateStatus(opt_message) {
-       if (opt_message)
-               statusText = opt_message;
-       var statusField = document.getElementById('statusField');
-       if (statusField) {
-               statusField.innerHTML = statusText;
-       }
-}
-               """.write_to_file(file)
-
-               ### generate the manifest file : app_name.nmf
-               # used to point the HTML to the Native Client module
-               # and optionally provide additional commands to the PNaCl translator in Chrome
-               file = "{outname}/{app_name}.nmf"
-               """
-{
-       "program": {
-               "portable": {
-                       "pnacl-translate": {
-                               "url": "{{{app_name}}}.pexe"
-                       }
-               }
-       }
-}
-               """.write_to_file(file)
-       end
-
-       redef fun write_makefile(compile_dir, cfiles)
-       do
-               # Do nothing, already done in `write_files`
-       end
-
-       redef fun compile_c_code(compile_dir)
-       do
-               # Generate the pexe
-               toolcontext.exec_and_check(["make", "-C", compile_dir, "-j", "4"], "PNaCl project error")
-       end
-end
index e6ce3b1..1400778 100644 (file)
@@ -8,7 +8,6 @@ gtk
 nitcorn
 ffi_objc
 mpi
-pnacl
 emscipten
 nodejs
 nitunit