Merge branch 'master' of http://github.com/ajaxorg/editor
This commit is contained in:
commit
523ea3c082
33 changed files with 619 additions and 355 deletions
168
demo/require.js
168
demo/require.js
|
|
@ -13,7 +13,7 @@ setInterval: false, importScripts: false */
|
||||||
var require;
|
var require;
|
||||||
(function () {
|
(function () {
|
||||||
//Change this version number for each release.
|
//Change this version number for each release.
|
||||||
var version = "0.14.1",
|
var version = "0.14.2",
|
||||||
empty = {}, s,
|
empty = {}, s,
|
||||||
i, defContextName = "_", contextLoads = [],
|
i, defContextName = "_", contextLoads = [],
|
||||||
scripts, script, rePkg, src, m, dataMain, cfg = {}, setReadyState,
|
scripts, script, rePkg, src, m, dataMain, cfg = {}, setReadyState,
|
||||||
|
|
@ -43,7 +43,7 @@ var require;
|
||||||
cfg = require;
|
cfg = require;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calls a method on a plugin. The obj object should have two property,
|
* Calls a method on a plugin. The obj object should have two property,
|
||||||
* name: the name of the method to call on the plugin
|
* name: the name of the method to call on the plugin
|
||||||
|
|
@ -65,7 +65,7 @@ var require;
|
||||||
req(["require/" + prefix], context.contextName);
|
req(["require/" + prefix], context.contextName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convenience method to call main for a require.def call that was put on
|
* Convenience method to call main for a require.def call that was put on
|
||||||
* hold in the defQueue.
|
* hold in the defQueue.
|
||||||
|
|
@ -78,6 +78,33 @@ var require;
|
||||||
context.loaded[args[0]] = true;
|
context.loaded[args[0]] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to set up package paths from a packagePaths or packages config object.
|
||||||
|
* @param {Object} packages the object to store the new package config
|
||||||
|
* @param {Array} currentPackages an array of packages to configure
|
||||||
|
* @param {String} [dir] a prefix dir to use.
|
||||||
|
*/
|
||||||
|
function configurePackageDir(packages, currentPackages, dir) {
|
||||||
|
var i, location, pkgObj;
|
||||||
|
for (i = 0; (pkgObj = currentPackages[i]); i++) {
|
||||||
|
pkgObj = typeof pkgObj === "string" ? { name: pkgObj } : pkgObj;
|
||||||
|
location = pkgObj.location;
|
||||||
|
|
||||||
|
//Add dir to the path, but avoid paths that start with a slash
|
||||||
|
//or have a colon (indicates a protocol)
|
||||||
|
if (dir && (!location || (location.indexOf("/") !== 0 && location.indexOf(":") === -1))) {
|
||||||
|
pkgObj.location = dir + "/" + (pkgObj.location || pkgObj.name);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Normalize package paths.
|
||||||
|
pkgObj.location = pkgObj.location || pkgObj.name;
|
||||||
|
pkgObj.lib = pkgObj.lib || "lib";
|
||||||
|
pkgObj.main = pkgObj.main || "main";
|
||||||
|
|
||||||
|
packages[pkgObj.name] = pkgObj;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resumes tracing of dependencies and then checks if everything is loaded.
|
* Resumes tracing of dependencies and then checks if everything is loaded.
|
||||||
*/
|
*/
|
||||||
|
|
@ -253,7 +280,7 @@ var require;
|
||||||
var context, newContext, loaded, pluginPrefix,
|
var context, newContext, loaded, pluginPrefix,
|
||||||
canSetContext, prop, newLength, outDeps, mods, paths, index, i,
|
canSetContext, prop, newLength, outDeps, mods, paths, index, i,
|
||||||
deferMods, deferModArgs, lastModArg, waitingName, packages,
|
deferMods, deferModArgs, lastModArg, waitingName, packages,
|
||||||
packagePaths, pkgPath, pkgNames, pkgName, pkgObj;
|
packagePaths;
|
||||||
|
|
||||||
contextName = contextName ? contextName : (config && config.context ? config.context : s.ctxName);
|
contextName = contextName ? contextName : (config && config.context ? config.context : s.ctxName);
|
||||||
context = s.contexts[contextName];
|
context = s.contexts[contextName];
|
||||||
|
|
@ -271,7 +298,7 @@ var require;
|
||||||
pluginPrefix = context.defPlugin[name];
|
pluginPrefix = context.defPlugin[name];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//If module already defined for context, or already waiting to be
|
//If module already defined for context, or already waiting to be
|
||||||
//evaluated, leave.
|
//evaluated, leave.
|
||||||
waitingName = context.waiting[name];
|
waitingName = context.waiting[name];
|
||||||
|
|
@ -326,7 +353,7 @@ var require;
|
||||||
if (s.plugins.newContext) {
|
if (s.plugins.newContext) {
|
||||||
s.plugins.newContext(newContext);
|
s.plugins.newContext(newContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
context = s.contexts[contextName] = newContext;
|
context = s.contexts[contextName] = newContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -365,43 +392,14 @@ var require;
|
||||||
if (packagePaths) {
|
if (packagePaths) {
|
||||||
for (prop in packagePaths) {
|
for (prop in packagePaths) {
|
||||||
if (!(prop in empty)) {
|
if (!(prop in empty)) {
|
||||||
pkgPath = prop;
|
configurePackageDir(packages, packagePaths[prop], prop);
|
||||||
pkgNames = packagePaths[pkgPath];
|
|
||||||
for (i = 0; (pkgName = pkgNames[i]); i++) {
|
|
||||||
if (typeof pkgName === "string") {
|
|
||||||
//Standard package mapping.
|
|
||||||
pkgObj = packages[pkgName] = {
|
|
||||||
name: pkgName,
|
|
||||||
location: pkgPath + "/" + pkgName
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
//A custom setup.
|
|
||||||
pkgObj = context.config.packages[pkgName.name] = pkgName;
|
|
||||||
pkgObj.location = pkgPath + "/" + (pkgObj.location || pkgObj.name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Adjust packages if necessary.
|
//Adjust packages if necessary.
|
||||||
if (config.packages) {
|
if (config.packages) {
|
||||||
for (prop in config.packages) {
|
configurePackageDir(packages, config.packages);
|
||||||
if (!(prop in empty)) {
|
|
||||||
pkgObj = packages[prop] = config.packages[prop];
|
|
||||||
pkgObj.name = pkgObj.name || prop;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//Normalize package paths.
|
|
||||||
for (prop in packages) {
|
|
||||||
if (!(prop in empty)) {
|
|
||||||
pkgObj = packages[prop];
|
|
||||||
pkgObj.location = pkgObj.location || pkgObj.name;
|
|
||||||
pkgObj.lib = pkgObj.lib || "lib";
|
|
||||||
pkgObj.main = pkgObj.main || "main";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Done with modifications, assing packages back to context config
|
//Done with modifications, assing packages back to context config
|
||||||
|
|
@ -430,7 +428,7 @@ var require;
|
||||||
if (config.ready) {
|
if (config.ready) {
|
||||||
req.ready(config.ready);
|
req.ready(config.ready);
|
||||||
}
|
}
|
||||||
|
|
||||||
//If it is just a config block, nothing else,
|
//If it is just a config block, nothing else,
|
||||||
//then return.
|
//then return.
|
||||||
if (!deps) {
|
if (!deps) {
|
||||||
|
|
@ -445,7 +443,7 @@ var require;
|
||||||
outDeps = deps;
|
outDeps = deps;
|
||||||
deps = [];
|
deps = [];
|
||||||
for (i = 0; i < outDeps.length; i++) {
|
for (i = 0; i < outDeps.length; i++) {
|
||||||
deps[i] = req.splitPrefix(outDeps[i], name);
|
deps[i] = req.splitPrefix(outDeps[i], name, context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -501,7 +499,7 @@ var require;
|
||||||
args: [name, deps, callback, context]
|
args: [name, deps, callback, context]
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
//Hold on to the module until a script load or other adapter has finished
|
//Hold on to the module until a script load or other adapter has finished
|
||||||
//evaluating the whole file. This helps when a file has more than one
|
//evaluating the whole file. This helps when a file has more than one
|
||||||
//module in it -- dependencies are not traced and fetched until the whole
|
//module in it -- dependencies are not traced and fetched until the whole
|
||||||
|
|
@ -630,7 +628,7 @@ var require;
|
||||||
|
|
||||||
return req;
|
return req;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Internal method used by environment adapters to complete a load event.
|
* Internal method used by environment adapters to complete a load event.
|
||||||
* A load event could be a script load or just a load pass from a synchronous
|
* A load event could be a script load or just a load pass from a synchronous
|
||||||
|
|
@ -663,7 +661,7 @@ var require;
|
||||||
//moduleName that maps to a require.def call. This line is important
|
//moduleName that maps to a require.def call. This line is important
|
||||||
//for traditional browser scripts.
|
//for traditional browser scripts.
|
||||||
context.loaded[moduleName] = true;
|
context.loaded[moduleName] = true;
|
||||||
|
|
||||||
context.scriptCount -= 1;
|
context.scriptCount -= 1;
|
||||||
resume(context);
|
resume(context);
|
||||||
};
|
};
|
||||||
|
|
@ -788,7 +786,7 @@ var require;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
req.isArray = function (it) {
|
req.isArray = function (it) {
|
||||||
return ostring.call(it) === "[object Array]";
|
return ostring.call(it) === "[object Array]";
|
||||||
};
|
};
|
||||||
|
|
@ -817,10 +815,12 @@ var require;
|
||||||
}
|
}
|
||||||
contextName = contextName || s.ctxName;
|
contextName = contextName || s.ctxName;
|
||||||
|
|
||||||
//Normalize module name, if it contains . or ..
|
var ret, context = s.contexts[contextName];
|
||||||
moduleName = req.normalizeName(moduleName, relModuleName);
|
|
||||||
|
|
||||||
var ret = s.contexts[contextName].defined[moduleName];
|
//Normalize module name, if it contains . or ..
|
||||||
|
moduleName = req.normalizeName(moduleName, relModuleName, context);
|
||||||
|
|
||||||
|
ret = context.defined[moduleName];
|
||||||
if (ret === undefined) {
|
if (ret === undefined) {
|
||||||
req.onError(new Error("require: module name '" +
|
req.onError(new Error("require: module name '" +
|
||||||
moduleName +
|
moduleName +
|
||||||
|
|
@ -867,16 +867,17 @@ var require;
|
||||||
|
|
||||||
req.jsExtRegExp = /\.js$/;
|
req.jsExtRegExp = /\.js$/;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Given a relative module name, like ./something, normalize it to
|
* Given a relative module name, like ./something, normalize it to
|
||||||
* a real name that can be mapped to a path.
|
* a real name that can be mapped to a path.
|
||||||
* @param {String} name the relative name
|
* @param {String} name the relative name
|
||||||
* @param {String} baseName a real name that the name arg is relative
|
* @param {String} baseName a real name that the name arg is relative
|
||||||
* to.
|
* to.
|
||||||
|
* @param {Object} context
|
||||||
* @returns {String} normalized name
|
* @returns {String} normalized name
|
||||||
*/
|
*/
|
||||||
req.normalizeName = function (name, baseName) {
|
req.normalizeName = function (name, baseName, context) {
|
||||||
//Adjust any relative paths.
|
//Adjust any relative paths.
|
||||||
var part;
|
var part;
|
||||||
if (name.charAt(0) === ".") {
|
if (name.charAt(0) === ".") {
|
||||||
|
|
@ -885,13 +886,20 @@ var require;
|
||||||
name +
|
name +
|
||||||
", no relative module name available."));
|
", no relative module name available."));
|
||||||
}
|
}
|
||||||
//Convert baseName to array, and lop off the last part,
|
|
||||||
//so that . matches that "directory" and not name of the baseName's
|
if (context.config.packages[baseName]) {
|
||||||
//module. For instance, baseName of "one/two/three", maps to
|
//If the baseName is a package name, then just treat it as one
|
||||||
//"one/two/three.js", but we want the directory, "one/two" for
|
//name to concat the name with.
|
||||||
//this normalization.
|
baseName = [baseName];
|
||||||
baseName = baseName.split("/");
|
} else {
|
||||||
baseName = baseName.slice(0, baseName.length - 1);
|
//Convert baseName to array, and lop off the last part,
|
||||||
|
//so that . matches that "directory" and not name of the baseName's
|
||||||
|
//module. For instance, baseName of "one/two/three", maps to
|
||||||
|
//"one/two/three.js", but we want the directory, "one/two" for
|
||||||
|
//this normalization.
|
||||||
|
baseName = baseName.split("/");
|
||||||
|
baseName = baseName.slice(0, baseName.length - 1);
|
||||||
|
}
|
||||||
|
|
||||||
name = baseName.concat(name.split("/"));
|
name = baseName.concat(name.split("/"));
|
||||||
for (i = 0; (part = name[i]); i++) {
|
for (i = 0; (part = name[i]); i++) {
|
||||||
|
|
@ -912,16 +920,17 @@ var require;
|
||||||
* Splits a name into a possible plugin prefix and
|
* Splits a name into a possible plugin prefix and
|
||||||
* the module name. If baseName is provided it will
|
* the module name. If baseName is provided it will
|
||||||
* also normalize the name via require.normalizeName()
|
* also normalize the name via require.normalizeName()
|
||||||
*
|
*
|
||||||
* @param {String} name the module name
|
* @param {String} name the module name
|
||||||
* @param {String} [baseName] base name that name is
|
* @param {String} [baseName] base name that name is
|
||||||
* relative to.
|
* relative to.
|
||||||
|
* @param {Object} context
|
||||||
*
|
*
|
||||||
* @returns {Object} with properties, 'prefix' (which
|
* @returns {Object} with properties, 'prefix' (which
|
||||||
* may be null), 'name' and 'fullName', which is a combination
|
* may be null), 'name' and 'fullName', which is a combination
|
||||||
* of the prefix (if it exists) and the name.
|
* of the prefix (if it exists) and the name.
|
||||||
*/
|
*/
|
||||||
req.splitPrefix = function (name, baseName) {
|
req.splitPrefix = function (name, baseName, context) {
|
||||||
var index = name.indexOf("!"), prefix = null;
|
var index = name.indexOf("!"), prefix = null;
|
||||||
if (index !== -1) {
|
if (index !== -1) {
|
||||||
prefix = name.substring(0, index);
|
prefix = name.substring(0, index);
|
||||||
|
|
@ -929,7 +938,7 @@ var require;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Account for relative paths if there is a base name.
|
//Account for relative paths if there is a base name.
|
||||||
name = req.normalizeName(name, baseName);
|
name = req.normalizeName(name, baseName, context);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
prefix: prefix,
|
prefix: prefix,
|
||||||
|
|
@ -943,10 +952,11 @@ var require;
|
||||||
*/
|
*/
|
||||||
req.nameToUrl = function (moduleName, ext, contextName, relModuleName) {
|
req.nameToUrl = function (moduleName, ext, contextName, relModuleName) {
|
||||||
var paths, packages, pkg, pkgPath, syms, i, parentModule, url,
|
var paths, packages, pkg, pkgPath, syms, i, parentModule, url,
|
||||||
config = s.contexts[contextName].config;
|
context = s.contexts[contextName],
|
||||||
|
config = context.config;
|
||||||
|
|
||||||
//Normalize module name if have a base relative module name to work from.
|
//Normalize module name if have a base relative module name to work from.
|
||||||
moduleName = req.normalizeName(moduleName, relModuleName);
|
moduleName = req.normalizeName(moduleName, relModuleName, context);
|
||||||
|
|
||||||
//If a colon is in the URL, it indicates a protocol is used and it is just
|
//If a colon is in the URL, it indicates a protocol is used and it is just
|
||||||
//an URL to a file, or if it starts with a slash or ends with .js, it is just a plain file.
|
//an URL to a file, or if it starts with a slash or ends with .js, it is just a plain file.
|
||||||
|
|
@ -1010,7 +1020,7 @@ var require;
|
||||||
priorityName,
|
priorityName,
|
||||||
|
|
||||||
pIsWaiting = s.plugins.isWaiting, pOrderDeps = s.plugins.orderDeps,
|
pIsWaiting = s.plugins.isWaiting, pOrderDeps = s.plugins.orderDeps,
|
||||||
|
|
||||||
i, module, allDone, loads, loadArgs, err;
|
i, module, allDone, loads, loadArgs, err;
|
||||||
|
|
||||||
//If already doing a checkLoaded call,
|
//If already doing a checkLoaded call,
|
||||||
|
|
@ -1103,7 +1113,7 @@ var require;
|
||||||
if (pOrderDeps) {
|
if (pOrderDeps) {
|
||||||
pOrderDeps(context);
|
pOrderDeps(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Before defining the modules, give priority treatment to any modifiers
|
//Before defining the modules, give priority treatment to any modifiers
|
||||||
//for modules that are already defined.
|
//for modules that are already defined.
|
||||||
for (prop in modifiers) {
|
for (prop in modifiers) {
|
||||||
|
|
@ -1113,7 +1123,7 @@ var require;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Define the modules, doing a depth first search.
|
//Define the modules, doing a depth first search.
|
||||||
for (i = 0; (module = waiting[i]); i++) {
|
for (i = 0; (module = waiting[i]); i++) {
|
||||||
req.exec(module, {}, waiting, context);
|
req.exec(module, {}, waiting, context);
|
||||||
|
|
@ -1212,12 +1222,12 @@ var require;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Executes the modules in the correct order.
|
* Executes the modules in the correct order.
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
req.exec = function (module, traced, waiting, context) {
|
req.exec = function (module, traced, waiting, context) {
|
||||||
//Some modules are just plain script files, abddo not have a formal
|
//Some modules are just plain script files, abddo not have a formal
|
||||||
//module definition,
|
//module definition,
|
||||||
if (!module) {
|
if (!module) {
|
||||||
//Returning undefined for Spidermonky strict checking in Komodo
|
//Returning undefined for Spidermonky strict checking in Komodo
|
||||||
return undefined;
|
return undefined;
|
||||||
|
|
@ -1281,7 +1291,7 @@ var require;
|
||||||
ret = defined[name];
|
ret = defined[name];
|
||||||
} else {
|
} else {
|
||||||
if (cjsModule && "exports" in cjsModule) {
|
if (cjsModule && "exports" in cjsModule) {
|
||||||
ret = defined[name] = depModule.exports;
|
ret = defined[name] = cjsModule.exports;
|
||||||
} else {
|
} else {
|
||||||
if (name in defined && !usingExports) {
|
if (name in defined && !usingExports) {
|
||||||
req.onError(new Error(name + " has already been defined"));
|
req.onError(new Error(name + " has already been defined"));
|
||||||
|
|
@ -1294,7 +1304,7 @@ var require;
|
||||||
|
|
||||||
//Execute modifiers, if they exist.
|
//Execute modifiers, if they exist.
|
||||||
req.execModifiers(name, traced, waiting, context);
|
req.execModifiers(name, traced, waiting, context);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -1334,7 +1344,7 @@ var require;
|
||||||
delete modifiers[target];
|
delete modifiers[target];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* callback for script loads, used to check status of loading.
|
* callback for script loads, used to check status of loading.
|
||||||
*
|
*
|
||||||
|
|
@ -1455,11 +1465,11 @@ var require;
|
||||||
if (cfg.baseUrlMatch) {
|
if (cfg.baseUrlMatch) {
|
||||||
rePkg = cfg.baseUrlMatch;
|
rePkg = cfg.baseUrlMatch;
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
rePkg = /(allplugins-|transportD-)?require\.js(\W|$)/i;
|
rePkg = /(allplugins-|transportD-)?require\.js(\W|$)/i;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = scripts.length - 1; i > -1 && (script = scripts[i]); i--) {
|
for (i = scripts.length - 1; i > -1 && (script = scripts[i]); i--) {
|
||||||
|
|
@ -1590,7 +1600,7 @@ var require;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//****** END page load functionality ****************
|
//****** END page load functionality ****************
|
||||||
|
|
||||||
//Set up default context. If require was a configuration object, use that as base config.
|
//Set up default context. If require was a configuration object, use that as base config.
|
||||||
req(cfg);
|
req(cfg);
|
||||||
|
|
||||||
|
|
@ -1888,7 +1898,7 @@ var require;
|
||||||
if (loc === "_match") {
|
if (loc === "_match") {
|
||||||
//Found default locale to use for the top-level bundle name.
|
//Found default locale to use for the top-level bundle name.
|
||||||
defLoc = msWaiting[loc];
|
defLoc = msWaiting[loc];
|
||||||
|
|
||||||
} else if (msWaiting[loc] !== loc) {
|
} else if (msWaiting[loc] !== loc) {
|
||||||
//A "best fit" locale, store it off to the end and handle
|
//A "best fit" locale, store it off to the end and handle
|
||||||
//it at the end by just assigning the best fit value, since
|
//it at the end by just assigning the best fit value, since
|
||||||
|
|
@ -1918,7 +1928,7 @@ var require;
|
||||||
//loop above so that the default locale bundle has been properly mixed
|
//loop above so that the default locale bundle has been properly mixed
|
||||||
//together.
|
//together.
|
||||||
context.defined[master] = context.defined[modulePrefix + "/" + defLoc + "/" + moduleSuffix];
|
context.defined[master] = context.defined[modulePrefix + "/" + defLoc + "/" + moduleSuffix];
|
||||||
|
|
||||||
//Handle any best fit locale definitions.
|
//Handle any best fit locale definitions.
|
||||||
if (bestFit) {
|
if (bestFit) {
|
||||||
for (loc in bestFit) {
|
for (loc in bestFit) {
|
||||||
|
|
@ -1983,7 +1993,7 @@ var require;
|
||||||
progIds = [progId]; // so faster next time
|
progIds = [progId]; // so faster next time
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!xhr) {
|
if (!xhr) {
|
||||||
|
|
@ -1993,7 +2003,7 @@ var require;
|
||||||
return xhr;
|
return xhr;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!require.fetchText) {
|
if (!require.fetchText) {
|
||||||
require.fetchText = function (url, callback) {
|
require.fetchText = function (url, callback) {
|
||||||
var xhr = require.getXhr();
|
var xhr = require.getXhr();
|
||||||
|
|
@ -2092,7 +2102,7 @@ var require;
|
||||||
require.fetchText(url, function (text) {
|
require.fetchText(url, function (text) {
|
||||||
context.text[key] = text;
|
context.text[key] = text;
|
||||||
context.loaded[name] = true;
|
context.loaded[name] = true;
|
||||||
require.checkLoaded(contextName);
|
require.checkLoaded(contextName);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
@ -2376,7 +2386,7 @@ var require;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when all modules have been loaded. Not needed for this plugin.
|
* Called when all modules have been loaded. Not needed for this plugin.
|
||||||
* State is reset as part of scriptCacheCallback.
|
* State is reset as part of scriptCacheCallback.
|
||||||
*/
|
*/
|
||||||
orderDeps: function (context) {
|
orderDeps: function (context) {
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,17 +2,19 @@
|
||||||
server: http://localhost:4224
|
server: http://localhost:4224
|
||||||
|
|
||||||
load:
|
load:
|
||||||
- src/ace/lib/core.js
|
- demo/require.js
|
||||||
- src/ace/lib/*.js
|
# - src/ace/lib/core.js
|
||||||
- src/ace/MEventEmitter.js
|
# - src/ace/lib/*.js
|
||||||
- src/ace/mode/Text.js
|
# - src/ace/MEventEmitter.js
|
||||||
- src/ace/mode/TextHighlightRules.js
|
# - src/ace/mode/Text.js
|
||||||
- src/ace/mode/*.js
|
# - src/ace/mode/TextHighlightRules.js
|
||||||
- src/ace/layer/*.js
|
# - src/ace/mode/*.js
|
||||||
- src/ace/*.js
|
# - src/ace/layer/*.js
|
||||||
|
# - src/ace/*.js
|
||||||
|
|
||||||
- src/debug/*.js
|
# - src/debug/*.js
|
||||||
|
|
||||||
- src/test/ace/*.js
|
# - src/test/ace/*.js
|
||||||
- src/test/ace/mode/*.js
|
# - src/test/ace/mode/*.js
|
||||||
- src/test/debug/*.js
|
# - src/test/debug/*.js
|
||||||
|
- src/ace/test/all.js
|
||||||
|
|
@ -34,7 +34,7 @@ var BackgroundTokenizer = function(tokenizer, editor) {
|
||||||
processedLines += 1;
|
processedLines += 1;
|
||||||
if ((processedLines % 5 == 0) && (new Date() - workerStart) > 20) {
|
if ((processedLines % 5 == 0) && (new Date() - workerStart) > 20) {
|
||||||
self.fireUpdateEvent(startLine, self.currentLine-1);
|
self.fireUpdateEvent(startLine, self.currentLine-1);
|
||||||
|
|
||||||
var timeout = self.currentLine < lastVisibleRow ? 20 : 100;
|
var timeout = self.currentLine < lastVisibleRow ? 20 : 100;
|
||||||
self.running = setTimeout(self.$worker, timeout);
|
self.running = setTimeout(self.$worker, timeout);
|
||||||
return;
|
return;
|
||||||
|
|
@ -102,7 +102,7 @@ var BackgroundTokenizer = function(tokenizer, editor) {
|
||||||
this.$tokenizeRows = function(firstRow, lastRow) {
|
this.$tokenizeRows = function(firstRow, lastRow) {
|
||||||
var rows = [];
|
var rows = [];
|
||||||
|
|
||||||
// determin start state
|
// determine start state
|
||||||
var state = "start";
|
var state = "start";
|
||||||
var doCache = false;
|
var doCache = false;
|
||||||
if (firstRow > 0 && this.lines[firstRow - 1]) {
|
if (firstRow > 0 && this.lines[firstRow - 1]) {
|
||||||
|
|
|
||||||
|
|
@ -100,7 +100,7 @@ var Document = function(text, mode) {
|
||||||
|
|
||||||
this.getTabString = function() {
|
this.getTabString = function() {
|
||||||
if (this.getUseSoftTabs()) {
|
if (this.getUseSoftTabs()) {
|
||||||
return new Array(this.getTabSize()+1).join(" ");
|
return lang.stringRepeat(" ", this.getTabSize());
|
||||||
} else {
|
} else {
|
||||||
return "\t";
|
return "\t";
|
||||||
}
|
}
|
||||||
|
|
@ -433,10 +433,10 @@ var Document = function(text, mode) {
|
||||||
var lastLine = newLines[newLines.length - 1] + line.substring(position.column);
|
var lastLine = newLines[newLines.length - 1] + line.substring(position.column);
|
||||||
|
|
||||||
this.lines[position.row] = firstLine;
|
this.lines[position.row] = firstLine;
|
||||||
this.$insertLines(position.row + 1, [lastLine], fromUndo);
|
this.$insertLines(position.row + 1, [lastLine], true);
|
||||||
|
|
||||||
if (newLines.length > 2) {
|
if (newLines.length > 2) {
|
||||||
this.$insertLines(position.row + 1, newLines.slice(1, -1), fromUndo);
|
this.$insertLines(position.row + 1, newLines.slice(1, -1), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
var end = {
|
var end = {
|
||||||
|
|
@ -446,7 +446,6 @@ var Document = function(text, mode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!fromUndo && this.$undoManager) {
|
if (!fromUndo && this.$undoManager) {
|
||||||
var nl = this.$getNewLineCharacter();
|
|
||||||
this.$deltas.push({
|
this.$deltas.push({
|
||||||
action: "insertText",
|
action: "insertText",
|
||||||
range: Range.fromPoints(position, end),
|
range: Range.fromPoints(position, end),
|
||||||
|
|
@ -549,34 +548,42 @@ var Document = function(text, mode) {
|
||||||
};
|
};
|
||||||
|
|
||||||
this.indentRows = function(range, indentString) {
|
this.indentRows = function(range, indentString) {
|
||||||
for (var row=range.start.row; row<= range.end.row; row++) {
|
indentString.replace("\t", this.getTabString());
|
||||||
|
for (var row=range.start.row; row<=range.end.row; row++) {
|
||||||
this.$insert({row: row, column:0}, indentString);
|
this.$insert({row: row, column:0}, indentString);
|
||||||
}
|
}
|
||||||
this.fireChangeEvent(range.start.row, range.end.row);
|
this.fireChangeEvent(range.start.row, range.end.row);
|
||||||
return indentString.length;
|
return indentString.length;
|
||||||
};
|
};
|
||||||
|
|
||||||
this.outdentRows = function(range, indentString) {
|
this.outdentRows = function (range) {
|
||||||
outdentLength = indentString.length;
|
var deleteRange = new Range(0, 0, 0, 0),
|
||||||
|
size = this.getTabSize();
|
||||||
for (var i=range.start.row; i<= range.end.row; i++) {
|
|
||||||
if (this.getLine(i).substr(0, outdentLength) !== indentString) {
|
for (var i = range.start.row; i <= range.end.row; ++i) {
|
||||||
return 0;
|
var line = this.getLine(i);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var deleteRange = new Range(0, 0, 0, outdentLength);
|
|
||||||
|
|
||||||
for (var i=range.start.row; i<= range.end.row; i++)
|
|
||||||
{
|
|
||||||
deleteRange.start.row = i;
|
deleteRange.start.row = i;
|
||||||
deleteRange.end.row = i;
|
deleteRange.end.row = i;
|
||||||
|
for (var j = 0; j < size; ++j)
|
||||||
|
if (line.charAt(j) != ' ')
|
||||||
|
break;
|
||||||
|
if (j < size && line.charAt(j) == '\t') {
|
||||||
|
deleteRange.start.column = j;
|
||||||
|
deleteRange.end.column = j + 1;
|
||||||
|
} else {
|
||||||
|
deleteRange.start.column = 0;
|
||||||
|
deleteRange.end.column = j;
|
||||||
|
}
|
||||||
|
if (i == range.start.row)
|
||||||
|
range.start.column -= deleteRange.end.column - deleteRange.start.column;
|
||||||
|
if (i == range.end.row)
|
||||||
|
range.end.column -= deleteRange.end.column - deleteRange.start.column;
|
||||||
this.$remove(deleteRange);
|
this.$remove(deleteRange);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.fireChangeEvent(range.start.row, range.end.row);
|
this.fireChangeEvent(range.start.row, range.end.row);
|
||||||
return -outdentLength;
|
return range;
|
||||||
};
|
}
|
||||||
|
|
||||||
this.moveLinesUp = function(firstRow, lastRow) {
|
this.moveLinesUp = function(firstRow, lastRow) {
|
||||||
if (firstRow <= 0) return 0;
|
if (firstRow <= 0) return 0;
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ require.def("ace/Editor",
|
||||||
[
|
[
|
||||||
"ace/ace",
|
"ace/ace",
|
||||||
"ace/lib/event",
|
"ace/lib/event",
|
||||||
|
"ace/lib/lang",
|
||||||
"ace/TextInput",
|
"ace/TextInput",
|
||||||
"ace/KeyBinding",
|
"ace/KeyBinding",
|
||||||
"ace/Document",
|
"ace/Document",
|
||||||
|
|
@ -16,7 +17,7 @@ require.def("ace/Editor",
|
||||||
"ace/BackgroundTokenizer",
|
"ace/BackgroundTokenizer",
|
||||||
"ace/Range",
|
"ace/Range",
|
||||||
"ace/MEventEmitter"
|
"ace/MEventEmitter"
|
||||||
], function(ace, event, TextInput, KeyBinding, Document, Search, BackgroundTokenizer, Range, MEventEmitter) {
|
], function(ace, event, lang, TextInput, KeyBinding, Document, Search, BackgroundTokenizer, Range, MEventEmitter) {
|
||||||
|
|
||||||
var Editor = function(renderer, doc) {
|
var Editor = function(renderer, doc) {
|
||||||
var container = renderer.getContainerElement();
|
var container = renderer.getContainerElement();
|
||||||
|
|
@ -344,7 +345,7 @@ var Editor = function(renderer, doc) {
|
||||||
};
|
};
|
||||||
|
|
||||||
this.onMouseWheel = function(e) {
|
this.onMouseWheel = function(e) {
|
||||||
this.renderer.scrollBy(e.wheelX, e.wheelY);
|
this.renderer.scrollBy(e.wheelX * 2, e.wheelY * 2);
|
||||||
return event.preventDefault(e);
|
return event.preventDefault(e);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -524,14 +525,26 @@ var Editor = function(renderer, doc) {
|
||||||
this.clearSelection();
|
this.clearSelection();
|
||||||
};
|
};
|
||||||
|
|
||||||
this.blockIndent = function(indentString) {
|
this.indent = function() {
|
||||||
if (this.$readOnly)
|
if (this.$readOnly)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var indentString = indentString || this.doc.getTabString();
|
if (this.selection.isMultiLine()) {
|
||||||
var addedColumns = this.doc.indentRows(this.getSelectionRange(), indentString);
|
var addedColumns = this.doc.indentRows(this.getSelectionRange(), "\t");
|
||||||
|
this.selection.shiftSelection(addedColumns);
|
||||||
|
} else {
|
||||||
|
if (!this.doc.getUseSoftTabs())
|
||||||
|
return this.onTextInput("\t");
|
||||||
|
|
||||||
|
var cursor = this.doc.remove(this.getSelectionRange());
|
||||||
|
this.clearSelection();
|
||||||
|
|
||||||
this.selection.shiftSelection(addedColumns);
|
// compute indent string
|
||||||
|
var indentString = lang.stringRepeat(" ", this.doc.getTabSize() - (cursor.column % this.doc.getTabSize()));
|
||||||
|
var addedColumns = this.doc.indentRows(this.getSelectionRange(), indentString);
|
||||||
|
cursor.column += addedColumns;
|
||||||
|
this.moveCursorToPosition(cursor);
|
||||||
|
}
|
||||||
this.$updateDesiredColumn();
|
this.$updateDesiredColumn();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -539,14 +552,10 @@ var Editor = function(renderer, doc) {
|
||||||
if (this.$readOnly)
|
if (this.$readOnly)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var indentString = indentString || this.doc.getTabString();
|
var selection = this.doc.getSelection(),
|
||||||
var addedColumns = this.doc.outdentRows(this.getSelectionRange(), indentString);
|
range = this.doc.outdentRows(selection.getRange());
|
||||||
|
|
||||||
// besides the indent string also outdent tabs
|
selection.setSelectionRange(range, selection.isBackwards());
|
||||||
if (addedColumns == 0 && indentString != "\t")
|
|
||||||
var addedColumns = this.doc.outdentRows(this.getSelectionRange(), "\t");
|
|
||||||
|
|
||||||
this.selection.shiftSelection(addedColumns);
|
|
||||||
this.$updateDesiredColumn();
|
this.$updateDesiredColumn();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -170,7 +170,7 @@ Search.SELECTION = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
var modifier = "g";
|
var modifier = "g";
|
||||||
if (this.$options.caseSensitive) {
|
if (!this.$options.caseSensitive) {
|
||||||
modifier += "i";
|
modifier += "i";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -79,7 +79,7 @@ var Selection = function(doc) {
|
||||||
var anchor = this.getSelectionAnchor();
|
var anchor = this.getSelectionAnchor();
|
||||||
var lead = this.getSelectionLead();
|
var lead = this.getSelectionLead();
|
||||||
|
|
||||||
var isBackwards = this.$isBackwards();
|
var isBackwards = this.isBackwards();
|
||||||
|
|
||||||
if (!isBackwards || anchor.column !== 0)
|
if (!isBackwards || anchor.column !== 0)
|
||||||
this.setSelectionAnchor(anchor.row, anchor.column + columns);
|
this.setSelectionAnchor(anchor.row, anchor.column + columns);
|
||||||
|
|
@ -91,7 +91,7 @@ var Selection = function(doc) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
this.$isBackwards = function() {
|
this.isBackwards = function() {
|
||||||
var anchor = this.selectionAnchor || this.selectionLead;
|
var anchor = this.selectionAnchor || this.selectionLead;
|
||||||
var lead = this.selectionLead;
|
var lead = this.selectionLead;
|
||||||
return (anchor.row > lead.row || (anchor.row == lead.row && anchor.column > lead.column));
|
return (anchor.row > lead.row || (anchor.row == lead.row && anchor.column > lead.column));
|
||||||
|
|
@ -101,7 +101,7 @@ var Selection = function(doc) {
|
||||||
var anchor = this.selectionAnchor || this.selectionLead;
|
var anchor = this.selectionAnchor || this.selectionLead;
|
||||||
var lead = this.selectionLead;
|
var lead = this.selectionLead;
|
||||||
|
|
||||||
if (this.$isBackwards()) {
|
if (this.isBackwards()) {
|
||||||
return Range.fromPoints(lead, anchor);
|
return Range.fromPoints(lead, anchor);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
@ -116,7 +116,6 @@ var Selection = function(doc) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
this.selectAll = function() {
|
this.selectAll = function() {
|
||||||
var lastRow = this.doc.getLength() - 1;
|
var lastRow = this.doc.getLength() - 1;
|
||||||
this.setSelectionAnchor(lastRow, this.doc.getLine(lastRow).length);
|
this.setSelectionAnchor(lastRow, this.doc.getLine(lastRow).length);
|
||||||
|
|
@ -126,9 +125,14 @@ var Selection = function(doc) {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
this.setSelectionRange = function(range) {
|
this.setSelectionRange = function(range, reverse) {
|
||||||
this.setSelectionAnchor(range.start.row, range.start.column);
|
if (reverse) {
|
||||||
this.selectTo(range.end.row, range.end.column);
|
this.setSelectionAnchor(range.end.row, range.end.column);
|
||||||
|
this.selectTo(range.start.row, range.start.column);
|
||||||
|
} else {
|
||||||
|
this.setSelectionAnchor(range.start.row, range.start.column);
|
||||||
|
this.selectTo(range.end.row, range.end.column);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
this.$moveSelection = function(mover) {
|
this.$moveSelection = function(mover) {
|
||||||
|
|
|
||||||
|
|
@ -71,6 +71,7 @@ var TextInput = function(parentNode, host) {
|
||||||
text.value = host.getCopyText();
|
text.value = host.getCopyText();
|
||||||
text.select();
|
text.select();
|
||||||
copied = true;
|
copied = true;
|
||||||
|
setTimeout(sendText, 0);
|
||||||
};
|
};
|
||||||
|
|
||||||
var onCut = function() {
|
var onCut = function() {
|
||||||
|
|
@ -78,6 +79,7 @@ var TextInput = function(parentNode, host) {
|
||||||
text.value = host.getCopyText();
|
text.value = host.getCopyText();
|
||||||
host.onCut();
|
host.onCut();
|
||||||
text.select();
|
text.select();
|
||||||
|
setTimeout(sendText, 0);
|
||||||
};
|
};
|
||||||
|
|
||||||
event.addListener(text, "keypress", onTextInput);
|
event.addListener(text, "keypress", onTextInput);
|
||||||
|
|
|
||||||
|
|
@ -151,12 +151,7 @@ PluginManager.registerCommand("outdent", function(editor, selection) {
|
||||||
editor.blockOutdent();
|
editor.blockOutdent();
|
||||||
});
|
});
|
||||||
PluginManager.registerCommand("indent", function(editor, selection) {
|
PluginManager.registerCommand("indent", function(editor, selection) {
|
||||||
if (selection.isMultiLine()) {
|
editor.indent();
|
||||||
editor.blockIndent();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
editor.onTextInput("\t");
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
@ -16,6 +16,10 @@ require.def("ace/lib/lang", function() {
|
||||||
return string.split("").reverse().join("");
|
return string.split("").reverse().join("");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
lang.stringRepeat = function (string, count) {
|
||||||
|
return new Array(count + 1).join(string);
|
||||||
|
}
|
||||||
|
|
||||||
if (Array.prototype.indexOf) {
|
if (Array.prototype.indexOf) {
|
||||||
lang.arrayIndexOf = function(array, searchElement) {
|
lang.arrayIndexOf = function(array, searchElement) {
|
||||||
return array.indexOf(searchElement);
|
return array.indexOf(searchElement);
|
||||||
|
|
|
||||||
|
|
@ -8,40 +8,29 @@
|
||||||
require.def("ace/mode/JavaScriptHighlightRules",
|
require.def("ace/mode/JavaScriptHighlightRules",
|
||||||
[
|
[
|
||||||
"ace/lib/oop",
|
"ace/lib/oop",
|
||||||
|
"ace/lib/lang",
|
||||||
"ace/mode/DocCommentHighlightRules",
|
"ace/mode/DocCommentHighlightRules",
|
||||||
"ace/mode/TextHighlightRules"
|
"ace/mode/TextHighlightRules"
|
||||||
], function(oop, DocCommentHighlightRules, TextHighlightRules) {
|
], function(oop, lang, DocCommentHighlightRules, TextHighlightRules) {
|
||||||
|
|
||||||
|
|
||||||
JavaScriptHighlightRules = function() {
|
JavaScriptHighlightRules = function() {
|
||||||
|
|
||||||
var docComment = new DocCommentHighlightRules();
|
var docComment = new DocCommentHighlightRules();
|
||||||
|
|
||||||
var keywords = {
|
var keywords = lang.arrayToMap(
|
||||||
"break" : 1,
|
("break|case|catch|continue|default|delete|do|else|finally|for|function|" +
|
||||||
"case" : 1,
|
"if|in|instanceof|new|return|switch|throw|try|typeof|var|while|with").split("|")
|
||||||
"catch" : 1,
|
);
|
||||||
"continue" : 1,
|
|
||||||
"default" : 1,
|
var buildinConstants = lang.arrayToMap(
|
||||||
"delete" : 1,
|
("true|false|null|undefined|Infinity|NaN|undefined").split("|")
|
||||||
"do" : 1,
|
);
|
||||||
"else" : 1,
|
|
||||||
"finally" : 1,
|
var futureReserved = lang.arrayToMap(
|
||||||
"for" : 1,
|
("class|enum|extends|super|const|export|import|implements|let|private|" +
|
||||||
"function" : 1,
|
"public|yield|interface|package|protected|static").split("|")
|
||||||
"if" : 1,
|
);
|
||||||
"in" : 1,
|
|
||||||
"instanceof" : 1,
|
|
||||||
"new" : 1,
|
|
||||||
"return" : 1,
|
|
||||||
"switch" : 1,
|
|
||||||
"throw" : 1,
|
|
||||||
"try" : 1,
|
|
||||||
"typeof" : 1,
|
|
||||||
"var" : 1,
|
|
||||||
"while" : 1,
|
|
||||||
"with" : 1
|
|
||||||
};
|
|
||||||
|
|
||||||
// regexp must not have capturing parentheses. Use (?:) instead.
|
// regexp must not have capturing parentheses. Use (?:) instead.
|
||||||
// regexps are ordered -> the first match is used
|
// regexps are ordered -> the first match is used
|
||||||
|
|
@ -80,12 +69,14 @@ JavaScriptHighlightRules = function() {
|
||||||
token : function(value) {
|
token : function(value) {
|
||||||
if (value == "this")
|
if (value == "this")
|
||||||
return "variable";
|
return "variable";
|
||||||
if (keywords[value]) {
|
else if (keywords[value])
|
||||||
return "keyword";
|
return "keyword";
|
||||||
}
|
else if (buildinConstants[value])
|
||||||
else {
|
return "buildin-constant";
|
||||||
|
else if (futureReserved[value] || value == "debugger")
|
||||||
|
return "invalid";
|
||||||
|
else
|
||||||
return "identifier";
|
return "identifier";
|
||||||
}
|
|
||||||
},
|
},
|
||||||
regex : "[a-zA-Z_][a-zA-Z0-9_]*\\b"
|
regex : "[a-zA-Z_][a-zA-Z0-9_]*\\b"
|
||||||
}, {
|
}, {
|
||||||
|
|
|
||||||
|
|
@ -5,12 +5,26 @@
|
||||||
* @license LGPLv3 <http://www.gnu.org/licenses/lgpl-3.0.txt>
|
* @license LGPLv3 <http://www.gnu.org/licenses/lgpl-3.0.txt>
|
||||||
* @author Fabian Jakobs <fabian AT ajax DOT org>
|
* @author Fabian Jakobs <fabian AT ajax DOT org>
|
||||||
*/
|
*/
|
||||||
var ChangeDocumentTest = new TestCase("ChangeDocumentTest", {
|
|
||||||
|
|
||||||
|
require.def([
|
||||||
|
"ace/Document",
|
||||||
|
"ace/Editor",
|
||||||
|
"ace/mode/Text",
|
||||||
|
"ace/mode/JavaScript",
|
||||||
|
"ace/test/MockRenderer"
|
||||||
|
], function(
|
||||||
|
Document,
|
||||||
|
Editor,
|
||||||
|
TextMode,
|
||||||
|
JavaScriptMode,
|
||||||
|
MockRenderer
|
||||||
|
) {
|
||||||
|
|
||||||
|
var ChangeDocumentTest = new TestCase("ChangeDocumentTest", {
|
||||||
setUp : function() {
|
setUp : function() {
|
||||||
this.doc1 = new ace.Document(["abc", "def"].join("\n"));
|
this.doc1 = new Document(["abc", "def"].join("\n"));
|
||||||
this.doc2 = new ace.Document(["ghi", "jkl"].join("\n"));
|
this.doc2 = new Document(["ghi", "jkl"].join("\n"));
|
||||||
this.editor = new ace.Editor(new MockRenderer());
|
this.editor = new Editor(new MockRenderer());
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: change document" : function() {
|
"test: change document" : function() {
|
||||||
|
|
@ -105,10 +119,12 @@ var ChangeDocumentTest = new TestCase("ChangeDocumentTest", {
|
||||||
this.editor.setDocument(this.doc2);
|
this.editor.setDocument(this.doc2);
|
||||||
|
|
||||||
var called = false;
|
var called = false;
|
||||||
this.doc1.setMode(new ace.mode.Text());
|
this.doc1.setMode(new Text());
|
||||||
assertFalse(called);
|
assertFalse(called);
|
||||||
|
|
||||||
this.doc2.setMode(new ace.mode.JavaScript());
|
this.doc2.setMode(new JavaScriptMode());
|
||||||
assertTrue(called);
|
assertTrue(called);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
@ -5,10 +5,23 @@
|
||||||
* @license LGPLv3 <http://www.gnu.org/licenses/lgpl-3.0.txt>
|
* @license LGPLv3 <http://www.gnu.org/licenses/lgpl-3.0.txt>
|
||||||
* @author Fabian Jakobs <fabian AT ajax DOT org>
|
* @author Fabian Jakobs <fabian AT ajax DOT org>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
require.def([
|
||||||
|
"ace/Document",
|
||||||
|
"ace/UndoManager",
|
||||||
|
"ace/Editor",
|
||||||
|
"ace/test/MockRenderer"
|
||||||
|
], function(
|
||||||
|
Document,
|
||||||
|
UndoManager,
|
||||||
|
Editor,
|
||||||
|
MockRenderer
|
||||||
|
) {
|
||||||
|
|
||||||
var TextDocumentTest = new TestCase("TextDocumentTest", {
|
var TextDocumentTest = new TestCase("TextDocumentTest", {
|
||||||
|
|
||||||
"test: find matching opening bracket" : function() {
|
"test: find matching opening bracket" : function() {
|
||||||
var doc = new ace.Document(["(()(", "())))"]);
|
var doc = new Document(["(()(", "())))"]);
|
||||||
|
|
||||||
assertPosition(0, 1, doc.findMatchingBracket({row: 0, column: 3}));
|
assertPosition(0, 1, doc.findMatchingBracket({row: 0, column: 3}));
|
||||||
assertPosition(1, 0, doc.findMatchingBracket({row: 1, column: 2}));
|
assertPosition(1, 0, doc.findMatchingBracket({row: 1, column: 2}));
|
||||||
|
|
@ -18,7 +31,7 @@ var TextDocumentTest = new TestCase("TextDocumentTest", {
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: find matching closing bracket" : function() {
|
"test: find matching closing bracket" : function() {
|
||||||
var doc = new ace.Document(["(()(", "())))"]);
|
var doc = new Document(["(()(", "())))"]);
|
||||||
|
|
||||||
assertPosition(1, 1, doc.findMatchingBracket({row: 1, column: 1}));
|
assertPosition(1, 1, doc.findMatchingBracket({row: 1, column: 1}));
|
||||||
assertPosition(1, 1, doc.findMatchingBracket({row: 1, column: 1}));
|
assertPosition(1, 1, doc.findMatchingBracket({row: 1, column: 1}));
|
||||||
|
|
@ -29,7 +42,7 @@ var TextDocumentTest = new TestCase("TextDocumentTest", {
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: match different bracket types" : function() {
|
"test: match different bracket types" : function() {
|
||||||
var doc = new ace.Document(["({[", ")]}"]);
|
var doc = new Document(["({[", ")]}"]);
|
||||||
|
|
||||||
assertPosition(1, 0, doc.findMatchingBracket({row: 0, column: 1}));
|
assertPosition(1, 0, doc.findMatchingBracket({row: 0, column: 1}));
|
||||||
assertPosition(1, 2, doc.findMatchingBracket({row: 0, column: 2}));
|
assertPosition(1, 2, doc.findMatchingBracket({row: 0, column: 2}));
|
||||||
|
|
@ -41,7 +54,7 @@ var TextDocumentTest = new TestCase("TextDocumentTest", {
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: move lines down" : function() {
|
"test: move lines down" : function() {
|
||||||
var doc = new ace.Document(["1", "2", "3", "4"]);
|
var doc = new Document(["1", "2", "3", "4"]);
|
||||||
|
|
||||||
doc.moveLinesDown(0, 1);
|
doc.moveLinesDown(0, 1);
|
||||||
assertEquals(["3", "1", "2", "4"].join("\n"), doc.toString());
|
assertEquals(["3", "1", "2", "4"].join("\n"), doc.toString());
|
||||||
|
|
@ -57,7 +70,7 @@ var TextDocumentTest = new TestCase("TextDocumentTest", {
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: move lines up" : function() {
|
"test: move lines up" : function() {
|
||||||
var doc = new ace.Document(["1", "2", "3", "4"]);
|
var doc = new Document(["1", "2", "3", "4"]);
|
||||||
|
|
||||||
doc.moveLinesUp(2, 3);
|
doc.moveLinesUp(2, 3);
|
||||||
assertEquals(["1", "3", "4", "2"].join("\n"), doc.toString());
|
assertEquals(["1", "3", "4", "2"].join("\n"), doc.toString());
|
||||||
|
|
@ -73,70 +86,70 @@ var TextDocumentTest = new TestCase("TextDocumentTest", {
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: duplicate lines" : function() {
|
"test: duplicate lines" : function() {
|
||||||
var doc = new ace.Document(["1", "2", "3", "4"]);
|
var doc = new Document(["1", "2", "3", "4"]);
|
||||||
|
|
||||||
doc.duplicateLines(1, 2);
|
doc.duplicateLines(1, 2);
|
||||||
assertEquals(["1", "2", "3", "2", "3", "4"].join("\n"), doc.toString());
|
assertEquals(["1", "2", "3", "2", "3", "4"].join("\n"), doc.toString());
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: duplicate last line" : function() {
|
"test: duplicate last line" : function() {
|
||||||
var doc = new ace.Document(["1", "2", "3"]);
|
var doc = new Document(["1", "2", "3"]);
|
||||||
|
|
||||||
doc.duplicateLines(2, 2);
|
doc.duplicateLines(2, 2);
|
||||||
assertEquals(["1", "2", "3", "3"].join("\n"), doc.toString());
|
assertEquals(["1", "2", "3", "3"].join("\n"), doc.toString());
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: duplicate first line" : function() {
|
"test: duplicate first line" : function() {
|
||||||
var doc = new ace.Document(["1", "2", "3"]);
|
var doc = new Document(["1", "2", "3"]);
|
||||||
|
|
||||||
doc.duplicateLines(0, 0);
|
doc.duplicateLines(0, 0);
|
||||||
assertEquals(["1", "1", "2", "3"].join("\n"), doc.toString());
|
assertEquals(["1", "1", "2", "3"].join("\n"), doc.toString());
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: should handle unix style new lines" : function() {
|
"test: should handle unix style new lines" : function() {
|
||||||
var doc = new ace.Document(["1", "2", "3"]);
|
var doc = new Document(["1", "2", "3"]);
|
||||||
assertEquals(["1", "2", "3"].join("\n"), doc.toString());
|
assertEquals(["1", "2", "3"].join("\n"), doc.toString());
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: should handle windows style new lines" : function() {
|
"test: should handle windows style new lines" : function() {
|
||||||
var doc = new ace.Document(["1", "2", "3"].join("\r\n"));
|
var doc = new Document(["1", "2", "3"].join("\r\n"));
|
||||||
doc.setNewLineMode("unix");
|
doc.setNewLineMode("unix");
|
||||||
assertEquals(["1", "2", "3"].join("\n"), doc.toString());
|
assertEquals(["1", "2", "3"].join("\n"), doc.toString());
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: set new line mode to 'windows' should use '\r\n' as new lines": function() {
|
"test: set new line mode to 'windows' should use '\r\n' as new lines": function() {
|
||||||
var doc = new ace.Document(["1", "2", "3"].join("\n"));
|
var doc = new Document(["1", "2", "3"].join("\n"));
|
||||||
doc.setNewLineMode("windows");
|
doc.setNewLineMode("windows");
|
||||||
assertEquals(["1", "2", "3"].join("\r\n"), doc.toString());
|
assertEquals(["1", "2", "3"].join("\r\n"), doc.toString());
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: set new line mode to 'unix' should use '\n' as new lines": function() {
|
"test: set new line mode to 'unix' should use '\n' as new lines": function() {
|
||||||
var doc = new ace.Document(["1", "2", "3"].join("\r\n"));
|
var doc = new Document(["1", "2", "3"].join("\r\n"));
|
||||||
doc.setNewLineMode("unix");
|
doc.setNewLineMode("unix");
|
||||||
assertEquals(["1", "2", "3"].join("\n"), doc.toString());
|
assertEquals(["1", "2", "3"].join("\n"), doc.toString());
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: set new line mode to 'auto' should use detect the incoming nl type": function() {
|
"test: set new line mode to 'auto' should use detect the incoming nl type": function() {
|
||||||
var doc = new ace.Document(["1", "2", "3"].join("\n"));
|
var doc = new Document(["1", "2", "3"].join("\n"));
|
||||||
doc.setNewLineMode("auto");
|
doc.setNewLineMode("auto");
|
||||||
assertEquals(["1", "2", "3"].join("\n"), doc.toString());
|
assertEquals(["1", "2", "3"].join("\n"), doc.toString());
|
||||||
|
|
||||||
var doc = new ace.Document(["1", "2", "3"].join("\r\n"));
|
var doc = new Document(["1", "2", "3"].join("\r\n"));
|
||||||
doc.setNewLineMode("auto");
|
doc.setNewLineMode("auto");
|
||||||
assertEquals(["1", "2", "3"].join("\r\n"), doc.toString());
|
assertEquals(["1", "2", "3"].join("\r\n"), doc.toString());
|
||||||
|
|
||||||
doc.replace(new ace.Range(0, 0, 2, 1), ["4", "5", "6"].join("\n"));
|
doc.replace(new Range(0, 0, 2, 1), ["4", "5", "6"].join("\n"));
|
||||||
assertEquals(["4", "5", "6"].join("\n"), doc.toString());
|
assertEquals(["4", "5", "6"].join("\n"), doc.toString());
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: undo/redo for delete line" : function() {
|
"test: undo/redo for delete line" : function() {
|
||||||
var doc = new ace.Document(["111", "222", "333"]);
|
var doc = new Document(["111", "222", "333"]);
|
||||||
var undoManager = new ace.UndoManager();
|
var undoManager = new UndoManager();
|
||||||
doc.setUndoManager(undoManager);
|
doc.setUndoManager(undoManager);
|
||||||
|
|
||||||
var initialText = doc.toString();
|
var initialText = doc.toString();
|
||||||
|
|
||||||
var editor = new ace.Editor(new MockRenderer(), doc);
|
var editor = new Editor(new MockRenderer(), doc);
|
||||||
|
|
||||||
editor.removeLines();
|
editor.removeLines();
|
||||||
var step1 = doc.toString();
|
var step1 = doc.toString();
|
||||||
|
|
@ -172,7 +185,7 @@ var TextDocumentTest = new TestCase("TextDocumentTest", {
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: convert document to screen coordinates" : function() {
|
"test: convert document to screen coordinates" : function() {
|
||||||
var doc = new ace.Document("01234\t567890\t1234");
|
var doc = new Document("01234\t567890\t1234");
|
||||||
doc.setTabSize(4);
|
doc.setTabSize(4);
|
||||||
|
|
||||||
assertEquals(0, doc.documentToScreenColumn(0, 0));
|
assertEquals(0, doc.documentToScreenColumn(0, 0));
|
||||||
|
|
@ -193,7 +206,7 @@ var TextDocumentTest = new TestCase("TextDocumentTest", {
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: convert document to scrren coordinates with leading tabs": function() {
|
"test: convert document to scrren coordinates with leading tabs": function() {
|
||||||
var doc = new ace.Document("\t\t123");
|
var doc = new Document("\t\t123");
|
||||||
doc.setTabSize(4);
|
doc.setTabSize(4);
|
||||||
|
|
||||||
assertEquals(0, doc.documentToScreenColumn(0, 0));
|
assertEquals(0, doc.documentToScreenColumn(0, 0));
|
||||||
|
|
@ -203,7 +216,7 @@ var TextDocumentTest = new TestCase("TextDocumentTest", {
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: convert screen to document coordinates" : function() {
|
"test: convert screen to document coordinates" : function() {
|
||||||
var doc = new ace.Document("01234\t567890\t1234");
|
var doc = new Document("01234\t567890\t1234");
|
||||||
doc.setTabSize(4);
|
doc.setTabSize(4);
|
||||||
|
|
||||||
assertEquals(0, doc.screenToDocumentColumn(0, 0));
|
assertEquals(0, doc.screenToDocumentColumn(0, 0));
|
||||||
|
|
@ -216,4 +229,6 @@ var TextDocumentTest = new TestCase("TextDocumentTest", {
|
||||||
assertEquals(12, doc.screenToDocumentColumn(0, 15));
|
assertEquals(12, doc.screenToDocumentColumn(0, 15));
|
||||||
assertEquals(13, doc.screenToDocumentColumn(0, 19));
|
assertEquals(13, doc.screenToDocumentColumn(0, 19));
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
@ -5,9 +5,18 @@
|
||||||
* @license LGPLv3 <http://www.gnu.org/licenses/lgpl-3.0.txt>
|
* @license LGPLv3 <http://www.gnu.org/licenses/lgpl-3.0.txt>
|
||||||
* @author Fabian Jakobs <fabian AT ajax DOT org>
|
* @author Fabian Jakobs <fabian AT ajax DOT org>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
require.def([
|
||||||
|
"ace/lib/oop",
|
||||||
|
"ace/MEventEmitter"
|
||||||
|
], function(
|
||||||
|
oop,
|
||||||
|
MEventEmitter
|
||||||
|
) {
|
||||||
|
|
||||||
var EventEmitter = function() {};
|
var EventEmitter = function() {};
|
||||||
|
|
||||||
ace.implement(EventEmitter.prototype, ace.MEventEmitter);
|
oop.implement(EventEmitter.prototype, MEventEmitter);
|
||||||
|
|
||||||
var EventEmitterTest = new TestCase("EventEmitterTest", {
|
var EventEmitterTest = new TestCase("EventEmitterTest", {
|
||||||
"test: dispatch event with no data" : function() {
|
"test: dispatch event with no data" : function() {
|
||||||
|
|
@ -22,4 +31,6 @@ var EventEmitterTest = new TestCase("EventEmitterTest", {
|
||||||
emitter.$dispatchEvent("juhu");
|
emitter.$dispatchEvent("juhu");
|
||||||
assertTrue(called);
|
assertTrue(called);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
@ -5,6 +5,9 @@
|
||||||
* @license LGPLv3 <http://www.gnu.org/licenses/lgpl-3.0.txt>
|
* @license LGPLv3 <http://www.gnu.org/licenses/lgpl-3.0.txt>
|
||||||
* @author Fabian Jakobs <fabian AT ajax DOT org>
|
* @author Fabian Jakobs <fabian AT ajax DOT org>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
require.def([], function() {
|
||||||
|
|
||||||
MockRenderer = function(visibleRowCount) {
|
MockRenderer = function(visibleRowCount) {
|
||||||
this.container = document.createElement("div");
|
this.container = document.createElement("div");
|
||||||
this.cursor = {
|
this.cursor = {
|
||||||
|
|
@ -80,3 +83,6 @@ MockRenderer.prototype.addMarker = function() {
|
||||||
|
|
||||||
MockRenderer.prototype.setBreakpoints = function() {
|
MockRenderer.prototype.setBreakpoints = function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
return MockRenderer;
|
||||||
|
});
|
||||||
|
|
@ -5,17 +5,28 @@
|
||||||
* @license LGPLv3 <http://www.gnu.org/licenses/lgpl-3.0.txt>
|
* @license LGPLv3 <http://www.gnu.org/licenses/lgpl-3.0.txt>
|
||||||
* @author Fabian Jakobs <fabian AT ajax DOT org>
|
* @author Fabian Jakobs <fabian AT ajax DOT org>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
require.def([
|
||||||
|
"ace/Document",
|
||||||
|
"ace/Editor",
|
||||||
|
"ace/test/MockRenderer"
|
||||||
|
], function(
|
||||||
|
Document,
|
||||||
|
Editor,
|
||||||
|
MockRenderer
|
||||||
|
) {
|
||||||
|
|
||||||
var NavigationTest = TestCase("NavigationTest",
|
var NavigationTest = TestCase("NavigationTest",
|
||||||
{
|
{
|
||||||
createTextDocument : function(rows, cols) {
|
createTextDocument : function(rows, cols) {
|
||||||
var line = new Array(cols + 1).join("a");
|
var line = new Array(cols + 1).join("a");
|
||||||
var text = new Array(rows).join(line + "\n") + line;
|
var text = new Array(rows).join(line + "\n") + line;
|
||||||
return new ace.Document(text);
|
return new Document(text);
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: navigate to end of file should scroll the last line into view" : function() {
|
"test: navigate to end of file should scroll the last line into view" : function() {
|
||||||
var doc = this.createTextDocument(200, 10);
|
var doc = this.createTextDocument(200, 10);
|
||||||
var editor = new ace.Editor(new MockRenderer(), doc);
|
var editor = new Editor(new MockRenderer(), doc);
|
||||||
|
|
||||||
editor.navigateFileEnd();
|
editor.navigateFileEnd();
|
||||||
var cursor = editor.getCursorPosition();
|
var cursor = editor.getCursorPosition();
|
||||||
|
|
@ -26,7 +37,7 @@ var NavigationTest = TestCase("NavigationTest",
|
||||||
|
|
||||||
"test: navigate to start of file should scroll the first row into view" : function() {
|
"test: navigate to start of file should scroll the first row into view" : function() {
|
||||||
var doc = this.createTextDocument(200, 10);
|
var doc = this.createTextDocument(200, 10);
|
||||||
var editor = new ace.Editor(new MockRenderer(), doc);
|
var editor = new Editor(new MockRenderer(), doc);
|
||||||
|
|
||||||
editor.moveCursorTo(editor.getLastVisibleRow() + 20);
|
editor.moveCursorTo(editor.getLastVisibleRow() + 20);
|
||||||
editor.navigateFileStart();
|
editor.navigateFileStart();
|
||||||
|
|
@ -35,7 +46,7 @@ var NavigationTest = TestCase("NavigationTest",
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: goto hidden line should scroll the line into the middle of the viewport" : function() {
|
"test: goto hidden line should scroll the line into the middle of the viewport" : function() {
|
||||||
var editor = new ace.Editor(new MockRenderer(), this.createTextDocument(200, 5));
|
var editor = new Editor(new MockRenderer(), this.createTextDocument(200, 5));
|
||||||
|
|
||||||
editor.navigateTo(0, 0);
|
editor.navigateTo(0, 0);
|
||||||
editor.gotoLine(101);
|
editor.gotoLine(101);
|
||||||
|
|
@ -69,7 +80,7 @@ var NavigationTest = TestCase("NavigationTest",
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: goto visible line should only move the cursor and not scroll": function() {
|
"test: goto visible line should only move the cursor and not scroll": function() {
|
||||||
var editor = new ace.Editor(new MockRenderer(), this.createTextDocument(200, 5));
|
var editor = new Editor(new MockRenderer(), this.createTextDocument(200, 5));
|
||||||
|
|
||||||
editor.navigateTo(0, 0);
|
editor.navigateTo(0, 0);
|
||||||
editor.gotoLine(12);
|
editor.gotoLine(12);
|
||||||
|
|
@ -83,7 +94,7 @@ var NavigationTest = TestCase("NavigationTest",
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: navigate from the end of a long line down to a short line and back should maintain the curser column": function() {
|
"test: navigate from the end of a long line down to a short line and back should maintain the curser column": function() {
|
||||||
var editor = new ace.Editor(new MockRenderer(), new ace.Document(["123456", "1"]));
|
var editor = new Editor(new MockRenderer(), new Document(["123456", "1"]));
|
||||||
|
|
||||||
editor.navigateTo(0, 6);
|
editor.navigateTo(0, 6);
|
||||||
assertPosition(0, 6, editor.getCursorPosition());
|
assertPosition(0, 6, editor.getCursorPosition());
|
||||||
|
|
@ -96,7 +107,7 @@ var NavigationTest = TestCase("NavigationTest",
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: reset desired column on navigate left or right": function() {
|
"test: reset desired column on navigate left or right": function() {
|
||||||
var editor = new ace.Editor(new MockRenderer(), new ace.Document(["123456", "12"]));
|
var editor = new Editor(new MockRenderer(), new Document(["123456", "12"]));
|
||||||
|
|
||||||
editor.navigateTo(0, 6);
|
editor.navigateTo(0, 6);
|
||||||
assertPosition(0, 6, editor.getCursorPosition());
|
assertPosition(0, 6, editor.getCursorPosition());
|
||||||
|
|
@ -110,4 +121,6 @@ var NavigationTest = TestCase("NavigationTest",
|
||||||
editor.navigateUp();
|
editor.navigateUp();
|
||||||
assertPosition(0, 1, editor.getCursorPosition());
|
assertPosition(0, 1, editor.getCursorPosition());
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
@ -5,10 +5,17 @@
|
||||||
* @license LGPLv3 <http://www.gnu.org/licenses/lgpl-3.0.txt>
|
* @license LGPLv3 <http://www.gnu.org/licenses/lgpl-3.0.txt>
|
||||||
* @author Fabian Jakobs <fabian AT ajax DOT org>
|
* @author Fabian Jakobs <fabian AT ajax DOT org>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
require.def([
|
||||||
|
"ace/Range"
|
||||||
|
], function(
|
||||||
|
Range
|
||||||
|
) {
|
||||||
|
|
||||||
RangeTest = new TestCase("RangeTest", {
|
RangeTest = new TestCase("RangeTest", {
|
||||||
|
|
||||||
"test: create range": function() {
|
"test: create range": function() {
|
||||||
var range = new ace.Range(1,2,3,4);
|
var range = new Range(1,2,3,4);
|
||||||
|
|
||||||
assertEquals(1, range.start.row);
|
assertEquals(1, range.start.row);
|
||||||
assertEquals(2, range.start.column);
|
assertEquals(2, range.start.column);
|
||||||
|
|
@ -17,7 +24,7 @@ RangeTest = new TestCase("RangeTest", {
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: create from points": function() {
|
"test: create from points": function() {
|
||||||
var range = ace.Range.fromPoints({row: 1, column: 2}, {row:3, column:4});
|
var range = Range.fromPoints({row: 1, column: 2}, {row:3, column:4});
|
||||||
|
|
||||||
assertEquals(1, range.start.row);
|
assertEquals(1, range.start.row);
|
||||||
assertEquals(2, range.start.column);
|
assertEquals(2, range.start.column);
|
||||||
|
|
@ -26,10 +33,10 @@ RangeTest = new TestCase("RangeTest", {
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: clip to rows": function() {
|
"test: clip to rows": function() {
|
||||||
assertRange(10, 0, 31, 0, new ace.Range(0, 20, 100, 30).clipRows(10, 30));
|
assertRange(10, 0, 31, 0, new Range(0, 20, 100, 30).clipRows(10, 30));
|
||||||
assertRange(10, 0, 30, 10, new ace.Range(0, 20, 30, 10).clipRows(10, 30));
|
assertRange(10, 0, 30, 10, new Range(0, 20, 30, 10).clipRows(10, 30));
|
||||||
|
|
||||||
var range = new ace.Range(0, 20, 3, 10);
|
var range = new Range(0, 20, 3, 10);
|
||||||
var range = range.clipRows(10, 30);
|
var range = range.clipRows(10, 30);
|
||||||
|
|
||||||
assertTrue(range.isEmpty());
|
assertTrue(range.isEmpty());
|
||||||
|
|
@ -37,23 +44,23 @@ RangeTest = new TestCase("RangeTest", {
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: isEmpty": function() {
|
"test: isEmpty": function() {
|
||||||
var range = new ace.Range(1, 2, 1, 2);
|
var range = new Range(1, 2, 1, 2);
|
||||||
assertTrue(range.isEmpty());
|
assertTrue(range.isEmpty());
|
||||||
|
|
||||||
var range = new ace.Range(1, 2, 1, 6);
|
var range = new Range(1, 2, 1, 6);
|
||||||
assertFalse(range.isEmpty());
|
assertFalse(range.isEmpty());
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: is multi line": function() {
|
"test: is multi line": function() {
|
||||||
var range = new ace.Range(1, 2, 1, 6);
|
var range = new Range(1, 2, 1, 6);
|
||||||
assertFalse(range.isMultiLine());
|
assertFalse(range.isMultiLine());
|
||||||
|
|
||||||
var range = new ace.Range(1, 2, 2, 6);
|
var range = new Range(1, 2, 2, 6);
|
||||||
assertTrue(range.isMultiLine());
|
assertTrue(range.isMultiLine());
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: clone": function() {
|
"test: clone": function() {
|
||||||
var range = new ace.Range(1, 2, 3, 4);
|
var range = new Range(1, 2, 3, 4);
|
||||||
var clone = range.clone();
|
var clone = range.clone();
|
||||||
|
|
||||||
assertPosition(1, 2, clone.start);
|
assertPosition(1, 2, clone.start);
|
||||||
|
|
@ -67,7 +74,7 @@ RangeTest = new TestCase("RangeTest", {
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: contains for multi line ranges": function() {
|
"test: contains for multi line ranges": function() {
|
||||||
var range = new ace.Range(1, 10, 5, 20);
|
var range = new Range(1, 10, 5, 20);
|
||||||
|
|
||||||
assertTrue(range.contains(1, 10));
|
assertTrue(range.contains(1, 10));
|
||||||
assertTrue(range.contains(2, 0));
|
assertTrue(range.contains(2, 0));
|
||||||
|
|
@ -81,7 +88,7 @@ RangeTest = new TestCase("RangeTest", {
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: contains for single line ranges": function() {
|
"test: contains for single line ranges": function() {
|
||||||
var range = new ace.Range(1, 10, 1, 20);
|
var range = new Range(1, 10, 1, 20);
|
||||||
|
|
||||||
assertTrue(range.contains(1, 10));
|
assertTrue(range.contains(1, 10));
|
||||||
assertTrue(range.contains(1, 15));
|
assertTrue(range.contains(1, 15));
|
||||||
|
|
@ -94,7 +101,7 @@ RangeTest = new TestCase("RangeTest", {
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: extend range": function() {
|
"test: extend range": function() {
|
||||||
var range = new ace.Range(2, 10, 2, 30);
|
var range = new Range(2, 10, 2, 30);
|
||||||
|
|
||||||
var range = range.extend(2, 5);
|
var range = range.extend(2, 5);
|
||||||
assertRange(2, 5, 2, 30, range);
|
assertRange(2, 5, 2, 30, range);
|
||||||
|
|
@ -111,4 +118,6 @@ RangeTest = new TestCase("RangeTest", {
|
||||||
var range = range.extend(6, 10);
|
var range = range.extend(6, 10);
|
||||||
assertRange(1, 4, 6, 10, range);
|
assertRange(1, 4, 6, 10, range);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
@ -5,19 +5,28 @@
|
||||||
* @license LGPLv3 <http://www.gnu.org/licenses/lgpl-3.0.txt>
|
* @license LGPLv3 <http://www.gnu.org/licenses/lgpl-3.0.txt>
|
||||||
* @author Fabian Jakobs <fabian AT ajax DOT org>
|
* @author Fabian Jakobs <fabian AT ajax DOT org>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
require.def([
|
||||||
|
"ace/Document",
|
||||||
|
"ace/Search"
|
||||||
|
], function(
|
||||||
|
Document,
|
||||||
|
Search
|
||||||
|
) {
|
||||||
|
|
||||||
var SearchTest = new TestCase("SearchTest", {
|
var SearchTest = new TestCase("SearchTest", {
|
||||||
|
|
||||||
"test: configure the search object" : function() {
|
"test: configure the search object" : function() {
|
||||||
var search = new ace.Search();
|
var search = new Search();
|
||||||
search.set({
|
search.set({
|
||||||
needle: "juhu",
|
needle: "juhu",
|
||||||
scope: ace.Search.ALL
|
scope: Search.ALL
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: find simple text in document" : function() {
|
"test: find simple text in document" : function() {
|
||||||
var doc = new ace.Document(["juhu kinners 123", "456"]);
|
var doc = new Document(["juhu kinners 123", "456"]);
|
||||||
var search = new ace.Search().set({
|
var search = new Search().set({
|
||||||
needle: "kinners"
|
needle: "kinners"
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -27,8 +36,8 @@ var SearchTest = new TestCase("SearchTest", {
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: find simple text in next line" : function() {
|
"test: find simple text in next line" : function() {
|
||||||
var doc = new ace.Document(["abc", "juhu kinners 123", "456"]);
|
var doc = new Document(["abc", "juhu kinners 123", "456"]);
|
||||||
var search = new ace.Search().set({
|
var search = new Search().set({
|
||||||
needle: "kinners"
|
needle: "kinners"
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -38,9 +47,9 @@ var SearchTest = new TestCase("SearchTest", {
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: find text starting at cursor position" : function() {
|
"test: find text starting at cursor position" : function() {
|
||||||
var doc = new ace.Document(["juhu kinners", "juhu kinners 123"]);
|
var doc = new Document(["juhu kinners", "juhu kinners 123"]);
|
||||||
doc.getSelection().moveCursorTo(0, 6);
|
doc.getSelection().moveCursorTo(0, 6);
|
||||||
var search = new ace.Search().set({
|
var search = new Search().set({
|
||||||
needle: "kinners"
|
needle: "kinners"
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -50,10 +59,10 @@ var SearchTest = new TestCase("SearchTest", {
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: wrap search is off by default" : function() {
|
"test: wrap search is off by default" : function() {
|
||||||
var doc = new ace.Document(["abc", "juhu kinners 123", "456"]);
|
var doc = new Document(["abc", "juhu kinners 123", "456"]);
|
||||||
doc.getSelection().moveCursorTo(2, 1);
|
doc.getSelection().moveCursorTo(2, 1);
|
||||||
|
|
||||||
var search = new ace.Search().set({
|
var search = new Search().set({
|
||||||
needle: "kinners"
|
needle: "kinners"
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -61,10 +70,10 @@ var SearchTest = new TestCase("SearchTest", {
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: wrap search should wrap at file end" : function() {
|
"test: wrap search should wrap at file end" : function() {
|
||||||
var doc = new ace.Document(["abc", "juhu kinners 123", "456"]);
|
var doc = new Document(["abc", "juhu kinners 123", "456"]);
|
||||||
doc.getSelection().moveCursorTo(2, 1);
|
doc.getSelection().moveCursorTo(2, 1);
|
||||||
|
|
||||||
var search = new ace.Search().set({
|
var search = new Search().set({
|
||||||
needle: "kinners",
|
needle: "kinners",
|
||||||
wrap: true
|
wrap: true
|
||||||
});
|
});
|
||||||
|
|
@ -75,10 +84,10 @@ var SearchTest = new TestCase("SearchTest", {
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: wrap search with no match should return 'null'": function() {
|
"test: wrap search with no match should return 'null'": function() {
|
||||||
var doc = new ace.Document(["abc", "juhu kinners 123", "456"]);
|
var doc = new Document(["abc", "juhu kinners 123", "456"]);
|
||||||
doc.getSelection().moveCursorTo(2, 1);
|
doc.getSelection().moveCursorTo(2, 1);
|
||||||
|
|
||||||
var search = new ace.Search().set({
|
var search = new Search().set({
|
||||||
needle: "xyz",
|
needle: "xyz",
|
||||||
wrap: true
|
wrap: true
|
||||||
});
|
});
|
||||||
|
|
@ -87,9 +96,9 @@ var SearchTest = new TestCase("SearchTest", {
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: case sensitive is by default off": function() {
|
"test: case sensitive is by default off": function() {
|
||||||
var doc = new ace.Document(["abc", "juhu kinners 123", "456"]);
|
var doc = new Document(["abc", "juhu kinners 123", "456"]);
|
||||||
|
|
||||||
var search = new ace.Search().set({
|
var search = new Search().set({
|
||||||
needle: "JUHU"
|
needle: "JUHU"
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -97,9 +106,9 @@ var SearchTest = new TestCase("SearchTest", {
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: case sensitive search": function() {
|
"test: case sensitive search": function() {
|
||||||
var doc = new ace.Document(["abc", "juhu kinners 123", "456"]);
|
var doc = new Document(["abc", "juhu kinners 123", "456"]);
|
||||||
|
|
||||||
var search = new ace.Search().set({
|
var search = new Search().set({
|
||||||
needle: "KINNERS",
|
needle: "KINNERS",
|
||||||
caseSensitive: true
|
caseSensitive: true
|
||||||
});
|
});
|
||||||
|
|
@ -110,9 +119,9 @@ var SearchTest = new TestCase("SearchTest", {
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: whole word search should not match inside of words": function() {
|
"test: whole word search should not match inside of words": function() {
|
||||||
var doc = new ace.Document(["juhukinners", "juhu kinners 123", "456"]);
|
var doc = new Document(["juhukinners", "juhu kinners 123", "456"]);
|
||||||
|
|
||||||
var search = new ace.Search().set({
|
var search = new Search().set({
|
||||||
needle: "kinners",
|
needle: "kinners",
|
||||||
wholeWord: true
|
wholeWord: true
|
||||||
});
|
});
|
||||||
|
|
@ -123,9 +132,9 @@ var SearchTest = new TestCase("SearchTest", {
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: find backwards": function() {
|
"test: find backwards": function() {
|
||||||
var doc = new ace.Document(["juhu juhu juhu juhu"]);
|
var doc = new Document(["juhu juhu juhu juhu"]);
|
||||||
doc.getSelection().moveCursorTo(0, 10);
|
doc.getSelection().moveCursorTo(0, 10);
|
||||||
var search = new ace.Search().set({
|
var search = new Search().set({
|
||||||
needle: "juhu",
|
needle: "juhu",
|
||||||
backwards: true
|
backwards: true
|
||||||
});
|
});
|
||||||
|
|
@ -136,14 +145,14 @@ var SearchTest = new TestCase("SearchTest", {
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: find in selection": function() {
|
"test: find in selection": function() {
|
||||||
var doc = new ace.Document(["juhu", "juhu", "juhu", "juhu"]);
|
var doc = new Document(["juhu", "juhu", "juhu", "juhu"]);
|
||||||
doc.getSelection().setSelectionAnchor(1, 0);
|
doc.getSelection().setSelectionAnchor(1, 0);
|
||||||
doc.getSelection().selectTo(3, 5);
|
doc.getSelection().selectTo(3, 5);
|
||||||
|
|
||||||
var search = new ace.Search().set({
|
var search = new Search().set({
|
||||||
needle: "juhu",
|
needle: "juhu",
|
||||||
wrap: true,
|
wrap: true,
|
||||||
scope: ace.Search.SELECTION
|
scope: Search.SELECTION
|
||||||
});
|
});
|
||||||
|
|
||||||
var range = search.find(doc);
|
var range = search.find(doc);
|
||||||
|
|
@ -159,13 +168,13 @@ var SearchTest = new TestCase("SearchTest", {
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: find backwards in selection": function() {
|
"test: find backwards in selection": function() {
|
||||||
var doc = new ace.Document(["juhu", "juhu", "juhu", "juhu"]);
|
var doc = new Document(["juhu", "juhu", "juhu", "juhu"]);
|
||||||
|
|
||||||
var search = new ace.Search().set({
|
var search = new Search().set({
|
||||||
needle: "juhu",
|
needle: "juhu",
|
||||||
wrap: true,
|
wrap: true,
|
||||||
backwards: true,
|
backwards: true,
|
||||||
scope: ace.Search.SELECTION
|
scope: Search.SELECTION
|
||||||
});
|
});
|
||||||
|
|
||||||
doc.getSelection().setSelectionAnchor(0, 2);
|
doc.getSelection().setSelectionAnchor(0, 2);
|
||||||
|
|
@ -182,9 +191,9 @@ var SearchTest = new TestCase("SearchTest", {
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: edge case - match directly before the cursor" : function() {
|
"test: edge case - match directly before the cursor" : function() {
|
||||||
var doc = new ace.Document(["123", "123", "juhu"]);
|
var doc = new Document(["123", "123", "juhu"]);
|
||||||
|
|
||||||
var search = new ace.Search().set({
|
var search = new Search().set({
|
||||||
needle: "juhu",
|
needle: "juhu",
|
||||||
wrap: true
|
wrap: true
|
||||||
});
|
});
|
||||||
|
|
@ -197,9 +206,9 @@ var SearchTest = new TestCase("SearchTest", {
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: edge case - match backwards directly after the cursor" : function() {
|
"test: edge case - match backwards directly after the cursor" : function() {
|
||||||
var doc = new ace.Document(["123", "123", "juhu"]);
|
var doc = new Document(["123", "123", "juhu"]);
|
||||||
|
|
||||||
var search = new ace.Search().set({
|
var search = new Search().set({
|
||||||
needle: "juhu",
|
needle: "juhu",
|
||||||
wrap: true,
|
wrap: true,
|
||||||
backwards: true
|
backwards: true
|
||||||
|
|
@ -213,9 +222,9 @@ var SearchTest = new TestCase("SearchTest", {
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: find using a regular expression" : function() {
|
"test: find using a regular expression" : function() {
|
||||||
var doc = new ace.Document(["abc123 123 cd", "abc"]);
|
var doc = new Document(["abc123 123 cd", "abc"]);
|
||||||
|
|
||||||
var search = new ace.Search().set({
|
var search = new Search().set({
|
||||||
needle: "\\d+",
|
needle: "\\d+",
|
||||||
regExp: true
|
regExp: true
|
||||||
});
|
});
|
||||||
|
|
@ -226,9 +235,9 @@ var SearchTest = new TestCase("SearchTest", {
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: find using a regular expression and whole word" : function() {
|
"test: find using a regular expression and whole word" : function() {
|
||||||
var doc = new ace.Document(["abc123 123 cd", "abc"]);
|
var doc = new Document(["abc123 123 cd", "abc"]);
|
||||||
|
|
||||||
var search = new ace.Search().set({
|
var search = new Search().set({
|
||||||
needle: "\\d+\\b",
|
needle: "\\d+\\b",
|
||||||
regExp: true,
|
regExp: true,
|
||||||
wholeWord: true
|
wholeWord: true
|
||||||
|
|
@ -240,9 +249,9 @@ var SearchTest = new TestCase("SearchTest", {
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: use regular expressions with capture groups": function() {
|
"test: use regular expressions with capture groups": function() {
|
||||||
var doc = new ace.Document([" ab: 12px", " <h1 abc"]);
|
var doc = new Document([" ab: 12px", " <h1 abc"]);
|
||||||
|
|
||||||
var search = new ace.Search().set({
|
var search = new Search().set({
|
||||||
needle: "(\\d+)",
|
needle: "(\\d+)",
|
||||||
regExp: true
|
regExp: true
|
||||||
});
|
});
|
||||||
|
|
@ -253,12 +262,12 @@ var SearchTest = new TestCase("SearchTest", {
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: find all matches in selection" : function() {
|
"test: find all matches in selection" : function() {
|
||||||
var doc = new ace.Document(["juhu", "juhu", "juhu", "juhu"]);
|
var doc = new Document(["juhu", "juhu", "juhu", "juhu"]);
|
||||||
|
|
||||||
var search = new ace.Search().set({
|
var search = new Search().set({
|
||||||
needle: "uh",
|
needle: "uh",
|
||||||
wrap: true,
|
wrap: true,
|
||||||
scope: ace.Search.SELECTION
|
scope: Search.SELECTION
|
||||||
});
|
});
|
||||||
|
|
||||||
doc.getSelection().setSelectionAnchor(0, 2);
|
doc.getSelection().setSelectionAnchor(0, 2);
|
||||||
|
|
@ -274,7 +283,7 @@ var SearchTest = new TestCase("SearchTest", {
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: replace() should return the replacement if the input matches the needle" : function() {
|
"test: replace() should return the replacement if the input matches the needle" : function() {
|
||||||
var search = new ace.Search().set({
|
var search = new Search().set({
|
||||||
needle: "juhu"
|
needle: "juhu"
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -286,7 +295,7 @@ var SearchTest = new TestCase("SearchTest", {
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: replace with a RegExp search" : function() {
|
"test: replace with a RegExp search" : function() {
|
||||||
var search = new ace.Search().set({
|
var search = new Search().set({
|
||||||
needle: "\\d+",
|
needle: "\\d+",
|
||||||
regExp: true
|
regExp: true
|
||||||
});
|
});
|
||||||
|
|
@ -299,7 +308,7 @@ var SearchTest = new TestCase("SearchTest", {
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: replace with RegExp match and capture groups" : function() {
|
"test: replace with RegExp match and capture groups" : function() {
|
||||||
var search = new ace.Search().set({
|
var search = new Search().set({
|
||||||
needle: "ab(\\d\\d)",
|
needle: "ab(\\d\\d)",
|
||||||
regExp: true
|
regExp: true
|
||||||
});
|
});
|
||||||
|
|
@ -308,4 +317,6 @@ var SearchTest = new TestCase("SearchTest", {
|
||||||
assertEquals("-ab12-", search.replace("ab12", "-$&-"));
|
assertEquals("-ab12-", search.replace("ab12", "-$&-"));
|
||||||
assertEquals("$", search.replace("ab12", "$$"));
|
assertEquals("$", search.replace("ab12", "$$"));
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
@ -5,12 +5,19 @@
|
||||||
* @license LGPLv3 <http://www.gnu.org/licenses/lgpl-3.0.txt>
|
* @license LGPLv3 <http://www.gnu.org/licenses/lgpl-3.0.txt>
|
||||||
* @author Fabian Jakobs <fabian AT ajax DOT org>
|
* @author Fabian Jakobs <fabian AT ajax DOT org>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
require.def([
|
||||||
|
"ace/Document"
|
||||||
|
], function(
|
||||||
|
Document
|
||||||
|
) {
|
||||||
|
|
||||||
var SelectionTest = TestCase("SelectionTest",
|
var SelectionTest = TestCase("SelectionTest",
|
||||||
{
|
{
|
||||||
createTextDocument : function(rows, cols) {
|
createTextDocument : function(rows, cols) {
|
||||||
var line = new Array(cols + 1).join("a");
|
var line = new Array(cols + 1).join("a");
|
||||||
var text = new Array(rows).join(line + "\n") + line;
|
var text = new Array(rows).join(line + "\n") + line;
|
||||||
return new ace.Document(text);
|
return new Document(text);
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: move cursor to end of file should place the cursor on last row and column" : function() {
|
"test: move cursor to end of file should place the cursor on last row and column" : function() {
|
||||||
|
|
@ -56,7 +63,7 @@ var SelectionTest = TestCase("SelectionTest",
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: move cursor word right" : function() {
|
"test: move cursor word right" : function() {
|
||||||
var doc = new ace.Document( ["ab",
|
var doc = new Document( ["ab",
|
||||||
" Juhu Kinners (abc, 12)", " cde"].join("\n"));
|
" Juhu Kinners (abc, 12)", " cde"].join("\n"));
|
||||||
var selection = doc.getSelection();
|
var selection = doc.getSelection();
|
||||||
|
|
||||||
|
|
@ -96,7 +103,7 @@ var SelectionTest = TestCase("SelectionTest",
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: select word right if cursor in word" : function() {
|
"test: select word right if cursor in word" : function() {
|
||||||
var doc = new ace.Document("Juhu Kinners");
|
var doc = new Document("Juhu Kinners");
|
||||||
var selection = doc.getSelection();
|
var selection = doc.getSelection();
|
||||||
|
|
||||||
selection.moveCursorTo(0, 2);
|
selection.moveCursorTo(0, 2);
|
||||||
|
|
@ -106,7 +113,7 @@ var SelectionTest = TestCase("SelectionTest",
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: moveCursor word left" : function() {
|
"test: moveCursor word left" : function() {
|
||||||
var doc = new ace.Document( ["ab",
|
var doc = new Document( ["ab",
|
||||||
" Juhu Kinners (abc, 12)", " cde"].join("\n"));
|
" Juhu Kinners (abc, 12)", " cde"].join("\n"));
|
||||||
var selection = doc.getSelection();
|
var selection = doc.getSelection();
|
||||||
|
|
||||||
|
|
@ -147,7 +154,7 @@ var SelectionTest = TestCase("SelectionTest",
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: select word left if cursor in word" : function() {
|
"test: select word left if cursor in word" : function() {
|
||||||
var doc = new ace.Document("Juhu Kinners");
|
var doc = new Document("Juhu Kinners");
|
||||||
var selection = doc.getSelection();
|
var selection = doc.getSelection();
|
||||||
|
|
||||||
selection.moveCursorTo(0, 8);
|
selection.moveCursorTo(0, 8);
|
||||||
|
|
@ -157,7 +164,7 @@ var SelectionTest = TestCase("SelectionTest",
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: select word right and select" : function() {
|
"test: select word right and select" : function() {
|
||||||
var doc = new ace.Document("Juhu Kinners");
|
var doc = new Document("Juhu Kinners");
|
||||||
var selection = doc.getSelection();
|
var selection = doc.getSelection();
|
||||||
|
|
||||||
selection.moveCursorTo(0, 0);
|
selection.moveCursorTo(0, 0);
|
||||||
|
|
@ -170,7 +177,7 @@ var SelectionTest = TestCase("SelectionTest",
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: select word left and select" : function() {
|
"test: select word left and select" : function() {
|
||||||
var doc = new ace.Document("Juhu Kinners");
|
var doc = new Document("Juhu Kinners");
|
||||||
var selection = doc.getSelection();
|
var selection = doc.getSelection();
|
||||||
|
|
||||||
selection.moveCursorTo(0, 3);
|
selection.moveCursorTo(0, 3);
|
||||||
|
|
@ -183,7 +190,7 @@ var SelectionTest = TestCase("SelectionTest",
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: select word with cursor in word should select the word" : function() {
|
"test: select word with cursor in word should select the word" : function() {
|
||||||
var doc = new ace.Document("Juhu Kinners 123");
|
var doc = new Document("Juhu Kinners 123");
|
||||||
var selection = doc.getSelection();
|
var selection = doc.getSelection();
|
||||||
|
|
||||||
selection.moveCursorTo(0, 8);
|
selection.moveCursorTo(0, 8);
|
||||||
|
|
@ -195,7 +202,7 @@ var SelectionTest = TestCase("SelectionTest",
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: select word with cursor betwen white space and word should select the word" : function() {
|
"test: select word with cursor betwen white space and word should select the word" : function() {
|
||||||
var doc = new ace.Document("Juhu Kinners");
|
var doc = new Document("Juhu Kinners");
|
||||||
var selection = doc.getSelection();
|
var selection = doc.getSelection();
|
||||||
|
|
||||||
selection.moveCursorTo(0, 4);
|
selection.moveCursorTo(0, 4);
|
||||||
|
|
@ -214,7 +221,7 @@ var SelectionTest = TestCase("SelectionTest",
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: select word with cursor in white space should select white space" : function() {
|
"test: select word with cursor in white space should select white space" : function() {
|
||||||
var doc = new ace.Document("Juhu Kinners");
|
var doc = new Document("Juhu Kinners");
|
||||||
var selection = doc.getSelection();
|
var selection = doc.getSelection();
|
||||||
|
|
||||||
selection.moveCursorTo(0, 5);
|
selection.moveCursorTo(0, 5);
|
||||||
|
|
@ -226,7 +233,7 @@ var SelectionTest = TestCase("SelectionTest",
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: moving cursor should fire a 'changeCursor' event" : function() {
|
"test: moving cursor should fire a 'changeCursor' event" : function() {
|
||||||
var doc = new ace.Document("Juhu Kinners");
|
var doc = new Document("Juhu Kinners");
|
||||||
var selection = doc.getSelection();
|
var selection = doc.getSelection();
|
||||||
|
|
||||||
selection.moveCursorTo(0, 5);
|
selection.moveCursorTo(0, 5);
|
||||||
|
|
@ -241,7 +248,7 @@ var SelectionTest = TestCase("SelectionTest",
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: calling setCursor with the same position should not fire an event": function() {
|
"test: calling setCursor with the same position should not fire an event": function() {
|
||||||
var doc = new ace.Document("Juhu Kinners");
|
var doc = new Document("Juhu Kinners");
|
||||||
var selection = doc.getSelection();
|
var selection = doc.getSelection();
|
||||||
|
|
||||||
selection.moveCursorTo(0, 5);
|
selection.moveCursorTo(0, 5);
|
||||||
|
|
@ -254,4 +261,6 @@ var SelectionTest = TestCase("SelectionTest",
|
||||||
selection.moveCursorTo(0, 5);
|
selection.moveCursorTo(0, 5);
|
||||||
assertFalse(called);
|
assertFalse(called);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
@ -5,11 +5,24 @@
|
||||||
* @license LGPLv3 <http://www.gnu.org/licenses/lgpl-3.0.txt>
|
* @license LGPLv3 <http://www.gnu.org/licenses/lgpl-3.0.txt>
|
||||||
* @author Fabian Jakobs <fabian AT ajax DOT org>
|
* @author Fabian Jakobs <fabian AT ajax DOT org>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
require.def([
|
||||||
|
"ace/Document",
|
||||||
|
"ace/Editor",
|
||||||
|
"ace/mode/JavaScript",
|
||||||
|
"ace/test/MockRenderer"
|
||||||
|
], function(
|
||||||
|
Document,
|
||||||
|
Editor,
|
||||||
|
JavaScriptMode,
|
||||||
|
MockRenderer
|
||||||
|
) {
|
||||||
|
|
||||||
var TextEditTest = TestCase("TextEditTest",
|
var TextEditTest = TestCase("TextEditTest",
|
||||||
{
|
{
|
||||||
"test: delete line from the middle" : function() {
|
"test: delete line from the middle" : function() {
|
||||||
var doc = new ace.Document(["a", "b", "c", "d"].join("\n"));
|
var doc = new Document(["a", "b", "c", "d"].join("\n"));
|
||||||
var editor = new ace.Editor(new MockRenderer(), doc);
|
var editor = new Editor(new MockRenderer(), doc);
|
||||||
|
|
||||||
editor.moveCursorTo(1, 1);
|
editor.moveCursorTo(1, 1);
|
||||||
editor.removeLines();
|
editor.removeLines();
|
||||||
|
|
@ -34,8 +47,8 @@ var TextEditTest = TestCase("TextEditTest",
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: delete multiple selected lines" : function() {
|
"test: delete multiple selected lines" : function() {
|
||||||
var doc = new ace.Document(["a", "b", "c", "d"].join("\n"));
|
var doc = new Document(["a", "b", "c", "d"].join("\n"));
|
||||||
var editor = new ace.Editor(new MockRenderer(), doc);
|
var editor = new Editor(new MockRenderer(), doc);
|
||||||
|
|
||||||
editor.moveCursorTo(1, 1);
|
editor.moveCursorTo(1, 1);
|
||||||
editor.getSelection().selectDown();
|
editor.getSelection().selectDown();
|
||||||
|
|
@ -46,8 +59,8 @@ var TextEditTest = TestCase("TextEditTest",
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: delete first line" : function() {
|
"test: delete first line" : function() {
|
||||||
var doc = new ace.Document(["a", "b", "c"].join("\n"));
|
var doc = new Document(["a", "b", "c"].join("\n"));
|
||||||
var editor = new ace.Editor(new MockRenderer(), doc);
|
var editor = new Editor(new MockRenderer(), doc);
|
||||||
|
|
||||||
editor.removeLines();
|
editor.removeLines();
|
||||||
|
|
||||||
|
|
@ -56,8 +69,8 @@ var TextEditTest = TestCase("TextEditTest",
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: delete last" : function() {
|
"test: delete last" : function() {
|
||||||
var doc = new ace.Document(["a", "b", "c"].join("\n"));
|
var doc = new Document(["a", "b", "c"].join("\n"));
|
||||||
var editor = new ace.Editor(new MockRenderer(), doc);
|
var editor = new Editor(new MockRenderer(), doc);
|
||||||
|
|
||||||
editor.moveCursorTo(2, 1);
|
editor.moveCursorTo(2, 1);
|
||||||
editor.removeLines();
|
editor.removeLines();
|
||||||
|
|
@ -67,8 +80,8 @@ var TextEditTest = TestCase("TextEditTest",
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: indent block" : function() {
|
"test: indent block" : function() {
|
||||||
var doc = new ace.Document(["a12345", "b12345", "c12345"].join("\n"));
|
var doc = new Document(["a12345", "b12345", "c12345"].join("\n"));
|
||||||
var editor = new ace.Editor(new MockRenderer(), doc);
|
var editor = new Editor(new MockRenderer(), doc);
|
||||||
|
|
||||||
editor.moveCursorTo(1, 3);
|
editor.moveCursorTo(1, 3);
|
||||||
editor.getSelection().selectDown();
|
editor.getSelection().selectDown();
|
||||||
|
|
@ -86,8 +99,8 @@ var TextEditTest = TestCase("TextEditTest",
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: outdent block" : function() {
|
"test: outdent block" : function() {
|
||||||
var doc = new ace.Document([" a12345", " b12345", " c12345"].join("\n"));
|
var doc = new Document([" a12345", " b12345", " c12345"].join("\n"));
|
||||||
var editor = new ace.Editor(new MockRenderer(), doc);
|
var editor = new Editor(new MockRenderer(), doc);
|
||||||
|
|
||||||
editor.moveCursorTo(0, 3);
|
editor.moveCursorTo(0, 3);
|
||||||
editor.getSelection().selectDown();
|
editor.getSelection().selectDown();
|
||||||
|
|
@ -114,8 +127,8 @@ var TextEditTest = TestCase("TextEditTest",
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: outent without a selection should update cursor" : function() {
|
"test: outent without a selection should update cursor" : function() {
|
||||||
var doc = new ace.Document(" 12");
|
var doc = new Document(" 12");
|
||||||
var editor = new ace.Editor(new MockRenderer(), doc);
|
var editor = new Editor(new MockRenderer(), doc);
|
||||||
|
|
||||||
editor.moveCursorTo(0, 3);
|
editor.moveCursorTo(0, 3);
|
||||||
editor.blockOutdent(" ");
|
editor.blockOutdent(" ");
|
||||||
|
|
@ -125,8 +138,8 @@ var TextEditTest = TestCase("TextEditTest",
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: comment lines should perserve selection" : function() {
|
"test: comment lines should perserve selection" : function() {
|
||||||
var doc = new ace.Document([" abc", "cde"].join("\n"), new ace.mode.JavaScript());
|
var doc = new Document([" abc", "cde"].join("\n"), new JavaScriptMode());
|
||||||
var editor = new ace.Editor(new MockRenderer(), doc);
|
var editor = new Editor(new MockRenderer(), doc);
|
||||||
|
|
||||||
editor.moveCursorTo(0, 2);
|
editor.moveCursorTo(0, 2);
|
||||||
editor.getSelection().selectDown();
|
editor.getSelection().selectDown();
|
||||||
|
|
@ -141,8 +154,8 @@ var TextEditTest = TestCase("TextEditTest",
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: uncomment lines should perserve selection" : function() {
|
"test: uncomment lines should perserve selection" : function() {
|
||||||
var doc = new ace.Document(["// abc", "//cde"].join("\n"), new ace.mode.JavaScript());
|
var doc = new Document(["// abc", "//cde"].join("\n"), new JavaScriptMode());
|
||||||
var editor = new ace.Editor(new MockRenderer(), doc);
|
var editor = new Editor(new MockRenderer(), doc);
|
||||||
|
|
||||||
editor.moveCursorTo(0, 1);
|
editor.moveCursorTo(0, 1);
|
||||||
editor.getSelection().selectDown();
|
editor.getSelection().selectDown();
|
||||||
|
|
@ -157,8 +170,8 @@ var TextEditTest = TestCase("TextEditTest",
|
||||||
|
|
||||||
"test: comment lines - if the selection end is at the line start it should stay there": function() {
|
"test: comment lines - if the selection end is at the line start it should stay there": function() {
|
||||||
//select down
|
//select down
|
||||||
var doc = new ace.Document(["abc", "cde"].join("\n"), new ace.mode.JavaScript());
|
var doc = new Document(["abc", "cde"].join("\n"), new JavaScriptMode());
|
||||||
var editor = new ace.Editor(new MockRenderer(), doc);
|
var editor = new Editor(new MockRenderer(), doc);
|
||||||
|
|
||||||
editor.moveCursorTo(0, 0);
|
editor.moveCursorTo(0, 0);
|
||||||
editor.getSelection().selectDown();
|
editor.getSelection().selectDown();
|
||||||
|
|
@ -167,8 +180,8 @@ var TextEditTest = TestCase("TextEditTest",
|
||||||
assertRange(0, 2, 1, 0, editor.getSelectionRange());
|
assertRange(0, 2, 1, 0, editor.getSelectionRange());
|
||||||
|
|
||||||
// select up
|
// select up
|
||||||
var doc = new ace.Document(["abc", "cde"].join("\n"), new ace.mode.JavaScript());
|
var doc = new Document(["abc", "cde"].join("\n"), new JavaScriptMode());
|
||||||
var editor = new ace.Editor(new MockRenderer(), doc);
|
var editor = new Editor(new MockRenderer(), doc);
|
||||||
|
|
||||||
editor.moveCursorTo(1, 0);
|
editor.moveCursorTo(1, 0);
|
||||||
editor.getSelection().selectUp();
|
editor.getSelection().selectUp();
|
||||||
|
|
@ -178,8 +191,8 @@ var TextEditTest = TestCase("TextEditTest",
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: move lines down should select moved lines" : function() {
|
"test: move lines down should select moved lines" : function() {
|
||||||
var doc = new ace.Document(["11", "22", "33", "44"].join("\n"));
|
var doc = new Document(["11", "22", "33", "44"].join("\n"));
|
||||||
var editor = new ace.Editor(new MockRenderer(), doc);
|
var editor = new Editor(new MockRenderer(), doc);
|
||||||
|
|
||||||
editor.moveCursorTo(0, 1);
|
editor.moveCursorTo(0, 1);
|
||||||
editor.getSelection().selectDown();
|
editor.getSelection().selectDown();
|
||||||
|
|
@ -205,8 +218,8 @@ var TextEditTest = TestCase("TextEditTest",
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: move lines up should select moved lines" : function() {
|
"test: move lines up should select moved lines" : function() {
|
||||||
var doc = new ace.Document(["11", "22", "33", "44"].join("\n"));
|
var doc = new Document(["11", "22", "33", "44"].join("\n"));
|
||||||
var editor = new ace.Editor(new MockRenderer(), doc);
|
var editor = new Editor(new MockRenderer(), doc);
|
||||||
|
|
||||||
editor.moveCursorTo(2, 1);
|
editor.moveCursorTo(2, 1);
|
||||||
editor.getSelection().selectDown();
|
editor.getSelection().selectDown();
|
||||||
|
|
@ -226,8 +239,8 @@ var TextEditTest = TestCase("TextEditTest",
|
||||||
|
|
||||||
"test: move line without active selection should move cursor to start of the moved line" : function()
|
"test: move line without active selection should move cursor to start of the moved line" : function()
|
||||||
{
|
{
|
||||||
var doc = new ace.Document(["11", "22", "33", "44"].join("\n"));
|
var doc = new Document(["11", "22", "33", "44"].join("\n"));
|
||||||
var editor = new ace.Editor(new MockRenderer(), doc);
|
var editor = new Editor(new MockRenderer(), doc);
|
||||||
|
|
||||||
editor.moveCursorTo(1, 1);
|
editor.moveCursorTo(1, 1);
|
||||||
editor.clearSelection();
|
editor.clearSelection();
|
||||||
|
|
@ -244,8 +257,8 @@ var TextEditTest = TestCase("TextEditTest",
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: copy lines down should select lines and place cursor at the selection start" : function() {
|
"test: copy lines down should select lines and place cursor at the selection start" : function() {
|
||||||
var doc = new ace.Document(["11", "22", "33", "44"].join("\n"));
|
var doc = new Document(["11", "22", "33", "44"].join("\n"));
|
||||||
var editor = new ace.Editor(new MockRenderer(), doc);
|
var editor = new Editor(new MockRenderer(), doc);
|
||||||
|
|
||||||
editor.moveCursorTo(1, 1);
|
editor.moveCursorTo(1, 1);
|
||||||
editor.getSelection().selectDown();
|
editor.getSelection().selectDown();
|
||||||
|
|
@ -259,8 +272,8 @@ var TextEditTest = TestCase("TextEditTest",
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: copy lines up should select lines and place cursor at the selection start" : function() {
|
"test: copy lines up should select lines and place cursor at the selection start" : function() {
|
||||||
var doc = new ace.Document(["11", "22", "33", "44"].join("\n"));
|
var doc = new Document(["11", "22", "33", "44"].join("\n"));
|
||||||
var editor = new ace.Editor(new MockRenderer(), doc);
|
var editor = new Editor(new MockRenderer(), doc);
|
||||||
|
|
||||||
editor.moveCursorTo(1, 1);
|
editor.moveCursorTo(1, 1);
|
||||||
editor.getSelection().selectDown();
|
editor.getSelection().selectDown();
|
||||||
|
|
@ -274,8 +287,8 @@ var TextEditTest = TestCase("TextEditTest",
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: input a tab with soft tab should convert it to spaces" : function() {
|
"test: input a tab with soft tab should convert it to spaces" : function() {
|
||||||
var doc = new ace.Document("");
|
var doc = new Document("");
|
||||||
var editor = new ace.Editor(new MockRenderer(), doc);
|
var editor = new Editor(new MockRenderer(), doc);
|
||||||
|
|
||||||
doc.setTabSize(2);
|
doc.setTabSize(2);
|
||||||
doc.setUseSoftTabs(true);
|
doc.setUseSoftTabs(true);
|
||||||
|
|
@ -289,12 +302,14 @@ var TextEditTest = TestCase("TextEditTest",
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: input tab without soft tabs should keep the tab character" : function() {
|
"test: input tab without soft tabs should keep the tab character" : function() {
|
||||||
var doc = new ace.Document("");
|
var doc = new Document("");
|
||||||
var editor = new ace.Editor(new MockRenderer(), doc);
|
var editor = new Editor(new MockRenderer(), doc);
|
||||||
|
|
||||||
doc.setUseSoftTabs(false);
|
doc.setUseSoftTabs(false);
|
||||||
|
|
||||||
editor.onTextInput("\t");
|
editor.onTextInput("\t");
|
||||||
assertEquals("\t", doc.toString());
|
assertEquals("\t", doc.toString());
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
@ -5,6 +5,15 @@
|
||||||
* @license LGPLv3 <http://www.gnu.org/licenses/lgpl-3.0.txt>
|
* @license LGPLv3 <http://www.gnu.org/licenses/lgpl-3.0.txt>
|
||||||
* @author Fabian Jakobs <fabian AT ajax DOT org>
|
* @author Fabian Jakobs <fabian AT ajax DOT org>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
require.def([
|
||||||
|
"ace/Document",
|
||||||
|
"ace/VirtualRenderer"
|
||||||
|
], function(
|
||||||
|
Document,
|
||||||
|
VirtualRenderer
|
||||||
|
) {
|
||||||
|
|
||||||
var VirtualRendererTest = new TestCase("VirtualRendererTest", {
|
var VirtualRendererTest = new TestCase("VirtualRendererTest", {
|
||||||
|
|
||||||
"test: screen2text the column should be rounded to the next character edge" : function() {
|
"test: screen2text the column should be rounded to the next character edge" : function() {
|
||||||
|
|
@ -17,8 +26,8 @@ var VirtualRendererTest = new TestCase("VirtualRendererTest", {
|
||||||
document.body.style.padding = "0px";
|
document.body.style.padding = "0px";
|
||||||
document.body.appendChild(el);
|
document.body.appendChild(el);
|
||||||
|
|
||||||
var renderer = new ace.VirtualRenderer(el);
|
var renderer = new VirtualRenderer(el);
|
||||||
renderer.setDocument(new ace.Document("1234"));
|
renderer.setDocument(new Document("1234"));
|
||||||
|
|
||||||
renderer.characterWidth = 10;
|
renderer.characterWidth = 10;
|
||||||
renderer.lineHeight = 15;
|
renderer.lineHeight = 15;
|
||||||
|
|
@ -33,6 +42,7 @@ var VirtualRendererTest = new TestCase("VirtualRendererTest", {
|
||||||
document.body.removeChild(el);
|
document.body.removeChild(el);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// change tab size after setDocument (for text layer)
|
// change tab size after setDocument (for text layer)
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
11
src/ace/test/all.js
Normal file
11
src/ace/test/all.js
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
require({
|
||||||
|
paths: {
|
||||||
|
"ace": "../src/ace"
|
||||||
|
}},
|
||||||
|
["ace/test/assertions", "ace/test/ChangeDocumentTest"],
|
||||||
|
function(a) {
|
||||||
|
console.log(a)
|
||||||
|
alert("a " + a)
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
|
@ -5,16 +5,21 @@
|
||||||
* @license LGPLv3 <http://www.gnu.org/licenses/lgpl-3.0.txt>
|
* @license LGPLv3 <http://www.gnu.org/licenses/lgpl-3.0.txt>
|
||||||
* @author Fabian Jakobs <fabian AT ajax DOT org>
|
* @author Fabian Jakobs <fabian AT ajax DOT org>
|
||||||
*/
|
*/
|
||||||
assertPosition = function(row, column, cursor) {
|
|
||||||
|
require.def([], function() {
|
||||||
|
|
||||||
|
window.assertPosition = function(row, column, cursor) {
|
||||||
assertEquals(row, cursor.row);
|
assertEquals(row, cursor.row);
|
||||||
assertEquals(column, cursor.column);
|
assertEquals(column, cursor.column);
|
||||||
};
|
};
|
||||||
|
|
||||||
assertRange = function(startRow, startColumn, endRow, endColumn, range) {
|
window.assertRange = function(startRow, startColumn, endRow, endColumn, range) {
|
||||||
assertPosition(startRow, startColumn, range.start);
|
assertPosition(startRow, startColumn, range.start);
|
||||||
assertPosition(endRow, endColumn, range.end);
|
assertPosition(endRow, endColumn, range.end);
|
||||||
};
|
};
|
||||||
|
|
||||||
assertJsonEquals = function(expectedJson, foundJson) {
|
window.assertJsonEquals = function(expectedJson, foundJson) {
|
||||||
assertEquals(JSON.stringify(expectedJson), JSON.stringify(foundJson));
|
assertEquals(JSON.stringify(expectedJson), JSON.stringify(foundJson));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
});
|
||||||
|
|
@ -5,16 +5,27 @@
|
||||||
* @license LGPLv3 <http://www.gnu.org/licenses/lgpl-3.0.txt>
|
* @license LGPLv3 <http://www.gnu.org/licenses/lgpl-3.0.txt>
|
||||||
* @author Fabian Jakobs <fabian AT ajax DOT org>
|
* @author Fabian Jakobs <fabian AT ajax DOT org>
|
||||||
*/
|
*/
|
||||||
var CssTest = new TestCase("mode.CssTest", {
|
|
||||||
|
require.def([
|
||||||
|
"ace/Document",
|
||||||
|
"ace/Range",
|
||||||
|
"ace/mode/Css"
|
||||||
|
], function(
|
||||||
|
Document,
|
||||||
|
Range,
|
||||||
|
CssMode
|
||||||
|
) {
|
||||||
|
|
||||||
|
var CssTest = new TestCase("mode.CssTest", {
|
||||||
|
|
||||||
setUp : function() {
|
setUp : function() {
|
||||||
this.mode = new ace.mode.Css();
|
this.mode = new CssMode();
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: toggle comment lines should not do anything" : function() {
|
"test: toggle comment lines should not do anything" : function() {
|
||||||
var doc = new ace.Document([" abc", "cde", "fg"].join("\n"));
|
var doc = new Document([" abc", "cde", "fg"].join("\n"));
|
||||||
|
|
||||||
var range = new ace.Range(0, 3, 1, 1);
|
var range = new Range(0, 3, 1, 1);
|
||||||
var comment = this.mode.toggleCommentLines("start", doc, range);
|
var comment = this.mode.toggleCommentLines("start", doc, range);
|
||||||
assertEquals([" abc", "cde", "fg"].join("\n"), doc.toString());
|
assertEquals([" abc", "cde", "fg"].join("\n"), doc.toString());
|
||||||
},
|
},
|
||||||
|
|
@ -34,4 +45,6 @@ var CssTest = new TestCase("mode.CssTest", {
|
||||||
assertEquals(" ", this.mode.getNextLineIndent("start", " /*{", " "));
|
assertEquals(" ", this.mode.getNextLineIndent("start", " /*{", " "));
|
||||||
assertEquals(" ", this.mode.getNextLineIndent("start", " /*{ ", " "));
|
assertEquals(" ", this.mode.getNextLineIndent("start", " /*{ ", " "));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
@ -5,10 +5,17 @@
|
||||||
* @license LGPLv3 <http://www.gnu.org/licenses/lgpl-3.0.txt>
|
* @license LGPLv3 <http://www.gnu.org/licenses/lgpl-3.0.txt>
|
||||||
* @author Fabian Jakobs <fabian AT ajax DOT org>
|
* @author Fabian Jakobs <fabian AT ajax DOT org>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
require.def([
|
||||||
|
"ace/mode/Css"
|
||||||
|
], function(
|
||||||
|
CssMode
|
||||||
|
) {
|
||||||
|
|
||||||
var CssTest = new TestCase("mode.CssTest", {
|
var CssTest = new TestCase("mode.CssTest", {
|
||||||
|
|
||||||
setUp : function() {
|
setUp : function() {
|
||||||
this.tokenizer = new ace.mode.Css().getTokenizer();
|
this.tokenizer = new CssMode().getTokenizer();
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: tokenize pixel number" : function() {
|
"test: tokenize pixel number" : function() {
|
||||||
|
|
@ -41,4 +48,6 @@ var CssTest = new TestCase("mode.CssTest", {
|
||||||
assertEquals("text", tokens[1].type);
|
assertEquals("text", tokens[1].type);
|
||||||
assertEquals("rparen", tokens[2].type);
|
assertEquals("rparen", tokens[2].type);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
@ -5,16 +5,27 @@
|
||||||
* @license LGPLv3 <http://www.gnu.org/licenses/lgpl-3.0.txt>
|
* @license LGPLv3 <http://www.gnu.org/licenses/lgpl-3.0.txt>
|
||||||
* @author Fabian Jakobs <fabian AT ajax DOT org>
|
* @author Fabian Jakobs <fabian AT ajax DOT org>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
require.def([
|
||||||
|
"ace/Document",
|
||||||
|
"ace/Range",
|
||||||
|
"ace/mode/Html"
|
||||||
|
], function(
|
||||||
|
Document,
|
||||||
|
Range,
|
||||||
|
HtmlMode
|
||||||
|
) {
|
||||||
|
|
||||||
var HtmlTest = new TestCase("mode.HtmlTest", {
|
var HtmlTest = new TestCase("mode.HtmlTest", {
|
||||||
|
|
||||||
setUp : function() {
|
setUp : function() {
|
||||||
this.mode = new ace.mode.Html();
|
this.mode = new HtmlMode();
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: toggle comment lines should not do anything" : function() {
|
"test: toggle comment lines should not do anything" : function() {
|
||||||
var doc = new ace.Document([" abc", "cde", "fg"]);
|
var doc = new Document([" abc", "cde", "fg"]);
|
||||||
|
|
||||||
var range = new ace.Range(0, 3, 1, 1);
|
var range = new Range(0, 3, 1, 1);
|
||||||
var comment = this.mode.toggleCommentLines("start", doc, range);
|
var comment = this.mode.toggleCommentLines("start", doc, range);
|
||||||
assertEquals([" abc", "cde", "fg"].join("\n"), doc.toString());
|
assertEquals([" abc", "cde", "fg"].join("\n"), doc.toString());
|
||||||
},
|
},
|
||||||
|
|
@ -24,4 +35,6 @@ var HtmlTest = new TestCase("mode.HtmlTest", {
|
||||||
assertEquals("", this.mode.getNextLineIndent("start", "abc"));
|
assertEquals("", this.mode.getNextLineIndent("start", "abc"));
|
||||||
assertEquals("\t", this.mode.getNextLineIndent("start", "\tabc"));
|
assertEquals("\t", this.mode.getNextLineIndent("start", "\tabc"));
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
@ -5,10 +5,17 @@
|
||||||
* @license LGPLv3 <http://www.gnu.org/licenses/lgpl-3.0.txt>
|
* @license LGPLv3 <http://www.gnu.org/licenses/lgpl-3.0.txt>
|
||||||
* @author Fabian Jakobs <fabian AT ajax DOT org>
|
* @author Fabian Jakobs <fabian AT ajax DOT org>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
require.def([
|
||||||
|
"ace/mode/Html"
|
||||||
|
], function(
|
||||||
|
HtmlMode
|
||||||
|
) {
|
||||||
|
|
||||||
var HtmlTest = new TestCase("mode.HtmlTest", {
|
var HtmlTest = new TestCase("mode.HtmlTest", {
|
||||||
|
|
||||||
setUp : function() {
|
setUp : function() {
|
||||||
this.tokenizer = new ace.mode.Html().getTokenizer();
|
this.tokenizer = new HtmlMode().getTokenizer();
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: tokenize embedded script" : function() {
|
"test: tokenize embedded script" : function() {
|
||||||
|
|
@ -29,4 +36,6 @@ var HtmlTest = new TestCase("mode.HtmlTest", {
|
||||||
assertEquals("keyword", tokens[9].type);
|
assertEquals("keyword", tokens[9].type);
|
||||||
assertEquals("text", tokens[10].type);
|
assertEquals("text", tokens[10].type);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
@ -5,49 +5,62 @@
|
||||||
* @license LGPLv3 <http://www.gnu.org/licenses/lgpl-3.0.txt>
|
* @license LGPLv3 <http://www.gnu.org/licenses/lgpl-3.0.txt>
|
||||||
* @author Fabian Jakobs <fabian AT ajax DOT org>
|
* @author Fabian Jakobs <fabian AT ajax DOT org>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
require.def([
|
||||||
|
"ace/Document",
|
||||||
|
"ace/Range",
|
||||||
|
"ace/Tokenizer",
|
||||||
|
"ace/mode/JavaScript"
|
||||||
|
], function(
|
||||||
|
Document,
|
||||||
|
Range,
|
||||||
|
Tokenizer,
|
||||||
|
JavaScriptMode
|
||||||
|
) {
|
||||||
|
|
||||||
var JavaScriptTest = new TestCase("mode.JavaScriptTest", {
|
var JavaScriptTest = new TestCase("mode.JavaScriptTest", {
|
||||||
|
|
||||||
setUp : function() {
|
setUp : function() {
|
||||||
this.mode = new ace.mode.JavaScript();
|
this.mode = new JavaScriptMode();
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: getTokenizer() (smoke test)" : function() {
|
"test: getTokenizer() (smoke test)" : function() {
|
||||||
var tokenizer = this.mode.getTokenizer();
|
var tokenizer = this.mode.getTokenizer();
|
||||||
|
|
||||||
assertTrue(tokenizer instanceof ace.Tokenizer);
|
assertTrue(tokenizer instanceof Tokenizer);
|
||||||
|
|
||||||
var tokens = tokenizer.getLineTokens("'juhu'", "start").tokens;
|
var tokens = tokenizer.getLineTokens("'juhu'", "start").tokens;
|
||||||
assertEquals("string", tokens[0].type);
|
assertEquals("string", tokens[0].type);
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: toggle comment lines should prepend '//' to each line" : function() {
|
"test: toggle comment lines should prepend '//' to each line" : function() {
|
||||||
var doc = new ace.Document([" abc", "cde", "fg"]);
|
var doc = new Document([" abc", "cde", "fg"]);
|
||||||
|
|
||||||
var range = new ace.Range(0, 3, 1, 1);
|
var range = new Range(0, 3, 1, 1);
|
||||||
var comment = this.mode.toggleCommentLines("start", doc, range);
|
var comment = this.mode.toggleCommentLines("start", doc, range);
|
||||||
assertEquals(["// abc", "//cde", "fg"].join("\n"), doc.toString());
|
assertEquals(["// abc", "//cde", "fg"].join("\n"), doc.toString());
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: toggle comment on commented lines should remove leading '//' chars" : function() {
|
"test: toggle comment on commented lines should remove leading '//' chars" : function() {
|
||||||
var doc = new ace.Document(["// abc", "//cde", "fg"]);
|
var doc = new Document(["// abc", "//cde", "fg"]);
|
||||||
|
|
||||||
var range = new ace.Range(0, 3, 1, 1);
|
var range = new Range(0, 3, 1, 1);
|
||||||
var comment = this.mode.toggleCommentLines("start", doc, range);
|
var comment = this.mode.toggleCommentLines("start", doc, range);
|
||||||
assertEquals([" abc", "cde", "fg"].join("\n"), doc.toString());
|
assertEquals([" abc", "cde", "fg"].join("\n"), doc.toString());
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: toggle comment on multiple lines with one commented line prepend '//' to each line" : function() {
|
"test: toggle comment on multiple lines with one commented line prepend '//' to each line" : function() {
|
||||||
var doc = new ace.Document(["// abc", "//cde", "fg"]);
|
var doc = new Document(["// abc", "//cde", "fg"]);
|
||||||
|
|
||||||
var range = new ace.Range(0, 3, 2, 1);
|
var range = new Range(0, 3, 2, 1);
|
||||||
var comment = this.mode.toggleCommentLines("start", doc, range);
|
var comment = this.mode.toggleCommentLines("start", doc, range);
|
||||||
assertEquals(["//// abc", "////cde", "//fg"].join("\n"), doc.toString());
|
assertEquals(["//// abc", "////cde", "//fg"].join("\n"), doc.toString());
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: toggle comment on a comment line with leading white space": function() {
|
"test: toggle comment on a comment line with leading white space": function() {
|
||||||
var doc = new ace.Document(["//cde", " //fg"]);
|
var doc = new Document(["//cde", " //fg"]);
|
||||||
|
|
||||||
var range = new ace.Range(0, 3, 1, 1);
|
var range = new Range(0, 3, 1, 1);
|
||||||
var comment = this.mode.toggleCommentLines("start", doc, range);
|
var comment = this.mode.toggleCommentLines("start", doc, range);
|
||||||
assertEquals(["cde", " fg"].join("\n"), doc.toString());
|
assertEquals(["cde", " fg"].join("\n"), doc.toString());
|
||||||
},
|
},
|
||||||
|
|
@ -92,15 +105,17 @@ var JavaScriptTest = new TestCase("mode.JavaScriptTest", {
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: auto outdent should indent the line with the same indent as the line with the matching opening brace" : function() {
|
"test: auto outdent should indent the line with the same indent as the line with the matching opening brace" : function() {
|
||||||
var doc = new ace.Document([" function foo() {", " bla", " }"]);
|
var doc = new Document([" function foo() {", " bla", " }"]);
|
||||||
this.mode.autoOutdent("start", doc, 2);
|
this.mode.autoOutdent("start", doc, 2);
|
||||||
assertEquals(" }", doc.getLine(2));
|
assertEquals(" }", doc.getLine(2));
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: no auto outdent if no matching brace is found" : function() {
|
"test: no auto outdent if no matching brace is found" : function() {
|
||||||
var doc = new ace.Document([" function foo()", " bla", " }"]);
|
var doc = new Document([" function foo()", " bla", " }"]);
|
||||||
this.mode.autoOutdent("start", doc, 2);
|
this.mode.autoOutdent("start", doc, 2);
|
||||||
assertEquals(" }", doc.getLine(2));
|
assertEquals(" }", doc.getLine(2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
@ -5,10 +5,17 @@
|
||||||
* @license LGPLv3 <http://www.gnu.org/licenses/lgpl-3.0.txt>
|
* @license LGPLv3 <http://www.gnu.org/licenses/lgpl-3.0.txt>
|
||||||
* @author Fabian Jakobs <fabian AT ajax DOT org>
|
* @author Fabian Jakobs <fabian AT ajax DOT org>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
require.def([
|
||||||
|
"ace/mode/JavaScript"
|
||||||
|
], function(
|
||||||
|
JavaScriptMode
|
||||||
|
) {
|
||||||
|
|
||||||
var JavaScriptTokenizerTest = new TestCase("mode.JavaScriptTokenizerTest", {
|
var JavaScriptTokenizerTest = new TestCase("mode.JavaScriptTokenizerTest", {
|
||||||
|
|
||||||
setUp : function() {
|
setUp : function() {
|
||||||
this.tokenizer = new ace.mode.JavaScript().getTokenizer();
|
this.tokenizer = new JavaScriptMode().getTokenizer();
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: tokenize1" : function() {
|
"test: tokenize1" : function() {
|
||||||
|
|
@ -56,4 +63,6 @@ var JavaScriptTokenizerTest = new TestCase("mode.JavaScriptTokenizerTest", {
|
||||||
assertEquals("text", tokens[1].type);
|
assertEquals("text", tokens[1].type);
|
||||||
assertEquals("rparen", tokens[2].type);
|
assertEquals("rparen", tokens[2].type);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
@ -5,16 +5,27 @@
|
||||||
* @license LGPLv3 <http://www.gnu.org/licenses/lgpl-3.0.txt>
|
* @license LGPLv3 <http://www.gnu.org/licenses/lgpl-3.0.txt>
|
||||||
* @author Fabian Jakobs <fabian AT ajax DOT org>
|
* @author Fabian Jakobs <fabian AT ajax DOT org>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
require.def([
|
||||||
|
"ace/Document",
|
||||||
|
"ace/Range",
|
||||||
|
"ace/mode/Text"
|
||||||
|
], function(
|
||||||
|
Document,
|
||||||
|
Range,
|
||||||
|
TextMode
|
||||||
|
) {
|
||||||
|
|
||||||
var TextTest = new TestCase("mode.TextTest", {
|
var TextTest = new TestCase("mode.TextTest", {
|
||||||
|
|
||||||
setUp : function() {
|
setUp : function() {
|
||||||
this.mode = new ace.mode.Text();
|
this.mode = new TextMode();
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: toggle comment lines should not do anything" : function() {
|
"test: toggle comment lines should not do anything" : function() {
|
||||||
var doc = new ace.Document([" abc", "cde", "fg"]);
|
var doc = new Document([" abc", "cde", "fg"]);
|
||||||
|
|
||||||
var range = new ace.Range(0, 3, 1, 1);
|
var range = new Range(0, 3, 1, 1);
|
||||||
var comment = this.mode.toggleCommentLines("start", doc, range);
|
var comment = this.mode.toggleCommentLines("start", doc, range);
|
||||||
assertEquals([" abc", "cde", "fg"].join("\n"), doc.toString());
|
assertEquals([" abc", "cde", "fg"].join("\n"), doc.toString());
|
||||||
},
|
},
|
||||||
|
|
@ -23,4 +34,6 @@ var TextTest = new TestCase("mode.TextTest", {
|
||||||
"text: lines should not be indented" : function() {
|
"text: lines should not be indented" : function() {
|
||||||
assertEquals("", this.mode.getNextLineIndent("start", " abc", " "));
|
assertEquals("", this.mode.getNextLineIndent("start", " abc", " "));
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
@ -5,25 +5,38 @@
|
||||||
* @license LGPLv3 <http://www.gnu.org/licenses/lgpl-3.0.txt>
|
* @license LGPLv3 <http://www.gnu.org/licenses/lgpl-3.0.txt>
|
||||||
* @author Fabian Jakobs <fabian AT ajax DOT org>
|
* @author Fabian Jakobs <fabian AT ajax DOT org>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
require.def([
|
||||||
|
"ace/Document",
|
||||||
|
"ace/Range",
|
||||||
|
"ace/Tokenizer",
|
||||||
|
"ace/mode/Xml"
|
||||||
|
], function(
|
||||||
|
Document,
|
||||||
|
Range,
|
||||||
|
Tokenizer,
|
||||||
|
XmlMode
|
||||||
|
) {
|
||||||
|
|
||||||
var XmlTest = new TestCase("mode.XmlTest", {
|
var XmlTest = new TestCase("mode.XmlTest", {
|
||||||
|
|
||||||
setUp : function() {
|
setUp : function() {
|
||||||
this.mode = new ace.mode.Xml();
|
this.mode = new XmlMode();
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: getTokenizer() (smoke test)" : function() {
|
"test: getTokenizer() (smoke test)" : function() {
|
||||||
var tokenizer = this.mode.getTokenizer();
|
var tokenizer = this.mode.getTokenizer();
|
||||||
|
|
||||||
assertTrue(tokenizer instanceof ace.Tokenizer);
|
assertTrue(tokenizer instanceof Tokenizer);
|
||||||
|
|
||||||
var tokens = tokenizer.getLineTokens("<juhu>", "start").tokens;
|
var tokens = tokenizer.getLineTokens("<juhu>", "start").tokens;
|
||||||
assertEquals("keyword", tokens[1].type);
|
assertEquals("keyword", tokens[1].type);
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: toggle comment lines should not do anything" : function() {
|
"test: toggle comment lines should not do anything" : function() {
|
||||||
var doc = new ace.Document([" abc", "cde", "fg"]);
|
var doc = new Document([" abc", "cde", "fg"]);
|
||||||
|
|
||||||
var range = new ace.Range(0, 3, 1, 1);
|
var range = new Range(0, 3, 1, 1);
|
||||||
var comment = this.mode.toggleCommentLines("start", doc, range);
|
var comment = this.mode.toggleCommentLines("start", doc, range);
|
||||||
assertEquals([" abc", "cde", "fg"].join("\n"), doc.toString());
|
assertEquals([" abc", "cde", "fg"].join("\n"), doc.toString());
|
||||||
},
|
},
|
||||||
|
|
@ -33,4 +46,6 @@ var XmlTest = new TestCase("mode.XmlTest", {
|
||||||
assertEquals("", this.mode.getNextLineIndent("start", "abc"));
|
assertEquals("", this.mode.getNextLineIndent("start", "abc"));
|
||||||
assertEquals("\t", this.mode.getNextLineIndent("start", "\tabc"));
|
assertEquals("\t", this.mode.getNextLineIndent("start", "\tabc"));
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
@ -5,10 +5,17 @@
|
||||||
* @license LGPLv3 <http://www.gnu.org/licenses/lgpl-3.0.txt>
|
* @license LGPLv3 <http://www.gnu.org/licenses/lgpl-3.0.txt>
|
||||||
* @author Fabian Jakobs <fabian AT ajax DOT org>
|
* @author Fabian Jakobs <fabian AT ajax DOT org>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
require.def([
|
||||||
|
"ace/mode/Xml"
|
||||||
|
], function(
|
||||||
|
XmlMode
|
||||||
|
) {
|
||||||
|
|
||||||
var XmlTest = new TestCase("mode.XmlTest", {
|
var XmlTest = new TestCase("mode.XmlTest", {
|
||||||
|
|
||||||
setUp : function() {
|
setUp : function() {
|
||||||
this.tokenizer = new ace.mode.Xml().getTokenizer();
|
this.tokenizer = new XmlMode().getTokenizer();
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: tokenize1" : function() {
|
"test: tokenize1" : function() {
|
||||||
|
|
@ -23,4 +30,6 @@ var XmlTest = new TestCase("mode.XmlTest", {
|
||||||
assertEquals("keyword", tokens[3].type);
|
assertEquals("keyword", tokens[3].type);
|
||||||
assertEquals("text", tokens[4].type);
|
assertEquals("text", tokens[4].type);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
.ace-tm .ace_editor {
|
.ace-tm .ace_editor {
|
||||||
border: 2px solid rgb(159, 159, 159);
|
border: 2px solid rgb(159, 159, 159);
|
||||||
font-family: Monaco, "Courier New";
|
font-family: "Menlo", "Monaco", "Courier New", "Courier", monospace;
|
||||||
font-size: 12px;
|
font-size: 11px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.ace-tm .ace_editor.ace_focus {
|
.ace-tm .ace_editor.ace_focus {
|
||||||
|
|
@ -12,8 +12,8 @@
|
||||||
width: 50px;
|
width: 50px;
|
||||||
background: #e8e8e8;
|
background: #e8e8e8;
|
||||||
color: #333;
|
color: #333;
|
||||||
font-family: Monaco, "Courier New";
|
font-family: "Menlo", "Monaco", "Courier New", monospace;
|
||||||
font-size: 12px;
|
font-size: 11px;
|
||||||
overflow : hidden;
|
overflow : hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -60,6 +60,11 @@
|
||||||
color: rgb(6, 150, 14);
|
color: rgb(6, 150, 14);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.ace-tm .ace_line .ace_invalid {
|
||||||
|
background-color: rgb(153, 0, 0);
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
.ace-tm .ace_line .ace_buildin-function {
|
.ace-tm .ace_line .ace_buildin-function {
|
||||||
color: rgb(60, 76, 114);
|
color: rgb(60, 76, 114);
|
||||||
}
|
}
|
||||||
|
|
@ -73,7 +78,6 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.ace-tm .ace_line .ace_comment {
|
.ace-tm .ace_line .ace_comment {
|
||||||
font-style: italic;
|
|
||||||
color: rgb(76, 136, 107);
|
color: rgb(76, 136, 107);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue