Merge branch 'gh-pages' of git://github.com/ajaxorg/ace into gh-pages
|
|
@ -1,3 +1,47 @@
|
|||
2012.09.17, Version 0.1.0
|
||||
|
||||
* New Features
|
||||
- Multiple cursors and selections (https://c9.io/site/blog/2012/08/be-an-armenian-warrior-with-block-selection-on-steroids/)
|
||||
- Fold buttons displayed in the gutter
|
||||
- Indent Guides
|
||||
- Completely reworked vim mode (Sergi Mansilla)
|
||||
- Improved emacs keybindings
|
||||
- Autoclosing of html tags (danyaPostfactum)
|
||||
|
||||
* 20 New language modes
|
||||
- Coldfusion (Russ)
|
||||
- Diff
|
||||
- GLSL (Ed Mackey)
|
||||
- Go (Davide Saurino)
|
||||
- Haxe (Jason O'Neil)
|
||||
- Jade (Garen Torikian)
|
||||
- jsx (Syu Kato)
|
||||
- LaTeX (James Allen)
|
||||
- Less (John Roepke)
|
||||
- Liquid (Bernie Telles)
|
||||
- Lua (Lee Gao)
|
||||
- LuaPage (Choonster)
|
||||
- Markdown (Chris Spencer)
|
||||
- PostgreSQL (John DeSoi)
|
||||
- Powershell (John Kane)
|
||||
- Sh (Richo Healey)
|
||||
- SQL (Jonathan Camile)
|
||||
- Tcl (Cristoph Hochreiner)
|
||||
- XQuery (William Candillion)
|
||||
- Yaml (Meg Sharkey)
|
||||
|
||||
* Live syntax checks
|
||||
- for XQuery and JSON
|
||||
|
||||
* New Themes
|
||||
- Ambiance (Irakli Gozalishvili)
|
||||
- Dreamweaver (Adam Jimenez)
|
||||
- Github (bootstraponline)
|
||||
- Tommorrow themes (https://github.com/chriskempson/tomorrow-theme)
|
||||
- XCode
|
||||
|
||||
* Many Small Enhancements and Bugfixes
|
||||
|
||||
2011.08.02, Version 0.2.0
|
||||
|
||||
* Split view (Julian Viereck)
|
||||
|
|
@ -27,15 +71,14 @@
|
|||
- SCAD (Jacob Hansson)
|
||||
|
||||
* Live syntax checks
|
||||
- Lint for Css using CSS Lint <http://csslint.net/>
|
||||
- Lint for CSS using CSS Lint <http://csslint.net/>
|
||||
- CoffeeScript
|
||||
|
||||
* New Themes
|
||||
- Crimson Editor (iebuggy)
|
||||
- Merbivore (Michael Schwartz)
|
||||
- Merbivore soft (Michael Schwartz)
|
||||
- Solarized dark/light <http://ethanschoonover.com/solarized> (David Alan
|
||||
Hjelle)
|
||||
- Solarized dark/light <http://ethanschoonover.com/solarized> (David Alan Hjelle)
|
||||
- Vibrant Ink (Michael Schwartz)
|
||||
|
||||
* Small Features/Enhancements
|
||||
|
|
@ -48,10 +91,8 @@
|
|||
highlight are not affected (Irakli Gozalishvili)
|
||||
- Added setFontSize method
|
||||
- Improved vi keybindings (Trent Ogren)
|
||||
- When unfocused make cursor transparent instead of removing it (Harutyun
|
||||
Amirjanyan)
|
||||
- Support for matching groups in tokenizer with arrays of tokens (Chris
|
||||
Spencer)
|
||||
- When unfocused make cursor transparent instead of removing it (Harutyun Amirjanyan)
|
||||
- Support for matching groups in tokenizer with arrays of tokens (Chris Spencer)
|
||||
|
||||
* Bug fixes
|
||||
- Add support for the new OSX scroll bars
|
||||
|
|
@ -59,8 +100,7 @@
|
|||
- Proper handling of unicode characters in JavaScript identifiers
|
||||
- Fix remove lines command on last line (Harutyun Amirjanyan)
|
||||
- Fix scroll wheel sluggishness in Safari
|
||||
- Make keyboard infrastructure route keys like []^$ the right way (Julian
|
||||
Viereck)
|
||||
- Make keyboard infrastructure route keys like []^$ the right way (Julian Viereck)
|
||||
|
||||
2011.02.14, Version 0.1.6
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
*
|
||||
* 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
|
||||
|
|
@ -15,7 +15,7 @@
|
|||
* * 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
|
||||
|
|
@ -44,7 +44,7 @@ function main(args) {
|
|||
return "-" + x;
|
||||
return x;
|
||||
});
|
||||
|
||||
|
||||
if (args[2] && (args[2][0] != "-" || args[2].indexOf("h") != -1))
|
||||
type = args[2];
|
||||
|
||||
|
|
@ -52,40 +52,43 @@ function main(args) {
|
|||
if (i != -1 && args[i+1])
|
||||
BUILD_DIR = args[i+1];
|
||||
|
||||
if (type == "minimal") {
|
||||
buildAce({
|
||||
compress: args.indexOf("--m") != -1,
|
||||
noconflict: args.indexOf("--nc") != -1
|
||||
});
|
||||
} else if (type == "normal") {
|
||||
ace();
|
||||
} else if (type == "demo") {
|
||||
demo();
|
||||
} else if (type == "bm") {
|
||||
bookmarklet();
|
||||
} else if (type == "full") {
|
||||
ace();
|
||||
demo();
|
||||
bookmarklet();
|
||||
if (args.indexOf("--h") == -1) {
|
||||
if (type == "minimal") {
|
||||
buildAce({
|
||||
compress: args.indexOf("--m") != -1,
|
||||
noconflict: args.indexOf("--nc") != -1,
|
||||
shrinkwrap: args.indexOf("--s") != -1
|
||||
});
|
||||
} else if (type == "normal") {
|
||||
ace();
|
||||
} else if (type == "demo") {
|
||||
demo();
|
||||
} else if (type == "bm") {
|
||||
bookmarklet();
|
||||
} else if (type == "full") {
|
||||
demo(ace());
|
||||
bookmarklet();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
console.log("--- Ace Dryice Build Tool ---");
|
||||
console.log("");
|
||||
console.log("Options:");
|
||||
console.log(" normal Runs embedded build of Ace");
|
||||
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(" demo Runs demo build of Ace");
|
||||
console.log(" bm Runs bookmarklet build of Ace");
|
||||
console.log(" full all of above");
|
||||
console.log("flags:");
|
||||
console.log(" -m minify");
|
||||
console.log(" -nc namespace require");
|
||||
console.log("args:");
|
||||
console.log(" --target ./path path to build folder");
|
||||
console.log("flags:");
|
||||
console.log(" --h print this help");
|
||||
console.log(" --m minify");
|
||||
console.log(" --nc namespace require");
|
||||
console.log(" --s shrinkwrap (combines all output files into one)");
|
||||
console.log("");
|
||||
if (BUILD_DIR)
|
||||
console.log(" output generated in " + type + __dirname + "/" + BUILD_DIR)
|
||||
|
||||
process.exit(0);
|
||||
|
||||
}
|
||||
|
||||
function bookmarklet() {
|
||||
|
|
@ -116,7 +119,7 @@ function ace() {
|
|||
console.log('# ace ---------');
|
||||
|
||||
// uncompressed
|
||||
buildAce({
|
||||
var project = buildAce({
|
||||
compress: false,
|
||||
noconflict: false
|
||||
});
|
||||
|
|
@ -149,9 +152,16 @@ function ace() {
|
|||
source: ACE_HOME + "/ChangeLog.txt",
|
||||
dest: BUILD_DIR + "/ChangeLog.txt"
|
||||
});
|
||||
|
||||
return project;
|
||||
}
|
||||
|
||||
function demo() {
|
||||
function demo(project) {
|
||||
project = project || buildAce({
|
||||
compress: false,
|
||||
noconflict: false,
|
||||
coreOnly: true
|
||||
});
|
||||
console.log('# kitchen sink ---------');
|
||||
|
||||
var version, ref;
|
||||
|
|
@ -162,23 +172,26 @@ function demo() {
|
|||
ref = "";
|
||||
version = "";
|
||||
}
|
||||
var changeComments = function(data) {
|
||||
return (data
|
||||
.replace(/<!\-\-DEVEL[\d\D]*?DEVEL\-\->/g, "")
|
||||
.replace(/PACKAGE\-\->|<!\-\-PACKAGE/g, "")
|
||||
.replace(/\/\*DEVEL[\d\D]*?DEVEL\*\//g, "")
|
||||
.replace(/PACKAGE\*\/|\/\*PACKAGE/g, "")
|
||||
.replace("%version%", version)
|
||||
.replace("%commit%", ref)
|
||||
);
|
||||
}
|
||||
|
||||
function changeComments(data) {
|
||||
return (data
|
||||
.replace(/<!\-\-DEVEL[\d\D]*?DEVEL\-\->/g, "")
|
||||
.replace(/PACKAGE\-\->|<!\-\-PACKAGE/g, "")
|
||||
.replace(/\/\*DEVEL[\d\D]*?DEVEL\*\//g, "")
|
||||
.replace(/PACKAGE\*\/|\/\*PACKAGE/g, "")
|
||||
.replace("%version%", version)
|
||||
.replace("%commit%", ref)
|
||||
);
|
||||
};
|
||||
|
||||
function fixDocPaths(data) {
|
||||
return data.replace(/"(demo|build)\//g, "\"");
|
||||
}
|
||||
|
||||
copy({
|
||||
source: ACE_HOME + "/kitchen-sink.html",
|
||||
dest: BUILD_DIR + "/kitchen-sink.html",
|
||||
filter: [changeComments, function(data) {
|
||||
return data.replace(/"(demo|build)\//g, "\"");
|
||||
}]
|
||||
filter: [changeComments, fixDocPaths]
|
||||
});
|
||||
|
||||
copy({
|
||||
|
|
@ -195,22 +208,17 @@ function demo() {
|
|||
});
|
||||
|
||||
var demo = copy.createDataObject();
|
||||
|
||||
project.assumeAllFilesLoaded();
|
||||
copy({
|
||||
source: ACE_HOME + "/demo/kitchen-sink/demo.js",
|
||||
dest: demo,
|
||||
filter: [changeComments, function(data) {
|
||||
return data.replace(/"(demo|build)\//g, "\"");
|
||||
}, function(data) {
|
||||
return data.replace("define(", "define('kitchen-sink/demo',");
|
||||
}]
|
||||
});
|
||||
copy({
|
||||
source: ACE_HOME + "/lib/ace/split.js",
|
||||
dest: demo,
|
||||
filter: [changeComments, function(data) {
|
||||
return data.replace("define(", "define('ace/split',");
|
||||
}]
|
||||
source: [{
|
||||
project: cloneProject(project),
|
||||
require: [ "kitchen-sink/demo" ]
|
||||
}],
|
||||
filter: getWriteFilters({filters:[fixDocPaths]}, "demo"),
|
||||
dest: demo
|
||||
});
|
||||
|
||||
copy({
|
||||
source: demo,
|
||||
dest: BUILD_DIR + "/kitchen-sink/demo.js",
|
||||
|
|
@ -219,7 +227,57 @@ function demo() {
|
|||
copyFileSync(ACE_HOME + "/demo/kitchen-sink/logo.png", BUILD_DIR + "/kitchen-sink/logo.png");
|
||||
}
|
||||
|
||||
function buildAce(options) {
|
||||
function jsFileList(path, filter) {
|
||||
path = ACE_HOME + "/" + path;
|
||||
if (!filter)
|
||||
filter = /_test/;
|
||||
|
||||
return fs.readdirSync(path).map(function(x) {
|
||||
if (x.slice(-3) == ".js" && !filter.test(x))
|
||||
return x.slice(0, -3);
|
||||
}).filter(function(x){ return !!x });
|
||||
}
|
||||
|
||||
function addSuffix(options) {
|
||||
if (options.suffix == null) {
|
||||
options.suffix = "";
|
||||
if (options.compress)
|
||||
options.suffix += "-min";
|
||||
if (options.noconflict)
|
||||
options.suffix += "-noconflict";
|
||||
}
|
||||
}
|
||||
|
||||
function getWriteFilters(options, projectType) {
|
||||
var filters = [
|
||||
copy.filter.moduleDefines,
|
||||
removeUseStrict,
|
||||
removeLicenceComments,
|
||||
inlineTextModules
|
||||
];
|
||||
|
||||
if (options.filters)
|
||||
filters = filters.concat(options.filters);
|
||||
|
||||
if (projectType == "worker")
|
||||
return filters;
|
||||
|
||||
if (options.noconflict)
|
||||
filters.push(namespace(options.ns));
|
||||
|
||||
if (options.compress)
|
||||
filters.push(copy.filter.uglifyjs);
|
||||
|
||||
if (options.exportModule && projectType == "main") {
|
||||
if (options.noconflict)
|
||||
filters.push(exportAce(options.ns, options.exportModule, options.ns));
|
||||
else
|
||||
filters.push(exportAce(options.ns, options.exportModule));
|
||||
}
|
||||
return filters;
|
||||
}
|
||||
|
||||
var buildAce = function(options) {
|
||||
var aceProject = {
|
||||
roots: [ACE_HOME + '/lib', ACE_HOME + '/demo'],
|
||||
textPluginPattern: /^ace\/requirejs\/text!/
|
||||
|
|
@ -234,51 +292,22 @@ function buildAce(options) {
|
|||
noconflict: false,
|
||||
suffix: null,
|
||||
name: "ace",
|
||||
modes: fs.readdirSync(ACE_HOME + "/lib/ace/mode").map(function(x) {
|
||||
if (x.slice(-3) == ".js" && !/_highlight_rules|_test|_worker|xml_util|_outdent|behaviour/.test(x))
|
||||
return x.slice(0, -3);
|
||||
}).filter(function(x) { return !!x; }),
|
||||
themes: fs.readdirSync(ACE_HOME + "/lib/ace/theme").map(function(x){
|
||||
return x.slice(-3) == ".js" && x.slice(0, -3);
|
||||
}).filter(function(x){ return !!x; }),
|
||||
modes: jsFileList("lib/ace/mode", /_highlight_rules|_test|_worker|xml_util|_outdent|behaviour/),
|
||||
themes: jsFileList("lib/ace/theme"),
|
||||
extensions: jsFileList("lib/ace/ext"),
|
||||
workers: ["javascript", "coffee", "css", "json", "xquery"],
|
||||
keybindings: ["vim", "emacs"]
|
||||
};
|
||||
|
||||
|
||||
for(var key in defaults)
|
||||
if (!options.hasOwnProperty(key))
|
||||
options[key] = defaults[key];
|
||||
|
||||
if (options.suffix == null) {
|
||||
options.suffix = "";
|
||||
if (options.compress)
|
||||
options.suffix += "-min";
|
||||
if (options.noconflict)
|
||||
options.suffix += "-noconflict";
|
||||
}
|
||||
addSuffix(options);
|
||||
|
||||
if (!options.requires)
|
||||
options.requires = [options.exportModule];
|
||||
|
||||
var filters = [
|
||||
copy.filter.moduleDefines,
|
||||
filterTextPlugin,
|
||||
removeUseStrict,
|
||||
removeLicenceCmments
|
||||
];
|
||||
|
||||
if (options.noconflict) {
|
||||
filters.push(namespace(options.ns));
|
||||
if (options.exportModule)
|
||||
var exportFilter = exportAce(options.ns, options.exportModule, options.ns);
|
||||
} else if (options.exportModule) {
|
||||
var exportFilter = exportAce(options.ns, options.exportModule);
|
||||
}
|
||||
|
||||
if (options.compress)
|
||||
filters.push(copy.filter.uglifyjs);
|
||||
|
||||
var targetDir = options.targetDir + options.suffix;
|
||||
var name = options.name;
|
||||
|
||||
|
|
@ -296,10 +325,13 @@ function buildAce(options) {
|
|||
filter: [ copy.filter.moduleDefines ],
|
||||
dest: ace
|
||||
});
|
||||
|
||||
if (options.coreOnly)
|
||||
return project;
|
||||
|
||||
copy({
|
||||
source: ace,
|
||||
filter: exportFilter ? filters.concat(exportFilter) : filters,
|
||||
filter: getWriteFilters(options, "main"),
|
||||
dest: targetDir + '/' + name + ".js"
|
||||
});
|
||||
|
||||
|
|
@ -313,7 +345,7 @@ function buildAce(options) {
|
|||
project: cloneProject(project),
|
||||
require: [ 'ace/mode/' + mode ]
|
||||
}],
|
||||
filter: filters,
|
||||
filter: getWriteFilters(options, "mode"),
|
||||
dest: targetDir + "/mode-" + mode + ".js"
|
||||
});
|
||||
});
|
||||
|
|
@ -323,26 +355,29 @@ function buildAce(options) {
|
|||
project.assumeAllFilesLoaded();
|
||||
options.themes.forEach(function(theme) {
|
||||
console.log("theme " + theme);
|
||||
/*copy({
|
||||
copy({
|
||||
source: [{
|
||||
project: cloneProject(project),
|
||||
require: ["ace/theme/" + theme]
|
||||
}],
|
||||
filter: filters,
|
||||
dest: targetDir + "/theme-" + theme + ".js"
|
||||
});*/
|
||||
// use this instead, to not create separate modules for js and css
|
||||
var themePath = ACE_HOME + "/lib/ace/theme/" + theme
|
||||
var js = fs.readFileSync(themePath + ".js", "utf8");
|
||||
js = js.replace("define(", "define('ace/theme/" + theme + "', ['require', 'exports', 'module', 'ace/lib/dom'], ");
|
||||
|
||||
if (fs.existsSync(themePath + ".css", "utf8")) {
|
||||
var css = fs.readFileSync(themePath + ".css", "utf8")
|
||||
js = js.replace(/require\(.ace\/requirejs\/text!.*?\)/, quoteString(css))
|
||||
}
|
||||
filters.forEach(function(f) {js = f(js); });
|
||||
|
||||
fs.writeFileSync(targetDir + "/theme-" + theme + ".js", js);
|
||||
filter: getWriteFilters(options, "theme"),
|
||||
dest: targetDir + "/theme-" + theme.replace("_theme", "") + ".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"),
|
||||
dest: targetDir + "/ext-" + ext + ".js"
|
||||
});
|
||||
});
|
||||
|
||||
console.log('# ace key bindings ---------');
|
||||
|
|
@ -355,19 +390,12 @@ function buildAce(options) {
|
|||
project: cloneProject(project),
|
||||
require: [ 'ace/keyboard/' + keybinding ]
|
||||
}],
|
||||
filter: filters,
|
||||
filter: getWriteFilters(options, "keybinding"),
|
||||
dest: targetDir + "/keybinding-" + keybinding + ".js"
|
||||
});
|
||||
});
|
||||
|
||||
console.log('# ace worker ---------');
|
||||
|
||||
filters = [
|
||||
copy.filter.moduleDefines,
|
||||
filterTextPlugin,
|
||||
removeUseStrict,
|
||||
removeLicenceCmments
|
||||
];
|
||||
|
||||
options.workers.forEach(function(mode) {
|
||||
console.log("worker for " + mode + " mode");
|
||||
|
|
@ -386,7 +414,7 @@ function buildAce(options) {
|
|||
'ace/mode/' + mode + '_worker'
|
||||
]
|
||||
}],
|
||||
filter: filters,
|
||||
filter: getWriteFilters(options, "worker"),
|
||||
dest: worker
|
||||
});
|
||||
copy({
|
||||
|
|
@ -399,6 +427,71 @@ function buildAce(options) {
|
|||
});
|
||||
});
|
||||
|
||||
|
||||
if (options.shrinkwrap) {
|
||||
console.log('# combining files into one ---------');
|
||||
copy({
|
||||
source: { root:targetDir, exclude:/^worker\-/ },
|
||||
dest: BUILD_DIR + '/ace-min.js'
|
||||
});
|
||||
}
|
||||
|
||||
return project;
|
||||
};
|
||||
|
||||
// silence annoying messages from dryice
|
||||
var buildAce = function(fn) {
|
||||
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 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, '\\"');
|
||||
input = input.replace(/\n\s+/g, "\n");
|
||||
input = '"' + input.replace(/\n/g, '\\\n') + '"';
|
||||
textModules[module] = input;
|
||||
|
||||
return "";
|
||||
};
|
||||
detectTextModules.onRead = true;
|
||||
copy.filter.addDefines = detectTextModules;
|
||||
|
||||
function inlineTextModules(text) {
|
||||
var lastDep = "";
|
||||
return text.replace(/, *['"]ace\/requirejs\/text!(.*?)['"]|= *require\(['"](?:ace|[.\/]+)\/requirejs\/text!(.*?)['"]\)/g, function(_, dep, call) {
|
||||
if (dep) {
|
||||
if (!lastDep) {
|
||||
lastDep = dep;
|
||||
return "";
|
||||
}
|
||||
} else if (call) {
|
||||
call = textModules[lastDep];
|
||||
delete textModules[lastDep];
|
||||
lastDep = "";
|
||||
if (call)
|
||||
return "= " + call;
|
||||
}
|
||||
console.log(dep, lastDep, call);
|
||||
throw "inlining of multiple text modules is not supported";
|
||||
});
|
||||
}
|
||||
|
||||
// TODO: replace with project.clone once it is fixed in dryice
|
||||
|
|
@ -419,6 +512,7 @@ function cloneProject(project) {
|
|||
|
||||
return clone;
|
||||
}
|
||||
|
||||
function copyFileSync(srcFile, destFile) {
|
||||
var BUF_LENGTH = 64*1024,
|
||||
buf = new Buffer(BUF_LENGTH),
|
||||
|
|
@ -445,16 +539,12 @@ function quoteString(str) {
|
|||
return '"' + str.replace(/\\/, "\\\\").replace(/"/g, '\\"').replace(/\n/g, "\\\n") + '"';
|
||||
}
|
||||
|
||||
function filterTextPlugin(text) {
|
||||
return text.replace(/(['"])ace\/requirejs\/text\!/g, "$1text!");
|
||||
}
|
||||
|
||||
function removeUseStrict(text) {
|
||||
return text.replace(/['"]use strict['"];/g, "");
|
||||
}
|
||||
|
||||
function removeLicenceCmments(text) {
|
||||
return text.replace(/(;)\s*\/\*[\d\D]*?\*\//g, "$1");
|
||||
function removeLicenceComments(text) {
|
||||
return text.replace(/(?:(;)|\n)\s*\/\*[\d\D]*?\*\/|\n\s*\/\/.*/g, "$1");
|
||||
}
|
||||
|
||||
function namespace(ns) {
|
||||
|
|
|
|||
64
Readme.md
|
|
@ -1,17 +1,19 @@
|
|||
Ace (Ajax.org Cloud9 Editor)
|
||||
============================
|
||||
|
||||
_Note_: The new site at http://ace.ajax.org contains all the info below along with an embedding guide and all the other resources you need to get started with Ace.
|
||||
|
||||
Ace is a standalone code editor written in JavaScript. Our goal is to create a browser based editor that matches and extends the features, usability and performance of existing native editors such as TextMate, Vim or Eclipse. It can be easily embedded in any web page or JavaScript application. Ace is developed as the primary editor for [Cloud9 IDE](http://www.cloud9ide.com/) and the successor of the Mozilla Skywriter (Bespin) Project.
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
* Syntax highlighting
|
||||
* Syntax highlighting for over 40 languages (TextMate/Sublime/_.tmlanguage_ files can be imported)
|
||||
* Over 20 themes (TextMate/Sublime/_.tmtheme_ files can be imported)
|
||||
* Automatic indent and outdent
|
||||
* An optional command line
|
||||
* Handles huge documents (100,000 lines and more are no problem)
|
||||
* Fully customizable key bindings including VIM and Emacs modes
|
||||
* Themes (TextMate themes can be imported)
|
||||
* Handles huge documents (at last check, 4,000,000 lines is the upper limit)
|
||||
* Fully customizable key bindings including vim and Emacs modes
|
||||
* Search and replace with regular expressions
|
||||
* Highlight matching parentheses
|
||||
* Toggle between soft tabs and real tabs
|
||||
|
|
@ -19,8 +21,9 @@ Features
|
|||
* Drag and drop text using the mouse
|
||||
* Line wrapping
|
||||
* Code folding
|
||||
* Multiple selections
|
||||
* Live syntax checker (currently JavaScript/CoffeeScript/Css/XQuery)
|
||||
* Multiple cursors and selections
|
||||
* Live syntax checker (currently JavaScript/CoffeeScript/CSS/XQuery)
|
||||
* Cut, copy, and paste functionality
|
||||
|
||||
Take Ace for a spin!
|
||||
--------------------
|
||||
|
|
@ -29,15 +32,6 @@ Check out the Ace live [demo](http://ajaxorg.github.com/ace/build/kitchen-sink.h
|
|||
|
||||
If you want, you can use Ace as a textarea replacement thanks to the [Ace Bookmarklet](http://ajaxorg.github.com/ace/build/textarea/editor.html).
|
||||
|
||||
Getting the code
|
||||
----------------
|
||||
|
||||
Ace is a community project. We actively encourage and support contributions. The Ace source code is hosted on GitHub. It is released under the BSD License. This license is very simple, and is friendly to all kinds of projects, whether open source or not. Take charge of your editor and add your favorite language highlighting and keybindings!
|
||||
|
||||
```bash
|
||||
git clone git://github.com/ajaxorg/ace.git
|
||||
```
|
||||
|
||||
Embedding Ace
|
||||
-------------
|
||||
|
||||
|
|
@ -82,30 +76,28 @@ By default the editor only supports plain text mode; many other languages are av
|
|||
<script src="src/mode-javascript.js" type="text/javascript" charset="utf-8"></script>
|
||||
```
|
||||
|
||||
Then the mode can be used like this:
|
||||
The mode can then be used like this:
|
||||
|
||||
```javascript
|
||||
var JavaScriptMode = require("ace/mode/javascript").Mode;
|
||||
editor.getSession().setMode(new JavaScriptMode());
|
||||
```
|
||||
|
||||
and take a look at the one of [included](https://github.com/ajaxorg/ace-builds/blob/master/editor.html) [demos](https://github.com/ajaxorg/ace/blob/master/demo/kitchen-sink/demo.js) of how to use Ace.
|
||||
|
||||
Documentation
|
||||
-------------
|
||||
|
||||
You can find api documentation at [http://ajaxorg.github.com/ace/api/index.html](http://ajaxorg.github.com/ace/api/index.html).
|
||||
Additional usage information, including events to listen to and extending syntax highlighters, can be found [on the main Ace website](http://ace.ajax.org).
|
||||
|
||||
And a lot more sample code in the [demo app](https://github.com/ajaxorg/ace/blob/master/demo/kitchen-sink/demo.js).
|
||||
You can also find API documentation at [http://ajaxorg.github.com/ace/api/index.html](http://ajaxorg.github.com/ace/api/index.html).
|
||||
|
||||
There is also some documentation on the [wiki page](https://github.com/ajaxorg/ace/wiki).
|
||||
Also check out the sample code for the kitchen sink [demo app](https://github.com/ajaxorg/ace/blob/master/demo/kitchen-sink/demo.js).
|
||||
|
||||
If you still need help, feel free to drop a mail on the [ace mailing list](http://groups.google.com/group/ace-discuss).
|
||||
If you still need help, feel free to drop a mail on the [ace mailing list](http://groups.google.com/group/ace-discuss), or at `irc.freenode.net#ace`.
|
||||
|
||||
Running Ace
|
||||
-----------
|
||||
|
||||
After the checkout Ace works out of the box. No build step is required. To open editor with a file:/// URL see [wiki](https://github.com/ajaxorg/ace/wiki/Running-Ace-from-file:---). Or Simply start bundled mini HTTP server:
|
||||
After the checkout Ace works out of the box. No build step is required. To try it out, simply start the bundled mini HTTP server:
|
||||
|
||||
```bash
|
||||
./static.py
|
||||
|
|
@ -120,16 +112,31 @@ Or using Node.JS
|
|||
|
||||
The editor can then be opened at http://localhost:8888/kitchen-sink.html.
|
||||
|
||||
Package Ace
|
||||
To open the editor with a file:/// URL see [the wiki](https://github.com/ajaxorg/ace/wiki/Running-Ace-from-a-file:).
|
||||
|
||||
Building Ace
|
||||
-----------
|
||||
|
||||
To package Ace we use the dryice build tool developed by the Mozilla Skywriter team. (see the [wiki](https://github.com/ajaxorg/ace/wiki/Building-ace) for more details)
|
||||
You do not generally need to build ACE. The [ace-builds repository](https://github.com/ajaxorg/ace-builds/) endeavours to maintain the latest build, and you can just copy one of _src*_ subdirectories somewhere into your project.
|
||||
|
||||
However, all you need is Node.js and npm installed to package ACE. Just run `npm install` in the ace folder to install dependencies:
|
||||
|
||||
```bash
|
||||
npm install
|
||||
node ./Makefile.dryice.js
|
||||
```
|
||||
|
||||
To package Ace, we use the dryice build tool developed by the Mozilla Skywriter team. Call `node Makefile.dryice.js` on the command-line to start the packing. This build script accepts the following options
|
||||
|
||||
```bash
|
||||
-m minify build files with uglify-js
|
||||
-nc namespace require and define calls with "ace"
|
||||
-bm builds the bookmarklet version
|
||||
--target ./path specify relative path for output folder (default value is "./build")
|
||||
```
|
||||
|
||||
To generate all the files in the ace-builds repository, run `node Makefile.dryice.js full --target ../ace-builds`
|
||||
|
||||
Running the Unit Tests
|
||||
----------------------
|
||||
|
||||
|
|
@ -151,17 +158,20 @@ Continuous Integration status
|
|||
This project is tested with [Travis CI](http://travis-ci.org)
|
||||
[](http://travis-ci.org/ajaxorg/ace)
|
||||
|
||||
|
||||
Contributing
|
||||
------------
|
||||
|
||||
Ace wouldn't be what it is without contributions! Feel free to fork and improve/enhance Ace any way you want. If you feel that the editor or the Ace community will benefit from your changes, please open a pull request. To protect the interests of the Ace contributors and users we require contributors to sign a Contributors License Agreement (CLA) before we pull the changes into the main repository. Our CLA is the simplest of agreements, requiring that the contributions you make to an ajax.org project are only those you're allowed to make. This helps us significantly reduce future legal risk for everyone involved. It is easy, helps everyone, takes ten minutes, and only needs to be completed once. There are two versions of the agreement:
|
||||
Ace is a community project and wouldn't be what it is without contributions! We actively encourage and support contributions. The Ace source code is released under the BSD License. This license is very simple, and is friendly to all kinds of projects, whether open source or not. Take charge of your editor and add your favorite language highlighting and keybindings!
|
||||
|
||||
Feel free to fork and improve/enhance Ace any way you want. If you feel that the editor or the Ace community will benefit from your changes, please open a pull request. To protect the interests of the Ace contributors and users we require contributors to sign a Contributors License Agreement (CLA) before we pull the changes into the main repository. Our CLA is the simplest of agreements, requiring that the contributions you make to an ajax.org project are only those you're allowed to make. This helps us significantly reduce future legal risk for everyone involved. It is easy, helps everyone, takes ten minutes, and only needs to be completed once. There are two versions of the agreement:
|
||||
|
||||
1. [The Individual CLA](https://github.com/ajaxorg/ace/raw/master/doc/Contributor_License_Agreement-v2.pdf): use this version if you're working on an ajax.org in your spare time, or can clearly claim ownership of copyright in what you'll be submitting.
|
||||
2. [The Corporate CLA](https://github.com/ajaxorg/ace/raw/master/doc/Corporate_Contributor_License_Agreement-v2.pdf): have your corporate lawyer review and submit this if your company is going to be contributing to ajax.org projects
|
||||
|
||||
If you want to contribute to an ajax.org project please print the CLA and fill it out and sign it. Then either send it by snail mail or fax to us or send it back scanned (or as a photo) by email.
|
||||
|
||||
Email: fabian.jakobs@web.de
|
||||
Email: ace+cla@c9.io
|
||||
|
||||
Fax: +31 (0) 206388953
|
||||
|
||||
|
|
|
|||
|
|
@ -136,7 +136,7 @@
|
|||
</div><div class="description"><p>Returns the value of the distance between the left of the editor and the leftmost part of the visible content.</p>
|
||||
</div></div></div></div></article><article id="EditSession.getScrollTop" data-title="EditSession.getScrollTop (class method)" class="article"><div class="section method"><div class="memberContent"><div class="title"><i id="EditSession.getScrollTop" class="methodToggle methodClicker inactive icon-caret-right"></i><ul class="signatures"><li class="signature"><ul><li class="signature-call"><span id="EditSession.getScrollTop" class="member-name methodClicker"><span class="sigClassName">EditSession.</span><span class="sigMemberName">getScrollTop</span></span>(<span class="sigArgList"></span>)<li class="signature-returns"><ul class="argument-types"><li class="argument-type"><a href="http://www.nodemanual.org/latest/js_doc/Number.html" class="returnType " title="Number" data-id="Number">Number</a></li></ul></li></li></ul><ul class="metaInfo"></ul></li></ul></div><div class="sideToggler"><div id="ellipsis_EditSession.getScrollTop" class="ellipsis_description"><p>Returns the value of the distance between the top of the editor and the topmost part of the visible content.</p>
|
||||
</div><div class="description"><p>Returns the value of the distance between the top of the editor and the topmost part of the visible content.</p>
|
||||
</div></div></div></div></article><article id="EditSession.getSelection" data-title="EditSession.getSelection (class method)" class="article"><div class="section method"><div class="memberContent"><div class="title"><i id="EditSession.getSelection" class="methodToggle methodClicker inactive icon-caret-right"></i><ul class="signatures"><li class="signature"><ul><li class="signature-call"><span id="EditSession.getSelection" class="member-name methodClicker"><span class="sigClassName">EditSession.</span><span class="sigMemberName">getSelection</span></span>(<span class="sigArgList"></span>)<li class="signature-returns"><ul class="argument-types"><li class="argument-type"><a href="http://www.nodemanual.org/latest/js_doc/String.html" class="returnType " title="String" data-id="String">String</a></li></ul></li></li></ul><ul class="metaInfo"></ul></li></ul></div><div class="sideToggler"><div id="ellipsis_EditSession.getSelection" class="ellipsis_description"><p>Returns the string of the current selection.</p>
|
||||
</div></div></div></div></article><article id="EditSession.getSelection" data-title="EditSession.getSelection (class method)" class="article"><div class="section method"><div class="memberContent"><div class="title"><i id="EditSession.getSelection" class="methodToggle methodClicker inactive icon-caret-right"></i><ul class="signatures"><li class="signature"><ul><li class="signature-call"><span id="EditSession.getSelection" class="member-name methodClicker"><span class="sigClassName">EditSession.</span><span class="sigMemberName">getSelection</span></span>(<span class="sigArgList"></span>)<li class="signature-returns"><ul class="argument-types"><li class="argument-type"><a href="selection.html" class="returnType " title="Selection" data-id="Selection">Selection</a></li></ul></li></li></ul><ul class="metaInfo"></ul></li></ul></div><div class="sideToggler"><div id="ellipsis_EditSession.getSelection" class="ellipsis_description"><p>Returns the string of the current selection.</p>
|
||||
</div><div class="description"><p>Returns the string of the current selection.</p>
|
||||
</div></div></div></div></article><article id="EditSession.getState" data-title="EditSession.getState (class method)" class="article"><div class="section method"><div class="memberContent"><div class="title"><i id="EditSession.getState" class="methodToggle methodClicker inactive icon-caret-right"></i><ul class="signatures"><li class="signature"><ul><li class="signature-call"><span id="EditSession.getState" class="member-name methodClicker"><span class="sigClassName">EditSession.</span><span class="sigMemberName">getState</span></span>(<span class="sigArgList"><a href="http://www.nodemanual.org/latest/js_doc/Number.html" class="argument methodClicker" title="Number" data-id="Number">Number</a> row</span>)<li class="signature-returns"><ul class="argument-types"><li class="argument-type"><a href="http://www.nodemanual.org/latest/js_doc/Array.html" class="returnType " title="Array" data-id="Array">Array</a></li></ul></li></li></ul><ul class="metaInfo"><li><span class="label related-to">Related to: <obj class="related_to"> </obj></span></li></ul></li></ul></div><div class="sideToggler"><div id="ellipsis_EditSession.getState" class="ellipsis_description"><p>Returns the state of tokenization at the end of a row.</p>
|
||||
</div><div class="description"><p>Returns the state of tokenization at the end of a row.</p>
|
||||
|
|
@ -147,9 +147,9 @@
|
|||
</div><div class="description"><p>Returns the current value for tabs. If the user is using soft tabs, this will be a series of spaces (defined by <a href="#EditSession.getTabSize" class="link-short" title="EditSession.getTabSize (class method)" data-id="EditSession.getTabSize"><code>getTabSize()</code></a>); otherwise it's simply <code>'\t'</code>.</p>
|
||||
</div></div></div></div></article><article id="EditSession.getTextRange" data-title="EditSession.getTextRange (class method)" class="article"><div class="section method"><div class="memberContent"><div class="title"><i id="EditSession.getTextRange" class="methodToggle methodClicker inactive icon-caret-right"></i><ul class="signatures"><li class="signature"><ul><li class="signature-call"><span id="EditSession.getTextRange" class="member-name methodClicker"><span class="sigClassName">EditSession.</span><span class="sigMemberName">getTextRange</span></span>(<span class="sigArgList"><a href="http://www.nodemanual.org/latest/js_doc/String.html" class="argument methodClicker" title="String" data-id="String">String</a> range</span>)<li class="signature-returns"><ul class="argument-types"><li class="argument-type"><a href="http://www.nodemanual.org/latest/js_doc/Array.html" class="returnType " title="Array" data-id="Array">Array</a></li></ul></li></li></ul><ul class="metaInfo"><li><span class="label related-to">Related to: <obj class="related_to"> </obj></span></li></ul></li></ul></div><div class="sideToggler"><div id="ellipsis_EditSession.getTextRange" class="ellipsis_description"><p>Given a range within the document, this function returns all the text within that range as a single string.</p>
|
||||
</div><div class="description"><p>Given a range within the document, this function returns all the text within that range as a single string.</p>
|
||||
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">range</td><td class="argType" "><a href="http://www.nodemanual.org/latest/js_doc/String.html" class="" title="String" data-id="String">String</a></td><td class="argDescription "><p>Required. The range to work with</p>
|
||||
</td></tr></table></div></div></div></div></article><article id="EditSession.getTokenAt" data-title="EditSession.getTokenAt (class method)" class="article"><div class="section method"><div class="memberContent"><div class="title"><i id="EditSession.getTokenAt" class="methodToggle methodClicker inactive icon-caret-right"></i><ul class="signatures"><li class="signature"><ul><li class="signature-call"><span id="EditSession.getTokenAt" class="member-name methodClicker"><span class="sigClassName">EditSession.</span><span class="sigMemberName">getTokenAt</span></span>(<span class="sigArgList"><a href="http://www.nodemanual.org/latest/js_doc/Number.html" class="argument methodClicker" title="Number" data-id="Number">Number</a> row, <a href="http://www.nodemanual.org/latest/js_doc/Number.html" class="argument methodClicker" title="Number" data-id="Number">Number</a> column</span>)<li class="signature-returns"><ul class="argument-types"><li class="argument-type"><a href="http://www.nodemanual.org/latest/js_doc/Array.html" class="returnType " title="Array" data-id="Array">Array</a></li></ul></li></li></ul><ul class="metaInfo"></ul></li></ul></div><div class="sideToggler"><div id="ellipsis_EditSession.getTokenAt" class="ellipsis_description"><p>Returns an array of tokens at the indicated row and column.</p>
|
||||
</div><div class="description"><p>Returns an array of tokens at the indicated row and column.</p>
|
||||
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">range</td><td class="argType" "><a href="range.html" class="" title="Range" data-id="Range">Range</a></td><td class="argDescription "><p>Required. The range to work with</p>
|
||||
</td></tr></table></div></div></div></div></article><article id="EditSession.getTokenAt" data-title="EditSession.getTokenAt (class method)" class="article"><div class="section method"><div class="memberContent"><div class="title"><i id="EditSession.getTokenAt" class="methodToggle methodClicker inactive icon-caret-right"></i><ul class="signatures"><li class="signature"><ul><li class="signature-call"><span id="EditSession.getTokenAt" class="member-name methodClicker"><span class="sigClassName">EditSession.</span><span class="sigMemberName">getTokenAt</span></span>(<span class="sigArgList"><a href="http://www.nodemanual.org/latest/js_doc/Number.html" class="argument methodClicker" title="Number" data-id="Number">Number</a> row, <a href="http://www.nodemanual.org/latest/js_doc/Number.html" class="argument methodClicker" title="Number" data-id="Number">Number</a> column</span>)<li class="signature-returns"><ul class="argument-types"><li class="argument-type"><a href="http://www.nodemanual.org/latest/js_doc/Array.html" class="returnType " title="Array" data-id="Array">Array</a></li></ul></li></li></ul><ul class="metaInfo"></ul></li></ul></div><div class="sideToggler"><div id="ellipsis_EditSession.getTokenAt" class="ellipsis_description"><p>Returns an object indicating the token at the current row. The object has two properties: <code>index</code> and <code>start</code>.</p>
|
||||
</div><div class="description"><p>Returns an object indicating the token at the current row. The object has two properties: <code>index</code> and <code>start</code>.</p>
|
||||
<h4>Arguments</h4><table class="argumentTable argument-list table table-striped table-bordered"><tr class="argumentRow "><td class="argName ">row</td><td class="argType" "><a href="http://www.nodemanual.org/latest/js_doc/Number.html" class="" title="Number" data-id="Number">Number</a></td><td class="argDescription "><p>Required. The row number to retrieve from</p>
|
||||
</td></tr><tr class="argumentRow "><td class="argName ">column</td><td class="argType" "><a href="http://www.nodemanual.org/latest/js_doc/Number.html" class="" title="Number" data-id="Number">Number</a></td><td class="argDescription "><p>Required. The column number to retrieve from</p>
|
||||
</td></tr></table></div></div></div></div></article><article id="EditSession.getTokens" data-title="EditSession.getTokens (class method)" class="article"><div class="section method"><div class="memberContent"><div class="title"><i id="EditSession.getTokens" class="methodToggle methodClicker inactive icon-caret-right"></i><ul class="signatures"><li class="signature"><ul><li class="signature-call"><span id="EditSession.getTokens" class="member-name methodClicker"><span class="sigClassName">EditSession.</span><span class="sigMemberName">getTokens</span></span>(<span class="sigArgList"><a href="http://www.nodemanual.org/latest/js_doc/Number.html" class="argument methodClicker" title="Number" data-id="Number">Number</a> row</span>)<li class="signature-returns"><ul class="argument-types"><li class="argument-type"><a href="http://www.nodemanual.org/latest/js_doc/Array.html" class="returnType " title="Array" data-id="Array">Array</a></li></ul></li></li></ul><ul class="metaInfo"><li><span class="label related-to">Related to: <obj class="related_to"> </obj></span></li></ul></li></ul></div><div class="sideToggler"><div id="ellipsis_EditSession.getTokens" class="ellipsis_description"><p>Starts tokenizing at the row indicated. Returns a list of objects of the tokenized rows.</p>
|
||||
|
|
|
|||
|
|
@ -147,6 +147,19 @@ form.navbar-search {
|
|||
|
||||
form.navbar-search .search-query {
|
||||
background-color: #FFFFFF;
|
||||
border-color: #999;
|
||||
-webkit-transition: border 0.3s;
|
||||
-moz-transition: border 0.3s;
|
||||
font-size: 14px;
|
||||
line-height: 16px;
|
||||
}
|
||||
|
||||
form.navbar-search .search-query:focus, form.navbar-search .search-query:active {
|
||||
border: 1px solid #666;
|
||||
}
|
||||
|
||||
.navbar-search .search-query:focus, .navbar-search .search-query.focused {
|
||||
padding: 4px 9px;
|
||||
}
|
||||
|
||||
h3.api_title {
|
||||
|
|
@ -154,24 +167,28 @@ h3.api_title {
|
|||
}
|
||||
|
||||
ul.menu {
|
||||
margin-left: 16px;
|
||||
margin-left: 2px;
|
||||
}
|
||||
|
||||
.menu li {
|
||||
list-style-image: url(../images/menu_disc.png);
|
||||
margin-bottom: 3px;
|
||||
font-weight : 700;
|
||||
margin-bottom: 4px;
|
||||
font-weight: 700;
|
||||
padding-left: 10px;
|
||||
margin-left: 0;
|
||||
}
|
||||
|
||||
.menu li .menu-item a.menuLink, .menu li .menu-item span.menuLink {
|
||||
color: #262626;
|
||||
color: #3E7096;
|
||||
font-weight: 100;
|
||||
}
|
||||
.menuTwo {
|
||||
margin-bottom: 5px;
|
||||
margin-top: 2px;
|
||||
}
|
||||
.menuTwo li .menu-item a.menuLink {
|
||||
color: #262626;
|
||||
color: #3E7096;
|
||||
font-weight: 100;
|
||||
}
|
||||
|
||||
/* need specificity to "beat" the above colors */
|
||||
|
|
@ -281,9 +298,14 @@ ul.menu {
|
|||
.srolled .membersContent {
|
||||
/*top : 0;*/
|
||||
width: 625px;
|
||||
padding-left: 330px;
|
||||
padding-left: 327px;
|
||||
margin : 0 auto 0 auto;
|
||||
}
|
||||
|
||||
.srolled ul.nav {
|
||||
padding-right: 10px;
|
||||
}
|
||||
|
||||
.membersBackground {
|
||||
/* background-color: white;
|
||||
position: fixed;
|
||||
|
|
@ -480,7 +502,6 @@ ul.tabs .double ul, ul.tabs .triple ul, ul.tabs .quad ul{
|
|||
height: 100%;
|
||||
}
|
||||
.content .row {
|
||||
width: 1060px;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
|
|
@ -492,8 +513,8 @@ header.filler {
|
|||
}
|
||||
|
||||
.centerpiece {
|
||||
background: url(../images/sidebar_border.png) repeat-y 230px 0;
|
||||
min-height: 100%;
|
||||
padding: 20px 0;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -510,7 +531,7 @@ header.filler {
|
|||
}
|
||||
|
||||
#sidebar {
|
||||
margin-top: 9px;
|
||||
margin-top: 5px;
|
||||
/*background: url(../images/sidebar-border.png) repeat-y right 0;*/
|
||||
margin-left: 12px;
|
||||
/* width: 280px;*/
|
||||
|
|
@ -535,6 +556,9 @@ header.filler {
|
|||
#documentation article.article {
|
||||
border-top: 1px solid #e9e9e9;
|
||||
padding: 16px 10px 2px;
|
||||
-webkit-transition: padding 0.2s;
|
||||
-moz-transition: padding 0.2s;
|
||||
-o-transition: padding 0.2s;
|
||||
}
|
||||
|
||||
#documentation h3.sectionHeader + article.article {
|
||||
|
|
@ -781,7 +805,7 @@ li.signature {
|
|||
#documentation i.methodToggle {
|
||||
cursor: pointer;
|
||||
color: #9f9f9f;
|
||||
padding-top: 5px;
|
||||
padding-top: 2px;
|
||||
float: left;
|
||||
}
|
||||
#documentation i.methodToggle.methodToggleHover {
|
||||
|
|
@ -802,6 +826,7 @@ li.signature {
|
|||
|
||||
/* Opera */
|
||||
-o-transform: rotate(45deg);
|
||||
padding-top: 9px;
|
||||
}
|
||||
|
||||
#documentation h3.sectionHeader {
|
||||
|
|
|
|||
92
api/resources/javascripts/bootstrap-dropdown.js
vendored
|
|
@ -1,92 +0,0 @@
|
|||
/* ============================================================
|
||||
* bootstrap-dropdown.js v2.0.2
|
||||
* http://twitter.github.com/bootstrap/javascript.html#dropdowns
|
||||
* ============================================================
|
||||
* Copyright 2012 Twitter, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ============================================================ */
|
||||
|
||||
|
||||
!function( $ ){
|
||||
|
||||
"use strict"
|
||||
|
||||
/* DROPDOWN CLASS DEFINITION
|
||||
* ========================= */
|
||||
|
||||
var toggle = '[data-toggle="dropdown"]'
|
||||
, Dropdown = function ( element ) {
|
||||
var $el = $(element).on('click.dropdown.data-api', this.toggle)
|
||||
$('html').on('click.dropdown.data-api', function () {
|
||||
$el.parent().removeClass('open')
|
||||
})
|
||||
}
|
||||
|
||||
Dropdown.prototype = {
|
||||
|
||||
constructor: Dropdown
|
||||
|
||||
, toggle: function ( e ) {
|
||||
var $this = $(this)
|
||||
, selector = $this.attr('data-target')
|
||||
, $parent
|
||||
, isActive
|
||||
|
||||
if (!selector) {
|
||||
selector = $this.attr('href')
|
||||
selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
|
||||
}
|
||||
|
||||
$parent = $(selector)
|
||||
$parent.length || ($parent = $this.parent())
|
||||
|
||||
isActive = $parent.hasClass('open')
|
||||
|
||||
clearMenus()
|
||||
!isActive && $parent.toggleClass('open')
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function clearMenus() {
|
||||
$(toggle).parent().removeClass('open')
|
||||
}
|
||||
|
||||
|
||||
/* DROPDOWN PLUGIN DEFINITION
|
||||
* ========================== */
|
||||
|
||||
$.fn.dropdown = function ( option ) {
|
||||
return this.each(function () {
|
||||
var $this = $(this)
|
||||
, data = $this.data('dropdown')
|
||||
if (!data) $this.data('dropdown', (data = new Dropdown(this)))
|
||||
if (typeof option == 'string') data[option].call($this)
|
||||
})
|
||||
}
|
||||
|
||||
$.fn.dropdown.Constructor = Dropdown
|
||||
|
||||
|
||||
/* APPLY TO STANDARD DROPDOWN ELEMENTS
|
||||
* =================================== */
|
||||
|
||||
$(function () {
|
||||
$('html').on('click.dropdown.data-api', clearMenus)
|
||||
$('body').on('click.dropdown.data-api', toggle, Dropdown.prototype.toggle)
|
||||
})
|
||||
|
||||
}( window.jQuery );
|
||||
135
api/resources/javascripts/bootstrap-tab.js
vendored
|
|
@ -1,135 +0,0 @@
|
|||
/* ========================================================
|
||||
* bootstrap-tab.js v2.1.1
|
||||
* http://twitter.github.com/bootstrap/javascript.html#tabs
|
||||
* ========================================================
|
||||
* Copyright 2012 Twitter, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ======================================================== */
|
||||
|
||||
|
||||
!function ($) {
|
||||
|
||||
"use strict"; // jshint ;_;
|
||||
|
||||
|
||||
/* TAB CLASS DEFINITION
|
||||
* ==================== */
|
||||
|
||||
var Tab = function (element) {
|
||||
this.element = $(element)
|
||||
}
|
||||
|
||||
Tab.prototype = {
|
||||
|
||||
constructor: Tab
|
||||
|
||||
, show: function () {
|
||||
var $this = this.element
|
||||
, $ul = $this.closest('ul:not(.dropdown-menu)')
|
||||
, selector = $this.attr('data-target')
|
||||
, previous
|
||||
, $target
|
||||
, e
|
||||
|
||||
if (!selector) {
|
||||
selector = $this.attr('href')
|
||||
selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
|
||||
}
|
||||
|
||||
if ( $this.parent('li').hasClass('active') ) return
|
||||
|
||||
previous = $ul.find('.active a').last()[0]
|
||||
|
||||
e = $.Event('show', {
|
||||
relatedTarget: previous
|
||||
})
|
||||
|
||||
$this.trigger(e)
|
||||
|
||||
if (e.isDefaultPrevented()) return
|
||||
|
||||
$target = $(selector)
|
||||
|
||||
this.activate($this.parent('li'), $ul)
|
||||
this.activate($target, $target.parent(), function () {
|
||||
$this.trigger({
|
||||
type: 'shown'
|
||||
, relatedTarget: previous
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
, activate: function ( element, container, callback) {
|
||||
var $active = container.find('> .active')
|
||||
, transition = callback
|
||||
&& $.support.transition
|
||||
&& $active.hasClass('fade')
|
||||
|
||||
function next() {
|
||||
$active
|
||||
.removeClass('active')
|
||||
.find('> .dropdown-menu > .active')
|
||||
.removeClass('active')
|
||||
|
||||
element.addClass('active')
|
||||
|
||||
if (transition) {
|
||||
element[0].offsetWidth // reflow for transition
|
||||
element.addClass('in')
|
||||
} else {
|
||||
element.removeClass('fade')
|
||||
}
|
||||
|
||||
if ( element.parent('.dropdown-menu') ) {
|
||||
element.closest('li.dropdown').addClass('active')
|
||||
}
|
||||
|
||||
callback && callback()
|
||||
}
|
||||
|
||||
transition ?
|
||||
$active.one($.support.transition.end, next) :
|
||||
next()
|
||||
|
||||
$active.removeClass('in')
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* TAB PLUGIN DEFINITION
|
||||
* ===================== */
|
||||
|
||||
$.fn.tab = function ( option ) {
|
||||
return this.each(function () {
|
||||
var $this = $(this)
|
||||
, data = $this.data('tab')
|
||||
if (!data) $this.data('tab', (data = new Tab(this)))
|
||||
if (typeof option == 'string') data[option]()
|
||||
})
|
||||
}
|
||||
|
||||
$.fn.tab.Constructor = Tab
|
||||
|
||||
|
||||
/* TAB DATA-API
|
||||
* ============ */
|
||||
|
||||
$(function () {
|
||||
$('body').on('click.tab.data-api', '[data-toggle="tab"], [data-toggle="pill"]', function (e) {
|
||||
e.preventDefault()
|
||||
$(this).tab('show')
|
||||
})
|
||||
})
|
||||
|
||||
}(window.jQuery);
|
||||
389
api/resources/javascripts/bootstrap.js
vendored
Normal file
|
|
@ -0,0 +1,389 @@
|
|||
/* ============================================================
|
||||
* bootstrap-dropdown.js v2.1.1
|
||||
* http://twitter.github.com/bootstrap/javascript.html#dropdowns
|
||||
* ============================================================
|
||||
* Copyright 2012 Twitter, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ============================================================ */
|
||||
|
||||
|
||||
!function ($) {
|
||||
|
||||
"use strict"; // jshint ;_;
|
||||
|
||||
|
||||
/* DROPDOWN CLASS DEFINITION
|
||||
* ========================= */
|
||||
|
||||
var toggle = '[data-toggle=dropdown]'
|
||||
, Dropdown = function (element) {
|
||||
var $el = $(element).on('click.dropdown.data-api', this.toggle)
|
||||
$('html').on('click.dropdown.data-api', function () {
|
||||
$el.parent().removeClass('open')
|
||||
})
|
||||
}
|
||||
|
||||
Dropdown.prototype = {
|
||||
|
||||
constructor: Dropdown
|
||||
|
||||
, toggle: function (e) {
|
||||
var $this = $(this)
|
||||
, $parent
|
||||
, isActive
|
||||
|
||||
if ($this.is('.disabled, :disabled')) return
|
||||
|
||||
$parent = getParent($this)
|
||||
|
||||
isActive = $parent.hasClass('open')
|
||||
|
||||
clearMenus()
|
||||
|
||||
if (!isActive) {
|
||||
$parent.toggleClass('open')
|
||||
$this.focus()
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
, keydown: function (e) {
|
||||
var $this
|
||||
, $items
|
||||
, $active
|
||||
, $parent
|
||||
, isActive
|
||||
, index
|
||||
|
||||
if (!/(38|40|27)/.test(e.keyCode)) return
|
||||
|
||||
$this = $(this)
|
||||
|
||||
e.preventDefault()
|
||||
e.stopPropagation()
|
||||
|
||||
if ($this.is('.disabled, :disabled')) return
|
||||
|
||||
$parent = getParent($this)
|
||||
|
||||
isActive = $parent.hasClass('open')
|
||||
|
||||
if (!isActive || (isActive && e.keyCode == 27)) return $this.click()
|
||||
|
||||
$items = $('[role=menu] li:not(.divider) a', $parent)
|
||||
|
||||
if (!$items.length) return
|
||||
|
||||
index = $items.index($items.filter(':focus'))
|
||||
|
||||
if (e.keyCode == 38 && index > 0) index-- // up
|
||||
if (e.keyCode == 40 && index < $items.length - 1) index++ // down
|
||||
if (!~index) index = 0
|
||||
|
||||
$items
|
||||
.eq(index)
|
||||
.focus()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function clearMenus() {
|
||||
getParent($(toggle))
|
||||
.removeClass('open')
|
||||
}
|
||||
|
||||
function getParent($this) {
|
||||
var selector = $this.attr('data-target')
|
||||
, $parent
|
||||
|
||||
if (!selector) {
|
||||
selector = $this.attr('href')
|
||||
selector = selector && /#/.test(selector) && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
|
||||
}
|
||||
|
||||
$parent = $(selector)
|
||||
$parent.length || ($parent = $this.parent())
|
||||
|
||||
return $parent
|
||||
}
|
||||
|
||||
|
||||
/* DROPDOWN PLUGIN DEFINITION
|
||||
* ========================== */
|
||||
|
||||
$.fn.dropdown = function (option) {
|
||||
return this.each(function () {
|
||||
var $this = $(this)
|
||||
, data = $this.data('dropdown')
|
||||
if (!data) $this.data('dropdown', (data = new Dropdown(this)))
|
||||
if (typeof option == 'string') data[option].call($this)
|
||||
})
|
||||
}
|
||||
|
||||
$.fn.dropdown.Constructor = Dropdown
|
||||
|
||||
|
||||
/* APPLY TO STANDARD DROPDOWN ELEMENTS
|
||||
* =================================== */
|
||||
|
||||
$(function () {
|
||||
$('html')
|
||||
.on('click.dropdown.data-api touchstart.dropdown.data-api', clearMenus)
|
||||
$('body')
|
||||
.on('click.dropdown touchstart.dropdown.data-api', '.dropdown form', function (e) { e.stopPropagation() })
|
||||
.on('click.dropdown.data-api touchstart.dropdown.data-api' , toggle, Dropdown.prototype.toggle)
|
||||
.on('keydown.dropdown.data-api touchstart.dropdown.data-api', toggle + ', [role=menu]' , Dropdown.prototype.keydown)
|
||||
})
|
||||
|
||||
}(window.jQuery);
|
||||
/* ========================================================
|
||||
* bootstrap-tab.js v2.1.1
|
||||
* http://twitter.github.com/bootstrap/javascript.html#tabs
|
||||
* ========================================================
|
||||
* Copyright 2012 Twitter, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ======================================================== */
|
||||
|
||||
|
||||
!function ($) {
|
||||
|
||||
"use strict"; // jshint ;_;
|
||||
|
||||
|
||||
/* TAB CLASS DEFINITION
|
||||
* ==================== */
|
||||
|
||||
var Tab = function (element) {
|
||||
this.element = $(element)
|
||||
}
|
||||
|
||||
Tab.prototype = {
|
||||
|
||||
constructor: Tab
|
||||
|
||||
, show: function () {
|
||||
var $this = this.element
|
||||
, $ul = $this.closest('ul:not(.dropdown-menu)')
|
||||
, selector = $this.attr('data-target')
|
||||
, previous
|
||||
, $target
|
||||
, e
|
||||
|
||||
if (!selector) {
|
||||
selector = $this.attr('href')
|
||||
selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
|
||||
}
|
||||
|
||||
if ( $this.parent('li').hasClass('active') ) return
|
||||
|
||||
previous = $ul.find('.active a').last()[0]
|
||||
|
||||
e = $.Event('show', {
|
||||
relatedTarget: previous
|
||||
})
|
||||
|
||||
$this.trigger(e)
|
||||
|
||||
if (e.isDefaultPrevented()) return
|
||||
|
||||
$target = $(selector)
|
||||
|
||||
this.activate($this.parent('li'), $ul)
|
||||
this.activate($target, $target.parent(), function () {
|
||||
$this.trigger({
|
||||
type: 'shown'
|
||||
, relatedTarget: previous
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
, activate: function ( element, container, callback) {
|
||||
var $active = container.find('> .active')
|
||||
, transition = callback
|
||||
&& $.support.transition
|
||||
&& $active.hasClass('fade')
|
||||
|
||||
function next() {
|
||||
$active
|
||||
.removeClass('active')
|
||||
.find('> .dropdown-menu > .active')
|
||||
.removeClass('active')
|
||||
|
||||
element.addClass('active')
|
||||
|
||||
if (transition) {
|
||||
element[0].offsetWidth // reflow for transition
|
||||
element.addClass('in')
|
||||
} else {
|
||||
element.removeClass('fade')
|
||||
}
|
||||
|
||||
if ( element.parent('.dropdown-menu') ) {
|
||||
element.closest('li.dropdown').addClass('active')
|
||||
}
|
||||
|
||||
callback && callback()
|
||||
}
|
||||
|
||||
transition ?
|
||||
$active.one($.support.transition.end, next) :
|
||||
next()
|
||||
|
||||
$active.removeClass('in')
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* TAB PLUGIN DEFINITION
|
||||
* ===================== */
|
||||
|
||||
$.fn.tab = function ( option ) {
|
||||
return this.each(function () {
|
||||
var $this = $(this)
|
||||
, data = $this.data('tab')
|
||||
if (!data) $this.data('tab', (data = new Tab(this)))
|
||||
if (typeof option == 'string') data[option]()
|
||||
})
|
||||
}
|
||||
|
||||
$.fn.tab.Constructor = Tab
|
||||
|
||||
|
||||
/* TAB DATA-API
|
||||
* ============ */
|
||||
|
||||
$(function () {
|
||||
$('body').on('click.tab.data-api', '[data-toggle="tab"], [data-toggle="pill"]', function (e) {
|
||||
e.preventDefault()
|
||||
$(this).tab('show')
|
||||
})
|
||||
})
|
||||
|
||||
}(window.jQuery);
|
||||
/* ==========================================================
|
||||
* bootstrap-affix.js v2.1.1
|
||||
* http://twitter.github.com/bootstrap/javascript.html#affix
|
||||
* ==========================================================
|
||||
* Copyright 2012 Twitter, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ========================================================== */
|
||||
|
||||
|
||||
!function ($) {
|
||||
|
||||
"use strict"; // jshint ;_;
|
||||
|
||||
|
||||
/* AFFIX CLASS DEFINITION
|
||||
* ====================== */
|
||||
|
||||
var Affix = function (element, options) {
|
||||
this.options = $.extend({}, $.fn.affix.defaults, options)
|
||||
this.$window = $(window).on('scroll.affix.data-api', $.proxy(this.checkPosition, this))
|
||||
this.$element = $(element)
|
||||
this.checkPosition()
|
||||
}
|
||||
|
||||
Affix.prototype.checkPosition = function () {
|
||||
if (!this.$element.is(':visible')) return
|
||||
|
||||
var scrollHeight = $(document).height()
|
||||
, scrollTop = this.$window.scrollTop()
|
||||
, position = this.$element.offset()
|
||||
, offset = this.options.offset
|
||||
, offsetBottom = offset.bottom
|
||||
, offsetTop = offset.top
|
||||
, reset = 'affix affix-top affix-bottom'
|
||||
, affix
|
||||
|
||||
if (typeof offset != 'object') offsetBottom = offsetTop = offset
|
||||
if (typeof offsetTop == 'function') offsetTop = offset.top()
|
||||
if (typeof offsetBottom == 'function') offsetBottom = offset.bottom()
|
||||
|
||||
affix = this.unpin != null && (scrollTop + this.unpin <= position.top) ?
|
||||
false : offsetBottom != null && (position.top + this.$element.height() >= scrollHeight - offsetBottom) ?
|
||||
'bottom' : offsetTop != null && scrollTop <= offsetTop ?
|
||||
'top' : false
|
||||
|
||||
if (this.affixed === affix) return
|
||||
|
||||
this.affixed = affix
|
||||
this.unpin = affix == 'bottom' ? position.top - scrollTop : null
|
||||
|
||||
this.$element.removeClass(reset).addClass('affix' + (affix ? '-' + affix : ''))
|
||||
}
|
||||
|
||||
|
||||
/* AFFIX PLUGIN DEFINITION
|
||||
* ======================= */
|
||||
|
||||
$.fn.affix = function (option) {
|
||||
return this.each(function () {
|
||||
var $this = $(this)
|
||||
, data = $this.data('affix')
|
||||
, options = typeof option == 'object' && option
|
||||
if (!data) $this.data('affix', (data = new Affix(this, options)))
|
||||
if (typeof option == 'string') data[option]()
|
||||
})
|
||||
}
|
||||
|
||||
$.fn.affix.Constructor = Affix
|
||||
|
||||
$.fn.affix.defaults = {
|
||||
offset: 0
|
||||
}
|
||||
|
||||
|
||||
/* AFFIX DATA-API
|
||||
* ============== */
|
||||
|
||||
$(window).on('load', function () {
|
||||
$('[data-spy="affix"]').each(function () {
|
||||
var $spy = $(this)
|
||||
, data = $spy.data()
|
||||
|
||||
data.offset = data.offset || {}
|
||||
|
||||
data.offsetBottom && (data.offset.bottom = data.offsetBottom)
|
||||
data.offsetTop && (data.offset.top = data.offsetTop)
|
||||
|
||||
$spy.affix(data)
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
}(window.jQuery);
|
||||
|
|
@ -28,7 +28,10 @@ function setupClicker() {
|
|||
if (!$article.hasClass('methodToggleOpen') || this.force) {
|
||||
$article.addClass('methodToggleOpen');
|
||||
$arrow.removeClass('inactive').addClass('active');
|
||||
|
||||
|
||||
if (!$arrow[0])
|
||||
return;
|
||||
|
||||
var data = $arrow[0].id.replace(/^js_/, "");
|
||||
//var state = {};
|
||||
//state.section = data;
|
||||
|
|
|
|||
|
|
@ -1,22 +1,17 @@
|
|||
function setupDisqus() {
|
||||
function setupDisqus(href) {
|
||||
var disqus_shortname = 'aceapi';
|
||||
var dsqId = "disqusScript";
|
||||
|
||||
//var paths = window.location.pathname.split("/");
|
||||
//var fileName = paths[paths.length - 2] + "/" + paths[paths.length - 1];
|
||||
|
||||
//var disqus_identifier = fileName;
|
||||
|
||||
var lochash = location.hash.substr(1);
|
||||
var disqus_identifier = "api/" + (lochash.substr(lochash.indexOf('api=')).split('&')[0].split('=')[1] || "index") + ".html";
|
||||
var disqus_identifier = href.substring(2);
|
||||
|
||||
(function() {
|
||||
if (document.getElementById(dsqId))
|
||||
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).removeChild(document.getElementById(dsqId));
|
||||
|
||||
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
|
||||
dsq.src = 'https://' + disqus_shortname + '.disqus.com/embed.js';
|
||||
dsq.id="disqusScript";
|
||||
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
|
||||
if (document.getElementById("disqusScript") === null) {
|
||||
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
|
||||
dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
|
||||
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
|
||||
}
|
||||
})();
|
||||
}
|
||||
2
build
|
|
@ -1 +1 @@
|
|||
Subproject commit c2f3abb2ecd3287f90225d804132f0fd26cfb639
|
||||
Subproject commit 6149ca6b148e878d4c1341d4675ca3597d78dbdd
|
||||
|
|
@ -55,201 +55,18 @@ var Editor = require("ace/editor").Editor;
|
|||
var MultiSelect = require("ace/multi_select").MultiSelect;
|
||||
|
||||
// workers do not work for file:
|
||||
if (location.protocol == "file:")
|
||||
EditSession.prototype.$useWorker = false;
|
||||
/* if (location.protocol == "file:")
|
||||
EditSession.prototype.$useWorker = false; */
|
||||
|
||||
/************** modes ***********************/
|
||||
var modes = [];
|
||||
function getModeFromPath(path) {
|
||||
var mode = modesByName.text;
|
||||
for (var i = 0; i < modes.length; i++) {
|
||||
if (modes[i].supportsFile(path)) {
|
||||
mode = modes[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
return mode;
|
||||
};
|
||||
|
||||
var Mode = function(name, desc, extensions) {
|
||||
this.name = name;
|
||||
this.desc = desc;
|
||||
this.mode = "ace/mode/" + name;
|
||||
this.extRe = new RegExp("^.*\\.(" + extensions + ")$", "g");
|
||||
};
|
||||
|
||||
Mode.prototype.supportsFile = function(filename) {
|
||||
return filename.match(this.extRe);
|
||||
};
|
||||
|
||||
var modesByName = {
|
||||
c9search: ["C9Search" , "c9search_results"],
|
||||
coffee: ["CoffeeScript" , "coffee|^Cakefile"],
|
||||
coldfusion: ["ColdFusion" , "cfm"],
|
||||
csharp: ["C#" , "cs"],
|
||||
css: ["CSS" , "css"],
|
||||
diff: ["Diff" , "diff|patch"],
|
||||
glsl: ["Glsl" , "glsl|frag|vert"],
|
||||
golang: ["Go" , "go"],
|
||||
groovy: ["Groovy" , "groovy"],
|
||||
haxe: ["haXe" , "hx"],
|
||||
html: ["HTML" , "htm|html|xhtml"],
|
||||
c_cpp: ["C/C++" , "c|cc|cpp|cxx|h|hh|hpp"],
|
||||
clojure: ["Clojure" , "clj"],
|
||||
jade: ["Jade" , "jade"],
|
||||
java: ["Java" , "java"],
|
||||
javascript: ["JavaScript" , "js"],
|
||||
json: ["JSON" , "json"],
|
||||
jsx: ["JSX" , "jsx"],
|
||||
latex: ["LaTeX" , "latex|tex|ltx|bib"],
|
||||
less: ["LESS" , "less"],
|
||||
liquid: ["Liquid" , "liquid"],
|
||||
lua: ["Lua" , "lua"],
|
||||
luapage: ["LuaPage" , "lp"], // http://keplerproject.github.com/cgilua/manual.html#templates
|
||||
markdown: ["Markdown" , "md|markdown"],
|
||||
ocaml: ["OCaml" , "ml|mli"],
|
||||
perl: ["Perl" , "pl|pm"],
|
||||
pgsql: ["pgSQL" , "pgsql"],
|
||||
php: ["PHP" , "php|phtml"],
|
||||
powershell: ["Powershell" , "ps1"],
|
||||
python: ["Python" , "py"],
|
||||
ruby: ["Ruby" , "ru|gemspec|rake|rb"],
|
||||
scad: ["OpenSCAD" , "scad"],
|
||||
scala: ["Scala" , "scala"],
|
||||
scss: ["SCSS" , "scss|sass"],
|
||||
sh: ["SH" , "sh|bash|bat"],
|
||||
sql: ["SQL" , "sql"],
|
||||
svg: ["SVG" , "svg"],
|
||||
tcl: ["Tcl" , "tcl"],
|
||||
text: ["Text" , "txt"],
|
||||
textile: ["Textile" , "textile"],
|
||||
xml: ["XML" , "xml|rdf|rss|wsdl|xslt|atom|mathml|mml|xul|xbl"],
|
||||
xquery: ["XQuery" , "xq"],
|
||||
yaml: ["YAML" , "yaml"]
|
||||
};
|
||||
|
||||
for (var name in modesByName) {
|
||||
var mode = modesByName[name];
|
||||
mode = new Mode(name, mode[0], mode[1])
|
||||
modesByName[name] = mode;
|
||||
modes.push(mode);
|
||||
}
|
||||
|
||||
|
||||
/*********** demo documents ***************************/
|
||||
var fileCache = {};
|
||||
|
||||
function initDoc(file, path, doc) {
|
||||
if (doc.prepare)
|
||||
file = doc.prepare(file);
|
||||
|
||||
var session = new EditSession(file);
|
||||
session.setUndoManager(new UndoManager());
|
||||
doc.session = session;
|
||||
doc.path = path;
|
||||
if (doc.wrapped) {
|
||||
session.setUseWrapMode(true);
|
||||
session.setWrapLimitRange(80, 80);
|
||||
}
|
||||
var mode = getModeFromPath(path)
|
||||
session.modeName = mode.name;
|
||||
session.setMode(mode.mode);
|
||||
}
|
||||
|
||||
|
||||
function makeHuge(txt) {
|
||||
for (var i = 0; i < 5; i++)
|
||||
txt += txt;
|
||||
return txt
|
||||
}
|
||||
|
||||
var docs = {
|
||||
"docs/javascript.js": "JavaScript",
|
||||
"docs/clojure.clj": "Clojure",
|
||||
"docs/coffeescript.coffee": "Coffeescript",
|
||||
"docs/coldfusion.cfm": "ColdFusion",
|
||||
"docs/cpp.cpp": "C/C++",
|
||||
"docs/csharp.cs": "C#",
|
||||
"docs/css.css": "CSS",
|
||||
"docs/diff.diff": "Diff",
|
||||
"docs/glsl.glsl": "Glsl",
|
||||
"docs/golang.go": "Go",
|
||||
"docs/groovy.groovy": "Groovy",
|
||||
"docs/Haxe.hx": "haXe",
|
||||
"docs/html.html": "HTML",
|
||||
"docs/jade.jade": "Jade",
|
||||
"docs/java.java": "Java",
|
||||
"docs/json.json": "JSON",
|
||||
"docs/jsx.jsx": "JSX",
|
||||
"docs/latex.tex": {name: "LaTeX", wrapped: true},
|
||||
"docs/less.less": "LESS",
|
||||
"docs/liquid.liquid": "Liquid",
|
||||
"docs/lua.lua": "Lua",
|
||||
"docs/luapage.lp": "LuaPage",
|
||||
"docs/markdown.md": {name: "Markdown", wrapped: true},
|
||||
"docs/ocaml.ml": "OCaml",
|
||||
"docs/OpenSCAD.scad": "OpenSCAD",
|
||||
"docs/perl.pl": "Perl",
|
||||
"docs/pgsql.pgsql": {name: "pgSQL", wrapped: true},
|
||||
"docs/php.php": "PHP",
|
||||
"docs/plaintext.txt": {name: "Plain Text", prepare: makeHuge, wrapped: true},
|
||||
"docs/powershell.ps1": "Powershell",
|
||||
"docs/python.py": "Python",
|
||||
"docs/ruby.rb": "Ruby",
|
||||
"docs/scala.scala": "Scala",
|
||||
"docs/scss.scss": "SCSS",
|
||||
"docs/sh.sh": "SH",
|
||||
"docs/sql.sql": {name: "SQL", wrapped: true},
|
||||
"docs/svg.svg": "SVG",
|
||||
"docs/tcl.tcl": "Tcl",
|
||||
"docs/textile.textile": {name: "Textile", wrapped: true},
|
||||
"docs/xml.xml": "XML",
|
||||
"docs/xquery.xq": "XQuery",
|
||||
"docs/yaml.yaml": "YAML",
|
||||
"docs/c9search.c9search_results": "C9 Search Results"
|
||||
}
|
||||
|
||||
var ownSource = {
|
||||
/* filled from require*/
|
||||
};
|
||||
|
||||
var hugeDocs = {
|
||||
"build/src/ace.js": "",
|
||||
"build/src-min/ace.js": ""
|
||||
};
|
||||
|
||||
if (window.require && window.require.s) try {
|
||||
for (var path in window.require.s.contexts._.loaded) {
|
||||
if (path.indexOf("!") != -1)
|
||||
path = path.split("!").pop();
|
||||
else
|
||||
path = path + ".js";
|
||||
ownSource[path] = ""
|
||||
}
|
||||
} catch(e) {}
|
||||
|
||||
function prepareDocList(docs) {
|
||||
var list = []
|
||||
for (var path in docs) {
|
||||
var doc = docs[path];
|
||||
if (typeof doc != "object")
|
||||
doc = {name: doc || path};
|
||||
|
||||
doc.path = path;
|
||||
doc.desc = doc.name.replace(/^(ace|docs|demo|build)\//, "");
|
||||
if (doc.desc.length > 18)
|
||||
doc.desc = doc.desc.slice(0, 7) + ".." + doc.desc.slice(-9)
|
||||
|
||||
fileCache[doc.name] = doc;
|
||||
list.push(doc);
|
||||
};
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
docs = prepareDocList(docs);
|
||||
ownSource = prepareDocList(ownSource);
|
||||
hugeDocs = prepareDocList(hugeDocs);
|
||||
var doclist = require("./doclist");
|
||||
var modelist = require("./modelist");
|
||||
var layout = require("./layout");
|
||||
var TokenTooltip = require("./token_tooltip").TokenTooltip;
|
||||
var util = require("./util");
|
||||
var saveOption = util.saveOption;
|
||||
var fillDropdown = util.fillDropdown;
|
||||
var bindCheckbox = util.bindCheckbox;
|
||||
var bindDropdown = util.bindDropdown;
|
||||
|
||||
/*********** create editor ***************************/
|
||||
var container = document.getElementById("editor");
|
||||
|
|
@ -267,27 +84,30 @@ window.env = env;
|
|||
window.ace = env.editor;
|
||||
env.editor.setAnimatedScroll(true);
|
||||
|
||||
// add multiple cursor support to editor
|
||||
require("ace/multi_select").MultiSelect(env.editor);
|
||||
|
||||
var consoleEl = dom.createElement("div");
|
||||
container.parentNode.appendChild(consoleEl);
|
||||
consoleEl.style.position="fixed"
|
||||
consoleEl.style.bottom = "1px"
|
||||
consoleEl.style.right = 0
|
||||
consoleEl.style.background = "white"
|
||||
consoleEl.style.border = "1px solid #baf"
|
||||
consoleEl.style.zIndex = "100"
|
||||
var cmdLine = new singleLineEditor(consoleEl);
|
||||
consoleEl.style.cssText = "position:fixed; bottom:1px; right:0;\
|
||||
border:1px solid #baf; zIndex:100";
|
||||
|
||||
var cmdLine = new layout.singleLineEditor(consoleEl);
|
||||
cmdLine.editor = env.editor;
|
||||
env.editor.cmdLine = cmdLine;
|
||||
|
||||
/**
|
||||
* This demonstrates how you can define commands and bind shortcuts to them.
|
||||
*/
|
||||
env.editor.commands.addCommands([{
|
||||
name: "gotoline",
|
||||
bindKey: {win: "Ctrl-L", mac: "Command-L"},
|
||||
exec: function(editor, line) {
|
||||
if (typeof line == "object") {
|
||||
var arg = this.name + " " + editor.getCursorPosition().row;
|
||||
editor.cmdLine.setValue(arg, 1)
|
||||
editor.cmdLine.focus()
|
||||
return
|
||||
editor.cmdLine.setValue(arg, 1);
|
||||
editor.cmdLine.focus();
|
||||
return;
|
||||
}
|
||||
line = parseInt(line, 10);
|
||||
if (!isNaN(line))
|
||||
|
|
@ -299,10 +119,10 @@ env.editor.commands.addCommands([{
|
|||
bindKey: {win: "Ctrl-F", mac: "Command-F"},
|
||||
exec: function(editor, needle) {
|
||||
if (typeof needle == "object") {
|
||||
var arg = this.name + " " + editor.getCopyText()
|
||||
editor.cmdLine.setValue(arg, 1)
|
||||
editor.cmdLine.focus()
|
||||
return
|
||||
var arg = this.name + " " + editor.getCopyText();
|
||||
editor.cmdLine.setValue(arg, 1);
|
||||
editor.cmdLine.focus();
|
||||
return;
|
||||
}
|
||||
editor.find(needle);
|
||||
},
|
||||
|
|
@ -312,24 +132,32 @@ env.editor.commands.addCommands([{
|
|||
bindKey: "shift-esc",
|
||||
exec: function(editor, needle) { editor.cmdLine.focus(); },
|
||||
readOnly: true
|
||||
}])
|
||||
}, {
|
||||
name: "execute",
|
||||
bindKey: "ctrl+enter",
|
||||
exec: function(editor) {
|
||||
try {
|
||||
var r = eval(editor.getCopyText()||editor.getValue());
|
||||
} catch(e) {
|
||||
r = e;
|
||||
}
|
||||
editor.cmdLine.setValue(r + "")
|
||||
},
|
||||
readOnly: true
|
||||
}]);
|
||||
|
||||
cmdLine.commands.bindKeys({
|
||||
"Shift-Return|Ctrl-Return|Alt-Return": function(cmdLine) { cmdLine.insert("\n")},
|
||||
"Shift-Return|Ctrl-Return|Alt-Return": function(cmdLine) { cmdLine.insert("\n"); },
|
||||
"Esc|Shift-Esc": function(cmdLine){ cmdLine.editor.focus(); },
|
||||
"Return": function(cmdLine){
|
||||
var command = cmdLine.getValue().split(/\s+/);
|
||||
var editor = cmdLine.editor;
|
||||
editor.commands.exec(command[0], editor, command[1]);
|
||||
editor.focus();
|
||||
},
|
||||
})
|
||||
}
|
||||
});
|
||||
|
||||
cmdLine.commands.removeCommands(["find", "gotoline", "findall", "replace", "replaceall"])
|
||||
|
||||
/**
|
||||
* This demonstrates how you can define commands and bind shortcuts to them.
|
||||
*/
|
||||
cmdLine.commands.removeCommands(["find", "gotoline", "findall", "replace", "replaceall"]);
|
||||
|
||||
var commands = env.editor.commands;
|
||||
commands.addCommand({
|
||||
|
|
@ -350,28 +178,28 @@ var keybindings = {
|
|||
"outdent": "[",
|
||||
"gotolinestart": "^",
|
||||
"gotolineend": "$"
|
||||
})
|
||||
})
|
||||
};
|
||||
|
||||
|
||||
|
||||
/*********** manage layout ***************************/
|
||||
var consoleHight = 20;
|
||||
var consoleHeight = 20;
|
||||
function onResize() {
|
||||
var left = env.split.$container.offsetLeft;
|
||||
var width = document.documentElement.clientWidth - left;
|
||||
container.style.width = width + "px";
|
||||
container.style.height = document.documentElement.clientHeight - consoleHight + "px";
|
||||
container.style.height = document.documentElement.clientHeight - consoleHeight + "px";
|
||||
env.split.resize();
|
||||
|
||||
consoleEl.style.width = width + "px";
|
||||
cmdLine.resize()
|
||||
cmdLine.resize();
|
||||
}
|
||||
|
||||
window.onresize = onResize;
|
||||
onResize();
|
||||
|
||||
/*********** options pane ***************************/
|
||||
/*********** options panel ***************************/
|
||||
var docEl = document.getElementById("doc");
|
||||
var modeEl = document.getElementById("mode");
|
||||
var wrapModeEl = document.getElementById("soft_wrap");
|
||||
|
|
@ -388,54 +216,23 @@ var animateScrollEl = document.getElementById("animate_scroll");
|
|||
var softTabEl = document.getElementById("soft_tab");
|
||||
var behavioursEl = document.getElementById("enable_behaviours");
|
||||
|
||||
var group = document.createElement("optgroup");
|
||||
group.setAttribute("label", "Mode Examples");
|
||||
fillDropdown(docs, group);
|
||||
docEl.appendChild(group);
|
||||
var group = document.createElement("optgroup");
|
||||
group.setAttribute("label", "Huge documents");
|
||||
fillDropdown(hugeDocs, group);
|
||||
docEl.appendChild(group);
|
||||
var group = document.createElement("optgroup");
|
||||
group.setAttribute("label", "own source");
|
||||
fillDropdown(ownSource, group);
|
||||
docEl.appendChild(group);
|
||||
|
||||
|
||||
fillDropdown(modes, modeEl);
|
||||
fillDropdown(docEl, doclist.all);
|
||||
|
||||
fillDropdown(modeEl, modelist.modes);
|
||||
var modesByName = modelist.modesByName;
|
||||
bindDropdown("mode", function(value) {
|
||||
env.editor.getSession().setMode(modesByName[value].mode || modesByName.text.mode);
|
||||
env.editor.getSession().modeName = value;
|
||||
env.editor.session.setMode(modesByName[value].mode || modesByName.text.mode);
|
||||
env.editor.session.modeName = value;
|
||||
});
|
||||
|
||||
bindDropdown("doc", function(name) {
|
||||
var doc = fileCache[name];
|
||||
if (!doc)
|
||||
return;
|
||||
|
||||
if (doc.session)
|
||||
return setSession(doc.session)
|
||||
|
||||
//@todo do something while waiting
|
||||
// env.editor.setSession(emptySession || (emptySession = new EditSession("")))
|
||||
var path = doc.path;
|
||||
var parts = path.split("/");
|
||||
if (parts[0] == "docs")
|
||||
path = "demo/kitchen-sink/" + path;
|
||||
else if (parts[0] == "ace")
|
||||
path = "lib/" + path;
|
||||
|
||||
net.get(path, function(x) {
|
||||
initDoc(x, path, doc);
|
||||
setSession(doc.session)
|
||||
})
|
||||
|
||||
function setSession(session) {
|
||||
var session = env.split.setSession(session);
|
||||
doclist.loadDoc(name, function(session) {
|
||||
if (!session)
|
||||
return;
|
||||
session = env.split.setSession(session);
|
||||
updateUIEditorOptions();
|
||||
env.editor.focus();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function updateUIEditorOptions() {
|
||||
|
|
@ -461,40 +258,22 @@ function updateUIEditorOptions() {
|
|||
saveOption(behavioursEl, editor.getBehavioursEnabled());
|
||||
}
|
||||
|
||||
function saveOption(el, val) {
|
||||
if (!el.onchange && !el.onclick)
|
||||
return;
|
||||
|
||||
if ("checked" in el) {
|
||||
if (val !== undefined)
|
||||
el.checked = val;
|
||||
|
||||
localStorage && localStorage.setItem(el.id, el.checked ? 1 : 0);
|
||||
}
|
||||
else {
|
||||
if (val !== undefined)
|
||||
el.value = val;
|
||||
|
||||
localStorage && localStorage.setItem(el.id, el.value);
|
||||
}
|
||||
}
|
||||
|
||||
event.addListener(themeEl, "mouseover", function(e){
|
||||
this.desiredValue = e.target.value;
|
||||
if (!this.$timer)
|
||||
this.$timer = setTimeout(this.updateTheme);
|
||||
})
|
||||
});
|
||||
|
||||
event.addListener(themeEl, "mouseout", function(e){
|
||||
this.desiredValue = null;
|
||||
if (!this.$timer)
|
||||
this.$timer = setTimeout(this.updateTheme, 20);
|
||||
})
|
||||
});
|
||||
|
||||
themeEl.updateTheme = function(){
|
||||
env.split.setTheme(themeEl.desiredValue || themeEl.selectedValue);
|
||||
themeEl.$timer = null;
|
||||
}
|
||||
};
|
||||
|
||||
bindDropdown("theme", function(value) {
|
||||
if (!value)
|
||||
|
|
@ -512,33 +291,28 @@ bindDropdown("fontsize", function(value) {
|
|||
});
|
||||
|
||||
bindDropdown("folding", function(value) {
|
||||
env.editor.getSession().setFoldStyle(value);
|
||||
env.editor.session.setFoldStyle(value);
|
||||
env.editor.setShowFoldWidgets(value !== "manual");
|
||||
});
|
||||
|
||||
bindDropdown("soft_wrap", function(value) {
|
||||
var session = env.editor.getSession();
|
||||
var session = env.editor.session;
|
||||
var renderer = env.editor.renderer;
|
||||
switch (value) {
|
||||
case "off":
|
||||
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;
|
||||
default:
|
||||
session.setUseWrapMode(true);
|
||||
var col = parseInt(value, 10);
|
||||
session.setWrapLimitRange(col, col);
|
||||
renderer.setPrintMarginColumn(col);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -579,7 +353,7 @@ bindCheckbox("animate_scroll", function(checked) {
|
|||
});
|
||||
|
||||
bindCheckbox("soft_tab", function(checked) {
|
||||
env.editor.getSession().setUseSoftTabs(checked);
|
||||
env.editor.session.setUseSoftTabs(checked);
|
||||
});
|
||||
|
||||
bindCheckbox("enable_behaviours", function(checked) {
|
||||
|
|
@ -615,42 +389,15 @@ bindDropdown("split", function(value) {
|
|||
}
|
||||
});
|
||||
|
||||
function bindCheckbox(id, callback) {
|
||||
var el = document.getElementById(id);
|
||||
if (localStorage && localStorage.getItem(id))
|
||||
el.checked = localStorage.getItem(id) == "1";
|
||||
|
||||
var onCheck = function() {
|
||||
callback(!!el.checked);
|
||||
saveOption(el);
|
||||
};
|
||||
el.onclick = onCheck;
|
||||
onCheck();
|
||||
}
|
||||
|
||||
function bindDropdown(id, callback) {
|
||||
var el = document.getElementById(id);
|
||||
if (localStorage && localStorage.getItem(id))
|
||||
el.value = localStorage.getItem(id);
|
||||
|
||||
var onChange = function() {
|
||||
callback(el.value);
|
||||
saveOption(el);
|
||||
};
|
||||
|
||||
el.onchange = onChange;
|
||||
onChange();
|
||||
}
|
||||
|
||||
function fillDropdown(list, el) {
|
||||
list.forEach(function(item) {
|
||||
var option = document.createElement("option");
|
||||
option.setAttribute("value", item.name);
|
||||
option.innerHTML = item.desc;
|
||||
el.appendChild(option);
|
||||
});
|
||||
}
|
||||
|
||||
bindCheckbox("highlight_token", function(checked) {
|
||||
var editor = env.editor;
|
||||
if (editor.tokenTooltip && !checked) {
|
||||
editor.tokenTooltip.destroy();
|
||||
delete editor.tokenTooltip;
|
||||
} else if (checked) {
|
||||
editor.tokenTooltip = new TokenTooltip(editor);
|
||||
}
|
||||
});
|
||||
|
||||
/************** dragover ***************************/
|
||||
event.addListener(container, "dragover", function(e) {
|
||||
|
|
@ -679,96 +426,10 @@ event.addListener(container, "drop", function(e) {
|
|||
}
|
||||
});
|
||||
|
||||
// add multiple cursor support to editor
|
||||
require("ace/multi_select").MultiSelect(env.editor);
|
||||
|
||||
|
||||
|
||||
function singleLineEditor(el) {
|
||||
var renderer = new Renderer(el);
|
||||
renderer.scrollBar.element.style.display = "none";
|
||||
renderer.scrollBar.width = 0;
|
||||
renderer.content.style.height = "auto";
|
||||
|
||||
renderer.screenToTextCoordinates = function(x, y) {
|
||||
var pos = this.pixelToScreenCoordinates(x, y);
|
||||
return this.session.screenToDocumentPosition(
|
||||
Math.min(this.session.getScreenLength() - 1, Math.max(pos.row, 0)),
|
||||
Math.max(pos.column, 0)
|
||||
);
|
||||
};
|
||||
// todo size change event
|
||||
renderer.$computeLayerConfig = function() {
|
||||
var longestLine = this.$getLongestLine();
|
||||
var firstRow = 0;
|
||||
var lastRow = this.session.getLength();
|
||||
var height = this.session.getScreenLength() * this.lineHeight;
|
||||
|
||||
this.scrollTop = 0;
|
||||
var config = this.layerConfig;
|
||||
config.width = longestLine;
|
||||
config.padding = this.$padding;
|
||||
config.firstRow = 0;
|
||||
config.firstRowScreen = 0;
|
||||
config.lastRow = lastRow;
|
||||
config.lineHeight = this.lineHeight;
|
||||
config.characterWidth = this.characterWidth;
|
||||
config.minHeight = height;
|
||||
config.maxHeight = height;
|
||||
config.offset = 0;
|
||||
config.height = height;
|
||||
|
||||
this.$gutterLayer.element.style.marginTop = 0 + "px";
|
||||
this.content.style.marginTop = 0 + "px";
|
||||
this.content.style.width = longestLine + 2 * this.$padding + "px";
|
||||
this.content.style.height = height + "px";
|
||||
this.scroller.style.height = height + "px";
|
||||
this.container.style.height = height + "px";
|
||||
};
|
||||
renderer.isScrollableBy=function(){return false};
|
||||
|
||||
var editor = new Editor(renderer);
|
||||
new MultiSelect(editor);
|
||||
editor.session.setUndoManager(new UndoManager());
|
||||
|
||||
editor.setHighlightActiveLine(false);
|
||||
editor.setShowPrintMargin(false);
|
||||
editor.renderer.setShowGutter(false);
|
||||
editor.renderer.setHighlightGutterLine(false);
|
||||
return editor;
|
||||
};
|
||||
|
||||
|
||||
/** simple statusbar **/
|
||||
var editor = env.editor;
|
||||
var statusBarEl = dom.createElement("div");
|
||||
statusBarEl.style.cssText = "color:gray;position:absolute;right:0;border-left:1px solid";
|
||||
cmdLine.container.appendChild(statusBarEl);
|
||||
var statusUpdate = lang.deferredCall(function() {
|
||||
var status = [];
|
||||
function add(s, sep) {s && status.push(s, sep || "|")}
|
||||
if (editor.$vimModeHandler)
|
||||
add(editor.$vimModeHandler.getStatusText());
|
||||
else if (editor.commands.recording)
|
||||
add("REC");
|
||||
|
||||
var c = editor.selection.lead;
|
||||
add(c.row + ":" + c.column, " ");
|
||||
if (!editor.selection.isEmpty()) {
|
||||
var r = editor.getSelectionRange()
|
||||
add("(" + (r.end.row - r.start.row) + ":" +(r.end.column - r.start.column) + ")");
|
||||
}
|
||||
status.pop();
|
||||
statusBarEl.textContent = status.join("");
|
||||
});
|
||||
|
||||
env.editor.on("changeStatus", function() {
|
||||
statusUpdate.schedule(50);
|
||||
});
|
||||
env.editor.on("changeSelection", function() {
|
||||
statusUpdate.schedule(50);
|
||||
});
|
||||
|
||||
var StatusBar = require("./statusbar").StatusBar;
|
||||
new StatusBar(env.editor, cmdLine.container);
|
||||
|
||||
});
|
||||
|
||||
|
|
|
|||
190
demo/kitchen-sink/doclist.js
Normal file
|
|
@ -0,0 +1,190 @@
|
|||
/* ***** 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 EditSession = require("ace/edit_session").EditSession;
|
||||
var UndoManager = require("ace/undomanager").UndoManager;
|
||||
var net = require("ace/lib/net");
|
||||
|
||||
var modelist = require("./modelist");
|
||||
/*********** demo documents ***************************/
|
||||
var fileCache = {};
|
||||
|
||||
function initDoc(file, path, doc) {
|
||||
if (doc.prepare)
|
||||
file = doc.prepare(file);
|
||||
|
||||
var session = new EditSession(file);
|
||||
session.setUndoManager(new UndoManager());
|
||||
doc.session = session;
|
||||
doc.path = path;
|
||||
if (doc.wrapped) {
|
||||
session.setUseWrapMode(true);
|
||||
session.setWrapLimitRange(80, 80);
|
||||
}
|
||||
var mode = modelist.getModeFromPath(path);
|
||||
session.modeName = mode.name;
|
||||
session.setMode(mode.mode);
|
||||
}
|
||||
|
||||
|
||||
function makeHuge(txt) {
|
||||
for (var i = 0; i < 5; i++)
|
||||
txt += txt;
|
||||
return txt;
|
||||
}
|
||||
|
||||
var docs = {
|
||||
"docs/AsciiDoc.asciidoc": "AsciiDoc",
|
||||
"docs/javascript.js": "JavaScript",
|
||||
"docs/clojure.clj": "Clojure",
|
||||
"docs/coffeescript.coffee": "Coffeescript",
|
||||
"docs/coldfusion.cfm": "ColdFusion",
|
||||
"docs/cpp.cpp": "C/C++",
|
||||
"docs/csharp.cs": "C#",
|
||||
"docs/css.css": "CSS",
|
||||
"docs/diff.diff": "Diff",
|
||||
"docs/glsl.glsl": "Glsl",
|
||||
"docs/golang.go": "Go",
|
||||
"docs/groovy.groovy": "Groovy",
|
||||
"docs/Haxe.hx": "haXe",
|
||||
"docs/html.html": "HTML",
|
||||
"docs/jade.jade": "Jade",
|
||||
"docs/java.java": "Java",
|
||||
"docs/jsp.jsp": "JSP",
|
||||
"docs/json.json": "JSON",
|
||||
"docs/jsx.jsx": "JSX",
|
||||
"docs/latex.tex": {name: "LaTeX", wrapped: true},
|
||||
"docs/less.less": "LESS",
|
||||
"docs/liquid.liquid": "Liquid",
|
||||
"docs/lua.lua": "Lua",
|
||||
"docs/luapage.lp": "LuaPage",
|
||||
"docs/markdown.md": {name: "Markdown", wrapped: true},
|
||||
"docs/ocaml.ml": "OCaml",
|
||||
"docs/OpenSCAD.scad": "OpenSCAD",
|
||||
"docs/perl.pl": "Perl",
|
||||
"docs/pgsql.pgsql": {name: "pgSQL", wrapped: true},
|
||||
"docs/php.php": "PHP",
|
||||
"docs/plaintext.txt": {name: "Plain Text", prepare: makeHuge, wrapped: true},
|
||||
"docs/powershell.ps1": "Powershell",
|
||||
"docs/python.py": "Python",
|
||||
"docs/ruby.rb": "Ruby",
|
||||
"docs/scala.scala": "Scala",
|
||||
"docs/scss.scss": "SCSS",
|
||||
"docs/sh.sh": "SH",
|
||||
"docs/sql.sql": {name: "SQL", wrapped: true},
|
||||
"docs/svg.svg": "SVG",
|
||||
"docs/tcl.tcl": "Tcl",
|
||||
"docs/textile.textile": {name: "Textile", wrapped: true},
|
||||
"docs/typescript.ts": "Typescript",
|
||||
"docs/xml.xml": "XML",
|
||||
"docs/xquery.xq": "XQuery",
|
||||
"docs/yaml.yaml": "YAML",
|
||||
"docs/c9search.c9search_results": "C9 Search Results"
|
||||
};
|
||||
|
||||
var ownSource = {
|
||||
/* filled from require*/
|
||||
};
|
||||
|
||||
var hugeDocs = {
|
||||
"build/src/ace.js": "",
|
||||
"build/src-min/ace.js": ""
|
||||
};
|
||||
|
||||
if (window.require && window.require.s) try {
|
||||
for (var path in window.require.s.contexts._.defined) {
|
||||
if (path.indexOf("!") != -1)
|
||||
path = path.split("!").pop();
|
||||
else
|
||||
path = path + ".js";
|
||||
ownSource[path] = "";
|
||||
}
|
||||
} catch(e) {}
|
||||
|
||||
function prepareDocList(docs) {
|
||||
var list = [];
|
||||
for (var path in docs) {
|
||||
var doc = docs[path];
|
||||
if (typeof doc != "object")
|
||||
doc = {name: doc || path};
|
||||
|
||||
doc.path = path;
|
||||
doc.desc = doc.name.replace(/^(ace|docs|demo|build)\//, "");
|
||||
if (doc.desc.length > 18)
|
||||
doc.desc = doc.desc.slice(0, 7) + ".." + doc.desc.slice(-9);
|
||||
|
||||
fileCache[doc.name] = doc;
|
||||
list.push(doc);
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
function loadDoc(name, callback) {
|
||||
var doc = fileCache[name];
|
||||
if (!doc)
|
||||
return callback(null);
|
||||
|
||||
if (doc.session)
|
||||
return callback(doc.session);
|
||||
|
||||
// TODO: show load screen while waiting
|
||||
var path = doc.path;
|
||||
var parts = path.split("/");
|
||||
if (parts[0] == "docs")
|
||||
path = "demo/kitchen-sink/" + path;
|
||||
else if (parts[0] == "ace")
|
||||
path = "lib/" + path;
|
||||
|
||||
net.get(path, function(x) {
|
||||
initDoc(x, path, doc);
|
||||
callback(doc.session);
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
fileCache: fileCache,
|
||||
docs: prepareDocList(docs),
|
||||
ownSource: prepareDocList(ownSource),
|
||||
hugeDocs: prepareDocList(hugeDocs),
|
||||
initDoc: initDoc,
|
||||
loadDoc: loadDoc
|
||||
};
|
||||
module.exports.all = {
|
||||
"Mode Examples": module.exports.docs,
|
||||
"Huge documents": module.exports.hugeDocs,
|
||||
"own source": module.exports.ownSource
|
||||
};
|
||||
|
||||
});
|
||||
|
||||
6040
demo/kitchen-sink/docs/AsciiDoc.asciidoc
Normal file
|
|
@ -16,7 +16,7 @@ index 23fc3fc..ed3b273 100644
|
|||
|
||||
+ this.highlight = function(re) {
|
||||
+ if (!this.$searchHighlight) {
|
||||
+ var highlight = new SearchHighlight(null, "ace_selected_word", "text");
|
||||
+ var highlight = new SearchHighlight(null, "ace_selected-word", "text");
|
||||
+ this.$searchHighlight = this.addDynamicMarker(highlight);
|
||||
+ }
|
||||
+ this.$searchHighlight.setRegexp(re);
|
||||
|
|
|
|||
46
demo/kitchen-sink/docs/jsp.jsp
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
<html>
|
||||
<body>
|
||||
<script>
|
||||
var x = "abc";
|
||||
function y {
|
||||
}
|
||||
</script>
|
||||
<style>
|
||||
.class {
|
||||
background: #124356;
|
||||
}
|
||||
</style>
|
||||
|
||||
<p>
|
||||
Today's date: <%= (new java.util.Date()).toLocaleString()%>
|
||||
</p>
|
||||
<%! int i = 0; %>
|
||||
<jsp:declaration>
|
||||
int j = 10;
|
||||
</jsp:declaration>
|
||||
|
||||
<%-- This is JSP comment --%>
|
||||
<%@ directive attribute="value" %>
|
||||
|
||||
<h2>Select Languages:</h2>
|
||||
|
||||
<form ACTION="jspCheckBox.jsp">
|
||||
<input type="checkbox" name="id" value="Java"> Java<BR>
|
||||
<input type="checkbox" name="id" value=".NET"> .NET<BR>
|
||||
<input type="checkbox" name="id" value="PHP"> PHP<BR>
|
||||
<input type="checkbox" name="id" value="C/C++"> C/C++<BR>
|
||||
<input type="checkbox" name="id" value="PERL"> PERL <BR>
|
||||
<input type="submit" value="Submit">
|
||||
</form>
|
||||
|
||||
<%
|
||||
String select[] = request.getParameterValues("id");
|
||||
if (select != null && select.length != 0) {
|
||||
out.println("You have selected: ");
|
||||
for (int i = 0; i < select.length; i++) {
|
||||
out.println(select[i]);
|
||||
}
|
||||
}
|
||||
%>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -47,7 +47,7 @@
|
|||
setTimeout("ShowAndGrowElement()", timer_increment)
|
||||
}
|
||||
window.ShowAndGrowElement = ShowAndGrowElement
|
||||
]]</script>
|
||||
]]></script>
|
||||
|
||||
<rect
|
||||
fill="#2e3436"
|
||||
|
|
|
|||
|
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 2.8 KiB |
72
demo/kitchen-sink/docs/typescript.ts
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
class Greeter {
|
||||
greeting: string;
|
||||
constructor (message: string) {
|
||||
this.greeting = message;
|
||||
}
|
||||
greet() {
|
||||
return "Hello, " + this.greeting;
|
||||
}
|
||||
}
|
||||
|
||||
var greeter = new Greeter("world");
|
||||
|
||||
var button = document.createElement('button')
|
||||
button.innerText = "Say Hello"
|
||||
button.onclick = function() {
|
||||
alert(greeter.greet())
|
||||
}
|
||||
|
||||
document.body.appendChild(button)
|
||||
|
||||
class Snake extends Animal {
|
||||
move() {
|
||||
alert("Slithering...");
|
||||
super(5);
|
||||
}
|
||||
}
|
||||
|
||||
class Horse extends Animal {
|
||||
move() {
|
||||
alert("Galloping...");
|
||||
super.move(45);
|
||||
}
|
||||
}
|
||||
|
||||
module Sayings {
|
||||
export class Greeter {
|
||||
greeting: string;
|
||||
constructor (message: string) {
|
||||
this.greeting = message;
|
||||
}
|
||||
greet() {
|
||||
return "Hello, " + this.greeting;
|
||||
}
|
||||
}
|
||||
}
|
||||
module Mankala {
|
||||
export class Features {
|
||||
public turnContinues = false;
|
||||
public seedStoredCount = 0;
|
||||
public capturedCount = 0;
|
||||
public spaceCaptured = NoSpace;
|
||||
|
||||
public clear() {
|
||||
this.turnContinues = false;
|
||||
this.seedStoredCount = 0;
|
||||
this.capturedCount = 0;
|
||||
this.spaceCaptured = NoSpace;
|
||||
}
|
||||
|
||||
public toString() {
|
||||
var stringBuilder = "";
|
||||
if (this.turnContinues) {
|
||||
stringBuilder += " turn continues,";
|
||||
}
|
||||
stringBuilder += " stores " + this.seedStoredCount;
|
||||
if (this.capturedCount > 0) {
|
||||
stringBuilder += " captures " + this.capturedCount + " from space " + this.spaceCaptured;
|
||||
}
|
||||
return stringBuilder;
|
||||
}
|
||||
}
|
||||
}
|
||||
194
demo/kitchen-sink/layout.js
Normal file
|
|
@ -0,0 +1,194 @@
|
|||
|
||||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var dom = require("ace/lib/dom");
|
||||
var event = require("ace/lib/event");
|
||||
|
||||
var EditSession = require("ace/edit_session").EditSession;
|
||||
var UndoManager = require("ace/undomanager").UndoManager;
|
||||
var Renderer = require("ace/virtual_renderer").VirtualRenderer;
|
||||
var Editor = require("ace/editor").Editor;
|
||||
var MultiSelect = require("ace/multi_select").MultiSelect;
|
||||
|
||||
dom.importCssString("\
|
||||
splitter {\
|
||||
border: 1px solid #C6C6D2;\
|
||||
width: 0px;\
|
||||
cursor: ew-resize;\
|
||||
z-index:10}\
|
||||
splitter:hover {\
|
||||
margin-left: -2px;\
|
||||
width:3px;\
|
||||
border-color: #B5B4E0;\
|
||||
}\
|
||||
", "splitEditor");
|
||||
|
||||
exports.edit = function(el) {
|
||||
if (typeof(el) == "string")
|
||||
el = document.getElementById(el);
|
||||
|
||||
var editor = new Editor(new Renderer(el, require("ace/theme/textmate")));
|
||||
|
||||
editor.resize();
|
||||
event.addListener(window, "resize", function() {
|
||||
editor.resize();
|
||||
});
|
||||
return editor;
|
||||
};
|
||||
|
||||
|
||||
var SplitRoot = function(el, theme, position, getSize) {
|
||||
el.style.position = position || "relative";
|
||||
this.container = el;
|
||||
this.getSize = getSize || this.getSize;
|
||||
this.resize = this.$resize.bind(this);
|
||||
|
||||
event.addListener(el.ownerDocument.defaultView, "resize", this.resize);
|
||||
this.editor = this.createEditor();
|
||||
};
|
||||
|
||||
(function(){
|
||||
this.createEditor = function() {
|
||||
var el = document.createElement("div");
|
||||
el.className = this.$editorCSS;
|
||||
el.style.cssText = "position: absolute; top:0px; bottom:0px";
|
||||
this.$container.appendChild(el);
|
||||
var session = new EditSession("");
|
||||
var editor = new Editor(new Renderer(el, this.$theme));
|
||||
|
||||
/*editor.on("focus", function() {
|
||||
this._emit("focus", editor);
|
||||
}.bind(this));*/
|
||||
|
||||
this.$editors.push(editor);
|
||||
editor.setFontSize(this.$fontSize);
|
||||
return editor;
|
||||
};
|
||||
this.$resize = function() {
|
||||
var size = this.getSize(this.container);
|
||||
this.rect = {
|
||||
x: size.left,
|
||||
y: size.top,
|
||||
w: size.width,
|
||||
h: size.height
|
||||
};
|
||||
this.item.resize(this.rect);
|
||||
};
|
||||
this.getSize = function(el) {
|
||||
return el.getBoundingClientRect();
|
||||
};
|
||||
this.destroy = function() {
|
||||
var win = this.container.ownerDocument.defaultView;
|
||||
event.removeListener(win, "resize", this.resize);
|
||||
};
|
||||
|
||||
|
||||
}).call(SplitRoot.prototype);
|
||||
|
||||
|
||||
|
||||
var Split = function(){
|
||||
|
||||
};
|
||||
(function(){
|
||||
this.execute = function(options) {
|
||||
this.$u.execute(options);
|
||||
};
|
||||
|
||||
}).call(Split.prototype);
|
||||
|
||||
|
||||
|
||||
exports.singleLineEditor = function(el) {
|
||||
var renderer = new Renderer(el);
|
||||
el.style.overflow = "hidden";
|
||||
renderer.scrollBar.element.style.top = "0";
|
||||
renderer.scrollBar.element.style.display = "none";
|
||||
renderer.scrollBar.orginalWidth = renderer.scrollBar.width;
|
||||
renderer.scrollBar.width = 0;
|
||||
renderer.content.style.height = "auto";
|
||||
|
||||
renderer.screenToTextCoordinates = function(x, y) {
|
||||
var pos = this.pixelToScreenCoordinates(x, y);
|
||||
return this.session.screenToDocumentPosition(
|
||||
Math.min(this.session.getScreenLength() - 1, Math.max(pos.row, 0)),
|
||||
Math.max(pos.column, 0)
|
||||
);
|
||||
};
|
||||
|
||||
renderer.maxLines = 4;
|
||||
renderer.$computeLayerConfigWithScroll = renderer.$computeLayerConfig;
|
||||
renderer.$computeLayerConfig = function() {
|
||||
var config = this.layerConfig;
|
||||
var height = this.session.getScreenLength() * this.lineHeight;
|
||||
if (config.height != height) {
|
||||
var vScroll = height > this.maxLines * this.lineHeight;
|
||||
|
||||
if (vScroll != this.$vScroll) {
|
||||
if (vScroll) {
|
||||
this.scrollBar.element.style.display = "";
|
||||
this.scrollBar.width = this.scrollBar.orginalWidth;
|
||||
this.container.style.height = config.height + "px";
|
||||
height = config.height;
|
||||
this.scrollTop = height - this.maxLines * this.lineHeight;
|
||||
} else {
|
||||
this.scrollBar.element.style.display = "none";
|
||||
this.scrollBar.width = 0;
|
||||
}
|
||||
|
||||
this.onResize();
|
||||
this.$vScroll = vScroll;
|
||||
}
|
||||
|
||||
if (this.$vScroll)
|
||||
return renderer.$computeLayerConfigWithScroll();
|
||||
|
||||
this.container.style.height = height + "px";
|
||||
this.scroller.style.height = height + "px";
|
||||
this.content.style.height = height + "px";
|
||||
this._emit("resize");
|
||||
}
|
||||
|
||||
var longestLine = this.$getLongestLine();
|
||||
var firstRow = 0;
|
||||
var lastRow = this.session.getLength();
|
||||
|
||||
this.scrollTop = 0;
|
||||
config.width = longestLine;
|
||||
config.padding = this.$padding;
|
||||
config.firstRow = 0;
|
||||
config.firstRowScreen = 0;
|
||||
config.lastRow = lastRow;
|
||||
config.lineHeight = this.lineHeight;
|
||||
config.characterWidth = this.characterWidth;
|
||||
config.minHeight = height;
|
||||
config.maxHeight = height;
|
||||
config.offset = 0;
|
||||
config.height = height;
|
||||
|
||||
this.$gutterLayer.element.style.marginTop = 0 + "px";
|
||||
this.content.style.marginTop = 0 + "px";
|
||||
this.content.style.width = longestLine + 2 * this.$padding + "px";
|
||||
};
|
||||
renderer.isScrollableBy=function(){return false};
|
||||
|
||||
renderer.setStyle("ace_one-line");
|
||||
var editor = new Editor(renderer);
|
||||
new MultiSelect(editor);
|
||||
editor.session.setUndoManager(new UndoManager());
|
||||
|
||||
editor.setHighlightActiveLine(false);
|
||||
editor.setShowPrintMargin(false);
|
||||
editor.renderer.setShowGutter(false);
|
||||
editor.renderer.setHighlightGutterLine(false);
|
||||
|
||||
editor.$mouseHandler.$focusWaitTimout = 0;
|
||||
|
||||
return editor;
|
||||
};
|
||||
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
|
@ -1,52 +1,6 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
<title>Editor</title>
|
||||
<style type="text/css" media="screen">
|
||||
body {
|
||||
overflow: hidden;
|
||||
margin: 0;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
}
|
||||
|
||||
#editor {
|
||||
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
<div id="toolbar"></div>
|
||||
<pre id="editor"></pre>
|
||||
|
||||
<script src="../build/src/ace.js" type="text/javascript"></script>
|
||||
<script src="../build/kitchen-sink/demo.js" type="text/javascript"></script>
|
||||
|
||||
<script>
|
||||
var $ = document.getElementById.bind(document);
|
||||
function bindDropdown(el, callback) {
|
||||
var onChange = function() {
|
||||
callback(el.value);
|
||||
};
|
||||
el.onchange = onChange;
|
||||
onChange();
|
||||
}
|
||||
|
||||
function fillDropdown(list, el) {
|
||||
list.forEach(function(item) {
|
||||
var option = document.createElement("option");
|
||||
option.setAttribute("value", item.name);
|
||||
option.innerHTML = item.desc;
|
||||
el.appendChild(option);
|
||||
});
|
||||
}
|
||||
|
||||
/************** modes ***********************/
|
||||
var modes = [];
|
||||
function getModeFromPath(path) {
|
||||
|
|
@ -58,7 +12,7 @@ function getModeFromPath(path) {
|
|||
}
|
||||
}
|
||||
return mode;
|
||||
};
|
||||
}
|
||||
|
||||
var Mode = function(name, desc, extensions) {
|
||||
this.name = name;
|
||||
|
|
@ -72,19 +26,23 @@ Mode.prototype.supportsFile = function(filename) {
|
|||
};
|
||||
|
||||
var modesByName = {
|
||||
asciidoc: ["AsciiDoc" , "asciidoc"],
|
||||
c9search: ["C9Search" , "c9search_results"],
|
||||
coffee: ["CoffeeScript" , "coffee|^Cakefile"],
|
||||
coldfusion: ["ColdFusion" , "cfm"],
|
||||
csharp: ["C#" , "cs"],
|
||||
css: ["CSS" , "css"],
|
||||
diff: ["Diff" , "diff|patch"],
|
||||
glsl: ["Glsl" , "glsl|frag|vert"],
|
||||
golang: ["Go" , "go"],
|
||||
groovy: ["Groovy" , "groovy"],
|
||||
haxe: ["haXe" , "hx"],
|
||||
html: ["HTML" , "htm|html|xhtml"],
|
||||
c_cpp: ["C/C++" , "c|cc|cpp|cxx|h|hh|hpp"],
|
||||
clojure: ["Clojure" , "clj"],
|
||||
jade: ["Jade" , "jade"],
|
||||
java: ["Java" , "java"],
|
||||
jsp: ["JSP" , "jsp"],
|
||||
javascript: ["JavaScript" , "js"],
|
||||
json: ["JSON" , "json"],
|
||||
jsx: ["JSX" , "jsx"],
|
||||
|
|
@ -107,8 +65,10 @@ var modesByName = {
|
|||
sh: ["SH" , "sh|bash|bat"],
|
||||
sql: ["SQL" , "sql"],
|
||||
svg: ["SVG" , "svg"],
|
||||
tcl: ["Tcl" , "tcl"],
|
||||
text: ["Text" , "txt"],
|
||||
textile: ["Textile" , "textile"],
|
||||
typescript: ["Typescript" , "typescript|ts|str"],
|
||||
xml: ["XML" , "xml|rdf|rss|wsdl|xslt|atom|mathml|mml|xul|xbl"],
|
||||
xquery: ["XQuery" , "xq"],
|
||||
yaml: ["YAML" , "yaml"]
|
||||
|
|
@ -116,69 +76,16 @@ var modesByName = {
|
|||
|
||||
for (var name in modesByName) {
|
||||
var mode = modesByName[name];
|
||||
mode = new Mode(name, mode[0], mode[1])
|
||||
mode = new Mode(name, mode[0], mode[1]);
|
||||
modesByName[name] = mode;
|
||||
modes.push(mode);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getModeFromPath: getModeFromPath,
|
||||
modes: modes,
|
||||
modesByName: modesByName
|
||||
};
|
||||
|
||||
|
||||
var container = document.getElementById("editor");
|
||||
container.style.position = "absolute";
|
||||
// Splitting.
|
||||
var Split = require("ace/split").Split;
|
||||
var split = new Split(container, null, 1);
|
||||
split.setOrientation(split.BESIDE);
|
||||
split.setSplits(2);
|
||||
|
||||
var editor1 = split.getEditor(0);
|
||||
var editor2 = split.getEditor(1);
|
||||
|
||||
var toolbar = $("toolbar");
|
||||
var modeEl = document.createElement("select");
|
||||
fillDropdown(modes, modeEl);
|
||||
|
||||
bindDropdown(modeEl, function(value) {
|
||||
editor1.session.setMode((modesByName[value] || modesByName.text).mode);
|
||||
});
|
||||
toolbar.appendChild(modeEl);
|
||||
var button = document.createElement("input");
|
||||
button.setAttribute("type", "button");
|
||||
button.value = "generate test";
|
||||
toolbar.appendChild(button)
|
||||
|
||||
function onResize() {
|
||||
var top = toolbar.clientHeight;
|
||||
var width = document.documentElement.clientWidth;
|
||||
container.style.top = top + "px";
|
||||
container.style.width = width + "px";
|
||||
container.style.height = document.documentElement.clientHeight - top + "px";
|
||||
split.resize();
|
||||
}
|
||||
|
||||
window.onresize = onResize;
|
||||
onResize();
|
||||
|
||||
|
||||
|
||||
|
||||
button.onclick = function() {
|
||||
var s = editor1.session
|
||||
tok = s.bgTokenizer
|
||||
var data = []
|
||||
for (var i = 0; i < s.getLength(); i++) {
|
||||
data.push({
|
||||
text: s.getLine(i),
|
||||
state: [tok.getState(i - 1), tok.getState(i)],
|
||||
tokens: tok.getTokens(i)
|
||||
})
|
||||
}
|
||||
data = JSON.stringify(data, null, 4);
|
||||
data = data.replace(/(\n\s*)"(\w+)":/g, "$1$2:");
|
||||
editor2.insert(data);
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
48
demo/kitchen-sink/statusbar.js
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
/** simple statusbar **/
|
||||
var dom = require("ace/lib/dom");
|
||||
var lang = require("ace/lib/lang");
|
||||
|
||||
var StatusBar = function(editor, parentNode) {
|
||||
this.element = dom.createElement("div");
|
||||
this.element.style.cssText = "color: gray; position:absolute; right:0; border-left:1px solid";
|
||||
parentNode.appendChild(this.element);
|
||||
|
||||
var statusUpdate = lang.deferredCall(function(){
|
||||
this.updateStatus(editor)
|
||||
}.bind(this));
|
||||
editor.on("changeStatus", function() {
|
||||
statusUpdate.schedule(50);
|
||||
});
|
||||
editor.on("changeSelection", function() {
|
||||
statusUpdate.schedule(50);
|
||||
});
|
||||
};
|
||||
|
||||
(function(){
|
||||
this.updateStatus = function(editor) {
|
||||
var status = [];
|
||||
function add(str, separator) {
|
||||
str && status.push(str, separator || "|");
|
||||
}
|
||||
|
||||
if (editor.$vimModeHandler)
|
||||
add(editor.$vimModeHandler.getStatusText());
|
||||
else if (editor.commands.recording)
|
||||
add("REC");
|
||||
|
||||
var c = editor.selection.lead;
|
||||
add(c.row + ":" + c.column, " ");
|
||||
if (!editor.selection.isEmpty()) {
|
||||
var r = editor.getSelectionRange();
|
||||
add("(" + (r.end.row - r.start.row) + ":" +(r.end.column - r.start.column) + ")");
|
||||
}
|
||||
status.pop();
|
||||
this.element.textContent = status.join("");
|
||||
};
|
||||
}).call(StatusBar.prototype);
|
||||
|
||||
exports.StatusBar = StatusBar;
|
||||
|
||||
});
|
||||
|
|
@ -1,7 +1,3 @@
|
|||
/*PACKAGE
|
||||
@import url(//fonts.googleapis.com/css?family=Droid+Sans+Mono);
|
||||
PACKAGE*/
|
||||
|
||||
html {
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
|
|
|
|||
183
demo/kitchen-sink/token_tooltip.js
Normal file
|
|
@ -0,0 +1,183 @@
|
|||
/* ***** 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 dom = require("ace/lib/dom");
|
||||
var event = require("ace/lib/event");
|
||||
var Range = require("ace/range").Range;
|
||||
|
||||
var tooltipNode;
|
||||
|
||||
var TokenTooltip = function(editor) {
|
||||
if (editor.tokenTooltip)
|
||||
return;
|
||||
editor.tokenTooltip = this;
|
||||
this.editor = editor;
|
||||
|
||||
editor.tooltip = tooltipNode || this.$init();
|
||||
|
||||
this.update = this.update.bind(this);
|
||||
this.onMouseMove = this.onMouseMove.bind(this);
|
||||
this.onMouseOut = this.onMouseOut.bind(this);
|
||||
event.addListener(editor.renderer.scroller, "mousemove", this.onMouseMove);
|
||||
event.addListener(editor.renderer.content, "mouseout", this.onMouseOut);
|
||||
};
|
||||
|
||||
(function(){
|
||||
this.token = {};
|
||||
this.range = new Range();
|
||||
|
||||
this.update = function() {
|
||||
this.$timer = null;
|
||||
|
||||
var r = this.editor.renderer;
|
||||
if (this.lastT - (r.timeStamp || 0) > 1000) {
|
||||
r.rect = null;
|
||||
r.timeStamp = this.lastT;
|
||||
this.maxHeight = innerHeight;
|
||||
this.maxWidth = innerWidth;
|
||||
}
|
||||
|
||||
var canvasPos = r.rect || (r.rect = r.scroller.getBoundingClientRect());
|
||||
var offset = (this.x + r.scrollLeft - canvasPos.left - r.$padding) / r.characterWidth;
|
||||
var row = Math.floor((this.y + r.scrollTop - canvasPos.top) / r.lineHeight);
|
||||
var col = Math.round(offset);
|
||||
|
||||
var screenPos = {row: row, column: col, side: offset - col > 0 ? 1 : -1};
|
||||
var session = this.editor.session;
|
||||
var docPos = session.screenToDocumentPosition(screenPos.row, screenPos.column);
|
||||
var token = session.getTokenAt(docPos.row, docPos.column);
|
||||
|
||||
if (!token && !session.getLine(docPos.row)) {
|
||||
token = {
|
||||
type: "",
|
||||
value: "",
|
||||
state: session.bgTokenizer.getState(0)
|
||||
};
|
||||
}
|
||||
if (!token) {
|
||||
session.removeMarker(this.marker);
|
||||
tooltipNode.style.display = "none";
|
||||
this.isOpen = false;
|
||||
return;
|
||||
}
|
||||
if (!this.isOpen) {
|
||||
tooltipNode.style.display = "";
|
||||
this.isOpen = true;
|
||||
}
|
||||
|
||||
var tokenText = token.type;
|
||||
if (token.state)
|
||||
tokenText += "|" + token.state;
|
||||
if (token.merge)
|
||||
tokenText += "\n merge";
|
||||
if (token.stateTransitions)
|
||||
tokenText += "\n " + token.stateTransitions.join("\n ");
|
||||
|
||||
if (this.tokenText != tokenText) {
|
||||
tooltipNode.textContent = tokenText;
|
||||
this.tooltipWidth = tooltipNode.offsetWidth;
|
||||
this.tooltipHeight = tooltipNode.offsetHeight;
|
||||
this.tokenText = tokenText;
|
||||
}
|
||||
|
||||
this.updateTooltipPosition(this.x, this.y);
|
||||
|
||||
this.token = token;
|
||||
session.removeMarker(this.marker);
|
||||
this.range = new Range(docPos.row, token.start, docPos.row, token.start + token.value.length);
|
||||
this.marker = session.addMarker(this.range, "ace_bracket", "text");
|
||||
};
|
||||
|
||||
this.onMouseMove = function(e) {
|
||||
this.x = e.clientX;
|
||||
this.y = e.clientY;
|
||||
if (this.isOpen) {
|
||||
this.lastT = e.timeStamp;
|
||||
this.updateTooltipPosition(this.x, this.y);
|
||||
}
|
||||
if (!this.$timer)
|
||||
this.$timer = setTimeout(this.update, 100);
|
||||
};
|
||||
|
||||
this.onMouseOut = function(e) {
|
||||
var t = e && e.relatedTarget;
|
||||
var ct = e && e.currentTarget;
|
||||
while(t && (t = t.parentNode)) {
|
||||
if (t == ct)
|
||||
return;
|
||||
}
|
||||
tooltipNode.style.display = "none";
|
||||
this.editor.session.removeMarker(this.marker);
|
||||
this.$timer = clearTimeout(this.$timer);
|
||||
this.isOpen = false;
|
||||
};
|
||||
|
||||
this.updateTooltipPosition = function(x, y) {
|
||||
var st = tooltipNode.style;
|
||||
if (x + 10 + this.tooltipWidth > this.maxWidth)
|
||||
x = innerWidth - this.tooltipWidth - 10;
|
||||
if (y > innerHeight * 0.75 || y + 20 + this.tooltipHeight > this.maxHeight);
|
||||
y = y - this.tooltipHeight - 30;
|
||||
|
||||
st.left = x + 10 + "px";
|
||||
st.top = y + 20 + "px";
|
||||
};
|
||||
|
||||
this.$init = function() {
|
||||
tooltipNode = document.documentElement.appendChild(dom.createElement("div"));
|
||||
var st = tooltipNode.style;
|
||||
st.position = "fixed";
|
||||
st.display = "none";
|
||||
st.background = "lightyellow";
|
||||
st.borderRadius = "";
|
||||
st.border = "1px solid gray";
|
||||
st.padding = "1px";
|
||||
st.zIndex = 1000;
|
||||
st.fontFamily = "monospace";
|
||||
st.whiteSpace = "pre-line";
|
||||
return tooltipNode;
|
||||
};
|
||||
|
||||
this.destroy = function() {
|
||||
this.onMouseOut();
|
||||
event.removeListener(this.editor.renderer.scroller, "mousemove", this.onMouseMove);
|
||||
event.removeListener(this.editor.renderer.content, "mouseout", this.onMouseOut);
|
||||
delete this.editor.tokenTooltip;
|
||||
};
|
||||
|
||||
}).call(TokenTooltip.prototype);
|
||||
|
||||
exports.TokenTooltip = TokenTooltip;
|
||||
|
||||
});
|
||||
|
||||
234
demo/kitchen-sink/util.js
Normal file
|
|
@ -0,0 +1,234 @@
|
|||
/* ***** 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 dom = require("ace/lib/dom");
|
||||
var event = require("ace/lib/event");
|
||||
|
||||
var EditSession = require("ace/edit_session").EditSession;
|
||||
var UndoManager = require("ace/undomanager").UndoManager;
|
||||
var Renderer = require("ace/virtual_renderer").VirtualRenderer;
|
||||
var Editor = require("ace/editor").Editor;
|
||||
var MultiSelect = require("ace/multi_select").MultiSelect;
|
||||
|
||||
exports.createSplitEditor = function(el) {
|
||||
if (typeof(el) == "string")
|
||||
el = document.getElementById(el);
|
||||
|
||||
var e0 = document.createElement("div");
|
||||
var s = document.createElement("splitter");
|
||||
var e1 = document.createElement("div");
|
||||
el.appendChild(e0);
|
||||
el.appendChild(e1);
|
||||
el.appendChild(s);
|
||||
e0.style.position = e1.style.position = s.style.position = "absolute";
|
||||
el.style.position = "relative";
|
||||
var split = {$container: el};
|
||||
|
||||
split.editor0 = split[0] = new Editor(new Renderer(e0, require("ace/theme/textmate")));
|
||||
split.editor1 = split[1] = new Editor(new Renderer(e1, require("ace/theme/textmate")));
|
||||
split.splitter = s;
|
||||
|
||||
MultiSelect(split.editor0);
|
||||
MultiSelect(split.editor1);
|
||||
|
||||
s.ratio = 0.5;
|
||||
|
||||
split.resize = function resize(){
|
||||
var height = el.parentNode.clientHeight - el.offsetTop;
|
||||
var total = el.clientWidth;
|
||||
var w1 = total * s.ratio;
|
||||
var w2 = total * (1- s.ratio);
|
||||
s.style.left = w1 - 1 + "px";
|
||||
s.style.height = el.style.height = height + "px";
|
||||
|
||||
var st0 = split[0].container.style;
|
||||
var st1 = split[1].container.style;
|
||||
st0.width = w1 + "px";
|
||||
st1.width = w2 + "px";
|
||||
st0.left = 0 + "px";
|
||||
st1.left = w1 + "px";
|
||||
|
||||
st0.top = st1.top = "0px";
|
||||
st0.height = st1.height = height + "px";
|
||||
|
||||
split[0].resize();
|
||||
split[1].resize();
|
||||
};
|
||||
|
||||
split.onMouseDown = function(e) {
|
||||
var rect = el.getBoundingClientRect();
|
||||
var x = e.clientX;
|
||||
var y = e.clientY;
|
||||
|
||||
var button = e.button;
|
||||
if (button !== 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
var onMouseMove = function(e) {
|
||||
x = e.clientX;
|
||||
y = e.clientY;
|
||||
};
|
||||
var onResizeEnd = function(e) {
|
||||
clearInterval(timerId);
|
||||
};
|
||||
|
||||
var onResizeInterval = function() {
|
||||
s.ratio = (x - rect.left) / rect.width
|
||||
split.resize()
|
||||
};
|
||||
|
||||
event.capture(s, onMouseMove, onResizeEnd);
|
||||
var timerId = setInterval(onResizeInterval, 40);
|
||||
|
||||
return e.preventDefault();
|
||||
};
|
||||
|
||||
|
||||
|
||||
event.addListener(s, "mousedown", split.onMouseDown);
|
||||
event.addListener(window, "resize", split.resize);
|
||||
split.resize();
|
||||
return split;
|
||||
};
|
||||
|
||||
/***************************/
|
||||
exports.stripLeadingComments = function(str) {
|
||||
if(str.slice(0,2)=='/*') {
|
||||
var j = str.indexOf('*/')+2;
|
||||
str = str.substr(j);
|
||||
}
|
||||
return str.trim() + "\n";
|
||||
};
|
||||
|
||||
/***************************/
|
||||
exports.saveOption = function(el, val) {
|
||||
if (!el.onchange && !el.onclick)
|
||||
return;
|
||||
|
||||
if ("checked" in el) {
|
||||
if (val !== undefined)
|
||||
el.checked = val;
|
||||
|
||||
localStorage && localStorage.setItem(el.id, el.checked ? 1 : 0);
|
||||
}
|
||||
else {
|
||||
if (val !== undefined)
|
||||
el.value = val;
|
||||
|
||||
localStorage && localStorage.setItem(el.id, el.value);
|
||||
}
|
||||
};
|
||||
|
||||
exports.bindCheckbox = function(id, callback, noInit) {
|
||||
if (typeof id == "string")
|
||||
var el = document.getElementById(id);
|
||||
else {
|
||||
var el = id;
|
||||
id = el.id;
|
||||
}
|
||||
var el = document.getElementById(id);
|
||||
if (localStorage && localStorage.getItem(id))
|
||||
el.checked = localStorage.getItem(id) == "1";
|
||||
|
||||
var onCheck = function() {
|
||||
callback(!!el.checked);
|
||||
exports.saveOption(el);
|
||||
};
|
||||
el.onclick = onCheck;
|
||||
noInit || onCheck();
|
||||
};
|
||||
|
||||
exports.bindDropdown = function(id, callback, noInit) {
|
||||
if (typeof id == "string")
|
||||
var el = document.getElementById(id);
|
||||
else {
|
||||
var el = id;
|
||||
id = el.id;
|
||||
}
|
||||
if (localStorage && localStorage.getItem(id))
|
||||
el.value = localStorage.getItem(id);
|
||||
|
||||
var onChange = function() {
|
||||
callback(el.value);
|
||||
exports.saveOption(el);
|
||||
};
|
||||
|
||||
el.onchange = onChange;
|
||||
noInit || onChange();
|
||||
};
|
||||
|
||||
exports.fillDropdown = function(el, values) {
|
||||
if (typeof el == "string")
|
||||
el = document.getElementById(el);
|
||||
|
||||
dropdown(values).forEach(function(e) {
|
||||
el.appendChild(e);
|
||||
});
|
||||
};
|
||||
|
||||
function elt(tag, attributes, content) {
|
||||
var el = dom.createElement(tag);
|
||||
if (typeof content == "string") {
|
||||
el.textContent = content;
|
||||
} else if (content) {
|
||||
content.forEach(function(ch) {
|
||||
el.appendChild(ch);
|
||||
});
|
||||
}
|
||||
|
||||
for (var i in attributes)
|
||||
el.setAttribute(i, attributes[i]);
|
||||
return el;
|
||||
}
|
||||
|
||||
function optgroup(values) {
|
||||
return values.map(function(item) {
|
||||
if (typeof item == "string")
|
||||
item = {name: item, desc: item};
|
||||
return elt("option", {value: item.name}, item.desc);
|
||||
});
|
||||
}
|
||||
|
||||
function dropdown(values) {
|
||||
if (Array.isArray(values))
|
||||
return optgroup(values);
|
||||
|
||||
return Object.keys(values).map(function(i) {
|
||||
return elt("optgroup", {"label": i}, optgroup(values[i]));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
|
@ -147,6 +147,19 @@ form.navbar-search {
|
|||
|
||||
form.navbar-search .search-query {
|
||||
background-color: #FFFFFF;
|
||||
border-color: #999;
|
||||
-webkit-transition: border 0.3s;
|
||||
-moz-transition: border 0.3s;
|
||||
font-size: 14px;
|
||||
line-height: 16px;
|
||||
}
|
||||
|
||||
form.navbar-search .search-query:focus, form.navbar-search .search-query:active {
|
||||
border: 1px solid #666;
|
||||
}
|
||||
|
||||
.navbar-search .search-query:focus, .navbar-search .search-query.focused {
|
||||
padding: 4px 9px;
|
||||
}
|
||||
|
||||
h3.api_title {
|
||||
|
|
@ -154,24 +167,28 @@ h3.api_title {
|
|||
}
|
||||
|
||||
ul.menu {
|
||||
margin-left: 16px;
|
||||
margin-left: 2px;
|
||||
}
|
||||
|
||||
.menu li {
|
||||
list-style-image: url(../images/menu_disc.png);
|
||||
margin-bottom: 3px;
|
||||
font-weight : 700;
|
||||
margin-bottom: 4px;
|
||||
font-weight: 700;
|
||||
padding-left: 10px;
|
||||
margin-left: 0;
|
||||
}
|
||||
|
||||
.menu li .menu-item a.menuLink, .menu li .menu-item span.menuLink {
|
||||
color: #262626;
|
||||
color: #3E7096;
|
||||
font-weight: 100;
|
||||
}
|
||||
.menuTwo {
|
||||
margin-bottom: 5px;
|
||||
margin-top: 2px;
|
||||
}
|
||||
.menuTwo li .menu-item a.menuLink {
|
||||
color: #262626;
|
||||
color: #3E7096;
|
||||
font-weight: 100;
|
||||
}
|
||||
|
||||
/* need specificity to "beat" the above colors */
|
||||
|
|
@ -281,9 +298,14 @@ ul.menu {
|
|||
.srolled .membersContent {
|
||||
/*top : 0;*/
|
||||
width: 625px;
|
||||
padding-left: 330px;
|
||||
padding-left: 327px;
|
||||
margin : 0 auto 0 auto;
|
||||
}
|
||||
|
||||
.srolled ul.nav {
|
||||
padding-right: 10px;
|
||||
}
|
||||
|
||||
.membersBackground {
|
||||
/* background-color: white;
|
||||
position: fixed;
|
||||
|
|
@ -480,7 +502,6 @@ ul.tabs .double ul, ul.tabs .triple ul, ul.tabs .quad ul{
|
|||
height: 100%;
|
||||
}
|
||||
.content .row {
|
||||
width: 1060px;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
|
|
@ -492,8 +513,8 @@ header.filler {
|
|||
}
|
||||
|
||||
.centerpiece {
|
||||
background: url(../images/sidebar_border.png) repeat-y 230px 0;
|
||||
min-height: 100%;
|
||||
padding: 20px 0;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -510,7 +531,7 @@ header.filler {
|
|||
}
|
||||
|
||||
#sidebar {
|
||||
margin-top: 9px;
|
||||
margin-top: 5px;
|
||||
/*background: url(../images/sidebar-border.png) repeat-y right 0;*/
|
||||
margin-left: 12px;
|
||||
/* width: 280px;*/
|
||||
|
|
@ -535,6 +556,9 @@ header.filler {
|
|||
#documentation article.article {
|
||||
border-top: 1px solid #e9e9e9;
|
||||
padding: 16px 10px 2px;
|
||||
-webkit-transition: padding 0.2s;
|
||||
-moz-transition: padding 0.2s;
|
||||
-o-transition: padding 0.2s;
|
||||
}
|
||||
|
||||
#documentation h3.sectionHeader + article.article {
|
||||
|
|
@ -781,7 +805,7 @@ li.signature {
|
|||
#documentation i.methodToggle {
|
||||
cursor: pointer;
|
||||
color: #9f9f9f;
|
||||
padding-top: 5px;
|
||||
padding-top: 2px;
|
||||
float: left;
|
||||
}
|
||||
#documentation i.methodToggle.methodToggleHover {
|
||||
|
|
@ -802,6 +826,7 @@ li.signature {
|
|||
|
||||
/* Opera */
|
||||
-o-transform: rotate(45deg);
|
||||
padding-top: 9px;
|
||||
}
|
||||
|
||||
#documentation h3.sectionHeader {
|
||||
|
|
|
|||
|
|
@ -1,92 +0,0 @@
|
|||
/* ============================================================
|
||||
* bootstrap-dropdown.js v2.0.2
|
||||
* http://twitter.github.com/bootstrap/javascript.html#dropdowns
|
||||
* ============================================================
|
||||
* Copyright 2012 Twitter, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ============================================================ */
|
||||
|
||||
|
||||
!function( $ ){
|
||||
|
||||
"use strict"
|
||||
|
||||
/* DROPDOWN CLASS DEFINITION
|
||||
* ========================= */
|
||||
|
||||
var toggle = '[data-toggle="dropdown"]'
|
||||
, Dropdown = function ( element ) {
|
||||
var $el = $(element).on('click.dropdown.data-api', this.toggle)
|
||||
$('html').on('click.dropdown.data-api', function () {
|
||||
$el.parent().removeClass('open')
|
||||
})
|
||||
}
|
||||
|
||||
Dropdown.prototype = {
|
||||
|
||||
constructor: Dropdown
|
||||
|
||||
, toggle: function ( e ) {
|
||||
var $this = $(this)
|
||||
, selector = $this.attr('data-target')
|
||||
, $parent
|
||||
, isActive
|
||||
|
||||
if (!selector) {
|
||||
selector = $this.attr('href')
|
||||
selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
|
||||
}
|
||||
|
||||
$parent = $(selector)
|
||||
$parent.length || ($parent = $this.parent())
|
||||
|
||||
isActive = $parent.hasClass('open')
|
||||
|
||||
clearMenus()
|
||||
!isActive && $parent.toggleClass('open')
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function clearMenus() {
|
||||
$(toggle).parent().removeClass('open')
|
||||
}
|
||||
|
||||
|
||||
/* DROPDOWN PLUGIN DEFINITION
|
||||
* ========================== */
|
||||
|
||||
$.fn.dropdown = function ( option ) {
|
||||
return this.each(function () {
|
||||
var $this = $(this)
|
||||
, data = $this.data('dropdown')
|
||||
if (!data) $this.data('dropdown', (data = new Dropdown(this)))
|
||||
if (typeof option == 'string') data[option].call($this)
|
||||
})
|
||||
}
|
||||
|
||||
$.fn.dropdown.Constructor = Dropdown
|
||||
|
||||
|
||||
/* APPLY TO STANDARD DROPDOWN ELEMENTS
|
||||
* =================================== */
|
||||
|
||||
$(function () {
|
||||
$('html').on('click.dropdown.data-api', clearMenus)
|
||||
$('body').on('click.dropdown.data-api', toggle, Dropdown.prototype.toggle)
|
||||
})
|
||||
|
||||
}( window.jQuery );
|
||||
|
|
@ -1,135 +0,0 @@
|
|||
/* ========================================================
|
||||
* bootstrap-tab.js v2.1.1
|
||||
* http://twitter.github.com/bootstrap/javascript.html#tabs
|
||||
* ========================================================
|
||||
* Copyright 2012 Twitter, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ======================================================== */
|
||||
|
||||
|
||||
!function ($) {
|
||||
|
||||
"use strict"; // jshint ;_;
|
||||
|
||||
|
||||
/* TAB CLASS DEFINITION
|
||||
* ==================== */
|
||||
|
||||
var Tab = function (element) {
|
||||
this.element = $(element)
|
||||
}
|
||||
|
||||
Tab.prototype = {
|
||||
|
||||
constructor: Tab
|
||||
|
||||
, show: function () {
|
||||
var $this = this.element
|
||||
, $ul = $this.closest('ul:not(.dropdown-menu)')
|
||||
, selector = $this.attr('data-target')
|
||||
, previous
|
||||
, $target
|
||||
, e
|
||||
|
||||
if (!selector) {
|
||||
selector = $this.attr('href')
|
||||
selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
|
||||
}
|
||||
|
||||
if ( $this.parent('li').hasClass('active') ) return
|
||||
|
||||
previous = $ul.find('.active a').last()[0]
|
||||
|
||||
e = $.Event('show', {
|
||||
relatedTarget: previous
|
||||
})
|
||||
|
||||
$this.trigger(e)
|
||||
|
||||
if (e.isDefaultPrevented()) return
|
||||
|
||||
$target = $(selector)
|
||||
|
||||
this.activate($this.parent('li'), $ul)
|
||||
this.activate($target, $target.parent(), function () {
|
||||
$this.trigger({
|
||||
type: 'shown'
|
||||
, relatedTarget: previous
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
, activate: function ( element, container, callback) {
|
||||
var $active = container.find('> .active')
|
||||
, transition = callback
|
||||
&& $.support.transition
|
||||
&& $active.hasClass('fade')
|
||||
|
||||
function next() {
|
||||
$active
|
||||
.removeClass('active')
|
||||
.find('> .dropdown-menu > .active')
|
||||
.removeClass('active')
|
||||
|
||||
element.addClass('active')
|
||||
|
||||
if (transition) {
|
||||
element[0].offsetWidth // reflow for transition
|
||||
element.addClass('in')
|
||||
} else {
|
||||
element.removeClass('fade')
|
||||
}
|
||||
|
||||
if ( element.parent('.dropdown-menu') ) {
|
||||
element.closest('li.dropdown').addClass('active')
|
||||
}
|
||||
|
||||
callback && callback()
|
||||
}
|
||||
|
||||
transition ?
|
||||
$active.one($.support.transition.end, next) :
|
||||
next()
|
||||
|
||||
$active.removeClass('in')
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* TAB PLUGIN DEFINITION
|
||||
* ===================== */
|
||||
|
||||
$.fn.tab = function ( option ) {
|
||||
return this.each(function () {
|
||||
var $this = $(this)
|
||||
, data = $this.data('tab')
|
||||
if (!data) $this.data('tab', (data = new Tab(this)))
|
||||
if (typeof option == 'string') data[option]()
|
||||
})
|
||||
}
|
||||
|
||||
$.fn.tab.Constructor = Tab
|
||||
|
||||
|
||||
/* TAB DATA-API
|
||||
* ============ */
|
||||
|
||||
$(function () {
|
||||
$('body').on('click.tab.data-api', '[data-toggle="tab"], [data-toggle="pill"]', function (e) {
|
||||
e.preventDefault()
|
||||
$(this).tab('show')
|
||||
})
|
||||
})
|
||||
|
||||
}(window.jQuery);
|
||||
389
doc/resources/ace/skeleton/javascripts/bootstrap.js
vendored
Normal file
|
|
@ -0,0 +1,389 @@
|
|||
/* ============================================================
|
||||
* bootstrap-dropdown.js v2.1.1
|
||||
* http://twitter.github.com/bootstrap/javascript.html#dropdowns
|
||||
* ============================================================
|
||||
* Copyright 2012 Twitter, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ============================================================ */
|
||||
|
||||
|
||||
!function ($) {
|
||||
|
||||
"use strict"; // jshint ;_;
|
||||
|
||||
|
||||
/* DROPDOWN CLASS DEFINITION
|
||||
* ========================= */
|
||||
|
||||
var toggle = '[data-toggle=dropdown]'
|
||||
, Dropdown = function (element) {
|
||||
var $el = $(element).on('click.dropdown.data-api', this.toggle)
|
||||
$('html').on('click.dropdown.data-api', function () {
|
||||
$el.parent().removeClass('open')
|
||||
})
|
||||
}
|
||||
|
||||
Dropdown.prototype = {
|
||||
|
||||
constructor: Dropdown
|
||||
|
||||
, toggle: function (e) {
|
||||
var $this = $(this)
|
||||
, $parent
|
||||
, isActive
|
||||
|
||||
if ($this.is('.disabled, :disabled')) return
|
||||
|
||||
$parent = getParent($this)
|
||||
|
||||
isActive = $parent.hasClass('open')
|
||||
|
||||
clearMenus()
|
||||
|
||||
if (!isActive) {
|
||||
$parent.toggleClass('open')
|
||||
$this.focus()
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
, keydown: function (e) {
|
||||
var $this
|
||||
, $items
|
||||
, $active
|
||||
, $parent
|
||||
, isActive
|
||||
, index
|
||||
|
||||
if (!/(38|40|27)/.test(e.keyCode)) return
|
||||
|
||||
$this = $(this)
|
||||
|
||||
e.preventDefault()
|
||||
e.stopPropagation()
|
||||
|
||||
if ($this.is('.disabled, :disabled')) return
|
||||
|
||||
$parent = getParent($this)
|
||||
|
||||
isActive = $parent.hasClass('open')
|
||||
|
||||
if (!isActive || (isActive && e.keyCode == 27)) return $this.click()
|
||||
|
||||
$items = $('[role=menu] li:not(.divider) a', $parent)
|
||||
|
||||
if (!$items.length) return
|
||||
|
||||
index = $items.index($items.filter(':focus'))
|
||||
|
||||
if (e.keyCode == 38 && index > 0) index-- // up
|
||||
if (e.keyCode == 40 && index < $items.length - 1) index++ // down
|
||||
if (!~index) index = 0
|
||||
|
||||
$items
|
||||
.eq(index)
|
||||
.focus()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function clearMenus() {
|
||||
getParent($(toggle))
|
||||
.removeClass('open')
|
||||
}
|
||||
|
||||
function getParent($this) {
|
||||
var selector = $this.attr('data-target')
|
||||
, $parent
|
||||
|
||||
if (!selector) {
|
||||
selector = $this.attr('href')
|
||||
selector = selector && /#/.test(selector) && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
|
||||
}
|
||||
|
||||
$parent = $(selector)
|
||||
$parent.length || ($parent = $this.parent())
|
||||
|
||||
return $parent
|
||||
}
|
||||
|
||||
|
||||
/* DROPDOWN PLUGIN DEFINITION
|
||||
* ========================== */
|
||||
|
||||
$.fn.dropdown = function (option) {
|
||||
return this.each(function () {
|
||||
var $this = $(this)
|
||||
, data = $this.data('dropdown')
|
||||
if (!data) $this.data('dropdown', (data = new Dropdown(this)))
|
||||
if (typeof option == 'string') data[option].call($this)
|
||||
})
|
||||
}
|
||||
|
||||
$.fn.dropdown.Constructor = Dropdown
|
||||
|
||||
|
||||
/* APPLY TO STANDARD DROPDOWN ELEMENTS
|
||||
* =================================== */
|
||||
|
||||
$(function () {
|
||||
$('html')
|
||||
.on('click.dropdown.data-api touchstart.dropdown.data-api', clearMenus)
|
||||
$('body')
|
||||
.on('click.dropdown touchstart.dropdown.data-api', '.dropdown form', function (e) { e.stopPropagation() })
|
||||
.on('click.dropdown.data-api touchstart.dropdown.data-api' , toggle, Dropdown.prototype.toggle)
|
||||
.on('keydown.dropdown.data-api touchstart.dropdown.data-api', toggle + ', [role=menu]' , Dropdown.prototype.keydown)
|
||||
})
|
||||
|
||||
}(window.jQuery);
|
||||
/* ========================================================
|
||||
* bootstrap-tab.js v2.1.1
|
||||
* http://twitter.github.com/bootstrap/javascript.html#tabs
|
||||
* ========================================================
|
||||
* Copyright 2012 Twitter, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ======================================================== */
|
||||
|
||||
|
||||
!function ($) {
|
||||
|
||||
"use strict"; // jshint ;_;
|
||||
|
||||
|
||||
/* TAB CLASS DEFINITION
|
||||
* ==================== */
|
||||
|
||||
var Tab = function (element) {
|
||||
this.element = $(element)
|
||||
}
|
||||
|
||||
Tab.prototype = {
|
||||
|
||||
constructor: Tab
|
||||
|
||||
, show: function () {
|
||||
var $this = this.element
|
||||
, $ul = $this.closest('ul:not(.dropdown-menu)')
|
||||
, selector = $this.attr('data-target')
|
||||
, previous
|
||||
, $target
|
||||
, e
|
||||
|
||||
if (!selector) {
|
||||
selector = $this.attr('href')
|
||||
selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
|
||||
}
|
||||
|
||||
if ( $this.parent('li').hasClass('active') ) return
|
||||
|
||||
previous = $ul.find('.active a').last()[0]
|
||||
|
||||
e = $.Event('show', {
|
||||
relatedTarget: previous
|
||||
})
|
||||
|
||||
$this.trigger(e)
|
||||
|
||||
if (e.isDefaultPrevented()) return
|
||||
|
||||
$target = $(selector)
|
||||
|
||||
this.activate($this.parent('li'), $ul)
|
||||
this.activate($target, $target.parent(), function () {
|
||||
$this.trigger({
|
||||
type: 'shown'
|
||||
, relatedTarget: previous
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
, activate: function ( element, container, callback) {
|
||||
var $active = container.find('> .active')
|
||||
, transition = callback
|
||||
&& $.support.transition
|
||||
&& $active.hasClass('fade')
|
||||
|
||||
function next() {
|
||||
$active
|
||||
.removeClass('active')
|
||||
.find('> .dropdown-menu > .active')
|
||||
.removeClass('active')
|
||||
|
||||
element.addClass('active')
|
||||
|
||||
if (transition) {
|
||||
element[0].offsetWidth // reflow for transition
|
||||
element.addClass('in')
|
||||
} else {
|
||||
element.removeClass('fade')
|
||||
}
|
||||
|
||||
if ( element.parent('.dropdown-menu') ) {
|
||||
element.closest('li.dropdown').addClass('active')
|
||||
}
|
||||
|
||||
callback && callback()
|
||||
}
|
||||
|
||||
transition ?
|
||||
$active.one($.support.transition.end, next) :
|
||||
next()
|
||||
|
||||
$active.removeClass('in')
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* TAB PLUGIN DEFINITION
|
||||
* ===================== */
|
||||
|
||||
$.fn.tab = function ( option ) {
|
||||
return this.each(function () {
|
||||
var $this = $(this)
|
||||
, data = $this.data('tab')
|
||||
if (!data) $this.data('tab', (data = new Tab(this)))
|
||||
if (typeof option == 'string') data[option]()
|
||||
})
|
||||
}
|
||||
|
||||
$.fn.tab.Constructor = Tab
|
||||
|
||||
|
||||
/* TAB DATA-API
|
||||
* ============ */
|
||||
|
||||
$(function () {
|
||||
$('body').on('click.tab.data-api', '[data-toggle="tab"], [data-toggle="pill"]', function (e) {
|
||||
e.preventDefault()
|
||||
$(this).tab('show')
|
||||
})
|
||||
})
|
||||
|
||||
}(window.jQuery);
|
||||
/* ==========================================================
|
||||
* bootstrap-affix.js v2.1.1
|
||||
* http://twitter.github.com/bootstrap/javascript.html#affix
|
||||
* ==========================================================
|
||||
* Copyright 2012 Twitter, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ========================================================== */
|
||||
|
||||
|
||||
!function ($) {
|
||||
|
||||
"use strict"; // jshint ;_;
|
||||
|
||||
|
||||
/* AFFIX CLASS DEFINITION
|
||||
* ====================== */
|
||||
|
||||
var Affix = function (element, options) {
|
||||
this.options = $.extend({}, $.fn.affix.defaults, options)
|
||||
this.$window = $(window).on('scroll.affix.data-api', $.proxy(this.checkPosition, this))
|
||||
this.$element = $(element)
|
||||
this.checkPosition()
|
||||
}
|
||||
|
||||
Affix.prototype.checkPosition = function () {
|
||||
if (!this.$element.is(':visible')) return
|
||||
|
||||
var scrollHeight = $(document).height()
|
||||
, scrollTop = this.$window.scrollTop()
|
||||
, position = this.$element.offset()
|
||||
, offset = this.options.offset
|
||||
, offsetBottom = offset.bottom
|
||||
, offsetTop = offset.top
|
||||
, reset = 'affix affix-top affix-bottom'
|
||||
, affix
|
||||
|
||||
if (typeof offset != 'object') offsetBottom = offsetTop = offset
|
||||
if (typeof offsetTop == 'function') offsetTop = offset.top()
|
||||
if (typeof offsetBottom == 'function') offsetBottom = offset.bottom()
|
||||
|
||||
affix = this.unpin != null && (scrollTop + this.unpin <= position.top) ?
|
||||
false : offsetBottom != null && (position.top + this.$element.height() >= scrollHeight - offsetBottom) ?
|
||||
'bottom' : offsetTop != null && scrollTop <= offsetTop ?
|
||||
'top' : false
|
||||
|
||||
if (this.affixed === affix) return
|
||||
|
||||
this.affixed = affix
|
||||
this.unpin = affix == 'bottom' ? position.top - scrollTop : null
|
||||
|
||||
this.$element.removeClass(reset).addClass('affix' + (affix ? '-' + affix : ''))
|
||||
}
|
||||
|
||||
|
||||
/* AFFIX PLUGIN DEFINITION
|
||||
* ======================= */
|
||||
|
||||
$.fn.affix = function (option) {
|
||||
return this.each(function () {
|
||||
var $this = $(this)
|
||||
, data = $this.data('affix')
|
||||
, options = typeof option == 'object' && option
|
||||
if (!data) $this.data('affix', (data = new Affix(this, options)))
|
||||
if (typeof option == 'string') data[option]()
|
||||
})
|
||||
}
|
||||
|
||||
$.fn.affix.Constructor = Affix
|
||||
|
||||
$.fn.affix.defaults = {
|
||||
offset: 0
|
||||
}
|
||||
|
||||
|
||||
/* AFFIX DATA-API
|
||||
* ============== */
|
||||
|
||||
$(window).on('load', function () {
|
||||
$('[data-spy="affix"]').each(function () {
|
||||
var $spy = $(this)
|
||||
, data = $spy.data()
|
||||
|
||||
data.offset = data.offset || {}
|
||||
|
||||
data.offsetBottom && (data.offset.bottom = data.offsetBottom)
|
||||
data.offsetTop && (data.offset.top = data.offsetTop)
|
||||
|
||||
$spy.affix(data)
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
}(window.jQuery);
|
||||
|
|
@ -28,7 +28,10 @@ function setupClicker() {
|
|||
if (!$article.hasClass('methodToggleOpen') || this.force) {
|
||||
$article.addClass('methodToggleOpen');
|
||||
$arrow.removeClass('inactive').addClass('active');
|
||||
|
||||
|
||||
if (!$arrow[0])
|
||||
return;
|
||||
|
||||
var data = $arrow[0].id.replace(/^js_/, "");
|
||||
//var state = {};
|
||||
//state.section = data;
|
||||
|
|
@ -58,7 +61,7 @@ function setupClicker() {
|
|||
// for the top dropdown
|
||||
$('li.memberLink a').click(transformHash);
|
||||
|
||||
$('a[href^="#"]').click(transformHash);
|
||||
//$('a[href^="#"]').click(transformHash);
|
||||
|
||||
$('.related-to', '.metaInfo').click(function(){
|
||||
location.hash = $(this).find('a').attr('href').split('#')[1];
|
||||
|
|
|
|||
|
|
@ -1,22 +1,17 @@
|
|||
function setupDisqus() {
|
||||
function setupDisqus(href) {
|
||||
var disqus_shortname = 'aceapi';
|
||||
var dsqId = "disqusScript";
|
||||
|
||||
//var paths = window.location.pathname.split("/");
|
||||
//var fileName = paths[paths.length - 2] + "/" + paths[paths.length - 1];
|
||||
|
||||
//var disqus_identifier = fileName;
|
||||
|
||||
var lochash = location.hash.substr(1);
|
||||
var disqus_identifier = "api/" + (lochash.substr(lochash.indexOf('api=')).split('&')[0].split('=')[1] || "index") + ".html";
|
||||
var disqus_identifier = href.substring(2);
|
||||
|
||||
(function() {
|
||||
if (document.getElementById(dsqId))
|
||||
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).removeChild(document.getElementById(dsqId));
|
||||
|
||||
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
|
||||
dsq.src = 'https://' + disqus_shortname + '.disqus.com/embed.js';
|
||||
dsq.id="disqusScript";
|
||||
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
|
||||
if (document.getElementById("disqusScript") === null) {
|
||||
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
|
||||
dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
|
||||
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
|
||||
}
|
||||
})();
|
||||
}
|
||||
|
|
@ -39,8 +39,7 @@ mixin head
|
|||
script(src='#{dirPrefix}resources/javascripts/bbq.js')
|
||||
script(src="#{dirPrefix}resources/javascripts/jquery.collapse.js")
|
||||
script(src="#{dirPrefix}resources/javascripts/jquery.cookie.js")
|
||||
script(src="#{dirPrefix}resources/javascripts/bootstrap-dropdown.js")
|
||||
script(src='#{dirPrefix}resources/javascripts/bootstrap-tab.js')
|
||||
script(src="#{dirPrefix}resources/javascripts/bootstrap.js")
|
||||
|
||||
|
||||
mixin endingScripts
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ include lib
|
|||
|
||||
#documentation.span8
|
||||
-if (isIndex)
|
||||
!= content
|
||||
!= indexContent
|
||||
-else
|
||||
mixin api()
|
||||
|
||||
|
|
|
|||
|
|
@ -39,8 +39,7 @@ mixin head
|
|||
script(src='#{dirPrefix}resources/javascripts/bbq.js')
|
||||
script(src="#{dirPrefix}resources/javascripts/jquery.collapse.js")
|
||||
script(src="#{dirPrefix}resources/javascripts/jquery.cookie.js")
|
||||
script(src="#{dirPrefix}resources/javascripts/bootstrap-dropdown.js")
|
||||
script(src='#{dirPrefix}resources/javascripts/bootstrap-tab.js')
|
||||
script(src="#{dirPrefix}resources/javascripts/bootstrap.js")
|
||||
|
||||
|
||||
mixin endingScripts
|
||||
|
|
|
|||
BIN
doc/site/images/FineCut_small_logo.png
Normal file
|
After Width: | Height: | Size: 2.6 KiB |
BIN
doc/site/images/KERA-med-web.png
Normal file
|
After Width: | Height: | Size: 2.8 KiB |
BIN
doc/site/images/ac-logo.png
Normal file
|
After Width: | Height: | Size: 2.6 KiB |
BIN
doc/site/images/ace-logo.png
Normal file
|
After Width: | Height: | Size: 59 KiB |
BIN
doc/site/images/ace-tab.png
Normal file
|
After Width: | Height: | Size: 2.6 KiB |
BIN
doc/site/images/codiad.png
Normal file
|
After Width: | Height: | Size: 10 KiB |
BIN
doc/site/images/header-bg.png
Normal file
|
After Width: | Height: | Size: 154 B |
BIN
doc/site/images/ideone-logo.png
Normal file
|
After Width: | Height: | Size: 2.9 KiB |
BIN
doc/site/images/plunker.png
Normal file
|
After Width: | Height: | Size: 2.1 KiB |
BIN
doc/site/images/sassmeister-logo.png
Normal file
|
After Width: | Height: | Size: 6.1 KiB |
BIN
doc/site/images/spandexio-logo.png
Normal file
|
After Width: | Height: | Size: 10 KiB |
BIN
doc/site/images/textimage.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
doc/site/images/wolf_3d_logo_trans.png
Normal file
|
After Width: | Height: | Size: 45 KiB |
BIN
doc/site/images/zorba-logo.png
Normal file
|
After Width: | Height: | Size: 8 KiB |
|
|
@ -4,17 +4,16 @@ $(function() {
|
|||
hljs.initHighlighting();
|
||||
editor = ace.edit("ace_editor_demo");
|
||||
embedded_editor = ace.edit("embedded_ace_code");
|
||||
var javascriptMode = require("ace/mode/javascript").Mode;
|
||||
var htmlMode = require("ace/mode/html").Mode;
|
||||
editor.getSession().setMode(new javascriptMode());
|
||||
embedded_editor.getSession().setMode(new htmlMode());
|
||||
editor.getSession().setMode("ace/mode/javascript");
|
||||
editor.getSession().setMode("ace/mode/javascript");
|
||||
embedded_editor.getSession().setMode("ace/mode/html");
|
||||
|
||||
$("ul.menu-list li").click(function(e) {
|
||||
if (e.target.tagName === "LI") {
|
||||
console.log($(this).find("a"));
|
||||
window.location = $(this).find("a").attr("href");
|
||||
}
|
||||
else if (e.target.tagName === "P") {
|
||||
else if (e.target.tagName === "P" || e.target.tagName === "IMG") {
|
||||
var anchor = $(e.target).siblings();
|
||||
window.location = anchor.attr("href");
|
||||
}
|
||||
|
|
@ -28,8 +27,9 @@ $(function() {
|
|||
state.api = $(this).attr("href").substring(6, $(this).attr("href").length - 5);
|
||||
$.bbq.pushState(state);
|
||||
|
||||
$("#apiHolder").removeClass("apiIntro").removeClass("span8");
|
||||
var _self = $(this);
|
||||
$("#apiHolder").load($(this).attr("href") + " #documentation", function(){
|
||||
$("#apiHolder").removeClass("apiIntro").removeClass("span8");
|
||||
ux();
|
||||
setupClicker();
|
||||
|
||||
|
|
@ -39,33 +39,17 @@ $(function() {
|
|||
$("li#dropdown_" + section.replace(/\./g, '\\.') + " a").triggerHandler('click');
|
||||
}
|
||||
|
||||
setupDisqus();
|
||||
//setupDisqus(_self.attr("href"));
|
||||
});
|
||||
}
|
||||
|
||||
$('.menu-item a').click(magicClickInterceptor);
|
||||
$('a.argument').click(function (e) {
|
||||
e.preventDefault();
|
||||
|
||||
var state = {};
|
||||
state.api = $(this).attr("href").substring(6, $(this).attr("href").length - 5);
|
||||
$.bbq.pushState(state);
|
||||
|
||||
$("#apiHolder").load($(this).attr("href") + " #documentation", function(){
|
||||
$("#apiHolder").removeClass("apiIntro").removeClass("span8");
|
||||
ux();
|
||||
setupClicker();
|
||||
|
||||
// handles dropping in from new link
|
||||
var section = $.bbq.getState("section");
|
||||
if (section) {
|
||||
$("li#dropdown_" + section.replace(/\./g, '\\.') + " a").triggerHandler('click');
|
||||
}
|
||||
|
||||
setupDisqus();
|
||||
});
|
||||
});
|
||||
$('a.argument').click(magicClickInterceptor);
|
||||
|
||||
$('a.external').click(function(e) {
|
||||
e.preventDefault();
|
||||
});
|
||||
|
||||
var tabs = $("#tabnav"),
|
||||
tab_a_selector = "a";
|
||||
|
||||
|
|
@ -75,8 +59,10 @@ $(function() {
|
|||
e.preventDefault();
|
||||
embedded_editor.resize();
|
||||
editor.resize();
|
||||
if ($(this).attr("href") === "/")
|
||||
if ($(this).attr("href") === "/") {
|
||||
window.location = "http://ace.ajax.org";
|
||||
return;
|
||||
}
|
||||
if ($(this).attr("href").indexOf("#api") === 0) {
|
||||
$("#top_container").addClass("collapse");
|
||||
scrollIntoPosition(null, 0);
|
||||
|
|
@ -103,7 +89,7 @@ $(function() {
|
|||
}
|
||||
else if ($("body").scrollTop() > 345) {
|
||||
$("body").stop().animate({
|
||||
scrollTop: ($(el).offset().top - 15)
|
||||
scrollTop: ($(el).offset().top - 10)
|
||||
}, 400);
|
||||
}
|
||||
}
|
||||
|
|
@ -116,8 +102,10 @@ $(function() {
|
|||
});
|
||||
|
||||
$(window).on("hashchange", function(e) {
|
||||
_gaq.push(['_trackPageview',location.pathname + location.search + location.hash]);
|
||||
tabs.each(function() {
|
||||
var idx = $.bbq.getState("nav") || "about";
|
||||
var section = e.fragment.split("&")[1] || "";
|
||||
$(this).find(tab_a_selector + "[href='#" + idx + "']").triggerHandler('click');
|
||||
|
||||
// handles dropping in from new link
|
||||
|
|
|
|||
|
|
@ -5,6 +5,10 @@ body {
|
|||
font-family: Helvetica, Arial;
|
||||
}
|
||||
|
||||
#embed_ace_wrapper {
|
||||
height: 525px;
|
||||
}
|
||||
|
||||
.ace_editor_wrapper {
|
||||
height: 275px;
|
||||
position: relative;
|
||||
|
|
@ -49,6 +53,7 @@ H3 {
|
|||
H4 {
|
||||
font-size:21px;
|
||||
color:#222222;
|
||||
margin-bottom:8px;
|
||||
}
|
||||
|
||||
P {
|
||||
|
|
@ -143,14 +148,15 @@ UL{
|
|||
float: left;
|
||||
font-weight: 100;
|
||||
font-family: Helvetica;
|
||||
padding-top: 20px;
|
||||
padding: 65px 0 0 14px;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
#top_container {
|
||||
background: url(images/header-bg.png) 0 0;
|
||||
overflow: hidden;
|
||||
padding: 15px 40px;
|
||||
height: 280px;
|
||||
padding: 11px 36px 19px 40px;
|
||||
height: 267px;
|
||||
-webkit-transition: height 0.4s ease-out, opacity 0.4s ease-out, padding 0.4s ease-out, margin 0.4s ease-out;
|
||||
-moz-transition: height 0.4s ease-out, opacity 0.4s ease-out, padding 0.4s ease-out, margin 0.4s ease-out;
|
||||
opacity: 1;
|
||||
|
|
@ -165,12 +171,11 @@ UL{
|
|||
}
|
||||
|
||||
#page_logo {
|
||||
padding: 15px 0;
|
||||
padding: 35px 0 15px 0;
|
||||
width: 350px;
|
||||
float: right;
|
||||
text-align: center;
|
||||
height: 220px;
|
||||
padding-top: 45px;
|
||||
}
|
||||
|
||||
.fork_on_github {
|
||||
|
|
@ -245,6 +250,14 @@ ul.menu-list li {
|
|||
hsl(0,0%,90%) 47%,
|
||||
hsl(0,0%,78%) 53%,
|
||||
hsl(0,0%,70%)100%);
|
||||
background-image: -moz-repeating-linear-gradient(left, hsla(0,0%,100%,0) 0%, hsla(0,0%,100%,0) 6%, hsla(0,0%,100%, .1) 7.5%),
|
||||
-moz-repeating-linear-gradient(left, hsla(0,0%, 0%,0) 0%, hsla(0,0%, 0%,0) 4%, hsla(0,0%, 0%,.03) 4.5%),
|
||||
-moz-repeating-linear-gradient(left, hsla(0,0%,100%,0) 0%, hsla(0,0%,100%,0) 1.2%, hsla(0,0%,100%,.15) 2.2%),
|
||||
|
||||
-moz-linear-gradient(-90deg, hsl(0,0%,78%) 0%,
|
||||
hsl(0,0%,90%) 47%,
|
||||
hsl(0,0%,78%) 53%,
|
||||
hsl(0,0%,70%)100%);
|
||||
}
|
||||
|
||||
ul.menu-list li:hover {
|
||||
|
|
@ -276,7 +289,7 @@ li#add_your_site p {
|
|||
border: 3px solid #34A034;
|
||||
color: #34A034;
|
||||
border-radius: 34px;
|
||||
padding: 3px 4px 4px 6px;
|
||||
padding: 3px 4px 4px 5px;
|
||||
width: 20px;
|
||||
height: 22px;
|
||||
line-height: 18px;
|
||||
|
|
@ -351,7 +364,7 @@ UL.menu-footer LI A:hover {
|
|||
}
|
||||
|
||||
.nav-pills.nav {
|
||||
margin: 25px 0 25px 0;
|
||||
margin: 10px 0 25px 0;
|
||||
padding: 0;
|
||||
border-radius: 5px;
|
||||
border: 1px solid #d7d7d7;
|
||||
|
|
@ -370,7 +383,7 @@ UL.menu-footer LI A:hover {
|
|||
color: white;
|
||||
background-color: #555;
|
||||
box-shadow: inset 0 0 8px rgba(0, 0, 0, 0.8);
|
||||
text-shadow: none;
|
||||
text-shadow: 0px 0px 3px #000;
|
||||
}
|
||||
|
||||
.nav-tabs > li > a, .nav-pills > li > a {
|
||||
|
|
@ -379,7 +392,7 @@ UL.menu-footer LI A:hover {
|
|||
border-right: 1px solid #bbb;
|
||||
border-radius: 0;
|
||||
margin: 0;
|
||||
line-height: 24px;
|
||||
line-height: 25px;
|
||||
font-size: 14px;
|
||||
color: #333;
|
||||
text-shadow: 1px 1px 0 rgba(255, 255, 255, 0.3);
|
||||
|
|
@ -413,12 +426,15 @@ UL.menu-footer LI A:hover {
|
|||
}
|
||||
|
||||
#top_container, .tab-content > .active, .pill-content > .active {
|
||||
background: rgba(255, 255, 255, 0.7);
|
||||
border: 1px solid #DDD;
|
||||
border-radius: 5px;
|
||||
-moz-border-radius: 5px;
|
||||
}
|
||||
|
||||
.tab-content > .active, .pill-content > .active {
|
||||
background: rgba(255, 255, 255, 0.7);
|
||||
}
|
||||
|
||||
pre .xml .javascript, pre .xml .css {
|
||||
opacity: 1;
|
||||
}
|
||||
|
|
@ -462,4 +478,16 @@ p.highlight_note a {
|
|||
.apiIntro {
|
||||
padding-left: 15px;
|
||||
padding-bottom: 10px;
|
||||
}
|
||||
|
||||
.prod_no_image {
|
||||
position: relative; left: -10px; top: -12px;
|
||||
}
|
||||
|
||||
#sidebarContainer {
|
||||
margin: 0px 20px 0 15px;
|
||||
}
|
||||
|
||||
#api {
|
||||
padding: 0;
|
||||
}
|
||||
122
index.html
|
|
@ -5,11 +5,8 @@
|
|||
<title>ACE - The High Performance Code Editor for the Web</title>
|
||||
<script src="./doc/resources/ace/skeleton/javascripts/jquery.js"></script>
|
||||
<script src="./doc/resources/ace/skeleton/javascripts/bbq.js"></script>
|
||||
<script src="./api/resources/javascripts/bootstrap-tab.js"></script>
|
||||
<script src="./api/resources/javascripts/bootstrap-dropdown.js"></script>
|
||||
<script src="https://raw.github.com/ajaxorg/ace-builds/master/src-min/ace.js"></script>
|
||||
<script src="https://raw.github.com/ajaxorg/ace-builds/master/src-min/mode-javascript.js"></script>
|
||||
<script src="https://raw.github.com/ajaxorg/ace-builds/master/src-min/mode-html.js"></script>
|
||||
<script src="./api/resources/javascripts/bootstrap.js"></script>
|
||||
<script src="https://d1n0x3qji82z53.cloudfront.net/src-min-noconflict/ace.js"></script>
|
||||
<script src="https://yandex.st/highlightjs/7.2/highlight.min.js"></script>
|
||||
<script src="doc/site/js/main.js"></script>
|
||||
<link rel="stylesheet" href="https://yandex.st/highlightjs/7.0/styles/default.min.css">
|
||||
|
|
@ -17,8 +14,6 @@
|
|||
<link href="doc/site/style.css" rel="stylesheet" type="text/css" />
|
||||
<link href="api/resources/csses/ace_api.css" rel="stylesheet" type="text/css" />
|
||||
<link rel="stylesheet" href="./api/resources/csses/font-awesome.css">
|
||||
<link rel="stylesheet" media="all and (max-device-width: 480px)" href="doc/site/iphone.css">
|
||||
<link rel="stylesheet" media="all and (min-device-width: 481px) and (max-device-width: 1024px)" href="doc/site/iphone.css">
|
||||
<link href="./doc/resources/ace/skeleton/images/favicon.ico" rel="icon" type="image/x-icon">
|
||||
</head>
|
||||
<body>
|
||||
|
|
@ -30,15 +25,18 @@
|
|||
<div class="content">
|
||||
<div class="column2">
|
||||
<div id="top_container" class="collapse">
|
||||
<h1>The high performance code editor for the web.</h1>
|
||||
<h1><img src="https://d1n0x3qji82z53.cloudfront.net/textimage.png"
|
||||
alt="The high performance code editor for the web." /></h1>
|
||||
<div id="page_logo">
|
||||
<img src="doc/site/images/logo.png" />
|
||||
<img src="https://d1n0x3qji82z53.cloudfront.net/ace-logo.png" />
|
||||
<iframe style="padding-top:5px" src="http://ghbtns.com/github-btn.html?user=ajaxorg&repo=ace&type=watch&count=true" allowtransparency="true" frameborder="0" scrolling="0" width="110px" height="20px"></iframe>
|
||||
<iframe src="http://ghbtns.com/github-btn.html?user=ajaxorg&repo=ace&type=fork&count=true" allowtransparency="true" frameborder="0" scrolling="0" width="95px" height="20px"></iframe>
|
||||
</div>
|
||||
</div>
|
||||
<div style="clear: both"></div>
|
||||
<ul id="tabnav" class="nav nav-pills">
|
||||
<li>
|
||||
<a href="/"><img src="api/resources/images/ace_logo_menu.png" /></a>
|
||||
<a href="/"><img src="./doc/site/images/ace-tab.png" /></a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#about" data-toggle="tab">About</a>
|
||||
|
|
@ -70,7 +68,7 @@
|
|||
and is the successor of the Mozilla Skywriter (Bespin) project.</p>
|
||||
<div class="ace_editor_wrapper">
|
||||
<div id="ace_editor_demo">/**
|
||||
* In fact, you're looking at ACE right now.
|
||||
* 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
|
||||
* language modes and 24 color themes!
|
||||
|
|
@ -88,7 +86,7 @@ console.log(addResult);</div>
|
|||
<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
|
||||
<a href="http://ace.ajax.org/build/kitchen-sink.html" target="_blank">kitchen sink</a>.</p>
|
||||
<h2>ACE Features</h2>
|
||||
<h2>Features</h2>
|
||||
<ul class="content-list">
|
||||
<li><a href="http://pcwalton.blogspot.com/2010/11/syntax-highlighting-specification.html">Syntax highlighting</a> for over 40 languages (TextMate/Sublime/<em>.tmlanguage</em> files can be imported)</li>
|
||||
<li>Over 20 themes (TextMate/Sublime/<em>.tmtheme</em> files can be imported)</li>
|
||||
|
|
@ -139,9 +137,9 @@ console.log(addResult);</div>
|
|||
</div>
|
||||
<div class="tab-pane fade active in" id="embedding">
|
||||
<h1>Embedding ACE in Your Site</h1>
|
||||
<p>ACE can be easily embedded into a web page:</p>
|
||||
<p>ACE can be easily embedded into a web page. Just copy the code below:</p>
|
||||
|
||||
<div class="ace_editor_wrapper">
|
||||
<div id="embed_ace_wrapper" class="ace_editor_wrapper">
|
||||
<div id="embedded_ace_code"><!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
|
|
@ -163,10 +161,10 @@ console.log(addResult);</div>
|
|||
return x;
|
||||
}</div>
|
||||
|
||||
<script src="src-noconflict/ace.js" type="text/javascript" charset="utf-8"></script>
|
||||
<script src="http://d1n0x3qji82z53.cloudfront.net/src-min-noconflict/ace.js" type="text/javascript" charset="utf-8"></script>
|
||||
<script>
|
||||
var editor = ace.edit("editor");
|
||||
editor.setTheme("ace/theme/twilight");
|
||||
editor.setTheme("ace/theme/monokai");
|
||||
editor.getSession().setMode("ace/mode/javascript");
|
||||
</script>
|
||||
</body>
|
||||
|
|
@ -175,7 +173,10 @@ console.log(addResult);</div>
|
|||
common operations, such as setting a different language mode or
|
||||
getting the contents from the editor.</p>
|
||||
<h2>Loading ACE from a Local URL</h2>
|
||||
<p>The above code is sufficient to get started, but if you want to clone host ACE locally you can
|
||||
<p>The above code is all you need to embed ACE in your site (including setting language modes
|
||||
and themes). Plus it's super fast because it's on Amazon's distributed content network.
|
||||
</p>
|
||||
<p>But, if you want to clone host ACE locally you can
|
||||
use one of the <a href="https://github.com/ajaxorg/ace-builds/">pre-packaged versions</a>. Just copy
|
||||
one of <code>src*</code> subdirectories somewhere into your project, or use RequireJS to load the
|
||||
contents of <a href="https://github.com/ajaxorg/ace/tree/master/lib/ace">lib/ace</a> as <code>ace</code>:</p>
|
||||
|
|
@ -189,17 +190,14 @@ console.log(addResult);</div>
|
|||
<p>Themes are loaded on demand; all you have to do is pass the string name:</p>
|
||||
|
||||
<pre><code class="javascript">editor.setTheme("ace/theme/twilight");</code></pre>
|
||||
<p><span class="expand_arrow">></span> (See all themes)</p>
|
||||
<p><span class="expand_arrow">></span> <a href="https://github.com/ajaxorg/ace/tree/master/lib/ace/theme"
|
||||
target="_blank">See all themes</a></p>
|
||||
|
||||
<h2>Setting the Programming Language Mode</h2>
|
||||
<p>By default, the editor supports plain text mode. All other language modes are available as separate modules, loaded on demand like this:</p>
|
||||
<pre><code class="javascript">editor.getSession().setMode("ace/mode/javascript");</pre></code>
|
||||
|
||||
<pre><code class="javascript"><script src="src/mode-javascript.js" type="text/javascript" charset="utf-8"></script></code></pre>
|
||||
<p>The mode can then be used like this:</p>
|
||||
<pre><code class="javascript">var javascriptMode = require("ace/mode/javascript").Mode;
|
||||
editor.getSession().setMode(new javascriptMode());</pre></code>
|
||||
|
||||
<h2>One Editor, Multiple Sessions</h2>
|
||||
<!--h2>One Editor, Multiple Sessions</h2>
|
||||
<p>ACE keeps everything about the state of the editor (selection, scroll position, etc.)
|
||||
in <code class="javascript">editor.session</code>. This means you can grab the
|
||||
session, store it in a var, and set the editor to another session (e.g. a tabbed editor).</p>
|
||||
|
|
@ -209,10 +207,10 @@ editor.getSession().setMode(new javascriptMode());</pre></code>
|
|||
var js = new EditSession("some js code");
|
||||
var css = new EditSession(["some", "css", "code here"]);
|
||||
// and then to load document into editor, just call
|
||||
editor.setSession(js);</code></pre>
|
||||
editor.setSession(js);</code></pre-->
|
||||
|
||||
<h2>Common Operations</h2>
|
||||
<p>Set and get content:`</p>
|
||||
<p>Set and get content:</p>
|
||||
|
||||
<pre><code class="javascript">editor.setValue("the new text here"); // or session.setValue
|
||||
editor.getValue(); // or session.getValue</code></pre>
|
||||
|
|
@ -344,7 +342,7 @@ editor.replace('bar');</code></pre>
|
|||
//...
|
||||
}
|
||||
});</code></pre>
|
||||
<h3>Importing Themes and Languages</h3>
|
||||
<h3 id ="importing">Importing Themes and Languages</h3>
|
||||
<p>ACE supports the importing of <em>.tmtheme</em> and <em>.tmlanguage</em> files for use
|
||||
in the editor. The task is accomplished by two simple node scripts.</p>
|
||||
|
||||
|
|
@ -429,8 +427,8 @@ tests for the highlighting.</p>
|
|||
</div>
|
||||
<div class="span8">
|
||||
<div id="apiHolder" class="span8 apiIntro"><h1>Ace API Reference</h1>
|
||||
<p>Welcome to the Ace API Reference Guide. Ace is a standalone code editor written in JavaScript that you can embed onto any website. We're used in a bunch of places already, like GitHub, Google, and Facebook.</p>
|
||||
<p>On the left, you'll find a list of all of our currently documented classes. There are plenty more to do, but these represent the "core" set. For more information on how to work with Ace, check out the <a href="#nav=howto">embedding guide</a>.</p>
|
||||
<p>Welcome to the Ace API Reference!</p>
|
||||
<p>On the left, you'll find a list of all of our currently documented classes. There are plenty more to do, but these represent the "core" set. For more information on how to work with Ace, check out the <a href="#nav=embedding">embedding guide</a>.</p>
|
||||
</div>
|
||||
</div></div>
|
||||
</div>
|
||||
|
|
@ -451,13 +449,13 @@ tests for the highlighting.</p>
|
|||
</li>
|
||||
<li>
|
||||
<img src="doc/site/images/cloud9-logo.png"
|
||||
style="position: relative; left: -13px; top: -13px;" />
|
||||
style="position: relative;left: -11px;top:-12px; width:122px" />
|
||||
<a href="https://github.com/ajaxorg/cloud9">Cloud9 IDE</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<img src="doc/site/images/firefox-logo.png"
|
||||
style="position: relative; left: 0px; top: -20px;" />
|
||||
style="position: relative;left:10px;top:-5px;width:80px" />
|
||||
<a href="https://builder.addons.mozilla.org/">Firefox Add-on Builder</a>
|
||||
</li>
|
||||
<li>
|
||||
|
|
@ -470,10 +468,61 @@ tests for the highlighting.</p>
|
|||
style="position: relative; left: 19px; top: 2px;" />
|
||||
<a href="http://rstudio.org/">RStudio</a>
|
||||
</li>
|
||||
<li><a href="https://github.com/Gozala/sky-edit">Sky Edit</a></li>
|
||||
<li>
|
||||
<img src="doc/site/images/empty-logo.png"
|
||||
style="position: relative; left: -10px; top: -12px;" />
|
||||
<img src="doc/site/images/ac-logo.png"
|
||||
style="position: relative; left: 4px; top: 25px;" />
|
||||
<a href="http://www.applicationcraft.com/">Application Craft</a>
|
||||
</li>
|
||||
<li>
|
||||
<img src="doc/site/images/wolf_3d_logo_trans.png"
|
||||
style="position: relative; left: 10px; top: -4px; width:80px" />
|
||||
<a href="http://www.wolfcms.org/repository/133">Wolf CMS</a>
|
||||
</li>
|
||||
<li>
|
||||
<img src="doc/site/images/codiad.png"
|
||||
style="position: relative; left: 10px; top: -4px; width:80px" />
|
||||
<a href="http://codiad.com/">Codiad</a>
|
||||
</li>
|
||||
<li>
|
||||
<img src="doc/site/images/FineCut_small_logo.png"
|
||||
style="position: relative; left: 12px; top: -4px" />
|
||||
<a href="http://finecut.info/">Fine Cut Engine</a>
|
||||
</li>
|
||||
<li>
|
||||
<img src="doc/site/images/zorba-logo.png"
|
||||
style="position: relative; left: -5px; top: 16px;
|
||||
padding: 6px 4px 6px 6px; width: 100px" />
|
||||
<a href="http://www.zorba-xquery.com/html/demo">Zorba XQuery</a>
|
||||
</li>
|
||||
<li>
|
||||
<img src="doc/site/images/plunker.png"
|
||||
style="position: relative; left: 13px; top: -4px; width: 75px" />
|
||||
<a href="http://plnkr.co/edit/">Plunker</a>
|
||||
</li>
|
||||
<li>
|
||||
<img src="doc/site/images/KERA-med-web.png"
|
||||
style="position: relative; left: 3px;top: 23px;width: 97px;" />
|
||||
<a href="http://kera.io/">Kera.io</a>
|
||||
</li>
|
||||
<li>
|
||||
<img src="doc/site/images/sassmeister-logo.png"
|
||||
style="position: relative; left: 10px;top: -5px;width: 80px;" />
|
||||
<a href="http://sassmeister.com/">SassMeister</a>
|
||||
</li>
|
||||
<li>
|
||||
<img src="doc/site/images/spandexio-logo.png"
|
||||
style="position: relative; left: 10px;top: -5px;width: 80px;" />
|
||||
<a href="http://SpanDeX.io/">SpanDeX.io</a>
|
||||
</li>
|
||||
<li>
|
||||
<img src="doc/site/images/ideone-logo.png"
|
||||
style="position: relative; left: -5px; top: 20px;">
|
||||
<a href="http://ideone.com">Ideone.com</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://github.com/Gozala/sky-edit">Sky Edit</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="http://www.wavemaker.com/">WaveMaker</a>
|
||||
</li>
|
||||
<li>
|
||||
|
|
@ -492,8 +541,11 @@ tests for the highlighting.</p>
|
|||
<a href="http://www.pythonanywhere.com/">PythonAnywhere</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="http://shiftedit.net/">shiftEdit</a>
|
||||
<a href="http://shiftedit.net/">ShiftEdit</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="http://sharejs.org/hello-ace.html">ShareJS</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="http://www.akshell.com/">Akshell</a>
|
||||
</li>
|
||||
|
|
|
|||
49
install.js
|
|
@ -33,27 +33,36 @@
|
|||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
var buildAce = require("./Makefile.dryice").buildAce;
|
||||
|
||||
var fs = require("fs");
|
||||
|
||||
var ACE_HOME = __dirname;
|
||||
|
||||
try {
|
||||
var aceProject = {
|
||||
roots: [
|
||||
ACE_HOME + '/lib',
|
||||
ACE_HOME + '/demo'
|
||||
],
|
||||
textPluginPattern: /^ace\/requirejs\/text!/
|
||||
};
|
||||
buildAce(aceProject, {
|
||||
compress: false,
|
||||
noconflict: false,
|
||||
suffix: "",
|
||||
compat: true,
|
||||
name: "ace"
|
||||
});
|
||||
} catch (e) {
|
||||
console.log("--- Ace Build error ---");
|
||||
console.log(e);
|
||||
process.exit(0);
|
||||
function getVersion(path) {
|
||||
if (fs.existsSync(path + "/.git-ref"))
|
||||
return fs.readFileSync(path + "/.git-ref", "utf8");
|
||||
if (fs.existsSync(path + "/.git/ORIG_HEAD"))
|
||||
return fs.readFileSync(path + "/.git/ORIG_HEAD", "utf8");
|
||||
}
|
||||
|
||||
if (process.argv.indexOf("-c") > 0) try {
|
||||
var version = getVersion(ACE_HOME);
|
||||
var oldVersion = getVersion(ACE_HOME + "/build");
|
||||
if (version && oldVersion == version) {
|
||||
console.log("ace build is up to date");
|
||||
process.exit(0);
|
||||
}
|
||||
fs.writeFileSync(ACE_HOME + "/build/.git-ref", version, "utf8");
|
||||
} catch (e) {}
|
||||
|
||||
try {
|
||||
buildAce({
|
||||
compress: false,
|
||||
noconflict: false,
|
||||
suffix: "",
|
||||
name: "ace"
|
||||
});
|
||||
} catch (e) {
|
||||
console.log("--- Ace Build error ---");
|
||||
console.log(e);
|
||||
process.exit(0);
|
||||
}
|
||||
|
|
@ -1,5 +1,4 @@
|
|||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
|
||||
"http://www.w3.org/TR/html4/strict.dtd">
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html lang="en">
|
||||
<head>
|
||||
|
|
@ -7,25 +6,29 @@
|
|||
<title>Ace Kitchen Sink</title>
|
||||
<meta name="author" content="Fabian Jakobs">
|
||||
<!--
|
||||
|
||||
Ace
|
||||
version %version%
|
||||
commit %commit%
|
||||
|
||||
-->
|
||||
|
||||
<!--DEVEL-->
|
||||
<link rel="stylesheet" href="demo/kitchen-sink/styles.css" type="text/css" media="screen" charset="utf-8">
|
||||
<script src="http://use.edgefonts.net/source-code-pro.js"></script>
|
||||
<!--DEVEL-->
|
||||
|
||||
<!--PACKAGE
|
||||
<link rel="stylesheet" href="kitchen-sink/styles.css" type="text/css" media="screen" charset="utf-8">
|
||||
<script src="http://use.edgefonts.net/source-code-pro.js"></script>
|
||||
PACKAGE-->
|
||||
</head>
|
||||
<body>
|
||||
<div id="optionsPanel" style="position:absolute;height:100%">
|
||||
<a href="http://ajaxorg.github.com/ace/" >
|
||||
<img id="logo" src="demo/kitchen-sink/logo.png">
|
||||
</a>
|
||||
<div style="position: absolute; overflow: hidden; top:80px; bottom:0">
|
||||
<div style="width: 120%; height:100%; overflow-y: scroll">
|
||||
|
||||
<table id="controls">
|
||||
<tr>
|
||||
<td>
|
||||
|
|
@ -70,8 +73,10 @@
|
|||
<option value="ace/theme/solarized_light">Solarized Light</option>
|
||||
<option value="ace/theme/textmate" selected="selected">TextMate</option>
|
||||
<option value="ace/theme/tomorrow">Tomorrow</option>
|
||||
<option value="ace/theme/xcode">XCode</option>
|
||||
</optgroup>
|
||||
<optgroup label="Dark">
|
||||
<option value="ace/theme/ambiance">Ambiance</option>
|
||||
<option value="ace/theme/clouds_midnight">Clouds Midnight</option>
|
||||
<option value="ace/theme/cobalt">Cobalt</option>
|
||||
<option value="ace/theme/idle_fingers">idleFingers</option>
|
||||
|
|
@ -232,9 +237,20 @@
|
|||
<input type="checkbox" id="fade_fold_widgets">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td >
|
||||
<label for="highlight_token">Show token info</label>
|
||||
</td>
|
||||
<td>
|
||||
<input type="checkbox" id="highlight_token">
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td></tr>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="editor"></div>
|
||||
|
||||
|
|
|
|||
|
|
@ -53,8 +53,8 @@ var MultiSelect = require("./multi_select").MultiSelect;
|
|||
// The following require()s are for inclusion in the built ace file
|
||||
require("./worker/worker_client");
|
||||
require("./keyboard/hash_handler");
|
||||
require("./keyboard/state_handler");
|
||||
require("./placeholder");
|
||||
require("./mode/folding/fold_mode");
|
||||
exports.config = require("./config");
|
||||
/**
|
||||
* Ace.edit(el) -> Editor
|
||||
|
|
|
|||
|
|
@ -321,6 +321,11 @@ exports.commands = [{
|
|||
bindKey: bindKey("Ctrl-Shift-D", "Command-Shift-D"),
|
||||
exec: function(editor) { editor.duplicateSelection(); },
|
||||
multiSelectAction: "forEach"
|
||||
}, {
|
||||
name: "sortlines",
|
||||
bindKey: bindKey("Ctrl-Alt-S", "Command-Alt-S"),
|
||||
exec: function(editor) { editor.sortLines(); },
|
||||
multiSelectAction: "forEach"
|
||||
}, {
|
||||
name: "togglecomment",
|
||||
bindKey: bindKey("Ctrl-/", "Command-/"),
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
.ace_editor {
|
||||
position: absolute;
|
||||
overflow: hidden;
|
||||
font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Droid Sans Mono', 'Consolas', monospace;
|
||||
font-family: 'Menlo', 'Monaco', 'Ubuntu Mono', 'Consolas', 'source-code-pro', monospace;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
|
|
@ -12,9 +12,9 @@
|
|||
|
||||
.ace_content {
|
||||
position: absolute;
|
||||
box-sizing: border-box;
|
||||
-moz-box-sizing: border-box;
|
||||
-webkit-box-sizing: border-box;
|
||||
box-sizing: border-box;
|
||||
cursor: text;
|
||||
}
|
||||
|
||||
|
|
@ -27,13 +27,13 @@
|
|||
z-index: 4;
|
||||
}
|
||||
|
||||
.ace_gutter_active_line {
|
||||
.ace_gutter-active-line {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
right: 0;
|
||||
}
|
||||
|
||||
.ace_scroller.horscroll {
|
||||
.ace_scroller.ace_scroll-left {
|
||||
box-shadow: 17px 0 16px -16px rgba(0, 0, 0, 0.4) inset;
|
||||
}
|
||||
|
||||
|
|
@ -62,50 +62,40 @@
|
|||
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyRpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMy1jMDExIDY2LjE0NTY2MSwgMjAxMi8wMi8wNi0xNDo1NjoyNyAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNiAoTWFjaW50b3NoKSIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDpGRTk5MTVGREIxNDkxMUUxOTc5Q0FFREQyMTNGMjBFQyIgeG1wTU06RG9jdW1lbnRJRD0ieG1wLmRpZDpGRTk5MTVGRUIxNDkxMUUxOTc5Q0FFREQyMTNGMjBFQyI+IDx4bXBNTTpEZXJpdmVkRnJvbSBzdFJlZjppbnN0YW5jZUlEPSJ4bXAuaWlkOkZFOTkxNUZCQjE0OTExRTE5NzlDQUVERDIxM0YyMEVDIiBzdFJlZjpkb2N1bWVudElEPSJ4bXAuZGlkOkZFOTkxNUZDQjE0OTExRTE5NzlDQUVERDIxM0YyMEVDIi8+IDwvcmRmOkRlc2NyaXB0aW9uPiA8L3JkZjpSREY+IDwveDp4bXBtZXRhPiA8P3hwYWNrZXQgZW5kPSJyIj8+SIDkjAAAAJ1JREFUeNpi/P//PwMlgImBQkB7A6qrq/+DMC55FkIGKCoq4pVnpFkgTp069f/+/fv/r1u37r+tre1/kg0A+ptn9uzZYLaRkRHpLvjw4cNXWVlZhufPnzOcO3eOdAO0tbVPAjHDmzdvGA4fPsxIsgGSkpJmv379Ynj37h2DjIyMCMkG3LhxQ/T27dsMampqDHZ2dq/pH41DxwCAAAMAFdc68dUsFZgAAAAASUVORK5CYII=");
|
||||
}
|
||||
|
||||
.ace_editor .ace_sb {
|
||||
.ace_scrollbar {
|
||||
position: absolute;
|
||||
overflow-x: hidden;
|
||||
overflow-y: scroll;
|
||||
right: 0;
|
||||
}
|
||||
|
||||
.ace_editor .ace_sb div {
|
||||
.ace_scrollbar-inner {
|
||||
position: absolute;
|
||||
width: 1px;
|
||||
left: 0;
|
||||
}
|
||||
|
||||
.ace_editor .ace_print_margin_layer {
|
||||
z-index: 0;
|
||||
position: absolute;
|
||||
overflow: hidden;
|
||||
margin: 0;
|
||||
left: 0;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.ace_editor .ace_print_margin {
|
||||
.ace_print-margin {
|
||||
position: absolute;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.ace_editor > textarea {
|
||||
.ace_text-input {
|
||||
position: absolute;
|
||||
z-index: 0;
|
||||
width: 0.5em;
|
||||
height: 1em;
|
||||
opacity: 0;
|
||||
background: transparent;
|
||||
appearance: none;
|
||||
-moz-appearance: none;
|
||||
appearance: none;
|
||||
border: none;
|
||||
resize: none;
|
||||
outline: none;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.ace_editor > textarea.ace_composition {
|
||||
.ace_text-input.ace_composition {
|
||||
background: #fff;
|
||||
color: #000;
|
||||
z-index: 1000;
|
||||
|
|
@ -121,15 +111,15 @@
|
|||
white-space: nowrap;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
-moz-box-sizing: border-box;
|
||||
-webkit-box-sizing: border-box;
|
||||
box-sizing: border-box;
|
||||
/* setting pointer-events: auto; on node under the mouse, which changes
|
||||
during scroll, will break mouse wheel scrolling in Safari */
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.ace_gutter .ace_layer {
|
||||
.ace_gutter-layer {
|
||||
position: relative;
|
||||
width: auto;
|
||||
text-align: right;
|
||||
|
|
@ -153,13 +143,16 @@
|
|||
.ace_cursor {
|
||||
z-index: 4;
|
||||
position: absolute;
|
||||
-moz-box-sizing: border-box;
|
||||
-webkit-box-sizing: border-box;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.ace_cursor.ace_hidden {
|
||||
opacity: 0.2;
|
||||
}
|
||||
|
||||
.ace_editor.multiselect .ace_cursor {
|
||||
.ace_editor.ace_multiselect .ace_cursor {
|
||||
border-left-width: 1px;
|
||||
}
|
||||
|
||||
|
|
@ -182,23 +175,23 @@
|
|||
z-index: 6;
|
||||
}
|
||||
|
||||
.ace_marker-layer .ace_active_line {
|
||||
.ace_marker-layer .ace_active-line {
|
||||
position: absolute;
|
||||
z-index: 2;
|
||||
}
|
||||
|
||||
.ace_marker-layer .ace_selected_word {
|
||||
.ace_marker-layer .ace_selected-word {
|
||||
position: absolute;
|
||||
z-index: 4;
|
||||
box-sizing: border-box;
|
||||
-moz-box-sizing: border-box;
|
||||
-webkit-box-sizing: border-box;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.ace_line .ace_fold {
|
||||
box-sizing: border-box;
|
||||
-moz-box-sizing: border-box;
|
||||
-webkit-box-sizing: border-box;
|
||||
box-sizing: border-box;
|
||||
|
||||
display: inline-block;
|
||||
height: 11px;
|
||||
|
|
@ -232,11 +225,11 @@
|
|||
background-position: center center, top left;
|
||||
}
|
||||
|
||||
.ace_dragging .ace_content {
|
||||
.ace_editor.ace_dragging .ace_content {
|
||||
cursor: move;
|
||||
}
|
||||
|
||||
.ace_gutter_tooltip {
|
||||
.ace_gutter-tooltip {
|
||||
background-color: #FFFFD5;
|
||||
border: 1px solid gray;
|
||||
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.4);
|
||||
|
|
@ -245,10 +238,12 @@
|
|||
padding: 4px;
|
||||
position: absolute;
|
||||
z-index: 300;
|
||||
box-sizing: border-box;
|
||||
-moz-box-sizing: border-box;
|
||||
-webkit-box-sizing: border-box;
|
||||
box-sizing: border-box;
|
||||
cursor: default;
|
||||
white-space: pre-line;
|
||||
word-wrap: break-word;
|
||||
}
|
||||
|
||||
.ace_folding-enabled > .ace_gutter-cell {
|
||||
|
|
@ -256,9 +251,9 @@
|
|||
}
|
||||
|
||||
.ace_fold-widget {
|
||||
box-sizing: border-box;
|
||||
-moz-box-sizing: border-box;
|
||||
-webkit-box-sizing: border-box;
|
||||
box-sizing: border-box;
|
||||
|
||||
margin: 0 -12px 0 1px;
|
||||
display: inline-block;
|
||||
|
|
@ -274,11 +269,11 @@
|
|||
border: 1px solid transparent;
|
||||
}
|
||||
|
||||
.ace_fold-widget.end {
|
||||
.ace_fold-widget.ace_end {
|
||||
background-image: url("data:image/png,%89PNG%0D%0A%1A%0A%00%00%00%0DIHDR%00%00%00%05%00%00%00%05%08%06%00%00%00%8Do%26%E5%00%00%004IDATx%DAm%C7%C1%09%000%08C%D1%8C%ECE%C8E(%8E%EC%02)%1EZJ%F1%C1'%04%07I%E1%E5%EE%CAL%F5%A2%99%99%22%E2%D6%1FU%B5%FE0%D9x%A7%26Wz5%0E%D5%00%00%00%00IEND%AEB%60%82");
|
||||
}
|
||||
|
||||
.ace_fold-widget.closed {
|
||||
.ace_fold-widget.ace_closed {
|
||||
background-image: url("data:image/png,%89PNG%0D%0A%1A%0A%00%00%00%0DIHDR%00%00%00%03%00%00%00%06%08%06%00%00%00%06%E5%24%0C%00%00%009IDATx%DA5%CA%C1%09%000%08%03%C0%AC*(%3E%04%C1%0D%BA%B1%23%A4Uh%E0%20%81%C0%CC%F8%82%81%AA%A2%AArGfr%88%08%11%11%1C%DD%7D%E0%EE%5B%F6%F6%CB%B8%05Q%2F%E9tai%D9%00%00%00%00IEND%AEB%60%82");
|
||||
}
|
||||
|
||||
|
|
@ -303,10 +298,10 @@
|
|||
.ace_dark .ace_fold-widget {
|
||||
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHklEQVQIW2P4//8/AzoGEQ7oGCaLLAhWiSwB146BAQCSTPYocqT0AAAAAElFTkSuQmCC");
|
||||
}
|
||||
.ace_dark .ace_fold-widget.end {
|
||||
.ace_dark .ace_fold-widget.ace_end {
|
||||
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAH0lEQVQIW2P4//8/AxQ7wNjIAjDMgC4AxjCVKBirIAAF0kz2rlhxpAAAAABJRU5ErkJggg==");
|
||||
}
|
||||
.ace_dark .ace_fold-widget.closed {
|
||||
.ace_dark .ace_fold-widget.ace_closed {
|
||||
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAMAAAAFCAYAAACAcVaiAAAAHElEQVQIW2P4//+/AxAzgDADlOOAznHAKgPWAwARji8UIDTfQQAAAABJRU5ErkJggg==");
|
||||
}
|
||||
.ace_dark .ace_fold-widget:hover {
|
||||
|
|
@ -321,7 +316,7 @@
|
|||
|
||||
|
||||
|
||||
.ace_fold-widget.invalid {
|
||||
.ace_fold-widget.ace_invalid {
|
||||
background-color: #FFB4B4;
|
||||
border-color: #DE5555;
|
||||
}
|
||||
|
|
@ -343,3 +338,19 @@
|
|||
transition: opacity 0.05s ease 0.05s;
|
||||
opacity:1;
|
||||
}
|
||||
|
||||
.ace_underline {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.ace_bold {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.ace_nobold .ace_bold {
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
.ace_italic {
|
||||
font-style: italic;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -318,7 +318,7 @@ var EditSession = function(text, mode) {
|
|||
};
|
||||
|
||||
/**
|
||||
* EditSession.getSelection() -> String
|
||||
* EditSession.getSelection() -> Selection
|
||||
*
|
||||
* Returns the string of the current selection.
|
||||
**/
|
||||
|
|
@ -349,11 +349,11 @@ var EditSession = function(text, mode) {
|
|||
};
|
||||
|
||||
/**
|
||||
* EditSession.getTokenAt(row, column) -> Array
|
||||
* EditSession.getTokenAt(row, column) -> Object
|
||||
* - row (Number): The row number to retrieve from
|
||||
* - column (Number): The column number to retrieve from
|
||||
*
|
||||
* Returns an array of tokens at the indicated row and column.
|
||||
* Returns an object indicating the token at the current row. The object has two properties: `index` and `start`.
|
||||
**/
|
||||
this.getTokenAt = function(row, column) {
|
||||
var tokens = this.bgTokenizer.getTokens(row);
|
||||
|
|
@ -378,7 +378,7 @@ var EditSession = function(text, mode) {
|
|||
|
||||
this.highlight = function(re) {
|
||||
if (!this.$searchHighlight) {
|
||||
var highlight = new SearchHighlight(null, "ace_selected_word", "text");
|
||||
var highlight = new SearchHighlight(null, "ace_selected-word", "text");
|
||||
this.$searchHighlight = this.addDynamicMarker(highlight);
|
||||
}
|
||||
this.$searchHighlight.setRegexp(re);
|
||||
|
|
@ -752,15 +752,7 @@ var EditSession = function(text, mode) {
|
|||
* Sets annotations for the `EditSession`. This functions emits the `'changeAnnotation'` event.
|
||||
**/
|
||||
this.setAnnotations = function(annotations) {
|
||||
this.$annotations = {};
|
||||
for (var i=0; i<annotations.length; i++) {
|
||||
var annotation = annotations[i];
|
||||
var row = annotation.row;
|
||||
if (this.$annotations[row])
|
||||
this.$annotations[row].push(annotation);
|
||||
else
|
||||
this.$annotations[row] = [annotation];
|
||||
}
|
||||
this.$annotations = annotations;
|
||||
this._emit("changeAnnotation", {});
|
||||
};
|
||||
|
||||
|
|
@ -1212,8 +1204,8 @@ var EditSession = function(text, mode) {
|
|||
};
|
||||
|
||||
/** related to: Document.getTextRange
|
||||
* EditSession.getTextRange(range) -> Array
|
||||
* - range (String): The range to work with
|
||||
* EditSession.getTextRange(range) -> String
|
||||
* - range (Range): The range to work with
|
||||
*
|
||||
* {:Document.getTextRange.desc}
|
||||
**/
|
||||
|
|
|
|||
|
|
@ -683,6 +683,7 @@ function Folding() {
|
|||
};
|
||||
|
||||
this.onFoldWidgetClick = function(row, e) {
|
||||
e = e.domEvent;
|
||||
var type = this.getFoldWidget(row);
|
||||
var line = this.getLine(row);
|
||||
var onlySubfolds = e.shiftKey;
|
||||
|
|
|
|||
|
|
@ -497,7 +497,7 @@ var Editor = function(renderer, session) {
|
|||
} else {
|
||||
range = new Range(cursor.row, 0, cursor.row+1, 0);
|
||||
}
|
||||
session.$highlightLineMarker = session.addMarker(range, "ace_active_line", "background");
|
||||
session.$highlightLineMarker = session.addMarker(range, "ace_active-line", "background");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -1276,6 +1276,31 @@ var Editor = function(renderer, session) {
|
|||
this.session.outdentRows(selection.getRange());
|
||||
};
|
||||
|
||||
// TODO: move out of core when we have good mechanism for managing extensions
|
||||
this.sortLines = function() {
|
||||
var rows = this.$getSelectedRows();
|
||||
var session = this.session;
|
||||
|
||||
var lines = [];
|
||||
for (i = rows.first; i <= rows.last; i++)
|
||||
lines.push(session.getLine(i));
|
||||
|
||||
lines.sort(function(a, b) {
|
||||
if (a.toLowerCase() < b.toLowerCase()) return -1;
|
||||
if (a.toLowerCase() > b.toLowerCase()) return 1;
|
||||
return 0;
|
||||
});
|
||||
|
||||
var deleteRange = new Range(0, 0, 0, 0);
|
||||
for (var i = rows.first; i <= rows.last; i++) {
|
||||
var line = session.getLine(i);
|
||||
deleteRange.start.row = i;
|
||||
deleteRange.end.row = i;
|
||||
deleteRange.end.column = line.length;
|
||||
session.replace(deleteRange, lines[i-rows.first]);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Editor.toggleCommentLines()
|
||||
*
|
||||
|
|
@ -1308,20 +1333,20 @@ var Editor = function(renderer, session) {
|
|||
|
||||
this.duplicateSelection = function() {
|
||||
var sel = this.selection;
|
||||
var doc = this.session;
|
||||
var range = sel.getRange();
|
||||
if (range.isEmpty()) {
|
||||
var row = range.start.row;
|
||||
doc.duplicateLines(row, row);
|
||||
} else {
|
||||
var reverse = sel.isBackwards()
|
||||
var point = sel.isBackwards() ? range.start : range.end;
|
||||
var endPoint = doc.insert(point, doc.getTextRange(range), false);
|
||||
range.start = point;
|
||||
range.end = endPoint;
|
||||
|
||||
sel.setSelectionRange(range, reverse)
|
||||
}
|
||||
var doc = this.session;
|
||||
var range = sel.getRange();
|
||||
if (range.isEmpty()) {
|
||||
var row = range.start.row;
|
||||
doc.duplicateLines(row, row);
|
||||
} else {
|
||||
var reverse = sel.isBackwards()
|
||||
var point = sel.isBackwards() ? range.start : range.end;
|
||||
var endPoint = doc.insert(point, doc.getTextRange(range), false);
|
||||
range.start = point;
|
||||
range.end = endPoint;
|
||||
|
||||
sel.setSelectionRange(range, reverse)
|
||||
}
|
||||
};
|
||||
|
||||
/** related to: EditSession.moveLinesDown
|
||||
|
|
@ -2101,4 +2126,4 @@ var Editor = function(renderer, session) {
|
|||
|
||||
|
||||
exports.Editor = Editor;
|
||||
});
|
||||
});
|
||||
|
|
@ -36,7 +36,7 @@ var UA = require("../lib/useragent");
|
|||
var net = require("../lib/net");
|
||||
var ace = require("../ace");
|
||||
|
||||
require("ace/theme/textmate");
|
||||
require("../theme/textmate");
|
||||
|
||||
module.exports = exports = ace;
|
||||
|
||||
|
|
|
|||
|
|
@ -57,6 +57,7 @@ exports.handler.attach = function(editor) {
|
|||
.emacs-mode .ace_cursor{\
|
||||
border: 2px rgba(50,250,50,0.8) solid!important;\
|
||||
-moz-box-sizing: border-box!important;\
|
||||
-webkit-box-sizing: border-box!important;\
|
||||
box-sizing: border-box!important;\
|
||||
background-color: rgba(0,250,0,0.9);\
|
||||
opacity: 0.5;\
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ var dom = require("../lib/dom");
|
|||
|
||||
var TextInput = function(parentNode, host) {
|
||||
var text = dom.createElement("textarea");
|
||||
text.className = "ace_text-input";
|
||||
/*/ debug
|
||||
text.style.opacity = 1
|
||||
text.style.background = "rgba(0, 250, 0, 0.3)"
|
||||
|
|
@ -46,13 +47,16 @@ var TextInput = function(parentNode, host) {
|
|||
if (useragent.isTouchPad)
|
||||
text.setAttribute("x-palm-disable-auto-cap", true);
|
||||
|
||||
text.setAttribute("wrap", "off");
|
||||
text.wrap = "off";
|
||||
text.spellcheck = false;
|
||||
|
||||
text.style.top = "-2em";
|
||||
parentNode.insertBefore(text, parentNode.firstChild);
|
||||
|
||||
var PLACEHOLDER = useragent.isIE ? "\x01" : "\x01";
|
||||
sendText();
|
||||
var PLACEHOLDER = useragent.isIE ? "\x01" : "\x00";
|
||||
reset(true);
|
||||
if (isFocused())
|
||||
host.onFocus();
|
||||
|
||||
var inCompostion = false;
|
||||
var copied = false;
|
||||
|
|
|
|||
|
|
@ -304,76 +304,76 @@ var inputBuffer = exports.inputBuffer = {
|
|||
|
||||
lastInsertCommands: [],
|
||||
|
||||
push: function(editor, char, keyId) {
|
||||
push: function(editor, ch, keyId) {
|
||||
this.idle = false;
|
||||
var wObj = this.waitingForParam;
|
||||
if (wObj) {
|
||||
this.exec(editor, wObj, char);
|
||||
this.exec(editor, wObj, ch);
|
||||
}
|
||||
// If input is a number (that doesn't start with 0)
|
||||
else if (!(char === "0" && !this.currentCount.length) &&
|
||||
(char.match(/^\d+$/) && this.isAccepting(NUMBER))) {
|
||||
// Assuming that char is always of type String, and not Number
|
||||
this.currentCount += char;
|
||||
else if (!(ch === "0" && !this.currentCount.length) &&
|
||||
(ch.match(/^\d+$/) && this.isAccepting(NUMBER))) {
|
||||
// Assuming that ch is always of type String, and not Number
|
||||
this.currentCount += ch;
|
||||
this.currentCmd = NUMBER;
|
||||
this.accepting = [NUMBER, OPERATOR, MOTION, ACTION];
|
||||
}
|
||||
else if (!this.operator && this.isAccepting(OPERATOR) && operators[char]) {
|
||||
else if (!this.operator && this.isAccepting(OPERATOR) && operators[ch]) {
|
||||
this.operator = {
|
||||
char: char,
|
||||
ch: ch,
|
||||
count: this.getCount()
|
||||
};
|
||||
this.currentCmd = OPERATOR;
|
||||
this.accepting = [NUMBER, MOTION, ACTION];
|
||||
this.exec(editor, { operator: this.operator });
|
||||
}
|
||||
else if (motions[char] && this.isAccepting(MOTION)) {
|
||||
else if (motions[ch] && this.isAccepting(MOTION)) {
|
||||
this.currentCmd = MOTION;
|
||||
|
||||
var ctx = {
|
||||
operator: this.operator,
|
||||
motion: {
|
||||
char: char,
|
||||
ch: ch,
|
||||
count: this.getCount()
|
||||
}
|
||||
};
|
||||
|
||||
if (motions[char].param)
|
||||
if (motions[ch].param)
|
||||
this.waitForParam(ctx);
|
||||
else
|
||||
this.exec(editor, ctx);
|
||||
}
|
||||
else if (alias[char] && this.isAccepting(MOTION)) {
|
||||
alias[char].operator.count = this.getCount();
|
||||
this.exec(editor, alias[char]);
|
||||
else if (alias[ch] && this.isAccepting(MOTION)) {
|
||||
alias[ch].operator.count = this.getCount();
|
||||
this.exec(editor, alias[ch]);
|
||||
}
|
||||
else if (actions[char] && this.isAccepting(ACTION)) {
|
||||
else if (actions[ch] && this.isAccepting(ACTION)) {
|
||||
var actionObj = {
|
||||
action: {
|
||||
fn: actions[char].fn,
|
||||
fn: actions[ch].fn,
|
||||
count: this.getCount()
|
||||
}
|
||||
};
|
||||
|
||||
if (actions[char].param) {
|
||||
if (actions[ch].param) {
|
||||
this.waitForParam(actionObj);
|
||||
}
|
||||
else {
|
||||
this.exec(editor, actionObj);
|
||||
}
|
||||
|
||||
if (actions[char].acceptsMotion)
|
||||
if (actions[ch].acceptsMotion)
|
||||
this.idle = false;
|
||||
}
|
||||
else if (this.operator) {
|
||||
this.exec(editor, { operator: this.operator }, char);
|
||||
this.exec(editor, { operator: this.operator }, ch);
|
||||
}
|
||||
else {
|
||||
this.reset();
|
||||
}
|
||||
|
||||
if (this.waitingForParam || this.motion || this.operator) {
|
||||
this.status += char;
|
||||
this.status += ch;
|
||||
} else if (this.currentCount) {
|
||||
this.status = this.currentCount;
|
||||
} else if (this.status) {
|
||||
|
|
@ -410,18 +410,18 @@ var inputBuffer = exports.inputBuffer = {
|
|||
}
|
||||
|
||||
if (o && !editor.selection.isEmpty()) {
|
||||
if (operators[o.char].selFn) {
|
||||
operators[o.char].selFn(editor, editor.getSelectionRange(), o.count, param);
|
||||
if (operators[o.ch].selFn) {
|
||||
operators[o.ch].selFn(editor, editor.getSelectionRange(), o.count, param);
|
||||
this.reset();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// There is an operator, but no motion or action. We try to pass the
|
||||
// current char to the operator to see if it responds to it (an example
|
||||
// current ch to the operator to see if it responds to it (an example
|
||||
// of this is the 'dd' operator).
|
||||
else if (!m && !a && o && param) {
|
||||
operators[o.char].fn(editor, null, o.count, param);
|
||||
operators[o.ch].fn(editor, null, o.count, param);
|
||||
this.reset();
|
||||
}
|
||||
else if (m) {
|
||||
|
|
@ -434,7 +434,7 @@ var inputBuffer = exports.inputBuffer = {
|
|||
}
|
||||
};
|
||||
|
||||
var motionObj = motions[m.char];
|
||||
var motionObj = motions[m.ch];
|
||||
var selectable = motionObj.sel;
|
||||
|
||||
if (!o) {
|
||||
|
|
@ -446,7 +446,7 @@ var inputBuffer = exports.inputBuffer = {
|
|||
else if (selectable) {
|
||||
repeat(function() {
|
||||
run(motionObj.sel);
|
||||
operators[o.char].fn(editor, editor.getSelectionRange(), o.count, param);
|
||||
operators[o.ch].fn(editor, editor.getSelectionRange(), o.count, param);
|
||||
}, o.count || 1);
|
||||
}
|
||||
this.reset();
|
||||
|
|
|
|||
|
|
@ -34,57 +34,57 @@ define(function(require, exports, module) {
|
|||
module.exports = {
|
||||
"x": {
|
||||
operator: {
|
||||
char: "d",
|
||||
ch: "d",
|
||||
count: 1
|
||||
},
|
||||
motion: {
|
||||
char: "l",
|
||||
ch: "l",
|
||||
count: 1
|
||||
}
|
||||
},
|
||||
"X": {
|
||||
operator: {
|
||||
char: "d",
|
||||
ch: "d",
|
||||
count: 1
|
||||
},
|
||||
motion: {
|
||||
char: "h",
|
||||
ch: "h",
|
||||
count: 1
|
||||
}
|
||||
},
|
||||
"D": {
|
||||
operator: {
|
||||
char: "d",
|
||||
ch: "d",
|
||||
count: 1
|
||||
},
|
||||
motion: {
|
||||
char: "$",
|
||||
ch: "$",
|
||||
count: 1
|
||||
}
|
||||
},
|
||||
"C": {
|
||||
operator: {
|
||||
char: "c",
|
||||
ch: "c",
|
||||
count: 1
|
||||
},
|
||||
motion: {
|
||||
char: "$",
|
||||
ch: "$",
|
||||
count: 1
|
||||
}
|
||||
},
|
||||
"s": {
|
||||
operator: {
|
||||
char: "c",
|
||||
ch: "c",
|
||||
count: 1
|
||||
},
|
||||
motion: {
|
||||
char: "l",
|
||||
ch: "l",
|
||||
count: 1
|
||||
}
|
||||
},
|
||||
"S": {
|
||||
operator: {
|
||||
char: "c",
|
||||
ch: "c",
|
||||
count: 1
|
||||
},
|
||||
param: "c"
|
||||
|
|
|
|||
|
|
@ -28,9 +28,9 @@
|
|||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
"use strict"
|
||||
|
||||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var util = require("./util");
|
||||
|
||||
|
|
@ -42,42 +42,27 @@ var keepScrollPosition = function(editor, fn) {
|
|||
editor.renderer.scrollToRow(editor.getCursorPosition().row - diff);
|
||||
};
|
||||
|
||||
function Motion(getRange, type){
|
||||
if (type == 'extend')
|
||||
var extend = true;
|
||||
else
|
||||
var reverse = type;
|
||||
|
||||
this.nav = function(editor) {
|
||||
var r = getRange(editor);
|
||||
if (!r)
|
||||
function Motion(m) {
|
||||
if (typeof m == "function") {
|
||||
var getPos = m;
|
||||
m = this;
|
||||
} else {
|
||||
var getPos = m.getPos;
|
||||
}
|
||||
m.nav = function(editor, range, count, param) {
|
||||
var a = getPos(editor, range, count, param, false);
|
||||
if (!a)
|
||||
return;
|
||||
if (!r.end)
|
||||
var a = r;
|
||||
else if (reverse)
|
||||
var a = r.start;
|
||||
else
|
||||
var a = r.end;
|
||||
|
||||
editor.clearSelection();
|
||||
editor.moveCursorTo(a.row, a.column);
|
||||
}
|
||||
this.sel = function(editor){
|
||||
var r = getRange(editor);
|
||||
if (!r)
|
||||
};
|
||||
m.sel = function(editor, range, count, param) {
|
||||
var a = getPos(editor, range, count, param, true);
|
||||
if (!a)
|
||||
return;
|
||||
if (extend)
|
||||
return editor.selection.setSelectionRange(r);
|
||||
|
||||
if (!r.end)
|
||||
var a = r;
|
||||
else if (reverse)
|
||||
var a = r.start;
|
||||
else
|
||||
var a = r.end;
|
||||
|
||||
editor.selection.selectTo(a.row, a.column);
|
||||
}
|
||||
};
|
||||
return m;
|
||||
}
|
||||
|
||||
var nonWordRe = /[\s.\/\\()\"'-:,.;<>~!@#$%^&*|+=\[\]{}`~?]/;
|
||||
|
|
@ -90,20 +75,20 @@ var StringStream = function(editor, cursor) {
|
|||
this.row = cursor.row;
|
||||
this.col = cursor.column;
|
||||
var line = editor.session.getLine(this.row);
|
||||
var maxRow = editor.session.getLength()
|
||||
this.ch = line[this.col] || '\n'
|
||||
var maxRow = editor.session.getLength();
|
||||
this.ch = line[this.col] || '\n';
|
||||
this.skippedLines = 0;
|
||||
|
||||
this.next = function() {
|
||||
this.ch = line[++this.col] || this.handleNewLine(1);
|
||||
//this.debug()
|
||||
return this.ch;
|
||||
}
|
||||
};
|
||||
this.prev = function() {
|
||||
this.ch = line[--this.col] || this.handleNewLine(-1);
|
||||
//this.debug()
|
||||
return this.ch;
|
||||
}
|
||||
};
|
||||
this.peek = function(dir) {
|
||||
var ch = line[this.col + dir];
|
||||
if (ch)
|
||||
|
|
@ -113,7 +98,7 @@ var StringStream = function(editor, cursor) {
|
|||
if (this.col == line.length - 1)
|
||||
return '\n';
|
||||
return editor.session.getLine(this.row + 1)[0] || '\n';
|
||||
}
|
||||
};
|
||||
|
||||
this.handleNewLine = function(dir) {
|
||||
if (dir == 1){
|
||||
|
|
@ -128,7 +113,7 @@ var StringStream = function(editor, cursor) {
|
|||
return line[0] || '\n';
|
||||
}
|
||||
if (dir == -1) {
|
||||
if (this.row == 0)
|
||||
if (this.row === 0)
|
||||
return '';
|
||||
this.row --;
|
||||
line = editor.session.getLine(this.row);
|
||||
|
|
@ -136,13 +121,13 @@ var StringStream = function(editor, cursor) {
|
|||
this.skippedLines--;
|
||||
return '\n';
|
||||
}
|
||||
}
|
||||
};
|
||||
this.debug = function() {
|
||||
console.log(line.substring(0, this.col)+'|'+this.ch+'\''+this.col+'\''+line.substr(this.col+1));
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
var Search = require("ace/search").Search;
|
||||
var Search = require("../../../search").Search;
|
||||
var search = new Search();
|
||||
|
||||
function find(editor, needle, dir) {
|
||||
|
|
@ -151,7 +136,7 @@ function find(editor, needle, dir) {
|
|||
return search.find(editor.session);
|
||||
}
|
||||
|
||||
var Range = require("ace/range").Range;
|
||||
var Range = require("../../../range").Range;
|
||||
|
||||
module.exports = {
|
||||
"w": new Motion(function(editor) {
|
||||
|
|
@ -179,7 +164,7 @@ module.exports = {
|
|||
else
|
||||
str.next();
|
||||
|
||||
return {column: str.col, row: str.row}
|
||||
return {column: str.col, row: str.row};
|
||||
}),
|
||||
"b": new Motion(function(editor) {
|
||||
var str = new StringStream(editor);
|
||||
|
|
@ -199,7 +184,7 @@ module.exports = {
|
|||
return {column: str.col, row: str.row};
|
||||
}),
|
||||
"B": new Motion(function(editor) {
|
||||
var str = new StringStream(editor)
|
||||
var str = new StringStream(editor);
|
||||
str.prev();
|
||||
while(str.ch && !(!whiteRe.test(str.ch) && whiteRe.test(str.peek(-1))) && str.skippedLines > -2)
|
||||
str.prev();
|
||||
|
|
@ -208,7 +193,7 @@ module.exports = {
|
|||
str.next();
|
||||
|
||||
return {column: str.col, row: str.row};
|
||||
}, true),
|
||||
}),
|
||||
"e": new Motion(function(editor) {
|
||||
var str = new StringStream(editor);
|
||||
|
||||
|
|
@ -389,98 +374,58 @@ module.exports = {
|
|||
}
|
||||
},
|
||||
|
||||
"f": {
|
||||
"f": new Motion({
|
||||
param: true,
|
||||
handlesCount: true,
|
||||
nav: function(editor, range, count, param) {
|
||||
var ed = editor;
|
||||
var cursor = ed.getCursorPosition();
|
||||
getPos: function(editor, range, count, param, isSel) {
|
||||
var cursor = editor.getCursorPosition();
|
||||
var column = util.getRightNthChar(editor, cursor, param, count || 1);
|
||||
|
||||
if (typeof column === "number") {
|
||||
ed.selection.clearSelection(); // Why does it select in the first place?
|
||||
ed.moveCursorTo(cursor.row, column + cursor.column + 1);
|
||||
cursor.column += column + (isSel ? 2 : 1);
|
||||
return cursor;
|
||||
}
|
||||
},
|
||||
sel: function(editor, range, count, param) {
|
||||
var ed = editor;
|
||||
var cursor = ed.getCursorPosition();
|
||||
}
|
||||
}),
|
||||
"F": new Motion({
|
||||
param: true,
|
||||
handlesCount: true,
|
||||
getPos: function(editor, range, count, param, isSel) {
|
||||
var cursor = editor.getCursorPosition();
|
||||
var column = util.getLeftNthChar(editor, cursor, param, count || 1);
|
||||
|
||||
if (typeof column === "number") {
|
||||
cursor.column -= column + 1;
|
||||
return cursor;
|
||||
}
|
||||
}
|
||||
}),
|
||||
"t": new Motion({
|
||||
param: true,
|
||||
handlesCount: true,
|
||||
getPos: function(editor, range, count, param, isSel) {
|
||||
var cursor = editor.getCursorPosition();
|
||||
var column = util.getRightNthChar(editor, cursor, param, count || 1);
|
||||
|
||||
if (typeof column === "number") {
|
||||
ed.moveCursorTo(cursor.row, column + cursor.column + 1);
|
||||
cursor.column += column + (isSel ? 1 : 0);
|
||||
return cursor;
|
||||
}
|
||||
}
|
||||
},
|
||||
"F": {
|
||||
}),
|
||||
"T": new Motion({
|
||||
param: true,
|
||||
handlesCount: true,
|
||||
nav: function(editor, range, count, param) {
|
||||
var ed = editor;
|
||||
var cursor = ed.getCursorPosition();
|
||||
getPos: function(editor, range, count, param, isSel) {
|
||||
var cursor = editor.getCursorPosition();
|
||||
var column = util.getLeftNthChar(editor, cursor, param, count || 1);
|
||||
|
||||
if (typeof column === "number") {
|
||||
ed.selection.clearSelection(); // Why does it select in the first place?
|
||||
ed.moveCursorTo(cursor.row, cursor.column - column - 1);
|
||||
}
|
||||
},
|
||||
sel: function(editor, range, count, param) {
|
||||
var ed = editor;
|
||||
var cursor = ed.getCursorPosition();
|
||||
var column = util.getLeftNthChar(editor, cursor, param, count || 1);
|
||||
|
||||
if (typeof column === "number") {
|
||||
ed.moveCursorTo(cursor.row, cursor.column - column - 1);
|
||||
cursor.column -= column;
|
||||
return cursor;
|
||||
}
|
||||
}
|
||||
},
|
||||
"t": {
|
||||
param: true,
|
||||
handlesCount: true,
|
||||
nav: function(editor, range, count, param) {
|
||||
var ed = editor;
|
||||
var cursor = ed.getCursorPosition();
|
||||
var column = util.getRightNthChar(editor, cursor, param, count || 1);
|
||||
|
||||
if (typeof column === "number") {
|
||||
ed.selection.clearSelection(); // Why does it select in the first place?
|
||||
ed.moveCursorTo(cursor.row, column + cursor.column);
|
||||
}
|
||||
},
|
||||
sel: function(editor, range, count, param) {
|
||||
var ed = editor;
|
||||
var cursor = ed.getCursorPosition();
|
||||
var column = util.getRightNthChar(editor, cursor, param, count || 1);
|
||||
|
||||
if (typeof column === "number") {
|
||||
ed.moveCursorTo(cursor.row, column + cursor.column);
|
||||
}
|
||||
}
|
||||
},
|
||||
"T": {
|
||||
param: true,
|
||||
handlesCount: true,
|
||||
nav: function(editor, range, count, param) {
|
||||
var ed = editor;
|
||||
var cursor = ed.getCursorPosition();
|
||||
var column = util.getLeftNthChar(editor, cursor, param, count || 1);
|
||||
|
||||
if (typeof column === "number") {
|
||||
ed.selection.clearSelection(); // Why does it select in the first place?
|
||||
ed.moveCursorTo(cursor.row, -column + cursor.column);
|
||||
}
|
||||
},
|
||||
sel: function(editor, range, count, param) {
|
||||
var ed = editor;
|
||||
var cursor = ed.getCursorPosition();
|
||||
var column = util.getLeftNthChar(editor, cursor, param, count || 1);
|
||||
|
||||
if (typeof column === "number") {
|
||||
ed.moveCursorTo(cursor.row, -column + cursor.column);
|
||||
}
|
||||
}
|
||||
},
|
||||
}),
|
||||
|
||||
"^": {
|
||||
nav: function(editor) {
|
||||
|
|
@ -635,7 +580,7 @@ module.exports = {
|
|||
sel: function(editor, range, count, param) {
|
||||
keepScrollPosition(editor, editor.selectPageUp);
|
||||
}
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
module.exports.backspace = module.exports.left = module.exports.h;
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ define(function(require, exports, module) {
|
|||
var registers = require("../registers");
|
||||
|
||||
var dom = require("../../../lib/dom");
|
||||
dom.importCssString('.insert-mode. ace_cursor{\
|
||||
dom.importCssString('.insert-mode .ace_cursor{\
|
||||
border-left: 2px solid #333333;\
|
||||
}\
|
||||
.ace_dark.insert-mode .ace_cursor{\
|
||||
|
|
@ -99,24 +99,24 @@ module.exports = {
|
|||
this.onVisualLineMode = false;
|
||||
}
|
||||
},
|
||||
getRightNthChar: function(editor, cursor, char, n) {
|
||||
getRightNthChar: function(editor, cursor, ch, n) {
|
||||
var line = editor.getSession().getLine(cursor.row);
|
||||
var matches = line.substr(cursor.column + 1).split(char);
|
||||
var matches = line.substr(cursor.column + 1).split(ch);
|
||||
|
||||
return n < matches.length ? matches.slice(0, n).join(char).length : null;
|
||||
return n < matches.length ? matches.slice(0, n).join(ch).length : null;
|
||||
},
|
||||
getLeftNthChar: function(editor, cursor, char, n) {
|
||||
getLeftNthChar: function(editor, cursor, ch, n) {
|
||||
var line = editor.getSession().getLine(cursor.row);
|
||||
var matches = line.substr(0, cursor.column).split(char);
|
||||
var matches = line.substr(0, cursor.column).split(ch);
|
||||
|
||||
return n < matches.length ? matches.slice(-1 * n).join(char).length : null;
|
||||
return n < matches.length ? matches.slice(-1 * n).join(ch).length : null;
|
||||
},
|
||||
toRealChar: function(char) {
|
||||
if (char.length === 1)
|
||||
return char;
|
||||
toRealChar: function(ch) {
|
||||
if (ch.length === 1)
|
||||
return ch;
|
||||
|
||||
if (/^shift-./.test(char))
|
||||
return char[char.length - 1].toUpperCase();
|
||||
if (/^shift-./.test(ch))
|
||||
return ch[ch.length - 1].toUpperCase();
|
||||
else
|
||||
return "";
|
||||
},
|
||||
|
|
|
|||
|
|
@ -177,7 +177,7 @@ var Cursor = function(parentEl) {
|
|||
|
||||
var overwrite = this.session.getOverwrite();
|
||||
if (overwrite != this.overwrite)
|
||||
this.$setOverite(overwrite);
|
||||
this.$setOverwrite(overwrite);
|
||||
|
||||
// cache for textarea and gutter highlight
|
||||
this.$pixelPos = pixelPos;
|
||||
|
|
@ -185,7 +185,7 @@ var Cursor = function(parentEl) {
|
|||
this.restartTimer();
|
||||
};
|
||||
|
||||
this.$setOverite = function(overwrite) {
|
||||
this.$setOverwrite = function(overwrite) {
|
||||
this.overwrite = overwrite;
|
||||
for (var i = this.cursors.length; i--; ) {
|
||||
if (overwrite)
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ define(function(require, exports, module) {
|
|||
|
||||
var dom = require("../lib/dom");
|
||||
var oop = require("../lib/oop");
|
||||
var lang = require("../lib/lang");
|
||||
var EventEmitter = require("../lib/event_emitter").EventEmitter;
|
||||
|
||||
var Gutter = function(parentEl) {
|
||||
|
|
@ -44,14 +45,18 @@ var Gutter = function(parentEl) {
|
|||
this.gutterWidth = 0;
|
||||
|
||||
this.$annotations = [];
|
||||
this.$updateAnnotations = this.$updateAnnotations.bind(this);
|
||||
};
|
||||
|
||||
(function() {
|
||||
|
||||
oop.implement(this, EventEmitter);
|
||||
|
||||
|
||||
this.setSession = function(session) {
|
||||
if (this.session)
|
||||
this.session.removeEventListener("change", this.$updateAnnotations);
|
||||
this.session = session;
|
||||
session.on("change", this.$updateAnnotations);
|
||||
};
|
||||
|
||||
this.addGutterDecoration = function(row, className){
|
||||
|
|
@ -68,28 +73,46 @@ var Gutter = function(parentEl) {
|
|||
|
||||
this.setAnnotations = function(annotations) {
|
||||
// iterate over sparse array
|
||||
this.$annotations = [];
|
||||
for (var row in annotations) if (annotations.hasOwnProperty(row)) {
|
||||
var rowAnnotations = annotations[row];
|
||||
if (!rowAnnotations)
|
||||
continue;
|
||||
this.$annotations = []
|
||||
var rowInfo, row;
|
||||
for (var i = 0; i < annotations.length; i++) {
|
||||
var annotation = annotations[i];
|
||||
var row = annotation.row;
|
||||
var rowInfo = this.$annotations[row];
|
||||
if (!rowInfo)
|
||||
rowInfo = this.$annotations[row] = {text: []};
|
||||
|
||||
var annoText = annotation.text;
|
||||
annoText = annoText ? lang.escapeHTML(annoText) : annotation.html || "";
|
||||
|
||||
var rowInfo = this.$annotations[row] = {
|
||||
text: []
|
||||
};
|
||||
for (var i=0; i<rowAnnotations.length; i++) {
|
||||
var annotation = rowAnnotations[i];
|
||||
var annoText = annotation.text.replace(/"/g, """).replace(/'/g, "’").replace(/</, "<");
|
||||
if (rowInfo.text.indexOf(annoText) === -1)
|
||||
rowInfo.text.push(annoText);
|
||||
var type = annotation.type;
|
||||
if (type == "error")
|
||||
rowInfo.className = " ace_error";
|
||||
else if (type == "warning" && rowInfo.className != " ace_error")
|
||||
rowInfo.className = " ace_warning";
|
||||
else if (type == "info" && (!rowInfo.className))
|
||||
rowInfo.className = " ace_info";
|
||||
}
|
||||
if (rowInfo.text.indexOf(annoText) === -1)
|
||||
rowInfo.text.push(annoText);
|
||||
|
||||
var type = annotation.type;
|
||||
if (type == "error")
|
||||
rowInfo.className = " ace_error";
|
||||
else if (type == "warning" && rowInfo.className != " ace_error")
|
||||
rowInfo.className = " ace_warning";
|
||||
else if (type == "info" && (!rowInfo.className))
|
||||
rowInfo.className = " ace_info";
|
||||
}
|
||||
};
|
||||
|
||||
this.$updateAnnotations = function (e) {
|
||||
if (!this.$annotations.length)
|
||||
return;
|
||||
var delta = e.data;
|
||||
var range = delta.range;
|
||||
var firstRow = range.start.row;
|
||||
var len = range.end.row - firstRow;
|
||||
if (len === 0) {
|
||||
// do nothing
|
||||
} else if (delta.action == "removeText" || delta.action == "removeLines") {
|
||||
this.$annotations.splice(firstRow, len + 1, null);
|
||||
} else {
|
||||
var args = Array(len + 1);
|
||||
args.unshift(firstRow, 1);
|
||||
this.$annotations.splice.apply(this.$annotations, args);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -129,8 +152,8 @@ var Gutter = function(parentEl) {
|
|||
c = foldWidgets[i] = this.session.getFoldWidget(i);
|
||||
if (c)
|
||||
html.push(
|
||||
"<span class='ace_fold-widget ", c,
|
||||
c == "start" && i == foldStart && i < fold.end.row ? " closed" : " open",
|
||||
"<span class='ace_fold-widget ace_", c,
|
||||
c == "start" && i == foldStart && i < fold.end.row ? " ace_closed" : " ace_open",
|
||||
"' style='height:", config.lineHeight, "px",
|
||||
"'></span>"
|
||||
);
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ var Marker = function(parentEl) {
|
|||
}
|
||||
else {
|
||||
this.drawSingleLineMarker(
|
||||
html, range, marker.clazz + " start", config,
|
||||
html, range, marker.clazz + " ace_start", config,
|
||||
null, marker.type
|
||||
);
|
||||
}
|
||||
|
|
@ -116,7 +116,7 @@ var Marker = function(parentEl) {
|
|||
row, range.start.column,
|
||||
row, this.session.getScreenLastRowColumn(row)
|
||||
);
|
||||
this.drawSingleLineMarker(stringBuilder, lineRange, clazz + " start", layerConfig, 1, "text");
|
||||
this.drawSingleLineMarker(stringBuilder, lineRange, clazz + " ace_start", layerConfig, 1, "text");
|
||||
|
||||
// selection end
|
||||
row = range.end.row;
|
||||
|
|
@ -140,7 +140,7 @@ var Marker = function(parentEl) {
|
|||
var left = Math.round(padding + range.start.column * config.characterWidth);
|
||||
|
||||
stringBuilder.push(
|
||||
"<div class='", clazz, " start' style='",
|
||||
"<div class='", clazz, " ace_start' style='",
|
||||
"height:", height, "px;",
|
||||
"right:0;",
|
||||
"top:", top, "px;",
|
||||
|
|
|
|||
|
|
@ -42,7 +42,8 @@ var Text = function(parentEl) {
|
|||
this.element.className = "ace_layer ace_text-layer";
|
||||
parentEl.appendChild(this.element);
|
||||
|
||||
this.$characterSize = this.$measureSizes() || {width: 0, height: 0};
|
||||
this.$characterSize = {width: 0, height: 0};
|
||||
this.checkForSizeChanges();
|
||||
this.$pollSizeChanges();
|
||||
};
|
||||
|
||||
|
|
@ -72,7 +73,11 @@ var Text = function(parentEl) {
|
|||
this.checkForSizeChanges = function() {
|
||||
var size = this.$measureSizes();
|
||||
if (size && (this.$characterSize.width !== size.width || this.$characterSize.height !== size.height)) {
|
||||
this.$measureNode.style.fontWeight = "bold";
|
||||
var boldSize = this.$measureSizes();
|
||||
this.$measureNode.style.fontWeight = "";
|
||||
this.$characterSize = size;
|
||||
this.allowBoldFonts = boldSize && boldSize.width === size.width && boldSize.height === size.height;
|
||||
this._emit("changeCharacterSize", {data: size});
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -117,6 +117,10 @@ exports.escapeRegExp = function(str) {
|
|||
return str.replace(/([.*+?^${}()|[\]\/\\])/g, '\\$1');
|
||||
};
|
||||
|
||||
exports.escapeHTML = function(str) {
|
||||
return str.replace(/&/g, "&").replace(/"/g, """).replace(/'/g, "'").replace(/</g, "<");
|
||||
};
|
||||
|
||||
exports.getMatchOffsets = function(string, regExp) {
|
||||
var matches = [];
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@ function foo(items, nada) {
|
|||
} // Real Tab.
|
||||
}
|
||||
|
||||
regexp = /p|p/ // ends here
|
||||
|
||||
r = /d{1,2}?f{e}++r*?\d+?[]r[^r-o\f\f[\f]?r{7}+r\{7}+rr--rr$^(?:d|s)(?=a|)(?!y)[]|$?|^*/ o
|
||||
a=/a/ jk = / / / / /
|
||||
/************************************/
|
||||
|
|
|
|||
|
|
@ -20,9 +20,9 @@
|
|||
{
|
||||
"state": "start",
|
||||
"data": [
|
||||
[ "keyword", "using" ],
|
||||
[ "keyword.control", "using" ],
|
||||
[ "text", " " ],
|
||||
[ "keyword", "namespace" ],
|
||||
[ "keyword.operator", "namespace" ],
|
||||
[ "text", " " ],
|
||||
[ "identifier", "std" ],
|
||||
[ "punctuation.operator", ";" ]
|
||||
|
|
@ -35,9 +35,9 @@
|
|||
{
|
||||
"state": "start",
|
||||
"data": [
|
||||
[ "keyword", "int" ],
|
||||
[ "storage.type", "int" ],
|
||||
[ "text", " " ],
|
||||
[ "identifier", "main" ],
|
||||
[ "entity.name.function", "main" ],
|
||||
[ "text", " " ],
|
||||
[ "paren.lparen", "(" ],
|
||||
[ "paren.rparen", ")" ]
|
||||
|
|
@ -53,7 +53,7 @@
|
|||
"state": "start",
|
||||
"data": [
|
||||
[ "text", " " ],
|
||||
[ "keyword", "int" ],
|
||||
[ "storage.type", "int" ],
|
||||
[ "text", " " ],
|
||||
[ "identifier", "a" ],
|
||||
[ "punctuation.operator", "," ],
|
||||
|
|
@ -109,7 +109,7 @@
|
|||
"state": "start",
|
||||
"data": [
|
||||
[ "text", " " ],
|
||||
[ "keyword", "return" ],
|
||||
[ "keyword.control", "return" ],
|
||||
[ "text", " " ],
|
||||
[ "constant.numeric", "0" ],
|
||||
[ "punctuation.operator", ";" ]
|
||||
|
|
|
|||
|
|
@ -193,7 +193,7 @@
|
|||
"state": "start",
|
||||
"data": [
|
||||
[ "support.constant", "+" ],
|
||||
[ "text", " var highlight = new SearchHighlight(null, \"ace_selected_word\", \"text\");" ]
|
||||
[ "text", " var highlight = new SearchHighlight(null, \"ace_selected-word\", \"text\");" ]
|
||||
]
|
||||
},
|
||||
{
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@
|
|||
"data": [
|
||||
[ "keyword", "void" ],
|
||||
[ "text", " " ],
|
||||
[ "identifier", "main" ],
|
||||
[ "entity.name.function", "main" ],
|
||||
[ "paren.lparen", "(" ],
|
||||
[ "paren.rparen", ")" ],
|
||||
[ "text", " " ],
|
||||
|
|
|
|||
|
|
@ -81,6 +81,24 @@
|
|||
"state": "start",
|
||||
"data": []
|
||||
},
|
||||
{
|
||||
"state": "start",
|
||||
"data": [
|
||||
[ "identifier", "regexp" ],
|
||||
[ "text", " " ],
|
||||
[ "keyword.operator", "=" ],
|
||||
[ "text", " " ],
|
||||
[ "string.regexp", "/p" ],
|
||||
[ "constant.language.escape", "|" ],
|
||||
[ "string.regexp", "p/" ],
|
||||
[ "text", " " ],
|
||||
[ "comment", "// ends here" ]
|
||||
]
|
||||
},
|
||||
{
|
||||
"state": "start",
|
||||
"data": []
|
||||
},
|
||||
{
|
||||
"state": "start",
|
||||
"data": [
|
||||
|
|
@ -118,10 +136,13 @@
|
|||
[ "constant.language.escape", "$" ],
|
||||
[ "constant.language.escape", "^" ],
|
||||
[ "constant.language.escape", "(?:" ],
|
||||
[ "string.regexp", "d|s" ],
|
||||
[ "string.regexp", "d" ],
|
||||
[ "constant.language.escape", "|" ],
|
||||
[ "string.regexp", "s" ],
|
||||
[ "constant.language.escape", ")" ],
|
||||
[ "constant.language.escape", "(?=" ],
|
||||
[ "string.regexp", "a|" ],
|
||||
[ "string.regexp", "a" ],
|
||||
[ "constant.language.escape", "|" ],
|
||||
[ "constant.language.escape", ")" ],
|
||||
[ "constant.language.escape", "(?!" ],
|
||||
[ "string.regexp", "y" ],
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
{
|
||||
"state": "start",
|
||||
"data": [
|
||||
[ "xml_pe", "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" ]
|
||||
[ "xml-pe", "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" ]
|
||||
]
|
||||
},
|
||||
{
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
*
|
||||
* 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
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
* * 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
|
||||
|
|
@ -27,27 +27,38 @@
|
|||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
define(function(require, exports, module){
|
||||
var Position = exports.Position = function(line, offset, length)
|
||||
{
|
||||
this.line = line;
|
||||
this.offset = offset;
|
||||
this.length = length;
|
||||
|
||||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var oop = require("../lib/oop");
|
||||
var TextMode = require("./text").Mode;
|
||||
var Tokenizer = require("../tokenizer").Tokenizer;
|
||||
var AsciidocHighlightRules = require("./asciidoc_highlight_rules").AsciidocHighlightRules;
|
||||
var AsciidocFoldMode = require("./folding/asciidoc").FoldMode;
|
||||
|
||||
var Mode = function() {
|
||||
var highlighter = new AsciidocHighlightRules();
|
||||
|
||||
this.getLine = function()
|
||||
{
|
||||
return this.line;
|
||||
};
|
||||
this.$tokenizer = new Tokenizer(highlighter.getRules());
|
||||
this.foldingRules = new AsciidocFoldMode();
|
||||
};
|
||||
oop.inherits(Mode, TextMode);
|
||||
|
||||
this.getOffset = function()
|
||||
{
|
||||
return this.offset;
|
||||
(function() {
|
||||
this.getNextLineIndent = function(state, line, tab) {
|
||||
if (state == "listblock") {
|
||||
var match = /^((?:.+)?)([-+*][ ]+)/.exec(line);
|
||||
if (match) {
|
||||
return new Array(match[1].length + 1).join(" ") + match[2];
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
} else {
|
||||
return this.$getIndent(line);
|
||||
}
|
||||
};
|
||||
}).call(Mode.prototype);
|
||||
|
||||
this.getLength = function()
|
||||
{
|
||||
return this.length;
|
||||
};
|
||||
};
|
||||
|
||||
});
|
||||
exports.Mode = Mode;
|
||||
});
|
||||
233
lib/ace/mode/asciidoc_highlight_rules.js
Normal file
|
|
@ -0,0 +1,233 @@
|
|||
/* ***** 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 oop = require("../lib/oop");
|
||||
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
|
||||
|
||||
var AsciidocHighlightRules = function() {
|
||||
var identifierRe = "[a-zA-Z\u00a1-\uffff]+\\b";
|
||||
|
||||
this.$rules = {
|
||||
"start": [
|
||||
{token: "empty", regex: /$/},
|
||||
{token: "literal", regex: /^\.{4,}\s*$/, next: "listingBlock"},
|
||||
{token: "literal", regex: /^-{4,}\s*$/, next: "literalBlock"},
|
||||
{token: "string", regex: /^\+{4,}\s*$/, next: "passthroughBlock"},
|
||||
{token: "keyword", regex: /^={4,}\s*$/},
|
||||
{token: "text", regex: /^\s*$/},
|
||||
// immediately return to the start mode without matching anything
|
||||
{token: "empty", regex: "", next: "dissallowDelimitedBlock"}
|
||||
],
|
||||
|
||||
"dissallowDelimitedBlock": [
|
||||
{include: "paragraphEnd"},
|
||||
{token: "comment", regex: '^//.+$'},
|
||||
{token: "keyword", regex: "^(?:NOTE|TIP|IMPORTANT|WARNING|CAUTION):"},
|
||||
|
||||
{include: "listStart"},
|
||||
{token: "literal", regex: /^\s+.+$/, next: "indentedBlock"},
|
||||
{token: "empty", regex: "", next: "text"}
|
||||
],
|
||||
|
||||
"paragraphEnd": [
|
||||
{token: "doc.comment", regex: /^\/{4,}\s*$/, next: "commentBlock"},
|
||||
{token: "tableBlock", regex: /^\s*[|!]=+\s*$/, next: "tableBlock"},
|
||||
// open block, ruller
|
||||
{token: "keyword", regex: /^(?:--|''')\s*$/, next: "start"},
|
||||
{token: "option", regex: /^\[.*\]\s*$/, next: "start"},
|
||||
{token: "pageBreak", regex: /^>{3,}$/, next: "start"},
|
||||
{token: "literal", regex: /^\.{4,}\s*$/, next: "listingBlock"},
|
||||
{token: "titleUnderline", regex: /^(?:={2,}|-{2,}|~{2,}|\^{2,}|\+{2,})\s*$/, next: "start"},
|
||||
{token: "singleLineTitle", regex: /^={1,5}\s+\S.*$/, next: "start"},
|
||||
|
||||
{token: "otherBlock", regex: /^(?:\*{2,}|_{2,})\s*$/, next: "start"},
|
||||
// .optional title
|
||||
{token: "optionalTitle", regex: /^\.[^.\s].+$/, next: "start"}
|
||||
],
|
||||
|
||||
"listStart": [
|
||||
{token: "keyword", regex: /^\s*(?:\d+\.|[a-zA-Z]\.|[ixvmIXVM]+\)|\*{1,5}|-|\.{1,5})\s/, next: "listText"},
|
||||
{token: "meta.tag", regex: /^.+(?::{2,4}|;;)(?: |$)/, next: "listText"},
|
||||
{token: "support.function.list.callout", regex: /^(?:<\d+>|\d+>|>) /, next: "text"},
|
||||
// continuation
|
||||
{token: "keyword", regex: /^\+\s*$/, next: "start"}
|
||||
],
|
||||
|
||||
"text": [
|
||||
{token: ["link", "variable.language"], regex: /((?:https?:\/\/|ftp:\/\/|file:\/\/|mailto:|callto:)[^\s\[]+)(\[.*?\])/},
|
||||
{token: "link", regex: /(?:https?:\/\/|ftp:\/\/|file:\/\/|mailto:|callto:)[^\s\[]+/},
|
||||
{token: "link", regex: /\b[\w\.\/\-]+@[\w\.\/\-]+\b/},
|
||||
{include: "macros"},
|
||||
{include: "paragraphEnd"},
|
||||
{token: "literal", regex:/\+{3,}/, next:"smallPassthrough"},
|
||||
{token: "escape", regex: /\((?:C|TM|R)\)|\.{3}|->|<-|=>|<=|&#(?:\d+|x[a-fA-F\d]+);|(?: |^)--(?=\s+\S)/},
|
||||
{token: "escape", regex: /\\[_*'`+#]|\\{2}[_*'`+#]{2}/},
|
||||
{token: "keyword", regex: /\s\+$/},
|
||||
// any word
|
||||
{token: "text", regex: identifierRe},
|
||||
{token: ["keyword", "string", "keyword"],
|
||||
regex: /(<<[\w\d\-$]+,)(.*?)(>>|$)/, merge: true},
|
||||
{token: "keyword", regex: /<<[\w\d\-$]+,?|>>/, merge: true},
|
||||
{token: "constant.character", regex: /\({2,3}.*?\){2,3}/, merge: true},
|
||||
// Anchor
|
||||
{token: "keyword", regex: /\[\[.+?\]\]/},
|
||||
// bibliography
|
||||
{token: "support", regex: /^\[{3}[\w\d =\-]+\]{3}/},
|
||||
|
||||
{include: "quotes"},
|
||||
// text block end
|
||||
{token: "empty", regex: /^\s*$/, next: "start"}
|
||||
],
|
||||
|
||||
"listText": [
|
||||
{include: "listStart"},
|
||||
{include: "text"}
|
||||
],
|
||||
|
||||
"indentedBlock": [
|
||||
{token: "literal", regex: /^[\s\w].+$/, next: "indentedBlock"},
|
||||
{token: "literal", regex: "", next: "start"}
|
||||
],
|
||||
|
||||
"listingBlock": [
|
||||
{token: "literal", regex: /^\.{4,}\s*$/, next: "dissallowDelimitedBlock"},
|
||||
{token: "constant.numeric", regex: '<\\d+>'},
|
||||
{token: "literal", regex: '[^<]+', merge: true},
|
||||
{token: "literal", regex: '<', merge: true}
|
||||
],
|
||||
"literalBlock": [
|
||||
{token: "literal", regex: /^-{4,}\s*$/, next: "dissallowDelimitedBlock"},
|
||||
{token: "constant.numeric", regex: '<\\d+>'},
|
||||
{token: "literal", regex: '[^<]+', merge: true},
|
||||
{token: "literal", regex: '<', merge: true}
|
||||
],
|
||||
"passthroughBlock": [
|
||||
{token: "literal", regex: /^\+{4,}\s*$/, next: "dissallowDelimitedBlock"},
|
||||
{token: "literal", regex: identifierRe + "|\\d+", merge: true},
|
||||
{include: "macros"},
|
||||
{token: "literal", regex: ".", merge: true}
|
||||
],
|
||||
|
||||
"smallPassthrough": [
|
||||
{token: "literal", regex: /[+]{3,}/, next: "dissallowDelimitedBlock"},
|
||||
{token: "literal", regex: /^\s*$/, next: "dissallowDelimitedBlock", merge: true},
|
||||
{token: "literal", regex: identifierRe + "|\\d+", merge: true},
|
||||
{include: "macros"}
|
||||
],
|
||||
|
||||
"commentBlock": [
|
||||
{token: "doc.comment", regex: /^\/{4,}\s*$/, next: "dissallowDelimitedBlock"},
|
||||
{token: "doc.comment", regex: '^.*$'}
|
||||
],
|
||||
"tableBlock": [
|
||||
{token: "tableBlock", regex: /^\s*\|={3,}\s*$/, next: "dissallowDelimitedBlock"},
|
||||
{token: "tableBlock", regex: /^\s*!={3,}\s*$/, next: "innerTableBlock"},
|
||||
{token: "tableBlock", regex: /\|/},
|
||||
{include: "text", noEscape: true}
|
||||
],
|
||||
"innerTableBlock": [
|
||||
{token: "tableBlock", regex: /^\s*!={3,}\s*$/, next: "tableBlock"},
|
||||
{token: "tableBlock", regex: /^\s*|={3,}\s*$/, next: "dissallowDelimitedBlock"},
|
||||
{token: "tableBlock", regex: /\!/}
|
||||
],
|
||||
"macros": [
|
||||
{token: "macro", regex: /{[\w\-$]+}/},
|
||||
{token: ["text", "string", "text", "constant.character", "text"], regex: /({)([\w\-$]+)(:)?(.+)?(})/},
|
||||
{token: ["markup.list.macro", "keyword", "string"], regex: /([\w\.\/\-]+::?)([^\s\[]+)(\[.*?\])?/},
|
||||
{token: ["markup.list.macro", "keyword"], regex: /([\w\.\/\-]+::?)(\[.*?\])/},
|
||||
{token: "keyword", regex: /^:.+?:(?= |$)/}
|
||||
],
|
||||
|
||||
"quotes": [
|
||||
{token: "string.italic", regex: /__[^_\s].*?__/},
|
||||
{token: "string.italic", regex: quoteRule("_")},
|
||||
|
||||
{token: "keyword.bold", regex: /\*\*[^*\s].*?\*\*/},
|
||||
{token: "keyword.bold", regex: quoteRule("\\*")},
|
||||
|
||||
{token: "literal", regex: quoteRule("\\+")},
|
||||
{token: "literal", regex: /\+\+[^+\s].*?\+\+/},
|
||||
{token: "literal", regex: /\$\$.+?\$\$/},
|
||||
{token: "literal", regex: quoteRule("`")},
|
||||
|
||||
{token: "keyword", regex: quoteRule("^")},
|
||||
{token: "keyword", regex: quoteRule("~")},
|
||||
{token: "keyword", regex: /##?/},
|
||||
{token: "keyword", regex: /(?:\B|^)``|\b''/}
|
||||
]
|
||||
|
||||
};
|
||||
|
||||
function quoteRule(ch) {
|
||||
var prefix = /\w/.test(ch) ? "\\b" : "(?:\\B|^)";
|
||||
return prefix + ch + "[^" + ch + "].*?" + ch + "(?![\\w*])";
|
||||
}
|
||||
|
||||
//addQuoteBlock("text")
|
||||
|
||||
var tokenMap = {
|
||||
macro: "constant.character",
|
||||
tableBlock: "doc.comment",
|
||||
titleUnderline: "markup.heading",
|
||||
singleLineTitle: "markup.heading",
|
||||
pageBreak: "string",
|
||||
option: "string.regexp",
|
||||
otherBlock: "markup.list",
|
||||
literal: "support.function",
|
||||
optionalTitle: "constant.numeric",
|
||||
escape: "constant.language.escape",
|
||||
link: "markup.underline.list"
|
||||
};
|
||||
|
||||
for (var state in this.$rules) {
|
||||
var stateRules = this.$rules[state];
|
||||
for (var i = stateRules.length; i--; ) {
|
||||
var rule = stateRules[i];
|
||||
if (rule.include || typeof rule == "string") {
|
||||
var args = [i, 1].concat(this.$rules[rule.include || rule]);
|
||||
if (rule.noEscape) {
|
||||
args = args.filter(function(x) {
|
||||
return !x.next;
|
||||
});
|
||||
}
|
||||
stateRules.splice.apply(stateRules, args);
|
||||
} else if (rule.token in tokenMap) {
|
||||
rule.token = tokenMap[rule.token];
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
oop.inherits(AsciidocHighlightRules, TextHighlightRules);
|
||||
|
||||
exports.AsciidocHighlightRules = AsciidocHighlightRules;
|
||||
});
|
||||
|
|
@ -33,19 +33,70 @@ define(function(require, exports, module) {
|
|||
|
||||
var oop = require("../../lib/oop");
|
||||
var Behaviour = require("../behaviour").Behaviour;
|
||||
var TokenIterator = require("../../token_iterator").TokenIterator;
|
||||
|
||||
var autoInsertedBrackets = 0;
|
||||
var autoInsertedRow = -1;
|
||||
var autoInsertedLineEnd = "";
|
||||
|
||||
var CstyleBehaviour = function () {
|
||||
|
||||
CstyleBehaviour.isSaneInsertion = function(editor, session) {
|
||||
var cursor = editor.getCursorPosition();
|
||||
var iterator = new TokenIterator(session, cursor.row, cursor.column);
|
||||
|
||||
// Don't insert in the middle of a keyword/identifier/lexical
|
||||
if (!this.$matchTokenType(iterator.getCurrentToken() || "text", ["text", "paren.rparen"])) {
|
||||
// Look ahead in case we're at the end of a token
|
||||
iterator = new TokenIterator(session, cursor.row, cursor.column + 1);
|
||||
if (!this.$matchTokenType(iterator.getCurrentToken() || "text", ["text", "paren.rparen"]))
|
||||
return false;
|
||||
}
|
||||
|
||||
// Only insert in front of whitespace/comments
|
||||
iterator.stepForward();
|
||||
return iterator.getCurrentTokenRow() !== cursor.row ||
|
||||
this.$matchTokenType(iterator.getCurrentToken() || "text", ["text", "comment", "paren.rparen"]);
|
||||
};
|
||||
|
||||
CstyleBehaviour.$matchTokenType = function(token, types) {
|
||||
return types.indexOf(token.type || token) > -1;
|
||||
};
|
||||
|
||||
CstyleBehaviour.recordAutoInsert = function(editor, session, bracket) {
|
||||
var cursor = editor.getCursorPosition();
|
||||
var line = session.doc.getLine(cursor.row);
|
||||
// Reset previous state if text or context changed too much
|
||||
if (!this.isAutoInsertedClosing(cursor, line, autoInsertedLineEnd[0]))
|
||||
autoInsertedBrackets = 0;
|
||||
autoInsertedRow = cursor.row;
|
||||
autoInsertedLineEnd = bracket + line.substr(cursor.column);
|
||||
autoInsertedBrackets++;
|
||||
};
|
||||
|
||||
CstyleBehaviour.isAutoInsertedClosing = function(cursor, line, bracket) {
|
||||
return autoInsertedBrackets > 0 &&
|
||||
cursor.row === autoInsertedRow &&
|
||||
bracket === autoInsertedLineEnd[0] &&
|
||||
line.substr(cursor.column) === autoInsertedLineEnd;
|
||||
};
|
||||
|
||||
CstyleBehaviour.popAutoInsertedClosing = function() {
|
||||
autoInsertedLineEnd = autoInsertedLineEnd.substr(1);
|
||||
autoInsertedBrackets--;
|
||||
};
|
||||
|
||||
this.add("braces", "insertion", function (state, action, editor, session, text) {
|
||||
if (text == '{') {
|
||||
var selection = editor.getSelectionRange();
|
||||
var selected = session.doc.getTextRange(selection);
|
||||
if (selected !== "") {
|
||||
if (selected !== "" && selected !== "{") {
|
||||
return {
|
||||
text: '{' + selected + '}',
|
||||
selection: false
|
||||
};
|
||||
} else {
|
||||
} else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
|
||||
CstyleBehaviour.recordAutoInsert(editor, session, "}");
|
||||
return {
|
||||
text: '{}',
|
||||
selection: [1, 1]
|
||||
|
|
@ -57,7 +108,8 @@ var CstyleBehaviour = function () {
|
|||
var rightChar = line.substring(cursor.column, cursor.column + 1);
|
||||
if (rightChar == '}') {
|
||||
var matching = session.$findOpeningBracket('}', {column: cursor.column + 1, row: cursor.row});
|
||||
if (matching !== null) {
|
||||
if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) {
|
||||
CstyleBehaviour.popAutoInsertedClosing();
|
||||
return {
|
||||
text: '',
|
||||
selection: [1, 1]
|
||||
|
|
@ -105,7 +157,8 @@ var CstyleBehaviour = function () {
|
|||
text: '(' + selected + ')',
|
||||
selection: false
|
||||
};
|
||||
} else {
|
||||
} else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
|
||||
CstyleBehaviour.recordAutoInsert(editor, session, ")");
|
||||
return {
|
||||
text: '()',
|
||||
selection: [1, 1]
|
||||
|
|
@ -117,7 +170,8 @@ var CstyleBehaviour = function () {
|
|||
var rightChar = line.substring(cursor.column, cursor.column + 1);
|
||||
if (rightChar == ')') {
|
||||
var matching = session.$findOpeningBracket(')', {column: cursor.column + 1, row: cursor.row});
|
||||
if (matching !== null) {
|
||||
if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) {
|
||||
CstyleBehaviour.popAutoInsertedClosing();
|
||||
return {
|
||||
text: '',
|
||||
selection: [1, 1]
|
||||
|
|
@ -148,7 +202,8 @@ var CstyleBehaviour = function () {
|
|||
text: '[' + selected + ']',
|
||||
selection: false
|
||||
};
|
||||
} else {
|
||||
} else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
|
||||
CstyleBehaviour.recordAutoInsert(editor, session, "]");
|
||||
return {
|
||||
text: '[]',
|
||||
selection: [1, 1]
|
||||
|
|
@ -160,7 +215,8 @@ var CstyleBehaviour = function () {
|
|||
var rightChar = line.substring(cursor.column, cursor.column + 1);
|
||||
if (rightChar == ']') {
|
||||
var matching = session.$findOpeningBracket(']', {column: cursor.column + 1, row: cursor.row});
|
||||
if (matching !== null) {
|
||||
if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) {
|
||||
CstyleBehaviour.popAutoInsertedClosing();
|
||||
return {
|
||||
text: '',
|
||||
selection: [1, 1]
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2011 Jeremy Ashkenas
|
||||
/**
|
||||
* Copyright (c) 2009-2012 Jeremy Ashkenas
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person
|
||||
* obtaining a copy of this software and associated documentation
|
||||
|
|
@ -24,9 +24,9 @@
|
|||
*/
|
||||
|
||||
define(function(require, exports, module) {
|
||||
// Generated by CoffeeScript 1.2.1-pre
|
||||
// Generated by CoffeeScript 1.3.3
|
||||
|
||||
var extend, flatten;
|
||||
var extend, flatten, _ref;
|
||||
|
||||
exports.starts = function(string, literal, start) {
|
||||
return literal === string.substr(start, literal.length);
|
||||
|
|
@ -43,7 +43,9 @@ define(function(require, exports, module) {
|
|||
_results = [];
|
||||
for (_i = 0, _len = array.length; _i < _len; _i++) {
|
||||
item = array[_i];
|
||||
if (item) _results.push(item);
|
||||
if (item) {
|
||||
_results.push(item);
|
||||
}
|
||||
}
|
||||
return _results;
|
||||
};
|
||||
|
|
@ -51,7 +53,9 @@ define(function(require, exports, module) {
|
|||
exports.count = function(string, substr) {
|
||||
var num, pos;
|
||||
num = pos = 0;
|
||||
if (!substr.length) return 1 / 0;
|
||||
if (!substr.length) {
|
||||
return 1 / 0;
|
||||
}
|
||||
while (pos = 1 + string.indexOf(substr, pos)) {
|
||||
num++;
|
||||
}
|
||||
|
|
@ -96,5 +100,16 @@ define(function(require, exports, module) {
|
|||
return array[array.length - (back || 0) - 1];
|
||||
};
|
||||
|
||||
exports.some = (_ref = Array.prototype.some) != null ? _ref : function(fn) {
|
||||
var e, _i, _len;
|
||||
for (_i = 0, _len = this.length; _i < _len; _i++) {
|
||||
e = this[_i];
|
||||
if (fn(e)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2011 Jeremy Ashkenas
|
||||
/**
|
||||
* Copyright (c) 2009-2012 Jeremy Ashkenas
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person
|
||||
* obtaining a copy of this software and associated documentation
|
||||
|
|
@ -24,7 +24,7 @@
|
|||
*/
|
||||
|
||||
define(function(require, exports, module) {
|
||||
// Generated by CoffeeScript 1.2.1-pre
|
||||
// Generated by CoffeeScript 1.3.3
|
||||
|
||||
var BOOL, CALLABLE, CODE, COFFEE_ALIASES, COFFEE_ALIAS_MAP, COFFEE_KEYWORDS, COMMENT, COMPARE, COMPOUND_ASSIGN, HEREDOC, HEREDOC_ILLEGAL, HEREDOC_INDENT, HEREGEX, HEREGEX_OMIT, IDENTIFIER, INDEXABLE, INVERSES, JSTOKEN, JS_FORBIDDEN, JS_KEYWORDS, LINE_BREAK, LINE_CONTINUER, LOGIC, Lexer, MATH, MULTILINER, MULTI_DENT, NOT_REGEX, NOT_SPACED_REGEX, NUMBER, OPERATOR, REGEX, RELATION, RESERVED, Rewriter, SHIFT, SIMPLESTR, STRICT_PROSCRIBED, TRAILING_SPACES, UNARY, WHITESPACE, compact, count, key, last, starts, _ref, _ref1,
|
||||
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
|
||||
|
|
@ -35,14 +35,16 @@ define(function(require, exports, module) {
|
|||
|
||||
exports.Lexer = Lexer = (function() {
|
||||
|
||||
Lexer.name = 'Lexer';
|
||||
|
||||
function Lexer() {}
|
||||
|
||||
Lexer.prototype.tokenize = function(code, opts) {
|
||||
var i, tag;
|
||||
if (opts == null) opts = {};
|
||||
if (WHITESPACE.test(code)) code = "\n" + code;
|
||||
if (opts == null) {
|
||||
opts = {};
|
||||
}
|
||||
if (WHITESPACE.test(code)) {
|
||||
code = "\n" + code;
|
||||
}
|
||||
code = code.replace(/\r/g, '').replace(TRAILING_SPACES, '');
|
||||
this.code = code;
|
||||
this.line = opts.line || 0;
|
||||
|
|
@ -57,14 +59,20 @@ define(function(require, exports, module) {
|
|||
i += this.identifierToken() || this.commentToken() || this.whitespaceToken() || this.lineToken() || this.heredocToken() || this.stringToken() || this.numberToken() || this.regexToken() || this.jsToken() || this.literalToken();
|
||||
}
|
||||
this.closeIndentation();
|
||||
if (tag = this.ends.pop()) this.error("missing " + tag);
|
||||
if (opts.rewrite === false) return this.tokens;
|
||||
if (tag = this.ends.pop()) {
|
||||
this.error("missing " + tag);
|
||||
}
|
||||
if (opts.rewrite === false) {
|
||||
return this.tokens;
|
||||
}
|
||||
return (new Rewriter).rewrite(this.tokens);
|
||||
};
|
||||
|
||||
Lexer.prototype.identifierToken = function() {
|
||||
var colon, forcedIdentifier, id, input, match, prev, tag, _ref2, _ref3;
|
||||
if (!(match = IDENTIFIER.exec(this.chunk))) return 0;
|
||||
if (!(match = IDENTIFIER.exec(this.chunk))) {
|
||||
return 0;
|
||||
}
|
||||
input = match[0], id = match[1], colon = match[2];
|
||||
if (id === 'own' && this.tag() === 'FOR') {
|
||||
this.token('OWN', id);
|
||||
|
|
@ -105,7 +113,9 @@ define(function(require, exports, module) {
|
|||
}
|
||||
}
|
||||
if (!forcedIdentifier) {
|
||||
if (__indexOf.call(COFFEE_ALIASES, id) >= 0) id = COFFEE_ALIAS_MAP[id];
|
||||
if (__indexOf.call(COFFEE_ALIASES, id) >= 0) {
|
||||
id = COFFEE_ALIAS_MAP[id];
|
||||
}
|
||||
tag = (function() {
|
||||
switch (id) {
|
||||
case '!':
|
||||
|
|
@ -118,8 +128,6 @@ define(function(require, exports, module) {
|
|||
return 'LOGIC';
|
||||
case 'true':
|
||||
case 'false':
|
||||
case 'null':
|
||||
case 'undefined':
|
||||
return 'BOOL';
|
||||
case 'break':
|
||||
case 'continue':
|
||||
|
|
@ -130,29 +138,33 @@ define(function(require, exports, module) {
|
|||
})();
|
||||
}
|
||||
this.token(tag, id);
|
||||
if (colon) this.token(':', ':');
|
||||
if (colon) {
|
||||
this.token(':', ':');
|
||||
}
|
||||
return input.length;
|
||||
};
|
||||
|
||||
Lexer.prototype.numberToken = function() {
|
||||
var binaryLiteral, lexedLength, match, number, octalLiteral;
|
||||
if (!(match = NUMBER.exec(this.chunk))) return 0;
|
||||
if (!(match = NUMBER.exec(this.chunk))) {
|
||||
return 0;
|
||||
}
|
||||
number = match[0];
|
||||
if (/E/.test(number)) {
|
||||
this.error("exponential notation '" + number + "' must be indicated with a lowercase 'e'");
|
||||
} else if (/[BOX]/.test(number)) {
|
||||
if (/^0[BOX]/.test(number)) {
|
||||
this.error("radix prefix '" + number + "' must be lowercase");
|
||||
} else if (/^0[89]/.test(number)) {
|
||||
} else if (/E/.test(number) && !/^0x/.test(number)) {
|
||||
this.error("exponential notation '" + number + "' must be indicated with a lowercase 'e'");
|
||||
} else if (/^0\d*[89]/.test(number)) {
|
||||
this.error("decimal literal '" + number + "' must not be prefixed with '0'");
|
||||
} else if (/^0[0-7]/.test(number)) {
|
||||
} else if (/^0\d+/.test(number)) {
|
||||
this.error("octal literal '" + number + "' must be prefixed with '0o'");
|
||||
}
|
||||
lexedLength = number.length;
|
||||
if (octalLiteral = /0o([0-7]+)/.exec(number)) {
|
||||
number = (parseInt(octalLiteral[1], 8)).toString();
|
||||
if (octalLiteral = /^0o([0-7]+)/.exec(number)) {
|
||||
number = '0x' + (parseInt(octalLiteral[1], 8)).toString(16);
|
||||
}
|
||||
if (binaryLiteral = /0b([01]+)/.exec(number)) {
|
||||
number = (parseInt(binaryLiteral[1], 2)).toString();
|
||||
if (binaryLiteral = /^0b([01]+)/.exec(number)) {
|
||||
number = '0x' + (parseInt(binaryLiteral[1], 2)).toString(16);
|
||||
}
|
||||
this.token('NUMBER', number);
|
||||
return lexedLength;
|
||||
|
|
@ -162,11 +174,15 @@ define(function(require, exports, module) {
|
|||
var match, octalEsc, string;
|
||||
switch (this.chunk.charAt(0)) {
|
||||
case "'":
|
||||
if (!(match = SIMPLESTR.exec(this.chunk))) return 0;
|
||||
if (!(match = SIMPLESTR.exec(this.chunk))) {
|
||||
return 0;
|
||||
}
|
||||
this.token('STRING', (string = match[0]).replace(MULTILINER, '\\\n'));
|
||||
break;
|
||||
case '"':
|
||||
if (!(string = this.balancedString(this.chunk, '"'))) return 0;
|
||||
if (!(string = this.balancedString(this.chunk, '"'))) {
|
||||
return 0;
|
||||
}
|
||||
if (0 < string.indexOf('#{', 1)) {
|
||||
this.interpolateString(string.slice(1, -1));
|
||||
} else {
|
||||
|
|
@ -176,7 +192,7 @@ define(function(require, exports, module) {
|
|||
default:
|
||||
return 0;
|
||||
}
|
||||
if (octalEsc = /^(?:\\.|[^\\])*\\[0-7]/.test(string)) {
|
||||
if (octalEsc = /^(?:\\.|[^\\])*\\(?:0[0-7]|[1-7])/.test(string)) {
|
||||
this.error("octal escape sequences " + string + " are not allowed");
|
||||
}
|
||||
this.line += count(string, '\n');
|
||||
|
|
@ -185,7 +201,9 @@ define(function(require, exports, module) {
|
|||
|
||||
Lexer.prototype.heredocToken = function() {
|
||||
var doc, heredoc, match, quote;
|
||||
if (!(match = HEREDOC.exec(this.chunk))) return 0;
|
||||
if (!(match = HEREDOC.exec(this.chunk))) {
|
||||
return 0;
|
||||
}
|
||||
heredoc = match[0];
|
||||
quote = heredoc.charAt(0);
|
||||
doc = this.sanitizeHeredoc(match[2], {
|
||||
|
|
@ -205,7 +223,9 @@ define(function(require, exports, module) {
|
|||
|
||||
Lexer.prototype.commentToken = function() {
|
||||
var comment, here, match;
|
||||
if (!(match = this.chunk.match(COMMENT))) return 0;
|
||||
if (!(match = this.chunk.match(COMMENT))) {
|
||||
return 0;
|
||||
}
|
||||
comment = match[0], here = match[1];
|
||||
if (here) {
|
||||
this.token('HERECOMMENT', this.sanitizeHeredoc(here, {
|
||||
|
|
@ -223,12 +243,15 @@ define(function(require, exports, module) {
|
|||
return 0;
|
||||
}
|
||||
this.token('JS', (script = match[0]).slice(1, -1));
|
||||
this.line += count(script, '\n');
|
||||
return script.length;
|
||||
};
|
||||
|
||||
Lexer.prototype.regexToken = function() {
|
||||
var flags, length, match, prev, regex, _ref2, _ref3;
|
||||
if (this.chunk.charAt(0) !== '/') return 0;
|
||||
if (this.chunk.charAt(0) !== '/') {
|
||||
return 0;
|
||||
}
|
||||
if (match = HEREGEX.exec(this.chunk)) {
|
||||
length = this.heregexToken(match);
|
||||
this.line += count(match[0], '\n');
|
||||
|
|
@ -238,12 +261,16 @@ define(function(require, exports, module) {
|
|||
if (prev && (_ref2 = prev[0], __indexOf.call((prev.spaced ? NOT_REGEX : NOT_SPACED_REGEX), _ref2) >= 0)) {
|
||||
return 0;
|
||||
}
|
||||
if (!(match = REGEX.exec(this.chunk))) return 0;
|
||||
if (!(match = REGEX.exec(this.chunk))) {
|
||||
return 0;
|
||||
}
|
||||
_ref3 = match, match = _ref3[0], regex = _ref3[1], flags = _ref3[2];
|
||||
if (regex.slice(0, 2) === '/*') {
|
||||
this.error('regular expressions cannot begin with `*`');
|
||||
}
|
||||
if (regex === '//') regex = '/(?:)/';
|
||||
if (regex === '//') {
|
||||
regex = '/(?:)/';
|
||||
}
|
||||
this.token('REGEX', "" + regex + flags);
|
||||
return match.length;
|
||||
};
|
||||
|
|
@ -270,7 +297,9 @@ define(function(require, exports, module) {
|
|||
if (tag === 'TOKENS') {
|
||||
tokens.push.apply(tokens, value);
|
||||
} else {
|
||||
if (!(value = value.replace(HEREGEX_OMIT, ''))) continue;
|
||||
if (!(value = value.replace(HEREGEX_OMIT, ''))) {
|
||||
continue;
|
||||
}
|
||||
value = value.replace(/\\/g, '\\\\');
|
||||
tokens.push(['STRING', this.makeString(value, '"', true)]);
|
||||
}
|
||||
|
|
@ -281,18 +310,21 @@ define(function(require, exports, module) {
|
|||
this.tokens.push(['STRING', '""'], ['+', '+']);
|
||||
}
|
||||
(_ref5 = this.tokens).push.apply(_ref5, tokens);
|
||||
if (flags) this.tokens.push([',', ','], ['STRING', '"' + flags + '"']);
|
||||
if (flags) {
|
||||
this.tokens.push([',', ','], ['STRING', '"' + flags + '"']);
|
||||
}
|
||||
this.token(')', ')');
|
||||
return heregex.length;
|
||||
};
|
||||
|
||||
Lexer.prototype.lineToken = function() {
|
||||
var diff, indent, match, noNewlines, prev, size;
|
||||
if (!(match = MULTI_DENT.exec(this.chunk))) return 0;
|
||||
var diff, indent, match, noNewlines, size;
|
||||
if (!(match = MULTI_DENT.exec(this.chunk))) {
|
||||
return 0;
|
||||
}
|
||||
indent = match[0];
|
||||
this.line += count(indent, '\n');
|
||||
this.seenFor = false;
|
||||
prev = last(this.tokens, 1);
|
||||
size = indent.length - 1 - indent.lastIndexOf('\n');
|
||||
noNewlines = this.unfinished();
|
||||
if (size - this.indebt === this.indent) {
|
||||
|
|
@ -342,7 +374,9 @@ define(function(require, exports, module) {
|
|||
this.token('OUTDENT', dent);
|
||||
}
|
||||
}
|
||||
if (dent) this.outdebt -= moveOut;
|
||||
if (dent) {
|
||||
this.outdebt -= moveOut;
|
||||
}
|
||||
while (this.value() === ';') {
|
||||
this.tokens.pop();
|
||||
}
|
||||
|
|
@ -358,7 +392,9 @@ define(function(require, exports, module) {
|
|||
return 0;
|
||||
}
|
||||
prev = last(this.tokens);
|
||||
if (prev) prev[match ? 'spaced' : 'newLine'] = true;
|
||||
if (prev) {
|
||||
prev[match ? 'spaced' : 'newLine'] = true;
|
||||
}
|
||||
if (match) {
|
||||
return match[0].length;
|
||||
} else {
|
||||
|
|
@ -370,12 +406,16 @@ define(function(require, exports, module) {
|
|||
while (this.value() === ';') {
|
||||
this.tokens.pop();
|
||||
}
|
||||
if (this.tag() !== 'TERMINATOR') this.token('TERMINATOR', '\n');
|
||||
if (this.tag() !== 'TERMINATOR') {
|
||||
this.token('TERMINATOR', '\n');
|
||||
}
|
||||
return this;
|
||||
};
|
||||
|
||||
Lexer.prototype.suppressNewlines = function() {
|
||||
if (this.value() === '\\') this.tokens.pop();
|
||||
if (this.value() === '\\') {
|
||||
this.tokens.pop();
|
||||
}
|
||||
return this;
|
||||
};
|
||||
|
||||
|
|
@ -383,7 +423,9 @@ define(function(require, exports, module) {
|
|||
var match, prev, tag, value, _ref2, _ref3, _ref4, _ref5;
|
||||
if (match = OPERATOR.exec(this.chunk)) {
|
||||
value = match[0];
|
||||
if (CODE.test(value)) this.tagParameters();
|
||||
if (CODE.test(value)) {
|
||||
this.tagParameters();
|
||||
}
|
||||
} else {
|
||||
value = this.chunk.charAt(0);
|
||||
}
|
||||
|
|
@ -416,7 +458,9 @@ define(function(require, exports, module) {
|
|||
tag = 'LOGIC';
|
||||
} else if (prev && !prev.spaced) {
|
||||
if (value === '(' && (_ref4 = prev[0], __indexOf.call(CALLABLE, _ref4) >= 0)) {
|
||||
if (prev[0] === '?') prev[0] = 'FUNC_EXIST';
|
||||
if (prev[0] === '?') {
|
||||
prev[0] = 'FUNC_EXIST';
|
||||
}
|
||||
tag = 'CALL_START';
|
||||
} else if (value === '[' && (_ref5 = prev[0], __indexOf.call(INDEXABLE, _ref5) >= 0)) {
|
||||
tag = 'INDEX_START';
|
||||
|
|
@ -448,7 +492,9 @@ define(function(require, exports, module) {
|
|||
if (HEREDOC_ILLEGAL.test(doc)) {
|
||||
this.error("block comment cannot contain \"*/\", starting");
|
||||
}
|
||||
if (doc.indexOf('\n') <= 0) return doc;
|
||||
if (doc.indexOf('\n') <= 0) {
|
||||
return doc;
|
||||
}
|
||||
} else {
|
||||
while (match = HEREDOC_INDENT.exec(doc)) {
|
||||
attempt = match[1];
|
||||
|
|
@ -457,14 +503,20 @@ define(function(require, exports, module) {
|
|||
}
|
||||
}
|
||||
}
|
||||
if (indent) doc = doc.replace(RegExp("\\n" + indent, "g"), '\n');
|
||||
if (!herecomment) doc = doc.replace(/^\n/, '');
|
||||
if (indent) {
|
||||
doc = doc.replace(RegExp("\\n" + indent, "g"), '\n');
|
||||
}
|
||||
if (!herecomment) {
|
||||
doc = doc.replace(/^\n/, '');
|
||||
}
|
||||
return doc;
|
||||
};
|
||||
|
||||
Lexer.prototype.tagParameters = function() {
|
||||
var i, stack, tok, tokens;
|
||||
if (this.tag() !== ')') return this;
|
||||
if (this.tag() !== ')') {
|
||||
return this;
|
||||
}
|
||||
stack = [];
|
||||
tokens = this.tokens;
|
||||
i = tokens.length;
|
||||
|
|
@ -508,7 +560,9 @@ define(function(require, exports, module) {
|
|||
continue;
|
||||
case end:
|
||||
stack.pop();
|
||||
if (!stack.length) return str.slice(0, i + 1 || 9e9);
|
||||
if (!stack.length) {
|
||||
return str.slice(0, +i + 1 || 9e9);
|
||||
}
|
||||
end = stack[stack.length - 1];
|
||||
continue;
|
||||
}
|
||||
|
|
@ -528,7 +582,9 @@ define(function(require, exports, module) {
|
|||
|
||||
Lexer.prototype.interpolateString = function(str, options) {
|
||||
var expr, heredoc, i, inner, interpolated, len, letter, nested, pi, regex, tag, tokens, value, _i, _len, _ref2, _ref3, _ref4;
|
||||
if (options == null) options = {};
|
||||
if (options == null) {
|
||||
options = {};
|
||||
}
|
||||
heredoc = options.heredoc, regex = options.regex;
|
||||
tokens = [];
|
||||
pi = 0;
|
||||
|
|
@ -541,7 +597,9 @@ define(function(require, exports, module) {
|
|||
if (!(letter === '#' && str.charAt(i + 1) === '{' && (expr = this.balancedString(str.slice(i + 1), '}')))) {
|
||||
continue;
|
||||
}
|
||||
if (pi < i) tokens.push(['NEOSTRING', str.slice(pi, i)]);
|
||||
if (pi < i) {
|
||||
tokens.push(['NEOSTRING', str.slice(pi, i)]);
|
||||
}
|
||||
inner = expr.slice(1, -1);
|
||||
if (inner.length) {
|
||||
nested = new Lexer().tokenize(inner, {
|
||||
|
|
@ -563,28 +621,44 @@ define(function(require, exports, module) {
|
|||
i += expr.length;
|
||||
pi = i + 1;
|
||||
}
|
||||
if ((i > pi && pi < str.length)) tokens.push(['NEOSTRING', str.slice(pi)]);
|
||||
if (regex) return tokens;
|
||||
if (!tokens.length) return this.token('STRING', '""');
|
||||
if (tokens[0][0] !== 'NEOSTRING') tokens.unshift(['', '']);
|
||||
if (interpolated = tokens.length > 1) this.token('(', '(');
|
||||
if ((i > pi && pi < str.length)) {
|
||||
tokens.push(['NEOSTRING', str.slice(pi)]);
|
||||
}
|
||||
if (regex) {
|
||||
return tokens;
|
||||
}
|
||||
if (!tokens.length) {
|
||||
return this.token('STRING', '""');
|
||||
}
|
||||
if (tokens[0][0] !== 'NEOSTRING') {
|
||||
tokens.unshift(['', '']);
|
||||
}
|
||||
if (interpolated = tokens.length > 1) {
|
||||
this.token('(', '(');
|
||||
}
|
||||
for (i = _i = 0, _len = tokens.length; _i < _len; i = ++_i) {
|
||||
_ref3 = tokens[i], tag = _ref3[0], value = _ref3[1];
|
||||
if (i) this.token('+', '+');
|
||||
if (i) {
|
||||
this.token('+', '+');
|
||||
}
|
||||
if (tag === 'TOKENS') {
|
||||
(_ref4 = this.tokens).push.apply(_ref4, value);
|
||||
} else {
|
||||
this.token('STRING', this.makeString(value, '"', heredoc));
|
||||
}
|
||||
}
|
||||
if (interpolated) this.token(')', ')');
|
||||
if (interpolated) {
|
||||
this.token(')', ')');
|
||||
}
|
||||
return tokens;
|
||||
};
|
||||
|
||||
Lexer.prototype.pair = function(tag) {
|
||||
var size, wanted;
|
||||
if (tag !== (wanted = last(this.ends))) {
|
||||
if ('OUTDENT' !== wanted) this.error("unmatched " + tag);
|
||||
if ('OUTDENT' !== wanted) {
|
||||
this.error("unmatched " + tag);
|
||||
}
|
||||
this.indent -= size = last(this.indents);
|
||||
this.outdentToken(size, true);
|
||||
return this.pair(tag);
|
||||
|
|
@ -616,7 +690,9 @@ define(function(require, exports, module) {
|
|||
};
|
||||
|
||||
Lexer.prototype.makeString = function(body, quote, heredoc) {
|
||||
if (!body) return quote + quote;
|
||||
if (!body) {
|
||||
return quote + quote;
|
||||
}
|
||||
body = body.replace(/\\([\s\S])/g, function(match, contents) {
|
||||
if (contents === '\n' || contents === quote) {
|
||||
return contents;
|
||||
|
|
@ -663,7 +739,7 @@ define(function(require, exports, module) {
|
|||
|
||||
COFFEE_KEYWORDS = COFFEE_KEYWORDS.concat(COFFEE_ALIASES);
|
||||
|
||||
RESERVED = ['case', 'default', 'function', 'var', 'void', 'with', 'const', 'let', 'enum', 'export', 'import', 'native', '__hasProp', '__extends', '__slice', '__bind', '__indexOf', 'implements', 'interface', 'let', 'package', 'private', 'protected', 'public', 'static', 'yield'];
|
||||
RESERVED = ['case', 'default', 'function', 'var', 'void', 'with', 'const', 'let', 'enum', 'export', 'import', 'native', '__hasProp', '__extends', '__slice', '__bind', '__indexOf', 'implements', 'interface', 'package', 'private', 'protected', 'public', 'static', 'yield'];
|
||||
|
||||
STRICT_PROSCRIBED = ['arguments', 'eval'];
|
||||
|
||||
|
|
@ -723,17 +799,17 @@ define(function(require, exports, module) {
|
|||
|
||||
RELATION = ['IN', 'OF', 'INSTANCEOF'];
|
||||
|
||||
BOOL = ['TRUE', 'FALSE', 'NULL', 'UNDEFINED'];
|
||||
BOOL = ['TRUE', 'FALSE'];
|
||||
|
||||
NOT_REGEX = ['NUMBER', 'REGEX', 'BOOL', '++', '--', ']'];
|
||||
NOT_REGEX = ['NUMBER', 'REGEX', 'BOOL', 'NULL', 'UNDEFINED', '++', '--', ']'];
|
||||
|
||||
NOT_SPACED_REGEX = NOT_REGEX.concat(')', '}', 'THIS', 'IDENTIFIER', 'STRING');
|
||||
|
||||
CALLABLE = ['IDENTIFIER', 'STRING', 'REGEX', ')', ']', '}', '?', '::', '@', 'THIS', 'SUPER'];
|
||||
|
||||
INDEXABLE = CALLABLE.concat('NUMBER', 'BOOL');
|
||||
INDEXABLE = CALLABLE.concat('NUMBER', 'BOOL', 'NULL', 'UNDEFINED');
|
||||
|
||||
LINE_BREAK = ['INDENT', 'OUTDENT', 'TERMINATOR'];
|
||||
|
||||
|
||||
});
|
||||
});
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2011 Jeremy Ashkenas
|
||||
/**
|
||||
* Copyright (c) 2009-2012 Jeremy Ashkenas
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person
|
||||
* obtaining a copy of this software and associated documentation
|
||||
|
|
@ -24,7 +24,7 @@
|
|||
*/
|
||||
|
||||
define(function(require, exports, module) {
|
||||
// Generated by CoffeeScript 1.2.1-pre
|
||||
// Generated by CoffeeScript 1.3.3
|
||||
|
||||
var BALANCED_PAIRS, EXPRESSION_CLOSE, EXPRESSION_END, EXPRESSION_START, IMPLICIT_BLOCK, IMPLICIT_CALL, IMPLICIT_END, IMPLICIT_FUNC, IMPLICIT_UNSPACED_CALL, INVERSES, LINEBREAKS, SINGLE_CLOSERS, SINGLE_LINERS, left, rite, _i, _len, _ref,
|
||||
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; },
|
||||
|
|
@ -32,8 +32,6 @@ define(function(require, exports, module) {
|
|||
|
||||
exports.Rewriter = (function() {
|
||||
|
||||
Rewriter.name = 'Rewriter';
|
||||
|
||||
function Rewriter() {}
|
||||
|
||||
Rewriter.prototype.rewrite = function(tokens) {
|
||||
|
|
@ -67,7 +65,9 @@ define(function(require, exports, module) {
|
|||
if (levels === 0 && condition.call(this, token, i)) {
|
||||
return action.call(this, token, i);
|
||||
}
|
||||
if (!token || levels < 0) return action.call(this, token, i - 1);
|
||||
if (!token || levels < 0) {
|
||||
return action.call(this, token, i - 1);
|
||||
}
|
||||
if (_ref = token[0], __indexOf.call(EXPRESSION_START, _ref) >= 0) {
|
||||
levels += 1;
|
||||
} else if (_ref1 = token[0], __indexOf.call(EXPRESSION_END, _ref1) >= 0) {
|
||||
|
|
@ -83,9 +83,13 @@ define(function(require, exports, module) {
|
|||
_ref = this.tokens;
|
||||
for (i = _i = 0, _len = _ref.length; _i < _len; i = ++_i) {
|
||||
tag = _ref[i][0];
|
||||
if (tag !== 'TERMINATOR') break;
|
||||
if (tag !== 'TERMINATOR') {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i) {
|
||||
return this.tokens.splice(0, i);
|
||||
}
|
||||
if (i) return this.tokens.splice(0, i);
|
||||
};
|
||||
|
||||
Rewriter.prototype.removeMidExpressionNewlines = function() {
|
||||
|
|
@ -109,7 +113,9 @@ define(function(require, exports, module) {
|
|||
return this.tokens[token[0] === 'OUTDENT' ? i - 1 : i][0] = 'CALL_END';
|
||||
};
|
||||
return this.scanTokens(function(token, i) {
|
||||
if (token[0] === 'CALL_START') this.detectEnd(i + 1, condition, action);
|
||||
if (token[0] === 'CALL_START') {
|
||||
this.detectEnd(i + 1, condition, action);
|
||||
}
|
||||
return 1;
|
||||
});
|
||||
};
|
||||
|
|
@ -124,25 +130,32 @@ define(function(require, exports, module) {
|
|||
return token[0] = 'INDEX_END';
|
||||
};
|
||||
return this.scanTokens(function(token, i) {
|
||||
if (token[0] === 'INDEX_START') this.detectEnd(i + 1, condition, action);
|
||||
if (token[0] === 'INDEX_START') {
|
||||
this.detectEnd(i + 1, condition, action);
|
||||
}
|
||||
return 1;
|
||||
});
|
||||
};
|
||||
|
||||
Rewriter.prototype.addImplicitBraces = function() {
|
||||
var action, condition, sameLine, stack, start, startIndent, startsLine;
|
||||
var action, condition, sameLine, stack, start, startIndent, startIndex, startsLine;
|
||||
stack = [];
|
||||
start = null;
|
||||
startsLine = null;
|
||||
sameLine = true;
|
||||
startIndent = 0;
|
||||
startIndex = 0;
|
||||
condition = function(token, i) {
|
||||
var one, tag, three, two, _ref, _ref1;
|
||||
_ref = this.tokens.slice(i + 1, (i + 3) + 1 || 9e9), one = _ref[0], two = _ref[1], three = _ref[2];
|
||||
if ('HERECOMMENT' === (one != null ? one[0] : void 0)) return false;
|
||||
_ref = this.tokens.slice(i + 1, +(i + 3) + 1 || 9e9), one = _ref[0], two = _ref[1], three = _ref[2];
|
||||
if ('HERECOMMENT' === (one != null ? one[0] : void 0)) {
|
||||
return false;
|
||||
}
|
||||
tag = token[0];
|
||||
if (__indexOf.call(LINEBREAKS, tag) >= 0) sameLine = false;
|
||||
return (((tag === 'TERMINATOR' || tag === 'OUTDENT') || (__indexOf.call(IMPLICIT_END, tag) >= 0 && sameLine)) && ((!startsLine && this.tag(i - 1) !== ',') || !((two != null ? two[0] : void 0) === ':' || (one != null ? one[0] : void 0) === '@' && (three != null ? three[0] : void 0) === ':'))) || (tag === ',' && one && ((_ref1 = one[0]) !== 'IDENTIFIER' && _ref1 !== 'NUMBER' && _ref1 !== 'STRING' && _ref1 !== '@' && _ref1 !== 'TERMINATOR' && _ref1 !== 'OUTDENT'));
|
||||
if (__indexOf.call(LINEBREAKS, tag) >= 0) {
|
||||
sameLine = false;
|
||||
}
|
||||
return (((tag === 'TERMINATOR' || tag === 'OUTDENT') || (__indexOf.call(IMPLICIT_END, tag) >= 0 && sameLine && !(i - startIndex === 1))) && ((!startsLine && this.tag(i - 1) !== ',') || !((two != null ? two[0] : void 0) === ':' || (one != null ? one[0] : void 0) === '@' && (three != null ? three[0] : void 0) === ':'))) || (tag === ',' && one && ((_ref1 = one[0]) !== 'IDENTIFIER' && _ref1 !== 'NUMBER' && _ref1 !== 'STRING' && _ref1 !== '@' && _ref1 !== 'TERMINATOR' && _ref1 !== 'OUTDENT'));
|
||||
};
|
||||
action = function(token, i) {
|
||||
var tok;
|
||||
|
|
@ -163,6 +176,7 @@ define(function(require, exports, module) {
|
|||
return 1;
|
||||
}
|
||||
sameLine = true;
|
||||
startIndex = i + 1;
|
||||
stack.push(['{']);
|
||||
idx = ago === '@' ? i - 2 : i - 1;
|
||||
while (this.tag(idx - 2) === 'HERECOMMENT') {
|
||||
|
|
@ -185,7 +199,9 @@ define(function(require, exports, module) {
|
|||
condition = function(token, i) {
|
||||
var post, tag, _ref, _ref1;
|
||||
tag = token[0];
|
||||
if (!seenSingle && token.fromThen) return true;
|
||||
if (!seenSingle && token.fromThen) {
|
||||
return true;
|
||||
}
|
||||
if (tag === 'IF' || tag === 'ELSE' || tag === 'CATCH' || tag === '->' || tag === '=>' || tag === 'CLASS') {
|
||||
seenSingle = true;
|
||||
}
|
||||
|
|
@ -206,19 +222,27 @@ define(function(require, exports, module) {
|
|||
if (tag === 'CLASS' || tag === 'IF' || tag === 'FOR' || tag === 'WHILE') {
|
||||
noCall = true;
|
||||
}
|
||||
_ref = tokens.slice(i - 1, (i + 1) + 1 || 9e9), prev = _ref[0], current = _ref[1], next = _ref[2];
|
||||
_ref = tokens.slice(i - 1, +(i + 1) + 1 || 9e9), prev = _ref[0], current = _ref[1], next = _ref[2];
|
||||
callObject = !noCall && tag === 'INDENT' && next && next.generated && next[0] === '{' && prev && (_ref1 = prev[0], __indexOf.call(IMPLICIT_FUNC, _ref1) >= 0);
|
||||
seenSingle = false;
|
||||
seenControl = false;
|
||||
if (__indexOf.call(LINEBREAKS, tag) >= 0) noCall = false;
|
||||
if (prev && !prev.spaced && tag === '?') token.call = true;
|
||||
if (token.fromThen) return 1;
|
||||
if (__indexOf.call(LINEBREAKS, tag) >= 0) {
|
||||
noCall = false;
|
||||
}
|
||||
if (prev && !prev.spaced && tag === '?') {
|
||||
token.call = true;
|
||||
}
|
||||
if (token.fromThen) {
|
||||
return 1;
|
||||
}
|
||||
if (!(callObject || (prev != null ? prev.spaced : void 0) && (prev.call || (_ref2 = prev[0], __indexOf.call(IMPLICIT_FUNC, _ref2) >= 0)) && (__indexOf.call(IMPLICIT_CALL, tag) >= 0 || !(token.spaced || token.newLine) && __indexOf.call(IMPLICIT_UNSPACED_CALL, tag) >= 0))) {
|
||||
return 1;
|
||||
}
|
||||
tokens.splice(i, 0, this.generate('CALL_START', '(', token[2]));
|
||||
this.detectEnd(i + 1, condition, action);
|
||||
if (prev[0] === '?') prev[0] = 'FUNC_EXIST';
|
||||
if (prev[0] === '?') {
|
||||
prev[0] = 'FUNC_EXIST';
|
||||
}
|
||||
return 2;
|
||||
});
|
||||
};
|
||||
|
|
@ -251,10 +275,14 @@ define(function(require, exports, module) {
|
|||
if (__indexOf.call(SINGLE_LINERS, tag) >= 0 && this.tag(i + 1) !== 'INDENT' && !(tag === 'ELSE' && this.tag(i + 1) === 'IF')) {
|
||||
starter = tag;
|
||||
_ref1 = this.indentation(token, true), indent = _ref1[0], outdent = _ref1[1];
|
||||
if (starter === 'THEN') indent.fromThen = true;
|
||||
if (starter === 'THEN') {
|
||||
indent.fromThen = true;
|
||||
}
|
||||
tokens.splice(i + 1, 0, indent);
|
||||
this.detectEnd(i + 2, condition, action);
|
||||
if (tag === 'THEN') tokens.splice(i, 1);
|
||||
if (tag === 'THEN') {
|
||||
tokens.splice(i, 1);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
return 1;
|
||||
|
|
@ -274,7 +302,9 @@ define(function(require, exports, module) {
|
|||
}
|
||||
};
|
||||
return this.scanTokens(function(token, i) {
|
||||
if (token[0] !== 'IF') return 1;
|
||||
if (token[0] !== 'IF') {
|
||||
return 1;
|
||||
}
|
||||
original = token;
|
||||
this.detectEnd(i + 1, condition, action);
|
||||
return 1;
|
||||
|
|
@ -283,10 +313,14 @@ define(function(require, exports, module) {
|
|||
|
||||
Rewriter.prototype.indentation = function(token, implicit) {
|
||||
var indent, outdent;
|
||||
if (implicit == null) implicit = false;
|
||||
if (implicit == null) {
|
||||
implicit = false;
|
||||
}
|
||||
indent = ['INDENT', 2, token[2]];
|
||||
outdent = ['OUTDENT', 2, token[2]];
|
||||
if (implicit) indent.generated = outdent.generated = true;
|
||||
if (implicit) {
|
||||
indent.generated = outdent.generated = true;
|
||||
}
|
||||
return [indent, outdent];
|
||||
};
|
||||
|
||||
|
|
@ -324,7 +358,7 @@ define(function(require, exports, module) {
|
|||
|
||||
IMPLICIT_FUNC = ['IDENTIFIER', 'SUPER', ')', 'CALL_END', ']', 'INDEX_END', '@', 'THIS'];
|
||||
|
||||
IMPLICIT_CALL = ['IDENTIFIER', 'NUMBER', 'STRING', 'JS', 'REGEX', 'NEW', 'PARAM_START', 'CLASS', 'IF', 'TRY', 'SWITCH', 'THIS', 'BOOL', 'UNARY', 'SUPER', '@', '->', '=>', '[', '(', '{', '--', '++'];
|
||||
IMPLICIT_CALL = ['IDENTIFIER', 'NUMBER', 'STRING', 'JS', 'REGEX', 'NEW', 'PARAM_START', 'CLASS', 'IF', 'TRY', 'SWITCH', 'THIS', 'BOOL', 'NULL', 'UNDEFINED', 'UNARY', 'SUPER', '@', '->', '=>', '[', '(', '{', '--', '++'];
|
||||
|
||||
IMPLICIT_UNSPACED_CALL = ['+', '-'];
|
||||
|
||||
|
|
@ -339,4 +373,4 @@ define(function(require, exports, module) {
|
|||
LINEBREAKS = ['TERMINATOR', 'INDENT', 'OUTDENT'];
|
||||
|
||||
|
||||
});
|
||||
});
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2011 Jeremy Ashkenas
|
||||
/**
|
||||
* Copyright (c) 2009-2012 Jeremy Ashkenas
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person
|
||||
* obtaining a copy of this software and associated documentation
|
||||
|
|
@ -24,7 +24,7 @@
|
|||
*/
|
||||
|
||||
define(function(require, exports, module) {
|
||||
// Generated by CoffeeScript 1.2.1-pre
|
||||
// Generated by CoffeeScript 1.3.3
|
||||
|
||||
var Scope, extend, last, _ref;
|
||||
|
||||
|
|
@ -32,8 +32,6 @@ define(function(require, exports, module) {
|
|||
|
||||
exports.Scope = Scope = (function() {
|
||||
|
||||
Scope.name = 'Scope';
|
||||
|
||||
Scope.root = null;
|
||||
|
||||
function Scope(parent, expressions, method) {
|
||||
|
|
@ -47,11 +45,15 @@ define(function(require, exports, module) {
|
|||
}
|
||||
];
|
||||
this.positions = {};
|
||||
if (!this.parent) Scope.root = this;
|
||||
if (!this.parent) {
|
||||
Scope.root = this;
|
||||
}
|
||||
}
|
||||
|
||||
Scope.prototype.add = function(name, type, immediate) {
|
||||
if (this.shared && !immediate) return this.parent.add(name, type, immediate);
|
||||
if (this.shared && !immediate) {
|
||||
return this.parent.add(name, type, immediate);
|
||||
}
|
||||
if (Object.prototype.hasOwnProperty.call(this.positions, name)) {
|
||||
return this.variables[this.positions[name]].type = type;
|
||||
} else {
|
||||
|
|
@ -62,22 +64,31 @@ define(function(require, exports, module) {
|
|||
}
|
||||
};
|
||||
|
||||
Scope.prototype.find = function(name, options) {
|
||||
if (this.check(name, options)) return true;
|
||||
Scope.prototype.namedMethod = function() {
|
||||
if (this.method.name || !this.parent) {
|
||||
return this.method;
|
||||
}
|
||||
return this.parent.namedMethod();
|
||||
};
|
||||
|
||||
Scope.prototype.find = function(name) {
|
||||
if (this.check(name)) {
|
||||
return true;
|
||||
}
|
||||
this.add(name, 'var');
|
||||
return false;
|
||||
};
|
||||
|
||||
Scope.prototype.parameter = function(name) {
|
||||
if (this.shared && this.parent.check(name, true)) return;
|
||||
if (this.shared && this.parent.check(name, true)) {
|
||||
return;
|
||||
}
|
||||
return this.add(name, 'param');
|
||||
};
|
||||
|
||||
Scope.prototype.check = function(name, immediate) {
|
||||
var found, _ref1;
|
||||
found = !!this.type(name);
|
||||
if (found || immediate) return found;
|
||||
return !!((_ref1 = this.parent) != null ? _ref1.check(name) : void 0);
|
||||
Scope.prototype.check = function(name) {
|
||||
var _ref1;
|
||||
return !!(this.type(name) || ((_ref1 = this.parent) != null ? _ref1.check(name) : void 0));
|
||||
};
|
||||
|
||||
Scope.prototype.temporary = function(name, index) {
|
||||
|
|
@ -93,19 +104,25 @@ define(function(require, exports, module) {
|
|||
_ref1 = this.variables;
|
||||
for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
|
||||
v = _ref1[_i];
|
||||
if (v.name === name) return v.type;
|
||||
if (v.name === name) {
|
||||
return v.type;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
Scope.prototype.freeVariable = function(name, reserve) {
|
||||
var index, temp;
|
||||
if (reserve == null) reserve = true;
|
||||
if (reserve == null) {
|
||||
reserve = true;
|
||||
}
|
||||
index = 0;
|
||||
while (this.check((temp = this.temporary(name, index)))) {
|
||||
index++;
|
||||
}
|
||||
if (reserve) this.add(temp, 'var', true);
|
||||
if (reserve) {
|
||||
this.add(temp, 'var', true);
|
||||
}
|
||||
return temp;
|
||||
};
|
||||
|
||||
|
|
@ -141,7 +158,9 @@ define(function(require, exports, module) {
|
|||
_results = [];
|
||||
for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
|
||||
v = _ref1[_i];
|
||||
if (v.type.assigned) _results.push("" + v.name + " = " + v.type.value);
|
||||
if (v.type.assigned) {
|
||||
_results.push("" + v.name + " = " + v.type.value);
|
||||
}
|
||||
}
|
||||
return _results;
|
||||
};
|
||||
|
|
@ -151,4 +170,4 @@ define(function(require, exports, module) {
|
|||
})();
|
||||
|
||||
|
||||
});
|
||||
});
|
||||
|
|
@ -45,25 +45,28 @@ define(function(require, exports, module) {
|
|||
};
|
||||
|
||||
var keywords = (
|
||||
"this|throw|then|try|typeof|super|switch|return|break|by)|continue|" +
|
||||
"this|throw|then|try|typeof|super|switch|return|break|by|continue|" +
|
||||
"catch|class|in|instanceof|is|isnt|if|else|extends|for|forown|" +
|
||||
"finally|function|while|when|new|no|not|delete|debugger|do|loop|of|off|" +
|
||||
"or|on|unless|until|and|yes"
|
||||
);
|
||||
|
||||
var langConstant = (
|
||||
"true|false|null|undefined"
|
||||
"true|false|null|undefined|NaN|Infinity"
|
||||
);
|
||||
|
||||
var illegal = (
|
||||
"case|const|default|function|var|void|with|enum|export|implements|" +
|
||||
"interface|let|package|private|protected|public|static|yield|" +
|
||||
"__hasProp|extends|slice|bind|indexOf"
|
||||
"__hasProp|slice|bind|indexOf"
|
||||
);
|
||||
|
||||
var supportClass = (
|
||||
"Array|Boolean|Date|Function|Number|Object|RegExp|ReferenceError|" +
|
||||
"String|RangeError|SyntaxError|Error|EvalError|TypeError|URIError"
|
||||
"Array|Boolean|Date|Function|Number|Object|RegExp|ReferenceError|String|" +
|
||||
"Error|EvalError|InternalError|RangeError|ReferenceError|StopIteration|" +
|
||||
"SyntaxError|TypeError|URIError|" +
|
||||
"ArrayBuffer|Float32Array|Float64Array|Int16Array|Int32Array|Int8Array|" +
|
||||
"Uint16Array|Uint32Array|Uint8Array|Uint8ClampedArray"
|
||||
);
|
||||
|
||||
var supportFunction = (
|
||||
|
|
@ -71,26 +74,41 @@ define(function(require, exports, module) {
|
|||
"encodeURIComponent|decodeURI|decodeURIComponent|String|"
|
||||
);
|
||||
|
||||
var variableLanguage = (
|
||||
"window|arguments|prototype|document"
|
||||
);
|
||||
|
||||
var keywordMapper = this.createKeywordMapper({
|
||||
"keyword": keywords,
|
||||
"constant.language": langConstant,
|
||||
"invalid.illegal": illegal,
|
||||
"language.support.class": supportClass,
|
||||
"language.support.function": supportFunction,
|
||||
"variable.language": variableLanguage
|
||||
}, "identifier");
|
||||
|
||||
var functionRules = {
|
||||
"({args})->": {
|
||||
token: ["paren.lparen", "text", "paren.lparen", "text", "variable.parameter", "text", "paren.rparen", "text", "paren.rparen", "text", "storage.type"],
|
||||
regex: "(\\()(\\s*)(\\{)(\\s*)([$@A-Za-z_\\x7f-\\uffff][$@\\w\\s,\\x7f-\\uffff]*)(\\s*)(\\})(\\s*)(\\))(\\s*)([\\-=]>)"
|
||||
},
|
||||
"({})->": {
|
||||
token: ["paren.lparen", "text", "paren.lparen", "text", "paren.rparen", "text", "paren.rparen", "text", "storage.type"],
|
||||
regex: "(\\()(\\s*)(\\{)(\\s*)(\\})(\\s*)(\\))(\\s*)([\\-=]>)"
|
||||
},
|
||||
"(args)->": {
|
||||
token: ["paren.lparen", "text", "variable.parameter", "text", "paren.rparen", "text", "storage.type"],
|
||||
regex: "(\\()(\\s*)([$@A-Za-z_\\x7f-\\uffff][\\s\\x21-\\uffff]*)(\\s*)(\\))(\\s*)([\\-=]>)"
|
||||
},
|
||||
"()->": {
|
||||
token: ["paren.lparen", "text", "paren.rparen", "text", "storage.type"],
|
||||
regex: "(\\()(\\s*)(\\))(\\s*)([\\-=]>)"
|
||||
}
|
||||
};
|
||||
|
||||
this.$rules = {
|
||||
start : [
|
||||
{
|
||||
token : "identifier",
|
||||
regex : "(?:(?:\\.|::)\\s*)" + identifier
|
||||
}, {
|
||||
token : "variable",
|
||||
regex : "@(?:" + identifier + ")?"
|
||||
}, {
|
||||
token: keywordMapper,
|
||||
regex : identifier
|
||||
}, {
|
||||
token : "constant.numeric",
|
||||
regex : "(?:0x[\\da-fA-F]+|(?:\\d+(?:\\.\\d+)?|\\.\\d+)(?:[eE][+-]?\\d+)?)"
|
||||
}, {
|
||||
|
|
@ -125,7 +143,7 @@ define(function(require, exports, module) {
|
|||
next : "heregex"
|
||||
}, {
|
||||
token : "string.regex",
|
||||
regex : "/(?!\\s)[^[/\\n\\\\]*(?: (?:\\\\.|\\[[^\\]\\n\\\\]*(?:\\\\.[^\\]\\n\\\\]*)*\\])[^[/\\n\\\\]*)*/[imgy]{0,4}(?!\\w)"
|
||||
regex : /(?:\/(?![\s=])[^[\/\n\\]*(?:(?:\\[\s\S]|\[[^\]\n\\]*(?:\\[\s\S][^\]\n\\]*)*])[^[\/\n\\]*)*\/)(?:[imgy]{0,4})(?!\w)/
|
||||
}, {
|
||||
token : "comment",
|
||||
merge : true,
|
||||
|
|
@ -134,12 +152,109 @@ define(function(require, exports, module) {
|
|||
}, {
|
||||
token : "comment",
|
||||
regex : "#.*"
|
||||
}, {
|
||||
token : [
|
||||
"punctuation.operator", "identifier"
|
||||
],
|
||||
regex : "(\\.)(" + illegal + ")"
|
||||
}, {
|
||||
token : "punctuation.operator",
|
||||
regex : "\\."
|
||||
}, {
|
||||
//class A extends B
|
||||
token : [
|
||||
"keyword", "text", "language.support.class", "text", "keyword", "text", "language.support.class"
|
||||
],
|
||||
regex : "(class)(\\s+)(" + identifier + ")(\\s+)(extends)(\\s+)(" + identifier + ")"
|
||||
}, {
|
||||
//class A
|
||||
token : [
|
||||
"keyword", "text", "language.support.class"
|
||||
],
|
||||
regex : "(class)(\\s+)(" + identifier + ")"
|
||||
}, {
|
||||
//play = ({args}) ->
|
||||
token : [
|
||||
"entity.name.function", "text", "keyword.operator", "text"
|
||||
].concat(functionRules["({args})->"].token),
|
||||
regex : "(" + identifier + ")(\\s*)(=)(\\s*)" + functionRules["({args})->"].regex
|
||||
}, {
|
||||
//play : ({args}) ->
|
||||
token : [
|
||||
"entity.name.function", "text", "punctuation.operator", "text"
|
||||
].concat(functionRules["({args})->"].token),
|
||||
regex : "(" + identifier + ")(\\s*)(:)(\\s*)" + functionRules["({args})->"].regex
|
||||
}, {
|
||||
//play = ({}) ->
|
||||
token : [
|
||||
"entity.name.function", "text", "keyword.operator", "text"
|
||||
].concat(functionRules["({})->"].token),
|
||||
regex : "(" + identifier + ")(\\s*)(=)(\\s*)" + functionRules["({})->"].regex
|
||||
}, {
|
||||
//play : ({}) ->
|
||||
token : [
|
||||
"entity.name.function", "text", "punctuation.operator", "text"
|
||||
].concat(functionRules["({})->"].token),
|
||||
regex : "(" + identifier + ")(\\s*)(:)(\\s*)" + functionRules["({})->"].regex
|
||||
}, {
|
||||
//play = (args) ->
|
||||
token : [
|
||||
"entity.name.function", "text", "keyword.operator", "text"
|
||||
].concat(functionRules["(args)->"].token),
|
||||
regex : "(" + identifier + ")(\\s*)(=)(\\s*)" + functionRules["(args)->"].regex
|
||||
}, {
|
||||
//play : (args) ->
|
||||
token : [
|
||||
"entity.name.function", "text", "punctuation.operator", "text"
|
||||
].concat(functionRules["(args)->"].token),
|
||||
regex : "(" + identifier + ")(\\s*)(:)(\\s*)" + functionRules["(args)->"].regex
|
||||
}, {
|
||||
//play = () ->
|
||||
token : [
|
||||
"entity.name.function", "text", "keyword.operator", "text"
|
||||
].concat(functionRules["()->"].token),
|
||||
regex : "(" + identifier + ")(\\s*)(=)(\\s*)" + functionRules["()->"].regex
|
||||
}, {
|
||||
//play : () ->
|
||||
token : [
|
||||
"entity.name.function", "text", "punctuation.operator", "text"
|
||||
].concat(functionRules["()->"].token),
|
||||
regex : "(" + identifier + ")(\\s*)(:)(\\s*)" + functionRules["()->"].regex
|
||||
}, {
|
||||
//play = ->
|
||||
token : [
|
||||
"entity.name.function", "text", "keyword.operator", "text", "storage.type"
|
||||
],
|
||||
regex : "(" + identifier + ")(\\s*)(=)(\\s*)([\\-=]>)"
|
||||
}, {
|
||||
//play : ->
|
||||
token : [
|
||||
"entity.name.function", "text", "punctuation.operator", "text", "storage.type"
|
||||
],
|
||||
regex : "(" + identifier + ")(\\s*)(:)(\\s*)([\\-=]>)"
|
||||
},
|
||||
functionRules["({args})->"],
|
||||
functionRules["({})->"],
|
||||
functionRules["(args)->"],
|
||||
functionRules["()->"]
|
||||
, {
|
||||
token : "identifier",
|
||||
regex : "(?:(?:\\.|::)\\s*)" + identifier
|
||||
}, {
|
||||
token : "variable",
|
||||
regex : "@(?:" + identifier + ")?"
|
||||
}, {
|
||||
token: keywordMapper,
|
||||
regex : identifier
|
||||
}, {
|
||||
token : "punctuation.operator",
|
||||
regex : "\\?|\\:|\\,|\\."
|
||||
}, {
|
||||
token : "storage.type",
|
||||
regex : "[\\-=]>"
|
||||
}, {
|
||||
token : "keyword.operator",
|
||||
regex : "(?:[\\-=]>|[-+*/%<>&|^!?=]=|>>>=?|\\-\\-|\\+\\+|::|&&=|\\|\\|=|<<=|>>=|\\?\\.|\\.{2,3}|[!*+-=><])"
|
||||
regex : "(?:[-+*/%<>&|^!?=]=|>>>=?|\\-\\-|\\+\\+|::|&&=|\\|\\|=|<<=|>>=|\\?\\.|\\.{2,3}|[!*+-=><])"
|
||||
}, {
|
||||
token : "paren.lparen",
|
||||
regex : "[({[]"
|
||||
|
|
|
|||
|
|
@ -41,6 +41,12 @@ var assert = require("../test/assertions");
|
|||
module.exports = {
|
||||
setUp : function() {
|
||||
this.tokenizer = new Mode().getTokenizer();
|
||||
this.testTokens = function(tokens, correct) {
|
||||
assert.equal(tokens.length, correct.length);
|
||||
correct.forEach(function(type, i) {
|
||||
assert.equal(tokens[i].type, type);
|
||||
});
|
||||
};
|
||||
},
|
||||
|
||||
"test: tokenize keyword": function() {
|
||||
|
|
@ -49,6 +55,201 @@ module.exports = {
|
|||
assert.equal(tokens[0].type, "keyword");
|
||||
},
|
||||
|
||||
"test: tokenize regexp": function() {
|
||||
var tokens = this.tokenizer.getLineTokens('/"[a]/', "start").tokens;
|
||||
assert.equal(tokens.length, 1);
|
||||
assert.equal(tokens[0].type, "string.regex");
|
||||
},
|
||||
|
||||
"test: tokenize function: 'foo = ({args}) ->'": function() {
|
||||
var tokens = this.tokenizer.getLineTokens("foo = ({args}) ->", "start").tokens;
|
||||
var correct = [
|
||||
"entity.name.function", "text", "keyword.operator", "text",
|
||||
"paren.lparen", "paren.lparen", "variable.parameter", "paren.rparen", "paren.rparen", "text", "storage.type"
|
||||
];
|
||||
this.testTokens(tokens, correct);
|
||||
|
||||
tokens = this.tokenizer.getLineTokens("foo = ({a1, a2}) ->", "start").tokens;
|
||||
this.testTokens(tokens, correct);
|
||||
|
||||
tokens = this.tokenizer.getLineTokens("foo = ({@a1, a2}) ->", "start").tokens;
|
||||
this.testTokens(tokens, correct);
|
||||
},
|
||||
|
||||
"test: tokenize function: 'foo : ({args}) ->'": function() {
|
||||
var tokens = this.tokenizer.getLineTokens("foo : ({args}) ->", "start").tokens;
|
||||
var correct = [
|
||||
"entity.name.function", "text", "punctuation.operator", "text",
|
||||
"paren.lparen", "paren.lparen", "variable.parameter", "paren.rparen", "paren.rparen", "text", "storage.type"
|
||||
];
|
||||
this.testTokens(tokens, correct);
|
||||
},
|
||||
|
||||
"test: tokenize function: invalid case: 'foo = ({args}) ->'": function() {
|
||||
var tokens = this.tokenizer.getLineTokens("foo = ({0abc}) ->", "start").tokens;
|
||||
assert.notEqual(tokens[0].type, "entity.name.function");
|
||||
|
||||
tokens = this.tokenizer.getLineTokens("foo = ({/abc}) ->", "start").tokens;
|
||||
assert.notEqual(tokens[0].type, "entity.name.function");
|
||||
|
||||
tokens = this.tokenizer.getLineTokens("foo = ({abc/}) ->", "start").tokens;
|
||||
assert.notEqual(tokens[0].type, "entity.name.function");
|
||||
|
||||
tokens = this.tokenizer.getLineTokens("foo = ({#abc}) ->", "start").tokens;
|
||||
assert.notEqual(tokens[0].type, "entity.name.function");
|
||||
|
||||
tokens = this.tokenizer.getLineTokens("foo = ({abc#}) ->", "start").tokens;
|
||||
assert.notEqual(tokens[0].type, "entity.name.function");
|
||||
|
||||
tokens = this.tokenizer.getLineTokens("foo = ({)abc}) ->", "start").tokens;
|
||||
assert.notEqual(tokens[0].type, "entity.name.function");
|
||||
|
||||
tokens = this.tokenizer.getLineTokens("foo = ({abc)}) ->", "start").tokens;
|
||||
assert.notEqual(tokens[0].type, "entity.name.function");
|
||||
|
||||
tokens = this.tokenizer.getLineTokens("foo = ({a{bc}) ->", "start").tokens;
|
||||
assert.notEqual(tokens[0].type, "entity.name.function");
|
||||
},
|
||||
|
||||
"test: tokenize function: 'foo = ({}) ->'": function() {
|
||||
var tokens = this.tokenizer.getLineTokens("foo = ({}) ->", "start").tokens;
|
||||
var correct = [
|
||||
"entity.name.function", "text", "keyword.operator", "text",
|
||||
"paren.lparen", "paren.lparen", "paren.rparen", "paren.rparen", "text", "storage.type"
|
||||
];
|
||||
this.testTokens(tokens, correct);
|
||||
|
||||
tokens = this.tokenizer.getLineTokens("foo = ({ }) ->", "start").tokens;
|
||||
correct = [
|
||||
"entity.name.function", "text", "keyword.operator", "text",
|
||||
"paren.lparen", "paren.lparen", "text", "paren.rparen", "paren.rparen", "text", "storage.type"
|
||||
];
|
||||
assert.equal(tokens.length, 11);
|
||||
this.testTokens(tokens, correct);
|
||||
},
|
||||
|
||||
"test: tokenize function: 'foo : ({}) ->'": function() {
|
||||
var tokens = this.tokenizer.getLineTokens("foo : ({}) ->", "start").tokens;
|
||||
var correct = [
|
||||
"entity.name.function", "text", "punctuation.operator", "text",
|
||||
"paren.lparen", "paren.lparen", "paren.rparen", "paren.rparen", "text", "storage.type"
|
||||
];
|
||||
this.testTokens(tokens, correct);
|
||||
},
|
||||
|
||||
"test: tokenize function: 'foo = (args) ->'": function() {
|
||||
var tokens = this.tokenizer.getLineTokens("foo = (args) ->", "start").tokens;
|
||||
var correct = [
|
||||
"entity.name.function", "text", "keyword.operator", "text",
|
||||
"paren.lparen", "variable.parameter", "paren.rparen", "text", "storage.type"
|
||||
];
|
||||
this.testTokens(tokens, correct);
|
||||
|
||||
tokens = this.tokenizer.getLineTokens("foo = (arg1, arg2) ->", "start").tokens;
|
||||
this.testTokens(tokens, correct);
|
||||
|
||||
tokens = this.tokenizer.getLineTokens("foo = (arg1 = 1, arg2 = 'name') ->", "start").tokens;
|
||||
this.testTokens(tokens, correct);
|
||||
|
||||
tokens = this.tokenizer.getLineTokens("foo = (@arg1 = /abc/, arg2 = 'name') ->", "start").tokens;
|
||||
this.testTokens(tokens, correct);
|
||||
},
|
||||
|
||||
"test: tokenize function: invalid case: 'foo=(args) ->'": function() {
|
||||
var tokens = this.tokenizer.getLineTokens("foo=(/args) ->", "start").tokens;
|
||||
assert.notEqual(tokens[0].type, "entity.name.function");
|
||||
},
|
||||
|
||||
"test: tokenize function: 'foo = () ->'": function() {
|
||||
var tokens = this.tokenizer.getLineTokens("foo = () ->", "start").tokens;
|
||||
var correct = [
|
||||
"entity.name.function", "text", "keyword.operator", "text",
|
||||
"paren.lparen", "paren.rparen", "text", "storage.type"
|
||||
];
|
||||
this.testTokens(tokens, correct);
|
||||
|
||||
tokens = this.tokenizer.getLineTokens("foo = ( ) ->", "start").tokens;
|
||||
correct = [
|
||||
"entity.name.function", "text", "keyword.operator", "text",
|
||||
"paren.lparen", "text", "paren.rparen", "text", "storage.type"
|
||||
];
|
||||
this.testTokens(tokens, correct);
|
||||
},
|
||||
|
||||
"test: tokenize function: 'foo : () ->'": function() {
|
||||
var tokens = this.tokenizer.getLineTokens("foo : () ->", "start").tokens;
|
||||
var correct = [
|
||||
"entity.name.function", "text", "punctuation.operator", "text",
|
||||
"paren.lparen", "paren.rparen", "text", "storage.type"
|
||||
];
|
||||
this.testTokens(tokens, correct);
|
||||
|
||||
tokens = this.tokenizer.getLineTokens("foo : ( ) ->", "start").tokens;
|
||||
var correct = [
|
||||
"entity.name.function", "text", "punctuation.operator", "text",
|
||||
"paren.lparen", "text", "paren.rparen", "text", "storage.type"
|
||||
];
|
||||
this.testTokens(tokens, correct);
|
||||
},
|
||||
|
||||
"test: tokenize function: 'window.foo = (args) ->'": function() {
|
||||
var tokens = this.tokenizer.getLineTokens("window.foo = (args) ->", "start").tokens;
|
||||
var correct = [
|
||||
"variable.language", "punctuation.operator", "entity.name.function", "text", "keyword.operator", "text",
|
||||
"paren.lparen", "variable.parameter", "paren.rparen", "text", "storage.type"
|
||||
];
|
||||
this.testTokens(tokens, correct);
|
||||
},
|
||||
|
||||
"test: tokenize function: 'foo = ->'": function() {
|
||||
var tokens = this.tokenizer.getLineTokens("foo = ->", "start").tokens;
|
||||
var correct = [
|
||||
"entity.name.function", "text", "keyword.operator", "text", "storage.type"
|
||||
];
|
||||
this.testTokens(tokens, correct);
|
||||
},
|
||||
|
||||
"test: tokenize function: 'foo : ->'": function() {
|
||||
var tokens = this.tokenizer.getLineTokens("foo : ->", "start").tokens;
|
||||
var correct = [
|
||||
"entity.name.function", "text", "punctuation.operator", "text", "storage.type"
|
||||
];
|
||||
this.testTokens(tokens, correct);
|
||||
},
|
||||
|
||||
"test: tokenize callback function: 'foo bar: 1, (args) ->'": function() {
|
||||
var tokens = this.tokenizer.getLineTokens("foo bar: 1, (args) ->", "start").tokens;
|
||||
var correct = [
|
||||
"identifier", "text", "identifier", "punctuation.operator", "text", "constant.numeric", "punctuation.operator", "text",
|
||||
"paren.lparen", "variable.parameter", "paren.rparen", "text", "storage.type"
|
||||
];
|
||||
this.testTokens(tokens, correct);
|
||||
},
|
||||
|
||||
"test: tokenize class: 'class Foo'": function() {
|
||||
var tokens = this.tokenizer.getLineTokens("class Foo", "start").tokens;
|
||||
var correct = [
|
||||
"keyword", "text", "language.support.class"
|
||||
];
|
||||
this.testTokens(tokens, correct);
|
||||
},
|
||||
|
||||
"test: tokenize class 'class Foo extends Bar'": function() {
|
||||
var tokens = this.tokenizer.getLineTokens("class Foo extends Bar", "start").tokens;
|
||||
var correct = [
|
||||
"keyword", "text", "language.support.class", "text", "keyword", "text", "language.support.class"
|
||||
];
|
||||
this.testTokens(tokens, correct);
|
||||
},
|
||||
|
||||
"test: tokenize illegal name property: 'foo.static.function'": function() {
|
||||
var tokens = this.tokenizer.getLineTokens("foo.static.function", "start").tokens;
|
||||
var correct = [
|
||||
"identifier", "punctuation.operator", "identifier", "punctuation.operator", "identifier"
|
||||
];
|
||||
this.testTokens(tokens, correct);
|
||||
},
|
||||
|
||||
// TODO: disable. not yet implemented
|
||||
"!test tokenize string with interpolation": function() {
|
||||
var tokens = this.tokenizer.getLineTokens('"#{ 22 / 7 } is a decent approximation of π"', "start").tokens;
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ var ColdfusionHighlightRules = function() {
|
|||
regex : "<\\!\\[CDATA\\[",
|
||||
next : "cdata"
|
||||
}, {
|
||||
token : "xml_pe",
|
||||
token : "xml-pe",
|
||||
regex : "<\\?.*?\\?>"
|
||||
}, {
|
||||
token : "comment",
|
||||
|
|
@ -58,11 +58,11 @@ var ColdfusionHighlightRules = function() {
|
|||
next : "comment"
|
||||
}, {
|
||||
token : "meta.tag",
|
||||
regex : "<(?=\s*script)",
|
||||
regex : "<(?=script)",
|
||||
next : "script"
|
||||
}, {
|
||||
token : "meta.tag",
|
||||
regex : "<(?=\s*style)",
|
||||
regex : "<(?=style)",
|
||||
next : "style"
|
||||
}, {
|
||||
token : "meta.tag", // opening tag
|
||||
|
|
|
|||
|
|
@ -74,25 +74,19 @@ oop.inherits(Mode, TextMode);
|
|||
this.autoOutdent = function(state, doc, row) {
|
||||
this.$outdent.autoOutdent(doc, row);
|
||||
};
|
||||
|
||||
|
||||
this.createWorker = function(session) {
|
||||
var worker = new WorkerClient(["ace"], "ace/mode/css_worker", "Worker");
|
||||
worker.attachToDocument(session.getDocument());
|
||||
|
||||
|
||||
worker.on("csslint", function(e) {
|
||||
var errors = [];
|
||||
e.data.forEach(function(message) {
|
||||
errors.push({
|
||||
row: message.line - 1,
|
||||
column: message.col - 1,
|
||||
text: message.message,
|
||||
type: message.type,
|
||||
lint: message
|
||||
});
|
||||
});
|
||||
|
||||
session.setAnnotations(errors);
|
||||
session.setAnnotations(e.data);
|
||||
});
|
||||
|
||||
worker.on("terminate", function() {
|
||||
session.clearAnnotations();
|
||||
});
|
||||
|
||||
return worker;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|||
THE SOFTWARE.
|
||||
|
||||
*/
|
||||
/* Build time: 2-March-2012 02:47:11 */
|
||||
/* Build time: 14-May-2012 10:24:48 */
|
||||
|
||||
/*!
|
||||
Parser-Lib
|
||||
|
|
@ -47,7 +47,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|||
THE SOFTWARE.
|
||||
|
||||
*/
|
||||
/* Version v0.1.6, Build time: 2-March-2012 02:44:32 */
|
||||
/* Version v0.1.7, Build time: 4-May-2012 03:57:04 */
|
||||
var parserlib = {};
|
||||
(function(){
|
||||
|
||||
|
|
@ -957,7 +957,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|||
THE SOFTWARE.
|
||||
|
||||
*/
|
||||
/* Version v0.1.6, Build time: 2-March-2012 02:44:32 */
|
||||
/* Version v0.1.7, Build time: 4-May-2012 03:57:04 */
|
||||
(function(){
|
||||
var EventTarget = parserlib.util.EventTarget,
|
||||
TokenStreamBase = parserlib.util.TokenStreamBase,
|
||||
|
|
@ -2171,7 +2171,7 @@ Parser.prototype = function(){
|
|||
|
||||
//there must be a next selector
|
||||
if (nextSelector === null){
|
||||
this._unexpectedToken(this.LT(1));
|
||||
this._unexpectedToken(tokenStream.LT(1));
|
||||
} else {
|
||||
|
||||
//nextSelector is an instance of SelectorPart
|
||||
|
|
@ -2666,7 +2666,8 @@ Parser.prototype = function(){
|
|||
expr = null,
|
||||
prio = null,
|
||||
error = null,
|
||||
invalid = null;
|
||||
invalid = null,
|
||||
propertyName= "";
|
||||
|
||||
property = this._property();
|
||||
if (property !== null){
|
||||
|
|
@ -2683,8 +2684,20 @@ Parser.prototype = function(){
|
|||
|
||||
prio = this._prio();
|
||||
|
||||
/*
|
||||
* If hacks should be allowed, then only check the root
|
||||
* property. If hacks should not be allowed, treat
|
||||
* _property or *property as invalid properties.
|
||||
*/
|
||||
propertyName = property.toString();
|
||||
if (this.options.starHack && property.hack == "*" ||
|
||||
this.options.underscoreHack && property.hack == "_") {
|
||||
|
||||
propertyName = property.text;
|
||||
}
|
||||
|
||||
try {
|
||||
this._validateProperty(property, expr);
|
||||
this._validateProperty(propertyName, expr);
|
||||
} catch (ex) {
|
||||
invalid = ex;
|
||||
}
|
||||
|
|
@ -3525,6 +3538,7 @@ var Properties = {
|
|||
"background-repeat" : { multi: "<repeat-style>" },
|
||||
"background-size" : { multi: "<bg-size>", comma: true },
|
||||
"baseline-shift" : "baseline | sub | super | <percentage> | <length>",
|
||||
"behavior" : 1,
|
||||
"binding" : 1,
|
||||
"bleed" : "<length>",
|
||||
"bookmark-label" : "<content> | <attr> | <string>",
|
||||
|
|
@ -3871,6 +3885,7 @@ var Properties = {
|
|||
"text-justify" : "auto | none | inter-word | inter-ideograph | inter-cluster | distribute | kashida",
|
||||
"text-outline" : 1,
|
||||
"text-overflow" : 1,
|
||||
"text-rendering" : "auto | optimizeSpeed | optimizeLegibility | geometricPrecision | inherit",
|
||||
"text-shadow" : 1,
|
||||
"text-transform" : "capitalize | uppercase | lowercase | none | inherit",
|
||||
"text-wrap" : "normal | none | avoid",
|
||||
|
|
@ -5950,7 +5965,7 @@ var ValidationTypes = {
|
|||
i, len, found = false;
|
||||
|
||||
for (i=0,len=args.length; i < len && !found; i++){
|
||||
if (text == args[i]){
|
||||
if (text == args[i].toLowerCase()){
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
|
|
@ -6042,7 +6057,7 @@ var ValidationTypes = {
|
|||
},
|
||||
|
||||
"<gradient>": function(part) {
|
||||
return part.type == "function" && /^(?:\-(?:ms|moz|o|webkit)\-)?(?:repeating\-)?(?:radial|linear)\-gradient/i.test(part);
|
||||
return part.type == "function" && /^(?:\-(?:ms|moz|o|webkit)\-)?(?:repeating\-)?(?:radial\-|linear\-)?gradient/i.test(part);
|
||||
},
|
||||
|
||||
"<box>": function(part){
|
||||
|
|
@ -6134,6 +6149,18 @@ var ValidationTypes = {
|
|||
part,
|
||||
i, len;
|
||||
|
||||
/*
|
||||
<position> = [
|
||||
[ left | center | right | top | bottom | <percentage> | <length> ]
|
||||
|
|
||||
[ left | center | right | <percentage> | <length> ]
|
||||
[ top | center | bottom | <percentage> | <length> ]
|
||||
|
|
||||
[ center | [ left | right ] [ <percentage> | <length> ]? ] &&
|
||||
[ center | [ top | bottom ] [ <percentage> | <length> ]? ]
|
||||
]
|
||||
|
||||
*/
|
||||
|
||||
if (ValidationTypes.isAny(expression, "top | bottom")) {
|
||||
result = true;
|
||||
|
|
@ -6306,7 +6333,7 @@ var CSSLint = (function(){
|
|||
formatters = [],
|
||||
api = new parserlib.util.EventTarget();
|
||||
|
||||
api.version = "0.9.7";
|
||||
api.version = "0.9.8";
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Rule Management
|
||||
|
|
@ -7633,7 +7660,7 @@ CSSLint.addRule({
|
|||
parser.addListener("endstylesheet", function(){
|
||||
reporter.stat("important", count);
|
||||
if (count >= 10){
|
||||
reporter.rollupWarn("Too many !important declarations (" + count + "), try to use less than 10 to avoid specifity issues.", rule);
|
||||
reporter.rollupWarn("Too many !important declarations (" + count + "), try to use less than 10 to avoid specificity issues.", rule);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
@ -8290,8 +8317,35 @@ CSSLint.addRule({
|
|||
|
||||
});
|
||||
/*
|
||||
* Rule: Don't use text-indent for image replacement if you need to support rtl.
|
||||
*
|
||||
* Rule: Don't use properties with a star prefix.
|
||||
*
|
||||
*/
|
||||
/*global CSSLint*/
|
||||
CSSLint.addRule({
|
||||
|
||||
//rule information
|
||||
id: "star-property-hack",
|
||||
name: "Disallow properties with a star prefix",
|
||||
desc: "Checks for the star property hack (targets IE6/7)",
|
||||
browsers: "All",
|
||||
|
||||
//initialization
|
||||
init: function(parser, reporter){
|
||||
var rule = this;
|
||||
|
||||
//check if property name starts with "*"
|
||||
parser.addListener("property", function(event){
|
||||
var property = event.property;
|
||||
|
||||
if (property.hack == "*") {
|
||||
reporter.report("Property with star prefix found.", event.property.line, event.property.col, rule);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
/*
|
||||
* Rule: Don't use text-indent for image replacement if you need to support rtl.
|
||||
*
|
||||
*/
|
||||
/*global CSSLint*/
|
||||
CSSLint.addRule({
|
||||
|
|
@ -8301,27 +8355,29 @@ CSSLint.addRule({
|
|||
name: "Disallow negative text-indent",
|
||||
desc: "Checks for text indent less than -99px",
|
||||
browsers: "All",
|
||||
|
||||
|
||||
//initialization
|
||||
init: function(parser, reporter){
|
||||
var rule = this,
|
||||
textIndent = false;
|
||||
|
||||
|
||||
textIndent,
|
||||
direction;
|
||||
|
||||
|
||||
function startRule(event){
|
||||
textIndent = false;
|
||||
direction = "inherit";
|
||||
}
|
||||
|
||||
|
||||
//event handler for end of rules
|
||||
function endRule(event){
|
||||
if (textIndent){
|
||||
if (textIndent && direction != "ltr"){
|
||||
reporter.report("Negative text-indent doesn't work well with RTL. If you use text-indent for image replacement explicitly set direction for that item to ltr.", textIndent.line, textIndent.col, rule);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
parser.addListener("startrule", startRule);
|
||||
parser.addListener("startfontface", startRule);
|
||||
|
||||
|
||||
//check for use of "font-size"
|
||||
parser.addListener("property", function(event){
|
||||
var name = event.property.toString().toLowerCase(),
|
||||
|
|
@ -8330,16 +8386,43 @@ CSSLint.addRule({
|
|||
if (name == "text-indent" && value.parts[0].value < -99){
|
||||
textIndent = event.property;
|
||||
} else if (name == "direction" && value == "ltr"){
|
||||
textIndent = false;
|
||||
direction = "ltr";
|
||||
}
|
||||
});
|
||||
|
||||
parser.addListener("endrule", endRule);
|
||||
parser.addListener("endfontface", endRule);
|
||||
parser.addListener("endfontface", endRule);
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
/*
|
||||
* Rule: Don't use properties with a underscore prefix.
|
||||
*
|
||||
*/
|
||||
/*global CSSLint*/
|
||||
CSSLint.addRule({
|
||||
|
||||
//rule information
|
||||
id: "underscore-property-hack",
|
||||
name: "Disallow properties with an underscore prefix",
|
||||
desc: "Checks for the underscore property hack (targets IE6)",
|
||||
browsers: "All",
|
||||
|
||||
//initialization
|
||||
init: function(parser, reporter){
|
||||
var rule = this;
|
||||
|
||||
//check if property name starts with "_"
|
||||
parser.addListener("property", function(event){
|
||||
var property = event.property;
|
||||
|
||||
if (property.hack == "_") {
|
||||
reporter.report("Property with underscore prefix found.", event.property.line, event.property.col, rule);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
/*
|
||||
* Rule: Headings (h1-h6) should be defined only once.
|
||||
*/
|
||||
|
|
@ -8669,343 +8752,6 @@ CSSLint.addRule({
|
|||
|
||||
});
|
||||
/*global CSSLint*/
|
||||
CSSLint.addFormatter({
|
||||
//format information
|
||||
id: "checkstyle-xml",
|
||||
name: "Checkstyle XML format",
|
||||
|
||||
/**
|
||||
* Return opening root XML tag.
|
||||
* @return {String} to prepend before all results
|
||||
*/
|
||||
startFormat: function(){
|
||||
return "<?xml version=\"1.0\" encoding=\"utf-8\"?><checkstyle>";
|
||||
},
|
||||
|
||||
/**
|
||||
* Return closing root XML tag.
|
||||
* @return {String} to append after all results
|
||||
*/
|
||||
endFormat: function(){
|
||||
return "</checkstyle>";
|
||||
},
|
||||
|
||||
/**
|
||||
* Given CSS Lint results for a file, return output for this format.
|
||||
* @param results {Object} with error and warning messages
|
||||
* @param filename {String} relative file path
|
||||
* @param options {Object} (UNUSED for now) specifies special handling of output
|
||||
* @return {String} output for results
|
||||
*/
|
||||
formatResults: function(results, filename, options) {
|
||||
var messages = results.messages,
|
||||
output = [];
|
||||
|
||||
/**
|
||||
* Generate a source string for a rule.
|
||||
* Checkstyle source strings usually resemble Java class names e.g
|
||||
* net.csslint.SomeRuleName
|
||||
* @param {Object} rule
|
||||
* @return rule source as {String}
|
||||
*/
|
||||
var generateSource = function(rule) {
|
||||
if (!rule || !('name' in rule)) {
|
||||
return "";
|
||||
}
|
||||
return 'net.csslint.' + rule.name.replace(/\s/g,'');
|
||||
};
|
||||
|
||||
/**
|
||||
* Replace special characters before write to output.
|
||||
*
|
||||
* Rules:
|
||||
* - single quotes is the escape sequence for double-quotes
|
||||
* - < is the escape sequence for <
|
||||
* - > is the escape sequence for >
|
||||
*
|
||||
* @param {String} message to escape
|
||||
* @return escaped message as {String}
|
||||
*/
|
||||
var escapeSpecialCharacters = function(str) {
|
||||
if (!str || str.constructor !== String) {
|
||||
return "";
|
||||
}
|
||||
return str.replace(/\"/g, "'").replace(/</g, "<").replace(/>/g, ">");
|
||||
};
|
||||
|
||||
if (messages.length > 0) {
|
||||
output.push("<file name=\""+filename+"\">");
|
||||
CSSLint.Util.forEach(messages, function (message, i) {
|
||||
//ignore rollups for now
|
||||
if (!message.rollup) {
|
||||
output.push("<error line=\"" + message.line + "\" column=\"" + message.col + "\" severity=\"" + message.type + "\"" +
|
||||
" message=\"" + escapeSpecialCharacters(message.message) + "\" source=\"" + generateSource(message.rule) +"\"/>");
|
||||
}
|
||||
});
|
||||
output.push("</file>");
|
||||
}
|
||||
|
||||
return output.join("");
|
||||
}
|
||||
});
|
||||
/*global CSSLint*/
|
||||
CSSLint.addFormatter({
|
||||
//format information
|
||||
id: "compact",
|
||||
name: "Compact, 'porcelain' format",
|
||||
|
||||
/**
|
||||
* Return content to be printed before all file results.
|
||||
* @return {String} to prepend before all results
|
||||
*/
|
||||
startFormat: function() {
|
||||
return "";
|
||||
},
|
||||
|
||||
/**
|
||||
* Return content to be printed after all file results.
|
||||
* @return {String} to append after all results
|
||||
*/
|
||||
endFormat: function() {
|
||||
return "";
|
||||
},
|
||||
|
||||
/**
|
||||
* Given CSS Lint results for a file, return output for this format.
|
||||
* @param results {Object} with error and warning messages
|
||||
* @param filename {String} relative file path
|
||||
* @param options {Object} (Optional) specifies special handling of output
|
||||
* @return {String} output for results
|
||||
*/
|
||||
formatResults: function(results, filename, options) {
|
||||
var messages = results.messages,
|
||||
output = "";
|
||||
options = options || {};
|
||||
|
||||
/**
|
||||
* Capitalize and return given string.
|
||||
* @param str {String} to capitalize
|
||||
* @return {String} capitalized
|
||||
*/
|
||||
var capitalize = function(str) {
|
||||
return str.charAt(0).toUpperCase() + str.slice(1);
|
||||
};
|
||||
|
||||
if (messages.length === 0) {
|
||||
return options.quiet ? "" : filename + ": Lint Free!";
|
||||
}
|
||||
|
||||
CSSLint.Util.forEach(messages, function(message, i) {
|
||||
if (message.rollup) {
|
||||
output += filename + ": " + capitalize(message.type) + " - " + message.message + "\n";
|
||||
} else {
|
||||
output += filename + ": " + "line " + message.line +
|
||||
", col " + message.col + ", " + capitalize(message.type) + " - " + message.message + "\n";
|
||||
}
|
||||
});
|
||||
|
||||
return output;
|
||||
}
|
||||
});
|
||||
/*global CSSLint*/
|
||||
CSSLint.addFormatter({
|
||||
//format information
|
||||
id: "csslint-xml",
|
||||
name: "CSSLint XML format",
|
||||
|
||||
/**
|
||||
* Return opening root XML tag.
|
||||
* @return {String} to prepend before all results
|
||||
*/
|
||||
startFormat: function(){
|
||||
return "<?xml version=\"1.0\" encoding=\"utf-8\"?><csslint>";
|
||||
},
|
||||
|
||||
/**
|
||||
* Return closing root XML tag.
|
||||
* @return {String} to append after all results
|
||||
*/
|
||||
endFormat: function(){
|
||||
return "</csslint>";
|
||||
},
|
||||
|
||||
/**
|
||||
* Given CSS Lint results for a file, return output for this format.
|
||||
* @param results {Object} with error and warning messages
|
||||
* @param filename {String} relative file path
|
||||
* @param options {Object} (UNUSED for now) specifies special handling of output
|
||||
* @return {String} output for results
|
||||
*/
|
||||
formatResults: function(results, filename, options) {
|
||||
var messages = results.messages,
|
||||
output = [];
|
||||
|
||||
/**
|
||||
* Replace special characters before write to output.
|
||||
*
|
||||
* Rules:
|
||||
* - single quotes is the escape sequence for double-quotes
|
||||
* - < is the escape sequence for <
|
||||
* - > is the escape sequence for >
|
||||
*
|
||||
* @param {String} message to escape
|
||||
* @return escaped message as {String}
|
||||
*/
|
||||
var escapeSpecialCharacters = function(str) {
|
||||
if (!str || str.constructor !== String) {
|
||||
return "";
|
||||
}
|
||||
return str.replace(/\"/g, "'").replace(/</g, "<").replace(/>/g, ">");
|
||||
};
|
||||
|
||||
if (messages.length > 0) {
|
||||
output.push("<file name=\""+filename+"\">");
|
||||
CSSLint.Util.forEach(messages, function (message, i) {
|
||||
if (message.rollup) {
|
||||
output.push("<issue severity=\"" + message.type + "\" reason=\"" + escapeSpecialCharacters(message.message) + "\" evidence=\"" + escapeSpecialCharacters(message.evidence) + "\"/>");
|
||||
} else {
|
||||
output.push("<issue line=\"" + message.line + "\" char=\"" + message.col + "\" severity=\"" + message.type + "\"" +
|
||||
" reason=\"" + escapeSpecialCharacters(message.message) + "\" evidence=\"" + escapeSpecialCharacters(message.evidence) + "\"/>");
|
||||
}
|
||||
});
|
||||
output.push("</file>");
|
||||
}
|
||||
|
||||
return output.join("");
|
||||
}
|
||||
});
|
||||
/*global CSSLint*/
|
||||
CSSLint.addFormatter({
|
||||
//format information
|
||||
id: "lint-xml",
|
||||
name: "Lint XML format",
|
||||
|
||||
/**
|
||||
* Return opening root XML tag.
|
||||
* @return {String} to prepend before all results
|
||||
*/
|
||||
startFormat: function(){
|
||||
return "<?xml version=\"1.0\" encoding=\"utf-8\"?><lint>";
|
||||
},
|
||||
|
||||
/**
|
||||
* Return closing root XML tag.
|
||||
* @return {String} to append after all results
|
||||
*/
|
||||
endFormat: function(){
|
||||
return "</lint>";
|
||||
},
|
||||
|
||||
/**
|
||||
* Given CSS Lint results for a file, return output for this format.
|
||||
* @param results {Object} with error and warning messages
|
||||
* @param filename {String} relative file path
|
||||
* @param options {Object} (UNUSED for now) specifies special handling of output
|
||||
* @return {String} output for results
|
||||
*/
|
||||
formatResults: function(results, filename, options) {
|
||||
var messages = results.messages,
|
||||
output = [];
|
||||
|
||||
/**
|
||||
* Replace special characters before write to output.
|
||||
*
|
||||
* Rules:
|
||||
* - single quotes is the escape sequence for double-quotes
|
||||
* - < is the escape sequence for <
|
||||
* - > is the escape sequence for >
|
||||
*
|
||||
* @param {String} message to escape
|
||||
* @return escaped message as {String}
|
||||
*/
|
||||
var escapeSpecialCharacters = function(str) {
|
||||
if (!str || str.constructor !== String) {
|
||||
return "";
|
||||
}
|
||||
return str.replace(/\"/g, "'").replace(/</g, "<").replace(/>/g, ">");
|
||||
};
|
||||
|
||||
if (messages.length > 0) {
|
||||
|
||||
output.push("<file name=\""+filename+"\">");
|
||||
CSSLint.Util.forEach(messages, function (message, i) {
|
||||
if (message.rollup) {
|
||||
output.push("<issue severity=\"" + message.type + "\" reason=\"" + escapeSpecialCharacters(message.message) + "\" evidence=\"" + escapeSpecialCharacters(message.evidence) + "\"/>");
|
||||
} else {
|
||||
output.push("<issue line=\"" + message.line + "\" char=\"" + message.col + "\" severity=\"" + message.type + "\"" +
|
||||
" reason=\"" + escapeSpecialCharacters(message.message) + "\" evidence=\"" + escapeSpecialCharacters(message.evidence) + "\"/>");
|
||||
}
|
||||
});
|
||||
output.push("</file>");
|
||||
}
|
||||
|
||||
return output.join("");
|
||||
}
|
||||
});
|
||||
/*global CSSLint*/
|
||||
CSSLint.addFormatter({
|
||||
//format information
|
||||
id: "text",
|
||||
name: "Plain Text",
|
||||
|
||||
/**
|
||||
* Return content to be printed before all file results.
|
||||
* @return {String} to prepend before all results
|
||||
*/
|
||||
startFormat: function() {
|
||||
return "";
|
||||
},
|
||||
|
||||
/**
|
||||
* Return content to be printed after all file results.
|
||||
* @return {String} to append after all results
|
||||
*/
|
||||
endFormat: function() {
|
||||
return "";
|
||||
},
|
||||
|
||||
/**
|
||||
* Given CSS Lint results for a file, return output for this format.
|
||||
* @param results {Object} with error and warning messages
|
||||
* @param filename {String} relative file path
|
||||
* @param options {Object} (Optional) specifies special handling of output
|
||||
* @return {String} output for results
|
||||
*/
|
||||
formatResults: function(results, filename, options) {
|
||||
var messages = results.messages,
|
||||
output = "";
|
||||
options = options || {};
|
||||
|
||||
if (messages.length === 0) {
|
||||
return options.quiet ? "" : "\n\ncsslint: No errors in " + filename + ".";
|
||||
}
|
||||
|
||||
output = "\n\ncsslint: There are " + messages.length + " problems in " + filename + ".";
|
||||
var pos = filename.lastIndexOf("/"),
|
||||
shortFilename = filename;
|
||||
|
||||
if (pos === -1){
|
||||
pos = filename.lastIndexOf("\\");
|
||||
}
|
||||
if (pos > -1){
|
||||
shortFilename = filename.substring(pos+1);
|
||||
}
|
||||
|
||||
CSSLint.Util.forEach(messages, function (message, i) {
|
||||
output = output + "\n\n" + shortFilename;
|
||||
if (message.rollup) {
|
||||
output += "\n" + (i+1) + ": " + message.type;
|
||||
output += "\n" + message.message;
|
||||
} else {
|
||||
output += "\n" + (i+1) + ": " + message.type + " at line " + message.line + ", col " + message.col;
|
||||
output += "\n" + message.message;
|
||||
output += "\n" + message.evidence;
|
||||
}
|
||||
});
|
||||
|
||||
return output;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
exports.CSSLint = CSSLint;
|
||||
|
|
|
|||
|
|
@ -27,33 +27,68 @@
|
|||
* 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 lang = require("../lib/lang");
|
||||
var Mirror = require("../worker/mirror").Mirror;
|
||||
var CSSLint = require("./css/csslint").CSSLint;
|
||||
|
||||
var Worker = exports.Worker = function(sender) {
|
||||
Mirror.call(this, sender);
|
||||
this.setTimeout(200);
|
||||
this.setTimeout(400);
|
||||
this.ruleset = null;
|
||||
this.setDisabledRules("");
|
||||
this.setInfoRules("adjoining-classes|qualified-headings|zero-units|gradients|import|outline-none");
|
||||
};
|
||||
|
||||
oop.inherits(Worker, Mirror);
|
||||
|
||||
(function() {
|
||||
|
||||
this.setInfoRules = function(ruleNames) {
|
||||
if (typeof ruleNames == "string")
|
||||
ruleNames = ruleNames.split("|");
|
||||
this.infoRules = lang.arrayToMap(ruleNames);
|
||||
this.doc.getValue() && this.deferredUpdate.schedule(100);
|
||||
};
|
||||
|
||||
this.setDisabledRules = function(ruleNames) {
|
||||
if (!ruleNames) {
|
||||
this.ruleset = null;
|
||||
} else {
|
||||
if (typeof ruleNames == "string")
|
||||
ruleNames = ruleNames.split("|");
|
||||
var all = {};
|
||||
|
||||
CSSLint.getRules().forEach(function(x){
|
||||
all[x.id] = true;
|
||||
});
|
||||
ruleNames.forEach(function(x) {
|
||||
delete all[x];
|
||||
});
|
||||
console.log(all)
|
||||
this.ruleset = all;
|
||||
}
|
||||
this.doc.getValue() && this.deferredUpdate.schedule(100);
|
||||
};
|
||||
|
||||
this.onUpdate = function() {
|
||||
var value = this.doc.getValue();
|
||||
|
||||
var result = CSSLint.verify(value);
|
||||
var infoRules = this.infoRules;
|
||||
|
||||
var result = CSSLint.verify(value, this.ruleset);
|
||||
this.sender.emit("csslint", result.messages.map(function(msg) {
|
||||
delete msg.rule;
|
||||
return msg;
|
||||
return {
|
||||
row: msg.line - 1,
|
||||
column: msg.col - 1,
|
||||
text: msg.message,
|
||||
type: infoRules[msg.rule.id] ? "info" : msg.type
|
||||
}
|
||||
}));
|
||||
};
|
||||
|
||||
|
||||
}).call(Worker.prototype);
|
||||
|
||||
});
|
||||
|
|
|
|||
|
|
@ -74,14 +74,14 @@ var DiffHighlightRules = function() {
|
|||
"support.constant",
|
||||
"text",
|
||||
"invalid"
|
||||
],
|
||||
]
|
||||
}, { // removed
|
||||
"regex": "^([<\\-])(.*?)(\\s*)$",
|
||||
"token": [
|
||||
"support.function",
|
||||
"string",
|
||||
"invalid"
|
||||
],
|
||||
]
|
||||
}, {
|
||||
"regex": "^(diff)(\\s+--\\w+)?(.+?)( .+)?$",
|
||||
"token": ["variable", "variable", "keyword", "variable"]
|
||||
|
|
|
|||
142
lib/ace/mode/folding/asciidoc.js
Normal file
|
|
@ -0,0 +1,142 @@
|
|||
/* ***** 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 oop = require("../../lib/oop");
|
||||
var BaseFoldMode = require("./fold_mode").FoldMode;
|
||||
var Range = require("../../range").Range;
|
||||
|
||||
var FoldMode = exports.FoldMode = function() {};
|
||||
oop.inherits(FoldMode, BaseFoldMode);
|
||||
|
||||
(function() {
|
||||
this.foldingStartMarker = /^(?:\|={10,}|[\.\/=\-~^+]{4,}|={1,5} )/;
|
||||
this.singleLineHeadingRe = /^={1,5}(?=\s+\S)/;
|
||||
|
||||
this.getFoldWidget = function(session, foldStyle, row) {
|
||||
var line = session.getLine(row);
|
||||
if (!this.foldingStartMarker.test(line))
|
||||
return ""
|
||||
|
||||
if (line[0] == "=") {
|
||||
if (this.singleLineHeadingRe.test(line))
|
||||
return "start";
|
||||
if (session.getLine(row - 1).length != session.getLine(row).length)
|
||||
return "";
|
||||
return "start";
|
||||
}
|
||||
if (session.bgTokenizer.getState(row) == "dissallowDelimitedBlock")
|
||||
return "end";
|
||||
return "start";
|
||||
};
|
||||
|
||||
this.getFoldWidgetRange = function(session, foldStyle, row) {
|
||||
var line = session.getLine(row);
|
||||
var startColumn = line.length;
|
||||
var maxRow = session.getLength();
|
||||
var startRow = row;
|
||||
var endRow = row;
|
||||
if (!line.match(this.foldingStartMarker))
|
||||
return;
|
||||
|
||||
var token;
|
||||
function getTokenType(row) {
|
||||
token = session.getTokens(row)[0];
|
||||
return token && token.type;
|
||||
}
|
||||
|
||||
var levels = ["=","-","~","^","+"];
|
||||
var heading = "markup.heading";
|
||||
var singleLineHeadingRe = this.singleLineHeadingRe;
|
||||
function getLevel() {
|
||||
var match = token.value.match(singleLineHeadingRe);
|
||||
if (match)
|
||||
return match[0].length;
|
||||
var level = levels.indexOf(token.value[0]) + 1;
|
||||
if (level == 1) {
|
||||
if (session.getLine(row - 1).length != session.getLine(row).length)
|
||||
return Infinity;
|
||||
}
|
||||
return level;
|
||||
}
|
||||
|
||||
if (getTokenType(row) == heading) {
|
||||
var startHeadingLevel = getLevel();
|
||||
while (++row < maxRow) {
|
||||
if (getTokenType(row) != heading)
|
||||
continue;
|
||||
var level = getLevel();
|
||||
if (level <= startHeadingLevel)
|
||||
break;
|
||||
}
|
||||
|
||||
var isSingleLineHeading = token && token.value.match(this.singleLineHeadingRe);
|
||||
endRow = isSingleLineHeading ? row - 1 : row - 2;
|
||||
|
||||
if (endRow > startRow) {
|
||||
while (endRow > startRow && (!getTokenType(endRow) || token.value[0] == "["))
|
||||
endRow--;
|
||||
}
|
||||
|
||||
if (endRow > startRow) {
|
||||
var endColumn = session.getLine(endRow).length;
|
||||
return new Range(startRow, startColumn, endRow, endColumn);
|
||||
}
|
||||
} else {
|
||||
var state = session.bgTokenizer.getState(row);
|
||||
if (state == "dissallowDelimitedBlock") {
|
||||
while (row -- > 0) {
|
||||
if (session.bgTokenizer.getState(row).lastIndexOf("Block") == -1)
|
||||
break;
|
||||
}
|
||||
endRow = row + 1;
|
||||
if (endRow < startRow) {
|
||||
var endColumn = session.getLine(row).length;
|
||||
return new Range(endRow, 5, startRow, startColumn - 5);
|
||||
}
|
||||
} else {
|
||||
while (++row < maxRow) {
|
||||
if (session.bgTokenizer.getState(row) == "dissallowDelimitedBlock")
|
||||
break;
|
||||
}
|
||||
endRow = row;
|
||||
if (endRow > startRow) {
|
||||
var endColumn = session.getLine(row).length;
|
||||
return new Range(startRow, 5, endRow, endColumn - 5);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
}).call(FoldMode.prototype);
|
||||
|
||||
});
|
||||
|
|
@ -47,7 +47,7 @@ module.exports = {
|
|||
']',
|
||||
'[ ',
|
||||
'{ ',
|
||||
'[ #-',
|
||||
'[ #-'
|
||||
]);
|
||||
|
||||
var mode = new PythonMode();
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ var HtmlHighlightRules = function() {
|
|||
regex : "<\\!\\[CDATA\\[",
|
||||
next : "cdata"
|
||||
}, {
|
||||
token : "xml_pe",
|
||||
token : "xml-pe",
|
||||
regex : "<\\?.*?\\?>"
|
||||
}, {
|
||||
token : "comment",
|
||||
|
|
@ -76,15 +76,15 @@ var HtmlHighlightRules = function() {
|
|||
regex : "<\\!--",
|
||||
next : "comment"
|
||||
}, {
|
||||
token : "xml_pe",
|
||||
token : "xml-pe",
|
||||
regex : "<\\!.*?>"
|
||||
}, {
|
||||
token : "meta.tag",
|
||||
regex : "<(?=\s*script\\b)",
|
||||
regex : "<(?=script\\b)",
|
||||
next : "script"
|
||||
}, {
|
||||
token : "meta.tag",
|
||||
regex : "<(?=\s*style\\b)",
|
||||
regex : "<(?=style\\b)",
|
||||
next : "style"
|
||||
}, {
|
||||
token : "meta.tag", // opening tag
|
||||
|
|
|
|||
|
|
@ -40,8 +40,8 @@ var oop = require("../lib/oop");
|
|||
var TextMode = require("./text").Mode;
|
||||
var Tokenizer = require("../tokenizer").Tokenizer;
|
||||
var JadeHighlightRules = require("./jade_highlight_rules").JadeHighlightRules;
|
||||
// var JavascriptMode = require("ace/mode/javascript").Mode;
|
||||
// var CssMode = require("ace/mode/css").Mode;
|
||||
// var JavascriptMode = require("../mode/javascript").Mode;
|
||||
// var CssMode = require("../mode/css").Mode;
|
||||
|
||||
var Mode = function() {
|
||||
var highlighter = new JadeHighlightRules();
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ var JadeHighlightRules = function() {
|
|||
},
|
||||
{
|
||||
"token" : "punctuation.section.comment",
|
||||
"regex" : "^\\s*\/\/(?:\\s*[^-\\s]|\\s+\\S)(?:.*$)",
|
||||
"regex" : "^\\s*\/\/(?:\\s*[^-\\s]|\\s+\\S)(?:.*$)"
|
||||
},
|
||||
{
|
||||
"token" : function(space, text) {
|
||||
|
|
@ -120,11 +120,11 @@ var JadeHighlightRules = function() {
|
|||
"token": [ "storage.type.function.jade", "entity.name.function.jade"],
|
||||
"regex": "^(\\s*mixin)( [\\w\\-]+)"
|
||||
},
|
||||
/* {
|
||||
{
|
||||
"token": "source.js.embedded.jade",
|
||||
"regex": "^\\s*-|=|!=",
|
||||
"next": "js_code"
|
||||
},*/
|
||||
"regex": "^\\s*(?:-|=|!=)",
|
||||
"next": "js-start"
|
||||
},
|
||||
/*{
|
||||
"token": "entity.name.tag.script.jade",
|
||||
"regex": "^\\s*script",
|
||||
|
|
@ -219,7 +219,21 @@ var JadeHighlightRules = function() {
|
|||
"next": "start"
|
||||
}
|
||||
],
|
||||
"tag_attributes": [
|
||||
"tag_attributes": [
|
||||
{
|
||||
"token" : "string",
|
||||
"regex" : "'(?=.)",
|
||||
"next" : "qstring"
|
||||
},
|
||||
{
|
||||
"token" : "string",
|
||||
"regex" : '"(?=.)',
|
||||
"next" : "qqstring"
|
||||
},
|
||||
{
|
||||
"token": "entity.other.attribute-name.jade",
|
||||
"regex": "\\b[a-zA-Z\\-:]+"
|
||||
},
|
||||
{
|
||||
"token": ["entity.other.attribute-name.jade", "punctuation"],
|
||||
"regex": "\\b([a-zA-Z:\\.-]+)(=)",
|
||||
|
|
@ -284,6 +298,12 @@ var JadeHighlightRules = function() {
|
|||
}
|
||||
]
|
||||
};
|
||||
|
||||
this.embedRules(JavaScriptHighlightRules, "js-", [{
|
||||
token: "text",
|
||||
regex: ".$",
|
||||
next: "start"
|
||||
}]);
|
||||
/*
|
||||
this.embedRules(MarkdownHighlightRules, "markdown-", [{
|
||||
token : "support.function",
|
||||
|
|
@ -324,4 +344,4 @@ var JadeHighlightRules = function() {
|
|||
oop.inherits(JadeHighlightRules, TextHighlightRules);
|
||||
|
||||
exports.JadeHighlightRules = JadeHighlightRules;
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -55,8 +55,7 @@ var JavaHighlightRules = function() {
|
|||
"variable.language": "this",
|
||||
"keyword": keywords,
|
||||
"constant.language": buildinConstants,
|
||||
"support.function": langClasses,
|
||||
|
||||
"support.function": langClasses
|
||||
}, "identifier");
|
||||
|
||||
// regexp must not have capturing parentheses. Use (?:) instead.
|
||||
|
|
|
|||
|
|
@ -123,25 +123,9 @@ oop.inherits(Mode, TextMode);
|
|||
this.createWorker = function(session) {
|
||||
var worker = new WorkerClient(["ace"], "ace/mode/javascript_worker", "JavaScriptWorker");
|
||||
worker.attachToDocument(session.getDocument());
|
||||
|
||||
|
||||
worker.on("jslint", function(results) {
|
||||
var errors = [];
|
||||
for (var i=0; i<results.data.length; i++) {
|
||||
var error = results.data[i];
|
||||
if (error)
|
||||
errors.push({
|
||||
row: error.line-1,
|
||||
column: error.character-1,
|
||||
text: error.reason,
|
||||
type: "warning",
|
||||
lint: error
|
||||
});
|
||||
}
|
||||
session.setAnnotations(errors);
|
||||
});
|
||||
|
||||
worker.on("narcissus", function(e) {
|
||||
session.setAnnotations([e.data]);
|
||||
session.setAnnotations(results.data);
|
||||
});
|
||||
|
||||
worker.on("terminate", function() {
|
||||
|
|
|
|||