commit
12ef5f9f6b
11 changed files with 133 additions and 57 deletions
|
|
@ -267,7 +267,7 @@ function workers(path) {
|
|||
}).filter(function(x) { return !!x; });
|
||||
}
|
||||
function modeList() {
|
||||
return jsFileList("lib/ace/mode", /_highlight_rules|_test|_worker|_outdent|behaviour|completions/)
|
||||
return jsFileList("lib/ace/mode", /_highlight_rules|_test|_worker|xml_util|_outdent|behaviour|completions/)
|
||||
}
|
||||
|
||||
function addSuffix(options) {
|
||||
|
|
@ -280,7 +280,7 @@ function addSuffix(options) {
|
|||
}
|
||||
}
|
||||
|
||||
function getWriteFilters(options, projectType) {
|
||||
function getWriteFilters(options, projectType, main) {
|
||||
var filters = [
|
||||
copy.filter.moduleDefines,
|
||||
removeUseStrict,
|
||||
|
|
@ -293,29 +293,30 @@ function getWriteFilters(options, projectType) {
|
|||
|
||||
if (options.noconflict)
|
||||
filters.push(namespace(options.ns));
|
||||
|
||||
|
||||
if (options.exportModule && projectType == "main" || projectType == "ext") {
|
||||
filters.push(exportAce(options.ns, options.exportModule,
|
||||
options.noconflict ? options.ns : "", projectType == "ext" && main));
|
||||
}
|
||||
|
||||
if (options.compress)
|
||||
filters.push(copy.filter.uglifyjs);
|
||||
|
||||
// copy.filter.uglifyjs.options.ascii = true; doesn't work with some uglify.js versions
|
||||
|
||||
// copy.filter.uglifyjs.options.ascii_only = true; doesn't work with some uglify.js versions
|
||||
filters.push(function(text) {
|
||||
var t1 = text.replace(/[\x80-\uffff]/g, function(c) {
|
||||
var text = text.replace(/[\x00-\x08\x0b\x0c\x0e\x19\x80-\uffff]/g, function(c) {
|
||||
c = c.charCodeAt(0).toString(16);
|
||||
if (c.length == 1)
|
||||
return "\\x0" + c;
|
||||
if (c.length == 2)
|
||||
return "\\x" + c;
|
||||
if (c.length == 3)
|
||||
c = "0" + c;
|
||||
return "\\u0" + c;
|
||||
return "\\u" + c;
|
||||
});
|
||||
return text;
|
||||
return text;
|
||||
});
|
||||
|
||||
if (options.exportModule && projectType == "main") {
|
||||
if (options.noconflict)
|
||||
filters.push(exportAce(options.ns, options.exportModule, options.ns));
|
||||
else
|
||||
filters.push(exportAce(options.ns, options.exportModule));
|
||||
}
|
||||
|
||||
return filters;
|
||||
}
|
||||
|
||||
|
|
@ -390,7 +391,7 @@ var buildAce = function(options) {
|
|||
project: cloneProject(project),
|
||||
require: [ 'ace/ext/' + ext ]
|
||||
}],
|
||||
filter: getWriteFilters(options, "ext"),
|
||||
filter: getWriteFilters(options, "ext", 'ace/ext/' + ext),
|
||||
dest: targetDir + "/ext-" + ext + ".js"
|
||||
});
|
||||
});
|
||||
|
|
@ -416,7 +417,7 @@ var buildAce = function(options) {
|
|||
project.assumeAllFilesLoaded();
|
||||
delete project.ignoredModules["ace/theme/textmate"];
|
||||
delete project.ignoredModules["ace/requirejs/text!ace/theme/textmate.css"];
|
||||
|
||||
|
||||
options.themes.forEach(function(theme) {
|
||||
console.log("theme " + theme);
|
||||
copy({
|
||||
|
|
@ -428,7 +429,7 @@ var buildAce = function(options) {
|
|||
dest: targetDir + "/theme-" + theme.replace("_theme", "") + ".js"
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
// generateThemesModule(options.themes);
|
||||
|
||||
console.log('# ace key bindings ---------');
|
||||
|
|
@ -552,15 +553,6 @@ var detectTextModules = function(input, source) {
|
|||
detectTextModules.onRead = true;
|
||||
copy.filter.addDefines = detectTextModules;
|
||||
|
||||
function generateThemesModule(themes) {
|
||||
var themelist = [
|
||||
'define(function(require, exports, module) {',
|
||||
'\n\nmodule.exports.themes = ' + JSON.stringify(themes, null, ' '),
|
||||
';\n\n});'
|
||||
].join('');
|
||||
fs.writeFileSync(__dirname + '/lib/ace/ext/themelist_utils/themes.js', themelist, 'utf8');
|
||||
}
|
||||
|
||||
function inlineTextModules(text) {
|
||||
var deps = [];
|
||||
return text.replace(/, *['"]ace\/requirejs\/text!(.*?)['"]| require\(['"](?:ace|[.\/]+)\/requirejs\/text!(.*?)['"]\)/g, function(_, dep, call) {
|
||||
|
|
@ -576,14 +568,38 @@ function inlineTextModules(text) {
|
|||
});
|
||||
|
||||
call = textModules[dep];
|
||||
// if (deps.length > 1)
|
||||
// console.log(call.length)
|
||||
if (call)
|
||||
return " " + call;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var CommonJsProject = copy.createCommonJsProject({roots:[]}).constructor;
|
||||
CommonJsProject.prototype.getCurrentModules = function() {
|
||||
function isDep(child, parent) {
|
||||
if (!modules[parent])
|
||||
return false;
|
||||
var deps = modules[parent].deps;
|
||||
if (deps[child]) return true;
|
||||
return Object.keys(deps).some(function(x) {
|
||||
return isDep(child, x)
|
||||
});
|
||||
}
|
||||
var depMap = {}, modules = this.currentModules;
|
||||
return Object.keys(this.currentModules).map(function(moduleName) {
|
||||
module = modules[moduleName];
|
||||
module.id = moduleName;
|
||||
module.isSpecial = !/define\(\'[^']*',/.test(module.source);
|
||||
return module;
|
||||
}).sort(function(a, b) {
|
||||
if (a.isSpecial) return -1;
|
||||
if (b.isSpecial) return 1;
|
||||
if (isDep(a.id, b.id)) return -1;
|
||||
if (isDep(b.id, a.id)) return 1;
|
||||
return Object.keys(a.deps).length - Object.keys(b.deps).length || a.id.localeCompare(b.id)
|
||||
});
|
||||
};
|
||||
|
||||
// TODO: replace with project.clone once it is fixed in dryice
|
||||
function cloneProject(project) {
|
||||
var clone = copy.createCommonJsProject({
|
||||
|
|
@ -604,16 +620,12 @@ function cloneProject(project) {
|
|||
}
|
||||
|
||||
function copyFileSync(srcFile, destFile) {
|
||||
var BUF_LENGTH = 64*1024,
|
||||
buf = new Buffer(BUF_LENGTH),
|
||||
bytesRead = BUF_LENGTH,
|
||||
pos = 0,
|
||||
fdr = null,
|
||||
fdw = null;
|
||||
|
||||
|
||||
fdr = fs.openSync(srcFile, 'r');
|
||||
fdw = fs.openSync(destFile, 'w');
|
||||
var BUF_LENGTH = 64*1024;
|
||||
var buf = new Buffer(BUF_LENGTH);
|
||||
var bytesRead = BUF_LENGTH;
|
||||
var pos = 0;
|
||||
var fdr = fs.openSync(srcFile, 'r');
|
||||
var fdw = fs.openSync(destFile, 'w');
|
||||
|
||||
while (bytesRead === BUF_LENGTH) {
|
||||
bytesRead = fs.readSync(fdr, buf, 0, BUF_LENGTH, pos);
|
||||
|
|
@ -650,23 +662,33 @@ function namespace(ns) {
|
|||
};
|
||||
}
|
||||
|
||||
function exportAce(ns, module, requireBase) {
|
||||
function exportAce(ns, module, requireBase, extModule) {
|
||||
requireBase = requireBase || "window";
|
||||
module = module || "ace/ace";
|
||||
return function(text) {
|
||||
|
||||
var template = function() {
|
||||
(function() {
|
||||
REQUIRE_NS.require(["MODULE"], function(a) {
|
||||
a && a.config.init();
|
||||
a && a.config.init(true);
|
||||
if (!window.NS)
|
||||
window.NS = {};
|
||||
window.NS = a;
|
||||
for (var key in a) if (a.hasOwnProperty(key))
|
||||
NS[key] = a[key];
|
||||
});
|
||||
})();
|
||||
};
|
||||
|
||||
|
||||
if (extModule) {
|
||||
module = extModule;
|
||||
template = function() {
|
||||
(function() {
|
||||
REQUIRE_NS.require(["MODULE"], function() {});
|
||||
})();
|
||||
};
|
||||
}
|
||||
|
||||
text = text.replace(/function init\(packaged\) {/, "init(true);$&\n");
|
||||
|
||||
return (text + ";" + template
|
||||
.toString()
|
||||
.replace(/MODULE/g, module)
|
||||
|
|
@ -683,12 +705,21 @@ function updateModes() {
|
|||
var source = fs.readFileSync(filepath, "utf8");
|
||||
if (!/this.\$id\s*=\s*"/.test(source))
|
||||
source = source.replace(/\n([ \t]*)(\}\).call\(\w*Mode.prototype\))/, '\n$1 this.$id = "";\n$1$2');
|
||||
|
||||
|
||||
source = source.replace(/(this.\$id\s*=\s*)"[^"]*"/, '$1"ace/mode/' + m + '"');
|
||||
fs.writeFileSync(filepath, source, "utf8")
|
||||
})
|
||||
}
|
||||
|
||||
function generateThemesModule(themes) {
|
||||
var themelist = [
|
||||
'define(function(require, exports, module) {',
|
||||
'\n\nmodule.exports.themes = ' + JSON.stringify(themes, null, ' '),
|
||||
';\n\n});'
|
||||
].join('');
|
||||
fs.writeFileSync(__dirname + '/lib/ace/ext/themelist_utils/themes.js', themelist, 'utf8');
|
||||
}
|
||||
|
||||
if (!module.parent)
|
||||
main(process.argv);
|
||||
else
|
||||
|
|
|
|||
|
|
@ -80,6 +80,11 @@ exports.defaultCommands = [{
|
|||
name: "alignCursors",
|
||||
exec: function(editor) { editor.alignCursors(); },
|
||||
bindKey: {win: "Ctrl-Alt-A", mac: "Ctrl-Alt-A"}
|
||||
}, {
|
||||
name: "findAll",
|
||||
exec: function(editor) { editor.findAll(); },
|
||||
bindKey: {win: "Ctrl-Alt-K", mac: "Ctrl-Alt-G"},
|
||||
readonly: true
|
||||
}];
|
||||
|
||||
// commands active only in multiselect mode
|
||||
|
|
|
|||
|
|
@ -149,12 +149,13 @@ exports.handler = {
|
|||
if (!isHandled && hashId !== -1)
|
||||
return;
|
||||
return {command: "null", passEvent: !isHandled};
|
||||
} // if no modifier || shift: wait for input.
|
||||
else if (key.length == 1 && (hashId === 0 || hashId == 4)) {
|
||||
return {command: "null", passEvent: true};
|
||||
} else if (key == "esc" && hashId === 0) {
|
||||
return {command: coreCommands.stop};
|
||||
}
|
||||
// if no modifier || shift: wait for input.
|
||||
else if (hashId === 0 || hashId == 4) {
|
||||
return {command: "null", passEvent: true};
|
||||
}
|
||||
} else {
|
||||
if (key == "ctrl-w") {
|
||||
return {command: "removewordleft"};
|
||||
|
|
|
|||
|
|
@ -123,10 +123,12 @@ var actions = exports.actions = {
|
|||
range.end.column++;
|
||||
var text = editor.session.getTextRange(range);
|
||||
var toggled = text.toUpperCase();
|
||||
if (toggled == text)
|
||||
editor.navigateRight();
|
||||
else
|
||||
if (toggled != text)
|
||||
editor.session.replace(range, toggled);
|
||||
else if (text.toLowerCase() != text)
|
||||
editor.session.replace(range, text.toLowerCase())
|
||||
else
|
||||
editor.navigateRight();
|
||||
}, count || 1);
|
||||
}
|
||||
},
|
||||
|
|
@ -164,6 +166,7 @@ var actions = exports.actions = {
|
|||
fn: function(editor, range, count, param) {
|
||||
var options = editor.getLastSearchOptions();
|
||||
options.backwards = false;
|
||||
options.start = null;
|
||||
|
||||
editor.selection.moveCursorRight();
|
||||
editor.selection.clearSelection();
|
||||
|
|
@ -180,6 +183,7 @@ var actions = exports.actions = {
|
|||
fn: function(editor, range, count, param) {
|
||||
var options = editor.getLastSearchOptions();
|
||||
options.backwards = true;
|
||||
options.start = null;
|
||||
|
||||
editor.findPrevious(options);
|
||||
ensureScrollMargin(editor);
|
||||
|
|
@ -340,6 +344,7 @@ var inputBuffer = exports.inputBuffer = {
|
|||
currentCmd: null,
|
||||
//currentMode: 0,
|
||||
currentCount: "",
|
||||
pendingCount: "",
|
||||
status: "",
|
||||
|
||||
// Types
|
||||
|
|
@ -440,8 +445,9 @@ var inputBuffer = exports.inputBuffer = {
|
|||
},
|
||||
|
||||
getCount: function() {
|
||||
var count = this.currentCount;
|
||||
var count = this.currentCount || this.pendingCount;
|
||||
this.currentCount = "";
|
||||
this.pendingCount = count;
|
||||
return count && parseInt(count, 10);
|
||||
},
|
||||
|
||||
|
|
@ -497,7 +503,8 @@ var inputBuffer = exports.inputBuffer = {
|
|||
else if (selectable) {
|
||||
repeat(function() {
|
||||
run(motionObj.sel);
|
||||
operators[o.ch].fn(editor, editor.getSelectionRange(), o.count, param);
|
||||
operators[o.ch].fn(editor, editor.getSelectionRange(),
|
||||
o.count, motionObj.param ? motionObj : param);
|
||||
}, o.count || 1);
|
||||
}
|
||||
this.reset();
|
||||
|
|
@ -517,6 +524,7 @@ var inputBuffer = exports.inputBuffer = {
|
|||
this.operator = null;
|
||||
this.motion = null;
|
||||
this.currentCount = "";
|
||||
this.pendingCount = "";
|
||||
this.status = "";
|
||||
this.accepting = [NUMBER, OPERATOR, MOTION, ACTION];
|
||||
this.idle = true;
|
||||
|
|
|
|||
|
|
@ -350,6 +350,10 @@ module.exports = {
|
|||
case "W":
|
||||
editor.selection.selectAWord();
|
||||
break;
|
||||
case ")":
|
||||
case "}":
|
||||
case "]":
|
||||
param = editor.session.$brackets[param];
|
||||
case "(":
|
||||
case "{":
|
||||
case "[":
|
||||
|
|
@ -383,6 +387,7 @@ module.exports = {
|
|||
param: true,
|
||||
handlesCount: true,
|
||||
getPos: function(editor, range, count, param, isSel, isRepeat) {
|
||||
if (param == "space") param = " ";
|
||||
if (!isRepeat)
|
||||
LAST_SEARCH_MOTION = {ch: "f", param: param};
|
||||
var cursor = editor.getCursorPosition();
|
||||
|
|
@ -398,6 +403,7 @@ module.exports = {
|
|||
param: true,
|
||||
handlesCount: true,
|
||||
getPos: function(editor, range, count, param, isSel, isRepeat) {
|
||||
if (param == "space") param = " ";
|
||||
if (!isRepeat)
|
||||
LAST_SEARCH_MOTION = {ch: "F", param: param};
|
||||
var cursor = editor.getCursorPosition();
|
||||
|
|
@ -413,6 +419,7 @@ module.exports = {
|
|||
param: true,
|
||||
handlesCount: true,
|
||||
getPos: function(editor, range, count, param, isSel, isRepeat) {
|
||||
if (param == "space") param = " ";
|
||||
if (!isRepeat)
|
||||
LAST_SEARCH_MOTION = {ch: "t", param: param};
|
||||
var cursor = editor.getCursorPosition();
|
||||
|
|
@ -431,6 +438,7 @@ module.exports = {
|
|||
param: true,
|
||||
handlesCount: true,
|
||||
getPos: function(editor, range, count, param, isSel, isRepeat) {
|
||||
if (param == "space") param = " ";
|
||||
if (!isRepeat)
|
||||
LAST_SEARCH_MOTION = {ch: "T", param: param};
|
||||
var cursor = editor.getCursorPosition();
|
||||
|
|
@ -656,7 +664,8 @@ module.exports = {
|
|||
pos.column = line.length;
|
||||
return pos;
|
||||
}
|
||||
}
|
||||
},
|
||||
isLine: true
|
||||
})
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -115,6 +115,8 @@ module.exports = {
|
|||
},
|
||||
fn: function(editor, range, count, param) {
|
||||
count = count || 1;
|
||||
if (param && param.isLine)
|
||||
param = "y";
|
||||
switch (param) {
|
||||
case "y":
|
||||
var pos = editor.getCursorPosition();
|
||||
|
|
|
|||
|
|
@ -133,6 +133,15 @@ var Keys = (function() {
|
|||
|
||||
// workaround for firefox bug
|
||||
ret[173] = '-';
|
||||
|
||||
(function() {
|
||||
var mods = ["cmd", "ctrl", "alt", "shift"];
|
||||
for (var i = Math.pow(2, mods.length); i--;) {
|
||||
ret.KEY_MODS[i] = mods.filter(function(x) {
|
||||
return i & ret.KEY_MODS[x];
|
||||
}).join("-") + "-";
|
||||
}
|
||||
})();
|
||||
|
||||
(function() {
|
||||
var mods = ["cmd", "ctrl", "alt", "shift"];
|
||||
|
|
|
|||
|
|
@ -176,9 +176,12 @@ var JavaScriptHighlightRules = function() {
|
|||
}, {
|
||||
token : ["punctuation.operator", "support.constant"],
|
||||
regex : /(\.)(s(?:ystemLanguage|cr(?:ipts|ollbars|een(?:X|Y|Top|Left))|t(?:yle(?:Sheets)?|atus(?:Text|bar)?)|ibling(?:Below|Above)|ource|uffixes|e(?:curity(?:Policy)?|l(?:ection|f)))|h(?:istory|ost(?:name)?|as(?:h|Focus))|y|X(?:MLDocument|SLDocument)|n(?:ext|ame(?:space(?:s|URI)|Prop))|M(?:IN_VALUE|AX_VALUE)|c(?:haracterSet|o(?:n(?:structor|trollers)|okieEnabled|lorDepth|mp(?:onents|lete))|urrent|puClass|l(?:i(?:p(?:boardData)?|entInformation)|osed|asses)|alle(?:e|r)|rypto)|t(?:o(?:olbar|p)|ext(?:Transform|Indent|Decoration|Align)|ags)|SQRT(?:1_2|2)|i(?:n(?:ner(?:Height|Width)|put)|ds|gnoreCase)|zIndex|o(?:scpu|n(?:readystatechange|Line)|uter(?:Height|Width)|p(?:sProfile|ener)|ffscreenBuffering)|NEGATIVE_INFINITY|d(?:i(?:splay|alog(?:Height|Top|Width|Left|Arguments)|rectories)|e(?:scription|fault(?:Status|Ch(?:ecked|arset)|View)))|u(?:ser(?:Profile|Language|Agent)|n(?:iqueID|defined)|pdateInterval)|_content|p(?:ixelDepth|ort|ersonalbar|kcs11|l(?:ugins|atform)|a(?:thname|dding(?:Right|Bottom|Top|Left)|rent(?:Window|Layer)?|ge(?:X(?:Offset)?|Y(?:Offset)?))|r(?:o(?:to(?:col|type)|duct(?:Sub)?|mpter)|e(?:vious|fix)))|e(?:n(?:coding|abledPlugin)|x(?:ternal|pando)|mbeds)|v(?:isibility|endor(?:Sub)?|Linkcolor)|URLUnencoded|P(?:I|OSITIVE_INFINITY)|f(?:ilename|o(?:nt(?:Size|Family|Weight)|rmName)|rame(?:s|Element)|gColor)|E|whiteSpace|l(?:i(?:stStyleType|n(?:eHeight|kColor))|o(?:ca(?:tion(?:bar)?|lName)|wsrc)|e(?:ngth|ft(?:Context)?)|a(?:st(?:M(?:odified|atch)|Index|Paren)|yer(?:s|X)|nguage))|a(?:pp(?:MinorVersion|Name|Co(?:deName|re)|Version)|vail(?:Height|Top|Width|Left)|ll|r(?:ity|guments)|Linkcolor|bove)|r(?:ight(?:Context)?|e(?:sponse(?:XML|Text)|adyState))|global|x|m(?:imeTypes|ultiline|enubar|argin(?:Right|Bottom|Top|Left))|L(?:N(?:10|2)|OG(?:10E|2E))|b(?:o(?:ttom|rder(?:Width|RightWidth|BottomWidth|Style|Color|TopWidth|LeftWidth))|ufferDepth|elow|ackground(?:Color|Image)))\b/
|
||||
}, {
|
||||
token : ["support.constant"],
|
||||
regex : /that\b/
|
||||
}, {
|
||||
token : ["storage.type", "punctuation.operator", "support.function.firebug"],
|
||||
regex : /(console)(\.)(warn|info|log|error|time|timeEnd|assert)\b/
|
||||
regex : /(console)(\.)(warn|info|log|error|time|trace|timeEnd|assert)\b/
|
||||
}, {
|
||||
token : keywordMapper,
|
||||
regex : identifierRe
|
||||
|
|
|
|||
|
|
@ -36,10 +36,12 @@ var TextMode = require("./text").Mode;
|
|||
var ShHighlightRules = require("./sh_highlight_rules").ShHighlightRules;
|
||||
var Range = require("../range").Range;
|
||||
var CStyleFoldMode = require("./folding/cstyle").FoldMode;
|
||||
var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour;
|
||||
|
||||
var Mode = function() {
|
||||
this.HighlightRules = ShHighlightRules;
|
||||
this.foldingRules = new CStyleFoldMode();
|
||||
this.$behaviour = new CstyleBehaviour();
|
||||
};
|
||||
oop.inherits(Mode, TextMode);
|
||||
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ var ShHighlightRules = function() {
|
|||
var floatNumber = "(?:" + exponentFloat + "|" + pointFloat + ")";
|
||||
var fileDescriptor = "(?:&" + intPart + ")";
|
||||
|
||||
var variableName = "[a-zA-Z][a-zA-Z0-9_]*";
|
||||
var variableName = "[a-zA-Z_][a-zA-Z0-9_]*";
|
||||
var variable = "(?:(?:\\$" + variableName + ")|(?:" + variableName + "=))";
|
||||
|
||||
var builtinVariable = "(?:\\$(?:SHLVL|\\$|\\!|\\?))";
|
||||
|
|
|
|||
|
|
@ -578,8 +578,14 @@ var Editor = require("./editor").Editor;
|
|||
this.findAll = function(needle, options, additive) {
|
||||
options = options || {};
|
||||
options.needle = needle || options.needle;
|
||||
if (options.needle == undefined) {
|
||||
var range = this.selection.isEmpty()
|
||||
? this.selection.getWordRange()
|
||||
: this.selection.getRange();
|
||||
options.needle = this.session.getTextRange(range);
|
||||
}
|
||||
this.$search.set(options);
|
||||
|
||||
|
||||
var ranges = this.$search.findAll(this.session);
|
||||
if (!ranges.length)
|
||||
return 0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue