diff --git a/demo/kitchen-sink/doclist.js b/demo/kitchen-sink/doclist.js index 56208dad..9c8b1a0d 100644 --- a/demo/kitchen-sink/doclist.js +++ b/demo/kitchen-sink/doclist.js @@ -88,6 +88,7 @@ var docs = { "docs/liquid.liquid": "Liquid", "docs/lua.lua": "Lua", "docs/luapage.lp": "LuaPage", + "docs/Makefile": "Makefile", "docs/markdown.md": {name: "Markdown", wrapped: true}, "docs/ocaml.ml": "OCaml", "docs/OpenSCAD.scad": "OpenSCAD", diff --git a/demo/kitchen-sink/docs/Makefile b/demo/kitchen-sink/docs/Makefile new file mode 100644 index 00000000..867c7cec --- /dev/null +++ b/demo/kitchen-sink/docs/Makefile @@ -0,0 +1,116 @@ +.PHONY: apf ext worker mode theme package test + +default: apf worker + +update: worker + +# packages apf + +# This is the first line of a comment \ +and this is still part of the comment \ +as is this, since I keep ending each line \ +with a backslash character + +apf: + cd node_modules/packager; node package.js projects/apf_cloud9.apr + cd node_modules/packager; cat build/apf_release.js | sed 's/\(\/\*FILEHEAD(\).*//g' > ../../plugins-client/lib.apf/www/apf-packaged/apf_release.js + +# package debug version of apf +apfdebug: + cd node_modules/packager/projects; cat apf_cloud9.apr | sed 's///g' > apf_cloud9_debug2.apr + cd node_modules/packager/projects; cat apf_cloud9_debug2.apr | sed 's/apf_release/apf_debug/g' > apf_cloud9_debug.apr; rm apf_cloud9_debug2.apr + cd node_modules/packager; node package.js projects/apf_cloud9_debug.apr + cd node_modules/packager; cat build/apf_debug.js | sed 's/\(\/\*FILEHEAD(\).*\/apf\/\(.*\)/\1\2/g' > ../../plugins-client/lib.apf/www/apf-packaged/apf_debug.js + +# package_apf--temporary fix for non-workering infra +pack_apf: + mkdir -p build/src + mv plugins-client/lib.apf/www/apf-packaged/apf_release.js build/src/apf_release.js + node build/r.js -o name=./build/src/apf_release.js out=./plugins-client/lib.apf/www/apf-packaged/apf_release.js baseUrl=. + +# makes ace; at the moment, requires dryice@0.4.2 +ace: + cd node_modules/ace; make clean pre_build; ./Makefile.dryice.js minimal + + +# packages core +core: ace + mkdir -p build/src + node build/r.js -o build/core.build.js + +# generates packed template +helper: + node build/packed_helper.js + +helper_clean: + mkdir -p build/src + node build/packed_helper.js 1 + +# packages ext +ext: + node build/r.js -o build/app.build.js + +# calls dryice on worker & packages it +worker: plugins-client/lib.ace/www/worker/worker-language.js + +plugins-client/lib.ace/www/worker/worker-language.js plugins-client/lib.ace/www/worker/worker-javascript.js : \ + $(wildcard node_modules/ace/*) $(wildcard node_modules/ace/*/*) $(wildcard node_modules/ace/*/*/mode/*) \ + $(wildcard plugins-client/ext.language/*) \ + $(wildcard plugins-client/ext.language/*/*) \ + $(wildcard plugins-client/ext.linereport/*) \ + $(wildcard plugins-client/ext.codecomplete/*) \ + $(wildcard plugins-client/ext.codecomplete/*/*) \ + $(wildcard plugins-client/ext.jslanguage/*) \ + $(wildcard plugins-client/ext.jslanguage/*/*) \ + $(wildcard plugins-client/ext.csslanguage/*) \ + $(wildcard plugins-client/ext.csslanguage/*/*) \ + $(wildcard plugins-client/ext.htmllanguage/*) \ + $(wildcard plugins-client/ext.htmllanguage/*/*) \ + $(wildcard plugins-client/ext.jsinfer/*) \ + $(wildcard plugins-client/ext.jsinfer/*/*) \ + $(wildcard node_modules/treehugger/lib/*) \ + $(wildcard node_modules/treehugger/lib/*/*) \ + $(wildcard node_modules/ace/lib/*) \ + $(wildcard node_modules/ace/*/*) \ + Makefile.dryice.js + mkdir -p plugins-client/lib.ace/www/worker + rm -rf /tmp/c9_worker_build + mkdir -p /tmp/c9_worker_build/ext + ln -s `pwd`/plugins-client/ext.language /tmp/c9_worker_build/ext/language + ln -s `pwd`/plugins-client/ext.codecomplete /tmp/c9_worker_build/ext/codecomplete + ln -s `pwd`/plugins-client/ext.jslanguage /tmp/c9_worker_build/ext/jslanguage + ln -s `pwd`/plugins-client/ext.csslanguage /tmp/c9_worker_build/ext/csslanguage + ln -s `pwd`/plugins-client/ext.htmllanguage /tmp/c9_worker_build/ext/htmllanguage + ln -s `pwd`/plugins-client/ext.linereport /tmp/c9_worker_build/ext/linereport + ln -s `pwd`/plugins-client/ext.linereport_php /tmp/c9_worker_build/ext/linereport_php + node Makefile.dryice.js worker + cp node_modules/ace/build/src/worker* plugins-client/lib.ace/www/worker + +# copies built ace modes +mode: + mkdir -p plugins-client/lib.ace/www/mode + cp `find node_modules/ace/build/src | grep -E "mode-[a-zA-Z_0-9]+.js"` plugins-client/lib.ace/www/mode + +# copies built ace themes +theme: + mkdir -p plugins-client/lib.ace/www/theme + cp `find node_modules/ace/build/src | grep -E "theme-[a-zA-Z_0-9]+.js"` plugins-client/lib.ace/www/theme + +gzip_safe: + for i in `ls ./plugins-client/lib.packed/www/*.js`; do \ + gzip -9 -v -c -q -f $$i > $$i.gz ; \ + done + +gzip: + for i in `ls ./plugins-client/lib.packed/www/*.js`; do \ + gzip -9 -v -q -f $$i ; \ + done + +c9core: apf ace core worker mode theme + +package_clean: helper_clean c9core ext + +package: helper c9core ext + +test check: + test/run-tests.sh \ No newline at end of file diff --git a/demo/kitchen-sink/modelist.js b/demo/kitchen-sink/modelist.js index 9b4c7e3c..58edfbbe 100644 --- a/demo/kitchen-sink/modelist.js +++ b/demo/kitchen-sink/modelist.js @@ -51,6 +51,7 @@ var modesByName = { liquid: ["Liquid" , "liquid"], lua: ["Lua" , "lua"], luapage: ["LuaPage" , "lp"], // http://keplerproject.github.com/cgilua/manual.html#templates + makefile: ["Makefile" , "Makefile"], markdown: ["Markdown" , "md|markdown"], ocaml: ["OCaml" , "ml|mli"], perl: ["Perl" , "pl|pm"], diff --git a/lib/ace/mode/makefile.js b/lib/ace/mode/makefile.js new file mode 100644 index 00000000..77a0bad7 --- /dev/null +++ b/lib/ace/mode/makefile.js @@ -0,0 +1,60 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2012, Ajax.org B.V. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Ajax.org B.V. nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * + * Contributor(s): + * + * + * + * ***** END LICENSE BLOCK ***** */ + +/* + THIS FILE WAS AUTOGENERATED BY mode.tmpl.js +*/ + +define(function(require, exports, module) { +"use strict"; + +var oop = require("../lib/oop"); +var TextMode = require("./text").Mode; +var Tokenizer = require("../tokenizer").Tokenizer; +var MakefileHighlightRules = require("./makefile_highlight_rules").MakefileHighlightRules; + +var Mode = function() { + var highlighter = new MakefileHighlightRules(); + + this.$tokenizer = new Tokenizer(highlighter.getRules()); +}; +oop.inherits(Mode, TextMode); + +(function() { + // Extra logic goes here. +}).call(Mode.prototype); + +exports.Mode = Mode; +}); \ No newline at end of file diff --git a/lib/ace/mode/makefile_highlight_rules.js b/lib/ace/mode/makefile_highlight_rules.js new file mode 100644 index 00000000..e647616c --- /dev/null +++ b/lib/ace/mode/makefile_highlight_rules.js @@ -0,0 +1,124 @@ +/* ***** 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. + * + * Contributor(s): + * + * Garen J. Torikian < gjtorikian AT gmail DOT com > + * + * ***** END LICENSE BLOCK ***** */ + +define(function(require, exports, module) { +"use strict"; + +var oop = require("../lib/oop"); +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +var ShHighlightFile = require("./sh_highlight_rules"); + +var MakefileHighlightRules = function() { + + // regexp must not have capturing parentheses. Use (?:) instead. + // regexps are ordered -> the first match is used + + var keywordMapper = this.createKeywordMapper({ + "keyword": ShHighlightFile.reservedKeywords, + "support.function.builtin": ShHighlightFile.languageConstructs, + "invalid.deprecated": "debugger" + }, "string"); + + this.$rules = + { + "start": [ + { + "token": [ "variable.other.makefile" ], + "regex": "^(?:\\w|[-_])+\\s*\\??=", + "next": "state_1" + }, + { + "token": "string.interpolated.backtick.makefile", + "regex": "`", + "next": "shell-start" + }, + { + "token": "punctuation.definition.comment.makefile", + "regex": /#(?=.)/, + "next": "comment" + }, + { + "token": [ "keyword.control.makefile", "keyword.control.makefile"], + "regex": "^(\\s*)\\b(\\-??include|ifeq|ifneq|ifdef|ifndef|else|endif|vpath|export|unexport|define|endef|override)\\b" + }, + { + "token": ["entity.name.function.makefile", "text"], + "regex": "(^(?:[^\t ]+(?:\s[^\t ]+)*:))(\s*.*)" + } + ], + "state_1": [ + { + "regex": "\\\\\\n" + }, + { + "token": "TODO", + "regex": "$", + "next": "start" + } + ], + "comment": [ + { + "token" : "punctuation.definition.comment.makefile", + "regex" : /.+\\/ + }, + { + "token" : "punctuation.definition.comment.makefile", + "regex" : ".+", + "next" : "start" + } + ], + "shell-start": [ + { + "token": keywordMapper, + "regex" : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b" + }, + { + "token": "string", + "regex" : "\\w+" + }, + { + "token" : "string.interpolated.backtick.makefile", + "regex" : "`", + "next" : "start" + } + ] +} + +}; + +oop.inherits(MakefileHighlightRules, TextHighlightRules); + +exports.MakefileHighlightRules = MakefileHighlightRules; +}); diff --git a/lib/ace/mode/sh_highlight_rules.js b/lib/ace/mode/sh_highlight_rules.js index ebb9631a..6f5efb54 100644 --- a/lib/ace/mode/sh_highlight_rules.js +++ b/lib/ace/mode/sh_highlight_rules.js @@ -34,29 +34,28 @@ define(function(require, exports, module) { var oop = require("../lib/oop"); var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; -var ShHighlightRules = function() { - - var reservedKeywords = ( +var reservedKeywords = exports.reservedKeywords = ( '!|{|}|case|do|done|elif|else|'+ 'esac|fi|for|if|in|then|until|while|'+ '&|;|export|local|read|typeset|unset|'+ 'elif|select|set' ); - var languageConstructs = ( - '[|]|alias|bg|bind|break|builtin|'+ - 'cd|command|compgen|complete|continue|'+ - 'dirs|disown|echo|enable|eval|exec|'+ - 'exit|fc|fg|getopts|hash|help|history|'+ - 'jobs|kill|let|logout|popd|printf|pushd|'+ - 'pwd|return|set|shift|shopt|source|'+ - 'suspend|test|times|trap|type|ulimit|'+ - 'umask|unalias|wait' - ); +var languageConstructs = exports.languageConstructs = ( + '[|]|alias|bg|bind|break|builtin|'+ + 'cd|command|compgen|complete|continue|'+ + 'dirs|disown|echo|enable|eval|exec|'+ + 'exit|fc|fg|getopts|hash|help|history|'+ + 'jobs|kill|let|logout|popd|printf|pushd|'+ + 'pwd|return|set|shift|shopt|source|'+ + 'suspend|test|times|trap|type|ulimit|'+ + 'umask|unalias|wait' +); +var ShHighlightRules = function() { var keywordMapper = this.createKeywordMapper({ "keyword": reservedKeywords, - "constant.language": languageConstructs, + "support.function.builtin": languageConstructs, "invalid.deprecated": "debugger" }, "identifier"); diff --git a/lib/ace/mode/text_highlight_rules.js b/lib/ace/mode/text_highlight_rules.js index d339b9a1..466778aa 100644 --- a/lib/ace/mode/text_highlight_rules.js +++ b/lib/ace/mode/text_highlight_rules.js @@ -68,7 +68,7 @@ var TextHighlightRules = function() { return this.$rules; }; - this.embedRules = function (HighlightRules, prefix, escapeRules, states) { + this.embedRules = function (HighlightRules, prefix, escapeRules, states, append) { var embedRules = new HighlightRules().getRules(); if (states) { for (var i = 0; i < states.length; i++) { @@ -80,10 +80,18 @@ var TextHighlightRules = function() { states.push(prefix + key); } } + this.addRules(embedRules, prefix); - for (var i = 0; i < states.length; i++) { - Array.prototype.unshift.apply(this.$rules[states[i]], lang.deepCopy(escapeRules)); + if (append) { + for (var i = 0; i < states.length; i++) { + Array.prototype.push.apply(this.$rules[states[i]], lang.deepCopy(escapeRules)); + } + } + else { + for (var i = 0; i < states.length; i++) { + Array.prototype.unshift.apply(this.$rules[states[i]], lang.deepCopy(escapeRules)); + } } if (!this.$embeds) {