Merge remote-tracking branch 'remotes/origin/master' into v-1.2

Conflicts:
	lib/ace/anchor.js
	lib/ace/keyboard/vim/maps/operators.js
This commit is contained in:
nightwing 2014-07-02 21:58:13 +04:00
commit 1f7582b5a6
267 changed files with 107605 additions and 62551 deletions

View file

@ -1,3 +1,13 @@
2014.07.01 Version 1.1.4
* New Features
- Highlight matching tags (Adam Jimenez)
- Improved jump to matching command (Adam Jimenez)
* new language modes
- AppleScript (Yaogang Lian)
- Vala
2014.03.08 Version 1.1.3 2014.03.08 Version 1.1.3
* New Features * New Features

View file

@ -13,7 +13,6 @@ pre_build:
build: pre_build build: pre_build
./Makefile.dryice.js normal ./Makefile.dryice.js normal
./Makefile.dryice.js demo ./Makefile.dryice.js demo
./Makefile.dryice.js bm
# Minimal build: call Makefile.dryice.js only if our sources changed # Minimal build: call Makefile.dryice.js only if our sources changed
basic: build/src/ace.js basic: build/src/ace.js

View file

@ -31,14 +31,12 @@
var fs = require("fs"); var fs = require("fs");
var path = require("path"); var path = require("path");
if (!fs.existsSync) var copy = require('architect-build/copy');
fs.existsSync = path.existsSync; var build = require('architect-build/build');
else
path.existsSync = fs.existsSync;
var copy = require('dryice').copy;
var ACE_HOME = __dirname; var ACE_HOME = __dirname;
var BUILD_DIR = ACE_HOME + "/build"; var BUILD_DIR = ACE_HOME + "/build";
var CACHE = {};
function main(args) { function main(args) {
if (args.indexOf("updateModes") !== -1) { if (args.indexOf("updateModes") !== -1) {
@ -49,7 +47,7 @@ function main(args) {
if (x[0] == "-" && x[1] != "-") if (x[0] == "-" && x[1] != "-")
return "-" + x; return "-" + x;
return x; return x;
}); }).filter(Boolean);
if (args[2] && (args[2][0] != "-" || args[2].indexOf("h") != -1)) if (args[2] && (args[2][0] != "-" || args[2].indexOf("h") != -1))
type = args[2]; type = args[2];
@ -69,36 +67,22 @@ function main(args) {
ace(); ace();
} else if (type == "demo") { } else if (type == "demo") {
demo(); demo();
} else if (type == "bm") {
bookmarklet();
} else if (type == "full") { } else if (type == "full") {
demo(ace()); ace();
bookmarklet(); demo();
} else if (type == "highlighter") { } else if (type == "highlighter") {
var project = buildAce({ // TODO
coreOnly: true,
exportModule: "ace/ext/static_highlight",
requires: ["ace/ext/static_highlight", "ace/theme/textmate"],
readFilters: [copy.filter.moduleDefines, function(a) {
console.log(a.substring(0, 2500))
return a
}]
})
copy({
source: project.result,
filter: getWriteFilters(project.options, "main"),
dest: BUILD_DIR + "/static_highlight.js"
});
} }
} }
}
function showHelp(type) {
console.log("--- Ace Dryice Build Tool ---"); console.log("--- Ace Dryice Build Tool ---");
console.log(""); console.log("");
console.log("Options:"); console.log("Options:");
console.log(" minimal Places necessary Ace files out in build dir; uses configuration flags below [default]"); console.log(" minimal Places necessary Ace files out in build dir; uses configuration flags below [default]");
console.log(" normal Runs four Ace builds--minimal, minimal-noconflict, minimal-min, and minimal-noconflict-min"); console.log(" normal Runs four Ace builds--minimal, minimal-noconflict, minimal-min, and minimal-noconflict-min");
console.log(" demo Runs demo build of Ace"); console.log(" demo Runs demo build of Ace");
console.log(" bm Runs bookmarklet build of Ace");
console.log(" full all of above"); console.log(" full all of above");
console.log(" highlighter "); console.log(" highlighter ");
console.log("args:"); console.log("args:");
@ -109,91 +93,30 @@ function main(args) {
console.log(" --nc namespace require"); console.log(" --nc namespace require");
console.log(" --s shrinkwrap (combines all output files into one)"); console.log(" --s shrinkwrap (combines all output files into one)");
console.log(""); console.log("");
if (BUILD_DIR) if (type)
console.log(" output generated in " + type + __dirname + "/" + BUILD_DIR) console.log(" output for " + type + " generated in " + BUILD_DIR);
}
function bookmarklet() {
var targetDir = BUILD_DIR + "/textarea";
copy({
source: "build_support/editor_textarea.html",
dest: targetDir + '/editor.html'
});
copy({
source: "build_support/style.css",
dest: targetDir + '/style.css'
});
buildAce({
targetDir: targetDir + "/src",
ns: "__ace_shadowed__",
exportModule: "ace/ext/textarea",
compress: false,
noconflict: true,
suffix: "",
name: "ace-bookmarklet",
workers: [],
keybindings: []
});
} }
function ace() { function ace() {
console.log('# ace ---------');
// uncompressed
var project = buildAce({
compress: false,
noconflict: false
});
buildAce({
compress: false,
noconflict: true
});
// compressed
buildAce({
compress: true,
noconflict: false
});
buildAce({
compress: true,
noconflict: true
});
console.log('# ace License | Readme | Changelog ---------'); console.log('# ace License | Readme | Changelog ---------');
copy({ copy.file(ACE_HOME + "/build_support/editor.html", BUILD_DIR + "/editor.html");
source: ACE_HOME + "/build_support/editor.html", copy.file(ACE_HOME + "/LICENSE", BUILD_DIR + "/LICENSE");
dest: BUILD_DIR + "/editor.html" copy.file(ACE_HOME + "/ChangeLog.txt", BUILD_DIR + "/ChangeLog.txt");
});
copy({
source: ACE_HOME + "/LICENSE",
dest: BUILD_DIR + "/LICENSE"
});
copy({
source: ACE_HOME + "/ChangeLog.txt",
dest: BUILD_DIR + "/ChangeLog.txt"
});
return project; console.log('# ace ---------');
for (var i = 0; i < 4; i++)
buildAce({compress: i & 2, noconflict: i & 1});
} }
function demo(project) { function demo() {
project = project || buildAce({
compress: false,
noconflict: false,
coreOnly: true
});
console.log('# kitchen sink ---------'); console.log('# kitchen sink ---------');
var version, ref; var version = "", ref = "";
try { try {
version = JSON.parse(fs.readFileSync(ACE_HOME + "/package.json")).version; version = JSON.parse(fs.readFileSync(ACE_HOME + "/package.json")).version;
ref = fs.readFileSync(ACE_HOME + "/.git-ref").toString(); ref = fs.readFileSync(ACE_HOME + "/.git-ref").toString();
} catch(e) { } catch(e) {}
ref = "";
version = "";
}
function changeComments(data) { function changeComments(data) {
return (data return (data
@ -204,49 +127,55 @@ function demo(project) {
.replace("%version%", version) .replace("%version%", version)
.replace("%commit%", ref) .replace("%commit%", ref)
); );
};
function fixDocPaths(data) {
return data.replace(/"(demo|build)\//g, "\"");
} }
copy({ copy(ACE_HOME +"/demo/kitchen-sink/docs/", BUILD_DIR + "/demo/kitchen-sink/docs/");
source: ACE_HOME + "/kitchen-sink.html",
dest: BUILD_DIR + "/kitchen-sink.html",
filter: [changeComments, fixDocPaths]
});
copy({ copy.file(ACE_HOME + "/demo/kitchen-sink/logo.png", BUILD_DIR + "/demo/kitchen-sink/logo.png");
source: ACE_HOME + "/demo/kitchen-sink/styles.css", copy.file(ACE_HOME + "/demo/kitchen-sink/styles.css", BUILD_DIR + "/demo/kitchen-sink/styles.css");
dest: BUILD_DIR + "/kitchen-sink/styles.css", copy.file(ACE_HOME + "/kitchen-sink.html", BUILD_DIR + "/kitchen-sink.html", changeComments);
filter: [ changeComments ]
});
fs.readdirSync(ACE_HOME +"/demo/kitchen-sink/docs/").forEach(function(x) { buildSubmodule({}, {
copy({ require: ["kitchen-sink/demo"],
source: ACE_HOME +"/demo/kitchen-sink/docs/" + x, projectType: "demo"
dest: BUILD_DIR + "/kitchen-sink/docs/" + x }, BUILD_DIR + "/demo/kitchen-sink/demo");
});
});
var demo = copy.createDataObject(); copy(ACE_HOME + "/demo/", BUILD_DIR + "/demo/", {
shallow: true,
project.assumeAllFilesLoaded(); exclude: /\s|requirejs/,
copy({ include: /\.(js|html)$/,
source: [{ replace: function(source) {
project: cloneProject(project), if (!/^\s*</.test(source))
require: [ "kitchen-sink/demo" ] return source;
}], var removeRequireJS;
filter: getWriteFilters({filters:[fixDocPaths]}, "demo"), source = source.replace(/<script src="kitchen-sink\/require.js"[\s\S]+?require\(\[([^\]]+).*/, function(e, m) {
dest: demo removeRequireJS = true;
var scripts = m.split(/,\s*/);
var result = [];
function comment(str) {result.push("<!-- " + str + " -->")}
function script(str) {result.push('<script src="../src/' + str + '.js"></script>')}
scripts.forEach(function(s) {
s = s.replace(/"/g, "");
if (s == "ace/ace") {
comment("load ace");
script("ace");
} else {
var extName = s.match(/[^/]*$/)[0];
comment("load ace " + extName + " extension");
script("ext-" + extName);
}
}); });
result.push("<script>");
copy({ return result.join("\n");
source: demo, });
dest: BUILD_DIR + "/kitchen-sink/demo.js", if (removeRequireJS)
source = source.replace(/\s*\}\);?\s*(<\/script>)/, "\n$1");
source = source.replace(/"\.\.\/build\//g, function(e) {
console.log(e); return '"../';
});
return source;
}
}); });
copyFileSync(ACE_HOME + "/demo/kitchen-sink/logo.png", BUILD_DIR + "/kitchen-sink/logo.png");
} }
function jsFileList(path, filter) { function jsFileList(path, filter) {
@ -257,7 +186,7 @@ function jsFileList(path, filter) {
return fs.readdirSync(path).map(function(x) { return fs.readdirSync(path).map(function(x) {
if (x.slice(-3) == ".js" && !filter.test(x) && !/\s/.test(x)) if (x.slice(-3) == ".js" && !filter.test(x) && !/\s/.test(x))
return x.slice(0, -3); return x.slice(0, -3);
}).filter(function(x){ return !!x }); }).filter(Boolean);
} }
function workers(path) { function workers(path) {
@ -266,300 +195,244 @@ function workers(path) {
return x.slice(0, -7); return x.slice(0, -7);
}).filter(function(x) { return !!x; }); }).filter(function(x) { return !!x; });
} }
function modeList() { function modeList() {
return jsFileList("lib/ace/mode", /_highlight_rules|_test|_worker|xml_util|_outdent|behaviour|completions/) return jsFileList("lib/ace/mode", /_highlight_rules|_test|_worker|xml_util|_outdent|behaviour|completions/);
} }
function addSuffix(options) { function buildAceModule(opts, callback) {
if (options.suffix == null) { // calling buildAceModuleInternal many times in parallel is slow, so we use queue
options.suffix = ""; if (!buildAceModule.queue) {
if (options.compress) buildAceModule.queue = [];
options.suffix += "-min"; buildAceModule.dequeue = function() {
if (options.noconflict) if (buildAceModule.running) return;
options.suffix += "-noconflict"; var call = buildAceModule.queue.shift();
} buildAceModule.running = call;
} if (call)
buildAceModuleInternal.apply(null, call);
function getWriteFilters(options, projectType, main) {
var filters = [
copy.filter.moduleDefines,
removeUseStrict,
removeLicenceComments,
inlineTextModules
];
if (options.filters)
filters = filters.concat(options.filters);
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_only = true; doesn't work with some uglify.js versions
filters.push(function(text) {
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)
return "\\u0" + c;
return "\\u" + c;
});
return text;
});
return filters;
}
var buildAce = function(options) {
var aceProject = {
roots: [ACE_HOME + '/lib', ACE_HOME + '/demo'],
textPluginPattern: /^ace\/requirejs\/text!/
}; };
var defaults = {
targetDir: BUILD_DIR + "/src",
ns: "ace",
exportModule: "ace/ace",
requires: null,
compress: false,
noconflict: false,
suffix: null,
name: "ace",
modes: modeList(),
themes: jsFileList("lib/ace/theme"),
extensions: jsFileList("lib/ace/ext"),
workers: workers("lib/ace/mode"),
keybindings: ["vim", "emacs"],
readFilters: [copy.filter.moduleDefines]
};
for(var key in defaults)
if (!options.hasOwnProperty(key))
options[key] = defaults[key];
addSuffix(options);
if (!options.requires)
options.requires = [options.exportModule];
var targetDir = options.targetDir + options.suffix;
var name = options.name;
var project = copy.createCommonJsProject(aceProject);
project.options = options;
var ace = copy.createDataObject();
copy({
source: [ACE_HOME + "/build_support/mini_require.js"],
dest: ace
});
copy({
source: [{
project: project,
require: options.requires
}],
filter: options.readFilters,
dest: ace
});
if (options.coreOnly) {
project.result = ace;
return project;
}
copy({
source: ace,
filter: getWriteFilters(options, "main"),
dest: targetDir + '/' + name + ".js"
});
console.log('# ace extensions ---------');
project.assumeAllFilesLoaded();
options.extensions.forEach(function(ext) {
console.log("extensions " + ext);
copy({
source: [{
project: cloneProject(project),
require: [ 'ace/ext/' + ext ]
}],
filter: getWriteFilters(options, "ext", 'ace/ext/' + ext),
dest: targetDir + "/ext-" + ext + ".js"
});
});
console.log('# ace modes ---------');
project.assumeAllFilesLoaded();
options.modes.forEach(function(mode) {
console.log("mode " + mode);
addSnippetFile(mode, project, targetDir, options);
copy({
source: [{
project: cloneProject(project),
require: [ 'ace/mode/' + mode ]
}],
filter: getWriteFilters(options, "mode"),
dest: targetDir + "/mode-" + mode + ".js"
});
});
console.log('# ace themes ---------');
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({
source: [{
project: cloneProject(project),
require: ["ace/theme/" + theme]
}],
filter: getWriteFilters(options, "theme"),
dest: targetDir + "/theme-" + theme.replace("_theme", "") + ".js"
});
});
// generateThemesModule(options.themes);
console.log('# ace key bindings ---------');
// copy key bindings
project.assumeAllFilesLoaded();
options.keybindings.forEach(function(keybinding) {
copy({
source: [{
project: cloneProject(project),
require: [ 'ace/keyboard/' + keybinding ]
}],
filter: getWriteFilters(options, "keybinding"),
dest: targetDir + "/keybinding-" + keybinding + ".js"
});
});
console.log('# ace worker ---------');
options.workers.forEach(function(mode) {
console.log("worker for " + mode + " mode");
var worker = copy.createDataObject();
var workerProject = copy.createCommonJsProject({
roots: [ ACE_HOME + '/lib' ],
textPluginPattern: /^ace\/requirejs\/text!/
});
copy({
source: [{
project: workerProject,
require: [
'ace/worker/worker',
'ace/mode/' + mode + '_worker'
]
}],
filter: getWriteFilters(options, "worker"),
dest: worker
});
copy({
source: [
worker
],
filter: options.compress ? [copy.filter.uglifyjs] : [],
dest: targetDir + "/worker-" + mode + ".js"
});
});
if (options.shrinkwrap) {
console.log('# combining files into one ---------');
copy({
source: { root:targetDir, exclude:/(^|\\|\/)worker\-[^\\\/]*\.js$/ },
dest: BUILD_DIR + '/ace-min.js'
});
} }
return project; buildAceModule.queue.push([opts, function(err, result) {
}; callback && callback(err, result);
buildAceModule.running = null;
buildAceModule.dequeue();
}]);
// silence annoying messages from dryice if (!buildAceModule.running) {
var buildAce = function(fn) { buildAceModule.dequeue();
return function() {
var log = console.log
console.log = function() {
if (typeof arguments[0] == "string" && /Ignoring requirement/.test(arguments[0]))
return;
log.apply(console, arguments);
}
var ret = fn.apply(null, arguments);
console.log = log;
return ret;
}
}(buildAce);
var addSnippetFile = function(modeName, project, targetDir, options) {
var snippetFilePath = ACE_HOME + "/lib/ace/snippets/" + modeName;
if (!fs.existsSync(snippetFilePath + ".js")) {
copy({
source: ACE_HOME + "/tool/snippets.tmpl.js",
dest: snippetFilePath + ".js",
filter: [
function(t) {return t.replace(/%modeName%/g, modeName);}
]
});
}
if (!fs.existsSync(snippetFilePath + ".snippets")) {
fs.writeFileSync(snippetFilePath + ".snippets", "")
}
copy({
source: [{
project: cloneProject(project),
require: [ 'ace/snippets/' + modeName ]
}],
filter: getWriteFilters(options, "mode"),
dest: targetDir + "/snippets/" + modeName + ".js"
});
}
var textModules = {}
var detectTextModules = function(input, source) {
if (!source)
throw new Error('Missing filename for text module');
if (typeof input !== 'string')
input = input.toString();
var module = source.isLocation ? source.path : source;
input = input.replace(/\\/g, "\\\\").replace(/"/g, '\\"');
if (/\.css$/.test(module)) {
// remove unnecessary whitespace from css
input = input.replace(/\n\s+/g, "\n");
input = '"' + input.replace(/\r?\n/g, '\\\n') + '"';
} else { } else {
// but don't break other files! process.nextTick(buildAceModule.dequeue);
input = '"' + input.replace(/\r?\n/g, '\\n\\\n') + '"';
} }
textModules[module] = input; }
return ""; function buildAceModuleInternal(opts, callback) {
}; var cache = opts.cache == undefined ? CACHE : opts.cache;
detectTextModules.onRead = true; var key = opts.require + "|" + opts.projectType;
copy.filter.addDefines = detectTextModules; if (cache && cache.configs && cache.configs[key])
return write(null, cache.configs[key]);
function inlineTextModules(text) { var pathConfig = {
var deps = []; paths: {
return text.replace(/, *['"]ace\/requirejs\/text!(.*?)['"]| require\(['"](?:ace|[.\/]+)\/requirejs\/text!(.*?)['"]\)/g, function(_, dep, call) { ace: ACE_HOME + "/lib/ace",
if (dep) { "kitchen-sink": ACE_HOME + "/demo/kitchen-sink",
deps.push(dep); build_support: ACE_HOME + "/build_support",
return ""; },
} else if (call) { root: ACE_HOME
};
function write(err, result) {
if (cache && key && !(cache.configs && cache.configs[key])) {
cache.configs = cache.configs || Object.create(null);
cache.configs[key] = result;
result.sources = result.sources.map(function(pkg) {
return {deps: pkg.deps};
});
}
if (!opts.outputFile)
return callback(err, result);
var code = result.code;
if (opts.compress) {
if (!result.codeMin)
result.codeMin = compress(result.code);
code = result.codeMin;
}
var targetDir = BUILD_DIR + "/src";
if (opts.compress)
targetDir += "-min";
if (opts.noconflict)
targetDir += "-noconflict";
var to = /^([\\/]|\w:)/.test(opts.outputFile)
? opts.outputFile
: path.join(opts.outputFolder || targetDir, opts.outputFile);
var filters = [];
var ns = opts.ns || "ace";
if (opts.filters)
filters = filters.concat(opts.filters);
if (opts.noconflict)
filters.push(namespace(ns));
var projectType = opts.projectType;
if (projectType == "main" || projectType == "ext") {
filters.push(exportAce(ns, opts.require[0],
opts.noconflict ? ns : "", projectType == "ext"));
}
filters.forEach(function(f) { code = f(code); });
build.writeToFile({code: code}, {
outputFolder: path.dirname(to),
outputFile: path.basename(to),
}, function() {});
callback && callback(err, result);
}
build(opts.require, {
cache: cache,
quiet: opts.quiet,
pathConfig: pathConfig,
additional: opts.additional,
enableBrowser: true,
keepDepArrays: "all",
noArchitect: true,
compress: false,
ignore: opts.ignore || [],
withRequire: false,
basepath: ACE_HOME,
afterRead: [optimizeTextModules]
}, write);
}
function buildCore(options, extra, callback) {
options = extend(extra, options);
options.additional = [{
id: "build_support/mini_require",
order: -1000,
literal: true
}];
options.require =["ace/ace"];
options.projectType = "main";
options.ns = "ace";
buildAceModule(options, callback);
}
function buildSubmodule(options, extra, file, callback) {
options = extend(extra, options);
getLoadedFileList(options, function(coreFiles) {
options.outputFile = file + ".js";
options.ignore = options.ignore || coreFiles;
options.quiet = true;
buildAceModule(options, callback);
});
}
function buildAce(options) {
var snippetFiles = jsFileList("lib/ace/snippets");
var modeNames = modeList();
buildCore(options, {outputFile: "ace.js"}),
// modes
modeNames.forEach(function(name) {
buildSubmodule(options, {
projectType: "mode",
require: ["ace/mode/" + name]
}, "mode-" + name);
});
// snippets
modeNames.forEach(function(name) {
if (snippetFiles.indexOf(name + ".js") == -1)
addSnippetFile(name);
buildSubmodule(options, {
require: ["ace/snippets/" + name],
}, "snippets/" + name);
});
// themes
jsFileList("lib/ace/theme").forEach(function(name) {
buildSubmodule(options, {
projectType: "theme",
require: ["ace/theme/" + name]
}, "theme-" + name.replace("_theme", ""));
});
// keybindings
["vim", "emacs"].forEach(function(name) {
buildSubmodule(options, {
projectType: "keybinding",
require: ["ace/keyboard/" + name ]
}, "keybinding-" + name);
});
// extensions
jsFileList("lib/ace/ext").forEach(function(name) {
buildSubmodule(options, {
projectType: "ext",
require: ["ace/ext/" + name]
}, "ext-" + name);
});
// workers
workers("lib/ace/mode").forEach(function(name) {
buildSubmodule(options, {
projectType: "worker",
require: ["ace/mode/" + name + "_worker"],
ignore: [],
additional: [{
id: "ace/worker/worker",
transforms: [],
order: -1000
}],
}, "worker-" + name);
});
}
function getLoadedFileList(options, callback, result) {
if (!result) {
return buildCore({}, {}, function(e, result) {
getLoadedFileList(options, callback, result);
});
}
var deps = Object.create(null);
result.sources.forEach(function(pkg) {
pkg.deps && pkg.deps.forEach(function(p) {
if (!deps[p]) deps[p] = 1;
});
});
delete deps["ace/theme/textmate"];
callback(Object.keys(deps));
}
function optimizeTextModules(sources) {
var textModules = {};
return sources.filter(function(pkg) {
if (!pkg.id) {
return true;
}
else if (pkg.id.indexOf("text!") > -1) {
detectTextModules(pkg);
return false;
}
else {
pkg.source = rewriteTextImports(pkg.source, pkg.deps);
return true;
}
}).map(function(pkg) {
if (pkg && pkg.deps) {
pkg.deps = pkg.deps && pkg.deps.filter(function(p) {
return p.indexOf("text!") == -1;
});
}
return pkg;
});
function rewriteTextImports(text, deps) {
return text.replace(/ require\(['"](?:ace|[.\/]+)\/requirejs\/text!(.*?)['"]\)/g, function(_, call) {
if (call) {
var dep;
deps.some(function(d) { deps.some(function(d) {
if (d.split("/").pop() == call.split("/").pop()) { if (d.split("/").pop() == call.split("/").pop()) {
dep = d; dep = d;
@ -572,126 +445,66 @@ function inlineTextModules(text) {
return " " + 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; function detectTextModules(pkg) {
return Object.keys(this.currentModules).map(function(moduleName) { var input = pkg.source.replace(/\\/g, "\\\\").replace(/"/g, '\\"');
module = modules[moduleName]; if (/\.css$/.test(pkg.id)) {
module.id = moduleName; // remove unnecessary whitespace from css
module.isSpecial = !/define\(\'[^']*',/.test(module.source); input = input.replace(/\n\s+/g, "\n");
return module; input = '"' + input.replace(/\r?\n/g, '\\\n') + '"';
}).sort(function(a, b) { } else {
if (a.isSpecial) return -1; // but don't break other files!
if (b.isSpecial) return 1; input = '"' + input.replace(/\r?\n/g, '\\n\\\n') + '"';
if (isDep(a.id, b.id)) return -1; }
if (isDep(b.id, a.id)) return 1; textModules[pkg.id] = input;
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({
roots: project.roots,
ignores: project.ignoreRequires,
textPluginPattern: project.textPluginPattern
});
Object.keys(project.currentModules).forEach(function(module) {
clone.currentModules[module] = project.currentModules[module];
});
Object.keys(project.ignoredModules).forEach(function(module) {
clone.ignoredModules[module] = project.ignoredModules[module];
});
return clone;
}
function copyFileSync(srcFile, destFile) {
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);
fs.writeSync(fdw, buf, 0, bytesRead);
pos += bytesRead;
} }
fs.closeSync(fdr);
fs.closeSync(fdw);
}
function quoteString(str) {
return '"' + str.replace(/\\/, "\\\\").replace(/"/g, '\\"').replace(/\n/g, "\\\n") + '"';
}
function removeUseStrict(text) {
return text.replace(/['"]use strict['"];/g, "");
}
function removeLicenceComments(text) {
return text.replace(/(?:(;)|\n)\s*\/\*[\d\D]*?\*\/|\n\s*\/\/.*/g, "$1");
} }
function namespace(ns) { function namespace(ns) {
return function(text) { return function(text) {
text = text text = text
.toString() .toString()
.replace('var ACE_NAMESPACE = "";', 'var ACE_NAMESPACE = "' + ns +'";') .replace(/ACE_NAMESPACE\s*=\s*""/, 'ACE_NAMESPACE = "' + ns +'"')
.replace(/(\.define)|\bdefine\(/g, function(_, a) { .replace(/(\.define)|\bdefine\(/g, function(_, a) {
return a || ns + ".define(" return a || ns + ".define(";
}); });
return text; return text;
}; };
} }
function exportAce(ns, module, requireBase, extModule) { function exportAce(ns, modules, requireBase, extModules) {
requireBase = requireBase || "window"; requireBase = requireBase || "window";
module = module || "ace/ace";
return function(text) { return function(text) {
/*globals REQUIRE_NS, MODULES, NS*/
var template = function() { var template = function() {
(function() { (function() {
REQUIRE_NS.require(["MODULE"], function(a) { REQUIRE_NS.require(MODULES, function(a) {
a && a.config.init(true); a && a.config.init(true);
if (!window.NS) if (!window.NS)
window.NS = a; window.NS = a;
for (var key in a) if (a.hasOwnProperty(key)) for (var key in a) if (a.hasOwnProperty(key))
NS[key] = a[key]; window.NS[key] = a[key];
}); });
})(); })();
}; };
if (extModule) { if (extModules) {
module = extModule;
template = function() { template = function() {
(function() { (function() {
REQUIRE_NS.require(["MODULE"], function() {}); REQUIRE_NS.require(MODULES, function() {});
})(); })();
}; };
} }
text = text.replace(/function init\(packaged\) {/, "init(true);$&\n"); text = text.replace(/function init\(packaged\) {/, "init(true);$&\n");
if (typeof modules == "string")
modules = [modules];
return (text + ";" + template return (text + ";" + template
.toString() .toString()
.replace(/MODULE/g, module) .replace(/MODULES/g, JSON.stringify(modules))
.replace(/REQUIRE_NS/g, requireBase) .replace(/REQUIRE_NS/g, requireBase)
.replace(/NS/g, ns) .replace(/NS/g, ns)
.slice(13, -1) .slice(13, -1)
@ -701,14 +514,14 @@ function exportAce(ns, module, requireBase, extModule) {
function updateModes() { function updateModes() {
modeList().forEach(function(m) { modeList().forEach(function(m) {
var filepath = __dirname + "/lib/ace/mode/" + m + ".js" var filepath = __dirname + "/lib/ace/mode/" + m + ".js";
var source = fs.readFileSync(filepath, "utf8"); var source = fs.readFileSync(filepath, "utf8");
if (!/this.\$id\s*=\s*"/.test(source)) 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(/\n([ \t]*)(\}\).call\(\w*Mode.prototype\))/, '\n$1 this.$id = "";\n$1$2');
source = source.replace(/(this.\$id\s*=\s*)"[^"]*"/, '$1"ace/mode/' + m + '"'); source = source.replace(/(this.\$id\s*=\s*)"[^"]*"/, '$1"ace/mode/' + m + '"');
fs.writeFileSync(filepath, source, "utf8") fs.writeFileSync(filepath, source, "utf8");
}) });
} }
function generateThemesModule(themes) { function generateThemesModule(themes) {
@ -720,6 +533,32 @@ function generateThemesModule(themes) {
fs.writeFileSync(__dirname + '/lib/ace/ext/themelist_utils/themes.js', themelist, 'utf8'); fs.writeFileSync(__dirname + '/lib/ace/ext/themelist_utils/themes.js', themelist, 'utf8');
} }
function addSnippetFile(modeName) {
var snippetFilePath = ACE_HOME + "/lib/ace/snippets/" + modeName;
if (!fs.existsSync(snippetFilePath + ".js")) {
copy.file(ACE_HOME + "/tool/snippets.tmpl.js", snippetFilePath + ".js", function(t) {
return t.replace(/%modeName%/g, modeName);
});
}
if (!fs.existsSync(snippetFilePath + ".snippets")) {
fs.writeFileSync(snippetFilePath + ".snippets", "");
}
}
function compress(text) {
var ujs = require("dryice").copy.filter.uglifyjs;
ujs.options.mangle_toplevel = {except: ["ACE_NAMESPACE", "requirejs"]};
ujs.options.beautify = {ascii_only: true, inline_script: true}
return ujs(text);
}
function extend(base, extra) {
Object.keys(extra).forEach(function(k) {
base[k] = extra[k];
});
return base;
}
if (!module.parent) if (!module.parent)
main(process.argv); main(process.argv);
else else

View file

@ -20,7 +20,7 @@ function foo() {
var bar = true; var bar = true;
}</textarea><br> }</textarea><br>
SourceUrl: <br> SourceUrl: <br>
<input id="srcURL" style="width:300px" value="http://ajaxorg.github.com/ace-builds/textarea/src/"></input><br> <input id="srcURL" style="width:300px" value="http://ajaxorg.github.com/ace-builds/src-noconflict"></input><br>
<button id="buBuild">Build Link</button> <br> <a href="#"></a> <button id="buBuild">Build Link</button> <br> <a href="#"></a>
<a href="https://github.com/ajaxorg/ace/"> <a href="https://github.com/ajaxorg/ace/">
<div class="fork_on_github" ></div> <div class="fork_on_github" ></div>
@ -49,63 +49,60 @@ function foo() {
<script> <script>
function inject(callback) { function inject(options, callback) {
var baseUrl = "src/"; var baseUrl = options.baseUrl || "../../src-noconflict";
var load = window.__ace_loader__ = function(path, module, callback) { var load = function(path, callback) {
var head = document.getElementsByTagName('head')[0]; var head = document.getElementsByTagName('head')[0];
var s = document.createElement('script'); var s = document.createElement('script');
s.src = baseUrl + path; s.src = baseUrl + "/" + path;
head.appendChild(s); head.appendChild(s);
s.onload = function() { s.onload = s.onreadystatechange = function(_, isAbort) {
window.__ace_shadowed__.require([module], callback); if (isAbort || !s.readyState || s.readyState == "loaded" || s.readyState == "complete") {
s = s.onload = s.onreadystatechange = null;
if (!isAbort)
callback();
}
}; };
}; };
load('ace-bookmarklet.js', "ace/ext/textarea", function() { load("ace.js", function() {
var ace = window.__ace_shadowed__; ace.config.loadModule("ace/ext/textarea", function() {
var event = ace.require("ace/lib/event");
ace.options.mode = "javascript";
var Event = ace.require("ace/lib/event");
var areas = document.getElementsByTagName("textarea"); var areas = document.getElementsByTagName("textarea");
for (var i = 0; i < areas.length; i++) { for (var i = 0; i < areas.length; i++) {
Event.addListener(areas[i], "click", function(e) { event.addListener(areas[i], "click", function(e) {
if (e.detail == 3) { if (e.detail == 3) {
ace.transformTextarea(e.target, load); ace.transformTextarea(e.target, options.ace);
} }
}); });
} }
callback && callback(); callback && callback();
}); });
});
} }
// Call the inject function to load the ace files. // Call the inject function to load the ace files.
var textAce; var textAce;
inject(function () { inject({}, function () {
// Transform the textarea on the page into an ace editor. // Transform the textarea on the page into an ace editor.
var ace = window.__ace_shadowed__;
var t = document.querySelector("textarea"); var t = document.querySelector("textarea");
textAce = ace.transformTextarea(t, window.__ace_loader__); textAce = ace.require("ace/ext/textarea").transformTextarea(t);
setTimeout(function(){textAce.setDisplaySettings(true)}); setTimeout(function(){textAce.setDisplaySettings(true)});
}); });
document.getElementById("buBuild").onclick = function() { document.getElementById("buBuild").onclick = function() {
var injectSrc = inject.toString().split("\n").join(""); var injectSrc = inject.toString().split("\n").join("");
injectSrc = injectSrc.replace('baseUrl = "src/"', 'baseUrl="' + document.getElementById("srcURL").value + '"');
var aceOptions = textAce.getOptions();
var opt = [];
for (var option in aceOptions) {
opt.push(option + ":'" + aceOptions[option] + "'");
}
injectSrc = injectSrc.replace('ace.options.mode = "javascript"', 'ace.options = { ' + opt.join(",") + ' }');
injectSrc = injectSrc.replace(/\s+/g, " "); injectSrc = injectSrc.replace(/\s+/g, " ");
var options = textAce.getOptions();
options.baseUrl = document.getElementById("srcURL").value;
var a = document.querySelector("a"); var a = document.querySelector("a");
a.href = "javascript:(" + injectSrc + ")()"; a.href = "javascript:(" + injectSrc + ")(" + JSON.stringify(options) + ")";
a.innerHTML = "Ace Bookmarklet Link"; a.innerHTML = "Ace Bookmarklet Link";
} }

View file

@ -35,7 +35,8 @@
// enable autocompletion and snippets // enable autocompletion and snippets
editor.setOptions({ editor.setOptions({
enableBasicAutocompletion: true, enableBasicAutocompletion: true,
enableSnippets: true enableSnippets: true,
enableLiveAutocompletion: false
}); });
</script> </script>

View file

@ -20,29 +20,41 @@
</style> </style>
</head> </head>
<body> <body>
<pre id="editor">autoresizing editor</pre> <pre id="editor1">autoresizing editor</pre>
<div class="scrollmargin"></div> <div class="scrollmargin"></div>
<pre id="editor2">minHeight = 2 lines</pre> <pre id="editor2">minHeight = 2 lines</pre>
<div class="scrollmargin"></div>
<pre id="editor"></pre>
<script src="../build/src/ace.js"></script> <script src="kitchen-sink/require.js"></script>
<script> <script>
// setup paths
require.config({paths: { "ace" : "../lib/ace"}});
// load ace and extensions
require(["ace/ace"], function(ace) {
// create first editor var editor1 = ace.edit("editor1");
var editor = ace.edit("editor"); editor1.setTheme("ace/theme/tomorrow_night_eighties");
editor.setTheme("ace/theme/tomorrow"); editor1.session.setMode("ace/mode/html");
editor.session.setMode("ace/mode/html"); editor1.setAutoScrollEditorIntoView(true);
editor.setAutoScrollEditorIntoView(); editor1.setOption("maxLines", 30);
editor.setOption("maxLines", 100);
var editor2 = ace.edit("editor2");
editor2.setTheme("ace/theme/tomorrow_night_blue");
editor2.session.setMode("ace/mode/html");
editor2.setAutoScrollEditorIntoView();
editor2.setOption("maxLines", 30);
editor2.setOption("minLines", 2);
var editor2 = ace.edit("editor2");
editor2.setTheme("ace/theme/tomorrow_night_blue");
editor2.session.setMode("ace/mode/html");
editor2.setAutoScrollEditorIntoView(true);
editor2.setOption("maxLines", 30);
editor2.setOption("minLines", 2);
var editor = ace.edit("editor");
editor.setTheme("ace/theme/tomorrow");
editor.session.setMode("ace/mode/html");
editor.setAutoScrollEditorIntoView(true);
editor.setOption("maxLines", 100);
});
</script> </script>
<script src="./show_own_source.js"></script>
</body> </body>
</html> </html>

View file

@ -22,19 +22,20 @@
<pre id="editor"></pre> <pre id="editor"></pre>
<!-- load ace --> <!-- load emmet code and snippets compiled for browser -->
<script src="../build/src-noconflict/ace.js"></script> <script src="https://nightwing.github.io/emmet-core/emmet.js"></script>
<!-- load ace emmet extension -->
<script src="../build/src-noconflict/ext-emmet.js"></script> <script src="kitchen-sink/require.js"></script>
<!-- load core emmet files -->
<script src="http://nightwing.github.io/emmet-core/emmet.js"></script>
<script> <script>
// trigger extension // setup paths
ace.require("ace/ext/emmet"); require.config({paths: { "ace" : "../lib/ace"}});
// load ace and extensions
require(["ace/ace", "ace/ext/emmet"], function(ace) {
var editor = ace.edit("editor"); var editor = ace.edit("editor");
editor.session.setMode("ace/mode/html"); editor.session.setMode("ace/mode/html");
// enable emmet on the current editor // enable emmet on the current editor
editor.setOption("enableEmmet", true); editor.setOption("enableEmmet", true);
});
</script> </script>
<script src="./show_own_source.js"></script> <script src="./show_own_source.js"></script>

View file

@ -5,7 +5,7 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>ACE Editor StatusBar Demo</title> <title>ACE Editor StatusBar Demo</title>
<style type="text/css" media="screen"> <style type="text/css" media="screen">
/*!important without this top: 0; bottom: 0 doesn't work */ /*!important without this top: 0; bottom: 0 doesn't work on old ie */
body, html { body, html {
position: absolute; position: absolute;
top: 0px; bottom: 0; left: 0; right: 0; top: 0px; bottom: 0; left: 0; right: 0;

View file

@ -22,8 +22,11 @@
<pre id="editor"></pre> <pre id="editor"></pre>
<script src="../build/src-noconflict/ace.js"></script> <script src="kitchen-sink/require.js"></script>
<script> <script>
// setup paths
require.config({paths: { "ace" : "../lib/ace"}});
require(["ace/ace"], function(ace) {
var editor = ace.edit("editor") var editor = ace.edit("editor")
editor.setTheme("ace/theme/twilight") editor.setTheme("ace/theme/twilight")
editor.session.setMode("ace/mode/html") editor.session.setMode("ace/mode/html")
@ -39,6 +42,8 @@
}) })
} }
}) })
editor.execCommand("showKeyboardShortcuts")
})
</script> </script>
<script src="./show_own_source.js"></script> <script src="./show_own_source.js"></script>

View file

@ -184,21 +184,21 @@ env.editor.commands.addCommands([{
} }
}, { }, {
name: "increaseFontSize", name: "increaseFontSize",
bindKey: "Ctrl-+", bindKey: "Ctrl-=|Ctrl-+",
exec: function(editor) { exec: function(editor) {
var size = parseInt(editor.getFontSize(), 10) || 12; var size = parseInt(editor.getFontSize(), 10) || 12;
editor.setFontSize(size + 1); editor.setFontSize(size + 1);
} }
}, { }, {
name: "decreaseFontSize", name: "decreaseFontSize",
bindKey: "Ctrl+-", bindKey: "Ctrl+-|Ctrl-_",
exec: function(editor) { exec: function(editor) {
var size = parseInt(editor.getFontSize(), 10) || 12; var size = parseInt(editor.getFontSize(), 10) || 12;
editor.setFontSize(Math.max(size - 1 || 1)); editor.setFontSize(Math.max(size - 1 || 1));
} }
}, { }, {
name: "resetFontSize", name: "resetFontSize",
bindKey: "Ctrl+0", bindKey: "Ctrl+0|Ctrl-Numpad0",
exec: function(editor) { exec: function(editor) {
editor.setFontSize(12); editor.setFontSize(12);
} }
@ -548,7 +548,7 @@ new StatusBar(env.editor, cmdLine.container);
var Emmet = require("ace/ext/emmet"); var Emmet = require("ace/ext/emmet");
net.loadScript("http://nightwing.github.io/emmet-core/emmet.js", function() { net.loadScript("https://nightwing.github.io/emmet-core/emmet.js", function() {
Emmet.setCore(window.emmet); Emmet.setCore(window.emmet);
env.editor.setOption("enableEmmet", true); env.editor.setOption("enableEmmet", true);
}); });
@ -592,7 +592,7 @@ env.editSnippets = function() {
require("ace/ext/language_tools"); require("ace/ext/language_tools");
env.editor.setOptions({ env.editor.setOptions({
enableBasicAutocompletion: true, enableBasicAutocompletion: true,
enableLiveAutocomplete: true, enableLiveAutocompletion: true,
enableSnippets: true enableSnippets: true
}); });

View file

@ -0,0 +1,53 @@
#
# example Dockerfile for http://docs.docker.io/en/latest/examples/postgresql_service/
#
FROM ubuntu
MAINTAINER SvenDowideit@docker.com
# Add the PostgreSQL PGP key to verify their Debian packages.
# It should be the same key as https://www.postgresql.org/media/keys/ACCC4CF8.asc
RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys B97B0AFCAA1A47F044F244A07FCC7D46ACCC4CF8
# Add PostgreSQL's repository. It contains the most recent stable release
# of PostgreSQL, ``9.3``.
RUN echo "deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main" > /etc/apt/sources.list.d/pgdg.list
# Update the Ubuntu and PostgreSQL repository indexes
RUN apt-get update
# Install ``python-software-properties``, ``software-properties-common`` and PostgreSQL 9.3
# There are some warnings (in red) that show up during the build. You can hide
# them by prefixing each apt-get statement with DEBIAN_FRONTEND=noninteractive
RUN apt-get -y -q install python-software-properties software-properties-common
RUN apt-get -y -q install postgresql-9.3 postgresql-client-9.3 postgresql-contrib-9.3
# Note: The official Debian and Ubuntu images automatically ``apt-get clean``
# after each ``apt-get``
# Run the rest of the commands as the ``postgres`` user created by the ``postgres-9.3`` package when it was ``apt-get installed``
USER postgres
# Create a PostgreSQL role named ``docker`` with ``docker`` as the password and
# then create a database `docker` owned by the ``docker`` role.
# Note: here we use ``&&\`` to run commands one after the other - the ``\``
# allows the RUN command to span multiple lines.
RUN /etc/init.d/postgresql start &&\
psql --command "CREATE USER docker WITH SUPERUSER PASSWORD 'docker';" &&\
createdb -O docker docker
# Adjust PostgreSQL configuration so that remote connections to the
# database are possible.
RUN echo "host all all 0.0.0.0/0 md5" >> /etc/postgresql/9.3/main/pg_hba.conf
# And add ``listen_addresses`` to ``/etc/postgresql/9.3/main/postgresql.conf``
RUN echo "listen_addresses='*'" >> /etc/postgresql/9.3/main/postgresql.conf
# Expose the PostgreSQL port
EXPOSE 5432
# Add VOLUMEs to allow backup of config, logs and databases
VOLUME ["/etc/postgresql", "/var/log/postgresql", "/var/lib/postgresql"]
# Set the default command to run when starting the container
CMD ["/usr/lib/postgresql/9.3/bin/postgres", "-D", "/var/lib/postgresql/9.3/main", "-c", "config_file=/etc/postgresql/9.3/main/postgresql.conf"]

View file

@ -2,7 +2,7 @@ for op = (:+, :*, :&, :|, :$)
@eval ($op)(a,b,c) = ($op)(($op)(a,b),c) @eval ($op)(a,b,c) = ($op)(($op)(a,b),c)
end end
v = α';
function g(x,y) function g(x,y)
return x * y return x * y
x + y x + y

View file

@ -0,0 +1,21 @@
using Gtk;
int main (string[] args) {
Gtk.init (ref args);
var foo = new MyFoo<string[](), MyBar<string, int>>();
var window = new Window();
window.title = "Hello, World!";
window.border_width = 10;
window.window_position = WindowPosition.CENTER;
window.set_default_size(350, 70);
window.destroy.connect(Gtk.main_quit);
var label = new Label("Hello, World!");
window.add(label);
window.show_all();
Gtk.main();
return 0;
}

View file

@ -1,5 +1,5 @@
/** vim: et:ts=4:sw=4:sts=4 /** vim: et:ts=4:sw=4:sts=4
* @license RequireJS 2.1.9+ Copyright (c) 2010-2012, The Dojo Foundation All Rights Reserved. * @license RequireJS 2.1.11+ Copyright (c) 2010-2014, The Dojo Foundation All Rights Reserved.
* Available via the MIT or new BSD license. * Available via the MIT or new BSD license.
* see: http://github.com/jrburke/requirejs for details * see: http://github.com/jrburke/requirejs for details
*/ */
@ -12,7 +12,7 @@ var requirejs, require, define;
(function (global) { (function (global) {
var req, s, head, baseElement, dataMain, src, var req, s, head, baseElement, dataMain, src,
interactiveScript, currentlyAddingScript, mainScript, subPath, interactiveScript, currentlyAddingScript, mainScript, subPath,
version = '2.1.9+', version = '2.1.11+',
commentRegExp = /(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg, commentRegExp = /(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg,
cjsRequireRegExp = /[^.]\s*require\s*\(\s*["']([^'"\s]+)["']\s*\)/g, cjsRequireRegExp = /[^.]\s*require\s*\(\s*["']([^'"\s]+)["']\s*\)/g,
jsSuffixRegExp = /\.js$/, jsSuffixRegExp = /\.js$/,
@ -108,7 +108,10 @@ var requirejs, require, define;
if (source) { if (source) {
eachProp(source, function (value, prop) { eachProp(source, function (value, prop) {
if (force || !hasProp(target, prop)) { if (force || !hasProp(target, prop)) {
if (deepStringMixin && typeof value !== 'string') { if (deepStringMixin && typeof value === 'object' && value &&
!isArray(value) && !isFunction(value) &&
!(value instanceof RegExp)) {
if (!target[prop]) { if (!target[prop]) {
target[prop] = {}; target[prop] = {};
} }
@ -138,7 +141,7 @@ var requirejs, require, define;
throw err; throw err;
} }
//Allow getting a global that expressed in //Allow getting a global that is expressed in
//dot notation, like 'a.b.c'. //dot notation, like 'a.b.c'.
function getGlobal(value) { function getGlobal(value) {
if (!value) { if (!value) {
@ -177,7 +180,7 @@ var requirejs, require, define;
if (typeof requirejs !== 'undefined') { if (typeof requirejs !== 'undefined') {
if (isFunction(requirejs)) { if (isFunction(requirejs)) {
//Do not overwrite and existing requirejs instance. //Do not overwrite an existing requirejs instance.
return; return;
} }
cfg = requirejs; cfg = requirejs;
@ -201,6 +204,7 @@ var requirejs, require, define;
waitSeconds: 7, waitSeconds: 7,
baseUrl: './', baseUrl: './',
paths: {}, paths: {},
bundles: {},
pkgs: {}, pkgs: {},
shim: {}, shim: {},
config: {} config: {}
@ -214,6 +218,7 @@ var requirejs, require, define;
defQueue = [], defQueue = [],
defined = {}, defined = {},
urlFetched = {}, urlFetched = {},
bundlesMap = {},
requireCounter = 1, requireCounter = 1,
unnormalizedCounter = 1; unnormalizedCounter = 1;
@ -227,8 +232,8 @@ var requirejs, require, define;
* @param {Array} ary the array of path segments. * @param {Array} ary the array of path segments.
*/ */
function trimDots(ary) { function trimDots(ary) {
var i, part; var i, part, length = ary.length;
for (i = 0; ary[i]; i += 1) { for (i = 0; i < length; i++) {
part = ary[i]; part = ary[i];
if (part === '.') { if (part === '.') {
ary.splice(i, 1); ary.splice(i, 1);
@ -261,7 +266,7 @@ var requirejs, require, define;
* @returns {String} normalized name * @returns {String} normalized name
*/ */
function normalize(name, baseName, applyMap) { function normalize(name, baseName, applyMap) {
var pkgName, pkgConfig, mapValue, nameParts, i, j, nameSegment, var pkgMain, mapValue, nameParts, i, j, nameSegment, lastIndex,
foundMap, foundI, foundStarMap, starI, foundMap, foundI, foundStarMap, starI,
baseParts = baseName && baseName.split('/'), baseParts = baseName && baseName.split('/'),
normalizedBaseParts = baseParts, normalizedBaseParts = baseParts,
@ -274,29 +279,26 @@ var requirejs, require, define;
//otherwise, assume it is a top-level require that will //otherwise, assume it is a top-level require that will
//be relative to baseUrl in the end. //be relative to baseUrl in the end.
if (baseName) { if (baseName) {
if (getOwn(config.pkgs, baseName)) {
//If the baseName is a package name, then just treat it as one
//name to concat the name with.
normalizedBaseParts = baseParts = [baseName];
} else {
//Convert baseName to array, and lop off the last part, //Convert baseName to array, and lop off the last part,
//so that . matches that 'directory' and not name of the baseName's //so that . matches that 'directory' and not name of the baseName's
//module. For instance, baseName of 'one/two/three', maps to //module. For instance, baseName of 'one/two/three', maps to
//'one/two/three.js', but we want the directory, 'one/two' for //'one/two/three.js', but we want the directory, 'one/two' for
//this normalization. //this normalization.
normalizedBaseParts = baseParts.slice(0, baseParts.length - 1); normalizedBaseParts = baseParts.slice(0, baseParts.length - 1);
name = name.split('/');
lastIndex = name.length - 1;
// If wanting node ID compatibility, strip .js from end
// of IDs. Have to do this here, and not in nameToUrl
// because node allows either .js or non .js to map
// to same file.
if (config.nodeIdCompat && jsSuffixRegExp.test(name[lastIndex])) {
name[lastIndex] = name[lastIndex].replace(jsSuffixRegExp, '');
} }
name = normalizedBaseParts.concat(name.split('/')); name = normalizedBaseParts.concat(name);
trimDots(name); trimDots(name);
//Some use of packages may use a . path to reference the
//'main' module name, so normalize for that.
pkgConfig = getOwn(config.pkgs, (pkgName = name[0]));
name = name.join('/'); name = name.join('/');
if (pkgConfig && name === pkgName + '/' + pkgConfig.main) {
name = pkgName;
}
} else if (name.indexOf('./') === 0) { } else if (name.indexOf('./') === 0) {
// No baseName, so this is ID is resolved relative // No baseName, so this is ID is resolved relative
// to baseUrl, pull off the leading dot. // to baseUrl, pull off the leading dot.
@ -308,7 +310,7 @@ var requirejs, require, define;
if (applyMap && map && (baseParts || starMap)) { if (applyMap && map && (baseParts || starMap)) {
nameParts = name.split('/'); nameParts = name.split('/');
for (i = nameParts.length; i > 0; i -= 1) { outerLoop: for (i = nameParts.length; i > 0; i -= 1) {
nameSegment = nameParts.slice(0, i).join('/'); nameSegment = nameParts.slice(0, i).join('/');
if (baseParts) { if (baseParts) {
@ -325,16 +327,12 @@ var requirejs, require, define;
//Match, update name to the new value. //Match, update name to the new value.
foundMap = mapValue; foundMap = mapValue;
foundI = i; foundI = i;
break; break outerLoop;
} }
} }
} }
} }
if (foundMap) {
break;
}
//Check for a star map match, but just hold on to it, //Check for a star map match, but just hold on to it,
//if there is a shorter segment match later in a matching //if there is a shorter segment match later in a matching
//config, then favor over this star map. //config, then favor over this star map.
@ -355,7 +353,11 @@ var requirejs, require, define;
} }
} }
return name; // If the name points to a package's name, use
// the package main instead.
pkgMain = getOwn(config.pkgs, name);
return pkgMain ? pkgMain : name;
} }
function removeScript(name) { function removeScript(name) {
@ -377,7 +379,13 @@ var requirejs, require, define;
//retry //retry
pathConfig.shift(); pathConfig.shift();
context.require.undef(id); context.require.undef(id);
context.require([id]);
//Custom require that does not do map translation, since
//ID is "absolute", already mapped/resolved.
context.makeRequire(null, {
skipMap: true
})([id]);
return true; return true;
} }
} }
@ -565,7 +573,7 @@ var requirejs, require, define;
mod.usingExports = true; mod.usingExports = true;
if (mod.map.isDefine) { if (mod.map.isDefine) {
if (mod.exports) { if (mod.exports) {
return mod.exports; return (defined[mod.map.id] = mod.exports);
} else { } else {
return (mod.exports = defined[mod.map.id] = {}); return (mod.exports = defined[mod.map.id] = {});
} }
@ -579,15 +587,9 @@ var requirejs, require, define;
id: mod.map.id, id: mod.map.id,
uri: mod.map.url, uri: mod.map.url,
config: function () { config: function () {
var c, return getOwn(config.config, mod.map.id) || {};
pkg = getOwn(config.pkgs, mod.map.id);
// For packages, only support config targeted
// at the main module.
c = pkg ? getOwn(config.config, mod.map.id + '/' + pkg.main) :
getOwn(config.config, mod.map.id);
return c || {};
}, },
exports: defined[mod.map.id] exports: mod.exports || (mod.exports = {})
}); });
} }
} }
@ -870,17 +872,14 @@ var requirejs, require, define;
exports = context.execCb(id, factory, depExports, exports); exports = context.execCb(id, factory, depExports, exports);
} }
if (this.map.isDefine) { // Favor return value over exports. If node/cjs in play,
//If setting exports via 'module' is in play, // then will not have a return value anyway. Favor
//favor that over return value and exports. After that, // module.exports assignment over exports object.
//favor a non-undefined return value over exports use. if (this.map.isDefine && exports === undefined) {
cjsModule = this.module; cjsModule = this.module;
if (cjsModule && if (cjsModule) {
cjsModule.exports !== undefined &&
//Make sure it is not already the exports value
cjsModule.exports !== this.exports) {
exports = cjsModule.exports; exports = cjsModule.exports;
} else if (exports === undefined && this.usingExports) { } else if (this.usingExports) {
//exports already set the defined value. //exports already set the defined value.
exports = this.exports; exports = this.exports;
} }
@ -940,6 +939,7 @@ var requirejs, require, define;
on(pluginMap, 'defined', bind(this, function (plugin) { on(pluginMap, 'defined', bind(this, function (plugin) {
var load, normalizedMap, normalizedMod, var load, normalizedMap, normalizedMod,
bundleId = getOwn(bundlesMap, this.map.id),
name = this.map.name, name = this.map.name,
parentName = this.map.parentMap ? this.map.parentMap.name : null, parentName = this.map.parentMap ? this.map.parentMap.name : null,
localRequire = context.makeRequire(map.parentMap, { localRequire = context.makeRequire(map.parentMap, {
@ -985,6 +985,14 @@ var requirejs, require, define;
return; return;
} }
//If a paths config, then just load that file instead to
//resolve the plugin, as it is built into that paths layer.
if (bundleId) {
this.map.url = context.nameToUrl(bundleId);
this.load();
return;
}
load = bind(this, function (value) { load = bind(this, function (value) {
this.init([], function () { return value; }, null, { this.init([], function () { return value; }, null, {
enabled: true enabled: true
@ -1249,31 +1257,38 @@ var requirejs, require, define;
} }
} }
//Save off the paths and packages since they require special processing, //Save off the paths since they require special processing,
//they are additive. //they are additive.
var pkgs = config.pkgs, var shim = config.shim,
shim = config.shim,
objs = { objs = {
paths: true, paths: true,
bundles: true,
config: true, config: true,
map: true map: true
}; };
eachProp(cfg, function (value, prop) { eachProp(cfg, function (value, prop) {
if (objs[prop]) { if (objs[prop]) {
if (prop === 'map') { if (!config[prop]) {
if (!config.map) { config[prop] = {};
config.map = {};
} }
mixin(config[prop], value, true, true); mixin(config[prop], value, true, true);
} else {
mixin(config[prop], value, true);
}
} else { } else {
config[prop] = value; config[prop] = value;
} }
}); });
//Reverse map the bundles
if (cfg.bundles) {
eachProp(cfg.bundles, function (value, prop) {
each(value, function (v) {
if (v !== prop) {
bundlesMap[v] = prop;
}
});
});
}
//Merge shim //Merge shim
if (cfg.shim) { if (cfg.shim) {
eachProp(cfg.shim, function (value, id) { eachProp(cfg.shim, function (value, id) {
@ -1294,29 +1309,25 @@ var requirejs, require, define;
//Adjust packages if necessary. //Adjust packages if necessary.
if (cfg.packages) { if (cfg.packages) {
each(cfg.packages, function (pkgObj) { each(cfg.packages, function (pkgObj) {
var location; var location, name;
pkgObj = typeof pkgObj === 'string' ? { name: pkgObj } : pkgObj; pkgObj = typeof pkgObj === 'string' ? { name: pkgObj } : pkgObj;
location = pkgObj.location;
//Create a brand new object on pkgs, since currentPackages can name = pkgObj.name;
//be passed in again, and config.pkgs is the internal transformed location = pkgObj.location;
//state for all package configs. if (location) {
pkgs[pkgObj.name] = { config.paths[name] = pkgObj.location;
name: pkgObj.name, }
location: location || pkgObj.name,
//Save pointer to main module ID for pkg name.
//Remove leading dot in main, so main paths are normalized, //Remove leading dot in main, so main paths are normalized,
//and remove any trailing .js, since different package //and remove any trailing .js, since different package
//envs have different conventions: some use a module name, //envs have different conventions: some use a module name,
//some use a file name. //some use a file name.
main: (pkgObj.main || 'main') config.pkgs[name] = pkgObj.name + '/' + (pkgObj.main || 'main')
.replace(currDirRegExp, '') .replace(currDirRegExp, '')
.replace(jsSuffixRegExp, '') .replace(jsSuffixRegExp, '');
};
}); });
//Done with modifications, assing packages back to context config
config.pkgs = pkgs;
} }
//If there are any "waiting to execute" modules in the registry, //If there are any "waiting to execute" modules in the registry,
@ -1497,7 +1508,7 @@ var requirejs, require, define;
/** /**
* Called to enable a module if it is still in the registry * Called to enable a module if it is still in the registry
* awaiting enablement. A second arg, parent, the parent module, * awaiting enablement. A second arg, parent, the parent module,
* is passed in for context, when this method is overriden by * is passed in for context, when this method is overridden by
* the optimizer. Not shown here to keep code compact. * the optimizer. Not shown here to keep code compact.
*/ */
enable: function (depMap) { enable: function (depMap) {
@ -1571,8 +1582,19 @@ var requirejs, require, define;
* internal API, not a public one. Use toUrl for the public API. * internal API, not a public one. Use toUrl for the public API.
*/ */
nameToUrl: function (moduleName, ext, skipExt) { nameToUrl: function (moduleName, ext, skipExt) {
var paths, pkgs, pkg, pkgPath, syms, i, parentModule, url, var paths, syms, i, parentModule, url,
parentPath; parentPath, bundleId,
pkgMain = getOwn(config.pkgs, moduleName);
if (pkgMain) {
moduleName = pkgMain;
}
bundleId = getOwn(bundlesMap, moduleName);
if (bundleId) {
return context.nameToUrl(bundleId, ext, skipExt);
}
//If a colon is in the URL, it indicates a protocol is used and it is just //If a colon is in the URL, it indicates a protocol is used and it is just
//an URL to a file, or if it starts with a slash, contains a query arg (i.e. ?) //an URL to a file, or if it starts with a slash, contains a query arg (i.e. ?)
@ -1586,7 +1608,6 @@ var requirejs, require, define;
} else { } else {
//A module that needs to be converted to a path. //A module that needs to be converted to a path.
paths = config.paths; paths = config.paths;
pkgs = config.pkgs;
syms = moduleName.split('/'); syms = moduleName.split('/');
//For each module name segment, see if there is a path //For each module name segment, see if there is a path
@ -1594,7 +1615,7 @@ var requirejs, require, define;
//and work up from it. //and work up from it.
for (i = syms.length; i > 0; i -= 1) { for (i = syms.length; i > 0; i -= 1) {
parentModule = syms.slice(0, i).join('/'); parentModule = syms.slice(0, i).join('/');
pkg = getOwn(pkgs, parentModule);
parentPath = getOwn(paths, parentModule); parentPath = getOwn(paths, parentModule);
if (parentPath) { if (parentPath) {
//If an array, it means there are a few choices, //If an array, it means there are a few choices,
@ -1604,16 +1625,6 @@ var requirejs, require, define;
} }
syms.splice(0, i, parentPath); syms.splice(0, i, parentPath);
break; break;
} else if (pkg) {
//If module name is just the package name, then looking
//for the main module.
if (moduleName === pkg.name) {
pkgPath = pkg.location + '/' + pkg.main;
} else {
pkgPath = pkg.location;
}
syms.splice(0, i, pkgPath);
break;
} }
} }

View file

@ -23,24 +23,27 @@
<pre id="editor"></pre> <pre id="editor"></pre>
<script src="../build/src-noconflict/ace.js"></script> <script src="kitchen-sink/require.js"></script>
<script src="../build/src-noconflict/ext-modelist.js"></script>
<script> <script>
// setup paths
require.config({paths: { "ace" : "../lib/ace"}});
// load ace and extensions
require(["ace/ace", "ace/ext/modelist"], function(ace) {
var editor = ace.edit("editor"); var editor = ace.edit("editor");
editor.setTheme("ace/theme/twilight"); editor.setTheme("ace/theme/twilight");
(function () { (function () {
var modelist = ace.require('ace/ext/modelist'); var modelist = ace.require("ace/ext/modelist");
// the file path could come from an xmlhttp request, a drop event, // the file path could come from an xmlhttp request, a drop event,
// or any other scriptable file loading process. // or any other scriptable file loading process.
// Extensions could consume the modelist and use it to dynamically // Extensions could consume the modelist and use it to dynamically
// set the editor mode. Webmasters could use it in their scripts // set the editor mode. Webmasters could use it in their scripts
// for site specific purposes as well. // for site specific purposes as well.
var filePath = 'blahblah/weee/some.js'; var filePath = "blahblah/weee/some.js";
var mode = modelist.getModeForPath(filePath).mode; var mode = modelist.getModeForPath(filePath).mode;
console.log(mode); console.log(mode);
editor.session.setMode(mode); editor.session.setMode(mode);
}()); }());
})
</script> </script>
<script src="./show_own_source.js"></script> <script src="./show_own_source.js"></script>

20
demo/r.js/build.js Normal file
View file

@ -0,0 +1,20 @@
({
optimize: "none",
preserveLicenseComments: false,
name: "node_modules/almond/almond",
baseUrl: "../../",
paths: {
ace : "lib/ace",
demo: "demo/kitchen-sink"
},
packages: [
],
include: [
"ace/ace"
],
exclude: [
],
out: "./packed.js",
useStrict: true,
wrap: false
})

36
demo/r.js/editor.html Normal file
View file

@ -0,0 +1,36 @@
<!DOCTYPE html>
<html>
<head>
<title>Editor</title>
<link rel="stylesheet" href="../kitchen-sink/styles.css" type="text/css" media="screen" charset="utf-8">
</head>
<body>
<div id="optionsPanel" style="position:absolute;height:100%;width:260px">
<a href="http://c9.io" title="Cloud9 IDE | Your code anywhere, anytime">
<img id="c9-logo" src="../kitchen-sink/logo.png" style="width: 172px;margin: -9px 30px -12px 51px;">
</a>
</div>
<pre id="editor-container">
<div style="color:black; padding: 10px">
demo showing Ace usage with r.js:
install r.js and almond
and run `<code>r.js -o demo/r.js/build.js</code>`
note that you also need ace/build/src to lazy load modes and themes
require("ace/config").set("basePath", "../../build/src");
require("ace/config").set("packaged", true);
<div>
</pre>
<script src="./packed.js" data-ace-base="src" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">
require("ace/config").set("basePath", "../../build/src")
require("ace/config").set("packaged", true)
var editor = require("ace/ace").edit("editor-container");
editor.session.setMode("ace/mode/javascript");
// editor.session.setValue("var editor = Ace!")
</script>
</body>
</html>

View file

@ -29,14 +29,20 @@
}</pre> }</pre>
<script src="../demo/kitchen-sink/require.js"></script> <script src="../demo/kitchen-sink/require.js"></script>
<script src="../build/src/ace.js" charset="utf-8"></script>
<script> <script>
require.config({paths: {ace: "../build/src"}})
define('testace', ['ace/ace'],
function(ace, langtools) {
console.log("This is the testace module");
var editor = ace.edit("editor"); var editor = ace.edit("editor");
editor.setTheme("ace/theme/twilight"); editor.setTheme("ace/theme/twilight");
editor.session.setMode("ace/mode/javascript"); editor.session.setMode("ace/mode/javascript");
require(["ace/requirejs/text!src/ace"], function(e){ require(["ace/requirejs/text!src/ace"], function(e){
editor.setValue(e); editor.setValue(e);
}) })
}
);
require(['testace'])
</script> </script>
</body> </body>

View file

@ -5,7 +5,6 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Editor</title> <title>Editor</title>
<style type="text/css" media="screen"> <style type="text/css" media="screen">
.ace_editor { .ace_editor {
position: relative !important; position: relative !important;
border: 1px solid lightgray; border: 1px solid lightgray;
@ -25,7 +24,6 @@
left: 0; left: 0;
right: 0; right: 0;
z-index: 10; z-index: 10;
background: white;
} }
.fullScreen { .fullScreen {
@ -76,8 +74,11 @@
</div> </div>
<script src="../build/src/ace.js"></script> <script src="kitchen-sink/require.js"></script>
<script> <script>
require.config({paths: { "ace" : "../lib/ace"}});
require(["ace/ace", "ace/ext/themelist"], function(ace) {
var $ = document.getElementById.bind(document); var $ = document.getElementById.bind(document);
var dom = require("ace/lib/dom"); var dom = require("ace/lib/dom");
@ -86,9 +87,9 @@ require("ace/commands/default_commands").commands.push({
name: "Toggle Fullscreen", name: "Toggle Fullscreen",
bindKey: "F11", bindKey: "F11",
exec: function(editor) { exec: function(editor) {
dom.toggleCssClass(document.body, "fullScreen") var fullScreen = dom.toggleCssClass(document.body, "fullScreen")
dom.toggleCssClass(editor.container, "fullScreen") dom.setCssClass(editor.container, "fullScreen", fullScreen)
editor.setAutoScrollEditorIntoView() editor.setAutoScrollEditorIntoView(!fullScreen)
editor.resize() editor.resize()
} }
}) })
@ -97,7 +98,11 @@ require("ace/commands/default_commands").commands.push({
var editor = ace.edit("editor"); var editor = ace.edit("editor");
editor.setTheme("ace/theme/twilight"); editor.setTheme("ace/theme/twilight");
editor.session.setMode("ace/mode/javascript"); editor.session.setMode("ace/mode/javascript");
editor.setAutoScrollEditorIntoView(); editor.renderer.setScrollMargin(10, 10);
editor.setOptions({
// "scrollPastEnd": 0.8,
autoScrollEditorIntoView: true
});
var count = 1; var count = 1;
function add() { function add() {
@ -110,12 +115,13 @@ function add() {
oldEl.parentNode.insertBefore(el, pad.nextSibling) oldEl.parentNode.insertBefore(el, pad.nextSibling)
count++ count++
var theme = "ace/theme/" + themes[Math.floor(themes.length * Math.random() - 1e-5)] var theme = themes[Math.floor(themes.length * Math.random() - 1e-5)]
editor = ace.edit(el) editor = ace.edit(el)
editor.setTheme(theme) editor.setOptions({
editor.session.setMode("ace/mode/javascript") mode: "ace/mode/javascript",
theme: theme,
editor.setAutoScrollEditorIntoView() autoScrollEditorIntoView: true
})
editor.setValue([ editor.setValue([
"this is editor number: ", count, "\n", "this is editor number: ", count, "\n",
@ -126,7 +132,6 @@ function add() {
scroll() scroll()
} }
function scroll(speed) { function scroll(speed) {
var top = editor.container.getBoundingClientRect().top var top = editor.container.getBoundingClientRect().top
speed = speed || 10 speed = speed || 10
@ -139,14 +144,11 @@ function scroll(speed) {
} }
} }
var themes = { var themes = require("ace/ext/themelist").themes.map(function(t){return t.theme});
bright: [ "chrome", "clouds", "crimson_editor", "dawn", "dreamweaver", "eclipse", "github",
"solarized_light", "textmate", "tomorrow"], window.add = add;
dark: [ "clouds_midnight", "cobalt", "idle_fingers", "kr_theme", "merbivore", "merbivore_soft", window.scroll = scroll;
"mono_industrial", "monokai", "pastel_on_dark", "solarized_dark", "terminal", "tomorrow_night", });
"tomorrow_night_blue", "tomorrow_night_bright", "tomorrow_night_eighties", "twilight", "vibrant_ink"]
}
themes = [].concat(themes.bright, themes.dark);
</script> </script>
</body> </body>

View file

@ -23,9 +23,12 @@
<pre id="editor"></pre> <pre id="editor"></pre>
<script src="../build/src-noconflict/ace.js"></script> <script src="kitchen-sink/require.js"></script>
<script src="../build/src-noconflict/ext-settings_menu.js"></script>
<script> <script>
// setup paths
require.config({paths: { "ace" : "../lib/ace"}});
// load ace and extensions
require(["ace/ace", "ace/ext/settings_menu"], function(ace) {
var editor = ace.edit("editor"); var editor = ace.edit("editor");
ace.require('ace/ext/settings_menu').init(editor); ace.require('ace/ext/settings_menu').init(editor);
editor.setTheme("ace/theme/twilight"); editor.setTheme("ace/theme/twilight");
@ -38,6 +41,7 @@
}, },
readOnly: true readOnly: true
}]); }]);
})
</script> </script>
<script src="./show_own_source.js"></script> <script src="./show_own_source.js"></script>

View file

@ -1,3 +1,16 @@
ace.require("ace/lib/net").get(document.baseURI, function(t){ if (typeof ace == "undefined" && typeof require == "undefined") {
editor.setValue(t, 1); document.body.innerHTML = "<p style='padding: 20px 50px;'>couldn't find ace.js file, <br>"
}) + "to build it run <code>node Makefile.dryice.js full<code>"
} else if (typeof ace == "undefined" && typeof require != "undefined") {
require(["ace/ace"], setValue)
} else {
require = ace.require;
setValue()
}
function setValue() {
require("ace/lib/net").get(document.baseURI, function(t){
var el = document.getElementById("editor");
el.env.editor.setValue(t, 1);
})
}

View file

@ -1,5 +1,4 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" <!DOCTYPE html>
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en"> <html lang="en">
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
@ -34,30 +33,31 @@ function wobble (flam) {
return flam.wobbled = true; return flam.wobbled = true;
} }
// the scrollbars are from overflow auto on .ace_editor.
</pre> </pre>
<script src="../../build/src-noconflict/ace.js"></script> <script src="kitchen-sink/require.js"></script>
<script src="../../build/src-noconflict/ext-static_highlight.js"></script>
<script> <script>
var highlight = ace.require("ace/ext/static_highlight") require.config({paths: { "ace" : "../lib/ace"}});
var dom = ace.require("ace/lib/dom")
function qsa(sel) {
return [].slice.call(document.querySelectorAll(sel));
}
qsa(".code").forEach(function (codeEl) { require(["ace/ace", "ace/ext/static_highlight"], function(ace) {
var highlight = ace.require("ace/ext/static_highlight")
var dom = ace.require("ace/lib/dom")
function qsa(sel) {
return Array.apply(null, document.querySelectorAll(sel));
}
qsa(".code").forEach(function (codeEl) {
highlight(codeEl, { highlight(codeEl, {
mode: codeEl.getAttribute('ace-mode'), mode: codeEl.getAttribute("ace-mode"),
theme: codeEl.getAttribute('ace-theme'), theme: codeEl.getAttribute("ace-theme"),
startLineNumber: 1, startLineNumber: 1,
showGutter: codeEl.getAttribute("ace-gutter"), showGutter: codeEl.getAttribute("ace-gutter"),
trim: true trim: true
}, function (highlighted) { }, function (highlighted) {
}); });
}); });
})
</script> </script>
</body> </body>

View file

@ -41,15 +41,19 @@
<pre id="editor"></pre> <pre id="editor"></pre>
<div id="statusBar">ace rocks!</div> <div id="statusBar">ace rocks!</div>
<script src="../build/src-noconflict/ace.js"></script> <script src="kitchen-sink/require.js"></script>
<script src="../build/src-noconflict/ext-statusbar.js"></script>
<script> <script>
// setup paths
require.config({paths: { "ace" : "../lib/ace"}});
// load ace and extensions
require(["ace/ace", "ace/ext/statusbar"], function(ace) {
var editor = ace.edit("editor"); var editor = ace.edit("editor");
var StatusBar = ace.require('ace/ext/statusbar').StatusBar; var StatusBar = ace.require("ace/ext/statusbar").StatusBar;
// create a simple selection status indicator // create a simple selection status indicator
var statusBar = new StatusBar(editor, document.getElementById('statusBar')); var statusBar = new StatusBar(editor, document.getElementById("statusBar"));
editor.setTheme("ace/theme/dawn"); editor.setTheme("ace/theme/dawn");
editor.session.setMode("ace/mode/html"); editor.session.setMode("ace/mode/html");
});
</script> </script>
<script src="./show_own_source.js"></script> <script src="./show_own_source.js"></script>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

View file

@ -161,7 +161,7 @@ function highlight() {
var highlighter = ace.require("ace/ext/static_highlight") var highlighter = ace.require("ace/ext/static_highlight")
var dom = ace.require("ace/lib/dom") var dom = ace.require("ace/lib/dom")
function qsa(sel) { function qsa(sel) {
return [].slice.call(document.querySelectorAll(sel)); return Array.apply(null, document.querySelectorAll(sel));
} }
qsa("code[class]").forEach(function(el) { qsa("code[class]").forEach(function(el) {

View file

@ -9,12 +9,15 @@
<link href="./doc/site/style.css" rel="stylesheet" type="text/css" /> <link href="./doc/site/style.css" rel="stylesheet" type="text/css" />
<link href="./doc/site/images/favicon.ico" rel="icon" type="image/x-icon" /> <link href="./doc/site/images/favicon.ico" rel="icon" type="image/x-icon" />
<script src="./build/src-min/ace.js"></script> <script src="./build/src/ace.js"></script>
<script src="./build/src-min/ext-static_highlight.js"></script> <script src="./build/src/ext-static_highlight.js"></script>
<!--[if lt IE 9]>
<script src="./build/src/ext-old_ie.js"></script>
<![endif]-->
</head> </head>
<body> <body>
<a href="http://github.com/ajaxorg/ace"> <a href="http://github.com/ajaxorg/ace">
<img style="z-index: 50000; position: absolute; top: 0; right: 0; border: 0; width: 125px; height: 125px" src="https://a248.e.akamai.net/camo.github.com/e6bef7a091f5f3138b8cd40bc3e114258dd68ddf/687474703a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f7265645f6161303030302e706e67" alt="Fork me on GitHub" /> <img style="z-index: 50000; position: absolute; top: 0; right: 0; border: 0; width: 125px; height: 125px" src="https://camo.githubusercontent.com/e6bef7a091f5f3138b8cd40bc3e114258dd68ddf/687474703a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f7265645f6161303030302e706e67" alt="Fork me on GitHub" />
</a> </a>
<div id="wrapper"> <div id="wrapper">
<div class="content"> <div class="content">
@ -65,7 +68,7 @@
and is the successor of the Mozilla Skywriter (Bespin) project. and is the successor of the Mozilla Skywriter (Bespin) project.
</p> </p>
<div id="ace_editor_demo" style="opacity:0">/** <pre id="ace_editor_demo" style="opacity:0">/**
* In fact, you're looking at ACE right now. Go ahead and play with it! * In fact, you're looking at ACE right now. Go ahead and play with it!
* *
* We are currently showing off the JavaScript mode. ACE has support for 45 * We are currently showing off the JavaScript mode. ACE has support for 45
@ -80,7 +83,7 @@ function add(x, y) {
var addResult = add(3, 2); var addResult = add(3, 2);
console.log(addResult); console.log(addResult);
</div> </pre>
<p id="embed_link"><a href="#nav=embedding">Learn how to embed this in your own site</a></p> <p id="embed_link"><a href="#nav=embedding">Learn how to embed this in your own site</a></p>
<p class="highlight_note">Looking for a more full-featured demo? Check out the <p class="highlight_note">Looking for a more full-featured demo? Check out the
<a href="build/kitchen-sink.html" target="_blank">kitchen sink</a>. <a href="build/kitchen-sink.html" target="_blank">kitchen sink</a>.
@ -140,7 +143,7 @@ console.log(addResult);
<h1>Embedding Ace in Your Site</h1> <h1>Embedding Ace in Your Site</h1>
<p>Ace can be easily embedded into a web page. Get prebuilt version of ace from <p>Ace can be easily embedded into a web page. Get prebuilt version of ace from
<a href="https://github.com/ajaxorg/ace-builds/">ace-builds</a> repository and use the code below:</p> <a href="https://github.com/ajaxorg/ace-builds/">ace-builds</a> repository and use the code below:</p>
<div id="embedded_ace_code" style="opacity:0">&lt;!DOCTYPE html> <pre id="embedded_ace_code" style="opacity:0">&lt;!DOCTYPE html>
&lt;html lang="en"> &lt;html lang="en">
&lt;head> &lt;head>
&lt;title>ACE in Action&lt;/title> &lt;title>ACE in Action&lt;/title>
@ -168,7 +171,7 @@ console.log(addResult);
editor.getSession().setMode("ace/mode/javascript"); editor.getSession().setMode("ace/mode/javascript");
&lt;/script> &lt;/script>
&lt;/body> &lt;/body>
&lt;/html></div> &lt;/html></pre>
<p>Now check out the <a href="#nav=howto">How-To Guide</a> for instructions on <p>Now check out the <a href="#nav=howto">How-To Guide</a> for instructions on
common operations, such as setting a different language mode or common operations, such as setting a different language mode or
getting the contents from the editor. getting the contents from the editor.
@ -785,7 +788,7 @@ if (match) {
<img src="doc/site/images/zorba-logo.png" <img src="doc/site/images/zorba-logo.png"
style="left: -5px; top: 16px; style="left: -5px; top: 16px;
padding: 6px 4px 6px 6px; width: 100px" /> padding: 6px 4px 6px 6px; width: 100px" />
<a href="http://www.zorba-xquery.com/html/demo">Zorba XQuery</a> <a href="http://try.zorba.io/queries/xquery">Zorba XQuery</a>
</li> </li>
<li> <li>
<img src="doc/site/images/plunker.png" <img src="doc/site/images/plunker.png"
@ -871,9 +874,9 @@ if (match) {
<a href="https://drivenotepad.appspot.com/support">Drive Notepad</a> <a href="https://drivenotepad.appspot.com/support">Drive Notepad</a>
</li> </li>
<li> <li>
<img src="doc/site/images/FineCut_small_logo.png" <img src="http://textor.houfeng.net/images/textor.png"
style="left: 12px; top: -4px" /> style="position: relative; left: 13px; top: -3px; width: 75px" />
<a href="http://finecut.info/">Fine Cut Engine</a> <a href="http://textor.houfeng.net/">Textor</a>
</li> </li>
<li> <li>
<img src="http://phpassist.com/images/logo-large.png" <img src="http://phpassist.com/images/logo-large.png"
@ -907,9 +910,9 @@ if (match) {
<a href="http://orbit.bonsaijs.org/">BonsaiJS playground</a> <a href="http://orbit.bonsaijs.org/">BonsaiJS playground</a>
</li> </li>
<li> <li>
<img src="doc/site/images/acebug-logo.png" <img src="http://approximatrix.com/products/simplytext/logo-320x320.png"
style="left: 20px; top: 5px;"> style="width: 106px; left: -4px; top: -22px;">
<a href="https://addons.mozilla.org/en-US/firefox/addon/acebug/">Acebug</a> <a href="http://approximatrix.com/products/simplytext">Simply Text</a>
</li> </li>
<li> <li>
<div class="text-logo" style="font-size: 18px;">ShareLaTeX</div> <div class="text-logo" style="font-size: 18px;">ShareLaTeX</div>
@ -1109,7 +1112,7 @@ if (match) {
<a href="http://bakemycss.mypathforpython.appspot.com/">BakeMyCss</a> <a href="http://bakemycss.mypathforpython.appspot.com/">BakeMyCss</a>
</li> </li>
<li> <li>
<div class="" style=" <div style="
background: url(https://s3.amazonaws.com/spark-website/spark.png) no-repeat; background: url(https://s3.amazonaws.com/spark-website/spark.png) no-repeat;
position: absolute; height: 65px; width: 83px; background-size: 200px 65px; position: absolute; height: 65px; width: 83px; background-size: 200px 65px;
background-position: 19px;"></div> background-position: 19px;"></div>
@ -1128,7 +1131,56 @@ if (match) {
<a href=" http://www.praczone.com/editor">pracZone</a> <a href=" http://www.praczone.com/editor">pracZone</a>
</li> </li>
<li> <li>
<a href="https://github.com/Gozala/sky-edit">Sky Edit</a> <img src="http://resources.qooxdoo.org/images/logo.gif"
style="width: 125px; left: -13px; top: 18px;">
<a href="http://demo.qooxdoo.org/devel/playground/#">Qooxdoo playground</a>
</li>
<li>
<div class="text-logo">ShareJS</div>
<a href="http://sharejs.org/hello-ace.html">ShareJS</a>
</li>
<li>
<img src="https://neutron-drive.appspot.com/static/img/neutron_face_high.png"
style="width: 86px; left: 7px; top: -11px;">
<a href="http://neutronide.com/">Neutron IDE</a>
</li>
<li>
<div style="
background: url(https://www.pythonanywhere.com/static/anywhere/images/logo-234x35.png) no-repeat;
position: absolute; height: 65px; width: 94px; background-size: 234px 35px;
background-position: 19px;"></div>
<a href="http://www.pythonanywhere.com/">PythonAnywhere</a>
</li>
<li>
<img src="http://subtexteditor.com/images/subtext-icon-4.png"
style="width: 86px; left: 7px; top: -11px;">
<a href="http://subtexteditor.com/">Subtext Editor</a>
</li>
<li>
<img src="http://climbi.com/static/img/logo.png"
style="width: 86px; left: 7px; top: -11px;">
<a href="http://climbi.com/">Climbi</a>
</li>
<li>
<div style="
background: url(http://gpupowered.org/sites/default/files/favicon.png) rgba(0, 0, 0, 0.66) no-repeat;
position: absolute;
height: 75px;
width: 99px; background-size: 27px 32px;
background-position: 37px;"></div>
<a href="http://www.gpupowered.org/sand2/launch2/#">GPUPowered</a>
</li>
<li style="width: 248px;">
<img src="http://www.codeavengers.com/image/RedLogoSmall.png" style="width: 248px; top: 30px;">
<a href="http://www.codeavengers.com/image/RedLogoSmall.png">Code Avengers</a>
</li>
<li style="width: 248px;">
<img src="http://www.codemonkey.co.il/images/logoSmallFaceTop.png" style="width: 248px; top: -3px;">
<a href="http://www.codemonkey.co.il/">CodeMonkey</a>
</li>
<li style="width: 248px;">
<img src="http://learn-angular.org/Content/Images/LearnAngular-small.png" style="width: 275px; left: -12px; top: 7px;">
<a href="http://learn-angular.org">Learn Angular</a>
</li> </li>
<li> <li>
<a href="http://www.wavemaker.com/">WaveMaker</a> <a href="http://www.wavemaker.com/">WaveMaker</a>
@ -1136,35 +1188,15 @@ if (match) {
<li> <li>
<a href="http://www.playmycode.com/">Play My Code</a> <a href="http://www.playmycode.com/">Play My Code</a>
</li> </li>
<li>
<img src="http://resources.qooxdoo.org/images/logo.gif"
style="width: 125px; left: -13px; top: 18px;">
<a href="http://demo.qooxdoo.org/devel/playground/#">Qooxdoo playground</a>
</li>
<li> <li>
<a href="http://ext.radiantcms.org/extensions/264-ace">Radiant CMS</a> <a href="http://ext.radiantcms.org/extensions/264-ace">Radiant CMS</a>
</li> </li>
<li> <li>
<a href="http://developercompanion.com/">Developer Companion</a> <a href="http://developercompanion.com/">Developer Companion</a>
</li> </li>
<li>
<a href="http://www.pythonanywhere.com/">PythonAnywhere</a>
</li>
<li>
<div class="text-logo">ShareJS</div>
<a href="http://sharejs.org/hello-ace.html">ShareJS</a>
</li>
<li>
<img src="https://neutron-drive.appspot.com/static/img/neutron_face_high.png"
style="width: 76px; left: 7px; top: -11px;">
<a href="http://neutronide.com/">Neutron IDE</a>
</li>
<li> <li>
<a href="http://www.akshell.com/">Akshell</a> <a href="http://www.akshell.com/">Akshell</a>
</li> </li>
<li>
<a href="http://beanstalkapp.com/">beanstalk</a>
</li>
<li> <li>
<div class="text-logo">tmpltr</div> <div class="text-logo">tmpltr</div>

View file

@ -11,16 +11,10 @@
commit %commit% commit %commit%
--> -->
<!--DEVEL-->
<link rel="stylesheet" href="demo/kitchen-sink/styles.css" type="text/css" media="screen" charset="utf-8"> <link rel="stylesheet" href="demo/kitchen-sink/styles.css" type="text/css" media="screen" charset="utf-8">
<script async="true" src="http://use.edgefonts.net/source-code-pro.js"></script> <script async="true" src="https://use.edgefonts.net/source-code-pro.js"></script>
<!--DEVEL-->
<link href="./doc/site/images/favicon.ico" rel="icon" type="image/x-icon"> <link href="./doc/site/images/favicon.ico" rel="icon" type="image/x-icon">
<!--PACKAGE
<link rel="stylesheet" href="kitchen-sink/styles.css" type="text/css" media="screen" charset="utf-8">
<script async="true" src="http://use.edgefonts.net/source-code-pro.js"></script>
PACKAGE-->
</head> </head>
<body> <body>
<div id="optionsPanel" style="position:absolute;height:100%;width:260px"> <div id="optionsPanel" style="position:absolute;height:100%;width:260px">
@ -287,7 +281,7 @@
<script src="src/ace.js" data-ace-base="src" type="text/javascript" charset="utf-8"></script> <script src="src/ace.js" data-ace-base="src" type="text/javascript" charset="utf-8"></script>
<script src="src/keybinding-vim.js"></script> <script src="src/keybinding-vim.js"></script>
<script src="src/keybinding-emacs.js"></script> <script src="src/keybinding-emacs.js"></script>
<script src="kitchen-sink/demo.js"></script> <script src="demo/kitchen-sink/demo.js"></script>
<script type="text/javascript" charset="utf-8"> <script type="text/javascript" charset="utf-8">
require("kitchen-sink/demo"); require("kitchen-sink/demo");
</script> </script>

View file

@ -46,12 +46,12 @@ var Editor = require("./editor").Editor;
var EditSession = require("./edit_session").EditSession; var EditSession = require("./edit_session").EditSession;
var UndoManager = require("./undomanager").UndoManager; var UndoManager = require("./undomanager").UndoManager;
var Renderer = require("./virtual_renderer").VirtualRenderer; var Renderer = require("./virtual_renderer").VirtualRenderer;
var MultiSelect = require("./multi_select").MultiSelect;
// The following require()s are for inclusion in the built ace file // The following require()s are for inclusion in the built ace file
require("./worker/worker_client"); require("./worker/worker_client");
require("./keyboard/hash_handler"); require("./keyboard/hash_handler");
require("./placeholder"); require("./placeholder");
require("./multi_select");
require("./mode/folding/fold_mode"); require("./mode/folding/fold_mode");
require("./theme/textmate"); require("./theme/textmate");
require("./ext/error_marker"); require("./ext/error_marker");
@ -74,7 +74,7 @@ exports.require = require;
exports.edit = function(el) { exports.edit = function(el) {
if (typeof(el) == "string") { if (typeof(el) == "string") {
var _id = el; var _id = el;
var el = document.getElementById(_id); el = document.getElementById(_id);
if (!el) if (!el)
throw new Error("ace.edit can't find div #" + _id); throw new Error("ace.edit can't find div #" + _id);
} }
@ -86,7 +86,6 @@ exports.edit = function(el) {
el.innerHTML = ''; el.innerHTML = '';
var editor = new Editor(new Renderer(el)); var editor = new Editor(new Renderer(el));
new MultiSelect(editor);
editor.setSession(doc); editor.setSession(doc);
var env = { var env = {

View file

@ -58,6 +58,15 @@ module.exports = {
assert.position(anchor.getPosition(), 1, 7); assert.position(anchor.getPosition(), 1, 7);
}, },
"test insert text at anchor should not move anchor when insertRight is true": function() {
var doc = new Document("juhu\nkinners");
var anchor = new Anchor(doc, 1, 4);
anchor.$insertRight = true;
doc.insert({row: 1, column: 4}, "123");
assert.position(anchor.getPosition(), 1, 4);
},
"test insert lines before cursor should move anchor row": function() { "test insert lines before cursor should move anchor row": function() {
var doc = new Document("juhu\nkinners"); var doc = new Document("juhu\nkinners");
var anchor = new Anchor(doc, 1, 4); var anchor = new Anchor(doc, 1, 4);
@ -66,6 +75,32 @@ module.exports = {
assert.position(anchor.getPosition(), 3, 4); assert.position(anchor.getPosition(), 3, 4);
}, },
"test insert lines at anchor position should move anchor down": function() {
var doc = new Document("juhu\nkinners");
var anchor = new Anchor(doc, 1, 0);
doc.insertLines(1, ["line"]);
assert.position(anchor.getPosition(), 2, 0);
},
"test insert lines at anchor position should not move anchor down when insertRight is true and column is 0": function() {
var doc = new Document("juhu\nkinners");
var anchor = new Anchor(doc, 1, 0);
anchor.$insertRight = true;
doc.insertLines(1, ["line"]);
assert.position(anchor.getPosition(), 1, 0);
},
"test insert lines at anchor row should move anchor down when column > 0": function() {
var doc = new Document("juhu\nkinners");
var anchor = new Anchor(doc, 1, 2);
anchor.$insertRight = true;
doc.insertLines(1, ["line"]);
assert.position(anchor.getPosition(), 2, 2);
},
"test insert new line before cursor should move anchor column": function() { "test insert new line before cursor should move anchor column": function() {
var doc = new Document("juhu\nkinners"); var doc = new Document("juhu\nkinners");
var anchor = new Anchor(doc, 1, 4); var anchor = new Anchor(doc, 1, 4);

View file

@ -51,7 +51,7 @@ var Autocomplete = function() {
this.changeTimer = lang.delayedCall(function() { this.changeTimer = lang.delayedCall(function() {
this.updateCompletions(true); this.updateCompletions(true);
}.bind(this)) }.bind(this));
}; };
(function() { (function() {
@ -63,6 +63,7 @@ var Autocomplete = function() {
this.insertMatch(); this.insertMatch();
e.stop(); e.stop();
}.bind(this)); }.bind(this));
this.popup.focus = this.editor.focus.bind(this.editor);
}; };
this.openPopup = function(editor, prefix, keepPopupPosition) { this.openPopup = function(editor, prefix, keepPopupPosition) {
@ -122,7 +123,10 @@ var Autocomplete = function() {
}; };
this.blurListener = function() { this.blurListener = function() {
if (document.activeElement != this.editor.textInput.getElement()) // we have to check if activeElement is a child of popup because
// on IE preventDefault doesn't stop scrollbar from being focussed
var el = document.activeElement;
if (el != this.editor.textInput.getElement() && el.parentNode != this.popup.container)
this.detach(); this.detach();
}; };
@ -139,7 +143,7 @@ var Autocomplete = function() {
var max = this.popup.session.getLength() - 1; var max = this.popup.session.getLength() - 1;
switch(where) { switch(where) {
case "up": row = row < 0 ? max : row - 1; break; case "up": row = row <= 0 ? max : row - 1; break;
case "down": row = row >= max ? -1 : row + 1; break; case "down": row = row >= max ? -1 : row + 1; break;
case "start": row = 0; break; case "start": row = 0; break;
case "end": row = max; break; case "end": row = max; break;
@ -180,13 +184,15 @@ var Autocomplete = function() {
"Esc": function(editor) { editor.completer.detach(); }, "Esc": function(editor) { editor.completer.detach(); },
"Space": function(editor) { editor.completer.detach(); editor.insert(" ");}, "Space": function(editor) { editor.completer.detach(); editor.insert(" ");},
"Return": function(editor) { "Return": function(editor) { return editor.completer.insertMatch(); },
if (editor.completer.popup.getRow() == -1)
return false;
editor.completer.insertMatch();
},
"Shift-Return": function(editor) { editor.completer.insertMatch(true); }, "Shift-Return": function(editor) { editor.completer.insertMatch(true); },
"Tab": function(editor) { editor.completer.insertMatch(); }, "Tab": function(editor) {
var result = editor.completer.insertMatch();
if (!result && !editor.tabstopManager)
editor.completer.goTo("down");
else
return result;
},
"PageUp": function(editor) { editor.completer.popup.gotoPageUp(); }, "PageUp": function(editor) { editor.completer.popup.gotoPageUp(); },
"PageDown": function(editor) { editor.completer.popup.gotoPageDown(); } "PageDown": function(editor) { editor.completer.popup.gotoPageDown(); }
@ -212,7 +218,7 @@ var Autocomplete = function() {
var pos = editor.getCursorPosition(); var pos = editor.getCursorPosition();
var line = session.getLine(pos.row); var line = session.getLine(pos.row);
callback(null, { callback(null, {
prefix: util.retrievePrecedingIdentifier(line, pos.column), prefix: util.retrievePrecedingIdentifier(line, pos.column, results[0] && results[0].identifierRegex),
matches: matches, matches: matches,
finished: (--total === 0) finished: (--total === 0)
}); });
@ -264,31 +270,19 @@ var Autocomplete = function() {
var _id = this.gatherCompletionsId; var _id = this.gatherCompletionsId;
this.gatherCompletions(this.editor, function(err, results) { this.gatherCompletions(this.editor, function(err, results) {
// Only detach if result gathering is finished // Only detach if result gathering is finished
var doDetach = function() { var detachIfFinished = function() {
if (!results.finished) return; if (!results.finished) return;
return this.detach(); return this.detach();
}.bind(this); }.bind(this);
// Calcul prefix var prefix = results.prefix;
var session = this.editor.getSession();
var pos = this.editor.getCursorPosition();
var line = session.getLine(pos.row);
var prefix = util.retrievePrecedingIdentifier(line, pos.column);
// Results matches
var matches = results && results.matches; var matches = results && results.matches;
if (!matches || !matches.length)
return this.detach();
// TODO reenable this when we have proper change tracking
// if (matches.length == 1)
// return this.insertMatch(matches[0]);
// No prefix or no results -> close if (!matches || !matches.length)
if (!prefix || !prefix.length || !matches || !matches.length) return detachIfFinished();
return doDetach();
// Wrong prefix or wrong session -> ignore // Wrong prefix or wrong session -> ignore
if (prefix.indexOf(results.prefix) != 0 || _id != this.gatherCompletionsId) if (prefix.indexOf(results.prefix) !== 0 || _id != this.gatherCompletionsId)
return; return;
this.completions = new FilteredList(matches); this.completions = new FilteredList(matches);
@ -297,11 +291,11 @@ var Autocomplete = function() {
// No results // No results
if (!filtered.length) if (!filtered.length)
return doDetach(); return detachIfFinished();
// One result equals to the prefix // One result equals to the prefix
if (filtered.length == 1 && filtered[0].value == prefix && !filtered[0].snippet) if (filtered.length == 1 && filtered[0].value == prefix && !filtered[0].snippet)
return doDetach(); return detachIfFinished();
// Autoinsert if one result // Autoinsert if one result
if (this.autoInsert && filtered.length == 1) if (this.autoInsert && filtered.length == 1)
@ -312,13 +306,7 @@ var Autocomplete = function() {
}; };
this.cancelContextMenu = function() { this.cancelContextMenu = function() {
var stop = function(e) { this.editor.$mouseHandler.cancelContextMenu();
this.editor.off("nativecontextmenu", stop);
if (e && e.domEvent)
event.stopEvent(e.domEvent);
}.bind(this);
setTimeout(stop, 10);
this.editor.on("nativecontextmenu", stop);
}; };
}).call(Autocomplete.prototype); }).call(Autocomplete.prototype);
@ -328,6 +316,8 @@ Autocomplete.startCommand = {
exec: function(editor) { exec: function(editor) {
if (!editor.completer) if (!editor.completer)
editor.completer = new Autocomplete(); editor.completer = new Autocomplete();
editor.completer.autoInsert =
editor.completer.autoSelect = true;
editor.completer.showPopup(editor); editor.completer.showPopup(editor);
// needed for firefox on mac // needed for firefox on mac
editor.completer.cancelContextMenu(); editor.completer.cancelContextMenu();

View file

@ -31,7 +31,7 @@
define(function(require, exports, module) { define(function(require, exports, module) {
var Range = require("../range").Range; var Range = require("../range").Range;
var splitRegex = /[^a-zA-Z_0-9\$\-]+/; var splitRegex = /[^a-zA-Z_0-9\$\-\u00C0-\u1FFF\u2C00-\uD7FF\w]+/;
function getWordIndex(doc, pos) { function getWordIndex(doc, pos) {
var textBefore = doc.getTextRange(Range.fromPoints({row: 0, column:0}, pos)); var textBefore = doc.getTextRange(Range.fromPoints({row: 0, column:0}, pos));

View file

@ -43,9 +43,9 @@ exports.parForEach = function(array, fn, callback) {
callback(result, err); callback(result, err);
}); });
} }
} };
var ID_REGEX = /[a-zA-Z_0-9\$-]/; var ID_REGEX = /[a-zA-Z_0-9\$\-\u00A2-\uFFFF]/;
exports.retrievePrecedingIdentifier = function(text, pos, regex) { exports.retrievePrecedingIdentifier = function(text, pos, regex) {
regex = regex || ID_REGEX; regex = regex || ID_REGEX;
@ -57,7 +57,7 @@ exports.retrievePrecedingIdentifier = function(text, pos, regex) {
break; break;
} }
return buf.reverse().join(""); return buf.reverse().join("");
} };
exports.retrieveFollowingIdentifier = function(text, pos, regex) { exports.retrieveFollowingIdentifier = function(text, pos, regex) {
regex = regex || ID_REGEX; regex = regex || ID_REGEX;
@ -69,6 +69,6 @@ exports.retrieveFollowingIdentifier = function(text, pos, regex) {
break; break;
} }
return buf; return buf;
} };
}); });

View file

@ -33,6 +33,7 @@ define(function(require, exports, module) {
var lang = require("../lib/lang"); var lang = require("../lib/lang");
var config = require("../config"); var config = require("../config");
var Range = require("../range").Range;
function bindKey(win, mac) { function bindKey(win, mac) {
return {win: win, mac: mac}; return {win: win, mac: mac};
@ -141,15 +142,19 @@ exports.commands = [{
name: "findnext", name: "findnext",
bindKey: bindKey("Ctrl-K", "Command-G"), bindKey: bindKey("Ctrl-K", "Command-G"),
exec: function(editor) { editor.findNext(); }, exec: function(editor) { editor.findNext(); },
multiSelectAction: "forEach",
scrollIntoView: "center",
readOnly: true readOnly: true
}, { }, {
name: "findprevious", name: "findprevious",
bindKey: bindKey("Ctrl-Shift-K", "Command-Shift-G"), bindKey: bindKey("Ctrl-Shift-K", "Command-Shift-G"),
exec: function(editor) { editor.findPrevious(); }, exec: function(editor) { editor.findPrevious(); },
multiSelectAction: "forEach",
scrollIntoView: "center",
readOnly: true readOnly: true
}, { }, {
name: "selectOrFindNext", name: "selectOrFindNext",
bindKey: bindKey("ALt-K", "Ctrl-G"), bindKey: bindKey("Alt-K", "Ctrl-G"),
exec: function(editor) { exec: function(editor) {
if (editor.selection.isEmpty()) if (editor.selection.isEmpty())
editor.selection.selectWord(); editor.selection.selectWord();
@ -387,16 +392,22 @@ exports.commands = [{
readOnly: true readOnly: true
}, { }, {
name: "jumptomatching", name: "jumptomatching",
bindKey: bindKey("Ctrl-P", "Ctrl-Shift-P"), bindKey: bindKey("Ctrl-P", "Ctrl-P"),
exec: function(editor) { editor.jumpToMatching(); }, exec: function(editor) { editor.jumpToMatching(); },
multiSelectAction: "forEach", multiSelectAction: "forEach",
readOnly: true readOnly: true
}, { }, {
name: "selecttomatching", name: "selecttomatching",
bindKey: bindKey("Ctrl-Shift-P", null), bindKey: bindKey("Ctrl-Shift-P", "Ctrl-Shift-P"),
exec: function(editor) { editor.jumpToMatching(true); }, exec: function(editor) { editor.jumpToMatching(true); },
multiSelectAction: "forEach", multiSelectAction: "forEach",
readOnly: true readOnly: true
}, {
name: "passKeysToBrowser",
bindKey: bindKey("null", "null"),
exec: function() {},
passEvent: true,
readOnly: true
}, },
// commands disabled in readOnly mode // commands disabled in readOnly mode
@ -598,6 +609,100 @@ exports.commands = [{
exec: function(editor) { editor.toLowerCase(); }, exec: function(editor) { editor.toLowerCase(); },
multiSelectAction: "forEach", multiSelectAction: "forEach",
scrollIntoView: "cursor" scrollIntoView: "cursor"
}, {
name: "expandtoline",
bindKey: bindKey("Ctrl-Shift-L", "Command-Shift-L"),
exec: function(editor) {
var range = editor.selection.getRange();
range.start.column = range.end.column = 0;
range.end.row++;
editor.selection.setRange(range, false);
},
multiSelectAction: "forEach",
scrollIntoView: "cursor",
readOnly: true
}, {
name: "joinlines",
bindKey: bindKey(null, null),
exec: function(editor) {
var isBackwards = editor.selection.isBackwards();
var selectionStart = isBackwards ? editor.selection.getSelectionLead() : editor.selection.getSelectionAnchor();
var selectionEnd = isBackwards ? editor.selection.getSelectionAnchor() : editor.selection.getSelectionLead();
var firstLineEndCol = editor.session.doc.getLine(selectionStart.row).length
var selectedText = editor.session.doc.getTextRange(editor.selection.getRange());
var selectedCount = selectedText.replace(/\n\s*/, " ").length;
var insertLine = editor.session.doc.getLine(selectionStart.row);
for (var i = selectionStart.row + 1; i <= selectionEnd.row + 1; i++) {
var curLine = lang.stringTrimLeft(lang.stringTrimRight(editor.session.doc.getLine(i)));
if (curLine.length !== 0) {
curLine = " " + curLine;
}
insertLine += curLine;
};
if (selectionEnd.row + 1 < (editor.session.doc.getLength() - 1)) {
// Don't insert a newline at the end of the document
insertLine += editor.session.doc.getNewLineCharacter();
}
editor.clearSelection();
editor.session.doc.replace(new Range(selectionStart.row, 0, selectionEnd.row + 2, 0), insertLine);
if (selectedCount > 0) {
// Select the text that was previously selected
editor.selection.moveCursorTo(selectionStart.row, selectionStart.column);
editor.selection.selectTo(selectionStart.row, selectionStart.column + selectedCount);
} else {
// If the joined line had something in it, start the cursor at that something
firstLineEndCol = editor.session.doc.getLine(selectionStart.row).length > firstLineEndCol ? (firstLineEndCol + 1) : firstLineEndCol;
editor.selection.moveCursorTo(selectionStart.row, firstLineEndCol);
}
},
multiSelectAction: "forEach",
readOnly: true
}, {
name: "invertSelection",
bindKey: bindKey(null, null),
exec: function(editor) {
var endRow = editor.session.doc.getLength() - 1;
var endCol = editor.session.doc.getLine(endRow).length;
var ranges = editor.selection.rangeList.ranges;
var newRanges = [];
// If multiple selections don't exist, rangeList will return 0 so replace with single range
if (ranges.length < 1) {
ranges = [editor.selection.getRange()];
}
for (var i = 0; i < ranges.length; i++) {
if (i == (ranges.length - 1)) {
// The last selection must connect to the end of the document, unless it already does
if (!(ranges[i].end.row === endRow && ranges[i].end.column === endCol)) {
newRanges.push(new Range(ranges[i].end.row, ranges[i].end.column, endRow, endCol));
}
}
if (i === 0) {
// The first selection must connect to the start of the document, unless it already does
if (!(ranges[i].start.row === 0 && ranges[i].start.column === 0)) {
newRanges.push(new Range(0, 0, ranges[i].start.row, ranges[i].start.column));
}
} else {
newRanges.push(new Range(ranges[i-1].end.row, ranges[i-1].end.column, ranges[i].start.row, ranges[i].start.column));
}
}
editor.exitMultiSelectMode();
editor.clearSelection();
for(var i = 0; i < newRanges.length; i++) {
editor.selection.addRange(newRanges[i], false);
}
},
readOnly: true,
scrollIntoView: "none"
}]; }];
}); });

View file

@ -80,6 +80,11 @@ exports.defaultCommands = [{
name: "alignCursors", name: "alignCursors",
exec: function(editor) { editor.alignCursors(); }, exec: function(editor) { editor.alignCursors(); },
bindKey: {win: "Ctrl-Alt-A", mac: "Ctrl-Alt-A"} 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 // commands active only in multiselect mode

View file

@ -153,7 +153,11 @@ function init(packaged) {
var scriptOptions = {}; var scriptOptions = {};
var scriptUrl = ""; var scriptUrl = "";
var scripts = document.getElementsByTagName("script"); // Use currentScript.ownerDocument in case this file was loaded from imported document. (HTML Imports)
var currentScript = (document.currentScript || document._currentScript ); // native or polyfill
var currentDocument = currentScript && currentScript.ownerDocument || document;
var scripts = currentDocument.getElementsByTagName("script");
for (var i=0; i<scripts.length; i++) { for (var i=0; i<scripts.length; i++) {
var script = scripts[i]; var script = scripts[i];

View file

@ -485,15 +485,15 @@ function Folding() {
}; };
this.getFoldDisplayLine = function(foldLine, endRow, endColumn, startRow, startColumn) { this.getFoldDisplayLine = function(foldLine, endRow, endColumn, startRow, startColumn) {
if (startRow == null) { if (startRow == null)
startRow = foldLine.start.row; startRow = foldLine.start.row;
if (startColumn == null)
startColumn = 0; startColumn = 0;
} if (endRow == null)
if (endRow == null) {
endRow = foldLine.end.row; endRow = foldLine.end.row;
if (endColumn == null)
endColumn = this.getLine(endRow).length; endColumn = this.getLine(endRow).length;
}
// Build the textline using the FoldLine walker. // Build the textline using the FoldLine walker.
var doc = this.doc; var doc = this.doc;

View file

@ -48,6 +48,7 @@ var EventEmitter = require("./lib/event_emitter").EventEmitter;
var CommandManager = require("./commands/command_manager").CommandManager; var CommandManager = require("./commands/command_manager").CommandManager;
var defaultCommands = require("./commands/default_commands").commands; var defaultCommands = require("./commands/default_commands").commands;
var config = require("./config"); var config = require("./config");
var TokenIterator = require("./token_iterator").TokenIterator;
/** /**
* The main entry point into the Ace functionality. * The main entry point into the Ace functionality.
@ -210,13 +211,14 @@ var Editor = function(renderer, session) {
} }
}; };
// TODO use property on commands instead of this
this.$mergeableCommands = ["backspace", "del", "insertstring"];
this.$historyTracker = function(e) { this.$historyTracker = function(e) {
if (!this.$mergeUndoDeltas) if (!this.$mergeUndoDeltas)
return; return;
var prev = this.prevOp; var prev = this.prevOp;
var mergeableCommands = ["backspace", "del", "insertstring"]; var mergeableCommands = this.$mergeableCommands;
// previous command was the same // previous command was the same
var shouldMerge = prev.command && (e.command.name == prev.command.name); var shouldMerge = prev.command && (e.command.name == prev.command.name);
if (e.command.name == "insertstring") { if (e.command.name == "insertstring") {
@ -535,6 +537,89 @@ var Editor = function(renderer, session) {
}, 50); }, 50);
}; };
// todo: move to mode.getMatching
this.$highlightTags = function() {
var session = this.session;
if (this.$highlightTagPending) {
return;
}
// perform highlight async to not block the browser during navigation
var self = this;
this.$highlightTagPending = true;
setTimeout(function() {
self.$highlightTagPending = false;
var pos = self.getCursorPosition();
var iterator = new TokenIterator(self.session, pos.row, pos.column);
var token = iterator.getCurrentToken();
if (!token || token.type.indexOf('tag-name') === -1) {
session.removeMarker(session.$tagHighlight);
session.$tagHighlight = null;
return;
}
var tag = token.value;
var depth = 0;
var prevToken = iterator.stepBackward();
if (prevToken.value == '<'){
//find closing tag
do {
prevToken = token;
token = iterator.stepForward();
if (token && token.value === tag && token.type.indexOf('tag-name') !== -1) {
if (prevToken.value==='<'){
depth++;
} else if (prevToken.value==='</'){
depth--;
}
}
} while (token && depth>=0);
}else{
//find opening tag
do {
token = prevToken;
prevToken = iterator.stepBackward();
if(token && token.value === tag && token.type.indexOf('tag-name') !== -1) {
if (prevToken.value==='<') {
depth++;
} else if( prevToken.value==='</') {
depth--;
}
}
} while (prevToken && depth<=0);
//select tag again
iterator.stepForward();
}
if (!token) {
session.removeMarker(session.$tagHighlight);
session.$tagHighlight = null;
return;
}
var row = iterator.getCurrentTokenRow();
var column = iterator.getCurrentTokenColumn();
var range = new Range(row, column, row, column+token.value.length);
//remove range if different
if (session.$tagHighlight && range.compareRange(session.$backMarkers[session.$tagHighlight].range)!==0) {
session.removeMarker(session.$tagHighlight);
session.$tagHighlight = null;
}
if (range && !session.$tagHighlight)
session.$tagHighlight = session.addMarker(range, "ace_bracket", "text");
}, 50);
};
/** /**
* *
* Brings the current `textInput` into focus. * Brings the current `textInput` into focus.
@ -645,6 +730,7 @@ var Editor = function(renderer, session) {
} }
this.$highlightBrackets(); this.$highlightBrackets();
this.$highlightTags();
this.$updateHighlightActiveLine(); this.$updateHighlightActiveLine();
this._signal("changeSelection"); this._signal("changeSelection");
}; };
@ -1901,25 +1987,158 @@ var Editor = function(renderer, session) {
}; };
/** /**
* Moves the cursor's row and column to the next matching bracket. * Moves the cursor's row and column to the next matching bracket or HTML tag.
* *
**/ **/
this.jumpToMatching = function(select) { this.jumpToMatching = function(select) {
var cursor = this.getCursorPosition(); var cursor = this.getCursorPosition();
var iterator = new TokenIterator(this.session, cursor.row, cursor.column);
var prevToken = iterator.getCurrentToken();
var token = prevToken;
var range = this.session.getBracketRange(cursor); if (!token)
token = iterator.stepForward();
if (!token)
return;
//get next closing tag or bracket
var matchType;
var found = false;
var depth = {};
var i = cursor.column - token.start;
var bracketType;
var brackets = {
")": "(",
"(": "(",
"]": "[",
"[": "[",
"{": "{",
"}": "{"
};
do {
if (token.value.match(/[{}()\[\]]/g)) {
for (; i<token.value.length && !found; i++) {
if (!brackets[token.value[i]]) {
continue;
}
bracketType = brackets[token.value[i]]+'.'+token.type.replace("rparen", "lparen");
if (isNaN(depth[bracketType])) {
depth[bracketType] = 0;
}
switch (token.value[i]) {
case '(':
case '[':
case '{':
depth[bracketType]++;
break;
case ')':
case ']':
case '}':
depth[bracketType]--;
if (depth[bracketType]===-1) {
matchType = 'bracket';
found = true;
}
break;
}
}
} else if (token && token.type.indexOf('tag-name') !== -1) {
if (isNaN(depth[token.value])) {
depth[token.value] = 0;
}
if (prevToken.value === '<') {
depth[token.value]++;
} else if (prevToken.value === '</') {
depth[token.value]--;
}
if (depth[token.value] === -1) {
matchType = 'tag';
found = true;
}
}
if (!found) {
prevToken = token;
token = iterator.stepForward();
i = 0;
}
} while (token && !found);
//no match found
if (!matchType) {
return;
}
var range;
if (matchType==='bracket') {
range = this.session.getBracketRange(cursor);
if (!range) { if (!range) {
range = this.find({ range = new Range(
needle: /[{}()\[\]]/g, iterator.getCurrentTokenRow(),
preventScroll:true, iterator.getCurrentTokenColumn()+i-1,
start: {row: cursor.row, column: cursor.column - 1} iterator.getCurrentTokenRow(),
}); iterator.getCurrentTokenColumn()+i-1
);
if (!range) if (!range)
return; return;
var pos = range.start; var pos = range.start;
if (pos.row == cursor.row && Math.abs(pos.column - cursor.column) < 2) if (pos.row === cursor.row && Math.abs(pos.column - cursor.column) < 2)
range = this.session.getBracketRange(pos); range = this.session.getBracketRange(pos);
} }
} else if(matchType==='tag') {
if (token && token.type.indexOf('tag-name') !== -1)
var tag = token.value;
else
return;
var range = new Range(
iterator.getCurrentTokenRow(),
iterator.getCurrentTokenColumn()-2,
iterator.getCurrentTokenRow(),
iterator.getCurrentTokenColumn()-2
);
//find matching tag
if (range.compare(cursor.row, cursor.column) === 0) {
found = false;
do {
token = prevToken;
prevToken = iterator.stepBackward();
if (prevToken) {
if (prevToken.type.indexOf('tag-close') !== -1) {
range.setEnd(iterator.getCurrentTokenRow(), iterator.getCurrentTokenColumn()+1);
}
if (token.value === tag && token.type.indexOf('tag-name') !== -1) {
if (prevToken.value === '<') {
depth[tag]++;
} else if ( prevToken.value === '</') {
depth[tag]--;
}
if (depth[tag]===0)
found = true;
}
}
} while (prevToken && !found);
}
//we found it
if (token && token.type.indexOf('tag-name')) {
var pos = range.start;
if (pos.row == cursor.row && Math.abs(pos.column - cursor.column) < 2)
pos = range.end;
}
}
pos = range && range.cursor || pos; pos = range && range.cursor || pos;
if (pos) { if (pos) {
@ -2349,8 +2568,9 @@ var Editor = function(renderer, session) {
var cursorLayer = this.renderer.$cursorLayer; var cursorLayer = this.renderer.$cursorLayer;
if (!cursorLayer) if (!cursorLayer)
return; return;
cursorLayer.setSmoothBlinking(style == "smooth"); cursorLayer.setSmoothBlinking(/smooth/.test(style));
cursorLayer.isBlinking = !this.$readOnly && style != "wide"; cursorLayer.isBlinking = !this.$readOnly && style != "wide";
dom.setCssClass(cursorLayer.element, "ace_slim-cursors", /slim/.test(style));
}; };
}).call(Editor.prototype); }).call(Editor.prototype);
@ -2375,7 +2595,8 @@ config.defineOptions(Editor.prototype, "editor", {
}, },
readOnly: { readOnly: {
set: function(readOnly) { set: function(readOnly) {
this.textInput.setReadOnly(readOnly); // disabled to not break vim mode!
// this.textInput.setReadOnly(readOnly);
this.$resetCursorStyle(); this.$resetCursorStyle();
}, },
initialValue: false initialValue: false

View file

@ -368,6 +368,7 @@ exports.runEmmetCommand = function(editor) {
} catch(e) { } catch(e) {
editor._signal("changeStatus", typeof e == "string" ? e : e.message); editor._signal("changeStatus", typeof e == "string" ? e : e.message);
console.log(e); console.log(e);
result = false
} }
return result; return result;
}; };

View file

@ -72,6 +72,11 @@ exports.addCompleter = function(completer) {
completers.push(completer); completers.push(completer);
}; };
// Exports existing completer so that user can construct his own set of completers.
exports.textCompleter = textCompleter;
exports.keyWordCompleter = keyWordCompleter;
exports.snippetCompleter = snippetCompleter;
var expandSnippet = { var expandSnippet = {
name: "expandSnippet", name: "expandSnippet",
exec: function(editor) { exec: function(editor) {
@ -79,7 +84,7 @@ var expandSnippet = {
if (!success) if (!success)
editor.execCommand("indent"); editor.execCommand("indent");
}, },
bindKey: "tab" bindKey: "Tab"
}; };
var onChangeMode = function(e, editor) { var onChangeMode = function(e, editor) {
@ -103,8 +108,9 @@ var loadSnippetFile = function(id) {
config.loadModule(snippetFilePath, function(m) { config.loadModule(snippetFilePath, function(m) {
if (m) { if (m) {
snippetManager.files[id] = m; snippetManager.files[id] = m;
if (!m.snippets && m.snippetText)
m.snippets = snippetManager.parseSnippetFile(m.snippetText); m.snippets = snippetManager.parseSnippetFile(m.snippetText);
snippetManager.register(m.snippets, m.scope); snippetManager.register(m.snippets || [], m.scope);
if (m.includeScopes) { if (m.includeScopes) {
snippetManager.snippetMap[m.scope].includeScopes = m.includeScopes; snippetManager.snippetMap[m.scope].includeScopes = m.includeScopes;
m.includeScopes.forEach(function(x) { m.includeScopes.forEach(function(x) {
@ -115,56 +121,52 @@ var loadSnippetFile = function(id) {
}); });
}; };
function getCompletionPrefix(editor) {
var pos = editor.getCursorPosition();
var line = editor.session.getLine(pos.row);
var prefix = util.retrievePrecedingIdentifier(line, pos.column);
// Try to find custom prefixes on the completers
editor.completers.forEach(function(completer) {
if (completer.identifierRegexps) {
completer.identifierRegexps.forEach(function(identifierRegex) {
if (!prefix && identifierRegex)
prefix = util.retrievePrecedingIdentifier(line, pos.column, identifierRegex);
});
}
});
return prefix;
}
var doLiveAutocomplete = function(e) { var doLiveAutocomplete = function(e) {
var editor = e.editor; var editor = e.editor;
var session = editor.getSession();
var pos = editor.getCursorPosition();
var line = session.getLine(pos.row);
var hasCompleter = (editor.completer && editor.completer.activated);
var text = e.args || ""; var text = e.args || "";
var hasCompleter = editor.completer && editor.completer.activated;
// Is the user entering text
// we only want to automatically show the autocomplete dialog
// whenever the user is typing in text not pasting, deleting, ...
var typing = (e.command.name === "insertstring" && text.length === 1);
// We don't want to autocomplete with no prefix // We don't want to autocomplete with no prefix
if( if (e.command.name === "backspace") {
e.command.name === 'backspace' && if (hasCompleter && !getCompletionPrefix(editor))
util.retrievePrecedingIdentifier(line, pos.column) === '' editor.completer.detach();
) {
if(hasCompleter) editor.completer.detach();
return;
} }
else if (e.command.name === "insertstring") {
// we don't want to autocomplete on paste events var prefix = getCompletionPrefix(editor);
if(!typing) {
return;
}
// The prefix to autocomplete for
var prefix = util.retrievePrecedingIdentifier(line, pos.column);
// Only autocomplete if there's a prefix that can be matched // Only autocomplete if there's a prefix that can be matched
if(prefix !== '' && !(hasCompleter)) { if (prefix && !hasCompleter) {
if (!editor.completer) { if (!editor.completer) {
// Create new autocompleter // Create new autocompleter
editor.completer = new Autocomplete(); editor.completer = new Autocomplete();
// Disable autoInsert
editor.completer.autoInsert = false;
} }
// Disable autoInsert
editor.completer.autoSelect = false;
editor.completer.autoInsert = false;
editor.completer.showPopup(editor); editor.completer.showPopup(editor);
// needed for firefox on mac } else if (!prefix && hasCompleter) {
editor.completer.cancelContextMenu();
} else if(prefix === '' && hasCompleter) {
// When the prefix is empty // When the prefix is empty
// close the autocomplete dialog // close the autocomplete dialog
editor.completer.detach(); editor.completer.detach();
} }
}
}; };
var Editor = require("../editor").Editor; var Editor = require("../editor").Editor;
@ -172,7 +174,8 @@ require("../config").defineOptions(Editor.prototype, "editor", {
enableBasicAutocompletion: { enableBasicAutocompletion: {
set: function(val) { set: function(val) {
if (val) { if (val) {
this.completers = completers; if (!this.completers)
this.completers = Array.isArray(val)? val: completers;
this.commands.addCommand(Autocomplete.startCommand); this.commands.addCommand(Autocomplete.startCommand);
} else { } else {
this.commands.removeCommand(Autocomplete.startCommand); this.commands.removeCommand(Autocomplete.startCommand);
@ -180,9 +183,15 @@ require("../config").defineOptions(Editor.prototype, "editor", {
}, },
value: false value: false
}, },
enableLiveAutocomplete: { /**
* Enable live autocomplete. If the value is an array, it is assumed to be an array of completers
* and will use them instead of the default completers.
*/
enableLiveAutocompletion: {
set: function(val) { set: function(val) {
if (val) { if (val) {
if (!this.completers)
this.completers = Array.isArray(val)? val: completers;
// On each change automatically trigger the autocomplete // On each change automatically trigger the autocomplete
this.commands.on('afterExec', doLiveAutocomplete); this.commands.on('afterExec', doLiveAutocomplete);
} else { } else {
@ -205,5 +214,4 @@ require("../config").defineOptions(Editor.prototype, "editor", {
value: false value: false
} }
}); });
}); });

78
lib/ace/ext/linking.js Normal file
View file

@ -0,0 +1,78 @@
/* ***** BEGIN LICENSE BLOCK *****
* Distributed under the BSD license:
*
* Copyright (c) 2010, Ajax.org B.V.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Ajax.org B.V. nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* ***** END LICENSE BLOCK ***** */
define(function(require, exports, module) {
var Editor = require("ace/editor").Editor;
require("../config").defineOptions(Editor.prototype, "editor", {
enableLinking: {
set: function(val) {
if (val) {
this.on("click", onClick);
this.on("mousemove", onMouseMove);
} else {
this.off("click", onClick);
this.off("mousemove", onMouseMove);
}
},
value: false
}
})
function onMouseMove(e) {
var editor = e.editor;
var ctrl = e.getAccelKey();
if (ctrl) {
var editor = e.editor;
var docPos = e.getDocumentPosition();
var session = editor.session;
var token = session.getTokenAt(docPos.row, docPos.column);
editor._emit("linkHover", {position: docPos, token: token});
}
}
function onClick(e) {
var ctrl = e.getAccelKey();
var button = e.getButton();
if (button == 0 && ctrl) {
var editor = e.editor;
var docPos = e.getDocumentPosition();
var session = editor.session;
var token = session.getTokenAt(docPos.row, docPos.column);
editor._emit("linkClick", {position: docPos, token: token});
}
}
});

View file

@ -60,41 +60,47 @@ module.exports.addEditorMenuOptions = function addEditorMenuOptions (editor) {
var modelist = require('../modelist'); var modelist = require('../modelist');
var themelist = require('../themelist'); var themelist = require('../themelist');
editor.menuOptions = { editor.menuOptions = {
"setNewLineMode" : [{ setNewLineMode: [{
"textContent" : "unix", textContent: "unix",
"value" : "unix" value: "unix"
}, { }, {
"textContent" : "windows", textContent: "windows",
"value" : "windows" value: "windows"
}, { }, {
"textContent" : "auto", textContent: "auto",
"value" : "auto" value: "auto"
}], }],
"setTheme" : [], setTheme: [],
"setMode" : [], setMode: [],
"setKeyboardHandler": [{ setKeyboardHandler: [{
"textContent" : "ace", textContent: "ace",
"value" : "" value: ""
}, { }, {
"textContent" : "vim", textContent: "vim",
"value" : "ace/keyboard/vim" value: "ace/keyboard/vim"
}, { }, {
"textContent" : "emacs", textContent: "emacs",
"value" : "ace/keyboard/emacs" value: "ace/keyboard/emacs"
}, {
textContent: "textarea",
value: "ace/keyboard/textarea"
}, {
textContent: "sublime",
value: "ace/keyboard/sublime"
}] }]
}; };
editor.menuOptions.setTheme = themelist.themes.map(function(theme) { editor.menuOptions.setTheme = themelist.themes.map(function(theme) {
return { return {
'textContent' : theme.caption, textContent: theme.caption,
'value' : theme.theme value: theme.theme
}; };
}); });
editor.menuOptions.setMode = modelist.modes.map(function(mode) { editor.menuOptions.setMode = modelist.modes.map(function(mode) {
return { return {
'textContent' : mode.name, textContent: mode.name,
'value' : mode.mode value: mode.mode
}; };
}); });
}; };

View file

@ -53,7 +53,7 @@ var supportedModes = {
C9Search: ["c9search_results"], C9Search: ["c9search_results"],
C_Cpp: ["cpp|c|cc|cxx|h|hh|hpp"], C_Cpp: ["cpp|c|cc|cxx|h|hh|hpp"],
Cirru: ["cirru|cr"], Cirru: ["cirru|cr"],
Clojure: ["clj"], Clojure: ["clj|cljs"],
Cobol: ["CBL|COB"], Cobol: ["CBL|COB"],
coffee: ["coffee|cf|cson|^Cakefile"], coffee: ["coffee|cf|cson|^Cakefile"],
ColdFusion: ["cfm"], ColdFusion: ["cfm"],
@ -63,6 +63,7 @@ var supportedModes = {
D: ["d|di"], D: ["d|di"],
Dart: ["dart"], Dart: ["dart"],
Diff: ["diff|patch"], Diff: ["diff|patch"],
Dockerfile: ["^Dockerfile"],
Dot: ["dot"], Dot: ["dot"],
Erlang: ["erl|hrl"], Erlang: ["erl|hrl"],
EJS: ["ejs"], EJS: ["ejs"],
@ -142,6 +143,7 @@ var supportedModes = {
Toml: ["toml"], Toml: ["toml"],
Twig: ["twig"], Twig: ["twig"],
Typescript: ["ts|typescript|str"], Typescript: ["ts|typescript|str"],
Vala: ["vala"],
VBScript: ["vbs"], VBScript: ["vbs"],
Velocity: ["vm"], Velocity: ["vm"],
Verilog: ["v|vh|sv|svh"], Verilog: ["v|vh|sv|svh"],

View file

@ -103,6 +103,12 @@ patch(
}" }"
); );
patch(
require("../mode/text").Mode.prototype, "getTokenizer",
/Tokenizer/,
"TokenizerModule.Tokenizer"
);
useragent.isOldIE = true; useragent.isOldIE = true;
}); });

View file

@ -100,7 +100,7 @@ var highlight = function(el, opts, callback) {
*/ */
highlight.render = function(input, mode, theme, lineStart, disableGutter, callback) { highlight.render = function(input, mode, theme, lineStart, disableGutter, callback) {
var waiting = 0; var waiting = 1;
var modeCache = EditSession.prototype.$modes; var modeCache = EditSession.prototype.$modes;
// if either the theme or the mode were specified as objects // if either the theme or the mode were specified as objects
@ -127,7 +127,7 @@ highlight.render = function(input, mode, theme, lineStart, disableGutter, callba
var result = highlight.renderSync(input, mode, theme, lineStart, disableGutter); var result = highlight.renderSync(input, mode, theme, lineStart, disableGutter);
return callback ? callback(result) : result; return callback ? callback(result) : result;
} }
return waiting || done(); return --waiting || done();
}; };
/* /*

View file

@ -155,7 +155,7 @@ function setupContainer(element, getValue) {
return container; return container;
} }
exports.transformTextarea = function(element, loader) { exports.transformTextarea = function(element, options) {
var session; var session;
var container = setupContainer(element, function() { var container = setupContainer(element, function() {
return session.getValue(); return session.getValue();
@ -215,9 +215,8 @@ exports.transformTextarea = function(element, loader) {
applyStyles(settingDiv, settingDivStyles); applyStyles(settingDiv, settingDivStyles);
container.appendChild(settingDiv); container.appendChild(settingDiv);
options = options || exports.defaultOptions;
// Power up ace on the textarea: // Power up ace on the textarea:
var options = {};
var editor = ace.edit(editorDiv); var editor = ace.edit(editorDiv);
session = editor.getSession(); session = editor.getSession();
@ -228,10 +227,10 @@ exports.transformTextarea = function(element, loader) {
container.appendChild(settingOpener); container.appendChild(settingOpener);
// Create the API. // Create the API.
setupApi(editor, editorDiv, settingDiv, ace, options, loader); setupApi(editor, editorDiv, settingDiv, ace, options, load);
// Create the setting's panel. // Create the setting's panel.
setupSettingPanel(settingDiv, settingOpener, editor, options); setupSettingPanel(settingDiv, settingOpener, editor);
var state = ""; var state = "";
event.addListener(settingOpener, "mousemove", function(e) { event.addListener(settingOpener, "mousemove", function(e) {
@ -296,37 +295,15 @@ function setupApi(editor, editorDiv, settingDiv, ace, options, loader) {
}; };
editor.$setOption = editor.setOption; editor.$setOption = editor.setOption;
editor.$getOption = editor.getOption;
editor.setOption = function(key, value) { editor.setOption = function(key, value) {
if (options[key] == value) return;
switch (key) { switch (key) {
case "mode": case "mode":
if (value != "text") { editor.$setOption("mode", "ace/mode/" + value)
// Load the required mode file. Files get loaded only once.
loader("mode-" + value + ".js", "ace/mode/" + value, function() {
var aceMode = require("../mode/" + value).Mode;
session.setMode(new aceMode());
});
} else {
session.setMode(new (require("../mode/text").Mode));
}
break; break;
case "theme": case "theme":
if (value != "textmate") { editor.$setOption("theme", "ace/theme/" + value)
// Load the required theme file. Files get loaded only once.
loader("theme-" + value + ".js", "ace/theme/" + value, function() {
editor.setTheme("ace/theme/" + value);
});
} else {
editor.setTheme("ace/theme/textmate");
}
break; break;
case "fontSize":
editorDiv.style.fontSize = value;
break;
case "keybindings": case "keybindings":
switch (value) { switch (value) {
case "vim": case "vim":
@ -341,58 +318,55 @@ function setupApi(editor, editorDiv, settingDiv, ace, options, loader) {
break; break;
case "softWrap": case "softWrap":
switch (value) { case "fontSize":
case "off": editor.$setOption(key, value);
session.setUseWrapMode(false);
renderer.setPrintMarginColumn(80);
break;
case "40":
session.setUseWrapMode(true);
session.setWrapLimitRange(40, 40);
renderer.setPrintMarginColumn(40);
break;
case "80":
session.setUseWrapMode(true);
session.setWrapLimitRange(80, 80);
renderer.setPrintMarginColumn(80);
break;
case "free":
session.setUseWrapMode(true);
session.setWrapLimitRange(null, null);
renderer.setPrintMarginColumn(80);
break;
}
break; break;
default: default:
editor.$setOption(key, toBool(value)); editor.$setOption(key, toBool(value));
} }
options[key] = value;
}; };
editor.getOption = function(key) { editor.getOption = function(key) {
return options[key]; switch (key) {
case "mode":
return editor.$getOption("mode").substr("ace/mode/".length)
break;
case "theme":
return editor.$getOption("theme").substr("ace/theme/".length)
break;
case "keybindings":
var value = editor.getKeyboardHandler()
switch (value && value.$id) {
case "ace/keyboard/vim":
return "vim";
case "ace/keyboard/emacs":
return "emacs";
default:
return "ace";
}
break;
default:
return editor.$getOption(key);
}
}; };
editor.getOptions = function() { editor.setOptions(options);
return options;
};
editor.setOptions(exports.options);
return editor; return editor;
} }
function setupSettingPanel(settingDiv, settingOpener, editor, options) { function setupSettingPanel(settingDiv, settingOpener, editor) {
var BOOL = null; var BOOL = null;
var desc = { var desc = {
mode: "Mode:", mode: "Mode:",
gutter: "Display Gutter:", wrap: "Soft Wrap:",
theme: "Theme:", theme: "Theme:",
fontSize: "Font Size:", fontSize: "Font Size:",
softWrap: "Soft Wrap:", showGutter: "Display Gutter:",
keybindings: "Keyboard", keybindings: "Keyboard",
showPrintMargin: "Show Print Margin:", showPrintMargin: "Show Print Margin:",
useSoftTabs: "Use Soft Tabs:", useSoftTabs: "Use Soft Tabs:",
@ -445,7 +419,7 @@ function setupSettingPanel(settingDiv, settingOpener, editor, options) {
twilight: "Twilight", twilight: "Twilight",
vibrant_ink: "Vibrant Ink" vibrant_ink: "Vibrant Ink"
}, },
gutter: BOOL, showGutter: BOOL,
fontSize: { fontSize: {
"10px": "10px", "10px": "10px",
"11px": "11px", "11px": "11px",
@ -453,7 +427,7 @@ function setupSettingPanel(settingDiv, settingOpener, editor, options) {
"14px": "14px", "14px": "14px",
"16px": "16px" "16px": "16px"
}, },
softWrap: { wrap: {
off: "Off", off: "Off",
40: "40", 40: "40",
80: "80", 80: "80",
@ -476,7 +450,7 @@ function setupSettingPanel(settingDiv, settingOpener, editor, options) {
if (!obj) { if (!obj) {
builder.push( builder.push(
"<input type='checkbox' title='", option, "' ", "<input type='checkbox' title='", option, "' ",
cValue == "true" ? "checked='true'" : "", cValue + "" == "true" ? "checked='true'" : "",
"'></input>" "'></input>"
); );
return; return;
@ -496,10 +470,10 @@ function setupSettingPanel(settingDiv, settingOpener, editor, options) {
builder.push("</select>"); builder.push("</select>");
} }
for (var option in options) { for (var option in exports.defaultOptions) {
table.push("<tr><td>", desc[option], "</td>"); table.push("<tr><td>", desc[option], "</td>");
table.push("<td>"); table.push("<td>");
renderOption(table, option, optionValues[option], options[option]); renderOption(table, option, optionValues[option], editor.getOption(option));
table.push("</td></tr>"); table.push("</td></tr>");
} }
table.push("</table>"); table.push("</table>");
@ -532,12 +506,12 @@ function setupSettingPanel(settingDiv, settingOpener, editor, options) {
} }
// Default startup options. // Default startup options.
exports.options = { exports.defaultOptions = {
mode: "text", mode: "javascript",
theme: "textmate", theme: "textmate",
gutter: "false", wrap: "off",
fontSize: "12px", fontSize: "12px",
softWrap: "off", showGutter: "false",
keybindings: "ace", keybindings: "ace",
showPrintMargin: "false", showPrintMargin: "false",
useSoftTabs: "true", useSoftTabs: "true",

View file

@ -41,6 +41,7 @@
define(function(require, exports, module) { define(function(require, exports, module) {
"use strict"; "use strict";
require("ace/lib/fixoldbrowsers");
var themeData = [ var themeData = [
["Chrome" ], ["Chrome" ],

View file

@ -46,7 +46,6 @@ exports.$detectIndentation = function(lines, fallback) {
if (!/^\s*[^*+\-\s]/.test(line)) if (!/^\s*[^*+\-\s]/.test(line))
continue; continue;
var tabs = line.match(/^\t*/)[0].length;
if (line[0] == "\t") if (line[0] == "\t")
tabIndents++; tabIndents++;
@ -65,9 +64,6 @@ exports.$detectIndentation = function(lines, fallback) {
line = lines[i++]; line = lines[i++];
} }
if (!stats.length)
return;
function getScore(indent) { function getScore(indent) {
var score = 0; var score = 0;
for (var i = indent; i < stats.length; i += indent) for (var i = indent; i < stats.length; i += indent)
@ -82,13 +78,12 @@ exports.$detectIndentation = function(lines, fallback) {
for (var i = 1; i < 12; i++) { for (var i = 1; i < 12; i++) {
if (i == 1) { if (i == 1) {
spaceIndents = getScore(i); spaceIndents = getScore(i);
var score = 1; var score = stats.length && 1;
} else } else
var score = getScore(i) / spaceIndents; var score = getScore(i) / spaceIndents;
if (changes[i]) { if (changes[i])
score += changes[i] / changesTotal; score += changes[i] / changesTotal;
}
if (score > first.score) if (score > first.score)
first = {score: score, length: i}; first = {score: score, length: i};
@ -100,7 +95,7 @@ exports.$detectIndentation = function(lines, fallback) {
if (tabIndents > spaceIndents + 1) if (tabIndents > spaceIndents + 1)
return {ch: "\t", length: tabLength}; return {ch: "\t", length: tabLength};
if (spaceIndents + 1 > tabIndents) if (spaceIndents > tabIndents + 1)
return {ch: " ", length: tabLength}; return {ch: " ", length: tabLength};
}; };

View file

@ -0,0 +1,116 @@
if (typeof process !== "undefined") {
require("amd-loader");
require("../test/mockdom");
}
define(function(require, exports, module) {
"use strict";
var assert = require("assert");
var EditSession = require("../edit_session").EditSession;
var whitespace = require("./whitespace");
// Execution ORDER: test.setUpSuite, setUp, testFn, tearDown, test.tearDownSuite
module.exports = {
timeout: 10000,
"test tab detection": function(next) {
var s = new EditSession([
"define({",
"\tfoo:1,",
"\tbar:2,",
"\tbaz:{,",
"\t\tx:3",
"\t}",
"})"
]);
var indent = whitespace.$detectIndentation(s.doc.$lines);
assert.equal(indent.ch, "\t");
assert.equal(indent.length, undefined);
s.insert({row: 0, column: 0}, " ");
indent = whitespace.$detectIndentation(s.doc.$lines);
assert.equal(indent.ch, "\t");
assert.equal(indent.length, 4);
s.setValue("");
indent = whitespace.$detectIndentation(s.doc.$lines);
assert.ok(!indent);
next();
},
"test empty session": function(next) {
var s = new EditSession([
"define({",
"foo:1,",
"})"
]);
var indent = whitespace.$detectIndentation(s.doc.$lines);
assert.ok(!indent);
s.insert({row: 1, column: 0}, " x\n ");
indent = whitespace.$detectIndentation(s.doc.$lines);
assert.equal(indent.ch, " ");
assert.equal(indent.length, 4);
next();
},
"!test one line": function(next) {
var s = new EditSession([
"define({",
" foo:1,",
"})"
]);
var indent = whitespace.$detectIndentation(s.doc.$lines);
assert.equal(indent.ch, " ");
assert.equal(indent.length, 4);
next();
},
"test 1 width indents": function(next) {
var s = new EditSession([
"define({",
" foo:1,",
"})",
"define({",
" bar:1,",
"})",
" t",
" t",
" t",
" t",
" t",
" t",
" t",
" t"
]);
var indent = whitespace.$detectIndentation(s.doc.$lines);
// assert.equal(indent.ch, " ");
// assert.equal(indent.length, 4);
s = new EditSession([
"{",
" foo:1,",
" bar: {",
" baz:2",
" }",
"}"
]);
indent = whitespace.$detectIndentation(s.doc.$lines);
assert.equal(indent.ch, " ");
assert.equal(indent.length, 1);
next();
},
};
});
if (typeof module !== "undefined" && module === require.main) {
require("asyncjs").test.testcase(module.exports).exec();
}

View file

@ -36,7 +36,7 @@ var event = require("../lib/event");
var KeyBinding = function(editor) { var KeyBinding = function(editor) {
this.$editor = editor; this.$editor = editor;
this.$data = {}; this.$data = {editor: editor};
this.$handlers = []; this.$handlers = [];
this.setDefaultHandler(editor.commands); this.setDefaultHandler(editor.commands);
}; };
@ -46,7 +46,6 @@ var KeyBinding = function(editor) {
this.removeKeyboardHandler(this.$defaultHandler); this.removeKeyboardHandler(this.$defaultHandler);
this.$defaultHandler = kb; this.$defaultHandler = kb;
this.addKeyboardHandler(kb, 0); this.addKeyboardHandler(kb, 0);
this.$data = {editor: this.$editor};
}; };
this.setKeyboardHandler = function(kb) { this.setKeyboardHandler = function(kb) {

View file

@ -0,0 +1,82 @@
/* ***** BEGIN LICENSE BLOCK *****
* Distributed under the BSD license:
*
* Copyright (c) 2010, Ajax.org B.V.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Ajax.org B.V. nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* ***** END LICENSE BLOCK ***** */
define(function(require, exports, module) {
"use strict";
var HashHandler = require("./hash_handler").HashHandler;
exports.handler = new HashHandler();
[{
bindKey: "Shift-Tab|Tab",
command: "passKeysToBrowser"
}, {
bindKey: {win: "Ctrl-L", mac: "Cmd-L"},
command: "passKeysToBrowser"
}, {
bindKey: {win: "Ctrl-G", mac: "Cmd-G"},
command: "gotoline"
}, {
bindKey: {win: "Ctrl-T|Ctrl-Shift-T", mac: "Cmd-T|Cmd-Shift-T"},
command: "passKeysToBrowser"
}, {
bindKey: {win: "Ctrl-G", mac: "Cmd-G"},
command: "passKeysToBrowser"
}, {
bindKey: {win: "Ctrl-G", mac: "Cmd-G"},
command: "passKeysToBrowser"
}, {
name: "golineup",
bindKey: {win: null, mac: "Ctrl-P"},
}, {
name: "golinedown",
bindKey: {win: null, mac: "Ctrl-N"},
}, {
name: "gotoleft",
bindKey: {win: null, mac: "Ctrl-B"},
}, {
name: "gotoright",
bindKey: {win: null, mac: "Ctrl-F"},
}, {
name: "gotolineend",
bindKey: {win: null, mac: "Ctrl-E"},
}, {
name: "gotolinestart",
bindKey: {win: null, mac: "Ctrl-A"},
}
].forEach(function(k) {
var bindKey = k.bindKey;
if (typeof bindKey == "object")
bindKey = bindKey[exports.handler.platform];
exports.handler.bindKey(bindKey, k.command);
});
exports.handler.$id = "ace/keyboard/textarea";
});

View file

@ -36,6 +36,7 @@ var useragent = require("../lib/useragent");
var dom = require("../lib/dom"); var dom = require("../lib/dom");
var lang = require("../lib/lang"); var lang = require("../lib/lang");
var BROKEN_SETDATA = useragent.isChrome < 18; var BROKEN_SETDATA = useragent.isChrome < 18;
var USE_IE_MIME_TYPE = useragent.isIE;
var TextInput = function(parentNode, host) { var TextInput = function(parentNode, host) {
var text = dom.createElement("textarea"); var text = dom.createElement("textarea");
@ -54,7 +55,6 @@ var TextInput = function(parentNode, host) {
var PLACEHOLDER = "\x01\x01"; var PLACEHOLDER = "\x01\x01";
var cut = false;
var copied = false; var copied = false;
var pasted = false; var pasted = false;
var inComposition = false; var inComposition = false;
@ -186,9 +186,7 @@ var TextInput = function(parentNode, host) {
} }
var onSelect = function(e) { var onSelect = function(e) {
if (cut) { if (copied) {
cut = false;
} else if (copied) {
copied = false; copied = false;
} else if (isAllSelected(text)) { } else if (isAllSelected(text)) {
host.selectAll(); host.selectAll();
@ -244,54 +242,30 @@ var TextInput = function(parentNode, host) {
resetValue(); resetValue();
}; };
var onCut = function(e) { var handleClipboardData = function(e, data) {
var data = host.getCopyText();
if (!data) {
event.preventDefault(e);
return;
}
var clipboardData = e.clipboardData || window.clipboardData; var clipboardData = e.clipboardData || window.clipboardData;
if (!clipboardData || BROKEN_SETDATA)
if (clipboardData && !BROKEN_SETDATA) {
// Safari 5 has clipboardData object, but does not handle setData()
var supported = clipboardData.setData("Text", data);
if (supported) {
host.onCut();
event.preventDefault(e);
}
}
if (!supported) {
cut = true;
text.value = data;
text.select();
setTimeout(function(){
cut = false;
resetValue();
resetSelection();
host.onCut();
});
}
};
var onCopy = function(e) {
var data = host.getCopyText();
if (!data) {
event.preventDefault(e);
return; return;
// using "Text" doesn't work on old webkit but ie needs it
// TODO are there other browsers that require "Text"?
var mime = USE_IE_MIME_TYPE ? "Text" : "text/plain";
if (data) {
// Safari 5 has clipboardData object, but does not handle setData()
return clipboardData.setData(mime, data) !== false;
} else {
return clipboardData.getData(mime);
}
} }
var clipboardData = e.clipboardData || window.clipboardData; var doCopy = function(e, isCut) {
if (clipboardData && !BROKEN_SETDATA) { var data = host.getCopyText();
// Safari 5 has clipboardData object, but does not handle setData() if (!data)
var supported = clipboardData.setData("Text", data); return event.preventDefault(e);
if (supported) {
host.onCopy(); if (handleClipboardData(e, data)) {
isCut ? host.onCut() : host.onCopy();
event.preventDefault(e); event.preventDefault(e);
} } else {
}
if (!supported) {
copied = true; copied = true;
text.value = data; text.value = data;
text.select(); text.select();
@ -299,16 +273,22 @@ var TextInput = function(parentNode, host) {
copied = false; copied = false;
resetValue(); resetValue();
resetSelection(); resetSelection();
host.onCopy(); isCut ? host.onCut() : host.onCopy();
}); });
} }
}; };
var onPaste = function(e) { var onCut = function(e) {
var clipboardData = e.clipboardData || window.clipboardData; doCopy(e, true);
}
if (clipboardData) { var onCopy = function(e) {
var data = clipboardData.getData("Text"); doCopy(e, false);
}
var onPaste = function(e) {
var data = handleClipboardData(e);
if (typeof data == "string") {
if (data) if (data)
host.onPaste(data); host.onPaste(data);
if (useragent.isIE) if (useragent.isIE)

View file

@ -120,13 +120,14 @@ exports.handler = {
return null; return null;
var editor = data.editor; var editor = data.editor;
var vimState = data.vimState || "start";
if (hashId == 1) if (hashId == 1)
key = "ctrl-" + key; key = "ctrl-" + key;
if (key == "ctrl-c") { if (key == "ctrl-c") {
if (!useragent.isMac && editor.getCopyText()) { if (!useragent.isMac && editor.getCopyText()) {
editor.once("copy", function() { editor.once("copy", function() {
if (data.state == "start") if (vimState == "start")
coreCommands.stop.exec(editor); coreCommands.stop.exec(editor);
else else
editor.selection.clearSelection(); editor.selection.clearSelection();
@ -136,7 +137,7 @@ exports.handler = {
return {command: coreCommands.stop}; return {command: coreCommands.stop};
} else if ((key == "esc" && hashId === 0) || key == "ctrl-[") { } else if ((key == "esc" && hashId === 0) || key == "ctrl-[") {
return {command: coreCommands.stop}; return {command: coreCommands.stop};
} else if (data.state == "start") { } else if (vimState == "start") {
if (useragent.isMac && this.handleMacRepeat(data, hashId, key)) { if (useragent.isMac && this.handleMacRepeat(data, hashId, key)) {
hashId = -1; hashId = -1;
key = data.inputChar; key = data.inputChar;
@ -146,13 +147,16 @@ exports.handler = {
if (cmds.inputBuffer.idle && startCommands[key]) if (cmds.inputBuffer.idle && startCommands[key])
return startCommands[key]; return startCommands[key];
var isHandled = cmds.inputBuffer.push(editor, key); var isHandled = cmds.inputBuffer.push(editor, key);
if (!isHandled && hashId !== -1)
return;
return {command: "null", passEvent: !isHandled}; 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) { } else if (key == "esc" && hashId === 0) {
return {command: coreCommands.stop}; return {command: coreCommands.stop};
} }
// if no modifier || shift: wait for input.
else if (hashId === 0 || hashId == 4) {
return {command: "null", passEvent: true};
}
} else { } else {
if (key == "ctrl-w") { if (key == "ctrl-w") {
return {command: "removewordleft"}; return {command: "removewordleft"};

View file

@ -123,10 +123,12 @@ var actions = exports.actions = {
range.end.column++; range.end.column++;
var text = editor.session.getTextRange(range); var text = editor.session.getTextRange(range);
var toggled = text.toUpperCase(); var toggled = text.toUpperCase();
if (toggled == text) if (toggled != text)
editor.navigateRight();
else
editor.session.replace(range, toggled); editor.session.replace(range, toggled);
else if (text.toLowerCase() != text)
editor.session.replace(range, text.toLowerCase())
else
editor.navigateRight();
}, count || 1); }, count || 1);
} }
}, },
@ -164,6 +166,7 @@ var actions = exports.actions = {
fn: function(editor, range, count, param) { fn: function(editor, range, count, param) {
var options = editor.getLastSearchOptions(); var options = editor.getLastSearchOptions();
options.backwards = false; options.backwards = false;
options.start = null;
editor.selection.moveCursorRight(); editor.selection.moveCursorRight();
editor.selection.clearSelection(); editor.selection.clearSelection();
@ -180,6 +183,7 @@ var actions = exports.actions = {
fn: function(editor, range, count, param) { fn: function(editor, range, count, param) {
var options = editor.getLastSearchOptions(); var options = editor.getLastSearchOptions();
options.backwards = true; options.backwards = true;
options.start = null;
editor.findPrevious(options); editor.findPrevious(options);
ensureScrollMargin(editor); ensureScrollMargin(editor);
@ -340,6 +344,7 @@ var inputBuffer = exports.inputBuffer = {
currentCmd: null, currentCmd: null,
//currentMode: 0, //currentMode: 0,
currentCount: "", currentCount: "",
pendingCount: "",
status: "", status: "",
// Types // Types
@ -440,8 +445,9 @@ var inputBuffer = exports.inputBuffer = {
}, },
getCount: function() { getCount: function() {
var count = this.currentCount; var count = this.currentCount || this.pendingCount;
this.currentCount = ""; this.currentCount = "";
this.pendingCount = count;
return count && parseInt(count, 10); return count && parseInt(count, 10);
}, },
@ -497,7 +503,8 @@ var inputBuffer = exports.inputBuffer = {
else if (selectable) { else if (selectable) {
repeat(function() { repeat(function() {
run(motionObj.sel); 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); }, o.count || 1);
} }
this.reset(); this.reset();
@ -517,6 +524,7 @@ var inputBuffer = exports.inputBuffer = {
this.operator = null; this.operator = null;
this.motion = null; this.motion = null;
this.currentCount = ""; this.currentCount = "";
this.pendingCount = "";
this.status = ""; this.status = "";
this.accepting = [NUMBER, OPERATOR, MOTION, ACTION]; this.accepting = [NUMBER, OPERATOR, MOTION, ACTION];
this.idle = true; this.idle = true;

View file

@ -350,6 +350,10 @@ module.exports = {
case "W": case "W":
editor.selection.selectAWord(); editor.selection.selectAWord();
break; break;
case ")":
case "}":
case "]":
param = editor.session.$brackets[param];
case "(": case "(":
case "{": case "{":
case "[": case "[":
@ -383,6 +387,7 @@ module.exports = {
param: true, param: true,
handlesCount: true, handlesCount: true,
getPos: function(editor, range, count, param, isSel, isRepeat) { getPos: function(editor, range, count, param, isSel, isRepeat) {
if (param == "space") param = " ";
if (!isRepeat) if (!isRepeat)
LAST_SEARCH_MOTION = {ch: "f", param: param}; LAST_SEARCH_MOTION = {ch: "f", param: param};
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
@ -398,6 +403,7 @@ module.exports = {
param: true, param: true,
handlesCount: true, handlesCount: true,
getPos: function(editor, range, count, param, isSel, isRepeat) { getPos: function(editor, range, count, param, isSel, isRepeat) {
if (param == "space") param = " ";
if (!isRepeat) if (!isRepeat)
LAST_SEARCH_MOTION = {ch: "F", param: param}; LAST_SEARCH_MOTION = {ch: "F", param: param};
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
@ -413,6 +419,7 @@ module.exports = {
param: true, param: true,
handlesCount: true, handlesCount: true,
getPos: function(editor, range, count, param, isSel, isRepeat) { getPos: function(editor, range, count, param, isSel, isRepeat) {
if (param == "space") param = " ";
if (!isRepeat) if (!isRepeat)
LAST_SEARCH_MOTION = {ch: "t", param: param}; LAST_SEARCH_MOTION = {ch: "t", param: param};
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
@ -431,6 +438,7 @@ module.exports = {
param: true, param: true,
handlesCount: true, handlesCount: true,
getPos: function(editor, range, count, param, isSel, isRepeat) { getPos: function(editor, range, count, param, isSel, isRepeat) {
if (param == "space") param = " ";
if (!isRepeat) if (!isRepeat)
LAST_SEARCH_MOTION = {ch: "T", param: param}; LAST_SEARCH_MOTION = {ch: "T", param: param};
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
@ -656,7 +664,8 @@ module.exports = {
pos.column = line.length; pos.column = line.length;
return pos; return pos;
} }
} },
isLine: true
}) })
}; };

View file

@ -34,6 +34,7 @@ define(function(require, exports, module) {
var util = require("./util"); var util = require("./util");
var registers = require("../registers"); var registers = require("../registers");
var Range = require("../../../range").Range;
module.exports = { module.exports = {
"d": { "d": {
@ -90,10 +91,15 @@ module.exports = {
count = count || 1; count = count || 1;
switch (param) { switch (param) {
case "c": case "c":
for (var i = 0; i < count; i++) { editor.$blockScrolling++;
editor.removeLines(); editor.selection.$moveSelection(function() {
editor.selection.moveCursorBy(count - 1, 0);
});
var rows = editor.$getSelectedRows();
range = new Range(rows.first, 0, rows.last, Infinity);
editor.session.remove(range);
editor.$blockScrolling--;
util.insertMode(editor); util.insertMode(editor);
}
break; break;
default: default:
if (range) { if (range) {
@ -113,6 +119,8 @@ module.exports = {
}, },
fn: function(editor, range, count, param) { fn: function(editor, range, count, param) {
count = count || 1; count = count || 1;
if (param && param.isLine)
param = "y";
switch (param) { switch (param) {
case "y": case "y":
var pos = editor.getCursorPosition(); var pos = editor.getCursorPosition();

View file

@ -33,7 +33,7 @@ module.exports = {
editor.setOverwrite(false); editor.setOverwrite(false);
editor.keyBinding.$data.buffer = ""; editor.keyBinding.$data.buffer = "";
editor.keyBinding.$data.state = "insertMode"; editor.keyBinding.$data.vimState = "insertMode";
this.onVisualMode = false; this.onVisualMode = false;
this.onVisualLineMode = false; this.onVisualLineMode = false;
if(this.onInsertReplaySequence) { if(this.onInsertReplaySequence) {
@ -66,7 +66,7 @@ module.exports = {
editor.setOverwrite(true); editor.setOverwrite(true);
editor.keyBinding.$data.buffer = ""; editor.keyBinding.$data.buffer = "";
editor.keyBinding.$data.state = "start"; editor.keyBinding.$data.vimState = "start";
this.onVisualMode = false; this.onVisualMode = false;
this.onVisualLineMode = false; this.onVisualLineMode = false;
editor._emit("changeStatus"); editor._emit("changeStatus");

View file

@ -33,6 +33,7 @@ define(function(require, exports, module) {
var oop = require("../lib/oop"); var oop = require("../lib/oop");
var dom = require("../lib/dom"); var dom = require("../lib/dom");
var lang = require("../lib/lang"); var lang = require("../lib/lang");
var useragent = require("../lib/useragent");
var EventEmitter = require("../lib/event_emitter").EventEmitter; var EventEmitter = require("../lib/event_emitter").EventEmitter;
var CHAR_COUNT = 0; var CHAR_COUNT = 0;
@ -54,7 +55,7 @@ var FontMetrics = exports.FontMetrics = function(parentEl, interval) {
if (!CHAR_COUNT) if (!CHAR_COUNT)
this.$testFractionalRect(); this.$testFractionalRect();
this.$measureNode.textContent = lang.stringRepeat("X", CHAR_COUNT); this.$measureNode.innerHTML = lang.stringRepeat("X", CHAR_COUNT);
this.$characterSize = {width: 0, height: 0}; this.$characterSize = {width: 0, height: 0};
this.checkForSizeChanges(); this.checkForSizeChanges();
@ -85,7 +86,12 @@ var FontMetrics = exports.FontMetrics = function(parentEl, interval) {
style.visibility = "hidden"; style.visibility = "hidden";
style.position = "fixed"; style.position = "fixed";
style.whiteSpace = "pre"; style.whiteSpace = "pre";
if (useragent.isIE < 8) {
style["font-family"] = "inherit";
} else {
style.font = "inherit"; style.font = "inherit";
}
style.overflow = isRoot ? "hidden" : "visible"; style.overflow = isRoot ? "hidden" : "visible";
}; };
@ -121,11 +127,18 @@ var FontMetrics = exports.FontMetrics = function(parentEl, interval) {
}; };
this.$measureSizes = function() { this.$measureSizes = function() {
if (CHAR_COUNT === 1) {
var rect = this.$measureNode.getBoundingClientRect(); var rect = this.$measureNode.getBoundingClientRect();
var size = { var size = {
height: rect.height, height: rect.height,
width: rect.width / CHAR_COUNT width: rect.width
}; };
} else {
var size = {
height: this.$measureNode.clientHeight,
width: this.$measureNode.clientWidth / CHAR_COUNT
};
}
// Size and width can be null if the editor is not visible or // Size and width can be null if the editor is not visible or
// detached from the document // detached from the document
if (size.width === 0 || size.height === 0) if (size.width === 0 || size.height === 0)
@ -134,7 +147,7 @@ var FontMetrics = exports.FontMetrics = function(parentEl, interval) {
}; };
this.$measureCharWidth = function(ch) { this.$measureCharWidth = function(ch) {
this.$main.textContent = lang.stringRepeat(ch, CHAR_COUNT); this.$main.innerHTML = lang.stringRepeat(ch, CHAR_COUNT);
var rect = this.$main.getBoundingClientRect(); var rect = this.$main.getBoundingClientRect();
return rect.width / CHAR_COUNT; return rect.width / CHAR_COUNT;
}; };

View file

@ -85,7 +85,7 @@ exports.preventDefault = function(e) {
exports.getButton = function(e) { exports.getButton = function(e) {
if (e.type == "dblclick") if (e.type == "dblclick")
return 0; return 0;
if (e.type == "contextmenu" || (e.ctrlKey && useragent.isMac)) if (e.type == "contextmenu" || (useragent.isMac && (e.ctrlKey && !e.altKey && !e.shiftKey)))
return 2; return 2;
// DOM Event // DOM Event
@ -180,9 +180,12 @@ exports.addMultiMouseDownListener = function(el, timeouts, eventHandler, callbac
} }
if (useragent.isIE) { if (useragent.isIE) {
var isNewClick = Math.abs(e.clientX - startX) > 5 || Math.abs(e.clientY - startY) > 5; var isNewClick = Math.abs(e.clientX - startX) > 5 || Math.abs(e.clientY - startY) > 5;
if (isNewClick) { if (!timer || isNewClick)
clicks = 1; clicks = 1;
} if (timer)
clearTimeout(timer);
timer = setTimeout(function() {timer = null}, timeouts[clicks - 1] || 600);
if (clicks == 1) { if (clicks == 1) {
startX = e.clientX; startX = e.clientX;
startY = e.clientY; startY = e.clientY;
@ -277,6 +280,14 @@ function normalizeCommandKeys(callback, e, keyCode) {
} }
} }
if (useragent.isChromeOS && hashId & 8) {
callback(e, hashId, keyCode);
if (e.defaultPrevented)
return;
else
hashId &= ~8;
}
// If there is no hashId and the keyCode is not a function key, then // 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 // we don't call the callback as we don't handle a command key here
// (it's a normal key/character input). // (it's a normal key/character input).

View file

@ -103,7 +103,7 @@ var Keys = (function() {
80: 'p', 81: 'q', 82: 'r', 83: 's', 84: 't', 85: 'u', 86: 'v', 80: 'p', 81: 'q', 82: 'r', 83: 's', 84: 't', 85: 'u', 86: 'v',
87: 'w', 88: 'x', 89: 'y', 90: 'z', 107: '+', 109: '-', 110: '.', 87: 'w', 88: 'x', 89: 'y', 90: 'z', 107: '+', 109: '-', 110: '.',
187: '=', 188: ',', 189: '-', 190: '.', 191: '/', 192: '`', 219: '[', 187: '=', 188: ',', 189: '-', 190: '.', 191: '/', 192: '`', 219: '[',
220: '\\',221: ']', 222: '\'', 220: '\\',221: ']', 222: '\''
} }
}; };
@ -148,7 +148,11 @@ var Keys = (function() {
oop.mixin(exports, Keys); oop.mixin(exports, Keys);
exports.keyCodeToString = function(keyCode) { exports.keyCodeToString = function(keyCode) {
return (Keys[keyCode] || String.fromCharCode(keyCode)).toLowerCase(); // Language-switching keystroke in Chrome/Linux emits keyCode 0.
var keyString = Keys[keyCode];
if (typeof keyString != "string")
keyString = String.fromCharCode(keyCode);
return keyString.toLowerCase();
}; };
}); });

View file

@ -76,15 +76,16 @@ exports.isLinux = (os == "linux");
// Windows Store JavaScript apps (aka Metro apps written in HTML5 and JavaScript) do not use the "Microsoft Internet Explorer" string in their user agent, but "MSAppHost" instead. // Windows Store JavaScript apps (aka Metro apps written in HTML5 and JavaScript) do not use the "Microsoft Internet Explorer" string in their user agent, but "MSAppHost" instead.
exports.isIE = exports.isIE =
(navigator.appName == "Microsoft Internet Explorer" || navigator.appName.indexOf("MSAppHost") >= 0) (navigator.appName == "Microsoft Internet Explorer" || navigator.appName.indexOf("MSAppHost") >= 0)
&& parseFloat(navigator.userAgent.match(/(?:Trident\/[0-9]+[\.0-9]+;.*rv:|MSIE )([0-9]+[\.0-9]+)/)[1]); ? parseFloat((ua.match(/(?:MSIE |Trident\/[0-9]+[\.0-9]+;.*rv:)([0-9]+[\.0-9]+)/)||[])[1])
: parseFloat((ua.match(/(?:Trident\/[0-9]+[\.0-9]+;.*rv:)([0-9]+[\.0-9]+)/)||[])[1]); // for ie
exports.isOldIE = exports.isIE && exports.isIE < 9; exports.isOldIE = exports.isIE && exports.isIE < 9;
// Is this Firefox or related? // Is this Firefox or related?
exports.isGecko = exports.isMozilla = window.controllers && window.navigator.product === "Gecko"; exports.isGecko = exports.isMozilla = (window.Controllers || window.controllers) && window.navigator.product === "Gecko";
// oldGecko == rev < 2.0 // oldGecko == rev < 2.0
exports.isOldGecko = exports.isGecko && parseInt((navigator.userAgent.match(/rv\:(\d+)/)||[])[1], 10) < 4; exports.isOldGecko = exports.isGecko && parseInt((ua.match(/rv\:(\d+)/)||[])[1], 10) < 4;
// Is this Opera // Is this Opera
exports.isOpera = window.opera && Object.prototype.toString.call(window.opera) == "[object Opera]"; exports.isOpera = window.opera && Object.prototype.toString.call(window.opera) == "[object Opera]";
@ -100,4 +101,6 @@ exports.isIPad = ua.indexOf("iPad") >= 0;
exports.isTouchPad = ua.indexOf("TouchPad") >= 0; exports.isTouchPad = ua.indexOf("TouchPad") >= 0;
exports.isChromeOS = ua.indexOf(" CrOS ") >= 0;
}); });

View file

@ -87,7 +87,6 @@ function LineWidgets(session) {
editor.widgetManager = this; editor.widgetManager = this;
editor.setOption("enableLineWidgets", true);
editor.renderer.on("beforeRender", this.measureWidgets); editor.renderer.on("beforeRender", this.measureWidgets);
editor.renderer.on("afterRender", this.renderWidgets); editor.renderer.on("afterRender", this.renderWidgets);
}; };

View file

@ -1,5 +1,7 @@
<html> <html>
<script a='a'>var</script>'123' <scripts>
<script a='a'>var "</scripts></script>'123'
</scripts>
<a href="abc <a href="abc
def"> def">
<a href='abc <a href='abc

View file

@ -330,7 +330,7 @@
["text",";"] ["text",";"]
],[ ],[
"start", "start",
["identifier","assert"], ["keyword.control.dart","assert"],
["text","("], ["text","("],
["identifier","unicorn"], ["identifier","unicorn"],
["text"," "], ["text"," "],
@ -357,7 +357,7 @@
["text",";"] ["text",";"]
],[ ],[
"start", "start",
["identifier","assert"], ["keyword.control.dart","assert"],
["text","("], ["text","("],
["identifier","iMeantToDoThis"], ["identifier","iMeantToDoThis"],
["text","."], ["text","."],

View file

@ -4,393 +4,257 @@
["variable"," --git"], ["variable"," --git"],
["keyword"," a/lib/ace/edit_session.js"], ["keyword"," a/lib/ace/edit_session.js"],
["variable"," b/lib/ace/edit_session.js"] ["variable"," b/lib/ace/edit_session.js"]
],[
"start"
],[ ],[
"start", "start",
["variable","index 23fc3fc..ed3b273 100644"] ["variable","index 23fc3fc..ed3b273 100644"]
],[
"start"
],[ ],[
"start", "start",
["constant.numeric","---"], ["constant.numeric","---"],
["meta.tag"," a/lib/ace/edit_session.js"] ["meta.tag"," a/lib/ace/edit_session.js"]
],[
"start"
],[ ],[
"start", "start",
["constant.numeric","+++"], ["constant.numeric","+++"],
["meta.tag"," b/lib/ace/edit_session.js"] ["meta.tag"," b/lib/ace/edit_session.js"]
],[
"start"
],[ ],[
"start", "start",
["constant","@@"], ["constant","@@"],
["constant.numeric"," -51,6 +51,7 "], ["constant.numeric"," -51,6 +51,7 "],
["constant","@@"], ["constant","@@"],
["comment.doc.tag"," var TextMode = require(\"./mode/text\").Mode;"] ["comment.doc.tag"," var TextMode = require(\"./mode/text\").Mode;"]
],[
"start"
],[ ],[
"start", "start",
["invisible"," var Range = require(\"./range\").Range;"] ["invisible"," var Range = require(\"./range\").Range;"]
],[
"start"
],[ ],[
"start", "start",
["invisible"," var Document = require(\"./document\").Document;"] ["invisible"," var Document = require(\"./document\").Document;"]
],[
"start"
],[ ],[
"start", "start",
["invisible"," var BackgroundTokenizer = require(\"./background_tokenizer\").BackgroundTokenizer;"] ["invisible"," var BackgroundTokenizer = require(\"./background_tokenizer\").BackgroundTokenizer;"]
],[
"start"
],[ ],[
"start", "start",
["support.constant","+"], ["support.constant","+"],
["text","var SearchHighlight = require(\"./search_highlight\").SearchHighlight;"] ["text","var SearchHighlight = require(\"./search_highlight\").SearchHighlight;"]
],[
"start"
],[ ],[
"start", "start",
["text"," "] ["text"," "]
],[
"start"
],[ ],[
"start", "start",
["invisible"," /**"] ["invisible"," /**"]
],[
"start"
],[ ],[
"start", "start",
["invisible"," * class EditSession"] ["invisible"," * class EditSession"]
],[
"start"
],[ ],[
"start", "start",
["constant","@@"], ["constant","@@"],
["constant.numeric"," -307,6 +308,13 "], ["constant.numeric"," -307,6 +308,13 "],
["constant","@@"], ["constant","@@"],
["comment.doc.tag"," var EditSession = function(text, mode) {"] ["comment.doc.tag"," var EditSession = function(text, mode) {"]
],[
"start"
],[ ],[
"start", "start",
["invisible"," return token;"] ["invisible"," return token;"]
],[
"start"
],[ ],[
"start", "start",
["invisible"," };"] ["invisible"," };"]
],[
"start"
],[ ],[
"start", "start",
["text"," "] ["text"," "]
],[
"start"
],[ ],[
"start", "start",
["support.constant","+"], ["support.constant","+"],
["text"," this.highlight = function(re) {"] ["text"," this.highlight = function(re) {"]
],[
"start"
],[ ],[
"start", "start",
["support.constant","+"], ["support.constant","+"],
["text"," if (!this.$searchHighlight) {"] ["text"," if (!this.$searchHighlight) {"]
],[
"start"
],[ ],[
"start", "start",
["support.constant","+"], ["support.constant","+"],
["text"," var highlight = new SearchHighlight(null, \"ace_selected-word\", \"text\");"] ["text"," var highlight = new SearchHighlight(null, \"ace_selected-word\", \"text\");"]
],[
"start"
],[ ],[
"start", "start",
["support.constant","+"], ["support.constant","+"],
["text"," this.$searchHighlight = this.addDynamicMarker(highlight);"] ["text"," this.$searchHighlight = this.addDynamicMarker(highlight);"]
],[
"start"
],[ ],[
"start", "start",
["support.constant","+"], ["support.constant","+"],
["text"," }"] ["text"," }"]
],[
"start"
],[ ],[
"start", "start",
["support.constant","+"], ["support.constant","+"],
["text"," this.$searchHighlight.setRegexp(re);"] ["text"," this.$searchHighlight.setRegexp(re);"]
],[
"start"
],[ ],[
"start", "start",
["support.constant","+"], ["support.constant","+"],
["text"," }"] ["text"," }"]
],[
"start"
],[ ],[
"start", "start",
["invisible"," /**"] ["invisible"," /**"]
],[
"start"
],[ ],[
"start", "start",
["invisible"," * EditSession.setUndoManager(undoManager)"] ["invisible"," * EditSession.setUndoManager(undoManager)"]
],[
"start"
],[ ],[
"start", "start",
["invisible"," * - undoManager (UndoManager): The new undo manager"] ["invisible"," * - undoManager (UndoManager): The new undo manager"]
],[
"start"
],[ ],[
"start", "start",
["constant","@@"], ["constant","@@"],
["constant.numeric"," -556,7 +564,8 "], ["constant.numeric"," -556,7 +564,8 "],
["constant","@@"], ["constant","@@"],
["comment.doc.tag"," var EditSession = function(text, mode) {"] ["comment.doc.tag"," var EditSession = function(text, mode) {"]
],[
"start"
],[ ],[
"start", "start",
["invisible"," type : type || \"line\","] ["invisible"," type : type || \"line\","]
],[
"start"
],[ ],[
"start", "start",
["invisible"," renderer: typeof type == \"function\" ? type : null,"] ["invisible"," renderer: typeof type == \"function\" ? type : null,"]
],[
"start"
],[ ],[
"start", "start",
["invisible"," clazz : clazz,"] ["invisible"," clazz : clazz,"]
],[
"start"
],[ ],[
"start", "start",
["support.function","-"], ["support.function","-"],
["string"," inFront: !!inFront"] ["string"," inFront: !!inFront"]
],[
"start"
],[ ],[
"start", "start",
["support.constant","+"], ["support.constant","+"],
["text"," inFront: !!inFront,"] ["text"," inFront: !!inFront,"]
],[
"start"
],[ ],[
"start", "start",
["support.constant","+"], ["support.constant","+"],
["text"," id: id"] ["text"," id: id"]
],[
"start"
],[ ],[
"start", "start",
["invisible"," }"] ["invisible"," }"]
],[
"start"
],[ ],[
"start", "start",
["text"," "] ["text"," "]
],[
"start"
],[ ],[
"start", "start",
["invisible"," if (inFront) {"] ["invisible"," if (inFront) {"]
],[
"start"
],[ ],[
"start", "start",
["variable","diff"], ["variable","diff"],
["variable"," --git"], ["variable"," --git"],
["keyword"," a/lib/ace/editor.js"], ["keyword"," a/lib/ace/editor.js"],
["variable"," b/lib/ace/editor.js"] ["variable"," b/lib/ace/editor.js"]
],[
"start"
],[ ],[
"start", "start",
["variable","index 834e603..b27ec73 100644"] ["variable","index 834e603..b27ec73 100644"]
],[
"start"
],[ ],[
"start", "start",
["constant.numeric","---"], ["constant.numeric","---"],
["meta.tag"," a/lib/ace/editor.js"] ["meta.tag"," a/lib/ace/editor.js"]
],[
"start"
],[ ],[
"start", "start",
["constant.numeric","+++"], ["constant.numeric","+++"],
["meta.tag"," b/lib/ace/editor.js"] ["meta.tag"," b/lib/ace/editor.js"]
],[
"start"
],[ ],[
"start", "start",
["constant","@@"], ["constant","@@"],
["constant.numeric"," -494,7 +494,7 "], ["constant.numeric"," -494,7 +494,7 "],
["constant","@@"], ["constant","@@"],
["comment.doc.tag"," var Editor = function(renderer, session) {"] ["comment.doc.tag"," var Editor = function(renderer, session) {"]
],[
"start"
],[ ],[
"start", "start",
["invisible"," * Emitted when a selection has changed."] ["invisible"," * Emitted when a selection has changed."]
],[
"start"
],[ ],[
"start", "start",
["invisible"," **/"] ["invisible"," **/"]
],[
"start"
],[ ],[
"start", "start",
["invisible"," this.onSelectionChange = function(e) {"] ["invisible"," this.onSelectionChange = function(e) {"]
],[
"start"
],[ ],[
"start", "start",
["support.function","-"], ["support.function","-"],
["string"," var session = this.getSession();"] ["string"," var session = this.getSession();"]
],[
"start"
],[ ],[
"start", "start",
["support.constant","+"], ["support.constant","+"],
["text"," var session = this.session;"] ["text"," var session = this.session;"]
],[
"start"
],[ ],[
"start", "start",
["text"," "] ["text"," "]
],[
"start"
],[ ],[
"start", "start",
["invisible"," if (session.$selectionMarker) {"] ["invisible"," if (session.$selectionMarker) {"]
],[
"start"
],[ ],[
"start", "start",
["invisible"," session.removeMarker(session.$selectionMarker);"] ["invisible"," session.removeMarker(session.$selectionMarker);"]
],[
"start"
],[ ],[
"start", "start",
["constant","@@"], ["constant","@@"],
["constant.numeric"," -509,12 +509,40 "], ["constant.numeric"," -509,12 +509,40 "],
["constant","@@"], ["constant","@@"],
["comment.doc.tag"," var Editor = function(renderer, session) {"] ["comment.doc.tag"," var Editor = function(renderer, session) {"]
],[
"start"
],[ ],[
"start", "start",
["invisible"," this.$updateHighlightActiveLine();"] ["invisible"," this.$updateHighlightActiveLine();"]
],[
"start"
],[ ],[
"start", "start",
["invisible"," }"] ["invisible"," }"]
],[
"start"
],[ ],[
"start", "start",
["text"," "] ["text"," "]
],[
"start"
],[ ],[
"start", "start",
["support.function","-"], ["support.function","-"],
["string"," var self = this;"] ["string"," var self = this;"]
],[
"start"
],[ ],[
"start", "start",
["support.function","-"], ["support.function","-"],
["string"," if (this.$highlightSelectedWord && !this.$wordHighlightTimer)"] ["string"," if (this.$highlightSelectedWord && !this.$wordHighlightTimer)"]
],[
"start"
],[ ],[
"start", "start",
["support.function","-"], ["support.function","-"],
["string"," this.$wordHighlightTimer = setTimeout(function() {"] ["string"," this.$wordHighlightTimer = setTimeout(function() {"]
],[
"start"
],[ ],[
"start", "start",
["support.function","-"], ["support.function","-"],
["string"," self.session.$mode.highlightSelection(self);"] ["string"," self.session.$mode.highlightSelection(self);"]
],[
"start"
],[ ],[
"start", "start",
["support.function","-"], ["support.function","-"],
["string"," self.$wordHighlightTimer = null;"] ["string"," self.$wordHighlightTimer = null;"]
],[
"start"
],[ ],[
"start", "start",
["support.function","-"], ["support.function","-"],
["string"," }, 30, this);"] ["string"," }, 30, this);"]
],[
"start"
],[ ],[
"start", "start",
["support.constant","+"], ["support.constant","+"],
["text"," var re = this.$highlightSelectedWord && this.$getSelectionHighLightRegexp()"] ["text"," var re = this.$highlightSelectedWord && this.$getSelectionHighLightRegexp()"]
],[
"start"
],[ ],[
"start", "start",
["invisible"," };"] ["invisible"," };"]
],[
"start"
],[ ],[
"start", "start",
["variable","diff"], ["variable","diff"],
["variable"," --git"], ["variable"," --git"],
["keyword"," a/lib/ace/search_highlight.js"], ["keyword"," a/lib/ace/search_highlight.js"],
["variable"," b/lib/ace/search_highlight.js"] ["variable"," b/lib/ace/search_highlight.js"]
],[
"start"
],[ ],[
"start", "start",
["invisible","new file mode 100644"] ["invisible","new file mode 100644"]
],[
"start"
],[ ],[
"start", "start",
["variable","index 0000000..b2df779"] ["variable","index 0000000..b2df779"]
],[
"start"
],[ ],[
"start", "start",
["constant.numeric","---"], ["constant.numeric","---"],
["meta.tag"," /dev/null"] ["meta.tag"," /dev/null"]
],[
"start"
],[ ],[
"start", "start",
["constant.numeric","+++"], ["constant.numeric","+++"],
["meta.tag"," b/lib/ace/search_highlight.js"] ["meta.tag"," b/lib/ace/search_highlight.js"]
],[
"start"
],[ ],[
"start", "start",
["constant","@@"], ["constant","@@"],
["constant.numeric"," -0,0 +1,3 "], ["constant.numeric"," -0,0 +1,3 "],
["constant","@@"] ["constant","@@"]
],[
"start"
],[ ],[
"start", "start",
["support.constant","+"], ["support.constant","+"],
["text","new"] ["text","new"]
],[
"start"
],[ ],[
"start", "start",
["support.constant","+"], ["support.constant","+"],

View file

@ -0,0 +1,142 @@
[[
"start",
["comment","@these"],
["text"," "],
["comment","@are"],
["text"," "],
["comment","@tags"]
],[
"start",
["keyword","Feature:"],
["text"," Serve coffee"]
],[
"start",
["text"," Coffee should not be served until paid for"]
],[
"start",
["text"," Coffee should not be served until the button has been pressed"]
],[
"start",
["text"," If there is no coffee left then money should be refunded"]
],[
"start",
["text"," "]
],[
"start",
["text"," "],
["keyword","Scenario Outline:"],
["text"," Eating"]
],[
"start",
["text"," "],
["keyword","Given"],
["text"," there are "],
["comment","<start>"],
["text"," cucumbers"]
],[
"start",
["text"," "],
["keyword","When"],
["text"," I eat "],
["comment","<eat>"],
["text"," cucumbers"]
],[
"start",
["text"," "],
["keyword","Then"],
["text"," I should have "],
["comment","<left>"],
["text"," cucumbers"]
],[
"start"
],[
"start",
["text"," "],
["keyword","Examples:"]
],[
"start",
["text"," "],
["comment","| "],
["string","start "],
["comment","| "],
["string","eat "],
["comment","| "],
["string","left "],
["comment","|"]
],[
"start",
["text"," "],
["comment","| "],
["string"," 12 "],
["comment","| "],
["string"," 5 "],
["comment","| "],
["string"," 7 "],
["comment","|"]
],[
"start",
["text"," "],
["comment","| "],
["string"," 20 "],
["comment","| "],
["string"," 5 "],
["comment","| "],
["string"," 15 "],
["comment","| "],
["string"," "]
],[
"start"
],[
"start",
["text"," "],
["keyword","Scenario:"],
["text"," Buy last coffee"]
],[
"start",
["text"," "],
["keyword","Given"],
["text"," there are "],
["constant.numeric","1"],
["text"," coffees left in the machine"]
],[
"start",
["text"," "],
["keyword","And"],
["text"," I have deposited "],
["constant.numeric","1"],
["text","$ "]
],[
"start",
["text"," "],
["keyword","When"],
["text"," I press the coffee button"]
],[
"start",
["text"," "],
["keyword","Then"],
["text"," I should be served a "],
["string","\"coffee\""]
],[
"start",
["text"," "]
],[
"start",
["text"," "],
["comment","# this a comment"]
],[
"start",
["text"," "]
],[
"qqstring3",
["text"," "],
["string","\"\"\""]
],[
"qqstring3",
["string"," this is a "]
],[
"qqstring3",
["string"," pystring"]
],[
"start",
["string"," \"\"\""]
]]

View file

@ -3,6 +3,11 @@
["meta.tag.punctuation.tag-open.xml","<"], ["meta.tag.punctuation.tag-open.xml","<"],
["meta.tag.tag-name.xml","html"], ["meta.tag.tag-name.xml","html"],
["meta.tag.punctuation.tag-close.xml",">"] ["meta.tag.punctuation.tag-close.xml",">"]
],[
"start",
["meta.tag.punctuation.tag-open.xml","<"],
["meta.tag.tag-name.xml","scripts"],
["meta.tag.punctuation.tag-close.xml",">"]
],[ ],[
"start", "start",
["meta.tag.punctuation.tag-open.xml","<"], ["meta.tag.punctuation.tag-open.xml","<"],
@ -13,10 +18,17 @@
["string.attribute-value.xml","'a'"], ["string.attribute-value.xml","'a'"],
["meta.tag.punctuation.tag-close.xml",">"], ["meta.tag.punctuation.tag-close.xml",">"],
["storage.type","var"], ["storage.type","var"],
["text"," "],
["string","\"</scripts>"],
["meta.tag.punctuation.end-tag-open.xml","</"], ["meta.tag.punctuation.end-tag-open.xml","</"],
["meta.tag.script.tag-name.xml","script"], ["meta.tag.script.tag-name.xml","script"],
["meta.tag.punctuation.tag-close.xml",">"], ["meta.tag.punctuation.tag-close.xml",">"],
["text.xml","'123'"] ["text.xml","'123'"]
],[
"start",
["meta.tag.punctuation.end-tag-open.xml","</"],
["meta.tag.tag-name.xml","scripts"],
["meta.tag.punctuation.tag-close.xml",">"]
],[ ],[
["string.attribute-value.xml0","tag_stuff"], ["string.attribute-value.xml0","tag_stuff"],
["meta.tag.punctuation.tag-open.xml","<"], ["meta.tag.punctuation.tag-open.xml","<"],

View file

@ -0,0 +1,23 @@
[[
"start",
["punctuation.definition.entity.ini","["],
["constant.section.group-title.ini",".ShellClassInfo"],
["punctuation.definition.entity.ini","]"]
],[
"start",
["keyword.other.definition.ini","IconResource"],
["punctuation.separator.key-value.ini","="],
["text","..\\logo.png"]
],[
"start",
["punctuation.definition.entity.ini","["],
["constant.section.group-title.ini","ViewState"],
["punctuation.definition.entity.ini","]"]
],[
"start",
["keyword.other.definition.ini","FolderType"],
["punctuation.separator.key-value.ini","="],
["text","Generic"]
],[
"start"
]]

View file

@ -38,7 +38,13 @@
],[ ],[
"start" "start"
],[ ],[
"start" "start",
["text","v "],
["keyword.operator.update.julia","="],
["text"," "],
["variable","α"],
["keyword.operator.transposed-variable.julia","'"],
["text",";"]
],[ ],[
"start", "start",
["keyword.other.julia","function"], ["keyword.other.julia","function"],

View file

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

View file

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

View file

@ -297,10 +297,10 @@
["comment.doc","* Dollar quotes starting at the end of the line are colored as SQL unless"] ["comment.doc","* Dollar quotes starting at the end of the line are colored as SQL unless"]
],[ ],[
"doc-start", "doc-start",
["comment.doc","* a special language tag is used. Pearl and Python are currently implemented"] ["comment.doc","* a special language tag is used. Dollar quote syntax coloring is implemented"]
],[ ],[
"doc-start", "doc-start",
["comment.doc","* but lots of others are possible."] ["comment.doc","* for Perl, Python, JavaScript, and Json."]
],[ ],[
"start", "start",
["comment.doc","*/"] ["comment.doc","*/"]
@ -662,6 +662,160 @@
["statementEnd",";"] ["statementEnd",";"]
],[ ],[
"start" "start"
],[
"start",
["comment","-- pl/v8 (javascript)"]
],[
"javascript-start",
["keyword.statementBegin","CREATE"],
["text"," "],
["keyword","FUNCTION"],
["text"," "],
["identifier","plv8_test"],
["paren.lparen","("],
["identifier","keys"],
["text"," "],
["keyword","text"],
["text","[], "],
["identifier","vals"],
["text"," "],
["keyword","text"],
["text","[]"],
["paren.rparen",")"],
["text"," "],
["keyword","RETURNS"],
["text"," "],
["keyword","text"],
["text"," "],
["keyword","AS"],
["text"," "],
["string","$javascript$"]
],[
"javascript-start",
["storage.type","var"],
["text"," "],
["identifier","o"],
["text"," "],
["keyword.operator","="],
["text"," "],
["paren.lparen","{"],
["paren.rparen","}"],
["punctuation.operator",";"]
],[
"javascript-start",
["keyword","for"],
["paren.lparen","("],
["storage.type","var"],
["text"," "],
["identifier","i"],
["keyword.operator","="],
["constant.numeric","0"],
["punctuation.operator",";"],
["text"," "],
["identifier","i"],
["keyword.operator","<"],
["identifier","keys"],
["punctuation.operator","."],
["support.constant","length"],
["punctuation.operator",";"],
["text"," "],
["identifier","i"],
["keyword.operator","++"],
["paren.rparen",")"],
["paren.lparen","{"]
],[
"javascript-start",
["text"," "],
["identifier","o"],
["paren.lparen","["],
["identifier","keys"],
["paren.lparen","["],
["identifier","i"],
["paren.rparen","]]"],
["text"," "],
["keyword.operator","="],
["text"," "],
["identifier","vals"],
["paren.lparen","["],
["identifier","i"],
["paren.rparen","]"],
["punctuation.operator",";"]
],[
"javascript-no_regex",
["paren.rparen","}"]
],[
"javascript-start",
["keyword","return"],
["text"," "],
["variable.language","JSON"],
["punctuation.operator","."],
["identifier","stringify"],
["paren.lparen","("],
["identifier","o"],
["paren.rparen",")"],
["punctuation.operator",";"]
],[
"start",
["string","$javascript$"],
["text"," "],
["keyword","LANGUAGE"],
["text"," "],
["identifier","plv8"],
["text"," "],
["keyword","IMMUTABLE"],
["text"," "],
["keyword","STRICT"],
["statementEnd",";"]
],[
"start"
],[
"start",
["comment","-- json"]
],[
"json-start",
["keyword.statementBegin","select"],
["text"," "],
["keyword.operator","*"],
["text"," "],
["keyword","from"],
["text"," "],
["support.function","json_object_keys"],
["paren.lparen","("],
["string","$json$"]
],[
"json-start",
["paren.lparen","{"]
],[
"json-start",
["text"," "],
["variable","\"f1\""],
["text",": "],
["constant.numeric","5"],
["text",","]
],[
"json-start",
["text"," "],
["variable","\"f2\""],
["text",": "],
["string","\"test\""],
["text",","]
],[
"json-start",
["text"," "],
["variable","\"f3\""],
["text",": "],
["paren.lparen","{"],
["paren.rparen","}"]
],[
"json-start",
["paren.rparen","}"]
],[
"start",
["string","$json$"],
["paren.rparen",")"],
["statementEnd",";"]
],[
"start"
],[ ],[
"start" "start"
],[ ],[

View file

@ -0,0 +1,98 @@
[[
"start",
["punctuation.section.embedded.begin.smarty","{"],
["keyword.control.smarty","foreach"],
["source.smarty"," "],
["punctuation.definition.variable.smarty","$"],
["variable.other.smarty","foo"],
["source.smarty"," as "],
["punctuation.definition.variable.smarty","$"],
["variable.other.smarty","bar"],
["punctuation.section.embedded.end.smarty","}"]
],[
"start",
["text.xml"," "],
["meta.tag.punctuation.tag-open.xml","<"],
["meta.tag.anchor.tag-name.xml","a"],
["text.tag-whitespace.xml"," "],
["entity.other.attribute-name.xml","href"],
["keyword.operator.attribute-equals.xml","="],
["string.attribute-value.xml","\""],
["punctuation.section.embedded.begin.smarty","{"],
["punctuation.definition.variable.smarty","$"],
["variable.other.smarty","bar"],
["source.smarty",".zig"],
["punctuation.section.embedded.end.smarty","}"],
["string.attribute-value.xml","\""],
["meta.tag.punctuation.tag-close.xml",">"],
["punctuation.section.embedded.begin.smarty","{"],
["punctuation.definition.variable.smarty","$"],
["variable.other.smarty","bar"],
["source.smarty",".zag"],
["punctuation.section.embedded.end.smarty","}"],
["meta.tag.punctuation.end-tag-open.xml","</"],
["meta.tag.anchor.tag-name.xml","a"],
["meta.tag.punctuation.tag-close.xml",">"]
],[
"start",
["text.xml"," "],
["meta.tag.punctuation.tag-open.xml","<"],
["meta.tag.anchor.tag-name.xml","a"],
["text.tag-whitespace.xml"," "],
["entity.other.attribute-name.xml","href"],
["keyword.operator.attribute-equals.xml","="],
["string.attribute-value.xml","\""],
["punctuation.section.embedded.begin.smarty","{"],
["punctuation.definition.variable.smarty","$"],
["variable.other.smarty","bar"],
["source.smarty",".zig2"],
["punctuation.section.embedded.end.smarty","}"],
["string.attribute-value.xml","\""],
["meta.tag.punctuation.tag-close.xml",">"],
["punctuation.section.embedded.begin.smarty","{"],
["punctuation.definition.variable.smarty","$"],
["variable.other.smarty","bar"],
["source.smarty",".zag2"],
["punctuation.section.embedded.end.smarty","}"],
["meta.tag.punctuation.end-tag-open.xml","</"],
["meta.tag.anchor.tag-name.xml","a"],
["meta.tag.punctuation.tag-close.xml",">"]
],[
"start",
["text.xml"," "],
["meta.tag.punctuation.tag-open.xml","<"],
["meta.tag.anchor.tag-name.xml","a"],
["text.tag-whitespace.xml"," "],
["entity.other.attribute-name.xml","href"],
["keyword.operator.attribute-equals.xml","="],
["string.attribute-value.xml","\""],
["punctuation.section.embedded.begin.smarty","{"],
["punctuation.definition.variable.smarty","$"],
["variable.other.smarty","bar"],
["source.smarty",".zig3"],
["punctuation.section.embedded.end.smarty","}"],
["string.attribute-value.xml","\""],
["meta.tag.punctuation.tag-close.xml",">"],
["punctuation.section.embedded.begin.smarty","{"],
["punctuation.definition.variable.smarty","$"],
["variable.other.smarty","bar"],
["source.smarty",".zag3"],
["punctuation.section.embedded.end.smarty","}"],
["meta.tag.punctuation.end-tag-open.xml","</"],
["meta.tag.anchor.tag-name.xml","a"],
["meta.tag.punctuation.tag-close.xml",">"]
],[
"start",
["punctuation.section.embedded.begin.smarty","{"],
["keyword.control.smarty","foreachelse"],
["punctuation.section.embedded.end.smarty","}"]
],[
"start",
["text.xml"," There were no rows found."]
],[
"start",
["punctuation.section.embedded.begin.smarty","{"],
["source.smarty","/"],
["keyword.control.smarty","foreach"],
["punctuation.section.embedded.end.smarty","}"]
]]

View file

@ -5,18 +5,12 @@
["text"," "], ["text"," "],
["punctuation.definition.string.begin.asp","\""], ["punctuation.definition.string.begin.asp","\""],
["string.quoted.double.asp","C:\\Wikipedia - VBScript - Example - Hello World.txt\""] ["string.quoted.double.asp","C:\\Wikipedia - VBScript - Example - Hello World.txt\""]
],[
"start"
],[ ],[
"start", "start",
["text","MakeHelloWorldFile myfilename"] ["text","MakeHelloWorldFile myfilename"]
],[
"start"
],[ ],[
"state_4", "state_4",
["meta.leading-space"," "] ["meta.leading-space"," "]
],[
"state_4"
],[ ],[
"start", "start",
["storage.type.function.asp","Sub"], ["storage.type.function.asp","Sub"],
@ -26,14 +20,10 @@
["punctuation.definition.parameters.asp","("], ["punctuation.definition.parameters.asp","("],
["variable.parameter.function.asp","FileName"], ["variable.parameter.function.asp","FileName"],
["punctuation.definition.parameters.asp",")"] ["punctuation.definition.parameters.asp",")"]
],[
"start"
],[ ],[
"start", "start",
["punctuation.definition.comment.asp","'"], ["punctuation.definition.comment.asp","'"],
["comment.line.apostrophe.asp","Create a new file in C: drive or overwrite existing file"] ["comment.line.apostrophe.asp","Create a new file in C: drive or overwrite existing file"]
],[
"start"
],[ ],[
"start", "start",
["meta.odd-tab.spaces"," "], ["meta.odd-tab.spaces"," "],
@ -47,8 +37,6 @@
["punctuation.definition.string.begin.asp","\""], ["punctuation.definition.string.begin.asp","\""],
["string.quoted.double.asp","Scripting.FileSystemObject\""], ["string.quoted.double.asp","Scripting.FileSystemObject\""],
["text",")"] ["text",")"]
],[
"start"
],[ ],[
"start", "start",
["meta.odd-tab.spaces"," "], ["meta.odd-tab.spaces"," "],
@ -59,8 +47,6 @@
["text","(FileName) "], ["text","(FileName) "],
["keyword.control.asp","Then"], ["keyword.control.asp","Then"],
["text"," "] ["text"," "]
],[
"start"
],[ ],[
"start", "start",
["meta.odd-tab.spaces"," "], ["meta.odd-tab.spaces"," "],
@ -81,8 +67,6 @@
["punctuation.definition.string.begin.asp","\""], ["punctuation.definition.string.begin.asp","\""],
["string.quoted.double.asp"," exists ... OK to overwrite?\""], ["string.quoted.double.asp"," exists ... OK to overwrite?\""],
["text",", vbOKCancel)"] ["text",", vbOKCancel)"]
],[
"start"
],[ ],[
"start", "start",
["meta.odd-tab.spaces"," "], ["meta.odd-tab.spaces"," "],
@ -90,8 +74,6 @@
["meta.odd-tab.spaces"," "], ["meta.odd-tab.spaces"," "],
["punctuation.definition.comment.asp","'"], ["punctuation.definition.comment.asp","'"],
["comment.line.apostrophe.asp","If button selected is not OK, then quit now"] ["comment.line.apostrophe.asp","If button selected is not OK, then quit now"]
],[
"start"
],[ ],[
"start", "start",
["meta.odd-tab.spaces"," "], ["meta.odd-tab.spaces"," "],
@ -99,8 +81,6 @@
["meta.odd-tab.spaces"," "], ["meta.odd-tab.spaces"," "],
["punctuation.definition.comment.asp","'"], ["punctuation.definition.comment.asp","'"],
["comment.line.apostrophe.asp","vbOK is a language constant"] ["comment.line.apostrophe.asp","vbOK is a language constant"]
],[
"start"
],[ ],[
"start", "start",
["meta.odd-tab.spaces"," "], ["meta.odd-tab.spaces"," "],
@ -113,15 +93,11 @@
["keyword.control.asp","Then"], ["keyword.control.asp","Then"],
["text"," "], ["text"," "],
["keyword.control.asp","Exit Sub"] ["keyword.control.asp","Exit Sub"]
],[
"start"
],[ ],[
"start", "start",
["meta.odd-tab.spaces"," "], ["meta.odd-tab.spaces"," "],
["meta.leading-space"," "], ["meta.leading-space"," "],
["keyword.control.asp","Else"] ["keyword.control.asp","Else"]
],[
"start"
],[ ],[
"start", "start",
["meta.odd-tab.spaces"," "], ["meta.odd-tab.spaces"," "],
@ -129,8 +105,6 @@
["meta.odd-tab.spaces"," "], ["meta.odd-tab.spaces"," "],
["punctuation.definition.comment.asp","'"], ["punctuation.definition.comment.asp","'"],
["comment.line.apostrophe.asp","Confirm OK to create"] ["comment.line.apostrophe.asp","Confirm OK to create"]
],[
"start"
],[ ],[
"start", "start",
["meta.odd-tab.spaces"," "], ["meta.odd-tab.spaces"," "],
@ -151,8 +125,6 @@
["punctuation.definition.string.begin.asp","\""], ["punctuation.definition.string.begin.asp","\""],
["string.quoted.double.asp"," ... OK to create?\""], ["string.quoted.double.asp"," ... OK to create?\""],
["text",", vbOKCancel)"] ["text",", vbOKCancel)"]
],[
"start"
],[ ],[
"start", "start",
["meta.odd-tab.spaces"," "], ["meta.odd-tab.spaces"," "],
@ -165,23 +137,17 @@
["keyword.control.asp","Then"], ["keyword.control.asp","Then"],
["text"," "], ["text"," "],
["keyword.control.asp","Exit Sub"] ["keyword.control.asp","Exit Sub"]
],[
"start"
],[ ],[
"start", "start",
["meta.odd-tab.spaces"," "], ["meta.odd-tab.spaces"," "],
["meta.leading-space"," "], ["meta.leading-space"," "],
["keyword.control.asp","End If"] ["keyword.control.asp","End If"]
],[
"start"
],[ ],[
"start", "start",
["meta.odd-tab.spaces"," "], ["meta.odd-tab.spaces"," "],
["meta.leading-space"," "], ["meta.leading-space"," "],
["punctuation.definition.comment.asp","'"], ["punctuation.definition.comment.asp","'"],
["comment.line.apostrophe.asp","Create new file (or replace an existing file)"] ["comment.line.apostrophe.asp","Create new file (or replace an existing file)"]
],[
"start"
],[ ],[
"start", "start",
["meta.odd-tab.spaces"," "], ["meta.odd-tab.spaces"," "],
@ -190,8 +156,6 @@
["text"," FileObject "], ["text"," FileObject "],
["keyword.operator.asp","="], ["keyword.operator.asp","="],
["text"," FSO.CreateTextFile (FileName)"] ["text"," FSO.CreateTextFile (FileName)"]
],[
"start"
],[ ],[
"start", "start",
["meta.odd-tab.spaces"," "], ["meta.odd-tab.spaces"," "],
@ -204,8 +168,6 @@
["text"," "], ["text"," "],
["support.function.vb.asp","Now"], ["support.function.vb.asp","Now"],
["text","()"] ["text","()"]
],[
"start"
],[ ],[
"start", "start",
["meta.odd-tab.spaces"," "], ["meta.odd-tab.spaces"," "],
@ -213,8 +175,6 @@
["text","FileObject.WriteLine "], ["text","FileObject.WriteLine "],
["punctuation.definition.string.begin.asp","\""], ["punctuation.definition.string.begin.asp","\""],
["string.quoted.double.asp","Hello World\""] ["string.quoted.double.asp","Hello World\""]
],[
"start"
],[ ],[
"start", "start",
["meta.odd-tab.spaces"," "], ["meta.odd-tab.spaces"," "],
@ -222,8 +182,6 @@
["text","FileObject."], ["text","FileObject."],
["entity.name.function.asp","Close"], ["entity.name.function.asp","Close"],
["text","()"] ["text","()"]
],[
"start"
],[ ],[
"start", "start",
["meta.odd-tab.spaces"," "], ["meta.odd-tab.spaces"," "],
@ -239,8 +197,6 @@
["text"," "], ["text"," "],
["punctuation.definition.string.begin.asp","\""], ["punctuation.definition.string.begin.asp","\""],
["string.quoted.double.asp"," ... updated.\""] ["string.quoted.double.asp"," ... updated.\""]
],[
"start"
],[ ],[
"start", "start",
["support.function.asp","End"], ["support.function.asp","End"],

View file

@ -31,7 +31,6 @@
define(function(require, exports, module) { define(function(require, exports, module) {
"use strict"; "use strict";
var Tokenizer = require("../tokenizer").Tokenizer;
var Rules = require("./abap_highlight_rules").AbapHighlightRules; var Rules = require("./abap_highlight_rules").AbapHighlightRules;
var FoldMode = require("./folding/coffee").FoldMode; var FoldMode = require("./folding/coffee").FoldMode;
var Range = require("../range").Range; var Range = require("../range").Range;

View file

@ -42,7 +42,6 @@ define(function(require, exports, module) {
var oop = require("../lib/oop"); var oop = require("../lib/oop");
var TextMode = require("./text").Mode; var TextMode = require("./text").Mode;
var Tokenizer = require("../tokenizer").Tokenizer;
var ActionScriptHighlightRules = require("./actionscript_highlight_rules").ActionScriptHighlightRules; var ActionScriptHighlightRules = require("./actionscript_highlight_rules").ActionScriptHighlightRules;
// TODO: pick appropriate fold mode // TODO: pick appropriate fold mode
var FoldMode = require("./folding/cstyle").FoldMode; var FoldMode = require("./folding/cstyle").FoldMode;

View file

@ -33,7 +33,6 @@ define(function(require, exports, module) {
var oop = require("../lib/oop"); var oop = require("../lib/oop");
var TextMode = require("./text").Mode; var TextMode = require("./text").Mode;
var Tokenizer = require("../tokenizer").Tokenizer;
var AdaHighlightRules = require("./ada_highlight_rules").AdaHighlightRules; var AdaHighlightRules = require("./ada_highlight_rules").AdaHighlightRules;
var Range = require("../range").Range; var Range = require("../range").Range;

View file

@ -42,7 +42,6 @@ define(function(require, exports, module) {
var oop = require("../lib/oop"); var oop = require("../lib/oop");
var TextMode = require("./text").Mode; var TextMode = require("./text").Mode;
var Tokenizer = require("../tokenizer").Tokenizer;
var ApacheConfHighlightRules = require("./apache_conf_highlight_rules").ApacheConfHighlightRules; var ApacheConfHighlightRules = require("./apache_conf_highlight_rules").ApacheConfHighlightRules;
// TODO: pick appropriate fold mode // TODO: pick appropriate fold mode
var FoldMode = require("./folding/cstyle").FoldMode; var FoldMode = require("./folding/cstyle").FoldMode;

View file

@ -0,0 +1,55 @@
/* ***** BEGIN LICENSE BLOCK *****
* Distributed under the BSD license:
*
* Copyright (c) 2012, Ajax.org B.V.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Ajax.org B.V. nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* ***** END LICENSE BLOCK ***** */
define(function(require, exports, module) {
"use strict";
var oop = require("../lib/oop");
var TextMode = require("./text").Mode;
var Tokenizer = require("../tokenizer").Tokenizer;
var AppleScriptHighlightRules = require("./applescript_highlight_rules").AppleScriptHighlightRules;
// TODO: pick appropriate fold mode
var FoldMode = require("./folding/cstyle").FoldMode;
var Mode = function() {
this.HighlightRules = AppleScriptHighlightRules;
this.foldingRules = new FoldMode();
};
oop.inherits(Mode, TextMode);
(function() {
this.lineCommentStart = "--";
this.blockComment = {start: "(*", end: "*)"};
this.$id = "ace/mode/applescript";
// Extra logic goes here.
}).call(Mode.prototype);
exports.Mode = Mode;
});

View file

@ -0,0 +1,139 @@
/* ***** BEGIN LICENSE BLOCK *****
* Distributed under the BSD license:
*
* Copyright (c) 2012, Ajax.org B.V.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Ajax.org B.V. nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* ***** END LICENSE BLOCK ***** */
define(function(require, exports, module) {
"use strict";
var oop = require("../lib/oop");
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
var AppleScriptHighlightRules = function() {
// regexp must not have capturing parentheses. Use (?:) instead.
// regexps are ordered -> the first match is used
var keywords = (
"about|above|after|against|and|around|as|at|back|before|beginning|" +
"behind|below|beneath|beside|between|but|by|considering|" +
"contain|contains|continue|copy|div|does|eighth|else|end|equal|" +
"equals|error|every|exit|fifth|first|for|fourth|from|front|" +
"get|given|global|if|ignoring|in|into|is|it|its|last|local|me|" +
"middle|mod|my|ninth|not|of|on|onto|or|over|prop|property|put|ref|" +
"reference|repeat|returning|script|second|set|seventh|since|" +
"sixth|some|tell|tenth|that|the|then|third|through|thru|" +
"timeout|times|to|transaction|try|until|where|while|whose|with|without"
);
var builtinConstants = (
"AppleScript|false|linefeed|return|pi|quote|result|space|tab|true"
);
var builtinFunctions = (
"activate|beep|count|delay|launch|log|offset|read|round|run|say|" +
"summarize|write"
);
var builtinTypes = (
"alias|application|boolean|class|constant|date|file|integer|list|" +
"number|real|record|string|text|character|characters|contents|day|" +
"frontmost|id|item|length|month|name|paragraph|paragraphs|rest|" +
"reverse|running|time|version|weekday|word|words|year"
);
var keywordMapper = this.createKeywordMapper({
"support.function": builtinFunctions,
"constant.language": builtinConstants,
"support.type": builtinTypes,
"keyword": keywords
}, "identifier");
this.$rules = {
"start": [
{
token: "comment",
regex: "--.*$"
},
{
token : "comment", // multi line comment
regex : "\\(\\*",
next : "comment"
},
{
token: "string", // " string
regex: '".*?"'
},
{
token: "support.type",
regex: '\\b(POSIX file|POSIX path|(date|time) string|quoted form)\\b'
},
{
token: "support.function",
regex: '\\b(clipboard info|the clipboard|info for|list (disks|folder)|' +
'mount volume|path to|(close|open for) access|(get|set) eof|' +
'current date|do shell script|get volume settings|random number|' +
'set volume|system attribute|system info|time to GMT|' +
'(load|run|store) script|scripting components|' +
'ASCII (character|number)|localized string|' +
'choose (application|color|file|file name|' +
'folder|from list|remote application|URL)|' +
'display (alert|dialog))\\b|^\\s*return\\b'
},
{
token: "constant.language",
regex: '\\b(text item delimiters|current application|missing value)\\b'
},
{
token: "keyword",
regex: '\\b(apart from|aside from|instead of|out of|greater than|' +
"isn't|(doesn't|does not) (equal|come before|come after|contain)|" +
'(greater|less) than( or equal)?|(starts?|ends|begins?) with|' +
'contained by|comes (before|after)|a (ref|reference))\\b'
},
{
token: keywordMapper,
regex: "[a-zA-Z][a-zA-Z0-9_]*\\b"
}
],
"comment": [
{
token: "comment", // closing comment
regex: "\\*\\)",
next: "start"
}, {
defaultToken: "comment"
}
]
}
this.normalizeRules();
};
oop.inherits(AppleScriptHighlightRules, TextHighlightRules);
exports.AppleScriptHighlightRules = AppleScriptHighlightRules;
});

View file

@ -33,7 +33,6 @@ define(function(require, exports, module) {
var oop = require("../lib/oop"); var oop = require("../lib/oop");
var TextMode = require("./text").Mode; var TextMode = require("./text").Mode;
var Tokenizer = require("../tokenizer").Tokenizer;
var AsciidocHighlightRules = require("./asciidoc_highlight_rules").AsciidocHighlightRules; var AsciidocHighlightRules = require("./asciidoc_highlight_rules").AsciidocHighlightRules;
var AsciidocFoldMode = require("./folding/asciidoc").FoldMode; var AsciidocFoldMode = require("./folding/asciidoc").FoldMode;

View file

@ -38,7 +38,6 @@ define(function(require, exports, module) {
var oop = require("../lib/oop"); var oop = require("../lib/oop");
var TextMode = require("./text").Mode; var TextMode = require("./text").Mode;
var Tokenizer = require("../tokenizer").Tokenizer;
var AssemblyX86HighlightRules = require("./assembly_x86_highlight_rules").AssemblyX86HighlightRules; var AssemblyX86HighlightRules = require("./assembly_x86_highlight_rules").AssemblyX86HighlightRules;
var FoldMode = require("./folding/coffee").FoldMode; var FoldMode = require("./folding/coffee").FoldMode;

View file

@ -42,7 +42,6 @@ define(function(require, exports, module) {
var oop = require("../lib/oop"); var oop = require("../lib/oop");
var TextMode = require("./text").Mode; var TextMode = require("./text").Mode;
var Tokenizer = require("../tokenizer").Tokenizer;
var AutoHotKeyHighlightRules = require("./autohotkey_highlight_rules").AutoHotKeyHighlightRules; var AutoHotKeyHighlightRules = require("./autohotkey_highlight_rules").AutoHotKeyHighlightRules;
// TODO: pick appropriate fold mode // TODO: pick appropriate fold mode
var FoldMode = require("./folding/cstyle").FoldMode; var FoldMode = require("./folding/cstyle").FoldMode;

View file

@ -42,7 +42,6 @@ define(function(require, exports, module) {
var oop = require("../lib/oop"); var oop = require("../lib/oop");
var TextMode = require("./text").Mode; var TextMode = require("./text").Mode;
var Tokenizer = require("../tokenizer").Tokenizer;
var BatchFileHighlightRules = require("./batchfile_highlight_rules").BatchFileHighlightRules; var BatchFileHighlightRules = require("./batchfile_highlight_rules").BatchFileHighlightRules;
var FoldMode = require("./folding/cstyle").FoldMode; var FoldMode = require("./folding/cstyle").FoldMode;

View file

@ -33,7 +33,6 @@ define(function(require, exports, module) {
var oop = require("../lib/oop"); var oop = require("../lib/oop");
var TextMode = require("./text").Mode; var TextMode = require("./text").Mode;
var Tokenizer = require("../tokenizer").Tokenizer;
var C9SearchHighlightRules = require("./c9search_highlight_rules").C9SearchHighlightRules; var C9SearchHighlightRules = require("./c9search_highlight_rules").C9SearchHighlightRules;
var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
var C9StyleFoldMode = require("./folding/c9search").FoldMode; var C9StyleFoldMode = require("./folding/c9search").FoldMode;

View file

@ -33,7 +33,6 @@ define(function(require, exports, module) {
var oop = require("../lib/oop"); var oop = require("../lib/oop");
var TextMode = require("./text").Mode; var TextMode = require("./text").Mode;
var Tokenizer = require("../tokenizer").Tokenizer;
var c_cppHighlightRules = require("./c_cpp_highlight_rules").c_cppHighlightRules; var c_cppHighlightRules = require("./c_cpp_highlight_rules").c_cppHighlightRules;
var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
var Range = require("../range").Range; var Range = require("../range").Range;

View file

@ -33,7 +33,6 @@ define(function(require, exports, module) {
var oop = require("../lib/oop"); var oop = require("../lib/oop");
var TextMode = require("./text").Mode; var TextMode = require("./text").Mode;
var Tokenizer = require("../tokenizer").Tokenizer;
var CirruHighlightRules = require("./cirru_highlight_rules").CirruHighlightRules; var CirruHighlightRules = require("./cirru_highlight_rules").CirruHighlightRules;
var CoffeeFoldMode = require("./folding/coffee").FoldMode; var CoffeeFoldMode = require("./folding/coffee").FoldMode;

View file

@ -33,10 +33,8 @@ define(function(require, exports, module) {
var oop = require("../lib/oop"); var oop = require("../lib/oop");
var TextMode = require("./text").Mode; var TextMode = require("./text").Mode;
var Tokenizer = require("../tokenizer").Tokenizer;
var ClojureHighlightRules = require("./clojure_highlight_rules").ClojureHighlightRules; var ClojureHighlightRules = require("./clojure_highlight_rules").ClojureHighlightRules;
var MatchingParensOutdent = require("./matching_parens_outdent").MatchingParensOutdent; var MatchingParensOutdent = require("./matching_parens_outdent").MatchingParensOutdent;
var Range = require("../range").Range;
var Mode = function() { var Mode = function() {
this.HighlightRules = ClojureHighlightRules; this.HighlightRules = ClojureHighlightRules;
@ -47,29 +45,72 @@ oop.inherits(Mode, TextMode);
(function() { (function() {
this.lineCommentStart = ";"; this.lineCommentStart = ";";
this.minorIndentFunctions = ["defn", "defn-", "defmacro", "def", "deftest", "testing"];
this.$toIndent = function(str) {
return str.split('').map(function(ch) {
if (/\s/.exec(ch)) {
return ch;
} else {
return ' ';
}
}).join('');
};
this.$calculateIndent = function(line, tab) {
var baseIndent = this.$getIndent(line);
var delta = 0;
var isParen, ch;
// Walk back from end of line, find matching braces
for (var i = line.length - 1; i >= 0; i--) {
ch = line[i];
if (ch === '(') {
delta--;
isParen = true;
} else if (ch === '(' || ch === '[' || ch === '{') {
delta--;
isParen = false;
} else if (ch === ')' || ch === ']' || ch === '}') {
delta++;
}
if (delta < 0) {
break;
}
}
if (delta < 0 && isParen) {
// Were more brackets opened than closed and was a ( left open?
i += 1;
var iBefore = i;
var fn = '';
while (true) {
ch = line[i];
if (ch === ' ' || ch === '\t') {
if(this.minorIndentFunctions.indexOf(fn) !== -1) {
return this.$toIndent(line.substring(0, iBefore - 1) + tab);
} else {
return this.$toIndent(line.substring(0, i + 1));
}
} else if (ch === undefined) {
return this.$toIndent(line.substring(0, iBefore - 1) + tab);
}
fn += line[i];
i++;
}
} else if(delta < 0 && !isParen) {
// Were more brackets openend than closed and was it not a (?
return this.$toIndent(line.substring(0, i+1));
} else if(delta > 0) {
// Mere more brackets closed than opened? Outdent.
baseIndent = baseIndent.substring(0, baseIndent.length - tab.length);
return baseIndent;
} else {
// Were they nicely matched? Just indent like line before.
return baseIndent;
}
};
this.getNextLineIndent = function(state, line, tab) { this.getNextLineIndent = function(state, line, tab) {
var indent = this.$getIndent(line); return this.$calculateIndent(line, tab);
var tokenizedLine = this.getTokenizer().getLineTokens(line, state);
var tokens = tokenizedLine.tokens;
if (tokens.length && tokens[tokens.length-1].type == "comment") {
return indent;
}
if (state == "start") {
var match = line.match(/[\(\[]/);
if (match) {
indent += " ";
}
match = line.match(/[\)]/);
if (match) {
indent = "";
}
}
return indent;
}; };
this.checkOutdent = function(state, line, input) { this.checkOutdent = function(state, line, input) {

View file

@ -33,7 +33,6 @@ define(function(require, exports, module) {
var oop = require("../lib/oop"); var oop = require("../lib/oop");
var TextMode = require("./text").Mode; var TextMode = require("./text").Mode;
var Tokenizer = require("../tokenizer").Tokenizer;
var CobolHighlightRules = require("./cobol_highlight_rules").CobolHighlightRules; var CobolHighlightRules = require("./cobol_highlight_rules").CobolHighlightRules;
var Range = require("../range").Range; var Range = require("../range").Range;

View file

@ -31,7 +31,6 @@
define(function(require, exports, module) { define(function(require, exports, module) {
"use strict"; "use strict";
var Tokenizer = require("../tokenizer").Tokenizer;
var Rules = require("./coffee_highlight_rules").CoffeeHighlightRules; var Rules = require("./coffee_highlight_rules").CoffeeHighlightRules;
var Outdent = require("./matching_brace_outdent").MatchingBraceOutdent; var Outdent = require("./matching_brace_outdent").MatchingBraceOutdent;
var FoldMode = require("./folding/coffee").FoldMode; var FoldMode = require("./folding/coffee").FoldMode;
@ -50,7 +49,28 @@ oop.inherits(Mode, TextMode);
(function() { (function() {
var indenter = /(?:[({[=:]|[-=]>|\b(?:else|switch|try|catch(?:\s*[$A-Za-z_\x7f-\uffff][$\w\x7f-\uffff]*)?|finally))\s*$/; /*:
[({[=:] # Opening parentheses or brackets
|[-=]> # OR single or double arrow
|\b(?: # OR one of these words:
else # else
|try # OR try
|(?:swi|ca)tch # OR catch, optionally followed by:
(?:\s*[$A-Za-z_\x7f-\uffff][$\w\x7f-\uffff]*)? # a variable
|finally # OR finally
))\s*$ # all as the last thing on a line (allowing trailing space)
| # ---- OR ---- :
^\s* # a line starting with optional space
(else\b\s*)? # followed by an optional "else"
(?: # followed by one of the following:
if # if
|for # OR for
|while # OR while
|loop # OR loop
)\b # (as a word)
(?!.*\bthen\b) # ... but NOT followed by "then" on the line
*/
var indenter = /(?:[({[=:]|[-=]>|\b(?:else|try|(?:swi|ca)tch(?:\s+[$A-Za-z_\x7f-\uffff][$\w\x7f-\uffff]*)?|finally))\s*$|^\s*(else\b\s*)?(?:if|for|while|loop)\b(?!.*\bthen\b)/;
var commentLine = /^(\s*)#/; var commentLine = /^(\s*)#/;
var hereComment = /^\s*###(?!#)/; var hereComment = /^\s*###(?!#)/;
var indentation = /^\s*/; var indentation = /^\s*/;

View file

@ -34,7 +34,6 @@ define(function(require, exports, module) {
var oop = require("../lib/oop"); var oop = require("../lib/oop");
var lang = require("../lib/lang"); var lang = require("../lib/lang");
var HtmlMode = require("./html").Mode; var HtmlMode = require("./html").Mode;
var Tokenizer = require("../tokenizer").Tokenizer;
var ColdfusionHighlightRules = require("./coldfusion_highlight_rules").ColdfusionHighlightRules; var ColdfusionHighlightRules = require("./coldfusion_highlight_rules").ColdfusionHighlightRules;
var voidElements = "cfabort|cfapplication|cfargument|cfassociate|cfbreak|cfcache|cfcollection|cfcookie|cfdbinfo|cfdirectory|cfdump|cfelse|cfelseif|cferror|cfexchangecalendar|cfexchangeconnection|cfexchangecontact|cfexchangefilter|cfexchangetask|cfexit|cffeed|cffile|cfflush|cfftp|cfheader|cfhtmlhead|cfhttpparam|cfimage|cfimport|cfinclude|cfindex|cfinsert|cfinvokeargument|cflocation|cflog|cfmailparam|cfNTauthenticate|cfobject|cfobjectcache|cfparam|cfpdfformparam|cfprint|cfprocparam|cfprocresult|cfproperty|cfqueryparam|cfregistry|cfreportparam|cfrethrow|cfreturn|cfschedule|cfsearch|cfset|cfsetting|cfthrow|cfzipparam)".split("|"); var voidElements = "cfabort|cfapplication|cfargument|cfassociate|cfbreak|cfcache|cfcollection|cfcookie|cfdbinfo|cfdirectory|cfdump|cfelse|cfelseif|cferror|cfexchangecalendar|cfexchangeconnection|cfexchangecontact|cfexchangefilter|cfexchangetask|cfexit|cffeed|cffile|cfflush|cfftp|cfheader|cfhtmlhead|cfhttpparam|cfimage|cfimport|cfinclude|cfindex|cfinsert|cfinvokeargument|cflocation|cflog|cfmailparam|cfNTauthenticate|cfobject|cfobjectcache|cfparam|cfpdfformparam|cfprint|cfprocparam|cfprocresult|cfproperty|cfqueryparam|cfregistry|cfreportparam|cfrethrow|cfreturn|cfschedule|cfsearch|cfset|cfsetting|cfthrow|cfzipparam)".split("|");

View file

@ -3,7 +3,6 @@ define(function(require, exports, module) {
var oop = require("../lib/oop"); var oop = require("../lib/oop");
var TextMode = require("./text").Mode; var TextMode = require("./text").Mode;
var Tokenizer = require("../tokenizer").Tokenizer;
var CSharpHighlightRules = require("./csharp_highlight_rules").CSharpHighlightRules; var CSharpHighlightRules = require("./csharp_highlight_rules").CSharpHighlightRules;
var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour; var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour;

View file

@ -26,9 +26,6 @@ var CSharpHighlightRules = function() {
token : "comment", // multi line comment token : "comment", // multi line comment
regex : "\\/\\*", regex : "\\/\\*",
next : "comment" next : "comment"
}, {
token : "string.regexp",
regex : "[/](?:(?:\\[(?:\\\\]|[^\\]])+\\])|(?:\\\\/|[^\\]/]))*[/]\\w*\\s*(?=[).,;]|$)"
}, { }, {
token : "string", // character token : "string", // character
regex : /'(?:.|\\(:?u[\da-fA-F]+|x[\da-fA-F]+|[tbrf'"n]))'/ regex : /'(?:.|\\(:?u[\da-fA-F]+|x[\da-fA-F]+|[tbrf'"n]))'/

View file

@ -33,7 +33,6 @@ define(function(require, exports, module) {
var oop = require("../lib/oop"); var oop = require("../lib/oop");
var TextMode = require("./text").Mode; var TextMode = require("./text").Mode;
var Tokenizer = require("../tokenizer").Tokenizer;
var CssHighlightRules = require("./css_highlight_rules").CssHighlightRules; var CssHighlightRules = require("./css_highlight_rules").CssHighlightRules;
var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
var WorkerClient = require("../worker/worker_client").WorkerClient; var WorkerClient = require("../worker/worker_client").WorkerClient;

View file

@ -1,7 +1,7 @@
define(function(require, exports, module) { define(function(require, exports, module) {
/*! /*!
CSSLint CSSLint
Copyright (c) 2013 Nicole Sullivan and Nicholas C. Zakas. All rights reserved. Copyright (c) 2014 Nicole Sullivan and Nicholas C. Zakas. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal
@ -22,7 +22,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. THE SOFTWARE.
*/ */
/* Build: v0.10.0 15-August-2013 01:07:22 */ /* Build: v0.10.0 31-March-2014 08:16:48 */
/*! /*!
Parser-Lib Parser-Lib
Copyright (c) 2009-2011 Nicholas C. Zakas. All rights reserved. Copyright (c) 2009-2011 Nicholas C. Zakas. All rights reserved.
@ -46,7 +46,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. THE SOFTWARE.
*/ */
/* Version v0.2.3, Build time: 19-June-2013 11:16:15 */ /* Version v0.2.4, Build time: 7-January-2014 07:32:49 */
var parserlib = {}; var parserlib = {};
(function(){ (function(){
@ -956,7 +956,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. THE SOFTWARE.
*/ */
/* Version v0.2.3, Build time: 19-June-2013 11:16:15 */ /* Version v0.2.4, Build time: 7-January-2014 07:32:49 */
(function(){ (function(){
var EventTarget = parserlib.util.EventTarget, var EventTarget = parserlib.util.EventTarget,
TokenStreamBase = parserlib.util.TokenStreamBase, TokenStreamBase = parserlib.util.TokenStreamBase,
@ -991,6 +991,7 @@ var Colors = {
darkcyan :"#008b8b", darkcyan :"#008b8b",
darkgoldenrod :"#b8860b", darkgoldenrod :"#b8860b",
darkgray :"#a9a9a9", darkgray :"#a9a9a9",
darkgrey :"#a9a9a9",
darkgreen :"#006400", darkgreen :"#006400",
darkkhaki :"#bdb76b", darkkhaki :"#bdb76b",
darkmagenta :"#8b008b", darkmagenta :"#8b008b",
@ -1002,11 +1003,13 @@ var Colors = {
darkseagreen :"#8fbc8f", darkseagreen :"#8fbc8f",
darkslateblue :"#483d8b", darkslateblue :"#483d8b",
darkslategray :"#2f4f4f", darkslategray :"#2f4f4f",
darkslategrey :"#2f4f4f",
darkturquoise :"#00ced1", darkturquoise :"#00ced1",
darkviolet :"#9400d3", darkviolet :"#9400d3",
deeppink :"#ff1493", deeppink :"#ff1493",
deepskyblue :"#00bfff", deepskyblue :"#00bfff",
dimgray :"#696969", dimgray :"#696969",
dimgrey :"#696969",
dodgerblue :"#1e90ff", dodgerblue :"#1e90ff",
firebrick :"#b22222", firebrick :"#b22222",
floralwhite :"#fffaf0", floralwhite :"#fffaf0",
@ -1017,6 +1020,7 @@ var Colors = {
gold :"#ffd700", gold :"#ffd700",
goldenrod :"#daa520", goldenrod :"#daa520",
gray :"#808080", gray :"#808080",
grey :"#808080",
green :"#008000", green :"#008000",
greenyellow :"#adff2f", greenyellow :"#adff2f",
honeydew :"#f0fff0", honeydew :"#f0fff0",
@ -1034,12 +1038,14 @@ var Colors = {
lightcyan :"#e0ffff", lightcyan :"#e0ffff",
lightgoldenrodyellow :"#fafad2", lightgoldenrodyellow :"#fafad2",
lightgray :"#d3d3d3", lightgray :"#d3d3d3",
lightgrey :"#d3d3d3",
lightgreen :"#90ee90", lightgreen :"#90ee90",
lightpink :"#ffb6c1", lightpink :"#ffb6c1",
lightsalmon :"#ffa07a", lightsalmon :"#ffa07a",
lightseagreen :"#20b2aa", lightseagreen :"#20b2aa",
lightskyblue :"#87cefa", lightskyblue :"#87cefa",
lightslategray :"#778899", lightslategray :"#778899",
lightslategrey :"#778899",
lightsteelblue :"#b0c4de", lightsteelblue :"#b0c4de",
lightyellow :"#ffffe0", lightyellow :"#ffffe0",
lime :"#00ff00", lime :"#00ff00",
@ -1092,6 +1098,7 @@ var Colors = {
skyblue :"#87ceeb", skyblue :"#87ceeb",
slateblue :"#6a5acd", slateblue :"#6a5acd",
slategray :"#708090", slategray :"#708090",
slategrey :"#708090",
snow :"#fffafa", snow :"#fffafa",
springgreen :"#00ff7f", springgreen :"#00ff7f",
steelblue :"#4682b4", steelblue :"#4682b4",
@ -1117,6 +1124,7 @@ var Colors = {
buttontext :"Text on push buttons.", buttontext :"Text on push buttons.",
captiontext :"Text in caption, size box, and scrollbar arrow box.", captiontext :"Text in caption, size box, and scrollbar arrow box.",
graytext :"Grayed (disabled) text. This color is set to #000 if the current display driver does not support a solid gray color.", graytext :"Grayed (disabled) text. This color is set to #000 if the current display driver does not support a solid gray color.",
greytext :"Greyed (disabled) text. This color is set to #000 if the current display driver does not support a solid grey color.",
highlight :"Item(s) selected in a control.", highlight :"Item(s) selected in a control.",
highlighttext :"Text of item(s) selected in a control.", highlighttext :"Text of item(s) selected in a control.",
inactiveborder :"Inactive window border.", inactiveborder :"Inactive window border.",
@ -3533,6 +3541,12 @@ nth
var Properties = { var Properties = {
//A //A
"align-items" : "flex-start | flex-end | center | baseline | stretch",
"align-content" : "flex-start | flex-end | center | space-between | space-around | stretch",
"align-self" : "auto | flex-start | flex-end | center | baseline | stretch",
"-webkit-align-items" : "flex-start | flex-end | center | baseline | stretch",
"-webkit-align-content" : "flex-start | flex-end | center | space-between | space-around | stretch",
"-webkit-align-self" : "auto | flex-start | flex-end | center | baseline | stretch",
"alignment-adjust" : "auto | baseline | before-edge | text-before-edge | middle | central | after-edge | text-after-edge | ideographic | alphabetic | hanging | mathematical | <percentage> | <length>", "alignment-adjust" : "auto | baseline | before-edge | text-before-edge | middle | central | after-edge | text-after-edge | ideographic | alphabetic | hanging | mathematical | <percentage> | <length>",
"alignment-baseline" : "baseline | use-script | before-edge | text-before-edge | after-edge | text-after-edge | central | middle | ideographic | alphabetic | hanging | mathematical", "alignment-baseline" : "baseline | use-script | before-edge | text-before-edge | after-edge | text-after-edge | central | middle | ideographic | alphabetic | hanging | mathematical",
"animation" : 1, "animation" : 1,
@ -3728,15 +3742,24 @@ var Properties = {
"border-top-width" : "<border-width>", "border-top-width" : "<border-width>",
"border-width" : { multi: "<border-width>", max: 4 }, "border-width" : { multi: "<border-width>", max: 4 },
"bottom" : "<margin-width> | inherit", "bottom" : "<margin-width> | inherit",
"box-align" : "start | end | center | baseline | stretch", //http://www.w3.org/TR/2009/WD-css3-flexbox-20090723/ "-moz-box-align" : "start | end | center | baseline | stretch",
"box-decoration-break" : "slice |clone", "-moz-box-decoration-break" : "slice |clone",
"box-direction" : "normal | reverse | inherit", "-moz-box-direction" : "normal | reverse | inherit",
"box-flex" : "<number>", "-moz-box-flex" : "<number>",
"box-flex-group" : "<integer>", "-moz-box-flex-group" : "<integer>",
"box-lines" : "single | multiple", "-moz-box-lines" : "single | multiple",
"box-ordinal-group" : "<integer>", "-moz-box-ordinal-group" : "<integer>",
"box-orient" : "horizontal | vertical | inline-axis | block-axis | inherit", "-moz-box-orient" : "horizontal | vertical | inline-axis | block-axis | inherit",
"box-pack" : "start | end | center | justify", "-moz-box-pack" : "start | end | center | justify",
"-webkit-box-align" : "start | end | center | baseline | stretch",
"-webkit-box-decoration-break" : "slice |clone",
"-webkit-box-direction" : "normal | reverse | inherit",
"-webkit-box-flex" : "<number>",
"-webkit-box-flex-group" : "<integer>",
"-webkit-box-lines" : "single | multiple",
"-webkit-box-ordinal-group" : "<integer>",
"-webkit-box-orient" : "horizontal | vertical | inline-axis | block-axis | inherit",
"-webkit-box-pack" : "start | end | center | justify",
"box-shadow" : function (expression) { "box-shadow" : function (expression) {
var result = false, var result = false,
part; part;
@ -3782,7 +3805,7 @@ var Properties = {
//D //D
"direction" : "ltr | rtl | inherit", "direction" : "ltr | rtl | inherit",
"display" : "inline | block | list-item | inline-block | table | inline-table | table-row-group | table-header-group | table-footer-group | table-row | table-column-group | table-column | table-cell | table-caption | box | inline-box | grid | inline-grid | none | inherit | -moz-box | -moz-inline-block | -moz-inline-box | -moz-inline-grid | -moz-inline-stack | -moz-inline-table | -moz-grid | -moz-grid-group | -moz-grid-line | -moz-groupbox | -moz-deck | -moz-popup | -moz-stack | -moz-marker | -webkit-box | -webkit-inline-box", "display" : "inline | block | list-item | inline-block | table | inline-table | table-row-group | table-header-group | table-footer-group | table-row | table-column-group | table-column | table-cell | table-caption | grid | inline-grid | none | inherit | -moz-box | -moz-inline-block | -moz-inline-box | -moz-inline-grid | -moz-inline-stack | -moz-inline-table | -moz-grid | -moz-grid-group | -moz-grid-line | -moz-groupbox | -moz-deck | -moz-popup | -moz-stack | -moz-marker | -webkit-box | -webkit-inline-box | -ms-flexbox | -ms-inline-flexbox | flex | -webkit-flex | inline-flex | -webkit-inline-flex",
"dominant-baseline" : 1, "dominant-baseline" : 1,
"drop-initial-after-adjust" : "central | middle | after-edge | text-after-edge | ideographic | alphabetic | mathematical | <percentage> | <length>", "drop-initial-after-adjust" : "central | middle | after-edge | text-after-edge | ideographic | alphabetic | mathematical | <percentage> | <length>",
"drop-initial-after-align" : "baseline | use-script | before-edge | text-before-edge | after-edge | text-after-edge | central | middle | ideographic | alphabetic | hanging | mathematical", "drop-initial-after-align" : "baseline | use-script | before-edge | text-before-edge | after-edge | text-after-edge | central | middle | ideographic | alphabetic | hanging | mathematical",
@ -3799,6 +3822,26 @@ var Properties = {
"filter" : 1, "filter" : 1,
"fit" : "fill | hidden | meet | slice", "fit" : "fill | hidden | meet | slice",
"fit-position" : 1, "fit-position" : 1,
"flex" : "none | [ <flex-grow> <flex-shrink>? || <flex-basis>",
"flex-basis" : "<width>",
"flex-direction" : "row | row-reverse | column | column-reverse",
"flex-flow" : "<flex-direction> || <flex-wrap>",
"flex-grow" : "<number>",
"flex-shrink" : "<number>",
"flex-wrap" : "nowrap | wrap | wrap-reverse",
"-webkit-flex" : "none | [ <flex-grow> <flex-shrink>? || <flex-basis>",
"-webkit-flex-basis" : "<width>",
"-webkit-flex-direction" : "row | row-reverse | column | column-reverse",
"-webkit-flex-flow" : "<flex-direction> || <flex-wrap>",
"-webkit-flex-grow" : "<number>",
"-webkit-flex-shrink" : "<number>",
"-webkit-flex-wrap" : "nowrap | wrap | wrap-reverse",
"-ms-flex" : "[[ <number> <number>? ] || [ <length> || <percentage> || auto ] ] | none",
"-ms-flex-align" : "start | end | center | stretch | baseline",
"-ms-flex-direction" : "row | column | row-reverse | column-reverse | inherit",
"-ms-flex-order" : "<number>",
"-ms-flex-pack" : "start | end | center | justify",
"-ms-flex-wrap" : "nowrap | wrap | wrap-reverse",
"float" : "left | right | none | inherit", "float" : "left | right | none | inherit",
"float-offset" : 1, "float-offset" : 1,
"font" : 1, "font" : 1,
@ -3842,6 +3885,10 @@ var Properties = {
"image-resolution" : 1, "image-resolution" : 1,
"inline-box-align" : "initial | last | <integer>", "inline-box-align" : "initial | last | <integer>",
//J
"justify-content" : "flex-start | flex-end | center | space-between | space-around",
"-webkit-justify-content" : "flex-start | flex-end | center | space-between | space-around",
//L //L
"left" : "<margin-width> | inherit", "left" : "<margin-width> | inherit",
"letter-spacing" : "<length> | normal | inherit", "letter-spacing" : "<length> | normal | inherit",
@ -3885,6 +3932,8 @@ var Properties = {
//O //O
"opacity" : "<number> | inherit", "opacity" : "<number> | inherit",
"order" : "<integer>",
"-webkit-order" : "<integer>",
"orphans" : "<integer> | inherit", "orphans" : "<integer> | inherit",
"outline" : 1, "outline" : 1,
"outline-color" : "<color> | invert | inherit", "outline-color" : "<color> | invert | inherit",
@ -3893,6 +3942,7 @@ var Properties = {
"outline-width" : "<border-width> | inherit", "outline-width" : "<border-width> | inherit",
"overflow" : "visible | hidden | scroll | auto | inherit", "overflow" : "visible | hidden | scroll | auto | inherit",
"overflow-style" : 1, "overflow-style" : 1,
"overflow-wrap" : "normal | break-word",
"overflow-x" : 1, "overflow-x" : 1,
"overflow-y" : 1, "overflow-y" : 1,
@ -3970,6 +4020,8 @@ var Properties = {
"text-transform" : "capitalize | uppercase | lowercase | none | inherit", "text-transform" : "capitalize | uppercase | lowercase | none | inherit",
"text-wrap" : "normal | none | avoid", "text-wrap" : "normal | none | avoid",
"top" : "<margin-width> | inherit", "top" : "<margin-width> | inherit",
"-ms-touch-action" : "auto | none | pan-x | pan-y",
"touch-action" : "auto | none | pan-x | pan-y",
"transform" : 1, "transform" : 1,
"transform-origin" : 1, "transform-origin" : 1,
"transform-style" : 1, "transform-style" : 1,
@ -3980,7 +4032,7 @@ var Properties = {
"transition-timing-function" : 1, "transition-timing-function" : 1,
//U //U
"unicode-bidi" : "normal | embed | bidi-override | inherit", "unicode-bidi" : "normal | embed | isolate | bidi-override | isolate-override | plaintext | inherit",
"user-modify" : "read-only | read-write | write-only | inherit", "user-modify" : "read-only | read-write | write-only | inherit",
"user-select" : "none | text | toggle | element | elements | all | inherit", "user-select" : "none | text | toggle | element | elements | all | inherit",
@ -4004,7 +4056,8 @@ var Properties = {
"width" : "<length> | <percentage> | auto | inherit" , "width" : "<length> | <percentage> | auto | inherit" ,
"word-break" : "normal | keep-all | break-all", "word-break" : "normal | keep-all | break-all",
"word-spacing" : "<length> | normal | inherit", "word-spacing" : "<length> | normal | inherit",
"word-wrap" : 1, "word-wrap" : "normal | break-word",
"writing-mode" : "horizontal-tb | vertical-rl | vertical-lr | lr-tb | rl-tb | tb-rl | bt-rl | tb-lr | bt-lr | lr-bt | rl-bt | lr | rl | tb | inherit",
//Z //Z
"z-index" : "<integer> | auto | inherit", "z-index" : "<integer> | auto | inherit",
@ -4275,9 +4328,6 @@ function PropertyValuePart(text, line, col){
} }
} else if (/^([+\-]?[\d\.]+)%$/i.test(text)){ //percentage
this.type = "percentage";
this.value = +RegExp.$1;
} else if (/^([+\-]?[\d\.]+)%$/i.test(text)){ //percentage } else if (/^([+\-]?[\d\.]+)%$/i.test(text)){ //percentage
this.type = "percentage"; this.type = "percentage";
this.value = +RegExp.$1; this.value = +RegExp.$1;
@ -4374,6 +4424,7 @@ PropertyValuePart.prototype.constructor = PropertyValuePart;
PropertyValuePart.fromToken = function(token){ PropertyValuePart.fromToken = function(token){
return new PropertyValuePart(token.value, token.startLine, token.startCol); return new PropertyValuePart(token.value, token.startLine, token.startCol);
}; };
var Pseudos = { var Pseudos = {
":first-letter": 1, ":first-letter": 1,
":first-line": 1, ":first-line": 1,
@ -5661,7 +5712,7 @@ var Tokens = [
{ name: "FONT_FACE_SYM", text: "@font-face"}, { name: "FONT_FACE_SYM", text: "@font-face"},
{ name: "CHARSET_SYM", text: "@charset"}, { name: "CHARSET_SYM", text: "@charset"},
{ name: "NAMESPACE_SYM", text: "@namespace"}, { name: "NAMESPACE_SYM", text: "@namespace"},
{ name: "VIEWPORT_SYM", text: "@viewport"}, { name: "VIEWPORT_SYM", text: ["@viewport", "@-ms-viewport"]},
{ name: "UNKNOWN_SYM" }, { name: "UNKNOWN_SYM" },
//{ name: "ATKEYWORD"}, //{ name: "ATKEYWORD"},
@ -6443,7 +6494,7 @@ var CSSLint = (function(){
embeddedRuleset = /\/\*csslint([^\*]*)\*\//, embeddedRuleset = /\/\*csslint([^\*]*)\*\//,
api = new parserlib.util.EventTarget(); api = new parserlib.util.EventTarget();
api.version = "0.10.0"; api.version = "@VERSION@";
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
// Rule Management // Rule Management
@ -8941,13 +8992,14 @@ CSSLint.addFormatter({
output += filename + ": " + capitalize(message.type) + " - " + message.message + "\n"; output += filename + ": " + capitalize(message.type) + " - " + message.message + "\n";
} else { } else {
output += filename + ": " + "line " + message.line + output += filename + ": " + "line " + message.line +
", col " + message.col + ", " + capitalize(message.type) + " - " + message.message + "\n"; ", col " + message.col + ", " + capitalize(message.type) + " - " + message.message + " (" + message.rule.id + ")\n";
} }
}); });
return output; return output;
} }
}); });
/*global CSSLint*/ /*global CSSLint*/
CSSLint.addFormatter({ CSSLint.addFormatter({
//format information //format information

View file

@ -76,6 +76,8 @@ oop.inherits(Worker, Mirror);
this.onUpdate = function() { this.onUpdate = function() {
var value = this.doc.getValue(); var value = this.doc.getValue();
if (!value)
return this.sender.emit("csslint", []);
var infoRules = this.infoRules; var infoRules = this.infoRules;
var result = CSSLint.verify(value, this.ruleset); var result = CSSLint.verify(value, this.ruleset);

View file

@ -40,7 +40,6 @@ define(function(require, exports, module) {
var oop = require("../lib/oop"); var oop = require("../lib/oop");
// defines the parent mode // defines the parent mode
var HtmlMode = require("./html").Mode; var HtmlMode = require("./html").Mode;
var Tokenizer = require("../tokenizer").Tokenizer;
var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
var HtmlHighlightRules = require("./html_highlight_rules").HtmlHighlightRules; var HtmlHighlightRules = require("./html_highlight_rules").HtmlHighlightRules;
var HtmlFoldMode = require("./folding/html").FoldMode; var HtmlFoldMode = require("./folding/html").FoldMode;

View file

@ -37,7 +37,6 @@ define(function(require, exports, module) {
var oop = require("../lib/oop"); var oop = require("../lib/oop");
var TextMode = require("./text").Mode; var TextMode = require("./text").Mode;
var Tokenizer = require("../tokenizer").Tokenizer;
var DHighlightRules = require("./d_highlight_rules").DHighlightRules; var DHighlightRules = require("./d_highlight_rules").DHighlightRules;
var FoldMode = require("./folding/cstyle").FoldMode; var FoldMode = require("./folding/cstyle").FoldMode;

View file

@ -66,7 +66,7 @@ var DHighlightRules = function() {
var stringEscapesSeq = { var stringEscapesSeq = {
token: "constant.language.escape", token: "constant.language.escape",
regex: "\\\\(?:(?:x[0-9A-F]{2})|(?:[0-7]{1,3})|(?:['\"\\?0abfnrtv])|" + regex: "\\\\(?:(?:x[0-9A-F]{2})|(?:[0-7]{1,3})|(?:['\"\\?0abfnrtv\\\\])|" +
"(?:u[0-9a-fA-F]{4})|(?:U[0-9a-fA-F]{8}))" "(?:u[0-9a-fA-F]{4})|(?:U[0-9a-fA-F]{8}))"
}; };

View file

@ -42,7 +42,6 @@ define(function(require, exports, module) {
var oop = require("../lib/oop"); var oop = require("../lib/oop");
var CMode = require("./c_cpp").Mode; var CMode = require("./c_cpp").Mode;
var Tokenizer = require("../tokenizer").Tokenizer;
var DartHighlightRules = require("./dart_highlight_rules").DartHighlightRules; var DartHighlightRules = require("./dart_highlight_rules").DartHighlightRules;
var CStyleFoldMode = require("./folding/cstyle").FoldMode; var CStyleFoldMode = require("./folding/cstyle").FoldMode;

Some files were not shown because too many files have changed in this diff Show more