Merge git://github.com/ajaxorg/ace

This commit is contained in:
William Candillon 2012-10-18 10:42:58 +02:00
commit 57635c78fa
16 changed files with 86 additions and 24 deletions

View file

@ -242,6 +242,8 @@
-webkit-box-sizing: border-box;
box-sizing: border-box;
cursor: default;
white-space: pre-line;
word-wrap: break-word;
}
.ace_folding-enabled > .ace_gutter-cell {

View file

@ -318,7 +318,7 @@ var EditSession = function(text, mode) {
};
/**
* EditSession.getSelection() -> String
* EditSession.getSelection() -> Selection
*
* Returns the string of the current selection.
**/
@ -349,11 +349,11 @@ var EditSession = function(text, mode) {
};
/**
* EditSession.getTokenAt(row, column) -> Array
* EditSession.getTokenAt(row, column) -> Object
* - row (Number): The row number to retrieve from
* - column (Number): The column number to retrieve from
*
* Returns an array of tokens at the indicated row and column.
* Returns an object indicating the token at the current row. The object has two properties: `index` and `start`.
**/
this.getTokenAt = function(row, column) {
var tokens = this.bgTokenizer.getTokens(row);
@ -1204,8 +1204,8 @@ var EditSession = function(text, mode) {
};
/** related to: Document.getTextRange
* EditSession.getTextRange(range) -> Array
* - range (String): The range to work with
* EditSession.getTextRange(range) -> String
* - range (Range): The range to work with
*
* {:Document.getTextRange.desc}
**/

View file

@ -33,6 +33,7 @@ define(function(require, exports, module) {
var dom = require("../lib/dom");
var oop = require("../lib/oop");
var lang = require("../lib/lang");
var EventEmitter = require("../lib/event_emitter").EventEmitter;
var Gutter = function(parentEl) {
@ -78,12 +79,15 @@ var Gutter = function(parentEl) {
var annotation = annotations[i];
var row = annotation.row;
var rowInfo = this.$annotations[row];
if (!rowInfo) {
if (!rowInfo)
rowInfo = this.$annotations[row] = {text: []};
}
var annoText = annotation.text.replace(/"/g, "&quot;").replace(/'/g, "&#8217;").replace(/</g, "&lt;");
var annoText = annotation.text;
annoText = annoText ? lang.escapeHTML(annoText) : annotation.html || "";
if (rowInfo.text.indexOf(annoText) === -1)
rowInfo.text.push(annoText);
var type = annotation.type;
if (type == "error")
rowInfo.className = " ace_error";

View file

@ -117,6 +117,10 @@ exports.escapeRegExp = function(str) {
return str.replace(/([.*+?^${}()|[\]\/\\])/g, '\\$1');
};
exports.escapeHTML = function(str) {
return str.replace(/&/g, "&#38;").replace(/"/g, "&#34;").replace(/'/g, "&#39;").replace(/</g, "&#60;");
};
exports.getMatchOffsets = function(string, regExp) {
var matches = [];

View file

@ -120,11 +120,11 @@ var JadeHighlightRules = function() {
"token": [ "storage.type.function.jade", "entity.name.function.jade"],
"regex": "^(\\s*mixin)( [\\w\\-]+)"
},
/* {
{
"token": "source.js.embedded.jade",
"regex": "^\\s*-|=|!=",
"next": "js_code"
},*/
"regex": "^\\s*(?:-|=|!=)",
"next": "js-start"
},
/*{
"token": "entity.name.tag.script.jade",
"regex": "^\\s*script",
@ -219,7 +219,21 @@ var JadeHighlightRules = function() {
"next": "start"
}
],
"tag_attributes": [
"tag_attributes": [
{
"token" : "string",
"regex" : "'(?=.)",
"next" : "qstring"
},
{
"token" : "string",
"regex" : '"(?=.)',
"next" : "qqstring"
},
{
"token": "entity.other.attribute-name.jade",
"regex": "\\b[a-zA-Z\\-:]+"
},
{
"token": ["entity.other.attribute-name.jade", "punctuation"],
"regex": "\\b([a-zA-Z:\\.-]+)(=)",
@ -284,6 +298,12 @@ var JadeHighlightRules = function() {
}
]
};
this.embedRules(JavaScriptHighlightRules, "js-", [{
token: "text",
regex: ".$",
next: "start"
}]);
/*
this.embedRules(MarkdownHighlightRules, "markdown-", [{
token : "support.function",
@ -324,4 +344,4 @@ var JadeHighlightRules = function() {
oop.inherits(JadeHighlightRules, TextHighlightRules);
exports.JadeHighlightRules = JadeHighlightRules;
});
});

View file

@ -52,7 +52,7 @@ var JavaScriptHighlightRules = function() {
"invalid.deprecated":
"__parent__|__count__|escape|unescape|with|__proto__",
"keyword":
"const|yield|import|get|set" +
"const|yield|import|get|set|" +
"break|case|catch|continue|default|delete|do|else|finally|for|function|" +
"if|in|instanceof|new|return|switch|throw|try|typeof|let|var|while|with|debugger",
"storage.type":

View file

@ -143,6 +143,8 @@ oop.inherits(JavaScriptWorker, Mirror);
if (maxErrorLevel == "error" && str && /[\w\d{(['"]/.test(str)) {
error.reason = 'Missing ";" before statement';
type = "error";
} else {
type = "info";
}
}
else if (disabledWarningsRe.test(raw)) {

View file

@ -39,6 +39,7 @@ var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutd
var Range = require("../range").Range;
var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour;
var CStyleFoldMode = require("./folding/cstyle").FoldMode;
var unicode = require("../unicode");
var Mode = function() {
this.$tokenizer = new Tokenizer(new PhpHighlightRules().getRules());
@ -50,6 +51,20 @@ oop.inherits(Mode, TextMode);
(function() {
this.tokenRe = new RegExp("^["
+ unicode.packages.L
+ unicode.packages.Mn + unicode.packages.Mc
+ unicode.packages.Nd
+ unicode.packages.Pc + "\_]+", "g"
);
this.nonTokenRe = new RegExp("^(?:[^"
+ unicode.packages.L
+ unicode.packages.Mn + unicode.packages.Mc
+ unicode.packages.Nd
+ unicode.packages.Pc + "\_]|\s])+", "g"
);
this.toggleCommentLines = function(state, doc, startRow, endRow) {
var outdent = true;
var re = /^(\s*)#/;

View file

@ -30,7 +30,7 @@
define(function(require, exports, module) {
/**
/*
* version of Tokenizer with additional logging
* and infinite loop checks
* can be used for developing/testing new modes

View file

@ -1,8 +1,13 @@
"no use strict";
var console = {
log: function(msgs) {
postMessage({type: "log", data: arguments.join(" ")});
log: function() {
var msgs = Array.prototype.slice.call(arguments, 0);
postMessage({type: "log", data: msgs});
},
error: function() {
var msgs = Array.prototype.slice.call(arguments, 0);
postMessage({type: "log", data: msgs});
}
};
var window = {

View file

@ -84,7 +84,7 @@ var WorkerClient = function(topLevelNamespaces, mod, classname) {
var msg = e.data;
switch(msg.type) {
case "log":
window.console && console.log && console.log(msg.data);
window.console && console.log && console.log.apply(console, msg.data);
break;
case "event":