diff --git a/build.js b/build.js index 41dfa4a6..7f64186e 100644 --- a/build.js +++ b/build.js @@ -29,50 +29,60 @@ "ace/document", "ace/undomanager", "ace/virtual_renderer", - + "ace/mode/javascript", "ace/theme/textmate" ], includeRequire: false }, - - { - name: "ace/theme/eclipse", + + { + name: "ace/theme/eclipse", exclude: [ - "ace/lib/lang", - "ace/lib/dom", - "ace/lib/oop" + "pilot/lang", + "pilot/dom", + "pilot/oop" ] }, - { + { name: "ace/mode/xml", exclude: [ - "ace/lib/oop", + "pilot/oop", "ace/tokenizer", - "ace/mode/text" + "ace/mode/text" ] }, - { + { name: "ace/mode/css", exclude: [ - "ace/lib/oop", - "ace/lib/lang", + "pilot/oop", + "pilot/lang", "ace/tokenizer", "ace/range", - "ace/mode/text" + "ace/mode/text" ] }, - { + { name: "ace/mode/html", exclude: [ - "ace/lib/oop", - "ace/lib/lang", + "pilot/oop", + "pilot/lang", "ace/tokenizer", "ace/range", "ace/mode/text", "ace/mode/javascript", "ace/mode/css", ] + }, + { + name: "ace/mode/python", + exclude: [ + "ace/lib/oop", + "ace/lib/lang", + "ace/tokenizer", + "ace/range", + "ace/mode/text" + ] } ] } \ No newline at end of file diff --git a/build/ace/conf/keybindings/default_mac.js b/build/ace/conf/keybindings/default_mac.js index 4903199a..1c61910a 100644 --- a/build/ace/conf/keybindings/default_mac.js +++ b/build/ace/conf/keybindings/default_mac.js @@ -1,5 +1,5 @@ define(function() { return{selectall:"Command-A", removeline:"Command-D", gotoline:"Command-L", togglecomment:"Command-7", findnext:"Command-K", findprevious:"Command-Shift-K", find:"Command-F", replace:"Command-R", undo:"Command-Z", redo:"Command-Shift-Z|Command-Y", overwrite:"Insert", copylinesup:"Command-Option-Up", movelinesup:"Option-Up", selecttostart:"Command-Shift-Up", gotostart:"Command-Home|Command-Up", selectup:"Shift-Up", golineup:"Up", copylinesdown:"Command-Option-Down", movelinesdown:"Option-Down", selecttoend:"Command-Shift-Down", gotoend:"Command-End|Command-Down", selectdown:"Shift-Down", godown:"Down", selectwordleft:"Option-Shift-Left", gotowordleft:"Option-Left", selecttolinestart:"Command-Shift-Left", gotolinestart:"Command-Left|Home", selectleft:"Shift-Left", gotoleft:"Left", selectwordright:"Option-Shift-Right", gotowordright:"Option-Right", selecttolineend:"Command-Shift-Right", gotolineend:"Command-Right|End", selectright:"Shift-Right", gotoright:"Right", selectpagedown:"Shift-PageDown", - pagedown:"PageDown", selectpageup:"Shift-PageUp", pageup:"PageUp", selectlinestart:"Shift-Home", selectlineend:"Shift-End", del:"Delete", backspace:"Backspace", outdent:"Shift-Tab", indent:"Tab"} + pagedown:"PageDown", selectpageup:"Shift-PageUp", pageup:"PageUp", selectlinestart:"Shift-Home", selectlineend:"Shift-End", del:"Delete", backspace:"Ctrl-Backspace|Command-Backspace|Option-Backspace|Backspace", outdent:"Shift-Tab", indent:"Tab"} }); \ No newline at end of file diff --git a/build/ace/conf/keybindings/default_win.js b/build/ace/conf/keybindings/default_win.js index 5e2a5ef5..428c47b0 100644 --- a/build/ace/conf/keybindings/default_win.js +++ b/build/ace/conf/keybindings/default_win.js @@ -1,5 +1,5 @@ define(function() { return{selectall:"Ctrl-A", removeline:"Ctrl-D", gotoline:"Ctrl-L", togglecomment:"Ctrl-7", findnext:"Ctrl-K", findprevious:"Ctrl-Shift-K", find:"Ctrl-F", replace:"Ctrl-R", undo:"Ctrl-Z", redo:"Ctrl-Shift-Z|Ctrl-Y", overwrite:"Insert", copylinesup:"Ctrl-Alt-Up", movelinesup:"Alt-Up", selecttostart:"Alt-Shift-Up", gotostart:"Ctrl-Home|Ctrl-Up", selectup:"Shift-Up", golineup:"Up", copylinesdown:"Ctrl-Alt-Down", movelinesdown:"Alt-Down", selecttoend:"Alt-Shift-Down", gotoend:"Ctrl-End|Ctrl-Down", selectdown:"Shift-Down", - godown:"Down", selectwordleft:"Ctrl-Shift-Left", gotowordleft:"Ctrl-Left", selecttolinestart:"Ctrl-Shift-Left", gotolinestart:"Alt-Left|Home", selectleft:"Shift-Left", gotoleft:"Left", selectwordright:"Ctrl-Shift-Right", gotowordright:"Ctrl-Right", selecttolineend:"Ctrl-Shift-Right", gotolineend:"Alt-Right|End", selectright:"Shift-Right", gotoright:"Right", selectpagedown:"Shift-PageDown", pagedown:"PageDown", selectpageup:"Shift-PageUp", pageup:"PageUp", selectlinestart:"Shift-Home", selectlineend:"Shift-End", + godown:"Down", selectwordleft:"Ctrl-Shift-Left", gotowordleft:"Ctrl-Left", selecttolinestart:"Alt-Shift-Left", gotolinestart:"Alt-Left|Home", selectleft:"Shift-Left", gotoleft:"Left", selectwordright:"Ctrl-Shift-Right", gotowordright:"Ctrl-Right", selecttolineend:"Alt-Shift-Right", gotolineend:"Alt-Right|End", selectright:"Shift-Right", gotoright:"Right", selectpagedown:"Shift-PageDown", pagedown:"PageDown", selectpageup:"Shift-PageUp", pageup:"PageUp", selectlinestart:"Shift-Home", selectlineend:"Shift-End", del:"Delete", backspace:"Backspace", outdent:"Shift-Tab", indent:"Tab"} }); \ No newline at end of file diff --git a/build/ace/document.js b/build/ace/document.js index d3b0effa..681bad90 100644 --- a/build/ace/document.js +++ b/build/ace/document.js @@ -327,7 +327,7 @@ define(function(g) { }this.modified = true; b = a.start.row; var c = a.end.row, d = this.getLine(b).substring(0, a.start.column) + this.getLine(c).substring(a.end.column); - this.lines.splice(b, c - b + 1, d); + d != "" ? this.lines.splice(b, c - b + 1, d) : this.lines.splice(b, c - b + 1, ""); return a.start } }; diff --git a/build/ace/editor.js b/build/ace/editor.js index 55fe732c..731b5f77 100644 --- a/build/ace/editor.js +++ b/build/ace/editor.js @@ -6,105 +6,105 @@ (function() { var h = ["Msxml2.XMLHTTP", "Microsoft.XMLHTTP", "Msxml2.XMLHTTP.4.0"], g = /^\s*<\?xml(\s)+version=[\'\"](\d)*.(\d)*[\'\"](\s)*\?>/im, e = /]*>\s*([\s\S]+)\s*<\/body>/im; if(!require.textStrip) { - require.textStrip = function(d) { - if(d) { - d = d.replace(g, ""); - var i = d.match(e); + require.textStrip = function(c) { + if(c) { + c = c.replace(g, ""); + var i = c.match(e); if(i) { - d = i[1] + c = i[1] } }else { - d = "" - }return d + c = "" + }return c } }if(!require.getXhr) { require.getXhr = function() { - var d, i, c; + var c, i, b; if(typeof XMLHttpRequest !== "undefined") { return new XMLHttpRequest }else { for(i = 0;i < 3;i++) { - c = h[i]; + b = h[i]; try { - d = new ActiveXObject(c) + c = new ActiveXObject(b) }catch(j) { - }if(d) { - h = [c]; + }if(c) { + h = [b]; break } } - }if(!d) { + }if(!c) { throw new Error("require.getXhr(): XMLHttpRequest not available"); - }return d + }return c } }if(!require.fetchText) { - require.fetchText = function(d, i) { - var c = require.getXhr(); - c.open("GET", d, true); - c.onreadystatechange = function() { - c.readyState === 4 && i(c.responseText) + require.fetchText = function(c, i) { + var b = require.getXhr(); + b.open("GET", c, true); + b.onreadystatechange = function() { + b.readyState === 4 && i(b.responseText) }; - c.send(null) + b.send(null) } }require.plugin({prefix:"text", require:function() { - }, newContext:function(d) { - require.mixin(d, {text:{}, textWaiting:[]}) - }, load:function(d, i) { - var c = false, j = null, a, f = d.indexOf("."), m = d.substring(0, f), n = d.substring(f + 1, d.length), b = require.s.contexts[i], k = b.textWaiting; + }, newContext:function(c) { + require.mixin(c, {text:{}, textWaiting:[]}) + }, load:function(c, i) { + var b = false, j = null, a, f = c.indexOf("."), l = c.substring(0, f), n = c.substring(f + 1, c.length), d = require.s.contexts[i], k = d.textWaiting; f = n.indexOf("!"); if(f !== -1) { - c = n.substring(f + 1, n.length); + b = n.substring(f + 1, n.length); n = n.substring(0, f); - f = c.indexOf("!"); - if(f !== -1 && c.substring(0, f) === "strip") { - j = c.substring(f + 1, c.length); - c = "strip" + f = b.indexOf("!"); + if(f !== -1 && b.substring(0, f) === "strip") { + j = b.substring(f + 1, b.length); + b = "strip" }else { - if(c !== "strip") { - j = c; - c = null + if(b !== "strip") { + j = b; + b = null } } - }a = m + "!" + n; - f = c ? a + "!" + c : a; - if(j !== null && !b.text[a]) { - b.defined[d] = b.text[a] = j + }a = l + "!" + n; + f = b ? a + "!" + b : a; + if(j !== null && !d.text[a]) { + d.defined[c] = d.text[a] = j }else { - if(!b.text[a] && !b.textWaiting[a] && !b.textWaiting[f]) { - k[f] || (k[f] = k[k.push({name:d, key:a, fullKey:f, strip:!!c}) - 1]); - i = require.nameToUrl(m, "." + n, i); - b.loaded[d] = false; + if(!d.text[a] && !d.textWaiting[a] && !d.textWaiting[f]) { + k[f] || (k[f] = k[k.push({name:c, key:a, fullKey:f, strip:!!b}) - 1]); + i = require.nameToUrl(l, "." + n, i); + d.loaded[c] = false; require.fetchText(i, function(p) { - b.text[a] = p; - b.loaded[d] = true + d.text[a] = p; + d.loaded[c] = true }) } } }, checkDeps:function() { - }, isWaiting:function(d) { - return!!d.textWaiting.length - }, orderDeps:function(d) { - var i, c, j, a = d.textWaiting; - d.textWaiting = []; - for(i = 0;c = a[i];i++) { - j = d.text[c.key]; - d.defined[c.name] = c.strip ? require.textStrip(j) : j + }, isWaiting:function(c) { + return!!c.textWaiting.length + }, orderDeps:function(c) { + var i, b, j, a = c.textWaiting; + c.textWaiting = []; + for(i = 0;b = a[i];i++) { + j = c.text[b.key]; + c.defined[b.name] = b.strip ? require.textStrip(j) : j } }}) })(); define("ace/lib/oop", ["require", "exports", "module"], function() { var h = {}; h.inherits = function(g, e) { - var d = function() { + var c = function() { }; - d.prototype = e.prototype; + c.prototype = e.prototype; g.super_ = e.prototype; - g.prototype = new d; + g.prototype = new c; g.prototype.constructor = g }; h.mixin = function(g, e) { - for(var d in e) { - g[d] = e[d] + for(var c in e) { + g[c] = e[c] } }; h.implement = function(g, e) { @@ -121,83 +121,83 @@ define("ace/lib/core", ["require", "exports", "module"], function() { h.isGecko = window.controllers && window.navigator.product === "Gecko"; h.provide = function(e) { e = e.split("."); - for(var d = window, i = 0;i < e.length;i++) { - var c = e[i]; - d[c] || (d[c] = {}); - d = d[c] + for(var c = window, i = 0;i < e.length;i++) { + var b = e[i]; + c[b] || (c[b] = {}); + c = c[b] } }; return h }); define("ace/lib/event", ["require", "exports", "module", "./core"], function(h) { var g = h("./core"), e = {}; - e.addListener = function(d, i, c) { - if(d.addEventListener) { - return d.addEventListener(i, c, false) - }if(d.attachEvent) { + e.addListener = function(c, i, b) { + if(c.addEventListener) { + return c.addEventListener(i, b, false) + }if(c.attachEvent) { var j = function() { - c(window.event) + b(window.event) }; - c.$$wrapper = j; - d.attachEvent("on" + i, j) + b.$$wrapper = j; + c.attachEvent("on" + i, j) } }; - e.removeListener = function(d, i, c) { - if(d.removeEventListener) { - return d.removeEventListener(i, c, false) - }if(d.detachEvent) { - d.detachEvent("on" + i, c.$$wrapper || c) + e.removeListener = function(c, i, b) { + if(c.removeEventListener) { + return c.removeEventListener(i, b, false) + }if(c.detachEvent) { + c.detachEvent("on" + i, b.$$wrapper || b) } }; - e.stopEvent = function(d) { - e.stopPropagation(d); - e.preventDefault(d); + e.stopEvent = function(c) { + e.stopPropagation(c); + e.preventDefault(c); return false }; - e.stopPropagation = function(d) { - if(d.stopPropagation) { - d.stopPropagation() + e.stopPropagation = function(c) { + if(c.stopPropagation) { + c.stopPropagation() }else { - d.cancelBubble = true + c.cancelBubble = true } }; - e.preventDefault = function(d) { - if(d.preventDefault) { - d.preventDefault() + e.preventDefault = function(c) { + if(c.preventDefault) { + c.preventDefault() }else { - d.returnValue = false + c.returnValue = false } }; - e.getDocumentX = function(d) { - return d.clientX ? d.clientX + (document.documentElement.scrollLeft || document.body.scrollLeft) : d.pageX + e.getDocumentX = function(c) { + return c.clientX ? c.clientX + (document.documentElement.scrollLeft || document.body.scrollLeft) : c.pageX }; - e.getDocumentY = function(d) { - return d.clientY ? d.clientY + (document.documentElement.scrollTop || document.body.scrollTop) : d.pageX + e.getDocumentY = function(c) { + return c.clientY ? c.clientY + (document.documentElement.scrollTop || document.body.scrollTop) : c.pageX }; - e.getButton = function(d) { - return d.preventDefault ? d.button : Math.max(d.button - 1, 2) + e.getButton = function(c) { + return c.preventDefault ? c.button : Math.max(c.button - 1, 2) }; - e.capture = document.documentElement.setCapture ? function(d, i, c) { + e.capture = document.documentElement.setCapture ? function(c, i, b) { function j(a) { i && i(a); - c && c(); - e.removeListener(d, "mousemove", i); - e.removeListener(d, "mouseup", j); - e.removeListener(d, "losecapture", j); - d.releaseCapture() + b && b(); + e.removeListener(c, "mousemove", i); + e.removeListener(c, "mouseup", j); + e.removeListener(c, "losecapture", j); + c.releaseCapture() } - e.addListener(d, "mousemove", i); - e.addListener(d, "mouseup", j); - e.addListener(d, "losecapture", j); - d.setCapture() - } : function(d, i, c) { + e.addListener(c, "mousemove", i); + e.addListener(c, "mouseup", j); + e.addListener(c, "losecapture", j); + c.setCapture() + } : function(c, i, b) { function j(f) { i(f); f.stopPropagation() } function a(f) { i && i(f); - c && c(); + b && b(); document.removeEventListener("mousemove", j, true); document.removeEventListener("mouseup", a, true); f.stopPropagation() @@ -205,8 +205,8 @@ define("ace/lib/event", ["require", "exports", "module", "./core"], function(h) document.addEventListener("mousemove", j, true); document.addEventListener("mouseup", a, true) }; - e.addMouseWheelListener = function(d, i) { - var c = function(j) { + e.addMouseWheelListener = function(c, i) { + var b = function(j) { if(j.wheelDelta !== undefined) { if(j.wheelDeltaX !== undefined) { j.wheelX = -j.wheelDeltaX / 8; @@ -225,39 +225,39 @@ define("ace/lib/event", ["require", "exports", "module", "./core"], function(h) } }i(j) }; - e.addListener(d, "DOMMouseScroll", c); - e.addListener(d, "mousewheel", c) + e.addListener(c, "DOMMouseScroll", b); + e.addListener(c, "mousewheel", b) }; - e.addMultiMouseDownListener = function(d, i, c, j, a) { - var f = 0, m, n, b = function(k) { + e.addMultiMouseDownListener = function(c, i, b, j, a) { + var f = 0, l, n, d = function(k) { f += 1; if(f == 1) { - m = k.clientX; + l = k.clientX; n = k.clientY; setTimeout(function() { f = 0 }, j || 600) - }if(e.getButton(k) != i || Math.abs(k.clientX - m) > 5 || Math.abs(k.clientY - n) > 5) { + }if(e.getButton(k) != i || Math.abs(k.clientX - l) > 5 || Math.abs(k.clientY - n) > 5) { f = 0 - }if(f == c) { + }if(f == b) { f = 0; a(k) }return e.preventDefault(k) }; - e.addListener(d, "mousedown", b); - g.isIE && e.addListener(d, "dblclick", b) + e.addListener(c, "mousedown", d); + g.isIE && e.addListener(c, "dblclick", d) }; - e.addKeyListener = function(d, i) { - var c = null; - e.addListener(d, "keydown", function(j) { - c = j.keyIdentifier || j.keyCode; + e.addKeyListener = function(c, i) { + var b = null; + e.addListener(c, "keydown", function(j) { + b = j.keyIdentifier || j.keyCode; return i(j) }); - g.isMac && g.isGecko && e.addListener(d, "keypress", function(j) { - if(c !== (j.keyIdentifier || j.keyCode)) { + g.isMac && g.isGecko && e.addListener(c, "keypress", function(j) { + if(b !== (j.keyIdentifier || j.keyCode)) { return i(j) }else { - c = null + b = null } }) }; @@ -274,9 +274,9 @@ define("ace/lib/lang", ["require", "exports", "module"], function() { h.arrayIndexOf = Array.prototype.indexOf ? function(g, e) { return g.indexOf(e) } : function(g, e) { - for(var d = 0;d < g.length;d++) { - if(g[d] == e) { - return d + for(var c = 0;c < g.length;c++) { + if(g[c] == e) { + return c } }return-1 }; @@ -285,13 +285,13 @@ define("ace/lib/lang", ["require", "exports", "module"], function() { }; h.copyObject = function(g) { var e = {}; - for(var d in g) { - e[d] = g[d] + for(var c in g) { + e[c] = g[c] }return e }; h.arrayToMap = function(g) { - for(var e = {}, d = 0;d < g.length;d++) { - e[g[d]] = 1 + for(var e = {}, c = 0;c < g.length;c++) { + e[g[c]] = 1 }return e }; h.escapeRegExp = function(g) { @@ -303,12 +303,12 @@ define("ace/lib/lang", ["require", "exports", "module"], function() { } }; h.deferredCall = function(g) { - var e = null, d = function() { + var e = null, c = function() { e = null; g() }; return{schedule:function() { - e || (e = setTimeout(d, 0)) + e || (e = setTimeout(c, 0)) }, call:function() { h.cancel(); g() @@ -321,91 +321,91 @@ define("ace/lib/lang", ["require", "exports", "module"], function() { }); define("ace/textinput", ["require", "exports", "module", "./lib/event"], function(h) { var g = h("./lib/event"); - return function(e, d) { + return function(e, c) { function i() { - if(!m) { - var k = c.value; + if(!l) { + var k = b.value; if(k) { if(k.charCodeAt(k.length - 1) == a.charCodeAt(0)) { - (k = k.slice(0, -1)) && d.onTextInput(k) + (k = k.slice(0, -1)) && c.onTextInput(k) }else { - d.onTextInput(k) + c.onTextInput(k) } } - }m = false; - c.value = a; - c.select() + }l = false; + b.value = a; + b.select() } - var c = document.createElement("textarea"), j = c.style; + var b = document.createElement("textarea"), j = b.style; j.position = "absolute"; j.left = "-10000px"; j.top = "-10000px"; - e.appendChild(c); + e.appendChild(b); var a = String.fromCharCode(0); i(); - var f = false, m = false, n = function() { + var f = false, l = false, n = function() { setTimeout(function() { f || i() }, 0) - }, b = function() { - d.onCompositionUpdate(c.value) + }, d = function() { + c.onCompositionUpdate(b.value) }; - g.addListener(c, "keypress", n); - g.addListener(c, "textInput", n); - g.addListener(c, "paste", n); - g.addListener(c, "propertychange", n); - g.addListener(c, "copy", function() { - m = true; - c.value = d.getCopyText(); - c.select(); - m = true; + g.addListener(b, "keypress", n); + g.addListener(b, "textInput", n); + g.addListener(b, "paste", n); + g.addListener(b, "propertychange", n); + g.addListener(b, "copy", function() { + l = true; + b.value = c.getCopyText(); + b.select(); + l = true; setTimeout(i, 0) }); - g.addListener(c, "cut", function() { - m = true; - c.value = d.getCopyText(); - d.onCut(); - c.select(); + g.addListener(b, "cut", function() { + l = true; + b.value = c.getCopyText(); + c.onCut(); + b.select(); setTimeout(i, 0) }); - g.addListener(c, "compositionstart", function() { + g.addListener(b, "compositionstart", function() { f = true; i(); - c.value = ""; - d.onCompositionStart(); - setTimeout(b, 0) + b.value = ""; + c.onCompositionStart(); + setTimeout(d, 0) }); - g.addListener(c, "compositionupdate", b); - g.addListener(c, "compositionend", function() { + g.addListener(b, "compositionupdate", d); + g.addListener(b, "compositionend", function() { f = false; - d.onCompositionEnd(); + c.onCompositionEnd(); n() }); - g.addListener(c, "blur", function() { - d.onBlur() + g.addListener(b, "blur", function() { + c.onBlur() }); - g.addListener(c, "focus", function() { - d.onFocus(); - c.select() + g.addListener(b, "focus", function() { + c.onFocus(); + b.select() }); this.focus = function() { - d.onFocus(); - c.select(); - c.focus() + c.onFocus(); + b.select(); + b.focus() }; this.blur = function() { - c.blur() + b.blur() } } }); define("ace/conf/keybindings/default_mac", ["require", "exports", "module"], function() { return{selectall:"Command-A", removeline:"Command-D", gotoline:"Command-L", togglecomment:"Command-7", findnext:"Command-K", findprevious:"Command-Shift-K", find:"Command-F", replace:"Command-R", undo:"Command-Z", redo:"Command-Shift-Z|Command-Y", overwrite:"Insert", copylinesup:"Command-Option-Up", movelinesup:"Option-Up", selecttostart:"Command-Shift-Up", gotostart:"Command-Home|Command-Up", selectup:"Shift-Up", golineup:"Up", copylinesdown:"Command-Option-Down", movelinesdown:"Option-Down", selecttoend:"Command-Shift-Down", gotoend:"Command-End|Command-Down", selectdown:"Shift-Down", godown:"Down", selectwordleft:"Option-Shift-Left", gotowordleft:"Option-Left", selecttolinestart:"Command-Shift-Left", gotolinestart:"Command-Left|Home", selectleft:"Shift-Left", gotoleft:"Left", selectwordright:"Option-Shift-Right", gotowordright:"Option-Right", selecttolineend:"Command-Shift-Right", gotolineend:"Command-Right|End", selectright:"Shift-Right", gotoright:"Right", selectpagedown:"Shift-PageDown", - pagedown:"PageDown", selectpageup:"Shift-PageUp", pageup:"PageUp", selectlinestart:"Shift-Home", selectlineend:"Shift-End", del:"Delete", backspace:"Backspace", outdent:"Shift-Tab", indent:"Tab"} + pagedown:"PageDown", selectpageup:"Shift-PageUp", pageup:"PageUp", selectlinestart:"Shift-Home", selectlineend:"Shift-End", del:"Delete", backspace:"Ctrl-Backspace|Command-Backspace|Option-Backspace|Backspace", outdent:"Shift-Tab", indent:"Tab"} }); define("ace/conf/keybindings/default_win", ["require", "exports", "module"], function() { return{selectall:"Ctrl-A", removeline:"Ctrl-D", gotoline:"Ctrl-L", togglecomment:"Ctrl-7", findnext:"Ctrl-K", findprevious:"Ctrl-Shift-K", find:"Ctrl-F", replace:"Ctrl-R", undo:"Ctrl-Z", redo:"Ctrl-Shift-Z|Ctrl-Y", overwrite:"Insert", copylinesup:"Ctrl-Alt-Up", movelinesup:"Alt-Up", selecttostart:"Alt-Shift-Up", gotostart:"Ctrl-Home|Ctrl-Up", selectup:"Shift-Up", golineup:"Up", copylinesdown:"Ctrl-Alt-Down", movelinesdown:"Alt-Down", selecttoend:"Alt-Shift-Down", gotoend:"Ctrl-End|Ctrl-Down", selectdown:"Shift-Down", - godown:"Down", selectwordleft:"Ctrl-Shift-Left", gotowordleft:"Ctrl-Left", selecttolinestart:"Ctrl-Shift-Left", gotolinestart:"Alt-Left|Home", selectleft:"Shift-Left", gotoleft:"Left", selectwordright:"Ctrl-Shift-Right", gotowordright:"Ctrl-Right", selecttolineend:"Ctrl-Shift-Right", gotolineend:"Alt-Right|End", selectright:"Shift-Right", gotoright:"Right", selectpagedown:"Shift-PageDown", pagedown:"PageDown", selectpageup:"Shift-PageUp", pageup:"PageUp", selectlinestart:"Shift-Home", selectlineend:"Shift-End", + godown:"Down", selectwordleft:"Ctrl-Shift-Left", gotowordleft:"Ctrl-Left", selecttolinestart:"Alt-Shift-Left", gotolinestart:"Alt-Left|Home", selectleft:"Shift-Left", gotoleft:"Left", selectwordright:"Ctrl-Shift-Right", gotowordright:"Ctrl-Right", selecttolineend:"Alt-Shift-Right", gotolineend:"Alt-Right|End", selectright:"Shift-Right", gotoright:"Right", selectpagedown:"Shift-PageDown", pagedown:"PageDown", selectpageup:"Shift-PageUp", pageup:"PageUp", selectlinestart:"Shift-Home", selectlineend:"Shift-End", del:"Delete", backspace:"Backspace", outdent:"Shift-Tab", indent:"Tab"} }); define("ace/plugin_manager", ["require", "exports", "module"], function() { @@ -566,54 +566,54 @@ define("ace/commands/default_commands", ["require", "exports", "module", "../plu }) }); define("ace/keybinding", ["require", "exports", "module", "./lib/core", "./lib/event", "./conf/keybindings/default_mac", "./conf/keybindings/default_win", "./plugin_manager", "./commands/default_commands"], function(h) { - var g = h("./lib/core"), e = h("./lib/event"), d = h("./conf/keybindings/default_mac"), i = h("./conf/keybindings/default_win"), c = h("./plugin_manager"); + var g = h("./lib/core"), e = h("./lib/event"), c = h("./conf/keybindings/default_mac"), i = h("./conf/keybindings/default_win"), b = h("./plugin_manager"); h("./commands/default_commands"); h = function(j, a, f) { this.setConfig(f); - var m = this; + var l = this; e.addKeyListener(j, function(n) { - var b = (m.config.reverse[0 | (n.ctrlKey ? 1 : 0) | (n.altKey ? 2 : 0) | (n.shiftKey ? 4 : 0) | (n.metaKey ? 8 : 0)] || {})[(m.keyNames[n.keyCode] || String.fromCharCode(n.keyCode)).toLowerCase()]; - if(b = c.commands[b]) { - b(a, a.getSelection()); + var d = (l.config.reverse[0 | (n.ctrlKey ? 1 : 0) | (n.altKey ? 2 : 0) | (n.shiftKey ? 4 : 0) | (n.metaKey ? 8 : 0)] || {})[(l.keyNames[n.keyCode] || String.fromCharCode(n.keyCode)).toLowerCase()]; + if(d = b.commands[d]) { + d(a, a.getSelection()); return e.stopEvent(n) } }) }; (function() { - function j(m, n, b, k) { - return(k && m.toLowerCase() || m).replace(/(?:^\s+|\n|\s+$)/g, "").split(new RegExp("[\\s ]*" + n + "[\\s ]*", "g"), b || 999) + function j(l, n, d, k) { + return(k && l.toLowerCase() || l).replace(/(?:^\s+|\n|\s+$)/g, "").split(new RegExp("[\\s ]*" + n + "[\\s ]*", "g"), d || 999) } - function a(m, n, b) { + function a(l, n, d) { var k, p = 0; - m = j(m, "\\-", null, true); - for(var o = 0, l = m.length;o < l;++o) { - if(this.keyMods[m[o]]) { - p |= this.keyMods[m[o]] + l = j(l, "\\-", null, true); + for(var o = 0, m = l.length;o < m;++o) { + if(this.keyMods[l[o]]) { + p |= this.keyMods[l[o]] }else { - k = m[o] || "-" + k = l[o] || "-" } - }(b[p] || (b[p] = {}))[k] = n; - return b + }(d[p] || (d[p] = {}))[k] = n; + return d } - function f(m, n) { - var b, k, p, o, l = {}; - for(b in m) { - o = m[b]; + function f(l, n) { + var d, k, p, o, m = {}; + for(d in l) { + o = l[d]; if(n && typeof o == "string") { o = o.split(n); k = 0; for(p = o.length;k < p;++k) { - a.call(this, o[k], b, l) + a.call(this, o[k], d, m) } }else { - a.call(this, o, b, l) + a.call(this, o, d, m) } - }return l + }return m } this.keyMods = {ctrl:1, alt:2, option:2, shift:4, meta:8, command:8}; this.keyNames = {"8":"Backspace", "9":"Tab", "13":"Enter", "27":"Esc", "32":"Space", "33":"PageUp", "34":"PageDown", "35":"End", "36":"Home", "37":"Left", "38":"Up", "39":"Right", "40":"Down", "45":"Insert", "46":"Delete", "107":"+", "112":"F1", "113":"F2", "114":"F3", "115":"F4", "116":"F5", "117":"F6", "118":"F7", "119":"F8", "120":"F9", "121":"F10", "122":"F11", "123":"F12"}; - this.setConfig = function(m) { - this.config = m || (g.isMac ? d : i); + this.setConfig = function(l) { + this.config = l || (g.isMac ? c : i); if(typeof this.config.reverse == "undefined") { this.config.reverse = f.call(this, this.config, "|") } @@ -624,36 +624,36 @@ define("ace/keybinding", ["require", "exports", "module", "./lib/core", "./lib/e define("ace/event_emitter", ["require", "exports", "module", "./lib/lang"], function(h) { var g = h("./lib/lang"); h = {}; - h.$dispatchEvent = function(e, d) { + h.$dispatchEvent = function(e, c) { this.$eventRegistry = this.$eventRegistry || {}; var i = this.$eventRegistry[e]; if(i && i.length) { - d = d || {}; - d.type = e; + c = c || {}; + c.type = e; for(e = 0;e < i.length;e++) { - i[e](d) + i[e](c) } } }; - h.on = h.addEventListener = function(e, d) { + h.on = h.addEventListener = function(e, c) { this.$eventRegistry = this.$eventRegistry || {}; var i = this.$eventRegistry[e]; i || (i = this.$eventRegistry[e] = []); - g.arrayIndexOf(i, d) == -1 && i.push(d) + g.arrayIndexOf(i, c) == -1 && i.push(c) }; - h.removeEventListener = function(e, d) { + h.removeEventListener = function(e, c) { this.$eventRegistry = this.$eventRegistry || {}; if(e = this.$eventRegistry[e]) { - d = g.arrayIndexOf(e, d); - d !== -1 && e.splice(d, 1) + c = g.arrayIndexOf(e, c); + c !== -1 && e.splice(c, 1) } }; return h }); define("ace/range", ["require", "exports", "module"], function() { - var h = function(g, e, d, i) { + var h = function(g, e, c, i) { this.start = {row:g, column:e}; - this.end = {row:d, column:i} + this.end = {row:c, column:i} }; (function() { this.toString = function() { @@ -679,26 +679,26 @@ define("ace/range", ["require", "exports", "module"], function() { }; this.clipRows = function(g, e) { if(this.end.row > e) { - var d = {row:e + 1, column:0} + var c = {row:e + 1, column:0} }if(this.start.row > e) { var i = {row:e + 1, column:0} }if(this.start.row < g) { i = {row:g, column:0} }if(this.end.row < g) { - d = {row:g, column:0} - }return h.fromPoints(i || this.start, d || this.end) + c = {row:g, column:0} + }return h.fromPoints(i || this.start, c || this.end) }; this.extend = function(g, e) { - var d = this.compare(g, e); - if(d == 0) { + var c = this.compare(g, e); + if(c == 0) { return this }else { - if(d == -1) { + if(c == -1) { var i = {row:g, column:e} }else { - var c = {row:g, column:e} + var b = {row:g, column:e} } - }return h.fromPoints(i || this.start, c || this.end) + }return h.fromPoints(i || this.start, b || this.end) }; this.isEmpty = function() { return this.start.row == this.end.row && this.start.column == this.end.column @@ -719,14 +719,14 @@ define("ace/range", ["require", "exports", "module"], function() { return h }); define("ace/selection", ["require", "exports", "module", "./lib/oop", "./lib/lang", "./event_emitter", "./range"], function(h) { - var g = h("./lib/oop"), e = h("./lib/lang"), d = h("./event_emitter"), i = h("./range"); - h = function(c) { - this.doc = c; + var g = h("./lib/oop"), e = h("./lib/lang"), c = h("./event_emitter"), i = h("./range"); + h = function(b) { + this.doc = b; this.clearSelection(); this.selectionLead = {row:0, column:0} }; (function() { - g.implement(this, d); + g.implement(this, c); this.isEmpty = function() { return!this.selectionAnchor || this.selectionAnchor.row == this.selectionLead.row && this.selectionAnchor.column == this.selectionLead.column }; @@ -738,15 +738,15 @@ define("ace/selection", ["require", "exports", "module", "./lib/oop", "./lib/lan this.getCursor = function() { return this.selectionLead }; - this.setSelectionAnchor = function(c, j) { - c = this.$clipPositionToDocument(c, j); + this.setSelectionAnchor = function(b, j) { + b = this.$clipPositionToDocument(b, j); if(this.selectionAnchor) { - if(this.selectionAnchor.row !== c.row || this.selectionAnchor.column !== c.column) { - this.selectionAnchor = c; + if(this.selectionAnchor.row !== b.row || this.selectionAnchor.column !== b.column) { + this.selectionAnchor = b; this.$dispatchEvent("changeSelection", {}) } }else { - this.selectionAnchor = c; + this.selectionAnchor = b; this.$dispatchEvent("changeSelection", {}) } }; @@ -756,27 +756,27 @@ define("ace/selection", ["require", "exports", "module", "./lib/oop", "./lib/lan this.getSelectionLead = function() { return this.$clone(this.selectionLead) }; - this.shiftSelection = function(c) { + this.shiftSelection = function(b) { if(this.isEmpty()) { - this.moveCursorTo(this.selectionLead.row, this.selectionLead.column + c) + this.moveCursorTo(this.selectionLead.row, this.selectionLead.column + b) }else { var j = this.getSelectionAnchor(), a = this.getSelectionLead(), f = this.isBackwards(); if(!f || j.column !== 0) { - this.setSelectionAnchor(j.row, j.column + c) + this.setSelectionAnchor(j.row, j.column + b) }if(f || a.column !== 0) { this.$moveSelection(function() { - this.moveCursorTo(a.row, a.column + c) + this.moveCursorTo(a.row, a.column + b) }) } } }; this.isBackwards = function() { - var c = this.selectionAnchor || this.selectionLead, j = this.selectionLead; - return c.row > j.row || c.row == j.row && c.column > j.column + var b = this.selectionAnchor || this.selectionLead, j = this.selectionLead; + return b.row > j.row || b.row == j.row && b.column > j.column }; this.getRange = function() { - var c = this.selectionAnchor || this.selectionLead, j = this.selectionLead; - return this.isBackwards() ? i.fromPoints(j, c) : i.fromPoints(c, j) + var b = this.selectionAnchor || this.selectionLead, j = this.selectionLead; + return this.isBackwards() ? i.fromPoints(j, b) : i.fromPoints(b, j) }; this.clearSelection = function() { if(this.selectionAnchor) { @@ -785,40 +785,40 @@ define("ace/selection", ["require", "exports", "module", "./lib/oop", "./lib/lan } }; this.selectAll = function() { - var c = this.doc.getLength() - 1; - this.setSelectionAnchor(c, this.doc.getLine(c).length); + var b = this.doc.getLength() - 1; + this.setSelectionAnchor(b, this.doc.getLine(b).length); this.$moveSelection(function() { this.moveCursorTo(0, 0) }) }; - this.setSelectionRange = function(c, j) { + this.setSelectionRange = function(b, j) { if(j) { - this.setSelectionAnchor(c.end.row, c.end.column); - this.selectTo(c.start.row, c.start.column) + this.setSelectionAnchor(b.end.row, b.end.column); + this.selectTo(b.start.row, b.start.column) }else { - this.setSelectionAnchor(c.start.row, c.start.column); - this.selectTo(c.end.row, c.end.column) + this.setSelectionAnchor(b.start.row, b.start.column); + this.selectTo(b.end.row, b.end.column) } }; - this.$moveSelection = function(c) { + this.$moveSelection = function(b) { var j = false; if(!this.selectionAnchor) { j = true; this.selectionAnchor = this.$clone(this.selectionLead) }var a = this.$clone(this.selectionLead); - c.call(this); + b.call(this); if(a.row !== this.selectionLead.row || a.column !== this.selectionLead.column) { j = true }j && this.$dispatchEvent("changeSelection", {}) }; - this.selectTo = function(c, j) { + this.selectTo = function(b, j) { this.$moveSelection(function() { - this.moveCursorTo(c, j) + this.moveCursorTo(b, j) }) }; - this.selectToPosition = function(c) { + this.selectToPosition = function(b) { this.$moveSelection(function() { - this.moveCursorToPosition(c) + this.moveCursorToPosition(b) }) }; this.selectUp = function() { @@ -852,8 +852,8 @@ define("ace/selection", ["require", "exports", "module", "./lib/oop", "./lib/lan this.$moveSelection(this.moveCursorWordLeft) }; this.selectWord = function() { - var c = this.selectionLead; - this.setSelectionRange(this.doc.getWordRange(c.row, c.column)) + var b = this.selectionLead; + this.setSelectionRange(this.doc.getWordRange(b.row, b.column)) }; this.selectLine = function() { this.setSelectionAnchor(this.selectionLead.row, 0); @@ -882,25 +882,25 @@ define("ace/selection", ["require", "exports", "module", "./lib/oop", "./lib/lan } }; this.moveCursorLineStart = function() { - var c = this.selectionLead.row, j = this.selectionLead.column, a = this.doc.getLine(c).slice(0, j).match(/^\s*/); + var b = this.selectionLead.row, j = this.selectionLead.column, a = this.doc.getLine(b).slice(0, j).match(/^\s*/); if(a[0].length == 0) { - this.moveCursorTo(c, this.doc.getLine(c).match(/^\s*/)[0].length) + this.moveCursorTo(b, this.doc.getLine(b).match(/^\s*/)[0].length) }else { - a[0].length >= j ? this.moveCursorTo(c, 0) : this.moveCursorTo(c, a[0].length) + a[0].length >= j ? this.moveCursorTo(b, 0) : this.moveCursorTo(b, a[0].length) } }; this.moveCursorLineEnd = function() { this.moveCursorTo(this.selectionLead.row, this.doc.getLine(this.selectionLead.row).length) }; this.moveCursorFileEnd = function() { - var c = this.doc.getLength() - 1, j = this.doc.getLine(c).length; - this.moveCursorTo(c, j) + var b = this.doc.getLength() - 1, j = this.doc.getLine(b).length; + this.moveCursorTo(b, j) }; this.moveCursorFileStart = function() { this.moveCursorTo(0, 0) }; this.moveCursorWordRight = function() { - var c = this.selectionLead.row, j = this.selectionLead.column, a = this.doc.getLine(c), f = a.substring(j); + var b = this.selectionLead.row, j = this.selectionLead.column, a = this.doc.getLine(b), f = a.substring(j); this.doc.nonTokenRe.lastIndex = 0; this.doc.tokenRe.lastIndex = 0; if(j == a.length) { @@ -914,11 +914,11 @@ define("ace/selection", ["require", "exports", "module", "./lib/oop", "./lib/lan j += this.doc.tokenRe.lastIndex; this.doc.tokenRe.lastIndex = 0 } - }this.moveCursorTo(c, j) + }this.moveCursorTo(b, j) } }; this.moveCursorWordLeft = function() { - var c = this.selectionLead.row, j = this.selectionLead.column, a = this.doc.getLine(c); + var b = this.selectionLead.row, j = this.selectionLead.column, a = this.doc.getLine(b); a = e.stringReverse(a.substring(0, j)); this.doc.nonTokenRe.lastIndex = 0; this.doc.tokenRe.lastIndex = 0; @@ -933,42 +933,42 @@ define("ace/selection", ["require", "exports", "module", "./lib/oop", "./lib/lan j -= this.doc.tokenRe.lastIndex; this.doc.tokenRe.lastIndex = 0 } - }this.moveCursorTo(c, j) + }this.moveCursorTo(b, j) } }; - this.moveCursorBy = function(c, j) { - this.moveCursorTo(this.selectionLead.row + c, this.selectionLead.column + j) + this.moveCursorBy = function(b, j) { + this.moveCursorTo(this.selectionLead.row + b, this.selectionLead.column + j) }; - this.moveCursorToPosition = function(c) { - this.moveCursorTo(c.row, c.column) + this.moveCursorToPosition = function(b) { + this.moveCursorTo(b.row, b.column) }; - this.moveCursorTo = function(c, j) { - c = this.$clipPositionToDocument(c, j); - if(c.row !== this.selectionLead.row || c.column !== this.selectionLead.column) { - this.selectionLead = c; + this.moveCursorTo = function(b, j) { + b = this.$clipPositionToDocument(b, j); + if(b.row !== this.selectionLead.row || b.column !== this.selectionLead.column) { + this.selectionLead = b; this.$dispatchEvent("changeCursor", {data:this.getCursor()}) } }; this.moveCursorUp = function() { this.moveCursorBy(-1, 0) }; - this.$clipPositionToDocument = function(c, j) { + this.$clipPositionToDocument = function(b, j) { var a = {}; - if(c >= this.doc.getLength()) { + if(b >= this.doc.getLength()) { a.row = Math.max(0, this.doc.getLength() - 1); a.column = this.doc.getLine(a.row).length }else { - if(c < 0) { + if(b < 0) { a.row = 0; a.column = 0 }else { - a.row = c; + a.row = b; a.column = Math.min(this.doc.getLine(a.row).length, Math.max(0, j)) } }return a }; - this.$clone = function(c) { - return{row:c.row, column:c.column} + this.$clone = function(b) { + return{row:b.row, column:b.column} } }).call(h.prototype); return h @@ -979,36 +979,36 @@ define("ace/tokenizer", ["require", "exports", "module"], function() { this.regExps = {}; for(var e in this.rules) { g = this.rules[e]; - for(var d = [], i = 0;i < g.length;i++) { - d.push(g[i].regex) - }this.regExps[e] = new RegExp("(?:(" + d.join(")|(") + ")|(.))", "g") + for(var c = [], i = 0;i < g.length;i++) { + c.push(g[i].regex) + }this.regExps[e] = new RegExp("(?:(" + c.join(")|(") + ")|(.))", "g") } }; (function() { this.getLineTokens = function(g, e) { e = e; - var d = this.rules[e], i = this.regExps[e]; + var c = this.rules[e], i = this.regExps[e]; i.lastIndex = 0; - for(var c, j = [], a = 0, f = {type:null, value:""};c = i.exec(g);) { - var m = "text", n = c[0]; + for(var b, j = [], a = 0, f = {type:null, value:""};b = i.exec(g);) { + var l = "text", n = b[0]; if(i.lastIndex == a) { throw new Error("tokenizer error"); }a = i.lastIndex; - window.LOG && console.log(e, c); - for(var b = 0;b < d.length;b++) { - if(c[b + 1]) { - m = typeof d[b].token == "function" ? d[b].token(c[0]) : d[b].token; - if(d[b].next && d[b].next !== e) { - e = d[b].next; - d = this.rules[e]; + window.LOG && console.log(e, b); + for(var d = 0;d < c.length;d++) { + if(b[d + 1]) { + l = typeof c[d].token == "function" ? c[d].token(b[0]) : c[d].token; + if(c[d].next && c[d].next !== e) { + e = c[d].next; + c = this.rules[e]; a = i.lastIndex; i = this.regExps[e]; i.lastIndex = a }break } - }if(f.type !== m) { + }if(f.type !== l) { f.type && j.push(f); - f = {type:m, value:n} + f = {type:l, value:n} }else { f.value += n } @@ -1025,11 +1025,11 @@ define("ace/mode/text_highlight_rules", ["require", "exports", "module"], functi }; (function() { this.addRules = function(g, e) { - for(var d in g) { - for(var i = g[d], c = 0;c < i.length;c++) { - var j = i[c]; - j.next = j.next ? e + j.next : e + d - }this.$rules[e + d] = i + for(var c in g) { + for(var i = g[c], b = 0;b < i.length;b++) { + var j = i[b]; + j.next = j.next ? e + j.next : e + c + }this.$rules[e + c] = i } }; this.getRules = function() { @@ -1058,16 +1058,16 @@ define("ace/mode/text", ["require", "exports", "module", "../tokenizer", "./text }; this.autoOutdent = function() { }; - this.$getIndent = function(d) { - if(d = d.match(/^(\s+)/)) { - return d[1] + this.$getIndent = function(c) { + if(c = c.match(/^(\s+)/)) { + return c[1] }return"" } }).call(h.prototype); return h }); define("ace/document", ["require", "exports", "module", "./lib/oop", "./lib/lang", "./event_emitter", "./selection", "./mode/text", "./range"], function(h) { - var g = h("./lib/oop"), e = h("./lib/lang"), d = h("./event_emitter"), i = h("./selection"), c = h("./mode/text"), j = h("./range"); + var g = h("./lib/oop"), e = h("./lib/lang"), c = h("./event_emitter"), i = h("./selection"), b = h("./mode/text"), j = h("./range"); h = function(a, f) { this.modified = true; this.lines = []; @@ -1078,7 +1078,7 @@ define("ace/document", ["require", "exports", "module", "./lib/oop", "./lib/lang e.isArray(a) ? this.$insertLines(0, a) : this.$insert({row:0, column:0}, a) }; (function() { - g.implement(this, d); + g.implement(this, c); this.$undoManager = null; this.$split = function(a) { return a.split(/\r\n|\r|\n/) @@ -1167,20 +1167,20 @@ define("ace/document", ["require", "exports", "module", "./lib/oop", "./lib/lang this.tokenRe = /^[\w\d]+/g; this.nonTokenRe = /^[^\w\d]+/g; this.getWordRange = function(a, f) { - var m = this.getLine(a), n = false; + var l = this.getLine(a), n = false; if(f > 0) { - n = !!m.charAt(f - 1).match(this.tokenRe) - }n || (n = !!m.charAt(f).match(this.tokenRe)); + n = !!l.charAt(f - 1).match(this.tokenRe) + }n || (n = !!l.charAt(f).match(this.tokenRe)); n = n ? this.tokenRe : this.nonTokenRe; - var b = f; - if(b > 0) { + var d = f; + if(d > 0) { do { - b-- - }while(b >= 0 && m.charAt(b).match(n)); - b++ - }for(f = f;f < m.length && m.charAt(f).match(n);) { + d-- + }while(d >= 0 && l.charAt(d).match(n)); + d++ + }for(f = f;f < l.length && l.charAt(f).match(n);) { f++ - }return new j(a, b, a, f) + }return new j(a, d, a, f) }; this.$getNewLineCharacter = function() { switch(this.$newLineMode) { @@ -1211,7 +1211,7 @@ define("ace/document", ["require", "exports", "module", "./lib/oop", "./lib/lang }; this.getMode = function() { if(!this.$mode) { - this.$mode = new c + this.$mode = new b }return this.$mode }; this.$scrollTop = 0; @@ -1235,16 +1235,16 @@ define("ace/document", ["require", "exports", "module", "./lib/oop", "./lib/lang this.$computeWidth = function() { if(this.modified) { this.modified = false; - for(var a = this.lines, f = 0, m = 0, n = this.getTabSize(), b = 0;b < a.length;b++) { - var k = a[b].length; + for(var a = this.lines, f = 0, l = 0, n = this.getTabSize(), d = 0;d < a.length;d++) { + var k = a[d].length; f = Math.max(f, k); - a[b].replace("\t", function(p) { + a[d].replace("\t", function(p) { k += n - 1; return p }); - m = Math.max(m, k) + l = Math.max(l, k) }this.width = f; - this.screenWith = m + this.screenWith = l } }; this.getLine = function(a) { @@ -1284,19 +1284,19 @@ define("ace/document", ["require", "exports", "module", "./lib/oop", "./lib/lang }; this.$brackets = {")":"(", "(":")", "]":"[", "[":"]", "{":"}", "}":"{"}; this.$findOpeningBracket = function(a, f) { - var m = this.$brackets[a], n = f.column - 2; + var l = this.$brackets[a], n = f.column - 2; f = f.row; - for(var b = 1, k = this.getLine(f);;) { + for(var d = 1, k = this.getLine(f);;) { for(;n >= 0;) { var p = k.charAt(n); - if(p == m) { - b -= 1; - if(b == 0) { + if(p == l) { + d -= 1; + if(d == 0) { return{row:f, column:n} } }else { if(p == a) { - b += 1 + d += 1 } }n -= 1 }f -= 1; @@ -1307,19 +1307,19 @@ define("ace/document", ["require", "exports", "module", "./lib/oop", "./lib/lang }return null }; this.$findClosingBracket = function(a, f) { - var m = this.$brackets[a], n = f.column; + var l = this.$brackets[a], n = f.column; f = f.row; - for(var b = 1, k = this.getLine(f), p = this.getLength();;) { + for(var d = 1, k = this.getLine(f), p = this.getLength();;) { for(;n < k.length;) { var o = k.charAt(n); - if(o == m) { - b -= 1; - if(b == 0) { + if(o == l) { + d -= 1; + if(d == 0) { return{row:f, column:n} } }else { if(o == a) { - b += 1 + d += 1 } }n += 1 }f += 1; @@ -1329,49 +1329,49 @@ define("ace/document", ["require", "exports", "module", "./lib/oop", "./lib/lang n = 0 }return null }; - this.insert = function(a, f, m) { - f = this.$insert(a, f, m); + this.insert = function(a, f, l) { + f = this.$insert(a, f, l); this.fireChangeEvent(a.row, a.row == f.row ? a.row : undefined); return f }; - this.$insertLines = function(a, f, m) { + this.$insertLines = function(a, f, l) { if(f.length != 0) { var n = [a, 0]; n.push.apply(n, f); this.lines.splice.apply(this.lines, n); - if(!m && this.$undoManager) { - m = this.$getNewLineCharacter(); - this.$deltas.push({action:"insertText", range:new j(a, 0, a + f.length, 0), text:f.join(m) + m}); + if(!l && this.$undoManager) { + l = this.$getNewLineCharacter(); + this.$deltas.push({action:"insertText", range:new j(a, 0, a + f.length, 0), text:f.join(l) + l}); this.$informUndoManager.schedule() } } }; - this.$insert = function(a, f, m) { + this.$insert = function(a, f, l) { if(f.length == 0) { return a }this.modified = true; this.lines.length <= 1 && this.$detectNewLine(f); var n = this.$split(f); if(this.$isNewLine(f)) { - var b = this.lines[a.row] || ""; - this.lines[a.row] = b.substring(0, a.column); - this.lines.splice(a.row + 1, 0, b.substring(a.column)); + var d = this.lines[a.row] || ""; + this.lines[a.row] = d.substring(0, a.column); + this.lines.splice(a.row + 1, 0, d.substring(a.column)); n = {row:a.row + 1, column:0} }else { if(n.length == 1) { - b = this.lines[a.row] || ""; - this.lines[a.row] = b.substring(0, a.column) + f + b.substring(a.column); + d = this.lines[a.row] || ""; + this.lines[a.row] = d.substring(0, a.column) + f + d.substring(a.column); n = {row:a.row, column:a.column + f.length} }else { - b = this.lines[a.row] || ""; - var k = b.substring(0, a.column) + n[0]; - b = n[n.length - 1] + b.substring(a.column); + d = this.lines[a.row] || ""; + var k = d.substring(0, a.column) + n[0]; + d = n[n.length - 1] + d.substring(a.column); this.lines[a.row] = k; - this.$insertLines(a.row + 1, [b], true); + this.$insertLines(a.row + 1, [d], true); n.length > 2 && this.$insertLines(a.row + 1, n.slice(1, -1), true); n = {row:a.row + n.length - 1, column:n[n.length - 1].length} } - }if(!m && this.$undoManager) { + }if(!l && this.$undoManager) { this.$deltas.push({action:"insertText", range:j.fromPoints(a, n), text:f}); this.$informUndoManager.schedule() }return n @@ -1394,20 +1394,20 @@ define("ace/document", ["require", "exports", "module", "./lib/oop", "./lib/lang this.$informUndoManager.schedule() }this.modified = true; f = a.start.row; - var m = a.end.row, n = this.getLine(f).substring(0, a.start.column) + this.getLine(m).substring(a.end.column); - this.lines.splice(f, m - f + 1, n); + var l = a.end.row, n = this.getLine(f).substring(0, a.start.column) + this.getLine(l).substring(a.end.column); + n != "" ? this.lines.splice(f, l - f + 1, n) : this.lines.splice(f, l - f + 1, ""); return a.start } }; this.undoChanges = function(a) { this.selection.clearSelection(); for(var f = a.length - 1;f >= 0;f--) { - var m = a[f]; - if(m.action == "insertText") { - this.remove(m.range, true); - this.selection.moveCursorToPosition(m.range.start) + var l = a[f]; + if(l.action == "insertText") { + this.remove(l.range, true); + this.selection.moveCursorToPosition(l.range.start) }else { - this.insert(m.range.start, m.text, true); + this.insert(l.range.start, l.text, true); this.selection.clearSelection() } } @@ -1415,40 +1415,40 @@ define("ace/document", ["require", "exports", "module", "./lib/oop", "./lib/lang this.redoChanges = function(a) { this.selection.clearSelection(); for(var f = 0;f < a.length;f++) { - var m = a[f]; - if(m.action == "insertText") { - this.insert(m.range.start, m.text, true); - this.selection.setSelectionRange(m.range) + var l = a[f]; + if(l.action == "insertText") { + this.insert(l.range.start, l.text, true); + this.selection.setSelectionRange(l.range) }else { - this.remove(m.range, true); - this.selection.moveCursorToPosition(m.range.start) + this.remove(l.range, true); + this.selection.moveCursorToPosition(l.range.start) } } }; this.replace = function(a, f) { this.$remove(a); f = f ? this.$insert(a.start, f) : a.start; - var m = a.end.column == 0 ? a.end.column - 1 : a.end.column; - this.fireChangeEvent(a.start.row, m == f.row ? m : undefined); + var l = a.end.column == 0 ? a.end.column - 1 : a.end.column; + this.fireChangeEvent(a.start.row, l == f.row ? l : undefined); return f }; this.indentRows = function(a, f) { f.replace("\t", this.getTabString()); - for(var m = a.start.row;m <= a.end.row;m++) { - this.$insert({row:m, column:0}, f) + for(var l = a.start.row;l <= a.end.row;l++) { + this.$insert({row:l, column:0}, f) }this.fireChangeEvent(a.start.row, a.end.row); return f.length }; this.outdentRows = function(a) { - for(var f = new j(0, 0, 0, 0), m = this.getTabSize(), n = a.start.row;n <= a.end.row;++n) { - var b = this.getLine(n); + for(var f = new j(0, 0, 0, 0), l = this.getTabSize(), n = a.start.row;n <= a.end.row;++n) { + var d = this.getLine(n); f.start.row = n; f.end.row = n; - for(var k = 0;k < m;++k) { - if(b.charAt(k) != " ") { + for(var k = 0;k < l;++k) { + if(d.charAt(k) != " ") { break } - }if(k < m && b.charAt(k) == "\t") { + }if(k < l && d.charAt(k) == "\t") { f.start.column = k; f.end.column = k + 1 }else { @@ -1465,26 +1465,26 @@ define("ace/document", ["require", "exports", "module", "./lib/oop", "./lib/lang this.moveLinesUp = function(a, f) { if(a <= 0) { return 0 - }var m = this.lines.slice(a, f + 1); + }var l = this.lines.slice(a, f + 1); this.$remove(new j(a, 0, f + 1, 0)); - this.$insertLines(a - 1, m); + this.$insertLines(a - 1, l); this.fireChangeEvent(a - 1, f); return-1 }; this.moveLinesDown = function(a, f) { if(f >= this.lines.length - 1) { return 0 - }var m = this.lines.slice(a, f + 1); + }var l = this.lines.slice(a, f + 1); this.$remove(new j(a, 0, f + 1, 0)); - this.$insertLines(a + 1, m); + this.$insertLines(a + 1, l); this.fireChangeEvent(a, f + 1); return 1 }; this.duplicateLines = function(a, f) { a = this.$clipRowToDocument(a); f = this.$clipRowToDocument(f); - var m = this.getLines(a, f); - this.$insertLines(a, m); + var l = this.getLines(a, f); + this.$insertLines(a, l); f = f - a + 1; this.fireChangeEvent(a); return f @@ -1493,14 +1493,14 @@ define("ace/document", ["require", "exports", "module", "./lib/oop", "./lib/lang return Math.max(0, Math.min(a, this.lines.length - 1)) }; this.documentToScreenColumn = function(a, f) { - var m = this.getTabSize(), n = 0; + var l = this.getTabSize(), n = 0; f = f; a = this.getLine(a).split("\t"); - for(var b = 0;b < a.length;b++) { - var k = a[b].length; + for(var d = 0;d < a.length;d++) { + var k = a[d].length; if(f > k) { f -= k + 1; - n += k + m + n += k + l }else { n += f; break @@ -1508,13 +1508,13 @@ define("ace/document", ["require", "exports", "module", "./lib/oop", "./lib/lang }return n }; this.screenToDocumentColumn = function(a, f) { - var m = this.getTabSize(), n = 0; + var l = this.getTabSize(), n = 0; f = f; a = this.getLine(a).split("\t"); - for(var b = 0;b < a.length;b++) { - var k = a[b].length; - if(f >= k + m) { - f -= k + m; + for(var d = 0;d < a.length;d++) { + var k = a[d].length; + if(f >= k + l) { + f -= k + l; n += k + 1 }else { n += f > k ? k : f; @@ -1526,56 +1526,56 @@ define("ace/document", ["require", "exports", "module", "./lib/oop", "./lib/lang return h }); define("ace/search", ["require", "exports", "module", "./lib/lang", "./lib/oop", "./range"], function(h) { - var g = h("./lib/lang"), e = h("./lib/oop"), d = h("./range"), i = function() { + var g = h("./lib/lang"), e = h("./lib/oop"), c = h("./range"), i = function() { this.$options = {needle:"", backwards:false, wrap:false, caseSensitive:false, wholeWord:false, scope:i.ALL, regExp:false} }; i.ALL = 1; i.SELECTION = 2; (function() { - this.set = function(c) { - e.mixin(this.$options, c); + this.set = function(b) { + e.mixin(this.$options, b); return this }; this.getOptions = function() { return g.copyObject(this.$options) }; - this.find = function(c) { + this.find = function(b) { if(!this.$options.needle) { return null }var j = null; - (this.$options.backwards ? this.$backwardMatchIterator(c) : this.$forwardMatchIterator(c)).forEach(function(a) { + (this.$options.backwards ? this.$backwardMatchIterator(b) : this.$forwardMatchIterator(b)).forEach(function(a) { j = a; return true }); return j }; - this.findAll = function(c) { + this.findAll = function(b) { if(!this.$options.needle) { return[] }var j = []; - (this.$options.backwards ? this.$backwardMatchIterator(c) : this.$forwardMatchIterator(c)).forEach(function(a) { + (this.$options.backwards ? this.$backwardMatchIterator(b) : this.$forwardMatchIterator(b)).forEach(function(a) { j.push(a) }); return j }; - this.replace = function(c, j) { - var a = this.$assembleRegExp(), f = a.exec(c); - return f && f[0].length == c.length ? this.$options.regExp ? c.replace(a, j) : j : null + this.replace = function(b, j) { + var a = this.$assembleRegExp(), f = a.exec(b); + return f && f[0].length == b.length ? this.$options.regExp ? b.replace(a, j) : j : null }; - this.$forwardMatchIterator = function(c) { + this.$forwardMatchIterator = function(b) { var j = this.$assembleRegExp(), a = this; return{forEach:function(f) { - a.$forwardLineIterator(c).forEach(function(m, n, b) { + a.$forwardLineIterator(b).forEach(function(l, n, d) { if(n) { - m = m.substring(n) + l = l.substring(n) }var k = []; - m.replace(j, function(o) { + l.replace(j, function(o) { k.push({str:o, offset:n + arguments[arguments.length - 2]}); return o }); - for(m = 0;m < k.length;m++) { - var p = k[m]; - p = a.$rangeFromMatch(b, p.offset, p.str.length); + for(l = 0;l < k.length;l++) { + var p = k[l]; + p = a.$rangeFromMatch(d, p.offset, p.str.length); if(f(p)) { return true } @@ -1583,20 +1583,20 @@ define("ace/search", ["require", "exports", "module", "./lib/lang", "./lib/oop", }) }} }; - this.$backwardMatchIterator = function(c) { + this.$backwardMatchIterator = function(b) { var j = this.$assembleRegExp(), a = this; return{forEach:function(f) { - a.$backwardLineIterator(c).forEach(function(m, n, b) { + a.$backwardLineIterator(b).forEach(function(l, n, d) { if(n) { - m = m.substring(n) + l = l.substring(n) }var k = []; - m.replace(j, function(o, l) { - k.push({str:o, offset:n + l}); + l.replace(j, function(o, m) { + k.push({str:o, offset:n + m}); return o }); - for(m = k.length - 1;m >= 0;m--) { - var p = k[m]; - p = a.$rangeFromMatch(b, p.offset, p.str.length); + for(l = k.length - 1;l >= 0;l--) { + var p = k[l]; + p = a.$rangeFromMatch(d, p.offset, p.str.length); if(f(p)) { return true } @@ -1604,67 +1604,67 @@ define("ace/search", ["require", "exports", "module", "./lib/lang", "./lib/oop", }) }} }; - this.$rangeFromMatch = function(c, j, a) { - return new d(c, j, c, j + a) + this.$rangeFromMatch = function(b, j, a) { + return new c(b, j, b, j + a) }; this.$assembleRegExp = function() { - var c = this.$options.regExp ? this.$options.needle : g.escapeRegExp(this.$options.needle); + var b = this.$options.regExp ? this.$options.needle : g.escapeRegExp(this.$options.needle); if(this.$options.wholeWord) { - c = "\\b" + c + "\\b" + b = "\\b" + b + "\\b" }var j = "g"; this.$options.caseSensitive || (j += "i"); - return new RegExp(c, j) + return new RegExp(b, j) }; - this.$forwardLineIterator = function(c) { + this.$forwardLineIterator = function(b) { function j(o) { - var l = c.getLine(o); + var m = b.getLine(o); if(a && o == f.end.row) { - l = l.substring(0, f.end.column) - }return l + m = m.substring(0, f.end.column) + }return m } - var a = this.$options.scope == i.SELECTION, f = c.getSelection().getRange(), m = c.getSelection().getCursor(), n = a ? f.start.row : 0, b = a ? f.start.column : 0, k = a ? f.end.row : c.getLength() - 1, p = this.$options.wrap; + var a = this.$options.scope == i.SELECTION, f = b.getSelection().getRange(), l = b.getSelection().getCursor(), n = a ? f.start.row : 0, d = a ? f.start.column : 0, k = a ? f.end.row : b.getLength() - 1, p = this.$options.wrap; return{forEach:function(o) { - for(var l = m.row, r = j(l), q = m.column, s = false;!o(r, q, l);) { + for(var m = l.row, r = j(m), q = l.column, s = false;!o(r, q, m);) { if(s) { return - }l++; + }m++; q = 0; - if(l > k) { + if(m > k) { if(p) { - l = n; - q = b + m = n; + q = d }else { return } - }if(l == m.row) { + }if(m == l.row) { s = true - }r = j(l) + }r = j(m) } }} }; - this.$backwardLineIterator = function(c) { - var j = this.$options.scope == i.SELECTION, a = c.getSelection().getRange(), f = j ? a.end : a.start, m = j ? a.start.row : 0, n = j ? a.start.column : 0, b = j ? a.end.row : c.getLength() - 1, k = this.$options.wrap; + this.$backwardLineIterator = function(b) { + var j = this.$options.scope == i.SELECTION, a = b.getSelection().getRange(), f = j ? a.end : a.start, l = j ? a.start.row : 0, n = j ? a.start.column : 0, d = j ? a.end.row : b.getLength() - 1, k = this.$options.wrap; return{forEach:function(p) { - for(var o = f.row, l = c.getLine(o).substring(0, f.column), r = 0, q = false;!p(l, r, o);) { + for(var o = f.row, m = b.getLine(o).substring(0, f.column), r = 0, q = false;!p(m, r, o);) { if(q) { return }o--; r = 0; - if(o < m) { + if(o < l) { if(k) { - o = b + o = d }else { return } }if(o == f.row) { q = true - }l = c.getLine(o); + }m = b.getLine(o); if(j) { - if(o == m) { + if(o == l) { r = n }else { - if(o == b) { - l = l.substring(0, a.end.column) + if(o == d) { + m = m.substring(0, a.end.column) } } } @@ -1676,46 +1676,46 @@ define("ace/search", ["require", "exports", "module", "./lib/lang", "./lib/oop", }); define("ace/background_tokenizer", ["require", "exports", "module", "./lib/oop", "./event_emitter"], function(h) { var g = h("./lib/oop"), e = h("./event_emitter"); - h = function(d, i) { + h = function(c, i) { this.running = false; this.textLines = []; this.lines = []; this.currentLine = 0; - this.tokenizer = d; - var c = this; + this.tokenizer = c; + var b = this; this.$worker = function() { - if(c.running) { - for(var j = new Date, a = c.currentLine, f = c.textLines, m = 0, n = i.getLastVisibleRow();c.currentLine < f.length;) { - c.lines[c.currentLine] = c.$tokenizeRows(c.currentLine, c.currentLine)[0]; - c.currentLine++; - m += 1; - if(m % 5 == 0 && new Date - j > 20) { - c.fireUpdateEvent(a, c.currentLine - 1); - c.running = setTimeout(c.$worker, c.currentLine < n ? 20 : 100); + if(b.running) { + for(var j = new Date, a = b.currentLine, f = b.textLines, l = 0, n = i.getLastVisibleRow();b.currentLine < f.length;) { + b.lines[b.currentLine] = b.$tokenizeRows(b.currentLine, b.currentLine)[0]; + b.currentLine++; + l += 1; + if(l % 5 == 0 && new Date - j > 20) { + b.fireUpdateEvent(a, b.currentLine - 1); + b.running = setTimeout(b.$worker, b.currentLine < n ? 20 : 100); return } - }c.running = false; - c.fireUpdateEvent(a, f.length - 1) + }b.running = false; + b.fireUpdateEvent(a, f.length - 1) } } }; (function() { g.implement(this, e); - this.setTokenizer = function(d) { - this.tokenizer = d; + this.setTokenizer = function(c) { + this.tokenizer = c; this.lines = []; this.start(0) }; - this.setLines = function(d) { - this.textLines = d; + this.setLines = function(c) { + this.textLines = c; this.lines = []; this.stop() }; - this.fireUpdateEvent = function(d, i) { - this.$dispatchEvent("update", {data:{first:d, last:i}}) + this.fireUpdateEvent = function(c, i) { + this.$dispatchEvent("update", {data:{first:c, last:i}}) }; - this.start = function(d) { - this.currentLine = Math.min(d || 0, this.currentLine, this.textLines.length); + this.start = function(c) { + this.currentLine = Math.min(c || 0, this.currentLine, this.textLines.length); this.lines.splice(this.currentLine, this.lines.length); this.stop(); this.running = setTimeout(this.$worker, 700) @@ -1724,58 +1724,58 @@ define("ace/background_tokenizer", ["require", "exports", "module", "./lib/oop", this.running && clearTimeout(this.running); this.running = false }; - this.getTokens = function(d, i, c) { - c(this.$tokenizeRows(d, i)) + this.getTokens = function(c, i, b) { + b(this.$tokenizeRows(c, i)) }; - this.getState = function(d, i) { - i(this.$tokenizeRows(d, d)[0].state) + this.getState = function(c, i) { + i(this.$tokenizeRows(c, c)[0].state) }; - this.$tokenizeRows = function(d, i) { - var c = [], j = "start", a = false; - if(d > 0 && this.lines[d - 1]) { - j = this.lines[d - 1].state; + this.$tokenizeRows = function(c, i) { + var b = [], j = "start", a = false; + if(c > 0 && this.lines[c - 1]) { + j = this.lines[c - 1].state; a = true - }for(d = d;d <= i;d++) { - if(this.lines[d]) { - f = this.lines[d]; + }for(c = c;c <= i;c++) { + if(this.lines[c]) { + f = this.lines[c]; j = f.state; - c.push(f) + b.push(f) }else { - var f = this.tokenizer.getLineTokens(this.textLines[d] || "", j); + var f = this.tokenizer.getLineTokens(this.textLines[c] || "", j); j = f.state; - c.push(f); + b.push(f); if(a) { - this.lines[d] = f + this.lines[c] = f } } - }return c + }return b } }).call(h.prototype); return h }); define("ace/editor", ["require", "exports", "module", "./lib/oop", "./lib/event", "./lib/lang", "./textinput", "./keybinding", "./document", "./search", "./background_tokenizer", "./range", "./event_emitter"], function(h) { - var g = h("./lib/oop"), e = h("./lib/event"), d = h("./lib/lang"), i = h("./textinput"), c = h("./keybinding"), j = h("./document"), a = h("./search"), f = h("./background_tokenizer"), m = h("./range"), n = h("./event_emitter"); - h = function(b, k) { - var p = b.getContainerElement(); + var g = h("./lib/oop"), e = h("./lib/event"), c = h("./lib/lang"), i = h("./textinput"), b = h("./keybinding"), j = h("./document"), a = h("./search"), f = h("./background_tokenizer"), l = h("./range"), n = h("./event_emitter"); + h = function(d, k) { + var p = d.getContainerElement(); this.container = p; - this.renderer = b; + this.renderer = d; this.textInput = new i(p, this); - this.keyBinding = new c(p, this); + this.keyBinding = new b(p, this); var o = this; - e.addListener(p, "mousedown", function(l) { + e.addListener(p, "mousedown", function(m) { setTimeout(function() { o.focus() }); - return e.preventDefault(l) + return e.preventDefault(m) }); - e.addListener(p, "selectstart", function(l) { - return e.preventDefault(l) + e.addListener(p, "selectstart", function(m) { + return e.preventDefault(m) }); - b = b.getMouseEventTarget(); - e.addListener(b, "mousedown", d.bind(this.onMouseDown, this)); - e.addMultiMouseDownListener(b, 0, 2, 500, d.bind(this.onMouseDoubleClick, this)); - e.addMultiMouseDownListener(b, 0, 3, 600, d.bind(this.onMouseTripleClick, this)); - e.addMouseWheelListener(b, d.bind(this.onMouseWheel, this)); + d = d.getMouseEventTarget(); + e.addListener(d, "mousedown", c.bind(this.onMouseDown, this)); + e.addMultiMouseDownListener(d, 0, 2, 500, c.bind(this.onMouseDoubleClick, this)); + e.addMultiMouseDownListener(d, 0, 3, 600, c.bind(this.onMouseTripleClick, this)); + e.addMouseWheelListener(d, c.bind(this.onMouseWheel, this)); this.$highlightLineMarker = this.$selectionMarker = null; this.$blockScrolling = false; this.$search = (new a).set({wrap:true}); @@ -1787,14 +1787,14 @@ define("ace/editor", ["require", "exports", "module", "./lib/oop", "./lib/event" this.$forwardEvents = {gutterclick:1, gutterdblclick:1}; this.$originalAddEventListener = this.addEventListener; this.$originalRemoveEventListener = this.removeEventListener; - this.addEventListener = function(b, k) { - return this.$forwardEvents[b] ? this.renderer.addEventListener(b, k) : this.$originalAddEventListener(b, k) + this.addEventListener = function(d, k) { + return this.$forwardEvents[d] ? this.renderer.addEventListener(d, k) : this.$originalAddEventListener(d, k) }; - this.removeEventListener = function(b, k) { - return this.$forwardEvents[b] ? this.renderer.removeEventListener(b, k) : this.$originalRemoveEventListener(b, k) + this.removeEventListener = function(d, k) { + return this.$forwardEvents[d] ? this.renderer.removeEventListener(d, k) : this.$originalRemoveEventListener(d, k) }; - this.setDocument = function(b) { - if(this.doc != b) { + this.setDocument = function(d) { + if(this.doc != d) { if(this.doc) { this.doc.removeEventListener("change", this.$onDocumentChange); this.doc.removeEventListener("changeMode", this.$onDocumentModeChange); @@ -1804,21 +1804,21 @@ define("ace/editor", ["require", "exports", "module", "./lib/oop", "./lib/event" k.removeEventListener("changeCursor", this.$onCursorChange); k.removeEventListener("changeSelection", this.$onSelectionChange); this.doc.setScrollTopRow(this.renderer.getScrollTopRow()) - }this.doc = b; - this.$onDocumentChange = d.bind(this.onDocumentChange, this); - b.addEventListener("change", this.$onDocumentChange); - this.renderer.setDocument(b); - this.$onDocumentModeChange = d.bind(this.onDocumentModeChange, this); - b.addEventListener("changeMode", this.$onDocumentModeChange); - this.$onDocumentChangeTabSize = d.bind(this.renderer.updateText, this.renderer); - b.addEventListener("changeTabSize", this.$onDocumentChangeTabSize); - this.$onDocumentChangeBreakpoint = d.bind(this.onDocumentChangeBreakpoint, this); + }this.doc = d; + this.$onDocumentChange = c.bind(this.onDocumentChange, this); + d.addEventListener("change", this.$onDocumentChange); + this.renderer.setDocument(d); + this.$onDocumentModeChange = c.bind(this.onDocumentModeChange, this); + d.addEventListener("changeMode", this.$onDocumentModeChange); + this.$onDocumentChangeTabSize = c.bind(this.renderer.updateText, this.renderer); + d.addEventListener("changeTabSize", this.$onDocumentChangeTabSize); + this.$onDocumentChangeBreakpoint = c.bind(this.onDocumentChangeBreakpoint, this); this.doc.addEventListener("changeBreakpoint", this.$onDocumentChangeBreakpoint); - this.selection = b.getSelection(); + this.selection = d.getSelection(); this.$desiredColumn = 0; - this.$onCursorChange = d.bind(this.onCursorChange, this); + this.$onCursorChange = c.bind(this.onCursorChange, this); this.selection.addEventListener("changeCursor", this.$onCursorChange); - this.$onSelectionChange = d.bind(this.onSelectionChange, this); + this.$onSelectionChange = c.bind(this.onSelectionChange, this); this.selection.addEventListener("changeSelection", this.$onSelectionChange); this.onDocumentModeChange(); this.bgTokenizer.setLines(this.doc.lines); @@ -1826,7 +1826,7 @@ define("ace/editor", ["require", "exports", "module", "./lib/oop", "./lib/event" this.onCursorChange(); this.onSelectionChange(); this.onDocumentChangeBreakpoint(); - this.renderer.scrollToRow(b.getScrollTopRow()); + this.renderer.scrollToRow(d.getScrollTopRow()); this.renderer.updateFull() } }; @@ -1839,22 +1839,22 @@ define("ace/editor", ["require", "exports", "module", "./lib/oop", "./lib/event" this.resize = function() { this.renderer.onResize() }; - this.setTheme = function(b) { - this.renderer.setTheme(b) + this.setTheme = function(d) { + this.renderer.setTheme(d) }; this.$highlightBrackets = function() { if(this.$bracketHighlight) { this.renderer.removeMarker(this.$bracketHighlight); this.$bracketHighlight = null }if(!this.$highlightPending) { - var b = this; + var d = this; this.$highlightPending = true; setTimeout(function() { - b.$highlightPending = false; - var k = b.doc.findMatchingBracket(b.getCursorPosition()); + d.$highlightPending = false; + var k = d.doc.findMatchingBracket(d.getCursorPosition()); if(k) { - k = new m(k.row, k.column, k.row, k.column + 1); - b.$bracketHighlight = b.renderer.addMarker(k, "ace_bracket") + k = new l(k.row, k.column, k.row, k.column + 1); + d.$bracketHighlight = d.renderer.addMarker(k, "ace_bracket") } }, 10) } @@ -1873,15 +1873,15 @@ define("ace/editor", ["require", "exports", "module", "./lib/oop", "./lib/event" this.renderer.hideCursor(); this.renderer.visualizeBlur() }; - this.onDocumentChange = function(b) { - b = b.data; - this.bgTokenizer.start(b.firstRow); - this.renderer.updateLines(b.firstRow, b.lastRow); + this.onDocumentChange = function(d) { + d = d.data; + this.bgTokenizer.start(d.firstRow); + this.renderer.updateLines(d.firstRow, d.lastRow); this.renderer.updateCursor(this.getCursorPosition(), this.$overwrite) }; - this.onTokenizerUpdate = function(b) { - b = b.data; - this.renderer.updateLines(b.first, b.last) + this.onTokenizerUpdate = function(d) { + d = d.data; + this.renderer.updateLines(d.first, d.last) }; this.onCursorChange = function() { this.$highlightBrackets(); @@ -1893,59 +1893,59 @@ define("ace/editor", ["require", "exports", "module", "./lib/oop", "./lib/event" this.$highlightLineMarker && this.renderer.removeMarker(this.$highlightLineMarker); this.$highlightLineMarker = null; if(this.getHighlightActiveLine() && (this.getSelectionStyle() != "line" || !this.selection.isMultiLine())) { - var b = this.getCursorPosition(); - this.$highlightLineMarker = this.renderer.addMarker(new m(b.row, 0, b.row + 1, 0), "ace_active_line", "line") + var d = this.getCursorPosition(); + this.$highlightLineMarker = this.renderer.addMarker(new l(d.row, 0, d.row + 1, 0), "ace_active_line", "line") } }; this.onSelectionChange = function() { this.$selectionMarker && this.renderer.removeMarker(this.$selectionMarker); this.$selectionMarker = null; if(!this.selection.isEmpty()) { - var b = this.selection.getRange(), k = this.getSelectionStyle(); - this.$selectionMarker = this.renderer.addMarker(b, "ace_selection", k) + var d = this.selection.getRange(), k = this.getSelectionStyle(); + this.$selectionMarker = this.renderer.addMarker(d, "ace_selection", k) }this.onCursorChange() }; this.onDocumentChangeBreakpoint = function() { this.renderer.setBreakpoints(this.doc.getBreakpoints()) }; this.onDocumentModeChange = function() { - var b = this.doc.getMode(); - if(this.mode != b) { - this.mode = b; - b = b.getTokenizer(); + var d = this.doc.getMode(); + if(this.mode != d) { + this.mode = d; + d = d.getTokenizer(); if(this.bgTokenizer) { - this.bgTokenizer.setTokenizer(b) + this.bgTokenizer.setTokenizer(d) }else { - var k = d.bind(this.onTokenizerUpdate, this); - this.bgTokenizer = new f(b, this); + var k = c.bind(this.onTokenizerUpdate, this); + this.bgTokenizer = new f(d, this); this.bgTokenizer.addEventListener("update", k) }this.renderer.setTokenizer(this.bgTokenizer) } }; - this.onMouseDown = function(b) { - var k = e.getDocumentX(b), p = e.getDocumentY(b); + this.onMouseDown = function(d) { + var k = e.getDocumentX(d), p = e.getDocumentY(d); k = this.renderer.screenToTextCoordinates(k, p); k.row = Math.max(0, Math.min(k.row, this.doc.getLength() - 1)); - if(e.getButton(b) != 0) { + if(e.getButton(d) != 0) { this.selection.isEmpty() && this.moveCursorToPosition(k) }else { - if(b.shiftKey) { + if(d.shiftKey) { this.selection.selectToPosition(k) }else { this.moveCursorToPosition(k); this.$clickSelection || this.selection.clearSelection(k.row, k.column) }this.renderer.scrollCursorIntoView(); - var o = this, l, r; + var o = this, m, r; e.capture(this.container, function(s) { - l = e.getDocumentX(s); + m = e.getDocumentX(s); r = e.getDocumentY(s) }, function() { clearInterval(q); o.$clickSelection = null }); var q = setInterval(function() { - if(!(l === undefined || r === undefined)) { - var s = o.renderer.screenToTextCoordinates(l, r); + if(!(m === undefined || r === undefined)) { + var s = o.renderer.screenToTextCoordinates(m, r); s.row = Math.max(0, Math.min(s.row, o.doc.getLength() - 1)); if(o.$clickSelection) { if(o.$clickSelection.contains(s.row, s.column)) { @@ -1960,7 +1960,7 @@ define("ace/editor", ["require", "exports", "module", "./lib/oop", "./lib/event" }o.renderer.scrollCursorIntoView() } }, 20); - return e.preventDefault(b) + return e.preventDefault(d) } }; this.onMouseDoubleClick = function() { @@ -1973,10 +1973,10 @@ define("ace/editor", ["require", "exports", "module", "./lib/oop", "./lib/event" this.$clickSelection = this.getSelectionRange(); this.$updateDesiredColumn() }; - this.onMouseWheel = function(b) { + this.onMouseWheel = function(d) { var k = this.$scrollSpeed * 2; - this.renderer.scrollBy(b.wheelX * k, b.wheelY * k); - return e.preventDefault(b) + this.renderer.scrollBy(d.wheelX * k, d.wheelY * k); + return e.preventDefault(d) }; this.getCopyText = function() { return this.selection.isEmpty() ? "" : this.doc.getTextRange(this.getSelectionRange()) @@ -1989,14 +1989,14 @@ define("ace/editor", ["require", "exports", "module", "./lib/oop", "./lib/event" } } }; - this.onTextInput = function(b) { + this.onTextInput = function(d) { if(!this.$readOnly) { var k = this.getCursorPosition(); - b = b.replace("\t", this.doc.getTabString()); + d = d.replace("\t", this.doc.getTabString()); if(this.selection.isEmpty()) { if(this.$overwrite) { - var p = new m.fromPoints(k, k); - p.end.column += b.length; + var p = new l.fromPoints(k, k); + p.end.column += d.length; this.doc.remove(p) } }else { @@ -2004,8 +2004,8 @@ define("ace/editor", ["require", "exports", "module", "./lib/oop", "./lib/event" this.clearSelection() }this.clearSelection(); var o = this; - this.bgTokenizer.getState(k.row, function(l) { - var r = o.mode.checkOutdent(l, o.doc.getLine(k.row), b), q = o.doc.getLine(k.row), s = o.mode.getNextLineIndent(l, q, o.doc.getTabString()), t = o.doc.insert(k, b); + this.bgTokenizer.getState(k.row, function(m) { + var r = o.mode.checkOutdent(m, o.doc.getLine(k.row), d), q = o.doc.getLine(k.row), s = o.mode.getNextLineIndent(m, q, o.doc.getTabString()), t = o.doc.insert(k, d); o.bgTokenizer.getState(k.row, function(u) { if(k.row !== t.row) { u = o.doc.getTabSize(); @@ -2022,7 +2022,7 @@ define("ace/editor", ["require", "exports", "module", "./lib/oop", "./lib/event" break } } - }if(/[^\s]$/.test(q)) { + }if(/[^\s]/.test(q)) { y = Math.min(x, y) } }for(w = k.row + 1;w <= t.row;++w) { @@ -2036,8 +2036,8 @@ define("ace/editor", ["require", "exports", "module", "./lib/oop", "./lib/event" x -= 1 } } - }o.doc.replace(new m(w, 0, w, q.length), q.substr(v)) - }t.column += o.doc.indentRows(new m(k.row + 1, 0, t.row, t.column), s) + }o.doc.replace(new l(w, 0, w, q.length), q.substr(v)) + }t.column += o.doc.indentRows(new l(k.row + 1, 0, t.row, t.column), s) }else { if(r) { t.column += o.mode.autoOutdent(u, o.doc, k.row) @@ -2049,13 +2049,13 @@ define("ace/editor", ["require", "exports", "module", "./lib/oop", "./lib/event" } }; this.$overwrite = false; - this.setOverwrite = function(b) { - if(this.$overwrite != b) { - this.$overwrite = b; + this.setOverwrite = function(d) { + if(this.$overwrite != d) { + this.$overwrite = d; this.$blockScrolling = true; this.onCursorChange(); this.$blockScrolling = false; - this.$dispatchEvent("changeOverwrite", {data:b}) + this.$dispatchEvent("changeOverwrite", {data:d}) } }; this.getOverwrite = function() { @@ -2065,54 +2065,54 @@ define("ace/editor", ["require", "exports", "module", "./lib/oop", "./lib/event" this.setOverwrite(!this.$overwrite) }; this.$scrollSpeed = 1; - this.setScrollSpeed = function(b) { - this.$scrollSpeed = b + this.setScrollSpeed = function(d) { + this.$scrollSpeed = d }; this.getScrollSpeed = function() { return this.$scrollSpeed }; this.$selectionStyle = "line"; - this.setSelectionStyle = function(b) { - if(this.$selectionStyle != b) { - this.$selectionStyle = b; + this.setSelectionStyle = function(d) { + if(this.$selectionStyle != d) { + this.$selectionStyle = d; this.onSelectionChange(); - this.$dispatchEvent("changeSelectionStyle", {data:b}) + this.$dispatchEvent("changeSelectionStyle", {data:d}) } }; this.getSelectionStyle = function() { return this.$selectionStyle }; this.$highlightActiveLine = true; - this.setHighlightActiveLine = function(b) { - if(this.$highlightActiveLine != b) { - this.$highlightActiveLine = b; + this.setHighlightActiveLine = function(d) { + if(this.$highlightActiveLine != d) { + this.$highlightActiveLine = d; this.$updateHighlightActiveLine() } }; this.getHighlightActiveLine = function() { return this.$highlightActiveLine }; - this.setShowInvisibles = function(b) { - this.getShowInvisibles() != b && this.renderer.setShowInvisibles(b) + this.setShowInvisibles = function(d) { + this.getShowInvisibles() != d && this.renderer.setShowInvisibles(d) }; this.getShowInvisibles = function() { return this.renderer.getShowInvisibles() }; - this.setShowPrintMargin = function(b) { - this.renderer.setShowPrintMargin(b) + this.setShowPrintMargin = function(d) { + this.renderer.setShowPrintMargin(d) }; this.getShowPrintMargin = function() { return this.renderer.getShowPrintMargin() }; - this.setPrintMarginColumn = function(b) { - this.renderer.setPrintMarginColumn(b) + this.setPrintMarginColumn = function(d) { + this.renderer.setPrintMarginColumn(d) }; this.getPrintMarginColumn = function() { return this.renderer.getPrintMarginColumn() }; this.$readOnly = false; - this.setReadOnly = function(b) { - this.$readOnly = b + this.setReadOnly = function(d) { + this.$readOnly = d }; this.getReadOnly = function() { return this.$readOnly @@ -2133,31 +2133,33 @@ define("ace/editor", ["require", "exports", "module", "./lib/oop", "./lib/event" }; this.indent = function() { if(!this.$readOnly) { - var b = this.getSelectionRange(); - if(b.start.row < b.end.row || b.start.column < b.end.column) { - b = this.doc.indentRows(this.getSelectionRange(), "\t"); - this.selection.shiftSelection(b) + var d = this.doc, k = this.getSelectionRange(); + if(k.start.row < k.end.row || k.start.column < k.end.column) { + d = d.indentRows(this.getSelectionRange(), "\t"); + this.selection.shiftSelection(d) }else { if(this.doc.getUseSoftTabs()) { - b = this.doc.getTabSize(); - b = b - this.getCursorPosition().column % b; - b = d.stringRepeat(" ", b) + k = d.getTabSize(); + var p = this.getCursorPosition(); + d = d.documentToScreenColumn(p.row, p.column); + d = k - d % k; + d = c.stringRepeat(" ", d) }else { - b = "\t" - }return this.onTextInput(b) + d = "\t" + }return this.onTextInput(d) } } }; this.blockOutdent = function() { if(!this.$readOnly) { - var b = this.doc.getSelection(), k = this.doc.outdentRows(b.getRange()); - b.setSelectionRange(k, b.isBackwards()); + var d = this.doc.getSelection(), k = this.doc.outdentRows(d.getRange()); + d.setSelectionRange(k, d.isBackwards()); this.$updateDesiredColumn() } }; this.toggleCommentLines = function() { if(!this.$readOnly) { - var b = this.$getSelectedRows(), k = new m(b.first, 0, b.last, 0), p = this; + var d = this.$getSelectedRows(), k = new l(d.first, 0, d.last, 0), p = this; this.bgTokenizer.getState(this.getCursorPosition().row, function(o) { o = p.mode.toggleCommentLines(o, p.doc, k); p.selection.shiftSelection(o) @@ -2166,52 +2168,52 @@ define("ace/editor", ["require", "exports", "module", "./lib/oop", "./lib/event" }; this.removeLines = function() { if(!this.$readOnly) { - var b = this.$getSelectedRows(); - this.selection.setSelectionAnchor(b.last + 1, 0); - this.selection.selectTo(b.first, 0); + var d = this.$getSelectedRows(); + this.selection.setSelectionAnchor(d.last + 1, 0); + this.selection.selectTo(d.first, 0); this.doc.remove(this.getSelectionRange()); this.clearSelection() } }; this.moveLinesDown = function() { - this.$readOnly || this.$moveLines(function(b, k) { - return this.doc.moveLinesDown(b, k) + this.$readOnly || this.$moveLines(function(d, k) { + return this.doc.moveLinesDown(d, k) }) }; this.moveLinesUp = function() { - this.$readOnly || this.$moveLines(function(b, k) { - return this.doc.moveLinesUp(b, k) + this.$readOnly || this.$moveLines(function(d, k) { + return this.doc.moveLinesUp(d, k) }) }; this.copyLinesUp = function() { - this.$readOnly || this.$moveLines(function(b, k) { - this.doc.duplicateLines(b, k); + this.$readOnly || this.$moveLines(function(d, k) { + this.doc.duplicateLines(d, k); return 0 }) }; this.copyLinesDown = function() { - this.$readOnly || this.$moveLines(function(b, k) { - return this.doc.duplicateLines(b, k) + this.$readOnly || this.$moveLines(function(d, k) { + return this.doc.duplicateLines(d, k) }) }; - this.$moveLines = function(b) { - var k = this.$getSelectedRows(), p = b.call(this, k.first, k.last), o = this.selection; + this.$moveLines = function(d) { + var k = this.$getSelectedRows(), p = d.call(this, k.first, k.last), o = this.selection; o.setSelectionAnchor(k.last + p + 1, 0); o.$moveSelection(function() { o.moveCursorTo(k.first + p, 0) }) }; this.$getSelectedRows = function() { - var b = this.getSelectionRange(), k = b.start.row, p = b.end.row; - if(b.end.column == 0 && b.start.row !== b.end.row) { + var d = this.getSelectionRange(), k = d.start.row, p = d.end.row; + if(d.end.column == 0 && d.start.row !== d.end.row) { p -= 1 }return{first:k, last:p} }; this.onCompositionStart = function() { this.renderer.showComposition(this.getCursorPosition()) }; - this.onCompositionUpdate = function(b) { - this.renderer.setCompositionText(b) + this.onCompositionUpdate = function(d) { + this.renderer.setCompositionText(d) }; this.onCompositionEnd = function() { this.renderer.hideComposition() @@ -2222,8 +2224,8 @@ define("ace/editor", ["require", "exports", "module", "./lib/oop", "./lib/event" this.getLastVisibleRow = function() { return this.renderer.getLastVisibleRow() }; - this.isRowVisible = function(b) { - return b >= this.getFirstVisibleRow() && b <= this.getLastVisibleRow() + this.isRowVisible = function(d) { + return d >= this.getFirstVisibleRow() && d <= this.getLastVisibleRow() }; this.getVisibleRowCount = function() { return this.getLastVisibleRow() - this.getFirstVisibleRow() + 1 @@ -2232,19 +2234,19 @@ define("ace/editor", ["require", "exports", "module", "./lib/oop", "./lib/event" return this.renderer.getLastVisibleRow() - 1 }; this.getPageUpRow = function() { - var b = this.renderer.getFirstVisibleRow(), k = this.renderer.getLastVisibleRow(); - return b - (k - b) + 1 + var d = this.renderer.getFirstVisibleRow(), k = this.renderer.getLastVisibleRow(); + return d - (k - d) + 1 }; this.selectPageDown = function() { - var b = this.getPageDownRow() + Math.floor(this.getVisibleRowCount() / 2); + var d = this.getPageDownRow() + Math.floor(this.getVisibleRowCount() / 2); this.scrollPageDown(); var k = this.getSelection(); k.$moveSelection(function() { - k.moveCursorTo(b, k.getSelectionLead().column) + k.moveCursorTo(d, k.getSelectionLead().column) }) }; this.selectPageUp = function() { - var b = this.getLastVisibleRow() - this.getFirstVisibleRow(), k = this.getPageUpRow() + Math.round(b / 2); + var d = this.getLastVisibleRow() - this.getFirstVisibleRow(), k = this.getPageUpRow() + Math.round(d / 2); this.scrollPageUp(); var p = this.getSelection(); p.$moveSelection(function() { @@ -2252,14 +2254,14 @@ define("ace/editor", ["require", "exports", "module", "./lib/oop", "./lib/event" }) }; this.gotoPageDown = function() { - var b = this.getPageDownRow(), k = Math.min(this.getCursorPosition().column, this.doc.getLine(b).length); - this.scrollToRow(b); - this.getSelection().moveCursorTo(b, k) + var d = this.getPageDownRow(), k = Math.min(this.getCursorPosition().column, this.doc.getLine(d).length); + this.scrollToRow(d); + this.getSelection().moveCursorTo(d, k) }; this.gotoPageUp = function() { - var b = this.getPageUpRow(), k = Math.min(this.getCursorPosition().column, this.doc.getLine(b).length); - this.scrollToRow(b); - this.getSelection().moveCursorTo(b, k) + var d = this.getPageUpRow(), k = Math.min(this.getCursorPosition().column, this.doc.getLine(d).length); + this.scrollToRow(d); + this.getSelection().moveCursorTo(d, k) }; this.scrollPageDown = function() { this.scrollToRow(this.getPageDownRow()) @@ -2267,8 +2269,8 @@ define("ace/editor", ["require", "exports", "module", "./lib/oop", "./lib/event" this.scrollPageUp = function() { this.renderer.scrollToRow(this.getPageUpRow()) }; - this.scrollToRow = function(b) { - this.renderer.scrollToRow(b) + this.scrollToRow = function(d) { + this.renderer.scrollToRow(d) }; this.getCursorPosition = function() { return this.selection.getCursor() @@ -2280,45 +2282,45 @@ define("ace/editor", ["require", "exports", "module", "./lib/oop", "./lib/event" this.selection.clearSelection(); this.$updateDesiredColumn() }; - this.moveCursorTo = function(b, k) { - this.selection.moveCursorTo(b, k); + this.moveCursorTo = function(d, k) { + this.selection.moveCursorTo(d, k); this.$updateDesiredColumn() }; - this.moveCursorToPosition = function(b) { - this.selection.moveCursorToPosition(b); + this.moveCursorToPosition = function(d) { + this.selection.moveCursorToPosition(d); this.$updateDesiredColumn() }; - this.gotoLine = function(b, k) { + this.gotoLine = function(d, k) { this.selection.clearSelection(); this.$blockScrolling = true; - this.moveCursorTo(b - 1, k || 0); + this.moveCursorTo(d - 1, k || 0); this.$blockScrolling = false; - this.isRowVisible(this.getCursorPosition().row) || this.scrollToRow(b - 1 - Math.floor(this.getVisibleRowCount() / 2)) + this.isRowVisible(this.getCursorPosition().row) || this.scrollToRow(d - 1 - Math.floor(this.getVisibleRowCount() / 2)) }; - this.navigateTo = function(b, k) { + this.navigateTo = function(d, k) { this.clearSelection(); - this.moveCursorTo(b, k); + this.moveCursorTo(d, k); this.$updateDesiredColumn(k) }; this.navigateUp = function() { this.selection.clearSelection(); this.selection.moveCursorBy(-1, 0); if(this.$desiredColumn) { - var b = this.getCursorPosition(), k = this.doc.screenToDocumentColumn(b.row, this.$desiredColumn); - this.selection.moveCursorTo(b.row, k) + var d = this.getCursorPosition(), k = this.doc.screenToDocumentColumn(d.row, this.$desiredColumn); + this.selection.moveCursorTo(d.row, k) } }; this.navigateDown = function() { this.selection.clearSelection(); this.selection.moveCursorBy(1, 0); if(this.$desiredColumn) { - var b = this.getCursorPosition(), k = this.doc.screenToDocumentColumn(b.row, this.$desiredColumn); - this.selection.moveCursorTo(b.row, k) + var d = this.getCursorPosition(), k = this.doc.screenToDocumentColumn(d.row, this.$desiredColumn); + this.selection.moveCursorTo(d.row, k) } }; this.$updateDesiredColumn = function() { - var b = this.getCursorPosition(); - this.$desiredColumn = this.doc.documentToScreenColumn(b.row, b.column) + var d = this.getCursorPosition(); + this.$desiredColumn = this.doc.documentToScreenColumn(d.row, d.column) }; this.navigateLeft = function() { this.selection.isEmpty() ? this.selection.moveCursorLeft() : this.moveCursorToPosition(this.getSelectionRange().start); @@ -2352,30 +2354,30 @@ define("ace/editor", ["require", "exports", "module", "./lib/oop", "./lib/event" this.selection.moveCursorWordLeft(); this.clearSelection() }; - this.replace = function(b, k) { + this.replace = function(d, k) { k && this.$search.set(k); k = this.$search.find(this.doc); - this.$tryReplace(k, b); + this.$tryReplace(k, d); k !== null && this.selection.setSelectionRange(k); this.$updateDesiredColumn() }; - this.replaceAll = function(b, k) { + this.replaceAll = function(d, k) { k && this.$search.set(k); - this.clearSelection(); - this.selection.moveCursorTo(0, 0); k = this.$search.findAll(this.doc); if(k.length) { + this.clearSelection(); + this.selection.moveCursorTo(0, 0); for(var p = k.length - 1;p >= 0;--p) { - this.$tryReplace(k[p], b) + this.$tryReplace(k[p], d) }k[0] !== null && this.selection.setSelectionRange(k[0]); this.$updateDesiredColumn() } }; - this.$tryReplace = function(b, k) { - k = this.$search.replace(this.doc.getTextRange(b), k); + this.$tryReplace = function(d, k) { + k = this.$search.replace(this.doc.getTextRange(d), k); if(k !== null) { - b.end = this.doc.replace(b, k); - return b + d.end = this.doc.replace(d, k); + return d }else { return null } @@ -2383,34 +2385,34 @@ define("ace/editor", ["require", "exports", "module", "./lib/oop", "./lib/event" this.getLastSearchOptions = function() { return this.$search.getOptions() }; - this.find = function(b, k) { + this.find = function(d, k) { this.clearSelection(); k = k || {}; - k.needle = b; + k.needle = d; this.$search.set(k); this.$find() }; - this.findNext = function(b) { - b = b || {}; - if(typeof b.backwards == "undefined") { - b.backwards = false - }this.$search.set(b); + this.findNext = function(d) { + d = d || {}; + if(typeof d.backwards == "undefined") { + d.backwards = false + }this.$search.set(d); this.$find() }; - this.findPrevious = function(b) { - b = b || {}; - if(typeof b.backwards == "undefined") { - b.backwards = true - }this.$search.set(b); + this.findPrevious = function(d) { + d = d || {}; + if(typeof d.backwards == "undefined") { + d.backwards = true + }this.$search.set(d); this.$find() }; - this.$find = function(b) { + this.$find = function(d) { this.selection.isEmpty() || this.$search.set({needle:this.doc.getTextRange(this.getSelectionRange())}); - typeof b != "undefined" && this.$search.set({backwards:b}); - if(b = this.$search.find(this.doc)) { - this.gotoLine(b.end.row + 1, b.end.column); + typeof d != "undefined" && this.$search.set({backwards:d}); + if(d = this.$search.find(this.doc)) { + this.gotoLine(d.end.row + 1, d.end.column); this.$updateDesiredColumn(); - this.selection.setSelectionRange(b) + this.selection.setSelectionRange(d) } }; this.undo = function() { @@ -2471,8 +2473,8 @@ define("ace/layer/gutter", ["require", "exports", "module"], function() { }; this.update = function(g) { this.$config = g; - for(var e = [], d = g.firstRow;d <= g.lastRow;d++) { - e.push("
", d + 1, "
"); + for(var e = [], c = g.firstRow;c <= g.lastRow;c++) { + e.push("
", c + 1, "
"); e.push("") }this.element.innerHTML = e.join(""); this.element.style.height = g.minHeight + "px" @@ -2493,10 +2495,10 @@ define("ace/layer/marker", ["require", "exports", "module", "../range"], functio this.setDocument = function(e) { this.doc = e }; - this.addMarker = function(e, d, i) { - var c = this.$markerId++; - this.markers[c] = {range:e, type:i || "line", clazz:d}; - return c + this.addMarker = function(e, c, i) { + var b = this.$markerId++; + this.markers[b] = {range:e, type:i || "line", clazz:c}; + return b }; this.removeMarker = function(e) { this.markers[e] && delete this.markers[e] @@ -2504,121 +2506,121 @@ define("ace/layer/marker", ["require", "exports", "module", "../range"], functio this.update = function(e) { if(e = e || this.config) { this.config = e; - var d = []; + var c = []; for(var i in this.markers) { - var c = this.markers[i], j = c.range.clipRows(e.firstRow, e.lastRow); + var b = this.markers[i], j = b.range.clipRows(e.firstRow, e.lastRow); if(!j.isEmpty()) { if(j.isMultiLine()) { - c.type == "text" ? this.drawTextMarker(d, j, c.clazz, e) : this.drawMultiLineMarker(d, j, c.clazz, e) + b.type == "text" ? this.drawTextMarker(c, j, b.clazz, e) : this.drawMultiLineMarker(c, j, b.clazz, e) }else { - this.drawSingleLineMarker(d, j, c.clazz, e) + this.drawSingleLineMarker(c, j, b.clazz, e) } } - }this.element.innerHTML = d.join("") + }this.element.innerHTML = c.join("") } }; - this.drawTextMarker = function(e, d, i, c) { - var j = d.start.row, a = new g(j, d.start.column, j, this.doc.getLine(j).length); - this.drawSingleLineMarker(e, a, i, c); - j = d.end.row; - a = new g(j, 0, j, d.end.column); - this.drawSingleLineMarker(e, a, i, c); - for(j = d.start.row + 1;j < d.end.row;j++) { + this.drawTextMarker = function(e, c, i, b) { + var j = c.start.row, a = new g(j, c.start.column, j, this.doc.getLine(j).length); + this.drawSingleLineMarker(e, a, i, b); + j = c.end.row; + a = new g(j, 0, j, c.end.column); + this.drawSingleLineMarker(e, a, i, b); + for(j = c.start.row + 1;j < c.end.row;j++) { a.start.row = j; a.end.row = j; a.end.column = this.doc.getLine(j).length; - this.drawSingleLineMarker(e, a, i, c) + this.drawSingleLineMarker(e, a, i, b) } }; - this.drawMultiLineMarker = function(e, d, i, c) { - d = d.toScreenRange(this.doc); - var j = c.lineHeight, a = Math.round(c.width - d.start.column * c.characterWidth), f = (d.start.row - c.firstRow) * c.lineHeight, m = Math.round(d.start.column * c.characterWidth); - e.push("
"); - f = (d.end.row - c.firstRow) * c.lineHeight; - a = Math.round(d.end.column * c.characterWidth); + this.drawMultiLineMarker = function(e, c, i, b) { + c = c.toScreenRange(this.doc); + var j = b.lineHeight, a = Math.round(b.width - c.start.column * b.characterWidth), f = (c.start.row - b.firstRow) * b.lineHeight, l = Math.round(c.start.column * b.characterWidth); + e.push("
"); + f = (c.end.row - b.firstRow) * b.lineHeight; + a = Math.round(c.end.column * b.characterWidth); e.push("
"); - j = (d.end.row - d.start.row - 1) * c.lineHeight; + j = (c.end.row - c.start.row - 1) * b.lineHeight; if(!(j < 0)) { - f = (d.start.row + 1 - c.firstRow) * c.lineHeight; - e.push("
") + f = (c.start.row + 1 - b.firstRow) * b.lineHeight; + e.push("
") } }; - this.drawSingleLineMarker = function(e, d, i, c) { - d = d.toScreenRange(this.doc); - var j = c.lineHeight, a = Math.round((d.end.column - d.start.column) * c.characterWidth), f = (d.start.row - c.firstRow) * c.lineHeight; - d = Math.round(d.start.column * c.characterWidth); - e.push("
") + this.drawSingleLineMarker = function(e, c, i, b) { + c = c.toScreenRange(this.doc); + var j = b.lineHeight, a = Math.round((c.end.column - c.start.column) * b.characterWidth), f = (c.start.row - b.firstRow) * b.lineHeight; + c = Math.round(c.start.column * b.characterWidth); + e.push("
") } }).call(h.prototype); return h }); define("ace/lib/dom", ["require", "exports", "module", "./lang"], function(h) { var g = h("./lang"), e = {}; - e.setText = function(d, i) { - if(d.innerText !== undefined) { - d.innerText = i - }if(d.textContent !== undefined) { - d.textContent = i + e.setText = function(c, i) { + if(c.innerText !== undefined) { + c.innerText = i + }if(c.textContent !== undefined) { + c.textContent = i } }; - e.hasCssClass = function(d, i) { - d = d.className.split(/\s+/g); - return g.arrayIndexOf(d, i) !== -1 + e.hasCssClass = function(c, i) { + c = c.className.split(/\s+/g); + return g.arrayIndexOf(c, i) !== -1 }; - e.addCssClass = function(d, i) { - e.hasCssClass(d, i) || (d.className += " " + i) + e.addCssClass = function(c, i) { + e.hasCssClass(c, i) || (c.className += " " + i) }; - e.removeCssClass = function(d, i) { - for(var c = d.className.split(/\s+/g);;) { - var j = g.arrayIndexOf(c, i); + e.removeCssClass = function(c, i) { + for(var b = c.className.split(/\s+/g);;) { + var j = g.arrayIndexOf(b, i); if(j == -1) { break - }c.splice(j, 1) - }d.className = c.join(" ") + }b.splice(j, 1) + }c.className = b.join(" ") }; - e.importCssString = function(d, i) { + e.importCssString = function(c, i) { i = i || document; if(i.createStyleSheet) { - i.createStyleSheet().cssText = d + i.createStyleSheet().cssText = c }else { - var c = i.createElement("style"); - c.appendChild(i.createTextNode(d)); - i.getElementsByTagName("head")[0].appendChild(c) + var b = i.createElement("style"); + b.appendChild(i.createTextNode(c)); + i.getElementsByTagName("head")[0].appendChild(b) } }; - e.getInnerWidth = function(d) { - return parseInt(e.computedStyle(d, "paddingLeft")) + parseInt(e.computedStyle(d, "paddingRight")) + d.clientWidth + e.getInnerWidth = function(c) { + return parseInt(e.computedStyle(c, "paddingLeft")) + parseInt(e.computedStyle(c, "paddingRight")) + c.clientWidth }; - e.getInnerHeight = function(d) { - return parseInt(e.computedStyle(d, "paddingTop")) + parseInt(e.computedStyle(d, "paddingBottom")) + d.clientHeight + e.getInnerHeight = function(c) { + return parseInt(e.computedStyle(c, "paddingTop")) + parseInt(e.computedStyle(c, "paddingBottom")) + c.clientHeight }; - e.computedStyle = function(d, i) { - return window.getComputedStyle ? (window.getComputedStyle(d, "") || {})[i] || "" : d.currentStyle[i] + e.computedStyle = function(c, i) { + return window.getComputedStyle ? (window.getComputedStyle(c, "") || {})[i] || "" : c.currentStyle[i] }; e.scrollbarWidth = function() { - var d = document.createElement("p"); - d.style.width = "100%"; - d.style.height = "200px"; - var i = document.createElement("div"), c = i.style; - c.position = "absolute"; - c.left = "-10000px"; - c.overflow = "hidden"; - c.width = "200px"; - c.height = "150px"; - i.appendChild(d); + var c = document.createElement("p"); + c.style.width = "100%"; + c.style.height = "200px"; + var i = document.createElement("div"), b = i.style; + b.position = "absolute"; + b.left = "-10000px"; + b.overflow = "hidden"; + b.width = "200px"; + b.height = "150px"; + i.appendChild(c); document.body.appendChild(i); - var j = d.offsetWidth; - c.overflow = "scroll"; - d = d.offsetWidth; - if(j == d) { - d = i.clientWidth + var j = c.offsetWidth; + b.overflow = "scroll"; + c = c.offsetWidth; + if(j == c) { + c = i.clientWidth }document.body.removeChild(i); - return j - d + return j - c }; return e }); define("ace/layer/text", ["require", "exports", "module", "../lib/oop", "../lib/dom", "../event_emitter"], function(h) { - var g = h("../lib/oop"), e = h("../lib/dom"), d = h("../event_emitter"); + var g = h("../lib/oop"), e = h("../lib/dom"), c = h("../event_emitter"); h = function(i) { this.element = document.createElement("div"); this.element.className = "ace_layer ace_text-layer"; @@ -2627,7 +2629,7 @@ define("ace/layer/text", ["require", "exports", "module", "../lib/oop", "../lib/ this.$pollSizeChanges() }; (function() { - g.implement(this, d); + g.implement(this, c); this.EOF_CHAR = "¶"; this.EOL_CHAR = "¬"; this.TAB_CHAR = "→"; @@ -2644,29 +2646,29 @@ define("ace/layer/text", ["require", "exports", "module", "../lib/oop", "../lib/ this.$pollSizeChanges = function() { var i = this; setInterval(function() { - var c = i.$measureSizes(); - if(i.$characterSize.width !== c.width || i.$characterSize.height !== c.height) { - i.$characterSize = c; - i.$dispatchEvent("changeCharaterSize", {data:c}) + var b = i.$measureSizes(); + if(i.$characterSize.width !== b.width || i.$characterSize.height !== b.height) { + i.$characterSize = b; + i.$dispatchEvent("changeCharaterSize", {data:b}) } }, 500) }; this.$fontStyles = {fontFamily:1, fontSize:1, fontWeight:1, fontStyle:1, lineHeight:1}; this.$measureSizes = function() { - var i = document.createElement("div"), c = i.style; - c.width = c.height = "auto"; - c.left = c.top = "-1000px"; - c.visibility = "hidden"; - c.position = "absolute"; - c.overflow = "visible"; + var i = document.createElement("div"), b = i.style; + b.width = b.height = "auto"; + b.left = b.top = "-1000px"; + b.visibility = "hidden"; + b.position = "absolute"; + b.overflow = "visible"; for(var j in this.$fontStyles) { var a = e.computedStyle(this.element, j); - c[j] = a + b[j] = a }i.innerHTML = (new Array(1E3)).join("Xy"); document.body.insertBefore(i, document.body.firstChild); - c = {height:i.offsetHeight, width:i.offsetWidth / 2E3}; + b = {height:i.offsetHeight, width:i.offsetWidth / 2E3}; document.body.removeChild(i); - return c + return b }; this.setDocument = function(i) { this.doc = i @@ -2684,30 +2686,31 @@ define("ace/layer/text", ["require", "exports", "module", "../lib/oop", "../lib/ this.$tabString = (new Array(i + 1)).join(" ") } }; - this.updateLines = function(i, c, j) { + this.updateLines = function(i, b, j) { this.$computeTabString(); - var a = Math.max(c, i.firstRow), f = Math.min(j, i.lastRow), m = this.element.childNodes, n = this; - this.tokenizer.getTokens(a, f, function(b) { + this.config = i; + var a = Math.max(b, i.firstRow), f = Math.min(j, i.lastRow), l = this.element.childNodes, n = this; + this.tokenizer.getTokens(a, f, function(d) { for(var k = a;k <= f;k++) { - var p = m[k - i.firstRow]; + var p = l[k - i.firstRow]; if(p) { var o = []; - n.$renderLine(o, k, b[k - a].tokens); + n.$renderLine(o, k, d[k - a].tokens); p.innerHTML = o.join("") } } }) }; this.scrollLines = function(i) { - function c(b) { + function b(d) { i.firstRow < f.firstRow ? a.$renderLinesFragment(i, i.firstRow, f.firstRow - 1, function(k) { - m.firstChild ? m.insertBefore(k, m.firstChild) : m.appendChild(k); - b() - }) : b() + l.firstChild ? l.insertBefore(k, l.firstChild) : l.appendChild(k); + d() + }) : d() } function j() { - i.lastRow > f.lastRow && a.$renderLinesFragment(i, f.lastRow + 1, i.lastRow, function(b) { - m.appendChild(b) + i.lastRow > f.lastRow && a.$renderLinesFragment(i, f.lastRow + 1, i.lastRow, function(d) { + l.appendChild(d) }) } var a = this; @@ -2718,28 +2721,28 @@ define("ace/layer/text", ["require", "exports", "module", "../lib/oop", "../lib/ return this.update(i) }if(i.lastRow < f.firstRow) { return this.update(i) - }var m = this.element; + }var l = this.element; if(f.firstRow < i.firstRow) { for(var n = f.firstRow;n < i.firstRow;n++) { - m.removeChild(m.firstChild) + l.removeChild(l.firstChild) } }if(f.lastRow > i.lastRow) { for(n = i.lastRow + 1;n <= f.lastRow;n++) { - m.removeChild(m.lastChild) + l.removeChild(l.lastChild) } - }c(j) + }b(j) }; - this.$renderLinesFragment = function(i, c, j, a) { - var f = document.createDocumentFragment(), m = this; - this.tokenizer.getTokens(c, j, function(n) { - for(var b = c;b <= j;b++) { + this.$renderLinesFragment = function(i, b, j, a) { + var f = document.createDocumentFragment(), l = this; + this.tokenizer.getTokens(b, j, function(n) { + for(var d = b;d <= j;d++) { var k = document.createElement("div"); k.className = "ace_line"; var p = k.style; - p.height = m.$characterSize.height + "px"; + p.height = l.$characterSize.height + "px"; p.width = i.width + "px"; p = []; - m.$renderLine(p, b, n[b - c].tokens); + l.$renderLine(p, d, n[d - b].tokens); k.innerHTML = p.join(""); f.appendChild(k) }a(f) @@ -2747,27 +2750,28 @@ define("ace/layer/text", ["require", "exports", "module", "../lib/oop", "../lib/ }; this.update = function(i) { this.$computeTabString(); - var c = [], j = this; + this.config = i; + var b = [], j = this; this.tokenizer.getTokens(i.firstRow, i.lastRow, function(a) { for(var f = i.firstRow;f <= i.lastRow;f++) { - c.push("
"); - j.$renderLine(c, f, a[f - i.firstRow].tokens); - c.push("
") - }j.element.innerHTML = c.join("") + b.push("
"); + j.$renderLine(b, f, a[f - i.firstRow].tokens); + b.push("
") + }j.element.innerHTML = b.join("") }) }; this.$textToken = {text:true, rparen:true, lparen:true}; - this.$renderLine = function(i, c, j) { + this.$renderLine = function(i, b, j) { for(var a = /[\v\f \u00a0\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u200b\u2028\u2029\u3000]/g, f = 0;f < j.length;f++) { - var m = j[f], n = m.value.replace(/&/g, "&").replace(/", n, "") + l = "ace_" + l.type.replace(/\./g, " ace_"); + i.push("", n, "") } }if(this.$showInvisibles) { - c !== this.doc.getLength() - 1 ? i.push("" + this.EOL_CHAR + "") : i.push("" + this.EOF_CHAR + "") + b !== this.doc.getLength() - 1 ? i.push("" + this.EOL_CHAR + "") : i.push("" + this.EOF_CHAR + "") } } }).call(h.prototype); @@ -2787,9 +2791,9 @@ define("ace/layer/cursor", ["require", "exports", "module", "../lib/dom"], funct this.setDocument = function(e) { this.doc = e }; - this.setCursor = function(e, d) { + this.setCursor = function(e, c) { this.position = {row:e.row, column:this.doc.documentToScreenColumn(e.row, e.column)}; - d ? g.addCssClass(this.cursor, "ace_overwrite") : g.removeCssClass(this.cursor, "ace_overwrite") + c ? g.addCssClass(this.cursor, "ace_overwrite") : g.removeCssClass(this.cursor, "ace_overwrite") }; this.hideCursor = function() { this.isVisible = false; @@ -2823,9 +2827,9 @@ define("ace/layer/cursor", ["require", "exports", "module", "../lib/dom"], funct this.update = function(e) { if(this.position) { this.config = e; - var d = Math.round(this.position.column * e.characterWidth), i = this.position.row * e.lineHeight; - this.pixelPos = {left:d, top:i}; - this.cursor.style.left = d + "px"; + var c = Math.round(this.position.column * e.characterWidth), i = this.position.row * e.lineHeight; + this.pixelPos = {left:c, top:i}; + this.cursor.style.left = c + "px"; this.cursor.style.top = i - e.firstRow * e.lineHeight + "px"; this.cursor.style.width = e.characterWidth + "px"; this.cursor.style.height = e.lineHeight + "px"; @@ -2837,19 +2841,19 @@ define("ace/layer/cursor", ["require", "exports", "module", "../lib/dom"], funct return h }); define("ace/scrollbar", ["require", "exports", "module", "./lib/oop", "./lib/lang", "./lib/dom", "./lib/event", "./event_emitter"], function(h) { - var g = h("./lib/oop"), e = h("./lib/lang"), d = h("./lib/dom"), i = h("./lib/event"), c = h("./event_emitter"); + var g = h("./lib/oop"), e = h("./lib/lang"), c = h("./lib/dom"), i = h("./lib/event"), b = h("./event_emitter"); h = function(j) { this.element = document.createElement("div"); this.element.className = "ace_sb"; this.inner = document.createElement("div"); this.element.appendChild(this.inner); j.appendChild(this.element); - this.width = d.scrollbarWidth(); + this.width = c.scrollbarWidth(); this.element.style.width = this.width; i.addListener(this.element, "scroll", e.bind(this.onScroll, this)) }; (function() { - g.implement(this, c); + g.implement(this, b); this.onScroll = function() { this.$dispatchEvent("scroll", {data:this.element.scrollTop}) }; @@ -2880,11 +2884,12 @@ define("ace/renderloop", ["require", "exports", "module", "./lib/event"], functi this.changes |= e; if(!this.pending) { this.pending = true; - var d = this; + var c = this; this.setTimeoutZero(function() { - d.pending = false; - d.onRender(d.changes); - d.changes = 0 + c.pending = false; + var i = c.changes; + c.changes = 0; + c.onRender(i) }) } }; @@ -2892,11 +2897,11 @@ define("ace/renderloop", ["require", "exports", "module", "./lib/event"], functi this.messageName = "zero-timeout-message"; this.setTimeoutZero = function(e) { if(!this.attached) { - var d = this; + var c = this; g.addListener(window, "message", function(i) { - if(i.source == window && d.callback && i.data == d.messageName) { + if(i.source == window && c.callback && i.data == c.messageName) { g.stopPropagation(i); - d.callback() + c.callback() } }); this.attached = true @@ -2912,32 +2917,32 @@ define("ace/renderloop", ["require", "exports", "module", "./lib/event"], functi return h }); define("ace/virtual_renderer", ["require", "exports", "module", 'text!ace/css/editor.css!.ace_editor {\n position: absolute;\n overflow: hidden;\n\n font-family: "Menlo", "Monaco", "Courier New", monospace;\n font-size: 12px; \n}\n\n.ace_scroller {\n position: absolute;\n overflow-x: scroll;\n overflow-y: hidden; \n}\n\n.ace_gutter {\n position: absolute;\n overflow-x: hidden;\n overflow-y: hidden;\n height: 100%;\n}\n\n.ace_editor .ace_sb {\n position: absolute;\n overflow-x: hidden;\n overflow-y: scroll;\n right: 0;\n}\n\n.ace_editor .ace_sb div {\n position: absolute;\n width: 1px;\n left: 0px;\n}\n\n.ace_editor .ace_printMargin {\n position: absolute;\n height: 100%;\n}\n\n.ace_layer {\n z-index: 0;\n position: absolute;\n overflow: hidden; \n white-space: nowrap;\n height: 100%;\n}\n\n.ace_text-layer {\n font-family: Monaco, "Courier New", monospace;\n color: black;\n}\n\n.ace_cursor-layer {\n cursor: text;\n}\n\n.ace_cursor {\n z-index: 3;\n position: absolute;\n}\n\n.ace_line {\n white-space: nowrap;\n}\n\n.ace_marker-layer {\n}\n\n.ace_marker-layer .ace_step {\n position: absolute;\n z-index: 2;\n}\n\n.ace_marker-layer .ace_selection {\n position: absolute;\n z-index: 3;\n}\n\n.ace_marker-layer .ace_bracket {\n position: absolute;\n z-index: 4;\n}\n\n.ace_marker-layer .ace_active_line {\n position: absolute;\n z-index: 1;\n}', -"./lib/oop", "./lib/oop", "./lib/event", "./layer/gutter", "./layer/marker", "./layer/text", "./layer/cursor", "./scrollbar", "./renderloop", "./event_emitter"], function(h, g, e, d) { - var i = h("./lib/oop"), c = h("./lib/lang"), j = h("./lib/dom"), a = h("./lib/event"), f = h("./layer/gutter"), m = h("./layer/marker"), n = h("./layer/text"), b = h("./layer/cursor"), k = h("./scrollbar"), p = h("./renderloop"), o = h("./event_emitter"); - j.importCssString(d); - g = function(l, r) { - this.container = l; +"./lib/oop", "./lib/oop", "./lib/event", "./layer/gutter", "./layer/marker", "./layer/text", "./layer/cursor", "./scrollbar", "./renderloop", "./event_emitter"], function(h, g, e, c) { + var i = h("./lib/oop"), b = h("./lib/lang"), j = h("./lib/dom"), a = h("./lib/event"), f = h("./layer/gutter"), l = h("./layer/marker"), n = h("./layer/text"), d = h("./layer/cursor"), k = h("./scrollbar"), p = h("./renderloop"), o = h("./event_emitter"); + j.importCssString(c); + g = function(m, r) { + this.container = m; j.addCssClass(this.container, "ace_editor"); this.setTheme(r); - this.scroller = document.createElement("div"); - this.scroller.className = "ace_scroller"; - this.container.appendChild(this.scroller); this.$gutter = document.createElement("div"); this.$gutter.className = "ace_gutter"; this.container.appendChild(this.$gutter); + this.scroller = document.createElement("div"); + this.scroller.className = "ace_scroller"; + this.container.appendChild(this.scroller); this.content = document.createElement("div"); this.content.style.position = "absolute"; this.scroller.appendChild(this.content); this.$gutterLayer = new f(this.$gutter); - this.$markerLayer = new m(this.content); + this.$markerLayer = new l(this.content); var q = this.$textLayer = new n(this.content); this.canvas = q.element; this.characterWidth = q.getCharacterWidth(); this.lineHeight = q.getLineHeight(); - this.$cursorLayer = new b(this.content); + this.$cursorLayer = new d(this.content); this.layers = [this.$markerLayer, q, this.$cursorLayer]; - this.scrollBar = new k(l); - this.scrollBar.addEventListener("scroll", c.bind(this.onScroll, this)); + this.scrollBar = new k(m); + this.scrollBar.addEventListener("scroll", b.bind(this.onScroll, this)); this.scrollTop = 0; this.cursorPos = {row:0, column:0}; var s = this; @@ -2946,10 +2951,10 @@ define("ace/virtual_renderer", ["require", "exports", "module", 'text!ace/css/ed s.lineHeight = q.getLineHeight(); s.$loop.schedule(s.CHANGE_FULL) }); - a.addListener(this.$gutter, "click", c.bind(this.$onGutterClick, this)); - a.addListener(this.$gutter, "dblclick", c.bind(this.$onGutterClick, this)); + a.addListener(this.$gutter, "click", b.bind(this.$onGutterClick, this)); + a.addListener(this.$gutter, "dblclick", b.bind(this.$onGutterClick, this)); this.$size = {width:0, height:0, scrollerHeight:0, scrollerWidth:0}; - this.$loop = new p(c.bind(this.$renderChanges, this)); + this.$loop = new p(b.bind(this.$renderChanges, this)); this.$loop.schedule(this.CHANGE_FULL); this.$updatePrintMargin(); this.setPadding(4) @@ -2965,25 +2970,25 @@ define("ace/virtual_renderer", ["require", "exports", "module", 'text!ace/css/ed this.CHANGE_SIZE = 64; this.CHANGE_FULL = 128; i.implement(this, o); - this.setDocument = function(l) { - this.lines = l.lines; - this.doc = l; - this.$cursorLayer.setDocument(l); - this.$markerLayer.setDocument(l); - this.$textLayer.setDocument(l); + this.setDocument = function(m) { + this.lines = m.lines; + this.doc = m; + this.$cursorLayer.setDocument(m); + this.$markerLayer.setDocument(m); + this.$textLayer.setDocument(m); this.$loop.schedule(this.CHANGE_FULL) }; - this.updateLines = function(l, r) { + this.updateLines = function(m, r) { if(r === undefined) { r = Infinity }if(this.$changedLines) { - if(this.$changedLines.firstRow > l) { - this.$changedLines.firstRow = l + if(this.$changedLines.firstRow > m) { + this.$changedLines.firstRow = m }if(this.$changedLines.lastRow < r) { this.$changedLines.lastRow = r } }else { - this.$changedLines = {firstRow:l, lastRow:r} + this.$changedLines = {firstRow:m, lastRow:r} }this.$loop.schedule(this.CHANGE_LINES) }; this.updateText = function() { @@ -2994,61 +2999,61 @@ define("ace/virtual_renderer", ["require", "exports", "module", 'text!ace/css/ed }; this.onResize = function() { this.$loop.schedule(this.CHANGE_SIZE); - var l = j.getInnerHeight(this.container); - if(this.$size.height != l) { - this.$size.height = l; - this.scroller.style.height = l + "px"; - this.scrollBar.setHeight(l); + var m = j.getInnerHeight(this.container); + if(this.$size.height != m) { + this.$size.height = m; + this.scroller.style.height = m + "px"; + this.scrollBar.setHeight(m); if(this.doc) { this.scrollToY(this.getScrollTop()); this.$loop.schedule(this.CHANGE_FULL) } - }l = j.getInnerWidth(this.container); - if(this.$size.width != l) { - this.$size.width = l; + }m = j.getInnerWidth(this.container); + if(this.$size.width != m) { + this.$size.width = m; var r = this.showGutter ? this.$gutter.offsetWidth : 0; this.scroller.style.left = r + "px"; - this.scroller.style.width = Math.max(0, l - r - this.scrollBar.getWidth()) + "px" + this.scroller.style.width = Math.max(0, m - r - this.scrollBar.getWidth()) + "px" }this.$size.scrollerWidth = this.scroller.clientWidth; this.$size.scrollerHeight = this.scroller.clientHeight }; - this.setTokenizer = function(l) { - this.$tokenizer = l; - this.$textLayer.setTokenizer(l); + this.setTokenizer = function(m) { + this.$tokenizer = m; + this.$textLayer.setTokenizer(m); this.$loop.schedule(this.CHANGE_TEXT) }; - this.$onGutterClick = function(l) { - var r = a.getDocumentX(l), q = a.getDocumentY(l); - this.$dispatchEvent("gutter" + l.type, {row:this.screenToTextCoordinates(r, q).row, htmlEvent:l}) + this.$onGutterClick = function(m) { + var r = a.getDocumentX(m), q = a.getDocumentY(m); + this.$dispatchEvent("gutter" + m.type, {row:this.screenToTextCoordinates(r, q).row, htmlEvent:m}) }; this.$showInvisibles = true; - this.setShowInvisibles = function(l) { - this.$showInvisibles = l; - this.$textLayer.setShowInvisibles(l); + this.setShowInvisibles = function(m) { + this.$showInvisibles = m; + this.$textLayer.setShowInvisibles(m); this.$loop.schedule(this.CHANGE_TEXT) }; this.getShowInvisibles = function() { return this.$showInvisibles }; this.$showPrintMargin = true; - this.setShowPrintMargin = function(l) { - this.$showPrintMargin = l; + this.setShowPrintMargin = function(m) { + this.$showPrintMargin = m; this.$updatePrintMargin() }; this.getShowPrintMargin = function() { return this.$showPrintMargin }; this.$printMarginColumn = 80; - this.setPrintMarginColumn = function(l) { - this.$printMarginColumn = l; + this.setPrintMarginColumn = function(m) { + this.$printMarginColumn = m; this.$updatePrintMargin() }; this.getPrintMarginColumn = function() { return this.$printMarginColumn }; - this.setShowGutter = function(l) { - this.$gutter.style.display = l ? "block" : "none"; - this.showGutter = l; + this.setShowGutter = function(m) { + this.$gutter.style.display = m ? "block" : "none"; + this.showGutter = m; this.onResize() }; this.$updatePrintMargin = function() { @@ -3057,9 +3062,9 @@ define("ace/virtual_renderer", ["require", "exports", "module", 'text!ace/css/ed this.$printMarginEl = document.createElement("div"); this.$printMarginEl.className = "ace_printMargin"; this.content.insertBefore(this.$printMarginEl, this.$textLayer.element) - }var l = this.$printMarginEl.style; - l.left = this.characterWidth * this.$printMarginColumn + "px"; - l.visibility = this.$showPrintMargin ? "visible" : "hidden" + }var m = this.$printMarginEl.style; + m.left = this.characterWidth * this.$printMarginColumn + "px"; + m.visibility = this.$showPrintMargin ? "visible" : "hidden" } }; this.getContainerElement = function() { @@ -3085,117 +3090,112 @@ define("ace/virtual_renderer", ["require", "exports", "module", 'text!ace/css/ed return(this.layerConfig || {}).lastRow || 0 }; this.$padding = null; - this.setPadding = function(l) { - this.$padding = l; - this.content.style.padding = "0 " + l + "px"; + this.setPadding = function(m) { + this.$padding = m; + this.content.style.padding = "0 " + m + "px"; this.$loop.schedule(this.CHANGE_FULL) }; - this.onScroll = function(l) { - this.scrollToY(l.data) + this.onScroll = function(m) { + this.scrollToY(m.data) }; this.$updateScrollBar = function() { this.scrollBar.setInnerHeight(this.doc.getLength() * this.lineHeight); this.scrollBar.setScrollTop(this.scrollTop) }; - this.$renderChanges = function(l) { - if(!(!l || !this.doc || !this.$tokenizer)) { - if(!this.layerConfig || l & this.CHANGE_FULL || l & this.CHANGE_SIZE || l & this.CHANGE_TEXT || l & this.CHANGE_LINES || l & this.CHANGE_SCROLL) { + this.$renderChanges = function(m) { + if(!(!m || !this.doc || !this.$tokenizer)) { + if(!this.layerConfig || m & this.CHANGE_FULL || m & this.CHANGE_SIZE || m & this.CHANGE_TEXT || m & this.CHANGE_LINES || m & this.CHANGE_SCROLL) { this.$computeLayerConfig() - }if(l & this.CHANGE_FULL) { + }if(m & this.CHANGE_FULL) { this.$textLayer.update(this.layerConfig); this.showGutter && this.$gutterLayer.update(this.layerConfig); this.$markerLayer.update(this.layerConfig); this.$cursorLayer.update(this.layerConfig); this.$updateScrollBar() }else { - if(l & this.CHANGE_SCROLL) { - l & this.CHANGE_TEXT || l & this.CHANGE_LINES ? this.$textLayer.scrollLines(this.layerConfig) : this.$textLayer.update(this.layerConfig); + if(m & this.CHANGE_SCROLL) { + m & this.CHANGE_TEXT || m & this.CHANGE_LINES ? this.$textLayer.update(this.layerConfig) : this.$textLayer.scrollLines(this.layerConfig); this.showGutter && this.$gutterLayer.update(this.layerConfig); this.$markerLayer.update(this.layerConfig); this.$cursorLayer.update(this.layerConfig); this.$updateScrollBar() }else { - if(l & this.CHANGE_TEXT) { + if(m & this.CHANGE_TEXT) { this.$textLayer.update(this.layerConfig); this.showGutter && this.$gutterLayer.update(this.layerConfig) }else { - if(l & this.CHANGE_LINES) { + if(m & this.CHANGE_LINES) { this.$updateLines(); this.$updateScrollBar() - }else { - if(l & this.CHANGE_SCROLL) { - this.$textLayer.scrollLines(this.layerConfig); - this.showGutter && this.$gutterLayer.update(this.layerConfig) - } } - }l & this.CHANGE_GUTTER && this.showGutter && this.$gutterLayer.update(this.layerConfig); - l & this.CHANGE_CURSOR && this.$cursorLayer.update(this.layerConfig); - l & this.CHANGE_MARKER && this.$markerLayer.update(this.layerConfig); - l & this.CHANGE_SIZE && this.$updateScrollBar() + }m & this.CHANGE_GUTTER && this.showGutter && this.$gutterLayer.update(this.layerConfig); + m & this.CHANGE_CURSOR && this.$cursorLayer.update(this.layerConfig); + m & this.CHANGE_MARKER && this.$markerLayer.update(this.layerConfig); + m & this.CHANGE_SIZE && this.$updateScrollBar() } } } }; this.$computeLayerConfig = function() { - var l = this.scrollTop % this.lineHeight, r = this.$size.scrollerHeight + this.lineHeight, q = this.$getLongestLine(), s = !this.layerConfig ? true : this.layerConfig.width != q, t = Math.ceil(r / this.lineHeight), u = Math.max(0, Math.round((this.scrollTop - l) / this.lineHeight)); + var m = this.scrollTop % this.lineHeight, r = this.$size.scrollerHeight + this.lineHeight, q = this.$getLongestLine(), s = !this.layerConfig ? true : this.layerConfig.width != q, t = Math.ceil(r / this.lineHeight), u = Math.max(0, Math.round((this.scrollTop - m) / this.lineHeight)); t = Math.min(this.lines.length, u + t) - 1; - this.layerConfig = {width:q, padding:this.$padding, firstRow:u, lastRow:t, lineHeight:this.lineHeight, characterWidth:this.characterWidth, minHeight:r, offset:l, height:this.$size.scrollerHeight}; + this.layerConfig = {width:q, padding:this.$padding, firstRow:u, lastRow:t, lineHeight:this.lineHeight, characterWidth:this.characterWidth, minHeight:r, offset:m, height:this.$size.scrollerHeight}; for(u = 0;u < this.layers.length;u++) { t = this.layers[u]; if(s) { t.element.style.width = q + "px" } - }this.$gutterLayer.element.style.marginTop = -l + "px"; - this.content.style.marginTop = -l + "px"; + }this.$gutterLayer.element.style.marginTop = -m + "px"; + this.content.style.marginTop = -m + "px"; this.content.style.width = q + "px"; this.content.style.height = r + "px" }; this.$updateLines = function() { - var l = this.$changedLines.firstRow, r = this.$changedLines.lastRow; + var m = this.$changedLines.firstRow, r = this.$changedLines.lastRow; this.$changedLines = null; var q = this.layerConfig; if(q.width != this.$getLongestLine()) { return this.$textLayer.update(q) - }if(!(l > q.lastRow + 1)) { + }if(!(m > q.lastRow + 1)) { if(!(r < q.firstRow)) { if(r === Infinity) { this.showGutter && this.$gutterLayer.update(q); this.$textLayer.update(q) }else { - this.$textLayer.updateLines(q, l, r) + this.$textLayer.updateLines(q, m, r) } } } }; this.$getLongestLine = function() { - var l = this.doc.getScreenWidth(); + var m = this.doc.getScreenWidth(); if(this.$showInvisibles) { - l += 1 - }return Math.max(this.$size.scrollerWidth - this.$padding * 2, Math.round(l * this.characterWidth)) + m += 1 + }return Math.max(this.$size.scrollerWidth - this.$padding * 2, Math.round(m * this.characterWidth)) }; - this.addMarker = function(l, r, q) { - l = this.$markerLayer.addMarker(l, r, q); + this.addMarker = function(m, r, q) { + m = this.$markerLayer.addMarker(m, r, q); this.$loop.schedule(this.CHANGE_MARKER); - return l + return m }; - this.removeMarker = function(l) { - this.$markerLayer.removeMarker(l); + this.removeMarker = function(m) { + this.$markerLayer.removeMarker(m); this.$loop.schedule(this.CHANGE_MARKER) }; - this.addGutterDecoration = function(l, r) { - this.$gutterLayer.addGutterDecoration(l, r); + this.addGutterDecoration = function(m, r) { + this.$gutterLayer.addGutterDecoration(m, r); this.$loop.schedule(this.CHANGE_GUTTER) }; - this.removeGutterDecoration = function(l, r) { - this.$gutterLayer.removeGutterDecoration(l, r); + this.removeGutterDecoration = function(m, r) { + this.$gutterLayer.removeGutterDecoration(m, r); this.$loop.schedule(this.CHANGE_GUTTER) }; - this.setBreakpoints = function(l) { - this.$gutterLayer.setBreakpoints(l); + this.setBreakpoints = function(m) { + this.$gutterLayer.setBreakpoints(m); this.$loop.schedule(this.CHANGE_GUTTER) }; - this.updateCursor = function(l, r) { - this.$cursorLayer.setCursor(l, r); + this.updateCursor = function(m, r) { + this.$cursorLayer.setCursor(m, r); this.$loop.schedule(this.CHANGE_CURSOR) }; this.hideCursor = function() { @@ -3205,10 +3205,10 @@ define("ace/virtual_renderer", ["require", "exports", "module", 'text!ace/css/ed this.$cursorLayer.showCursor() }; this.scrollCursorIntoView = function() { - var l = this.$cursorLayer.getPixelPosition(), r = l.left + this.$padding; - l = l.top; - this.getScrollTop() > l && this.scrollToY(l); - this.getScrollTop() + this.$size.scrollerHeight < l + this.lineHeight && this.scrollToY(l + this.lineHeight - this.$size.scrollerHeight); + var m = this.$cursorLayer.getPixelPosition(), r = m.left + this.$padding; + m = m.top; + this.getScrollTop() > m && this.scrollToY(m); + this.getScrollTop() + this.$size.scrollerHeight < m + this.lineHeight && this.scrollToY(m + this.lineHeight - this.$size.scrollerHeight); this.scroller.scrollLeft > r && this.scrollToX(r); this.scroller.scrollLeft + this.$size.scrollerWidth < r + this.characterWidth && this.scrollToX(Math.round(r + this.characterWidth - this.$size.scrollerWidth)) }; @@ -3221,36 +3221,36 @@ define("ace/virtual_renderer", ["require", "exports", "module", 'text!ace/css/ed this.getScrollTopRow = function() { return this.scrollTop / this.lineHeight }; - this.scrollToRow = function(l) { - this.scrollToY(l * this.lineHeight) + this.scrollToRow = function(m) { + this.scrollToY(m * this.lineHeight) }; - this.scrollToY = function(l) { - l = Math.max(0, Math.min(this.lines.length * this.lineHeight - this.$size.scrollerHeight, l)); - if(this.scrollTop !== l) { - this.scrollTop = l; + this.scrollToY = function(m) { + m = Math.max(0, Math.min(this.lines.length * this.lineHeight - this.$size.scrollerHeight, m)); + if(this.scrollTop !== m) { + this.scrollTop = m; this.$loop.schedule(this.CHANGE_SCROLL) } }; - this.scrollToX = function(l) { - if(l <= this.$padding) { - l = 0 - }this.scroller.scrollLeft = l + this.scrollToX = function(m) { + if(m <= this.$padding) { + m = 0 + }this.scroller.scrollLeft = m }; - this.scrollBy = function(l, r) { + this.scrollBy = function(m, r) { r && this.scrollToY(this.scrollTop + r); - l && this.scrollToX(this.scroller.scrollLeft + l) + m && this.scrollToX(this.scroller.scrollLeft + m) }; - this.screenToTextCoordinates = function(l, r) { + this.screenToTextCoordinates = function(m, r) { var q = this.scroller.getBoundingClientRect(); - l = Math.round((l + this.scroller.scrollLeft - q.left - this.$padding) / this.characterWidth); + m = Math.round((m + this.scroller.scrollLeft - q.left - this.$padding) / this.characterWidth); r = Math.floor((r + this.scrollTop - q.top) / this.lineHeight); - return{row:r, column:this.doc.screenToDocumentColumn(Math.max(0, Math.min(r, this.doc.getLength() - 1)), l)} + return{row:r, column:this.doc.screenToDocumentColumn(Math.max(0, Math.min(r, this.doc.getLength() - 1)), m)} }; - this.textToScreenCoordinates = function(l, r) { + this.textToScreenCoordinates = function(m, r) { var q = this.scroller.getBoundingClientRect(); - r = this.padding + Math.round(this.doc.documentToScreenColumn(l, r) * this.characterWidth); - l = l * this.lineHeight; - return{pageX:q.left + r - this.getScrollLeft(), pageY:q.top + l - this.getScrollTop()} + r = this.padding + Math.round(this.doc.documentToScreenColumn(m, r) * this.characterWidth); + m = m * this.lineHeight; + return{pageX:q.left + r - this.getScrollLeft(), pageY:q.top + m - this.getScrollTop()} }; this.visualizeFocus = function() { j.addCssClass(this.container, "ace_focus") @@ -3264,7 +3264,7 @@ define("ace/virtual_renderer", ["require", "exports", "module", 'text!ace/css/ed }; this.hideComposition = function() { }; - this.setTheme = function(l) { + this.setTheme = function(m) { function r(s) { q.$theme && j.removeCssClass(q.container, q.$theme); q.$theme = s ? s.cssClass : null; @@ -3275,13 +3275,13 @@ define("ace/virtual_renderer", ["require", "exports", "module", 'text!ace/css/ed } } var q = this; - if(!l || typeof l == "string") { - l = l || "ace/theme/TextMate"; - h([l], function(s) { + if(!m || typeof m == "string") { + m = m || "ace/theme/textmate"; + h([m], function(s) { r(s) }) }else { - r(l) + r(m) }q = this } }).call(g.prototype); @@ -3295,20 +3295,20 @@ define("ace/mode/doc_comment_highlight_rules", ["require", "exports", "module", }; g.inherits(e, h); (function() { - this.getStartRule = function(d) { - return{token:"comment.doc", regex:"\\/\\*(?=\\*)", next:d} + this.getStartRule = function(c) { + return{token:"comment.doc", regex:"\\/\\*(?=\\*)", next:c} } }).call(e.prototype); return e }); define("ace/mode/javascript_highlight_rules", ["require", "exports", "module", "../lib/oop", "../lib/lang", "./doc_comment_highlight_rules", "./text_highlight_rules"], function(h) { - var g = h("../lib/oop"), e = h("../lib/lang"), d = h("./doc_comment_highlight_rules"); + var g = h("../lib/oop"), e = h("../lib/lang"), c = h("./doc_comment_highlight_rules"); h = h("./text_highlight_rules"); JavaScriptHighlightRules = function() { - var i = new d, c = e.arrayToMap("break|case|catch|continue|default|delete|do|else|finally|for|function|if|in|instanceof|new|return|switch|throw|try|typeof|var|while|with".split("|")), j = e.arrayToMap("true|false|null|undefined|Infinity|NaN|undefined".split("|")), a = e.arrayToMap("class|enum|extends|super|const|export|import|implements|let|private|public|yield|interface|package|protected|static".split("|")); + var i = new c, b = e.arrayToMap("break|case|catch|continue|default|delete|do|else|finally|for|function|if|in|instanceof|new|return|switch|throw|try|typeof|var|while|with".split("|")), j = e.arrayToMap("true|false|null|undefined|Infinity|NaN|undefined".split("|")), a = e.arrayToMap("class|enum|extends|super|const|export|import|implements|let|private|public|yield|interface|package|protected|static".split("|")); this.$rules = {start:[{token:"comment", regex:"\\/\\/.*$"}, i.getStartRule("doc-start"), {token:"comment", regex:"\\/\\*", next:"comment"}, {token:"string.regexp", regex:"[/](?:(?:\\[(?:\\\\]|[^\\]])+\\])|(?:\\\\/|[^\\]/]))*[/][gimy]*\\s*(?=[).,;]|$)"}, {token:"string", regex:'["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'}, {token:"string", regex:'["].*\\\\$', next:"qqstring"}, {token:"string", regex:"['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"}, {token:"string", regex:"['].*\\\\$", next:"qstring"}, {token:"constant.numeric", regex:"0[xX][0-9a-fA-F]+\\b"}, {token:"constant.numeric", regex:"[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"}, {token:function(f) { - return f == "this" ? "variable.language" : c[f] ? "keyword" : j[f] ? "constant.language" : a[f] ? "invalid.illegal" : f == "debugger" ? "invalid.deprecated" : "identifier" + return f == "this" ? "variable.language" : b[f] ? "keyword" : j[f] ? "constant.language" : a[f] ? "invalid.illegal" : f == "debugger" ? "invalid.deprecated" : "identifier" }, regex:"[a-zA-Z_$][a-zA-Z0-9_$]*\\b"}, {token:"keyword.operator", regex:"!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(in|instanceof|new|delete|typeof|void)"}, {token:"lparen", regex:"[\\[\\(\\{]"}, {token:"rparen", regex:"[\\]\\)\\}]"}, {token:"text", regex:"\\s+"}], comment:[{token:"comment", regex:".*?\\*\\/", next:"start"}, {token:"comment", regex:".+"}], qqstring:[{token:"string", regex:'(?:(?:\\\\.)|(?:[^"\\\\]))*?"', next:"start"}, {token:"string", regex:".+"}], qstring:[{token:"string", regex:"(?:(?:\\\\.)|(?:[^'\\\\]))*?'", next:"start"}, {token:"string", regex:".+"}]}; this.addRules(i.getRules(), "doc-"); @@ -3322,22 +3322,22 @@ define("ace/mode/matching_brace_outdent", ["require", "exports", "module", "../r h = function() { }; (function() { - this.checkOutdent = function(e, d) { + this.checkOutdent = function(e, c) { if(!/^\s+$/.test(e)) { return false - }return/^\s*\}/.test(d) + }return/^\s*\}/.test(c) }; - this.autoOutdent = function(e, d) { - var i = e.getLine(d).match(/^(\s*\})/); + this.autoOutdent = function(e, c) { + var i = e.getLine(c).match(/^(\s*\})/); if(!i) { return 0 }i = i[1].length; - var c = e.findMatchingBracket({row:d, column:i}); - if(!c || c.row == d) { + var b = e.findMatchingBracket({row:c, column:i}); + if(!b || b.row == c) { return 0 - }c = this.$getIndent(e.getLine(c.row)); - e.replace(new g(d, 0, d, i - 1), c); - return c.length - (i - 1) + }b = this.$getIndent(e.getLine(b.row)); + e.replace(new g(c, 0, c, i - 1), b); + return b.length - (i - 1) }; this.$getIndent = function(e) { if(e = e.match(/^(\s+)/)) { @@ -3348,66 +3348,68 @@ define("ace/mode/matching_brace_outdent", ["require", "exports", "module", "../r return h }); define("ace/mode/javascript", ["require", "exports", "module", "../lib/oop", "./text", "../tokenizer", "./javascript_highlight_rules", "./matching_brace_outdent", "../range"], function(h) { - var g = h("../lib/oop"), e = h("./text"), d = h("../tokenizer"), i = h("./javascript_highlight_rules"), c = h("./matching_brace_outdent"), j = h("../range"); + var g = h("../lib/oop"), e = h("./text"), c = h("../tokenizer"), i = h("./javascript_highlight_rules"), b = h("./matching_brace_outdent"), j = h("../range"); h = function() { - this.$tokenizer = new d((new i).getRules()); - this.$outdent = new c + this.$tokenizer = new c((new i).getRules()); + this.$outdent = new b }; g.inherits(h, e); (function() { - this.toggleCommentLines = function(a, f, m) { + this.toggleCommentLines = function(a, f, l) { var n = true; a = /^(\s*)\/\//; - for(var b = m.start.row;b <= m.end.row;b++) { - if(!a.test(f.getLine(b))) { + for(var d = l.start.row;d <= l.end.row;d++) { + if(!a.test(f.getLine(d))) { n = false; break } }if(n) { n = new j(0, 0, 0, 0); - for(b = m.start.row;b <= m.end.row;b++) { - var k = f.getLine(b).replace(a, "$1"); - n.start.row = b; - n.end.row = b; + for(d = l.start.row;d <= l.end.row;d++) { + var k = f.getLine(d).replace(a, "$1"); + n.start.row = d; + n.end.row = d; n.end.column = k.length + 2; f.replace(n, k) }return-2 }else { - return f.indentRows(m, "//") + return f.indentRows(l, "//") } }; - this.getNextLineIndent = function(a, f, m) { - var n = this.$getIndent(f), b = this.$tokenizer.getLineTokens(f, a), k = b.tokens; - b = b.state; + this.getNextLineIndent = function(a, f, l) { + var n = this.$getIndent(f), d = this.$tokenizer.getLineTokens(f, a), k = d.tokens; + d = d.state; if(k.length && k[k.length - 1].type == "comment") { return n }if(a == "start") { if(a = f.match(/^.*[\{\(\[]\s*$/)) { - n += m + n += l } }else { if(a == "doc-start") { - if(b == "start") { + if(d == "start") { return"" }if(a = f.match(/^\s*(\/?)\*/)) { if(a[1]) { n += " " }n += "* " - } + }if(a[1]) { + n += " " + }n += "* " } }return n }; - this.checkOutdent = function(a, f, m) { - return this.$outdent.checkOutdent(f, m) + this.checkOutdent = function(a, f, l) { + return this.$outdent.checkOutdent(f, l) }; - this.autoOutdent = function(a, f, m) { - return this.$outdent.autoOutdent(f, m) + this.autoOutdent = function(a, f, l) { + return this.$outdent.autoOutdent(f, l) } }).call(h.prototype); return h }); define("ace/theme/textmate", ["require", "exports", "module", "text!ace/theme/tm.css!.ace-tm .ace_editor {\n border: 2px solid rgb(159, 159, 159);\n}\n\n.ace-tm .ace_editor.ace_focus {\n border: 2px solid #327fbd;\n}\n\n.ace-tm .ace_gutter {\n width: 50px;\n background: #e8e8e8;\n color: #333;\n overflow : hidden;\n}\n\n.ace-tm .ace_gutter-layer {\n width: 100%;\n text-align: right;\n}\n\n.ace-tm .ace_gutter-layer .ace_gutter-cell {\n padding-right: 6px;\n}\n\n.ace-tm .ace_editor .ace_printMargin {\n width: 1px;\n background: #e8e8e8;\n}\n\n.ace-tm .ace_text-layer {\n cursor: text;\n}\n\n.ace-tm .ace_cursor {\n border-left: 2px solid black;\n}\n\n.ace-tm .ace_cursor.ace_overwrite {\n border-left: 0px;\n border-bottom: 1px solid black;\n}\n \n.ace-tm .ace_line .ace_invisible {\n color: rgb(191, 191, 191);\n}\n\n.ace-tm .ace_line .ace_keyword {\n color: blue;\n}\n\n.ace-tm .ace_line .ace_constant.ace_buildin {\n color: rgb(88, 72, 246);\n}\n\n.ace-tm .ace_line .ace_constant.ace_library {\n color: rgb(6, 150, 14);\n}\n\n.ace-tm .ace_line .ace_invalid {\n background-color: rgb(153, 0, 0);\n color: white;\n}\n\n.ace-tm .ace_line .ace_support.ace_function {\n color: rgb(60, 76, 114);\n}\n\n.ace-tm .ace_line .ace_keyword.ace_operator {\n color: rgb(104, 118, 135);\n}\n\n.ace-tm .ace_line .ace_string {\n color: rgb(3, 106, 7);\n}\n\n.ace-tm .ace_line .ace_comment {\n color: rgb(76, 136, 107);\n}\n\n.ace-tm .ace_line .ace_comment.ace_doc {\n color: rgb(0, 102, 255);\n}\n\n.ace-tm .ace_line .ace_comment.ace_doc.ace_tag {\n color: rgb(128, 159, 191);\n}\n\n.ace-tm .ace_line .ace_constant.ace_numeric {\n color: rgb(0, 0, 205);\n}\n\n.ace-tm .ace_line .ace_variable {\n color: rgb(49, 132, 149);\n}\n\n.ace-tm .ace_line .ace_xml_pe {\n color: rgb(104, 104, 91);\n}\n\n.ace-tm .ace_marker-layer .ace_selection {\n background: rgb(181, 213, 255);\n}\n\n.ace-tm .ace_marker-layer .ace_step {\n background: rgb(252, 255, 0);\n}\n\n.ace-tm .ace_marker-layer .ace_stack {\n background: rgb(164, 229, 101);\n}\n\n.ace-tm .ace_marker-layer .ace_bracket {\n margin: -1px 0 0 -1px;\n border: 1px solid rgb(192, 192, 192);\n}\n\n.ace-tm .ace_marker-layer .ace_active_line {\n background: rgb(232, 242, 254);\n}\n\n.ace-tm .ace_string.ace_regex {\n color: rgb(255, 0, 0) \n}", -"../lib/dom"], function(h, g, e, d) { - h("../lib/dom").importCssString(d); +"../lib/dom"], function(h, g, e, c) { + h("../lib/dom").importCssString(c); return{cssClass:"ace-tm"} }); \ No newline at end of file diff --git a/build/ace/layer/text.js b/build/ace/layer/text.js index 58692e6a..7e37774c 100644 --- a/build/ace/layer/text.js +++ b/build/ace/layer/text.js @@ -67,6 +67,7 @@ define(function(k) { }; this.updateLines = function(a, b, e) { this.$computeTabString(); + this.config = a; var f = Math.max(b, a.firstRow), c = Math.min(e, a.lastRow), d = this.element.childNodes, h = this; this.tokenizer.getTokens(f, c, function(i) { for(var g = f;g <= c;g++) { @@ -128,6 +129,7 @@ define(function(k) { }; this.update = function(a) { this.$computeTabString(); + this.config = a; var b = [], e = this; this.tokenizer.getTokens(a.firstRow, a.lastRow, function(f) { for(var c = a.firstRow;c <= a.lastRow;c++) { diff --git a/build/ace/mode/javascript.js b/build/ace/mode/javascript.js index 5db7b0ef..0217d3fc 100644 --- a/build/ace/mode/javascript.js +++ b/build/ace/mode/javascript.js @@ -6,53 +6,55 @@ define(function(f) { }; h.inherits(f, i); (function() { - this.toggleCommentLines = function(d, b, e) { - var c = true; - d = /^(\s*)\/\//; - for(var a = e.start.row;a <= e.end.row;a++) { - if(!d.test(b.getLine(a))) { - c = false; + this.toggleCommentLines = function(c, d, e) { + var a = true; + c = /^(\s*)\/\//; + for(var b = e.start.row;b <= e.end.row;b++) { + if(!c.test(d.getLine(b))) { + a = false; break } - }if(c) { - c = new m(0, 0, 0, 0); - for(a = e.start.row;a <= e.end.row;a++) { - var g = b.getLine(a).replace(d, "$1"); - c.start.row = a; - c.end.row = a; - c.end.column = g.length + 2; - b.replace(c, g) + }if(a) { + a = new m(0, 0, 0, 0); + for(b = e.start.row;b <= e.end.row;b++) { + var g = d.getLine(b).replace(c, "$1"); + a.start.row = b; + a.end.row = b; + a.end.column = g.length + 2; + d.replace(a, g) }return-2 }else { - return b.indentRows(e, "//") + return d.indentRows(e, "//") } }; - this.getNextLineIndent = function(d, b, e) { - var c = this.$getIndent(b), a = this.$tokenizer.getLineTokens(b, d), g = a.tokens; - a = a.state; + this.getNextLineIndent = function(c, d, e) { + var a = this.$getIndent(d), b = this.$tokenizer.getLineTokens(d, c), g = b.tokens; + b = b.state; if(g.length && g[g.length - 1].type == "comment") { - return c - }if(d == "start") { - if(d = b.match(/^.*[\{\(\[]\s*$/)) { - c += e + return a + }if(c == "start") { + if(c = d.match(/^.*[\{\(\[]\s*$/)) { + a += e } }else { - if(d == "doc-start") { - if(a == "start") { + if(c == "doc-start") { + if(b == "start") { return"" - }if(d = b.match(/^\s*(\/?)\*/)) { - if(d[1]) { - c += " " - }c += "* " - } + }if(c = d.match(/^\s*(\/?)\*/)) { + if(c[1]) { + a += " " + }a += "* " + }if(c[1]) { + a += " " + }a += "* " } - }return c + }return a }; - this.checkOutdent = function(d, b, e) { - return this.$outdent.checkOutdent(b, e) + this.checkOutdent = function(c, d, e) { + return this.$outdent.checkOutdent(d, e) }; - this.autoOutdent = function(d, b, e) { - return this.$outdent.autoOutdent(b, e) + this.autoOutdent = function(c, d, e) { + return this.$outdent.autoOutdent(d, e) } }).call(f.prototype); return f diff --git a/build/ace/mode/python.js b/build/ace/mode/python.js new file mode 100644 index 00000000..1df73e4d --- /dev/null +++ b/build/ace/mode/python.js @@ -0,0 +1,93 @@ +define("ace/mode/python_highlight_rules", ["require", "exports", "module", "../lib/oop", "../lib/lang", "./text_highlight_rules"], function(a) { + var k = a("../lib/oop"), b = a("../lib/lang"); + a = a("./text_highlight_rules"); + PythonHighlightRules = function() { + var f = b.arrayToMap("and|as|assert|break|class|continue|def|del|elif|else|except|exec|finally|for|from|global|if|import|in|is|lambda|not|or|pass|print|raise|return|try|while|with|yield".split("|")), i = b.arrayToMap("True|False|None|NotImplemented|Ellipsis|__debug__".split("|")), j = b.arrayToMap("abs|divmod|input|open|staticmethod|all|enumerate|int|ord|str|any|eval|isinstance|pow|sum|basestring|execfile|issubclass|print|super|binfile|iter|property|tuple|bool|filter|len|range|type|bytearray|float|list|raw_input|unichr|callable|format|locals|reduce|unicode|chr|frozenset|long|reload|vars|classmethod|getattr|map|repr|xrange|cmp|globals|max|reversed|zip|compile|hasattr|memoryview|round|__import__|complex|hash|min|set|apply|delattr|help|next|setattr|buffer|dict|hex|object|slice|coerce|dir|id|oct|sorted|intern".split("|")), + l = b.arrayToMap("".split("|")); + this.$rules = {start:[{token:"comment", regex:"#.*$"}, {token:"string", regex:'(?:(?:[rubRUB])|(?:[ubUB][rR]))?"{3}(?:(?:.)|(?:^"{3}))*?"{3}'}, {token:"string", regex:'(?:(?:[rubRUB])|(?:[ubUB][rR]))?"{3}.*$', next:"qqstring"}, {token:"string", regex:'(?:(?:[rubRUB])|(?:[ubUB][rR]))?"(?:(?:\\\\.)|(?:[^"\\\\]))*?"'}, {token:"string", regex:"(?:(?:[rubRUB])|(?:[ubUB][rR]))?'{3}(?:(?:.)|(?:^'{3}))*?'{3}"}, {token:"string", regex:"(?:(?:[rubRUB])|(?:[ubUB][rR]))?'{3}.*$", next:"qstring"}, {token:"string", + regex:"(?:(?:[rubRUB])|(?:[ubUB][rR]))?'(?:(?:\\\\.)|(?:[^'\\\\]))*?'"}, {token:"constant.numeric", regex:"(?:(?:(?:(?:(?:(?:(?:\\d+)?(?:\\.\\d+))|(?:(?:\\d+)\\.))|(?:\\d+))(?:[eE][+-]?\\d+))|(?:(?:(?:\\d+)?(?:\\.\\d+))|(?:(?:\\d+)\\.)))|\\d+)[jJ]\\b"}, {token:"constant.numeric", regex:"(?:(?:(?:(?:(?:(?:\\d+)?(?:\\.\\d+))|(?:(?:\\d+)\\.))|(?:\\d+))(?:[eE][+-]?\\d+))|(?:(?:(?:\\d+)?(?:\\.\\d+))|(?:(?:\\d+)\\.)))"}, {token:"constant.numeric", regex:"(?:(?:(?:[1-9]\\d*)|(?:0))|(?:0[oO]?[0-7]+)|(?:0[xX][\\dA-Fa-f]+)|(?:0[bB][01]+))[lL]\\b"}, + {token:"constant.numeric", regex:"(?:(?:(?:[1-9]\\d*)|(?:0))|(?:0[oO]?[0-7]+)|(?:0[xX][\\dA-Fa-f]+)|(?:0[bB][01]+))\\b"}, {token:function(c) { + return f[c] ? "keyword" : i[c] ? "constant.language" : l[c] ? "invalid.illegal" : j[c] ? "support.function" : c == "debugger" ? "invalid.deprecated" : "identifier" + }, regex:"[a-zA-Z_$][a-zA-Z0-9_$]*\\b"}, {token:"keyword.operator", regex:"\\+|\\-|\\*|\\*\\*|\\/|\\/\\/|%|<<|>>|&|\\||\\^|~|<|>|<=|=>|==|!=|<>|="}, {token:"lparen", regex:"[\\[\\(\\{]"}, {token:"rparen", regex:"[\\]\\)\\}]"}, {token:"text", regex:"\\s+"}], qqstring:[{token:"string", regex:'(?:^"{3})*?"{3}', next:"start"}, {token:"string", regex:".+"}], qstring:[{token:"string", regex:"(?:^'{3})*?'{3}", next:"start"}, {token:"string", regex:".+"}]} + }; + k.inherits(PythonHighlightRules, a); + return PythonHighlightRules +}); +define("ace/mode/matching_brace_outdent", ["require", "exports", "module", "../range"], function(a) { + var k = a("../range"); + a = function() { + }; + (function() { + this.checkOutdent = function(b, f) { + if(!/^\s+$/.test(b)) { + return false + }return/^\s*\}/.test(f) + }; + this.autoOutdent = function(b, f) { + var i = b.getLine(f).match(/^(\s*\})/); + if(!i) { + return 0 + }i = i[1].length; + var j = b.findMatchingBracket({row:f, column:i}); + if(!j || j.row == f) { + return 0 + }j = this.$getIndent(b.getLine(j.row)); + b.replace(new k(f, 0, f, i - 1), j); + return j.length - (i - 1) + }; + this.$getIndent = function(b) { + if(b = b.match(/^(\s+)/)) { + return b[1] + }return"" + } + }).call(a.prototype); + return a +}); +define("ace/mode/python", ["require", "exports", "module", "../lib/oop", "./text", "../tokenizer", "./python_highlight_rules", "./matching_brace_outdent", "../range"], function(a) { + var k = a("../lib/oop"), b = a("./text"), f = a("../tokenizer"), i = a("./python_highlight_rules"), j = a("./matching_brace_outdent"), l = a("../range"); + a = function() { + this.$tokenizer = new f((new i).getRules()); + this.$outdent = new j + }; + k.inherits(a, b); + (function() { + this.toggleCommentLines = function(c, e, g) { + var h = true; + c = /^(\s*)#/; + for(var d = g.start.row;d <= g.end.row;d++) { + if(!c.test(e.getLine(d))) { + h = false; + break + } + }if(h) { + h = new l(0, 0, 0, 0); + for(d = g.start.row;d <= g.end.row;d++) { + var m = e.getLine(d).replace(c, "$1"); + h.start.row = d; + h.end.row = d; + h.end.column = m.length + 2; + e.replace(h, m) + }return-2 + }else { + return e.indentRows(g, "#") + } + }; + this.getNextLineIndent = function(c, e, g) { + var h = this.$getIndent(e), d = this.$tokenizer.getLineTokens(e, c).tokens; + if(d.length && d[d.length - 1].type == "comment") { + return h + }if(c == "start") { + if(e.match(/^.*[\{\(\[\:]\s*$/)) { + h += g + } + }return h + }; + this.checkOutdent = function(c, e, g) { + return this.$outdent.checkOutdent(e, g) + }; + this.autoOutdent = function(c, e, g) { + return this.$outdent.autoOutdent(e, g) + } + }).call(a.prototype); + return a +}); \ No newline at end of file diff --git a/build/ace/mode/python_highlight_rules.js b/build/ace/mode/python_highlight_rules.js new file mode 100644 index 00000000..cade2c71 --- /dev/null +++ b/build/ace/mode/python_highlight_rules.js @@ -0,0 +1,15 @@ +define(function(a) { + var d = a("../lib/oop"), c = a("../lib/lang"); + a = a("./text_highlight_rules"); + PythonHighlightRules = function() { + var e = c.arrayToMap("and|as|assert|break|class|continue|def|del|elif|else|except|exec|finally|for|from|global|if|import|in|is|lambda|not|or|pass|print|raise|return|try|while|with|yield".split("|")), f = c.arrayToMap("True|False|None|NotImplemented|Ellipsis|__debug__".split("|")), g = c.arrayToMap("abs|divmod|input|open|staticmethod|all|enumerate|int|ord|str|any|eval|isinstance|pow|sum|basestring|execfile|issubclass|print|super|binfile|iter|property|tuple|bool|filter|len|range|type|bytearray|float|list|raw_input|unichr|callable|format|locals|reduce|unicode|chr|frozenset|long|reload|vars|classmethod|getattr|map|repr|xrange|cmp|globals|max|reversed|zip|compile|hasattr|memoryview|round|__import__|complex|hash|min|set|apply|delattr|help|next|setattr|buffer|dict|hex|object|slice|coerce|dir|id|oct|sorted|intern".split("|")), + h = c.arrayToMap("".split("|")); + this.$rules = {start:[{token:"comment", regex:"#.*$"}, {token:"string", regex:'(?:(?:[rubRUB])|(?:[ubUB][rR]))?"{3}(?:(?:.)|(?:^"{3}))*?"{3}'}, {token:"string", regex:'(?:(?:[rubRUB])|(?:[ubUB][rR]))?"{3}.*$', next:"qqstring"}, {token:"string", regex:'(?:(?:[rubRUB])|(?:[ubUB][rR]))?"(?:(?:\\\\.)|(?:[^"\\\\]))*?"'}, {token:"string", regex:"(?:(?:[rubRUB])|(?:[ubUB][rR]))?'{3}(?:(?:.)|(?:^'{3}))*?'{3}"}, {token:"string", regex:"(?:(?:[rubRUB])|(?:[ubUB][rR]))?'{3}.*$", next:"qstring"}, {token:"string", + regex:"(?:(?:[rubRUB])|(?:[ubUB][rR]))?'(?:(?:\\\\.)|(?:[^'\\\\]))*?'"}, {token:"constant.numeric", regex:"(?:(?:(?:(?:(?:(?:(?:\\d+)?(?:\\.\\d+))|(?:(?:\\d+)\\.))|(?:\\d+))(?:[eE][+-]?\\d+))|(?:(?:(?:\\d+)?(?:\\.\\d+))|(?:(?:\\d+)\\.)))|\\d+)[jJ]\\b"}, {token:"constant.numeric", regex:"(?:(?:(?:(?:(?:(?:\\d+)?(?:\\.\\d+))|(?:(?:\\d+)\\.))|(?:\\d+))(?:[eE][+-]?\\d+))|(?:(?:(?:\\d+)?(?:\\.\\d+))|(?:(?:\\d+)\\.)))"}, {token:"constant.numeric", regex:"(?:(?:(?:[1-9]\\d*)|(?:0))|(?:0[oO]?[0-7]+)|(?:0[xX][\\dA-Fa-f]+)|(?:0[bB][01]+))[lL]\\b"}, + {token:"constant.numeric", regex:"(?:(?:(?:[1-9]\\d*)|(?:0))|(?:0[oO]?[0-7]+)|(?:0[xX][\\dA-Fa-f]+)|(?:0[bB][01]+))\\b"}, {token:function(b) { + return e[b] ? "keyword" : f[b] ? "constant.language" : h[b] ? "invalid.illegal" : g[b] ? "support.function" : b == "debugger" ? "invalid.deprecated" : "identifier" + }, regex:"[a-zA-Z_$][a-zA-Z0-9_$]*\\b"}, {token:"keyword.operator", regex:"\\+|\\-|\\*|\\*\\*|\\/|\\/\\/|%|<<|>>|&|\\||\\^|~|<|>|<=|=>|==|!=|<>|="}, {token:"lparen", regex:"[\\[\\(\\{]"}, {token:"rparen", regex:"[\\]\\)\\}]"}, {token:"text", regex:"\\s+"}], qqstring:[{token:"string", regex:'(?:^"{3})*?"{3}', next:"start"}, {token:"string", regex:".+"}], qstring:[{token:"string", regex:"(?:^'{3})*?'{3}", next:"start"}, {token:"string", regex:".+"}]} + }; + d.inherits(PythonHighlightRules, a); + return PythonHighlightRules +}); \ No newline at end of file diff --git a/build/ace/renderloop.js b/build/ace/renderloop.js index 7eac3a96..fbd33510 100644 --- a/build/ace/renderloop.js +++ b/build/ace/renderloop.js @@ -1,6 +1,6 @@ -define(function(c) { - var e = c("./lib/event"); - c = function(b) { +define(function(d) { + var e = d("./lib/event"); + d = function(b) { this.onRender = b; this.pending = false; this.changes = 0 @@ -13,8 +13,9 @@ define(function(c) { var a = this; this.setTimeoutZero(function() { a.pending = false; - a.onRender(a.changes); - a.changes = 0 + var c = a.changes; + a.changes = 0; + a.onRender(c) }) } }; @@ -23,9 +24,9 @@ define(function(c) { this.setTimeoutZero = function(b) { if(!this.attached) { var a = this; - e.addListener(window, "message", function(d) { - if(d.source == window && a.callback && d.data == a.messageName) { - e.stopPropagation(d); + e.addListener(window, "message", function(c) { + if(c.source == window && a.callback && c.data == a.messageName) { + e.stopPropagation(c); a.callback() } }); @@ -38,6 +39,6 @@ define(function(c) { setTimeout(b, 0) } } - }).call(c.prototype); - return c + }).call(d.prototype); + return d }); \ No newline at end of file diff --git a/build/ace/test/assertions.js b/build/ace/test/assertions.js index c7c5eefa..e69de29b 100644 --- a/build/ace/test/assertions.js +++ b/build/ace/test/assertions.js @@ -1,16 +0,0 @@ -/* - LGPLv3 -*/ -require.def([], function() { - window.assertPosition = function(a, b, c) { - assertEquals(a, c.row); - assertEquals(b, c.column) - }; - window.assertRange = function(a, b, c, e, d) { - assertPosition(a, b, d.start); - assertPosition(c, e, d.end) - }; - window.assertJsonEquals = function(a, b) { - assertEquals(JSON.stringify(a), JSON.stringify(b)) - } -}); \ No newline at end of file diff --git a/build/ace/test/change_document_test.js b/build/ace/test/change_document_test.js index afd3d113..e69de29b 100644 --- a/build/ace/test/change_document_test.js +++ b/build/ace/test/change_document_test.js @@ -1,79 +0,0 @@ -/* - LGPLv3 -*/ -require.def(["ace/Document", "ace/Editor", "ace/mode/Text", "ace/mode/JavaScript", "ace/test/MockRenderer"], function(b, c, f, d, e) { - new TestCase("ChangeDocumentTest", {setUp:function() { - this.doc1 = new b("abc\ndef"); - this.doc2 = new b("ghi\njkl"); - this.editor = new c(new e) - }, "test: change document":function() { - this.editor.setDocument(this.doc1); - assertEquals(this.doc1, this.editor.getDocument()); - this.editor.setDocument(this.doc2); - assertEquals(this.doc2, this.editor.getDocument()) - }, "test: only changes to the new document should have effect":function() { - var a = false; - this.editor.onDocumentChange = function() { - a = true - }; - this.editor.setDocument(this.doc1); - this.editor.setDocument(this.doc2); - this.doc1.duplicateLines(0, 0); - assertFalse(a); - this.doc2.duplicateLines(0, 0); - assertTrue(a) - }, "test: should use cursor of new document":function() { - this.doc1.getSelection().moveCursorTo(0, 1); - this.doc2.getSelection().moveCursorTo(1, 0); - this.editor.setDocument(this.doc1); - assertPosition(0, 1, this.editor.getCursorPosition()); - this.editor.setDocument(this.doc2); - assertPosition(1, 0, this.editor.getCursorPosition()) - }, "test: only changing the cursor of the new doc should not have an effect":function() { - this.editor.onCursorChange = function() { - a = true - }; - this.editor.setDocument(this.doc1); - this.editor.setDocument(this.doc2); - assertPosition(0, 0, this.editor.getCursorPosition()); - var a = false; - this.doc1.getSelection().moveCursorTo(0, 1); - assertPosition(0, 0, this.editor.getCursorPosition()); - assertFalse(a); - this.doc2.getSelection().moveCursorTo(1, 1); - assertPosition(1, 1, this.editor.getCursorPosition()); - assertTrue(a) - }, "test: should use selection of new document":function() { - this.doc1.getSelection().selectTo(0, 1); - this.doc2.getSelection().selectTo(1, 0); - this.editor.setDocument(this.doc1); - assertPosition(0, 1, this.editor.getSelection().getSelectionLead()); - this.editor.setDocument(this.doc2); - assertPosition(1, 0, this.editor.getSelection().getSelectionLead()) - }, "test: only changing the selection of the new doc should not have an effect":function() { - this.editor.onSelectionChange = function() { - a = true - }; - this.editor.setDocument(this.doc1); - this.editor.setDocument(this.doc2); - assertPosition(0, 0, this.editor.getSelection().getSelectionLead()); - var a = false; - this.doc1.getSelection().selectTo(0, 1); - assertPosition(0, 0, this.editor.getSelection().getSelectionLead()); - assertFalse(a); - this.doc2.getSelection().selectTo(1, 1); - assertPosition(1, 1, this.editor.getSelection().getSelectionLead()); - assertTrue(a) - }, "test: should use mode of new document":function() { - this.editor.onDocumentModeChange = function() { - a = true - }; - this.editor.setDocument(this.doc1); - this.editor.setDocument(this.doc2); - var a = false; - this.doc1.setMode(new Text); - assertFalse(a); - this.doc2.setMode(new d); - assertTrue(a) - }}) -}); \ No newline at end of file diff --git a/build/ace/test/document_test.js b/build/ace/test/document_test.js index c9e44b04..2e8f4bdd 100644 --- a/build/ace/test/document_test.js +++ b/build/ace/test/document_test.js @@ -1,148 +1,153 @@ /* LGPLv3 */ -require.def(["ace/Document", "ace/UndoManager", "ace/Editor", "ace/test/MockRenderer"], function(b, h, i, j) { - new TestCase("TextDocumentTest", {"test: find matching opening bracket":function() { - var a = new b(["(()(", "())))"]); - assertPosition(0, 1, a.findMatchingBracket({row:0, column:3})); - assertPosition(1, 0, a.findMatchingBracket({row:1, column:2})); - assertPosition(0, 3, a.findMatchingBracket({row:1, column:3})); - assertPosition(0, 0, a.findMatchingBracket({row:1, column:4})); - assertEquals(null, a.findMatchingBracket({row:1, column:5})) - }, "test: find matching closing bracket":function() { - var a = new b(["(()(", "())))"]); - assertPosition(1, 1, a.findMatchingBracket({row:1, column:1})); - assertPosition(1, 1, a.findMatchingBracket({row:1, column:1})); - assertPosition(1, 2, a.findMatchingBracket({row:0, column:4})); - assertPosition(0, 2, a.findMatchingBracket({row:0, column:2})); - assertPosition(1, 3, a.findMatchingBracket({row:0, column:1})); - assertEquals(null, a.findMatchingBracket({row:0, column:0})) - }, "test: match different bracket types":function() { - var a = new b(["({[", ")]}"]); - assertPosition(1, 0, a.findMatchingBracket({row:0, column:1})); - assertPosition(1, 2, a.findMatchingBracket({row:0, column:2})); - assertPosition(1, 1, a.findMatchingBracket({row:0, column:3})); - assertPosition(0, 0, a.findMatchingBracket({row:1, column:1})); - assertPosition(0, 2, a.findMatchingBracket({row:1, column:2})); - assertPosition(0, 1, a.findMatchingBracket({row:1, column:3})) - }, "test: move lines down":function() { - var a = new b(["1", "2", "3", "4"]); - a.moveLinesDown(0, 1); - assertEquals("3\n1\n2\n4", a.toString()); - a.moveLinesDown(1, 2); - assertEquals("3\n4\n1\n2", a.toString()); - a.moveLinesDown(2, 3); - assertEquals("3\n4\n1\n2", a.toString()); - a.moveLinesDown(2, 2); - assertEquals("3\n4\n2\n1", a.toString()) - }, "test: move lines up":function() { - var a = new b(["1", "2", "3", "4"]); - a.moveLinesUp(2, 3); - assertEquals("1\n3\n4\n2", a.toString()); - a.moveLinesUp(1, 2); - assertEquals("3\n4\n1\n2", a.toString()); - a.moveLinesUp(0, 1); - assertEquals("3\n4\n1\n2", a.toString()); - a.moveLinesUp(2, 2); - assertEquals("3\n1\n4\n2", a.toString()) - }, "test: duplicate lines":function() { - var a = new b(["1", "2", "3", "4"]); - a.duplicateLines(1, 2); - assertEquals("1\n2\n3\n2\n3\n4", a.toString()) - }, "test: duplicate last line":function() { - var a = new b(["1", "2", "3"]); - a.duplicateLines(2, 2); - assertEquals("1\n2\n3\n3", a.toString()) - }, "test: duplicate first line":function() { - var a = new b(["1", "2", "3"]); - a.duplicateLines(0, 0); - assertEquals("1\n1\n2\n3", a.toString()) - }, "test: should handle unix style new lines":function() { - var a = new b(["1", "2", "3"]); - assertEquals("1\n2\n3", a.toString()) - }, "test: should handle windows style new lines":function() { - var a = new b("1\r\n2\r\n3"); - a.setNewLineMode("unix"); - assertEquals("1\n2\n3", a.toString()) - }, "test: set new line mode to 'windows' should use '\r\n' as new lines":function() { - var a = new b("1\n2\n3"); - a.setNewLineMode("windows"); - assertEquals("1\r\n2\r\n3", a.toString()) - }, "test: set new line mode to 'unix' should use '\n' as new lines":function() { - var a = new b("1\r\n2\r\n3"); - a.setNewLineMode("unix"); - assertEquals("1\n2\n3", a.toString()) - }, "test: set new line mode to 'auto' should use detect the incoming nl type":function() { - var a = new b("1\n2\n3"); - a.setNewLineMode("auto"); - assertEquals("1\n2\n3", a.toString()); - a = new b("1\r\n2\r\n3"); - a.setNewLineMode("auto"); - assertEquals("1\r\n2\r\n3", a.toString()); - a.replace(new Range(0, 0, 2, 1), "4\n5\n6"); - assertEquals("4\n5\n6", a.toString()) - }, "test: undo/redo for delete line":function() { - var a = new b(["111", "222", "333"]), c = new h; - a.setUndoManager(c); - var e = a.toString(), d = new i(new j, a); - d.removeLines(); - var f = a.toString(); - assertEquals("222\n333", f); - a.$informUndoManager.call(); - d.removeLines(); - var g = a.toString(); - assertEquals("333", g); - a.$informUndoManager.call(); - d.removeLines(); - d = a.toString(); - assertEquals("", d); - a.$informUndoManager.call(); - c.undo(); - a.$informUndoManager.call(); - assertEquals(g, a.toString()); - c.undo(); - a.$informUndoManager.call(); - assertEquals(f, a.toString()); - c.undo(); - a.$informUndoManager.call(); - assertEquals(e, a.toString()); - c.undo(); - a.$informUndoManager.call(); - assertEquals(e, a.toString()) - }, "test: convert document to screen coordinates":function() { - var a = new b("01234\t567890\t1234"); - a.setTabSize(4); - assertEquals(0, a.documentToScreenColumn(0, 0)); - assertEquals(4, a.documentToScreenColumn(0, 4)); - assertEquals(5, a.documentToScreenColumn(0, 5)); - assertEquals(9, a.documentToScreenColumn(0, 6)); - assertEquals(15, a.documentToScreenColumn(0, 12)); - assertEquals(19, a.documentToScreenColumn(0, 13)); - a.setTabSize(2); - assertEquals(0, a.documentToScreenColumn(0, 0)); - assertEquals(4, a.documentToScreenColumn(0, 4)); - assertEquals(5, a.documentToScreenColumn(0, 5)); - assertEquals(7, a.documentToScreenColumn(0, 6)); - assertEquals(13, a.documentToScreenColumn(0, 12)); - assertEquals(15, a.documentToScreenColumn(0, 13)) - }, "test: convert document to scrren coordinates with leading tabs":function() { - var a = new b("\t\t123"); - a.setTabSize(4); - assertEquals(0, a.documentToScreenColumn(0, 0)); - assertEquals(4, a.documentToScreenColumn(0, 1)); - assertEquals(8, a.documentToScreenColumn(0, 2)); - assertEquals(9, a.documentToScreenColumn(0, 3)) - }, "test: convert screen to document coordinates":function() { - var a = new b("01234\t567890\t1234"); - a.setTabSize(4); - assertEquals(0, a.screenToDocumentColumn(0, 0)); - assertEquals(4, a.screenToDocumentColumn(0, 4)); - assertEquals(5, a.screenToDocumentColumn(0, 5)); - assertEquals(5, a.screenToDocumentColumn(0, 6)); - assertEquals(5, a.screenToDocumentColumn(0, 7)); - assertEquals(5, a.screenToDocumentColumn(0, 8)); - assertEquals(6, a.screenToDocumentColumn(0, 9)); - assertEquals(12, a.screenToDocumentColumn(0, 15)); - assertEquals(13, a.screenToDocumentColumn(0, 19)) - }}) -}); \ No newline at end of file +require("../../../support/paths"); +var Document = require("../document"), UndoManager = require("../undomanager"), MockRenderer = require("./mockrenderer"), Range = require("../range"), assert = require("./assertions"), async = require("async"), Test = {"test: find matching opening bracket":function() { + var a = new Document(["(()(", "())))"]); + assert.position(a.findMatchingBracket({row:0, column:3}), 0, 1); + assert.position(a.findMatchingBracket({row:1, column:2}), 1, 0); + assert.position(a.findMatchingBracket({row:1, column:3}), 0, 3); + assert.position(a.findMatchingBracket({row:1, column:4}), 0, 0); + assert.equal(a.findMatchingBracket({row:1, column:5}), null) +}, "test: find matching closing bracket":function() { + var a = new Document(["(()(", "())))"]); + assert.position(a.findMatchingBracket({row:1, column:1}), 1, 1); + assert.position(a.findMatchingBracket({row:1, column:1}), 1, 1); + assert.position(a.findMatchingBracket({row:0, column:4}), 1, 2); + assert.position(a.findMatchingBracket({row:0, column:2}), 0, 2); + assert.position(a.findMatchingBracket({row:0, column:1}), 1, 3); + assert.equal(a.findMatchingBracket({row:0, column:0}), null) +}, "test: match different bracket types":function() { + var a = new Document(["({[", ")]}"]); + assert.position(a.findMatchingBracket({row:0, column:1}), 1, 0); + assert.position(a.findMatchingBracket({row:0, column:2}), 1, 2); + assert.position(a.findMatchingBracket({row:0, column:3}), 1, 1); + assert.position(a.findMatchingBracket({row:1, column:1}), 0, 0); + assert.position(a.findMatchingBracket({row:1, column:2}), 0, 2); + assert.position(a.findMatchingBracket({row:1, column:3}), 0, 1) +}, "test: move lines down":function() { + var a = new Document(["1", "2", "3", "4"]); + console.log(a.toString().replace(/\n/g, "\\n")); + a.moveLinesDown(0, 1); + console.log(a.toString().replace(/\n/g, "\\n")); + assert.equal(a.toString(), "3\n1\n2\n4"); + a.moveLinesDown(1, 2); + assert.equal(a.toString(), "3\n4\n1\n2"); + a.moveLinesDown(2, 3); + assert.equal(a.toString(), "3\n4\n1\n2"); + a.moveLinesDown(2, 2); + assert.equal(a.toString(), "3\n4\n2\n1") +}, "__test: move lines up":function() { + var a = new Document(["1", "2", "3", "4"]); + console.log(a.toString().replace(/\n/g, "\\n")); + a.moveLinesUp(2, 3); + console.log(a.toString().replace(/\n/g, "\\n")); + assert.equal(a.toString(), "1\n3\n4\n2"); + a.moveLinesUp(1, 2); + assert.equal(a.toString(), "3\n4\n1\n2"); + a.moveLinesUp(0, 1); + assert.equal(a.toString(), "3\n4\n1\n2"); + a.moveLinesUp(2, 2); + assert.equal(a.toString(), "3\n1\n4\n2") +}, "test: duplicate lines":function() { + var a = new Document(["1", "2", "3", "4"]); + a.duplicateLines(1, 2); + assert.equal(a.toString(), "1\n2\n3\n2\n3\n4") +}, "test: duplicate last line":function() { + var a = new Document(["1", "2", "3"]); + a.duplicateLines(2, 2); + assert.equal(a.toString(), "1\n2\n3\n3") +}, "test: duplicate first line":function() { + var a = new Document(["1", "2", "3"]); + a.duplicateLines(0, 0); + assert.equal(a.toString(), "1\n1\n2\n3") +}, "test: should handle unix style new lines":function() { + var a = new Document(["1", "2", "3"]); + assert.equal(a.toString(), "1\n2\n3") +}, "test: should handle windows style new lines":function() { + var a = new Document("1\r\n2\r\n3"); + a.setNewLineMode("unix"); + assert.equal(a.toString(), "1\n2\n3") +}, "test: set new line mode to 'windows' should use '\r\n' as new lines":function() { + var a = new Document("1\n2\n3"); + a.setNewLineMode("windows"); + assert.equal(a.toString(), "1\r\n2\r\n3") +}, "test: set new line mode to 'unix' should use '\n' as new lines":function() { + var a = new Document("1\r\n2\r\n3"); + a.setNewLineMode("unix"); + assert.equal(a.toString(), "1\n2\n3") +}, "test: set new line mode to 'auto' should detect the incoming nl type":function() { + var a = new Document("1\n2\n3"); + a.setNewLineMode("auto"); + assert.equal(a.toString(), "1\n2\n3"); + a = new Document("1\r\n2\r\n3"); + a.setNewLineMode("auto"); + assert.equal(a.toString(), "1\r\n2\r\n3"); + a.replace(new Range(0, 0, 2, 1), "4\n5\n6"); + assert.equal("4\n5\n6", a.toString()) +}, "__test: undo/redo for delete line":function() { + var a = new Document(["111", "222", "333"]), b = new UndoManager; + a.setUndoManager(b); + var d = a.toString(), c = new Editor(new MockRenderer, a); + c.removeLines(); + var e = a.toString(); + assert.equal(e, "222\n333"); + a.$informUndoManager.call(); + c.removeLines(); + var f = a.toString(); + assert.equal(f, "333"); + a.$informUndoManager.call(); + c.removeLines(); + c = a.toString(); + assert.equal(c, ""); + a.$informUndoManager.call(); + b.undo(); + a.$informUndoManager.call(); + assert.equal(a.toString(), f); + b.undo(); + a.$informUndoManager.call(); + assert.equal(a.toString(), e); + b.undo(); + a.$informUndoManager.call(); + assert.equal(a.toString(), d); + b.undo(); + a.$informUndoManager.call(); + assert.equal(a.toString(), d) +}, "test: convert document to screen coordinates":function() { + var a = new Document("01234\t567890\t1234"); + a.setTabSize(4); + assert.equal(a.documentToScreenColumn(0, 0), 0); + assert.equal(a.documentToScreenColumn(0, 4), 4); + assert.equal(a.documentToScreenColumn(0, 5), 5); + assert.equal(a.documentToScreenColumn(0, 6), 9); + assert.equal(a.documentToScreenColumn(0, 12), 15); + assert.equal(a.documentToScreenColumn(0, 13), 19); + a.setTabSize(2); + assert.equal(a.documentToScreenColumn(0, 0), 0); + assert.equal(a.documentToScreenColumn(0, 4), 4); + assert.equal(a.documentToScreenColumn(0, 5), 5); + assert.equal(a.documentToScreenColumn(0, 6), 7); + assert.equal(a.documentToScreenColumn(0, 12), 13); + assert.equal(a.documentToScreenColumn(0, 13), 15) +}, "test: convert document to scrren coordinates with leading tabs":function() { + var a = new Document("\t\t123"); + a.setTabSize(4); + assert.equal(a.documentToScreenColumn(0, 0), 0); + assert.equal(a.documentToScreenColumn(0, 1), 4); + assert.equal(a.documentToScreenColumn(0, 2), 8); + assert.equal(a.documentToScreenColumn(0, 3), 9) +}, "test: convert screen to document coordinates":function() { + var a = new Document("01234\t567890\t1234"); + a.setTabSize(4); + assert.equal(a.screenToDocumentColumn(0, 0), 0); + assert.equal(a.screenToDocumentColumn(0, 4), 4); + assert.equal(a.screenToDocumentColumn(0, 5), 5); + assert.equal(a.screenToDocumentColumn(0, 6), 5); + assert.equal(a.screenToDocumentColumn(0, 7), 5); + assert.equal(a.screenToDocumentColumn(0, 8), 5); + assert.equal(a.screenToDocumentColumn(0, 9), 6); + assert.equal(a.screenToDocumentColumn(0, 15), 12); + assert.equal(a.screenToDocumentColumn(0, 19), 13) +}}; +module.exports = require("async/test").testcase(Test); +module === require.main && module.exports.exec(); \ No newline at end of file diff --git a/build/ace/test/event_emitter_test.js b/build/ace/test/event_emitter_test.js index 5b91cdfa..e69de29b 100644 --- a/build/ace/test/event_emitter_test.js +++ b/build/ace/test/event_emitter_test.js @@ -1,17 +0,0 @@ -/* - LGPLv3 -*/ -require.def(["ace/lib/oop", "ace/MEventEmitter"], function(d, e) { - var a = function() { - }; - d.implement(a.prototype, e); - new TestCase("EventEmitterTest", {"test: dispatch event with no data":function() { - var b = new a, c = false; - b.addEventListener("juhu", function(f) { - c = true; - assertEquals("juhu", f.type) - }); - b.$dispatchEvent("juhu"); - assertTrue(c) - }}) -}); \ No newline at end of file diff --git a/build/ace/test/mockrenderer.js b/build/ace/test/mockrenderer.js index 80df09eb..54fe2288 100644 --- a/build/ace/test/mockrenderer.js +++ b/build/ace/test/mockrenderer.js @@ -1,7 +1,7 @@ /* LGPLv3 */ -require.def([], function() { +define(function() { MockRenderer = function(a) { this.container = document.createElement("div"); this.cursor = {row:0, column:0}; @@ -52,5 +52,11 @@ require.def([], function() { }; MockRenderer.prototype.setBreakpoints = function() { }; + MockRenderer.prototype.updateFull = function() { + }; + MockRenderer.prototype.showCursor = function() { + }; + MockRenderer.prototype.visualizeFocus = function() { + }; return MockRenderer }); \ No newline at end of file diff --git a/build/ace/test/navigation_test.js b/build/ace/test/navigation_test.js index 7a33ea4d..e69de29b 100644 --- a/build/ace/test/navigation_test.js +++ b/build/ace/test/navigation_test.js @@ -1,77 +0,0 @@ -/* - LGPLv3 -*/ -require.def(["ace/Document", "ace/Editor", "ace/test/MockRenderer"], function(e, c, d) { - TestCase("NavigationTest", {createTextDocument:function(a, b) { - b = (new Array(b + 1)).join("a"); - a = (new Array(a)).join(b + "\n") + b; - return new e(a) - }, "test: navigate to end of file should scroll the last line into view":function() { - var a = this.createTextDocument(200, 10); - a = new c(new d, a); - a.navigateFileEnd(); - var b = a.getCursorPosition(); - assertTrue(a.getFirstVisibleRow() <= b.row); - assertTrue(a.getLastVisibleRow() >= b.row) - }, "test: navigate to start of file should scroll the first row into view":function() { - var a = this.createTextDocument(200, 10); - a = new c(new d, a); - a.moveCursorTo(a.getLastVisibleRow() + 20); - a.navigateFileStart(); - assertEquals(0, a.getFirstVisibleRow()) - }, "test: goto hidden line should scroll the line into the middle of the viewport":function() { - var a = new c(new d, this.createTextDocument(200, 5)); - a.navigateTo(0, 0); - a.gotoLine(101); - assertPosition(100, 0, a.getCursorPosition()); - assertEquals(90, a.getFirstVisibleRow()); - a.navigateTo(100, 0); - a.gotoLine(11); - assertPosition(10, 0, a.getCursorPosition()); - assertEquals(0, a.getFirstVisibleRow()); - a.navigateTo(100, 0); - a.gotoLine(6); - assertPosition(5, 0, a.getCursorPosition()); - assertEquals(0, a.getFirstVisibleRow()); - a.navigateTo(100, 0); - a.gotoLine(1); - assertPosition(0, 0, a.getCursorPosition()); - assertEquals(0, a.getFirstVisibleRow()); - a.navigateTo(0, 0); - a.gotoLine(191); - assertPosition(190, 0, a.getCursorPosition()); - assertEquals(180, a.getFirstVisibleRow()); - a.navigateTo(0, 0); - a.gotoLine(196); - assertPosition(195, 0, a.getCursorPosition()); - assertEquals(180, a.getFirstVisibleRow()) - }, "test: goto visible line should only move the cursor and not scroll":function() { - var a = new c(new d, this.createTextDocument(200, 5)); - a.navigateTo(0, 0); - a.gotoLine(12); - assertPosition(11, 0, a.getCursorPosition()); - assertEquals(0, a.getFirstVisibleRow()); - a.navigateTo(30, 0); - a.gotoLine(33); - assertPosition(32, 0, a.getCursorPosition()); - assertEquals(30, a.getFirstVisibleRow()) - }, "test: navigate from the end of a long line down to a short line and back should maintain the curser column":function() { - var a = new c(new d, new e(["123456", "1"])); - a.navigateTo(0, 6); - assertPosition(0, 6, a.getCursorPosition()); - a.navigateDown(); - assertPosition(1, 1, a.getCursorPosition()); - a.navigateUp(); - assertPosition(0, 6, a.getCursorPosition()) - }, "test: reset desired column on navigate left or right":function() { - var a = new c(new d, new e(["123456", "12"])); - a.navigateTo(0, 6); - assertPosition(0, 6, a.getCursorPosition()); - a.navigateDown(); - assertPosition(1, 2, a.getCursorPosition()); - a.navigateLeft(); - assertPosition(1, 1, a.getCursorPosition()); - a.navigateUp(); - assertPosition(0, 1, a.getCursorPosition()) - }}) -}); \ No newline at end of file diff --git a/build/ace/test/range_test.js b/build/ace/test/range_test.js index 56243724..e69de29b 100644 --- a/build/ace/test/range_test.js +++ b/build/ace/test/range_test.js @@ -1,74 +0,0 @@ -/* - LGPLv3 -*/ -require.def(["ace/Range"], function(b) { - RangeTest = new TestCase("RangeTest", {"test: create range":function() { - var a = new b(1, 2, 3, 4); - assertEquals(1, a.start.row); - assertEquals(2, a.start.column); - assertEquals(3, a.end.row); - assertEquals(4, a.end.column) - }, "test: create from points":function() { - var a = b.fromPoints({row:1, column:2}, {row:3, column:4}); - assertEquals(1, a.start.row); - assertEquals(2, a.start.column); - assertEquals(3, a.end.row); - assertEquals(4, a.end.column) - }, "test: clip to rows":function() { - assertRange(10, 0, 31, 0, (new b(0, 20, 100, 30)).clipRows(10, 30)); - assertRange(10, 0, 30, 10, (new b(0, 20, 30, 10)).clipRows(10, 30)); - var a = new b(0, 20, 3, 10); - a = a.clipRows(10, 30); - assertTrue(a.isEmpty()); - assertRange(10, 0, 10, 0, a) - }, "test: isEmpty":function() { - var a = new b(1, 2, 1, 2); - assertTrue(a.isEmpty()); - a = new b(1, 2, 1, 6); - assertFalse(a.isEmpty()) - }, "test: is multi line":function() { - var a = new b(1, 2, 1, 6); - assertFalse(a.isMultiLine()); - a = new b(1, 2, 2, 6); - assertTrue(a.isMultiLine()) - }, "test: clone":function() { - var a = new b(1, 2, 3, 4), c = a.clone(); - assertPosition(1, 2, c.start); - assertPosition(3, 4, c.end); - c.start.column = 20; - assertPosition(1, 2, a.start); - c.end.column = 20; - assertPosition(3, 4, a.end) - }, "test: contains for multi line ranges":function() { - var a = new b(1, 10, 5, 20); - assertTrue(a.contains(1, 10)); - assertTrue(a.contains(2, 0)); - assertTrue(a.contains(3, 100)); - assertTrue(a.contains(5, 19)); - assertTrue(a.contains(5, 20)); - assertFalse(a.contains(1, 9)); - assertFalse(a.contains(0, 0)); - assertFalse(a.contains(5, 21)) - }, "test: contains for single line ranges":function() { - var a = new b(1, 10, 1, 20); - assertTrue(a.contains(1, 10)); - assertTrue(a.contains(1, 15)); - assertTrue(a.contains(1, 20)); - assertFalse(a.contains(0, 9)); - assertFalse(a.contains(2, 9)); - assertFalse(a.contains(1, 9)); - assertFalse(a.contains(1, 21)) - }, "test: extend range":function() { - var a = new b(2, 10, 2, 30); - a = a.extend(2, 5); - assertRange(2, 5, 2, 30, a); - a = a.extend(2, 35); - assertRange(2, 5, 2, 35, a); - a = a.extend(2, 15); - assertRange(2, 5, 2, 35, a); - a = a.extend(1, 4); - assertRange(1, 4, 2, 35, a); - a = a.extend(6, 10); - assertRange(1, 4, 6, 10, a) - }}) -}); \ No newline at end of file diff --git a/build/ace/test/search_test.js b/build/ace/test/search_test.js index 83494e64..a0b34be2 100644 --- a/build/ace/test/search_test.js +++ b/build/ace/test/search_test.js @@ -1,135 +1,135 @@ /* LGPLv3 */ -require.def(["ace/Document", "ace/Search"], function(c, b) { - new TestCase("SearchTest", {"test: configure the search object":function() { - (new b).set({needle:"juhu", scope:b.ALL}) - }, "test: find simple text in document":function() { - var a = new c(["juhu kinners 123", "456"]); - a = (new b).set({needle:"kinners"}).find(a); - assertPosition(0, 5, a.start); - assertPosition(0, 12, a.end) - }, "test: find simple text in next line":function() { - var a = new c(["abc", "juhu kinners 123", "456"]); - a = (new b).set({needle:"kinners"}).find(a); - assertPosition(1, 5, a.start); - assertPosition(1, 12, a.end) - }, "test: find text starting at cursor position":function() { - var a = new c(["juhu kinners", "juhu kinners 123"]); - a.getSelection().moveCursorTo(0, 6); - a = (new b).set({needle:"kinners"}).find(a); - assertPosition(1, 5, a.start); - assertPosition(1, 12, a.end) - }, "test: wrap search is off by default":function() { - var a = new c(["abc", "juhu kinners 123", "456"]); - a.getSelection().moveCursorTo(2, 1); - var d = (new b).set({needle:"kinners"}); - assertEquals(null, d.find(a)) - }, "test: wrap search should wrap at file end":function() { - var a = new c(["abc", "juhu kinners 123", "456"]); - a.getSelection().moveCursorTo(2, 1); - a = (new b).set({needle:"kinners", wrap:true}).find(a); - assertPosition(1, 5, a.start); - assertPosition(1, 12, a.end) - }, "test: wrap search with no match should return 'null'":function() { - var a = new c(["abc", "juhu kinners 123", "456"]); - a.getSelection().moveCursorTo(2, 1); - var d = (new b).set({needle:"xyz", wrap:true}); - assertEquals(null, d.find(a)) - }, "test: case sensitive is by default off":function() { - var a = new c(["abc", "juhu kinners 123", "456"]), d = (new b).set({needle:"JUHU"}); - assertEquals(null, d.find(a)) - }, "test: case sensitive search":function() { - var a = new c(["abc", "juhu kinners 123", "456"]); - a = (new b).set({needle:"KINNERS", caseSensitive:true}).find(a); - assertPosition(1, 5, a.start); - assertPosition(1, 12, a.end) - }, "test: whole word search should not match inside of words":function() { - var a = new c(["juhukinners", "juhu kinners 123", "456"]); - a = (new b).set({needle:"kinners", wholeWord:true}).find(a); - assertPosition(1, 5, a.start); - assertPosition(1, 12, a.end) - }, "test: find backwards":function() { - var a = new c(["juhu juhu juhu juhu"]); - a.getSelection().moveCursorTo(0, 10); - a = (new b).set({needle:"juhu", backwards:true}).find(a); - assertPosition(0, 5, a.start); - assertPosition(0, 9, a.end) - }, "test: find in selection":function() { - var a = new c(["juhu", "juhu", "juhu", "juhu"]); - a.getSelection().setSelectionAnchor(1, 0); - a.getSelection().selectTo(3, 5); - var d = (new b).set({needle:"juhu", wrap:true, scope:b.SELECTION}), e = d.find(a); - assertPosition(1, 0, e.start); - assertPosition(1, 4, e.end); - a.getSelection().setSelectionAnchor(0, 2); - a.getSelection().selectTo(3, 2); - e = d.find(a); - assertPosition(1, 0, e.start); - assertPosition(1, 4, e.end) - }, "test: find backwards in selection":function() { - var a = new c(["juhu", "juhu", "juhu", "juhu"]), d = (new b).set({needle:"juhu", wrap:true, backwards:true, scope:b.SELECTION}); - a.getSelection().setSelectionAnchor(0, 2); - a.getSelection().selectTo(3, 2); - var e = d.find(a); - assertPosition(2, 0, e.start); - assertPosition(2, 4, e.end); - a.getSelection().setSelectionAnchor(0, 2); - a.getSelection().selectTo(1, 2); - assertEquals(null, d.find(a)) - }, "test: edge case - match directly before the cursor":function() { - var a = new c(["123", "123", "juhu"]), d = (new b).set({needle:"juhu", wrap:true}); - a.getSelection().moveCursorTo(2, 5); - a = d.find(a); - assertPosition(2, 0, a.start); - assertPosition(2, 4, a.end) - }, "test: edge case - match backwards directly after the cursor":function() { - var a = new c(["123", "123", "juhu"]), d = (new b).set({needle:"juhu", wrap:true, backwards:true}); - a.getSelection().moveCursorTo(2, 0); - a = d.find(a); - assertPosition(2, 0, a.start); - assertPosition(2, 4, a.end) - }, "test: find using a regular expression":function() { - var a = new c(["abc123 123 cd", "abc"]); - a = (new b).set({needle:"\\d+", regExp:true}).find(a); - assertPosition(0, 3, a.start); - assertPosition(0, 6, a.end) - }, "test: find using a regular expression and whole word":function() { - var a = new c(["abc123 123 cd", "abc"]); - a = (new b).set({needle:"\\d+\\b", regExp:true, wholeWord:true}).find(a); - assertPosition(0, 7, a.start); - assertPosition(0, 10, a.end) - }, "test: use regular expressions with capture groups":function() { - var a = new c([" ab: 12px", "

-*/ -require.def(["ace/Document"], function(c) { - TestCase("SelectionTest", {createTextDocument:function(a, b) { - b = (new Array(b + 1)).join("a"); - a = (new Array(a)).join(b + "\n") + b; - return new c(a) - }, "test: move cursor to end of file should place the cursor on last row and column":function() { - var a = this.createTextDocument(200, 10).getSelection(); - a.moveCursorFileEnd(); - assertPosition(199, 10, a.getCursor()) - }, "test: moveCursor to start of file should place the cursor on the first row and column":function() { - var a = this.createTextDocument(200, 10).getSelection(); - a.moveCursorFileStart(); - assertPosition(0, 0, a.getCursor()) - }, "test: move selection lead to end of file":function() { - var a = this.createTextDocument(200, 10).getSelection(); - a.moveCursorTo(100, 5); - a.selectFileEnd(); - a = a.getRange(); - assertPosition(100, 5, a.start); - assertPosition(199, 10, a.end) - }, "test: move selection lead to start of file":function() { - var a = this.createTextDocument(200, 10).getSelection(); - a.moveCursorTo(100, 5); - a.selectFileStart(); - a = a.getRange(); - assertPosition(0, 0, a.start); - assertPosition(100, 5, a.end) - }, "test: move cursor word right":function() { - var a = (new c("ab\n Juhu Kinners (abc, 12)\n cde")).getSelection(); - a.moveCursorDown(); - assertPosition(1, 0, a.getCursor()); - a.moveCursorWordRight(); - assertPosition(1, 1, a.getCursor()); - a.moveCursorWordRight(); - assertPosition(1, 5, a.getCursor()); - a.moveCursorWordRight(); - assertPosition(1, 6, a.getCursor()); - a.moveCursorWordRight(); - assertPosition(1, 13, a.getCursor()); - a.moveCursorWordRight(); - assertPosition(1, 15, a.getCursor()); - a.moveCursorWordRight(); - assertPosition(1, 18, a.getCursor()); - a.moveCursorWordRight(); - assertPosition(1, 20, a.getCursor()); - a.moveCursorWordRight(); - assertPosition(1, 22, a.getCursor()); - a.moveCursorWordRight(); - assertPosition(1, 23, a.getCursor()); - a.moveCursorWordRight(); - assertPosition(2, 0, a.getCursor()) - }, "test: select word right if cursor in word":function() { - var a = (new c("Juhu Kinners")).getSelection(); - a.moveCursorTo(0, 2); - a.moveCursorWordRight(); - assertPosition(0, 4, a.getCursor()) - }, "test: moveCursor word left":function() { - var a = (new c("ab\n Juhu Kinners (abc, 12)\n cde")).getSelection(); - a.moveCursorDown(); - a.moveCursorLineEnd(); - assertPosition(1, 23, a.getCursor()); - a.moveCursorWordLeft(); - assertPosition(1, 22, a.getCursor()); - a.moveCursorWordLeft(); - assertPosition(1, 20, a.getCursor()); - a.moveCursorWordLeft(); - assertPosition(1, 18, a.getCursor()); - a.moveCursorWordLeft(); - assertPosition(1, 15, a.getCursor()); - a.moveCursorWordLeft(); - assertPosition(1, 13, a.getCursor()); - a.moveCursorWordLeft(); - assertPosition(1, 6, a.getCursor()); - a.moveCursorWordLeft(); - assertPosition(1, 5, a.getCursor()); - a.moveCursorWordLeft(); - assertPosition(1, 1, a.getCursor()); - a.moveCursorWordLeft(); - assertPosition(1, 0, a.getCursor()); - a.moveCursorWordLeft(); - assertPosition(0, 2, a.getCursor()) - }, "test: select word left if cursor in word":function() { - var a = (new c("Juhu Kinners")).getSelection(); - a.moveCursorTo(0, 8); - a.moveCursorWordLeft(); - assertPosition(0, 5, a.getCursor()) - }, "test: select word right and select":function() { - var a = (new c("Juhu Kinners")).getSelection(); - a.moveCursorTo(0, 0); - a.selectWordRight(); - a = a.getRange(); - assertPosition(0, 0, a.start); - assertPosition(0, 4, a.end) - }, "test: select word left and select":function() { - var a = (new c("Juhu Kinners")).getSelection(); - a.moveCursorTo(0, 3); - a.selectWordLeft(); - a = a.getRange(); - assertPosition(0, 0, a.start); - assertPosition(0, 3, a.end) - }, "test: select word with cursor in word should select the word":function() { - var a = (new c("Juhu Kinners 123")).getSelection(); - a.moveCursorTo(0, 8); - a.selectWord(); - a = a.getRange(); - assertPosition(0, 5, a.start); - assertPosition(0, 12, a.end) - }, "test: select word with cursor betwen white space and word should select the word":function() { - var a = (new c("Juhu Kinners")).getSelection(); - a.moveCursorTo(0, 4); - a.selectWord(); - var b = a.getRange(); - assertPosition(0, 0, b.start); - assertPosition(0, 4, b.end); - a.moveCursorTo(0, 5); - a.selectWord(); - b = a.getRange(); - assertPosition(0, 5, b.start); - assertPosition(0, 12, b.end) - }, "test: select word with cursor in white space should select white space":function() { - var a = (new c("Juhu Kinners")).getSelection(); - a.moveCursorTo(0, 5); - a.selectWord(); - a = a.getRange(); - assertPosition(0, 4, a.start); - assertPosition(0, 6, a.end) - }, "test: moving cursor should fire a 'changeCursor' event":function() { - var a = (new c("Juhu Kinners")).getSelection(); - a.moveCursorTo(0, 5); - var b = false; - a.addEventListener("changeCursor", function() { - b = true - }); - a.moveCursorTo(0, 6); - assertTrue(b) - }, "test: calling setCursor with the same position should not fire an event":function() { - var a = (new c("Juhu Kinners")).getSelection(); - a.moveCursorTo(0, 5); - var b = false; - a.addEventListener("changeCursor", function() { - b = true - }); - a.moveCursorTo(0, 5); - assertFalse(b) - }}) -}); \ No newline at end of file diff --git a/build/ace/test/text_edit_test.js b/build/ace/test/text_edit_test.js index f69ce6f4..218e7848 100644 --- a/build/ace/test/text_edit_test.js +++ b/build/ace/test/text_edit_test.js @@ -1,178 +1,185 @@ /* LGPLv3 */ -require.def(["ace/Document", "ace/Editor", "ace/mode/JavaScript", "ace/test/MockRenderer"], function(c, d, g, e) { - TestCase("TextEditTest", {"test: delete line from the middle":function() { - var b = new c("a\nb\nc\nd"), a = new d(new e, b); - a.moveCursorTo(1, 1); - a.removeLines(); - assertEquals("a\nc\nd", b.toString()); - assertPosition(1, 0, a.getCursorPosition()); - a.removeLines(); - assertEquals("a\nd", b.toString()); - assertPosition(1, 0, a.getCursorPosition()); - a.removeLines(); - assertEquals("a\n", b.toString()); - assertPosition(1, 0, a.getCursorPosition()); - a.removeLines(); - assertEquals("a\n", b.toString()); - assertPosition(1, 0, a.getCursorPosition()) - }, "test: delete multiple selected lines":function() { - var b = new c("a\nb\nc\nd"), a = new d(new e, b); - a.moveCursorTo(1, 1); - a.getSelection().selectDown(); - a.removeLines(); - assertEquals("a\nd", b.toString()); - assertPosition(1, 0, a.getCursorPosition()) - }, "test: delete first line":function() { - var b = new c("a\nb\nc"), a = new d(new e, b); - a.removeLines(); - assertEquals("b\nc", b.toString()); - assertPosition(0, 0, a.getCursorPosition()) - }, "test: delete last":function() { - var b = new c("a\nb\nc"), a = new d(new e, b); - a.moveCursorTo(2, 1); - a.removeLines(); - assertEquals("a\nb\n", b.toString()); - assertPosition(2, 0, a.getCursorPosition()) - }, "test: indent block":function() { - var b = new c("a12345\nb12345\nc12345"), a = new d(new e, b); - a.moveCursorTo(1, 3); - a.getSelection().selectDown(); - a.blockIndent(" "); - assertEquals("a12345\n b12345\n c12345", b.toString()); - assertPosition(2, 7, a.getCursorPosition()); - b = a.getSelectionRange(); - assertPosition(1, 7, b.start); - assertPosition(2, 7, b.end) - }, "test: outdent block":function() { - var b = new c(" a12345\n b12345\n c12345"), a = new d(new e, b); - a.moveCursorTo(0, 3); - a.getSelection().selectDown(); - a.getSelection().selectDown(); - a.blockOutdent(" "); - assertEquals(" a12345\nb12345\n c12345", b.toString()); - assertPosition(2, 1, a.getCursorPosition()); - var f = a.getSelectionRange(); - assertPosition(0, 1, f.start); - assertPosition(2, 1, f.end); - a.blockOutdent(" "); - assertEquals(" a12345\nb12345\n c12345", b.toString()); - f = a.getSelectionRange(); - assertPosition(0, 1, f.start); - assertPosition(2, 1, f.end) - }, "test: outent without a selection should update cursor":function() { - var b = new c(" 12"), a = new d(new e, b); - a.moveCursorTo(0, 3); - a.blockOutdent(" "); - assertEquals(" 12", b.toString()); - assertPosition(0, 1, a.getCursorPosition()) - }, "test: comment lines should perserve selection":function() { - var b = new c(" abc\ncde", new g), a = new d(new e, b); - a.moveCursorTo(0, 2); - a.getSelection().selectDown(); - a.toggleCommentLines(); - assertEquals("// abc\n//cde", b.toString()); - b = a.getSelectionRange(); - assertPosition(0, 4, b.start); - assertPosition(1, 4, b.end) - }, "test: uncomment lines should perserve selection":function() { - var b = new c("// abc\n//cde", new g), a = new d(new e, b); - a.moveCursorTo(0, 1); - a.getSelection().selectDown(); - a.getSelection().selectRight(); - a.getSelection().selectRight(); - a.toggleCommentLines(); - assertEquals(" abc\ncde", b.toString()); - assertRange(0, 0, 1, 1, a.getSelectionRange()) - }, "test: comment lines - if the selection end is at the line start it should stay there":function() { - var b = new c("abc\ncde", new g); - b = new d(new e, b); - b.moveCursorTo(0, 0); - b.getSelection().selectDown(); - b.toggleCommentLines(); - assertRange(0, 2, 1, 0, b.getSelectionRange()); - b = new c("abc\ncde", new g); - b = new d(new e, b); - b.moveCursorTo(1, 0); - b.getSelection().selectUp(); - b.toggleCommentLines(); - assertRange(0, 2, 1, 0, b.getSelectionRange()) - }, "test: move lines down should select moved lines":function() { - var b = new c("11\n22\n33\n44"), a = new d(new e, b); - a.moveCursorTo(0, 1); - a.getSelection().selectDown(); - a.moveLinesDown(); - assertEquals("33\n11\n22\n44", b.toString()); - assertPosition(1, 0, a.getCursorPosition()); - assertPosition(3, 0, a.getSelection().getSelectionAnchor()); - assertPosition(1, 0, a.getSelection().getSelectionLead()); - a.moveLinesDown(); - assertEquals("33\n44\n11\n22", b.toString()); - assertPosition(2, 0, a.getCursorPosition()); - assertPosition(3, 2, a.getSelection().getSelectionAnchor()); - assertPosition(2, 0, a.getSelection().getSelectionLead()); - a.moveLinesDown(); - assertEquals("33\n44\n11\n22", b.toString()); - assertPosition(2, 0, a.getCursorPosition()); - assertPosition(3, 2, a.getSelection().getSelectionAnchor()); - assertPosition(2, 0, a.getSelection().getSelectionLead()) - }, "test: move lines up should select moved lines":function() { - var b = new c("11\n22\n33\n44"), a = new d(new e, b); - a.moveCursorTo(2, 1); - a.getSelection().selectDown(); - a.moveLinesUp(); - assertEquals("11\n33\n44\n22", b.toString()); - assertPosition(1, 0, a.getCursorPosition()); - assertPosition(3, 0, a.getSelection().getSelectionAnchor()); - assertPosition(1, 0, a.getSelection().getSelectionLead()); - a.moveLinesUp(); - assertEquals("33\n44\n11\n22", b.toString()); - assertPosition(0, 0, a.getCursorPosition()); - assertPosition(2, 0, a.getSelection().getSelectionAnchor()); - assertPosition(0, 0, a.getSelection().getSelectionLead()) - }, "test: move line without active selection should move cursor to start of the moved line":function() { - var b = new c("11\n22\n33\n44"), a = new d(new e, b); - a.moveCursorTo(1, 1); - a.clearSelection(); - a.moveLinesDown(); - assertEquals("11\n33\n22\n44", b.toString()); - assertPosition(2, 0, a.getCursorPosition()); - a.clearSelection(); - a.moveLinesUp(); - assertEquals("11\n22\n33\n44", b.toString()); - assertPosition(1, 0, a.getCursorPosition()) - }, "test: copy lines down should select lines and place cursor at the selection start":function() { - var b = new c("11\n22\n33\n44"), a = new d(new e, b); - a.moveCursorTo(1, 1); - a.getSelection().selectDown(); - a.copyLinesDown(); - assertEquals("11\n22\n33\n22\n33\n44", b.toString()); - assertPosition(3, 0, a.getCursorPosition()); - assertPosition(5, 0, a.getSelection().getSelectionAnchor()); - assertPosition(3, 0, a.getSelection().getSelectionLead()) - }, "test: copy lines up should select lines and place cursor at the selection start":function() { - var b = new c("11\n22\n33\n44"), a = new d(new e, b); - a.moveCursorTo(1, 1); - a.getSelection().selectDown(); - a.copyLinesUp(); - assertEquals("11\n22\n33\n22\n33\n44", b.toString()); - assertPosition(1, 0, a.getCursorPosition()); - assertPosition(3, 0, a.getSelection().getSelectionAnchor()); - assertPosition(1, 0, a.getSelection().getSelectionLead()) - }, "test: input a tab with soft tab should convert it to spaces":function() { - var b = new c(""), a = new d(new e, b); - b.setTabSize(2); - b.setUseSoftTabs(true); - a.onTextInput("\t"); - assertEquals(" ", b.toString()); - b.setTabSize(5); - a.onTextInput("\t"); - assertEquals(" ", b.toString()) - }, "test: input tab without soft tabs should keep the tab character":function() { - var b = new c(""), a = new d(new e, b); - b.setUseSoftTabs(false); - a.onTextInput("\t"); - assertEquals("\t", b.toString()) - }}) -}); \ No newline at end of file +require("../../../support/paths"); +var dom = require("jsdom/level2/html").dom.level2.html, browser = require("jsdom/browser/index").windowAugmentation(dom); +global.document = browser.document; +global.window = browser.window; +global.self = browser.self; +global.navigator = browser.navigator; +global.location = browser.location; +var Document = require("../document"), Editor = require("../editor"), JavaScriptMode = require("../mode/javascript"), MockRenderer = require("./mockrenderer"), assert = require("./assertions"), Test = {"test: delete line from the middle":function() { + var b = new Document("a\nb\nc\nd"), a = new Editor(new MockRenderer, b); + a.moveCursorTo(1, 1); + a.removeLines(); + assert.equal(b.toString(), "a\nc\nd"); + assert.position(a.getCursorPosition(), 1, 0); + a.removeLines(); + assert.equal(b.toString(), "a\nd"); + assert.position(a.getCursorPosition(), 1, 0); + a.removeLines(); + assert.equal(b.toString(), "a\n"); + assert.position(a.getCursorPosition(), 1, 0); + a.removeLines(); + assert.equal(b.toString(), "a\n"); + assert.position(a.getCursorPosition(), 1, 0) +}, "test: delete multiple selected lines":function() { + var b = new Document("a\nb\nc\nd"), a = new Editor(new MockRenderer, b); + a.moveCursorTo(1, 1); + a.getSelection().selectDown(); + a.removeLines(); + assert.equal(b.toString(), "a\nd"); + assert.position(a.getCursorPosition(), 1, 0) +}, "test: delete first line":function() { + var b = new Document("a\nb\nc"), a = new Editor(new MockRenderer, b); + a.removeLines(); + assert.equal(b.toString(), "b\nc"); + assert.position(a.getCursorPosition(), 0, 0) +}, "test: delete last":function() { + var b = new Document("a\nb\nc"), a = new Editor(new MockRenderer, b); + a.moveCursorTo(2, 1); + a.removeLines(); + assert.equal(b.toString(), "a\nb\n"); + assert.position(a.getCursorPosition(), 2, 0) +}, "__test: indent block":function() { + var b = new Document("a12345\nb12345\nc12345"), a = new Editor(new MockRenderer, b); + a.moveCursorTo(1, 3); + a.getSelection().selectDown(); + a.blockIndent(" "); + assert.equal("a12345\n b12345\n c12345", b.toString()); + assert.position(a.getCursorPosition(), 2, 7); + b = a.getSelectionRange(); + assert.position(b.start, 1, 7); + assert.position(b.end, 2, 7) +}, "__test: outdent block":function() { + var b = new Document(" a12345\n b12345\n c12345"), a = new Editor(new MockRenderer, b); + a.moveCursorTo(0, 3); + a.getSelection().selectDown(); + a.getSelection().selectDown(); + a.blockOutdent(" "); + assert.equal(b.toString(), " a12345\nb12345\n c12345"); + assert.position(a.getCursorPosition(), 2, 0); + var c = a.getSelectionRange(); + assert.position(c.start, 0, 1); + assert.position(c.end, 2, 1); + a.blockOutdent(" "); + assert.equal(b.toString(), "a12345\nb12345\nc12345"); + c = a.getSelectionRange(); + assert.position(c.start, 0, 1); + assert.position(c.end, 2, 1) +}, "test: outent without a selection should update cursor":function() { + var b = new Document(" 12"), a = new Editor(new MockRenderer, b); + a.moveCursorTo(0, 3); + a.blockOutdent(" "); + assert.equal(b.toString(), " 12"); + assert.position(a.getCursorPosition(), 0, 0) +}, "test: comment lines should perserve selection":function() { + var b = new Document(" abc\ncde", new JavaScriptMode), a = new Editor(new MockRenderer, b); + a.moveCursorTo(0, 2); + a.getSelection().selectDown(); + a.toggleCommentLines(); + assert.equal("// abc\n//cde", b.toString()); + b = a.getSelectionRange(); + assert.position(b.start, 0, 4); + assert.position(b.end, 1, 4) +}, "test: uncomment lines should perserve selection":function() { + var b = new Document("// abc\n//cde", new JavaScriptMode), a = new Editor(new MockRenderer, b); + a.moveCursorTo(0, 1); + a.getSelection().selectDown(); + a.getSelection().selectRight(); + a.getSelection().selectRight(); + a.toggleCommentLines(); + assert.equal(" abc\ncde", b.toString()); + assert.range(a.getSelectionRange(), 0, 0, 1, 1) +}, "test: comment lines - if the selection end is at the line start it should stay there":function() { + var b = new Document("abc\ncde", new JavaScriptMode); + b = new Editor(new MockRenderer, b); + b.moveCursorTo(0, 0); + b.getSelection().selectDown(); + b.toggleCommentLines(); + assert.range(b.getSelectionRange(), 0, 2, 1, 0); + b = new Document("abc\ncde", new JavaScriptMode); + b = new Editor(new MockRenderer, b); + b.moveCursorTo(1, 0); + b.getSelection().selectUp(); + b.toggleCommentLines(); + assert.range(b.getSelectionRange(), 0, 2, 1, 0) +}, "test: move lines down should select moved lines":function() { + var b = new Document("11\n22\n33\n44"), a = new Editor(new MockRenderer, b); + a.moveCursorTo(0, 1); + a.getSelection().selectDown(); + a.moveLinesDown(); + assert.equal("33\n11\n22\n44", b.toString()); + assert.position(a.getCursorPosition(), 1, 0); + assert.position(a.getSelection().getSelectionAnchor(), 3, 0); + assert.position(a.getSelection().getSelectionLead(), 1, 0); + a.moveLinesDown(); + assert.equal("33\n44\n11\n22", b.toString()); + assert.position(a.getCursorPosition(), 2, 0); + assert.position(a.getSelection().getSelectionAnchor(), 3, 2); + assert.position(a.getSelection().getSelectionLead(), 2, 0); + a.moveLinesDown(); + assert.equal("33\n44\n11\n22", b.toString()); + assert.position(a.getCursorPosition(), 2, 0); + assert.position(a.getSelection().getSelectionAnchor(), 3, 2); + assert.position(a.getSelection().getSelectionLead(), 2, 0) +}, "__test: move lines up should select moved lines":function() { + var b = new Document("11\n22\n33\n44"), a = new Editor(new MockRenderer, b); + a.moveCursorTo(2, 1); + a.getSelection().selectDown(); + a.moveLinesUp(); + assert.equal(b.toString(), "11\n33\n44\n22"); + assert.position(a.getCursorPosition(), 1, 0); + assert.position(a.getSelection().getSelectionAnchor(), 3, 0); + assert.position(a.getSelection().getSelectionLead(), 1, 0); + a.moveLinesUp(); + assert.equal(b.toString(), "33\n44\n11\n22"); + assert.position(a.getCursorPosition(), 0, 0); + assert.position(a.getSelection().getSelectionAnchor(), 2, 0); + assert.position(a.getSelection().getSelectionLead(), 0, 0) +}, "test: move line without active selection should move cursor to start of the moved line":function() { + var b = new Document("11\n22\n33\n44"), a = new Editor(new MockRenderer, b); + a.moveCursorTo(1, 1); + a.clearSelection(); + a.moveLinesDown(); + assert.equal("11\n33\n22\n44", b.toString()); + assert.position(a.getCursorPosition(), 2, 0); + a.clearSelection(); + a.moveLinesUp(); + assert.equal("11\n22\n33\n44", b.toString()); + assert.position(a.getCursorPosition(), 1, 0) +}, "test: copy lines down should select lines and place cursor at the selection start":function() { + var b = new Document("11\n22\n33\n44"), a = new Editor(new MockRenderer, b); + a.moveCursorTo(1, 1); + a.getSelection().selectDown(); + a.copyLinesDown(); + assert.equal("11\n22\n33\n22\n33\n44", b.toString()); + assert.position(a.getCursorPosition(), 3, 0); + assert.position(a.getSelection().getSelectionAnchor(), 5, 0); + assert.position(a.getSelection().getSelectionLead(), 3, 0) +}, "test: copy lines up should select lines and place cursor at the selection start":function() { + var b = new Document("11\n22\n33\n44"), a = new Editor(new MockRenderer, b); + a.moveCursorTo(1, 1); + a.getSelection().selectDown(); + a.copyLinesUp(); + assert.equal("11\n22\n33\n22\n33\n44", b.toString()); + assert.position(a.getCursorPosition(), 1, 0); + assert.position(a.getSelection().getSelectionAnchor(), 3, 0); + assert.position(a.getSelection().getSelectionLead(), 1, 0) +}, "test: input a tab with soft tab should convert it to spaces":function() { + var b = new Document(""), a = new Editor(new MockRenderer, b); + b.setTabSize(2); + b.setUseSoftTabs(true); + a.onTextInput("\t"); + assert.equal(b.toString(), " "); + b.setTabSize(5); + a.onTextInput("\t"); + assert.equal(b.toString(), " ") +}, "test: input tab without soft tabs should keep the tab character":function() { + var b = new Document(""), a = new Editor(new MockRenderer, b); + b.setUseSoftTabs(false); + a.onTextInput("\t"); + assert.equal(b.toString(), "\t") +}}; +module.exports = require("async/test").testcase(Test); +module === require.main && module.exports.exec(); \ No newline at end of file diff --git a/build/ace/test/virtual_renderer_test.js b/build/ace/test/virtual_renderer_test.js index 8c3a51c3..a594764a 100644 --- a/build/ace/test/virtual_renderer_test.js +++ b/build/ace/test/virtual_renderer_test.js @@ -1,27 +1,28 @@ /* LGPLv3 */ -require.def(["ace/Document", "ace/VirtualRenderer"], function(c, d) { - new TestCase("VirtualRendererTest", {"test: screen2text the column should be rounded to the next character edge":function() { - var b = document.createElement("div"); - b.style.left = "0px"; - b.style.top = "0px"; - b.style.width = "100px"; - b.style.height = "100px"; - document.body.style.margin = "0px"; - document.body.style.padding = "0px"; - document.body.appendChild(b); - var a = new d(b); - a.setDocument(new c("1234")); - a.characterWidth = 10; - a.lineHeight = 15; - assertPosition(0, 0, a.screenToTextCoordinates(0, 0)); - assertPosition(0, 0, a.screenToTextCoordinates(4, 0)); - assertPosition(0, 1, a.screenToTextCoordinates(5, 0)); - assertPosition(0, 1, a.screenToTextCoordinates(9, 0)); - assertPosition(0, 1, a.screenToTextCoordinates(10, 0)); - assertPosition(0, 1, a.screenToTextCoordinates(14, 0)); - assertPosition(0, 2, a.screenToTextCoordinates(15, 0)); - document.body.removeChild(b) - }}) -}); \ No newline at end of file +require("../../../support/paths"); +var Document = "../document", VirtualRenderer = "../virtual_renderer", assert = "../assertions", Test = {"test: screen2text the column should be rounded to the next character edge":function() { + var b = document.createElement("div"); + b.style.left = "0px"; + b.style.top = "0px"; + b.style.width = "100px"; + b.style.height = "100px"; + document.body.style.margin = "0px"; + document.body.style.padding = "0px"; + document.body.appendChild(b); + var a = new VirtualRenderer(b); + a.setDocument(new Document("1234")); + a.characterWidth = 10; + a.lineHeight = 15; + assert.position(a.screenToTextCoordinates(0, 0), 0, 0); + assert.position(a.screenToTextCoordinates(4, 0), 0, 0); + assert.position(a.screenToTextCoordinates(5, 0), 0, 1); + assert.position(a.screenToTextCoordinates(9, 0), 0, 1); + assert.position(a.screenToTextCoordinates(10, 0), 0, 1); + assert.position(a.screenToTextCoordinates(14, 0), 0, 1); + assert.position(a.screenToTextCoordinates(15, 0), 0, 2); + document.body.removeChild(b) +}}; +module.exports = require("async/test").testcase(Test); +module === require.main && module.exports.exec(); \ No newline at end of file diff --git a/build/ace/virtual_renderer.js b/build/ace/virtual_renderer.js index d6913644..b2121244 100644 --- a/build/ace/virtual_renderer.js +++ b/build/ace/virtual_renderer.js @@ -6,12 +6,12 @@ define(["require", "exports", "module", 'text!ace/css/editor.css!.ace_editor {\n this.container = a; f.addCssClass(this.container, "ace_editor"); this.setTheme(b); - this.scroller = document.createElement("div"); - this.scroller.className = "ace_scroller"; - this.container.appendChild(this.scroller); this.$gutter = document.createElement("div"); this.$gutter.className = "ace_gutter"; this.container.appendChild(this.$gutter); + this.scroller = document.createElement("div"); + this.scroller.className = "ace_scroller"; + this.container.appendChild(this.scroller); this.content = document.createElement("div"); this.content.style.position = "absolute"; this.scroller.appendChild(this.content); @@ -196,7 +196,7 @@ define(["require", "exports", "module", 'text!ace/css/editor.css!.ace_editor {\n this.$updateScrollBar() }else { if(a & this.CHANGE_SCROLL) { - a & this.CHANGE_TEXT || a & this.CHANGE_LINES ? this.$textLayer.scrollLines(this.layerConfig) : this.$textLayer.update(this.layerConfig); + a & this.CHANGE_TEXT || a & this.CHANGE_LINES ? this.$textLayer.update(this.layerConfig) : this.$textLayer.scrollLines(this.layerConfig); this.showGutter && this.$gutterLayer.update(this.layerConfig); this.$markerLayer.update(this.layerConfig); this.$cursorLayer.update(this.layerConfig); @@ -209,11 +209,6 @@ define(["require", "exports", "module", 'text!ace/css/editor.css!.ace_editor {\n if(a & this.CHANGE_LINES) { this.$updateLines(); this.$updateScrollBar() - }else { - if(a & this.CHANGE_SCROLL) { - this.$textLayer.scrollLines(this.layerConfig); - this.showGutter && this.$gutterLayer.update(this.layerConfig) - } } }a & this.CHANGE_GUTTER && this.showGutter && this.$gutterLayer.update(this.layerConfig); a & this.CHANGE_CURSOR && this.$cursorLayer.update(this.layerConfig); @@ -363,7 +358,7 @@ define(["require", "exports", "module", 'text!ace/css/editor.css!.ace_editor {\n } var c = this; if(!a || typeof a == "string") { - a = a || "ace/theme/TextMate"; + a = a || "ace/theme/textmate"; d([a], function(e) { b(e) }) diff --git a/build/build.txt b/build/build.txt index ccdafa0a..db072cfc 100644 --- a/build/build.txt +++ b/build/build.txt @@ -55,3 +55,9 @@ ace/mode/html.js ---------------- ace/mode/html_highlight_rules.js ace/mode/html.js + +ace/mode/python.js +---------------- +ace/mode/python_highlight_rules.js +ace/mode/matching_brace_outdent.js +ace/mode/python.js diff --git a/demo/boot.js b/demo/boot.js new file mode 100644 index 00000000..1e63002a --- /dev/null +++ b/demo/boot.js @@ -0,0 +1,126 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Skywriter. + * + * The Initial Developer of the Original Code is + * Mozilla. + * Portions created by the Initial Developer are Copyright (C) 2009 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Kevin Dangoor (kdangoor@mozilla.com) + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +// TODO: Yuck! A global function +var setupPlugins = function(config, callback) { + config = config || {}; + if (!config.pluginDirs) { + config.pluginDirs = {}; + } + // config.pluginDirs["../lib"] = { + // packages: ["ace"] + // }; + config.pluginDirs["../plugins"] = { + packages: ["pilot", "cockpit"] + }; + + var knownPlugins = []; + + var pluginPackageInfo = { + "../lib": [ + { + name: "ace", + lib: "." + } + ] + }; + + var paths = {}; + var i; + var location; + + // we need to ensure that the core plugin directory is loaded first + var pluginDirs = []; + var pluginDir; + for (pluginDir in config.pluginDirs) { + pluginDirs.push(pluginDir); + } + pluginDirs.sort(function(a, b) { + if (a == "../plugins") { + return -1; + } else if (b == "../plugins") { + return 1; + } else if (a < b) { + return -1; + } else if (b < a) { + return 1; + } else { + return 0; + } + }); + + // set up RequireJS to know that our plugins all have a main module called "index" + for (var dirNum = 0; dirNum < pluginDirs.length; dirNum++) { + pluginDir = pluginDirs[dirNum]; + var dirInfo = config.pluginDirs[pluginDir]; + if (dirInfo.packages) { + location = pluginPackageInfo[pluginDir]; + if (location === undefined) { + pluginPackageInfo[pluginDir] = location = []; + } + var packages = dirInfo.packages; + for (i = 0; i < packages.length; i++) { + location.push({ + name: packages[i], + main: "index", + lib: "." + }); + knownPlugins.push(packages[i]); + } + } + if (dirInfo.singleFiles) { + for (i = 0; i < dirInfo.singleFiles.length; i++) { + var pluginName = dirInfo.singleFiles[i]; + paths[pluginName] = pluginDir + "/" + pluginName; + knownPlugins.push(pluginName); + } + } + } + require({ + packagePaths: pluginPackageInfo, + paths: paths + }); + require(["pilot/fixoldbrowsers", "pilot/plugin_manager", "pilot/settings"], function() { + var pluginsModule = require("pilot/plugin_manager"); + var settings = require("pilot/settings").settings; + var catalog = pluginsModule.catalog; + catalog.registerPlugins(knownPlugins); + if (callback) { + callback(pluginsModule, settings); + } + }); +}; diff --git a/demo/demo_startup.js b/demo/demo_startup.js new file mode 100644 index 00000000..99823cc9 --- /dev/null +++ b/demo/demo_startup.js @@ -0,0 +1,210 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Skywriter. + * + * The Initial Developer of the Original Code is + * Mozilla. + * Portions created by the Initial Developer are Copyright (C) 2009 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Fabian Jakobs + * Kevin Dangoor (kdangoor@mozilla.com) + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + + +define(function(require, exports, module) { + +exports.launch = function(env) { + + var event = require("pilot/event").event; + var Editor = require("ace/editor").Editor; + var Renderer = require("ace/virtual_renderer").VirtualRenderer; + var theme = require("ace/theme/textmate"); + var Document = require("ace/document").Document; + var JavaScriptMode = require("ace/mode/javascript").Mode; + var CssMode = require("ace/mode/css").Mode; + var HtmlMode = require("ace/mode/html").Mode; + var XmlMode = require("ace/mode/xml").Mode; + var PythonMode = require("ace/mode/python").Mode; + var TextMode = require("ace/mode/text").Mode; + var UndoManager = require("ace/undomanager").UndoManager; + + var docs = {}; + + docs.js = new Document(document.getElementById("jstext").innerHTML); + docs.js.setMode(new JavaScriptMode()); + docs.js.setUndoManager(new UndoManager()); + + docs.css = new Document(document.getElementById("csstext").innerHTML); + docs.css.setMode(new CssMode()); + docs.css.setUndoManager(new UndoManager()); + + docs.html = new Document(document.getElementById("htmltext").innerHTML); + docs.html.setMode(new HtmlMode()); + docs.html.setUndoManager(new UndoManager()); + + docs.python = new Document(document.getElementById("pythontext").innerHTML); + docs.python.setMode(new PythonMode()); + docs.python.setUndoManager(new UndoManager()); + + var docEl = document.getElementById("doc"); + + var container = document.getElementById("editor"); + env.editor = new Editor(new Renderer(container, theme)); + + function onDocChange() { + var doc = getDoc(); + env.editor.setDocument(doc); + + var mode = doc.getMode(); + if (mode instanceof JavaScriptMode) { + modeEl.value = "javascript"; + } + else if (mode instanceof CssMode) { + modeEl.value = "css"; + } + else if (mode instanceof HtmlMode) { + modeEl.value = "html"; + } + else if (mode instanceof XmlMode) { + modeEl.value = "xml"; + } + else if (mode instanceof PythonMode) { + modeEl.value = "python"; + } + else { + modeEl.value = "text"; + } + + env.editor.focus(); + } + docEl.onchange = onDocChange; + + function getDoc() { + return docs[docEl.value]; + } + + var modeEl = document.getElementById("mode"); + modeEl.onchange = function() { + env.editor.getDocument().setMode(modes[modeEl.value] || modes.text); + }; + + var modes = { + text: new TextMode(), + xml: new XmlMode(), + html: new HtmlMode(), + css: new CssMode(), + javascript: new JavaScriptMode(), + python: new PythonMode() + }; + + function getMode() { + return modes[modeEl.value]; + } + + var themeEl = document.getElementById("theme"); + themeEl.onchange = function() { + env.editor.setTheme(themeEl.value); + }; + + var selectEl = document.getElementById("select_style"); + selectEl.onchange = function() { + if (selectEl.checked) { + env.editor.setSelectionStyle("line"); + } else { + env.editor.setSelectionStyle("text"); + } + }; + + var activeEl = document.getElementById("highlight_active"); + activeEl.onchange = function() { + env.editor.setHighlightActiveLine(!!activeEl.checked); + }; + + onDocChange(); + + window.jump = function() { + var jump = document.getElementById("jump"); + var cursor = env.editor.getCursorPosition(); + var pos = env.editor.renderer.textToScreenCoordinates(cursor.row, cursor.column); + jump.style.left = pos.pageX + "px"; + jump.style.top = pos.pageY + "px"; + jump.style.display = "block"; + }; + + function onResize() { + container.style.width = (document.documentElement.clientWidth - 4) + "px"; + container.style.height = (document.documentElement.clientHeight - 55 - 4 - 23) + "px"; + env.editor.resize(); + }; + + window.onresize = onResize; + onResize(); + + event.addListener(container, "dragover", function(e) { + return event.preventDefault(e); + }); + + event.addListener(container, "drop", function(e) { + try { + var file = e.dataTransfer.files[0]; + } catch(e) { + return event.stopEvent(); + } + + if (window.FileReader) { + var reader = new FileReader(); + reader.onload = function(e) { + env.editor.getSelection().selectAll(); + + var mode = "text"; + if (/^.*\.js$/i.test(file.name)) { + mode = "javascript"; + } else if (/^.*\.xml$/i.test(file.name)) { + mode = "xml"; + } else if (/^.*\.html$/i.test(file.name)) { + mode = "html"; + } else if (/^.*\.css$/i.test(file.name)) { + mode = "css"; + } else if (/^.*\.py$/i.test(file.name)) { + mode = "python"; + } + + env.editor.onTextInput(reader.result); + + modeEl.value = mode; + env.editor.getDocument().setMode(modes[mode]); + }; + reader.readAsText(file); + } + + return event.preventDefault(e); + }); +}; + +}); diff --git a/demo/editor-build.html b/demo/editor-build.html deleted file mode 100644 index 7f791814..00000000 --- a/demo/editor-build.html +++ /dev/null @@ -1,299 +0,0 @@ - - - - - - Editor - - - - - - - -
- - - - - - - - - - -
- - - - - - - - - - - - - - - - -
- -
-
- - - - - - - - - - - \ No newline at end of file diff --git a/demo/editor.html b/demo/editor.html deleted file mode 100644 index 1d5c1718..00000000 --- a/demo/editor.html +++ /dev/null @@ -1,298 +0,0 @@ - - - - - - Editor - - - - - - -
- - - - - - - - - - -
- - - - - - - - - - - - - - - - -
- -
-
- - - - - - - - - - - \ No newline at end of file diff --git a/demo/require.js b/demo/require.js index 29462455..1f94622e 100644 --- a/demo/require.js +++ b/demo/require.js @@ -13,16 +13,20 @@ setInterval: false, importScripts: false, jQuery: false */ var require, define; (function () { //Change this version number for each release. - var version = "0.14.5", + var version = "0.14.5+", empty = {}, s, i, defContextName = "_", contextLoads = [], scripts, script, rePkg, src, m, dataMain, cfg = {}, setReadyState, - readyRegExp = /^(complete|loaded)$/, commentRegExp = /(\/\*([\s\S]*?)\*\/|\/\/(.*)$)/mg, - cjsRequireRegExp = /require\(["']([\w-_\.\/]+)["']\)/g, + cjsRequireRegExp = /require\(["']([\w\!\-_\.\/]+)["']\)/g, main, isBrowser = !!(typeof window !== "undefined" && navigator && document), isWebWorker = !isBrowser && typeof importScripts !== "undefined", + //PS3 indicates loaded and complete, but need to wait for complete + //specifically. Sequence is "loading", "loaded", execution, + // then "complete". The UA check is unfortunate, but not sure how + //to feature test w/o causing perf issues. + readyRegExp = isBrowser && navigator.platform === 'PLAYSTATION 3' ? /^complete$/ : /^(complete|loaded)$/, ostring = Object.prototype.toString, ap = Array.prototype, aps = ap.slice, scrollIntervalId, req, baseElement, @@ -882,12 +886,12 @@ var require, define; } contextName = contextName || s.ctxName; - var ret, context = s.contexts[contextName]; + var ret, context = s.contexts[contextName], nameProps; //Normalize module name, if it contains . or .. - moduleName = req.normalizeName(moduleName, relModuleName, context); + nameProps = req.splitPrefix(moduleName, relModuleName, context); - ret = context.defined[moduleName]; + ret = context.defined[nameProps.name]; if (ret === undefined) { req.onError(new Error("require: module name '" + moduleName + @@ -940,7 +944,7 @@ var require, define; } }; - req.jsExtRegExp = /\.js$/; + req.jsExtRegExp = /^\/|:|\?|\.js$/; /** * Given a relative module name, like ./something, normalize it to @@ -955,37 +959,44 @@ var require, define; //Adjust any relative paths. var part; if (name.charAt(0) === ".") { - if (!baseName) { - req.onError(new Error("Cannot normalize module name: " + - name + - ", no relative module name available.")); - } - - if (context.config.packages[baseName]) { - //If the baseName is a package name, then just treat it as one - //name to concat the name with. - baseName = [baseName]; - } else { - //Convert baseName to array, and lop off the last part, - //so that . matches that "directory" and not name of the baseName's - //module. For instance, baseName of "one/two/three", maps to - //"one/two/three.js", but we want the directory, "one/two" for - //this normalization. - baseName = baseName.split("/"); - baseName = baseName.slice(0, baseName.length - 1); - } - - name = baseName.concat(name.split("/")); - for (i = 0; (part = name[i]); i++) { - if (part === ".") { - name.splice(i, 1); - i -= 1; - } else if (part === "..") { - name.splice(i - 1, 2); - i -= 2; + //If have a base name, try to normalize against it, + //otherwise, assume it is a top-level require that will + //be relative to baseUrl in the end. + if (baseName) { + if (context.config.packages[baseName]) { + //If the baseName is a package name, then just treat it as one + //name to concat the name with. + baseName = [baseName]; + } else { + //Convert baseName to array, and lop off the last part, + //so that . matches that "directory" and not name of the baseName's + //module. For instance, baseName of "one/two/three", maps to + //"one/two/three.js", but we want the directory, "one/two" for + //this normalization. + baseName = baseName.split("/"); + baseName = baseName.slice(0, baseName.length - 1); } + + name = baseName.concat(name.split("/")); + for (i = 0; (part = name[i]); i++) { + if (part === ".") { + name.splice(i, 1); + i -= 1; + } else if (part === "..") { + if (i === 1) { + //End of the line. Keep at least one non-dot + //path segment at the front so it can be mapped + //correctly to disk. Otherwise, there is likely + //no path mapping for '..'. + break; + } else if (i > 1) { + name.splice(i - 1, 2); + i -= 2; + } + } + } + name = name.join("/"); } - name = name.join("/"); } return name; }; @@ -1035,7 +1046,7 @@ var require, define; //If a colon is in the URL, it indicates a protocol is used and it is just //an URL to a file, or if it starts with a slash or ends with .js, it is just a plain file. //The slash is important for protocol-less URLs as well as full paths. - if (moduleName.indexOf(":") !== -1 || moduleName.charAt(0) === '/' || req.jsExtRegExp.test(moduleName)) { + if (req.jsExtRegExp.test(moduleName)) { //Just a plain path, not module name lookup, so just return it. //Add extension if it is included. This is a bit wonky, only non-.js things pass //an extension, this method probably needs to be reworked. @@ -1078,6 +1089,11 @@ var require, define; config.urlArgs) : url; }; + //In async environments, checkLoaded can get called a few times in the same + //call stack. Allow only one to do the finishing work. Set to false + //for sync environments. + req.blockCheckLoaded = true; + /** * Checks if all modules for a context are loaded, and if so, evaluates the * new ones in right dependency order. @@ -1119,7 +1135,7 @@ var require, define; //by calling a waiting callback that then calls require and then this function //should not proceed. At the end of this function, if there are still things //waiting, then checkLoaded will be called again. - context.isCheckLoaded = true; + context.isCheckLoaded = req.blockCheckLoaded; //Grab waiting and loaded lists here, since it could have changed since //this function was first called. @@ -2477,4 +2493,4 @@ var require, define; }()); //Target build file for a require.js that has all of require's functionality, -//and includes specific plugins: i18n and text. \ No newline at end of file +//and includes specific plugins: i18n and text. diff --git a/editor.html b/editor.html new file mode 100644 index 00000000..81ceef48 --- /dev/null +++ b/editor.html @@ -0,0 +1,183 @@ + + + + + + Editor + + + + + + + + + +
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + +
+ +
+
+ + + + + + + + + + + + + \ No newline at end of file diff --git a/lib/ace/background_tokenizer.js b/lib/ace/background_tokenizer.js index d3d6828f..811eeb8d 100644 --- a/lib/ace/background_tokenizer.js +++ b/lib/ace/background_tokenizer.js @@ -37,8 +37,8 @@ define(function(require, exports, module) { -var oop = require("./lib/oop"); -var MEventEmitter = require("./event_emitter"); +var oop = require("pilot/oop").oop; +var EventEmitter = require("pilot/event_emitter").EventEmitter; var BackgroundTokenizer = function(tokenizer, editor) { this.running = false; @@ -82,7 +82,7 @@ var BackgroundTokenizer = function(tokenizer, editor) { (function(){ - oop.implement(this, MEventEmitter); + oop.implement(this, EventEmitter); this.setTokenizer = function(tokenizer) { this.tokenizer = tokenizer; @@ -103,7 +103,7 @@ var BackgroundTokenizer = function(tokenizer, editor) { first: firstRow, last: lastRow }; - this.$dispatchEvent("update", {data: data}); + this._dispatchEvent("update", {data: data}); }; this.start = function(startRow) { @@ -164,5 +164,5 @@ var BackgroundTokenizer = function(tokenizer, editor) { }).call(BackgroundTokenizer.prototype); -return BackgroundTokenizer; +exports.BackgroundTokenizer = BackgroundTokenizer; }); diff --git a/lib/ace/commands/default_commands.js b/lib/ace/commands/default_commands.js index 8d6a221a..4e7d66b1 100644 --- a/lib/ace/commands/default_commands.js +++ b/lib/ace/commands/default_commands.js @@ -37,158 +37,211 @@ define(function(require, exports, module) { -var PluginManager = require("../plugin_manager"); +var canon = require("pilot/canon"); -PluginManager.registerCommand("selectall", function(editor, selection) { - selection.selectAll(); +canon.addCommand({ + name: "selectall", + exec: function(env, args, request) { env.selection.selectAll(); } }); -PluginManager.registerCommand("removeline", function(editor, selection) { - editor.removeLines(); +canon.addCommand({ + name: "removeline", + exec: function(env, args, request) { env.editor.removeLines(); } }); -PluginManager.registerCommand("gotoline", function(editor, selection) { - var line = parseInt(prompt("Enter line number:")); - if (!isNaN(line)) { - editor.gotoLine(line); +canon.addCommand({ + name: "gotoline", + exec: function(env, args, request) { + var line = parseInt(prompt("Enter line number:")); + if (!isNaN(line)) { + env.editor.gotoLine(line); + } } }); -PluginManager.registerCommand("togglecomment", function(editor, selection) { - editor.toggleCommentLines(); +canon.addCommand({ + name: "togglecomment", + exec: function(env, args, request) { env.editor.toggleCommentLines(); } }); -PluginManager.registerCommand("findnext", function(editor, selection) { - editor.findNext(); +canon.addCommand({ + name: "findnext", + exec: function(env, args, request) { env.editor.findNext(); } }); -PluginManager.registerCommand("findprevious", function(editor, selection) { - editor.findPrevious(); +canon.addCommand({ + name: "findprevious", + exec: function(env, args, request) { env.editor.findPrevious(); } }); -PluginManager.registerCommand("find", function(editor, selection) { - var needle = prompt("Find:"); - editor.find(needle); +canon.addCommand({ + name: "find", + exec: function(env, args, request) { + var needle = prompt("Find:"); + env.editor.find(needle); + } }); -PluginManager.registerCommand("undo", function(editor, selection) { - editor.undo(); +canon.addCommand({ + name: "undo", + exec: function(env, args, request) { env.editor.undo(); } }); -PluginManager.registerCommand("redo", function(editor, selection) { - editor.redo(); +canon.addCommand({ + name: "redo", + exec: function(env, args, request) { env.editor.redo(); } }); -PluginManager.registerCommand("redo", function(editor, selection) { - editor.redo(); +canon.addCommand({ + name: "redo", + exec: function(env, args, request) { env.editor.redo(); } }); -PluginManager.registerCommand("overwrite", function(editor, selection) { - editor.toggleOverwrite(); +canon.addCommand({ + name: "overwrite", + exec: function(env, args, request) { env.editor.toggleOverwrite(); } }); -PluginManager.registerCommand("copylinesup", function(editor, selection) { - editor.copyLinesUp(); +canon.addCommand({ + name: "copylinesup", + exec: function(env, args, request) { env.editor.copyLinesUp(); } }); -PluginManager.registerCommand("movelinesup", function(editor, selection) { - editor.moveLinesUp(); +canon.addCommand({ + name: "movelinesup", + exec: function(env, args, request) { env.editor.moveLinesUp(); } }); -PluginManager.registerCommand("selecttostart", function(editor, selection) { - selection.selectFileStart(); +canon.addCommand({ + name: "selecttostart", + exec: function(env, args, request) { env.selection.selectFileStart(); } }); -PluginManager.registerCommand("gotostart", function(editor, selection) { - editor.navigateFileStart(); +canon.addCommand({ + name: "gotostart", + exec: function(env, args, request) { env.editor.navigateFileStart(); } }); -PluginManager.registerCommand("selectup", function(editor, selection) { - selection.selectUp(); +canon.addCommand({ + name: "selectup", + exec: function(env, args, request) { env.selection.selectUp(); } }); -PluginManager.registerCommand("golineup", function(editor, selection) { - editor.navigateUp(); +canon.addCommand({ + name: "golineup", + exec: function(env, args, request) { env.editor.navigateUp(); } }); -PluginManager.registerCommand("copylinesdown", function(editor, selection) { - editor.copyLinesDown(); +canon.addCommand({ + name: "copylinesdown", + exec: function(env, args, request) { env.editor.copyLinesDown(); } }); -PluginManager.registerCommand("movelinesdown", function(editor, selection) { - editor.moveLinesDown(); +canon.addCommand({ + name: "movelinesdown", + exec: function(env, args, request) { env.editor.moveLinesDown(); } }); -PluginManager.registerCommand("selecttoend", function(editor, selection) { - selection.selectFileEnd(); +canon.addCommand({ + name: "selecttoend", + exec: function(env, args, request) { env.selection.selectFileEnd(); } }); -PluginManager.registerCommand("gotoend", function(editor, selection) { - editor.navigateFileEnd(); +canon.addCommand({ + name: "gotoend", + exec: function(env, args, request) { env.editor.navigateFileEnd(); } }); -PluginManager.registerCommand("selectdown", function(editor, selection) { - selection.selectDown(); +canon.addCommand({ + name: "selectdown", + exec: function(env, args, request) { env.selection.selectDown(); } }); -PluginManager.registerCommand("godown", function(editor, selection) { - editor.navigateDown(); +canon.addCommand({ + name: "godown", + exec: function(env, args, request) { env.editor.navigateDown(); } }); -PluginManager.registerCommand("selectwordleft", function(editor, selection) { - selection.selectWordLeft(); +canon.addCommand({ + name: "selectwordleft", + exec: function(env, args, request) { env.selection.selectWordLeft(); } }); -PluginManager.registerCommand("gotowordleft", function(editor, selection) { - editor.navigateWordLeft(); +canon.addCommand({ + name: "gotowordleft", + exec: function(env, args, request) { env.editor.navigateWordLeft(); } }); -PluginManager.registerCommand("selecttolinestart", function(editor, selection) { - selection.selectLineStart(); +canon.addCommand({ + name: "selecttolinestart", + exec: function(env, args, request) { env.selection.selectLineStart(); } }); -PluginManager.registerCommand("gotolinestart", function(editor, selection) { - editor.navigateLineStart(); +canon.addCommand({ + name: "gotolinestart", + exec: function(env, args, request) { env.editor.navigateLineStart(); } }); -PluginManager.registerCommand("selectleft", function(editor, selection) { - selection.selectLeft(); +canon.addCommand({ + name: "selectleft", + exec: function(env, args, request) { env.selection.selectLeft(); } }); -PluginManager.registerCommand("gotoleft", function(editor, selection) { - editor.navigateLeft(); +canon.addCommand({ + name: "gotoleft", + exec: function(env, args, request) { env.editor.navigateLeft(); } }); -PluginManager.registerCommand("selectwordright", function(editor, selection) { - selection.selectWordRight(); +canon.addCommand({ + name: "selectwordright", + exec: function(env, args, request) { env.selection.selectWordRight(); } }); -PluginManager.registerCommand("gotowordright", function(editor, selection) { - editor.navigateWordRight(); +canon.addCommand({ + name: "gotowordright", + exec: function(env, args, request) { env.editor.navigateWordRight(); } }); -PluginManager.registerCommand("selecttolineend", function(editor, selection) { - selection.selectLineEnd(); +canon.addCommand({ + name: "selecttolineend", + exec: function(env, args, request) { env.selection.selectLineEnd(); } }); -PluginManager.registerCommand("gotolineend", function(editor, selection) { - editor.navigateLineEnd(); +canon.addCommand({ + name: "gotolineend", + exec: function(env, args, request) { env.editor.navigateLineEnd(); } }); -PluginManager.registerCommand("selectright", function(editor, selection) { - selection.selectRight(); +canon.addCommand({ + name: "selectright", + exec: function(env, args, request) { env.selection.selectRight(); } }); -PluginManager.registerCommand("gotoright", function(editor, selection) { - editor.navigateRight(); +canon.addCommand({ + name: "gotoright", + exec: function(env, args, request) { env.editor.navigateRight(); } }); -PluginManager.registerCommand("selectpagedown", function(editor, selection) { - editor.selectPageDown(); +canon.addCommand({ + name: "selectpagedown", + exec: function(env, args, request) { env.editor.selectPageDown(); } }); -PluginManager.registerCommand("pagedown", function(editor, selection) { - editor.scrollPageDown(); +canon.addCommand({ + name: "pagedown", + exec: function(env, args, request) { env.editor.scrollPageDown(); } }); -PluginManager.registerCommand("gotopagedown", function(editor, selection) { - editor.gotoPageDown(); +canon.addCommand({ + name: "gotopagedown", + exec: function(env, args, request) { env.editor.gotoPageDown(); } }); -PluginManager.registerCommand("selectpageup", function(editor, selection) { - editor.selectPageUp(); +canon.addCommand({ + name: "selectpageup", + exec: function(env, args, request) { env.editor.selectPageUp(); } }); -PluginManager.registerCommand("pageup", function(editor, selection) { - editor.scrollPageUp(); +canon.addCommand({ + name: "pageup", + exec: function(env, args, request) { env.editor.scrollPageUp(); } }); -PluginManager.registerCommand("gotopageup", function(editor, selection) { - editor.gotoPageUp(); +canon.addCommand({ + name: "gotopageup", + exec: function(env, args, request) { env.editor.gotoPageUp(); } }); -PluginManager.registerCommand("selectlinestart", function(editor, selection) { - selection.selectLineStart(); +canon.addCommand({ + name: "selectlinestart", + exec: function(env, args, request) { env.selection.selectLineStart(); } }); -PluginManager.registerCommand("gotolinestart", function(editor, selection) { - editor.navigateLineStart(); +canon.addCommand({ + name: "gotolinestart", + exec: function(env, args, request) { env.editor.navigateLineStart(); } }); -PluginManager.registerCommand("selectlineend", function(editor, selection) { - selection.selectLineEnd(); +canon.addCommand({ + name: "selectlineend", + exec: function(env, args, request) { env.selection.selectLineEnd(); } }); -PluginManager.registerCommand("gotolineend", function(editor, selection) { - editor.navigateLineEnd(); +canon.addCommand({ + name: "gotolineend", + exec: function(env, args, request) { env.editor.navigateLineEnd(); } }); -PluginManager.registerCommand("del", function(editor, selection) { - editor.removeRight(); +canon.addCommand({ + name: "del", + exec: function(env, args, request) { env.editor.removeRight(); } }); -PluginManager.registerCommand("backspace", function(editor, selection) { - editor.removeLeft(); +canon.addCommand({ + name: "backspace", + exec: function(env, args, request) { env.editor.removeLeft(); } }); -PluginManager.registerCommand("outdent", function(editor, selection) { - editor.blockOutdent(); +canon.addCommand({ + name: "outdent", + exec: function(env, args, request) { env.editor.blockOutdent(); } }); -PluginManager.registerCommand("indent", function(editor, selection) { - editor.indent(); +canon.addCommand({ + name: "indent", + exec: function(env, args, request) { env.editor.indent(); } }); -}); \ No newline at end of file +}); diff --git a/lib/ace/conf/keybindings/default_mac.js b/lib/ace/conf/keybindings/default_mac.js index d027d031..788ed577 100644 --- a/lib/ace/conf/keybindings/default_mac.js +++ b/lib/ace/conf/keybindings/default_mac.js @@ -37,7 +37,7 @@ define(function(require, exports, module) { -return { +exports.bindings = { "selectall": "Command-A", "removeline": "Command-D", "gotoline": "Command-L", diff --git a/lib/ace/conf/keybindings/default_win.js b/lib/ace/conf/keybindings/default_win.js index b752d0b1..3ae134b9 100644 --- a/lib/ace/conf/keybindings/default_win.js +++ b/lib/ace/conf/keybindings/default_win.js @@ -37,7 +37,7 @@ define(function(require, exports, module) { -return { +exports.bindings = { "selectall": "Ctrl-A", "removeline": "Ctrl-D", "gotoline": "Ctrl-L", diff --git a/lib/ace/document.js b/lib/ace/document.js index 9d250095..a705b682 100644 --- a/lib/ace/document.js +++ b/lib/ace/document.js @@ -37,17 +37,17 @@ define(function(require, exports, module) { -var oop = require("./lib/oop"); -var lang = require("./lib/lang"); -var MEventEmitter = require("./event_emitter"); -var Selection = require("./selection"); -var TextMode = require("./mode/text"); -var Range = require("./range"); +var oop = require("pilot/oop").oop; +var lang = require("pilot/lang").lang; +var EventEmitter = require("pilot/event_emitter").EventEmitter; +var Selection = require("ace/selection").Selection; +var TextMode = require("ace/mode/text").Mode; +var Range = require("ace/range").Range; var Document = function(text, mode) { this.modified = true; - this.lines = []; + this.lines = [""]; this.selection = new Selection(this); this.$breakpoints = []; @@ -66,7 +66,7 @@ var Document = function(text, mode) { (function() { - oop.implement(this, MEventEmitter); + oop.implement(this, EventEmitter); this.$undoManager = null; @@ -74,13 +74,13 @@ var Document = function(text, mode) { return text.split(/\r\n|\r|\n/); }; - this.setValue = function(text) { - var args = [0, this.lines.length]; - args.push.apply(args, this.$split(text)); - this.lines.splice.apply(this.lines, args); - this.modified = true; - this.fireChangeEvent(0); - }; + this.setValue = function(text) { + var args = [0, this.lines.length]; + args.push.apply(args, this.$split(text)); + this.lines.splice.apply(this.lines, args); + this.modified = true; + this.fireChangeEvent(0); + }; this.toString = function() { return this.lines.join(this.$getNewLineCharacter()); @@ -95,7 +95,7 @@ var Document = function(text, mode) { firstRow: firstRow, lastRow: lastRow }; - this.$dispatchEvent("change", { data: data}); + this._dispatchEvent("change", { data: data}); }; this.setUndoManager = function(undoManager) { @@ -154,7 +154,7 @@ var Document = function(text, mode) { this.modified = true; this.$tabSize = tabSize; - this.$dispatchEvent("changeTabSize"); + this._dispatchEvent("changeTabSize"); }; this.getTabSize = function() { @@ -170,22 +170,22 @@ var Document = function(text, mode) { for (var i=0; i= 0; --i) this.$tryReplace(ranges[i], replacement); if (ranges[0] !== null) @@ -1041,5 +1041,5 @@ var Editor =function(renderer, doc) { }).call(Editor.prototype); -return Editor; +exports.Editor = Editor; }); diff --git a/lib/ace/keybinding.js b/lib/ace/keybinding.js index 1adc4886..d9ecd4a1 100644 --- a/lib/ace/keybinding.js +++ b/lib/ace/keybinding.js @@ -37,12 +37,12 @@ define(function(require, exports, module) { -var core = require("./lib/core"); -var event = require("./lib/event"); -var default_mac = require("./conf/keybindings/default_mac"); -var default_win = require("./conf/keybindings/default_win"); -var PluginManager = require("./plugin_manager"); -require("./commands/default_commands"); +var core = require("pilot/core").core; +var event = require("pilot/event").event; +var default_mac = require("ace/conf/keybindings/default_mac").bindings; +var default_win = require("ace/conf/keybindings/default_win").bindings; +var canon = require("pilot/canon"); +require("ace/commands/default_commands"); var KeyBinding = function(element, editor, config) { this.setConfig(config); @@ -55,10 +55,9 @@ var KeyBinding = function(element, editor, config) { var commandName = (_self.config.reverse[hashId] || {})[(key || String.fromCharCode(e.keyCode)).toLowerCase()]; - var command = PluginManager.commands[commandName]; - if (command) { - command(editor, editor.getSelection()); + var success = canon.exec(commandName, {editor: editor}); + if (success) { return event.stopEvent(e); } }); @@ -149,5 +148,5 @@ var KeyBinding = function(element, editor, config) { }).call(KeyBinding.prototype); -return KeyBinding; +exports.KeyBinding = KeyBinding; }); diff --git a/lib/ace/layer/cursor.js b/lib/ace/layer/cursor.js index f1f99916..57ffc7f7 100644 --- a/lib/ace/layer/cursor.js +++ b/lib/ace/layer/cursor.js @@ -37,7 +37,7 @@ define(function(require, exports, module) { -var dom = require("../lib/dom"); +var dom = require("pilot/dom").dom; var Cursor = function(parentEl) { this.element = document.createElement("div"); @@ -120,7 +120,7 @@ var Cursor = function(parentEl) { this.update = function(config) { if (!this.position) return; - + this.config = config; var cursorLeft = Math.round(this.position.column * config.characterWidth); @@ -145,5 +145,6 @@ var Cursor = function(parentEl) { }).call(Cursor.prototype); -return Cursor; +exports.Cursor = Cursor; + }); diff --git a/lib/ace/layer/gutter.js b/lib/ace/layer/gutter.js index 87db1632..4202772f 100644 --- a/lib/ace/layer/gutter.js +++ b/lib/ace/layer/gutter.js @@ -81,5 +81,6 @@ var Gutter = function(parentEl) { }).call(Gutter.prototype); -return Gutter; +exports.Gutter = Gutter; + }); diff --git a/lib/ace/layer/marker.js b/lib/ace/layer/marker.js index 0c304915..06422bd5 100644 --- a/lib/ace/layer/marker.js +++ b/lib/ace/layer/marker.js @@ -37,7 +37,7 @@ define(function(require, exports, module) { -var Range = require("../range"); +var Range = require("ace/range").Range; var Marker = function(parentEl) { this.element = document.createElement("div"); @@ -181,5 +181,6 @@ var Marker = function(parentEl) { }).call(Marker.prototype); -return Marker; +exports.Marker = Marker; + }); diff --git a/lib/ace/layer/text.js b/lib/ace/layer/text.js index 08f3670a..9ba67f43 100644 --- a/lib/ace/layer/text.js +++ b/lib/ace/layer/text.js @@ -37,9 +37,9 @@ define(function(require, exports, module) { -var oop = require("../lib/oop"); -var dom = require("../lib/dom"); -var MEventEmitter = require("../event_emitter"); +var oop = require("pilot/oop").oop; +var dom = require("pilot/dom").dom; +var EventEmitter = require("pilot/event_emitter").EventEmitter; var Text = function(parentEl) { this.element = document.createElement("div"); @@ -52,7 +52,7 @@ var Text = function(parentEl) { (function() { - oop.implement(this, MEventEmitter); + oop.implement(this, EventEmitter); this.EOF_CHAR = "¶"; this.EOL_CHAR = "¬"; @@ -77,7 +77,7 @@ var Text = function(parentEl) { var size = self.$measureSizes(); if (self.$characterSize.width !== size.width || self.$characterSize.height !== size.height) { self.$characterSize = size; - self.$dispatchEvent("changeCharaterSize", {data: size}); + self._dispatchEvent("changeCharaterSize", {data: size}); } }, 500); }; @@ -155,7 +155,7 @@ var Text = function(parentEl) { this.tokenizer.getTokens(first, last, function(tokens) { for ( var i = first; i <= last; i++) { var lineElement = lineElements[i - layerConfig.firstRow]; - if (!lineElement) + if (!lineElement) continue; var html = []; @@ -299,5 +299,6 @@ var Text = function(parentEl) { }).call(Text.prototype); -return Text; +exports.Text = Text; + }); diff --git a/lib/ace/mode/css.js b/lib/ace/mode/css.js index 91819a91..7f69fdf1 100644 --- a/lib/ace/mode/css.js +++ b/lib/ace/mode/css.js @@ -37,17 +37,17 @@ define(function(require, exports, module) { -var oop = require("../lib/oop"); -var TextMode = require("./text"); -var Tokenizer = require("../tokenizer"); -var CssHighlightRules = require("./css_highlight_rules"); -var MatchingBraceOutdent = require("./matching_brace_outdent"); +var oop = require("pilot/oop").oop; +var TextMode = require("ace/mode/text").Mode; +var Tokenizer = require("ace/tokenizer").Tokenizer; +var CssHighlightRules = require("ace/mode/css_highlight_rules").CssHighlightRules; +var MatchingBraceOutdent = require("ace/mode/matching_brace_outdent").MatchingBraceOutdent; -var Css = function() { +var Mode = function() { this.$tokenizer = new Tokenizer(new CssHighlightRules().getRules()); this.$outdent = new MatchingBraceOutdent(); }; -oop.inherits(Css, TextMode); +oop.inherits(Mode, TextMode); (function() { @@ -76,7 +76,8 @@ oop.inherits(Css, TextMode); return this.$outdent.autoOutdent(doc, row); }; -}).call(Css.prototype); +}).call(Mode.prototype); -return Css; -}); \ No newline at end of file +exports.Mode = Mode; + +}); diff --git a/lib/ace/mode/css_highlight_rules.js b/lib/ace/mode/css_highlight_rules.js index 938b9bca..a4445f41 100644 --- a/lib/ace/mode/css_highlight_rules.js +++ b/lib/ace/mode/css_highlight_rules.js @@ -37,9 +37,9 @@ define(function(require, exports, module) { -var oop = require("../lib/oop"); -var lang = require("../lib/lang"); -var TextHighlightRules = require("./text_highlight_rules"); +var oop = require("pilot/oop").oop; +var lang = require("pilot/lang").lang; +var TextHighlightRules = require("ace/mode/text_highlight_rules").TextHighlightRules; var CssHighlightRules = function() { @@ -229,5 +229,6 @@ var CssHighlightRules = function() { oop.inherits(CssHighlightRules, TextHighlightRules); -return CssHighlightRules; +exports.CssHighlightRules = CssHighlightRules; + }); diff --git a/lib/ace/mode/doc_comment_highlight_rules.js b/lib/ace/mode/doc_comment_highlight_rules.js index 5db3a5d1..48812aed 100644 --- a/lib/ace/mode/doc_comment_highlight_rules.js +++ b/lib/ace/mode/doc_comment_highlight_rules.js @@ -37,8 +37,8 @@ define(function(require, exports, module) { -var oop = require("../lib/oop"); -var TextHighlightRules = require("./text_highlight_rules"); +var oop = require("pilot/oop").oop; +var TextHighlightRules = require("ace/mode/text_highlight_rules").TextHighlightRules; var DocCommentHighlightRules = function() { @@ -77,5 +77,6 @@ oop.inherits(DocCommentHighlightRules, TextHighlightRules); }).call(DocCommentHighlightRules.prototype); -return DocCommentHighlightRules; -}); \ No newline at end of file +exports.DocCommentHighlightRules = DocCommentHighlightRules; + +}); diff --git a/lib/ace/mode/html.js b/lib/ace/mode/html.js index 8694b00a..25746d8e 100644 --- a/lib/ace/mode/html.js +++ b/lib/ace/mode/html.js @@ -37,20 +37,20 @@ define(function(require, exports, module) { -var oop = require("../lib/oop"); -var TextMode = require("./text"); -var JavaScriptMode = require("./javascript"); -var CssMode = require("./css"); -var Tokenizer = require("../tokenizer"); -var HtmlHighlightRules = require("./html_highlight_rules"); +var oop = require("pilot/oop").oop; +var TextMode = require("ace/mode/text").Mode; +var JavaScriptMode = require("ace/mode/javascript").Mode; +var CssMode = require("ace/mode/css").Mode; +var Tokenizer = require("ace/tokenizer").Tokenizer; +var HtmlHighlightRules = require("ace/mode/html_highlight_rules").HtmlHighlightRules; -var Html = function() { +var Mode = function() { this.$tokenizer = new Tokenizer(new HtmlHighlightRules().getRules()); this.$js = new JavaScriptMode(); this.$css = new CssMode(); }; -oop.inherits(Html, TextMode); +oop.inherits(Mode, TextMode); (function() { @@ -95,7 +95,7 @@ oop.inherits(Html, TextMode); return defaultHandler ? defaultHandler() : undefined; }; -}).call(Html.prototype); +}).call(Mode.prototype); -return Html; +exports.Mode = Mode; }); diff --git a/lib/ace/mode/html_highlight_rules.js b/lib/ace/mode/html_highlight_rules.js index c914b112..be441552 100644 --- a/lib/ace/mode/html_highlight_rules.js +++ b/lib/ace/mode/html_highlight_rules.js @@ -37,10 +37,10 @@ define(function(require, exports, module) { -var oop = require("../lib/oop"); -var CssHighlightRules = require("./css_highlight_rules"); -var JavaScriptHighlightRules = require("./javascript_highlight_rules"); -var TextHighlightRules = require("./text_highlight_rules"); +var oop = require("pilot/oop").oop; +var CssHighlightRules = require("ace/mode/css_highlight_rules").CssHighlightRules; +var JavaScriptHighlightRules = require("ace/mode/javascript_highlight_rules").JavaScriptHighlightRules; +var TextHighlightRules = require("ace/mode/text_highlight_rules").TextHighlightRules; var HtmlHighlightRules = function() { @@ -178,5 +178,5 @@ var HtmlHighlightRules = function() { oop.inherits(HtmlHighlightRules, TextHighlightRules); -return HtmlHighlightRules; +exports.HtmlHighlightRules = HtmlHighlightRules; }); diff --git a/lib/ace/mode/javascript.js b/lib/ace/mode/javascript.js index 5479e704..66d6c317 100644 --- a/lib/ace/mode/javascript.js +++ b/lib/ace/mode/javascript.js @@ -37,18 +37,18 @@ define(function(require, exports, module) { -var oop = require("../lib/oop"); -var TextMode = require("./text"); -var Tokenizer = require("../tokenizer"); -var JavaScriptHighlightRules = require("./javascript_highlight_rules"); -var MatchingBraceOutdent = require("./matching_brace_outdent"); -var Range = require("../range"); +var oop = require("pilot/oop").oop; +var TextMode = require("ace/mode/text").Mode; +var Tokenizer = require("ace/tokenizer").Tokenizer; +var JavaScriptHighlightRules = require("ace/mode/javascript_highlight_rules").JavaScriptHighlightRules; +var MatchingBraceOutdent = require("ace/mode/matching_brace_outdent").MatchingBraceOutdent; +var Range = require("ace/range").Range; -var JavaScript = function() { +var Mode = function() { this.$tokenizer = new Tokenizer(new JavaScriptHighlightRules().getRules()); this.$outdent = new MatchingBraceOutdent(); }; -oop.inherits(JavaScript, TextMode); +oop.inherits(Mode, TextMode); (function() { @@ -107,12 +107,7 @@ oop.inherits(JavaScript, TextMode); indent += " "; } indent += "* "; - }{ - if (match[1]) { - indent += " "; - } - indent += "* "; - } + } } return indent; @@ -126,7 +121,7 @@ oop.inherits(JavaScript, TextMode); return this.$outdent.autoOutdent(doc, row); }; -}).call(JavaScript.prototype); +}).call(Mode.prototype); -return JavaScript; +exports.Mode = Mode; }); diff --git a/lib/ace/mode/javascript_highlight_rules.js b/lib/ace/mode/javascript_highlight_rules.js index 039422c4..0cbad802 100644 --- a/lib/ace/mode/javascript_highlight_rules.js +++ b/lib/ace/mode/javascript_highlight_rules.js @@ -37,10 +37,10 @@ define(function(require, exports, module) { -var oop = require("../lib/oop"); -var lang = require("../lib/lang"); -var DocCommentHighlightRules = require("./doc_comment_highlight_rules"); -var TextHighlightRules = require("./text_highlight_rules"); +var oop = require("pilot/oop").oop; +var lang = require("pilot/lang").lang; +var DocCommentHighlightRules = require("ace/mode/doc_comment_highlight_rules").DocCommentHighlightRules; +var TextHighlightRules = require("ace/mode/text_highlight_rules").TextHighlightRules; JavaScriptHighlightRules = function() { @@ -159,5 +159,5 @@ JavaScriptHighlightRules = function() { oop.inherits(JavaScriptHighlightRules, TextHighlightRules); -return JavaScriptHighlightRules; -}); \ No newline at end of file +exports.JavaScriptHighlightRules = JavaScriptHighlightRules; +}); diff --git a/lib/ace/mode/matching_brace_outdent.js b/lib/ace/mode/matching_brace_outdent.js index 82777425..6f4896aa 100644 --- a/lib/ace/mode/matching_brace_outdent.js +++ b/lib/ace/mode/matching_brace_outdent.js @@ -37,7 +37,7 @@ define(function(require, exports, module) { -var Range = require("../range"); +var Range = require("ace/range").Range; var MatchingBraceOutdent = function() {}; @@ -78,5 +78,5 @@ var MatchingBraceOutdent = function() {}; }).call(MatchingBraceOutdent.prototype); -return MatchingBraceOutdent; +exports.MatchingBraceOutdent = MatchingBraceOutdent; }); diff --git a/lib/ace/mode/python.js b/lib/ace/mode/python.js new file mode 100644 index 00000000..4111b877 --- /dev/null +++ b/lib/ace/mode/python.js @@ -0,0 +1,116 @@ +/* ***** BEGIN LICENSE BLOCK ***** +* Version: MPL 1.1/GPL 2.0/LGPL 2.1 +* +* The contents of this file are subject to the Mozilla Public License Version +* 1.1 (the "License"); you may not use this file except in compliance with +* the License. You may obtain a copy of the License at +* http://www.mozilla.org/MPL/ +* +* Software distributed under the License is distributed on an "AS IS" basis, +* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +* for the specific language governing rights and limitations under the +* License. +* +* The Original Code is Ajax.org Code Editor (ACE). +* +* The Initial Developer of the Original Code is +* Ajax.org Services B.V. +* Portions created by the Initial Developer are Copyright (C) 2010 +* the Initial Developer. All Rights Reserved. +* +* Contributor(s): +* Fabian Jakobs +* +* Alternatively, the contents of this file may be used under the terms of +* either the GNU General Public License Version 2 or later (the "GPL"), or +* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), +* in which case the provisions of the GPL or the LGPL are applicable instead +* of those above. If you wish to allow use of your version of this file only +* under the terms of either the GPL or the LGPL, and not to allow others to +* use your version of this file under the terms of the MPL, indicate your +* decision by deleting the provisions above and replace them with the notice +* and other provisions required by the GPL or the LGPL. If you do not delete +* the provisions above, a recipient may use your version of this file under +* the terms of any one of the MPL, the GPL or the LGPL. +* +* ***** END LICENSE BLOCK ***** */ + +define(function(require, exports, module) { + +var oop = require("pilot/oop").oop; +var TextMode = require("./text").Mode; +var Tokenizer = require("../tokenizer").Tokenizer; +var PythonHighlightRules = require("./python_highlight_rules").PythonHighlightRules; +var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; +var Range = require("../range").Range; + +var Mode = function() { + this.$tokenizer = new Tokenizer(new PythonHighlightRules().getRules()); + this.$outdent = new MatchingBraceOutdent(); +}; +oop.inherits(Mode, TextMode); + +(function() { + + this.toggleCommentLines = function(state, doc, range) { + var outdent = true; + var outentedRows = []; + var re = /^(\s*)#/; + + for (var i=range.start.row; i<= range.end.row; i++) { + if (!re.test(doc.getLine(i))) { + outdent = false; + break; + } + } + + if (outdent) { + var deleteRange = new Range(0, 0, 0, 0); + for (var i=range.start.row; i<= range.end.row; i++) + { + var line = doc.getLine(i).replace(re, "$1"); + deleteRange.start.row = i; + deleteRange.end.row = i; + deleteRange.end.column = line.length + 2; + doc.replace(deleteRange, line); + } + return -2; + } + else { + return doc.indentRows(range, "#"); + } + }; + + this.getNextLineIndent = function(state, line, tab) { + var indent = this.$getIndent(line); + + var tokenizedLine = this.$tokenizer.getLineTokens(line, state); + var tokens = tokenizedLine.tokens; + var endState = tokenizedLine.state; + + if (tokens.length && tokens[tokens.length-1].type == "comment") { + return indent; + } + + if (state == "start") { + var match = line.match(/^.*[\{\(\[\:]\s*$/); + if (match) { + indent += tab; + } + } + + return indent; + }; + + this.checkOutdent = function(state, line, input) { + return this.$outdent.checkOutdent(line, input); + }; + + this.autoOutdent = function(state, doc, row) { + return this.$outdent.autoOutdent(doc, row); + }; + +}).call(Mode.prototype); + +exports.Mode = Mode; +}); diff --git a/lib/ace/mode/python_highlight_rules.js b/lib/ace/mode/python_highlight_rules.js new file mode 100644 index 00000000..0a48fcd3 --- /dev/null +++ b/lib/ace/mode/python_highlight_rules.js @@ -0,0 +1,176 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Ajax.org Code Editor (ACE). + * + * The Initial Developer of the Original Code is + * Ajax.org Services B.V. + * Portions created by the Initial Developer are Copyright (C) 2010 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Fabian Jakobs + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** + * + * TODO: python delimiters + */ + +define(function(require, exports, module) { + +var oop = require("pilot/oop").oop; +var lang = require("pilot/lang").lang; +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +PythonHighlightRules = function() { + + var keywords = lang.arrayToMap( + ("and|as|assert|break|class|continue|def|del|elif|else|except|exec|" + + "finally|for|from|global|if|import|in|is|lambda|not|or|pass|print|" + + "raise|return|try|while|with|yield").split("|") + ); + + var builtinConstants = lang.arrayToMap( + ("True|False|None|NotImplemented|Ellipsis|__debug__").split("|") + ); + + var builtinFunctions = lang.arrayToMap( + ("abs|divmod|input|open|staticmethod|all|enumerate|int|ord|str|any|" + + "eval|isinstance|pow|sum|basestring|execfile|issubclass|print|super|" + + "binfile|iter|property|tuple|bool|filter|len|range|type|bytearray|" + + "float|list|raw_input|unichr|callable|format|locals|reduce|unicode|" + + "chr|frozenset|long|reload|vars|classmethod|getattr|map|repr|xrange|" + + "cmp|globals|max|reversed|zip|compile|hasattr|memoryview|round|" + + "__import__|complex|hash|min|set|apply|delattr|help|next|setattr|" + + "buffer|dict|hex|object|slice|coerce|dir|id|oct|sorted|intern").split("|") + ); + + var futureReserved = lang.arrayToMap( + ("").split("|") + ); + + var strPre = "(?:(?:[rubRUB])|(?:[ubUB][rR]))?"; + + var decimalInteger = "(?:(?:[1-9]\\d*)|(?:0))"; + var octInteger = "(?:0[oO]?[0-7]+)"; + var hexInteger = "(?:0[xX][\\dA-Fa-f]+)"; + var binInteger = "(?:0[bB][01]+)"; + var integer = "(?:" + decimalInteger + "|" + octInteger + "|" + hexInteger + "|" + binInteger + ")"; + + var exponent = "(?:[eE][+-]?\\d+)"; + var fraction = "(?:\\.\\d+)"; + var intPart = "(?:\\d+)"; + var pointFloat = "(?:(?:" + intPart + "?" + fraction + ")|(?:" + intPart + "\\.))"; + var exponentFloat = "(?:(?:" + pointFloat + "|" + intPart + ")" + exponent + ")"; + var floatNumber = "(?:" + exponentFloat + "|" + pointFloat + ")"; + + this.$rules = { + "start" : [ { + token : "comment", + regex : "#.*$" + }, { + token : "string", // """ string + regex : strPre + '"{3}(?:(?:.)|(?:^"{3}))*?"{3}' + }, { + token : "string", // multi line """ string start + regex : strPre + '"{3}.*$', + next : "qqstring" + }, { + token : "string", // " string + regex : strPre + '"(?:(?:\\\\.)|(?:[^"\\\\]))*?"' + }, { + token : "string", // ''' string + regex : strPre + "'{3}(?:(?:.)|(?:^'{3}))*?'{3}" + }, { + token : "string", // multi line ''' string start + regex : strPre + "'{3}.*$", + next : "qstring" + }, { + token : "string", // ' string + regex : strPre + "'(?:(?:\\\\.)|(?:[^'\\\\]))*?'" + }, { + token : "constant.numeric", // imaginary + regex : "(?:" + floatNumber + "|\\d+)[jJ]\\b" + }, { + token : "constant.numeric", // float + regex : floatNumber + }, { + token : "constant.numeric", // long integer + regex : integer + "[lL]\\b" + }, { + token : "constant.numeric", // integer + regex : integer + "\\b" + }, { + token : function(value) { + if (keywords[value]) + return "keyword"; + else if (builtinConstants[value]) + return "constant.language"; + else if (futureReserved[value]) + return "invalid.illegal"; + else if (builtinFunctions[value]) + return "support.function"; + else if (value == "debugger") + return "invalid.deprecated"; + else + return "identifier"; + }, + regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b" + }, { + token : "keyword.operator", + regex : "\\+|\\-|\\*|\\*\\*|\\/|\\/\\/|%|<<|>>|&|\\||\\^|~|<|>|<=|=>|==|!=|<>|=" + }, { + token : "lparen", + regex : "[\\[\\(\\{]" + }, { + token : "rparen", + regex : "[\\]\\)\\}]" + }, { + token : "text", + regex : "\\s+" + } ], + "qqstring" : [ { + token : "string", // multi line """ string end + regex : '(?:^"{3})*?"{3}', + next : "start" + }, { + token : "string", + regex : '.+' + } ], + "qstring" : [ { + token : "string", // multi line ''' string end + regex : "(?:^'{3})*?'{3}", + next : "start" + }, { + token : "string", + regex : '.+' + } ] + }; +}; + +oop.inherits(PythonHighlightRules, TextHighlightRules); + +exports.PythonHighlightRules = PythonHighlightRules; +}); \ No newline at end of file diff --git a/lib/ace/mode/text.js b/lib/ace/mode/text.js index 7cf04cb8..0e18d038 100644 --- a/lib/ace/mode/text.js +++ b/lib/ace/mode/text.js @@ -37,10 +37,10 @@ define(function(require, exports, module) { -var Tokenizer = require("../tokenizer"); -var TextHighlightRules = require("./text_highlight_rules"); +var Tokenizer = require("ace/tokenizer").Tokenizer; +var TextHighlightRules = require("ace/mode/text_highlight_rules").TextHighlightRules; -var Text = function() { +var Mode = function() { this.$tokenizer = new Tokenizer(new TextHighlightRules().getRules()); }; @@ -74,7 +74,7 @@ var Text = function() { return ""; }; -}).call(Text.prototype); +}).call(Mode.prototype); -return Text; -}); \ No newline at end of file +exports.Mode = Mode; +}); diff --git a/lib/ace/mode/text_highlight_rules.js b/lib/ace/mode/text_highlight_rules.js index c5331061..3f5351ce 100644 --- a/lib/ace/mode/text_highlight_rules.js +++ b/lib/ace/mode/text_highlight_rules.js @@ -73,5 +73,5 @@ var TextHighlightRules = function() { }).call(TextHighlightRules.prototype); -return TextHighlightRules; -}); \ No newline at end of file +exports.TextHighlightRules = TextHighlightRules; +}); diff --git a/lib/ace/mode/xml.js b/lib/ace/mode/xml.js index a64eeac7..e51bd7f8 100644 --- a/lib/ace/mode/xml.js +++ b/lib/ace/mode/xml.js @@ -37,16 +37,16 @@ define(function(require, exports, module) { -var oop = require("../lib/oop"); -var TextMode = require("./text"); -var Tokenizer = require("../tokenizer"); -var XmlHighlightRules = require("./xml_highlight_rules"); +var oop = require("pilot/oop").oop; +var TextMode = require("ace/mode/text").Mode; +var Tokenizer = require("ace/tokenizer").Tokenizer; +var XmlHighlightRules = require("ace/mode/xml_highlight_rules").XmlHighlightRules; -var Xml = function() { +var Mode = function() { this.$tokenizer = new Tokenizer(new XmlHighlightRules().getRules()); }; -oop.inherits(Xml, TextMode); +oop.inherits(Mode, TextMode); (function() { @@ -54,7 +54,7 @@ oop.inherits(Xml, TextMode); return this.$getIndent(line); }; -}).call(Xml.prototype); +}).call(Mode.prototype); -return Xml; -}); \ No newline at end of file +exports.Mode = Mode; +}); diff --git a/lib/ace/mode/xml_highlight_rules.js b/lib/ace/mode/xml_highlight_rules.js index 69e7b691..b1c6e874 100644 --- a/lib/ace/mode/xml_highlight_rules.js +++ b/lib/ace/mode/xml_highlight_rules.js @@ -37,8 +37,8 @@ define(function(require, exports, module) { -var oop = require("../lib/oop"); -var TextHighlightRules = require("./text_highlight_rules"); +var oop = require("pilot/oop").oop; +var TextHighlightRules = require("ace/mode/text_highlight_rules").TextHighlightRules; var XmlHighlightRules = function() { @@ -114,5 +114,5 @@ var XmlHighlightRules = function() { oop.inherits(XmlHighlightRules, TextHighlightRules); -return XmlHighlightRules; -}); \ No newline at end of file +exports.XmlHighlightRules = XmlHighlightRules; +}); diff --git a/lib/ace/range.js b/lib/ace/range.js index 31e4ecae..a818617a 100644 --- a/lib/ace/range.js +++ b/lib/ace/range.js @@ -152,5 +152,5 @@ Range.fromPoints = function(start, end) { return new Range(start.row, start.column, end.row, end.column); }; -return Range; -}) +exports.Range = Range; +}); diff --git a/lib/ace/renderloop.js b/lib/ace/renderloop.js index 9a8ea34f..20fa21fb 100644 --- a/lib/ace/renderloop.js +++ b/lib/ace/renderloop.js @@ -37,7 +37,7 @@ define(function(require, exports, module) { -var event = require("./lib/event") +var event = require("pilot/event").event; var RenderLoop = function(onRender) { this.onRender = onRender; @@ -62,11 +62,11 @@ var RenderLoop = function(onRender) { }) } }; - + if (window.postMessage) { - + this.messageName = "zero-timeout-message"; - + this.setTimeoutZero = function(callback) { if (!this.attached) { var _self = this; @@ -81,15 +81,15 @@ var RenderLoop = function(onRender) { this.callback = callback; window.postMessage(this.messageName, "*"); } - + } else { - + this.setTimeoutZero = function(callback) { setTimeout(callback, 0); } } - + }).call(RenderLoop.prototype); -return RenderLoop; -}); \ No newline at end of file +exports.RenderLoop = RenderLoop; +}); diff --git a/lib/ace/scrollbar.js b/lib/ace/scrollbar.js index 576b5ab4..67411c15 100644 --- a/lib/ace/scrollbar.js +++ b/lib/ace/scrollbar.js @@ -37,11 +37,11 @@ define(function(require, exports, module) { -var oop = require("./lib/oop"); -var lang = require("./lib/lang"); -var dom = require("./lib/dom"); -var event = require("./lib/event"); -var MEventEmitter = require("./event_emitter"); +var oop = require("pilot/oop").oop; +var lang = require("pilot/lang").lang; +var dom = require("pilot/dom").dom; +var event = require("pilot/event").event; +var EventEmitter = require("pilot/event_emitter").EventEmitter; var ScrollBar = function(parent) { this.element = document.createElement("div"); @@ -59,10 +59,10 @@ var ScrollBar = function(parent) { }; (function() { - oop.implement(this, MEventEmitter); + oop.implement(this, EventEmitter); this.onScroll = function() { - this.$dispatchEvent("scroll", {data: this.element.scrollTop}); + this._dispatchEvent("scroll", {data: this.element.scrollTop}); }; this.getWidth = function() { @@ -83,5 +83,5 @@ var ScrollBar = function(parent) { }).call(ScrollBar.prototype); -return ScrollBar; +exports.ScrollBar = ScrollBar; }); diff --git a/lib/ace/search.js b/lib/ace/search.js index e3f040c4..3ea5eba0 100644 --- a/lib/ace/search.js +++ b/lib/ace/search.js @@ -37,9 +37,9 @@ define(function(require, exports, module) { -var lang = require("./lib/lang"); -var oop = require("./lib/oop"); -var Range = require("./range"); +var lang = require("pilot/lang").lang; +var oop = require("pilot/oop").oop; +var Range = require("ace/range").Range; var Search = function() { this.$options = { @@ -317,5 +317,5 @@ Search.SELECTION = 2; }).call(Search.prototype); -return Search; +exports.Search = Search; }); diff --git a/lib/ace/selection.js b/lib/ace/selection.js index 7af93630..3b551667 100644 --- a/lib/ace/selection.js +++ b/lib/ace/selection.js @@ -37,10 +37,10 @@ define(function(require, exports, module) { -var oop = require("./lib/oop"); -var lang = require("./lib/lang"); -var MEventEmitter = require("./event_emitter"); -var Range = require("./range"); +var oop = require("pilot/oop").oop; +var lang = require("pilot/lang").lang; +var EventEmitter = require("pilot/event_emitter").EventEmitter; +var Range = require("ace/range").Range; var Selection = function(doc) { this.doc = doc; @@ -54,7 +54,7 @@ var Selection = function(doc) { (function() { - oop.implement(this, MEventEmitter); + oop.implement(this, EventEmitter); this.isEmpty = function() { return (!this.selectionAnchor || @@ -79,11 +79,11 @@ var Selection = function(doc) { if (!this.selectionAnchor) { this.selectionAnchor = anchor; - this.$dispatchEvent("changeSelection", {}); + this._dispatchEvent("changeSelection", {}); } else if (this.selectionAnchor.row !== anchor.row || this.selectionAnchor.column !== anchor.column) { this.selectionAnchor = anchor; - this.$dispatchEvent("changeSelection", {}); + this._dispatchEvent("changeSelection", {}); } }; @@ -142,7 +142,7 @@ var Selection = function(doc) { this.clearSelection = function() { if (this.selectionAnchor) { this.selectionAnchor = null; - this.$dispatchEvent("changeSelection", {}); + this._dispatchEvent("changeSelection", {}); } }; @@ -181,7 +181,7 @@ var Selection = function(doc) { } if (changed) - this.$dispatchEvent("changeSelection", {}); + this._dispatchEvent("changeSelection", {}); }; this.selectTo = function(row, column) { @@ -381,7 +381,7 @@ var Selection = function(doc) { // only dispatch change if the cursor actually changed if (cursor.row !== this.selectionLead.row || cursor.column !== this.selectionLead.column) { this.selectionLead = cursor; - this.$dispatchEvent("changeCursor", { data: this.getCursor() }); + this._dispatchEvent("changeCursor", { data: this.getCursor() }); } }; @@ -417,5 +417,5 @@ var Selection = function(doc) { }).call(Selection.prototype); -return Selection; +exports.Selection = Selection; }); diff --git a/lib/ace/test/all.js b/lib/ace/test/all.js index be6a4ffa..297c69a4 100644 --- a/lib/ace/test/all.js +++ b/lib/ace/test/all.js @@ -1,3 +1,40 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Ajax.org Code Editor (ACE). + * + * The Initial Developer of the Original Code is + * Ajax.org Services B.V. + * Portions created by the Initial Developer are Copyright (C) 2010 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Fabian Jakobs + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + require({ paths: { "ace": "../src/ace" diff --git a/lib/ace/test/assertions.js b/lib/ace/test/assertions.js index 9075823b..1bccf3da 100644 --- a/lib/ace/test/assertions.js +++ b/lib/ace/test/assertions.js @@ -1,10 +1,39 @@ -/** - * Ajax.org Code Editor (ACE) +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * - * @copyright 2010, Ajax.org Services B.V. - * @license LGPLv3 - * @author Fabian Jakobs - */ + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Ajax.org Code Editor (ACE). + * + * The Initial Developer of the Original Code is + * Ajax.org Services B.V. + * Portions created by the Initial Developer are Copyright (C) 2010 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Fabian Jakobs + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ define(function(require, exports, module) { diff --git a/lib/ace/test/change_document_test.js b/lib/ace/test/change_document_test.js index a78fe5ee..90ca741f 100644 --- a/lib/ace/test/change_document_test.js +++ b/lib/ace/test/change_document_test.js @@ -1,10 +1,39 @@ -/** - * Ajax.org Code Editor (ACE) +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * - * @copyright 2010, Ajax.org Services B.V. - * @license LGPLv3 - * @author Fabian Jakobs - */ + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Ajax.org Code Editor (ACE). + * + * The Initial Developer of the Original Code is + * Ajax.org Services B.V. + * Portions created by the Initial Developer are Copyright (C) 2010 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Fabian Jakobs + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ require("../../../support/paths"); @@ -30,11 +59,11 @@ var Test = { this.doc2 = new Document(["ghi", "jkl"].join("\n")); this.editor = new Editor(new MockRenderer()); }, - + "test: change document" : function() { this.editor.setDocument(this.doc1); assert.equal(this.editor.getDocument(), this.doc1); - + this.editor.setDocument(this.doc2); assert.equal(this.editor.getDocument(), this.doc2); }, @@ -134,4 +163,4 @@ var Test = { module.exports = require("async/test").testcase(Test); if (module === require.main) - module.exports.exec() \ No newline at end of file + module.exports.exec() diff --git a/lib/ace/test/document_test.js b/lib/ace/test/document_test.js index 4575b6e9..6ae725da 100644 --- a/lib/ace/test/document_test.js +++ b/lib/ace/test/document_test.js @@ -1,10 +1,39 @@ -/** - * Ajax.org Code Editor (ACE) +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * - * @copyright 2010, Ajax.org Services B.V. - * @license LGPLv3 - * @author Fabian Jakobs - */ + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Ajax.org Code Editor (ACE). + * + * The Initial Developer of the Original Code is + * Ajax.org Services B.V. + * Portions created by the Initial Developer are Copyright (C) 2010 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Fabian Jakobs + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ require("../../../support/paths"); diff --git a/lib/ace/test/event_emitter_test.js b/lib/ace/test/event_emitter_test.js index b8f96f1e..8b6b6a26 100644 --- a/lib/ace/test/event_emitter_test.js +++ b/lib/ace/test/event_emitter_test.js @@ -1,21 +1,49 @@ -/** - * Ajax.org Code Editor (ACE) +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * - * @copyright 2010, Ajax.org Services B.V. - * @license LGPLv3 - * @author Fabian Jakobs - */ + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Ajax.org Code Editor (ACE). + * + * The Initial Developer of the Original Code is + * Ajax.org Services B.V. + * Portions created by the Initial Developer are Copyright (C) 2010 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Fabian Jakobs + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ require("../../../support/paths"); var oop = require("../lib/oop"); MEventEmitter = require("../event_emitter"), assert = require("./assertions"); - - + var EventEmitter = function() {}; -oop.implement(EventEmitter.prototype, MEventEmitter); +oop.implement(EventEmitter.prototype, EventEmitter); var Test = { "test: dispatch event with no data" : function() { @@ -35,4 +63,4 @@ var Test = { module.exports = require("async/test").testcase(Test) if (module === require.main) - module.exports.exec() \ No newline at end of file + module.exports.exec() diff --git a/lib/ace/test/mockrenderer.js b/lib/ace/test/mockrenderer.js index 40367ee1..6a3f51a1 100644 --- a/lib/ace/test/mockrenderer.js +++ b/lib/ace/test/mockrenderer.js @@ -1,10 +1,39 @@ -/** - * Ajax.org Code Editor (ACE) +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * - * @copyright 2010, Ajax.org Services B.V. - * @license LGPLv3 - * @author Fabian Jakobs - */ + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Ajax.org Code Editor (ACE). + * + * The Initial Developer of the Original Code is + * Ajax.org Services B.V. + * Portions created by the Initial Developer are Copyright (C) 2010 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Fabian Jakobs + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ define(function(require, exports, module) { diff --git a/lib/ace/test/mode/css_test.js b/lib/ace/test/mode/css_test.js index 0660ad56..27b5e55a 100644 --- a/lib/ace/test/mode/css_test.js +++ b/lib/ace/test/mode/css_test.js @@ -1,22 +1,47 @@ -/** - * Ajax.org Code Editor (ACE) +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * - * @copyright 2010, Ajax.org Services B.V. - * @license LGPLv3 - * @author Fabian Jakobs - */ + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Ajax.org Code Editor (ACE). + * + * The Initial Developer of the Original Code is + * Ajax.org Services B.V. + * Portions created by the Initial Developer are Copyright (C) 2010 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Fabian Jakobs + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ -require.def([ - "ace/Document", - "ace/Range", - "ace/mode/Css" - ], function( - Document, - Range, - CssMode - ) { +define(function(require, exports, module) { + +var Document = require("ace/document").Document; +var Range = require("ace/range").Range; +var Css = require("ace/mode/css").Mode; - var CssTest = new TestCase("mode.CssTest", { +var CssTest = new TestCase("mode.CssTest", { setUp : function() { this.mode = new CssMode(); diff --git a/lib/ace/test/mode/css_tokenizer_test.js b/lib/ace/test/mode/css_tokenizer_test.js index d6200751..858770ba 100644 --- a/lib/ace/test/mode/css_tokenizer_test.js +++ b/lib/ace/test/mode/css_tokenizer_test.js @@ -1,16 +1,43 @@ -/** - * Ajax.org Code Editor (ACE) +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * - * @copyright 2010, Ajax.org Services B.V. - * @license LGPLv3 - * @author Fabian Jakobs - */ + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Ajax.org Code Editor (ACE). + * + * The Initial Developer of the Original Code is + * Ajax.org Services B.V. + * Portions created by the Initial Developer are Copyright (C) 2010 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Fabian Jakobs + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ -require.def([ - "ace/mode/Css" - ], function( - CssMode - ) { +define(function(require, exports, module) { + +var Css = require("ace/mode/css").Mode; var CssTest = new TestCase("mode.CssTest", { diff --git a/lib/ace/test/mode/html_test.js b/lib/ace/test/mode/html_test.js index d809315f..1e631b55 100644 --- a/lib/ace/test/mode/html_test.js +++ b/lib/ace/test/mode/html_test.js @@ -1,20 +1,45 @@ -/** - * Ajax.org Code Editor (ACE) +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * - * @copyright 2010, Ajax.org Services B.V. - * @license LGPLv3 - * @author Fabian Jakobs - */ + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Ajax.org Code Editor (ACE). + * + * The Initial Developer of the Original Code is + * Ajax.org Services B.V. + * Portions created by the Initial Developer are Copyright (C) 2010 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Fabian Jakobs + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ -require.def([ - "ace/Document", - "ace/Range", - "ace/mode/Html" - ], function( - Document, - Range, - HtmlMode - ) { +define(function(require, exports, module) { + +var Document = require("ace/document").Document; +var Range = require("ace/range").Range; +var Html = require("ace/mode/html").Mode; var HtmlTest = new TestCase("mode.HtmlTest", { diff --git a/lib/ace/test/mode/html_tokenizer_test.js b/lib/ace/test/mode/html_tokenizer_test.js index b538e4c4..6c89dc81 100644 --- a/lib/ace/test/mode/html_tokenizer_test.js +++ b/lib/ace/test/mode/html_tokenizer_test.js @@ -1,16 +1,43 @@ -/** - * Ajax.org Code Editor (ACE) +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * - * @copyright 2010, Ajax.org Services B.V. - * @license LGPLv3 - * @author Fabian Jakobs - */ + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Ajax.org Code Editor (ACE). + * + * The Initial Developer of the Original Code is + * Ajax.org Services B.V. + * Portions created by the Initial Developer are Copyright (C) 2010 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Fabian Jakobs + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ -require.def([ - "ace/mode/Html" - ], function( - HtmlMode - ) { +define(function(require, exports, module) { + +var Html = require("ace/mode/html").Mode; var HtmlTest = new TestCase("mode.HtmlTest", { diff --git a/lib/ace/test/mode/javascript_test.js b/lib/ace/test/mode/javascript_test.js index 8f61d55a..52de56d1 100644 --- a/lib/ace/test/mode/javascript_test.js +++ b/lib/ace/test/mode/javascript_test.js @@ -1,22 +1,46 @@ -/** - * Ajax.org Code Editor (ACE) +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * - * @copyright 2010, Ajax.org Services B.V. - * @license LGPLv3 - * @author Fabian Jakobs - */ + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Ajax.org Code Editor (ACE). + * + * The Initial Developer of the Original Code is + * Ajax.org Services B.V. + * Portions created by the Initial Developer are Copyright (C) 2010 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Fabian Jakobs + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ -require.def([ - "ace/Document", - "ace/Range", - "ace/Tokenizer", - "ace/mode/JavaScript" - ], function( - Document, - Range, - Tokenizer, - JavaScriptMode - ) { +define(function(require, exports, module) { + +var Document = require("ace/document").Document; +var Range = require("ace/range").Range; +var Tokenizer = require("ace/tokenizer").Tokenizer; +var JavaScript = require("ace/mode/javascript").Mode; var JavaScriptTest = new TestCase("mode.JavaScriptTest", { diff --git a/lib/ace/test/mode/javascript_tokenizer_test.js b/lib/ace/test/mode/javascript_tokenizer_test.js index 65f40f21..518d58e4 100644 --- a/lib/ace/test/mode/javascript_tokenizer_test.js +++ b/lib/ace/test/mode/javascript_tokenizer_test.js @@ -1,16 +1,43 @@ -/** - * Ajax.org Code Editor (ACE) +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * - * @copyright 2010, Ajax.org Services B.V. - * @license LGPLv3 - * @author Fabian Jakobs - */ + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Ajax.org Code Editor (ACE). + * + * The Initial Developer of the Original Code is + * Ajax.org Services B.V. + * Portions created by the Initial Developer are Copyright (C) 2010 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Fabian Jakobs + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ -require.def([ - "ace/mode/JavaScript" - ], function( - JavaScriptMode - ) { +define(function(require, exports, module) { + +var JavaScript = require("ace/mode/javascript").Mode; var JavaScriptTokenizerTest = new TestCase("mode.JavaScriptTokenizerTest", { diff --git a/lib/ace/test/mode/text_test.js b/lib/ace/test/mode/text_test.js index 252b867e..ef41e7b3 100644 --- a/lib/ace/test/mode/text_test.js +++ b/lib/ace/test/mode/text_test.js @@ -1,20 +1,45 @@ -/** - * Ajax.org Code Editor (ACE) +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * - * @copyright 2010, Ajax.org Services B.V. - * @license LGPLv3 - * @author Fabian Jakobs - */ + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Ajax.org Code Editor (ACE). + * + * The Initial Developer of the Original Code is + * Ajax.org Services B.V. + * Portions created by the Initial Developer are Copyright (C) 2010 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Fabian Jakobs + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ -require.def([ - "ace/Document", - "ace/Range", - "ace/mode/Text" - ], function( - Document, - Range, - TextMode - ) { +define(function(require, exports, module) { + +var Document = require("ace/document").Document; +var Range = require("ace/range").Range; +var Text = require("ace/mode/text").Mode; var TextTest = new TestCase("mode.TextTest", { diff --git a/lib/ace/test/mode/xml_test.js b/lib/ace/test/mode/xml_test.js index 8c8e7f92..8f2962c6 100644 --- a/lib/ace/test/mode/xml_test.js +++ b/lib/ace/test/mode/xml_test.js @@ -1,22 +1,46 @@ -/** - * Ajax.org Code Editor (ACE) +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * - * @copyright 2010, Ajax.org Services B.V. - * @license LGPLv3 - * @author Fabian Jakobs - */ + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Ajax.org Code Editor (ACE). + * + * The Initial Developer of the Original Code is + * Ajax.org Services B.V. + * Portions created by the Initial Developer are Copyright (C) 2010 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Fabian Jakobs + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ -require.def([ - "ace/Document", - "ace/Range", - "ace/Tokenizer", - "ace/mode/Xml" - ], function( - Document, - Range, - Tokenizer, - XmlMode - ) { +define(function(require, exports, module) { + +var Document = require("ace/document").Document; +var Range = require("ace/range").Range; +var Tokenizer = require("ace/tokenizer").Tokenizer; +var Xml = require("ace/mode/xml").Mode; var XmlTest = new TestCase("mode.XmlTest", { diff --git a/lib/ace/test/mode/xml_tokenizer_test.js b/lib/ace/test/mode/xml_tokenizer_test.js index 3963fa70..cb03b4f5 100644 --- a/lib/ace/test/mode/xml_tokenizer_test.js +++ b/lib/ace/test/mode/xml_tokenizer_test.js @@ -1,16 +1,43 @@ -/** - * Ajax.org Code Editor (ACE) +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * - * @copyright 2010, Ajax.org Services B.V. - * @license LGPLv3 - * @author Fabian Jakobs - */ + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Ajax.org Code Editor (ACE). + * + * The Initial Developer of the Original Code is + * Ajax.org Services B.V. + * Portions created by the Initial Developer are Copyright (C) 2010 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Fabian Jakobs + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ -require.def([ - "ace/mode/Xml" - ], function( - XmlMode - ) { +define(function(require, exports, module) { + +var Xml = require("ace/mode/xml").Mode; var XmlTest = new TestCase("mode.XmlTest", { diff --git a/lib/ace/test/navigation_test.js b/lib/ace/test/navigation_test.js index f05acd79..63e519e8 100644 --- a/lib/ace/test/navigation_test.js +++ b/lib/ace/test/navigation_test.js @@ -1,10 +1,39 @@ -/** - * Ajax.org Code Editor (ACE) +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * - * @copyright 2010, Ajax.org Services B.V. - * @license LGPLv3 - * @author Fabian Jakobs - */ + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Ajax.org Code Editor (ACE). + * + * The Initial Developer of the Original Code is + * Ajax.org Services B.V. + * Portions created by the Initial Developer are Copyright (C) 2010 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Fabian Jakobs + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ require("../../../support/paths"); @@ -132,4 +161,4 @@ var Test = { module.exports = require("async/test").testcase(Test) if (module === require.main) - module.exports.exec() \ No newline at end of file + module.exports.exec() diff --git a/lib/ace/test/range_test.js b/lib/ace/test/range_test.js index 3e8989c9..3aa1cc72 100644 --- a/lib/ace/test/range_test.js +++ b/lib/ace/test/range_test.js @@ -1,10 +1,39 @@ -/** - * Ajax.org Code Editor (ACE) +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * - * @copyright 2010, Ajax.org Services B.V. - * @license LGPLv3 - * @author Fabian Jakobs - */ + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Ajax.org Code Editor (ACE). + * + * The Initial Developer of the Original Code is + * Ajax.org Services B.V. + * Portions created by the Initial Developer are Copyright (C) 2010 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Fabian Jakobs + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ require("../../../support/paths"); @@ -121,4 +150,4 @@ var Test = { module.exports = require("async/test").testcase(Test); if (module === require.main) - module.exports.exec() \ No newline at end of file + module.exports.exec() diff --git a/lib/ace/test/search_test.js b/lib/ace/test/search_test.js index 9f4255fc..ba9b6e10 100644 --- a/lib/ace/test/search_test.js +++ b/lib/ace/test/search_test.js @@ -1,10 +1,39 @@ -/** - * Ajax.org Code Editor (ACE) +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * - * @copyright 2010, Ajax.org Services B.V. - * @license LGPLv3 - * @author Fabian Jakobs - */ + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Ajax.org Code Editor (ACE). + * + * The Initial Developer of the Original Code is + * Ajax.org Services B.V. + * Portions created by the Initial Developer are Copyright (C) 2010 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Fabian Jakobs + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ require("../../../support/paths"); @@ -318,4 +347,4 @@ var Test = { module.exports = require("async/test").testcase(Test) if (module === require.main) - module.exports.exec(); \ No newline at end of file + module.exports.exec(); diff --git a/lib/ace/test/selection_test.js b/lib/ace/test/selection_test.js index 539c146d..407fd3bf 100644 --- a/lib/ace/test/selection_test.js +++ b/lib/ace/test/selection_test.js @@ -1,10 +1,39 @@ -/** - * Ajax.org Code Editor (ACE) +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * - * @copyright 2010, Ajax.org Services B.V. - * @license LGPLv3 - * @author Fabian Jakobs - */ + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Ajax.org Code Editor (ACE). + * + * The Initial Developer of the Original Code is + * Ajax.org Services B.V. + * Portions created by the Initial Developer are Copyright (C) 2010 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Fabian Jakobs + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ require("../../../support/paths"); @@ -264,4 +293,4 @@ var Test = { module.exports = require("async/test").testcase(Test); if (module === require.main) - module.exports.exec() \ No newline at end of file + module.exports.exec() diff --git a/lib/ace/test/text_edit_test.js b/lib/ace/test/text_edit_test.js index 7dd20a19..fbc39d2b 100644 --- a/lib/ace/test/text_edit_test.js +++ b/lib/ace/test/text_edit_test.js @@ -1,10 +1,39 @@ -/** - * Ajax.org Code Editor (ACE) +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * - * @copyright 2010, Ajax.org Services B.V. - * @license LGPLv3 - * @author Fabian Jakobs - */ + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Ajax.org Code Editor (ACE). + * + * The Initial Developer of the Original Code is + * Ajax.org Services B.V. + * Portions created by the Initial Developer are Copyright (C) 2010 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Fabian Jakobs + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ require("../../../support/paths"); @@ -18,11 +47,11 @@ global.navigator = browser.navigator; global.location = browser.location; var Document = require("../document"), - Editor = require("../editor"), - JavaScriptMode = require("../mode/javascript"), + Editor = require("../editor"), + JavaScriptMode = require("../mode/javascript").Mode, MockRenderer = require("./mockrenderer"), assert = require("./assertions"); - + var Test = { "test: delete line from the middle" : function() { var doc = new Document(["a", "b", "c", "d"].join("\n")); @@ -83,7 +112,7 @@ var Test = { assert.position(editor.getCursorPosition(), 2, 0); }, - "__test: indent block" : function() { + "test: indent block" : function() { var doc = new Document(["a12345", "b12345", "c12345"].join("\n")); var editor = new Editor(new MockRenderer(), doc); @@ -102,7 +131,7 @@ var Test = { assert.position(range.end, 2, 7); }, - "__test: outdent block" : function() { + "test: outdent block" : function() { var doc = new Document([" a12345", " b12345", " c12345"].join("\n")); var editor = new Editor(new MockRenderer(), doc); @@ -219,7 +248,7 @@ var Test = { assert.position(editor.getSelection().getSelectionLead(), 2, 0); }, - "__test: move lines up should select moved lines" : function() { + "test: move lines up should select moved lines" : function() { var doc = new Document(["11", "22", "33", "44"].join("\n")); var editor = new Editor(new MockRenderer(), doc); @@ -317,4 +346,4 @@ var Test = { module.exports = require("async/test").testcase(Test); if (module === require.main) - module.exports.exec() \ No newline at end of file + module.exports.exec() diff --git a/lib/ace/test/virtual_renderer_test.js b/lib/ace/test/virtual_renderer_test.js index 3f4a5ca3..776d8bab 100644 --- a/lib/ace/test/virtual_renderer_test.js +++ b/lib/ace/test/virtual_renderer_test.js @@ -1,13 +1,42 @@ -/** - * Ajax.org Code Editor (ACE) +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * - * @copyright 2010, Ajax.org Services B.V. - * @license LGPLv3 - * @author Fabian Jakobs - */ - + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Ajax.org Code Editor (ACE). + * + * The Initial Developer of the Original Code is + * Ajax.org Services B.V. + * Portions created by the Initial Developer are Copyright (C) 2010 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Fabian Jakobs + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + require("../../../support/paths"); - + var Document = "../document", VirtualRenderer = "../virtual_renderer", assert = "../assertions"; @@ -45,4 +74,4 @@ var Test = { module.exports = require("async/test").testcase(Test); if (module === require.main) - module.exports.exec() \ No newline at end of file + module.exports.exec() diff --git a/lib/ace/textinput.js b/lib/ace/textinput.js index 4bcf479f..d4abdc96 100644 --- a/lib/ace/textinput.js +++ b/lib/ace/textinput.js @@ -37,7 +37,7 @@ define(function(require, exports, module) { -var event = require("./lib/event"); +var event = require("pilot/event").event; var TextInput = function(parentNode, host) { @@ -146,5 +146,5 @@ var TextInput = function(parentNode, host) { }; }; -return TextInput; -}); \ No newline at end of file +exports.TextInput = TextInput; +}); diff --git a/lib/ace/theme/clouds.js b/lib/ace/theme/clouds.js index 9489d9ea..6f1fa494 100644 --- a/lib/ace/theme/clouds.js +++ b/lib/ace/theme/clouds.js @@ -1,6 +1,43 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Ajax.org Code Editor (ACE). + * + * The Initial Developer of the Original Code is + * Ajax.org Services B.V. + * Portions created by the Initial Developer are Copyright (C) 2010 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Fabian Jakobs + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + define(function(require, exports, module) { -var dom = require("../lib/dom"); + var dom = require("pilot/dom").dom; var cssText = ".ace-clouds .ace_editor {\ border: 2px solid rgb(159, 159, 159);\ @@ -150,11 +187,9 @@ var dom = require("../lib/dom"); .ace-clouds .ace_xml_pe {\ \ }"; - + // import CSS once dom.importCssString(cssText); - - return { - cssClass: "ace-clouds" - }; -}) \ No newline at end of file + + exports.cssClass = "ace-clouds"; +}); diff --git a/lib/ace/theme/clouds_mignight.js b/lib/ace/theme/clouds_mignight.js index 93c3f99d..d73350f2 100644 --- a/lib/ace/theme/clouds_mignight.js +++ b/lib/ace/theme/clouds_mignight.js @@ -1,6 +1,43 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Ajax.org Code Editor (ACE). + * + * The Initial Developer of the Original Code is + * Ajax.org Services B.V. + * Portions created by the Initial Developer are Copyright (C) 2010 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Fabian Jakobs + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + define(function(require, exports, module) { -var dom = require("../lib/dom"); + var dom = require("pilot/dom").dom; var cssText = ".ace-clouds-midnight .ace_editor {\ border: 2px solid rgb(159, 159, 159);\ @@ -151,11 +188,9 @@ background-color:#E92E2E;\ .ace-clouds-midnight .ace_xml_pe {\ \ }"; - + // import CSS once dom.importCssString(cssText); - - return { - cssClass: "ace-clouds-midnight" - }; -}) \ No newline at end of file + + exports.cssClass = "ace-clouds-midnight"; +}); diff --git a/lib/ace/theme/cobalt.js b/lib/ace/theme/cobalt.js index def66f11..5ae45ca1 100644 --- a/lib/ace/theme/cobalt.js +++ b/lib/ace/theme/cobalt.js @@ -1,7 +1,43 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Ajax.org Code Editor (ACE). + * + * The Initial Developer of the Original Code is + * Ajax.org Services B.V. + * Portions created by the Initial Developer are Copyright (C) 2010 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Fabian Jakobs + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + define(function(require, exports, module) { -var dom = require("../lib/dom"); - + var dom = require("pilot/dom").dom; var cssText = ".ace-cobalt .ace_editor {\ border: 2px solid rgb(159, 159, 159);\ @@ -153,11 +189,9 @@ color:#0088FF;\ .ace-cobalt .ace_xml_pe {\ \ }"; - + // import CSS once dom.importCssString(cssText); - - return { - cssClass: "ace-cobalt" - }; -}) \ No newline at end of file + + exports.cssClass = "ace-cobalt"; +}); diff --git a/lib/ace/theme/dawn.js b/lib/ace/theme/dawn.js index 247336da..02a46140 100644 --- a/lib/ace/theme/dawn.js +++ b/lib/ace/theme/dawn.js @@ -1,6 +1,43 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Ajax.org Code Editor (ACE). + * + * The Initial Developer of the Original Code is + * Ajax.org Services B.V. + * Portions created by the Initial Developer are Copyright (C) 2010 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Fabian Jakobs + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + define(function(require, exports, module) { -var dom = require("../lib/dom"); + var dom = require("pilot/dom").dom; var cssText = ".ace-dawn .ace_editor {\ border: 2px solid rgb(159, 159, 159);\ @@ -156,11 +193,9 @@ color:#5A525F;\ .ace-dawn .ace_xml_pe {\ \ }"; - + // import CSS once dom.importCssString(cssText); - - return { - cssClass: "ace-dawn" - }; -}) \ No newline at end of file + + exports.cssClass = "ace-dawn"; +}); diff --git a/lib/ace/theme/eclipse.js b/lib/ace/theme/eclipse.js index 8cee6e9e..9545a5eb 100644 --- a/lib/ace/theme/eclipse.js +++ b/lib/ace/theme/eclipse.js @@ -1,12 +1,47 @@ -define(["require", "exports", "module", "text!ace/theme/eclipse.css", "../lib/dom"], - function(require, exports, module, cssText) { +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Ajax.org Code Editor (ACE). + * + * The Initial Developer of the Original Code is + * Ajax.org Services B.V. + * Portions created by the Initial Developer are Copyright (C) 2010 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Fabian Jakobs + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +define(function(require, exports, module) { + + var dom = require("pilot/dom").dom; + var cssText = require("text!ace/theme/eclipse.css"); - var dom = require("../lib/dom"); - // import CSS once dom.importCssString(cssText); - return { - cssClass: "ace-eclipse" - }; -}) \ No newline at end of file + exports.cssClass = "ace-eclipse"; +}); diff --git a/lib/ace/theme/idle_fingers.js b/lib/ace/theme/idle_fingers.js index 6975a87d..c0e3733a 100644 --- a/lib/ace/theme/idle_fingers.js +++ b/lib/ace/theme/idle_fingers.js @@ -1,7 +1,43 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Ajax.org Code Editor (ACE). + * + * The Initial Developer of the Original Code is + * Ajax.org Services B.V. + * Portions created by the Initial Developer are Copyright (C) 2010 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Fabian Jakobs + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + define(function(require, exports, module) { -var dom = require("../lib/dom"); - + var dom = require("pilot/dom").dom; var cssText = ".ace-idle-fingers .ace_editor {\ border: 2px solid rgb(159, 159, 159);\ @@ -153,11 +189,9 @@ color:#BC9458;\ .ace-idle-fingers .ace_xml_pe {\ \ }"; - + // import CSS once dom.importCssString(cssText); - - return { - cssClass: "ace-idle-fingers" - }; -}) \ No newline at end of file + + exports.cssClass = "ace-idle-fingers"; +}); diff --git a/lib/ace/theme/kr_theme.js b/lib/ace/theme/kr_theme.js index 406f159b..164232d7 100644 --- a/lib/ace/theme/kr_theme.js +++ b/lib/ace/theme/kr_theme.js @@ -1,7 +1,43 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Ajax.org Code Editor (ACE). + * + * The Initial Developer of the Original Code is + * Ajax.org Services B.V. + * Portions created by the Initial Developer are Copyright (C) 2010 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Fabian Jakobs + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + define(function(require, exports, module) { -var dom = require("../lib/dom"); - + var dom = require("pilot/dom").dom; var cssText = ".ace-kr-theme .ace_editor {\ border: 2px solid rgb(159, 159, 159);\ @@ -153,11 +189,9 @@ color:#706D5B;\ .ace-kr-theme .ace_xml_pe {\ \ }"; - + // import CSS once dom.importCssString(cssText); - - return { - cssClass: "ace-kr-theme" - }; -}) \ No newline at end of file + + exports.cssClass = "ace-kr-theme"; +}); diff --git a/lib/ace/theme/mono_industrial.js b/lib/ace/theme/mono_industrial.js index 842f7ec3..20a0efbb 100644 --- a/lib/ace/theme/mono_industrial.js +++ b/lib/ace/theme/mono_industrial.js @@ -1,7 +1,43 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Ajax.org Code Editor (ACE). + * + * The Initial Developer of the Original Code is + * Ajax.org Services B.V. + * Portions created by the Initial Developer are Copyright (C) 2010 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Fabian Jakobs + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + define(function(require, exports, module) { -var dom = require("../lib/dom"); - + var dom = require("pilot/dom").dom; var cssText = ".ace-mono-industrial .ace_editor {\ border: 2px solid rgb(159, 159, 159);\ @@ -153,11 +189,9 @@ background-color:#151C19;\ .ace-mono-industrial .ace_xml_pe {\ \ }"; - + // import CSS once dom.importCssString(cssText); - - return { - cssClass: "ace-mono-industrial" - }; -}) \ No newline at end of file + + exports.cssClass = "ace-mono-industrial"; +}); diff --git a/lib/ace/theme/monokai.js b/lib/ace/theme/monokai.js index d20ac5d5..3e116bc6 100644 --- a/lib/ace/theme/monokai.js +++ b/lib/ace/theme/monokai.js @@ -1,7 +1,43 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Ajax.org Code Editor (ACE). + * + * The Initial Developer of the Original Code is + * Ajax.org Services B.V. + * Portions created by the Initial Developer are Copyright (C) 2010 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Fabian Jakobs + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + define(function(require, exports, module) { -var dom = require("../lib/dom"); - + var dom = require("pilot/dom").dom; var cssText = ".ace-monokai .ace_editor {\ border: 2px solid rgb(159, 159, 159);\ @@ -153,11 +189,9 @@ background-color:#AE81FF;\ .ace-monokai .ace_xml_pe {\ \ }"; - + // import CSS once dom.importCssString(cssText); - - return { - cssClass: "ace-monokai" - }; -}) \ No newline at end of file + + exports.cssClass = "ace-monokai"; +}); diff --git a/lib/ace/theme/textmate.js b/lib/ace/theme/textmate.js index a28c2d6e..19d65d27 100644 --- a/lib/ace/theme/textmate.js +++ b/lib/ace/theme/textmate.js @@ -1,12 +1,47 @@ -define(["require", "exports", "module", "text!ace/theme/tm.css", "../lib/dom"], - function(require, exports, module, cssText) { +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Ajax.org Code Editor (ACE). + * + * The Initial Developer of the Original Code is + * Ajax.org Services B.V. + * Portions created by the Initial Developer are Copyright (C) 2010 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Fabian Jakobs + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ - var dom = require("../lib/dom"); +define(function(require, exports, module) { + + var dom = require("pilot/dom").dom; + var cssText = require("text!ace/theme/tm.css"); // import CSS once dom.importCssString(cssText); - - return { - cssClass: "ace-tm" - }; -}) \ No newline at end of file + + exports.cssClass = "ace-tm"; +}); diff --git a/lib/ace/theme/twilight.js b/lib/ace/theme/twilight.js index 1f3d61d5..dba0f7a4 100644 --- a/lib/ace/theme/twilight.js +++ b/lib/ace/theme/twilight.js @@ -1,6 +1,43 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Ajax.org Code Editor (ACE). + * + * The Initial Developer of the Original Code is + * Ajax.org Services B.V. + * Portions created by the Initial Developer are Copyright (C) 2010 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Fabian Jakobs + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + define(function(require, exports, module) { -var dom = require("../lib/dom"); + var dom = require("pilot/dom").dom; var cssText = ".ace-twilight .ace_editor {\ border: 2px solid rgb(159, 159, 159);\ @@ -154,11 +191,9 @@ color:#5F5A60;\ .ace-twilight .ace_xml_pe {\ color:#494949;\ }"; - + // import CSS once dom.importCssString(cssText); - - return { - cssClass: "ace-twilight" - }; -}) \ No newline at end of file + + exports.cssClass = "ace-twilight"; +}); diff --git a/lib/ace/tokenizer.js b/lib/ace/tokenizer.js index 79e9082d..c5cdf964 100644 --- a/lib/ace/tokenizer.js +++ b/lib/ace/tokenizer.js @@ -128,5 +128,5 @@ var Tokenizer = function(rules) { }).call(Tokenizer.prototype); -return Tokenizer; -}); \ No newline at end of file +exports.Tokenizer = Tokenizer; +}); diff --git a/lib/ace/undomanager.js b/lib/ace/undomanager.js index 79a4ad7b..4ef90fef 100644 --- a/lib/ace/undomanager.js +++ b/lib/ace/undomanager.js @@ -73,5 +73,5 @@ var UndoManager = function() { }).call(UndoManager.prototype); -return UndoManager; -}); \ No newline at end of file +exports.UndoManager = UndoManager; +}); diff --git a/lib/ace/virtual_renderer.js b/lib/ace/virtual_renderer.js index 11869f63..08155d9c 100644 --- a/lib/ace/virtual_renderer.js +++ b/lib/ace/virtual_renderer.js @@ -35,22 +35,20 @@ * * ***** END LICENSE BLOCK ***** */ -define(["require", "exports", "module", "text!ace/css/editor.css", "./lib/oop", "./lib/oop", - "./lib/event", "./layer/gutter", "./layer/marker", "./layer/text", - "./layer/cursor", "./scrollbar", "./renderloop", "./event_emitter"], - function(require, exports, module, editorCss) { +define(function(require, exports, module) { -var oop = require("./lib/oop"); -var lang = require("./lib/lang"); -var dom = require("./lib/dom"); -var event = require("./lib/event"); -var GutterLayer = require("./layer/gutter"); -var MarkerLayer = require("./layer/marker"); -var TextLayer = require("./layer/text"); -var CursorLayer = require("./layer/cursor"); -var ScrollBar = require("./scrollbar"); -var RenderLoop = require("./renderloop"); -var MEventEmitter = require("./event_emitter"); +var oop = require("pilot/oop").oop; +var lang = require("pilot/lang").lang; +var dom = require("pilot/dom").dom; +var event = require("pilot/event").event; +var GutterLayer = require("ace/layer/gutter").Gutter; +var MarkerLayer = require("ace/layer/marker").Marker; +var TextLayer = require("ace/layer/text").Text; +var CursorLayer = require("ace/layer/cursor").Cursor; +var ScrollBar = require("ace/scrollbar").ScrollBar; +var RenderLoop = require("ace/renderloop").RenderLoop; +var EventEmitter = require("pilot/event_emitter").EventEmitter; +var editorCss = require("text!ace/css/editor.css"); // import CSS once dom.importCssString(editorCss); @@ -115,7 +113,7 @@ var VirtualRenderer = function(container, theme) { this.$loop = new RenderLoop(lang.bind(this.$renderChanges, this)); this.$loop.schedule(this.CHANGE_FULL); - + this.$updatePrintMargin(); this.setPadding(4); }; @@ -133,7 +131,7 @@ var VirtualRenderer = function(container, theme) { this.CHANGE_SIZE = 64; this.CHANGE_FULL = 128; - oop.implement(this, MEventEmitter); + oop.implement(this, EventEmitter); this.setDocument = function(doc) { this.lines = doc.lines; @@ -225,7 +223,7 @@ var VirtualRenderer = function(container, theme) { var pageX = event.getDocumentX(e); var pageY = event.getDocumentY(e); - this.$dispatchEvent("gutter" + e.type, { + this._dispatchEvent("gutter" + e.type, { row: this.screenToTextCoordinates(pageX, pageY).row, htmlEvent: e }); @@ -262,7 +260,7 @@ var VirtualRenderer = function(container, theme) { this.getPrintMarginColumn = function() { return this.$printMarginColumn; }; - + this.setShowGutter = function(show){ this.$gutter.style.display = show ? "block" : "none"; this.showGutter = show; @@ -295,18 +293,18 @@ var VirtualRenderer = function(container, theme) { this.getFirstVisibleRow = function() { return (this.layerConfig || {}).firstRow || 0; }; - + this.getFirstFullyVisibleRow = function(){ if (!this.layerConfig) return 0; - + return this.layerConfig.firstRow + (this.layerConfig.offset == 0 ? 0 : 1); } this.getLastFullyVisibleRow = function() { if (!this.layerConfig) return 0; - + var flint = Math.floor((this.layerConfig.height + this.layerConfig.offset) / this.layerConfig.lineHeight); return this.layerConfig.firstRow - 1 + flint; } @@ -374,7 +372,7 @@ var VirtualRenderer = function(container, theme) { } else if (changes & this.CHANGE_LINES) { this.$updateLines(); - this.$updateScrollBar(); + this.$updateScrollBar(); } if (changes & this.CHANGE_GUTTER) { this.showGutter && this.$gutterLayer.update(this.layerConfig); } @@ -399,7 +397,7 @@ var VirtualRenderer = function(container, theme) { var lineCount = Math.ceil(minHeight / this.lineHeight); var firstRow = Math.max(0, Math.round((this.scrollTop - offset) / this.lineHeight)); - var lastRow = Math.min(this.lines.length, firstRow + lineCount) - 1; + var lastRow = Math.max(0, Math.min(this.lines.length, firstRow + lineCount) - 1); var layerConfig = this.layerConfig = { width : longestLine, @@ -470,17 +468,17 @@ var VirtualRenderer = function(container, theme) { this.$markerLayer.removeMarker(markerId); this.$loop.schedule(this.CHANGE_MARKER); }; - + this.addGutterDecoration = function(row, className){ this.$gutterLayer.addGutterDecoration(row, className); this.$loop.schedule(this.CHANGE_GUTTER); } - + this.removeGutterDecoration = function(row, className){ this.$gutterLayer.removeGutterDecoration(row, className); this.$loop.schedule(this.CHANGE_GUTTER); } - + this.setBreakpoints = function(rows) { this.$gutterLayer.setBreakpoints(rows); this.$loop.schedule(this.CHANGE_GUTTER); @@ -528,7 +526,7 @@ var VirtualRenderer = function(container, theme) { this.getScrollTop = function() { return this.scrollTop; }; - + this.getScrollLeft = function() { return this.scroller.scrollLeft; }; @@ -550,7 +548,7 @@ var VirtualRenderer = function(container, theme) { this.$loop.schedule(this.CHANGE_SCROLL); } }; - + this.scrollToX = function(scrollLeft) { if (scrollLeft <= this.$padding) scrollLeft = 0; @@ -579,10 +577,10 @@ var VirtualRenderer = function(container, theme) { this.textToScreenCoordinates = function(row, column) { var canvasPos = this.scroller.getBoundingClientRect(); - + var x = this.padding + Math.round(this.doc.documentToScreenColumn(row, column) * this.characterWidth); var y = row * this.lineHeight; - + return { pageX: canvasPos.left + x - this.getScrollLeft(), pageY: canvasPos.top + y - this.getScrollTop() @@ -637,5 +635,5 @@ var VirtualRenderer = function(container, theme) { }).call(VirtualRenderer.prototype); -return VirtualRenderer; -}); \ No newline at end of file +exports.VirtualRenderer = VirtualRenderer; +}); diff --git a/plugins/cockpit/cli.js b/plugins/cockpit/cli.js new file mode 100644 index 00000000..85382cb9 --- /dev/null +++ b/plugins/cockpit/cli.js @@ -0,0 +1,825 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Skywriter. + * + * The Initial Developer of the Original Code is + * Mozilla. + * Portions created by the Initial Developer are Copyright (C) 2009 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Joe Walker (jwalker@mozilla.com) + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +define(function(require, exports, module) { + + +var console = require('pilot/console'); +var util = require('pilot/util'); +var oop = require('pilot/oop').oop; +var EventEmitter = require('pilot/event_emitter').EventEmitter; + +//var keyboard = require('keyboard/keyboard'); +var types = require('pilot/types'); +var Status = require('pilot/types').Status; +var Conversion = require('pilot/types').Conversion; +var canon = require('pilot/canon'); + + +/** + * The information required to tell the user there is a problem with their + * input. + */ +function Hint(status, message, start, end) { + this.status = status; + this.message = message; + + if (typeof start === 'number') { + this.start = start; + this.end = end; + } + else { + var arg = start; + this.start = arg.start; + this.end = arg.end; + } +} +Hint.prototype = { +}; +exports.Hint = Hint; + +/** + * A Hint that arose as a result of a Conversion + */ +function ConversionHint(conversion, arg) { + this.status = conversion.status; + this.message = conversion.message; + if (arg) { + this.start = arg.start; + this.end = arg.end; + } + else { + this.start = 0; + this.end = 0; + } + this.predictions = conversion.predictions; +}; +oop.inherits(ConversionHint, Hint); + + +/** + * We record where in the input string an argument comes so we can report errors + * against those string positions. + * @constructor + */ +function Argument(text, start, end, priorSpace) { + this.setText(text); + this.start = start; + this.end = end; + this.priorSpace = priorSpace; +} +Argument.prototype = { + /** + * Return the result of merging these arguments + */ + merge: function(following) { + return new Argument( + this.text + following.priorSpace + following.text, + this.start, following.end, + this.priorSpace); + }, + + setText: function(text) { + if (text == null) { + throw new Error('Illegal text for Argument: ' + text); + } + this.text = text; + } +}; +/** + * Merge an array of arguments into a single argument. + */ +Argument.merge = function(argArray, start, end) { + start = (start === undefined) ? 0 : start; + end = (end === undefined) ? argArray.length : end; + + var joined; + for (var i = start; i < end; i++) { + var arg = argArray[i]; + if (!joined) { + joined = arg; + } + else { + joined = joined.merge(arg); + } + } + return joined; +}; + + +/** + * A link between a parameter and the data for that parameter. + * The data for the parameter is available as in the preferred type and as + * an Argument for the CLI. + *

We also record validity information where applicable. + *

For values, null and undefined have distinct definitions. null means + * that a value has been provided, undefined means that it has not. + * Thus, null is a valid default value, and common because it identifies an + * parameter that is optional. undefined means there is no value from + * the command line. + * @constructor + */ +function Assignment(param) { + this.param = param; + this.setValue(param.defaultValue); +}; +Assignment.prototype = { + /** + * The parameter that we are assigning to + * @readonly + */ + param: undefined, + + /** + * The current value (i.e. not the string representation) + * Use setValue() to mutate + */ + value: undefined, + setValue: function(value) { + if (this.value === value) { + return; + } + if (value === undefined) { + value = this.param.defaultValue; + } + this.value = value; + + var text = (value == null) ? '' : this.param.type.stringify(value); + if (this.arg) { + this.arg.setText(text); + } + + this.conversion = undefined; + //this._dispatchEvent('change', { assignment: this }); + }, + + /** + * The textual representation of the current value + * Use setValue() to mutate + */ + arg: undefined, + setArgument: function(arg) { + if (this.arg === arg) { + return; + } + this.arg = arg; + this.conversion = this.param.type.parse(arg.text); + this.value = this.conversion.value; + //this._dispatchEvent('change', { assignment: this }); + }, + + /** + * Create a list of this hints associated with this parameter assignment + */ + getHints: function() { + var hints = []; + if (this.conversion != null && + (this.conversion.status !== Status.VALID || + this.conversion.message)) { + hints.push(new ConversionHint(this.conversion, this.arg)); + } + + var argProvided = this.arg != null && this.arg.text !== ''; + var dataProvided = this.value !== undefined || argProvided; + + if (this.param.defaultValue === undefined && !dataProvided) { + // If the there is no data provided, we have no start/end. Use -1 + hints.push(new Hint(Status.INVALID, + 'Argument for ' + param.name + ' is required' + -1, -1)); + } + return hints; + }, + + /** + * Report on the status of the last parse() conversion. + * @see types.Conversion + */ + conversion: undefined +}; +oop.implement(Assignment, EventEmitter); +exports.Assignment = Assignment; + + +/** + * A Requisition collects the information needed to execute a command. + * There is no point in a requisition for parameter-less commands because there + * is no information to collect. A Requisition is a collection of assignments + * of values to parameters, each handled by an instance of Assignment. + * CliRequisition adds functions for parsing input from a command line to this + * class + * @constructor + */ +function Requisition(env) { + this.env = env; +} + +Requisition.prototype = { + /** + * The command that we are about to execute. + * @readonly + */ + command: undefined, + + /** + * The count of assignments + * @readonly + */ + assignmentCount: undefined, + + /** + * Set a new command. We make no attempt to convert the args in the old + * command to args in the new command. The assignments need to be + * re-entered. + */ + setCommand: function(command) { + if (this.command === command) { + return; + } + + this.command = command; + this._assignments = {}; + + if (command) { + command.params.forEach(function(param) { + this._assignments[param.name] = new Assignment(param); + }, this); + } + + this.assignmentCount = Object.keys(this._assignments); + }, + + /** + * Assignments have an order, so we need to store them in an array. + * But we also need named access ... + */ + getAssignment: function(nameOrNumber) { + var name = (typeof nameOrNumber === 'string') ? + nameOrNumber : + Object.keys(this._assignments)[nameOrNumber]; + return this._assignments[name]; + }, + + /** + * Where parameter name == assignment names - they are the same. + */ + getParameterNames: function() { + return Object.keys(this._assignments); + }, + + /** + * A *shallow* clone of the assignments. + * This is useful for systems that wish to go over all the assignments + * finding values one way or another and wish to trim an array as they go. + */ + cloneAssignments: function() { + return Object.keys(this._assignments).map(function(name) { + return this._assignments[name]; + }, this); + }, + + /** + * Collect the statuses from the Assignments + */ + getHints: function() { + var hints = []; + Object.keys(this._assignments).map(function(name) { + // Append the assignments hints to our list + hints.push.apply(hints, this._assignments[name].getHints()); + }, this); + return hints; + }, + + /** + * Extract the names and values of all the assignments, and return as + * an object. + */ + getArgs: function() { + var args = {}; + Object.keys(this._assignments).forEach(function(name) { + args[name] = this.getAssignment(name).value; + }, this); + return args; + }, + + /** + * Reset all the assignments to their default values + */ + setDefaultValues: function() { + Object.keys(this._assignments).forEach(function(name) { + this._assignments[name].setValue(undefined); + }, this); + }, + + /** + * Helper to call canon.exec + */ + exec: function() { + canon.exec(this.command, this.getArgs()); + } +}; +exports.Requisition = Requisition; + + +/** + * An object used during command line parsing to hold the various intermediate + * data steps. + *

The 'output' of the update is held in 2 objects: input.hints which is an + * array of hints to display to the user. In the future this will become a + * single value. + *

The other output value is input.requisition which gives access to an + * args object for use in executing the final command. + * + *

The majority of the functions in this class are called in sequence by the + * constructor. Their task is to add to hints fill out the requisition. + *

The general sequence is:

    + *
  • _tokenize(): convert _typed into _parts + *
  • _split(): convert _parts into _command and _unparsedArgs + *
  • _assign(): convert _unparsedArgs into requisition + *
+ * + * @param typed {string} The instruction as typed by the user so far + * @param options {object} A list of optional named parameters. Can be any of: + * flags: Flags for us to check against the predicates specified with the + * commands. Defaulted to keyboard.buildFlags({ }); + * if not specified. + * @constructor + */ +function CliRequisition(env, options) { + Requisition.call(this, env); + + if (options && options.flags) { + /** + * TODO: We were using a default of keyboard.buildFlags({ }); + * This allowed us to have commands that only existed in certain contexts + * - i.e. Javascript specific commands. + */ + this.flags = options.flags; + } +} +oop.inherits(CliRequisition, Requisition); +(function() { + /** + * + */ + CliRequisition.prototype.update = function(input) { + this.hints = []; + + if (util.none(input.typed)) { + this.setCommand(null); + return; + } + + var args = _tokenize(input.typed); + if (args.length === 0) { + // We would like to put some initial help here, but for anyone but + // a complete novice a 'type help' message is very annoying, so we + // need to find a way to only display this message once, or for + // until the user click a 'close' button or similar + this._addHint(Status.INCOMPLETE, '', 0, 0); + this.setCommand(null); + return; + } + + var command = _split(args); + if (!command) { + // No command found - bail helpfully. + var commandType = types.getType('command'); + var conversion = commandType.parse(input.typed); + var arg = Argument.merge(args); + this._addHint(new ConversionHint(conversion, arg)); + + this.setCommand(null); + } + else { + // The user hasn't started to type any arguments + if (args.length === 0) { + var message = documentCommand(command); + this._addHint(Status.VALID, message, 0, input.typed.length); + } + + this.setCommand(command); + this._assign(args); + this._addHint(CliRequisition.super_.getHints.call(this)); + } + + // Not knowing about cursor positioning, the requisition and assignments + // can't know this, but anything they mark as INCOMPLETE is actually + // INVALID unless the cursor is actually inside that argument. + var c = input.cursor; + this.hints.forEach(function(hint) { + var startInHint = c.start >= hint.start && c.start <= hint.end; + var endInHint = c.end >= hint.start && c.end <= hint.end; + var inHint = startInHint || endInHint; + if (!inHint && hint.status === Status.INCOMPLETE) { + hint.status = Status.INVALID; + } + }, this); + + return; + }; + + CliRequisition.prototype.getHints = function() { + return this.hints; + }; + + /** + * Some sugar around: 'this.hints.push(new Hint(...));', but you can also + * pass in an array of Hints or the parameters to create a hint + */ + CliRequisition.prototype._addHint = function(status, message, start, end) { + if (status == null) { + return; + } + if (status instanceof Hint) { + this.hints.push(status); + } + else if (Array.isArray(status)) { + this.hints.push.apply(this.hints, status); + } + else { + this.hints.push(new Hint(status, message, start, end)); + } + }; + + /** + * Work out which arguments are applicable to which parameters. + *

This takes #_command.params and #_unparsedArgs and creates a map of + * param names to 'assignment' objects, which have the following properties: + *

    + *
  • param - The matching parameter. + *
  • index - Zero based index into where the match came from on the input + *
  • value - The matching input + *
+ */ + CliRequisition.prototype._assign = function(args) { + if (args.length === 0) { + this.setDefaultValues(); + return; + } + + // Create an error if the command does not take parameters, but we have + // been given them ... + if (this.assignmentCount === 0) { + // TODO: previously we were doing some extra work to avoid this if + // we determined that we had args that were all whitespace, but + // probably given our tighter tokenize() this won't be an issue? + this._addHint(Status.INVALID, + this.command.name + ' does not take any parameters', + Argument.merge(args)); + return; + } + + // Special case: if there is only 1 parameter, and that's of type + // text we put all the params into the first param + if (this.assignmentCount == 1) { + var assignment = this.getAssignment(0); + if (assignment.param.type.name === 'text') { + assignment.setArgument(Argument.merge(args)); + return; + } + } + + var assignments = this.cloneAssignments(); + var names = this.getParameterNames(); + + // Extract all the named parameters + var used = []; + assignments.forEach(function(assignment) { + var namedArgText = '--' + assignment.name; + + var i = 0; + while (true) { + var arg = args[i]; + if (namedArgText !== arg.text) { + i++; + if (i >= args.length) { + break; + } + continue; + } + + // boolean parameters don't have values, default to false + if (assignment.param.type.name === 'boolean') { + assignment.setValue(true); + } + else { + if (i + 1 < args.length) { + // Missing value portion of this named param + this._addHint(Status.INCOMPLETE, + 'Missing value for: ' + namedArgText, + args[i]); + } + else { + args.splice(i + 1, 1); + assignment.setArgument(args[i + 1]); + } + } + + util.arrayRemove(names, assignment.name); + args.splice(i, 1); + // We don't need to i++ if we splice + } + }, this); + + // What's left are positional parameters assign in order + names.forEach(function(name) { + var assignment = this.getAssignment(name); + if (args.length === 0) { + // No more values + assignment.setValue(undefined); // i.e. default + } + else { + var arg = args[0]; + args.splice(0, 1); + assignment.setArgument(arg); + } + }, this); + + if (args.length > 0) { + var remaining = Argument.merge(args); + this._addHint(Status.INVALID, + 'Input \'' + remaining.text + '\' makes no sense.', + remaining); + } + }; + +})(); +exports.CliRequisition = CliRequisition; + +/** + * Split up the input taking into account ' and " + */ +function _tokenize(typed) { + var OUTSIDE = 1; // The last character was whitespace + var IN_SIMPLE = 2; // The last character was part of a parameter + var IN_SINGLE_Q = 3; // We're inside a single quote: ' + var IN_DOUBLE_Q = 4; // We're inside double quotes: " + + var mode = OUTSIDE; + + // First we un-escape. This list was taken from: + // https://developer.mozilla.org/en/Core_JavaScript_1.5_Guide/Core_Language_Features#Unicode + // We are generally converting to their real values except for \', \" + // and '\ ' which we are converting to unicode private characters so we + // can distinguish them from ', " and ' ', which have special meaning. + // They need swapping back post-split - see unescape() + typed = typed + .replace(/\\\\/g, '\\') + .replace(/\\b/g, '\b') + .replace(/\\f/g, '\f') + .replace(/\\n/g, '\n') + .replace(/\\r/g, '\r') + .replace(/\\t/g, '\t') + .replace(/\\v/g, '\v') + .replace(/\\n/g, '\n') + .replace(/\\r/g, '\r') + .replace(/\\ /g, '\uF000') + .replace(/\\'/g, '\uF001') + .replace(/\\"/g, '\uF002'); + + function unescape(str) { + return str + .replace(/\uF000/g, ' ') + .replace(/\uF001/g, '\'') + .replace(/\uF002/g, '"'); + } + + var i = 0; + var start = 0; // Where did this section start? + var priorSpace = ''; + var args = []; + + while (true) { + if (i >= typed.length) { + // There is no more - tidy up + if (mode !== OUTSIDE) { + var str = unescape(typed.substring(start, i)); + args.push(new Argument(str, start, i, priorSpace)); + } + break; + } + + var c = typed[i]; + switch (mode) { + case OUTSIDE: + if (c === '\'') { + priorSpace = typed.substring(start, i); + mode = IN_SINGLE_Q; + start = i + 1; + } + else if (c === '"') { + priorSpace = typed.substring(start, i); + mode = IN_DOUBLE_Q; + start = i + 1; + } + else if (/ /.test(c)) { + // Still whitespace, do nothing + } + else { + priorSpace = typed.substring(start, i); + mode = IN_SIMPLE; + start = i; + } + break; + + case IN_SIMPLE: + // There is an edge case of xx'xx which we are assuming to be + // a single parameter (and same with ") + if (c === ' ') { + var str = unescape(typed.substring(start, i)); + args.push(new Argument(str, start, i, priorSpace)); + mode = OUTSIDE; + start = i; + priorSpace = ''; + } + break; + + case IN_SINGLE_Q: + if (c === '\'') { + var str = unescape(typed.substring(start, i)); + args.push(new Argument(str, start, i, priorSpace)); + mode = OUTSIDE; + start = i + 1; + priorSpace = ''; + } + break; + + case IN_DOUBLE_Q: + if (c === '"') { + var str = unescape(typed.substring(start, i)); + args.push(new Argument(str, start, i, priorSpace)); + mode = OUTSIDE; + start = i + 1; + priorSpace = ''; + } + break; + } + + i++; + } + + return args; +} +exports._tokenize = _tokenize; + +/** + * Looks in the canon for a command extension that matches what has been + * typed at the command line. + */ +function _split(args) { + if (args.length === 0) { + return undefined; + } + + var argsUsed = 0; + var lookup = ''; + var command; + + while (true) { + argsUsed++; + lookup += args.map(function(arg) { + return arg.text; + }).slice(0, argsUsed).join(' '); + command = canon.getCommand(lookup); + + if (!command) { + // Not found. break with command == null + return undefined; + } + + /* + // Previously we needed a way to hide commands depending context. + // We have not resurrected that feature yet. + if (!keyboard.flagsMatch(command.predicates, this.flags)) { + // If the predicates say 'no match' then go LA LA LA + command = null; + break; + } + */ + + if (command.exec) { + // Valid command, break with command valid + break; + } + + // command, but no exec - this must be a sub-command + lookup += ' '; + } + + // Remove the used args + for (var i = 0; i < argsUsed; i++) { + args.shift(); + } + + return command; +} +exports._split = _split; + + +/** + * Provide some documentation for a command. + * TODO: this should return a hint + */ +function documentCommand(command) { + var docs = []; + docs.push('

' + command.name + '

'); + docs.push('

Summary

'); + docs.push('

' + command.description + '

'); + + if (command.manual) { + docs.push('

Description

'); + docs.push('

' + command.description + '

'); + } + + if (command.params && command.params.length > 0) { + docs.push('

Synopsis

'); + docs.push('
');
+        docs.push(command.name);
+        var optionalParamCount = 0;
+        command.params.forEach(function(param) {
+            if (param.defaultValue === undefined) {
+                docs.push(' ');
+                docs.push(param.name);
+                docs.push('');
+            }
+            else if (param.defaultValue === null) {
+                docs.push(' [');
+                docs.push(param.name);
+                docs.push(']');
+            }
+            else {
+                optionalParamCount++;
+            }
+        }, this);
+        if (optionalParamCount > 3) {
+            docs.push(' [options]');
+        } else if (optionalParamCount > 0) {
+            command.params.forEach(function(param) {
+                if (param.defaultValue) {
+                    docs.push(' [--');
+                    docs.push(param.name);
+                    if (param.type.name === 'boolean') {
+                        docs.push('');
+                    }
+                    else {
+                        docs.push(' ' + param.type.name);
+                    }
+                    docs.push(']');
+                }
+            }, this);
+        }
+        docs.push('
'); + + docs.push('

Parameters

'); + command.params.forEach(function(param) { + docs.push('

' + param.name + '

'); + docs.push('

' + param.description + '

'); + if (param.type.defaultValue) { + docs.push('

Default: ' + param.type.defaultValue + '

'); + } + }, this); + } + + return docs.join(''); +}; +exports.documentCommand = documentCommand; + + + + +}); diff --git a/plugins/cockpit/index.js b/plugins/cockpit/index.js new file mode 100644 index 00000000..beacc28f --- /dev/null +++ b/plugins/cockpit/index.js @@ -0,0 +1,59 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Skywriter. + * + * The Initial Developer of the Original Code is + * Mozilla. + * Portions created by the Initial Developer are Copyright (C) 2009 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Kevin Dangoor (kdangoor@mozilla.com) + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +define(function(require, exports, module) { + +exports.startup = function(data, reason) { + + window.testCli = require('cockpit/test/testCli'); + + var plain = require('cockpit/ui/plain'); + plain.startup(data, reason); + +}; + +/* +exports.shutdown(data, reason) { + deps.forEach(function(dep) { + var module = require(dep); + if (typeof module.shutdown === "function") { + module.shutdown(data, reason); + } + }); +}; +*/ +}); diff --git a/plugins/cockpit/test/assert.js b/plugins/cockpit/test/assert.js new file mode 100644 index 00000000..d0d1b93a --- /dev/null +++ b/plugins/cockpit/test/assert.js @@ -0,0 +1,317 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Skywriter. + * + * The Initial Developer of the Original Code is + * Mozilla. + * Portions created by the Initial Developer are Copyright (C) 2009 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Joe Walker (jwalker@mozilla.com) + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +define(function(require, exports, module) { + +var test = { + + success: function(message) { + console.log(message); + }, + + fail: function(message) { + test._recordThrow("fail", arguments); + }, + + assertTrue: function(value) { + if (!value) { + test._recordThrow("assertTrue", arguments); + } + }, + + verifyTrue: function(value) { + if (!value) { + test._recordTrace("verifyTrue", arguments); + } + }, + + assertFalse: function(value) { + if (value) { + test._recordThrow("assertFalse", arguments); + } + }, + + verifyFalse: function(value) { + if (value) { + test._recordTrace("verifyFalse", arguments); + } + }, + + assertNull: function(value) { + if (value !== null) { + test._recordThrow("assertNull", arguments); + } + }, + + verifyNull: function(value) { + if (value !== null) { + test._recordTrace("verifyNull", arguments); + } + }, + + assertNotNull: function(value) { + if (value === null) { + test._recordThrow("assertNotNull", arguments); + } + }, + + verifyNotNull: function(value) { + if (value === null) { + test._recordTrace("verifyNotNull", arguments); + } + }, + + assertUndefined: function(value) { + if (value !== undefined) { + test._recordThrow("assertUndefined", arguments); + } + }, + + verifyUndefined: function(value) { + if (value !== undefined) { + test._recordTrace("verifyUndefined", arguments); + } + }, + + assertNotUndefined: function(value) { + if (value === undefined) { + test._recordThrow("assertNotUndefined", arguments); + } + }, + + verifyNotUndefined: function(value) { + if (value === undefined) { + test._recordTrace("verifyNotUndefined", arguments); + } + }, + + assertNaN: function(value) { + if (!isNaN(value)) { + test._recordThrow("assertNaN", arguments); + } + }, + + verifyNaN: function(value) { + if (!isNaN(value)) { + test._recordTrace("verifyNaN", arguments); + } + }, + + assertNotNaN: function(value) { + if (isNaN(value)) { + test._recordThrow("assertNotNaN", arguments); + } + }, + + verifyNotNaN: function(value) { + if (isNaN(value)) { + test._recordTrace("verifyNotNaN", arguments); + } + }, + + assertEqual: function(expected, actual) { + if (!test._isEqual(expected, actual)) { + test._recordThrow("assertEqual", arguments); + } + }, + + verifyEqual: function(expected, actual) { + if (!test._isEqual(expected, actual)) { + test._recordTrace("verifyEqual", arguments); + } + }, + + assertNotEqual: function(expected, actual) { + if (test._isEqual(expected, actual)) { + test._recordThrow("assertNotEqual", arguments); + } + }, + + verifyNotEqual: function(expected, actual) { + if (test._isEqual(expected, actual)) { + test._recordTrace("verifyNotEqual", arguments); + } + }, + + assertSame: function(expected, actual) { + if (expected !== actual) { + test._recordThrow("assertSame", arguments); + } + }, + + verifySame: function(expected, actual) { + if (expected !== actual) { + test._recordTrace("verifySame", arguments); + } + }, + + assertNotSame: function(expected, actual) { + if (expected !== actual) { + test._recordThrow("assertNotSame", arguments); + } + }, + + verifyNotSame: function(expected, actual) { + if (expected !== actual) { + test._recordTrace("verifyNotSame", arguments); + } + }, + + _recordTrace: function() { + test._record.apply(this, arguments); + console.trace(); + }, + + _recordThrow: function() { + test._record.apply(this, arguments); + throw new Error(); + }, + + _record: function() { + console.error(arguments); + var message = arguments[0] + "("; + var data = arguments[1]; + if (typeof data == "string") { + message += data; + } + else { + for (var i = 0; i < data.length; i++) { + if (i != 0){message += ", ";} + message += data[i]; + } + } + message += ")"; + console.log(message); + }, + + _isEqual: function(expected, actual, depth) { + if (!depth){depth = 0;} + // Rather than failing we assume that it works! + if (depth > 10) { + return true; + } + + if (expected == null) { + if (actual != null) { + console.log("expected: null, actual non-null: ", actual); + return false; + } + return true; + } + + if (typeof(expected) == "number" && isNaN(expected)) { + if (!(typeof(actual) == "number" && isNaN(actual))) { + console.log("expected: NaN, actual non-NaN: ", actual); + return false; + } + return true; + } + + if (actual == null) { + if (expected != null) { + console.log("actual: null, expected non-null: ", expected); + return false; + } + return true; // we wont get here of course ... + } + + if (typeof expected == "object") { + if (!(typeof actual == "object")) { + console.log("expected object, actual not an object"); + return false; + } + + var actualLength = 0; + for (var prop in actual) { + if (typeof actual[prop] != "function" || + typeof expected[prop] != "function") { + var nest = test._isEqual(actual[prop], expected[prop], depth + 1); + if (typeof nest != "boolean" || !nest) { + console.log("element '" + prop + "' does not match: " + nest); + return false; + } + } + actualLength++; + } + + // need to check length too + var expectedLength = 0; + for (prop in expected) expectedLength++; + if (actualLength != expectedLength) { + console.log("expected object size = " + expectedLength + + ", actual object size = " + actualLength); + return false; + } + return true; + } + + if (actual != expected) { + console.log("expected = " + expected + " (type=" + typeof expected + "), " + + "actual = " + actual + " (type=" + typeof actual + ")"); + return false; + } + + if (expected instanceof Array) { + if (!(actual instanceof Array)) { + console.log("expected array, actual not an array"); + return false; + } + if (actual.length != expected.length) { + console.log("expected array length = " + expected.length + + ", actual array length = " + actual.length); + return false; + } + for (var i = 0; i < actual.length; i++) { + var inner = test._isEqual(actual[i], expected[i], depth + 1); + if (typeof inner != "boolean" || !inner) { + console.log("element " + i + " does not match: " + inner); + return false; + } + } + + return true; + } + + return true; + } +}; + + +exports.test = test; + + +}); diff --git a/plugins/cockpit/test/testCli.js b/plugins/cockpit/test/testCli.js new file mode 100644 index 00000000..bace956e --- /dev/null +++ b/plugins/cockpit/test/testCli.js @@ -0,0 +1,279 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Skywriter. + * + * The Initial Developer of the Original Code is + * Mozilla. + * Portions created by the Initial Developer are Copyright (C) 2009 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Joe Walker (jwalker@mozilla.com) + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +define(function(require, exports, module) { + + +var test = require('cockpit/test/assert').test; +var Status = require('pilot/types').Status; +var settings = require('pilot/settings').settings; +var tokenize = require('cockpit/cli')._tokenize; +var split = require('cockpit/cli')._split; +var CliRequisition = require('cockpit/cli').CliRequisition; + + +exports.testAll = function() { + exports.testTokenize(); + exports.testSplit(); + exports.testCli(); + return "testAll Completed"; +}; + +exports.testTokenize = function() { + var args = tokenize(''); + test.verifyEqual(0, args.length); + + args = tokenize('s'); + test.verifyEqual(1, args.length); + test.verifyEqual('s', args[0].text); + test.verifyEqual(0, args[0].start); + test.verifyEqual(1, args[0].end); + test.verifyEqual('', args[0].priorSpace); + + args = tokenize('s s'); + test.verifyEqual(2, args.length); + test.verifyEqual('s', args[0].text); + test.verifyEqual(0, args[0].start); + test.verifyEqual(1, args[0].end); + test.verifyEqual('', args[0].priorSpace); + test.verifyEqual('s', args[1].text); + test.verifyEqual(2, args[1].start); + test.verifyEqual(3, args[1].end); + test.verifyEqual(' ', args[1].priorSpace); + + args = tokenize(' 1234 \'12 34\''); + test.verifyEqual(2, args.length); + test.verifyEqual('1234', args[0].text); + test.verifyEqual(1, args[0].start); + test.verifyEqual(5, args[0].end); + test.verifyEqual(' ', args[0].priorSpace); + test.verifyEqual('12 34', args[1].text); + test.verifyEqual(8, args[1].start); + test.verifyEqual(13, args[1].end); + test.verifyEqual(' ', args[1].priorSpace); + + args = tokenize('12\'34 "12 34" \\'); // 12'34 "12 34" \ + test.verifyEqual(3, args.length); + test.verifyEqual('12\'34', args[0].text); + test.verifyEqual(0, args[0].start); + test.verifyEqual(5, args[0].end); + test.verifyEqual('', args[0].priorSpace); + test.verifyEqual('12 34', args[1].text); + test.verifyEqual(7, args[1].start); + test.verifyEqual(12, args[1].end); + test.verifyEqual(' ', args[1].priorSpace); + test.verifyEqual('\\', args[2].text); + test.verifyEqual(14, args[2].start); + test.verifyEqual(15, args[2].end); + test.verifyEqual(' ', args[2].priorSpace); + + args = tokenize('a\\ b \\t\\n\\r \\\'x\\\" \'d'); // a_b \t\n\r \'x\" 'd + test.verifyEqual(4, args.length); + test.verifyEqual('a b', args[0].text); + test.verifyEqual(0, args[0].start); + test.verifyEqual(3, args[0].end); + test.verifyEqual('', args[0].priorSpace); + test.verifyEqual('\t\n\r', args[1].text); + test.verifyEqual(4, args[1].start); + test.verifyEqual(7, args[1].end); + test.verifyEqual(' ', args[1].priorSpace); + test.verifyEqual('\'x"', args[2].text); + test.verifyEqual(8, args[2].start); + test.verifyEqual(11, args[2].end); + test.verifyEqual(' ', args[2].priorSpace); + test.verifyEqual('d', args[3].text); + test.verifyEqual(13, args[3].start); + test.verifyEqual(14, args[3].end); + test.verifyEqual(' ', args[3].priorSpace); + + return "testTokenize Completed"; +}; + +exports.testSplit = function() { + var args = tokenize('s'); + var command = split(args); + test.verifyEqual(1, args.length); + test.verifyEqual('s', args[0].text); + test.verifyUndefined(command); + + var args = tokenize('set'); + var command = split(args); + test.verifyEqual([], args); + test.verifyEqual('set', command.name); + + var args = tokenize('set a b'); + var command = split(args); + test.verifyEqual('set', command.name); + test.verifyEqual(2, args.length); + test.verifyEqual('a', args[0].text); + test.verifyEqual('b', args[1].text); + + // TODO: add tests for sub commands + return "testSplit Completed"; +}; + +exports.testCli = function() { + var hints; + var hint0; + var settingAssignment; + var valueAssignment; + var cli = new CliRequisition(); + + function update(input) { + cli.update(input); + hints = cli.getHints(); + hint0 = (hints.length !== 0) ? hints[0] : undefined; + if (cli.command && cli.command.name === 'set') { + settingAssignment = cli.getAssignment('setting'); + valueAssignment = cli.getAssignment('value'); + } + else { + settingAssignment = undefined; + valueAssignment = undefined; + } + } + + var historyLengthSetting = settings.getSetting('historyLength'); + + update({ typed: '', cursor: { start: 0, end: 0 } }); + test.verifyEqual(1, hints.length); + test.verifyEqual(Status.INCOMPLETE, hint0.status); + test.verifyEqual(0, hint0.start); + test.verifyEqual(0, hint0.end); + test.verifyNull(cli.command); + + update({ typed: 's', cursor: { start: 1, end: 1 } }); + test.verifyEqual(1, hints.length); + test.verifyEqual(Status.INCOMPLETE, hint0.status); + test.verifyNotEqual(-1, hint0.message.indexOf('possibilities')); + test.verifyEqual(0, hint0.start); + test.verifyEqual(1, hint0.end); + test.verifyTrue(hint0.predictions.length > 0); + // This is slightly fragile because it depends on the configuration + test.verifyTrue(hint0.predictions.length < 20); + test.verifyNotEqual(-1, hint0.predictions.indexOf('set')); + test.verifyNull(cli.command); + + update({ typed: 'set', cursor: { start: 3, end: 3 } }); + test.verifyEqual(1, hints.length); + test.verifyEqual(Status.VALID, hint0.status); + test.verifyEqual(0, hint0.start); + test.verifyEqual(3, hint0.end); + test.verifyEqual('set', cli.command.name); + + update({ typed: 'set ', cursor: { start: 4, end: 4 } }); + test.verifyEqual(1, hints.length); + test.verifyEqual(Status.VALID, hint0.status); + test.verifyEqual(0, hint0.start); + // Technically the command ends at 3, but we're returning 4 currently. + // This is caused by us using the whole input to determine the length. + // Maybe one day we should fix this? + //test.verifyEqual(3, hint0.end); + test.verifyEqual('set', cli.command.name); + + update({ typed: 'set h', cursor: { start: 5, end: 5 } }); + test.verifyEqual(1, hints.length); + test.verifyEqual(Status.INCOMPLETE, hint0.status); + test.verifyTrue(hint0.predictions.length > 0); + test.verifyEqual(4, hint0.start); + test.verifyEqual(5, hint0.end); + test.verifyNotEqual(-1, hint0.predictions.indexOf('historyLength')); + test.verifyEqual('set', cli.command.name); + test.verifyEqual('h', settingAssignment.arg.text); + test.verifyEqual(undefined, settingAssignment.value); + + update({ typed: 'set historyLengt', cursor: { start: 16, end: 16 } }); + test.verifyEqual(1, hints.length); + test.verifyEqual(Status.INCOMPLETE, hint0.status); + test.verifyEqual(1, hint0.predictions.length); + test.verifyEqual(4, hint0.start); + test.verifyEqual(16, hint0.end); + test.verifyEqual('historyLength', hint0.predictions[0]); + test.verifyEqual('set', cli.command.name); + test.verifyEqual('historyLengt', settingAssignment.arg.text); + test.verifyEqual(undefined, settingAssignment.value); + + update({ typed: 'set historyLengt', cursor: { start: 1, end: 1 } }); + test.verifyEqual(1, hints.length); + test.verifyEqual(Status.INVALID, hint0.status); + test.verifyEqual(4, hint0.start); + test.verifyEqual(16, hint0.end); + test.verifyEqual(1, hint0.predictions.length); + test.verifyEqual('historyLength', hint0.predictions[0]); + test.verifyEqual('set', cli.command.name); + test.verifyEqual('historyLengt', settingAssignment.arg.text); + test.verifyEqual(undefined, settingAssignment.value); + + update({ typed: 'set historyLengt ', cursor: { start: 17, end: 17 } }); + test.verifyEqual(1, hints.length); + test.verifyEqual(Status.INVALID, hint0.status); + test.verifyEqual(4, hint0.start); + test.verifyEqual(16, hint0.end); + test.verifyEqual(1, hint0.predictions.length); + test.verifyEqual('historyLength', hint0.predictions[0]); + test.verifyEqual('set', cli.command.name); + test.verifyEqual('historyLengt', settingAssignment.arg.text); + test.verifyEqual(undefined, settingAssignment.value); + + update({ typed: 'set historyLength', cursor: { start: 17, end: 17 } }); + test.verifyEqual(0, hints.length); + test.verifyEqual('set', cli.command.name); + test.verifyEqual('historyLength', settingAssignment.arg.text); + test.verifyEqual(historyLengthSetting, settingAssignment.value); + + update({ typed: 'set historyLength ', cursor: { start: 18, end: 18 } }); + test.verifyEqual(0, hints.length); + test.verifyEqual('set', cli.command.name); + test.verifyEqual('historyLength', settingAssignment.arg.text); + test.verifyEqual(historyLengthSetting, settingAssignment.value); + + update({ typed: 'set historyLength 6', cursor: { start: 19, end: 19 } }); + test.verifyEqual(0, hints.length); + test.verifyEqual('set', cli.command.name); + test.verifyEqual('historyLength', settingAssignment.arg.text); + test.verifyEqual(historyLengthSetting, settingAssignment.value); + test.verifyEqual('6', valueAssignment.arg.text); + test.verifyEqual(6, valueAssignment.value); + test.verifyEqual('number', typeof valueAssignment.value); + + // TODO: Add test to see that a command without mandatory param causes INVALID + + return "testCli Completed"; +}; + + +}); diff --git a/lib/ace/plugin_manager.js b/plugins/cockpit/test/testNothing.js similarity index 84% rename from lib/ace/plugin_manager.js rename to plugins/cockpit/test/testNothing.js index 2bd5abc6..567b575a 100644 --- a/lib/ace/plugin_manager.js +++ b/plugins/cockpit/test/testNothing.js @@ -11,15 +11,15 @@ * for the specific language governing rights and limitations under the * License. * - * The Original Code is Ajax.org Code Editor (ACE). + * The Original Code is Skywriter. * * The Initial Developer of the Original Code is - * Ajax.org Services B.V. - * Portions created by the Initial Developer are Copyright (C) 2010 + * Mozilla. + * Portions created by the Initial Developer are Copyright (C) 2009 * the Initial Developer. All Rights Reserved. * * Contributor(s): - * Fabian Jakobs + * Joe Walker (jwalker@mozilla.com) * * Alternatively, the contents of this file may be used under the terms of * either the GNU General Public License Version 2 or later (the "GPL"), or @@ -37,13 +37,4 @@ define(function(require, exports, module) { -var PluginManager = { - commands : {}, - - registerCommand : function(name, command) { - this.commands[name] = command; - } -}; - -return PluginManager; -}); \ No newline at end of file +}); diff --git a/plugins/cockpit/ui/plain.css b/plugins/cockpit/ui/plain.css new file mode 100644 index 00000000..85c55ff1 --- /dev/null +++ b/plugins/cockpit/ui/plain.css @@ -0,0 +1,2 @@ + +#cockpit { color: red; } diff --git a/plugins/cockpit/ui/plain.js b/plugins/cockpit/ui/plain.js new file mode 100644 index 00000000..445a7864 --- /dev/null +++ b/plugins/cockpit/ui/plain.js @@ -0,0 +1,98 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Skywriter. + * + * The Initial Developer of the Original Code is + * Mozilla. + * Portions created by the Initial Developer are Copyright (C) 2009 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Joe Walker (jwalker@mozilla.com) + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +define(function(require, exports, module) { + +var editorCss = require("text!cockpit/ui/plain.css"); +var dom = require("pilot/dom").dom; +dom.importCssString(editorCss); + +var CliRequisition = require('cockpit/cli').CliRequisition; +var keyutil = require('pilot/keyboard/keyutil'); + +exports.startup = function(data, reason) { + // TODO: we should have a better way to specify command lines??? + this.input = document.getElementById('cockpit'); + if (!this.input) { + console.log('No element with an id of cockpit. Bailing on plain cli'); + return; + } + + var cli = new CliRequisition(); + + /* + // All this does is to kill TABs normal use. I wonder if we can train + // people to use right arrow? Probably not? but ... + keyutil.addKeyDownListener(input, function(ev) { + // env.commandLine = this; + // var handled = keyboardManager.processKeyEvent(ev, this, { + // isCommandLine: true, isKeyUp: false + // }); + if (ev.keyCode === keyutil.KeyHelper.KEY.TAB) { + return true; + } + //return handled; + }.bind(this)); + */ + + this.input.addEventListener('keyup', function(ev) { + /* + var handled = keyboardManager.processKeyEvent(ev, this, { + isCommandLine: true, isKeyUp: true + }); + */ + + if (ev.keyCode === keyutil.KeyHelper.KEY.RETURN) { + cli.exec(); + this.input.value = ''; + } else { + cli.update({ + typed: this.input.value, + cursor: { + start: this.input.selectionStart, + end: this.input.selectionEnd + } + }); + console.log(JSON.stringify(cli.getHints())); + } + + // return handled; + }.bind(this), true); +}; + + +}); diff --git a/plugins/pilot/canon.js b/plugins/pilot/canon.js new file mode 100644 index 00000000..5bf4e79a --- /dev/null +++ b/plugins/pilot/canon.js @@ -0,0 +1,325 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Skywriter. + * + * The Initial Developer of the Original Code is + * Mozilla. + * Portions created by the Initial Developer are Copyright (C) 2009 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Joe Walker (jwalker@mozilla.com) + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +define(function(require, exports, module) { + +var console = require('pilot/console'); +var Trace = require('pilot/stacktrace').Trace; +var oop = require('pilot/oop').oop; +var EventEmitter = require('pilot/event_emitter').EventEmitter; +var catalog = require('pilot/catalog'); +var Status = require('pilot/types').Status; +var types = require('pilot/types'); + +/* +// TODO: this doesn't belong here - or maybe anywhere? +var dimensionsChangedExtensionSpec = { + name: 'dimensionsChanged', + description: 'A dimensionsChanged is a way to be notified of ' + + 'changes to the dimension of Skywriter' +}; +exports.startup = function(data, reason) { + catalog.addExtensionSpec(commandExtensionSpec); +}; +exports.shutdown = function(data, reason) { + catalog.removeExtensionSpec(commandExtensionSpec); +}; +*/ + +var commandExtensionSpec = { + name: 'command', + description: 'A command is a bit of functionality with optional ' + + 'typed arguments which can do something small like moving ' + + 'the cursor around the screen, or large like cloning a ' + + 'project from VCS.', + indexOn: 'name' +}; + +exports.startup = function(data, reason) { + // TODO: this is probably all kinds of evil, but we need something working + catalog.addExtensionSpec(commandExtensionSpec); +}; + +exports.shutdown = function(data, reason) { + catalog.removeExtensionSpec(commandExtensionSpec); +}; + +/** + * Manage a list of commands in the current canon + */ + +/** + * A Command is a discrete action optionally with a set of ways to customize + * how it happens. This is here for documentation purposes. + * TODO: Document better + */ +var thingCommand = { + name: 'thing', + description: 'thing is an example command', + params: [{ + name: 'param1', + description: 'an example parameter', + type: 'text', + defaultValue: null + }], + exec: function(env, args, request) { + thing(); + } +}; + +var commands = {}; + +/** + * This registration method isn't like other Ace registration methods because + * it doesn't return a decorated command because there is no functional + * decoration to be done. + * TODO: Are we sure that in the future there will be no such decoration? + */ +exports.addCommand = function(command) { + if (!command.name) { + throw new Error('All registered commands must have a name'); + } + if (command.params == null) { + command.params = []; + } + if (!Array.isArray(command.params)) { + throw new Error('command.params must be an array in ' + command.name); + } + // Replace the type + command.params.forEach(function(param) { + if (!param.name) { + throw new Error('In ' + command.name + ': all params must have a name'); + } + var lookup = param.type; + param.type = types.getType(lookup); + if (param.type == null) { + throw new Error('In ' + command.name + '/' + param.name + + ': can\'t find type for: ' + JSON.stringify(lookup)); + } + }, this); + commands[command.name] = command; +}; + +exports.removeCommand = function(command) { + if (typeof command === 'string') { + delete commands[command]; + } + else { + delete commands[command.name]; + } +}; + +exports.getCommand = function(name) { + return commands[name]; +}; + +exports.getCommandNames = function() { + return Object.keys(commands); +}; + +/** + * Entry point for keyboard accelerators or anything else that knows + * everything it needs to about the command params + * @param command Either a command, or the name of one + */ +exports.exec = function(command, env, args) { + if (typeof command === 'string') { + command = commands[command]; + } + if (!command) { + // TODO: Should we complain more than returning false? + return false; + } + + // TODO: Ugg. really? + env.selection = env.editor.getSelection(); + var request = new Request(); + command.exec(env, args || {}, request); + return true; +}; + +/** + * We publish a 'addedRequestOutput' event whenever new command begins output + * TODO: make this more obvious + */ +oop.implement(exports, EventEmitter); + + +/** + * Current requirements are around displaying the command line, and provision + * of a 'history' command and cursor up|down navigation of history. + *

Future requirements could include: + *

    + *
  • Multiple command lines + *
  • The ability to recall key presses (i.e. requests with no output) which + * will likely be needed for macro recording or similar + *
  • The ability to store the command history either on the server or in the + * browser local storage. + *
+ *

The execute() command doesn't really live here, except as part of that + * last future requirement, and because it doesn't really have anywhere else to + * live. + */ + +/** + * The array of requests that wish to announce their presence + */ +exports.requests = []; + +/** + * How many requests do we store? + */ +var maxRequestLength = 100; + +/** + * Called by Request instances when some output (or a cell to async() happens) + */ +exports.addRequestOutput = function(request) { + exports.requests.push(request); + // This could probably be optimized with some maths, but 99.99% of the + // time we will only be off by one, and I'm feeling lazy. + while (exports.requests.length > maxRequestLength) { + exports.requests.shiftObject(); + } + + exports._dispatchEvent('addedRequestOutput', { request: request }); +}; + +/** + * To create an invocation, you need to do something like this (all the ctor + * args are optional): + *

+ * var request = new Request({
+ *     command: command,
+ *     commandExt: commandExt,
+ *     args: args,
+ *     typed: typed
+ * });
+ * 
+ * @constructor + */ +function Request(options) { + options = options || {}; + + // Will be used in the keyboard case and the cli case + this.command = options.command; + this.commandExt = options.commandExt; + + // Will be used only in the cli case + this.args = options.args; + this.typed = options.typed; + + // Have we been initialized? + this._begunOutput = false; + + this.start = new Date(); + this.end = null; + this.completed = false; + this.error = false; +}; + +oop.implement(Request.prototype, EventEmitter); + +/** + * Lazy init to register with the history should only be done on output. + * init() is expensive, and won't be used in the majority of cases + */ +Request.prototype._beginOutput = function() { + this._begunOutput = true; + this.outputs = []; + + exports.addRequestOutput(this); +}; + +/** + * Sugar for: + *
request.error = true; request.done(output);
+ */ +Request.prototype.doneWithError = function(content) { + this.error = true; + this.done(content); +}; + +/** + * Declares that this function will not be automatically done when + * the command exits + */ +Request.prototype.async = function() { + if (!this._begunOutput) { + this._beginOutput(); + } +}; + +/** + * Complete the currently executing command with successful output. + * @param output Either DOM node, an SproutCore element or something that + * can be used in the content of a DIV to create a DOM node. + */ +Request.prototype.output = function(content) { + if (!this._begunOutput) { + this._beginOutput(); + } + + if (typeof content !== 'string' && !(content instanceof Node)) { + content = content.toString(); + } + + this.outputs.push(content); + this._dispatchEvent('changed', {}); + + return this; +}; + +/** + * All commands that do output must call this to indicate that the command + * has finished execution. + */ +Request.prototype.done = function(content) { + this.completed = true; + this.end = new Date(); + this.duration = this.end.getTime() - this.start.getTime(); + + if (content) { + this.output(content); + } + + this._dispatchEvent('changed', {}); +}; +exports.Request = Request; + + +}); diff --git a/plugins/pilot/catalog.js b/plugins/pilot/catalog.js new file mode 100644 index 00000000..5acb69e5 --- /dev/null +++ b/plugins/pilot/catalog.js @@ -0,0 +1,65 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Skywriter. + * + * The Initial Developer of the Original Code is + * Mozilla. + * Portions created by the Initial Developer are Copyright (C) 2009 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Julian Viereck (jviereck@mozilla.com) + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +define(function(require, exports, module) { + + +var extensionSpecs = {}; + +exports.addExtensionSpec = function(extensionSpec) { + extensionSpecs[extensionSpec.name] = extensionSpec; +}; + +exports.removeExtensionSpec = function(extensionSpec) { + if (typeof extensionSpec === "string") { + delete extensionSpecs[extensionSpec]; + } + else { + delete extensionSpecs[extensionSpec.name]; + } +}; + +exports.getExtensionSpec = function(name) { + return extensionSpecs[name]; +}; + +exports.getExtensionSpecs = function() { + return Object.keys(extensionSpecs); +}; + + +}); diff --git a/plugins/pilot/commands/settings.js b/plugins/pilot/commands/settings.js new file mode 100644 index 00000000..f2b6100b --- /dev/null +++ b/plugins/pilot/commands/settings.js @@ -0,0 +1,146 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Skywriter. + * + * The Initial Developer of the Original Code is + * Mozilla. + * Portions created by the Initial Developer are Copyright (C) 2009 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Skywriter Team (skywriter@mozilla.com) + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +define(function(require, exports, module) { + + +var setCommandSpec = { + name: 'set', + params: [ + { + name: 'setting', + type: 'setting', + description: 'The name of the setting to display or alter', + defaultValue: null + }, + { + name: 'value', + type: 'settingValue', + description: 'The new value for the chosen setting', + defaultValue: null + } + ], + description: 'define and show settings', + exec: function(env, args, request) { + var html; + if (!args.setting) { + // 'set' by itself lists all the settings + var settingsList = env.settings._list(); + html = ''; + // first sort the settingsList based on the key + settingsList.sort(function(a, b) { + if (a.key < b.key) { + return -1; + } else if (a.key == b.key) { + return 0; + } else { + return 1; + } + }); + var url = 'https://wiki.mozilla.org/Labs/Skywriter/Settings#' + + setting.key; + settingsList.forEach(function(setting) { + html += '' + + setting.key + + ' = ' + + setting.value + + '
'; + }); + } else { + var setting = env.settings.get(args.setting); + if (!setting) { + request.doneWithError('No setting with the name ' + + setting.name + '.'); + return; + } + + // set with only a setting, shows the value for that setting + if (args.value === undefined) { + html = '' + setting.name + ' = ' + + setting.get(); + } else { + // Actually change the setting + setting.set(args.value); + html = 'Setting: ' + setting.name + ' = ' + + setting.get(); + } + } + request.done(html); + } +}; + +var unsetCommandSpec = { + name: 'unset', + params: [ + { + name: 'setting', + type: 'setting', + description: 'The name of the setting to return to defaults' + } + ], + description: 'unset a setting entirely', + exec: function(env, args, request) { + var setting = env.settings.get(args.setting); + if (!setting) { + request.doneWithError('No setting with the name ' + + args.setting + '.'); + return; + } + + setting.reset(); + request.done('Reset ' + setting.name + ' to default: ' + + env.settings.get(args.setting)); + } +}; + +var canon = require('pilot/canon'); + +exports.startup = function(data, reason) { + canon.addCommand(setCommandSpec); + canon.addCommand(unsetCommandSpec); +}; + +exports.shutdown = function(data, reason) { + canon.removeCommand(setCommandSpec); + canon.removeCommand(unsetCommandSpec); +}; + + +}); diff --git a/plugins/pilot/console.js b/plugins/pilot/console.js new file mode 100644 index 00000000..b1fe5190 --- /dev/null +++ b/plugins/pilot/console.js @@ -0,0 +1,76 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Skywriter. + * + * The Initial Developer of the Original Code is + * Mozilla. + * Portions created by the Initial Developer are Copyright (C) 2009 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Joe Walker (jwalker@mozilla.com) + * Patrick Walton (pwalton@mozilla.com) + * Julian Viereck (jviereck@mozilla.com) + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ +define(function(require, exports, module) { + +/** + * This object represents a "safe console" object that forwards debugging + * messages appropriately without creating a dependency on Firebug in Firefox. + */ + +var noop = function() {}; + +// These are the functions that are available in Chrome 4/5, Safari 4 +// and Firefox 3.6. Don't add to this list without checking browser support +var NAMES = [ + "assert", "count", "debug", "dir", "dirxml", "error", "group", "groupEnd", + "info", "log", "profile", "profileEnd", "time", "timeEnd", "trace", "warn" +]; + +if (typeof(window) === 'undefined') { + // We're in a web worker. Forward to the main thread so the messages + // will show up. + NAMES.forEach(function(name) { + exports[name] = function() { + var args = Array.prototype.slice.call(arguments); + var msg = { op: 'log', method: name, args: args }; + postMessage(JSON.stringify(msg)); + }; + }); +} else { + // For each of the console functions, copy them if they exist, stub if not + NAMES.forEach(function(name) { + if (window.console && window.console[name]) { + exports[name] = window.console[name].bind(window.console); + } else { + exports[name] = noop; + } + }); +} + +}); diff --git a/lib/ace/lib/core.js b/plugins/pilot/core.js similarity index 98% rename from lib/ace/lib/core.js rename to plugins/pilot/core.js index 295be086..29aacf9e 100644 --- a/lib/ace/lib/core.js +++ b/plugins/pilot/core.js @@ -58,6 +58,6 @@ define(function(require, exports, module) { } }; - return core; + exports.core = core; -}); \ No newline at end of file +}); diff --git a/lib/ace/lib/dom.js b/plugins/pilot/dom.js similarity index 98% rename from lib/ace/lib/dom.js rename to plugins/pilot/dom.js index 86cd1e4b..f1021241 100644 --- a/lib/ace/lib/dom.js +++ b/plugins/pilot/dom.js @@ -37,7 +37,7 @@ define(function(require, exports, module) { -var lang = require("./lang"); + var lang = require("pilot/lang").lang; var dom = {}; @@ -137,5 +137,5 @@ var lang = require("./lang"); return noScrollbar-withScrollbar; }; - return dom; -}); \ No newline at end of file + exports.dom = dom; +}); diff --git a/lib/ace/lib/event.js b/plugins/pilot/event.js similarity index 96% rename from lib/ace/lib/event.js rename to plugins/pilot/event.js index 33176db2..c2f6be72 100644 --- a/lib/ace/lib/event.js +++ b/plugins/pilot/event.js @@ -37,8 +37,7 @@ define(function(require, exports, module) { - -var core = require("./core"); + var core = require("pilot/core").core; var event = {}; event.addListener = function(elem, type, callback) { @@ -49,7 +48,7 @@ var core = require("./core"); var wrapper = function() { callback(window.event); }; - callback.$$wrapper = wrapper; + callback._wrapper = wrapper; elem.attachEvent("on" + type, wrapper); } }; @@ -59,7 +58,7 @@ var core = require("./core"); return elem.removeEventListener(type, callback, false); } if (elem.detachEvent) { - elem.detachEvent("on" + type, callback.$$wrapper || callback); + elem.detachEvent("on" + type, callback._wrapper || callback); } }; @@ -111,10 +110,10 @@ var core = require("./core"); } // old IE else { - return Math.max(e.button - 1, 2) + return Math.max(e.button - 1, 2); } }; - + if (document.documentElement.setCapture) { event.capture = function(el, eventHandler, releaseCaptureHandler) { function onMouseMove(e) { @@ -202,7 +201,7 @@ var core = require("./core"); }, timeout || 600); } - if (event.getButton(e) != button + if (event.getButton(e) != button || Math.abs(e.clientX - startX) > 5 || Math.abs(e.clientY - startY) > 5) clicks = 0; @@ -238,5 +237,6 @@ var core = require("./core"); } }; - return event; -}); \ No newline at end of file + exports.event = event; + +}); diff --git a/lib/ace/event_emitter.js b/plugins/pilot/event_emitter.js similarity index 58% rename from lib/ace/event_emitter.js rename to plugins/pilot/event_emitter.js index ee73b3c1..c7ddf1cd 100644 --- a/lib/ace/event_emitter.js +++ b/plugins/pilot/event_emitter.js @@ -37,49 +37,50 @@ define(function(require, exports, module) { - var lang = require("./lib/lang"); +var lang = require('pilot/lang').lang; - var MEventEmitter = {} +var EventEmitter = {}; - MEventEmitter.$dispatchEvent = function(eventName, e) { - this.$eventRegistry = this.$eventRegistry || {}; +EventEmitter._dispatchEvent = function(eventName, e) { + this._eventRegistry = this._eventRegistry || {}; - var listeners = this.$eventRegistry[eventName]; - if (!listeners || !listeners.length) return; + var listeners = this._eventRegistry[eventName]; + if (!listeners || !listeners.length) return; - var e = e || {}; - e.type = eventName; + var e = e || {}; + e.type = eventName; - for (var i=0; i + // This is necessary for the French keyboard. On that keyboard, + // you have to hold down the shift key to access the number + // characters. + if (code > 47 && code < 58) { + allowShift = evt.altKey; + } + } + + if (ret) { + if (evt.altKey) { + modifiers += 'alt_'; + } + if (evt.ctrlKey) { + modifiers += 'ctrl_'; + } + if (evt.metaKey) { + modifiers += 'meta_'; + } + } else if (evt.ctrlKey || evt.metaKey) { + return false; + } + } + + // otherwise just go get the right key. + if (!ret) { + code = evt.which; + key = ret = String.fromCharCode(code); + lowercase = ret.toLowerCase(); + + if (evt.metaKey) { + modifiers = 'meta_'; + ret = lowercase; + + } else ret = null; + } + + if (evt.shiftKey && ret && allowShift) { + modifiers += 'shift_'; + } + + if (ret) { + ret = modifiers + ret; + } + + if (!dontIgnoreMeta && ret) { + ret = ret.replace(/ctrl_meta|meta/,'ctrl'); + } + + return [ret, key]; +}; + +// Note: Most of the following code is taken from SproutCore with a few changes. + +/** + * Firefox sends a few key events twice: the first time to the keydown event + * and then later again to the keypress event. To handle them correct, they + * should be processed only once. Due to this, we will skip these events + * in keydown and handle them then in keypress. + */ +exports.addKeyDownListener = function(element, boundFunction) { + + var handleBoundFunction = function(ev) { + var handled = boundFunction(ev); + // If the boundFunction returned true, then stop the event. + if (handled) { + util.stopEvent(ev); + } + return handled; + }; + + element.addEventListener('keydown', function(ev) { + if (util.isMozilla) { + // Check for function keys (like DELETE, TAB, LEFT, RIGHT...) + if (exports.KeyHelper.FUNCTION_KEYS[ev.keyCode]) { + return true; + // Check for command keys (like ctrl_c, ctrl_z...) + } else if ((ev.ctrlKey || ev.metaKey) && + exports.KeyHelper.PRINTABLE_KEYS[ev.keyCode]) { + return true; + } + } + + if (isFunctionOrNonPrintableKey(ev)) { + return handleBoundFunction(ev); + } + + return true; + }, false); + + element.addEventListener('keypress', function(ev) { + if (util.isMozilla) { + // If this is a function key, we have to use the keyCode. + if (exports.KeyHelper.FUNCTION_KEYS[ev.keyCode]) { + return handleBoundFunction(ev); + } else if ((ev.ctrlKey || ev.metaKey) && + exports.KeyHelper.PRINTABLE_KEYS_CHARCODE[ev.charCode]){ + // Check for command keys (like ctrl_c, ctrl_z...). + // For command keys have to convert the charCode to a keyCode + // as it has been sent from the keydown event to be in line + // with the other browsers implementations. + + // FF does not allow let you change the keyCode or charCode + // property. Store to a custom keyCode/charCode variable. + // The getCommandCodes() function takes care of these + // special variables. + ev._keyCode = exports.KeyHelper.PRINTABLE_KEYS_CHARCODE[ev.charCode]; + ev._charCode = 0; + return handleBoundFunction(ev); + } + } + + // normal processing: send keyDown for printable keys. + if (ev.charCode !== undefined && ev.charCode === 0) { + return true; + } + + return handleBoundFunction(ev); + }, false); +}; + +}); diff --git a/plugins/pilot/keyboard/tests/testKeyboard.js b/plugins/pilot/keyboard/tests/testKeyboard.js new file mode 100644 index 00000000..17918935 --- /dev/null +++ b/plugins/pilot/keyboard/tests/testKeyboard.js @@ -0,0 +1,99 @@ +require.def(['require', 'exports', 'module', + 'keyboard/keyboard', + 'keyboard/tests/plugindev' +], function(require, exports, module, + keyboard, + t +) { + +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Skywriter. + * + * The Initial Developer of the Original Code is + * Mozilla. + * Portions created by the Initial Developer are Copyright (C) 2009 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Skywriter Team (skywriter@mozilla.com) + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + + + + +exports.testKeyMatching = function() { + var km = keyboard.keyboardManager; + var command = {}; + t.equal(km._commandMatches(command, 'meta_z', {}), false, + 'no keymapping means false'); + + command = { + key: 'meta_z' + }; + t.equal(km._commandMatches(command, 'meta_z', {}), true, + 'matching keys, simple string'); + t.equal(km._commandMatches(command, 'meta_a', {}), false, + 'not matching key, simple string'); + + command = { + key: {key: 'meta_z', predicates: {isGreen: true}} + }; + t.equal(km._commandMatches(command, 'meta_z', {}), false, + 'object with not matching predicate'); + t.equal(km._commandMatches(command, 'meta_z', {isGreen: true}), true, + 'object with matching key and predicate'); + t.equal(km._commandMatches(command, 'meta_a', {isGreen: true}), false, + 'object with not matching key'); + t.equal(km._commandMatches(command, 'meta_a', {isGreen: false}), false, + 'object with neither matching'); + t.equal(km._commandMatches(command, 'meta_z', {isGreen: false}), false, + 'object with matching key and but different predicate'); + + command = { + key: ['meta_b', {key: 'meta_z', predicates: {isGreen: true}}, + {key: 'meta_c'}] + }; + t.equal(km._commandMatches(command, 'meta_z', {}), false, + 'list: object with not matching predicate'); + t.equal(km._commandMatches(command, 'meta_z', {isGreen: true}), true, + 'list: object with matching key and predicate'); + t.equal(km._commandMatches(command, 'meta_a', {isGreen: true}), false, + 'list: object with not matching key'); + t.equal(km._commandMatches(command, 'meta_a', {isGreen: false}), false, + 'list: object with neither matching'); + t.equal(km._commandMatches(command, 'meta_z', {isGreen: false}), false, + 'list: object with matching key and but different predicate'); + t.equal(km._commandMatches(command, 'meta_b'), true, + 'list: simple key match'); + t.equal(km._commandMatches(command, 'meta_c'), true, + 'list: object without predicate match'); + t.equal(km._commandMatches(command, 'meta_c', {isGreen: false}), true, + 'list: flags don\'t matter without predicates'); +}; + +}); diff --git a/lib/ace/lib/lang.js b/plugins/pilot/lang.js similarity index 97% rename from lib/ace/lib/lang.js rename to plugins/pilot/lang.js index 2a9ff350..f99d7a04 100644 --- a/lib/ace/lib/lang.js +++ b/plugins/pilot/lang.js @@ -37,6 +37,7 @@ define(function(require, exports, module) { + var lang = {}; lang.stringReverse = function(string) { @@ -44,9 +45,9 @@ define(function(require, exports, module) { }; lang.stringRepeat = function (string, count) { - return new Array(count + 1).join(string); - } - + return new Array(count + 1).join(string); + }; + if (Array.prototype.indexOf) { lang.arrayIndexOf = function(array, searchElement) { return array.indexOf(searchElement); @@ -121,5 +122,5 @@ define(function(require, exports, module) { }; }; - return lang; + exports.lang = lang; }); diff --git a/lib/ace/lib/oop.js b/plugins/pilot/oop.js similarity index 98% rename from lib/ace/lib/oop.js rename to plugins/pilot/oop.js index 8a825a27..eaf2cc73 100644 --- a/lib/ace/lib/oop.js +++ b/plugins/pilot/oop.js @@ -57,5 +57,5 @@ define(function(require, exports, module) { oop.mixin(proto, mixin); }; - return oop; -}); \ No newline at end of file + exports.oop = oop; +}); diff --git a/plugins/pilot/plugin_manager.js b/plugins/pilot/plugin_manager.js new file mode 100644 index 00000000..79b5b4cc --- /dev/null +++ b/plugins/pilot/plugin_manager.js @@ -0,0 +1,137 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Skywriter. + * + * The Initial Developer of the Original Code is + * Mozilla. + * Portions created by the Initial Developer are Copyright (C) 2009 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Kevin Dangoor (kdangoor@mozilla.com) + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +define(function(require, exports, module) { + +var Promise = require("pilot/promise").Promise; + +exports.REASONS = { + APP_STARTUP: 1, + APP_SHUTDOWN: 2, + PLUGIN_ENABLE: 3, + PLUGIN_DISABLE: 4, + PLUGIN_INSTALL: 5, + PLUGIN_UNINSTALL: 6, + PLUGIN_UPGRADE: 7, + PLUGIN_DOWNGRADE: 8 +}; + +exports.Plugin = function(name) { + this.name = name; + this.status = this.INSTALLED; +}; + +exports.Plugin.prototype = { + /** + * constants for the state + */ + NEW: 0, + INSTALLED: 1, + STARTED: 2, + SHUTDOWN: 3, + + install: function(data, reason) { + var pr = new Promise(); + if (this.status > this.NEW) { + pr.resolve(this); + return pr; + } + require([this.name], function(pluginModule) { + if (pluginModule.install) { + pluginModule.install(data, reason); + } + this.status = this.INSTALLED; + pr.resolve(this); + }.bind(this)); + return pr; + }, + + startup: function(data, reason) { + var pr = new Promise(); + if (this.status != this.INSTALLED) { + pr.resolve(this); + return pr; + } + require([this.name], function(pluginModule) { + if (pluginModule.startup) { + pluginModule.startup(data, reason); + } + this.status = this.STARTED; + pr.resolve(this); + }.bind(this)); + return pr; + }, + + shutdown: function(data, reason) { + if (this.status != this.STARTED) { + return; + } + pluginModule = require(this.name); + if (pluginModule.shutdown) { + pluginModule.shutdown(data, reason); + } + } +}; + +exports.PluginCatalog = function() { + this.plugins = {}; +}; + +exports.PluginCatalog.prototype = { + registerPlugins: function(pluginList) { + pluginList.forEach(function(pluginName) { + var plugin = this.plugins[pluginName]; + if (plugin === undefined) { + plugin = new exports.Plugin(pluginName); + this.plugins[pluginName] = plugin; + } + }.bind(this)); + }, + + startupPlugins: function(data, reason) { + var startupPromises = []; + for (var pluginName in this.plugins) { + var plugin = this.plugins[pluginName]; + startupPromises.push(plugin.startup(data, reason)); + } + return Promise.group(startupPromises); + } +}; + +exports.catalog = new exports.PluginCatalog(); + +}); diff --git a/plugins/pilot/promise.js b/plugins/pilot/promise.js new file mode 100644 index 00000000..8bd9f971 --- /dev/null +++ b/plugins/pilot/promise.js @@ -0,0 +1,264 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Skywriter. + * + * The Initial Developer of the Original Code is + * Mozilla. + * Portions created by the Initial Developer are Copyright (C) 2009 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Joe Walker (jwalker@mozilla.com) + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +define(function(require, exports, module) { + +var console = require("pilot/console"); +var Trace = require('pilot/stacktrace').Trace; + +/** + * A promise can be in one of 2 states. + * The ERROR and SUCCESS states are terminal, the PENDING state is the only + * start state. + */ +var ERROR = -1; +var PENDING = 0; +var SUCCESS = 1; + +/** + * We give promises and ID so we can track which are outstanding + */ +var _nextId = 0; + +/** + * Debugging help if 2 things try to complete the same promise. + * This can be slow (especially on chrome due to the stack trace unwinding) so + * we should leave this turned off in normal use. + */ +var _traceCompletion = false; + +/** + * Outstanding promises. Handy list for debugging only. + */ +var _outstanding = []; + +/** + * Recently resolved promises. Also for debugging only. + */ +var _recent = []; + +/** + * Create an unfulfilled promise + */ +Promise = function () { + this._status = PENDING; + this._value = undefined; + this._onSuccessHandlers = []; + this._onErrorHandlers = []; + + // Debugging help + this._id = _nextId++; + //this._createTrace = new Trace(new Error()); + _outstanding[this._id] = this; +}; + +/** + * Yeay for RTTI. + */ +Promise.prototype.isPromise = true; + +/** + * Have we either been resolve()ed or reject()ed? + */ +Promise.prototype.isComplete = function() { + return this._status != PENDING; +}; + +/** + * Have we resolve()ed? + */ +Promise.prototype.isResolved = function() { + return this._status == SUCCESS; +}; + +/** + * Have we reject()ed? + */ +Promise.prototype.isRejected = function() { + return this._status == ERROR; +}; + +/** + * Take the specified action of fulfillment of a promise, and (optionally) + * a different action on promise rejection. + */ +Promise.prototype.then = function(onSuccess, onError) { + if (typeof onSuccess === 'function') { + if (this._status === SUCCESS) { + onSuccess.call(null, this._value); + } else if (this._status === PENDING) { + this._onSuccessHandlers.push(onSuccess); + } + } + + if (typeof onError === 'function') { + if (this._status === ERROR) { + onError.call(null, this._value); + } else if (this._status === PENDING) { + this._onErrorHandlers.push(onError); + } + } + + return this; +}; + +/** + * Like then() except that rather than returning this we return + * a promise which + */ +Promise.prototype.chainPromise = function(onSuccess) { + var chain = new Promise(); + chain._chainedFrom = this; + this.then(function(data) { + try { + chain.resolve(onSuccess(data)); + } catch (ex) { + chain.reject(ex); + } + }, function(ex) { + chain.reject(ex); + }); + return chain; +}; + +/** + * Supply the fulfillment of a promise + */ +Promise.prototype.resolve = function(data) { + return this._complete(this._onSuccessHandlers, SUCCESS, data, 'resolve'); +}; + +/** + * Renege on a promise + */ +Promise.prototype.reject = function(data) { + return this._complete(this._onErrorHandlers, ERROR, data, 'reject'); +}; + +/** + * Internal method to be called on resolve() or reject(). + * @private + */ +Promise.prototype._complete = function(list, status, data, name) { + // Complain if we've already been completed + if (this._status != PENDING) { + console.group('Promise already closed'); + console.error('Attempted ' + name + '() with ', data); + console.error('Previous status = ', this._status, + ', previous value = ', this._value); + console.trace(); + + if (this._completeTrace) { + console.error('Trace of previous completion:'); + this._completeTrace.log(5); + } + console.groupEnd(); + return this; + } + + if (_traceCompletion) { + this._completeTrace = new Trace(new Error()); + } + + this._status = status; + this._value = data; + + // Call all the handlers, and then delete them + list.forEach(function(handler) { + handler.call(null, this._value); + }, this); + this._onSuccessHandlers.length = 0; + this._onErrorHandlers.length = 0; + + // Remove the given {promise} from the _outstanding list, and add it to the + // _recent list, pruning more than 20 recent promises from that list. + delete _outstanding[this._id]; + _recent.push(this); + while (_recent.length > 20) { + _recent.shift(); + } + + return this; +}; + +/** + * Takes an array of promises and returns a promise that that is fulfilled once + * all the promises in the array are fulfilled + * @param group The array of promises + * @return the promise that is fulfilled when all the array is fulfilled + */ +Promise.group = function(promiseList) { + if (!(promiseList instanceof Array)) { + promiseList = Array.prototype.slice.call(arguments); + } + + // If the original array has nothing in it, return now to avoid waiting + if (promiseList.length === 0) { + return new Promise().resolve([]); + } + + var groupPromise = new Promise(); + var results = []; + var fulfilled = 0; + + var onSuccessFactory = function(index) { + return function(data) { + results[index] = data; + fulfilled++; + // If the group has already failed, silently drop extra results + if (groupPromise._status !== ERROR) { + if (fulfilled === promiseList.length) { + groupPromise.resolve(results); + } + } + }; + }; + + promiseList.forEach(function(promise, index) { + var onSuccess = onSuccessFactory(index); + var onError = groupPromise.reject.bind(groupPromise); + promise.then(onSuccess, onError); + }); + + return groupPromise; +}; + +exports.Promise = Promise; +exports._outstanding = _outstanding; +exports._recent = _recent; + +}); diff --git a/plugins/pilot/proxy.js b/plugins/pilot/proxy.js new file mode 100644 index 00000000..88d76a54 --- /dev/null +++ b/plugins/pilot/proxy.js @@ -0,0 +1,83 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Skywriter. + * + * The Initial Developer of the Original Code is + * Mozilla. + * Portions created by the Initial Developer are Copyright (C) 2009 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Julian Viereck (jviereck@mozilla.com) + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +define(function(require, exports, module) { + +var Promise = require('pilot/promise').Promise; + +exports.xhr = function(method, url, async, beforeSendCallback) { + var pr = new Promise(); + + if (!skywriter.proxy || !skywriter.proxy.xhr) { + var req = new XMLHttpRequest(); + req.onreadystatechange = function() { + if (req.readyState !== 4) { + return; + } + + var status = req.status; + if (status !== 0 && status !== 200) { + var error = new Error(req.responseText + ' (Status ' + req.status + ")"); + error.xhr = req; + pr.reject(error); + return; + } + + pr.resolve(req.responseText); + }.bind(this); + + req.open("GET", url, async); + if (beforeSendCallback) { + beforeSendCallback(req); + } + req.send(); + } else { + skywriter.proxy.xhr.call(this, method, url, async, beforeSendCallback, pr); + } + + return pr; +}; + +exports.Worker = function(url) { + if (!skywriter.proxy || !skywriter.proxy.worker) { + return new Worker(url); + } else { + return new skywriter.proxy.worker(url); + } +}; + +}); diff --git a/plugins/pilot/rangeutils.js b/plugins/pilot/rangeutils.js new file mode 100644 index 00000000..b4714f7b --- /dev/null +++ b/plugins/pilot/rangeutils.js @@ -0,0 +1,185 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Skywriter. + * + * The Initial Developer of the Original Code is + * Mozilla. + * Portions created by the Initial Developer are Copyright (C) 2009 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Patrick Walton (pwalton@mozilla.com) + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +define(function(require, exports, module) { + +var util = require("util/util"); + +/** + * Returns the result of adding the two positions. + */ +exports.addPositions = function(a, b) { + return { row: a.row + b.row, col: a.col + b.col }; +}; + +/** Returns a copy of the given range. */ +exports.cloneRange = function(range) { + var oldStart = range.start, oldEnd = range.end; + var newStart = { row: oldStart.row, col: oldStart.col }; + var newEnd = { row: oldEnd.row, col: oldEnd.col }; + return { start: newStart, end: newEnd }; +}; + +/** + * Given two positions a and b, returns a negative number if a < b, 0 if a = b, + * or a positive number if a > b. + */ +exports.comparePositions = function(positionA, positionB) { + var rowDiff = positionA.row - positionB.row; + return rowDiff === 0 ? positionA.col - positionB.col : rowDiff; +}; + +/** + * Returns true if the two ranges are equal and false otherwise. + */ +exports.equal = function(rangeA, rangeB) { + return (exports.comparePositions(rangeA.start, rangeB.start) === 0 && + exports.comparePositions(rangeA.end, rangeB.end) === 0); +}; + +exports.extendRange = function(range, delta) { + var end = range.end; + return { + start: range.start, + end: { + row: end.row + delta.row, + col: end.col + delta.col + } + }; +}; + +/** + * Given two sets of ranges, returns the ranges of characters that exist in one + * of the sets but not both. + */ +exports.intersectRangeSets = function(setA, setB) { + var stackA = util.clone(setA), stackB = util.clone(setB); + var result = []; + while (stackA.length > 0 && stackB.length > 0) { + var rangeA = stackA.shift(), rangeB = stackB.shift(); + var startDiff = exports.comparePositions(rangeA.start, rangeB.start); + var endDiff = exports.comparePositions(rangeA.end, rangeB.end); + + if (exports.comparePositions(rangeA.end, rangeB.start) < 0) { + // A is completely before B + result.push(rangeA); + stackB.unshift(rangeB); + } else if (exports.comparePositions(rangeB.end, rangeA.start) < 0) { + // B is completely before A + result.push(rangeB); + stackA.unshift(rangeA); + } else if (startDiff < 0) { // A starts before B + result.push({ start: rangeA.start, end: rangeB.start }); + stackA.unshift({ start: rangeB.start, end: rangeA.end }); + stackB.unshift(rangeB); + } else if (startDiff === 0) { // A and B start at the same place + if (endDiff < 0) { // A ends before B + stackB.unshift({ start: rangeA.end, end: rangeB.end }); + } else if (endDiff > 0) { // A ends after B + stackA.unshift({ start: rangeB.end, end: rangeA.end }); + } + } else if (startDiff > 0) { // A starts after B + result.push({ start: rangeB.start, end: rangeA.start }); + stackA.unshift(rangeA); + stackB.unshift({ start: rangeA.start, end: rangeB.end }); + } + } + return result.concat(stackA, stackB); +}; + +exports.isZeroLength = function(range) { + return range.start.row === range.end.row && + range.start.col === range.end.col; +}; + +/** + * Returns the greater of the two positions. + */ +exports.maxPosition = function(a, b) { + return exports.comparePositions(a, b) > 0 ? a : b; +}; + +/** + * Converts a range with swapped 'end' and 'start' values into one with the + * values in the correct order. + * + * TODO: Unit test. + */ +exports.normalizeRange = function(range) { + return this.comparePositions(range.start, range.end) < 0 ? range : + { start: range.end, end: range.start }; +}; + +/** + * Returns a single range that spans the entire given set of ranges. + */ +exports.rangeSetBoundaries = function(rangeSet) { + return { + start: rangeSet[0].start, + end: rangeSet[rangeSet.length - 1].end + }; +}; + +exports.toString = function(range) { + var start = range.start, end = range.end; + return '[ ' + start.row + ', ' + start.col + ' ' + end.row + ',' + + end.col +' ]'; +}; + +/** + * Returns the union of the two ranges. + */ +exports.unionRanges = function(a, b) { + return { + start: a.start.row < b.start.row || + (a.start.row === b.start.row && a.start.col < b.start.col) ? + a.start : b.start, + end: a.end.row > b.end.row || + (a.end.row === b.end.row && a.end.col > b.end.col) ? + a.end : b.end + }; +}; + +exports.isPosition = function(pos) { + return !util.none(pos) && !util.none(pos.row) && !util.none(pos.col); +}; + +exports.isRange = function(range) { + return (!util.none(range) && exports.isPosition(range.start) && + exports.isPosition(range.end)); +}; + +}); \ No newline at end of file diff --git a/plugins/pilot/settings.js b/plugins/pilot/settings.js new file mode 100644 index 00000000..fbe8b2ab --- /dev/null +++ b/plugins/pilot/settings.js @@ -0,0 +1,298 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Skywriter. + * + * The Initial Developer of the Original Code is + * Mozilla. + * Portions created by the Initial Developer are Copyright (C) 2009 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Joe Walker (jwalker@mozilla.com) + * Julian Viereck (jviereck@mozilla.com) + * Kevin Dangoor (kdangoor@mozilla.com) + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +define(function(require, exports, module) { + +/** + * This plug-in manages settings. + */ + +var console = require('pilot/console'); +var oop = require('pilot/oop').oop; +var types = require('pilot/types'); +var EventEmitter = require('pilot/event_emitter').EventEmitter; +var catalog = require('pilot/catalog'); + +var settingExtensionSpec = { + name: 'setting', + description: 'A setting is something that the application offers as a ' + + 'way to customize how it works', + register: 'env.settings.addSetting', + indexOn: 'name' +}; + +exports.startup = function(data, reason) { + catalog.addExtensionSpec(settingExtensionSpec); +}; + +exports.shutdown = function(data, reason) { + catalog.removeExtensionSpec(settingExtensionSpec); +}; + + +/** + * Create a new setting. + * @param settingSpec An object literal that looks like this: + * { + * name: 'thing', + * description: 'Thing is an example setting', + * type: 'string', + * defaultValue: 'something' + * } + */ +function Setting(settingSpec, settings) { + this._settings = settings; + + Object.keys(settingSpec).forEach(function(key) { + this[key] = settingSpec[key]; + }, this); + + this.type = types.getType(this.type); + if (this.type == null) { + throw new Error('In ' + this.name + + ': can\'t find type for: ' + JSON.stringify(settingSpec.type)); + } + + if (!this.name) { + throw new Error('Setting.name == undefined. Ignoring.', this); + } + + if (!this.defaultValue === undefined) { + throw new Error('Setting.defaultValue == undefined', this); + } + + this.value = this.defaultValue; +} +Setting.prototype = { + get: function() { + return this.value; + }, + + set: function(value) { + if (this.value === value) { + return; + } + + this.value = value; + if (this._settings.persister) { + this._settings.persister.persistValue(this._settings, this.name, value); + } + + this._dispatchEvent('change', { setting: this, value: value }); + }, + + /** + * Reset the value of the key setting to it's default + */ + resetValue: function() { + this.set(this.defaultValue); + } +}; +oop.implement(Setting.prototype, EventEmitter); + + +/** + * A base class for all the various methods of storing settings. + *

Usage: + *

+ * // Create manually, or require 'settings' from the container.
+ * // This is the manual version:
+ * var settings = plugins.catalog.getObject('settings');
+ * // Add a new setting
+ * settings.addSetting({ name:'foo', ... });
+ * // Display the default value
+ * alert(settings.get('foo'));
+ * // Alter the value, which also publishes the change etc.
+ * settings.set('foo', 'bar');
+ * // Reset the value to the default
+ * settings.resetValue('foo');
+ * 
+ * @constructor + */ +function Settings(persister) { + /** + * Storage for deactivated values + */ + this._deactivated = {}; + + this._settings = {}; + + if (persister) { + this.setPersister(persister); + } +}; + +Settings.prototype = { + /** + * Function to add to the list of available settings. + *

Example usage: + *

+     * var settings = plugins.catalog.getObject('settings');
+     * settings.addSetting({
+     *     name: 'tabsize', // For use in settings.get('X')
+     *     type: 'number',  // To allow value checking.
+     *     defaultValue: 4  // Default value for use when none is directly set
+     * });
+     * 
+ * @param {object} settingSpec Object containing name/type/defaultValue members. + */ + addSetting: function(settingSpec) { + var setting = new Setting(settingSpec, this); + this._settings[setting.name] = setting; + }, + + removeSetting: function(name) { + delete this._settings[name]; + }, + + getSettingNames: function() { + return Object.keys(this._settings); + }, + + getSetting: function(name) { + return this._settings[name]; + }, + + /** + * A Persister is able to store settings. It is an object that defines + * two functions: + * loadInitialValues(settings) and persistValue(settings, key, value). + */ + setPersister: function(persister) { + this._persister = persister; + if (persister) { + persister.loadInitialValues(this); + } + }, + + resetAll: function() { + this.getSettingNames().forEach(function(key) { + this.resetValue(key); + }.bind(this)); + }, + + /** + * Retrieve a list of the known settings and their values + */ + _list: function() { + var reply = []; + this.getSettingNames().forEach(function(setting) { + reply.push({ + 'key': setting, + 'value': this.get(setting) + }); + }.bind(this)); + return reply; + }, + + /** + * Prime the local cache with the defaults. + */ + _loadDefaultValues: function() { + this._loadFromObject(this._getDefaultValues()); + }, + + /** + * Utility to load settings from an object + */ + _loadFromObject: function(data) { + // We iterate over data rather than keys so we don't forget values + // which don't have a setting yet. + for (var key in data) { + if (data.hasOwnProperty(key)) { + var setting = this._settings[key]; + if (setting) { + var value = setting.type.parse(data[key]); + this.set(key, value); + } else { + this.set(key, data[key]); + } + } + } + }, + + /** + * Utility to grab all the settings and export them into an object + */ + _saveToObject: function() { + return this.getSettingNames().map(function(key) { + return this._settings[key].type.stringify(this.get(key)); + }.bind(this)); + }, + + /** + * The default initial settings + */ + _getDefaultValues: function() { + return this.getSettingNames().map(function(key) { + return this._settings[key].spec.defaultValue; + }.bind(this)); + } +}; +exports.settings = new Settings(); + +/** + * Save the settings in a cookie + * This code has not been tested since reboot + * @constructor + */ +function CookiePersister() { +}; + +CookiePersister.prototype = { + loadInitialValues: function(settings) { + settings._loadDefaultValues(); + var data = cookie.get('settings'); + settings._loadFromObject(JSON.parse(data)); + }, + + persistValue: function(settings, key, value) { + try { + var stringData = JSON.stringify(settings._saveToObject()); + cookie.set('settings', stringData); + } catch (ex) { + console.error('Unable to JSONify the settings! ' + ex); + return; + } + } +}; + +exports.CookiePersister = CookiePersister; + +}); diff --git a/plugins/pilot/settings/canon.js b/plugins/pilot/settings/canon.js new file mode 100644 index 00000000..5ad36d50 --- /dev/null +++ b/plugins/pilot/settings/canon.js @@ -0,0 +1,57 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Skywriter. + * + * The Initial Developer of the Original Code is + * Mozilla. + * Portions created by the Initial Developer are Copyright (C) 2009 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Joe Walker (jwalker@mozilla.com) + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +define(function(require, exports, module) { + + +var historyLengthSetting = { + name: "historyLength", + description: "How many typed commands do we recall for reference?", + type: "number", + defaultValue: 50 +}; + +exports.startup = function(data, reason) { + data.env.settings.addSetting(historyLengthSetting); +}; + +exports.shutdown = function(data, reason) { + data.env.settings.removeSetting(historyLengthSetting); +}; + + +}); diff --git a/plugins/pilot/stacktrace.js b/plugins/pilot/stacktrace.js new file mode 100644 index 00000000..961d88cc --- /dev/null +++ b/plugins/pilot/stacktrace.js @@ -0,0 +1,332 @@ +define(function(require, exports, module) { + +var util = require("pilot/util"); +var console = require('pilot/console'); + +// Changed to suit the specific needs of running within Skywriter + +// Domain Public by Eric Wendelin http://eriwen.com/ (2008) +// Luke Smith http://lucassmith.name/ (2008) +// Loic Dachary (2008) +// Johan Euphrosine (2008) +// Øyvind Sean Kinsey http://kinsey.no/blog +// +// Information and discussions +// http://jspoker.pokersource.info/skin/test-printstacktrace.html +// http://eriwen.com/javascript/js-stack-trace/ +// http://eriwen.com/javascript/stacktrace-update/ +// http://pastie.org/253058 +// http://browsershots.org/http://jspoker.pokersource.info/skin/test-printstacktrace.html +// + +// +// guessFunctionNameFromLines comes from firebug +// +// Software License Agreement (BSD License) +// +// Copyright (c) 2007, Parakey Inc. +// All rights reserved. +// +// Redistribution and use of this software 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 Parakey Inc. nor the names of its +// contributors may be used to endorse or promote products +// derived from this software without specific prior +// written permission of Parakey Inc. +// +// 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 THE COPYRIGHT OWNER OR +// CONTRIBUTORS 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. + + + +/** + * Different browsers create stack traces in different ways. + * Feature Browser detection baby ;). + */ +var mode = (function() { + + // We use SC's browser detection here to avoid the "break on error" + // functionality provided by Firebug. Firebug tries to do the right + // thing here and break, but it happens every time you load the page. + // bug 554105 + if (util.isMozilla) { + return 'firefox'; + } else if (util.isOpera) { + return 'opera'; + } else if (util.isSafari) { + return 'other'; + } + + // SC doesn't do any detection of Chrome at this time. + + // this is the original feature detection code that is used as a + // fallback. + try { + (0)(); + } catch (e) { + if (e.arguments) { + return 'chrome'; + } + if (e.stack) { + return 'firefox'; + } + if (window.opera && !('stacktrace' in e)) { //Opera 9- + return 'opera'; + } + } + return 'other'; +})(); + +/** + * + */ +function stringifyArguments(args) { + for (var i = 0; i < args.length; ++i) { + var argument = args[i]; + if (typeof argument == 'object') { + args[i] = '#object'; + } else if (typeof argument == 'function') { + args[i] = '#function'; + } else if (typeof argument == 'string') { + args[i] = '"' + argument + '"'; + } + } + return args.join(','); +} + +/** + * Extract a stack trace from the format emitted by each browser. + */ +var decoders = { + chrome: function(e) { + var stack = e.stack; + if (!stack) { + console.log(e); + return []; + } + return stack.replace(/^.*?\n/, ''). + replace(/^.*?\n/, ''). + replace(/^.*?\n/, ''). + replace(/^[^\(]+?[\n$]/gm, ''). + replace(/^\s+at\s+/gm, ''). + replace(/^Object.\s*\(/gm, '{anonymous}()@'). + split('\n'); + }, + + firefox: function(e) { + var stack = e.stack; + if (!stack) { + console.log(e); + return []; + } + // stack = stack.replace(/^.*?\n/, ''); + stack = stack.replace(/(?:\n@:0)?\s+$/m, ''); + stack = stack.replace(/^\(/gm, '{anonymous}('); + return stack.split('\n'); + }, + + // Opera 7.x and 8.x only! + opera: function(e) { + var lines = e.message.split('\n'), ANON = '{anonymous}', + lineRE = /Line\s+(\d+).*?script\s+(http\S+)(?:.*?in\s+function\s+(\S+))?/i, i, j, len; + + for (i = 4, j = 0, len = lines.length; i < len; i += 2) { + if (lineRE.test(lines[i])) { + lines[j++] = (RegExp.$3 ? RegExp.$3 + '()@' + RegExp.$2 + RegExp.$1 : ANON + '()@' + RegExp.$2 + ':' + RegExp.$1) + + ' -- ' + + lines[i + 1].replace(/^\s+/, ''); + } + } + + lines.splice(j, lines.length - j); + return lines; + }, + + // Safari, Opera 9+, IE, and others + other: function(curr) { + var ANON = '{anonymous}', fnRE = /function\s*([\w\-$]+)?\s*\(/i, stack = [], j = 0, fn, args; + + var maxStackSize = 10; + while (curr && stack.length < maxStackSize) { + fn = fnRE.test(curr.toString()) ? RegExp.$1 || ANON : ANON; + args = Array.prototype.slice.call(curr['arguments']); + stack[j++] = fn + '(' + stringifyArguments(args) + ')'; + + //Opera bug: if curr.caller does not exist, Opera returns curr (WTF) + if (curr === curr.caller && window.opera) { + //TODO: check for same arguments if possible + break; + } + curr = curr.caller; + } + return stack; + } +}; + +/** + * + */ +function NameGuesser() { +} + +NameGuesser.prototype = { + + sourceCache: {}, + + ajax: function(url) { + var req = this.createXMLHTTPObject(); + if (!req) { + return; + } + req.open('GET', url, false); + req.setRequestHeader('User-Agent', 'XMLHTTP/1.0'); + req.send(''); + return req.responseText; + }, + + createXMLHTTPObject: function() { + // Try XHR methods in order and store XHR factory + var xmlhttp, XMLHttpFactories = [ + function() { + return new XMLHttpRequest(); + }, function() { + return new ActiveXObject('Msxml2.XMLHTTP'); + }, function() { + return new ActiveXObject('Msxml3.XMLHTTP'); + }, function() { + return new ActiveXObject('Microsoft.XMLHTTP'); + } + ]; + for (var i = 0; i < XMLHttpFactories.length; i++) { + try { + xmlhttp = XMLHttpFactories[i](); + // Use memoization to cache the factory + this.createXMLHTTPObject = XMLHttpFactories[i]; + return xmlhttp; + } catch (e) {} + } + }, + + getSource: function(url) { + if (!(url in this.sourceCache)) { + this.sourceCache[url] = this.ajax(url).split('\n'); + } + return this.sourceCache[url]; + }, + + guessFunctions: function(stack) { + for (var i = 0; i < stack.length; ++i) { + var reStack = /{anonymous}\(.*\)@(\w+:\/\/([-\w\.]+)+(:\d+)?[^:]+):(\d+):?(\d+)?/; + var frame = stack[i], m = reStack.exec(frame); + if (m) { + var file = m[1], lineno = m[4]; //m[7] is character position in Chrome + if (file && lineno) { + var functionName = this.guessFunctionName(file, lineno); + stack[i] = frame.replace('{anonymous}', functionName); + } + } + } + return stack; + }, + + guessFunctionName: function(url, lineNo) { + try { + return this.guessFunctionNameFromLines(lineNo, this.getSource(url)); + } catch (e) { + return 'getSource failed with url: ' + url + ', exception: ' + e.toString(); + } + }, + + guessFunctionNameFromLines: function(lineNo, source) { + var reFunctionArgNames = /function ([^(]*)\(([^)]*)\)/; + var reGuessFunction = /['"]?([0-9A-Za-z_]+)['"]?\s*[:=]\s*(function|eval|new Function)/; + // Walk backwards from the first line in the function until we find the line which + // matches the pattern above, which is the function definition + var line = '', maxLines = 10; + for (var i = 0; i < maxLines; ++i) { + line = source[lineNo - i] + line; + if (line !== undefined) { + var m = reGuessFunction.exec(line); + if (m) { + return m[1]; + } + else { + m = reFunctionArgNames.exec(line); + } + if (m && m[1]) { + return m[1]; + } + } + } + return '(?)'; + } +}; + +var guesser = new NameGuesser(); + +var frameIgnorePatterns = [ + /http:\/\/localhost:4020\/sproutcore.js:/ +]; + +exports.ignoreFramesMatching = function(regex) { + frameIgnorePatterns.push(regex); +}; + +/** + * Create a stack trace from an exception + * @param ex {Error} The error to create a stacktrace from (optional) + * @param guess {Boolean} If we should try to resolve the names of anonymous functions + */ +exports.Trace = function Trace(ex, guess) { + this._ex = ex; + this._stack = decoders[mode](ex); + + if (guess) { + this._stack = guesser.guessFunctions(this._stack); + } +}; + +/** + * Log to the console a number of lines (default all of them) + * @param lines {number} Maximum number of lines to wrote to console + */ +exports.Trace.prototype.log = function(lines) { + if (lines <= 0) { + // You aren't going to have more lines in your stack trace than this + // and it still fits in a 32bit integer + lines = 999999999; + } + + var printed = 0; + for (var i = 0; i < this._stack.length && printed < lines; i++) { + var frame = this._stack[i]; + var display = true; + frameIgnorePatterns.forEach(function(regex) { + if (regex.test(frame)) { + display = false; + } + }); + if (display) { + console.debug(frame); + printed++; + } + } +}; + +}); diff --git a/plugins/pilot/tests/testRangeutils.js b/plugins/pilot/tests/testRangeutils.js new file mode 100644 index 00000000..d96c43a4 --- /dev/null +++ b/plugins/pilot/tests/testRangeutils.js @@ -0,0 +1,163 @@ +require.def(['require', 'exports', 'module', + 'rangeutils/tests/plugindev', + 'rangeutils/tests/utils/range' +], function(require, exports, module, + t, + Range +) { + +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Skywriter. + * + * The Initial Developer of the Original Code is + * Mozilla. + * Portions created by the Initial Developer are Copyright (C) 2009 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Skywriter Team (skywriter@mozilla.com) + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + + + + +exports.testAddPositions = function() { + t.deepEqual(Range.addPositions({ row: 0, col: 0 }, + { row: 0, col: 0 }), { row: 0, col: 0 }, '0,0 + 0,0 and 0,0'); + t.deepEqual(Range.addPositions({ row: 1, col: 0 }, + { row: 2, col: 0 }), { row: 3, col: 0 }, '1,0 + 2,0 and 3,0'); + t.deepEqual(Range.addPositions({ row: 0, col: 1 }, + { row: 0, col: 1 }), { row: 0, col: 2 }, '0,1 + 0,1 and 0,2'); + t.deepEqual(Range.addPositions({ row: 1, col: 2 }, + { row: -1, col: -2 }), { row: 0, col: 0 }, '1,2 + -1,-2 and 0,0'); +}; + +exports.testCloneRange = function() { + var oldRange = { start: { row: 1, col: 2 }, end: { row: 3, col: 4 } }; + var newRange = Range.cloneRange(oldRange); + t.deepEqual(oldRange, newRange, "the old range and the new range"); + t.ok(oldRange.start !== newRange.start, "the old range's start position " + + "is distinct from the new range's start position"); + t.ok(oldRange.end !== newRange.end, "the old range's end position is " + + "distinct from the new range's end position"); + t.ok(oldRange !== newRange, "the old range is distinct from the new " + + "range"); +}; + +exports.testComparePositions = function() { + t.equal(Range.comparePositions({ row: 0, col: 0 }, + { row: 0, col: 0 }), 0, '0,0 = 0,0'); + t.ok(Range.comparePositions({ row: 0, col: 0 }, + { row: 1, col: 0 }) < 0, '0,0 < 1,0'); + t.ok(Range.comparePositions({ row: 0, col: 0 }, + { row: 0, col: 1 }) < 0, '0,0 < 0,1'); + t.ok(Range.comparePositions({ row: 1, col: 0 }, + { row: 0, col: 0 }) > 0, '1,0 > 0,0'); + t.ok(Range.comparePositions({ row: 0, col: 1 }, + { row: 0, col: 0 }) > 0, '0,1 > 0,0'); +}; + +exports.testExtendRange = function() { + t.deepEqual(Range.extendRange({ + start: { row: 1, col: 2 }, + end: { row: 3, col: 4 } + }, { row: 5, col: 6 }), { + start: { row: 1, col: 2 }, + end: { row: 8, col: 10 } + }, '[ 1,2 3,4 ] extended by 5,6 = [ 1,2 8,10 ]'); + t.deepEqual(Range.extendRange({ + start: { row: 7, col: 8 }, + end: { row: 9, col: 10 } + }, { row: 0, col: 0 }), { + start: { row: 7, col: 8 }, + end: { row: 9, col: 10 } + }, '[ 7,8 9,10 ] extended by 0,0 remains the same'); +}; + +exports.testMaxPosition = function() { + t.deepEqual(Range.maxPosition({ row: 0, col: 0 }, + { row: 0, col: 0 }), { row: 0, col: 0 }, 'max(0,0 0,0) = 0,0'); + t.deepEqual(Range.maxPosition({ row: 0, col: 0 }, + { row: 1, col: 0 }), { row: 1, col: 0 }, 'max(0,0 1,0) = 1,0'); + t.deepEqual(Range.maxPosition({ row: 0, col: 0 }, + { row: 0, col: 1 }), { row: 0, col: 1 }, 'max(0,0 0,1) = 0,1'); + t.deepEqual(Range.maxPosition({ row: 1, col: 0 }, + { row: 0, col: 0 }), { row: 1, col: 0 }, 'max(1,0 0,0) = 1,0'); + t.deepEqual(Range.maxPosition({ row: 0, col: 1 }, + { row: 0, col: 0 }), { row: 0, col: 1 }, 'max(0,1 0,0) = 0,1'); +}; + +exports.testNormalizeRange = function() { + t.deepEqual(Range.normalizeRange({ + start: { row: 0, col: 0 }, + end: { row: 0, col: 0 } + }), { + start: { row: 0, col: 0 }, + end: { row: 0, col: 0 } + }, 'normalize(0,0 0,0) and (0,0 0,0)'); + t.deepEqual(Range.normalizeRange({ + start: { row: 1, col: 2 }, + end: { row: 3, col: 4 } + }), { + start: { row: 1, col: 2 }, + end: { row: 3, col: 4 } + }, 'normalize(1,2 3,4) and (1,2 3,4)'); + t.deepEqual(Range.normalizeRange({ + start: { row: 4, col: 3 }, + end: { row: 2, col: 1 } + }), { + start: { row: 2, col: 1 }, + end: { row: 4, col: 3 } + }, 'normalize(4,3 2,1) and (2,1 4,3)'); +}; + +exports.testUnionRanges = function() { + t.deepEqual(Range.unionRanges({ + start: { row: 1, col: 2 }, + end: { row: 3, col: 4 } + }, { + start: { row: 5, col: 6 }, + end: { row: 7, col: 8 } + }), { + start: { row: 1, col: 2 }, + end: { row: 7, col: 8 } + }, '[ 1,2 3,4 ] union [ 5,6 7,8 ] = [ 1,2 7,8 ]'); + t.deepEqual(Range.unionRanges({ + start: { row: 4, col: 4 }, + end: { row: 5, col: 5 } + }, { + start: { row: 3, col: 3 }, + end: { row: 4, col: 5 } + }), { + start: { row: 3, col: 3 }, + end: { row: 5, col: 5 } + }, '[ 4,4 5,5 ] union [ 3,3 4,5 ] = [ 3,3 5,5 ]'); +}; + + +}); diff --git a/plugins/pilot/types.js b/plugins/pilot/types.js new file mode 100644 index 00000000..0452b0a6 --- /dev/null +++ b/plugins/pilot/types.js @@ -0,0 +1,238 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Skywriter. + * + * The Initial Developer of the Original Code is + * Mozilla. + * Portions created by the Initial Developer are Copyright (C) 2009 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Joe Walker (jwalker@mozilla.com) + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +define(function(require, exports, module) { + +/** + * Some types can detect validity, that is to say they can distinguish between + * valid and invalid values. + * TODO: Change these constants to be numbers for more performance? + */ +var Status = { + /** + * The conversion process worked without any problem, and the value is + * valid. There are a number of failure states, so the best way to check + * for failure is (x !== Status.VALID) + */ + VALID: 'VALID', + + /** + * The conversion process did not work like Status.INVALID, however it was + * noted that the string provided to 'parse()' could be VALID by the + * addition of more characters, so the typing may not be actually incorrect + * yet, just unfinished. + * @see Status.INVALID + */ + INCOMPLETE: 'INCOMPLETE', + + /** + * The conversion process did not work, the value should be null and a + * reason for failure should have been provided. In addition some completion + * values may be available. + * @see Status.INCOMPLETE + */ + INVALID: 'INVALID', + + /** + * A combined status is the worser of the provided statuses + */ + combine: function(statuses) { + var combined = Status.VALID; + for (var i = 0; i < arguments; i++) { + if (arguments[i] > combined) { + combined = arguments[i]; + } + } + return combined; + } +}; +exports.Status = Status; + +/** + * The type.parse() method returns a Conversion to inform the user about not + * only the result of a Conversion but also about what went wrong. + * We could use an exception, and throw if the conversion failed, but that + * seems to violate the idea that exceptions should be exceptional. Typos are + * not. Also in order to store both a status and a message we'd still need + * some sort of exception type... + */ +function Conversion(value, status, message, predictions) { + /** + * The result of the conversion process. Will be null if status != VALID + */ + this.value = value; + + /** + * The status of the conversion. + * @see Status + */ + this.status = status || Status.VALID; + + /** + * A message to go with the conversion. This could be present for any status + * including VALID in the case where we want to note a warning for example. + * I18N: On the one hand this nasty and un-internationalized, however with + * a command line it is hard to know where to start. + */ + this.message = message; + + /** + * A array of strings which are the systems best guess at better inputs than + * the one presented. + * We generally expect there to be about 7 predictions (to match human list + * comprehension ability) however it is valid to provide up to about 20, + * or less. It is the job of the predictor to decide a smart cut-off. + * For example if there are 4 very good matches and 4 very poor ones, + * probably only the 4 very good matches should be presented. + */ + this.predictions = predictions || []; +} +exports.Conversion = Conversion; + +/** + * Most of our types are 'static' e.g. there is only one type of 'text', however + * some types like 'selection' and 'deferred' are customizable. The basic + * Type type isn't useful, but does provide documentation about what types do. + * + */ +function Type() { +}; +Type.prototype = { + /** + * Convert the given value to a string representation. + * Where possible, there should be round-tripping between values and their + * string representations. + */ + stringify: function(value) { throw new Error("not implemented"); }, + + /** + * Convert the given str to an instance of this type. + * Where possible, there should be round-tripping between values and their + * string representations. + * @return Conversion + */ + parse: function(str) { throw new Error("not implemented"); }, + + /** + * The plug-in system, and other things need to know what this type is + * called. The name alone is not enough to fully specify a type. Types like + * 'selection' and 'deferred' need extra data, however this function returns + * only the name, not the extra data. + *

In old bespin, equality was based on the name. This may turn out to be + * important in Ace too. + */ + name: undefined +}; +exports.Type = Type; + +/** + * Private registry of types + * Invariant: types[name] = type.name + */ +var types = {}; + +/** + * Add a new type to the list available to the system. + * You can pass 2 things to this function - either an instance of Type, in + * which case we return this instance when #getType() is called with a 'name' + * that matches type.name. + * Also you can pass in a constructor (i.e. function) in which case when + * #getType() is called with a 'name' that matches Type.prototype.name we will + * pass the typeSpec into this constructor. See #reconstituteType(). + */ +exports.registerType = function(type) { + if (typeof type === 'object') { + if (type instanceof Type) { + if (!type.name) { + throw new Error('All registered types must have a name'); + } + types[type.name] = type; + } + else { + throw new Error('Can\'t registerType using: ' + type); + } + } + else if (typeof type === 'function') { + if (!type.prototype.name) { + throw new Error('All registered types must have a name'); + } + types[type.prototype.name] = type; + } + else { + throw new Error('Unknown type: ' + type); + } +}; + +/** + * Remove a type from the list available to the system + */ +exports.deregisterType = function(type) { + delete types[type.name]; +}; + +/** + * See description of #exports.registerType() + */ +function reconstituteType(name, typeSpec) { + var type = types[name]; + if (typeof type === 'function') { + // TODO: should we complain if typeSpec is a string? + type = new type(typeSpec); + } + return type; +} + +/** + * Find a type, previously registered using #registerType() + */ +exports.getType = function(typeSpec) { + if (typeof typeSpec === 'string') { + return reconstituteType(typeSpec, typeSpec); + } + + if (typeof typeSpec == 'object') { + if (!typeSpec.name) { + throw new Error('Missing \'name\' member to typeSpec'); + } + return reconstituteType(typeSpec.name, typeSpec); + } + + throw new Error('Can\'t extract type from ' + typeSpec); +}; + + +}); diff --git a/plugins/pilot/types/basic.js b/plugins/pilot/types/basic.js new file mode 100644 index 00000000..8e7e5ebc --- /dev/null +++ b/plugins/pilot/types/basic.js @@ -0,0 +1,238 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Skywriter. + * + * The Initial Developer of the Original Code is + * Mozilla. + * Portions created by the Initial Developer are Copyright (C) 2009 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Joe Walker (jwalker@mozilla.com) + * Kevin Dangoor (kdangoor@mozilla.com) + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +define(function(require, exports, module) { + +var types = require("pilot/types"); +var Type = types.Type; +var Conversion = types.Conversion; +var Status = types.Status; + +/** + * These are the basic types that we accept. They are vaguely based on the + * Jetpack settings system (https://wiki.mozilla.org/Labs/Jetpack/JEP/24) + * although clearly more restricted. + * + *

In addition to these types, Jetpack also accepts range, member, password + * that we are thinking of adding. + * + *

This module probably should not be accessed directly, but instead used + * through types.js + */ + +/** + * 'text' is the default if no type is given. + */ +var text = new Type(); + +text.stringify = function(value) { + return value; +}; + +text.parse = function(value) { + if (typeof value != 'string') { + throw new Error('non-string passed to text.parse()'); + } + return new Conversion(value); +}; + +text.name = 'text'; + +/** + * We don't currently plan to distinguish between integers and floats + */ +var number = new Type(); + +number.stringify = function(value) { + if (!value) { + return null; + } + return '' + value; +}; + +number.parse = function(value) { + if (typeof value != 'string') { + throw new Error('non-string passed to number.parse()'); + } + + var reply = new Conversion(parseInt(value, 10)); + if (isNaN(reply.value)) { + reply.status = Status.INVALID; + reply.message = 'Can\'t convert "' + value + '" to a number.'; + } + + return reply; +}; + +number.name = 'number'; + +/** + * One of a known set of options + */ +function SelectionType(typeSpec) { + if (!Array.isArray(typeSpec.data) && typeof typeSpec.data !== 'function') { + throw new Error('instances of SelectionType need typeSpec.data to be an array or function that returns an array:' + JSON.stringify(typeSpec)); + } + Object.keys(typeSpec).forEach(function(key) { + this[key] = typeSpec[key]; + }, this); +}; + +SelectionType.prototype = new Type(); + +SelectionType.prototype.stringify = function(value) { + return value; +}; + +SelectionType.prototype.parse = function(value) { + if (typeof value != 'string') { + throw new Error('non-string passed to parse()'); + } + if (!this.data) { + throw new Error('Missing data on selection type extension.'); + } + var data = (typeof(this.data) === "function") ? this.data() : this.data; + + var match = false; + var completions = []; + data.forEach(function(option) { + if (value == option) { + match = true; + } + else if (option.indexOf(value) === 0) { + completions.push(option); + } + }); + + if (match) { + return new Conversion(value); + } + else { + var status = completions.length > 0 ? Status.INCOMPLETE : Status.INVALID; + + // TODO: better error message - include options? + // TODO: better completions - we're just using the extensions + return new Conversion(null, + status, + 'Can\'t convert \'' + value + '\' to a selection.', + completions); + } +}; + +SelectionType.prototype.name = 'selection'; + +/** + * SelectionType is a base class for other types + */ +exports.SelectionType = SelectionType; + +/** + * true/false values + */ +var bool = new SelectionType({ + name: 'bool', + data: [ 'true', 'false' ], + stringify: function(value) { + return '' + value; + }, + parse: function(value) { + var conversion = SelectionType.prototype.parse(value); + + if (conversion.value === 'true') { + conversion.value = true; + } + if (conversion.value === 'false') { + conversion.value = false; + } + + return conversion; + } +}); + + +/** + * One of a known set of options + */ +function DeferredType(typeSpec) { + if (typeof typeSpec.defer !== 'function') { + throw new Error('Instances of DeferredType need typeSpec.defer to be a function that returns a type'); + } + Object.keys(typeSpec).forEach(function(key) { + this[key] = typeSpec[key]; + }, this); +}; + +DeferredType.prototype = new Type(); + +DeferredType.prototype.stringify = function(value) { + return this.defer().stringify(value); +}; + +DeferredType.prototype.parse = function(value) { + console.log(this.defer); + return this.defer().parse(value); +}; + +DeferredType.prototype.name = 'deferred'; + +/** + * DeferredType is a base class for other types + */ +exports.DeferredType = DeferredType; + +/** + * Registration and de-registration. + */ +exports.startup = function() { + types.registerType(text); + types.registerType(number); + types.registerType(bool); + types.registerType(SelectionType); + types.registerType(DeferredType); +}; + +exports.shutdown = function() { + types.unregisterType(text); + types.unregisterType(number); + types.unregisterType(bool); + types.unregisterType(SelectionType); + types.unregisterType(DeferredType); +}; + + +}); diff --git a/plugins/pilot/types/command.js b/plugins/pilot/types/command.js new file mode 100644 index 00000000..b53fc19d --- /dev/null +++ b/plugins/pilot/types/command.js @@ -0,0 +1,82 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Skywriter. + * + * The Initial Developer of the Original Code is + * Mozilla. + * Portions created by the Initial Developer are Copyright (C) 2009 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Joe Walker (jwalker@mozilla.com) + * Kevin Dangoor (kdangoor@mozilla.com) + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +define(function(require, exports, module) { + +var canon = require("pilot/canon"); +var SelectionType = require("pilot/types/basic").SelectionType; +var types = require("pilot/types"); + + +/** + * Select from the available commands + */ +var command = new SelectionType({ + name: 'command', + data: function() { + return canon.getCommandNames(); + }, + stringify: function(command) { + return command.name; + }, + parse: function(value) { + var conversion = SelectionType.prototype.parse.call(this, value); + if (conversion.value) { + conversion.value = canon.getCommand(conversion.value); + } + else { + conversion.message = 'Several possibilities for \'' + value + '\''; + } + return conversion; + } +}); + + +/** + * Registration and de-registration. + */ +exports.startup = function() { + types.registerType(command); +}; + +exports.shutdown = function() { + types.unregisterType(command); +}; + + +}); diff --git a/plugins/pilot/types/settings.js b/plugins/pilot/types/settings.js new file mode 100644 index 00000000..587a1df7 --- /dev/null +++ b/plugins/pilot/types/settings.js @@ -0,0 +1,109 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Skywriter. + * + * The Initial Developer of the Original Code is + * Mozilla. + * Portions created by the Initial Developer are Copyright (C) 2009 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Joe Walker (jwalker@mozilla.com) + * Kevin Dangoor (kdangoor@mozilla.com) + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +define(function(require, exports, module) { + +var SelectionType = require('pilot/types/basic').SelectionType; +var DeferredType = require('pilot/types/basic').DeferredType; +var types = require('pilot/types'); +var settings = require('pilot/settings').settings; + + +/** + * EVIL: This relies on us using settingValue in the same event as setting + * The alternative is to have some central place where we store the current + * command line, but this might be a lesser evil for now. + */ +var lastSetting; + +/** + * Select from the available settings + */ +var setting = new SelectionType({ + name: 'setting', + data: function() { + return env.settings.getSettingNames(); + }, + stringify: function(setting) { + lastSetting = setting; + return setting.name; + }, + parse: function(text) { + lastSetting = text; + + var conversion = SelectionType.prototype.parse.call(this, text); + if (conversion.value) { + conversion.value = settings.getSetting(conversion.value); + } + else { + conversion.message = 'Several possibilities for \'' + text + '\''; + } + return conversion; + } +}); + +/** + * Something of a hack to allow the set command to give a clearer definition + * of the type to the command line. + */ +var settingValue = new DeferredType({ + name: 'settingValue', + defer: function() { + return env.settings.getSetting(lastSetting).type; + } +}); + +var env; + +/** + * Registration and de-registration. + */ +exports.startup = function(data, reason) { + // TODO: this is probably all kinds of evil, but we need something working + env = data.env; + types.registerType(setting); + types.registerType(settingValue); +}; + +exports.shutdown = function(data, reason) { + types.unregisterType(setting); + types.unregisterType(settingValue); +}; + + +}); diff --git a/plugins/pilot/util.js b/plugins/pilot/util.js new file mode 100644 index 00000000..e0cd4bb3 --- /dev/null +++ b/plugins/pilot/util.js @@ -0,0 +1,671 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Skywriter. + * + * The Initial Developer of the Original Code is + * Mozilla. + * Portions created by the Initial Developer are Copyright (C) 2009 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Skywriter Team (skywriter@mozilla.com) + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +define(function(require, exports, module) { + +/** + * Create an object representing a de-serialized query section of a URL. + * Query keys with multiple values are returned in an array. + *

Example: The input "foo=bar&foo=baz&thinger=%20spaces%20=blah&zonk=blarg&" + * Produces the output object: + *

{
+ *   foo: [ "bar", "baz" ],
+ *   thinger: " spaces =blah",
+ *   zonk: "blarg"
+ * }
+ * 
+ *

Note that spaces and other urlencoded entities are correctly handled + * @see dojo.queryToObject() + * While dojo.queryToObject() is mainly for URL query strings, this version + * allows to specify a separator character + */ +exports.queryToObject = function(str, seperator) { + var ret = {}; + var qp = str.split(seperator || "&"); + var dec = decodeURIComponent; + qp.forEach(function(item) { + if (item.length) { + var parts = item.split("="); + var name = dec(parts.shift()); + var val = dec(parts.join("=")); + if (exports.isString(ret[name])){ + ret[name] = [ret[name]]; + } + if (Array.isArray(ret[name])){ + ret[name].push(val); + } else { + ret[name] = val; + } + } + }); + return ret; +}; + +/** + * Takes a name/value mapping object and returns a string representing a + * URL-encoded version of that object for use in a GET request + *

For example, given the input: + * { blah: "blah", multi: [ "thud", "thonk" ] } + * The following string would be returned: + * "blah=blah&multi=thud&multi=thonk" + * @param map {Object} The object to convert + * @return {string} A URL-encoded version of the input + */ +exports.objectToQuery = function(map) { + // FIXME: need to implement encodeAscii!! + var enc = encodeURIComponent; + var pairs = []; + var backstop = {}; + for (var name in map) { + var value = map[name]; + if (value != backstop[name]) { + var assign = enc(name) + "="; + if (value.isArray) { + for (var i = 0; i < value.length; i++) { + pairs.push(assign + enc(value[i])); + } + } else { + pairs.push(assign + enc(value)); + } + } + } + return pairs.join("&"); +}; + +/** + * Holds the count to keep a unique value for setTimeout + * @private See rateLimit() + */ +var nextRateLimitId = 0; + +/** + * Holds the timeouts so they can be cleared later + * @private See rateLimit() + */ +var rateLimitTimeouts = {}; + +/** + * Delay calling some function to check that it's not called again inside a + * maxRate. The real function is called after maxRate ms unless the return + * value of this function is called before, in which case the clock is restarted + */ +exports.rateLimit = function(maxRate, scope, func) { + if (maxRate) { + var rateLimitId = nextRateLimitId++; + + return function() { + if (rateLimitTimeouts[rateLimitId]) { + clearTimeout(rateLimitTimeouts[rateLimitId]); + } + + rateLimitTimeouts[rateLimitId] = setTimeout(function() { + func.apply(scope, arguments); + delete rateLimitTimeouts[rateLimitId]; + }, maxRate); + }; + } +}; + +/** + * Return true if it is a String + */ +exports.isString = function(it) { + return (typeof it == "string" || it instanceof String); +}; + +/** + * Returns true if it is a Boolean. + */ +exports.isBoolean = function(it) { + return (typeof it == 'boolean'); +}; + +/** + * Returns true if it is a Number. + */ +exports.isNumber = function(it) { + return (typeof it == 'number' && isFinite(it)); +}; + +/** + * Hack copied from dojo. + */ +exports.isObject = function(it) { + return it !== undefined && + (it === null || typeof it == "object" || + Array.isArray(it) || exports.isFunction(it)); +}; + +/** + * Is the passed object a function? + * From dojo.isFunction() + */ +exports.isFunction = (function() { + var _isFunction = function(it) { + var t = typeof it; // must evaluate separately due to bizarre Opera bug. See #8937 + //Firefox thinks object HTML element is a function, so test for nodeType. + return it && (t == "function" || it instanceof Function) && !it.nodeType; // Boolean + }; + + return exports.isSafari ? + // only slow this down w/ gratuitious casting in Safari (not WebKit) + function(/*anything*/ it) { + if (typeof it == "function" && it == "[object NodeList]") { + return false; + } + return _isFunction(it); // Boolean + } : _isFunction; +})(); + +/** + * A la Prototype endsWith(). Takes a regex excluding the '$' end marker + */ +exports.endsWith = function(str, end) { + if (!str) { + return false; + } + return str.match(new RegExp(end + "$")); +}; + +/** + * A la Prototype include(). + */ +exports.include = function(array, item) { + return array.indexOf(item) > -1; +}; + +/** + * Like include, but useful when you're checking for a specific + * property on each object in the list... + * + * Returns null if the item is not in the list, otherwise + * returns the index of the item. + */ +exports.indexOfProperty = function(array, propertyName, item) { + for (var i = 0; i < array.length; i++) { + if (array[i][propertyName] == item) { + return i; + } + } + return null; +}; + +/** + * A la Prototype last(). + */ +exports.last = function(array) { + if (Array.isArray(array)) { + return array[array.length - 1]; + } +}; + +/** + * Knock off any undefined items from the end of an array + */ +exports.shrinkArray = function(array) { + var newArray = []; + + var stillAtBeginning = true; + array.reverse().forEach(function(item) { + if (stillAtBeginning && item === undefined) { + return; + } + + stillAtBeginning = false; + + newArray.push(item); + }); + + return newArray.reverse(); +}; + +/** + * Create an array + * @param number The size of the new array to create + * @param character The item to put in the array, defaults to ' ' + */ +exports.makeArray = function(number, character) { + if (number < 1) { + return []; // give us a normal number please! + } + if (!character){character = ' ';} + + var newArray = []; + for (var i = 0; i < number; i++) { + newArray.push(character); + } + return newArray; +}; + +/** + * Repeat a string a given number of times. + * @param string String to repeat + * @param repeat Number of times to repeat + */ +exports.repeatString = function(string, repeat) { + var newstring = ''; + + for (var i = 0; i < repeat; i++) { + newstring += string; + } + + return newstring; +}; + +/** + * Given a row, find the number of leading spaces. + * E.g. an array with the string " aposjd" would return 2 + * @param row The row to hunt through + */ +exports.leadingSpaces = function(row) { + var numspaces = 0; + for (var i = 0; i < row.length; i++) { + if (row[i] == ' ' || row[i] == '' || row[i] === undefined) { + numspaces++; + } else { + return numspaces; + } + } + return numspaces; +}; + +/** + * Given a row, find the number of leading tabs. + * E.g. an array with the string " aposjd" would return 2 + * @param row The row to hunt through + */ +exports.leadingTabs = function(row) { + var numtabs = 0; + for (var i = 0; i < row.length; i++) { + if (row[i] == ' ' || row[i] == '' || row[i] === undefined) { + numtabs++; + } else { + return numtabs; + } + } + return numtabs; +}; + +/** + * Given a row, extract a copy of the leading spaces or tabs. + * E.g. an array with the string " aposjd" would return an array with the + * string " ". + * @param row The row to hunt through + */ +exports.leadingWhitespace = function(row) { + var leading = []; + for (var i = 0; i < row.length; i++) { + if (row[i] == ' ' || row[i] == ' ' || row[i] == '' || row[i] === undefined) { + leading.push(row[i]); + } else { + return leading; + } + } + return leading; +}; + +/** + * Given a camelCaseWord convert to "Camel Case Word" + */ +exports.englishFromCamel = function(camel) { + camel.replace(/([A-Z])/g, function(str) { + return " " + str.toLowerCase(); + }).trim(); +}; + +/** + * I hate doing this, but we need some way to determine if the user is on a Mac + * The reason is that users have different expectations of their key combinations. + * + * Take copy as an example, Mac people expect to use CMD or APPLE + C + * Windows folks expect to use CTRL + C + */ +exports.OS = { + LINUX: 'LINUX', + MAC: 'MAC', + WINDOWS: 'WINDOWS' +}; + +var ua = navigator.userAgent; +var av = navigator.appVersion; + +/** Is the user using a browser that identifies itself as Linux */ +exports.isLinux = av.indexOf("Linux") >= 0; + +/** Is the user using a browser that identifies itself as Windows */ +exports.isWindows = av.indexOf("Win") >= 0; + +/** Is the user using a browser that identifies itself as WebKit */ +exports.isWebKit = parseFloat(ua.split("WebKit/")[1]) || undefined; + +/** Is the user using a browser that identifies itself as Chrome */ +exports.isChrome = parseFloat(ua.split("Chrome/")[1]) || undefined; + +/** Is the user using a browser that identifies itself as Mac OS */ +exports.isMac = av.indexOf("Macintosh") >= 0; + +/* Is this Firefox or related? */ +exports.isMozilla = av.indexOf('Gecko/') >= 0; + +if (ua.indexOf("AdobeAIR") >= 0) { + exports.isAIR = 1; +} + +/** + * Is the user using a browser that identifies itself as Safari + * See also: + * - http://developer.apple.com/internet/safari/faq.html#anchor2 + * - http://developer.apple.com/internet/safari/uamatrix.html + */ +var index = Math.max(av.indexOf("WebKit"), av.indexOf("Safari"), 0); +if (index && !exports.isChrome) { + // try to grab the explicit Safari version first. If we don't get + // one, look for less than 419.3 as the indication that we're on something + // "Safari 2-ish". + exports.isSafari = parseFloat(av.split("Version/")[1]); + if (!exports.isSafari || parseFloat(av.substr(index + 7)) <= 419.3) { + exports.isSafari = 2; + } +} + +if (ua.indexOf("Gecko") >= 0 && !exports.isWebKit) { + exports.isMozilla = parseFloat(av); +} + +/** + * Return a exports.OS constant + */ +exports.getOS = function() { + if (exports.isMac) { + return exports.OS['MAC']; + } else if (exports.isLinux) { + return exports.OS['LINUX']; + } else { + return exports.OS['WINDOWS']; + } +}; + +/** Returns true if the DOM element "b" is inside the element "a". */ +if (typeof(document) !== 'undefined' && document.compareDocumentPosition) { + exports.contains = function(a, b) { + return a.compareDocumentPosition(b) & 16; + }; +} else { + exports.contains = function(a, b) { + return a !== b && (a.contains ? a.contains(b) : true); + }; +} + +/** + * Prevents propagation and clobbers the default action of the passed event + */ +exports.stopEvent = function(ev) { + ev.preventDefault(); + ev.stopPropagation(); +}; + +/** + * Create a random password of the given length (default 16 chars) + */ +exports.randomPassword = function(length) { + length = length || 16; + var chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"; + var pass = ""; + for (var x = 0; x < length; x++) { + var charIndex = Math.floor(Math.random() * chars.length); + pass += chars.charAt(charIndex); + } + return pass; +}; + +/** + * Is the passed object free of members, i.e. are there any enumerable + * properties which the objects claims as it's own using hasOwnProperty() + */ +exports.isEmpty = function(object) { + for (var x in object) { + if (object.hasOwnProperty(x)) { + return false; + } + } + return true; +}; + +/** + * Does the name of a project indicate that it is owned by someone else + * TODO: This is a major hack. We really should have a File object that include + * separate owner information. + */ +exports.isMyProject = function(project) { + return project.indexOf("+") == -1; +}; + +/** + * Format a date as dd MMM yyyy + */ +exports.formatDate = function (date) { + if (!date) { + return "Unknown"; + } + return date.getDate() + " " + + exports.formatDate.shortMonths[date.getMonth()] + " " + + date.getFullYear(); +}; + +/** + * Month data for exports.formatDate + */ +exports.formatDate.shortMonths = [ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" ]; + +/** + * Add a CSS class to the list of classes on the given node + */ +exports.addClass = function(node, className) { + var parts = className.split(/\s+/); + var cls = " " + node.className + " "; + for (var i = 0, len = parts.length, c; i < len; ++i) { + c = parts[i]; + if (c && cls.indexOf(" " + c + " ") < 0) { + cls += c + " "; + } + } + node.className = cls.trim(); +}; + +/** + * Remove a CSS class from the list of classes on the given node + */ +exports.removeClass = function(node, className) { + var cls; + if (className !== undefined) { + var parts = className.split(/\s+/); + cls = " " + node.className + " "; + for (var i = 0, len = parts.length; i < len; ++i) { + cls = cls.replace(" " + parts[i] + " ", " "); + } + cls = cls.trim(); + } else { + cls = ""; + } + if (node.className != cls) { + node.className = cls; + } +}; + +/** + * Add or remove a CSS class from the list of classes on the given node + * depending on the value of include + */ +exports.setClass = function(node, className, include) { + if (include) { + exports.addClass(node, className); + } else { + exports.removeClass(node, className); + } +}; + +/** + * Is the passed object either null or undefined (using ===) + */ +exports.none = function(obj) { + return obj === null || obj === undefined; +}; + +/** + * Creates a clone of the passed object. This function can take just about + * any type of object and create a clone of it, including primitive values + * (which are not actually cloned because they are immutable). + * If the passed object implements the clone() method, then this function + * will simply call that method and return the result. + * + * @param object {Object} the object to clone + * @param deep {Boolean} do a deep clone? + * @returns {Object} the cloned object + */ +exports.clone = function(object, deep) { + if (Array.isArray(object) && !deep) { + return object.slice(); + } + + if (typeof object === 'object' || Array.isArray(object)) { + if (object === null) { + return null; + } + + var reply = (Array.isArray(object) ? [] : {}); + for (var key in object) { + if (deep && (typeof object[key] === 'object' + || Array.isArray(object[key]))) { + reply[key] = exports.clone(object[key], true); + } else { + reply[key] = object[key]; + } + } + return reply; + } + + if (object && typeof(object.clone) === 'function') { + return object.clone(); + } + + // That leaves numbers, booleans, undefined. Doesn't it? + return object; +}; + + +/** + * Helper method for extending one object with another + * Copies all properties from source to target. Returns the extended target + * object. + * Taken from John Resig, http://ejohn.org/blog/javascript-getters-and-setters/. + */ +exports.mixin = function(a, b) { + for (var i in b) { + var g = b.__lookupGetter__(i); + var s = b.__lookupSetter__(i); + + if (g || s) { + if (g) { + a.__defineGetter__(i, g); + } + if (s) { + a.__defineSetter__(i, s); + } + } else { + a[i] = b[i]; + } + } + + return a; +}; + +/** + * Basically taken from Sproutcore. + * Replaces the count items from idx with objects. + */ +exports.replace = function(arr, idx, amt, objects) { + return arr.slice(0, idx).concat(objects).concat(arr.slice(idx + amt)); +}; + +/** + * Return true if the two frames match. You can also pass only points or sizes. + * @param r1 {Rect} the first rect + * @param r2 {Rect} the second rect + * @param delta {Float} an optional delta that allows for rects that do not match exactly. Defaults to 0.1 + * @returns {Boolean} true if rects match + */ +exports.rectsEqual = function(r1, r2, delta) { + if (!r1 || !r2) { + return r1 == r2; + } + + if (!delta && delta !== 0) { + delta = 0.1; + } + + if ((r1.y != r2.y) && (Math.abs(r1.y - r2.y) > delta)) { + return false; + } + + if ((r1.x != r2.x) && (Math.abs(r1.x - r2.x) > delta)) { + return false; + } + + if ((r1.width != r2.width) && (Math.abs(r1.width - r2.width) > delta)) { + return false; + } + + if ((r1.height != r2.height) && (Math.abs(r1.height - r2.height) > delta)) { + return false; + } + + return true; +}; + +/** + * splice out of 'array' anything that === 'value' + */ +exports.arrayRemove = function(array, value) { + for (var i = 0; i <= array.length; i++) { + if (value === array[i]) { + array.splice(i, 1); + } + } +}; + + +}); diff --git a/tool/theme.tmpl.js b/tool/theme.tmpl.js index b4eed087..38a23553 100644 --- a/tool/theme.tmpl.js +++ b/tool/theme.tmpl.js @@ -1,10 +1,10 @@ define(function(require, exports, module) { - var dom = require("./lib/dom"); + var dom = require("pilot/dom"); var cssText = %css%; - + // import CSS once dom.importCssString(cssText); - + return { cssClass: "%cssClass%" };