Merge branch 'master' of github.com:ajaxorg/ace
This commit is contained in:
commit
d46de9b118
131 changed files with 10328 additions and 3257 deletions
26
build.js
26
build.js
|
|
@ -39,15 +39,15 @@
|
||||||
{
|
{
|
||||||
name: "ace/theme/eclipse",
|
name: "ace/theme/eclipse",
|
||||||
exclude: [
|
exclude: [
|
||||||
"ace/lib/lang",
|
"pilot/lang",
|
||||||
"ace/lib/dom",
|
"pilot/dom",
|
||||||
"ace/lib/oop"
|
"pilot/oop"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "ace/mode/xml",
|
name: "ace/mode/xml",
|
||||||
exclude: [
|
exclude: [
|
||||||
"ace/lib/oop",
|
"pilot/oop",
|
||||||
"ace/tokenizer",
|
"ace/tokenizer",
|
||||||
"ace/mode/text"
|
"ace/mode/text"
|
||||||
]
|
]
|
||||||
|
|
@ -55,8 +55,8 @@
|
||||||
{
|
{
|
||||||
name: "ace/mode/css",
|
name: "ace/mode/css",
|
||||||
exclude: [
|
exclude: [
|
||||||
"ace/lib/oop",
|
"pilot/oop",
|
||||||
"ace/lib/lang",
|
"pilot/lang",
|
||||||
"ace/tokenizer",
|
"ace/tokenizer",
|
||||||
"ace/range",
|
"ace/range",
|
||||||
"ace/mode/text"
|
"ace/mode/text"
|
||||||
|
|
@ -65,14 +65,24 @@
|
||||||
{
|
{
|
||||||
name: "ace/mode/html",
|
name: "ace/mode/html",
|
||||||
exclude: [
|
exclude: [
|
||||||
"ace/lib/oop",
|
"pilot/oop",
|
||||||
"ace/lib/lang",
|
"pilot/lang",
|
||||||
"ace/tokenizer",
|
"ace/tokenizer",
|
||||||
"ace/range",
|
"ace/range",
|
||||||
"ace/mode/text",
|
"ace/mode/text",
|
||||||
"ace/mode/javascript",
|
"ace/mode/javascript",
|
||||||
"ace/mode/css",
|
"ace/mode/css",
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "ace/mode/python",
|
||||||
|
exclude: [
|
||||||
|
"ace/lib/oop",
|
||||||
|
"ace/lib/lang",
|
||||||
|
"ace/tokenizer",
|
||||||
|
"ace/range",
|
||||||
|
"ace/mode/text"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
define(function() {
|
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",
|
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",
|
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"}
|
||||||
});
|
});
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
define(function() {
|
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",
|
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"}
|
del:"Delete", backspace:"Backspace", outdent:"Shift-Tab", indent:"Tab"}
|
||||||
});
|
});
|
||||||
|
|
@ -327,7 +327,7 @@ define(function(g) {
|
||||||
}this.modified = true;
|
}this.modified = true;
|
||||||
b = a.start.row;
|
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);
|
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
|
return a.start
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
1904
build/ace/editor.js
1904
build/ace/editor.js
File diff suppressed because it is too large
Load diff
|
|
@ -67,6 +67,7 @@ define(function(k) {
|
||||||
};
|
};
|
||||||
this.updateLines = function(a, b, e) {
|
this.updateLines = function(a, b, e) {
|
||||||
this.$computeTabString();
|
this.$computeTabString();
|
||||||
|
this.config = a;
|
||||||
var f = Math.max(b, a.firstRow), c = Math.min(e, a.lastRow), d = this.element.childNodes, h = this;
|
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) {
|
this.tokenizer.getTokens(f, c, function(i) {
|
||||||
for(var g = f;g <= c;g++) {
|
for(var g = f;g <= c;g++) {
|
||||||
|
|
@ -128,6 +129,7 @@ define(function(k) {
|
||||||
};
|
};
|
||||||
this.update = function(a) {
|
this.update = function(a) {
|
||||||
this.$computeTabString();
|
this.$computeTabString();
|
||||||
|
this.config = a;
|
||||||
var b = [], e = this;
|
var b = [], e = this;
|
||||||
this.tokenizer.getTokens(a.firstRow, a.lastRow, function(f) {
|
this.tokenizer.getTokens(a.firstRow, a.lastRow, function(f) {
|
||||||
for(var c = a.firstRow;c <= a.lastRow;c++) {
|
for(var c = a.firstRow;c <= a.lastRow;c++) {
|
||||||
|
|
|
||||||
|
|
@ -6,53 +6,55 @@ define(function(f) {
|
||||||
};
|
};
|
||||||
h.inherits(f, i);
|
h.inherits(f, i);
|
||||||
(function() {
|
(function() {
|
||||||
this.toggleCommentLines = function(d, b, e) {
|
this.toggleCommentLines = function(c, d, e) {
|
||||||
var c = true;
|
var a = true;
|
||||||
d = /^(\s*)\/\//;
|
c = /^(\s*)\/\//;
|
||||||
for(var a = e.start.row;a <= e.end.row;a++) {
|
for(var b = e.start.row;b <= e.end.row;b++) {
|
||||||
if(!d.test(b.getLine(a))) {
|
if(!c.test(d.getLine(b))) {
|
||||||
c = false;
|
a = false;
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}if(c) {
|
}if(a) {
|
||||||
c = new m(0, 0, 0, 0);
|
a = new m(0, 0, 0, 0);
|
||||||
for(a = e.start.row;a <= e.end.row;a++) {
|
for(b = e.start.row;b <= e.end.row;b++) {
|
||||||
var g = b.getLine(a).replace(d, "$1");
|
var g = d.getLine(b).replace(c, "$1");
|
||||||
c.start.row = a;
|
a.start.row = b;
|
||||||
c.end.row = a;
|
a.end.row = b;
|
||||||
c.end.column = g.length + 2;
|
a.end.column = g.length + 2;
|
||||||
b.replace(c, g)
|
d.replace(a, g)
|
||||||
}return-2
|
}return-2
|
||||||
}else {
|
}else {
|
||||||
return b.indentRows(e, "//")
|
return d.indentRows(e, "//")
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
this.getNextLineIndent = function(d, b, e) {
|
this.getNextLineIndent = function(c, d, e) {
|
||||||
var c = this.$getIndent(b), a = this.$tokenizer.getLineTokens(b, d), g = a.tokens;
|
var a = this.$getIndent(d), b = this.$tokenizer.getLineTokens(d, c), g = b.tokens;
|
||||||
a = a.state;
|
b = b.state;
|
||||||
if(g.length && g[g.length - 1].type == "comment") {
|
if(g.length && g[g.length - 1].type == "comment") {
|
||||||
return c
|
return a
|
||||||
}if(d == "start") {
|
}if(c == "start") {
|
||||||
if(d = b.match(/^.*[\{\(\[]\s*$/)) {
|
if(c = d.match(/^.*[\{\(\[]\s*$/)) {
|
||||||
c += e
|
a += e
|
||||||
}
|
}
|
||||||
}else {
|
}else {
|
||||||
if(d == "doc-start") {
|
if(c == "doc-start") {
|
||||||
if(a == "start") {
|
if(b == "start") {
|
||||||
return""
|
return""
|
||||||
}if(d = b.match(/^\s*(\/?)\*/)) {
|
}if(c = d.match(/^\s*(\/?)\*/)) {
|
||||||
if(d[1]) {
|
if(c[1]) {
|
||||||
c += " "
|
a += " "
|
||||||
}c += "* "
|
}a += "* "
|
||||||
|
}if(c[1]) {
|
||||||
|
a += " "
|
||||||
|
}a += "* "
|
||||||
}
|
}
|
||||||
}
|
}return a
|
||||||
}return c
|
|
||||||
};
|
};
|
||||||
this.checkOutdent = function(d, b, e) {
|
this.checkOutdent = function(c, d, e) {
|
||||||
return this.$outdent.checkOutdent(b, e)
|
return this.$outdent.checkOutdent(d, e)
|
||||||
};
|
};
|
||||||
this.autoOutdent = function(d, b, e) {
|
this.autoOutdent = function(c, d, e) {
|
||||||
return this.$outdent.autoOutdent(b, e)
|
return this.$outdent.autoOutdent(d, e)
|
||||||
}
|
}
|
||||||
}).call(f.prototype);
|
}).call(f.prototype);
|
||||||
return f
|
return f
|
||||||
|
|
|
||||||
93
build/ace/mode/python.js
Normal file
93
build/ace/mode/python.js
Normal file
|
|
@ -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
|
||||||
|
});
|
||||||
15
build/ace/mode/python_highlight_rules.js
Normal file
15
build/ace/mode/python_highlight_rules.js
Normal file
|
|
@ -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
|
||||||
|
});
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
define(function(c) {
|
define(function(d) {
|
||||||
var e = c("./lib/event");
|
var e = d("./lib/event");
|
||||||
c = function(b) {
|
d = function(b) {
|
||||||
this.onRender = b;
|
this.onRender = b;
|
||||||
this.pending = false;
|
this.pending = false;
|
||||||
this.changes = 0
|
this.changes = 0
|
||||||
|
|
@ -13,8 +13,9 @@ define(function(c) {
|
||||||
var a = this;
|
var a = this;
|
||||||
this.setTimeoutZero(function() {
|
this.setTimeoutZero(function() {
|
||||||
a.pending = false;
|
a.pending = false;
|
||||||
a.onRender(a.changes);
|
var c = a.changes;
|
||||||
a.changes = 0
|
a.changes = 0;
|
||||||
|
a.onRender(c)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -23,9 +24,9 @@ define(function(c) {
|
||||||
this.setTimeoutZero = function(b) {
|
this.setTimeoutZero = function(b) {
|
||||||
if(!this.attached) {
|
if(!this.attached) {
|
||||||
var a = this;
|
var a = this;
|
||||||
e.addListener(window, "message", function(d) {
|
e.addListener(window, "message", function(c) {
|
||||||
if(d.source == window && a.callback && d.data == a.messageName) {
|
if(c.source == window && a.callback && c.data == a.messageName) {
|
||||||
e.stopPropagation(d);
|
e.stopPropagation(c);
|
||||||
a.callback()
|
a.callback()
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -38,6 +39,6 @@ define(function(c) {
|
||||||
setTimeout(b, 0)
|
setTimeout(b, 0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}).call(c.prototype);
|
}).call(d.prototype);
|
||||||
return c
|
return d
|
||||||
});
|
});
|
||||||
|
|
@ -1,16 +0,0 @@
|
||||||
/*
|
|
||||||
LGPLv3 <http://www.gnu.org/licenses/lgpl-3.0.txt>
|
|
||||||
*/
|
|
||||||
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))
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
@ -1,79 +0,0 @@
|
||||||
/*
|
|
||||||
LGPLv3 <http://www.gnu.org/licenses/lgpl-3.0.txt>
|
|
||||||
*/
|
|
||||||
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)
|
|
||||||
}})
|
|
||||||
});
|
|
||||||
|
|
@ -1,148 +1,153 @@
|
||||||
/*
|
/*
|
||||||
LGPLv3 <http://www.gnu.org/licenses/lgpl-3.0.txt>
|
LGPLv3 <http://www.gnu.org/licenses/lgpl-3.0.txt>
|
||||||
*/
|
*/
|
||||||
require.def(["ace/Document", "ace/UndoManager", "ace/Editor", "ace/test/MockRenderer"], function(b, h, i, j) {
|
require("../../../support/paths");
|
||||||
new TestCase("TextDocumentTest", {"test: find matching opening bracket":function() {
|
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 b(["(()(", "())))"]);
|
var a = new Document(["(()(", "())))"]);
|
||||||
assertPosition(0, 1, a.findMatchingBracket({row:0, column:3}));
|
assert.position(a.findMatchingBracket({row:0, column:3}), 0, 1);
|
||||||
assertPosition(1, 0, a.findMatchingBracket({row:1, column:2}));
|
assert.position(a.findMatchingBracket({row:1, column:2}), 1, 0);
|
||||||
assertPosition(0, 3, a.findMatchingBracket({row:1, column:3}));
|
assert.position(a.findMatchingBracket({row:1, column:3}), 0, 3);
|
||||||
assertPosition(0, 0, a.findMatchingBracket({row:1, column:4}));
|
assert.position(a.findMatchingBracket({row:1, column:4}), 0, 0);
|
||||||
assertEquals(null, a.findMatchingBracket({row:1, column:5}))
|
assert.equal(a.findMatchingBracket({row:1, column:5}), null)
|
||||||
}, "test: find matching closing bracket":function() {
|
}, "test: find matching closing bracket":function() {
|
||||||
var a = new b(["(()(", "())))"]);
|
var a = new Document(["(()(", "())))"]);
|
||||||
assertPosition(1, 1, a.findMatchingBracket({row:1, column:1}));
|
assert.position(a.findMatchingBracket({row:1, column:1}), 1, 1);
|
||||||
assertPosition(1, 1, a.findMatchingBracket({row:1, column:1}));
|
assert.position(a.findMatchingBracket({row:1, column:1}), 1, 1);
|
||||||
assertPosition(1, 2, a.findMatchingBracket({row:0, column:4}));
|
assert.position(a.findMatchingBracket({row:0, column:4}), 1, 2);
|
||||||
assertPosition(0, 2, a.findMatchingBracket({row:0, column:2}));
|
assert.position(a.findMatchingBracket({row:0, column:2}), 0, 2);
|
||||||
assertPosition(1, 3, a.findMatchingBracket({row:0, column:1}));
|
assert.position(a.findMatchingBracket({row:0, column:1}), 1, 3);
|
||||||
assertEquals(null, a.findMatchingBracket({row:0, column:0}))
|
assert.equal(a.findMatchingBracket({row:0, column:0}), null)
|
||||||
}, "test: match different bracket types":function() {
|
}, "test: match different bracket types":function() {
|
||||||
var a = new b(["({[", ")]}"]);
|
var a = new Document(["({[", ")]}"]);
|
||||||
assertPosition(1, 0, a.findMatchingBracket({row:0, column:1}));
|
assert.position(a.findMatchingBracket({row:0, column:1}), 1, 0);
|
||||||
assertPosition(1, 2, a.findMatchingBracket({row:0, column:2}));
|
assert.position(a.findMatchingBracket({row:0, column:2}), 1, 2);
|
||||||
assertPosition(1, 1, a.findMatchingBracket({row:0, column:3}));
|
assert.position(a.findMatchingBracket({row:0, column:3}), 1, 1);
|
||||||
assertPosition(0, 0, a.findMatchingBracket({row:1, column:1}));
|
assert.position(a.findMatchingBracket({row:1, column:1}), 0, 0);
|
||||||
assertPosition(0, 2, a.findMatchingBracket({row:1, column:2}));
|
assert.position(a.findMatchingBracket({row:1, column:2}), 0, 2);
|
||||||
assertPosition(0, 1, a.findMatchingBracket({row:1, column:3}))
|
assert.position(a.findMatchingBracket({row:1, column:3}), 0, 1)
|
||||||
}, "test: move lines down":function() {
|
}, "test: move lines down":function() {
|
||||||
var a = new b(["1", "2", "3", "4"]);
|
var a = new Document(["1", "2", "3", "4"]);
|
||||||
|
console.log(a.toString().replace(/\n/g, "\\n"));
|
||||||
a.moveLinesDown(0, 1);
|
a.moveLinesDown(0, 1);
|
||||||
assertEquals("3\n1\n2\n4", a.toString());
|
console.log(a.toString().replace(/\n/g, "\\n"));
|
||||||
|
assert.equal(a.toString(), "3\n1\n2\n4");
|
||||||
a.moveLinesDown(1, 2);
|
a.moveLinesDown(1, 2);
|
||||||
assertEquals("3\n4\n1\n2", a.toString());
|
assert.equal(a.toString(), "3\n4\n1\n2");
|
||||||
a.moveLinesDown(2, 3);
|
a.moveLinesDown(2, 3);
|
||||||
assertEquals("3\n4\n1\n2", a.toString());
|
assert.equal(a.toString(), "3\n4\n1\n2");
|
||||||
a.moveLinesDown(2, 2);
|
a.moveLinesDown(2, 2);
|
||||||
assertEquals("3\n4\n2\n1", a.toString())
|
assert.equal(a.toString(), "3\n4\n2\n1")
|
||||||
}, "test: move lines up":function() {
|
}, "__test: move lines up":function() {
|
||||||
var a = new b(["1", "2", "3", "4"]);
|
var a = new Document(["1", "2", "3", "4"]);
|
||||||
|
console.log(a.toString().replace(/\n/g, "\\n"));
|
||||||
a.moveLinesUp(2, 3);
|
a.moveLinesUp(2, 3);
|
||||||
assertEquals("1\n3\n4\n2", a.toString());
|
console.log(a.toString().replace(/\n/g, "\\n"));
|
||||||
|
assert.equal(a.toString(), "1\n3\n4\n2");
|
||||||
a.moveLinesUp(1, 2);
|
a.moveLinesUp(1, 2);
|
||||||
assertEquals("3\n4\n1\n2", a.toString());
|
assert.equal(a.toString(), "3\n4\n1\n2");
|
||||||
a.moveLinesUp(0, 1);
|
a.moveLinesUp(0, 1);
|
||||||
assertEquals("3\n4\n1\n2", a.toString());
|
assert.equal(a.toString(), "3\n4\n1\n2");
|
||||||
a.moveLinesUp(2, 2);
|
a.moveLinesUp(2, 2);
|
||||||
assertEquals("3\n1\n4\n2", a.toString())
|
assert.equal(a.toString(), "3\n1\n4\n2")
|
||||||
}, "test: duplicate lines":function() {
|
}, "test: duplicate lines":function() {
|
||||||
var a = new b(["1", "2", "3", "4"]);
|
var a = new Document(["1", "2", "3", "4"]);
|
||||||
a.duplicateLines(1, 2);
|
a.duplicateLines(1, 2);
|
||||||
assertEquals("1\n2\n3\n2\n3\n4", a.toString())
|
assert.equal(a.toString(), "1\n2\n3\n2\n3\n4")
|
||||||
}, "test: duplicate last line":function() {
|
}, "test: duplicate last line":function() {
|
||||||
var a = new b(["1", "2", "3"]);
|
var a = new Document(["1", "2", "3"]);
|
||||||
a.duplicateLines(2, 2);
|
a.duplicateLines(2, 2);
|
||||||
assertEquals("1\n2\n3\n3", a.toString())
|
assert.equal(a.toString(), "1\n2\n3\n3")
|
||||||
}, "test: duplicate first line":function() {
|
}, "test: duplicate first line":function() {
|
||||||
var a = new b(["1", "2", "3"]);
|
var a = new Document(["1", "2", "3"]);
|
||||||
a.duplicateLines(0, 0);
|
a.duplicateLines(0, 0);
|
||||||
assertEquals("1\n1\n2\n3", a.toString())
|
assert.equal(a.toString(), "1\n1\n2\n3")
|
||||||
}, "test: should handle unix style new lines":function() {
|
}, "test: should handle unix style new lines":function() {
|
||||||
var a = new b(["1", "2", "3"]);
|
var a = new Document(["1", "2", "3"]);
|
||||||
assertEquals("1\n2\n3", a.toString())
|
assert.equal(a.toString(), "1\n2\n3")
|
||||||
}, "test: should handle windows style new lines":function() {
|
}, "test: should handle windows style new lines":function() {
|
||||||
var a = new b("1\r\n2\r\n3");
|
var a = new Document("1\r\n2\r\n3");
|
||||||
a.setNewLineMode("unix");
|
a.setNewLineMode("unix");
|
||||||
assertEquals("1\n2\n3", a.toString())
|
assert.equal(a.toString(), "1\n2\n3")
|
||||||
}, "test: set new line mode to 'windows' should use '\r\n' as new lines":function() {
|
}, "test: set new line mode to 'windows' should use '\r\n' as new lines":function() {
|
||||||
var a = new b("1\n2\n3");
|
var a = new Document("1\n2\n3");
|
||||||
a.setNewLineMode("windows");
|
a.setNewLineMode("windows");
|
||||||
assertEquals("1\r\n2\r\n3", a.toString())
|
assert.equal(a.toString(), "1\r\n2\r\n3")
|
||||||
}, "test: set new line mode to 'unix' should use '\n' as new lines":function() {
|
}, "test: set new line mode to 'unix' should use '\n' as new lines":function() {
|
||||||
var a = new b("1\r\n2\r\n3");
|
var a = new Document("1\r\n2\r\n3");
|
||||||
a.setNewLineMode("unix");
|
a.setNewLineMode("unix");
|
||||||
assertEquals("1\n2\n3", a.toString())
|
assert.equal(a.toString(), "1\n2\n3")
|
||||||
}, "test: set new line mode to 'auto' should use detect the incoming nl type":function() {
|
}, "test: set new line mode to 'auto' should detect the incoming nl type":function() {
|
||||||
var a = new b("1\n2\n3");
|
var a = new Document("1\n2\n3");
|
||||||
a.setNewLineMode("auto");
|
a.setNewLineMode("auto");
|
||||||
assertEquals("1\n2\n3", a.toString());
|
assert.equal(a.toString(), "1\n2\n3");
|
||||||
a = new b("1\r\n2\r\n3");
|
a = new Document("1\r\n2\r\n3");
|
||||||
a.setNewLineMode("auto");
|
a.setNewLineMode("auto");
|
||||||
assertEquals("1\r\n2\r\n3", a.toString());
|
assert.equal(a.toString(), "1\r\n2\r\n3");
|
||||||
a.replace(new Range(0, 0, 2, 1), "4\n5\n6");
|
a.replace(new Range(0, 0, 2, 1), "4\n5\n6");
|
||||||
assertEquals("4\n5\n6", a.toString())
|
assert.equal("4\n5\n6", a.toString())
|
||||||
}, "test: undo/redo for delete line":function() {
|
}, "__test: undo/redo for delete line":function() {
|
||||||
var a = new b(["111", "222", "333"]), c = new h;
|
var a = new Document(["111", "222", "333"]), b = new UndoManager;
|
||||||
a.setUndoManager(c);
|
a.setUndoManager(b);
|
||||||
var e = a.toString(), d = new i(new j, a);
|
var d = a.toString(), c = new Editor(new MockRenderer, a);
|
||||||
d.removeLines();
|
c.removeLines();
|
||||||
|
var e = a.toString();
|
||||||
|
assert.equal(e, "222\n333");
|
||||||
|
a.$informUndoManager.call();
|
||||||
|
c.removeLines();
|
||||||
var f = a.toString();
|
var f = a.toString();
|
||||||
assertEquals("222\n333", f);
|
assert.equal(f, "333");
|
||||||
a.$informUndoManager.call();
|
a.$informUndoManager.call();
|
||||||
d.removeLines();
|
c.removeLines();
|
||||||
var g = a.toString();
|
c = a.toString();
|
||||||
assertEquals("333", g);
|
assert.equal(c, "");
|
||||||
a.$informUndoManager.call();
|
a.$informUndoManager.call();
|
||||||
d.removeLines();
|
b.undo();
|
||||||
d = a.toString();
|
|
||||||
assertEquals("", d);
|
|
||||||
a.$informUndoManager.call();
|
a.$informUndoManager.call();
|
||||||
c.undo();
|
assert.equal(a.toString(), f);
|
||||||
|
b.undo();
|
||||||
a.$informUndoManager.call();
|
a.$informUndoManager.call();
|
||||||
assertEquals(g, a.toString());
|
assert.equal(a.toString(), e);
|
||||||
c.undo();
|
b.undo();
|
||||||
a.$informUndoManager.call();
|
a.$informUndoManager.call();
|
||||||
assertEquals(f, a.toString());
|
assert.equal(a.toString(), d);
|
||||||
c.undo();
|
b.undo();
|
||||||
a.$informUndoManager.call();
|
a.$informUndoManager.call();
|
||||||
assertEquals(e, a.toString());
|
assert.equal(a.toString(), d)
|
||||||
c.undo();
|
}, "test: convert document to screen coordinates":function() {
|
||||||
a.$informUndoManager.call();
|
var a = new Document("01234\t567890\t1234");
|
||||||
assertEquals(e, a.toString())
|
|
||||||
}, "test: convert document to screen coordinates":function() {
|
|
||||||
var a = new b("01234\t567890\t1234");
|
|
||||||
a.setTabSize(4);
|
a.setTabSize(4);
|
||||||
assertEquals(0, a.documentToScreenColumn(0, 0));
|
assert.equal(a.documentToScreenColumn(0, 0), 0);
|
||||||
assertEquals(4, a.documentToScreenColumn(0, 4));
|
assert.equal(a.documentToScreenColumn(0, 4), 4);
|
||||||
assertEquals(5, a.documentToScreenColumn(0, 5));
|
assert.equal(a.documentToScreenColumn(0, 5), 5);
|
||||||
assertEquals(9, a.documentToScreenColumn(0, 6));
|
assert.equal(a.documentToScreenColumn(0, 6), 9);
|
||||||
assertEquals(15, a.documentToScreenColumn(0, 12));
|
assert.equal(a.documentToScreenColumn(0, 12), 15);
|
||||||
assertEquals(19, a.documentToScreenColumn(0, 13));
|
assert.equal(a.documentToScreenColumn(0, 13), 19);
|
||||||
a.setTabSize(2);
|
a.setTabSize(2);
|
||||||
assertEquals(0, a.documentToScreenColumn(0, 0));
|
assert.equal(a.documentToScreenColumn(0, 0), 0);
|
||||||
assertEquals(4, a.documentToScreenColumn(0, 4));
|
assert.equal(a.documentToScreenColumn(0, 4), 4);
|
||||||
assertEquals(5, a.documentToScreenColumn(0, 5));
|
assert.equal(a.documentToScreenColumn(0, 5), 5);
|
||||||
assertEquals(7, a.documentToScreenColumn(0, 6));
|
assert.equal(a.documentToScreenColumn(0, 6), 7);
|
||||||
assertEquals(13, a.documentToScreenColumn(0, 12));
|
assert.equal(a.documentToScreenColumn(0, 12), 13);
|
||||||
assertEquals(15, a.documentToScreenColumn(0, 13))
|
assert.equal(a.documentToScreenColumn(0, 13), 15)
|
||||||
}, "test: convert document to scrren coordinates with leading tabs":function() {
|
}, "test: convert document to scrren coordinates with leading tabs":function() {
|
||||||
var a = new b("\t\t123");
|
var a = new Document("\t\t123");
|
||||||
a.setTabSize(4);
|
a.setTabSize(4);
|
||||||
assertEquals(0, a.documentToScreenColumn(0, 0));
|
assert.equal(a.documentToScreenColumn(0, 0), 0);
|
||||||
assertEquals(4, a.documentToScreenColumn(0, 1));
|
assert.equal(a.documentToScreenColumn(0, 1), 4);
|
||||||
assertEquals(8, a.documentToScreenColumn(0, 2));
|
assert.equal(a.documentToScreenColumn(0, 2), 8);
|
||||||
assertEquals(9, a.documentToScreenColumn(0, 3))
|
assert.equal(a.documentToScreenColumn(0, 3), 9)
|
||||||
}, "test: convert screen to document coordinates":function() {
|
}, "test: convert screen to document coordinates":function() {
|
||||||
var a = new b("01234\t567890\t1234");
|
var a = new Document("01234\t567890\t1234");
|
||||||
a.setTabSize(4);
|
a.setTabSize(4);
|
||||||
assertEquals(0, a.screenToDocumentColumn(0, 0));
|
assert.equal(a.screenToDocumentColumn(0, 0), 0);
|
||||||
assertEquals(4, a.screenToDocumentColumn(0, 4));
|
assert.equal(a.screenToDocumentColumn(0, 4), 4);
|
||||||
assertEquals(5, a.screenToDocumentColumn(0, 5));
|
assert.equal(a.screenToDocumentColumn(0, 5), 5);
|
||||||
assertEquals(5, a.screenToDocumentColumn(0, 6));
|
assert.equal(a.screenToDocumentColumn(0, 6), 5);
|
||||||
assertEquals(5, a.screenToDocumentColumn(0, 7));
|
assert.equal(a.screenToDocumentColumn(0, 7), 5);
|
||||||
assertEquals(5, a.screenToDocumentColumn(0, 8));
|
assert.equal(a.screenToDocumentColumn(0, 8), 5);
|
||||||
assertEquals(6, a.screenToDocumentColumn(0, 9));
|
assert.equal(a.screenToDocumentColumn(0, 9), 6);
|
||||||
assertEquals(12, a.screenToDocumentColumn(0, 15));
|
assert.equal(a.screenToDocumentColumn(0, 15), 12);
|
||||||
assertEquals(13, a.screenToDocumentColumn(0, 19))
|
assert.equal(a.screenToDocumentColumn(0, 19), 13)
|
||||||
}})
|
}};
|
||||||
});
|
module.exports = require("async/test").testcase(Test);
|
||||||
|
module === require.main && module.exports.exec();
|
||||||
|
|
@ -1,17 +0,0 @@
|
||||||
/*
|
|
||||||
LGPLv3 <http://www.gnu.org/licenses/lgpl-3.0.txt>
|
|
||||||
*/
|
|
||||||
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)
|
|
||||||
}})
|
|
||||||
});
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
LGPLv3 <http://www.gnu.org/licenses/lgpl-3.0.txt>
|
LGPLv3 <http://www.gnu.org/licenses/lgpl-3.0.txt>
|
||||||
*/
|
*/
|
||||||
require.def([], function() {
|
define(function() {
|
||||||
MockRenderer = function(a) {
|
MockRenderer = function(a) {
|
||||||
this.container = document.createElement("div");
|
this.container = document.createElement("div");
|
||||||
this.cursor = {row:0, column:0};
|
this.cursor = {row:0, column:0};
|
||||||
|
|
@ -52,5 +52,11 @@ require.def([], function() {
|
||||||
};
|
};
|
||||||
MockRenderer.prototype.setBreakpoints = function() {
|
MockRenderer.prototype.setBreakpoints = function() {
|
||||||
};
|
};
|
||||||
|
MockRenderer.prototype.updateFull = function() {
|
||||||
|
};
|
||||||
|
MockRenderer.prototype.showCursor = function() {
|
||||||
|
};
|
||||||
|
MockRenderer.prototype.visualizeFocus = function() {
|
||||||
|
};
|
||||||
return MockRenderer
|
return MockRenderer
|
||||||
});
|
});
|
||||||
|
|
@ -1,77 +0,0 @@
|
||||||
/*
|
|
||||||
LGPLv3 <http://www.gnu.org/licenses/lgpl-3.0.txt>
|
|
||||||
*/
|
|
||||||
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())
|
|
||||||
}})
|
|
||||||
});
|
|
||||||
|
|
@ -1,74 +0,0 @@
|
||||||
/*
|
|
||||||
LGPLv3 <http://www.gnu.org/licenses/lgpl-3.0.txt>
|
|
||||||
*/
|
|
||||||
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)
|
|
||||||
}})
|
|
||||||
});
|
|
||||||
|
|
@ -1,135 +1,135 @@
|
||||||
/*
|
/*
|
||||||
LGPLv3 <http://www.gnu.org/licenses/lgpl-3.0.txt>
|
LGPLv3 <http://www.gnu.org/licenses/lgpl-3.0.txt>
|
||||||
*/
|
*/
|
||||||
require.def(["ace/Document", "ace/Search"], function(c, b) {
|
require("../../../support/paths");
|
||||||
new TestCase("SearchTest", {"test: configure the search object":function() {
|
var Document = require("../document"), Search = require("../search"), assert = require("./assertions"), Test = {"test: configure the search object":function() {
|
||||||
(new b).set({needle:"juhu", scope:b.ALL})
|
(new Search).set({needle:"juhu", scope:Search.ALL})
|
||||||
}, "test: find simple text in document":function() {
|
}, "test: find simple text in document":function() {
|
||||||
var a = new c(["juhu kinners 123", "456"]);
|
var a = new Document(["juhu kinners 123", "456"]);
|
||||||
a = (new b).set({needle:"kinners"}).find(a);
|
a = (new Search).set({needle:"kinners"}).find(a);
|
||||||
assertPosition(0, 5, a.start);
|
assert.position(a.start, 0, 5);
|
||||||
assertPosition(0, 12, a.end)
|
assert.position(a.end, 0, 12)
|
||||||
}, "test: find simple text in next line":function() {
|
}, "test: find simple text in next line":function() {
|
||||||
var a = new c(["abc", "juhu kinners 123", "456"]);
|
var a = new Document(["abc", "juhu kinners 123", "456"]);
|
||||||
a = (new b).set({needle:"kinners"}).find(a);
|
a = (new Search).set({needle:"kinners"}).find(a);
|
||||||
assertPosition(1, 5, a.start);
|
assert.position(a.start, 1, 5);
|
||||||
assertPosition(1, 12, a.end)
|
assert.position(a.end, 1, 12)
|
||||||
}, "test: find text starting at cursor position":function() {
|
}, "test: find text starting at cursor position":function() {
|
||||||
var a = new c(["juhu kinners", "juhu kinners 123"]);
|
var a = new Document(["juhu kinners", "juhu kinners 123"]);
|
||||||
a.getSelection().moveCursorTo(0, 6);
|
a.getSelection().moveCursorTo(0, 6);
|
||||||
a = (new b).set({needle:"kinners"}).find(a);
|
a = (new Search).set({needle:"kinners"}).find(a);
|
||||||
assertPosition(1, 5, a.start);
|
assert.position(a.start, 1, 5);
|
||||||
assertPosition(1, 12, a.end)
|
assert.position(a.end, 1, 12)
|
||||||
}, "test: wrap search is off by default":function() {
|
}, "test: wrap search is off by default":function() {
|
||||||
var a = new c(["abc", "juhu kinners 123", "456"]);
|
var a = new Document(["abc", "juhu kinners 123", "456"]);
|
||||||
a.getSelection().moveCursorTo(2, 1);
|
a.getSelection().moveCursorTo(2, 1);
|
||||||
var d = (new b).set({needle:"kinners"});
|
var b = (new Search).set({needle:"kinners"});
|
||||||
assertEquals(null, d.find(a))
|
assert.equal(b.find(a), null)
|
||||||
}, "test: wrap search should wrap at file end":function() {
|
}, "test: wrap search should wrap at file end":function() {
|
||||||
var a = new c(["abc", "juhu kinners 123", "456"]);
|
var a = new Document(["abc", "juhu kinners 123", "456"]);
|
||||||
a.getSelection().moveCursorTo(2, 1);
|
a.getSelection().moveCursorTo(2, 1);
|
||||||
a = (new b).set({needle:"kinners", wrap:true}).find(a);
|
a = (new Search).set({needle:"kinners", wrap:true}).find(a);
|
||||||
assertPosition(1, 5, a.start);
|
assert.position(a.start, 1, 5);
|
||||||
assertPosition(1, 12, a.end)
|
assert.position(a.end, 1, 12)
|
||||||
}, "test: wrap search with no match should return 'null'":function() {
|
}, "test: wrap search with no match should return 'null'":function() {
|
||||||
var a = new c(["abc", "juhu kinners 123", "456"]);
|
var a = new Document(["abc", "juhu kinners 123", "456"]);
|
||||||
a.getSelection().moveCursorTo(2, 1);
|
a.getSelection().moveCursorTo(2, 1);
|
||||||
var d = (new b).set({needle:"xyz", wrap:true});
|
var b = (new Search).set({needle:"xyz", wrap:true});
|
||||||
assertEquals(null, d.find(a))
|
assert.equal(b.find(a), null)
|
||||||
}, "test: case sensitive is by default off":function() {
|
}, "test: case sensitive is by default off":function() {
|
||||||
var a = new c(["abc", "juhu kinners 123", "456"]), d = (new b).set({needle:"JUHU"});
|
var a = new Document(["abc", "juhu kinners 123", "456"]), b = (new Search).set({needle:"JUHU"});
|
||||||
assertEquals(null, d.find(a))
|
assert.range(b.find(a), 1, 0, 1, 4)
|
||||||
}, "test: case sensitive search":function() {
|
}, "test: case sensitive search":function() {
|
||||||
var a = new c(["abc", "juhu kinners 123", "456"]);
|
var a = new Document(["abc", "juhu kinners 123", "456"]);
|
||||||
a = (new b).set({needle:"KINNERS", caseSensitive:true}).find(a);
|
a = (new Search).set({needle:"KINNERS", caseSensitive:true}).find(a);
|
||||||
assertPosition(1, 5, a.start);
|
assert.equal(a, null)
|
||||||
assertPosition(1, 12, a.end)
|
}, "test: whole word search should not match inside of words":function() {
|
||||||
}, "test: whole word search should not match inside of words":function() {
|
var a = new Document(["juhukinners", "juhu kinners 123", "456"]);
|
||||||
var a = new c(["juhukinners", "juhu kinners 123", "456"]);
|
a = (new Search).set({needle:"kinners", wholeWord:true}).find(a);
|
||||||
a = (new b).set({needle:"kinners", wholeWord:true}).find(a);
|
assert.position(a.start, 1, 5);
|
||||||
assertPosition(1, 5, a.start);
|
assert.position(a.end, 1, 12)
|
||||||
assertPosition(1, 12, a.end)
|
}, "test: find backwards":function() {
|
||||||
}, "test: find backwards":function() {
|
var a = new Document(["juhu juhu juhu juhu"]);
|
||||||
var a = new c(["juhu juhu juhu juhu"]);
|
|
||||||
a.getSelection().moveCursorTo(0, 10);
|
a.getSelection().moveCursorTo(0, 10);
|
||||||
a = (new b).set({needle:"juhu", backwards:true}).find(a);
|
a = (new Search).set({needle:"juhu", backwards:true}).find(a);
|
||||||
assertPosition(0, 5, a.start);
|
assert.position(a.start, 0, 5);
|
||||||
assertPosition(0, 9, a.end)
|
assert.position(a.end, 0, 9)
|
||||||
}, "test: find in selection":function() {
|
}, "test: find in selection":function() {
|
||||||
var a = new c(["juhu", "juhu", "juhu", "juhu"]);
|
var a = new Document(["juhu", "juhu", "juhu", "juhu"]);
|
||||||
a.getSelection().setSelectionAnchor(1, 0);
|
a.getSelection().setSelectionAnchor(1, 0);
|
||||||
a.getSelection().selectTo(3, 5);
|
a.getSelection().selectTo(3, 5);
|
||||||
var d = (new b).set({needle:"juhu", wrap:true, scope:b.SELECTION}), e = d.find(a);
|
var b = (new Search).set({needle:"juhu", wrap:true, scope:Search.SELECTION}), c = b.find(a);
|
||||||
assertPosition(1, 0, e.start);
|
assert.position(c.start, 1, 0);
|
||||||
assertPosition(1, 4, e.end);
|
assert.position(c.end, 1, 4);
|
||||||
a.getSelection().setSelectionAnchor(0, 2);
|
a.getSelection().setSelectionAnchor(0, 2);
|
||||||
a.getSelection().selectTo(3, 2);
|
a.getSelection().selectTo(3, 2);
|
||||||
e = d.find(a);
|
c = b.find(a);
|
||||||
assertPosition(1, 0, e.start);
|
assert.position(c.start, 1, 0);
|
||||||
assertPosition(1, 4, e.end)
|
assert.position(c.end, 1, 4)
|
||||||
}, "test: find backwards in selection":function() {
|
}, "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});
|
var a = new Document(["juhu", "juhu", "juhu", "juhu"]), b = (new Search).set({needle:"juhu", wrap:true, backwards:true, scope:Search.SELECTION});
|
||||||
a.getSelection().setSelectionAnchor(0, 2);
|
a.getSelection().setSelectionAnchor(0, 2);
|
||||||
a.getSelection().selectTo(3, 2);
|
a.getSelection().selectTo(3, 2);
|
||||||
var e = d.find(a);
|
var c = b.find(a);
|
||||||
assertPosition(2, 0, e.start);
|
assert.position(c.start, 2, 0);
|
||||||
assertPosition(2, 4, e.end);
|
assert.position(c.end, 2, 4);
|
||||||
a.getSelection().setSelectionAnchor(0, 2);
|
a.getSelection().setSelectionAnchor(0, 2);
|
||||||
a.getSelection().selectTo(1, 2);
|
a.getSelection().selectTo(1, 2);
|
||||||
assertEquals(null, d.find(a))
|
assert.equal(b.find(a), null)
|
||||||
}, "test: edge case - match directly before the cursor":function() {
|
}, "test: edge case - match directly before the cursor":function() {
|
||||||
var a = new c(["123", "123", "juhu"]), d = (new b).set({needle:"juhu", wrap:true});
|
var a = new Document(["123", "123", "juhu"]), b = (new Search).set({needle:"juhu", wrap:true});
|
||||||
a.getSelection().moveCursorTo(2, 5);
|
a.getSelection().moveCursorTo(2, 5);
|
||||||
a = d.find(a);
|
a = b.find(a);
|
||||||
assertPosition(2, 0, a.start);
|
assert.position(a.start, 2, 0);
|
||||||
assertPosition(2, 4, a.end)
|
assert.position(a.end, 2, 4)
|
||||||
}, "test: edge case - match backwards directly after the cursor":function() {
|
}, "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});
|
var a = new Document(["123", "123", "juhu"]), b = (new Search).set({needle:"juhu", wrap:true, backwards:true});
|
||||||
a.getSelection().moveCursorTo(2, 0);
|
a.getSelection().moveCursorTo(2, 0);
|
||||||
a = d.find(a);
|
a = b.find(a);
|
||||||
assertPosition(2, 0, a.start);
|
assert.position(a.start, 2, 0);
|
||||||
assertPosition(2, 4, a.end)
|
assert.position(a.end, 2, 4)
|
||||||
}, "test: find using a regular expression":function() {
|
}, "test: find using a regular expression":function() {
|
||||||
var a = new c(["abc123 123 cd", "abc"]);
|
var a = new Document(["abc123 123 cd", "abc"]);
|
||||||
a = (new b).set({needle:"\\d+", regExp:true}).find(a);
|
a = (new Search).set({needle:"\\d+", regExp:true}).find(a);
|
||||||
assertPosition(0, 3, a.start);
|
assert.position(a.start, 0, 3);
|
||||||
assertPosition(0, 6, a.end)
|
assert.position(a.end, 0, 6)
|
||||||
}, "test: find using a regular expression and whole word":function() {
|
}, "test: find using a regular expression and whole word":function() {
|
||||||
var a = new c(["abc123 123 cd", "abc"]);
|
var a = new Document(["abc123 123 cd", "abc"]);
|
||||||
a = (new b).set({needle:"\\d+\\b", regExp:true, wholeWord:true}).find(a);
|
a = (new Search).set({needle:"\\d+\\b", regExp:true, wholeWord:true}).find(a);
|
||||||
assertPosition(0, 7, a.start);
|
assert.position(a.start, 0, 7);
|
||||||
assertPosition(0, 10, a.end)
|
assert.position(a.end, 0, 10)
|
||||||
}, "test: use regular expressions with capture groups":function() {
|
}, "test: use regular expressions with capture groups":function() {
|
||||||
var a = new c([" ab: 12px", " <h1 abc"]);
|
var a = new Document([" ab: 12px", " <h1 abc"]);
|
||||||
a = (new b).set({needle:"(\\d+)", regExp:true}).find(a);
|
a = (new Search).set({needle:"(\\d+)", regExp:true}).find(a);
|
||||||
assertPosition(0, 6, a.start);
|
assert.position(a.start, 0, 6);
|
||||||
assertPosition(0, 8, a.end)
|
assert.position(a.end, 0, 8)
|
||||||
}, "test: find all matches in selection":function() {
|
}, "test: find all matches in selection":function() {
|
||||||
var a = new c(["juhu", "juhu", "juhu", "juhu"]), d = (new b).set({needle:"uh", wrap:true, scope:b.SELECTION});
|
var a = new Document(["juhu", "juhu", "juhu", "juhu"]), b = (new Search).set({needle:"uh", wrap:true, scope:Search.SELECTION});
|
||||||
a.getSelection().setSelectionAnchor(0, 2);
|
a.getSelection().setSelectionAnchor(0, 2);
|
||||||
a.getSelection().selectTo(3, 2);
|
a.getSelection().selectTo(3, 2);
|
||||||
a = d.findAll(a);
|
a = b.findAll(a);
|
||||||
assertEquals(2, a.length);
|
assert.equal(a.length, 2);
|
||||||
assertPosition(1, 1, a[0].start);
|
assert.position(a[0].start, 1, 1);
|
||||||
assertPosition(1, 3, a[0].end);
|
assert.position(a[0].end, 1, 3);
|
||||||
assertPosition(2, 1, a[1].start);
|
assert.position(a[1].start, 2, 1);
|
||||||
assertPosition(2, 3, a[1].end)
|
assert.position(a[1].end, 2, 3)
|
||||||
}, "test: replace() should return the replacement if the input matches the needle":function() {
|
}, "test: replace() should return the replacement if the input matches the needle":function() {
|
||||||
var a = (new b).set({needle:"juhu"});
|
var a = (new Search).set({needle:"juhu"});
|
||||||
assertEquals("kinners", a.replace("juhu", "kinners"));
|
assert.equal(a.replace("juhu", "kinners"), "kinners");
|
||||||
assertEquals(null, a.replace("", "kinners"));
|
assert.equal(a.replace("", "kinners"), null);
|
||||||
assertEquals(null, a.replace(" juhu", "kinners"))
|
assert.equal(a.replace(" juhu", "kinners"), null)
|
||||||
}, "test: replace with a RegExp search":function() {
|
}, "test: replace with a RegExp search":function() {
|
||||||
var a = (new b).set({needle:"\\d+", regExp:true});
|
var a = (new Search).set({needle:"\\d+", regExp:true});
|
||||||
assertEquals("kinners", a.replace("123", "kinners"));
|
assert.equal(a.replace("123", "kinners"), "kinners");
|
||||||
assertEquals("kinners", a.replace("01234", "kinners"));
|
assert.equal(a.replace("01234", "kinners"), "kinners");
|
||||||
assertEquals(null, a.replace("", "kinners"));
|
assert.equal(a.replace("", "kinners"), null);
|
||||||
assertEquals(null, a.replace("a12", "kinners"));
|
assert.equal(a.replace("a12", "kinners"), null);
|
||||||
assertEquals(null, a.replace("12a", "kinners"))
|
assert.equal(a.replace("12a", "kinners"), null)
|
||||||
}, "test: replace with RegExp match and capture groups":function() {
|
}, "test: replace with RegExp match and capture groups":function() {
|
||||||
var a = (new b).set({needle:"ab(\\d\\d)", regExp:true});
|
var a = (new Search).set({needle:"ab(\\d\\d)", regExp:true});
|
||||||
assertEquals("cd12", a.replace("ab12", "cd$1"));
|
assert.equal(a.replace("ab12", "cd$1"), "cd12");
|
||||||
assertEquals("-ab12-", a.replace("ab12", "-$&-"));
|
assert.equal(a.replace("ab12", "-$&-"), "-ab12-");
|
||||||
assertEquals("$", a.replace("ab12", "$$"))
|
assert.equal(a.replace("ab12", "$$"), "$")
|
||||||
}})
|
}};
|
||||||
});
|
module.exports = require("async/test").testcase(Test);
|
||||||
|
module === require.main && module.exports.exec();
|
||||||
|
|
@ -1,149 +0,0 @@
|
||||||
/*
|
|
||||||
LGPLv3 <http://www.gnu.org/licenses/lgpl-3.0.txt>
|
|
||||||
*/
|
|
||||||
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)
|
|
||||||
}})
|
|
||||||
});
|
|
||||||
|
|
@ -1,178 +1,185 @@
|
||||||
/*
|
/*
|
||||||
LGPLv3 <http://www.gnu.org/licenses/lgpl-3.0.txt>
|
LGPLv3 <http://www.gnu.org/licenses/lgpl-3.0.txt>
|
||||||
*/
|
*/
|
||||||
require.def(["ace/Document", "ace/Editor", "ace/mode/JavaScript", "ace/test/MockRenderer"], function(c, d, g, e) {
|
require("../../../support/paths");
|
||||||
TestCase("TextEditTest", {"test: delete line from the middle":function() {
|
var dom = require("jsdom/level2/html").dom.level2.html, browser = require("jsdom/browser/index").windowAugmentation(dom);
|
||||||
var b = new c("a\nb\nc\nd"), a = new d(new e, b);
|
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.moveCursorTo(1, 1);
|
||||||
a.removeLines();
|
a.removeLines();
|
||||||
assertEquals("a\nc\nd", b.toString());
|
assert.equal(b.toString(), "a\nc\nd");
|
||||||
assertPosition(1, 0, a.getCursorPosition());
|
assert.position(a.getCursorPosition(), 1, 0);
|
||||||
a.removeLines();
|
a.removeLines();
|
||||||
assertEquals("a\nd", b.toString());
|
assert.equal(b.toString(), "a\nd");
|
||||||
assertPosition(1, 0, a.getCursorPosition());
|
assert.position(a.getCursorPosition(), 1, 0);
|
||||||
a.removeLines();
|
a.removeLines();
|
||||||
assertEquals("a\n", b.toString());
|
assert.equal(b.toString(), "a\n");
|
||||||
assertPosition(1, 0, a.getCursorPosition());
|
assert.position(a.getCursorPosition(), 1, 0);
|
||||||
a.removeLines();
|
a.removeLines();
|
||||||
assertEquals("a\n", b.toString());
|
assert.equal(b.toString(), "a\n");
|
||||||
assertPosition(1, 0, a.getCursorPosition())
|
assert.position(a.getCursorPosition(), 1, 0)
|
||||||
}, "test: delete multiple selected lines":function() {
|
}, "test: delete multiple selected lines":function() {
|
||||||
var b = new c("a\nb\nc\nd"), a = new d(new e, b);
|
var b = new Document("a\nb\nc\nd"), a = new Editor(new MockRenderer, b);
|
||||||
a.moveCursorTo(1, 1);
|
a.moveCursorTo(1, 1);
|
||||||
a.getSelection().selectDown();
|
a.getSelection().selectDown();
|
||||||
a.removeLines();
|
a.removeLines();
|
||||||
assertEquals("a\nd", b.toString());
|
assert.equal(b.toString(), "a\nd");
|
||||||
assertPosition(1, 0, a.getCursorPosition())
|
assert.position(a.getCursorPosition(), 1, 0)
|
||||||
}, "test: delete first line":function() {
|
}, "test: delete first line":function() {
|
||||||
var b = new c("a\nb\nc"), a = new d(new e, b);
|
var b = new Document("a\nb\nc"), a = new Editor(new MockRenderer, b);
|
||||||
a.removeLines();
|
a.removeLines();
|
||||||
assertEquals("b\nc", b.toString());
|
assert.equal(b.toString(), "b\nc");
|
||||||
assertPosition(0, 0, a.getCursorPosition())
|
assert.position(a.getCursorPosition(), 0, 0)
|
||||||
}, "test: delete last":function() {
|
}, "test: delete last":function() {
|
||||||
var b = new c("a\nb\nc"), a = new d(new e, b);
|
var b = new Document("a\nb\nc"), a = new Editor(new MockRenderer, b);
|
||||||
a.moveCursorTo(2, 1);
|
a.moveCursorTo(2, 1);
|
||||||
a.removeLines();
|
a.removeLines();
|
||||||
assertEquals("a\nb\n", b.toString());
|
assert.equal(b.toString(), "a\nb\n");
|
||||||
assertPosition(2, 0, a.getCursorPosition())
|
assert.position(a.getCursorPosition(), 2, 0)
|
||||||
}, "test: indent block":function() {
|
}, "__test: indent block":function() {
|
||||||
var b = new c("a12345\nb12345\nc12345"), a = new d(new e, b);
|
var b = new Document("a12345\nb12345\nc12345"), a = new Editor(new MockRenderer, b);
|
||||||
a.moveCursorTo(1, 3);
|
a.moveCursorTo(1, 3);
|
||||||
a.getSelection().selectDown();
|
a.getSelection().selectDown();
|
||||||
a.blockIndent(" ");
|
a.blockIndent(" ");
|
||||||
assertEquals("a12345\n b12345\n c12345", b.toString());
|
assert.equal("a12345\n b12345\n c12345", b.toString());
|
||||||
assertPosition(2, 7, a.getCursorPosition());
|
assert.position(a.getCursorPosition(), 2, 7);
|
||||||
b = a.getSelectionRange();
|
b = a.getSelectionRange();
|
||||||
assertPosition(1, 7, b.start);
|
assert.position(b.start, 1, 7);
|
||||||
assertPosition(2, 7, b.end)
|
assert.position(b.end, 2, 7)
|
||||||
}, "test: outdent block":function() {
|
}, "__test: outdent block":function() {
|
||||||
var b = new c(" a12345\n b12345\n c12345"), a = new d(new e, b);
|
var b = new Document(" a12345\n b12345\n c12345"), a = new Editor(new MockRenderer, b);
|
||||||
a.moveCursorTo(0, 3);
|
a.moveCursorTo(0, 3);
|
||||||
a.getSelection().selectDown();
|
a.getSelection().selectDown();
|
||||||
a.getSelection().selectDown();
|
a.getSelection().selectDown();
|
||||||
a.blockOutdent(" ");
|
a.blockOutdent(" ");
|
||||||
assertEquals(" a12345\nb12345\n c12345", b.toString());
|
assert.equal(b.toString(), " a12345\nb12345\n c12345");
|
||||||
assertPosition(2, 1, a.getCursorPosition());
|
assert.position(a.getCursorPosition(), 2, 0);
|
||||||
var f = a.getSelectionRange();
|
var c = a.getSelectionRange();
|
||||||
assertPosition(0, 1, f.start);
|
assert.position(c.start, 0, 1);
|
||||||
assertPosition(2, 1, f.end);
|
assert.position(c.end, 2, 1);
|
||||||
a.blockOutdent(" ");
|
a.blockOutdent(" ");
|
||||||
assertEquals(" a12345\nb12345\n c12345", b.toString());
|
assert.equal(b.toString(), "a12345\nb12345\nc12345");
|
||||||
f = a.getSelectionRange();
|
c = a.getSelectionRange();
|
||||||
assertPosition(0, 1, f.start);
|
assert.position(c.start, 0, 1);
|
||||||
assertPosition(2, 1, f.end)
|
assert.position(c.end, 2, 1)
|
||||||
}, "test: outent without a selection should update cursor":function() {
|
}, "test: outent without a selection should update cursor":function() {
|
||||||
var b = new c(" 12"), a = new d(new e, b);
|
var b = new Document(" 12"), a = new Editor(new MockRenderer, b);
|
||||||
a.moveCursorTo(0, 3);
|
a.moveCursorTo(0, 3);
|
||||||
a.blockOutdent(" ");
|
a.blockOutdent(" ");
|
||||||
assertEquals(" 12", b.toString());
|
assert.equal(b.toString(), " 12");
|
||||||
assertPosition(0, 1, a.getCursorPosition())
|
assert.position(a.getCursorPosition(), 0, 0)
|
||||||
}, "test: comment lines should perserve selection":function() {
|
}, "test: comment lines should perserve selection":function() {
|
||||||
var b = new c(" abc\ncde", new g), a = new d(new e, b);
|
var b = new Document(" abc\ncde", new JavaScriptMode), a = new Editor(new MockRenderer, b);
|
||||||
a.moveCursorTo(0, 2);
|
a.moveCursorTo(0, 2);
|
||||||
a.getSelection().selectDown();
|
a.getSelection().selectDown();
|
||||||
a.toggleCommentLines();
|
a.toggleCommentLines();
|
||||||
assertEquals("// abc\n//cde", b.toString());
|
assert.equal("// abc\n//cde", b.toString());
|
||||||
b = a.getSelectionRange();
|
b = a.getSelectionRange();
|
||||||
assertPosition(0, 4, b.start);
|
assert.position(b.start, 0, 4);
|
||||||
assertPosition(1, 4, b.end)
|
assert.position(b.end, 1, 4)
|
||||||
}, "test: uncomment lines should perserve selection":function() {
|
}, "test: uncomment lines should perserve selection":function() {
|
||||||
var b = new c("// abc\n//cde", new g), a = new d(new e, b);
|
var b = new Document("// abc\n//cde", new JavaScriptMode), a = new Editor(new MockRenderer, b);
|
||||||
a.moveCursorTo(0, 1);
|
a.moveCursorTo(0, 1);
|
||||||
a.getSelection().selectDown();
|
a.getSelection().selectDown();
|
||||||
a.getSelection().selectRight();
|
a.getSelection().selectRight();
|
||||||
a.getSelection().selectRight();
|
a.getSelection().selectRight();
|
||||||
a.toggleCommentLines();
|
a.toggleCommentLines();
|
||||||
assertEquals(" abc\ncde", b.toString());
|
assert.equal(" abc\ncde", b.toString());
|
||||||
assertRange(0, 0, 1, 1, a.getSelectionRange())
|
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() {
|
}, "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);
|
var b = new Document("abc\ncde", new JavaScriptMode);
|
||||||
b = new d(new e, b);
|
b = new Editor(new MockRenderer, b);
|
||||||
b.moveCursorTo(0, 0);
|
b.moveCursorTo(0, 0);
|
||||||
b.getSelection().selectDown();
|
b.getSelection().selectDown();
|
||||||
b.toggleCommentLines();
|
b.toggleCommentLines();
|
||||||
assertRange(0, 2, 1, 0, b.getSelectionRange());
|
assert.range(b.getSelectionRange(), 0, 2, 1, 0);
|
||||||
b = new c("abc\ncde", new g);
|
b = new Document("abc\ncde", new JavaScriptMode);
|
||||||
b = new d(new e, b);
|
b = new Editor(new MockRenderer, b);
|
||||||
b.moveCursorTo(1, 0);
|
b.moveCursorTo(1, 0);
|
||||||
b.getSelection().selectUp();
|
b.getSelection().selectUp();
|
||||||
b.toggleCommentLines();
|
b.toggleCommentLines();
|
||||||
assertRange(0, 2, 1, 0, b.getSelectionRange())
|
assert.range(b.getSelectionRange(), 0, 2, 1, 0)
|
||||||
}, "test: move lines down should select moved lines":function() {
|
}, "test: move lines down should select moved lines":function() {
|
||||||
var b = new c("11\n22\n33\n44"), a = new d(new e, b);
|
var b = new Document("11\n22\n33\n44"), a = new Editor(new MockRenderer, b);
|
||||||
a.moveCursorTo(0, 1);
|
a.moveCursorTo(0, 1);
|
||||||
a.getSelection().selectDown();
|
a.getSelection().selectDown();
|
||||||
a.moveLinesDown();
|
a.moveLinesDown();
|
||||||
assertEquals("33\n11\n22\n44", b.toString());
|
assert.equal("33\n11\n22\n44", b.toString());
|
||||||
assertPosition(1, 0, a.getCursorPosition());
|
assert.position(a.getCursorPosition(), 1, 0);
|
||||||
assertPosition(3, 0, a.getSelection().getSelectionAnchor());
|
assert.position(a.getSelection().getSelectionAnchor(), 3, 0);
|
||||||
assertPosition(1, 0, a.getSelection().getSelectionLead());
|
assert.position(a.getSelection().getSelectionLead(), 1, 0);
|
||||||
a.moveLinesDown();
|
a.moveLinesDown();
|
||||||
assertEquals("33\n44\n11\n22", b.toString());
|
assert.equal("33\n44\n11\n22", b.toString());
|
||||||
assertPosition(2, 0, a.getCursorPosition());
|
assert.position(a.getCursorPosition(), 2, 0);
|
||||||
assertPosition(3, 2, a.getSelection().getSelectionAnchor());
|
assert.position(a.getSelection().getSelectionAnchor(), 3, 2);
|
||||||
assertPosition(2, 0, a.getSelection().getSelectionLead());
|
assert.position(a.getSelection().getSelectionLead(), 2, 0);
|
||||||
a.moveLinesDown();
|
a.moveLinesDown();
|
||||||
assertEquals("33\n44\n11\n22", b.toString());
|
assert.equal("33\n44\n11\n22", b.toString());
|
||||||
assertPosition(2, 0, a.getCursorPosition());
|
assert.position(a.getCursorPosition(), 2, 0);
|
||||||
assertPosition(3, 2, a.getSelection().getSelectionAnchor());
|
assert.position(a.getSelection().getSelectionAnchor(), 3, 2);
|
||||||
assertPosition(2, 0, a.getSelection().getSelectionLead())
|
assert.position(a.getSelection().getSelectionLead(), 2, 0)
|
||||||
}, "test: move lines up should select moved lines":function() {
|
}, "__test: move lines up should select moved lines":function() {
|
||||||
var b = new c("11\n22\n33\n44"), a = new d(new e, b);
|
var b = new Document("11\n22\n33\n44"), a = new Editor(new MockRenderer, b);
|
||||||
a.moveCursorTo(2, 1);
|
a.moveCursorTo(2, 1);
|
||||||
a.getSelection().selectDown();
|
a.getSelection().selectDown();
|
||||||
a.moveLinesUp();
|
a.moveLinesUp();
|
||||||
assertEquals("11\n33\n44\n22", b.toString());
|
assert.equal(b.toString(), "11\n33\n44\n22");
|
||||||
assertPosition(1, 0, a.getCursorPosition());
|
assert.position(a.getCursorPosition(), 1, 0);
|
||||||
assertPosition(3, 0, a.getSelection().getSelectionAnchor());
|
assert.position(a.getSelection().getSelectionAnchor(), 3, 0);
|
||||||
assertPosition(1, 0, a.getSelection().getSelectionLead());
|
assert.position(a.getSelection().getSelectionLead(), 1, 0);
|
||||||
a.moveLinesUp();
|
a.moveLinesUp();
|
||||||
assertEquals("33\n44\n11\n22", b.toString());
|
assert.equal(b.toString(), "33\n44\n11\n22");
|
||||||
assertPosition(0, 0, a.getCursorPosition());
|
assert.position(a.getCursorPosition(), 0, 0);
|
||||||
assertPosition(2, 0, a.getSelection().getSelectionAnchor());
|
assert.position(a.getSelection().getSelectionAnchor(), 2, 0);
|
||||||
assertPosition(0, 0, a.getSelection().getSelectionLead())
|
assert.position(a.getSelection().getSelectionLead(), 0, 0)
|
||||||
}, "test: move line without active selection should move cursor to start of the moved line":function() {
|
}, "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);
|
var b = new Document("11\n22\n33\n44"), a = new Editor(new MockRenderer, b);
|
||||||
a.moveCursorTo(1, 1);
|
a.moveCursorTo(1, 1);
|
||||||
a.clearSelection();
|
a.clearSelection();
|
||||||
a.moveLinesDown();
|
a.moveLinesDown();
|
||||||
assertEquals("11\n33\n22\n44", b.toString());
|
assert.equal("11\n33\n22\n44", b.toString());
|
||||||
assertPosition(2, 0, a.getCursorPosition());
|
assert.position(a.getCursorPosition(), 2, 0);
|
||||||
a.clearSelection();
|
a.clearSelection();
|
||||||
a.moveLinesUp();
|
a.moveLinesUp();
|
||||||
assertEquals("11\n22\n33\n44", b.toString());
|
assert.equal("11\n22\n33\n44", b.toString());
|
||||||
assertPosition(1, 0, a.getCursorPosition())
|
assert.position(a.getCursorPosition(), 1, 0)
|
||||||
}, "test: copy lines down should select lines and place cursor at the selection start":function() {
|
}, "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);
|
var b = new Document("11\n22\n33\n44"), a = new Editor(new MockRenderer, b);
|
||||||
a.moveCursorTo(1, 1);
|
a.moveCursorTo(1, 1);
|
||||||
a.getSelection().selectDown();
|
a.getSelection().selectDown();
|
||||||
a.copyLinesDown();
|
a.copyLinesDown();
|
||||||
assertEquals("11\n22\n33\n22\n33\n44", b.toString());
|
assert.equal("11\n22\n33\n22\n33\n44", b.toString());
|
||||||
assertPosition(3, 0, a.getCursorPosition());
|
assert.position(a.getCursorPosition(), 3, 0);
|
||||||
assertPosition(5, 0, a.getSelection().getSelectionAnchor());
|
assert.position(a.getSelection().getSelectionAnchor(), 5, 0);
|
||||||
assertPosition(3, 0, a.getSelection().getSelectionLead())
|
assert.position(a.getSelection().getSelectionLead(), 3, 0)
|
||||||
}, "test: copy lines up should select lines and place cursor at the selection start":function() {
|
}, "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);
|
var b = new Document("11\n22\n33\n44"), a = new Editor(new MockRenderer, b);
|
||||||
a.moveCursorTo(1, 1);
|
a.moveCursorTo(1, 1);
|
||||||
a.getSelection().selectDown();
|
a.getSelection().selectDown();
|
||||||
a.copyLinesUp();
|
a.copyLinesUp();
|
||||||
assertEquals("11\n22\n33\n22\n33\n44", b.toString());
|
assert.equal("11\n22\n33\n22\n33\n44", b.toString());
|
||||||
assertPosition(1, 0, a.getCursorPosition());
|
assert.position(a.getCursorPosition(), 1, 0);
|
||||||
assertPosition(3, 0, a.getSelection().getSelectionAnchor());
|
assert.position(a.getSelection().getSelectionAnchor(), 3, 0);
|
||||||
assertPosition(1, 0, a.getSelection().getSelectionLead())
|
assert.position(a.getSelection().getSelectionLead(), 1, 0)
|
||||||
}, "test: input a tab with soft tab should convert it to spaces":function() {
|
}, "test: input a tab with soft tab should convert it to spaces":function() {
|
||||||
var b = new c(""), a = new d(new e, b);
|
var b = new Document(""), a = new Editor(new MockRenderer, b);
|
||||||
b.setTabSize(2);
|
b.setTabSize(2);
|
||||||
b.setUseSoftTabs(true);
|
b.setUseSoftTabs(true);
|
||||||
a.onTextInput("\t");
|
a.onTextInput("\t");
|
||||||
assertEquals(" ", b.toString());
|
assert.equal(b.toString(), " ");
|
||||||
b.setTabSize(5);
|
b.setTabSize(5);
|
||||||
a.onTextInput("\t");
|
a.onTextInput("\t");
|
||||||
assertEquals(" ", b.toString())
|
assert.equal(b.toString(), " ")
|
||||||
}, "test: input tab without soft tabs should keep the tab character":function() {
|
}, "test: input tab without soft tabs should keep the tab character":function() {
|
||||||
var b = new c(""), a = new d(new e, b);
|
var b = new Document(""), a = new Editor(new MockRenderer, b);
|
||||||
b.setUseSoftTabs(false);
|
b.setUseSoftTabs(false);
|
||||||
a.onTextInput("\t");
|
a.onTextInput("\t");
|
||||||
assertEquals("\t", b.toString())
|
assert.equal(b.toString(), "\t")
|
||||||
}})
|
}};
|
||||||
});
|
module.exports = require("async/test").testcase(Test);
|
||||||
|
module === require.main && module.exports.exec();
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
/*
|
/*
|
||||||
LGPLv3 <http://www.gnu.org/licenses/lgpl-3.0.txt>
|
LGPLv3 <http://www.gnu.org/licenses/lgpl-3.0.txt>
|
||||||
*/
|
*/
|
||||||
require.def(["ace/Document", "ace/VirtualRenderer"], function(c, d) {
|
require("../../../support/paths");
|
||||||
new TestCase("VirtualRendererTest", {"test: screen2text the column should be rounded to the next character edge":function() {
|
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");
|
var b = document.createElement("div");
|
||||||
b.style.left = "0px";
|
b.style.left = "0px";
|
||||||
b.style.top = "0px";
|
b.style.top = "0px";
|
||||||
|
|
@ -11,17 +11,18 @@ require.def(["ace/Document", "ace/VirtualRenderer"], function(c, d) {
|
||||||
document.body.style.margin = "0px";
|
document.body.style.margin = "0px";
|
||||||
document.body.style.padding = "0px";
|
document.body.style.padding = "0px";
|
||||||
document.body.appendChild(b);
|
document.body.appendChild(b);
|
||||||
var a = new d(b);
|
var a = new VirtualRenderer(b);
|
||||||
a.setDocument(new c("1234"));
|
a.setDocument(new Document("1234"));
|
||||||
a.characterWidth = 10;
|
a.characterWidth = 10;
|
||||||
a.lineHeight = 15;
|
a.lineHeight = 15;
|
||||||
assertPosition(0, 0, a.screenToTextCoordinates(0, 0));
|
assert.position(a.screenToTextCoordinates(0, 0), 0, 0);
|
||||||
assertPosition(0, 0, a.screenToTextCoordinates(4, 0));
|
assert.position(a.screenToTextCoordinates(4, 0), 0, 0);
|
||||||
assertPosition(0, 1, a.screenToTextCoordinates(5, 0));
|
assert.position(a.screenToTextCoordinates(5, 0), 0, 1);
|
||||||
assertPosition(0, 1, a.screenToTextCoordinates(9, 0));
|
assert.position(a.screenToTextCoordinates(9, 0), 0, 1);
|
||||||
assertPosition(0, 1, a.screenToTextCoordinates(10, 0));
|
assert.position(a.screenToTextCoordinates(10, 0), 0, 1);
|
||||||
assertPosition(0, 1, a.screenToTextCoordinates(14, 0));
|
assert.position(a.screenToTextCoordinates(14, 0), 0, 1);
|
||||||
assertPosition(0, 2, a.screenToTextCoordinates(15, 0));
|
assert.position(a.screenToTextCoordinates(15, 0), 0, 2);
|
||||||
document.body.removeChild(b)
|
document.body.removeChild(b)
|
||||||
}})
|
}};
|
||||||
});
|
module.exports = require("async/test").testcase(Test);
|
||||||
|
module === require.main && module.exports.exec();
|
||||||
|
|
@ -6,12 +6,12 @@ define(["require", "exports", "module", 'text!ace/css/editor.css!.ace_editor {\n
|
||||||
this.container = a;
|
this.container = a;
|
||||||
f.addCssClass(this.container, "ace_editor");
|
f.addCssClass(this.container, "ace_editor");
|
||||||
this.setTheme(b);
|
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 = document.createElement("div");
|
||||||
this.$gutter.className = "ace_gutter";
|
this.$gutter.className = "ace_gutter";
|
||||||
this.container.appendChild(this.$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 = document.createElement("div");
|
||||||
this.content.style.position = "absolute";
|
this.content.style.position = "absolute";
|
||||||
this.scroller.appendChild(this.content);
|
this.scroller.appendChild(this.content);
|
||||||
|
|
@ -196,7 +196,7 @@ define(["require", "exports", "module", 'text!ace/css/editor.css!.ace_editor {\n
|
||||||
this.$updateScrollBar()
|
this.$updateScrollBar()
|
||||||
}else {
|
}else {
|
||||||
if(a & this.CHANGE_SCROLL) {
|
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.showGutter && this.$gutterLayer.update(this.layerConfig);
|
||||||
this.$markerLayer.update(this.layerConfig);
|
this.$markerLayer.update(this.layerConfig);
|
||||||
this.$cursorLayer.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) {
|
if(a & this.CHANGE_LINES) {
|
||||||
this.$updateLines();
|
this.$updateLines();
|
||||||
this.$updateScrollBar()
|
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_GUTTER && this.showGutter && this.$gutterLayer.update(this.layerConfig);
|
||||||
a & this.CHANGE_CURSOR && this.$cursorLayer.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;
|
var c = this;
|
||||||
if(!a || typeof a == "string") {
|
if(!a || typeof a == "string") {
|
||||||
a = a || "ace/theme/TextMate";
|
a = a || "ace/theme/textmate";
|
||||||
d([a], function(e) {
|
d([a], function(e) {
|
||||||
b(e)
|
b(e)
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -55,3 +55,9 @@ ace/mode/html.js
|
||||||
----------------
|
----------------
|
||||||
ace/mode/html_highlight_rules.js
|
ace/mode/html_highlight_rules.js
|
||||||
ace/mode/html.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
|
||||||
|
|
|
||||||
126
demo/boot.js
Normal file
126
demo/boot.js
Normal file
|
|
@ -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);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
210
demo/demo_startup.js
Normal file
210
demo/demo_startup.js
Normal file
|
|
@ -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 <fabian AT ajax DOT org>
|
||||||
|
* 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);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
});
|
||||||
|
|
@ -1,299 +0,0 @@
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
|
|
||||||
"http://www.w3.org/TR/html4/strict.dtd">
|
|
||||||
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
|
||||||
<title>Editor</title>
|
|
||||||
<meta name="author" content="Fabian Jakobs">
|
|
||||||
|
|
||||||
<style type="text/css" media="screen">
|
|
||||||
|
|
||||||
html {
|
|
||||||
height: 100%;
|
|
||||||
overflow: hidden;
|
|
||||||
}
|
|
||||||
|
|
||||||
body {
|
|
||||||
overflow: hidden;
|
|
||||||
margin: 0;
|
|
||||||
padding: 0;
|
|
||||||
font: sans-serif;
|
|
||||||
height: 100%;
|
|
||||||
width: 100%;
|
|
||||||
font-family: Arial, Helvetica, sans-serif, Tahoma, Verdana;
|
|
||||||
font-size: 12px;
|
|
||||||
background: rgb(14, 98, 165);
|
|
||||||
color: white;
|
|
||||||
}
|
|
||||||
|
|
||||||
#editor {
|
|
||||||
top: 55px;
|
|
||||||
left: 0px;
|
|
||||||
background: white;
|
|
||||||
}
|
|
||||||
|
|
||||||
#controls {
|
|
||||||
width: 100%;
|
|
||||||
height: 55px;
|
|
||||||
}
|
|
||||||
|
|
||||||
#jump {
|
|
||||||
position: absolute;
|
|
||||||
width: 10px;
|
|
||||||
height: 10px;
|
|
||||||
border: 1px solid red;
|
|
||||||
z-index: 10000;
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
</style>
|
|
||||||
<script src="require.js" type="text/javascript" charset="utf-8"></script>
|
|
||||||
<script src="../build/ace/editor.js" type="text/javascript" charset="utf-8"></script>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div id="jump"></div>
|
|
||||||
|
|
||||||
<table id="controls">
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<label for="doc">Document:</label>
|
|
||||||
<select id="doc" size="1">
|
|
||||||
<option value="js">JS Document</option>
|
|
||||||
<option value="html">HTML Document</option>
|
|
||||||
<option value="css">CSS Document</option>
|
|
||||||
</select>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<label for="mode">Mode:</label>
|
|
||||||
<select id="mode" size="1">
|
|
||||||
<option value="text">Plain Text</option>
|
|
||||||
<option value="javascript">JavaScript</option>
|
|
||||||
<option value="xml">XML</option>
|
|
||||||
<option value="html">HTML</option>
|
|
||||||
<option value="css">CSS</option>
|
|
||||||
</select>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<label for="theme">Theme:</label>
|
|
||||||
<select id="theme" size="1">
|
|
||||||
<option value="ace/theme/textmate">TextMate</option>
|
|
||||||
<option value="ace/theme/eclipse">Eclipse</option>
|
|
||||||
<option value="ace/theme/dawn">Dawn</option>
|
|
||||||
<option value="ace/theme/idle_fingers">idleFingers</option>
|
|
||||||
<option value="ace/theme/twilight">Twilight</option>
|
|
||||||
</select>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<label for="select_style">Full line selections</label>
|
|
||||||
<input type="checkbox" name="select_style" id="select_style" checked>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<label for="highlight_active">Highlight active line</label>
|
|
||||||
<input type="checkbox" name="highlight_active" id="highlight_active" checked>
|
|
||||||
</td>
|
|
||||||
<td align="right">
|
|
||||||
<img src="logo.png">
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
<div id="editor">
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<script type="text/editor" id="jstext">function foo(items) {
|
|
||||||
for (var i=0; i<items.length; i++) {
|
|
||||||
alert(items[i] + "juhu");
|
|
||||||
}
|
|
||||||
}</script>
|
|
||||||
|
|
||||||
<script type="text/editor" id="csstext">.text-layer {
|
|
||||||
font-family: Monaco, "Courier New", monospace;
|
|
||||||
font-size: 12px;
|
|
||||||
cursor: text;
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<script type="text/editor" id="htmltext"><html>
|
|
||||||
<head>
|
|
||||||
|
|
||||||
<style type="text/css">
|
|
||||||
.text-layer {
|
|
||||||
font-family: Monaco, "Courier New", monospace;
|
|
||||||
font-size: 12px;
|
|
||||||
cursor: text;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1 style="color:red">Juhu Kinners</h1>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<script type="text/javascript" charset="utf-8">
|
|
||||||
|
|
||||||
require(
|
|
||||||
{baseUrl: "../build"},
|
|
||||||
[
|
|
||||||
"ace/lib/event",
|
|
||||||
"ace/editor",
|
|
||||||
"ace/virtual_renderer",
|
|
||||||
"ace/theme/textmate",
|
|
||||||
"ace/document",
|
|
||||||
"ace/mode/javascript",
|
|
||||||
"ace/mode/css",
|
|
||||||
"ace/mode/html",
|
|
||||||
"ace/mode/xml",
|
|
||||||
"ace/mode/text",
|
|
||||||
"ace/undomanager"
|
|
||||||
], function(event, Editor, Renderer, theme, Document, JavaScriptMode, CssMode, HtmlMode, XmlMode, TextMode, 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());
|
|
||||||
|
|
||||||
var docEl = document.getElementById("doc");
|
|
||||||
|
|
||||||
function onDocChange() {
|
|
||||||
var doc = getDoc();
|
|
||||||
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 {
|
|
||||||
modeEl.value = "text"
|
|
||||||
}
|
|
||||||
|
|
||||||
editor.focus();
|
|
||||||
}
|
|
||||||
docEl.onchange = onDocChange;
|
|
||||||
|
|
||||||
function getDoc() {
|
|
||||||
return docs[docEl.value];
|
|
||||||
}
|
|
||||||
|
|
||||||
var modeEl = document.getElementById("mode");
|
|
||||||
modeEl.onchange = function() {
|
|
||||||
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()
|
|
||||||
};
|
|
||||||
|
|
||||||
function getMode() {
|
|
||||||
return modes[modeEl.value];
|
|
||||||
}
|
|
||||||
|
|
||||||
var themeEl = document.getElementById("theme");
|
|
||||||
themeEl.onchange = function() {
|
|
||||||
editor.setTheme(themeEl.value);
|
|
||||||
};
|
|
||||||
|
|
||||||
var selectEl = document.getElementById("select_style");
|
|
||||||
selectEl.onchange = function() {
|
|
||||||
if (selectEl.checked) {
|
|
||||||
editor.setSelectionStyle("line");
|
|
||||||
} else {
|
|
||||||
editor.setSelectionStyle("text");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
var activeEl = document.getElementById("highlight_active");
|
|
||||||
activeEl.onchange = function() {
|
|
||||||
editor.setHighlightActiveLine(!!activeEl.checked);
|
|
||||||
};
|
|
||||||
|
|
||||||
var container = document.getElementById("editor");
|
|
||||||
var editor = new Editor(new Renderer(container, theme));
|
|
||||||
onDocChange();
|
|
||||||
|
|
||||||
window.jump = function() {
|
|
||||||
var jump = document.getElementById("jump")
|
|
||||||
var cursor = editor.getCursorPosition()
|
|
||||||
var pos = 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) + "px";
|
|
||||||
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) {
|
|
||||||
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";
|
|
||||||
}
|
|
||||||
|
|
||||||
editor.onTextInput(reader.result);
|
|
||||||
|
|
||||||
modeEl.value = mode;
|
|
||||||
editor.getDocument().setMode(modes[mode]);
|
|
||||||
}
|
|
||||||
reader.readAsText(file);
|
|
||||||
}
|
|
||||||
|
|
||||||
return event.preventDefault(e);
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
298
demo/editor.html
298
demo/editor.html
|
|
@ -1,298 +0,0 @@
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
|
|
||||||
"http://www.w3.org/TR/html4/strict.dtd">
|
|
||||||
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
|
||||||
<title>Editor</title>
|
|
||||||
<meta name="author" content="Fabian Jakobs">
|
|
||||||
|
|
||||||
<style type="text/css" media="screen">
|
|
||||||
|
|
||||||
html {
|
|
||||||
height: 100%;
|
|
||||||
overflow: hidden;
|
|
||||||
}
|
|
||||||
|
|
||||||
body {
|
|
||||||
overflow: hidden;
|
|
||||||
margin: 0;
|
|
||||||
padding: 0;
|
|
||||||
font: sans-serif;
|
|
||||||
height: 100%;
|
|
||||||
width: 100%;
|
|
||||||
font-family: Arial, Helvetica, sans-serif, Tahoma, Verdana;
|
|
||||||
font-size: 12px;
|
|
||||||
background: rgb(14, 98, 165);
|
|
||||||
color: white;
|
|
||||||
}
|
|
||||||
|
|
||||||
#editor {
|
|
||||||
top: 55px;
|
|
||||||
left: 0px;
|
|
||||||
background: white;
|
|
||||||
}
|
|
||||||
|
|
||||||
#controls {
|
|
||||||
width: 100%;
|
|
||||||
height: 55px;
|
|
||||||
}
|
|
||||||
|
|
||||||
#jump {
|
|
||||||
position: absolute;
|
|
||||||
width: 10px;
|
|
||||||
height: 10px;
|
|
||||||
border: 1px solid red;
|
|
||||||
z-index: 10000;
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
</style>
|
|
||||||
<script src="require.js" type="text/javascript" charset="utf-8"></script>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div id="jump"></div>
|
|
||||||
|
|
||||||
<table id="controls">
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<label for="doc">Document:</label>
|
|
||||||
<select id="doc" size="1">
|
|
||||||
<option value="js">JS Document</option>
|
|
||||||
<option value="html">HTML Document</option>
|
|
||||||
<option value="css">CSS Document</option>
|
|
||||||
</select>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<label for="mode">Mode:</label>
|
|
||||||
<select id="mode" size="1">
|
|
||||||
<option value="text">Plain Text</option>
|
|
||||||
<option value="javascript">JavaScript</option>
|
|
||||||
<option value="xml">XML</option>
|
|
||||||
<option value="html">HTML</option>
|
|
||||||
<option value="css">CSS</option>
|
|
||||||
</select>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<label for="theme">Theme:</label>
|
|
||||||
<select id="theme" size="1">
|
|
||||||
<option value="ace/theme/textmate">TextMate</option>
|
|
||||||
<option value="ace/theme/eclipse">Eclipse</option>
|
|
||||||
<option value="ace/theme/dawn">Dawn</option>
|
|
||||||
<option value="ace/theme/idle_fingers">idleFingers</option>
|
|
||||||
<option value="ace/theme/twilight">Twilight</option>
|
|
||||||
</select>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<label for="select_style">Full line selections</label>
|
|
||||||
<input type="checkbox" name="select_style" id="select_style" checked>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<label for="highlight_active">Highlight active line</label>
|
|
||||||
<input type="checkbox" name="highlight_active" id="highlight_active" checked>
|
|
||||||
</td>
|
|
||||||
<td align="right">
|
|
||||||
<img src="logo.png">
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
<div id="editor">
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<script type="text/editor" id="jstext">function foo(items) {
|
|
||||||
for (var i=0; i<items.length; i++) {
|
|
||||||
alert(items[i] + "juhu");
|
|
||||||
}
|
|
||||||
}</script>
|
|
||||||
|
|
||||||
<script type="text/editor" id="csstext">.text-layer {
|
|
||||||
font-family: Monaco, "Courier New", monospace;
|
|
||||||
font-size: 12px;
|
|
||||||
cursor: text;
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<script type="text/editor" id="htmltext"><html>
|
|
||||||
<head>
|
|
||||||
|
|
||||||
<style type="text/css">
|
|
||||||
.text-layer {
|
|
||||||
font-family: Monaco, "Courier New", monospace;
|
|
||||||
font-size: 12px;
|
|
||||||
cursor: text;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1 style="color:red">Juhu Kinners</h1>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<script type="text/javascript" charset="utf-8">
|
|
||||||
|
|
||||||
require(
|
|
||||||
{baseUrl: "../lib"},
|
|
||||||
[
|
|
||||||
"ace/lib/event",
|
|
||||||
"ace/editor",
|
|
||||||
"ace/virtual_renderer",
|
|
||||||
"ace/theme/textmate",
|
|
||||||
"ace/document",
|
|
||||||
"ace/mode/javascript",
|
|
||||||
"ace/mode/css",
|
|
||||||
"ace/mode/html",
|
|
||||||
"ace/mode/xml",
|
|
||||||
"ace/mode/text",
|
|
||||||
"ace/undomanager"
|
|
||||||
], function(event, Editor, Renderer, theme, Document, JavaScriptMode, CssMode, HtmlMode, XmlMode, TextMode, 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());
|
|
||||||
|
|
||||||
var docEl = document.getElementById("doc");
|
|
||||||
|
|
||||||
function onDocChange() {
|
|
||||||
var doc = getDoc();
|
|
||||||
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 {
|
|
||||||
modeEl.value = "text"
|
|
||||||
}
|
|
||||||
|
|
||||||
editor.focus();
|
|
||||||
}
|
|
||||||
docEl.onchange = onDocChange;
|
|
||||||
|
|
||||||
function getDoc() {
|
|
||||||
return docs[docEl.value];
|
|
||||||
}
|
|
||||||
|
|
||||||
var modeEl = document.getElementById("mode");
|
|
||||||
modeEl.onchange = function() {
|
|
||||||
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()
|
|
||||||
};
|
|
||||||
|
|
||||||
function getMode() {
|
|
||||||
return modes[modeEl.value];
|
|
||||||
}
|
|
||||||
|
|
||||||
var themeEl = document.getElementById("theme");
|
|
||||||
themeEl.onchange = function() {
|
|
||||||
editor.setTheme(themeEl.value);
|
|
||||||
};
|
|
||||||
|
|
||||||
var selectEl = document.getElementById("select_style");
|
|
||||||
selectEl.onchange = function() {
|
|
||||||
if (selectEl.checked) {
|
|
||||||
editor.setSelectionStyle("line");
|
|
||||||
} else {
|
|
||||||
editor.setSelectionStyle("text");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
var activeEl = document.getElementById("highlight_active");
|
|
||||||
activeEl.onchange = function() {
|
|
||||||
editor.setHighlightActiveLine(!!activeEl.checked);
|
|
||||||
};
|
|
||||||
|
|
||||||
var container = document.getElementById("editor");
|
|
||||||
var editor = new Editor(new Renderer(container, theme));
|
|
||||||
onDocChange();
|
|
||||||
|
|
||||||
window.jump = function() {
|
|
||||||
var jump = document.getElementById("jump")
|
|
||||||
var cursor = editor.getCursorPosition()
|
|
||||||
var pos = 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) + "px";
|
|
||||||
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) {
|
|
||||||
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";
|
|
||||||
}
|
|
||||||
|
|
||||||
editor.onTextInput(reader.result);
|
|
||||||
|
|
||||||
modeEl.value = mode;
|
|
||||||
editor.getDocument().setMode(modes[mode]);
|
|
||||||
}
|
|
||||||
reader.readAsText(file);
|
|
||||||
}
|
|
||||||
|
|
||||||
return event.preventDefault(e);
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
|
|
@ -13,16 +13,20 @@ setInterval: false, importScripts: false, jQuery: false */
|
||||||
var require, define;
|
var require, define;
|
||||||
(function () {
|
(function () {
|
||||||
//Change this version number for each release.
|
//Change this version number for each release.
|
||||||
var version = "0.14.5",
|
var version = "0.14.5+",
|
||||||
empty = {}, s,
|
empty = {}, s,
|
||||||
i, defContextName = "_", contextLoads = [],
|
i, defContextName = "_", contextLoads = [],
|
||||||
scripts, script, rePkg, src, m, dataMain, cfg = {}, setReadyState,
|
scripts, script, rePkg, src, m, dataMain, cfg = {}, setReadyState,
|
||||||
readyRegExp = /^(complete|loaded)$/,
|
|
||||||
commentRegExp = /(\/\*([\s\S]*?)\*\/|\/\/(.*)$)/mg,
|
commentRegExp = /(\/\*([\s\S]*?)\*\/|\/\/(.*)$)/mg,
|
||||||
cjsRequireRegExp = /require\(["']([\w-_\.\/]+)["']\)/g,
|
cjsRequireRegExp = /require\(["']([\w\!\-_\.\/]+)["']\)/g,
|
||||||
main,
|
main,
|
||||||
isBrowser = !!(typeof window !== "undefined" && navigator && document),
|
isBrowser = !!(typeof window !== "undefined" && navigator && document),
|
||||||
isWebWorker = !isBrowser && typeof importScripts !== "undefined",
|
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,
|
ostring = Object.prototype.toString,
|
||||||
ap = Array.prototype,
|
ap = Array.prototype,
|
||||||
aps = ap.slice, scrollIntervalId, req, baseElement,
|
aps = ap.slice, scrollIntervalId, req, baseElement,
|
||||||
|
|
@ -882,12 +886,12 @@ var require, define;
|
||||||
}
|
}
|
||||||
contextName = contextName || s.ctxName;
|
contextName = contextName || s.ctxName;
|
||||||
|
|
||||||
var ret, context = s.contexts[contextName];
|
var ret, context = s.contexts[contextName], nameProps;
|
||||||
|
|
||||||
//Normalize module name, if it contains . or ..
|
//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) {
|
if (ret === undefined) {
|
||||||
req.onError(new Error("require: module name '" +
|
req.onError(new Error("require: module name '" +
|
||||||
moduleName +
|
moduleName +
|
||||||
|
|
@ -940,7 +944,7 @@ var require, define;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
req.jsExtRegExp = /\.js$/;
|
req.jsExtRegExp = /^\/|:|\?|\.js$/;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Given a relative module name, like ./something, normalize it to
|
* Given a relative module name, like ./something, normalize it to
|
||||||
|
|
@ -955,12 +959,10 @@ var require, define;
|
||||||
//Adjust any relative paths.
|
//Adjust any relative paths.
|
||||||
var part;
|
var part;
|
||||||
if (name.charAt(0) === ".") {
|
if (name.charAt(0) === ".") {
|
||||||
if (!baseName) {
|
//If have a base name, try to normalize against it,
|
||||||
req.onError(new Error("Cannot normalize module name: " +
|
//otherwise, assume it is a top-level require that will
|
||||||
name +
|
//be relative to baseUrl in the end.
|
||||||
", no relative module name available."));
|
if (baseName) {
|
||||||
}
|
|
||||||
|
|
||||||
if (context.config.packages[baseName]) {
|
if (context.config.packages[baseName]) {
|
||||||
//If the baseName is a package name, then just treat it as one
|
//If the baseName is a package name, then just treat it as one
|
||||||
//name to concat the name with.
|
//name to concat the name with.
|
||||||
|
|
@ -981,12 +983,21 @@ var require, define;
|
||||||
name.splice(i, 1);
|
name.splice(i, 1);
|
||||||
i -= 1;
|
i -= 1;
|
||||||
} else if (part === "..") {
|
} 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);
|
name.splice(i - 1, 2);
|
||||||
i -= 2;
|
i -= 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
name = name.join("/");
|
name = name.join("/");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return name;
|
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
|
//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.
|
//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.
|
//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.
|
//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
|
//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.
|
//an extension, this method probably needs to be reworked.
|
||||||
|
|
@ -1078,6 +1089,11 @@ var require, define;
|
||||||
config.urlArgs) : url;
|
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
|
* Checks if all modules for a context are loaded, and if so, evaluates the
|
||||||
* new ones in right dependency order.
|
* 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
|
//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
|
//should not proceed. At the end of this function, if there are still things
|
||||||
//waiting, then checkLoaded will be called again.
|
//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
|
//Grab waiting and loaded lists here, since it could have changed since
|
||||||
//this function was first called.
|
//this function was first called.
|
||||||
|
|
|
||||||
183
editor.html
Normal file
183
editor.html
Normal file
|
|
@ -0,0 +1,183 @@
|
||||||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
|
||||||
|
"http://www.w3.org/TR/html4/strict.dtd">
|
||||||
|
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||||
|
<title>Editor</title>
|
||||||
|
<meta name="author" content="Fabian Jakobs">
|
||||||
|
|
||||||
|
<style type="text/css" media="screen">
|
||||||
|
|
||||||
|
html {
|
||||||
|
height: 100%;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
overflow: hidden;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
font: sans-serif;
|
||||||
|
height: 100%;
|
||||||
|
width: 100%;
|
||||||
|
font-family: Arial, Helvetica, sans-serif, Tahoma, Verdana;
|
||||||
|
font-size: 12px;
|
||||||
|
background: rgb(14, 98, 165);
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
#editor {
|
||||||
|
top: 55px;
|
||||||
|
left: 0px;
|
||||||
|
background: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
#controls {
|
||||||
|
width: 100%;
|
||||||
|
height: 55px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#jump {
|
||||||
|
position: absolute;
|
||||||
|
width: 10px;
|
||||||
|
height: 10px;
|
||||||
|
border: 1px solid red;
|
||||||
|
z-index: 10000;
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
#cockpit {
|
||||||
|
position: absolute;
|
||||||
|
width: 100%;
|
||||||
|
bottom: 0;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<script>
|
||||||
|
require = {
|
||||||
|
//urlArgs: "bust=" + (new Date()).getTime()
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
<script src="demo/require.js" type="text/javascript" charset="utf-8"></script>
|
||||||
|
<script src="demo/boot.js" type="text/javascript"></script>
|
||||||
|
<script>
|
||||||
|
setupPlugins({
|
||||||
|
pluginDirs: {
|
||||||
|
"../demo": {
|
||||||
|
singleFiles: ["demo_startup"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, function(plugin_manager, settings) {
|
||||||
|
var data = { env: { settings: settings } };
|
||||||
|
plugin_manager.catalog.startupPlugins(data, plugin_manager.REASONS.APP_STARTUP).then(function() {
|
||||||
|
var demo_startup = require("demo_startup");
|
||||||
|
demo_startup.launch(data.env);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="jump"></div>
|
||||||
|
|
||||||
|
<table id="controls">
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<label for="doc">Document:</label>
|
||||||
|
<select id="doc" size="1">
|
||||||
|
<option value="js">JS Document</option>
|
||||||
|
<option value="html">HTML Document</option>
|
||||||
|
<option value="css">CSS Document</option>
|
||||||
|
<option value="python">Python Document</option>
|
||||||
|
</select>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<label for="mode">Mode:</label>
|
||||||
|
<select id="mode" size="1">
|
||||||
|
<option value="text">Plain Text</option>
|
||||||
|
<option value="javascript">JavaScript</option>
|
||||||
|
<option value="xml">XML</option>
|
||||||
|
<option value="html">HTML</option>
|
||||||
|
<option value="css">CSS</option>
|
||||||
|
<option value="python">Python</option>
|
||||||
|
</select>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<label for="theme">Theme:</label>
|
||||||
|
<select id="theme" size="1">
|
||||||
|
<option value="ace/theme/textmate">TextMate</option>
|
||||||
|
<option value="ace/theme/eclipse">Eclipse</option>
|
||||||
|
<option value="ace/theme/dawn">Dawn</option>
|
||||||
|
<option value="ace/theme/idle_fingers">idleFingers</option>
|
||||||
|
<option value="ace/theme/twilight">Twilight</option>
|
||||||
|
</select>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<label for="select_style">Full line selections</label>
|
||||||
|
<input type="checkbox" name="select_style" id="select_style" checked>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<label for="highlight_active">Highlight active line</label>
|
||||||
|
<input type="checkbox" name="highlight_active" id="highlight_active" checked>
|
||||||
|
</td>
|
||||||
|
<td align="right">
|
||||||
|
<img src="demo/logo.png">
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<div id="editor">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script type="text/editor" id="jstext">function foo(items) {
|
||||||
|
for (var i=0; i<items.length; i++) {
|
||||||
|
alert(items[i] + "juhu");
|
||||||
|
}
|
||||||
|
}</script>
|
||||||
|
|
||||||
|
<script type="text/editor" id="csstext">.text-layer {
|
||||||
|
font-family: Monaco, "Courier New", monospace;
|
||||||
|
font-size: 12px;
|
||||||
|
cursor: text;
|
||||||
|
}</script>
|
||||||
|
|
||||||
|
<script type="text/editor" id="htmltext"><html>
|
||||||
|
<head>
|
||||||
|
|
||||||
|
<style type="text/css">
|
||||||
|
.text-layer {
|
||||||
|
font-family: Monaco, "Courier New", monospace;
|
||||||
|
font-size: 12px;
|
||||||
|
cursor: text;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1 style="color:red">Juhu Kinners</h1>
|
||||||
|
</body>
|
||||||
|
</html></script>
|
||||||
|
|
||||||
|
<script type="text/editor" id="pythontext">#!/usr/local/bin/python
|
||||||
|
|
||||||
|
import string, sys
|
||||||
|
|
||||||
|
# If no arguments were given, print a helpful message
|
||||||
|
if len(sys.argv)==1:
|
||||||
|
print 'Usage: celsius temp1 temp2 ...'
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
|
# Loop over the arguments
|
||||||
|
for i in sys.argv[1:]:
|
||||||
|
try:
|
||||||
|
fahrenheit=float(string.atoi(i))
|
||||||
|
except string.atoi_error:
|
||||||
|
print repr(i), "not a numeric value"
|
||||||
|
else:
|
||||||
|
celsius=(fahrenheit-32)*5.0/9.0
|
||||||
|
print '%i\260F = %i\260C' % (int(fahrenheit), int(celsius+.5))
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<input id="cockpit" type="text"/>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
@ -37,8 +37,8 @@
|
||||||
|
|
||||||
define(function(require, exports, module) {
|
define(function(require, exports, module) {
|
||||||
|
|
||||||
var oop = require("./lib/oop");
|
var oop = require("pilot/oop").oop;
|
||||||
var MEventEmitter = require("./event_emitter");
|
var EventEmitter = require("pilot/event_emitter").EventEmitter;
|
||||||
|
|
||||||
var BackgroundTokenizer = function(tokenizer, editor) {
|
var BackgroundTokenizer = function(tokenizer, editor) {
|
||||||
this.running = false;
|
this.running = false;
|
||||||
|
|
@ -82,7 +82,7 @@ var BackgroundTokenizer = function(tokenizer, editor) {
|
||||||
|
|
||||||
(function(){
|
(function(){
|
||||||
|
|
||||||
oop.implement(this, MEventEmitter);
|
oop.implement(this, EventEmitter);
|
||||||
|
|
||||||
this.setTokenizer = function(tokenizer) {
|
this.setTokenizer = function(tokenizer) {
|
||||||
this.tokenizer = tokenizer;
|
this.tokenizer = tokenizer;
|
||||||
|
|
@ -103,7 +103,7 @@ var BackgroundTokenizer = function(tokenizer, editor) {
|
||||||
first: firstRow,
|
first: firstRow,
|
||||||
last: lastRow
|
last: lastRow
|
||||||
};
|
};
|
||||||
this.$dispatchEvent("update", {data: data});
|
this._dispatchEvent("update", {data: data});
|
||||||
};
|
};
|
||||||
|
|
||||||
this.start = function(startRow) {
|
this.start = function(startRow) {
|
||||||
|
|
@ -164,5 +164,5 @@ var BackgroundTokenizer = function(tokenizer, editor) {
|
||||||
|
|
||||||
}).call(BackgroundTokenizer.prototype);
|
}).call(BackgroundTokenizer.prototype);
|
||||||
|
|
||||||
return BackgroundTokenizer;
|
exports.BackgroundTokenizer = BackgroundTokenizer;
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -37,158 +37,211 @@
|
||||||
|
|
||||||
define(function(require, exports, module) {
|
define(function(require, exports, module) {
|
||||||
|
|
||||||
var PluginManager = require("../plugin_manager");
|
var canon = require("pilot/canon");
|
||||||
|
|
||||||
PluginManager.registerCommand("selectall", function(editor, selection) {
|
canon.addCommand({
|
||||||
selection.selectAll();
|
name: "selectall",
|
||||||
|
exec: function(env, args, request) { env.selection.selectAll(); }
|
||||||
});
|
});
|
||||||
PluginManager.registerCommand("removeline", function(editor, selection) {
|
canon.addCommand({
|
||||||
editor.removeLines();
|
name: "removeline",
|
||||||
|
exec: function(env, args, request) { env.editor.removeLines(); }
|
||||||
});
|
});
|
||||||
PluginManager.registerCommand("gotoline", function(editor, selection) {
|
canon.addCommand({
|
||||||
|
name: "gotoline",
|
||||||
|
exec: function(env, args, request) {
|
||||||
var line = parseInt(prompt("Enter line number:"));
|
var line = parseInt(prompt("Enter line number:"));
|
||||||
if (!isNaN(line)) {
|
if (!isNaN(line)) {
|
||||||
editor.gotoLine(line);
|
env.editor.gotoLine(line);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
PluginManager.registerCommand("togglecomment", function(editor, selection) {
|
canon.addCommand({
|
||||||
editor.toggleCommentLines();
|
name: "togglecomment",
|
||||||
|
exec: function(env, args, request) { env.editor.toggleCommentLines(); }
|
||||||
});
|
});
|
||||||
PluginManager.registerCommand("findnext", function(editor, selection) {
|
canon.addCommand({
|
||||||
editor.findNext();
|
name: "findnext",
|
||||||
|
exec: function(env, args, request) { env.editor.findNext(); }
|
||||||
});
|
});
|
||||||
PluginManager.registerCommand("findprevious", function(editor, selection) {
|
canon.addCommand({
|
||||||
editor.findPrevious();
|
name: "findprevious",
|
||||||
|
exec: function(env, args, request) { env.editor.findPrevious(); }
|
||||||
});
|
});
|
||||||
PluginManager.registerCommand("find", function(editor, selection) {
|
canon.addCommand({
|
||||||
|
name: "find",
|
||||||
|
exec: function(env, args, request) {
|
||||||
var needle = prompt("Find:");
|
var needle = prompt("Find:");
|
||||||
editor.find(needle);
|
env.editor.find(needle);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
PluginManager.registerCommand("undo", function(editor, selection) {
|
canon.addCommand({
|
||||||
editor.undo();
|
name: "undo",
|
||||||
|
exec: function(env, args, request) { env.editor.undo(); }
|
||||||
});
|
});
|
||||||
PluginManager.registerCommand("redo", function(editor, selection) {
|
canon.addCommand({
|
||||||
editor.redo();
|
name: "redo",
|
||||||
|
exec: function(env, args, request) { env.editor.redo(); }
|
||||||
});
|
});
|
||||||
PluginManager.registerCommand("redo", function(editor, selection) {
|
canon.addCommand({
|
||||||
editor.redo();
|
name: "redo",
|
||||||
|
exec: function(env, args, request) { env.editor.redo(); }
|
||||||
});
|
});
|
||||||
PluginManager.registerCommand("overwrite", function(editor, selection) {
|
canon.addCommand({
|
||||||
editor.toggleOverwrite();
|
name: "overwrite",
|
||||||
|
exec: function(env, args, request) { env.editor.toggleOverwrite(); }
|
||||||
});
|
});
|
||||||
PluginManager.registerCommand("copylinesup", function(editor, selection) {
|
canon.addCommand({
|
||||||
editor.copyLinesUp();
|
name: "copylinesup",
|
||||||
|
exec: function(env, args, request) { env.editor.copyLinesUp(); }
|
||||||
});
|
});
|
||||||
PluginManager.registerCommand("movelinesup", function(editor, selection) {
|
canon.addCommand({
|
||||||
editor.moveLinesUp();
|
name: "movelinesup",
|
||||||
|
exec: function(env, args, request) { env.editor.moveLinesUp(); }
|
||||||
});
|
});
|
||||||
PluginManager.registerCommand("selecttostart", function(editor, selection) {
|
canon.addCommand({
|
||||||
selection.selectFileStart();
|
name: "selecttostart",
|
||||||
|
exec: function(env, args, request) { env.selection.selectFileStart(); }
|
||||||
});
|
});
|
||||||
PluginManager.registerCommand("gotostart", function(editor, selection) {
|
canon.addCommand({
|
||||||
editor.navigateFileStart();
|
name: "gotostart",
|
||||||
|
exec: function(env, args, request) { env.editor.navigateFileStart(); }
|
||||||
});
|
});
|
||||||
PluginManager.registerCommand("selectup", function(editor, selection) {
|
canon.addCommand({
|
||||||
selection.selectUp();
|
name: "selectup",
|
||||||
|
exec: function(env, args, request) { env.selection.selectUp(); }
|
||||||
});
|
});
|
||||||
PluginManager.registerCommand("golineup", function(editor, selection) {
|
canon.addCommand({
|
||||||
editor.navigateUp();
|
name: "golineup",
|
||||||
|
exec: function(env, args, request) { env.editor.navigateUp(); }
|
||||||
});
|
});
|
||||||
PluginManager.registerCommand("copylinesdown", function(editor, selection) {
|
canon.addCommand({
|
||||||
editor.copyLinesDown();
|
name: "copylinesdown",
|
||||||
|
exec: function(env, args, request) { env.editor.copyLinesDown(); }
|
||||||
});
|
});
|
||||||
PluginManager.registerCommand("movelinesdown", function(editor, selection) {
|
canon.addCommand({
|
||||||
editor.moveLinesDown();
|
name: "movelinesdown",
|
||||||
|
exec: function(env, args, request) { env.editor.moveLinesDown(); }
|
||||||
});
|
});
|
||||||
PluginManager.registerCommand("selecttoend", function(editor, selection) {
|
canon.addCommand({
|
||||||
selection.selectFileEnd();
|
name: "selecttoend",
|
||||||
|
exec: function(env, args, request) { env.selection.selectFileEnd(); }
|
||||||
});
|
});
|
||||||
PluginManager.registerCommand("gotoend", function(editor, selection) {
|
canon.addCommand({
|
||||||
editor.navigateFileEnd();
|
name: "gotoend",
|
||||||
|
exec: function(env, args, request) { env.editor.navigateFileEnd(); }
|
||||||
});
|
});
|
||||||
PluginManager.registerCommand("selectdown", function(editor, selection) {
|
canon.addCommand({
|
||||||
selection.selectDown();
|
name: "selectdown",
|
||||||
|
exec: function(env, args, request) { env.selection.selectDown(); }
|
||||||
});
|
});
|
||||||
PluginManager.registerCommand("godown", function(editor, selection) {
|
canon.addCommand({
|
||||||
editor.navigateDown();
|
name: "godown",
|
||||||
|
exec: function(env, args, request) { env.editor.navigateDown(); }
|
||||||
});
|
});
|
||||||
PluginManager.registerCommand("selectwordleft", function(editor, selection) {
|
canon.addCommand({
|
||||||
selection.selectWordLeft();
|
name: "selectwordleft",
|
||||||
|
exec: function(env, args, request) { env.selection.selectWordLeft(); }
|
||||||
});
|
});
|
||||||
PluginManager.registerCommand("gotowordleft", function(editor, selection) {
|
canon.addCommand({
|
||||||
editor.navigateWordLeft();
|
name: "gotowordleft",
|
||||||
|
exec: function(env, args, request) { env.editor.navigateWordLeft(); }
|
||||||
});
|
});
|
||||||
PluginManager.registerCommand("selecttolinestart", function(editor, selection) {
|
canon.addCommand({
|
||||||
selection.selectLineStart();
|
name: "selecttolinestart",
|
||||||
|
exec: function(env, args, request) { env.selection.selectLineStart(); }
|
||||||
});
|
});
|
||||||
PluginManager.registerCommand("gotolinestart", function(editor, selection) {
|
canon.addCommand({
|
||||||
editor.navigateLineStart();
|
name: "gotolinestart",
|
||||||
|
exec: function(env, args, request) { env.editor.navigateLineStart(); }
|
||||||
});
|
});
|
||||||
PluginManager.registerCommand("selectleft", function(editor, selection) {
|
canon.addCommand({
|
||||||
selection.selectLeft();
|
name: "selectleft",
|
||||||
|
exec: function(env, args, request) { env.selection.selectLeft(); }
|
||||||
});
|
});
|
||||||
PluginManager.registerCommand("gotoleft", function(editor, selection) {
|
canon.addCommand({
|
||||||
editor.navigateLeft();
|
name: "gotoleft",
|
||||||
|
exec: function(env, args, request) { env.editor.navigateLeft(); }
|
||||||
});
|
});
|
||||||
PluginManager.registerCommand("selectwordright", function(editor, selection) {
|
canon.addCommand({
|
||||||
selection.selectWordRight();
|
name: "selectwordright",
|
||||||
|
exec: function(env, args, request) { env.selection.selectWordRight(); }
|
||||||
});
|
});
|
||||||
PluginManager.registerCommand("gotowordright", function(editor, selection) {
|
canon.addCommand({
|
||||||
editor.navigateWordRight();
|
name: "gotowordright",
|
||||||
|
exec: function(env, args, request) { env.editor.navigateWordRight(); }
|
||||||
});
|
});
|
||||||
PluginManager.registerCommand("selecttolineend", function(editor, selection) {
|
canon.addCommand({
|
||||||
selection.selectLineEnd();
|
name: "selecttolineend",
|
||||||
|
exec: function(env, args, request) { env.selection.selectLineEnd(); }
|
||||||
});
|
});
|
||||||
PluginManager.registerCommand("gotolineend", function(editor, selection) {
|
canon.addCommand({
|
||||||
editor.navigateLineEnd();
|
name: "gotolineend",
|
||||||
|
exec: function(env, args, request) { env.editor.navigateLineEnd(); }
|
||||||
});
|
});
|
||||||
PluginManager.registerCommand("selectright", function(editor, selection) {
|
canon.addCommand({
|
||||||
selection.selectRight();
|
name: "selectright",
|
||||||
|
exec: function(env, args, request) { env.selection.selectRight(); }
|
||||||
});
|
});
|
||||||
PluginManager.registerCommand("gotoright", function(editor, selection) {
|
canon.addCommand({
|
||||||
editor.navigateRight();
|
name: "gotoright",
|
||||||
|
exec: function(env, args, request) { env.editor.navigateRight(); }
|
||||||
});
|
});
|
||||||
PluginManager.registerCommand("selectpagedown", function(editor, selection) {
|
canon.addCommand({
|
||||||
editor.selectPageDown();
|
name: "selectpagedown",
|
||||||
|
exec: function(env, args, request) { env.editor.selectPageDown(); }
|
||||||
});
|
});
|
||||||
PluginManager.registerCommand("pagedown", function(editor, selection) {
|
canon.addCommand({
|
||||||
editor.scrollPageDown();
|
name: "pagedown",
|
||||||
|
exec: function(env, args, request) { env.editor.scrollPageDown(); }
|
||||||
});
|
});
|
||||||
PluginManager.registerCommand("gotopagedown", function(editor, selection) {
|
canon.addCommand({
|
||||||
editor.gotoPageDown();
|
name: "gotopagedown",
|
||||||
|
exec: function(env, args, request) { env.editor.gotoPageDown(); }
|
||||||
});
|
});
|
||||||
PluginManager.registerCommand("selectpageup", function(editor, selection) {
|
canon.addCommand({
|
||||||
editor.selectPageUp();
|
name: "selectpageup",
|
||||||
|
exec: function(env, args, request) { env.editor.selectPageUp(); }
|
||||||
});
|
});
|
||||||
PluginManager.registerCommand("pageup", function(editor, selection) {
|
canon.addCommand({
|
||||||
editor.scrollPageUp();
|
name: "pageup",
|
||||||
|
exec: function(env, args, request) { env.editor.scrollPageUp(); }
|
||||||
});
|
});
|
||||||
PluginManager.registerCommand("gotopageup", function(editor, selection) {
|
canon.addCommand({
|
||||||
editor.gotoPageUp();
|
name: "gotopageup",
|
||||||
|
exec: function(env, args, request) { env.editor.gotoPageUp(); }
|
||||||
});
|
});
|
||||||
PluginManager.registerCommand("selectlinestart", function(editor, selection) {
|
canon.addCommand({
|
||||||
selection.selectLineStart();
|
name: "selectlinestart",
|
||||||
|
exec: function(env, args, request) { env.selection.selectLineStart(); }
|
||||||
});
|
});
|
||||||
PluginManager.registerCommand("gotolinestart", function(editor, selection) {
|
canon.addCommand({
|
||||||
editor.navigateLineStart();
|
name: "gotolinestart",
|
||||||
|
exec: function(env, args, request) { env.editor.navigateLineStart(); }
|
||||||
});
|
});
|
||||||
PluginManager.registerCommand("selectlineend", function(editor, selection) {
|
canon.addCommand({
|
||||||
selection.selectLineEnd();
|
name: "selectlineend",
|
||||||
|
exec: function(env, args, request) { env.selection.selectLineEnd(); }
|
||||||
});
|
});
|
||||||
PluginManager.registerCommand("gotolineend", function(editor, selection) {
|
canon.addCommand({
|
||||||
editor.navigateLineEnd();
|
name: "gotolineend",
|
||||||
|
exec: function(env, args, request) { env.editor.navigateLineEnd(); }
|
||||||
});
|
});
|
||||||
PluginManager.registerCommand("del", function(editor, selection) {
|
canon.addCommand({
|
||||||
editor.removeRight();
|
name: "del",
|
||||||
|
exec: function(env, args, request) { env.editor.removeRight(); }
|
||||||
});
|
});
|
||||||
PluginManager.registerCommand("backspace", function(editor, selection) {
|
canon.addCommand({
|
||||||
editor.removeLeft();
|
name: "backspace",
|
||||||
|
exec: function(env, args, request) { env.editor.removeLeft(); }
|
||||||
});
|
});
|
||||||
PluginManager.registerCommand("outdent", function(editor, selection) {
|
canon.addCommand({
|
||||||
editor.blockOutdent();
|
name: "outdent",
|
||||||
|
exec: function(env, args, request) { env.editor.blockOutdent(); }
|
||||||
});
|
});
|
||||||
PluginManager.registerCommand("indent", function(editor, selection) {
|
canon.addCommand({
|
||||||
editor.indent();
|
name: "indent",
|
||||||
|
exec: function(env, args, request) { env.editor.indent(); }
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
@ -37,7 +37,7 @@
|
||||||
|
|
||||||
define(function(require, exports, module) {
|
define(function(require, exports, module) {
|
||||||
|
|
||||||
return {
|
exports.bindings = {
|
||||||
"selectall": "Command-A",
|
"selectall": "Command-A",
|
||||||
"removeline": "Command-D",
|
"removeline": "Command-D",
|
||||||
"gotoline": "Command-L",
|
"gotoline": "Command-L",
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@
|
||||||
|
|
||||||
define(function(require, exports, module) {
|
define(function(require, exports, module) {
|
||||||
|
|
||||||
return {
|
exports.bindings = {
|
||||||
"selectall": "Ctrl-A",
|
"selectall": "Ctrl-A",
|
||||||
"removeline": "Ctrl-D",
|
"removeline": "Ctrl-D",
|
||||||
"gotoline": "Ctrl-L",
|
"gotoline": "Ctrl-L",
|
||||||
|
|
|
||||||
|
|
@ -37,17 +37,17 @@
|
||||||
|
|
||||||
define(function(require, exports, module) {
|
define(function(require, exports, module) {
|
||||||
|
|
||||||
var oop = require("./lib/oop");
|
var oop = require("pilot/oop").oop;
|
||||||
var lang = require("./lib/lang");
|
var lang = require("pilot/lang").lang;
|
||||||
var MEventEmitter = require("./event_emitter");
|
var EventEmitter = require("pilot/event_emitter").EventEmitter;
|
||||||
var Selection = require("./selection");
|
var Selection = require("ace/selection").Selection;
|
||||||
var TextMode = require("./mode/text");
|
var TextMode = require("ace/mode/text").Mode;
|
||||||
var Range = require("./range");
|
var Range = require("ace/range").Range;
|
||||||
|
|
||||||
var Document = function(text, mode) {
|
var Document = function(text, mode) {
|
||||||
|
|
||||||
this.modified = true;
|
this.modified = true;
|
||||||
this.lines = [];
|
this.lines = [""];
|
||||||
this.selection = new Selection(this);
|
this.selection = new Selection(this);
|
||||||
this.$breakpoints = [];
|
this.$breakpoints = [];
|
||||||
|
|
||||||
|
|
@ -66,7 +66,7 @@ var Document = function(text, mode) {
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
oop.implement(this, MEventEmitter);
|
oop.implement(this, EventEmitter);
|
||||||
|
|
||||||
this.$undoManager = null;
|
this.$undoManager = null;
|
||||||
|
|
||||||
|
|
@ -95,7 +95,7 @@ var Document = function(text, mode) {
|
||||||
firstRow: firstRow,
|
firstRow: firstRow,
|
||||||
lastRow: lastRow
|
lastRow: lastRow
|
||||||
};
|
};
|
||||||
this.$dispatchEvent("change", { data: data});
|
this._dispatchEvent("change", { data: data});
|
||||||
};
|
};
|
||||||
|
|
||||||
this.setUndoManager = function(undoManager) {
|
this.setUndoManager = function(undoManager) {
|
||||||
|
|
@ -154,7 +154,7 @@ var Document = function(text, mode) {
|
||||||
|
|
||||||
this.modified = true;
|
this.modified = true;
|
||||||
this.$tabSize = tabSize;
|
this.$tabSize = tabSize;
|
||||||
this.$dispatchEvent("changeTabSize");
|
this._dispatchEvent("changeTabSize");
|
||||||
};
|
};
|
||||||
|
|
||||||
this.getTabSize = function() {
|
this.getTabSize = function() {
|
||||||
|
|
@ -170,22 +170,22 @@ var Document = function(text, mode) {
|
||||||
for (var i=0; i<rows.length; i++) {
|
for (var i=0; i<rows.length; i++) {
|
||||||
this.$breakpoints[rows[i]] = true;
|
this.$breakpoints[rows[i]] = true;
|
||||||
}
|
}
|
||||||
this.$dispatchEvent("changeBreakpoint", {});
|
this._dispatchEvent("changeBreakpoint", {});
|
||||||
};
|
};
|
||||||
|
|
||||||
this.clearBreakpoints = function() {
|
this.clearBreakpoints = function() {
|
||||||
this.$breakpoints = [];
|
this.$breakpoints = [];
|
||||||
this.$dispatchEvent("changeBreakpoint", {});
|
this._dispatchEvent("changeBreakpoint", {});
|
||||||
};
|
};
|
||||||
|
|
||||||
this.setBreakpoint = function(row) {
|
this.setBreakpoint = function(row) {
|
||||||
this.$breakpoints[row] = true;
|
this.$breakpoints[row] = true;
|
||||||
this.$dispatchEvent("changeBreakpoint", {});
|
this._dispatchEvent("changeBreakpoint", {});
|
||||||
};
|
};
|
||||||
|
|
||||||
this.clearBreakpoint = function(row) {
|
this.clearBreakpoint = function(row) {
|
||||||
delete this.$breakpoints[row];
|
delete this.$breakpoints[row];
|
||||||
this.$dispatchEvent("changeBreakpoint", {});
|
this._dispatchEvent("changeBreakpoint", {});
|
||||||
};
|
};
|
||||||
|
|
||||||
this.$detectNewLine = function(text) {
|
this.$detectNewLine = function(text) {
|
||||||
|
|
@ -261,7 +261,7 @@ var Document = function(text, mode) {
|
||||||
if (this.$mode === mode) return;
|
if (this.$mode === mode) return;
|
||||||
|
|
||||||
this.$mode = mode;
|
this.$mode = mode;
|
||||||
this.$dispatchEvent("changeMode");
|
this._dispatchEvent("changeMode");
|
||||||
};
|
};
|
||||||
|
|
||||||
this.getMode = function() {
|
this.getMode = function() {
|
||||||
|
|
@ -276,7 +276,7 @@ var Document = function(text, mode) {
|
||||||
if (this.$scrollTop === scrollTopRow) return;
|
if (this.$scrollTop === scrollTopRow) return;
|
||||||
|
|
||||||
this.$scrollTop = scrollTopRow;
|
this.$scrollTop = scrollTopRow;
|
||||||
this.$dispatchEvent("changeScrollTop");
|
this._dispatchEvent("changeScrollTop");
|
||||||
};
|
};
|
||||||
|
|
||||||
this.getScrollTopRow = function() {
|
this.getScrollTopRow = function() {
|
||||||
|
|
@ -748,5 +748,5 @@ var Document = function(text, mode) {
|
||||||
|
|
||||||
}).call(Document.prototype);
|
}).call(Document.prototype);
|
||||||
|
|
||||||
return Document;
|
exports.Document = Document;
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -37,16 +37,16 @@
|
||||||
|
|
||||||
define(function(require, exports, module) {
|
define(function(require, exports, module) {
|
||||||
|
|
||||||
var oop = require("./lib/oop");
|
var oop = require("pilot/oop").oop;
|
||||||
var event = require("./lib/event");
|
var event = require("pilot/event").event;
|
||||||
var lang = require("./lib/lang");
|
var lang = require("pilot/lang").lang;
|
||||||
var TextInput = require("./textinput");
|
var TextInput = require("ace/textinput").TextInput;
|
||||||
var KeyBinding = require("./keybinding");
|
var KeyBinding = require("ace/keybinding").KeyBinding;
|
||||||
var Document = require("./document");
|
var Document = require("ace/document").Document;
|
||||||
var Search = require("./search");
|
var Search = require("ace/search").Search;
|
||||||
var BackgroundTokenizer = require("./background_tokenizer");
|
var BackgroundTokenizer = require("ace/background_tokenizer").BackgroundTokenizer;
|
||||||
var Range = require("./range");
|
var Range = require("ace/range").Range;
|
||||||
var MEventEmitter = require("./event_emitter");
|
var EventEmitter = require("pilot/event_emitter").EventEmitter;
|
||||||
|
|
||||||
var Editor =function(renderer, doc) {
|
var Editor =function(renderer, doc) {
|
||||||
var container = renderer.getContainerElement();
|
var container = renderer.getContainerElement();
|
||||||
|
|
@ -84,7 +84,7 @@ var Editor =function(renderer, doc) {
|
||||||
|
|
||||||
(function(){
|
(function(){
|
||||||
|
|
||||||
oop.implement(this, MEventEmitter);
|
oop.implement(this, EventEmitter);
|
||||||
|
|
||||||
this.$forwardEvents = {
|
this.$forwardEvents = {
|
||||||
gutterclick: 1,
|
gutterclick: 1,
|
||||||
|
|
@ -494,7 +494,7 @@ var Editor =function(renderer, doc) {
|
||||||
this.onCursorChange();
|
this.onCursorChange();
|
||||||
this.$blockScrolling = false;
|
this.$blockScrolling = false;
|
||||||
|
|
||||||
this.$dispatchEvent("changeOverwrite", {data: overwrite});
|
this._dispatchEvent("changeOverwrite", {data: overwrite});
|
||||||
};
|
};
|
||||||
|
|
||||||
this.getOverwrite = function() {
|
this.getOverwrite = function() {
|
||||||
|
|
@ -521,7 +521,7 @@ var Editor =function(renderer, doc) {
|
||||||
|
|
||||||
this.$selectionStyle = style;
|
this.$selectionStyle = style;
|
||||||
this.onSelectionChange();
|
this.onSelectionChange();
|
||||||
this.$dispatchEvent("changeSelectionStyle", {data: style});
|
this._dispatchEvent("changeSelectionStyle", {data: style});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1041,5 +1041,5 @@ var Editor =function(renderer, doc) {
|
||||||
}).call(Editor.prototype);
|
}).call(Editor.prototype);
|
||||||
|
|
||||||
|
|
||||||
return Editor;
|
exports.Editor = Editor;
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -37,12 +37,12 @@
|
||||||
|
|
||||||
define(function(require, exports, module) {
|
define(function(require, exports, module) {
|
||||||
|
|
||||||
var core = require("./lib/core");
|
var core = require("pilot/core").core;
|
||||||
var event = require("./lib/event");
|
var event = require("pilot/event").event;
|
||||||
var default_mac = require("./conf/keybindings/default_mac");
|
var default_mac = require("ace/conf/keybindings/default_mac").bindings;
|
||||||
var default_win = require("./conf/keybindings/default_win");
|
var default_win = require("ace/conf/keybindings/default_win").bindings;
|
||||||
var PluginManager = require("./plugin_manager");
|
var canon = require("pilot/canon");
|
||||||
require("./commands/default_commands");
|
require("ace/commands/default_commands");
|
||||||
|
|
||||||
var KeyBinding = function(element, editor, config) {
|
var KeyBinding = function(element, editor, config) {
|
||||||
this.setConfig(config);
|
this.setConfig(config);
|
||||||
|
|
@ -55,10 +55,9 @@ var KeyBinding = function(element, editor, config) {
|
||||||
|
|
||||||
var commandName = (_self.config.reverse[hashId] || {})[(key
|
var commandName = (_self.config.reverse[hashId] || {})[(key
|
||||||
|| String.fromCharCode(e.keyCode)).toLowerCase()];
|
|| String.fromCharCode(e.keyCode)).toLowerCase()];
|
||||||
var command = PluginManager.commands[commandName];
|
|
||||||
|
|
||||||
if (command) {
|
var success = canon.exec(commandName, {editor: editor});
|
||||||
command(editor, editor.getSelection());
|
if (success) {
|
||||||
return event.stopEvent(e);
|
return event.stopEvent(e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -149,5 +148,5 @@ var KeyBinding = function(element, editor, config) {
|
||||||
|
|
||||||
}).call(KeyBinding.prototype);
|
}).call(KeyBinding.prototype);
|
||||||
|
|
||||||
return KeyBinding;
|
exports.KeyBinding = KeyBinding;
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@
|
||||||
|
|
||||||
define(function(require, exports, module) {
|
define(function(require, exports, module) {
|
||||||
|
|
||||||
var dom = require("../lib/dom");
|
var dom = require("pilot/dom").dom;
|
||||||
|
|
||||||
var Cursor = function(parentEl) {
|
var Cursor = function(parentEl) {
|
||||||
this.element = document.createElement("div");
|
this.element = document.createElement("div");
|
||||||
|
|
@ -145,5 +145,6 @@ var Cursor = function(parentEl) {
|
||||||
|
|
||||||
}).call(Cursor.prototype);
|
}).call(Cursor.prototype);
|
||||||
|
|
||||||
return Cursor;
|
exports.Cursor = Cursor;
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -81,5 +81,6 @@ var Gutter = function(parentEl) {
|
||||||
|
|
||||||
}).call(Gutter.prototype);
|
}).call(Gutter.prototype);
|
||||||
|
|
||||||
return Gutter;
|
exports.Gutter = Gutter;
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@
|
||||||
|
|
||||||
define(function(require, exports, module) {
|
define(function(require, exports, module) {
|
||||||
|
|
||||||
var Range = require("../range");
|
var Range = require("ace/range").Range;
|
||||||
|
|
||||||
var Marker = function(parentEl) {
|
var Marker = function(parentEl) {
|
||||||
this.element = document.createElement("div");
|
this.element = document.createElement("div");
|
||||||
|
|
@ -181,5 +181,6 @@ var Marker = function(parentEl) {
|
||||||
|
|
||||||
}).call(Marker.prototype);
|
}).call(Marker.prototype);
|
||||||
|
|
||||||
return Marker;
|
exports.Marker = Marker;
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -37,9 +37,9 @@
|
||||||
|
|
||||||
define(function(require, exports, module) {
|
define(function(require, exports, module) {
|
||||||
|
|
||||||
var oop = require("../lib/oop");
|
var oop = require("pilot/oop").oop;
|
||||||
var dom = require("../lib/dom");
|
var dom = require("pilot/dom").dom;
|
||||||
var MEventEmitter = require("../event_emitter");
|
var EventEmitter = require("pilot/event_emitter").EventEmitter;
|
||||||
|
|
||||||
var Text = function(parentEl) {
|
var Text = function(parentEl) {
|
||||||
this.element = document.createElement("div");
|
this.element = document.createElement("div");
|
||||||
|
|
@ -52,7 +52,7 @@ var Text = function(parentEl) {
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
oop.implement(this, MEventEmitter);
|
oop.implement(this, EventEmitter);
|
||||||
|
|
||||||
this.EOF_CHAR = "¶";
|
this.EOF_CHAR = "¶";
|
||||||
this.EOL_CHAR = "¬";
|
this.EOL_CHAR = "¬";
|
||||||
|
|
@ -77,7 +77,7 @@ var Text = function(parentEl) {
|
||||||
var size = self.$measureSizes();
|
var size = self.$measureSizes();
|
||||||
if (self.$characterSize.width !== size.width || self.$characterSize.height !== size.height) {
|
if (self.$characterSize.width !== size.width || self.$characterSize.height !== size.height) {
|
||||||
self.$characterSize = size;
|
self.$characterSize = size;
|
||||||
self.$dispatchEvent("changeCharaterSize", {data: size});
|
self._dispatchEvent("changeCharaterSize", {data: size});
|
||||||
}
|
}
|
||||||
}, 500);
|
}, 500);
|
||||||
};
|
};
|
||||||
|
|
@ -299,5 +299,6 @@ var Text = function(parentEl) {
|
||||||
|
|
||||||
}).call(Text.prototype);
|
}).call(Text.prototype);
|
||||||
|
|
||||||
return Text;
|
exports.Text = Text;
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -37,17 +37,17 @@
|
||||||
|
|
||||||
define(function(require, exports, module) {
|
define(function(require, exports, module) {
|
||||||
|
|
||||||
var oop = require("../lib/oop");
|
var oop = require("pilot/oop").oop;
|
||||||
var TextMode = require("./text");
|
var TextMode = require("ace/mode/text").Mode;
|
||||||
var Tokenizer = require("../tokenizer");
|
var Tokenizer = require("ace/tokenizer").Tokenizer;
|
||||||
var CssHighlightRules = require("./css_highlight_rules");
|
var CssHighlightRules = require("ace/mode/css_highlight_rules").CssHighlightRules;
|
||||||
var MatchingBraceOutdent = require("./matching_brace_outdent");
|
var MatchingBraceOutdent = require("ace/mode/matching_brace_outdent").MatchingBraceOutdent;
|
||||||
|
|
||||||
var Css = function() {
|
var Mode = function() {
|
||||||
this.$tokenizer = new Tokenizer(new CssHighlightRules().getRules());
|
this.$tokenizer = new Tokenizer(new CssHighlightRules().getRules());
|
||||||
this.$outdent = new MatchingBraceOutdent();
|
this.$outdent = new MatchingBraceOutdent();
|
||||||
};
|
};
|
||||||
oop.inherits(Css, TextMode);
|
oop.inherits(Mode, TextMode);
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
|
|
@ -76,7 +76,8 @@ oop.inherits(Css, TextMode);
|
||||||
return this.$outdent.autoOutdent(doc, row);
|
return this.$outdent.autoOutdent(doc, row);
|
||||||
};
|
};
|
||||||
|
|
||||||
}).call(Css.prototype);
|
}).call(Mode.prototype);
|
||||||
|
|
||||||
|
exports.Mode = Mode;
|
||||||
|
|
||||||
return Css;
|
|
||||||
});
|
});
|
||||||
|
|
@ -37,9 +37,9 @@
|
||||||
|
|
||||||
define(function(require, exports, module) {
|
define(function(require, exports, module) {
|
||||||
|
|
||||||
var oop = require("../lib/oop");
|
var oop = require("pilot/oop").oop;
|
||||||
var lang = require("../lib/lang");
|
var lang = require("pilot/lang").lang;
|
||||||
var TextHighlightRules = require("./text_highlight_rules");
|
var TextHighlightRules = require("ace/mode/text_highlight_rules").TextHighlightRules;
|
||||||
|
|
||||||
var CssHighlightRules = function() {
|
var CssHighlightRules = function() {
|
||||||
|
|
||||||
|
|
@ -229,5 +229,6 @@ var CssHighlightRules = function() {
|
||||||
|
|
||||||
oop.inherits(CssHighlightRules, TextHighlightRules);
|
oop.inherits(CssHighlightRules, TextHighlightRules);
|
||||||
|
|
||||||
return CssHighlightRules;
|
exports.CssHighlightRules = CssHighlightRules;
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -37,8 +37,8 @@
|
||||||
|
|
||||||
define(function(require, exports, module) {
|
define(function(require, exports, module) {
|
||||||
|
|
||||||
var oop = require("../lib/oop");
|
var oop = require("pilot/oop").oop;
|
||||||
var TextHighlightRules = require("./text_highlight_rules");
|
var TextHighlightRules = require("ace/mode/text_highlight_rules").TextHighlightRules;
|
||||||
|
|
||||||
var DocCommentHighlightRules = function() {
|
var DocCommentHighlightRules = function() {
|
||||||
|
|
||||||
|
|
@ -77,5 +77,6 @@ oop.inherits(DocCommentHighlightRules, TextHighlightRules);
|
||||||
|
|
||||||
}).call(DocCommentHighlightRules.prototype);
|
}).call(DocCommentHighlightRules.prototype);
|
||||||
|
|
||||||
return DocCommentHighlightRules;
|
exports.DocCommentHighlightRules = DocCommentHighlightRules;
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
@ -37,20 +37,20 @@
|
||||||
|
|
||||||
define(function(require, exports, module) {
|
define(function(require, exports, module) {
|
||||||
|
|
||||||
var oop = require("../lib/oop");
|
var oop = require("pilot/oop").oop;
|
||||||
var TextMode = require("./text");
|
var TextMode = require("ace/mode/text").Mode;
|
||||||
var JavaScriptMode = require("./javascript");
|
var JavaScriptMode = require("ace/mode/javascript").Mode;
|
||||||
var CssMode = require("./css");
|
var CssMode = require("ace/mode/css").Mode;
|
||||||
var Tokenizer = require("../tokenizer");
|
var Tokenizer = require("ace/tokenizer").Tokenizer;
|
||||||
var HtmlHighlightRules = require("./html_highlight_rules");
|
var HtmlHighlightRules = require("ace/mode/html_highlight_rules").HtmlHighlightRules;
|
||||||
|
|
||||||
var Html = function() {
|
var Mode = function() {
|
||||||
this.$tokenizer = new Tokenizer(new HtmlHighlightRules().getRules());
|
this.$tokenizer = new Tokenizer(new HtmlHighlightRules().getRules());
|
||||||
|
|
||||||
this.$js = new JavaScriptMode();
|
this.$js = new JavaScriptMode();
|
||||||
this.$css = new CssMode();
|
this.$css = new CssMode();
|
||||||
};
|
};
|
||||||
oop.inherits(Html, TextMode);
|
oop.inherits(Mode, TextMode);
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
|
|
@ -95,7 +95,7 @@ oop.inherits(Html, TextMode);
|
||||||
return defaultHandler ? defaultHandler() : undefined;
|
return defaultHandler ? defaultHandler() : undefined;
|
||||||
};
|
};
|
||||||
|
|
||||||
}).call(Html.prototype);
|
}).call(Mode.prototype);
|
||||||
|
|
||||||
return Html;
|
exports.Mode = Mode;
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -37,10 +37,10 @@
|
||||||
|
|
||||||
define(function(require, exports, module) {
|
define(function(require, exports, module) {
|
||||||
|
|
||||||
var oop = require("../lib/oop");
|
var oop = require("pilot/oop").oop;
|
||||||
var CssHighlightRules = require("./css_highlight_rules");
|
var CssHighlightRules = require("ace/mode/css_highlight_rules").CssHighlightRules;
|
||||||
var JavaScriptHighlightRules = require("./javascript_highlight_rules");
|
var JavaScriptHighlightRules = require("ace/mode/javascript_highlight_rules").JavaScriptHighlightRules;
|
||||||
var TextHighlightRules = require("./text_highlight_rules");
|
var TextHighlightRules = require("ace/mode/text_highlight_rules").TextHighlightRules;
|
||||||
|
|
||||||
var HtmlHighlightRules = function() {
|
var HtmlHighlightRules = function() {
|
||||||
|
|
||||||
|
|
@ -178,5 +178,5 @@ var HtmlHighlightRules = function() {
|
||||||
|
|
||||||
oop.inherits(HtmlHighlightRules, TextHighlightRules);
|
oop.inherits(HtmlHighlightRules, TextHighlightRules);
|
||||||
|
|
||||||
return HtmlHighlightRules;
|
exports.HtmlHighlightRules = HtmlHighlightRules;
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -37,18 +37,18 @@
|
||||||
|
|
||||||
define(function(require, exports, module) {
|
define(function(require, exports, module) {
|
||||||
|
|
||||||
var oop = require("../lib/oop");
|
var oop = require("pilot/oop").oop;
|
||||||
var TextMode = require("./text");
|
var TextMode = require("ace/mode/text").Mode;
|
||||||
var Tokenizer = require("../tokenizer");
|
var Tokenizer = require("ace/tokenizer").Tokenizer;
|
||||||
var JavaScriptHighlightRules = require("./javascript_highlight_rules");
|
var JavaScriptHighlightRules = require("ace/mode/javascript_highlight_rules").JavaScriptHighlightRules;
|
||||||
var MatchingBraceOutdent = require("./matching_brace_outdent");
|
var MatchingBraceOutdent = require("ace/mode/matching_brace_outdent").MatchingBraceOutdent;
|
||||||
var Range = require("../range");
|
var Range = require("ace/range").Range;
|
||||||
|
|
||||||
var JavaScript = function() {
|
var Mode = function() {
|
||||||
this.$tokenizer = new Tokenizer(new JavaScriptHighlightRules().getRules());
|
this.$tokenizer = new Tokenizer(new JavaScriptHighlightRules().getRules());
|
||||||
this.$outdent = new MatchingBraceOutdent();
|
this.$outdent = new MatchingBraceOutdent();
|
||||||
};
|
};
|
||||||
oop.inherits(JavaScript, TextMode);
|
oop.inherits(Mode, TextMode);
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
|
|
@ -107,11 +107,6 @@ oop.inherits(JavaScript, TextMode);
|
||||||
indent += " ";
|
indent += " ";
|
||||||
}
|
}
|
||||||
indent += "* ";
|
indent += "* ";
|
||||||
}{
|
|
||||||
if (match[1]) {
|
|
||||||
indent += " ";
|
|
||||||
}
|
|
||||||
indent += "* ";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -126,7 +121,7 @@ oop.inherits(JavaScript, TextMode);
|
||||||
return this.$outdent.autoOutdent(doc, row);
|
return this.$outdent.autoOutdent(doc, row);
|
||||||
};
|
};
|
||||||
|
|
||||||
}).call(JavaScript.prototype);
|
}).call(Mode.prototype);
|
||||||
|
|
||||||
return JavaScript;
|
exports.Mode = Mode;
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -37,10 +37,10 @@
|
||||||
|
|
||||||
define(function(require, exports, module) {
|
define(function(require, exports, module) {
|
||||||
|
|
||||||
var oop = require("../lib/oop");
|
var oop = require("pilot/oop").oop;
|
||||||
var lang = require("../lib/lang");
|
var lang = require("pilot/lang").lang;
|
||||||
var DocCommentHighlightRules = require("./doc_comment_highlight_rules");
|
var DocCommentHighlightRules = require("ace/mode/doc_comment_highlight_rules").DocCommentHighlightRules;
|
||||||
var TextHighlightRules = require("./text_highlight_rules");
|
var TextHighlightRules = require("ace/mode/text_highlight_rules").TextHighlightRules;
|
||||||
|
|
||||||
JavaScriptHighlightRules = function() {
|
JavaScriptHighlightRules = function() {
|
||||||
|
|
||||||
|
|
@ -159,5 +159,5 @@ JavaScriptHighlightRules = function() {
|
||||||
|
|
||||||
oop.inherits(JavaScriptHighlightRules, TextHighlightRules);
|
oop.inherits(JavaScriptHighlightRules, TextHighlightRules);
|
||||||
|
|
||||||
return JavaScriptHighlightRules;
|
exports.JavaScriptHighlightRules = JavaScriptHighlightRules;
|
||||||
});
|
});
|
||||||
|
|
@ -37,7 +37,7 @@
|
||||||
|
|
||||||
define(function(require, exports, module) {
|
define(function(require, exports, module) {
|
||||||
|
|
||||||
var Range = require("../range");
|
var Range = require("ace/range").Range;
|
||||||
|
|
||||||
var MatchingBraceOutdent = function() {};
|
var MatchingBraceOutdent = function() {};
|
||||||
|
|
||||||
|
|
@ -78,5 +78,5 @@ var MatchingBraceOutdent = function() {};
|
||||||
|
|
||||||
}).call(MatchingBraceOutdent.prototype);
|
}).call(MatchingBraceOutdent.prototype);
|
||||||
|
|
||||||
return MatchingBraceOutdent;
|
exports.MatchingBraceOutdent = MatchingBraceOutdent;
|
||||||
});
|
});
|
||||||
|
|
|
||||||
116
lib/ace/mode/python.js
Normal file
116
lib/ace/mode/python.js
Normal file
|
|
@ -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 <fabian AT ajax DOT org>
|
||||||
|
*
|
||||||
|
* 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;
|
||||||
|
});
|
||||||
176
lib/ace/mode/python_highlight_rules.js
Normal file
176
lib/ace/mode/python_highlight_rules.js
Normal file
|
|
@ -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 <fabian AT ajax DOT org>
|
||||||
|
*
|
||||||
|
* 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;
|
||||||
|
});
|
||||||
|
|
@ -37,10 +37,10 @@
|
||||||
|
|
||||||
define(function(require, exports, module) {
|
define(function(require, exports, module) {
|
||||||
|
|
||||||
var Tokenizer = require("../tokenizer");
|
var Tokenizer = require("ace/tokenizer").Tokenizer;
|
||||||
var TextHighlightRules = require("./text_highlight_rules");
|
var TextHighlightRules = require("ace/mode/text_highlight_rules").TextHighlightRules;
|
||||||
|
|
||||||
var Text = function() {
|
var Mode = function() {
|
||||||
this.$tokenizer = new Tokenizer(new TextHighlightRules().getRules());
|
this.$tokenizer = new Tokenizer(new TextHighlightRules().getRules());
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -74,7 +74,7 @@ var Text = function() {
|
||||||
return "";
|
return "";
|
||||||
};
|
};
|
||||||
|
|
||||||
}).call(Text.prototype);
|
}).call(Mode.prototype);
|
||||||
|
|
||||||
return Text;
|
exports.Mode = Mode;
|
||||||
});
|
});
|
||||||
|
|
@ -73,5 +73,5 @@ var TextHighlightRules = function() {
|
||||||
|
|
||||||
}).call(TextHighlightRules.prototype);
|
}).call(TextHighlightRules.prototype);
|
||||||
|
|
||||||
return TextHighlightRules;
|
exports.TextHighlightRules = TextHighlightRules;
|
||||||
});
|
});
|
||||||
|
|
@ -37,16 +37,16 @@
|
||||||
|
|
||||||
define(function(require, exports, module) {
|
define(function(require, exports, module) {
|
||||||
|
|
||||||
var oop = require("../lib/oop");
|
var oop = require("pilot/oop").oop;
|
||||||
var TextMode = require("./text");
|
var TextMode = require("ace/mode/text").Mode;
|
||||||
var Tokenizer = require("../tokenizer");
|
var Tokenizer = require("ace/tokenizer").Tokenizer;
|
||||||
var XmlHighlightRules = require("./xml_highlight_rules");
|
var XmlHighlightRules = require("ace/mode/xml_highlight_rules").XmlHighlightRules;
|
||||||
|
|
||||||
var Xml = function() {
|
var Mode = function() {
|
||||||
this.$tokenizer = new Tokenizer(new XmlHighlightRules().getRules());
|
this.$tokenizer = new Tokenizer(new XmlHighlightRules().getRules());
|
||||||
};
|
};
|
||||||
|
|
||||||
oop.inherits(Xml, TextMode);
|
oop.inherits(Mode, TextMode);
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
|
|
@ -54,7 +54,7 @@ oop.inherits(Xml, TextMode);
|
||||||
return this.$getIndent(line);
|
return this.$getIndent(line);
|
||||||
};
|
};
|
||||||
|
|
||||||
}).call(Xml.prototype);
|
}).call(Mode.prototype);
|
||||||
|
|
||||||
return Xml;
|
exports.Mode = Mode;
|
||||||
});
|
});
|
||||||
|
|
@ -37,8 +37,8 @@
|
||||||
|
|
||||||
define(function(require, exports, module) {
|
define(function(require, exports, module) {
|
||||||
|
|
||||||
var oop = require("../lib/oop");
|
var oop = require("pilot/oop").oop;
|
||||||
var TextHighlightRules = require("./text_highlight_rules");
|
var TextHighlightRules = require("ace/mode/text_highlight_rules").TextHighlightRules;
|
||||||
|
|
||||||
var XmlHighlightRules = function() {
|
var XmlHighlightRules = function() {
|
||||||
|
|
||||||
|
|
@ -114,5 +114,5 @@ var XmlHighlightRules = function() {
|
||||||
|
|
||||||
oop.inherits(XmlHighlightRules, TextHighlightRules);
|
oop.inherits(XmlHighlightRules, TextHighlightRules);
|
||||||
|
|
||||||
return XmlHighlightRules;
|
exports.XmlHighlightRules = XmlHighlightRules;
|
||||||
});
|
});
|
||||||
|
|
@ -152,5 +152,5 @@ Range.fromPoints = function(start, end) {
|
||||||
return new Range(start.row, start.column, end.row, end.column);
|
return new Range(start.row, start.column, end.row, end.column);
|
||||||
};
|
};
|
||||||
|
|
||||||
return Range;
|
exports.Range = Range;
|
||||||
})
|
});
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@
|
||||||
|
|
||||||
define(function(require, exports, module) {
|
define(function(require, exports, module) {
|
||||||
|
|
||||||
var event = require("./lib/event")
|
var event = require("pilot/event").event;
|
||||||
|
|
||||||
var RenderLoop = function(onRender) {
|
var RenderLoop = function(onRender) {
|
||||||
this.onRender = onRender;
|
this.onRender = onRender;
|
||||||
|
|
@ -91,5 +91,5 @@ var RenderLoop = function(onRender) {
|
||||||
|
|
||||||
}).call(RenderLoop.prototype);
|
}).call(RenderLoop.prototype);
|
||||||
|
|
||||||
return RenderLoop;
|
exports.RenderLoop = RenderLoop;
|
||||||
});
|
});
|
||||||
|
|
@ -37,11 +37,11 @@
|
||||||
|
|
||||||
define(function(require, exports, module) {
|
define(function(require, exports, module) {
|
||||||
|
|
||||||
var oop = require("./lib/oop");
|
var oop = require("pilot/oop").oop;
|
||||||
var lang = require("./lib/lang");
|
var lang = require("pilot/lang").lang;
|
||||||
var dom = require("./lib/dom");
|
var dom = require("pilot/dom").dom;
|
||||||
var event = require("./lib/event");
|
var event = require("pilot/event").event;
|
||||||
var MEventEmitter = require("./event_emitter");
|
var EventEmitter = require("pilot/event_emitter").EventEmitter;
|
||||||
|
|
||||||
var ScrollBar = function(parent) {
|
var ScrollBar = function(parent) {
|
||||||
this.element = document.createElement("div");
|
this.element = document.createElement("div");
|
||||||
|
|
@ -59,10 +59,10 @@ var ScrollBar = function(parent) {
|
||||||
};
|
};
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
oop.implement(this, MEventEmitter);
|
oop.implement(this, EventEmitter);
|
||||||
|
|
||||||
this.onScroll = function() {
|
this.onScroll = function() {
|
||||||
this.$dispatchEvent("scroll", {data: this.element.scrollTop});
|
this._dispatchEvent("scroll", {data: this.element.scrollTop});
|
||||||
};
|
};
|
||||||
|
|
||||||
this.getWidth = function() {
|
this.getWidth = function() {
|
||||||
|
|
@ -83,5 +83,5 @@ var ScrollBar = function(parent) {
|
||||||
|
|
||||||
}).call(ScrollBar.prototype);
|
}).call(ScrollBar.prototype);
|
||||||
|
|
||||||
return ScrollBar;
|
exports.ScrollBar = ScrollBar;
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -37,9 +37,9 @@
|
||||||
|
|
||||||
define(function(require, exports, module) {
|
define(function(require, exports, module) {
|
||||||
|
|
||||||
var lang = require("./lib/lang");
|
var lang = require("pilot/lang").lang;
|
||||||
var oop = require("./lib/oop");
|
var oop = require("pilot/oop").oop;
|
||||||
var Range = require("./range");
|
var Range = require("ace/range").Range;
|
||||||
|
|
||||||
var Search = function() {
|
var Search = function() {
|
||||||
this.$options = {
|
this.$options = {
|
||||||
|
|
@ -317,5 +317,5 @@ Search.SELECTION = 2;
|
||||||
|
|
||||||
}).call(Search.prototype);
|
}).call(Search.prototype);
|
||||||
|
|
||||||
return Search;
|
exports.Search = Search;
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -37,10 +37,10 @@
|
||||||
|
|
||||||
define(function(require, exports, module) {
|
define(function(require, exports, module) {
|
||||||
|
|
||||||
var oop = require("./lib/oop");
|
var oop = require("pilot/oop").oop;
|
||||||
var lang = require("./lib/lang");
|
var lang = require("pilot/lang").lang;
|
||||||
var MEventEmitter = require("./event_emitter");
|
var EventEmitter = require("pilot/event_emitter").EventEmitter;
|
||||||
var Range = require("./range");
|
var Range = require("ace/range").Range;
|
||||||
|
|
||||||
var Selection = function(doc) {
|
var Selection = function(doc) {
|
||||||
this.doc = doc;
|
this.doc = doc;
|
||||||
|
|
@ -54,7 +54,7 @@ var Selection = function(doc) {
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
oop.implement(this, MEventEmitter);
|
oop.implement(this, EventEmitter);
|
||||||
|
|
||||||
this.isEmpty = function() {
|
this.isEmpty = function() {
|
||||||
return (!this.selectionAnchor ||
|
return (!this.selectionAnchor ||
|
||||||
|
|
@ -79,11 +79,11 @@ var Selection = function(doc) {
|
||||||
|
|
||||||
if (!this.selectionAnchor) {
|
if (!this.selectionAnchor) {
|
||||||
this.selectionAnchor = anchor;
|
this.selectionAnchor = anchor;
|
||||||
this.$dispatchEvent("changeSelection", {});
|
this._dispatchEvent("changeSelection", {});
|
||||||
}
|
}
|
||||||
else if (this.selectionAnchor.row !== anchor.row || this.selectionAnchor.column !== anchor.column) {
|
else if (this.selectionAnchor.row !== anchor.row || this.selectionAnchor.column !== anchor.column) {
|
||||||
this.selectionAnchor = anchor;
|
this.selectionAnchor = anchor;
|
||||||
this.$dispatchEvent("changeSelection", {});
|
this._dispatchEvent("changeSelection", {});
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
@ -142,7 +142,7 @@ var Selection = function(doc) {
|
||||||
this.clearSelection = function() {
|
this.clearSelection = function() {
|
||||||
if (this.selectionAnchor) {
|
if (this.selectionAnchor) {
|
||||||
this.selectionAnchor = null;
|
this.selectionAnchor = null;
|
||||||
this.$dispatchEvent("changeSelection", {});
|
this._dispatchEvent("changeSelection", {});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -181,7 +181,7 @@ var Selection = function(doc) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (changed)
|
if (changed)
|
||||||
this.$dispatchEvent("changeSelection", {});
|
this._dispatchEvent("changeSelection", {});
|
||||||
};
|
};
|
||||||
|
|
||||||
this.selectTo = function(row, column) {
|
this.selectTo = function(row, column) {
|
||||||
|
|
@ -381,7 +381,7 @@ var Selection = function(doc) {
|
||||||
// only dispatch change if the cursor actually changed
|
// only dispatch change if the cursor actually changed
|
||||||
if (cursor.row !== this.selectionLead.row || cursor.column !== this.selectionLead.column) {
|
if (cursor.row !== this.selectionLead.row || cursor.column !== this.selectionLead.column) {
|
||||||
this.selectionLead = cursor;
|
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);
|
}).call(Selection.prototype);
|
||||||
|
|
||||||
return Selection;
|
exports.Selection = Selection;
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -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 <fabian AT ajax DOT org>
|
||||||
|
*
|
||||||
|
* 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({
|
require({
|
||||||
paths: {
|
paths: {
|
||||||
"ace": "../src/ace"
|
"ace": "../src/ace"
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,39 @@
|
||||||
/**
|
/* ***** BEGIN LICENSE BLOCK *****
|
||||||
* Ajax.org Code Editor (ACE)
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||||
*
|
*
|
||||||
* @copyright 2010, Ajax.org Services B.V.
|
* The contents of this file are subject to the Mozilla Public License Version
|
||||||
* @license LGPLv3 <http://www.gnu.org/licenses/lgpl-3.0.txt>
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||||
* @author Fabian Jakobs <fabian AT ajax DOT org>
|
* 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 <fabian AT ajax DOT org>
|
||||||
|
*
|
||||||
|
* 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) {
|
define(function(require, exports, module) {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,39 @@
|
||||||
/**
|
/* ***** BEGIN LICENSE BLOCK *****
|
||||||
* Ajax.org Code Editor (ACE)
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||||
*
|
*
|
||||||
* @copyright 2010, Ajax.org Services B.V.
|
* The contents of this file are subject to the Mozilla Public License Version
|
||||||
* @license LGPLv3 <http://www.gnu.org/licenses/lgpl-3.0.txt>
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||||
* @author Fabian Jakobs <fabian AT ajax DOT org>
|
* 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 <fabian AT ajax DOT org>
|
||||||
|
*
|
||||||
|
* 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");
|
require("../../../support/paths");
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,39 @@
|
||||||
/**
|
/* ***** BEGIN LICENSE BLOCK *****
|
||||||
* Ajax.org Code Editor (ACE)
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||||
*
|
*
|
||||||
* @copyright 2010, Ajax.org Services B.V.
|
* The contents of this file are subject to the Mozilla Public License Version
|
||||||
* @license LGPLv3 <http://www.gnu.org/licenses/lgpl-3.0.txt>
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||||
* @author Fabian Jakobs <fabian AT ajax DOT org>
|
* 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 <fabian AT ajax DOT org>
|
||||||
|
*
|
||||||
|
* 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");
|
require("../../../support/paths");
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,39 @@
|
||||||
/**
|
/* ***** BEGIN LICENSE BLOCK *****
|
||||||
* Ajax.org Code Editor (ACE)
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||||
*
|
*
|
||||||
* @copyright 2010, Ajax.org Services B.V.
|
* The contents of this file are subject to the Mozilla Public License Version
|
||||||
* @license LGPLv3 <http://www.gnu.org/licenses/lgpl-3.0.txt>
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||||
* @author Fabian Jakobs <fabian AT ajax DOT org>
|
* 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 <fabian AT ajax DOT org>
|
||||||
|
*
|
||||||
|
* 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");
|
require("../../../support/paths");
|
||||||
|
|
||||||
|
|
@ -12,10 +41,9 @@ var oop = require("../lib/oop");
|
||||||
MEventEmitter = require("../event_emitter"),
|
MEventEmitter = require("../event_emitter"),
|
||||||
assert = require("./assertions");
|
assert = require("./assertions");
|
||||||
|
|
||||||
|
|
||||||
var EventEmitter = function() {};
|
var EventEmitter = function() {};
|
||||||
|
|
||||||
oop.implement(EventEmitter.prototype, MEventEmitter);
|
oop.implement(EventEmitter.prototype, EventEmitter);
|
||||||
|
|
||||||
var Test = {
|
var Test = {
|
||||||
"test: dispatch event with no data" : function() {
|
"test: dispatch event with no data" : function() {
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,39 @@
|
||||||
/**
|
/* ***** BEGIN LICENSE BLOCK *****
|
||||||
* Ajax.org Code Editor (ACE)
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||||
*
|
*
|
||||||
* @copyright 2010, Ajax.org Services B.V.
|
* The contents of this file are subject to the Mozilla Public License Version
|
||||||
* @license LGPLv3 <http://www.gnu.org/licenses/lgpl-3.0.txt>
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||||
* @author Fabian Jakobs <fabian AT ajax DOT org>
|
* 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 <fabian AT ajax DOT org>
|
||||||
|
*
|
||||||
|
* 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) {
|
define(function(require, exports, module) {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,22 +1,47 @@
|
||||||
/**
|
/* ***** BEGIN LICENSE BLOCK *****
|
||||||
* Ajax.org Code Editor (ACE)
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||||
*
|
*
|
||||||
* @copyright 2010, Ajax.org Services B.V.
|
* The contents of this file are subject to the Mozilla Public License Version
|
||||||
* @license LGPLv3 <http://www.gnu.org/licenses/lgpl-3.0.txt>
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||||
* @author Fabian Jakobs <fabian AT ajax DOT org>
|
* 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 <fabian AT ajax DOT org>
|
||||||
|
*
|
||||||
|
* 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([
|
define(function(require, exports, module) {
|
||||||
"ace/Document",
|
|
||||||
"ace/Range",
|
|
||||||
"ace/mode/Css"
|
|
||||||
], function(
|
|
||||||
Document,
|
|
||||||
Range,
|
|
||||||
CssMode
|
|
||||||
) {
|
|
||||||
|
|
||||||
var CssTest = new TestCase("mode.CssTest", {
|
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", {
|
||||||
|
|
||||||
setUp : function() {
|
setUp : function() {
|
||||||
this.mode = new CssMode();
|
this.mode = new CssMode();
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,43 @@
|
||||||
/**
|
/* ***** BEGIN LICENSE BLOCK *****
|
||||||
* Ajax.org Code Editor (ACE)
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||||
*
|
*
|
||||||
* @copyright 2010, Ajax.org Services B.V.
|
* The contents of this file are subject to the Mozilla Public License Version
|
||||||
* @license LGPLv3 <http://www.gnu.org/licenses/lgpl-3.0.txt>
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||||
* @author Fabian Jakobs <fabian AT ajax DOT org>
|
* 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 <fabian AT ajax DOT org>
|
||||||
|
*
|
||||||
|
* 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([
|
define(function(require, exports, module) {
|
||||||
"ace/mode/Css"
|
|
||||||
], function(
|
var Css = require("ace/mode/css").Mode;
|
||||||
CssMode
|
|
||||||
) {
|
|
||||||
|
|
||||||
var CssTest = new TestCase("mode.CssTest", {
|
var CssTest = new TestCase("mode.CssTest", {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,20 +1,45 @@
|
||||||
/**
|
/* ***** BEGIN LICENSE BLOCK *****
|
||||||
* Ajax.org Code Editor (ACE)
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||||
*
|
*
|
||||||
* @copyright 2010, Ajax.org Services B.V.
|
* The contents of this file are subject to the Mozilla Public License Version
|
||||||
* @license LGPLv3 <http://www.gnu.org/licenses/lgpl-3.0.txt>
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||||
* @author Fabian Jakobs <fabian AT ajax DOT org>
|
* 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 <fabian AT ajax DOT org>
|
||||||
|
*
|
||||||
|
* 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([
|
define(function(require, exports, module) {
|
||||||
"ace/Document",
|
|
||||||
"ace/Range",
|
var Document = require("ace/document").Document;
|
||||||
"ace/mode/Html"
|
var Range = require("ace/range").Range;
|
||||||
], function(
|
var Html = require("ace/mode/html").Mode;
|
||||||
Document,
|
|
||||||
Range,
|
|
||||||
HtmlMode
|
|
||||||
) {
|
|
||||||
|
|
||||||
var HtmlTest = new TestCase("mode.HtmlTest", {
|
var HtmlTest = new TestCase("mode.HtmlTest", {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,43 @@
|
||||||
/**
|
/* ***** BEGIN LICENSE BLOCK *****
|
||||||
* Ajax.org Code Editor (ACE)
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||||
*
|
*
|
||||||
* @copyright 2010, Ajax.org Services B.V.
|
* The contents of this file are subject to the Mozilla Public License Version
|
||||||
* @license LGPLv3 <http://www.gnu.org/licenses/lgpl-3.0.txt>
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||||
* @author Fabian Jakobs <fabian AT ajax DOT org>
|
* 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 <fabian AT ajax DOT org>
|
||||||
|
*
|
||||||
|
* 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([
|
define(function(require, exports, module) {
|
||||||
"ace/mode/Html"
|
|
||||||
], function(
|
var Html = require("ace/mode/html").Mode;
|
||||||
HtmlMode
|
|
||||||
) {
|
|
||||||
|
|
||||||
var HtmlTest = new TestCase("mode.HtmlTest", {
|
var HtmlTest = new TestCase("mode.HtmlTest", {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,22 +1,46 @@
|
||||||
/**
|
/* ***** BEGIN LICENSE BLOCK *****
|
||||||
* Ajax.org Code Editor (ACE)
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||||
*
|
*
|
||||||
* @copyright 2010, Ajax.org Services B.V.
|
* The contents of this file are subject to the Mozilla Public License Version
|
||||||
* @license LGPLv3 <http://www.gnu.org/licenses/lgpl-3.0.txt>
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||||
* @author Fabian Jakobs <fabian AT ajax DOT org>
|
* 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 <fabian AT ajax DOT org>
|
||||||
|
*
|
||||||
|
* 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([
|
define(function(require, exports, module) {
|
||||||
"ace/Document",
|
|
||||||
"ace/Range",
|
var Document = require("ace/document").Document;
|
||||||
"ace/Tokenizer",
|
var Range = require("ace/range").Range;
|
||||||
"ace/mode/JavaScript"
|
var Tokenizer = require("ace/tokenizer").Tokenizer;
|
||||||
], function(
|
var JavaScript = require("ace/mode/javascript").Mode;
|
||||||
Document,
|
|
||||||
Range,
|
|
||||||
Tokenizer,
|
|
||||||
JavaScriptMode
|
|
||||||
) {
|
|
||||||
|
|
||||||
var JavaScriptTest = new TestCase("mode.JavaScriptTest", {
|
var JavaScriptTest = new TestCase("mode.JavaScriptTest", {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,43 @@
|
||||||
/**
|
/* ***** BEGIN LICENSE BLOCK *****
|
||||||
* Ajax.org Code Editor (ACE)
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||||
*
|
*
|
||||||
* @copyright 2010, Ajax.org Services B.V.
|
* The contents of this file are subject to the Mozilla Public License Version
|
||||||
* @license LGPLv3 <http://www.gnu.org/licenses/lgpl-3.0.txt>
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||||
* @author Fabian Jakobs <fabian AT ajax DOT org>
|
* 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 <fabian AT ajax DOT org>
|
||||||
|
*
|
||||||
|
* 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([
|
define(function(require, exports, module) {
|
||||||
"ace/mode/JavaScript"
|
|
||||||
], function(
|
var JavaScript = require("ace/mode/javascript").Mode;
|
||||||
JavaScriptMode
|
|
||||||
) {
|
|
||||||
|
|
||||||
var JavaScriptTokenizerTest = new TestCase("mode.JavaScriptTokenizerTest", {
|
var JavaScriptTokenizerTest = new TestCase("mode.JavaScriptTokenizerTest", {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,20 +1,45 @@
|
||||||
/**
|
/* ***** BEGIN LICENSE BLOCK *****
|
||||||
* Ajax.org Code Editor (ACE)
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||||
*
|
*
|
||||||
* @copyright 2010, Ajax.org Services B.V.
|
* The contents of this file are subject to the Mozilla Public License Version
|
||||||
* @license LGPLv3 <http://www.gnu.org/licenses/lgpl-3.0.txt>
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||||
* @author Fabian Jakobs <fabian AT ajax DOT org>
|
* 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 <fabian AT ajax DOT org>
|
||||||
|
*
|
||||||
|
* 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([
|
define(function(require, exports, module) {
|
||||||
"ace/Document",
|
|
||||||
"ace/Range",
|
var Document = require("ace/document").Document;
|
||||||
"ace/mode/Text"
|
var Range = require("ace/range").Range;
|
||||||
], function(
|
var Text = require("ace/mode/text").Mode;
|
||||||
Document,
|
|
||||||
Range,
|
|
||||||
TextMode
|
|
||||||
) {
|
|
||||||
|
|
||||||
var TextTest = new TestCase("mode.TextTest", {
|
var TextTest = new TestCase("mode.TextTest", {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,22 +1,46 @@
|
||||||
/**
|
/* ***** BEGIN LICENSE BLOCK *****
|
||||||
* Ajax.org Code Editor (ACE)
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||||
*
|
*
|
||||||
* @copyright 2010, Ajax.org Services B.V.
|
* The contents of this file are subject to the Mozilla Public License Version
|
||||||
* @license LGPLv3 <http://www.gnu.org/licenses/lgpl-3.0.txt>
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||||
* @author Fabian Jakobs <fabian AT ajax DOT org>
|
* 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 <fabian AT ajax DOT org>
|
||||||
|
*
|
||||||
|
* 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([
|
define(function(require, exports, module) {
|
||||||
"ace/Document",
|
|
||||||
"ace/Range",
|
var Document = require("ace/document").Document;
|
||||||
"ace/Tokenizer",
|
var Range = require("ace/range").Range;
|
||||||
"ace/mode/Xml"
|
var Tokenizer = require("ace/tokenizer").Tokenizer;
|
||||||
], function(
|
var Xml = require("ace/mode/xml").Mode;
|
||||||
Document,
|
|
||||||
Range,
|
|
||||||
Tokenizer,
|
|
||||||
XmlMode
|
|
||||||
) {
|
|
||||||
|
|
||||||
var XmlTest = new TestCase("mode.XmlTest", {
|
var XmlTest = new TestCase("mode.XmlTest", {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,43 @@
|
||||||
/**
|
/* ***** BEGIN LICENSE BLOCK *****
|
||||||
* Ajax.org Code Editor (ACE)
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||||
*
|
*
|
||||||
* @copyright 2010, Ajax.org Services B.V.
|
* The contents of this file are subject to the Mozilla Public License Version
|
||||||
* @license LGPLv3 <http://www.gnu.org/licenses/lgpl-3.0.txt>
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||||
* @author Fabian Jakobs <fabian AT ajax DOT org>
|
* 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 <fabian AT ajax DOT org>
|
||||||
|
*
|
||||||
|
* 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([
|
define(function(require, exports, module) {
|
||||||
"ace/mode/Xml"
|
|
||||||
], function(
|
var Xml = require("ace/mode/xml").Mode;
|
||||||
XmlMode
|
|
||||||
) {
|
|
||||||
|
|
||||||
var XmlTest = new TestCase("mode.XmlTest", {
|
var XmlTest = new TestCase("mode.XmlTest", {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,39 @@
|
||||||
/**
|
/* ***** BEGIN LICENSE BLOCK *****
|
||||||
* Ajax.org Code Editor (ACE)
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||||
*
|
*
|
||||||
* @copyright 2010, Ajax.org Services B.V.
|
* The contents of this file are subject to the Mozilla Public License Version
|
||||||
* @license LGPLv3 <http://www.gnu.org/licenses/lgpl-3.0.txt>
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||||
* @author Fabian Jakobs <fabian AT ajax DOT org>
|
* 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 <fabian AT ajax DOT org>
|
||||||
|
*
|
||||||
|
* 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");
|
require("../../../support/paths");
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,39 @@
|
||||||
/**
|
/* ***** BEGIN LICENSE BLOCK *****
|
||||||
* Ajax.org Code Editor (ACE)
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||||
*
|
*
|
||||||
* @copyright 2010, Ajax.org Services B.V.
|
* The contents of this file are subject to the Mozilla Public License Version
|
||||||
* @license LGPLv3 <http://www.gnu.org/licenses/lgpl-3.0.txt>
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||||
* @author Fabian Jakobs <fabian AT ajax DOT org>
|
* 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 <fabian AT ajax DOT org>
|
||||||
|
*
|
||||||
|
* 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");
|
require("../../../support/paths");
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,39 @@
|
||||||
/**
|
/* ***** BEGIN LICENSE BLOCK *****
|
||||||
* Ajax.org Code Editor (ACE)
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||||
*
|
*
|
||||||
* @copyright 2010, Ajax.org Services B.V.
|
* The contents of this file are subject to the Mozilla Public License Version
|
||||||
* @license LGPLv3 <http://www.gnu.org/licenses/lgpl-3.0.txt>
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||||
* @author Fabian Jakobs <fabian AT ajax DOT org>
|
* 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 <fabian AT ajax DOT org>
|
||||||
|
*
|
||||||
|
* 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");
|
require("../../../support/paths");
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,39 @@
|
||||||
/**
|
/* ***** BEGIN LICENSE BLOCK *****
|
||||||
* Ajax.org Code Editor (ACE)
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||||
*
|
*
|
||||||
* @copyright 2010, Ajax.org Services B.V.
|
* The contents of this file are subject to the Mozilla Public License Version
|
||||||
* @license LGPLv3 <http://www.gnu.org/licenses/lgpl-3.0.txt>
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||||
* @author Fabian Jakobs <fabian AT ajax DOT org>
|
* 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 <fabian AT ajax DOT org>
|
||||||
|
*
|
||||||
|
* 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");
|
require("../../../support/paths");
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,39 @@
|
||||||
/**
|
/* ***** BEGIN LICENSE BLOCK *****
|
||||||
* Ajax.org Code Editor (ACE)
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||||
*
|
*
|
||||||
* @copyright 2010, Ajax.org Services B.V.
|
* The contents of this file are subject to the Mozilla Public License Version
|
||||||
* @license LGPLv3 <http://www.gnu.org/licenses/lgpl-3.0.txt>
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||||
* @author Fabian Jakobs <fabian AT ajax DOT org>
|
* 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 <fabian AT ajax DOT org>
|
||||||
|
*
|
||||||
|
* 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");
|
require("../../../support/paths");
|
||||||
|
|
||||||
|
|
@ -19,7 +48,7 @@ global.location = browser.location;
|
||||||
|
|
||||||
var Document = require("../document"),
|
var Document = require("../document"),
|
||||||
Editor = require("../editor"),
|
Editor = require("../editor"),
|
||||||
JavaScriptMode = require("../mode/javascript"),
|
JavaScriptMode = require("../mode/javascript").Mode,
|
||||||
MockRenderer = require("./mockrenderer"),
|
MockRenderer = require("./mockrenderer"),
|
||||||
assert = require("./assertions");
|
assert = require("./assertions");
|
||||||
|
|
||||||
|
|
@ -83,7 +112,7 @@ var Test = {
|
||||||
assert.position(editor.getCursorPosition(), 2, 0);
|
assert.position(editor.getCursorPosition(), 2, 0);
|
||||||
},
|
},
|
||||||
|
|
||||||
"__test: indent block" : function() {
|
"test: indent block" : function() {
|
||||||
var doc = new Document(["a12345", "b12345", "c12345"].join("\n"));
|
var doc = new Document(["a12345", "b12345", "c12345"].join("\n"));
|
||||||
var editor = new Editor(new MockRenderer(), doc);
|
var editor = new Editor(new MockRenderer(), doc);
|
||||||
|
|
||||||
|
|
@ -102,7 +131,7 @@ var Test = {
|
||||||
assert.position(range.end, 2, 7);
|
assert.position(range.end, 2, 7);
|
||||||
},
|
},
|
||||||
|
|
||||||
"__test: outdent block" : function() {
|
"test: outdent block" : function() {
|
||||||
var doc = new Document([" a12345", " b12345", " c12345"].join("\n"));
|
var doc = new Document([" a12345", " b12345", " c12345"].join("\n"));
|
||||||
var editor = new Editor(new MockRenderer(), doc);
|
var editor = new Editor(new MockRenderer(), doc);
|
||||||
|
|
||||||
|
|
@ -219,7 +248,7 @@ var Test = {
|
||||||
assert.position(editor.getSelection().getSelectionLead(), 2, 0);
|
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 doc = new Document(["11", "22", "33", "44"].join("\n"));
|
||||||
var editor = new Editor(new MockRenderer(), doc);
|
var editor = new Editor(new MockRenderer(), doc);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,39 @@
|
||||||
/**
|
/* ***** BEGIN LICENSE BLOCK *****
|
||||||
* Ajax.org Code Editor (ACE)
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||||
*
|
*
|
||||||
* @copyright 2010, Ajax.org Services B.V.
|
* The contents of this file are subject to the Mozilla Public License Version
|
||||||
* @license LGPLv3 <http://www.gnu.org/licenses/lgpl-3.0.txt>
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||||
* @author Fabian Jakobs <fabian AT ajax DOT org>
|
* 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 <fabian AT ajax DOT org>
|
||||||
|
*
|
||||||
|
* 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");
|
require("../../../support/paths");
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@
|
||||||
|
|
||||||
define(function(require, exports, module) {
|
define(function(require, exports, module) {
|
||||||
|
|
||||||
var event = require("./lib/event");
|
var event = require("pilot/event").event;
|
||||||
|
|
||||||
var TextInput = function(parentNode, host) {
|
var TextInput = function(parentNode, host) {
|
||||||
|
|
||||||
|
|
@ -146,5 +146,5 @@ var TextInput = function(parentNode, host) {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
return TextInput;
|
exports.TextInput = TextInput;
|
||||||
});
|
});
|
||||||
|
|
@ -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 <fabian AT ajax DOT org>
|
||||||
|
*
|
||||||
|
* 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) {
|
define(function(require, exports, module) {
|
||||||
|
|
||||||
var dom = require("../lib/dom");
|
var dom = require("pilot/dom").dom;
|
||||||
|
|
||||||
var cssText = ".ace-clouds .ace_editor {\
|
var cssText = ".ace-clouds .ace_editor {\
|
||||||
border: 2px solid rgb(159, 159, 159);\
|
border: 2px solid rgb(159, 159, 159);\
|
||||||
|
|
@ -154,7 +191,5 @@ var dom = require("../lib/dom");
|
||||||
// import CSS once
|
// import CSS once
|
||||||
dom.importCssString(cssText);
|
dom.importCssString(cssText);
|
||||||
|
|
||||||
return {
|
exports.cssClass = "ace-clouds";
|
||||||
cssClass: "ace-clouds"
|
});
|
||||||
};
|
|
||||||
})
|
|
||||||
|
|
|
||||||
|
|
@ -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 <fabian AT ajax DOT org>
|
||||||
|
*
|
||||||
|
* 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) {
|
define(function(require, exports, module) {
|
||||||
|
|
||||||
var dom = require("../lib/dom");
|
var dom = require("pilot/dom").dom;
|
||||||
|
|
||||||
var cssText = ".ace-clouds-midnight .ace_editor {\
|
var cssText = ".ace-clouds-midnight .ace_editor {\
|
||||||
border: 2px solid rgb(159, 159, 159);\
|
border: 2px solid rgb(159, 159, 159);\
|
||||||
|
|
@ -155,7 +192,5 @@ background-color:#E92E2E;\
|
||||||
// import CSS once
|
// import CSS once
|
||||||
dom.importCssString(cssText);
|
dom.importCssString(cssText);
|
||||||
|
|
||||||
return {
|
exports.cssClass = "ace-clouds-midnight";
|
||||||
cssClass: "ace-clouds-midnight"
|
});
|
||||||
};
|
|
||||||
})
|
|
||||||
|
|
|
||||||
|
|
@ -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 <fabian AT ajax DOT org>
|
||||||
|
*
|
||||||
|
* 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) {
|
define(function(require, exports, module) {
|
||||||
|
|
||||||
var dom = require("../lib/dom");
|
var dom = require("pilot/dom").dom;
|
||||||
|
|
||||||
|
|
||||||
var cssText = ".ace-cobalt .ace_editor {\
|
var cssText = ".ace-cobalt .ace_editor {\
|
||||||
border: 2px solid rgb(159, 159, 159);\
|
border: 2px solid rgb(159, 159, 159);\
|
||||||
|
|
@ -157,7 +193,5 @@ color:#0088FF;\
|
||||||
// import CSS once
|
// import CSS once
|
||||||
dom.importCssString(cssText);
|
dom.importCssString(cssText);
|
||||||
|
|
||||||
return {
|
exports.cssClass = "ace-cobalt";
|
||||||
cssClass: "ace-cobalt"
|
});
|
||||||
};
|
|
||||||
})
|
|
||||||
|
|
|
||||||
|
|
@ -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 <fabian AT ajax DOT org>
|
||||||
|
*
|
||||||
|
* 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) {
|
define(function(require, exports, module) {
|
||||||
|
|
||||||
var dom = require("../lib/dom");
|
var dom = require("pilot/dom").dom;
|
||||||
|
|
||||||
var cssText = ".ace-dawn .ace_editor {\
|
var cssText = ".ace-dawn .ace_editor {\
|
||||||
border: 2px solid rgb(159, 159, 159);\
|
border: 2px solid rgb(159, 159, 159);\
|
||||||
|
|
@ -160,7 +197,5 @@ color:#5A525F;\
|
||||||
// import CSS once
|
// import CSS once
|
||||||
dom.importCssString(cssText);
|
dom.importCssString(cssText);
|
||||||
|
|
||||||
return {
|
exports.cssClass = "ace-dawn";
|
||||||
cssClass: "ace-dawn"
|
});
|
||||||
};
|
|
||||||
})
|
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,47 @@
|
||||||
define(["require", "exports", "module", "text!ace/theme/eclipse.css", "../lib/dom"],
|
/* ***** BEGIN LICENSE BLOCK *****
|
||||||
function(require, exports, module, cssText) {
|
* 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 <fabian AT ajax DOT org>
|
||||||
|
*
|
||||||
|
* 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/eclipse.css");
|
||||||
|
|
||||||
// import CSS once
|
// import CSS once
|
||||||
dom.importCssString(cssText);
|
dom.importCssString(cssText);
|
||||||
|
|
||||||
return {
|
exports.cssClass = "ace-eclipse";
|
||||||
cssClass: "ace-eclipse"
|
});
|
||||||
};
|
|
||||||
})
|
|
||||||
|
|
|
||||||
|
|
@ -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 <fabian AT ajax DOT org>
|
||||||
|
*
|
||||||
|
* 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) {
|
define(function(require, exports, module) {
|
||||||
|
|
||||||
var dom = require("../lib/dom");
|
var dom = require("pilot/dom").dom;
|
||||||
|
|
||||||
|
|
||||||
var cssText = ".ace-idle-fingers .ace_editor {\
|
var cssText = ".ace-idle-fingers .ace_editor {\
|
||||||
border: 2px solid rgb(159, 159, 159);\
|
border: 2px solid rgb(159, 159, 159);\
|
||||||
|
|
@ -157,7 +193,5 @@ color:#BC9458;\
|
||||||
// import CSS once
|
// import CSS once
|
||||||
dom.importCssString(cssText);
|
dom.importCssString(cssText);
|
||||||
|
|
||||||
return {
|
exports.cssClass = "ace-idle-fingers";
|
||||||
cssClass: "ace-idle-fingers"
|
});
|
||||||
};
|
|
||||||
})
|
|
||||||
|
|
|
||||||
|
|
@ -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 <fabian AT ajax DOT org>
|
||||||
|
*
|
||||||
|
* 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) {
|
define(function(require, exports, module) {
|
||||||
|
|
||||||
var dom = require("../lib/dom");
|
var dom = require("pilot/dom").dom;
|
||||||
|
|
||||||
|
|
||||||
var cssText = ".ace-kr-theme .ace_editor {\
|
var cssText = ".ace-kr-theme .ace_editor {\
|
||||||
border: 2px solid rgb(159, 159, 159);\
|
border: 2px solid rgb(159, 159, 159);\
|
||||||
|
|
@ -157,7 +193,5 @@ color:#706D5B;\
|
||||||
// import CSS once
|
// import CSS once
|
||||||
dom.importCssString(cssText);
|
dom.importCssString(cssText);
|
||||||
|
|
||||||
return {
|
exports.cssClass = "ace-kr-theme";
|
||||||
cssClass: "ace-kr-theme"
|
});
|
||||||
};
|
|
||||||
})
|
|
||||||
|
|
|
||||||
|
|
@ -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 <fabian AT ajax DOT org>
|
||||||
|
*
|
||||||
|
* 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) {
|
define(function(require, exports, module) {
|
||||||
|
|
||||||
var dom = require("../lib/dom");
|
var dom = require("pilot/dom").dom;
|
||||||
|
|
||||||
|
|
||||||
var cssText = ".ace-mono-industrial .ace_editor {\
|
var cssText = ".ace-mono-industrial .ace_editor {\
|
||||||
border: 2px solid rgb(159, 159, 159);\
|
border: 2px solid rgb(159, 159, 159);\
|
||||||
|
|
@ -157,7 +193,5 @@ background-color:#151C19;\
|
||||||
// import CSS once
|
// import CSS once
|
||||||
dom.importCssString(cssText);
|
dom.importCssString(cssText);
|
||||||
|
|
||||||
return {
|
exports.cssClass = "ace-mono-industrial";
|
||||||
cssClass: "ace-mono-industrial"
|
});
|
||||||
};
|
|
||||||
})
|
|
||||||
|
|
|
||||||
|
|
@ -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 <fabian AT ajax DOT org>
|
||||||
|
*
|
||||||
|
* 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) {
|
define(function(require, exports, module) {
|
||||||
|
|
||||||
var dom = require("../lib/dom");
|
var dom = require("pilot/dom").dom;
|
||||||
|
|
||||||
|
|
||||||
var cssText = ".ace-monokai .ace_editor {\
|
var cssText = ".ace-monokai .ace_editor {\
|
||||||
border: 2px solid rgb(159, 159, 159);\
|
border: 2px solid rgb(159, 159, 159);\
|
||||||
|
|
@ -157,7 +193,5 @@ background-color:#AE81FF;\
|
||||||
// import CSS once
|
// import CSS once
|
||||||
dom.importCssString(cssText);
|
dom.importCssString(cssText);
|
||||||
|
|
||||||
return {
|
exports.cssClass = "ace-monokai";
|
||||||
cssClass: "ace-monokai"
|
});
|
||||||
};
|
|
||||||
})
|
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,47 @@
|
||||||
define(["require", "exports", "module", "text!ace/theme/tm.css", "../lib/dom"],
|
/* ***** BEGIN LICENSE BLOCK *****
|
||||||
function(require, exports, module, cssText) {
|
* 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 <fabian AT ajax DOT org>
|
||||||
|
*
|
||||||
|
* 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
|
// import CSS once
|
||||||
dom.importCssString(cssText);
|
dom.importCssString(cssText);
|
||||||
|
|
||||||
return {
|
exports.cssClass = "ace-tm";
|
||||||
cssClass: "ace-tm"
|
});
|
||||||
};
|
|
||||||
})
|
|
||||||
|
|
|
||||||
|
|
@ -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 <fabian AT ajax DOT org>
|
||||||
|
*
|
||||||
|
* 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) {
|
define(function(require, exports, module) {
|
||||||
|
|
||||||
var dom = require("../lib/dom");
|
var dom = require("pilot/dom").dom;
|
||||||
|
|
||||||
var cssText = ".ace-twilight .ace_editor {\
|
var cssText = ".ace-twilight .ace_editor {\
|
||||||
border: 2px solid rgb(159, 159, 159);\
|
border: 2px solid rgb(159, 159, 159);\
|
||||||
|
|
@ -158,7 +195,5 @@ color:#5F5A60;\
|
||||||
// import CSS once
|
// import CSS once
|
||||||
dom.importCssString(cssText);
|
dom.importCssString(cssText);
|
||||||
|
|
||||||
return {
|
exports.cssClass = "ace-twilight";
|
||||||
cssClass: "ace-twilight"
|
});
|
||||||
};
|
|
||||||
})
|
|
||||||
|
|
|
||||||
|
|
@ -128,5 +128,5 @@ var Tokenizer = function(rules) {
|
||||||
|
|
||||||
}).call(Tokenizer.prototype);
|
}).call(Tokenizer.prototype);
|
||||||
|
|
||||||
return Tokenizer;
|
exports.Tokenizer = Tokenizer;
|
||||||
});
|
});
|
||||||
|
|
@ -73,5 +73,5 @@ var UndoManager = function() {
|
||||||
|
|
||||||
}).call(UndoManager.prototype);
|
}).call(UndoManager.prototype);
|
||||||
|
|
||||||
return UndoManager;
|
exports.UndoManager = UndoManager;
|
||||||
});
|
});
|
||||||
|
|
@ -35,22 +35,20 @@
|
||||||
*
|
*
|
||||||
* ***** END LICENSE BLOCK ***** */
|
* ***** END LICENSE BLOCK ***** */
|
||||||
|
|
||||||
define(["require", "exports", "module", "text!ace/css/editor.css", "./lib/oop", "./lib/oop",
|
define(function(require, exports, module) {
|
||||||
"./lib/event", "./layer/gutter", "./layer/marker", "./layer/text",
|
|
||||||
"./layer/cursor", "./scrollbar", "./renderloop", "./event_emitter"],
|
|
||||||
function(require, exports, module, editorCss) {
|
|
||||||
|
|
||||||
var oop = require("./lib/oop");
|
var oop = require("pilot/oop").oop;
|
||||||
var lang = require("./lib/lang");
|
var lang = require("pilot/lang").lang;
|
||||||
var dom = require("./lib/dom");
|
var dom = require("pilot/dom").dom;
|
||||||
var event = require("./lib/event");
|
var event = require("pilot/event").event;
|
||||||
var GutterLayer = require("./layer/gutter");
|
var GutterLayer = require("ace/layer/gutter").Gutter;
|
||||||
var MarkerLayer = require("./layer/marker");
|
var MarkerLayer = require("ace/layer/marker").Marker;
|
||||||
var TextLayer = require("./layer/text");
|
var TextLayer = require("ace/layer/text").Text;
|
||||||
var CursorLayer = require("./layer/cursor");
|
var CursorLayer = require("ace/layer/cursor").Cursor;
|
||||||
var ScrollBar = require("./scrollbar");
|
var ScrollBar = require("ace/scrollbar").ScrollBar;
|
||||||
var RenderLoop = require("./renderloop");
|
var RenderLoop = require("ace/renderloop").RenderLoop;
|
||||||
var MEventEmitter = require("./event_emitter");
|
var EventEmitter = require("pilot/event_emitter").EventEmitter;
|
||||||
|
var editorCss = require("text!ace/css/editor.css");
|
||||||
|
|
||||||
// import CSS once
|
// import CSS once
|
||||||
dom.importCssString(editorCss);
|
dom.importCssString(editorCss);
|
||||||
|
|
@ -133,7 +131,7 @@ var VirtualRenderer = function(container, theme) {
|
||||||
this.CHANGE_SIZE = 64;
|
this.CHANGE_SIZE = 64;
|
||||||
this.CHANGE_FULL = 128;
|
this.CHANGE_FULL = 128;
|
||||||
|
|
||||||
oop.implement(this, MEventEmitter);
|
oop.implement(this, EventEmitter);
|
||||||
|
|
||||||
this.setDocument = function(doc) {
|
this.setDocument = function(doc) {
|
||||||
this.lines = doc.lines;
|
this.lines = doc.lines;
|
||||||
|
|
@ -225,7 +223,7 @@ var VirtualRenderer = function(container, theme) {
|
||||||
var pageX = event.getDocumentX(e);
|
var pageX = event.getDocumentX(e);
|
||||||
var pageY = event.getDocumentY(e);
|
var pageY = event.getDocumentY(e);
|
||||||
|
|
||||||
this.$dispatchEvent("gutter" + e.type, {
|
this._dispatchEvent("gutter" + e.type, {
|
||||||
row: this.screenToTextCoordinates(pageX, pageY).row,
|
row: this.screenToTextCoordinates(pageX, pageY).row,
|
||||||
htmlEvent: e
|
htmlEvent: e
|
||||||
});
|
});
|
||||||
|
|
@ -399,7 +397,7 @@ var VirtualRenderer = function(container, theme) {
|
||||||
|
|
||||||
var lineCount = Math.ceil(minHeight / this.lineHeight);
|
var lineCount = Math.ceil(minHeight / this.lineHeight);
|
||||||
var firstRow = Math.max(0, Math.round((this.scrollTop - offset) / 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 = {
|
var layerConfig = this.layerConfig = {
|
||||||
width : longestLine,
|
width : longestLine,
|
||||||
|
|
@ -637,5 +635,5 @@ var VirtualRenderer = function(container, theme) {
|
||||||
|
|
||||||
}).call(VirtualRenderer.prototype);
|
}).call(VirtualRenderer.prototype);
|
||||||
|
|
||||||
return VirtualRenderer;
|
exports.VirtualRenderer = VirtualRenderer;
|
||||||
});
|
});
|
||||||
825
plugins/cockpit/cli.js
Normal file
825
plugins/cockpit/cli.js
Normal file
|
|
@ -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.
|
||||||
|
* <p>We also record validity information where applicable.
|
||||||
|
* <p>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.
|
||||||
|
* <p>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.
|
||||||
|
* <p>The other output value is input.requisition which gives access to an
|
||||||
|
* args object for use in executing the final command.
|
||||||
|
*
|
||||||
|
* <p>The majority of the functions in this class are called in sequence by the
|
||||||
|
* constructor. Their task is to add to <tt>hints</tt> fill out the requisition.
|
||||||
|
* <p>The general sequence is:<ul>
|
||||||
|
* <li>_tokenize(): convert _typed into _parts
|
||||||
|
* <li>_split(): convert _parts into _command and _unparsedArgs
|
||||||
|
* <li>_assign(): convert _unparsedArgs into requisition
|
||||||
|
* </ul>
|
||||||
|
*
|
||||||
|
* @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:
|
||||||
|
* <b>flags</b>: Flags for us to check against the predicates specified with the
|
||||||
|
* commands. Defaulted to <tt>keyboard.buildFlags({ });</tt>
|
||||||
|
* 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.
|
||||||
|
* <p>This takes #_command.params and #_unparsedArgs and creates a map of
|
||||||
|
* param names to 'assignment' objects, which have the following properties:
|
||||||
|
* <ul>
|
||||||
|
* <li>param - The matching parameter.
|
||||||
|
* <li>index - Zero based index into where the match came from on the input
|
||||||
|
* <li>value - The matching input
|
||||||
|
* </ul>
|
||||||
|
*/
|
||||||
|
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('<h1>' + command.name + '</h1>');
|
||||||
|
docs.push('<h2>Summary</h2>');
|
||||||
|
docs.push('<p>' + command.description + '</p>');
|
||||||
|
|
||||||
|
if (command.manual) {
|
||||||
|
docs.push('<h2>Description</h2>');
|
||||||
|
docs.push('<p>' + command.description + '</p>');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (command.params && command.params.length > 0) {
|
||||||
|
docs.push('<h2>Synopsis</h2>');
|
||||||
|
docs.push('<pre>');
|
||||||
|
docs.push(command.name);
|
||||||
|
var optionalParamCount = 0;
|
||||||
|
command.params.forEach(function(param) {
|
||||||
|
if (param.defaultValue === undefined) {
|
||||||
|
docs.push(' <i>');
|
||||||
|
docs.push(param.name);
|
||||||
|
docs.push('</i>');
|
||||||
|
}
|
||||||
|
else if (param.defaultValue === null) {
|
||||||
|
docs.push(' <i>[');
|
||||||
|
docs.push(param.name);
|
||||||
|
docs.push(']</i>');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
optionalParamCount++;
|
||||||
|
}
|
||||||
|
}, this);
|
||||||
|
if (optionalParamCount > 3) {
|
||||||
|
docs.push(' [options]');
|
||||||
|
} else if (optionalParamCount > 0) {
|
||||||
|
command.params.forEach(function(param) {
|
||||||
|
if (param.defaultValue) {
|
||||||
|
docs.push(' [--<i>');
|
||||||
|
docs.push(param.name);
|
||||||
|
if (param.type.name === 'boolean') {
|
||||||
|
docs.push('</i>');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
docs.push('</i> ' + param.type.name);
|
||||||
|
}
|
||||||
|
docs.push(']');
|
||||||
|
}
|
||||||
|
}, this);
|
||||||
|
}
|
||||||
|
docs.push('</pre>');
|
||||||
|
|
||||||
|
docs.push('<h2>Parameters</h2>');
|
||||||
|
command.params.forEach(function(param) {
|
||||||
|
docs.push('<h3 class="cmd_body"><i>' + param.name + '</i></h3>');
|
||||||
|
docs.push('<p>' + param.description + '</p>');
|
||||||
|
if (param.type.defaultValue) {
|
||||||
|
docs.push('<p>Default: ' + param.type.defaultValue + '</p>');
|
||||||
|
}
|
||||||
|
}, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
return docs.join('');
|
||||||
|
};
|
||||||
|
exports.documentCommand = documentCommand;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
59
plugins/cockpit/index.js
Normal file
59
plugins/cockpit/index.js
Normal file
|
|
@ -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);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
*/
|
||||||
|
});
|
||||||
317
plugins/cockpit/test/assert.js
Normal file
317
plugins/cockpit/test/assert.js
Normal file
|
|
@ -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;
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
279
plugins/cockpit/test/testCli.js
Normal file
279
plugins/cockpit/test/testCli.js
Normal file
|
|
@ -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";
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
|
|
@ -11,15 +11,15 @@
|
||||||
* for the specific language governing rights and limitations under the
|
* for the specific language governing rights and limitations under the
|
||||||
* License.
|
* License.
|
||||||
*
|
*
|
||||||
* The Original Code is Ajax.org Code Editor (ACE).
|
* The Original Code is Skywriter.
|
||||||
*
|
*
|
||||||
* The Initial Developer of the Original Code is
|
* The Initial Developer of the Original Code is
|
||||||
* Ajax.org Services B.V.
|
* Mozilla.
|
||||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
* Portions created by the Initial Developer are Copyright (C) 2009
|
||||||
* the Initial Developer. All Rights Reserved.
|
* the Initial Developer. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Contributor(s):
|
* Contributor(s):
|
||||||
* Fabian Jakobs <fabian AT ajax DOT org>
|
* Joe Walker (jwalker@mozilla.com)
|
||||||
*
|
*
|
||||||
* Alternatively, the contents of this file may be used under the terms of
|
* 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
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||||
|
|
@ -37,13 +37,4 @@
|
||||||
|
|
||||||
define(function(require, exports, module) {
|
define(function(require, exports, module) {
|
||||||
|
|
||||||
var PluginManager = {
|
|
||||||
commands : {},
|
|
||||||
|
|
||||||
registerCommand : function(name, command) {
|
|
||||||
this.commands[name] = command;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
return PluginManager;
|
|
||||||
});
|
});
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue