Merge pull request #1723 from ajaxorg/misc

fix several small bugs
This commit is contained in:
Lennart Kats 2013-12-25 07:11:00 -08:00
commit c612dac355
22 changed files with 3407 additions and 1006 deletions

View file

@ -1,5 +1,5 @@
/** vim: et:ts=4:sw=4:sts=4
* @license RequireJS 2.1.8+ Copyright (c) 2010-2012, The Dojo Foundation All Rights Reserved.
* @license RequireJS 2.1.9+ Copyright (c) 2010-2012, The Dojo Foundation All Rights Reserved.
* Available via the MIT or new BSD license.
* see: http://github.com/jrburke/requirejs for details
*/
@ -12,7 +12,7 @@ var requirejs, require, define;
(function (global) {
var req, s, head, baseElement, dataMain, src,
interactiveScript, currentlyAddingScript, mainScript, subPath,
version = '2.1.8+',
version = '2.1.9+',
commentRegExp = /(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg,
cjsRequireRegExp = /[^.]\s*require\s*\(\s*["']([^'"\s]+)["']\s*\)/g,
jsSuffixRegExp = /\.js$/,
@ -22,7 +22,7 @@ var requirejs, require, define;
hasOwn = op.hasOwnProperty,
ap = Array.prototype,
apsp = ap.splice,
isBrowser = !!(typeof window !== 'undefined' && navigator && window.document),
isBrowser = !!(typeof window !== 'undefined' && typeof navigator !== 'undefined' && window.document),
isWebWorker = !isBrowser && typeof importScripts !== 'undefined',
//PS3 indicates loaded and complete, but need to wait for complete
//specifically. Sequence is 'loading', 'loaded', execution,
@ -373,7 +373,6 @@ var requirejs, require, define;
function hasPathFallback(id) {
var pathConfig = getOwn(config.paths, id);
if (pathConfig && isArray(pathConfig) && pathConfig.length > 1) {
removeScript(id);
//Pop off the first array value, since it failed, and
//retry
pathConfig.shift();
@ -549,7 +548,7 @@ var requirejs, require, define;
//local var ref to defQueue, so cannot just reassign the one
//on context.
apsp.apply(defQueue,
[defQueue.length - 1, 0].concat(globalDefQueue));
[defQueue.length, 0].concat(globalDefQueue));
globalDefQueue = [];
}
}
@ -629,7 +628,7 @@ var requirejs, require, define;
}
function checkLoaded() {
var map, modId, err, usingPathFallback,
var err, usingPathFallback,
waitInterval = config.waitSeconds * 1000,
//It is possible to disable the wait interval by using waitSeconds of 0.
expired = waitInterval && (context.startTime + waitInterval) < new Date().getTime(),
@ -647,8 +646,8 @@ var requirejs, require, define;
//Figure out the state of all the modules.
eachProp(enabledRegistry, function (mod) {
map = mod.map;
modId = map.id;
var map = mod.map,
modId = map.id;
//Skip things that are not enabled or in error state.
if (!mod.enabled) {
@ -1464,10 +1463,21 @@ var requirejs, require, define;
var map = makeModuleMap(id, relMap, true),
mod = getOwn(registry, id);
removeScript(id);
delete defined[id];
delete urlFetched[map.url];
delete undefEvents[id];
//Clean queued defines too. Go backwards
//in array so that the splices do not
//mess up the iteration.
eachReverse(defQueue, function(args, i) {
if(args[0] === id) {
defQueue.splice(i, 1);
}
});
if (mod) {
//Hold on to listeners in case the
//module will be attempted to be reloaded
@ -1918,7 +1928,7 @@ var requirejs, require, define;
}
//Look for a data-main script attribute, which could also adjust the baseUrl.
if (isBrowser) {
if (isBrowser && !cfg.skipDataMain) {
//Figure out baseUrl. Get it from the script tag with require.js in it.
eachReverse(scripts(), function (script) {
//Set the 'head' where we can append children by

View file

@ -2534,6 +2534,10 @@ config.defineOptions(EditSession.prototype, "session", {
set: function(val) {this.doc.setNewLineMode(val)},
get: function() {return this.doc.getNewLineMode()},
handlesSet: true
},
mode: {
set: function(val) { this.setMode(val) },
get: function() { return this.$modeId }
}
});

View file

@ -747,8 +747,11 @@ function Folding() {
};
var range = this.$toggleFoldWidget(row, options);
if (!range)
(e.target || e.srcElement).className += " ace_invalid";
if (!range) {
var el = (e.target || e.srcElement)
if (el && /ace_fold-widget/.test(el.className))
el.className += " ace_invalid";
}
};
this.$toggleFoldWidget = function(row, options) {

View file

@ -248,7 +248,7 @@ var Editor = function(renderer, session) {
this.setKeyboardHandler = function(keyboardHandler) {
if (!keyboardHandler) {
this.keyBinding.setKeyboardHandler(null);
} else if (typeof keyboardHandler == "string") {
} else if (typeof keyboardHandler === "string") {
this.$keybindingId = keyboardHandler;
var _self = this;
config.loadModule(["keybinding", keyboardHandler], function(module) {
@ -2424,6 +2424,7 @@ config.defineOptions(Editor.prototype, "editor", {
minLines: "renderer",
scrollPastEnd: "renderer",
fixedWidthGutter: "renderer",
theme: "renderer",
scrollSpeed: "$mouseHandler",
dragDelay: "$mouseHandler",
@ -2437,7 +2438,8 @@ config.defineOptions(Editor.prototype, "editor", {
useSoftTabs: "session",
tabSize: "session",
wrap: "session",
foldStyle: "session"
foldStyle: "session",
mode: "session"
});
exports.Editor = Editor;

View file

@ -214,7 +214,7 @@ var Gutter = function(parentEl) {
this.element.style.height = config.minHeight + "px";
if (this.$fixedWidth || session.$useWrapMode)
lastLineNumber = session.getLength();
lastLineNumber = session.getLength() + firstLineNumber;
var gutterWidth = gutterRenderer
? gutterRenderer.getWidth(session, lastLineNumber, config)

View file

@ -0,0 +1,39 @@
[[
"start",
["keyword","with"],
["text"," "],
["identifier","Ada"],
["text","."],
["identifier","Text_IO"],
["text","; "],
["keyword","use"],
["text"," "],
["identifier","Ada"],
["text","."],
["identifier","Text_IO"],
["text",";"]
],[
"start",
["keyword","procedure"],
["text"," "],
["identifier","Hello"],
["text"," "],
["keyword","is"]
],[
"start",
["keyword","begin"]
],[
"start",
["text"," "],
["identifier","Put_Line"],
["paren.lparen","("],
["string","\"Hello, world!\""],
["paren.rparen",")"],
["text",";"]
],[
"start",
["keyword","end"],
["text"," "],
["identifier","Hello"],
["text",";"]
]]

View file

@ -0,0 +1,4 @@
[[
"start",
["identifier","TODO"]
]]

View file

@ -0,0 +1,111 @@
[[
"start",
["comment.shebang","#!/usr/bin/env rdmd"]
],[
"start",
["comment","// Computes average line length for standard input."]
],[
"start",
["keyword","import"],
["text"," "],
["variable.module","std.stdio"],
["punctuation.operator",";"]
],[
"start"
],[
"start",
["keyword.type","void"],
["text"," "],
["identifier","main"],
["paren.lparen","("],
["paren.rparen",")"],
["text"," "],
["paren.lparen","{"]
],[
"start",
["text"," "],
["keyword.type","ulong"],
["text"," "],
["identifier","lines"],
["text"," "],
["keyword.operator","="],
["text"," "],
["constant.numeric","0"],
["punctuation.operator",";"]
],[
"start",
["text"," "],
["keyword.type","double"],
["text"," "],
["identifier","sumLength"],
["text"," "],
["keyword.operator","="],
["text"," "],
["constant.numeric","0"],
["punctuation.operator",";"]
],[
"start",
["text"," "],
["keyword.control","foreach"],
["text"," "],
["paren.lparen","("],
["identifier","line"],
["punctuation.operator",";"],
["text"," "],
["identifier","stdin"],
["punctuation.operator","."],
["identifier","byLine"],
["paren.lparen","("],
["paren.rparen","))"],
["text"," "],
["paren.lparen","{"]
],[
"start",
["text"," "],
["keyword.operator","++"],
["identifier","lines"],
["punctuation.operator",";"]
],[
"start",
["text"," "],
["identifier","sumLength"],
["text"," "],
["keyword.operator","+="],
["text"," "],
["identifier","line"],
["punctuation.operator","."],
["identifier","length"],
["punctuation.operator",";"]
],[
"start",
["text"," "],
["paren.rparen","}"]
],[
"start",
["text"," "],
["identifier","writeln"],
["paren.lparen","("],
["string","\"Average line length: \""],
["punctuation.operator",","]
],[
"start",
["text"," "],
["identifier","lines"],
["text"," "],
["keyword.operator","?"],
["text"," "],
["identifier","sumLength"],
["text"," "],
["keyword.operator","/"],
["text"," "],
["identifier","lines"],
["text"," "],
["punctuation.operator",":"],
["text"," "],
["constant.numeric","0"],
["paren.rparen",")"],
["punctuation.operator",";"]
],[
"start",
["paren.rparen","}"]
]]

View file

@ -0,0 +1,81 @@
[[
"start",
["comment.start","{{!--"],
["comment"," Ace + :-}} "],
["comment.end","--}}"]
],[
"start"
],[
"start",
["meta.tag.punctuation.begin","<"],
["meta.tag.name","div"],
["text"," "],
["entity.other.attribute-name","id"],
["keyword.operator.separator","="],
["string","\"comments\""],
["meta.tag.punctuation.end",">"]
],[
"start",
["text"," "],
["storage.type.start","{{#"],
["variable.parameter","each"],
["text"," "],
["variable.parameter","comments"],
["storage.type.end","}}"]
],[
"start",
["text"," "],
["meta.tag.punctuation.begin","<"],
["meta.tag.name","h2"],
["meta.tag.punctuation.end",">"],
["meta.tag.punctuation.begin","<"],
["meta.tag.name.anchor","a"],
["text"," "],
["entity.other.attribute-name","href"],
["keyword.operator.separator","="],
["string","\"/posts/"],
["storage.type.start","{{"],
["text","../"],
["variable.parameter","permalink"],
["storage.type.end","}}"],
["string","#"],
["storage.type.start","{{"],
["variable.parameter","id"],
["storage.type.end","}}"],
["string","\""],
["meta.tag.punctuation.end",">"],
["storage.type.start","{{"],
["variable.parameter","title"],
["storage.type.end","}}"],
["meta.tag.punctuation.begin","</"],
["meta.tag.name.anchor","a"],
["meta.tag.punctuation.end",">"],
["meta.tag.punctuation.begin","</"],
["meta.tag.name","h2"],
["meta.tag.punctuation.end",">"]
],[
"start",
["text"," "],
["meta.tag.punctuation.begin","<"],
["meta.tag.name","div"],
["meta.tag.punctuation.end",">"],
["storage.type.start","{{"],
["variable.parameter","body"],
["storage.type.end","}}"],
["meta.tag.punctuation.begin","</"],
["meta.tag.name","div"],
["meta.tag.punctuation.end",">"]
],[
"start",
["text"," "],
["storage.type.start","{{/"],
["variable.parameter","each"],
["storage.type.end","}}"]
],[
"start",
["meta.tag.punctuation.begin","</"],
["meta.tag.name","div"],
["meta.tag.punctuation.end",">"]
],[
"start"
]]

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,257 @@
[[
"start",
["comment.line.double-slash.mel","//"],
["punctuation.definition.comment.mel"," animated duplicates, instances script"]
],[
"start",
["meta.function.mel","proc"],
["keyword.other.mel"," "],
["storage.type.mel","animatedDuplication"],
["entity.name.function.mel"," ("],
["punctuation.section.function.mel","("],
["meta.function.mel","int $rangeStart, int $rangeEnd, int $numOfDuplicates, int $duplicateOrInstance"],
["punctuation.section.function.mel",")"],
"proc animatedDuplication (int $rangeStart, int $rangeEnd, int $numOfDuplicates, int $duplicateOrInstance)"
],[
"start",
["text","{"]
],[
"start",
["text"," "],
["storage.type.mel","int"],
["text"," "],
["variable.other.mel","$"],
["punctuation.definition.variable.mel","range_start"],
["text"," "],
["keyword.operator.symbolic.mel","="],
["text"," "],
["variable.other.mel","$"],
["punctuation.definition.variable.mel","rangeStart"],
["text",";"]
],[
"start",
["text"," "],
["storage.type.mel","int"],
["text"," "],
["variable.other.mel","$"],
["punctuation.definition.variable.mel","range_end"],
["text"," "],
["keyword.operator.symbolic.mel","="],
["text"," "],
["variable.other.mel","$"],
["punctuation.definition.variable.mel","rangeEnd"],
["text",";"]
],[
"start",
["text"," "],
["storage.type.mel","int"],
["text"," "],
["variable.other.mel","$"],
["punctuation.definition.variable.mel","num_of_duplicates"],
["text"," "],
["keyword.operator.symbolic.mel","="],
["text"," "],
["variable.other.mel","$"],
["punctuation.definition.variable.mel","numOfDuplicates"],
["text",";"]
],[
"start",
["text"," "],
["storage.type.mel","int"],
["text"," "],
["variable.other.mel","$"],
["punctuation.definition.variable.mel","step_size"],
["text"," "],
["keyword.operator.symbolic.mel","="],
["text"," ("],
["variable.other.mel","$"],
["punctuation.definition.variable.mel","range_end"],
["text"," "],
["keyword.operator.symbolic.mel","-"],
["text"," "],
["variable.other.mel","$"],
["punctuation.definition.variable.mel","range_start"],
["text",") "],
["keyword.operator.symbolic.mel","/"],
["text"," "],
["variable.other.mel","$"],
["punctuation.definition.variable.mel","num_of_duplicates"],
["text",";"]
],[
"start",
["text"," "],
["storage.type.mel","int"],
["text"," "],
["variable.other.mel","$"],
["punctuation.definition.variable.mel","i"],
["text"," "],
["keyword.operator.symbolic.mel","="],
["text"," "],
["constant.numeric.mel","0"],
["text",";"]
],[
"start",
["text"," "],
["storage.type.mel","int"],
["text"," "],
["variable.other.mel","$"],
["punctuation.definition.variable.mel","temp"],
["text",";"]
],[
"start"
],[
"start",
["text"," "],
["support.function.mel","currentTime"],
["text"," "],
["variable.other.mel","$"],
["punctuation.definition.variable.mel","range_start"],
["text","; "],
["comment.line.double-slash.mel","//"],
["punctuation.definition.comment.mel"," set to range start"]
],[
"start"
],[
"start",
["text"," "],
["storage.type.mel","string"],
["text"," "],
["variable.other.mel","$"],
["punctuation.definition.variable.mel","selectedObjects"],
["text","[]; "],
["comment.line.double-slash.mel","//"],
["punctuation.definition.comment.mel"," to store selected objects"]
],[
"start",
["text"," "],
["variable.other.mel","$"],
["punctuation.definition.variable.mel","selectedObjects"],
["text"," "],
["keyword.operator.symbolic.mel","="],
["text"," `"],
["support.function.mel","ls"],
["text"," "],
["keyword.operator.symbolic.mel","-"],
["text","sl`; "],
["comment.line.double-slash.mel","//"],
["punctuation.definition.comment.mel"," store selected objects"]
],[
"start",
["text"," "],
["support.function.mel","select"],
["text"," "],
["variable.other.mel","$"],
["punctuation.definition.variable.mel","selectedObjects"],
["text",";"]
],[
"start"
],[
"start",
["text"," "],
["keyword.control.mel","while"],
["text"," ("],
["variable.other.mel","$"],
["punctuation.definition.variable.mel","i"],
["text"," <"],
["keyword.operator.symbolic.mel","="],
["text"," "],
["variable.other.mel","$"],
["punctuation.definition.variable.mel","num_of_duplicates"],
["text",")"]
],[
"start",
["text"," {"]
],[
"start",
["text"," "],
["variable.other.mel","$"],
["punctuation.definition.variable.mel","temp"],
["text"," "],
["keyword.operator.symbolic.mel","="],
["text"," "],
["variable.other.mel","$"],
["punctuation.definition.variable.mel","range_start"],
["text"," "],
["keyword.operator.symbolic.mel","+"],
["text"," ("],
["variable.other.mel","$"],
["punctuation.definition.variable.mel","step_size"],
["text"," "],
["keyword.operator.symbolic.mel","*"],
["text"," "],
["variable.other.mel","$"],
["punctuation.definition.variable.mel","i"],
["text",");"]
],[
"start",
["text"," "],
["support.function.mel","currentTime"],
["text"," ("],
["variable.other.mel","$"],
["punctuation.definition.variable.mel","temp"],
["text",");"]
],[
"start",
["text"," "],
["comment.line.double-slash.mel","//"],
["punctuation.definition.comment.mel"," seleced the objects to duplicate or instance"]
],[
"start",
["text"," "],
["support.function.mel","select"],
["text"," "],
["variable.other.mel","$"],
["punctuation.definition.variable.mel","selectedObjects"],
["text",";"]
],[
"start",
["text"," "],
["keyword.control.mel","if"],
["text","("],
["variable.other.mel","$"],
["punctuation.definition.variable.mel","duplicateOrInstance"],
["text"," "],
["keyword.operator.symbolic.mel","=="],
["text"," "],
["constant.numeric.mel","0"],
["text",")"]
],[
"start",
["text"," {"]
],[
"start",
["text"," "],
["support.function.mel","duplicate"],
["text",";"]
],[
"start",
["text"," }"]
],[
"start",
["text"," "],
["keyword.control.mel","else"]
],[
"start",
["text"," {"]
],[
"start",
["text"," "],
["support.function.mel","instance"],
["text",";"]
],[
"start",
["text"," }"]
],[
"start",
["text"," "],
["variable.other.mel","$"],
["punctuation.definition.variable.mel","i"],
["keyword.operator.symbolic.mel","++"],
["text",";"]
],[
"start",
["text"," }"]
],[
"start",
["text","}"]
]]

View file

@ -194,7 +194,7 @@ define(function(require, exports, module) {
pathSep = useWinPathSep ? /\\|\// : /\//;
parts = file.split(pathSep);
file = parts[parts.length - 1];
if (!stripExt) {
if (!(stripExt && file.indexOf('.') >= 0)) {
return file;
}
parts = file.split('.');

View file

@ -193,30 +193,25 @@ define(function(require, exports, module) {
};
Lexer.prototype.stringToken = function() {
var match, octalEsc, string;
switch (this.chunk.charAt(0)) {
var octalEsc, quote, string, trimmed;
switch (quote = this.chunk.charAt(0)) {
case "'":
if (!(match = SIMPLESTR.exec(this.chunk))) {
return 0;
}
string = match[0];
this.token('STRING', string.replace(MULTILINER, '\\\n'), 0, string.length);
string = SIMPLESTR.exec(this.chunk)[0];
break;
case '"':
if (!(string = this.balancedString(this.chunk, '"'))) {
return 0;
}
if (0 < string.indexOf('#{', 1)) {
this.interpolateString(string.slice(1, -1), {
strOffset: 1,
lexedLength: string.length
});
} else {
this.token('STRING', this.escapeLines(string, 0, string.length));
}
break;
default:
return 0;
string = this.balancedString(this.chunk, '"');
}
if (!string) {
return 0;
}
trimmed = this.removeNewlines(string.slice(1, -1));
if (quote === '"' && 0 < string.indexOf('#{', 1)) {
this.interpolateString(trimmed, {
strOffset: 1,
lexedLength: string.length
});
} else {
this.token('STRING', quote + this.escapeLines(trimmed) + quote, 0, string.length);
}
if (octalEsc = /^(?:\\.|[^\\])*\\(?:0[0-7]|[1-7])/.test(string)) {
this.error("octal escape sequences " + string + " are not allowed");
@ -302,7 +297,7 @@ define(function(require, exports, module) {
var body, flags, flagsOffset, heregex, plusToken, prev, re, tag, token, tokens, value, _i, _len, _ref2, _ref3, _ref4;
heregex = match[0], body = match[1], flags = match[2];
if (0 > body.indexOf('#{')) {
re = body.replace(HEREGEX_OMIT, '').replace(/\//g, '\\/');
re = this.escapeLines(body.replace(HEREGEX_OMIT, '$1$2').replace(/\//g, '\\/'), true);
if (re.match(/^\*/)) {
this.error('regular expressions cannot begin with `*`');
}
@ -321,7 +316,7 @@ define(function(require, exports, module) {
if (tag === 'TOKENS') {
tokens.push.apply(tokens, value);
} else if (tag === 'NEOSTRING') {
if (!(value = value.replace(HEREGEX_OMIT, ''))) {
if (!(value = value.replace(HEREGEX_OMIT, '$1$2'))) {
continue;
}
value = value.replace(/\\/g, '\\\\');
@ -628,10 +623,6 @@ define(function(require, exports, module) {
offsetInChunk = offsetInChunk || 0;
strOffset = strOffset || 0;
lexedLength = lexedLength || str.length;
if (heredoc && str.length > 0 && str[0] === '\n') {
str = str.slice(1);
strOffset++;
}
tokens = [];
pi = 0;
i = -1;
@ -789,16 +780,31 @@ define(function(require, exports, module) {
return LINE_CONTINUER.test(this.chunk) || ((_ref2 = this.tag()) === '\\' || _ref2 === '.' || _ref2 === '?.' || _ref2 === '?::' || _ref2 === 'UNARY' || _ref2 === 'MATH' || _ref2 === '+' || _ref2 === '-' || _ref2 === 'SHIFT' || _ref2 === 'RELATION' || _ref2 === 'COMPARE' || _ref2 === 'LOGIC' || _ref2 === 'THROW' || _ref2 === 'EXTENDS');
};
Lexer.prototype.removeNewlines = function(str) {
return str.replace(/^\s*\n\s*/, '').replace(/([^\\]|\\\\)\s*\n\s*$/, '$1');
};
Lexer.prototype.escapeLines = function(str, heredoc) {
return str.replace(MULTILINER, heredoc ? '\\n' : '');
str = str.replace(/\\[^\S\n]*(\n|\\)\s*/g, function(escaped, character) {
if (character === '\n') {
return '';
} else {
return escaped;
}
});
if (heredoc) {
return str.replace(MULTILINER, '\\n');
} else {
return str.replace(/\s*\n\s*/g, ' ');
}
};
Lexer.prototype.makeString = function(body, quote, heredoc) {
if (!body) {
return quote + quote;
}
body = body.replace(/\\([\s\S])/g, function(match, contents) {
if (contents === '\n' || contents === quote) {
body = body.replace(RegExp("\\\\(" + quote + "|\\\\)", "g"), function(match, contents) {
if (contents === quote) {
return contents;
} else {
return match;
@ -867,27 +873,27 @@ define(function(require, exports, module) {
NUMBER = /^0b[01]+|^0o[0-7]+|^0x[\da-f]+|^\d*\.?\d+(?:e[+-]?\d+)?/i;
HEREDOC = /^("""|''')([\s\S]*?)(?:\n[^\n\S]*)?\1/;
HEREDOC = /^("""|''')((?:\\[\s\S]|[^\\])*?)(?:\n[^\n\S]*)?\1/;
OPERATOR = /^(?:[-=]>|[-+*\/%<>&|^!?=]=|>>>=?|([-+:])\1|([&|<>])\2=?|\?(\.|::)|\.{2,3})/;
WHITESPACE = /^[^\n\S]+/;
COMMENT = /^###([^#][\s\S]*?)(?:###[^\n\S]*|(?:###)$)|^(?:\s*#(?!##[^#]).*)+/;
COMMENT = /^###([^#][\s\S]*?)(?:###[^\n\S]*|###$)|^(?:\s*#(?!##[^#]).*)+/;
CODE = /^[-=]>/;
MULTI_DENT = /^(?:\n[^\n\S]*)+/;
SIMPLESTR = /^'[^\\']*(?:\\.[^\\']*)*'/;
SIMPLESTR = /^'[^\\']*(?:\\[\s\S][^\\']*)*'/;
JSTOKEN = /^`[^\\`]*(?:\\.[^\\`]*)*`/;
REGEX = /^(\/(?![\s=])[^[\/\n\\]*(?:(?:\\[\s\S]|\[[^\]\n\\]*(?:\\[\s\S][^\]\n\\]*)*])[^[\/\n\\]*)*\/)([imgy]{0,4})(?!\w)/;
HEREGEX = /^\/{3}([\s\S]+?)\/{3}([imgy]{0,4})(?!\w)/;
HEREGEX = /^\/{3}((?:\\?[\s\S])+?)\/{3}([imgy]{0,4})(?!\w)/;
HEREGEX_OMIT = /\s+(?:#.*)?/g;
HEREGEX_OMIT = /((?:\\\\)+)|\\(\s|\/)|\s+(?:#.*)?/g;
MULTILINER = /\n/g;

File diff suppressed because it is too large Load diff

View file

@ -27,7 +27,7 @@
define(function(require, exports, module) {
// Generated by CoffeeScript 1.6.3
var BALANCED_PAIRS, EXPRESSION_CLOSE, EXPRESSION_END, EXPRESSION_START, IMPLICIT_CALL, IMPLICIT_END, IMPLICIT_FUNC, IMPLICIT_UNSPACED_CALL, INVERSES, LINEBREAKS, SINGLE_CLOSERS, SINGLE_LINERS, generate, left, rite, _i, _len, _ref,
var BALANCED_PAIRS, CALL_CLOSERS, EXPRESSION_CLOSE, EXPRESSION_END, EXPRESSION_START, IMPLICIT_CALL, IMPLICIT_END, IMPLICIT_FUNC, IMPLICIT_UNSPACED_CALL, INVERSES, LINEBREAKS, SINGLE_CLOSERS, SINGLE_LINERS, generate, left, rite, _i, _len, _ref,
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; },
__slice = [].slice;
@ -44,10 +44,9 @@ define(function(require, exports, module) {
Rewriter.prototype.rewrite = function(tokens) {
this.tokens = tokens;
this.removeLeadingNewlines();
this.removeMidExpressionNewlines();
this.closeOpenCalls();
this.closeOpenIndexes();
this.addImplicitIndentation();
this.normalizeLines();
this.tagPostfixConditionals();
this.addImplicitBracesAndParens();
this.addLocationDataToGeneratedTokens();
@ -99,17 +98,6 @@ define(function(require, exports, module) {
}
};
Rewriter.prototype.removeMidExpressionNewlines = function() {
return this.scanTokens(function(token, i, tokens) {
var _ref;
if (!(token[0] === 'TERMINATOR' && (_ref = this.tag(i + 1), __indexOf.call(EXPRESSION_CLOSE, _ref) >= 0))) {
return 1;
}
tokens.splice(i, 1);
return 0;
});
};
Rewriter.prototype.closeOpenCalls = function() {
var action, condition;
condition = function(token, i) {
@ -188,9 +176,9 @@ define(function(require, exports, module) {
var stack;
stack = [];
return this.scanTokens(function(token, i, tokens) {
var endImplicitCall, endImplicitObject, forward, inImplicit, inImplicitCall, inImplicitControl, inImplicitObject, nextTag, offset, prevTag, s, sameLine, stackIdx, stackTag, stackTop, startIdx, startImplicitCall, startImplicitObject, startsLine, tag, _ref, _ref1, _ref2, _ref3, _ref4, _ref5;
var endAllImplicitCalls, endImplicitCall, endImplicitObject, forward, inImplicit, inImplicitCall, inImplicitControl, inImplicitObject, nextTag, offset, prevTag, prevToken, s, sameLine, stackIdx, stackTag, stackTop, startIdx, startImplicitCall, startImplicitObject, startsLine, tag, _ref, _ref1, _ref2, _ref3, _ref4, _ref5;
tag = token[0];
prevTag = (i > 0 ? tokens[i - 1] : [])[0];
prevTag = (prevToken = i > 0 ? tokens[i - 1] : [])[0];
nextTag = (i < tokens.length - 1 ? tokens[i + 1] : [])[0];
stackTop = function() {
return stack[stack.length - 1];
@ -233,6 +221,11 @@ define(function(require, exports, module) {
tokens.splice(i, 0, generate('CALL_END', ')'));
return i += 1;
};
endAllImplicitCalls = function() {
while (inImplicitCall()) {
endImplicitCall();
}
};
startImplicitObject = function(j, startsLine) {
var idx;
if (startsLine == null) {
@ -324,9 +317,15 @@ define(function(require, exports, module) {
startImplicitObject(s, !!startsLine);
return forward(2);
}
if (prevTag === 'OUTDENT' && inImplicitCall() && (tag === '.' || tag === '?.' || tag === '::' || tag === '?::')) {
endImplicitCall();
return forward(1);
if (inImplicitCall() && __indexOf.call(CALL_CLOSERS, tag) >= 0) {
if (prevTag === 'OUTDENT') {
endImplicitCall();
return forward(1);
}
if (prevToken.newLine) {
endAllImplicitCalls();
return forward(1);
}
}
if (inImplicitObject() && __indexOf.call(LINEBREAKS, tag) >= 0) {
stackTop()[2].sameLine = false;
@ -381,30 +380,32 @@ define(function(require, exports, module) {
});
};
Rewriter.prototype.addImplicitIndentation = function() {
Rewriter.prototype.normalizeLines = function() {
var action, condition, indent, outdent, starter;
starter = indent = outdent = null;
condition = function(token, i) {
var _ref, _ref1;
return token[1] !== ';' && (_ref = token[0], __indexOf.call(SINGLE_CLOSERS, _ref) >= 0) && !(token[0] === 'ELSE' && starter !== 'THEN') && !(((_ref1 = token[0]) === 'CATCH' || _ref1 === 'FINALLY') && (starter === '->' || starter === '=>'));
var _ref, _ref1, _ref2, _ref3;
return token[1] !== ';' && (_ref = token[0], __indexOf.call(SINGLE_CLOSERS, _ref) >= 0) && !(token[0] === 'TERMINATOR' && (_ref1 = this.tag(i + 1), __indexOf.call(EXPRESSION_CLOSE, _ref1) >= 0)) && !(token[0] === 'ELSE' && starter !== 'THEN') && !(((_ref2 = token[0]) === 'CATCH' || _ref2 === 'FINALLY') && (starter === '->' || starter === '=>')) || (_ref3 = token[0], __indexOf.call(CALL_CLOSERS, _ref3) >= 0) && this.tokens[i - 1].newLine;
};
action = function(token, i) {
return this.tokens.splice((this.tag(i - 1) === ',' ? i - 1 : i), 0, outdent);
};
return this.scanTokens(function(token, i, tokens) {
var j, tag, _i, _ref, _ref1;
var j, tag, _i, _ref, _ref1, _ref2;
tag = token[0];
if (tag === 'TERMINATOR' && this.tag(i + 1) === 'THEN') {
tokens.splice(i, 1);
return 0;
}
if (tag === 'ELSE' && this.tag(i - 1) !== 'OUTDENT') {
tokens.splice.apply(tokens, [i, 0].concat(__slice.call(this.indentation())));
return 2;
if (tag === 'TERMINATOR') {
if (this.tag(i + 1) === 'ELSE' && this.tag(i - 1) !== 'OUTDENT') {
tokens.splice.apply(tokens, [i, 1].concat(__slice.call(this.indentation())));
return 1;
}
if (_ref = this.tag(i + 1), __indexOf.call(EXPRESSION_CLOSE, _ref) >= 0) {
tokens.splice(i, 1);
return 0;
}
}
if (tag === 'CATCH') {
for (j = _i = 1; _i <= 2; j = ++_i) {
if (!((_ref = this.tag(i + j)) === 'OUTDENT' || _ref === 'TERMINATOR' || _ref === 'FINALLY')) {
if (!((_ref1 = this.tag(i + j)) === 'OUTDENT' || _ref1 === 'TERMINATOR' || _ref1 === 'FINALLY')) {
continue;
}
tokens.splice.apply(tokens, [i + j, 0].concat(__slice.call(this.indentation())));
@ -413,7 +414,7 @@ define(function(require, exports, module) {
}
if (__indexOf.call(SINGLE_LINERS, tag) >= 0 && this.tag(i + 1) !== 'INDENT' && !(tag === 'ELSE' && this.tag(i + 1) === 'IF')) {
starter = tag;
_ref1 = this.indentation(true), indent = _ref1[0], outdent = _ref1[1];
_ref2 = this.indentation(true), indent = _ref2[0], outdent = _ref2[1];
if (starter === 'THEN') {
indent.fromThen = true;
}
@ -493,7 +494,7 @@ define(function(require, exports, module) {
EXPRESSION_END.push(INVERSES[left] = rite);
}
EXPRESSION_CLOSE = ['CATCH', 'WHEN', 'ELSE', 'FINALLY'].concat(EXPRESSION_END);
EXPRESSION_CLOSE = ['CATCH', 'THEN', 'ELSE', 'FINALLY'].concat(EXPRESSION_END);
IMPLICIT_FUNC = ['IDENTIFIER', 'SUPER', ')', 'CALL_END', ']', 'INDEX_END', '@', 'THIS'];
@ -509,5 +510,7 @@ define(function(require, exports, module) {
LINEBREAKS = ['TERMINATOR', 'INDENT', 'OUTDENT'];
CALL_CLOSERS = ['.', '?.', '::', '?::'];
});

File diff suppressed because it is too large Load diff

View file

@ -191,7 +191,7 @@ var DHighlightRules = function() {
"star-comment" : [
{
token : "comment", // closing comment
regex : ".*?\\*\\/",
regex : "\\*\\/",
next : "start"
}, {
defaultToken: 'comment'
@ -200,7 +200,7 @@ var DHighlightRules = function() {
"plus-comment" : [
{
token : "comment", // closing comment
regex : ".*?\\+\\/",
regex : "\\+\\/",
next : "start"
}, {
defaultToken: 'comment'
@ -211,7 +211,7 @@ var DHighlightRules = function() {
stringEscapesSeq,
{
token : "string",
regex : '(?:(?:\\\\.)|(?:[^"\\\\]))*?"[cdw]?',
regex : '"[cdw]?',
next : "start"
}, {
defaultToken: 'string'
@ -222,7 +222,7 @@ var DHighlightRules = function() {
stringEscapesSeq,
{
token : "string",
regex : '(?:(?:\\\\.)|(?:[^`\\\\]))*?`[cdw]?',
regex : '`[cdw]?',
next : "start"
}, {
defaultToken: 'string'
@ -234,7 +234,7 @@ var DHighlightRules = function() {
onMatch: function(value, currentState, state) {
value = value.substring(value.length-2, value.length-1);
var map = {'>':'<',']':'[',')':'(','}':'{'};
if(Object.keys(map).indexOf(value) != -1)
if(Object.keys(map).indexOf(value) != -1)
value = map[value];
if(value != state[1]) return "string";
state.shift();

View file

@ -44,8 +44,8 @@ var CStyleFoldMode = require("./folding/cstyle").FoldMode;
var unicode = require("../unicode");
var Mode = function(opts) {
var inline = opts && opts.inline;
var HighlightRules = inline ? PhpLangHighlightRules : PhpHighlightRules;
this.inlinePhp = opts && opts.inline;
var HighlightRules = this.inlinePhp ? PhpLangHighlightRules : PhpHighlightRules;
this.HighlightRules = HighlightRules;
this.$outdent = new MatchingBraceOutdent();
this.$behaviour = new CstyleBehaviour();
@ -117,6 +117,9 @@ oop.inherits(Mode, TextMode);
this.createWorker = function(session) {
var worker = new WorkerClient(["ace"], "ace/mode/php_worker", "PhpWorker");
worker.attachToDocument(session.getDocument());
if (this.inlinePhp)
worker.call("setOptions", [{inline: true}]);
worker.on("error", function(e) {
session.setAnnotations(e.data);

View file

@ -43,12 +43,17 @@ var PhpWorker = exports.PhpWorker = function(sender) {
oop.inherits(PhpWorker, Mirror);
(function() {
this.setOptions = function(opts) {
this.inlinePhp = opts && opts.inline;
};
this.onUpdate = function() {
var value = this.doc.getValue();
var errors = [];
// var start = new Date();
if (this.inlinePhp)
value = "<?" + value + "?>";
var tokens = PHP.Lexer(value, {short_open_tag: 1});
try {

View file

@ -130,7 +130,7 @@ var XmlHighlightRules = function(normalize) {
token : "constant.language.escape",
regex : "(?:&#[0-9]+;)|(?:&#x[0-9a-fA-F]+;)|(?:&[a-zA-Z0-9_:\\.-]+;)"
}, {
token : "invalid.illegal", regex : "&"
token : "text", regex : "&"
}],
string: [{

View file

@ -49,6 +49,7 @@ dom.importCssString(editorCss, "ace_editor");
/**
* The class that is responsible for drawing everything you see on the screen!
* @related editor.renderer
* @class VirtualRenderer
**/
@ -1469,18 +1470,18 @@ var VirtualRenderer = function(container, theme) {
**/
this.setTheme = function(theme, cb) {
var _self = this;
this.$themeValue = theme;
this.$themeId = theme;
_self._dispatchEvent('themeChange',{theme:theme});
if (!theme || typeof theme == "string") {
var moduleName = theme || "ace/theme/textmate";
var moduleName = theme || this.$options.theme.initialValue;
config.loadModule(["theme", moduleName], afterLoad);
} else {
afterLoad(theme);
}
function afterLoad(module) {
if (_self.$themeValue != theme)
if (_self.$themeId != theme)
return cb && cb();
if (!module.cssClass)
return;
@ -1507,7 +1508,7 @@ var VirtualRenderer = function(container, theme) {
// force re-measure of the gutter width
if (_self.$size) {
_self.$size.width = 0;
_self.onResize();
_self.$updateSizeAsync();
}
_self._dispatchEvent('themeLoaded', {theme:module});
@ -1520,7 +1521,7 @@ var VirtualRenderer = function(container, theme) {
* @returns {String}
**/
this.getTheme = function() {
return this.$themeValue;
return this.$themeId;
};
// Methods allows to add / remove CSS classnames to the editor element.
@ -1688,6 +1689,12 @@ config.defineOptions(VirtualRenderer.prototype, "renderer", {
this.$gutterLayer.$fixedWidth = !!val;
this.$loop.schedule(this.CHANGE_GUTTER);
}
},
theme: {
set: function(val) { this.setTheme(val) },
get: function() { return this.$themeId || this.theme; },
initialValue: "./theme/textmate",
handlesSet: true
}
});

View file

@ -11,7 +11,7 @@ var rootDir = __dirname + "/../lib/ace/";
var deps = {
csslint: {
path: "mode/css/csslint.js",
url: "https://raw.github.com/stubbornella/csslint/master/release/csslint-node.js",
url: "https://raw.github.com/stubbornella/csslint/master/release/csslint.js",
needsFixup: true
},
requirejs: {