diff --git a/build/standalone/config/default.js b/build/standalone/config/default.js index 6c5decd5..8cb97e75 100644 --- a/build/standalone/config/default.js +++ b/build/standalone/config/default.js @@ -373,7 +373,7 @@ require.MODULE_LOAD_URL = MODULE_LOAD_URL; require.toUrl = function(moduleName, ext, skipExt, skipBalancers) { var absRe = /^([\w\+\.\-]+:|\/)/; var index = moduleName.indexOf("!"); - if (index !== -1 || !ext || /^\/|\.js$/.test(moduleName)) + if (index !== -1 || !ext || /^\//.test(moduleName)) ext = ""; var paths = config.paths; @@ -398,7 +398,9 @@ require.toUrl = function(moduleName, ext, skipExt, skipBalancers) { if (skipExt) return testPath; - var url = moduleName + ext; + var url = ext == ".js" && moduleName.slice(-3) == ext + ? moduleName + : moduleName + ext; if (!absRe.test(url)) { if (ext == ".js" && require.config.transform) url = ("~/" + require.config.transform + "/" + url).replace("//", "/"); @@ -408,6 +410,8 @@ require.toUrl = function(moduleName, ext, skipExt, skipBalancers) { var n = Math.abs(hashCode(url)) % config.baseUrlLoadBalancers.length; url = config.baseUrlLoadBalancers[n] + url; } + if (url[0] == "/") + url = host + url; return url; }; @@ -571,6 +575,10 @@ function checkCache() { if (parts[i]) { var del = ideCache.delete(baseUrl + parts[i]); toDelete.push(del); + if (require.config.transform) { + del = ideCache.delete(baseUrl + ("~/" + require.config.transform) + parts[i]); + toDelete.push(del); + } } } }, function(e, t) { @@ -663,9 +671,9 @@ function definePlugin(plugin, p) { } require["vfs!"] = function(module, callback) { var url = require.MODULE_LOAD_URL + "/~node/" + module; - if (define.fetchedUrls[url] & 3) + if (define.fetchedUrls[url] & 4) return false; - define.fetchedUrls[url] |= 3; + define.fetchedUrls[url] |= 4; define("vfs!" + module, [], { srcUrl: url, path: module @@ -2654,9 +2662,58 @@ exports.implement = function(proto, mixin) { }); +define("ace/lib/useragent",[], function(require, exports, module) { +"use strict"; +exports.OS = { + LINUX: "LINUX", + MAC: "MAC", + WINDOWS: "WINDOWS" +}; +exports.getOS = function() { + if (exports.isMac) { + return exports.OS.MAC; + } else if (exports.isLinux) { + return exports.OS.LINUX; + } else { + return exports.OS.WINDOWS; + } +}; +if (typeof navigator != "object") + return; + +var os = (navigator.platform.match(/mac|win|linux/i) || ["other"])[0].toLowerCase(); +var ua = navigator.userAgent; +exports.isWin = (os == "win"); +exports.isMac = (os == "mac"); +exports.isLinux = (os == "linux"); +exports.isIE = + (navigator.appName == "Microsoft Internet Explorer" || navigator.appName.indexOf("MSAppHost") >= 0) + ? parseFloat((ua.match(/(?:MSIE |Trident\/[0-9]+[\.0-9]+;.*rv:)([0-9]+[\.0-9]+)/)||[])[1]) + : parseFloat((ua.match(/(?:Trident\/[0-9]+[\.0-9]+;.*rv:)([0-9]+[\.0-9]+)/)||[])[1]); // for ie + +exports.isOldIE = exports.isIE && exports.isIE < 9; +exports.isGecko = exports.isMozilla = ua.match(/ Gecko\/\d+/); +exports.isOpera = window.opera && Object.prototype.toString.call(window.opera) == "[object Opera]"; +exports.isWebKit = parseFloat(ua.split("WebKit/")[1]) || undefined; + +exports.isChrome = parseFloat(ua.split(" Chrome/")[1]) || undefined; + +exports.isAIR = ua.indexOf("AdobeAIR") >= 0; + +exports.isIPad = ua.indexOf("iPad") >= 0; + +exports.isChromeOS = ua.indexOf(" CrOS ") >= 0; + +exports.isIOS = /iPad|iPhone|iPod/.test(ua) && !window.MSStream; + +if (exports.isIOS) exports.isMac = true; + +}); + define("ace/lib/dom",[], function(require, exports, module) { "use strict"; +var useragent = require("./useragent"); var XHTML_NS = "http://www.w3.org/1999/xhtml"; exports.buildDom = function buildDom(arr, parent, refs) { @@ -2716,6 +2773,20 @@ exports.createElement = function(tag, ns) { document.createElement(tag); }; +exports.removeChildren = function(element) { + element.innerHTML = ""; +}; + +exports.createTextNode = function(textContent, element) { + var doc = element ? element.ownerDocument : document; + return doc.createTextNode(textContent); +}; + +exports.createFragment = function(element) { + var doc = element ? element.ownerDocument : document; + return doc.createDocumentFragment(); +}; + exports.hasCssClass = function(el, name) { var classes = (el.className + "").split(/\s+/g); return classes.indexOf(name) !== -1; @@ -2793,6 +2864,9 @@ exports.importCssString = function importCssString(cssText, id, container) { root.appendChild(style); }; +exports.importCssStylsheet = function(uri, doc) { + exports.buildDom(["link", {rel: "stylesheet", href: uri}], exports.getDocumentHead(doc)); +}; exports.scrollbarWidth = function(document) { var inner = exports.createElement("ace_inner"); inner.style.width = "100%"; @@ -2838,6 +2912,44 @@ exports.computedStyle = function(element, style) { return window.getComputedStyle(element, "") || {}; }; +exports.setStyle = function(styles, property, value) { + if (styles[property] !== value) { + styles[property] = value; + } +}; + +exports.HAS_CSS_ANIMATION = false; +if (typeof document !== "undefined") { + var div = document.createElement("div"); + if (typeof div.style.animationName !== "undefined") { + exports.HAS_CSS_ANIMATION = true; + } +} + +exports.HAS_CSS_TRANSFORMS = false; +exports.HI_DPI = useragent.isWin + ? typeof window !== "undefined" && window.devicePixelRatio >= 1.5 + : true; + +if (exports.HI_DPI && typeof document !== "undefined") { + var div = document.createElement("div"); + if (div.style.transform !== undefined) + exports.HAS_CSS_TRANSFORMS = true; + div = null; + +} + +if (exports.HAS_CSS_TRANSFORMS) { + exports.translate = function(element, tx, ty) { + element.style.transform = "translate(" + Math.round(tx) + "px, " + Math.round(ty) +"px)"; + }; +} else { + exports.translate = function(element, tx, ty) { + element.style.top = Math.round(ty) + "px"; + element.style.left = Math.round(tx) + "px"; + }; +} + }); define("ace/lib/lang",[], function(require, exports, module) { @@ -3147,7 +3259,6 @@ EventEmitter.removeDefaultHandler = function(eventName, callback) { var disabled = handlers._disabled_[eventName]; if (handlers[eventName] == callback) { - var old = handlers[eventName]; if (disabled) this.setDefaultHandler(eventName, disabled.pop()); } else if (disabled) { @@ -3938,139 +4049,9 @@ exports.ColumnHeader = ColumnHeader; }); -define("ace/lib/es6-shim",[], function(require, exports, module) { - function defineProp(obj, name, val) { - Object.defineProperty(obj, name, { - value: val, - enumerable: false, - writable: true, - configurable: true, - }); - } - if (!String.prototype.startsWith) { - defineProp(String.prototype, "startsWith", function(searchString, position) { - position = position || 0; - return this.lastIndexOf(searchString, position) === position; - }); - } - if (!String.prototype.endsWith) { - defineProp(String.prototype, "endsWith", function(searchString, position) { - var subjectString = this; - if (position === undefined || position > subjectString.length) { - position = subjectString.length; - } - position -= searchString.length; - var lastIndex = subjectString.indexOf(searchString, position); - return lastIndex !== -1 && lastIndex === position; - }); - } - if (!String.prototype.repeat) { - defineProp(String.prototype, "repeat", function(count) { - var result = ""; - var string = this; - while (count > 0) { - if (count & 1) - result += string; - - if (count >>= 1) - string += string; - } - return result; - }); - } - if (!String.prototype.includes) { - defineProp(String.prototype, "includes", function(str, position) { - return this.indexOf(str, position) != -1; - }); - } - if (!Object.assign) { - Object.assign = function(target) { - if (target === undefined || target === null) { - throw new TypeError("Cannot convert undefined or null to object"); - } - - var output = Object(target); - for (var index = 1; index < arguments.length; index++) { - var source = arguments[index]; - if (source !== undefined && source !== null) { - Object.keys(source).forEach(function(key) { - output[key] = source[key]; - }); - } - } - return output; - }; - } - if (!Array.prototype.find) { - defineProp(Array.prototype, "find", function(predicate) { - var len = this.length; - var thisArg = arguments[1]; - for (var k = 0; k < len; k++) { - var kValue = this[k]; - if (predicate.call(thisArg, kValue, k, this)) { - return kValue; - } - } - }); - } - if (!Array.prototype.findIndex) { - defineProp(Array.prototype, "findIndex", function(predicate) { - var len = this.length; - var thisArg = arguments[1]; - for (var k = 0; k < len; k++) { - var kValue = this[k]; - if (predicate.call(thisArg, kValue, k, this)) { - return k; - } - } - }); - } - if (!Array.prototype.includes) { - defineProp(Array.prototype, "includes", function(item, position) { - return this.indexOf(item, position) != -1; - }); - } - if (!Array.prototype.fill) { - defineProp(Array.prototype, "fill", function(value) { - var O = this; - var len = O.length >>> 0; - var start = arguments[1]; - var relativeStart = start >> 0; - var k = relativeStart < 0 ? - Math.max(len + relativeStart, 0) : - Math.min(relativeStart, len); - var end = arguments[2]; - var relativeEnd = end === undefined ? - len : end >> 0; - var final = relativeEnd < 0 ? - Math.max(len + relativeEnd, 0) : - Math.min(relativeEnd, len); - while (k < final) { - O[k] = value; - k++; - } - return O; - }); - } - if (!Array.of) { - defineProp(Array, "of", function() { - return Array.prototype.slice.call(arguments); - }); - } -}); - -define("ace/lib/fixoldbrowsers",[], function(require, exports, module) { -"use strict"; - -require("./es6-shim"); - -}); - define("ace/lib/keys",[], function(require, exports, module) { "use strict"; -require("./fixoldbrowsers"); - var oop = require("./oop"); var Keys = (function() { var ret = { @@ -4181,54 +4162,6 @@ exports.keyCodeToString = function(keyCode) { }); -define("ace/lib/useragent",[], function(require, exports, module) { -"use strict"; -exports.OS = { - LINUX: "LINUX", - MAC: "MAC", - WINDOWS: "WINDOWS" -}; -exports.getOS = function() { - if (exports.isMac) { - return exports.OS.MAC; - } else if (exports.isLinux) { - return exports.OS.LINUX; - } else { - return exports.OS.WINDOWS; - } -}; -if (typeof navigator != "object") - return; - -var os = (navigator.platform.match(/mac|win|linux/i) || ["other"])[0].toLowerCase(); -var ua = navigator.userAgent; -exports.isWin = (os == "win"); -exports.isMac = (os == "mac"); -exports.isLinux = (os == "linux"); -exports.isIE = - (navigator.appName == "Microsoft Internet Explorer" || navigator.appName.indexOf("MSAppHost") >= 0) - ? parseFloat((ua.match(/(?:MSIE |Trident\/[0-9]+[\.0-9]+;.*rv:)([0-9]+[\.0-9]+)/)||[])[1]) - : parseFloat((ua.match(/(?:Trident\/[0-9]+[\.0-9]+;.*rv:)([0-9]+[\.0-9]+)/)||[])[1]); // for ie - -exports.isOldIE = exports.isIE && exports.isIE < 9; -exports.isGecko = exports.isMozilla = ua.match(/ Gecko\/\d+/); -exports.isOpera = window.opera && Object.prototype.toString.call(window.opera) == "[object Opera]"; -exports.isWebKit = parseFloat(ua.split("WebKit/")[1]) || undefined; - -exports.isChrome = parseFloat(ua.split(" Chrome/")[1]) || undefined; - -exports.isAIR = ua.indexOf("AdobeAIR") >= 0; - -exports.isIPad = ua.indexOf("iPad") >= 0; - -exports.isChromeOS = ua.indexOf(" CrOS ") >= 0; - -exports.isIOS = /iPad|iPhone|iPod/.test(ua) && !window.MSStream; - -if (exports.isIOS) exports.isMac = true; - -}); - define("ace/lib/event",[], function(require, exports, module) { "use strict"; @@ -4548,18 +4481,42 @@ if (typeof window == "object" && window.postMessage && !useragent.isOldIE) { var postMessageId = 1; exports.nextTick = function(callback, win) { win = win || window; - var messageName = "zero-timeout-message-" + postMessageId; - exports.addListener(win, "message", function listener(e) { + var messageName = "zero-timeout-message-" + (postMessageId++); + + var listener = function(e) { if (e.data == messageName) { exports.stopPropagation(e); exports.removeListener(win, "message", listener); callback(); } - }); + }; + + exports.addListener(win, "message", listener); win.postMessage(messageName, "*"); }; } +exports.$idleBlocked = false; +exports.onIdle = function(cb, timeout) { + return setTimeout(function handler() { + if (!exports.$idleBlocked) { + cb(); + } else { + setTimeout(handler, 100); + } + }, timeout); +}; + +exports.$idleBlockId = null; +exports.blockIdle = function(delay) { + if (exports.$idleBlockId) + clearTimeout(exports.$idleBlockId); + + exports.$idleBlocked = true; + exports.$idleBlockId = setTimeout(function() { + exports.$idleBlocked = false; + }, delay || 100); +}; exports.nextFrame = typeof window == "object" && (window.requestAnimationFrame || window.mozRequestAnimationFrame @@ -4727,20 +4684,23 @@ var RenderLoop = function(onRender, win) { (function() { - this.schedule = function(change) { this.changes = this.changes | change; - if (!this.pending && this.changes) { - this.pending = true; + if (this.changes) { var _self = this; - event.nextFrame(function() { - _self.pending = false; - var changes; - while (changes = _self.changes) { + + event.nextFrame(function(ts) { + var changes = _self.changes; + + if (changes) { + event.blockIdle(100); _self.changes = 0; _self.onRender(changes); } - }, this.window); + + if (_self.changes) + _self.schedule(); + }); } }; @@ -13001,9 +12961,16 @@ define("plugins/c9.ide.collab/author_layer",[], function(require, module, export return; session._emit("changeBackMarker"); - var gutter = ace.renderer.$gutterLayer; - gutter.update = updateGutter; - gutter.update(ace.renderer.layerConfig); + var renderer = ace.renderer; + renderer.$gutterLayer.$padding = null; + renderer.$loop.schedule(renderer.CHANGE_GUTTER); + if (showAuthorInfo) { + renderer.$gutterLayer.on("afterRender", decorateGutter); + } + else { + renderer.$gutterLayer.off("afterRender", decorateGutter); + clearGutterDecorations(renderer); + } } function drawAuthInfos(html, markerLayer, session, config) { @@ -13058,141 +13025,45 @@ define("plugins/c9.ide.collab/author_layer",[], function(require, module, export } } - function updateGutter(config) { - var session = this.session; - var firstRow = config.firstRow; - var lastRow = Math.min(config.lastRow + config.gutterOffset, // needed to compensate for hor scollbar - session.getLength() - 1); - var fold = session.getNextFoldLine(firstRow); - var foldStart = fold ? fold.start.row : Infinity; - var foldWidgets = this.$showFoldWidgets && session.foldWidgets; - var breakpoints = session.$breakpoints; - var decorations = session.$decorations; - var firstLineNumber = session.$firstLineNumber; - var lastLineNumber = 0; - - var gutterRenderer = session.gutterRenderer || this.$renderer; + function decorateGutter(e, gutter) { + var session = gutter.session; var editorDoc = session.doc; var doc = session.collabDoc; - var range = new Range(firstRow, 0, lastRow, editorDoc.getLine(lastRow).length); var isCollabGutter = doc && showAuthorInfo && util.isRealCollab(workspace); + + var config = gutter.config; + var range = new Range(config.firstRow, 0, config.lastRow, Number.MAX_VALUE); var authorKeysCache = isCollabGutter && createAuthorKeyCache(editorDoc, doc.authAttribs, range).authorKeys; - var colorPool = workspace.colorPool; var reversedAuthorPool = workspace.reversedAuthorPool; - var cell = null; - var index = -1; - var row = firstRow; - while (true) { - if (row > foldStart) { - row = fold.end.row + 1; - fold = session.getNextFoldLine(row, fold); - foldStart = fold ? fold.start.row : Infinity; + if (!isCollabGutter) + return clearGutterDecorations(); + var cells = gutter.$lines.cells; + for (var i = 0; i < cells.length; i++) { + var cell = cells[i]; + var authorKey = authorKeysCache[cell.row]; + var authorColor = "transparent"; + var fullname = null; + if (authorKey) { + var uid = reversedAuthorPool[authorKey]; + authorColor = util.formatColor(colorPool[uid]); + var user = workspace.users[uid]; + fullname = user && user.fullname; } - if (row > lastRow) { - while (this.$cells.length > index + 1) { - cell = this.$cells.pop(); - this.element.removeChild(cell.element); - } - break; - } - - cell = this.$cells[++index]; - if (!cell) { - cell = { element: null, textNode: null, foldWidget: null }; - cell.element = dom.createElement("div"); - cell.textNode = document.createTextNode(''); - cell.element.appendChild(cell.textNode); - this.element.appendChild(cell.element); - this.$cells[index] = cell; - } - - var className = "ace_gutter-cell "; - if (breakpoints[row]) - className += breakpoints[row]; - if (decorations[row]) - className += decorations[row]; - if (this.$annotations[row]) - className += this.$annotations[row].className; - if (cell.element.className != className) - cell.element.className = className; - - var height = session.getRowLength(row) * config.lineHeight + "px"; - if (height != cell.element.style.height) - cell.element.style.height = height; - - if (isCollabGutter) { - var authorKey = authorKeysCache[row]; - var authorColor = "transparent"; - var fullname = null; - if (authorKey) { - var uid = reversedAuthorPool[authorKey]; - authorColor = util.formatColor(colorPool[uid]); - var user = workspace.users[uid]; - fullname = user && user.fullname; - } - cell.element.style.borderLeft = "solid 5px " + authorColor; - cell.element.setAttribute("uid", fullname ? uid : ""); - } else { - cell.element.style.borderLeft = ""; - cell.element.setAttribute("uid", ""); - } - - if (foldWidgets) { - var c = foldWidgets[row]; - if (c == null) - c = foldWidgets[row] = session.getFoldWidget(row); - } - - if (c) { - if (!cell.foldWidget) { - cell.foldWidget = dom.createElement("span"); - cell.element.appendChild(cell.foldWidget); - } - var className = "ace_fold-widget ace_" + c; - if (c == "start" && row == foldStart && row < fold.end.row) - className += " ace_closed"; - else - className += " ace_open"; - if (cell.foldWidget.className != className) - cell.foldWidget.className = className; - - var height = config.lineHeight + "px"; - if (cell.foldWidget.style.height != height) - cell.foldWidget.style.height = height; - } else { - if (cell.foldWidget) { - cell.element.removeChild(cell.foldWidget); - cell.foldWidget = null; - } - } - - var text = lastLineNumber = gutterRenderer - ? gutterRenderer.getText(session, row) - : row + firstLineNumber; - if (text != cell.textNode.data) - cell.textNode.data = text; - - row++; + cell.element.style.borderLeft = "solid 5px " + authorColor; + cell.element.setAttribute("uid", fullname ? uid : ""); } - - this.element.style.height = config.minHeight + "px"; - - if (this.$fixedWidth || session.$useWrapMode) - lastLineNumber = session.getLength() + firstLineNumber; - - var gutterWidth = gutterRenderer - ? gutterRenderer.getWidth(session, lastLineNumber, config) - : lastLineNumber.toString().length * config.characterWidth; - - var padding = this.$padding || this.$computePadding(); - gutterWidth += padding.left + padding.right + (isCollabGutter ? 5 : 0); - if (gutterWidth !== this.gutterWidth && !isNaN(gutterWidth)) { - this.gutterWidth = gutterWidth; - this.element.style.width = Math.ceil(this.gutterWidth) + "px"; - this._emit("changeGutterWidth", gutterWidth); + } + + function clearGutterDecorations(renderer) { + renderer.$gutterLayer.$lines.cellCache.length = 0; + var cells = renderer.$gutterLayer.$lines.cells; + for (var i = 0; i < cells.length; i++) { + var cell = cells[i]; + cell.element.style.borderLeft = ""; + cell.element.setAttribute("uid", ""); } } @@ -13553,44 +13424,87 @@ var RangeList = function() { }; this.$onChange = function(delta) { - if (delta.action == "insert"){ - var start = delta.start; - var end = delta.end; - } else { - var end = delta.start; - var start = delta.end; - } + var start = delta.start; + var end = delta.end; var startRow = start.row; var endRow = end.row; - var lineDif = endRow - startRow; - - var colDiff = -start.column + end.column; var ranges = this.ranges; - for (var i = 0, n = ranges.length; i < n; i++) { var r = ranges[i]; - if (r.end.row < startRow) - continue; - if (r.start.row > startRow) + if (r.end.row >= startRow) break; - - if (r.start.row == startRow && r.start.column >= start.column ) { - if (r.start.column == start.column && this.$insertRight) { - } else { - r.start.column += colDiff; - r.start.row += lineDif; + } + + if (delta.action == "insert") { + var lineDif = endRow - startRow; + var colDiff = -start.column + end.column; + for (; i < n; i++) { + var r = ranges[i]; + if (r.start.row > startRow) + break; + + if (r.start.row == startRow && r.start.column >= start.column) { + if (r.start.column == start.column && this.$insertRight) { + } else { + r.start.column += colDiff; + r.start.row += lineDif; + } + } + if (r.end.row == startRow && r.end.column >= start.column) { + if (r.end.column == start.column && this.$insertRight) { + continue; + } + if (r.end.column == start.column && colDiff > 0 && i < n - 1) { + if (r.end.column > r.start.column && r.end.column == ranges[i+1].start.column) + r.end.column -= colDiff; + } + r.end.column += colDiff; + r.end.row += lineDif; } } - if (r.end.row == startRow && r.end.column >= start.column) { - if (r.end.column == start.column && this.$insertRight) { - continue; + } else { + var lineDif = startRow - endRow; + var colDiff = start.column - end.column; + for (; i < n; i++) { + var r = ranges[i]; + + if (r.start.row > endRow) + break; + + if (r.end.row < endRow) { + r.end.row = startRow; + r.end.column = start.column; } - if (r.end.column == start.column && colDiff > 0 && i < n - 1) { - if (r.end.column > r.start.column && r.end.column == ranges[i+1].start.column) - r.end.column -= colDiff; + + if (r.start.row < endRow || r.start.row == endRow && r.start.column <= end.colum) { + r.start.row = startRow; + r.start.column = start.column; + } + + if (r.end.row == endRow) { + if (r.end.column <= end.column) { + if (lineDif || r.end.column > start.column) { + r.end.column = start.column; + r.end.row = start.row; + } + } + else { + r.end.column += colDiff; + r.end.row += lineDif; + } + } + if (r.start.row == endRow) { + if (r.start.column <= end.column) { + if (lineDif || r.start.column > start.column) { + r.start.column = start.column; + r.start.row = start.row; + } + } + else { + r.start.column += colDiff; + r.start.row += lineDif; + } } - r.end.column += colDiff; - r.end.row += lineDif; } } @@ -13647,27 +13561,16 @@ define("plugins/c9.ide.collab/cursor_layer",[], function(require, module, export } function drawCursor(pos, html, markerLayer, session, config, bgColor) { - var cursorStyle = "background-color:" + util.formatColor(bgColor) + ";"; - var top = markerLayer.$getTop(pos.row, config); var left = Math.round(markerLayer.$padding + pos.column * config.characterWidth); - html.push( - "
", - "
" + + markerLayer.elt( + "ace_collab_cursor", + "height:" + config.lineHeight + "px;" + + "width:" + 2 + "px;" + + "top:" + top + "px;" + + "left:" + left + "px;" + + "background-color:" + util.formatColor(bgColor) + ";" ); } @@ -20457,8 +20360,6 @@ exports.DIFF_EQUAL = DIFF_EQUAL; define("ace/mouse/default_handlers",[], function(require, exports, module) { "use strict"; -var dom = require("../lib/dom"); -var event = require("../lib/event"); var useragent = require("../lib/useragent"); var DRAG_OFFSET = 0; // pixels @@ -21591,7 +21492,7 @@ var MouseHandler = function(editor) { config.defineOptions(MouseHandler.prototype, "mouseHandler", { scrollSpeed: {initialValue: 2}, - dragDelay: {initialValue: 150}, + dragDelay: {initialValue: (useragent.isMac ? 150 : 0)}, dragEnabled: {initialValue: true}, focusTimeout: {initialValue: 0}, tooltipFollowsMouse: {initialValue: true} @@ -22353,6 +22254,7 @@ var Selection = function(session) { this.$setSelection = function(anchorRow, anchorColumn, cursorRow, cursorColumn) { var wasEmpty = this.$isEmpty; + var wasMultiselect = this.inMultiSelectMode; this.$silent = true; this.$cursorChanged = this.$anchorChanged = false; this.anchor.setPosition(anchorRow, anchorColumn); @@ -22361,7 +22263,7 @@ var Selection = function(session) { this.$silent = false; if (this.$cursorChanged) this._emit("changeCursor"); - if (this.$cursorChanged || this.$anchorChanged) + if (this.$cursorChanged || this.$anchorChanged || wasEmpty != this.$isEmpty || wasMultiselect) this._emit("changeSelection"); }; @@ -27798,6 +27700,7 @@ EditSession.$uid = 0; return screenRows; }; this.$setFontMetrics = function(fm) { + if (!this.$enableVarChar) return; this.$getStringScreenWidth = function(str, maxScreenColumn, screenColumn) { if (maxScreenColumn === 0) return [0, 0]; @@ -27969,7 +27872,8 @@ config.defineOptions(EditSession.prototype, "session", { }, mode: { set: function(val) { this.setMode(val); }, - get: function() { return this.$modeId; } + get: function() { return this.$modeId; }, + handlesSet: true } }); @@ -29008,8 +28912,6 @@ module.exports = { lineMode: false }; define("ace/editor",[], function(require, exports, module) { "use strict"; -require("./lib/fixoldbrowsers"); - var oop = require("./lib/oop"); var dom = require("./lib/dom"); var lang = require("./lib/lang"); @@ -29653,11 +29555,11 @@ Editor.$uid = 0; this.$updateHighlightActiveLine(); this.renderer.updateFull(); }; - this.getSelectedText = function(newLineCharacter) { - return this.session.getTextRange(this.getSelectionRange(), newLineCharacter); + this.getSelectedText = function() { + return this.session.getTextRange(this.getSelectionRange()); }; this.getCopyText = function() { - var text = this.getSelectedText(useragent.isWin ? "\r\n" : "\n"); + var text = this.getSelectedText(); var nl = this.session.doc.getNewLineCharacter(); var copyLine= false; if (!text && this.$copyWithEmptySelection) { @@ -29723,10 +29625,6 @@ Editor.$uid = 0; this.execCommand = function(command, args) { return this.commands.exec(command, this, args); }; - - this.transformAction = function(type, text) { - - }; this.insert = function(text, pasted) { var session = this.session; var mode = session.getMode(); @@ -30846,6 +30744,26 @@ config.defineOptions(Editor.prototype, "editor", { handlesSet: true, hidden: true }, + + showLineNumbers: { + set: function(show) { + this.renderer.$gutterLayer.setShowLineNumbers(show); + this.renderer.$loop.schedule(this.renderer.CHANGE_GUTTER); + if (show && this.$relativeLineNumbers) + relativeNumberRenderer.attach(this); + else + relativeNumberRenderer.detach(this); + }, + initialValue: true + }, + relativeLineNumbers: { + set: function(value) { + if (this.$showLineNumbers && value) + relativeNumberRenderer.attach(this); + else + relativeNumberRenderer.detach(this); + } + }, hScrollBarAlwaysVisible: "renderer", vScrollBarAlwaysVisible: "renderer", @@ -30857,9 +30775,8 @@ config.defineOptions(Editor.prototype, "editor", { printMargin: "renderer", fadeFoldWidgets: "renderer", showFoldWidgets: "renderer", - showLineNumbers: "renderer", - showGutter: "renderer", displayIndentGuides: "renderer", + showGutter: "renderer", fontSize: "renderer", fontFamily: "renderer", maxLines: "renderer", @@ -30868,6 +30785,7 @@ config.defineOptions(Editor.prototype, "editor", { fixedWidthGutter: "renderer", theme: "renderer", hasCssTransforms: "renderer", + maxPixelHeight: "renderer", scrollSpeed: "$mouseHandler", dragDelay: "$mouseHandler", @@ -30888,9 +30806,162 @@ config.defineOptions(Editor.prototype, "editor", { mode: "session" }); + +var relativeNumberRenderer = { + getText: function(session, row) { + return (Math.abs(session.selection.lead.row - row) || (row + 1 + (row < 9 ? "\xb7" : ""))) + ""; + }, + getWidth: function(session, lastLineNumber, config) { + return Math.max( + lastLineNumber.toString().length, + (config.lastRow + 1).toString().length, + 2 + ) * config.characterWidth; + }, + update: function(e, editor) { + editor.renderer.$loop.schedule(editor.renderer.CHANGE_GUTTER); + }, + attach: function(editor) { + editor.renderer.$gutterLayer.$renderer = this; + editor.on("changeSelection", this.update); + this.update(null, editor); + }, + detach: function(editor) { + if (editor.renderer.$gutterLayer.$renderer == this) + editor.renderer.$gutterLayer.$renderer = null; + editor.off("changeSelection", this.update); + this.update(null, editor); + } +}; + exports.Editor = Editor; }); +define("ace/layer/lines",[], function(require, exports, module) { +"use strict"; + +var dom = require("../lib/dom"); + +var Lines = function(element, canvasHeight) { + this.element = element; + this.canvasHeight = canvasHeight || 500000; + this.element.style.height = (this.canvasHeight * 2) + "px"; + + this.cells = []; + this.cellCache = []; +}; + +(function() { + + this.moveContainer = function(config) { + dom.translate(this.element, 0, -((config.firstRowScreen * config.lineHeight) % this.canvasHeight)); + }; + + this.pageChanged = function(oldConfig, newConfig) { + return ( + Math.floor((oldConfig.firstRowScreen * oldConfig.lineHeight) / this.canvasHeight) !== + Math.floor((newConfig.firstRowScreen * newConfig.lineHeight) / this.canvasHeight) + ); + }; + + this.computeLineTop = function(row, config, session) { + var screenTop = config.firstRowScreen * config.lineHeight; + var screenPage = Math.floor(screenTop / this.canvasHeight); + var lineTop = session.documentToScreenRow(row, 0) * config.lineHeight; + return lineTop - (screenPage * this.canvasHeight); + }; + + this.computeLineHeight = function(row, config, session) { + return config.lineHeight * session.getRowLength(row); + }; + + this.getLength = function() { + return this.cells.length; + }; + + this.get = function(index) { + return this.cells[index]; + }; + + this.shift = function() { + this.$cacheCell(this.cells.shift()); + }; + + this.pop = function() { + this.$cacheCell(this.cells.pop()); + }; + + this.push = function(cell) { + if (Array.isArray(cell)) { + this.cells.push.apply(this.cells, cell); + var fragment = dom.createFragment(this.element); + for (var i=0; i foldStart) { row = fold.end.row + 1; @@ -31002,95 +31079,243 @@ var Gutter = function(parentEl) { foldStart = fold ? fold.start.row : Infinity; } if (row > lastRow) { - while (this.$cells.length > index + 1) { - cell = this.$cells.pop(); - this.element.removeChild(cell.element); - } + while (this.$lines.getLength() > index + 1) + this.$lines.pop(); + break; } - cell = this.$cells[++index]; + cell = this.$lines.get(++index); if (!cell) { - cell = {element: null, textNode: null, foldWidget: null}; - cell.element = dom.createElement("div"); - cell.textNode = document.createTextNode(''); - cell.element.appendChild(cell.textNode); - this.element.appendChild(cell.element); - this.$cells[index] = cell; + cell = this.$lines.createCell(row, config, this.session, onCreateCell); + this.$lines.push(cell); } - var className = "ace_gutter-cell "; - if (breakpoints[row]) - className += breakpoints[row]; - if (decorations[row]) - className += decorations[row]; - if (this.$annotations[row]) - className += this.$annotations[row].className; - if (cell.element.className != className) - cell.element.className = className; - - var height = session.getRowLength(row) * config.lineHeight + "px"; - if (height != cell.element.style.height) - cell.element.style.height = height; - - if (foldWidgets) { - var c = foldWidgets[row]; - if (c == null) - c = foldWidgets[row] = session.getFoldWidget(row); - } - - if (c) { - if (!cell.foldWidget) { - cell.foldWidget = dom.createElement("span"); - cell.element.appendChild(cell.foldWidget); - } - var className = "ace_fold-widget ace_" + c; - if (c == "start" && row == foldStart && row < fold.end.row) - className += " ace_closed"; - else - className += " ace_open"; - if (cell.foldWidget.className != className) - cell.foldWidget.className = className; - - var height = config.lineHeight + "px"; - if (cell.foldWidget.style.height != height) - cell.foldWidget.style.height = height; - } else { - if (cell.foldWidget) { - cell.element.removeChild(cell.foldWidget); - cell.foldWidget = null; - } - } - - var text = lastLineNumber = gutterRenderer - ? gutterRenderer.getText(session, row) - : row + firstLineNumber; - if (text !== cell.textNode.data) - cell.textNode.data = text; - + this.$renderCell(cell, config, fold, row); row++; } + + this._signal("afterRender"); + this.$updateGutterWidth(config); + }; - this.element.style.height = config.minHeight + "px"; - + this.$updateGutterWidth = function(config) { + var session = this.session; + + var gutterRenderer = session.gutterRenderer || this.$renderer; + + var firstLineNumber = session.$firstLineNumber; + var lastLineText = this.$lines.last() ? this.$lines.last().text : ""; + if (this.$fixedWidth || session.$useWrapMode) - lastLineNumber = session.getLength() + firstLineNumber; + lastLineText = session.getLength() + firstLineNumber; var gutterWidth = gutterRenderer - ? gutterRenderer.getWidth(session, lastLineNumber, config) - : lastLineNumber.toString().length * config.characterWidth; + ? gutterRenderer.getWidth(session, lastLineText, config) + : lastLineText.toString().length * config.characterWidth; var padding = this.$padding || this.$computePadding(); gutterWidth += padding.left + padding.right; if (gutterWidth !== this.gutterWidth && !isNaN(gutterWidth)) { this.gutterWidth = gutterWidth; + this.element.parentNode.style.width = this.element.style.width = Math.ceil(this.gutterWidth) + "px"; - this._emit("changeGutterWidth", gutterWidth); + this._signal("changeGutterWidth", gutterWidth); } }; + + this.$updateCursorRow = function() { + if (!this.$highlightGutterLine) + return; + + var position = this.session.selection.getCursor(); + if (this.$cursorRow === position.row) + return; + + this.$cursorRow = position.row; + }; + + this.updateLineHighlight = function() { + if (!this.$highlightGutterLine) + return; + var row = this.session.selection.cursor.row; + this.$cursorRow = row; + + if (this.$cursorCell && this.$cursorCell.row == row) + return; + if (this.$cursorCell) + this.$cursorCell.element.className = this.$cursorCell.element.className.replace("ace_gutter-active-line ", ""); + var cells = this.$lines.cells; + this.$cursorCell = null; + for (var i = 0; i < cells.length; i++) { + var cell = cells[i]; + if (cell.row >= this.$cursorRow) { + if (cell.row > this.$cursorRow) { + var fold = this.session.getFoldLine(this.$cursorRow); + if (i > 0 && fold && fold.start.row == cells[i - 1].row) + cell = cells[i - 1]; + else + break; + } + cell.element.className = "ace_gutter-active-line " + cell.element.className; + this.$cursorCell = cell; + break; + } + } + }; + + this.scrollLines = function(config) { + var oldConfig = this.config; + this.config = config; + + this.$updateCursorRow(); + if (this.$lines.pageChanged(oldConfig, config)) + return this.update(config); + + this.$lines.moveContainer(config); + + var lastRow = Math.min(config.lastRow + config.gutterOffset, // needed to compensate for hor scollbar + this.session.getLength() - 1); + var oldLastRow = this.oldLastRow; + this.oldLastRow = lastRow; + + if (!oldConfig || oldLastRow < config.firstRow) + return this.update(config); + + if (lastRow < oldConfig.firstRow) + return this.update(config); + + if (oldConfig.firstRow < config.firstRow) + for (var row=this.session.getFoldedRowCount(oldConfig.firstRow, config.firstRow - 1); row>0; row--) + this.$lines.shift(); + + if (oldLastRow > lastRow) + for (var row=this.session.getFoldedRowCount(lastRow + 1, oldLastRow); row>0; row--) + this.$lines.pop(); + + if (config.firstRow < oldConfig.firstRow) { + this.$lines.unshift(this.$renderLines(config, config.firstRow, oldConfig.firstRow - 1)); + } + + if (lastRow > oldLastRow) { + this.$lines.push(this.$renderLines(config, oldLastRow + 1, lastRow)); + } + + this.updateLineHighlight(); + + this._signal("afterRender"); + this.$updateGutterWidth(config); + }; + + this.$renderLines = function(config, firstRow, lastRow) { + var fragment = []; + var row = firstRow; + var foldLine = this.session.getNextFoldLine(row); + var foldStart = foldLine ? foldLine.start.row : Infinity; + + while (true) { + if (row > foldStart) { + row = foldLine.end.row+1; + foldLine = this.session.getNextFoldLine(row, foldLine); + foldStart = foldLine ? foldLine.start.row : Infinity; + } + if (row > lastRow) + break; + + var cell = this.$lines.createCell(row, config, this.session, onCreateCell); + this.$renderCell(cell, config, foldLine, row); + fragment.push(cell); + + row++; + } + return fragment; + }; + + this.$renderCell = function(cell, config, fold, row) { + var element = cell.element; + + var session = this.session; + + var textNode = element.childNodes[0]; + var foldWidget = element.childNodes[1]; + + var firstLineNumber = session.$firstLineNumber; + + var breakpoints = session.$breakpoints; + var decorations = session.$decorations; + var gutterRenderer = session.gutterRenderer || this.$renderer; + var foldWidgets = this.$showFoldWidgets && session.foldWidgets; + var foldStart = fold ? fold.start.row : Number.MAX_VALUE; + + var className = "ace_gutter-cell "; + if (this.$highlightGutterLine) { + if (row == this.$cursorRow || (fold && row < this.$cursorRow && row >= foldStart && this.$cursorRow <= fold.end.row)) { + className += "ace_gutter-active-line "; + if (this.$cursorCell != cell) { + if (this.$cursorCell) + this.$cursorCell.element.className = this.$cursorCell.element.className.replace("ace_gutter-active-line ", ""); + this.$cursorCell = cell; + } + } + } + + if (breakpoints[row]) + className += breakpoints[row]; + if (decorations[row]) + className += decorations[row]; + if (this.$annotations[row]) + className += this.$annotations[row].className; + if (element.className != className) + element.className = className; + + if (foldWidgets) { + var c = foldWidgets[row]; + if (c == null) + c = foldWidgets[row] = session.getFoldWidget(row); + } + + if (c) { + var className = "ace_fold-widget ace_" + c; + if (c == "start" && row == foldStart && row < fold.end.row) + className += " ace_closed"; + else + className += " ace_open"; + if (foldWidget.className != className) + foldWidget.className = className; + + var foldHeight = config.lineHeight + "px"; + dom.setStyle(foldWidget.style, "height", foldHeight); + dom.setStyle(foldWidget.style, "display", "inline-block"); + } else { + if (foldWidget) { + dom.setStyle(foldWidget.style, "display", "none"); + } + } + + var text = (gutterRenderer + ? gutterRenderer.getText(session, row) + : row + firstLineNumber).toString(); + + if (text !== textNode.data) { + textNode.data = text; + } + + dom.setStyle(cell.element.style, "height", this.$lines.computeLineHeight(row, config, session) + "px"); + dom.setStyle(cell.element.style, "top", this.$lines.computeLineTop(row, config, session) + "px"); + + cell.text = text; + cell.row = row; + return cell; + }; this.$fixedWidth = false; + this.$highlightGutterLine = true; + this.$renderer = ""; + this.setHighlightGutterLine = function(highlightGutterLine) { + this.$highlightGutterLine = highlightGutterLine; + }; + this.$showLineNumbers = true; this.$renderer = ""; this.setShowLineNumbers = function(show) { @@ -31124,8 +31349,10 @@ var Gutter = function(parentEl) { return {left: 0, right: 0}; var style = dom.computedStyle(this.element.firstChild); this.$padding = {}; - this.$padding.left = parseInt(style.paddingLeft) + 1 || 0; - this.$padding.right = parseInt(style.paddingRight) || 0; + this.$padding.left = (parseInt(style.borderLeftWidth) || 0) + + (parseInt(style.paddingLeft) || 0) + 1; + this.$padding.right = (parseInt(style.borderRightWidth) || 0) + + (parseInt(style.paddingRight) || 0); return this.$padding; }; @@ -31140,6 +31367,16 @@ var Gutter = function(parentEl) { }).call(Gutter.prototype); +function onCreateCell(element) { + var textNode = document.createTextNode(''); + element.appendChild(textNode); + + var foldWidget = dom.createElement("span"); + element.appendChild(foldWidget); + + return element; +} + exports.Gutter = Gutter; }); @@ -31170,14 +31407,27 @@ var Marker = function(parentEl) { this.setMarkers = function(markers) { this.markers = markers; }; + + this.elt = function(className, css) { + var x = this.i != -1 && this.element.childNodes[this.i]; + if (!x) { + x = document.createElement("div"); + this.element.appendChild(x); + this.i = -1; + } else { + this.i++; + } + x.style.cssText = css; + x.className = className; + }; this.update = function(config) { if (!config) return; this.config = config; - - var html = []; + this.i = 0; + var html; for (var key in this.markers) { var marker = this.markers[key]; @@ -31192,9 +31442,7 @@ var Marker = function(parentEl) { range = range.toScreenRange(this.session); if (marker.renderer) { var top = this.$getTop(range.start.row, config); - var left = this.$padding + (this.session.$bidiHandler.isBidiRow(range.start.row) - ? this.session.$bidiHandler.getPosLeft(range.start.column) - : range.start.column * config.characterWidth); + var left = this.$padding + range.start.column * config.characterWidth; marker.renderer(html, range, left, top, config); } else if (marker.type == "fullLine") { this.drawFullLineMarker(html, range, marker.clazz, config); @@ -31206,14 +31454,13 @@ var Marker = function(parentEl) { else this.drawMultiLineMarker(html, range, marker.clazz, config); } else { - if (this.session.$bidiHandler.isBidiRow(range.start.row)) { - this.drawBidiSingleLineMarker(html, range, marker.clazz + " ace_start" + " ace_br15", config); - } else { - this.drawSingleLineMarker(html, range, marker.clazz + " ace_start" + " ace_br15", config); - } + this.drawSingleLineMarker(html, range, marker.clazz + " ace_start" + " ace_br15", config); } } - this.element.innerHTML = html.join(""); + if (this.i !=-1) { + while (this.i < this.element.childElementCount) + this.element.removeChild(this.element.lastChild); + } }; this.$getTop = function(row, layerConfig) { @@ -31231,7 +31478,6 @@ var Marker = function(parentEl) { var prev = 0; var curr = 0; var next = session.getScreenLastRowColumn(row); - var clazzModified = null; var lineRange = new Range(row, range.start.column, row, curr); for (; row <= end; row++) { lineRange.start.row = lineRange.end.row = row; @@ -31240,56 +31486,33 @@ var Marker = function(parentEl) { prev = curr; curr = next; next = row + 1 < end ? session.getScreenLastRowColumn(row + 1) : row == end ? 0 : range.end.column; - clazzModified = clazz + (row == start ? " ace_start" : "") + " ace_br" - + getBorderClass(row == start || row == start + 1 && range.start.column, prev < curr, curr > next, row == end); - - if (this.session.$bidiHandler.isBidiRow(row)) { - this.drawBidiSingleLineMarker(stringBuilder, lineRange, clazzModified, - layerConfig, row == end ? 0 : 1, extraStyle); - } else { - this.drawSingleLineMarker(stringBuilder, lineRange, clazzModified, - layerConfig, row == end ? 0 : 1, extraStyle); - } + this.drawSingleLineMarker(stringBuilder, lineRange, + clazz + (row == start ? " ace_start" : "") + " ace_br" + + getBorderClass(row == start || row == start + 1 && range.start.column, prev < curr, curr > next, row == end), + layerConfig, row == end ? 0 : 1, extraStyle); } }; this.drawMultiLineMarker = function(stringBuilder, range, clazz, config, extraStyle) { var padding = this.$padding; - var height, top, left; + var height = config.lineHeight; + var top = this.$getTop(range.start.row, config); + var left = padding + range.start.column * config.characterWidth; extraStyle = extraStyle || ""; - if (this.session.$bidiHandler.isBidiRow(range.start.row)) { - var range1 = range.clone(); - range1.end.row = range1.start.row; - range1.end.column = this.session.getLine(range1.start.row).length; - this.drawBidiSingleLineMarker(stringBuilder, range1, clazz + " ace_br1 ace_start", config, null, extraStyle); - } else { - height = config.lineHeight; - top = this.$getTop(range.start.row, config); - left = padding + range.start.column * config.characterWidth; - stringBuilder.push( - "
" - ); - } - if (this.session.$bidiHandler.isBidiRow(range.end.row)) { - var range1 = range.clone(); - range1.start.row = range1.end.row; - range1.start.column = 0; - this.drawBidiSingleLineMarker(stringBuilder, range1, clazz + " ace_br12", config, null, extraStyle); - } else { - var width = range.end.column * config.characterWidth; - height = config.lineHeight; - top = this.$getTop(range.end.row, config); - stringBuilder.push( - "
" - ); - } + + this.elt( + clazz + " ace_br1 ace_start", + "height:"+ height+ "px;"+ "right:0;"+ "top:"+top+ "px;left:"+ left+ "px;" + (extraStyle || "") + ); + top = this.$getTop(range.end.row, config); + var width = range.end.column * config.characterWidth; + + this.elt( + clazz + " ace_br12", + "height:"+ height+ "px;"+ + "width:"+ width+ "px;"+ + "top:"+ top+ "px;"+ + "left:"+ padding+ "px;"+ (extraStyle || "") + ); height = (range.end.row - range.start.row - 1) * config.lineHeight; if (height <= 0) return; @@ -31297,12 +31520,12 @@ var Marker = function(parentEl) { var radiusClass = (range.start.column ? 1 : 0) | (range.end.column ? 0 : 8); - stringBuilder.push( - "
" + this.elt( + clazz + (radiusClass ? " ace_br" + radiusClass : ""), + "height:"+ height+ "px;"+ + "right:0;"+ + "top:"+ top+ "px;"+ + "left:"+ padding+ "px;"+ (extraStyle || "") ); }; this.drawSingleLineMarker = function(stringBuilder, range, clazz, config, extraLength, extraStyle) { @@ -31312,28 +31535,14 @@ var Marker = function(parentEl) { var top = this.$getTop(range.start.row, config); var left = this.$padding + range.start.column * config.characterWidth; - stringBuilder.push( - "
" + this.elt( + clazz, + "height:"+ height+ "px;"+ + "width:"+ width+ "px;"+ + "top:"+ top+ "px;"+ + "left:"+ left+ "px;"+ (extraStyle || "") ); }; - this.drawBidiSingleLineMarker = function(stringBuilder, range, clazz, config, extraLength, extraStyle) { - var height = config.lineHeight, top = this.$getTop(range.start.row, config), padding = this.$padding; - var selections = this.session.$bidiHandler.getSelections(range.start.column, range.end.column); - - selections.forEach(function(selection) { - stringBuilder.push( - "
" - ); - }); - }; this.drawFullLineMarker = function(stringBuilder, range, clazz, config, extraStyle) { var top = this.$getTop(range.start.row, config); @@ -31341,11 +31550,11 @@ var Marker = function(parentEl) { if (range.start.row != range.end.row) height += this.$getTop(range.end.row, config) - top; - stringBuilder.push( - "
" + this.elt( + clazz, + "height:"+ height+ "px;"+ + "top:"+ top+ "px;"+ + "left:0;right:0;"+ (extraStyle || "") ); }; @@ -31353,11 +31562,11 @@ var Marker = function(parentEl) { var top = this.$getTop(range.start.row, config); var height = config.lineHeight; - stringBuilder.push( - "
" + this.elt( + clazz, + "height:"+ height+ "px;"+ + "top:"+ top+ "px;"+ + "left:0;right:0;"+ (extraStyle || "") ); }; @@ -31373,14 +31582,16 @@ define("ace/layer/text",[], function(require, exports, module) { var oop = require("../lib/oop"); var dom = require("../lib/dom"); var lang = require("../lib/lang"); -var useragent = require("../lib/useragent"); +var Lines = require("./lines").Lines; var EventEmitter = require("../lib/event_emitter").EventEmitter; var Text = function(parentEl) { - this.element = dom.createElement("div"); + this.dom = dom; + this.element = this.dom.createElement("div"); this.element.className = "ace_layer ace_text-layer"; parentEl.appendChild(this.element); this.$updateEolChar = this.$updateEolChar.bind(this); + this.$lines = new Lines(this.element); }; (function() { @@ -31408,7 +31619,7 @@ var Text = function(parentEl) { this.setPadding = function(padding) { this.$padding = padding; - this.element.style.padding = "0 " + padding + "px"; + this.element.style.margin = "0 " + padding + "px"; }; this.getLineHeight = function() { @@ -31467,11 +31678,12 @@ var Text = function(parentEl) { var tabStr = this.$tabStrings = [0]; for (var i = 1; i < tabSize + 1; i++) { if (this.showInvisibles) { - tabStr.push("" - + lang.stringRepeat(this.TAB_CHAR, i) - + ""); + var span = this.dom.createElement("span"); + span.className = "ace_invisible ace_invisible_tab"; + span.textContent = lang.stringRepeat(this.TAB_CHAR, i); + tabStr.push(span); } else { - tabStr.push(lang.stringRepeat(" ", i)); + tabStr.push(this.dom.createTextNode(lang.stringRepeat(" ", i), this.element)); } } if (this.displayIndentGuides) { @@ -31485,21 +31697,29 @@ var Text = function(parentEl) { tabClass = " ace_invisible_tab"; var spaceContent = lang.stringRepeat(this.SPACE_CHAR, this.tabSize); var tabContent = lang.stringRepeat(this.TAB_CHAR, this.tabSize); - } else{ + } else { var spaceContent = lang.stringRepeat(" ", this.tabSize); var tabContent = spaceContent; } - this.$tabStrings[" "] = "" + spaceContent + ""; - this.$tabStrings["\t"] = "" + tabContent + ""; + var span = this.dom.createElement("span"); + span.className = className + spaceClass; + span.textContent = spaceContent; + this.$tabStrings[" "] = span; + + var span = this.dom.createElement("span"); + span.className = className + tabClass; + span.textContent = tabContent; + this.$tabStrings["\t"] = span; } }; this.updateLines = function(config, firstRow, lastRow) { if (this.config.lastRow != config.lastRow || this.config.firstRow != config.firstRow) { - this.scrollLines(config); + return this.update(config); } + this.config = config; var first = Math.max(firstRow, config.firstRow); @@ -31521,6 +31741,7 @@ var Text = function(parentEl) { lineElementsIdx ++; } + var heightChanged = false; var row = first; var foldLine = this.session.getNextFoldLine(row); var foldStart = foldLine ? foldLine.start.row : Infinity; @@ -31536,52 +31757,69 @@ var Text = function(parentEl) { var lineElement = lineElements[lineElementsIdx++]; if (lineElement) { - var html = []; + this.dom.removeChildren(lineElement); this.$renderLine( - html, row, !this.$useLineGroups(), row == foldStart ? foldLine : false + lineElement, row, row == foldStart ? foldLine : false ); - lineElement.style.height = config.lineHeight * this.session.getRowLength(row) + "px"; - lineElement.innerHTML = html.join(""); + var height = (config.lineHeight * this.session.getRowLength(row)) + "px"; + if (lineElement.style.height != height) { + heightChanged = true; + lineElement.style.height = height; + } } row++; } + if (heightChanged) { + while (lineElementsIdx < this.$lines.cells.length) { + var cell = this.$lines.cells[lineElementsIdx++]; + cell.element.style.top = this.$lines.computeLineTop(cell.row, config, this.session) + "px"; + } + } }; this.scrollLines = function(config) { var oldConfig = this.config; this.config = config; + if (this.$lines.pageChanged(oldConfig, config)) + return this.update(config); + + this.$lines.moveContainer(config); + + var lastRow = config.lastRow; + var oldLastRow = oldConfig ? oldConfig.lastRow : -1; + + if (!oldConfig || oldLastRow < config.firstRow) + return this.update(config); + + if (lastRow < oldConfig.firstRow) + return this.update(config); + if (!oldConfig || oldConfig.lastRow < config.firstRow) return this.update(config); if (config.lastRow < oldConfig.firstRow) return this.update(config); - var el = this.element; if (oldConfig.firstRow < config.firstRow) for (var row=this.session.getFoldedRowCount(oldConfig.firstRow, config.firstRow - 1); row>0; row--) - el.removeChild(el.firstChild); + this.$lines.shift(); if (oldConfig.lastRow > config.lastRow) for (var row=this.session.getFoldedRowCount(config.lastRow + 1, oldConfig.lastRow); row>0; row--) - el.removeChild(el.lastChild); + this.$lines.pop(); if (config.firstRow < oldConfig.firstRow) { - var fragment = this.$renderLinesFragment(config, config.firstRow, oldConfig.firstRow - 1); - if (el.firstChild) - el.insertBefore(fragment, el.firstChild); - else - el.appendChild(fragment); + this.$lines.unshift(this.$renderLinesFragment(config, config.firstRow, oldConfig.firstRow - 1)); } if (config.lastRow > oldConfig.lastRow) { - var fragment = this.$renderLinesFragment(config, oldConfig.lastRow + 1, config.lastRow); - el.appendChild(fragment); + this.$lines.push(this.$renderLinesFragment(config, oldConfig.lastRow + 1, config.lastRow)); } }; this.$renderLinesFragment = function(config, firstRow, lastRow) { - var fragment = this.element.ownerDocument.createDocumentFragment(); + var fragment = []; var row = firstRow; var foldLine = this.session.getNextFoldLine(row); var foldStart = foldLine ? foldLine.start.row : Infinity; @@ -31595,21 +31833,20 @@ var Text = function(parentEl) { if (row > lastRow) break; - var container = dom.createElement("div"); + var line = this.$lines.createCell(row, config, this.session); + + var lineEl = line.element; + this.dom.removeChildren(lineEl); + dom.setStyle(lineEl.style, "height", this.$lines.computeLineHeight(row, config, this.session) + "px"); + dom.setStyle(lineEl.style, "top", this.$lines.computeLineTop(row, config, this.session) + "px"); + this.$renderLine(lineEl, row, row == foldStart ? foldLine : false); - var html = []; - this.$renderLine(html, row, false, row == foldStart ? foldLine : false); - - container.innerHTML = html.join(""); if (this.$useLineGroups()) { - container.className = 'ace_line_group'; - fragment.appendChild(container); - container.style.height = config.lineHeight * this.session.getRowLength(row) + "px"; - + lineEl.className = "ace_line_group"; } else { - while(container.firstChild) - fragment.appendChild(container.firstChild); + lineEl.className = "ace_line"; } + fragment.push(line); row++; } @@ -31617,35 +31854,18 @@ var Text = function(parentEl) { }; this.update = function(config) { + this.$lines.moveContainer(config); + this.config = config; - var html = []; - var firstRow = config.firstRow, lastRow = config.lastRow; + var firstRow = config.firstRow; + var lastRow = config.lastRow; - var row = firstRow; - var foldLine = this.session.getNextFoldLine(row); - var foldStart = foldLine ? foldLine.start.row : Infinity; - - while (true) { - if (row > foldStart) { - row = foldLine.end.row+1; - foldLine = this.session.getNextFoldLine(row, foldLine); - foldStart = foldLine ? foldLine.start.row :Infinity; - } - if (row > lastRow) - break; - - if (this.$useLineGroups()) - html.push("
"); - - this.$renderLine(html, row, false, row == foldStart ? foldLine : false); - - if (this.$useLineGroups()) - html.push("
"); // end the line group - - row++; - } - this.element.innerHTML = html.join(""); + var lines = this.$lines; + while (lines.getLength()) + lines.pop(); + + lines.push(this.$renderLinesFragment(config, firstRow, lastRow)); }; this.$textToken = { @@ -31654,108 +31874,153 @@ var Text = function(parentEl) { "lparen": true }; - this.$renderToken = function(stringBuilder, screenColumn, token, value) { + this.$renderToken = function(parent, screenColumn, token, value) { var self = this; - var replaceReg = /\t|&|<|>|( +)|([\x00-\x1f\x80-\xa0\xad\u1680\u180E\u2000-\u200f\u2028\u2029\u202F\u205F\u3000\uFEFF\uFFF9-\uFFFC])|[\u1100-\u115F\u11A3-\u11A7\u11FA-\u11FF\u2329-\u232A\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u2FFB\u3000-\u303E\u3041-\u3096\u3099-\u30FF\u3105-\u312D\u3131-\u318E\u3190-\u31BA\u31C0-\u31E3\u31F0-\u321E\u3220-\u3247\u3250-\u32FE\u3300-\u4DBF\u4E00-\uA48C\uA490-\uA4C6\uA960-\uA97C\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFAFF\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE66\uFE68-\uFE6B\uFF01-\uFF60\uFFE0-\uFFE6]|[\uD800-\uDBFF][\uDC00-\uDFFF]/g; - var replaceFunc = function(c, a, b, tabIdx, idx4) { - if (a) { - return self.showInvisibles - ? "" + lang.stringRepeat(self.SPACE_CHAR, c.length) + "" - : c; - } else if (c == "&") { - return "&"; - } else if (c == "<") { - return "<"; - } else if (c == ">") { - return ">"; - } else if (c == "\t") { - var tabSize = self.session.getScreenTabSize(screenColumn + tabIdx); + var re = /(\t)|( +)|([\x00-\x1f\x80-\xa0\xad\u1680\u180E\u2000-\u200f\u2028\u2029\u202F\u205F\uFEFF\uFFF9-\uFFFC]+)|(\u3000)|([\u1100-\u115F\u11A3-\u11A7\u11FA-\u11FF\u2329-\u232A\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u2FFB\u3001-\u303E\u3041-\u3096\u3099-\u30FF\u3105-\u312D\u3131-\u318E\u3190-\u31BA\u31C0-\u31E3\u31F0-\u321E\u3220-\u3247\u3250-\u32FE\u3300-\u4DBF\u4E00-\uA48C\uA490-\uA4C6\uA960-\uA97C\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFAFF\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE66\uFE68-\uFE6B\uFF01-\uFF60\uFFE0-\uFFE6]|[\uD800-\uDBFF][\uDC00-\uDFFF])/g; + + var valueFragment = this.dom.createFragment(this.element); + + var m; + var i = 0; + while (m = re.exec(value)) { + var tab = m[1]; + var simpleSpace = m[2]; + var controlCharacter = m[3]; + var cjkSpace = m[4]; + var cjk = m[5]; + + if (!self.showInvisibles && simpleSpace) + continue; + + var before = i != m.index ? value.slice(i, m.index) : ""; + + i = m.index + m[0].length; + + if (before) { + valueFragment.appendChild(this.dom.createTextNode(before, this.element)); + } + + if (tab) { + var tabSize = self.session.getScreenTabSize(screenColumn + m.index); + valueFragment.appendChild(self.$tabStrings[tabSize].cloneNode(true)); screenColumn += tabSize - 1; - return self.$tabStrings[tabSize]; - } else if (c == "\u3000") { - var classToUse = self.showInvisibles ? "ace_cjk ace_invisible ace_invisible_space" : "ace_cjk"; + } else if (simpleSpace) { + if (self.showInvisibles) { + var span = this.dom.createElement("span"); + span.className = "ace_invisible ace_invisible_space"; + span.textContent = lang.stringRepeat(self.SPACE_CHAR, simpleSpace.length); + valueFragment.appendChild(span); + } else { + valueFragment.appendChild(this.com.createTextNode(simpleSpace, this.element)); + } + } else if (controlCharacter) { + var span = this.dom.createElement("span"); + span.className = "ace_invisible ace_invisible_space ace_invalid"; + span.textContent = lang.stringRepeat(self.SPACE_CHAR, controlCharacter.length); + valueFragment.appendChild(span); + } else if (cjkSpace) { var space = self.showInvisibles ? self.SPACE_CHAR : ""; screenColumn += 1; - return "" + space + ""; - } else if (b) { - return "" + self.SPACE_CHAR + ""; - } else { + + var span = this.dom.createElement("span"); + span.style.width = (self.config.characterWidth * 2) + "px"; + span.className = self.showInvisibles ? "ace_cjk ace_invisible ace_invisible_space" : "ace_cjk"; + span.textContent = self.showInvisibles ? self.SPACE_CHAR : ""; + valueFragment.appendChild(span); + } else if (cjk) { screenColumn += 1; - return "" + c + ""; + var span = dom.createElement("span"); + span.style.width = (self.config.characterWidth * 2) + "px"; + span.className = "ace_cjk"; + span.textContent = cjk; + valueFragment.appendChild(span); } - }; - - var output = value.replace(replaceReg, replaceFunc); + } + + valueFragment.appendChild(this.dom.createTextNode(i ? value.slice(i) : value, this.element)); if (!this.$textToken[token.type]) { var classes = "ace_" + token.type.replace(/\./g, " ace_"); - var style = ""; + var span = this.dom.createElement("span"); if (token.type == "fold") - style = " style='width:" + (token.value.length * this.config.characterWidth) + "px;' "; - stringBuilder.push("", output, ""); + span.style.width = (token.value.length * this.config.characterWidth) + "px"; + + span.className = classes; + span.appendChild(valueFragment); + + parent.appendChild(span); } else { - stringBuilder.push(output); + parent.appendChild(valueFragment); } + return screenColumn + value.length; }; - this.renderIndentGuide = function(stringBuilder, value, max) { + this.renderIndentGuide = function(parent, value, max) { var cols = value.search(this.$indentGuideRe); if (cols <= 0 || cols >= max) return value; if (value[0] == " ") { cols -= cols % this.tabSize; - stringBuilder.push(lang.stringRepeat(this.$tabStrings[" "], cols/this.tabSize)); + var count = cols/this.tabSize; + for (var i=0; i= splitChars) { screenColumn = this.$renderToken( - stringBuilder, screenColumn, + lineEl, screenColumn, token, value.substring(0, splitChars - chars) ); value = value.substring(splitChars - chars); chars = splitChars; - if (!onlyContents) { - stringBuilder.push("", - "
" - ); - } + lineEl = this.$createLineElement(); + parent.appendChild(lineEl); - stringBuilder.push(lang.stringRepeat("\xa0", splits.indent)); + lineEl.appendChild(this.dom.createTextNode(lang.stringRepeat("\xa0", splits.indent), this.element)); split ++; screenColumn = 0; @@ -31764,38 +32029,43 @@ var Text = function(parentEl) { if (value.length != 0) { chars += value.length; screenColumn = this.$renderToken( - stringBuilder, screenColumn, token, value + lineEl, screenColumn, token, value ); } } } }; - this.$renderSimpleLine = function(stringBuilder, tokens) { + this.$renderSimpleLine = function(parent, tokens) { var screenColumn = 0; var token = tokens[0]; var value = token.value; if (this.displayIndentGuides) - value = this.renderIndentGuide(stringBuilder, value); + value = this.renderIndentGuide(parent, value); if (value) - screenColumn = this.$renderToken(stringBuilder, screenColumn, token, value); + screenColumn = this.$renderToken(parent, screenColumn, token, value); for (var i = 1; i < tokens.length; i++) { token = tokens[i]; value = token.value; if (screenColumn + value.length > this.MAX_LINE_LENGTH) - return this.$renderOverflowMessage(stringBuilder, screenColumn, token, value); - screenColumn = this.$renderToken(stringBuilder, screenColumn, token, value); + return this.$renderOverflowMessage(parent, screenColumn, token, value); + screenColumn = this.$renderToken(parent, screenColumn, token, value); } }; - this.$renderOverflowMessage = function(stringBuilder, screenColumn, token, value) { - this.$renderToken(stringBuilder, screenColumn, token, + this.$renderOverflowMessage = function(parent, screenColumn, token, value) { + this.$renderToken(parent, screenColumn, token, value.slice(0, this.MAX_LINE_LENGTH - screenColumn)); - stringBuilder.push( - "<click to see more...>" - ); + + var overflowEl = this.dom.createElement("span"); + overflowEl.className = "ace_inline_button ace_keyword ace_toggle_wrap"; + overflowEl.style.position = "absolute"; + overflowEl.style.right = "0"; + overflowEl.textContent = ""; + + parent.appendChild(overflowEl); }; - this.$renderLine = function(stringBuilder, row, onlyContents, foldLine) { + this.$renderLine = function(parent, row, foldLine) { if (!foldLine && foldLine != false) foldLine = this.session.getFoldLine(row); @@ -31804,36 +32074,35 @@ var Text = function(parentEl) { else var tokens = this.session.getTokens(row); - - if (!onlyContents) { - stringBuilder.push( - "
" - ); - } - + var lastLineEl = parent; if (tokens.length) { var splits = this.session.getRowSplitData(row); - if (splits && splits.length) - this.$renderWrappedLine(stringBuilder, tokens, splits, onlyContents); - else - this.$renderSimpleLine(stringBuilder, tokens); + if (splits && splits.length) { + this.$renderWrappedLine(parent, tokens, splits); + var lastLineEl = parent.lastChild; + } else { + var lastLineEl = parent; + if (this.$useLineGroups()) { + lastLineEl = this.$createLineElement(); + parent.appendChild(lastLineEl); + } + this.$renderSimpleLine(lastLineEl, tokens); + } + } else if (this.$useLineGroups()) { + lastLineEl = this.$createLineElement(); + parent.appendChild(lastLineEl); } - if (this.showInvisibles) { + if (this.showInvisibles && lastLineEl) { if (foldLine) row = foldLine.end.row; - stringBuilder.push( - "", - row == this.session.getLength() - 1 ? this.EOF_CHAR : this.EOL_CHAR, - "" - ); + var invisibleEl = this.dom.createElement("span"); + invisibleEl.className = "ace_invisible ace_invisible_eol"; + invisibleEl.textContent = row == this.session.getLength() - 1 ? this.EOF_CHAR : this.EOL_CHAR; + + lastLineEl.appendChild(invisibleEl); } - if (!onlyContents) - stringBuilder.push("
"); }; this.$getFoldLineTokens = function(row, foldLine) { @@ -31917,16 +32186,12 @@ define("ace/layer/cursor",[], function(require, exports, module) { "use strict"; var dom = require("../lib/dom"); -var isIE8; var Cursor = function(parentEl) { this.element = dom.createElement("div"); this.element.className = "ace_layer ace_cursor-layer"; parentEl.appendChild(this.element); - if (isIE8 === undefined) - isIE8 = !("opacity" in this.element.style); - this.isVisible = false; this.isBlinking = true; this.blinkInterval = 1000; @@ -31935,24 +32200,30 @@ var Cursor = function(parentEl) { this.cursors = []; this.cursor = this.addCursor(); dom.addCssClass(this.element, "ace_hidden-cursors"); - this.$updateCursors = (isIE8 - ? this.$updateVisibility - : this.$updateOpacity).bind(this); + this.$updateCursors = this.$updateOpacity.bind(this); }; (function() { - this.$updateVisibility = function(val) { - var cursors = this.cursors; - for (var i = cursors.length; i--; ) - cursors[i].style.visibility = val ? "" : "hidden"; - }; this.$updateOpacity = function(val) { var cursors = this.cursors; for (var i = cursors.length; i--; ) - cursors[i].style.opacity = val ? "" : "0"; + dom.setStyle(cursors[i].style, "opacity", val ? "" : "0"); + }; + + this.$startCssAnimation = function() { + var cursors = this.cursors; + for (var i = cursors.length; i--; ) + cursors[i].style.animationDuration = this.blinkInterval + "ms"; + + setTimeout(function() { + dom.addCssClass(this.element, "ace_animate-blinking"); + }.bind(this)); }; + this.$stopCssAnimation = function() { + dom.removeCssClass(this.element, "ace_animate-blinking"); + }; this.$padding = 0; this.setPadding = function(padding) { @@ -31964,25 +32235,24 @@ var Cursor = function(parentEl) { }; this.setBlinking = function(blinking) { - if (blinking != this.isBlinking){ + if (blinking != this.isBlinking) { this.isBlinking = blinking; this.restartTimer(); } }; this.setBlinkInterval = function(blinkInterval) { - if (blinkInterval != this.blinkInterval){ + if (blinkInterval != this.blinkInterval) { this.blinkInterval = blinkInterval; this.restartTimer(); } }; this.setSmoothBlinking = function(smoothBlinking) { - if (smoothBlinking != this.smoothBlinking && !isIE8) { + if (smoothBlinking != this.smoothBlinking) { this.smoothBlinking = smoothBlinking; dom.setCssClass(this.element, "ace_smooth-blinking", smoothBlinking); this.$updateCursors(true); - this.$updateCursors = (this.$updateOpacity).bind(this); this.restartTimer(); } }; @@ -32019,14 +32289,18 @@ var Cursor = function(parentEl) { var update = this.$updateCursors; clearInterval(this.intervalId); clearTimeout(this.timeoutId); + this.$stopCssAnimation(); + if (this.smoothBlinking) { dom.removeCssClass(this.element, "ace_smooth-blinking"); } update(true); - if (!this.isBlinking || !this.blinkInterval || !this.isVisible) + if (!this.isBlinking || !this.blinkInterval || !this.isVisible) { + this.$stopCssAnimation(); return; + } if (this.smoothBlinking) { setTimeout(function(){ @@ -32034,18 +32308,21 @@ var Cursor = function(parentEl) { }.bind(this)); } - var blink = function(){ - this.timeoutId = setTimeout(function() { - update(false); - }, 0.6 * this.blinkInterval); - }.bind(this); - - this.intervalId = setInterval(function() { - update(true); + if (dom.HAS_CSS_ANIMATION) { + this.$startCssAnimation(); + } else { + var blink = function(){ + this.timeoutId = setTimeout(function() { + update(false); + }, 0.6 * this.blinkInterval); + }.bind(this); + + this.intervalId = setInterval(function() { + update(true); + blink(); + }, this.blinkInterval); blink(); - }, this.blinkInterval); - - blink(); + } }; this.getPixelPosition = function(position, onScreen) { @@ -32065,6 +32342,10 @@ var Cursor = function(parentEl) { return {left : cursorLeft, top : cursorTop}; }; + this.isCursorInView = function(pixelPos, config) { + return pixelPos.top >= 0 && pixelPos.top < config.maxHeight; + }; + this.update = function(config) { this.config = config; @@ -32082,15 +32363,20 @@ var Cursor = function(parentEl) { continue; } - var style = (this.cursors[cursorIndex++] || this.addCursor()).style; + var element = this.cursors[cursorIndex++] || this.addCursor(); + var style = element.style; if (!this.drawCursor) { - style.left = pixelPos.left + "px"; - style.top = pixelPos.top + "px"; - style.width = config.characterWidth + "px"; - style.height = config.lineHeight + "px"; + if (!this.isCursorInView(pixelPos, config)) { + dom.setStyle(style, "display", "none"); + } else { + dom.setStyle(style, "display", "block"); + dom.translate(element, pixelPos.left, pixelPos.top); + dom.setStyle(style, "width", Math.round(config.characterWidth) + "px"); + dom.setStyle(style, "height", config.lineHeight + "px"); + } } else { - this.drawCursor(style, pixelPos, config, selections[i], this.session); + this.drawCursor(element, pixelPos, config, selections[i], this.session); } } while (this.cursors.length > cursorIndex) @@ -32130,6 +32416,7 @@ define("ace/layer/font_metrics",[], function(require, exports, module) { var oop = require("../lib/oop"); var dom = require("../lib/dom"); var lang = require("../lib/lang"); +var event = require("../lib/event"); var useragent = require("../lib/useragent"); var EventEmitter = require("../lib/event_emitter").EventEmitter; @@ -32214,8 +32501,10 @@ var FontMetrics = exports.FontMetrics = function(parentEl) { if (this.$pollSizeChangesTimer || this.$observer) return this.$pollSizeChangesTimer; var self = this; - return this.$pollSizeChangesTimer = setInterval(function() { + + return this.$pollSizeChangesTimer = event.onIdle(function cb() { self.checkForSizeChanges(); + event.onIdle(cb, 500); }, 500); }; @@ -32328,7 +32617,6 @@ define("ace/virtual_renderer",[], function(require, exports, module) { var oop = require("./lib/oop"); var dom = require("./lib/dom"); var config = require("./config"); -var useragent = require("./lib/useragent"); var GutterLayer = require("./layer/gutter").Gutter; var MarkerLayer = require("./layer/marker").Marker; var TextLayer = require("./layer/text").Text; @@ -32348,6 +32636,7 @@ var VirtualRenderer = function(container, theme) { this.container = container || dom.createElement("div"); dom.addCssClass(this.container, "ace_editor"); + if (dom.HI_DPI) dom.addCssClass(this.container, "ace_hidpi"); this.setTheme(theme); @@ -32358,6 +32647,7 @@ var VirtualRenderer = function(container, theme) { this.scroller = dom.createElement("div"); this.scroller.className = "ace_scroller"; + this.container.appendChild(this.scroller); this.content = dom.createElement("div"); @@ -32437,6 +32727,15 @@ var VirtualRenderer = function(container, theme) { v: 0, h: 0 }; + + this.margin = { + left: 0, + right: 0, + top: 0, + bottom: 0, + v: 0, + h: 0 + }; this.$loop = new RenderLoop( this.$renderChanges.bind(this), @@ -32494,6 +32793,7 @@ var VirtualRenderer = function(container, theme) { return; this.$loop.schedule(this.CHANGE_FULL); + this.session.$setFontMetrics(this.$fontMetrics); this.scrollBarH.scrollLeft = this.scrollBarV.scrollTop = null; this.onChangeNewLineMode = this.onChangeNewLineMode.bind(this); @@ -32620,15 +32920,17 @@ var VirtualRenderer = function(container, theme) { this.gutterWidth = gutterWidth; - this.scrollBarH.element.style.left = - this.scroller.style.left = gutterWidth + "px"; - size.scrollerWidth = Math.max(0, width - gutterWidth - this.scrollBarV.getWidth()); + dom.setStyle(this.scrollBarH.element.style, "left", gutterWidth + "px"); + dom.setStyle(this.scroller.style, "left", gutterWidth + this.margin.left + "px"); + size.scrollerWidth = Math.max(0, width - gutterWidth - this.scrollBarV.getWidth() - this.margin.h); - this.scrollBarH.element.style.right = - this.scroller.style.right = this.scrollBarV.getWidth() + "px"; - this.scroller.style.bottom = this.scrollBarH.getHeight() + "px"; - if (this.session && this.session.getUseWrapMode() && this.adjustWrapLimit() || force) + var right = this.scrollBarV.getWidth() + "px"; + dom.setStyle(this.scrollBarH.element.style, "right", right); + dom.setStyle(this.scroller.style, "right", right); + dom.setStyle(this.scroller.style, "bottom", this.scrollBarH.getHeight()); + if (this.session && this.session.getUseWrapMode() && this.adjustWrapLimit() || force) { changes |= this.CHANGE_FULL; + } } size.$dirty = !width || !height; @@ -32639,8 +32941,8 @@ var VirtualRenderer = function(container, theme) { return changes; }; - this.onGutterResize = function() { - var gutterWidth = this.$showGutter ? this.$gutter.offsetWidth : 0; + this.onGutterResize = function(width) { + var gutterWidth = this.$showGutter ? width : 0; if (gutterWidth != this.gutterWidth) this.$changes |= this.$updateCachedSize(true, gutterWidth, this.$size.width, this.$size.height); @@ -32650,7 +32952,6 @@ var VirtualRenderer = function(container, theme) { this.$loop.schedule(this.CHANGE_FULL); } else { this.$computeLayerConfig(); - this.$loop.schedule(this.CHANGE_MARKER); } }; this.adjustWrapLimit = function() { @@ -32713,19 +33014,6 @@ var VirtualRenderer = function(container, theme) { return this.getOption("highlightGutterLine"); }; - this.$updateGutterLineHighlight = function() { - var pos = this.$cursorLayer.$pixelPos; - var height = this.layerConfig.lineHeight; - if (this.session.getUseWrapMode()) { - var cursor = this.session.selection.getCursor(); - cursor.column = 0; - pos = this.$cursorLayer.getPixelPosition(cursor, true); - height *= this.session.getRowLength(cursor.row); - } - this.$gutterLineHighlight.style.top = pos.top - this.layerConfig.offset + "px"; - this.$gutterLineHighlight.style.height = height + "px"; - }; - this.$updatePrintMargin = function() { if (!this.$showPrintMargin && !this.$printMarginEl) return; @@ -32758,9 +33046,11 @@ var VirtualRenderer = function(container, theme) { this.$moveTextAreaToCursor = function() { var style = this.textarea.style; if (!this.$keepTextAreaAtCursor) { - style.left = -100 + "px"; + dom.translate(this.textarea, -100, 0); return; } + if (!this.$cursorLayer.$pixelPos) + return; var config = this.layerConfig; var posTop = this.$cursorLayer.$pixelPos.top; var posLeft = this.$cursorLayer.$pixelPos.left; @@ -32768,7 +33058,7 @@ var VirtualRenderer = function(container, theme) { var h = this.lineHeight; if (posTop < 0 || posTop > config.height - h) { - style.top = style.left = "0"; + dom.translate(this.textarea, 0, 0); return; } @@ -32782,11 +33072,10 @@ var VirtualRenderer = function(container, theme) { if (posLeft > this.$size.scrollerWidth - w) posLeft = this.$size.scrollerWidth - w; - posLeft += this.gutterWidth; - style.height = h + "px"; - style.width = w + "px"; - style.left = Math.min(posLeft, this.$size.scrollerWidth - w) + "px"; - style.top = Math.min(posTop, this.$size.height - h) + "px"; + posLeft += this.gutterWidth + this.margin.left; + dom.setStyle(style, "height", h + "px"); + dom.setStyle(style, "width", w + "px"); + dom.translate(this.textarea, Math.min(posLeft, this.$size.scrollerWidth - w), Math.min(posTop, this.$size.height - h)); }; this.getFirstVisibleRow = function() { return this.layerConfig.firstRow; @@ -32829,6 +33118,18 @@ var VirtualRenderer = function(container, theme) { this.session.setScrollTop(-sm.top); this.updateFull(); }; + + this.setMargin = function(top, bottom, left, right) { + var sm = this.margin; + sm.top = top|0; + sm.bottom = bottom|0; + sm.right = right|0; + sm.left = left|0; + sm.v = sm.top + sm.bottom; + sm.h = sm.left + sm.right; + this.$updateCachedSize(true, this.gutterWidth, this.$size.width, this.$size.height); + this.updateFull(); + }; this.getHScrollBarAlwaysVisible = function() { return this.$hScrollBarAlwaysVisible; }; @@ -32911,13 +33212,18 @@ var VirtualRenderer = function(container, theme) { this.$updateScrollBarV(); if (changes & this.CHANGE_H_SCROLL) this.$updateScrollBarH(); - this.$gutterLayer.element.style.marginTop = (-config.offset) + "px"; - this.content.style.marginTop = (-config.offset) + "px"; - this.content.style.width = config.width + 2 * this.$padding + "px"; - this.content.style.height = config.minHeight + "px"; + + dom.translate(this.$gutter, this.margin.left, -config.offset); + dom.translate(this.content, -this.scrollLeft, -config.offset); + + var width = config.width + 2 * this.$padding + "px"; + var height = config.minHeight + "px"; + + dom.setStyle(this.content.style, "width", width); + dom.setStyle(this.content.style, "height", height); } if (changes & this.CHANGE_H_SCROLL) { - this.content.style.marginLeft = -this.scrollLeft + "px"; + dom.translate(this.content, -this.scrollLeft, -config.offset); this.scroller.className = this.scrollLeft <= 0 ? "ace_scroller" : "ace_scroller ace_scroll-left"; } if (changes & this.CHANGE_FULL) { @@ -32928,7 +33234,6 @@ var VirtualRenderer = function(container, theme) { this.$markerFront.update(config); this.$cursorLayer.update(config); this.$moveTextAreaToCursor(); - this.$highlightGutterLine && this.$updateGutterLineHighlight(); this._signal("afterRender"); return; } @@ -32938,12 +33243,15 @@ var VirtualRenderer = function(container, theme) { else this.$textLayer.scrollLines(config); - if (this.$showGutter) - this.$gutterLayer.update(config); + if (this.$showGutter) { + if (changes & this.CHANGE_GUTTER || changes & this.CHANGE_LINES) + this.$gutterLayer.update(config); + else + this.$gutterLayer.scrollLines(config); + } this.$markerBack.update(config); this.$markerFront.update(config); this.$cursorLayer.update(config); - this.$highlightGutterLine && this.$updateGutterLineHighlight(); this.$moveTextAreaToCursor(); this._signal("afterRender"); return; @@ -32962,11 +33270,14 @@ var VirtualRenderer = function(container, theme) { if (this.$showGutter) this.$gutterLayer.update(config); } + else if (changes & this.CHANGE_CURSOR) { + if (this.$highlightGutterLine) + this.$gutterLayer.updateLineHighlight(config); + } if (changes & this.CHANGE_CURSOR) { this.$cursorLayer.update(config); this.$moveTextAreaToCursor(); - this.$highlightGutterLine && this.$updateGutterLineHighlight(); } if (changes & (this.CHANGE_MARKER | this.CHANGE_MARKER_FRONT)) { @@ -32991,7 +33302,9 @@ var VirtualRenderer = function(container, theme) { desiredHeight += this.scrollBarH.getHeight(); if (this.$maxPixelHeight && desiredHeight > this.$maxPixelHeight) desiredHeight = this.$maxPixelHeight; - var vScroll = height > maxHeight; + + var hideScrollbars = desiredHeight <= 2 * this.lineHeight; + var vScroll = !hideScrollbars && height > maxHeight; if (desiredHeight != this.desiredHeight || this.$size.height != this.desiredHeight || vScroll != this.$vScroll) { @@ -33336,7 +33649,7 @@ var VirtualRenderer = function(container, theme) { if (this.$hasCssTransforms) { canvasPos = {top:0, left: 0}; var p = this.$fontMetrics.transformCoordinates([x, y]); - x = p[1] - this.gutterWidth; + x = p[1] - this.gutterWidth - this.margin.left; y = p[0]; } else { canvasPos = this.scroller.getBoundingClientRect(); @@ -33355,7 +33668,7 @@ var VirtualRenderer = function(container, theme) { if (this.$hasCssTransforms) { canvasPos = {top:0, left: 0}; var p = this.$fontMetrics.transformCoordinates([x, y]); - x = p[1] - this.gutterWidth; + x = p[1] - this.gutterWidth - this.margin.left; y = p[0]; } else { canvasPos = this.scroller.getBoundingClientRect(); @@ -33365,7 +33678,7 @@ var VirtualRenderer = function(container, theme) { var offset = offsetX / this.characterWidth; var col = this.$blockCursor ? Math.floor(offset) : Math.round(offset); - var row = (y + this.scrollTop - canvasPos.top) / this.lineHeight; + var row = Math.floor((y + this.scrollTop - canvasPos.top) / this.lineHeight); return this.session.screenToDocumentPosition(row, Math.max(col, 0), offsetX); }; @@ -33471,11 +33784,10 @@ var VirtualRenderer = function(container, theme) { }; this.setCursorStyle = function(style) { - if (this.scroller.style.cursor != style) - this.scroller.style.cursor = style; + dom.setStyle(this.scroller.style, "cursor", style); }; this.setMouseCursor = function(cursorStyle) { - this.scroller.style.cursor = cursorStyle; + dom.setStyle(this.scroller.style, "cursor", cursorStyle); }; this.attachToShadowRoot = function() { @@ -33532,12 +33844,8 @@ config.defineOptions(VirtualRenderer.prototype, "renderer", { initialValue: false }, showFoldWidgets: { - set: function(show) {this.$gutterLayer.setShowFoldWidgets(show);}, - initialValue: true - }, - showLineNumbers: { set: function(show) { - this.$gutterLayer.setShowLineNumbers(show); + this.$gutterLayer.setShowFoldWidgets(show); this.$loop.schedule(this.CHANGE_GUTTER); }, initialValue: true @@ -33551,19 +33859,10 @@ config.defineOptions(VirtualRenderer.prototype, "renderer", { }, highlightGutterLine: { set: function(shouldHighlight) { - if (!this.$gutterLineHighlight) { - this.$gutterLineHighlight = dom.createElement("div"); - this.$gutterLineHighlight.className = "ace_gutter-active-line"; - this.$gutter.appendChild(this.$gutterLineHighlight); - return; - } - - this.$gutterLineHighlight.style.display = shouldHighlight ? "" : "none"; - if (this.$cursorLayer.$pixelPos) - this.$updateGutterLineHighlight(); + this.$gutterLayer.setHighlightGutterLine(shouldHighlight); + this.$loop.schedule(this.CHANGE_GUTTER); }, - initialValue: false, - value: true + initialValue: true }, hScrollBarAlwaysVisible: { set: function(val) { @@ -33579,7 +33878,7 @@ config.defineOptions(VirtualRenderer.prototype, "renderer", { }, initialValue: false }, - fontSize: { + fontSize: { set: function(size) { if (typeof size == "number") size = size + "px"; @@ -33832,6 +34131,10 @@ var UndoManager = function() { this.isClean = this.isAtBookmark; this.markClean = this.bookmark; + this.$prettyPrint = function(delta) { + if (delta) return stringifyDelta(delta); + return stringifyDelta(this.$undoStack) + "\n---\n" + stringifyDelta(this.$redoStack); + }; }).call(UndoManager.prototype); function rearrangeUndoStack(stack, pos) { @@ -34083,20 +34386,23 @@ function moveDeltasByOne(redoStack, d) { d = cloneDelta(d); for (var j = redoStack.length; j--;) { var deltaSet = redoStack[j]; - for (var i = deltaSet.length; i-- > 0;) { + for (var i = 0; i < deltaSet.length; i++) { var x = deltaSet[i]; var xformed = xform(x, d); d = xformed[0]; if (xformed.length != 2) { if (xformed[2]) { - redoStack.splice(i + 1, 1, xformed[1], xformed[2]); + deltaSet.splice(i + 1, 1, xformed[1], xformed[2]); i++; } else if (!xformed[1]) { - redoStack.splice(i, 1); + deltaSet.splice(i, 1); i--; } } } + if (!deltaSet.length) { + redoStack.splice(j, 1); + } } return redoStack; } @@ -59784,8 +60090,77 @@ var baseStyles = require("../requirejs/text!./static.css"); var config = require("../config"); var dom = require("../lib/dom"); +var simpleDom = { + createTextNode: function(textContent) { + return textContent; + }, + createElement: function(type) { + var element = { + type: type, + style: {}, + childNodes: [], + appendChild: function(child) { + element.childNodes.push(child); + }, + toString: function() { + var internal = { + type: 1, + style: 1, + className: 1, + textContent: 1, + childNodes: 1, + appendChild: 1, + toString: 1 + }; + var stringBuilder = []; + + if (element.type != "fragment") { + stringBuilder.push("<", element.type); + if (element.className) + stringBuilder.push(" class='", element.className, "'"); + var styleStr = []; + for (var key in element.style) { + styleStr.push(key, ":", element.style[key]); + } + if (styleStr.length) + stringBuilder.push(" style='", styleStr.join(""), "'"); + for (var key in element) { + if (!internal[key]) { + stringBuilder.push(" ", key, "='", element[key], "'"); + } + } + stringBuilder.push(">"); + } + + if (element.textContent) { + stringBuilder.push(element.textContent); + } else { + for (var i=0; i"); + } + + return stringBuilder.join(""); + } + }; + return element; + }, + createFragment: function() { + return this.createElement("fragment"); + } +}; + var SimpleTextLayer = function() { this.config = {}; + this.dom = simpleDom; }; SimpleTextLayer.prototype = TextLayer.prototype; @@ -59811,7 +60186,7 @@ var highlight = function(el, opts, callback) { } } } else { - data = dom.getInnerText(el); + data = el.textContent; if (opts.trim) data = data.trim(); } @@ -59870,29 +60245,35 @@ highlight.renderSync = function(input, mode, theme, lineStart, disableGutter) { textLayer.setSession(session); session.setValue(input); - - var stringBuilder = []; var length = session.getLength(); + + var outerEl = simpleDom.createElement("div"); + outerEl.className = theme.cssClass; + + var innerEl = simpleDom.createElement("div"); + innerEl.className = "ace_static_highlight" + (disableGutter ? "" : " ace_show_gutter"); + innerEl.style["counter-reset"] = "ace_line " + (lineStart - 1); + outerEl.appendChild(innerEl); - for(var ix = 0; ix < length; ix++) { - stringBuilder.push("
"); - if (!disableGutter) - stringBuilder.push("" + /*(ix + lineStart) + */ ""); - textLayer.$renderLine(stringBuilder, ix, true, false); - stringBuilder.push("\n
"); + for (var ix = 0; ix < length; ix++) { + var lineEl = simpleDom.createElement("div"); + lineEl.className = "ace_line"; + + if (!disableGutter) { + var gutterEl = simpleDom.createElement("span"); + gutterEl.className ="ace_gutter ace_gutter-cell"; + gutterEl.unselectable ="on"; + gutterEl.textContent = ""; /*(ix + lineStart) + */ + lineEl.appendChild(gutterEl); + } + textLayer.$renderLine(lineEl, ix, false); + innerEl.appendChild(lineEl); } - var html = "
" + - "
" + - stringBuilder.join("") + - "
" + - "
"; - textLayer.destroy(); return { css: baseStyles + theme.cssText, - html: html, + html: outerEl.toString(), session: session }; }; @@ -59944,6 +60325,7 @@ var supportedModes = { ADA: ["ada|adb"], Apache_Conf: ["^htaccess|^htgroups|^htpasswd|^conf|htaccess|htgroups|htpasswd"], AsciiDoc: ["asciidoc|adoc"], + ASL: ["dsl|asl"], Assembly_x86:["asm|a"], AutoHotKey: ["ahk"], BatchFile: ["bat|cmd"], @@ -69916,6 +70298,7 @@ function onMouseDown(e) { screenCursor = {row: -1, column: -1}; var onMouseSelectionEnd = function(e) { + blockSelect(); clearInterval(timerId); editor.removeSelectionMarkers(rectSel); if (!rectSel.length) @@ -70463,6 +70846,8 @@ var Editor = require("./editor").Editor; if (pos.row != anchor.row || this.session.$clipPositionToDocument(pos.row, pos.column).column != anchor.column) this.multiSelect.toSingleRange(this.multiSelect.toOrientedRange()); + else + this.multiSelect.mergeOverlappingRanges(); } }; this.findAll = function(needle, options, additive) { @@ -80851,26 +81236,12 @@ define("plugins/c9.ide.terminal/aceterm/aceterm",[], function(require, exports, ace.renderer.$textLayer.element.style.overflow = "visible"; ace.renderer.$textLayer.$renderLine = Aceterm.renderLine; - - ace.renderer.$textLayer.$renderLineInner = Aceterm.renderLineInner; ace.setOption("showPrintMargin", false); ace.setOption("highlightActiveLine", false); } - Aceterm.renderLine = function(stringBuilder, row, onlyContents, foldLine) { - if (!onlyContents) { - stringBuilder.push( - "
" - ); - } - this.$renderLineInner(stringBuilder, row); - - if (!onlyContents) - stringBuilder.push("
"); - }; - - Aceterm.renderLineInner = function(stringBuilder, row) { + Aceterm.renderLine = function(lineEl, row, foldLine) { var term = this.session.term; if (!term) return; @@ -80893,7 +81264,8 @@ define("plugins/c9.ide.terminal/aceterm/aceterm",[], function(require, exports, : -1; var defAttr = term.defAttr; - var attr = defAttr; + var attr; + var span, text; for (var i = 0; i < width; i++) { var token = line[i] || term.ch; var data = token[0]; @@ -80902,14 +81274,23 @@ define("plugins/c9.ide.terminal/aceterm/aceterm",[], function(require, exports, if (i === x) data = -1; if (data !== attr) { - if (attr !== defAttr) - out += ''; + if (span) { + text.data = out; + lineEl.appendChild(span); + out = ""; + span = null; + } + text = this.dom.createTextNode(); if (data === defAttr) { + span = text; } else if (data === -1) { - out += ''; + span = this.dom.createElement("span"); + span.appendChild(text); + span.className = "reverse-video"; this.$cur = null; } else { - out += '> 9) & 0x1ff; @@ -80917,46 +81298,42 @@ define("plugins/c9.ide.terminal/aceterm/aceterm",[], function(require, exports, if (flags & 1) { if (this.$fontMetrics.allowBoldFonts) - out += 'font-weight:bold;'; + span.style.fontWeight = "bold"; if (fgColor < 8) fgColor += 8; } if (flags & 2) - out += 'text-decoration:underline;'; + span.style.textDecoration = "underline"; if (bgColor === 256) { if (fgColor !== 257) - out += 'color:' + ( + span.style.color = ( Terminal.overridenColors[fgColor] || Terminal.colors[fgColor] - ) + ';'; + ); } else { - out += 'background-color:' + Terminal.colors[bgColor] + ';'; + span.style.backgroundColor = Terminal.colors[bgColor]; if (fgColor !== 257) - out += 'color:' + Terminal.colors[fgColor] + ';'; - out += 'display:inline-block" class="aceterm-line-bg" l="' + i; + span.style.color = Terminal.colors[fgColor]; + span.style.display = "inline-block" + span.className = "aceterm-line-bg"; } - out += '">'; } } - if (ch <= ' ') out += ch == "\x00" ? "" : "\xa0"; - else if (ch == '&') - out += '&'; - else if (ch == '<') - out += '<'; else out += ch; attr = data; } - if (attr !== defAttr) - out += ''; - stringBuilder.push(out); + if (span) { + text.data = out; + lineEl.appendChild(span); + } }; }); @@ -103025,8 +103402,6 @@ var AcePopup = function(parentNode) { var row = popup.getRow(); var t = popup.renderer.$textLayer; var selected = t.element.childNodes[row - t.config.firstRow]; - if (selected == t.selectedNode) - return; if (t.selectedNode) dom.removeCssClass(t.selectedNode, "ace_selected"); t.selectedNode = selected; @@ -103232,7 +103607,6 @@ exports.AcePopup = AcePopup; }); define("plugins/c9.ide.language.core/completedp",[], function(require, exports, module) { - var escapeHTML = require("ace/lib/lang").escapeHTML; var guidToShortString = exports.guidToShortString = function(guid) { var result = guid && guid.replace(/^[^:]+:(([^\/]+)\/)*?([^\/]*?)(\[\d+[^\]]*\])?(\/prototype)?$|.*/, "$3"); @@ -103273,12 +103647,14 @@ define("plugins/c9.ide.language.core/completedp",[], function(require, exports, function tokenizeRow() { return []; } - function renderLineInner(builder, row) { - var match = this.data[row]; + function renderLine(lineEl, row, foldLine) { + var match = this.popup.data[row]; - var html = ""; + var icon = this.dom.createElement("span"); + icon.className = "completer-img " + (match.icon + ? iconClass[match.icon] || this.popup.$defineIcon(match.icon) + : ""); + lineEl.appendChild(icon); if (match.type) { var shortType = guidToShortString(match.type); @@ -103286,58 +103662,41 @@ define("plugins/c9.ide.language.core/completedp",[], function(require, exports, match.meta = shortType; } - var name = escapeHTML(match.name); + var name = match.name; var prefix = match.identifierRegex - ? this.calcPrefix(match.identifierRegex) - : name.substr(0, this.prefix.length); + ? this.popup.calcPrefix(match.identifierRegex) + : name.substr(0, this.popup.prefix.length); var trim = match.meta ? " maintrim" : ""; if (!this.ignoreGenericMatches || !match.isGeneric) { var simpleName = match.replaceText.replace("^^", "").replace(/\(\)$/, ""); if (name.indexOf(simpleName) === 0) { - simpleName = escapeHTML(simpleName); - html += '' - + prefix + "" + simpleName.substring(prefix.length) - + '' - + '' - + name.substring(Math.max(simpleName.length, prefix.length)) - + ''; + this.dom.buildDom([["span", { class: "main" + trim }, + ["u", prefix], simpleName.substring(prefix.length)], + ["span", { class: "deferred" }, name.substring(Math.max(simpleName.length, prefix.length))] + ], lineEl); } else { - html += '' - + prefix + "" + name.substring(prefix.length) - + ''; + this.dom.buildDom(["span", { class: "main" + trim }, + ["u", prefix], name.substring(prefix.length) + ], lineEl); } } else { - html += '' + prefix + "" - + name.substring(prefix.length) + ''; + this.dom.buildDom(["span", { class: "main" + trim }, + ["span", { class: "deferred" }, ["u", prefix], name.substring(prefix.length)] + ], lineEl); } - if (match.meta) - html += ' - ' + match.meta + ''; - - builder.push(html); - } - - function renderLine(stringBuilder, row, onlyContents, foldLine) { - if (!onlyContents) { - stringBuilder.push( - "
" - ); + if (match.meta) { + this.dom.buildDom(["span", { class: "meta"}, match.meta], lineEl); } - this.popup.$renderLineInner(stringBuilder, row); - - if (!onlyContents) - stringBuilder.push("
"); } exports.initPopup = function(popup, staticUrl) { popup.session.bgTokenizer.popup = popup; popup.session.bgTokenizer.$tokenizeRow = tokenizeRow; popup.renderer.$textLayer.popup = popup; - popup.$renderLineInner = renderLineInner; popup.$defineIcon = defineIcon; popup.renderer.$textLayer.$renderLine = renderLine; popup.staticUrl = staticUrl; @@ -131390,6 +131749,134 @@ define("plugins/c9.ide.ui/anims",[], function(require, exports, module) { } }); +define("ace/lib/es6-shim",[], function(require, exports, module) { + function defineProp(obj, name, val) { + Object.defineProperty(obj, name, { + value: val, + enumerable: false, + writable: true, + configurable: true, + }); + } + if (!String.prototype.startsWith) { + defineProp(String.prototype, "startsWith", function(searchString, position) { + position = position || 0; + return this.lastIndexOf(searchString, position) === position; + }); + } + if (!String.prototype.endsWith) { + defineProp(String.prototype, "endsWith", function(searchString, position) { + var subjectString = this; + if (position === undefined || position > subjectString.length) { + position = subjectString.length; + } + position -= searchString.length; + var lastIndex = subjectString.indexOf(searchString, position); + return lastIndex !== -1 && lastIndex === position; + }); + } + if (!String.prototype.repeat) { + defineProp(String.prototype, "repeat", function(count) { + var result = ""; + var string = this; + while (count > 0) { + if (count & 1) + result += string; + + if (count >>= 1) + string += string; + } + return result; + }); + } + if (!String.prototype.includes) { + defineProp(String.prototype, "includes", function(str, position) { + return this.indexOf(str, position) != -1; + }); + } + if (!Object.assign) { + Object.assign = function(target) { + if (target === undefined || target === null) { + throw new TypeError("Cannot convert undefined or null to object"); + } + + var output = Object(target); + for (var index = 1; index < arguments.length; index++) { + var source = arguments[index]; + if (source !== undefined && source !== null) { + Object.keys(source).forEach(function(key) { + output[key] = source[key]; + }); + } + } + return output; + }; + } + if (!Array.prototype.find) { + defineProp(Array.prototype, "find", function(predicate) { + var len = this.length; + var thisArg = arguments[1]; + for (var k = 0; k < len; k++) { + var kValue = this[k]; + if (predicate.call(thisArg, kValue, k, this)) { + return kValue; + } + } + }); + } + if (!Array.prototype.findIndex) { + defineProp(Array.prototype, "findIndex", function(predicate) { + var len = this.length; + var thisArg = arguments[1]; + for (var k = 0; k < len; k++) { + var kValue = this[k]; + if (predicate.call(thisArg, kValue, k, this)) { + return k; + } + } + }); + } + if (!Array.prototype.includes) { + defineProp(Array.prototype, "includes", function(item, position) { + return this.indexOf(item, position) != -1; + }); + } + if (!Array.prototype.fill) { + defineProp(Array.prototype, "fill", function(value) { + var O = this; + var len = O.length >>> 0; + var start = arguments[1]; + var relativeStart = start >> 0; + var k = relativeStart < 0 ? + Math.max(len + relativeStart, 0) : + Math.min(relativeStart, len); + var end = arguments[2]; + var relativeEnd = end === undefined ? + len : end >> 0; + var final = relativeEnd < 0 ? + Math.max(len + relativeEnd, 0) : + Math.min(relativeEnd, len); + while (k < final) { + O[k] = value; + k++; + } + return O; + }); + } + if (!Array.of) { + defineProp(Array, "of", function() { + return Array.prototype.slice.call(arguments); + }); + } +}); + +define("ace/lib/fixoldbrowsers",[], function(require, exports, module) { +"use strict"; + +require("./es6-shim"); + +}); + define("plugins/c9.ide.ui/codebox",[], function(require, exports, module) { "use strict"; @@ -135425,7 +135912,7 @@ exports.isAvailable = function(editor, command) { if (isSupported && mode.$modes) { try { editorProxy.setupContext(editor); - if (/^(js|php)/.test(editorProxy.getSyntax())) + if (/js|php/.test(editorProxy.getSyntax())) isSupported = false; } catch(e) {} } @@ -136259,16 +136746,18 @@ dom.importCssString(".normal-mode .ace_cursor{\ .ace_dialog {\ position: absolute;\ left: 0; right: 0;\ - background: inherit;\ + background: white;\ z-index: 15;\ padding: .1em .8em;\ overflow: hidden;\ - color: inherit;\ + color: #333;\ }\ .ace_dialog-top {\ + border-bottom: 1px solid #eee;\ top: 0;\ }\ .ace_dialog-bottom {\ + border-top: 1px solid #eee;\ bottom: 0;\ }\ .ace_dialog input {\ @@ -139602,8 +140091,10 @@ dom.importCssString(".normal-mode .ace_cursor{\ cm.openDialog(template, onClose, { bottom: true, value: options.value, onKeyDown: options.onKeyDown, onKeyUp: options.onKeyUp, selectValueOnOpen: false, onClose: function() { - cm.state.vim.status = ""; - cm.ace.renderer.$loop.schedule(cm.ace.renderer.CHANGE_CURSOR); + if (cm.state.vim) { + cm.state.vim.status = ""; + cm.ace.renderer.$loop.schedule(cm.ace.renderer.CHANGE_CURSOR); + } }}); } else { @@ -140956,7 +141447,7 @@ dom.importCssString(".normal-mode .ace_cursor{\ var name = ''; if (e.ctrlKey) { name += 'C-'; } if (e.altKey) { name += 'A-'; } - if (e.shiftKey) { name += 'S-'; } + if ((name || key.length > 1) && e.shiftKey) { name += 'S-'; } name += key; if (name.length > 1) { name = '<' + name + '>'; } @@ -141031,7 +141522,7 @@ dom.importCssString(".normal-mode .ace_cursor{\ var getVim = Vim.maybeInitVimState_; exports.handler = { $id: "ace/keyboard/vim", - drawCursor: function(style, pixelPos, config, sel, session) { + drawCursor: function(element, pixelPos, config, sel, session) { var vim = this.state.vim || {}; var w = config.characterWidth; var h = config.lineHeight; @@ -141048,10 +141539,9 @@ dom.importCssString(".normal-mode .ace_cursor{\ h = h / 2; top += h; } - style.left = left + "px"; - style.top = top + "px"; - style.width = w + "px"; - style.height = h + "px"; + dom.translate(element, left, top); + dom.setStyle(element.style, "width", w + "px"); + dom.setStyle(element.style, "height", h + "px"); }, handleKeyboard: function(data, hashId, key, keyCode, e) { var editor = data.editor; @@ -141215,25 +141705,6 @@ dom.importCssString(".normal-mode .ace_cursor{\ } } }; - var renderVirtualNumbers = { - getText: function(session, row) { - return (Math.abs(session.selection.lead.row - row) || (row + 1 + (row < 9? "\xb7" : "" ))) + ""; - }, - getWidth: function(session, lastLineNumber, config) { - return session.getLength().toString().length * config.characterWidth; - }, - update: function(e, editor) { - editor.renderer.$loop.schedule(editor.renderer.CHANGE_GUTTER); - }, - attach: function(editor) { - editor.renderer.$gutterLayer.$renderer = this; - editor.on("changeSelection", this.update); - }, - detach: function(editor) { - editor.renderer.$gutterLayer.$renderer = null; - editor.off("changeSelection", this.update); - } - }; Vim.defineOption({ name: "wrap", set: function(value, cm) { @@ -146140,7 +146611,7 @@ define("plugins/c9.ide.ace/ace",[], function(require, exports, module) { "threewaymerge", "error_handler", "apf" ]; main.provides = ["ace"]; - return main; + module.exports = main; function main(options, imports, register) { var Editor = imports.Editor; @@ -147640,39 +148111,6 @@ define("plugins/c9.ide.ace/ace",[], function(require, exports, module) { return s; } - - var relativeNumbers = { - getText: function(session, row) { - return (Math.abs(session.selection.lead.row - row) || (row + 1 + (row < 9 ? "\xb7" : ""))) + ""; - }, - getWidth: function(session, lastLineNumber, config) { - return session.getLength().toString().length * config.characterWidth; - }, - update: function(e, editor) { - editor.renderer.$loop.schedule(editor.renderer.CHANGE_GUTTER); - }, - attach: function(editor) { - editor.renderer.$gutterLayer.$renderer = this; - editor.on("changeSelection", this.update); - }, - detach: function(editor) { - editor.renderer.$gutterLayer.$renderer = null; - editor.off("changeSelection", this.update); - } - }; - - var noNumbers = { - getText: function(session, row) { - return ""; - }, - getWidth: function(session, lastLineNumber, config) { - return ""; - }, - attach: function(editor) { - }, - detach: function(editor) { - }, - }; handle.freezePublicAPI({ get contextMenu() { draw(); return mnuAce; }, get gutterContextMenu() { draw(); return mnuGutter; }, @@ -148066,20 +148504,9 @@ define("plugins/c9.ide.ace/ace",[], function(require, exports, module) { break; case "showLineNumbers": var renderer = ace.renderer; - var gutterRenderer = renderer.$gutterLayer.$renderer; - if (gutterRenderer && gutterRenderer.detach) - gutterRenderer.detach(ace); - if (value == "relative") - gutterRenderer = relativeNumbers; - else if (value) - gutterRenderer = null; - else - gutterRenderer = noNumbers; + ace.setOption("relativeLineNumbers", value == "relative"); + ace.setOption("showLineNumbers", !!value); dom.setCssClass(renderer.$gutter, "ace_gutter-compact", !value); - renderer.$gutterLayer.$renderer = gutterRenderer; - if (gutterRenderer && gutterRenderer.attach) - gutterRenderer.attach(ace); - renderer.$loop.schedule(renderer.CHANGE_GUTTER); return; } diff --git a/build/standalone/modules/ace/ext/beautify.js b/build/standalone/modules/ace/ext/beautify.js index eea63283..d6b3f3d2 100644 --- a/build/standalone/modules/ace/ext/beautify.js +++ b/build/standalone/modules/ace/ext/beautify.js @@ -16,13 +16,17 @@ exports.beautify = function(session) { var blockTags = exports.blockTags; var nextToken; var breakBefore = false; + var spaceBefore = false; + var spaceAfter = false; var code = ""; var value = ""; var tagName = ""; + var depth = 0; + var lastDepth = 0; + var lastIndent = 0; var indent = 0; - var inBlock = false; - var inComment = false; - var inCase = false; + var unindent = 0; + var roundDepth = 0; var onCaseLine = false; var row; var curRow = 0; @@ -31,134 +35,261 @@ exports.beautify = function(session) { var abort = false; var i; var indentNextLine = false; + var inTag = false; + var inCSS = false; + var inBlock = false; + var levels = {0: 0}; + var parents = {}; + + var trimNext = function() { + if (nextToken && nextToken.value && nextToken.type !== 'string.regexp') + nextToken.value = nextToken.value.trim(); + }; + + var trimLine = function() { + code = code.replace(/ +$/, ""); + }; + + var trimCode = function() { + code = code.trimRight(); + breakBefore = false; + }; while (token !== null) { - value = token.value; curRow = iterator.getCurrentTokenRow(); rowTokens = iterator.$rowTokens; nextToken = iterator.stepForward(); - if (is(token, "tag-open") && value === "<" && nextToken) - inBlock = (blockTags.indexOf(nextToken.value) !== -1); - if (is(token, "comment.start")) { - inComment = true; - inBlock = true; - } else if (is(token, "comment.end")) { - inComment = false; - inBlock = false; - } - if (is(token, "tag-open") && value === " 0; rowsToAdd--) - code += "\n"; - - breakBefore = true; - if (!inComment) - value = value.trimLeft(); - } - - if (value) { - if (token.type === "keyword" && value.match(/^(if|else|elseif|for|while|switch)$/)) { - value += " "; - nextToken.value = nextToken.value.trim(); - if (!breakBefore && token.type === "keyword" && value.trim().match(/^(else|elseif)$/)) { - code = code.trimRight(); - value = " "+value; - } - } else if (token.type === "paren.lparen") { - nextToken.value = nextToken.value.trim(); - if (value.substr(-1) === "{") { - code = code.replace(/ +$/, ""); - value = value + " "; - } - if (value.substr(0, 1) === "{" && !code.match(/\s$/)) - value = " " + value; - } else if (token.type === "paren.rparen") { - code = code.replace(/ +$/, ""); - if (value.substr(0, 1) === "}" && !code.match(/\s$/)) - value = " " + value; - } else if ((token.type === "keyword.operator" || token.type === "keyword") && value.match(/^(=|==|===|!=|!==|&&|\|\||and|or|xor|\+=|.=|>|>=|<|<=)$/)) { - code = code.trimRight(); - value = " " + value + " "; - nextToken.value = nextToken.value.trim(); - } else if (token.type === "support.php_tag" && value === "?>" && !breakBefore) { - code = code.trimRight(); - value = " " + value; } - if (curRow != row && rowTokens) { - abort = false; - for (i = 0; i=0 && !abort; i--) { - if (rowTokens[i].type == "paren.rparen") { - abort = true; - } else if (rowTokens[i].type == "paren.lparen") { + + if (rowsToAdd) { + trimCode(); + for (; rowsToAdd > 0; rowsToAdd--) + code += "\n"; + + breakBefore = true; + if (!is(token, "comment") && !token.type.match(/^(comment|string)$/)) + value = value.trimLeft(); + } + + if (value) { + if (token.type === "keyword" && value.match(/^(if|else|elseif|for|foreach|while|switch)$/)) { + parents[depth] = value; + + trimNext(); + spaceAfter = true; + if (value.match(/^(else|elseif)$/)) { + if (code.match(/\}[\s]*$/)) { + trimCode(); + spaceBefore = true; + } + } + } else if (token.type === "paren.lparen") { + trimNext(); + if (value.substr(-1) === "{") { + spaceAfter = true; + indentNextLine = false; + + if(!inTag) + rowsToAdd = 1; + } + if (value.substr(0, 1) === "{") { + spaceBefore = true; + if (code.substr(-1) !== '[' && code.trimRight().substr(-1) === '[') { + trimCode(); + spaceBefore = false; + } else if (code.trimRight().substr(-1) === ')') { + trimCode(); + } else { + trimLine(); + } + } + } else if (token.type === "paren.rparen") { + unindent = 1; + if (value.substr(0, 1) === "}") { + if (parents[depth-1] === 'case') + unindent++; + + if (code.trimRight().substr(-1) === '{') { + trimCode(); + } else { + spaceBefore = true; + + if (inCSS) + rowsToAdd+=2; + } + } + if (value.substr(0, 1) === "]") { + if (code.substr(-1) !== '}' && code.trimRight().substr(-1) === '}') { + spaceBefore = false; + indent++; + trimCode(); + } + } + if (value.substr(0, 1) === ")") { + if (code.substr(-1) !== '(' && code.trimRight().substr(-1) === '(') { + spaceBefore = false; + indent++; + trimCode(); + } + } + + trimLine(); + } else if ((token.type === "keyword.operator" || token.type === "keyword") && value.match(/^(=|==|===|!=|!==|&&|\|\||and|or|xor|\+=|.=|>|>=|<|<=|=>)$/)) { + trimCode(); + trimNext(); + spaceBefore = true; + spaceAfter = true; + } else if (token.type === "punctuation.operator" && value === ';') { + trimCode(); + trimNext(); + spaceAfter = true; + + if (inCSS) + rowsToAdd++; + } else if (token.type === "punctuation.operator" && value.match(/^(:|,)$/)) { + trimCode(); + trimNext(); + spaceAfter = true; + breakBefore = false; + } else if (token.type === "support.php_tag" && value === "?>" && !breakBefore) { + trimCode(); + spaceBefore = true; + } else if (is(token, "attribute-name") && code.substr(-1).match(/^\s$/)) { + spaceBefore = true; + } else if (is(token, "attribute-equals")) { + trimLine(); + trimNext(); + } else if (is(token, "tag-close")) { + trimLine(); + if(value === "/>") + spaceBefore = true; + } + if (breakBefore && !(token.type.match(/^(comment)$/) && !value.substr(0, 1).match(/^[/#]$/)) && !(token.type.match(/^(string)$/) && !value.substr(0, 1).match(/^['"]$/))) { + + indent = lastIndent; + + if(depth > lastDepth) { + indent++; + + for (i=depth; i > lastDepth; i--) + levels[i] = indent; + } else if(depth < lastDepth) + indent = levels[depth]; + + lastDepth = depth; + lastIndent = indent; + + if(unindent) + indent -= unindent; + + if (indentNextLine && !roundDepth) { indent++; indentNextLine = false; - abort = true; + } + + for (i = 0; i < indent; i++) + code += tabString; + } + + + if (token.type === "keyword" && value.match(/^(case|default)$/)) { + parents[depth] = value; + depth++; + } + + + if (token.type === "keyword" && value.match(/^(break)$/)) { + if(parents[depth-1] && parents[depth-1].match(/^(case|default)$/)) { + depth--; } } - } - if (indentNextLine !== false && token.type === "keyword" && value.trim().match(/^(if|else|elseif|for|while)$/)) - indentNextLine = true; - code += value; - breakBefore = false; - if ((is(token, "tag-close") && (inBlock || blockTags.indexOf(tagName) !== -1)) || (is(token, "doctype") && value==">")) { - if (inBlock && nextToken && nextToken.value === "" && singletonTags.indexOf(tagName) === -1) - indent--; + if (token.type === "keyword" && value.match(/^(if|else|elseif|for|while)$/)) { + indentNextLine = true; + roundDepth = 0; + } else if (!roundDepth && value.trim() && token.type !== "comment") + indentNextLine = false; - row = curRow; + if (token.type === "paren.rparen") { + roundDepth -= (value.match(/\)/g) || []).length; + + for (i = 0; i < value.length; i++) { + depth--; + if(value.substr(i, 1)==='}' && parents[depth]==='case') { + depth--; + } + } + } + if (spaceBefore && !breakBefore) { + trimLine(); + if (code.substr(-1) !== "\n") + code += " "; + } + + code += value; + + if (spaceAfter) + code += " "; + + breakBefore = false; + spaceBefore = false; + spaceAfter = false; + if ((is(token, "tag-close") && (inBlock || blockTags.indexOf(tagName) !== -1)) || (is(token, "doctype") && value === ">")) { + if (inBlock && nextToken && nextToken.value === "" && singletonTags.indexOf(tagName) === -1){ + depth--; + } + + row = curRow; + } } token = nextToken; diff --git a/build/standalone/modules/ace/ext/emmet.js b/build/standalone/modules/ace/ext/emmet.js index 46f32c89..e5201654 100644 --- a/build/standalone/modules/ace/ext/emmet.js +++ b/build/standalone/modules/ace/ext/emmet.js @@ -1170,7 +1170,7 @@ exports.isAvailable = function(editor, command) { if (isSupported && mode.$modes) { try { editorProxy.setupContext(editor); - if (/^(js|php)/.test(editorProxy.getSyntax())) + if (/js|php/.test(editorProxy.getSyntax())) isSupported = false; } catch(e) {} } diff --git a/build/standalone/modules/ace/ext/language_tools.js b/build/standalone/modules/ace/ext/language_tools.js index 365b1c05..4ac97ad4 100644 --- a/build/standalone/modules/ace/ext/language_tools.js +++ b/build/standalone/modules/ace/ext/language_tools.js @@ -906,6 +906,131 @@ var Editor = require("./editor").Editor; }); +define("ace/layer/lines",[], function(require, exports, module) { +"use strict"; + +var dom = require("../lib/dom"); + +var Lines = function(element, canvasHeight) { + this.element = element; + this.canvasHeight = canvasHeight || 500000; + this.element.style.height = (this.canvasHeight * 2) + "px"; + + this.cells = []; + this.cellCache = []; +}; + +(function() { + + this.moveContainer = function(config) { + dom.translate(this.element, 0, -((config.firstRowScreen * config.lineHeight) % this.canvasHeight)); + }; + + this.pageChanged = function(oldConfig, newConfig) { + return ( + Math.floor((oldConfig.firstRowScreen * oldConfig.lineHeight) / this.canvasHeight) !== + Math.floor((newConfig.firstRowScreen * newConfig.lineHeight) / this.canvasHeight) + ); + }; + + this.computeLineTop = function(row, config, session) { + var screenTop = config.firstRowScreen * config.lineHeight; + var screenPage = Math.floor(screenTop / this.canvasHeight); + var lineTop = session.documentToScreenRow(row, 0) * config.lineHeight; + return lineTop - (screenPage * this.canvasHeight); + }; + + this.computeLineHeight = function(row, config, session) { + return config.lineHeight * session.getRowLength(row); + }; + + this.getLength = function() { + return this.cells.length; + }; + + this.get = function(index) { + return this.cells[index]; + }; + + this.shift = function() { + this.$cacheCell(this.cells.shift()); + }; + + this.pop = function() { + this.$cacheCell(this.cells.pop()); + }; + + this.push = function(cell) { + if (Array.isArray(cell)) { + this.cells.push.apply(this.cells, cell); + var fragment = dom.createFragment(this.element); + for (var i=0; i foldStart) { row = fold.end.row + 1; @@ -1017,95 +1148,243 @@ var Gutter = function(parentEl) { foldStart = fold ? fold.start.row : Infinity; } if (row > lastRow) { - while (this.$cells.length > index + 1) { - cell = this.$cells.pop(); - this.element.removeChild(cell.element); - } + while (this.$lines.getLength() > index + 1) + this.$lines.pop(); + break; } - cell = this.$cells[++index]; + cell = this.$lines.get(++index); if (!cell) { - cell = {element: null, textNode: null, foldWidget: null}; - cell.element = dom.createElement("div"); - cell.textNode = document.createTextNode(''); - cell.element.appendChild(cell.textNode); - this.element.appendChild(cell.element); - this.$cells[index] = cell; + cell = this.$lines.createCell(row, config, this.session, onCreateCell); + this.$lines.push(cell); } - var className = "ace_gutter-cell "; - if (breakpoints[row]) - className += breakpoints[row]; - if (decorations[row]) - className += decorations[row]; - if (this.$annotations[row]) - className += this.$annotations[row].className; - if (cell.element.className != className) - cell.element.className = className; - - var height = session.getRowLength(row) * config.lineHeight + "px"; - if (height != cell.element.style.height) - cell.element.style.height = height; - - if (foldWidgets) { - var c = foldWidgets[row]; - if (c == null) - c = foldWidgets[row] = session.getFoldWidget(row); - } - - if (c) { - if (!cell.foldWidget) { - cell.foldWidget = dom.createElement("span"); - cell.element.appendChild(cell.foldWidget); - } - var className = "ace_fold-widget ace_" + c; - if (c == "start" && row == foldStart && row < fold.end.row) - className += " ace_closed"; - else - className += " ace_open"; - if (cell.foldWidget.className != className) - cell.foldWidget.className = className; - - var height = config.lineHeight + "px"; - if (cell.foldWidget.style.height != height) - cell.foldWidget.style.height = height; - } else { - if (cell.foldWidget) { - cell.element.removeChild(cell.foldWidget); - cell.foldWidget = null; - } - } - - var text = lastLineNumber = gutterRenderer - ? gutterRenderer.getText(session, row) - : row + firstLineNumber; - if (text !== cell.textNode.data) - cell.textNode.data = text; - + this.$renderCell(cell, config, fold, row); row++; } + + this._signal("afterRender"); + this.$updateGutterWidth(config); + }; - this.element.style.height = config.minHeight + "px"; - + this.$updateGutterWidth = function(config) { + var session = this.session; + + var gutterRenderer = session.gutterRenderer || this.$renderer; + + var firstLineNumber = session.$firstLineNumber; + var lastLineText = this.$lines.last() ? this.$lines.last().text : ""; + if (this.$fixedWidth || session.$useWrapMode) - lastLineNumber = session.getLength() + firstLineNumber; + lastLineText = session.getLength() + firstLineNumber; var gutterWidth = gutterRenderer - ? gutterRenderer.getWidth(session, lastLineNumber, config) - : lastLineNumber.toString().length * config.characterWidth; + ? gutterRenderer.getWidth(session, lastLineText, config) + : lastLineText.toString().length * config.characterWidth; var padding = this.$padding || this.$computePadding(); gutterWidth += padding.left + padding.right; if (gutterWidth !== this.gutterWidth && !isNaN(gutterWidth)) { this.gutterWidth = gutterWidth; + this.element.parentNode.style.width = this.element.style.width = Math.ceil(this.gutterWidth) + "px"; - this._emit("changeGutterWidth", gutterWidth); + this._signal("changeGutterWidth", gutterWidth); } }; + + this.$updateCursorRow = function() { + if (!this.$highlightGutterLine) + return; + + var position = this.session.selection.getCursor(); + if (this.$cursorRow === position.row) + return; + + this.$cursorRow = position.row; + }; + + this.updateLineHighlight = function() { + if (!this.$highlightGutterLine) + return; + var row = this.session.selection.cursor.row; + this.$cursorRow = row; + + if (this.$cursorCell && this.$cursorCell.row == row) + return; + if (this.$cursorCell) + this.$cursorCell.element.className = this.$cursorCell.element.className.replace("ace_gutter-active-line ", ""); + var cells = this.$lines.cells; + this.$cursorCell = null; + for (var i = 0; i < cells.length; i++) { + var cell = cells[i]; + if (cell.row >= this.$cursorRow) { + if (cell.row > this.$cursorRow) { + var fold = this.session.getFoldLine(this.$cursorRow); + if (i > 0 && fold && fold.start.row == cells[i - 1].row) + cell = cells[i - 1]; + else + break; + } + cell.element.className = "ace_gutter-active-line " + cell.element.className; + this.$cursorCell = cell; + break; + } + } + }; + + this.scrollLines = function(config) { + var oldConfig = this.config; + this.config = config; + + this.$updateCursorRow(); + if (this.$lines.pageChanged(oldConfig, config)) + return this.update(config); + + this.$lines.moveContainer(config); + + var lastRow = Math.min(config.lastRow + config.gutterOffset, // needed to compensate for hor scollbar + this.session.getLength() - 1); + var oldLastRow = this.oldLastRow; + this.oldLastRow = lastRow; + + if (!oldConfig || oldLastRow < config.firstRow) + return this.update(config); + + if (lastRow < oldConfig.firstRow) + return this.update(config); + + if (oldConfig.firstRow < config.firstRow) + for (var row=this.session.getFoldedRowCount(oldConfig.firstRow, config.firstRow - 1); row>0; row--) + this.$lines.shift(); + + if (oldLastRow > lastRow) + for (var row=this.session.getFoldedRowCount(lastRow + 1, oldLastRow); row>0; row--) + this.$lines.pop(); + + if (config.firstRow < oldConfig.firstRow) { + this.$lines.unshift(this.$renderLines(config, config.firstRow, oldConfig.firstRow - 1)); + } + + if (lastRow > oldLastRow) { + this.$lines.push(this.$renderLines(config, oldLastRow + 1, lastRow)); + } + + this.updateLineHighlight(); + + this._signal("afterRender"); + this.$updateGutterWidth(config); + }; + + this.$renderLines = function(config, firstRow, lastRow) { + var fragment = []; + var row = firstRow; + var foldLine = this.session.getNextFoldLine(row); + var foldStart = foldLine ? foldLine.start.row : Infinity; + + while (true) { + if (row > foldStart) { + row = foldLine.end.row+1; + foldLine = this.session.getNextFoldLine(row, foldLine); + foldStart = foldLine ? foldLine.start.row : Infinity; + } + if (row > lastRow) + break; + + var cell = this.$lines.createCell(row, config, this.session, onCreateCell); + this.$renderCell(cell, config, foldLine, row); + fragment.push(cell); + + row++; + } + return fragment; + }; + + this.$renderCell = function(cell, config, fold, row) { + var element = cell.element; + + var session = this.session; + + var textNode = element.childNodes[0]; + var foldWidget = element.childNodes[1]; + + var firstLineNumber = session.$firstLineNumber; + + var breakpoints = session.$breakpoints; + var decorations = session.$decorations; + var gutterRenderer = session.gutterRenderer || this.$renderer; + var foldWidgets = this.$showFoldWidgets && session.foldWidgets; + var foldStart = fold ? fold.start.row : Number.MAX_VALUE; + + var className = "ace_gutter-cell "; + if (this.$highlightGutterLine) { + if (row == this.$cursorRow || (fold && row < this.$cursorRow && row >= foldStart && this.$cursorRow <= fold.end.row)) { + className += "ace_gutter-active-line "; + if (this.$cursorCell != cell) { + if (this.$cursorCell) + this.$cursorCell.element.className = this.$cursorCell.element.className.replace("ace_gutter-active-line ", ""); + this.$cursorCell = cell; + } + } + } + + if (breakpoints[row]) + className += breakpoints[row]; + if (decorations[row]) + className += decorations[row]; + if (this.$annotations[row]) + className += this.$annotations[row].className; + if (element.className != className) + element.className = className; + + if (foldWidgets) { + var c = foldWidgets[row]; + if (c == null) + c = foldWidgets[row] = session.getFoldWidget(row); + } + + if (c) { + var className = "ace_fold-widget ace_" + c; + if (c == "start" && row == foldStart && row < fold.end.row) + className += " ace_closed"; + else + className += " ace_open"; + if (foldWidget.className != className) + foldWidget.className = className; + + var foldHeight = config.lineHeight + "px"; + dom.setStyle(foldWidget.style, "height", foldHeight); + dom.setStyle(foldWidget.style, "display", "inline-block"); + } else { + if (foldWidget) { + dom.setStyle(foldWidget.style, "display", "none"); + } + } + + var text = (gutterRenderer + ? gutterRenderer.getText(session, row) + : row + firstLineNumber).toString(); + + if (text !== textNode.data) { + textNode.data = text; + } + + dom.setStyle(cell.element.style, "height", this.$lines.computeLineHeight(row, config, session) + "px"); + dom.setStyle(cell.element.style, "top", this.$lines.computeLineTop(row, config, session) + "px"); + + cell.text = text; + cell.row = row; + return cell; + }; this.$fixedWidth = false; + this.$highlightGutterLine = true; + this.$renderer = ""; + this.setHighlightGutterLine = function(highlightGutterLine) { + this.$highlightGutterLine = highlightGutterLine; + }; + this.$showLineNumbers = true; this.$renderer = ""; this.setShowLineNumbers = function(show) { @@ -1139,8 +1418,10 @@ var Gutter = function(parentEl) { return {left: 0, right: 0}; var style = dom.computedStyle(this.element.firstChild); this.$padding = {}; - this.$padding.left = parseInt(style.paddingLeft) + 1 || 0; - this.$padding.right = parseInt(style.paddingRight) || 0; + this.$padding.left = (parseInt(style.borderLeftWidth) || 0) + + (parseInt(style.paddingLeft) || 0) + 1; + this.$padding.right = (parseInt(style.borderRightWidth) || 0) + + (parseInt(style.paddingRight) || 0); return this.$padding; }; @@ -1155,6 +1436,16 @@ var Gutter = function(parentEl) { }).call(Gutter.prototype); +function onCreateCell(element) { + var textNode = document.createTextNode(''); + element.appendChild(textNode); + + var foldWidget = dom.createElement("span"); + element.appendChild(foldWidget); + + return element; +} + exports.Gutter = Gutter; }); @@ -1185,14 +1476,27 @@ var Marker = function(parentEl) { this.setMarkers = function(markers) { this.markers = markers; }; + + this.elt = function(className, css) { + var x = this.i != -1 && this.element.childNodes[this.i]; + if (!x) { + x = document.createElement("div"); + this.element.appendChild(x); + this.i = -1; + } else { + this.i++; + } + x.style.cssText = css; + x.className = className; + }; this.update = function(config) { if (!config) return; this.config = config; - - var html = []; + this.i = 0; + var html; for (var key in this.markers) { var marker = this.markers[key]; @@ -1207,9 +1511,7 @@ var Marker = function(parentEl) { range = range.toScreenRange(this.session); if (marker.renderer) { var top = this.$getTop(range.start.row, config); - var left = this.$padding + (this.session.$bidiHandler.isBidiRow(range.start.row) - ? this.session.$bidiHandler.getPosLeft(range.start.column) - : range.start.column * config.characterWidth); + var left = this.$padding + range.start.column * config.characterWidth; marker.renderer(html, range, left, top, config); } else if (marker.type == "fullLine") { this.drawFullLineMarker(html, range, marker.clazz, config); @@ -1221,14 +1523,13 @@ var Marker = function(parentEl) { else this.drawMultiLineMarker(html, range, marker.clazz, config); } else { - if (this.session.$bidiHandler.isBidiRow(range.start.row)) { - this.drawBidiSingleLineMarker(html, range, marker.clazz + " ace_start" + " ace_br15", config); - } else { - this.drawSingleLineMarker(html, range, marker.clazz + " ace_start" + " ace_br15", config); - } + this.drawSingleLineMarker(html, range, marker.clazz + " ace_start" + " ace_br15", config); } } - this.element.innerHTML = html.join(""); + if (this.i !=-1) { + while (this.i < this.element.childElementCount) + this.element.removeChild(this.element.lastChild); + } }; this.$getTop = function(row, layerConfig) { @@ -1246,7 +1547,6 @@ var Marker = function(parentEl) { var prev = 0; var curr = 0; var next = session.getScreenLastRowColumn(row); - var clazzModified = null; var lineRange = new Range(row, range.start.column, row, curr); for (; row <= end; row++) { lineRange.start.row = lineRange.end.row = row; @@ -1255,56 +1555,33 @@ var Marker = function(parentEl) { prev = curr; curr = next; next = row + 1 < end ? session.getScreenLastRowColumn(row + 1) : row == end ? 0 : range.end.column; - clazzModified = clazz + (row == start ? " ace_start" : "") + " ace_br" - + getBorderClass(row == start || row == start + 1 && range.start.column, prev < curr, curr > next, row == end); - - if (this.session.$bidiHandler.isBidiRow(row)) { - this.drawBidiSingleLineMarker(stringBuilder, lineRange, clazzModified, - layerConfig, row == end ? 0 : 1, extraStyle); - } else { - this.drawSingleLineMarker(stringBuilder, lineRange, clazzModified, - layerConfig, row == end ? 0 : 1, extraStyle); - } + this.drawSingleLineMarker(stringBuilder, lineRange, + clazz + (row == start ? " ace_start" : "") + " ace_br" + + getBorderClass(row == start || row == start + 1 && range.start.column, prev < curr, curr > next, row == end), + layerConfig, row == end ? 0 : 1, extraStyle); } }; this.drawMultiLineMarker = function(stringBuilder, range, clazz, config, extraStyle) { var padding = this.$padding; - var height, top, left; + var height = config.lineHeight; + var top = this.$getTop(range.start.row, config); + var left = padding + range.start.column * config.characterWidth; extraStyle = extraStyle || ""; - if (this.session.$bidiHandler.isBidiRow(range.start.row)) { - var range1 = range.clone(); - range1.end.row = range1.start.row; - range1.end.column = this.session.getLine(range1.start.row).length; - this.drawBidiSingleLineMarker(stringBuilder, range1, clazz + " ace_br1 ace_start", config, null, extraStyle); - } else { - height = config.lineHeight; - top = this.$getTop(range.start.row, config); - left = padding + range.start.column * config.characterWidth; - stringBuilder.push( - "
" - ); - } - if (this.session.$bidiHandler.isBidiRow(range.end.row)) { - var range1 = range.clone(); - range1.start.row = range1.end.row; - range1.start.column = 0; - this.drawBidiSingleLineMarker(stringBuilder, range1, clazz + " ace_br12", config, null, extraStyle); - } else { - var width = range.end.column * config.characterWidth; - height = config.lineHeight; - top = this.$getTop(range.end.row, config); - stringBuilder.push( - "
" - ); - } + + this.elt( + clazz + " ace_br1 ace_start", + "height:"+ height+ "px;"+ "right:0;"+ "top:"+top+ "px;left:"+ left+ "px;" + (extraStyle || "") + ); + top = this.$getTop(range.end.row, config); + var width = range.end.column * config.characterWidth; + + this.elt( + clazz + " ace_br12", + "height:"+ height+ "px;"+ + "width:"+ width+ "px;"+ + "top:"+ top+ "px;"+ + "left:"+ padding+ "px;"+ (extraStyle || "") + ); height = (range.end.row - range.start.row - 1) * config.lineHeight; if (height <= 0) return; @@ -1312,12 +1589,12 @@ var Marker = function(parentEl) { var radiusClass = (range.start.column ? 1 : 0) | (range.end.column ? 0 : 8); - stringBuilder.push( - "
" + this.elt( + clazz + (radiusClass ? " ace_br" + radiusClass : ""), + "height:"+ height+ "px;"+ + "right:0;"+ + "top:"+ top+ "px;"+ + "left:"+ padding+ "px;"+ (extraStyle || "") ); }; this.drawSingleLineMarker = function(stringBuilder, range, clazz, config, extraLength, extraStyle) { @@ -1327,28 +1604,14 @@ var Marker = function(parentEl) { var top = this.$getTop(range.start.row, config); var left = this.$padding + range.start.column * config.characterWidth; - stringBuilder.push( - "
" + this.elt( + clazz, + "height:"+ height+ "px;"+ + "width:"+ width+ "px;"+ + "top:"+ top+ "px;"+ + "left:"+ left+ "px;"+ (extraStyle || "") ); }; - this.drawBidiSingleLineMarker = function(stringBuilder, range, clazz, config, extraLength, extraStyle) { - var height = config.lineHeight, top = this.$getTop(range.start.row, config), padding = this.$padding; - var selections = this.session.$bidiHandler.getSelections(range.start.column, range.end.column); - - selections.forEach(function(selection) { - stringBuilder.push( - "
" - ); - }); - }; this.drawFullLineMarker = function(stringBuilder, range, clazz, config, extraStyle) { var top = this.$getTop(range.start.row, config); @@ -1356,11 +1619,11 @@ var Marker = function(parentEl) { if (range.start.row != range.end.row) height += this.$getTop(range.end.row, config) - top; - stringBuilder.push( - "
" + this.elt( + clazz, + "height:"+ height+ "px;"+ + "top:"+ top+ "px;"+ + "left:0;right:0;"+ (extraStyle || "") ); }; @@ -1368,11 +1631,11 @@ var Marker = function(parentEl) { var top = this.$getTop(range.start.row, config); var height = config.lineHeight; - stringBuilder.push( - "
" + this.elt( + clazz, + "height:"+ height+ "px;"+ + "top:"+ top+ "px;"+ + "left:0;right:0;"+ (extraStyle || "") ); }; @@ -1388,14 +1651,16 @@ define("ace/layer/text",[], function(require, exports, module) { var oop = require("../lib/oop"); var dom = require("../lib/dom"); var lang = require("../lib/lang"); -var useragent = require("../lib/useragent"); +var Lines = require("./lines").Lines; var EventEmitter = require("../lib/event_emitter").EventEmitter; var Text = function(parentEl) { - this.element = dom.createElement("div"); + this.dom = dom; + this.element = this.dom.createElement("div"); this.element.className = "ace_layer ace_text-layer"; parentEl.appendChild(this.element); this.$updateEolChar = this.$updateEolChar.bind(this); + this.$lines = new Lines(this.element); }; (function() { @@ -1423,7 +1688,7 @@ var Text = function(parentEl) { this.setPadding = function(padding) { this.$padding = padding; - this.element.style.padding = "0 " + padding + "px"; + this.element.style.margin = "0 " + padding + "px"; }; this.getLineHeight = function() { @@ -1482,11 +1747,12 @@ var Text = function(parentEl) { var tabStr = this.$tabStrings = [0]; for (var i = 1; i < tabSize + 1; i++) { if (this.showInvisibles) { - tabStr.push("" - + lang.stringRepeat(this.TAB_CHAR, i) - + ""); + var span = this.dom.createElement("span"); + span.className = "ace_invisible ace_invisible_tab"; + span.textContent = lang.stringRepeat(this.TAB_CHAR, i); + tabStr.push(span); } else { - tabStr.push(lang.stringRepeat(" ", i)); + tabStr.push(this.dom.createTextNode(lang.stringRepeat(" ", i), this.element)); } } if (this.displayIndentGuides) { @@ -1500,21 +1766,29 @@ var Text = function(parentEl) { tabClass = " ace_invisible_tab"; var spaceContent = lang.stringRepeat(this.SPACE_CHAR, this.tabSize); var tabContent = lang.stringRepeat(this.TAB_CHAR, this.tabSize); - } else{ + } else { var spaceContent = lang.stringRepeat(" ", this.tabSize); var tabContent = spaceContent; } - this.$tabStrings[" "] = "" + spaceContent + ""; - this.$tabStrings["\t"] = "" + tabContent + ""; + var span = this.dom.createElement("span"); + span.className = className + spaceClass; + span.textContent = spaceContent; + this.$tabStrings[" "] = span; + + var span = this.dom.createElement("span"); + span.className = className + tabClass; + span.textContent = tabContent; + this.$tabStrings["\t"] = span; } }; this.updateLines = function(config, firstRow, lastRow) { if (this.config.lastRow != config.lastRow || this.config.firstRow != config.firstRow) { - this.scrollLines(config); + return this.update(config); } + this.config = config; var first = Math.max(firstRow, config.firstRow); @@ -1536,6 +1810,7 @@ var Text = function(parentEl) { lineElementsIdx ++; } + var heightChanged = false; var row = first; var foldLine = this.session.getNextFoldLine(row); var foldStart = foldLine ? foldLine.start.row : Infinity; @@ -1551,52 +1826,69 @@ var Text = function(parentEl) { var lineElement = lineElements[lineElementsIdx++]; if (lineElement) { - var html = []; + this.dom.removeChildren(lineElement); this.$renderLine( - html, row, !this.$useLineGroups(), row == foldStart ? foldLine : false + lineElement, row, row == foldStart ? foldLine : false ); - lineElement.style.height = config.lineHeight * this.session.getRowLength(row) + "px"; - lineElement.innerHTML = html.join(""); + var height = (config.lineHeight * this.session.getRowLength(row)) + "px"; + if (lineElement.style.height != height) { + heightChanged = true; + lineElement.style.height = height; + } } row++; } + if (heightChanged) { + while (lineElementsIdx < this.$lines.cells.length) { + var cell = this.$lines.cells[lineElementsIdx++]; + cell.element.style.top = this.$lines.computeLineTop(cell.row, config, this.session) + "px"; + } + } }; this.scrollLines = function(config) { var oldConfig = this.config; this.config = config; + if (this.$lines.pageChanged(oldConfig, config)) + return this.update(config); + + this.$lines.moveContainer(config); + + var lastRow = config.lastRow; + var oldLastRow = oldConfig ? oldConfig.lastRow : -1; + + if (!oldConfig || oldLastRow < config.firstRow) + return this.update(config); + + if (lastRow < oldConfig.firstRow) + return this.update(config); + if (!oldConfig || oldConfig.lastRow < config.firstRow) return this.update(config); if (config.lastRow < oldConfig.firstRow) return this.update(config); - var el = this.element; if (oldConfig.firstRow < config.firstRow) for (var row=this.session.getFoldedRowCount(oldConfig.firstRow, config.firstRow - 1); row>0; row--) - el.removeChild(el.firstChild); + this.$lines.shift(); if (oldConfig.lastRow > config.lastRow) for (var row=this.session.getFoldedRowCount(config.lastRow + 1, oldConfig.lastRow); row>0; row--) - el.removeChild(el.lastChild); + this.$lines.pop(); if (config.firstRow < oldConfig.firstRow) { - var fragment = this.$renderLinesFragment(config, config.firstRow, oldConfig.firstRow - 1); - if (el.firstChild) - el.insertBefore(fragment, el.firstChild); - else - el.appendChild(fragment); + this.$lines.unshift(this.$renderLinesFragment(config, config.firstRow, oldConfig.firstRow - 1)); } if (config.lastRow > oldConfig.lastRow) { - var fragment = this.$renderLinesFragment(config, oldConfig.lastRow + 1, config.lastRow); - el.appendChild(fragment); + this.$lines.push(this.$renderLinesFragment(config, oldConfig.lastRow + 1, config.lastRow)); } }; this.$renderLinesFragment = function(config, firstRow, lastRow) { - var fragment = this.element.ownerDocument.createDocumentFragment(); + var fragment = []; var row = firstRow; var foldLine = this.session.getNextFoldLine(row); var foldStart = foldLine ? foldLine.start.row : Infinity; @@ -1610,21 +1902,20 @@ var Text = function(parentEl) { if (row > lastRow) break; - var container = dom.createElement("div"); + var line = this.$lines.createCell(row, config, this.session); + + var lineEl = line.element; + this.dom.removeChildren(lineEl); + dom.setStyle(lineEl.style, "height", this.$lines.computeLineHeight(row, config, this.session) + "px"); + dom.setStyle(lineEl.style, "top", this.$lines.computeLineTop(row, config, this.session) + "px"); + this.$renderLine(lineEl, row, row == foldStart ? foldLine : false); - var html = []; - this.$renderLine(html, row, false, row == foldStart ? foldLine : false); - - container.innerHTML = html.join(""); if (this.$useLineGroups()) { - container.className = 'ace_line_group'; - fragment.appendChild(container); - container.style.height = config.lineHeight * this.session.getRowLength(row) + "px"; - + lineEl.className = "ace_line_group"; } else { - while(container.firstChild) - fragment.appendChild(container.firstChild); + lineEl.className = "ace_line"; } + fragment.push(line); row++; } @@ -1632,35 +1923,18 @@ var Text = function(parentEl) { }; this.update = function(config) { + this.$lines.moveContainer(config); + this.config = config; - var html = []; - var firstRow = config.firstRow, lastRow = config.lastRow; + var firstRow = config.firstRow; + var lastRow = config.lastRow; - var row = firstRow; - var foldLine = this.session.getNextFoldLine(row); - var foldStart = foldLine ? foldLine.start.row : Infinity; - - while (true) { - if (row > foldStart) { - row = foldLine.end.row+1; - foldLine = this.session.getNextFoldLine(row, foldLine); - foldStart = foldLine ? foldLine.start.row :Infinity; - } - if (row > lastRow) - break; - - if (this.$useLineGroups()) - html.push("
"); - - this.$renderLine(html, row, false, row == foldStart ? foldLine : false); - - if (this.$useLineGroups()) - html.push("
"); // end the line group - - row++; - } - this.element.innerHTML = html.join(""); + var lines = this.$lines; + while (lines.getLength()) + lines.pop(); + + lines.push(this.$renderLinesFragment(config, firstRow, lastRow)); }; this.$textToken = { @@ -1669,108 +1943,153 @@ var Text = function(parentEl) { "lparen": true }; - this.$renderToken = function(stringBuilder, screenColumn, token, value) { + this.$renderToken = function(parent, screenColumn, token, value) { var self = this; - var replaceReg = /\t|&|<|>|( +)|([\x00-\x1f\x80-\xa0\xad\u1680\u180E\u2000-\u200f\u2028\u2029\u202F\u205F\u3000\uFEFF\uFFF9-\uFFFC])|[\u1100-\u115F\u11A3-\u11A7\u11FA-\u11FF\u2329-\u232A\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u2FFB\u3000-\u303E\u3041-\u3096\u3099-\u30FF\u3105-\u312D\u3131-\u318E\u3190-\u31BA\u31C0-\u31E3\u31F0-\u321E\u3220-\u3247\u3250-\u32FE\u3300-\u4DBF\u4E00-\uA48C\uA490-\uA4C6\uA960-\uA97C\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFAFF\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE66\uFE68-\uFE6B\uFF01-\uFF60\uFFE0-\uFFE6]|[\uD800-\uDBFF][\uDC00-\uDFFF]/g; - var replaceFunc = function(c, a, b, tabIdx, idx4) { - if (a) { - return self.showInvisibles - ? "" + lang.stringRepeat(self.SPACE_CHAR, c.length) + "" - : c; - } else if (c == "&") { - return "&"; - } else if (c == "<") { - return "<"; - } else if (c == ">") { - return ">"; - } else if (c == "\t") { - var tabSize = self.session.getScreenTabSize(screenColumn + tabIdx); + var re = /(\t)|( +)|([\x00-\x1f\x80-\xa0\xad\u1680\u180E\u2000-\u200f\u2028\u2029\u202F\u205F\uFEFF\uFFF9-\uFFFC]+)|(\u3000)|([\u1100-\u115F\u11A3-\u11A7\u11FA-\u11FF\u2329-\u232A\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u2FFB\u3001-\u303E\u3041-\u3096\u3099-\u30FF\u3105-\u312D\u3131-\u318E\u3190-\u31BA\u31C0-\u31E3\u31F0-\u321E\u3220-\u3247\u3250-\u32FE\u3300-\u4DBF\u4E00-\uA48C\uA490-\uA4C6\uA960-\uA97C\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFAFF\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE66\uFE68-\uFE6B\uFF01-\uFF60\uFFE0-\uFFE6]|[\uD800-\uDBFF][\uDC00-\uDFFF])/g; + + var valueFragment = this.dom.createFragment(this.element); + + var m; + var i = 0; + while (m = re.exec(value)) { + var tab = m[1]; + var simpleSpace = m[2]; + var controlCharacter = m[3]; + var cjkSpace = m[4]; + var cjk = m[5]; + + if (!self.showInvisibles && simpleSpace) + continue; + + var before = i != m.index ? value.slice(i, m.index) : ""; + + i = m.index + m[0].length; + + if (before) { + valueFragment.appendChild(this.dom.createTextNode(before, this.element)); + } + + if (tab) { + var tabSize = self.session.getScreenTabSize(screenColumn + m.index); + valueFragment.appendChild(self.$tabStrings[tabSize].cloneNode(true)); screenColumn += tabSize - 1; - return self.$tabStrings[tabSize]; - } else if (c == "\u3000") { - var classToUse = self.showInvisibles ? "ace_cjk ace_invisible ace_invisible_space" : "ace_cjk"; + } else if (simpleSpace) { + if (self.showInvisibles) { + var span = this.dom.createElement("span"); + span.className = "ace_invisible ace_invisible_space"; + span.textContent = lang.stringRepeat(self.SPACE_CHAR, simpleSpace.length); + valueFragment.appendChild(span); + } else { + valueFragment.appendChild(this.com.createTextNode(simpleSpace, this.element)); + } + } else if (controlCharacter) { + var span = this.dom.createElement("span"); + span.className = "ace_invisible ace_invisible_space ace_invalid"; + span.textContent = lang.stringRepeat(self.SPACE_CHAR, controlCharacter.length); + valueFragment.appendChild(span); + } else if (cjkSpace) { var space = self.showInvisibles ? self.SPACE_CHAR : ""; screenColumn += 1; - return "" + space + ""; - } else if (b) { - return "" + self.SPACE_CHAR + ""; - } else { + + var span = this.dom.createElement("span"); + span.style.width = (self.config.characterWidth * 2) + "px"; + span.className = self.showInvisibles ? "ace_cjk ace_invisible ace_invisible_space" : "ace_cjk"; + span.textContent = self.showInvisibles ? self.SPACE_CHAR : ""; + valueFragment.appendChild(span); + } else if (cjk) { screenColumn += 1; - return "" + c + ""; + var span = dom.createElement("span"); + span.style.width = (self.config.characterWidth * 2) + "px"; + span.className = "ace_cjk"; + span.textContent = cjk; + valueFragment.appendChild(span); } - }; - - var output = value.replace(replaceReg, replaceFunc); + } + + valueFragment.appendChild(this.dom.createTextNode(i ? value.slice(i) : value, this.element)); if (!this.$textToken[token.type]) { var classes = "ace_" + token.type.replace(/\./g, " ace_"); - var style = ""; + var span = this.dom.createElement("span"); if (token.type == "fold") - style = " style='width:" + (token.value.length * this.config.characterWidth) + "px;' "; - stringBuilder.push("", output, ""); + span.style.width = (token.value.length * this.config.characterWidth) + "px"; + + span.className = classes; + span.appendChild(valueFragment); + + parent.appendChild(span); } else { - stringBuilder.push(output); + parent.appendChild(valueFragment); } + return screenColumn + value.length; }; - this.renderIndentGuide = function(stringBuilder, value, max) { + this.renderIndentGuide = function(parent, value, max) { var cols = value.search(this.$indentGuideRe); if (cols <= 0 || cols >= max) return value; if (value[0] == " ") { cols -= cols % this.tabSize; - stringBuilder.push(lang.stringRepeat(this.$tabStrings[" "], cols/this.tabSize)); + var count = cols/this.tabSize; + for (var i=0; i= splitChars) { screenColumn = this.$renderToken( - stringBuilder, screenColumn, + lineEl, screenColumn, token, value.substring(0, splitChars - chars) ); value = value.substring(splitChars - chars); chars = splitChars; - if (!onlyContents) { - stringBuilder.push("
", - "
" - ); - } + lineEl = this.$createLineElement(); + parent.appendChild(lineEl); - stringBuilder.push(lang.stringRepeat("\xa0", splits.indent)); + lineEl.appendChild(this.dom.createTextNode(lang.stringRepeat("\xa0", splits.indent), this.element)); split ++; screenColumn = 0; @@ -1779,38 +2098,43 @@ var Text = function(parentEl) { if (value.length != 0) { chars += value.length; screenColumn = this.$renderToken( - stringBuilder, screenColumn, token, value + lineEl, screenColumn, token, value ); } } } }; - this.$renderSimpleLine = function(stringBuilder, tokens) { + this.$renderSimpleLine = function(parent, tokens) { var screenColumn = 0; var token = tokens[0]; var value = token.value; if (this.displayIndentGuides) - value = this.renderIndentGuide(stringBuilder, value); + value = this.renderIndentGuide(parent, value); if (value) - screenColumn = this.$renderToken(stringBuilder, screenColumn, token, value); + screenColumn = this.$renderToken(parent, screenColumn, token, value); for (var i = 1; i < tokens.length; i++) { token = tokens[i]; value = token.value; if (screenColumn + value.length > this.MAX_LINE_LENGTH) - return this.$renderOverflowMessage(stringBuilder, screenColumn, token, value); - screenColumn = this.$renderToken(stringBuilder, screenColumn, token, value); + return this.$renderOverflowMessage(parent, screenColumn, token, value); + screenColumn = this.$renderToken(parent, screenColumn, token, value); } }; - this.$renderOverflowMessage = function(stringBuilder, screenColumn, token, value) { - this.$renderToken(stringBuilder, screenColumn, token, + this.$renderOverflowMessage = function(parent, screenColumn, token, value) { + this.$renderToken(parent, screenColumn, token, value.slice(0, this.MAX_LINE_LENGTH - screenColumn)); - stringBuilder.push( - "<click to see more...>" - ); + + var overflowEl = this.dom.createElement("span"); + overflowEl.className = "ace_inline_button ace_keyword ace_toggle_wrap"; + overflowEl.style.position = "absolute"; + overflowEl.style.right = "0"; + overflowEl.textContent = ""; + + parent.appendChild(overflowEl); }; - this.$renderLine = function(stringBuilder, row, onlyContents, foldLine) { + this.$renderLine = function(parent, row, foldLine) { if (!foldLine && foldLine != false) foldLine = this.session.getFoldLine(row); @@ -1819,36 +2143,35 @@ var Text = function(parentEl) { else var tokens = this.session.getTokens(row); - - if (!onlyContents) { - stringBuilder.push( - "
" - ); - } - + var lastLineEl = parent; if (tokens.length) { var splits = this.session.getRowSplitData(row); - if (splits && splits.length) - this.$renderWrappedLine(stringBuilder, tokens, splits, onlyContents); - else - this.$renderSimpleLine(stringBuilder, tokens); + if (splits && splits.length) { + this.$renderWrappedLine(parent, tokens, splits); + var lastLineEl = parent.lastChild; + } else { + var lastLineEl = parent; + if (this.$useLineGroups()) { + lastLineEl = this.$createLineElement(); + parent.appendChild(lastLineEl); + } + this.$renderSimpleLine(lastLineEl, tokens); + } + } else if (this.$useLineGroups()) { + lastLineEl = this.$createLineElement(); + parent.appendChild(lastLineEl); } - if (this.showInvisibles) { + if (this.showInvisibles && lastLineEl) { if (foldLine) row = foldLine.end.row; - stringBuilder.push( - "", - row == this.session.getLength() - 1 ? this.EOF_CHAR : this.EOL_CHAR, - "" - ); + var invisibleEl = this.dom.createElement("span"); + invisibleEl.className = "ace_invisible ace_invisible_eol"; + invisibleEl.textContent = row == this.session.getLength() - 1 ? this.EOF_CHAR : this.EOL_CHAR; + + lastLineEl.appendChild(invisibleEl); } - if (!onlyContents) - stringBuilder.push("
"); }; this.$getFoldLineTokens = function(row, foldLine) { @@ -1932,16 +2255,12 @@ define("ace/layer/cursor",[], function(require, exports, module) { "use strict"; var dom = require("../lib/dom"); -var isIE8; var Cursor = function(parentEl) { this.element = dom.createElement("div"); this.element.className = "ace_layer ace_cursor-layer"; parentEl.appendChild(this.element); - if (isIE8 === undefined) - isIE8 = !("opacity" in this.element.style); - this.isVisible = false; this.isBlinking = true; this.blinkInterval = 1000; @@ -1950,24 +2269,30 @@ var Cursor = function(parentEl) { this.cursors = []; this.cursor = this.addCursor(); dom.addCssClass(this.element, "ace_hidden-cursors"); - this.$updateCursors = (isIE8 - ? this.$updateVisibility - : this.$updateOpacity).bind(this); + this.$updateCursors = this.$updateOpacity.bind(this); }; (function() { - this.$updateVisibility = function(val) { - var cursors = this.cursors; - for (var i = cursors.length; i--; ) - cursors[i].style.visibility = val ? "" : "hidden"; - }; this.$updateOpacity = function(val) { var cursors = this.cursors; for (var i = cursors.length; i--; ) - cursors[i].style.opacity = val ? "" : "0"; + dom.setStyle(cursors[i].style, "opacity", val ? "" : "0"); + }; + + this.$startCssAnimation = function() { + var cursors = this.cursors; + for (var i = cursors.length; i--; ) + cursors[i].style.animationDuration = this.blinkInterval + "ms"; + + setTimeout(function() { + dom.addCssClass(this.element, "ace_animate-blinking"); + }.bind(this)); }; + this.$stopCssAnimation = function() { + dom.removeCssClass(this.element, "ace_animate-blinking"); + }; this.$padding = 0; this.setPadding = function(padding) { @@ -1979,25 +2304,24 @@ var Cursor = function(parentEl) { }; this.setBlinking = function(blinking) { - if (blinking != this.isBlinking){ + if (blinking != this.isBlinking) { this.isBlinking = blinking; this.restartTimer(); } }; this.setBlinkInterval = function(blinkInterval) { - if (blinkInterval != this.blinkInterval){ + if (blinkInterval != this.blinkInterval) { this.blinkInterval = blinkInterval; this.restartTimer(); } }; this.setSmoothBlinking = function(smoothBlinking) { - if (smoothBlinking != this.smoothBlinking && !isIE8) { + if (smoothBlinking != this.smoothBlinking) { this.smoothBlinking = smoothBlinking; dom.setCssClass(this.element, "ace_smooth-blinking", smoothBlinking); this.$updateCursors(true); - this.$updateCursors = (this.$updateOpacity).bind(this); this.restartTimer(); } }; @@ -2034,14 +2358,18 @@ var Cursor = function(parentEl) { var update = this.$updateCursors; clearInterval(this.intervalId); clearTimeout(this.timeoutId); + this.$stopCssAnimation(); + if (this.smoothBlinking) { dom.removeCssClass(this.element, "ace_smooth-blinking"); } update(true); - if (!this.isBlinking || !this.blinkInterval || !this.isVisible) + if (!this.isBlinking || !this.blinkInterval || !this.isVisible) { + this.$stopCssAnimation(); return; + } if (this.smoothBlinking) { setTimeout(function(){ @@ -2049,18 +2377,21 @@ var Cursor = function(parentEl) { }.bind(this)); } - var blink = function(){ - this.timeoutId = setTimeout(function() { - update(false); - }, 0.6 * this.blinkInterval); - }.bind(this); - - this.intervalId = setInterval(function() { - update(true); + if (dom.HAS_CSS_ANIMATION) { + this.$startCssAnimation(); + } else { + var blink = function(){ + this.timeoutId = setTimeout(function() { + update(false); + }, 0.6 * this.blinkInterval); + }.bind(this); + + this.intervalId = setInterval(function() { + update(true); + blink(); + }, this.blinkInterval); blink(); - }, this.blinkInterval); - - blink(); + } }; this.getPixelPosition = function(position, onScreen) { @@ -2080,6 +2411,10 @@ var Cursor = function(parentEl) { return {left : cursorLeft, top : cursorTop}; }; + this.isCursorInView = function(pixelPos, config) { + return pixelPos.top >= 0 && pixelPos.top < config.maxHeight; + }; + this.update = function(config) { this.config = config; @@ -2097,15 +2432,20 @@ var Cursor = function(parentEl) { continue; } - var style = (this.cursors[cursorIndex++] || this.addCursor()).style; + var element = this.cursors[cursorIndex++] || this.addCursor(); + var style = element.style; if (!this.drawCursor) { - style.left = pixelPos.left + "px"; - style.top = pixelPos.top + "px"; - style.width = config.characterWidth + "px"; - style.height = config.lineHeight + "px"; + if (!this.isCursorInView(pixelPos, config)) { + dom.setStyle(style, "display", "none"); + } else { + dom.setStyle(style, "display", "block"); + dom.translate(element, pixelPos.left, pixelPos.top); + dom.setStyle(style, "width", Math.round(config.characterWidth) + "px"); + dom.setStyle(style, "height", config.lineHeight + "px"); + } } else { - this.drawCursor(style, pixelPos, config, selections[i], this.session); + this.drawCursor(element, pixelPos, config, selections[i], this.session); } } while (this.cursors.length > cursorIndex) @@ -2292,20 +2632,23 @@ var RenderLoop = function(onRender, win) { (function() { - this.schedule = function(change) { this.changes = this.changes | change; - if (!this.pending && this.changes) { - this.pending = true; + if (this.changes) { var _self = this; - event.nextFrame(function() { - _self.pending = false; - var changes; - while (changes = _self.changes) { + + event.nextFrame(function(ts) { + var changes = _self.changes; + + if (changes) { + event.blockIdle(100); _self.changes = 0; _self.onRender(changes); } - }, this.window); + + if (_self.changes) + _self.schedule(); + }); } }; @@ -2319,6 +2662,7 @@ define("ace/layer/font_metrics",[], function(require, exports, module) { var oop = require("../lib/oop"); var dom = require("../lib/dom"); var lang = require("../lib/lang"); +var event = require("../lib/event"); var useragent = require("../lib/useragent"); var EventEmitter = require("../lib/event_emitter").EventEmitter; @@ -2403,8 +2747,10 @@ var FontMetrics = exports.FontMetrics = function(parentEl) { if (this.$pollSizeChangesTimer || this.$observer) return this.$pollSizeChangesTimer; var self = this; - return this.$pollSizeChangesTimer = setInterval(function() { + + return this.$pollSizeChangesTimer = event.onIdle(function cb() { self.checkForSizeChanges(); + event.onIdle(cb, 500); }, 500); }; @@ -2509,7 +2855,7 @@ var FontMetrics = exports.FontMetrics = function(parentEl) { }); -define("ace/requirejs/text!ace/css/editor.css",[],".ace_editor {\n position: relative;\n overflow: hidden;\n font: 12px/normal 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'source-code-pro', monospace;\n direction: ltr;\n text-align: left;\n -webkit-tap-highlight-color: rgba(0, 0, 0, 0);\n}\n\n.ace_scroller {\n position: absolute;\n overflow: hidden;\n top: 0;\n bottom: 0;\n background-color: inherit;\n -ms-user-select: none;\n -moz-user-select: none;\n -webkit-user-select: none;\n user-select: none;\n cursor: text;\n}\n\n.ace_content {\n position: absolute;\n box-sizing: border-box;\n min-width: 100%;\n}\n\n.ace_dragging .ace_scroller:before{\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n content: '';\n background: rgba(250, 250, 250, 0.01);\n z-index: 1000;\n}\n.ace_dragging.ace_dark .ace_scroller:before{\n background: rgba(0, 0, 0, 0.01);\n}\n\n.ace_gutter {\n position: absolute;\n overflow : hidden;\n width: auto;\n top: 0;\n bottom: 0;\n left: 0;\n cursor: default;\n z-index: 4;\n -ms-user-select: none;\n -moz-user-select: none;\n -webkit-user-select: none;\n user-select: none;\n}\n\n.ace_gutter-active-line {\n position: absolute;\n left: 0;\n right: 0;\n}\n\n.ace_scroller.ace_scroll-left {\n box-shadow: 17px 0 16px -16px rgba(0, 0, 0, 0.4) inset;\n}\n\n.ace_gutter-cell {\n padding-left: 19px;\n padding-right: 6px;\n background-repeat: no-repeat;\n}\n\n.ace_gutter-cell.ace_error {\n background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAABOFBMVEX/////////QRswFAb/Ui4wFAYwFAYwFAaWGAfDRymzOSH/PxswFAb/SiUwFAYwFAbUPRvjQiDllog5HhHdRybsTi3/Tyv9Tir+Syj/UC3////XurebMBIwFAb/RSHbPx/gUzfdwL3kzMivKBAwFAbbvbnhPx66NhowFAYwFAaZJg8wFAaxKBDZurf/RB6mMxb/SCMwFAYwFAbxQB3+RB4wFAb/Qhy4Oh+4QifbNRcwFAYwFAYwFAb/QRzdNhgwFAYwFAbav7v/Uy7oaE68MBK5LxLewr/r2NXewLswFAaxJw4wFAbkPRy2PyYwFAaxKhLm1tMwFAazPiQwFAaUGAb/QBrfOx3bvrv/VC/maE4wFAbRPBq6MRO8Qynew8Dp2tjfwb0wFAbx6eju5+by6uns4uH9/f36+vr/GkHjAAAAYnRSTlMAGt+64rnWu/bo8eAA4InH3+DwoN7j4eLi4xP99Nfg4+b+/u9B/eDs1MD1mO7+4PHg2MXa347g7vDizMLN4eG+Pv7i5evs/v79yu7S3/DV7/498Yv24eH+4ufQ3Ozu/v7+y13sRqwAAADLSURBVHjaZc/XDsFgGIBhtDrshlitmk2IrbHFqL2pvXf/+78DPokj7+Fz9qpU/9UXJIlhmPaTaQ6QPaz0mm+5gwkgovcV6GZzd5JtCQwgsxoHOvJO15kleRLAnMgHFIESUEPmawB9ngmelTtipwwfASilxOLyiV5UVUyVAfbG0cCPHig+GBkzAENHS0AstVF6bacZIOzgLmxsHbt2OecNgJC83JERmePUYq8ARGkJx6XtFsdddBQgZE2nPR6CICZhawjA4Fb/chv+399kfR+MMMDGOQAAAABJRU5ErkJggg==\");\n background-repeat: no-repeat;\n background-position: 2px center;\n}\n\n.ace_gutter-cell.ace_warning {\n background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAAmVBMVEX///8AAAD///8AAAAAAABPSzb/5sAAAAB/blH/73z/ulkAAAAAAAD85pkAAAAAAAACAgP/vGz/rkDerGbGrV7/pkQICAf////e0IsAAAD/oED/qTvhrnUAAAD/yHD/njcAAADuv2r/nz//oTj/p064oGf/zHAAAAA9Nir/tFIAAAD/tlTiuWf/tkIAAACynXEAAAAAAAAtIRW7zBpBAAAAM3RSTlMAABR1m7RXO8Ln31Z36zT+neXe5OzooRDfn+TZ4p3h2hTf4t3k3ucyrN1K5+Xaks52Sfs9CXgrAAAAjklEQVR42o3PbQ+CIBQFYEwboPhSYgoYunIqqLn6/z8uYdH8Vmdnu9vz4WwXgN/xTPRD2+sgOcZjsge/whXZgUaYYvT8QnuJaUrjrHUQreGczuEafQCO/SJTufTbroWsPgsllVhq3wJEk2jUSzX3CUEDJC84707djRc5MTAQxoLgupWRwW6UB5fS++NV8AbOZgnsC7BpEAAAAABJRU5ErkJggg==\");\n background-position: 2px center;\n}\n\n.ace_gutter-cell.ace_info {\n background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAAAAAA6mKC9AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAAJ0Uk5TAAB2k804AAAAPklEQVQY02NgIB68QuO3tiLznjAwpKTgNyDbMegwisCHZUETUZV0ZqOquBpXj2rtnpSJT1AEnnRmL2OgGgAAIKkRQap2htgAAAAASUVORK5CYII=\");\n background-position: 2px center;\n}\n.ace_dark .ace_gutter-cell.ace_info {\n background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQBAMAAADt3eJSAAAAJFBMVEUAAAChoaGAgIAqKiq+vr6tra1ZWVmUlJSbm5s8PDxubm56enrdgzg3AAAAAXRSTlMAQObYZgAAAClJREFUeNpjYMAPdsMYHegyJZFQBlsUlMFVCWUYKkAZMxZAGdxlDMQBAG+TBP4B6RyJAAAAAElFTkSuQmCC\");\n}\n\n.ace_scrollbar {\n position: absolute;\n right: 0;\n bottom: 0;\n z-index: 6;\n}\n\n.ace_scrollbar-inner {\n position: absolute;\n cursor: text;\n left: 0;\n top: 0;\n}\n\n.ace_scrollbar-v{\n overflow-x: hidden;\n overflow-y: scroll;\n top: 0;\n}\n\n.ace_scrollbar-h {\n overflow-x: scroll;\n overflow-y: hidden;\n left: 0;\n}\n\n.ace_print-margin {\n position: absolute;\n height: 100%;\n}\n\n.ace_text-input {\n position: absolute;\n z-index: 0;\n width: 0.5em;\n height: 1em;\n opacity: 0;\n background: transparent;\n -moz-appearance: none;\n appearance: none;\n border: none;\n resize: none;\n outline: none;\n overflow: hidden;\n font: inherit;\n padding: 0 1px;\n margin: 0 -1px;\n text-indent: -1em;\n -ms-user-select: text;\n -moz-user-select: text;\n -webkit-user-select: text;\n user-select: text;\n white-space: pre!important;\n}\n.ace_text-input.ace_composition {\n background: inherit;\n color: inherit;\n z-index: 1000;\n opacity: 1;\n text-indent: 0;\n}\n[ace_nocontext=true] {\n transform: none!important;\n filter: none!important;\n perspective: none!important;\n clip-path: none!important;\n mask : none!important;\n contain: none!important;\n perspective: none!important;\n mix-blend-mode: initial!important;\n z-index: auto;\n}\n\n.ace_layer {\n z-index: 1;\n position: absolute;\n overflow: hidden;\n word-wrap: normal;\n white-space: pre;\n height: 100%;\n width: 100%;\n box-sizing: border-box;\n pointer-events: none;\n}\n\n.ace_gutter-layer {\n position: relative;\n width: auto;\n text-align: right;\n pointer-events: auto;\n}\n\n.ace_text-layer {\n font: inherit !important;\n}\n\n.ace_cjk {\n display: inline-block;\n text-align: center;\n}\n\n.ace_cursor-layer {\n z-index: 4;\n}\n\n.ace_cursor {\n z-index: 4;\n position: absolute;\n box-sizing: border-box;\n border-left: 2px solid;\n transform: translatez(0);\n}\n\n.ace_multiselect .ace_cursor {\n border-left-width: 1px;\n}\n\n.ace_slim-cursors .ace_cursor {\n border-left-width: 1px;\n}\n\n.ace_overwrite-cursors .ace_cursor {\n border-left-width: 0;\n border-bottom: 1px solid;\n}\n\n.ace_hidden-cursors .ace_cursor {\n opacity: 0.2;\n}\n\n.ace_smooth-blinking .ace_cursor {\n transition: opacity 0.18s;\n}\n\n.ace_marker-layer .ace_step, .ace_marker-layer .ace_stack {\n position: absolute;\n z-index: 3;\n}\n\n.ace_marker-layer .ace_selection {\n position: absolute;\n z-index: 5;\n}\n\n.ace_marker-layer .ace_bracket {\n position: absolute;\n z-index: 6;\n}\n\n.ace_marker-layer .ace_active-line {\n position: absolute;\n z-index: 2;\n}\n\n.ace_marker-layer .ace_selected-word {\n position: absolute;\n z-index: 4;\n box-sizing: border-box;\n}\n\n.ace_line .ace_fold {\n box-sizing: border-box;\n\n display: inline-block;\n height: 11px;\n margin-top: -2px;\n vertical-align: middle;\n\n background-image:\n url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABEAAAAJCAYAAADU6McMAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAJpJREFUeNpi/P//PwOlgAXGYGRklAVSokD8GmjwY1wasKljQpYACtpCFeADcHVQfQyMQAwzwAZI3wJKvCLkfKBaMSClBlR7BOQikCFGQEErIH0VqkabiGCAqwUadAzZJRxQr/0gwiXIal8zQQPnNVTgJ1TdawL0T5gBIP1MUJNhBv2HKoQHHjqNrA4WO4zY0glyNKLT2KIfIMAAQsdgGiXvgnYAAAAASUVORK5CYII=\"),\n url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAA3CAYAAADNNiA5AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAACJJREFUeNpi+P//fxgTAwPDBxDxD078RSX+YeEyDFMCIMAAI3INmXiwf2YAAAAASUVORK5CYII=\");\n background-repeat: no-repeat, repeat-x;\n background-position: center center, top left;\n color: transparent;\n\n border: 1px solid black;\n border-radius: 2px;\n\n cursor: pointer;\n pointer-events: auto;\n}\n\n.ace_dark .ace_fold {\n}\n\n.ace_fold:hover{\n background-image:\n url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABEAAAAJCAYAAADU6McMAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAJpJREFUeNpi/P//PwOlgAXGYGRklAVSokD8GmjwY1wasKljQpYACtpCFeADcHVQfQyMQAwzwAZI3wJKvCLkfKBaMSClBlR7BOQikCFGQEErIH0VqkabiGCAqwUadAzZJRxQr/0gwiXIal8zQQPnNVTgJ1TdawL0T5gBIP1MUJNhBv2HKoQHHjqNrA4WO4zY0glyNKLT2KIfIMAAQsdgGiXvgnYAAAAASUVORK5CYII=\"),\n url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAA3CAYAAADNNiA5AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAACBJREFUeNpi+P//fz4TAwPDZxDxD5X4i5fLMEwJgAADAEPVDbjNw87ZAAAAAElFTkSuQmCC\");\n}\n\n.ace_tooltip {\n background-color: #FFF;\n background-image: linear-gradient(to bottom, transparent, rgba(0, 0, 0, 0.1));\n border: 1px solid gray;\n border-radius: 1px;\n box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);\n color: black;\n max-width: 100%;\n padding: 3px 4px;\n position: fixed;\n z-index: 999999;\n box-sizing: border-box;\n cursor: default;\n white-space: pre;\n word-wrap: break-word;\n line-height: normal;\n font-style: normal;\n font-weight: normal;\n letter-spacing: normal;\n pointer-events: none;\n}\n\n.ace_folding-enabled > .ace_gutter-cell {\n padding-right: 13px;\n}\n\n.ace_fold-widget {\n box-sizing: border-box;\n\n margin: 0 -12px 0 1px;\n display: none;\n width: 11px;\n vertical-align: top;\n\n background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAANElEQVR42mWKsQ0AMAzC8ixLlrzQjzmBiEjp0A6WwBCSPgKAXoLkqSot7nN3yMwR7pZ32NzpKkVoDBUxKAAAAABJRU5ErkJggg==\");\n background-repeat: no-repeat;\n background-position: center;\n\n border-radius: 3px;\n \n border: 1px solid transparent;\n cursor: pointer;\n}\n\n.ace_folding-enabled .ace_fold-widget {\n display: inline-block; \n}\n\n.ace_fold-widget.ace_end {\n background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAANElEQVR42m3HwQkAMAhD0YzsRchFKI7sAikeWkrxwScEB0nh5e7KTPWimZki4tYfVbX+MNl4pyZXejUO1QAAAABJRU5ErkJggg==\");\n}\n\n.ace_fold-widget.ace_closed {\n background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAMAAAAGCAYAAAAG5SQMAAAAOUlEQVR42jXKwQkAMAgDwKwqKD4EwQ26sSOkVWjgIIHAzPiCgaqiqnJHZnKICBERHN194O5b9vbLuAVRL+l0YWnZAAAAAElFTkSuQmCCXA==\");\n}\n\n.ace_fold-widget:hover {\n border: 1px solid rgba(0, 0, 0, 0.3);\n background-color: rgba(255, 255, 255, 0.2);\n box-shadow: 0 1px 1px rgba(255, 255, 255, 0.7);\n}\n\n.ace_fold-widget:active {\n border: 1px solid rgba(0, 0, 0, 0.4);\n background-color: rgba(0, 0, 0, 0.05);\n box-shadow: 0 1px 1px rgba(255, 255, 255, 0.8);\n}\n.ace_dark .ace_fold-widget {\n background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHklEQVQIW2P4//8/AzoGEQ7oGCaLLAhWiSwB146BAQCSTPYocqT0AAAAAElFTkSuQmCC\");\n}\n.ace_dark .ace_fold-widget.ace_end {\n background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAH0lEQVQIW2P4//8/AxQ7wNjIAjDMgC4AxjCVKBirIAAF0kz2rlhxpAAAAABJRU5ErkJggg==\");\n}\n.ace_dark .ace_fold-widget.ace_closed {\n background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAMAAAAFCAYAAACAcVaiAAAAHElEQVQIW2P4//+/AxAzgDADlOOAznHAKgPWAwARji8UIDTfQQAAAABJRU5ErkJggg==\");\n}\n.ace_dark .ace_fold-widget:hover {\n box-shadow: 0 1px 1px rgba(255, 255, 255, 0.2);\n background-color: rgba(255, 255, 255, 0.1);\n}\n.ace_dark .ace_fold-widget:active {\n box-shadow: 0 1px 1px rgba(255, 255, 255, 0.2);\n}\n\n.ace_inline_button {\n border: 1px solid lightgray;\n display: inline-block;\n margin: -1px 8px;\n padding: 0 5px;\n pointer-events: auto;\n cursor: pointer;\n}\n.ace_inline_button:hover {\n border-color: gray;\n background: rgba(200,200,200,0.2);\n display: inline-block;\n pointer-events: auto;\n}\n\n.ace_fold-widget.ace_invalid {\n background-color: #FFB4B4;\n border-color: #DE5555;\n}\n\n.ace_fade-fold-widgets .ace_fold-widget {\n transition: opacity 0.4s ease 0.05s;\n opacity: 0;\n}\n\n.ace_fade-fold-widgets:hover .ace_fold-widget {\n transition: opacity 0.05s ease 0.05s;\n opacity:1;\n}\n\n.ace_underline {\n text-decoration: underline;\n}\n\n.ace_bold {\n font-weight: bold;\n}\n\n.ace_nobold .ace_bold {\n font-weight: normal;\n}\n\n.ace_italic {\n font-style: italic;\n}\n\n\n.ace_error-marker {\n background-color: rgba(255, 0, 0,0.2);\n position: absolute;\n z-index: 9;\n}\n\n.ace_highlight-marker {\n background-color: rgba(255, 255, 0,0.2);\n position: absolute;\n z-index: 8;\n}\n.ace_lineWidgetContainer {\n z-index: 5;\n position: absolute;\n}\n.ace_br1 {border-top-left-radius : 3px;}\n.ace_br2 {border-top-right-radius : 3px;}\n.ace_br3 {border-top-left-radius : 3px; border-top-right-radius: 3px;}\n.ace_br4 {border-bottom-right-radius: 3px;}\n.ace_br5 {border-top-left-radius : 3px; border-bottom-right-radius: 3px;}\n.ace_br6 {border-top-right-radius : 3px; border-bottom-right-radius: 3px;}\n.ace_br7 {border-top-left-radius : 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px;}\n.ace_br8 {border-bottom-left-radius : 3px;}\n.ace_br9 {border-top-left-radius : 3px; border-bottom-left-radius: 3px;}\n.ace_br10{border-top-right-radius : 3px; border-bottom-left-radius: 3px;}\n.ace_br11{border-top-left-radius : 3px; border-top-right-radius: 3px; border-bottom-left-radius: 3px;}\n.ace_br12{border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;}\n.ace_br13{border-top-left-radius : 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;}\n.ace_br14{border-top-right-radius : 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;}\n.ace_br15{border-top-left-radius : 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;}\n\n.ace_text-input-ios {\n position: absolute !important;\n top: -100000px !important;\n left: -100000px !important;\n}\n"); +define("ace/requirejs/text!ace/css/editor.css",[],".ace_editor {\n position: relative;\n overflow: hidden;\n font: 12px/normal 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'source-code-pro', monospace;\n direction: ltr;\n text-align: left;\n -webkit-tap-highlight-color: rgba(0, 0, 0, 0);\n}\n\n.ace_scroller {\n position: absolute;\n overflow: hidden;\n top: 0;\n bottom: 0;\n background-color: inherit;\n -ms-user-select: none;\n -moz-user-select: none;\n -webkit-user-select: none;\n user-select: none;\n cursor: text;\n}\n\n.ace_content {\n position: absolute;\n box-sizing: border-box;\n min-width: 100%;\n contain: style size layout;\n}\n\n.ace_dragging .ace_scroller:before{\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n content: '';\n background: rgba(250, 250, 250, 0.01);\n z-index: 1000;\n}\n.ace_dragging.ace_dark .ace_scroller:before{\n background: rgba(0, 0, 0, 0.01);\n}\n\n.ace_gutter {\n position: absolute;\n overflow : hidden;\n width: auto;\n top: 0;\n bottom: 0;\n left: 0;\n cursor: default;\n z-index: 4;\n -ms-user-select: none;\n -moz-user-select: none;\n -webkit-user-select: none;\n user-select: none;\n contain: style size layout;\n}\n\n.ace_gutter-active-line {\n position: absolute;\n left: 0;\n right: 0;\n}\n\n.ace_scroller.ace_scroll-left {\n box-shadow: 17px 0 16px -16px rgba(0, 0, 0, 0.4) inset;\n}\n\n.ace_gutter-cell {\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n padding-left: 19px;\n padding-right: 6px;\n background-repeat: no-repeat;\n}\n\n.ace_gutter-cell.ace_error {\n background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAABOFBMVEX/////////QRswFAb/Ui4wFAYwFAYwFAaWGAfDRymzOSH/PxswFAb/SiUwFAYwFAbUPRvjQiDllog5HhHdRybsTi3/Tyv9Tir+Syj/UC3////XurebMBIwFAb/RSHbPx/gUzfdwL3kzMivKBAwFAbbvbnhPx66NhowFAYwFAaZJg8wFAaxKBDZurf/RB6mMxb/SCMwFAYwFAbxQB3+RB4wFAb/Qhy4Oh+4QifbNRcwFAYwFAYwFAb/QRzdNhgwFAYwFAbav7v/Uy7oaE68MBK5LxLewr/r2NXewLswFAaxJw4wFAbkPRy2PyYwFAaxKhLm1tMwFAazPiQwFAaUGAb/QBrfOx3bvrv/VC/maE4wFAbRPBq6MRO8Qynew8Dp2tjfwb0wFAbx6eju5+by6uns4uH9/f36+vr/GkHjAAAAYnRSTlMAGt+64rnWu/bo8eAA4InH3+DwoN7j4eLi4xP99Nfg4+b+/u9B/eDs1MD1mO7+4PHg2MXa347g7vDizMLN4eG+Pv7i5evs/v79yu7S3/DV7/498Yv24eH+4ufQ3Ozu/v7+y13sRqwAAADLSURBVHjaZc/XDsFgGIBhtDrshlitmk2IrbHFqL2pvXf/+78DPokj7+Fz9qpU/9UXJIlhmPaTaQ6QPaz0mm+5gwkgovcV6GZzd5JtCQwgsxoHOvJO15kleRLAnMgHFIESUEPmawB9ngmelTtipwwfASilxOLyiV5UVUyVAfbG0cCPHig+GBkzAENHS0AstVF6bacZIOzgLmxsHbt2OecNgJC83JERmePUYq8ARGkJx6XtFsdddBQgZE2nPR6CICZhawjA4Fb/chv+399kfR+MMMDGOQAAAABJRU5ErkJggg==\");\n background-repeat: no-repeat;\n background-position: 2px center;\n}\n\n.ace_gutter-cell.ace_warning {\n background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAAmVBMVEX///8AAAD///8AAAAAAABPSzb/5sAAAAB/blH/73z/ulkAAAAAAAD85pkAAAAAAAACAgP/vGz/rkDerGbGrV7/pkQICAf////e0IsAAAD/oED/qTvhrnUAAAD/yHD/njcAAADuv2r/nz//oTj/p064oGf/zHAAAAA9Nir/tFIAAAD/tlTiuWf/tkIAAACynXEAAAAAAAAtIRW7zBpBAAAAM3RSTlMAABR1m7RXO8Ln31Z36zT+neXe5OzooRDfn+TZ4p3h2hTf4t3k3ucyrN1K5+Xaks52Sfs9CXgrAAAAjklEQVR42o3PbQ+CIBQFYEwboPhSYgoYunIqqLn6/z8uYdH8Vmdnu9vz4WwXgN/xTPRD2+sgOcZjsge/whXZgUaYYvT8QnuJaUrjrHUQreGczuEafQCO/SJTufTbroWsPgsllVhq3wJEk2jUSzX3CUEDJC84707djRc5MTAQxoLgupWRwW6UB5fS++NV8AbOZgnsC7BpEAAAAABJRU5ErkJggg==\");\n background-position: 2px center;\n}\n\n.ace_gutter-cell.ace_info {\n background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAAAAAA6mKC9AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAAJ0Uk5TAAB2k804AAAAPklEQVQY02NgIB68QuO3tiLznjAwpKTgNyDbMegwisCHZUETUZV0ZqOquBpXj2rtnpSJT1AEnnRmL2OgGgAAIKkRQap2htgAAAAASUVORK5CYII=\");\n background-position: 2px center;\n}\n.ace_dark .ace_gutter-cell.ace_info {\n background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQBAMAAADt3eJSAAAAJFBMVEUAAAChoaGAgIAqKiq+vr6tra1ZWVmUlJSbm5s8PDxubm56enrdgzg3AAAAAXRSTlMAQObYZgAAAClJREFUeNpjYMAPdsMYHegyJZFQBlsUlMFVCWUYKkAZMxZAGdxlDMQBAG+TBP4B6RyJAAAAAElFTkSuQmCC\");\n}\n\n.ace_scrollbar {\n contain: strict;\n position: absolute;\n right: 0;\n bottom: 0;\n z-index: 6;\n}\n\n.ace_scrollbar-inner {\n position: absolute;\n cursor: text;\n left: 0;\n top: 0;\n}\n\n.ace_scrollbar-v{\n overflow-x: hidden;\n overflow-y: scroll;\n top: 0;\n}\n\n.ace_scrollbar-h {\n overflow-x: scroll;\n overflow-y: hidden;\n left: 0;\n}\n\n.ace_print-margin {\n position: absolute;\n height: 100%;\n}\n\n.ace_text-input {\n position: absolute;\n z-index: 0;\n width: 0.5em;\n height: 1em;\n opacity: 0;\n background: transparent;\n -moz-appearance: none;\n appearance: none;\n border: none;\n resize: none;\n outline: none;\n overflow: hidden;\n font: inherit;\n padding: 0 1px;\n margin: 0 -1px;\n text-indent: -1em;\n -ms-user-select: text;\n -moz-user-select: text;\n -webkit-user-select: text;\n user-select: text;\n white-space: pre!important;\n}\n.ace_text-input.ace_composition {\n background: inherit;\n color: inherit;\n z-index: 1000;\n opacity: 1;\n text-indent: 0;\n}\n[ace_nocontext=true] {\n transform: none!important;\n filter: none!important;\n perspective: none!important;\n clip-path: none!important;\n mask : none!important;\n contain: none!important;\n perspective: none!important;\n mix-blend-mode: initial!important;\n z-index: auto;\n}\n\n.ace_layer {\n z-index: 1;\n position: absolute;\n overflow: hidden;\n word-wrap: normal;\n white-space: pre;\n height: 100%;\n width: 100%;\n box-sizing: border-box;\n pointer-events: none;\n}\n\n.ace_gutter-layer {\n position: relative;\n width: auto;\n text-align: right;\n pointer-events: auto;\n height: 1000000px;\n contain: style size layout;\n}\n\n.ace_text-layer {\n font: inherit !important;\n position: absolute;\n height: 1000000px;\n width: 1000000px;\n contain: style size layout;\n}\n\n.ace_text-layer > .ace_line, .ace_text-layer > .ace_line_group {\n contain: style size layout;\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n}\n\n.ace_hidpi .ace_text-layer,\n.ace_hidpi .ace_gutter-layer,\n.ace_hidpi .ace_content,\n.ace_hidpi .ace_gutter {\n contain: strict;\n will-change: transform;\n}\n.ace_hidpi .ace_text-layer > .ace_line, \n.ace_hidpi .ace_text-layer > .ace_line_group {\n contain: strict;\n}\n\n.ace_cjk {\n display: inline-block;\n text-align: center;\n}\n\n.ace_cursor-layer {\n z-index: 4;\n}\n\n.ace_cursor {\n z-index: 4;\n position: absolute;\n box-sizing: border-box;\n border-left: 2px solid;\n transform: translatez(0);\n}\n\n.ace_multiselect .ace_cursor {\n border-left-width: 1px;\n}\n\n.ace_slim-cursors .ace_cursor {\n border-left-width: 1px;\n}\n\n.ace_overwrite-cursors .ace_cursor {\n border-left-width: 0;\n border-bottom: 1px solid;\n}\n\n.ace_hidden-cursors .ace_cursor {\n opacity: 0.2;\n}\n\n.ace_smooth-blinking .ace_cursor {\n transition: opacity 0.18s;\n}\n\n.ace_animate-blinking .ace_cursor {\n animation-duration: 1000ms;\n animation-timing-function: step-end;\n animation-name: blink-ace-animate;\n animation-iteration-count: infinite;\n}\n\n.ace_animate-blinking.ace_smooth-blinking .ace_cursor {\n animation-duration: 1000ms;\n animation-timing-function: ease-in-out;\n animation-name: blink-ace-animate-smooth;\n}\n \n@keyframes blink-ace-animate {\n from, to { opacity: 1; }\n 60% { opacity: 0; }\n}\n\n@keyframes blink-ace-animate-smooth {\n from, to { opacity: 1; }\n 45% { opacity: 1; }\n 60% { opacity: 0; }\n 85% { opacity: 0; }\n}\n\n.ace_marker-layer .ace_step, .ace_marker-layer .ace_stack {\n position: absolute;\n z-index: 3;\n}\n\n.ace_marker-layer .ace_selection {\n position: absolute;\n z-index: 5;\n}\n\n.ace_marker-layer .ace_bracket {\n position: absolute;\n z-index: 6;\n}\n\n.ace_marker-layer .ace_active-line {\n position: absolute;\n z-index: 2;\n}\n\n.ace_marker-layer .ace_selected-word {\n position: absolute;\n z-index: 4;\n box-sizing: border-box;\n}\n\n.ace_line .ace_fold {\n box-sizing: border-box;\n\n display: inline-block;\n height: 11px;\n margin-top: -2px;\n vertical-align: middle;\n\n background-image:\n url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABEAAAAJCAYAAADU6McMAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAJpJREFUeNpi/P//PwOlgAXGYGRklAVSokD8GmjwY1wasKljQpYACtpCFeADcHVQfQyMQAwzwAZI3wJKvCLkfKBaMSClBlR7BOQikCFGQEErIH0VqkabiGCAqwUadAzZJRxQr/0gwiXIal8zQQPnNVTgJ1TdawL0T5gBIP1MUJNhBv2HKoQHHjqNrA4WO4zY0glyNKLT2KIfIMAAQsdgGiXvgnYAAAAASUVORK5CYII=\"),\n url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAA3CAYAAADNNiA5AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAACJJREFUeNpi+P//fxgTAwPDBxDxD078RSX+YeEyDFMCIMAAI3INmXiwf2YAAAAASUVORK5CYII=\");\n background-repeat: no-repeat, repeat-x;\n background-position: center center, top left;\n color: transparent;\n\n border: 1px solid black;\n border-radius: 2px;\n\n cursor: pointer;\n pointer-events: auto;\n}\n\n.ace_dark .ace_fold {\n}\n\n.ace_fold:hover{\n background-image:\n url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABEAAAAJCAYAAADU6McMAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAJpJREFUeNpi/P//PwOlgAXGYGRklAVSokD8GmjwY1wasKljQpYACtpCFeADcHVQfQyMQAwzwAZI3wJKvCLkfKBaMSClBlR7BOQikCFGQEErIH0VqkabiGCAqwUadAzZJRxQr/0gwiXIal8zQQPnNVTgJ1TdawL0T5gBIP1MUJNhBv2HKoQHHjqNrA4WO4zY0glyNKLT2KIfIMAAQsdgGiXvgnYAAAAASUVORK5CYII=\"),\n url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAA3CAYAAADNNiA5AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAACBJREFUeNpi+P//fz4TAwPDZxDxD5X4i5fLMEwJgAADAEPVDbjNw87ZAAAAAElFTkSuQmCC\");\n}\n\n.ace_tooltip {\n background-color: #FFF;\n background-image: linear-gradient(to bottom, transparent, rgba(0, 0, 0, 0.1));\n border: 1px solid gray;\n border-radius: 1px;\n box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);\n color: black;\n max-width: 100%;\n padding: 3px 4px;\n position: fixed;\n z-index: 999999;\n box-sizing: border-box;\n cursor: default;\n white-space: pre;\n word-wrap: break-word;\n line-height: normal;\n font-style: normal;\n font-weight: normal;\n letter-spacing: normal;\n pointer-events: none;\n}\n\n.ace_folding-enabled > .ace_gutter-cell {\n padding-right: 13px;\n}\n\n.ace_fold-widget {\n box-sizing: border-box;\n\n margin: 0 -12px 0 1px;\n display: none;\n width: 11px;\n vertical-align: top;\n\n background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAANElEQVR42mWKsQ0AMAzC8ixLlrzQjzmBiEjp0A6WwBCSPgKAXoLkqSot7nN3yMwR7pZ32NzpKkVoDBUxKAAAAABJRU5ErkJggg==\");\n background-repeat: no-repeat;\n background-position: center;\n\n border-radius: 3px;\n \n border: 1px solid transparent;\n cursor: pointer;\n}\n\n.ace_folding-enabled .ace_fold-widget {\n display: inline-block; \n}\n\n.ace_fold-widget.ace_end {\n background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAANElEQVR42m3HwQkAMAhD0YzsRchFKI7sAikeWkrxwScEB0nh5e7KTPWimZki4tYfVbX+MNl4pyZXejUO1QAAAABJRU5ErkJggg==\");\n}\n\n.ace_fold-widget.ace_closed {\n background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAMAAAAGCAYAAAAG5SQMAAAAOUlEQVR42jXKwQkAMAgDwKwqKD4EwQ26sSOkVWjgIIHAzPiCgaqiqnJHZnKICBERHN194O5b9vbLuAVRL+l0YWnZAAAAAElFTkSuQmCCXA==\");\n}\n\n.ace_fold-widget:hover {\n border: 1px solid rgba(0, 0, 0, 0.3);\n background-color: rgba(255, 255, 255, 0.2);\n box-shadow: 0 1px 1px rgba(255, 255, 255, 0.7);\n}\n\n.ace_fold-widget:active {\n border: 1px solid rgba(0, 0, 0, 0.4);\n background-color: rgba(0, 0, 0, 0.05);\n box-shadow: 0 1px 1px rgba(255, 255, 255, 0.8);\n}\n.ace_dark .ace_fold-widget {\n background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHklEQVQIW2P4//8/AzoGEQ7oGCaLLAhWiSwB146BAQCSTPYocqT0AAAAAElFTkSuQmCC\");\n}\n.ace_dark .ace_fold-widget.ace_end {\n background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAH0lEQVQIW2P4//8/AxQ7wNjIAjDMgC4AxjCVKBirIAAF0kz2rlhxpAAAAABJRU5ErkJggg==\");\n}\n.ace_dark .ace_fold-widget.ace_closed {\n background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAMAAAAFCAYAAACAcVaiAAAAHElEQVQIW2P4//+/AxAzgDADlOOAznHAKgPWAwARji8UIDTfQQAAAABJRU5ErkJggg==\");\n}\n.ace_dark .ace_fold-widget:hover {\n box-shadow: 0 1px 1px rgba(255, 255, 255, 0.2);\n background-color: rgba(255, 255, 255, 0.1);\n}\n.ace_dark .ace_fold-widget:active {\n box-shadow: 0 1px 1px rgba(255, 255, 255, 0.2);\n}\n\n.ace_inline_button {\n border: 1px solid lightgray;\n display: inline-block;\n margin: -1px 8px;\n padding: 0 5px;\n pointer-events: auto;\n cursor: pointer;\n}\n.ace_inline_button:hover {\n border-color: gray;\n background: rgba(200,200,200,0.2);\n display: inline-block;\n pointer-events: auto;\n}\n\n.ace_fold-widget.ace_invalid {\n background-color: #FFB4B4;\n border-color: #DE5555;\n}\n\n.ace_fade-fold-widgets .ace_fold-widget {\n transition: opacity 0.4s ease 0.05s;\n opacity: 0;\n}\n\n.ace_fade-fold-widgets:hover .ace_fold-widget {\n transition: opacity 0.05s ease 0.05s;\n opacity:1;\n}\n\n.ace_underline {\n text-decoration: underline;\n}\n\n.ace_bold {\n font-weight: bold;\n}\n\n.ace_nobold .ace_bold {\n font-weight: normal;\n}\n\n.ace_italic {\n font-style: italic;\n}\n\n\n.ace_error-marker {\n background-color: rgba(255, 0, 0,0.2);\n position: absolute;\n z-index: 9;\n}\n\n.ace_highlight-marker {\n background-color: rgba(255, 255, 0,0.2);\n position: absolute;\n z-index: 8;\n}\n.ace_br1 {border-top-left-radius : 3px;}\n.ace_br2 {border-top-right-radius : 3px;}\n.ace_br3 {border-top-left-radius : 3px; border-top-right-radius: 3px;}\n.ace_br4 {border-bottom-right-radius: 3px;}\n.ace_br5 {border-top-left-radius : 3px; border-bottom-right-radius: 3px;}\n.ace_br6 {border-top-right-radius : 3px; border-bottom-right-radius: 3px;}\n.ace_br7 {border-top-left-radius : 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px;}\n.ace_br8 {border-bottom-left-radius : 3px;}\n.ace_br9 {border-top-left-radius : 3px; border-bottom-left-radius: 3px;}\n.ace_br10{border-top-right-radius : 3px; border-bottom-left-radius: 3px;}\n.ace_br11{border-top-left-radius : 3px; border-top-right-radius: 3px; border-bottom-left-radius: 3px;}\n.ace_br12{border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;}\n.ace_br13{border-top-left-radius : 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;}\n.ace_br14{border-top-right-radius : 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;}\n.ace_br15{border-top-left-radius : 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;}\n\n.ace_text-input-ios {\n position: absolute !important;\n top: -100000px !important;\n left: -100000px !important;\n}\n"); define("ace/virtual_renderer",[], function(require, exports, module) { "use strict"; @@ -2517,7 +2863,6 @@ define("ace/virtual_renderer",[], function(require, exports, module) { var oop = require("./lib/oop"); var dom = require("./lib/dom"); var config = require("./config"); -var useragent = require("./lib/useragent"); var GutterLayer = require("./layer/gutter").Gutter; var MarkerLayer = require("./layer/marker").Marker; var TextLayer = require("./layer/text").Text; @@ -2537,6 +2882,7 @@ var VirtualRenderer = function(container, theme) { this.container = container || dom.createElement("div"); dom.addCssClass(this.container, "ace_editor"); + if (dom.HI_DPI) dom.addCssClass(this.container, "ace_hidpi"); this.setTheme(theme); @@ -2547,6 +2893,7 @@ var VirtualRenderer = function(container, theme) { this.scroller = dom.createElement("div"); this.scroller.className = "ace_scroller"; + this.container.appendChild(this.scroller); this.content = dom.createElement("div"); @@ -2626,6 +2973,15 @@ var VirtualRenderer = function(container, theme) { v: 0, h: 0 }; + + this.margin = { + left: 0, + right: 0, + top: 0, + bottom: 0, + v: 0, + h: 0 + }; this.$loop = new RenderLoop( this.$renderChanges.bind(this), @@ -2683,6 +3039,7 @@ var VirtualRenderer = function(container, theme) { return; this.$loop.schedule(this.CHANGE_FULL); + this.session.$setFontMetrics(this.$fontMetrics); this.scrollBarH.scrollLeft = this.scrollBarV.scrollTop = null; this.onChangeNewLineMode = this.onChangeNewLineMode.bind(this); @@ -2809,15 +3166,17 @@ var VirtualRenderer = function(container, theme) { this.gutterWidth = gutterWidth; - this.scrollBarH.element.style.left = - this.scroller.style.left = gutterWidth + "px"; - size.scrollerWidth = Math.max(0, width - gutterWidth - this.scrollBarV.getWidth()); + dom.setStyle(this.scrollBarH.element.style, "left", gutterWidth + "px"); + dom.setStyle(this.scroller.style, "left", gutterWidth + this.margin.left + "px"); + size.scrollerWidth = Math.max(0, width - gutterWidth - this.scrollBarV.getWidth() - this.margin.h); - this.scrollBarH.element.style.right = - this.scroller.style.right = this.scrollBarV.getWidth() + "px"; - this.scroller.style.bottom = this.scrollBarH.getHeight() + "px"; - if (this.session && this.session.getUseWrapMode() && this.adjustWrapLimit() || force) + var right = this.scrollBarV.getWidth() + "px"; + dom.setStyle(this.scrollBarH.element.style, "right", right); + dom.setStyle(this.scroller.style, "right", right); + dom.setStyle(this.scroller.style, "bottom", this.scrollBarH.getHeight()); + if (this.session && this.session.getUseWrapMode() && this.adjustWrapLimit() || force) { changes |= this.CHANGE_FULL; + } } size.$dirty = !width || !height; @@ -2828,8 +3187,8 @@ var VirtualRenderer = function(container, theme) { return changes; }; - this.onGutterResize = function() { - var gutterWidth = this.$showGutter ? this.$gutter.offsetWidth : 0; + this.onGutterResize = function(width) { + var gutterWidth = this.$showGutter ? width : 0; if (gutterWidth != this.gutterWidth) this.$changes |= this.$updateCachedSize(true, gutterWidth, this.$size.width, this.$size.height); @@ -2839,7 +3198,6 @@ var VirtualRenderer = function(container, theme) { this.$loop.schedule(this.CHANGE_FULL); } else { this.$computeLayerConfig(); - this.$loop.schedule(this.CHANGE_MARKER); } }; this.adjustWrapLimit = function() { @@ -2902,19 +3260,6 @@ var VirtualRenderer = function(container, theme) { return this.getOption("highlightGutterLine"); }; - this.$updateGutterLineHighlight = function() { - var pos = this.$cursorLayer.$pixelPos; - var height = this.layerConfig.lineHeight; - if (this.session.getUseWrapMode()) { - var cursor = this.session.selection.getCursor(); - cursor.column = 0; - pos = this.$cursorLayer.getPixelPosition(cursor, true); - height *= this.session.getRowLength(cursor.row); - } - this.$gutterLineHighlight.style.top = pos.top - this.layerConfig.offset + "px"; - this.$gutterLineHighlight.style.height = height + "px"; - }; - this.$updatePrintMargin = function() { if (!this.$showPrintMargin && !this.$printMarginEl) return; @@ -2947,9 +3292,11 @@ var VirtualRenderer = function(container, theme) { this.$moveTextAreaToCursor = function() { var style = this.textarea.style; if (!this.$keepTextAreaAtCursor) { - style.left = -100 + "px"; + dom.translate(this.textarea, -100, 0); return; } + if (!this.$cursorLayer.$pixelPos) + return; var config = this.layerConfig; var posTop = this.$cursorLayer.$pixelPos.top; var posLeft = this.$cursorLayer.$pixelPos.left; @@ -2957,7 +3304,7 @@ var VirtualRenderer = function(container, theme) { var h = this.lineHeight; if (posTop < 0 || posTop > config.height - h) { - style.top = style.left = "0"; + dom.translate(this.textarea, 0, 0); return; } @@ -2971,11 +3318,10 @@ var VirtualRenderer = function(container, theme) { if (posLeft > this.$size.scrollerWidth - w) posLeft = this.$size.scrollerWidth - w; - posLeft += this.gutterWidth; - style.height = h + "px"; - style.width = w + "px"; - style.left = Math.min(posLeft, this.$size.scrollerWidth - w) + "px"; - style.top = Math.min(posTop, this.$size.height - h) + "px"; + posLeft += this.gutterWidth + this.margin.left; + dom.setStyle(style, "height", h + "px"); + dom.setStyle(style, "width", w + "px"); + dom.translate(this.textarea, Math.min(posLeft, this.$size.scrollerWidth - w), Math.min(posTop, this.$size.height - h)); }; this.getFirstVisibleRow = function() { return this.layerConfig.firstRow; @@ -3018,6 +3364,18 @@ var VirtualRenderer = function(container, theme) { this.session.setScrollTop(-sm.top); this.updateFull(); }; + + this.setMargin = function(top, bottom, left, right) { + var sm = this.margin; + sm.top = top|0; + sm.bottom = bottom|0; + sm.right = right|0; + sm.left = left|0; + sm.v = sm.top + sm.bottom; + sm.h = sm.left + sm.right; + this.$updateCachedSize(true, this.gutterWidth, this.$size.width, this.$size.height); + this.updateFull(); + }; this.getHScrollBarAlwaysVisible = function() { return this.$hScrollBarAlwaysVisible; }; @@ -3100,13 +3458,18 @@ var VirtualRenderer = function(container, theme) { this.$updateScrollBarV(); if (changes & this.CHANGE_H_SCROLL) this.$updateScrollBarH(); - this.$gutterLayer.element.style.marginTop = (-config.offset) + "px"; - this.content.style.marginTop = (-config.offset) + "px"; - this.content.style.width = config.width + 2 * this.$padding + "px"; - this.content.style.height = config.minHeight + "px"; + + dom.translate(this.$gutter, this.margin.left, -config.offset); + dom.translate(this.content, -this.scrollLeft, -config.offset); + + var width = config.width + 2 * this.$padding + "px"; + var height = config.minHeight + "px"; + + dom.setStyle(this.content.style, "width", width); + dom.setStyle(this.content.style, "height", height); } if (changes & this.CHANGE_H_SCROLL) { - this.content.style.marginLeft = -this.scrollLeft + "px"; + dom.translate(this.content, -this.scrollLeft, -config.offset); this.scroller.className = this.scrollLeft <= 0 ? "ace_scroller" : "ace_scroller ace_scroll-left"; } if (changes & this.CHANGE_FULL) { @@ -3117,7 +3480,6 @@ var VirtualRenderer = function(container, theme) { this.$markerFront.update(config); this.$cursorLayer.update(config); this.$moveTextAreaToCursor(); - this.$highlightGutterLine && this.$updateGutterLineHighlight(); this._signal("afterRender"); return; } @@ -3127,12 +3489,15 @@ var VirtualRenderer = function(container, theme) { else this.$textLayer.scrollLines(config); - if (this.$showGutter) - this.$gutterLayer.update(config); + if (this.$showGutter) { + if (changes & this.CHANGE_GUTTER || changes & this.CHANGE_LINES) + this.$gutterLayer.update(config); + else + this.$gutterLayer.scrollLines(config); + } this.$markerBack.update(config); this.$markerFront.update(config); this.$cursorLayer.update(config); - this.$highlightGutterLine && this.$updateGutterLineHighlight(); this.$moveTextAreaToCursor(); this._signal("afterRender"); return; @@ -3151,11 +3516,14 @@ var VirtualRenderer = function(container, theme) { if (this.$showGutter) this.$gutterLayer.update(config); } + else if (changes & this.CHANGE_CURSOR) { + if (this.$highlightGutterLine) + this.$gutterLayer.updateLineHighlight(config); + } if (changes & this.CHANGE_CURSOR) { this.$cursorLayer.update(config); this.$moveTextAreaToCursor(); - this.$highlightGutterLine && this.$updateGutterLineHighlight(); } if (changes & (this.CHANGE_MARKER | this.CHANGE_MARKER_FRONT)) { @@ -3180,7 +3548,9 @@ var VirtualRenderer = function(container, theme) { desiredHeight += this.scrollBarH.getHeight(); if (this.$maxPixelHeight && desiredHeight > this.$maxPixelHeight) desiredHeight = this.$maxPixelHeight; - var vScroll = height > maxHeight; + + var hideScrollbars = desiredHeight <= 2 * this.lineHeight; + var vScroll = !hideScrollbars && height > maxHeight; if (desiredHeight != this.desiredHeight || this.$size.height != this.desiredHeight || vScroll != this.$vScroll) { @@ -3525,7 +3895,7 @@ var VirtualRenderer = function(container, theme) { if (this.$hasCssTransforms) { canvasPos = {top:0, left: 0}; var p = this.$fontMetrics.transformCoordinates([x, y]); - x = p[1] - this.gutterWidth; + x = p[1] - this.gutterWidth - this.margin.left; y = p[0]; } else { canvasPos = this.scroller.getBoundingClientRect(); @@ -3544,7 +3914,7 @@ var VirtualRenderer = function(container, theme) { if (this.$hasCssTransforms) { canvasPos = {top:0, left: 0}; var p = this.$fontMetrics.transformCoordinates([x, y]); - x = p[1] - this.gutterWidth; + x = p[1] - this.gutterWidth - this.margin.left; y = p[0]; } else { canvasPos = this.scroller.getBoundingClientRect(); @@ -3554,7 +3924,7 @@ var VirtualRenderer = function(container, theme) { var offset = offsetX / this.characterWidth; var col = this.$blockCursor ? Math.floor(offset) : Math.round(offset); - var row = (y + this.scrollTop - canvasPos.top) / this.lineHeight; + var row = Math.floor((y + this.scrollTop - canvasPos.top) / this.lineHeight); return this.session.screenToDocumentPosition(row, Math.max(col, 0), offsetX); }; @@ -3660,11 +4030,10 @@ var VirtualRenderer = function(container, theme) { }; this.setCursorStyle = function(style) { - if (this.scroller.style.cursor != style) - this.scroller.style.cursor = style; + dom.setStyle(this.scroller.style, "cursor", style); }; this.setMouseCursor = function(cursorStyle) { - this.scroller.style.cursor = cursorStyle; + dom.setStyle(this.scroller.style, "cursor", cursorStyle); }; this.attachToShadowRoot = function() { @@ -3721,12 +4090,8 @@ config.defineOptions(VirtualRenderer.prototype, "renderer", { initialValue: false }, showFoldWidgets: { - set: function(show) {this.$gutterLayer.setShowFoldWidgets(show);}, - initialValue: true - }, - showLineNumbers: { set: function(show) { - this.$gutterLayer.setShowLineNumbers(show); + this.$gutterLayer.setShowFoldWidgets(show); this.$loop.schedule(this.CHANGE_GUTTER); }, initialValue: true @@ -3740,19 +4105,10 @@ config.defineOptions(VirtualRenderer.prototype, "renderer", { }, highlightGutterLine: { set: function(shouldHighlight) { - if (!this.$gutterLineHighlight) { - this.$gutterLineHighlight = dom.createElement("div"); - this.$gutterLineHighlight.className = "ace_gutter-active-line"; - this.$gutter.appendChild(this.$gutterLineHighlight); - return; - } - - this.$gutterLineHighlight.style.display = shouldHighlight ? "" : "none"; - if (this.$cursorLayer.$pixelPos) - this.$updateGutterLineHighlight(); + this.$gutterLayer.setHighlightGutterLine(shouldHighlight); + this.$loop.schedule(this.CHANGE_GUTTER); }, - initialValue: false, - value: true + initialValue: true }, hScrollBarAlwaysVisible: { set: function(val) { @@ -3768,7 +4124,7 @@ config.defineOptions(VirtualRenderer.prototype, "renderer", { }, initialValue: false }, - fontSize: { + fontSize: { set: function(size) { if (typeof size == "number") size = size + "px"; @@ -3935,8 +4291,6 @@ var AcePopup = function(parentNode) { var row = popup.getRow(); var t = popup.renderer.$textLayer; var selected = t.element.childNodes[row - t.config.firstRow]; - if (selected == t.selectedNode) - return; if (t.selectedNode) dom.removeCssClass(t.selectedNode, "ace_selected"); t.selectedNode = selected; diff --git a/build/standalone/modules/ace/ext/modelist.js b/build/standalone/modules/ace/ext/modelist.js index 31e3e0d6..fe3143fb 100644 --- a/build/standalone/modules/ace/ext/modelist.js +++ b/build/standalone/modules/ace/ext/modelist.js @@ -41,6 +41,7 @@ var supportedModes = { ADA: ["ada|adb"], Apache_Conf: ["^htaccess|^htgroups|^htpasswd|^conf|htaccess|htgroups|htpasswd"], AsciiDoc: ["asciidoc|adoc"], + ASL: ["dsl|asl"], Assembly_x86:["asm|a"], AutoHotKey: ["ahk"], BatchFile: ["bat|cmd"], diff --git a/build/standalone/modules/ace/ext/options.js b/build/standalone/modules/ace/ext/options.js index 3b71f1c2..ca433322 100644 --- a/build/standalone/modules/ace/ext/options.js +++ b/build/standalone/modules/ace/ext/options.js @@ -100,6 +100,7 @@ var supportedModes = { ADA: ["ada|adb"], Apache_Conf: ["^htaccess|^htgroups|^htpasswd|^conf|htaccess|htgroups|htpasswd"], AsciiDoc: ["asciidoc|adoc"], + ASL: ["dsl|asl"], Assembly_x86:["asm|a"], AutoHotKey: ["ahk"], BatchFile: ["bat|cmd"], @@ -273,7 +274,6 @@ module.exports = { define("ace/ext/themelist",[], function(require, exports, module) { "use strict"; -require("ace/lib/fixoldbrowsers"); var themeData = [ ["Chrome" ], @@ -461,6 +461,15 @@ var optionGroups = { "Show Gutter": { path: "showGutter" }, + "Show Line Numbers": { + path: "showLineNumbers" + }, + "Relative Line Numbers": { + path: "relativeLineNumbers" + }, + "Fixed Gutter Width": { + path: "fixedWidthGutter" + }, "Show Print Margin": [{ path: "showPrintMargin" }, { diff --git a/build/standalone/modules/ace/ext/settings_menu.js b/build/standalone/modules/ace/ext/settings_menu.js index c5e7ae61..554b7299 100644 --- a/build/standalone/modules/ace/ext/settings_menu.js +++ b/build/standalone/modules/ace/ext/settings_menu.js @@ -100,6 +100,7 @@ var supportedModes = { ADA: ["ada|adb"], Apache_Conf: ["^htaccess|^htgroups|^htpasswd|^conf|htaccess|htgroups|htpasswd"], AsciiDoc: ["asciidoc|adoc"], + ASL: ["dsl|asl"], Assembly_x86:["asm|a"], AutoHotKey: ["ahk"], BatchFile: ["bat|cmd"], @@ -273,7 +274,6 @@ module.exports = { define("ace/ext/themelist",[], function(require, exports, module) { "use strict"; -require("ace/lib/fixoldbrowsers"); var themeData = [ ["Chrome" ], @@ -461,6 +461,15 @@ var optionGroups = { "Show Gutter": { path: "showGutter" }, + "Show Line Numbers": { + path: "showLineNumbers" + }, + "Relative Line Numbers": { + path: "relativeLineNumbers" + }, + "Fixed Gutter Width": { + path: "fixedWidthGutter" + }, "Show Print Margin": [{ path: "showPrintMargin" }, { diff --git a/build/standalone/modules/ace/ext/split.js b/build/standalone/modules/ace/ext/split.js index 6c52430f..efcdc8a2 100644 --- a/build/standalone/modules/ace/ext/split.js +++ b/build/standalone/modules/ace/ext/split.js @@ -1,3 +1,128 @@ +define("ace/layer/lines",[], function(require, exports, module) { +"use strict"; + +var dom = require("../lib/dom"); + +var Lines = function(element, canvasHeight) { + this.element = element; + this.canvasHeight = canvasHeight || 500000; + this.element.style.height = (this.canvasHeight * 2) + "px"; + + this.cells = []; + this.cellCache = []; +}; + +(function() { + + this.moveContainer = function(config) { + dom.translate(this.element, 0, -((config.firstRowScreen * config.lineHeight) % this.canvasHeight)); + }; + + this.pageChanged = function(oldConfig, newConfig) { + return ( + Math.floor((oldConfig.firstRowScreen * oldConfig.lineHeight) / this.canvasHeight) !== + Math.floor((newConfig.firstRowScreen * newConfig.lineHeight) / this.canvasHeight) + ); + }; + + this.computeLineTop = function(row, config, session) { + var screenTop = config.firstRowScreen * config.lineHeight; + var screenPage = Math.floor(screenTop / this.canvasHeight); + var lineTop = session.documentToScreenRow(row, 0) * config.lineHeight; + return lineTop - (screenPage * this.canvasHeight); + }; + + this.computeLineHeight = function(row, config, session) { + return config.lineHeight * session.getRowLength(row); + }; + + this.getLength = function() { + return this.cells.length; + }; + + this.get = function(index) { + return this.cells[index]; + }; + + this.shift = function() { + this.$cacheCell(this.cells.shift()); + }; + + this.pop = function() { + this.$cacheCell(this.cells.pop()); + }; + + this.push = function(cell) { + if (Array.isArray(cell)) { + this.cells.push.apply(this.cells, cell); + var fragment = dom.createFragment(this.element); + for (var i=0; i foldStart) { row = fold.end.row + 1; @@ -109,95 +240,243 @@ var Gutter = function(parentEl) { foldStart = fold ? fold.start.row : Infinity; } if (row > lastRow) { - while (this.$cells.length > index + 1) { - cell = this.$cells.pop(); - this.element.removeChild(cell.element); - } + while (this.$lines.getLength() > index + 1) + this.$lines.pop(); + break; } - cell = this.$cells[++index]; + cell = this.$lines.get(++index); if (!cell) { - cell = {element: null, textNode: null, foldWidget: null}; - cell.element = dom.createElement("div"); - cell.textNode = document.createTextNode(''); - cell.element.appendChild(cell.textNode); - this.element.appendChild(cell.element); - this.$cells[index] = cell; + cell = this.$lines.createCell(row, config, this.session, onCreateCell); + this.$lines.push(cell); } - var className = "ace_gutter-cell "; - if (breakpoints[row]) - className += breakpoints[row]; - if (decorations[row]) - className += decorations[row]; - if (this.$annotations[row]) - className += this.$annotations[row].className; - if (cell.element.className != className) - cell.element.className = className; - - var height = session.getRowLength(row) * config.lineHeight + "px"; - if (height != cell.element.style.height) - cell.element.style.height = height; - - if (foldWidgets) { - var c = foldWidgets[row]; - if (c == null) - c = foldWidgets[row] = session.getFoldWidget(row); - } - - if (c) { - if (!cell.foldWidget) { - cell.foldWidget = dom.createElement("span"); - cell.element.appendChild(cell.foldWidget); - } - var className = "ace_fold-widget ace_" + c; - if (c == "start" && row == foldStart && row < fold.end.row) - className += " ace_closed"; - else - className += " ace_open"; - if (cell.foldWidget.className != className) - cell.foldWidget.className = className; - - var height = config.lineHeight + "px"; - if (cell.foldWidget.style.height != height) - cell.foldWidget.style.height = height; - } else { - if (cell.foldWidget) { - cell.element.removeChild(cell.foldWidget); - cell.foldWidget = null; - } - } - - var text = lastLineNumber = gutterRenderer - ? gutterRenderer.getText(session, row) - : row + firstLineNumber; - if (text !== cell.textNode.data) - cell.textNode.data = text; - + this.$renderCell(cell, config, fold, row); row++; } + + this._signal("afterRender"); + this.$updateGutterWidth(config); + }; - this.element.style.height = config.minHeight + "px"; - + this.$updateGutterWidth = function(config) { + var session = this.session; + + var gutterRenderer = session.gutterRenderer || this.$renderer; + + var firstLineNumber = session.$firstLineNumber; + var lastLineText = this.$lines.last() ? this.$lines.last().text : ""; + if (this.$fixedWidth || session.$useWrapMode) - lastLineNumber = session.getLength() + firstLineNumber; + lastLineText = session.getLength() + firstLineNumber; var gutterWidth = gutterRenderer - ? gutterRenderer.getWidth(session, lastLineNumber, config) - : lastLineNumber.toString().length * config.characterWidth; + ? gutterRenderer.getWidth(session, lastLineText, config) + : lastLineText.toString().length * config.characterWidth; var padding = this.$padding || this.$computePadding(); gutterWidth += padding.left + padding.right; if (gutterWidth !== this.gutterWidth && !isNaN(gutterWidth)) { this.gutterWidth = gutterWidth; + this.element.parentNode.style.width = this.element.style.width = Math.ceil(this.gutterWidth) + "px"; - this._emit("changeGutterWidth", gutterWidth); + this._signal("changeGutterWidth", gutterWidth); } }; + + this.$updateCursorRow = function() { + if (!this.$highlightGutterLine) + return; + + var position = this.session.selection.getCursor(); + if (this.$cursorRow === position.row) + return; + + this.$cursorRow = position.row; + }; + + this.updateLineHighlight = function() { + if (!this.$highlightGutterLine) + return; + var row = this.session.selection.cursor.row; + this.$cursorRow = row; + + if (this.$cursorCell && this.$cursorCell.row == row) + return; + if (this.$cursorCell) + this.$cursorCell.element.className = this.$cursorCell.element.className.replace("ace_gutter-active-line ", ""); + var cells = this.$lines.cells; + this.$cursorCell = null; + for (var i = 0; i < cells.length; i++) { + var cell = cells[i]; + if (cell.row >= this.$cursorRow) { + if (cell.row > this.$cursorRow) { + var fold = this.session.getFoldLine(this.$cursorRow); + if (i > 0 && fold && fold.start.row == cells[i - 1].row) + cell = cells[i - 1]; + else + break; + } + cell.element.className = "ace_gutter-active-line " + cell.element.className; + this.$cursorCell = cell; + break; + } + } + }; + + this.scrollLines = function(config) { + var oldConfig = this.config; + this.config = config; + + this.$updateCursorRow(); + if (this.$lines.pageChanged(oldConfig, config)) + return this.update(config); + + this.$lines.moveContainer(config); + + var lastRow = Math.min(config.lastRow + config.gutterOffset, // needed to compensate for hor scollbar + this.session.getLength() - 1); + var oldLastRow = this.oldLastRow; + this.oldLastRow = lastRow; + + if (!oldConfig || oldLastRow < config.firstRow) + return this.update(config); + + if (lastRow < oldConfig.firstRow) + return this.update(config); + + if (oldConfig.firstRow < config.firstRow) + for (var row=this.session.getFoldedRowCount(oldConfig.firstRow, config.firstRow - 1); row>0; row--) + this.$lines.shift(); + + if (oldLastRow > lastRow) + for (var row=this.session.getFoldedRowCount(lastRow + 1, oldLastRow); row>0; row--) + this.$lines.pop(); + + if (config.firstRow < oldConfig.firstRow) { + this.$lines.unshift(this.$renderLines(config, config.firstRow, oldConfig.firstRow - 1)); + } + + if (lastRow > oldLastRow) { + this.$lines.push(this.$renderLines(config, oldLastRow + 1, lastRow)); + } + + this.updateLineHighlight(); + + this._signal("afterRender"); + this.$updateGutterWidth(config); + }; + + this.$renderLines = function(config, firstRow, lastRow) { + var fragment = []; + var row = firstRow; + var foldLine = this.session.getNextFoldLine(row); + var foldStart = foldLine ? foldLine.start.row : Infinity; + + while (true) { + if (row > foldStart) { + row = foldLine.end.row+1; + foldLine = this.session.getNextFoldLine(row, foldLine); + foldStart = foldLine ? foldLine.start.row : Infinity; + } + if (row > lastRow) + break; + + var cell = this.$lines.createCell(row, config, this.session, onCreateCell); + this.$renderCell(cell, config, foldLine, row); + fragment.push(cell); + + row++; + } + return fragment; + }; + + this.$renderCell = function(cell, config, fold, row) { + var element = cell.element; + + var session = this.session; + + var textNode = element.childNodes[0]; + var foldWidget = element.childNodes[1]; + + var firstLineNumber = session.$firstLineNumber; + + var breakpoints = session.$breakpoints; + var decorations = session.$decorations; + var gutterRenderer = session.gutterRenderer || this.$renderer; + var foldWidgets = this.$showFoldWidgets && session.foldWidgets; + var foldStart = fold ? fold.start.row : Number.MAX_VALUE; + + var className = "ace_gutter-cell "; + if (this.$highlightGutterLine) { + if (row == this.$cursorRow || (fold && row < this.$cursorRow && row >= foldStart && this.$cursorRow <= fold.end.row)) { + className += "ace_gutter-active-line "; + if (this.$cursorCell != cell) { + if (this.$cursorCell) + this.$cursorCell.element.className = this.$cursorCell.element.className.replace("ace_gutter-active-line ", ""); + this.$cursorCell = cell; + } + } + } + + if (breakpoints[row]) + className += breakpoints[row]; + if (decorations[row]) + className += decorations[row]; + if (this.$annotations[row]) + className += this.$annotations[row].className; + if (element.className != className) + element.className = className; + + if (foldWidgets) { + var c = foldWidgets[row]; + if (c == null) + c = foldWidgets[row] = session.getFoldWidget(row); + } + + if (c) { + var className = "ace_fold-widget ace_" + c; + if (c == "start" && row == foldStart && row < fold.end.row) + className += " ace_closed"; + else + className += " ace_open"; + if (foldWidget.className != className) + foldWidget.className = className; + + var foldHeight = config.lineHeight + "px"; + dom.setStyle(foldWidget.style, "height", foldHeight); + dom.setStyle(foldWidget.style, "display", "inline-block"); + } else { + if (foldWidget) { + dom.setStyle(foldWidget.style, "display", "none"); + } + } + + var text = (gutterRenderer + ? gutterRenderer.getText(session, row) + : row + firstLineNumber).toString(); + + if (text !== textNode.data) { + textNode.data = text; + } + + dom.setStyle(cell.element.style, "height", this.$lines.computeLineHeight(row, config, session) + "px"); + dom.setStyle(cell.element.style, "top", this.$lines.computeLineTop(row, config, session) + "px"); + + cell.text = text; + cell.row = row; + return cell; + }; this.$fixedWidth = false; + this.$highlightGutterLine = true; + this.$renderer = ""; + this.setHighlightGutterLine = function(highlightGutterLine) { + this.$highlightGutterLine = highlightGutterLine; + }; + this.$showLineNumbers = true; this.$renderer = ""; this.setShowLineNumbers = function(show) { @@ -231,8 +510,10 @@ var Gutter = function(parentEl) { return {left: 0, right: 0}; var style = dom.computedStyle(this.element.firstChild); this.$padding = {}; - this.$padding.left = parseInt(style.paddingLeft) + 1 || 0; - this.$padding.right = parseInt(style.paddingRight) || 0; + this.$padding.left = (parseInt(style.borderLeftWidth) || 0) + + (parseInt(style.paddingLeft) || 0) + 1; + this.$padding.right = (parseInt(style.borderRightWidth) || 0) + + (parseInt(style.paddingRight) || 0); return this.$padding; }; @@ -247,6 +528,16 @@ var Gutter = function(parentEl) { }).call(Gutter.prototype); +function onCreateCell(element) { + var textNode = document.createTextNode(''); + element.appendChild(textNode); + + var foldWidget = dom.createElement("span"); + element.appendChild(foldWidget); + + return element; +} + exports.Gutter = Gutter; }); @@ -277,14 +568,27 @@ var Marker = function(parentEl) { this.setMarkers = function(markers) { this.markers = markers; }; + + this.elt = function(className, css) { + var x = this.i != -1 && this.element.childNodes[this.i]; + if (!x) { + x = document.createElement("div"); + this.element.appendChild(x); + this.i = -1; + } else { + this.i++; + } + x.style.cssText = css; + x.className = className; + }; this.update = function(config) { if (!config) return; this.config = config; - - var html = []; + this.i = 0; + var html; for (var key in this.markers) { var marker = this.markers[key]; @@ -299,9 +603,7 @@ var Marker = function(parentEl) { range = range.toScreenRange(this.session); if (marker.renderer) { var top = this.$getTop(range.start.row, config); - var left = this.$padding + (this.session.$bidiHandler.isBidiRow(range.start.row) - ? this.session.$bidiHandler.getPosLeft(range.start.column) - : range.start.column * config.characterWidth); + var left = this.$padding + range.start.column * config.characterWidth; marker.renderer(html, range, left, top, config); } else if (marker.type == "fullLine") { this.drawFullLineMarker(html, range, marker.clazz, config); @@ -313,14 +615,13 @@ var Marker = function(parentEl) { else this.drawMultiLineMarker(html, range, marker.clazz, config); } else { - if (this.session.$bidiHandler.isBidiRow(range.start.row)) { - this.drawBidiSingleLineMarker(html, range, marker.clazz + " ace_start" + " ace_br15", config); - } else { - this.drawSingleLineMarker(html, range, marker.clazz + " ace_start" + " ace_br15", config); - } + this.drawSingleLineMarker(html, range, marker.clazz + " ace_start" + " ace_br15", config); } } - this.element.innerHTML = html.join(""); + if (this.i !=-1) { + while (this.i < this.element.childElementCount) + this.element.removeChild(this.element.lastChild); + } }; this.$getTop = function(row, layerConfig) { @@ -338,7 +639,6 @@ var Marker = function(parentEl) { var prev = 0; var curr = 0; var next = session.getScreenLastRowColumn(row); - var clazzModified = null; var lineRange = new Range(row, range.start.column, row, curr); for (; row <= end; row++) { lineRange.start.row = lineRange.end.row = row; @@ -347,56 +647,33 @@ var Marker = function(parentEl) { prev = curr; curr = next; next = row + 1 < end ? session.getScreenLastRowColumn(row + 1) : row == end ? 0 : range.end.column; - clazzModified = clazz + (row == start ? " ace_start" : "") + " ace_br" - + getBorderClass(row == start || row == start + 1 && range.start.column, prev < curr, curr > next, row == end); - - if (this.session.$bidiHandler.isBidiRow(row)) { - this.drawBidiSingleLineMarker(stringBuilder, lineRange, clazzModified, - layerConfig, row == end ? 0 : 1, extraStyle); - } else { - this.drawSingleLineMarker(stringBuilder, lineRange, clazzModified, - layerConfig, row == end ? 0 : 1, extraStyle); - } + this.drawSingleLineMarker(stringBuilder, lineRange, + clazz + (row == start ? " ace_start" : "") + " ace_br" + + getBorderClass(row == start || row == start + 1 && range.start.column, prev < curr, curr > next, row == end), + layerConfig, row == end ? 0 : 1, extraStyle); } }; this.drawMultiLineMarker = function(stringBuilder, range, clazz, config, extraStyle) { var padding = this.$padding; - var height, top, left; + var height = config.lineHeight; + var top = this.$getTop(range.start.row, config); + var left = padding + range.start.column * config.characterWidth; extraStyle = extraStyle || ""; - if (this.session.$bidiHandler.isBidiRow(range.start.row)) { - var range1 = range.clone(); - range1.end.row = range1.start.row; - range1.end.column = this.session.getLine(range1.start.row).length; - this.drawBidiSingleLineMarker(stringBuilder, range1, clazz + " ace_br1 ace_start", config, null, extraStyle); - } else { - height = config.lineHeight; - top = this.$getTop(range.start.row, config); - left = padding + range.start.column * config.characterWidth; - stringBuilder.push( - "
" - ); - } - if (this.session.$bidiHandler.isBidiRow(range.end.row)) { - var range1 = range.clone(); - range1.start.row = range1.end.row; - range1.start.column = 0; - this.drawBidiSingleLineMarker(stringBuilder, range1, clazz + " ace_br12", config, null, extraStyle); - } else { - var width = range.end.column * config.characterWidth; - height = config.lineHeight; - top = this.$getTop(range.end.row, config); - stringBuilder.push( - "
" - ); - } + + this.elt( + clazz + " ace_br1 ace_start", + "height:"+ height+ "px;"+ "right:0;"+ "top:"+top+ "px;left:"+ left+ "px;" + (extraStyle || "") + ); + top = this.$getTop(range.end.row, config); + var width = range.end.column * config.characterWidth; + + this.elt( + clazz + " ace_br12", + "height:"+ height+ "px;"+ + "width:"+ width+ "px;"+ + "top:"+ top+ "px;"+ + "left:"+ padding+ "px;"+ (extraStyle || "") + ); height = (range.end.row - range.start.row - 1) * config.lineHeight; if (height <= 0) return; @@ -404,12 +681,12 @@ var Marker = function(parentEl) { var radiusClass = (range.start.column ? 1 : 0) | (range.end.column ? 0 : 8); - stringBuilder.push( - "
" + this.elt( + clazz + (radiusClass ? " ace_br" + radiusClass : ""), + "height:"+ height+ "px;"+ + "right:0;"+ + "top:"+ top+ "px;"+ + "left:"+ padding+ "px;"+ (extraStyle || "") ); }; this.drawSingleLineMarker = function(stringBuilder, range, clazz, config, extraLength, extraStyle) { @@ -419,28 +696,14 @@ var Marker = function(parentEl) { var top = this.$getTop(range.start.row, config); var left = this.$padding + range.start.column * config.characterWidth; - stringBuilder.push( - "
" + this.elt( + clazz, + "height:"+ height+ "px;"+ + "width:"+ width+ "px;"+ + "top:"+ top+ "px;"+ + "left:"+ left+ "px;"+ (extraStyle || "") ); }; - this.drawBidiSingleLineMarker = function(stringBuilder, range, clazz, config, extraLength, extraStyle) { - var height = config.lineHeight, top = this.$getTop(range.start.row, config), padding = this.$padding; - var selections = this.session.$bidiHandler.getSelections(range.start.column, range.end.column); - - selections.forEach(function(selection) { - stringBuilder.push( - "
" - ); - }); - }; this.drawFullLineMarker = function(stringBuilder, range, clazz, config, extraStyle) { var top = this.$getTop(range.start.row, config); @@ -448,11 +711,11 @@ var Marker = function(parentEl) { if (range.start.row != range.end.row) height += this.$getTop(range.end.row, config) - top; - stringBuilder.push( - "
" + this.elt( + clazz, + "height:"+ height+ "px;"+ + "top:"+ top+ "px;"+ + "left:0;right:0;"+ (extraStyle || "") ); }; @@ -460,11 +723,11 @@ var Marker = function(parentEl) { var top = this.$getTop(range.start.row, config); var height = config.lineHeight; - stringBuilder.push( - "
" + this.elt( + clazz, + "height:"+ height+ "px;"+ + "top:"+ top+ "px;"+ + "left:0;right:0;"+ (extraStyle || "") ); }; @@ -480,14 +743,16 @@ define("ace/layer/text",[], function(require, exports, module) { var oop = require("../lib/oop"); var dom = require("../lib/dom"); var lang = require("../lib/lang"); -var useragent = require("../lib/useragent"); +var Lines = require("./lines").Lines; var EventEmitter = require("../lib/event_emitter").EventEmitter; var Text = function(parentEl) { - this.element = dom.createElement("div"); + this.dom = dom; + this.element = this.dom.createElement("div"); this.element.className = "ace_layer ace_text-layer"; parentEl.appendChild(this.element); this.$updateEolChar = this.$updateEolChar.bind(this); + this.$lines = new Lines(this.element); }; (function() { @@ -515,7 +780,7 @@ var Text = function(parentEl) { this.setPadding = function(padding) { this.$padding = padding; - this.element.style.padding = "0 " + padding + "px"; + this.element.style.margin = "0 " + padding + "px"; }; this.getLineHeight = function() { @@ -574,11 +839,12 @@ var Text = function(parentEl) { var tabStr = this.$tabStrings = [0]; for (var i = 1; i < tabSize + 1; i++) { if (this.showInvisibles) { - tabStr.push("" - + lang.stringRepeat(this.TAB_CHAR, i) - + ""); + var span = this.dom.createElement("span"); + span.className = "ace_invisible ace_invisible_tab"; + span.textContent = lang.stringRepeat(this.TAB_CHAR, i); + tabStr.push(span); } else { - tabStr.push(lang.stringRepeat(" ", i)); + tabStr.push(this.dom.createTextNode(lang.stringRepeat(" ", i), this.element)); } } if (this.displayIndentGuides) { @@ -592,21 +858,29 @@ var Text = function(parentEl) { tabClass = " ace_invisible_tab"; var spaceContent = lang.stringRepeat(this.SPACE_CHAR, this.tabSize); var tabContent = lang.stringRepeat(this.TAB_CHAR, this.tabSize); - } else{ + } else { var spaceContent = lang.stringRepeat(" ", this.tabSize); var tabContent = spaceContent; } - this.$tabStrings[" "] = "" + spaceContent + ""; - this.$tabStrings["\t"] = "" + tabContent + ""; + var span = this.dom.createElement("span"); + span.className = className + spaceClass; + span.textContent = spaceContent; + this.$tabStrings[" "] = span; + + var span = this.dom.createElement("span"); + span.className = className + tabClass; + span.textContent = tabContent; + this.$tabStrings["\t"] = span; } }; this.updateLines = function(config, firstRow, lastRow) { if (this.config.lastRow != config.lastRow || this.config.firstRow != config.firstRow) { - this.scrollLines(config); + return this.update(config); } + this.config = config; var first = Math.max(firstRow, config.firstRow); @@ -628,6 +902,7 @@ var Text = function(parentEl) { lineElementsIdx ++; } + var heightChanged = false; var row = first; var foldLine = this.session.getNextFoldLine(row); var foldStart = foldLine ? foldLine.start.row : Infinity; @@ -643,52 +918,69 @@ var Text = function(parentEl) { var lineElement = lineElements[lineElementsIdx++]; if (lineElement) { - var html = []; + this.dom.removeChildren(lineElement); this.$renderLine( - html, row, !this.$useLineGroups(), row == foldStart ? foldLine : false + lineElement, row, row == foldStart ? foldLine : false ); - lineElement.style.height = config.lineHeight * this.session.getRowLength(row) + "px"; - lineElement.innerHTML = html.join(""); + var height = (config.lineHeight * this.session.getRowLength(row)) + "px"; + if (lineElement.style.height != height) { + heightChanged = true; + lineElement.style.height = height; + } } row++; } + if (heightChanged) { + while (lineElementsIdx < this.$lines.cells.length) { + var cell = this.$lines.cells[lineElementsIdx++]; + cell.element.style.top = this.$lines.computeLineTop(cell.row, config, this.session) + "px"; + } + } }; this.scrollLines = function(config) { var oldConfig = this.config; this.config = config; + if (this.$lines.pageChanged(oldConfig, config)) + return this.update(config); + + this.$lines.moveContainer(config); + + var lastRow = config.lastRow; + var oldLastRow = oldConfig ? oldConfig.lastRow : -1; + + if (!oldConfig || oldLastRow < config.firstRow) + return this.update(config); + + if (lastRow < oldConfig.firstRow) + return this.update(config); + if (!oldConfig || oldConfig.lastRow < config.firstRow) return this.update(config); if (config.lastRow < oldConfig.firstRow) return this.update(config); - var el = this.element; if (oldConfig.firstRow < config.firstRow) for (var row=this.session.getFoldedRowCount(oldConfig.firstRow, config.firstRow - 1); row>0; row--) - el.removeChild(el.firstChild); + this.$lines.shift(); if (oldConfig.lastRow > config.lastRow) for (var row=this.session.getFoldedRowCount(config.lastRow + 1, oldConfig.lastRow); row>0; row--) - el.removeChild(el.lastChild); + this.$lines.pop(); if (config.firstRow < oldConfig.firstRow) { - var fragment = this.$renderLinesFragment(config, config.firstRow, oldConfig.firstRow - 1); - if (el.firstChild) - el.insertBefore(fragment, el.firstChild); - else - el.appendChild(fragment); + this.$lines.unshift(this.$renderLinesFragment(config, config.firstRow, oldConfig.firstRow - 1)); } if (config.lastRow > oldConfig.lastRow) { - var fragment = this.$renderLinesFragment(config, oldConfig.lastRow + 1, config.lastRow); - el.appendChild(fragment); + this.$lines.push(this.$renderLinesFragment(config, oldConfig.lastRow + 1, config.lastRow)); } }; this.$renderLinesFragment = function(config, firstRow, lastRow) { - var fragment = this.element.ownerDocument.createDocumentFragment(); + var fragment = []; var row = firstRow; var foldLine = this.session.getNextFoldLine(row); var foldStart = foldLine ? foldLine.start.row : Infinity; @@ -702,21 +994,20 @@ var Text = function(parentEl) { if (row > lastRow) break; - var container = dom.createElement("div"); + var line = this.$lines.createCell(row, config, this.session); + + var lineEl = line.element; + this.dom.removeChildren(lineEl); + dom.setStyle(lineEl.style, "height", this.$lines.computeLineHeight(row, config, this.session) + "px"); + dom.setStyle(lineEl.style, "top", this.$lines.computeLineTop(row, config, this.session) + "px"); + this.$renderLine(lineEl, row, row == foldStart ? foldLine : false); - var html = []; - this.$renderLine(html, row, false, row == foldStart ? foldLine : false); - - container.innerHTML = html.join(""); if (this.$useLineGroups()) { - container.className = 'ace_line_group'; - fragment.appendChild(container); - container.style.height = config.lineHeight * this.session.getRowLength(row) + "px"; - + lineEl.className = "ace_line_group"; } else { - while(container.firstChild) - fragment.appendChild(container.firstChild); + lineEl.className = "ace_line"; } + fragment.push(line); row++; } @@ -724,35 +1015,18 @@ var Text = function(parentEl) { }; this.update = function(config) { + this.$lines.moveContainer(config); + this.config = config; - var html = []; - var firstRow = config.firstRow, lastRow = config.lastRow; + var firstRow = config.firstRow; + var lastRow = config.lastRow; - var row = firstRow; - var foldLine = this.session.getNextFoldLine(row); - var foldStart = foldLine ? foldLine.start.row : Infinity; - - while (true) { - if (row > foldStart) { - row = foldLine.end.row+1; - foldLine = this.session.getNextFoldLine(row, foldLine); - foldStart = foldLine ? foldLine.start.row :Infinity; - } - if (row > lastRow) - break; - - if (this.$useLineGroups()) - html.push("
"); - - this.$renderLine(html, row, false, row == foldStart ? foldLine : false); - - if (this.$useLineGroups()) - html.push("
"); // end the line group - - row++; - } - this.element.innerHTML = html.join(""); + var lines = this.$lines; + while (lines.getLength()) + lines.pop(); + + lines.push(this.$renderLinesFragment(config, firstRow, lastRow)); }; this.$textToken = { @@ -761,108 +1035,153 @@ var Text = function(parentEl) { "lparen": true }; - this.$renderToken = function(stringBuilder, screenColumn, token, value) { + this.$renderToken = function(parent, screenColumn, token, value) { var self = this; - var replaceReg = /\t|&|<|>|( +)|([\x00-\x1f\x80-\xa0\xad\u1680\u180E\u2000-\u200f\u2028\u2029\u202F\u205F\u3000\uFEFF\uFFF9-\uFFFC])|[\u1100-\u115F\u11A3-\u11A7\u11FA-\u11FF\u2329-\u232A\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u2FFB\u3000-\u303E\u3041-\u3096\u3099-\u30FF\u3105-\u312D\u3131-\u318E\u3190-\u31BA\u31C0-\u31E3\u31F0-\u321E\u3220-\u3247\u3250-\u32FE\u3300-\u4DBF\u4E00-\uA48C\uA490-\uA4C6\uA960-\uA97C\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFAFF\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE66\uFE68-\uFE6B\uFF01-\uFF60\uFFE0-\uFFE6]|[\uD800-\uDBFF][\uDC00-\uDFFF]/g; - var replaceFunc = function(c, a, b, tabIdx, idx4) { - if (a) { - return self.showInvisibles - ? "" + lang.stringRepeat(self.SPACE_CHAR, c.length) + "" - : c; - } else if (c == "&") { - return "&"; - } else if (c == "<") { - return "<"; - } else if (c == ">") { - return ">"; - } else if (c == "\t") { - var tabSize = self.session.getScreenTabSize(screenColumn + tabIdx); + var re = /(\t)|( +)|([\x00-\x1f\x80-\xa0\xad\u1680\u180E\u2000-\u200f\u2028\u2029\u202F\u205F\uFEFF\uFFF9-\uFFFC]+)|(\u3000)|([\u1100-\u115F\u11A3-\u11A7\u11FA-\u11FF\u2329-\u232A\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u2FFB\u3001-\u303E\u3041-\u3096\u3099-\u30FF\u3105-\u312D\u3131-\u318E\u3190-\u31BA\u31C0-\u31E3\u31F0-\u321E\u3220-\u3247\u3250-\u32FE\u3300-\u4DBF\u4E00-\uA48C\uA490-\uA4C6\uA960-\uA97C\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFAFF\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE66\uFE68-\uFE6B\uFF01-\uFF60\uFFE0-\uFFE6]|[\uD800-\uDBFF][\uDC00-\uDFFF])/g; + + var valueFragment = this.dom.createFragment(this.element); + + var m; + var i = 0; + while (m = re.exec(value)) { + var tab = m[1]; + var simpleSpace = m[2]; + var controlCharacter = m[3]; + var cjkSpace = m[4]; + var cjk = m[5]; + + if (!self.showInvisibles && simpleSpace) + continue; + + var before = i != m.index ? value.slice(i, m.index) : ""; + + i = m.index + m[0].length; + + if (before) { + valueFragment.appendChild(this.dom.createTextNode(before, this.element)); + } + + if (tab) { + var tabSize = self.session.getScreenTabSize(screenColumn + m.index); + valueFragment.appendChild(self.$tabStrings[tabSize].cloneNode(true)); screenColumn += tabSize - 1; - return self.$tabStrings[tabSize]; - } else if (c == "\u3000") { - var classToUse = self.showInvisibles ? "ace_cjk ace_invisible ace_invisible_space" : "ace_cjk"; + } else if (simpleSpace) { + if (self.showInvisibles) { + var span = this.dom.createElement("span"); + span.className = "ace_invisible ace_invisible_space"; + span.textContent = lang.stringRepeat(self.SPACE_CHAR, simpleSpace.length); + valueFragment.appendChild(span); + } else { + valueFragment.appendChild(this.com.createTextNode(simpleSpace, this.element)); + } + } else if (controlCharacter) { + var span = this.dom.createElement("span"); + span.className = "ace_invisible ace_invisible_space ace_invalid"; + span.textContent = lang.stringRepeat(self.SPACE_CHAR, controlCharacter.length); + valueFragment.appendChild(span); + } else if (cjkSpace) { var space = self.showInvisibles ? self.SPACE_CHAR : ""; screenColumn += 1; - return "" + space + ""; - } else if (b) { - return "" + self.SPACE_CHAR + ""; - } else { + + var span = this.dom.createElement("span"); + span.style.width = (self.config.characterWidth * 2) + "px"; + span.className = self.showInvisibles ? "ace_cjk ace_invisible ace_invisible_space" : "ace_cjk"; + span.textContent = self.showInvisibles ? self.SPACE_CHAR : ""; + valueFragment.appendChild(span); + } else if (cjk) { screenColumn += 1; - return "" + c + ""; + var span = dom.createElement("span"); + span.style.width = (self.config.characterWidth * 2) + "px"; + span.className = "ace_cjk"; + span.textContent = cjk; + valueFragment.appendChild(span); } - }; - - var output = value.replace(replaceReg, replaceFunc); + } + + valueFragment.appendChild(this.dom.createTextNode(i ? value.slice(i) : value, this.element)); if (!this.$textToken[token.type]) { var classes = "ace_" + token.type.replace(/\./g, " ace_"); - var style = ""; + var span = this.dom.createElement("span"); if (token.type == "fold") - style = " style='width:" + (token.value.length * this.config.characterWidth) + "px;' "; - stringBuilder.push("", output, ""); + span.style.width = (token.value.length * this.config.characterWidth) + "px"; + + span.className = classes; + span.appendChild(valueFragment); + + parent.appendChild(span); } else { - stringBuilder.push(output); + parent.appendChild(valueFragment); } + return screenColumn + value.length; }; - this.renderIndentGuide = function(stringBuilder, value, max) { + this.renderIndentGuide = function(parent, value, max) { var cols = value.search(this.$indentGuideRe); if (cols <= 0 || cols >= max) return value; if (value[0] == " ") { cols -= cols % this.tabSize; - stringBuilder.push(lang.stringRepeat(this.$tabStrings[" "], cols/this.tabSize)); + var count = cols/this.tabSize; + for (var i=0; i= splitChars) { screenColumn = this.$renderToken( - stringBuilder, screenColumn, + lineEl, screenColumn, token, value.substring(0, splitChars - chars) ); value = value.substring(splitChars - chars); chars = splitChars; - if (!onlyContents) { - stringBuilder.push("
", - "
" - ); - } + lineEl = this.$createLineElement(); + parent.appendChild(lineEl); - stringBuilder.push(lang.stringRepeat("\xa0", splits.indent)); + lineEl.appendChild(this.dom.createTextNode(lang.stringRepeat("\xa0", splits.indent), this.element)); split ++; screenColumn = 0; @@ -871,38 +1190,43 @@ var Text = function(parentEl) { if (value.length != 0) { chars += value.length; screenColumn = this.$renderToken( - stringBuilder, screenColumn, token, value + lineEl, screenColumn, token, value ); } } } }; - this.$renderSimpleLine = function(stringBuilder, tokens) { + this.$renderSimpleLine = function(parent, tokens) { var screenColumn = 0; var token = tokens[0]; var value = token.value; if (this.displayIndentGuides) - value = this.renderIndentGuide(stringBuilder, value); + value = this.renderIndentGuide(parent, value); if (value) - screenColumn = this.$renderToken(stringBuilder, screenColumn, token, value); + screenColumn = this.$renderToken(parent, screenColumn, token, value); for (var i = 1; i < tokens.length; i++) { token = tokens[i]; value = token.value; if (screenColumn + value.length > this.MAX_LINE_LENGTH) - return this.$renderOverflowMessage(stringBuilder, screenColumn, token, value); - screenColumn = this.$renderToken(stringBuilder, screenColumn, token, value); + return this.$renderOverflowMessage(parent, screenColumn, token, value); + screenColumn = this.$renderToken(parent, screenColumn, token, value); } }; - this.$renderOverflowMessage = function(stringBuilder, screenColumn, token, value) { - this.$renderToken(stringBuilder, screenColumn, token, + this.$renderOverflowMessage = function(parent, screenColumn, token, value) { + this.$renderToken(parent, screenColumn, token, value.slice(0, this.MAX_LINE_LENGTH - screenColumn)); - stringBuilder.push( - "<click to see more...>" - ); + + var overflowEl = this.dom.createElement("span"); + overflowEl.className = "ace_inline_button ace_keyword ace_toggle_wrap"; + overflowEl.style.position = "absolute"; + overflowEl.style.right = "0"; + overflowEl.textContent = ""; + + parent.appendChild(overflowEl); }; - this.$renderLine = function(stringBuilder, row, onlyContents, foldLine) { + this.$renderLine = function(parent, row, foldLine) { if (!foldLine && foldLine != false) foldLine = this.session.getFoldLine(row); @@ -911,36 +1235,35 @@ var Text = function(parentEl) { else var tokens = this.session.getTokens(row); - - if (!onlyContents) { - stringBuilder.push( - "
" - ); - } - + var lastLineEl = parent; if (tokens.length) { var splits = this.session.getRowSplitData(row); - if (splits && splits.length) - this.$renderWrappedLine(stringBuilder, tokens, splits, onlyContents); - else - this.$renderSimpleLine(stringBuilder, tokens); + if (splits && splits.length) { + this.$renderWrappedLine(parent, tokens, splits); + var lastLineEl = parent.lastChild; + } else { + var lastLineEl = parent; + if (this.$useLineGroups()) { + lastLineEl = this.$createLineElement(); + parent.appendChild(lastLineEl); + } + this.$renderSimpleLine(lastLineEl, tokens); + } + } else if (this.$useLineGroups()) { + lastLineEl = this.$createLineElement(); + parent.appendChild(lastLineEl); } - if (this.showInvisibles) { + if (this.showInvisibles && lastLineEl) { if (foldLine) row = foldLine.end.row; - stringBuilder.push( - "", - row == this.session.getLength() - 1 ? this.EOF_CHAR : this.EOL_CHAR, - "" - ); + var invisibleEl = this.dom.createElement("span"); + invisibleEl.className = "ace_invisible ace_invisible_eol"; + invisibleEl.textContent = row == this.session.getLength() - 1 ? this.EOF_CHAR : this.EOL_CHAR; + + lastLineEl.appendChild(invisibleEl); } - if (!onlyContents) - stringBuilder.push("
"); }; this.$getFoldLineTokens = function(row, foldLine) { @@ -1024,16 +1347,12 @@ define("ace/layer/cursor",[], function(require, exports, module) { "use strict"; var dom = require("../lib/dom"); -var isIE8; var Cursor = function(parentEl) { this.element = dom.createElement("div"); this.element.className = "ace_layer ace_cursor-layer"; parentEl.appendChild(this.element); - if (isIE8 === undefined) - isIE8 = !("opacity" in this.element.style); - this.isVisible = false; this.isBlinking = true; this.blinkInterval = 1000; @@ -1042,24 +1361,30 @@ var Cursor = function(parentEl) { this.cursors = []; this.cursor = this.addCursor(); dom.addCssClass(this.element, "ace_hidden-cursors"); - this.$updateCursors = (isIE8 - ? this.$updateVisibility - : this.$updateOpacity).bind(this); + this.$updateCursors = this.$updateOpacity.bind(this); }; (function() { - this.$updateVisibility = function(val) { - var cursors = this.cursors; - for (var i = cursors.length; i--; ) - cursors[i].style.visibility = val ? "" : "hidden"; - }; this.$updateOpacity = function(val) { var cursors = this.cursors; for (var i = cursors.length; i--; ) - cursors[i].style.opacity = val ? "" : "0"; + dom.setStyle(cursors[i].style, "opacity", val ? "" : "0"); + }; + + this.$startCssAnimation = function() { + var cursors = this.cursors; + for (var i = cursors.length; i--; ) + cursors[i].style.animationDuration = this.blinkInterval + "ms"; + + setTimeout(function() { + dom.addCssClass(this.element, "ace_animate-blinking"); + }.bind(this)); }; + this.$stopCssAnimation = function() { + dom.removeCssClass(this.element, "ace_animate-blinking"); + }; this.$padding = 0; this.setPadding = function(padding) { @@ -1071,25 +1396,24 @@ var Cursor = function(parentEl) { }; this.setBlinking = function(blinking) { - if (blinking != this.isBlinking){ + if (blinking != this.isBlinking) { this.isBlinking = blinking; this.restartTimer(); } }; this.setBlinkInterval = function(blinkInterval) { - if (blinkInterval != this.blinkInterval){ + if (blinkInterval != this.blinkInterval) { this.blinkInterval = blinkInterval; this.restartTimer(); } }; this.setSmoothBlinking = function(smoothBlinking) { - if (smoothBlinking != this.smoothBlinking && !isIE8) { + if (smoothBlinking != this.smoothBlinking) { this.smoothBlinking = smoothBlinking; dom.setCssClass(this.element, "ace_smooth-blinking", smoothBlinking); this.$updateCursors(true); - this.$updateCursors = (this.$updateOpacity).bind(this); this.restartTimer(); } }; @@ -1126,14 +1450,18 @@ var Cursor = function(parentEl) { var update = this.$updateCursors; clearInterval(this.intervalId); clearTimeout(this.timeoutId); + this.$stopCssAnimation(); + if (this.smoothBlinking) { dom.removeCssClass(this.element, "ace_smooth-blinking"); } update(true); - if (!this.isBlinking || !this.blinkInterval || !this.isVisible) + if (!this.isBlinking || !this.blinkInterval || !this.isVisible) { + this.$stopCssAnimation(); return; + } if (this.smoothBlinking) { setTimeout(function(){ @@ -1141,18 +1469,21 @@ var Cursor = function(parentEl) { }.bind(this)); } - var blink = function(){ - this.timeoutId = setTimeout(function() { - update(false); - }, 0.6 * this.blinkInterval); - }.bind(this); - - this.intervalId = setInterval(function() { - update(true); + if (dom.HAS_CSS_ANIMATION) { + this.$startCssAnimation(); + } else { + var blink = function(){ + this.timeoutId = setTimeout(function() { + update(false); + }, 0.6 * this.blinkInterval); + }.bind(this); + + this.intervalId = setInterval(function() { + update(true); + blink(); + }, this.blinkInterval); blink(); - }, this.blinkInterval); - - blink(); + } }; this.getPixelPosition = function(position, onScreen) { @@ -1172,6 +1503,10 @@ var Cursor = function(parentEl) { return {left : cursorLeft, top : cursorTop}; }; + this.isCursorInView = function(pixelPos, config) { + return pixelPos.top >= 0 && pixelPos.top < config.maxHeight; + }; + this.update = function(config) { this.config = config; @@ -1189,15 +1524,20 @@ var Cursor = function(parentEl) { continue; } - var style = (this.cursors[cursorIndex++] || this.addCursor()).style; + var element = this.cursors[cursorIndex++] || this.addCursor(); + var style = element.style; if (!this.drawCursor) { - style.left = pixelPos.left + "px"; - style.top = pixelPos.top + "px"; - style.width = config.characterWidth + "px"; - style.height = config.lineHeight + "px"; + if (!this.isCursorInView(pixelPos, config)) { + dom.setStyle(style, "display", "none"); + } else { + dom.setStyle(style, "display", "block"); + dom.translate(element, pixelPos.left, pixelPos.top); + dom.setStyle(style, "width", Math.round(config.characterWidth) + "px"); + dom.setStyle(style, "height", config.lineHeight + "px"); + } } else { - this.drawCursor(style, pixelPos, config, selections[i], this.session); + this.drawCursor(element, pixelPos, config, selections[i], this.session); } } while (this.cursors.length > cursorIndex) @@ -1384,20 +1724,23 @@ var RenderLoop = function(onRender, win) { (function() { - this.schedule = function(change) { this.changes = this.changes | change; - if (!this.pending && this.changes) { - this.pending = true; + if (this.changes) { var _self = this; - event.nextFrame(function() { - _self.pending = false; - var changes; - while (changes = _self.changes) { + + event.nextFrame(function(ts) { + var changes = _self.changes; + + if (changes) { + event.blockIdle(100); _self.changes = 0; _self.onRender(changes); } - }, this.window); + + if (_self.changes) + _self.schedule(); + }); } }; @@ -1411,6 +1754,7 @@ define("ace/layer/font_metrics",[], function(require, exports, module) { var oop = require("../lib/oop"); var dom = require("../lib/dom"); var lang = require("../lib/lang"); +var event = require("../lib/event"); var useragent = require("../lib/useragent"); var EventEmitter = require("../lib/event_emitter").EventEmitter; @@ -1495,8 +1839,10 @@ var FontMetrics = exports.FontMetrics = function(parentEl) { if (this.$pollSizeChangesTimer || this.$observer) return this.$pollSizeChangesTimer; var self = this; - return this.$pollSizeChangesTimer = setInterval(function() { + + return this.$pollSizeChangesTimer = event.onIdle(function cb() { self.checkForSizeChanges(); + event.onIdle(cb, 500); }, 500); }; @@ -1601,7 +1947,7 @@ var FontMetrics = exports.FontMetrics = function(parentEl) { }); -define("ace/requirejs/text!ace/css/editor.css",[],".ace_editor {\n position: relative;\n overflow: hidden;\n font: 12px/normal 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'source-code-pro', monospace;\n direction: ltr;\n text-align: left;\n -webkit-tap-highlight-color: rgba(0, 0, 0, 0);\n}\n\n.ace_scroller {\n position: absolute;\n overflow: hidden;\n top: 0;\n bottom: 0;\n background-color: inherit;\n -ms-user-select: none;\n -moz-user-select: none;\n -webkit-user-select: none;\n user-select: none;\n cursor: text;\n}\n\n.ace_content {\n position: absolute;\n box-sizing: border-box;\n min-width: 100%;\n}\n\n.ace_dragging .ace_scroller:before{\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n content: '';\n background: rgba(250, 250, 250, 0.01);\n z-index: 1000;\n}\n.ace_dragging.ace_dark .ace_scroller:before{\n background: rgba(0, 0, 0, 0.01);\n}\n\n.ace_gutter {\n position: absolute;\n overflow : hidden;\n width: auto;\n top: 0;\n bottom: 0;\n left: 0;\n cursor: default;\n z-index: 4;\n -ms-user-select: none;\n -moz-user-select: none;\n -webkit-user-select: none;\n user-select: none;\n}\n\n.ace_gutter-active-line {\n position: absolute;\n left: 0;\n right: 0;\n}\n\n.ace_scroller.ace_scroll-left {\n box-shadow: 17px 0 16px -16px rgba(0, 0, 0, 0.4) inset;\n}\n\n.ace_gutter-cell {\n padding-left: 19px;\n padding-right: 6px;\n background-repeat: no-repeat;\n}\n\n.ace_gutter-cell.ace_error {\n background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAABOFBMVEX/////////QRswFAb/Ui4wFAYwFAYwFAaWGAfDRymzOSH/PxswFAb/SiUwFAYwFAbUPRvjQiDllog5HhHdRybsTi3/Tyv9Tir+Syj/UC3////XurebMBIwFAb/RSHbPx/gUzfdwL3kzMivKBAwFAbbvbnhPx66NhowFAYwFAaZJg8wFAaxKBDZurf/RB6mMxb/SCMwFAYwFAbxQB3+RB4wFAb/Qhy4Oh+4QifbNRcwFAYwFAYwFAb/QRzdNhgwFAYwFAbav7v/Uy7oaE68MBK5LxLewr/r2NXewLswFAaxJw4wFAbkPRy2PyYwFAaxKhLm1tMwFAazPiQwFAaUGAb/QBrfOx3bvrv/VC/maE4wFAbRPBq6MRO8Qynew8Dp2tjfwb0wFAbx6eju5+by6uns4uH9/f36+vr/GkHjAAAAYnRSTlMAGt+64rnWu/bo8eAA4InH3+DwoN7j4eLi4xP99Nfg4+b+/u9B/eDs1MD1mO7+4PHg2MXa347g7vDizMLN4eG+Pv7i5evs/v79yu7S3/DV7/498Yv24eH+4ufQ3Ozu/v7+y13sRqwAAADLSURBVHjaZc/XDsFgGIBhtDrshlitmk2IrbHFqL2pvXf/+78DPokj7+Fz9qpU/9UXJIlhmPaTaQ6QPaz0mm+5gwkgovcV6GZzd5JtCQwgsxoHOvJO15kleRLAnMgHFIESUEPmawB9ngmelTtipwwfASilxOLyiV5UVUyVAfbG0cCPHig+GBkzAENHS0AstVF6bacZIOzgLmxsHbt2OecNgJC83JERmePUYq8ARGkJx6XtFsdddBQgZE2nPR6CICZhawjA4Fb/chv+399kfR+MMMDGOQAAAABJRU5ErkJggg==\");\n background-repeat: no-repeat;\n background-position: 2px center;\n}\n\n.ace_gutter-cell.ace_warning {\n background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAAmVBMVEX///8AAAD///8AAAAAAABPSzb/5sAAAAB/blH/73z/ulkAAAAAAAD85pkAAAAAAAACAgP/vGz/rkDerGbGrV7/pkQICAf////e0IsAAAD/oED/qTvhrnUAAAD/yHD/njcAAADuv2r/nz//oTj/p064oGf/zHAAAAA9Nir/tFIAAAD/tlTiuWf/tkIAAACynXEAAAAAAAAtIRW7zBpBAAAAM3RSTlMAABR1m7RXO8Ln31Z36zT+neXe5OzooRDfn+TZ4p3h2hTf4t3k3ucyrN1K5+Xaks52Sfs9CXgrAAAAjklEQVR42o3PbQ+CIBQFYEwboPhSYgoYunIqqLn6/z8uYdH8Vmdnu9vz4WwXgN/xTPRD2+sgOcZjsge/whXZgUaYYvT8QnuJaUrjrHUQreGczuEafQCO/SJTufTbroWsPgsllVhq3wJEk2jUSzX3CUEDJC84707djRc5MTAQxoLgupWRwW6UB5fS++NV8AbOZgnsC7BpEAAAAABJRU5ErkJggg==\");\n background-position: 2px center;\n}\n\n.ace_gutter-cell.ace_info {\n background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAAAAAA6mKC9AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAAJ0Uk5TAAB2k804AAAAPklEQVQY02NgIB68QuO3tiLznjAwpKTgNyDbMegwisCHZUETUZV0ZqOquBpXj2rtnpSJT1AEnnRmL2OgGgAAIKkRQap2htgAAAAASUVORK5CYII=\");\n background-position: 2px center;\n}\n.ace_dark .ace_gutter-cell.ace_info {\n background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQBAMAAADt3eJSAAAAJFBMVEUAAAChoaGAgIAqKiq+vr6tra1ZWVmUlJSbm5s8PDxubm56enrdgzg3AAAAAXRSTlMAQObYZgAAAClJREFUeNpjYMAPdsMYHegyJZFQBlsUlMFVCWUYKkAZMxZAGdxlDMQBAG+TBP4B6RyJAAAAAElFTkSuQmCC\");\n}\n\n.ace_scrollbar {\n position: absolute;\n right: 0;\n bottom: 0;\n z-index: 6;\n}\n\n.ace_scrollbar-inner {\n position: absolute;\n cursor: text;\n left: 0;\n top: 0;\n}\n\n.ace_scrollbar-v{\n overflow-x: hidden;\n overflow-y: scroll;\n top: 0;\n}\n\n.ace_scrollbar-h {\n overflow-x: scroll;\n overflow-y: hidden;\n left: 0;\n}\n\n.ace_print-margin {\n position: absolute;\n height: 100%;\n}\n\n.ace_text-input {\n position: absolute;\n z-index: 0;\n width: 0.5em;\n height: 1em;\n opacity: 0;\n background: transparent;\n -moz-appearance: none;\n appearance: none;\n border: none;\n resize: none;\n outline: none;\n overflow: hidden;\n font: inherit;\n padding: 0 1px;\n margin: 0 -1px;\n text-indent: -1em;\n -ms-user-select: text;\n -moz-user-select: text;\n -webkit-user-select: text;\n user-select: text;\n white-space: pre!important;\n}\n.ace_text-input.ace_composition {\n background: inherit;\n color: inherit;\n z-index: 1000;\n opacity: 1;\n text-indent: 0;\n}\n[ace_nocontext=true] {\n transform: none!important;\n filter: none!important;\n perspective: none!important;\n clip-path: none!important;\n mask : none!important;\n contain: none!important;\n perspective: none!important;\n mix-blend-mode: initial!important;\n z-index: auto;\n}\n\n.ace_layer {\n z-index: 1;\n position: absolute;\n overflow: hidden;\n word-wrap: normal;\n white-space: pre;\n height: 100%;\n width: 100%;\n box-sizing: border-box;\n pointer-events: none;\n}\n\n.ace_gutter-layer {\n position: relative;\n width: auto;\n text-align: right;\n pointer-events: auto;\n}\n\n.ace_text-layer {\n font: inherit !important;\n}\n\n.ace_cjk {\n display: inline-block;\n text-align: center;\n}\n\n.ace_cursor-layer {\n z-index: 4;\n}\n\n.ace_cursor {\n z-index: 4;\n position: absolute;\n box-sizing: border-box;\n border-left: 2px solid;\n transform: translatez(0);\n}\n\n.ace_multiselect .ace_cursor {\n border-left-width: 1px;\n}\n\n.ace_slim-cursors .ace_cursor {\n border-left-width: 1px;\n}\n\n.ace_overwrite-cursors .ace_cursor {\n border-left-width: 0;\n border-bottom: 1px solid;\n}\n\n.ace_hidden-cursors .ace_cursor {\n opacity: 0.2;\n}\n\n.ace_smooth-blinking .ace_cursor {\n transition: opacity 0.18s;\n}\n\n.ace_marker-layer .ace_step, .ace_marker-layer .ace_stack {\n position: absolute;\n z-index: 3;\n}\n\n.ace_marker-layer .ace_selection {\n position: absolute;\n z-index: 5;\n}\n\n.ace_marker-layer .ace_bracket {\n position: absolute;\n z-index: 6;\n}\n\n.ace_marker-layer .ace_active-line {\n position: absolute;\n z-index: 2;\n}\n\n.ace_marker-layer .ace_selected-word {\n position: absolute;\n z-index: 4;\n box-sizing: border-box;\n}\n\n.ace_line .ace_fold {\n box-sizing: border-box;\n\n display: inline-block;\n height: 11px;\n margin-top: -2px;\n vertical-align: middle;\n\n background-image:\n url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABEAAAAJCAYAAADU6McMAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAJpJREFUeNpi/P//PwOlgAXGYGRklAVSokD8GmjwY1wasKljQpYACtpCFeADcHVQfQyMQAwzwAZI3wJKvCLkfKBaMSClBlR7BOQikCFGQEErIH0VqkabiGCAqwUadAzZJRxQr/0gwiXIal8zQQPnNVTgJ1TdawL0T5gBIP1MUJNhBv2HKoQHHjqNrA4WO4zY0glyNKLT2KIfIMAAQsdgGiXvgnYAAAAASUVORK5CYII=\"),\n url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAA3CAYAAADNNiA5AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAACJJREFUeNpi+P//fxgTAwPDBxDxD078RSX+YeEyDFMCIMAAI3INmXiwf2YAAAAASUVORK5CYII=\");\n background-repeat: no-repeat, repeat-x;\n background-position: center center, top left;\n color: transparent;\n\n border: 1px solid black;\n border-radius: 2px;\n\n cursor: pointer;\n pointer-events: auto;\n}\n\n.ace_dark .ace_fold {\n}\n\n.ace_fold:hover{\n background-image:\n url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABEAAAAJCAYAAADU6McMAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAJpJREFUeNpi/P//PwOlgAXGYGRklAVSokD8GmjwY1wasKljQpYACtpCFeADcHVQfQyMQAwzwAZI3wJKvCLkfKBaMSClBlR7BOQikCFGQEErIH0VqkabiGCAqwUadAzZJRxQr/0gwiXIal8zQQPnNVTgJ1TdawL0T5gBIP1MUJNhBv2HKoQHHjqNrA4WO4zY0glyNKLT2KIfIMAAQsdgGiXvgnYAAAAASUVORK5CYII=\"),\n url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAA3CAYAAADNNiA5AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAACBJREFUeNpi+P//fz4TAwPDZxDxD5X4i5fLMEwJgAADAEPVDbjNw87ZAAAAAElFTkSuQmCC\");\n}\n\n.ace_tooltip {\n background-color: #FFF;\n background-image: linear-gradient(to bottom, transparent, rgba(0, 0, 0, 0.1));\n border: 1px solid gray;\n border-radius: 1px;\n box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);\n color: black;\n max-width: 100%;\n padding: 3px 4px;\n position: fixed;\n z-index: 999999;\n box-sizing: border-box;\n cursor: default;\n white-space: pre;\n word-wrap: break-word;\n line-height: normal;\n font-style: normal;\n font-weight: normal;\n letter-spacing: normal;\n pointer-events: none;\n}\n\n.ace_folding-enabled > .ace_gutter-cell {\n padding-right: 13px;\n}\n\n.ace_fold-widget {\n box-sizing: border-box;\n\n margin: 0 -12px 0 1px;\n display: none;\n width: 11px;\n vertical-align: top;\n\n background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAANElEQVR42mWKsQ0AMAzC8ixLlrzQjzmBiEjp0A6WwBCSPgKAXoLkqSot7nN3yMwR7pZ32NzpKkVoDBUxKAAAAABJRU5ErkJggg==\");\n background-repeat: no-repeat;\n background-position: center;\n\n border-radius: 3px;\n \n border: 1px solid transparent;\n cursor: pointer;\n}\n\n.ace_folding-enabled .ace_fold-widget {\n display: inline-block; \n}\n\n.ace_fold-widget.ace_end {\n background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAANElEQVR42m3HwQkAMAhD0YzsRchFKI7sAikeWkrxwScEB0nh5e7KTPWimZki4tYfVbX+MNl4pyZXejUO1QAAAABJRU5ErkJggg==\");\n}\n\n.ace_fold-widget.ace_closed {\n background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAMAAAAGCAYAAAAG5SQMAAAAOUlEQVR42jXKwQkAMAgDwKwqKD4EwQ26sSOkVWjgIIHAzPiCgaqiqnJHZnKICBERHN194O5b9vbLuAVRL+l0YWnZAAAAAElFTkSuQmCCXA==\");\n}\n\n.ace_fold-widget:hover {\n border: 1px solid rgba(0, 0, 0, 0.3);\n background-color: rgba(255, 255, 255, 0.2);\n box-shadow: 0 1px 1px rgba(255, 255, 255, 0.7);\n}\n\n.ace_fold-widget:active {\n border: 1px solid rgba(0, 0, 0, 0.4);\n background-color: rgba(0, 0, 0, 0.05);\n box-shadow: 0 1px 1px rgba(255, 255, 255, 0.8);\n}\n.ace_dark .ace_fold-widget {\n background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHklEQVQIW2P4//8/AzoGEQ7oGCaLLAhWiSwB146BAQCSTPYocqT0AAAAAElFTkSuQmCC\");\n}\n.ace_dark .ace_fold-widget.ace_end {\n background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAH0lEQVQIW2P4//8/AxQ7wNjIAjDMgC4AxjCVKBirIAAF0kz2rlhxpAAAAABJRU5ErkJggg==\");\n}\n.ace_dark .ace_fold-widget.ace_closed {\n background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAMAAAAFCAYAAACAcVaiAAAAHElEQVQIW2P4//+/AxAzgDADlOOAznHAKgPWAwARji8UIDTfQQAAAABJRU5ErkJggg==\");\n}\n.ace_dark .ace_fold-widget:hover {\n box-shadow: 0 1px 1px rgba(255, 255, 255, 0.2);\n background-color: rgba(255, 255, 255, 0.1);\n}\n.ace_dark .ace_fold-widget:active {\n box-shadow: 0 1px 1px rgba(255, 255, 255, 0.2);\n}\n\n.ace_inline_button {\n border: 1px solid lightgray;\n display: inline-block;\n margin: -1px 8px;\n padding: 0 5px;\n pointer-events: auto;\n cursor: pointer;\n}\n.ace_inline_button:hover {\n border-color: gray;\n background: rgba(200,200,200,0.2);\n display: inline-block;\n pointer-events: auto;\n}\n\n.ace_fold-widget.ace_invalid {\n background-color: #FFB4B4;\n border-color: #DE5555;\n}\n\n.ace_fade-fold-widgets .ace_fold-widget {\n transition: opacity 0.4s ease 0.05s;\n opacity: 0;\n}\n\n.ace_fade-fold-widgets:hover .ace_fold-widget {\n transition: opacity 0.05s ease 0.05s;\n opacity:1;\n}\n\n.ace_underline {\n text-decoration: underline;\n}\n\n.ace_bold {\n font-weight: bold;\n}\n\n.ace_nobold .ace_bold {\n font-weight: normal;\n}\n\n.ace_italic {\n font-style: italic;\n}\n\n\n.ace_error-marker {\n background-color: rgba(255, 0, 0,0.2);\n position: absolute;\n z-index: 9;\n}\n\n.ace_highlight-marker {\n background-color: rgba(255, 255, 0,0.2);\n position: absolute;\n z-index: 8;\n}\n.ace_lineWidgetContainer {\n z-index: 5;\n position: absolute;\n}\n.ace_br1 {border-top-left-radius : 3px;}\n.ace_br2 {border-top-right-radius : 3px;}\n.ace_br3 {border-top-left-radius : 3px; border-top-right-radius: 3px;}\n.ace_br4 {border-bottom-right-radius: 3px;}\n.ace_br5 {border-top-left-radius : 3px; border-bottom-right-radius: 3px;}\n.ace_br6 {border-top-right-radius : 3px; border-bottom-right-radius: 3px;}\n.ace_br7 {border-top-left-radius : 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px;}\n.ace_br8 {border-bottom-left-radius : 3px;}\n.ace_br9 {border-top-left-radius : 3px; border-bottom-left-radius: 3px;}\n.ace_br10{border-top-right-radius : 3px; border-bottom-left-radius: 3px;}\n.ace_br11{border-top-left-radius : 3px; border-top-right-radius: 3px; border-bottom-left-radius: 3px;}\n.ace_br12{border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;}\n.ace_br13{border-top-left-radius : 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;}\n.ace_br14{border-top-right-radius : 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;}\n.ace_br15{border-top-left-radius : 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;}\n\n.ace_text-input-ios {\n position: absolute !important;\n top: -100000px !important;\n left: -100000px !important;\n}\n"); +define("ace/requirejs/text!ace/css/editor.css",[],".ace_editor {\n position: relative;\n overflow: hidden;\n font: 12px/normal 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'source-code-pro', monospace;\n direction: ltr;\n text-align: left;\n -webkit-tap-highlight-color: rgba(0, 0, 0, 0);\n}\n\n.ace_scroller {\n position: absolute;\n overflow: hidden;\n top: 0;\n bottom: 0;\n background-color: inherit;\n -ms-user-select: none;\n -moz-user-select: none;\n -webkit-user-select: none;\n user-select: none;\n cursor: text;\n}\n\n.ace_content {\n position: absolute;\n box-sizing: border-box;\n min-width: 100%;\n contain: style size layout;\n}\n\n.ace_dragging .ace_scroller:before{\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n content: '';\n background: rgba(250, 250, 250, 0.01);\n z-index: 1000;\n}\n.ace_dragging.ace_dark .ace_scroller:before{\n background: rgba(0, 0, 0, 0.01);\n}\n\n.ace_gutter {\n position: absolute;\n overflow : hidden;\n width: auto;\n top: 0;\n bottom: 0;\n left: 0;\n cursor: default;\n z-index: 4;\n -ms-user-select: none;\n -moz-user-select: none;\n -webkit-user-select: none;\n user-select: none;\n contain: style size layout;\n}\n\n.ace_gutter-active-line {\n position: absolute;\n left: 0;\n right: 0;\n}\n\n.ace_scroller.ace_scroll-left {\n box-shadow: 17px 0 16px -16px rgba(0, 0, 0, 0.4) inset;\n}\n\n.ace_gutter-cell {\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n padding-left: 19px;\n padding-right: 6px;\n background-repeat: no-repeat;\n}\n\n.ace_gutter-cell.ace_error {\n background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAABOFBMVEX/////////QRswFAb/Ui4wFAYwFAYwFAaWGAfDRymzOSH/PxswFAb/SiUwFAYwFAbUPRvjQiDllog5HhHdRybsTi3/Tyv9Tir+Syj/UC3////XurebMBIwFAb/RSHbPx/gUzfdwL3kzMivKBAwFAbbvbnhPx66NhowFAYwFAaZJg8wFAaxKBDZurf/RB6mMxb/SCMwFAYwFAbxQB3+RB4wFAb/Qhy4Oh+4QifbNRcwFAYwFAYwFAb/QRzdNhgwFAYwFAbav7v/Uy7oaE68MBK5LxLewr/r2NXewLswFAaxJw4wFAbkPRy2PyYwFAaxKhLm1tMwFAazPiQwFAaUGAb/QBrfOx3bvrv/VC/maE4wFAbRPBq6MRO8Qynew8Dp2tjfwb0wFAbx6eju5+by6uns4uH9/f36+vr/GkHjAAAAYnRSTlMAGt+64rnWu/bo8eAA4InH3+DwoN7j4eLi4xP99Nfg4+b+/u9B/eDs1MD1mO7+4PHg2MXa347g7vDizMLN4eG+Pv7i5evs/v79yu7S3/DV7/498Yv24eH+4ufQ3Ozu/v7+y13sRqwAAADLSURBVHjaZc/XDsFgGIBhtDrshlitmk2IrbHFqL2pvXf/+78DPokj7+Fz9qpU/9UXJIlhmPaTaQ6QPaz0mm+5gwkgovcV6GZzd5JtCQwgsxoHOvJO15kleRLAnMgHFIESUEPmawB9ngmelTtipwwfASilxOLyiV5UVUyVAfbG0cCPHig+GBkzAENHS0AstVF6bacZIOzgLmxsHbt2OecNgJC83JERmePUYq8ARGkJx6XtFsdddBQgZE2nPR6CICZhawjA4Fb/chv+399kfR+MMMDGOQAAAABJRU5ErkJggg==\");\n background-repeat: no-repeat;\n background-position: 2px center;\n}\n\n.ace_gutter-cell.ace_warning {\n background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAAmVBMVEX///8AAAD///8AAAAAAABPSzb/5sAAAAB/blH/73z/ulkAAAAAAAD85pkAAAAAAAACAgP/vGz/rkDerGbGrV7/pkQICAf////e0IsAAAD/oED/qTvhrnUAAAD/yHD/njcAAADuv2r/nz//oTj/p064oGf/zHAAAAA9Nir/tFIAAAD/tlTiuWf/tkIAAACynXEAAAAAAAAtIRW7zBpBAAAAM3RSTlMAABR1m7RXO8Ln31Z36zT+neXe5OzooRDfn+TZ4p3h2hTf4t3k3ucyrN1K5+Xaks52Sfs9CXgrAAAAjklEQVR42o3PbQ+CIBQFYEwboPhSYgoYunIqqLn6/z8uYdH8Vmdnu9vz4WwXgN/xTPRD2+sgOcZjsge/whXZgUaYYvT8QnuJaUrjrHUQreGczuEafQCO/SJTufTbroWsPgsllVhq3wJEk2jUSzX3CUEDJC84707djRc5MTAQxoLgupWRwW6UB5fS++NV8AbOZgnsC7BpEAAAAABJRU5ErkJggg==\");\n background-position: 2px center;\n}\n\n.ace_gutter-cell.ace_info {\n background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAAAAAA6mKC9AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAAJ0Uk5TAAB2k804AAAAPklEQVQY02NgIB68QuO3tiLznjAwpKTgNyDbMegwisCHZUETUZV0ZqOquBpXj2rtnpSJT1AEnnRmL2OgGgAAIKkRQap2htgAAAAASUVORK5CYII=\");\n background-position: 2px center;\n}\n.ace_dark .ace_gutter-cell.ace_info {\n background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQBAMAAADt3eJSAAAAJFBMVEUAAAChoaGAgIAqKiq+vr6tra1ZWVmUlJSbm5s8PDxubm56enrdgzg3AAAAAXRSTlMAQObYZgAAAClJREFUeNpjYMAPdsMYHegyJZFQBlsUlMFVCWUYKkAZMxZAGdxlDMQBAG+TBP4B6RyJAAAAAElFTkSuQmCC\");\n}\n\n.ace_scrollbar {\n contain: strict;\n position: absolute;\n right: 0;\n bottom: 0;\n z-index: 6;\n}\n\n.ace_scrollbar-inner {\n position: absolute;\n cursor: text;\n left: 0;\n top: 0;\n}\n\n.ace_scrollbar-v{\n overflow-x: hidden;\n overflow-y: scroll;\n top: 0;\n}\n\n.ace_scrollbar-h {\n overflow-x: scroll;\n overflow-y: hidden;\n left: 0;\n}\n\n.ace_print-margin {\n position: absolute;\n height: 100%;\n}\n\n.ace_text-input {\n position: absolute;\n z-index: 0;\n width: 0.5em;\n height: 1em;\n opacity: 0;\n background: transparent;\n -moz-appearance: none;\n appearance: none;\n border: none;\n resize: none;\n outline: none;\n overflow: hidden;\n font: inherit;\n padding: 0 1px;\n margin: 0 -1px;\n text-indent: -1em;\n -ms-user-select: text;\n -moz-user-select: text;\n -webkit-user-select: text;\n user-select: text;\n white-space: pre!important;\n}\n.ace_text-input.ace_composition {\n background: inherit;\n color: inherit;\n z-index: 1000;\n opacity: 1;\n text-indent: 0;\n}\n[ace_nocontext=true] {\n transform: none!important;\n filter: none!important;\n perspective: none!important;\n clip-path: none!important;\n mask : none!important;\n contain: none!important;\n perspective: none!important;\n mix-blend-mode: initial!important;\n z-index: auto;\n}\n\n.ace_layer {\n z-index: 1;\n position: absolute;\n overflow: hidden;\n word-wrap: normal;\n white-space: pre;\n height: 100%;\n width: 100%;\n box-sizing: border-box;\n pointer-events: none;\n}\n\n.ace_gutter-layer {\n position: relative;\n width: auto;\n text-align: right;\n pointer-events: auto;\n height: 1000000px;\n contain: style size layout;\n}\n\n.ace_text-layer {\n font: inherit !important;\n position: absolute;\n height: 1000000px;\n width: 1000000px;\n contain: style size layout;\n}\n\n.ace_text-layer > .ace_line, .ace_text-layer > .ace_line_group {\n contain: style size layout;\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n}\n\n.ace_hidpi .ace_text-layer,\n.ace_hidpi .ace_gutter-layer,\n.ace_hidpi .ace_content,\n.ace_hidpi .ace_gutter {\n contain: strict;\n will-change: transform;\n}\n.ace_hidpi .ace_text-layer > .ace_line, \n.ace_hidpi .ace_text-layer > .ace_line_group {\n contain: strict;\n}\n\n.ace_cjk {\n display: inline-block;\n text-align: center;\n}\n\n.ace_cursor-layer {\n z-index: 4;\n}\n\n.ace_cursor {\n z-index: 4;\n position: absolute;\n box-sizing: border-box;\n border-left: 2px solid;\n transform: translatez(0);\n}\n\n.ace_multiselect .ace_cursor {\n border-left-width: 1px;\n}\n\n.ace_slim-cursors .ace_cursor {\n border-left-width: 1px;\n}\n\n.ace_overwrite-cursors .ace_cursor {\n border-left-width: 0;\n border-bottom: 1px solid;\n}\n\n.ace_hidden-cursors .ace_cursor {\n opacity: 0.2;\n}\n\n.ace_smooth-blinking .ace_cursor {\n transition: opacity 0.18s;\n}\n\n.ace_animate-blinking .ace_cursor {\n animation-duration: 1000ms;\n animation-timing-function: step-end;\n animation-name: blink-ace-animate;\n animation-iteration-count: infinite;\n}\n\n.ace_animate-blinking.ace_smooth-blinking .ace_cursor {\n animation-duration: 1000ms;\n animation-timing-function: ease-in-out;\n animation-name: blink-ace-animate-smooth;\n}\n \n@keyframes blink-ace-animate {\n from, to { opacity: 1; }\n 60% { opacity: 0; }\n}\n\n@keyframes blink-ace-animate-smooth {\n from, to { opacity: 1; }\n 45% { opacity: 1; }\n 60% { opacity: 0; }\n 85% { opacity: 0; }\n}\n\n.ace_marker-layer .ace_step, .ace_marker-layer .ace_stack {\n position: absolute;\n z-index: 3;\n}\n\n.ace_marker-layer .ace_selection {\n position: absolute;\n z-index: 5;\n}\n\n.ace_marker-layer .ace_bracket {\n position: absolute;\n z-index: 6;\n}\n\n.ace_marker-layer .ace_active-line {\n position: absolute;\n z-index: 2;\n}\n\n.ace_marker-layer .ace_selected-word {\n position: absolute;\n z-index: 4;\n box-sizing: border-box;\n}\n\n.ace_line .ace_fold {\n box-sizing: border-box;\n\n display: inline-block;\n height: 11px;\n margin-top: -2px;\n vertical-align: middle;\n\n background-image:\n url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABEAAAAJCAYAAADU6McMAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAJpJREFUeNpi/P//PwOlgAXGYGRklAVSokD8GmjwY1wasKljQpYACtpCFeADcHVQfQyMQAwzwAZI3wJKvCLkfKBaMSClBlR7BOQikCFGQEErIH0VqkabiGCAqwUadAzZJRxQr/0gwiXIal8zQQPnNVTgJ1TdawL0T5gBIP1MUJNhBv2HKoQHHjqNrA4WO4zY0glyNKLT2KIfIMAAQsdgGiXvgnYAAAAASUVORK5CYII=\"),\n url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAA3CAYAAADNNiA5AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAACJJREFUeNpi+P//fxgTAwPDBxDxD078RSX+YeEyDFMCIMAAI3INmXiwf2YAAAAASUVORK5CYII=\");\n background-repeat: no-repeat, repeat-x;\n background-position: center center, top left;\n color: transparent;\n\n border: 1px solid black;\n border-radius: 2px;\n\n cursor: pointer;\n pointer-events: auto;\n}\n\n.ace_dark .ace_fold {\n}\n\n.ace_fold:hover{\n background-image:\n url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABEAAAAJCAYAAADU6McMAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAJpJREFUeNpi/P//PwOlgAXGYGRklAVSokD8GmjwY1wasKljQpYACtpCFeADcHVQfQyMQAwzwAZI3wJKvCLkfKBaMSClBlR7BOQikCFGQEErIH0VqkabiGCAqwUadAzZJRxQr/0gwiXIal8zQQPnNVTgJ1TdawL0T5gBIP1MUJNhBv2HKoQHHjqNrA4WO4zY0glyNKLT2KIfIMAAQsdgGiXvgnYAAAAASUVORK5CYII=\"),\n url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAA3CAYAAADNNiA5AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAACBJREFUeNpi+P//fz4TAwPDZxDxD5X4i5fLMEwJgAADAEPVDbjNw87ZAAAAAElFTkSuQmCC\");\n}\n\n.ace_tooltip {\n background-color: #FFF;\n background-image: linear-gradient(to bottom, transparent, rgba(0, 0, 0, 0.1));\n border: 1px solid gray;\n border-radius: 1px;\n box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);\n color: black;\n max-width: 100%;\n padding: 3px 4px;\n position: fixed;\n z-index: 999999;\n box-sizing: border-box;\n cursor: default;\n white-space: pre;\n word-wrap: break-word;\n line-height: normal;\n font-style: normal;\n font-weight: normal;\n letter-spacing: normal;\n pointer-events: none;\n}\n\n.ace_folding-enabled > .ace_gutter-cell {\n padding-right: 13px;\n}\n\n.ace_fold-widget {\n box-sizing: border-box;\n\n margin: 0 -12px 0 1px;\n display: none;\n width: 11px;\n vertical-align: top;\n\n background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAANElEQVR42mWKsQ0AMAzC8ixLlrzQjzmBiEjp0A6WwBCSPgKAXoLkqSot7nN3yMwR7pZ32NzpKkVoDBUxKAAAAABJRU5ErkJggg==\");\n background-repeat: no-repeat;\n background-position: center;\n\n border-radius: 3px;\n \n border: 1px solid transparent;\n cursor: pointer;\n}\n\n.ace_folding-enabled .ace_fold-widget {\n display: inline-block; \n}\n\n.ace_fold-widget.ace_end {\n background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAANElEQVR42m3HwQkAMAhD0YzsRchFKI7sAikeWkrxwScEB0nh5e7KTPWimZki4tYfVbX+MNl4pyZXejUO1QAAAABJRU5ErkJggg==\");\n}\n\n.ace_fold-widget.ace_closed {\n background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAMAAAAGCAYAAAAG5SQMAAAAOUlEQVR42jXKwQkAMAgDwKwqKD4EwQ26sSOkVWjgIIHAzPiCgaqiqnJHZnKICBERHN194O5b9vbLuAVRL+l0YWnZAAAAAElFTkSuQmCCXA==\");\n}\n\n.ace_fold-widget:hover {\n border: 1px solid rgba(0, 0, 0, 0.3);\n background-color: rgba(255, 255, 255, 0.2);\n box-shadow: 0 1px 1px rgba(255, 255, 255, 0.7);\n}\n\n.ace_fold-widget:active {\n border: 1px solid rgba(0, 0, 0, 0.4);\n background-color: rgba(0, 0, 0, 0.05);\n box-shadow: 0 1px 1px rgba(255, 255, 255, 0.8);\n}\n.ace_dark .ace_fold-widget {\n background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHklEQVQIW2P4//8/AzoGEQ7oGCaLLAhWiSwB146BAQCSTPYocqT0AAAAAElFTkSuQmCC\");\n}\n.ace_dark .ace_fold-widget.ace_end {\n background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAH0lEQVQIW2P4//8/AxQ7wNjIAjDMgC4AxjCVKBirIAAF0kz2rlhxpAAAAABJRU5ErkJggg==\");\n}\n.ace_dark .ace_fold-widget.ace_closed {\n background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAMAAAAFCAYAAACAcVaiAAAAHElEQVQIW2P4//+/AxAzgDADlOOAznHAKgPWAwARji8UIDTfQQAAAABJRU5ErkJggg==\");\n}\n.ace_dark .ace_fold-widget:hover {\n box-shadow: 0 1px 1px rgba(255, 255, 255, 0.2);\n background-color: rgba(255, 255, 255, 0.1);\n}\n.ace_dark .ace_fold-widget:active {\n box-shadow: 0 1px 1px rgba(255, 255, 255, 0.2);\n}\n\n.ace_inline_button {\n border: 1px solid lightgray;\n display: inline-block;\n margin: -1px 8px;\n padding: 0 5px;\n pointer-events: auto;\n cursor: pointer;\n}\n.ace_inline_button:hover {\n border-color: gray;\n background: rgba(200,200,200,0.2);\n display: inline-block;\n pointer-events: auto;\n}\n\n.ace_fold-widget.ace_invalid {\n background-color: #FFB4B4;\n border-color: #DE5555;\n}\n\n.ace_fade-fold-widgets .ace_fold-widget {\n transition: opacity 0.4s ease 0.05s;\n opacity: 0;\n}\n\n.ace_fade-fold-widgets:hover .ace_fold-widget {\n transition: opacity 0.05s ease 0.05s;\n opacity:1;\n}\n\n.ace_underline {\n text-decoration: underline;\n}\n\n.ace_bold {\n font-weight: bold;\n}\n\n.ace_nobold .ace_bold {\n font-weight: normal;\n}\n\n.ace_italic {\n font-style: italic;\n}\n\n\n.ace_error-marker {\n background-color: rgba(255, 0, 0,0.2);\n position: absolute;\n z-index: 9;\n}\n\n.ace_highlight-marker {\n background-color: rgba(255, 255, 0,0.2);\n position: absolute;\n z-index: 8;\n}\n.ace_br1 {border-top-left-radius : 3px;}\n.ace_br2 {border-top-right-radius : 3px;}\n.ace_br3 {border-top-left-radius : 3px; border-top-right-radius: 3px;}\n.ace_br4 {border-bottom-right-radius: 3px;}\n.ace_br5 {border-top-left-radius : 3px; border-bottom-right-radius: 3px;}\n.ace_br6 {border-top-right-radius : 3px; border-bottom-right-radius: 3px;}\n.ace_br7 {border-top-left-radius : 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px;}\n.ace_br8 {border-bottom-left-radius : 3px;}\n.ace_br9 {border-top-left-radius : 3px; border-bottom-left-radius: 3px;}\n.ace_br10{border-top-right-radius : 3px; border-bottom-left-radius: 3px;}\n.ace_br11{border-top-left-radius : 3px; border-top-right-radius: 3px; border-bottom-left-radius: 3px;}\n.ace_br12{border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;}\n.ace_br13{border-top-left-radius : 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;}\n.ace_br14{border-top-right-radius : 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;}\n.ace_br15{border-top-left-radius : 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;}\n\n.ace_text-input-ios {\n position: absolute !important;\n top: -100000px !important;\n left: -100000px !important;\n}\n"); define("ace/virtual_renderer",[], function(require, exports, module) { "use strict"; @@ -1609,7 +1955,6 @@ define("ace/virtual_renderer",[], function(require, exports, module) { var oop = require("./lib/oop"); var dom = require("./lib/dom"); var config = require("./config"); -var useragent = require("./lib/useragent"); var GutterLayer = require("./layer/gutter").Gutter; var MarkerLayer = require("./layer/marker").Marker; var TextLayer = require("./layer/text").Text; @@ -1629,6 +1974,7 @@ var VirtualRenderer = function(container, theme) { this.container = container || dom.createElement("div"); dom.addCssClass(this.container, "ace_editor"); + if (dom.HI_DPI) dom.addCssClass(this.container, "ace_hidpi"); this.setTheme(theme); @@ -1639,6 +1985,7 @@ var VirtualRenderer = function(container, theme) { this.scroller = dom.createElement("div"); this.scroller.className = "ace_scroller"; + this.container.appendChild(this.scroller); this.content = dom.createElement("div"); @@ -1718,6 +2065,15 @@ var VirtualRenderer = function(container, theme) { v: 0, h: 0 }; + + this.margin = { + left: 0, + right: 0, + top: 0, + bottom: 0, + v: 0, + h: 0 + }; this.$loop = new RenderLoop( this.$renderChanges.bind(this), @@ -1775,6 +2131,7 @@ var VirtualRenderer = function(container, theme) { return; this.$loop.schedule(this.CHANGE_FULL); + this.session.$setFontMetrics(this.$fontMetrics); this.scrollBarH.scrollLeft = this.scrollBarV.scrollTop = null; this.onChangeNewLineMode = this.onChangeNewLineMode.bind(this); @@ -1901,15 +2258,17 @@ var VirtualRenderer = function(container, theme) { this.gutterWidth = gutterWidth; - this.scrollBarH.element.style.left = - this.scroller.style.left = gutterWidth + "px"; - size.scrollerWidth = Math.max(0, width - gutterWidth - this.scrollBarV.getWidth()); + dom.setStyle(this.scrollBarH.element.style, "left", gutterWidth + "px"); + dom.setStyle(this.scroller.style, "left", gutterWidth + this.margin.left + "px"); + size.scrollerWidth = Math.max(0, width - gutterWidth - this.scrollBarV.getWidth() - this.margin.h); - this.scrollBarH.element.style.right = - this.scroller.style.right = this.scrollBarV.getWidth() + "px"; - this.scroller.style.bottom = this.scrollBarH.getHeight() + "px"; - if (this.session && this.session.getUseWrapMode() && this.adjustWrapLimit() || force) + var right = this.scrollBarV.getWidth() + "px"; + dom.setStyle(this.scrollBarH.element.style, "right", right); + dom.setStyle(this.scroller.style, "right", right); + dom.setStyle(this.scroller.style, "bottom", this.scrollBarH.getHeight()); + if (this.session && this.session.getUseWrapMode() && this.adjustWrapLimit() || force) { changes |= this.CHANGE_FULL; + } } size.$dirty = !width || !height; @@ -1920,8 +2279,8 @@ var VirtualRenderer = function(container, theme) { return changes; }; - this.onGutterResize = function() { - var gutterWidth = this.$showGutter ? this.$gutter.offsetWidth : 0; + this.onGutterResize = function(width) { + var gutterWidth = this.$showGutter ? width : 0; if (gutterWidth != this.gutterWidth) this.$changes |= this.$updateCachedSize(true, gutterWidth, this.$size.width, this.$size.height); @@ -1931,7 +2290,6 @@ var VirtualRenderer = function(container, theme) { this.$loop.schedule(this.CHANGE_FULL); } else { this.$computeLayerConfig(); - this.$loop.schedule(this.CHANGE_MARKER); } }; this.adjustWrapLimit = function() { @@ -1994,19 +2352,6 @@ var VirtualRenderer = function(container, theme) { return this.getOption("highlightGutterLine"); }; - this.$updateGutterLineHighlight = function() { - var pos = this.$cursorLayer.$pixelPos; - var height = this.layerConfig.lineHeight; - if (this.session.getUseWrapMode()) { - var cursor = this.session.selection.getCursor(); - cursor.column = 0; - pos = this.$cursorLayer.getPixelPosition(cursor, true); - height *= this.session.getRowLength(cursor.row); - } - this.$gutterLineHighlight.style.top = pos.top - this.layerConfig.offset + "px"; - this.$gutterLineHighlight.style.height = height + "px"; - }; - this.$updatePrintMargin = function() { if (!this.$showPrintMargin && !this.$printMarginEl) return; @@ -2039,9 +2384,11 @@ var VirtualRenderer = function(container, theme) { this.$moveTextAreaToCursor = function() { var style = this.textarea.style; if (!this.$keepTextAreaAtCursor) { - style.left = -100 + "px"; + dom.translate(this.textarea, -100, 0); return; } + if (!this.$cursorLayer.$pixelPos) + return; var config = this.layerConfig; var posTop = this.$cursorLayer.$pixelPos.top; var posLeft = this.$cursorLayer.$pixelPos.left; @@ -2049,7 +2396,7 @@ var VirtualRenderer = function(container, theme) { var h = this.lineHeight; if (posTop < 0 || posTop > config.height - h) { - style.top = style.left = "0"; + dom.translate(this.textarea, 0, 0); return; } @@ -2063,11 +2410,10 @@ var VirtualRenderer = function(container, theme) { if (posLeft > this.$size.scrollerWidth - w) posLeft = this.$size.scrollerWidth - w; - posLeft += this.gutterWidth; - style.height = h + "px"; - style.width = w + "px"; - style.left = Math.min(posLeft, this.$size.scrollerWidth - w) + "px"; - style.top = Math.min(posTop, this.$size.height - h) + "px"; + posLeft += this.gutterWidth + this.margin.left; + dom.setStyle(style, "height", h + "px"); + dom.setStyle(style, "width", w + "px"); + dom.translate(this.textarea, Math.min(posLeft, this.$size.scrollerWidth - w), Math.min(posTop, this.$size.height - h)); }; this.getFirstVisibleRow = function() { return this.layerConfig.firstRow; @@ -2110,6 +2456,18 @@ var VirtualRenderer = function(container, theme) { this.session.setScrollTop(-sm.top); this.updateFull(); }; + + this.setMargin = function(top, bottom, left, right) { + var sm = this.margin; + sm.top = top|0; + sm.bottom = bottom|0; + sm.right = right|0; + sm.left = left|0; + sm.v = sm.top + sm.bottom; + sm.h = sm.left + sm.right; + this.$updateCachedSize(true, this.gutterWidth, this.$size.width, this.$size.height); + this.updateFull(); + }; this.getHScrollBarAlwaysVisible = function() { return this.$hScrollBarAlwaysVisible; }; @@ -2192,13 +2550,18 @@ var VirtualRenderer = function(container, theme) { this.$updateScrollBarV(); if (changes & this.CHANGE_H_SCROLL) this.$updateScrollBarH(); - this.$gutterLayer.element.style.marginTop = (-config.offset) + "px"; - this.content.style.marginTop = (-config.offset) + "px"; - this.content.style.width = config.width + 2 * this.$padding + "px"; - this.content.style.height = config.minHeight + "px"; + + dom.translate(this.$gutter, this.margin.left, -config.offset); + dom.translate(this.content, -this.scrollLeft, -config.offset); + + var width = config.width + 2 * this.$padding + "px"; + var height = config.minHeight + "px"; + + dom.setStyle(this.content.style, "width", width); + dom.setStyle(this.content.style, "height", height); } if (changes & this.CHANGE_H_SCROLL) { - this.content.style.marginLeft = -this.scrollLeft + "px"; + dom.translate(this.content, -this.scrollLeft, -config.offset); this.scroller.className = this.scrollLeft <= 0 ? "ace_scroller" : "ace_scroller ace_scroll-left"; } if (changes & this.CHANGE_FULL) { @@ -2209,7 +2572,6 @@ var VirtualRenderer = function(container, theme) { this.$markerFront.update(config); this.$cursorLayer.update(config); this.$moveTextAreaToCursor(); - this.$highlightGutterLine && this.$updateGutterLineHighlight(); this._signal("afterRender"); return; } @@ -2219,12 +2581,15 @@ var VirtualRenderer = function(container, theme) { else this.$textLayer.scrollLines(config); - if (this.$showGutter) - this.$gutterLayer.update(config); + if (this.$showGutter) { + if (changes & this.CHANGE_GUTTER || changes & this.CHANGE_LINES) + this.$gutterLayer.update(config); + else + this.$gutterLayer.scrollLines(config); + } this.$markerBack.update(config); this.$markerFront.update(config); this.$cursorLayer.update(config); - this.$highlightGutterLine && this.$updateGutterLineHighlight(); this.$moveTextAreaToCursor(); this._signal("afterRender"); return; @@ -2243,11 +2608,14 @@ var VirtualRenderer = function(container, theme) { if (this.$showGutter) this.$gutterLayer.update(config); } + else if (changes & this.CHANGE_CURSOR) { + if (this.$highlightGutterLine) + this.$gutterLayer.updateLineHighlight(config); + } if (changes & this.CHANGE_CURSOR) { this.$cursorLayer.update(config); this.$moveTextAreaToCursor(); - this.$highlightGutterLine && this.$updateGutterLineHighlight(); } if (changes & (this.CHANGE_MARKER | this.CHANGE_MARKER_FRONT)) { @@ -2272,7 +2640,9 @@ var VirtualRenderer = function(container, theme) { desiredHeight += this.scrollBarH.getHeight(); if (this.$maxPixelHeight && desiredHeight > this.$maxPixelHeight) desiredHeight = this.$maxPixelHeight; - var vScroll = height > maxHeight; + + var hideScrollbars = desiredHeight <= 2 * this.lineHeight; + var vScroll = !hideScrollbars && height > maxHeight; if (desiredHeight != this.desiredHeight || this.$size.height != this.desiredHeight || vScroll != this.$vScroll) { @@ -2617,7 +2987,7 @@ var VirtualRenderer = function(container, theme) { if (this.$hasCssTransforms) { canvasPos = {top:0, left: 0}; var p = this.$fontMetrics.transformCoordinates([x, y]); - x = p[1] - this.gutterWidth; + x = p[1] - this.gutterWidth - this.margin.left; y = p[0]; } else { canvasPos = this.scroller.getBoundingClientRect(); @@ -2636,7 +3006,7 @@ var VirtualRenderer = function(container, theme) { if (this.$hasCssTransforms) { canvasPos = {top:0, left: 0}; var p = this.$fontMetrics.transformCoordinates([x, y]); - x = p[1] - this.gutterWidth; + x = p[1] - this.gutterWidth - this.margin.left; y = p[0]; } else { canvasPos = this.scroller.getBoundingClientRect(); @@ -2646,7 +3016,7 @@ var VirtualRenderer = function(container, theme) { var offset = offsetX / this.characterWidth; var col = this.$blockCursor ? Math.floor(offset) : Math.round(offset); - var row = (y + this.scrollTop - canvasPos.top) / this.lineHeight; + var row = Math.floor((y + this.scrollTop - canvasPos.top) / this.lineHeight); return this.session.screenToDocumentPosition(row, Math.max(col, 0), offsetX); }; @@ -2752,11 +3122,10 @@ var VirtualRenderer = function(container, theme) { }; this.setCursorStyle = function(style) { - if (this.scroller.style.cursor != style) - this.scroller.style.cursor = style; + dom.setStyle(this.scroller.style, "cursor", style); }; this.setMouseCursor = function(cursorStyle) { - this.scroller.style.cursor = cursorStyle; + dom.setStyle(this.scroller.style, "cursor", cursorStyle); }; this.attachToShadowRoot = function() { @@ -2813,12 +3182,8 @@ config.defineOptions(VirtualRenderer.prototype, "renderer", { initialValue: false }, showFoldWidgets: { - set: function(show) {this.$gutterLayer.setShowFoldWidgets(show);}, - initialValue: true - }, - showLineNumbers: { set: function(show) { - this.$gutterLayer.setShowLineNumbers(show); + this.$gutterLayer.setShowFoldWidgets(show); this.$loop.schedule(this.CHANGE_GUTTER); }, initialValue: true @@ -2832,19 +3197,10 @@ config.defineOptions(VirtualRenderer.prototype, "renderer", { }, highlightGutterLine: { set: function(shouldHighlight) { - if (!this.$gutterLineHighlight) { - this.$gutterLineHighlight = dom.createElement("div"); - this.$gutterLineHighlight.className = "ace_gutter-active-line"; - this.$gutter.appendChild(this.$gutterLineHighlight); - return; - } - - this.$gutterLineHighlight.style.display = shouldHighlight ? "" : "none"; - if (this.$cursorLayer.$pixelPos) - this.$updateGutterLineHighlight(); + this.$gutterLayer.setHighlightGutterLine(shouldHighlight); + this.$loop.schedule(this.CHANGE_GUTTER); }, - initialValue: false, - value: true + initialValue: true }, hScrollBarAlwaysVisible: { set: function(val) { @@ -2860,7 +3216,7 @@ config.defineOptions(VirtualRenderer.prototype, "renderer", { }, initialValue: false }, - fontSize: { + fontSize: { set: function(size) { if (typeof size == "number") size = size + "px"; diff --git a/build/standalone/modules/ace/ext/static_highlight.js b/build/standalone/modules/ace/ext/static_highlight.js index 52904cab..9a918ead 100644 --- a/build/standalone/modules/ace/ext/static_highlight.js +++ b/build/standalone/modules/ace/ext/static_highlight.js @@ -1,17 +1,144 @@ +define("ace/layer/lines",[], function(require, exports, module) { +"use strict"; + +var dom = require("../lib/dom"); + +var Lines = function(element, canvasHeight) { + this.element = element; + this.canvasHeight = canvasHeight || 500000; + this.element.style.height = (this.canvasHeight * 2) + "px"; + + this.cells = []; + this.cellCache = []; +}; + +(function() { + + this.moveContainer = function(config) { + dom.translate(this.element, 0, -((config.firstRowScreen * config.lineHeight) % this.canvasHeight)); + }; + + this.pageChanged = function(oldConfig, newConfig) { + return ( + Math.floor((oldConfig.firstRowScreen * oldConfig.lineHeight) / this.canvasHeight) !== + Math.floor((newConfig.firstRowScreen * newConfig.lineHeight) / this.canvasHeight) + ); + }; + + this.computeLineTop = function(row, config, session) { + var screenTop = config.firstRowScreen * config.lineHeight; + var screenPage = Math.floor(screenTop / this.canvasHeight); + var lineTop = session.documentToScreenRow(row, 0) * config.lineHeight; + return lineTop - (screenPage * this.canvasHeight); + }; + + this.computeLineHeight = function(row, config, session) { + return config.lineHeight * session.getRowLength(row); + }; + + this.getLength = function() { + return this.cells.length; + }; + + this.get = function(index) { + return this.cells[index]; + }; + + this.shift = function() { + this.$cacheCell(this.cells.shift()); + }; + + this.pop = function() { + this.$cacheCell(this.cells.pop()); + }; + + this.push = function(cell) { + if (Array.isArray(cell)) { + this.cells.push.apply(this.cells, cell); + var fragment = dom.createFragment(this.element); + for (var i=0; i" - + lang.stringRepeat(this.TAB_CHAR, i) - + ""); + var span = this.dom.createElement("span"); + span.className = "ace_invisible ace_invisible_tab"; + span.textContent = lang.stringRepeat(this.TAB_CHAR, i); + tabStr.push(span); } else { - tabStr.push(lang.stringRepeat(" ", i)); + tabStr.push(this.dom.createTextNode(lang.stringRepeat(" ", i), this.element)); } } if (this.displayIndentGuides) { @@ -116,21 +244,29 @@ var Text = function(parentEl) { tabClass = " ace_invisible_tab"; var spaceContent = lang.stringRepeat(this.SPACE_CHAR, this.tabSize); var tabContent = lang.stringRepeat(this.TAB_CHAR, this.tabSize); - } else{ + } else { var spaceContent = lang.stringRepeat(" ", this.tabSize); var tabContent = spaceContent; } - this.$tabStrings[" "] = "" + spaceContent + ""; - this.$tabStrings["\t"] = "" + tabContent + ""; + var span = this.dom.createElement("span"); + span.className = className + spaceClass; + span.textContent = spaceContent; + this.$tabStrings[" "] = span; + + var span = this.dom.createElement("span"); + span.className = className + tabClass; + span.textContent = tabContent; + this.$tabStrings["\t"] = span; } }; this.updateLines = function(config, firstRow, lastRow) { if (this.config.lastRow != config.lastRow || this.config.firstRow != config.firstRow) { - this.scrollLines(config); + return this.update(config); } + this.config = config; var first = Math.max(firstRow, config.firstRow); @@ -152,6 +288,7 @@ var Text = function(parentEl) { lineElementsIdx ++; } + var heightChanged = false; var row = first; var foldLine = this.session.getNextFoldLine(row); var foldStart = foldLine ? foldLine.start.row : Infinity; @@ -167,52 +304,69 @@ var Text = function(parentEl) { var lineElement = lineElements[lineElementsIdx++]; if (lineElement) { - var html = []; + this.dom.removeChildren(lineElement); this.$renderLine( - html, row, !this.$useLineGroups(), row == foldStart ? foldLine : false + lineElement, row, row == foldStart ? foldLine : false ); - lineElement.style.height = config.lineHeight * this.session.getRowLength(row) + "px"; - lineElement.innerHTML = html.join(""); + var height = (config.lineHeight * this.session.getRowLength(row)) + "px"; + if (lineElement.style.height != height) { + heightChanged = true; + lineElement.style.height = height; + } } row++; } + if (heightChanged) { + while (lineElementsIdx < this.$lines.cells.length) { + var cell = this.$lines.cells[lineElementsIdx++]; + cell.element.style.top = this.$lines.computeLineTop(cell.row, config, this.session) + "px"; + } + } }; this.scrollLines = function(config) { var oldConfig = this.config; this.config = config; + if (this.$lines.pageChanged(oldConfig, config)) + return this.update(config); + + this.$lines.moveContainer(config); + + var lastRow = config.lastRow; + var oldLastRow = oldConfig ? oldConfig.lastRow : -1; + + if (!oldConfig || oldLastRow < config.firstRow) + return this.update(config); + + if (lastRow < oldConfig.firstRow) + return this.update(config); + if (!oldConfig || oldConfig.lastRow < config.firstRow) return this.update(config); if (config.lastRow < oldConfig.firstRow) return this.update(config); - var el = this.element; if (oldConfig.firstRow < config.firstRow) for (var row=this.session.getFoldedRowCount(oldConfig.firstRow, config.firstRow - 1); row>0; row--) - el.removeChild(el.firstChild); + this.$lines.shift(); if (oldConfig.lastRow > config.lastRow) for (var row=this.session.getFoldedRowCount(config.lastRow + 1, oldConfig.lastRow); row>0; row--) - el.removeChild(el.lastChild); + this.$lines.pop(); if (config.firstRow < oldConfig.firstRow) { - var fragment = this.$renderLinesFragment(config, config.firstRow, oldConfig.firstRow - 1); - if (el.firstChild) - el.insertBefore(fragment, el.firstChild); - else - el.appendChild(fragment); + this.$lines.unshift(this.$renderLinesFragment(config, config.firstRow, oldConfig.firstRow - 1)); } if (config.lastRow > oldConfig.lastRow) { - var fragment = this.$renderLinesFragment(config, oldConfig.lastRow + 1, config.lastRow); - el.appendChild(fragment); + this.$lines.push(this.$renderLinesFragment(config, oldConfig.lastRow + 1, config.lastRow)); } }; this.$renderLinesFragment = function(config, firstRow, lastRow) { - var fragment = this.element.ownerDocument.createDocumentFragment(); + var fragment = []; var row = firstRow; var foldLine = this.session.getNextFoldLine(row); var foldStart = foldLine ? foldLine.start.row : Infinity; @@ -226,21 +380,20 @@ var Text = function(parentEl) { if (row > lastRow) break; - var container = dom.createElement("div"); + var line = this.$lines.createCell(row, config, this.session); + + var lineEl = line.element; + this.dom.removeChildren(lineEl); + dom.setStyle(lineEl.style, "height", this.$lines.computeLineHeight(row, config, this.session) + "px"); + dom.setStyle(lineEl.style, "top", this.$lines.computeLineTop(row, config, this.session) + "px"); + this.$renderLine(lineEl, row, row == foldStart ? foldLine : false); - var html = []; - this.$renderLine(html, row, false, row == foldStart ? foldLine : false); - - container.innerHTML = html.join(""); if (this.$useLineGroups()) { - container.className = 'ace_line_group'; - fragment.appendChild(container); - container.style.height = config.lineHeight * this.session.getRowLength(row) + "px"; - + lineEl.className = "ace_line_group"; } else { - while(container.firstChild) - fragment.appendChild(container.firstChild); + lineEl.className = "ace_line"; } + fragment.push(line); row++; } @@ -248,35 +401,18 @@ var Text = function(parentEl) { }; this.update = function(config) { + this.$lines.moveContainer(config); + this.config = config; - var html = []; - var firstRow = config.firstRow, lastRow = config.lastRow; + var firstRow = config.firstRow; + var lastRow = config.lastRow; - var row = firstRow; - var foldLine = this.session.getNextFoldLine(row); - var foldStart = foldLine ? foldLine.start.row : Infinity; - - while (true) { - if (row > foldStart) { - row = foldLine.end.row+1; - foldLine = this.session.getNextFoldLine(row, foldLine); - foldStart = foldLine ? foldLine.start.row :Infinity; - } - if (row > lastRow) - break; - - if (this.$useLineGroups()) - html.push("
"); - - this.$renderLine(html, row, false, row == foldStart ? foldLine : false); - - if (this.$useLineGroups()) - html.push("
"); // end the line group - - row++; - } - this.element.innerHTML = html.join(""); + var lines = this.$lines; + while (lines.getLength()) + lines.pop(); + + lines.push(this.$renderLinesFragment(config, firstRow, lastRow)); }; this.$textToken = { @@ -285,108 +421,153 @@ var Text = function(parentEl) { "lparen": true }; - this.$renderToken = function(stringBuilder, screenColumn, token, value) { + this.$renderToken = function(parent, screenColumn, token, value) { var self = this; - var replaceReg = /\t|&|<|>|( +)|([\x00-\x1f\x80-\xa0\xad\u1680\u180E\u2000-\u200f\u2028\u2029\u202F\u205F\u3000\uFEFF\uFFF9-\uFFFC])|[\u1100-\u115F\u11A3-\u11A7\u11FA-\u11FF\u2329-\u232A\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u2FFB\u3000-\u303E\u3041-\u3096\u3099-\u30FF\u3105-\u312D\u3131-\u318E\u3190-\u31BA\u31C0-\u31E3\u31F0-\u321E\u3220-\u3247\u3250-\u32FE\u3300-\u4DBF\u4E00-\uA48C\uA490-\uA4C6\uA960-\uA97C\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFAFF\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE66\uFE68-\uFE6B\uFF01-\uFF60\uFFE0-\uFFE6]|[\uD800-\uDBFF][\uDC00-\uDFFF]/g; - var replaceFunc = function(c, a, b, tabIdx, idx4) { - if (a) { - return self.showInvisibles - ? "" + lang.stringRepeat(self.SPACE_CHAR, c.length) + "" - : c; - } else if (c == "&") { - return "&"; - } else if (c == "<") { - return "<"; - } else if (c == ">") { - return ">"; - } else if (c == "\t") { - var tabSize = self.session.getScreenTabSize(screenColumn + tabIdx); + var re = /(\t)|( +)|([\x00-\x1f\x80-\xa0\xad\u1680\u180E\u2000-\u200f\u2028\u2029\u202F\u205F\uFEFF\uFFF9-\uFFFC]+)|(\u3000)|([\u1100-\u115F\u11A3-\u11A7\u11FA-\u11FF\u2329-\u232A\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u2FFB\u3001-\u303E\u3041-\u3096\u3099-\u30FF\u3105-\u312D\u3131-\u318E\u3190-\u31BA\u31C0-\u31E3\u31F0-\u321E\u3220-\u3247\u3250-\u32FE\u3300-\u4DBF\u4E00-\uA48C\uA490-\uA4C6\uA960-\uA97C\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFAFF\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE66\uFE68-\uFE6B\uFF01-\uFF60\uFFE0-\uFFE6]|[\uD800-\uDBFF][\uDC00-\uDFFF])/g; + + var valueFragment = this.dom.createFragment(this.element); + + var m; + var i = 0; + while (m = re.exec(value)) { + var tab = m[1]; + var simpleSpace = m[2]; + var controlCharacter = m[3]; + var cjkSpace = m[4]; + var cjk = m[5]; + + if (!self.showInvisibles && simpleSpace) + continue; + + var before = i != m.index ? value.slice(i, m.index) : ""; + + i = m.index + m[0].length; + + if (before) { + valueFragment.appendChild(this.dom.createTextNode(before, this.element)); + } + + if (tab) { + var tabSize = self.session.getScreenTabSize(screenColumn + m.index); + valueFragment.appendChild(self.$tabStrings[tabSize].cloneNode(true)); screenColumn += tabSize - 1; - return self.$tabStrings[tabSize]; - } else if (c == "\u3000") { - var classToUse = self.showInvisibles ? "ace_cjk ace_invisible ace_invisible_space" : "ace_cjk"; + } else if (simpleSpace) { + if (self.showInvisibles) { + var span = this.dom.createElement("span"); + span.className = "ace_invisible ace_invisible_space"; + span.textContent = lang.stringRepeat(self.SPACE_CHAR, simpleSpace.length); + valueFragment.appendChild(span); + } else { + valueFragment.appendChild(this.com.createTextNode(simpleSpace, this.element)); + } + } else if (controlCharacter) { + var span = this.dom.createElement("span"); + span.className = "ace_invisible ace_invisible_space ace_invalid"; + span.textContent = lang.stringRepeat(self.SPACE_CHAR, controlCharacter.length); + valueFragment.appendChild(span); + } else if (cjkSpace) { var space = self.showInvisibles ? self.SPACE_CHAR : ""; screenColumn += 1; - return "" + space + ""; - } else if (b) { - return "" + self.SPACE_CHAR + ""; - } else { + + var span = this.dom.createElement("span"); + span.style.width = (self.config.characterWidth * 2) + "px"; + span.className = self.showInvisibles ? "ace_cjk ace_invisible ace_invisible_space" : "ace_cjk"; + span.textContent = self.showInvisibles ? self.SPACE_CHAR : ""; + valueFragment.appendChild(span); + } else if (cjk) { screenColumn += 1; - return "" + c + ""; + var span = dom.createElement("span"); + span.style.width = (self.config.characterWidth * 2) + "px"; + span.className = "ace_cjk"; + span.textContent = cjk; + valueFragment.appendChild(span); } - }; - - var output = value.replace(replaceReg, replaceFunc); + } + + valueFragment.appendChild(this.dom.createTextNode(i ? value.slice(i) : value, this.element)); if (!this.$textToken[token.type]) { var classes = "ace_" + token.type.replace(/\./g, " ace_"); - var style = ""; + var span = this.dom.createElement("span"); if (token.type == "fold") - style = " style='width:" + (token.value.length * this.config.characterWidth) + "px;' "; - stringBuilder.push("", output, ""); + span.style.width = (token.value.length * this.config.characterWidth) + "px"; + + span.className = classes; + span.appendChild(valueFragment); + + parent.appendChild(span); } else { - stringBuilder.push(output); + parent.appendChild(valueFragment); } + return screenColumn + value.length; }; - this.renderIndentGuide = function(stringBuilder, value, max) { + this.renderIndentGuide = function(parent, value, max) { var cols = value.search(this.$indentGuideRe); if (cols <= 0 || cols >= max) return value; if (value[0] == " ") { cols -= cols % this.tabSize; - stringBuilder.push(lang.stringRepeat(this.$tabStrings[" "], cols/this.tabSize)); + var count = cols/this.tabSize; + for (var i=0; i= splitChars) { screenColumn = this.$renderToken( - stringBuilder, screenColumn, + lineEl, screenColumn, token, value.substring(0, splitChars - chars) ); value = value.substring(splitChars - chars); chars = splitChars; - if (!onlyContents) { - stringBuilder.push("
", - "
" - ); - } + lineEl = this.$createLineElement(); + parent.appendChild(lineEl); - stringBuilder.push(lang.stringRepeat("\xa0", splits.indent)); + lineEl.appendChild(this.dom.createTextNode(lang.stringRepeat("\xa0", splits.indent), this.element)); split ++; screenColumn = 0; @@ -395,38 +576,43 @@ var Text = function(parentEl) { if (value.length != 0) { chars += value.length; screenColumn = this.$renderToken( - stringBuilder, screenColumn, token, value + lineEl, screenColumn, token, value ); } } } }; - this.$renderSimpleLine = function(stringBuilder, tokens) { + this.$renderSimpleLine = function(parent, tokens) { var screenColumn = 0; var token = tokens[0]; var value = token.value; if (this.displayIndentGuides) - value = this.renderIndentGuide(stringBuilder, value); + value = this.renderIndentGuide(parent, value); if (value) - screenColumn = this.$renderToken(stringBuilder, screenColumn, token, value); + screenColumn = this.$renderToken(parent, screenColumn, token, value); for (var i = 1; i < tokens.length; i++) { token = tokens[i]; value = token.value; if (screenColumn + value.length > this.MAX_LINE_LENGTH) - return this.$renderOverflowMessage(stringBuilder, screenColumn, token, value); - screenColumn = this.$renderToken(stringBuilder, screenColumn, token, value); + return this.$renderOverflowMessage(parent, screenColumn, token, value); + screenColumn = this.$renderToken(parent, screenColumn, token, value); } }; - this.$renderOverflowMessage = function(stringBuilder, screenColumn, token, value) { - this.$renderToken(stringBuilder, screenColumn, token, + this.$renderOverflowMessage = function(parent, screenColumn, token, value) { + this.$renderToken(parent, screenColumn, token, value.slice(0, this.MAX_LINE_LENGTH - screenColumn)); - stringBuilder.push( - "<click to see more...>" - ); + + var overflowEl = this.dom.createElement("span"); + overflowEl.className = "ace_inline_button ace_keyword ace_toggle_wrap"; + overflowEl.style.position = "absolute"; + overflowEl.style.right = "0"; + overflowEl.textContent = ""; + + parent.appendChild(overflowEl); }; - this.$renderLine = function(stringBuilder, row, onlyContents, foldLine) { + this.$renderLine = function(parent, row, foldLine) { if (!foldLine && foldLine != false) foldLine = this.session.getFoldLine(row); @@ -435,36 +621,35 @@ var Text = function(parentEl) { else var tokens = this.session.getTokens(row); - - if (!onlyContents) { - stringBuilder.push( - "
" - ); - } - + var lastLineEl = parent; if (tokens.length) { var splits = this.session.getRowSplitData(row); - if (splits && splits.length) - this.$renderWrappedLine(stringBuilder, tokens, splits, onlyContents); - else - this.$renderSimpleLine(stringBuilder, tokens); + if (splits && splits.length) { + this.$renderWrappedLine(parent, tokens, splits); + var lastLineEl = parent.lastChild; + } else { + var lastLineEl = parent; + if (this.$useLineGroups()) { + lastLineEl = this.$createLineElement(); + parent.appendChild(lastLineEl); + } + this.$renderSimpleLine(lastLineEl, tokens); + } + } else if (this.$useLineGroups()) { + lastLineEl = this.$createLineElement(); + parent.appendChild(lastLineEl); } - if (this.showInvisibles) { + if (this.showInvisibles && lastLineEl) { if (foldLine) row = foldLine.end.row; - stringBuilder.push( - "", - row == this.session.getLength() - 1 ? this.EOF_CHAR : this.EOL_CHAR, - "" - ); + var invisibleEl = this.dom.createElement("span"); + invisibleEl.className = "ace_invisible ace_invisible_eol"; + invisibleEl.textContent = row == this.session.getLength() - 1 ? this.EOF_CHAR : this.EOL_CHAR; + + lastLineEl.appendChild(invisibleEl); } - if (!onlyContents) - stringBuilder.push("
"); }; this.$getFoldLineTokens = function(row, foldLine) { @@ -555,8 +740,77 @@ var baseStyles = require("../requirejs/text!./static.css"); var config = require("../config"); var dom = require("../lib/dom"); +var simpleDom = { + createTextNode: function(textContent) { + return textContent; + }, + createElement: function(type) { + var element = { + type: type, + style: {}, + childNodes: [], + appendChild: function(child) { + element.childNodes.push(child); + }, + toString: function() { + var internal = { + type: 1, + style: 1, + className: 1, + textContent: 1, + childNodes: 1, + appendChild: 1, + toString: 1 + }; + var stringBuilder = []; + + if (element.type != "fragment") { + stringBuilder.push("<", element.type); + if (element.className) + stringBuilder.push(" class='", element.className, "'"); + var styleStr = []; + for (var key in element.style) { + styleStr.push(key, ":", element.style[key]); + } + if (styleStr.length) + stringBuilder.push(" style='", styleStr.join(""), "'"); + for (var key in element) { + if (!internal[key]) { + stringBuilder.push(" ", key, "='", element[key], "'"); + } + } + stringBuilder.push(">"); + } + + if (element.textContent) { + stringBuilder.push(element.textContent); + } else { + for (var i=0; i"); + } + + return stringBuilder.join(""); + } + }; + return element; + }, + createFragment: function() { + return this.createElement("fragment"); + } +}; + var SimpleTextLayer = function() { this.config = {}; + this.dom = simpleDom; }; SimpleTextLayer.prototype = TextLayer.prototype; @@ -582,7 +836,7 @@ var highlight = function(el, opts, callback) { } } } else { - data = dom.getInnerText(el); + data = el.textContent; if (opts.trim) data = data.trim(); } @@ -641,29 +895,35 @@ highlight.renderSync = function(input, mode, theme, lineStart, disableGutter) { textLayer.setSession(session); session.setValue(input); - - var stringBuilder = []; var length = session.getLength(); + + var outerEl = simpleDom.createElement("div"); + outerEl.className = theme.cssClass; + + var innerEl = simpleDom.createElement("div"); + innerEl.className = "ace_static_highlight" + (disableGutter ? "" : " ace_show_gutter"); + innerEl.style["counter-reset"] = "ace_line " + (lineStart - 1); + outerEl.appendChild(innerEl); - for(var ix = 0; ix < length; ix++) { - stringBuilder.push("
"); - if (!disableGutter) - stringBuilder.push("" + /*(ix + lineStart) + */ ""); - textLayer.$renderLine(stringBuilder, ix, true, false); - stringBuilder.push("\n
"); + for (var ix = 0; ix < length; ix++) { + var lineEl = simpleDom.createElement("div"); + lineEl.className = "ace_line"; + + if (!disableGutter) { + var gutterEl = simpleDom.createElement("span"); + gutterEl.className ="ace_gutter ace_gutter-cell"; + gutterEl.unselectable ="on"; + gutterEl.textContent = ""; /*(ix + lineStart) + */ + lineEl.appendChild(gutterEl); + } + textLayer.$renderLine(lineEl, ix, false); + innerEl.appendChild(lineEl); } - var html = "
" + - "
" + - stringBuilder.join("") + - "
" + - "
"; - textLayer.destroy(); return { css: baseStyles + theme.cssText, - html: html, + html: outerEl.toString(), session: session }; }; diff --git a/build/standalone/modules/ace/ext/textarea.js b/build/standalone/modules/ace/ext/textarea.js index b43b8a7b..f0affb9d 100644 --- a/build/standalone/modules/ace/ext/textarea.js +++ b/build/standalone/modules/ace/ext/textarea.js @@ -1,3 +1,131 @@ +define("ace/lib/es6-shim",[], function(require, exports, module) { + function defineProp(obj, name, val) { + Object.defineProperty(obj, name, { + value: val, + enumerable: false, + writable: true, + configurable: true, + }); + } + if (!String.prototype.startsWith) { + defineProp(String.prototype, "startsWith", function(searchString, position) { + position = position || 0; + return this.lastIndexOf(searchString, position) === position; + }); + } + if (!String.prototype.endsWith) { + defineProp(String.prototype, "endsWith", function(searchString, position) { + var subjectString = this; + if (position === undefined || position > subjectString.length) { + position = subjectString.length; + } + position -= searchString.length; + var lastIndex = subjectString.indexOf(searchString, position); + return lastIndex !== -1 && lastIndex === position; + }); + } + if (!String.prototype.repeat) { + defineProp(String.prototype, "repeat", function(count) { + var result = ""; + var string = this; + while (count > 0) { + if (count & 1) + result += string; + + if (count >>= 1) + string += string; + } + return result; + }); + } + if (!String.prototype.includes) { + defineProp(String.prototype, "includes", function(str, position) { + return this.indexOf(str, position) != -1; + }); + } + if (!Object.assign) { + Object.assign = function(target) { + if (target === undefined || target === null) { + throw new TypeError("Cannot convert undefined or null to object"); + } + + var output = Object(target); + for (var index = 1; index < arguments.length; index++) { + var source = arguments[index]; + if (source !== undefined && source !== null) { + Object.keys(source).forEach(function(key) { + output[key] = source[key]; + }); + } + } + return output; + }; + } + if (!Array.prototype.find) { + defineProp(Array.prototype, "find", function(predicate) { + var len = this.length; + var thisArg = arguments[1]; + for (var k = 0; k < len; k++) { + var kValue = this[k]; + if (predicate.call(thisArg, kValue, k, this)) { + return kValue; + } + } + }); + } + if (!Array.prototype.findIndex) { + defineProp(Array.prototype, "findIndex", function(predicate) { + var len = this.length; + var thisArg = arguments[1]; + for (var k = 0; k < len; k++) { + var kValue = this[k]; + if (predicate.call(thisArg, kValue, k, this)) { + return k; + } + } + }); + } + if (!Array.prototype.includes) { + defineProp(Array.prototype, "includes", function(item, position) { + return this.indexOf(item, position) != -1; + }); + } + if (!Array.prototype.fill) { + defineProp(Array.prototype, "fill", function(value) { + var O = this; + var len = O.length >>> 0; + var start = arguments[1]; + var relativeStart = start >> 0; + var k = relativeStart < 0 ? + Math.max(len + relativeStart, 0) : + Math.min(relativeStart, len); + var end = arguments[2]; + var relativeEnd = end === undefined ? + len : end >> 0; + var final = relativeEnd < 0 ? + Math.max(len + relativeEnd, 0) : + Math.min(relativeEnd, len); + while (k < final) { + O[k] = value; + k++; + } + return O; + }); + } + if (!Array.of) { + defineProp(Array, "of", function() { + return Array.prototype.slice.call(arguments); + }); + } +}); + +define("ace/lib/fixoldbrowsers",[], function(require, exports, module) { +"use strict"; + +require("./es6-shim"); + +}); + define("ace/undomanager",[], function(require, exports, module) { "use strict"; var UndoManager = function() { @@ -190,6 +318,10 @@ var UndoManager = function() { this.isClean = this.isAtBookmark; this.markClean = this.bookmark; + this.$prettyPrint = function(delta) { + if (delta) return stringifyDelta(delta); + return stringifyDelta(this.$undoStack) + "\n---\n" + stringifyDelta(this.$redoStack); + }; }).call(UndoManager.prototype); function rearrangeUndoStack(stack, pos) { @@ -441,20 +573,23 @@ function moveDeltasByOne(redoStack, d) { d = cloneDelta(d); for (var j = redoStack.length; j--;) { var deltaSet = redoStack[j]; - for (var i = deltaSet.length; i-- > 0;) { + for (var i = 0; i < deltaSet.length; i++) { var x = deltaSet[i]; var xformed = xform(x, d); d = xformed[0]; if (xformed.length != 2) { if (xformed[2]) { - redoStack.splice(i + 1, 1, xformed[1], xformed[2]); + deltaSet.splice(i + 1, 1, xformed[1], xformed[2]); i++; } else if (!xformed[1]) { - redoStack.splice(i, 1); + deltaSet.splice(i, 1); i--; } } } + if (!deltaSet.length) { + redoStack.splice(j, 1); + } } return redoStack; } @@ -471,6 +606,131 @@ exports.UndoManager = UndoManager; }); +define("ace/layer/lines",[], function(require, exports, module) { +"use strict"; + +var dom = require("../lib/dom"); + +var Lines = function(element, canvasHeight) { + this.element = element; + this.canvasHeight = canvasHeight || 500000; + this.element.style.height = (this.canvasHeight * 2) + "px"; + + this.cells = []; + this.cellCache = []; +}; + +(function() { + + this.moveContainer = function(config) { + dom.translate(this.element, 0, -((config.firstRowScreen * config.lineHeight) % this.canvasHeight)); + }; + + this.pageChanged = function(oldConfig, newConfig) { + return ( + Math.floor((oldConfig.firstRowScreen * oldConfig.lineHeight) / this.canvasHeight) !== + Math.floor((newConfig.firstRowScreen * newConfig.lineHeight) / this.canvasHeight) + ); + }; + + this.computeLineTop = function(row, config, session) { + var screenTop = config.firstRowScreen * config.lineHeight; + var screenPage = Math.floor(screenTop / this.canvasHeight); + var lineTop = session.documentToScreenRow(row, 0) * config.lineHeight; + return lineTop - (screenPage * this.canvasHeight); + }; + + this.computeLineHeight = function(row, config, session) { + return config.lineHeight * session.getRowLength(row); + }; + + this.getLength = function() { + return this.cells.length; + }; + + this.get = function(index) { + return this.cells[index]; + }; + + this.shift = function() { + this.$cacheCell(this.cells.shift()); + }; + + this.pop = function() { + this.$cacheCell(this.cells.pop()); + }; + + this.push = function(cell) { + if (Array.isArray(cell)) { + this.cells.push.apply(this.cells, cell); + var fragment = dom.createFragment(this.element); + for (var i=0; i foldStart) { row = fold.end.row + 1; @@ -582,95 +848,243 @@ var Gutter = function(parentEl) { foldStart = fold ? fold.start.row : Infinity; } if (row > lastRow) { - while (this.$cells.length > index + 1) { - cell = this.$cells.pop(); - this.element.removeChild(cell.element); - } + while (this.$lines.getLength() > index + 1) + this.$lines.pop(); + break; } - cell = this.$cells[++index]; + cell = this.$lines.get(++index); if (!cell) { - cell = {element: null, textNode: null, foldWidget: null}; - cell.element = dom.createElement("div"); - cell.textNode = document.createTextNode(''); - cell.element.appendChild(cell.textNode); - this.element.appendChild(cell.element); - this.$cells[index] = cell; + cell = this.$lines.createCell(row, config, this.session, onCreateCell); + this.$lines.push(cell); } - var className = "ace_gutter-cell "; - if (breakpoints[row]) - className += breakpoints[row]; - if (decorations[row]) - className += decorations[row]; - if (this.$annotations[row]) - className += this.$annotations[row].className; - if (cell.element.className != className) - cell.element.className = className; - - var height = session.getRowLength(row) * config.lineHeight + "px"; - if (height != cell.element.style.height) - cell.element.style.height = height; - - if (foldWidgets) { - var c = foldWidgets[row]; - if (c == null) - c = foldWidgets[row] = session.getFoldWidget(row); - } - - if (c) { - if (!cell.foldWidget) { - cell.foldWidget = dom.createElement("span"); - cell.element.appendChild(cell.foldWidget); - } - var className = "ace_fold-widget ace_" + c; - if (c == "start" && row == foldStart && row < fold.end.row) - className += " ace_closed"; - else - className += " ace_open"; - if (cell.foldWidget.className != className) - cell.foldWidget.className = className; - - var height = config.lineHeight + "px"; - if (cell.foldWidget.style.height != height) - cell.foldWidget.style.height = height; - } else { - if (cell.foldWidget) { - cell.element.removeChild(cell.foldWidget); - cell.foldWidget = null; - } - } - - var text = lastLineNumber = gutterRenderer - ? gutterRenderer.getText(session, row) - : row + firstLineNumber; - if (text !== cell.textNode.data) - cell.textNode.data = text; - + this.$renderCell(cell, config, fold, row); row++; } + + this._signal("afterRender"); + this.$updateGutterWidth(config); + }; - this.element.style.height = config.minHeight + "px"; - + this.$updateGutterWidth = function(config) { + var session = this.session; + + var gutterRenderer = session.gutterRenderer || this.$renderer; + + var firstLineNumber = session.$firstLineNumber; + var lastLineText = this.$lines.last() ? this.$lines.last().text : ""; + if (this.$fixedWidth || session.$useWrapMode) - lastLineNumber = session.getLength() + firstLineNumber; + lastLineText = session.getLength() + firstLineNumber; var gutterWidth = gutterRenderer - ? gutterRenderer.getWidth(session, lastLineNumber, config) - : lastLineNumber.toString().length * config.characterWidth; + ? gutterRenderer.getWidth(session, lastLineText, config) + : lastLineText.toString().length * config.characterWidth; var padding = this.$padding || this.$computePadding(); gutterWidth += padding.left + padding.right; if (gutterWidth !== this.gutterWidth && !isNaN(gutterWidth)) { this.gutterWidth = gutterWidth; + this.element.parentNode.style.width = this.element.style.width = Math.ceil(this.gutterWidth) + "px"; - this._emit("changeGutterWidth", gutterWidth); + this._signal("changeGutterWidth", gutterWidth); } }; + + this.$updateCursorRow = function() { + if (!this.$highlightGutterLine) + return; + + var position = this.session.selection.getCursor(); + if (this.$cursorRow === position.row) + return; + + this.$cursorRow = position.row; + }; + + this.updateLineHighlight = function() { + if (!this.$highlightGutterLine) + return; + var row = this.session.selection.cursor.row; + this.$cursorRow = row; + + if (this.$cursorCell && this.$cursorCell.row == row) + return; + if (this.$cursorCell) + this.$cursorCell.element.className = this.$cursorCell.element.className.replace("ace_gutter-active-line ", ""); + var cells = this.$lines.cells; + this.$cursorCell = null; + for (var i = 0; i < cells.length; i++) { + var cell = cells[i]; + if (cell.row >= this.$cursorRow) { + if (cell.row > this.$cursorRow) { + var fold = this.session.getFoldLine(this.$cursorRow); + if (i > 0 && fold && fold.start.row == cells[i - 1].row) + cell = cells[i - 1]; + else + break; + } + cell.element.className = "ace_gutter-active-line " + cell.element.className; + this.$cursorCell = cell; + break; + } + } + }; + + this.scrollLines = function(config) { + var oldConfig = this.config; + this.config = config; + + this.$updateCursorRow(); + if (this.$lines.pageChanged(oldConfig, config)) + return this.update(config); + + this.$lines.moveContainer(config); + + var lastRow = Math.min(config.lastRow + config.gutterOffset, // needed to compensate for hor scollbar + this.session.getLength() - 1); + var oldLastRow = this.oldLastRow; + this.oldLastRow = lastRow; + + if (!oldConfig || oldLastRow < config.firstRow) + return this.update(config); + + if (lastRow < oldConfig.firstRow) + return this.update(config); + + if (oldConfig.firstRow < config.firstRow) + for (var row=this.session.getFoldedRowCount(oldConfig.firstRow, config.firstRow - 1); row>0; row--) + this.$lines.shift(); + + if (oldLastRow > lastRow) + for (var row=this.session.getFoldedRowCount(lastRow + 1, oldLastRow); row>0; row--) + this.$lines.pop(); + + if (config.firstRow < oldConfig.firstRow) { + this.$lines.unshift(this.$renderLines(config, config.firstRow, oldConfig.firstRow - 1)); + } + + if (lastRow > oldLastRow) { + this.$lines.push(this.$renderLines(config, oldLastRow + 1, lastRow)); + } + + this.updateLineHighlight(); + + this._signal("afterRender"); + this.$updateGutterWidth(config); + }; + + this.$renderLines = function(config, firstRow, lastRow) { + var fragment = []; + var row = firstRow; + var foldLine = this.session.getNextFoldLine(row); + var foldStart = foldLine ? foldLine.start.row : Infinity; + + while (true) { + if (row > foldStart) { + row = foldLine.end.row+1; + foldLine = this.session.getNextFoldLine(row, foldLine); + foldStart = foldLine ? foldLine.start.row : Infinity; + } + if (row > lastRow) + break; + + var cell = this.$lines.createCell(row, config, this.session, onCreateCell); + this.$renderCell(cell, config, foldLine, row); + fragment.push(cell); + + row++; + } + return fragment; + }; + + this.$renderCell = function(cell, config, fold, row) { + var element = cell.element; + + var session = this.session; + + var textNode = element.childNodes[0]; + var foldWidget = element.childNodes[1]; + + var firstLineNumber = session.$firstLineNumber; + + var breakpoints = session.$breakpoints; + var decorations = session.$decorations; + var gutterRenderer = session.gutterRenderer || this.$renderer; + var foldWidgets = this.$showFoldWidgets && session.foldWidgets; + var foldStart = fold ? fold.start.row : Number.MAX_VALUE; + + var className = "ace_gutter-cell "; + if (this.$highlightGutterLine) { + if (row == this.$cursorRow || (fold && row < this.$cursorRow && row >= foldStart && this.$cursorRow <= fold.end.row)) { + className += "ace_gutter-active-line "; + if (this.$cursorCell != cell) { + if (this.$cursorCell) + this.$cursorCell.element.className = this.$cursorCell.element.className.replace("ace_gutter-active-line ", ""); + this.$cursorCell = cell; + } + } + } + + if (breakpoints[row]) + className += breakpoints[row]; + if (decorations[row]) + className += decorations[row]; + if (this.$annotations[row]) + className += this.$annotations[row].className; + if (element.className != className) + element.className = className; + + if (foldWidgets) { + var c = foldWidgets[row]; + if (c == null) + c = foldWidgets[row] = session.getFoldWidget(row); + } + + if (c) { + var className = "ace_fold-widget ace_" + c; + if (c == "start" && row == foldStart && row < fold.end.row) + className += " ace_closed"; + else + className += " ace_open"; + if (foldWidget.className != className) + foldWidget.className = className; + + var foldHeight = config.lineHeight + "px"; + dom.setStyle(foldWidget.style, "height", foldHeight); + dom.setStyle(foldWidget.style, "display", "inline-block"); + } else { + if (foldWidget) { + dom.setStyle(foldWidget.style, "display", "none"); + } + } + + var text = (gutterRenderer + ? gutterRenderer.getText(session, row) + : row + firstLineNumber).toString(); + + if (text !== textNode.data) { + textNode.data = text; + } + + dom.setStyle(cell.element.style, "height", this.$lines.computeLineHeight(row, config, session) + "px"); + dom.setStyle(cell.element.style, "top", this.$lines.computeLineTop(row, config, session) + "px"); + + cell.text = text; + cell.row = row; + return cell; + }; this.$fixedWidth = false; + this.$highlightGutterLine = true; + this.$renderer = ""; + this.setHighlightGutterLine = function(highlightGutterLine) { + this.$highlightGutterLine = highlightGutterLine; + }; + this.$showLineNumbers = true; this.$renderer = ""; this.setShowLineNumbers = function(show) { @@ -704,8 +1118,10 @@ var Gutter = function(parentEl) { return {left: 0, right: 0}; var style = dom.computedStyle(this.element.firstChild); this.$padding = {}; - this.$padding.left = parseInt(style.paddingLeft) + 1 || 0; - this.$padding.right = parseInt(style.paddingRight) || 0; + this.$padding.left = (parseInt(style.borderLeftWidth) || 0) + + (parseInt(style.paddingLeft) || 0) + 1; + this.$padding.right = (parseInt(style.borderRightWidth) || 0) + + (parseInt(style.paddingRight) || 0); return this.$padding; }; @@ -720,6 +1136,16 @@ var Gutter = function(parentEl) { }).call(Gutter.prototype); +function onCreateCell(element) { + var textNode = document.createTextNode(''); + element.appendChild(textNode); + + var foldWidget = dom.createElement("span"); + element.appendChild(foldWidget); + + return element; +} + exports.Gutter = Gutter; }); @@ -750,14 +1176,27 @@ var Marker = function(parentEl) { this.setMarkers = function(markers) { this.markers = markers; }; + + this.elt = function(className, css) { + var x = this.i != -1 && this.element.childNodes[this.i]; + if (!x) { + x = document.createElement("div"); + this.element.appendChild(x); + this.i = -1; + } else { + this.i++; + } + x.style.cssText = css; + x.className = className; + }; this.update = function(config) { if (!config) return; this.config = config; - - var html = []; + this.i = 0; + var html; for (var key in this.markers) { var marker = this.markers[key]; @@ -772,9 +1211,7 @@ var Marker = function(parentEl) { range = range.toScreenRange(this.session); if (marker.renderer) { var top = this.$getTop(range.start.row, config); - var left = this.$padding + (this.session.$bidiHandler.isBidiRow(range.start.row) - ? this.session.$bidiHandler.getPosLeft(range.start.column) - : range.start.column * config.characterWidth); + var left = this.$padding + range.start.column * config.characterWidth; marker.renderer(html, range, left, top, config); } else if (marker.type == "fullLine") { this.drawFullLineMarker(html, range, marker.clazz, config); @@ -786,14 +1223,13 @@ var Marker = function(parentEl) { else this.drawMultiLineMarker(html, range, marker.clazz, config); } else { - if (this.session.$bidiHandler.isBidiRow(range.start.row)) { - this.drawBidiSingleLineMarker(html, range, marker.clazz + " ace_start" + " ace_br15", config); - } else { - this.drawSingleLineMarker(html, range, marker.clazz + " ace_start" + " ace_br15", config); - } + this.drawSingleLineMarker(html, range, marker.clazz + " ace_start" + " ace_br15", config); } } - this.element.innerHTML = html.join(""); + if (this.i !=-1) { + while (this.i < this.element.childElementCount) + this.element.removeChild(this.element.lastChild); + } }; this.$getTop = function(row, layerConfig) { @@ -811,7 +1247,6 @@ var Marker = function(parentEl) { var prev = 0; var curr = 0; var next = session.getScreenLastRowColumn(row); - var clazzModified = null; var lineRange = new Range(row, range.start.column, row, curr); for (; row <= end; row++) { lineRange.start.row = lineRange.end.row = row; @@ -820,56 +1255,33 @@ var Marker = function(parentEl) { prev = curr; curr = next; next = row + 1 < end ? session.getScreenLastRowColumn(row + 1) : row == end ? 0 : range.end.column; - clazzModified = clazz + (row == start ? " ace_start" : "") + " ace_br" - + getBorderClass(row == start || row == start + 1 && range.start.column, prev < curr, curr > next, row == end); - - if (this.session.$bidiHandler.isBidiRow(row)) { - this.drawBidiSingleLineMarker(stringBuilder, lineRange, clazzModified, - layerConfig, row == end ? 0 : 1, extraStyle); - } else { - this.drawSingleLineMarker(stringBuilder, lineRange, clazzModified, - layerConfig, row == end ? 0 : 1, extraStyle); - } + this.drawSingleLineMarker(stringBuilder, lineRange, + clazz + (row == start ? " ace_start" : "") + " ace_br" + + getBorderClass(row == start || row == start + 1 && range.start.column, prev < curr, curr > next, row == end), + layerConfig, row == end ? 0 : 1, extraStyle); } }; this.drawMultiLineMarker = function(stringBuilder, range, clazz, config, extraStyle) { var padding = this.$padding; - var height, top, left; + var height = config.lineHeight; + var top = this.$getTop(range.start.row, config); + var left = padding + range.start.column * config.characterWidth; extraStyle = extraStyle || ""; - if (this.session.$bidiHandler.isBidiRow(range.start.row)) { - var range1 = range.clone(); - range1.end.row = range1.start.row; - range1.end.column = this.session.getLine(range1.start.row).length; - this.drawBidiSingleLineMarker(stringBuilder, range1, clazz + " ace_br1 ace_start", config, null, extraStyle); - } else { - height = config.lineHeight; - top = this.$getTop(range.start.row, config); - left = padding + range.start.column * config.characterWidth; - stringBuilder.push( - "
" - ); - } - if (this.session.$bidiHandler.isBidiRow(range.end.row)) { - var range1 = range.clone(); - range1.start.row = range1.end.row; - range1.start.column = 0; - this.drawBidiSingleLineMarker(stringBuilder, range1, clazz + " ace_br12", config, null, extraStyle); - } else { - var width = range.end.column * config.characterWidth; - height = config.lineHeight; - top = this.$getTop(range.end.row, config); - stringBuilder.push( - "
" - ); - } + + this.elt( + clazz + " ace_br1 ace_start", + "height:"+ height+ "px;"+ "right:0;"+ "top:"+top+ "px;left:"+ left+ "px;" + (extraStyle || "") + ); + top = this.$getTop(range.end.row, config); + var width = range.end.column * config.characterWidth; + + this.elt( + clazz + " ace_br12", + "height:"+ height+ "px;"+ + "width:"+ width+ "px;"+ + "top:"+ top+ "px;"+ + "left:"+ padding+ "px;"+ (extraStyle || "") + ); height = (range.end.row - range.start.row - 1) * config.lineHeight; if (height <= 0) return; @@ -877,12 +1289,12 @@ var Marker = function(parentEl) { var radiusClass = (range.start.column ? 1 : 0) | (range.end.column ? 0 : 8); - stringBuilder.push( - "
" + this.elt( + clazz + (radiusClass ? " ace_br" + radiusClass : ""), + "height:"+ height+ "px;"+ + "right:0;"+ + "top:"+ top+ "px;"+ + "left:"+ padding+ "px;"+ (extraStyle || "") ); }; this.drawSingleLineMarker = function(stringBuilder, range, clazz, config, extraLength, extraStyle) { @@ -892,28 +1304,14 @@ var Marker = function(parentEl) { var top = this.$getTop(range.start.row, config); var left = this.$padding + range.start.column * config.characterWidth; - stringBuilder.push( - "
" + this.elt( + clazz, + "height:"+ height+ "px;"+ + "width:"+ width+ "px;"+ + "top:"+ top+ "px;"+ + "left:"+ left+ "px;"+ (extraStyle || "") ); }; - this.drawBidiSingleLineMarker = function(stringBuilder, range, clazz, config, extraLength, extraStyle) { - var height = config.lineHeight, top = this.$getTop(range.start.row, config), padding = this.$padding; - var selections = this.session.$bidiHandler.getSelections(range.start.column, range.end.column); - - selections.forEach(function(selection) { - stringBuilder.push( - "
" - ); - }); - }; this.drawFullLineMarker = function(stringBuilder, range, clazz, config, extraStyle) { var top = this.$getTop(range.start.row, config); @@ -921,11 +1319,11 @@ var Marker = function(parentEl) { if (range.start.row != range.end.row) height += this.$getTop(range.end.row, config) - top; - stringBuilder.push( - "
" + this.elt( + clazz, + "height:"+ height+ "px;"+ + "top:"+ top+ "px;"+ + "left:0;right:0;"+ (extraStyle || "") ); }; @@ -933,11 +1331,11 @@ var Marker = function(parentEl) { var top = this.$getTop(range.start.row, config); var height = config.lineHeight; - stringBuilder.push( - "
" + this.elt( + clazz, + "height:"+ height+ "px;"+ + "top:"+ top+ "px;"+ + "left:0;right:0;"+ (extraStyle || "") ); }; @@ -953,14 +1351,16 @@ define("ace/layer/text",[], function(require, exports, module) { var oop = require("../lib/oop"); var dom = require("../lib/dom"); var lang = require("../lib/lang"); -var useragent = require("../lib/useragent"); +var Lines = require("./lines").Lines; var EventEmitter = require("../lib/event_emitter").EventEmitter; var Text = function(parentEl) { - this.element = dom.createElement("div"); + this.dom = dom; + this.element = this.dom.createElement("div"); this.element.className = "ace_layer ace_text-layer"; parentEl.appendChild(this.element); this.$updateEolChar = this.$updateEolChar.bind(this); + this.$lines = new Lines(this.element); }; (function() { @@ -988,7 +1388,7 @@ var Text = function(parentEl) { this.setPadding = function(padding) { this.$padding = padding; - this.element.style.padding = "0 " + padding + "px"; + this.element.style.margin = "0 " + padding + "px"; }; this.getLineHeight = function() { @@ -1047,11 +1447,12 @@ var Text = function(parentEl) { var tabStr = this.$tabStrings = [0]; for (var i = 1; i < tabSize + 1; i++) { if (this.showInvisibles) { - tabStr.push("" - + lang.stringRepeat(this.TAB_CHAR, i) - + ""); + var span = this.dom.createElement("span"); + span.className = "ace_invisible ace_invisible_tab"; + span.textContent = lang.stringRepeat(this.TAB_CHAR, i); + tabStr.push(span); } else { - tabStr.push(lang.stringRepeat(" ", i)); + tabStr.push(this.dom.createTextNode(lang.stringRepeat(" ", i), this.element)); } } if (this.displayIndentGuides) { @@ -1065,21 +1466,29 @@ var Text = function(parentEl) { tabClass = " ace_invisible_tab"; var spaceContent = lang.stringRepeat(this.SPACE_CHAR, this.tabSize); var tabContent = lang.stringRepeat(this.TAB_CHAR, this.tabSize); - } else{ + } else { var spaceContent = lang.stringRepeat(" ", this.tabSize); var tabContent = spaceContent; } - this.$tabStrings[" "] = "" + spaceContent + ""; - this.$tabStrings["\t"] = "" + tabContent + ""; + var span = this.dom.createElement("span"); + span.className = className + spaceClass; + span.textContent = spaceContent; + this.$tabStrings[" "] = span; + + var span = this.dom.createElement("span"); + span.className = className + tabClass; + span.textContent = tabContent; + this.$tabStrings["\t"] = span; } }; this.updateLines = function(config, firstRow, lastRow) { if (this.config.lastRow != config.lastRow || this.config.firstRow != config.firstRow) { - this.scrollLines(config); + return this.update(config); } + this.config = config; var first = Math.max(firstRow, config.firstRow); @@ -1101,6 +1510,7 @@ var Text = function(parentEl) { lineElementsIdx ++; } + var heightChanged = false; var row = first; var foldLine = this.session.getNextFoldLine(row); var foldStart = foldLine ? foldLine.start.row : Infinity; @@ -1116,52 +1526,69 @@ var Text = function(parentEl) { var lineElement = lineElements[lineElementsIdx++]; if (lineElement) { - var html = []; + this.dom.removeChildren(lineElement); this.$renderLine( - html, row, !this.$useLineGroups(), row == foldStart ? foldLine : false + lineElement, row, row == foldStart ? foldLine : false ); - lineElement.style.height = config.lineHeight * this.session.getRowLength(row) + "px"; - lineElement.innerHTML = html.join(""); + var height = (config.lineHeight * this.session.getRowLength(row)) + "px"; + if (lineElement.style.height != height) { + heightChanged = true; + lineElement.style.height = height; + } } row++; } + if (heightChanged) { + while (lineElementsIdx < this.$lines.cells.length) { + var cell = this.$lines.cells[lineElementsIdx++]; + cell.element.style.top = this.$lines.computeLineTop(cell.row, config, this.session) + "px"; + } + } }; this.scrollLines = function(config) { var oldConfig = this.config; this.config = config; + if (this.$lines.pageChanged(oldConfig, config)) + return this.update(config); + + this.$lines.moveContainer(config); + + var lastRow = config.lastRow; + var oldLastRow = oldConfig ? oldConfig.lastRow : -1; + + if (!oldConfig || oldLastRow < config.firstRow) + return this.update(config); + + if (lastRow < oldConfig.firstRow) + return this.update(config); + if (!oldConfig || oldConfig.lastRow < config.firstRow) return this.update(config); if (config.lastRow < oldConfig.firstRow) return this.update(config); - var el = this.element; if (oldConfig.firstRow < config.firstRow) for (var row=this.session.getFoldedRowCount(oldConfig.firstRow, config.firstRow - 1); row>0; row--) - el.removeChild(el.firstChild); + this.$lines.shift(); if (oldConfig.lastRow > config.lastRow) for (var row=this.session.getFoldedRowCount(config.lastRow + 1, oldConfig.lastRow); row>0; row--) - el.removeChild(el.lastChild); + this.$lines.pop(); if (config.firstRow < oldConfig.firstRow) { - var fragment = this.$renderLinesFragment(config, config.firstRow, oldConfig.firstRow - 1); - if (el.firstChild) - el.insertBefore(fragment, el.firstChild); - else - el.appendChild(fragment); + this.$lines.unshift(this.$renderLinesFragment(config, config.firstRow, oldConfig.firstRow - 1)); } if (config.lastRow > oldConfig.lastRow) { - var fragment = this.$renderLinesFragment(config, oldConfig.lastRow + 1, config.lastRow); - el.appendChild(fragment); + this.$lines.push(this.$renderLinesFragment(config, oldConfig.lastRow + 1, config.lastRow)); } }; this.$renderLinesFragment = function(config, firstRow, lastRow) { - var fragment = this.element.ownerDocument.createDocumentFragment(); + var fragment = []; var row = firstRow; var foldLine = this.session.getNextFoldLine(row); var foldStart = foldLine ? foldLine.start.row : Infinity; @@ -1175,21 +1602,20 @@ var Text = function(parentEl) { if (row > lastRow) break; - var container = dom.createElement("div"); + var line = this.$lines.createCell(row, config, this.session); + + var lineEl = line.element; + this.dom.removeChildren(lineEl); + dom.setStyle(lineEl.style, "height", this.$lines.computeLineHeight(row, config, this.session) + "px"); + dom.setStyle(lineEl.style, "top", this.$lines.computeLineTop(row, config, this.session) + "px"); + this.$renderLine(lineEl, row, row == foldStart ? foldLine : false); - var html = []; - this.$renderLine(html, row, false, row == foldStart ? foldLine : false); - - container.innerHTML = html.join(""); if (this.$useLineGroups()) { - container.className = 'ace_line_group'; - fragment.appendChild(container); - container.style.height = config.lineHeight * this.session.getRowLength(row) + "px"; - + lineEl.className = "ace_line_group"; } else { - while(container.firstChild) - fragment.appendChild(container.firstChild); + lineEl.className = "ace_line"; } + fragment.push(line); row++; } @@ -1197,35 +1623,18 @@ var Text = function(parentEl) { }; this.update = function(config) { + this.$lines.moveContainer(config); + this.config = config; - var html = []; - var firstRow = config.firstRow, lastRow = config.lastRow; + var firstRow = config.firstRow; + var lastRow = config.lastRow; - var row = firstRow; - var foldLine = this.session.getNextFoldLine(row); - var foldStart = foldLine ? foldLine.start.row : Infinity; - - while (true) { - if (row > foldStart) { - row = foldLine.end.row+1; - foldLine = this.session.getNextFoldLine(row, foldLine); - foldStart = foldLine ? foldLine.start.row :Infinity; - } - if (row > lastRow) - break; - - if (this.$useLineGroups()) - html.push("
"); - - this.$renderLine(html, row, false, row == foldStart ? foldLine : false); - - if (this.$useLineGroups()) - html.push("
"); // end the line group - - row++; - } - this.element.innerHTML = html.join(""); + var lines = this.$lines; + while (lines.getLength()) + lines.pop(); + + lines.push(this.$renderLinesFragment(config, firstRow, lastRow)); }; this.$textToken = { @@ -1234,108 +1643,153 @@ var Text = function(parentEl) { "lparen": true }; - this.$renderToken = function(stringBuilder, screenColumn, token, value) { + this.$renderToken = function(parent, screenColumn, token, value) { var self = this; - var replaceReg = /\t|&|<|>|( +)|([\x00-\x1f\x80-\xa0\xad\u1680\u180E\u2000-\u200f\u2028\u2029\u202F\u205F\u3000\uFEFF\uFFF9-\uFFFC])|[\u1100-\u115F\u11A3-\u11A7\u11FA-\u11FF\u2329-\u232A\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u2FFB\u3000-\u303E\u3041-\u3096\u3099-\u30FF\u3105-\u312D\u3131-\u318E\u3190-\u31BA\u31C0-\u31E3\u31F0-\u321E\u3220-\u3247\u3250-\u32FE\u3300-\u4DBF\u4E00-\uA48C\uA490-\uA4C6\uA960-\uA97C\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFAFF\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE66\uFE68-\uFE6B\uFF01-\uFF60\uFFE0-\uFFE6]|[\uD800-\uDBFF][\uDC00-\uDFFF]/g; - var replaceFunc = function(c, a, b, tabIdx, idx4) { - if (a) { - return self.showInvisibles - ? "" + lang.stringRepeat(self.SPACE_CHAR, c.length) + "" - : c; - } else if (c == "&") { - return "&"; - } else if (c == "<") { - return "<"; - } else if (c == ">") { - return ">"; - } else if (c == "\t") { - var tabSize = self.session.getScreenTabSize(screenColumn + tabIdx); + var re = /(\t)|( +)|([\x00-\x1f\x80-\xa0\xad\u1680\u180E\u2000-\u200f\u2028\u2029\u202F\u205F\uFEFF\uFFF9-\uFFFC]+)|(\u3000)|([\u1100-\u115F\u11A3-\u11A7\u11FA-\u11FF\u2329-\u232A\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u2FFB\u3001-\u303E\u3041-\u3096\u3099-\u30FF\u3105-\u312D\u3131-\u318E\u3190-\u31BA\u31C0-\u31E3\u31F0-\u321E\u3220-\u3247\u3250-\u32FE\u3300-\u4DBF\u4E00-\uA48C\uA490-\uA4C6\uA960-\uA97C\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFAFF\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE66\uFE68-\uFE6B\uFF01-\uFF60\uFFE0-\uFFE6]|[\uD800-\uDBFF][\uDC00-\uDFFF])/g; + + var valueFragment = this.dom.createFragment(this.element); + + var m; + var i = 0; + while (m = re.exec(value)) { + var tab = m[1]; + var simpleSpace = m[2]; + var controlCharacter = m[3]; + var cjkSpace = m[4]; + var cjk = m[5]; + + if (!self.showInvisibles && simpleSpace) + continue; + + var before = i != m.index ? value.slice(i, m.index) : ""; + + i = m.index + m[0].length; + + if (before) { + valueFragment.appendChild(this.dom.createTextNode(before, this.element)); + } + + if (tab) { + var tabSize = self.session.getScreenTabSize(screenColumn + m.index); + valueFragment.appendChild(self.$tabStrings[tabSize].cloneNode(true)); screenColumn += tabSize - 1; - return self.$tabStrings[tabSize]; - } else if (c == "\u3000") { - var classToUse = self.showInvisibles ? "ace_cjk ace_invisible ace_invisible_space" : "ace_cjk"; + } else if (simpleSpace) { + if (self.showInvisibles) { + var span = this.dom.createElement("span"); + span.className = "ace_invisible ace_invisible_space"; + span.textContent = lang.stringRepeat(self.SPACE_CHAR, simpleSpace.length); + valueFragment.appendChild(span); + } else { + valueFragment.appendChild(this.com.createTextNode(simpleSpace, this.element)); + } + } else if (controlCharacter) { + var span = this.dom.createElement("span"); + span.className = "ace_invisible ace_invisible_space ace_invalid"; + span.textContent = lang.stringRepeat(self.SPACE_CHAR, controlCharacter.length); + valueFragment.appendChild(span); + } else if (cjkSpace) { var space = self.showInvisibles ? self.SPACE_CHAR : ""; screenColumn += 1; - return "" + space + ""; - } else if (b) { - return "" + self.SPACE_CHAR + ""; - } else { + + var span = this.dom.createElement("span"); + span.style.width = (self.config.characterWidth * 2) + "px"; + span.className = self.showInvisibles ? "ace_cjk ace_invisible ace_invisible_space" : "ace_cjk"; + span.textContent = self.showInvisibles ? self.SPACE_CHAR : ""; + valueFragment.appendChild(span); + } else if (cjk) { screenColumn += 1; - return "" + c + ""; + var span = dom.createElement("span"); + span.style.width = (self.config.characterWidth * 2) + "px"; + span.className = "ace_cjk"; + span.textContent = cjk; + valueFragment.appendChild(span); } - }; - - var output = value.replace(replaceReg, replaceFunc); + } + + valueFragment.appendChild(this.dom.createTextNode(i ? value.slice(i) : value, this.element)); if (!this.$textToken[token.type]) { var classes = "ace_" + token.type.replace(/\./g, " ace_"); - var style = ""; + var span = this.dom.createElement("span"); if (token.type == "fold") - style = " style='width:" + (token.value.length * this.config.characterWidth) + "px;' "; - stringBuilder.push("", output, ""); + span.style.width = (token.value.length * this.config.characterWidth) + "px"; + + span.className = classes; + span.appendChild(valueFragment); + + parent.appendChild(span); } else { - stringBuilder.push(output); + parent.appendChild(valueFragment); } + return screenColumn + value.length; }; - this.renderIndentGuide = function(stringBuilder, value, max) { + this.renderIndentGuide = function(parent, value, max) { var cols = value.search(this.$indentGuideRe); if (cols <= 0 || cols >= max) return value; if (value[0] == " ") { cols -= cols % this.tabSize; - stringBuilder.push(lang.stringRepeat(this.$tabStrings[" "], cols/this.tabSize)); + var count = cols/this.tabSize; + for (var i=0; i= splitChars) { screenColumn = this.$renderToken( - stringBuilder, screenColumn, + lineEl, screenColumn, token, value.substring(0, splitChars - chars) ); value = value.substring(splitChars - chars); chars = splitChars; - if (!onlyContents) { - stringBuilder.push("
", - "
" - ); - } + lineEl = this.$createLineElement(); + parent.appendChild(lineEl); - stringBuilder.push(lang.stringRepeat("\xa0", splits.indent)); + lineEl.appendChild(this.dom.createTextNode(lang.stringRepeat("\xa0", splits.indent), this.element)); split ++; screenColumn = 0; @@ -1344,38 +1798,43 @@ var Text = function(parentEl) { if (value.length != 0) { chars += value.length; screenColumn = this.$renderToken( - stringBuilder, screenColumn, token, value + lineEl, screenColumn, token, value ); } } } }; - this.$renderSimpleLine = function(stringBuilder, tokens) { + this.$renderSimpleLine = function(parent, tokens) { var screenColumn = 0; var token = tokens[0]; var value = token.value; if (this.displayIndentGuides) - value = this.renderIndentGuide(stringBuilder, value); + value = this.renderIndentGuide(parent, value); if (value) - screenColumn = this.$renderToken(stringBuilder, screenColumn, token, value); + screenColumn = this.$renderToken(parent, screenColumn, token, value); for (var i = 1; i < tokens.length; i++) { token = tokens[i]; value = token.value; if (screenColumn + value.length > this.MAX_LINE_LENGTH) - return this.$renderOverflowMessage(stringBuilder, screenColumn, token, value); - screenColumn = this.$renderToken(stringBuilder, screenColumn, token, value); + return this.$renderOverflowMessage(parent, screenColumn, token, value); + screenColumn = this.$renderToken(parent, screenColumn, token, value); } }; - this.$renderOverflowMessage = function(stringBuilder, screenColumn, token, value) { - this.$renderToken(stringBuilder, screenColumn, token, + this.$renderOverflowMessage = function(parent, screenColumn, token, value) { + this.$renderToken(parent, screenColumn, token, value.slice(0, this.MAX_LINE_LENGTH - screenColumn)); - stringBuilder.push( - "<click to see more...>" - ); + + var overflowEl = this.dom.createElement("span"); + overflowEl.className = "ace_inline_button ace_keyword ace_toggle_wrap"; + overflowEl.style.position = "absolute"; + overflowEl.style.right = "0"; + overflowEl.textContent = ""; + + parent.appendChild(overflowEl); }; - this.$renderLine = function(stringBuilder, row, onlyContents, foldLine) { + this.$renderLine = function(parent, row, foldLine) { if (!foldLine && foldLine != false) foldLine = this.session.getFoldLine(row); @@ -1384,36 +1843,35 @@ var Text = function(parentEl) { else var tokens = this.session.getTokens(row); - - if (!onlyContents) { - stringBuilder.push( - "
" - ); - } - + var lastLineEl = parent; if (tokens.length) { var splits = this.session.getRowSplitData(row); - if (splits && splits.length) - this.$renderWrappedLine(stringBuilder, tokens, splits, onlyContents); - else - this.$renderSimpleLine(stringBuilder, tokens); + if (splits && splits.length) { + this.$renderWrappedLine(parent, tokens, splits); + var lastLineEl = parent.lastChild; + } else { + var lastLineEl = parent; + if (this.$useLineGroups()) { + lastLineEl = this.$createLineElement(); + parent.appendChild(lastLineEl); + } + this.$renderSimpleLine(lastLineEl, tokens); + } + } else if (this.$useLineGroups()) { + lastLineEl = this.$createLineElement(); + parent.appendChild(lastLineEl); } - if (this.showInvisibles) { + if (this.showInvisibles && lastLineEl) { if (foldLine) row = foldLine.end.row; - stringBuilder.push( - "", - row == this.session.getLength() - 1 ? this.EOF_CHAR : this.EOL_CHAR, - "" - ); + var invisibleEl = this.dom.createElement("span"); + invisibleEl.className = "ace_invisible ace_invisible_eol"; + invisibleEl.textContent = row == this.session.getLength() - 1 ? this.EOF_CHAR : this.EOL_CHAR; + + lastLineEl.appendChild(invisibleEl); } - if (!onlyContents) - stringBuilder.push("
"); }; this.$getFoldLineTokens = function(row, foldLine) { @@ -1497,16 +1955,12 @@ define("ace/layer/cursor",[], function(require, exports, module) { "use strict"; var dom = require("../lib/dom"); -var isIE8; var Cursor = function(parentEl) { this.element = dom.createElement("div"); this.element.className = "ace_layer ace_cursor-layer"; parentEl.appendChild(this.element); - if (isIE8 === undefined) - isIE8 = !("opacity" in this.element.style); - this.isVisible = false; this.isBlinking = true; this.blinkInterval = 1000; @@ -1515,24 +1969,30 @@ var Cursor = function(parentEl) { this.cursors = []; this.cursor = this.addCursor(); dom.addCssClass(this.element, "ace_hidden-cursors"); - this.$updateCursors = (isIE8 - ? this.$updateVisibility - : this.$updateOpacity).bind(this); + this.$updateCursors = this.$updateOpacity.bind(this); }; (function() { - this.$updateVisibility = function(val) { - var cursors = this.cursors; - for (var i = cursors.length; i--; ) - cursors[i].style.visibility = val ? "" : "hidden"; - }; this.$updateOpacity = function(val) { var cursors = this.cursors; for (var i = cursors.length; i--; ) - cursors[i].style.opacity = val ? "" : "0"; + dom.setStyle(cursors[i].style, "opacity", val ? "" : "0"); + }; + + this.$startCssAnimation = function() { + var cursors = this.cursors; + for (var i = cursors.length; i--; ) + cursors[i].style.animationDuration = this.blinkInterval + "ms"; + + setTimeout(function() { + dom.addCssClass(this.element, "ace_animate-blinking"); + }.bind(this)); }; + this.$stopCssAnimation = function() { + dom.removeCssClass(this.element, "ace_animate-blinking"); + }; this.$padding = 0; this.setPadding = function(padding) { @@ -1544,25 +2004,24 @@ var Cursor = function(parentEl) { }; this.setBlinking = function(blinking) { - if (blinking != this.isBlinking){ + if (blinking != this.isBlinking) { this.isBlinking = blinking; this.restartTimer(); } }; this.setBlinkInterval = function(blinkInterval) { - if (blinkInterval != this.blinkInterval){ + if (blinkInterval != this.blinkInterval) { this.blinkInterval = blinkInterval; this.restartTimer(); } }; this.setSmoothBlinking = function(smoothBlinking) { - if (smoothBlinking != this.smoothBlinking && !isIE8) { + if (smoothBlinking != this.smoothBlinking) { this.smoothBlinking = smoothBlinking; dom.setCssClass(this.element, "ace_smooth-blinking", smoothBlinking); this.$updateCursors(true); - this.$updateCursors = (this.$updateOpacity).bind(this); this.restartTimer(); } }; @@ -1599,14 +2058,18 @@ var Cursor = function(parentEl) { var update = this.$updateCursors; clearInterval(this.intervalId); clearTimeout(this.timeoutId); + this.$stopCssAnimation(); + if (this.smoothBlinking) { dom.removeCssClass(this.element, "ace_smooth-blinking"); } update(true); - if (!this.isBlinking || !this.blinkInterval || !this.isVisible) + if (!this.isBlinking || !this.blinkInterval || !this.isVisible) { + this.$stopCssAnimation(); return; + } if (this.smoothBlinking) { setTimeout(function(){ @@ -1614,18 +2077,21 @@ var Cursor = function(parentEl) { }.bind(this)); } - var blink = function(){ - this.timeoutId = setTimeout(function() { - update(false); - }, 0.6 * this.blinkInterval); - }.bind(this); - - this.intervalId = setInterval(function() { - update(true); + if (dom.HAS_CSS_ANIMATION) { + this.$startCssAnimation(); + } else { + var blink = function(){ + this.timeoutId = setTimeout(function() { + update(false); + }, 0.6 * this.blinkInterval); + }.bind(this); + + this.intervalId = setInterval(function() { + update(true); + blink(); + }, this.blinkInterval); blink(); - }, this.blinkInterval); - - blink(); + } }; this.getPixelPosition = function(position, onScreen) { @@ -1645,6 +2111,10 @@ var Cursor = function(parentEl) { return {left : cursorLeft, top : cursorTop}; }; + this.isCursorInView = function(pixelPos, config) { + return pixelPos.top >= 0 && pixelPos.top < config.maxHeight; + }; + this.update = function(config) { this.config = config; @@ -1662,15 +2132,20 @@ var Cursor = function(parentEl) { continue; } - var style = (this.cursors[cursorIndex++] || this.addCursor()).style; + var element = this.cursors[cursorIndex++] || this.addCursor(); + var style = element.style; if (!this.drawCursor) { - style.left = pixelPos.left + "px"; - style.top = pixelPos.top + "px"; - style.width = config.characterWidth + "px"; - style.height = config.lineHeight + "px"; + if (!this.isCursorInView(pixelPos, config)) { + dom.setStyle(style, "display", "none"); + } else { + dom.setStyle(style, "display", "block"); + dom.translate(element, pixelPos.left, pixelPos.top); + dom.setStyle(style, "width", Math.round(config.characterWidth) + "px"); + dom.setStyle(style, "height", config.lineHeight + "px"); + } } else { - this.drawCursor(style, pixelPos, config, selections[i], this.session); + this.drawCursor(element, pixelPos, config, selections[i], this.session); } } while (this.cursors.length > cursorIndex) @@ -1857,20 +2332,23 @@ var RenderLoop = function(onRender, win) { (function() { - this.schedule = function(change) { this.changes = this.changes | change; - if (!this.pending && this.changes) { - this.pending = true; + if (this.changes) { var _self = this; - event.nextFrame(function() { - _self.pending = false; - var changes; - while (changes = _self.changes) { + + event.nextFrame(function(ts) { + var changes = _self.changes; + + if (changes) { + event.blockIdle(100); _self.changes = 0; _self.onRender(changes); } - }, this.window); + + if (_self.changes) + _self.schedule(); + }); } }; @@ -1884,6 +2362,7 @@ define("ace/layer/font_metrics",[], function(require, exports, module) { var oop = require("../lib/oop"); var dom = require("../lib/dom"); var lang = require("../lib/lang"); +var event = require("../lib/event"); var useragent = require("../lib/useragent"); var EventEmitter = require("../lib/event_emitter").EventEmitter; @@ -1968,8 +2447,10 @@ var FontMetrics = exports.FontMetrics = function(parentEl) { if (this.$pollSizeChangesTimer || this.$observer) return this.$pollSizeChangesTimer; var self = this; - return this.$pollSizeChangesTimer = setInterval(function() { + + return this.$pollSizeChangesTimer = event.onIdle(function cb() { self.checkForSizeChanges(); + event.onIdle(cb, 500); }, 500); }; @@ -2074,7 +2555,7 @@ var FontMetrics = exports.FontMetrics = function(parentEl) { }); -define("ace/requirejs/text!ace/css/editor.css",[],".ace_editor {\n position: relative;\n overflow: hidden;\n font: 12px/normal 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'source-code-pro', monospace;\n direction: ltr;\n text-align: left;\n -webkit-tap-highlight-color: rgba(0, 0, 0, 0);\n}\n\n.ace_scroller {\n position: absolute;\n overflow: hidden;\n top: 0;\n bottom: 0;\n background-color: inherit;\n -ms-user-select: none;\n -moz-user-select: none;\n -webkit-user-select: none;\n user-select: none;\n cursor: text;\n}\n\n.ace_content {\n position: absolute;\n box-sizing: border-box;\n min-width: 100%;\n}\n\n.ace_dragging .ace_scroller:before{\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n content: '';\n background: rgba(250, 250, 250, 0.01);\n z-index: 1000;\n}\n.ace_dragging.ace_dark .ace_scroller:before{\n background: rgba(0, 0, 0, 0.01);\n}\n\n.ace_gutter {\n position: absolute;\n overflow : hidden;\n width: auto;\n top: 0;\n bottom: 0;\n left: 0;\n cursor: default;\n z-index: 4;\n -ms-user-select: none;\n -moz-user-select: none;\n -webkit-user-select: none;\n user-select: none;\n}\n\n.ace_gutter-active-line {\n position: absolute;\n left: 0;\n right: 0;\n}\n\n.ace_scroller.ace_scroll-left {\n box-shadow: 17px 0 16px -16px rgba(0, 0, 0, 0.4) inset;\n}\n\n.ace_gutter-cell {\n padding-left: 19px;\n padding-right: 6px;\n background-repeat: no-repeat;\n}\n\n.ace_gutter-cell.ace_error {\n background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAABOFBMVEX/////////QRswFAb/Ui4wFAYwFAYwFAaWGAfDRymzOSH/PxswFAb/SiUwFAYwFAbUPRvjQiDllog5HhHdRybsTi3/Tyv9Tir+Syj/UC3////XurebMBIwFAb/RSHbPx/gUzfdwL3kzMivKBAwFAbbvbnhPx66NhowFAYwFAaZJg8wFAaxKBDZurf/RB6mMxb/SCMwFAYwFAbxQB3+RB4wFAb/Qhy4Oh+4QifbNRcwFAYwFAYwFAb/QRzdNhgwFAYwFAbav7v/Uy7oaE68MBK5LxLewr/r2NXewLswFAaxJw4wFAbkPRy2PyYwFAaxKhLm1tMwFAazPiQwFAaUGAb/QBrfOx3bvrv/VC/maE4wFAbRPBq6MRO8Qynew8Dp2tjfwb0wFAbx6eju5+by6uns4uH9/f36+vr/GkHjAAAAYnRSTlMAGt+64rnWu/bo8eAA4InH3+DwoN7j4eLi4xP99Nfg4+b+/u9B/eDs1MD1mO7+4PHg2MXa347g7vDizMLN4eG+Pv7i5evs/v79yu7S3/DV7/498Yv24eH+4ufQ3Ozu/v7+y13sRqwAAADLSURBVHjaZc/XDsFgGIBhtDrshlitmk2IrbHFqL2pvXf/+78DPokj7+Fz9qpU/9UXJIlhmPaTaQ6QPaz0mm+5gwkgovcV6GZzd5JtCQwgsxoHOvJO15kleRLAnMgHFIESUEPmawB9ngmelTtipwwfASilxOLyiV5UVUyVAfbG0cCPHig+GBkzAENHS0AstVF6bacZIOzgLmxsHbt2OecNgJC83JERmePUYq8ARGkJx6XtFsdddBQgZE2nPR6CICZhawjA4Fb/chv+399kfR+MMMDGOQAAAABJRU5ErkJggg==\");\n background-repeat: no-repeat;\n background-position: 2px center;\n}\n\n.ace_gutter-cell.ace_warning {\n background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAAmVBMVEX///8AAAD///8AAAAAAABPSzb/5sAAAAB/blH/73z/ulkAAAAAAAD85pkAAAAAAAACAgP/vGz/rkDerGbGrV7/pkQICAf////e0IsAAAD/oED/qTvhrnUAAAD/yHD/njcAAADuv2r/nz//oTj/p064oGf/zHAAAAA9Nir/tFIAAAD/tlTiuWf/tkIAAACynXEAAAAAAAAtIRW7zBpBAAAAM3RSTlMAABR1m7RXO8Ln31Z36zT+neXe5OzooRDfn+TZ4p3h2hTf4t3k3ucyrN1K5+Xaks52Sfs9CXgrAAAAjklEQVR42o3PbQ+CIBQFYEwboPhSYgoYunIqqLn6/z8uYdH8Vmdnu9vz4WwXgN/xTPRD2+sgOcZjsge/whXZgUaYYvT8QnuJaUrjrHUQreGczuEafQCO/SJTufTbroWsPgsllVhq3wJEk2jUSzX3CUEDJC84707djRc5MTAQxoLgupWRwW6UB5fS++NV8AbOZgnsC7BpEAAAAABJRU5ErkJggg==\");\n background-position: 2px center;\n}\n\n.ace_gutter-cell.ace_info {\n background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAAAAAA6mKC9AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAAJ0Uk5TAAB2k804AAAAPklEQVQY02NgIB68QuO3tiLznjAwpKTgNyDbMegwisCHZUETUZV0ZqOquBpXj2rtnpSJT1AEnnRmL2OgGgAAIKkRQap2htgAAAAASUVORK5CYII=\");\n background-position: 2px center;\n}\n.ace_dark .ace_gutter-cell.ace_info {\n background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQBAMAAADt3eJSAAAAJFBMVEUAAAChoaGAgIAqKiq+vr6tra1ZWVmUlJSbm5s8PDxubm56enrdgzg3AAAAAXRSTlMAQObYZgAAAClJREFUeNpjYMAPdsMYHegyJZFQBlsUlMFVCWUYKkAZMxZAGdxlDMQBAG+TBP4B6RyJAAAAAElFTkSuQmCC\");\n}\n\n.ace_scrollbar {\n position: absolute;\n right: 0;\n bottom: 0;\n z-index: 6;\n}\n\n.ace_scrollbar-inner {\n position: absolute;\n cursor: text;\n left: 0;\n top: 0;\n}\n\n.ace_scrollbar-v{\n overflow-x: hidden;\n overflow-y: scroll;\n top: 0;\n}\n\n.ace_scrollbar-h {\n overflow-x: scroll;\n overflow-y: hidden;\n left: 0;\n}\n\n.ace_print-margin {\n position: absolute;\n height: 100%;\n}\n\n.ace_text-input {\n position: absolute;\n z-index: 0;\n width: 0.5em;\n height: 1em;\n opacity: 0;\n background: transparent;\n -moz-appearance: none;\n appearance: none;\n border: none;\n resize: none;\n outline: none;\n overflow: hidden;\n font: inherit;\n padding: 0 1px;\n margin: 0 -1px;\n text-indent: -1em;\n -ms-user-select: text;\n -moz-user-select: text;\n -webkit-user-select: text;\n user-select: text;\n white-space: pre!important;\n}\n.ace_text-input.ace_composition {\n background: inherit;\n color: inherit;\n z-index: 1000;\n opacity: 1;\n text-indent: 0;\n}\n[ace_nocontext=true] {\n transform: none!important;\n filter: none!important;\n perspective: none!important;\n clip-path: none!important;\n mask : none!important;\n contain: none!important;\n perspective: none!important;\n mix-blend-mode: initial!important;\n z-index: auto;\n}\n\n.ace_layer {\n z-index: 1;\n position: absolute;\n overflow: hidden;\n word-wrap: normal;\n white-space: pre;\n height: 100%;\n width: 100%;\n box-sizing: border-box;\n pointer-events: none;\n}\n\n.ace_gutter-layer {\n position: relative;\n width: auto;\n text-align: right;\n pointer-events: auto;\n}\n\n.ace_text-layer {\n font: inherit !important;\n}\n\n.ace_cjk {\n display: inline-block;\n text-align: center;\n}\n\n.ace_cursor-layer {\n z-index: 4;\n}\n\n.ace_cursor {\n z-index: 4;\n position: absolute;\n box-sizing: border-box;\n border-left: 2px solid;\n transform: translatez(0);\n}\n\n.ace_multiselect .ace_cursor {\n border-left-width: 1px;\n}\n\n.ace_slim-cursors .ace_cursor {\n border-left-width: 1px;\n}\n\n.ace_overwrite-cursors .ace_cursor {\n border-left-width: 0;\n border-bottom: 1px solid;\n}\n\n.ace_hidden-cursors .ace_cursor {\n opacity: 0.2;\n}\n\n.ace_smooth-blinking .ace_cursor {\n transition: opacity 0.18s;\n}\n\n.ace_marker-layer .ace_step, .ace_marker-layer .ace_stack {\n position: absolute;\n z-index: 3;\n}\n\n.ace_marker-layer .ace_selection {\n position: absolute;\n z-index: 5;\n}\n\n.ace_marker-layer .ace_bracket {\n position: absolute;\n z-index: 6;\n}\n\n.ace_marker-layer .ace_active-line {\n position: absolute;\n z-index: 2;\n}\n\n.ace_marker-layer .ace_selected-word {\n position: absolute;\n z-index: 4;\n box-sizing: border-box;\n}\n\n.ace_line .ace_fold {\n box-sizing: border-box;\n\n display: inline-block;\n height: 11px;\n margin-top: -2px;\n vertical-align: middle;\n\n background-image:\n url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABEAAAAJCAYAAADU6McMAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAJpJREFUeNpi/P//PwOlgAXGYGRklAVSokD8GmjwY1wasKljQpYACtpCFeADcHVQfQyMQAwzwAZI3wJKvCLkfKBaMSClBlR7BOQikCFGQEErIH0VqkabiGCAqwUadAzZJRxQr/0gwiXIal8zQQPnNVTgJ1TdawL0T5gBIP1MUJNhBv2HKoQHHjqNrA4WO4zY0glyNKLT2KIfIMAAQsdgGiXvgnYAAAAASUVORK5CYII=\"),\n url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAA3CAYAAADNNiA5AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAACJJREFUeNpi+P//fxgTAwPDBxDxD078RSX+YeEyDFMCIMAAI3INmXiwf2YAAAAASUVORK5CYII=\");\n background-repeat: no-repeat, repeat-x;\n background-position: center center, top left;\n color: transparent;\n\n border: 1px solid black;\n border-radius: 2px;\n\n cursor: pointer;\n pointer-events: auto;\n}\n\n.ace_dark .ace_fold {\n}\n\n.ace_fold:hover{\n background-image:\n url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABEAAAAJCAYAAADU6McMAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAJpJREFUeNpi/P//PwOlgAXGYGRklAVSokD8GmjwY1wasKljQpYACtpCFeADcHVQfQyMQAwzwAZI3wJKvCLkfKBaMSClBlR7BOQikCFGQEErIH0VqkabiGCAqwUadAzZJRxQr/0gwiXIal8zQQPnNVTgJ1TdawL0T5gBIP1MUJNhBv2HKoQHHjqNrA4WO4zY0glyNKLT2KIfIMAAQsdgGiXvgnYAAAAASUVORK5CYII=\"),\n url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAA3CAYAAADNNiA5AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAACBJREFUeNpi+P//fz4TAwPDZxDxD5X4i5fLMEwJgAADAEPVDbjNw87ZAAAAAElFTkSuQmCC\");\n}\n\n.ace_tooltip {\n background-color: #FFF;\n background-image: linear-gradient(to bottom, transparent, rgba(0, 0, 0, 0.1));\n border: 1px solid gray;\n border-radius: 1px;\n box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);\n color: black;\n max-width: 100%;\n padding: 3px 4px;\n position: fixed;\n z-index: 999999;\n box-sizing: border-box;\n cursor: default;\n white-space: pre;\n word-wrap: break-word;\n line-height: normal;\n font-style: normal;\n font-weight: normal;\n letter-spacing: normal;\n pointer-events: none;\n}\n\n.ace_folding-enabled > .ace_gutter-cell {\n padding-right: 13px;\n}\n\n.ace_fold-widget {\n box-sizing: border-box;\n\n margin: 0 -12px 0 1px;\n display: none;\n width: 11px;\n vertical-align: top;\n\n background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAANElEQVR42mWKsQ0AMAzC8ixLlrzQjzmBiEjp0A6WwBCSPgKAXoLkqSot7nN3yMwR7pZ32NzpKkVoDBUxKAAAAABJRU5ErkJggg==\");\n background-repeat: no-repeat;\n background-position: center;\n\n border-radius: 3px;\n \n border: 1px solid transparent;\n cursor: pointer;\n}\n\n.ace_folding-enabled .ace_fold-widget {\n display: inline-block; \n}\n\n.ace_fold-widget.ace_end {\n background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAANElEQVR42m3HwQkAMAhD0YzsRchFKI7sAikeWkrxwScEB0nh5e7KTPWimZki4tYfVbX+MNl4pyZXejUO1QAAAABJRU5ErkJggg==\");\n}\n\n.ace_fold-widget.ace_closed {\n background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAMAAAAGCAYAAAAG5SQMAAAAOUlEQVR42jXKwQkAMAgDwKwqKD4EwQ26sSOkVWjgIIHAzPiCgaqiqnJHZnKICBERHN194O5b9vbLuAVRL+l0YWnZAAAAAElFTkSuQmCCXA==\");\n}\n\n.ace_fold-widget:hover {\n border: 1px solid rgba(0, 0, 0, 0.3);\n background-color: rgba(255, 255, 255, 0.2);\n box-shadow: 0 1px 1px rgba(255, 255, 255, 0.7);\n}\n\n.ace_fold-widget:active {\n border: 1px solid rgba(0, 0, 0, 0.4);\n background-color: rgba(0, 0, 0, 0.05);\n box-shadow: 0 1px 1px rgba(255, 255, 255, 0.8);\n}\n.ace_dark .ace_fold-widget {\n background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHklEQVQIW2P4//8/AzoGEQ7oGCaLLAhWiSwB146BAQCSTPYocqT0AAAAAElFTkSuQmCC\");\n}\n.ace_dark .ace_fold-widget.ace_end {\n background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAH0lEQVQIW2P4//8/AxQ7wNjIAjDMgC4AxjCVKBirIAAF0kz2rlhxpAAAAABJRU5ErkJggg==\");\n}\n.ace_dark .ace_fold-widget.ace_closed {\n background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAMAAAAFCAYAAACAcVaiAAAAHElEQVQIW2P4//+/AxAzgDADlOOAznHAKgPWAwARji8UIDTfQQAAAABJRU5ErkJggg==\");\n}\n.ace_dark .ace_fold-widget:hover {\n box-shadow: 0 1px 1px rgba(255, 255, 255, 0.2);\n background-color: rgba(255, 255, 255, 0.1);\n}\n.ace_dark .ace_fold-widget:active {\n box-shadow: 0 1px 1px rgba(255, 255, 255, 0.2);\n}\n\n.ace_inline_button {\n border: 1px solid lightgray;\n display: inline-block;\n margin: -1px 8px;\n padding: 0 5px;\n pointer-events: auto;\n cursor: pointer;\n}\n.ace_inline_button:hover {\n border-color: gray;\n background: rgba(200,200,200,0.2);\n display: inline-block;\n pointer-events: auto;\n}\n\n.ace_fold-widget.ace_invalid {\n background-color: #FFB4B4;\n border-color: #DE5555;\n}\n\n.ace_fade-fold-widgets .ace_fold-widget {\n transition: opacity 0.4s ease 0.05s;\n opacity: 0;\n}\n\n.ace_fade-fold-widgets:hover .ace_fold-widget {\n transition: opacity 0.05s ease 0.05s;\n opacity:1;\n}\n\n.ace_underline {\n text-decoration: underline;\n}\n\n.ace_bold {\n font-weight: bold;\n}\n\n.ace_nobold .ace_bold {\n font-weight: normal;\n}\n\n.ace_italic {\n font-style: italic;\n}\n\n\n.ace_error-marker {\n background-color: rgba(255, 0, 0,0.2);\n position: absolute;\n z-index: 9;\n}\n\n.ace_highlight-marker {\n background-color: rgba(255, 255, 0,0.2);\n position: absolute;\n z-index: 8;\n}\n.ace_lineWidgetContainer {\n z-index: 5;\n position: absolute;\n}\n.ace_br1 {border-top-left-radius : 3px;}\n.ace_br2 {border-top-right-radius : 3px;}\n.ace_br3 {border-top-left-radius : 3px; border-top-right-radius: 3px;}\n.ace_br4 {border-bottom-right-radius: 3px;}\n.ace_br5 {border-top-left-radius : 3px; border-bottom-right-radius: 3px;}\n.ace_br6 {border-top-right-radius : 3px; border-bottom-right-radius: 3px;}\n.ace_br7 {border-top-left-radius : 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px;}\n.ace_br8 {border-bottom-left-radius : 3px;}\n.ace_br9 {border-top-left-radius : 3px; border-bottom-left-radius: 3px;}\n.ace_br10{border-top-right-radius : 3px; border-bottom-left-radius: 3px;}\n.ace_br11{border-top-left-radius : 3px; border-top-right-radius: 3px; border-bottom-left-radius: 3px;}\n.ace_br12{border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;}\n.ace_br13{border-top-left-radius : 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;}\n.ace_br14{border-top-right-radius : 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;}\n.ace_br15{border-top-left-radius : 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;}\n\n.ace_text-input-ios {\n position: absolute !important;\n top: -100000px !important;\n left: -100000px !important;\n}\n"); +define("ace/requirejs/text!ace/css/editor.css",[],".ace_editor {\n position: relative;\n overflow: hidden;\n font: 12px/normal 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'source-code-pro', monospace;\n direction: ltr;\n text-align: left;\n -webkit-tap-highlight-color: rgba(0, 0, 0, 0);\n}\n\n.ace_scroller {\n position: absolute;\n overflow: hidden;\n top: 0;\n bottom: 0;\n background-color: inherit;\n -ms-user-select: none;\n -moz-user-select: none;\n -webkit-user-select: none;\n user-select: none;\n cursor: text;\n}\n\n.ace_content {\n position: absolute;\n box-sizing: border-box;\n min-width: 100%;\n contain: style size layout;\n}\n\n.ace_dragging .ace_scroller:before{\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n content: '';\n background: rgba(250, 250, 250, 0.01);\n z-index: 1000;\n}\n.ace_dragging.ace_dark .ace_scroller:before{\n background: rgba(0, 0, 0, 0.01);\n}\n\n.ace_gutter {\n position: absolute;\n overflow : hidden;\n width: auto;\n top: 0;\n bottom: 0;\n left: 0;\n cursor: default;\n z-index: 4;\n -ms-user-select: none;\n -moz-user-select: none;\n -webkit-user-select: none;\n user-select: none;\n contain: style size layout;\n}\n\n.ace_gutter-active-line {\n position: absolute;\n left: 0;\n right: 0;\n}\n\n.ace_scroller.ace_scroll-left {\n box-shadow: 17px 0 16px -16px rgba(0, 0, 0, 0.4) inset;\n}\n\n.ace_gutter-cell {\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n padding-left: 19px;\n padding-right: 6px;\n background-repeat: no-repeat;\n}\n\n.ace_gutter-cell.ace_error {\n background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAABOFBMVEX/////////QRswFAb/Ui4wFAYwFAYwFAaWGAfDRymzOSH/PxswFAb/SiUwFAYwFAbUPRvjQiDllog5HhHdRybsTi3/Tyv9Tir+Syj/UC3////XurebMBIwFAb/RSHbPx/gUzfdwL3kzMivKBAwFAbbvbnhPx66NhowFAYwFAaZJg8wFAaxKBDZurf/RB6mMxb/SCMwFAYwFAbxQB3+RB4wFAb/Qhy4Oh+4QifbNRcwFAYwFAYwFAb/QRzdNhgwFAYwFAbav7v/Uy7oaE68MBK5LxLewr/r2NXewLswFAaxJw4wFAbkPRy2PyYwFAaxKhLm1tMwFAazPiQwFAaUGAb/QBrfOx3bvrv/VC/maE4wFAbRPBq6MRO8Qynew8Dp2tjfwb0wFAbx6eju5+by6uns4uH9/f36+vr/GkHjAAAAYnRSTlMAGt+64rnWu/bo8eAA4InH3+DwoN7j4eLi4xP99Nfg4+b+/u9B/eDs1MD1mO7+4PHg2MXa347g7vDizMLN4eG+Pv7i5evs/v79yu7S3/DV7/498Yv24eH+4ufQ3Ozu/v7+y13sRqwAAADLSURBVHjaZc/XDsFgGIBhtDrshlitmk2IrbHFqL2pvXf/+78DPokj7+Fz9qpU/9UXJIlhmPaTaQ6QPaz0mm+5gwkgovcV6GZzd5JtCQwgsxoHOvJO15kleRLAnMgHFIESUEPmawB9ngmelTtipwwfASilxOLyiV5UVUyVAfbG0cCPHig+GBkzAENHS0AstVF6bacZIOzgLmxsHbt2OecNgJC83JERmePUYq8ARGkJx6XtFsdddBQgZE2nPR6CICZhawjA4Fb/chv+399kfR+MMMDGOQAAAABJRU5ErkJggg==\");\n background-repeat: no-repeat;\n background-position: 2px center;\n}\n\n.ace_gutter-cell.ace_warning {\n background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAAmVBMVEX///8AAAD///8AAAAAAABPSzb/5sAAAAB/blH/73z/ulkAAAAAAAD85pkAAAAAAAACAgP/vGz/rkDerGbGrV7/pkQICAf////e0IsAAAD/oED/qTvhrnUAAAD/yHD/njcAAADuv2r/nz//oTj/p064oGf/zHAAAAA9Nir/tFIAAAD/tlTiuWf/tkIAAACynXEAAAAAAAAtIRW7zBpBAAAAM3RSTlMAABR1m7RXO8Ln31Z36zT+neXe5OzooRDfn+TZ4p3h2hTf4t3k3ucyrN1K5+Xaks52Sfs9CXgrAAAAjklEQVR42o3PbQ+CIBQFYEwboPhSYgoYunIqqLn6/z8uYdH8Vmdnu9vz4WwXgN/xTPRD2+sgOcZjsge/whXZgUaYYvT8QnuJaUrjrHUQreGczuEafQCO/SJTufTbroWsPgsllVhq3wJEk2jUSzX3CUEDJC84707djRc5MTAQxoLgupWRwW6UB5fS++NV8AbOZgnsC7BpEAAAAABJRU5ErkJggg==\");\n background-position: 2px center;\n}\n\n.ace_gutter-cell.ace_info {\n background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAAAAAA6mKC9AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAAJ0Uk5TAAB2k804AAAAPklEQVQY02NgIB68QuO3tiLznjAwpKTgNyDbMegwisCHZUETUZV0ZqOquBpXj2rtnpSJT1AEnnRmL2OgGgAAIKkRQap2htgAAAAASUVORK5CYII=\");\n background-position: 2px center;\n}\n.ace_dark .ace_gutter-cell.ace_info {\n background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQBAMAAADt3eJSAAAAJFBMVEUAAAChoaGAgIAqKiq+vr6tra1ZWVmUlJSbm5s8PDxubm56enrdgzg3AAAAAXRSTlMAQObYZgAAAClJREFUeNpjYMAPdsMYHegyJZFQBlsUlMFVCWUYKkAZMxZAGdxlDMQBAG+TBP4B6RyJAAAAAElFTkSuQmCC\");\n}\n\n.ace_scrollbar {\n contain: strict;\n position: absolute;\n right: 0;\n bottom: 0;\n z-index: 6;\n}\n\n.ace_scrollbar-inner {\n position: absolute;\n cursor: text;\n left: 0;\n top: 0;\n}\n\n.ace_scrollbar-v{\n overflow-x: hidden;\n overflow-y: scroll;\n top: 0;\n}\n\n.ace_scrollbar-h {\n overflow-x: scroll;\n overflow-y: hidden;\n left: 0;\n}\n\n.ace_print-margin {\n position: absolute;\n height: 100%;\n}\n\n.ace_text-input {\n position: absolute;\n z-index: 0;\n width: 0.5em;\n height: 1em;\n opacity: 0;\n background: transparent;\n -moz-appearance: none;\n appearance: none;\n border: none;\n resize: none;\n outline: none;\n overflow: hidden;\n font: inherit;\n padding: 0 1px;\n margin: 0 -1px;\n text-indent: -1em;\n -ms-user-select: text;\n -moz-user-select: text;\n -webkit-user-select: text;\n user-select: text;\n white-space: pre!important;\n}\n.ace_text-input.ace_composition {\n background: inherit;\n color: inherit;\n z-index: 1000;\n opacity: 1;\n text-indent: 0;\n}\n[ace_nocontext=true] {\n transform: none!important;\n filter: none!important;\n perspective: none!important;\n clip-path: none!important;\n mask : none!important;\n contain: none!important;\n perspective: none!important;\n mix-blend-mode: initial!important;\n z-index: auto;\n}\n\n.ace_layer {\n z-index: 1;\n position: absolute;\n overflow: hidden;\n word-wrap: normal;\n white-space: pre;\n height: 100%;\n width: 100%;\n box-sizing: border-box;\n pointer-events: none;\n}\n\n.ace_gutter-layer {\n position: relative;\n width: auto;\n text-align: right;\n pointer-events: auto;\n height: 1000000px;\n contain: style size layout;\n}\n\n.ace_text-layer {\n font: inherit !important;\n position: absolute;\n height: 1000000px;\n width: 1000000px;\n contain: style size layout;\n}\n\n.ace_text-layer > .ace_line, .ace_text-layer > .ace_line_group {\n contain: style size layout;\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n}\n\n.ace_hidpi .ace_text-layer,\n.ace_hidpi .ace_gutter-layer,\n.ace_hidpi .ace_content,\n.ace_hidpi .ace_gutter {\n contain: strict;\n will-change: transform;\n}\n.ace_hidpi .ace_text-layer > .ace_line, \n.ace_hidpi .ace_text-layer > .ace_line_group {\n contain: strict;\n}\n\n.ace_cjk {\n display: inline-block;\n text-align: center;\n}\n\n.ace_cursor-layer {\n z-index: 4;\n}\n\n.ace_cursor {\n z-index: 4;\n position: absolute;\n box-sizing: border-box;\n border-left: 2px solid;\n transform: translatez(0);\n}\n\n.ace_multiselect .ace_cursor {\n border-left-width: 1px;\n}\n\n.ace_slim-cursors .ace_cursor {\n border-left-width: 1px;\n}\n\n.ace_overwrite-cursors .ace_cursor {\n border-left-width: 0;\n border-bottom: 1px solid;\n}\n\n.ace_hidden-cursors .ace_cursor {\n opacity: 0.2;\n}\n\n.ace_smooth-blinking .ace_cursor {\n transition: opacity 0.18s;\n}\n\n.ace_animate-blinking .ace_cursor {\n animation-duration: 1000ms;\n animation-timing-function: step-end;\n animation-name: blink-ace-animate;\n animation-iteration-count: infinite;\n}\n\n.ace_animate-blinking.ace_smooth-blinking .ace_cursor {\n animation-duration: 1000ms;\n animation-timing-function: ease-in-out;\n animation-name: blink-ace-animate-smooth;\n}\n \n@keyframes blink-ace-animate {\n from, to { opacity: 1; }\n 60% { opacity: 0; }\n}\n\n@keyframes blink-ace-animate-smooth {\n from, to { opacity: 1; }\n 45% { opacity: 1; }\n 60% { opacity: 0; }\n 85% { opacity: 0; }\n}\n\n.ace_marker-layer .ace_step, .ace_marker-layer .ace_stack {\n position: absolute;\n z-index: 3;\n}\n\n.ace_marker-layer .ace_selection {\n position: absolute;\n z-index: 5;\n}\n\n.ace_marker-layer .ace_bracket {\n position: absolute;\n z-index: 6;\n}\n\n.ace_marker-layer .ace_active-line {\n position: absolute;\n z-index: 2;\n}\n\n.ace_marker-layer .ace_selected-word {\n position: absolute;\n z-index: 4;\n box-sizing: border-box;\n}\n\n.ace_line .ace_fold {\n box-sizing: border-box;\n\n display: inline-block;\n height: 11px;\n margin-top: -2px;\n vertical-align: middle;\n\n background-image:\n url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABEAAAAJCAYAAADU6McMAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAJpJREFUeNpi/P//PwOlgAXGYGRklAVSokD8GmjwY1wasKljQpYACtpCFeADcHVQfQyMQAwzwAZI3wJKvCLkfKBaMSClBlR7BOQikCFGQEErIH0VqkabiGCAqwUadAzZJRxQr/0gwiXIal8zQQPnNVTgJ1TdawL0T5gBIP1MUJNhBv2HKoQHHjqNrA4WO4zY0glyNKLT2KIfIMAAQsdgGiXvgnYAAAAASUVORK5CYII=\"),\n url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAA3CAYAAADNNiA5AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAACJJREFUeNpi+P//fxgTAwPDBxDxD078RSX+YeEyDFMCIMAAI3INmXiwf2YAAAAASUVORK5CYII=\");\n background-repeat: no-repeat, repeat-x;\n background-position: center center, top left;\n color: transparent;\n\n border: 1px solid black;\n border-radius: 2px;\n\n cursor: pointer;\n pointer-events: auto;\n}\n\n.ace_dark .ace_fold {\n}\n\n.ace_fold:hover{\n background-image:\n url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABEAAAAJCAYAAADU6McMAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAJpJREFUeNpi/P//PwOlgAXGYGRklAVSokD8GmjwY1wasKljQpYACtpCFeADcHVQfQyMQAwzwAZI3wJKvCLkfKBaMSClBlR7BOQikCFGQEErIH0VqkabiGCAqwUadAzZJRxQr/0gwiXIal8zQQPnNVTgJ1TdawL0T5gBIP1MUJNhBv2HKoQHHjqNrA4WO4zY0glyNKLT2KIfIMAAQsdgGiXvgnYAAAAASUVORK5CYII=\"),\n url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAA3CAYAAADNNiA5AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAACBJREFUeNpi+P//fz4TAwPDZxDxD5X4i5fLMEwJgAADAEPVDbjNw87ZAAAAAElFTkSuQmCC\");\n}\n\n.ace_tooltip {\n background-color: #FFF;\n background-image: linear-gradient(to bottom, transparent, rgba(0, 0, 0, 0.1));\n border: 1px solid gray;\n border-radius: 1px;\n box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);\n color: black;\n max-width: 100%;\n padding: 3px 4px;\n position: fixed;\n z-index: 999999;\n box-sizing: border-box;\n cursor: default;\n white-space: pre;\n word-wrap: break-word;\n line-height: normal;\n font-style: normal;\n font-weight: normal;\n letter-spacing: normal;\n pointer-events: none;\n}\n\n.ace_folding-enabled > .ace_gutter-cell {\n padding-right: 13px;\n}\n\n.ace_fold-widget {\n box-sizing: border-box;\n\n margin: 0 -12px 0 1px;\n display: none;\n width: 11px;\n vertical-align: top;\n\n background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAANElEQVR42mWKsQ0AMAzC8ixLlrzQjzmBiEjp0A6WwBCSPgKAXoLkqSot7nN3yMwR7pZ32NzpKkVoDBUxKAAAAABJRU5ErkJggg==\");\n background-repeat: no-repeat;\n background-position: center;\n\n border-radius: 3px;\n \n border: 1px solid transparent;\n cursor: pointer;\n}\n\n.ace_folding-enabled .ace_fold-widget {\n display: inline-block; \n}\n\n.ace_fold-widget.ace_end {\n background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAANElEQVR42m3HwQkAMAhD0YzsRchFKI7sAikeWkrxwScEB0nh5e7KTPWimZki4tYfVbX+MNl4pyZXejUO1QAAAABJRU5ErkJggg==\");\n}\n\n.ace_fold-widget.ace_closed {\n background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAMAAAAGCAYAAAAG5SQMAAAAOUlEQVR42jXKwQkAMAgDwKwqKD4EwQ26sSOkVWjgIIHAzPiCgaqiqnJHZnKICBERHN194O5b9vbLuAVRL+l0YWnZAAAAAElFTkSuQmCCXA==\");\n}\n\n.ace_fold-widget:hover {\n border: 1px solid rgba(0, 0, 0, 0.3);\n background-color: rgba(255, 255, 255, 0.2);\n box-shadow: 0 1px 1px rgba(255, 255, 255, 0.7);\n}\n\n.ace_fold-widget:active {\n border: 1px solid rgba(0, 0, 0, 0.4);\n background-color: rgba(0, 0, 0, 0.05);\n box-shadow: 0 1px 1px rgba(255, 255, 255, 0.8);\n}\n.ace_dark .ace_fold-widget {\n background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHklEQVQIW2P4//8/AzoGEQ7oGCaLLAhWiSwB146BAQCSTPYocqT0AAAAAElFTkSuQmCC\");\n}\n.ace_dark .ace_fold-widget.ace_end {\n background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAH0lEQVQIW2P4//8/AxQ7wNjIAjDMgC4AxjCVKBirIAAF0kz2rlhxpAAAAABJRU5ErkJggg==\");\n}\n.ace_dark .ace_fold-widget.ace_closed {\n background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAMAAAAFCAYAAACAcVaiAAAAHElEQVQIW2P4//+/AxAzgDADlOOAznHAKgPWAwARji8UIDTfQQAAAABJRU5ErkJggg==\");\n}\n.ace_dark .ace_fold-widget:hover {\n box-shadow: 0 1px 1px rgba(255, 255, 255, 0.2);\n background-color: rgba(255, 255, 255, 0.1);\n}\n.ace_dark .ace_fold-widget:active {\n box-shadow: 0 1px 1px rgba(255, 255, 255, 0.2);\n}\n\n.ace_inline_button {\n border: 1px solid lightgray;\n display: inline-block;\n margin: -1px 8px;\n padding: 0 5px;\n pointer-events: auto;\n cursor: pointer;\n}\n.ace_inline_button:hover {\n border-color: gray;\n background: rgba(200,200,200,0.2);\n display: inline-block;\n pointer-events: auto;\n}\n\n.ace_fold-widget.ace_invalid {\n background-color: #FFB4B4;\n border-color: #DE5555;\n}\n\n.ace_fade-fold-widgets .ace_fold-widget {\n transition: opacity 0.4s ease 0.05s;\n opacity: 0;\n}\n\n.ace_fade-fold-widgets:hover .ace_fold-widget {\n transition: opacity 0.05s ease 0.05s;\n opacity:1;\n}\n\n.ace_underline {\n text-decoration: underline;\n}\n\n.ace_bold {\n font-weight: bold;\n}\n\n.ace_nobold .ace_bold {\n font-weight: normal;\n}\n\n.ace_italic {\n font-style: italic;\n}\n\n\n.ace_error-marker {\n background-color: rgba(255, 0, 0,0.2);\n position: absolute;\n z-index: 9;\n}\n\n.ace_highlight-marker {\n background-color: rgba(255, 255, 0,0.2);\n position: absolute;\n z-index: 8;\n}\n.ace_br1 {border-top-left-radius : 3px;}\n.ace_br2 {border-top-right-radius : 3px;}\n.ace_br3 {border-top-left-radius : 3px; border-top-right-radius: 3px;}\n.ace_br4 {border-bottom-right-radius: 3px;}\n.ace_br5 {border-top-left-radius : 3px; border-bottom-right-radius: 3px;}\n.ace_br6 {border-top-right-radius : 3px; border-bottom-right-radius: 3px;}\n.ace_br7 {border-top-left-radius : 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px;}\n.ace_br8 {border-bottom-left-radius : 3px;}\n.ace_br9 {border-top-left-radius : 3px; border-bottom-left-radius: 3px;}\n.ace_br10{border-top-right-radius : 3px; border-bottom-left-radius: 3px;}\n.ace_br11{border-top-left-radius : 3px; border-top-right-radius: 3px; border-bottom-left-radius: 3px;}\n.ace_br12{border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;}\n.ace_br13{border-top-left-radius : 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;}\n.ace_br14{border-top-right-radius : 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;}\n.ace_br15{border-top-left-radius : 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;}\n\n.ace_text-input-ios {\n position: absolute !important;\n top: -100000px !important;\n left: -100000px !important;\n}\n"); define("ace/virtual_renderer",[], function(require, exports, module) { "use strict"; @@ -2082,7 +2563,6 @@ define("ace/virtual_renderer",[], function(require, exports, module) { var oop = require("./lib/oop"); var dom = require("./lib/dom"); var config = require("./config"); -var useragent = require("./lib/useragent"); var GutterLayer = require("./layer/gutter").Gutter; var MarkerLayer = require("./layer/marker").Marker; var TextLayer = require("./layer/text").Text; @@ -2102,6 +2582,7 @@ var VirtualRenderer = function(container, theme) { this.container = container || dom.createElement("div"); dom.addCssClass(this.container, "ace_editor"); + if (dom.HI_DPI) dom.addCssClass(this.container, "ace_hidpi"); this.setTheme(theme); @@ -2112,6 +2593,7 @@ var VirtualRenderer = function(container, theme) { this.scroller = dom.createElement("div"); this.scroller.className = "ace_scroller"; + this.container.appendChild(this.scroller); this.content = dom.createElement("div"); @@ -2191,6 +2673,15 @@ var VirtualRenderer = function(container, theme) { v: 0, h: 0 }; + + this.margin = { + left: 0, + right: 0, + top: 0, + bottom: 0, + v: 0, + h: 0 + }; this.$loop = new RenderLoop( this.$renderChanges.bind(this), @@ -2248,6 +2739,7 @@ var VirtualRenderer = function(container, theme) { return; this.$loop.schedule(this.CHANGE_FULL); + this.session.$setFontMetrics(this.$fontMetrics); this.scrollBarH.scrollLeft = this.scrollBarV.scrollTop = null; this.onChangeNewLineMode = this.onChangeNewLineMode.bind(this); @@ -2374,15 +2866,17 @@ var VirtualRenderer = function(container, theme) { this.gutterWidth = gutterWidth; - this.scrollBarH.element.style.left = - this.scroller.style.left = gutterWidth + "px"; - size.scrollerWidth = Math.max(0, width - gutterWidth - this.scrollBarV.getWidth()); + dom.setStyle(this.scrollBarH.element.style, "left", gutterWidth + "px"); + dom.setStyle(this.scroller.style, "left", gutterWidth + this.margin.left + "px"); + size.scrollerWidth = Math.max(0, width - gutterWidth - this.scrollBarV.getWidth() - this.margin.h); - this.scrollBarH.element.style.right = - this.scroller.style.right = this.scrollBarV.getWidth() + "px"; - this.scroller.style.bottom = this.scrollBarH.getHeight() + "px"; - if (this.session && this.session.getUseWrapMode() && this.adjustWrapLimit() || force) + var right = this.scrollBarV.getWidth() + "px"; + dom.setStyle(this.scrollBarH.element.style, "right", right); + dom.setStyle(this.scroller.style, "right", right); + dom.setStyle(this.scroller.style, "bottom", this.scrollBarH.getHeight()); + if (this.session && this.session.getUseWrapMode() && this.adjustWrapLimit() || force) { changes |= this.CHANGE_FULL; + } } size.$dirty = !width || !height; @@ -2393,8 +2887,8 @@ var VirtualRenderer = function(container, theme) { return changes; }; - this.onGutterResize = function() { - var gutterWidth = this.$showGutter ? this.$gutter.offsetWidth : 0; + this.onGutterResize = function(width) { + var gutterWidth = this.$showGutter ? width : 0; if (gutterWidth != this.gutterWidth) this.$changes |= this.$updateCachedSize(true, gutterWidth, this.$size.width, this.$size.height); @@ -2404,7 +2898,6 @@ var VirtualRenderer = function(container, theme) { this.$loop.schedule(this.CHANGE_FULL); } else { this.$computeLayerConfig(); - this.$loop.schedule(this.CHANGE_MARKER); } }; this.adjustWrapLimit = function() { @@ -2467,19 +2960,6 @@ var VirtualRenderer = function(container, theme) { return this.getOption("highlightGutterLine"); }; - this.$updateGutterLineHighlight = function() { - var pos = this.$cursorLayer.$pixelPos; - var height = this.layerConfig.lineHeight; - if (this.session.getUseWrapMode()) { - var cursor = this.session.selection.getCursor(); - cursor.column = 0; - pos = this.$cursorLayer.getPixelPosition(cursor, true); - height *= this.session.getRowLength(cursor.row); - } - this.$gutterLineHighlight.style.top = pos.top - this.layerConfig.offset + "px"; - this.$gutterLineHighlight.style.height = height + "px"; - }; - this.$updatePrintMargin = function() { if (!this.$showPrintMargin && !this.$printMarginEl) return; @@ -2512,9 +2992,11 @@ var VirtualRenderer = function(container, theme) { this.$moveTextAreaToCursor = function() { var style = this.textarea.style; if (!this.$keepTextAreaAtCursor) { - style.left = -100 + "px"; + dom.translate(this.textarea, -100, 0); return; } + if (!this.$cursorLayer.$pixelPos) + return; var config = this.layerConfig; var posTop = this.$cursorLayer.$pixelPos.top; var posLeft = this.$cursorLayer.$pixelPos.left; @@ -2522,7 +3004,7 @@ var VirtualRenderer = function(container, theme) { var h = this.lineHeight; if (posTop < 0 || posTop > config.height - h) { - style.top = style.left = "0"; + dom.translate(this.textarea, 0, 0); return; } @@ -2536,11 +3018,10 @@ var VirtualRenderer = function(container, theme) { if (posLeft > this.$size.scrollerWidth - w) posLeft = this.$size.scrollerWidth - w; - posLeft += this.gutterWidth; - style.height = h + "px"; - style.width = w + "px"; - style.left = Math.min(posLeft, this.$size.scrollerWidth - w) + "px"; - style.top = Math.min(posTop, this.$size.height - h) + "px"; + posLeft += this.gutterWidth + this.margin.left; + dom.setStyle(style, "height", h + "px"); + dom.setStyle(style, "width", w + "px"); + dom.translate(this.textarea, Math.min(posLeft, this.$size.scrollerWidth - w), Math.min(posTop, this.$size.height - h)); }; this.getFirstVisibleRow = function() { return this.layerConfig.firstRow; @@ -2583,6 +3064,18 @@ var VirtualRenderer = function(container, theme) { this.session.setScrollTop(-sm.top); this.updateFull(); }; + + this.setMargin = function(top, bottom, left, right) { + var sm = this.margin; + sm.top = top|0; + sm.bottom = bottom|0; + sm.right = right|0; + sm.left = left|0; + sm.v = sm.top + sm.bottom; + sm.h = sm.left + sm.right; + this.$updateCachedSize(true, this.gutterWidth, this.$size.width, this.$size.height); + this.updateFull(); + }; this.getHScrollBarAlwaysVisible = function() { return this.$hScrollBarAlwaysVisible; }; @@ -2665,13 +3158,18 @@ var VirtualRenderer = function(container, theme) { this.$updateScrollBarV(); if (changes & this.CHANGE_H_SCROLL) this.$updateScrollBarH(); - this.$gutterLayer.element.style.marginTop = (-config.offset) + "px"; - this.content.style.marginTop = (-config.offset) + "px"; - this.content.style.width = config.width + 2 * this.$padding + "px"; - this.content.style.height = config.minHeight + "px"; + + dom.translate(this.$gutter, this.margin.left, -config.offset); + dom.translate(this.content, -this.scrollLeft, -config.offset); + + var width = config.width + 2 * this.$padding + "px"; + var height = config.minHeight + "px"; + + dom.setStyle(this.content.style, "width", width); + dom.setStyle(this.content.style, "height", height); } if (changes & this.CHANGE_H_SCROLL) { - this.content.style.marginLeft = -this.scrollLeft + "px"; + dom.translate(this.content, -this.scrollLeft, -config.offset); this.scroller.className = this.scrollLeft <= 0 ? "ace_scroller" : "ace_scroller ace_scroll-left"; } if (changes & this.CHANGE_FULL) { @@ -2682,7 +3180,6 @@ var VirtualRenderer = function(container, theme) { this.$markerFront.update(config); this.$cursorLayer.update(config); this.$moveTextAreaToCursor(); - this.$highlightGutterLine && this.$updateGutterLineHighlight(); this._signal("afterRender"); return; } @@ -2692,12 +3189,15 @@ var VirtualRenderer = function(container, theme) { else this.$textLayer.scrollLines(config); - if (this.$showGutter) - this.$gutterLayer.update(config); + if (this.$showGutter) { + if (changes & this.CHANGE_GUTTER || changes & this.CHANGE_LINES) + this.$gutterLayer.update(config); + else + this.$gutterLayer.scrollLines(config); + } this.$markerBack.update(config); this.$markerFront.update(config); this.$cursorLayer.update(config); - this.$highlightGutterLine && this.$updateGutterLineHighlight(); this.$moveTextAreaToCursor(); this._signal("afterRender"); return; @@ -2716,11 +3216,14 @@ var VirtualRenderer = function(container, theme) { if (this.$showGutter) this.$gutterLayer.update(config); } + else if (changes & this.CHANGE_CURSOR) { + if (this.$highlightGutterLine) + this.$gutterLayer.updateLineHighlight(config); + } if (changes & this.CHANGE_CURSOR) { this.$cursorLayer.update(config); this.$moveTextAreaToCursor(); - this.$highlightGutterLine && this.$updateGutterLineHighlight(); } if (changes & (this.CHANGE_MARKER | this.CHANGE_MARKER_FRONT)) { @@ -2745,7 +3248,9 @@ var VirtualRenderer = function(container, theme) { desiredHeight += this.scrollBarH.getHeight(); if (this.$maxPixelHeight && desiredHeight > this.$maxPixelHeight) desiredHeight = this.$maxPixelHeight; - var vScroll = height > maxHeight; + + var hideScrollbars = desiredHeight <= 2 * this.lineHeight; + var vScroll = !hideScrollbars && height > maxHeight; if (desiredHeight != this.desiredHeight || this.$size.height != this.desiredHeight || vScroll != this.$vScroll) { @@ -3090,7 +3595,7 @@ var VirtualRenderer = function(container, theme) { if (this.$hasCssTransforms) { canvasPos = {top:0, left: 0}; var p = this.$fontMetrics.transformCoordinates([x, y]); - x = p[1] - this.gutterWidth; + x = p[1] - this.gutterWidth - this.margin.left; y = p[0]; } else { canvasPos = this.scroller.getBoundingClientRect(); @@ -3109,7 +3614,7 @@ var VirtualRenderer = function(container, theme) { if (this.$hasCssTransforms) { canvasPos = {top:0, left: 0}; var p = this.$fontMetrics.transformCoordinates([x, y]); - x = p[1] - this.gutterWidth; + x = p[1] - this.gutterWidth - this.margin.left; y = p[0]; } else { canvasPos = this.scroller.getBoundingClientRect(); @@ -3119,7 +3624,7 @@ var VirtualRenderer = function(container, theme) { var offset = offsetX / this.characterWidth; var col = this.$blockCursor ? Math.floor(offset) : Math.round(offset); - var row = (y + this.scrollTop - canvasPos.top) / this.lineHeight; + var row = Math.floor((y + this.scrollTop - canvasPos.top) / this.lineHeight); return this.session.screenToDocumentPosition(row, Math.max(col, 0), offsetX); }; @@ -3225,11 +3730,10 @@ var VirtualRenderer = function(container, theme) { }; this.setCursorStyle = function(style) { - if (this.scroller.style.cursor != style) - this.scroller.style.cursor = style; + dom.setStyle(this.scroller.style, "cursor", style); }; this.setMouseCursor = function(cursorStyle) { - this.scroller.style.cursor = cursorStyle; + dom.setStyle(this.scroller.style, "cursor", cursorStyle); }; this.attachToShadowRoot = function() { @@ -3286,12 +3790,8 @@ config.defineOptions(VirtualRenderer.prototype, "renderer", { initialValue: false }, showFoldWidgets: { - set: function(show) {this.$gutterLayer.setShowFoldWidgets(show);}, - initialValue: true - }, - showLineNumbers: { set: function(show) { - this.$gutterLayer.setShowLineNumbers(show); + this.$gutterLayer.setShowFoldWidgets(show); this.$loop.schedule(this.CHANGE_GUTTER); }, initialValue: true @@ -3305,19 +3805,10 @@ config.defineOptions(VirtualRenderer.prototype, "renderer", { }, highlightGutterLine: { set: function(shouldHighlight) { - if (!this.$gutterLineHighlight) { - this.$gutterLineHighlight = dom.createElement("div"); - this.$gutterLineHighlight.className = "ace_gutter-active-line"; - this.$gutter.appendChild(this.$gutterLineHighlight); - return; - } - - this.$gutterLineHighlight.style.display = shouldHighlight ? "" : "none"; - if (this.$cursorLayer.$pixelPos) - this.$updateGutterLineHighlight(); + this.$gutterLayer.setHighlightGutterLine(shouldHighlight); + this.$loop.schedule(this.CHANGE_GUTTER); }, - initialValue: false, - value: true + initialValue: true }, hScrollBarAlwaysVisible: { set: function(val) { @@ -3333,7 +3824,7 @@ config.defineOptions(VirtualRenderer.prototype, "renderer", { }, initialValue: false }, - fontSize: { + fontSize: { set: function(size) { if (typeof size == "number") size = size + "px"; @@ -4488,7 +4979,7 @@ exports.Range = Range; exports.EditSession = EditSession; exports.UndoManager = UndoManager; exports.VirtualRenderer = Renderer; -exports.version = "1.3.1"; +exports.version = "1.3.3"; }); define("ace/ext/textarea",[], function(require, exports, module) { @@ -4567,6 +5058,7 @@ function setupContainer(element, getValue) { } exports.transformTextarea = function(element, options) { + var isFocused = element.autofocus || document.activeElement == element; var session; var container = setupContainer(element, function() { return session.getValue(); @@ -4626,7 +5118,8 @@ exports.transformTextarea = function(element, options) { session = editor.getSession(); session.setValue(element.value || element.innerHTML); - editor.focus(); + if (isFocused) + editor.focus(); container.appendChild(settingOpener); setupApi(editor, editorDiv, settingDiv, ace, options); setupSettingPanel(settingDiv, settingOpener, editor); diff --git a/build/standalone/modules/ace/ext/themelist.js b/build/standalone/modules/ace/ext/themelist.js index 7a24d106..3e23389a 100644 --- a/build/standalone/modules/ace/ext/themelist.js +++ b/build/standalone/modules/ace/ext/themelist.js @@ -1,6 +1,5 @@ define("ace/ext/themelist",[], function(require, exports, module) { "use strict"; -require("ace/lib/fixoldbrowsers"); var themeData = [ ["Chrome" ], diff --git a/build/standalone/modules/ace/mode/drools.js b/build/standalone/modules/ace/mode/drools.js index 96117581..951c69ca 100644 --- a/build/standalone/modules/ace/mode/drools.js +++ b/build/standalone/modules/ace/mode/drools.js @@ -132,6 +132,36 @@ var JavaHighlightRules = function() { }, { token : "constant.language.boolean", regex : "(?:true|false)\\b" + }, { + regex: "(open(?:\\s+))?module(?=\\s*\\w)", + token: "keyword", + next: [{ + regex: "{", + token: "paren.lparen", + next: [{ + regex: "}", + token: "paren.rparen", + next: "start" + }, { + regex: "\\b(requires|transitive|exports|opens|to|uses|provides|with)\\b", + token: "keyword" + }] + }, { + token : "text", + regex : "\\s+" + }, { + token : "identifier", + regex : "\\w+" + }, { + token : "punctuation.operator", + regex : "." + }, { + token : "text", + regex : "\\s+" + }, { + regex: "", // exit if there is anything else + next: "start" + }] }, { token : keywordMapper, regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b" @@ -160,8 +190,10 @@ var JavaHighlightRules = function() { ] }; + this.embedRules(DocCommentHighlightRules, "doc-", [ DocCommentHighlightRules.getEndRule("start") ]); + this.normalizeRules(); }; oop.inherits(JavaHighlightRules, TextHighlightRules); diff --git a/build/standalone/modules/ace/mode/java.js b/build/standalone/modules/ace/mode/java.js index ce5d1d8c..e6ff0ff1 100644 --- a/build/standalone/modules/ace/mode/java.js +++ b/build/standalone/modules/ace/mode/java.js @@ -1170,6 +1170,36 @@ var JavaHighlightRules = function() { }, { token : "constant.language.boolean", regex : "(?:true|false)\\b" + }, { + regex: "(open(?:\\s+))?module(?=\\s*\\w)", + token: "keyword", + next: [{ + regex: "{", + token: "paren.lparen", + next: [{ + regex: "}", + token: "paren.rparen", + next: "start" + }, { + regex: "\\b(requires|transitive|exports|opens|to|uses|provides|with)\\b", + token: "keyword" + }] + }, { + token : "text", + regex : "\\s+" + }, { + token : "identifier", + regex : "\\w+" + }, { + token : "punctuation.operator", + regex : "." + }, { + token : "text", + regex : "\\s+" + }, { + regex: "", // exit if there is anything else + next: "start" + }] }, { token : keywordMapper, regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b" @@ -1198,8 +1228,10 @@ var JavaHighlightRules = function() { ] }; + this.embedRules(DocCommentHighlightRules, "doc-", [ DocCommentHighlightRules.getEndRule("start") ]); + this.normalizeRules(); }; oop.inherits(JavaHighlightRules, TextHighlightRules); diff --git a/build/standalone/modules/ace/mode/jsp.js b/build/standalone/modules/ace/mode/jsp.js index 9270c9c4..b323526e 100644 --- a/build/standalone/modules/ace/mode/jsp.js +++ b/build/standalone/modules/ace/mode/jsp.js @@ -1080,6 +1080,36 @@ var JavaHighlightRules = function() { }, { token : "constant.language.boolean", regex : "(?:true|false)\\b" + }, { + regex: "(open(?:\\s+))?module(?=\\s*\\w)", + token: "keyword", + next: [{ + regex: "{", + token: "paren.lparen", + next: [{ + regex: "}", + token: "paren.rparen", + next: "start" + }, { + regex: "\\b(requires|transitive|exports|opens|to|uses|provides|with)\\b", + token: "keyword" + }] + }, { + token : "text", + regex : "\\s+" + }, { + token : "identifier", + regex : "\\w+" + }, { + token : "punctuation.operator", + regex : "." + }, { + token : "text", + regex : "\\s+" + }, { + regex: "", // exit if there is anything else + next: "start" + }] }, { token : keywordMapper, regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b" @@ -1108,8 +1138,10 @@ var JavaHighlightRules = function() { ] }; + this.embedRules(DocCommentHighlightRules, "doc-", [ DocCommentHighlightRules.getEndRule("start") ]); + this.normalizeRules(); }; oop.inherits(JavaHighlightRules, TextHighlightRules); diff --git a/build/standalone/modules/ace/mode/php.js b/build/standalone/modules/ace/mode/php.js index 8604cf7f..64a8bea8 100644 --- a/build/standalone/modules/ace/mode/php.js +++ b/build/standalone/modules/ace/mode/php.js @@ -1958,6 +1958,9 @@ var PhpLangHighlightRules = function() { }, { token : "keyword.operator", regex : "::|!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|!=|!==|<=|>=|=>|<<=|>>=|>>>=|<>|<|>|\\.=|=|!|&&|\\|\\||\\?\\:|\\*=|/=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|instanceof|new|delete|typeof|void)" + }, { + token : "punctuation.operator", + regex : /[,;]/ }, { token : "paren.lparen", regex : "[[({]" diff --git a/build/standalone/modules/ace/mode/text.js b/build/standalone/modules/ace/mode/text.js index 848de47f..f4d9c687 100644 --- a/build/standalone/modules/ace/mode/text.js +++ b/build/standalone/modules/ace/mode/text.js @@ -214,9 +214,58 @@ exports.implement = function(proto, mixin) { }); +define("ace/lib/useragent",[], function(require, exports, module) { +"use strict"; +exports.OS = { + LINUX: "LINUX", + MAC: "MAC", + WINDOWS: "WINDOWS" +}; +exports.getOS = function() { + if (exports.isMac) { + return exports.OS.MAC; + } else if (exports.isLinux) { + return exports.OS.LINUX; + } else { + return exports.OS.WINDOWS; + } +}; +if (typeof navigator != "object") + return; + +var os = (navigator.platform.match(/mac|win|linux/i) || ["other"])[0].toLowerCase(); +var ua = navigator.userAgent; +exports.isWin = (os == "win"); +exports.isMac = (os == "mac"); +exports.isLinux = (os == "linux"); +exports.isIE = + (navigator.appName == "Microsoft Internet Explorer" || navigator.appName.indexOf("MSAppHost") >= 0) + ? parseFloat((ua.match(/(?:MSIE |Trident\/[0-9]+[\.0-9]+;.*rv:)([0-9]+[\.0-9]+)/)||[])[1]) + : parseFloat((ua.match(/(?:Trident\/[0-9]+[\.0-9]+;.*rv:)([0-9]+[\.0-9]+)/)||[])[1]); // for ie + +exports.isOldIE = exports.isIE && exports.isIE < 9; +exports.isGecko = exports.isMozilla = ua.match(/ Gecko\/\d+/); +exports.isOpera = window.opera && Object.prototype.toString.call(window.opera) == "[object Opera]"; +exports.isWebKit = parseFloat(ua.split("WebKit/")[1]) || undefined; + +exports.isChrome = parseFloat(ua.split(" Chrome/")[1]) || undefined; + +exports.isAIR = ua.indexOf("AdobeAIR") >= 0; + +exports.isIPad = ua.indexOf("iPad") >= 0; + +exports.isChromeOS = ua.indexOf(" CrOS ") >= 0; + +exports.isIOS = /iPad|iPhone|iPod/.test(ua) && !window.MSStream; + +if (exports.isIOS) exports.isMac = true; + +}); + define("ace/lib/dom",[], function(require, exports, module) { "use strict"; +var useragent = require("./useragent"); var XHTML_NS = "http://www.w3.org/1999/xhtml"; exports.buildDom = function buildDom(arr, parent, refs) { @@ -276,6 +325,20 @@ exports.createElement = function(tag, ns) { document.createElement(tag); }; +exports.removeChildren = function(element) { + element.innerHTML = ""; +}; + +exports.createTextNode = function(textContent, element) { + var doc = element ? element.ownerDocument : document; + return doc.createTextNode(textContent); +}; + +exports.createFragment = function(element) { + var doc = element ? element.ownerDocument : document; + return doc.createDocumentFragment(); +}; + exports.hasCssClass = function(el, name) { var classes = (el.className + "").split(/\s+/g); return classes.indexOf(name) !== -1; @@ -353,6 +416,9 @@ exports.importCssString = function importCssString(cssText, id, container) { root.appendChild(style); }; +exports.importCssStylsheet = function(uri, doc) { + exports.buildDom(["link", {rel: "stylesheet", href: uri}], exports.getDocumentHead(doc)); +}; exports.scrollbarWidth = function(document) { var inner = exports.createElement("ace_inner"); inner.style.width = "100%"; @@ -398,6 +464,44 @@ exports.computedStyle = function(element, style) { return window.getComputedStyle(element, "") || {}; }; +exports.setStyle = function(styles, property, value) { + if (styles[property] !== value) { + styles[property] = value; + } +}; + +exports.HAS_CSS_ANIMATION = false; +if (typeof document !== "undefined") { + var div = document.createElement("div"); + if (typeof div.style.animationName !== "undefined") { + exports.HAS_CSS_ANIMATION = true; + } +} + +exports.HAS_CSS_TRANSFORMS = false; +exports.HI_DPI = useragent.isWin + ? typeof window !== "undefined" && window.devicePixelRatio >= 1.5 + : true; + +if (exports.HI_DPI && typeof document !== "undefined") { + var div = document.createElement("div"); + if (div.style.transform !== undefined) + exports.HAS_CSS_TRANSFORMS = true; + div = null; + +} + +if (exports.HAS_CSS_TRANSFORMS) { + exports.translate = function(element, tx, ty) { + element.style.transform = "translate(" + Math.round(tx) + "px, " + Math.round(ty) +"px)"; + }; +} else { + exports.translate = function(element, tx, ty) { + element.style.top = Math.round(ty) + "px"; + element.style.left = Math.round(tx) + "px"; + }; +} + }); define("ace/lib/net",[], function(require, exports, module) { @@ -519,7 +623,6 @@ EventEmitter.removeDefaultHandler = function(eventName, callback) { var disabled = handlers._disabled_[eventName]; if (handlers[eventName] == callback) { - var old = handlers[eventName]; if (disabled) this.setDefaultHandler(eventName, disabled.pop()); } else if (disabled) { diff --git a/build/standalone/modules/plugins/c9.ide.ace.keymaps/vim/keymap.js b/build/standalone/modules/plugins/c9.ide.ace.keymaps/vim/keymap.js index d0082715..d12853a6 100644 --- a/build/standalone/modules/plugins/c9.ide.ace.keymaps/vim/keymap.js +++ b/build/standalone/modules/plugins/c9.ide.ace.keymaps/vim/keymap.js @@ -675,16 +675,18 @@ dom.importCssString(".normal-mode .ace_cursor{\ .ace_dialog {\ position: absolute;\ left: 0; right: 0;\ - background: inherit;\ + background: white;\ z-index: 15;\ padding: .1em .8em;\ overflow: hidden;\ - color: inherit;\ + color: #333;\ }\ .ace_dialog-top {\ + border-bottom: 1px solid #eee;\ top: 0;\ }\ .ace_dialog-bottom {\ + border-top: 1px solid #eee;\ bottom: 0;\ }\ .ace_dialog input {\ @@ -4018,8 +4020,10 @@ dom.importCssString(".normal-mode .ace_cursor{\ cm.openDialog(template, onClose, { bottom: true, value: options.value, onKeyDown: options.onKeyDown, onKeyUp: options.onKeyUp, selectValueOnOpen: false, onClose: function() { - cm.state.vim.status = ""; - cm.ace.renderer.$loop.schedule(cm.ace.renderer.CHANGE_CURSOR); + if (cm.state.vim) { + cm.state.vim.status = ""; + cm.ace.renderer.$loop.schedule(cm.ace.renderer.CHANGE_CURSOR); + } }}); } else { @@ -5372,7 +5376,7 @@ dom.importCssString(".normal-mode .ace_cursor{\ var name = ''; if (e.ctrlKey) { name += 'C-'; } if (e.altKey) { name += 'A-'; } - if (e.shiftKey) { name += 'S-'; } + if ((name || key.length > 1) && e.shiftKey) { name += 'S-'; } name += key; if (name.length > 1) { name = '<' + name + '>'; } @@ -5447,7 +5451,7 @@ dom.importCssString(".normal-mode .ace_cursor{\ var getVim = Vim.maybeInitVimState_; exports.handler = { $id: "ace/keyboard/vim", - drawCursor: function(style, pixelPos, config, sel, session) { + drawCursor: function(element, pixelPos, config, sel, session) { var vim = this.state.vim || {}; var w = config.characterWidth; var h = config.lineHeight; @@ -5464,10 +5468,9 @@ dom.importCssString(".normal-mode .ace_cursor{\ h = h / 2; top += h; } - style.left = left + "px"; - style.top = top + "px"; - style.width = w + "px"; - style.height = h + "px"; + dom.translate(element, left, top); + dom.setStyle(element.style, "width", w + "px"); + dom.setStyle(element.style, "height", h + "px"); }, handleKeyboard: function(data, hashId, key, keyCode, e) { var editor = data.editor; @@ -5631,25 +5634,6 @@ dom.importCssString(".normal-mode .ace_cursor{\ } } }; - var renderVirtualNumbers = { - getText: function(session, row) { - return (Math.abs(session.selection.lead.row - row) || (row + 1 + (row < 9? "\xb7" : "" ))) + ""; - }, - getWidth: function(session, lastLineNumber, config) { - return session.getLength().toString().length * config.characterWidth; - }, - update: function(e, editor) { - editor.renderer.$loop.schedule(editor.renderer.CHANGE_GUTTER); - }, - attach: function(editor) { - editor.renderer.$gutterLayer.$renderer = this; - editor.on("changeSelection", this.update); - }, - detach: function(editor) { - editor.renderer.$gutterLayer.$renderer = null; - editor.off("changeSelection", this.update); - } - }; Vim.defineOption({ name: "wrap", set: function(value, cm) { diff --git a/build/standalone/modules/plugins/c9.ide.scm/blame.js b/build/standalone/modules/plugins/c9.ide.scm/blame.js index 38d4beee..da462d52 100644 --- a/build/standalone/modules/plugins/c9.ide.scm/blame.js +++ b/build/standalone/modules/plugins/c9.ide.scm/blame.js @@ -153,6 +153,7 @@ var BlameGutter = function(editor, blameStr) { this.onMouseout = this.onMouseout.bind(this); this.blameData = []; + this.$cache = []; if (blameStr) this.setData(blameStr); @@ -175,32 +176,24 @@ var BlameGutter = function(editor, blameStr) { editor.blameGutter = this; gutter.blameColumn = this; - this.element = dom.createElement("div"); - this.element.className = "ace_layer ace_blame-gutter-layer"; - var parentEl = editor.renderer.$gutter; - parentEl.appendChild(this.element); - - this.resizer = dom.createElement("div"); - this.resizer.className = "ace_resizer_v"; - parentEl.appendChild(this.resizer); - - this.closeButton = dom.createElement("div"); - this.closeButton.className = "ace_closeButton"; - this.resizer.appendChild(this.closeButton); - - gutter.update = this.drawGutter; - this.editor.on("guttermousedown", this.onMousedown); + this.element = dom.buildDom(["div", { + class: "ace_layer ace_blame-gutter-layer ace_gutter" + }], editor.container); + this.resizer = dom.buildDom(["div", { class: "ace_resizer_v" }, + ["div", { class: "ace_closeButton" }] + ], editor.container); + this.closeButton = this.resizer.firstChild; - var gutterEl = this.editor.renderer.$gutter; - event.addListener(gutterEl, "mousemove", this.onMousemove); - event.addListener(gutterEl, "mouseout", this.onMouseout); + gutter.on("afterRender", this.drawGutter); + this.element.addEventListener("mousedown", this.onMousedown); + this.resizer.addEventListener("mousedown", this.onMousedown); - gutter.element.style.width = ""; - this.resizer.style.right = "40px"; - this.element.style.width = "260px"; - parentEl.style.width = "300px"; + event.addListener(this.element, "mousemove", this.onMousemove); + event.addListener(this.element, "mouseout", this.onMouseout); - gutter.update(this.editor.renderer.layerConfig); + this.resizer.style.left = + this.element.style.width = "220px"; + editor.renderer.setMargin(0, 0, 220, 0); }; this.detachFromEditor = function() { @@ -208,26 +201,14 @@ var BlameGutter = function(editor, blameStr) { var editor = this.editor; var gutter = editor.renderer.$gutterLayer; - gutter.$cells.length = 0; - gutter.element.innerHTML = ""; - delete gutter.update; + gutter.off("afterRender", this.drawGutter); editor.blameGutter = gutter.blameColumn = this.editor = null; - editor.off("guttermousedown", this.onMousedown); - var gutterEl = editor.renderer.$gutter; - event.removeListener(gutterEl, "mousemove", this.onMousemove); - event.removeListener(gutterEl, "mouseout", this.onMouseout); - - gutterEl.style.width = ""; + editor.renderer.setMargin(0); - if (this.element.parentNode) - this.element.parentNode.removeChild(this.element); - - if (this.resizer.parentNode) - this.resizer.parentNode.removeChild(this.resizer); - - gutter.update(editor.renderer.layerConfig); + this.element.remove(); + this.resizer.remove(); }; this.setData = function(blameStr) { @@ -252,151 +233,116 @@ var BlameGutter = function(editor, blameStr) { this.attachToEditor(e.editor); }; - this.drawGutter = function(config) { - this.$config = config; + this.drawGutter = function(e, gutter) { + var container = gutter.blameColumn.element; + var blameData = gutter.blameColumn.blameData; + var selectedHash = gutter.blameColumn.selectedHash; - var blameEl = this.blameColumn.element; - blameEl.style.marginTop = -config.offset + "px"; - - var html = []; - var i = config.firstRow; - var lastRow = config.lastRow; - var fold = this.session.getNextFoldLine(i); - var foldStart = fold ? fold.start.row : Infinity; - var foldWidgets = this.$showFoldWidgets && this.session.foldWidgets; - var lineHeight = config.lineHeight; - - var blameData = this.blameColumn.blameData; - var selectedText = this.selectedText; - var blameHtml = []; - var $blameIndex, lastBlameCellIndex = 0; - var blameCell; - - findBlameCell(i); - if (blameCell) - addBlameCell(blameCell.text, blameCell.title); - else - addBlameCell("", ""); - if (!blameData[i + 1]) { - blameHtml[$blameIndex] -= config.offset - 1; - blameHtml.splice($blameIndex + 1, 0, "px;margin-top:", config.offset - 1); - } - - - while (true) { - if (i > foldStart) { - i = fold.end.row + 1; - fold = this.session.getNextFoldLine(i, fold); - if (fold) { - foldStart = fold.start.row; - lastBlameCellIndex = fold.end.row; - } else { - foldStart = Infinity; - } + var cells = gutter.$lines.cells; + var cache = gutter.blameColumn.$cache; + var cacheIndex = 0; + var offset = - getTop(gutter.element) + gutter.config.offset; + + var commit; + for (var i = 0; i < cells.length; i++) { + var cell = cells[i]; + var row = cell.row; + var data = blameData[row]; + + if (!data && i == 0) { + while (!blameData[row] && row > 0) row--; + data = blameData[row] + commit = { + row: row, + cell: cell, + data: data, + }; } - if (i > lastRow) - break; - - html.push("
", (i + 1)); - - if (foldWidgets) { - var c = foldWidgets[i]; - if (c == null) - c = foldWidgets[i] = this.session.getFoldWidget(i); - if (c) - html.push( - "" - ); - } - - var wrappedRowLength = this.session.getRowLength(i) - 1; - while (wrappedRowLength--) { - html.push("
\xA6"); - } - html.push("
"); - - i++; - findBlameCell(i); - if (blameCell) - addBlameCell(blameCell.text, blameCell.title); - else - blameHtml[$blameIndex] += this.session.getRowLength(i - 1) * lineHeight; + + if (!data) + continue; + + if (commit) + add(commit.data, commit.row, commit.cell, cell); + + commit = { + row: row, + cell: cell, + data: data, + }; } - - this.element.innerHTML = html.join(""); - blameEl.innerHTML = blameHtml.join(""); - this.element.style.height = config.minHeight + "px"; - - var gutterWidth = this.element.parentNode.offsetWidth; - if (gutterWidth !== this.gutterWidth) { - this.gutterWidth = gutterWidth; - this._emit("changeGutterWidth", gutterWidth); + if (commit.cell == cell) + add(commit.data, commit.row, commit.cell); + + function add(data, row, firstCell, nextCell) { + var el = cache[cacheIndex++]; + if (!el) + cache.push(el = dom.createElement("div")); + el.className = "ace_blame-cell " + (data.data.hash == selectedHash ? "selected" : ""); + el.index = row; + el.textContent = data.text + " " + data.title; + + var top = getTop(firstCell.element) - offset; + var next = nextCell ? getTop(nextCell.element) - offset : gutter.config.height; + el.style.top = top + "px"; + el.style.height = next - top + "px"; + + container.appendChild(el); } - - function addBlameCell(text, title) { - blameHtml.push( - "
", - text, " ", title, - "
" - ); - $blameIndex = blameHtml.length - 6; - } - function findBlameCell(i) { - do { - blameCell = blameData[i]; - } while (!blameCell && i-- > lastBlameCellIndex); - lastBlameCellIndex = i + 1; + + while (cacheIndex < cache.length) { + cache.pop().remove(); + } + + function getTop(element) { + return parseInt(element.style.top); } }; this.onMousedown = function(e) { - var target = e.domEvent.target; + var target = e.target; if (target == this.closeButton) { this.removeData(); - return e.stop(); + return event.stopEvent(e); } if (target == this.resizer) { var rect = this.editor.blameGutter.element.getBoundingClientRect(); var mouseHandler = this.editor.$mouseHandler; + apf.plane.setCursor("ew-resize"); + this.editor.blameGutter.resizer.classList.add("hover"); mouseHandler.resizeBlameGutter = function() { - var gutterWidth = this.x + 40 - rect.left; - this.editor.renderer.$gutter.style.width = gutterWidth + "px"; - this.editor.blameGutter.element.style.width = gutterWidth - 40 + "px"; - this.editor.renderer.$gutterLayer._emit("changeGutterWidth", gutterWidth); + var gutterWidth = this.x - rect.left; + this.editor.blameGutter.resizer.style.left = + this.editor.blameGutter.element.style.width = gutterWidth + "px"; + this.editor.renderer.setMargin(0, 0, gutterWidth, 0); }; + mouseHandler.resizeBlameGutterEnd = function() { + apf.plane.unsetCursor(); + this.editor.blameGutter.resizer.classList.remove("hover"); + }; + mouseHandler.setState("resizeBlameGutter"); mouseHandler.captureMouse(e, mouseHandler.resizeBlameGutter.bind(mouseHandler)); - return e.stop(); + return event.stopEvent(e); } if (dom.hasCssClass(target, "ace_blame-cell")) { var gutter = this.editor.renderer.$gutterLayer; - var index = parseInt(target.getAttribute("index"), 10); + var blameData = gutter.blameColumn.blameData; - var blameCell = gutter.blameColumn.blameData[index]; + var blameCell = blameData[target.index]; if (!blameCell) - return e.stop(); - gutter.selectedText = blameCell.text; - var ch = target.parentNode.children; - for (var i = ch.length; i--;) { - var isSelected = ch[i].innerHTML.indexOf(gutter.selectedText) == 0; - ch[i].className = "ace_blame-cell" + (isSelected ? " selected" : ""); - } - return e.stop(); + return event.stopEvent(e); + gutter.blameColumn.selectedHash = blameCell.data.hash; + this.editor.renderer.$loop.schedule(this.editor.renderer.CHANGE_GUTTER); + return event.stopEvent(e); } }; this.onMousemove = function(e) { var target = e.target; var container = e.currentTarget; - return; var tooltip = this.editor.tooltip; if (this.$highlightedCell != target) { if (dom.hasCssClass(target, "ace_blame-cell")) { @@ -407,6 +353,8 @@ var BlameGutter = function(editor, blameStr) { } if (this.$highlightedCell) { + tooltip.style.top = e.clientY + 10 + "px"; + tooltip.style.left = e.clientX + 10 + "px"; } else { this.onMouseout(); return; @@ -416,6 +364,8 @@ var BlameGutter = function(editor, blameStr) { this.$highlightedCell = null; }; }).call(BlameGutter.prototype); + + exports.annotate = function annotate(editor, blameStr) { return new BlameGutter(editor, blameStr); }; diff --git a/build/standalone/skin/default/dark-gray.css b/build/standalone/skin/default/dark-gray.css index 511dc99b..f50c7222 100644 --- a/build/standalone/skin/default/dark-gray.css +++ b/build/standalone/skin/default/dark-gray.css @@ -1182,6 +1182,18 @@ color: #d9ff0f; padding: 1px 2px 1px 2px; } +.ace_collab_cursor { + position: absolute; + z-index: 11; +} +.ace_collab_cursor:before { + content: ""; + width: 6px; + height: 5px; + display: block; + background: inherit; + margin-left: -2px; +} /* @file plugins/c9.ide.scm/diff/conflictmarker.css */ .conflict-widget-1 { background: #b2e491; @@ -1442,6 +1454,7 @@ position: absolute; box-sizing: border-box; min-width: 100%; + contain: style size layout; } .ace_dragging .ace_scroller:before { position: absolute; @@ -1469,6 +1482,7 @@ -moz-user-select: none; -webkit-user-select: none; -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; + contain: style size layout; } .ace_gutter-active-line { position: absolute; @@ -1479,6 +1493,10 @@ box-shadow: 17px 0 16px -16px rgba(0, 0, 0, 0.4) inset; } .ace_gutter-cell { + position: absolute; + top: 0; + left: 0; + right: 0; padding-left: 19px; padding-right: 6px; background-repeat: no-repeat; @@ -1500,6 +1518,7 @@ background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQBAMAAADt3eJSAAAAJFBMVEUAAAChoaGAgIAqKiq+vr6tra1ZWVmUlJSbm5s8PDxubm56enrdgzg3AAAAAXRSTlMAQObYZgAAAClJREFUeNpjYMAPdsMYHegyJZFQBlsUlMFVCWUYKkAZMxZAGdxlDMQBAG+TBP4B6RyJAAAAAElFTkSuQmCC"); } .ace_scrollbar { + contain: strict; position: absolute; right: 0; bottom: 0; @@ -1581,9 +1600,34 @@ width: auto; text-align: right; pointer-events: auto; + height: 1000000px; + contain: style size layout; } .ace_text-layer { font: inherit !important; + position: absolute; + height: 1000000px; + width: 1000000px; + contain: style size layout; +} +.ace_text-layer > .ace_line, +.ace_text-layer > .ace_line_group { + contain: style size layout; + position: absolute; + top: 0; + left: 0; + right: 0; +} +.ace_hidpi .ace_text-layer, +.ace_hidpi .ace_gutter-layer, +.ace_hidpi .ace_content, +.ace_hidpi .ace_gutter { + contain: strict; + will-change: transform; +} +.ace_hidpi .ace_text-layer > .ace_line, +.ace_hidpi .ace_text-layer > .ace_line_group { + contain: strict; } .ace_cjk { display: inline-block; @@ -1615,6 +1659,41 @@ .ace_smooth-blinking .ace_cursor { transition: opacity 0.18s; } +.ace_animate-blinking .ace_cursor { + animation-duration: 1000ms; + animation-timing-function: step-end; + animation-name: blink-ace-animate; + animation-iteration-count: infinite; +} +.ace_animate-blinking.ace_smooth-blinking .ace_cursor { + animation-duration: 1000ms; + animation-timing-function: ease-in-out; + animation-name: blink-ace-animate-smooth; +} +@keyframes blink-ace-animate { + from, + to { + opacity: 1; + } + 60% { + opacity: 0; + } +} +@keyframes blink-ace-animate-smooth { + from, + to { + opacity: 1; + } + 45% { + opacity: 1; + } + 60% { + opacity: 0; + } + 85% { + opacity: 0; + } +} .ace_marker-layer .ace_step, .ace_marker-layer .ace_stack { position: absolute; @@ -1775,10 +1854,6 @@ position: absolute; z-index: 8; } -.ace_lineWidgetContainer { - z-index: 5; - position: absolute; -} .ace_br1 { border-top-left-radius: 3px; } @@ -10518,16 +10593,11 @@ body .splitbutton .arrow { text-shadow: none; } .code_complete_text .ace_text-layer { - left: 1px; - right: 1px; - width: auto; - top: 1px; - bottom: 1px; + margin: 1px!important; } .code_complete_text .ace_line { background: transparent; overflow: hidden; - position: relative; white-space: nowrap; pointer-events: auto; cursor: pointer; diff --git a/build/standalone/skin/default/dark.css b/build/standalone/skin/default/dark.css index 8a411e79..1c4f94f0 100644 --- a/build/standalone/skin/default/dark.css +++ b/build/standalone/skin/default/dark.css @@ -1182,6 +1182,18 @@ color: #d9ff0f; padding: 1px 2px 1px 2px; } +.ace_collab_cursor { + position: absolute; + z-index: 11; +} +.ace_collab_cursor:before { + content: ""; + width: 6px; + height: 5px; + display: block; + background: inherit; + margin-left: -2px; +} /* @file plugins/c9.ide.scm/diff/conflictmarker.css */ .conflict-widget-1 { background: #b2e491; @@ -1442,6 +1454,7 @@ position: absolute; box-sizing: border-box; min-width: 100%; + contain: style size layout; } .ace_dragging .ace_scroller:before { position: absolute; @@ -1469,6 +1482,7 @@ -moz-user-select: none; -webkit-user-select: none; -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; + contain: style size layout; } .ace_gutter-active-line { position: absolute; @@ -1479,6 +1493,10 @@ box-shadow: 17px 0 16px -16px rgba(0, 0, 0, 0.4) inset; } .ace_gutter-cell { + position: absolute; + top: 0; + left: 0; + right: 0; padding-left: 19px; padding-right: 6px; background-repeat: no-repeat; @@ -1500,6 +1518,7 @@ background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQBAMAAADt3eJSAAAAJFBMVEUAAAChoaGAgIAqKiq+vr6tra1ZWVmUlJSbm5s8PDxubm56enrdgzg3AAAAAXRSTlMAQObYZgAAAClJREFUeNpjYMAPdsMYHegyJZFQBlsUlMFVCWUYKkAZMxZAGdxlDMQBAG+TBP4B6RyJAAAAAElFTkSuQmCC"); } .ace_scrollbar { + contain: strict; position: absolute; right: 0; bottom: 0; @@ -1581,9 +1600,34 @@ width: auto; text-align: right; pointer-events: auto; + height: 1000000px; + contain: style size layout; } .ace_text-layer { font: inherit !important; + position: absolute; + height: 1000000px; + width: 1000000px; + contain: style size layout; +} +.ace_text-layer > .ace_line, +.ace_text-layer > .ace_line_group { + contain: style size layout; + position: absolute; + top: 0; + left: 0; + right: 0; +} +.ace_hidpi .ace_text-layer, +.ace_hidpi .ace_gutter-layer, +.ace_hidpi .ace_content, +.ace_hidpi .ace_gutter { + contain: strict; + will-change: transform; +} +.ace_hidpi .ace_text-layer > .ace_line, +.ace_hidpi .ace_text-layer > .ace_line_group { + contain: strict; } .ace_cjk { display: inline-block; @@ -1615,6 +1659,41 @@ .ace_smooth-blinking .ace_cursor { transition: opacity 0.18s; } +.ace_animate-blinking .ace_cursor { + animation-duration: 1000ms; + animation-timing-function: step-end; + animation-name: blink-ace-animate; + animation-iteration-count: infinite; +} +.ace_animate-blinking.ace_smooth-blinking .ace_cursor { + animation-duration: 1000ms; + animation-timing-function: ease-in-out; + animation-name: blink-ace-animate-smooth; +} +@keyframes blink-ace-animate { + from, + to { + opacity: 1; + } + 60% { + opacity: 0; + } +} +@keyframes blink-ace-animate-smooth { + from, + to { + opacity: 1; + } + 45% { + opacity: 1; + } + 60% { + opacity: 0; + } + 85% { + opacity: 0; + } +} .ace_marker-layer .ace_step, .ace_marker-layer .ace_stack { position: absolute; @@ -1775,10 +1854,6 @@ position: absolute; z-index: 8; } -.ace_lineWidgetContainer { - z-index: 5; - position: absolute; -} .ace_br1 { border-top-left-radius: 3px; } @@ -10518,16 +10593,11 @@ body .splitbutton .arrow { text-shadow: none; } .code_complete_text .ace_text-layer { - left: 1px; - right: 1px; - width: auto; - top: 1px; - bottom: 1px; + margin: 1px!important; } .code_complete_text .ace_line { background: transparent; overflow: hidden; - position: relative; white-space: nowrap; pointer-events: auto; cursor: pointer; diff --git a/build/standalone/skin/default/flat-dark.css b/build/standalone/skin/default/flat-dark.css index 3d8c5e63..d7944cb0 100644 --- a/build/standalone/skin/default/flat-dark.css +++ b/build/standalone/skin/default/flat-dark.css @@ -1114,6 +1114,18 @@ color: #d9ff0f; padding: 1px 2px 1px 2px; } +.ace_collab_cursor { + position: absolute; + z-index: 11; +} +.ace_collab_cursor:before { + content: ""; + width: 6px; + height: 5px; + display: block; + background: inherit; + margin-left: -2px; +} /* @file plugins/c9.ide.scm/diff/conflictmarker.css */ .conflict-widget-1 { background: #b2e491; @@ -1374,6 +1386,7 @@ position: absolute; box-sizing: border-box; min-width: 100%; + contain: style size layout; } .ace_dragging .ace_scroller:before { position: absolute; @@ -1401,6 +1414,7 @@ -moz-user-select: none; -webkit-user-select: none; -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; + contain: style size layout; } .ace_gutter-active-line { position: absolute; @@ -1411,6 +1425,10 @@ box-shadow: 17px 0 16px -16px rgba(0, 0, 0, 0.4) inset; } .ace_gutter-cell { + position: absolute; + top: 0; + left: 0; + right: 0; padding-left: 19px; padding-right: 6px; background-repeat: no-repeat; @@ -1432,6 +1450,7 @@ background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQBAMAAADt3eJSAAAAJFBMVEUAAAChoaGAgIAqKiq+vr6tra1ZWVmUlJSbm5s8PDxubm56enrdgzg3AAAAAXRSTlMAQObYZgAAAClJREFUeNpjYMAPdsMYHegyJZFQBlsUlMFVCWUYKkAZMxZAGdxlDMQBAG+TBP4B6RyJAAAAAElFTkSuQmCC"); } .ace_scrollbar { + contain: strict; position: absolute; right: 0; bottom: 0; @@ -1513,9 +1532,34 @@ width: auto; text-align: right; pointer-events: auto; + height: 1000000px; + contain: style size layout; } .ace_text-layer { font: inherit !important; + position: absolute; + height: 1000000px; + width: 1000000px; + contain: style size layout; +} +.ace_text-layer > .ace_line, +.ace_text-layer > .ace_line_group { + contain: style size layout; + position: absolute; + top: 0; + left: 0; + right: 0; +} +.ace_hidpi .ace_text-layer, +.ace_hidpi .ace_gutter-layer, +.ace_hidpi .ace_content, +.ace_hidpi .ace_gutter { + contain: strict; + will-change: transform; +} +.ace_hidpi .ace_text-layer > .ace_line, +.ace_hidpi .ace_text-layer > .ace_line_group { + contain: strict; } .ace_cjk { display: inline-block; @@ -1547,6 +1591,41 @@ .ace_smooth-blinking .ace_cursor { transition: opacity 0.18s; } +.ace_animate-blinking .ace_cursor { + animation-duration: 1000ms; + animation-timing-function: step-end; + animation-name: blink-ace-animate; + animation-iteration-count: infinite; +} +.ace_animate-blinking.ace_smooth-blinking .ace_cursor { + animation-duration: 1000ms; + animation-timing-function: ease-in-out; + animation-name: blink-ace-animate-smooth; +} +@keyframes blink-ace-animate { + from, + to { + opacity: 1; + } + 60% { + opacity: 0; + } +} +@keyframes blink-ace-animate-smooth { + from, + to { + opacity: 1; + } + 45% { + opacity: 1; + } + 60% { + opacity: 0; + } + 85% { + opacity: 0; + } +} .ace_marker-layer .ace_step, .ace_marker-layer .ace_stack { position: absolute; @@ -1707,10 +1786,6 @@ position: absolute; z-index: 8; } -.ace_lineWidgetContainer { - z-index: 5; - position: absolute; -} .ace_br1 { border-top-left-radius: 3px; } @@ -10531,16 +10606,11 @@ body .splitbutton .arrow { text-shadow: none; } .code_complete_text .ace_text-layer { - left: 1px; - right: 1px; - width: auto; - top: 1px; - bottom: 1px; + margin: 1px!important; } .code_complete_text .ace_line { background: transparent; overflow: hidden; - position: relative; white-space: nowrap; pointer-events: auto; cursor: pointer; diff --git a/build/standalone/skin/default/flat-light.css b/build/standalone/skin/default/flat-light.css index 0ffeb551..3fce8f69 100644 --- a/build/standalone/skin/default/flat-light.css +++ b/build/standalone/skin/default/flat-light.css @@ -1114,6 +1114,18 @@ color: #d9ff0f; padding: 1px 2px 1px 2px; } +.ace_collab_cursor { + position: absolute; + z-index: 11; +} +.ace_collab_cursor:before { + content: ""; + width: 6px; + height: 5px; + display: block; + background: inherit; + margin-left: -2px; +} /* @file plugins/c9.ide.scm/diff/conflictmarker.css */ .conflict-widget-1 { background: #b2e491; @@ -1374,6 +1386,7 @@ position: absolute; box-sizing: border-box; min-width: 100%; + contain: style size layout; } .ace_dragging .ace_scroller:before { position: absolute; @@ -1401,6 +1414,7 @@ -moz-user-select: none; -webkit-user-select: none; -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; + contain: style size layout; } .ace_gutter-active-line { position: absolute; @@ -1411,6 +1425,10 @@ box-shadow: 17px 0 16px -16px rgba(0, 0, 0, 0.4) inset; } .ace_gutter-cell { + position: absolute; + top: 0; + left: 0; + right: 0; padding-left: 19px; padding-right: 6px; background-repeat: no-repeat; @@ -1432,6 +1450,7 @@ background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQBAMAAADt3eJSAAAAJFBMVEUAAAChoaGAgIAqKiq+vr6tra1ZWVmUlJSbm5s8PDxubm56enrdgzg3AAAAAXRSTlMAQObYZgAAAClJREFUeNpjYMAPdsMYHegyJZFQBlsUlMFVCWUYKkAZMxZAGdxlDMQBAG+TBP4B6RyJAAAAAElFTkSuQmCC"); } .ace_scrollbar { + contain: strict; position: absolute; right: 0; bottom: 0; @@ -1513,9 +1532,34 @@ width: auto; text-align: right; pointer-events: auto; + height: 1000000px; + contain: style size layout; } .ace_text-layer { font: inherit !important; + position: absolute; + height: 1000000px; + width: 1000000px; + contain: style size layout; +} +.ace_text-layer > .ace_line, +.ace_text-layer > .ace_line_group { + contain: style size layout; + position: absolute; + top: 0; + left: 0; + right: 0; +} +.ace_hidpi .ace_text-layer, +.ace_hidpi .ace_gutter-layer, +.ace_hidpi .ace_content, +.ace_hidpi .ace_gutter { + contain: strict; + will-change: transform; +} +.ace_hidpi .ace_text-layer > .ace_line, +.ace_hidpi .ace_text-layer > .ace_line_group { + contain: strict; } .ace_cjk { display: inline-block; @@ -1547,6 +1591,41 @@ .ace_smooth-blinking .ace_cursor { transition: opacity 0.18s; } +.ace_animate-blinking .ace_cursor { + animation-duration: 1000ms; + animation-timing-function: step-end; + animation-name: blink-ace-animate; + animation-iteration-count: infinite; +} +.ace_animate-blinking.ace_smooth-blinking .ace_cursor { + animation-duration: 1000ms; + animation-timing-function: ease-in-out; + animation-name: blink-ace-animate-smooth; +} +@keyframes blink-ace-animate { + from, + to { + opacity: 1; + } + 60% { + opacity: 0; + } +} +@keyframes blink-ace-animate-smooth { + from, + to { + opacity: 1; + } + 45% { + opacity: 1; + } + 60% { + opacity: 0; + } + 85% { + opacity: 0; + } +} .ace_marker-layer .ace_step, .ace_marker-layer .ace_stack { position: absolute; @@ -1707,10 +1786,6 @@ position: absolute; z-index: 8; } -.ace_lineWidgetContainer { - z-index: 5; - position: absolute; -} .ace_br1 { border-top-left-radius: 3px; } @@ -10508,16 +10583,11 @@ body .splitbutton .arrow { text-shadow: none; } .code_complete_text .ace_text-layer { - left: 1px; - right: 1px; - width: auto; - top: 1px; - bottom: 1px; + margin: 1px!important; } .code_complete_text .ace_line { background: transparent; overflow: hidden; - position: relative; white-space: nowrap; pointer-events: auto; cursor: pointer; diff --git a/build/standalone/skin/default/jett-dark.css b/build/standalone/skin/default/jett-dark.css index 9ac1d866..41b47d5f 100644 --- a/build/standalone/skin/default/jett-dark.css +++ b/build/standalone/skin/default/jett-dark.css @@ -1114,6 +1114,18 @@ color: #d9ff0f; padding: 1px 2px 1px 2px; } +.ace_collab_cursor { + position: absolute; + z-index: 11; +} +.ace_collab_cursor:before { + content: ""; + width: 6px; + height: 5px; + display: block; + background: inherit; + margin-left: -2px; +} /* @file plugins/c9.ide.scm/diff/conflictmarker.css */ .conflict-widget-1 { background: #b2e491; @@ -1374,6 +1386,7 @@ position: absolute; box-sizing: border-box; min-width: 100%; + contain: style size layout; } .ace_dragging .ace_scroller:before { position: absolute; @@ -1401,6 +1414,7 @@ -moz-user-select: none; -webkit-user-select: none; -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; + contain: style size layout; } .ace_gutter-active-line { position: absolute; @@ -1411,6 +1425,10 @@ box-shadow: 17px 0 16px -16px rgba(0, 0, 0, 0.4) inset; } .ace_gutter-cell { + position: absolute; + top: 0; + left: 0; + right: 0; padding-left: 19px; padding-right: 6px; background-repeat: no-repeat; @@ -1432,6 +1450,7 @@ background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQBAMAAADt3eJSAAAAJFBMVEUAAAChoaGAgIAqKiq+vr6tra1ZWVmUlJSbm5s8PDxubm56enrdgzg3AAAAAXRSTlMAQObYZgAAAClJREFUeNpjYMAPdsMYHegyJZFQBlsUlMFVCWUYKkAZMxZAGdxlDMQBAG+TBP4B6RyJAAAAAElFTkSuQmCC"); } .ace_scrollbar { + contain: strict; position: absolute; right: 0; bottom: 0; @@ -1513,9 +1532,34 @@ width: auto; text-align: right; pointer-events: auto; + height: 1000000px; + contain: style size layout; } .ace_text-layer { font: inherit !important; + position: absolute; + height: 1000000px; + width: 1000000px; + contain: style size layout; +} +.ace_text-layer > .ace_line, +.ace_text-layer > .ace_line_group { + contain: style size layout; + position: absolute; + top: 0; + left: 0; + right: 0; +} +.ace_hidpi .ace_text-layer, +.ace_hidpi .ace_gutter-layer, +.ace_hidpi .ace_content, +.ace_hidpi .ace_gutter { + contain: strict; + will-change: transform; +} +.ace_hidpi .ace_text-layer > .ace_line, +.ace_hidpi .ace_text-layer > .ace_line_group { + contain: strict; } .ace_cjk { display: inline-block; @@ -1547,6 +1591,41 @@ .ace_smooth-blinking .ace_cursor { transition: opacity 0.18s; } +.ace_animate-blinking .ace_cursor { + animation-duration: 1000ms; + animation-timing-function: step-end; + animation-name: blink-ace-animate; + animation-iteration-count: infinite; +} +.ace_animate-blinking.ace_smooth-blinking .ace_cursor { + animation-duration: 1000ms; + animation-timing-function: ease-in-out; + animation-name: blink-ace-animate-smooth; +} +@keyframes blink-ace-animate { + from, + to { + opacity: 1; + } + 60% { + opacity: 0; + } +} +@keyframes blink-ace-animate-smooth { + from, + to { + opacity: 1; + } + 45% { + opacity: 1; + } + 60% { + opacity: 0; + } + 85% { + opacity: 0; + } +} .ace_marker-layer .ace_step, .ace_marker-layer .ace_stack { position: absolute; @@ -1707,10 +1786,6 @@ position: absolute; z-index: 8; } -.ace_lineWidgetContainer { - z-index: 5; - position: absolute; -} .ace_br1 { border-top-left-radius: 3px; } @@ -10508,16 +10583,11 @@ body .splitbutton .arrow { text-shadow: none; } .code_complete_text .ace_text-layer { - left: 1px; - right: 1px; - width: auto; - top: 1px; - bottom: 1px; + margin: 1px!important; } .code_complete_text .ace_line { background: transparent; overflow: hidden; - position: relative; white-space: nowrap; pointer-events: auto; cursor: pointer; diff --git a/build/standalone/skin/default/light-gray.css b/build/standalone/skin/default/light-gray.css index 6135e178..76580ed9 100644 --- a/build/standalone/skin/default/light-gray.css +++ b/build/standalone/skin/default/light-gray.css @@ -1182,6 +1182,18 @@ color: #d9ff0f; padding: 1px 2px 1px 2px; } +.ace_collab_cursor { + position: absolute; + z-index: 11; +} +.ace_collab_cursor:before { + content: ""; + width: 6px; + height: 5px; + display: block; + background: inherit; + margin-left: -2px; +} /* @file plugins/c9.ide.scm/diff/conflictmarker.css */ .conflict-widget-1 { background: #b2e491; @@ -1442,6 +1454,7 @@ position: absolute; box-sizing: border-box; min-width: 100%; + contain: style size layout; } .ace_dragging .ace_scroller:before { position: absolute; @@ -1469,6 +1482,7 @@ -moz-user-select: none; -webkit-user-select: none; -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; + contain: style size layout; } .ace_gutter-active-line { position: absolute; @@ -1479,6 +1493,10 @@ box-shadow: 17px 0 16px -16px rgba(0, 0, 0, 0.4) inset; } .ace_gutter-cell { + position: absolute; + top: 0; + left: 0; + right: 0; padding-left: 19px; padding-right: 6px; background-repeat: no-repeat; @@ -1500,6 +1518,7 @@ background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQBAMAAADt3eJSAAAAJFBMVEUAAAChoaGAgIAqKiq+vr6tra1ZWVmUlJSbm5s8PDxubm56enrdgzg3AAAAAXRSTlMAQObYZgAAAClJREFUeNpjYMAPdsMYHegyJZFQBlsUlMFVCWUYKkAZMxZAGdxlDMQBAG+TBP4B6RyJAAAAAElFTkSuQmCC"); } .ace_scrollbar { + contain: strict; position: absolute; right: 0; bottom: 0; @@ -1581,9 +1600,34 @@ width: auto; text-align: right; pointer-events: auto; + height: 1000000px; + contain: style size layout; } .ace_text-layer { font: inherit !important; + position: absolute; + height: 1000000px; + width: 1000000px; + contain: style size layout; +} +.ace_text-layer > .ace_line, +.ace_text-layer > .ace_line_group { + contain: style size layout; + position: absolute; + top: 0; + left: 0; + right: 0; +} +.ace_hidpi .ace_text-layer, +.ace_hidpi .ace_gutter-layer, +.ace_hidpi .ace_content, +.ace_hidpi .ace_gutter { + contain: strict; + will-change: transform; +} +.ace_hidpi .ace_text-layer > .ace_line, +.ace_hidpi .ace_text-layer > .ace_line_group { + contain: strict; } .ace_cjk { display: inline-block; @@ -1615,6 +1659,41 @@ .ace_smooth-blinking .ace_cursor { transition: opacity 0.18s; } +.ace_animate-blinking .ace_cursor { + animation-duration: 1000ms; + animation-timing-function: step-end; + animation-name: blink-ace-animate; + animation-iteration-count: infinite; +} +.ace_animate-blinking.ace_smooth-blinking .ace_cursor { + animation-duration: 1000ms; + animation-timing-function: ease-in-out; + animation-name: blink-ace-animate-smooth; +} +@keyframes blink-ace-animate { + from, + to { + opacity: 1; + } + 60% { + opacity: 0; + } +} +@keyframes blink-ace-animate-smooth { + from, + to { + opacity: 1; + } + 45% { + opacity: 1; + } + 60% { + opacity: 0; + } + 85% { + opacity: 0; + } +} .ace_marker-layer .ace_step, .ace_marker-layer .ace_stack { position: absolute; @@ -1775,10 +1854,6 @@ position: absolute; z-index: 8; } -.ace_lineWidgetContainer { - z-index: 5; - position: absolute; -} .ace_br1 { border-top-left-radius: 3px; } @@ -10518,16 +10593,11 @@ body .splitbutton .arrow { text-shadow: none; } .code_complete_text .ace_text-layer { - left: 1px; - right: 1px; - width: auto; - top: 1px; - bottom: 1px; + margin: 1px!important; } .code_complete_text .ace_line { background: transparent; overflow: hidden; - position: relative; white-space: nowrap; pointer-events: auto; cursor: pointer; diff --git a/build/standalone/skin/default/light.css b/build/standalone/skin/default/light.css index eaa6b13d..fb8f73fd 100644 --- a/build/standalone/skin/default/light.css +++ b/build/standalone/skin/default/light.css @@ -1182,6 +1182,18 @@ color: #d9ff0f; padding: 1px 2px 1px 2px; } +.ace_collab_cursor { + position: absolute; + z-index: 11; +} +.ace_collab_cursor:before { + content: ""; + width: 6px; + height: 5px; + display: block; + background: inherit; + margin-left: -2px; +} /* @file plugins/c9.ide.scm/diff/conflictmarker.css */ .conflict-widget-1 { background: #b2e491; @@ -1442,6 +1454,7 @@ position: absolute; box-sizing: border-box; min-width: 100%; + contain: style size layout; } .ace_dragging .ace_scroller:before { position: absolute; @@ -1469,6 +1482,7 @@ -moz-user-select: none; -webkit-user-select: none; -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; + contain: style size layout; } .ace_gutter-active-line { position: absolute; @@ -1479,6 +1493,10 @@ box-shadow: 17px 0 16px -16px rgba(0, 0, 0, 0.4) inset; } .ace_gutter-cell { + position: absolute; + top: 0; + left: 0; + right: 0; padding-left: 19px; padding-right: 6px; background-repeat: no-repeat; @@ -1500,6 +1518,7 @@ background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQBAMAAADt3eJSAAAAJFBMVEUAAAChoaGAgIAqKiq+vr6tra1ZWVmUlJSbm5s8PDxubm56enrdgzg3AAAAAXRSTlMAQObYZgAAAClJREFUeNpjYMAPdsMYHegyJZFQBlsUlMFVCWUYKkAZMxZAGdxlDMQBAG+TBP4B6RyJAAAAAElFTkSuQmCC"); } .ace_scrollbar { + contain: strict; position: absolute; right: 0; bottom: 0; @@ -1581,9 +1600,34 @@ width: auto; text-align: right; pointer-events: auto; + height: 1000000px; + contain: style size layout; } .ace_text-layer { font: inherit !important; + position: absolute; + height: 1000000px; + width: 1000000px; + contain: style size layout; +} +.ace_text-layer > .ace_line, +.ace_text-layer > .ace_line_group { + contain: style size layout; + position: absolute; + top: 0; + left: 0; + right: 0; +} +.ace_hidpi .ace_text-layer, +.ace_hidpi .ace_gutter-layer, +.ace_hidpi .ace_content, +.ace_hidpi .ace_gutter { + contain: strict; + will-change: transform; +} +.ace_hidpi .ace_text-layer > .ace_line, +.ace_hidpi .ace_text-layer > .ace_line_group { + contain: strict; } .ace_cjk { display: inline-block; @@ -1615,6 +1659,41 @@ .ace_smooth-blinking .ace_cursor { transition: opacity 0.18s; } +.ace_animate-blinking .ace_cursor { + animation-duration: 1000ms; + animation-timing-function: step-end; + animation-name: blink-ace-animate; + animation-iteration-count: infinite; +} +.ace_animate-blinking.ace_smooth-blinking .ace_cursor { + animation-duration: 1000ms; + animation-timing-function: ease-in-out; + animation-name: blink-ace-animate-smooth; +} +@keyframes blink-ace-animate { + from, + to { + opacity: 1; + } + 60% { + opacity: 0; + } +} +@keyframes blink-ace-animate-smooth { + from, + to { + opacity: 1; + } + 45% { + opacity: 1; + } + 60% { + opacity: 0; + } + 85% { + opacity: 0; + } +} .ace_marker-layer .ace_step, .ace_marker-layer .ace_stack { position: absolute; @@ -1775,10 +1854,6 @@ position: absolute; z-index: 8; } -.ace_lineWidgetContainer { - z-index: 5; - position: absolute; -} .ace_br1 { border-top-left-radius: 3px; } @@ -10518,16 +10593,11 @@ body .splitbutton .arrow { text-shadow: none; } .code_complete_text .ace_text-layer { - left: 1px; - right: 1px; - width: auto; - top: 1px; - bottom: 1px; + margin: 1px!important; } .code_complete_text .ace_line { background: transparent; overflow: hidden; - position: relative; white-space: nowrap; pointer-events: auto; cursor: pointer; diff --git a/build/standalone/static/places.html b/build/standalone/static/places.html index 23c40d66..0d7fbd79 100644 --- a/build/standalone/static/places.html +++ b/build/standalone/static/places.html @@ -13,8 +13,7 @@ var places = { VFS: "/vfs", Preview: "/preview", StaticIde: ["/static/ide.html", "/static/ide.offline.html"], - Test: "/static/test.html", - List_of_tests: "/static/test.html?", + List_of_tests: ["/static/test.html", "?es5=1"] }, Collab: { main: "/static/plugins/c9.ide.collab/collab_test.html", diff --git a/build/standalone/static/plugins/c9.ide.scm/blame.css b/build/standalone/static/plugins/c9.ide.scm/blame.css index 891b7b9e..a4fc2485 100644 --- a/build/standalone/static/plugins/c9.ide.scm/blame.css +++ b/build/standalone/static/plugins/c9.ide.scm/blame.css @@ -7,7 +7,7 @@ position: absolute; border-right: 1px solid black; } -.ace_resizer_v:hover { +.ace_resizer_v:hover,.ace_resizer_v.hover { border-right-color: darkblue; } .ace_closeButton { @@ -38,7 +38,9 @@ overflow: hidden !important; padding: 0 8px; border-top-color: rgba(230, 230, 250, 0.24); - font-family: arial + font-family: arial; + position: absolute; + width: 100%; } .ace_blame-cell.selected{ background: rgba(255, 237, 0, 0.31); diff --git a/build/standalone/static/test.html b/build/standalone/static/test.html index 9e0c2cfb..9705e85b 100644 --- a/build/standalone/static/test.html +++ b/build/standalone/static/test.html @@ -22,6 +22,10 @@ " + ], new PHPMode()); + s.setUseSoftTabs(false); + + beautify.beautify(s); + assert.equal(s.getValue(), ""); + next(); } }; diff --git a/plugins/node_modules/ace/lib/ace/ext/emmet.js b/plugins/node_modules/ace/lib/ace/ext/emmet.js index e2cc28ae..2587d44e 100644 --- a/plugins/node_modules/ace/lib/ace/ext/emmet.js +++ b/plugins/node_modules/ace/lib/ace/ext/emmet.js @@ -414,7 +414,7 @@ exports.isAvailable = function(editor, command) { // TODO refactor mode delegates to make this simpler try { editorProxy.setupContext(editor); - if (/^(js|php)/.test(editorProxy.getSyntax())) + if (/js|php/.test(editorProxy.getSyntax())) isSupported = false; } catch(e) {} } diff --git a/plugins/node_modules/ace/lib/ace/ext/modelist.js b/plugins/node_modules/ace/lib/ace/ext/modelist.js index 942ce142..08deec8f 100644 --- a/plugins/node_modules/ace/lib/ace/ext/modelist.js +++ b/plugins/node_modules/ace/lib/ace/ext/modelist.js @@ -49,6 +49,7 @@ var supportedModes = { ADA: ["ada|adb"], Apache_Conf: ["^htaccess|^htgroups|^htpasswd|^conf|htaccess|htgroups|htpasswd"], AsciiDoc: ["asciidoc|adoc"], + ASL: ["dsl|asl"], Assembly_x86:["asm|a"], AutoHotKey: ["ahk"], BatchFile: ["bat|cmd"], diff --git a/plugins/node_modules/ace/lib/ace/ext/options.js b/plugins/node_modules/ace/lib/ace/ext/options.js index 9014aeb5..48359643 100644 --- a/plugins/node_modules/ace/lib/ace/ext/options.js +++ b/plugins/node_modules/ace/lib/ace/ext/options.js @@ -129,6 +129,15 @@ var optionGroups = { "Show Gutter": { path: "showGutter" }, + "Show Line Numbers": { + path: "showLineNumbers" + }, + "Relative Line Numbers": { + path: "relativeLineNumbers" + }, + "Fixed Gutter Width": { + path: "fixedWidthGutter" + }, "Show Print Margin": [{ path: "showPrintMargin" }, { diff --git a/plugins/node_modules/ace/lib/ace/ext/static_highlight.js b/plugins/node_modules/ace/lib/ace/ext/static_highlight.js index fc1928fc..e45e83cc 100644 --- a/plugins/node_modules/ace/lib/ace/ext/static_highlight.js +++ b/plugins/node_modules/ace/lib/ace/ext/static_highlight.js @@ -37,8 +37,77 @@ var baseStyles = require("../requirejs/text!./static.css"); var config = require("../config"); var dom = require("../lib/dom"); +var simpleDom = { + createTextNode: function(textContent) { + return textContent; + }, + createElement: function(type) { + var element = { + type: type, + style: {}, + childNodes: [], + appendChild: function(child) { + element.childNodes.push(child); + }, + toString: function() { + var internal = { + type: 1, + style: 1, + className: 1, + textContent: 1, + childNodes: 1, + appendChild: 1, + toString: 1 + }; + var stringBuilder = []; + + if (element.type != "fragment") { + stringBuilder.push("<", element.type); + if (element.className) + stringBuilder.push(" class='", element.className, "'"); + var styleStr = []; + for (var key in element.style) { + styleStr.push(key, ":", element.style[key]); + } + if (styleStr.length) + stringBuilder.push(" style='", styleStr.join(""), "'"); + for (var key in element) { + if (!internal[key]) { + stringBuilder.push(" ", key, "='", element[key], "'"); + } + } + stringBuilder.push(">"); + } + + if (element.textContent) { + stringBuilder.push(element.textContent); + } else { + for (var i=0; i"); + } + + return stringBuilder.join(""); + } + }; + return element; + }, + createFragment: function() { + return this.createElement("fragment"); + } +}; + var SimpleTextLayer = function() { this.config = {}; + this.dom = simpleDom; }; SimpleTextLayer.prototype = TextLayer.prototype; @@ -64,7 +133,7 @@ var highlight = function(el, opts, callback) { } } } else { - data = dom.getInnerText(el); + data = el.textContent; if (opts.trim) data = data.trim(); } @@ -157,31 +226,38 @@ highlight.renderSync = function(input, mode, theme, lineStart, disableGutter) { textLayer.setSession(session); session.setValue(input); - - var stringBuilder = []; var length = session.getLength(); + + var outerEl = simpleDom.createElement("div"); + outerEl.className = theme.cssClass; + + var innerEl = simpleDom.createElement("div"); + innerEl.className = "ace_static_highlight" + (disableGutter ? "" : " ace_show_gutter"); + innerEl.style["counter-reset"] = "ace_line " + (lineStart - 1); + outerEl.appendChild(innerEl); - for(var ix = 0; ix < length; ix++) { - stringBuilder.push("
"); - if (!disableGutter) - stringBuilder.push("" + /*(ix + lineStart) + */ ""); - textLayer.$renderLine(stringBuilder, ix, true, false); - stringBuilder.push("\n
"); + for (var ix = 0; ix < length; ix++) { + var lineEl = simpleDom.createElement("div"); + lineEl.className = "ace_line"; + + if (!disableGutter) { + var gutterEl = simpleDom.createElement("span"); + gutterEl.className ="ace_gutter ace_gutter-cell"; + gutterEl.unselectable ="on"; + gutterEl.textContent = ""; /*(ix + lineStart) + */ + lineEl.appendChild(gutterEl); + } + textLayer.$renderLine(lineEl, ix, false); + innerEl.appendChild(lineEl); } - // let's prepare the whole html - var html = "
" + - "
" + - stringBuilder.join("") + - "
" + - "
"; - + //console.log(JSON.stringify(outerEl, null, 2)); + //console.log(outerEl.toString()); textLayer.destroy(); return { css: baseStyles + theme.cssText, - html: html, + html: outerEl.toString(), session: session }; }; diff --git a/plugins/node_modules/ace/lib/ace/ext/static_highlight_test.js b/plugins/node_modules/ace/lib/ace/ext/static_highlight_test.js index b091bad7..bbefef41 100644 --- a/plugins/node_modules/ace/lib/ace/ext/static_highlight_test.js +++ b/plugins/node_modules/ace/lib/ace/ext/static_highlight_test.js @@ -35,12 +35,12 @@ module.exports = { var result = highlighter.render(snippet, mode, theme); assert.equal(result.html, "
" - + "
/** this is a function\n
" - + "
*\n
" - + "
*/\n
" - + "
function hello (a, b, c) {\n
" - + "
console.log(a * b + c + 'sup$');\n
" - + "
}\n
" + + "
/** this is a function
" + + "
*
" + + "
*/
" + + "
function hello (a, b, c) {
" + + "
console.log(a * b + c + 'sup$');
" + + "
}
" + "
"); assert.ok(!!result.css); next(); diff --git a/plugins/node_modules/ace/lib/ace/ext/textarea.js b/plugins/node_modules/ace/lib/ace/ext/textarea.js index cced80dc..f74d5be5 100644 --- a/plugins/node_modules/ace/lib/ace/ext/textarea.js +++ b/plugins/node_modules/ace/lib/ace/ext/textarea.js @@ -156,6 +156,7 @@ function setupContainer(element, getValue) { } exports.transformTextarea = function(element, options) { + var isFocused = element.autofocus || document.activeElement == element; var session; var container = setupContainer(element, function() { return session.getValue(); @@ -218,7 +219,8 @@ exports.transformTextarea = function(element, options) { session = editor.getSession(); session.setValue(element.value || element.innerHTML); - editor.focus(); + if (isFocused) + editor.focus(); // Add the settingPanel opener to the editor's div. container.appendChild(settingOpener); diff --git a/plugins/node_modules/ace/lib/ace/ext/themelist.js b/plugins/node_modules/ace/lib/ace/ext/themelist.js index aa8b79d4..beacc552 100644 --- a/plugins/node_modules/ace/lib/ace/ext/themelist.js +++ b/plugins/node_modules/ace/lib/ace/ext/themelist.js @@ -41,7 +41,6 @@ define(function(require, exports, module) { "use strict"; -require("ace/lib/fixoldbrowsers"); var themeData = [ ["Chrome" ], diff --git a/plugins/node_modules/ace/lib/ace/keyboard/vim.js b/plugins/node_modules/ace/lib/ace/keyboard/vim.js index c0a474c8..3ecf0d9f 100644 --- a/plugins/node_modules/ace/lib/ace/keyboard/vim.js +++ b/plugins/node_modules/ace/lib/ace/keyboard/vim.js @@ -715,16 +715,18 @@ dom.importCssString(".normal-mode .ace_cursor{\ .ace_dialog {\ position: absolute;\ left: 0; right: 0;\ - background: inherit;\ + background: white;\ z-index: 15;\ padding: .1em .8em;\ overflow: hidden;\ - color: inherit;\ + color: #333;\ }\ .ace_dialog-top {\ + border-bottom: 1px solid #eee;\ top: 0;\ }\ .ace_dialog-bottom {\ + border-top: 1px solid #eee;\ bottom: 0;\ }\ .ace_dialog input {\ @@ -4456,8 +4458,10 @@ dom.importCssString(".normal-mode .ace_cursor{\ cm.openDialog(template, onClose, { bottom: true, value: options.value, onKeyDown: options.onKeyDown, onKeyUp: options.onKeyUp, selectValueOnOpen: false, onClose: function() { - cm.state.vim.status = ""; - cm.ace.renderer.$loop.schedule(cm.ace.renderer.CHANGE_CURSOR); + if (cm.state.vim) { + cm.state.vim.status = ""; + cm.ace.renderer.$loop.schedule(cm.ace.renderer.CHANGE_CURSOR); + } }}); } else { @@ -6033,7 +6037,7 @@ dom.importCssString(".normal-mode .ace_cursor{\ var name = ''; if (e.ctrlKey) { name += 'C-'; } if (e.altKey) { name += 'A-'; } - if (e.shiftKey) { name += 'S-'; } + if ((name || key.length > 1) && e.shiftKey) { name += 'S-'; } name += key; if (name.length > 1) { name = '<' + name + '>'; } @@ -6108,7 +6112,7 @@ dom.importCssString(".normal-mode .ace_cursor{\ var getVim = Vim.maybeInitVimState_; exports.handler = { $id: "ace/keyboard/vim", - drawCursor: function(style, pixelPos, config, sel, session) { + drawCursor: function(element, pixelPos, config, sel, session) { var vim = this.state.vim || {}; var w = config.characterWidth; var h = config.lineHeight; @@ -6125,10 +6129,9 @@ dom.importCssString(".normal-mode .ace_cursor{\ h = h / 2; top += h; } - style.left = left + "px"; - style.top = top + "px"; - style.width = w + "px"; - style.height = h + "px"; + dom.translate(element, left, top); + dom.setStyle(element.style, "width", w + "px"); + dom.setStyle(element.style, "height", h + "px"); }, handleKeyboard: function(data, hashId, key, keyCode, e) { var editor = data.editor; @@ -6301,25 +6304,6 @@ dom.importCssString(".normal-mode .ace_cursor{\ } } }; - var renderVirtualNumbers = { - getText: function(session, row) { - return (Math.abs(session.selection.lead.row - row) || (row + 1 + (row < 9? "\xb7" : "" ))) + ""; - }, - getWidth: function(session, lastLineNumber, config) { - return session.getLength().toString().length * config.characterWidth; - }, - update: function(e, editor) { - editor.renderer.$loop.schedule(editor.renderer.CHANGE_GUTTER); - }, - attach: function(editor) { - editor.renderer.$gutterLayer.$renderer = this; - editor.on("changeSelection", this.update); - }, - detach: function(editor) { - editor.renderer.$gutterLayer.$renderer = null; - editor.off("changeSelection", this.update); - } - }; Vim.defineOption({ name: "wrap", set: function(value, cm) { diff --git a/plugins/node_modules/ace/lib/ace/keyboard/vim_test.js b/plugins/node_modules/ace/lib/ace/keyboard/vim_test.js index 3a9ead85..c64e17f8 100644 --- a/plugins/node_modules/ace/lib/ace/keyboard/vim_test.js +++ b/plugins/node_modules/ace/lib/ace/keyboard/vim_test.js @@ -1,6 +1,7 @@ if (typeof process !== "undefined") { require("amd-loader"); + require("../test/mockdom"); } define(function(require, exports, module) { diff --git a/plugins/node_modules/ace/lib/ace/layer/cursor.js b/plugins/node_modules/ace/lib/ace/layer/cursor.js index 14edaebb..ccc6d3f7 100644 --- a/plugins/node_modules/ace/lib/ace/layer/cursor.js +++ b/plugins/node_modules/ace/lib/ace/layer/cursor.js @@ -32,16 +32,12 @@ define(function(require, exports, module) { "use strict"; var dom = require("../lib/dom"); -var isIE8; var Cursor = function(parentEl) { this.element = dom.createElement("div"); this.element.className = "ace_layer ace_cursor-layer"; parentEl.appendChild(this.element); - if (isIE8 === undefined) - isIE8 = !("opacity" in this.element.style); - this.isVisible = false; this.isBlinking = true; this.blinkInterval = 1000; @@ -50,24 +46,30 @@ var Cursor = function(parentEl) { this.cursors = []; this.cursor = this.addCursor(); dom.addCssClass(this.element, "ace_hidden-cursors"); - this.$updateCursors = (isIE8 - ? this.$updateVisibility - : this.$updateOpacity).bind(this); + this.$updateCursors = this.$updateOpacity.bind(this); }; (function() { - this.$updateVisibility = function(val) { - var cursors = this.cursors; - for (var i = cursors.length; i--; ) - cursors[i].style.visibility = val ? "" : "hidden"; - }; this.$updateOpacity = function(val) { var cursors = this.cursors; for (var i = cursors.length; i--; ) - cursors[i].style.opacity = val ? "" : "0"; + dom.setStyle(cursors[i].style, "opacity", val ? "" : "0"); + }; + + this.$startCssAnimation = function() { + var cursors = this.cursors; + for (var i = cursors.length; i--; ) + cursors[i].style.animationDuration = this.blinkInterval + "ms"; + + setTimeout(function() { + dom.addCssClass(this.element, "ace_animate-blinking"); + }.bind(this)); }; + this.$stopCssAnimation = function() { + dom.removeCssClass(this.element, "ace_animate-blinking"); + }; this.$padding = 0; this.setPadding = function(padding) { @@ -79,25 +81,24 @@ var Cursor = function(parentEl) { }; this.setBlinking = function(blinking) { - if (blinking != this.isBlinking){ + if (blinking != this.isBlinking) { this.isBlinking = blinking; this.restartTimer(); } }; this.setBlinkInterval = function(blinkInterval) { - if (blinkInterval != this.blinkInterval){ + if (blinkInterval != this.blinkInterval) { this.blinkInterval = blinkInterval; this.restartTimer(); } }; this.setSmoothBlinking = function(smoothBlinking) { - if (smoothBlinking != this.smoothBlinking && !isIE8) { + if (smoothBlinking != this.smoothBlinking) { this.smoothBlinking = smoothBlinking; dom.setCssClass(this.element, "ace_smooth-blinking", smoothBlinking); this.$updateCursors(true); - this.$updateCursors = (this.$updateOpacity).bind(this); this.restartTimer(); } }; @@ -134,14 +135,18 @@ var Cursor = function(parentEl) { var update = this.$updateCursors; clearInterval(this.intervalId); clearTimeout(this.timeoutId); + this.$stopCssAnimation(); + if (this.smoothBlinking) { dom.removeCssClass(this.element, "ace_smooth-blinking"); } update(true); - if (!this.isBlinking || !this.blinkInterval || !this.isVisible) + if (!this.isBlinking || !this.blinkInterval || !this.isVisible) { + this.$stopCssAnimation(); return; + } if (this.smoothBlinking) { setTimeout(function(){ @@ -149,18 +154,21 @@ var Cursor = function(parentEl) { }.bind(this)); } - var blink = function(){ - this.timeoutId = setTimeout(function() { - update(false); - }, 0.6 * this.blinkInterval); - }.bind(this); - - this.intervalId = setInterval(function() { - update(true); + if (dom.HAS_CSS_ANIMATION) { + this.$startCssAnimation(); + } else { + var blink = function(){ + this.timeoutId = setTimeout(function() { + update(false); + }, 0.6 * this.blinkInterval); + }.bind(this); + + this.intervalId = setInterval(function() { + update(true); + blink(); + }, this.blinkInterval); blink(); - }, this.blinkInterval); - - blink(); + } }; this.getPixelPosition = function(position, onScreen) { @@ -180,6 +188,10 @@ var Cursor = function(parentEl) { return {left : cursorLeft, top : cursorTop}; }; + this.isCursorInView = function(pixelPos, config) { + return pixelPos.top >= 0 && pixelPos.top < config.maxHeight; + }; + this.update = function(config) { this.config = config; @@ -197,15 +209,20 @@ var Cursor = function(parentEl) { continue; } - var style = (this.cursors[cursorIndex++] || this.addCursor()).style; + var element = this.cursors[cursorIndex++] || this.addCursor(); + var style = element.style; if (!this.drawCursor) { - style.left = pixelPos.left + "px"; - style.top = pixelPos.top + "px"; - style.width = config.characterWidth + "px"; - style.height = config.lineHeight + "px"; + if (!this.isCursorInView(pixelPos, config)) { + dom.setStyle(style, "display", "none"); + } else { + dom.setStyle(style, "display", "block"); + dom.translate(element, pixelPos.left, pixelPos.top); + dom.setStyle(style, "width", Math.round(config.characterWidth) + "px"); + dom.setStyle(style, "height", config.lineHeight + "px"); + } } else { - this.drawCursor(style, pixelPos, config, selections[i], this.session); + this.drawCursor(element, pixelPos, config, selections[i], this.session); } } while (this.cursors.length > cursorIndex) diff --git a/plugins/node_modules/ace/lib/ace/layer/font_metrics.js b/plugins/node_modules/ace/lib/ace/layer/font_metrics.js index 5f2a81fd..6864108f 100644 --- a/plugins/node_modules/ace/lib/ace/layer/font_metrics.js +++ b/plugins/node_modules/ace/lib/ace/layer/font_metrics.js @@ -33,6 +33,7 @@ define(function(require, exports, module) { var oop = require("../lib/oop"); var dom = require("../lib/dom"); var lang = require("../lib/lang"); +var event = require("../lib/event"); var useragent = require("../lib/useragent"); var EventEmitter = require("../lib/event_emitter").EventEmitter; @@ -117,8 +118,10 @@ var FontMetrics = exports.FontMetrics = function(parentEl) { if (this.$pollSizeChangesTimer || this.$observer) return this.$pollSizeChangesTimer; var self = this; - return this.$pollSizeChangesTimer = setInterval(function() { + + return this.$pollSizeChangesTimer = event.onIdle(function cb() { self.checkForSizeChanges(); + event.onIdle(cb, 500); }, 500); }; diff --git a/plugins/node_modules/ace/lib/ace/layer/gutter.js b/plugins/node_modules/ace/lib/ace/layer/gutter.js index 18fe3358..e4ac8376 100644 --- a/plugins/node_modules/ace/lib/ace/layer/gutter.js +++ b/plugins/node_modules/ace/lib/ace/layer/gutter.js @@ -35,6 +35,7 @@ var dom = require("../lib/dom"); var oop = require("../lib/oop"); var lang = require("../lib/lang"); var EventEmitter = require("../lib/event_emitter").EventEmitter; +var Lines = require("./lines").Lines; var Gutter = function(parentEl) { this.element = dom.createElement("div"); @@ -46,8 +47,8 @@ var Gutter = function(parentEl) { this.$annotations = []; this.$updateAnnotations = this.$updateAnnotations.bind(this); - - this.$cells = []; + + this.$lines = new Lines(this.element); }; (function() { @@ -62,13 +63,13 @@ var Gutter = function(parentEl) { session.on("change", this.$updateAnnotations); }; - this.addGutterDecoration = function(row, className){ + this.addGutterDecoration = function(row, className) { if (window.console) console.warn && console.warn("deprecated use session.addGutterDecoration"); this.session.addGutterDecoration(row, className); }; - this.removeGutterDecoration = function(row, className){ + this.removeGutterDecoration = function(row, className) { if (window.console) console.warn && console.warn("deprecated use session.removeGutterDecoration"); this.session.removeGutterDecoration(row, className); @@ -117,23 +118,28 @@ var Gutter = function(parentEl) { }; this.update = function(config) { + this.config = config; + var session = this.session; var firstRow = config.firstRow; var lastRow = Math.min(config.lastRow + config.gutterOffset, // needed to compensate for hor scollbar session.getLength() - 1); + + this.oldLastRow = lastRow; + this.config = config; + + this.$lines.moveContainer(config); + this.$updateCursorRow(); + var fold = session.getNextFoldLine(firstRow); var foldStart = fold ? fold.start.row : Infinity; - var foldWidgets = this.$showFoldWidgets && session.foldWidgets; - var breakpoints = session.$breakpoints; - var decorations = session.$decorations; - var firstLineNumber = session.$firstLineNumber; - var lastLineNumber = 0; - - var gutterRenderer = session.gutterRenderer || this.$renderer; var cell = null; var index = -1; var row = firstRow; + + var cells = Array.prototype.slice.call(this.element.childNodes, 0); + while (true) { if (row > foldStart) { row = fold.end.row + 1; @@ -141,96 +147,244 @@ var Gutter = function(parentEl) { foldStart = fold ? fold.start.row : Infinity; } if (row > lastRow) { - while (this.$cells.length > index + 1) { - cell = this.$cells.pop(); - this.element.removeChild(cell.element); - } + while (this.$lines.getLength() > index + 1) + this.$lines.pop(); + break; } - cell = this.$cells[++index]; + cell = this.$lines.get(++index); if (!cell) { - cell = {element: null, textNode: null, foldWidget: null}; - cell.element = dom.createElement("div"); - cell.textNode = document.createTextNode(''); - cell.element.appendChild(cell.textNode); - this.element.appendChild(cell.element); - this.$cells[index] = cell; + cell = this.$lines.createCell(row, config, this.session, onCreateCell); + this.$lines.push(cell); } - var className = "ace_gutter-cell "; - if (breakpoints[row]) - className += breakpoints[row]; - if (decorations[row]) - className += decorations[row]; - if (this.$annotations[row]) - className += this.$annotations[row].className; - if (cell.element.className != className) - cell.element.className = className; - - var height = session.getRowLength(row) * config.lineHeight + "px"; - if (height != cell.element.style.height) - cell.element.style.height = height; - - if (foldWidgets) { - var c = foldWidgets[row]; - // check if cached value is invalidated and we need to recompute - if (c == null) - c = foldWidgets[row] = session.getFoldWidget(row); - } - - if (c) { - if (!cell.foldWidget) { - cell.foldWidget = dom.createElement("span"); - cell.element.appendChild(cell.foldWidget); - } - var className = "ace_fold-widget ace_" + c; - if (c == "start" && row == foldStart && row < fold.end.row) - className += " ace_closed"; - else - className += " ace_open"; - if (cell.foldWidget.className != className) - cell.foldWidget.className = className; - - var height = config.lineHeight + "px"; - if (cell.foldWidget.style.height != height) - cell.foldWidget.style.height = height; - } else { - if (cell.foldWidget) { - cell.element.removeChild(cell.foldWidget); - cell.foldWidget = null; - } - } - - var text = lastLineNumber = gutterRenderer - ? gutterRenderer.getText(session, row) - : row + firstLineNumber; - if (text !== cell.textNode.data) - cell.textNode.data = text; - + this.$renderCell(cell, config, fold, row); row++; } + + this._signal("afterRender"); + this.$updateGutterWidth(config); + }; - this.element.style.height = config.minHeight + "px"; - + this.$updateGutterWidth = function(config) { + var session = this.session; + + var gutterRenderer = session.gutterRenderer || this.$renderer; + + var firstLineNumber = session.$firstLineNumber; + var lastLineText = this.$lines.last() ? this.$lines.last().text : ""; + if (this.$fixedWidth || session.$useWrapMode) - lastLineNumber = session.getLength() + firstLineNumber; + lastLineText = session.getLength() + firstLineNumber; var gutterWidth = gutterRenderer - ? gutterRenderer.getWidth(session, lastLineNumber, config) - : lastLineNumber.toString().length * config.characterWidth; + ? gutterRenderer.getWidth(session, lastLineText, config) + : lastLineText.toString().length * config.characterWidth; var padding = this.$padding || this.$computePadding(); gutterWidth += padding.left + padding.right; if (gutterWidth !== this.gutterWidth && !isNaN(gutterWidth)) { this.gutterWidth = gutterWidth; + this.element.parentNode.style.width = this.element.style.width = Math.ceil(this.gutterWidth) + "px"; - this._emit("changeGutterWidth", gutterWidth); + this._signal("changeGutterWidth", gutterWidth); } }; + + this.$updateCursorRow = function() { + if (!this.$highlightGutterLine) + return; + + var position = this.session.selection.getCursor(); + if (this.$cursorRow === position.row) + return; + + this.$cursorRow = position.row; + }; + + this.updateLineHighlight = function() { + if (!this.$highlightGutterLine) + return; + var row = this.session.selection.cursor.row; + this.$cursorRow = row; + + if (this.$cursorCell && this.$cursorCell.row == row) + return; + if (this.$cursorCell) + this.$cursorCell.element.className = this.$cursorCell.element.className.replace("ace_gutter-active-line ", ""); + var cells = this.$lines.cells; + this.$cursorCell = null; + for (var i = 0; i < cells.length; i++) { + var cell = cells[i]; + if (cell.row >= this.$cursorRow) { + if (cell.row > this.$cursorRow) { + var fold = this.session.getFoldLine(this.$cursorRow); + if (i > 0 && fold && fold.start.row == cells[i - 1].row) + cell = cells[i - 1]; + else + break; + } + cell.element.className = "ace_gutter-active-line " + cell.element.className; + this.$cursorCell = cell; + break; + } + } + }; + + this.scrollLines = function(config) { + var oldConfig = this.config; + this.config = config; + + this.$updateCursorRow(); + if (this.$lines.pageChanged(oldConfig, config)) + return this.update(config); + + this.$lines.moveContainer(config); + + var lastRow = Math.min(config.lastRow + config.gutterOffset, // needed to compensate for hor scollbar + this.session.getLength() - 1); + var oldLastRow = this.oldLastRow; + this.oldLastRow = lastRow; + + if (!oldConfig || oldLastRow < config.firstRow) + return this.update(config); + + if (lastRow < oldConfig.firstRow) + return this.update(config); + + if (oldConfig.firstRow < config.firstRow) + for (var row=this.session.getFoldedRowCount(oldConfig.firstRow, config.firstRow - 1); row>0; row--) + this.$lines.shift(); + + if (oldLastRow > lastRow) + for (var row=this.session.getFoldedRowCount(lastRow + 1, oldLastRow); row>0; row--) + this.$lines.pop(); + + if (config.firstRow < oldConfig.firstRow) { + this.$lines.unshift(this.$renderLines(config, config.firstRow, oldConfig.firstRow - 1)); + } + + if (lastRow > oldLastRow) { + this.$lines.push(this.$renderLines(config, oldLastRow + 1, lastRow)); + } + + this.updateLineHighlight(); + + this._signal("afterRender"); + this.$updateGutterWidth(config); + }; + + this.$renderLines = function(config, firstRow, lastRow) { + var fragment = []; + var row = firstRow; + var foldLine = this.session.getNextFoldLine(row); + var foldStart = foldLine ? foldLine.start.row : Infinity; + + while (true) { + if (row > foldStart) { + row = foldLine.end.row+1; + foldLine = this.session.getNextFoldLine(row, foldLine); + foldStart = foldLine ? foldLine.start.row : Infinity; + } + if (row > lastRow) + break; + + var cell = this.$lines.createCell(row, config, this.session, onCreateCell); + this.$renderCell(cell, config, foldLine, row); + fragment.push(cell); + + row++; + } + return fragment; + }; + + this.$renderCell = function(cell, config, fold, row) { + var element = cell.element; + + var session = this.session; + + var textNode = element.childNodes[0]; + var foldWidget = element.childNodes[1]; + + var firstLineNumber = session.$firstLineNumber; + + var breakpoints = session.$breakpoints; + var decorations = session.$decorations; + var gutterRenderer = session.gutterRenderer || this.$renderer; + var foldWidgets = this.$showFoldWidgets && session.foldWidgets; + var foldStart = fold ? fold.start.row : Number.MAX_VALUE; + + var className = "ace_gutter-cell "; + if (this.$highlightGutterLine) { + if (row == this.$cursorRow || (fold && row < this.$cursorRow && row >= foldStart && this.$cursorRow <= fold.end.row)) { + className += "ace_gutter-active-line "; + if (this.$cursorCell != cell) { + if (this.$cursorCell) + this.$cursorCell.element.className = this.$cursorCell.element.className.replace("ace_gutter-active-line ", ""); + this.$cursorCell = cell; + } + } + } + + if (breakpoints[row]) + className += breakpoints[row]; + if (decorations[row]) + className += decorations[row]; + if (this.$annotations[row]) + className += this.$annotations[row].className; + if (element.className != className) + element.className = className; + + if (foldWidgets) { + var c = foldWidgets[row]; + // check if cached value is invalidated and we need to recompute + if (c == null) + c = foldWidgets[row] = session.getFoldWidget(row); + } + + if (c) { + var className = "ace_fold-widget ace_" + c; + if (c == "start" && row == foldStart && row < fold.end.row) + className += " ace_closed"; + else + className += " ace_open"; + if (foldWidget.className != className) + foldWidget.className = className; + + var foldHeight = config.lineHeight + "px"; + dom.setStyle(foldWidget.style, "height", foldHeight); + dom.setStyle(foldWidget.style, "display", "inline-block"); + } else { + if (foldWidget) { + dom.setStyle(foldWidget.style, "display", "none"); + } + } + + var text = (gutterRenderer + ? gutterRenderer.getText(session, row) + : row + firstLineNumber).toString(); + + if (text !== textNode.data) { + textNode.data = text; + } + + dom.setStyle(cell.element.style, "height", this.$lines.computeLineHeight(row, config, session) + "px"); + dom.setStyle(cell.element.style, "top", this.$lines.computeLineTop(row, config, session) + "px"); + + cell.text = text; + cell.row = row; + return cell; + }; this.$fixedWidth = false; + this.$highlightGutterLine = true; + this.$renderer = ""; + this.setHighlightGutterLine = function(highlightGutterLine) { + this.$highlightGutterLine = highlightGutterLine; + }; + this.$showLineNumbers = true; this.$renderer = ""; this.setShowLineNumbers = function(show) { @@ -264,8 +418,10 @@ var Gutter = function(parentEl) { return {left: 0, right: 0}; var style = dom.computedStyle(this.element.firstChild); this.$padding = {}; - this.$padding.left = parseInt(style.paddingLeft) + 1 || 0; - this.$padding.right = parseInt(style.paddingRight) || 0; + this.$padding.left = (parseInt(style.borderLeftWidth) || 0) + + (parseInt(style.paddingLeft) || 0) + 1; + this.$padding.right = (parseInt(style.borderRightWidth) || 0) + + (parseInt(style.paddingRight) || 0); return this.$padding; }; @@ -280,6 +436,16 @@ var Gutter = function(parentEl) { }).call(Gutter.prototype); +function onCreateCell(element) { + var textNode = document.createTextNode(''); + element.appendChild(textNode); + + var foldWidget = dom.createElement("span"); + element.appendChild(foldWidget); + + return element; +} + exports.Gutter = Gutter; }); diff --git a/plugins/node_modules/ace/lib/ace/layer/lines.js b/plugins/node_modules/ace/lib/ace/layer/lines.js new file mode 100644 index 00000000..96936764 --- /dev/null +++ b/plugins/node_modules/ace/lib/ace/layer/lines.js @@ -0,0 +1,154 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2010, Ajax.org B.V. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Ajax.org B.V. nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * ***** END LICENSE BLOCK ***** */ + +define(function(require, exports, module) { +"use strict"; + +var dom = require("../lib/dom"); + +var Lines = function(element, canvasHeight) { + this.element = element; + this.canvasHeight = canvasHeight || 500000; + this.element.style.height = (this.canvasHeight * 2) + "px"; + + this.cells = []; + this.cellCache = []; +}; + +(function() { + + this.moveContainer = function(config) { + dom.translate(this.element, 0, -((config.firstRowScreen * config.lineHeight) % this.canvasHeight)); + }; + + this.pageChanged = function(oldConfig, newConfig) { + return ( + Math.floor((oldConfig.firstRowScreen * oldConfig.lineHeight) / this.canvasHeight) !== + Math.floor((newConfig.firstRowScreen * newConfig.lineHeight) / this.canvasHeight) + ); + }; + + this.computeLineTop = function(row, config, session) { + var screenTop = config.firstRowScreen * config.lineHeight; + var screenPage = Math.floor(screenTop / this.canvasHeight); + var lineTop = session.documentToScreenRow(row, 0) * config.lineHeight; + return lineTop - (screenPage * this.canvasHeight); + }; + + this.computeLineHeight = function(row, config, session) { + return config.lineHeight * session.getRowLength(row); + }; + + this.getLength = function() { + return this.cells.length; + }; + + this.get = function(index) { + return this.cells[index]; + }; + + this.shift = function() { + this.$cacheCell(this.cells.shift()); + }; + + this.pop = function() { + this.$cacheCell(this.cells.pop()); + }; + + this.push = function(cell) { + if (Array.isArray(cell)) { + this.cells.push.apply(this.cells, cell); + var fragment = dom.createFragment(this.element); + for (var i=0; i next, row == end); - - if (this.session.$bidiHandler.isBidiRow(row)) { - this.drawBidiSingleLineMarker(stringBuilder, lineRange, clazzModified, - layerConfig, row == end ? 0 : 1, extraStyle); - } else { - this.drawSingleLineMarker(stringBuilder, lineRange, clazzModified, - layerConfig, row == end ? 0 : 1, extraStyle); - } + this.drawSingleLineMarker(stringBuilder, lineRange, + clazz + (row == start ? " ace_start" : "") + " ace_br" + + getBorderClass(row == start || row == start + 1 && range.start.column, prev < curr, curr > next, row == end), + layerConfig, row == end ? 0 : 1, extraStyle); } }; @@ -142,43 +145,28 @@ var Marker = function(parentEl) { this.drawMultiLineMarker = function(stringBuilder, range, clazz, config, extraStyle) { // from selection start to the end of the line var padding = this.$padding; - var height, top, left; + var height = config.lineHeight; + var top = this.$getTop(range.start.row, config); + var left = padding + range.start.column * config.characterWidth; extraStyle = extraStyle || ""; - if (this.session.$bidiHandler.isBidiRow(range.start.row)) { - var range1 = range.clone(); - range1.end.row = range1.start.row; - range1.end.column = this.session.getLine(range1.start.row).length; - this.drawBidiSingleLineMarker(stringBuilder, range1, clazz + " ace_br1 ace_start", config, null, extraStyle); - } else { - height = config.lineHeight; - top = this.$getTop(range.start.row, config); - left = padding + range.start.column * config.characterWidth; - stringBuilder.push( - "
" - ); - } + + this.elt( + clazz + " ace_br1 ace_start", + "height:"+ height+ "px;"+ "right:0;"+ "top:"+top+ "px;left:"+ left+ "px;" + (extraStyle || "") + ); + // from start of the last line to the selection end - if (this.session.$bidiHandler.isBidiRow(range.end.row)) { - var range1 = range.clone(); - range1.start.row = range1.end.row; - range1.start.column = 0; - this.drawBidiSingleLineMarker(stringBuilder, range1, clazz + " ace_br12", config, null, extraStyle); - } else { - var width = range.end.column * config.characterWidth; - height = config.lineHeight; - top = this.$getTop(range.end.row, config); - stringBuilder.push( - "
" - ); - } + top = this.$getTop(range.end.row, config); + var width = range.end.column * config.characterWidth; + + this.elt( + clazz + " ace_br12", + "height:"+ height+ "px;"+ + "width:"+ width+ "px;"+ + "top:"+ top+ "px;"+ + "left:"+ padding+ "px;"+ (extraStyle || "") + ); + // all the complete lines height = (range.end.row - range.start.row - 1) * config.lineHeight; if (height <= 0) @@ -187,12 +175,12 @@ var Marker = function(parentEl) { var radiusClass = (range.start.column ? 1 : 0) | (range.end.column ? 0 : 8); - stringBuilder.push( - "
" + this.elt( + clazz + (radiusClass ? " ace_br" + radiusClass : ""), + "height:"+ height+ "px;"+ + "right:0;"+ + "top:"+ top+ "px;"+ + "left:"+ padding+ "px;"+ (extraStyle || "") ); }; @@ -204,42 +192,26 @@ var Marker = function(parentEl) { var top = this.$getTop(range.start.row, config); var left = this.$padding + range.start.column * config.characterWidth; - stringBuilder.push( - "
" + this.elt( + clazz, + "height:"+ height+ "px;"+ + "width:"+ width+ "px;"+ + "top:"+ top+ "px;"+ + "left:"+ left+ "px;"+ (extraStyle || "") ); }; - // Draws Bidi marker which covers part or whole width of a single screen line - this.drawBidiSingleLineMarker = function(stringBuilder, range, clazz, config, extraLength, extraStyle) { - var height = config.lineHeight, top = this.$getTop(range.start.row, config), padding = this.$padding; - var selections = this.session.$bidiHandler.getSelections(range.start.column, range.end.column); - - selections.forEach(function(selection) { - stringBuilder.push( - "
" - ); - }); - }; - this.drawFullLineMarker = function(stringBuilder, range, clazz, config, extraStyle) { var top = this.$getTop(range.start.row, config); var height = config.lineHeight; if (range.start.row != range.end.row) height += this.$getTop(range.end.row, config) - top; - stringBuilder.push( - "
" + this.elt( + clazz, + "height:"+ height+ "px;"+ + "top:"+ top+ "px;"+ + "left:0;right:0;"+ (extraStyle || "") ); }; @@ -247,11 +219,11 @@ var Marker = function(parentEl) { var top = this.$getTop(range.start.row, config); var height = config.lineHeight; - stringBuilder.push( - "
" + this.elt( + clazz, + "height:"+ height+ "px;"+ + "top:"+ top+ "px;"+ + "left:0;right:0;"+ (extraStyle || "") ); }; @@ -259,4 +231,4 @@ var Marker = function(parentEl) { exports.Marker = Marker; -}); +}); \ No newline at end of file diff --git a/plugins/node_modules/ace/lib/ace/layer/text.js b/plugins/node_modules/ace/lib/ace/layer/text.js index 675a58ef..13980d0e 100644 --- a/plugins/node_modules/ace/lib/ace/layer/text.js +++ b/plugins/node_modules/ace/lib/ace/layer/text.js @@ -34,14 +34,16 @@ define(function(require, exports, module) { var oop = require("../lib/oop"); var dom = require("../lib/dom"); var lang = require("../lib/lang"); -var useragent = require("../lib/useragent"); +var Lines = require("./lines").Lines; var EventEmitter = require("../lib/event_emitter").EventEmitter; var Text = function(parentEl) { - this.element = dom.createElement("div"); + this.dom = dom; + this.element = this.dom.createElement("div"); this.element.className = "ace_layer ace_text-layer"; parentEl.appendChild(this.element); this.$updateEolChar = this.$updateEolChar.bind(this); + this.$lines = new Lines(this.element); }; (function() { @@ -69,7 +71,7 @@ var Text = function(parentEl) { this.setPadding = function(padding) { this.$padding = padding; - this.element.style.padding = "0 " + padding + "px"; + this.element.style.margin = "0 " + padding + "px"; }; this.getLineHeight = function() { @@ -128,11 +130,12 @@ var Text = function(parentEl) { var tabStr = this.$tabStrings = [0]; for (var i = 1; i < tabSize + 1; i++) { if (this.showInvisibles) { - tabStr.push("" - + lang.stringRepeat(this.TAB_CHAR, i) - + ""); + var span = this.dom.createElement("span"); + span.className = "ace_invisible ace_invisible_tab"; + span.textContent = lang.stringRepeat(this.TAB_CHAR, i); + tabStr.push(span); } else { - tabStr.push(lang.stringRepeat(" ", i)); + tabStr.push(this.dom.createTextNode(lang.stringRepeat(" ", i), this.element)); } } if (this.displayIndentGuides) { @@ -146,13 +149,20 @@ var Text = function(parentEl) { tabClass = " ace_invisible_tab"; var spaceContent = lang.stringRepeat(this.SPACE_CHAR, this.tabSize); var tabContent = lang.stringRepeat(this.TAB_CHAR, this.tabSize); - } else{ + } else { var spaceContent = lang.stringRepeat(" ", this.tabSize); var tabContent = spaceContent; } - this.$tabStrings[" "] = "" + spaceContent + ""; - this.$tabStrings["\t"] = "" + tabContent + ""; + var span = this.dom.createElement("span"); + span.className = className + spaceClass; + span.textContent = spaceContent; + this.$tabStrings[" "] = span; + + var span = this.dom.createElement("span"); + span.className = className + tabClass; + span.textContent = tabContent; + this.$tabStrings["\t"] = span; } }; @@ -161,8 +171,9 @@ var Text = function(parentEl) { // the line to updated wrapped in the meantime. if (this.config.lastRow != config.lastRow || this.config.firstRow != config.firstRow) { - this.scrollLines(config); + return this.update(config); } + this.config = config; var first = Math.max(firstRow, config.firstRow); @@ -184,6 +195,7 @@ var Text = function(parentEl) { lineElementsIdx ++; } + var heightChanged = false; var row = first; var foldLine = this.session.getNextFoldLine(row); var foldStart = foldLine ? foldLine.start.row : Infinity; @@ -199,52 +211,69 @@ var Text = function(parentEl) { var lineElement = lineElements[lineElementsIdx++]; if (lineElement) { - var html = []; + this.dom.removeChildren(lineElement); this.$renderLine( - html, row, !this.$useLineGroups(), row == foldStart ? foldLine : false + lineElement, row, row == foldStart ? foldLine : false ); - lineElement.style.height = config.lineHeight * this.session.getRowLength(row) + "px"; - lineElement.innerHTML = html.join(""); + var height = (config.lineHeight * this.session.getRowLength(row)) + "px"; + if (lineElement.style.height != height) { + heightChanged = true; + lineElement.style.height = height; + } } row++; } + if (heightChanged) { + while (lineElementsIdx < this.$lines.cells.length) { + var cell = this.$lines.cells[lineElementsIdx++]; + cell.element.style.top = this.$lines.computeLineTop(cell.row, config, this.session) + "px"; + } + } }; this.scrollLines = function(config) { var oldConfig = this.config; this.config = config; + if (this.$lines.pageChanged(oldConfig, config)) + return this.update(config); + + this.$lines.moveContainer(config); + + var lastRow = config.lastRow; + var oldLastRow = oldConfig ? oldConfig.lastRow : -1; + + if (!oldConfig || oldLastRow < config.firstRow) + return this.update(config); + + if (lastRow < oldConfig.firstRow) + return this.update(config); + if (!oldConfig || oldConfig.lastRow < config.firstRow) return this.update(config); if (config.lastRow < oldConfig.firstRow) return this.update(config); - var el = this.element; if (oldConfig.firstRow < config.firstRow) for (var row=this.session.getFoldedRowCount(oldConfig.firstRow, config.firstRow - 1); row>0; row--) - el.removeChild(el.firstChild); + this.$lines.shift(); if (oldConfig.lastRow > config.lastRow) for (var row=this.session.getFoldedRowCount(config.lastRow + 1, oldConfig.lastRow); row>0; row--) - el.removeChild(el.lastChild); + this.$lines.pop(); if (config.firstRow < oldConfig.firstRow) { - var fragment = this.$renderLinesFragment(config, config.firstRow, oldConfig.firstRow - 1); - if (el.firstChild) - el.insertBefore(fragment, el.firstChild); - else - el.appendChild(fragment); + this.$lines.unshift(this.$renderLinesFragment(config, config.firstRow, oldConfig.firstRow - 1)); } if (config.lastRow > oldConfig.lastRow) { - var fragment = this.$renderLinesFragment(config, oldConfig.lastRow + 1, config.lastRow); - el.appendChild(fragment); + this.$lines.push(this.$renderLinesFragment(config, oldConfig.lastRow + 1, config.lastRow)); } }; this.$renderLinesFragment = function(config, firstRow, lastRow) { - var fragment = this.element.ownerDocument.createDocumentFragment(); + var fragment = []; var row = firstRow; var foldLine = this.session.getNextFoldLine(row); var foldStart = foldLine ? foldLine.start.row : Infinity; @@ -258,23 +287,23 @@ var Text = function(parentEl) { if (row > lastRow) break; - var container = dom.createElement("div"); + var line = this.$lines.createCell(row, config, this.session); + + var lineEl = line.element; + this.dom.removeChildren(lineEl); + dom.setStyle(lineEl.style, "height", this.$lines.computeLineHeight(row, config, this.session) + "px"); + dom.setStyle(lineEl.style, "top", this.$lines.computeLineTop(row, config, this.session) + "px"); - var html = []; // Get the tokens per line as there might be some lines in between // beeing folded. - this.$renderLine(html, row, false, row == foldStart ? foldLine : false); + this.$renderLine(lineEl, row, row == foldStart ? foldLine : false); - container.innerHTML = html.join(""); if (this.$useLineGroups()) { - container.className = 'ace_line_group'; - fragment.appendChild(container); - container.style.height = config.lineHeight * this.session.getRowLength(row) + "px"; - + lineEl.className = "ace_line_group"; } else { - while(container.firstChild) - fragment.appendChild(container.firstChild); + lineEl.className = "ace_line"; } + fragment.push(line); row++; } @@ -282,35 +311,18 @@ var Text = function(parentEl) { }; this.update = function(config) { + this.$lines.moveContainer(config); + this.config = config; - var html = []; - var firstRow = config.firstRow, lastRow = config.lastRow; + var firstRow = config.firstRow; + var lastRow = config.lastRow; - var row = firstRow; - var foldLine = this.session.getNextFoldLine(row); - var foldStart = foldLine ? foldLine.start.row : Infinity; - - while (true) { - if (row > foldStart) { - row = foldLine.end.row+1; - foldLine = this.session.getNextFoldLine(row, foldLine); - foldStart = foldLine ? foldLine.start.row :Infinity; - } - if (row > lastRow) - break; - - if (this.$useLineGroups()) - html.push("
"); - - this.$renderLine(html, row, false, row == foldStart ? foldLine : false); - - if (this.$useLineGroups()) - html.push("
"); // end the line group - - row++; - } - this.element.innerHTML = html.join(""); + var lines = this.$lines; + while (lines.getLength()) + lines.pop(); + + lines.push(this.$renderLinesFragment(config, firstRow, lastRow)); }; this.$textToken = { @@ -319,110 +331,154 @@ var Text = function(parentEl) { "lparen": true }; - this.$renderToken = function(stringBuilder, screenColumn, token, value) { + this.$renderToken = function(parent, screenColumn, token, value) { var self = this; - var replaceReg = /\t|&|<|>|( +)|([\x00-\x1f\x80-\xa0\xad\u1680\u180E\u2000-\u200f\u2028\u2029\u202F\u205F\u3000\uFEFF\uFFF9-\uFFFC])|[\u1100-\u115F\u11A3-\u11A7\u11FA-\u11FF\u2329-\u232A\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u2FFB\u3000-\u303E\u3041-\u3096\u3099-\u30FF\u3105-\u312D\u3131-\u318E\u3190-\u31BA\u31C0-\u31E3\u31F0-\u321E\u3220-\u3247\u3250-\u32FE\u3300-\u4DBF\u4E00-\uA48C\uA490-\uA4C6\uA960-\uA97C\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFAFF\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE66\uFE68-\uFE6B\uFF01-\uFF60\uFFE0-\uFFE6]|[\uD800-\uDBFF][\uDC00-\uDFFF]/g; - var replaceFunc = function(c, a, b, tabIdx, idx4) { - if (a) { - return self.showInvisibles - ? "" + lang.stringRepeat(self.SPACE_CHAR, c.length) + "" - : c; - } else if (c == "&") { - return "&"; - } else if (c == "<") { - return "<"; - } else if (c == ">") { - // normally escaping this is not needed, but xml documents throw error when setting innerHTML to ]]> - return ">"; - } else if (c == "\t") { - var tabSize = self.session.getScreenTabSize(screenColumn + tabIdx); + var re = /(\t)|( +)|([\x00-\x1f\x80-\xa0\xad\u1680\u180E\u2000-\u200f\u2028\u2029\u202F\u205F\uFEFF\uFFF9-\uFFFC]+)|(\u3000)|([\u1100-\u115F\u11A3-\u11A7\u11FA-\u11FF\u2329-\u232A\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u2FFB\u3001-\u303E\u3041-\u3096\u3099-\u30FF\u3105-\u312D\u3131-\u318E\u3190-\u31BA\u31C0-\u31E3\u31F0-\u321E\u3220-\u3247\u3250-\u32FE\u3300-\u4DBF\u4E00-\uA48C\uA490-\uA4C6\uA960-\uA97C\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFAFF\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE66\uFE68-\uFE6B\uFF01-\uFF60\uFFE0-\uFFE6]|[\uD800-\uDBFF][\uDC00-\uDFFF])/g; + + var valueFragment = this.dom.createFragment(this.element); + + var m; + var i = 0; + while (m = re.exec(value)) { + var tab = m[1]; + var simpleSpace = m[2]; + var controlCharacter = m[3]; + var cjkSpace = m[4]; + var cjk = m[5]; + + if (!self.showInvisibles && simpleSpace) + continue; + + var before = i != m.index ? value.slice(i, m.index) : ""; + + i = m.index + m[0].length; + + if (before) { + valueFragment.appendChild(this.dom.createTextNode(before, this.element)); + } + + if (tab) { + var tabSize = self.session.getScreenTabSize(screenColumn + m.index); + valueFragment.appendChild(self.$tabStrings[tabSize].cloneNode(true)); screenColumn += tabSize - 1; - return self.$tabStrings[tabSize]; - } else if (c == "\u3000") { + } else if (simpleSpace) { + if (self.showInvisibles) { + var span = this.dom.createElement("span"); + span.className = "ace_invisible ace_invisible_space"; + span.textContent = lang.stringRepeat(self.SPACE_CHAR, simpleSpace.length); + valueFragment.appendChild(span); + } else { + valueFragment.appendChild(this.com.createTextNode(simpleSpace, this.element)); + } + } else if (controlCharacter) { + var span = this.dom.createElement("span"); + span.className = "ace_invisible ace_invisible_space ace_invalid"; + span.textContent = lang.stringRepeat(self.SPACE_CHAR, controlCharacter.length); + valueFragment.appendChild(span); + } else if (cjkSpace) { // U+3000 is both invisible AND full-width, so must be handled uniquely - var classToUse = self.showInvisibles ? "ace_cjk ace_invisible ace_invisible_space" : "ace_cjk"; var space = self.showInvisibles ? self.SPACE_CHAR : ""; screenColumn += 1; - return "" + space + ""; - } else if (b) { - return "" + self.SPACE_CHAR + ""; - } else { + + var span = this.dom.createElement("span"); + span.style.width = (self.config.characterWidth * 2) + "px"; + span.className = self.showInvisibles ? "ace_cjk ace_invisible ace_invisible_space" : "ace_cjk"; + span.textContent = self.showInvisibles ? self.SPACE_CHAR : ""; + valueFragment.appendChild(span); + } else if (cjk) { screenColumn += 1; - return "" + c + ""; + var span = dom.createElement("span"); + span.style.width = (self.config.characterWidth * 2) + "px"; + span.className = "ace_cjk"; + span.textContent = cjk; + valueFragment.appendChild(span); } - }; - - var output = value.replace(replaceReg, replaceFunc); + } + + valueFragment.appendChild(this.dom.createTextNode(i ? value.slice(i) : value, this.element)); if (!this.$textToken[token.type]) { var classes = "ace_" + token.type.replace(/\./g, " ace_"); - var style = ""; + var span = this.dom.createElement("span"); if (token.type == "fold") - style = " style='width:" + (token.value.length * this.config.characterWidth) + "px;' "; - stringBuilder.push("", output, ""); + span.style.width = (token.value.length * this.config.characterWidth) + "px"; + + span.className = classes; + span.appendChild(valueFragment); + + parent.appendChild(span); } else { - stringBuilder.push(output); + parent.appendChild(valueFragment); } + return screenColumn + value.length; }; - this.renderIndentGuide = function(stringBuilder, value, max) { + this.renderIndentGuide = function(parent, value, max) { var cols = value.search(this.$indentGuideRe); if (cols <= 0 || cols >= max) return value; if (value[0] == " ") { cols -= cols % this.tabSize; - stringBuilder.push(lang.stringRepeat(this.$tabStrings[" "], cols/this.tabSize)); + var count = cols/this.tabSize; + for (var i=0; i= splitChars) { screenColumn = this.$renderToken( - stringBuilder, screenColumn, + lineEl, screenColumn, token, value.substring(0, splitChars - chars) ); value = value.substring(splitChars - chars); chars = splitChars; - if (!onlyContents) { - stringBuilder.push("
", - "
" - ); - } + lineEl = this.$createLineElement(); + parent.appendChild(lineEl); - stringBuilder.push(lang.stringRepeat("\xa0", splits.indent)); + lineEl.appendChild(this.dom.createTextNode(lang.stringRepeat("\xa0", splits.indent), this.element)); split ++; screenColumn = 0; @@ -431,40 +487,45 @@ var Text = function(parentEl) { if (value.length != 0) { chars += value.length; screenColumn = this.$renderToken( - stringBuilder, screenColumn, token, value + lineEl, screenColumn, token, value ); } } } }; - this.$renderSimpleLine = function(stringBuilder, tokens) { + this.$renderSimpleLine = function(parent, tokens) { var screenColumn = 0; var token = tokens[0]; var value = token.value; if (this.displayIndentGuides) - value = this.renderIndentGuide(stringBuilder, value); + value = this.renderIndentGuide(parent, value); if (value) - screenColumn = this.$renderToken(stringBuilder, screenColumn, token, value); + screenColumn = this.$renderToken(parent, screenColumn, token, value); for (var i = 1; i < tokens.length; i++) { token = tokens[i]; value = token.value; if (screenColumn + value.length > this.MAX_LINE_LENGTH) - return this.$renderOverflowMessage(stringBuilder, screenColumn, token, value); - screenColumn = this.$renderToken(stringBuilder, screenColumn, token, value); + return this.$renderOverflowMessage(parent, screenColumn, token, value); + screenColumn = this.$renderToken(parent, screenColumn, token, value); } }; - this.$renderOverflowMessage = function(stringBuilder, screenColumn, token, value) { - this.$renderToken(stringBuilder, screenColumn, token, + this.$renderOverflowMessage = function(parent, screenColumn, token, value) { + this.$renderToken(parent, screenColumn, token, value.slice(0, this.MAX_LINE_LENGTH - screenColumn)); - stringBuilder.push( - "<click to see more...>" - ); + + var overflowEl = this.dom.createElement("span"); + overflowEl.className = "ace_inline_button ace_keyword ace_toggle_wrap"; + overflowEl.style.position = "absolute"; + overflowEl.style.right = "0"; + overflowEl.textContent = ""; + + parent.appendChild(overflowEl); }; // row is either first row of foldline or not in fold - this.$renderLine = function(stringBuilder, row, onlyContents, foldLine) { + this.$renderLine = function(parent, row, foldLine) { if (!foldLine && foldLine != false) foldLine = this.session.getFoldLine(row); @@ -473,36 +534,35 @@ var Text = function(parentEl) { else var tokens = this.session.getTokens(row); - - if (!onlyContents) { - stringBuilder.push( - "
" - ); - } - + var lastLineEl = parent; if (tokens.length) { var splits = this.session.getRowSplitData(row); - if (splits && splits.length) - this.$renderWrappedLine(stringBuilder, tokens, splits, onlyContents); - else - this.$renderSimpleLine(stringBuilder, tokens); + if (splits && splits.length) { + this.$renderWrappedLine(parent, tokens, splits); + var lastLineEl = parent.lastChild; + } else { + var lastLineEl = parent; + if (this.$useLineGroups()) { + lastLineEl = this.$createLineElement(); + parent.appendChild(lastLineEl); + } + this.$renderSimpleLine(lastLineEl, tokens); + } + } else if (this.$useLineGroups()) { + lastLineEl = this.$createLineElement(); + parent.appendChild(lastLineEl); } - if (this.showInvisibles) { + if (this.showInvisibles && lastLineEl) { if (foldLine) row = foldLine.end.row; - stringBuilder.push( - "", - row == this.session.getLength() - 1 ? this.EOF_CHAR : this.EOL_CHAR, - "" - ); + var invisibleEl = this.dom.createElement("span"); + invisibleEl.className = "ace_invisible ace_invisible_eol"; + invisibleEl.textContent = row == this.session.getLength() - 1 ? this.EOF_CHAR : this.EOL_CHAR; + + lastLineEl.appendChild(invisibleEl); } - if (!onlyContents) - stringBuilder.push("
"); }; this.$getFoldLineTokens = function(row, foldLine) { diff --git a/plugins/node_modules/ace/lib/ace/layer/text_test.js b/plugins/node_modules/ace/lib/ace/layer/text_test.js index b7dbcc0e..aa944821 100644 --- a/plugins/node_modules/ace/lib/ace/layer/text_test.js +++ b/plugins/node_modules/ace/lib/ace/layer/text_test.js @@ -40,6 +40,7 @@ var assert = require("../test/assertions"); var EditSession = require("../edit_session").EditSession; var TextLayer = require("./text").Text; var JavaScriptMode = require("../mode/javascript").Mode; +var dom = require("../lib/dom"); module.exports = { @@ -60,61 +61,63 @@ module.exports = { this.textLayer.$computeTabString(); // row with hard tabs - var stringBuilder = []; - this.textLayer.$renderLine(stringBuilder, 0); + var parent1 = dom.createElement("div"); + this.textLayer.$renderLine(parent1, 0); // row with soft tabs - var stringBuilder2 = []; - this.textLayer.$renderLine(stringBuilder2, 1); - assert.equal(stringBuilder.join(""), stringBuilder2.join("")); + var parent2 = dom.createElement("div"); + this.textLayer.$renderLine(parent2, 1); + assert.equal(parent1.innerHTML, parent2.innerHTML); }, "test rendering width of ideographic space (U+3000)" : function() { this.session.setValue("\u3000"); - var stringBuilder = []; - this.textLayer.$renderLine(stringBuilder, 0, true); - assert.equal(stringBuilder.join(""), ""); + var parent = dom.createElement("div"); + this.textLayer.$renderLine(parent, 0); + assert.domNode(parent, ["div", {}, ["span", {class: "ace_cjk", style: "width: 20px;"}]]); this.textLayer.setShowInvisibles(true); - var stringBuilder = []; - this.textLayer.$renderLine(stringBuilder, 0, true); - assert.equal( - stringBuilder.join(""), - "" + this.textLayer.SPACE_CHAR + "" - + "\xB6" - ); + var parent = dom.createElement("div"); + this.textLayer.$renderLine(parent, 0); + assert.domNode(parent, ["div", {}, + ["span", {class: "ace_cjk ace_invisible ace_invisible_space", style: "width: 20px;"}, this.textLayer.SPACE_CHAR], + ["span", {class: "ace_invisible ace_invisible_eol"}, "\xB6"] + ]); }, "test rendering of indent guides" : function() { var textLayer = this.textLayer; - var EOL = "" + textLayer.EOL_CHAR + ""; + var EOL = "" + textLayer.EOL_CHAR + ""; var SPACE = function(i) {return Array(i+1).join(" ");}; var DOT = function(i) {return Array(i+1).join(textLayer.SPACE_CHAR);}; var TAB = function(i) {return Array(i+1).join(textLayer.TAB_CHAR);}; function testRender(results) { for (var i = results.length; i--; ) { - var stringBuilder = []; - textLayer.$renderLine(stringBuilder, i, true); - assert.equal(stringBuilder.join(""), results[i]); + var parent = dom.createElement("div"); + textLayer.$renderLine(parent, i); + + assert.equal(parent.innerHTML, results[i]); } } this.session.setValue(" \n\t\tf\n "); testRender([ - "" + SPACE(4) + "" + SPACE(2), - "" + SPACE(4) + "" + SPACE(4) + "f", + "" + SPACE(4) + "" + SPACE(2), + "" + SPACE(4) + "" + SPACE(4) + "f", SPACE(3) ]); + this.textLayer.setShowInvisibles(true); testRender([ - "" + DOT(4) + "" + DOT(2) + "" + EOL, - "" + TAB(4) + "" + TAB(4) + "f" + EOL + "" + DOT(4) + "" + DOT(2) + "" + EOL, + "" + TAB(4) + "" + TAB(4) + "f" + EOL ]); + this.textLayer.setDisplayIndentGuides(false); testRender([ - "" + DOT(6) + "" + EOL, - "" + TAB(4) + "" + TAB(4) + "f" + EOL + "" + DOT(6) + "" + EOL, + "" + TAB(4) + "" + TAB(4) + "f" + EOL ]); } }; diff --git a/plugins/node_modules/ace/lib/ace/lib/dom.js b/plugins/node_modules/ace/lib/ace/lib/dom.js index ae3513ce..ccfda22c 100644 --- a/plugins/node_modules/ace/lib/ace/lib/dom.js +++ b/plugins/node_modules/ace/lib/ace/lib/dom.js @@ -31,6 +31,7 @@ define(function(require, exports, module) { "use strict"; +var useragent = require("./useragent"); var XHTML_NS = "http://www.w3.org/1999/xhtml"; exports.buildDom = function buildDom(arr, parent, refs) { @@ -90,6 +91,20 @@ exports.createElement = function(tag, ns) { document.createElement(tag); }; +exports.removeChildren = function(element) { + element.innerHTML = ""; +}; + +exports.createTextNode = function(textContent, element) { + var doc = element ? element.ownerDocument : document; + return doc.createTextNode(textContent); +}; + +exports.createFragment = function(element) { + var doc = element ? element.ownerDocument : document; + return doc.createDocumentFragment(); +}; + exports.hasCssClass = function(el, name) { var classes = (el.className + "").split(/\s+/g); return classes.indexOf(name) !== -1; @@ -183,6 +198,9 @@ exports.importCssString = function importCssString(cssText, id, container) { root.appendChild(style); }; +exports.importCssStylsheet = function(uri, doc) { + exports.buildDom(["link", {rel: "stylesheet", href: uri}], exports.getDocumentHead(doc)); +}; exports.scrollbarWidth = function(document) { var inner = exports.createElement("ace_inner"); inner.style.width = "100%"; @@ -228,4 +246,44 @@ exports.computedStyle = function(element, style) { return window.getComputedStyle(element, "") || {}; }; +exports.setStyle = function(styles, property, value) { + if (styles[property] !== value) { + //console.log("set style", property, styles[property], value); + styles[property] = value; + } +}; + +exports.HAS_CSS_ANIMATION = false; +if (typeof document !== "undefined") { + var div = document.createElement("div"); + if (typeof div.style.animationName !== "undefined") { + exports.HAS_CSS_ANIMATION = true; + } +} + +exports.HAS_CSS_TRANSFORMS = false; +exports.HI_DPI = useragent.isWin + ? typeof window !== "undefined" && window.devicePixelRatio >= 1.5 + : true; + +if (exports.HI_DPI && typeof document !== "undefined") { + // detect CSS transformation support + var div = document.createElement("div"); + if (div.style.transform !== undefined) + exports.HAS_CSS_TRANSFORMS = true; + div = null; + +} + +if (exports.HAS_CSS_TRANSFORMS) { + exports.translate = function(element, tx, ty) { + element.style.transform = "translate(" + Math.round(tx) + "px, " + Math.round(ty) +"px)"; + }; +} else { + exports.translate = function(element, tx, ty) { + element.style.top = Math.round(ty) + "px"; + element.style.left = Math.round(tx) + "px"; + }; +} + }); diff --git a/plugins/node_modules/ace/lib/ace/lib/event.js b/plugins/node_modules/ace/lib/ace/lib/event.js index fbbf7f7c..2b2d52f5 100644 --- a/plugins/node_modules/ace/lib/ace/lib/event.js +++ b/plugins/node_modules/ace/lib/ace/lib/event.js @@ -364,7 +364,6 @@ exports.addCommandKeyListener = function(el, callback) { } }; function resetPressedKeys() { - // console.log("resetting") pressedKeys = Object.create(null); } @@ -372,18 +371,42 @@ if (typeof window == "object" && window.postMessage && !useragent.isOldIE) { var postMessageId = 1; exports.nextTick = function(callback, win) { win = win || window; - var messageName = "zero-timeout-message-" + postMessageId; - exports.addListener(win, "message", function listener(e) { + var messageName = "zero-timeout-message-" + (postMessageId++); + + var listener = function(e) { if (e.data == messageName) { exports.stopPropagation(e); exports.removeListener(win, "message", listener); callback(); } - }); + }; + + exports.addListener(win, "message", listener); win.postMessage(messageName, "*"); }; } +exports.$idleBlocked = false; +exports.onIdle = function(cb, timeout) { + return setTimeout(function handler() { + if (!exports.$idleBlocked) { + cb(); + } else { + setTimeout(handler, 100); + } + }, timeout); +}; + +exports.$idleBlockId = null; +exports.blockIdle = function(delay) { + if (exports.$idleBlockId) + clearTimeout(exports.$idleBlockId); + + exports.$idleBlocked = true; + exports.$idleBlockId = setTimeout(function() { + exports.$idleBlocked = false; + }, delay || 100); +}; exports.nextFrame = typeof window == "object" && (window.requestAnimationFrame || window.mozRequestAnimationFrame diff --git a/plugins/node_modules/ace/lib/ace/lib/event_emitter.js b/plugins/node_modules/ace/lib/ace/lib/event_emitter.js index 4412e2be..6d5c2f0e 100644 --- a/plugins/node_modules/ace/lib/ace/lib/event_emitter.js +++ b/plugins/node_modules/ace/lib/ace/lib/event_emitter.js @@ -109,7 +109,6 @@ EventEmitter.removeDefaultHandler = function(eventName, callback) { var disabled = handlers._disabled_[eventName]; if (handlers[eventName] == callback) { - var old = handlers[eventName]; if (disabled) this.setDefaultHandler(eventName, disabled.pop()); } else if (disabled) { diff --git a/plugins/node_modules/ace/lib/ace/lib/keys.js b/plugins/node_modules/ace/lib/ace/lib/keys.js index cca7ff24..5e72b779 100644 --- a/plugins/node_modules/ace/lib/ace/lib/keys.js +++ b/plugins/node_modules/ace/lib/ace/lib/keys.js @@ -34,8 +34,6 @@ For more information about SproutCore, visit http://www.sproutcore.com define(function(require, exports, module) { "use strict"; -require("./fixoldbrowsers"); - var oop = require("./oop"); /* diff --git a/plugins/node_modules/ace/lib/ace/mode/java_highlight_rules.js b/plugins/node_modules/ace/lib/ace/mode/java_highlight_rules.js index add43eef..0f28b717 100644 --- a/plugins/node_modules/ace/lib/ace/mode/java_highlight_rules.js +++ b/plugins/node_modules/ace/lib/ace/mode/java_highlight_rules.js @@ -88,6 +88,37 @@ var JavaHighlightRules = function() { }, { token : "constant.language.boolean", regex : "(?:true|false)\\b" + }, { + regex: "(open(?:\\s+))?module(?=\\s*\\w)", + token: "keyword", + next: [{ + regex: "{", + token: "paren.lparen", + next: [{ + regex: "}", + token: "paren.rparen", + next: "start" + }, { + // From Section 3.9 of http://cr.openjdk.java.net/~mr/jigsaw/spec/java-se-9-jls-diffs.pdf + regex: "\\b(requires|transitive|exports|opens|to|uses|provides|with)\\b", + token: "keyword" + }] + }, { + token : "text", + regex : "\\s+" + }, { + token : "identifier", + regex : "\\w+" + }, { + token : "punctuation.operator", + regex : "." + }, { + token : "text", + regex : "\\s+" + }, { + regex: "", // exit if there is anything else + next: "start" + }] }, { token : keywordMapper, // TODO: Unicode escape sequences @@ -118,8 +149,10 @@ var JavaHighlightRules = function() { ] }; + this.embedRules(DocCommentHighlightRules, "doc-", [ DocCommentHighlightRules.getEndRule("start") ]); + this.normalizeRules(); }; oop.inherits(JavaHighlightRules, TextHighlightRules); diff --git a/plugins/node_modules/ace/lib/ace/mode/php_highlight_rules.js b/plugins/node_modules/ace/lib/ace/mode/php_highlight_rules.js index 7bb3e4c2..f79dea03 100644 --- a/plugins/node_modules/ace/lib/ace/mode/php_highlight_rules.js +++ b/plugins/node_modules/ace/lib/ace/mode/php_highlight_rules.js @@ -1002,6 +1002,9 @@ var PhpLangHighlightRules = function() { }, { token : "keyword.operator", regex : "::|!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|!=|!==|<=|>=|=>|<<=|>>=|>>>=|<>|<|>|\\.=|=|!|&&|\\|\\||\\?\\:|\\*=|/=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|instanceof|new|delete|typeof|void)" + }, { + token : "punctuation.operator", + regex : /[,;]/ }, { token : "paren.lparen", regex : "[[({]" diff --git a/plugins/node_modules/ace/lib/ace/mouse/default_handlers.js b/plugins/node_modules/ace/lib/ace/mouse/default_handlers.js index 140cbd50..046a8038 100644 --- a/plugins/node_modules/ace/lib/ace/mouse/default_handlers.js +++ b/plugins/node_modules/ace/lib/ace/mouse/default_handlers.js @@ -31,8 +31,6 @@ define(function(require, exports, module) { "use strict"; -var dom = require("../lib/dom"); -var event = require("../lib/event"); var useragent = require("../lib/useragent"); var DRAG_OFFSET = 0; // pixels diff --git a/plugins/node_modules/ace/lib/ace/mouse/mouse_handler.js b/plugins/node_modules/ace/lib/ace/mouse/mouse_handler.js index a383ba32..439692b5 100644 --- a/plugins/node_modules/ace/lib/ace/mouse/mouse_handler.js +++ b/plugins/node_modules/ace/lib/ace/mouse/mouse_handler.js @@ -216,7 +216,7 @@ var MouseHandler = function(editor) { config.defineOptions(MouseHandler.prototype, "mouseHandler", { scrollSpeed: {initialValue: 2}, - dragDelay: {initialValue: 150}, + dragDelay: {initialValue: (useragent.isMac ? 150 : 0)}, dragEnabled: {initialValue: true}, focusTimeout: {initialValue: 0}, tooltipFollowsMouse: {initialValue: true} diff --git a/plugins/node_modules/ace/lib/ace/mouse/mouse_handler_test.js b/plugins/node_modules/ace/lib/ace/mouse/mouse_handler_test.js index c35b09d5..fff48caf 100644 --- a/plugins/node_modules/ace/lib/ace/mouse/mouse_handler_test.js +++ b/plugins/node_modules/ace/lib/ace/mouse/mouse_handler_test.js @@ -36,8 +36,9 @@ if (typeof process !== "undefined") { define(function(require, exports, module) { "use strict"; +require("../multi_select"); var Editor = require("../editor").Editor; -var MockRenderer = require("../test/mockrenderer").MockRenderer; +var VirtualRenderer = require("../virtual_renderer").VirtualRenderer; var assert = require("../test/assertions"); var MouseEvent = function(type, opts){ var e = document.createEvent("MouseEvents"); @@ -53,20 +54,77 @@ var MouseEvent = function(type, opts){ module.exports = { setUp : function(next) { - this.editor = new Editor(new MockRenderer()); - this.editor.setValue("Juhu kinners!"); + this.editor = new Editor(new VirtualRenderer()); + this.editor.session.setValue("Juhu kinners!"); + this.editor.container.style.position = "absolute"; + this.editor.container.style.height = "500px"; + this.editor.container.style.width = "500px"; + this.editor.container.style.left = "50px"; + this.editor.container.style.top = "10px"; + document.body.appendChild(this.editor.container); next(); }, "test: double tap. issue #956" : function() { // mouse up fired immediately after mouse down + this.editor.resize(true); + var pos = this.editor.renderer.textToScreenCoordinates(0, 1); var target = this.editor.renderer.getMouseEventTarget(); - target.dispatchEvent(MouseEvent("down", {x: 1, y: 1})); - target.dispatchEvent(MouseEvent("up", {x: 1, y: 1})); - target.dispatchEvent(MouseEvent("down", {x: 1, y: 1, detail: 2})); - target.dispatchEvent(MouseEvent("up", {x: 1, y: 1, detail: 2})); + target.dispatchEvent(MouseEvent("down", {x: pos.pageX, y: pos.pageY})); + target.dispatchEvent(MouseEvent("up", {x: pos.pageX, y: pos.pageY})); + target.dispatchEvent(MouseEvent("down", {x: pos.pageX, y: pos.pageY, detail: 2})); + target.dispatchEvent(MouseEvent("up", {x: pos.pageX, y: pos.pageY, detail: 2})); assert.equal(this.editor.getSelectedText(), "Juhu"); + + target.dispatchEvent(MouseEvent("down", {x: pos.pageX, y: pos.pageY})); + target.dispatchEvent(MouseEvent("up", {x: pos.pageX, y: pos.pageY})); + assert.equal(this.editor.getSelectedText(), ""); + }, + "test: multiselect" : function() { + var target = this.editor.renderer.getMouseEventTarget(); + this.editor.session.setValue("xyz\n\nabc efg"); + this.editor.resize(true); + + var pos = this.editor.renderer.textToScreenCoordinates(0, 1); + + target.dispatchEvent(MouseEvent("down", {x: pos.pageX, y: pos.pageY})); + target.dispatchEvent(MouseEvent("up", {x: pos.pageX, y: pos.pageY})); + + pos = this.editor.renderer.textToScreenCoordinates(0, 2); + + target.dispatchEvent(MouseEvent("down", {x: pos.pageX, y: pos.pageY, ctrl: true})); + target.dispatchEvent(MouseEvent("up", {x: pos.pageX, y: pos.pageY})); + + var selection = "Range: [0/2] -> [0/2],Range: [0/1] -> [0/1]"; + assert.equal(this.editor.selection.toJSON() + "", selection); + + pos = this.editor.renderer.textToScreenCoordinates(2, 2); + + target.dispatchEvent(MouseEvent("down", {x: pos.pageX, y: pos.pageY, detail: 2, ctrl: true})); + target.dispatchEvent(MouseEvent("up", {x: pos.pageX, y: pos.pageY, detail: 2, ctrl: true})); + + selection = "Range: [2/0] -> [2/3]," + selection; + assert.equal(this.editor.selection.toJSON() + "", selection); + + var pos = this.editor.renderer.textToScreenCoordinates(0, 1); + + target.dispatchEvent(MouseEvent("down", {x: pos.pageX, y: pos.pageY, ctrl: true})); + target.dispatchEvent(MouseEvent("up", {x: pos.pageX, y: pos.pageY, ctrl: true})); + selection = selection.split(",").slice(0, -1).join(","); + assert.equal(this.editor.selection.toJSON() + "", selection); + + var pos1 = this.editor.renderer.textToScreenCoordinates(0, 2); + var pos2 = this.editor.renderer.textToScreenCoordinates(2, 2); + + target.dispatchEvent(MouseEvent("down", {x: pos1.pageX, y: pos1.pageY, alt: true})); + target.dispatchEvent(MouseEvent("move", {x: pos2.pageX, y: pos2.pageY + 1, alt: true})); + target.dispatchEvent(MouseEvent("up", {x: pos2.pageX, y: pos2.pageY + 1, alt: true})); + assert.equal(this.editor.selection.toJSON() + "", "Range: [2/2] -> [2/2],Range: [1/0] -> [1/0],Range: [0/2] -> [0/2]"); + }, + + tearDown : function() { + document.body.removeChild(this.editor.container); } }; diff --git a/plugins/node_modules/ace/lib/ace/mouse/multi_select_handler.js b/plugins/node_modules/ace/lib/ace/mouse/multi_select_handler.js index 5ec027ec..92ebc575 100644 --- a/plugins/node_modules/ace/lib/ace/mouse/multi_select_handler.js +++ b/plugins/node_modules/ace/lib/ace/mouse/multi_select_handler.js @@ -173,6 +173,7 @@ function onMouseDown(e) { screenCursor = {row: -1, column: -1}; var onMouseSelectionEnd = function(e) { + blockSelect(); clearInterval(timerId); editor.removeSelectionMarkers(rectSel); if (!rectSel.length) diff --git a/plugins/node_modules/ace/lib/ace/multi_select.js b/plugins/node_modules/ace/lib/ace/multi_select.js index a98a0d0a..ea056814 100644 --- a/plugins/node_modules/ace/lib/ace/multi_select.js +++ b/plugins/node_modules/ace/lib/ace/multi_select.js @@ -560,6 +560,8 @@ var Editor = require("./editor").Editor; if (pos.row != anchor.row || this.session.$clipPositionToDocument(pos.row, pos.column).column != anchor.column) this.multiSelect.toSingleRange(this.multiSelect.toOrientedRange()); + else + this.multiSelect.mergeOverlappingRanges(); } }; diff --git a/plugins/node_modules/ace/lib/ace/multi_select_test.js b/plugins/node_modules/ace/lib/ace/multi_select_test.js index b08e160c..75f69ab0 100644 --- a/plugins/node_modules/ace/lib/ace/multi_select_test.js +++ b/plugins/node_modules/ace/lib/ace/multi_select_test.js @@ -275,6 +275,31 @@ module.exports = { doc.markUndoGroup(); editor.execCommand("undo"); assert.equal('l1\nl2\nl3', editor.getValue()); + }, + + "test splitIntoLines": function() { + var session = new EditSession(["l1", "l2", "l3"]); + var selection = session.selection; + editor = new Editor(new MockRenderer(), session); + + var nCursor = 0; + var nSelection = 0; + selection.on("changeCursor", function() { nCursor++; }); + selection.on("changeSelection", function() { nSelection++; }); + + selection.moveTo(0, 0); + selection.selectDown(); + selection.splitIntoLines(); + assert.equal(nCursor, 2); + assert.equal(nSelection, 2); + nCursor = nSelection = 0; + selection.selectAll(); + assert.equal(nCursor, 0); + assert.equal(nSelection, 1); + + selection.splitIntoLines(); + editor.setValue(""); + assert.equal(editor.selection.inMultiSelectMode, false); } }; diff --git a/plugins/node_modules/ace/lib/ace/range_list.js b/plugins/node_modules/ace/lib/ace/range_list.js index 149d6372..5b8f73ce 100644 --- a/plugins/node_modules/ace/lib/ace/range_list.js +++ b/plugins/node_modules/ace/lib/ace/range_list.js @@ -181,46 +181,89 @@ var RangeList = function() { }; this.$onChange = function(delta) { - if (delta.action == "insert"){ - var start = delta.start; - var end = delta.end; - } else { - var end = delta.start; - var start = delta.end; - } + var start = delta.start; + var end = delta.end; var startRow = start.row; var endRow = end.row; - var lineDif = endRow - startRow; - - var colDiff = -start.column + end.column; var ranges = this.ranges; - for (var i = 0, n = ranges.length; i < n; i++) { var r = ranges[i]; - if (r.end.row < startRow) - continue; - if (r.start.row > startRow) + if (r.end.row >= startRow) break; - - if (r.start.row == startRow && r.start.column >= start.column ) { - if (r.start.column == start.column && this.$insertRight) { - // do nothing - } else { - r.start.column += colDiff; - r.start.row += lineDif; + } + + if (delta.action == "insert") { + var lineDif = endRow - startRow; + var colDiff = -start.column + end.column; + for (; i < n; i++) { + var r = ranges[i]; + if (r.start.row > startRow) + break; + + if (r.start.row == startRow && r.start.column >= start.column) { + if (r.start.column == start.column && this.$insertRight) { + // do nothing + } else { + r.start.column += colDiff; + r.start.row += lineDif; + } + } + if (r.end.row == startRow && r.end.column >= start.column) { + if (r.end.column == start.column && this.$insertRight) { + continue; + } + // special handling for the case when two ranges share an edge + if (r.end.column == start.column && colDiff > 0 && i < n - 1) { + if (r.end.column > r.start.column && r.end.column == ranges[i+1].start.column) + r.end.column -= colDiff; + } + r.end.column += colDiff; + r.end.row += lineDif; } } - if (r.end.row == startRow && r.end.column >= start.column) { - if (r.end.column == start.column && this.$insertRight) { - continue; + } else { + var lineDif = startRow - endRow; + var colDiff = start.column - end.column; + for (; i < n; i++) { + var r = ranges[i]; + + if (r.start.row > endRow) + break; + + if (r.end.row < endRow) { + r.end.row = startRow; + r.end.column = start.column; } - // special handling for the case when two ranges share an edge - if (r.end.column == start.column && colDiff > 0 && i < n - 1) { - if (r.end.column > r.start.column && r.end.column == ranges[i+1].start.column) - r.end.column -= colDiff; + + if (r.start.row < endRow || r.start.row == endRow && r.start.column <= end.colum) { + r.start.row = startRow; + r.start.column = start.column; + } + + if (r.end.row == endRow) { + if (r.end.column <= end.column) { + if (lineDif || r.end.column > start.column) { + r.end.column = start.column; + r.end.row = start.row; + } + } + else { + r.end.column += colDiff; + r.end.row += lineDif; + } + } + if (r.start.row == endRow) { + if (r.start.column <= end.column) { + if (lineDif || r.start.column > start.column) { + r.start.column = start.column; + r.start.row = start.row; + } + } + else { + r.start.column += colDiff; + r.start.row += lineDif; + } } - r.end.column += colDiff; - r.end.row += lineDif; } } diff --git a/plugins/node_modules/ace/lib/ace/renderloop.js b/plugins/node_modules/ace/lib/ace/renderloop.js index 6d31bd13..444fe19f 100644 --- a/plugins/node_modules/ace/lib/ace/renderloop.js +++ b/plugins/node_modules/ace/lib/ace/renderloop.js @@ -50,22 +50,23 @@ var RenderLoop = function(onRender, win) { (function() { - this.schedule = function(change) { - //this.onRender(change); - //return; this.changes = this.changes | change; - if (!this.pending && this.changes) { - this.pending = true; + if (this.changes) { var _self = this; - event.nextFrame(function() { - _self.pending = false; - var changes; - while (changes = _self.changes) { + + event.nextFrame(function(ts) { + var changes = _self.changes; + + if (changes) { + event.blockIdle(100); _self.changes = 0; _self.onRender(changes); } - }, this.window); + + if (_self.changes) + _self.schedule(); + }); } }; diff --git a/plugins/node_modules/ace/lib/ace/requirejs/text.js b/plugins/node_modules/ace/lib/ace/requirejs/text.js index 8283c82f..f03c64c8 100644 --- a/plugins/node_modules/ace/lib/ace/requirejs/text.js +++ b/plugins/node_modules/ace/lib/ace/requirejs/text.js @@ -33,17 +33,17 @@ */ (function() { - -var globalRequire = typeof require != "undefined" && require; -if (typeof define !== "function") // running in webpack - return module.exports = function(source) { return source; }; +var globalRequire = typeof require != "undefined" && require; +if (typeof define !== "function" || (!define.amd && typeof XMLHttpRequest == "undefined")) { // running in webpack + return module.exports = globalRequire("./text_loader_webpack"); +} define(function (require, exports, module) { "use strict"; if (globalRequire && globalRequire.nodeRequire) { module.exports = globalRequire.nodeRequire(require.toUrl("./text_build")); } else { - exports.load = function(name, req, onLoad, config) { + exports.load = function(name, req, onLoad, config) { require("../lib/net").get(req.toUrl(name), onLoad); }; } diff --git a/plugins/node_modules/ace/lib/ace/requirejs/text_loader_webpack.js b/plugins/node_modules/ace/lib/ace/requirejs/text_loader_webpack.js new file mode 100644 index 00000000..660281b9 --- /dev/null +++ b/plugins/node_modules/ace/lib/ace/requirejs/text_loader_webpack.js @@ -0,0 +1,45 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2010, Ajax.org B.V. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Ajax.org B.V. nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * ***** END LICENSE BLOCK ***** */ + +/* + * used by r.js during build + */ + +"use strict"; +module.exports = function(source) { + if (this.fs && this.resourcePath) + source = this.fs.readFileSync(this.resourcePath).toString("utf8"); + source = source.replace(/\/\*(?:[^*]|[*](?=[^\/]))+\*\//g, "") + .replace(/^[ \t]+/gm, ""); + var json = JSON.stringify(source) + .replace(/[\u2028\u2029]/g, function(x) { '\\u' + x.charCodeAt(0).toString(16); }); + + return "module.exports = " + json; +}; \ No newline at end of file diff --git a/plugins/node_modules/ace/lib/ace/selection.js b/plugins/node_modules/ace/lib/ace/selection.js index a9dd9251..6be44c7a 100644 --- a/plugins/node_modules/ace/lib/ace/selection.js +++ b/plugins/node_modules/ace/lib/ace/selection.js @@ -211,6 +211,7 @@ var Selection = function(session) { this.$setSelection = function(anchorRow, anchorColumn, cursorRow, cursorColumn) { var wasEmpty = this.$isEmpty; + var wasMultiselect = this.inMultiSelectMode; this.$silent = true; this.$cursorChanged = this.$anchorChanged = false; this.anchor.setPosition(anchorRow, anchorColumn); @@ -219,7 +220,7 @@ var Selection = function(session) { this.$silent = false; if (this.$cursorChanged) this._emit("changeCursor"); - if (this.$cursorChanged || this.$anchorChanged) + if (this.$cursorChanged || this.$anchorChanged || wasEmpty != this.$isEmpty || wasMultiselect) this._emit("changeSelection"); }; diff --git a/plugins/node_modules/ace/lib/ace/selection_test.js b/plugins/node_modules/ace/lib/ace/selection_test.js index 051f8748..492a64d7 100644 --- a/plugins/node_modules/ace/lib/ace/selection_test.js +++ b/plugins/node_modules/ace/lib/ace/selection_test.js @@ -507,6 +507,18 @@ module.exports = { assert.equal(nCursor, 2); assert.equal(nSelection, 3); assert.ok(selection.isEqual(data)); + + selection.moveTo(0, 0); + nCursor = nSelection = 0; + selection.selectAll(); + assert.equal(nCursor, 1); + assert.equal(nSelection, 1); + selection.moveCursorRight(); + selection.clearSelection(); + nCursor = nSelection = 0; + selection.selectAll(); + assert.equal(nCursor, 0); + assert.equal(nSelection, 1); }, "test setRange inside fold": function() { diff --git a/plugins/node_modules/ace/lib/ace/undomanager.js b/plugins/node_modules/ace/lib/ace/undomanager.js index 2091058a..27098928 100644 --- a/plugins/node_modules/ace/lib/ace/undomanager.js +++ b/plugins/node_modules/ace/lib/ace/undomanager.js @@ -277,6 +277,10 @@ var UndoManager = function() { this.isClean = this.isAtBookmark; this.markClean = this.bookmark; + this.$prettyPrint = function(delta) { + if (delta) return stringifyDelta(delta); + return stringifyDelta(this.$undoStack) + "\n---\n" + stringifyDelta(this.$redoStack); + }; }).call(UndoManager.prototype); function rearrangeUndoStack(stack, pos) { @@ -558,20 +562,23 @@ function moveDeltasByOne(redoStack, d) { d = cloneDelta(d); for (var j = redoStack.length; j--;) { var deltaSet = redoStack[j]; - for (var i = deltaSet.length; i-- > 0;) { + for (var i = 0; i < deltaSet.length; i++) { var x = deltaSet[i]; var xformed = xform(x, d); d = xformed[0]; if (xformed.length != 2) { if (xformed[2]) { - redoStack.splice(i + 1, 1, xformed[1], xformed[2]); + deltaSet.splice(i + 1, 1, xformed[1], xformed[2]); i++; } else if (!xformed[1]) { - redoStack.splice(i, 1); + deltaSet.splice(i, 1); i--; } } } + if (!deltaSet.length) { + redoStack.splice(j, 1); + } } return redoStack; } diff --git a/plugins/node_modules/ace/lib/ace/undomanager_test.js b/plugins/node_modules/ace/lib/ace/undomanager_test.js index 4a9c1028..5265ad80 100644 --- a/plugins/node_modules/ace/lib/ace/undomanager_test.js +++ b/plugins/node_modules/ace/lib/ace/undomanager_test.js @@ -44,19 +44,20 @@ var EditSession = require("./edit_session").EditSession; var MockRenderer = require("./test/mockrenderer").MockRenderer; var UndoManager = require("./undomanager").UndoManager; -var editor; - +var editor, session, undoManager; module.exports = { name: "ACE undoManager.js", + setUp: function() { + editor = editor || new Editor(new MockRenderer()); + session = new EditSession(""); + undoManager = new UndoManager(); + session.setUndoManager(undoManager); + editor.setSession(session); + }, "test: reabsing": function() { - var session = new EditSession(""); - var editor = new Editor(new MockRenderer(), session); - var undoManager = new UndoManager(); - session.setUndoManager(undoManager); - session.setValue("012345-012345-012345"); session.insert({row: 0, column: 0}, "xx"); session.markUndoGroup(); @@ -66,9 +67,9 @@ module.exports = { session.markUndoGroup(); editor.undo(); editor.undo(); - var rev = session.getUndoManager().startNewGroup(); + var rev = undoManager.startNewGroup(); session.insert({row: 0, column: 5}, "z\nz"); - session.getUndoManager().markIgnored(rev); + undoManager.markIgnored(rev); // editor.undo() editor.redo(); editor.redo(); @@ -84,11 +85,6 @@ module.exports = { assert.equal(val1, val2); }, "test: conflicting deletes": function() { - var session = new EditSession(""); - var editor = new Editor(new MockRenderer(), session); - var undoManager = new UndoManager(); - session.setUndoManager(undoManager); - session.setValue("012345\nabcdefg\nxyz"); session.remove(new Range(0, 2, 0, 4)); assert.equal(session.getLine(0), "0145"); @@ -101,6 +97,208 @@ module.exports = { assert.equal(session.getLine(0), "05"); editor.undo(); assert.equal(session.getLine(0), "012345"); + }, + "test: several deltas ignored": function() { + session.setValue("012345\nabcdefg\nxyz"); + session.insert({row: 0, column: 5}, "zzzz"); + var rev = undoManager.startNewGroup(); + session.insert({row: 0, column: 5}, "yyyy"); + session.insert({row: 0, column: 5}, "aaaa"); + undoManager.markIgnored(rev, undoManager.getRevision() + 1); + editor.undo(); + assert.equal(editor.getValue(), "01234aaaayyyy5\nabcdefg\nxyz"); + }, + "test: canUndo/canRedo and bookmarks": function() { + session.setValue("012345\nabcdefg\nxyz"); + assert.ok(undoManager.isAtBookmark()); + editor.execCommand("removewordright"); + assert.ok(!undoManager.isAtBookmark()); + var rev = undoManager.getRevision(); + undoManager.bookmark(); + assert.ok(undoManager.isAtBookmark()); + editor.undo(); + assert.ok(!undoManager.isAtBookmark()); + undoManager.bookmark(rev); + assert.ok(!undoManager.canUndo()); + assert.ok(undoManager.canRedo()); + editor.redo(); + assert.ok(undoManager.isAtBookmark()); + + session.insert({row: 0, column: 5}, "yyyy"); + assert.ok(undoManager.canUndo()); + assert.ok(!undoManager.canRedo()); + }, + "test: getRevision": function () { + session.setValue("012345\nabcdefg\nxyz"); + session.insert({row: 0, column: 5}, "yyyy"); + var rev = undoManager.getRevision(); + assert.equal(rev, 2); + editor.undo(); + rev = undoManager.getRevision(); + assert.equal(rev, 0); + }, + "test: swap deltas delete/insert": function () { + session.setValue("012345\nabcdefg\nxyz"); + session.insert({row: 0, column: 5}, "zzzz"); + undoManager.startNewGroup(); + session.insert({row: 0, column: 5}, "yyyy"); + session.remove(new Range(0, 5, 0, 9)); + var rev = undoManager.startNewGroup(); + session.insert({row: 0, column: 5}, "aaaa"); + undoManager.markIgnored(rev); + editor.undo(); + assert.equal(editor.getValue(), "01234aaaazzzz5\nabcdefg\nxyz"); + }, + "test: swap deltas insert/delete": function () { + session.setValue("012345"); + undoManager.startNewGroup(); + session.insert({row: 0, column: 5}, "yyyy"); + var rev = undoManager.startNewGroup(); + session.remove(new Range(0, 5, 0, 9)); + undoManager.markIgnored(rev); + editor.undo(); + assert.equal(editor.getValue(), "01234yyyy5"); + + editor.redo(); + undoManager.startNewGroup(); + session.insert({row: 0, column: 5}, "yyyy"); + var rev1 = undoManager.startNewGroup(); + session.remove(new Range(0, 1, 0, 4)); + undoManager.markIgnored(rev1); + editor.undo(); + assert.equal(editor.getValue(), "045"); + + editor.redo(); + undoManager.startNewGroup(); + session.insert({row: 0, column: 1}, "yyyy"); + var rev2 = undoManager.startNewGroup(); + session.remove(new Range(0, 7, 0, 9)); + undoManager.markIgnored(rev2); + editor.undo(); + assert.equal(editor.getValue(), "04yy5"); + }, + "test: swap deltas insert/insert": function () { + session.setValue("012345"); + undoManager.startNewGroup(); + session.insert({row: 0, column: 1}, "yyyy"); + var rev = undoManager.startNewGroup(); + session.insert({row: 0, column: 2}, "xxxx"); + undoManager.markIgnored(rev); + editor.undo(); + assert.equal(editor.getValue(), "0yyyy12345"); + + }, + "test: swap deltas delete/delete": function () { + session.setValue("012345"); + session.insert({row: 0, column: 5}, "zzzz"); + undoManager.startNewGroup(); + session.insert({row: 0, column: 5}, "yyyy"); + session.remove(new Range(0, 5, 0, 9)); + session.insert({row: 0, column: 5}, "aaaa"); + var rev = undoManager.startNewGroup(); + session.remove(new Range(0, 5, 0, 9)); + undoManager.markIgnored(rev); + editor.undo(); + assert.equal(editor.getValue(), "01234aaaazzzz5"); + + editor.undo(); + assert.equal(editor.getValue(), "01234zzzz5"); + + editor.redo(); + var rev1=undoManager.startNewGroup(); + session.insert({row: 0, column: 1}, "yyyy"); + session.remove(new Range(0, 0, 0, 1)); + undoManager.markIgnored(rev1); + editor.undo(); + assert.equal(editor.getValue(), "yyyy1234zzzz5"); + + undoManager.startNewGroup(); + session.remove(new Range(0, 0, 0, 1)); + var rev2=undoManager.startNewGroup(); + session.remove(new Range(0, 3, 0, 5)); + undoManager.markIgnored(rev2); + editor.undo(); + assert.equal(editor.getValue(), "yyyy34zzzz5"); + + editor.redo(); + undoManager.startNewGroup(); + session.remove(new Range(0, 3, 0, 5)); + var rev3=undoManager.startNewGroup(); + session.remove(new Range(0, 1, 0, 5)); + undoManager.markIgnored(rev3); + editor.undo(); + assert.equal(editor.getValue(), "yyyzzzz5"); + + }, + "test: xform deltas insert/insert": function () { + session.setValue("012345"); + session.insert({row: 0, column: 5}, "zzzz"); + undoManager.startNewGroup(); + session.insert({row: 0, column: 0}, "yyyy"); + editor.undo(); + session.insert({row: 0, column: 5}, "aaaa"); + editor.redo(); + assert.equal(editor.getValue(), "yyyy01234aaaazzzz5"); + }, + "test: xform deltas insert/delete": function () { + session.setValue("012345"); + session.insert({row: 0, column: 5}, "zzzz"); + undoManager.startNewGroup(); + session.insert({row: 0, column: 0}, "yyyy"); + editor.undo(); + session.remove(new Range(0, 0, 0, 1)); + editor.redo(); + assert.equal(editor.getValue(), "yyyy1234zzzz5"); + + session.setValue("012345"); + session.insert({row: 0, column: 5}, "zzzz"); + undoManager.startNewGroup(); + var rev=undoManager.startNewGroup(); + session.insert({row: 0, column: 0}, "yyyy"); + undoManager.markIgnored(rev); + editor.undo(); + session.remove(new Range(0, 0, 0, 1)); + editor.redo(); + assert.equal(editor.getValue(), "yyy01234zzzz5"); + }, + "test: xform deltas delete/insert": function () { + session.setValue("012345"); + session.insert({row: 0, column: 0}, "yyyy"); + undoManager.startNewGroup(); + session.remove(new Range(0, 0, 0, 1)); + editor.undo(); + session.insert({row: 0, column: 5}, "zzzz"); + editor.redo(); + assert.equal(editor.getValue(), "yyy0zzzz12345"); + }, + "test: xform deltas delete/delete": function () { + session.setValue("012345"); + session.insert({row: 0, column: 0}, "yyyy"); + undoManager.startNewGroup(); + session.remove(new Range(0, 3, 0, 4)); + editor.undo(); + session.remove(new Range(0, 4, 0, 5)); + editor.redo(); + assert.equal(editor.getValue(), "yyy12345"); + + session.setValue("012345"); + session.insert({row: 0, column: 0}, "yyyy"); + session.remove(new Range(0, 2, 0, 5)); + assert.equal(editor.getValue(), "yy12345"); + editor.undo(); + assert.equal(editor.getValue(), "012345"); + session.remove(new Range(0, 1, 0, 2)); + editor.redo(); + assert.equal(editor.getValue(), "yy2345"); + + session.setValue("1234abcd ---"); + session.insert({row: 0, column: 0}, "ijkl"); + session.remove(new Range(0, 2, 0, 8)); + editor.undo(); + session.remove(new Range(0, 4, 0, 7)); + editor.redo(); + assert.equal(editor.getValue(), "ijd ---"); + assert.equal(undoManager.$prettyPrint(), '-[abc]0:4=>0:7\t(12)\n+[ijkl]0:0=>0:4\t(13)\n-[kl1234]0:2=>0:8\n---\n'); } }; diff --git a/plugins/node_modules/ace/lib/ace/virtual_renderer.js b/plugins/node_modules/ace/lib/ace/virtual_renderer.js index 87ee6ad3..0d3e2f3d 100644 --- a/plugins/node_modules/ace/lib/ace/virtual_renderer.js +++ b/plugins/node_modules/ace/lib/ace/virtual_renderer.js @@ -34,7 +34,6 @@ define(function(require, exports, module) { var oop = require("./lib/oop"); var dom = require("./lib/dom"); var config = require("./config"); -var useragent = require("./lib/useragent"); var GutterLayer = require("./layer/gutter").Gutter; var MarkerLayer = require("./layer/marker").Marker; var TextLayer = require("./layer/text").Text; @@ -68,6 +67,7 @@ var VirtualRenderer = function(container, theme) { this.container = container || dom.createElement("div"); dom.addCssClass(this.container, "ace_editor"); + if (dom.HI_DPI) dom.addCssClass(this.container, "ace_hidpi"); this.setTheme(theme); @@ -78,6 +78,7 @@ var VirtualRenderer = function(container, theme) { this.scroller = dom.createElement("div"); this.scroller.className = "ace_scroller"; + this.container.appendChild(this.scroller); this.content = dom.createElement("div"); @@ -159,6 +160,15 @@ var VirtualRenderer = function(container, theme) { v: 0, h: 0 }; + + this.margin = { + left: 0, + right: 0, + top: 0, + bottom: 0, + v: 0, + h: 0 + }; this.$loop = new RenderLoop( this.$renderChanges.bind(this), @@ -238,7 +248,7 @@ var VirtualRenderer = function(container, theme) { return; this.$loop.schedule(this.CHANGE_FULL); - // this.session.$setFontMetrics(this.$fontMetrics); + this.session.$setFontMetrics(this.$fontMetrics); this.scrollBarH.scrollLeft = this.scrollBarV.scrollTop = null; this.onChangeNewLineMode = this.onChangeNewLineMode.bind(this); @@ -405,18 +415,20 @@ var VirtualRenderer = function(container, theme) { this.gutterWidth = gutterWidth; - this.scrollBarH.element.style.left = - this.scroller.style.left = gutterWidth + "px"; - size.scrollerWidth = Math.max(0, width - gutterWidth - this.scrollBarV.getWidth()); + dom.setStyle(this.scrollBarH.element.style, "left", gutterWidth + "px"); + dom.setStyle(this.scroller.style, "left", gutterWidth + this.margin.left + "px"); + size.scrollerWidth = Math.max(0, width - gutterWidth - this.scrollBarV.getWidth() - this.margin.h); - this.scrollBarH.element.style.right = - this.scroller.style.right = this.scrollBarV.getWidth() + "px"; - this.scroller.style.bottom = this.scrollBarH.getHeight() + "px"; + var right = this.scrollBarV.getWidth() + "px"; + dom.setStyle(this.scrollBarH.element.style, "right", right); + dom.setStyle(this.scroller.style, "right", right); + dom.setStyle(this.scroller.style, "bottom", this.scrollBarH.getHeight()); // this.scrollBarH.element.style.setWidth(size.scrollerWidth); - if (this.session && this.session.getUseWrapMode() && this.adjustWrapLimit() || force) + if (this.session && this.session.getUseWrapMode() && this.adjustWrapLimit() || force) { changes |= this.CHANGE_FULL; + } } size.$dirty = !width || !height; @@ -427,8 +439,8 @@ var VirtualRenderer = function(container, theme) { return changes; }; - this.onGutterResize = function() { - var gutterWidth = this.$showGutter ? this.$gutter.offsetWidth : 0; + this.onGutterResize = function(width) { + var gutterWidth = this.$showGutter ? width : 0; if (gutterWidth != this.gutterWidth) this.$changes |= this.$updateCachedSize(true, gutterWidth, this.$size.width, this.$size.height); @@ -438,7 +450,6 @@ var VirtualRenderer = function(container, theme) { this.$loop.schedule(this.CHANGE_FULL); } else { this.$computeLayerConfig(); - this.$loop.schedule(this.CHANGE_MARKER); } }; @@ -559,19 +570,6 @@ var VirtualRenderer = function(container, theme) { return this.getOption("highlightGutterLine"); }; - this.$updateGutterLineHighlight = function() { - var pos = this.$cursorLayer.$pixelPos; - var height = this.layerConfig.lineHeight; - if (this.session.getUseWrapMode()) { - var cursor = this.session.selection.getCursor(); - cursor.column = 0; - pos = this.$cursorLayer.getPixelPosition(cursor, true); - height *= this.session.getRowLength(cursor.row); - } - this.$gutterLineHighlight.style.top = pos.top - this.layerConfig.offset + "px"; - this.$gutterLineHighlight.style.height = height + "px"; - }; - this.$updatePrintMargin = function() { if (!this.$showPrintMargin && !this.$printMarginEl) return; @@ -625,9 +623,11 @@ var VirtualRenderer = function(container, theme) { this.$moveTextAreaToCursor = function() { var style = this.textarea.style; if (!this.$keepTextAreaAtCursor) { - style.left = -100 + "px"; + dom.translate(this.textarea, -100, 0); return; } + if (!this.$cursorLayer.$pixelPos) + return; var config = this.layerConfig; var posTop = this.$cursorLayer.$pixelPos.top; var posLeft = this.$cursorLayer.$pixelPos.left; @@ -635,7 +635,7 @@ var VirtualRenderer = function(container, theme) { var h = this.lineHeight; if (posTop < 0 || posTop > config.height - h) { - style.top = style.left = "0"; + dom.translate(this.textarea, 0, 0); return; } @@ -649,11 +649,10 @@ var VirtualRenderer = function(container, theme) { if (posLeft > this.$size.scrollerWidth - w) posLeft = this.$size.scrollerWidth - w; - posLeft += this.gutterWidth; - style.height = h + "px"; - style.width = w + "px"; - style.left = Math.min(posLeft, this.$size.scrollerWidth - w) + "px"; - style.top = Math.min(posTop, this.$size.height - h) + "px"; + posLeft += this.gutterWidth + this.margin.left; + dom.setStyle(style, "height", h + "px"); + dom.setStyle(style, "width", w + "px"); + dom.translate(this.textarea, Math.min(posLeft, this.$size.scrollerWidth - w), Math.min(posTop, this.$size.height - h)); }; /** @@ -725,6 +724,18 @@ var VirtualRenderer = function(container, theme) { this.session.setScrollTop(-sm.top); this.updateFull(); }; + + this.setMargin = function(top, bottom, left, right) { + var sm = this.margin; + sm.top = top|0; + sm.bottom = bottom|0; + sm.right = right|0; + sm.left = left|0; + sm.v = sm.top + sm.bottom; + sm.h = sm.left + sm.right; + this.$updateCachedSize(true, this.gutterWidth, this.$size.width, this.$size.height); + this.updateFull(); + }; /** * Returns whether the horizontal scrollbar is set to be always visible. @@ -836,15 +847,20 @@ var VirtualRenderer = function(container, theme) { this.$updateScrollBarV(); if (changes & this.CHANGE_H_SCROLL) this.$updateScrollBarH(); - this.$gutterLayer.element.style.marginTop = (-config.offset) + "px"; - this.content.style.marginTop = (-config.offset) + "px"; - this.content.style.width = config.width + 2 * this.$padding + "px"; - this.content.style.height = config.minHeight + "px"; + + dom.translate(this.$gutter, this.margin.left, -config.offset); + dom.translate(this.content, -this.scrollLeft, -config.offset); + + var width = config.width + 2 * this.$padding + "px"; + var height = config.minHeight + "px"; + + dom.setStyle(this.content.style, "width", width); + dom.setStyle(this.content.style, "height", height); } // horizontal scrolling if (changes & this.CHANGE_H_SCROLL) { - this.content.style.marginLeft = -this.scrollLeft + "px"; + dom.translate(this.content, -this.scrollLeft, -config.offset); this.scroller.className = this.scrollLeft <= 0 ? "ace_scroller" : "ace_scroller ace_scroll-left"; } @@ -857,7 +873,6 @@ var VirtualRenderer = function(container, theme) { this.$markerFront.update(config); this.$cursorLayer.update(config); this.$moveTextAreaToCursor(); - this.$highlightGutterLine && this.$updateGutterLineHighlight(); this._signal("afterRender"); return; } @@ -869,12 +884,15 @@ var VirtualRenderer = function(container, theme) { else this.$textLayer.scrollLines(config); - if (this.$showGutter) - this.$gutterLayer.update(config); + if (this.$showGutter) { + if (changes & this.CHANGE_GUTTER || changes & this.CHANGE_LINES) + this.$gutterLayer.update(config); + else + this.$gutterLayer.scrollLines(config); + } this.$markerBack.update(config); this.$markerFront.update(config); this.$cursorLayer.update(config); - this.$highlightGutterLine && this.$updateGutterLineHighlight(); this.$moveTextAreaToCursor(); this._signal("afterRender"); return; @@ -893,11 +911,14 @@ var VirtualRenderer = function(container, theme) { if (this.$showGutter) this.$gutterLayer.update(config); } + else if (changes & this.CHANGE_CURSOR) { + if (this.$highlightGutterLine) + this.$gutterLayer.updateLineHighlight(config); + } if (changes & this.CHANGE_CURSOR) { this.$cursorLayer.update(config); this.$moveTextAreaToCursor(); - this.$highlightGutterLine && this.$updateGutterLineHighlight(); } if (changes & (this.CHANGE_MARKER | this.CHANGE_MARKER_FRONT)) { @@ -922,7 +943,9 @@ var VirtualRenderer = function(container, theme) { desiredHeight += this.scrollBarH.getHeight(); if (this.$maxPixelHeight && desiredHeight > this.$maxPixelHeight) desiredHeight = this.$maxPixelHeight; - var vScroll = height > maxHeight; + + var hideScrollbars = desiredHeight <= 2 * this.lineHeight; + var vScroll = !hideScrollbars && height > maxHeight; if (desiredHeight != this.desiredHeight || this.$size.height != this.desiredHeight || vScroll != this.$vScroll) { @@ -1413,7 +1436,7 @@ var VirtualRenderer = function(container, theme) { if (this.$hasCssTransforms) { canvasPos = {top:0, left: 0}; var p = this.$fontMetrics.transformCoordinates([x, y]); - x = p[1] - this.gutterWidth; + x = p[1] - this.gutterWidth - this.margin.left; y = p[0]; } else { canvasPos = this.scroller.getBoundingClientRect(); @@ -1432,7 +1455,7 @@ var VirtualRenderer = function(container, theme) { if (this.$hasCssTransforms) { canvasPos = {top:0, left: 0}; var p = this.$fontMetrics.transformCoordinates([x, y]); - x = p[1] - this.gutterWidth; + x = p[1] - this.gutterWidth - this.margin.left; y = p[0]; } else { canvasPos = this.scroller.getBoundingClientRect(); @@ -1442,7 +1465,7 @@ var VirtualRenderer = function(container, theme) { var offset = offsetX / this.characterWidth; var col = this.$blockCursor ? Math.floor(offset) : Math.round(offset); - var row = (y + this.scrollTop - canvasPos.top) / this.lineHeight; + var row = Math.floor((y + this.scrollTop - canvasPos.top) / this.lineHeight); return this.session.screenToDocumentPosition(row, Math.max(col, 0), offsetX); }; @@ -1615,8 +1638,7 @@ var VirtualRenderer = function(container, theme) { }; this.setCursorStyle = function(style) { - if (this.scroller.style.cursor != style) - this.scroller.style.cursor = style; + dom.setStyle(this.scroller.style, "cursor", style); }; /** @@ -1624,7 +1646,7 @@ var VirtualRenderer = function(container, theme) { * **/ this.setMouseCursor = function(cursorStyle) { - this.scroller.style.cursor = cursorStyle; + dom.setStyle(this.scroller.style, "cursor", cursorStyle); }; this.attachToShadowRoot = function() { @@ -1685,12 +1707,8 @@ config.defineOptions(VirtualRenderer.prototype, "renderer", { initialValue: false }, showFoldWidgets: { - set: function(show) {this.$gutterLayer.setShowFoldWidgets(show);}, - initialValue: true - }, - showLineNumbers: { set: function(show) { - this.$gutterLayer.setShowLineNumbers(show); + this.$gutterLayer.setShowFoldWidgets(show); this.$loop.schedule(this.CHANGE_GUTTER); }, initialValue: true @@ -1704,20 +1722,10 @@ config.defineOptions(VirtualRenderer.prototype, "renderer", { }, highlightGutterLine: { set: function(shouldHighlight) { - if (!this.$gutterLineHighlight) { - this.$gutterLineHighlight = dom.createElement("div"); - this.$gutterLineHighlight.className = "ace_gutter-active-line"; - this.$gutter.appendChild(this.$gutterLineHighlight); - return; - } - - this.$gutterLineHighlight.style.display = shouldHighlight ? "" : "none"; - // if cursorlayer have never been updated there's nothing on screen to update - if (this.$cursorLayer.$pixelPos) - this.$updateGutterLineHighlight(); + this.$gutterLayer.setHighlightGutterLine(shouldHighlight); + this.$loop.schedule(this.CHANGE_GUTTER); }, - initialValue: false, - value: true + initialValue: true }, hScrollBarAlwaysVisible: { set: function(val) { @@ -1733,7 +1741,7 @@ config.defineOptions(VirtualRenderer.prototype, "renderer", { }, initialValue: false }, - fontSize: { + fontSize: { set: function(size) { if (typeof size == "number") size = size + "px"; diff --git a/plugins/node_modules/ace/lib/ace/virtual_renderer_test.js b/plugins/node_modules/ace/lib/ace/virtual_renderer_test.js index 3bb98685..f58e7bc0 100644 --- a/plugins/node_modules/ace/lib/ace/virtual_renderer_test.js +++ b/plugins/node_modules/ace/lib/ace/virtual_renderer_test.js @@ -43,9 +43,10 @@ var assert = require("./test/assertions"); require("./ext/error_marker"); function setScreenPosition(node, rect) { - node.getBoundingClientRect = function() { - return { left: rect[0], top: rect[1], width: rect[2], height: rect[3] }; - }; + node.style.left = rect[0] + "px"; + node.style.top = rect[1] + "px"; + node.style.width = rect[2] + "px"; + node.style.height = rect[3] + "px"; } var editor = null; @@ -147,8 +148,6 @@ module.exports = { editor.renderer.setScrollMargin(10, 10); editor.setValue("\n\n"); editor.setValue("\n\n\n\n"); - if (editor.container.offsetWidth == undefined) - return done(); // jsdom editor.renderer.once("afterRender", function() { setTimeout(function() { done(); @@ -162,6 +161,11 @@ module.exports = { editor.execCommand(editor.commands.byName.goToNextError); assert.position(editor.getCursorPosition(), 1, 2); assert.ok(editor.session.lineWidgets[1]); + }, + + "test resize": function() { + editor.setValue("Juhu kinners!"); + editor.resize(true); } // change tab size after setDocument (for text layer) diff --git a/plugins/node_modules/architect-build/build_support/mini_require.js b/plugins/node_modules/architect-build/build_support/mini_require.js index 89170db8..a2ca04fa 100644 --- a/plugins/node_modules/architect-build/build_support/mini_require.js +++ b/plugins/node_modules/architect-build/build_support/mini_require.js @@ -379,7 +379,7 @@ require.MODULE_LOAD_URL = MODULE_LOAD_URL; require.toUrl = function(moduleName, ext, skipExt, skipBalancers) { var absRe = /^([\w\+\.\-]+:|\/)/; var index = moduleName.indexOf("!"); - if (index !== -1 || !ext || /^\/|\.js$/.test(moduleName)) + if (index !== -1 || !ext || /^\//.test(moduleName)) ext = ""; var paths = config.paths; @@ -404,7 +404,9 @@ require.toUrl = function(moduleName, ext, skipExt, skipBalancers) { if (skipExt) return testPath; - var url = moduleName + ext; + var url = ext == ".js" && moduleName.slice(-3) == ext + ? moduleName + : moduleName + ext; if (!absRe.test(url)) { if (ext == ".js" && require.config.transform) url = ("~/" + require.config.transform + "/" + url).replace("//", "/"); @@ -414,6 +416,8 @@ require.toUrl = function(moduleName, ext, skipExt, skipBalancers) { var n = Math.abs(hashCode(url)) % config.baseUrlLoadBalancers.length; url = config.baseUrlLoadBalancers[n] + url; } + if (url[0] == "/") + url = host + url; return url; }; @@ -580,6 +584,10 @@ function checkCache() { if (parts[i]) { var del = ideCache.delete(baseUrl + parts[i]); toDelete.push(del); + if (require.config.transform) { + del = ideCache.delete(baseUrl + ("~/" + require.config.transform) + parts[i]); + toDelete.push(del); + } } } }, function(e, t) { @@ -675,9 +683,9 @@ function definePlugin(plugin, p) { /*** plugins ***/ require["vfs!"] = function(module, callback) { var url = require.MODULE_LOAD_URL + "/~node/" + module; - if (define.fetchedUrls[url] & 3) + if (define.fetchedUrls[url] & 4) return false; - define.fetchedUrls[url] |= 3; + define.fetchedUrls[url] |= 4; define("vfs!" + module, [], { srcUrl: url, path: module diff --git a/plugins/node_modules/architect-build/compress.js b/plugins/node_modules/architect-build/compress.js index eb9f80f8..f87b254b 100644 --- a/plugins/node_modules/architect-build/compress.js +++ b/plugins/node_modules/architect-build/compress.js @@ -1,4 +1,5 @@ var UglifyJS = require("uglify-js"); +var transform = require("./transform").transform; var fs = require("fs"); function compress(sources, opts) { @@ -17,9 +18,16 @@ function compress(sources, opts) { if (/"disable compress"/.test(pkg.source)) return literals.push(pkg.source); + var source = pkg.source; + try { + source = transform(source, { mode: "es5" }); + } catch(e) { + logParseError(e, pkg); + throw e; + } // if (pkg.file) console.log("Adding '" + pkg.file + "'."); try { - toplevel = UglifyJS.parse(pkg.source, { + toplevel = UglifyJS.parse(source, { filename: (pkg.file || pkg.id || "").replace(new RegExp("^" + opts.basepath + "/"), ""), //@todo remove prefix toplevel: toplevel }); diff --git a/plugins/node_modules/architect-build/transform.js b/plugins/node_modules/architect-build/transform.js index 9ea58c16..74979551 100644 --- a/plugins/node_modules/architect-build/transform.js +++ b/plugins/node_modules/architect-build/transform.js @@ -5,7 +5,11 @@ var send = require("send"); exports.transform = function(code, options) { if (/^"disable compress"/.test(code)) return code; - + + if (options.amd && moduleDeps.isCJS(code)) { + code = "define(function(require, exports, module) {" + code + "\n})"; + } + if (options.mode == "babel") { var babel = require("babel"); return babel.transform(code, { @@ -18,13 +22,14 @@ exports.transform = function(code, options) { ] }).code; } - else if (options.mode == "ts") { + else if (options.mode == "ts" || options.mode == "es5") { var ts = require("typescript"); return ts.transpileModule(code, { compilerOptions: { downlevelIteration: true, suppressExcessPropertyErrors: true, removeComments: true, + newLine: "lf", module: ts.ModuleKind.CommonJS } }).outputText; @@ -32,18 +37,14 @@ exports.transform = function(code, options) { else if (options.mode == "buble") { return require("buble").transform(code).code; } - else { - if (moduleDeps.isCJS(code)) { - code = "define(function(require, exports, module) {" + code + "\n})"; - } - return code; - } + return code; }; var cache = Object.create(null); exports.sendFile = function(req, res, next) { var path = req.params.path; + var transform = req.params.transform; var filePath = moduleDeps.resolveModulePath(path, req.pathConfig.pathMap); if (!/\.js$/.test(filePath) || /(browserified|\.min|test\d)\.js$/.test(filePath)) { @@ -66,26 +67,31 @@ exports.sendFile = function(req, res, next) { return; } - if (cache[path] && cache[path].etag == etag) - return sendResponce(cache[path].value); + var key = transform + "|" + path; + if (cache[key] && cache[key].etag == etag) + return sendResponse(cache[key].value); res.setHeader("ETag", etag); - cache[path] = null; + cache[key] = null; fs.readFile(filePath, "utf8", function(err, value) { if (err) return next(err); var t = Date.now(); try { - value = exports.transform(value, { path: filePath }); + value = exports.transform(value, { + path: filePath, + mode: transform, + amd: true, + }); } catch (e) { return next(e); } - cache[path] = { value: value, etag: etag }; + cache[key] = { value: value, etag: etag }; var delta = Date.now() - t; res.setHeader('Server-Timing', 'transform=' + delta); - sendResponce(value); + sendResponse(value); }); - function sendResponce(value) { + function sendResponse(value) { res.setHeader('Content-Type', 'application/javascript'); res.setHeader('Cache-Control', 'public, max-age=0'); diff --git a/plugins/node_modules/vfs-local/localfs.js b/plugins/node_modules/vfs-local/localfs.js index e0342b88..fc1fc779 100644 --- a/plugins/node_modules/vfs-local/localfs.js +++ b/plugins/node_modules/vfs-local/localfs.js @@ -14,9 +14,9 @@ var getMime = (function(simpleMime) { return function(path) { var mime = simpleMime(path); if (typeof mime != "string") - return "application/octet-stream" + return "application/octet-stream"; return mime; - } + }; })(require("simple-mime")()); var vm = require("vm"); var exists = fs.exists || require("path").exists; @@ -69,9 +69,16 @@ function logToFile(message){ }); } +var auditLog = function(description, data) { +} + //////////////////////////////////////////////////////////////////////////////// module.exports = function setup(fsOptions) { + var debug = fsOptions.debug || false; + + auditLog = fsOptions.auditLog || auditLog; + var pty; if (fsOptions.nodePath) { process.env.NODE_PATH = fsOptions.nodePath; @@ -80,7 +87,7 @@ module.exports = function setup(fsOptions) { if (!fsOptions.nopty) { // on darwin trying to load binary for a wrong version crashes the process [(fsOptions.nodePath || process.env.HOME + "/.c9/node_modules") + "/pty.js", - "pty.js", "pty.nw.js"].some(function(p) { + "pty.js"].some(function(p) { try { pty = require(p); return true; @@ -510,19 +517,27 @@ module.exports = function setup(fsOptions) { }); } - function getMetadata(path, options, callback){ + function resolveMetaPath(path, options, callback) { if (path.charAt(0) == "~") path = join(process.env.HOME, path.substr(1)); var metaPath = join(WSMETAPATH, path); resolvePath(metaPath, options, function (err, path) { + if (err) return callback(err); + callback(null, path); + }); + } + + function getMetadata(path, options, callback){ + resolveMetaPath(path, options, function (err, path) { if (err) return callback(err); fs.readFile(path, callback); }); } function readfile(path, options, callback) { + auditLog("readfile", path); var meta = {}; var originalPath = path; @@ -535,20 +550,83 @@ module.exports = function setup(fsOptions) { return callback(err); } + var metadata = options.metadata && originalPath.indexOf(WSMETAPATH) == -1; + // Basic file info meta.mime = getMime(path); meta.size = stat.size; - meta.etag = calcEtag(stat); + + calcEtagConsideringMetadata(metadata, function(err, etag) { + if (err) return callback(err); + + meta.etag = etag; + + // ETag support + if ((TESTING || stat.mtime % 1000) && options.etag === meta.etag) { + meta.notModified = true; + fs.close(fd); + return callback(null, meta); + } + + supportRange(meta, function(_, stop) { + if (stop) { + fs.close(fd); + return callback(null, meta); + } + + if (metadata) { + addMetadata(meta); + return; + } + done(); + }); + + }); - // ETag support - if ((TESTING || stat.mtime % 1000) && options.etag === meta.etag) { - meta.notModified = true; - fs.close(fd); - return callback(null, meta); + function calcEtagConsideringMetadata(metadata, callback) { + if (!metadata) { + return callback(null, calcEtag(stat)); + } + + resolveMetaPath(originalPath, options, function (err, path) { + if (err) return callback(null, calcEtag(stat)); + + fs.stat(path, function (err, metaStat) { + if (err) return callback(null, calcEtag(stat)); + + var previousMtime = stat.mtime; + var previousSize = stat.size; + var mtime = stat.mtime < metaStat.mtime ? metaStat.mtime : stat.mtime; + var size = parseInt(stat.size.toString() + metaStat.size.toString()); + stat.mtime = mtime; + stat.size = size; + var etag = calcEtag(stat); + stat.mtime = previousMtime; + stat.size = previousSize; + callback(null, etag); + }); + }); + } + + function addMetadata(meta) { + getMetadata(originalPath, options, function (err, data) { + if (err) return done(); + + try { + meta.metadataSize = data.length; + meta.metadataStringLength = data.toString("utf8").length; + done(data); + } catch (e) { + fs.close(fd); + done(); + } + }); } - // Range support - if (options.hasOwnProperty('range') && !(options.range.etag && options.range.etag !== meta.etag)) { + function supportRange(meta, callback) { + if (!(options.hasOwnProperty('range') && !(options.range.etag && options.range.etag !== meta.etag))) + return callback(null, false); + var range = options.range; var start, end; if (range.hasOwnProperty("start")) { @@ -562,42 +640,21 @@ module.exports = function setup(fsOptions) { } else { meta.rangeNotSatisfiable = "Invalid Range"; - fs.close(fd); - return callback(null, meta); + return callback(null, true); } } if (end < start || start < 0 || end >= stat.size) { meta.rangeNotSatisfiable = "Range out of bounds"; - fs.close(fd); - return callback(null, meta); + return callback(null, true); } options.start = start; options.end = end; meta.size = end - start + 1; meta.partialContent = { start: start, end: end, size: stat.size }; - } - - var metaData; - if (options.hasOwnProperty("metadata") && originalPath.indexOf(WSMETAPATH) == -1) { - getMetadata(originalPath, options, function (err, data) { - if (err) - return done(); - try { - meta.metadataSize = data.length; - meta.metadataStringLength = data.toString("utf8").length; - metaData = data; - done(true); - } catch (e) { - fs.close(fd); - done(); - } - }); - } - else { - done(); + callback(null, false); } - function done(fakeStream){ + function done(metadata){ // HEAD request support if (options.hasOwnProperty("head")) { fs.close(fd); @@ -613,7 +670,7 @@ module.exports = function setup(fsOptions) { return callback(err); } - if (fakeStream) { + if (metadata) { var readStream = meta.stream; meta.stream = new Stream(); meta.stream.readable = true; @@ -627,7 +684,7 @@ module.exports = function setup(fsOptions) { }; readStream.pipe(meta.stream, { end : false }); readStream.on("end", function(){ - meta.stream.write(metaData); + meta.stream.write(metadata); meta.stream.end(); }); meta.stream.destroy = function () { @@ -710,6 +767,7 @@ module.exports = function setup(fsOptions) { // file and then renames to the final destination. // It will copy the properties of the existing file is there is one. function mkfile(path, options, realCallback) { + auditLog("mkfile", path); var meta = {}; var called; var callback = function (err) { @@ -1014,10 +1072,12 @@ module.exports = function setup(fsOptions) { } function rmfile(path, options, callback) { + auditLog("rmfile", path); remove(path, fs.unlink, options, callback); } function rmdir(path, options, callback) { + auditLog("rmdir", path); if (options.recursive) { remove(path, function(path, callback) { spawn("rm", {args: ["-rf", path], stdio: 'ignore'}, function(err, child) { @@ -1039,6 +1099,7 @@ module.exports = function setup(fsOptions) { } function rename(path, options, callback) { + auditLog("rename", path); var from, to; if (options.from) { from = options.from; to = path; @@ -1103,6 +1164,7 @@ module.exports = function setup(fsOptions) { } function copy(path, options, callback) { + auditLog("copy", path); var from, to; if (options.from) { from = options.from; to = path; @@ -1191,6 +1253,7 @@ module.exports = function setup(fsOptions) { } function symlink(path, options, callback) { + auditLog("symlink", path); if (!options.target) return callback(new Error("options.target is required")); var meta = {}; // Get real path to target dir @@ -1523,6 +1586,7 @@ module.exports = function setup(fsOptions) { } function chmod(path, options, callback) { + auditLog("chmod", path); resolvePath(path, options, function(err, path){ if (err) return callback(err); @@ -1540,6 +1604,7 @@ module.exports = function setup(fsOptions) { } function spawn(executablePath, options, callback) { + auditLog("spawn", executablePath); if (waitForEnv) return waitForEnv.push(spawn.bind(null, executablePath, options, callback)); @@ -1559,6 +1624,14 @@ module.exports = function setup(fsOptions) { } catch (err) { return callback(err); } + + if (!child.pid) { + err = new Error("spawn " + executablePath+ " ENOENT"); + err.code = "ENOENT"; + err.errno = "ENOENT"; + return callback(err); + } + if (options.resumeStdin) child.stdin.resume(); if (options.hasOwnProperty('stdoutEncoding')) { child.stdout && child.stdout.setEncoding(options.stdoutEncoding); @@ -1571,7 +1644,7 @@ module.exports = function setup(fsOptions) { child.on("error", function(err) { child.emit("exit", 127); }); - + callback(null, { process: child }); @@ -2306,6 +2379,7 @@ module.exports = function setup(fsOptions) { } function execFile(executablePath, options, callback) { + auditLog("execFile", executablePath); if (waitForEnv) return waitForEnv.push(execFile.bind(null, executablePath, options, callback)); diff --git a/version b/version index 69c472d3..e3b644ef 100644 --- a/version +++ b/version @@ -1 +1 @@ -1523328993 +1524106654