Merge branch 'master' of github.com:ajaxorg/ace
This commit is contained in:
commit
d46de9b118
131 changed files with 10328 additions and 3257 deletions
44
build.js
44
build.js
|
|
@ -29,50 +29,60 @@
|
|||
"ace/document",
|
||||
"ace/undomanager",
|
||||
"ace/virtual_renderer",
|
||||
|
||||
|
||||
"ace/mode/javascript",
|
||||
"ace/theme/textmate"
|
||||
],
|
||||
includeRequire: false
|
||||
},
|
||||
|
||||
{
|
||||
name: "ace/theme/eclipse",
|
||||
|
||||
{
|
||||
name: "ace/theme/eclipse",
|
||||
exclude: [
|
||||
"ace/lib/lang",
|
||||
"ace/lib/dom",
|
||||
"ace/lib/oop"
|
||||
"pilot/lang",
|
||||
"pilot/dom",
|
||||
"pilot/oop"
|
||||
]
|
||||
},
|
||||
{
|
||||
{
|
||||
name: "ace/mode/xml",
|
||||
exclude: [
|
||||
"ace/lib/oop",
|
||||
"pilot/oop",
|
||||
"ace/tokenizer",
|
||||
"ace/mode/text"
|
||||
"ace/mode/text"
|
||||
]
|
||||
},
|
||||
{
|
||||
{
|
||||
name: "ace/mode/css",
|
||||
exclude: [
|
||||
"ace/lib/oop",
|
||||
"ace/lib/lang",
|
||||
"pilot/oop",
|
||||
"pilot/lang",
|
||||
"ace/tokenizer",
|
||||
"ace/range",
|
||||
"ace/mode/text"
|
||||
"ace/mode/text"
|
||||
]
|
||||
},
|
||||
{
|
||||
{
|
||||
name: "ace/mode/html",
|
||||
exclude: [
|
||||
"ace/lib/oop",
|
||||
"ace/lib/lang",
|
||||
"pilot/oop",
|
||||
"pilot/lang",
|
||||
"ace/tokenizer",
|
||||
"ace/range",
|
||||
"ace/mode/text",
|
||||
"ace/mode/javascript",
|
||||
"ace/mode/css",
|
||||
]
|
||||
},
|
||||
{
|
||||
name: "ace/mode/python",
|
||||
exclude: [
|
||||
"ace/lib/oop",
|
||||
"ace/lib/lang",
|
||||
"ace/tokenizer",
|
||||
"ace/range",
|
||||
"ace/mode/text"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
define(function() {
|
||||
return{selectall:"Command-A", removeline:"Command-D", gotoline:"Command-L", togglecomment:"Command-7", findnext:"Command-K", findprevious:"Command-Shift-K", find:"Command-F", replace:"Command-R", undo:"Command-Z", redo:"Command-Shift-Z|Command-Y", overwrite:"Insert", copylinesup:"Command-Option-Up", movelinesup:"Option-Up", selecttostart:"Command-Shift-Up", gotostart:"Command-Home|Command-Up", selectup:"Shift-Up", golineup:"Up", copylinesdown:"Command-Option-Down", movelinesdown:"Option-Down",
|
||||
selecttoend:"Command-Shift-Down", gotoend:"Command-End|Command-Down", selectdown:"Shift-Down", godown:"Down", selectwordleft:"Option-Shift-Left", gotowordleft:"Option-Left", selecttolinestart:"Command-Shift-Left", gotolinestart:"Command-Left|Home", selectleft:"Shift-Left", gotoleft:"Left", selectwordright:"Option-Shift-Right", gotowordright:"Option-Right", selecttolineend:"Command-Shift-Right", gotolineend:"Command-Right|End", selectright:"Shift-Right", gotoright:"Right", selectpagedown:"Shift-PageDown",
|
||||
pagedown:"PageDown", selectpageup:"Shift-PageUp", pageup:"PageUp", selectlinestart:"Shift-Home", selectlineend:"Shift-End", del:"Delete", backspace:"Backspace", outdent:"Shift-Tab", indent:"Tab"}
|
||||
pagedown:"PageDown", selectpageup:"Shift-PageUp", pageup:"PageUp", selectlinestart:"Shift-Home", selectlineend:"Shift-End", del:"Delete", backspace:"Ctrl-Backspace|Command-Backspace|Option-Backspace|Backspace", outdent:"Shift-Tab", indent:"Tab"}
|
||||
});
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
define(function() {
|
||||
return{selectall:"Ctrl-A", removeline:"Ctrl-D", gotoline:"Ctrl-L", togglecomment:"Ctrl-7", findnext:"Ctrl-K", findprevious:"Ctrl-Shift-K", find:"Ctrl-F", replace:"Ctrl-R", undo:"Ctrl-Z", redo:"Ctrl-Shift-Z|Ctrl-Y", overwrite:"Insert", copylinesup:"Ctrl-Alt-Up", movelinesup:"Alt-Up", selecttostart:"Alt-Shift-Up", gotostart:"Ctrl-Home|Ctrl-Up", selectup:"Shift-Up", golineup:"Up", copylinesdown:"Ctrl-Alt-Down", movelinesdown:"Alt-Down", selecttoend:"Alt-Shift-Down", gotoend:"Ctrl-End|Ctrl-Down", selectdown:"Shift-Down",
|
||||
godown:"Down", selectwordleft:"Ctrl-Shift-Left", gotowordleft:"Ctrl-Left", selecttolinestart:"Ctrl-Shift-Left", gotolinestart:"Alt-Left|Home", selectleft:"Shift-Left", gotoleft:"Left", selectwordright:"Ctrl-Shift-Right", gotowordright:"Ctrl-Right", selecttolineend:"Ctrl-Shift-Right", gotolineend:"Alt-Right|End", selectright:"Shift-Right", gotoright:"Right", selectpagedown:"Shift-PageDown", pagedown:"PageDown", selectpageup:"Shift-PageUp", pageup:"PageUp", selectlinestart:"Shift-Home", selectlineend:"Shift-End",
|
||||
godown:"Down", selectwordleft:"Ctrl-Shift-Left", gotowordleft:"Ctrl-Left", selecttolinestart:"Alt-Shift-Left", gotolinestart:"Alt-Left|Home", selectleft:"Shift-Left", gotoleft:"Left", selectwordright:"Ctrl-Shift-Right", gotowordright:"Ctrl-Right", selecttolineend:"Alt-Shift-Right", gotolineend:"Alt-Right|End", selectright:"Shift-Right", gotoright:"Right", selectpagedown:"Shift-PageDown", pagedown:"PageDown", selectpageup:"Shift-PageUp", pageup:"PageUp", selectlinestart:"Shift-Home", selectlineend:"Shift-End",
|
||||
del:"Delete", backspace:"Backspace", outdent:"Shift-Tab", indent:"Tab"}
|
||||
});
|
||||
|
|
@ -327,7 +327,7 @@ define(function(g) {
|
|||
}this.modified = true;
|
||||
b = a.start.row;
|
||||
var c = a.end.row, d = this.getLine(b).substring(0, a.start.column) + this.getLine(c).substring(a.end.column);
|
||||
this.lines.splice(b, c - b + 1, d);
|
||||
d != "" ? this.lines.splice(b, c - b + 1, d) : this.lines.splice(b, c - b + 1, "");
|
||||
return a.start
|
||||
}
|
||||
};
|
||||
|
|
|
|||
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.$computeTabString();
|
||||
this.config = a;
|
||||
var f = Math.max(b, a.firstRow), c = Math.min(e, a.lastRow), d = this.element.childNodes, h = this;
|
||||
this.tokenizer.getTokens(f, c, function(i) {
|
||||
for(var g = f;g <= c;g++) {
|
||||
|
|
@ -128,6 +129,7 @@ define(function(k) {
|
|||
};
|
||||
this.update = function(a) {
|
||||
this.$computeTabString();
|
||||
this.config = a;
|
||||
var b = [], e = this;
|
||||
this.tokenizer.getTokens(a.firstRow, a.lastRow, function(f) {
|
||||
for(var c = a.firstRow;c <= a.lastRow;c++) {
|
||||
|
|
|
|||
|
|
@ -6,53 +6,55 @@ define(function(f) {
|
|||
};
|
||||
h.inherits(f, i);
|
||||
(function() {
|
||||
this.toggleCommentLines = function(d, b, e) {
|
||||
var c = true;
|
||||
d = /^(\s*)\/\//;
|
||||
for(var a = e.start.row;a <= e.end.row;a++) {
|
||||
if(!d.test(b.getLine(a))) {
|
||||
c = false;
|
||||
this.toggleCommentLines = function(c, d, e) {
|
||||
var a = true;
|
||||
c = /^(\s*)\/\//;
|
||||
for(var b = e.start.row;b <= e.end.row;b++) {
|
||||
if(!c.test(d.getLine(b))) {
|
||||
a = false;
|
||||
break
|
||||
}
|
||||
}if(c) {
|
||||
c = new m(0, 0, 0, 0);
|
||||
for(a = e.start.row;a <= e.end.row;a++) {
|
||||
var g = b.getLine(a).replace(d, "$1");
|
||||
c.start.row = a;
|
||||
c.end.row = a;
|
||||
c.end.column = g.length + 2;
|
||||
b.replace(c, g)
|
||||
}if(a) {
|
||||
a = new m(0, 0, 0, 0);
|
||||
for(b = e.start.row;b <= e.end.row;b++) {
|
||||
var g = d.getLine(b).replace(c, "$1");
|
||||
a.start.row = b;
|
||||
a.end.row = b;
|
||||
a.end.column = g.length + 2;
|
||||
d.replace(a, g)
|
||||
}return-2
|
||||
}else {
|
||||
return b.indentRows(e, "//")
|
||||
return d.indentRows(e, "//")
|
||||
}
|
||||
};
|
||||
this.getNextLineIndent = function(d, b, e) {
|
||||
var c = this.$getIndent(b), a = this.$tokenizer.getLineTokens(b, d), g = a.tokens;
|
||||
a = a.state;
|
||||
this.getNextLineIndent = function(c, d, e) {
|
||||
var a = this.$getIndent(d), b = this.$tokenizer.getLineTokens(d, c), g = b.tokens;
|
||||
b = b.state;
|
||||
if(g.length && g[g.length - 1].type == "comment") {
|
||||
return c
|
||||
}if(d == "start") {
|
||||
if(d = b.match(/^.*[\{\(\[]\s*$/)) {
|
||||
c += e
|
||||
return a
|
||||
}if(c == "start") {
|
||||
if(c = d.match(/^.*[\{\(\[]\s*$/)) {
|
||||
a += e
|
||||
}
|
||||
}else {
|
||||
if(d == "doc-start") {
|
||||
if(a == "start") {
|
||||
if(c == "doc-start") {
|
||||
if(b == "start") {
|
||||
return""
|
||||
}if(d = b.match(/^\s*(\/?)\*/)) {
|
||||
if(d[1]) {
|
||||
c += " "
|
||||
}c += "* "
|
||||
}
|
||||
}if(c = d.match(/^\s*(\/?)\*/)) {
|
||||
if(c[1]) {
|
||||
a += " "
|
||||
}a += "* "
|
||||
}if(c[1]) {
|
||||
a += " "
|
||||
}a += "* "
|
||||
}
|
||||
}return c
|
||||
}return a
|
||||
};
|
||||
this.checkOutdent = function(d, b, e) {
|
||||
return this.$outdent.checkOutdent(b, e)
|
||||
this.checkOutdent = function(c, d, e) {
|
||||
return this.$outdent.checkOutdent(d, e)
|
||||
};
|
||||
this.autoOutdent = function(d, b, e) {
|
||||
return this.$outdent.autoOutdent(b, e)
|
||||
this.autoOutdent = function(c, d, e) {
|
||||
return this.$outdent.autoOutdent(d, e)
|
||||
}
|
||||
}).call(f.prototype);
|
||||
return f
|
||||
|
|
|
|||
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) {
|
||||
var e = c("./lib/event");
|
||||
c = function(b) {
|
||||
define(function(d) {
|
||||
var e = d("./lib/event");
|
||||
d = function(b) {
|
||||
this.onRender = b;
|
||||
this.pending = false;
|
||||
this.changes = 0
|
||||
|
|
@ -13,8 +13,9 @@ define(function(c) {
|
|||
var a = this;
|
||||
this.setTimeoutZero(function() {
|
||||
a.pending = false;
|
||||
a.onRender(a.changes);
|
||||
a.changes = 0
|
||||
var c = a.changes;
|
||||
a.changes = 0;
|
||||
a.onRender(c)
|
||||
})
|
||||
}
|
||||
};
|
||||
|
|
@ -23,9 +24,9 @@ define(function(c) {
|
|||
this.setTimeoutZero = function(b) {
|
||||
if(!this.attached) {
|
||||
var a = this;
|
||||
e.addListener(window, "message", function(d) {
|
||||
if(d.source == window && a.callback && d.data == a.messageName) {
|
||||
e.stopPropagation(d);
|
||||
e.addListener(window, "message", function(c) {
|
||||
if(c.source == window && a.callback && c.data == a.messageName) {
|
||||
e.stopPropagation(c);
|
||||
a.callback()
|
||||
}
|
||||
});
|
||||
|
|
@ -38,6 +39,6 @@ define(function(c) {
|
|||
setTimeout(b, 0)
|
||||
}
|
||||
}
|
||||
}).call(c.prototype);
|
||||
return c
|
||||
}).call(d.prototype);
|
||||
return d
|
||||
});
|
||||
|
|
@ -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>
|
||||
*/
|
||||
require.def(["ace/Document", "ace/UndoManager", "ace/Editor", "ace/test/MockRenderer"], function(b, h, i, j) {
|
||||
new TestCase("TextDocumentTest", {"test: find matching opening bracket":function() {
|
||||
var a = new b(["(()(", "())))"]);
|
||||
assertPosition(0, 1, a.findMatchingBracket({row:0, column:3}));
|
||||
assertPosition(1, 0, a.findMatchingBracket({row:1, column:2}));
|
||||
assertPosition(0, 3, a.findMatchingBracket({row:1, column:3}));
|
||||
assertPosition(0, 0, a.findMatchingBracket({row:1, column:4}));
|
||||
assertEquals(null, a.findMatchingBracket({row:1, column:5}))
|
||||
}, "test: find matching closing bracket":function() {
|
||||
var a = new b(["(()(", "())))"]);
|
||||
assertPosition(1, 1, a.findMatchingBracket({row:1, column:1}));
|
||||
assertPosition(1, 1, a.findMatchingBracket({row:1, column:1}));
|
||||
assertPosition(1, 2, a.findMatchingBracket({row:0, column:4}));
|
||||
assertPosition(0, 2, a.findMatchingBracket({row:0, column:2}));
|
||||
assertPosition(1, 3, a.findMatchingBracket({row:0, column:1}));
|
||||
assertEquals(null, a.findMatchingBracket({row:0, column:0}))
|
||||
}, "test: match different bracket types":function() {
|
||||
var a = new b(["({[", ")]}"]);
|
||||
assertPosition(1, 0, a.findMatchingBracket({row:0, column:1}));
|
||||
assertPosition(1, 2, a.findMatchingBracket({row:0, column:2}));
|
||||
assertPosition(1, 1, a.findMatchingBracket({row:0, column:3}));
|
||||
assertPosition(0, 0, a.findMatchingBracket({row:1, column:1}));
|
||||
assertPosition(0, 2, a.findMatchingBracket({row:1, column:2}));
|
||||
assertPosition(0, 1, a.findMatchingBracket({row:1, column:3}))
|
||||
}, "test: move lines down":function() {
|
||||
var a = new b(["1", "2", "3", "4"]);
|
||||
a.moveLinesDown(0, 1);
|
||||
assertEquals("3\n1\n2\n4", a.toString());
|
||||
a.moveLinesDown(1, 2);
|
||||
assertEquals("3\n4\n1\n2", a.toString());
|
||||
a.moveLinesDown(2, 3);
|
||||
assertEquals("3\n4\n1\n2", a.toString());
|
||||
a.moveLinesDown(2, 2);
|
||||
assertEquals("3\n4\n2\n1", a.toString())
|
||||
}, "test: move lines up":function() {
|
||||
var a = new b(["1", "2", "3", "4"]);
|
||||
a.moveLinesUp(2, 3);
|
||||
assertEquals("1\n3\n4\n2", a.toString());
|
||||
a.moveLinesUp(1, 2);
|
||||
assertEquals("3\n4\n1\n2", a.toString());
|
||||
a.moveLinesUp(0, 1);
|
||||
assertEquals("3\n4\n1\n2", a.toString());
|
||||
a.moveLinesUp(2, 2);
|
||||
assertEquals("3\n1\n4\n2", a.toString())
|
||||
}, "test: duplicate lines":function() {
|
||||
var a = new b(["1", "2", "3", "4"]);
|
||||
a.duplicateLines(1, 2);
|
||||
assertEquals("1\n2\n3\n2\n3\n4", a.toString())
|
||||
}, "test: duplicate last line":function() {
|
||||
var a = new b(["1", "2", "3"]);
|
||||
a.duplicateLines(2, 2);
|
||||
assertEquals("1\n2\n3\n3", a.toString())
|
||||
}, "test: duplicate first line":function() {
|
||||
var a = new b(["1", "2", "3"]);
|
||||
a.duplicateLines(0, 0);
|
||||
assertEquals("1\n1\n2\n3", a.toString())
|
||||
}, "test: should handle unix style new lines":function() {
|
||||
var a = new b(["1", "2", "3"]);
|
||||
assertEquals("1\n2\n3", a.toString())
|
||||
}, "test: should handle windows style new lines":function() {
|
||||
var a = new b("1\r\n2\r\n3");
|
||||
a.setNewLineMode("unix");
|
||||
assertEquals("1\n2\n3", a.toString())
|
||||
}, "test: set new line mode to 'windows' should use '\r\n' as new lines":function() {
|
||||
var a = new b("1\n2\n3");
|
||||
a.setNewLineMode("windows");
|
||||
assertEquals("1\r\n2\r\n3", a.toString())
|
||||
}, "test: set new line mode to 'unix' should use '\n' as new lines":function() {
|
||||
var a = new b("1\r\n2\r\n3");
|
||||
a.setNewLineMode("unix");
|
||||
assertEquals("1\n2\n3", a.toString())
|
||||
}, "test: set new line mode to 'auto' should use detect the incoming nl type":function() {
|
||||
var a = new b("1\n2\n3");
|
||||
a.setNewLineMode("auto");
|
||||
assertEquals("1\n2\n3", a.toString());
|
||||
a = new b("1\r\n2\r\n3");
|
||||
a.setNewLineMode("auto");
|
||||
assertEquals("1\r\n2\r\n3", a.toString());
|
||||
a.replace(new Range(0, 0, 2, 1), "4\n5\n6");
|
||||
assertEquals("4\n5\n6", a.toString())
|
||||
}, "test: undo/redo for delete line":function() {
|
||||
var a = new b(["111", "222", "333"]), c = new h;
|
||||
a.setUndoManager(c);
|
||||
var e = a.toString(), d = new i(new j, a);
|
||||
d.removeLines();
|
||||
var f = a.toString();
|
||||
assertEquals("222\n333", f);
|
||||
a.$informUndoManager.call();
|
||||
d.removeLines();
|
||||
var g = a.toString();
|
||||
assertEquals("333", g);
|
||||
a.$informUndoManager.call();
|
||||
d.removeLines();
|
||||
d = a.toString();
|
||||
assertEquals("", d);
|
||||
a.$informUndoManager.call();
|
||||
c.undo();
|
||||
a.$informUndoManager.call();
|
||||
assertEquals(g, a.toString());
|
||||
c.undo();
|
||||
a.$informUndoManager.call();
|
||||
assertEquals(f, a.toString());
|
||||
c.undo();
|
||||
a.$informUndoManager.call();
|
||||
assertEquals(e, a.toString());
|
||||
c.undo();
|
||||
a.$informUndoManager.call();
|
||||
assertEquals(e, a.toString())
|
||||
}, "test: convert document to screen coordinates":function() {
|
||||
var a = new b("01234\t567890\t1234");
|
||||
a.setTabSize(4);
|
||||
assertEquals(0, a.documentToScreenColumn(0, 0));
|
||||
assertEquals(4, a.documentToScreenColumn(0, 4));
|
||||
assertEquals(5, a.documentToScreenColumn(0, 5));
|
||||
assertEquals(9, a.documentToScreenColumn(0, 6));
|
||||
assertEquals(15, a.documentToScreenColumn(0, 12));
|
||||
assertEquals(19, a.documentToScreenColumn(0, 13));
|
||||
a.setTabSize(2);
|
||||
assertEquals(0, a.documentToScreenColumn(0, 0));
|
||||
assertEquals(4, a.documentToScreenColumn(0, 4));
|
||||
assertEquals(5, a.documentToScreenColumn(0, 5));
|
||||
assertEquals(7, a.documentToScreenColumn(0, 6));
|
||||
assertEquals(13, a.documentToScreenColumn(0, 12));
|
||||
assertEquals(15, a.documentToScreenColumn(0, 13))
|
||||
}, "test: convert document to scrren coordinates with leading tabs":function() {
|
||||
var a = new b("\t\t123");
|
||||
a.setTabSize(4);
|
||||
assertEquals(0, a.documentToScreenColumn(0, 0));
|
||||
assertEquals(4, a.documentToScreenColumn(0, 1));
|
||||
assertEquals(8, a.documentToScreenColumn(0, 2));
|
||||
assertEquals(9, a.documentToScreenColumn(0, 3))
|
||||
}, "test: convert screen to document coordinates":function() {
|
||||
var a = new b("01234\t567890\t1234");
|
||||
a.setTabSize(4);
|
||||
assertEquals(0, a.screenToDocumentColumn(0, 0));
|
||||
assertEquals(4, a.screenToDocumentColumn(0, 4));
|
||||
assertEquals(5, a.screenToDocumentColumn(0, 5));
|
||||
assertEquals(5, a.screenToDocumentColumn(0, 6));
|
||||
assertEquals(5, a.screenToDocumentColumn(0, 7));
|
||||
assertEquals(5, a.screenToDocumentColumn(0, 8));
|
||||
assertEquals(6, a.screenToDocumentColumn(0, 9));
|
||||
assertEquals(12, a.screenToDocumentColumn(0, 15));
|
||||
assertEquals(13, a.screenToDocumentColumn(0, 19))
|
||||
}})
|
||||
});
|
||||
require("../../../support/paths");
|
||||
var Document = require("../document"), UndoManager = require("../undomanager"), MockRenderer = require("./mockrenderer"), Range = require("../range"), assert = require("./assertions"), async = require("async"), Test = {"test: find matching opening bracket":function() {
|
||||
var a = new Document(["(()(", "())))"]);
|
||||
assert.position(a.findMatchingBracket({row:0, column:3}), 0, 1);
|
||||
assert.position(a.findMatchingBracket({row:1, column:2}), 1, 0);
|
||||
assert.position(a.findMatchingBracket({row:1, column:3}), 0, 3);
|
||||
assert.position(a.findMatchingBracket({row:1, column:4}), 0, 0);
|
||||
assert.equal(a.findMatchingBracket({row:1, column:5}), null)
|
||||
}, "test: find matching closing bracket":function() {
|
||||
var a = new Document(["(()(", "())))"]);
|
||||
assert.position(a.findMatchingBracket({row:1, column:1}), 1, 1);
|
||||
assert.position(a.findMatchingBracket({row:1, column:1}), 1, 1);
|
||||
assert.position(a.findMatchingBracket({row:0, column:4}), 1, 2);
|
||||
assert.position(a.findMatchingBracket({row:0, column:2}), 0, 2);
|
||||
assert.position(a.findMatchingBracket({row:0, column:1}), 1, 3);
|
||||
assert.equal(a.findMatchingBracket({row:0, column:0}), null)
|
||||
}, "test: match different bracket types":function() {
|
||||
var a = new Document(["({[", ")]}"]);
|
||||
assert.position(a.findMatchingBracket({row:0, column:1}), 1, 0);
|
||||
assert.position(a.findMatchingBracket({row:0, column:2}), 1, 2);
|
||||
assert.position(a.findMatchingBracket({row:0, column:3}), 1, 1);
|
||||
assert.position(a.findMatchingBracket({row:1, column:1}), 0, 0);
|
||||
assert.position(a.findMatchingBracket({row:1, column:2}), 0, 2);
|
||||
assert.position(a.findMatchingBracket({row:1, column:3}), 0, 1)
|
||||
}, "test: move lines down":function() {
|
||||
var a = new Document(["1", "2", "3", "4"]);
|
||||
console.log(a.toString().replace(/\n/g, "\\n"));
|
||||
a.moveLinesDown(0, 1);
|
||||
console.log(a.toString().replace(/\n/g, "\\n"));
|
||||
assert.equal(a.toString(), "3\n1\n2\n4");
|
||||
a.moveLinesDown(1, 2);
|
||||
assert.equal(a.toString(), "3\n4\n1\n2");
|
||||
a.moveLinesDown(2, 3);
|
||||
assert.equal(a.toString(), "3\n4\n1\n2");
|
||||
a.moveLinesDown(2, 2);
|
||||
assert.equal(a.toString(), "3\n4\n2\n1")
|
||||
}, "__test: move lines up":function() {
|
||||
var a = new Document(["1", "2", "3", "4"]);
|
||||
console.log(a.toString().replace(/\n/g, "\\n"));
|
||||
a.moveLinesUp(2, 3);
|
||||
console.log(a.toString().replace(/\n/g, "\\n"));
|
||||
assert.equal(a.toString(), "1\n3\n4\n2");
|
||||
a.moveLinesUp(1, 2);
|
||||
assert.equal(a.toString(), "3\n4\n1\n2");
|
||||
a.moveLinesUp(0, 1);
|
||||
assert.equal(a.toString(), "3\n4\n1\n2");
|
||||
a.moveLinesUp(2, 2);
|
||||
assert.equal(a.toString(), "3\n1\n4\n2")
|
||||
}, "test: duplicate lines":function() {
|
||||
var a = new Document(["1", "2", "3", "4"]);
|
||||
a.duplicateLines(1, 2);
|
||||
assert.equal(a.toString(), "1\n2\n3\n2\n3\n4")
|
||||
}, "test: duplicate last line":function() {
|
||||
var a = new Document(["1", "2", "3"]);
|
||||
a.duplicateLines(2, 2);
|
||||
assert.equal(a.toString(), "1\n2\n3\n3")
|
||||
}, "test: duplicate first line":function() {
|
||||
var a = new Document(["1", "2", "3"]);
|
||||
a.duplicateLines(0, 0);
|
||||
assert.equal(a.toString(), "1\n1\n2\n3")
|
||||
}, "test: should handle unix style new lines":function() {
|
||||
var a = new Document(["1", "2", "3"]);
|
||||
assert.equal(a.toString(), "1\n2\n3")
|
||||
}, "test: should handle windows style new lines":function() {
|
||||
var a = new Document("1\r\n2\r\n3");
|
||||
a.setNewLineMode("unix");
|
||||
assert.equal(a.toString(), "1\n2\n3")
|
||||
}, "test: set new line mode to 'windows' should use '\r\n' as new lines":function() {
|
||||
var a = new Document("1\n2\n3");
|
||||
a.setNewLineMode("windows");
|
||||
assert.equal(a.toString(), "1\r\n2\r\n3")
|
||||
}, "test: set new line mode to 'unix' should use '\n' as new lines":function() {
|
||||
var a = new Document("1\r\n2\r\n3");
|
||||
a.setNewLineMode("unix");
|
||||
assert.equal(a.toString(), "1\n2\n3")
|
||||
}, "test: set new line mode to 'auto' should detect the incoming nl type":function() {
|
||||
var a = new Document("1\n2\n3");
|
||||
a.setNewLineMode("auto");
|
||||
assert.equal(a.toString(), "1\n2\n3");
|
||||
a = new Document("1\r\n2\r\n3");
|
||||
a.setNewLineMode("auto");
|
||||
assert.equal(a.toString(), "1\r\n2\r\n3");
|
||||
a.replace(new Range(0, 0, 2, 1), "4\n5\n6");
|
||||
assert.equal("4\n5\n6", a.toString())
|
||||
}, "__test: undo/redo for delete line":function() {
|
||||
var a = new Document(["111", "222", "333"]), b = new UndoManager;
|
||||
a.setUndoManager(b);
|
||||
var d = a.toString(), c = new Editor(new MockRenderer, a);
|
||||
c.removeLines();
|
||||
var e = a.toString();
|
||||
assert.equal(e, "222\n333");
|
||||
a.$informUndoManager.call();
|
||||
c.removeLines();
|
||||
var f = a.toString();
|
||||
assert.equal(f, "333");
|
||||
a.$informUndoManager.call();
|
||||
c.removeLines();
|
||||
c = a.toString();
|
||||
assert.equal(c, "");
|
||||
a.$informUndoManager.call();
|
||||
b.undo();
|
||||
a.$informUndoManager.call();
|
||||
assert.equal(a.toString(), f);
|
||||
b.undo();
|
||||
a.$informUndoManager.call();
|
||||
assert.equal(a.toString(), e);
|
||||
b.undo();
|
||||
a.$informUndoManager.call();
|
||||
assert.equal(a.toString(), d);
|
||||
b.undo();
|
||||
a.$informUndoManager.call();
|
||||
assert.equal(a.toString(), d)
|
||||
}, "test: convert document to screen coordinates":function() {
|
||||
var a = new Document("01234\t567890\t1234");
|
||||
a.setTabSize(4);
|
||||
assert.equal(a.documentToScreenColumn(0, 0), 0);
|
||||
assert.equal(a.documentToScreenColumn(0, 4), 4);
|
||||
assert.equal(a.documentToScreenColumn(0, 5), 5);
|
||||
assert.equal(a.documentToScreenColumn(0, 6), 9);
|
||||
assert.equal(a.documentToScreenColumn(0, 12), 15);
|
||||
assert.equal(a.documentToScreenColumn(0, 13), 19);
|
||||
a.setTabSize(2);
|
||||
assert.equal(a.documentToScreenColumn(0, 0), 0);
|
||||
assert.equal(a.documentToScreenColumn(0, 4), 4);
|
||||
assert.equal(a.documentToScreenColumn(0, 5), 5);
|
||||
assert.equal(a.documentToScreenColumn(0, 6), 7);
|
||||
assert.equal(a.documentToScreenColumn(0, 12), 13);
|
||||
assert.equal(a.documentToScreenColumn(0, 13), 15)
|
||||
}, "test: convert document to scrren coordinates with leading tabs":function() {
|
||||
var a = new Document("\t\t123");
|
||||
a.setTabSize(4);
|
||||
assert.equal(a.documentToScreenColumn(0, 0), 0);
|
||||
assert.equal(a.documentToScreenColumn(0, 1), 4);
|
||||
assert.equal(a.documentToScreenColumn(0, 2), 8);
|
||||
assert.equal(a.documentToScreenColumn(0, 3), 9)
|
||||
}, "test: convert screen to document coordinates":function() {
|
||||
var a = new Document("01234\t567890\t1234");
|
||||
a.setTabSize(4);
|
||||
assert.equal(a.screenToDocumentColumn(0, 0), 0);
|
||||
assert.equal(a.screenToDocumentColumn(0, 4), 4);
|
||||
assert.equal(a.screenToDocumentColumn(0, 5), 5);
|
||||
assert.equal(a.screenToDocumentColumn(0, 6), 5);
|
||||
assert.equal(a.screenToDocumentColumn(0, 7), 5);
|
||||
assert.equal(a.screenToDocumentColumn(0, 8), 5);
|
||||
assert.equal(a.screenToDocumentColumn(0, 9), 6);
|
||||
assert.equal(a.screenToDocumentColumn(0, 15), 12);
|
||||
assert.equal(a.screenToDocumentColumn(0, 19), 13)
|
||||
}};
|
||||
module.exports = require("async/test").testcase(Test);
|
||||
module === require.main && module.exports.exec();
|
||||
|
|
@ -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>
|
||||
*/
|
||||
require.def([], function() {
|
||||
define(function() {
|
||||
MockRenderer = function(a) {
|
||||
this.container = document.createElement("div");
|
||||
this.cursor = {row:0, column:0};
|
||||
|
|
@ -52,5 +52,11 @@ require.def([], function() {
|
|||
};
|
||||
MockRenderer.prototype.setBreakpoints = function() {
|
||||
};
|
||||
MockRenderer.prototype.updateFull = function() {
|
||||
};
|
||||
MockRenderer.prototype.showCursor = function() {
|
||||
};
|
||||
MockRenderer.prototype.visualizeFocus = function() {
|
||||
};
|
||||
return MockRenderer
|
||||
});
|
||||
|
|
@ -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>
|
||||
*/
|
||||
require.def(["ace/Document", "ace/Search"], function(c, b) {
|
||||
new TestCase("SearchTest", {"test: configure the search object":function() {
|
||||
(new b).set({needle:"juhu", scope:b.ALL})
|
||||
}, "test: find simple text in document":function() {
|
||||
var a = new c(["juhu kinners 123", "456"]);
|
||||
a = (new b).set({needle:"kinners"}).find(a);
|
||||
assertPosition(0, 5, a.start);
|
||||
assertPosition(0, 12, a.end)
|
||||
}, "test: find simple text in next line":function() {
|
||||
var a = new c(["abc", "juhu kinners 123", "456"]);
|
||||
a = (new b).set({needle:"kinners"}).find(a);
|
||||
assertPosition(1, 5, a.start);
|
||||
assertPosition(1, 12, a.end)
|
||||
}, "test: find text starting at cursor position":function() {
|
||||
var a = new c(["juhu kinners", "juhu kinners 123"]);
|
||||
a.getSelection().moveCursorTo(0, 6);
|
||||
a = (new b).set({needle:"kinners"}).find(a);
|
||||
assertPosition(1, 5, a.start);
|
||||
assertPosition(1, 12, a.end)
|
||||
}, "test: wrap search is off by default":function() {
|
||||
var a = new c(["abc", "juhu kinners 123", "456"]);
|
||||
a.getSelection().moveCursorTo(2, 1);
|
||||
var d = (new b).set({needle:"kinners"});
|
||||
assertEquals(null, d.find(a))
|
||||
}, "test: wrap search should wrap at file end":function() {
|
||||
var a = new c(["abc", "juhu kinners 123", "456"]);
|
||||
a.getSelection().moveCursorTo(2, 1);
|
||||
a = (new b).set({needle:"kinners", wrap:true}).find(a);
|
||||
assertPosition(1, 5, a.start);
|
||||
assertPosition(1, 12, a.end)
|
||||
}, "test: wrap search with no match should return 'null'":function() {
|
||||
var a = new c(["abc", "juhu kinners 123", "456"]);
|
||||
a.getSelection().moveCursorTo(2, 1);
|
||||
var d = (new b).set({needle:"xyz", wrap:true});
|
||||
assertEquals(null, d.find(a))
|
||||
}, "test: case sensitive is by default off":function() {
|
||||
var a = new c(["abc", "juhu kinners 123", "456"]), d = (new b).set({needle:"JUHU"});
|
||||
assertEquals(null, d.find(a))
|
||||
}, "test: case sensitive search":function() {
|
||||
var a = new c(["abc", "juhu kinners 123", "456"]);
|
||||
a = (new b).set({needle:"KINNERS", caseSensitive:true}).find(a);
|
||||
assertPosition(1, 5, a.start);
|
||||
assertPosition(1, 12, a.end)
|
||||
}, "test: whole word search should not match inside of words":function() {
|
||||
var a = new c(["juhukinners", "juhu kinners 123", "456"]);
|
||||
a = (new b).set({needle:"kinners", wholeWord:true}).find(a);
|
||||
assertPosition(1, 5, a.start);
|
||||
assertPosition(1, 12, a.end)
|
||||
}, "test: find backwards":function() {
|
||||
var a = new c(["juhu juhu juhu juhu"]);
|
||||
a.getSelection().moveCursorTo(0, 10);
|
||||
a = (new b).set({needle:"juhu", backwards:true}).find(a);
|
||||
assertPosition(0, 5, a.start);
|
||||
assertPosition(0, 9, a.end)
|
||||
}, "test: find in selection":function() {
|
||||
var a = new c(["juhu", "juhu", "juhu", "juhu"]);
|
||||
a.getSelection().setSelectionAnchor(1, 0);
|
||||
a.getSelection().selectTo(3, 5);
|
||||
var d = (new b).set({needle:"juhu", wrap:true, scope:b.SELECTION}), e = d.find(a);
|
||||
assertPosition(1, 0, e.start);
|
||||
assertPosition(1, 4, e.end);
|
||||
a.getSelection().setSelectionAnchor(0, 2);
|
||||
a.getSelection().selectTo(3, 2);
|
||||
e = d.find(a);
|
||||
assertPosition(1, 0, e.start);
|
||||
assertPosition(1, 4, e.end)
|
||||
}, "test: find backwards in selection":function() {
|
||||
var a = new c(["juhu", "juhu", "juhu", "juhu"]), d = (new b).set({needle:"juhu", wrap:true, backwards:true, scope:b.SELECTION});
|
||||
a.getSelection().setSelectionAnchor(0, 2);
|
||||
a.getSelection().selectTo(3, 2);
|
||||
var e = d.find(a);
|
||||
assertPosition(2, 0, e.start);
|
||||
assertPosition(2, 4, e.end);
|
||||
a.getSelection().setSelectionAnchor(0, 2);
|
||||
a.getSelection().selectTo(1, 2);
|
||||
assertEquals(null, d.find(a))
|
||||
}, "test: edge case - match directly before the cursor":function() {
|
||||
var a = new c(["123", "123", "juhu"]), d = (new b).set({needle:"juhu", wrap:true});
|
||||
a.getSelection().moveCursorTo(2, 5);
|
||||
a = d.find(a);
|
||||
assertPosition(2, 0, a.start);
|
||||
assertPosition(2, 4, a.end)
|
||||
}, "test: edge case - match backwards directly after the cursor":function() {
|
||||
var a = new c(["123", "123", "juhu"]), d = (new b).set({needle:"juhu", wrap:true, backwards:true});
|
||||
a.getSelection().moveCursorTo(2, 0);
|
||||
a = d.find(a);
|
||||
assertPosition(2, 0, a.start);
|
||||
assertPosition(2, 4, a.end)
|
||||
}, "test: find using a regular expression":function() {
|
||||
var a = new c(["abc123 123 cd", "abc"]);
|
||||
a = (new b).set({needle:"\\d+", regExp:true}).find(a);
|
||||
assertPosition(0, 3, a.start);
|
||||
assertPosition(0, 6, a.end)
|
||||
}, "test: find using a regular expression and whole word":function() {
|
||||
var a = new c(["abc123 123 cd", "abc"]);
|
||||
a = (new b).set({needle:"\\d+\\b", regExp:true, wholeWord:true}).find(a);
|
||||
assertPosition(0, 7, a.start);
|
||||
assertPosition(0, 10, a.end)
|
||||
}, "test: use regular expressions with capture groups":function() {
|
||||
var a = new c([" ab: 12px", " <h1 abc"]);
|
||||
a = (new b).set({needle:"(\\d+)", regExp:true}).find(a);
|
||||
assertPosition(0, 6, a.start);
|
||||
assertPosition(0, 8, a.end)
|
||||
}, "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});
|
||||
a.getSelection().setSelectionAnchor(0, 2);
|
||||
a.getSelection().selectTo(3, 2);
|
||||
a = d.findAll(a);
|
||||
assertEquals(2, a.length);
|
||||
assertPosition(1, 1, a[0].start);
|
||||
assertPosition(1, 3, a[0].end);
|
||||
assertPosition(2, 1, a[1].start);
|
||||
assertPosition(2, 3, a[1].end)
|
||||
}, "test: replace() should return the replacement if the input matches the needle":function() {
|
||||
var a = (new b).set({needle:"juhu"});
|
||||
assertEquals("kinners", a.replace("juhu", "kinners"));
|
||||
assertEquals(null, a.replace("", "kinners"));
|
||||
assertEquals(null, a.replace(" juhu", "kinners"))
|
||||
}, "test: replace with a RegExp search":function() {
|
||||
var a = (new b).set({needle:"\\d+", regExp:true});
|
||||
assertEquals("kinners", a.replace("123", "kinners"));
|
||||
assertEquals("kinners", a.replace("01234", "kinners"));
|
||||
assertEquals(null, a.replace("", "kinners"));
|
||||
assertEquals(null, a.replace("a12", "kinners"));
|
||||
assertEquals(null, a.replace("12a", "kinners"))
|
||||
}, "test: replace with RegExp match and capture groups":function() {
|
||||
var a = (new b).set({needle:"ab(\\d\\d)", regExp:true});
|
||||
assertEquals("cd12", a.replace("ab12", "cd$1"));
|
||||
assertEquals("-ab12-", a.replace("ab12", "-$&-"));
|
||||
assertEquals("$", a.replace("ab12", "$$"))
|
||||
}})
|
||||
});
|
||||
require("../../../support/paths");
|
||||
var Document = require("../document"), Search = require("../search"), assert = require("./assertions"), Test = {"test: configure the search object":function() {
|
||||
(new Search).set({needle:"juhu", scope:Search.ALL})
|
||||
}, "test: find simple text in document":function() {
|
||||
var a = new Document(["juhu kinners 123", "456"]);
|
||||
a = (new Search).set({needle:"kinners"}).find(a);
|
||||
assert.position(a.start, 0, 5);
|
||||
assert.position(a.end, 0, 12)
|
||||
}, "test: find simple text in next line":function() {
|
||||
var a = new Document(["abc", "juhu kinners 123", "456"]);
|
||||
a = (new Search).set({needle:"kinners"}).find(a);
|
||||
assert.position(a.start, 1, 5);
|
||||
assert.position(a.end, 1, 12)
|
||||
}, "test: find text starting at cursor position":function() {
|
||||
var a = new Document(["juhu kinners", "juhu kinners 123"]);
|
||||
a.getSelection().moveCursorTo(0, 6);
|
||||
a = (new Search).set({needle:"kinners"}).find(a);
|
||||
assert.position(a.start, 1, 5);
|
||||
assert.position(a.end, 1, 12)
|
||||
}, "test: wrap search is off by default":function() {
|
||||
var a = new Document(["abc", "juhu kinners 123", "456"]);
|
||||
a.getSelection().moveCursorTo(2, 1);
|
||||
var b = (new Search).set({needle:"kinners"});
|
||||
assert.equal(b.find(a), null)
|
||||
}, "test: wrap search should wrap at file end":function() {
|
||||
var a = new Document(["abc", "juhu kinners 123", "456"]);
|
||||
a.getSelection().moveCursorTo(2, 1);
|
||||
a = (new Search).set({needle:"kinners", wrap:true}).find(a);
|
||||
assert.position(a.start, 1, 5);
|
||||
assert.position(a.end, 1, 12)
|
||||
}, "test: wrap search with no match should return 'null'":function() {
|
||||
var a = new Document(["abc", "juhu kinners 123", "456"]);
|
||||
a.getSelection().moveCursorTo(2, 1);
|
||||
var b = (new Search).set({needle:"xyz", wrap:true});
|
||||
assert.equal(b.find(a), null)
|
||||
}, "test: case sensitive is by default off":function() {
|
||||
var a = new Document(["abc", "juhu kinners 123", "456"]), b = (new Search).set({needle:"JUHU"});
|
||||
assert.range(b.find(a), 1, 0, 1, 4)
|
||||
}, "test: case sensitive search":function() {
|
||||
var a = new Document(["abc", "juhu kinners 123", "456"]);
|
||||
a = (new Search).set({needle:"KINNERS", caseSensitive:true}).find(a);
|
||||
assert.equal(a, null)
|
||||
}, "test: whole word search should not match inside of words":function() {
|
||||
var a = new Document(["juhukinners", "juhu kinners 123", "456"]);
|
||||
a = (new Search).set({needle:"kinners", wholeWord:true}).find(a);
|
||||
assert.position(a.start, 1, 5);
|
||||
assert.position(a.end, 1, 12)
|
||||
}, "test: find backwards":function() {
|
||||
var a = new Document(["juhu juhu juhu juhu"]);
|
||||
a.getSelection().moveCursorTo(0, 10);
|
||||
a = (new Search).set({needle:"juhu", backwards:true}).find(a);
|
||||
assert.position(a.start, 0, 5);
|
||||
assert.position(a.end, 0, 9)
|
||||
}, "test: find in selection":function() {
|
||||
var a = new Document(["juhu", "juhu", "juhu", "juhu"]);
|
||||
a.getSelection().setSelectionAnchor(1, 0);
|
||||
a.getSelection().selectTo(3, 5);
|
||||
var b = (new Search).set({needle:"juhu", wrap:true, scope:Search.SELECTION}), c = b.find(a);
|
||||
assert.position(c.start, 1, 0);
|
||||
assert.position(c.end, 1, 4);
|
||||
a.getSelection().setSelectionAnchor(0, 2);
|
||||
a.getSelection().selectTo(3, 2);
|
||||
c = b.find(a);
|
||||
assert.position(c.start, 1, 0);
|
||||
assert.position(c.end, 1, 4)
|
||||
}, "test: find backwards in selection":function() {
|
||||
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().selectTo(3, 2);
|
||||
var c = b.find(a);
|
||||
assert.position(c.start, 2, 0);
|
||||
assert.position(c.end, 2, 4);
|
||||
a.getSelection().setSelectionAnchor(0, 2);
|
||||
a.getSelection().selectTo(1, 2);
|
||||
assert.equal(b.find(a), null)
|
||||
}, "test: edge case - match directly before the cursor":function() {
|
||||
var a = new Document(["123", "123", "juhu"]), b = (new Search).set({needle:"juhu", wrap:true});
|
||||
a.getSelection().moveCursorTo(2, 5);
|
||||
a = b.find(a);
|
||||
assert.position(a.start, 2, 0);
|
||||
assert.position(a.end, 2, 4)
|
||||
}, "test: edge case - match backwards directly after the cursor":function() {
|
||||
var a = new Document(["123", "123", "juhu"]), b = (new Search).set({needle:"juhu", wrap:true, backwards:true});
|
||||
a.getSelection().moveCursorTo(2, 0);
|
||||
a = b.find(a);
|
||||
assert.position(a.start, 2, 0);
|
||||
assert.position(a.end, 2, 4)
|
||||
}, "test: find using a regular expression":function() {
|
||||
var a = new Document(["abc123 123 cd", "abc"]);
|
||||
a = (new Search).set({needle:"\\d+", regExp:true}).find(a);
|
||||
assert.position(a.start, 0, 3);
|
||||
assert.position(a.end, 0, 6)
|
||||
}, "test: find using a regular expression and whole word":function() {
|
||||
var a = new Document(["abc123 123 cd", "abc"]);
|
||||
a = (new Search).set({needle:"\\d+\\b", regExp:true, wholeWord:true}).find(a);
|
||||
assert.position(a.start, 0, 7);
|
||||
assert.position(a.end, 0, 10)
|
||||
}, "test: use regular expressions with capture groups":function() {
|
||||
var a = new Document([" ab: 12px", " <h1 abc"]);
|
||||
a = (new Search).set({needle:"(\\d+)", regExp:true}).find(a);
|
||||
assert.position(a.start, 0, 6);
|
||||
assert.position(a.end, 0, 8)
|
||||
}, "test: find all matches in selection":function() {
|
||||
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().selectTo(3, 2);
|
||||
a = b.findAll(a);
|
||||
assert.equal(a.length, 2);
|
||||
assert.position(a[0].start, 1, 1);
|
||||
assert.position(a[0].end, 1, 3);
|
||||
assert.position(a[1].start, 2, 1);
|
||||
assert.position(a[1].end, 2, 3)
|
||||
}, "test: replace() should return the replacement if the input matches the needle":function() {
|
||||
var a = (new Search).set({needle:"juhu"});
|
||||
assert.equal(a.replace("juhu", "kinners"), "kinners");
|
||||
assert.equal(a.replace("", "kinners"), null);
|
||||
assert.equal(a.replace(" juhu", "kinners"), null)
|
||||
}, "test: replace with a RegExp search":function() {
|
||||
var a = (new Search).set({needle:"\\d+", regExp:true});
|
||||
assert.equal(a.replace("123", "kinners"), "kinners");
|
||||
assert.equal(a.replace("01234", "kinners"), "kinners");
|
||||
assert.equal(a.replace("", "kinners"), null);
|
||||
assert.equal(a.replace("a12", "kinners"), null);
|
||||
assert.equal(a.replace("12a", "kinners"), null)
|
||||
}, "test: replace with RegExp match and capture groups":function() {
|
||||
var a = (new Search).set({needle:"ab(\\d\\d)", regExp:true});
|
||||
assert.equal(a.replace("ab12", "cd$1"), "cd12");
|
||||
assert.equal(a.replace("ab12", "-$&-"), "-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>
|
||||
*/
|
||||
require.def(["ace/Document", "ace/Editor", "ace/mode/JavaScript", "ace/test/MockRenderer"], function(c, d, g, e) {
|
||||
TestCase("TextEditTest", {"test: delete line from the middle":function() {
|
||||
var b = new c("a\nb\nc\nd"), a = new d(new e, b);
|
||||
a.moveCursorTo(1, 1);
|
||||
a.removeLines();
|
||||
assertEquals("a\nc\nd", b.toString());
|
||||
assertPosition(1, 0, a.getCursorPosition());
|
||||
a.removeLines();
|
||||
assertEquals("a\nd", b.toString());
|
||||
assertPosition(1, 0, a.getCursorPosition());
|
||||
a.removeLines();
|
||||
assertEquals("a\n", b.toString());
|
||||
assertPosition(1, 0, a.getCursorPosition());
|
||||
a.removeLines();
|
||||
assertEquals("a\n", b.toString());
|
||||
assertPosition(1, 0, a.getCursorPosition())
|
||||
}, "test: delete multiple selected lines":function() {
|
||||
var b = new c("a\nb\nc\nd"), a = new d(new e, b);
|
||||
a.moveCursorTo(1, 1);
|
||||
a.getSelection().selectDown();
|
||||
a.removeLines();
|
||||
assertEquals("a\nd", b.toString());
|
||||
assertPosition(1, 0, a.getCursorPosition())
|
||||
}, "test: delete first line":function() {
|
||||
var b = new c("a\nb\nc"), a = new d(new e, b);
|
||||
a.removeLines();
|
||||
assertEquals("b\nc", b.toString());
|
||||
assertPosition(0, 0, a.getCursorPosition())
|
||||
}, "test: delete last":function() {
|
||||
var b = new c("a\nb\nc"), a = new d(new e, b);
|
||||
a.moveCursorTo(2, 1);
|
||||
a.removeLines();
|
||||
assertEquals("a\nb\n", b.toString());
|
||||
assertPosition(2, 0, a.getCursorPosition())
|
||||
}, "test: indent block":function() {
|
||||
var b = new c("a12345\nb12345\nc12345"), a = new d(new e, b);
|
||||
a.moveCursorTo(1, 3);
|
||||
a.getSelection().selectDown();
|
||||
a.blockIndent(" ");
|
||||
assertEquals("a12345\n b12345\n c12345", b.toString());
|
||||
assertPosition(2, 7, a.getCursorPosition());
|
||||
b = a.getSelectionRange();
|
||||
assertPosition(1, 7, b.start);
|
||||
assertPosition(2, 7, b.end)
|
||||
}, "test: outdent block":function() {
|
||||
var b = new c(" a12345\n b12345\n c12345"), a = new d(new e, b);
|
||||
a.moveCursorTo(0, 3);
|
||||
a.getSelection().selectDown();
|
||||
a.getSelection().selectDown();
|
||||
a.blockOutdent(" ");
|
||||
assertEquals(" a12345\nb12345\n c12345", b.toString());
|
||||
assertPosition(2, 1, a.getCursorPosition());
|
||||
var f = a.getSelectionRange();
|
||||
assertPosition(0, 1, f.start);
|
||||
assertPosition(2, 1, f.end);
|
||||
a.blockOutdent(" ");
|
||||
assertEquals(" a12345\nb12345\n c12345", b.toString());
|
||||
f = a.getSelectionRange();
|
||||
assertPosition(0, 1, f.start);
|
||||
assertPosition(2, 1, f.end)
|
||||
}, "test: outent without a selection should update cursor":function() {
|
||||
var b = new c(" 12"), a = new d(new e, b);
|
||||
a.moveCursorTo(0, 3);
|
||||
a.blockOutdent(" ");
|
||||
assertEquals(" 12", b.toString());
|
||||
assertPosition(0, 1, a.getCursorPosition())
|
||||
}, "test: comment lines should perserve selection":function() {
|
||||
var b = new c(" abc\ncde", new g), a = new d(new e, b);
|
||||
a.moveCursorTo(0, 2);
|
||||
a.getSelection().selectDown();
|
||||
a.toggleCommentLines();
|
||||
assertEquals("// abc\n//cde", b.toString());
|
||||
b = a.getSelectionRange();
|
||||
assertPosition(0, 4, b.start);
|
||||
assertPosition(1, 4, b.end)
|
||||
}, "test: uncomment lines should perserve selection":function() {
|
||||
var b = new c("// abc\n//cde", new g), a = new d(new e, b);
|
||||
a.moveCursorTo(0, 1);
|
||||
a.getSelection().selectDown();
|
||||
a.getSelection().selectRight();
|
||||
a.getSelection().selectRight();
|
||||
a.toggleCommentLines();
|
||||
assertEquals(" abc\ncde", b.toString());
|
||||
assertRange(0, 0, 1, 1, a.getSelectionRange())
|
||||
}, "test: comment lines - if the selection end is at the line start it should stay there":function() {
|
||||
var b = new c("abc\ncde", new g);
|
||||
b = new d(new e, b);
|
||||
b.moveCursorTo(0, 0);
|
||||
b.getSelection().selectDown();
|
||||
b.toggleCommentLines();
|
||||
assertRange(0, 2, 1, 0, b.getSelectionRange());
|
||||
b = new c("abc\ncde", new g);
|
||||
b = new d(new e, b);
|
||||
b.moveCursorTo(1, 0);
|
||||
b.getSelection().selectUp();
|
||||
b.toggleCommentLines();
|
||||
assertRange(0, 2, 1, 0, b.getSelectionRange())
|
||||
}, "test: move lines down should select moved lines":function() {
|
||||
var b = new c("11\n22\n33\n44"), a = new d(new e, b);
|
||||
a.moveCursorTo(0, 1);
|
||||
a.getSelection().selectDown();
|
||||
a.moveLinesDown();
|
||||
assertEquals("33\n11\n22\n44", b.toString());
|
||||
assertPosition(1, 0, a.getCursorPosition());
|
||||
assertPosition(3, 0, a.getSelection().getSelectionAnchor());
|
||||
assertPosition(1, 0, a.getSelection().getSelectionLead());
|
||||
a.moveLinesDown();
|
||||
assertEquals("33\n44\n11\n22", b.toString());
|
||||
assertPosition(2, 0, a.getCursorPosition());
|
||||
assertPosition(3, 2, a.getSelection().getSelectionAnchor());
|
||||
assertPosition(2, 0, a.getSelection().getSelectionLead());
|
||||
a.moveLinesDown();
|
||||
assertEquals("33\n44\n11\n22", b.toString());
|
||||
assertPosition(2, 0, a.getCursorPosition());
|
||||
assertPosition(3, 2, a.getSelection().getSelectionAnchor());
|
||||
assertPosition(2, 0, a.getSelection().getSelectionLead())
|
||||
}, "test: move lines up should select moved lines":function() {
|
||||
var b = new c("11\n22\n33\n44"), a = new d(new e, b);
|
||||
a.moveCursorTo(2, 1);
|
||||
a.getSelection().selectDown();
|
||||
a.moveLinesUp();
|
||||
assertEquals("11\n33\n44\n22", b.toString());
|
||||
assertPosition(1, 0, a.getCursorPosition());
|
||||
assertPosition(3, 0, a.getSelection().getSelectionAnchor());
|
||||
assertPosition(1, 0, a.getSelection().getSelectionLead());
|
||||
a.moveLinesUp();
|
||||
assertEquals("33\n44\n11\n22", b.toString());
|
||||
assertPosition(0, 0, a.getCursorPosition());
|
||||
assertPosition(2, 0, a.getSelection().getSelectionAnchor());
|
||||
assertPosition(0, 0, a.getSelection().getSelectionLead())
|
||||
}, "test: move line without active selection should move cursor to start of the moved line":function() {
|
||||
var b = new c("11\n22\n33\n44"), a = new d(new e, b);
|
||||
a.moveCursorTo(1, 1);
|
||||
a.clearSelection();
|
||||
a.moveLinesDown();
|
||||
assertEquals("11\n33\n22\n44", b.toString());
|
||||
assertPosition(2, 0, a.getCursorPosition());
|
||||
a.clearSelection();
|
||||
a.moveLinesUp();
|
||||
assertEquals("11\n22\n33\n44", b.toString());
|
||||
assertPosition(1, 0, a.getCursorPosition())
|
||||
}, "test: copy lines down should select lines and place cursor at the selection start":function() {
|
||||
var b = new c("11\n22\n33\n44"), a = new d(new e, b);
|
||||
a.moveCursorTo(1, 1);
|
||||
a.getSelection().selectDown();
|
||||
a.copyLinesDown();
|
||||
assertEquals("11\n22\n33\n22\n33\n44", b.toString());
|
||||
assertPosition(3, 0, a.getCursorPosition());
|
||||
assertPosition(5, 0, a.getSelection().getSelectionAnchor());
|
||||
assertPosition(3, 0, a.getSelection().getSelectionLead())
|
||||
}, "test: copy lines up should select lines and place cursor at the selection start":function() {
|
||||
var b = new c("11\n22\n33\n44"), a = new d(new e, b);
|
||||
a.moveCursorTo(1, 1);
|
||||
a.getSelection().selectDown();
|
||||
a.copyLinesUp();
|
||||
assertEquals("11\n22\n33\n22\n33\n44", b.toString());
|
||||
assertPosition(1, 0, a.getCursorPosition());
|
||||
assertPosition(3, 0, a.getSelection().getSelectionAnchor());
|
||||
assertPosition(1, 0, a.getSelection().getSelectionLead())
|
||||
}, "test: input a tab with soft tab should convert it to spaces":function() {
|
||||
var b = new c(""), a = new d(new e, b);
|
||||
b.setTabSize(2);
|
||||
b.setUseSoftTabs(true);
|
||||
a.onTextInput("\t");
|
||||
assertEquals(" ", b.toString());
|
||||
b.setTabSize(5);
|
||||
a.onTextInput("\t");
|
||||
assertEquals(" ", b.toString())
|
||||
}, "test: input tab without soft tabs should keep the tab character":function() {
|
||||
var b = new c(""), a = new d(new e, b);
|
||||
b.setUseSoftTabs(false);
|
||||
a.onTextInput("\t");
|
||||
assertEquals("\t", b.toString())
|
||||
}})
|
||||
});
|
||||
require("../../../support/paths");
|
||||
var dom = require("jsdom/level2/html").dom.level2.html, browser = require("jsdom/browser/index").windowAugmentation(dom);
|
||||
global.document = browser.document;
|
||||
global.window = browser.window;
|
||||
global.self = browser.self;
|
||||
global.navigator = browser.navigator;
|
||||
global.location = browser.location;
|
||||
var Document = require("../document"), Editor = require("../editor"), JavaScriptMode = require("../mode/javascript"), MockRenderer = require("./mockrenderer"), assert = require("./assertions"), Test = {"test: delete line from the middle":function() {
|
||||
var b = new Document("a\nb\nc\nd"), a = new Editor(new MockRenderer, b);
|
||||
a.moveCursorTo(1, 1);
|
||||
a.removeLines();
|
||||
assert.equal(b.toString(), "a\nc\nd");
|
||||
assert.position(a.getCursorPosition(), 1, 0);
|
||||
a.removeLines();
|
||||
assert.equal(b.toString(), "a\nd");
|
||||
assert.position(a.getCursorPosition(), 1, 0);
|
||||
a.removeLines();
|
||||
assert.equal(b.toString(), "a\n");
|
||||
assert.position(a.getCursorPosition(), 1, 0);
|
||||
a.removeLines();
|
||||
assert.equal(b.toString(), "a\n");
|
||||
assert.position(a.getCursorPosition(), 1, 0)
|
||||
}, "test: delete multiple selected lines":function() {
|
||||
var b = new Document("a\nb\nc\nd"), a = new Editor(new MockRenderer, b);
|
||||
a.moveCursorTo(1, 1);
|
||||
a.getSelection().selectDown();
|
||||
a.removeLines();
|
||||
assert.equal(b.toString(), "a\nd");
|
||||
assert.position(a.getCursorPosition(), 1, 0)
|
||||
}, "test: delete first line":function() {
|
||||
var b = new Document("a\nb\nc"), a = new Editor(new MockRenderer, b);
|
||||
a.removeLines();
|
||||
assert.equal(b.toString(), "b\nc");
|
||||
assert.position(a.getCursorPosition(), 0, 0)
|
||||
}, "test: delete last":function() {
|
||||
var b = new Document("a\nb\nc"), a = new Editor(new MockRenderer, b);
|
||||
a.moveCursorTo(2, 1);
|
||||
a.removeLines();
|
||||
assert.equal(b.toString(), "a\nb\n");
|
||||
assert.position(a.getCursorPosition(), 2, 0)
|
||||
}, "__test: indent block":function() {
|
||||
var b = new Document("a12345\nb12345\nc12345"), a = new Editor(new MockRenderer, b);
|
||||
a.moveCursorTo(1, 3);
|
||||
a.getSelection().selectDown();
|
||||
a.blockIndent(" ");
|
||||
assert.equal("a12345\n b12345\n c12345", b.toString());
|
||||
assert.position(a.getCursorPosition(), 2, 7);
|
||||
b = a.getSelectionRange();
|
||||
assert.position(b.start, 1, 7);
|
||||
assert.position(b.end, 2, 7)
|
||||
}, "__test: outdent block":function() {
|
||||
var b = new Document(" a12345\n b12345\n c12345"), a = new Editor(new MockRenderer, b);
|
||||
a.moveCursorTo(0, 3);
|
||||
a.getSelection().selectDown();
|
||||
a.getSelection().selectDown();
|
||||
a.blockOutdent(" ");
|
||||
assert.equal(b.toString(), " a12345\nb12345\n c12345");
|
||||
assert.position(a.getCursorPosition(), 2, 0);
|
||||
var c = a.getSelectionRange();
|
||||
assert.position(c.start, 0, 1);
|
||||
assert.position(c.end, 2, 1);
|
||||
a.blockOutdent(" ");
|
||||
assert.equal(b.toString(), "a12345\nb12345\nc12345");
|
||||
c = a.getSelectionRange();
|
||||
assert.position(c.start, 0, 1);
|
||||
assert.position(c.end, 2, 1)
|
||||
}, "test: outent without a selection should update cursor":function() {
|
||||
var b = new Document(" 12"), a = new Editor(new MockRenderer, b);
|
||||
a.moveCursorTo(0, 3);
|
||||
a.blockOutdent(" ");
|
||||
assert.equal(b.toString(), " 12");
|
||||
assert.position(a.getCursorPosition(), 0, 0)
|
||||
}, "test: comment lines should perserve selection":function() {
|
||||
var b = new Document(" abc\ncde", new JavaScriptMode), a = new Editor(new MockRenderer, b);
|
||||
a.moveCursorTo(0, 2);
|
||||
a.getSelection().selectDown();
|
||||
a.toggleCommentLines();
|
||||
assert.equal("// abc\n//cde", b.toString());
|
||||
b = a.getSelectionRange();
|
||||
assert.position(b.start, 0, 4);
|
||||
assert.position(b.end, 1, 4)
|
||||
}, "test: uncomment lines should perserve selection":function() {
|
||||
var b = new Document("// abc\n//cde", new JavaScriptMode), a = new Editor(new MockRenderer, b);
|
||||
a.moveCursorTo(0, 1);
|
||||
a.getSelection().selectDown();
|
||||
a.getSelection().selectRight();
|
||||
a.getSelection().selectRight();
|
||||
a.toggleCommentLines();
|
||||
assert.equal(" abc\ncde", b.toString());
|
||||
assert.range(a.getSelectionRange(), 0, 0, 1, 1)
|
||||
}, "test: comment lines - if the selection end is at the line start it should stay there":function() {
|
||||
var b = new Document("abc\ncde", new JavaScriptMode);
|
||||
b = new Editor(new MockRenderer, b);
|
||||
b.moveCursorTo(0, 0);
|
||||
b.getSelection().selectDown();
|
||||
b.toggleCommentLines();
|
||||
assert.range(b.getSelectionRange(), 0, 2, 1, 0);
|
||||
b = new Document("abc\ncde", new JavaScriptMode);
|
||||
b = new Editor(new MockRenderer, b);
|
||||
b.moveCursorTo(1, 0);
|
||||
b.getSelection().selectUp();
|
||||
b.toggleCommentLines();
|
||||
assert.range(b.getSelectionRange(), 0, 2, 1, 0)
|
||||
}, "test: move lines down should select moved lines":function() {
|
||||
var b = new Document("11\n22\n33\n44"), a = new Editor(new MockRenderer, b);
|
||||
a.moveCursorTo(0, 1);
|
||||
a.getSelection().selectDown();
|
||||
a.moveLinesDown();
|
||||
assert.equal("33\n11\n22\n44", b.toString());
|
||||
assert.position(a.getCursorPosition(), 1, 0);
|
||||
assert.position(a.getSelection().getSelectionAnchor(), 3, 0);
|
||||
assert.position(a.getSelection().getSelectionLead(), 1, 0);
|
||||
a.moveLinesDown();
|
||||
assert.equal("33\n44\n11\n22", b.toString());
|
||||
assert.position(a.getCursorPosition(), 2, 0);
|
||||
assert.position(a.getSelection().getSelectionAnchor(), 3, 2);
|
||||
assert.position(a.getSelection().getSelectionLead(), 2, 0);
|
||||
a.moveLinesDown();
|
||||
assert.equal("33\n44\n11\n22", b.toString());
|
||||
assert.position(a.getCursorPosition(), 2, 0);
|
||||
assert.position(a.getSelection().getSelectionAnchor(), 3, 2);
|
||||
assert.position(a.getSelection().getSelectionLead(), 2, 0)
|
||||
}, "__test: move lines up should select moved lines":function() {
|
||||
var b = new Document("11\n22\n33\n44"), a = new Editor(new MockRenderer, b);
|
||||
a.moveCursorTo(2, 1);
|
||||
a.getSelection().selectDown();
|
||||
a.moveLinesUp();
|
||||
assert.equal(b.toString(), "11\n33\n44\n22");
|
||||
assert.position(a.getCursorPosition(), 1, 0);
|
||||
assert.position(a.getSelection().getSelectionAnchor(), 3, 0);
|
||||
assert.position(a.getSelection().getSelectionLead(), 1, 0);
|
||||
a.moveLinesUp();
|
||||
assert.equal(b.toString(), "33\n44\n11\n22");
|
||||
assert.position(a.getCursorPosition(), 0, 0);
|
||||
assert.position(a.getSelection().getSelectionAnchor(), 2, 0);
|
||||
assert.position(a.getSelection().getSelectionLead(), 0, 0)
|
||||
}, "test: move line without active selection should move cursor to start of the moved line":function() {
|
||||
var b = new Document("11\n22\n33\n44"), a = new Editor(new MockRenderer, b);
|
||||
a.moveCursorTo(1, 1);
|
||||
a.clearSelection();
|
||||
a.moveLinesDown();
|
||||
assert.equal("11\n33\n22\n44", b.toString());
|
||||
assert.position(a.getCursorPosition(), 2, 0);
|
||||
a.clearSelection();
|
||||
a.moveLinesUp();
|
||||
assert.equal("11\n22\n33\n44", b.toString());
|
||||
assert.position(a.getCursorPosition(), 1, 0)
|
||||
}, "test: copy lines down should select lines and place cursor at the selection start":function() {
|
||||
var b = new Document("11\n22\n33\n44"), a = new Editor(new MockRenderer, b);
|
||||
a.moveCursorTo(1, 1);
|
||||
a.getSelection().selectDown();
|
||||
a.copyLinesDown();
|
||||
assert.equal("11\n22\n33\n22\n33\n44", b.toString());
|
||||
assert.position(a.getCursorPosition(), 3, 0);
|
||||
assert.position(a.getSelection().getSelectionAnchor(), 5, 0);
|
||||
assert.position(a.getSelection().getSelectionLead(), 3, 0)
|
||||
}, "test: copy lines up should select lines and place cursor at the selection start":function() {
|
||||
var b = new Document("11\n22\n33\n44"), a = new Editor(new MockRenderer, b);
|
||||
a.moveCursorTo(1, 1);
|
||||
a.getSelection().selectDown();
|
||||
a.copyLinesUp();
|
||||
assert.equal("11\n22\n33\n22\n33\n44", b.toString());
|
||||
assert.position(a.getCursorPosition(), 1, 0);
|
||||
assert.position(a.getSelection().getSelectionAnchor(), 3, 0);
|
||||
assert.position(a.getSelection().getSelectionLead(), 1, 0)
|
||||
}, "test: input a tab with soft tab should convert it to spaces":function() {
|
||||
var b = new Document(""), a = new Editor(new MockRenderer, b);
|
||||
b.setTabSize(2);
|
||||
b.setUseSoftTabs(true);
|
||||
a.onTextInput("\t");
|
||||
assert.equal(b.toString(), " ");
|
||||
b.setTabSize(5);
|
||||
a.onTextInput("\t");
|
||||
assert.equal(b.toString(), " ")
|
||||
}, "test: input tab without soft tabs should keep the tab character":function() {
|
||||
var b = new Document(""), a = new Editor(new MockRenderer, b);
|
||||
b.setUseSoftTabs(false);
|
||||
a.onTextInput("\t");
|
||||
assert.equal(b.toString(), "\t")
|
||||
}};
|
||||
module.exports = require("async/test").testcase(Test);
|
||||
module === require.main && module.exports.exec();
|
||||
|
|
@ -1,27 +1,28 @@
|
|||
/*
|
||||
LGPLv3 <http://www.gnu.org/licenses/lgpl-3.0.txt>
|
||||
*/
|
||||
require.def(["ace/Document", "ace/VirtualRenderer"], function(c, d) {
|
||||
new TestCase("VirtualRendererTest", {"test: screen2text the column should be rounded to the next character edge":function() {
|
||||
var b = document.createElement("div");
|
||||
b.style.left = "0px";
|
||||
b.style.top = "0px";
|
||||
b.style.width = "100px";
|
||||
b.style.height = "100px";
|
||||
document.body.style.margin = "0px";
|
||||
document.body.style.padding = "0px";
|
||||
document.body.appendChild(b);
|
||||
var a = new d(b);
|
||||
a.setDocument(new c("1234"));
|
||||
a.characterWidth = 10;
|
||||
a.lineHeight = 15;
|
||||
assertPosition(0, 0, a.screenToTextCoordinates(0, 0));
|
||||
assertPosition(0, 0, a.screenToTextCoordinates(4, 0));
|
||||
assertPosition(0, 1, a.screenToTextCoordinates(5, 0));
|
||||
assertPosition(0, 1, a.screenToTextCoordinates(9, 0));
|
||||
assertPosition(0, 1, a.screenToTextCoordinates(10, 0));
|
||||
assertPosition(0, 1, a.screenToTextCoordinates(14, 0));
|
||||
assertPosition(0, 2, a.screenToTextCoordinates(15, 0));
|
||||
document.body.removeChild(b)
|
||||
}})
|
||||
});
|
||||
require("../../../support/paths");
|
||||
var Document = "../document", VirtualRenderer = "../virtual_renderer", assert = "../assertions", Test = {"test: screen2text the column should be rounded to the next character edge":function() {
|
||||
var b = document.createElement("div");
|
||||
b.style.left = "0px";
|
||||
b.style.top = "0px";
|
||||
b.style.width = "100px";
|
||||
b.style.height = "100px";
|
||||
document.body.style.margin = "0px";
|
||||
document.body.style.padding = "0px";
|
||||
document.body.appendChild(b);
|
||||
var a = new VirtualRenderer(b);
|
||||
a.setDocument(new Document("1234"));
|
||||
a.characterWidth = 10;
|
||||
a.lineHeight = 15;
|
||||
assert.position(a.screenToTextCoordinates(0, 0), 0, 0);
|
||||
assert.position(a.screenToTextCoordinates(4, 0), 0, 0);
|
||||
assert.position(a.screenToTextCoordinates(5, 0), 0, 1);
|
||||
assert.position(a.screenToTextCoordinates(9, 0), 0, 1);
|
||||
assert.position(a.screenToTextCoordinates(10, 0), 0, 1);
|
||||
assert.position(a.screenToTextCoordinates(14, 0), 0, 1);
|
||||
assert.position(a.screenToTextCoordinates(15, 0), 0, 2);
|
||||
document.body.removeChild(b)
|
||||
}};
|
||||
module.exports = require("async/test").testcase(Test);
|
||||
module === require.main && module.exports.exec();
|
||||
|
|
@ -6,12 +6,12 @@ define(["require", "exports", "module", 'text!ace/css/editor.css!.ace_editor {\n
|
|||
this.container = a;
|
||||
f.addCssClass(this.container, "ace_editor");
|
||||
this.setTheme(b);
|
||||
this.scroller = document.createElement("div");
|
||||
this.scroller.className = "ace_scroller";
|
||||
this.container.appendChild(this.scroller);
|
||||
this.$gutter = document.createElement("div");
|
||||
this.$gutter.className = "ace_gutter";
|
||||
this.container.appendChild(this.$gutter);
|
||||
this.scroller = document.createElement("div");
|
||||
this.scroller.className = "ace_scroller";
|
||||
this.container.appendChild(this.scroller);
|
||||
this.content = document.createElement("div");
|
||||
this.content.style.position = "absolute";
|
||||
this.scroller.appendChild(this.content);
|
||||
|
|
@ -196,7 +196,7 @@ define(["require", "exports", "module", 'text!ace/css/editor.css!.ace_editor {\n
|
|||
this.$updateScrollBar()
|
||||
}else {
|
||||
if(a & this.CHANGE_SCROLL) {
|
||||
a & this.CHANGE_TEXT || a & this.CHANGE_LINES ? this.$textLayer.scrollLines(this.layerConfig) : this.$textLayer.update(this.layerConfig);
|
||||
a & this.CHANGE_TEXT || a & this.CHANGE_LINES ? this.$textLayer.update(this.layerConfig) : this.$textLayer.scrollLines(this.layerConfig);
|
||||
this.showGutter && this.$gutterLayer.update(this.layerConfig);
|
||||
this.$markerLayer.update(this.layerConfig);
|
||||
this.$cursorLayer.update(this.layerConfig);
|
||||
|
|
@ -209,11 +209,6 @@ define(["require", "exports", "module", 'text!ace/css/editor.css!.ace_editor {\n
|
|||
if(a & this.CHANGE_LINES) {
|
||||
this.$updateLines();
|
||||
this.$updateScrollBar()
|
||||
}else {
|
||||
if(a & this.CHANGE_SCROLL) {
|
||||
this.$textLayer.scrollLines(this.layerConfig);
|
||||
this.showGutter && this.$gutterLayer.update(this.layerConfig)
|
||||
}
|
||||
}
|
||||
}a & this.CHANGE_GUTTER && this.showGutter && this.$gutterLayer.update(this.layerConfig);
|
||||
a & this.CHANGE_CURSOR && this.$cursorLayer.update(this.layerConfig);
|
||||
|
|
@ -363,7 +358,7 @@ define(["require", "exports", "module", 'text!ace/css/editor.css!.ace_editor {\n
|
|||
}
|
||||
var c = this;
|
||||
if(!a || typeof a == "string") {
|
||||
a = a || "ace/theme/TextMate";
|
||||
a = a || "ace/theme/textmate";
|
||||
d([a], function(e) {
|
||||
b(e)
|
||||
})
|
||||
|
|
|
|||
|
|
@ -55,3 +55,9 @@ ace/mode/html.js
|
|||
----------------
|
||||
ace/mode/html_highlight_rules.js
|
||||
ace/mode/html.js
|
||||
|
||||
ace/mode/python.js
|
||||
----------------
|
||||
ace/mode/python_highlight_rules.js
|
||||
ace/mode/matching_brace_outdent.js
|
||||
ace/mode/python.js
|
||||
|
|
|
|||
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;
|
||||
(function () {
|
||||
//Change this version number for each release.
|
||||
var version = "0.14.5",
|
||||
var version = "0.14.5+",
|
||||
empty = {}, s,
|
||||
i, defContextName = "_", contextLoads = [],
|
||||
scripts, script, rePkg, src, m, dataMain, cfg = {}, setReadyState,
|
||||
readyRegExp = /^(complete|loaded)$/,
|
||||
commentRegExp = /(\/\*([\s\S]*?)\*\/|\/\/(.*)$)/mg,
|
||||
cjsRequireRegExp = /require\(["']([\w-_\.\/]+)["']\)/g,
|
||||
cjsRequireRegExp = /require\(["']([\w\!\-_\.\/]+)["']\)/g,
|
||||
main,
|
||||
isBrowser = !!(typeof window !== "undefined" && navigator && document),
|
||||
isWebWorker = !isBrowser && typeof importScripts !== "undefined",
|
||||
//PS3 indicates loaded and complete, but need to wait for complete
|
||||
//specifically. Sequence is "loading", "loaded", execution,
|
||||
// then "complete". The UA check is unfortunate, but not sure how
|
||||
//to feature test w/o causing perf issues.
|
||||
readyRegExp = isBrowser && navigator.platform === 'PLAYSTATION 3' ? /^complete$/ : /^(complete|loaded)$/,
|
||||
ostring = Object.prototype.toString,
|
||||
ap = Array.prototype,
|
||||
aps = ap.slice, scrollIntervalId, req, baseElement,
|
||||
|
|
@ -882,12 +886,12 @@ var require, define;
|
|||
}
|
||||
contextName = contextName || s.ctxName;
|
||||
|
||||
var ret, context = s.contexts[contextName];
|
||||
var ret, context = s.contexts[contextName], nameProps;
|
||||
|
||||
//Normalize module name, if it contains . or ..
|
||||
moduleName = req.normalizeName(moduleName, relModuleName, context);
|
||||
nameProps = req.splitPrefix(moduleName, relModuleName, context);
|
||||
|
||||
ret = context.defined[moduleName];
|
||||
ret = context.defined[nameProps.name];
|
||||
if (ret === undefined) {
|
||||
req.onError(new Error("require: module name '" +
|
||||
moduleName +
|
||||
|
|
@ -940,7 +944,7 @@ var require, define;
|
|||
}
|
||||
};
|
||||
|
||||
req.jsExtRegExp = /\.js$/;
|
||||
req.jsExtRegExp = /^\/|:|\?|\.js$/;
|
||||
|
||||
/**
|
||||
* Given a relative module name, like ./something, normalize it to
|
||||
|
|
@ -955,37 +959,44 @@ var require, define;
|
|||
//Adjust any relative paths.
|
||||
var part;
|
||||
if (name.charAt(0) === ".") {
|
||||
if (!baseName) {
|
||||
req.onError(new Error("Cannot normalize module name: " +
|
||||
name +
|
||||
", no relative module name available."));
|
||||
}
|
||||
|
||||
if (context.config.packages[baseName]) {
|
||||
//If the baseName is a package name, then just treat it as one
|
||||
//name to concat the name with.
|
||||
baseName = [baseName];
|
||||
} else {
|
||||
//Convert baseName to array, and lop off the last part,
|
||||
//so that . matches that "directory" and not name of the baseName's
|
||||
//module. For instance, baseName of "one/two/three", maps to
|
||||
//"one/two/three.js", but we want the directory, "one/two" for
|
||||
//this normalization.
|
||||
baseName = baseName.split("/");
|
||||
baseName = baseName.slice(0, baseName.length - 1);
|
||||
}
|
||||
|
||||
name = baseName.concat(name.split("/"));
|
||||
for (i = 0; (part = name[i]); i++) {
|
||||
if (part === ".") {
|
||||
name.splice(i, 1);
|
||||
i -= 1;
|
||||
} else if (part === "..") {
|
||||
name.splice(i - 1, 2);
|
||||
i -= 2;
|
||||
//If have a base name, try to normalize against it,
|
||||
//otherwise, assume it is a top-level require that will
|
||||
//be relative to baseUrl in the end.
|
||||
if (baseName) {
|
||||
if (context.config.packages[baseName]) {
|
||||
//If the baseName is a package name, then just treat it as one
|
||||
//name to concat the name with.
|
||||
baseName = [baseName];
|
||||
} else {
|
||||
//Convert baseName to array, and lop off the last part,
|
||||
//so that . matches that "directory" and not name of the baseName's
|
||||
//module. For instance, baseName of "one/two/three", maps to
|
||||
//"one/two/three.js", but we want the directory, "one/two" for
|
||||
//this normalization.
|
||||
baseName = baseName.split("/");
|
||||
baseName = baseName.slice(0, baseName.length - 1);
|
||||
}
|
||||
|
||||
name = baseName.concat(name.split("/"));
|
||||
for (i = 0; (part = name[i]); i++) {
|
||||
if (part === ".") {
|
||||
name.splice(i, 1);
|
||||
i -= 1;
|
||||
} else if (part === "..") {
|
||||
if (i === 1) {
|
||||
//End of the line. Keep at least one non-dot
|
||||
//path segment at the front so it can be mapped
|
||||
//correctly to disk. Otherwise, there is likely
|
||||
//no path mapping for '..'.
|
||||
break;
|
||||
} else if (i > 1) {
|
||||
name.splice(i - 1, 2);
|
||||
i -= 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
name = name.join("/");
|
||||
}
|
||||
name = name.join("/");
|
||||
}
|
||||
return name;
|
||||
};
|
||||
|
|
@ -1035,7 +1046,7 @@ var require, define;
|
|||
//If a colon is in the URL, it indicates a protocol is used and it is just
|
||||
//an URL to a file, or if it starts with a slash or ends with .js, it is just a plain file.
|
||||
//The slash is important for protocol-less URLs as well as full paths.
|
||||
if (moduleName.indexOf(":") !== -1 || moduleName.charAt(0) === '/' || req.jsExtRegExp.test(moduleName)) {
|
||||
if (req.jsExtRegExp.test(moduleName)) {
|
||||
//Just a plain path, not module name lookup, so just return it.
|
||||
//Add extension if it is included. This is a bit wonky, only non-.js things pass
|
||||
//an extension, this method probably needs to be reworked.
|
||||
|
|
@ -1078,6 +1089,11 @@ var require, define;
|
|||
config.urlArgs) : url;
|
||||
};
|
||||
|
||||
//In async environments, checkLoaded can get called a few times in the same
|
||||
//call stack. Allow only one to do the finishing work. Set to false
|
||||
//for sync environments.
|
||||
req.blockCheckLoaded = true;
|
||||
|
||||
/**
|
||||
* Checks if all modules for a context are loaded, and if so, evaluates the
|
||||
* new ones in right dependency order.
|
||||
|
|
@ -1119,7 +1135,7 @@ var require, define;
|
|||
//by calling a waiting callback that then calls require and then this function
|
||||
//should not proceed. At the end of this function, if there are still things
|
||||
//waiting, then checkLoaded will be called again.
|
||||
context.isCheckLoaded = true;
|
||||
context.isCheckLoaded = req.blockCheckLoaded;
|
||||
|
||||
//Grab waiting and loaded lists here, since it could have changed since
|
||||
//this function was first called.
|
||||
|
|
@ -2477,4 +2493,4 @@ var require, define;
|
|||
}());
|
||||
|
||||
//Target build file for a require.js that has all of require's functionality,
|
||||
//and includes specific plugins: i18n and text.
|
||||
//and includes specific plugins: i18n and text.
|
||||
|
|
|
|||
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) {
|
||||
|
||||
var oop = require("./lib/oop");
|
||||
var MEventEmitter = require("./event_emitter");
|
||||
var oop = require("pilot/oop").oop;
|
||||
var EventEmitter = require("pilot/event_emitter").EventEmitter;
|
||||
|
||||
var BackgroundTokenizer = function(tokenizer, editor) {
|
||||
this.running = false;
|
||||
|
|
@ -82,7 +82,7 @@ var BackgroundTokenizer = function(tokenizer, editor) {
|
|||
|
||||
(function(){
|
||||
|
||||
oop.implement(this, MEventEmitter);
|
||||
oop.implement(this, EventEmitter);
|
||||
|
||||
this.setTokenizer = function(tokenizer) {
|
||||
this.tokenizer = tokenizer;
|
||||
|
|
@ -103,7 +103,7 @@ var BackgroundTokenizer = function(tokenizer, editor) {
|
|||
first: firstRow,
|
||||
last: lastRow
|
||||
};
|
||||
this.$dispatchEvent("update", {data: data});
|
||||
this._dispatchEvent("update", {data: data});
|
||||
};
|
||||
|
||||
this.start = function(startRow) {
|
||||
|
|
@ -164,5 +164,5 @@ var BackgroundTokenizer = function(tokenizer, editor) {
|
|||
|
||||
}).call(BackgroundTokenizer.prototype);
|
||||
|
||||
return BackgroundTokenizer;
|
||||
exports.BackgroundTokenizer = BackgroundTokenizer;
|
||||
});
|
||||
|
|
|
|||
|
|
@ -37,158 +37,211 @@
|
|||
|
||||
define(function(require, exports, module) {
|
||||
|
||||
var PluginManager = require("../plugin_manager");
|
||||
var canon = require("pilot/canon");
|
||||
|
||||
PluginManager.registerCommand("selectall", function(editor, selection) {
|
||||
selection.selectAll();
|
||||
canon.addCommand({
|
||||
name: "selectall",
|
||||
exec: function(env, args, request) { env.selection.selectAll(); }
|
||||
});
|
||||
PluginManager.registerCommand("removeline", function(editor, selection) {
|
||||
editor.removeLines();
|
||||
canon.addCommand({
|
||||
name: "removeline",
|
||||
exec: function(env, args, request) { env.editor.removeLines(); }
|
||||
});
|
||||
PluginManager.registerCommand("gotoline", function(editor, selection) {
|
||||
var line = parseInt(prompt("Enter line number:"));
|
||||
if (!isNaN(line)) {
|
||||
editor.gotoLine(line);
|
||||
canon.addCommand({
|
||||
name: "gotoline",
|
||||
exec: function(env, args, request) {
|
||||
var line = parseInt(prompt("Enter line number:"));
|
||||
if (!isNaN(line)) {
|
||||
env.editor.gotoLine(line);
|
||||
}
|
||||
}
|
||||
});
|
||||
PluginManager.registerCommand("togglecomment", function(editor, selection) {
|
||||
editor.toggleCommentLines();
|
||||
canon.addCommand({
|
||||
name: "togglecomment",
|
||||
exec: function(env, args, request) { env.editor.toggleCommentLines(); }
|
||||
});
|
||||
PluginManager.registerCommand("findnext", function(editor, selection) {
|
||||
editor.findNext();
|
||||
canon.addCommand({
|
||||
name: "findnext",
|
||||
exec: function(env, args, request) { env.editor.findNext(); }
|
||||
});
|
||||
PluginManager.registerCommand("findprevious", function(editor, selection) {
|
||||
editor.findPrevious();
|
||||
canon.addCommand({
|
||||
name: "findprevious",
|
||||
exec: function(env, args, request) { env.editor.findPrevious(); }
|
||||
});
|
||||
PluginManager.registerCommand("find", function(editor, selection) {
|
||||
var needle = prompt("Find:");
|
||||
editor.find(needle);
|
||||
canon.addCommand({
|
||||
name: "find",
|
||||
exec: function(env, args, request) {
|
||||
var needle = prompt("Find:");
|
||||
env.editor.find(needle);
|
||||
}
|
||||
});
|
||||
PluginManager.registerCommand("undo", function(editor, selection) {
|
||||
editor.undo();
|
||||
canon.addCommand({
|
||||
name: "undo",
|
||||
exec: function(env, args, request) { env.editor.undo(); }
|
||||
});
|
||||
PluginManager.registerCommand("redo", function(editor, selection) {
|
||||
editor.redo();
|
||||
canon.addCommand({
|
||||
name: "redo",
|
||||
exec: function(env, args, request) { env.editor.redo(); }
|
||||
});
|
||||
PluginManager.registerCommand("redo", function(editor, selection) {
|
||||
editor.redo();
|
||||
canon.addCommand({
|
||||
name: "redo",
|
||||
exec: function(env, args, request) { env.editor.redo(); }
|
||||
});
|
||||
PluginManager.registerCommand("overwrite", function(editor, selection) {
|
||||
editor.toggleOverwrite();
|
||||
canon.addCommand({
|
||||
name: "overwrite",
|
||||
exec: function(env, args, request) { env.editor.toggleOverwrite(); }
|
||||
});
|
||||
PluginManager.registerCommand("copylinesup", function(editor, selection) {
|
||||
editor.copyLinesUp();
|
||||
canon.addCommand({
|
||||
name: "copylinesup",
|
||||
exec: function(env, args, request) { env.editor.copyLinesUp(); }
|
||||
});
|
||||
PluginManager.registerCommand("movelinesup", function(editor, selection) {
|
||||
editor.moveLinesUp();
|
||||
canon.addCommand({
|
||||
name: "movelinesup",
|
||||
exec: function(env, args, request) { env.editor.moveLinesUp(); }
|
||||
});
|
||||
PluginManager.registerCommand("selecttostart", function(editor, selection) {
|
||||
selection.selectFileStart();
|
||||
canon.addCommand({
|
||||
name: "selecttostart",
|
||||
exec: function(env, args, request) { env.selection.selectFileStart(); }
|
||||
});
|
||||
PluginManager.registerCommand("gotostart", function(editor, selection) {
|
||||
editor.navigateFileStart();
|
||||
canon.addCommand({
|
||||
name: "gotostart",
|
||||
exec: function(env, args, request) { env.editor.navigateFileStart(); }
|
||||
});
|
||||
PluginManager.registerCommand("selectup", function(editor, selection) {
|
||||
selection.selectUp();
|
||||
canon.addCommand({
|
||||
name: "selectup",
|
||||
exec: function(env, args, request) { env.selection.selectUp(); }
|
||||
});
|
||||
PluginManager.registerCommand("golineup", function(editor, selection) {
|
||||
editor.navigateUp();
|
||||
canon.addCommand({
|
||||
name: "golineup",
|
||||
exec: function(env, args, request) { env.editor.navigateUp(); }
|
||||
});
|
||||
PluginManager.registerCommand("copylinesdown", function(editor, selection) {
|
||||
editor.copyLinesDown();
|
||||
canon.addCommand({
|
||||
name: "copylinesdown",
|
||||
exec: function(env, args, request) { env.editor.copyLinesDown(); }
|
||||
});
|
||||
PluginManager.registerCommand("movelinesdown", function(editor, selection) {
|
||||
editor.moveLinesDown();
|
||||
canon.addCommand({
|
||||
name: "movelinesdown",
|
||||
exec: function(env, args, request) { env.editor.moveLinesDown(); }
|
||||
});
|
||||
PluginManager.registerCommand("selecttoend", function(editor, selection) {
|
||||
selection.selectFileEnd();
|
||||
canon.addCommand({
|
||||
name: "selecttoend",
|
||||
exec: function(env, args, request) { env.selection.selectFileEnd(); }
|
||||
});
|
||||
PluginManager.registerCommand("gotoend", function(editor, selection) {
|
||||
editor.navigateFileEnd();
|
||||
canon.addCommand({
|
||||
name: "gotoend",
|
||||
exec: function(env, args, request) { env.editor.navigateFileEnd(); }
|
||||
});
|
||||
PluginManager.registerCommand("selectdown", function(editor, selection) {
|
||||
selection.selectDown();
|
||||
canon.addCommand({
|
||||
name: "selectdown",
|
||||
exec: function(env, args, request) { env.selection.selectDown(); }
|
||||
});
|
||||
PluginManager.registerCommand("godown", function(editor, selection) {
|
||||
editor.navigateDown();
|
||||
canon.addCommand({
|
||||
name: "godown",
|
||||
exec: function(env, args, request) { env.editor.navigateDown(); }
|
||||
});
|
||||
PluginManager.registerCommand("selectwordleft", function(editor, selection) {
|
||||
selection.selectWordLeft();
|
||||
canon.addCommand({
|
||||
name: "selectwordleft",
|
||||
exec: function(env, args, request) { env.selection.selectWordLeft(); }
|
||||
});
|
||||
PluginManager.registerCommand("gotowordleft", function(editor, selection) {
|
||||
editor.navigateWordLeft();
|
||||
canon.addCommand({
|
||||
name: "gotowordleft",
|
||||
exec: function(env, args, request) { env.editor.navigateWordLeft(); }
|
||||
});
|
||||
PluginManager.registerCommand("selecttolinestart", function(editor, selection) {
|
||||
selection.selectLineStart();
|
||||
canon.addCommand({
|
||||
name: "selecttolinestart",
|
||||
exec: function(env, args, request) { env.selection.selectLineStart(); }
|
||||
});
|
||||
PluginManager.registerCommand("gotolinestart", function(editor, selection) {
|
||||
editor.navigateLineStart();
|
||||
canon.addCommand({
|
||||
name: "gotolinestart",
|
||||
exec: function(env, args, request) { env.editor.navigateLineStart(); }
|
||||
});
|
||||
PluginManager.registerCommand("selectleft", function(editor, selection) {
|
||||
selection.selectLeft();
|
||||
canon.addCommand({
|
||||
name: "selectleft",
|
||||
exec: function(env, args, request) { env.selection.selectLeft(); }
|
||||
});
|
||||
PluginManager.registerCommand("gotoleft", function(editor, selection) {
|
||||
editor.navigateLeft();
|
||||
canon.addCommand({
|
||||
name: "gotoleft",
|
||||
exec: function(env, args, request) { env.editor.navigateLeft(); }
|
||||
});
|
||||
PluginManager.registerCommand("selectwordright", function(editor, selection) {
|
||||
selection.selectWordRight();
|
||||
canon.addCommand({
|
||||
name: "selectwordright",
|
||||
exec: function(env, args, request) { env.selection.selectWordRight(); }
|
||||
});
|
||||
PluginManager.registerCommand("gotowordright", function(editor, selection) {
|
||||
editor.navigateWordRight();
|
||||
canon.addCommand({
|
||||
name: "gotowordright",
|
||||
exec: function(env, args, request) { env.editor.navigateWordRight(); }
|
||||
});
|
||||
PluginManager.registerCommand("selecttolineend", function(editor, selection) {
|
||||
selection.selectLineEnd();
|
||||
canon.addCommand({
|
||||
name: "selecttolineend",
|
||||
exec: function(env, args, request) { env.selection.selectLineEnd(); }
|
||||
});
|
||||
PluginManager.registerCommand("gotolineend", function(editor, selection) {
|
||||
editor.navigateLineEnd();
|
||||
canon.addCommand({
|
||||
name: "gotolineend",
|
||||
exec: function(env, args, request) { env.editor.navigateLineEnd(); }
|
||||
});
|
||||
PluginManager.registerCommand("selectright", function(editor, selection) {
|
||||
selection.selectRight();
|
||||
canon.addCommand({
|
||||
name: "selectright",
|
||||
exec: function(env, args, request) { env.selection.selectRight(); }
|
||||
});
|
||||
PluginManager.registerCommand("gotoright", function(editor, selection) {
|
||||
editor.navigateRight();
|
||||
canon.addCommand({
|
||||
name: "gotoright",
|
||||
exec: function(env, args, request) { env.editor.navigateRight(); }
|
||||
});
|
||||
PluginManager.registerCommand("selectpagedown", function(editor, selection) {
|
||||
editor.selectPageDown();
|
||||
canon.addCommand({
|
||||
name: "selectpagedown",
|
||||
exec: function(env, args, request) { env.editor.selectPageDown(); }
|
||||
});
|
||||
PluginManager.registerCommand("pagedown", function(editor, selection) {
|
||||
editor.scrollPageDown();
|
||||
canon.addCommand({
|
||||
name: "pagedown",
|
||||
exec: function(env, args, request) { env.editor.scrollPageDown(); }
|
||||
});
|
||||
PluginManager.registerCommand("gotopagedown", function(editor, selection) {
|
||||
editor.gotoPageDown();
|
||||
canon.addCommand({
|
||||
name: "gotopagedown",
|
||||
exec: function(env, args, request) { env.editor.gotoPageDown(); }
|
||||
});
|
||||
PluginManager.registerCommand("selectpageup", function(editor, selection) {
|
||||
editor.selectPageUp();
|
||||
canon.addCommand({
|
||||
name: "selectpageup",
|
||||
exec: function(env, args, request) { env.editor.selectPageUp(); }
|
||||
});
|
||||
PluginManager.registerCommand("pageup", function(editor, selection) {
|
||||
editor.scrollPageUp();
|
||||
canon.addCommand({
|
||||
name: "pageup",
|
||||
exec: function(env, args, request) { env.editor.scrollPageUp(); }
|
||||
});
|
||||
PluginManager.registerCommand("gotopageup", function(editor, selection) {
|
||||
editor.gotoPageUp();
|
||||
canon.addCommand({
|
||||
name: "gotopageup",
|
||||
exec: function(env, args, request) { env.editor.gotoPageUp(); }
|
||||
});
|
||||
PluginManager.registerCommand("selectlinestart", function(editor, selection) {
|
||||
selection.selectLineStart();
|
||||
canon.addCommand({
|
||||
name: "selectlinestart",
|
||||
exec: function(env, args, request) { env.selection.selectLineStart(); }
|
||||
});
|
||||
PluginManager.registerCommand("gotolinestart", function(editor, selection) {
|
||||
editor.navigateLineStart();
|
||||
canon.addCommand({
|
||||
name: "gotolinestart",
|
||||
exec: function(env, args, request) { env.editor.navigateLineStart(); }
|
||||
});
|
||||
PluginManager.registerCommand("selectlineend", function(editor, selection) {
|
||||
selection.selectLineEnd();
|
||||
canon.addCommand({
|
||||
name: "selectlineend",
|
||||
exec: function(env, args, request) { env.selection.selectLineEnd(); }
|
||||
});
|
||||
PluginManager.registerCommand("gotolineend", function(editor, selection) {
|
||||
editor.navigateLineEnd();
|
||||
canon.addCommand({
|
||||
name: "gotolineend",
|
||||
exec: function(env, args, request) { env.editor.navigateLineEnd(); }
|
||||
});
|
||||
PluginManager.registerCommand("del", function(editor, selection) {
|
||||
editor.removeRight();
|
||||
canon.addCommand({
|
||||
name: "del",
|
||||
exec: function(env, args, request) { env.editor.removeRight(); }
|
||||
});
|
||||
PluginManager.registerCommand("backspace", function(editor, selection) {
|
||||
editor.removeLeft();
|
||||
canon.addCommand({
|
||||
name: "backspace",
|
||||
exec: function(env, args, request) { env.editor.removeLeft(); }
|
||||
});
|
||||
PluginManager.registerCommand("outdent", function(editor, selection) {
|
||||
editor.blockOutdent();
|
||||
canon.addCommand({
|
||||
name: "outdent",
|
||||
exec: function(env, args, request) { env.editor.blockOutdent(); }
|
||||
});
|
||||
PluginManager.registerCommand("indent", function(editor, selection) {
|
||||
editor.indent();
|
||||
canon.addCommand({
|
||||
name: "indent",
|
||||
exec: function(env, args, request) { env.editor.indent(); }
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@
|
|||
|
||||
define(function(require, exports, module) {
|
||||
|
||||
return {
|
||||
exports.bindings = {
|
||||
"selectall": "Command-A",
|
||||
"removeline": "Command-D",
|
||||
"gotoline": "Command-L",
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@
|
|||
|
||||
define(function(require, exports, module) {
|
||||
|
||||
return {
|
||||
exports.bindings = {
|
||||
"selectall": "Ctrl-A",
|
||||
"removeline": "Ctrl-D",
|
||||
"gotoline": "Ctrl-L",
|
||||
|
|
|
|||
|
|
@ -37,17 +37,17 @@
|
|||
|
||||
define(function(require, exports, module) {
|
||||
|
||||
var oop = require("./lib/oop");
|
||||
var lang = require("./lib/lang");
|
||||
var MEventEmitter = require("./event_emitter");
|
||||
var Selection = require("./selection");
|
||||
var TextMode = require("./mode/text");
|
||||
var Range = require("./range");
|
||||
var oop = require("pilot/oop").oop;
|
||||
var lang = require("pilot/lang").lang;
|
||||
var EventEmitter = require("pilot/event_emitter").EventEmitter;
|
||||
var Selection = require("ace/selection").Selection;
|
||||
var TextMode = require("ace/mode/text").Mode;
|
||||
var Range = require("ace/range").Range;
|
||||
|
||||
var Document = function(text, mode) {
|
||||
|
||||
this.modified = true;
|
||||
this.lines = [];
|
||||
this.lines = [""];
|
||||
this.selection = new Selection(this);
|
||||
this.$breakpoints = [];
|
||||
|
||||
|
|
@ -66,7 +66,7 @@ var Document = function(text, mode) {
|
|||
|
||||
(function() {
|
||||
|
||||
oop.implement(this, MEventEmitter);
|
||||
oop.implement(this, EventEmitter);
|
||||
|
||||
this.$undoManager = null;
|
||||
|
||||
|
|
@ -74,13 +74,13 @@ var Document = function(text, mode) {
|
|||
return text.split(/\r\n|\r|\n/);
|
||||
};
|
||||
|
||||
this.setValue = function(text) {
|
||||
var args = [0, this.lines.length];
|
||||
args.push.apply(args, this.$split(text));
|
||||
this.lines.splice.apply(this.lines, args);
|
||||
this.modified = true;
|
||||
this.fireChangeEvent(0);
|
||||
};
|
||||
this.setValue = function(text) {
|
||||
var args = [0, this.lines.length];
|
||||
args.push.apply(args, this.$split(text));
|
||||
this.lines.splice.apply(this.lines, args);
|
||||
this.modified = true;
|
||||
this.fireChangeEvent(0);
|
||||
};
|
||||
|
||||
this.toString = function() {
|
||||
return this.lines.join(this.$getNewLineCharacter());
|
||||
|
|
@ -95,7 +95,7 @@ var Document = function(text, mode) {
|
|||
firstRow: firstRow,
|
||||
lastRow: lastRow
|
||||
};
|
||||
this.$dispatchEvent("change", { data: data});
|
||||
this._dispatchEvent("change", { data: data});
|
||||
};
|
||||
|
||||
this.setUndoManager = function(undoManager) {
|
||||
|
|
@ -154,7 +154,7 @@ var Document = function(text, mode) {
|
|||
|
||||
this.modified = true;
|
||||
this.$tabSize = tabSize;
|
||||
this.$dispatchEvent("changeTabSize");
|
||||
this._dispatchEvent("changeTabSize");
|
||||
};
|
||||
|
||||
this.getTabSize = function() {
|
||||
|
|
@ -170,22 +170,22 @@ var Document = function(text, mode) {
|
|||
for (var i=0; i<rows.length; i++) {
|
||||
this.$breakpoints[rows[i]] = true;
|
||||
}
|
||||
this.$dispatchEvent("changeBreakpoint", {});
|
||||
this._dispatchEvent("changeBreakpoint", {});
|
||||
};
|
||||
|
||||
this.clearBreakpoints = function() {
|
||||
this.$breakpoints = [];
|
||||
this.$dispatchEvent("changeBreakpoint", {});
|
||||
this._dispatchEvent("changeBreakpoint", {});
|
||||
};
|
||||
|
||||
this.setBreakpoint = function(row) {
|
||||
this.$breakpoints[row] = true;
|
||||
this.$dispatchEvent("changeBreakpoint", {});
|
||||
this._dispatchEvent("changeBreakpoint", {});
|
||||
};
|
||||
|
||||
this.clearBreakpoint = function(row) {
|
||||
delete this.$breakpoints[row];
|
||||
this.$dispatchEvent("changeBreakpoint", {});
|
||||
this._dispatchEvent("changeBreakpoint", {});
|
||||
};
|
||||
|
||||
this.$detectNewLine = function(text) {
|
||||
|
|
@ -261,7 +261,7 @@ var Document = function(text, mode) {
|
|||
if (this.$mode === mode) return;
|
||||
|
||||
this.$mode = mode;
|
||||
this.$dispatchEvent("changeMode");
|
||||
this._dispatchEvent("changeMode");
|
||||
};
|
||||
|
||||
this.getMode = function() {
|
||||
|
|
@ -276,7 +276,7 @@ var Document = function(text, mode) {
|
|||
if (this.$scrollTop === scrollTopRow) return;
|
||||
|
||||
this.$scrollTop = scrollTopRow;
|
||||
this.$dispatchEvent("changeScrollTop");
|
||||
this._dispatchEvent("changeScrollTop");
|
||||
};
|
||||
|
||||
this.getScrollTopRow = function() {
|
||||
|
|
@ -748,5 +748,5 @@ var Document = function(text, mode) {
|
|||
|
||||
}).call(Document.prototype);
|
||||
|
||||
return Document;
|
||||
exports.Document = Document;
|
||||
});
|
||||
|
|
|
|||
|
|
@ -37,16 +37,16 @@
|
|||
|
||||
define(function(require, exports, module) {
|
||||
|
||||
var oop = require("./lib/oop");
|
||||
var event = require("./lib/event");
|
||||
var lang = require("./lib/lang");
|
||||
var TextInput = require("./textinput");
|
||||
var KeyBinding = require("./keybinding");
|
||||
var Document = require("./document");
|
||||
var Search = require("./search");
|
||||
var BackgroundTokenizer = require("./background_tokenizer");
|
||||
var Range = require("./range");
|
||||
var MEventEmitter = require("./event_emitter");
|
||||
var oop = require("pilot/oop").oop;
|
||||
var event = require("pilot/event").event;
|
||||
var lang = require("pilot/lang").lang;
|
||||
var TextInput = require("ace/textinput").TextInput;
|
||||
var KeyBinding = require("ace/keybinding").KeyBinding;
|
||||
var Document = require("ace/document").Document;
|
||||
var Search = require("ace/search").Search;
|
||||
var BackgroundTokenizer = require("ace/background_tokenizer").BackgroundTokenizer;
|
||||
var Range = require("ace/range").Range;
|
||||
var EventEmitter = require("pilot/event_emitter").EventEmitter;
|
||||
|
||||
var Editor =function(renderer, doc) {
|
||||
var container = renderer.getContainerElement();
|
||||
|
|
@ -84,7 +84,7 @@ var Editor =function(renderer, doc) {
|
|||
|
||||
(function(){
|
||||
|
||||
oop.implement(this, MEventEmitter);
|
||||
oop.implement(this, EventEmitter);
|
||||
|
||||
this.$forwardEvents = {
|
||||
gutterclick: 1,
|
||||
|
|
@ -301,7 +301,7 @@ var Editor =function(renderer, doc) {
|
|||
|
||||
var pos = this.renderer.screenToTextCoordinates(pageX, pageY);
|
||||
pos.row = Math.max(0, Math.min(pos.row, this.doc.getLength()-1));
|
||||
|
||||
|
||||
if (event.getButton(e) != 0) {
|
||||
if (this.selection.isEmpty()) {
|
||||
this.moveCursorToPosition(pos);
|
||||
|
|
@ -436,7 +436,7 @@ var Editor =function(renderer, doc) {
|
|||
return;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
_self.bgTokenizer.getState(cursor.row, function(lineState) {
|
||||
// multi line insert
|
||||
if (cursor.row !== end.row) {
|
||||
|
|
@ -450,14 +450,14 @@ var Editor =function(renderer, doc) {
|
|||
for (var i = 0; i < line.length; ++i)
|
||||
if (line.charAt(i) == '\t')
|
||||
indent += size;
|
||||
else if (line.charAt(i) == ' ')
|
||||
else if (line.charAt(i) == ' ')
|
||||
indent += 1;
|
||||
else
|
||||
break;
|
||||
if (/[^\s]/.test(line))
|
||||
minIndent = Math.min(indent, minIndent);
|
||||
}
|
||||
|
||||
|
||||
for (var row = cursor.row + 1; row <= end.row; ++row) {
|
||||
var outdent = minIndent;
|
||||
|
||||
|
|
@ -470,7 +470,7 @@ var Editor =function(renderer, doc) {
|
|||
_self.doc.replace(new Range(row, 0, row, line.length), line.substr(i));
|
||||
}
|
||||
end.column += _self.doc.indentRows(
|
||||
new Range(cursor.row + 1, 0, end.row, end.column),
|
||||
new Range(cursor.row + 1, 0, end.row, end.column),
|
||||
lineIndent);
|
||||
} else {
|
||||
if (shouldOutdent) {
|
||||
|
|
@ -494,7 +494,7 @@ var Editor =function(renderer, doc) {
|
|||
this.onCursorChange();
|
||||
this.$blockScrolling = false;
|
||||
|
||||
this.$dispatchEvent("changeOverwrite", {data: overwrite});
|
||||
this._dispatchEvent("changeOverwrite", {data: overwrite});
|
||||
};
|
||||
|
||||
this.getOverwrite = function() {
|
||||
|
|
@ -521,7 +521,7 @@ var Editor =function(renderer, doc) {
|
|||
|
||||
this.$selectionStyle = style;
|
||||
this.onSelectionChange();
|
||||
this.$dispatchEvent("changeSelectionStyle", {data: style});
|
||||
this._dispatchEvent("changeSelectionStyle", {data: style});
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -605,21 +605,21 @@ var Editor =function(renderer, doc) {
|
|||
|
||||
var doc = this.doc,
|
||||
range = this.getSelectionRange();
|
||||
|
||||
|
||||
if (range.start.row < range.end.row ||
|
||||
range.start.column < range.end.column) {
|
||||
var count = doc.indentRows(this.getSelectionRange(), "\t");
|
||||
|
||||
|
||||
this.selection.shiftSelection(count);
|
||||
} else {
|
||||
var indentString;
|
||||
|
||||
|
||||
if (this.doc.getUseSoftTabs()) {
|
||||
var size = doc.getTabSize(),
|
||||
position = this.getCursorPosition(),
|
||||
column = doc.documentToScreenColumn(position.row, position.column),
|
||||
count = (size - column % size);
|
||||
|
||||
|
||||
indentString = lang.stringRepeat(" ", count);
|
||||
} else
|
||||
indentString = "\t";
|
||||
|
|
@ -633,7 +633,7 @@ var Editor =function(renderer, doc) {
|
|||
|
||||
var selection = this.doc.getSelection(),
|
||||
range = this.doc.outdentRows(selection.getRange());
|
||||
|
||||
|
||||
selection.setSelectionRange(range, selection.isBackwards());
|
||||
this.$updateDesiredColumn();
|
||||
};
|
||||
|
|
@ -797,7 +797,7 @@ var Editor =function(renderer, doc) {
|
|||
var row = this.getPageDownRow(),
|
||||
column = Math.min(this.getCursorPosition().column,
|
||||
this.doc.getLine(row).length);
|
||||
|
||||
|
||||
this.scrollToRow(row);
|
||||
this.getSelection().moveCursorTo(row, column);
|
||||
};
|
||||
|
|
@ -806,7 +806,7 @@ var Editor =function(renderer, doc) {
|
|||
var row = this.getPageUpRow(),
|
||||
column = Math.min(this.getCursorPosition().column,
|
||||
this.doc.getLine(row).length);
|
||||
|
||||
|
||||
this.scrollToRow(row);
|
||||
this.getSelection().moveCursorTo(row, column);
|
||||
};
|
||||
|
|
@ -850,7 +850,7 @@ var Editor =function(renderer, doc) {
|
|||
|
||||
this.gotoLine = function(lineNumber, row) {
|
||||
this.selection.clearSelection();
|
||||
|
||||
|
||||
this.$blockScrolling = true;
|
||||
this.moveCursorTo(lineNumber-1, row || 0);
|
||||
this.$blockScrolling = false;
|
||||
|
|
@ -948,7 +948,7 @@ var Editor =function(renderer, doc) {
|
|||
this.replace = function(replacement, options) {
|
||||
if (options)
|
||||
this.$search.set(options);
|
||||
|
||||
|
||||
var range = this.$search.find(this.doc);
|
||||
this.$tryReplace(range, replacement);
|
||||
if (range !== null)
|
||||
|
|
@ -965,9 +965,9 @@ var Editor =function(renderer, doc) {
|
|||
if (!ranges.length)
|
||||
return;
|
||||
|
||||
this.clearSelection();
|
||||
this.selection.moveCursorTo(0, 0);
|
||||
|
||||
this.clearSelection();
|
||||
this.selection.moveCursorTo(0, 0);
|
||||
|
||||
for (var i = ranges.length - 1; i >= 0; --i)
|
||||
this.$tryReplace(ranges[i], replacement);
|
||||
if (ranges[0] !== null)
|
||||
|
|
@ -1041,5 +1041,5 @@ var Editor =function(renderer, doc) {
|
|||
}).call(Editor.prototype);
|
||||
|
||||
|
||||
return Editor;
|
||||
exports.Editor = Editor;
|
||||
});
|
||||
|
|
|
|||
|
|
@ -37,12 +37,12 @@
|
|||
|
||||
define(function(require, exports, module) {
|
||||
|
||||
var core = require("./lib/core");
|
||||
var event = require("./lib/event");
|
||||
var default_mac = require("./conf/keybindings/default_mac");
|
||||
var default_win = require("./conf/keybindings/default_win");
|
||||
var PluginManager = require("./plugin_manager");
|
||||
require("./commands/default_commands");
|
||||
var core = require("pilot/core").core;
|
||||
var event = require("pilot/event").event;
|
||||
var default_mac = require("ace/conf/keybindings/default_mac").bindings;
|
||||
var default_win = require("ace/conf/keybindings/default_win").bindings;
|
||||
var canon = require("pilot/canon");
|
||||
require("ace/commands/default_commands");
|
||||
|
||||
var KeyBinding = function(element, editor, config) {
|
||||
this.setConfig(config);
|
||||
|
|
@ -55,10 +55,9 @@ var KeyBinding = function(element, editor, config) {
|
|||
|
||||
var commandName = (_self.config.reverse[hashId] || {})[(key
|
||||
|| String.fromCharCode(e.keyCode)).toLowerCase()];
|
||||
var command = PluginManager.commands[commandName];
|
||||
|
||||
if (command) {
|
||||
command(editor, editor.getSelection());
|
||||
var success = canon.exec(commandName, {editor: editor});
|
||||
if (success) {
|
||||
return event.stopEvent(e);
|
||||
}
|
||||
});
|
||||
|
|
@ -149,5 +148,5 @@ var KeyBinding = function(element, editor, config) {
|
|||
|
||||
}).call(KeyBinding.prototype);
|
||||
|
||||
return KeyBinding;
|
||||
exports.KeyBinding = KeyBinding;
|
||||
});
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@
|
|||
|
||||
define(function(require, exports, module) {
|
||||
|
||||
var dom = require("../lib/dom");
|
||||
var dom = require("pilot/dom").dom;
|
||||
|
||||
var Cursor = function(parentEl) {
|
||||
this.element = document.createElement("div");
|
||||
|
|
@ -120,7 +120,7 @@ var Cursor = function(parentEl) {
|
|||
this.update = function(config) {
|
||||
if (!this.position)
|
||||
return;
|
||||
|
||||
|
||||
this.config = config;
|
||||
|
||||
var cursorLeft = Math.round(this.position.column * config.characterWidth);
|
||||
|
|
@ -145,5 +145,6 @@ var Cursor = function(parentEl) {
|
|||
|
||||
}).call(Cursor.prototype);
|
||||
|
||||
return Cursor;
|
||||
exports.Cursor = Cursor;
|
||||
|
||||
});
|
||||
|
|
|
|||
|
|
@ -81,5 +81,6 @@ var Gutter = function(parentEl) {
|
|||
|
||||
}).call(Gutter.prototype);
|
||||
|
||||
return Gutter;
|
||||
exports.Gutter = Gutter;
|
||||
|
||||
});
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@
|
|||
|
||||
define(function(require, exports, module) {
|
||||
|
||||
var Range = require("../range");
|
||||
var Range = require("ace/range").Range;
|
||||
|
||||
var Marker = function(parentEl) {
|
||||
this.element = document.createElement("div");
|
||||
|
|
@ -181,5 +181,6 @@ var Marker = function(parentEl) {
|
|||
|
||||
}).call(Marker.prototype);
|
||||
|
||||
return Marker;
|
||||
exports.Marker = Marker;
|
||||
|
||||
});
|
||||
|
|
|
|||
|
|
@ -37,9 +37,9 @@
|
|||
|
||||
define(function(require, exports, module) {
|
||||
|
||||
var oop = require("../lib/oop");
|
||||
var dom = require("../lib/dom");
|
||||
var MEventEmitter = require("../event_emitter");
|
||||
var oop = require("pilot/oop").oop;
|
||||
var dom = require("pilot/dom").dom;
|
||||
var EventEmitter = require("pilot/event_emitter").EventEmitter;
|
||||
|
||||
var Text = function(parentEl) {
|
||||
this.element = document.createElement("div");
|
||||
|
|
@ -52,7 +52,7 @@ var Text = function(parentEl) {
|
|||
|
||||
(function() {
|
||||
|
||||
oop.implement(this, MEventEmitter);
|
||||
oop.implement(this, EventEmitter);
|
||||
|
||||
this.EOF_CHAR = "¶";
|
||||
this.EOL_CHAR = "¬";
|
||||
|
|
@ -77,7 +77,7 @@ var Text = function(parentEl) {
|
|||
var size = self.$measureSizes();
|
||||
if (self.$characterSize.width !== size.width || self.$characterSize.height !== size.height) {
|
||||
self.$characterSize = size;
|
||||
self.$dispatchEvent("changeCharaterSize", {data: size});
|
||||
self._dispatchEvent("changeCharaterSize", {data: size});
|
||||
}
|
||||
}, 500);
|
||||
};
|
||||
|
|
@ -155,7 +155,7 @@ var Text = function(parentEl) {
|
|||
this.tokenizer.getTokens(first, last, function(tokens) {
|
||||
for ( var i = first; i <= last; i++) {
|
||||
var lineElement = lineElements[i - layerConfig.firstRow];
|
||||
if (!lineElement)
|
||||
if (!lineElement)
|
||||
continue;
|
||||
|
||||
var html = [];
|
||||
|
|
@ -299,5 +299,6 @@ var Text = function(parentEl) {
|
|||
|
||||
}).call(Text.prototype);
|
||||
|
||||
return Text;
|
||||
exports.Text = Text;
|
||||
|
||||
});
|
||||
|
|
|
|||
|
|
@ -37,17 +37,17 @@
|
|||
|
||||
define(function(require, exports, module) {
|
||||
|
||||
var oop = require("../lib/oop");
|
||||
var TextMode = require("./text");
|
||||
var Tokenizer = require("../tokenizer");
|
||||
var CssHighlightRules = require("./css_highlight_rules");
|
||||
var MatchingBraceOutdent = require("./matching_brace_outdent");
|
||||
var oop = require("pilot/oop").oop;
|
||||
var TextMode = require("ace/mode/text").Mode;
|
||||
var Tokenizer = require("ace/tokenizer").Tokenizer;
|
||||
var CssHighlightRules = require("ace/mode/css_highlight_rules").CssHighlightRules;
|
||||
var MatchingBraceOutdent = require("ace/mode/matching_brace_outdent").MatchingBraceOutdent;
|
||||
|
||||
var Css = function() {
|
||||
var Mode = function() {
|
||||
this.$tokenizer = new Tokenizer(new CssHighlightRules().getRules());
|
||||
this.$outdent = new MatchingBraceOutdent();
|
||||
};
|
||||
oop.inherits(Css, TextMode);
|
||||
oop.inherits(Mode, TextMode);
|
||||
|
||||
(function() {
|
||||
|
||||
|
|
@ -76,7 +76,8 @@ oop.inherits(Css, TextMode);
|
|||
return this.$outdent.autoOutdent(doc, row);
|
||||
};
|
||||
|
||||
}).call(Css.prototype);
|
||||
}).call(Mode.prototype);
|
||||
|
||||
return Css;
|
||||
});
|
||||
exports.Mode = Mode;
|
||||
|
||||
});
|
||||
|
|
|
|||
|
|
@ -37,9 +37,9 @@
|
|||
|
||||
define(function(require, exports, module) {
|
||||
|
||||
var oop = require("../lib/oop");
|
||||
var lang = require("../lib/lang");
|
||||
var TextHighlightRules = require("./text_highlight_rules");
|
||||
var oop = require("pilot/oop").oop;
|
||||
var lang = require("pilot/lang").lang;
|
||||
var TextHighlightRules = require("ace/mode/text_highlight_rules").TextHighlightRules;
|
||||
|
||||
var CssHighlightRules = function() {
|
||||
|
||||
|
|
@ -229,5 +229,6 @@ var CssHighlightRules = function() {
|
|||
|
||||
oop.inherits(CssHighlightRules, TextHighlightRules);
|
||||
|
||||
return CssHighlightRules;
|
||||
exports.CssHighlightRules = CssHighlightRules;
|
||||
|
||||
});
|
||||
|
|
|
|||
|
|
@ -37,8 +37,8 @@
|
|||
|
||||
define(function(require, exports, module) {
|
||||
|
||||
var oop = require("../lib/oop");
|
||||
var TextHighlightRules = require("./text_highlight_rules");
|
||||
var oop = require("pilot/oop").oop;
|
||||
var TextHighlightRules = require("ace/mode/text_highlight_rules").TextHighlightRules;
|
||||
|
||||
var DocCommentHighlightRules = function() {
|
||||
|
||||
|
|
@ -77,5 +77,6 @@ oop.inherits(DocCommentHighlightRules, TextHighlightRules);
|
|||
|
||||
}).call(DocCommentHighlightRules.prototype);
|
||||
|
||||
return DocCommentHighlightRules;
|
||||
});
|
||||
exports.DocCommentHighlightRules = DocCommentHighlightRules;
|
||||
|
||||
});
|
||||
|
|
|
|||
|
|
@ -37,20 +37,20 @@
|
|||
|
||||
define(function(require, exports, module) {
|
||||
|
||||
var oop = require("../lib/oop");
|
||||
var TextMode = require("./text");
|
||||
var JavaScriptMode = require("./javascript");
|
||||
var CssMode = require("./css");
|
||||
var Tokenizer = require("../tokenizer");
|
||||
var HtmlHighlightRules = require("./html_highlight_rules");
|
||||
var oop = require("pilot/oop").oop;
|
||||
var TextMode = require("ace/mode/text").Mode;
|
||||
var JavaScriptMode = require("ace/mode/javascript").Mode;
|
||||
var CssMode = require("ace/mode/css").Mode;
|
||||
var Tokenizer = require("ace/tokenizer").Tokenizer;
|
||||
var HtmlHighlightRules = require("ace/mode/html_highlight_rules").HtmlHighlightRules;
|
||||
|
||||
var Html = function() {
|
||||
var Mode = function() {
|
||||
this.$tokenizer = new Tokenizer(new HtmlHighlightRules().getRules());
|
||||
|
||||
this.$js = new JavaScriptMode();
|
||||
this.$css = new CssMode();
|
||||
};
|
||||
oop.inherits(Html, TextMode);
|
||||
oop.inherits(Mode, TextMode);
|
||||
|
||||
(function() {
|
||||
|
||||
|
|
@ -95,7 +95,7 @@ oop.inherits(Html, TextMode);
|
|||
return defaultHandler ? defaultHandler() : undefined;
|
||||
};
|
||||
|
||||
}).call(Html.prototype);
|
||||
}).call(Mode.prototype);
|
||||
|
||||
return Html;
|
||||
exports.Mode = Mode;
|
||||
});
|
||||
|
|
|
|||
|
|
@ -37,10 +37,10 @@
|
|||
|
||||
define(function(require, exports, module) {
|
||||
|
||||
var oop = require("../lib/oop");
|
||||
var CssHighlightRules = require("./css_highlight_rules");
|
||||
var JavaScriptHighlightRules = require("./javascript_highlight_rules");
|
||||
var TextHighlightRules = require("./text_highlight_rules");
|
||||
var oop = require("pilot/oop").oop;
|
||||
var CssHighlightRules = require("ace/mode/css_highlight_rules").CssHighlightRules;
|
||||
var JavaScriptHighlightRules = require("ace/mode/javascript_highlight_rules").JavaScriptHighlightRules;
|
||||
var TextHighlightRules = require("ace/mode/text_highlight_rules").TextHighlightRules;
|
||||
|
||||
var HtmlHighlightRules = function() {
|
||||
|
||||
|
|
@ -178,5 +178,5 @@ var HtmlHighlightRules = function() {
|
|||
|
||||
oop.inherits(HtmlHighlightRules, TextHighlightRules);
|
||||
|
||||
return HtmlHighlightRules;
|
||||
exports.HtmlHighlightRules = HtmlHighlightRules;
|
||||
});
|
||||
|
|
|
|||
|
|
@ -37,18 +37,18 @@
|
|||
|
||||
define(function(require, exports, module) {
|
||||
|
||||
var oop = require("../lib/oop");
|
||||
var TextMode = require("./text");
|
||||
var Tokenizer = require("../tokenizer");
|
||||
var JavaScriptHighlightRules = require("./javascript_highlight_rules");
|
||||
var MatchingBraceOutdent = require("./matching_brace_outdent");
|
||||
var Range = require("../range");
|
||||
var oop = require("pilot/oop").oop;
|
||||
var TextMode = require("ace/mode/text").Mode;
|
||||
var Tokenizer = require("ace/tokenizer").Tokenizer;
|
||||
var JavaScriptHighlightRules = require("ace/mode/javascript_highlight_rules").JavaScriptHighlightRules;
|
||||
var MatchingBraceOutdent = require("ace/mode/matching_brace_outdent").MatchingBraceOutdent;
|
||||
var Range = require("ace/range").Range;
|
||||
|
||||
var JavaScript = function() {
|
||||
var Mode = function() {
|
||||
this.$tokenizer = new Tokenizer(new JavaScriptHighlightRules().getRules());
|
||||
this.$outdent = new MatchingBraceOutdent();
|
||||
};
|
||||
oop.inherits(JavaScript, TextMode);
|
||||
oop.inherits(Mode, TextMode);
|
||||
|
||||
(function() {
|
||||
|
||||
|
|
@ -107,12 +107,7 @@ oop.inherits(JavaScript, TextMode);
|
|||
indent += " ";
|
||||
}
|
||||
indent += "* ";
|
||||
}{
|
||||
if (match[1]) {
|
||||
indent += " ";
|
||||
}
|
||||
indent += "* ";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return indent;
|
||||
|
|
@ -126,7 +121,7 @@ oop.inherits(JavaScript, TextMode);
|
|||
return this.$outdent.autoOutdent(doc, row);
|
||||
};
|
||||
|
||||
}).call(JavaScript.prototype);
|
||||
}).call(Mode.prototype);
|
||||
|
||||
return JavaScript;
|
||||
exports.Mode = Mode;
|
||||
});
|
||||
|
|
|
|||
|
|
@ -37,10 +37,10 @@
|
|||
|
||||
define(function(require, exports, module) {
|
||||
|
||||
var oop = require("../lib/oop");
|
||||
var lang = require("../lib/lang");
|
||||
var DocCommentHighlightRules = require("./doc_comment_highlight_rules");
|
||||
var TextHighlightRules = require("./text_highlight_rules");
|
||||
var oop = require("pilot/oop").oop;
|
||||
var lang = require("pilot/lang").lang;
|
||||
var DocCommentHighlightRules = require("ace/mode/doc_comment_highlight_rules").DocCommentHighlightRules;
|
||||
var TextHighlightRules = require("ace/mode/text_highlight_rules").TextHighlightRules;
|
||||
|
||||
JavaScriptHighlightRules = function() {
|
||||
|
||||
|
|
@ -159,5 +159,5 @@ JavaScriptHighlightRules = function() {
|
|||
|
||||
oop.inherits(JavaScriptHighlightRules, TextHighlightRules);
|
||||
|
||||
return JavaScriptHighlightRules;
|
||||
});
|
||||
exports.JavaScriptHighlightRules = JavaScriptHighlightRules;
|
||||
});
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@
|
|||
|
||||
define(function(require, exports, module) {
|
||||
|
||||
var Range = require("../range");
|
||||
var Range = require("ace/range").Range;
|
||||
|
||||
var MatchingBraceOutdent = function() {};
|
||||
|
||||
|
|
@ -78,5 +78,5 @@ var MatchingBraceOutdent = function() {};
|
|||
|
||||
}).call(MatchingBraceOutdent.prototype);
|
||||
|
||||
return MatchingBraceOutdent;
|
||||
exports.MatchingBraceOutdent = MatchingBraceOutdent;
|
||||
});
|
||||
|
|
|
|||
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) {
|
||||
|
||||
var Tokenizer = require("../tokenizer");
|
||||
var TextHighlightRules = require("./text_highlight_rules");
|
||||
var Tokenizer = require("ace/tokenizer").Tokenizer;
|
||||
var TextHighlightRules = require("ace/mode/text_highlight_rules").TextHighlightRules;
|
||||
|
||||
var Text = function() {
|
||||
var Mode = function() {
|
||||
this.$tokenizer = new Tokenizer(new TextHighlightRules().getRules());
|
||||
};
|
||||
|
||||
|
|
@ -74,7 +74,7 @@ var Text = function() {
|
|||
return "";
|
||||
};
|
||||
|
||||
}).call(Text.prototype);
|
||||
}).call(Mode.prototype);
|
||||
|
||||
return Text;
|
||||
});
|
||||
exports.Mode = Mode;
|
||||
});
|
||||
|
|
|
|||
|
|
@ -73,5 +73,5 @@ var TextHighlightRules = function() {
|
|||
|
||||
}).call(TextHighlightRules.prototype);
|
||||
|
||||
return TextHighlightRules;
|
||||
});
|
||||
exports.TextHighlightRules = TextHighlightRules;
|
||||
});
|
||||
|
|
|
|||
|
|
@ -37,16 +37,16 @@
|
|||
|
||||
define(function(require, exports, module) {
|
||||
|
||||
var oop = require("../lib/oop");
|
||||
var TextMode = require("./text");
|
||||
var Tokenizer = require("../tokenizer");
|
||||
var XmlHighlightRules = require("./xml_highlight_rules");
|
||||
var oop = require("pilot/oop").oop;
|
||||
var TextMode = require("ace/mode/text").Mode;
|
||||
var Tokenizer = require("ace/tokenizer").Tokenizer;
|
||||
var XmlHighlightRules = require("ace/mode/xml_highlight_rules").XmlHighlightRules;
|
||||
|
||||
var Xml = function() {
|
||||
var Mode = function() {
|
||||
this.$tokenizer = new Tokenizer(new XmlHighlightRules().getRules());
|
||||
};
|
||||
|
||||
oop.inherits(Xml, TextMode);
|
||||
oop.inherits(Mode, TextMode);
|
||||
|
||||
(function() {
|
||||
|
||||
|
|
@ -54,7 +54,7 @@ oop.inherits(Xml, TextMode);
|
|||
return this.$getIndent(line);
|
||||
};
|
||||
|
||||
}).call(Xml.prototype);
|
||||
}).call(Mode.prototype);
|
||||
|
||||
return Xml;
|
||||
});
|
||||
exports.Mode = Mode;
|
||||
});
|
||||
|
|
|
|||
|
|
@ -37,8 +37,8 @@
|
|||
|
||||
define(function(require, exports, module) {
|
||||
|
||||
var oop = require("../lib/oop");
|
||||
var TextHighlightRules = require("./text_highlight_rules");
|
||||
var oop = require("pilot/oop").oop;
|
||||
var TextHighlightRules = require("ace/mode/text_highlight_rules").TextHighlightRules;
|
||||
|
||||
var XmlHighlightRules = function() {
|
||||
|
||||
|
|
@ -114,5 +114,5 @@ var XmlHighlightRules = function() {
|
|||
|
||||
oop.inherits(XmlHighlightRules, TextHighlightRules);
|
||||
|
||||
return XmlHighlightRules;
|
||||
});
|
||||
exports.XmlHighlightRules = XmlHighlightRules;
|
||||
});
|
||||
|
|
|
|||
|
|
@ -152,5 +152,5 @@ Range.fromPoints = function(start, end) {
|
|||
return new Range(start.row, start.column, end.row, end.column);
|
||||
};
|
||||
|
||||
return Range;
|
||||
})
|
||||
exports.Range = Range;
|
||||
});
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@
|
|||
|
||||
define(function(require, exports, module) {
|
||||
|
||||
var event = require("./lib/event")
|
||||
var event = require("pilot/event").event;
|
||||
|
||||
var RenderLoop = function(onRender) {
|
||||
this.onRender = onRender;
|
||||
|
|
@ -62,11 +62,11 @@ var RenderLoop = function(onRender) {
|
|||
})
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
if (window.postMessage) {
|
||||
|
||||
|
||||
this.messageName = "zero-timeout-message";
|
||||
|
||||
|
||||
this.setTimeoutZero = function(callback) {
|
||||
if (!this.attached) {
|
||||
var _self = this;
|
||||
|
|
@ -81,15 +81,15 @@ var RenderLoop = function(onRender) {
|
|||
this.callback = callback;
|
||||
window.postMessage(this.messageName, "*");
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
|
||||
this.setTimeoutZero = function(callback) {
|
||||
setTimeout(callback, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}).call(RenderLoop.prototype);
|
||||
|
||||
return RenderLoop;
|
||||
});
|
||||
exports.RenderLoop = RenderLoop;
|
||||
});
|
||||
|
|
|
|||
|
|
@ -37,11 +37,11 @@
|
|||
|
||||
define(function(require, exports, module) {
|
||||
|
||||
var oop = require("./lib/oop");
|
||||
var lang = require("./lib/lang");
|
||||
var dom = require("./lib/dom");
|
||||
var event = require("./lib/event");
|
||||
var MEventEmitter = require("./event_emitter");
|
||||
var oop = require("pilot/oop").oop;
|
||||
var lang = require("pilot/lang").lang;
|
||||
var dom = require("pilot/dom").dom;
|
||||
var event = require("pilot/event").event;
|
||||
var EventEmitter = require("pilot/event_emitter").EventEmitter;
|
||||
|
||||
var ScrollBar = function(parent) {
|
||||
this.element = document.createElement("div");
|
||||
|
|
@ -59,10 +59,10 @@ var ScrollBar = function(parent) {
|
|||
};
|
||||
|
||||
(function() {
|
||||
oop.implement(this, MEventEmitter);
|
||||
oop.implement(this, EventEmitter);
|
||||
|
||||
this.onScroll = function() {
|
||||
this.$dispatchEvent("scroll", {data: this.element.scrollTop});
|
||||
this._dispatchEvent("scroll", {data: this.element.scrollTop});
|
||||
};
|
||||
|
||||
this.getWidth = function() {
|
||||
|
|
@ -83,5 +83,5 @@ var ScrollBar = function(parent) {
|
|||
|
||||
}).call(ScrollBar.prototype);
|
||||
|
||||
return ScrollBar;
|
||||
exports.ScrollBar = ScrollBar;
|
||||
});
|
||||
|
|
|
|||
|
|
@ -37,9 +37,9 @@
|
|||
|
||||
define(function(require, exports, module) {
|
||||
|
||||
var lang = require("./lib/lang");
|
||||
var oop = require("./lib/oop");
|
||||
var Range = require("./range");
|
||||
var lang = require("pilot/lang").lang;
|
||||
var oop = require("pilot/oop").oop;
|
||||
var Range = require("ace/range").Range;
|
||||
|
||||
var Search = function() {
|
||||
this.$options = {
|
||||
|
|
@ -317,5 +317,5 @@ Search.SELECTION = 2;
|
|||
|
||||
}).call(Search.prototype);
|
||||
|
||||
return Search;
|
||||
exports.Search = Search;
|
||||
});
|
||||
|
|
|
|||
|
|
@ -37,10 +37,10 @@
|
|||
|
||||
define(function(require, exports, module) {
|
||||
|
||||
var oop = require("./lib/oop");
|
||||
var lang = require("./lib/lang");
|
||||
var MEventEmitter = require("./event_emitter");
|
||||
var Range = require("./range");
|
||||
var oop = require("pilot/oop").oop;
|
||||
var lang = require("pilot/lang").lang;
|
||||
var EventEmitter = require("pilot/event_emitter").EventEmitter;
|
||||
var Range = require("ace/range").Range;
|
||||
|
||||
var Selection = function(doc) {
|
||||
this.doc = doc;
|
||||
|
|
@ -54,7 +54,7 @@ var Selection = function(doc) {
|
|||
|
||||
(function() {
|
||||
|
||||
oop.implement(this, MEventEmitter);
|
||||
oop.implement(this, EventEmitter);
|
||||
|
||||
this.isEmpty = function() {
|
||||
return (!this.selectionAnchor ||
|
||||
|
|
@ -79,11 +79,11 @@ var Selection = function(doc) {
|
|||
|
||||
if (!this.selectionAnchor) {
|
||||
this.selectionAnchor = anchor;
|
||||
this.$dispatchEvent("changeSelection", {});
|
||||
this._dispatchEvent("changeSelection", {});
|
||||
}
|
||||
else if (this.selectionAnchor.row !== anchor.row || this.selectionAnchor.column !== anchor.column) {
|
||||
this.selectionAnchor = anchor;
|
||||
this.$dispatchEvent("changeSelection", {});
|
||||
this._dispatchEvent("changeSelection", {});
|
||||
}
|
||||
|
||||
};
|
||||
|
|
@ -142,7 +142,7 @@ var Selection = function(doc) {
|
|||
this.clearSelection = function() {
|
||||
if (this.selectionAnchor) {
|
||||
this.selectionAnchor = null;
|
||||
this.$dispatchEvent("changeSelection", {});
|
||||
this._dispatchEvent("changeSelection", {});
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -181,7 +181,7 @@ var Selection = function(doc) {
|
|||
}
|
||||
|
||||
if (changed)
|
||||
this.$dispatchEvent("changeSelection", {});
|
||||
this._dispatchEvent("changeSelection", {});
|
||||
};
|
||||
|
||||
this.selectTo = function(row, column) {
|
||||
|
|
@ -381,7 +381,7 @@ var Selection = function(doc) {
|
|||
// only dispatch change if the cursor actually changed
|
||||
if (cursor.row !== this.selectionLead.row || cursor.column !== this.selectionLead.column) {
|
||||
this.selectionLead = cursor;
|
||||
this.$dispatchEvent("changeCursor", { data: this.getCursor() });
|
||||
this._dispatchEvent("changeCursor", { data: this.getCursor() });
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -417,5 +417,5 @@ var Selection = function(doc) {
|
|||
|
||||
}).call(Selection.prototype);
|
||||
|
||||
return Selection;
|
||||
exports.Selection = Selection;
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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({
|
||||
paths: {
|
||||
"ace": "../src/ace"
|
||||
|
|
|
|||
|
|
@ -1,10 +1,39 @@
|
|||
/**
|
||||
* Ajax.org Code Editor (ACE)
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* @copyright 2010, Ajax.org Services B.V.
|
||||
* @license LGPLv3 <http://www.gnu.org/licenses/lgpl-3.0.txt>
|
||||
* @author Fabian Jakobs <fabian AT ajax DOT org>
|
||||
*/
|
||||
* 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) {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,39 @@
|
|||
/**
|
||||
* Ajax.org Code Editor (ACE)
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* @copyright 2010, Ajax.org Services B.V.
|
||||
* @license LGPLv3 <http://www.gnu.org/licenses/lgpl-3.0.txt>
|
||||
* @author Fabian Jakobs <fabian AT ajax DOT org>
|
||||
*/
|
||||
* 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("../../../support/paths");
|
||||
|
||||
|
|
@ -30,11 +59,11 @@ var Test = {
|
|||
this.doc2 = new Document(["ghi", "jkl"].join("\n"));
|
||||
this.editor = new Editor(new MockRenderer());
|
||||
},
|
||||
|
||||
|
||||
"test: change document" : function() {
|
||||
this.editor.setDocument(this.doc1);
|
||||
assert.equal(this.editor.getDocument(), this.doc1);
|
||||
|
||||
|
||||
this.editor.setDocument(this.doc2);
|
||||
assert.equal(this.editor.getDocument(), this.doc2);
|
||||
},
|
||||
|
|
@ -134,4 +163,4 @@ var Test = {
|
|||
module.exports = require("async/test").testcase(Test);
|
||||
|
||||
if (module === require.main)
|
||||
module.exports.exec()
|
||||
module.exports.exec()
|
||||
|
|
|
|||
|
|
@ -1,10 +1,39 @@
|
|||
/**
|
||||
* Ajax.org Code Editor (ACE)
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* @copyright 2010, Ajax.org Services B.V.
|
||||
* @license LGPLv3 <http://www.gnu.org/licenses/lgpl-3.0.txt>
|
||||
* @author Fabian Jakobs <fabian AT ajax DOT org>
|
||||
*/
|
||||
* 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("../../../support/paths");
|
||||
|
||||
|
|
|
|||
|
|
@ -1,21 +1,49 @@
|
|||
/**
|
||||
* Ajax.org Code Editor (ACE)
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* @copyright 2010, Ajax.org Services B.V.
|
||||
* @license LGPLv3 <http://www.gnu.org/licenses/lgpl-3.0.txt>
|
||||
* @author Fabian Jakobs <fabian AT ajax DOT org>
|
||||
*/
|
||||
* 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("../../../support/paths");
|
||||
|
||||
var oop = require("../lib/oop");
|
||||
MEventEmitter = require("../event_emitter"),
|
||||
assert = require("./assertions");
|
||||
|
||||
|
||||
|
||||
var EventEmitter = function() {};
|
||||
|
||||
oop.implement(EventEmitter.prototype, MEventEmitter);
|
||||
oop.implement(EventEmitter.prototype, EventEmitter);
|
||||
|
||||
var Test = {
|
||||
"test: dispatch event with no data" : function() {
|
||||
|
|
@ -35,4 +63,4 @@ var Test = {
|
|||
module.exports = require("async/test").testcase(Test)
|
||||
|
||||
if (module === require.main)
|
||||
module.exports.exec()
|
||||
module.exports.exec()
|
||||
|
|
|
|||
|
|
@ -1,10 +1,39 @@
|
|||
/**
|
||||
* Ajax.org Code Editor (ACE)
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* @copyright 2010, Ajax.org Services B.V.
|
||||
* @license LGPLv3 <http://www.gnu.org/licenses/lgpl-3.0.txt>
|
||||
* @author Fabian Jakobs <fabian AT ajax DOT org>
|
||||
*/
|
||||
* 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) {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,22 +1,47 @@
|
|||
/**
|
||||
* Ajax.org Code Editor (ACE)
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* @copyright 2010, Ajax.org Services B.V.
|
||||
* @license LGPLv3 <http://www.gnu.org/licenses/lgpl-3.0.txt>
|
||||
* @author Fabian Jakobs <fabian AT ajax DOT org>
|
||||
*/
|
||||
* 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.def([
|
||||
"ace/Document",
|
||||
"ace/Range",
|
||||
"ace/mode/Css"
|
||||
], function(
|
||||
Document,
|
||||
Range,
|
||||
CssMode
|
||||
) {
|
||||
define(function(require, exports, module) {
|
||||
|
||||
var Document = require("ace/document").Document;
|
||||
var Range = require("ace/range").Range;
|
||||
var Css = require("ace/mode/css").Mode;
|
||||
|
||||
var CssTest = new TestCase("mode.CssTest", {
|
||||
var CssTest = new TestCase("mode.CssTest", {
|
||||
|
||||
setUp : function() {
|
||||
this.mode = new CssMode();
|
||||
|
|
|
|||
|
|
@ -1,16 +1,43 @@
|
|||
/**
|
||||
* Ajax.org Code Editor (ACE)
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* @copyright 2010, Ajax.org Services B.V.
|
||||
* @license LGPLv3 <http://www.gnu.org/licenses/lgpl-3.0.txt>
|
||||
* @author Fabian Jakobs <fabian AT ajax DOT org>
|
||||
*/
|
||||
* 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.def([
|
||||
"ace/mode/Css"
|
||||
], function(
|
||||
CssMode
|
||||
) {
|
||||
define(function(require, exports, module) {
|
||||
|
||||
var Css = require("ace/mode/css").Mode;
|
||||
|
||||
var CssTest = new TestCase("mode.CssTest", {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,20 +1,45 @@
|
|||
/**
|
||||
* Ajax.org Code Editor (ACE)
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* @copyright 2010, Ajax.org Services B.V.
|
||||
* @license LGPLv3 <http://www.gnu.org/licenses/lgpl-3.0.txt>
|
||||
* @author Fabian Jakobs <fabian AT ajax DOT org>
|
||||
*/
|
||||
* 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.def([
|
||||
"ace/Document",
|
||||
"ace/Range",
|
||||
"ace/mode/Html"
|
||||
], function(
|
||||
Document,
|
||||
Range,
|
||||
HtmlMode
|
||||
) {
|
||||
define(function(require, exports, module) {
|
||||
|
||||
var Document = require("ace/document").Document;
|
||||
var Range = require("ace/range").Range;
|
||||
var Html = require("ace/mode/html").Mode;
|
||||
|
||||
var HtmlTest = new TestCase("mode.HtmlTest", {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,16 +1,43 @@
|
|||
/**
|
||||
* Ajax.org Code Editor (ACE)
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* @copyright 2010, Ajax.org Services B.V.
|
||||
* @license LGPLv3 <http://www.gnu.org/licenses/lgpl-3.0.txt>
|
||||
* @author Fabian Jakobs <fabian AT ajax DOT org>
|
||||
*/
|
||||
* 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.def([
|
||||
"ace/mode/Html"
|
||||
], function(
|
||||
HtmlMode
|
||||
) {
|
||||
define(function(require, exports, module) {
|
||||
|
||||
var Html = require("ace/mode/html").Mode;
|
||||
|
||||
var HtmlTest = new TestCase("mode.HtmlTest", {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,22 +1,46 @@
|
|||
/**
|
||||
* Ajax.org Code Editor (ACE)
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* @copyright 2010, Ajax.org Services B.V.
|
||||
* @license LGPLv3 <http://www.gnu.org/licenses/lgpl-3.0.txt>
|
||||
* @author Fabian Jakobs <fabian AT ajax DOT org>
|
||||
*/
|
||||
* 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.def([
|
||||
"ace/Document",
|
||||
"ace/Range",
|
||||
"ace/Tokenizer",
|
||||
"ace/mode/JavaScript"
|
||||
], function(
|
||||
Document,
|
||||
Range,
|
||||
Tokenizer,
|
||||
JavaScriptMode
|
||||
) {
|
||||
define(function(require, exports, module) {
|
||||
|
||||
var Document = require("ace/document").Document;
|
||||
var Range = require("ace/range").Range;
|
||||
var Tokenizer = require("ace/tokenizer").Tokenizer;
|
||||
var JavaScript = require("ace/mode/javascript").Mode;
|
||||
|
||||
var JavaScriptTest = new TestCase("mode.JavaScriptTest", {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,16 +1,43 @@
|
|||
/**
|
||||
* Ajax.org Code Editor (ACE)
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* @copyright 2010, Ajax.org Services B.V.
|
||||
* @license LGPLv3 <http://www.gnu.org/licenses/lgpl-3.0.txt>
|
||||
* @author Fabian Jakobs <fabian AT ajax DOT org>
|
||||
*/
|
||||
* 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.def([
|
||||
"ace/mode/JavaScript"
|
||||
], function(
|
||||
JavaScriptMode
|
||||
) {
|
||||
define(function(require, exports, module) {
|
||||
|
||||
var JavaScript = require("ace/mode/javascript").Mode;
|
||||
|
||||
var JavaScriptTokenizerTest = new TestCase("mode.JavaScriptTokenizerTest", {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,20 +1,45 @@
|
|||
/**
|
||||
* Ajax.org Code Editor (ACE)
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* @copyright 2010, Ajax.org Services B.V.
|
||||
* @license LGPLv3 <http://www.gnu.org/licenses/lgpl-3.0.txt>
|
||||
* @author Fabian Jakobs <fabian AT ajax DOT org>
|
||||
*/
|
||||
* 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.def([
|
||||
"ace/Document",
|
||||
"ace/Range",
|
||||
"ace/mode/Text"
|
||||
], function(
|
||||
Document,
|
||||
Range,
|
||||
TextMode
|
||||
) {
|
||||
define(function(require, exports, module) {
|
||||
|
||||
var Document = require("ace/document").Document;
|
||||
var Range = require("ace/range").Range;
|
||||
var Text = require("ace/mode/text").Mode;
|
||||
|
||||
var TextTest = new TestCase("mode.TextTest", {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,22 +1,46 @@
|
|||
/**
|
||||
* Ajax.org Code Editor (ACE)
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* @copyright 2010, Ajax.org Services B.V.
|
||||
* @license LGPLv3 <http://www.gnu.org/licenses/lgpl-3.0.txt>
|
||||
* @author Fabian Jakobs <fabian AT ajax DOT org>
|
||||
*/
|
||||
* 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.def([
|
||||
"ace/Document",
|
||||
"ace/Range",
|
||||
"ace/Tokenizer",
|
||||
"ace/mode/Xml"
|
||||
], function(
|
||||
Document,
|
||||
Range,
|
||||
Tokenizer,
|
||||
XmlMode
|
||||
) {
|
||||
define(function(require, exports, module) {
|
||||
|
||||
var Document = require("ace/document").Document;
|
||||
var Range = require("ace/range").Range;
|
||||
var Tokenizer = require("ace/tokenizer").Tokenizer;
|
||||
var Xml = require("ace/mode/xml").Mode;
|
||||
|
||||
var XmlTest = new TestCase("mode.XmlTest", {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,16 +1,43 @@
|
|||
/**
|
||||
* Ajax.org Code Editor (ACE)
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* @copyright 2010, Ajax.org Services B.V.
|
||||
* @license LGPLv3 <http://www.gnu.org/licenses/lgpl-3.0.txt>
|
||||
* @author Fabian Jakobs <fabian AT ajax DOT org>
|
||||
*/
|
||||
* 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.def([
|
||||
"ace/mode/Xml"
|
||||
], function(
|
||||
XmlMode
|
||||
) {
|
||||
define(function(require, exports, module) {
|
||||
|
||||
var Xml = require("ace/mode/xml").Mode;
|
||||
|
||||
var XmlTest = new TestCase("mode.XmlTest", {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,39 @@
|
|||
/**
|
||||
* Ajax.org Code Editor (ACE)
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* @copyright 2010, Ajax.org Services B.V.
|
||||
* @license LGPLv3 <http://www.gnu.org/licenses/lgpl-3.0.txt>
|
||||
* @author Fabian Jakobs <fabian AT ajax DOT org>
|
||||
*/
|
||||
* 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("../../../support/paths");
|
||||
|
||||
|
|
@ -132,4 +161,4 @@ var Test = {
|
|||
module.exports = require("async/test").testcase(Test)
|
||||
|
||||
if (module === require.main)
|
||||
module.exports.exec()
|
||||
module.exports.exec()
|
||||
|
|
|
|||
|
|
@ -1,10 +1,39 @@
|
|||
/**
|
||||
* Ajax.org Code Editor (ACE)
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* @copyright 2010, Ajax.org Services B.V.
|
||||
* @license LGPLv3 <http://www.gnu.org/licenses/lgpl-3.0.txt>
|
||||
* @author Fabian Jakobs <fabian AT ajax DOT org>
|
||||
*/
|
||||
* 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("../../../support/paths");
|
||||
|
||||
|
|
@ -121,4 +150,4 @@ var Test = {
|
|||
module.exports = require("async/test").testcase(Test);
|
||||
|
||||
if (module === require.main)
|
||||
module.exports.exec()
|
||||
module.exports.exec()
|
||||
|
|
|
|||
|
|
@ -1,10 +1,39 @@
|
|||
/**
|
||||
* Ajax.org Code Editor (ACE)
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* @copyright 2010, Ajax.org Services B.V.
|
||||
* @license LGPLv3 <http://www.gnu.org/licenses/lgpl-3.0.txt>
|
||||
* @author Fabian Jakobs <fabian AT ajax DOT org>
|
||||
*/
|
||||
* 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("../../../support/paths");
|
||||
|
||||
|
|
@ -318,4 +347,4 @@ var Test = {
|
|||
module.exports = require("async/test").testcase(Test)
|
||||
|
||||
if (module === require.main)
|
||||
module.exports.exec();
|
||||
module.exports.exec();
|
||||
|
|
|
|||
|
|
@ -1,10 +1,39 @@
|
|||
/**
|
||||
* Ajax.org Code Editor (ACE)
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* @copyright 2010, Ajax.org Services B.V.
|
||||
* @license LGPLv3 <http://www.gnu.org/licenses/lgpl-3.0.txt>
|
||||
* @author Fabian Jakobs <fabian AT ajax DOT org>
|
||||
*/
|
||||
* 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("../../../support/paths");
|
||||
|
||||
|
|
@ -264,4 +293,4 @@ var Test = {
|
|||
module.exports = require("async/test").testcase(Test);
|
||||
|
||||
if (module === require.main)
|
||||
module.exports.exec()
|
||||
module.exports.exec()
|
||||
|
|
|
|||
|
|
@ -1,10 +1,39 @@
|
|||
/**
|
||||
* Ajax.org Code Editor (ACE)
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* @copyright 2010, Ajax.org Services B.V.
|
||||
* @license LGPLv3 <http://www.gnu.org/licenses/lgpl-3.0.txt>
|
||||
* @author Fabian Jakobs <fabian AT ajax DOT org>
|
||||
*/
|
||||
* 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("../../../support/paths");
|
||||
|
||||
|
|
@ -18,11 +47,11 @@ global.navigator = browser.navigator;
|
|||
global.location = browser.location;
|
||||
|
||||
var Document = require("../document"),
|
||||
Editor = require("../editor"),
|
||||
JavaScriptMode = require("../mode/javascript"),
|
||||
Editor = require("../editor"),
|
||||
JavaScriptMode = require("../mode/javascript").Mode,
|
||||
MockRenderer = require("./mockrenderer"),
|
||||
assert = require("./assertions");
|
||||
|
||||
|
||||
var Test = {
|
||||
"test: delete line from the middle" : function() {
|
||||
var doc = new Document(["a", "b", "c", "d"].join("\n"));
|
||||
|
|
@ -83,7 +112,7 @@ var Test = {
|
|||
assert.position(editor.getCursorPosition(), 2, 0);
|
||||
},
|
||||
|
||||
"__test: indent block" : function() {
|
||||
"test: indent block" : function() {
|
||||
var doc = new Document(["a12345", "b12345", "c12345"].join("\n"));
|
||||
var editor = new Editor(new MockRenderer(), doc);
|
||||
|
||||
|
|
@ -102,7 +131,7 @@ var Test = {
|
|||
assert.position(range.end, 2, 7);
|
||||
},
|
||||
|
||||
"__test: outdent block" : function() {
|
||||
"test: outdent block" : function() {
|
||||
var doc = new Document([" a12345", " b12345", " c12345"].join("\n"));
|
||||
var editor = new Editor(new MockRenderer(), doc);
|
||||
|
||||
|
|
@ -219,7 +248,7 @@ var Test = {
|
|||
assert.position(editor.getSelection().getSelectionLead(), 2, 0);
|
||||
},
|
||||
|
||||
"__test: move lines up should select moved lines" : function() {
|
||||
"test: move lines up should select moved lines" : function() {
|
||||
var doc = new Document(["11", "22", "33", "44"].join("\n"));
|
||||
var editor = new Editor(new MockRenderer(), doc);
|
||||
|
||||
|
|
@ -317,4 +346,4 @@ var Test = {
|
|||
module.exports = require("async/test").testcase(Test);
|
||||
|
||||
if (module === require.main)
|
||||
module.exports.exec()
|
||||
module.exports.exec()
|
||||
|
|
|
|||
|
|
@ -1,13 +1,42 @@
|
|||
/**
|
||||
* Ajax.org Code Editor (ACE)
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* @copyright 2010, Ajax.org Services B.V.
|
||||
* @license LGPLv3 <http://www.gnu.org/licenses/lgpl-3.0.txt>
|
||||
* @author Fabian Jakobs <fabian AT ajax DOT org>
|
||||
*/
|
||||
|
||||
* 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("../../../support/paths");
|
||||
|
||||
|
||||
var Document = "../document",
|
||||
VirtualRenderer = "../virtual_renderer",
|
||||
assert = "../assertions";
|
||||
|
|
@ -45,4 +74,4 @@ var Test = {
|
|||
module.exports = require("async/test").testcase(Test);
|
||||
|
||||
if (module === require.main)
|
||||
module.exports.exec()
|
||||
module.exports.exec()
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@
|
|||
|
||||
define(function(require, exports, module) {
|
||||
|
||||
var event = require("./lib/event");
|
||||
var event = require("pilot/event").event;
|
||||
|
||||
var TextInput = function(parentNode, host) {
|
||||
|
||||
|
|
@ -146,5 +146,5 @@ var TextInput = function(parentNode, host) {
|
|||
};
|
||||
};
|
||||
|
||||
return TextInput;
|
||||
});
|
||||
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) {
|
||||
|
||||
var dom = require("../lib/dom");
|
||||
var dom = require("pilot/dom").dom;
|
||||
|
||||
var cssText = ".ace-clouds .ace_editor {\
|
||||
border: 2px solid rgb(159, 159, 159);\
|
||||
|
|
@ -150,11 +187,9 @@ var dom = require("../lib/dom");
|
|||
.ace-clouds .ace_xml_pe {\
|
||||
\
|
||||
}";
|
||||
|
||||
|
||||
// import CSS once
|
||||
dom.importCssString(cssText);
|
||||
|
||||
return {
|
||||
cssClass: "ace-clouds"
|
||||
};
|
||||
})
|
||||
|
||||
exports.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) {
|
||||
|
||||
var dom = require("../lib/dom");
|
||||
var dom = require("pilot/dom").dom;
|
||||
|
||||
var cssText = ".ace-clouds-midnight .ace_editor {\
|
||||
border: 2px solid rgb(159, 159, 159);\
|
||||
|
|
@ -151,11 +188,9 @@ background-color:#E92E2E;\
|
|||
.ace-clouds-midnight .ace_xml_pe {\
|
||||
\
|
||||
}";
|
||||
|
||||
|
||||
// import CSS once
|
||||
dom.importCssString(cssText);
|
||||
|
||||
return {
|
||||
cssClass: "ace-clouds-midnight"
|
||||
};
|
||||
})
|
||||
|
||||
exports.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) {
|
||||
|
||||
var dom = require("../lib/dom");
|
||||
|
||||
var dom = require("pilot/dom").dom;
|
||||
|
||||
var cssText = ".ace-cobalt .ace_editor {\
|
||||
border: 2px solid rgb(159, 159, 159);\
|
||||
|
|
@ -153,11 +189,9 @@ color:#0088FF;\
|
|||
.ace-cobalt .ace_xml_pe {\
|
||||
\
|
||||
}";
|
||||
|
||||
|
||||
// import CSS once
|
||||
dom.importCssString(cssText);
|
||||
|
||||
return {
|
||||
cssClass: "ace-cobalt"
|
||||
};
|
||||
})
|
||||
|
||||
exports.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) {
|
||||
|
||||
var dom = require("../lib/dom");
|
||||
var dom = require("pilot/dom").dom;
|
||||
|
||||
var cssText = ".ace-dawn .ace_editor {\
|
||||
border: 2px solid rgb(159, 159, 159);\
|
||||
|
|
@ -156,11 +193,9 @@ color:#5A525F;\
|
|||
.ace-dawn .ace_xml_pe {\
|
||||
\
|
||||
}";
|
||||
|
||||
|
||||
// import CSS once
|
||||
dom.importCssString(cssText);
|
||||
|
||||
return {
|
||||
cssClass: "ace-dawn"
|
||||
};
|
||||
})
|
||||
|
||||
exports.cssClass = "ace-dawn";
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,12 +1,47 @@
|
|||
define(["require", "exports", "module", "text!ace/theme/eclipse.css", "../lib/dom"],
|
||||
function(require, exports, module, cssText) {
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Ajax.org Code Editor (ACE).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ajax.org Services B.V.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Fabian Jakobs <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 dom = require("pilot/dom").dom;
|
||||
var cssText = require("text!ace/theme/eclipse.css");
|
||||
|
||||
var dom = require("../lib/dom");
|
||||
|
||||
// import CSS once
|
||||
dom.importCssString(cssText);
|
||||
|
||||
return {
|
||||
cssClass: "ace-eclipse"
|
||||
};
|
||||
})
|
||||
exports.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) {
|
||||
|
||||
var dom = require("../lib/dom");
|
||||
|
||||
var dom = require("pilot/dom").dom;
|
||||
|
||||
var cssText = ".ace-idle-fingers .ace_editor {\
|
||||
border: 2px solid rgb(159, 159, 159);\
|
||||
|
|
@ -153,11 +189,9 @@ color:#BC9458;\
|
|||
.ace-idle-fingers .ace_xml_pe {\
|
||||
\
|
||||
}";
|
||||
|
||||
|
||||
// import CSS once
|
||||
dom.importCssString(cssText);
|
||||
|
||||
return {
|
||||
cssClass: "ace-idle-fingers"
|
||||
};
|
||||
})
|
||||
|
||||
exports.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) {
|
||||
|
||||
var dom = require("../lib/dom");
|
||||
|
||||
var dom = require("pilot/dom").dom;
|
||||
|
||||
var cssText = ".ace-kr-theme .ace_editor {\
|
||||
border: 2px solid rgb(159, 159, 159);\
|
||||
|
|
@ -153,11 +189,9 @@ color:#706D5B;\
|
|||
.ace-kr-theme .ace_xml_pe {\
|
||||
\
|
||||
}";
|
||||
|
||||
|
||||
// import CSS once
|
||||
dom.importCssString(cssText);
|
||||
|
||||
return {
|
||||
cssClass: "ace-kr-theme"
|
||||
};
|
||||
})
|
||||
|
||||
exports.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) {
|
||||
|
||||
var dom = require("../lib/dom");
|
||||
|
||||
var dom = require("pilot/dom").dom;
|
||||
|
||||
var cssText = ".ace-mono-industrial .ace_editor {\
|
||||
border: 2px solid rgb(159, 159, 159);\
|
||||
|
|
@ -153,11 +189,9 @@ background-color:#151C19;\
|
|||
.ace-mono-industrial .ace_xml_pe {\
|
||||
\
|
||||
}";
|
||||
|
||||
|
||||
// import CSS once
|
||||
dom.importCssString(cssText);
|
||||
|
||||
return {
|
||||
cssClass: "ace-mono-industrial"
|
||||
};
|
||||
})
|
||||
|
||||
exports.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) {
|
||||
|
||||
var dom = require("../lib/dom");
|
||||
|
||||
var dom = require("pilot/dom").dom;
|
||||
|
||||
var cssText = ".ace-monokai .ace_editor {\
|
||||
border: 2px solid rgb(159, 159, 159);\
|
||||
|
|
@ -153,11 +189,9 @@ background-color:#AE81FF;\
|
|||
.ace-monokai .ace_xml_pe {\
|
||||
\
|
||||
}";
|
||||
|
||||
|
||||
// import CSS once
|
||||
dom.importCssString(cssText);
|
||||
|
||||
return {
|
||||
cssClass: "ace-monokai"
|
||||
};
|
||||
})
|
||||
|
||||
exports.cssClass = "ace-monokai";
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,12 +1,47 @@
|
|||
define(["require", "exports", "module", "text!ace/theme/tm.css", "../lib/dom"],
|
||||
function(require, exports, module, cssText) {
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Ajax.org Code Editor (ACE).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ajax.org Services B.V.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Fabian Jakobs <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
|
||||
dom.importCssString(cssText);
|
||||
|
||||
return {
|
||||
cssClass: "ace-tm"
|
||||
};
|
||||
})
|
||||
|
||||
exports.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) {
|
||||
|
||||
var dom = require("../lib/dom");
|
||||
var dom = require("pilot/dom").dom;
|
||||
|
||||
var cssText = ".ace-twilight .ace_editor {\
|
||||
border: 2px solid rgb(159, 159, 159);\
|
||||
|
|
@ -154,11 +191,9 @@ color:#5F5A60;\
|
|||
.ace-twilight .ace_xml_pe {\
|
||||
color:#494949;\
|
||||
}";
|
||||
|
||||
|
||||
// import CSS once
|
||||
dom.importCssString(cssText);
|
||||
|
||||
return {
|
||||
cssClass: "ace-twilight"
|
||||
};
|
||||
})
|
||||
|
||||
exports.cssClass = "ace-twilight";
|
||||
});
|
||||
|
|
|
|||
|
|
@ -128,5 +128,5 @@ var Tokenizer = function(rules) {
|
|||
|
||||
}).call(Tokenizer.prototype);
|
||||
|
||||
return Tokenizer;
|
||||
});
|
||||
exports.Tokenizer = Tokenizer;
|
||||
});
|
||||
|
|
|
|||
|
|
@ -73,5 +73,5 @@ var UndoManager = function() {
|
|||
|
||||
}).call(UndoManager.prototype);
|
||||
|
||||
return UndoManager;
|
||||
});
|
||||
exports.UndoManager = UndoManager;
|
||||
});
|
||||
|
|
|
|||
|
|
@ -35,22 +35,20 @@
|
|||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
define(["require", "exports", "module", "text!ace/css/editor.css", "./lib/oop", "./lib/oop",
|
||||
"./lib/event", "./layer/gutter", "./layer/marker", "./layer/text",
|
||||
"./layer/cursor", "./scrollbar", "./renderloop", "./event_emitter"],
|
||||
function(require, exports, module, editorCss) {
|
||||
define(function(require, exports, module) {
|
||||
|
||||
var oop = require("./lib/oop");
|
||||
var lang = require("./lib/lang");
|
||||
var dom = require("./lib/dom");
|
||||
var event = require("./lib/event");
|
||||
var GutterLayer = require("./layer/gutter");
|
||||
var MarkerLayer = require("./layer/marker");
|
||||
var TextLayer = require("./layer/text");
|
||||
var CursorLayer = require("./layer/cursor");
|
||||
var ScrollBar = require("./scrollbar");
|
||||
var RenderLoop = require("./renderloop");
|
||||
var MEventEmitter = require("./event_emitter");
|
||||
var oop = require("pilot/oop").oop;
|
||||
var lang = require("pilot/lang").lang;
|
||||
var dom = require("pilot/dom").dom;
|
||||
var event = require("pilot/event").event;
|
||||
var GutterLayer = require("ace/layer/gutter").Gutter;
|
||||
var MarkerLayer = require("ace/layer/marker").Marker;
|
||||
var TextLayer = require("ace/layer/text").Text;
|
||||
var CursorLayer = require("ace/layer/cursor").Cursor;
|
||||
var ScrollBar = require("ace/scrollbar").ScrollBar;
|
||||
var RenderLoop = require("ace/renderloop").RenderLoop;
|
||||
var EventEmitter = require("pilot/event_emitter").EventEmitter;
|
||||
var editorCss = require("text!ace/css/editor.css");
|
||||
|
||||
// import CSS once
|
||||
dom.importCssString(editorCss);
|
||||
|
|
@ -115,7 +113,7 @@ var VirtualRenderer = function(container, theme) {
|
|||
|
||||
this.$loop = new RenderLoop(lang.bind(this.$renderChanges, this));
|
||||
this.$loop.schedule(this.CHANGE_FULL);
|
||||
|
||||
|
||||
this.$updatePrintMargin();
|
||||
this.setPadding(4);
|
||||
};
|
||||
|
|
@ -133,7 +131,7 @@ var VirtualRenderer = function(container, theme) {
|
|||
this.CHANGE_SIZE = 64;
|
||||
this.CHANGE_FULL = 128;
|
||||
|
||||
oop.implement(this, MEventEmitter);
|
||||
oop.implement(this, EventEmitter);
|
||||
|
||||
this.setDocument = function(doc) {
|
||||
this.lines = doc.lines;
|
||||
|
|
@ -225,7 +223,7 @@ var VirtualRenderer = function(container, theme) {
|
|||
var pageX = event.getDocumentX(e);
|
||||
var pageY = event.getDocumentY(e);
|
||||
|
||||
this.$dispatchEvent("gutter" + e.type, {
|
||||
this._dispatchEvent("gutter" + e.type, {
|
||||
row: this.screenToTextCoordinates(pageX, pageY).row,
|
||||
htmlEvent: e
|
||||
});
|
||||
|
|
@ -262,7 +260,7 @@ var VirtualRenderer = function(container, theme) {
|
|||
this.getPrintMarginColumn = function() {
|
||||
return this.$printMarginColumn;
|
||||
};
|
||||
|
||||
|
||||
this.setShowGutter = function(show){
|
||||
this.$gutter.style.display = show ? "block" : "none";
|
||||
this.showGutter = show;
|
||||
|
|
@ -295,18 +293,18 @@ var VirtualRenderer = function(container, theme) {
|
|||
this.getFirstVisibleRow = function() {
|
||||
return (this.layerConfig || {}).firstRow || 0;
|
||||
};
|
||||
|
||||
|
||||
this.getFirstFullyVisibleRow = function(){
|
||||
if (!this.layerConfig)
|
||||
return 0;
|
||||
|
||||
|
||||
return this.layerConfig.firstRow + (this.layerConfig.offset == 0 ? 0 : 1);
|
||||
}
|
||||
|
||||
this.getLastFullyVisibleRow = function() {
|
||||
if (!this.layerConfig)
|
||||
return 0;
|
||||
|
||||
|
||||
var flint = Math.floor((this.layerConfig.height + this.layerConfig.offset) / this.layerConfig.lineHeight);
|
||||
return this.layerConfig.firstRow - 1 + flint;
|
||||
}
|
||||
|
|
@ -374,7 +372,7 @@ var VirtualRenderer = function(container, theme) {
|
|||
}
|
||||
else if (changes & this.CHANGE_LINES) {
|
||||
this.$updateLines();
|
||||
this.$updateScrollBar();
|
||||
this.$updateScrollBar();
|
||||
} if (changes & this.CHANGE_GUTTER) {
|
||||
this.showGutter && this.$gutterLayer.update(this.layerConfig);
|
||||
}
|
||||
|
|
@ -399,7 +397,7 @@ var VirtualRenderer = function(container, theme) {
|
|||
|
||||
var lineCount = Math.ceil(minHeight / this.lineHeight);
|
||||
var firstRow = Math.max(0, Math.round((this.scrollTop - offset) / this.lineHeight));
|
||||
var lastRow = Math.min(this.lines.length, firstRow + lineCount) - 1;
|
||||
var lastRow = Math.max(0, Math.min(this.lines.length, firstRow + lineCount) - 1);
|
||||
|
||||
var layerConfig = this.layerConfig = {
|
||||
width : longestLine,
|
||||
|
|
@ -470,17 +468,17 @@ var VirtualRenderer = function(container, theme) {
|
|||
this.$markerLayer.removeMarker(markerId);
|
||||
this.$loop.schedule(this.CHANGE_MARKER);
|
||||
};
|
||||
|
||||
|
||||
this.addGutterDecoration = function(row, className){
|
||||
this.$gutterLayer.addGutterDecoration(row, className);
|
||||
this.$loop.schedule(this.CHANGE_GUTTER);
|
||||
}
|
||||
|
||||
|
||||
this.removeGutterDecoration = function(row, className){
|
||||
this.$gutterLayer.removeGutterDecoration(row, className);
|
||||
this.$loop.schedule(this.CHANGE_GUTTER);
|
||||
}
|
||||
|
||||
|
||||
this.setBreakpoints = function(rows) {
|
||||
this.$gutterLayer.setBreakpoints(rows);
|
||||
this.$loop.schedule(this.CHANGE_GUTTER);
|
||||
|
|
@ -528,7 +526,7 @@ var VirtualRenderer = function(container, theme) {
|
|||
this.getScrollTop = function() {
|
||||
return this.scrollTop;
|
||||
};
|
||||
|
||||
|
||||
this.getScrollLeft = function() {
|
||||
return this.scroller.scrollLeft;
|
||||
};
|
||||
|
|
@ -550,7 +548,7 @@ var VirtualRenderer = function(container, theme) {
|
|||
this.$loop.schedule(this.CHANGE_SCROLL);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
this.scrollToX = function(scrollLeft) {
|
||||
if (scrollLeft <= this.$padding)
|
||||
scrollLeft = 0;
|
||||
|
|
@ -579,10 +577,10 @@ var VirtualRenderer = function(container, theme) {
|
|||
|
||||
this.textToScreenCoordinates = function(row, column) {
|
||||
var canvasPos = this.scroller.getBoundingClientRect();
|
||||
|
||||
|
||||
var x = this.padding + Math.round(this.doc.documentToScreenColumn(row, column) * this.characterWidth);
|
||||
var y = row * this.lineHeight;
|
||||
|
||||
|
||||
return {
|
||||
pageX: canvasPos.left + x - this.getScrollLeft(),
|
||||
pageY: canvasPos.top + y - this.getScrollTop()
|
||||
|
|
@ -637,5 +635,5 @@ var VirtualRenderer = function(container, theme) {
|
|||
|
||||
}).call(VirtualRenderer.prototype);
|
||||
|
||||
return VirtualRenderer;
|
||||
});
|
||||
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
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Ajax.org Code Editor (ACE).
|
||||
* The Original Code is Skywriter.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ajax.org Services B.V.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* Mozilla.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2009
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Fabian Jakobs <fabian AT ajax DOT org>
|
||||
* Joe Walker (jwalker@mozilla.com)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
|
|
@ -37,13 +37,4 @@
|
|||
|
||||
define(function(require, exports, module) {
|
||||
|
||||
var PluginManager = {
|
||||
commands : {},
|
||||
|
||||
registerCommand : function(name, command) {
|
||||
this.commands[name] = command;
|
||||
}
|
||||
};
|
||||
|
||||
return PluginManager;
|
||||
});
|
||||
});
|
||||
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