Upgrade ace & pilot. Fixes #44

This commit is contained in:
Chris Wanstrath
2011-11-06 16:14:56 -08:00
parent 419840e8b4
commit 11db5e1a5a
92 changed files with 3852 additions and 627 deletions

View File

@@ -303,7 +303,7 @@ canon.addCommand({
canon.addCommand({
name: "del",
bindKey: bindKey("Delete", "Delete|Ctrl-D"),
exec: function(env, args, request) { env.editor.removeRight(); }
exec: function(env, args, request) { env.editor.remove("right"); }
});
canon.addCommand({
name: "backspace",
@@ -311,16 +311,16 @@ canon.addCommand({
"Ctrl-Backspace|Command-Backspace|Option-Backspace|Shift-Backspace|Backspace",
"Ctrl-Backspace|Command-Backspace|Shift-Backspace|Backspace|Ctrl-H"
),
exec: function(env, args, request) { env.editor.removeLeft(); }
exec: function(env, args, request) { env.editor.remove("left"); }
});
canon.addCommand({
name: "removetolinestart",
bindKey: bindKey(null, "Option-Backspace"),
bindKey: bindKey("Alt-Backspace", "Option-Backspace"),
exec: function(env, args, request) { env.editor.removeToLineStart(); }
});
canon.addCommand({
name: "removetolineend",
bindKey: bindKey(null, "Ctrl-K"),
bindKey: bindKey("Alt-Delete", "Ctrl-K"),
exec: function(env, args, request) { env.editor.removeToLineEnd(); }
});
canon.addCommand({
@@ -330,7 +330,7 @@ canon.addCommand({
});
canon.addCommand({
name: "removewordright",
bindKey: bindKey(null, "Alt-Delete"),
bindKey: bindKey("Ctrl-Delete", "Alt-Delete"),
exec: function(env, args, request) { env.editor.removeWordRight(); }
});
canon.addCommand({
@@ -365,4 +365,33 @@ canon.addCommand({
exec: function(env, args, request) { env.editor.transposeLetters(); }
});
});
canon.addCommand({
name: "fold",
bindKey: bindKey("Alt-L", "Alt-L"),
exec: function(env) {
env.editor.session.toggleFold(false);
}
});
canon.addCommand({
name: "unfold",
bindKey: bindKey("Alt-Shift-L", "Alt-Shift-L"),
exec: function(env) {
env.editor.session.toggleFold(true);
}
});
canon.addCommand({
name: "foldall",
bindKey: bindKey("Alt-Shift-0", "Alt-Shift-0"),
exec: function(env) {
env.editor.session.foldAll();
}
});
canon.addCommand({
name: "unfoldall",
bindKey: bindKey("Alt-Shift-0", "Alt-Shift-0"),
exec: function(env) {
env.editor.session.unFoldAll();
}
});
});

View File

@@ -1,4 +1,4 @@
/*@import url(//fonts.googleapis.com/css?family=Droid+Sans+Mono);*/
@import url(//fonts.googleapis.com/css?family=Droid+Sans+Mono);
.ace_editor {
@@ -19,6 +19,13 @@
box-sizing: border-box;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
cursor: text;
}
/* setting pointer-events: auto; on node under the mouse, which changes during scroll,
will break mouse wheel scrolling in Safari */
.ace_content * {
pointer-events: none;
}
.ace_composition {
@@ -110,8 +117,6 @@
.ace_cursor-layer {
z-index: 4;
cursor: text;
/* setting pointer-events: none; here will break mouse wheel scrolling in Safari */
}
.ace_cursor {
@@ -127,11 +132,6 @@
white-space: nowrap;
}
.ace_marker-layer {
cursor: text;
pointer-events: none;
}
.ace_marker-layer .ace_step {
position: absolute;
z-index: 3;
@@ -162,8 +162,14 @@
.ace_line .ace_fold {
cursor: pointer;
pointer-events: auto;
color: darkred;
}
.ace_dragging .ace_marker-layer, .ace_dragging .ace_text-layer {
.ace_fold:hover{
background: gold!important;
}
.ace_dragging .ace_content {
cursor: move;
}

View File

@@ -91,6 +91,11 @@ var EditSession = function(text, mode) {
this.doc = doc;
doc.on("change", this.onChange.bind(this));
this.on("changeFold", this.onChangeFold.bind(this));
if (this.bgTokenizer) {
this.bgTokenizer.setDocument(this.getDocument());
this.bgTokenizer.start(0);
}
};
this.getDocument = function() {
@@ -131,7 +136,7 @@ var EditSession = function(text, mode) {
folds: removedFolds
});
}
this.$informUndoManager.schedule();
}
@@ -143,7 +148,7 @@ var EditSession = function(text, mode) {
this.doc.setValue(text);
this.selection.moveCursorTo(0, 0);
this.selection.clearSelection();
this.$resetRowCache(0);
this.$deltas = [];
this.$deltasDoc = [];
@@ -168,6 +173,27 @@ var EditSession = function(text, mode) {
return this.bgTokenizer.getTokens(firstRow, lastRow);
};
this.getTokenAt = function(row, column) {
var tokens = this.bgTokenizer.getTokens(row, row)[0].tokens;
var token, c = 0;
if (column == null) {
i = tokens.length - 1;
c = this.getLine(row).length;
} else {
for (var i = 0; i < tokens.length; i++) {
c += tokens[i].value.length;
if (c >= column)
break;
}
}
token = tokens[i];
if (!token)
return null;
token.index = i;
token.start = c - token.value.length;
return token;
};
this.setUndoManager = function(undoManager) {
this.$undoManager = undoManager;
this.$resetRowCache(0);
@@ -182,7 +208,7 @@ var EditSession = function(text, mode) {
var self = this;
this.$syncInformUndoManager = function() {
self.$informUndoManager.cancel();
if (self.$deltasFold.length) {
self.$deltas.push({
group: "fold",
@@ -190,7 +216,7 @@ var EditSession = function(text, mode) {
});
self.$deltasFold = [];
}
if (self.$deltasDoc.length) {
self.$deltas.push({
group: "doc",
@@ -198,14 +224,14 @@ var EditSession = function(text, mode) {
});
self.$deltasDoc = [];
}
if (self.$deltas.length > 0) {
undoManager.execute({
action: "aceupdate",
args: [self.$deltas, self]
});
}
self.$deltas = [];
}
this.$informUndoManager =
@@ -474,7 +500,7 @@ var EditSession = function(text, mode) {
this.bgTokenizer.setDocument(this.getDocument());
this.bgTokenizer.start(0);
this.tokenRe = mode.tokenRe;
this.nonTokenRe = mode.nonTokenRe;
@@ -889,7 +915,7 @@ var EditSession = function(text, mode) {
this.$clipRowToDocument = function(row) {
return Math.max(0, Math.min(row, this.doc.getLength()-1));
};
this.$clipPositionToDocument = function(row, column) {
column = Math.max(0, column);
@@ -905,7 +931,7 @@ var EditSession = function(text, mode) {
column = Math.min(this.doc.getLine(row).length, column);
}
}
return {
row: row,
column: column
@@ -1016,7 +1042,7 @@ var EditSession = function(text, mode) {
} else {
lastRow = firstRow;
}
len = e.data.lines.length;
len = e.data.lines ? e.data.lines.length : lastRow - firstRow;
} else {
len = lastRow - firstRow;
}
@@ -1171,6 +1197,7 @@ var EditSession = function(text, mode) {
CHAR_EXT = 2,
PLACEHOLDER_START = 3,
PLACEHOLDER_BODY = 4,
PUNCTUATION = 9,
SPACE = 10,
TAB = 11,
TAB_SPACE = 12;
@@ -1214,7 +1241,7 @@ var EditSession = function(text, mode) {
// a split is simple.
if (tokens[split] >= SPACE) {
// Include all following spaces + tabs in this split as well.
while (tokens[split] >= SPACE) {
while (tokens[split] >= SPACE) {
split ++;
}
addSplit(split);
@@ -1269,16 +1296,17 @@ var EditSession = function(text, mode) {
}
// === ELSE ===
// Search for the first non space/tab/placeholder token backwards.
for (split; split != lastSplit - 1; split--) {
if (tokens[split] >= PLACEHOLDER_START) {
split++;
break;
}
// Search for the first non space/tab/placeholder/punctuation token backwards.
var minSplit = Math.max(split - 10, lastSplit - 1);
while (split > minSplit && tokens[split] < PLACEHOLDER_START) {
split --;
}
while (split > minSplit && tokens[split] == PUNCTUATION) {
split --;
}
// If we found one, then add the split.
if (split > lastSplit) {
addSplit(split);
if (split > minSplit) {
addSplit(++split);
continue;
}
@@ -1286,7 +1314,7 @@ var EditSession = function(text, mode) {
split = lastSplit + wrapLimit;
// The split is inside of a CHAR or CHAR_EXT token and no space
// around -> force a split.
addSplit(lastSplit + wrapLimit);
addSplit(split);
}
return splits;
}
@@ -1312,11 +1340,13 @@ var EditSession = function(text, mode) {
}
}
// Space
else if(c == 32) {
else if (c == 32) {
arr.push(SPACE);
} else if((c > 39 && c < 48) || (c > 57 && c < 64)) {
arr.push(PUNCTUATION);
}
// full width characters
else if (isFullWidth(c)) {
else if (c >= 0x1100 && isFullWidth(c)) {
arr.push(CHAR, CHAR_EXT);
} else {
arr.push(CHAR);
@@ -1352,7 +1382,7 @@ var EditSession = function(text, mode) {
screenColumn += this.getScreenTabSize(screenColumn);
}
// full width characters
else if (isFullWidth(c)) {
else if (c >= 0x1100 && isFullWidth(c)) {
screenColumn += 2;
} else {
screenColumn += 1;
@@ -1428,7 +1458,7 @@ var EditSession = function(text, mode) {
column: 0
}
}
var line;
var docRow = 0;
var docColumn = 0;
@@ -1448,11 +1478,11 @@ var EditSession = function(text, mode) {
}
}
var doCache = !rowCache.length || i == rowCache.length;
// clamp row before clamping column, for selection on last line
var maxRow = this.getLength() - 1;
var foldLine = this.getNextFold(docRow);
var foldLine = this.getNextFoldLine(docRow);
var foldStart = foldLine ? foldLine.start.row : Infinity;
while (row <= screenRow) {
@@ -1464,7 +1494,7 @@ var EditSession = function(text, mode) {
docRow++;
if (docRow > foldStart) {
docRow = foldLine.end.row+1;
foldLine = this.getNextFold(docRow);
foldLine = this.getNextFoldLine(docRow, foldLine);
foldStart = foldLine ? foldLine.start.row : Infinity;
}
}
@@ -1516,7 +1546,7 @@ var EditSession = function(text, mode) {
if (foldLine) {
return foldLine.idxToPosition(docColumn);
}
return {
row: docRow,
column: docColumn
@@ -1527,12 +1557,12 @@ var EditSession = function(text, mode) {
// Normalize the passed in arguments.
if (typeof docColumn === "undefined")
var pos = this.$clipPositionToDocument(docRow.row, docRow.column);
else
else
pos = this.$clipPositionToDocument(docRow, docColumn);
docRow = pos.row;
docColumn = pos.column;
var LL = this.$rowCache.length;
var wrapData;
@@ -1574,7 +1604,7 @@ var EditSession = function(text, mode) {
}
var doCache = !rowCache.length || i == rowCache.length;
var foldLine = this.getNextFold(row);
var foldLine = this.getNextFoldLine(row);
var foldStart = foldLine ?foldLine.start.row :Infinity;
while (row < docRow) {
@@ -1582,7 +1612,7 @@ var EditSession = function(text, mode) {
rowEnd = foldLine.end.row + 1;
if (rowEnd > docRow)
break;
foldLine = this.getNextFold(rowEnd);
foldLine = this.getNextFoldLine(rowEnd, foldLine);
foldStart = foldLine ?foldLine.start.row :Infinity;
}
else {
@@ -1591,7 +1621,7 @@ var EditSession = function(text, mode) {
screenRow += this.getRowLength(row);
row = rowEnd;
if (doCache) {
rowCache.push({
docRow: row,
@@ -1708,4 +1738,4 @@ var EditSession = function(text, mode) {
require("ace/edit_session/folding").Folding.call(EditSession.prototype);
exports.EditSession = EditSession;
});
});

View File

@@ -52,7 +52,7 @@ function Folding() {
var foldLine = this.getFoldLine(row);
if (!foldLine)
return null;
var folds = foldLine.folds;
for (var i = 0; i < folds.length; i++) {
var fold = folds[i];
@@ -134,7 +134,7 @@ function Folding() {
var foldLine = foldLine || this.getFoldLine(row);
if (!foldLine)
return null;
var lastFold = {
end: { column: 0 }
};
@@ -183,7 +183,7 @@ function Folding() {
}
// returns the fold which starts after or contains docRow
this.getNextFold = function(docRow, startFoldLine) {
this.getNextFoldLine = function(docRow, startFoldLine) {
var foldData = this.$foldData, ans;
var i = 0;
if (startFoldLine)
@@ -251,7 +251,7 @@ function Folding() {
var startColumn = fold.start.column;
var endRow = fold.end.row;
var endColumn = fold.end.column;
// --- Some checking ---
if (fold.placeholder.length < 2)
throw "Placeholder has to be at least 2 characters";
@@ -489,8 +489,85 @@ function Folding() {
return fd;
};
}
this.toggleFold = function(tryToUnfold) {
var selection = this.selection;
var range = selection.getRange();
if (range.isEmpty()) {
var cursor = range.start
var fold = this.getFoldAt(cursor.row, cursor.column);
var bracketPos, column;
if (fold) {
this.expandFold(fold);
return;
} else if (bracketPos = this.findMatchingBracket(cursor)) {
if (range.comparePoint(bracketPos) == 1) {
range.end = bracketPos;
} else {
range.start = bracketPos;
range.start.column++;
range.end.column--;
}
} else if (bracketPos = this.findMatchingBracket({row: cursor.row, column: cursor.column + 1})) {
if (range.comparePoint(bracketPos) == 1)
range.end = bracketPos;
else
range.start = bracketPos;
range.start.column++;
} else {
var token = this.getTokenAt(cursor.row, cursor.column);
if (token && /^comment|string/.test(token.type)) {
var startRow = cursor.row;
var endRow = cursor.row;
var t = token;
while ((t = this.getTokenAt(startRow - 1)) && t.type == token.type) {
startRow --;
token = t;
}
range.start.row = startRow;
range.start.column = token.start + 2;
while ((t = this.getTokenAt(endRow + 1, 0)) && t.type == token.type) {
endRow ++;
token = t;
}
range.end.row = endRow;
range.end.column = token.start + token.value.length - 1;
}
}
} else {
var folds = this.getFoldsInRange(range);
if (tryToUnfold && folds.length) {
this.expandFolds(folds);
return;
} else if (folds.length == 1 ) {
fold = folds[0];
}
}
if (!fold)
fold = this.getFoldAt(range.start.row, range.start.column);
if (fold && fold.range.toString() == range.toString()){
this.expandFold(fold);
return
}
var placeholder = "...";
if (!range.isMultiLine()) {
placeholder = this.getTextRange(range);
if(placeholder.length < 4)
return;
placeholder = placeholder.trim().substring(0, 2) + ".."
}
this.addFold(placeholder, range);
};
}
exports.Folding = Folding;
});

View File

@@ -346,6 +346,11 @@ module.exports = {
computeAndAssert(" ぁぁ", [1, 2], 2);
computeAndAssert(" ぁ\tぁ", [1, 3], 2);
computeAndAssert(" ぁぁ\tぁ", [1, 4], 4);
// Test wrapping for punctuation.
computeAndAssert(" ab.c;ef++", [1, 3, 5, 7, 8], 2);
computeAndAssert(" a.b", [1, 2, 3], 1);
computeAndAssert("#>>", [1, 2], 1);
},
"test get longest line" : function() {

36
vendor/ace/editor.js vendored
View File

@@ -47,7 +47,7 @@ var event = require("pilot/event");
var lang = require("pilot/lang");
var useragent = require("pilot/useragent");
var TextInput = require("ace/keyboard/textinput").TextInput;
var MouseHandler = require("ace/mouse_handler").MouseHandler;
var MouseHandler = require("ace/mouse/mouse_handler").MouseHandler;
//var TouchHandler = require("ace/touch_handler").TouchHandler;
var KeyBinding = require("ace/keyboard/keybinding").KeyBinding;
var EditSession = require("ace/edit_session").EditSession;
@@ -230,7 +230,7 @@ var Editor =function(renderer, session) {
this.unsetStyle = function(style) {
this.renderer.unsetStyle(style);
};
this.setFontSize = function(size) {
this.container.style.fontSize = size;
};
@@ -269,7 +269,7 @@ var Editor =function(renderer, session) {
});
this.textInput.focus();
};
this.isFocused = function() {
return this.textInput.isFocused();
};
@@ -300,6 +300,8 @@ var Editor =function(renderer, session) {
lastRow = Infinity;
this.renderer.updateLines(range.start.row, lastRow);
this._dispatchEvent("change", e);
// update cursor because tab characters can influence the cursor position
this.renderer.updateCursor();
};
@@ -405,7 +407,7 @@ var Editor =function(renderer, session) {
var text = "";
if (!this.selection.isEmpty())
text = this.session.getTextRange(this.getSelectionRange());
this._emit("copy", text);
return text;
};
@@ -521,7 +523,7 @@ var Editor =function(renderer, session) {
this.onTextInput = function(text, notPasted) {
if (!notPasted)
this._emit("paste", text);
// In case the text was not pasted and we got only one character, then
// handel it as a command key stroke.
if (notPasted && text.length == 1) {
@@ -654,32 +656,24 @@ var Editor =function(renderer, session) {
return this.$modeBehaviours;
};
this.removeRight = function() {
this.remove = function(dir) {
if (this.$readOnly)
return;
if (this.selection.isEmpty()) {
this.selection.selectRight();
if (this.selection.isEmpty()){
if(dir == "left")
this.selection.selectLeft();
else
this.selection.selectRight();
}
this.session.remove(this.getSelectionRange());
this.clearSelection();
};
this.removeLeft = function() {
if (this.$readOnly)
return;
if (this.selection.isEmpty())
this.selection.selectLeft();
var range = this.getSelectionRange();
if (this.getBehavioursEnabled()) {
var session = this.session;
var state = session.getState(range.start.row);
var new_range = session.getMode().transformAction(state, 'deletion', this, session, range);
if (new_range !== false) {
if (new_range)
range = new_range;
}
}
this.session.remove(range);
@@ -798,7 +792,7 @@ var Editor =function(renderer, session) {
indentString = lang.stringRepeat(" ", count);
} else
indentString = "\t";
return this.onTextInput(indentString);
return this.onTextInput(indentString, true);
}
};

View File

@@ -420,7 +420,7 @@ module.exports = {
var editor = new Editor(new MockRenderer(), session);
editor.moveCursorTo(1, 1);
editor.removeLeft();
editor.remove("left");
assert.equal(session.toString(), "123\n56");
},
@@ -429,7 +429,7 @@ module.exports = {
var editor = new Editor(new MockRenderer(), session);
editor.moveCursorTo(1, 0);
editor.removeLeft();
editor.remove("left");
assert.equal(session.toString(), "123456");
},
@@ -440,7 +440,7 @@ module.exports = {
var editor = new Editor(new MockRenderer(), session);
editor.moveCursorTo(1, 8);
editor.removeLeft();
editor.remove("left");
assert.equal(session.toString(), "123\n 456");
},

22
vendor/ace/ext/static.css vendored Normal file
View File

@@ -0,0 +1,22 @@
.ace_editor {
font-family: 'Monaco', 'Menlo', 'Droid Sans Mono', 'Courier New', monospace;
font-size: 12px;
}
.ace_editor .ace_gutter {
width: 25px !important;
display: block;
float: left;
text-align: right;
padding: 0 3px 0 0;
margin-right: 3px;
}
.ace-row { clear: both; }
*.ace_gutter-cell {
-moz-user-select: -moz-none;
-khtml-user-select: none;
-webkit-user-select: none;
user-select: none;
}

95
vendor/ace/ext/static_highlight.js vendored Normal file
View File

@@ -0,0 +1,95 @@
/* vim:ts=4:sts=4:sw=4:
* ***** 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 B.V.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Jan Jongboom <fabian AT ajax DOT org>
* 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 EditSession = require("ace/edit_session").EditSession;
var TextLayer = require("ace/layer/text").Text;
var baseStyles = require("ace/requirejs/text!ace/ext/static.css");
/** Transforms a given input code snippet into HTML using the given mode
*
* @param {string} input Code snippet
* @param {mode} mode Mode loaded from /ace/mode (use 'ServerSideHiglighter.getMode')
* @param {string} r Code snippet
* @returns {object} An object containing: html, css
*/
exports.render = function(input, mode, theme) {
var session = new EditSession("");
session.setMode(mode);
session.setUseWorker(false);
var textLayer = new TextLayer(document.createElement("div"));
textLayer.setSession(session);
textLayer.config = {
characterWidth: 10,
lineHeight: 20
};
session.setValue(input);
var stringBuilder = [];
var length = session.getLength();
var tokens = session.getTokens(0, length - 1);
for(var ix = 0; ix < length; ix++) {
var lineTokens = tokens[ix].tokens;
stringBuilder.push("<div class='ace-row'>");
stringBuilder.push("<span class='ace_gutter ace_gutter-cell' unselectable='on'>" + (ix+1) + "</span>");
textLayer.$renderLine(stringBuilder, 0, lineTokens, true);
stringBuilder.push("</div>");
}
// let's prepare the whole html
var html = "<div class=':cssClass'>\
<div class='ace_editor ace_scroller ace_text-layer'>\
:code\
</div>\
</div>".replace(/:cssClass/, theme.cssClass).replace(/:code/, stringBuilder.join(""));
textLayer.destroy();
return {
css: baseStyles + theme.cssText,
html: html
};
};
});

74
vendor/ace/ext/static_highlight_test.js vendored Normal file
View File

@@ -0,0 +1,74 @@
if (typeof process !== "undefined") {
require("../../../support/paths");
require("ace/test/mockdom");
}
var assert = require("assert");
var highlighter = require("./static_highlight");
var JavaScriptMode = require("ace/mode/javascript").Mode;
// Execution ORDER: test.setUpSuite, setUp, testFn, tearDown, test.tearDownSuite
module.exports = {
timeout: 10000,
"test simple snippet": function(next) {
var theme = require("ace/theme/tomorrow");
var snippet = "/** this is a function\n\
*\n\
*/\n\
function hello (a, b, c) {\n\
console.log(a * b + c + 'sup?');\n\
}";
var mode = new JavaScriptMode();
var isError = false, result;
try {
result = highlighter.render(snippet, mode, theme);
}
catch (e) {
console.log(e);
isError = true;
}
// todo: write something more meaningful
assert.equal(isError, false);
next();
},
"test css from theme is used": function(next) {
var theme = require("ace/theme/tomorrow");
var snippet = "/** this is a function\n\
*\n\
*/\n\
function hello (a, b, c) {\n\
console.log(a * b + c + 'sup?');\n\
}";
var mode = new JavaScriptMode();
var isError = false, result;
result = highlighter.render(snippet, mode, theme);
assert.equal(result.css, theme.cssText);
next();
},
"test theme classname should be in output html": function (next) {
var theme = require("ace/theme/tomorrow");
var snippet = "/** this is a function\n\
*\n\
*/\n\
function hello (a, b, c) {\n\
console.log(a * b + c + 'sup?');\n\
}";
var mode = new JavaScriptMode();
var isError = false, result;
result = highlighter.render(snippet, mode, theme);
assert.equal(!!result.html.match(/<div class='ace-tomorrow'>/), true);
next();
}
};
!module.parent && require("asyncjs").test.testcase(module.exports).exec();

View File

@@ -93,8 +93,8 @@ var vimStates = {
},
vimcommand("(k|up)", "golineup"),
vimcommand("(j|down)", "golinedown"),
vimcommand("(l|right)", "golineright"),
vimcommand("(h|left)", "golineleft"),
vimcommand("(l|right)", "gotoright"),
vimcommand("(h|left)", "gotoleft"),
{
key: "shift-g",
exec: "gotoend"

View File

@@ -52,7 +52,7 @@ StateHandler.prototype = {
* need to be adapted.
*/
$buildKeymappingRegex: function(keymapping) {
for (state in keymapping) {
for (var state in keymapping) {
this.$buildBindingsRegex(keymapping[state]);
}
return keymapping;
@@ -64,7 +64,8 @@ StateHandler.prototype = {
if (binding.key) {
binding.key = new RegExp('^' + binding.key + '$');
} else if (Array.isArray(binding.regex)) {
binding.key = new RegExp('^' + binding.regex[1] + '$');
if (!('key' in binding))
binding.key = new RegExp('^' + binding.regex[1] + '$');
binding.regex = new RegExp(binding.regex.join('') + '$');
} else if (binding.regex) {
binding.regex = new RegExp(binding.regex + '$');

View File

@@ -47,7 +47,8 @@ var TextInput = function(parentNode, host) {
var text = dom.createElement("textarea");
if (useragent.isTouchPad)
text.setAttribute('x-palm-disable-auto-cap',true);
text.setAttribute("x-palm-disable-auto-cap", true);
text.style.left = "-10000px";
parentNode.appendChild(text);
@@ -63,7 +64,7 @@ var TextInput = function(parentNode, host) {
try {
text.select();
} catch (e) {}
};
}
function sendText(valueToSend) {
if (!copied) {
@@ -159,10 +160,10 @@ var TextInput = function(parentNode, host) {
setTimeout(onCompositionEnd, 0);
if ((text.value.charCodeAt(0)|0) < 129) {
return;
};
}
inCompostion ? onCompositionUpdate() : onCompositionStart();
});
};
}
if ("onpropertychange" in text && !("oninput" in text))
event.addListener(text, "propertychange", onPropertyChange);

View File

@@ -103,13 +103,13 @@ var Gutter = function(parentEl) {
var html = [];
var i = config.firstRow;
var lastRow = config.lastRow;
var fold = this.session.getNextFold(i);
var fold = this.session.getNextFoldLine(i);
var foldStart = fold ? fold.start.row : Infinity;
while (true) {
if(i > foldStart) {
i = fold.end.row + 1;
fold = this.session.getNextFold(i);
fold = this.session.getNextFoldLine(i, fold);
foldStart = fold ?fold.start.row :Infinity;
}
if(i > lastRow)

View File

@@ -23,6 +23,7 @@
* Fabian Jakobs <fabian AT ajax DOT org>
* Julian Viereck <julian DOT viereck AT gmail DOT com>
* Mihai Sucan <mihai.sucan@gmail.com>
* Irakli Gozalishvili <rfobic@gmail.com> (http://jeditoolkit.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
@@ -121,8 +122,8 @@ var Text = function(parentEl) {
// Note: characterWidth can be a float!
measureNode.innerHTML = lang.stringRepeat("Xy", n);
if (document.body) {
document.body.appendChild(measureNode);
if (this.element.ownerDocument.body) {
this.element.ownerDocument.body.appendChild(measureNode);
} else {
var container = this.element.parentNode;
while (!dom.hasCssClass(container, "ace_editor"))
@@ -257,15 +258,15 @@ var Text = function(parentEl) {
};
this.$renderLinesFragment = function(config, firstRow, lastRow) {
var fragment = document.createDocumentFragment(),
var fragment = this.element.ownerDocument.createDocumentFragment(),
row = firstRow,
fold = this.session.getNextFold(row),
fold = this.session.getNextFoldLine(row),
foldStart = fold ?fold.start.row :Infinity;
while (true) {
if(row > foldStart) {
row = fold.end.row+1;
fold = this.session.getNextFold(row);
fold = this.session.getNextFoldLine(row, fold);
foldStart = fold ?fold.start.row :Infinity;
}
if(row > lastRow)
@@ -306,13 +307,13 @@ var Text = function(parentEl) {
var firstRow = config.firstRow, lastRow = config.lastRow;
var row = firstRow,
fold = this.session.getNextFold(row),
fold = this.session.getNextFoldLine(row),
foldStart = fold ?fold.start.row :Infinity;
while (true) {
if(row > foldStart) {
row = fold.end.row+1;
fold = this.session.getNextFold(row);
fold = this.session.getNextFoldLine(row, fold);
foldStart = fold ?fold.start.row :Infinity;
}
if(row > lastRow)

View File

@@ -93,7 +93,7 @@ module.exports = {
assert.equal(
stringBuilder.join(""),
"<span class='ace_cjk ace_invisible' style='width:20px'>" + this.textLayer.SPACE_CHAR + "</span>"
+ "<span class='ace_invisible'>&para;</span>"
+ "<span class='ace_invisible'>\xB6</span>"
);
}
};

View File

@@ -78,7 +78,7 @@ var CstyleBehaviour = function () {
if (rightChar == '}') {
var openBracePos = session.findMatchingBracket({row: cursor.row, column: cursor.column + 1});
if (!openBracePos)
return false;
return null;
var indent = this.getNextLineIndent(state, line.substring(0, line.length - 1), session.getTabString());
var next_indent = this.$getIndent(session.doc.getLine(openBracePos.row));
@@ -89,7 +89,6 @@ var CstyleBehaviour = function () {
}
}
}
return false;
});
this.add("braces", "deletion", function (state, action, editor, session, range) {
@@ -102,7 +101,6 @@ var CstyleBehaviour = function () {
return range;
}
}
return false;
});
this.add("parens", "insertion", function (state, action, editor, session, text) {
@@ -134,7 +132,6 @@ var CstyleBehaviour = function () {
}
}
}
return false;
});
this.add("parens", "deletion", function (state, action, editor, session, range) {
@@ -147,7 +144,6 @@ var CstyleBehaviour = function () {
return range;
}
}
return false;
});
this.add("string_dquotes", "insertion", function (state, action, editor, session, text) {
@@ -166,7 +162,7 @@ var CstyleBehaviour = function () {
// We're escaped.
if (leftChar == '\\') {
return false;
return null;
}
// Find what token we're inside.
@@ -205,7 +201,6 @@ var CstyleBehaviour = function () {
}
}
}
return false;
});
this.add("string_dquotes", "deletion", function (state, action, editor, session, range) {
@@ -218,7 +213,6 @@ var CstyleBehaviour = function () {
return range;
}
}
return false;
});
}

View File

@@ -82,7 +82,6 @@ var XmlBehaviour = function () {
}
}
}
return false;
});
}

View File

@@ -121,10 +121,13 @@ var c_cppHighlightRules = function() {
token : "keyword.operator",
regex : "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|==|=|!=|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|new|delete|typeof|void)"
}, {
token : "lparen",
token : "punctuation.operator",
regex : "\\?|\\:|\\,|\\;|\\."
}, {
token : "paren.lparen",
regex : "[[({]"
}, {
token : "rparen",
token : "paren.rparen",
regex : "[\\])}]"
}, {
token : "text",

View File

@@ -97,17 +97,8 @@ oop.inherits(Mode, TextMode);
};
this.createWorker = function(session) {
var doc = session.getDocument();
var worker = new WorkerClient(["ace", "pilot"], "worker-coffee.js", "ace/mode/coffee_worker", "Worker");
worker.call("setValue", [doc.getValue()]);
doc.on("change", function(e) {
e.range = {
start: e.data.range.start,
end: e.data.range.end
};
worker.emit("change", e);
});
worker.attachToDocument(session.getDocument());
worker.on("error", function(e) {
session.setAnnotations([e.data]);

View File

@@ -37,18 +37,48 @@
define(function(require, exports, module) {
require("pilot/oop").inherits(CoffeeHighlightRules,
require("ace/mode/text_highlight_rules").TextHighlightRules);
var lang = require("pilot/lang");
var oop = require("pilot/oop");
var TextHighlightRules = require("ace/mode/text_highlight_rules").TextHighlightRules;
oop.inherits(CoffeeHighlightRules, TextHighlightRules);
function CoffeeHighlightRules() {
var identifier = "[$A-Za-z_\\x7f-\\uffff][$\\w\\x7f-\\uffff]*";
var keywordend = "(?![$\\w]|\\s*:)";
var stringfill = {
token : "string",
merge : true,
regex : ".+"
};
var keywords = lang.arrayToMap((
"this|throw|then|try|typeof|super|switch|return|break|by)|continue|" +
"catch|class|in|instanceof|is|isnt|if|else|extends|for|forown|" +
"finally|function|while|when|new|no|not|delete|debugger|do|loop|of|off|" +
"or|on|unless|until|and|yes").split("|")
);
var langConstant = lang.arrayToMap((
"true|false|null|undefined").split("|")
);
var illegal = lang.arrayToMap((
"case|const|default|function|var|void|with|enum|export|implements|" +
"interface|let|package|private|protected|public|static|yield|" +
"__hasProp|extends|slice|bind|indexOf").split("|")
);
var supportClass = lang.arrayToMap((
"Array|Boolean|Date|Function|Number|Object|RegExp|ReferenceError|" +
"RangeError|String|SyntaxError|Error|EvalError|TypeError|URIError").split("|")
);
var supportFunction = lang.arrayToMap((
"Math|JSON|isNaN|isFinite|parseInt|parseFloat|encodeURI|" +
"encodeURIComponent|decodeURI|decodeURIComponent|RangeError|String|" +
"SyntaxError|Error|EvalError|TypeError|URIError").split("|")
);
this.$rules = {
start : [
{
@@ -58,29 +88,20 @@ define(function(require, exports, module) {
token : "variable",
regex : "@" + identifier
}, {
token : "entity.name.function",
regex : identifier + "(?=\\s*:\\s*(?:\\(.*?\\)\\s*)?->)"
}, {
token : "keyword",
regex : "(?:t(?:h(?:is|row|en)|ry|ypeof)|s(?:uper|witch)|return|b(?:reak|y)|c(?:ontinue|atch|lass)|i(?:n(?:stanceof)?|s(?:nt)?|f)|e(?:lse|xtends)|f(?:or (?:own)?|inally|unction)|wh(?:ile|en)|n(?:ew|ot?)|d(?:e(?:lete|bugger)|o)|loop|for|o(?:ff?|[rn])|un(?:less|til)|and|yes)"
+ keywordend
}, {
token : "constant.language",
regex : "(?:true|false|null|undefined)" + keywordend
}, {
token : "invalid.illegal",
regex : "(?:c(?:ase|onst)|default|function|v(?:ar|oid)|with|e(?:num|xport)|i(?:mplements|nterface)|let|p(?:ackage|r(?:ivate|otected)|ublic)|static|yield|__(?:hasProp|extends|slice|bind|indexOf))"
+ keywordend
}, {
token : "language.support.class",
regex : "(?:Array|Boolean|Date|Function|Number|Object|R(?:e(?:gExp|ferenceError)|angeError)|S(?:tring|yntaxError)|E(?:rror|valError)|TypeError|URIError)"
+ keywordend
}, {
token : "language.support.function",
regex : "(?:Math|JSON|is(?:NaN|Finite)|parse(?:Int|Float)|encodeURI(?:Component)?|decodeURI(?:Component)?)"
+ keywordend
}, {
token : "identifier",
token: function(value) {
if (keywords.hasOwnProperty(value))
return "keyword";
else if (langConstant.hasOwnProperty(value))
return "constant.language";
else if (illegal.hasOwnProperty(value))
return "invalid.illegal";
else if (supportClass.hasOwnProperty(value))
return "language.support.class";
else if (supportFunction.hasOwnProperty(value))
return "language.support.function";
else
return "identifier";
},
regex : identifier
}, {
token : "constant.numeric",
@@ -127,10 +148,13 @@ define(function(require, exports, module) {
token : "comment",
regex : "#.*"
}, {
token : "lparen",
token : "punctuation.operator",
regex : "\\?|\\:|\\,|\\."
}, {
token : "paren.lparen",
regex : "[({[]"
}, {
token : "rparen",
token : "paren.rparen",
regex : "[\\]})]"
}, {
token : "keyword.operator",

View File

@@ -0,0 +1,63 @@
/* ***** 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 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 ***** */
if (typeof process !== "undefined") {
require("../../../support/paths");
}
define(function(require, exports, module) {
var Mode = require("ace/mode/coffee").Mode;
var assert = require("ace/test/assertions");
module.exports = {
setUp : function() {
this.tokenizer = new Mode().getTokenizer();
},
"test: tokenize keyword": function() {
var tokens = this.tokenizer.getLineTokens("for", "start").tokens;
assert.equal(tokens.length, 1);
assert.equal(tokens[0].type, "keyword");
}
};
});
if (typeof module !== "undefined" && module === require.main) {
require("asyncjs").test.testcase(module.exports).exec()
}

78
vendor/ace/mode/coldfusion.js vendored Normal file
View File

@@ -0,0 +1,78 @@
/* ***** 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 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");
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 ColdfusionHighlightRules = require("ace/mode/coldfusion_highlight_rules").ColdfusionHighlightRules;
var XmlBehaviour = require("ace/mode/behaviour/xml").XmlBehaviour;
var Mode = function() {
var highlighter = new ColdfusionHighlightRules();
this.$tokenizer = new Tokenizer(highlighter.getRules());
this.$behaviour = new XmlBehaviour();
this.$embeds = highlighter.getEmbeds();
this.createModeDelegates({
"js-": JavaScriptMode,
"css-": CssMode
});
};
oop.inherits(Mode, TextMode);
(function() {
this.toggleCommentLines = function(state, doc, startRow, endRow) {
return 0;
};
this.getNextLineIndent = function(state, line, tab) {
return this.$getIndent(line);
};
this.checkOutdent = function(state, line, input) {
return false;
};
}).call(Mode.prototype);
exports.Mode = Mode;
});

View File

@@ -0,0 +1,198 @@
/* ***** 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 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");
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 ColdfusionHighlightRules = function() {
// regexp must not have capturing parentheses
// regexps are ordered -> the first match is used
function string(state) {
return [{
token : "string",
regex : '".*?"'
}, {
token : "string", // multi line string start
merge : true,
regex : '["].*$',
next : state + "-qqstring"
}, {
token : "string",
regex : "'.*?'"
}, {
token : "string", // multi line string start
merge : true,
regex : "['].*$",
next : state + "-qstring"
}]
}
function multiLineString(quote, state) {
return [{
token : "string",
merge : true,
regex : ".*" + quote,
next : state
}, {
token : "string",
merge : true,
regex : '.+'
}]
}
function tag(states, name, nextState) {
states[name] = [{
token : "text",
regex : "\\s+"
}, {
token : "meta.tag",
regex : "[-_a-zA-Z0-9:]+",
next : name + "-attribute-list"
}, {
token: "empty",
regex: "",
next : name + "-attribute-list"
}];
states[name + "-qstring"] = multiLineString("'", name);
states[name + "-qqstring"] = multiLineString("\"", name);
states[name + "-attribute-list"] = [{
token : "text",
regex : ">",
next : nextState
}, {
token : "entity.other.attribute-name",
regex : "[-_a-zA-Z0-9:]+"
}, {
token : "constant.numeric", // float
regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
}, {
token : "text",
regex : "\\s+"
}].concat(string(name));
};
this.$rules = {
start : [ {
token : "text",
merge : true,
regex : "<\\!\\[CDATA\\[",
next : "cdata"
}, {
token : "xml_pe",
regex : "<\\?.*?\\?>"
}, {
token : "comment",
merge : true,
regex : "<\\!--",
next : "comment"
}, {
token : "text",
regex : "<(?=\s*script)",
next : "script"
}, {
token : "text",
regex : "<(?=\s*style)",
next : "css"
}, {
token : "text", // opening tag
regex : "<\\/?",
next : "tag"
}, {
token : "text",
regex : "\\s+"
}, {
token : "text",
regex : "[^<]+"
} ],
cdata : [ {
token : "text",
regex : "\\]\\]>",
next : "start"
}, {
token : "text",
merge : true,
regex : "\\s+"
}, {
token : "text",
merge : true,
regex : ".+"
} ],
comment : [ {
token : "comment",
regex : ".*?-->",
next : "start"
}, {
token : "comment",
merge : true,
regex : ".+"
} ]
};
tag(this.$rules, "tag", "start");
tag(this.$rules, "css", "css-start");
tag(this.$rules, "script", "js-start");
this.embedRules(JavaScriptHighlightRules, "js-", [{
token: "comment",
regex: "\\/\\/.*(?=<\\/script>)",
next: "tag"
}, {
token: "text",
regex: "<\\/(?=script)",
next: "tag"
}]);
this.embedRules(CssHighlightRules, "css-", [{
token: "text",
regex: "<\\/(?=style)",
next: "tag"
}]);
};
oop.inherits(ColdfusionHighlightRules, TextHighlightRules);
exports.ColdfusionHighlightRules = ColdfusionHighlightRules;
});

73
vendor/ace/mode/coldfusion_test.js vendored Normal file
View File

@@ -0,0 +1,73 @@
/* ***** 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 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 ***** */
if (typeof process !== "undefined") {
require("../../../support/paths");
}
define(function(require, exports, module) {
var EditSession = require("ace/edit_session").EditSession;
var Range = require("ace/range").Range;
var ColdfusionMode = require("ace/mode/coldfusion").Mode;
var assert = require("ace/test/assertions");
module.exports = {
setUp : function() {
this.mode = new ColdfusionMode();
},
"test: toggle comment lines should not do anything" : function() {
var session = new EditSession([" abc", "cde", "fg"]);
var range = new Range(0, 3, 1, 1);
var comment = this.mode.toggleCommentLines("start", session, 0, 1);
assert.equal([" abc", "cde", "fg"].join("\n"), session.toString());
},
"test: next line indent should be the same as the current line indent" : function() {
assert.equal(" ", this.mode.getNextLineIndent("start", " abc"));
assert.equal("", this.mode.getNextLineIndent("start", "abc"));
assert.equal("\t", this.mode.getNextLineIndent("start", "\tabc"));
}
};
});
if (typeof module !== "undefined" && module === require.main) {
require("asyncjs").test.testcase(module.exports).exec()
}

View File

@@ -67,10 +67,13 @@ var CSharpHighlightRules = function() {
token : "keyword.operator",
regex : "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|instanceof|new|delete|typeof|void)"
}, {
token : "lparen",
token : "punctuation.operator",
regex : "\\?|\\:|\\,|\\;|\\."
}, {
token : "paren.lparen",
regex : "[[({]"
}, {
token : "rparen",
token : "paren.rparen",
regex : "[\\])}]"
}, {
token : "text",

View File

@@ -78,17 +78,8 @@ oop.inherits(Mode, TextMode);
};
this.createWorker = function(session) {
var doc = session.getDocument();
var worker = new WorkerClient(["ace", "pilot"], "worker-css.js", "ace/mode/css_worker", "Worker");
worker.call("setValue", [doc.getValue()]);
doc.on("change", function(e) {
e.range = {
start: e.data.range.start,
end: e.data.range.end
};
worker.emit("change", e);
});
worker.attachToDocument(session.getDocument());
worker.on("csslint", function(e) {
var errors = [];

View File

@@ -215,14 +215,14 @@ var CssHighlightRules = function() {
var ruleset = lang.copyArray(base_ruleset);
ruleset.unshift({
token : "rparen",
token : "paren.rparen",
regex : "\\}",
next: "start"
});
var media_ruleset = lang.copyArray( base_ruleset );
media_ruleset.unshift({
token : "rparen",
token : "paren.rparen",
regex : "\\}",
next: "media"
});
@@ -261,7 +261,7 @@ var CssHighlightRules = function() {
regex : "\\/\\*",
next : "comment"
}, {
token: "lparen",
token: "paren.lparen",
regex: "\\{",
next: "ruleset"
}, {
@@ -288,7 +288,7 @@ var CssHighlightRules = function() {
regex : "\\/\\*",
next : "media_comment"
}, {
token: "lparen",
token: "paren.lparen",
regex: "\\{",
next: "media_ruleset"
},{

View File

@@ -78,9 +78,9 @@ module.exports = {
var tokens = this.tokenizer.getLineTokens("{()}", "start").tokens;
assert.equal(3, tokens.length);
assert.equal("lparen", tokens[0].type);
assert.equal("paren.lparen", tokens[0].type);
assert.equal("text", tokens[1].type);
assert.equal("rparen", tokens[2].type);
assert.equal("paren.rparen", tokens[2].type);
},
"test for last rule in ruleset to catch capturing group bugs" : function() {

View File

@@ -86,17 +86,17 @@ var HtmlHighlightRules = function() {
}, {
token : "meta.tag",
regex : "[-_a-zA-Z0-9:]+",
next : name + "-attribute-list"
next : name + "embed-attribute-list"
}, {
token: "empty",
regex: "",
next : name + "-attribute-list"
next : name + "embed-attribute-list"
}];
states[name + "-qstring"] = multiLineString("'", name);
states[name + "-qqstring"] = multiLineString("\"", name);
states[name + "-attribute-list"] = [{
states[name + "embed-attribute-list"] = [{
token : "text",
regex : ">",
next : nextState

View File

@@ -125,17 +125,8 @@ oop.inherits(Mode, TextMode);
};
this.createWorker = function(session) {
var doc = session.getDocument();
var worker = new WorkerClient(["ace", "pilot"], "worker-javascript.js", "ace/mode/javascript_worker", "JavaScriptWorker");
worker.call("setValue", [doc.getValue()]);
doc.on("change", function(e) {
e.range = {
start: e.data.range.start,
end: e.data.range.end
};
worker.emit("change", e);
});
worker.attachToDocument(session.getDocument());
worker.on("jslint", function(results) {
var errors = [];

View File

@@ -46,15 +46,42 @@ var TextHighlightRules = require("ace/mode/text_highlight_rules").TextHighlightR
var JavaScriptHighlightRules = function() {
// see: https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects
var globals = lang.arrayToMap(
// Constructors
("Array|Boolean|Date|Function|Iterator|Number|Object|RegExp|String|Proxy|" +
// E4X
"Namespace|QName|XML|XMLList|" +
"ArrayBuffer|Float32Array|Float64Array|Int16Array|Int32Array|Int8Array|" +
"Uint16Array|Uint32Array|Uint8Array|Uint8ClampedArray|" +
// Errors
"Error|EvalError|InternalError|RangeError|ReferenceError|StopIteration|" +
"SyntaxError|TypeError|URIError|" +
// Non-constructor functions
"decodeURI|decodeURIComponent|encodeURI|encodeURIComponent|eval|isFinite|" +
"isNaN|parseFloat|parseInt|" +
// Other
"JSON|Math|" +
// Pseudo
"this|arguments|prototype|window|document"
).split("|")
);
var keywords = lang.arrayToMap(
("break|case|catch|continue|default|delete|do|else|finally|for|function|" +
"if|in|instanceof|new|return|switch|throw|try|typeof|let|var|while|with|" +
"const|yield|import|get|set").split("|")
);
// keywords which can be followed by regular expressions
var kwBeforeRe = "case|do|else|finally|in|instanceof|return|throw|try|typeof|yield";
var deprecated = lang.arrayToMap(
("__parent__|__count__|escape|unescape|with|__proto__").split("|")
);
var definitions = lang.arrayToMap(("const|let|var|function").split("|"));
var buildinConstants = lang.arrayToMap(
("null|Infinity|NaN|undefined").split("|")
);
@@ -109,7 +136,7 @@ var JavaScriptHighlightRules = function() {
token : "constant.numeric", // float
regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
}, {
token : ["keyword", "text", "entity.name.function"],
token : ["keyword.definition", "text", "entity.name.function"],
regex : "(function)(\\s+)(" + identifierRe + ")"
}, {
token : "constant.language.boolean",
@@ -120,8 +147,12 @@ var JavaScriptHighlightRules = function() {
next : "regex_allowed"
}, {
token : function(value) {
if (value == "this")
if (globals.hasOwnProperty(value))
return "variable.language";
else if (deprecated.hasOwnProperty(value))
return "invalid.deprecated";
else if (definitions.hasOwnProperty(value))
return "keyword.definition";
else if (keywords.hasOwnProperty(value))
return "keyword";
else if (buildinConstants.hasOwnProperty(value))
@@ -139,11 +170,15 @@ var JavaScriptHighlightRules = function() {
regex : "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|instanceof|new|delete|typeof|void)",
next : "regex_allowed"
}, {
token : "lparen",
token : "punctuation.operator",
regex : "\\?|\\:|\\,|\\;|\\.",
next : "regex_allowed"
}, {
token : "paren.lparen",
regex : "[[({]",
next : "regex_allowed"
}, {
token : "rparen",
token : "paren.rparen",
regex : "[\\])}]"
}, {
token : "keyword.operator",
@@ -161,6 +196,11 @@ var JavaScriptHighlightRules = function() {
// makes sure we don't mix up regexps with the divison operator
"regex_allowed": [
{
token : "comment", // multi line comment
merge : true,
regex : "\\/\\*",
next : "comment_regex_allowed"
}, {
token : "comment",
regex : "\\/\\/.*$"
}, {
@@ -180,10 +220,23 @@ var JavaScriptHighlightRules = function() {
next: "start"
}
],
"comment_regex_allowed" : [
{
token : "comment", // closing comment
regex : ".*?\\*\\/",
merge : true,
next : "regex_allowed"
}, {
token : "comment", // comment spanning whole line
merge : true,
regex : ".+"
}
],
"comment" : [
{
token : "comment", // closing comment
regex : ".*?\\*\\/",
merge : true,
next : "start"
}, {
token : "comment", // comment spanning whole line

View File

@@ -95,20 +95,20 @@ module.exports = {
var tokens = this.tokenizer.getLineTokens(line, "start").tokens;
assert.equal(7, tokens.length);
assert.equal("lparen", tokens[0].type);
assert.equal("lparen", tokens[1].type);
assert.equal("lparen", tokens[2].type);
assert.equal("paren.lparen", tokens[0].type);
assert.equal("paren.lparen", tokens[1].type);
assert.equal("paren.lparen", tokens[2].type);
assert.equal("text", tokens[3].type);
assert.equal("rparen", tokens[4].type);
assert.equal("rparen", tokens[5].type);
assert.equal("rparen", tokens[6].type);
assert.equal("paren.rparen", tokens[4].type);
assert.equal("paren.rparen", tokens[5].type);
assert.equal("paren.rparen", tokens[6].type);
},
"test for last rule in ruleset to catch capturing group bugs" : function() {
var tokens = this.tokenizer.getLineTokens("}", "start").tokens;
assert.equal(1, tokens.length);
assert.equal("rparen", tokens[0].type);
assert.equal("paren.rparen", tokens[0].type);
},
"test tokenize arithmetic expression which looks like a regexp": function() {
@@ -142,6 +142,15 @@ module.exports = {
assert.equal("string.regexp", tokens[2].type);
},
"test tokenize multi-line comment containing a single line comment" : function() {
var tokens = this.tokenizer.getLineTokens("/* foo // bar */", "start").tokens;
assert.equal(1, tokens.length);
assert.equal("comment", tokens[0].type);
var tokens = this.tokenizer.getLineTokens("/* foo // bar */", "regex_allowed").tokens;
assert.equal(1, tokens.length);
assert.equal("comment", tokens[0].type);
},
"test tokenize identifier with umlauts": function() {
var tokens = this.tokenizer.getLineTokens("füße", "start").tokens;
@@ -151,7 +160,7 @@ module.exports = {
"test // is not a regexp": function() {
var tokens = this.tokenizer.getLineTokens("{ // 123", "start").tokens;
assert.equal(3, tokens.length);
assert.equal("lparen", tokens[0].type);
assert.equal("paren.lparen", tokens[0].type);
assert.equal("text", tokens[1].type);
assert.equal("comment", tokens[2].type);
}

View File

@@ -67,10 +67,10 @@ var JsonHighlightRules = function() {
token : "invalid.illegal", // comments are not allowed
regex : "\\/\\/.*$"
}, {
token : "lparen",
token : "paren.lparen",
regex : "[[({]"
}, {
token : "rparen",
token : "paren.rparen",
regex : "[\\])}]"
}, {
token : "text",
@@ -84,4 +84,4 @@ var JsonHighlightRules = function() {
oop.inherits(JsonHighlightRules, TextHighlightRules);
exports.JsonHighlightRules = JsonHighlightRules;
});
});

View File

@@ -279,10 +279,10 @@ var LuaHighlightRules = function() {
token : "keyword.operator",
regex : "\\+|\\-|\\*|\\/|%|\\#|\\^|~|<|>|<=|=>|==|~=|=|\\:|\\.\\.\\.|\\.\\."
}, {
token : "lparen",
token : "paren.lparen",
regex : "[\\[\\(\\{]"
}, {
token : "rparen",
token : "paren.rparen",
regex : "[\\]\\)\\}]"
}, {
token : "text",

View File

@@ -309,11 +309,11 @@ var OcamlHighlightRules = function() {
regex : "\\+\\.|\\-\\.|\\*\\.|\\/\\.|#|;;|\\+|\\-|\\*|\\*\\*\\/|\\/\\/|%|<<|>>|&|\\||\\^|~|<|>|<=|=>|==|!=|<>|<-|="
},
{
token : "lparen",
token : "paren.lparen",
regex : "[[({]"
},
{
token : "rparen",
token : "paren.rparen",
regex : "[\\])}]"
},
{

View File

@@ -1004,10 +1004,10 @@ var PhpHighlightRules = function() {
token : "keyword.operator",
regex : "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|instanceof|new|delete|typeof|void)"
}, {
token : "lparen",
token : "paren.lparen",
regex : "[[({]"
}, {
token : "rparen",
token : "paren.rparen",
regex : "[\\])}]"
}, {
token : "text",

56
vendor/ace/mode/powershell.js vendored Normal file
View File

@@ -0,0 +1,56 @@
define(function(require, exports, module) {
var oop = require("pilot/oop");
var TextMode = require("ace/mode/text").Mode;
var Tokenizer = require("ace/tokenizer").Tokenizer;
var PowershellHighlightRules = require("ace/mode/powershell_highlight_rules").PowershellHighlightRules;
var MatchingBraceOutdent = require("ace/mode/matching_brace_outdent").MatchingBraceOutdent;
var CstyleBehaviour = require("ace/mode/behaviour/cstyle").CstyleBehaviour;
var Mode = function() {
this.$tokenizer = new Tokenizer(new PowershellHighlightRules().getRules());
this.$outdent = new MatchingBraceOutdent();
this.$behaviour = new CstyleBehaviour();
};
oop.inherits(Mode, TextMode);
(function() {
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) {
this.$outdent.autoOutdent(doc, row);
};
this.createWorker = function(session) {
return null;
};
}).call(Mode.prototype);
exports.Mode = Mode;
});

View File

@@ -0,0 +1,138 @@
define(function(require, exports, module) {
var oop = require("pilot/oop");
var lang = require("pilot/lang");
var DocCommentHighlightRules = require("ace/mode/doc_comment_highlight_rules").DocCommentHighlightRules;
var TextHighlightRules = require("ace/mode/text_highlight_rules").TextHighlightRules;
var PowershellHighlightRules = function() {
var keywords = lang.arrayToMap(
("function|if|else|elseif|switch|while|default|for|do|until|break|continue|" +
"foreach|return|filter|in|trap|throw|param|begin|process|end").split("|")
);
var builtinFunctions = lang.arrayToMap(
("Get-Alias|Import-Alias|New-Alias|Set-Alias|Get-AuthenticodeSignature|Set-AuthenticodeSignature|" +
"Set-Location|Get-ChildItem|Clear-Item|Get-Command|Measure-Command|Trace-Command|" +
"Add-Computer|Checkpoint-Computer|Remove-Computer|Restart-Computer|Restore-Computer|Stop-Computer|" +
"Reset-ComputerMachinePassword|Test-ComputerSecureChannel|Add-Content|Get-Content|Set-Content|Clear-Content|" +
"Get-Command|Invoke-Command|Enable-ComputerRestore|Disable-ComputerRestore|Get-ComputerRestorePoint|Test-Connection|" +
"ConvertFrom-CSV|ConvertTo-CSV|ConvertTo-Html|ConvertTo-Xml|ConvertFrom-SecureString|ConvertTo-SecureString|" +
"Copy-Item|Export-Counter|Get-Counter|Import-Counter|Get-Credential|Get-Culture|" +
"Get-ChildItem|Get-Date|Set-Date|Remove-Item|Compare-Object|Get-Event|" +
"Get-WinEvent|New-Event|Remove-Event|Unregister-Event|Wait-Event|Clear-EventLog|" +
"Get-Eventlog|Limit-EventLog|New-Eventlog|Remove-EventLog|Show-EventLog|Write-EventLog|" +
"Get-EventSubscriber|Register-EngineEvent|Register-ObjectEvent|Register-WmiEvent|Get-ExecutionPolicy|Set-ExecutionPolicy|" +
"Export-Alias|Export-Clixml|Export-Console|Export-Csv|ForEach-Object|Format-Custom|" +
"Format-List|Format-Table|Format-Wide|Export-FormatData|Get-FormatData|Get-Item|" +
"Get-ChildItem|Get-Help|Add-History|Clear-History|Get-History|Invoke-History|" +
"Get-Host|Read-Host|Write-Host|Get-HotFix|Import-Clixml|Import-Csv|" +
"Invoke-Command|Invoke-Expression|Get-Item|Invoke-Item|New-Item|Remove-Item|" +
"Set-Item|Clear-ItemProperty|Copy-ItemProperty|Get-ItemProperty|Move-ItemProperty|New-ItemProperty|" +
"Remove-ItemProperty|Rename-ItemProperty|Set-ItemProperty|Get-Job|Receive-Job|Remove-Job|" +
"Start-Job|Stop-Job|Wait-Job|Stop-Process|Update-List|Get-Location|" +
"Pop-Location|Push-Location|Set-Location|Send-MailMessage|Add-Member|Get-Member|" +
"Move-Item|Compare-Object|Group-Object|Measure-Object|New-Object|Select-Object|" +
"Sort-Object|Where-Object|Out-Default|Out-File|Out-GridView|Out-Host|" +
"Out-Null|Out-Printer|Out-String|Convert-Path|Join-Path|Resolve-Path|" +
"Split-Path|Test-Path|Get-Pfxcertificate|Pop-Location|Push-Location|Get-Process|" +
"Start-Process|Stop-Process|Wait-Process|Enable-PSBreakpoint|Disable-PSBreakpoint|Get-PSBreakpoint|" +
"Set-PSBreakpoint|Remove-PSBreakpoint|Get-PSDrive|New-PSDrive|Remove-PSDrive|Get-PSProvider|" +
"Set-PSdebug|Enter-PSSession|Exit-PSSession|Export-PSSession|Get-PSSession|Import-PSSession|" +
"New-PSSession|Remove-PSSession|Disable-PSSessionConfiguration|Enable-PSSessionConfiguration|Get-PSSessionConfiguration|Register-PSSessionConfiguration|" +
"Set-PSSessionConfiguration|Unregister-PSSessionConfiguration|New-PSSessionOption|Add-PsSnapIn|Get-PsSnapin|Remove-PSSnapin|" +
"Get-Random|Read-Host|Remove-Item|Rename-Item|Rename-ItemProperty|Select-Object|" +
"Select-XML|Send-MailMessage|Get-Service|New-Service|Restart-Service|Resume-Service|" +
"Set-Service|Start-Service|Stop-Service|Suspend-Service|Sort-Object|Start-Sleep|" +
"ConvertFrom-StringData|Select-String|Tee-Object|New-Timespan|Trace-Command|Get-Tracesource|" +
"Set-Tracesource|Start-Transaction|Complete-Transaction|Get-Transaction|Use-Transaction|Undo-Transaction|" +
"Start-Transcript|Stop-Transcript|Add-Type|Update-TypeData|Get-Uiculture|Get-Unique|" +
"Update-Formatdata|Update-Typedata|Clear-Variable|Get-Variable|New-Variable|Remove-Variable|" +
"Set-Variable|New-WebServiceProxy|Where-Object|Write-Debug|Write-Error|Write-Host|" +
"Write-Output|Write-Progress|Write-Verbose|Write-Warning|Set-WmiInstance|Invoke-WmiMethod|" +
"Get-WmiObject|Remove-WmiObject|Connect-WSMan|Disconnect-WSMan|Test-WSMan|Invoke-WSManAction|" +
"Disable-WSManCredSSP|Enable-WSManCredSSP|Get-WSManCredSSP|New-WSManInstance|Get-WSManInstance|Set-WSManInstance|" +
"Remove-WSManInstance|Set-WSManQuickConfig|New-WSManSessionOption").split("|"));
var binaryOperatorsRe = "eq|ne|ge|gt|lt|le|like|notlike|match|notmatch|replace|contains|notcontains|" +
"ieq|ine|ige|igt|ile|ilt|ilike|inotlike|imatch|inotmatch|ireplace|icontains|inotcontains|" +
"is|isnot|as|" +
"and|or|band|bor|not";
// regexp must not have capturing parentheses. Use (?:) instead.
// regexps are ordered -> the first match is used
this.$rules = {
"start" : [
{
token : "comment",
regex : "#.*$"
}, {
token : "string", // single line
regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'
}, {
token : "string", // single line
regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
}, {
token : "constant.numeric", // hex
regex : "0[xX][0-9a-fA-F]+\\b"
}, {
token : "constant.numeric", // float
regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
}, {
token : "constant.language.boolean",
regex : "[$](?:[Tt]rue|[Ff]alse)\\b"
}, {
token : "constant.language",
regex : "[$][Nn]ull\\b"
}, {
token : "variable.instance",
regex : "[$][a-zA-Z][a-zA-Z0-9_]*\\b"
}, {
token : function(value) {
if (keywords.hasOwnProperty(value))
return "keyword";
else if (builtinFunctions.hasOwnProperty(value))
return "support.function";
else
return "identifier";
},
// TODO: Unicode escape sequences
// TODO: Unicode identifiers
regex : "[a-zA-Z_$][a-zA-Z0-9_$\\-]*\\b"
}, {
token : "keyword.operator",
regex : "\\-(?:" + binaryOperatorsRe + ")"
}, {
token : "keyword.operator",
regex : "&|\\*|\\+|\\-|\\=|\\+=|\\-="
}, {
token : "lparen",
regex : "[[({]"
}, {
token : "rparen",
regex : "[\\])}]"
}, {
token : "text",
regex : "\\s+"
}
],
"comment" : [
{
token : "comment", // closing comment
regex : ".*?\\*\\/",
next : "start"
}, {
token : "comment", // comment spanning whole line
merge : true,
regex : ".+"
}
]
};
};
oop.inherits(PowershellHighlightRules, TextHighlightRules);
exports.PowershellHighlightRules = PowershellHighlightRules;
});

View File

@@ -145,10 +145,10 @@ var PythonHighlightRules = function() {
token : "keyword.operator",
regex : "\\+|\\-|\\*|\\*\\*|\\/|\\/\\/|%|<<|>>|&|\\||\\^|~|<|>|<=|=>|==|!=|<>|="
}, {
token : "lparen",
token : "lparen.paren",
regex : "[\\[\\(\\{]"
}, {
token : "rparen",
token : "paren.rparen",
regex : "[\\]\\)\\}]"
}, {
token : "text",
@@ -178,4 +178,4 @@ var PythonHighlightRules = function() {
oop.inherits(PythonHighlightRules, TextHighlightRules);
exports.PythonHighlightRules = PythonHighlightRules;
});
});

View File

@@ -163,10 +163,10 @@ var RubyHighlightRules = function() {
token : "keyword.operator",
regex : "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|instanceof|new|delete|typeof|void)"
}, {
token : "lparen",
token : "paren.lparen",
regex : "[[({]"
}, {
token : "rparen",
token : "paren.rparen",
regex : "[\\])}]"
}, {
token : "text",

View File

@@ -112,10 +112,10 @@ var scadHighlightRules = function() {
token : "keyword.operator",
regex : "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|==|=|!=|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|new|delete|typeof|void)"
}, {
token : "lparen",
token : "paren.lparen",
regex : "[[({]"
}, {
token : "rparen",
token : "paren.rparen",
regex : "[\\])}]"
}, {
token : "text",

View File

@@ -110,10 +110,10 @@ var ScalaHighlightRules = function() {
token : "keyword.operator",
regex : "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|instanceof|new|delete|typeof|void)"
}, {
token : "lparen",
token : "paren.lparen",
regex : "[[({]"
}, {
token : "rparen",
token : "paren.rparen",
regex : "[\\])}]"
}, {
token : "text",

View File

@@ -310,10 +310,10 @@ var ScssHighlightRules = function() {
token : "keyword.operator",
regex : "<|>|<=|>=|==|!=|-|%|#|\\+|\\$|\\+|\\*"
}, {
token : "lparen",
token : "paren.lparen",
regex : "[[({]"
}, {
token : "rparen",
token : "paren.rparen",
regex : "[\\])}]"
}, {
token : "text",

68
vendor/ace/mode/sql.js vendored Normal file
View File

@@ -0,0 +1,68 @@
/* ***** BEGIN LICENSE BLOCK *****
* The Original Code is Ajax.org Code Editor (ACE).
*
* Contributor(s):
* Jonathan Camile <jonathan.camile AT gmail DOT 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 oop = require("pilot/oop");
var TextMode = require("ace/mode/text").Mode;
var Tokenizer = require("ace/tokenizer").Tokenizer;
var SqlHighlightRules = require("ace/mode/sql_highlight_rules").SqlHighlightRules;
var Range = require("ace/range").Range;
var Mode = function() {
this.$tokenizer = new Tokenizer(new SqlHighlightRules().getRules());
};
oop.inherits(Mode, TextMode);
(function() {
this.toggleCommentLines = function(state, doc, startRow, endRow) {
var outdent = true;
var outentedRows = [];
var re = /^(\s*)--/;
for (var i=startRow; i<= endRow; i++) {
if (!re.test(doc.getLine(i))) {
outdent = false;
break;
}
}
if (outdent) {
var deleteRange = new Range(0, 0, 0, 0);
for (var i=startRow; i<= endRow; i++)
{
var line = doc.getLine(i);
var m = line.match(re);
deleteRange.start.row = i;
deleteRange.end.row = i;
deleteRange.end.column = m[0].length;
doc.replace(deleteRange, m[1]);
}
}
else {
doc.indentRows(startRow, endRow, "--");
}
};
}).call(Mode.prototype);
exports.Mode = Mode;
});

90
vendor/ace/mode/sql_highlight_rules.js vendored Normal file
View File

@@ -0,0 +1,90 @@
/* ***** BEGIN LICENSE BLOCK *****
* The Original Code is Ajax.org Code Editor (ACE).
*
* Contributor(s):
* Jonathan Camile <jonathan.camile AT gmail DOT 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 oop = require("pilot/oop");
var lang = require("pilot/lang");
var TextHighlightRules = require("ace/mode/text_highlight_rules").TextHighlightRules;
var SqlHighlightRules = function() {
var keywords = lang.arrayToMap(
("select|from|where|and|or|group|by|order|limit|offset|having|as|case|" +
"when|else|end|type|left|right|join|on|outer|desc|asc").split("|")
);
var builtinConstants = lang.arrayToMap(
("true|false|null").split("|")
);
var builtinFunctions = lang.arrayToMap(
("count|min|max|avg|sum|rank|now|coalesce").split("|")
);
this.$rules = {
"start" : [ {
token : "comment",
regex : "--.*$"
}, {
token : "string", // " string
regex : '".*"'
}, {
token : "string", // ' string
regex : "'.*'"
}, {
token : "constant.numeric", // float
regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
}, {
token : function(value) {
value = value.toLowerCase();
if (keywords.hasOwnProperty(value))
return "keyword";
else if (builtinConstants.hasOwnProperty(value))
return "constant.language";
else if (builtinFunctions.hasOwnProperty(value))
return "support.function";
else
return "identifier";
},
regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
}, {
token : "keyword.operator",
regex : "\\+|\\-|\\/|\\/\\/|%|<@>|@>|<@|&|\\^|~|<|>|<=|=>|==|!=|<>|="
}, {
token : "lparen.paren",
regex : "[\\(]"
}, {
token : "paren.rparen",
regex : "[\\)]"
}, {
token : "text",
regex : "\\s+"
} ]
};
};
oop.inherits(SqlHighlightRules, TextHighlightRules);
exports.SqlHighlightRules = SqlHighlightRules;
});

View File

@@ -206,13 +206,12 @@ var Mode = function() {
for (var key in behaviours) {
if (behaviours[key][action]) {
var ret = behaviours[key][action].apply(this, arguments);
if (ret !== false) {
if (ret) {
return ret;
}
}
}
}
return false;
}
}).call(Mode.prototype);

303
vendor/ace/mouse/default_handlers.js vendored Normal file
View File

@@ -0,0 +1,303 @@
/* vim:ts=4:sts=4:sw=4:
* ***** 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 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>
* Mike de Boer <mike 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 event = require("pilot/event");
var dom = require("pilot/dom");
var EventEmitter = require("pilot/event_emitter").EventEmitter;
var BrowserFocus = require("pilot/browser_focus").BrowserFocus;
var STATE_UNKNOWN = 0;
var STATE_SELECT = 1;
var STATE_DRAG = 2;
var DRAG_TIMER = 250; // milliseconds
var DRAG_OFFSET = 5; // pixels
function DefaultHandlers(editor) {
this.editor = editor;
this.$clickSelection = null;
this.browserFocus = new BrowserFocus();
editor.setDefaultHandler("mousedown", this.onMouseDown.bind(this));
editor.setDefaultHandler("dblclick", this.onDoubleClick.bind(this));
editor.setDefaultHandler("tripleclick", this.onTripleClick.bind(this));
editor.setDefaultHandler("quadclick", this.onQuadClick.bind(this));
editor.setDefaultHandler("mousewheel", this.onScroll.bind(this));
}
(function() {
this.onMouseDown = function(ev) {
var inSelection = ev.inSelection();
var pageX = ev.pageX;
var pageY = ev.pageY;
var pos = ev.getDocumentPosition();
var editor = this.editor;
var _self = this;
var selectionRange = editor.getSelectionRange();
var selectionEmpty = selectionRange.isEmpty();
var state = STATE_UNKNOWN;
// if this click caused the editor to be focused should not clear the
// selection
if (
inSelection && (
!this.browserFocus.isFocused()
|| new Date().getTime() - this.browserFocus.lastFocus < 20
|| !editor.isFocused()
)
) {
editor.focus();
return;
}
var button = ev.getButton();
if (button !== 0) {
if (selectionEmpty) {
editor.moveCursorToPosition(pos);
}
if(button == 2) {
editor.textInput.onContextMenu({x: pageX, y: pageY}, selectionEmpty);
event.capture(editor.container, function(){}, editor.textInput.onContextMenuClose);
}
return;
}
else {
// Select the fold as the user clicks it.
var fold = editor.session.getFoldAt(pos.row, pos.column, 1);
if (fold) {
editor.selection.setSelectionRange(fold.range);
return;
}
}
if (!inSelection) {
// Directly pick STATE_SELECT, since the user is not clicking inside
// a selection.
onStartSelect(pos);
}
var mousePageX = pageX, mousePageY = pageY;
var overwrite = editor.getOverwrite();
var mousedownTime = (new Date()).getTime();
var dragCursor, dragRange;
var onMouseSelection = function(e) {
mousePageX = event.getDocumentX(e);
mousePageY = event.getDocumentY(e);
};
var onMouseSelectionEnd = function(e) {
clearInterval(timerId);
if (state == STATE_UNKNOWN)
onStartSelect(pos);
else if (state == STATE_DRAG)
onMouseDragSelectionEnd(e);
_self.$clickSelection = null;
state = STATE_UNKNOWN;
};
var onMouseDragSelectionEnd = function(e) {
dom.removeCssClass(editor.container, "ace_dragging");
editor.session.removeMarker(dragSelectionMarker);
if (!editor.$mouseHandler.$clickSelection) {
if (!dragCursor) {
editor.moveCursorToPosition(pos);
editor.selection.clearSelection(pos.row, pos.column);
}
}
if (!dragCursor)
return;
if (dragRange.contains(dragCursor.row, dragCursor.column)) {
dragCursor = null;
return;
}
editor.clearSelection();
if (e && (e.ctrlKey || e.altKey)) {
var session = editor.session;
var newRange = session.insert(dragCursor, session.getTextRange(dragRange));
} else {
var newRange = editor.moveText(dragRange, dragCursor);
}
if (!newRange) {
dragCursor = null;
return;
}
editor.selection.setSelectionRange(newRange);
};
var onSelectionInterval = function() {
if (state == STATE_UNKNOWN) {
var distance = calcDistance(pageX, pageY, mousePageX, mousePageY);
var time = (new Date()).getTime();
if (distance > DRAG_OFFSET) {
state = STATE_SELECT;
var cursor = editor.renderer.screenToTextCoordinates(mousePageX, mousePageY);
cursor.row = Math.max(0, Math.min(cursor.row, editor.session.getLength()-1));
onStartSelect(cursor);
}
else if ((time - mousedownTime) > DRAG_TIMER) {
state = STATE_DRAG;
dragRange = editor.getSelectionRange();
var style = editor.getSelectionStyle();
dragSelectionMarker = editor.session.addMarker(dragRange, "ace_selection", style);
editor.clearSelection();
dom.addCssClass(editor.container, "ace_dragging");
}
}
if (state == STATE_DRAG)
onDragSelectionInterval();
else if (state == STATE_SELECT)
onUpdateSelectionInterval();
};
function onStartSelect(pos) {
if (ev.getShiftKey()) {
editor.selection.selectToPosition(pos);
}
else {
if (!_self.$clickSelection) {
editor.moveCursorToPosition(pos);
editor.selection.clearSelection(pos.row, pos.column);
}
}
state = STATE_SELECT;
}
var onUpdateSelectionInterval = function() {
var anchor;
var cursor = editor.renderer.screenToTextCoordinates(mousePageX, mousePageY);
cursor.row = Math.max(0, Math.min(cursor.row, editor.session.getLength()-1));
if (_self.$clickSelection) {
if (_self.$clickSelection.contains(cursor.row, cursor.column)) {
editor.selection.setSelectionRange(_self.$clickSelection);
}
else {
if (_self.$clickSelection.compare(cursor.row, cursor.column) == -1) {
anchor = _self.$clickSelection.end;
}
else {
anchor = _self.$clickSelection.start;
}
editor.selection.setSelectionAnchor(anchor.row, anchor.column);
editor.selection.selectToPosition(cursor);
}
}
else {
editor.selection.selectToPosition(cursor);
}
editor.renderer.scrollCursorIntoView();
};
var onDragSelectionInterval = function() {
dragCursor = editor.renderer.screenToTextCoordinates(mousePageX, mousePageY);
dragCursor.row = Math.max(0, Math.min(dragCursor.row, editor.session.getLength() - 1));
editor.moveCursorToPosition(dragCursor);
};
event.capture(editor.container, onMouseSelection, onMouseSelectionEnd);
var timerId = setInterval(onSelectionInterval, 20);
return ev.preventDefault();
};
this.onDoubleClick = function(ev) {
var pos = ev.getDocumentPosition();
var editor = this.editor;
// If the user dclicked on a fold, then expand it.
var fold = editor.session.getFoldAt(pos.row, pos.column, 1);
if (fold) {
editor.session.expandFold(fold);
}
else {
editor.moveCursorToPosition(pos);
editor.selection.selectWord();
this.$clickSelection = editor.getSelectionRange();
}
};
this.onTripleClick = function(ev) {
var pos = ev.getDocumentPosition();
var editor = this.editor;
editor.moveCursorToPosition(pos);
editor.selection.selectLine();
this.$clickSelection = editor.getSelectionRange();
};
this.onQuadClick = function(ev) {
var editor = this.editor;
editor.selectAll();
this.$clickSelection = editor.getSelectionRange();
};
this.onScroll = function(ev) {
var editor = this.editor;
editor.renderer.scrollBy(ev.wheelX * ev.speed, ev.wheelY * ev.speed);
if (editor.renderer.isScrollableBy(ev.wheelX * ev.speed, ev.wheelY * ev.speed))
return ev.preventDefault();
};
}).call(DefaultHandlers.prototype);
exports.DefaultHandlers = DefaultHandlers;
function calcDistance(ax, ay, bx, by) {
return Math.sqrt(Math.pow(bx - ax, 2) + Math.pow(by - ay, 2));
}
});

0
vendor/ace/mouse/dragdrop.js vendored Normal file
View File

133
vendor/ace/mouse/mouse_event.js vendored Normal file
View File

@@ -0,0 +1,133 @@
/* vim:ts=4:sts=4:sw=4:
* ***** 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 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 event = require("pilot/event");
var dom = require("pilot/dom");
/**
* Custom Ace mouse event
*/
var MouseEvent = exports.MouseEvent = function(domEvent, editor) {
this.domEvent = domEvent;
this.editor = editor;
this.pageX = event.getDocumentX(domEvent);
this.pageY = event.getDocumentY(domEvent);
this.$pos = null;
this.$inSelection = null;
this.propagationStopped = false;
this.defaultPrevented = false;
};
(function() {
this.stopPropagation = function() {
event.stopPropagation(this.domEvent);
this.propagationStopped = true;
};
this.preventDefault = function() {
event.preventDefault(this.domEvent);
this.defaultPrevented = true;
};
/**
* Get the document position below the mouse cursor
*
* @return {Object} 'row' and 'column' of the document position
*/
this.getDocumentPosition = function() {
if (this.$pos)
return this.$pos;
var pageX = event.getDocumentX(this.domEvent);
var pageY = event.getDocumentY(this.domEvent);
this.$pos = this.editor.renderer.screenToTextCoordinates(pageX, pageY);
this.$pos.row = Math.max(0, Math.min(this.$pos.row, this.editor.session.getLength()-1));
return this.$pos;
};
/**
* Check if the mouse cursor is inside of the text selection
*
* @return {Boolean} whether the mouse cursor is inside of the selection
*/
this.inSelection = function() {
if (this.$inSelection !== null)
return this.$inSelection;
var editor = this.editor;
if (editor.getReadOnly()) {
this.$inSelection = false;
}
else {
var selectionRange = editor.getSelectionRange();
if (selectionRange.isEmpty())
this.$inSelection = false;
else {
var pos = this.getDocumentPosition();
this.$inSelection = selectionRange.contains(pos.row, pos.column);
}
}
return this.$inSelection;
};
/**
* Get the clicked mouse button
*
* @return {Number} 0 for left button, 1 for middle button, 2 for right button
*/
this.getButton = function() {
return event.getButton(this.domEvent);
};
/**
* @return {Boolean} whether the shift key was pressed when the event was emitted
*/
this.getShiftKey = function() {
return this.domEvent.shiftKey;
};
}).call(MouseEvent.prototype);
});

115
vendor/ace/mouse/mouse_handler.js vendored Normal file
View File

@@ -0,0 +1,115 @@
/* vim:ts=4:sts=4:sw=4:
* ***** 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 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>
* Mihai Sucan <mihai DOT sucan AT gmail DOT 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 event = require("pilot/event");
var DefaultHandlers = require("ace/mouse/default_handlers").DefaultHandlers;
var MouseEvent = require("ace/mouse/mouse_event").MouseEvent;
var MouseHandler = function(editor) {
this.editor = editor;
this.defaultHandlers = new DefaultHandlers(editor);
event.addListener(editor.container, "mousedown", function(e) {
editor.focus();
return event.preventDefault(e);
});
event.addListener(editor.container, "selectstart", function(e) {
return event.preventDefault(e);
});
var mouseTarget = editor.renderer.getMouseEventTarget();
event.addListener(mouseTarget, "mousedown", this.onMouseDown.bind(this));
event.addListener(mouseTarget, "mousemove", this.onMouseMove.bind(this));
event.addMultiMouseDownListener(mouseTarget, 0, 2, 500, this.onMouseDoubleClick.bind(this));
event.addMultiMouseDownListener(mouseTarget, 0, 3, 600, this.onMouseTripleClick.bind(this));
event.addMultiMouseDownListener(mouseTarget, 0, 4, 600, this.onMouseQuadClick.bind(this));
event.addMouseWheelListener(editor.container, this.onMouseWheel.bind(this));
};
(function() {
this.$scrollSpeed = 1;
this.setScrollSpeed = function(speed) {
this.$scrollSpeed = speed;
};
this.getScrollSpeed = function() {
return this.$scrollSpeed;
};
this.onMouseDown = function(e) {
this.editor._dispatchEvent("mousedown", new MouseEvent(e, this.editor));
};
this.onMouseMove = function(e) {
// optimization, because mousemove doesn't have a default handler.
var listeners = this.editor._eventRegistry && this.editor._eventRegistry["mousemove"];
if (!listeners || !listeners.length)
return;
this.editor._dispatchEvent("mousemove", new MouseEvent(e, this.editor));
};
this.onMouseDoubleClick = function(e) {
this.editor._dispatchEvent("dblclick", new MouseEvent(e, this.editor));
};
this.onMouseTripleClick = function(e) {
this.editor._dispatchEvent("tripleclick", new MouseEvent(e, this.editor));
};
this.onMouseQuadClick = function(e) {
this.editor._dispatchEvent("quadclick", new MouseEvent(e, this.editor));
};
this.onMouseWheel = function(e) {
var mouseEvent = new MouseEvent(e, this.editor);
mouseEvent.speed = this.$scrollSpeed * 2;
mouseEvent.wheelX = e.wheelX;
mouseEvent.wheelY = e.wheelY;
this.editor._dispatchEvent("mousewheel", mouseEvent);
};
}).call(MouseHandler.prototype);
exports.MouseHandler = MouseHandler;
});

7
vendor/ace/range.js vendored
View File

@@ -102,9 +102,12 @@ var Range = function(startRow, startColumn, endRow, endColumn) {
}
}
this.comparePoint = function(p) {
return this.compare(p.row, p.column);
}
this.containsRange = function(range) {
var cmp = this.compareRange(range);
return (cmp == -1 || cmp == 0 || cmp == 1);
return this.comparePoint(range.start) == 0 && this.comparePoint(range.end) == 0;
}
this.isEnd = function(row, column) {

View File

@@ -20,6 +20,7 @@
*
* Contributor(s):
* Fabian Jakobs <fabian AT ajax DOT org>
* Irakli Gozalishvili <rfobic@gmail.com> (http://jeditoolkit.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
@@ -39,10 +40,11 @@ define(function(require, exports, module) {
var event = require("pilot/event");
var RenderLoop = function(onRender) {
var RenderLoop = function(onRender, window) {
this.onRender = onRender;
this.pending = false;
this.changes = 0;
this.setTimeoutZero = this.setTimeoutZero.bind(window);
};
(function() {
@@ -70,31 +72,31 @@ var RenderLoop = function(onRender) {
window.msRequestAnimationFrame;
if (this.setTimeoutZero) {
this.setTimeoutZero = this.setTimeoutZero.bind(window)
this.setTimeoutZero = this.setTimeoutZero;
} else if (window.postMessage) {
this.messageName = "zero-timeout-message";
this.setTimeoutZero = (function(messageName, attached, listener) {
return function setTimeoutZero(callback) {
// Set up listener if not listening already.
if (!attached) {
event.addListener(this, "message", function(e) {
if (listener && e.data == messageName) {
event.stopPropagation(e);
listener();
}
});
attached = true;
}
this.setTimeoutZero = function(callback) {
if (!this.attached) {
var _self = this;
event.addListener(window, "message", function(e) {
if (_self.callback && e.data == _self.messageName) {
event.stopPropagation(e);
_self.callback();
}
});
this.attached = true;
}
this.callback = callback;
window.postMessage(this.messageName, "*");
}
listener = callback;
this.postMessage(messageName, "*");
};
})("zero-timeout-message", false, null);
} else {
this.setTimeoutZero = function(callback) {
setTimeout(callback, 0);
this.setTimeout(callback, 0);
}
}

View File

@@ -20,6 +20,7 @@
*
* Contributor(s):
* Fabian Jakobs <fabian AT ajax DOT org>
* Irakli Gozalishvili <rfobic@gmail.com> (http://jeditoolkit.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
@@ -56,7 +57,7 @@ var ScrollBar = function(parent) {
// of 0px
// in Firefox 6+ scrollbar is hidden if element has the same width as scrollbar
// make element a little bit wider to retain scrollbar when page is zoomed
this.width = dom.scrollbarWidth();
this.width = dom.scrollbarWidth(parent.ownerDocument);
this.element.style.width = (this.width || 15) + 5 + "px";
event.addListener(this.element, "scroll", this.onScroll.bind(this));

26
vendor/ace/search.js vendored
View File

@@ -89,29 +89,27 @@ Search.SELECTION = 2;
};
this.findAll = function(session) {
if (!this.$options.needle)
var options = this.$options;
if (!options.needle)
return [];
if (this.$options.backwards) {
if (options.backwards) {
var iterator = this.$backwardMatchIterator(session);
} else {
iterator = this.$forwardMatchIterator(session);
}
var ignoreCursorColumn = false && this.$options.wrap && this.$options.scope == Search.ALL;
var start = session.getSelection().getCursor();
if (ignoreCursorColumn) {
session.getSelection().moveCursorTo(0, 0);
}
var ignoreCursor = !options.start && options.wrap && options.scope == Search.ALL;
if (ignoreCursor)
options.start = {row: 0, column: 0};
var ranges = [];
iterator.forEach(function(range) {
ranges.push(range);
});
if (ignoreCursorColumn) {
session.getSelection().moveCursorTo(start.row, start.column)
}
if (ignoreCursor)
options.start = null;
return ranges;
};
@@ -223,8 +221,8 @@ Search.SELECTION = 2;
this.$forwardLineIterator = function(session) {
var searchSelection = this.$options.scope == Search.SELECTION;
var range = session.getSelection().getRange();
var start = session.getSelection().getCursor();
var range = this.$options.range || session.getSelection().getRange();
var start = this.$options.start || session.getSelection().getCursor();
var firstRow = searchSelection ? range.start.row : 0;
var firstColumn = searchSelection ? range.start.column : 0;
@@ -285,8 +283,8 @@ Search.SELECTION = 2;
this.$backwardLineIterator = function(session) {
var searchSelection = this.$options.scope == Search.SELECTION;
var range = session.getSelection().getRange();
var start = searchSelection ? range.end : range.start;
var range = this.$options.range || session.getSelection().getRange();
var start = this.$options.start || session.getSelection().getCursor();
var firstRow = searchSelection ? range.start.row : 0;
var firstColumn = searchSelection ? range.start.column : 0;

View File

@@ -123,7 +123,7 @@ var Selection = function(session) {
};
var anchor = this.getSelectionAnchor();
var lead = this.getSelectionLead();
var lead = this.getSelectionLead();
var isBackwards = this.isBackwards();
@@ -440,9 +440,26 @@ var Selection = function(session) {
this.selectionLead.row,
this.selectionLead.column
);
var screenCol = (chars == 0 && this.$desiredColumn) || screenPos.column;
var screenCol = (chars === 0 && this.$desiredColumn) || screenPos.column;
// so here is the deal. First checkout what the content of ur current and ur target line is
var currentLine = (this.session.getLines(screenPos.row, screenPos.row) || [""])[0],
targetLine = (this.session.getLines(screenPos.row + rows, screenPos.row + rows) || [""])[0];
// if you are at the EOL of your current line, and your targetline is all whitespace
if (currentLine && targetLine &&
currentLine.length === screenPos.column && targetLine.match(/^\s*$/)) {
// set the new column to the EOL of the target line
screenCol = this.session.getTabString(targetLine).length;
// update the chars so we are sure that the desired column will be updated
chars = 1;
};
var docPos = this.session.screenToDocumentPosition(screenPos.row + rows, screenCol);
this.moveCursorTo(docPos.row, docPos.column + chars, chars == 0);
// move the cursor and update the desired column
this.moveCursorTo(docPos.row, docPos.column + chars, chars === 0);
};
this.moveCursorToPosition = function(position) {

View File

@@ -442,6 +442,42 @@ module.exports = {
selection.moveCursorUp();
selection.moveCursorDown();
assert.position(selection.getCursor(), 1, 4);
},
"test (keyboard navigation) when curLine is EOL and targetLine is all whitespace new column should be targetLine's EOL": function() {
var session = new EditSession("function (a) {\n\
\n\
}");
var selection = session.getSelection();
selection.moveCursorTo(2, 1);
selection.moveCursorUp();
assert.position(selection.getCursor(), 1, 4);
},
"test (keyboard navigation) when curLine is not EOL and targetLine is all whitespace new column should be current column": function() {
var session = new EditSession("function (a) {\n\
\n\
}");
var selection = session.getSelection();
selection.moveCursorTo(2, 0);
selection.moveCursorUp();
assert.position(selection.getCursor(), 1, 0);
},
"test (keyboard navigation) when curLine is EOL and targetLine is shorter dan current column, new column should be targetLine's EOL": function() {
var session = new EditSession("function (a) {\n\
\n\
}");
var selection = session.getSelection();
selection.moveCursorTo(0, 14);
selection.moveCursorDown();
assert.position(selection.getCursor(), 1, 4);
}
};

View File

@@ -161,4 +161,8 @@ MockRenderer.prototype.textToScreenCoordinates = function() {
}
};
MockRenderer.prototype.adjustWrapLimit = function () {
};
});

View File

@@ -27,8 +27,7 @@
var require = {
paths: {
ace: "../",
cockpit: "../../../../support/cockpit/lib/cockpit",
pilot: "../../../../support/pilot/lib/pilot"
pilot: "../../../support/pilot/lib/pilot"
},
packages : [{
name: "asyncjs",
@@ -41,7 +40,7 @@
}]
};
</script>
<script src="../../../demo/require.js" data-main="all_browser" type="text/javascript" charset="utf-8"></script>
<script src="../../../demo/kitchen-sink/require.js" data-main="all_browser" type="text/javascript" charset="utf-8"></script>
</body>

View File

@@ -37,9 +37,8 @@
define(function(require, exports, module) {
var dom = require("pilot/dom");
var cssText = ".ace-clouds .ace_editor {\
exports.cssClass = "ace-clouds";
exports.cssText = ".ace-clouds .ace_editor {\
border: 2px solid rgb(159, 159, 159);\
}\
\
@@ -252,8 +251,4 @@ define(function(require, exports, module) {
\
}";
// import CSS once
dom.importCssString(cssText);
exports.cssClass = "ace-clouds";
});
});

View File

@@ -37,9 +37,8 @@
define(function(require, exports, module) {
var dom = require("pilot/dom");
var cssText = ".ace-clouds-midnight .ace_editor {\
exports.cssClass = "ace-clouds-midnight";
exports.cssText = ".ace-clouds-midnight .ace_editor {\
border: 2px solid rgb(159, 159, 159);\
}\
\
@@ -253,8 +252,4 @@ background-color:#E92E2E;\
\
}";
// import CSS once
dom.importCssString(cssText);
exports.cssClass = "ace-clouds-midnight";
});
});

View File

@@ -37,9 +37,8 @@
define(function(require, exports, module) {
var dom = require("pilot/dom");
var cssText = ".ace-cobalt .ace_editor {\
exports.cssClass = "ace-cobalt";
exports.cssText = ".ace-cobalt .ace_editor {\
border: 2px solid rgb(159, 159, 159);\
}\
\
@@ -255,8 +254,4 @@ background-color:#001221;\
\
}";
// import CSS once
dom.importCssString(cssText);
exports.cssClass = "ace-cobalt";
});
});

View File

@@ -37,9 +37,7 @@
define(function(require, exports, module) {
var dom = require("pilot/dom");
var cssText = ".ace-crimson-editor .ace_editor {\
exports.cssText = ".ace-crimson-editor .ace_editor {\
border: 2px solid rgb(159, 159, 159);\
}\
\
@@ -195,8 +193,6 @@ define(function(require, exports, module) {
color: rgb(192, 0, 192);\
}";
// Import CSS once.
dom.importCssString(cssText);
exports.cssClass = "ace-crimson-editor";
exports.cssClass = "ace-crimson-editor";
});

View File

@@ -37,9 +37,7 @@
define(function(require, exports, module) {
var dom = require("pilot/dom");
var cssText = ".ace-dawn .ace_editor {\
exports.cssText = ".ace-dawn .ace_editor {\
border: 2px solid rgb(159, 159, 159);\
}\
\
@@ -258,8 +256,6 @@ color:#5A525F;\
\
}";
// import CSS once
dom.importCssString(cssText);
exports.cssClass = "ace-dawn";
exports.cssClass = "ace-dawn";
});
});

View File

@@ -37,9 +37,7 @@
define(function(require, exports, module) {
var dom = require("pilot/dom");
var cssText = ".ace-eclipse .ace_editor {\
exports.cssText = ".ace-eclipse .ace_editor {\
border: 2px solid rgb(159, 159, 159);\
}\
\
@@ -143,8 +141,6 @@ define(function(require, exports, module) {
background: rgb(232, 242, 254);\
}";
// import CSS once
dom.importCssString(cssText);
exports.cssClass = "ace-eclipse";
exports.cssClass = "ace-eclipse";
});

View File

@@ -37,9 +37,7 @@
define(function(require, exports, module) {
var dom = require("pilot/dom");
var cssText = ".ace-idle-fingers .ace_editor {\
exports.cssText = ".ace-idle-fingers .ace_editor {\
border: 2px solid rgb(159, 159, 159);\
}\
\
@@ -255,8 +253,6 @@ color:#BC9458;\
background-color:#FFF980; \
}";
// import CSS once
dom.importCssString(cssText);
exports.cssClass = "ace-idle-fingers";
exports.cssClass = "ace-idle-fingers";
});
});

View File

@@ -37,9 +37,7 @@
define(function(require, exports, module) {
var dom = require("pilot/dom");
var cssText = ".ace-kr-theme .ace_editor {\
exports.cssText = ".ace-kr-theme .ace_editor {\
border: 2px solid rgb(159, 159, 159);\
}\
\
@@ -254,8 +252,6 @@ color:#706D5B;\
\
}";
// import CSS once
dom.importCssString(cssText);
exports.cssClass = "ace-kr-theme";
exports.cssClass = "ace-kr-theme";
});
});

View File

@@ -37,9 +37,7 @@
define(function(require, exports, module) {
var dom = require("pilot/dom");
var cssText = ".ace-merbivore .ace_editor {\
exports.cssText = ".ace-merbivore .ace_editor {\
border: 2px solid rgb(159, 159, 159);\
}\
\
@@ -246,8 +244,6 @@ background-color:#990000;\
\
}";
// import CSS once
dom.importCssString(cssText);
exports.cssClass = "ace-merbivore";
exports.cssClass = "ace-merbivore";
});
});

View File

@@ -37,9 +37,7 @@
define(function(require, exports, module) {
var dom = require("pilot/dom");
var cssText = ".ace-merbivore-soft .ace_editor {\
exports.cssText = ".ace-merbivore-soft .ace_editor {\
border: 2px solid rgb(159, 159, 159);\
}\
\
@@ -246,8 +244,6 @@ background-color:#FE3838;\
\
}";
// import CSS once
dom.importCssString(cssText);
exports.cssClass = "ace-merbivore-soft";
exports.cssClass = "ace-merbivore-soft";
});
});

View File

@@ -37,9 +37,7 @@
define(function(require, exports, module) {
var dom = require("pilot/dom");
var cssText = ".ace-mono-industrial .ace_editor {\
exports.cssText = ".ace-mono-industrial .ace_editor {\
border: 2px solid rgb(159, 159, 159);\
}\
\
@@ -254,8 +252,6 @@ background-color:#151C19;\
\
}";
// import CSS once
dom.importCssString(cssText);
exports.cssClass = "ace-mono-industrial";
exports.cssClass = "ace-mono-industrial";
});
});

View File

@@ -37,9 +37,7 @@
define(function(require, exports, module) {
var dom = require("pilot/dom");
var cssText = ".ace-monokai .ace_editor {\
exports.cssText = ".ace-monokai .ace_editor {\
border: 2px solid rgb(159, 159, 159);\
}\
\
@@ -254,8 +252,6 @@ background-color:#AE81FF;\
\
}";
// import CSS once
dom.importCssString(cssText);
exports.cssClass = "ace-monokai";
exports.cssClass = "ace-monokai";
});
});

View File

@@ -37,9 +37,7 @@
define(function(require, exports, module) {
var dom = require("pilot/dom");
var cssText = ".ace-pastel-on-dark .ace_editor {\
exports.cssText = ".ace-pastel-on-dark .ace_editor {\
border: 2px solid rgb(159, 159, 159);\
}\
\
@@ -195,8 +193,6 @@ color:#D2A8A1;\
color:#494949;\
}";
// import CSS once
dom.importCssString(cssText);
exports.cssClass = "ace-pastel-on-dark";
exports.cssClass = "ace-pastel-on-dark";
});

View File

@@ -37,9 +37,7 @@
define(function(require, exports, module) {
var dom = require("pilot/dom");
var cssText = ".ace-solarized-dark .ace_editor {\
exports.cssText = ".ace-solarized-dark .ace_editor {\
border: 2px solid rgb(159, 159, 159);\
}\
\
@@ -253,8 +251,6 @@ color:#657B83;\
\
}";
// import CSS once
dom.importCssString(cssText);
exports.cssClass = "ace-solarized-dark";
exports.cssClass = "ace-solarized-dark";
});
});

View File

@@ -37,9 +37,7 @@
define(function(require, exports, module) {
var dom = require("pilot/dom");
var cssText = ".ace-solarized-light .ace_editor {\
exports.cssText = ".ace-solarized-light .ace_editor {\
border: 2px solid rgb(159, 159, 159);\
}\
\
@@ -252,8 +250,6 @@ define(function(require, exports, module) {
\
}";
// import CSS once
dom.importCssString(cssText);
exports.cssClass = "ace-solarized-light";
exports.cssClass = "ace-solarized-light";
});
});

View File

@@ -37,9 +37,9 @@
define(function(require, exports, module) {
var dom = require("pilot/dom");
var cssText = ".ace-tm .ace_editor {\
exports.cssClass = "ace-tm";
exports.cssText = ".ace-tm .ace_editor {\
border: 2px solid rgb(159, 159, 159);\
}\
\
@@ -206,8 +206,4 @@ define(function(require, exports, module) {
color: rgb(255, 0, 0)\
}";
// import CSS once
dom.importCssString(cssText);
exports.cssClass = "ace-tm";
});

256
vendor/ace/theme/tomorrow.js vendored Normal file
View File

@@ -0,0 +1,256 @@
/* ***** 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 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) {
exports.cssText = ".ace-tomorrow .ace_editor {\
border: 2px solid rgb(159, 159, 159);\
}\
\
.ace-tomorrow .ace_editor.ace_focus {\
border: 2px solid #327fbd;\
}\
\
.ace-tomorrow .ace_gutter {\
width: 50px;\
background: #e8e8e8;\
color: #333;\
overflow : hidden;\
}\
\
.ace-tomorrow .ace_gutter-layer {\
width: 100%;\
text-align: right;\
}\
\
.ace-tomorrow .ace_gutter-layer .ace_gutter-cell {\
padding-right: 6px;\
}\
\
.ace-tomorrow .ace_print_margin {\
width: 1px;\
background: #e8e8e8;\
}\
\
.ace-tomorrow .ace_scroller {\
background-color: #FFFFFF;\
}\
\
.ace-tomorrow .ace_text-layer {\
cursor: text;\
color: #4D4D4C;\
}\
\
.ace-tomorrow .ace_cursor {\
border-left: 2px solid #AEAFAD;\
}\
\
.ace-tomorrow .ace_cursor.ace_overwrite {\
border-left: 0px;\
border-bottom: 1px solid #AEAFAD;\
}\
\
.ace-tomorrow .ace_marker-layer .ace_selection {\
background: #D6D6D6;\
}\
\
.ace-tomorrow .ace_marker-layer .ace_step {\
background: rgb(198, 219, 174);\
}\
\
.ace-tomorrow .ace_marker-layer .ace_bracket {\
margin: -1px 0 0 -1px;\
border: 1px solid #D1D1D1;\
}\
\
.ace-tomorrow .ace_marker-layer .ace_active_line {\
background: #EFEFEF;\
}\
\
\
.ace-tomorrow .ace_invisible {\
color: #D1D1D1;\
}\
\
.ace-tomorrow .ace_keyword {\
color:#8959A8;\
}\
\
.ace-tomorrow .ace_keyword.ace_operator {\
color:#3E999F;\
}\
\
.ace-tomorrow .ace_constant {\
\
}\
\
.ace-tomorrow .ace_constant.ace_language {\
color:#F5871F;\
}\
\
.ace-tomorrow .ace_constant.ace_library {\
\
}\
\
.ace-tomorrow .ace_constant.ace_numeric {\
color:#F5871F;\
}\
\
.ace-tomorrow .ace_invalid {\
color:#FFFFFF;\
background-color:#C82829;\
}\
\
.ace-tomorrow .ace_invalid.ace_illegal {\
\
}\
\
.ace-tomorrow .ace_invalid.ace_deprecated {\
color:#FFFFFF;\
background-color:#8959A8;\
}\
\
.ace-tomorrow .ace_support {\
\
}\
\
.ace-tomorrow .ace_support.ace_function {\
color:#4271AE;\
}\
\
.ace-tomorrow .ace_function.ace_buildin {\
\
}\
\
.ace-tomorrow .ace_string {\
color:#718C00;\
}\
\
.ace-tomorrow .ace_string.ace_regexp {\
color:#C82829;\
}\
\
.ace-tomorrow .ace_comment {\
color:#8E908C;\
}\
\
.ace-tomorrow .ace_comment.ace_doc {\
\
}\
\
.ace-tomorrow .ace_comment.ace_doc.ace_tag {\
\
}\
\
.ace-tomorrow .ace_variable {\
color:#C82829;\
}\
\
.ace-tomorrow .ace_variable.ace_language {\
\
}\
\
.ace-tomorrow .ace_xml_pe {\
\
}\
\
.ace-tomorrow .ace_meta {\
\
}\
\
.ace-tomorrow .ace_meta.ace_tag {\
color:#C82829;\
}\
\
.ace-tomorrow .ace_meta.ace_tag.ace_input {\
\
}\
\
.ace-tomorrow .ace_entity.ace_other.ace_attribute-name {\
color:#C82829;\
}\
\
.ace-tomorrow .ace_entity.ace_name {\
\
}\
\
.ace-tomorrow .ace_entity.ace_name.ace_function {\
color:#4271AE;\
}\
\
.ace-tomorrow .ace_markup.ace_underline {\
text-decoration:underline;\
}\
\
.ace-tomorrow .ace_markup.ace_heading {\
color:#718C00;\
}\
\
.ace-tomorrow .ace_markup.ace_heading.ace_1 {\
\
}\
\
.ace-tomorrow .ace_markup.ace_heading.ace_2 {\
\
}\
\
.ace-tomorrow .ace_markup.ace_heading.ace_3 {\
\
}\
\
.ace-tomorrow .ace_markup.ace_heading.ace_4 {\
\
}\
\
.ace-tomorrow .ace_markup.ace_heading.ace_5 {\
\
}\
\
.ace-tomorrow .ace_markup.ace_heading.ace_6 {\
\
}\
\
.ace-tomorrow .ace_markup.ace_list {\
\
}\
\
.ace-tomorrow .ace_collab.ace_user1 {\
\
}";
exports.cssClass = "ace-tomorrow";
});

261
vendor/ace/theme/tomorrow_night.js vendored Normal file
View File

@@ -0,0 +1,261 @@
/* ***** 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 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");
var cssText = ".ace-tomorrow-night .ace_editor {\
border: 2px solid rgb(159, 159, 159);\
}\
\
.ace-tomorrow-night .ace_editor.ace_focus {\
border: 2px solid #327fbd;\
}\
\
.ace-tomorrow-night .ace_gutter {\
width: 50px;\
background: #e8e8e8;\
color: #333;\
overflow : hidden;\
}\
\
.ace-tomorrow-night .ace_gutter-layer {\
width: 100%;\
text-align: right;\
}\
\
.ace-tomorrow-night .ace_gutter-layer .ace_gutter-cell {\
padding-right: 6px;\
}\
\
.ace-tomorrow-night .ace_print_margin {\
width: 1px;\
background: #e8e8e8;\
}\
\
.ace-tomorrow-night .ace_scroller {\
background-color: #1D1F21;\
}\
\
.ace-tomorrow-night .ace_text-layer {\
cursor: text;\
color: #C5C8C6;\
}\
\
.ace-tomorrow-night .ace_cursor {\
border-left: 2px solid #AEAFAD;\
}\
\
.ace-tomorrow-night .ace_cursor.ace_overwrite {\
border-left: 0px;\
border-bottom: 1px solid #AEAFAD;\
}\
\
.ace-tomorrow-night .ace_marker-layer .ace_selection {\
background: #373B41;\
}\
\
.ace-tomorrow-night .ace_marker-layer .ace_step {\
background: rgb(198, 219, 174);\
}\
\
.ace-tomorrow-night .ace_marker-layer .ace_bracket {\
margin: -1px 0 0 -1px;\
border: 1px solid #4B4E55;\
}\
\
.ace-tomorrow-night .ace_marker-layer .ace_active_line {\
background: #282A2E;\
}\
\
\
.ace-tomorrow-night .ace_invisible {\
color: #4B4E55;\
}\
\
.ace-tomorrow-night .ace_keyword {\
color:#B294BB;\
}\
\
.ace-tomorrow-night .ace_keyword.ace_operator {\
color:#8ABEB7;\
}\
\
.ace-tomorrow-night .ace_constant {\
\
}\
\
.ace-tomorrow-night .ace_constant.ace_language {\
color:#DE935F;\
}\
\
.ace-tomorrow-night .ace_constant.ace_library {\
\
}\
\
.ace-tomorrow-night .ace_constant.ace_numeric {\
color:#DE935F;\
}\
\
.ace-tomorrow-night .ace_invalid {\
color:#CED2CF;\
background-color:#DF5F5F;\
}\
\
.ace-tomorrow-night .ace_invalid.ace_illegal {\
\
}\
\
.ace-tomorrow-night .ace_invalid.ace_deprecated {\
color:#CED2CF;\
background-color:#B798BF;\
}\
\
.ace-tomorrow-night .ace_support {\
\
}\
\
.ace-tomorrow-night .ace_support.ace_function {\
color:#81A2BE;\
}\
\
.ace-tomorrow-night .ace_function.ace_buildin {\
\
}\
\
.ace-tomorrow-night .ace_string {\
color:#B5BD68;\
}\
\
.ace-tomorrow-night .ace_string.ace_regexp {\
color:#CC6666;\
}\
\
.ace-tomorrow-night .ace_comment {\
color:#969896;\
}\
\
.ace-tomorrow-night .ace_comment.ace_doc {\
\
}\
\
.ace-tomorrow-night .ace_comment.ace_doc.ace_tag {\
\
}\
\
.ace-tomorrow-night .ace_variable {\
color:#CC6666;\
}\
\
.ace-tomorrow-night .ace_variable.ace_language {\
\
}\
\
.ace-tomorrow-night .ace_xml_pe {\
\
}\
\
.ace-tomorrow-night .ace_meta {\
\
}\
\
.ace-tomorrow-night .ace_meta.ace_tag {\
color:#CC6666;\
}\
\
.ace-tomorrow-night .ace_meta.ace_tag.ace_input {\
\
}\
\
.ace-tomorrow-night .ace_entity.ace_other.ace_attribute-name {\
color:#CC6666;\
}\
\
.ace-tomorrow-night .ace_entity.ace_name {\
\
}\
\
.ace-tomorrow-night .ace_entity.ace_name.ace_function {\
color:#81A2BE;\
}\
\
.ace-tomorrow-night .ace_markup.ace_underline {\
text-decoration:underline;\
}\
\
.ace-tomorrow-night .ace_markup.ace_heading {\
color:#B5BD68;\
}\
\
.ace-tomorrow-night .ace_markup.ace_heading.ace_1 {\
\
}\
\
.ace-tomorrow-night .ace_markup.ace_heading.ace_2 {\
\
}\
\
.ace-tomorrow-night .ace_markup.ace_heading.ace_3 {\
\
}\
\
.ace-tomorrow-night .ace_markup.ace_heading.ace_4 {\
\
}\
\
.ace-tomorrow-night .ace_markup.ace_heading.ace_5 {\
\
}\
\
.ace-tomorrow-night .ace_markup.ace_heading.ace_6 {\
\
}\
\
.ace-tomorrow-night .ace_markup.ace_list {\
\
}\
\
.ace-tomorrow-night .ace_collab.ace_user1 {\
\
}";
// import CSS once
dom.importCssString(cssText);
exports.cssClass = "ace-tomorrow-night";
});

261
vendor/ace/theme/tomorrow_night_blue.js vendored Normal file
View File

@@ -0,0 +1,261 @@
/* ***** 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 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");
var cssText = ".ace-tomorrow-night-blue .ace_editor {\
border: 2px solid rgb(159, 159, 159);\
}\
\
.ace-tomorrow-night-blue .ace_editor.ace_focus {\
border: 2px solid #327fbd;\
}\
\
.ace-tomorrow-night-blue .ace_gutter {\
width: 50px;\
background: #e8e8e8;\
color: #333;\
overflow : hidden;\
}\
\
.ace-tomorrow-night-blue .ace_gutter-layer {\
width: 100%;\
text-align: right;\
}\
\
.ace-tomorrow-night-blue .ace_gutter-layer .ace_gutter-cell {\
padding-right: 6px;\
}\
\
.ace-tomorrow-night-blue .ace_print_margin {\
width: 1px;\
background: #e8e8e8;\
}\
\
.ace-tomorrow-night-blue .ace_scroller {\
background-color: #002451;\
}\
\
.ace-tomorrow-night-blue .ace_text-layer {\
cursor: text;\
color: #FFFFFF;\
}\
\
.ace-tomorrow-night-blue .ace_cursor {\
border-left: 2px solid #FFFFFF;\
}\
\
.ace-tomorrow-night-blue .ace_cursor.ace_overwrite {\
border-left: 0px;\
border-bottom: 1px solid #FFFFFF;\
}\
\
.ace-tomorrow-night-blue .ace_marker-layer .ace_selection {\
background: #003F8E;\
}\
\
.ace-tomorrow-night-blue .ace_marker-layer .ace_step {\
background: rgb(198, 219, 174);\
}\
\
.ace-tomorrow-night-blue .ace_marker-layer .ace_bracket {\
margin: -1px 0 0 -1px;\
border: 1px solid #404F7D;\
}\
\
.ace-tomorrow-night-blue .ace_marker-layer .ace_active_line {\
background: #00346E;\
}\
\
\
.ace-tomorrow-night-blue .ace_invisible {\
color: #404F7D;\
}\
\
.ace-tomorrow-night-blue .ace_keyword {\
color:#EBBBFF;\
}\
\
.ace-tomorrow-night-blue .ace_keyword.ace_operator {\
color:#99FFFF;\
}\
\
.ace-tomorrow-night-blue .ace_constant {\
\
}\
\
.ace-tomorrow-night-blue .ace_constant.ace_language {\
color:#FFC58F;\
}\
\
.ace-tomorrow-night-blue .ace_constant.ace_library {\
\
}\
\
.ace-tomorrow-night-blue .ace_constant.ace_numeric {\
color:#FFC58F;\
}\
\
.ace-tomorrow-night-blue .ace_invalid {\
color:#FFFFFF;\
background-color:#F99DA5;\
}\
\
.ace-tomorrow-night-blue .ace_invalid.ace_illegal {\
\
}\
\
.ace-tomorrow-night-blue .ace_invalid.ace_deprecated {\
color:#FFFFFF;\
background-color:#EBBBFF;\
}\
\
.ace-tomorrow-night-blue .ace_support {\
\
}\
\
.ace-tomorrow-night-blue .ace_support.ace_function {\
color:#BBDAFF;\
}\
\
.ace-tomorrow-night-blue .ace_function.ace_buildin {\
\
}\
\
.ace-tomorrow-night-blue .ace_string {\
color:#D1F1A9;\
}\
\
.ace-tomorrow-night-blue .ace_string.ace_regexp {\
color:#FF9DA4;\
}\
\
.ace-tomorrow-night-blue .ace_comment {\
color:#7285B7;\
}\
\
.ace-tomorrow-night-blue .ace_comment.ace_doc {\
\
}\
\
.ace-tomorrow-night-blue .ace_comment.ace_doc.ace_tag {\
\
}\
\
.ace-tomorrow-night-blue .ace_variable {\
color:#FF9DA4;\
}\
\
.ace-tomorrow-night-blue .ace_variable.ace_language {\
\
}\
\
.ace-tomorrow-night-blue .ace_xml_pe {\
\
}\
\
.ace-tomorrow-night-blue .ace_meta {\
\
}\
\
.ace-tomorrow-night-blue .ace_meta.ace_tag {\
color:#FF9DA4;\
}\
\
.ace-tomorrow-night-blue .ace_meta.ace_tag.ace_input {\
\
}\
\
.ace-tomorrow-night-blue .ace_entity.ace_other.ace_attribute-name {\
color:#FF9DA4;\
}\
\
.ace-tomorrow-night-blue .ace_entity.ace_name {\
\
}\
\
.ace-tomorrow-night-blue .ace_entity.ace_name.ace_function {\
color:#BBDAFF;\
}\
\
.ace-tomorrow-night-blue .ace_markup.ace_underline {\
text-decoration:underline;\
}\
\
.ace-tomorrow-night-blue .ace_markup.ace_heading {\
color:#D1F1A9;\
}\
\
.ace-tomorrow-night-blue .ace_markup.ace_heading.ace_1 {\
\
}\
\
.ace-tomorrow-night-blue .ace_markup.ace_heading.ace_2 {\
\
}\
\
.ace-tomorrow-night-blue .ace_markup.ace_heading.ace_3 {\
\
}\
\
.ace-tomorrow-night-blue .ace_markup.ace_heading.ace_4 {\
\
}\
\
.ace-tomorrow-night-blue .ace_markup.ace_heading.ace_5 {\
\
}\
\
.ace-tomorrow-night-blue .ace_markup.ace_heading.ace_6 {\
\
}\
\
.ace-tomorrow-night-blue .ace_markup.ace_list {\
\
}\
\
.ace-tomorrow-night-blue .ace_collab.ace_user1 {\
\
}";
// import CSS once
dom.importCssString(cssText);
exports.cssClass = "ace-tomorrow-night-blue";
});

View File

@@ -0,0 +1,261 @@
/* ***** 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 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");
var cssText = ".ace-tomorrow-night-bright .ace_editor {\
border: 2px solid rgb(159, 159, 159);\
}\
\
.ace-tomorrow-night-bright .ace_editor.ace_focus {\
border: 2px solid #327fbd;\
}\
\
.ace-tomorrow-night-bright .ace_gutter {\
width: 50px;\
background: #e8e8e8;\
color: #333;\
overflow : hidden;\
}\
\
.ace-tomorrow-night-bright .ace_gutter-layer {\
width: 100%;\
text-align: right;\
}\
\
.ace-tomorrow-night-bright .ace_gutter-layer .ace_gutter-cell {\
padding-right: 6px;\
}\
\
.ace-tomorrow-night-bright .ace_print_margin {\
width: 1px;\
background: #e8e8e8;\
}\
\
.ace-tomorrow-night-bright .ace_scroller {\
background-color: #000000;\
}\
\
.ace-tomorrow-night-bright .ace_text-layer {\
cursor: text;\
color: #DEDEDE;\
}\
\
.ace-tomorrow-night-bright .ace_cursor {\
border-left: 2px solid #9F9F9F;\
}\
\
.ace-tomorrow-night-bright .ace_cursor.ace_overwrite {\
border-left: 0px;\
border-bottom: 1px solid #9F9F9F;\
}\
\
.ace-tomorrow-night-bright .ace_marker-layer .ace_selection {\
background: #424242;\
}\
\
.ace-tomorrow-night-bright .ace_marker-layer .ace_step {\
background: rgb(198, 219, 174);\
}\
\
.ace-tomorrow-night-bright .ace_marker-layer .ace_bracket {\
margin: -1px 0 0 -1px;\
border: 1px solid #343434;\
}\
\
.ace-tomorrow-night-bright .ace_marker-layer .ace_active_line {\
background: #2A2A2A;\
}\
\
\
.ace-tomorrow-night-bright .ace_invisible {\
color: #343434;\
}\
\
.ace-tomorrow-night-bright .ace_keyword {\
color:#C397D8;\
}\
\
.ace-tomorrow-night-bright .ace_keyword.ace_operator {\
color:#70C0B1;\
}\
\
.ace-tomorrow-night-bright .ace_constant {\
\
}\
\
.ace-tomorrow-night-bright .ace_constant.ace_language {\
color:#E78C45;\
}\
\
.ace-tomorrow-night-bright .ace_constant.ace_library {\
\
}\
\
.ace-tomorrow-night-bright .ace_constant.ace_numeric {\
color:#E78C45;\
}\
\
.ace-tomorrow-night-bright .ace_invalid {\
color:#CED2CF;\
background-color:#DF5F5F;\
}\
\
.ace-tomorrow-night-bright .ace_invalid.ace_illegal {\
\
}\
\
.ace-tomorrow-night-bright .ace_invalid.ace_deprecated {\
color:#CED2CF;\
background-color:#B798BF;\
}\
\
.ace-tomorrow-night-bright .ace_support {\
\
}\
\
.ace-tomorrow-night-bright .ace_support.ace_function {\
color:#7AA6DA;\
}\
\
.ace-tomorrow-night-bright .ace_function.ace_buildin {\
\
}\
\
.ace-tomorrow-night-bright .ace_string {\
color:#B9CA4A;\
}\
\
.ace-tomorrow-night-bright .ace_string.ace_regexp {\
color:#D54E53;\
}\
\
.ace-tomorrow-night-bright .ace_comment {\
color:#969896;\
}\
\
.ace-tomorrow-night-bright .ace_comment.ace_doc {\
\
}\
\
.ace-tomorrow-night-bright .ace_comment.ace_doc.ace_tag {\
\
}\
\
.ace-tomorrow-night-bright .ace_variable {\
color:#D54E53;\
}\
\
.ace-tomorrow-night-bright .ace_variable.ace_language {\
\
}\
\
.ace-tomorrow-night-bright .ace_xml_pe {\
\
}\
\
.ace-tomorrow-night-bright .ace_meta {\
\
}\
\
.ace-tomorrow-night-bright .ace_meta.ace_tag {\
color:#D54E53;\
}\
\
.ace-tomorrow-night-bright .ace_meta.ace_tag.ace_input {\
\
}\
\
.ace-tomorrow-night-bright .ace_entity.ace_other.ace_attribute-name {\
color:#D54E53;\
}\
\
.ace-tomorrow-night-bright .ace_entity.ace_name {\
\
}\
\
.ace-tomorrow-night-bright .ace_entity.ace_name.ace_function {\
color:#7AA6DA;\
}\
\
.ace-tomorrow-night-bright .ace_markup.ace_underline {\
text-decoration:underline;\
}\
\
.ace-tomorrow-night-bright .ace_markup.ace_heading {\
color:#B9CA4A;\
}\
\
.ace-tomorrow-night-bright .ace_markup.ace_heading.ace_1 {\
\
}\
\
.ace-tomorrow-night-bright .ace_markup.ace_heading.ace_2 {\
\
}\
\
.ace-tomorrow-night-bright .ace_markup.ace_heading.ace_3 {\
\
}\
\
.ace-tomorrow-night-bright .ace_markup.ace_heading.ace_4 {\
\
}\
\
.ace-tomorrow-night-bright .ace_markup.ace_heading.ace_5 {\
\
}\
\
.ace-tomorrow-night-bright .ace_markup.ace_heading.ace_6 {\
\
}\
\
.ace-tomorrow-night-bright .ace_markup.ace_list {\
\
}\
\
.ace-tomorrow-night-bright .ace_collab.ace_user1 {\
\
}";
// import CSS once
dom.importCssString(cssText);
exports.cssClass = "ace-tomorrow-night-bright";
});

View File

@@ -0,0 +1,261 @@
/* ***** 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 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");
var cssText = ".ace-tomorrow-night-eighties .ace_editor {\
border: 2px solid rgb(159, 159, 159);\
}\
\
.ace-tomorrow-night-eighties .ace_editor.ace_focus {\
border: 2px solid #327fbd;\
}\
\
.ace-tomorrow-night-eighties .ace_gutter {\
width: 50px;\
background: #e8e8e8;\
color: #333;\
overflow : hidden;\
}\
\
.ace-tomorrow-night-eighties .ace_gutter-layer {\
width: 100%;\
text-align: right;\
}\
\
.ace-tomorrow-night-eighties .ace_gutter-layer .ace_gutter-cell {\
padding-right: 6px;\
}\
\
.ace-tomorrow-night-eighties .ace_print_margin {\
width: 1px;\
background: #e8e8e8;\
}\
\
.ace-tomorrow-night-eighties .ace_scroller {\
background-color: #2D2D2D;\
}\
\
.ace-tomorrow-night-eighties .ace_text-layer {\
cursor: text;\
color: #CCCCCC;\
}\
\
.ace-tomorrow-night-eighties .ace_cursor {\
border-left: 2px solid #CCCCCC;\
}\
\
.ace-tomorrow-night-eighties .ace_cursor.ace_overwrite {\
border-left: 0px;\
border-bottom: 1px solid #CCCCCC;\
}\
\
.ace-tomorrow-night-eighties .ace_marker-layer .ace_selection {\
background: #515151;\
}\
\
.ace-tomorrow-night-eighties .ace_marker-layer .ace_step {\
background: rgb(198, 219, 174);\
}\
\
.ace-tomorrow-night-eighties .ace_marker-layer .ace_bracket {\
margin: -1px 0 0 -1px;\
border: 1px solid #6A6A6A;\
}\
\
.ace-tomorrow-night-eighties .ace_marker-layer .ace_active_line {\
background: #393939;\
}\
\
\
.ace-tomorrow-night-eighties .ace_invisible {\
color: #6A6A6A;\
}\
\
.ace-tomorrow-night-eighties .ace_keyword {\
color:#CC99CC;\
}\
\
.ace-tomorrow-night-eighties .ace_keyword.ace_operator {\
color:#66CCCC;\
}\
\
.ace-tomorrow-night-eighties .ace_constant {\
\
}\
\
.ace-tomorrow-night-eighties .ace_constant.ace_language {\
color:#F99157;\
}\
\
.ace-tomorrow-night-eighties .ace_constant.ace_library {\
\
}\
\
.ace-tomorrow-night-eighties .ace_constant.ace_numeric {\
color:#F99157;\
}\
\
.ace-tomorrow-night-eighties .ace_invalid {\
color:#CDCDCD;\
background-color:#F2777A;\
}\
\
.ace-tomorrow-night-eighties .ace_invalid.ace_illegal {\
\
}\
\
.ace-tomorrow-night-eighties .ace_invalid.ace_deprecated {\
color:#CDCDCD;\
background-color:#CC99CC;\
}\
\
.ace-tomorrow-night-eighties .ace_support {\
\
}\
\
.ace-tomorrow-night-eighties .ace_support.ace_function {\
color:#6699CC;\
}\
\
.ace-tomorrow-night-eighties .ace_function.ace_buildin {\
\
}\
\
.ace-tomorrow-night-eighties .ace_string {\
color:#99CC99;\
}\
\
.ace-tomorrow-night-eighties .ace_string.ace_regexp {\
\
}\
\
.ace-tomorrow-night-eighties .ace_comment {\
color:#999999;\
}\
\
.ace-tomorrow-night-eighties .ace_comment.ace_doc {\
\
}\
\
.ace-tomorrow-night-eighties .ace_comment.ace_doc.ace_tag {\
\
}\
\
.ace-tomorrow-night-eighties .ace_variable {\
color:#F2777A;\
}\
\
.ace-tomorrow-night-eighties .ace_variable.ace_language {\
\
}\
\
.ace-tomorrow-night-eighties .ace_xml_pe {\
\
}\
\
.ace-tomorrow-night-eighties .ace_meta {\
\
}\
\
.ace-tomorrow-night-eighties .ace_meta.ace_tag {\
color:#F2777A;\
}\
\
.ace-tomorrow-night-eighties .ace_meta.ace_tag.ace_input {\
\
}\
\
.ace-tomorrow-night-eighties .ace_entity.ace_other.ace_attribute-name {\
color:#F2777A;\
}\
\
.ace-tomorrow-night-eighties .ace_entity.ace_name {\
\
}\
\
.ace-tomorrow-night-eighties .ace_entity.ace_name.ace_function {\
color:#6699CC;\
}\
\
.ace-tomorrow-night-eighties .ace_markup.ace_underline {\
text-decoration:underline;\
}\
\
.ace-tomorrow-night-eighties .ace_markup.ace_heading {\
color:#99CC99;\
}\
\
.ace-tomorrow-night-eighties .ace_markup.ace_heading.ace_1 {\
\
}\
\
.ace-tomorrow-night-eighties .ace_markup.ace_heading.ace_2 {\
\
}\
\
.ace-tomorrow-night-eighties .ace_markup.ace_heading.ace_3 {\
\
}\
\
.ace-tomorrow-night-eighties .ace_markup.ace_heading.ace_4 {\
\
}\
\
.ace-tomorrow-night-eighties .ace_markup.ace_heading.ace_5 {\
\
}\
\
.ace-tomorrow-night-eighties .ace_markup.ace_heading.ace_6 {\
\
}\
\
.ace-tomorrow-night-eighties .ace_markup.ace_list {\
\
}\
\
.ace-tomorrow-night-eighties .ace_collab.ace_user1 {\
\
}";
// import CSS once
dom.importCssString(cssText);
exports.cssClass = "ace-tomorrow-night-eighties";
});

View File

@@ -37,9 +37,8 @@
define(function(require, exports, module) {
var dom = require("pilot/dom");
var cssText = ".ace-twilight .ace_editor {\
exports.cssClass = "ace-twilight";
exports.cssText = ".ace-twilight .ace_editor {\
border: 2px solid rgb(159, 159, 159);\
}\
\
@@ -256,8 +255,4 @@ color:#5F5A60;\
\
}";
// import CSS once
dom.importCssString(cssText);
exports.cssClass = "ace-twilight";
});
});

View File

@@ -37,9 +37,7 @@
define(function(require, exports, module) {
var dom = require("pilot/dom");
var cssText = ".ace-vibrant-ink .ace_editor {\
exports.cssText = ".ace-vibrant-ink .ace_editor {\
border: 2px solid rgb(159, 159, 159);\
}\
\
@@ -255,8 +253,6 @@ color:#99CC99;\
\
}";
// import CSS once
dom.importCssString(cssText);
exports.cssClass = "ace-vibrant-ink";
exports.cssClass = "ace-vibrant-ink";
});
});

View File

@@ -53,11 +53,11 @@ var RenderLoop = require("ace/renderloop").RenderLoop;
var EventEmitter = require("pilot/event_emitter").EventEmitter;
var editorCss = require("ace/requirejs/text!ace/css/editor.css");
// import CSS once
dom.importCssString(editorCss);
var VirtualRenderer = function(container, theme) {
this.container = container;
// Imports CSS once per DOM document ('ace_editor' serves as an identifier).
dom.importCssString(editorCss, "ace_editor", container.ownerDocument);
dom.addCssClass(this.container, "ace_editor");
this.setTheme(theme);
@@ -135,7 +135,10 @@ var VirtualRenderer = function(container, theme) {
height : 1
};
this.$loop = new RenderLoop(this.$renderChanges.bind(this));
this.$loop = new RenderLoop(
this.$renderChanges.bind(this),
this.container.ownerDocument.defaultView
);
this.$loop.schedule(this.CHANGE_FULL);
this.setPadding(4);
@@ -800,6 +803,12 @@ var VirtualRenderer = function(container, theme) {
}
function afterLoad(theme) {
dom.importCssString(
theme.cssText,
theme.cssClass,
_self.container.ownerDocument
);
if (_self.$theme)
dom.removeCssClass(_self.container, _self.$theme);

View File

@@ -42,7 +42,7 @@ var EventEmitter = require("pilot/event_emitter").EventEmitter;
var WorkerClient = function(topLevelNamespaces, packagedJs, module, classname) {
this.callbacks = [];
this.changeListener = this.changeListener.bind(this);
if (require.packaged) {
var base = this.$guessBasePath();
@@ -104,9 +104,9 @@ var WorkerClient = function(topLevelNamespaces, packagedJs, module, classname) {
this.$normalizePath = function(path) {
if (!path.match(/^\w+:/)) {
path = location.protocol + "//" + location.host
path = location.protocol + "//" + location.host
// paths starting with a slash are relative to the root (host)
+ (path.charAt(0) == "/" ? "" : location.pathname.replace(/\/[^\/]*$/, ""))
+ (path.charAt(0) == "/" ? "" : location.pathname.replace(/\/[^\/]*$/, ""))
+ "/" + path.replace(/^[\/]+/, "");
}
return path;
@@ -115,7 +115,7 @@ var WorkerClient = function(topLevelNamespaces, packagedJs, module, classname) {
this.$guessBasePath = function() {
if (require.aceBaseUrl)
return require.aceBaseUrl;
var scripts = document.getElementsByTagName("script");
for (var i=0; i<scripts.length; i++) {
var script = scripts[i];
@@ -123,7 +123,7 @@ var WorkerClient = function(topLevelNamespaces, packagedJs, module, classname) {
var base = script.getAttribute("data-ace-base");
if (base)
return base.replace(/\/*$/, "/");
var src = script.src || script.getAttribute("src");
if (!src) {
continue;
@@ -138,6 +138,9 @@ var WorkerClient = function(topLevelNamespaces, packagedJs, module, classname) {
this.terminate = function() {
this._dispatchEvent("terminate", {});
this.$worker.terminate();
this.$worker = null;
this.$doc.removeEventListener("change", this.changeListener);
this.$doc = null;
};
this.send = function(cmd, args) {
@@ -154,7 +157,29 @@ var WorkerClient = function(topLevelNamespaces, packagedJs, module, classname) {
};
this.emit = function(event, data) {
this.$worker.postMessage({event: event, data: data});
try {
// firefox refuses to clone objects which have function properties
// TODO: cleanup event
this.$worker.postMessage({event: event, data: {data: data.data}});
}
catch(ex) {}
};
this.attachToDocument = function(doc) {
if(this.$doc)
this.terminate();
this.$doc = doc;
this.call("setValue", [doc.getValue()]);
doc.on("change", this.changeListener);
};
this.changeListener = function(e) {
e.range = {
start: e.data.range.start,
end: e.data.range.end
};
this.emit("change", e);
};
}).call(WorkerClient.prototype);

53
vendor/pilot/dom.js vendored
View File

@@ -22,6 +22,7 @@
* Contributor(s):
* Fabian Jakobs <fabian AT ajax DOT org>
* Mihai Sucan <mihai AT sucan AT gmail ODT com>
* Irakli Gozalishvili <rfobic@gmail.com> (http://jeditoolkit.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
@@ -132,25 +133,61 @@ exports.setCssClass = function(node, className, include) {
}
};
exports.importCssString = function(cssText, doc){
exports.hasCssString = function(id, doc) {
var index = 0, sheets;
doc = doc || document;
if (doc.createStyleSheet) {
var sheet = doc.createStyleSheet();
sheet.cssText = cssText;
if (doc.createStyleSheet && (sheets = doc.styleSheets)) {
while (index < sheets.length)
if (sheets[index++].title === id) return true;
} else if ((sheets = doc.getElementsByTagName("style"))) {
while (index < sheets.length)
if (sheets[index++].id === id) return true;
}
else {
var style = doc.createElementNS ?
return false;
};
exports.importCssString = function importCssString(cssText, id, doc) {
doc = doc || document;
// If style is already imported return immediately.
if (id && exports.hasCssString(id, doc))
return null;
var style;
if (doc.createStyleSheet) {
style = doc.createStyleSheet();
style.cssText = cssText;
if (id)
style.title = id;
} else {
style = doc.createElementNS ?
doc.createElementNS(XHTML_NS, "style") :
doc.createElement("style");
style.appendChild(doc.createTextNode(cssText));
if (id)
style.id = id;
var head = doc.getElementsByTagName("head")[0] || doc.documentElement;
head.appendChild(style);
}
};
exports.importCssStylsheet = function(uri, doc) {
if (doc.createStyleSheet) {
var sheet = doc.createStyleSheet(uri);
} else {
var link = exports.createElement('link');
link.rel = 'stylesheet';
link.href = uri;
var head = doc.getElementsByTagName("head")[0] || doc.documentElement;
head.appendChild(link);
}
};
exports.getInnerWidth = function(element) {
return (parseInt(exports.computedStyle(element, "paddingLeft"))
+ parseInt(exports.computedStyle(element, "paddingRight")) + element.clientWidth);
@@ -193,7 +230,7 @@ else
return element.currentStyle
};
exports.scrollbarWidth = function() {
exports.scrollbarWidth = function(document) {
var inner = exports.createElement("p");
inner.style.width = "100%";
@@ -243,6 +280,7 @@ exports.setInnerHtml = function(el, innerHtml) {
};
exports.setInnerText = function(el, innerText) {
var document = el.ownerDocument;
if (document.body && "textContent" in document.body)
el.textContent = innerText;
else
@@ -251,6 +289,7 @@ exports.setInnerText = function(el, innerText) {
};
exports.getInnerText = function(el) {
var document = el.ownerDocument;
if (document.body && "textContent" in document.body)
return el.textContent;
else

View File

@@ -1,10 +1,23 @@
// vim:set ts=4 sts=4 sw=4 st:
// -- kriskowal Kris Kowal Copyright (C) 2009-2010 MIT License
// vim: ts=4 sts=4 sw=4 expandtab
// -- kriskowal Kris Kowal Copyright (C) 2009-2011 MIT License
// -- tlrobinson Tom Robinson Copyright (C) 2009-2010 MIT License (Narwhal Project)
// -- dantman Daniel Friesen Copyright(C) 2010 XXX No License Specified
// -- dantman Daniel Friesen Copyright (C) 2010 XXX TODO License or CLA
// -- fschaefer Florian Schäfer Copyright (C) 2010 MIT License
// -- Irakli Gozalishvili Copyright (C) 2010 MIT License
// -- Gozala Irakli Gozalishvili Copyright (C) 2010 MIT License
// -- kitcambridge Kit Cambridge Copyright (C) 2011 MIT License
// -- kossnocorp Sasha Koss XXX TODO License or CLA
// -- bryanforbes Bryan Forbes XXX TODO License or CLA
// -- killdream Quildreen Motta Copyright (C) 2011 MIT Licence
// -- michaelficarra Michael Ficarra Copyright (C) 2011 3-clause BSD License
// -- sharkbrainguy Gerard Paapu Copyright (C) 2011 MIT License
// -- bbqsrc Brendan Molloy (C) 2011 Creative Commons Zero (public domain)
// -- iwyg XXX TODO License or CLA
// -- DomenicDenicola Domenic Denicola Copyright (C) 2011 MIT License
// -- xavierm02 Montillet Xavier XXX TODO License or CLA
// -- Raynos Raynos XXX TODO License or CLA
// -- samsonjs Sami Samhuri Copyright (C) 2010 MIT License
// -- rwldrn Rick Waldron Copyright (C) 2011 MIT License
// -- lexer Alexey Zakharov XXX TODO License or CLA
/*!
Copyright (c) 2009, 280 North Inc. http://280north.com/
@@ -17,19 +30,8 @@ define(function(require, exports, module) {
* Brings an environment as close to ECMAScript 5 compliance
* as is possible with the facilities of erstwhile engines.
*
* ES5 Draft
* http://www.ecma-international.org/publications/files/drafts/tc39-2009-050.pdf
*
* NOTE: this is a draft, and as such, the URL is subject to change. If the
* link is broken, check in the parent directory for the latest TC39 PDF.
* http://www.ecma-international.org/publications/files/drafts/
*
* Previous ES5 Draft
* http://www.ecma-international.org/publications/files/drafts/tc39-2009-025.pdf
* This is a broken link to the previous draft of ES5 on which most of the
* numbered specification references and quotes herein were taken. Updating
* these references and quotes to reflect the new document would be a welcome
* volunteer project.
* Annotated ES5: http://es5.github.com/ (specific links below)
* ES5 Spec: http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-262.pdf
*
* @module
*/
@@ -42,39 +44,35 @@ define(function(require, exports, module) {
//
// ES-5 15.3.4.5
// http://www.ecma-international.org/publications/files/drafts/tc39-2009-025.pdf
// http://es5.github.com/#x15.3.4.5
if (!Function.prototype.bind) {
Function.prototype.bind = function bind(that) { // .length is 1
// 1. Let Target be the this value.
var target = this;
// 2. If IsCallable(Target) is false, throw a TypeError exception.
// XXX this gets pretty close, for all intents and purposes, letting
// some duck-types slide
if (typeof target.apply != "function" || typeof target.call != "function")
return new TypeError();
if (typeof target != "function")
throw new TypeError(); // TODO message
// 3. Let A be a new (possibly empty) internal list of all of the
// argument values provided after thisArg (arg1, arg2 etc), in order.
// XXX slicedArgs will stand in for "A" if used
var args = slice.call(arguments, 1); // for normal call
// 4. Let F be a new native ECMAScript object.
// 9. Set the [[Prototype]] internal property of F to the standard
// 11. Set the [[Prototype]] internal property of F to the standard
// built-in Function prototype object as specified in 15.3.3.1.
// 10. Set the [[Call]] internal property of F as described in
// 12. Set the [[Call]] internal property of F as described in
// 15.3.4.5.1.
// 11. Set the [[Construct]] internal property of F as described in
// 13. Set the [[Construct]] internal property of F as described in
// 15.3.4.5.2.
// 12. Set the [[HasInstance]] internal property of F as described in
// 14. Set the [[HasInstance]] internal property of F as described in
// 15.3.4.5.3.
// 13. The [[Scope]] internal property of F is unused and need not
// exist.
var bound = function () {
if (this instanceof bound) {
// 15.3.4.5.2 [[Construct]]
// When the [[Construct]] internal method of a function object,
// F that was created using the bind function is called with a
// list of arguments ExtraArgs the following steps are taken:
// list of arguments ExtraArgs, the following steps are taken:
// 1. Let target be the value of F's [[TargetFunction]]
// internal property.
// 2. If target has no [[Construct]] internal method, a
@@ -84,8 +82,13 @@ if (!Function.prototype.bind) {
// 4. Let args be a new list containing the same values as the
// list boundArgs in the same order followed by the same
// values as the list ExtraArgs in the same order.
// 5. Return the result of calling the [[Construct]] internal
// method of target providing args as the arguments.
var F = function(){};
F.prototype = target.prototype;
var self = new F;
var self = Object.create(target.prototype);
var result = target.apply(
self,
args.concat(slice.call(arguments))
@@ -98,7 +101,7 @@ if (!Function.prototype.bind) {
// 15.3.4.5.1 [[Call]]
// When the [[Call]] internal method of a function object, F,
// which was created using the bind function is called with a
// this value and a list of arguments ExtraArgs the following
// this value and a list of arguments ExtraArgs, the following
// steps are taken:
// 1. Let boundArgs be the value of F's [[BoundArgs]] internal
// property.
@@ -106,12 +109,12 @@ if (!Function.prototype.bind) {
// property.
// 3. Let target be the value of F's [[TargetFunction]] internal
// property.
// 4. Let args be a new list containing the same values as the list
// boundArgs in the same order followed by the same values as
// the list ExtraArgs in the same order. 5. Return the
// result of calling the [[Call]] internal method of target
// providing boundThis as the this value and providing args
// as the arguments.
// 4. Let args be a new list containing the same values as the
// list boundArgs in the same order followed by the same
// values as the list ExtraArgs in the same order.
// 5. Return the result of calling the [[Call]] internal method
// of target providing boundThis as the this value and
// providing args as the arguments.
// equiv: target.call(this, ...boundArgs, ...args)
return target.apply(
@@ -122,27 +125,37 @@ if (!Function.prototype.bind) {
}
};
// XXX bound.length is never writable, so don't even try
//
// 16. The length own property of F is given attributes as specified in
// 15.3.5.1.
// 15. If the [[Class]] internal property of Target is "Function", then
// a. Let L be the length property of Target minus the length of A.
// b. Set the length own property of F to either 0 or L, whichever is
// larger.
// 16. Else set the length own property of F to 0.
// 17. Set the attributes of the length own property of F to the values
// specified in 15.3.5.1.
// TODO
// 17. Set the [[Extensible]] internal property of F to true.
// 18. Set the [[Extensible]] internal property of F to true.
// TODO
// 18. Call the [[DefineOwnProperty]] internal method of F with
// arguments "caller", PropertyDescriptor {[[Value]]: null,
// [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]:
// false}, and false.
// 19. Let thrower be the [[ThrowTypeError]] function Object (13.2.3).
// 20. Call the [[DefineOwnProperty]] internal method of F with
// arguments "caller", PropertyDescriptor {[[Get]]: thrower, [[Set]]:
// thrower, [[Enumerable]]: false, [[Configurable]]: false}, and
// false.
// 21. Call the [[DefineOwnProperty]] internal method of F with
// arguments "arguments", PropertyDescriptor {[[Get]]: thrower,
// [[Set]]: thrower, [[Enumerable]]: false, [[Configurable]]: false},
// and false.
// TODO
// 19. Call the [[DefineOwnProperty]] internal method of F with
// arguments "arguments", PropertyDescriptor {[[Value]]: null,
// [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]:
// false}, and false.
// TODO
// NOTE Function objects created using Function.prototype.bind do not
// have a prototype property.
// XXX can't delete it in pure-js.
// NOTE Function objects created using Function.prototype.bind do not
// have a prototype property or the [[Code]], [[FormalParameters]], and
// [[Scope]] internal properties.
// XXX can't delete prototype in pure-js.
// 22. Return F.
return bound;
};
}
@@ -155,12 +168,16 @@ var call = Function.prototype.call;
var prototypeOfArray = Array.prototype;
var prototypeOfObject = Object.prototype;
var slice = prototypeOfArray.slice;
var toString = prototypeOfObject.toString;
var toString = call.bind(prototypeOfObject.toString);
var owns = call.bind(prototypeOfObject.hasOwnProperty);
var defineGetter, defineSetter, lookupGetter, lookupSetter, supportsAccessors;
// If JS engine supports accessors creating shortcuts.
if ((supportsAccessors = owns(prototypeOfObject, '__defineGetter__'))) {
var defineGetter;
var defineSetter;
var lookupGetter;
var lookupSetter;
var supportsAccessors;
if ((supportsAccessors = owns(prototypeOfObject, "__defineGetter__"))) {
defineGetter = call.bind(prototypeOfObject.__defineGetter__);
defineSetter = call.bind(prototypeOfObject.__defineSetter__);
lookupGetter = call.bind(prototypeOfObject.__lookupGetter__);
@@ -173,24 +190,39 @@ if ((supportsAccessors = owns(prototypeOfObject, '__defineGetter__'))) {
//
// ES5 15.4.3.2
// http://es5.github.com/#x15.4.3.2
// https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/isArray
if (!Array.isArray) {
Array.isArray = function isArray(obj) {
return Object.prototype.toString.call(obj) == "[object Array]";
return toString(obj) == "[object Array]";
};
}
// The IsCallable() check in the Array functions
// has been replaced with a strict check on the
// internal class of the object to trap cases where
// the provided function was actually a regular
// expression literal, which in V8 and
// JavaScriptCore is a typeof "function". Only in
// V8 are regular expression literals permitted as
// reduce parameters, so it is desirable in the
// general case for the shim to match the more
// strict and common behavior of rejecting regular
// expressions.
// ES5 15.4.4.18
// https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/array/foreach
// http://es5.github.com/#x15.4.4.18
// https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/array/forEach
if (!Array.prototype.forEach) {
Array.prototype.forEach = function forEach(fun /*, thisp*/) {
var self = Object(this),
var self = toObject(this),
thisp = arguments[1],
i = 0,
length = self.length >>> 0;
// If no callback function or if callback is not a callable function
if (!fun || !fun.call) {
throw new TypeError();
if (toString(fun) != "[object Function]") {
throw new TypeError(); // TODO message
}
while (i < length) {
@@ -205,15 +237,20 @@ if (!Array.prototype.forEach) {
}
// ES5 15.4.4.19
// http://es5.github.com/#x15.4.4.19
// https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/map
if (!Array.prototype.map) {
Array.prototype.map = function map(fun /*, thisp*/) {
var self = Object(this);
var length = self.length >>> 0;
if (typeof fun != "function")
throw new TypeError();
var result = new Array(length);
var thisp = arguments[1];
var self = toObject(this),
length = self.length >>> 0,
result = Array(length),
thisp = arguments[1];
// If no callback function or if callback is not a callable function
if (toString(fun) != "[object Function]") {
throw new TypeError(); // TODO message
}
for (var i = 0; i < length; i++) {
if (i in self)
result[i] = fun.call(thisp, self[i], i, self);
@@ -223,31 +260,42 @@ if (!Array.prototype.map) {
}
// ES5 15.4.4.20
// http://es5.github.com/#x15.4.4.20
// https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/filter
if (!Array.prototype.filter) {
Array.prototype.filter = function filter(fun /*, thisp */) {
var self = Object(this);
var length = self.length >>> 0;
if (typeof fun != "function")
throw new TypeError();
var result = [];
var thisp = arguments[1];
for (var i = 0; i < length; i++)
var self = toObject(this),
length = self.length >>> 0,
result = [],
thisp = arguments[1];
// If no callback function or if callback is not a callable function
if (toString(fun) != "[object Function]") {
throw new TypeError(); // TODO message
}
for (var i = 0; i < length; i++) {
if (i in self && fun.call(thisp, self[i], i, self))
result.push(self[i]);
}
return result;
};
}
// ES5 15.4.4.16
// http://es5.github.com/#x15.4.4.16
// https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/every
if (!Array.prototype.every) {
Array.prototype.every = function every(fun /*, thisp */) {
if (this === void 0 || this === null)
throw new TypeError();
if (typeof fun !== "function")
throw new TypeError();
var self = Object(this);
var length = self.length >>> 0;
var thisp = arguments[1];
var self = toObject(this),
length = self.length >>> 0,
thisp = arguments[1];
// If no callback function or if callback is not a callable function
if (toString(fun) != "[object Function]") {
throw new TypeError(); // TODO message
}
for (var i = 0; i < length; i++) {
if (i in self && !fun.call(thisp, self[i], i, self))
return false;
@@ -257,16 +305,19 @@ if (!Array.prototype.every) {
}
// ES5 15.4.4.17
// http://es5.github.com/#x15.4.4.17
// https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/some
if (!Array.prototype.some) {
Array.prototype.some = function some(fun /*, thisp */) {
if (this === void 0 || this === null)
throw new TypeError();
if (typeof fun !== "function")
throw new TypeError();
var self = Object(this);
var length = self.length >>> 0;
var thisp = arguments[1];
var self = toObject(this),
length = self.length >>> 0,
thisp = arguments[1];
// If no callback function or if callback is not a callable function
if (toString(fun) != "[object Function]") {
throw new TypeError(); // TODO message
}
for (var i = 0; i < length; i++) {
if (i in self && fun.call(thisp, self[i], i, self))
return true;
@@ -276,31 +327,21 @@ if (!Array.prototype.some) {
}
// ES5 15.4.4.21
// http://es5.github.com/#x15.4.4.21
// https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/reduce
if (!Array.prototype.reduce) {
Array.prototype.reduce = function reduce(fun /*, initial*/) {
var self = Object(this);
var length = self.length >>> 0;
// Whether to include (... || fun instanceof RegExp)
// in the following expression to trap cases where
// the provided function was actually a regular
// expression literal, which in V8 and
// JavaScriptCore is a typeof "function". Only in
// V8 are regular expression literals permitted as
// reduce parameters, so it is desirable in the
// general case for the shim to match the more
// strict and common behavior of rejecting regular
// expressions. However, the only case where the
// shim is applied is IE's Trident (and perhaps very
// old revisions of other engines). In Trident,
// regular expressions are a typeof "object", so the
// following guard alone is sufficient.
if (Object.prototype.toString.call(fun) != "[object Function]")
throw new TypeError();
var self = toObject(this),
length = self.length >>> 0;
// If no callback function or if callback is not a callable function
if (toString(fun) != "[object Function]") {
throw new TypeError(); // TODO message
}
// no value to return if no initial value and an empty array
if (!length && arguments.length == 1)
throw new TypeError();
throw new TypeError(); // TODO message
var i = 0;
var result;
@@ -315,13 +356,13 @@ if (!Array.prototype.reduce) {
// if array contains no values, no initial value to return
if (++i >= length)
throw new TypeError();
throw new TypeError(); // TODO message
} while (true);
}
for (; i < length; i++) {
if (i in self)
result = fun.call(null, result, self[i], i, self);
result = fun.call(void 0, result, self[i], i, self);
}
return result;
@@ -329,16 +370,21 @@ if (!Array.prototype.reduce) {
}
// ES5 15.4.4.22
// http://es5.github.com/#x15.4.4.22
// https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/reduceRight
if (!Array.prototype.reduceRight) {
Array.prototype.reduceRight = function reduceRight(fun /*, initial*/) {
var self = Object(this);
var length = self.length >>> 0;
if (Object.prototype.toString.call(fun) != "[object Function]")
throw new TypeError();
var self = toObject(this),
length = self.length >>> 0;
// If no callback function or if callback is not a callable function
if (toString(fun) != "[object Function]") {
throw new TypeError(); // TODO message
}
// no value to return if no initial value, empty array
if (!length && arguments.length == 1)
throw new TypeError();
throw new TypeError(); // TODO message
var result, i = length - 1;
if (arguments.length >= 2) {
@@ -352,13 +398,13 @@ if (!Array.prototype.reduceRight) {
// if array contains no values, no initial value to return
if (--i < 0)
throw new TypeError();
throw new TypeError(); // TODO message
} while (true);
}
do {
if (i in this)
result = fun.call(null, result, self[i], i, self);
result = fun.call(void 0, result, self[i], i, self);
} while (i--);
return result;
@@ -366,42 +412,45 @@ if (!Array.prototype.reduceRight) {
}
// ES5 15.4.4.14
// http://es5.github.com/#x15.4.4.14
// https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/indexOf
if (!Array.prototype.indexOf) {
Array.prototype.indexOf = function indexOf(sought /*, fromIndex */ ) {
if (this === void 0 || this === null)
throw new TypeError();
var self = Object(this);
var length = self.length >>> 0;
var self = toObject(this),
length = self.length >>> 0;
if (!length)
return -1;
var i = 0;
if (arguments.length > 1)
i = toInteger(arguments[1]);
// handle negative indicies
i = i >= 0 ? i : length - Math.abs(i);
// handle negative indices
i = i >= 0 ? i : Math.max(0, length + i);
for (; i < length; i++) {
if (i in self && self[i] === sought) {
return i;
}
}
return -1;
}
};
}
// ES5 15.4.4.15
// http://es5.github.com/#x15.4.4.15
// https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/lastIndexOf
if (!Array.prototype.lastIndexOf) {
Array.prototype.lastIndexOf = function lastIndexOf(sought /*, fromIndex */) {
if (this === void 0 || this === null)
throw new TypeError();
var self = Object(this);
var length = self.length >>> 0;
var self = toObject(this),
length = self.length >>> 0;
if (!length)
return -1;
var i = length - 1;
if (arguments.length > 1)
i = toInteger(arguments[1]);
// handle negative indicies
i = Math.min(i, toInteger(arguments[1]));
// handle negative indices
i = i >= 0 ? i : length - Math.abs(i);
for (; i >= 0; i--) {
if (i in self && sought === self[i])
@@ -417,17 +466,22 @@ if (!Array.prototype.lastIndexOf) {
//
// ES5 15.2.3.2
// http://es5.github.com/#x15.2.3.2
if (!Object.getPrototypeOf) {
// https://github.com/kriskowal/es5-shim/issues#issue/2
// http://ejohn.org/blog/objectgetprototypeof/
// recommended by fschaefer on github
Object.getPrototypeOf = function getPrototypeOf(object) {
return object.__proto__ || object.constructor.prototype;
// or undefined if not available in this engine
return object.__proto__ || (
object.constructor ?
object.constructor.prototype :
prototypeOfObject
);
};
}
// ES5 15.2.3.3
// http://es5.github.com/#x15.2.3.3
if (!Object.getOwnPropertyDescriptor) {
var ERR_NON_OBJECT = "Object.getOwnPropertyDescriptor called on a " +
"non-object: ";
@@ -436,7 +490,7 @@ if (!Object.getOwnPropertyDescriptor) {
throw new TypeError(ERR_NON_OBJECT + object);
// If object does not owns property return undefined immediately.
if (!owns(object, property))
return undefined;
return;
var descriptor, getter, setter;
@@ -479,6 +533,7 @@ if (!Object.getOwnPropertyDescriptor) {
}
// ES5 15.2.3.4
// http://es5.github.com/#x15.2.3.4
if (!Object.getOwnPropertyNames) {
Object.getOwnPropertyNames = function getOwnPropertyNames(object) {
return Object.keys(object);
@@ -486,6 +541,7 @@ if (!Object.getOwnPropertyNames) {
}
// ES5 15.2.3.5
// http://es5.github.com/#x15.2.3.5
if (!Object.create) {
Object.create = function create(prototype, properties) {
var object;
@@ -503,36 +559,65 @@ if (!Object.create) {
// objects created using `Object.create`
object.__proto__ = prototype;
}
if (typeof properties != "undefined")
if (properties !== void 0)
Object.defineProperties(object, properties);
return object;
};
}
// ES5 15.2.3.6
var oldDefineProperty = Object.defineProperty;
var defineProperty = !!oldDefineProperty;
if (defineProperty) {
// detect IE 8's DOM-only implementation of defineProperty;
var subject = {};
Object.defineProperty(subject, "", {});
defineProperty = "" in subject;
// http://es5.github.com/#x15.2.3.6
// Patch for WebKit and IE8 standard mode
// Designed by hax <hax.github.com>
// related issue: https://github.com/kriskowal/es5-shim/issues#issue/5
// IE8 Reference:
// http://msdn.microsoft.com/en-us/library/dd282900.aspx
// http://msdn.microsoft.com/en-us/library/dd229916.aspx
// WebKit Bugs:
// https://bugs.webkit.org/show_bug.cgi?id=36423
function doesDefinePropertyWork(object) {
try {
Object.defineProperty(object, "sentinel", {});
return "sentinel" in object;
} catch (exception) {
// returns falsy
}
}
if (!defineProperty) {
// check whether defineProperty works if it's given. Otherwise,
// shim partially.
if (Object.defineProperty) {
var definePropertyWorksOnObject = doesDefinePropertyWork({});
var definePropertyWorksOnDom = typeof document == "undefined" ||
doesDefinePropertyWork(document.createElement("div"));
if (!definePropertyWorksOnObject || !definePropertyWorksOnDom) {
var definePropertyFallback = Object.defineProperty;
}
}
if (!Object.defineProperty || definePropertyFallback) {
var ERR_NON_OBJECT_DESCRIPTOR = "Property description must be an object: ";
var ERR_NON_OBJECT_TARGET = "Object.defineProperty called on non-object: "
var ERR_ACCESSORS_NOT_SUPPORTED = "getters & setters can not be defined " +
"on this javascript engine";
Object.defineProperty = function defineProperty(object, property, descriptor) {
if (typeof object != "object" && typeof object != "function")
if ((typeof object != "object" && typeof object != "function") || object === null)
throw new TypeError(ERR_NON_OBJECT_TARGET + object);
if (typeof descriptor != "object" || descriptor === null)
if ((typeof descriptor != "object" && typeof descriptor != "function") || descriptor === null)
throw new TypeError(ERR_NON_OBJECT_DESCRIPTOR + descriptor);
// make a valiant attempt to use the real defineProperty
// for I8's DOM elements.
if (oldDefineProperty && object.nodeType)
return oldDefineProperty(object, property, descriptor);
if (definePropertyFallback) {
try {
return definePropertyFallback.call(Object, object, property, descriptor);
} catch (exception) {
// try the shim if the real one doesn't work
}
}
// If it's a data property.
if (owns(descriptor, "value")) {
@@ -584,6 +669,7 @@ if (!defineProperty) {
}
// ES5 15.2.3.7
// http://es5.github.com/#x15.2.3.7
if (!Object.defineProperties) {
Object.defineProperties = function defineProperties(object, properties) {
for (var property in properties) {
@@ -595,6 +681,7 @@ if (!Object.defineProperties) {
}
// ES5 15.2.3.8
// http://es5.github.com/#x15.2.3.8
if (!Object.seal) {
Object.seal = function seal(object) {
// this is misleading and breaks feature-detection, but
@@ -605,6 +692,7 @@ if (!Object.seal) {
}
// ES5 15.2.3.9
// http://es5.github.com/#x15.2.3.9
if (!Object.freeze) {
Object.freeze = function freeze(object) {
// this is misleading and breaks feature-detection, but
@@ -630,6 +718,7 @@ try {
}
// ES5 15.2.3.10
// http://es5.github.com/#x15.2.3.10
if (!Object.preventExtensions) {
Object.preventExtensions = function preventExtensions(object) {
// this is misleading and breaks feature-detection, but
@@ -640,6 +729,7 @@ if (!Object.preventExtensions) {
}
// ES5 15.2.3.11
// http://es5.github.com/#x15.2.3.11
if (!Object.isSealed) {
Object.isSealed = function isSealed(object) {
return false;
@@ -647,6 +737,7 @@ if (!Object.isSealed) {
}
// ES5 15.2.3.12
// http://es5.github.com/#x15.2.3.12
if (!Object.isFrozen) {
Object.isFrozen = function isFrozen(object) {
return false;
@@ -654,25 +745,38 @@ if (!Object.isFrozen) {
}
// ES5 15.2.3.13
// http://es5.github.com/#x15.2.3.13
if (!Object.isExtensible) {
Object.isExtensible = function isExtensible(object) {
return true;
// 1. If Type(O) is not Object throw a TypeError exception.
if (Object(object) === object) {
throw new TypeError(); // TODO message
}
// 2. Return the Boolean value of the [[Extensible]] internal property of O.
var name = '';
while (owns(object, name)) {
name += '?';
}
object[name] = true;
var returnValue = owns(object, name);
delete object[name];
return returnValue;
};
}
// ES5 15.2.3.14
// http://whattheheadsaid.com/2010/10/a-safer-object-keys-compatibility-implementation
// http://es5.github.com/#x15.2.3.14
if (!Object.keys) {
// http://whattheheadsaid.com/2010/10/a-safer-object-keys-compatibility-implementation
var hasDontEnumBug = true,
dontEnums = [
'toString',
'toLocaleString',
'valueOf',
'hasOwnProperty',
'isPrototypeOf',
'propertyIsEnumerable',
'constructor'
"toString",
"toLocaleString",
"valueOf",
"hasOwnProperty",
"isPrototypeOf",
"propertyIsEnumerable",
"constructor"
],
dontEnumsLength = dontEnums.length;
@@ -681,10 +785,7 @@ if (!Object.keys) {
Object.keys = function keys(object) {
if (
typeof object != "object" && typeof object != "function"
|| object === null
)
if ((typeof object != "object" && typeof object != "function") || object === null)
throw new TypeError("Object.keys called on a non-object");
var keys = [];
@@ -714,32 +815,39 @@ if (!Object.keys) {
//
// ES5 15.9.5.43
// Format a Date object as a string according to a simplified subset of the ISO 8601
// standard as defined in 15.9.1.15.
if (!Date.prototype.toISOString) {
// http://es5.github.com/#x15.9.5.43
// This function returns a String value represent the instance in time
// represented by this Date object. The format of the String is the Date Time
// string format defined in 15.9.1.15. All fields are present in the String.
// The time zone is always UTC, denoted by the suffix Z. If the time value of
// this object is not a finite Number a RangeError exception is thrown.
if (!Date.prototype.toISOString || (new Date(-62198755200000).toISOString().indexOf('-000001') === -1)) {
Date.prototype.toISOString = function toISOString() {
var result, length, value;
var result, length, value, year;
if (!isFinite(this))
throw new RangeError;
// the date time string format is specified in 15.9.1.15.
result = [this.getUTCFullYear(), this.getUTCMonth() + 1, this.getUTCDate(),
result = [this.getUTCMonth() + 1, this.getUTCDate(),
this.getUTCHours(), this.getUTCMinutes(), this.getUTCSeconds()];
year = this.getUTCFullYear();
year = (year < 0 ? '-' : (year > 9999 ? '+' : '')) + ('00000' + Math.abs(year)).slice(0 <= year && year <= 9999 ? -4 : -6);
length = result.length;
while (length--) {
value = result[length];
// pad months, days, hours, minutes, and seconds to have two digits.
if (value < 10)
result[length] = '0' + value;
result[length] = "0" + value;
}
// pad milliseconds to have three digits.
return result.slice(0, 3).join('-') + 'T' + result.slice(3).join(':') + '.' +
('000' + this.getUTCMilliseconds()).slice(-3) + 'Z';
return year + "-" + result.slice(0, 2).join("-") + "T" + result.slice(2).join(":") + "." +
("000" + this.getUTCMilliseconds()).slice(-3) + "Z";
}
}
// ES5 15.9.4.4
// http://es5.github.com/#x15.9.4.4
if (!Date.now) {
Date.now = function now() {
return new Date().getTime();
@@ -747,11 +855,13 @@ if (!Date.now) {
}
// ES5 15.9.5.44
// http://es5.github.com/#x15.9.5.44
// This function provides a String representation of a Date object for use by
// JSON.stringify (15.12.3).
if (!Date.prototype.toJSON) {
Date.prototype.toJSON = function toJSON(key) {
// This function provides a String representation of a Date object for
// use by JSON.stringify (15.12.3). When the toJSON method is called
// with argument key, the following steps are taken:
// When the toJSON method is called with argument key, the following
// steps are taken:
// 1. Let O be the result of calling ToObject, giving it the this
// value as its argument.
@@ -761,13 +871,11 @@ if (!Date.prototype.toJSON) {
// 4. Let toISO be the result of calling the [[Get]] internal method of
// O with argument "toISOString".
// 5. If IsCallable(toISO) is false, throw a TypeError exception.
// XXX this gets pretty close, for all intents and purposes, letting
// some duck-types slide
if (typeof this.toISOString.call != "function")
throw new TypeError();
if (typeof this.toISOString != "function")
throw new TypeError(); // TODO message
// 6. Return the result of calling the [[Call]] internal method of
// toISO with O as the this value and an empty argument list.
return this.toISOString.call(this);
// toISO with O as the this value and an empty argument list.
return this.toISOString();
// NOTE 1 The argument is ignored.
@@ -780,18 +888,17 @@ if (!Date.prototype.toJSON) {
};
}
// 15.9.4.2 Date.parse (string)
// 15.9.1.15 Date Time String Format
// Date.parse
// ES5 15.9.4.2
// http://es5.github.com/#x15.9.4.2
// based on work shared by Daniel Friesen (dantman)
// http://gist.github.com/303249
if (isNaN(Date.parse("2011-06-15T21:40:05+06:00"))) {
if (Date.parse("+275760-09-13T00:00:00.000Z") !== 8.64e15) {
// XXX global assignment won't work in embeddings that use
// an alternate object for the context.
Date = (function(NativeDate) {
// Date.length === 7
var Date = function(Y, M, D, h, m, s, ms) {
var Date = function Date(Y, M, D, h, m, s, ms) {
var length = arguments.length;
if (this instanceof NativeDate) {
var date = length == 1 && String(Y) === Y ? // isString(Y)
@@ -814,25 +921,24 @@ if (isNaN(Date.parse("2011-06-15T21:40:05+06:00"))) {
return NativeDate.apply(this, arguments);
};
// 15.9.1.15 Date Time String Format. This pattern does not implement
// extended years ((15.9.1.15.1), as `Date.UTC` cannot parse them.
// 15.9.1.15 Date Time String Format.
var isoDateExpression = new RegExp("^" +
"(\d{4})" + // four-digit year capture
"(?:-(\d{2})" + // optional month capture
"(?:-(\d{2})" + // optional day capture
"(\\d{4}|[\+\-]\\d{6})" + // four-digit year capture or sign + 6-digit extended year
"(?:-(\\d{2})" + // optional month capture
"(?:-(\\d{2})" + // optional day capture
"(?:" + // capture hours:minutes:seconds.milliseconds
"T(\d{2})" + // hours capture
":(\d{2})" + // minutes capture
"T(\\d{2})" + // hours capture
":(\\d{2})" + // minutes capture
"(?:" + // optional :seconds.milliseconds
":(\d{2})" + // seconds capture
"(?:\.(\d{3}))?" + // milliseconds capture
":(\\d{2})" + // seconds capture
"(?:\\.(\\d{3}))?" + // milliseconds capture
")?" +
"(?:" + // capture UTC offset component
"Z|" + // UTC capture
"(?:" + // offset specifier +/-hours:minutes
"([-+])" + // sign capture
"(\d{2})" + // hours offset capture
":(\d{2})" + // minutes offest capture
"(\\d{2})" + // hours offset capture
":(\\d{2})" + // minutes offset capture
")" +
")?)?)?)?" +
"$");
@@ -864,7 +970,7 @@ if (isNaN(Date.parse("2011-06-15T21:40:05+06:00"))) {
}
// parse the UTC offset component
var minutesOffset = +match.pop(), hourOffset = +match.pop(), sign = match.pop();
var minuteOffset = +match.pop(), hourOffset = +match.pop(), sign = match.pop();
// compute the explicit time zone offset if specified
var offset = 0;
@@ -878,6 +984,16 @@ if (isNaN(Date.parse("2011-06-15T21:40:05+06:00"))) {
offset = (hourOffset * 60 + minuteOffset) * 6e4 * (sign == "+" ? -1 : 1);
}
// Date.UTC for years between 0 and 99 converts year to 1900 + year
// The Gregorian calendar has a 400-year cycle, so
// to Date.UTC(year + 400, .... ) - 12622780800000 == Date.UTC(year, ...),
// where 12622780800000 - number of milliseconds in Gregorian calendar 400 years
var year = +match[0];
if (0 <= year && year <= 99) {
match[0] = year + 400;
return NativeDate.UTC.apply(this, match) + offset - 12622780800000;
}
// compute a new UTC date value, accounting for the optional offset
return NativeDate.UTC.apply(this, match) + offset;
}
@@ -894,13 +1010,16 @@ if (isNaN(Date.parse("2011-06-15T21:40:05+06:00"))) {
//
// ES5 15.5.4.20
if (!String.prototype.trim) {
// http://es5.github.com/#x15.5.4.20
var ws = "\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003" +
"\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028" +
"\u2029\uFEFF";
if (!String.prototype.trim || ws.trim()) {
// http://blog.stevenlevithan.com/archives/faster-trim-javascript
// http://perfectionkills.com/whitespace-deviations/
var s = "[\x09\x0A\-\x0D\x20\xA0\u1680\u180E\u2000-\u200A\u202F" +
"\u205F\u3000\u2028\u2029\uFEFF]"
var trimBeginRegexp = new RegExp("^" + s + s + "*");
var trimEndRegexp = new RegExp(s + s + "*$");
ws = "[" + ws + "]";
var trimBeginRegexp = new RegExp("^" + ws + ws + "*"),
trimEndRegexp = new RegExp(ws + ws + "*$");
String.prototype.trim = function trim() {
return String(this).replace(trimBeginRegexp, "").replace(trimEndRegexp, "");
};
@@ -911,14 +1030,30 @@ if (!String.prototype.trim) {
// ======
//
// ES5 9.4
// http://es5.github.com/#x9.4
// http://jsperf.com/to-integer
var toInteger = function (n) {
n = +n;
if (n !== n) // isNaN
n = -1;
n = 0;
else if (n !== 0 && n !== (1/0) && n !== -(1/0))
n = (n > 0 || -1) * Math.floor(Math.abs(n));
return n;
};
var prepareString = "a"[0] != "a",
// ES5 9.9
// http://es5.github.com/#x9.9
toObject = function (o) {
if (o == null) { // this matches both null and undefined
throw new TypeError(); // TODO message
}
// If the implementation doesn't support by-index access of
// string characters (ex. IE < 7), split the string
if (prepareString && typeof o == "string" && o) {
return o.split("");
}
return Object(o);
};
});

21
vendor/pilot/event.js vendored
View File

@@ -87,7 +87,7 @@ exports.preventDefault = function(e) {
};
exports.getDocumentX = function(e) {
if (e.clientX) {
if (e.clientX) {
return e.clientX + dom.getPageScrollLeft();
} else {
return e.pageX;
@@ -110,7 +110,7 @@ exports.getButton = function(e) {
return 0;
else if (e.type == "contextmenu")
return 2;
// DOM Event
if (e.preventDefault) {
return e.button;
@@ -131,10 +131,10 @@ if (document.documentElement.setCapture) {
var called = false;
function onReleaseCapture(e) {
eventHandler(e);
if (!called) {
called = true;
releaseCaptureHandler();
releaseCaptureHandler(e);
}
exports.removeListener(el, "mousemove", eventHandler);
@@ -159,7 +159,7 @@ else {
function onMouseUp(e) {
eventHandler && eventHandler(e);
releaseCaptureHandler && releaseCaptureHandler();
releaseCaptureHandler && releaseCaptureHandler(e);
document.removeEventListener("mousemove", onMouseMove, true);
document.removeEventListener("mouseup", onMouseUp, true);
@@ -176,7 +176,7 @@ exports.addMouseWheelListener = function(el, callback) {
var max = 0;
var listener = function(e) {
if (e.wheelDelta !== undefined) {
// some versions of Safari (e.g. 5.0.5) report insanely high
// scroll values. These browsers require a higher factor
if (Math.abs(e.wheelDeltaY) > max)
@@ -186,7 +186,7 @@ exports.addMouseWheelListener = function(el, callback) {
factor = 400;
else
factor = 8;
if (e.wheelDeltaX !== undefined) {
e.wheelX = -e.wheelDeltaX / factor;
e.wheelY = -e.wheelDeltaY / factor;
@@ -233,7 +233,7 @@ exports.addMultiMouseDownListener = function(el, button, count, timeout, callbac
clicks = 0;
callback(e);
}
if (isButton)
return exports.preventDefault(e);
};
@@ -277,10 +277,9 @@ function normalizeCommandKeys(callback, e, keyCode) {
// If there is no hashID and the keyCode is not a function key, then
// we don't call the callback as we don't handle a command key here
// (it's a normal key/character input).
if (hashId == 0 && !(keyCode in keys.FUNCTION_KEYS)) {
if (!(keyCode in keys.FUNCTION_KEYS) && !(keyCode in keys.PRINTABLE_KEYS)) {
return false;
}
return callback(e, hashId, keyCode);
}
@@ -313,7 +312,7 @@ exports.addCommandKeyListener = function(el, callback) {
addListener(el, "keypress", function(e) {
var keyId = e.keyIdentifier || e.keyCode;
if (lastDown !== keyId) {
return normalizeCommandKeys(callback, e, e.keyCode);
return normalizeCommandKeys(callback, e, lastDown);
} else {
lastDown = null;
}

View File

@@ -22,6 +22,7 @@
* Contributor(s):
* Fabian Jakobs <fabian AT ajax DOT org>
* Irakli Gozalishvili <rfobic@gmail.com> (http://jeditoolkit.com)
* Mike de Boer <mike 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
@@ -44,16 +45,45 @@ var EventEmitter = {};
EventEmitter._emit =
EventEmitter._dispatchEvent = function(eventName, e) {
this._eventRegistry = this._eventRegistry || {};
this._defaultHandlers = this._defaultHandlers || {};
var listeners = this._eventRegistry[eventName];
if (!listeners || !listeners.length) return;
var listeners = this._eventRegistry[eventName] || [];
var defaultHandler = this._defaultHandlers[eventName];
if (!listeners.length && !defaultHandler)
return;
var e = e || {};
e = e || {};
e.type = eventName;
if (!e.stopPropagation) {
e.stopPropagation = function() {
this.propagationStopped = true;
};
}
if (!e.preventDefault) {
e.preventDefault = function() {
this.defaultPrevented = true;
};
}
for (var i=0; i<listeners.length; i++) {
listeners[i](e);
if (e.propagationStopped)
break;
}
if (defaultHandler && !e.defaultPrevented)
defaultHandler(e);
};
EventEmitter.setDefaultHandler = function(eventName, callback) {
this._defaultHandlers = this._defaultHandlers || {};
if (this._defaultHandlers[eventName])
throw new Error("The default handler for '" + eventName + "' is already set");
this._defaultHandlers[eventName] = callback;
};
EventEmitter.on =
@@ -61,12 +91,11 @@ EventEmitter.addEventListener = function(eventName, callback) {
this._eventRegistry = this._eventRegistry || {};
var listeners = this._eventRegistry[eventName];
if (!listeners) {
var listeners = this._eventRegistry[eventName] = [];
}
if (listeners.indexOf(callback) == -1) {
if (!listeners)
var listeners = this._eventRegistry[eventName] = [];
if (listeners.indexOf(callback) == -1)
listeners.push(callback);
}
};
EventEmitter.removeListener =
@@ -74,18 +103,17 @@ EventEmitter.removeEventListener = function(eventName, callback) {
this._eventRegistry = this._eventRegistry || {};
var listeners = this._eventRegistry[eventName];
if (!listeners) {
return;
}
if (!listeners)
return;
var index = listeners.indexOf(callback);
if (index !== -1) {
if (index !== -1)
listeners.splice(index, 1);
}
};
EventEmitter.removeAllListeners = function(eventName) {
if (this._eventRegistry) this._eventRegistry[eventName] = [];
}
};
exports.EventEmitter = EventEmitter;

View File

@@ -37,9 +37,9 @@
define(function(require, exports, module) {
exports.startup = function(data, reason) {
require('pilot/fixoldbrowsers');
require('pilot/fixoldbrowsers');
exports.startup = function(data, reason) {
require('pilot/types/basic').startup(data, reason);
require('pilot/types/command').startup(data, reason);
require('pilot/types/settings').startup(data, reason);

View File

@@ -96,7 +96,7 @@ var Keys = (function() {
};
// A reverse map of FUNCTION_KEYS
for (i in ret.FUNCTION_KEYS) {
for (var i in ret.FUNCTION_KEYS) {
var name = ret.FUNCTION_KEYS[i].toUpperCase();
ret[name] = parseInt(i, 10);
}

View File

@@ -124,9 +124,8 @@ exports.deferredCall = function(fcn) {
};
var deferred = function(timeout) {
if (!timer) {
timer = setTimeout(callback, timeout || 0);
}
deferred.cancel();
timer = setTimeout(callback, timeout || 0);
return deferred;
}

View File

@@ -101,7 +101,7 @@ exports.Plugin.prototype = {
startup: function(data, reason) {
reason = reason || exports.REASONS.APP_STARTUP;
var pr = new Promise();
if (this.status != this.REGISTERED) {
if (this.status < this.REGISTERED) {
pr.resolve(this);
return pr;
}