update modelist extension
This commit is contained in:
parent
635da1f2ea
commit
35563c5e84
7 changed files with 110 additions and 233 deletions
|
|
@ -451,7 +451,7 @@ event.addListener(container, "drop", function(e) {
|
|||
if (window.FileReader) {
|
||||
var reader = new FileReader();
|
||||
reader.onload = function() {
|
||||
var mode = modelist.getModeFromPath(file.name);
|
||||
var mode = modelist.getModeForPath(file.name);
|
||||
|
||||
env.editor.session.doc.setValue(reader.result);
|
||||
modeEl.value = mode.name;
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ function initDoc(file, path, doc) {
|
|||
session.setUseWrapMode(true);
|
||||
session.setWrapLimitRange(80, 80);
|
||||
}
|
||||
var mode = modelist.getModeFromPath(path);
|
||||
var mode = modelist.getModeForPath(path);
|
||||
session.modeName = mode.name;
|
||||
session.setMode(mode.mode);
|
||||
return session;
|
||||
|
|
|
|||
|
|
@ -1,138 +0,0 @@
|
|||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
/************** modes ***********************/
|
||||
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(fileName)) {
|
||||
mode = modes[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
return mode;
|
||||
}
|
||||
|
||||
var Mode = function(name, desc, extensions) {
|
||||
this.name = name;
|
||||
this.desc = desc;
|
||||
this.mode = "ace/mode/" + name;
|
||||
if (/\^/.test(extensions)) {
|
||||
var re = extensions.replace(/\|(\^)?/g, function(a, b){
|
||||
return "$|" + (b ? "^" : "^.*\\.");
|
||||
}) + "$";
|
||||
} else {
|
||||
var re = "^.*\\.(" + extensions + ")$";
|
||||
}
|
||||
|
||||
this.extRe = new RegExp(re, "gi");
|
||||
};
|
||||
|
||||
Mode.prototype.supportsFile = function(filename) {
|
||||
return filename.match(this.extRe);
|
||||
};
|
||||
|
||||
var modesByName = {
|
||||
asciidoc: ["AsciiDoc" , "asciidoc"],
|
||||
c9search: ["C9Search" , "c9search_results"],
|
||||
coffee: ["CoffeeScript" , "^Cakefile|coffee|cf|cson"],
|
||||
coldfusion: ["ColdFusion" , "cfm"],
|
||||
csharp: ["C#" , "cs"],
|
||||
css: ["CSS" , "css"],
|
||||
curly: ["Curly" , "curly"],
|
||||
dart: ["Dart" , "dart"],
|
||||
diff: ["Diff" , "diff|patch"],
|
||||
dot: ["Dot" , "dot"],
|
||||
ftl: ["FreeMarker" , "ftl"],
|
||||
glsl: ["Glsl" , "glsl|frag|vert"],
|
||||
golang: ["Go" , "go"],
|
||||
groovy: ["Groovy" , "groovy"],
|
||||
haxe: ["haXe" , "hx"],
|
||||
haml: ["HAML" , "haml"],
|
||||
html: ["HTML" , "htm|html|xhtml"],
|
||||
c_cpp: ["C/C++" , "c|cc|cpp|cxx|h|hh|hpp"],
|
||||
clojure: ["Clojure" , "clj"],
|
||||
jade: ["Jade" , "jade"],
|
||||
java: ["Java" , "java"],
|
||||
jsp: ["JSP" , "jsp"],
|
||||
javascript: ["JavaScript" , "js"],
|
||||
json: ["JSON" , "json"],
|
||||
jsx: ["JSX" , "jsx"],
|
||||
latex: ["LaTeX" , "latex|tex|ltx|bib"],
|
||||
less: ["LESS" , "less"],
|
||||
lisp: ["Lisp" , "lisp"],
|
||||
scheme: ["Scheme" , "scm|rkt"],
|
||||
liquid: ["Liquid" , "liquid"],
|
||||
livescript: ["LiveScript" , "ls"],
|
||||
logiql: ["LogiQL" , "logic|lql"],
|
||||
lua: ["Lua" , "lua"],
|
||||
luapage: ["LuaPage" , "lp"], // http://keplerproject.github.com/cgilua/manual.html#templates
|
||||
lucene: ["Lucene" , "lucene"],
|
||||
lsl: ["LSL" , "lsl"],
|
||||
makefile: ["Makefile" , "^GNUmakefile|^makefile|^Makefile|^OCamlMakefile|make"],
|
||||
markdown: ["Markdown" , "md|markdown"],
|
||||
mushcode: ["TinyMUSH" , "mc|mush"],
|
||||
objectivec: ["Objective-C" , "m"],
|
||||
ocaml: ["OCaml" , "ml|mli"],
|
||||
pascal: ["Pascal" , "pas|p"],
|
||||
perl: ["Perl" , "pl|pm"],
|
||||
pgsql: ["pgSQL" , "pgsql"],
|
||||
php: ["PHP" , "php|phtml"],
|
||||
powershell: ["Powershell" , "ps1"],
|
||||
properties: ["Properties" , "properties"],
|
||||
python: ["Python" , "py"],
|
||||
r: ["R" , "r"],
|
||||
rdoc: ["RDoc" , "Rd"],
|
||||
rhtml: ["RHTML" , "Rhtml"],
|
||||
ruby: ["Ruby" , "ru|gemspec|rake|rb"],
|
||||
scad: ["OpenSCAD" , "scad"],
|
||||
scala: ["Scala" , "scala"],
|
||||
scss: ["SCSS" , "scss"],
|
||||
sass: ["SASS" , "sass"],
|
||||
sh: ["SH" , "sh|bash"],
|
||||
sql: ["SQL" , "sql"],
|
||||
stylus: ["Stylus" , "styl|stylus"],
|
||||
svg: ["SVG" , "svg"],
|
||||
tcl: ["Tcl" , "tcl"],
|
||||
tex: ["Tex" , "tex"],
|
||||
text: ["Text" , "txt"],
|
||||
textile: ["Textile" , "textile"],
|
||||
tmsnippet: ["tmSnippet" , "tmSnippet"],
|
||||
toml: ["Toml" , "toml"],
|
||||
typescript: ["Typescript" , "typescript|ts|str"],
|
||||
vbscript: ["VBScript" , "vbs"],
|
||||
velocity: ["Velocity" , "vm"],
|
||||
xml: ["XML" , "xml|rdf|rss|wsdl|xslt|atom|mathml|mml|xul|xbl"],
|
||||
xquery: ["XQuery" , "xq"],
|
||||
jsoniq: ["JSONiq" , "jq"],
|
||||
yaml: ["YAML" , "yaml"],
|
||||
|
||||
abap: ["ABAP" , "abap"],
|
||||
actionscript: ["ActionScript" ,"as"],
|
||||
autohotkey: ["AutoHotKey" , "ahk"],
|
||||
batch_file: ["BatchFile" , "bat|cmd"],
|
||||
erlang: ["Erlang" ,"erl|hrl"],
|
||||
forth: ["Forth", ,"frt|fs|ldr"],
|
||||
haskell: ["Haskell", "hs"],
|
||||
julia: ["Julia", "jl"],
|
||||
prolog: ["Prolog", "plg|prolog"],
|
||||
rust: ["Rust", "rs"]
|
||||
};
|
||||
|
||||
for (var name in modesByName) {
|
||||
var mode = modesByName[name];
|
||||
mode = new Mode(name, mode[0], mode[1]);
|
||||
modesByName[name] = mode;
|
||||
modes.push(mode);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getModeFromPath: getModeFromPath,
|
||||
modes: modes,
|
||||
modesByName: modesByName
|
||||
};
|
||||
|
||||
});
|
||||
|
||||
|
|
@ -220,8 +220,8 @@ function elt(tag, attributes, content) {
|
|||
function optgroup(values) {
|
||||
return values.map(function(item) {
|
||||
if (typeof item == "string")
|
||||
item = {name: item, desc: item};
|
||||
return elt("option", {value: item.name}, item.desc);
|
||||
item = {name: item, caption: item};
|
||||
return elt("option", {value: item.name}, item.caption || item.desc);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,6 @@
|
|||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
/************** modes ***********************/
|
||||
/**
|
||||
* An array containing information about rendering modes.
|
||||
*/
|
||||
var modes = [];
|
||||
/**
|
||||
* Suggests a mode based on the file extension present in the given path
|
||||
|
|
@ -12,7 +8,7 @@ var modes = [];
|
|||
* @returns {object} Returns an object containing information about the
|
||||
* suggested mode.
|
||||
*/
|
||||
function getModeFromPath(path) {
|
||||
function getModeForPath(path) {
|
||||
var mode = modesByName.text;
|
||||
var fileName = path.split(/[\/\\]/).pop();
|
||||
for (var i = 0; i < modes.length; i++) {
|
||||
|
|
@ -24,10 +20,11 @@ function getModeFromPath(path) {
|
|||
return mode;
|
||||
}
|
||||
|
||||
var Mode = function(name, desc, extensions) {
|
||||
var Mode = function(name, caption, extensions) {
|
||||
this.name = name;
|
||||
this.desc = desc;
|
||||
this.caption = caption;
|
||||
this.mode = "ace/mode/" + name;
|
||||
this.extensions = extensions;
|
||||
if (/\^/.test(extensions)) {
|
||||
var re = extensions.replace(/\|(\^)?/g, function(a, b){
|
||||
return "$|" + (b ? "^" : "^.*\\.");
|
||||
|
|
@ -43,95 +40,113 @@ Mode.prototype.supportsFile = function(filename) {
|
|||
return filename.match(this.extRe);
|
||||
};
|
||||
|
||||
/**
|
||||
* An object containing properties that map to rendering modes. Each property
|
||||
* contains an array where element 0 is the name of the mode and element 1
|
||||
* contains information about the file extensions where this mode is
|
||||
* applicable.
|
||||
*/
|
||||
var modesByName = {
|
||||
abap: ["ABAP" , "abap"],
|
||||
asciidoc: ["AsciiDoc" , "asciidoc"],
|
||||
c9search: ["C9Search" , "c9search_results"],
|
||||
coffee: ["CoffeeScript" , "^Cakefile|coffee|cf|cson"],
|
||||
coldfusion: ["ColdFusion" , "cfm"],
|
||||
csharp: ["C#" , "cs"],
|
||||
css: ["CSS" , "css"],
|
||||
curly: ["Curly" , "curly"],
|
||||
dart: ["Dart" , "dart"],
|
||||
diff: ["Diff" , "diff|patch"],
|
||||
dot: ["Dot" , "dot"],
|
||||
ftl: ["FreeMarker" , "ftl"],
|
||||
glsl: ["Glsl" , "glsl|frag|vert"],
|
||||
golang: ["Go" , "go"],
|
||||
groovy: ["Groovy" , "groovy"],
|
||||
haxe: ["haXe" , "hx"],
|
||||
haml: ["HAML" , "haml"],
|
||||
html: ["HTML" , "htm|html|xhtml"],
|
||||
c_cpp: ["C/C++" , "c|cc|cpp|cxx|h|hh|hpp"],
|
||||
clojure: ["Clojure" , "clj"],
|
||||
jade: ["Jade" , "jade"],
|
||||
java: ["Java" , "java"],
|
||||
jsp: ["JSP" , "jsp"],
|
||||
javascript: ["JavaScript" , "js"],
|
||||
json: ["JSON" , "json"],
|
||||
jsx: ["JSX" , "jsx"],
|
||||
latex: ["LaTeX" , "latex|tex|ltx|bib"],
|
||||
less: ["LESS" , "less"],
|
||||
lisp: ["Lisp" , "lisp"],
|
||||
scheme: ["Scheme" , "scm|rkt"],
|
||||
liquid: ["Liquid" , "liquid"],
|
||||
livescript: ["LiveScript" , "ls"],
|
||||
logiql: ["LogiQL" , "logic|lql"],
|
||||
lua: ["Lua" , "lua"],
|
||||
luapage: ["LuaPage" , "lp"], // http://keplerproject.github.com/cgilua/manual.html#templates
|
||||
lucene: ["Lucene" , "lucene"],
|
||||
lsl: ["LSL" , "lsl"],
|
||||
makefile: ["Makefile" , "^GNUmakefile|^makefile|^Makefile|^OCamlMakefile|make"],
|
||||
markdown: ["Markdown" , "md|markdown"],
|
||||
mushcode: ["TinyMUSH" , "mc|mush"],
|
||||
objectivec: ["Objective-C" , "m"],
|
||||
ocaml: ["OCaml" , "ml|mli"],
|
||||
pascal: ["Pascal" , "pas|p"],
|
||||
perl: ["Perl" , "pl|pm"],
|
||||
pgsql: ["pgSQL" , "pgsql"],
|
||||
php: ["PHP" , "php|phtml"],
|
||||
powershell: ["Powershell" , "ps1"],
|
||||
python: ["Python" , "py"],
|
||||
r: ["R" , "r"],
|
||||
rdoc: ["RDoc" , "Rd"],
|
||||
rhtml: ["RHTML" , "Rhtml"],
|
||||
ruby: ["Ruby" , "ru|gemspec|rake|rb"],
|
||||
scad: ["OpenSCAD" , "scad"],
|
||||
scala: ["Scala" , "scala"],
|
||||
scss: ["SCSS" , "scss"],
|
||||
sass: ["SASS" , "sass"],
|
||||
sh: ["SH" , "sh|bash|bat"],
|
||||
sql: ["SQL" , "sql"],
|
||||
stylus: ["Stylus" , "styl|stylus"],
|
||||
svg: ["SVG" , "svg"],
|
||||
tcl: ["Tcl" , "tcl"],
|
||||
tex: ["Tex" , "tex"],
|
||||
text: ["Text" , "txt"],
|
||||
textile: ["Textile" , "textile"],
|
||||
tmsnippet: ["tmSnippet" , "tmSnippet"],
|
||||
toml: ["toml" , "toml"],
|
||||
typescript: ["Typescript" , "typescript|ts|str"],
|
||||
vbscript: ["VBScript" , "vbs"],
|
||||
xml: ["XML" , "xml|rdf|rss|wsdl|xslt|atom|mathml|mml|xul|xbl"],
|
||||
xquery: ["XQuery" , "xq"],
|
||||
yaml: ["YAML" , "yaml"]
|
||||
// todo firstlinematch
|
||||
var supportedModes = {
|
||||
ABAP: ["abap"],
|
||||
ActionScript:["as"],
|
||||
AsciiDoc: ["asciidoc"],
|
||||
AutoHotKey: ["ahk"],
|
||||
BatchFile: ["bat|cmd"],
|
||||
C9Search: ["c9search_results"],
|
||||
C_Cpp: ["c|cc|cpp|cxx|h|hh|hpp"],
|
||||
Clojure: ["clj"],
|
||||
coffee: ["^Cakefile|coffee|cf|cson"],
|
||||
ColdFusion: ["cfm"],
|
||||
CSharp: ["cs"],
|
||||
CSS: ["css"],
|
||||
Curly: ["curly"],
|
||||
Dart: ["dart"],
|
||||
Diff: ["diff|patch"],
|
||||
Dot: ["dot"],
|
||||
Erlang: ["erl|hrl"],
|
||||
Forth: ["frt|fs|ldr"],
|
||||
FreeMarker: ["ftl"],
|
||||
Glsl: ["glsl|frag|vert"],
|
||||
golang: ["go"],
|
||||
Groovy: ["groovy"],
|
||||
HAML: ["haml"],
|
||||
Haskell: ["hs"],
|
||||
haXe: ["hx"],
|
||||
HTML: ["htm|html|xhtml"],
|
||||
Ini: ["Ini|conf"],
|
||||
Jade: ["jade"],
|
||||
Java: ["java"],
|
||||
JavaScript: ["js"],
|
||||
JSON: ["json"],
|
||||
JSONiq: ["jq"],
|
||||
JSP: ["jsp"],
|
||||
JSX: ["jsx"],
|
||||
Julia: ["jl"],
|
||||
LaTeX: ["latex|tex|ltx|bib"],
|
||||
LESS: ["less"],
|
||||
Liquid: ["liquid"],
|
||||
Lisp: ["lisp"],
|
||||
LiveScript: ["ls"],
|
||||
LogiQL: ["logic|lql"],
|
||||
LSL: ["lsl"],
|
||||
Lua: ["lua"],
|
||||
LuaPage: ["lp"],
|
||||
Lucene: ["lucene"],
|
||||
Makefile: ["^GNUmakefile|^makefile|^Makefile|^OCamlMakefile|make"],
|
||||
Markdown: ["md|markdown"],
|
||||
MUSHCode: ["mc|mush"],
|
||||
ObjectiveC: ["m"],
|
||||
OCaml: ["ml|mli"],
|
||||
Pascal: ["pas|p"],
|
||||
Perl: ["pl|pm"],
|
||||
pgSQL: ["pgsql"],
|
||||
PHP: ["php|phtml"],
|
||||
Powershell: ["ps1"],
|
||||
Prolog: ["plg|prolog"],
|
||||
Properties: ["properties"],
|
||||
Python: ["py"],
|
||||
R: ["r"],
|
||||
RDoc: ["Rd"],
|
||||
RHTML: ["Rhtml"],
|
||||
Ruby: ["ru|gemspec|rake|rb"],
|
||||
Rust: ["rs"],
|
||||
SASS: ["sass"],
|
||||
SCAD: ["scad"],
|
||||
Scala: ["scala"],
|
||||
Scheme: ["scm|rkt"],
|
||||
SCSS: ["scss"],
|
||||
SH: ["sh|bash"],
|
||||
snippets: ["snippets"],
|
||||
SQL: ["sql"],
|
||||
Stylus: ["styl|stylus"],
|
||||
SVG: ["svg"],
|
||||
Tcl: ["tcl"],
|
||||
Tex: ["tex"],
|
||||
Text: ["txt"],
|
||||
Textile: ["textile"],
|
||||
Toml: ["toml"],
|
||||
Typescript: ["typescript|ts|str"],
|
||||
VBScript: ["vbs"],
|
||||
Velocity: ["vm"],
|
||||
XML: ["xml|rdf|rss|wsdl|xslt|atom|mathml|mml|xul|xbl"],
|
||||
XQuery: ["xq"],
|
||||
YAML: ["yaml"]
|
||||
};
|
||||
|
||||
for (var name in modesByName) {
|
||||
var mode = modesByName[name];
|
||||
mode = new Mode(name, mode[0], mode[1]);
|
||||
modesByName[name] = mode;
|
||||
var nameOverrides = {
|
||||
ObjectiveC: "Objective-C",
|
||||
CSharp: "C#",
|
||||
golang: "Go",
|
||||
C_Cpp: "C/C++",
|
||||
coffee: "CoffeeScript"
|
||||
};
|
||||
var modesByName = {};
|
||||
for (var name in supportedModes) {
|
||||
var data = supportedModes[name];
|
||||
var displayName = nameOverrides[name] || name;
|
||||
var filename = name.toLowerCase();
|
||||
mode = new Mode(filename, displayName, data[0]);
|
||||
modesByName[filename] = mode;
|
||||
modes.push(mode);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getModeFromPath: getModeFromPath,
|
||||
getModeForPath: getModeForPath,
|
||||
modes: modes,
|
||||
modesByName: modesByName
|
||||
};
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ define(function(require, exports, module) {
|
|||
var oop = require("../lib/oop");
|
||||
var TextMode = require("./text").Mode;
|
||||
var Tokenizer = require("../tokenizer").Tokenizer;
|
||||
var BatchFileHighlightRules = require("./batch_file_highlight_rules").BatchFileHighlightRules;
|
||||
var BatchFileHighlightRules = require("./batchfile_highlight_rules").BatchFileHighlightRules;
|
||||
var FoldMode = require("./folding/cstyle").FoldMode;
|
||||
|
||||
var Mode = function() {
|
||||
Loading…
Add table
Add a link
Reference in a new issue