diff --git a/Makefile.dryice.js b/Makefile.dryice.js index 6c55a5bd..4f56c016 100755 --- a/Makefile.dryice.js +++ b/Makefile.dryice.js @@ -4,7 +4,7 @@ * * Copyright (c) 2010, Ajax.org B.V. * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright @@ -15,7 +15,7 @@ * * Neither the name of Ajax.org B.V. nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE @@ -30,8 +30,11 @@ * ***** END LICENSE BLOCK ***** */ var fs = require("fs"); +var path = require("path"); if (!fs.existsSync) - fs.existsSync = require("path").existsSync; + fs.existsSync = path.existsSync; +else + path.existsSync = fs.existsSync; var copy = require('dryice').copy; var ACE_HOME = __dirname; @@ -44,7 +47,7 @@ function main(args) { return "-" + x; return x; }); - + if (args[2] && (args[2][0] != "-" || args[2].indexOf("h") != -1)) type = args[2]; @@ -66,8 +69,7 @@ function main(args) { } else if (type == "bm") { bookmarklet(); } else if (type == "full") { - ace(); - demo(); + demo(ace()); bookmarklet(); } } @@ -120,7 +122,7 @@ function ace() { console.log('# ace ---------'); // uncompressed - buildAce({ + var project = buildAce({ compress: false, noconflict: false }); @@ -153,9 +155,16 @@ function ace() { source: ACE_HOME + "/ChangeLog.txt", dest: BUILD_DIR + "/ChangeLog.txt" }); + + return project; } -function demo() { +function demo(project) { + project = project || buildAce({ + compress: false, + noconflict: false, + coreOnly: true + }); console.log('# kitchen sink ---------'); var version, ref; @@ -166,23 +175,26 @@ function demo() { ref = ""; version = ""; } - var changeComments = function(data) { - return (data - .replace(//g, "") - .replace(/PACKAGE\-\->|/g, "") + .replace(/PACKAGE\-\->| -1; i -= 1) { - if (func(ary[i], i, ary)) { + if (ary[i] && func(ary[i], i, ary)) { break; } } @@ -76,7 +78,7 @@ var requirejs, require, define; } function hasProp(obj, prop) { - return obj.hasOwnProperty(prop); + return hasOwn.call(obj, prop); } /** @@ -98,18 +100,23 @@ var requirejs, require, define; /** * Simple function to mix in properties from source into target, * but only if target does not already have a property of the same name. - * This is not robust in IE for transferring methods that match - * Object.prototype names, but the uses of mixin here seem unlikely to - * trigger a problem related to that. */ - function mixin(target, source, force) { + function mixin(target, source, force, deepStringMixin) { if (source) { eachProp(source, function (value, prop) { if (force || !hasProp(target, prop)) { - target[prop] = value; + if (deepStringMixin && typeof value !== 'string') { + if (!target[prop]) { + target[prop] = {}; + } + mixin(target[prop], value, force, deepStringMixin); + } else { + target[prop] = value; + } } }); } + return target; } //Similar to Function.prototype.bind, but the 'this' object is specified @@ -137,32 +144,6 @@ var requirejs, require, define; return g; } - function makeContextModuleFunc(func, relMap, enableBuildCallback) { - return function () { - //A version of a require function that passes a moduleName - //value for items that may need to - //look up paths relative to the moduleName - var args = aps.call(arguments, 0), lastArg; - if (enableBuildCallback && - isFunction((lastArg = args[args.length - 1]))) { - lastArg.__requireJsBuild = true; - } - args.push(relMap); - return func.apply(null, args); - }; - } - - function addRequireMethods(req, context, relMap) { - each([ - ['toUrl'], - ['undef'], - ['defined', 'requireDefined'], - ['specified', 'requireSpecified'] - ], function (item) { - req[item[0]] = makeContextModuleFunc(context[item[1] || item[0]], relMap); - }); - } - /** * Constructs an error with a pointer to an URL with more information. * @param {String} id the error ID that maps to an ID on a web page. @@ -204,28 +185,24 @@ var requirejs, require, define; } function newContext(contextName) { - var config = { + var inCheckLoaded, Module, context, handlers, + checkLoadedTimeoutId, + config = { waitSeconds: 7, baseUrl: './', paths: {}, pkgs: {}, - shim: {} + shim: {}, + map: {}, + config: {} }, registry = {}, undefEvents = {}, defQueue = [], defined = {}, - urlMap = {}, urlFetched = {}, requireCounter = 1, - unnormalizedCounter = 1, - //Used to track the order in which modules - //should be executed, by the order they - //load. Important for consistent cycle resolution - //behavior. - waitAry = [], - inCheckLoaded, Module, context, handlers, - checkLoadedTimeoutId; + unnormalizedCounter = 1; /** * Trims the . and .. from an array of path segments. @@ -238,7 +215,7 @@ var requirejs, require, define; */ function trimDots(ary) { var i, part; - for (i = 0; ary[i]; i+= 1) { + for (i = 0; ary[i]; i += 1) { part = ary[i]; if (part === '.') { ary.splice(i, 1); @@ -271,11 +248,12 @@ var requirejs, require, define; * @returns {String} normalized name */ function normalize(name, baseName, applyMap) { - var baseParts = baseName && baseName.split('/'), + var pkgName, pkgConfig, mapValue, nameParts, i, j, nameSegment, + foundMap, foundI, foundStarMap, starI, + baseParts = baseName && baseName.split('/'), + normalizedBaseParts = baseParts, map = config.map, - starMap = map && map['*'], - pkgName, pkgConfig, mapValue, nameParts, i, j, nameSegment, - foundMap; + starMap = map && map['*']; //Adjust any relative paths. if (name && name.charAt(0) === '.') { @@ -286,17 +264,17 @@ var requirejs, require, define; if (config.pkgs[baseName]) { //If the baseName is a package name, then just treat it as one //name to concat the name with. - baseParts = [baseName]; + normalizedBaseParts = baseParts = [baseName]; } else { //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. - baseParts = baseParts.slice(0, baseParts.length - 1); + normalizedBaseParts = baseParts.slice(0, baseParts.length - 1); } - name = baseParts.concat(name.split('/')); + name = normalizedBaseParts.concat(name.split('/')); trimDots(name); //Some use of packages may use a . path to reference the @@ -326,28 +304,41 @@ var requirejs, require, define; for (j = baseParts.length; j > 0; j -= 1) { mapValue = map[baseParts.slice(0, j).join('/')]; - //baseName segment has config, find if it has one for + //baseName segment has config, find if it has one for //this name. if (mapValue) { mapValue = mapValue[nameSegment]; if (mapValue) { //Match, update name to the new value. foundMap = mapValue; + foundI = i; break; } } } } - if (!foundMap && starMap && starMap[nameSegment]) { - foundMap = starMap[nameSegment]; - } - if (foundMap) { - nameParts.splice(0, i, foundMap); - name = nameParts.join('/'); break; } + + //Check for a star map match, but just hold on to it, + //if there is a shorter segment match later in a matching + //config, then favor over this star map. + if (!foundStarMap && starMap && starMap[nameSegment]) { + foundStarMap = starMap[nameSegment]; + starI = i; + } + } + + if (!foundMap && foundStarMap) { + foundMap = foundStarMap; + foundI = starI; + } + + if (foundMap) { + nameParts.splice(0, foundI, foundMap); + name = nameParts.join('/'); } } @@ -358,7 +349,7 @@ var requirejs, require, define; if (isBrowser) { each(scripts(), function (scriptNode) { if (scriptNode.getAttribute('data-requiremodule') === name && - scriptNode.getAttribute('data-requirecontext') === context.contextName) { + scriptNode.getAttribute('data-requirecontext') === context.contextName) { scriptNode.parentNode.removeChild(scriptNode); return true; } @@ -373,12 +364,25 @@ var requirejs, require, define; //Pop off the first array value, since it failed, and //retry pathConfig.shift(); - context.undef(id); + context.require.undef(id); context.require([id]); return true; } } + //Turns a plugin!resource to [plugin, resource] + //with the plugin being undefined if the name + //did not have a plugin prefix. + function splitPrefix(name) { + var prefix, + index = name ? name.indexOf('!') : -1; + if (index > -1) { + prefix = name.substring(0, index); + name = name.substring(index + 1, name.length); + } + return [prefix, name]; + } + /** * Creates a module mapping that includes plugin prefix, module * name, and path. If parentModuleMap is provided it will @@ -395,13 +399,12 @@ var requirejs, require, define; * @returns {Object} */ function makeModuleMap(name, parentModuleMap, isNormalized, applyMap) { - var index = name ? name.indexOf('!') : -1, + var url, pluginModule, suffix, nameParts, prefix = null, parentName = parentModuleMap ? parentModuleMap.name : null, originalName = name, isDefine = true, - normalizedName = '', - url, pluginModule, suffix; + normalizedName = ''; //If no name, then it means it is a require call, generate an //internal name. @@ -410,10 +413,9 @@ var requirejs, require, define; name = '_@r' + (requireCounter += 1); } - if (index !== -1) { - prefix = name.substring(0, index); - name = name.substring(index + 1, name.length); - } + nameParts = splitPrefix(name); + prefix = nameParts[0]; + name = nameParts[1]; if (prefix) { prefix = normalize(prefix, parentName, applyMap); @@ -435,22 +437,15 @@ var requirejs, require, define; //A regular module. normalizedName = normalize(name, parentName, applyMap); - url = urlMap[normalizedName]; - if (!url) { - //Calculate url for the module, if it has a name. - //Use name here since nameToUrl also calls normalize, - //and for relative names that are outside the baseUrl - //this causes havoc. Was thinking of just removing - //parentModuleMap to avoid extra normalization, but - //normalize() still does a dot removal because of - //issue #142, so just pass in name here and redo - //the normalization. Paths outside baseUrl are just - //messy to support. - url = context.nameToUrl(name, null, parentModuleMap); + //Normalized name may be a plugin ID due to map config + //application in normalize. The map config values must + //already be normalized, so do not need to redo that part. + nameParts = splitPrefix(normalizedName); + prefix = nameParts[0]; + normalizedName = nameParts[1]; + isNormalized = true; - //Store the URL mapping for later. - urlMap[normalizedName] = url; - } + url = context.nameToUrl(normalizedName); } } @@ -470,8 +465,8 @@ var requirejs, require, define; originalName: originalName, isDefine: isDefine, id: (prefix ? - prefix + '!' + normalizedName : - normalizedName) + suffix + prefix + '!' + normalizedName : + normalizedName) + suffix }; } @@ -491,7 +486,7 @@ var requirejs, require, define; mod = registry[id]; if (hasProp(defined, id) && - (!mod || mod.defineEmitComplete)) { + (!mod || mod.defineEmitComplete)) { if (name === 'defined') { fn(defined[id]); } @@ -541,163 +536,82 @@ var requirejs, require, define; } } - /** - * Helper function that creates a require function object to give to - * modules that ask for it as a dependency. It needs to be specific - * per module because of the implication of path mappings that may - * need to be relative to the module name. - */ - function makeRequire(mod, enableBuildCallback, altRequire) { - var relMap = mod && mod.map, - modRequire = makeContextModuleFunc(altRequire || context.require, - relMap, - enableBuildCallback); - - addRequireMethods(modRequire, context, relMap); - modRequire.isBrowser = isBrowser; - - return modRequire; - } - handlers = { 'require': function (mod) { - return makeRequire(mod); + if (mod.require) { + return mod.require; + } else { + return (mod.require = context.makeRequire(mod.map)); + } }, 'exports': function (mod) { mod.usingExports = true; if (mod.map.isDefine) { - return (mod.exports = defined[mod.map.id] = {}); + if (mod.exports) { + return mod.exports; + } else { + return (mod.exports = defined[mod.map.id] = {}); + } } }, 'module': function (mod) { - return (mod.module = { - id: mod.map.id, - uri: mod.map.url, - config: function () { - return (config.config && config.config[mod.map.id]) || {}; - }, - exports: defined[mod.map.id] - }); + if (mod.module) { + return mod.module; + } else { + return (mod.module = { + id: mod.map.id, + uri: mod.map.url, + config: function () { + return (config.config && config.config[mod.map.id]) || {}; + }, + exports: defined[mod.map.id] + }); + } } }; - function removeWaiting(id) { + function cleanRegistry(id) { //Clean up machinery used for waiting modules. delete registry[id]; - - each(waitAry, function (mod, i) { - if (mod.map.id === id) { - waitAry.splice(i, 1); - if (!mod.defined) { - context.waitCount -= 1; - } - return true; - } - }); } - function findCycle(mod, traced) { - var id = mod.map.id, - depArray = mod.depMaps, - foundModule; + function breakCycle(mod, traced, processed) { + var id = mod.map.id; - //Do not bother with unitialized modules or not yet enabled - //modules. - if (!mod.inited) { - return; - } + if (mod.error) { + mod.emit('error', mod.error); + } else { + traced[id] = true; + each(mod.depMaps, function (depMap, i) { + var depId = depMap.id, + dep = registry[depId]; - //Found the cycle. - if (traced[id]) { - return mod; - } - - traced[id] = true; - - //Trace through the dependencies. - each(depArray, function (depMap) { - var depId = depMap.id, - depMod = registry[depId]; - - if (!depMod) { - return; - } - - if (!depMod.inited || !depMod.enabled) { - //Dependency is not inited, so this cannot - //be used to determine a cycle. - foundModule = null; - delete traced[id]; - return true; - } - - return (foundModule = findCycle(depMod, traced)); - }); - - return foundModule; - } - - function forceExec(mod, traced, uninited) { - var id = mod.map.id, - depArray = mod.depMaps; - - if (!mod.inited || !mod.map.isDefine) { - return; - } - - if (traced[id]) { - return defined[id]; - } - - traced[id] = mod; - - each(depArray, function(depMap) { - var depId = depMap.id, - depMod = registry[depId], - value; - - if (handlers[depId]) { - return; - } - - if (depMod) { - if (!depMod.inited || !depMod.enabled) { - //Dependency is not inited, - //so this module cannot be - //given a forced value yet. - uninited[id] = true; - return; + //Only force things that have not completed + //being defined, so still in the registry, + //and only if it has not been matched up + //in the module already. + if (dep && !mod.depMatched[i] && !processed[depId]) { + if (traced[depId]) { + mod.defineDep(i, defined[depId]); + mod.check(); //pass false? + } else { + breakCycle(dep, traced, processed); + } } - - //Get the value for the current dependency - value = forceExec(depMod, traced, uninited); - - //Even with forcing it may not be done, - //in particular if the module is waiting - //on a plugin resource. - if (!uninited[depId]) { - mod.defineDepById(depId, value); - } - } - }); - - mod.check(true); - - return defined[id]; - } - - function modCheck(mod) { - mod.check(); + }); + processed[id] = true; + } } function checkLoaded() { - var waitInterval = config.waitSeconds * 1000, + var map, modId, err, usingPathFallback, + waitInterval = config.waitSeconds * 1000, //It is possible to disable the wait interval by using waitSeconds of 0. expired = waitInterval && (context.startTime + waitInterval) < new Date().getTime(), noLoads = [], + reqCalls = [], stillLoading = false, - needCycleCheck = true, - map, modId, err, usingPathFallback; + needCycleCheck = true; //Do not bother if this call was a result of a cycle break. if (inCheckLoaded) { @@ -716,6 +630,10 @@ var requirejs, require, define; return; } + if (!map.isDefine) { + reqCalls.push(mod); + } + if (!mod.error) { //If the module should be executed, and it has not //been inited and time is up, remember it. @@ -750,31 +668,9 @@ var requirejs, require, define; //Not expired, check for a cycle. if (needCycleCheck) { - - each(waitAry, function (mod) { - if (mod.defined) { - return; - } - - var cycleMod = findCycle(mod, {}), - traced = {}; - - if (cycleMod) { - forceExec(cycleMod, traced, {}); - - //traced modules may have been - //removed from the registry, but - //their listeners still need to - //be called. - eachProp(traced, modCheck); - } + each(reqCalls, function (mod) { + breakCycle(mod, {}, {}); }); - - //Now that dependencies have - //been satisfied, trigger the - //completion check that then - //notifies listeners. - eachProp(registry, modCheck); } //If still waiting on loads, and the waiting load is something @@ -811,7 +707,7 @@ var requirejs, require, define; }; Module.prototype = { - init: function(depMaps, factory, errback, options) { + init: function (depMaps, factory, errback, options) { options = options || {}; //Do not do more inits if already done. Can happen if there @@ -834,33 +730,14 @@ var requirejs, require, define; }); } - each(depMaps, bind(this, function (depMap, i) { - if (typeof depMap === 'string') { - depMap = makeModuleMap(depMap, - (this.map.isDefine ? this.map : this.map.parentMap), - false, - true); - this.depMaps.push(depMap); - } + //Do a copy of the dependency array, so that + //source inputs are not modified. For example + //"shim" deps are passed in here directly, and + //doing a direct modification of the depMaps array + //would affect that config. + this.depMaps = depMaps && depMaps.slice(0); - var handler = handlers[depMap.id]; - - if (handler) { - this.depExports[i] = handler(this); - return; - } - - this.depCount += 1; - - on(depMap, 'defined', bind(this, function (depExports) { - this.defineDep(i, depExports); - this.check(); - })); - - if (errback) { - on(depMap, 'error', errback); - } - })); + this.errback = errback; //Indicate this module has be initialized this.inited = true; @@ -880,20 +757,6 @@ var requirejs, require, define; } }, - defineDepById: function (id, depExports) { - var i; - - //Find the index for this dependency. - each(this.depMaps, function (map, index) { - if (map.id === id) { - i = index; - return true; - } - }); - - return this.defineDep(i, depExports); - }, - defineDep: function (i, depExports) { //Because of cycles, defined callback for a given //export can be called more than once. @@ -916,19 +779,19 @@ var requirejs, require, define; //If the manager is for a plugin managed resource, //ask the plugin to load it now. - if (map.prefix) { - this.callPlugin(); - } else if (this.shim) { - makeRequire(this, true)(this.shim.deps || [], bind(this, function () { - this.load(); + if (this.shim) { + context.makeRequire(this.map, { + enableBuildCallback: true + })(this.shim.deps || [], bind(this, function () { + return map.prefix ? this.callPlugin() : this.load(); })); } else { //Regular dependency. - this.load(); + return map.prefix ? this.callPlugin() : this.load(); } }, - load: function() { + load: function () { var url = this.map.url; //Regular dependency. @@ -940,20 +803,18 @@ var requirejs, require, define; /** * Checks is the module is ready to define itself, and if so, - * define it. If the silent argument is true, then it will just - * define, but not notify listeners, and not ask for a context-wide - * check of all loaded modules. That is useful for cycle breaking. + * define it. */ - check: function (silent) { - if (!this.enabled) { + check: function () { + if (!this.enabled || this.enabling) { return; } - var id = this.map.id, + var err, cjsModule, + id = this.map.id, depExports = this.depExports, exports = this.exports, - factory = this.factory, - err, cjsModule; + factory = this.factory; if (!this.inited) { this.fetch(); @@ -986,9 +847,9 @@ var requirejs, require, define; //favor a non-undefined return value over exports use. cjsModule = this.module; if (cjsModule && - cjsModule.exports !== undefined && - //Make sure it is not already the exports value - cjsModule.exports !== this.exports) { + cjsModule.exports !== undefined && + //Make sure it is not already the exports value + cjsModule.exports !== this.exports) { exports = cjsModule.exports; } else if (exports === undefined && this.usingExports) { //exports already set the defined value. @@ -1022,11 +883,6 @@ var requirejs, require, define; delete registry[id]; this.defined = true; - context.waitCount -= 1; - if (context.waitCount === 0) { - //Clear the wait array used for cycles. - waitAry = []; - } } //Finished the define stage. Allow calling check again @@ -1034,25 +890,33 @@ var requirejs, require, define; //cycle. this.defining = false; - if (!silent) { - if (this.defined && !this.defineEmitted) { - this.defineEmitted = true; - this.emit('defined', this.exports); - this.defineEmitComplete = true; - } + if (this.defined && !this.defineEmitted) { + this.defineEmitted = true; + this.emit('defined', this.exports); + this.defineEmitComplete = true; } + } }, - callPlugin: function() { + callPlugin: function () { var map = this.map, id = map.id, - pluginMap = makeModuleMap(map.prefix, null, false, true); + //Map already normalized the prefix. + pluginMap = makeModuleMap(map.prefix); + + //Mark this as a dependency for this plugin, so it + //can be traced for cycles. + this.depMaps.push(pluginMap); on(pluginMap, 'defined', bind(this, function (plugin) { - var name = this.map.name, + var load, normalizedMap, normalizedMod, + name = this.map.name, parentName = this.map.parentMap ? this.map.parentMap.name : null, - load, normalizedMap, normalizedMod; + localRequire = context.makeRequire(map.parentMap, { + enableBuildCallback: true, + skipMap: true + }); //If current map is not normalized, wait for that //normalized name to load instead of continuing. @@ -1064,16 +928,24 @@ var requirejs, require, define; }) || ''; } - normalizedMap = makeModuleMap(map.prefix + '!' + name); + //prefix and name should already be normalized, no need + //for applying map config again either. + normalizedMap = makeModuleMap(map.prefix + '!' + name, + this.map.parentMap); on(normalizedMap, - 'defined', bind(this, function (value) { - this.init([], function () { return value; }, null, { - enabled: true, - ignore: true - }); - })); + 'defined', bind(this, function (value) { + this.init([], function () { return value; }, null, { + enabled: true, + ignore: true + }); + })); + normalizedMod = registry[normalizedMap.id]; if (normalizedMod) { + //Mark this as a dependency for this plugin, so it + //can be traced for cycles. + this.depMaps.push(normalizedMap); + if (this.events.error) { normalizedMod.on('error', bind(this, function (err) { this.emit('error', err); @@ -1100,7 +972,7 @@ var requirejs, require, define; //since they will never be resolved otherwise now. eachProp(registry, function (mod) { if (mod.map.id.indexOf(id + '_unnormalized') === 0) { - removeWaiting(mod.map.id); + cleanRegistry(mod.map.id); } }); @@ -1109,9 +981,19 @@ var requirejs, require, define; //Allow plugins to load other code without having to know the //context or how to 'complete' the load. - load.fromText = function (moduleName, text) { + load.fromText = bind(this, function (text, textAlt) { /*jslint evil: true */ - var hasInteractive = useInteractive; + var moduleName = map.name, + moduleMap = makeModuleMap(moduleName), + hasInteractive = useInteractive; + + //As of 2.1.0, support just passing the text, to reinforce + //fromText only being called once per resource. Still + //support old style of passing moduleName but discard + //that moduleName in favor of the internal ref. + if (textAlt) { + text = textAlt; + } //Turn off interactive script matching for IE for any define //calls in the text, then turn it back on at the end. @@ -1119,22 +1001,37 @@ var requirejs, require, define; useInteractive = false; } - req.exec(text); + //Prime the system by creating a module instance for + //it. + getModule(moduleMap); + + try { + req.exec(text); + } catch (e) { + throw new Error('fromText eval for ' + moduleName + + ' failed: ' + e); + } if (hasInteractive) { useInteractive = true; } + //Mark this as a dependency for the plugin + //resource + this.depMaps.push(moduleMap); + //Support anonymous modules. context.completeLoad(moduleName); - }; + + //Bind the value of that module to the value for this + //resource ID. + localRequire([moduleName], load); + }); //Use parentName here since the plugin's name is not reliable, //could be some weird string with no path that actually wants to //reference the parentName's path. - plugin.load(map.name, makeRequire(map.parentMap, true, function (deps, cb) { - return context.require(deps, cb); - }), load, config); + plugin.load(map.name, localRequire, load, config); })); context.enable(pluginMap, this); @@ -1144,21 +1041,52 @@ var requirejs, require, define; enable: function () { this.enabled = true; - if (!this.waitPushed) { - waitAry.push(this); - context.waitCount += 1; - this.waitPushed = true; - } + //Set flag mentioning that the module is enabling, + //so that immediate calls to the defined callbacks + //for dependencies do not trigger inadvertent load + //with the depCount still being zero. + this.enabling = true; //Enable each dependency - each(this.depMaps, bind(this, function (map) { - var id = map.id, - mod = registry[id]; + each(this.depMaps, bind(this, function (depMap, i) { + var id, mod, handler; + + if (typeof depMap === 'string') { + //Dependency needs to be converted to a depMap + //and wired up to this module. + depMap = makeModuleMap(depMap, + (this.map.isDefine ? this.map : this.map.parentMap), + false, + !this.skipMap); + this.depMaps[i] = depMap; + + handler = handlers[depMap.id]; + + if (handler) { + this.depExports[i] = handler(this); + return; + } + + this.depCount += 1; + + on(depMap, 'defined', bind(this, function (depExports) { + this.defineDep(i, depExports); + this.check(); + })); + + if (this.errback) { + on(depMap, 'error', this.errback); + } + } + + id = depMap.id; + mod = registry[id]; + //Skip special modules like 'require', 'exports', 'module' //Also, don't call enable if it is already enabled, //important in circular dependency cases. if (!handlers[id] && mod && !mod.enabled) { - context.enable(map, this); + context.enable(depMap, this); } })); @@ -1171,10 +1099,12 @@ var requirejs, require, define; } })); + this.enabling = false; + this.check(); }, - on: function(name, cb) { + on: function (name, cb) { var cbs = this.events[name]; if (!cbs) { cbs = this.events[name] = []; @@ -1189,7 +1119,7 @@ var requirejs, require, define; if (name === 'error') { //Now that the error handler was triggered, remove //the listeners, since this broken Module instance - //can stay around for a while in the registry/waitAry. + //can stay around for a while in the registry. delete this.events[name]; } } @@ -1236,17 +1166,35 @@ var requirejs, require, define; }; } - return (context = { + function intakeDefines() { + var args; + + //Any defined modules in the global queue, intake them now. + takeGlobalQueue(); + + //Make sure any remaining defQueue items get properly processed. + while (defQueue.length) { + args = defQueue.shift(); + if (args[0] === null) { + return onError(makeError('mismatch', 'Mismatched anonymous define() module: ' + args[args.length - 1])); + } else { + //args are id, deps, factory. Should be normalized by the + //define() function. + callGetModule(args); + } + } + } + + context = { config: config, contextName: contextName, registry: registry, defined: defined, - urlMap: urlMap, urlFetched: urlFetched, - waitCount: 0, defQueue: defQueue, Module: Module, makeModuleMap: makeModuleMap, + nextTick: req.nextTick, /** * Set a configuration for the context. @@ -1262,24 +1210,25 @@ var requirejs, require, define; //Save off the paths and packages since they require special processing, //they are additive. - var paths = config.paths, - pkgs = config.pkgs, + var pkgs = config.pkgs, shim = config.shim, - map = config.map || {}; + objs = { + paths: true, + config: true, + map: true + }; - //Mix in the config values, favoring the new values over - //existing ones in context.config. - mixin(config, cfg, true); - - //Merge paths. - mixin(paths, cfg.paths, true); - config.paths = paths; - - //Merge map - if (cfg.map) { - mixin(map, cfg.map, true); - config.map = map; - } + eachProp(cfg, function (value, prop) { + if (objs[prop]) { + if (prop === 'map') { + mixin(config[prop], value, true, true); + } else { + mixin(config[prop], value, true); + } + } else { + config[prop] = value; + } + }); //Merge shim if (cfg.shim) { @@ -1290,8 +1239,8 @@ var requirejs, require, define; deps: value }; } - if (value.exports && !value.exports.__buildReady) { - value.exports = context.makeShimExports(value.exports); + if (value.exports && !value.exportsFn) { + value.exportsFn = context.makeShimExports(value); } shim[id] = value; }); @@ -1326,6 +1275,18 @@ var requirejs, require, define; config.pkgs = pkgs; } + //If there are any "waiting to execute" modules in the registry, + //update the maps for them, since their info, like URLs to load, + //may have changed. + eachProp(registry, function (mod, id) { + //If module already has init called, since it is too + //late to modify them, and ignore unnormalized ones + //since they are transient. + if (!mod.inited && !mod.map.unnormalized) { + mod.map = makeModuleMap(id); + } + }); + //If a deps array or a config callback is specified, then call //require with those args. This is useful when require is defined as a //config object before require.js is loaded. @@ -1334,122 +1295,144 @@ var requirejs, require, define; } }, - makeShimExports: function (exports) { - var func; - if (typeof exports === 'string') { - func = function () { - return getGlobal(exports); - }; - //Save the exports for use in nodefine checking. - func.exports = exports; - return func; - } else { - return function () { - return exports.apply(global, arguments); - }; + makeShimExports: function (value) { + function fn() { + var ret; + if (value.init) { + ret = value.init.apply(global, arguments); + } + return ret || getGlobal(value.exports); } + return fn; }, - requireDefined: function (id, relMap) { - return hasProp(defined, makeModuleMap(id, relMap, false, true).id); - }, + makeRequire: function (relMap, options) { + options = options || {}; - requireSpecified: function (id, relMap) { - id = makeModuleMap(id, relMap, false, true).id; - return hasProp(defined, id) || hasProp(registry, id); - }, + function localRequire(deps, callback, errback) { + var id, map, requireMod; - require: function (deps, callback, errback, relMap) { - var moduleName, id, map, requireMod, args; - if (typeof deps === 'string') { - if (isFunction(callback)) { - //Invalid call - return onError(makeError('requireargs', 'Invalid require call'), errback); + if (options.enableBuildCallback && callback && isFunction(callback)) { + callback.__requireJsBuild = true; } - //Synchronous access to one module. If require.get is - //available (as in the Node adapter), prefer that. - //In this case deps is the moduleName and callback is - //the relMap - if (req.get) { - return req.get(context, deps, callback); + if (typeof deps === 'string') { + if (isFunction(callback)) { + //Invalid call + return onError(makeError('requireargs', 'Invalid require call'), errback); + } + + //If require|exports|module are requested, get the + //value for them from the special handlers. Caveat: + //this only works while module is being defined. + if (relMap && handlers[deps]) { + return handlers[deps](registry[relMap.id]); + } + + //Synchronous access to one module. If require.get is + //available (as in the Node adapter), prefer that. + if (req.get) { + return req.get(context, deps, relMap); + } + + //Normalize module name, if it contains . or .. + map = makeModuleMap(deps, relMap, false, true); + id = map.id; + + if (!hasProp(defined, id)) { + return onError(makeError('notloaded', 'Module name "' + + id + + '" has not been loaded yet for context: ' + + contextName + + (relMap ? '' : '. Use require([])'))); + } + return defined[id]; } - //Just return the module wanted. In this scenario, the - //second arg (if passed) is just the relMap. - moduleName = deps; - relMap = callback; + //Grab defines waiting in the global queue. + intakeDefines(); - //Normalize module name, if it contains . or .. - map = makeModuleMap(moduleName, relMap, false, true); - id = map.id; + //Mark all the dependencies as needing to be loaded. + context.nextTick(function () { + //Some defines could have been added since the + //require call, collect them. + intakeDefines(); - if (!hasProp(defined, id)) { - return onError(makeError('notloaded', 'Module name "' + - id + - '" has not been loaded yet for context: ' + - contextName)); + requireMod = getModule(makeModuleMap(null, relMap)); + + //Store if map config should be applied to this require + //call for dependencies. + requireMod.skipMap = options.skipMap; + + requireMod.init(deps, callback, errback, { + enabled: true + }); + + checkLoaded(); + }); + + return localRequire; + } + + mixin(localRequire, { + isBrowser: isBrowser, + + /** + * Converts a module name + .extension into an URL path. + * *Requires* the use of a module name. It does not support using + * plain URLs like nameToUrl. + */ + toUrl: function (moduleNamePlusExt) { + var index = moduleNamePlusExt.lastIndexOf('.'), + ext = null; + + if (index !== -1) { + ext = moduleNamePlusExt.substring(index, moduleNamePlusExt.length); + moduleNamePlusExt = moduleNamePlusExt.substring(0, index); + } + + return context.nameToUrl(normalize(moduleNamePlusExt, + relMap && relMap.id, true), ext); + }, + + defined: function (id) { + return hasProp(defined, makeModuleMap(id, relMap, false, true).id); + }, + + specified: function (id) { + id = makeModuleMap(id, relMap, false, true).id; + return hasProp(defined, id) || hasProp(registry, id); } - return defined[id]; - } - - //Callback require. Normalize args. if callback or errback is - //not a function, it means it is a relMap. Test errback first. - if (errback && !isFunction(errback)) { - relMap = errback; - errback = undefined; - } - if (callback && !isFunction(callback)) { - relMap = callback; - callback = undefined; - } - - //Any defined modules in the global queue, intake them now. - takeGlobalQueue(); - - //Make sure any remaining defQueue items get properly processed. - while (defQueue.length) { - args = defQueue.shift(); - if (args[0] === null) { - return onError(makeError('mismatch', 'Mismatched anonymous define() module: ' + args[args.length - 1])); - } else { - //args are id, deps, factory. Should be normalized by the - //define() function. - callGetModule(args); - } - } - - //Mark all the dependencies as needing to be loaded. - requireMod = getModule(makeModuleMap(null, relMap)); - - requireMod.init(deps, callback, errback, { - enabled: true }); - checkLoaded(); + //Only allow undef on top level require calls + if (!relMap) { + localRequire.undef = function (id) { + //Bind any waiting define() calls to this context, + //fix for #408 + takeGlobalQueue(); - return context.require; - }, + var map = makeModuleMap(id, relMap, true), + mod = registry[id]; - undef: function (id) { - var map = makeModuleMap(id, null, true), - mod = registry[id]; + delete defined[id]; + delete urlFetched[map.url]; + delete undefEvents[id]; - delete defined[id]; - delete urlMap[id]; - delete urlFetched[map.url]; - delete undefEvents[id]; + if (mod) { + //Hold on to listeners in case the + //module will be attempted to be reloaded + //using a different config. + if (mod.events.defined) { + undefEvents[id] = mod.events; + } - if (mod) { - //Hold on to listeners in case the - //module will be attempted to be reloaded - //using a different config. - if (mod.events.defined) { - undefEvents[id] = mod.events; - } - - removeWaiting(id); + cleanRegistry(id); + } + }; } + + return localRequire; }, /** @@ -1471,9 +1454,9 @@ var requirejs, require, define; * @param {String} moduleName the name of the module to potentially complete. */ completeLoad: function (moduleName) { - var shim = config.shim[moduleName] || {}, - shExports = shim.exports && shim.exports.exports, - found, args, mod; + var found, args, mod, + shim = config.shim[moduleName] || {}, + shExports = shim.exports; takeGlobalQueue(); @@ -1500,9 +1483,7 @@ var requirejs, require, define; //of those calls/init calls changes the registry. mod = registry[moduleName]; - if (!found && - !defined[moduleName] && - mod && !mod.inited) { + if (!found && !defined[moduleName] && mod && !mod.inited) { if (config.enforceDefine && (!shExports || !getGlobal(shExports))) { if (hasPathFallback(moduleName)) { return; @@ -1515,41 +1496,24 @@ var requirejs, require, define; } else { //A script that does not call define(), so just simulate //the call for it. - callGetModule([moduleName, (shim.deps || []), shim.exports]); + callGetModule([moduleName, (shim.deps || []), shim.exportsFn]); } } checkLoaded(); }, - /** - * Converts a module name + .extension into an URL path. - * *Requires* the use of a module name. It does not support using - * plain URLs like nameToUrl. - */ - toUrl: function (moduleNamePlusExt, relModuleMap) { - var index = moduleNamePlusExt.lastIndexOf('.'), - ext = null; - - if (index !== -1) { - ext = moduleNamePlusExt.substring(index, moduleNamePlusExt.length); - moduleNamePlusExt = moduleNamePlusExt.substring(0, index); - } - - return context.nameToUrl(moduleNamePlusExt, ext, relModuleMap); - }, - /** * Converts a module name to a file path. Supports cases where * moduleName may actually be just an URL. + * Note that it **does not** call normalize on the moduleName, + * it is assumed to have already been normalized. This is an + * internal API, not a public one. Use toUrl for the public API. */ - nameToUrl: function (moduleName, ext, relModuleMap) { + nameToUrl: function (moduleName, ext) { var paths, pkgs, pkg, pkgPath, syms, i, parentModule, url, parentPath; - //Normalize module name if have a base relative module name to work from. - moduleName = normalize(moduleName, relModuleMap && relModuleMap.id, true); - //If a colon is in the URL, it indicates a protocol is used and it is just //an URL to a file, or if it starts with a slash, contains a query arg (i.e. ?) //or ends with .js, then assume the user meant to use an url and not a module id. @@ -1594,7 +1558,8 @@ var requirejs, require, define; } //Join the path parts together, then figure out if baseUrl is needed. - url = syms.join('/') + (ext || '.js'); + url = syms.join('/'); + url += (ext || (/\?/.test(url) ? '' : '.js')); url = (url.charAt(0) === '/' || url.match(/^[\w\+\.\-]+:/) ? '' : config.baseUrl) + url; } @@ -1631,7 +1596,7 @@ var requirejs, require, define; //all old browsers will be supported, but this one was easy enough //to support and still makes sense. if (evt.type === 'load' || - (readyRegExp.test((evt.currentTarget || evt.srcElement).readyState))) { + (readyRegExp.test((evt.currentTarget || evt.srcElement).readyState))) { //Reset interactive script so a script node is not held onto for //to long. interactiveScript = null; @@ -1651,7 +1616,10 @@ var requirejs, require, define; return onError(makeError('scripterror', 'Script error', evt, [data.id])); } } - }); + }; + + context.require = context.makeRequire(); + return context; } /** @@ -1671,8 +1639,8 @@ var requirejs, require, define; req = requirejs = function (deps, callback, errback, optional) { //Find the right context, use default - var contextName = defContextName, - context, config; + var context, config, + contextName = defContextName; // Determine if have config object in the call. if (!isArray(deps) && typeof deps !== 'string') { @@ -1712,6 +1680,16 @@ var requirejs, require, define; return req(config); }; + /** + * Execute something after the current tick + * of the event loop. Override for other envs + * that have a better solution than setTimeout. + * @param {Function} fn function to execute later. + */ + req.nextTick = typeof setTimeout !== 'undefined' ? function (fn) { + setTimeout(fn, 4); + } : function (fn) { fn(); }; + /** * Export require as a global, but only if it does not already exist. */ @@ -1732,9 +1710,21 @@ var requirejs, require, define; //Create default context. req({}); - //Exports some context-sensitive methods on global require, using - //default context if no context specified. - addRequireMethods(req, contexts[defContextName]); + //Exports some context-sensitive methods on global require. + each([ + 'toUrl', + 'undef', + 'defined', + 'specified' + ], function (prop) { + //Reference from contexts instead of early binding to default context, + //so that during builds, the latest instance of the default context + //with its config gets used. + req[prop] = function () { + var ctx = contexts[defContextName]; + return ctx.require[prop].apply(ctx, arguments); + }; + }); if (isBrowser) { head = s.head = document.getElementsByTagName('head')[0]; @@ -1771,10 +1761,11 @@ var requirejs, require, define; if (isBrowser) { //In the browser so use a script tag node = config.xhtml ? - document.createElementNS('http://www.w3.org/1999/xhtml', 'html:script') : - document.createElement('script'); + document.createElementNS('http://www.w3.org/1999/xhtml', 'html:script') : + document.createElement('script'); node.type = config.scriptType || 'text/javascript'; node.charset = 'utf-8'; + node.async = true; node.setAttribute('data-requirecontext', context.contextName); node.setAttribute('data-requiremodule', moduleName); @@ -1788,15 +1779,15 @@ var requirejs, require, define; //UNFORTUNATELY Opera implements attachEvent but does not follow the script //script execution mode. if (node.attachEvent && - //Check if node.attachEvent is artificially added by custom script or - //natively supported by browser - //read https://github.com/jrburke/requirejs/issues/187 - //if we can NOT find [native code] then it must NOT natively supported. - //in IE8, node.attachEvent does not have toString() - //Note the test for "[native code" with no closing brace, see: - //https://github.com/jrburke/requirejs/issues/273 - !(node.attachEvent.toString && node.attachEvent.toString().indexOf('[native code') < 0) && - !isOpera) { + //Check if node.attachEvent is artificially added by custom script or + //natively supported by browser + //read https://github.com/jrburke/requirejs/issues/187 + //if we can NOT find [native code] then it must NOT natively supported. + //in IE8, node.attachEvent does not have toString() + //Note the test for "[native code" with no closing brace, see: + //https://github.com/jrburke/requirejs/issues/273 + !(node.attachEvent.toString && node.attachEvent.toString().indexOf('[native code') < 0) && + !isOpera) { //Probably IE. IE (at least 6-8) do not fire //script onload right after executing the script, so //we cannot tie the anonymous define call to a name. @@ -1877,6 +1868,7 @@ var requirejs, require, define; //baseUrl, if it is not already set. dataMain = script.getAttribute('data-main'); if (dataMain) { + //Set final baseUrl if there is not already an explicit one. if (!cfg.baseUrl) { //Pull off the directory of data-main for use as the //baseUrl. @@ -1884,13 +1876,14 @@ var requirejs, require, define; mainScript = src.pop(); subPath = src.length ? src.join('/') + '/' : './'; - //Set final config. cfg.baseUrl = subPath; - //Strip off any trailing .js since dataMain is now - //like a module name. - dataMain = mainScript.replace(jsSuffixRegExp, ''); + dataMain = mainScript; } + //Strip off any trailing .js since dataMain is now + //like a module name. + dataMain = dataMain.replace(jsSuffixRegExp, ''); + //Put the data-main script in the files to load. cfg.deps = cfg.deps ? cfg.deps.concat(dataMain) : [dataMain]; @@ -1909,7 +1902,7 @@ var requirejs, require, define; define = function (name, deps, callback) { var node, context; - //Allow for anonymous functions + //Allow for anonymous modules if (typeof name !== 'string') { //Adjust args appropriately callback = deps; diff --git a/doc/site/images/ideone-logo.png b/doc/site/images/ideone-logo.png new file mode 100644 index 00000000..cbee7fad Binary files /dev/null and b/doc/site/images/ideone-logo.png differ diff --git a/doc/site/js/main.js b/doc/site/js/main.js index 49f91f5e..efa7ba2b 100644 --- a/doc/site/js/main.js +++ b/doc/site/js/main.js @@ -2,6 +2,7 @@ var editor; var embedded_editor; $(function() { hljs.initHighlighting(); + ace.config.set("workerPath", "build/src-min"); editor = ace.edit("ace_editor_demo"); embedded_editor = ace.edit("embedded_ace_code"); editor.getSession().setMode("ace/mode/javascript"); diff --git a/doc/site/style.css b/doc/site/style.css index f5524d81..16034342 100644 --- a/doc/site/style.css +++ b/doc/site/style.css @@ -250,6 +250,14 @@ ul.menu-list li { hsl(0,0%,90%) 47%, hsl(0,0%,78%) 53%, hsl(0,0%,70%)100%); + background-image: -moz-repeating-linear-gradient(left, hsla(0,0%,100%,0) 0%, hsla(0,0%,100%,0) 6%, hsla(0,0%,100%, .1) 7.5%), + -moz-repeating-linear-gradient(left, hsla(0,0%, 0%,0) 0%, hsla(0,0%, 0%,0) 4%, hsla(0,0%, 0%,.03) 4.5%), + -moz-repeating-linear-gradient(left, hsla(0,0%,100%,0) 0%, hsla(0,0%,100%,0) 1.2%, hsla(0,0%,100%,.15) 2.2%), + + -moz-linear-gradient(-90deg, hsl(0,0%,78%) 0%, + hsl(0,0%,90%) 47%, + hsl(0,0%,78%) 53%, + hsl(0,0%,70%)100%); } ul.menu-list li:hover { diff --git a/index.html b/index.html index d9f52317..7e2fca56 100644 --- a/index.html +++ b/index.html @@ -514,6 +514,11 @@ tests for the highlighting.

style="position: relative; left: 10px;top: -5px;width: 80px;" /> SpanDeX.io +
  • + + Ideone.com +
  • Sky Edit
  • diff --git a/install.js b/install.js index 4f96d891..dca36fff 100644 --- a/install.js +++ b/install.js @@ -33,27 +33,41 @@ * ***** END LICENSE BLOCK ***** */ var buildAce = require("./Makefile.dryice").buildAce; - +var fs = require("fs"); var ACE_HOME = __dirname; -try { - var aceProject = { - roots: [ - ACE_HOME + '/lib', - ACE_HOME + '/demo' - ], - textPluginPattern: /^ace\/requirejs\/text!/ - }; - buildAce(aceProject, { - compress: false, - noconflict: false, - suffix: "", - compat: true, - name: "ace" - }); -} catch (e) { - console.log("--- Ace Build error ---"); - console.log(e); - process.exit(0); +function getVersion(path) { + if (fs.existsSync(path + "/.git-ref")) + return fs.readFileSync(path + "/.git-ref", "utf8"); + if (fs.existsSync(path + "/.git/ORIG_HEAD")) + return fs.readFileSync(path + "/.git/ORIG_HEAD", "utf8"); + if (fs.existsSync(path + "/.sourcemint/source.json")) { + var json = fs.readFileSync(path + "/.sourcemint/source.json", "utf8"); + return JSON.parse(json).url.split("/").pop(); + } } + +if (process.argv.indexOf("-c") > 0) try { + var version = getVersion(ACE_HOME); + var oldVersion = getVersion(ACE_HOME + "/build"); + if (version && oldVersion == version) { + console.log("ace build is up to date"); + process.exit(0); + } + fs.writeFileSync(ACE_HOME + "/build/.git-ref", version, "utf8"); +} catch (e) {} + +try { + buildAce({ + compress: false, + noconflict: false, + suffix: "", + name: "ace" + }); + +} catch (err) { + console.error("--- Ace Build error ---"); + console.error(err.stack); + process.exit(1); +} \ No newline at end of file diff --git a/lib/ace/ace.js b/lib/ace/ace.js index 3dd08504..b40ab454 100644 --- a/lib/ace/ace.js +++ b/lib/ace/ace.js @@ -53,8 +53,8 @@ var MultiSelect = require("./multi_select").MultiSelect; // The following require()s are for inclusion in the built ace file require("./worker/worker_client"); require("./keyboard/hash_handler"); -require("./keyboard/state_handler"); require("./placeholder"); +require("./mode/folding/fold_mode"); exports.config = require("./config"); /** * Ace.edit(el) -> Editor @@ -66,9 +66,8 @@ exports.config = require("./config"); exports.edit = function(el) { if (typeof(el) == "string") { var _id = el; - if (!(el = document.getElementById(el))) { - console.log("can't match div #" + _id); - } + if (!(el = document.getElementById(el))) + throw "ace.edit can't find div #" + _id; } if (el.env && el.env.editor instanceof Editor) diff --git a/lib/ace/commands/default_commands.js b/lib/ace/commands/default_commands.js index ab7f6688..8c33fc42 100644 --- a/lib/ace/commands/default_commands.js +++ b/lib/ace/commands/default_commands.js @@ -321,11 +321,26 @@ exports.commands = [{ bindKey: bindKey("Ctrl-Shift-D", "Command-Shift-D"), exec: function(editor) { editor.duplicateSelection(); }, multiSelectAction: "forEach" +}, { + name: "sortlines", + bindKey: bindKey("Ctrl-Alt-S", "Command-Alt-S"), + exec: function(editor) { editor.sortLines(); }, + multiSelectAction: "forEach" }, { name: "togglecomment", bindKey: bindKey("Ctrl-/", "Command-/"), exec: function(editor) { editor.toggleCommentLines(); }, multiSelectAction: "forEach" +}, { + name: "modifyNumberUp", + bindKey: bindKey("Ctrl-Shift-Up", "Alt-Shift-Up"), + exec: function(editor) { editor.modifyNumber(1); }, + multiSelectAction: "forEach" +}, { + name: "modifyNumberDown", + bindKey: bindKey("Ctrl-Shift-Down", "Alt-Shift-Down"), + exec: function(editor) { editor.modifyNumber(-1); }, + multiSelectAction: "forEach" }, { name: "replace", bindKey: bindKey("Ctrl-R", "Command-Option-F"), diff --git a/lib/ace/config.js b/lib/ace/config.js index cf8151cb..5a1b0e47 100644 --- a/lib/ace/config.js +++ b/lib/ace/config.js @@ -39,9 +39,10 @@ var global = (function() { var options = { packaged: false, - workerPath: "", - modePath: "", - themePath: "", + workerPath: null, + modePath: null, + themePath: null, + basePath: "", suffix: ".js", $moduleUrls: {} }; @@ -74,7 +75,12 @@ exports.moduleUrl = function(name, component) { if (!base && parts.length > 1) base = parts[parts.length - 2]; - return this.get(component + "Path") + "/" + component + "-" + base + this.get("suffix"); + var path = options[component + "Path"]; + if (path == null) + path = options.basePath; + if (path && path.slice(-1) != "/") + path += "/"; + return path + component + "-" + base + this.get("suffix"); }; exports.setModuleUrl = function(name, subst) { @@ -95,9 +101,8 @@ exports.init = function() { var script = scripts[i]; var src = script.src || script.getAttribute("src"); - if (!src) { + if (!src) continue; - } var attributes = script.attributes; for (var j=0, l=attributes.length; j < l; j++) { diff --git a/lib/ace/config_test.js b/lib/ace/config_test.js new file mode 100644 index 00000000..9d0c4697 --- /dev/null +++ b/lib/ace/config_test.js @@ -0,0 +1,71 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2010, Ajax.org B.V. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Ajax.org B.V. nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * ***** END LICENSE BLOCK ***** */ + +if (typeof process !== "undefined") { + require("amd-loader"); +} + +define(function(require, exports, module) { +"use strict"; + +var config = require("./config"); +var assert = require("./test/assertions"); + +module.exports = { + + "test path resolution" : function() { + config.set("packaged", "true"); + var url = config.moduleUrl("kr_theme", "theme"); + assert.equal(url, "theme-kr.js"); + + config.set("basePath", "a/b"); + url = config.moduleUrl("m/theme", "theme"); + assert.equal(url, "a/b/theme-m.js"); + + url = config.moduleUrl("m/theme", "ext"); + assert.equal(url, "a/b/ext-theme.js"); + + config.set("workerPath", "c/"); + url = config.moduleUrl("foo/1", "worker"); + assert.equal(url, "c/worker-1.js"); + + config.setModuleUrl("foo/1", "a/b1.js"); + url = config.moduleUrl("foo/1", "theme"); + assert.equal(url, "a/b1.js"); + + assert.equal(); + } +}; + +}); + +if (typeof module !== "undefined" && module === require.main) { + require("asyncjs").test.testcase(module.exports).exec() +} diff --git a/lib/ace/css/editor.css b/lib/ace/css/editor.css index c3a7fc8e..73702bdf 100644 --- a/lib/ace/css/editor.css +++ b/lib/ace/css/editor.css @@ -1,7 +1,7 @@ .ace_editor { position: absolute; overflow: hidden; - font-family: 'Menlo', 'Monaco', 'Ubuntu Mono', 'Consolas', 'source-code-pro', monospace; + font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'source-code-pro', monospace; font-size: 12px; } @@ -148,10 +148,22 @@ box-sizing: border-box; } -.ace_cursor.ace_hidden { +.ace_hidden-cursors .ace_cursor { opacity: 0.2; } +.ace_smooth-blinking .ace_cursor { + -moz-transition: opacity 0.18s; + -webkit-transition: opacity 0.18s; + -o-transition: opacity 0.18s; + -ms-transition: opacity 0.18s; + transition: opacity 0.18s; +} + +.ace_cursor[style*="opacity: 0"]{ + -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)"; +} + .ace_editor.ace_multiselect .ace_cursor { border-left-width: 1px; } diff --git a/lib/ace/edit_session.js b/lib/ace/edit_session.js index a739b677..d24888da 100644 --- a/lib/ace/edit_session.js +++ b/lib/ace/edit_session.js @@ -375,14 +375,7 @@ var EditSession = function(text, mode) { token.start = c - token.value.length; return token; }; - - this.highlight = function(re) { - if (!this.$searchHighlight) { - var highlight = new SearchHighlight(null, "ace_selected-word", "text"); - this.$searchHighlight = this.addDynamicMarker(highlight); - } - this.$searchHighlight.setRegexp(re); - } + /** * EditSession.setUndoManager(undoManager) * - undoManager (UndoManager): The new undo manager @@ -736,6 +729,30 @@ var EditSession = function(text, mode) { return inFront ? this.$frontMarkers : this.$backMarkers; }; + this.highlight = function(re) { + if (!this.$searchHighlight) { + var highlight = new SearchHighlight(null, "ace_selected-word", "text"); + this.$searchHighlight = this.addDynamicMarker(highlight); + } + this.$searchHighlight.setRegexp(re); + } + + // experimental + this.highlightLines = function(startRow, endRow, clazz, inFront) { + if (typeof endRow != "number") { + clazz = endRow; + endRow = startRow; + } + if (!clazz) + clazz = "ace_step"; + + var range = new Range(startRow, 0, endRow, Infinity); + + var id = this.addMarker(range, clazz, "fullLine", inFront); + range.id = id; + return range; + }, + /* * Error: * { diff --git a/lib/ace/editor.js b/lib/ace/editor.js index 1010a49d..65d31201 100644 --- a/lib/ace/editor.js +++ b/lib/ace/editor.js @@ -481,28 +481,24 @@ var Editor = function(renderer, session) { this.$updateHighlightActiveLine = function() { var session = this.getSession(); - if (session.$highlightLineMarker) - session.removeMarker(session.$highlightLineMarker); - - session.$highlightLineMarker = null; - + var highlight; if (this.$highlightActiveLine) { - var cursor = this.getCursorPosition(); - var foldLine = this.session.getFoldLine(cursor.row); + if ((this.$selectionStyle != "line" || !this.selection.isMultiLine())) + highlight = this.getCursorPosition(); + } - if ((this.getSelectionStyle() != "line" || !this.selection.isMultiLine())) { - var range; - if (foldLine) { - range = new Range(foldLine.start.row, 0, foldLine.end.row + 1, 0); - } else { - range = new Range(cursor.row, 0, cursor.row+1, 0); - } - session.$highlightLineMarker = session.addMarker(range, "ace_active-line", "background"); - } + if (session.$highlightLineMarker && !highlight) { + session.removeMarker(session.$highlightLineMarker.id); + session.$highlightLineMarker = null; + } else if (!session.$highlightLineMarker && highlight) { + session.$highlightLineMarker = session.highlightLines(highlight.row, highlight.row, "ace_active-line"); + } else if (highlight) { + session.$highlightLineMarker.start.row = highlight.row; + session.$highlightLineMarker.end.row = highlight.row; + session._emit("changeBackMarker"); } }; - this.onSelectionChange = function(e) { var session = this.session; @@ -656,6 +652,11 @@ var Editor = function(renderer, session) { this.insert(text); }; + + this.execCommand = function(command, args) { + this.commands.exec(command, this, args); + }; + /** * Editor.insert(text) * - text (String): The new text to add @@ -1276,10 +1277,35 @@ var Editor = function(renderer, session) { this.session.outdentRows(selection.getRange()); }; + // TODO: move out of core when we have good mechanism for managing extensions + this.sortLines = function() { + var rows = this.$getSelectedRows(); + var session = this.session; + + var lines = []; + for (i = rows.first; i <= rows.last; i++) + lines.push(session.getLine(i)); + + lines.sort(function(a, b) { + if (a.toLowerCase() < b.toLowerCase()) return -1; + if (a.toLowerCase() > b.toLowerCase()) return 1; + return 0; + }); + + var deleteRange = new Range(0, 0, 0, 0); + for (var i = rows.first; i <= rows.last; i++) { + var line = session.getLine(i); + deleteRange.start.row = i; + deleteRange.end.row = i; + deleteRange.end.column = line.length; + session.replace(deleteRange, lines[i-rows.first]); + } + }; + /** * Editor.toggleCommentLines() * - * Given the currently selected range, this function either comments all lines or uncomments all lines (depending on whether it's commented or not). + * Given the currently selected range, this function either comments all the lines, or uncomments all of them. **/ this.toggleCommentLines = function() { var state = this.session.getState(this.getCursorPosition().row); @@ -1287,6 +1313,78 @@ var Editor = function(renderer, session) { this.session.getMode().toggleCommentLines(state, this.session, rows.first, rows.last); }; + /** + * Editor.getNumberAt() -> Number + * + * Works like [[Editor.getTokenAt]], except it returns a number. + **/ + this.getNumberAt = function( row, column ) { + var _numberRx = /[\-]?[0-9]+(?:\.[0-9]+)?/g + _numberRx.lastIndex = 0 + + var s = this.session.getLine(row) + while(_numberRx.lastIndex < column - 1 ){ + var m = _numberRx.exec(s) + if(m.index <= column && m.index+m[0].length >= column){ + var number = { + value: m[0], + start: m.index, + end: m.index+m[0].length + + } + return number + } + } + return null; + }; + /** + * Editor.modifyNumber(amount) + * - amount (Number): The value to change the numeral by (can be negative to decrease value) + * + * If the character before the cursor is a number, this functions changes its value by `amount`. + **/ + this.modifyNumber = function(amount) { + var row = this.selection.getCursor().row; + var column = this.selection.getCursor().column; + + // get the char before the cursor + var charRange = new Range(row, column-1, row, column); + + var c = this.session.getTextRange(charRange); + // if the char is a digit + if (!isNaN(parseFloat(c)) && isFinite(c)) { + // get the whole number the digit is part of + var nr = this.getNumberAt(row, column); + // if number found + if (nr) { + var fp = nr.value.indexOf(".") >= 0 ? nr.start + nr.value.indexOf(".") + 1 : nr.end; + var decimals = nr.start + nr.value.length - fp; + + var t = parseFloat(nr.value); + t *= Math.pow(10, decimals); + + + if(fp !== nr.end && column < fp){ + amount *= Math.pow(10, nr.end - column - 1); + } else { + amount *= Math.pow(10, nr.end - column); + } + + t += amount; + t /= Math.pow(10, decimals); + var nnr = t.toFixed(decimals); + + //update number + var replaceRange = new Range(row, nr.start, row, nr.end); + this.session.replace(replaceRange, nnr); + + //reposition the cursor + this.moveCursorTo(row, Math.max(nr.start +1, column + nnr.length - nr.value.length)); + + } + } + }; + /** related to: EditSession.remove * Editor.removeLines() * @@ -1308,20 +1406,20 @@ var Editor = function(renderer, session) { this.duplicateSelection = function() { var sel = this.selection; - var doc = this.session; - var range = sel.getRange(); - if (range.isEmpty()) { - var row = range.start.row; - doc.duplicateLines(row, row); - } else { - var reverse = sel.isBackwards() - var point = sel.isBackwards() ? range.start : range.end; - var endPoint = doc.insert(point, doc.getTextRange(range), false); - range.start = point; - range.end = endPoint; - - sel.setSelectionRange(range, reverse) - } + var doc = this.session; + var range = sel.getRange(); + if (range.isEmpty()) { + var row = range.start.row; + doc.duplicateLines(row, row); + } else { + var reverse = sel.isBackwards() + var point = sel.isBackwards() ? range.start : range.end; + var endPoint = doc.insert(point, doc.getTextRange(range), false); + range.start = point; + range.end = endPoint; + + sel.setSelectionRange(range, reverse) + } }; /** related to: EditSession.moveLinesDown diff --git a/lib/ace/ext/textarea.js b/lib/ace/ext/textarea.js index ddb57df0..a8f6317f 100644 --- a/lib/ace/ext/textarea.js +++ b/lib/ace/ext/textarea.js @@ -36,7 +36,7 @@ var UA = require("../lib/useragent"); var net = require("../lib/net"); var ace = require("../ace"); -require("ace/theme/textmate"); +require("../theme/textmate"); module.exports = exports = ace; diff --git a/lib/ace/keyboard/emacs.js b/lib/ace/keyboard/emacs.js index a1248759..8fc3aeeb 100644 --- a/lib/ace/keyboard/emacs.js +++ b/lib/ace/keyboard/emacs.js @@ -66,7 +66,7 @@ exports.handler.attach = function(editor) { opacity: 1;\ background-color: transparent;\ }\ - .emacs-mode .ace_cursor.ace_overwrite {\ + .emacs-mode .ace_overwrite-cursors .ace_cursor {\ opacity: 1;\ background-color: transparent;\ border-width: 0 0 2px 2px !important;\ diff --git a/lib/ace/keyboard/textinput.js b/lib/ace/keyboard/textinput.js index 7204c022..44632ef3 100644 --- a/lib/ace/keyboard/textinput.js +++ b/lib/ace/keyboard/textinput.js @@ -298,7 +298,7 @@ var TextInput = function(parentNode, host) { host.renderer.$keepTextAreaAtCursor = null; // on windows context menu is opened after mouseup - if (useragent.isWin && (useragent.isGecko || useragent.isIE)) + if (useragent.isWin) event.capture(host.container, function(e) { text.style.left = e.clientX - 2 + "px"; text.style.top = e.clientY - 2 + "px"; diff --git a/lib/ace/keyboard/vim/maps/motions.js b/lib/ace/keyboard/vim/maps/motions.js index 49b68d86..036930ec 100644 --- a/lib/ace/keyboard/vim/maps/motions.js +++ b/lib/ace/keyboard/vim/maps/motions.js @@ -127,7 +127,7 @@ var StringStream = function(editor, cursor) { }; }; -var Search = require("ace/search").Search; +var Search = require("../../../search").Search; var search = new Search(); function find(editor, needle, dir) { @@ -136,7 +136,7 @@ function find(editor, needle, dir) { return search.find(editor.session); } -var Range = require("ace/range").Range; +var Range = require("../../../range").Range; module.exports = { "w": new Motion(function(editor) { diff --git a/lib/ace/layer/cursor.js b/lib/ace/layer/cursor.js index 9d688b57..bd0219a4 100644 --- a/lib/ace/layer/cursor.js +++ b/lib/ace/layer/cursor.js @@ -40,9 +40,12 @@ var Cursor = function(parentEl) { this.isVisible = false; this.isBlinking = true; + this.blinkInterval = 1000; + this.smoothBlinking = false; this.cursors = []; this.cursor = this.addCursor(); + dom.addCssClass(this.element, "ace_hidden-cursors"); }; (function() { @@ -57,20 +60,33 @@ var Cursor = function(parentEl) { }; this.setBlinking = function(blinking) { - this.isBlinking = blinking; - if (blinking) + if (blinking != this.isBlinking){ + this.isBlinking = blinking; this.restartTimer(); + } + }; + + this.setBlinkInterval = function(blinkInterval) { + if (blinkInterval != this.blinkInterval){ + this.blinkInterval = blinkInterval; + this.restartTimer(); + } + }; + + this.setSmoothBlinking = function(smoothBlinking) { + if (smoothBlinking != this.smoothBlinking) { + this.smoothBlinking = smoothBlinking; + if (smoothBlinking) + dom.addCssClass(this.element, "ace_smooth-blinking"); + else + dom.removeCssClass(this.element, "ace_smooth-blinking"); + this.restartTimer(); + } }; this.addCursor = function() { var el = dom.createElement("div"); - var className = "ace_cursor"; - if (!this.isVisible) - className += " ace_hidden"; - if (this.overwrite) - className += " ace_overwrite"; - - el.className = className; + el.className = "ace_cursor"; this.element.appendChild(el); this.cursors.push(el); return el; @@ -86,118 +102,113 @@ var Cursor = function(parentEl) { this.hideCursor = function() { this.isVisible = false; - for (var i = this.cursors.length; i--; ) - dom.addCssClass(this.cursors[i], "ace_hidden"); - clearInterval(this.blinkId); + dom.addCssClass(this.element, "ace_hidden-cursors"); + this.restartTimer(); }; this.showCursor = function() { this.isVisible = true; - for (var i = this.cursors.length; i--; ) - dom.removeCssClass(this.cursors[i], "ace_hidden"); - - this.element.style.visibility = ""; + dom.removeCssClass(this.element, "ace_hidden-cursors"); this.restartTimer(); }; this.restartTimer = function() { - clearInterval(this.blinkId); - if (!this.isBlinking) - return; - if (!this.isVisible) + clearInterval(this.intervalId); + clearTimeout(this.timeoutId); + if (this.smoothBlinking) + dom.removeCssClass(this.element, "ace_smooth-blinking"); + for (var i = this.cursors.length; i--; ) + this.cursors[i].style.opacity = ""; + + if (!this.isBlinking || !this.blinkInterval || !this.isVisible) return; - var element = this.cursors.length == 1 ? this.cursor : this.element; - this.blinkId = setInterval(function() { - element.style.visibility = "hidden"; - setTimeout(function() { - element.style.visibility = ""; - }, 400); - }, 1000); + if (this.smoothBlinking) + setTimeout(function(){ + dom.addCssClass(this.element, "ace_smooth-blinking"); + }.bind(this)); + + var blink = function(){ + this.timeoutId = setTimeout(function() { + for (var i = this.cursors.length; i--; ) { + this.cursors[i].style.opacity = 0; + } + }.bind(this), 0.6 * this.blinkInterval); + }.bind(this); + + this.intervalId = setInterval(function() { + for (var i = this.cursors.length; i--; ) { + this.cursors[i].style.opacity = ""; + } + blink(); + }.bind(this), this.blinkInterval); + + blink(); }; this.getPixelPosition = function(position, onScreen) { - if (!this.config || !this.session) { - return { - left : 0, - top : 0 - }; - } + if (!this.config || !this.session) + return {left : 0, top : 0}; if (!position) position = this.session.selection.getCursor(); var pos = this.session.documentToScreenPosition(position); - var cursorLeft = Math.round(this.$padding + - pos.column * this.config.characterWidth); + var cursorLeft = this.$padding + pos.column * this.config.characterWidth; var cursorTop = (pos.row - (onScreen ? this.config.firstRowScreen : 0)) * this.config.lineHeight; - return { - left : cursorLeft, - top : cursorTop - }; + return {left : cursorLeft, top : cursorTop}; }; this.update = function(config) { this.config = config; - if (this.session.selectionMarkerCount > 0) { - var selections = this.session.$selectionMarkers; - var i = 0, sel, cursorIndex = 0; + var selections = this.session.$selectionMarkers; + var i = 0, cursorIndex = 0; - for (var i = selections.length; i--; ) { - sel = selections[i]; - var pixelPos = this.getPixelPosition(sel.cursor, true); - if ((pixelPos.top > config.height + config.offset || - pixelPos.top < -config.offset) && i > 1) { - continue; - } + if (selections === undefined || selections.length === 0){ + selections = [{cursor: null}]; + } - var style = (this.cursors[cursorIndex++] || this.addCursor()).style; - - style.left = pixelPos.left + "px"; - style.top = pixelPos.top + "px"; - style.width = config.characterWidth + "px"; - style.height = config.lineHeight + "px"; + for (var i = selections.length; i--; ) { + var pixelPos = this.getPixelPosition(selections[i].cursor, true); + if ((pixelPos.top > config.height + config.offset || + pixelPos.top < -config.offset) && i > 1) { + continue; } - if (cursorIndex > 1) - while (this.cursors.length > cursorIndex) - this.removeCursor(); - } else { - var pixelPos = this.getPixelPosition(null, true); - var style = this.cursor.style; + + var style = (this.cursors[cursorIndex++] || this.addCursor()).style; + style.left = pixelPos.left + "px"; style.top = pixelPos.top + "px"; style.width = config.characterWidth + "px"; style.height = config.lineHeight + "px"; - - while (this.cursors.length > 1) - this.removeCursor(); } + while (this.cursors.length > cursorIndex) + this.removeCursor(); var overwrite = this.session.getOverwrite(); - if (overwrite != this.overwrite) - this.$setOverwrite(overwrite); + this.$setOverwrite(overwrite); // cache for textarea and gutter highlight this.$pixelPos = pixelPos; - this.restartTimer(); }; this.$setOverwrite = function(overwrite) { - this.overwrite = overwrite; - for (var i = this.cursors.length; i--; ) { + if (overwrite != this.overwrite) { + this.overwrite = overwrite; if (overwrite) - dom.addCssClass(this.cursors[i], "ace_overwrite"); + dom.addCssClass(this.element, "ace_overwrite-cursors"); else - dom.removeCssClass(this.cursors[i], "ace_overwrite"); + dom.removeCssClass(this.element, "ace_overwrite-cursors"); } }; this.destroy = function() { - clearInterval(this.blinkId); - } + clearInterval(this.intervalId); + clearTimeout(this.timeoutId); + }; }).call(Cursor.prototype); diff --git a/lib/ace/layer/marker.js b/lib/ace/layer/marker.js index 7470bfd7..e09a3c9b 100644 --- a/lib/ace/layer/marker.js +++ b/lib/ace/layer/marker.js @@ -78,26 +78,20 @@ var Marker = function(parentEl) { range = range.toScreenRange(this.session); if (marker.renderer) { var top = this.$getTop(range.start.row, config); - var left = Math.round( - this.$padding + range.start.column * config.characterWidth - ); + var left = this.$padding + range.start.column * config.characterWidth; marker.renderer(html, range, left, top, config); } + if (marker.type == "fullLine") { + this.drawFullLineMarker(html, range, marker.clazz, config); + } else if (range.isMultiLine()) { - if (marker.type == "text") { + if (marker.type == "text") this.drawTextMarker(html, range, marker.clazz, config); - } else { - this.drawMultiLineMarker( - html, range, marker.clazz, config, - marker.type - ); - } + else + this.drawMultiLineMarker(html, range, marker.clazz, config); } else { - this.drawSingleLineMarker( - html, range, marker.clazz + " ace_start", config, - null, marker.type - ); + this.drawSingleLineMarker(html, range, marker.clazz + " ace_start", config); } } this.element = dom.setInnerHtml(this.element, html.join("")); @@ -133,11 +127,11 @@ var Marker = function(parentEl) { // Draws a multi line marker, where lines span the full width this.drawMultiLineMarker = function(stringBuilder, range, clazz, config, type) { - var padding = type === "background" ? 0 : this.$padding; // from selection start to the end of the line + var padding = this.$padding; var height = config.lineHeight; var top = this.$getTop(range.start.row, config); - var left = Math.round(padding + range.start.column * config.characterWidth); + var left = padding + range.start.column * config.characterWidth; stringBuilder.push( "
    " + ); + } + }).call(Marker.prototype); exports.Marker = Marker; diff --git a/lib/ace/lib/es5-shim.js b/lib/ace/lib/es5-shim.js index c0e7999c..3a3b68c5 100644 --- a/lib/ace/lib/es5-shim.js +++ b/lib/ace/lib/es5-shim.js @@ -543,10 +543,33 @@ if (!Object.getOwnPropertyNames) { // ES5 15.2.3.5 // http://es5.github.com/#x15.2.3.5 if (!Object.create) { + var createEmpty; + if (Object.prototype.__proto__ === null) { + createEmpty = function () { + return { "__proto__": null }; + }; + } else { + // In old IE __proto__ can't be used to manually set `null` + createEmpty = function () { + var empty = {}; + for (var i in empty) + empty[i] = null; + empty.constructor = + empty.hasOwnProperty = + empty.propertyIsEnumerable = + empty.isPrototypeOf = + empty.toLocaleString = + empty.toString = + empty.valueOf = + empty.__proto__ = null; + return empty; + } + } + Object.create = function create(prototype, properties) { var object; if (prototype === null) { - object = { "__proto__": null }; + object = createEmpty(); } else { if (typeof prototype != "object") throw new TypeError("typeof prototype["+(typeof prototype)+"] != 'object'"); diff --git a/lib/ace/mode/behaviour/cstyle.js b/lib/ace/mode/behaviour/cstyle.js index e4dea304..8397e79c 100644 --- a/lib/ace/mode/behaviour/cstyle.js +++ b/lib/ace/mode/behaviour/cstyle.js @@ -33,19 +33,70 @@ define(function(require, exports, module) { var oop = require("../../lib/oop"); var Behaviour = require("../behaviour").Behaviour; +var TokenIterator = require("../../token_iterator").TokenIterator; + +var autoInsertedBrackets = 0; +var autoInsertedRow = -1; +var autoInsertedLineEnd = ""; var CstyleBehaviour = function () { + + CstyleBehaviour.isSaneInsertion = function(editor, session) { + var cursor = editor.getCursorPosition(); + var iterator = new TokenIterator(session, cursor.row, cursor.column); + + // Don't insert in the middle of a keyword/identifier/lexical + if (!this.$matchTokenType(iterator.getCurrentToken() || "text", ["text", "paren.rparen"])) { + // Look ahead in case we're at the end of a token + iterator = new TokenIterator(session, cursor.row, cursor.column + 1); + if (!this.$matchTokenType(iterator.getCurrentToken() || "text", ["text", "paren.rparen"])) + return false; + } + + // Only insert in front of whitespace/comments + iterator.stepForward(); + return iterator.getCurrentTokenRow() !== cursor.row || + this.$matchTokenType(iterator.getCurrentToken() || "text", ["text", "comment", "paren.rparen"]); + }; + + CstyleBehaviour.$matchTokenType = function(token, types) { + return types.indexOf(token.type || token) > -1; + }; + + CstyleBehaviour.recordAutoInsert = function(editor, session, bracket) { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + // Reset previous state if text or context changed too much + if (!this.isAutoInsertedClosing(cursor, line, autoInsertedLineEnd[0])) + autoInsertedBrackets = 0; + autoInsertedRow = cursor.row; + autoInsertedLineEnd = bracket + line.substr(cursor.column); + autoInsertedBrackets++; + }; + + CstyleBehaviour.isAutoInsertedClosing = function(cursor, line, bracket) { + return autoInsertedBrackets > 0 && + cursor.row === autoInsertedRow && + bracket === autoInsertedLineEnd[0] && + line.substr(cursor.column) === autoInsertedLineEnd; + }; + + CstyleBehaviour.popAutoInsertedClosing = function() { + autoInsertedLineEnd = autoInsertedLineEnd.substr(1); + autoInsertedBrackets--; + }; this.add("braces", "insertion", function (state, action, editor, session, text) { if (text == '{') { var selection = editor.getSelectionRange(); var selected = session.doc.getTextRange(selection); - if (selected !== "") { + if (selected !== "" && selected !== "{") { return { text: '{' + selected + '}', selection: false }; - } else { + } else if (CstyleBehaviour.isSaneInsertion(editor, session)) { + CstyleBehaviour.recordAutoInsert(editor, session, "}"); return { text: '{}', selection: [1, 1] @@ -57,7 +108,8 @@ var CstyleBehaviour = function () { var rightChar = line.substring(cursor.column, cursor.column + 1); if (rightChar == '}') { var matching = session.$findOpeningBracket('}', {column: cursor.column + 1, row: cursor.row}); - if (matching !== null) { + if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) { + CstyleBehaviour.popAutoInsertedClosing(); return { text: '', selection: [1, 1] @@ -105,7 +157,8 @@ var CstyleBehaviour = function () { text: '(' + selected + ')', selection: false }; - } else { + } else if (CstyleBehaviour.isSaneInsertion(editor, session)) { + CstyleBehaviour.recordAutoInsert(editor, session, ")"); return { text: '()', selection: [1, 1] @@ -117,7 +170,8 @@ var CstyleBehaviour = function () { var rightChar = line.substring(cursor.column, cursor.column + 1); if (rightChar == ')') { var matching = session.$findOpeningBracket(')', {column: cursor.column + 1, row: cursor.row}); - if (matching !== null) { + if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) { + CstyleBehaviour.popAutoInsertedClosing(); return { text: '', selection: [1, 1] @@ -148,7 +202,8 @@ var CstyleBehaviour = function () { text: '[' + selected + ']', selection: false }; - } else { + } else if (CstyleBehaviour.isSaneInsertion(editor, session)) { + CstyleBehaviour.recordAutoInsert(editor, session, "]"); return { text: '[]', selection: [1, 1] @@ -160,7 +215,8 @@ var CstyleBehaviour = function () { var rightChar = line.substring(cursor.column, cursor.column + 1); if (rightChar == ']') { var matching = session.$findOpeningBracket(']', {column: cursor.column + 1, row: cursor.row}); - if (matching !== null) { + if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) { + CstyleBehaviour.popAutoInsertedClosing(); return { text: '', selection: [1, 1] diff --git a/lib/ace/mode/jade.js b/lib/ace/mode/jade.js index 03b54306..076b29c8 100644 --- a/lib/ace/mode/jade.js +++ b/lib/ace/mode/jade.js @@ -40,8 +40,8 @@ var oop = require("../lib/oop"); var TextMode = require("./text").Mode; var Tokenizer = require("../tokenizer").Tokenizer; var JadeHighlightRules = require("./jade_highlight_rules").JadeHighlightRules; -// var JavascriptMode = require("ace/mode/javascript").Mode; -// var CssMode = require("ace/mode/css").Mode; +// var JavascriptMode = require("../mode/javascript").Mode; +// var CssMode = require("../mode/css").Mode; var Mode = function() { var highlighter = new JadeHighlightRules(); diff --git a/lib/ace/mode/sql_highlight_rules.js b/lib/ace/mode/sql_highlight_rules.js index 31f609d7..e16ac9ab 100644 --- a/lib/ace/mode/sql_highlight_rules.js +++ b/lib/ace/mode/sql_highlight_rules.js @@ -37,7 +37,7 @@ var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; var SqlHighlightRules = function() { var keywords = ( - "select|from|where|and|or|group|by|order|limit|offset|having|as|case|" + + "select|insert|update|delete|from|where|and|or|group|by|order|limit|offset|having|as|case|" + "when|else|end|type|left|right|join|on|outer|desc|asc" ); diff --git a/lib/ace/placeholder.js b/lib/ace/placeholder.js index 8a93ee54..3306cba1 100644 --- a/lib/ace/placeholder.js +++ b/lib/ace/placeholder.js @@ -30,7 +30,7 @@ define(function(require, exports, module) { "use strict"; -var Range = require('./range').Range; +var Range = require("./range").Range; var EventEmitter = require("./lib/event_emitter").EventEmitter; var oop = require("./lib/oop"); diff --git a/lib/ace/placeholder_test.js b/lib/ace/placeholder_test.js index f395042b..97e561fd 100644 --- a/lib/ace/placeholder_test.js +++ b/lib/ace/placeholder_test.js @@ -41,8 +41,8 @@ var Editor = require("./editor").Editor; var MockRenderer = require("./test/mockrenderer").MockRenderer; var assert = require("./test/assertions"); var JavaScriptMode = require("./mode/javascript").Mode; -var PlaceHolder = require('./placeholder').PlaceHolder; -var UndoManager = require('./undomanager').UndoManager; +var PlaceHolder = require("./placeholder").PlaceHolder; +var UndoManager = require("./undomanager").UndoManager; module.exports = { diff --git a/lib/ace/requirejs/text.js b/lib/ace/requirejs/text.js index 66123169..cba62eef 100644 --- a/lib/ace/requirejs/text.js +++ b/lib/ace/requirejs/text.js @@ -44,7 +44,7 @@ define(function (require, exports, module) { if (globalRequire && globalRequire.nodeRequire) onLoad(globalRequire.nodeRequire('fs').readFileSync(req.toUrl(name), 'utf8')); else - require("ace/lib/net").get(req.toUrl(name), onLoad); + require("../lib/net").get(req.toUrl(name), onLoad); }; }); diff --git a/lib/ace/theme/ambiance.css b/lib/ace/theme/ambiance.css index 65a25bbd..524ad03a 100644 --- a/lib/ace/theme/ambiance.css +++ b/lib/ace/theme/ambiance.css @@ -66,7 +66,7 @@ border-left: 1px solid #7991E8; } -.ace-ambiance .ace_cursor.ace_overwrite { +.ace-ambiance .ace_overwrite-cursors .ace_cursor { border: 1px solid #FFE300; background: #766B13; } diff --git a/lib/ace/theme/ambiance.js b/lib/ace/theme/ambiance.js index 4c74d6f8..475c2e87 100644 --- a/lib/ace/theme/ambiance.js +++ b/lib/ace/theme/ambiance.js @@ -25,7 +25,7 @@ define(function(require, exports, module) { exports.isDark = true; exports.cssClass = "ace-ambiance"; -exports.cssText = require("ace/requirejs/text!./ambiance.css"); +exports.cssText = require("../requirejs/text!./ambiance.css"); var dom = require("../lib/dom"); dom.importCssString(exports.cssText, exports.cssClass); diff --git a/lib/ace/theme/chrome.css b/lib/ace/theme/chrome.css index 8e166a90..773c213c 100644 --- a/lib/ace/theme/chrome.css +++ b/lib/ace/theme/chrome.css @@ -17,7 +17,7 @@ border-left: 2px solid black; } -.ace-chrome .ace_cursor.ace_overwrite { +.ace-chrome .ace_overwrite-cursors .ace_cursor { border-left: 0px; border-bottom: 1px solid black; } diff --git a/lib/ace/theme/chrome.js b/lib/ace/theme/chrome.js index b0d02480..dafa99c2 100644 --- a/lib/ace/theme/chrome.js +++ b/lib/ace/theme/chrome.js @@ -32,7 +32,7 @@ define(function(require, exports, module) { exports.isDark = false; exports.cssClass = "ace-chrome"; -exports.cssText = require('ace/requirejs/text!./chrome.css'); +exports.cssText = require("../requirejs/text!./chrome.css"); var dom = require("../lib/dom"); dom.importCssString(exports.cssText, exports.cssClass); diff --git a/lib/ace/theme/clouds.css b/lib/ace/theme/clouds.css index 1f64a7cd..4ff7e7c2 100644 --- a/lib/ace/theme/clouds.css +++ b/lib/ace/theme/clouds.css @@ -20,7 +20,7 @@ border-left: 2px solid #000000 } -.ace-clouds .ace_cursor.ace_overwrite { +.ace-clouds .ace_overwrite-cursors .ace_cursor { border-left: 0px; border-bottom: 1px solid #000000 } diff --git a/lib/ace/theme/clouds.js b/lib/ace/theme/clouds.js index 13d66603..f9b7c6bf 100644 --- a/lib/ace/theme/clouds.js +++ b/lib/ace/theme/clouds.js @@ -32,7 +32,7 @@ define(function(require, exports, module) { exports.isDark = false; exports.cssClass = "ace-clouds"; -exports.cssText = require('ace/requirejs/text!./clouds.css'); +exports.cssText = require("../requirejs/text!./clouds.css"); var dom = require("../lib/dom"); dom.importCssString(exports.cssText, exports.cssClass); diff --git a/lib/ace/theme/clouds_midnight.css b/lib/ace/theme/clouds_midnight.css index 632dc4e5..6bc319d1 100644 --- a/lib/ace/theme/clouds_midnight.css +++ b/lib/ace/theme/clouds_midnight.css @@ -20,7 +20,7 @@ border-left: 2px solid #7DA5DC } -.ace-clouds-midnight .ace_cursor.ace_overwrite { +.ace-clouds-midnight .ace_overwrite-cursors .ace_cursor { border-left: 0px; border-bottom: 1px solid #7DA5DC } diff --git a/lib/ace/theme/clouds_midnight.js b/lib/ace/theme/clouds_midnight.js index 9359d120..a7b76d65 100644 --- a/lib/ace/theme/clouds_midnight.js +++ b/lib/ace/theme/clouds_midnight.js @@ -32,7 +32,7 @@ define(function(require, exports, module) { exports.isDark = true; exports.cssClass = "ace-clouds-midnight"; -exports.cssText = require('ace/requirejs/text!./clouds_midnight.css'); +exports.cssText = require("../requirejs/text!./clouds_midnight.css"); var dom = require("../lib/dom"); dom.importCssString(exports.cssText, exports.cssClass); diff --git a/lib/ace/theme/cobalt.css b/lib/ace/theme/cobalt.css index 3c8d61f9..3717ba64 100644 --- a/lib/ace/theme/cobalt.css +++ b/lib/ace/theme/cobalt.css @@ -20,7 +20,7 @@ border-left: 2px solid #FFFFFF } -.ace-cobalt .ace_cursor.ace_overwrite { +.ace-cobalt .ace_overwrite-cursors .ace_cursor { border-left: 0px; border-bottom: 1px solid #FFFFFF } diff --git a/lib/ace/theme/cobalt.js b/lib/ace/theme/cobalt.js index 0964e9a6..6e2f3d0a 100644 --- a/lib/ace/theme/cobalt.js +++ b/lib/ace/theme/cobalt.js @@ -32,7 +32,7 @@ define(function(require, exports, module) { exports.isDark = true; exports.cssClass = "ace-cobalt"; -exports.cssText = require('ace/requirejs/text!./cobalt.css'); +exports.cssText = require("../requirejs/text!./cobalt.css"); var dom = require("../lib/dom"); dom.importCssString(exports.cssText, exports.cssClass); diff --git a/lib/ace/theme/crimson_editor.css b/lib/ace/theme/crimson_editor.css index f8032fa4..2d4a0eef 100644 --- a/lib/ace/theme/crimson_editor.css +++ b/lib/ace/theme/crimson_editor.css @@ -26,7 +26,7 @@ border-left: 2px solid black; } -.ace-crimson-editor .ace_cursor.ace_overwrite { +.ace-crimson-editor .ace_overwrite-cursors .ace_cursor { border-left: 0px; border-bottom: 1px solid black; } diff --git a/lib/ace/theme/crimson_editor.js b/lib/ace/theme/crimson_editor.js index 943930d9..a5971075 100644 --- a/lib/ace/theme/crimson_editor.js +++ b/lib/ace/theme/crimson_editor.js @@ -30,7 +30,7 @@ define(function(require, exports, module) { exports.isDark = false; -exports.cssText = require('ace/requirejs/text!./crimson_editor.css'); +exports.cssText = require("../requirejs/text!./crimson_editor.css"); exports.cssClass = "ace-crimson-editor"; diff --git a/lib/ace/theme/dawn.css b/lib/ace/theme/dawn.css index fcfd5e89..ca544fea 100644 --- a/lib/ace/theme/dawn.css +++ b/lib/ace/theme/dawn.css @@ -20,7 +20,7 @@ border-left: 2px solid #000000 } -.ace-dawn .ace_cursor.ace_overwrite { +.ace-dawn .ace_overwrite-cursors .ace_cursor { border-left: 0px; border-bottom: 1px solid #000000 } diff --git a/lib/ace/theme/dawn.js b/lib/ace/theme/dawn.js index 88b5ae38..f31f00b8 100644 --- a/lib/ace/theme/dawn.js +++ b/lib/ace/theme/dawn.js @@ -32,7 +32,7 @@ define(function(require, exports, module) { exports.isDark = false; exports.cssClass = "ace-dawn"; -exports.cssText = require('ace/requirejs/text!./dawn.css'); +exports.cssText = require("../requirejs/text!./dawn.css"); var dom = require("../lib/dom"); dom.importCssString(exports.cssText, exports.cssClass); diff --git a/lib/ace/theme/dreamweaver.css b/lib/ace/theme/dreamweaver.css index 04983385..30f77cbf 100644 --- a/lib/ace/theme/dreamweaver.css +++ b/lib/ace/theme/dreamweaver.css @@ -23,7 +23,7 @@ border-left: 2px solid black; } -.ace-dreamweaver .ace_cursor.ace_overwrite { +.ace-dreamweaver .ace_overwrite-cursors .ace_cursor { border-left: 0px; border-bottom: 1px solid black; } diff --git a/lib/ace/theme/dreamweaver.js b/lib/ace/theme/dreamweaver.js index 25a7fcba..943dc692 100644 --- a/lib/ace/theme/dreamweaver.js +++ b/lib/ace/theme/dreamweaver.js @@ -31,7 +31,7 @@ define(function(require, exports, module) { exports.isDark = false; exports.cssClass = "ace-dreamweaver"; -exports.cssText = require('ace/requirejs/text!./dreamweaver.css'); +exports.cssText = require("../requirejs/text!./dreamweaver.css"); var dom = require("../lib/dom"); dom.importCssString(exports.cssText, exports.cssClass); diff --git a/lib/ace/theme/eclipse.js b/lib/ace/theme/eclipse.js index aabeeab2..329b8b79 100644 --- a/lib/ace/theme/eclipse.js +++ b/lib/ace/theme/eclipse.js @@ -32,7 +32,7 @@ define(function(require, exports, module) { "use strict"; exports.isDark = false; -exports.cssText = require('ace/requirejs/text!./eclipse.css'); +exports.cssText = require("../requirejs/text!./eclipse.css"); exports.cssClass = "ace-eclipse"; diff --git a/lib/ace/theme/github.css b/lib/ace/theme/github.css index 12ffa256..5b059727 100644 --- a/lib/ace/theme/github.css +++ b/lib/ace/theme/github.css @@ -70,7 +70,7 @@ border-left: 2px solid black; } -.ace-github .ace_cursor.ace_overwrite { +.ace-github .ace_overwrite-cursors .ace_cursor { border-left: 0px; border-bottom: 1px solid black; } diff --git a/lib/ace/theme/github.js b/lib/ace/theme/github.js index b5839dd4..de013c8c 100644 --- a/lib/ace/theme/github.js +++ b/lib/ace/theme/github.js @@ -32,7 +32,7 @@ define(function(require, exports, module) { exports.isDark = false; exports.cssClass = "ace-github"; -exports.cssText = require('ace/requirejs/text!./github.css'); +exports.cssText = require("../requirejs/text!./github.css"); var dom = require("../lib/dom"); dom.importCssString(exports.cssText, exports.cssClass); diff --git a/lib/ace/theme/idle_fingers.css b/lib/ace/theme/idle_fingers.css index 1b735dff..43eff698 100644 --- a/lib/ace/theme/idle_fingers.css +++ b/lib/ace/theme/idle_fingers.css @@ -20,7 +20,7 @@ border-left: 2px solid #91FF00 } -.ace-idle-fingers .ace_cursor.ace_overwrite { +.ace-idle-fingers .ace_overwrite-cursors .ace_cursor { border-left: 0px; border-bottom: 1px solid #91FF00 } diff --git a/lib/ace/theme/idle_fingers.js b/lib/ace/theme/idle_fingers.js index fcb3be31..5da497f0 100644 --- a/lib/ace/theme/idle_fingers.js +++ b/lib/ace/theme/idle_fingers.js @@ -32,7 +32,7 @@ define(function(require, exports, module) { exports.isDark = true; exports.cssClass = "ace-idle-fingers"; -exports.cssText = require('ace/requirejs/text!./idle_fingers.css'); +exports.cssText = require("../requirejs/text!./idle_fingers.css"); var dom = require("../lib/dom"); dom.importCssString(exports.cssText, exports.cssClass); diff --git a/lib/ace/theme/kr_theme.css b/lib/ace/theme/kr_theme.css index ffefb03a..0f42c384 100644 --- a/lib/ace/theme/kr_theme.css +++ b/lib/ace/theme/kr_theme.css @@ -20,7 +20,7 @@ border-left: 2px solid #FF9900 } -.ace-kr-theme .ace_cursor.ace_overwrite { +.ace-kr-theme .ace_overwrite-cursors .ace_cursor { border-left: 0px; border-bottom: 1px solid #FF9900 } diff --git a/lib/ace/theme/kr_theme.js b/lib/ace/theme/kr_theme.js index 81faf395..2018a962 100644 --- a/lib/ace/theme/kr_theme.js +++ b/lib/ace/theme/kr_theme.js @@ -32,7 +32,7 @@ define(function(require, exports, module) { exports.isDark = true; exports.cssClass = "ace-kr-theme"; -exports.cssText = require('ace/requirejs/text!./kr_theme.css'); +exports.cssText = require("../requirejs/text!./kr_theme.css"); var dom = require("../lib/dom"); dom.importCssString(exports.cssText, exports.cssClass); diff --git a/lib/ace/theme/merbivore.css b/lib/ace/theme/merbivore.css index a842b716..69e81376 100644 --- a/lib/ace/theme/merbivore.css +++ b/lib/ace/theme/merbivore.css @@ -20,7 +20,7 @@ border-left: 2px solid #FFFFFF } -.ace-merbivore .ace_cursor.ace_overwrite { +.ace-merbivore .ace_overwrite-cursors .ace_cursor { border-left: 0px; border-bottom: 1px solid #FFFFFF } diff --git a/lib/ace/theme/merbivore.js b/lib/ace/theme/merbivore.js index bba49410..699fb2eb 100644 --- a/lib/ace/theme/merbivore.js +++ b/lib/ace/theme/merbivore.js @@ -32,7 +32,7 @@ define(function(require, exports, module) { exports.isDark = true; exports.cssClass = "ace-merbivore"; -exports.cssText = require('ace/requirejs/text!./merbivore.css'); +exports.cssText = require("../requirejs/text!./merbivore.css"); var dom = require("../lib/dom"); dom.importCssString(exports.cssText, exports.cssClass); diff --git a/lib/ace/theme/merbivore_soft.css b/lib/ace/theme/merbivore_soft.css index 7e276a89..ddd417f8 100644 --- a/lib/ace/theme/merbivore_soft.css +++ b/lib/ace/theme/merbivore_soft.css @@ -20,7 +20,7 @@ border-left: 2px solid #FFFFFF } -.ace-merbivore-soft .ace_cursor.ace_overwrite { +.ace-merbivore-soft .ace_overwrite-cursors .ace_cursor { border-left: 0px; border-bottom: 1px solid #FFFFFF } diff --git a/lib/ace/theme/merbivore_soft.js b/lib/ace/theme/merbivore_soft.js index 5848e289..873a6023 100644 --- a/lib/ace/theme/merbivore_soft.js +++ b/lib/ace/theme/merbivore_soft.js @@ -32,7 +32,7 @@ define(function(require, exports, module) { exports.isDark = true; exports.cssClass = "ace-merbivore-soft"; -exports.cssText = require('ace/requirejs/text!./merbivore_soft.css'); +exports.cssText = require("../requirejs/text!./merbivore_soft.css"); var dom = require("../lib/dom"); dom.importCssString(exports.cssText, exports.cssClass); diff --git a/lib/ace/theme/mono_industrial.css b/lib/ace/theme/mono_industrial.css index 09c765b4..f9a318fc 100644 --- a/lib/ace/theme/mono_industrial.css +++ b/lib/ace/theme/mono_industrial.css @@ -20,7 +20,7 @@ border-left: 2px solid #FFFFFF } -.ace-mono-industrial .ace_cursor.ace_overwrite { +.ace-mono-industrial .ace_overwrite-cursors .ace_cursor { border-left: 0px; border-bottom: 1px solid #FFFFFF } diff --git a/lib/ace/theme/mono_industrial.js b/lib/ace/theme/mono_industrial.js index 288cd710..af763292 100644 --- a/lib/ace/theme/mono_industrial.js +++ b/lib/ace/theme/mono_industrial.js @@ -32,7 +32,7 @@ define(function(require, exports, module) { exports.isDark = true; exports.cssClass = "ace-mono-industrial"; -exports.cssText = require('ace/requirejs/text!./mono_industrial.css'); +exports.cssText = require("../requirejs/text!./mono_industrial.css"); var dom = require("../lib/dom"); dom.importCssString(exports.cssText, exports.cssClass); diff --git a/lib/ace/theme/monokai.css b/lib/ace/theme/monokai.css index 1a34fed4..ed876c79 100644 --- a/lib/ace/theme/monokai.css +++ b/lib/ace/theme/monokai.css @@ -20,7 +20,7 @@ border-left: 2px solid #F8F8F0 } -.ace-monokai .ace_cursor.ace_overwrite { +.ace-monokai .ace_overwrite-cursors .ace_cursor { border-left: 0px; border-bottom: 1px solid #F8F8F0 } diff --git a/lib/ace/theme/monokai.js b/lib/ace/theme/monokai.js index fe4283c6..a33326bd 100644 --- a/lib/ace/theme/monokai.js +++ b/lib/ace/theme/monokai.js @@ -32,7 +32,7 @@ define(function(require, exports, module) { exports.isDark = true; exports.cssClass = "ace-monokai"; -exports.cssText = require('ace/requirejs/text!./monokai.css'); +exports.cssText = require("../requirejs/text!./monokai.css"); var dom = require("../lib/dom"); dom.importCssString(exports.cssText, exports.cssClass); diff --git a/lib/ace/theme/pastel_on_dark.css b/lib/ace/theme/pastel_on_dark.css index 18f61d85..b517f22a 100644 --- a/lib/ace/theme/pastel_on_dark.css +++ b/lib/ace/theme/pastel_on_dark.css @@ -20,7 +20,7 @@ border-left: 2px solid #A7A7A7 } -.ace-pastel-on-dark .ace_cursor.ace_overwrite { +.ace-pastel-on-dark .ace_overwrite-cursors .ace_cursor { border-left: 0px; border-bottom: 1px solid #A7A7A7 } diff --git a/lib/ace/theme/pastel_on_dark.js b/lib/ace/theme/pastel_on_dark.js index 93776772..5c11fd4c 100644 --- a/lib/ace/theme/pastel_on_dark.js +++ b/lib/ace/theme/pastel_on_dark.js @@ -32,7 +32,7 @@ define(function(require, exports, module) { exports.isDark = true; exports.cssClass = "ace-pastel-on-dark"; -exports.cssText = require('ace/requirejs/text!./pastel_on_dark.css'); +exports.cssText = require("../requirejs/text!./pastel_on_dark.css"); var dom = require("../lib/dom"); dom.importCssString(exports.cssText, exports.cssClass); diff --git a/lib/ace/theme/solarized_dark.css b/lib/ace/theme/solarized_dark.css index 26b206b0..4d47fb76 100644 --- a/lib/ace/theme/solarized_dark.css +++ b/lib/ace/theme/solarized_dark.css @@ -22,7 +22,7 @@ border-left: 2px solid #D30102 } -.ace-solarized-dark .ace_cursor.ace_overwrite { +.ace-solarized-dark .ace_overwrite-cursors .ace_cursor { border-left: 0px; border-bottom: 1px solid #D30102 } diff --git a/lib/ace/theme/solarized_dark.js b/lib/ace/theme/solarized_dark.js index f2ef096b..d7ad4f90 100644 --- a/lib/ace/theme/solarized_dark.js +++ b/lib/ace/theme/solarized_dark.js @@ -32,7 +32,7 @@ define(function(require, exports, module) { exports.isDark = true; exports.cssClass = "ace-solarized-dark"; -exports.cssText = require('ace/requirejs/text!./solarized_dark.css'); +exports.cssText = require("../requirejs/text!./solarized_dark.css"); var dom = require("../lib/dom"); dom.importCssString(exports.cssText, exports.cssClass); diff --git a/lib/ace/theme/solarized_light.css b/lib/ace/theme/solarized_light.css index e00b9b39..65dfe8df 100644 --- a/lib/ace/theme/solarized_light.css +++ b/lib/ace/theme/solarized_light.css @@ -20,7 +20,7 @@ border-left: 2px solid #000000 } -.ace-solarized-light .ace_cursor.ace_overwrite { +.ace-solarized-light .ace_overwrite-cursors .ace_cursor { border-left: 0px; border-bottom: 1px solid #000000 } diff --git a/lib/ace/theme/solarized_light.js b/lib/ace/theme/solarized_light.js index a8e9e10f..eda2c45c 100644 --- a/lib/ace/theme/solarized_light.js +++ b/lib/ace/theme/solarized_light.js @@ -32,7 +32,7 @@ define(function(require, exports, module) { exports.isDark = false; exports.cssClass = "ace-solarized-light"; -exports.cssText = require('ace/requirejs/text!./solarized_light.css'); +exports.cssText = require("../requirejs/text!./solarized_light.css"); var dom = require("../lib/dom"); dom.importCssString(exports.cssText, exports.cssClass); diff --git a/lib/ace/theme/textmate.css b/lib/ace/theme/textmate.css index ef0be415..538700f2 100644 --- a/lib/ace/theme/textmate.css +++ b/lib/ace/theme/textmate.css @@ -20,7 +20,7 @@ border-left: 2px solid black; } -.ace-tm .ace_cursor.ace_overwrite { +.ace-tm .ace_overwrite-cursors .ace_cursor { border-left: 0px; border-bottom: 1px solid black; } diff --git a/lib/ace/theme/textmate.js b/lib/ace/theme/textmate.js index 47bbae0b..75e19745 100644 --- a/lib/ace/theme/textmate.js +++ b/lib/ace/theme/textmate.js @@ -33,7 +33,7 @@ define(function(require, exports, module) { exports.isDark = false; exports.cssClass = "ace-tm"; -exports.cssText = require('ace/requirejs/text!./textmate.css'); +exports.cssText = require("../requirejs/text!./textmate.css"); var dom = require("../lib/dom"); dom.importCssString(exports.cssText, exports.cssClass); diff --git a/lib/ace/theme/tomorrow.css b/lib/ace/theme/tomorrow.css index 90c397bf..a5d88b6c 100644 --- a/lib/ace/theme/tomorrow.css +++ b/lib/ace/theme/tomorrow.css @@ -20,7 +20,7 @@ border-left: 2px solid #AEAFAD } -.ace-tomorrow .ace_cursor.ace_overwrite { +.ace-tomorrow .ace_overwrite-cursors .ace_cursor { border-left: 0px; border-bottom: 1px solid #AEAFAD } diff --git a/lib/ace/theme/tomorrow.js b/lib/ace/theme/tomorrow.js index acf984f9..603c92a5 100644 --- a/lib/ace/theme/tomorrow.js +++ b/lib/ace/theme/tomorrow.js @@ -32,7 +32,7 @@ define(function(require, exports, module) { exports.isDark = false; exports.cssClass = "ace-tomorrow"; -exports.cssText = require('ace/requirejs/text!./tomorrow.css'); +exports.cssText = require("../requirejs/text!./tomorrow.css"); var dom = require("../lib/dom"); dom.importCssString(exports.cssText, exports.cssClass); diff --git a/lib/ace/theme/tomorrow_night.css b/lib/ace/theme/tomorrow_night.css index 8a62bac2..0baaf323 100644 --- a/lib/ace/theme/tomorrow_night.css +++ b/lib/ace/theme/tomorrow_night.css @@ -20,7 +20,7 @@ border-left: 2px solid #AEAFAD } -.ace-tomorrow-night .ace_cursor.ace_overwrite { +.ace-tomorrow-night .ace_overwrite-cursors .ace_cursor { border-left: 0px; border-bottom: 1px solid #AEAFAD } diff --git a/lib/ace/theme/tomorrow_night.js b/lib/ace/theme/tomorrow_night.js index f3fcdbc9..8a2454ea 100644 --- a/lib/ace/theme/tomorrow_night.js +++ b/lib/ace/theme/tomorrow_night.js @@ -32,7 +32,7 @@ define(function(require, exports, module) { exports.isDark = true; exports.cssClass = "ace-tomorrow-night"; -exports.cssText = require('ace/requirejs/text!./tomorrow_night.css'); +exports.cssText = require("../requirejs/text!./tomorrow_night.css"); var dom = require("../lib/dom"); dom.importCssString(exports.cssText, exports.cssClass); diff --git a/lib/ace/theme/tomorrow_night_blue.css b/lib/ace/theme/tomorrow_night_blue.css index ca0a84fe..daebddb1 100644 --- a/lib/ace/theme/tomorrow_night_blue.css +++ b/lib/ace/theme/tomorrow_night_blue.css @@ -21,7 +21,7 @@ border-left: 2px solid #FFFFFF } -.ace-tomorrow-night-blue .ace_cursor.ace_overwrite { +.ace-tomorrow-night-blue .ace_overwrite-cursors .ace_cursor { border-left: 0px; border-bottom: 1px solid #FFFFFF } diff --git a/lib/ace/theme/tomorrow_night_blue.js b/lib/ace/theme/tomorrow_night_blue.js index 0b496d20..dafd1f53 100644 --- a/lib/ace/theme/tomorrow_night_blue.js +++ b/lib/ace/theme/tomorrow_night_blue.js @@ -32,7 +32,7 @@ define(function(require, exports, module) { exports.isDark = true; exports.cssClass = "ace-tomorrow-night-blue"; -exports.cssText = require('ace/requirejs/text!./tomorrow_night_blue.css'); +exports.cssText = require("../requirejs/text!./tomorrow_night_blue.css"); var dom = require("../lib/dom"); dom.importCssString(exports.cssText, exports.cssClass); diff --git a/lib/ace/theme/tomorrow_night_bright.css b/lib/ace/theme/tomorrow_night_bright.css index 24f4469c..065e2f00 100644 --- a/lib/ace/theme/tomorrow_night_bright.css +++ b/lib/ace/theme/tomorrow_night_bright.css @@ -20,7 +20,7 @@ border-left: 2px solid #9F9F9F } -.ace-tomorrow-night-bright .ace_cursor.ace_overwrite { +.ace-tomorrow-night-bright .ace_overwrite-cursors .ace_cursor { border-left: 0px; border-bottom: 1px solid #9F9F9F } diff --git a/lib/ace/theme/tomorrow_night_bright.js b/lib/ace/theme/tomorrow_night_bright.js index 18bc4aa9..12c961ef 100644 --- a/lib/ace/theme/tomorrow_night_bright.js +++ b/lib/ace/theme/tomorrow_night_bright.js @@ -32,7 +32,7 @@ define(function(require, exports, module) { exports.isDark = true; exports.cssClass = "ace-tomorrow-night-bright"; -exports.cssText = require('ace/requirejs/text!./tomorrow_night_bright.css'); +exports.cssText = require("../requirejs/text!./tomorrow_night_bright.css"); var dom = require("../lib/dom"); dom.importCssString(exports.cssText, exports.cssClass); diff --git a/lib/ace/theme/tomorrow_night_eighties.css b/lib/ace/theme/tomorrow_night_eighties.css index c1695b0d..5584d62d 100644 --- a/lib/ace/theme/tomorrow_night_eighties.css +++ b/lib/ace/theme/tomorrow_night_eighties.css @@ -21,7 +21,7 @@ border-left: 2px solid #CCCCCC } -.ace-tomorrow-night-eighties .ace_cursor.ace_overwrite { +.ace-tomorrow-night-eighties .ace_overwrite-cursors .ace_cursor { border-left: 0px; border-bottom: 1px solid #CCCCCC } diff --git a/lib/ace/theme/tomorrow_night_eighties.js b/lib/ace/theme/tomorrow_night_eighties.js index 8217cdbd..fc2cd15c 100644 --- a/lib/ace/theme/tomorrow_night_eighties.js +++ b/lib/ace/theme/tomorrow_night_eighties.js @@ -32,7 +32,7 @@ define(function(require, exports, module) { exports.isDark = true; exports.cssClass = "ace-tomorrow-night-eighties"; -exports.cssText = require('ace/requirejs/text!./tomorrow_night_eighties.css'); +exports.cssText = require("../requirejs/text!./tomorrow_night_eighties.css"); var dom = require("../lib/dom"); dom.importCssString(exports.cssText, exports.cssClass); diff --git a/lib/ace/theme/twilight.css b/lib/ace/theme/twilight.css index 3051a3e6..3ef9de2e 100644 --- a/lib/ace/theme/twilight.css +++ b/lib/ace/theme/twilight.css @@ -20,7 +20,7 @@ border-left: 2px solid #A7A7A7 } -.ace-twilight .ace_cursor.ace_overwrite { +.ace-twilight .ace_overwrite-cursors .ace_cursor { border-left: 0px; border-bottom: 1px solid #A7A7A7 } diff --git a/lib/ace/theme/twilight.js b/lib/ace/theme/twilight.js index 5c1d3eef..216f09de 100644 --- a/lib/ace/theme/twilight.js +++ b/lib/ace/theme/twilight.js @@ -32,7 +32,7 @@ define(function(require, exports, module) { exports.isDark = true; exports.cssClass = "ace-twilight"; -exports.cssText = require('ace/requirejs/text!./twilight.css'); +exports.cssText = require("../requirejs/text!./twilight.css"); var dom = require("../lib/dom"); dom.importCssString(exports.cssText, exports.cssClass); diff --git a/lib/ace/theme/vibrant_ink.css b/lib/ace/theme/vibrant_ink.css index fdd965f1..c611681d 100644 --- a/lib/ace/theme/vibrant_ink.css +++ b/lib/ace/theme/vibrant_ink.css @@ -20,7 +20,7 @@ border-left: 2px solid #FFFFFF } -.ace-vibrant-ink .ace_cursor.ace_overwrite { +.ace-vibrant-ink .ace_overwrite-cursors .ace_cursor { border-left: 0px; border-bottom: 1px solid #FFFFFF } diff --git a/lib/ace/theme/vibrant_ink.js b/lib/ace/theme/vibrant_ink.js index 584f8d29..b41b1d47 100644 --- a/lib/ace/theme/vibrant_ink.js +++ b/lib/ace/theme/vibrant_ink.js @@ -32,7 +32,7 @@ define(function(require, exports, module) { exports.isDark = true; exports.cssClass = "ace-vibrant-ink"; -exports.cssText = require('ace/requirejs/text!./vibrant_ink.css'); +exports.cssText = require("../requirejs/text!./vibrant_ink.css"); var dom = require("../lib/dom"); dom.importCssString(exports.cssText, exports.cssClass); diff --git a/lib/ace/theme/xcode.css b/lib/ace/theme/xcode.css index 16db2006..463703b0 100644 --- a/lib/ace/theme/xcode.css +++ b/lib/ace/theme/xcode.css @@ -22,7 +22,7 @@ border-left: 2px solid #000000 } -.ace-xcode .ace_cursor.ace_overwrite { +.ace-xcode .ace_overwrite-cursors .ace_cursor { border-left: 0px; border-bottom: 1px solid #000000 } diff --git a/lib/ace/theme/xcode.js b/lib/ace/theme/xcode.js index c6cba5b9..19827338 100644 --- a/lib/ace/theme/xcode.js +++ b/lib/ace/theme/xcode.js @@ -32,7 +32,7 @@ define(function(require, exports, module) { exports.isDark = false; exports.cssClass = "ace-xcode"; -exports.cssText = require('ace/requirejs/text!./xcode.css'); +exports.cssText = require("../requirejs/text!./xcode.css"); var dom = require("../lib/dom"); dom.importCssString(exports.cssText, exports.cssClass); diff --git a/lib/ace/virtual_renderer.js b/lib/ace/virtual_renderer.js index fbb1661c..5f14bc14 100644 --- a/lib/ace/virtual_renderer.js +++ b/lib/ace/virtual_renderer.js @@ -44,7 +44,7 @@ var CursorLayer = require("./layer/cursor").Cursor; var ScrollBar = require("./scrollbar").ScrollBar; var RenderLoop = require("./renderloop").RenderLoop; var EventEmitter = require("./lib/event_emitter").EventEmitter; -var editorCss = require("ace/requirejs/text!./css/editor.css"); +var editorCss = require("./requirejs/text!./css/editor.css"); dom.importCssString(editorCss, "ace_editor"); @@ -164,8 +164,8 @@ var VirtualRenderer = function(container, theme) { ); this.$loop.schedule(this.CHANGE_FULL); - this.setPadding(4); this.updateCharacterSize(); + this.setPadding(4); }; (function() { @@ -509,13 +509,11 @@ var VirtualRenderer = function(container, theme) { }; this.$updatePrintMargin = function() { - var containerEl; - if (!this.$showPrintMargin && !this.$printMarginEl) return; if (!this.$printMarginEl) { - containerEl = dom.createElement("div"); + var containerEl = dom.createElement("div"); containerEl.className = "ace_layer ace_print-margin-layer"; this.$printMarginEl = dom.createElement("div"); this.$printMarginEl.className = "ace_print-margin"; diff --git a/package.json b/package.json index 86b2fd8e..eff404d8 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "asyncjs": "0.0.x", "jsdom": "0.2.x", "amd-loader": "~0.0.4", - "dryice": "" + "dryice": "0.4.7" }, "mappings": { "ace": "." @@ -29,7 +29,7 @@ }, "scripts": { "test": "node lib/ace/test/all.js", - "postinstall": "node ./install.js" + "postinstall": "node ./install.js -c" }, "config": { "github.com/sourcemint/bundler-js/0/-meta/config/0": { diff --git a/tool/Theme.tmpl.css b/tool/Theme.tmpl.css index 3b83c5ba..180132f2 100644 --- a/tool/Theme.tmpl.css +++ b/tool/Theme.tmpl.css @@ -22,7 +22,7 @@ border-left: 2px solid %cursor%; } -.%cssClass% .ace_cursor.ace_overwrite { +.%cssClass% .ace_overwrite-cursors .ace_cursor { border-left: 0px; border-bottom: 1px solid %overwrite%; } diff --git a/tool/tmtheme.js b/tool/tmtheme.js index 39570e05..ab40d4a5 100755 --- a/tool/tmtheme.js +++ b/tool/tmtheme.js @@ -278,7 +278,7 @@ function convertTheme(name) { var js = fillTemplate(jsTemplate, { name: name, - css: "require('ace/requirejs/text!./" + name + ".css')", // quoteString(css), // + css: 'require("../requirejs/text!./' + name + '.css")', // quoteString(css), // cssClass: "ace-" + hyphenate(name), isDark: styles.isDark }); diff --git a/tool/update_deps.js b/tool/update_deps.js index 91630a50..6d74040c 100644 --- a/tool/update_deps.js +++ b/tool/update_deps.js @@ -19,6 +19,10 @@ var deps = [{ path: "mode/css/csslint.js", url: "https://raw.github.com/stubbornella/csslint/master/release/csslint-node.js", needsFixup: true +}, { + path: "../../demo/kitchen-sink/require.js", + url: "https://raw.github.com/jrburke/requirejs/master/require.js", + needsFixup: false }] var download = function(href, callback) {