upgrade ace and pilot to newest

This commit is contained in:
Chris Wanstrath
2011-09-08 00:43:51 -07:00
parent 7ea2efaf06
commit 32f7a080ef
24 changed files with 257 additions and 34 deletions

View File

@@ -1,4 +1,4 @@
@import url(http://fonts.googleapis.com/css?family=Droid+Sans+Mono);
@import url(//fonts.googleapis.com/css?family=Droid+Sans+Mono);
.ace_editor {

41
vendor/ace/editor.js vendored
View File

@@ -382,7 +382,7 @@ var Editor =function(renderer, session) {
};
this.onChangeMode = function() {
this.renderer.updateText()
this.renderer.updateText();
};
this.onChangeWrapLimit = function() {
@@ -418,7 +418,7 @@ var Editor =function(renderer, session) {
this._emit("cut", range);
if (!this.selection.isEmpty()) {
this.session.remove(range)
this.session.remove(range);
this.clearSelection();
}
};
@@ -648,11 +648,11 @@ var Editor =function(renderer, session) {
this.$modeBehaviours = true;
this.setBehavioursEnabled = function (enabled) {
this.$modeBehaviours = enabled;
}
};
this.getBehavioursEnabled = function () {
return this.$modeBehaviours;
}
};
this.removeRight = function() {
if (this.$readOnly)
@@ -661,7 +661,7 @@ var Editor =function(renderer, session) {
if (this.selection.isEmpty()) {
this.selection.selectRight();
}
this.session.remove(this.getSelectionRange())
this.session.remove(this.getSelectionRange());
this.clearSelection();
};
@@ -760,17 +760,18 @@ var Editor =function(renderer, session) {
var cursor = this.getCursorPosition();
var column = cursor.column;
if (column == 0)
if (column === 0)
return;
var line = this.session.getLine(cursor.row);
var swap, range;
if (column < line.length) {
var swap = line.charAt(column) + line.charAt(column-1);
var range = new Range(cursor.row, column-1, cursor.row, column+1)
swap = line.charAt(column) + line.charAt(column-1);
range = new Range(cursor.row, column-1, cursor.row, column+1);
}
else {
var swap = line.charAt(column-1) + line.charAt(column-2);
var range = new Range(cursor.row, column-2, cursor.row, column)
swap = line.charAt(column-1) + line.charAt(column-2);
range = new Range(cursor.row, column-2, cursor.row, column);
}
this.session.replace(range, swap);
};
@@ -814,7 +815,7 @@ var Editor =function(renderer, session) {
return;
var state = this.session.getState(this.getCursorPosition().row);
var rows = this.$getSelectedRows()
var rows = this.$getSelectedRows();
this.session.getMode().toggleCommentLines(state, this.session, rows.first, rows.last);
};
@@ -823,10 +824,11 @@ var Editor =function(renderer, session) {
return;
var rows = this.$getSelectedRows();
var range;
if (rows.last == 0 || rows.last+1 < this.session.getLength())
var range = new Range(rows.first, 0, rows.last+1, 0)
range = new Range(rows.first, 0, rows.last+1, 0);
else
var range = new Range(
range = new Range(
rows.first-1, this.session.getLine(rows.first-1).length,
rows.last, this.session.getLine(rows.last).length
);
@@ -912,7 +914,6 @@ var Editor =function(renderer, session) {
this.renderer.hideComposition();
};
this.getFirstVisibleRow = function() {
return this.renderer.getFirstVisibleRow();
};
@@ -1043,7 +1044,7 @@ var Editor =function(renderer, session) {
if (!this.isRowVisible(this.getCursorPosition().row)) {
this.scrollToLine(lineNumber, true);
}
},
};
this.navigateTo = function(row, column) {
this.clearSelection();
@@ -1131,7 +1132,7 @@ var Editor =function(renderer, session) {
this.$tryReplace(range, replacement);
if (range !== null)
this.selection.setSelectionRange(range);
},
};
this.replaceAll = function(replacement, options) {
if (options) {
@@ -1152,11 +1153,11 @@ var Editor =function(renderer, session) {
this.selection.setSelectionRange(selection);
this.$blockScrolling -= 1;
},
};
this.$tryReplace = function(range, replacement) {
var input = this.session.getTextRange(range);
var replacement = this.$search.replace(input, replacement);
replacement = this.$search.replace(input, replacement);
if (replacement !== null) {
range.end = this.session.replace(range, replacement);
return range;
@@ -1175,7 +1176,7 @@ var Editor =function(renderer, session) {
options.needle = needle;
this.$search.set(options);
this.$find();
},
};
this.findNext = function(options) {
options = options || {};
@@ -1218,7 +1219,7 @@ var Editor =function(renderer, session) {
this.destroy = function() {
this.renderer.destroy();
}
};
}).call(Editor.prototype);

View File

@@ -125,7 +125,7 @@ var Gutter = function(parentEl) {
var wrappedRowLength = this.session.getRowLength(i) - 1;
while (wrappedRowLength--) {
html.push("</div><div class='ace_gutter-cell' style='height:", config.lineHeight, "px'>&brvbar;</div>");
html.push("</div><div class='ace_gutter-cell' style='height:", config.lineHeight, "px'>\xA6");
}
html.push("</div>");

View File

@@ -60,10 +60,10 @@ var Text = function(parentEl) {
oop.implement(this, EventEmitter);
this.EOF_CHAR = "&para;";
this.EOL_CHAR = "&not;";
this.TAB_CHAR = "&rarr;";
this.SPACE_CHAR = "&middot;";
this.EOF_CHAR = "\xB6"; //"&para;";
this.EOL_CHAR = "\xAC"; //"&not;";
this.TAB_CHAR = "\u2192"; //"&rarr;";
this.SPACE_CHAR = "\xB7"; //"&middot;";
this.$padding = 0;
this.setPadding = function(padding) {

View File

@@ -48,7 +48,7 @@ define(function(require, exports, module) {
merge : true,
regex : ".+"
};
this.$rules = {
start : [
{
@@ -58,8 +58,8 @@ define(function(require, exports, module) {
token : "variable",
regex : "@" + identifier
}, {
token : "label",
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|o(?:ff?|[rn])|un(?:less|til)|and|yes)"

View File

@@ -51,6 +51,9 @@ var JavaScriptHighlightRules = 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 buildinConstants = lang.arrayToMap(
("null|Infinity|NaN|undefined").split("|")
@@ -105,9 +108,16 @@ var JavaScriptHighlightRules = function() {
}, {
token : "constant.numeric", // float
regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
}, {
token : ["keyword", "text", "entity.name.function"],
regex : "(function)(\\s+)(" + identifierRe + ")"
}, {
token : "constant.language.boolean",
regex : "(?:true|false)\\b"
}, {
token : "keyword",
regex : "(?:" + kwBeforeRe + ")\\b",
next : "regex_allowed"
}, {
token : function(value) {
if (value == "this")
@@ -151,6 +161,9 @@ var JavaScriptHighlightRules = function() {
// makes sure we don't mix up regexps with the divison operator
"regex_allowed": [
{
token : "comment",
regex : "\\/\\/.*$"
}, {
token: "string.regexp",
regex: "\\/(?:(?:\\[(?:\\\\]|[^\\]])+\\])"
+ "|(?:\\\\/|[^\\]/]))*"

View File

@@ -136,12 +136,24 @@ module.exports = {
assert.equal(7, tokens.length);
assert.equal("string.regexp", tokens[2].type);
assert.equal("string.regexp", tokens[6].type);
var tokens = this.tokenizer.getLineTokens("case /a/.test(c)", "start").tokens;
assert.equal(8, tokens.length);
assert.equal("string.regexp", tokens[2].type);
},
"test tokenize identifier with umlauts": function() {
var tokens = this.tokenizer.getLineTokens("füße", "start").tokens;
assert.equal(1, tokens.length);
},
"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("text", tokens[1].type);
assert.equal("comment", tokens[2].type);
}
};

58
vendor/ace/mode/latex.js vendored Normal file
View File

@@ -0,0 +1,58 @@
define(function(require, exports, module) {
var oop = require("pilot/oop");
var TextMode = require("ace/mode/text").Mode;
var Tokenizer = require("ace/tokenizer").Tokenizer;
var LatexHighlightRules = require("ace/mode/latex_highlight_rules").LatexHighlightRules;
var Range = require("ace/range").Range;
var Mode = function()
{
this.$tokenizer = new Tokenizer(new LatexHighlightRules().getRules());
};
oop.inherits(Mode, TextMode);
(function()
{
this.toggleCommentLines = function(state, doc, startRow, endRow) {
// This code is adapted from ruby.js
var outdent = true;
var outentedRows = [];
// LaTeX comments begin with % and go to the end of the line
var commentRegEx = /^(\s*)\%/;
for (var i = startRow; i <= endRow; i++) {
if (!commentRegEx.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(commentRegEx);
deleteRange.start.row = i;
deleteRange.end.row = i;
deleteRange.end.column = m[0].length;
doc.replace(deleteRange, m[1]);
}
}
else {
doc.indentRows(startRow, endRow, "%");
}
};
// There is no universally accepted way of indenting a tex document
// so just maintain the indentation of the previous line
this.getNextLineIndent = function(state, line, tab) {
return this.$getIndent(line);
};
}).call(Mode.prototype);
exports.Mode = Mode;
});

View File

@@ -0,0 +1,38 @@
define(function(require, exports, module) {
var oop = require("pilot/oop");
var TextHighlightRules = require("ace/mode/text_highlight_rules").TextHighlightRules;
var LatexHighlightRules = function()
{
this.$rules = {
"start" : [{
// A tex command e.g. \foo
token : "keyword",
regex : "\\\\(?:[^a-zA-Z]|[a-zA-Z]+)",
}, {
// Curly and square braces
token : "lparen",
regex : "[[({]"
}, {
// Curly and square braces
token : "rparen",
regex : "[\\])}]"
}, {
// Inline math between two $ symbols
token : "string",
regex : "\\$(?:(?:\\\\.)|(?:[^\\$\\\\]))*?\\$"
}, {
// A comment. Tex comments start with % and go to
// the end of the line
token : "comment",
regex : "%.*$"
}]
};
};
oop.inherits(LatexHighlightRules, TextHighlightRules);
exports.LatexHighlightRules = LatexHighlightRules;
});

View File

@@ -204,6 +204,14 @@ define(function(require, exports, module) {
color:#606060;\
}\
\
.ace-clouds .ace_entity.ace_name {\
\
}\
\
.ace-clouds .ace_entity.ace_name.ace_function {\
\
}\
\
.ace-clouds .ace_markup.ace_underline {\
text-decoration:underline;\
}\

View File

@@ -205,6 +205,14 @@ background-color:#E92E2E;\
color:#606060;\
}\
\
.ace-clouds-midnight .ace_entity.ace_name {\
\
}\
\
.ace-clouds-midnight .ace_entity.ace_name.ace_function {\
\
}\
\
.ace-clouds-midnight .ace_markup.ace_underline {\
text-decoration:underline;\
}\

View File

@@ -206,6 +206,14 @@ color:#0088FF;\
\
}\
\
.ace-cobalt .ace_entity.ace_name {\
\
}\
\
.ace-cobalt .ace_entity.ace_name.ace_function {\
\
}\
\
.ace-cobalt .ace_markup.ace_underline {\
text-decoration:underline;\
}\

View File

@@ -210,6 +210,14 @@ color:#5A525F;\
\
}\
\
.ace-dawn .ace_entity.ace_name {\
\
}\
\
.ace-dawn .ace_entity.ace_name.ace_function {\
\
}\
\
.ace-dawn .ace_markup.ace_underline {\
text-decoration:underline;\
}\

View File

@@ -63,6 +63,10 @@ define(function(require, exports, module) {
padding-right: 6px;\
}\
\
.ace-eclipse .ace_print_margin {\
width: 1px;\
background: #b1b4ba;\
}\
.ace-eclipse .ace_text-layer {\
cursor: text;\
}\

View File

@@ -206,6 +206,14 @@ color:#BC9458;\
\
}\
\
.ace-idle-fingers .ace_entity.ace_name {\
color:#FFC66D;\
}\
\
.ace-idle-fingers .ace_entity.ace_name.ace_function {\
\
}\
\
.ace-idle-fingers .ace_markup.ace_underline {\
text-decoration:underline;\
}\

View File

@@ -206,6 +206,14 @@ color:#706D5B;\
\
}\
\
.ace-kr-theme .ace_entity.ace_name {\
\
}\
\
.ace-kr-theme .ace_entity.ace_name.ace_function {\
\
}\
\
.ace-kr-theme .ace_markup.ace_underline {\
text-decoration:underline;\
}\

View File

@@ -206,6 +206,14 @@ background-color:#151C19;\
color:#909993;\
}\
\
.ace-mono-industrial .ace_entity.ace_name {\
color:#5778B6;\
}\
\
.ace-mono-industrial .ace_entity.ace_name.ace_function {\
color:#A8B3AB;\
}\
\
.ace-mono-industrial .ace_markup.ace_underline {\
text-decoration:underline;\
}\

View File

@@ -206,6 +206,14 @@ background-color:#AE81FF;\
color:#A6E22E;\
}\
\
.ace-monokai .ace_entity.ace_name {\
\
}\
\
.ace-monokai .ace_entity.ace_name.ace_function {\
color:#A6E22E;\
}\
\
.ace-monokai .ace_markup.ace_underline {\
text-decoration:underline;\
}\

View File

@@ -205,6 +205,14 @@ color:#657B83;\
color:#93A1A1;\
}\
\
.ace-solarized-dark .ace_entity.ace_name {\
\
}\
\
.ace-solarized-dark .ace_entity.ace_name.ace_function {\
color:#268BD2;\
}\
\
.ace-solarized-dark .ace_markup.ace_underline {\
text-decoration:underline;\
}\

View File

@@ -204,6 +204,14 @@ define(function(require, exports, module) {
color:#93A1A1;\
}\
\
.ace-solarized-light .ace_entity.ace_name {\
\
}\
\
.ace-solarized-light .ace_entity.ace_name.ace_function {\
color:#268BD2;\
}\
\
.ace-solarized-light .ace_markup.ace_underline {\
text-decoration:underline;\
}\

View File

@@ -156,7 +156,11 @@ define(function(require, exports, module) {
color: rgb(104, 104, 91);\
}\
\
.ace-tm .ace_markup.ace_underline {\
.ace-tm .ace_entity.ace_name.ace_function {\
color: #0000A2;\
}\
\
.ace-tm .ace_markup.ace_markupine {\
text-decoration:underline;\
}\
\

View File

@@ -183,9 +183,6 @@ color:#5F5A60;\
.ace-twilight .ace_variable {\
color:#7587A6;\
}\
.ace-twilight .ace_label {\
color:#AC885B;\
}\
\
.ace-twilight .ace_variable.ace_language {\
\
@@ -211,6 +208,14 @@ color:#5F5A60;\
\
}\
\
.ace-twilight .ace_entity.ace_name {\
\
}\
\
.ace-twilight .ace_entity.ace_name.ace_function {\
color:#AC885B;\
}\
\
.ace-twilight .ace_markup.ace_underline {\
text-decoration:underline;\
}\

View File

@@ -207,6 +207,14 @@ define(function(require, exports, module) {
color:#99CC99;\
}\
\
.ace-vibrant-ink .ace_entity.ace_name {\
\
}\
\
.ace-vibrant-ink .ace_entity.ace_name.ace_function {\
color:#FFCC00;\
}\
\
.ace-vibrant-ink .ace_markup.ace_underline {\
text-decoration:underline;\
}\

View File

@@ -633,7 +633,7 @@ var VirtualRenderer = function(container, theme) {
var pos = this.$cursorLayer.getPixelPosition();
var left = pos.left + this.$padding;
var left = pos.left;
var top = pos.top;
if (this.scrollTop > top) {