Merge pull request #1355 from ajaxorg/highlighting/tmmodes

add several new modes autoconverted from textmate
This commit is contained in:
Lennart Kats 2013-05-01 06:08:17 -07:00
commit 28c810bbce
62 changed files with 5418 additions and 284 deletions

View file

@ -489,7 +489,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;

View file

@ -52,7 +52,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;
@ -66,8 +66,8 @@ function makeHuge(txt) {
}
var docs = {
"docs/AsciiDoc.asciidoc": "AsciiDoc",
"docs/javascript.js": "JavaScript",
"docs/AsciiDoc.asciidoc": "AsciiDoc",
"docs/clojure.clj": "Clojure",
"docs/coffeescript.coffee": "CoffeeScript",
"docs/coldfusion.cfm": "ColdFusion",
@ -103,7 +103,7 @@ var docs = {
"docs/luapage.lp": "LuaPage",
"docs/Makefile": "Makefile",
"docs/markdown.md": {name: "Markdown", wrapped: true},
"docs/tinymush.mc": {name: "TinyMUSH"},
"docs/mushcode.mc": {name: "MUSHCode", wrapped: true},
"docs/objectivec.m": {name: "Objective-C"},
"docs/ocaml.ml": "OCaml",
"docs/OpenSCAD.scad": "OpenSCAD",
@ -130,7 +130,7 @@ var docs = {
"docs/tcl.tcl": "Tcl",
"docs/tex.tex": "Tex",
"docs/textile.textile": {name: "Textile", wrapped: true},
"docs/tmSnippet.tmSnippet": "tmSnippet",
"docs/snippets.snippets": "snippets",
"docs/toml.toml": "TOML",
"docs/typescript.ts": "Typescript",
"docs/vbscript.vbs": "VBScript",
@ -138,7 +138,17 @@ var docs = {
"docs/xml.xml": "XML",
"docs/xquery.xq": "XQuery",
"docs/yaml.yaml": "YAML",
"docs/c9search.c9search_results": "C9 Search Results"
"docs/c9search.c9search_results": "C9 Search Results",
"docs/actionscript.as": "ActionScript",
"docs/autohotkey.ahk": "AutoHotKey",
"docs/batchfile.bat": "BatchFile",
"docs/erlang/erl": "Erlang",
"docs/forth.frt": "Forth",
"docs/haskell.hs": "Haskell",
"docs/julia.js": "Julia",
"docs/prolog/plg": "Prolog",
"docs/rust.rs": "Rust"
};
var ownSource = {

View file

@ -0,0 +1,51 @@
package code
{
/*****************************************
* based on textmate actionscript bundle
****************************************/
import fl.events.SliderEvent;
public class Foo extends MovieClip
{
//*************************
// Properties:
public var activeSwatch:MovieClip;
// Color offsets
public var c1:Number = 0; // R
//*************************
// Constructor:
public function Foo()
{
// Respond to mouse events
swatch1_btn.addEventListener(MouseEvent.CLICK,swatchHandler,false,0,false);
previewBox_btn.addEventListener(MouseEvent.MOUSE_DOWN,dragPressHandler);
// Respond to drag events
red_slider.addEventListener(SliderEvent.THUMB_DRAG,sliderHandler);
// Draw a frame later
addEventListener(Event.ENTER_FRAME,draw);
}
protected function clickHandler(event:MouseEvent):void
{
car.transform.colorTransform = new ColorTransform(0,0,0,1,c1,c2,c3);
}
protected function changeRGBHandler(event:Event):void
{
c1 = Number(c1_txt.text);
if(!(c1>=0)){
c1 = 0;
}
updateSliders();
}
}
}

View file

@ -0,0 +1,35 @@
#NoEnv
SetBatchLines -1
CoordMode Mouse, Screen
OnExit GuiClose
zoom := 9
computeSize(){
global as_x
as_x := Round(ws_x/zoom/2 - 0.5)
if (zoom>1) {
pix := Round(zoom)
} ele {
pix := 1
}
ToolTip Message %as_x% %zoom% %ws_x% %hws_x%
}
hdc_frame := DllCall("GetDC", UInt, MagnifierID)
; comment
DrawCross(byRef x="", rX,rY,z, dc){
;specify the style, thickness and color of the cross lines
h_pen := DllCall( "gdi32.dll\CreatePen", Int, 0, Int, 1, UInt, 0x0000FF)
}
;Ctrl ^; Shift +; Win #; Alt !
^NumPadAdd::
^WheelUp::
^;:: ;comment
If(zoom < ws_x and ( A_ThisHotKey = "^WheelUp" or A_ThisHotKey ="^NumPadAdd") )
zoom *= 1.189207115 ; sqrt(sqrt(2))
Gosub,setZoom
return

View file

@ -0,0 +1,15 @@
:: batch file highlighting in Ace!
@echo off
CALL set var1=%cd%
echo unhide everything in %var1%!
:: FOR loop in bat is super strange!
FOR /f "tokens=*" %%G IN ('dir /A:D /b') DO (
echo %var1%%%G
attrib -r -a -h -s "%var1%%%G" /D /S
)
pause
REM that's all

View file

@ -14,8 +14,8 @@ asdad
77
.86
#import("http://dartwatch.com/myOtherLibrary.dart");
#import("myOtherLibrary.dart", prefix:"lib1");
import("http://dartwatch.com/myOtherLibrary.dart");
import("myOtherLibrary.dart", prefix:"lib1");
"""asdasdads
asdadsadsasd

View file

@ -0,0 +1,20 @@
%% A process whose only job is to keep a counter.
%% First version
-module(counter).
-export([start/0, codeswitch/1]).
start() -> loop(0).
loop(Sum) ->
receive
{increment, Count} ->
loop(Sum+Count);
{counter, Pid} ->
Pid ! {counter, Sum},
loop(Sum);
code_switch ->
?MODULE:codeswitch(Sum)
% Force the use of 'codeswitch/1' from the latest MODULE version
end.
codeswitch(Sum) -> loop(Sum).

View file

@ -0,0 +1,41 @@
: HELLO ( -- ) CR ." Hello, world!" ;
HELLO <cr>
Hello, world!
: [CHAR] CHAR POSTPONE LITERAL ; IMMEDIATE
0 value ii 0 value jj
0 value KeyAddr 0 value KeyLen
create SArray 256 allot \ state array of 256 bytes
: KeyArray KeyLen mod KeyAddr ;
: get_byte + c@ ;
: set_byte + c! ;
: as_byte 255 and ;
: reset_ij 0 TO ii 0 TO jj ;
: i_update 1 + as_byte TO ii ;
: j_update ii SArray get_byte + as_byte TO jj ;
: swap_s_ij
jj SArray get_byte
ii SArray get_byte jj SArray set_byte
ii SArray set_byte
;
: rc4_init ( KeyAddr KeyLen -- )
256 min TO KeyLen TO KeyAddr
256 0 DO i i SArray set_byte LOOP
reset_ij
BEGIN
ii KeyArray get_byte jj + j_update
swap_s_ij
ii 255 < WHILE
ii i_update
REPEAT
reset_ij
;
: rc4_byte
ii i_update jj j_update
swap_s_ij
ii SArray get_byte jj SArray get_byte + as_byte SArray get_byte xor
;

View file

@ -0,0 +1,20 @@
-- Type annotation (optional)
fib :: Int -> Integer
-- With self-referencing data
fib n = fibs !! n
where fibs = 0 : scanl (+) 1 fibs
-- 0,1,1,2,3,5,...
-- Same, coded directly
fib n = fibs !! n
where fibs = 0 : 1 : next fibs
next (a : t@(b:_)) = (a+b) : next t
-- Similar idea, using zipWith
fib n = fibs !! n
where fibs = 0 : 1 : zipWith (+) fibs (tail fibs)
-- Using a generator function
fib n = fibs (0,1) !! n
where fibs (a,b) = a : fibs (b,a+b)

View file

@ -0,0 +1,15 @@
for op = (:+, :*, :&, :|, :$)
@eval ($op)(a,b,c) = ($op)(($op)(a,b),c)
end
function g(x,y)
return x * y
x + y
end
cd("data") do
open("outfile", "w") do f
write(f, data)
end
end

View file

@ -0,0 +1,18 @@
partition([], _, [], []).
partition([X|Xs], Pivot, Smalls, Bigs) :-
( X @< Pivot ->
Smalls = [X|Rest],
partition(Xs, Pivot, Rest, Bigs)
; Bigs = [X|Rest],
partition(Xs, Pivot, Smalls, Rest)
).
quicksort([]) --> [].
quicksort([X|Xs]) -->
{ partition(Xs, X, Smaller, Bigger) },
quicksort(Smaller), [X], quicksort(Bigger).
perfect(N) :-
between(1, inf, N), U is N // 2,
findall(D, (between(1,U,D), N mod D =:= 0), Ds),
sumlist(Ds, N).

View file

@ -0,0 +1,20 @@
use core::rand::RngUtil;
fn main() {
for ["Alice", "Bob", "Carol"].each |&name| {
do spawn {
let v = rand::Rng().shuffle([1, 2, 3]);
for v.each |&num| {
print(fmt!("%s says: '%d'\n", name, num + 1))
}
}
}
}
fn map<T, U>(vector: &[T], function: &fn(v: &T) -> U) -> ~[U] {
let mut accumulator = ~[];
for vec::each(vector) |element| {
accumulator.push(function(element));
}
return accumulator;
}

View file

@ -1,26 +1,26 @@
# Function
snippet fun
function ${1?:function_name}(${2:argument}) {
${3:// body...}
}
# Anonymous Function
regex /((=)\s*|(:)\s*|(\()|\b)/f/(\))?/
name f
function${M1?: ${1:functionName}}($2) {
${0:$TM_SELECTED_TEXT}
}${M2?;}${M3?,}${M4?)}
# Immediate function
trigger \(?f\(
endTrigger \)?
snippet f(
(function(${1}) {
${0:${TM_SELECTED_TEXT:/* code */}}
}(${1}));
# if
snippet if
if (${1:true}) {
${0}
}
# Function
snippet fun
function ${1?:function_name}(${2:argument}) {
${3:// body...}
}
# Anonymous Function
regex /((=)\s*|(:)\s*|(\()|\b)/f/(\))?/
name f
function${M1?: ${1:functionName}}($2) {
${0:$TM_SELECTED_TEXT}
}${M2?;}${M3?,}${M4?)}
# Immediate function
trigger \(?f\(
endTrigger \)?
snippet f(
(function(${1}) {
${0:${TM_SELECTED_TEXT:/* code */}}
}(${1}));
# if
snippet if
if (${1:true}) {
${0}
}

View file

@ -1,128 +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 = {
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"],
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|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"],
velocity: ["Velocity" , "vm"],
xml: ["XML" , "xml|rdf|rss|wsdl|xslt|atom|mathml|mml|xul|xbl"],
xquery: ["XQuery" , "xq"],
jsoniq: ["JSONiq" , "jq"],
yaml: ["YAML" , "yaml"]
};
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
};
});

View file

@ -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);
});
}