UNPKG

ace-builds

Version:
1,760 lines (1,534 loc) 420 kB
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: inlineEditor }; 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("ace/test/asyncjs/assert",["require","exports","module","ace/lib/oop"], function(require, exports, module) { var oop = require("ace/lib/oop"); var pSlice = Array.prototype.slice; var assert = exports; assert.AssertionError = function AssertionError(options) { this.name = 'AssertionError'; this.message = options.message; this.actual = options.actual; this.expected = options.expected; this.operator = options.operator; var stackStartFunction = options.stackStartFunction || fail; if (Error.captureStackTrace) { Error.captureStackTrace(this, stackStartFunction); } }; oop.inherits(assert.AssertionError, Error); toJSON = function(obj) { if (typeof JSON !== "undefined") return JSON.stringify(obj); else return obj.toString(); } assert.AssertionError.prototype.toString = function() { if (this.message) { return [this.name + ':', this.message].join(' '); } else { return [this.name + ':', toJSON(this.expected), this.operator, toJSON(this.actual)].join(' '); } }; assert.AssertionError.__proto__ = Error.prototype; function fail(actual, expected, message, operator, stackStartFunction) { throw new assert.AssertionError({ message: message, actual: actual, expected: expected, operator: operator, stackStartFunction: stackStartFunction }); } assert.fail = fail; assert.ok = function ok(value, message) { if (!!!value) fail(value, true, message, '==', assert.ok); }; assert.equal = function equal(actual, expected, message) { if (actual != expected) fail(actual, expected, message, '==', assert.equal); }; assert.notEqual = function notEqual(actual, expected, message) { if (actual == expected) { fail(actual, expected, message, '!=', assert.notEqual); } }; assert.deepEqual = function deepEqual(actual, expected, message) { if (!_deepEqual(actual, expected)) { fail(actual, expected, message, 'deepEqual', assert.deepEqual); } }; function _deepEqual(actual, expected) { if (actual === expected) { return true; } else if (typeof Buffer !== "undefined" && Buffer.isBuffer(actual) && Buffer.isBuffer(expected)) { if (actual.length != expected.length) return false; for (var i = 0; i < actual.length; i++) { if (actual[i] !== expected[i]) return false; } return true; } else if (actual instanceof Date && expected instanceof Date) { return actual.getTime() === expected.getTime(); } else if (typeof actual != 'object' && typeof expected != 'object') { return actual == expected; } else { return objEquiv(actual, expected); } } function isUndefinedOrNull(value) { return value === null || value === undefined; } function isArguments(object) { return Object.prototype.toString.call(object) == '[object Arguments]'; } function objEquiv(a, b) { if (isUndefinedOrNull(a) || isUndefinedOrNull(b)) return false; if (a.prototype !== b.prototype) return false; if (isArguments(a)) { if (!isArguments(b)) { return false; } a = pSlice.call(a); b = pSlice.call(b); return _deepEqual(a, b); } try { var ka = Object.keys(a), kb = Object.keys(b), key, i; } catch (e) {//happens when one is a string literal and the other isn't return false; } if (ka.length != kb.length) return false; ka.sort(); kb.sort(); for (i = ka.length - 1; i >= 0; i--) { if (ka[i] != kb[i]) return false; } for (i = ka.length - 1; i >= 0; i--) { key = ka[i]; if (!_deepEqual(a[key], b[key])) return false; } return true; } assert.notDeepEqual = function notDeepEqual(actual, expected, message) { if (_deepEqual(actual, expected)) { fail(actual, expected, message, 'notDeepEqual', assert.notDeepEqual); } }; assert.strictEqual = function strictEqual(actual, expected, message) { if (actual !== expected) { fail(actual, expected, message, '===', assert.strictEqual); } }; assert.notStrictEqual = function notStrictEqual(actual, expected, message) { if (actual === expected) { fail(actual, expected, message, '!==', assert.notStrictEqual); } }; function expectedException(actual, expected) { if (!actual || !expected) { return false; } if (expected instanceof RegExp) { return expected.test(actual); } else if (actual instanceof expected) { return true; } else if (expected.call({}, actual) === true) { return true; } return false; } function _throws(shouldThrow, block, expected, message) { var actual; if (typeof expected === 'string') { message = expected; expected = null; } try { block(); } catch (e) { actual = e; } message = (expected && expected.name ? ' (' + expected.name + ').' : '.') + (message ? ' ' + message : '.'); if (shouldThrow && !actual) { fail('Missing expected exception' + message); } if (!shouldThrow && expectedException(actual, expected)) { fail('Got unwanted exception' + message); } if ((shouldThrow && actual && expected && !expectedException(actual, expected)) || (!shouldThrow && actual)) { throw actual; } } assert.throws = function(block, /*optional*/error, /*optional*/message) { _throws.apply(this, [true].concat(pSlice.call(arguments))); }; assert.doesNotThrow = function(block, /*optional*/error, /*optional*/message) { _throws.apply(this, [false].concat(pSlice.call(arguments))); }; assert.ifError = function(err) { if (err) {throw err;}}; }); define("ace/test/asyncjs/async",["require","exports","module"], function(require, exports, module) { var STOP = exports.STOP = {} exports.Generator = function(source) { if (typeof source == "function") this.source = { next: source } else this.source = source } ;(function() { this.next = function(callback) { this.source.next(callback) } this.map = function(mapper) { if (!mapper) return this mapper = makeAsync(1, mapper) var source = this.source this.next = function(callback) { source.next(function(err, value) { if (err) callback(err) else { mapper(value, function(err, value) { if (err) callback(err) else callback(null, value) }) } }) } return new this.constructor(this) } this.filter = function(filter) { if (!filter) return this filter = makeAsync(1, filter) var source = this.source this.next = function(callback) { source.next(function handler(err, value) { if (err) callback(err) else { filter(value, function(err, takeIt) { if (err) callback(err) else if (takeIt) callback(null, value) else source.next(handler) }) } }) } return new this.constructor(this) } this.slice = function(begin, end) { var count = -1 if (!end || end < 0) var end = Infinity var source = this.source this.next = function(callback) { source.next(function handler(err, value) { count++ if (err) callback(err) else if (count >= begin && count < end) callback(null, value) else if (count >= end) callback(STOP) else source.next(handler) }) } return new this.constructor(this) } this.reduce = function(reduce, initialValue) { reduce = makeAsync(3, reduce) var index = 0 var done = false var previousValue = initialValue var source = this.source this.next = function(callback) { if (done) return callback(STOP) if (initialValue === undefined) { source.next(function(err, currentValue) { if (err) return callback(err, previousValue) previousValue = currentValue reduceAll() }) } else reduceAll() function reduceAll() { source.next(function handler(err, currentValue) { if (err) { done = true if (err == STOP) return callback(null, previousValue) else return(err) } reduce(previousValue, currentValue, index++, function(err, value) { previousValue = value source.next(handler) }) }) } } return new this.constructor(this) } this.forEach = this.each = function(fn) { fn = makeAsync(1, fn) var source = this.source this.next = function(callback) { source.next(function handler(err, value) { if (err) callback(err) else { fn(value, function(err) { callback(err, value) }) } }) } return new this.constructor(this) } this.some = function(condition) { condition = makeAsync(1, condition) var source = this.source var done = false this.next = function(callback) { if (done) return callback(STOP) source.next(function handler(err, value) { if (err) return callback(err) condition(value, function(err, result) { if (err) { done = true if (err == STOP) callback(null, false) else callback(err) } else if (result) { done = true callback(null, true) } else source.next(handler) }) }) } return new this.constructor(this) } this.every = function(condition) { condition = makeAsync(1, condition) var source = this.source var done = false this.next = function(callback) { if (done) return callback(STOP) source.next(function handler(err, value) { if (err) return callback(err) condition(value, function(err, result) { if (err) { done = true if (err == STOP) callback(null, true) else callback(err) } else if (!result) { done = true callback(null, false) } else source.next(handler) }) }) } return new this.constructor(this) } this.call = function(context) { var source = this.source return this.map(function(fn, next) { fn = makeAsync(0, fn, context) fn.call(context, function(err, value) { next(err, value) }) }) } this.concat = function(generator) { var generators = [this] generators.push.apply(generators, arguments) var index = 0 var source = generators[index++] return new this.constructor(function(callback) { source.next(function handler(err, value) { if (err) { if (err == STOP) { source = generators[index++] if (!source) return callback(STOP) else return source.next(handler) } else return callback(err) } else return callback(null, value) }) }) } this.zip = function(generator) { var generators = [this] generators.push.apply(generators, arguments) return new this.constructor(function(callback) { exports.list(generators) .map(function(gen, next) { gen.next(next) }) .toArray(callback) }) } this.expand = function(inserter, constructor) { if (!inserter) return this var inserter = makeAsync(1, inserter) var constructor = constructor || this.constructor var source = this.source; var spliced = null; return new constructor(function next(callback) { if (!spliced) { source.next(function(err, value) { if (err) return callback(err) inserter(value, function(err, toInsert) { if (err) return callback(err) spliced = toInsert next(callback) }) }) } else { spliced.next(function(err, value) { if (err == STOP) { spliced = null return next(callback) } else if (err) return callback(err) callback(err, value) }) } }) } this.sort = function(compare) { var self = this var arrGen this.next = function(callback) { if (arrGen) return arrGen.next(callback) self.toArray(function(err, arr) { if (err) callback(err) else { arrGen = exports.list(arr.sort(compare)) arrGen.next(callback) } }) } return new this.constructor(this) } this.join = function(separator) { return this.$arrayOp(Array.prototype.join, separator !== undefined ? [separator] : null) } this.reverse = function() { return this.$arrayOp(Array.prototype.reverse) } this.$arrayOp = function(arrayMethod, args) { var self = this var i = 0 this.next = function(callback) { if (i++ > 0) return callback(STOP) self.toArray(function(err, arr) { if (err) callback(err, "") else { if (args) callback(null, arrayMethod.apply(arr, args)) else callback(null, arrayMethod.call(arr)) } }) } return new this.constructor(this) } this.end = function(breakOnError, callback) { if (!callback) { callback = arguments[0] breakOnError = true } var source = this.source var last var lastError source.next(function handler(err, value) { if (err) { if (err == STOP) callback && callback(lastError, last) else if (!breakOnError) { lastError = err source.next(handler) } else callback && callback(err, value) } else { last = value source.next(handler) } }) } this.toArray = function(breakOnError, callback) { if (!callback) { callback = arguments[0] breakOnError = true } var values = [] var errors = [] var source = this.source source.next(function handler(err, value) { if (err) { if (err == STOP) { if (breakOnError) return callback(null, values) else { errors.length = values.length return callback(errors, values) } } else { if (breakOnError) return callback(err) else errors[values.length] = err } } values.push(value) source.next(handler) }) } }).call(exports.Generator.prototype) var makeAsync = exports.makeAsync = function(args, fn, context) { if (fn.length > args) return fn else { return function() { var value var next = arguments[args] try { value = fn.apply(context || this, arguments) } catch(e) { return next(e) } next(null, value) } } } exports.list = function(arr, construct) { var construct = construct || exports.Generator var i = 0 var len = arr.length return new construct(function(callback) { if (i < len) callback(null, arr[i++]) else callback(STOP) }) } exports.values = function(map, construct) { var values = [] for (var key in map) values.push(map[key]) return exports.list(values, construct) } exports.keys = function(map, construct) { var keys = [] for (var key in map) keys.push(key) return exports.list(keys, construct) } exports.range = function(start, stop, step, construct) { var construct = construct || exports.Generator start = start || 0 step = step || 1 if (stop === undefined || stop === null) stop = step > 0 ? Infinity : -Infinity var value = start return new construct(function(callback) { if (step > 0 && value >= stop || step < 0 && value <= stop) callback(STOP) else { var current = value value += step callback(null, current) } }) } exports.concat = function(first, varargs) { if (arguments.length > 1) return first.concat.apply(first, Array.prototype.slice.call(arguments, 1)) else return first } exports.zip = function(first, varargs) { if (arguments.length > 1) return first.zip.apply(first, Array.prototype.slice.call(arguments, 1)) else return first.map(function(item, next) { next(null, [item]) }) } exports.plugin = function(members, constructors) { if (members) { for (var key in members) { exports.Generator.prototype[key] = members[key] } } if (constructors) { for (var key in constructors) { exports[key] = constructors[key] } } } }) define("ace/test/mockrenderer",["require","exports","module"], function(require, exports, module) { "use strict"; var MockRenderer = exports.MockRenderer = function(visibleRowCount) { this.container = document.createElement("div"); this.scroller = document.createElement("div"); this.visibleRowCount = visibleRowCount || 20; this.layerConfig = { firstVisibleRow : 0, lastVisibleRow : this.visibleRowCount }; this.isMockRenderer = true; this.$gutter = {}; }; MockRenderer.prototype.getFirstVisibleRow = function() { return this.layerConfig.firstVisibleRow; }; MockRenderer.prototype.getLastVisibleRow = function() { return this.layerConfig.lastVisibleRow; }; MockRenderer.prototype.getFirstFullyVisibleRow = function() { return this.layerConfig.firstVisibleRow; }; MockRenderer.prototype.getLastFullyVisibleRow = function() { return this.layerConfig.lastVisibleRow; }; MockRenderer.prototype.getContainerElement = function() { return this.container; }; MockRenderer.prototype.getMouseEventTarget = function() { return this.container; }; MockRenderer.prototype.getTextAreaContainer = function() { return this.container; }; MockRenderer.prototype.addGutterDecoration = function() { }; MockRenderer.prototype.removeGutterDecoration = function() { }; MockRenderer.prototype.moveTextAreaToCursor = function() { }; MockRenderer.prototype.setSession = function(session) { this.session = session; }; MockRenderer.prototype.getSession = function(session) { return this.session; }; MockRenderer.prototype.setTokenizer = function() { }; MockRenderer.prototype.on = function() { }; MockRenderer.prototype.updateCursor = function() { }; MockRenderer.prototype.animateScrolling = function(fromValue, callback) { callback && callback(); }; MockRenderer.prototype.scrollToX = function(scrollTop) {}; MockRenderer.prototype.scrollToY = function(scrollLeft) {}; MockRenderer.prototype.scrollToLine = function(line, center) { var lineHeight = 16; var row = 0; for (var l = 1; l < line; l++) { row += this.session.getRowLength(l-1); } if (center) { row -= this.visibleRowCount / 2; } this.scrollToRow(row); }; MockRenderer.prototype.scrollSelectionIntoView = function() { }; MockRenderer.prototype.scrollCursorIntoView = function() { var cursor = this.session.getSelection().getCursor(); if (cursor.row < this.layerConfig.firstVisibleRow) { this.scrollToRow(cursor.row); } else if (cursor.row > this.layerConfig.lastVisibleRow) { this.scrollToRow(cursor.row); } }; MockRenderer.prototype.scrollToRow = function(row) { var row = Math.min(this.session.getLength() - this.visibleRowCount, Math.max(0, row)); this.layerConfig.firstVisibleRow = row; this.layerConfig.lastVisibleRow = row + this.visibleRowCount; }; MockRenderer.prototype.getScrollTopRow = function() { return this.layerConfig.firstVisibleRow; }; MockRenderer.prototype.draw = function() { }; MockRenderer.prototype.onChangeTabSize = function(startRow, endRow) { }; MockRenderer.prototype.updateLines = function(startRow, endRow) { }; MockRenderer.prototype.updateBackMarkers = function() { }; MockRenderer.prototype.updateFrontMarkers = function() { }; MockRenderer.prototype.updateBreakpoints = function() { }; MockRenderer.prototype.onResize = function() { }; MockRenderer.prototype.updateFull = function() { }; MockRenderer.prototype.updateText = function() { }; MockRenderer.prototype.showCursor = function() { }; MockRenderer.prototype.visualizeFocus = function() { }; MockRenderer.prototype.setAnnotations = function() { }; MockRenderer.prototype.setStyle = function() { }; MockRenderer.prototype.unsetStyle = function() { }; MockRenderer.prototype.textToScreenCoordinates = function() { return { pageX: 0, pageY: 0 } }; MockRenderer.prototype.screenToTextCoordinates = function() { return { row: 0, column: 0 } }; MockRenderer.prototype.adjustWrapLimit = function () { }; }); define("kitchen-sink/dev_util",["require","exports","module","ace/lib/dom","ace/range","ace/lib/oop","ace/lib/dom","ace/range","ace/editor","ace/test/asyncjs/assert","ace/test/asyncjs/async","ace/undomanager","ace/edit_session","ace/test/mockrenderer","ace/lib/event_emitter"], function(require, exports, module) { var dom = require("ace/lib/dom"); var Range = require("ace/range").Range; function warn() { var s = (new Error()).stack || ""; s = s.split("\n"); if (s[1] == "Error") s.shift(); // remove error description on chrome s.shift(); // remove warn s.shift(); // remove the getter s = s.join("\n"); if (!/at Object.InjectedScript.|@debugger eval|snippets:\/{3}|<anonymous>:\d+:\d+/.test(s)) { 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 }); def(window, "devUtil", function(){ warn(); return exports }); exports.showTextArea = function(argument) { dom.importCssString("\ .ace_text-input {\ position: absolute;\ z-index: 10!important;\ width: 6em!important;\ height: 1em;\ opacity: 1!important;\ background: rgba(0, 92, 255, 0.11);\ border: none;\ font: inherit;\ padding: 0 1px;\ margin: 0 -1px;\ text-indent: 0em;\ }\ "); }; exports.addGlobals = function() { window.oop = require("ace/lib/oop"); window.dom = require("ace/lib/dom"); window.Range = require("ace/range").Range; window.Editor = require("ace/editor").Editor; window.assert = require("ace/test/asyncjs/assert"); window.asyncjs = require("ace/test/asyncjs/async"); window.UndoManager = require("ace/undomanager").UndoManager; window.EditSession = require("ace/edit_session").EditSession; window.MockRenderer = require("ace/test/mockrenderer").MockRenderer; window.EventEmitter = require("ace/lib/event_emitter").EventEmitter; window.getSelection = getSelection; window.setSelection = setSelection; window.testSelection = testSelection; }; function getSelection(editor) { var data = editor.multiSelect.toJSON(); if (!data.length) data = [data]; data = data.map(function(x) { var a, c; if (x.isBackwards) { a = x.end; c = x.start; } else { c = x.end; a = x.start; } return Range.comparePoints(a, c) ? [a.row, a.column, c.row, c.column] : [a.row, a.column]; }); return data.length > 1 ? data : data[0]; } function setSelection(editor, data) { if (typeof data[0] == "number") data = [data]; editor.selection.fromJSON(data.map(function(x) { var start = {row: x[0], column: x[1]}; var end = x.length == 2 ? start : {row: x[2], column: x[3]}; var isBackwards = Range.comparePoints(start, end) > 0; return isBackwards ? { start: end, end: start, isBackwards: true } : { start: start, end: end, isBackwards: true }; })); } function testSelection(editor, data) { assert.equal(getSelection(editor) + "", data + ""); } exports.recordTestCase = function() { exports.addGlobals(); var editor = window.editor; var testcase = window.testcase = []; var assert; testcase.push({ type: "setValue", data: editor.getValue() }, { type: "setSelection", data: getSelection(editor) }); editor.commands.on("afterExec", function(e) { testcase.push({ type: "exec", data: e }); testcase.push({ type: "value", data: editor.getValue() }); testcase.push({ type: "selection", data: getSelection(editor) }); }); editor.on("mouseup", function() { testcase.push({ type: "setSelection", data: getSelection(editor) }); }); testcase.toString = function() { var lastValue = ""; var str = this.map(function(x) { var data = x.data; switch (x.type) { case "exec": return 'editor.execCommand("' + data.command.name + (data.args ? '", ' + JSON.stringify(data.args) : '"') + ')'; case "setSelection": return 'setSelection(editor, ' + JSON.stringify(data) + ')'; case "setValue": if (lastValue != data) { lastValue = data; return 'editor.setValue(' + JSON.stringify(data) + ', -1)'; } return; case "selection": return 'testSelection(editor, ' + JSON.stringify(data) + ')'; case "value": if (lastValue != data) { lastValue = data; return 'assert.equal(' + 'editor.getValue(),' + JSON.stringify(data) + ')'; } return; } }).filter(Boolean).join("\n"); return getSelection + "\n" + testSelection + "\n" + setSelection + "\n" + "\n" + str + "\n"; }; }; }); 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; var re; if (/\^/.test(extensions)) { re = extensions.replace(/\|(\^)?/g, function(a, b){ return "$|" + (b ? "^" : "^.*\\."); }) + "$"; } else { re = "^.*\\.(" + extensions + ")$"; } this.extRe = new RegExp(re, "gi"); }; Mode.prototype.supportsFile = function(filename) { return filename.match(this.extRe); }; var supportedModes = { ABAP: ["abap"], ABC: ["abc"], ActionScript:["as"], ADA: ["ada|adb"], Apache_Conf: ["^htaccess|^htgroups|^htpasswd|^conf|htaccess|htgroups|htpasswd"], AsciiDoc: ["asciidoc|adoc"], Assembly_x86:["asm|a"], AutoHotKey: ["ahk"], BatchFile: ["bat|cmd"], Bro: ["bro"], C_Cpp: ["cpp|c|cc|cxx|h|hh|hpp|ino"], C9Search: ["c9search_results"], 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"], Drools: ["drl"], Dummy: ["dummy"], DummySyntax: ["dummy"], Eiffel: ["e|ge"], EJS: ["ejs"], Elixir: ["ex|exs"], Elm: ["elm"], Erlang: ["erl|hrl"], Forth: ["frt|fs|ldr|fth|4th"], Fortran: ["f|f90"], FTL: ["ftl"], Gcode: ["gcode"], Gherkin: ["feature"], Gitignore: ["^.gitignore"], Glsl: ["glsl|frag|vert"], Gobstones: ["gbs"], golang: ["go"], Groovy: ["groovy"], HAML: ["haml"], Handlebars: ["hbs|handlebars|tpl|mustache"], Haskell: ["hs"], Haskell_Cabal: ["cabal"], haXe: ["hx"], Hjson: ["hjson"], HTML: ["html|htm|xhtml"], HTML_Elixir: ["eex|html.eex"], HTML_Ruby: ["erb|rhtml|html.erb"], INI: ["ini|conf|cfg|prefs"], Io: ["io"], Jack: ["jack"], Jade: ["jade|pug"], Java: ["java"], JavaScript: ["js|jsm|jsx"], JSON: ["json"], JSONiq: ["jq"], JSP: ["jsp"], JSX: ["jsx"], Julia: ["jl"], Kotlin: ["kt|kts"], 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"], Mask: ["mask"], MATLAB: ["matlab"], Maze: ["mz"], MEL: ["mel"], MUSHCode: ["mc|mush"], MySQL: ["mysql"], Nix: ["nix"], NSIS: ["nsi|nsh"], ObjectiveC: ["m|mm"], OCaml: ["ml|mli"], Pascal: ["pas|p"], Perl: ["pl|pm"], pgSQL: ["pgsql"], PHP: ["php|phtml|shtml|php3|php4|php5|phps|phpt|aw|ctp|module"], Powershell: ["ps1"], Praat: ["praat|praatscript|psc|proc"], Prolog: ["plg|prolog"], Properties: ["properties"], Protobuf: ["proto"], Python: ["py"], R: ["r"], Razor: ["cshtml|asp"], RDoc: ["Rd"], RHTML: ["Rhtml"], RST: ["rst"], Ruby: ["rb|ru|gemspec|rake|^Guardfile|^Rakefile|^Gemfile"], Rust: ["rs"], SASS: ["sass"], SCAD: ["scad"], Scala: ["scala"], Scheme: ["scm|sm|rkt|oak|scheme"], SCSS: ["scss"], SH: ["sh|bash|^.bashrc"], SJS: ["sjs"], Smarty: ["smarty|tpl"], snippets: ["snippets"], Soy_Template:["soy"], Space: ["space"], SQL: ["sql"], SQLServer: ["sqlserver"], Stylus: ["styl|stylus"], SVG: ["svg"], Swift: ["swift"], Tcl: ["tcl"], Tex: ["tex"], Text: ["txt"], Textile: ["textile"], Toml: ["toml"], TSX: ["tsx"], Twig: ["twig|swig"], Typescript: ["ts|typescript|str"], Vala: ["vala"], VBScript: ["vbs|vb"], Velocity: ["vm"], Verilog: ["v|vh|sv|svh"], VHDL: ["vhd|vhdl"], Wollok: ["wlk|wpgm|wtest"], XML: ["xml|rdf|rss|wsdl|xslt|atom|mathml|mml|xul|xbl|xaml"], XQuery: ["xq"], YAML: ["yaml|yml"], Django: ["html"] }; var nameOverrides = { ObjectiveC: "Objective-C", CSharp: "C#", golang: "Go", C_Cpp: "C and C++", coffee: "CoffeeScript", HTML_Ruby: "HTML (Ruby)", HTML_Elixir: "HTML (Elixir)", 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;\ }\ .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++; prevSpaces = -Number.MAX_VALUE; } else { 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) { if (tabLength == 1 || spaceIndents < tabIndents / 4 || first.score < 1.8) tabLength = undefined; 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.$pa