Merge pull request #887 from ajaxorg/highlighting/js
Highlighting tweaks
This commit is contained in:
commit
b9319e38f5
8 changed files with 190 additions and 9 deletions
|
|
@ -96,6 +96,7 @@ var modesByName = {
|
|||
csharp: ["C#" , "cs"],
|
||||
css: ["CSS" , "css"],
|
||||
diff: ["Diff" , "diff|patch"],
|
||||
glsl: ["Glsl" , "glsl|frag|vert"],
|
||||
golang: ["Go" , "go"],
|
||||
groovy: ["Groovy" , "groovy"],
|
||||
haxe: ["haXe" , "hx"],
|
||||
|
|
@ -177,6 +178,7 @@ var docs = {
|
|||
"docs/csharp.cs": "C#",
|
||||
"docs/css.css": "CSS",
|
||||
"docs/diff.diff": "Diff",
|
||||
"docs/glsl.glsl": "Glsl",
|
||||
"docs/golang.go": "Go",
|
||||
"docs/groovy.groovy": "Groovy",
|
||||
"docs/Haxe.hx": "haXe",
|
||||
|
|
|
|||
20
demo/kitchen-sink/docs/glsl.glsl
Normal file
20
demo/kitchen-sink/docs/glsl.glsl
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
uniform float amplitude;
|
||||
attribute float displacement;
|
||||
varying vec3 vNormal;
|
||||
|
||||
void main() {
|
||||
|
||||
vNormal = normal;
|
||||
|
||||
// multiply our displacement by the
|
||||
// amplitude. The amp will get animated
|
||||
// so we'll have animated displacement
|
||||
vec3 newPosition = position +
|
||||
normal *
|
||||
vec3(displacement *
|
||||
amplitude);
|
||||
|
||||
gl_Position = projectionMatrix *
|
||||
modelViewMatrix *
|
||||
vec4(newPosition,1.0);
|
||||
}
|
||||
|
|
@ -101,6 +101,14 @@ exports.arrayToMap = function(arr) {
|
|||
|
||||
};
|
||||
|
||||
exports.createMap = function(props) {
|
||||
var map = Object.create(null);
|
||||
for (var i in props) {
|
||||
map[i] = props[i];
|
||||
}
|
||||
return map;
|
||||
};
|
||||
|
||||
/*
|
||||
* splice out of 'array' anything that === 'value'
|
||||
*/
|
||||
|
|
|
|||
59
lib/ace/mode/glsl.js
Normal file
59
lib/ace/mode/glsl.js
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Ajax.org Code Editor (ACE).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ajax.org B.V.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var oop = require("../lib/oop");
|
||||
var CMode = require("./c_cpp").Mode;
|
||||
var Tokenizer = require("../tokenizer").Tokenizer;
|
||||
var glslHighlightRules = require("./glsl_highlight_rules").glslHighlightRules;
|
||||
var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
|
||||
var Range = require("../range").Range;
|
||||
var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour;
|
||||
var CStyleFoldMode = require("./folding/cstyle").FoldMode;
|
||||
|
||||
var Mode = function() {
|
||||
this.$tokenizer = new Tokenizer(new glslHighlightRules().getRules());
|
||||
this.$outdent = new MatchingBraceOutdent();
|
||||
this.$behaviour = new CstyleBehaviour();
|
||||
this.foldingRules = new CStyleFoldMode();
|
||||
};
|
||||
oop.inherits(Mode, CMode);
|
||||
|
||||
exports.Mode = Mode;
|
||||
});
|
||||
92
lib/ace/mode/glsl_highlight_rules.js
Normal file
92
lib/ace/mode/glsl_highlight_rules.js
Normal file
|
|
@ -0,0 +1,92 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Ajax.org Code Editor (ACE).
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Ajax.org B.V.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var oop = require("../lib/oop");
|
||||
var lang = require("../lib/lang");
|
||||
var c_cppHighlightRules = require("./c_cpp_highlight_rules").c_cppHighlightRules;
|
||||
|
||||
var glslHighlightRules = function() {
|
||||
|
||||
var keywords = lang.arrayToMap(
|
||||
("attribute|const|uniform|varying|break|continue|do|for|while|" +
|
||||
"if|else|in|out|inout|float|int|void|bool|true|false|" +
|
||||
"lowp|mediump|highp|precision|invariant|discard|return|mat2|mat3|" +
|
||||
"mat4|vec2|vec3|vec4|ivec2|ivec3|ivec4|bvec2|bvec3|bvec4|sampler2D|" +
|
||||
"samplerCube|struct").split("|")
|
||||
);
|
||||
|
||||
var buildinConstants = lang.arrayToMap(
|
||||
("radians|degrees|sin|cos|tan|asin|acos|atan|pow|" +
|
||||
"exp|log|exp2|log2|sqrt|inversesqrt|abs|sign|floor|ceil|fract|mod|" +
|
||||
"min|max|clamp|mix|step|smoothstep|length|distance|dot|cross|" +
|
||||
"normalize|faceforward|reflect|refract|matrixCompMult|lessThan|" +
|
||||
"lessThanEqual|greaterThan|greaterThanEqual|equal|notEqual|any|all|" +
|
||||
"not|dFdx|dFdy|fwidth|texture2D|texture2DProj|texture2DLod|" +
|
||||
"texture2DProjLod|textureCube|textureCubeLod|" +
|
||||
"gl_MaxVertexAttribs|gl_MaxVertexUniformVectors|gl_MaxVaryingVectors|" +
|
||||
"gl_MaxVertexTextureImageUnits|gl_MaxCombinedTextureImageUnits|" +
|
||||
"gl_MaxTextureImageUnits|gl_MaxFragmentUniformVectors|gl_MaxDrawBuffers|" +
|
||||
"gl_DepthRangeParameters|gl_DepthRange|" +
|
||||
// The following two are only for MIME x-shader/x-vertex.
|
||||
"gl_Position|gl_PointSize|" +
|
||||
// The following five are only for MIME x-shader/x-fragment.
|
||||
"gl_FragCoord|gl_FrontFacing|gl_PointCoord|gl_FragColor|gl_FragData").split("|")
|
||||
);
|
||||
|
||||
this.$rules = new c_cppHighlightRules().$rules;
|
||||
this.$rules.start.forEach(function(rule) {
|
||||
if (typeof rule.token == "function")
|
||||
rule.token = function(value) {
|
||||
if (value == "this")
|
||||
return "variable.language";
|
||||
else if (keywords.hasOwnProperty(value))
|
||||
return "keyword";
|
||||
else if (buildinConstants.hasOwnProperty(value))
|
||||
return "constant.language";
|
||||
else
|
||||
return "identifier";
|
||||
};
|
||||
})
|
||||
};
|
||||
|
||||
oop.inherits(glslHighlightRules, c_cppHighlightRules);
|
||||
|
||||
exports.glslHighlightRules = glslHighlightRules;
|
||||
});
|
||||
|
|
@ -39,12 +39,13 @@ define(function(require, exports, module) {
|
|||
"use strict";
|
||||
|
||||
var oop = require("../lib/oop");
|
||||
var lang = require("../lib/lang");
|
||||
var CssHighlightRules = require("./css_highlight_rules").CssHighlightRules;
|
||||
var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScriptHighlightRules;
|
||||
var xmlUtil = require("./xml_util");
|
||||
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
|
||||
|
||||
var tagMap = {
|
||||
var tagMap = lang.createMap({
|
||||
a : 'anchor',
|
||||
button : 'form',
|
||||
form : 'form',
|
||||
|
|
@ -61,7 +62,7 @@ var tagMap = {
|
|||
tfoot : 'table',
|
||||
th : 'table',
|
||||
tr : 'table'
|
||||
};
|
||||
});
|
||||
|
||||
var HtmlHighlightRules = function() {
|
||||
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ var JsonHighlightRules = function() {
|
|||
"string" : [
|
||||
{
|
||||
token : "constant.language.escape",
|
||||
regex : /\\(?:x[0-9a-fA-F]{2}|u[0-9a-fA-F]{4})/
|
||||
regex : /\\(?:x[0-9a-fA-F]{2}|u[0-9a-fA-F]{4}|["\\\/bfnrt])/
|
||||
}, {
|
||||
token : "string",
|
||||
regex : '[^"\\\\]+',
|
||||
|
|
|
|||
|
|
@ -78,13 +78,12 @@ exports.tag = function(states, name, nextState, tagMap) {
|
|||
}, {
|
||||
//token : "meta.tag",
|
||||
|
||||
token : function(value) {
|
||||
if (tagMap && tagMap[value]) {
|
||||
return "meta.tag.tag-name" + '.' + tagMap[value];
|
||||
} else {
|
||||
token : !tagMap ? "meta.tag.tag-name" : function(value) {
|
||||
if (tagMap[value])
|
||||
return "meta.tag.tag-name." + tagMap[value];
|
||||
else
|
||||
return "meta.tag.tag-name";
|
||||
}
|
||||
},
|
||||
},
|
||||
merge : true,
|
||||
regex : "[-_a-zA-Z0-9:]+",
|
||||
next : name + "_embed_attribute_list"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue