You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kylin.apache.org by li...@apache.org on 2015/03/03 11:00:17 UTC
[49/52] [abbrv] [partial] incubator-kylin git commit: update
ace-builds to new version
http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/99a418c0/webapp/app/components/ace-builds/demo/kitchen-sink/demo.js
----------------------------------------------------------------------
diff --git a/webapp/app/components/ace-builds/demo/kitchen-sink/demo.js b/webapp/app/components/ace-builds/demo/kitchen-sink/demo.js
new file mode 100644
index 0000000..41b39ce
--- /dev/null
+++ b/webapp/app/components/ace-builds/demo/kitchen-sink/demo.js
@@ -0,0 +1,7374 @@
+define("ace/ext/spellcheck",["require","exports","module","ace/lib/event","ace/editor","ace/config"], function(require, exports, module) {
+"use strict";
+var event = require("../lib/event");
+
+exports.contextMenuHandler = function(e){
+ var host = e.target;
+ var text = host.textInput.getElement();
+ if (!host.selection.isEmpty())
+ return;
+ var c = host.getCursorPosition();
+ var r = host.session.getWordRange(c.row, c.column);
+ var w = host.session.getTextRange(r);
+
+ host.session.tokenRe.lastIndex = 0;
+ if (!host.session.tokenRe.test(w))
+ return;
+ var PLACEHOLDER = "\x01\x01";
+ var value = w + " " + PLACEHOLDER;
+ text.value = value;
+ text.setSelectionRange(w.length, w.length + 1);
+ text.setSelectionRange(0, 0);
+ text.setSelectionRange(0, w.length);
+
+ var afterKeydown = false;
+ event.addListener(text, "keydown", function onKeydown() {
+ event.removeListener(text, "keydown", onKeydown);
+ afterKeydown = true;
+ });
+
+ host.textInput.setInputHandler(function(newVal) {
+ console.log(newVal , value, text.selectionStart, text.selectionEnd)
+ if (newVal == value)
+ return '';
+ if (newVal.lastIndexOf(value, 0) === 0)
+ return newVal.slice(value.length);
+ if (newVal.substr(text.selectionEnd) == value)
+ return newVal.slice(0, -value.length);
+ if (newVal.slice(-2) == PLACEHOLDER) {
+ var val = newVal.slice(0, -2);
+ if (val.slice(-1) == " ") {
+ if (afterKeydown)
+ return val.substring(0, text.selectionEnd);
+ val = val.slice(0, -1);
+ host.session.replace(r, val);
+ return "";
+ }
+ }
+
+ return newVal;
+ });
+};
+var Editor = require("../editor").Editor;
+require("../config").defineOptions(Editor.prototype, "editor", {
+ spellcheck: {
+ set: function(val) {
+ var text = this.textInput.getElement();
+ text.spellcheck = !!val;
+ if (!val)
+ this.removeListener("nativecontextmenu", exports.contextMenuHandler);
+ else
+ this.on("nativecontextmenu", exports.contextMenuHandler);
+ },
+ value: true
+ }
+});
+
+});
+
+define("kitchen-sink/inline_editor",["require","exports","module","ace/line_widgets","ace/editor","ace/virtual_renderer","ace/lib/dom","ace/commands/default_commands"], function(require, exports, module) {
+"use strict";
+
+var LineWidgets = require("ace/line_widgets").LineWidgets;
+var Editor = require("ace/editor").Editor;
+var Renderer = require("ace/virtual_renderer").VirtualRenderer;
+var dom = require("ace/lib/dom");
+
+
+require("ace/commands/default_commands").commands.push({
+ name: "openInlineEditor",
+ bindKey: "F3",
+ exec: function(editor) {
+ var split = window.env.split;
+ var s = editor.session;
+ var inlineEditor = new Editor(new Renderer());
+ var splitSession = split.$cloneSession(s);
+
+ var row = editor.getCursorPosition().row;
+ if (editor.session.lineWidgets && editor.session.lineWidgets[row]) {
+ editor.session.lineWidgets[row].destroy();
+ return;
+ }
+
+ var rowCount = 10;
+ var w = {
+ row: row,
+ fixedWidth: true,
+ el: dom.createElement("div"),
+ editor: editor
+ };
+ var el = w.el;
+ el.appendChild(inlineEditor.container);
+
+ if (!editor.session.widgetManager) {
+ editor.session.widgetManager = new LineWidgets(editor.session);
+ editor.session.widgetManager.attach(editor);
+ }
+
+ var h = rowCount*editor.renderer.layerConfig.lineHeight;
+ inlineEditor.container.style.height = h + "px";
+
+ el.style.position = "absolute";
+ el.style.zIndex = "4";
+ el.style.borderTop = "solid blue 2px";
+ el.style.borderBottom = "solid blue 2px";
+
+ inlineEditor.setSession(splitSession);
+ editor.session.widgetManager.addLineWidget(w);
+
+ var kb = {
+ handleKeyboard:function(_,hashId, keyString) {
+ if (hashId === 0 && keyString === "esc") {
+ w.destroy();
+ return true;
+ }
+ }
+ };
+
+ w.destroy = function() {
+ editor.keyBinding.removeKeyboardHandler(kb);
+ s.widgetManager.removeLineWidget(w);
+ };
+
+ editor.keyBinding.addKeyboardHandler(kb);
+ inlineEditor.keyBinding.addKeyboardHandler(kb);
+ inlineEditor.setTheme("ace/theme/solarized_light");
+ }
+});
+});
+
+define("kitchen-sink/dev_util",["require","exports","module"], function(require, exports, module) {
+function isStrict() {
+ try { return !arguments.callee.caller.caller.caller}
+ catch(e){ return true }
+}
+function warn() {
+ if (isStrict()) {
+ console.error("trying to access to global variable");
+ }
+}
+function def(o, key, get) {
+ try {
+ Object.defineProperty(o, key, {
+ configurable: true,
+ get: get,
+ set: function(val) {
+ delete o[key];
+ o[key] = val;
+ }
+ });
+ } catch(e) {
+ console.error(e);
+ }
+}
+def(window, "ace", function(){ warn(); return window.env.editor });
+def(window, "editor", function(){ warn(); return window.env.editor });
+def(window, "session", function(){ warn(); return window.env.editor.session });
+def(window, "split", function(){ warn(); return window.env.split });
+
+});
+
+define("ace/ext/modelist",["require","exports","module"], function(require, exports, module) {
+"use strict";
+
+var modes = [];
+function getModeForPath(path) {
+ var mode = modesByName.text;
+ var fileName = path.split(/[\/\\]/).pop();
+ for (var i = 0; i < modes.length; i++) {
+ if (modes[i].supportsFile(fileName)) {
+ mode = modes[i];
+ break;
+ }
+ }
+ return mode;
+}
+
+var Mode = function(name, caption, extensions) {
+ this.name = name;
+ this.caption = caption;
+ this.mode = "ace/mode/" + name;
+ this.extensions = extensions;
+ if (/\^/.test(extensions)) {
+ var re = extensions.replace(/\|(\^)?/g, function(a, b){
+ return "$|" + (b ? "^" : "^.*\\.");
+ }) + "$";
+ } else {
+ var re = "^.*\\.(" + extensions + ")$";
+ }
+
+ this.extRe = new RegExp(re, "gi");
+};
+
+Mode.prototype.supportsFile = function(filename) {
+ return filename.match(this.extRe);
+};
+var supportedModes = {
+ ABAP: ["abap"],
+ ActionScript:["as"],
+ ADA: ["ada|adb"],
+ Apache_Conf: ["^htaccess|^htgroups|^htpasswd|^conf|htaccess|htgroups|htpasswd"],
+ AsciiDoc: ["asciidoc"],
+ Assembly_x86:["asm"],
+ AutoHotKey: ["ahk"],
+ BatchFile: ["bat|cmd"],
+ C9Search: ["c9search_results"],
+ C_Cpp: ["cpp|c|cc|cxx|h|hh|hpp"],
+ Cirru: ["cirru|cr"],
+ Clojure: ["clj|cljs"],
+ Cobol: ["CBL|COB"],
+ coffee: ["coffee|cf|cson|^Cakefile"],
+ ColdFusion: ["cfm"],
+ CSharp: ["cs"],
+ CSS: ["css"],
+ Curly: ["curly"],
+ D: ["d|di"],
+ Dart: ["dart"],
+ Diff: ["diff|patch"],
+ Dockerfile: ["^Dockerfile"],
+ Dot: ["dot"],
+ Dummy: ["dummy"],
+ DummySyntax: ["dummy"],
+ Eiffel: ["e"],
+ EJS: ["ejs"],
+ Elixir: ["ex|exs"],
+ Elm: ["elm"],
+ Erlang: ["erl|hrl"],
+ Forth: ["frt|fs|ldr"],
+ FTL: ["ftl"],
+ Gcode: ["gcode"],
+ Gherkin: ["feature"],
+ Gitignore: ["^.gitignore"],
+ Glsl: ["glsl|frag|vert"],
+ golang: ["go"],
+ Groovy: ["groovy"],
+ HAML: ["haml"],
+ Handlebars: ["hbs|handlebars|tpl|mustache"],
+ Haskell: ["hs"],
+ haXe: ["hx"],
+ HTML: ["html|htm|xhtml"],
+ HTML_Ruby: ["erb|rhtml|html.erb"],
+ INI: ["ini|conf|cfg|prefs"],
+ Io: ["io"],
+ Jack: ["jack"],
+ Jade: ["jade"],
+ Java: ["java"],
+ JavaScript: ["js|jsm"],
+ JSON: ["json"],
+ JSONiq: ["jq"],
+ JSP: ["jsp"],
+ JSX: ["jsx"],
+ Julia: ["jl"],
+ LaTeX: ["tex|latex|ltx|bib"],
+ LESS: ["less"],
+ Liquid: ["liquid"],
+ Lisp: ["lisp"],
+ LiveScript: ["ls"],
+ LogiQL: ["logic|lql"],
+ LSL: ["lsl"],
+ Lua: ["lua"],
+ LuaPage: ["lp"],
+ Lucene: ["lucene"],
+ Makefile: ["^Makefile|^GNUmakefile|^makefile|^OCamlMakefile|make"],
+ Markdown: ["md|markdown"],
+ MATLAB: ["matlab"],
+ MEL: ["mel"],
+ MUSHCode: ["mc|mush"],
+ MySQL: ["mysql"],
+ Nix: ["nix"],
+ ObjectiveC: ["m|mm"],
+ OCaml: ["ml|mli"],
+ Pascal: ["pas|p"],
+ Perl: ["pl|pm"],
+ pgSQL: ["pgsql"],
+ PHP: ["php|phtml"],
+ Powershell: ["ps1"],
+ Praat: ["praat|praatscript|psc|proc"],
+ Prolog: ["plg|prolog"],
+ Properties: ["properties"],
+ Protobuf: ["proto"],
+ Python: ["py"],
+ R: ["r"],
+ RDoc: ["Rd"],
+ RHTML: ["Rhtml"],
+ Ruby: ["rb|ru|gemspec|rake|^Guardfile|^Rakefile|^Gemfile"],
+ Rust: ["rs"],
+ SASS: ["sass"],
+ SCAD: ["scad"],
+ Scala: ["scala"],
+ Scheme: ["scm|rkt"],
+ SCSS: ["scss"],
+ SH: ["sh|bash|^.bashrc"],
+ SJS: ["sjs"],
+ Smarty: ["smarty|tpl"],
+ snippets: ["snippets"],
+ Soy_Template:["soy"],
+ Space: ["space"],
+ SQL: ["sql"],
+ Stylus: ["styl|stylus"],
+ SVG: ["svg"],
+ Tcl: ["tcl"],
+ Tex: ["tex"],
+ Text: ["txt"],
+ Textile: ["textile"],
+ Toml: ["toml"],
+ Twig: ["twig"],
+ Typescript: ["ts|typescript|str"],
+ Vala: ["vala"],
+ VBScript: ["vbs|vb"],
+ Velocity: ["vm"],
+ Verilog: ["v|vh|sv|svh"],
+ VHDL: ["vhd|vhdl"],
+ XML: ["xml|rdf|rss|wsdl|xslt|atom|mathml|mml|xul|xbl"],
+ XQuery: ["xq"],
+ YAML: ["yaml|yml"]
+};
+
+var nameOverrides = {
+ ObjectiveC: "Objective-C",
+ CSharp: "C#",
+ golang: "Go",
+ C_Cpp: "C and C++",
+ coffee: "CoffeeScript",
+ HTML_Ruby: "HTML (Ruby)",
+ FTL: "FreeMarker"
+};
+var modesByName = {};
+for (var name in supportedModes) {
+ var data = supportedModes[name];
+ var displayName = (nameOverrides[name] || name).replace(/_/g, " ");
+ var filename = name.toLowerCase();
+ var mode = new Mode(filename, displayName, data[0]);
+ modesByName[filename] = mode;
+ modes.push(mode);
+}
+
+module.exports = {
+ getModeForPath: getModeForPath,
+ modes: modes,
+ modesByName: modesByName
+};
+
+});
+
+define("kitchen-sink/file_drop",["require","exports","module","ace/config","ace/lib/event","ace/ext/modelist","ace/editor"], function(require, exports, module) {
+
+var config = require("ace/config");
+var event = require("ace/lib/event");
+var modelist = require("ace/ext/modelist");
+
+module.exports = function(editor) {
+ event.addListener(editor.container, "dragover", function(e) {
+ var types = e.dataTransfer.types;
+ if (types && Array.prototype.indexOf.call(types, 'Files') !== -1)
+ return event.preventDefault(e);
+ });
+
+ event.addListener(editor.container, "drop", function(e) {
+ var file;
+ try {
+ file = e.dataTransfer.files[0];
+ if (window.FileReader) {
+ var reader = new FileReader();
+ reader.onload = function() {
+ var mode = modelist.getModeForPath(file.name);
+ editor.session.doc.setValue(reader.result);
+ editor.session.setMode(mode.mode);
+ editor.session.modeName = mode.name;
+ };
+ reader.readAsText(file);
+ }
+ return event.preventDefault(e);
+ } catch(err) {
+ return event.stopEvent(e);
+ }
+ });
+};
+
+var Editor = require("ace/editor").Editor;
+config.defineOptions(Editor.prototype, "editor", {
+ loadDroppedFile: {
+ set: function() { module.exports(this); },
+ value: true
+ }
+});
+
+});
+
+define("ace/theme/textmate",["require","exports","module","ace/lib/dom"], function(require, exports, module) {
+"use strict";
+
+exports.isDark = false;
+exports.cssClass = "ace-tm";
+exports.cssText = ".ace-tm .ace_gutter {\
+background: #f0f0f0;\
+color: #333;\
+}\
+.ace-tm .ace_print-margin {\
+width: 1px;\
+background: #e8e8e8;\
+}\
+.ace-tm .ace_fold {\
+background-color: #6B72E6;\
+}\
+.ace-tm {\
+background-color: #FFFFFF;\
+color: black;\
+}\
+.ace-tm .ace_cursor {\
+color: black;\
+}\
+.ace-tm .ace_invisible {\
+color: rgb(191, 191, 191);\
+}\
+.ace-tm .ace_storage,\
+.ace-tm .ace_keyword {\
+color: blue;\
+}\
+.ace-tm .ace_constant {\
+color: rgb(197, 6, 11);\
+}\
+.ace-tm .ace_constant.ace_buildin {\
+color: rgb(88, 72, 246);\
+}\
+.ace-tm .ace_constant.ace_language {\
+color: rgb(88, 92, 246);\
+}\
+.ace-tm .ace_constant.ace_library {\
+color: rgb(6, 150, 14);\
+}\
+.ace-tm .ace_invalid {\
+background-color: rgba(255, 0, 0, 0.1);\
+color: red;\
+}\
+.ace-tm .ace_support.ace_function {\
+color: rgb(60, 76, 114);\
+}\
+.ace-tm .ace_support.ace_constant {\
+color: rgb(6, 150, 14);\
+}\
+.ace-tm .ace_support.ace_type,\
+.ace-tm .ace_support.ace_class {\
+color: rgb(109, 121, 222);\
+}\
+.ace-tm .ace_keyword.ace_operator {\
+color: rgb(104, 118, 135);\
+}\
+.ace-tm .ace_string {\
+color: rgb(3, 106, 7);\
+}\
+.ace-tm .ace_comment {\
+color: rgb(76, 136, 107);\
+}\
+.ace-tm .ace_comment.ace_doc {\
+color: rgb(0, 102, 255);\
+}\
+.ace-tm .ace_comment.ace_doc.ace_tag {\
+color: rgb(128, 159, 191);\
+}\
+.ace-tm .ace_constant.ace_numeric {\
+color: rgb(0, 0, 205);\
+}\
+.ace-tm .ace_variable {\
+color: rgb(49, 132, 149);\
+}\
+.ace-tm .ace_xml-pe {\
+color: rgb(104, 104, 91);\
+}\
+.ace-tm .ace_entity.ace_name.ace_function {\
+color: #0000A2;\
+}\
+.ace-tm .ace_heading {\
+color: rgb(12, 7, 255);\
+}\
+.ace-tm .ace_list {\
+color:rgb(185, 6, 144);\
+}\
+.ace-tm .ace_meta.ace_tag {\
+color:rgb(0, 22, 142);\
+}\
+.ace-tm .ace_string.ace_regex {\
+color: rgb(255, 0, 0)\
+}\
+.ace-tm .ace_marker-layer .ace_selection {\
+background: rgb(181, 213, 255);\
+}\
+.ace-tm.ace_multiselect .ace_selection.ace_start {\
+box-shadow: 0 0 3px 0px white;\
+border-radius: 2px;\
+}\
+.ace-tm .ace_marker-layer .ace_step {\
+background: rgb(252, 255, 0);\
+}\
+.ace-tm .ace_marker-layer .ace_stack {\
+background: rgb(164, 229, 101);\
+}\
+.ace-tm .ace_marker-layer .ace_bracket {\
+margin: -1px 0 0 -1px;\
+border: 1px solid rgb(192, 192, 192);\
+}\
+.ace-tm .ace_marker-layer .ace_active-line {\
+background: rgba(0, 0, 0, 0.07);\
+}\
+.ace-tm .ace_gutter-active-line {\
+background-color : #dcdcdc;\
+}\
+.ace-tm .ace_marker-layer .ace_selected-word {\
+background: rgb(250, 250, 255);\
+border: 1px solid rgb(200, 200, 250);\
+}\
+.ace-tm .ace_indent-guide {\
+background: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgbYnAAAAE0lEQVQImWP4////f4bLly//BwAmVgd1/w11/gAAAABJRU5ErkJggg==\") right repeat-y;\
+}\
+";
+
+var dom = require("../lib/dom");
+dom.importCssString(exports.cssText, exports.cssClass);
+});
+
+define("ace/ext/whitespace",["require","exports","module","ace/lib/lang"], function(require, exports, module) {
+"use strict";
+
+var lang = require("../lib/lang");
+exports.$detectIndentation = function(lines, fallback) {
+ var stats = [];
+ var changes = [];
+ var tabIndents = 0;
+ var prevSpaces = 0;
+ var max = Math.min(lines.length, 1000);
+ for (var i = 0; i < max; i++) {
+ var line = lines[i];
+ if (!/^\s*[^*+\-\s]/.test(line))
+ continue;
+
+ if (line[0] == "\t")
+ tabIndents++;
+
+ var spaces = line.match(/^ */)[0].length;
+ if (spaces && line[spaces] != "\t") {
+ var diff = spaces - prevSpaces;
+ if (diff > 0 && !(prevSpaces%diff) && !(spaces%diff))
+ changes[diff] = (changes[diff] || 0) + 1;
+
+ stats[spaces] = (stats[spaces] || 0) + 1;
+ }
+ prevSpaces = spaces;
+ while (i < max && line[line.length - 1] == "\\")
+ line = lines[i++];
+ }
+
+ function getScore(indent) {
+ var score = 0;
+ for (var i = indent; i < stats.length; i += indent)
+ score += stats[i] || 0;
+ return score;
+ }
+
+ var changesTotal = changes.reduce(function(a,b){return a+b}, 0);
+
+ var first = {score: 0, length: 0};
+ var spaceIndents = 0;
+ for (var i = 1; i < 12; i++) {
+ var score = getScore(i);
+ if (i == 1) {
+ spaceIndents = score;
+ score = stats[1] ? 0.9 : 0.8;
+ if (!stats.length)
+ score = 0
+ } else
+ score /= spaceIndents;
+
+ if (changes[i])
+ score += changes[i] / changesTotal;
+
+ if (score > first.score)
+ first = {score: score, length: i};
+ }
+
+ if (first.score && first.score > 1.4)
+ var tabLength = first.length;
+
+ if (tabIndents > spaceIndents + 1)
+ return {ch: "\t", length: tabLength};
+
+ if (spaceIndents > tabIndents + 1)
+ return {ch: " ", length: tabLength};
+};
+
+exports.detectIndentation = function(session) {
+ var lines = session.getLines(0, 1000);
+ var indent = exports.$detectIndentation(lines) || {};
+
+ if (indent.ch)
+ session.setUseSoftTabs(indent.ch == " ");
+
+ if (indent.length)
+ session.setTabSize(indent.length);
+ return indent;
+};
+
+exports.trimTrailingSpace = function(session, trimEmpty) {
+ var doc = session.getDocument();
+ var lines = doc.getAllLines();
+
+ var min = trimEmpty ? -1 : 0;
+
+ for (var i = 0, l=lines.length; i < l; i++) {
+ var line = lines[i];
+ var index = line.search(/\s+$/);
+
+ if (index > min)
+ doc.removeInLine(i, index, line.length);
+ }
+};
+
+exports.convertIndentation = function(session, ch, len) {
+ var oldCh = session.getTabString()[0];
+ var oldLen = session.getTabSize();
+ if (!len) len = oldLen;
+ if (!ch) ch = oldCh;
+
+ var tab = ch == "\t" ? ch: lang.stringRepeat(ch, len);
+
+ var doc = session.doc;
+ var lines = doc.getAllLines();
+
+ var cache = {};
+ var spaceCache = {};
+ for (var i = 0, l=lines.length; i < l; i++) {
+ var line = lines[i];
+ var match = line.match(/^\s*/)[0];
+ if (match) {
+ var w = session.$getStringScreenWidth(match)[0];
+ var tabCount = Math.floor(w/oldLen);
+ var reminder = w%oldLen;
+ var toInsert = cache[tabCount] || (cache[tabCount] = lang.stringRepeat(tab, tabCount));
+ toInsert += spaceCache[reminder] || (spaceCache[reminder] = lang.stringRepeat(" ", reminder));
+
+ if (toInsert != match) {
+ doc.removeInLine(i, 0, match.length);
+ doc.insertInLine({row: i, column: 0}, toInsert);
+ }
+ }
+ }
+ session.setTabSize(len);
+ session.setUseSoftTabs(ch == " ");
+};
+
+exports.$parseStringArg = function(text) {
+ var indent = {};
+ if (/t/.test(text))
+ indent.ch = "\t";
+ else if (/s/.test(text))
+ indent.ch = " ";
+ var m = text.match(/\d+/);
+ if (m)
+ indent.length = parseInt(m[0], 10);
+ return indent;
+};
+
+exports.$parseArg = function(arg) {
+ if (!arg)
+ return {};
+ if (typeof arg == "string")
+ return exports.$parseStringArg(arg);
+ if (typeof arg.text == "string")
+ return exports.$parseStringArg(arg.text);
+ return arg;
+};
+
+exports.commands = [{
+ name: "detectIndentation",
+ exec: function(editor) {
+ exports.detectIndentation(editor.session);
+ }
+}, {
+ name: "trimTrailingSpace",
+ exec: function(editor) {
+ exports.trimTrailingSpace(editor.session);
+ }
+}, {
+ name: "convertIndentation",
+ exec: function(editor, arg) {
+ var indent = exports.$parseArg(arg);
+ exports.convertIndentation(editor.session, indent.ch, indent.length);
+ }
+}, {
+ name: "setIndentation",
+ exec: function(editor, arg) {
+ var indent = exports.$parseArg(arg);
+ indent.length && editor.session.setTabSize(indent.length);
+ indent.ch && editor.session.setUseSoftTabs(indent.ch == " ");
+ }
+}];
+
+});
+
+define("kitchen-sink/doclist",["require","exports","module","ace/edit_session","ace/undomanager","ace/lib/net","ace/ext/modelist"], function(require, exports, module) {
+"use strict";
+
+var EditSession = require("ace/edit_session").EditSession;
+var UndoManager = require("ace/undomanager").UndoManager;
+var net = require("ace/lib/net");
+
+var modelist = require("ace/ext/modelist");
+var fileCache = {};
+
+function initDoc(file, path, doc) {
+ if (doc.prepare)
+ file = doc.prepare(file);
+
+ var session = new EditSession(file);
+ session.setUndoManager(new UndoManager());
+ doc.session = session;
+ doc.path = path;
+ session.name = doc.name;
+ if (doc.wrapped) {
+ session.setUseWrapMode(true);
+ session.setWrapLimitRange(80, 80);
+ }
+ var mode = modelist.getModeForPath(path);
+ session.modeName = mode.name;
+ session.setMode(mode.mode);
+ return session;
+}
+
+
+function makeHuge(txt) {
+ for (var i = 0; i < 5; i++)
+ txt += txt;
+ return txt;
+}
+
+var docs = {
+ "docs/javascript.js": {order: 1, name: "JavaScript"},
+
+ "docs/latex.tex": {name: "LaTeX", wrapped: true},
+ "docs/markdown.md": {name: "Markdown", wrapped: true},
+ "docs/mushcode.mc": {name: "MUSHCode", wrapped: true},
+ "docs/pgsql.pgsql": {name: "pgSQL", wrapped: true},
+ "docs/plaintext.txt": {name: "Plain Text", prepare: makeHuge, wrapped: true},
+ "docs/sql.sql": {name: "SQL", wrapped: true},
+
+ "docs/textile.textile": {name: "Textile", wrapped: true},
+
+ "docs/c9search.c9search_results": "C9 Search Results",
+ "docs/mel.mel": "MEL",
+ "docs/Nix.nix": "Nix"
+};
+
+var ownSource = {
+};
+
+var hugeDocs = {
+ "build/src/ace.js": "",
+ "build/src-min/ace.js": ""
+};
+
+modelist.modes.forEach(function(m) {
+ var ext = m.extensions.split("|")[0];
+ if (ext[0] === "^") {
+ path = ext.substr(1);
+ } else {
+ var path = m.name + "." + ext;
+ }
+ path = "docs/" + path;
+ if (!docs[path]) {
+ docs[path] = {name: m.caption};
+ } else if (typeof docs[path] == "object" && !docs[path].name) {
+ docs[path].name = m.caption;
+ }
+});
+
+
+
+if (window.require && window.require.s) try {
+ for (var path in window.require.s.contexts._.defined) {
+ if (path.indexOf("!") != -1)
+ path = path.split("!").pop();
+ else
+ path = path + ".js";
+ ownSource[path] = "";
+ }
+} catch(e) {}
+
+function sort(list) {
+ return list.sort(function(a, b) {
+ var cmp = (b.order || 0) - (a.order || 0);
+ return cmp || a.name && a.name.localeCompare(b.name);
+ });
+}
+
+function prepareDocList(docs) {
+ var list = [];
+ for (var path in docs) {
+ var doc = docs[path];
+ if (typeof doc != "object")
+ doc = {name: doc || path};
+
+ doc.path = path;
+ doc.desc = doc.name.replace(/^(ace|docs|demo|build)\//, "");
+ if (doc.desc.length > 18)
+ doc.desc = doc.desc.slice(0, 7) + ".." + doc.desc.slice(-9);
+
+ fileCache[doc.name] = doc;
+ list.push(doc);
+ }
+
+ return list;
+}
+
+function loadDoc(name, callback) {
+ var doc = fileCache[name];
+ if (!doc)
+ return callback(null);
+
+ if (doc.session)
+ return callback(doc.session);
+ var path = doc.path;
+ var parts = path.split("/");
+ if (parts[0] == "docs")
+ path = "demo/kitchen-sink/" + path;
+ else if (parts[0] == "ace")
+ path = "lib/" + path;
+
+ net.get(path, function(x) {
+ initDoc(x, path, doc);
+ callback(doc.session);
+ });
+}
+
+module.exports = {
+ fileCache: fileCache,
+ docs: sort(prepareDocList(docs)),
+ ownSource: prepareDocList(ownSource),
+ hugeDocs: prepareDocList(hugeDocs),
+ initDoc: initDoc,
+ loadDoc: loadDoc
+};
+module.exports.all = {
+ "Mode Examples": module.exports.docs,
+ "Huge documents": module.exports.hugeDocs,
+ "own source": module.exports.ownSource
+};
+
+});
+
+define("ace/ext/themelist",["require","exports","module","ace/lib/fixoldbrowsers"], function(require, exports, module) {
+"use strict";
+require("ace/lib/fixoldbrowsers");
+
+var themeData = [
+ ["Chrome" ],
+ ["Clouds" ],
+ ["Crimson Editor" ],
+ ["Dawn" ],
+ ["Dreamweaver" ],
+ ["Eclipse" ],
+ ["GitHub" ],
+ ["Solarized Light"],
+ ["TextMate" ],
+ ["Tomorrow" ],
+ ["XCode" ],
+ ["Kuroir"],
+ ["KatzenMilch"],
+ ["Ambiance" ,"ambiance" , "dark"],
+ ["Chaos" ,"chaos" , "dark"],
+ ["Clouds Midnight" ,"clouds_midnight" , "dark"],
+ ["Cobalt" ,"cobalt" , "dark"],
+ ["idle Fingers" ,"idle_fingers" , "dark"],
+ ["krTheme" ,"kr_theme" , "dark"],
+ ["Merbivore" ,"merbivore" , "dark"],
+ ["Merbivore Soft" ,"merbivore_soft" , "dark"],
+ ["Mono Industrial" ,"mono_industrial" , "dark"],
+ ["Monokai" ,"monokai" , "dark"],
+ ["Pastel on dark" ,"pastel_on_dark" , "dark"],
+ ["Solarized Dark" ,"solarized_dark" , "dark"],
+ ["Terminal" ,"terminal" , "dark"],
+ ["Tomorrow Night" ,"tomorrow_night" , "dark"],
+ ["Tomorrow Night Blue" ,"tomorrow_night_blue" , "dark"],
+ ["Tomorrow Night Bright","tomorrow_night_bright" , "dark"],
+ ["Tomorrow Night 80s" ,"tomorrow_night_eighties" , "dark"],
+ ["Twilight" ,"twilight" , "dark"],
+ ["Vibrant Ink" ,"vibrant_ink" , "dark"]
+];
+
+
+exports.themesByName = {};
+exports.themes = themeData.map(function(data) {
+ var name = data[1] || data[0].replace(/ /g, "_").toLowerCase();
+ var theme = {
+ caption: data[0],
+ theme: "ace/theme/" + name,
+ isDark: data[2] == "dark",
+ name: name
+ };
+ exports.themesByName[name] = theme;
+ return theme;
+});
+
+});
+
+define("kitchen-sink/layout",["require","exports","module","ace/lib/dom","ace/lib/event","ace/edit_session","ace/undomanager","ace/virtual_renderer","ace/editor","ace/multi_select","ace/theme/textmate"], function(require, exports, module) {
+"use strict";
+
+var dom = require("ace/lib/dom");
+var event = require("ace/lib/event");
+
+var EditSession = require("ace/edit_session").EditSession;
+var UndoManager = require("ace/undomanager").UndoManager;
+var Renderer = require("ace/virtual_renderer").VirtualRenderer;
+var Editor = require("ace/editor").Editor;
+var MultiSelect = require("ace/multi_select").MultiSelect;
+
+dom.importCssString("\
+splitter {\
+ border: 1px solid #C6C6D2;\
+ width: 0px;\
+ cursor: ew-resize;\
+ z-index:10}\
+splitter:hover {\
+ margin-left: -2px;\
+ width:3px;\
+ border-color: #B5B4E0;\
+}\
+", "splitEditor");
+
+exports.edit = function(el) {
+ if (typeof(el) == "string")
+ el = document.getElementById(el);
+
+ var editor = new Editor(new Renderer(el, require("ace/theme/textmate")));
+
+ editor.resize();
+ event.addListener(window, "resize", function() {
+ editor.resize();
+ });
+ return editor;
+};
+
+
+var SplitRoot = function(el, theme, position, getSize) {
+ el.style.position = position || "relative";
+ this.container = el;
+ this.getSize = getSize || this.getSize;
+ this.resize = this.$resize.bind(this);
+
+ event.addListener(el.ownerDocument.defaultView, "resize", this.resize);
+ this.editor = this.createEditor();
+};
+
+(function(){
+ this.createEditor = function() {
+ var el = document.createElement("div");
+ el.className = this.$editorCSS;
+ el.style.cssText = "position: absolute; top:0px; bottom:0px";
+ this.$container.appendChild(el);
+ var session = new EditSession("");
+ var editor = new Editor(new Renderer(el, this.$theme));
+
+ this.$editors.push(editor);
+ editor.setFontSize(this.$fontSize);
+ return editor;
+ };
+ this.$resize = function() {
+ var size = this.getSize(this.container);
+ this.rect = {
+ x: size.left,
+ y: size.top,
+ w: size.width,
+ h: size.height
+ };
+ this.item.resize(this.rect);
+ };
+ this.getSize = function(el) {
+ return el.getBoundingClientRect();
+ };
+ this.destroy = function() {
+ var win = this.container.ownerDocument.defaultView;
+ event.removeListener(win, "resize", this.resize);
+ };
+
+
+}).call(SplitRoot.prototype);
+
+
+
+var Split = function(){
+
+};
+(function(){
+ this.execute = function(options) {
+ this.$u.execute(options);
+ };
+
+}).call(Split.prototype);
+
+
+
+exports.singleLineEditor = function(el) {
+ var renderer = new Renderer(el);
+ el.style.overflow = "hidden";
+
+ renderer.screenToTextCoordinates = function(x, y) {
+ var pos = this.pixelToScreenCoordinates(x, y);
+ return this.session.screenToDocumentPosition(
+ Math.min(this.session.getScreenLength() - 1, Math.max(pos.row, 0)),
+ Math.max(pos.column, 0)
+ );
+ };
+
+ renderer.$maxLines = 4;
+
+ renderer.setStyle("ace_one-line");
+ var editor = new Editor(renderer);
+ editor.session.setUndoManager(new UndoManager());
+
+ editor.setShowPrintMargin(false);
+ editor.renderer.setShowGutter(false);
+ editor.renderer.setHighlightGutterLine(false);
+ editor.$mouseHandler.$focusWaitTimout = 0;
+
+ return editor;
+};
+
+
+
+});
+
+define("kitchen-sink/token_tooltip",["require","exports","module","ace/lib/dom","ace/lib/oop","ace/lib/event","ace/range","ace/tooltip"], function(require, exports, module) {
+"use strict";
+
+var dom = require("ace/lib/dom");
+var oop = require("ace/lib/oop");
+var event = require("ace/lib/event");
+var Range = require("ace/range").Range;
+var Tooltip = require("ace/tooltip").Tooltip;
+
+function TokenTooltip (editor) {
+ if (editor.tokenTooltip)
+ return;
+ Tooltip.call(this, editor.container);
+ editor.tokenTooltip = this;
+ this.editor = editor;
+
+ this.update = this.update.bind(this);
+ this.onMouseMove = this.onMouseMove.bind(this);
+ this.onMouseOut = this.onMouseOut.bind(this);
+ event.addListener(editor.renderer.scroller, "mousemove", this.onMouseMove);
+ event.addListener(editor.renderer.content, "mouseout", this.onMouseOut);
+}
+
+oop.inherits(TokenTooltip, Tooltip);
+
+(function(){
+ this.token = {};
+ this.range = new Range();
+
+ this.update = function() {
+ this.$timer = null;
+
+ var r = this.editor.renderer;
+ if (this.lastT - (r.timeStamp || 0) > 1000) {
+ r.rect = null;
+ r.timeStamp = this.lastT;
+ this.maxHeight = window.innerHeight;
+ this.maxWidth = window.innerWidth;
+ }
+
+ var canvasPos = r.rect || (r.rect = r.scroller.getBoundingClientRect());
+ var offset = (this.x + r.scrollLeft - canvasPos.left - r.$padding) / r.characterWidth;
+ var row = Math.floor((this.y + r.scrollTop - canvasPos.top) / r.lineHeight);
+ var col = Math.round(offset);
+
+ var screenPos = {row: row, column: col, side: offset - col > 0 ? 1 : -1};
+ var session = this.editor.session;
+ var docPos = session.screenToDocumentPosition(screenPos.row, screenPos.column);
+ var token = session.getTokenAt(docPos.row, docPos.column);
+
+ if (!token && !session.getLine(docPos.row)) {
+ token = {
+ type: "",
+ value: "",
+ state: session.bgTokenizer.getState(0)
+ };
+ }
+ if (!token) {
+ session.removeMarker(this.marker);
+ this.hide();
+ return;
+ }
+
+ var tokenText = token.type;
+ if (token.state)
+ tokenText += "|" + token.state;
+ if (token.merge)
+ tokenText += "\n merge";
+ if (token.stateTransitions)
+ tokenText += "\n " + token.stateTransitions.join("\n ");
+
+ if (this.tokenText != tokenText) {
+ this.setText(tokenText);
+ this.width = this.getWidth();
+ this.height = this.getHeight();
+ this.tokenText = tokenText;
+ }
+
+ this.show(null, this.x, this.y);
+
+ this.token = token;
+ session.removeMarker(this.marker);
+ this.range = new Range(docPos.row, token.start, docPos.row, token.start + token.value.length);
+ this.marker = session.addMarker(this.range, "ace_bracket", "text");
+ };
+
+ this.onMouseMove = function(e) {
+ this.x = e.clientX;
+ this.y = e.clientY;
+ if (this.isOpen) {
+ this.lastT = e.timeStamp;
+ this.setPosition(this.x, this.y);
+ }
+ if (!this.$timer)
+ this.$timer = setTimeout(this.update, 100);
+ };
+
+ this.onMouseOut = function(e) {
+ if (e && e.currentTarget.contains(e.relatedTarget))
+ return;
+ this.hide();
+ this.editor.session.removeMarker(this.marker);
+ this.$timer = clearTimeout(this.$timer);
+ };
+
+ this.setPosition = function(x, y) {
+ if (x + 10 + this.width > this.maxWidth)
+ x = window.innerWidth - this.width - 10;
+ if (y > window.innerHeight * 0.75 || y + 20 + this.height > this.maxHeight)
+ y = y - this.height - 30;
+
+ Tooltip.prototype.setPosition.call(this, x + 10, y + 20);
+ };
+
+ this.destroy = function() {
+ this.onMouseOut();
+ event.removeListener(this.editor.renderer.scroller, "mousemove", this.onMouseMove);
+ event.removeListener(this.editor.renderer.content, "mouseout", this.onMouseOut);
+ delete this.editor.tokenTooltip;
+ };
+
+}).call(TokenTooltip.prototype);
+
+exports.TokenTooltip = TokenTooltip;
+
+});
+
+define("kitchen-sink/util",["require","exports","module","ace/lib/dom","ace/lib/event","ace/edit_session","ace/undomanager","ace/virtual_renderer","ace/editor","ace/multi_select"], function(require, exports, module) {
+"use strict";
+
+var dom = require("ace/lib/dom");
+var event = require("ace/lib/event");
+
+var EditSession = require("ace/edit_session").EditSession;
+var UndoManager = require("ace/undomanager").UndoManager;
+var Renderer = require("ace/virtual_renderer").VirtualRenderer;
+var Editor = require("ace/editor").Editor;
+var MultiSelect = require("ace/multi_select").MultiSelect;
+
+exports.createEditor = function(el) {
+ return new Editor(new Renderer(el));
+};
+
+exports.createSplitEditor = function(el) {
+ if (typeof(el) == "string")
+ el = document.getElementById(el);
+
+ var e0 = document.createElement("div");
+ var s = document.createElement("splitter");
+ var e1 = document.createElement("div");
+ el.appendChild(e0);
+ el.appendChild(e1);
+ el.appendChild(s);
+ e0.style.position = e1.style.position = s.style.position = "absolute";
+ el.style.position = "relative";
+ var split = {$container: el};
+
+ split.editor0 = split[0] = new Editor(new Renderer(e0));
+ split.editor1 = split[1] = new Editor(new Renderer(e1));
+ split.splitter = s;
+
+ s.ratio = 0.5;
+
+ split.resize = function resize(){
+ var height = el.parentNode.clientHeight - el.offsetTop;
+ var total = el.clientWidth;
+ var w1 = total * s.ratio;
+ var w2 = total * (1- s.ratio);
+ s.style.left = w1 - 1 + "px";
+ s.style.height = el.style.height = height + "px";
+
+ var st0 = split[0].container.style;
+ var st1 = split[1].container.style;
+ st0.width = w1 + "px";
+ st1.width = w2 + "px";
+ st0.left = 0 + "px";
+ st1.left = w1 + "px";
+
+ st0.top = st1.top = "0px";
+ st0.height = st1.height = height + "px";
+
+ split[0].resize();
+ split[1].resize();
+ };
+
+ split.onMouseDown = function(e) {
+ var rect = el.getBoundingClientRect();
+ var x = e.clientX;
+ var y = e.clientY;
+
+ var button = e.button;
+ if (button !== 0) {
+ return;
+ }
+
+ var onMouseMove = function(e) {
+ x = e.clientX;
+ y = e.clientY;
+ };
+ var onResizeEnd = function(e) {
+ clearInterval(timerId);
+ };
+
+ var onResizeInterval = function() {
+ s.ratio = (x - rect.left) / rect.width;
+ split.resize();
+ };
+
+ event.capture(s, onMouseMove, onResizeEnd);
+ var timerId = setInterval(onResizeInterval, 40);
+
+ return e.preventDefault();
+ };
+
+
+
+ event.addListener(s, "mousedown", split.onMouseDown);
+ event.addListener(window, "resize", split.resize);
+ split.resize();
+ return split;
+};
+exports.stripLeadingComments = function(str) {
+ if(str.slice(0,2)=='/*') {
+ var j = str.indexOf('*/')+2;
+ str = str.substr(j);
+ }
+ return str.trim() + "\n";
+};
+exports.saveOption = function(el, val) {
+ if (!el.onchange && !el.onclick)
+ return;
+
+ if ("checked" in el) {
+ if (val !== undefined)
+ el.checked = val;
+
+ localStorage && localStorage.setItem(el.id, el.checked ? 1 : 0);
+ }
+ else {
+ if (val !== undefined)
+ el.value = val;
+
+ localStorage && localStorage.setItem(el.id, el.value);
+ }
+};
+
+exports.bindCheckbox = function(id, callback, noInit) {
+ if (typeof id == "string")
+ var el = document.getElementById(id);
+ else {
+ var el = id;
+ id = el.id;
+ }
+ var el = document.getElementById(id);
+ if (localStorage && localStorage.getItem(id))
+ el.checked = localStorage.getItem(id) == "1";
+
+ var onCheck = function() {
+ callback(!!el.checked);
+ exports.saveOption(el);
+ };
+ el.onclick = onCheck;
+ noInit || onCheck();
+ return el;
+};
+
+exports.bindDropdown = function(id, callback, noInit) {
+ if (typeof id == "string")
+ var el = document.getElementById(id);
+ else {
+ var el = id;
+ id = el.id;
+ }
+ if (localStorage && localStorage.getItem(id))
+ el.value = localStorage.getItem(id);
+
+ var onChange = function() {
+ callback(el.value);
+ exports.saveOption(el);
+ };
+
+ el.onchange = onChange;
+ noInit || onChange();
+};
+
+exports.fillDropdown = function(el, values) {
+ if (typeof el == "string")
+ el = document.getElementById(el);
+
+ dropdown(values).forEach(function(e) {
+ el.appendChild(e);
+ });
+};
+
+function elt(tag, attributes, content) {
+ var el = dom.createElement(tag);
+ if (typeof content == "string") {
+ el.appendChild(document.createTextNode(content));
+ } else if (content) {
+ content.forEach(function(ch) {
+ el.appendChild(ch);
+ });
+ }
+
+ for (var i in attributes)
+ el.setAttribute(i, attributes[i]);
+ return el;
+}
+
+function optgroup(values) {
+ return values.map(function(item) {
+ if (typeof item == "string")
+ item = {name: item, caption: item};
+ return elt("option", {value: item.value || item.name}, item.caption || item.desc);
+ });
+}
+
+function dropdown(values) {
+ if (Array.isArray(values))
+ return optgroup(values);
+
+ return Object.keys(values).map(function(i) {
+ return elt("optgroup", {"label": i}, optgroup(values[i]));
+ });
+}
+
+
+});
+
+define("ace/ext/elastic_tabstops_lite",["require","exports","module","ace/editor","ace/config"], function(require, exports, module) {
+"use strict";
+
+var ElasticTabstopsLite = function(editor) {
+ this.$editor = editor;
+ var self = this;
+ var changedRows = [];
+ var recordChanges = false;
+ this.onAfterExec = function() {
+ recordChanges = false;
+ self.processRows(changedRows);
+ changedRows = [];
+ };
+ this.onExec = function() {
+ recordChanges = true;
+ };
+ this.onChange = function(e) {
+ var range = e.data.range
+ if (recordChanges) {
+ if (changedRows.indexOf(range.start.row) == -1)
+ changedRows.push(range.start.row);
+ if (range.end.row != range.start.row)
+ changedRows.push(range.end.row);
+ }
+ };
+};
+
+(function() {
+ this.processRows = function(rows) {
+ this.$inChange = true;
+ var checkedRows = [];
+
+ for (var r = 0, rowCount = rows.length; r < rowCount; r++) {
+ var row = rows[r];
+
+ if (checkedRows.indexOf(row) > -1)
+ continue;
+
+ var cellWidthObj = this.$findCellWidthsForBlock(row);
+ var cellWidths = this.$setBlockCellWidthsToMax(cellWidthObj.cellWidths);
+ var rowIndex = cellWidthObj.firstRow;
+
+ for (var w = 0, l = cellWidths.length; w < l; w++) {
+ var widths = cellWidths[w];
+ checkedRows.push(rowIndex);
+ this.$adjustRow(rowIndex, widths);
+ rowIndex++;
+ }
+ }
+ this.$inChange = false;
+ };
+
+ this.$findCellWidthsForBlock = function(row) {
+ var cellWidths = [], widths;
+ var rowIter = row;
+ while (rowIter >= 0) {
+ widths = this.$cellWidthsForRow(rowIter);
+ if (widths.length == 0)
+ break;
+
+ cellWidths.unshift(widths);
+ rowIter--;
+ }
+ var firstRow = rowIter + 1;
+ rowIter = row;
+ var numRows = this.$editor.session.getLength();
+
+ while (rowIter < numRows - 1) {
+ rowIter++;
+
+ widths = this.$cellWidthsForRow(rowIter);
+ if (widths.length == 0)
+ break;
+
+ cellWidths.push(widths);
+ }
+
+ return { cellWidths: cellWidths, firstRow: firstRow };
+ };
+
+ this.$cellWidthsForRow = function(row) {
+ var selectionColumns = this.$selectionColumnsForRow(row);
+
+ var tabs = [-1].concat(this.$tabsForRow(row));
+ var widths = tabs.map(function(el) { return 0; } ).slice(1);
+ var line = this.$editor.session.getLine(row);
+
+ for (var i = 0, len = tabs.length - 1; i < len; i++) {
+ var leftEdge = tabs[i]+1;
+ var rightEdge = tabs[i+1];
+
+ var rightmostSelection = this.$rightmostSelectionInCell(selectionColumns, rightEdge);
+ var cell = line.substring(leftEdge, rightEdge);
+ widths[i] = Math.max(cell.replace(/\s+$/g,'').length, rightmostSelection - leftEdge);
+ }
+
+ return widths;
+ };
+
+ this.$selectionColumnsForRow = function(row) {
+ var selections = [], cursor = this.$editor.getCursorPosition();
+ if (this.$editor.session.getSelection().isEmpty()) {
+ if (row == cursor.row)
+ selections.push(cursor.column);
+ }
+
+ return selections;
+ };
+
+ this.$setBlockCellWidthsToMax = function(cellWidths) {
+ var startingNewBlock = true, blockStartRow, blockEndRow, maxWidth;
+ var columnInfo = this.$izip_longest(cellWidths);
+
+ for (var c = 0, l = columnInfo.length; c < l; c++) {
+ var column = columnInfo[c];
+ if (!column.push) {
+ console.error(column);
+ continue;
+ }
+ column.push(NaN);
+
+ for (var r = 0, s = column.length; r < s; r++) {
+ var width = column[r];
+ if (startingNewBlock) {
+ blockStartRow = r;
+ maxWidth = 0;
+ startingNewBlock = false;
+ }
+ if (isNaN(width)) {
+ blockEndRow = r;
+
+ for (var j = blockStartRow; j < blockEndRow; j++) {
+ cellWidths[j][c] = maxWidth;
+ }
+ startingNewBlock = true;
+ }
+
+ maxWidth = Math.max(maxWidth, width);
+ }
+ }
+
+ return cellWidths;
+ };
+
+ this.$rightmostSelectionInCell = function(selectionColumns, cellRightEdge) {
+ var rightmost = 0;
+
+ if (selectionColumns.length) {
+ var lengths = [];
+ for (var s = 0, length = selectionColumns.length; s < length; s++) {
+ if (selectionColumns[s] <= cellRightEdge)
+ lengths.push(s);
+ else
+ lengths.push(0);
+ }
+ rightmost = Math.max.apply(Math, lengths);
+ }
+
+ return rightmost;
+ };
+
+ this.$tabsForRow = function(row) {
+ var rowTabs = [], line = this.$editor.session.getLine(row),
+ re = /\t/g, match;
+
+ while ((match = re.exec(line)) != null) {
+ rowTabs.push(match.index);
+ }
+
+ return rowTabs;
+ };
+
+ this.$adjustRow = function(row, widths) {
+ var rowTabs = this.$tabsForRow(row);
+
+ if (rowTabs.length == 0)
+ return;
+
+ var bias = 0, location = -1;
+ var expandedSet = this.$izip(widths, rowTabs);
+
+ for (var i = 0, l = expandedSet.length; i < l; i++) {
+ var w = expandedSet[i][0], it = expandedSet[i][1];
+ location += 1 + w;
+ it += bias;
+ var difference = location - it;
+
+ if (difference == 0)
+ continue;
+
+ var partialLine = this.$editor.session.getLine(row).substr(0, it );
+ var strippedPartialLine = partialLine.replace(/\s*$/g, "");
+ var ispaces = partialLine.length - strippedPartialLine.length;
+
+ if (difference > 0) {
+ this.$editor.session.getDocument().insertInLine({row: row, column: it + 1}, Array(difference + 1).join(" ") + "\t");
+ this.$editor.session.getDocument().removeInLine(row, it, it + 1);
+
+ bias += difference;
+ }
+
+ if (difference < 0 && ispaces >= -difference) {
+ this.$editor.session.getDocument().removeInLine(row, it + difference, it);
+ bias += difference;
+ }
+ }
+ };
+ this.$izip_longest = function(iterables) {
+ if (!iterables[0])
+ return [];
+ var longest = iterables[0].length;
+ var iterablesLength = iterables.length;
+
+ for (var i = 1; i < iterablesLength; i++) {
+ var iLength = iterables[i].length;
+ if (iLength > longest)
+ longest = iLength;
+ }
+
+ var expandedSet = [];
+
+ for (var l = 0; l < longest; l++) {
+ var set = [];
+ for (var i = 0; i < iterablesLength; i++) {
+ if (iterables[i][l] === "")
+ set.push(NaN);
+ else
+ set.push(iterables[i][l]);
+ }
+
+ expandedSet.push(set);
+ }
+
+
+ return expandedSet;
+ };
+ this.$izip = function(widths, tabs) {
+ var size = widths.length >= tabs.length ? tabs.length : widths.length;
+
+ var expandedSet = [];
+ for (var i = 0; i < size; i++) {
+ var set = [ widths[i], tabs[i] ];
+ expandedSet.push(set);
+ }
+ return expandedSet;
+ };
+
+}).call(ElasticTabstopsLite.prototype);
+
+exports.ElasticTabstopsLite = ElasticTabstopsLite;
+
+var Editor = require("../editor").Editor;
+require("../config").defineOptions(Editor.prototype, "editor", {
+ useElasticTabstops: {
+ set: function(val) {
+ if (val) {
+ if (!this.elasticTabstops)
+ this.elasticTabstops = new ElasticTabstopsLite(this);
+ this.commands.on("afterExec", this.elasticTabstops.onAfterExec);
+ this.commands.on("exec", this.elasticTabstops.onExec);
+ this.on("change", this.elasticTabstops.onChange);
+ } else if (this.elasticTabstops) {
+ this.commands.removeListener("afterExec", this.elasticTabstops.onAfterExec);
+ this.commands.removeListener("exec", this.elasticTabstops.onExec);
+ this.removeListener("change", this.elasticTabstops.onChange);
+ }
+ }
+ }
+});
+
+});
+
+define("ace/occur",["require","exports","module","ace/lib/oop","ace/range","ace/search","ace/edit_session","ace/search_highlight","ace/lib/dom"], function(require, exports, module) {
+"use strict";
+
+var oop = require("./lib/oop");
+var Range = require("./range").Range;
+var Search = require("./search").Search;
+var EditSession = require("./edit_session").EditSession;
+var SearchHighlight = require("./search_highlight").SearchHighlight;
+function Occur() {}
+
+oop.inherits(Occur, Search);
+
+(function() {
+ this.enter = function(editor, options) {
+ if (!options.needle) return false;
+ var pos = editor.getCursorPosition();
+ this.displayOccurContent(editor, options);
+ var translatedPos = this.originalToOccurPosition(editor.session, pos);
+ editor.moveCursorToPosition(translatedPos);
+ return true;
+ }
+ this.exit = function(editor, options) {
+ var pos = options.translatePosition && editor.getCursorPosition();
+ var translatedPos = pos && this.occurToOriginalPosition(editor.session, pos);
+ this.displayOriginalContent(editor);
+ if (translatedPos)
+ editor.moveCursorToPosition(translatedPos);
+ return true;
+ }
+
+ this.highlight = function(sess, regexp) {
+ var hl = sess.$occurHighlight = sess.$occurHighlight || sess.addDynamicMarker(
+ new SearchHighlight(null, "ace_occur-highlight", "text"));
+ hl.setRegexp(regexp);
+ sess._emit("changeBackMarker"); // force highlight layer redraw
+ }
+
+ this.displayOccurContent = function(editor, options) {
+ this.$originalSession = editor.session;
+ var found = this.matchingLines(editor.session, options);
+ var lines = found.map(function(foundLine) { return foundLine.content; });
+ var occurSession = new EditSession(lines.join('\n'));
+ occurSession.$occur = this;
+ occurSession.$occurMatchingLines = found;
+ editor.setSession(occurSession);
+ this.$useEmacsStyleLineStart = this.$originalSession.$useEmacsStyleLineStart;
+ occurSession.$useEmacsStyleLineStart = this.$useEmacsStyleLineStart;
+ this.highlight(occurSession, options.re);
+ occurSession._emit('changeBackMarker');
+ }
+
+ this.displayOriginalContent = function(editor) {
+ editor.setSession(this.$originalSession);
+ this.$originalSession.$useEmacsStyleLineStart = this.$useEmacsStyleLineStart;
+ }
+ this.originalToOccurPosition = function(session, pos) {
+ var lines = session.$occurMatchingLines;
+ var nullPos = {row: 0, column: 0};
+ if (!lines) return nullPos;
+ for (var i = 0; i < lines.length; i++) {
+ if (lines[i].row === pos.row)
+ return {row: i, column: pos.column};
+ }
+ return nullPos;
+ }
+ this.occurToOriginalPosition = function(session, pos) {
+ var lines = session.$occurMatchingLines;
+ if (!lines || !lines[pos.row])
+ return pos;
+ return {row: lines[pos.row].row, column: pos.column};
+ }
+
+ this.matchingLines = function(session, options) {
+ options = oop.mixin({}, options);
+ if (!session || !options.needle) return [];
+ var search = new Search();
+ search.set(options);
+ return search.findAll(session).reduce(function(lines, range) {
+ var row = range.start.row;
+ var last = lines[lines.length-1];
+ return last && last.row === row ?
+ lines :
+ lines.concat({row: row, content: session.getLine(row)});
+ }, []);
+ }
+
+}).call(Occur.prototype);
+
+var dom = require('./lib/dom');
+dom.importCssString(".ace_occur-highlight {\n\
+ border-radius: 4px;\n\
+ background-color: rgba(87, 255, 8, 0.25);\n\
+ position: absolute;\n\
+ z-index: 4;\n\
+ -moz-box-sizing: border-box;\n\
+ -webkit-box-sizing: border-box;\n\
+ box-sizing: border-box;\n\
+ box-shadow: 0 0 4px rgb(91, 255, 50);\n\
+}\n\
+.ace_dark .ace_occur-highlight {\n\
+ background-color: rgb(80, 140, 85);\n\
+ box-shadow: 0 0 4px rgb(60, 120, 70);\n\
+}\n", "incremental-occur-highlighting");
+
+exports.Occur = Occur;
+
+});
+
+define("ace/commands/occur_commands",["require","exports","module","ace/config","ace/occur","ace/keyboard/hash_handler","ace/lib/oop"], function(require, exports, module) {
+
+var config = require("../config"),
+ Occur = require("../occur").Occur;
+var occurStartCommand = {
+ name: "occur",
+ exec: function(editor, options) {
+ var alreadyInOccur = !!editor.session.$occur;
+ var occurSessionActive = new Occur().enter(editor, options);
+ if (occurSessionActive && !alreadyInOccur)
+ OccurKeyboardHandler.installIn(editor);
+ },
+ readOnly: true
+};
+
+var occurCommands = [{
+ name: "occurexit",
+ bindKey: 'esc|Ctrl-G',
+ exec: function(editor) {
+ var occur = editor.session.$occur;
+ if (!occur) return;
+ occur.exit(editor, {});
+ if (!editor.session.$occur) OccurKeyboardHandler.uninstallFrom(editor);
+ },
+ readOnly: true
+}, {
+ name: "occuraccept",
+ bindKey: 'enter',
+ exec: function(editor) {
+ var occur = editor.session.$occur;
+ if (!occur) return;
+ occur.exit(editor, {translatePosition: true});
+ if (!editor.session.$occur) OccurKeyboardHandler.uninstallFrom(editor);
+ },
+ readOnly: true
+}];
+
+var HashHandler = require("../keyboard/hash_handler").HashHandler;
+var oop = require("../lib/oop");
+
+
+function OccurKeyboardHandler() {}
+
+oop.inherits(OccurKeyboardHandler, HashHandler);
+
+;(function() {
+
+ this.isOccurHandler = true;
+
+ this.attach = function(editor) {
+ HashHandler.call(this, occurCommands, editor.commands.platform);
+ this.$editor = editor;
+ }
+
+ var handleKeyboard$super = this.handleKeyboard;
+ this.handleKeyboard = function(data, hashId, key, keyCode) {
+ var cmd = handleKeyboard$super.call(this, data, hashId, key, keyCode);
+ return (cmd && cmd.command) ? cmd : undefined;
+ }
+
+}).call(OccurKeyboardHandler.prototype);
+
+OccurKeyboardHandler.installIn = function(editor) {
+ var handler = new this();
+ editor.keyBinding.addKeyboardHandler(handler);
+ editor.commands.addCommands(occurCommands);
+}
+
+OccurKeyboardHandler.uninstallFrom = function(editor) {
+ editor.commands.removeCommands(occurCommands);
+ var handler = editor.getKeyboardHandler();
+ if (handler.isOccurHandler)
+ editor.keyBinding.removeKeyboardHandler(handler);
+}
+
+exports.occurStartCommand = occurStartCommand;
+
+});
+
+define("ace/commands/incremental_search_commands",["require","exports","module","ace/config","ace/lib/oop","ace/keyboard/hash_handler","ace/commands/occur_commands"], function(require, exports, module) {
+
+var config = require("../config");
+var oop = require("../lib/oop");
+var HashHandler = require("../keyboard/hash_handler").HashHandler;
+var occurStartCommand = require("./occur_commands").occurStartCommand;
+exports.iSearchStartCommands = [{
+ name: "iSearch",
+ bindKey: {win: "Ctrl-F", mac: "Command-F"},
+ exec: function(editor, options) {
+ config.loadModule(["core", "ace/incremental_search"], function(e) {
+ var iSearch = e.iSearch = e.iSearch || new e.IncrementalSearch();
+ iSearch.activate(editor, options.backwards);
+ if (options.jumpToFirstMatch) iSearch.next(options);
+ });
+ },
+ readOnly: true
+}, {
+ name: "iSearchBackwards",
+ exec: function(editor, jumpToNext) { editor.execCommand('iSearch', {backwards: true}); },
+ readOnly: true
+}, {
+ name: "iSearchAndGo",
+ bindKey: {win: "Ctrl-K", mac: "Command-G"},
+ exec: function(editor, jumpToNext) { editor.execCommand('iSearch', {jumpToFirstMatch: true, useCurrentOrPrevSearch: true}); },
+ readOnly: true
+}, {
+ name: "iSearchBackwardsAndGo",
+ bindKey: {win: "Ctrl-Shift-K", mac: "Command-Shift-G"},
+ exec: function(editor) { editor.execCommand('iSearch', {jumpToFirstMatch: true, backwards: true, useCurrentOrPrevSearch: true}); },
+ readOnly: true
+}];
+exports.iSearchCommands = [{
+ name: "restartSearch",
+ bindKey: {win: "Ctrl-F", mac: "Command-F"},
+ exec: function(iSearch) {
+ iSearch.cancelSearch(true);
+ },
+ readOnly: true,
+ isIncrementalSearchCommand: true
+}, {
+ name: "searchForward",
+ bindKey: {win: "Ctrl-S|Ctrl-K", mac: "Ctrl-S|Command-G"},
+ exec: function(iSearch, options) {
+ options.useCurrentOrPrevSearch = true;
+ iSearch.next(options);
+ },
+ readOnly: true,
+ isIncrementalSearchCommand: true
+}, {
+ name: "searchBackward",
+ bindKey: {win: "Ctrl-R|Ctrl-Shift-K", mac: "Ctrl-R|Command-Shift-G"},
+ exec: function(iSearch, options) {
+ options.useCurrentOrPrevSearch = true;
+ options.backwards = true;
+ iSearch.next(options);
+ },
+ readOnly: true,
+ isIncrementalSearchCommand: true
+}, {
+ name: "extendSearchTerm",
+ exec: function(iSearch, string) {
+ iSearch.addString(string);
+ },
+ readOnly: true,
+ isIncrementalSearchCommand: true
+}, {
+ name: "extendSearchTermSpace",
+ bindKey: "space",
+ exec: function(iSearch) { iSearch.addString(' '); },
+ readOnly: true,
+ isIncrementalSearchCommand: true
+}, {
+ name: "shrinkSearchTerm",
+ bindKey: "backspace",
+ exec: function(iSearch) {
+ iSearch.removeChar();
+ },
+ readOnly: true,
+ isIncrementalSearchCommand: true
+}, {
+ name: 'confirmSearch',
+ bindKey: 'return',
+ exec: function(iSearch) { iSearch.deactivate(); },
+ readOnly: true,
+ isIncrementalSearchCommand: true
+}, {
+ name: 'cancelSearch',
+ bindKey: 'esc|Ctrl-G',
+ exec: function(iSearch) { iSearch.deactivate(true); },
+ readOnly: true,
+ isIncrementalSearchCommand: true
+}, {
+ name: 'occurisearch',
+ bindKey: 'Ctrl-O',
+ exec: function(iSearch) {
+ var options = oop.mixin({}, iSearch.$options);
+ iSearch.deactivate();
+ occurStartCommand.exec(iSearch.$editor, options);
+ },
+ readOnly: true,
+ isIncrementalSearchCommand: true
+}, {
+ name: "yankNextWord",
+ bindKey: "Ctrl-w",
+ exec: function(iSearch) {
+ var ed = iSearch.$editor,
+ range = ed.selection.getRangeOfMovements(function(sel) { sel.moveCursorWordRight(); }),
+ string = ed.session.getTextRange(range);
+ iSearch.addString(string);
+ },
+ readOnly: true,
+ isIncrementalSearchCommand: true
+}, {
+ name: "yankNextChar",
+ bindKey: "Ctrl-Alt-y",
+ exec: function(iSearch) {
+ var ed = iSearch.$editor,
+ range = ed.selection.getRangeOfMovements(function(sel) { sel.moveCursorRight(); }),
+ string = ed.session.getTextRange(range);
+ iSearch.addString(string);
+ },
+ readOnly: true,
+ isIncrementalSearchCommand: true
+}, {
+ name: 'recenterTopBottom',
+ bindKey: 'Ctrl-l',
+ exec: function(iSearch) { iSearch.$editor.execCommand('recenterTopBottom'); },
+ readOnly: true,
+ isIncrementalSearchCommand: true
+}, {
+ name: 'selectAllMatches',
+ bindKey: 'Ctrl-space',
+ exec: function(iSearch) {
+ var ed = iSearch.$editor,
+ hl = ed.session.$isearchHighlight,
+ ranges = hl && hl.cache ? hl.cache
+ .reduce(function(ranges, ea) {
+ return ranges.concat(ea ? ea : []); }, []) : [];
+ iSearch.deactivate(false);
+ ranges.forEach(ed.selection.addRange.bind(ed.selection));
+ },
+ readOnly: true,
+ isIncrementalSearchCommand: true
+}, {
+ name: 'searchAsRegExp',
+ bindKey: 'Alt-r',
+ exec: function(iSearch) {
+ iSearch.convertNeedleToRegExp();
+ },
+ readOnly: true,
+ isIncrementalSearchCommand: true
+}];
+
+function IncrementalSearchKeyboardHandler(iSearch) {
+ this.$iSearch = iSearch;
+}
+
+oop.inherits(IncrementalSearchKeyboardHandler, HashHandler);
+
+;(function() {
+
+ this.attach = function(editor) {
+ var iSearch = this.$iSearch;
+ HashHandler.call(this, exports.iSearchCommands, editor.commands.platform);
+ this.$commandExecHandler = editor.commands.addEventListener('exec', function(e) {
+ if (!e.command.isIncrementalSearchCommand) return undefined;
+ e.stopPropagation();
+ e.preventDefault();
+ return e.command.exec(iSearch, e.args || {});
+ });
+ }
+
+ this.detach = function(editor) {
+ if (!this.$commandExecHandler) return;
+ editor.commands.removeEventListener('exec', this.$commandExecHandler);
+ delete this.$commandExecHandler;
+ }
+
+ var handleKeyboard$super = this.handleKeyboard;
+ this.handleKeyboard = function(data, hashId, key, keyCode) {
+ if (((hashId === 1/*ctrl*/ || hashId === 8/*command*/) && key === 'v')
+ || (hashId === 1/*ctrl*/ && key === 'y')) return null;
+ var cmd = handleKeyboard$super.call(this, data, hashId, key, keyCode);
+ if (cmd.command) { return cmd; }
+ if (hashId == -1) {
+ var extendCmd = this.commands.extendSearchTerm;
+ if (extendCmd) { return {command: extendCmd, args: key}; }
+ }
+ return {command: "null", passEvent: hashId == 0 || hashId == 4};
+ }
+
+}).call(IncrementalSearchKeyboardHandler.prototype);
+
+
+exports.IncrementalSearchKeyboardHandler = IncrementalSearchKeyboardHandler;
+
+});
+
+define("ace/incremental_search",["require","exports","module","ace/lib/oop","ace/range","ace/search","ace/search_highlight","ace/commands/incremental_search_commands","ace/lib/dom","ace/commands/command_manager","ace/editor","ace/config"], function(require, exports, module) {
+"use strict";
+
+var oop = require("./lib/oop");
+var Range = require("./range").Range;
+var Search = require("./search").Search;
+var SearchHighlight = require("./search_highlight").SearchHighlight;
+var iSearchCommandModule = require("./commands/incremental_search_commands");
+var ISearchKbd = iSearchCommandModule.IncrementalSearchKeyboardHandler;
+function IncrementalSearch() {
+ this.$options = {wrap: false, skipCurrent: false};
+ this.$keyboardHandler = new ISearchKbd(this);
+}
+
+oop.inherits(IncrementalSearch, Search);
+
+function isRegExp(obj) {
+ return obj instanceof RegExp;
+}
+
+function regExpToObject(re) {
+ var string = String(re),
+ start = string.indexOf('/'),
+ flagStart = string.lastIndexOf('/');
+ return {
+ expression: string.slice(start+1, flagStart),
+ flags: string.slice(flagStart+1)
+ }
+}
+
+function stringToRegExp(string, flags) {
+ try {
+ return new RegExp(string, flags);
+ } catch (e) { return string; }
+}
+
+function objectToRegExp(obj) {
+ return stringToRegExp(obj.expression, obj.flags);
+}
+
+;(function() {
+
+ this.activate = function(ed, backwards) {
+ this.$editor = ed;
+ this.$startPos = this.$currentPos = ed.getCursorPosition();
+ this.$options.needle = '';
+ this.$options.backwards = backwards;
+ ed.keyBinding.addKeyboardHandler(this.$keyboardHandler);
+ this.$originalEditorOnPaste = ed.onPaste; ed.onPaste = this.onPaste.bind(this);
+ this.$mousedownHandler = ed.addEventListener('mousedown', this.onMouseDown.bind(this));
+ this.selectionFix(ed);
+ this.statusMessage(true);
+ }
+
+ this.deactivate = function(reset) {
+ this.cancelSearch(reset);
+ var ed = this.$editor;
+ ed.keyBinding.removeKeyboardHandler(this.$keyboardHandler);
+ if (this.$mousedownHandler) {
+ ed.removeEventListener('mousedown', this.$mousedownHandler);
+ delete this.$mousedownHandler;
+ }
+ ed.onPaste = this.$originalEditorOnPaste;
+ this.message('');
+ }
+
+ this.selectionFix = function(editor) {
+ if (editor.selection.isEmpty() && !editor.session.$emacsMark) {
+ editor.clearSelection();
+ }
+ }
+
+ this.highlight = function(regexp) {
+ var sess = this.$editor.session,
+ hl = sess.$isearchHighlight = sess.$isearchHighlight || sess.addDynamicMarker(
+ new SearchHighlight(null, "ace_isearch-result", "text"));
+ hl.setRegexp(regexp);
+ sess._emit("changeBackMarker"); // force highlight layer redraw
+ }
+
+ this.cancelSearch = function(reset) {
+ var e = this.$editor;
+ this.$prevNeedle = this.$options.needle;
+ this.$options.needle = '';
+ if (reset) {
+ e.moveCursorToPosition(this.$startPos);
+ this.$currentPos = this.$startPos;
+ } else {
+ e.pushEmacsMark && e.pushEmacsMark(this.$startPos, false);
+ }
+ this.highlight(null);
+ return Range.fromPoints(this.$currentPos, this.$currentPos);
+ }
+
+ this.highlightAndFindWithNeedle = function(moveToNext, needleUpdateFunc) {
+ if (!this.$editor) return null;
+ var options = this.$options;
+ if (needleUpdateFunc) {
+ options.needle = needleUpdateFunc.call(this, options.needle || '') || '';
+ }
+ if (options.needle.length === 0) {
+ this.statusMessage(true);
+ return this.cancelSearch(true);
+ };
+ options.start = this.$currentPos;
+ var session = this.$editor.session,
+ found = this.find(session),
+ shouldSelect = this.$editor.emacsMark ?
+ !!this.$editor.emacsMark() : !this.$editor.selection.isEmpty();
+ if (found) {
+ if (options.backwards) found = Range.fromPoints(found.end, found.start);
+ this.$editor.selection.setRange(Range.fromPoints(shouldSelect ? this.$startPos : found.end, found.end));
+ if (moveToNext) this.$currentPos = found.end;
+ this.highlight(options.re)
+ }
+
+ this.statusMessage(found);
+
+ return found;
+ }
+
+ this.addString = function(s) {
+ return this.highlightAndFindWithNeedle(false, function(needle) {
+ if (!isRegExp(needle))
+ return needle + s;
+ var reObj = regExpToObject(needle);
+ reObj.expression += s;
+ return objectToRegExp(reObj);
+ });
+ }
+
+ this.removeChar = function(c) {
+ return this.highlightAndFindWithNeedle(false, function(needle) {
+ if (!isRegExp(needle))
+ return needle.substring(0, needle.length-1);
+ var reObj = regExpToObject(needle);
+ reObj.expression = reObj.expression.substring(0, reObj.expression.length-1);
+ return objectToRegExp(reObj);
+ });
+ }
+
+ this.next = function(options) {
+ options = options || {};
+ this.$options.backwards = !!options.backwards;
+ this.$currentPos = this.$editor.getCursorPosition();
+ return this.highlightAndFindWithNeedle(true, function(needle) {
+ return options.useCurrentOrPrevSearch && needle.length === 0 ?
+ this.$prevNeedle || '' : needle;
+ });
+ }
+
+ this.onMouseDown = function(evt) {
+ this.deactivate();
+ return true;
+ }
+
+ this.onPaste = function(text) {
+ this.addString(text);
+ }
+
+ this.convertNeedleToRegExp = function() {
+ return this.highlightAndFindWithNeedle(false, function(needle) {
+ return isRegExp(needle) ? needle : stringToRegExp(needle, 'ig');
+ });
+ }
+
+ this.convertNeedleToString = function() {
+ return this.highlightAndFindWithNeedle(false, function(needle) {
+ return isRegExp(needle) ? regExpToObject(needle).expression : needle;
+ });
+ }
+
+ this.statusMessage = function(found) {
+ var options = this.$options, msg = '';
+ msg += options.backwards ? 'reverse-' : '';
+ msg += 'isearch: ' + options.needle;
+ msg += found ? '' : ' (not found)';
+ this.message(msg);
+ }
+
+ this.message = function(msg) {
+ if (this.$editor.showCommandLine) {
+ this.$editor.showCommandLine(msg);
+ this.$editor.focus();
+ } else {
+ console.log(msg);
+ }
+ }
+
+}).call(IncrementalSearch.prototype);
+
+
+exports.IncrementalSearch = IncrementalSearch;
+
+var dom = require('./lib/dom');
+dom.importCssString && dom.importCssString("\
+.ace_marker-layer .ace_isearch-result {\
+ position: absolute;\
+ z-index: 6;\
+ -moz-box-sizing: border-box;\
+ -webkit-box-sizing: border-box;\
+ box-sizing: border-box;\
+}\
+div.ace_isearch-result {\
+ border-radius: 4px;\
+ background-color: rgba(255, 200, 0, 0.5);\
+ box-shadow: 0 0 4px rgb(255, 200, 0);\
+}\
+.ace_dark div.ace_isearch-result {\
+ background-color: rgb(100, 110, 160);\
+ box-shadow: 0 0 4px rgb(80, 90, 140);\
+}", "incremental-search-highlighting");
+var commands = require("./commands/command_manager");
+(function() {
+ this.setupIncrementalSearch = function(editor, val) {
+ if (this.usesIncrementalSearch == val) return;
+ this.usesIncrementalSearch = val;
+ var iSearchCommands = iSearchCommandModule.iSearchStartCommands;
+ var method = val ? 'addCommands' : 'removeCommands';
+ this[method](iSearchCommands);
+ };
+}).call(commands.CommandManager.prototype);
+var Editor = require("./editor").Editor;
+require("./config").defineOptions(Editor.prototype, "editor", {
+ useIncrementalSearch: {
+ set: function(val) {
+ this.keyBinding.$handlers.forEach(function(handler) {
+ if (handler.setupIncrementalSearch) {
+ handler.setupIncrementalSearch(this, val);
+ }
+ });
+ this._emit('incrementalSearchSettingChanged', {isEnabled: val});
+ }
+ }
+});
+
+});
+
+define("ace/split",["require","exports","module","ace/lib/oop","ace/lib/lang","ace/lib/event_emitter","ace/editor","ace/virtual_renderer","ace/edit_session"], function(require, exports, module) {
+"use strict";
+
+var oop = require("./lib/oop");
+var lang = require("./lib/lang");
+var EventEmitter = require("./lib/event_emitter").EventEmitter;
+
+var Editor = require("./editor").Editor;
+var Renderer = require("./virtual_renderer").VirtualRenderer;
+var EditSession = require("./edit_session").EditSession;
+
+
+var Split = function(container, theme, splits) {
+ this.BELOW = 1;
+ this.BESIDE = 0;
+
+ this.$container = container;
+ this.$theme = theme;
+ this.$splits = 0;
+ this.$editorCSS = "";
+ this.$editors = [];
+ this.$orientation = this.BESIDE;
+
+ this.setSplits(splits || 1);
+ this.$cEditor = this.$editors[0];
+
+
+ this.on("focus", function(editor) {
+ this.$cEditor = editor;
+ }.bind(this));
+};
+
+(function(){
+
+ oop.implement(this, EventEmitter);
+
+ this.$createEditor = function() {
+ var el = document.createElement("div");
+ el.className = this.$editorCSS;
+ el.style.cssText = "position: absolute; top:0px; bottom:0px";
+ this.$container.appendChild(el);
+ var editor = new Editor(new Renderer(el, this.$theme));
+
+ editor.on("focus", function() {
+ this._emit("focus", editor);
+ }.bind(this));
+
+ this.$editors.push(editor);
+ editor.setFontSize(this.$fontSize);
+ return editor;
+ };
+
+ this.setSplits = function(splits) {
+ var editor;
+ if (splits < 1) {
+ throw "The number of splits have to be > 0!";
+ }
+
+ if (splits == this.$splits) {
+ return;
+ } else if (splits > this.$splits) {
+ while (this.$splits < this.$editors.length && this.$splits < splits) {
+ editor = this.$editors[this.$splits];
+ this.$container.appendChild(editor.container);
+ editor.setFontSize(this.$fontSize);
+ this.$splits ++;
+ }
+ while (this.$splits < splits) {
+ this.$createEditor();
+ this.$splits ++;
+ }
+ } else {
+ while (this.$splits > splits) {
+ editor = this.$editors[this.$splits - 1];
+ this.$container.removeChild(editor.container);
+ this.$splits --;
+ }
+ }
+ this.resize();
+ };
+ this.getSplits = function() {
+ return this.$splits;
+ };
+ this.getEditor = function(idx) {
+ return this.$editors[idx];
+ };
+ this.getCurrentEditor = function() {
+ return this.$cEditor;
+ };
+ this.focus = function() {
+ this.$cEditor.focus();
+ };
+ this.blur = function() {
+ this.$cEditor.blur();
+ };
+ this.setTheme = function(theme) {
+ this.$editors.forEach(function(editor) {
+ editor.setTheme(theme);
+ });
+ };
+ this.setKeyboardHandler = function(keybinding) {
+ this.$editors.forEach(function(editor) {
+ editor.setKeyboardHandler(keybinding);
+ });
+ };
+ this.forEach = function(callback, scope) {
+ this.$editors.forEach(callback, scope);
+ };
+
+
+ this.$fontSize = "";
+ this.setFontSize = function(size) {
+ this.$fontSize = size;
+ this.forEach(function(editor) {
+ editor.setFontSize(size);
+ });
+ };
+
+ this.$cloneSession = function(session) {
+ var s = new EditSession(session.getDocument(), session.getMode());
+
+ var undoManager = session.getUndoManager();
+ if (undoManager) {
+ var undoManagerProxy = new UndoManagerProxy(undoManager, s);
+ s.setUndoManager(undoManagerProxy);
+ }
+ s.$informUndoManager = lang.delayedCall(function() { s.$deltas = []; });
+ s.setTabSize(session.getTabSize());
+ s.setUseSoftTabs(session.getUseSoftTabs());
+ s.setOverwrite(session.getOverwrite());
+ s.setBreakpoints(session.getBreakpoints());
+ s.setUseWrapMode(session.getUseWrapMode());
+ s.setUseWorker(session.getUseWorker());
+ s.setWrapLimitRange(session.$wrapLimitRange.min,
+ session.$wrapLimitRange.max);
+ s.$foldData = session.$cloneFoldData();
+
+ return s;
+ };
+ this.setSession = function(session, idx) {
+ var editor;
+ if (idx == null) {
+ editor = this.$cEditor;
+ } else {
+ editor = this.$editors[idx];
+ }
+ var isUsed = this.$editors.some(function(editor) {
+ return editor.session === session;
+ });
+
+ if (isUsed) {
+ session = this.$cloneSession(session);
+ }
+ editor.setSession(session);
+ return session;
+ };
+ this.getOrientation = function() {
+ return this.$orientation;
+ };
+ this.setOrientation = function(orientation) {
+ if (this.$orientation == orientation) {
+ return;
+ }
+ this.$orientation = orientation;
+ this.resize();
+ };
+ this.resize = function() {
+ var width = this.$container.clientWidth;
+ var height = this.$container.clientHeight;
+ var editor;
+
+ if (this.$orientation == this.BESIDE) {
+ var editorWidth = width / this.$splits;
+ for (var i = 0; i < this.$splits; i++) {
+ editor = this.$editors[i];
+ editor.container.style.width = editorWidth + "px";
+ editor.container.style.top = "0px";
+ editor.container.style.left = i * editorWidth + "px";
+ editor.container.style.height = height + "px";
+ editor.resize();
+ }
+ } else {
+ var editorHeight = height / this.$splits;
+ for (var i = 0; i < this.$splits; i++) {
+ editor = this.$editors[i];
+ editor.container.style.width = width + "px";
+ editor.container.style.top = i * editorHeight + "px";
+ editor.container.style.left = "0px";
+ editor.container.style.height = editorHeight + "px";
+ editor.resize();
+ }
+ }
+ };
+
+}).call(Split.prototype);
+
+
+function UndoManagerProxy(undoManager, session) {
+ this.$u = undoManager;
+ this.$doc = session;
+}
+
+(function() {
+ this.execute = function(options) {
+ this.$u.execute(options);
+ };
+
+ this.undo = function() {
+ var selectionRange = this.$u.undo(true);
+ if (selectionRange) {
+ this.$doc.selection.setSelectionRange(selectionRange);
+ }
+ };
+
+ this.redo = function() {
+ var selectionRange = this.$u.redo(true);
+ if (selectionRange) {
+ this.$doc.selection.setSelectionRange(selectionRange);
+ }
+ };
+
+ this.reset = function() {
+ this.$u.reset();
+ };
+
+ this.hasUndo = function() {
+ return this.$u.hasUndo();
+ };
+
+ this.hasRedo = function() {
+ return this.$u.hasRedo();
+ };
+}).call(UndoManagerProxy.prototype);
+
+exports.Split = Split;
+});
+
+define("ace/keyboard/vim/registers",["require","exports","module"], function(require, exports, module) {
+
+"never use strict";
+
+module.exports = {
+ _default: {
+ text: "",
+ isLine: false
+ }
+};
+
+});
+
+define("ace/keyboard/vim/maps/util",["require","exports","module","ace/keyboard/vim/registers","ace/lib/dom"], function(require, exports, module) {
+var registers = require("../registers");
+
+var dom = require("../../../lib/dom");
+dom.importCssString('.insert-mode .ace_cursor{\
+ border-left: 2px solid #333333;\
+}\
+.ace_dark.insert-mode .ace_cursor{\
+ border-left: 2px solid #eeeeee;\
+}\
+.normal-mode .ace_cursor{\
+ border: 0!important;\
+ background-color: red;\
+ opacity: 0.5;\
+}', 'vimMode');
+
+module.exports = {
+ onVisualMode: false,
+ onVisualLineMode: false,
+ currentMode: 'normal',
+ noMode: function(editor) {
+ editor.unsetStyle('insert-mode');
+ editor.unsetStyle('normal-mode');
+ if (editor.commands.recording)
+ editor.commands.toggleRecording(editor);
+ editor.setOverwrite(false);
+ },
+ insertMode: function(editor) {
+ this.currentMode = 'insert';
+ editor.setStyle('insert-mode');
+ editor.unsetStyle('normal-mode');
+
+ editor.setOverwrite(false);
+ editor.keyBinding.$data.buffer = "";
+ editor.keyBinding.$data.vimState = "insertMode";
+ this.onVisualMode = false;
+ this.onVisualLineMode = false;
+ if(this.onInsertReplaySequence) {
+ editor.commands.macro = this.onInsertReplaySequence;
+ editor.commands.replay(editor);
+ this.onInsertReplaySequence = null;
+ this.normalMode(editor);
+ } else {
+ editor._emit("changeStatus");
+ if(!editor.commands.recording)
+ editor.commands.toggleRecording(editor);
+ }
+ },
+ normalMode: function(editor) {
+ this.currentMode = 'normal';
+
+ editor.unsetStyle('insert-mode');
+ editor.setStyle('normal-mode');
+ editor.clearSelection();
+
+ var pos;
+ if (!editor.getOverwrite()) {
+ pos = editor.getCursorPosition();
+ if (pos.column > 0)
+ editor.navigateLeft();
+ }
+
+ editor.setOverwrite(true);
+ editor.keyBinding.$data.buffer = "";
+ editor.keyBinding.$data.vimState = "start";
+ this.onVisualMode = false;
+ this.onVisualLineMode = false;
+ editor._emit("changeStatus");
+ if (editor.commands.recording) {
+ editor.commands.toggleRecording(editor);
+ return editor.commands.macro;
+ }
+ else {
+ return [];
+ }
+ },
+ visualMode: function(editor, lineMode) {
+ if (
+ (this.onVisualLineMode && lineMode)
+ || (this.onVisualMode && !lineMode)
+ ) {
+ this.normalMode(editor);
+ return;
+ }
+
+ editor.setStyle('insert-mode');
+ editor.unsetStyle('normal-mode');
+
+ editor._emit("changeStatus");
+ if (lineMode) {
+ this.onVisualLineMode = true;
+ } else {
+ this.onVisualMode = true;
+ this.onVisualLineMode = false;
+ }
+ },
+ getRightNthChar: function(editor, cursor, ch, n) {
+ var line = editor.getSession().getLine(cursor.row);
+ var matches = line.substr(cursor.column + 1).split(ch);
+
+ return n < matches.length ? matches.slice(0, n).join(ch).length : null;
+ },
+ getLeftNthChar: function(editor, cursor, ch, n) {
+ var line = editor.getSession().getLine(cursor.row);
+ var matches = line.substr(0, cursor.column).split(ch);
+
+ return n < matches.length ? matches.slice(-1 * n).join(ch).length : null;
+ },
+ toRealChar: function(ch) {
+ if (ch.length === 1)
+ return ch;
+
+ if (/^shift-./.test(ch))
+ return ch[ch.length - 1].toUpperCase();
+ else
+ return "";
+ },
+ copyLine: function(editor) {
+ var pos = editor.getCursorPosition();
+ editor.selection.moveTo(pos.row, pos.column);
+ editor.selection.selectLine();
+ registers._default.isLine = true;
+ registers._default.text = editor.getCopyText().replace(/\n$/, "");
+ editor.selection.moveTo(pos.row, pos.column);
+ }
+};
+});
+
+define("ace/keyboard/vim/maps/motions",["require","exports","module","ace/keyboard/vim/maps/util","ace/search","ace/range"], function(require, exports, module) {
+"use strict";
+
+var util = require("./util");
+
+var keepScrollPosition = function(editor, fn) {
+ var scrollTopRow = editor.renderer.getScrollTopRow();
+ var initialRow = editor.getCursorPosition().row;
+ var diff = initialRow - scrollTopRow;
+ fn && fn.call(editor);
+ editor.renderer.scrollToRow(editor.getCursorPosition().row - diff);
+};
+
+function Motion(m) {
+ if (typeof m == "function") {
+ var getPos = m;
+ m = this;
+ } else {
+ var getPos = m.getPos;
+ }
+ m.nav = function(editor, range, count, param) {
+ var a = getPos(editor, range, count, param, false);
+ if (!a)
+ return;
+ editor.selection.moveTo(a.row, a.column);
+ };
+ m.sel = function(editor, range, count, param) {
+ var a = getPos(editor, range, count, param, true);
+ if (!a)
+ return;
+ editor.selection.selectTo(a.row, a.column);
+ };
+ return m;
+}
+
+var nonWordRe = /[\s.\/\\()\"'-:,.;<>~!@#$%^&*|+=\[\]{}`~?]/;
+var wordSeparatorRe = /[.\/\\()\"'-:,.;<>~!@#$%^&*|+=\[\]{}`~?]/;
+var whiteRe = /\s/;
+var StringStream = function(editor, cursor) {
+ var sel = editor.selection;
+ this.range = sel.getRange();
+ cursor = cursor || sel.selectionLead;
+ this.row = cursor.row;
+ this.col = cursor.column;
+ var line = editor.session.getLine(this.row);
+ var maxRow = editor.session.getLength();
+ this.ch = line[this.col] || '\n';
+ this.skippedLines = 0;
+
+ this.next = function() {
+ this.ch = line[++this.col] || this.handleNewLine(1);
+ return this.ch;
+ };
+ this.prev = function() {
+ this.ch = line[--this.col] || this.handleNewLine(-1);
+ return this.ch;
+ };
+ this.peek = function(dir) {
+ var ch = line[this.col + dir];
+ if (ch)
+ return ch;
+ if (dir == -1)
+ return '\n';
+ if (this.col == line.length - 1)
+ return '\n';
+ return editor.session.getLine(this.row + 1)[0] || '\n';
+ };
+
+ this.handleNewLine = function(dir) {
+ if (dir == 1){
+ if (this.col == line.length)
+ return '\n';
+ if (this.row == maxRow - 1)
+ return '';
+ this.col = 0;
+ this.row ++;
+ line = editor.session.getLine(this.row);
+ this.skippedLines++;
+ return line[0] || '\n';
+ }
+ if (dir == -1) {
+ if (this.row === 0)
+ return '';
+ this.row --;
+ line = editor.session.getLine(this.row);
+ this.col = line.length;
+ this.skippedLines--;
+ return '\n';
+ }
+ };
+ this.debug = function() {
+ console.log(line.substring(0, this.col)+'|'+this.ch+'\''+this.col+'\''+line.substr(this.col+1));
+ };
+};
+
+var Search = require("../../../search").Search;
+var search = new Search();
+
+function find(editor, needle, dir) {
+ search.$options.needle = needle;
+ search.$options.backwards = dir == -1;
+ return search.find(editor.session);
+}
+
+var Range = require("../../../range").Range;
+
+var LAST_SEARCH_MOTION = {};
+
+module.exports = {
+ "w": new Motion(function(editor) {
+ var str = new StringStream(editor);
+
+ if (str.ch && wordSeparatorRe.test(str.ch)) {
+ while (str.ch && wordSeparatorRe.test(str.ch))
+ str.next();
+ } else {
+ while (str.ch && !nonWordRe.test(str.ch))
+ str.next();
+ }
+ while (str.ch && whiteRe.test(str.ch) && str.skippedLines < 2)
+ str.next();
+
+ str.skippedLines == 2 && str.prev();
+ return {column: str.col, row: str.row};
+ }),
+ "W": new Motion(function(editor) {
+ var str = new StringStream(editor);
+ while(str.ch && !(whiteRe.test(str.ch) && !whiteRe.test(str.peek(1))) && str.skippedLines < 2)
+ str.next();
+ if (str.skippedLines == 2)
+ str.prev();
+ else
+ str.next();
+
+ return {column: str.col, row: str.row};
+ }),
+ "b": new Motion(function(editor) {
+ var str = new StringStream(editor);
+
+ str.prev();
+ while (str.ch && whiteRe.test(str.ch) && str.skippedLines > -2)
+ str.prev();
+
+ if (str.ch && wordSeparatorRe.test(str.ch)) {
+ while (str.ch && wordSeparatorRe.test(str.ch))
+ str.prev();
+ } else {
+ while (str.ch && !nonWordRe.test(str.ch))
+ str.prev();
+ }
+ str.ch && str.next();
+ return {column: str.col, row: str.row};
+ }),
+ "B": new Motion(function(editor) {
+ var str = new StringStream(editor);
+ str.prev();
+ while(str.ch && !(!whiteRe.test(str.ch) && whiteRe.test(str.peek(-1))) && str.skippedLines > -2)
+ str.prev();
+
+ if (str.skippedLines == -2)
+ str.next();
+
+ return {column: str.col, row: str.row};
+ }),
+ "e": new Motion(function(editor) {
+ var str = new StringStream(editor);
+
+ str.next();
+ while (str.ch && whiteR
<TRUNCATED>