diff --git a/Makefile b/Makefile index 95dcf964..29cf0495 100644 --- a/Makefile +++ b/Makefile @@ -13,7 +13,6 @@ pre_build: build: pre_build ./Makefile.dryice.js normal ./Makefile.dryice.js demo - ./Makefile.dryice.js bm # Minimal build: call Makefile.dryice.js only if our sources changed basic: build/src/ace.js diff --git a/Makefile.dryice.js b/Makefile.dryice.js index 19ba9192..2bc36f8b 100755 --- a/Makefile.dryice.js +++ b/Makefile.dryice.js @@ -31,14 +31,12 @@ var fs = require("fs"); var path = require("path"); -if (!fs.existsSync) - fs.existsSync = path.existsSync; -else - path.existsSync = fs.existsSync; -var copy = require('dryice').copy; +var copy = require('architect-build/copy'); +var build = require('architect-build/build'); var ACE_HOME = __dirname; var BUILD_DIR = ACE_HOME + "/build"; +var CACHE = {}; function main(args) { if (args.indexOf("updateModes") !== -1) { @@ -49,7 +47,7 @@ function main(args) { if (x[0] == "-" && x[1] != "-") return "-" + x; return x; - }); + }).filter(Boolean); if (args[2] && (args[2][0] != "-" || args[2].indexOf("h") != -1)) type = args[2]; @@ -69,36 +67,22 @@ function main(args) { ace(); } else if (type == "demo") { demo(); - } else if (type == "bm") { - bookmarklet(); } else if (type == "full") { - demo(ace()); - bookmarklet(); + ace(); + demo(); } else if (type == "highlighter") { - var project = buildAce({ - coreOnly: true, - exportModule: "ace/ext/static_highlight", - requires: ["ace/ext/static_highlight", "ace/theme/textmate"], - readFilters: [copy.filter.moduleDefines, function(a) { - console.log(a.substring(0, 2500)) - return a - }] - }) - copy({ - source: project.result, - filter: getWriteFilters(project.options, "main"), - dest: BUILD_DIR + "/static_highlight.js" - }); + // TODO } } +} +function showHelp(type) { console.log("--- Ace Dryice Build Tool ---"); console.log(""); console.log("Options:"); console.log(" minimal Places necessary Ace files out in build dir; uses configuration flags below [default]"); console.log(" normal Runs four Ace builds--minimal, minimal-noconflict, minimal-min, and minimal-noconflict-min"); console.log(" demo Runs demo build of Ace"); - console.log(" bm Runs bookmarklet build of Ace"); console.log(" full all of above"); console.log(" highlighter "); console.log("args:"); @@ -109,91 +93,30 @@ function main(args) { console.log(" --nc namespace require"); console.log(" --s shrinkwrap (combines all output files into one)"); console.log(""); - if (BUILD_DIR) - console.log(" output generated in " + type + __dirname + "/" + BUILD_DIR) -} - -function bookmarklet() { - var targetDir = BUILD_DIR + "/textarea"; - copy({ - source: "build_support/editor_textarea.html", - dest: targetDir + '/editor.html' - }); - copy({ - source: "build_support/style.css", - dest: targetDir + '/style.css' - }); - - buildAce({ - targetDir: targetDir + "/src", - ns: "__ace_shadowed__", - exportModule: "ace/ext/textarea", - compress: false, - noconflict: true, - suffix: "", - name: "ace-bookmarklet", - workers: [], - keybindings: [] - }); + if (type) + console.log(" output for " + type + " generated in " + BUILD_DIR); } function ace() { - console.log('# ace ---------'); - - // uncompressed - var project = buildAce({ - compress: false, - noconflict: false - }); - buildAce({ - compress: false, - noconflict: true - }); - - // compressed - buildAce({ - compress: true, - noconflict: false - }); - buildAce({ - compress: true, - noconflict: true - }); - console.log('# ace License | Readme | Changelog ---------'); - copy({ - source: ACE_HOME + "/build_support/editor.html", - dest: BUILD_DIR + "/editor.html" - }); - copy({ - source: ACE_HOME + "/LICENSE", - dest: BUILD_DIR + "/LICENSE" - }); - copy({ - source: ACE_HOME + "/ChangeLog.txt", - dest: BUILD_DIR + "/ChangeLog.txt" - }); - - return project; + copy.file(ACE_HOME + "/build_support/editor.html", BUILD_DIR + "/editor.html"); + copy.file(ACE_HOME + "/LICENSE", BUILD_DIR + "/LICENSE"); + copy.file(ACE_HOME + "/ChangeLog.txt", BUILD_DIR + "/ChangeLog.txt"); + + console.log('# ace ---------'); + for (var i = 0; i < 4; i++) + buildAce({compress: i & 2, noconflict: i & 1}); } -function demo(project) { - project = project || buildAce({ - compress: false, - noconflict: false, - coreOnly: true - }); +function demo() { console.log('# kitchen sink ---------'); - var version, ref; + var version = "", ref = ""; try { version = JSON.parse(fs.readFileSync(ACE_HOME + "/package.json")).version; ref = fs.readFileSync(ACE_HOME + "/.git-ref").toString(); - } catch(e) { - ref = ""; - version = ""; - } + } catch(e) {} function changeComments(data) { return (data @@ -204,88 +127,54 @@ function demo(project) { .replace("%version%", version) .replace("%commit%", ref) ); - }; - - function fixDocPaths(data) { - return data.replace(/"(demo|build)\//g, "\""); } - - copy({ - source: ACE_HOME + "/kitchen-sink.html", - dest: BUILD_DIR + "/kitchen-sink.html", - filter: [changeComments, fixDocPaths] - }); - - copy({ - source: ACE_HOME + "/demo/kitchen-sink/styles.css", - dest: BUILD_DIR + "/kitchen-sink/styles.css", - filter: [ changeComments ] - }); - - fs.readdirSync(ACE_HOME +"/demo/kitchen-sink/docs/").forEach(function(x) { - copy({ - source: ACE_HOME +"/demo/kitchen-sink/docs/" + x, - dest: BUILD_DIR + "/kitchen-sink/docs/" + x - }); - }); - - var demo = copy.createDataObject(); - - project.assumeAllFilesLoaded(); - copy({ - source: [{ - project: cloneProject(project), - require: [ "kitchen-sink/demo" ] - }], - filter: getWriteFilters({filters:[fixDocPaths]}, "demo"), - dest: demo - }); - - copy({ - source: demo, - dest: BUILD_DIR + "/kitchen-sink/demo.js", - }); - - copyFileSync(ACE_HOME + "/demo/kitchen-sink/logo.png", BUILD_DIR + "/kitchen-sink/logo.png"); - fs.readdirSync(ACE_HOME + "/demo/").forEach(function(x) { - if (/\s|requirejs/.test(x) || !/\.(js|html)$/.test(x)) - return; - copy({ - source: ACE_HOME +"/demo/" + x, - dest: BUILD_DIR + "/demo/" + x, - filter: [function(source) { - if (/\.(js)$/.test(x)) - return source; - var removeRequireJS - source = source.replace(/')} - scripts.forEach(function(s) { - s = s.replace(/"/g, ""); - if (s == "ace/ace") { - comment("load ace") - script("ace") - } else { - var extName = s.match(/[^/]*$/)[0]; - comment("load ace " + extName + " extension"); - script("ext-" + extName); - } - }); - result.push("')} + scripts.forEach(function(s) { + s = s.replace(/"/g, ""); + if (s == "ace/ace") { + comment("load ace"); + script("ace"); + } else { + var extName = s.match(/[^/]*$/)[0]; + comment("load ace " + extName + " extension"); + script("ext-" + extName); + } + }); + result.push(" - diff --git a/kitchen-sink.html b/kitchen-sink.html index f55cfa14..65fe2a2a 100644 --- a/kitchen-sink.html +++ b/kitchen-sink.html @@ -11,16 +11,10 @@ commit %commit% --> - - - - + + -
@@ -287,7 +281,7 @@ - + diff --git a/lib/ace/ext/textarea.js b/lib/ace/ext/textarea.js index 86b299e6..c9972488 100644 --- a/lib/ace/ext/textarea.js +++ b/lib/ace/ext/textarea.js @@ -155,7 +155,7 @@ function setupContainer(element, getValue) { return container; } -exports.transformTextarea = function(element, loader) { +exports.transformTextarea = function(element, options) { var session; var container = setupContainer(element, function() { return session.getValue(); @@ -215,9 +215,8 @@ exports.transformTextarea = function(element, loader) { applyStyles(settingDiv, settingDivStyles); container.appendChild(settingDiv); + options = options || exports.defaultOptions; // Power up ace on the textarea: - var options = {}; - var editor = ace.edit(editorDiv); session = editor.getSession(); @@ -228,10 +227,10 @@ exports.transformTextarea = function(element, loader) { container.appendChild(settingOpener); // Create the API. - setupApi(editor, editorDiv, settingDiv, ace, options, loader); + setupApi(editor, editorDiv, settingDiv, ace, options, load); // Create the setting's panel. - setupSettingPanel(settingDiv, settingOpener, editor, options); + setupSettingPanel(settingDiv, settingOpener, editor); var state = ""; event.addListener(settingOpener, "mousemove", function(e) { @@ -296,37 +295,15 @@ function setupApi(editor, editorDiv, settingDiv, ace, options, loader) { }; editor.$setOption = editor.setOption; + editor.$getOption = editor.getOption; editor.setOption = function(key, value) { - if (options[key] == value) return; - switch (key) { case "mode": - if (value != "text") { - // Load the required mode file. Files get loaded only once. - loader("mode-" + value + ".js", "ace/mode/" + value, function() { - var aceMode = require("../mode/" + value).Mode; - session.setMode(new aceMode()); - }); - } else { - session.setMode(new (require("../mode/text").Mode)); - } + editor.$setOption("mode", "ace/mode/" + value) break; - case "theme": - if (value != "textmate") { - // Load the required theme file. Files get loaded only once. - loader("theme-" + value + ".js", "ace/theme/" + value, function() { - editor.setTheme("ace/theme/" + value); - }); - } else { - editor.setTheme("ace/theme/textmate"); - } + editor.$setOption("theme", "ace/theme/" + value) break; - - case "fontSize": - editorDiv.style.fontSize = value; - break; - case "keybindings": switch (value) { case "vim": @@ -341,58 +318,55 @@ function setupApi(editor, editorDiv, settingDiv, ace, options, loader) { break; case "softWrap": - switch (value) { - case "off": - session.setUseWrapMode(false); - renderer.setPrintMarginColumn(80); - break; - case "40": - session.setUseWrapMode(true); - session.setWrapLimitRange(40, 40); - renderer.setPrintMarginColumn(40); - break; - case "80": - session.setUseWrapMode(true); - session.setWrapLimitRange(80, 80); - renderer.setPrintMarginColumn(80); - break; - case "free": - session.setUseWrapMode(true); - session.setWrapLimitRange(null, null); - renderer.setPrintMarginColumn(80); - break; - } + case "fontSize": + editor.$setOption(key, value); break; default: editor.$setOption(key, toBool(value)); } - - options[key] = value; }; editor.getOption = function(key) { - return options[key]; + switch (key) { + case "mode": + return editor.$getOption("mode").substr("ace/mode/".length) + break; + + case "theme": + return editor.$getOption("theme").substr("ace/theme/".length) + break; + + case "keybindings": + var value = editor.getKeyboardHandler() + switch (value && value.$id) { + case "ace/keyboard/vim": + return "vim"; + case "ace/keyboard/emacs": + return "emacs"; + default: + return "ace"; + } + break; + + default: + return editor.$getOption(key); + } }; - editor.getOptions = function() { - return options; - }; - - editor.setOptions(exports.options); - + editor.setOptions(options); return editor; } -function setupSettingPanel(settingDiv, settingOpener, editor, options) { +function setupSettingPanel(settingDiv, settingOpener, editor) { var BOOL = null; var desc = { mode: "Mode:", - gutter: "Display Gutter:", + wrap: "Soft Wrap:", theme: "Theme:", fontSize: "Font Size:", - softWrap: "Soft Wrap:", + showGutter: "Display Gutter:", keybindings: "Keyboard", showPrintMargin: "Show Print Margin:", useSoftTabs: "Use Soft Tabs:", @@ -445,7 +419,7 @@ function setupSettingPanel(settingDiv, settingOpener, editor, options) { twilight: "Twilight", vibrant_ink: "Vibrant Ink" }, - gutter: BOOL, + showGutter: BOOL, fontSize: { "10px": "10px", "11px": "11px", @@ -453,7 +427,7 @@ function setupSettingPanel(settingDiv, settingOpener, editor, options) { "14px": "14px", "16px": "16px" }, - softWrap: { + wrap: { off: "Off", 40: "40", 80: "80", @@ -476,7 +450,7 @@ function setupSettingPanel(settingDiv, settingOpener, editor, options) { if (!obj) { builder.push( "" ); return; @@ -496,10 +470,10 @@ function setupSettingPanel(settingDiv, settingOpener, editor, options) { builder.push(""); } - for (var option in options) { + for (var option in exports.defaultOptions) { table.push("", desc[option], ""); table.push(""); - renderOption(table, option, optionValues[option], options[option]); + renderOption(table, option, optionValues[option], editor.getOption(option)); table.push(""); } table.push(""); @@ -532,12 +506,12 @@ function setupSettingPanel(settingDiv, settingOpener, editor, options) { } // Default startup options. -exports.options = { - mode: "text", +exports.defaultOptions = { + mode: "javascript", theme: "textmate", - gutter: "false", + wrap: "off", fontSize: "12px", - softWrap: "off", + showGutter: "false", keybindings: "ace", showPrintMargin: "false", useSoftTabs: "true", diff --git a/package.json b/package.json index cbabb3a0..31a4dec9 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,8 @@ "asyncjs": "0.0.x", "jsdom": "0.2.x", "amd-loader": "~0.0.4", - "dryice": "0.4.10" + "dryice": "0.4.11", + "architect-build": "https://github.com/c9/architect-build/tarball/42723e152bb" }, "mappings": { "ace": "."