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..9b0b31ac
--- /dev/null
+++ b/demo/kitchen-sink/docs/Makefile
@@ -0,0 +1,122 @@
+.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
+
+define
+
+ifeq
+
+override
+
+# 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..ae46813f 100644
--- a/demo/kitchen-sink/modelist.js
+++ b/demo/kitchen-sink/modelist.js
@@ -5,8 +5,9 @@ define(function(require, exports, module) {
var modes = [];
function getModeFromPath(path) {
var mode = modesByName.text;
+ var fileName = path.split(/[\/\\]/).pop();
for (var i = 0; i < modes.length; i++) {
- if (modes[i].supportsFile(path)) {
+ if (modes[i].supportsFile(fileName)) {
mode = modes[i];
break;
}
@@ -18,7 +19,15 @@ var Mode = function(name, desc, extensions) {
this.name = name;
this.desc = desc;
this.mode = "ace/mode/" + name;
- this.extRe = new RegExp("^.*\\.(" + extensions + ")$", "g");
+ if (/\^/.test(extensions)) {
+ var re = extensions.replace(/\|(\^)?/g, function(a, b){
+ return "$|" + (b ? "^" : "^.*\\.");
+ }) + "$";
+ } else {
+ var re = "^.*\\.(" + extensions + ")$";
+ }
+
+ this.extRe = new RegExp(re, "g");
};
Mode.prototype.supportsFile = function(filename) {
@@ -28,7 +37,7 @@ Mode.prototype.supportsFile = function(filename) {
var modesByName = {
asciidoc: ["AsciiDoc" , "asciidoc"],
c9search: ["C9Search" , "c9search_results"],
- coffee: ["CoffeeScript" , "coffee|^Cakefile"],
+ coffee: ["CoffeeScript" , "^Cakefile|coffee|cf"],
coldfusion: ["ColdFusion" , "cfm"],
csharp: ["C#" , "cs"],
css: ["CSS" , "css"],
@@ -42,7 +51,7 @@ var modesByName = {
clojure: ["Clojure" , "clj"],
jade: ["Jade" , "jade"],
java: ["Java" , "java"],
- jsp: ["JSP" , "jsp"],
+ jsp: ["JSP" , "jsp"],
javascript: ["JavaScript" , "js"],
json: ["JSON" , "json"],
jsx: ["JSX" , "jsx"],
@@ -51,6 +60,7 @@ var modesByName = {
liquid: ["Liquid" , "liquid"],
lua: ["Lua" , "lua"],
luapage: ["LuaPage" , "lp"], // http://keplerproject.github.com/cgilua/manual.html#templates
+ makefile: ["Makefile" , "^GNUmakefile|^makefile|^Makefile|^OCamlMakefile|make"],
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..38267547
--- /dev/null
+++ b/lib/ace/mode/makefile_highlight_rules.js
@@ -0,0 +1,75 @@
+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": "string.interpolated.backtick.makefile",
+ "regex": "`",
+ "next": "shell-start"
+ },
+ {
+ "token": "punctuation.definition.comment.makefile",
+ "regex": /#(?=.)/,
+ "next": "comment"
+ },
+ {
+ "token": [ "keyword.control.makefile"],
+ "regex": "^(?:\\s*\\b)(\\-??include|ifeq|ifneq|ifdef|ifndef|else|endif|vpath|export|unexport|define|endef|override)(?:\\b)"
+ },
+ {// ^([^\t ]+(\s[^\t ]+)*:(?!\=))\s*.*
+ "token": ["entity.name.function.makefile", "text"],
+ "regex": "^([^\\t ]+(?:\\s[^\\t ]+)*:)(\\s*.*)"
+ }
+ ],
+ "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..e342c355 100644
--- a/lib/ace/mode/text_highlight_rules.js
+++ b/lib/ace/mode/text_highlight_rules.js
@@ -68,27 +68,25 @@ 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++) {
+ for (var i = 0; i < states.length; i++)
states[i] = prefix + states[i];
- }
} else {
states = [];
- for (var key in embedRules) {
+ for (var key in embedRules)
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));
- }
+ var addRules = Array.prototype[append ? "push" : "unshift"];
+ for (var i = 0; i < states.length; i++)
+ addRules.apply(this.$rules[states[i]], lang.deepCopy(escapeRules));
- if (!this.$embeds) {
+ if (!this.$embeds)
this.$embeds = [];
- }
this.$embeds.push(prefix);
}