diff --git a/.gitignore b/.gitignore index 813d6c10..59ec847b 100644 --- a/.gitignore +++ b/.gitignore @@ -2,9 +2,11 @@ .DS_Store *.swp *.tmp +*~ # Project files that should not be in the repo .* +\#* !/.gitignore .*.gz *.tmTheme.js diff --git a/.gitmodules b/.gitmodules index 4678c516..07bbe371 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,6 @@ [submodule "doc/wiki"] path = doc/wiki - url = git://github.com/ajaxorg/ace.wiki.git + url = https://github.com/ajaxorg/ace.wiki.git [submodule "build"] path = build - url = git://github.com/ajaxorg/ace-builds.git + url = https://github.com/ajaxorg/ace-builds.git diff --git a/CNAME b/CNAME new file mode 100644 index 00000000..75431b15 --- /dev/null +++ b/CNAME @@ -0,0 +1 @@ +ace.c9.io diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c44edcb0..062af59c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -7,16 +7,9 @@ Feel free to fork and improve/enhance Ace any way you want. If you feel that the There are two versions of the agreement: -1. [The Individual CLA](https://github.com/ajaxorg/ace/raw/master/doc/Contributor_License_Agreement-v2.pdf): use this version if you're working on an ajax.org in your spare time, or can clearly claim ownership of copyright in what you'll be submitting. -2. [The Corporate CLA](https://github.com/ajaxorg/ace/raw/master/doc/Corporate_Contributor_License_Agreement-v2.pdf): have your corporate lawyer review and submit this if your company is going to be contributing to ajax.org projects +1. [The Individual CLA](https://docs.google.com/a/c9.io/forms/d/1MfmfrxqD_PNlNsuK0lC2KSelRLxGLGfh_wEcG0ijVvo/viewform): use this version if you're working on the Cloud9 SDK or open source projects in your spare time, or can clearly claim ownership of copyright in what you'll be submitting. +2. [The Corporate CLA](https://docs.google.com/a/c9.io/forms/d/1vFejn4111GdnCNuQ6BfnJDaxdsUEMD4KCo1ayovAfu0/viewform): have your corporate lawyer review and submit this if your company is going to be contributing to the Cloud9 SDK and/or open source projects. -If you want to contribute to an ajax.org project please print the CLA and fill it out and sign it. Then either send it by snail mail or fax to us or send it back scanned (or as a photo) by email. +If you want to contribute to the Cloud9 SDK and/or open source projects please go to the online form, fill it out and submit it. -Email: ace+cla@c9.io - -Fax: +31 (0) 206388953 - -Address: Ajax.org B.V. - Keizersgracht 241 - 1016 EA, Amsterdam - the Netherlands \ No newline at end of file +Happy coding, Cloud9 diff --git a/ChangeLog.txt b/ChangeLog.txt index d4f5e1d1..3077d171 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,4 +1,103 @@ -2013.06.04 Version 1.1.01 +Version 1.2.0-pre + +* New Features + - Indented soft wrap (danyaPostfactum) + +* API Changes + - unified delta types `{start, end, action, lines}` (Alden Daniels https://github.com/ajaxorg/ace/pull/1745) + - "change" event listeners on session and editor get delta objects directly + +2015.04.03 Version 1.1.9 + + - Small Enhancements and Bugfixes + +2014.11.08 Version 1.1.8 + +* API Changes + - `editor.commands.commandKeyBinding` now contains direct map from keys to commands instead of grouping them by hashid + +* New Features + - Improved autoindent for html and php modes (Adam Jimenez) + - Find All from searchbox (Colton Voege) + +* new language modes + - Elixir, Elm + +2014.09.21 Version 1.1.7 + +* Bugfixes + - fix several bugs in autocompletion + - workaround for inaccurate getBoundingClientRect on chrome 37 + +2014.08.17 Version 1.1.6 + +* Bugfixes + - fix regression in double tap to highlight + - Improved Latex Mode (Daniel Felder) + +* API Changes + - editor.destroy destroys editor.session too (call editor.setSession(null) to prevent that) + +* new language modes + - Praat (José Joaquín Atria) + - Eiffel (Victorien Elvinger) + - G-code (Adam Joseph Cook) + +2014.07.09 Version 1.1.5 + +* Bugfixes + - fix regression in autocomplete popup + +* new language modes + - gitignore (Devon Carew) + +2014.07.01 Version 1.1.4 + +* New Features + - Highlight matching tags (Adam Jimenez) + - Improved jump to matching command (Adam Jimenez) + +* new language modes + - AppleScript (Yaogang Lian) + - Vala + +2014.03.08 Version 1.1.3 + +* New Features + - Allow syntax checkers to be loaded from CDN (Derk-Jan Hartman) + - Add ColdFusion behavior (Abram Adams) + - add showLineNumbers option + - Add html syntax checker (danyaPostfactum) + +* new language modes + - Gherkin (Patrick Nevels) + - Smarty + +2013.12.02 Version 1.1.2 + +* New Features + - Accessibility Theme for Ace (Peter Xiao) + - use snipetManager for expanding emmet snippets + - update jshint to 2.1.4 + - improve php syntax checker (jdalegonzalez) + - add option for autoresizing + - add option for autohiding vertical scrollbar + - improvements to highlighting of xml like languages (danyaPostfactum) + - add support for autocompletion and snippets (gjtorikyan danyaPostfactum and others) + - add option to merge similar changes in undo history + - add scrollPastEnd option + - use html5 dragndrop for text dragging (danyaPostfactum) + +* API Changes + - fixed typo in HashHandler commmandManager + +* new language modes + - Nix (Zef Hemel) + - Protobuf (Zef Hemel) + - Soy + - Handlebars + +2013.06.04 Version 1.1.1 - Improved emacs keybindings (Robert Krahn) - Added markClean, isClean methods to UndoManager (Joonsoo Jeon) diff --git a/Makefile b/Makefile index 373d4c88..29cf0495 100644 --- a/Makefile +++ b/Makefile @@ -13,7 +13,17 @@ pre_build: build: pre_build ./Makefile.dryice.js normal ./Makefile.dryice.js demo - ./Makefile.dryice.js bm + +# Minimal build: call Makefile.dryice.js only if our sources changed +basic: build/src/ace.js + +build/src/ace.js : ${wildcard lib/*} \ + ${wildcard lib/*/*} \ + ${wildcard lib/*/*/*} \ + ${wildcard lib/*/*/*/*} \ + ${wildcard lib/*/*/*/*/*} \ + ${wildcard lib/*/*/*/*/*/*} + ./Makefile.dryice.js doc: cd doc;\ diff --git a/Makefile.dryice.js b/Makefile.dryice.js index 73abf1c1..0ce7c657 100755 --- a/Makefile.dryice.js +++ b/Makefile.dryice.js @@ -31,22 +31,23 @@ var fs = require("fs"); var path = require("path"); -if (!fs.existsSync) - fs.existsSync = path.existsSync; -else - path.existsSync = fs.existsSync; -var copy = require('dryice').copy; +var copy = require('architect-build/copy'); +var build = require('architect-build/build'); var ACE_HOME = __dirname; var BUILD_DIR = ACE_HOME + "/build"; +var CACHE = {}; function main(args) { + if (args.indexOf("updateModes") !== -1) { + return updateModes(); + } var type = "minimal"; args = args.map(function(x) { if (x[0] == "-" && x[1] != "-") return "-" + x; return x; - }); + }).filter(Boolean); if (args[2] && (args[2][0] != "-" || args[2].indexOf("h") != -1)) type = args[2]; @@ -66,22 +67,24 @@ function main(args) { ace(); } else if (type == "demo") { demo(); - } else if (type == "bm") { - bookmarklet(); } else if (type == "full") { - demo(ace()); - bookmarklet(); + ace(); + demo(); + } else if (type == "highlighter") { + // TODO } } +} +function showHelp(type) { console.log("--- Ace Dryice Build Tool ---"); console.log(""); console.log("Options:"); - console.log(" minimal Places necessary Ace files out in build dir; uses configuration flags below [default]"); - console.log(" normal Runs four Ace builds--minimal, minimal-noconflict, minimal-min, and minimal-noconflict-min"); - console.log(" demo Runs demo build of Ace"); - console.log(" bm Runs bookmarklet build of Ace"); - console.log(" full all of above"); + console.log(" minimal Places necessary Ace files out in build dir; uses configuration flags below [default]"); + console.log(" normal Runs four Ace builds--minimal, minimal-noconflict, minimal-min, and minimal-noconflict-min"); + console.log(" demo Runs demo build of Ace"); + console.log(" full all of above"); + console.log(" highlighter "); console.log("args:"); console.log(" --target ./path path to build folder"); console.log("flags:"); @@ -90,94 +93,34 @@ function main(args) { console.log(" --nc namespace require"); console.log(" --s shrinkwrap (combines all output files into one)"); console.log(""); - if (BUILD_DIR) - console.log(" output generated in " + type + __dirname + "/" + BUILD_DIR) -} - -function bookmarklet() { - var targetDir = BUILD_DIR + "/textarea"; - copy({ - source: "build_support/editor_textarea.html", - dest: targetDir + '/editor.html' - }); - copy({ - source: "build_support/style.css", - dest: targetDir + '/style.css' - }); - - buildAce({ - targetDir: targetDir + "/src", - ns: "__ace_shadowed__", - exportModule: "ace/ext/textarea", - compress: false, - noconflict: true, - suffix: "", - name: "ace-bookmarklet", - workers: [], - keybindings: [] - }); + if (type) + console.log(" output for " + type + " generated in " + BUILD_DIR); } function ace() { - console.log('# ace ---------'); - - // uncompressed - var project = buildAce({ - compress: false, - noconflict: false - }); - buildAce({ - compress: false, - noconflict: true - }); - - // compressed - buildAce({ - compress: true, - noconflict: false - }); - buildAce({ - compress: true, - noconflict: true - }); - console.log('# ace License | Readme | Changelog ---------'); - copy({ - source: ACE_HOME + "/build_support/editor.html", - dest: BUILD_DIR + "/editor.html" - }); - copy({ - source: ACE_HOME + "/LICENSE", - dest: BUILD_DIR + "/LICENSE" - }); - copy({ - source: ACE_HOME + "/ChangeLog.txt", - dest: BUILD_DIR + "/ChangeLog.txt" - }); + copy.file(ACE_HOME + "/build_support/editor.html", BUILD_DIR + "/editor.html"); + copy.file(ACE_HOME + "/LICENSE", BUILD_DIR + "/LICENSE"); + copy.file(ACE_HOME + "/ChangeLog.txt", BUILD_DIR + "/ChangeLog.txt"); - return project; + console.log('# ace ---------'); + for (var i = 0; i < 4; i++) + buildAce({compress: i & 2, noconflict: i & 1}); } -function demo(project) { - project = project || buildAce({ - compress: false, - noconflict: false, - coreOnly: true - }); +function demo() { console.log('# kitchen sink ---------'); - var version, ref; + var version = "", ref = ""; try { version = JSON.parse(fs.readFileSync(ACE_HOME + "/package.json")).version; ref = fs.readFileSync(ACE_HOME + "/.git-ref").toString(); - } catch(e) { - ref = ""; - version = ""; - } + } catch(e) {} function changeComments(data) { return (data + .replace("doc/site/images/ace-logo.png", "demo/kitchen-sink/ace-logo.png") .replace(//g, "") .replace(/PACKAGE\-\->|")} + function script(str) {result.push('')} + scripts.forEach(function(s) { + s = s.replace(/"/g, ""); + if (s == "ace/ace") { + comment("load ace"); + script("ace"); + } else { + var extName = s.match(/[^/]*$/)[0]; + comment("load ace " + extName + " extension"); + script("ext-" + extName); + } + }); + result.push("
- \ No newline at end of file + diff --git a/build b/build index cf536740..a4e495d8 160000 --- a/build +++ b/build @@ -1 +1 @@ -Subproject commit cf536740d866276b65cfd351610001c2a841e751 +Subproject commit a4e495d8901876c6bafe3870a35cb8e32c827e97 diff --git a/build_support/editor_textarea.html b/build_support/bookmarklet.html similarity index 63% rename from build_support/editor_textarea.html rename to build_support/bookmarklet.html index bb691c11..88355f78 100644 --- a/build_support/editor_textarea.html +++ b/build_support/bookmarklet.html @@ -20,7 +20,7 @@ function foo() { var bar = true; }
SourceUrl:
-
+

@@ -49,63 +49,60 @@ function foo() { + + + + + + + diff --git a/demo/autoresize.html b/demo/autoresize.html new file mode 100644 index 00000000..b0464ecd --- /dev/null +++ b/demo/autoresize.html @@ -0,0 +1,68 @@ + + + + + + Editor + + + +
autoresizing editor
+
+
minHeight = 2 lines
+
+

+
+

+
+
+
+
+
+
+
+
diff --git a/demo/chromevox.html b/demo/chromevox.html
new file mode 100644
index 00000000..9aa65bae
--- /dev/null
+++ b/demo/chromevox.html
@@ -0,0 +1,39 @@
+
+
+
+  
+  ACE ChromeVox demo
+  
+
+
+
+

+
+
+
+
+
+
+
+
+
+
diff --git a/demo/demo_helper.js b/demo/demo_helper.js
deleted file mode 100644
index 116338af..00000000
--- a/demo/demo_helper.js
+++ /dev/null
@@ -1,3 +0,0 @@
-ace.require("ace/lib/net").get(document.baseURI, function(t){
-    editor.setValue(t, 1);
-})
\ No newline at end of file
diff --git a/demo/emmet.html b/demo/emmet.html
new file mode 100644
index 00000000..bd0d4abe
--- /dev/null
+++ b/demo/emmet.html
@@ -0,0 +1,43 @@
+
+
+
+  
+  ACE Emmet demo
+  
+
+
+
+

+
+
+
+
+
+
+
+
+
+
diff --git a/demo/ie7.html b/demo/ie7.html
new file mode 100644
index 00000000..f5db8667
--- /dev/null
+++ b/demo/ie7.html
@@ -0,0 +1,44 @@
+
+
+
+  
+  
+  ACE Editor StatusBar Demo
+  
+
+
+
+
+require("ace/ext/old_ie");
+// now ace will work even on ie7!
+var editor = ace.edit("editor");
+
+ + + + + + + + diff --git a/demo/keyboard_shortcuts.html b/demo/keyboard_shortcuts.html index 4a579d37..3d01f559 100644 --- a/demo/keyboard_shortcuts.html +++ b/demo/keyboard_shortcuts.html @@ -22,8 +22,11 @@

     
-
+
 
 
-
+
 
 
diff --git a/demo/kitchen-sink/demo.js b/demo/kitchen-sink/demo.js
index a2a7fbc8..33b2dbc0 100644
--- a/demo/kitchen-sink/demo.js
+++ b/demo/kitchen-sink/demo.js
@@ -33,6 +33,13 @@ define(function(require, exports, module) {
 "use strict";
 
 require("ace/lib/fixoldbrowsers");
+
+require("ace/multi_select");
+require("ace/ext/spellcheck");
+require("./inline_editor");
+require("./dev_util");
+require("./file_drop");
+
 var config = require("ace/config");
 config.init();
 var env = {};
@@ -51,12 +58,14 @@ var HashHandler = require("ace/keyboard/hash_handler").HashHandler;
 
 var Renderer = require("ace/virtual_renderer").VirtualRenderer;
 var Editor = require("ace/editor").Editor;
-var MultiSelect = require("ace/multi_select").MultiSelect;
 
 var whitespace = require("ace/ext/whitespace");
 
+
+
 var doclist = require("./doclist");
 var modelist = require("ace/ext/modelist");
+var themelist = require("ace/ext/themelist");
 var layout = require("./layout");
 var TokenTooltip = require("./token_tooltip").TokenTooltip;
 var util = require("./util");
@@ -69,6 +78,12 @@ var ElasticTabstopsLite = require("ace/ext/elastic_tabstops_lite").ElasticTabsto
 
 var IncrementalSearch = require("ace/incremental_search").IncrementalSearch;
 
+
+var workerModule = require("ace/worker/worker_client");
+if (location.href.indexOf("noworker") !== -1) {
+    workerModule.WorkerClient = workerModule.UIWorkerClient;
+}
+
 /*********** create editor ***************************/
 var container = document.getElementById("editor-container");
 
@@ -82,11 +97,7 @@ split.on("focus", function(editor) {
 });
 env.split = split;
 window.env = env;
-window.ace = env.editor;
-env.editor.setAnimatedScroll(true);
 
-// add multiple cursor support to editor
-require("ace/multi_select").MultiSelect(env.editor);
 
 var consoleEl = dom.createElement("div");
 container.parentNode.appendChild(consoleEl);
@@ -155,11 +166,11 @@ env.editor.commands.addCommands([{
     bindKey: "ctrl+enter",
     exec: function(editor) {
         try {
-            var r = eval(editor.getCopyText()||editor.getValue());
+            var r = window.eval(editor.getCopyText() || editor.getValue());
         } catch(e) {
             r = e;
         }
-        editor.cmdLine.setValue(r + "")
+        editor.cmdLine.setValue(r + "");
     },
     readOnly: true
 }, {
@@ -168,8 +179,28 @@ env.editor.commands.addCommands([{
     exec: function(editor) {
         config.loadModule("ace/ext/keybinding_menu", function(module) {
             module.init(editor);
-            editor.showKeyboardShortcuts()
-        })
+            editor.showKeyboardShortcuts();
+        });
+    }
+}, {
+    name: "increaseFontSize",
+    bindKey: "Ctrl-=|Ctrl-+",
+    exec: function(editor) {
+        var size = parseInt(editor.getFontSize(), 10) || 12;
+        editor.setFontSize(size + 1);
+    }
+}, {
+    name: "decreaseFontSize",
+    bindKey: "Ctrl+-|Ctrl-_",
+    exec: function(editor) {
+        var size = parseInt(editor.getFontSize(), 10) || 12;
+        editor.setFontSize(Math.max(size - 1 || 1));
+    }
+}, {
+    name: "resetFontSize",
+    bindKey: "Ctrl+0|Ctrl-Numpad0",
+    exec: function(editor) {
+        editor.setFontSize(12);
     }
 }]);
 
@@ -193,7 +224,31 @@ var commands = env.editor.commands;
 commands.addCommand({
     name: "save",
     bindKey: {win: "Ctrl-S", mac: "Command-S"},
-    exec: function() {alert("Fake Save File");}
+    exec: function(arg) {
+        var session = env.editor.session;
+        var name = session.name.match(/[^\/]+$/);
+        localStorage.setItem(
+            "saved_file:" + name,
+            session.getValue()
+        );
+        env.editor.cmdLine.setValue("saved "+ name);
+    }
+});
+
+commands.addCommand({
+    name: "load",
+    bindKey: {win: "Ctrl-O", mac: "Command-O"},
+    exec: function(arg) {
+        var session = env.editor.session;
+        var name = session.name.match(/[^\/]+$/);
+        var value = localStorage.getItem("saved_file:" + name);
+        if (typeof value == "string") {
+            session.setValue(value);
+            env.editor.cmdLine.setValue("loaded "+ name);
+        } else {
+            env.editor.cmdLine.setValue("no previuos value saved for "+ name);
+        }
+    }
 });
 
 var keybindings = {
@@ -241,6 +296,7 @@ var showGutterEl = document.getElementById("show_gutter");
 var showPrintMarginEl = document.getElementById("show_print_margin");
 var highlightSelectedWordE = document.getElementById("highlight_selected_word");
 var showHScrollEl = document.getElementById("show_hscroll");
+var showVScrollEl = document.getElementById("show_vscroll");
 var animateScrollEl = document.getElementById("animate_scroll");
 var softTabEl = document.getElementById("soft_tab");
 var behavioursEl = document.getElementById("enable_behaviours");
@@ -259,26 +315,25 @@ doclist.history = doclist.docs.map(function(doc) {
 });
 doclist.history.index = 0;
 doclist.cycleOpen = function(editor, dir) {
-    var h = this.history
+    var h = this.history;
     h.index += dir;
-    if (h.index >= h.length) 
+    if (h.index >= h.length)
         h.index = 0;
     else if (h.index <= 0)
         h.index = h.length - 1;
     var s = h[h.index];
     docEl.value = s;
     docEl.onchange();
-    h.index
-}
+};
 doclist.addToHistory = function(name) {
-    var h = this.history
+    var h = this.history;
     var i = h.indexOf(name);
     if (i != h.index) {
         if (i != -1)
             h.splice(i, 1);
         h.index = h.push(name);
     }
-}
+};
 
 bindDropdown("doc", function(name) {
     doclist.loadDoc(name, function(session) {
@@ -316,20 +371,26 @@ function updateUIEditorOptions() {
     saveOption(behavioursEl, editor.getBehavioursEnabled());
 }
 
+themelist.themes.forEach(function(x){ x.value = x.theme });
+fillDropdown(themeEl, {
+    Bright: themelist.themes.filter(function(x){return !x.isDark}),
+    Dark: themelist.themes.filter(function(x){return x.isDark}),
+});
+
 event.addListener(themeEl, "mouseover", function(e){
-    this.desiredValue = e.target.value;
-    if (!this.$timer)
-        this.$timer = setTimeout(this.updateTheme);
+    themeEl.desiredValue = e.target.value;
+    if (!themeEl.$timer)
+        themeEl.$timer = setTimeout(themeEl.updateTheme);
 });
 
 event.addListener(themeEl, "mouseout", function(e){
-    this.desiredValue = null;
-    if (!this.$timer)
-        this.$timer = setTimeout(this.updateTheme, 20);
+    themeEl.desiredValue = null;
+    if (!themeEl.$timer)
+        themeEl.$timer = setTimeout(themeEl.updateTheme, 20);
 });
 
 themeEl.updateTheme = function(){
-    env.split.setTheme(themeEl.desiredValue || themeEl.selectedValue);
+    env.split.setTheme((themeEl.desiredValue || themeEl.selectedValue));
     themeEl.$timer = null;
 };
 
@@ -354,28 +415,11 @@ bindDropdown("folding", function(value) {
 });
 
 bindDropdown("soft_wrap", function(value) {
-    var session = env.editor.session;
-    var renderer = env.editor.renderer;
-    switch (value) {
-        case "off":
-            session.setUseWrapMode(false);
-            renderer.setPrintMarginColumn(80);
-            break;
-        case "free":
-            session.setUseWrapMode(true);
-            session.setWrapLimitRange(null, null);
-            renderer.setPrintMarginColumn(80);
-            break;
-        default:
-            session.setUseWrapMode(true);
-            var col = parseInt(value, 10);
-            session.setWrapLimitRange(col, col);
-            renderer.setPrintMarginColumn(col);
-    }
+    env.editor.setOption("wrap", value);
 });
 
 bindCheckbox("select_style", function(checked) {
-    env.editor.setSelectionStyle(checked ? "line" : "text");
+    env.editor.setOption("selectionStyle", checked ? "line" : "text");
 });
 
 bindCheckbox("highlight_active", function(checked) {
@@ -403,7 +447,11 @@ bindCheckbox("highlight_selected_word", function(checked) {
 });
 
 bindCheckbox("show_hscroll", function(checked) {
-    env.editor.renderer.setHScrollBarAlwaysVisible(checked);
+    env.editor.setOption("hScrollBarAlwaysVisible", checked);
+});
+
+bindCheckbox("show_vscroll", function(checked) {
+    env.editor.setOption("vScrollBarAlwaysVisible", checked);
 });
 
 bindCheckbox("animate_scroll", function(checked) {
@@ -424,6 +472,9 @@ bindCheckbox("fade_fold_widgets", function(checked) {
 bindCheckbox("read_only", function(checked) {
     env.editor.setReadOnly(checked);
 });
+bindCheckbox("scrollPastEnd", function(checked) {
+    env.editor.setOption("scrollPastEnd", checked);
+});
 
 bindDropdown("split", function(value) {
     var sp = env.split;
@@ -475,59 +526,20 @@ bindCheckbox("highlight_token", function(checked) {
     }
 });
 
-/************** dragover ***************************/
-event.addListener(container, "dragover", function(e) {
-    var types = e.dataTransfer.types;
-    if (types && Array.prototype.indexOf.call(types, 'Files') !== -1)
-        return event.preventDefault(e);
-});
-
-event.addListener(container, "drop", function(e) {
-    var file;
-    try {
-        file = e.dataTransfer.files[0];
-        if (window.FileReader) {
-            var reader = new FileReader();
-            reader.onload = function() {
-                var mode = modelist.getModeForPath(file.name);
-
-                env.editor.session.doc.setValue(reader.result);
-                modeEl.value = mode.name;
-                env.editor.session.setMode(mode.mode);
-                env.editor.session.modeName = mode.name;
-            };
-            reader.readAsText(file);
-        }
-        return event.preventDefault(e);
-    } catch(err) {
-        return event.stopEvent(e);
-    }
-});
-
-
-
 var StatusBar = require("ace/ext/statusbar").StatusBar;
 new StatusBar(env.editor, cmdLine.container);
 
 
 var Emmet = require("ace/ext/emmet");
-net.loadScript("https://rawgithub.com/nightwing/emmet-core/master/emmet.js", function() {
+net.loadScript("https://cloud9ide.github.io/emmet-core/emmet.js", function() {
     Emmet.setCore(window.emmet);
     env.editor.setOption("enableEmmet", true);
-})
+});
 
 
-require("ace/placeholder").PlaceHolder;
+// require("ace/placeholder").PlaceHolder;
 
-var snippetManager = require("ace/snippets").snippetManager
-var jsSnippets = require("ace/snippets/javascript");
-window.snippetManager = snippetManager
-saveSnippets()
-
-function saveSnippets() {
-    jsSnippets.snippets = snippetManager.parseSnippetFile(jsSnippets.snippetText);
-    snippetManager.register(jsSnippets.snippets, "javascript")
-}
+var snippetManager = require("ace/snippets").snippetManager;
 
 env.editSnippets = function() {
     var sp = env.split;
@@ -538,25 +550,36 @@ env.editSnippets = function() {
     sp.setSplits(1);
     sp.setSplits(2);
     sp.setOrientation(sp.BESIDE);
-    var editor = sp.$editors[1]
-    if (!env.snippetSession) {
-        var file = jsSnippets.snippetText;
-        env.snippetSession = doclist.initDoc(file, "", {});
-        env.snippetSession.setMode("ace/mode/tmsnippet");
-        env.snippetSession.setUseSoftTabs(false);
+    var editor = sp.$editors[1];
+    var id = sp.$editors[0].session.$mode.$id || "";
+    var m = snippetManager.files[id];
+    if (!doclist["snippets/" + id]) {
+        var text = m.snippetText;
+        var s = doclist.initDoc(text, "", {});
+        s.setMode("ace/mode/snippets");
+        doclist["snippets/" + id] = s;
     }
     editor.on("blur", function() {
-        jsSnippets.snippetText = editor.getValue();
-        saveSnippets();
-    })
-    editor.setSession(env.snippetSession, 1);
+        m.snippetText = editor.getValue();
+        snippetManager.unregister(m.snippets);
+        m.snippets = snippetManager.parseSnippetFile(m.snippetText, m.scope);
+        snippetManager.register(m.snippets);
+    });
+    sp.$editors[0].once("changeMode", function() {
+        sp.setSplits(1);
+    });
+    editor.setSession(doclist["snippets/" + id], 1);
     editor.focus();
-}
+};
 
-ace.commands.bindKey("Tab", function(editor) {
-    var success = snippetManager.expandWithTab(editor);
-    if (!success)
-        editor.execCommand("indent");
-})
+require("ace/ext/language_tools");
+env.editor.setOptions({
+    enableBasicAutocompletion: true,
+    enableLiveAutocompletion: false,
+    enableSnippets: true
+});
+
+var beautify = require("ace/ext/beautify");
+env.editor.commands.addCommands(beautify.commands);
 
 });
diff --git a/demo/kitchen-sink/dev_util.js b/demo/kitchen-sink/dev_util.js
new file mode 100644
index 00000000..f466285d
--- /dev/null
+++ b/demo/kitchen-sink/dev_util.js
@@ -0,0 +1,217 @@
+/* ***** 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.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+define(function(require, exports, module) {
+var dom = require("ace/lib/dom");
+var Range = require("ace/range").Range;
+function warn() {
+    var s = (new Error()).stack || "";
+    s = s.split("\n");
+    if (s[1] == "Error") s.shift(); // remove error description on chrome
+    s.shift(); // remove warn
+    s.shift(); // remove the getter
+    s = s.join("\n");
+    // allow easy access to ace in console, but not in ace code
+    if (!/at Object.InjectedScript.|@debugger eval|snippets:\/{3}|\(:\d+:\d+\)/.test(s)) {
+        console.error("trying to access to global variable");
+    }
+}
+function def(o, key, get) {
+    try {
+        Object.defineProperty(o, key, {
+            configurable: true, 
+            get: get,
+            set: function(val) {
+                delete o[key];
+                o[key] = val;
+            }
+        });
+    } catch(e) {
+        console.error(e);
+    }
+}
+def(window, "ace", function(){ warn(); return window.env.editor });
+def(window, "editor", function(){ warn(); return window.env.editor });
+def(window, "session", function(){ warn(); return window.env.editor.session });
+def(window, "split", function(){ warn(); return window.env.split });
+
+
+def(window, "devUtil", function(){ warn(); return exports });
+exports.showTextArea = function(argument) {
+    dom.importCssString("\
+      .ace_text-input {\
+        position: absolute;\
+        z-index: 10!important;\
+        width: 6em!important;\
+        height: 1em;\
+        opacity: 1!important;\
+        background: rgba(0, 92, 255, 0.11);\
+        border: none;\
+        font: inherit;\
+        padding: 0 1px;\
+        margin: 0 -1px;\
+        text-indent: 0em;\
+    }\
+    ");
+};
+
+exports.addGlobals = function() {
+    window.oop = require("ace/lib/oop");
+    window.dom = require("ace/lib/dom");
+    window.Range = require("ace/range").Range;
+    window.Editor = require("ace/editor").Editor;
+    window.assert = require("ace/test/asyncjs/assert");
+    window.asyncjs = require("ace/test/asyncjs/async");
+    window.UndoManager = require("ace/undomanager").UndoManager;
+    window.EditSession = require("ace/edit_session").EditSession;
+    window.MockRenderer = require("ace/test/mockrenderer").MockRenderer;
+    window.EventEmitter = require("ace/lib/event_emitter").EventEmitter;
+    
+    window.getSelection = getSelection;
+    window.setSelection = setSelection;
+    window.testSelection = testSelection;
+};
+
+function getSelection(editor) {
+    var data = editor.multiSelect.toJSON();
+    if (!data.length) data = [data];
+    data = data.map(function(x) {
+        var a, c;
+        if (x.isBackwards) {
+            a = x.end;
+            c = x.start;
+        } else {
+            c = x.end;
+            a = x.start;
+        }
+        return Range.comparePoints(a, c) 
+            ? [a.row, a.column, c.row, c.column]
+            : [a.row, a.column];
+    });
+    return data.length > 1 ? data : data[0];
+}
+function setSelection(editor, data) {
+    if (typeof data[0] == "number")
+        data = [data];
+    editor.selection.fromJSON(data.map(function(x) {
+        var start = {row: x[0], column: x[1]};
+        var end = x.length == 2 ? start : {row: x[2], column: x[3]};
+        var isBackwards = Range.comparePoints(start, end) > 0;
+        return isBackwards ? {
+            start: end,
+            end: start,
+            isBackwards: true
+        } : {
+            start: start,
+            end: end,
+            isBackwards: true
+        };
+    }));
+}
+function testSelection(editor, data) {
+    assert.equal(getSelection(editor) + "", data + "");
+}
+
+exports.recordTestCase = function() {
+    exports.addGlobals();
+    var editor = window.editor;
+    var testcase = window.testcase = [];
+    var assert;
+
+    testcase.push({
+        type: "setValue",
+        data: editor.getValue()
+    }, {
+        type: "setSelection",
+        data: getSelection(editor)
+    });
+    editor.commands.on("afterExec", function(e) {
+        testcase.push({
+            type: "exec",
+            data: e
+        });
+        testcase.push({
+            type: "value",
+            data: editor.getValue()
+        });
+        testcase.push({
+            type: "selection",
+            data: getSelection(editor)
+        });
+    });
+    editor.on("mouseup", function() {
+        testcase.push({
+            type: "setSelection",
+            data: getSelection(editor)
+        });
+    });
+    
+    testcase.toString = function() {
+        var lastValue = "";
+        // var lastSelection = ""
+        var str = this.map(function(x) {
+            var data = x.data;
+            switch (x.type) {
+                case "exec": 
+                    return 'editor.execCommand("' 
+                        + data.command.name
+                        + (data.args ? '", ' + JSON.stringify(data.args) : '"')
+                    + ')';
+                case "setSelection":
+                    return 'setSelection(editor, ' + JSON.stringify(data)  + ')';
+                case "setValue":
+                    if (lastValue != data) {
+                        lastValue = data;
+                        return 'editor.setValue(' + JSON.stringify(data) + ', -1)';
+                    }
+                    return;
+                case "selection":
+                    return 'testSelection(editor, ' + JSON.stringify(data) + ')';
+                case "value":
+                    if (lastValue != data) {
+                        lastValue = data;
+                        return 'assert.equal('
+                            + 'editor.getValue(),'
+                            + JSON.stringify(data)
+                        + ')';
+                    }
+                    return;
+            }
+        }).filter(Boolean).join("\n");
+        
+        return getSelection + "\n"
+            + testSelection + "\n"
+            + setSelection + "\n"
+            + "\n" + str + "\n";
+    };
+};
+
+
+});
diff --git a/demo/kitchen-sink/doclist.js b/demo/kitchen-sink/doclist.js
index 5032a379..a4848d50 100644
--- a/demo/kitchen-sink/doclist.js
+++ b/demo/kitchen-sink/doclist.js
@@ -66,103 +66,51 @@ function makeHuge(txt) {
 }
 
 var docs = {
-    "docs/javascript.js": "JavaScript",
-    "docs/AsciiDoc.asciidoc": "AsciiDoc",
-    "docs/clojure.clj": "Clojure",
-    "docs/coffeescript.coffee": "CoffeeScript",
-    "docs/coldfusion.cfm": "ColdFusion",
-    "docs/cpp.cpp": "C/C++",
-    "docs/csharp.cs": "C#",
-    "docs/css.css": "CSS",
-    "docs/curly.curly": "Curly",
-    "docs/dart.dart": "Dart",
-    "docs/diff.diff": "Diff",
-    "docs/dot.dot": "Dot",
-    "docs/freemarker.ftl" : "FreeMarker",
-    "docs/glsl.glsl": "Glsl",
-    "docs/golang.go": "Go",
-    "docs/groovy.groovy": "Groovy",
-    "docs/haml.haml": "Haml",
-    "docs/Haxe.hx": "haXe",
-    "docs/html.html": "HTML",
-    "docs/html_ruby.erb": "HTML (Ruby)",
-    "docs/jade.jade": "Jade",
-    "docs/java.java": "Java",
-    "docs/jsp.jsp": "JSP",
-    "docs/json.json": "JSON",
-    "docs/jsx.jsx": "JSX",
+    "docs/javascript.js": {order: 1, name: "JavaScript"},
+
     "docs/latex.tex": {name: "LaTeX", wrapped: true},
-    "docs/less.less": "LESS",
-    "docs/lisp.lisp": "Lisp",
-    "docs/lsl.lsl": "LSL",
-    "docs/scheme.scm": "Scheme",
-    "docs/livescript.ls": "LiveScript",
-    "docs/liquid.liquid": "Liquid",
-    "docs/logiql.logic": "LogiQL",
-    "docs/lua.lua": "Lua",
-    "docs/lucene.lucene": "Lucene",
-    "docs/luapage.lp": "LuaPage",
-    "docs/Makefile": "Makefile",
     "docs/markdown.md": {name: "Markdown", wrapped: true},
     "docs/mushcode.mc": {name: "MUSHCode", wrapped: true},
-    "docs/objectivec.m": {name: "Objective-C"},
-    "docs/ocaml.ml": "OCaml",
-    "docs/OpenSCAD.scad": "OpenSCAD",
-    "docs/pascal.pas": "Pascal",
-    "docs/perl.pl": "Perl",
     "docs/pgsql.pgsql": {name: "pgSQL", wrapped: true},
-    "docs/php.php": "PHP",
     "docs/plaintext.txt": {name: "Plain Text", prepare: makeHuge, wrapped: true},
-    "docs/powershell.ps1": "Powershell",
-    "docs/properties.properties": "Properties",
-    "docs/python.py": "Python",
-    "docs/r.r": "R",
-    "docs/rdoc.Rd": "RDoc",
-    "docs/rhtml.rhtml": "RHTML",
-    "docs/ruby.rb": "Ruby",
-    "docs/abap.abap": "SAP - ABAP",
-    "docs/scala.scala": "Scala",
-    "docs/scss.scss": "SCSS",
-    "docs/sass.sass": "SASS",
-    "docs/sh.sh": "SH",
-    "docs/stylus.styl": "Stylus",
     "docs/sql.sql": {name: "SQL", wrapped: true},
-    "docs/svg.svg": "SVG",
-    "docs/tcl.tcl": "Tcl",
-    "docs/tex.tex": "Tex",
+
     "docs/textile.textile": {name: "Textile", wrapped: true},
-    "docs/snippets.snippets": "snippets",
-    "docs/toml.toml": "TOML",
-    "docs/typescript.ts": "Typescript",
-    "docs/vbscript.vbs": "VBScript",
-    "docs/velocity.vm": "Velocity",
-    "docs/xml.xml": "XML",
-    "docs/xquery.xq": "XQuery",
-    "docs/yaml.yaml": "YAML",
+
     "docs/c9search.c9search_results": "C9 Search Results",
-    
-    "docs/actionscript.as": "ActionScript",
-    "docs/assembly_x86.asm": "Assembly_x86",
-    "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",
-    "docs/twig.twig": "Twig"
+    "docs/mel.mel": "MEL",
+    "docs/Nix.nix": "Nix"
 };
 
 var ownSource = {
     /* filled from require*/
 };
 
-var hugeDocs = {
+var hugeDocs = require.toUrl ? {
     "build/src/ace.js": "",
     "build/src-min/ace.js": ""
+} : {
+    "src/ace.js": "",
+    "src-min/ace.js": ""
 };
 
+modelist.modes.forEach(function(m) {
+    var ext = m.extensions.split("|")[0];
+    if (ext[0] === "^") {
+        path = ext.substr(1);
+    } else {
+        var path = m.name + "." + ext;
+    }
+    path = "docs/" + path;
+    if (!docs[path]) {
+        docs[path] = {name: m.caption};
+    } else if (typeof docs[path] == "object" && !docs[path].name) {
+        docs[path].name = m.caption;
+    }
+});
+
+
+
 if (window.require && window.require.s) try {
     for (var path in window.require.s.contexts._.defined) {
         if (path.indexOf("!") != -1)
@@ -173,6 +121,13 @@ if (window.require && window.require.s) try {
     }
 } catch(e) {}
 
+function sort(list) {
+    return list.sort(function(a, b) {
+        var cmp = (b.order || 0) - (a.order || 0);
+        return cmp || a.name && a.name.localeCompare(b.name);
+    });
+}
+
 function prepareDocList(docs) {
     var list = [];
     for (var path in docs) {
@@ -214,13 +169,44 @@ function loadDoc(name, callback) {
     });
 }
 
+function saveDoc(name, callback) {
+    var doc = fileCache[name] || name;
+    if (!doc || !doc.session)
+        return callback("Unknown document: " + name);
+
+    var path = doc.path;
+    var parts = path.split("/");
+    if (parts[0] == "docs")
+        path = "demo/kitchen-sink/" + path;
+    else if (parts[0] == "ace")
+        path = "lib/" + path;
+
+    upload(path, doc.session.getValue(), callback);
+}
+
+function upload(url, data, callback) {
+    url = net.qualifyURL(url);
+    if (!/https?:/.test(url))
+        return callback(new Error("Unsupported url scheme"));
+    var xhr = new XMLHttpRequest();
+    xhr.open("PUT", url, true);
+    xhr.onreadystatechange = function () {
+        if (xhr.readyState === 4) {
+            callback(!/^2../.test(xhr.status));
+        }
+    };
+    xhr.send(data);
+};
+
+
 module.exports = {
     fileCache: fileCache,
-    docs: prepareDocList(docs),
+    docs: sort(prepareDocList(docs)),
     ownSource: prepareDocList(ownSource),
     hugeDocs: prepareDocList(hugeDocs),
     initDoc: initDoc,
-    loadDoc: loadDoc
+    loadDoc: loadDoc,
+    saveDoc: saveDoc,
 };
 module.exports.all = {
     "Mode Examples": module.exports.docs,
diff --git a/demo/kitchen-sink/docs/.gitignore b/demo/kitchen-sink/docs/.gitignore
new file mode 100644
index 00000000..56ec8fd9
--- /dev/null
+++ b/demo/kitchen-sink/docs/.gitignore
@@ -0,0 +1,11 @@
+# A sample .gitignore file.
+
+.buildlog
+.DS_Store
+.svn
+
+# Negated patterns:
+!foo.bar
+
+# Also ignore user settings...
+/.settings
diff --git a/demo/kitchen-sink/docs/Dockerfile b/demo/kitchen-sink/docs/Dockerfile
new file mode 100644
index 00000000..70270cbf
--- /dev/null
+++ b/demo/kitchen-sink/docs/Dockerfile
@@ -0,0 +1,53 @@
+#
+# example Dockerfile for http://docs.docker.io/en/latest/examples/postgresql_service/
+#
+
+FROM ubuntu
+MAINTAINER SvenDowideit@docker.com
+
+# Add the PostgreSQL PGP key to verify their Debian packages.
+# It should be the same key as https://www.postgresql.org/media/keys/ACCC4CF8.asc 
+RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys B97B0AFCAA1A47F044F244A07FCC7D46ACCC4CF8
+
+# Add PostgreSQL's repository. It contains the most recent stable release
+#     of PostgreSQL, ``9.3``.
+RUN echo "deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main" > /etc/apt/sources.list.d/pgdg.list
+
+# Update the Ubuntu and PostgreSQL repository indexes
+RUN apt-get update
+
+# Install ``python-software-properties``, ``software-properties-common`` and PostgreSQL 9.3
+#  There are some warnings (in red) that show up during the build. You can hide
+#  them by prefixing each apt-get statement with DEBIAN_FRONTEND=noninteractive
+RUN apt-get -y -q install python-software-properties software-properties-common
+RUN apt-get -y -q install postgresql-9.3 postgresql-client-9.3 postgresql-contrib-9.3
+
+# Note: The official Debian and Ubuntu images automatically ``apt-get clean``
+# after each ``apt-get`` 
+
+# Run the rest of the commands as the ``postgres`` user created by the ``postgres-9.3`` package when it was ``apt-get installed``
+USER postgres
+
+# Create a PostgreSQL role named ``docker`` with ``docker`` as the password and
+# then create a database `docker` owned by the ``docker`` role.
+# Note: here we use ``&&\`` to run commands one after the other - the ``\``
+#       allows the RUN command to span multiple lines.
+RUN    /etc/init.d/postgresql start &&\
+    psql --command "CREATE USER docker WITH SUPERUSER PASSWORD 'docker';" &&\
+    createdb -O docker docker
+
+# Adjust PostgreSQL configuration so that remote connections to the
+# database are possible. 
+RUN echo "host all  all    0.0.0.0/0  md5" >> /etc/postgresql/9.3/main/pg_hba.conf
+
+# And add ``listen_addresses`` to ``/etc/postgresql/9.3/main/postgresql.conf``
+RUN echo "listen_addresses='*'" >> /etc/postgresql/9.3/main/postgresql.conf
+
+# Expose the PostgreSQL port
+EXPOSE 5432
+
+# Add VOLUMEs to allow backup of config, logs and databases
+VOLUME	["/etc/postgresql", "/var/log/postgresql", "/var/lib/postgresql"]
+
+# Set the default command to run when starting the container
+CMD ["/usr/lib/postgresql/9.3/bin/postgres", "-D", "/var/lib/postgresql/9.3/main", "-c", "config_file=/etc/postgresql/9.3/main/postgresql.conf"]
\ No newline at end of file
diff --git a/demo/kitchen-sink/docs/Jack.jack b/demo/kitchen-sink/docs/Jack.jack
new file mode 100644
index 00000000..15acf743
--- /dev/null
+++ b/demo/kitchen-sink/docs/Jack.jack
@@ -0,0 +1,247 @@
+vars it, p
+
+p = {label, value|
+  print("\n" + label)
+  print(inspect(value))
+}
+-- Create an array from 0 to 15
+p("range", i-collect(range(5)))
+
+-- Create an array from 0 to 15 and break up in chunks of 4
+p("chunked range", i-collect(i-chunk(4, range(16))))
+
+-- Check if all or none items in stream pass test.
+p("all < 60 in range(60)", i-all?({i|i<60}, range(60)))
+p("any < 60 in range(60)", i-any?({i|i>60}, range(60)))
+p("all < 60 in range(70)", i-all?({i|i<60}, range(70)))
+p("any < 60 in range(70)", i-any?({i|i>60}, range(70)))
+
+-- Zip three different collections together
+p("zipped", i-collect(i-zip(
+  range(10),
+  [1,2,3,4,5],
+  i-map({i|i*i}, range(10))
+)))
+
+vars names, person, i, doubles, lengths, cubeRange
+names = ["Thorin", "Dwalin", "Balin", "Bifur", "Bofur", "Bombur", "Oin",
+         "Gloin", "Ori", "Nori", "Dori", "Fili", "Kili", "Bilbo", "Gandalf"]
+
+for name in names {
+  if name != "Bilbo" && name != "Gandalf" {
+    print(name)
+  }
+}
+
+person = {name: "Tim", age: 30}
+for key, value in person {
+  print(key + " = " + value)
+}
+
+i = 0
+while i < 10 {
+  i = i + 1
+  print(i)
+}
+
+print("range")
+for i in range(10) {
+  print(i + 1)
+}
+for i in range(10) {
+  print(10 - i)
+}
+
+-- Dynamic object that gives the first 10 doubles
+doubles = {
+  @len: {| 10 }
+  @get: {key|
+    if key is Integer { key * key }
+  }
+}
+print("#doubles", #doubles)
+
+print("Doubles")
+for k, v in doubles {
+  print([k, v])
+}
+
+-- Dynamic object that has names list as keys and string lenth as values
+lengths = {
+  @keys: {| names }
+  @get: {key|
+    if key is String { #key }
+  }
+}
+
+print ("Lengths")
+for k, v in lengths {
+  print([k, v])
+}
+
+
+cubeRange = {n|
+  vars i, v
+  i = 0
+  {
+    @call: {|
+      v = i
+      i = i + 1
+      if v < n { v * v * v }
+    }
+  }
+}
+
+print("Cubes")
+for k, v in cubeRange(5) {
+  print([k, v])
+}
+print("String")
+for k, v in "Hello World" {
+  print([k, v])
+}
+
+
+print([i for i in range(10)])
+print([i for i in range(20) if i % 3])
+
+
+
+-- Example showing how to do parallel work using split..and
+base = {bootstrap, target-dir|
+  split {
+    copy("res", target-dir)
+  } and {
+    if newer("src/*.less", target-dir + "/style.css") {
+      lessc("src/" + bootstrap + ".less", target-dir + "/style.css")
+    }
+  } and {
+    build("src/" + bootstrap + ".js", target-dir + "/app.js")
+  }
+}
+
+
+vars Dragon, pet
+
+Dragon = {name|
+  vars asleep, stuff-in-belly, stuff-in-intestine,
+       feed, walk, put-to-bed, toss, rock,
+       hungry?, poopy?, passage-of-time
+
+  asleep = false
+  stuff-in-belly     = 10 -- He's full.
+  stuff-in-intestine =  0 -- He doesn't need to go.
+
+  print(name + ' is born.')
+
+  feed = {|
+    print('You feed ' + name + '.')
+    stuff-in-belly = 10
+    passage-of-time()
+  }
+
+  walk = {|
+    print('You walk ' + name + ".")
+    stuff-in-intestine = 0
+    passage-of-time
+  }
+
+  put-to-bed = {|
+    print('You put ' + name + ' to bed.')
+    asleep = true
+    for i in range(3) {
+      if asleep {
+        passage-of-time()
+      }
+      if asleep {
+        print(name + ' snores, filling the room with smoke.')
+      }
+    }
+    if asleep {
+      asleep = false
+      print(name + ' wakes up slowly.')
+    }
+  }
+
+  toss = {|
+    print('You toss ' + name + ' up into the air.')
+    print('He giggles, which singes your eyebrows.')
+    passage-of-time()
+  }
+
+  rock = {|
+    print('You rock ' + name + ' gently.')
+    asleep = true
+    print('He briefly dozes off...')
+    passage-of-time()
+    if asleep {
+      asleep = false
+      print('...but wakes when you stop.')
+    }
+  }
+
+  hungry? = {|
+    stuff-in-belly <= 2
+  }
+
+  poopy? = {|
+    stuff-in-intestine >= 8
+  }
+
+  passage-of-time = {|
+    if stuff-in-belly > 0 {
+      -- Move food from belly to intestine
+      stuff-in-belly     = stuff-in-belly     - 1
+      stuff-in-intestine = stuff-in-intestine + 1
+    } else { -- Our dragon is starving!
+      if asleep {
+        asleep = false
+        print('He wakes up suddenly!')
+      }
+      print(name + ' is starving! In desperation, he ate YOU!')
+      abort "died"
+    }
+
+    if stuff-in-intestine >= 10 {
+      stuff-in-intestine = 0
+      print('Whoops! ' + name + ' had an accident...')
+    }
+
+    if hungry?() {
+      if asleep {
+        asleep = false
+        print('He wakes up suddenly!')
+      }
+      print(name + "'s stomach grumbles...")
+    }
+
+    if poopy?() {
+      if asleep {
+        asleep = false
+        print('He wakes up suddenly!')
+      }
+      print(name + ' does the potty dance...')
+    }
+  }
+
+  -- Export the public interface to this closure object.
+  {
+   feed: feed
+   walk: walk
+   put-to-bed: put-to-bed
+   toss: toss
+   rock: rock
+  }
+
+}
+
+pet = Dragon('Norbert')
+pet.feed()
+pet.toss()
+pet.walk()
+pet.put-to-bed()
+pet.rock()
+pet.put-to-bed()
+pet.put-to-bed()
+pet.put-to-bed()
+pet.put-to-bed()
diff --git a/demo/kitchen-sink/docs/Nix.nix b/demo/kitchen-sink/docs/Nix.nix
new file mode 100644
index 00000000..9476db3b
--- /dev/null
+++ b/demo/kitchen-sink/docs/Nix.nix
@@ -0,0 +1,57 @@
+{
+  # Name of our deployment
+  network.description = "HelloWorld";
+  # Enable rolling back to previous versions of our infrastructure
+  network.enableRollback = true;
+
+  # It consists of a single server named 'helloserver'
+  helloserver =
+    # Every server gets passed a few arguments, including a reference
+    # to nixpkgs (pkgs)
+    { config, pkgs, ... }:
+    let
+      # We import our custom packages from ./default passing pkgs as argument
+      packages = import ./default.nix { pkgs = pkgs; };
+      # This is the nodejs version specified in default.nix
+      nodejs   = packages.nodejs;
+      # And this is the application we'd like to deploy
+      app      = packages.app;
+    in
+    {
+      # We'll be running our application on port 8080, because a regular
+      # user cannot bind to port 80
+      # Then, using some iptables magic we'll forward traffic designated to port 80 to 8080
+      networking.firewall.enable = true;
+      # We will open up port 22 (SSH) as well otherwise we're locking ourselves out
+      networking.firewall.allowedTCPPorts = [ 80 8080 22 ];
+      networking.firewall.allowPing = true;
+
+      # Port forwarding using iptables
+      networking.firewall.extraCommands = ''
+        iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080
+      '';
+
+      # To run our node.js program we're going to use a systemd service
+      # We can configure the service to automatically start on boot and to restart
+      # the process in case it crashes
+      systemd.services.helloserver = {
+        description = "Hello world application";
+        # Start the service after the network is available
+        after = [ "network.target" ];
+        # We're going to run it on port 8080 in production
+        environment = { PORT = "8080"; };
+        serviceConfig = {
+          # The actual command to run
+          ExecStart = "${nodejs}/bin/node ${app}/server.js";
+          # For security reasons we'll run this process as a special 'nodejs' user
+          User = "nodejs";
+          Restart = "always";
+        };
+      };
+
+      # And lastly we ensure the user we run our application as is created
+      users.extraUsers = {
+        nodejs = { };
+      };
+    };
+}
\ No newline at end of file
diff --git a/demo/kitchen-sink/docs/abc.abc b/demo/kitchen-sink/docs/abc.abc
new file mode 100644
index 00000000..d8ac326e
--- /dev/null
+++ b/demo/kitchen-sink/docs/abc.abc
@@ -0,0 +1,171 @@
+%abc-2.1
+H:This file contains some example English tunes
+% note that the comments (like this one) are to highlight usages
+%  and would not normally be included in such detail
+O:England             % the origin of all tunes is England
+
+X:1                   % tune no 1
+T:Dusty Miller, The   % title
+T:Binny's Jig         % an alternative title
+C:Trad.               % traditional
+R:DH                  % double hornpipe
+M:3/4                 % meter
+K:G                   % key
+B>cd BAG|FA Ac BA|B>cd BAG|DG GB AG:|
+Bdd gfg|aA Ac BA|Bdd gfa|gG GB AG:|
+BG G/2G/2G BG|FA Ac BA|BG G/2G/2G BG|DG GB AG:|
+W:Hey, the dusty miller, and his dusty coat;
+W:He will win a shilling, or he spend a groat.
+W:Dusty was the coat, dusty was the colour;
+W:Dusty was the kiss, that I got frae the miller.
+
+X:2
+T:Old Sir Simon the King
+C:Trad.
+S:Offord MSS          % from Offord manuscript
+N:see also Playford   % reference note
+M:9/8
+R:SJ                  % slip jig
+N:originally in C     % transcription note
+K:G
+D|GFG GAG G2D|GFG GAG F2D|EFE EFE EFG|A2G F2E D2:|
+D|GAG GAB d2D|GAG GAB c2D|[1 EFE EFE EFG|[A2G] F2E D2:|\ % no line-break in score
+M:12/8                % change of meter
+[2 E2E EFE E2E EFG|\  % no line-break in score
+M:9/8                 % change of meter
+A2G F2E D2|]
+
+X:3
+T:William and Nancy
+T:New Mown Hay
+T:Legacy, The
+C:Trad.
+O:England; Gloucs; Bledington % place of origin
+B:Sussex Tune Book            % can be found in these books
+B:Mally's Cotswold Morris vol.1 2
+D:Morris On                   % can be heard on this record
+P:(AB)2(AC)2A                 % play the parts in this order
+M:6/8
+K:G                        
+[P:A] D|"G"G2G GBd|"C"e2e "G"dBG|"D7"A2d "G"BAG|"C"E2"D7"F "G"G2:|
+[P:B] d|"G"e2d B2d|"C"gfe "G"d2d| "G"e2d    B2d|"C"gfe    "D7"d2c|
+        "G"B2B Bcd|"C"e2e "G"dBG|"D7"A2d "G"BAG|"C"E2"D7"F "G"G2:|
+% changes of meter, using inline fields
+[T:Slows][M:4/4][L:1/4][P:C]"G"d2|"C"e2 "G"d2|B2 d2|"Em"gf "A7"e2|"D7"d2 "G"d2|\
+       "C"e2 "G"d2|[M:3/8][L:1/8] "G"B2 d |[M:6/8] "C"gfe "D7"d2c|
+        "G"B2B Bcd|"C"e2e "G"dBG|"D7"A2d "G"BAG|"C"E2"D7"F "G"G2:|
+
+X:4
+T:South Downs Jig
+R:jig
+S:Robert Harbron
+M:6/8
+L:1/8
+K:G
+|: d | dcA G3 | EFG AFE | DEF GAB | cde d2d |
+dcA G3 | EFG AFE | DEF GAB | cAF G2 :|
+B | Bcd e2c | d2B c2A | Bcd e2c | [M:9/8]d2B c2B A3 |
+[M:6/8]DGF E3 | cBA FED | DEF GAB |1 cAF G2 :|2 cAF G3 |]
+
+X:5
+T:Atholl Brose
+% in this example, which reproduces Highland Bagpipe gracing,
+%  the large number of grace notes mean that it is more convenient to be specific about
+%  score line-breaks (using the $ symbol), rather than using code line breaks to indicate them
+I:linebreak $
+K:D
+{gcd}c<{e}A {gAGAG}A2 {gef}e>A {gAGAG}Ad|
+{gcd}c<{e}A {gAGAG}A>e {ag}a>f {gef}e>d|
+{gcd}c<{e}A {gAGAG}A2 {gef}e>A {gAGAG}Ad|
+{g}c/d/e {g}G>{d}B {gf}gG {dc}d>B:|$
+{g}ce {ag}a>e {gf}g>e|
+{g}ce {ag}a2 {GdG}a>d|
+{g}ce {ag}a>e {gf}g>f|
+{gef}e>d {gf}g>d {gBd}B<{e}G {dc}d>B|
+{g}ce {ag}a>e {gf}g>e|
+{g}ce {ag}a2 {GdG}ad|
+{g}c<{GdG}e {gf}ga {f}g>e {g}f>d|
+{g}e/f/g {Gdc}d>c {gBd}B<{e}G {dc}d2|]
+
+X:6
+T:Untitled Reel
+C:Trad.
+K:D
+eg|a2ab ageg|agbg agef|g2g2 fgag|f2d2 d2:|\
+ed|cecA B2ed|cAcA E2ed|cecA B2ed|c2A2 A2:|
+K:G
+AB|cdec BcdB|ABAF GFE2|cdec BcdB|c2A2 A2:|
+
+X:7
+T:Kitchen Girl
+C:Trad.
+K:D
+[c4a4] [B4g4]|efed c2cd|e2f2 gaba|g2e2 e2fg|
+a4 g4|efed cdef|g2d2 efed|c2A2 A4:|
+K:G
+ABcA BAGB|ABAG EDEG|A2AB c2d2|e3f edcB|ABcA BAGB|
+ABAG EGAB|cBAc BAG2|A4 A4:|
+
+%abc-2.1
+%%pagewidth      21cm
+%%pageheight     29.7cm
+%%topspace       0.5cm
+%%topmargin      1cm
+%%botmargin      0cm
+%%leftmargin     1cm
+%%rightmargin    1cm
+%%titlespace     0cm
+%%titlefont      Times-Bold 32
+%%subtitlefont   Times-Bold 24
+%%composerfont   Times 16
+%%vocalfont      Times-Roman 14
+%%staffsep       60pt
+%%sysstaffsep    20pt
+%%musicspace     1cm
+%%vocalspace     5pt
+%%measurenb      0
+%%barsperstaff   5
+%%scale          0.7
+X: 1
+T: Canzonetta a tre voci
+C: Claudio Monteverdi (1567-1643)
+M: C
+L: 1/4
+Q: "Andante mosso" 1/4 = 110
+%%score [1 2 3]
+V: 1 clef=treble name="Soprano"sname="A"
+V: 2 clef=treble name="Alto"   sname="T"
+V: 3 clef=bass middle=d name="Tenor"  sname="B"
+%%MIDI program 1 75 % recorder
+%%MIDI program 2 75
+%%MIDI program 3 75
+K: Eb
+% 1 - 4
+[V: 1] |:z4  |z4  |f2ec         |_ddcc        |
+w: Son que-sti~i cre-spi cri-ni~e
+w: Que-sti son gli~oc-chi che mi-
+[V: 2] |:c2BG|AAGc|(F/G/A/B/)c=A|B2AA         |
+w: Son que-sti~i cre-spi cri-ni~e que - - - - sto~il vi-so e
+w: Que-sti son~gli oc-chi che mi-ran - - - - do fi-so mi-
+[V: 3] |:z4  |f2ec|_ddcf        |(B/c/_d/e/)ff|
+w: Son que-sti~i cre-spi cri-ni~e que - - - - sto~il
+w: Que-sti son~gli oc-chi che mi-ran - - - - do
+% 5 - 9
+[V: 1] cAB2     |cAAA |c3B|G2!fermata!Gz ::e4|
+w: que-sto~il vi-so ond' io ri-man-go~uc-ci-so. Deh,
+w: ran-do fi-so, tut-to re-stai con-qui-so.
+[V: 2] AAG2     |AFFF |A3F|=E2!fermata!Ez::c4|
+w: que-sto~il vi-so ond' io ri-man-go~uc-ci-so. Deh,
+w: ran-do fi-so tut-to re-stai con-qui-so.
+[V: 3] (ag/f/e2)|A_ddd|A3B|c2!fermata!cz ::A4|
+w: vi - - - so ond' io ti-man-go~uc-ci-so. Deh,
+w: fi - - - so tut-to re-stai con-qui-so.
+% 10 - 15
+[V: 1] f_dec |B2c2|zAGF  |\
+w: dim-me-lo ben mi-o, che que-sto\
+=EFG2          |1F2z2:|2F8|] % more notes
+w: sol de-si-o_. % more lyrics
+[V: 2] ABGA  |G2AA|GF=EF |(GF3/2=E//D//E)|1F2z2:|2F8|]
+w: dim-me-lo ben mi-o, che que-sto sol de-si - - - - o_.
+[V: 3] _dBc>d|e2AF|=EFc_d|c4             |1F2z2:|2F8|]
+w: dim-me-lo ben mi-o, che que-sto sol de-si-o_.
\ No newline at end of file
diff --git a/demo/kitchen-sink/docs/ada.ada b/demo/kitchen-sink/docs/ada.ada
new file mode 100644
index 00000000..90e027f0
--- /dev/null
+++ b/demo/kitchen-sink/docs/ada.ada
@@ -0,0 +1,5 @@
+with Ada.Text_IO; use Ada.Text_IO;
+procedure Hello is
+begin
+  Put_Line("Hello, world!");
+end Hello;
\ No newline at end of file
diff --git a/demo/kitchen-sink/docs/AsciiDoc.asciidoc b/demo/kitchen-sink/docs/asciidoc.asciidoc
similarity index 100%
rename from demo/kitchen-sink/docs/AsciiDoc.asciidoc
rename to demo/kitchen-sink/docs/asciidoc.asciidoc
diff --git a/demo/kitchen-sink/docs/c9search.c9search_results b/demo/kitchen-sink/docs/c9search.c9search_results
index bf0fdb87..0ad9ccd4 100644
--- a/demo/kitchen-sink/docs/c9search.c9search_results
+++ b/demo/kitchen-sink/docs/c9search.c9search_results
@@ -1,4 +1,4 @@
-Searching for 'var' in /workspace/configs
+Searching for var in/.c9/metadata/workspace/pluginsregexp, case sensitive, whole word
 
 configs/default.js:
     1: var fs = require("fs");
diff --git a/demo/kitchen-sink/docs/cpp.cpp b/demo/kitchen-sink/docs/c_cpp.cpp
similarity index 100%
rename from demo/kitchen-sink/docs/cpp.cpp
rename to demo/kitchen-sink/docs/c_cpp.cpp
diff --git a/demo/kitchen-sink/docs/cirru.cirru b/demo/kitchen-sink/docs/cirru.cirru
new file mode 100644
index 00000000..244833df
--- /dev/null
+++ b/demo/kitchen-sink/docs/cirru.cirru
@@ -0,0 +1,42 @@
+-- https://github.com/Cirru/cirru-gopher/blob/master/code/scope.cr,
+
+set a (int 2)
+
+print (self)
+
+set c (child)
+
+under c
+  under parent
+    print a
+
+print $ get c a
+
+set c x (int 3)
+print $ get c x
+
+set just-print $ code
+  print a
+
+print just-print
+
+eval (self) just-print
+eval just-print
+
+print (string "string with space")
+print (string "escapes \n \"\\")
+
+brackets ((((()))))
+
+"eval" $ string "eval"
+
+print (add $ (int 1) (int 2))
+
+print $ unwrap $
+  map (a $ int 1) (b $ int 2)
+
+print a
+  int 1
+  , b c
+  int 2
+  , d
\ No newline at end of file
diff --git a/demo/kitchen-sink/docs/cobol.CBL b/demo/kitchen-sink/docs/cobol.CBL
new file mode 100644
index 00000000..30404ce4
--- /dev/null
+++ b/demo/kitchen-sink/docs/cobol.CBL
@@ -0,0 +1 @@
+TODO
\ No newline at end of file
diff --git a/demo/kitchen-sink/docs/coffeescript.coffee b/demo/kitchen-sink/docs/coffee.coffee
similarity index 100%
rename from demo/kitchen-sink/docs/coffeescript.coffee
rename to demo/kitchen-sink/docs/coffee.coffee
diff --git a/demo/kitchen-sink/docs/css.css b/demo/kitchen-sink/docs/css.css
index 0ebe5f2d..6d2d71f5 100644
--- a/demo/kitchen-sink/docs/css.css
+++ b/demo/kitchen-sink/docs/css.css
@@ -1,28 +1,18 @@
 .text-layer {
-    font-family: Monaco, "Courier New", monospace;
-    font-size: 12pX;
+    font: 12px Monaco, "Courier New", monospace;
     cursor: text;
 }
 
 .blinker {
-    animation-duration: 1s;
-    animation-name: blink;
-    animation-iteration-count: infinite;
-    animation-direction: alternate;
-    animation-timing-function: linear;
+    animation: blink 1s linear infinite alternate;
 }
 
 @keyframes blink {
-    0% {
+    0%, 40% {
         opacity: 0;
     }
-    40% {
-        opacity: 0;
-    }
-    40.5% {
-        opacity: 1
-    }
-    100% {
+
+    40.5%, 100% {
         opacity: 1
     }
 }
\ No newline at end of file
diff --git a/demo/kitchen-sink/docs/d.d b/demo/kitchen-sink/docs/d.d
new file mode 100644
index 00000000..57069067
--- /dev/null
+++ b/demo/kitchen-sink/docs/d.d
@@ -0,0 +1,14 @@
+#!/usr/bin/env rdmd
+// Computes average line length for standard input.
+import std.stdio;
+
+void main() {
+    ulong lines = 0;
+    double sumLength = 0;
+    foreach (line; stdin.byLine()) {
+        ++lines;
+        sumLength += line.length;
+    }
+    writeln("Average line length: ",
+        lines ? sumLength / lines : 0);
+}
\ No newline at end of file
diff --git a/demo/kitchen-sink/docs/dart.dart b/demo/kitchen-sink/docs/dart.dart
index cdb43c38..735a20b3 100644
--- a/demo/kitchen-sink/docs/dart.dart
+++ b/demo/kitchen-sink/docs/dart.dart
@@ -1,58 +1,19 @@
-main() {
-  print('Hello World!');
+// Go ahead and modify this example.
+
+import "dart:html";
+
+// Computes the nth Fibonacci number.
+int fibonacci(int n) {
+  if (n < 2) return n;
+  return fibonacci(n - 1) + fibonacci(n - 2);
 }
 
+// Displays a Fibonacci number.
+void main() {
+  int i = 20;
+  String message = "fibonacci($i) = ${fibonacci(i)}";
 
-int fib(int n) => (n > 1) ? (fib(n - 1) + fib(n - 2)) : n;
-main() {
-  print('fib(20) = ${fib(20)}');
+  // This example uses HTML to display the result and it will appear
+  // in a nested HTML frame (an iframe).
+  document.body.append(new HeadingElement.h1()..appendText(message));
 }
-/*asd
-asdad
-*/
-0.67
-77
-.86
-
-import("http://dartwatch.com/myOtherLibrary.dart");
-import("myOtherLibrary.dart", prefix:"lib1");
-
-"""asdasdads
-asdadsadsasd
-asdasdasdad"""
- 
-'23424'
-
-0x234
-
-foo is bar
-
-int x = 4 << 10 
-// Create a class for Point.
-class Point {
- 
-  // Final variables cannot be changed once they are assigned.
-  // Create two instance variables.
-  final num x, y;
- 
-  // A constructor, with syntactic sugar for setting instance variables.
-  Point(this.x, this.y);
- 
-  // A named constructor with an initializer list.
-  Point.origin() : x = 0, y = 0;
- 
-  // A method.
-  num distanceTo(Point other) {
-    var dx = x - other.x;
-    var dy = y - other.y;
-    return sqrt(dx * dx + dy * dy);
-  }
-}
- 
- // Check for null.
-var unicorn;
-assert(unicorn == null);
-
-// Check for NaN.
-var iMeantToDoThis = 0/0;
-assert(iMeantToDoThis.isNaN());
diff --git a/demo/kitchen-sink/docs/eiffel.e b/demo/kitchen-sink/docs/eiffel.e
new file mode 100644
index 00000000..943cdb35
--- /dev/null
+++ b/demo/kitchen-sink/docs/eiffel.e
@@ -0,0 +1,30 @@
+note
+	description: "Represents a person."
+
+class
+	PERSON
+
+create
+	make, make_unknown
+
+feature {NONE} -- Creation
+
+	make (a_name: like name)
+			-- Create a person with `a_name' as `name'.
+		do
+			name := a_name
+		ensure
+			name = a_name
+		end
+
+	make_unknown
+		do ensure
+			name = Void
+		end
+
+feature -- Access
+
+	name: detachable STRING
+			-- Full name or Void if unknown.
+
+end
\ No newline at end of file
diff --git a/demo/kitchen-sink/docs/ejs.ejs b/demo/kitchen-sink/docs/ejs.ejs
new file mode 100644
index 00000000..aaf497a9
--- /dev/null
+++ b/demo/kitchen-sink/docs/ejs.ejs
@@ -0,0 +1,31 @@
+
+
+    
+        Cloud9 Rocks!
+    
+    
+
+    
+        
+            
+            
+        
+        <% if (!isRoot) { %>
+            
+                
+                
+            
+        <% } %>
+        <% entries.forEach(function(entry) { %>
+            
+                
+                
+            
+        <% }) %>
+    
NameSize
..
+ + <%= entry.name %> + <%= entry.size %>
+ + + \ No newline at end of file diff --git a/demo/kitchen-sink/docs/elixir.ex b/demo/kitchen-sink/docs/elixir.ex new file mode 100644 index 00000000..bb6a45f1 --- /dev/null +++ b/demo/kitchen-sink/docs/elixir.ex @@ -0,0 +1,42 @@ +defmodule HelloModule do + @moduledoc """ + This is supposed to be `markdown`. + __Yes__ this is [mark](http://down.format) + + # Truly + + ## marked + + * with lists + * more + * and more + + Even.with(code) + blocks |> with |> samples + + _Docs are first class citizens in Elixir_ (Jose Valim) + """ + + # A "Hello world" function + def some_fun do + IO.puts "Juhu Kinners!" + end + # A private function + defp priv do + is_regex ~r""" + This is a regex + spanning several + lines. + """ + x = elem({ :a, :b, :c }, 0) #=> :a + end +end + +test_fun = fn(x) -> + cond do + x > 10 -> + :greater_than_ten + true -> + :maybe_ten + end +end \ No newline at end of file diff --git a/demo/kitchen-sink/docs/elm.elm b/demo/kitchen-sink/docs/elm.elm new file mode 100644 index 00000000..eef70b2a --- /dev/null +++ b/demo/kitchen-sink/docs/elm.elm @@ -0,0 +1,12 @@ +{- Ace {- 4 -} Elm -} +main = lift clock (every second) + +clock t = collage 400 400 [ filled lightGrey (ngon 12 110) + , outlined (solid grey) (ngon 12 110) + , hand orange 100 t + , hand charcoal 100 (t/60) + , hand charcoal 60 (t/720) ] + +hand clr len time = + let angle = degrees (90 - 6 * inSeconds time) + in traced (solid clr) <| segment (0,0) (len * cos angle, len * sin angle) \ No newline at end of file diff --git a/demo/kitchen-sink/docs/freemarker.ftl b/demo/kitchen-sink/docs/ftl.ftl similarity index 100% rename from demo/kitchen-sink/docs/freemarker.ftl rename to demo/kitchen-sink/docs/ftl.ftl diff --git a/demo/kitchen-sink/docs/gcode.gcode b/demo/kitchen-sink/docs/gcode.gcode new file mode 100644 index 00000000..5f47bca3 --- /dev/null +++ b/demo/kitchen-sink/docs/gcode.gcode @@ -0,0 +1,31 @@ +O003 (DIAMOND SQUARE) +N2 G54 G90 G49 G80 +N3 M6 T1 (1.ENDMILL) +N4 M3 S1800 +N5 G0 X-.6 Y2.050 +N6 G43 H1 Z.1 +N7 G1 Z-.3 F50. +N8 G41 D1 Y1.45 +N9 G1 X0 F20. +N10 G2 J-1.45 +(CUTTER COMP CANCEL) +N11 G1 Z-.2 F50. +N12 Y-.990 +N13 G40 +N14 G0 X-.6 Y1.590 +N15 G0 Z.1 +N16 M5 G49 G28 G91 Z0 +N17 CALL O9456 +N18 #500=0.004 +N19 #503=[#500+#501] +N20 VC45=0.0006 +VS4=0.0007 +N21 G90 G10 L20 P3 X5.Y4. Z6.567 +N22 G0 X5000 +N23 IF [#1 LT 0.370] GOTO 49 +N24 X-0.678 Y+.990 +N25 G84.3 X-0.1 +N26 #4=#5*COS[45] +N27 #4=#5*SIN[45] +N28 VZOFZ=652.9658 +% \ No newline at end of file diff --git a/demo/kitchen-sink/docs/gherkin.feature b/demo/kitchen-sink/docs/gherkin.feature new file mode 100644 index 00000000..52cd811e --- /dev/null +++ b/demo/kitchen-sink/docs/gherkin.feature @@ -0,0 +1,28 @@ +@these @are @tags +Feature: Serve coffee + Coffee should not be served until paid for + Coffee should not be served until the button has been pressed + If there is no coffee left then money should be refunded + + Scenario Outline: Eating + Given there are cucumbers + When I eat cucumbers + Then I should have cucumbers + + Examples: + | start | eat | left | + | 12 | 5 | 7 | + | 20 | 5 | 15 | + + Scenario: Buy last coffee + Given there are 1 coffees left in the machine + And I have deposited 1$ + When I press the coffee button + Then I should be served a "coffee" + + # this a comment + + """ + this is a + pystring + """ \ No newline at end of file diff --git a/demo/kitchen-sink/docs/handlebars.hbs b/demo/kitchen-sink/docs/handlebars.hbs new file mode 100644 index 00000000..bb096a1a --- /dev/null +++ b/demo/kitchen-sink/docs/handlebars.hbs @@ -0,0 +1,8 @@ +{{!-- Ace + :-}} --}} + +
+ {{#each comments}} +

{{title}}

+
{{{body}}}
+ {{/each}} +
diff --git a/demo/kitchen-sink/docs/htaccess b/demo/kitchen-sink/docs/htaccess new file mode 100644 index 00000000..a9f5a27c --- /dev/null +++ b/demo/kitchen-sink/docs/htaccess @@ -0,0 +1,10 @@ +Redirect /linux http://www.linux.org +Redirect 301 /kernel http://www.linux.org + +# comment +RewriteEngine on + +RewriteCond %{HTTP_USER_AGENT} ^Mozilla.* +RewriteRule ^/$ /homepage.max.html [L] + +RewriteRule ^/$ /homepage.std.html [L] diff --git a/demo/kitchen-sink/docs/html.html b/demo/kitchen-sink/docs/html.html index a3a566ff..81398bef 100644 --- a/demo/kitchen-sink/docs/html.html +++ b/demo/kitchen-sink/docs/html.html @@ -1,3 +1,4 @@ + diff --git a/demo/kitchen-sink/docs/html_ruby.erb b/demo/kitchen-sink/docs/html_ruby.erb index 4ece6c8b..f75835ca 100644 --- a/demo/kitchen-sink/docs/html_ruby.erb +++ b/demo/kitchen-sink/docs/html_ruby.erb @@ -11,6 +11,7 @@ <% @books.each do |book| %> + <%# comment %> <%= book.title %> <%= book.content %> <%= link_to 'Show', book %> diff --git a/demo/kitchen-sink/docs/ini.ini b/demo/kitchen-sink/docs/ini.ini new file mode 100644 index 00000000..45f83c9a --- /dev/null +++ b/demo/kitchen-sink/docs/ini.ini @@ -0,0 +1,4 @@ +[.ShellClassInfo] +IconResource=..\logo.png +[ViewState] +FolderType=Generic diff --git a/demo/kitchen-sink/docs/io.io b/demo/kitchen-sink/docs/io.io new file mode 100644 index 00000000..4b80b6c2 --- /dev/null +++ b/demo/kitchen-sink/docs/io.io @@ -0,0 +1,6 @@ +// computes factorial of a number +factorial := method(n, + if(n == 0, return 1) + res := 1 + Range 1 to(n) foreach(i, res = res * i) +) \ No newline at end of file diff --git a/demo/kitchen-sink/docs/jsoniq.jq b/demo/kitchen-sink/docs/jsoniq.jq new file mode 100644 index 00000000..30404ce4 --- /dev/null +++ b/demo/kitchen-sink/docs/jsoniq.jq @@ -0,0 +1 @@ +TODO \ No newline at end of file diff --git a/demo/kitchen-sink/docs/julia.jl b/demo/kitchen-sink/docs/julia.jl index 97178469..f558ae22 100644 --- a/demo/kitchen-sink/docs/julia.jl +++ b/demo/kitchen-sink/docs/julia.jl @@ -2,7 +2,7 @@ for op = (:+, :*, :&, :|, :$) @eval ($op)(a,b,c) = ($op)(($op)(a,b),c) end - +v = α'; function g(x,y) return x * y x + y diff --git a/demo/kitchen-sink/docs/lean.lean b/demo/kitchen-sink/docs/lean.lean new file mode 100644 index 00000000..40e82753 --- /dev/null +++ b/demo/kitchen-sink/docs/lean.lean @@ -0,0 +1,9 @@ +import logic +section + variables (A : Type) (p q : A → Prop) + + example : (∀x : A, p x ∧ q x) → ∀y : A, p y := + assume H : ∀x : A, p x ∧ q x, + take y : A, + show p y, from and.elim_left (H y) +end diff --git a/demo/kitchen-sink/docs/lsl.lsl b/demo/kitchen-sink/docs/lsl.lsl index 185b9dd4..baf06f08 100644 --- a/demo/kitchen-sink/docs/lsl.lsl +++ b/demo/kitchen-sink/docs/lsl.lsl @@ -8,7 +8,7 @@ integer someIntNormal = 3672; integer someIntHex = 0x00000000; integer someIntMath = PI_BY_TWO; -integer event = 5673; // invalid reserved keyword! +integer event = 5673; // invalid.illegal key someKeyTexture = TEXTURE_DEFAULT; string someStringSpecial = EOF; @@ -53,12 +53,12 @@ default someIntHex = 0x00000000; someIntMath = PI_BY_TWO; - event = 5673; // invalid reserved keyword! + event = 5673; // invalid.illegal someKeyTexture = TEXTURE_DEFAULT; someStringSpecial = EOF; - llCollisionSprite(someKeyTexture); // invalid deprecated function! + llSetInventoryPermMask("some item", MASK_NEXT, PERM_ALL); // reserved.godmode llWhisper(PUBLIC_CHANNEL, "Leaving \"default\" now..."); state other; diff --git a/demo/kitchen-sink/docs/lua.lua b/demo/kitchen-sink/docs/lua.lua index 381b782c..6c927197 100644 --- a/demo/kitchen-sink/docs/lua.lua +++ b/demo/kitchen-sink/docs/lua.lua @@ -34,3 +34,5 @@ print([===[ table.maxn is deprecated, use # instead. --]=]-- print(table.maxn{1,2,[4]=4,[8]=8) -- outputs 8 instead of 2 + +print(5 --[[ blah ]]) \ No newline at end of file diff --git a/demo/kitchen-sink/docs/mask.mask b/demo/kitchen-sink/docs/mask.mask new file mode 100644 index 00000000..85a9e6c2 --- /dev/null +++ b/demo/kitchen-sink/docs/mask.mask @@ -0,0 +1,52 @@ +/* Mask Syntax Demo */ + +div > ' Test ~[name]'; + +define :userProfile { + header { + h4 > @title; + button.close; + } +} + +:userProfile { + @title > ' Hello ~[: username.toUpperCase()]' +} + +style { + html, body { + background: url('name.png') 0 0 no-repeat; + } +} + +button { + event click (e) { + this.textContent = `name ${e.clientX} !`; + } +} + +md > """ + +- div +- span + +Hello + +[one](http://google.com) + +"""; + + +header .foo > 'Heading' + +button .baz x-signal='click: test' disabled > " + Hello, + world + \"Buddy\" +" + +var a = { + name: `name ${window.innerWidth}` +}; + +span .foo > "~[bind: a.name]" \ No newline at end of file diff --git a/demo/kitchen-sink/docs/matlab.matlab b/demo/kitchen-sink/docs/matlab.matlab new file mode 100644 index 00000000..b2ca44d5 --- /dev/null +++ b/demo/kitchen-sink/docs/matlab.matlab @@ -0,0 +1,17 @@ +%{ + %{ + Ace Matlab demo + %} +%} + +classdef hello + methods + function greet(this) + disp('Hello!') % say hi + end + end +end + +% transpose +a = [ 'x''y', "x\n\ + y", 1' ]' + 2' \ No newline at end of file diff --git a/demo/kitchen-sink/docs/mel.mel b/demo/kitchen-sink/docs/mel.mel new file mode 100644 index 00000000..63dc14d6 --- /dev/null +++ b/demo/kitchen-sink/docs/mel.mel @@ -0,0 +1,33 @@ +// animated duplicates, instances script +proc animatedDuplication (int $rangeStart, int $rangeEnd, int $numOfDuplicates, int $duplicateOrInstance) +{ + int $range_start = $rangeStart; + int $range_end = $rangeEnd; + int $num_of_duplicates = $numOfDuplicates; + int $step_size = ($range_end - $range_start) / $num_of_duplicates; + int $i = 0; + int $temp; + + currentTime $range_start; // set to range start + + string $selectedObjects[]; // to store selected objects + $selectedObjects = `ls -sl`; // store selected objects + select $selectedObjects; + + while ($i <= $num_of_duplicates) + { + $temp = $range_start + ($step_size * $i); + currentTime ($temp); + // seleced the objects to duplicate or instance + select $selectedObjects; + if($duplicateOrInstance == 0) + { + duplicate; + } + else + { + instance; + } + $i++; + } +} \ No newline at end of file diff --git a/demo/kitchen-sink/docs/mysql.mysql b/demo/kitchen-sink/docs/mysql.mysql new file mode 100644 index 00000000..30404ce4 --- /dev/null +++ b/demo/kitchen-sink/docs/mysql.mysql @@ -0,0 +1 @@ +TODO \ No newline at end of file diff --git a/demo/kitchen-sink/docs/pgsql.pgsql b/demo/kitchen-sink/docs/pgsql.pgsql index 67be9882..ef265cdc 100644 --- a/demo/kitchen-sink/docs/pgsql.pgsql +++ b/demo/kitchen-sink/docs/pgsql.pgsql @@ -41,8 +41,8 @@ SELECT city, temp_lo, temp_hi, prcp, "date", location /** * Dollar quotes starting at the end of the line are colored as SQL unless -* a special language tag is used. Pearl and Python are currently implemented -* but lots of others are possible. +* a special language tag is used. Dollar quote syntax coloring is implemented +* for Perl, Python, JavaScript, and Json. */ create or replace function blob_content_chunked( in p_data bytea, @@ -82,6 +82,24 @@ CREATE FUNCTION usesavedplan() RETURNS trigger AS $python$ SD["plan"] = plan $python$ LANGUAGE plpythonu; +-- pl/v8 (javascript) +CREATE FUNCTION plv8_test(keys text[], vals text[]) RETURNS text AS $javascript$ +var o = {}; +for(var i=0; i= 5364 + # New-style procedure call with colon + @newStyle: "quoted", 2, "quoted string" +endif + +# if-block with built-in variables +if windows + # We are on Windows +elsif unix = 1 or !macintosh + exitScript: "We are on Linux" +else macintosh == 1 + exit We are on Mac +endif + +# inline if with inline comment +var = if macintosh = 1 then 0 else 1 fi ; This is an inline comment + +# for-loop with explicit from using local variable +# and paren-style function calls and variable interpolation +n = numberOfSelected("Sound") +for i from newStyle.local to n + sound'i' = selected("Sound", i) + sound[i] = sound'i' +endfor + +for i from 1 to n + # Different styles of object selection + select sound'i' + sound = selected() + sound$ = selected$("Sound") + select Sound 'sound$' + selectObject(sound[i]) + selectObject: sound + + # Pause commands + beginPause("Viewing " + sound$) + if i > 1 + button = endPause("Stop", "Previous", + ...if i = total_sounds then "Finish" else "Next" fi, + ...3, 1) + else + button = endPause("Stop", + ...if i = total_sounds then "Finish" else "Next" fi, + ...2, 1) + endif + editor_name$ = if total_textgrids then "TextGrid " else "Sound " fi + name$ + nocheck editor 'editor_name$' + nocheck Close + nocheck endeditor + + # New-style standalone command call + Rename: "SomeName" + + # Command call with assignment + duration = Get total duration + + # Multi-line command with modifier + pitch = noprogress To Pitch (ac): 0, 75, 15, "no", + ...0.03, 0.45, 0.01, 0.35, 0.14, 600 + + # do-style command with assignment + minimum = do("Get minimum...", 0, 0, "Hertz", "Parabolic") + + # New-style multi-line command call with broken strings + table = Create Table with column names: "table", 0, + ..."file subject speaker + ...f0 f1 f2 f3 " + + ..."duration response" + + removeObject: pitch, table + + # Picture window commands + selectObject: sound + # do-style command + do("Select inner viewport...", 1, 6, 0.5, 1.5) + Black + Draw... 0 0 0 0 "no" Curve + Draw inner box + Text bottom: "yes", sound$ + Erase all + + # Demo window commands + demo Erase all + demo Select inner viewport... 0 100 0 100 + demo Axes... 0 100 0 100 + demo Paint rectangle... white 0 100 0 100 + demo Text... 50 centre 50 half Click to finish + demoWaitForInput ( ) + demo Erase all + demo Text: 50, "centre", 50, "half", "Finished" +endfor + +# An old-style sendpraat block +sendpraat Praat + ...'newline$' Create Sound as pure tone... "tone" 1 0 0.4 44100 440 0.2 0.01 0.01 + ...'newline$' Play + ...'newline$' Remove + +# A new-style sendpraat block +beginSendPraat: "Praat" + Create Sound as pure tone: "tone", 1, 0, 0.4, 44100, 440, 0.2, 0.01, 0.01 + duration = Get total duration + Remove +endSendPraat: "duration" +appendInfoLine: "The generated sound lasted for ", duration, "seconds" + +time = stopwatch +clearinfo +echo This script took +print 'time' seconds to +printline execute. + +# Old-style procedure declaration +procedure oldStyle .str1$ .num .str2$ + .local = 1 +endproc + +# New-style procedure declaration +procedure newStyle (.str1$, .num, .str2$) + .local = 1 +endproc diff --git a/demo/kitchen-sink/docs/protobuf.proto b/demo/kitchen-sink/docs/protobuf.proto new file mode 100644 index 00000000..4da95a75 --- /dev/null +++ b/demo/kitchen-sink/docs/protobuf.proto @@ -0,0 +1,16 @@ +message Point { + required int32 x = 1; + required int32 y = 2; + optional string label = 3; +} + +message Line { + required Point start = 1; + required Point end = 2; + optional string label = 3; +} + +message Polyline { + repeated Point point = 1; + optional string label = 2; +} \ No newline at end of file diff --git a/demo/kitchen-sink/docs/ruby.rb b/demo/kitchen-sink/docs/ruby.rb index c4d73d19..386fbb86 100644 --- a/demo/kitchen-sink/docs/ruby.rb +++ b/demo/kitchen-sink/docs/ruby.rb @@ -20,7 +20,7 @@ class Range end end -{:id => 34, :key => "value"} +{:id => ?", :key => "value"} herDocs = [<<'FOO', < i.length); + } or { + hold(1500); + throw new Error("timed out"); + } +} // Real Tab. diff --git a/demo/kitchen-sink/docs/smarty.smarty b/demo/kitchen-sink/docs/smarty.smarty new file mode 100644 index 00000000..77206724 --- /dev/null +++ b/demo/kitchen-sink/docs/smarty.smarty @@ -0,0 +1,7 @@ +{foreach $foo as $bar} + {$bar.zag} + {$bar.zag2} + {$bar.zag3} +{foreachelse} + There were no rows found. +{/foreach} \ No newline at end of file diff --git a/demo/kitchen-sink/docs/soy_template.soy b/demo/kitchen-sink/docs/soy_template.soy new file mode 100644 index 00000000..3a9e3436 --- /dev/null +++ b/demo/kitchen-sink/docs/soy_template.soy @@ -0,0 +1,46 @@ +/** + * Greets a person using "Hello" by default. + * @param name The name of the person. + * @param? greetingWord Optional greeting word to use instead of "Hello". + */ +{template .helloName #eee} + {if not $greetingWord} + Hello {$name}! + {else} + {$greetingWord} {$name}! + {/if} +{/template} + +/** + * Greets a person and optionally a list of other people. + * @param name The name of the person. + * @param additionalNames The additional names to greet. May be an empty list. + */ +{template .helloNames} + // Greet the person. + {call .helloName data="all" /}
+ // Greet the additional people. + {foreach $additionalName in $additionalNames} + {call .helloName} + {param name: $additionalName /} + {/call} + {if not isLast($additionalName)} +
// break after every line except the last + {/if} + {ifempty} + No additional people to greet. + {/foreach} +{/template} + + +{/foreach} +{if length($items) > 5} +{msg desc="Says hello to the user."} + + +{namespace ns autoescape="contextual"} + +/** Example. */ +{template .example} + foo is {$ij.foo} +{/template} \ No newline at end of file diff --git a/demo/kitchen-sink/docs/space.space b/demo/kitchen-sink/docs/space.space new file mode 100644 index 00000000..7bd8ab19 --- /dev/null +++ b/demo/kitchen-sink/docs/space.space @@ -0,0 +1,56 @@ +query + count 10 + created 2011-06-21T08:10:46Z + lang en-US + results + photo + 0 + farm 6 + id 5855620975 + isfamily 0 + isfriend 0 + ispublic 1 + owner 32021554@N04 + secret f1f5e8515d + server 5110 + title 7087 bandit cat + 1 + farm 4 + id 5856170534 + isfamily 0 + isfriend 0 + ispublic 1 + owner 32021554@N04 + secret ff1efb2a6f + server 3217 + title 6975 rusty cat + 2 + farm 6 + id 5856172972 + isfamily 0 + isfriend 0 + ispublic 1 + owner 51249875@N03 + secret 6c6887347c + server 5192 + title watermarked-cats + 3 + farm 6 + id 5856168328 + isfamily 0 + isfriend 0 + ispublic 1 + owner 32021554@N04 + secret 0c1cfdf64c + server 5078 + title 7020 mandy cat + 4 + farm 3 + id 5856171774 + isfamily 0 + isfriend 0 + ispublic 1 + owner 32021554@N04 + secret 7f5a3180ab + server 2696 + title 7448 bobby cat diff --git a/demo/kitchen-sink/docs/sqlserver.sqlserver b/demo/kitchen-sink/docs/sqlserver.sqlserver new file mode 100644 index 00000000..7efd2b7e --- /dev/null +++ b/demo/kitchen-sink/docs/sqlserver.sqlserver @@ -0,0 +1,72 @@ +-- ============================================= +-- Author: Morgan Yarbrough +-- Create date: 4/27/2015 +-- Description: Test procedure that shows off language features. +-- Includes non-standard folding with region comments using either +-- line comments or block comments (both are demonstrated below). +-- This mode imitates SSMS and it designed to be used with SQL Server theme. +-- ============================================= +CREATE PROCEDURE dbo.TestProcedure + +--#region parameters + @vint INT = 1 + ,@vdate DATE = NULL + ,@vdatetime DATETIME = DATEADD(dd, 1, GETDATE()) + ,@vvarchar VARCHAR(MAX) = '' +--#endregion + +AS +BEGIN + + /*#region set statements */ + SET NOCOUNT ON; + SET XACT_ABORT ON; + SET QUOTED_IDENTIFIER ON; + /*#endregion*/ + + /** + * These comments will produce a fold widget + */ + + -- folding demonstration + SET @vint = CASE + WHEN @vdate IS NULL + THEN 1 + ELSE 2 + END + + -- another folding demonstration + IF @vint = 1 + BEGIN + SET @vvarchar = 'one' + SET @vint = DATEDIFF(dd, @vdate, @vdatetime) + END + + -- this mode handles strings properly + DECLARE @sql NVARCHAR(4000) = N'SELECT TOP(1) OrderID + FROM Orders + WHERE @OrderDate > GETDATE()' + + -- this mode is aware of built in stored procedures + EXECUTE sp_executesql @sql + + -- demonstrating some syntax highlighting + SELECT Orders.OrderID + ,Customers.CompanyName + ,DATEFROMPARTS(YEAR(GETDATE()), 1, 1) AS FirstDayOfYear + FROM Orders + INNER JOIN Customers + ON Orders.CustomerID = Customers.CustomerID + WHERE CompanyName NOT LIKE '%something' + OR CompanyName IS NULL + OR CompanyName IN ('bla', 'nothing') + + -- this mode includes snippets + -- place your cusor at the end of the line below and trigger auto complete (Ctrl+Space) + createpr + + -- SQL Server allows using keywords as object names (not recommended) as long as they are wrapped in brackets + DATABASE -- keyword + [DATABASE] -- not a keyword + +END diff --git a/demo/kitchen-sink/docs/twig.twig b/demo/kitchen-sink/docs/twig.twig index 120f33e9..02214f09 100644 --- a/demo/kitchen-sink/docs/twig.twig +++ b/demo/kitchen-sink/docs/twig.twig @@ -1,9 +1,30 @@ -{% autoescape true %} - {{ var }} - {{ var|raw }} {# var won't be escaped #} - {{ var|escape }} {# var won't be doubled-escaped #} -{% endautoescape %} + + + + My Webpage + + + -{{ include('twig.html', sandboxed = true) }} + {% if 1 not in [1, 2, 3] %} -{{"string #{with} \" escapes" 'another#one' }} \ No newline at end of file + {# is equivalent to #} + {% if not (1 in [1, 2, 3]) %} + + {% autoescape true %} + {{ var }} + {{ var|raw }} {# var won't be escaped #} + {{ var|escape }} {# var won't be doubled-escaped #} + {% endautoescape %} + + {{ include('twig.html', sandboxed = true) }} + + {{"string #{with} \" escapes" 'another#one' }} +

My Webpage

+ {{ a_variable }} + + \ No newline at end of file diff --git a/demo/kitchen-sink/docs/vala.vala b/demo/kitchen-sink/docs/vala.vala new file mode 100644 index 00000000..f9600286 --- /dev/null +++ b/demo/kitchen-sink/docs/vala.vala @@ -0,0 +1,21 @@ +using Gtk; + +int main (string[] args) { + Gtk.init (ref args); + var foo = new MyFoo>(); + + var window = new Window(); + window.title = "Hello, World!"; + window.border_width = 10; + window.window_position = WindowPosition.CENTER; + window.set_default_size(350, 70); + window.destroy.connect(Gtk.main_quit); + + var label = new Label("Hello, World!"); + + window.add(label); + window.show_all(); + + Gtk.main(); + return 0; +} \ No newline at end of file diff --git a/demo/kitchen-sink/docs/verilog.v b/demo/kitchen-sink/docs/verilog.v new file mode 100644 index 00000000..b1f79265 --- /dev/null +++ b/demo/kitchen-sink/docs/verilog.v @@ -0,0 +1,12 @@ +always @(negedge reset or posedge clk) begin + if (reset == 0) begin + d_out <= 16'h0000; + d_out_mem[resetcount] <= d_out; + laststoredvalue <= d_out; + end else begin + d_out <= d_out + 1'b1; + end +end + +always @(bufreadaddr) + bufreadval = d_out_mem[bufreadaddr]; \ No newline at end of file diff --git a/demo/kitchen-sink/docs/vhdl.vhd b/demo/kitchen-sink/docs/vhdl.vhd new file mode 100644 index 00000000..662375e8 --- /dev/null +++ b/demo/kitchen-sink/docs/vhdl.vhd @@ -0,0 +1,34 @@ +library IEEE +user IEEE.std_logic_1164.all; +use IEEE.numeric_std.all; + +entity COUNT16 is + + port ( + cOut :out std_logic_vector(15 downto 0); -- counter output + clkEn :in std_logic; -- count enable + clk :in std_logic; -- clock input + rst :in std_logic -- reset input + ); + +end entity; + +architecture count_rtl of COUNT16 is + signal count :std_logic_vector (15 downto 0); + +begin + process (clk, rst) begin + + if(rst = '1') then + count <= (others=>'0'); + elsif(rising_edge(clk)) then + if(clkEn = '1') then + count <= count + 1; + end if; + end if; + + end process; + cOut <= count; + +end architecture; + \ No newline at end of file diff --git a/demo/kitchen-sink/file_drop.js b/demo/kitchen-sink/file_drop.js new file mode 100644 index 00000000..8b89d5f1 --- /dev/null +++ b/demo/kitchen-sink/file_drop.js @@ -0,0 +1,73 @@ +/* ***** 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. + * + * ***** END LICENSE BLOCK ***** */ + +define(function(require, exports, module) { + +var config = require("ace/config"); +var event = require("ace/lib/event"); +var modelist = require("ace/ext/modelist"); + +module.exports = function(editor) { + event.addListener(editor.container, "dragover", function(e) { + var types = e.dataTransfer.types; + if (types && Array.prototype.indexOf.call(types, 'Files') !== -1) + return event.preventDefault(e); + }); + + event.addListener(editor.container, "drop", function(e) { + var file; + try { + file = e.dataTransfer.files[0]; + if (window.FileReader) { + var reader = new FileReader(); + reader.onload = function() { + var mode = modelist.getModeForPath(file.name); + editor.session.doc.setValue(reader.result); + editor.session.setMode(mode.mode); + editor.session.modeName = mode.name; + }; + reader.readAsText(file); + } + return event.preventDefault(e); + } catch(err) { + return event.stopEvent(e); + } + }); +}; + +var Editor = require("ace/editor").Editor; +config.defineOptions(Editor.prototype, "editor", { + loadDroppedFile: { + set: function() { module.exports(this); }, + value: true + } +}); + +}); \ No newline at end of file diff --git a/demo/kitchen-sink/inline_editor.js b/demo/kitchen-sink/inline_editor.js new file mode 100644 index 00000000..6b56887d --- /dev/null +++ b/demo/kitchen-sink/inline_editor.js @@ -0,0 +1,102 @@ +/* ***** 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. + * + * ***** END LICENSE BLOCK ***** */ + + +define(function(require, exports, module) { +"use strict"; + +var LineWidgets = require("ace/line_widgets").LineWidgets; +var Editor = require("ace/editor").Editor; +var Renderer = require("ace/virtual_renderer").VirtualRenderer; +var dom = require("ace/lib/dom"); + + +require("ace/commands/default_commands").commands.push({ + name: "openInlineEditor", + bindKey: "F3", + exec: function(editor) { + var split = window.env.split; + var s = editor.session; + var inlineEditor = new Editor(new Renderer()); + var splitSession = split.$cloneSession(s); + + var row = editor.getCursorPosition().row; + if (editor.session.lineWidgets && editor.session.lineWidgets[row]) { + editor.session.lineWidgets[row].destroy(); + return; + } + + var rowCount = 10; + var w = { + row: row, + // rowCount: rowCount, + fixedWidth: true, + el: dom.createElement("div"), + editor: inlineEditor + }; + var el = w.el; + el.appendChild(inlineEditor.container); + + if (!editor.session.widgetManager) { + editor.session.widgetManager = new LineWidgets(editor.session); + editor.session.widgetManager.attach(editor); + } + + var h = rowCount*editor.renderer.layerConfig.lineHeight; + inlineEditor.container.style.height = h + "px"; + + el.style.position = "absolute"; + el.style.zIndex = "4"; + el.style.borderTop = "solid blue 2px"; + el.style.borderBottom = "solid blue 2px"; + + inlineEditor.setSession(splitSession); + editor.session.widgetManager.addLineWidget(w); + + var kb = { + handleKeyboard:function(_,hashId, keyString) { + if (hashId === 0 && keyString === "esc") { + w.destroy(); + return true; + } + } + }; + + w.destroy = function() { + editor.keyBinding.removeKeyboardHandler(kb); + s.widgetManager.removeLineWidget(w); + }; + + editor.keyBinding.addKeyboardHandler(kb); + inlineEditor.keyBinding.addKeyboardHandler(kb); + inlineEditor.setTheme("ace/theme/solarized_light"); + } +}); +}); diff --git a/demo/kitchen-sink/layout.js b/demo/kitchen-sink/layout.js index 36f85cf3..1332eef3 100644 --- a/demo/kitchen-sink/layout.js +++ b/demo/kitchen-sink/layout.js @@ -103,11 +103,6 @@ var Split = function(){ exports.singleLineEditor = function(el) { var renderer = new Renderer(el); el.style.overflow = "hidden"; - renderer.scrollBar.element.style.top = "0"; - renderer.scrollBar.element.style.display = "none"; - renderer.scrollBar.orginalWidth = renderer.scrollBar.width; - renderer.scrollBar.width = 0; - renderer.content.style.height = "auto"; renderer.screenToTextCoordinates = function(x, y) { var pos = this.pixelToScreenCoordinates(x, y); @@ -117,72 +112,15 @@ exports.singleLineEditor = function(el) { ); }; - renderer.maxLines = 4; - renderer.$computeLayerConfigWithScroll = renderer.$computeLayerConfig; - renderer.$computeLayerConfig = function() { - var config = this.layerConfig; - var height = this.session.getScreenLength() * this.lineHeight; - if (config.height != height) { - var vScroll = height > this.maxLines * this.lineHeight; - - if (vScroll != this.$vScroll) { - if (vScroll) { - this.scrollBar.element.style.display = ""; - this.scrollBar.width = this.scrollBar.orginalWidth; - this.container.style.height = config.height + "px"; - height = config.height; - this.scrollTop = height - this.maxLines * this.lineHeight; - } else { - this.scrollBar.element.style.display = "none"; - this.scrollBar.width = 0; - } - - this.onResize(); - this.$vScroll = vScroll; - } - - if (this.$vScroll) - return renderer.$computeLayerConfigWithScroll(); - - this.container.style.height = height + "px"; - this.scroller.style.height = height + "px"; - this.content.style.height = height + "px"; - this._emit("resize"); - } - - var longestLine = this.$getLongestLine(); - var firstRow = 0; - var lastRow = this.session.getLength(); - - this.scrollTop = 0; - config.width = longestLine; - config.padding = this.$padding; - config.firstRow = 0; - config.firstRowScreen = 0; - config.lastRow = lastRow; - config.lineHeight = this.lineHeight; - config.characterWidth = this.characterWidth; - config.minHeight = height; - config.maxHeight = height; - config.offset = 0; - config.height = height; - - this.$gutterLayer.element.style.marginTop = 0 + "px"; - this.content.style.marginTop = 0 + "px"; - this.content.style.width = longestLine + 2 * this.$padding + "px"; - }; - renderer.isScrollableBy=function(){return false}; + renderer.$maxLines = 4; renderer.setStyle("ace_one-line"); var editor = new Editor(renderer); - new MultiSelect(editor); editor.session.setUndoManager(new UndoManager()); - editor.setHighlightActiveLine(false); editor.setShowPrintMargin(false); editor.renderer.setShowGutter(false); editor.renderer.setHighlightGutterLine(false); - editor.$mouseHandler.$focusWaitTimout = 0; return editor; diff --git a/demo/kitchen-sink/logo.png b/demo/kitchen-sink/logo.png index 58df6062..a722472f 100644 Binary files a/demo/kitchen-sink/logo.png and b/demo/kitchen-sink/logo.png differ diff --git a/demo/kitchen-sink/require.js b/demo/kitchen-sink/require.js index 9199e0fb..203843c1 100644 --- a/demo/kitchen-sink/require.js +++ b/demo/kitchen-sink/require.js @@ -1,5 +1,5 @@ /** vim: et:ts=4:sw=4:sts=4 - * @license RequireJS 2.1.5 Copyright (c) 2010-2012, The Dojo Foundation All Rights Reserved. + * @license RequireJS 2.1.11+ Copyright (c) 2010-2014, The Dojo Foundation All Rights Reserved. * Available via the MIT or new BSD license. * see: http://github.com/jrburke/requirejs for details */ @@ -12,7 +12,7 @@ var requirejs, require, define; (function (global) { var req, s, head, baseElement, dataMain, src, interactiveScript, currentlyAddingScript, mainScript, subPath, - version = '2.1.5', + version = '2.1.11+', commentRegExp = /(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg, cjsRequireRegExp = /[^.]\s*require\s*\(\s*["']([^'"\s]+)["']\s*\)/g, jsSuffixRegExp = /\.js$/, @@ -22,7 +22,7 @@ var requirejs, require, define; hasOwn = op.hasOwnProperty, ap = Array.prototype, apsp = ap.splice, - isBrowser = !!(typeof window !== 'undefined' && navigator && document), + isBrowser = !!(typeof window !== 'undefined' && typeof navigator !== 'undefined' && window.document), isWebWorker = !isBrowser && typeof importScripts !== 'undefined', //PS3 indicates loaded and complete, but need to wait for complete //specifically. Sequence is 'loading', 'loaded', execution, @@ -108,7 +108,10 @@ var requirejs, require, define; if (source) { eachProp(source, function (value, prop) { if (force || !hasProp(target, prop)) { - if (deepStringMixin && typeof value !== 'string') { + if (deepStringMixin && typeof value === 'object' && value && + !isArray(value) && !isFunction(value) && + !(value instanceof RegExp)) { + if (!target[prop]) { target[prop] = {}; } @@ -134,7 +137,11 @@ var requirejs, require, define; return document.getElementsByTagName('script'); } - //Allow getting a global that expressed in + function defaultOnError(err) { + throw err; + } + + //Allow getting a global that is expressed in //dot notation, like 'a.b.c'. function getGlobal(value) { if (!value) { @@ -173,7 +180,7 @@ var requirejs, require, define; if (typeof requirejs !== 'undefined') { if (isFunction(requirejs)) { - //Do not overwrite and existing requirejs instance. + //Do not overwrite an existing requirejs instance. return; } cfg = requirejs; @@ -197,6 +204,7 @@ var requirejs, require, define; waitSeconds: 7, baseUrl: './', paths: {}, + bundles: {}, pkgs: {}, shim: {}, config: {} @@ -210,6 +218,7 @@ var requirejs, require, define; defQueue = [], defined = {}, urlFetched = {}, + bundlesMap = {}, requireCounter = 1, unnormalizedCounter = 1; @@ -223,8 +232,8 @@ var requirejs, require, define; * @param {Array} ary the array of path segments. */ function trimDots(ary) { - var i, part; - for (i = 0; ary[i]; i += 1) { + var i, part, length = ary.length; + for (i = 0; i < length; i++) { part = ary[i]; if (part === '.') { ary.splice(i, 1); @@ -257,7 +266,7 @@ var requirejs, require, define; * @returns {String} normalized name */ function normalize(name, baseName, applyMap) { - var pkgName, pkgConfig, mapValue, nameParts, i, j, nameSegment, + var pkgMain, mapValue, nameParts, i, j, nameSegment, lastIndex, foundMap, foundI, foundStarMap, starI, baseParts = baseName && baseName.split('/'), normalizedBaseParts = baseParts, @@ -270,29 +279,26 @@ var requirejs, require, define; //otherwise, assume it is a top-level require that will //be relative to baseUrl in the end. if (baseName) { - if (getOwn(config.pkgs, baseName)) { - //If the baseName is a package name, then just treat it as one - //name to concat the name with. - normalizedBaseParts = baseParts = [baseName]; - } else { - //Convert baseName to array, and lop off the last part, - //so that . matches that 'directory' and not name of the baseName's - //module. For instance, baseName of 'one/two/three', maps to - //'one/two/three.js', but we want the directory, 'one/two' for - //this normalization. - normalizedBaseParts = baseParts.slice(0, baseParts.length - 1); + //Convert baseName to array, and lop off the last part, + //so that . matches that 'directory' and not name of the baseName's + //module. For instance, baseName of 'one/two/three', maps to + //'one/two/three.js', but we want the directory, 'one/two' for + //this normalization. + normalizedBaseParts = baseParts.slice(0, baseParts.length - 1); + name = name.split('/'); + lastIndex = name.length - 1; + + // If wanting node ID compatibility, strip .js from end + // of IDs. Have to do this here, and not in nameToUrl + // because node allows either .js or non .js to map + // to same file. + if (config.nodeIdCompat && jsSuffixRegExp.test(name[lastIndex])) { + name[lastIndex] = name[lastIndex].replace(jsSuffixRegExp, ''); } - name = normalizedBaseParts.concat(name.split('/')); + name = normalizedBaseParts.concat(name); trimDots(name); - - //Some use of packages may use a . path to reference the - //'main' module name, so normalize for that. - pkgConfig = getOwn(config.pkgs, (pkgName = name[0])); name = name.join('/'); - if (pkgConfig && name === pkgName + '/' + pkgConfig.main) { - name = pkgName; - } } else if (name.indexOf('./') === 0) { // No baseName, so this is ID is resolved relative // to baseUrl, pull off the leading dot. @@ -304,7 +310,7 @@ var requirejs, require, define; if (applyMap && map && (baseParts || starMap)) { nameParts = name.split('/'); - for (i = nameParts.length; i > 0; i -= 1) { + outerLoop: for (i = nameParts.length; i > 0; i -= 1) { nameSegment = nameParts.slice(0, i).join('/'); if (baseParts) { @@ -321,16 +327,12 @@ var requirejs, require, define; //Match, update name to the new value. foundMap = mapValue; foundI = i; - break; + break outerLoop; } } } } - if (foundMap) { - break; - } - //Check for a star map match, but just hold on to it, //if there is a shorter segment match later in a matching //config, then favor over this star map. @@ -351,7 +353,11 @@ var requirejs, require, define; } } - return name; + // If the name points to a package's name, use + // the package main instead. + pkgMain = getOwn(config.pkgs, name); + + return pkgMain ? pkgMain : name; } function removeScript(name) { @@ -369,12 +375,17 @@ var requirejs, require, define; function hasPathFallback(id) { var pathConfig = getOwn(config.paths, id); if (pathConfig && isArray(pathConfig) && pathConfig.length > 1) { - removeScript(id); //Pop off the first array value, since it failed, and //retry pathConfig.shift(); context.require.undef(id); - context.require([id]); + + //Custom require that does not do map translation, since + //ID is "absolute", already mapped/resolved. + context.makeRequire(null, { + skipMap: true + })([id]); + return true; } } @@ -500,7 +511,12 @@ var requirejs, require, define; fn(defined[id]); } } else { - getModule(depMap).on(name, fn); + mod = getModule(depMap); + if (mod.error && name === 'error') { + fn(mod.error); + } else { + mod.on(name, fn); + } } } @@ -540,7 +556,7 @@ var requirejs, require, define; //local var ref to defQueue, so cannot just reassign the one //on context. apsp.apply(defQueue, - [defQueue.length - 1, 0].concat(globalDefQueue)); + [defQueue.length, 0].concat(globalDefQueue)); globalDefQueue = []; } } @@ -557,7 +573,7 @@ var requirejs, require, define; mod.usingExports = true; if (mod.map.isDefine) { if (mod.exports) { - return mod.exports; + return (defined[mod.map.id] = mod.exports); } else { return (mod.exports = defined[mod.map.id] = {}); } @@ -571,9 +587,9 @@ var requirejs, require, define; id: mod.map.id, uri: mod.map.url, config: function () { - return (config.config && getOwn(config.config, mod.map.id)) || {}; + return getOwn(config.config, mod.map.id) || {}; }, - exports: defined[mod.map.id] + exports: mod.exports || (mod.exports = {}) }); } } @@ -614,7 +630,7 @@ var requirejs, require, define; } function checkLoaded() { - var map, modId, err, usingPathFallback, + var err, usingPathFallback, waitInterval = config.waitSeconds * 1000, //It is possible to disable the wait interval by using waitSeconds of 0. expired = waitInterval && (context.startTime + waitInterval) < new Date().getTime(), @@ -632,8 +648,8 @@ var requirejs, require, define; //Figure out the state of all the modules. eachProp(enabledRegistry, function (mod) { - map = mod.map; - modId = map.id; + var map = mod.map, + modId = map.id; //Skip things that are not enabled or in error state. if (!mod.enabled) { @@ -840,8 +856,13 @@ var requirejs, require, define; if (this.depCount < 1 && !this.defined) { if (isFunction(factory)) { //If there is an error listener, favor passing - //to that instead of throwing an error. - if (this.events.error) { + //to that instead of throwing an error. However, + //only do it for define()'d modules. require + //errbacks should not be called for failures in + //their callbacks (#699). However if a global + //onError is set, use that. + if ((this.events.error && this.map.isDefine) || + req.onError !== defaultOnError) { try { exports = context.execCb(id, factory, depExports, exports); } catch (e) { @@ -851,17 +872,14 @@ var requirejs, require, define; exports = context.execCb(id, factory, depExports, exports); } - if (this.map.isDefine) { - //If setting exports via 'module' is in play, - //favor that over return value and exports. After that, - //favor a non-undefined return value over exports use. + // Favor return value over exports. If node/cjs in play, + // then will not have a return value anyway. Favor + // module.exports assignment over exports object. + if (this.map.isDefine && exports === undefined) { cjsModule = this.module; - if (cjsModule && - cjsModule.exports !== undefined && - //Make sure it is not already the exports value - cjsModule.exports !== this.exports) { + if (cjsModule) { exports = cjsModule.exports; - } else if (exports === undefined && this.usingExports) { + } else if (this.usingExports) { //exports already set the defined value. exports = this.exports; } @@ -869,8 +887,8 @@ var requirejs, require, define; if (err) { err.requireMap = this.map; - err.requireModules = [this.map.id]; - err.requireType = 'define'; + err.requireModules = this.map.isDefine ? [this.map.id] : null; + err.requireType = this.map.isDefine ? 'define' : 'require'; return onError((this.error = err)); } @@ -921,6 +939,7 @@ var requirejs, require, define; on(pluginMap, 'defined', bind(this, function (plugin) { var load, normalizedMap, normalizedMod, + bundleId = getOwn(bundlesMap, this.map.id), name = this.map.name, parentName = this.map.parentMap ? this.map.parentMap.name : null, localRequire = context.makeRequire(map.parentMap, { @@ -966,6 +985,14 @@ var requirejs, require, define; return; } + //If a paths config, then just load that file instead to + //resolve the plugin, as it is built into that paths layer. + if (bundleId) { + this.map.url = context.nameToUrl(bundleId); + this.load(); + return; + } + load = bind(this, function (value) { this.init([], function () { return value; }, null, { enabled: true @@ -1093,7 +1120,7 @@ var requirejs, require, define; })); if (this.errback) { - on(depMap, 'error', this.errback); + on(depMap, 'error', bind(this, this.errback)); } } @@ -1230,31 +1257,38 @@ var requirejs, require, define; } } - //Save off the paths and packages since they require special processing, + //Save off the paths since they require special processing, //they are additive. - var pkgs = config.pkgs, - shim = config.shim, + var shim = config.shim, objs = { paths: true, + bundles: true, config: true, map: true }; eachProp(cfg, function (value, prop) { if (objs[prop]) { - if (prop === 'map') { - if (!config.map) { - config.map = {}; - } - mixin(config[prop], value, true, true); - } else { - mixin(config[prop], value, true); + if (!config[prop]) { + config[prop] = {}; } + mixin(config[prop], value, true, true); } else { config[prop] = value; } }); + //Reverse map the bundles + if (cfg.bundles) { + eachProp(cfg.bundles, function (value, prop) { + each(value, function (v) { + if (v !== prop) { + bundlesMap[v] = prop; + } + }); + }); + } + //Merge shim if (cfg.shim) { eachProp(cfg.shim, function (value, id) { @@ -1275,29 +1309,25 @@ var requirejs, require, define; //Adjust packages if necessary. if (cfg.packages) { each(cfg.packages, function (pkgObj) { - var location; + var location, name; pkgObj = typeof pkgObj === 'string' ? { name: pkgObj } : pkgObj; + + name = pkgObj.name; location = pkgObj.location; + if (location) { + config.paths[name] = pkgObj.location; + } - //Create a brand new object on pkgs, since currentPackages can - //be passed in again, and config.pkgs is the internal transformed - //state for all package configs. - pkgs[pkgObj.name] = { - name: pkgObj.name, - location: location || pkgObj.name, - //Remove leading dot in main, so main paths are normalized, - //and remove any trailing .js, since different package - //envs have different conventions: some use a module name, - //some use a file name. - main: (pkgObj.main || 'main') - .replace(currDirRegExp, '') - .replace(jsSuffixRegExp, '') - }; + //Save pointer to main module ID for pkg name. + //Remove leading dot in main, so main paths are normalized, + //and remove any trailing .js, since different package + //envs have different conventions: some use a module name, + //some use a file name. + config.pkgs[name] = pkgObj.name + '/' + (pkgObj.main || 'main') + .replace(currDirRegExp, '') + .replace(jsSuffixRegExp, ''); }); - - //Done with modifications, assing packages back to context config - config.pkgs = pkgs; } //If there are any "waiting to execute" modules in the registry, @@ -1444,10 +1474,21 @@ var requirejs, require, define; var map = makeModuleMap(id, relMap, true), mod = getOwn(registry, id); + removeScript(id); + delete defined[id]; delete urlFetched[map.url]; delete undefEvents[id]; + //Clean queued defines too. Go backwards + //in array so that the splices do not + //mess up the iteration. + eachReverse(defQueue, function(args, i) { + if(args[0] === id) { + defQueue.splice(i, 1); + } + }); + if (mod) { //Hold on to listeners in case the //module will be attempted to be reloaded @@ -1467,7 +1508,7 @@ var requirejs, require, define; /** * Called to enable a module if it is still in the registry * awaiting enablement. A second arg, parent, the parent module, - * is passed in for context, when this method is overriden by + * is passed in for context, when this method is overridden by * the optimizer. Not shown here to keep code compact. */ enable: function (depMap) { @@ -1541,8 +1582,19 @@ var requirejs, require, define; * internal API, not a public one. Use toUrl for the public API. */ nameToUrl: function (moduleName, ext, skipExt) { - var paths, pkgs, pkg, pkgPath, syms, i, parentModule, url, - parentPath; + var paths, syms, i, parentModule, url, + parentPath, bundleId, + pkgMain = getOwn(config.pkgs, moduleName); + + if (pkgMain) { + moduleName = pkgMain; + } + + bundleId = getOwn(bundlesMap, moduleName); + + if (bundleId) { + return context.nameToUrl(bundleId, ext, skipExt); + } //If a colon is in the URL, it indicates a protocol is used and it is just //an URL to a file, or if it starts with a slash, contains a query arg (i.e. ?) @@ -1556,7 +1608,6 @@ var requirejs, require, define; } else { //A module that needs to be converted to a path. paths = config.paths; - pkgs = config.pkgs; syms = moduleName.split('/'); //For each module name segment, see if there is a path @@ -1564,7 +1615,7 @@ var requirejs, require, define; //and work up from it. for (i = syms.length; i > 0; i -= 1) { parentModule = syms.slice(0, i).join('/'); - pkg = getOwn(pkgs, parentModule); + parentPath = getOwn(paths, parentModule); if (parentPath) { //If an array, it means there are a few choices, @@ -1574,22 +1625,12 @@ var requirejs, require, define; } syms.splice(0, i, parentPath); break; - } else if (pkg) { - //If module name is just the package name, then looking - //for the main module. - if (moduleName === pkg.name) { - pkgPath = pkg.location + '/' + pkg.main; - } else { - pkgPath = pkg.location; - } - syms.splice(0, i, pkgPath); - break; } } //Join the path parts together, then figure out if baseUrl is needed. url = syms.join('/'); - url += (ext || (/\?/.test(url) || skipExt ? '' : '.js')); + url += (ext || (/^data\:|\?/.test(url) || skipExt ? '' : '.js')); url = (url.charAt(0) === '/' || url.match(/^[\w\+\.\-]+:/) ? '' : config.baseUrl) + url; } @@ -1605,7 +1646,7 @@ var requirejs, require, define; }, /** - * Executes a module callack function. Broken out as a separate function + * Executes a module callback function. Broken out as a separate function * solely to allow the build system to sequence the files in the built * layer in the right sequence. * @@ -1643,7 +1684,7 @@ var requirejs, require, define; onScriptError: function (evt) { var data = getScriptData(evt); if (!hasPathFallback(data.id)) { - return onError(makeError('scripterror', 'Script error', evt, [data.id])); + return onError(makeError('scripterror', 'Script error for: ' + data.id, evt, [data.id])); } } }; @@ -1772,8 +1813,19 @@ var requirejs, require, define; * function. Intercept/override it if you want custom error handling. * @param {Error} err the error object. */ - req.onError = function (err) { - throw err; + req.onError = defaultOnError; + + /** + * Creates the node for the load command. Only used in browser envs. + */ + req.createNode = function (config, moduleName, url) { + var node = config.xhtml ? + document.createElementNS('http://www.w3.org/1999/xhtml', 'html:script') : + document.createElement('script'); + node.type = config.scriptType || 'text/javascript'; + node.charset = 'utf-8'; + node.async = true; + return node; }; /** @@ -1790,12 +1842,7 @@ var requirejs, require, define; node; if (isBrowser) { //In the browser so use a script tag - node = config.xhtml ? - document.createElementNS('http://www.w3.org/1999/xhtml', 'html:script') : - document.createElement('script'); - node.type = config.scriptType || 'text/javascript'; - node.charset = 'utf-8'; - node.async = true; + node = req.createNode(config, moduleName, url); node.setAttribute('data-requirecontext', context.contextName); node.setAttribute('data-requiremodule', moduleName); @@ -1892,7 +1939,7 @@ var requirejs, require, define; } //Look for a data-main script attribute, which could also adjust the baseUrl. - if (isBrowser) { + if (isBrowser && !cfg.skipDataMain) { //Figure out baseUrl. Get it from the script tag with require.js in it. eachReverse(scripts(), function (script) { //Set the 'head' where we can append children by @@ -1906,24 +1953,31 @@ var requirejs, require, define; //baseUrl, if it is not already set. dataMain = script.getAttribute('data-main'); if (dataMain) { + //Preserve dataMain in case it is a path (i.e. contains '?') + mainScript = dataMain; + //Set final baseUrl if there is not already an explicit one. if (!cfg.baseUrl) { //Pull off the directory of data-main for use as the //baseUrl. - src = dataMain.split('/'); + src = mainScript.split('/'); mainScript = src.pop(); subPath = src.length ? src.join('/') + '/' : './'; cfg.baseUrl = subPath; - dataMain = mainScript; } - //Strip off any trailing .js since dataMain is now + //Strip off any trailing .js since mainScript is now //like a module name. - dataMain = dataMain.replace(jsSuffixRegExp, ''); + mainScript = mainScript.replace(jsSuffixRegExp, ''); + + //If mainScript is still a path, fall back to dataMain + if (req.jsExtRegExp.test(mainScript)) { + mainScript = dataMain; + } //Put the data-main script in the files to load. - cfg.deps = cfg.deps ? cfg.deps.concat(dataMain) : [dataMain]; + cfg.deps = cfg.deps ? cfg.deps.concat(mainScript) : [mainScript]; return true; } diff --git a/demo/kitchen-sink/styles.css b/demo/kitchen-sink/styles.css index ba1c1b47..3f46f701 100644 --- a/demo/kitchen-sink/styles.css +++ b/demo/kitchen-sink/styles.css @@ -16,9 +16,8 @@ body { color: white; } -#logo { - padding: 15px; - margin-left: 70px; +#c9-logo, #ace-logo { + padding: 0; border: none; } @@ -47,4 +46,10 @@ body { position: absolute; right: 0; border-left: 1px solid; -} \ No newline at end of file +} + +/* .ace_text-input { + z-index: 10!important; + opacity: 1!important; + background: rgb(84, 0, 255)!important; +}*/ diff --git a/demo/kitchen-sink/token_tooltip.js b/demo/kitchen-sink/token_tooltip.js index b16966c2..9e607f69 100644 --- a/demo/kitchen-sink/token_tooltip.js +++ b/demo/kitchen-sink/token_tooltip.js @@ -32,25 +32,26 @@ define(function(require, exports, module) { "use strict"; var dom = require("ace/lib/dom"); +var oop = require("ace/lib/oop"); var event = require("ace/lib/event"); var Range = require("ace/range").Range; +var Tooltip = require("ace/tooltip").Tooltip; -var tooltipNode; - -var TokenTooltip = function(editor) { +function TokenTooltip (editor) { if (editor.tokenTooltip) return; - editor.tokenTooltip = this; + Tooltip.call(this, editor.container); + editor.tokenTooltip = this; this.editor = editor; - - editor.tooltip = tooltipNode || this.$init(); this.update = this.update.bind(this); this.onMouseMove = this.onMouseMove.bind(this); this.onMouseOut = this.onMouseOut.bind(this); event.addListener(editor.renderer.scroller, "mousemove", this.onMouseMove); event.addListener(editor.renderer.content, "mouseout", this.onMouseOut); -}; +} + +oop.inherits(TokenTooltip, Tooltip); (function(){ this.token = {}; @@ -63,8 +64,8 @@ var TokenTooltip = function(editor) { if (this.lastT - (r.timeStamp || 0) > 1000) { r.rect = null; r.timeStamp = this.lastT; - this.maxHeight = innerHeight; - this.maxWidth = innerWidth; + this.maxHeight = window.innerHeight; + this.maxWidth = window.innerWidth; } var canvasPos = r.rect || (r.rect = r.scroller.getBoundingClientRect()); @@ -86,15 +87,10 @@ var TokenTooltip = function(editor) { } if (!token) { session.removeMarker(this.marker); - tooltipNode.style.display = "none"; - this.isOpen = false; + this.hide(); return; } - if (!this.isOpen) { - tooltipNode.style.display = ""; - this.isOpen = true; - } - + var tokenText = token.type; if (token.state) tokenText += "|" + token.state; @@ -102,15 +98,15 @@ var TokenTooltip = function(editor) { tokenText += "\n merge"; if (token.stateTransitions) tokenText += "\n " + token.stateTransitions.join("\n "); - + if (this.tokenText != tokenText) { - tooltipNode.textContent = tokenText; - this.tooltipWidth = tooltipNode.offsetWidth; - this.tooltipHeight = tooltipNode.offsetHeight; + this.setText(tokenText); + this.width = this.getWidth(); + this.height = this.getHeight(); this.tokenText = tokenText; } - - this.updateTooltipPosition(this.x, this.y); + + this.show(null, this.x, this.y); this.token = token; session.removeMarker(this.marker); @@ -123,56 +119,34 @@ var TokenTooltip = function(editor) { this.y = e.clientY; if (this.isOpen) { this.lastT = e.timeStamp; - this.updateTooltipPosition(this.x, this.y); + this.setPosition(this.x, this.y); } if (!this.$timer) this.$timer = setTimeout(this.update, 100); }; - + this.onMouseOut = function(e) { - var t = e && e.relatedTarget; - var ct = e && e.currentTarget; - while(t && (t = t.parentNode)) { - if (t == ct) - return; - } - tooltipNode.style.display = "none"; + if (e && e.currentTarget.contains(e.relatedTarget)) + return; + this.hide(); this.editor.session.removeMarker(this.marker); this.$timer = clearTimeout(this.$timer); - this.isOpen = false; - }; - - this.updateTooltipPosition = function(x, y) { - var st = tooltipNode.style; - if (x + 10 + this.tooltipWidth > this.maxWidth) - x = innerWidth - this.tooltipWidth - 10; - if (y > innerHeight * 0.75 || y + 20 + this.tooltipHeight > this.maxHeight) - y = y - this.tooltipHeight - 30; - - st.left = x + 10 + "px"; - st.top = y + 20 + "px"; }; - this.$init = function() { - tooltipNode = document.documentElement.appendChild(dom.createElement("div")); - var st = tooltipNode.style; - st.position = "fixed"; - st.display = "none"; - st.background = "lightyellow"; - st.borderRadius = ""; - st.border = "1px solid gray"; - st.padding = "1px"; - st.zIndex = 1000; - st.fontFamily = "monospace"; - st.whiteSpace = "pre-line"; - return tooltipNode; + this.setPosition = function(x, y) { + if (x + 10 + this.width > this.maxWidth) + x = window.innerWidth - this.width - 10; + if (y > window.innerHeight * 0.75 || y + 20 + this.height > this.maxHeight) + y = y - this.height - 30; + + Tooltip.prototype.setPosition.call(this, x + 10, y + 20); }; this.destroy = function() { this.onMouseOut(); event.removeListener(this.editor.renderer.scroller, "mousemove", this.onMouseMove); event.removeListener(this.editor.renderer.content, "mouseout", this.onMouseOut); - delete this.editor.tokenTooltip; + delete this.editor.tokenTooltip; }; }).call(TokenTooltip.prototype); @@ -180,4 +154,3 @@ var TokenTooltip = function(editor) { exports.TokenTooltip = TokenTooltip; }); - diff --git a/demo/kitchen-sink/util.js b/demo/kitchen-sink/util.js index d2e32524..c4b74f38 100644 --- a/demo/kitchen-sink/util.js +++ b/demo/kitchen-sink/util.js @@ -42,7 +42,7 @@ var MultiSelect = require("ace/multi_select").MultiSelect; exports.createEditor = function(el) { return new Editor(new Renderer(el)); -} +}; exports.createSplitEditor = function(el) { if (typeof(el) == "string") @@ -62,9 +62,6 @@ exports.createSplitEditor = function(el) { split.editor1 = split[1] = new Editor(new Renderer(e1)); split.splitter = s; - MultiSelect(split.editor0); - MultiSelect(split.editor1); - s.ratio = 0.5; split.resize = function resize(){ @@ -108,8 +105,8 @@ exports.createSplitEditor = function(el) { }; var onResizeInterval = function() { - s.ratio = (x - rect.left) / rect.width - split.resize() + s.ratio = (x - rect.left) / rect.width; + split.resize(); }; event.capture(s, onMouseMove, onResizeEnd); @@ -221,7 +218,7 @@ function optgroup(values) { return values.map(function(item) { if (typeof item == "string") item = {name: item, caption: item}; - return elt("option", {value: item.name}, item.caption || item.desc); + return elt("option", {value: item.value || item.name}, item.caption || item.desc); }); } diff --git a/demo/modelist.html b/demo/modelist.html index 659e3805..9b4b6039 100644 --- a/demo/modelist.html +++ b/demo/modelist.html @@ -23,26 +23,29 @@

     
-
-
+
 
 
-
+
 
 
diff --git a/demo/r.js/build.js b/demo/r.js/build.js
new file mode 100644
index 00000000..028d2234
--- /dev/null
+++ b/demo/r.js/build.js
@@ -0,0 +1,20 @@
+({
+    optimize: "none",
+    preserveLicenseComments: false,
+    name: "node_modules/almond/almond",
+    baseUrl: "../../",
+    paths: {
+        ace : "lib/ace",
+        demo: "demo/kitchen-sink"        
+    },
+    packages: [
+    ],
+    include: [
+        "ace/ace"
+    ],
+    exclude: [
+    ],
+    out: "./packed.js",
+    useStrict: true,
+    wrap: false
+})
\ No newline at end of file
diff --git a/demo/r.js/editor.html b/demo/r.js/editor.html
new file mode 100644
index 00000000..9f7a47bf
--- /dev/null
+++ b/demo/r.js/editor.html
@@ -0,0 +1,36 @@
+
+
+
+
+    Editor
+        
+
+
+    
+ + + +
+
+        
+ demo showing Ace usage with r.js: + + install r.js and almond + and run `r.js -o demo/r.js/build.js` + + note that you also need ace/build/src to lazy load modes and themes + require("ace/config").set("basePath", "../../build/src"); + require("ace/config").set("packaged", true); +
+
+ + + + + diff --git a/demo/requirejs+build.html b/demo/requirejs+build.html index 4a494063..72d50dbc 100644 --- a/demo/requirejs+build.html +++ b/demo/requirejs+build.html @@ -29,14 +29,20 @@ } - diff --git a/demo/scrollable-page.html b/demo/scrollable-page.html index b2de3292..ef725c4a 100644 --- a/demo/scrollable-page.html +++ b/demo/scrollable-page.html @@ -5,19 +5,18 @@ Editor + + + +

Client Side Syntax Highlighting

+ +

Syntax highlighting using Ace language modes and themes.

+ +
+.code { + width: 50%; + white-space: pre-wrap; + border: solid lightgrey 1px +} + +
+ +
+function wobble (flam) {
+    return flam.wobbled = true;
+}
+
+
+ + +
+--[[-- +num_args takes in 5.1 byte code and extracts the number of arguments from its function header. +--]]-- + +function int(t) + return t:byte(1) + t:byte(2) * 0x100 + t:byte(3) * 0x10000 + t:byte(4) * 0x1000000 +end + +function num_args(func) + local dump = string.dump(func) + local offset, cursor = int(dump:sub(13)), offset + 26 + --Get the params and var flag (whether there's a ... in the param) + return dump:sub(cursor):byte(), dump:sub(cursor+1):byte() +end + +
+ + + + + + + diff --git a/demo/static-highlighter/client-noconflict.html b/demo/static-highlighter/client-noconflict.html deleted file mode 100644 index fa9d345d..00000000 --- a/demo/static-highlighter/client-noconflict.html +++ /dev/null @@ -1,71 +0,0 @@ - - - - - Static Code highlighter using Ace - - - - - -

Client Side Syntax Highlighting

- -

Syntax highlighting using Ace language modes and themes.

- -
-.code { - width: 50%; - position: relative; - white-space: pre-wrap; -} - -
- -
-function wobble (flam) {
-    return flam.wobbled = true;
-}
-
-// the scrollbars are from overflow auto on .ace_editor.
-
-
- - - - - - - - diff --git a/demo/static-highlighter/server.js b/demo/static-highlighter/server.js index 0571c8f8..ea8361d4 100644 --- a/demo/static-highlighter/server.js +++ b/demo/static-highlighter/server.js @@ -6,11 +6,9 @@ // include ace search path and modules require("amd-loader"); -// load jsdom, which is required by Ace -require("../../lib/ace/test/mockdom"); - var http = require("http"); var fs = require("fs"); +var resolve = require("path").resolve; // load the highlighter and the desired mode and theme var highlighter = require("../../lib/ace/ext/static_highlight"); @@ -20,15 +18,24 @@ var theme = require("../../lib/ace/theme/twilight"); var port = process.env.PORT || 2222; http.createServer(function(req, res) { + var url = req.url; + var path = /[^#?\x00]*/.exec(url)[0]; + var root = resolve(__dirname + "/../../").replace(/\\/g, "/"); + path = resolve(root + "/" + path).replace(/\\/g, "/"); + if (path.indexOf(root + "/") != 0) + path = __filename; res.writeHead(200, {"Content-Type": "text/html; charset=utf-8"}); - fs.readFile(__filename, "utf8", function(err, data) { + fs.readFile(path, "utf8", function(err, data) { + if (err) data = err.message; var highlighted = highlighter.render(data, new JavaScriptMode(), theme); - res.end('\n\ -\n\ -:html:\n\ -'.replace(":css:", highlighted.css).replace(":html:", highlighted.html)); + res.end( + '\n' + + '\n' + + highlighted.html + + '' + ); }); }).listen(port); diff --git a/demo/statusbar.html b/demo/statusbar.html index 9fc6583c..d38bfcb9 100644 --- a/demo/statusbar.html +++ b/demo/statusbar.html @@ -41,17 +41,21 @@

 
ace rocks!
- - + - + diff --git a/doc/Contributor_License_Agreement-v2.pdf b/doc/Contributor_License_Agreement-v2.pdf deleted file mode 100644 index 1c4baa87..00000000 Binary files a/doc/Contributor_License_Agreement-v2.pdf and /dev/null differ diff --git a/doc/Corporate_Contributor_License_Agreement-v2.pdf b/doc/Corporate_Contributor_License_Agreement-v2.pdf deleted file mode 100644 index dbeaf37c..00000000 Binary files a/doc/Corporate_Contributor_License_Agreement-v2.pdf and /dev/null differ diff --git a/doc/site/images/FineCut_small_logo.png b/doc/site/images/FineCut_small_logo.png deleted file mode 100644 index 87f310b2..00000000 Binary files a/doc/site/images/FineCut_small_logo.png and /dev/null differ diff --git a/doc/site/images/KERA-med-web.png b/doc/site/images/KERA-med-web.png deleted file mode 100644 index de004afc..00000000 Binary files a/doc/site/images/KERA-med-web.png and /dev/null differ diff --git a/doc/site/images/acebug-logo.png b/doc/site/images/acebug-logo.png deleted file mode 100644 index cac5a3fb..00000000 Binary files a/doc/site/images/acebug-logo.png and /dev/null differ diff --git a/doc/site/images/habitat-logo.svg b/doc/site/images/habitat-logo.svg new file mode 100644 index 00000000..986c3687 --- /dev/null +++ b/doc/site/images/habitat-logo.svg @@ -0,0 +1 @@ +Slice 1 \ No newline at end of file diff --git a/doc/site/images/lws-logo.png b/doc/site/images/lws-logo.png deleted file mode 100644 index 402b332c..00000000 Binary files a/doc/site/images/lws-logo.png and /dev/null differ diff --git a/doc/site/js/main.js b/doc/site/js/main.js index b52d6f6b..39dc202d 100644 --- a/doc/site/js/main.js +++ b/doc/site/js/main.js @@ -1,27 +1,62 @@ var editor; var embedded_editor; $(function() { - hljs.initHighlighting(); - ace.config.set("workerPath", "build/src-min"); - editor = ace.edit("ace_editor_demo"); - editor.container.style.opacity = ""; - embedded_editor = ace.edit("embedded_ace_code"); - embedded_editor.container.style.opacity = ""; - editor.session.setMode("ace/mode/javascript"); - editor.session.setMode("ace/mode/javascript"); - embedded_editor.session.setMode("ace/mode/html"); - - embedded_editor.setAutoScrollEditorIntoView(true); - editor.setAutoScrollEditorIntoView(true); + if (typeof ace !== "undefined") { + ace.config.set("workerPath", "build/src-min"); + editor = ace.edit("ace_editor_demo"); + editor.container.style.opacity = ""; + embedded_editor = ace.edit("embedded_ace_code"); + embedded_editor.container.style.opacity = ""; + embedded_editor.session.setMode("ace/mode/html"); + embedded_editor.setAutoScrollEditorIntoView(true); + embedded_editor.setOption("maxLines", 40); + + editor.setOptions({ + maxLines: 30, + mode: "ace/mode/javascript", + autoScrollEditorIntoView: true + }); + + ace.config.loadModule("ace/ext/emmet", function() { + ace.require("ace/lib/net").loadScript("http://cloud9ide.github.io/emmet-core/emmet.js", function() { + embedded_editor.setOption("enableEmmet", true); + editor.setOption("enableEmmet", true); + }); + }); + + ace.config.loadModule("ace/ext/language_tools", function() { + embedded_editor.setOptions({ + enableSnippets: true, + enableBasicAutocompletion: true + }); + editor.setOptions({ + enableSnippets: true, + enableBasicAutocompletion: true + }); + }); + } else { + document.body.insertAdjacentHTML("afterbegin", '
\ +
\ + \ + Oh No! Couldn\'t load build/src/ace.js.
\ + You can build it by running node Makefile.dryice.js
\ + Or download older version by running git submodule update --init --recursive
\ +
\ +
'); + } + $("ul.menu-list").mousedown(function(e) { + if (e.button === 1) { + e.preventDefault(); + } + }); $("ul.menu-list li").click(function(e) { - if (e.target.tagName === "LI") { - console.log($(this).find("a")); - window.location = $(this).find("a").attr("href"); - } - else if (e.target.tagName === "P" || e.target.tagName === "IMG") { - var anchor = $(e.target).siblings(); - window.location = anchor.attr("href"); + if (e.target.tagName !== "A") { + var href = $(this).find("a").attr("href"); + if (e.button == 1) + window.open(href, "_blank"); + else + window.location = href; } }); @@ -53,19 +88,17 @@ $(function() { $('.menu-item a').click(magicClickInterceptor); $('a.argument').click(magicClickInterceptor); - $('a.external').click(function(e) { + $('a.external').click(function(e) { e.preventDefault(); }); - var tabs = $("#tabnav"), - tab_a_selector = "a"; + var tabs = $("#tabnav"), + tab_a_selector = "a"; - var firstLoad = true; + var firstLoad = true; - tabs.find(tab_a_selector).click(function(e) { + tabs.find(tab_a_selector).click(function(e) { e.preventDefault(); - embedded_editor.resize(); - editor.resize(); if ($(this).attr("href") === "/") { window.location = "http://ace.ajax.org"; return; @@ -108,18 +141,47 @@ $(function() { $.bbq.pushState(state); }); - $(window).on("hashchange", function(e) { - _gaq.push(['_trackPageview',location.pathname + location.search + location.hash]); - tabs.each(function() { + $('#tabnav a[data-toggle="tab"]').on('shown', function (e) { + $(".tab-content .tab-pane.active .ace_editor").each(function(i, el){ + el.env.onResize(); + }); + }); + + $(window).on("hashchange", function(e) { + _gaq.push(['_trackPageview',location.pathname + location.search + location.hash]); + tabs.each(function() { var idx = $.bbq.getState("nav") || "about"; var section = e.fragment.split("&")[1] || ""; $(this).find(tab_a_selector + "[href='#" + idx + "']").triggerHandler('click'); - + // handles dropping in from new link var api = $.bbq.getState("api"); if (api) { $(tab_a_selector + "[href='./api/" + api + ".html']").triggerHandler('click'); } - }); - }).trigger("hashchange"); -}); \ No newline at end of file + }); + }).trigger("hashchange"); + + highlight(); +}); + + + +function highlight() { + var highlighter = ace.require("ace/ext/static_highlight") + var dom = ace.require("ace/lib/dom") + function qsa(sel) { + var els = document.querySelectorAll(sel); + var result = []; + for (var i = 0, l = els.length; i < l; i++) + result[i] = els[i]; + return result; + } + + qsa("code[class]").forEach(function(el) { + var m = el.className.match(/language-(\w+)|(javascript)/); + if (!m) return + var mode = "ace/mode/" + (m[1] || m[2]); + highlighter.highlight(el, {mode: mode, theme: "ace/theme/xcode"}) + }); +} \ No newline at end of file diff --git a/doc/site/style.css b/doc/site/style.css index 45e359b0..1167340a 100644 --- a/doc/site/style.css +++ b/doc/site/style.css @@ -489,4 +489,21 @@ img { margin-top: 23px; text-align: center; text-shadow: 1px 17px 2px gray, 1px 1px 2px gray; +} + +.menu-list>li>img { + position: relative; +} + +.rotating-logo { + -webkit-transform: rotate(0deg); + transform: rotate(0deg); + -webkit-transition: all 0.5s ease-out; + transition: all 0.5s ease-out; +} +.rotating-logo:hover { + -webkit-transform: rotate(360deg); + transform: rotate(360deg); + -webkit-transition: all 0.5s ease-in-out; + transition: all 0.5s ease-in-out; } \ No newline at end of file diff --git a/experiments/debug_mem_leak.html b/experiments/debug_mem_leak.html new file mode 100644 index 00000000..b8ee8726 --- /dev/null +++ b/experiments/debug_mem_leak.html @@ -0,0 +1,59 @@ + + + + + + + + +

+ +
+ + + \ No newline at end of file diff --git a/index.html b/index.html index 9576c2ad..e2440eb1 100644 --- a/index.html +++ b/index.html @@ -3,18 +3,21 @@ Ace - The High Performance Code Editor for the Web - - - + + - + + + - Fork me on GitHub + Fork me on GitHub
@@ -65,7 +68,7 @@ and is the successor of the Mozilla Skywriter (Bespin) project.

-
/** +
/**
  * In fact, you're looking at ACE right now. Go ahead and play with it!
  *
  * We are currently showing off the JavaScript mode. ACE has support for 45
@@ -80,14 +83,14 @@ function add(x, y) {
 
 var addResult = add(3, 2);
 console.log(addResult);
-                                
+

Looking for a more full-featured demo? Check out the - kitchen sink. + kitchen sink.

Features

    -
  • Syntax highlighting for over 60 languages (TextMate/Sublime Text.tmlanguage files can be imported)
  • +
  • Syntax highlighting for over 110 languages (TextMate/Sublime Text.tmlanguage files can be imported)
  • Over 20 themes (TextMate/Sublime Text .tmtheme files can be imported)
  • Automatic indent and outdent
  • An optional command line
  • @@ -140,7 +143,7 @@ console.log(addResult);

    Embedding Ace in Your Site

    Ace can be easily embedded into a web page. Get prebuilt version of ace from ace-builds repository and use the code below:

    -
    <!DOCTYPE html> +
    <!DOCTYPE html>
     <html lang="en">
     <head>
     <title>ACE in Action</title>
    @@ -168,21 +171,19 @@ console.log(addResult);
         editor.getSession().setMode("ace/mode/javascript");
     </script>
     </body>
    -</html>
    +</html>

    Now check out the How-To Guide for instructions on common operations, such as setting a different language mode or getting the contents from the editor.

    -

    Loading Ace from a Local URL

    -

    The above code is all you need to embed Ace in your site (including setting language modes - and themes). Plus it's super fast because it's on Amazon's distributed content network. -

    -

    But, if you want to clone host Ace locally you can +

    Loading Ace from a Local URL

    +

    If you want to clone and host Ace locally you can use one of the pre-packaged versions. Just copy one of src* subdirectories somewhere into your project, or use RequireJS to load the - contents of lib/ace as ace: + contents of lib/ace folder as ace: +

    +

    The packaged version can also be loaded from CDN's such as jsDelivr or cdnjs.

    -
    var ace = require("lib/ace");

Working with Ace

@@ -195,8 +196,7 @@ console.log(addResult);

> See all themes

Setting the Programming Language Mode

By default, the editor supports plain text mode. All other language modes are available as separate modules, loaded on demand like this:

-
editor.getSession().setMode("ace/mode/javascript");
-                            
+
editor.getSession().setMode("ace/mode/javascript");
  • + style="left: 0px; top: 17px; width: 100px" /> Repl.it
  • +
  • + + Stypi +
  • +
  • + + Weecod +
  • +
  • + + ProcessWire +
  • + style="left: 9px; top: -5px; width: 84px" /> Crunch
  • + style="left: 9px; top: -5px; width: 84px"> Drive Notepad
  • +
  • + + Textor +
  • - PHP Assist + style="left: 3px; top: -10px; width: 95px"> + PHP Assist
  • @@ -890,8 +887,10 @@ oop.inherits(FoldMode, BaseFoldMode); Evaluzio
  • - +
    CodeHelper
  • @@ -900,7 +899,7 @@ oop.inherits(FoldMode, BaseFoldMode);
  • + style="width: 108px; top: 20px; left: -3px;"> pixelJET
  • @@ -908,9 +907,9 @@ oop.inherits(FoldMode, BaseFoldMode); BonsaiJS playground
  • - - Acebug + + Simply Text
  • @@ -918,12 +917,12 @@ oop.inherits(FoldMode, BaseFoldMode);
  • + style="left: -6px; width: 113px;top: -37px;"> Code Complete
  • + style="left: 2px; width: 96px;top: -8px;"> ACEView
  • @@ -932,7 +931,7 @@ oop.inherits(FoldMode, BaseFoldMode);
  • + style="left: -9px; width: 117px;top: -22px;"> Codebender
  • @@ -940,25 +939,20 @@ oop.inherits(FoldMode, BaseFoldMode); Debuggex
  • - +
    S
    Slim Text
  • - + style="left: -5px; width: 111px;top: 20px;"> Decor
  • - - Divshot -
  • -
  • - - Codio + + Papeeria
  • - - + + diff --git a/kitchen-sink.html b/kitchen-sink.html index bb534835..a8e1fb7b 100644 --- a/kitchen-sink.html +++ b/kitchen-sink.html @@ -11,23 +11,17 @@ commit %commit% --> - - - - + + -
    - - + + -
    +
    @@ -63,40 +57,7 @@ @@ -188,6 +149,8 @@ @@ -274,6 +237,14 @@ + + + +
    + +
    + + + +
    @@ -282,7 +253,13 @@
    - + + + + +
    @@ -306,7 +283,7 @@ - + diff --git a/lib/ace/ace.js b/lib/ace/ace.js index 34859be4..6c8a6126 100644 --- a/lib/ace/ace.js +++ b/lib/ace/ace.js @@ -46,14 +46,15 @@ var Editor = require("./editor").Editor; var EditSession = require("./edit_session").EditSession; var UndoManager = require("./undomanager").UndoManager; var Renderer = require("./virtual_renderer").VirtualRenderer; -var MultiSelect = require("./multi_select").MultiSelect; // The following require()s are for inclusion in the built ace file require("./worker/worker_client"); require("./keyboard/hash_handler"); require("./placeholder"); +require("./multi_select"); require("./mode/folding/fold_mode"); require("./theme/textmate"); +require("./ext/error_marker"); exports.config = require("./config"); @@ -73,19 +74,28 @@ exports.require = require; exports.edit = function(el) { if (typeof(el) == "string") { var _id = el; - var el = document.getElementById(_id); + el = document.getElementById(_id); if (!el) - throw "ace.edit can't find div #" + _id; + throw new Error("ace.edit can't find div #" + _id); } - if (el.env && el.env.editor instanceof Editor) + if (el && el.env && el.env.editor instanceof Editor) return el.env.editor; - var doc = exports.createEditSession(dom.getInnerText(el)); - el.innerHTML = ''; + var value = ""; + if (el && /input|textarea/i.test(el.tagName)) { + var oldNode = el; + value = oldNode.value; + el = dom.createElement("pre"); + oldNode.parentNode.replaceChild(el, oldNode); + } else { + value = dom.getInnerText(el); + el.innerHTML = ''; + } + + var doc = exports.createEditSession(value); var editor = new Editor(new Renderer(el)); - new MultiSelect(editor); editor.setSession(doc); var env = { @@ -93,11 +103,13 @@ exports.edit = function(el) { editor: editor, onResize: editor.resize.bind(editor, null) }; + if (oldNode) env.textarea = oldNode; event.addListener(window, "resize", env.onResize); editor.on("destroy", function() { event.removeListener(window, "resize", env.onResize); + env.editor.container.env = null; // prevent memory leak on old ie }); - el.env = editor.env = env; + editor.container.env = editor.env = env; return editor; }; diff --git a/lib/ace/anchor.js b/lib/ace/anchor.js index d2ffd090..39b78e0f 100644 --- a/lib/ace/anchor.js +++ b/lib/ace/anchor.js @@ -36,7 +36,7 @@ var EventEmitter = require("./lib/event_emitter").EventEmitter; /** * - * Defines the floating pointer in the document. Whenever text is inserted or deleted before the cursor, the position of the cursor is updated. + * Defines a floating pointer in the document. Whenever text is inserted or deleted before the cursor, the position of the anchor is updated. * * @class Anchor **/ @@ -52,15 +52,13 @@ var EventEmitter = require("./lib/event_emitter").EventEmitter; **/ var Anchor = exports.Anchor = function(doc, row, column) { - this.document = doc; - + this.$onChange = this.onChange.bind(this); + this.attach(doc); + if (typeof column == "undefined") this.setPosition(row.row, row.column); else this.setPosition(row, column); - - this.$onChange = this.onChange.bind(this); - doc.on("change", this.$onChange); }; (function() { @@ -71,7 +69,6 @@ var Anchor = exports.Anchor = function(doc, row, column) { * Returns an object identifying the `row` and `column` position of the current anchor. * @returns {Object} **/ - this.getPosition = function() { return this.$clipPositionToDocument(this.row, this.column); }; @@ -81,11 +78,14 @@ var Anchor = exports.Anchor = function(doc, row, column) { * Returns the current document. * @returns {Document} **/ - this.getDocument = function() { return this.document; }; + /** + * experimental: allows anchor to stick to the next on the left + */ + this.$insertRight = false; /** * Fires whenever the anchor position changes. * @@ -98,70 +98,55 @@ var Anchor = exports.Anchor = function(doc, row, column) { * - `old`: An object describing the old Anchor position * - `value`: An object describing the new Anchor position * - * **/ - - this.onChange = function(e) { - var delta = e.data; - var range = delta.range; - - if (range.start.row == range.end.row && range.start.row != this.row) + this.onChange = function(delta) { + if (delta.start.row == delta.end.row && delta.start.row != this.row) return; - if (range.start.row > this.row) + if (delta.start.row > this.row) return; - - if (range.start.row == this.row && range.start.column > this.column) - return; - - var row = this.row; - var column = this.column; - var start = range.start; - var end = range.end; - - if (delta.action === "insertText") { - if (start.row === row && start.column <= column) { - if (start.row === end.row) { - column += end.column - start.column; - } else { - column -= start.column; - row += end.row - start.row; - } - } else if (start.row !== end.row && start.row < row) { - row += end.row - start.row; - } - } else if (delta.action === "insertLines") { - if (start.row <= row) { - row += end.row - start.row; - } - } else if (delta.action === "removeText") { - if (start.row === row && start.column < column) { - if (end.column >= column) - column = start.column; - else - column = Math.max(0, column - (end.column - start.column)); - - } else if (start.row !== end.row && start.row < row) { - if (end.row === row) - column = Math.max(0, column - end.column) + start.column; - row -= (end.row - start.row); - } else if (end.row === row) { - row -= end.row - start.row; - column = Math.max(0, column - end.column) + start.column; - } - } else if (delta.action == "removeLines") { - if (start.row <= row) { - if (end.row <= row) - row -= end.row - start.row; - else { - row = start.row; - column = 0; - } - } - } - - this.setPosition(row, column, true); + + var point = $getTransformedPoint(delta, {row: this.row, column: this.column}, this.$insertRight); + this.setPosition(point.row, point.column, true); }; + + function $pointsInOrder(point1, point2, equalPointsInOrder) { + var bColIsAfter = equalPointsInOrder ? point1.column <= point2.column : point1.column < point2.column; + return (point1.row < point2.row) || (point1.row == point2.row && bColIsAfter); + } + + function $getTransformedPoint(delta, point, moveIfEqual) { + // Get delta info. + var deltaIsInsert = delta.action == "insert"; + var deltaRowShift = (deltaIsInsert ? 1 : -1) * (delta.end.row - delta.start.row); + var deltaColShift = (deltaIsInsert ? 1 : -1) * (delta.end.column - delta.start.column); + var deltaStart = delta.start; + var deltaEnd = deltaIsInsert ? deltaStart : delta.end; // Collapse insert range. + + // DELTA AFTER POINT: No change needed. + if ($pointsInOrder(point, deltaStart, moveIfEqual)) { + return { + row: point.row, + column: point.column + }; + } + + // DELTA BEFORE POINT: Move point by delta shift. + if ($pointsInOrder(deltaEnd, point, !moveIfEqual)) { + return { + row: point.row + deltaRowShift, + column: point.column + (point.row == deltaEnd.row ? deltaColShift : 0) + }; + } + + // DELTA ENVELOPS POINT (delete only): Move point to delta start. + // TODO warn if delta.action != "remove" ? + + return { + row: deltaStart.row, + column: deltaStart.column + }; + } /** * Sets the anchor position to the specified row and column. If `noClip` is `true`, the position is not clipped. @@ -169,10 +154,7 @@ var Anchor = exports.Anchor = function(doc, row, column) { * @param {Number} column The column index to move the anchor to * @param {Boolean} noClip Identifies if you want the position to be clipped * - * - * **/ - this.setPosition = function(row, column, noClip) { var pos; if (noClip) { @@ -194,20 +176,23 @@ var Anchor = exports.Anchor = function(doc, row, column) { this.row = pos.row; this.column = pos.column; - this._emit("change", { + this._signal("change", { old: old, value: pos }); }; /** - * When called, the `'change'` event listener is removed. + * When called, the `"change"` event listener is removed. * **/ - this.detach = function() { this.document.removeEventListener("change", this.$onChange); }; + this.attach = function(doc) { + this.document = doc || this.document; + this.document.on("change", this.$onChange); + }; /** * Clips the anchor position to the specified row and column. diff --git a/lib/ace/anchor_test.js b/lib/ace/anchor_test.js index 2d7fcb63..c0b97273 100644 --- a/lib/ace/anchor_test.js +++ b/lib/ace/anchor_test.js @@ -57,20 +57,55 @@ module.exports = { doc.insert({row: 1, column: 1}, "123"); assert.position(anchor.getPosition(), 1, 7); }, + + "test insert text at anchor should not move anchor when insertRight is true": function() { + var doc = new Document("juhu\nkinners"); + var anchor = new Anchor(doc, 1, 4); + anchor.$insertRight = true; + + doc.insert({row: 1, column: 4}, "123"); + assert.position(anchor.getPosition(), 1, 4); + }, "test insert lines before cursor should move anchor row": function() { var doc = new Document("juhu\nkinners"); var anchor = new Anchor(doc, 1, 4); - doc.insertLines(1, ["123", "456"]); + doc.insertFullLines(1, ["123", "456"]); assert.position(anchor.getPosition(), 3, 4); }, + + "test insert lines at anchor position should move anchor down": function() { + var doc = new Document("juhu\nkinners"); + var anchor = new Anchor(doc, 1, 0); + + doc.insertLines(1, ["line"]); + assert.position(anchor.getPosition(), 2, 0); + }, + + "test insert lines at anchor position should not move anchor down when insertRight is true and column is 0": function() { + var doc = new Document("juhu\nkinners"); + var anchor = new Anchor(doc, 1, 0); + anchor.$insertRight = true; + + doc.insertLines(1, ["line"]); + assert.position(anchor.getPosition(), 1, 0); + }, + + "test insert lines at anchor row should move anchor down when column > 0": function() { + var doc = new Document("juhu\nkinners"); + var anchor = new Anchor(doc, 1, 2); + anchor.$insertRight = true; + + doc.insertLines(1, ["line"]); + assert.position(anchor.getPosition(), 2, 2); + }, "test insert new line before cursor should move anchor column": function() { var doc = new Document("juhu\nkinners"); var anchor = new Anchor(doc, 1, 4); - doc.insertNewLine({row: 0, column: 0}); + doc.insertMergedLines({row: 0, column: 0}, ['', '']); assert.position(anchor.getPosition(), 2, 4); }, @@ -78,7 +113,7 @@ module.exports = { var doc = new Document("juhu\nkinners"); var anchor = new Anchor(doc, 1, 4); - doc.insertNewLine({row: 1, column: 2}); + doc.insertMergedLines({row: 1, column: 2}, ['', '']); assert.position(anchor.getPosition(), 2, 2); }, @@ -110,7 +145,7 @@ module.exports = { var doc = new Document("juhu\n1\n2\nkinners"); var anchor = new Anchor(doc, 3, 4); - doc.removeLines(1, 2); + doc.removeFullLines(1, 2); assert.position(anchor.getPosition(), 1, 4); }, @@ -134,7 +169,7 @@ module.exports = { var doc = new Document("juhu\nkinners\n123"); var anchor = new Anchor(doc, 1, 5); - doc.removeLines(1, 1); + doc.removeFullLines(1, 1); assert.position(anchor.getPosition(), 1, 0); }, @@ -173,9 +208,9 @@ module.exports = { var doc = new Document("juhu\nkinners\n123"); var anchor = new Anchor(doc, 2, 4); - doc.removeLines(0, 3); + doc.removeFullLines(0, 3); assert.position(anchor.getPosition(), 0, 0); - doc.insertLines(0, ["a", "b", "c"]); + doc.insertFullLines(0, ["a", "b", "c"]); assert.position(anchor.getPosition(), 3, 0); assert.equal(doc.getValue(), "a\nb\nc\n"); } diff --git a/lib/ace/apply_delta.js b/lib/ace/apply_delta.js new file mode 100644 index 00000000..98bfe148 --- /dev/null +++ b/lib/ace/apply_delta.js @@ -0,0 +1,108 @@ +/* ***** 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. + * + * ***** END LICENSE BLOCK ***** */ + +define(function(require, exports, module) { +"use strict"; + +function throwDeltaError(delta, errorText){ + console.log("Invalid Delta:", delta); + throw "Invalid Delta: " + errorText; +} + +function positionInDocument(docLines, position) { + return position.row >= 0 && position.row < docLines.length && + position.column >= 0 && position.column <= docLines[position.row].length; +} + +function validateDelta(docLines, delta) { + // Validate action string. + if (delta.action != "insert" && delta.action != "remove") + throwDeltaError(delta, "delta.action must be 'insert' or 'remove'"); + + // Validate lines type. + if (!(delta.lines instanceof Array)) + throwDeltaError(delta, "delta.lines must be an Array"); + + // Validate range type. + if (!delta.start || !delta.end) + throwDeltaError(delta, "delta.start/end must be an present"); + + // Validate that the start point is contained in the document. + var start = delta.start; + if (!positionInDocument(docLines, delta.start)) + throwDeltaError(delta, "delta.start must be contained in document"); + + // Validate that the end point is contained in the document (remove deltas only). + var end = delta.end; + if (delta.action == "remove" && !positionInDocument(docLines, end)) + throwDeltaError(delta, "delta.end must contained in document for 'remove' actions"); + + // Validate that the .range size matches the .lines size. + var numRangeRows = end.row - start.row; + var numRangeLastLineChars = (end.column - (numRangeRows == 0 ? start.column : 0)); + if (numRangeRows != delta.lines.length - 1 || delta.lines[numRangeRows].length != numRangeLastLineChars) + throwDeltaError(delta, "delta.range must match delta lines"); +} + +exports.applyDelta = function(docLines, delta, doNotValidate) { + // disabled validation since it breaks autocompletion popup + // if (!doNotValidate) + // validateDelta(docLines, delta); + + var row = delta.start.row; + var startColumn = delta.start.column; + var line = docLines[row] || ""; + switch (delta.action) { + case "insert": + var lines = delta.lines; + if (lines.length === 1) { + docLines[row] = line.substring(0, startColumn) + delta.lines[0] + line.substring(startColumn); + } else { + var args = [row, 1].concat(delta.lines); + docLines.splice.apply(docLines, args); + docLines[row] = line.substring(0, startColumn) + docLines[row]; + docLines[row + delta.lines.length - 1] += line.substring(startColumn); + } + break; + case "remove": + var endColumn = delta.end.column; + var endRow = delta.end.row; + if (row === endRow) { + docLines[row] = line.substring(0, startColumn) + line.substring(endColumn); + } else { + docLines.splice( + row, endRow - row + 1, + line.substring(0, startColumn) + docLines[endRow].substring(endColumn) + ); + } + break; + } +} +}); diff --git a/lib/ace/autocomplete.js b/lib/ace/autocomplete.js new file mode 100644 index 00000000..8e121f35 --- /dev/null +++ b/lib/ace/autocomplete.js @@ -0,0 +1,497 @@ +/* ***** 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. + * + * ***** END LICENSE BLOCK ***** */ + +define(function(require, exports, module) { +"use strict"; + +var HashHandler = require("./keyboard/hash_handler").HashHandler; +var AcePopup = require("./autocomplete/popup").AcePopup; +var util = require("./autocomplete/util"); +var event = require("./lib/event"); +var lang = require("./lib/lang"); +var dom = require("./lib/dom"); +var snippetManager = require("./snippets").snippetManager; + +var Autocomplete = function() { + this.autoInsert = false; + this.autoSelect = true; + this.exactMatch = false; + this.gatherCompletionsId = 0; + this.keyboardHandler = new HashHandler(); + this.keyboardHandler.bindKeys(this.commands); + + this.blurListener = this.blurListener.bind(this); + this.changeListener = this.changeListener.bind(this); + this.mousedownListener = this.mousedownListener.bind(this); + this.mousewheelListener = this.mousewheelListener.bind(this); + + this.changeTimer = lang.delayedCall(function() { + this.updateCompletions(true); + }.bind(this)); + + this.tooltipTimer = lang.delayedCall(this.updateDocTooltip.bind(this), 50); +}; + +(function() { + + this.$init = function() { + this.popup = new AcePopup(document.body || document.documentElement); + this.popup.on("click", function(e) { + this.insertMatch(); + e.stop(); + }.bind(this)); + this.popup.focus = this.editor.focus.bind(this.editor); + this.popup.on("show", this.tooltipTimer.bind(null, null)); + this.popup.on("select", this.tooltipTimer.bind(null, null)); + this.popup.on("changeHoverMarker", this.tooltipTimer.bind(null, null)); + return this.popup; + }; + + this.getPopup = function() { + return this.popup || this.$init(); + }; + + this.openPopup = function(editor, prefix, keepPopupPosition) { + if (!this.popup) + this.$init(); + + this.popup.setData(this.completions.filtered); + + editor.keyBinding.addKeyboardHandler(this.keyboardHandler); + + var renderer = editor.renderer; + this.popup.setRow(this.autoSelect ? 0 : -1); + if (!keepPopupPosition) { + this.popup.setTheme(editor.getTheme()); + this.popup.setFontSize(editor.getFontSize()); + + var lineHeight = renderer.layerConfig.lineHeight; + + var pos = renderer.$cursorLayer.getPixelPosition(this.base, true); + pos.left -= this.popup.getTextLeftOffset(); + + var rect = editor.container.getBoundingClientRect(); + pos.top += rect.top - renderer.layerConfig.offset; + pos.left += rect.left - editor.renderer.scrollLeft; + pos.left += renderer.gutterWidth; + + this.popup.show(pos, lineHeight); + } else if (keepPopupPosition && !prefix) { + this.detach(); + } + }; + + this.detach = function() { + this.editor.keyBinding.removeKeyboardHandler(this.keyboardHandler); + this.editor.off("changeSelection", this.changeListener); + this.editor.off("blur", this.blurListener); + this.editor.off("mousedown", this.mousedownListener); + this.editor.off("mousewheel", this.mousewheelListener); + this.changeTimer.cancel(); + this.hideDocTooltip(); + + this.gatherCompletionsId += 1; + if (this.popup && this.popup.isOpen) + this.popup.hide(); + + if (this.base) + this.base.detach(); + this.activated = false; + this.completions = this.base = null; + }; + + this.changeListener = function(e) { + var cursor = this.editor.selection.lead; + if (cursor.row != this.base.row || cursor.column < this.base.column) { + this.detach(); + } + if (this.activated) + this.changeTimer.schedule(); + else + this.detach(); + }; + + this.blurListener = function(e) { + // we have to check if activeElement is a child of popup because + // on IE preventDefault doesn't stop scrollbar from being focussed + var el = document.activeElement; + var text = this.editor.textInput.getElement(); + var fromTooltip = e.relatedTarget && e.relatedTarget == this.tooltipNode; + var container = this.popup && this.popup.container; + if (el != text && el.parentNode != container && !fromTooltip + && el != this.tooltipNode && e.relatedTarget != text + ) { + this.detach(); + } + }; + + this.mousedownListener = function(e) { + this.detach(); + }; + + this.mousewheelListener = function(e) { + this.detach(); + }; + + this.goTo = function(where) { + var row = this.popup.getRow(); + var max = this.popup.session.getLength() - 1; + + switch(where) { + case "up": row = row <= 0 ? max : row - 1; break; + case "down": row = row >= max ? -1 : row + 1; break; + case "start": row = 0; break; + case "end": row = max; break; + } + + this.popup.setRow(row); + }; + + this.insertMatch = function(data) { + if (!data) + data = this.popup.getData(this.popup.getRow()); + if (!data) + return false; + + if (data.completer && data.completer.insertMatch) { + data.completer.insertMatch(this.editor, data); + } else { + if (this.completions.filterText) { + var ranges = this.editor.selection.getAllRanges(); + for (var i = 0, range; range = ranges[i]; i++) { + range.start.column -= this.completions.filterText.length; + this.editor.session.remove(range); + } + } + if (data.snippet) + snippetManager.insertSnippet(this.editor, data.snippet); + else + this.editor.execCommand("insertstring", data.value || data); + } + this.detach(); + }; + + + this.commands = { + "Up": function(editor) { editor.completer.goTo("up"); }, + "Down": function(editor) { editor.completer.goTo("down"); }, + "Ctrl-Up|Ctrl-Home": function(editor) { editor.completer.goTo("start"); }, + "Ctrl-Down|Ctrl-End": function(editor) { editor.completer.goTo("end"); }, + + "Esc": function(editor) { editor.completer.detach(); }, + "Return": function(editor) { return editor.completer.insertMatch(); }, + "Shift-Return": function(editor) { editor.completer.insertMatch(true); }, + "Tab": function(editor) { + var result = editor.completer.insertMatch(); + if (!result && !editor.tabstopManager) + editor.completer.goTo("down"); + else + return result; + }, + + "PageUp": function(editor) { editor.completer.popup.gotoPageUp(); }, + "PageDown": function(editor) { editor.completer.popup.gotoPageDown(); } + }; + + this.gatherCompletions = function(editor, callback) { + var session = editor.getSession(); + var pos = editor.getCursorPosition(); + + var line = session.getLine(pos.row); + var prefix = util.retrievePrecedingIdentifier(line, pos.column); + + this.base = session.doc.createAnchor(pos.row, pos.column - prefix.length); + this.base.$insertRight = true; + + var matches = []; + var total = editor.completers.length; + editor.completers.forEach(function(completer, i) { + completer.getCompletions(editor, session, pos, prefix, function(err, results) { + if (!err) + matches = matches.concat(results); + // Fetch prefix again, because they may have changed by now + var pos = editor.getCursorPosition(); + var line = session.getLine(pos.row); + callback(null, { + prefix: util.retrievePrecedingIdentifier(line, pos.column, results[0] && results[0].identifierRegex), + matches: matches, + finished: (--total === 0) + }); + }); + }); + return true; + }; + + this.showPopup = function(editor) { + if (this.editor) + this.detach(); + + this.activated = true; + + this.editor = editor; + if (editor.completer != this) { + if (editor.completer) + editor.completer.detach(); + editor.completer = this; + } + + editor.on("changeSelection", this.changeListener); + editor.on("blur", this.blurListener); + editor.on("mousedown", this.mousedownListener); + editor.on("mousewheel", this.mousewheelListener); + + this.updateCompletions(); + }; + + this.updateCompletions = function(keepPopupPosition) { + if (keepPopupPosition && this.base && this.completions) { + var pos = this.editor.getCursorPosition(); + var prefix = this.editor.session.getTextRange({start: this.base, end: pos}); + if (prefix == this.completions.filterText) + return; + this.completions.setFilter(prefix); + if (!this.completions.filtered.length) + return this.detach(); + if (this.completions.filtered.length == 1 + && this.completions.filtered[0].value == prefix + && !this.completions.filtered[0].snippet) + return this.detach(); + this.openPopup(this.editor, prefix, keepPopupPosition); + return; + } + + // Save current gatherCompletions session, session is close when a match is insert + var _id = this.gatherCompletionsId; + this.gatherCompletions(this.editor, function(err, results) { + // Only detach if result gathering is finished + var detachIfFinished = function() { + if (!results.finished) return; + return this.detach(); + }.bind(this); + + var prefix = results.prefix; + var matches = results && results.matches; + + if (!matches || !matches.length) + return detachIfFinished(); + + // Wrong prefix or wrong session -> ignore + if (prefix.indexOf(results.prefix) !== 0 || _id != this.gatherCompletionsId) + return; + + this.completions = new FilteredList(matches); + + if (this.exactMatch) + this.completions.exactMatch = true; + + this.completions.setFilter(prefix); + var filtered = this.completions.filtered; + + // No results + if (!filtered.length) + return detachIfFinished(); + + // One result equals to the prefix + if (filtered.length == 1 && filtered[0].value == prefix && !filtered[0].snippet) + return detachIfFinished(); + + // Autoinsert if one result + if (this.autoInsert && filtered.length == 1 && results.finished) + return this.insertMatch(filtered[0]); + + this.openPopup(this.editor, prefix, keepPopupPosition); + }.bind(this)); + }; + + this.cancelContextMenu = function() { + this.editor.$mouseHandler.cancelContextMenu(); + }; + + this.updateDocTooltip = function() { + var popup = this.popup; + var all = popup.data; + var selected = all && (all[popup.getHoveredRow()] || all[popup.getRow()]); + var doc = null; + if (!selected || !this.editor || !this.popup.isOpen) + return this.hideDocTooltip(); + this.editor.completers.some(function(completer) { + if (completer.getDocTooltip) + doc = completer.getDocTooltip(selected); + return doc; + }); + if (!doc) + doc = selected; + + if (typeof doc == "string") + doc = {docText: doc}; + if (!doc || !(doc.docHTML || doc.docText)) + return this.hideDocTooltip(); + this.showDocTooltip(doc); + }; + + this.showDocTooltip = function(item) { + if (!this.tooltipNode) { + this.tooltipNode = dom.createElement("div"); + this.tooltipNode.className = "ace_tooltip ace_doc-tooltip"; + this.tooltipNode.style.margin = 0; + this.tooltipNode.style.pointerEvents = "auto"; + this.tooltipNode.tabIndex = -1; + this.tooltipNode.onblur = this.blurListener.bind(this); + } + + var tooltipNode = this.tooltipNode; + if (item.docHTML) { + tooltipNode.innerHTML = item.docHTML; + } else if (item.docText) { + tooltipNode.textContent = item.docText; + } + + if (!tooltipNode.parentNode) + document.body.appendChild(tooltipNode); + var popup = this.popup; + var rect = popup.container.getBoundingClientRect(); + tooltipNode.style.top = popup.container.style.top; + tooltipNode.style.bottom = popup.container.style.bottom; + + if (window.innerWidth - rect.right < 320) { + tooltipNode.style.right = window.innerWidth - rect.left + "px"; + tooltipNode.style.left = ""; + } else { + tooltipNode.style.left = (rect.right + 1) + "px"; + tooltipNode.style.right = ""; + } + tooltipNode.style.display = "block"; + }; + + this.hideDocTooltip = function() { + this.tooltipTimer.cancel(); + if (!this.tooltipNode) return; + var el = this.tooltipNode; + if (!this.editor.isFocused() && document.activeElement == el) + this.editor.focus(); + this.tooltipNode = null; + if (el.parentNode) + el.parentNode.removeChild(el); + }; + +}).call(Autocomplete.prototype); + +Autocomplete.startCommand = { + name: "startAutocomplete", + exec: function(editor) { + if (!editor.completer) + editor.completer = new Autocomplete(); + editor.completer.autoInsert = false; + editor.completer.autoSelect = true; + editor.completer.showPopup(editor); + // prevent ctrl-space opening context menu on firefox on mac + editor.completer.cancelContextMenu(); + }, + bindKey: "Ctrl-Space|Ctrl-Shift-Space|Alt-Space" +}; + +var FilteredList = function(array, filterText) { + this.all = array; + this.filtered = array; + this.filterText = filterText || ""; + this.exactMatch = false; +}; +(function(){ + this.setFilter = function(str) { + if (str.length > this.filterText && str.lastIndexOf(this.filterText, 0) === 0) + var matches = this.filtered; + else + var matches = this.all; + + this.filterText = str; + matches = this.filterCompletions(matches, this.filterText); + matches = matches.sort(function(a, b) { + return b.exactMatch - a.exactMatch || b.score - a.score; + }); + + // make unique + var prev = null; + matches = matches.filter(function(item){ + var caption = item.snippet || item.caption || item.value; + if (caption === prev) return false; + prev = caption; + return true; + }); + + this.filtered = matches; + }; + this.filterCompletions = function(items, needle) { + var results = []; + var upper = needle.toUpperCase(); + var lower = needle.toLowerCase(); + loop: for (var i = 0, item; item = items[i]; i++) { + var caption = item.value || item.caption || item.snippet; + if (!caption) continue; + var lastIndex = -1; + var matchMask = 0; + var penalty = 0; + var index, distance; + + if (this.exactMatch) { + if (needle !== caption.substr(0, needle.length)) + continue loop; + }else{ + // caption char iteration is faster in Chrome but slower in Firefox, so lets use indexOf + for (var j = 0; j < needle.length; j++) { + // TODO add penalty on case mismatch + var i1 = caption.indexOf(lower[j], lastIndex + 1); + var i2 = caption.indexOf(upper[j], lastIndex + 1); + index = (i1 >= 0) ? ((i2 < 0 || i1 < i2) ? i1 : i2) : i2; + if (index < 0) + continue loop; + distance = index - lastIndex - 1; + if (distance > 0) { + // first char mismatch should be more sensitive + if (lastIndex === -1) + penalty += 10; + penalty += distance; + } + matchMask = matchMask | (1 << index); + lastIndex = index; + } + } + item.matchMask = matchMask; + item.exactMatch = penalty ? 0 : 1; + item.score = (item.score || 0) - penalty; + results.push(item); + } + return results; + }; +}).call(FilteredList.prototype); + +exports.Autocomplete = Autocomplete; +exports.FilteredList = FilteredList; + +}); diff --git a/lib/ace/autocomplete/popup.js b/lib/ace/autocomplete/popup.js new file mode 100644 index 00000000..6c480b38 --- /dev/null +++ b/lib/ace/autocomplete/popup.js @@ -0,0 +1,344 @@ +/* ***** 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. + * + * ***** END LICENSE BLOCK ***** */ + +define(function(require, exports, module) { +"use strict"; + +var Renderer = require("../virtual_renderer").VirtualRenderer; +var Editor = require("../editor").Editor; +var Range = require("../range").Range; +var event = require("../lib/event"); +var lang = require("../lib/lang"); +var dom = require("../lib/dom"); + +var $singleLineEditor = function(el) { + var renderer = new Renderer(el); + + renderer.$maxLines = 4; + + var editor = new Editor(renderer); + + editor.setHighlightActiveLine(false); + editor.setShowPrintMargin(false); + editor.renderer.setShowGutter(false); + editor.renderer.setHighlightGutterLine(false); + + editor.$mouseHandler.$focusWaitTimout = 0; + editor.$highlightTagPending = true; + + return editor; +}; + +var AcePopup = function(parentNode) { + var el = dom.createElement("div"); + var popup = new $singleLineEditor(el); + + if (parentNode) + parentNode.appendChild(el); + el.style.display = "none"; + popup.renderer.content.style.cursor = "default"; + popup.renderer.setStyle("ace_autocomplete"); + + popup.setOption("displayIndentGuides", false); + popup.setOption("dragDelay", 150); + + var noop = function(){}; + + popup.focus = noop; + popup.$isFocused = true; + + popup.renderer.$cursorLayer.restartTimer = noop; + popup.renderer.$cursorLayer.element.style.opacity = 0; + + popup.renderer.$maxLines = 8; + popup.renderer.$keepTextAreaAtCursor = false; + + popup.setHighlightActiveLine(false); + // set default highlight color + popup.session.highlight(""); + popup.session.$searchHighlight.clazz = "ace_highlight-marker"; + + popup.on("mousedown", function(e) { + var pos = e.getDocumentPosition(); + popup.selection.moveToPosition(pos); + selectionMarker.start.row = selectionMarker.end.row = pos.row; + e.stop(); + }); + + var lastMouseEvent; + var hoverMarker = new Range(-1,0,-1,Infinity); + var selectionMarker = new Range(-1,0,-1,Infinity); + selectionMarker.id = popup.session.addMarker(selectionMarker, "ace_active-line", "fullLine"); + popup.setSelectOnHover = function(val) { + if (!val) { + hoverMarker.id = popup.session.addMarker(hoverMarker, "ace_line-hover", "fullLine"); + } else if (hoverMarker.id) { + popup.session.removeMarker(hoverMarker.id); + hoverMarker.id = null; + } + }; + popup.setSelectOnHover(false); + popup.on("mousemove", function(e) { + if (!lastMouseEvent) { + lastMouseEvent = e; + return; + } + if (lastMouseEvent.x == e.x && lastMouseEvent.y == e.y) { + return; + } + lastMouseEvent = e; + lastMouseEvent.scrollTop = popup.renderer.scrollTop; + var row = lastMouseEvent.getDocumentPosition().row; + if (hoverMarker.start.row != row) { + if (!hoverMarker.id) + popup.setRow(row); + setHoverMarker(row); + } + }); + popup.renderer.on("beforeRender", function() { + if (lastMouseEvent && hoverMarker.start.row != -1) { + lastMouseEvent.$pos = null; + var row = lastMouseEvent.getDocumentPosition().row; + if (!hoverMarker.id) + popup.setRow(row); + setHoverMarker(row, true); + } + }); + popup.renderer.on("afterRender", function() { + var row = popup.getRow(); + var t = popup.renderer.$textLayer; + var selected = t.element.childNodes[row - t.config.firstRow]; + if (selected == t.selectedNode) + return; + if (t.selectedNode) + dom.removeCssClass(t.selectedNode, "ace_selected"); + t.selectedNode = selected; + if (selected) + dom.addCssClass(selected, "ace_selected"); + }); + var hideHoverMarker = function() { setHoverMarker(-1) }; + var setHoverMarker = function(row, suppressRedraw) { + if (row !== hoverMarker.start.row) { + hoverMarker.start.row = hoverMarker.end.row = row; + if (!suppressRedraw) + popup.session._emit("changeBackMarker"); + popup._emit("changeHoverMarker"); + } + }; + popup.getHoveredRow = function() { + return hoverMarker.start.row; + }; + + event.addListener(popup.container, "mouseout", hideHoverMarker); + popup.on("hide", hideHoverMarker); + popup.on("changeSelection", hideHoverMarker); + + popup.session.doc.getLength = function() { + return popup.data.length; + }; + popup.session.doc.getLine = function(i) { + var data = popup.data[i]; + if (typeof data == "string") + return data; + return (data && data.value) || ""; + }; + + var bgTokenizer = popup.session.bgTokenizer; + bgTokenizer.$tokenizeRow = function(row) { + var data = popup.data[row]; + var tokens = []; + if (!data) + return tokens; + if (typeof data == "string") + data = {value: data}; + if (!data.caption) + data.caption = data.value || data.name; + + var last = -1; + var flag, c; + for (var i = 0; i < data.caption.length; i++) { + c = data.caption[i]; + flag = data.matchMask & (1 << i) ? 1 : 0; + if (last !== flag) { + tokens.push({type: data.className || "" + ( flag ? "completion-highlight" : ""), value: c}); + last = flag; + } else { + tokens[tokens.length - 1].value += c; + } + } + + if (data.meta) { + var maxW = popup.renderer.$size.scrollerWidth / popup.renderer.layerConfig.characterWidth; + var metaData = data.meta; + if (metaData.length + data.caption.length > maxW - 2) { + // trim meta to fit this popup and add ellipsis + metaData = metaData.substr(0, maxW - data.caption.length - 3) + "\u2026" + } + tokens.push({type: "rightAlignedText", value: metaData}); + } + return tokens; + }; + bgTokenizer.$updateOnChange = noop; + bgTokenizer.start = noop; + + popup.session.$computeWidth = function() { + return this.screenWidth = 0; + }; + + popup.$blockScrolling = Infinity; + + // public + popup.isOpen = false; + popup.isTopdown = false; + + popup.data = []; + popup.setData = function(list) { + popup.setValue(lang.stringRepeat("\n", list.length), -1); + popup.data = list || []; + popup.setRow(0); + }; + popup.getData = function(row) { + return popup.data[row]; + }; + + popup.getRow = function() { + return selectionMarker.start.row; + }; + popup.setRow = function(line) { + line = Math.max(-1, Math.min(this.data.length, line)); + if (selectionMarker.start.row != line) { + popup.selection.clearSelection(); + selectionMarker.start.row = selectionMarker.end.row = line || 0; + popup.session._emit("changeBackMarker"); + popup.moveCursorTo(line || 0, 0); + if (popup.isOpen) + popup._signal("select"); + } + }; + + popup.on("changeSelection", function() { + if (popup.isOpen) + popup.setRow(popup.selection.lead.row); + popup.renderer.scrollCursorIntoView(); + }); + + popup.hide = function() { + this.container.style.display = "none"; + this._signal("hide"); + popup.isOpen = false; + }; + popup.show = function(pos, lineHeight, topdownOnly) { + var el = this.container; + var screenHeight = window.innerHeight; + var screenWidth = window.innerWidth; + var renderer = this.renderer; + // var maxLines = Math.min(renderer.$maxLines, this.session.getLength()); + var maxH = renderer.$maxLines * lineHeight * 1.4; + var top = pos.top + this.$borderSize; + if (top + maxH > screenHeight - lineHeight && !topdownOnly) { + el.style.top = ""; + el.style.bottom = screenHeight - top + "px"; + popup.isTopdown = false; + } else { + top += lineHeight; + el.style.top = top + "px"; + el.style.bottom = ""; + popup.isTopdown = true; + } + + el.style.display = ""; + this.renderer.$textLayer.checkForSizeChanges(); + + var left = pos.left; + if (left + el.offsetWidth > screenWidth) + left = screenWidth - el.offsetWidth; + + el.style.left = left + "px"; + + this._signal("show"); + lastMouseEvent = null; + popup.isOpen = true; + }; + + popup.getTextLeftOffset = function() { + return this.$borderSize + this.renderer.$padding + this.$imageSize; + }; + + popup.$imageSize = 0; + popup.$borderSize = 1; + + return popup; +}; + +dom.importCssString("\ +.ace_editor.ace_autocomplete .ace_marker-layer .ace_active-line {\ + background-color: #CAD6FA;\ + z-index: 1;\ +}\ +.ace_editor.ace_autocomplete .ace_line-hover {\ + border: 1px solid #abbffe;\ + margin-top: -1px;\ + background: rgba(233,233,253,0.4);\ +}\ +.ace_editor.ace_autocomplete .ace_line-hover {\ + position: absolute;\ + z-index: 2;\ +}\ +.ace_editor.ace_autocomplete .ace_scroller {\ + background: none;\ + border: none;\ + box-shadow: none;\ +}\ +.ace_rightAlignedText {\ + color: gray;\ + display: inline-block;\ + position: absolute;\ + right: 4px;\ + text-align: right;\ + z-index: -1;\ +}\ +.ace_editor.ace_autocomplete .ace_completion-highlight{\ + color: #000;\ + text-shadow: 0 0 0.01em;\ +}\ +.ace_editor.ace_autocomplete {\ + width: 280px;\ + z-index: 200000;\ + background: #fbfbfb;\ + color: #444;\ + border: 1px lightgray solid;\ + position: fixed;\ + box-shadow: 2px 3px 5px rgba(0,0,0,.2);\ + line-height: 1.4;\ +}"); + +exports.AcePopup = AcePopup; + +}); diff --git a/lib/ace/mode/html_eex_highlight_rules.js b/lib/ace/autocomplete/text_completer.js similarity index 53% rename from lib/ace/mode/html_eex_highlight_rules.js rename to lib/ace/autocomplete/text_completer.js index 199f067f..17a4bdad 100644 --- a/lib/ace/mode/html_eex_highlight_rules.js +++ b/lib/ace/autocomplete/text_completer.js @@ -3,7 +3,7 @@ * * 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 @@ -14,7 +14,7 @@ * * 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 @@ -28,35 +28,51 @@ * * ***** END LICENSE BLOCK ***** */ -/* This file was autogenerated from tool\tm bundles\elixir-tmbundle\Syntaxes\HTML (EEx).tmLanguage (uuid: ) */ -/**************************************************************************************** - * IT MIGHT NOT BE PERFECT ...But it's a good start from an existing *.tmlanguage file. * - * fileTypes * - ****************************************************************************************/ - define(function(require, exports, module) { -"use strict"; - -var oop = require("../lib/oop"); -var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; - -var HTMLEExHighlightRules = function() { - // regexp must not have capturing parentheses. Use (?:) instead. - // regexps are ordered -> the first match is used - - this.$rules = { start: [ { include: 'text.elixir' }, { include: 'text.html.basic' } ] } + var Range = require("../range").Range; - this.normalizeRules(); -}; + var splitRegex = /[^a-zA-Z_0-9\$\-\u00C0-\u1FFF\u2C00-\uD7FF\w]+/; -HTMLEExHighlightRules.metaData = { fileTypes: [ 'html.eex' ], - foldingStartMarker: '(?x)\n\t\t(<(?i:head|body|table|thead|tbody|tfoot|tr|div|select|fieldset|style|script|ul|ol|form|dl)\\b.*?>\n\t\t|)\n\t\t|\\{\\s*($|\\?>\\s*$|//|/\\*(.*\\*/\\s*$|(?!.*?\\*/)))\n\t\t)', - foldingStopMarker: '(?x)\n\t\t(\n\t\t|^\\s*-->\n\t\t|(^|\\s)\\}\n\t\t)', - name: 'HTML (EEx)', - scopeName: 'text.html.elixir' } + function getWordIndex(doc, pos) { + var textBefore = doc.getTextRange(Range.fromPoints({row: 0, column:0}, pos)); + return textBefore.split(splitRegex).length - 1; + } + /** + * Does a distance analysis of the word `prefix` at position `pos` in `doc`. + * @return Map + */ + function wordDistance(doc, pos) { + var prefixPos = getWordIndex(doc, pos); + var words = doc.getValue().split(splitRegex); + var wordScores = Object.create(null); + + var currentWord = words[prefixPos]; -oop.inherits(HTMLEExHighlightRules, TextHighlightRules); + words.forEach(function(word, idx) { + if (!word || word === currentWord) return; -exports.HTMLEExHighlightRules = HTMLEExHighlightRules; -}); \ No newline at end of file + var distance = Math.abs(prefixPos - idx); + var score = words.length - distance; + if (wordScores[word]) { + wordScores[word] = Math.max(score, wordScores[word]); + } else { + wordScores[word] = score; + } + }); + return wordScores; + } + + exports.getCompletions = function(editor, session, pos, prefix, callback) { + var wordScore = wordDistance(session, pos, prefix); + var wordList = Object.keys(wordScore); + callback(null, wordList.map(function(word) { + return { + caption: word, + value: word, + score: wordScore[word], + meta: "local" + }; + })); + }; +}); diff --git a/lib/ace/autocomplete/util.js b/lib/ace/autocomplete/util.js new file mode 100644 index 00000000..767b983e --- /dev/null +++ b/lib/ace/autocomplete/util.js @@ -0,0 +1,74 @@ +/* ***** 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. + * + * ***** END LICENSE BLOCK ***** */ + +define(function(require, exports, module) { +"use strict"; + +exports.parForEach = function(array, fn, callback) { + var completed = 0; + var arLength = array.length; + if (arLength === 0) + callback(); + for (var i = 0; i < arLength; i++) { + fn(array[i], function(result, err) { + completed++; + if (completed === arLength) + callback(result, err); + }); + } +}; + +var ID_REGEX = /[a-zA-Z_0-9\$\-\u00A2-\uFFFF]/; + +exports.retrievePrecedingIdentifier = function(text, pos, regex) { + regex = regex || ID_REGEX; + var buf = []; + for (var i = pos-1; i >= 0; i--) { + if (regex.test(text[i])) + buf.push(text[i]); + else + break; + } + return buf.reverse().join(""); +}; + +exports.retrieveFollowingIdentifier = function(text, pos, regex) { + regex = regex || ID_REGEX; + var buf = []; + for (var i = pos; i < text.length; i++) { + if (regex.test(text[i])) + buf.push(text[i]); + else + break; + } + return buf; +}; + +}); diff --git a/lib/ace/background_tokenizer.js b/lib/ace/background_tokenizer.js index 8f936d1a..ea4ddd0f 100644 --- a/lib/ace/background_tokenizer.js +++ b/lib/ace/background_tokenizer.js @@ -36,8 +36,6 @@ var EventEmitter = require("./lib/event_emitter").EventEmitter; /** - * - * * Tokenizes the current [[Document `Document`]] in the background, and caches the tokenized rows for future use. * * If a certain row is changed, everything below that row is re-tokenized. @@ -50,8 +48,6 @@ var EventEmitter = require("./lib/event_emitter").EventEmitter; * @param {Tokenizer} tokenizer The tokenizer to use * @param {Editor} editor The editor to associate with * - * - * * @constructor **/ @@ -68,29 +64,35 @@ var BackgroundTokenizer = function(tokenizer, editor) { if (!self.running) { return; } var workerStart = new Date(); - var startLine = self.currentLine; + var currentLine = self.currentLine; + var endLine = -1; var doc = self.doc; - var processedLines = 0; - + var startLine = currentLine; + while (self.lines[currentLine]) + currentLine++; + var len = doc.getLength(); - while (self.currentLine < len) { - self.$tokenizeRow(self.currentLine); - while (self.lines[self.currentLine]) - self.currentLine++; + var processedLines = 0; + self.running = false; + while (currentLine < len) { + self.$tokenizeRow(currentLine); + endLine = currentLine; + do { + currentLine++; + } while (self.lines[currentLine]); // only check every 5 lines processedLines ++; - if ((processedLines % 5 == 0) && (new Date() - workerStart) > 20) { - self.fireUpdateEvent(startLine, self.currentLine-1); + if ((processedLines % 5 === 0) && (new Date() - workerStart) > 20) { self.running = setTimeout(self.$worker, 20); - return; + break; } } - - self.running = false; - - self.fireUpdateEvent(startLine, len - 1); + self.currentLine = currentLine; + + if (startLine <= endLine) + self.fireUpdateEvent(startLine, endLine); }; }; @@ -142,7 +144,7 @@ var BackgroundTokenizer = function(tokenizer, editor) { first: firstRow, last: lastRow }; - this._emit("update", {data: data}); + this._signal("update", {data: data}); }; /** @@ -162,15 +164,19 @@ var BackgroundTokenizer = function(tokenizer, editor) { // pretty long delay to prevent the tokenizer from interfering with the user this.running = setTimeout(this.$worker, 700); }; + + this.scheduleStart = function() { + if (!this.running) + this.running = setTimeout(this.$worker, 700); + } this.$updateOnChange = function(delta) { - var range = delta.range; - var startRow = range.start.row; - var len = range.end.row - startRow; + var startRow = delta.start.row; + var len = delta.end.row - startRow; if (len === 0) { this.lines[startRow] = null; - } else if (delta.action == "removeText" || delta.action == "removeLines") { + } else if (delta.action == "remove") { this.lines.splice(startRow, len + 1, null); this.states.splice(startRow, len + 1, null); } else { @@ -183,8 +189,6 @@ var BackgroundTokenizer = function(tokenizer, editor) { this.currentLine = Math.min(startRow, this.currentLine, this.doc.getLength()); this.stop(); - // pretty long delay to prevent the tokenizer from interfering with the user - this.running = setTimeout(this.$worker, 700); }; /** diff --git a/lib/ace/background_tokenizer_test.js b/lib/ace/background_tokenizer_test.js index 7a4cc78c..fd738d06 100644 --- a/lib/ace/background_tokenizer_test.js +++ b/lib/ace/background_tokenizer_test.js @@ -75,6 +75,49 @@ module.exports = { forceTokenize(doc) testStates(doc, ["comment_regex_allowed", "start", "no_regex"]) + }, + "test background tokenizer sends update event" : function() { + var doc = new EditSession([ + "/*", + "var", + "juhu", + "*/" + ]); + doc.setMode("./mode/javascript"); + + var updateEvent = null; + doc.bgTokenizer.on("update", function(e) { + updateEvent = e.data; + }); + function checkEvent(first, last) { + assert.ok(!updateEvent, "unneccessary update event"); + doc.bgTokenizer.running = 1; + doc.bgTokenizer.$worker(); + assert.ok(updateEvent); + assert.equal([first, last] + "", + [updateEvent.first, updateEvent.last] + "") + updateEvent = null; + } + + forceTokenize(doc); + var comment = "comment_regex_allowed"; + testStates(doc, [comment, comment, comment, "start"]); + + doc.remove(new Range(0,0,0,2)); + testStates(doc, [comment, comment, comment, "start"]); + + checkEvent(0, 3); + testStates(doc, ["start", "no_regex", "no_regex", "regex"]); + + // insert /* and and press down several times quickly + doc.insert({row:0, column:0}, "/*"); + doc.getTokens(0); + doc.getTokens(1); + doc.getTokens(2); + checkEvent(0, 3); + + forceTokenize(doc); + testStates(doc, [comment, comment, comment, "start"]); } }; diff --git a/lib/ace/commands/command_manager.js b/lib/ace/commands/command_manager.js index b3e0fc6d..df30ef9b 100644 --- a/lib/ace/commands/command_manager.js +++ b/lib/ace/commands/command_manager.js @@ -2,45 +2,44 @@ define(function(require, exports, module) { "use strict"; var oop = require("../lib/oop"); -var HashHandler = require("../keyboard/hash_handler").HashHandler; +var MultiHashHandler = require("../keyboard/hash_handler").MultiHashHandler; var EventEmitter = require("../lib/event_emitter").EventEmitter; /** * @class CommandManager * - * **/ /** * new CommandManager(platform, commands) - * @param {String} platform Identifier for the platform; must be either `'mac'` or `'win'` + * @param {String} platform Identifier for the platform; must be either `"mac"` or `"win"` * @param {Array} commands A list of commands * - * - * - * **/ var CommandManager = function(platform, commands) { - this.platform = platform; - this.commands = this.byName = {}; - this.commmandKeyBinding = {}; - - this.addCommands(commands); - + MultiHashHandler.call(this, commands, platform); + this.byName = this.commands; this.setDefaultHandler("exec", function(e) { return e.command.exec(e.editor, e.args || {}); }); }; -oop.inherits(CommandManager, HashHandler); +oop.inherits(CommandManager, MultiHashHandler); (function() { oop.implement(this, EventEmitter); this.exec = function(command, editor, args) { - if (typeof command === 'string') + if (Array.isArray(command)) { + for (var i = command.length; i--; ) { + if (this.exec(command[i], editor, args)) return true; + } + return false; + } + + if (typeof command === "string") command = this.commands[command]; if (!command) @@ -50,10 +49,10 @@ oop.inherits(CommandManager, HashHandler); return false; var e = {editor: editor, command: command, args: args}; - var retvalue = this._emit("exec", e); + e.returnValue = this._emit("exec", e); this._signal("afterExec", e); - return retvalue === false ? false : true; + return e.returnValue === false ? false : true; }; this.toggleRecording = function(editor) { diff --git a/lib/ace/commands/command_manager_test.js b/lib/ace/commands/command_manager_test.js index 76d973bb..902600be 100644 --- a/lib/ace/commands/command_manager_test.js +++ b/lib/ace/commands/command_manager_test.js @@ -188,7 +188,7 @@ module.exports = { assert.equal(command, "cm2"); var command = this.cm.findKeyCommand(0, "return"); - assert.equal(command, "cm3"); + assert.equal(command + "", ["cm4", "cm3"] + ""); } }; diff --git a/lib/ace/commands/default_commands.js b/lib/ace/commands/default_commands.js index 9d3bc401..de14df85 100644 --- a/lib/ace/commands/default_commands.js +++ b/lib/ace/commands/default_commands.js @@ -33,14 +33,16 @@ define(function(require, exports, module) { var lang = require("../lib/lang"); var config = require("../config"); +var Range = require("../range").Range; function bindKey(win, mac) { - return { - win: win, - mac: mac - }; + return {win: win, mac: mac}; } +/* + multiSelectAction: "forEach"|"forEachLine"|function|undefined, + scrollIntoView: true|"cursor"|"center"|"selectionPart" +*/ exports.commands = [{ name: "showSettingsMenu", bindKey: bindKey("Ctrl-,", "Command-,"), @@ -51,6 +53,26 @@ exports.commands = [{ }); }, readOnly: true +}, { + name: "goToNextError", + bindKey: bindKey("Alt-E", "Ctrl-E"), + exec: function(editor) { + config.loadModule("ace/ext/error_marker", function(module) { + module.showErrorMarker(editor, 1); + }); + }, + scrollIntoView: "animate", + readOnly: true +}, { + name: "goToPreviousError", + bindKey: bindKey("Alt-Shift-E", "Ctrl-Shift-E"), + exec: function(editor) { + config.loadModule("ace/ext/error_marker", function(module) { + module.showErrorMarker(editor, -1); + }); + }, + scrollIntoView: "animate", + readOnly: true }, { name: "selectall", bindKey: bindKey("Ctrl-A", "Command-A"), @@ -75,31 +97,84 @@ exports.commands = [{ name: "fold", bindKey: bindKey("Alt-L|Ctrl-F1", "Command-Alt-L|Command-F1"), exec: function(editor) { editor.session.toggleFold(false); }, + multiSelectAction: "forEach", + scrollIntoView: "center", readOnly: true }, { name: "unfold", bindKey: bindKey("Alt-Shift-L|Ctrl-Shift-F1", "Command-Alt-Shift-L|Command-Shift-F1"), exec: function(editor) { editor.session.toggleFold(true); }, + multiSelectAction: "forEach", + scrollIntoView: "center", + readOnly: true +}, { + name: "toggleFoldWidget", + bindKey: bindKey("F2", "F2"), + exec: function(editor) { editor.session.toggleFoldWidget(); }, + multiSelectAction: "forEach", + scrollIntoView: "center", + readOnly: true +}, { + name: "toggleParentFoldWidget", + bindKey: bindKey("Alt-F2", "Alt-F2"), + exec: function(editor) { editor.session.toggleFoldWidget(true); }, + multiSelectAction: "forEach", + scrollIntoView: "center", readOnly: true }, { name: "foldall", - bindKey: bindKey("Alt-0", "Command-Option-0"), + bindKey: bindKey(null, "Ctrl-Command-Option-0"), exec: function(editor) { editor.session.foldAll(); }, + scrollIntoView: "center", + readOnly: true +}, { + name: "foldOther", + bindKey: bindKey("Alt-0", "Command-Option-0"), + exec: function(editor) { + editor.session.foldAll(); + editor.session.unfold(editor.selection.getAllRanges()); + }, + scrollIntoView: "center", readOnly: true }, { name: "unfoldall", bindKey: bindKey("Alt-Shift-0", "Command-Option-Shift-0"), exec: function(editor) { editor.session.unfold(); }, + scrollIntoView: "center", readOnly: true }, { name: "findnext", bindKey: bindKey("Ctrl-K", "Command-G"), exec: function(editor) { editor.findNext(); }, + multiSelectAction: "forEach", + scrollIntoView: "center", readOnly: true }, { name: "findprevious", bindKey: bindKey("Ctrl-Shift-K", "Command-Shift-G"), exec: function(editor) { editor.findPrevious(); }, + multiSelectAction: "forEach", + scrollIntoView: "center", + readOnly: true +}, { + name: "selectOrFindNext", + bindKey: bindKey("Alt-K", "Ctrl-G"), + exec: function(editor) { + if (editor.selection.isEmpty()) + editor.selection.selectWord(); + else + editor.findNext(); + }, + readOnly: true +}, { + name: "selectOrFindPrevious", + bindKey: bindKey("Alt-Shift-K", "Ctrl-Shift-G"), + exec: function(editor) { + if (editor.selection.isEmpty()) + editor.selection.selectWord(); + else + editor.findPrevious(); + }, readOnly: true }, { name: "find", @@ -118,120 +193,144 @@ exports.commands = [{ bindKey: bindKey("Ctrl-Shift-Home", "Command-Shift-Up"), exec: function(editor) { editor.getSelection().selectFileStart(); }, multiSelectAction: "forEach", - readOnly: true + readOnly: true, + scrollIntoView: "animate", + aceCommandGroup: "fileJump" }, { name: "gotostart", bindKey: bindKey("Ctrl-Home", "Command-Home|Command-Up"), exec: function(editor) { editor.navigateFileStart(); }, multiSelectAction: "forEach", - readOnly: true + readOnly: true, + scrollIntoView: "animate", + aceCommandGroup: "fileJump" }, { name: "selectup", bindKey: bindKey("Shift-Up", "Shift-Up"), exec: function(editor) { editor.getSelection().selectUp(); }, multiSelectAction: "forEach", + scrollIntoView: "cursor", readOnly: true }, { name: "golineup", bindKey: bindKey("Up", "Up|Ctrl-P"), exec: function(editor, args) { editor.navigateUp(args.times); }, multiSelectAction: "forEach", + scrollIntoView: "cursor", readOnly: true }, { name: "selecttoend", bindKey: bindKey("Ctrl-Shift-End", "Command-Shift-Down"), exec: function(editor) { editor.getSelection().selectFileEnd(); }, multiSelectAction: "forEach", - readOnly: true + readOnly: true, + scrollIntoView: "animate", + aceCommandGroup: "fileJump" }, { name: "gotoend", bindKey: bindKey("Ctrl-End", "Command-End|Command-Down"), exec: function(editor) { editor.navigateFileEnd(); }, multiSelectAction: "forEach", - readOnly: true + readOnly: true, + scrollIntoView: "animate", + aceCommandGroup: "fileJump" }, { name: "selectdown", bindKey: bindKey("Shift-Down", "Shift-Down"), exec: function(editor) { editor.getSelection().selectDown(); }, multiSelectAction: "forEach", + scrollIntoView: "cursor", readOnly: true }, { name: "golinedown", bindKey: bindKey("Down", "Down|Ctrl-N"), exec: function(editor, args) { editor.navigateDown(args.times); }, multiSelectAction: "forEach", + scrollIntoView: "cursor", readOnly: true }, { name: "selectwordleft", bindKey: bindKey("Ctrl-Shift-Left", "Option-Shift-Left"), exec: function(editor) { editor.getSelection().selectWordLeft(); }, multiSelectAction: "forEach", + scrollIntoView: "cursor", readOnly: true }, { name: "gotowordleft", bindKey: bindKey("Ctrl-Left", "Option-Left"), exec: function(editor) { editor.navigateWordLeft(); }, multiSelectAction: "forEach", + scrollIntoView: "cursor", readOnly: true }, { name: "selecttolinestart", bindKey: bindKey("Alt-Shift-Left", "Command-Shift-Left"), exec: function(editor) { editor.getSelection().selectLineStart(); }, multiSelectAction: "forEach", + scrollIntoView: "cursor", readOnly: true }, { name: "gotolinestart", bindKey: bindKey("Alt-Left|Home", "Command-Left|Home|Ctrl-A"), exec: function(editor) { editor.navigateLineStart(); }, multiSelectAction: "forEach", + scrollIntoView: "cursor", readOnly: true }, { name: "selectleft", bindKey: bindKey("Shift-Left", "Shift-Left"), exec: function(editor) { editor.getSelection().selectLeft(); }, multiSelectAction: "forEach", + scrollIntoView: "cursor", readOnly: true }, { name: "gotoleft", bindKey: bindKey("Left", "Left|Ctrl-B"), exec: function(editor, args) { editor.navigateLeft(args.times); }, multiSelectAction: "forEach", + scrollIntoView: "cursor", readOnly: true }, { name: "selectwordright", bindKey: bindKey("Ctrl-Shift-Right", "Option-Shift-Right"), exec: function(editor) { editor.getSelection().selectWordRight(); }, multiSelectAction: "forEach", + scrollIntoView: "cursor", readOnly: true }, { name: "gotowordright", bindKey: bindKey("Ctrl-Right", "Option-Right"), exec: function(editor) { editor.navigateWordRight(); }, multiSelectAction: "forEach", + scrollIntoView: "cursor", readOnly: true }, { name: "selecttolineend", bindKey: bindKey("Alt-Shift-Right", "Command-Shift-Right"), exec: function(editor) { editor.getSelection().selectLineEnd(); }, multiSelectAction: "forEach", + scrollIntoView: "cursor", readOnly: true }, { name: "gotolineend", bindKey: bindKey("Alt-Right|End", "Command-Right|End|Ctrl-E"), exec: function(editor) { editor.navigateLineEnd(); }, multiSelectAction: "forEach", + scrollIntoView: "cursor", readOnly: true }, { name: "selectright", bindKey: bindKey("Shift-Right", "Shift-Right"), exec: function(editor) { editor.getSelection().selectRight(); }, multiSelectAction: "forEach", + scrollIntoView: "cursor", readOnly: true }, { name: "gotoright", bindKey: bindKey("Right", "Right|Ctrl-F"), exec: function(editor, args) { editor.navigateRight(args.times); }, multiSelectAction: "forEach", + scrollIntoView: "cursor", readOnly: true }, { name: "selectpagedown", @@ -278,12 +377,14 @@ exports.commands = [{ bindKey: "Shift-Home", exec: function(editor) { editor.getSelection().selectLineStart(); }, multiSelectAction: "forEach", + scrollIntoView: "cursor", readOnly: true }, { name: "selectlineend", bindKey: "Shift-End", exec: function(editor) { editor.getSelection().selectLineEnd(); }, multiSelectAction: "forEach", + scrollIntoView: "cursor", readOnly: true }, { name: "togglerecording", @@ -297,17 +398,38 @@ exports.commands = [{ readOnly: true }, { name: "jumptomatching", - bindKey: bindKey("Ctrl-P", "Ctrl-Shift-P"), + bindKey: bindKey("Ctrl-P", "Ctrl-P"), exec: function(editor) { editor.jumpToMatching(); }, multiSelectAction: "forEach", + scrollIntoView: "animate", readOnly: true }, { name: "selecttomatching", - bindKey: bindKey("Ctrl-Shift-P", null), + bindKey: bindKey("Ctrl-Shift-P", "Ctrl-Shift-P"), exec: function(editor) { editor.jumpToMatching(true); }, multiSelectAction: "forEach", + scrollIntoView: "animate", readOnly: true -}, +}, { + name: "expandToMatching", + bindKey: bindKey("Ctrl-Shift-M", "Ctrl-Shift-M"), + exec: function(editor) { editor.jumpToMatching(true, true); }, + multiSelectAction: "forEach", + scrollIntoView: "animate", + readOnly: true +}, { + name: "passKeysToBrowser", + bindKey: bindKey(null, null), + exec: function() {}, + passEvent: true, + readOnly: true +}, { + name: "copy", + exec: function(editor) { + // placeholder for replay macro + }, + readOnly: true +}, // commands disabled in readOnly mode { @@ -321,41 +443,55 @@ exports.commands = [{ editor.clearSelection(); } }, + scrollIntoView: "cursor", multiSelectAction: "forEach" +}, { + name: "paste", + exec: function(editor, args) { + editor.$handlePaste(args); + }, + scrollIntoView: "cursor" }, { name: "removeline", bindKey: bindKey("Ctrl-D", "Command-D"), exec: function(editor) { editor.removeLines(); }, + scrollIntoView: "cursor", multiSelectAction: "forEachLine" }, { name: "duplicateSelection", bindKey: bindKey("Ctrl-Shift-D", "Command-Shift-D"), exec: function(editor) { editor.duplicateSelection(); }, + scrollIntoView: "cursor", multiSelectAction: "forEach" }, { name: "sortlines", bindKey: bindKey("Ctrl-Alt-S", "Command-Alt-S"), exec: function(editor) { editor.sortLines(); }, + scrollIntoView: "selection", multiSelectAction: "forEachLine" }, { name: "togglecomment", bindKey: bindKey("Ctrl-/", "Command-/"), exec: function(editor) { editor.toggleCommentLines(); }, - multiSelectAction: "forEachLine" + multiSelectAction: "forEachLine", + scrollIntoView: "selectionPart" }, { name: "toggleBlockComment", bindKey: bindKey("Ctrl-Shift-/", "Command-Shift-/"), exec: function(editor) { editor.toggleBlockComment(); }, - multiSelectAction: "forEach" + multiSelectAction: "forEach", + scrollIntoView: "selectionPart" }, { name: "modifyNumberUp", bindKey: bindKey("Ctrl-Shift-Up", "Alt-Shift-Up"), exec: function(editor) { editor.modifyNumber(1); }, + scrollIntoView: "cursor", multiSelectAction: "forEach" }, { name: "modifyNumberDown", bindKey: bindKey("Ctrl-Shift-Down", "Alt-Shift-Down"), exec: function(editor) { editor.modifyNumber(-1); }, + scrollIntoView: "cursor", multiSelectAction: "forEach" }, { name: "replace", @@ -374,102 +510,228 @@ exports.commands = [{ }, { name: "copylinesup", bindKey: bindKey("Alt-Shift-Up", "Command-Option-Up"), - exec: function(editor) { editor.copyLinesUp(); } + exec: function(editor) { editor.copyLinesUp(); }, + scrollIntoView: "cursor" }, { name: "movelinesup", bindKey: bindKey("Alt-Up", "Option-Up"), - exec: function(editor) { editor.moveLinesUp(); } + exec: function(editor) { editor.moveLinesUp(); }, + scrollIntoView: "cursor" }, { name: "copylinesdown", bindKey: bindKey("Alt-Shift-Down", "Command-Option-Down"), - exec: function(editor) { editor.copyLinesDown(); } + exec: function(editor) { editor.copyLinesDown(); }, + scrollIntoView: "cursor" }, { name: "movelinesdown", bindKey: bindKey("Alt-Down", "Option-Down"), - exec: function(editor) { editor.moveLinesDown(); } + exec: function(editor) { editor.moveLinesDown(); }, + scrollIntoView: "cursor" }, { name: "del", - bindKey: bindKey("Delete", "Delete|Ctrl-D"), + bindKey: bindKey("Delete", "Delete|Ctrl-D|Shift-Delete"), exec: function(editor) { editor.remove("right"); }, - multiSelectAction: "forEach" + multiSelectAction: "forEach", + scrollIntoView: "cursor" }, { name: "backspace", bindKey: bindKey( - "Command-Backspace|Option-Backspace|Shift-Backspace|Backspace", - "Ctrl-Backspace|Command-Backspace|Shift-Backspace|Backspace|Ctrl-H" + "Shift-Backspace|Backspace", + "Ctrl-Backspace|Shift-Backspace|Backspace|Ctrl-H" ), exec: function(editor) { editor.remove("left"); }, - multiSelectAction: "forEach" + multiSelectAction: "forEach", + scrollIntoView: "cursor" +}, { + name: "cut_or_delete", + bindKey: bindKey("Shift-Delete", null), + exec: function(editor) { + if (editor.selection.isEmpty()) { + editor.remove("left"); + } else { + return false; + } + }, + multiSelectAction: "forEach", + scrollIntoView: "cursor" }, { name: "removetolinestart", bindKey: bindKey("Alt-Backspace", "Command-Backspace"), exec: function(editor) { editor.removeToLineStart(); }, - multiSelectAction: "forEach" + multiSelectAction: "forEach", + scrollIntoView: "cursor" }, { name: "removetolineend", bindKey: bindKey("Alt-Delete", "Ctrl-K"), exec: function(editor) { editor.removeToLineEnd(); }, - multiSelectAction: "forEach" + multiSelectAction: "forEach", + scrollIntoView: "cursor" }, { name: "removewordleft", bindKey: bindKey("Ctrl-Backspace", "Alt-Backspace|Ctrl-Alt-Backspace"), exec: function(editor) { editor.removeWordLeft(); }, - multiSelectAction: "forEach" + multiSelectAction: "forEach", + scrollIntoView: "cursor" }, { name: "removewordright", bindKey: bindKey("Ctrl-Delete", "Alt-Delete"), exec: function(editor) { editor.removeWordRight(); }, - multiSelectAction: "forEach" + multiSelectAction: "forEach", + scrollIntoView: "cursor" }, { name: "outdent", bindKey: bindKey("Shift-Tab", "Shift-Tab"), exec: function(editor) { editor.blockOutdent(); }, - multiSelectAction: "forEach" + multiSelectAction: "forEach", + scrollIntoView: "selectionPart" }, { name: "indent", bindKey: bindKey("Tab", "Tab"), exec: function(editor) { editor.indent(); }, - multiSelectAction: "forEach" -},{ + multiSelectAction: "forEach", + scrollIntoView: "selectionPart" +}, { name: "blockoutdent", bindKey: bindKey("Ctrl-[", "Ctrl-["), exec: function(editor) { editor.blockOutdent(); }, - multiSelectAction: "forEachLine" -},{ + multiSelectAction: "forEachLine", + scrollIntoView: "selectionPart" +}, { name: "blockindent", bindKey: bindKey("Ctrl-]", "Ctrl-]"), exec: function(editor) { editor.blockIndent(); }, - multiSelectAction: "forEachLine" + multiSelectAction: "forEachLine", + scrollIntoView: "selectionPart" }, { name: "insertstring", exec: function(editor, str) { editor.insert(str); }, - multiSelectAction: "forEach" + multiSelectAction: "forEach", + scrollIntoView: "cursor" }, { name: "inserttext", exec: function(editor, args) { editor.insert(lang.stringRepeat(args.text || "", args.times || 1)); }, - multiSelectAction: "forEach" + multiSelectAction: "forEach", + scrollIntoView: "cursor" }, { name: "splitline", bindKey: bindKey(null, "Ctrl-O"), exec: function(editor) { editor.splitLine(); }, - multiSelectAction: "forEach" + multiSelectAction: "forEach", + scrollIntoView: "cursor" }, { name: "transposeletters", bindKey: bindKey("Ctrl-T", "Ctrl-T"), exec: function(editor) { editor.transposeLetters(); }, - multiSelectAction: function(editor) {editor.transposeSelections(1); } + multiSelectAction: function(editor) {editor.transposeSelections(1); }, + scrollIntoView: "cursor" }, { name: "touppercase", bindKey: bindKey("Ctrl-U", "Ctrl-U"), exec: function(editor) { editor.toUpperCase(); }, - multiSelectAction: "forEach" + multiSelectAction: "forEach", + scrollIntoView: "cursor" }, { name: "tolowercase", bindKey: bindKey("Ctrl-Shift-U", "Ctrl-Shift-U"), exec: function(editor) { editor.toLowerCase(); }, - multiSelectAction: "forEach" + multiSelectAction: "forEach", + scrollIntoView: "cursor" +}, { + name: "expandtoline", + bindKey: bindKey("Ctrl-Shift-L", "Command-Shift-L"), + exec: function(editor) { + var range = editor.selection.getRange(); + + range.start.column = range.end.column = 0; + range.end.row++; + editor.selection.setRange(range, false); + }, + multiSelectAction: "forEach", + scrollIntoView: "cursor", + readOnly: true +}, { + name: "joinlines", + bindKey: bindKey(null, null), + exec: function(editor) { + var isBackwards = editor.selection.isBackwards(); + var selectionStart = isBackwards ? editor.selection.getSelectionLead() : editor.selection.getSelectionAnchor(); + var selectionEnd = isBackwards ? editor.selection.getSelectionAnchor() : editor.selection.getSelectionLead(); + var firstLineEndCol = editor.session.doc.getLine(selectionStart.row).length; + var selectedText = editor.session.doc.getTextRange(editor.selection.getRange()); + var selectedCount = selectedText.replace(/\n\s*/, " ").length; + var insertLine = editor.session.doc.getLine(selectionStart.row); + + for (var i = selectionStart.row + 1; i <= selectionEnd.row + 1; i++) { + var curLine = lang.stringTrimLeft(lang.stringTrimRight(editor.session.doc.getLine(i))); + if (curLine.length !== 0) { + curLine = " " + curLine; + } + insertLine += curLine; + } + + if (selectionEnd.row + 1 < (editor.session.doc.getLength() - 1)) { + // Don't insert a newline at the end of the document + insertLine += editor.session.doc.getNewLineCharacter(); + } + + editor.clearSelection(); + editor.session.doc.replace(new Range(selectionStart.row, 0, selectionEnd.row + 2, 0), insertLine); + + if (selectedCount > 0) { + // Select the text that was previously selected + editor.selection.moveCursorTo(selectionStart.row, selectionStart.column); + editor.selection.selectTo(selectionStart.row, selectionStart.column + selectedCount); + } else { + // If the joined line had something in it, start the cursor at that something + firstLineEndCol = editor.session.doc.getLine(selectionStart.row).length > firstLineEndCol ? (firstLineEndCol + 1) : firstLineEndCol; + editor.selection.moveCursorTo(selectionStart.row, firstLineEndCol); + } + }, + multiSelectAction: "forEach", + readOnly: true +}, { + name: "invertSelection", + bindKey: bindKey(null, null), + exec: function(editor) { + var endRow = editor.session.doc.getLength() - 1; + var endCol = editor.session.doc.getLine(endRow).length; + var ranges = editor.selection.rangeList.ranges; + var newRanges = []; + + // If multiple selections don't exist, rangeList will return 0 so replace with single range + if (ranges.length < 1) { + ranges = [editor.selection.getRange()]; + } + + for (var i = 0; i < ranges.length; i++) { + if (i == (ranges.length - 1)) { + // The last selection must connect to the end of the document, unless it already does + if (!(ranges[i].end.row === endRow && ranges[i].end.column === endCol)) { + newRanges.push(new Range(ranges[i].end.row, ranges[i].end.column, endRow, endCol)); + } + } + + if (i === 0) { + // The first selection must connect to the start of the document, unless it already does + if (!(ranges[i].start.row === 0 && ranges[i].start.column === 0)) { + newRanges.push(new Range(0, 0, ranges[i].start.row, ranges[i].start.column)); + } + } else { + newRanges.push(new Range(ranges[i-1].end.row, ranges[i-1].end.column, ranges[i].start.row, ranges[i].start.column)); + } + } + + editor.exitMultiSelectMode(); + editor.clearSelection(); + + for(var i = 0; i < newRanges.length; i++) { + editor.selection.addRange(newRanges[i], false); + } + }, + readOnly: true, + scrollIntoView: "none" }]; }); diff --git a/lib/ace/commands/incremental_search_commands.js b/lib/ace/commands/incremental_search_commands.js index ebe979ca..59083a85 100644 --- a/lib/ace/commands/incremental_search_commands.js +++ b/lib/ace/commands/incremental_search_commands.js @@ -69,18 +69,14 @@ exports.iSearchCommands = [{ bindKey: {win: "Ctrl-F", mac: "Command-F"}, exec: function(iSearch) { iSearch.cancelSearch(true); - }, - readOnly: true, - isIncrementalSearchCommand: true + } }, { name: "searchForward", bindKey: {win: "Ctrl-S|Ctrl-K", mac: "Ctrl-S|Command-G"}, exec: function(iSearch, options) { options.useCurrentOrPrevSearch = true; iSearch.next(options); - }, - readOnly: true, - isIncrementalSearchCommand: true + } }, { name: "searchBackward", bindKey: {win: "Ctrl-R|Ctrl-Shift-K", mac: "Ctrl-R|Command-Shift-G"}, @@ -88,42 +84,30 @@ exports.iSearchCommands = [{ options.useCurrentOrPrevSearch = true; options.backwards = true; iSearch.next(options); - }, - readOnly: true, - isIncrementalSearchCommand: true + } }, { name: "extendSearchTerm", exec: function(iSearch, string) { - iSearch.addChar(string); - }, - readOnly: true, - isIncrementalSearchCommand: true + iSearch.addString(string); + } }, { name: "extendSearchTermSpace", bindKey: "space", - exec: function(iSearch) { iSearch.addChar(' '); }, - readOnly: true, - isIncrementalSearchCommand: true + exec: function(iSearch) { iSearch.addString(' '); } }, { name: "shrinkSearchTerm", bindKey: "backspace", exec: function(iSearch) { iSearch.removeChar(); - }, - readOnly: true, - isIncrementalSearchCommand: true + } }, { name: 'confirmSearch', bindKey: 'return', - exec: function(iSearch) { iSearch.deactivate(); }, - readOnly: true, - isIncrementalSearchCommand: true + exec: function(iSearch) { iSearch.deactivate(); } }, { name: 'cancelSearch', bindKey: 'esc|Ctrl-G', - exec: function(iSearch) { iSearch.deactivate(true); }, - readOnly: true, - isIncrementalSearchCommand: true + exec: function(iSearch) { iSearch.deactivate(true); } }, { name: 'occurisearch', bindKey: 'Ctrl-O', @@ -131,10 +115,53 @@ exports.iSearchCommands = [{ var options = oop.mixin({}, iSearch.$options); iSearch.deactivate(); occurStartCommand.exec(iSearch.$editor, options); - }, - readOnly: true, - isIncrementalSearchCommand: true -}]; + } +}, { + name: "yankNextWord", + bindKey: "Ctrl-w", + exec: function(iSearch) { + var ed = iSearch.$editor, + range = ed.selection.getRangeOfMovements(function(sel) { sel.moveCursorWordRight(); }), + string = ed.session.getTextRange(range); + iSearch.addString(string); + } +}, { + name: "yankNextChar", + bindKey: "Ctrl-Alt-y", + exec: function(iSearch) { + var ed = iSearch.$editor, + range = ed.selection.getRangeOfMovements(function(sel) { sel.moveCursorRight(); }), + string = ed.session.getTextRange(range); + iSearch.addString(string); + } +}, { + name: 'recenterTopBottom', + bindKey: 'Ctrl-l', + exec: function(iSearch) { iSearch.$editor.execCommand('recenterTopBottom'); } +}, { + name: 'selectAllMatches', + bindKey: 'Ctrl-space', + exec: function(iSearch) { + var ed = iSearch.$editor, + hl = ed.session.$isearchHighlight, + ranges = hl && hl.cache ? hl.cache + .reduce(function(ranges, ea) { + return ranges.concat(ea ? ea : []); }, []) : []; + iSearch.deactivate(false); + ranges.forEach(ed.selection.addRange.bind(ed.selection)); + } +}, { + name: 'searchAsRegExp', + bindKey: 'Alt-r', + exec: function(iSearch) { + iSearch.convertNeedleToRegExp(); + } +}].map(function(cmd) { + cmd.readOnly = true; + cmd.isIncrementalSearchCommand = true; + cmd.scrollIntoView = "animate-cursor"; + return cmd; +}); function IncrementalSearchKeyboardHandler(iSearch) { this.$iSearch = iSearch; @@ -142,7 +169,7 @@ function IncrementalSearchKeyboardHandler(iSearch) { oop.inherits(IncrementalSearchKeyboardHandler, HashHandler); -;(function() { +(function() { this.attach = function(editor) { var iSearch = this.$iSearch; @@ -151,18 +178,24 @@ oop.inherits(IncrementalSearchKeyboardHandler, HashHandler); if (!e.command.isIncrementalSearchCommand) return undefined; e.stopPropagation(); e.preventDefault(); - return e.command.exec(iSearch, e.args || {}); + var scrollTop = editor.session.getScrollTop(); + var result = e.command.exec(iSearch, e.args || {}); + editor.renderer.scrollCursorIntoView(null, 0.5); + editor.renderer.animateScrolling(scrollTop); + return result; }); - } + }; this.detach = function(editor) { if (!this.$commandExecHandler) return; editor.commands.removeEventListener('exec', this.$commandExecHandler); delete this.$commandExecHandler; - } + }; var handleKeyboard$super = this.handleKeyboard; this.handleKeyboard = function(data, hashId, key, keyCode) { + if (((hashId === 1/*ctrl*/ || hashId === 8/*command*/) && key === 'v') + || (hashId === 1/*ctrl*/ && key === 'y')) return null; var cmd = handleKeyboard$super.call(this, data, hashId, key, keyCode); if (cmd.command) { return cmd; } if (hashId == -1) { @@ -170,7 +203,7 @@ oop.inherits(IncrementalSearchKeyboardHandler, HashHandler); if (extendCmd) { return {command: extendCmd, args: key}; } } return {command: "null", passEvent: hashId == 0 || hashId == 4}; - } + }; }).call(IncrementalSearchKeyboardHandler.prototype); diff --git a/lib/ace/commands/multi_select_commands.js b/lib/ace/commands/multi_select_commands.js index ff59f045..ba6392bc 100644 --- a/lib/ace/commands/multi_select_commands.js +++ b/lib/ace/commands/multi_select_commands.js @@ -35,41 +35,49 @@ exports.defaultCommands = [{ name: "addCursorAbove", exec: function(editor) { editor.selectMoreLines(-1); }, bindKey: {win: "Ctrl-Alt-Up", mac: "Ctrl-Alt-Up"}, + scrollIntoView: "cursor", readonly: true }, { name: "addCursorBelow", exec: function(editor) { editor.selectMoreLines(1); }, bindKey: {win: "Ctrl-Alt-Down", mac: "Ctrl-Alt-Down"}, + scrollIntoView: "cursor", readonly: true }, { name: "addCursorAboveSkipCurrent", exec: function(editor) { editor.selectMoreLines(-1, true); }, bindKey: {win: "Ctrl-Alt-Shift-Up", mac: "Ctrl-Alt-Shift-Up"}, + scrollIntoView: "cursor", readonly: true }, { name: "addCursorBelowSkipCurrent", exec: function(editor) { editor.selectMoreLines(1, true); }, bindKey: {win: "Ctrl-Alt-Shift-Down", mac: "Ctrl-Alt-Shift-Down"}, + scrollIntoView: "cursor", readonly: true }, { name: "selectMoreBefore", exec: function(editor) { editor.selectMore(-1); }, bindKey: {win: "Ctrl-Alt-Left", mac: "Ctrl-Alt-Left"}, + scrollIntoView: "cursor", readonly: true }, { name: "selectMoreAfter", exec: function(editor) { editor.selectMore(1); }, bindKey: {win: "Ctrl-Alt-Right", mac: "Ctrl-Alt-Right"}, + scrollIntoView: "cursor", readonly: true }, { name: "selectNextBefore", exec: function(editor) { editor.selectMore(-1, true); }, bindKey: {win: "Ctrl-Alt-Shift-Left", mac: "Ctrl-Alt-Shift-Left"}, + scrollIntoView: "cursor", readonly: true }, { name: "selectNextAfter", exec: function(editor) { editor.selectMore(1, true); }, bindKey: {win: "Ctrl-Alt-Shift-Right", mac: "Ctrl-Alt-Shift-Right"}, + scrollIntoView: "cursor", readonly: true }, { name: "splitIntoLines", @@ -79,7 +87,14 @@ exports.defaultCommands = [{ }, { name: "alignCursors", exec: function(editor) { editor.alignCursors(); }, - bindKey: {win: "Ctrl-Alt-A", mac: "Ctrl-Alt-A"} + bindKey: {win: "Ctrl-Alt-A", mac: "Ctrl-Alt-A"}, + scrollIntoView: "cursor" +}, { + name: "findAll", + exec: function(editor) { editor.findAll(); }, + bindKey: {win: "Ctrl-Alt-K", mac: "Ctrl-Alt-G"}, + scrollIntoView: "cursor", + readonly: true }]; // commands active only in multiselect mode @@ -87,6 +102,7 @@ exports.multiSelectCommands = [{ name: "singleSelection", bindKey: "esc", exec: function(editor) { editor.exitMultiSelectMode(); }, + scrollIntoView: "cursor", readonly: true, isAvailable: function(editor) {return editor && editor.inMultiSelectMode} }]; diff --git a/lib/ace/config.js b/lib/ace/config.js index db36d59f..fe9312fd 100644 --- a/lib/ace/config.js +++ b/lib/ace/config.js @@ -34,10 +34,12 @@ define(function(require, exports, module) { var lang = require("./lib/lang"); var oop = require("./lib/oop"); var net = require("./lib/net"); -var EventEmitter = require("./lib/event_emitter").EventEmitter; +var AppConfig = require("./lib/app_config").AppConfig; + +module.exports = exports = new AppConfig(); var global = (function() { - return this; + return this || typeof window != "undefined" && window; })(); var options = { @@ -69,24 +71,32 @@ exports.all = function() { }; // module loading -oop.implement(exports, EventEmitter); - exports.moduleUrl = function(name, component) { if (options.$moduleUrls[name]) return options.$moduleUrls[name]; var parts = name.split("/"); component = component || parts[parts.length - 2] || ""; - var base = parts[parts.length - 1].replace(component, "").replace(/(^[\-_])|([\-_]$)/, ""); + + // todo make this configurable or get rid of '-' + var sep = component == "snippets" ? "/" : "-"; + var base = parts[parts.length - 1]; + if (component == "worker" && sep == "-") { + var re = new RegExp("^" + component + "[\\-_]|[\\-_]" + component + "$", "g"); + base = base.replace(re, ""); + } - if (!base && parts.length > 1) + if ((!base || base == component) && parts.length > 1) base = parts[parts.length - 2]; var path = options[component + "Path"]; - if (path == null) + if (path == null) { path = options.basePath; + } else if (sep == "/") { + component = sep = ""; + } if (path && path.slice(-1) != "/") path += "/"; - return path + component + "-" + base + this.get("suffix"); + return path + component + sep + base + this.get("suffix"); }; exports.setModuleUrl = function(name, subst) { @@ -103,7 +113,7 @@ exports.loadModule = function(moduleName, onLoad) { try { module = require(moduleName); - } catch (e) {}; + } catch (e) {} // require(moduleName) can return empty object if called after require([moduleName], callback) if (module && !exports.$loading[moduleName]) return onLoad && onLoad(module); @@ -132,10 +142,9 @@ exports.loadModule = function(moduleName, onLoad) { net.loadScript(exports.moduleUrl(moduleName, moduleType), afterLoad); }; - // initialization -exports.init = function() { - options.packaged = require.packaged || module.packaged || (global.define && define.packaged); +function init(packaged) { + options.packaged = packaged || require.packaged || module.packaged || (global.define && define.packaged); if (!global.document) return ""; @@ -143,7 +152,11 @@ exports.init = function() { var scriptOptions = {}; var scriptUrl = ""; - var scripts = document.getElementsByTagName("script"); + // Use currentScript.ownerDocument in case this file was loaded from imported document. (HTML Imports) + var currentScript = (document.currentScript || document._currentScript ); // native or polyfill + var currentDocument = currentScript && currentScript.ownerDocument || document; + + var scripts = currentDocument.getElementsByTagName("script"); for (var i=0; i .ace_gutter-cell { @@ -289,7 +324,7 @@ width: 11px; vertical-align: top; - background-image: url("data:image/png,%89PNG%0D%0A%1A%0A%00%00%00%0DIHDR%00%00%00%05%00%00%00%05%08%06%00%00%00%8Do%26%E5%00%00%004IDATx%DAe%8A%B1%0D%000%0C%C2%F2%2CK%96%BC%D0%8F9%81%88H%E9%D0%0E%96%C0%10%92%3E%02%80%5E%82%E4%A9*-%EEsw%C8%CC%11%EE%96w%D8%DC%E9*Eh%0C%151(%00%00%00%00IEND%AEB%60%82"); + background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAANElEQVR42mWKsQ0AMAzC8ixLlrzQjzmBiEjp0A6WwBCSPgKAXoLkqSot7nN3yMwR7pZ32NzpKkVoDBUxKAAAAABJRU5ErkJggg=="); background-repeat: no-repeat; background-position: center; @@ -304,26 +339,22 @@ } .ace_fold-widget.ace_end { - background-image: url("data:image/png,%89PNG%0D%0A%1A%0A%00%00%00%0DIHDR%00%00%00%05%00%00%00%05%08%06%00%00%00%8Do%26%E5%00%00%004IDATx%DAm%C7%C1%09%000%08C%D1%8C%ECE%C8E(%8E%EC%02)%1EZJ%F1%C1'%04%07I%E1%E5%EE%CAL%F5%A2%99%99%22%E2%D6%1FU%B5%FE0%D9x%A7%26Wz5%0E%D5%00%00%00%00IEND%AEB%60%82"); + background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAANElEQVR42m3HwQkAMAhD0YzsRchFKI7sAikeWkrxwScEB0nh5e7KTPWimZki4tYfVbX+MNl4pyZXejUO1QAAAABJRU5ErkJggg=="); } .ace_fold-widget.ace_closed { - background-image: url("data:image/png,%89PNG%0D%0A%1A%0A%00%00%00%0DIHDR%00%00%00%03%00%00%00%06%08%06%00%00%00%06%E5%24%0C%00%00%009IDATx%DA5%CA%C1%09%000%08%03%C0%AC*(%3E%04%C1%0D%BA%B1%23%A4Uh%E0%20%81%C0%CC%F8%82%81%AA%A2%AArGfr%88%08%11%11%1C%DD%7D%E0%EE%5B%F6%F6%CB%B8%05Q%2F%E9tai%D9%00%00%00%00IEND%AEB%60%82"); + background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAMAAAAGCAYAAAAG5SQMAAAAOUlEQVR42jXKwQkAMAgDwKwqKD4EwQ26sSOkVWjgIIHAzPiCgaqiqnJHZnKICBERHN194O5b9vbLuAVRL+l0YWnZAAAAAElFTkSuQmCCXA=="); } .ace_fold-widget:hover { border: 1px solid rgba(0, 0, 0, 0.3); background-color: rgba(255, 255, 255, 0.2); - -moz-box-shadow: 0 1px 1px rgba(255, 255, 255, 0.7); - -webkit-box-shadow: 0 1px 1px rgba(255, 255, 255, 0.7); box-shadow: 0 1px 1px rgba(255, 255, 255, 0.7); } .ace_fold-widget:active { border: 1px solid rgba(0, 0, 0, 0.4); background-color: rgba(0, 0, 0, 0.05); - -moz-box-shadow: 0 1px 1px rgba(255, 255, 255, 0.8); - -webkit-box-shadow: 0 1px 1px rgba(255, 255, 255, 0.8); box-shadow: 0 1px 1px rgba(255, 255, 255, 0.8); } /** @@ -343,8 +374,6 @@ background-color: rgba(255, 255, 255, 0.1); } .ace_dark .ace_fold-widget:active { - -moz-box-shadow: 0 1px 1px rgba(255, 255, 255, 0.2); - -webkit-box-shadow: 0 1px 1px rgba(255, 255, 255, 0.2); box-shadow: 0 1px 1px rgba(255, 255, 255, 0.2); } @@ -354,19 +383,13 @@ } .ace_fade-fold-widgets .ace_fold-widget { - -moz-transition: opacity 0.4s ease 0.05s; -webkit-transition: opacity 0.4s ease 0.05s; - -o-transition: opacity 0.4s ease 0.05s; - -ms-transition: opacity 0.4s ease 0.05s; transition: opacity 0.4s ease 0.05s; opacity: 0; } .ace_fade-fold-widgets:hover .ace_fold-widget { - -moz-transition: opacity 0.05s ease 0.05s; -webkit-transition: opacity 0.05s ease 0.05s; - -o-transition: opacity 0.05s ease 0.05s; - -ms-transition: opacity 0.05s ease 0.05s; transition: opacity 0.05s ease 0.05s; opacity:1; } @@ -386,3 +409,43 @@ .ace_italic { font-style: italic; } + + +.ace_error-marker { + background-color: rgba(255, 0, 0,0.2); + position: absolute; + z-index: 9; +} + +.ace_highlight-marker { + background-color: rgba(255, 255, 0,0.2); + position: absolute; + z-index: 8; +} + +/* +styles = [] +for (var i = 1; i < 16; i++) { + styles.push(".ace_br" + i + "{" + ( + ["top-left", "top-right", "bottom-right", "bottom-left"] + ).map(function(x, j) { + return i & (1<= length) { - position.row = Math.max(0, length - 1); - position.column = this.getLine(length-1).length; - } else if (position.row < 0) - position.row = 0; - return position; + // Deprecated methods retained for backwards compatibility. + this.insertLines = function(row, lines) { + console.warn("Use of document.insertLines is deprecated. Use the insertFullLines method instead."); + return this.insertFullLines(row, lines); + }; + this.removeLines = function(firstRow, lastRow) { + console.warn("Use of document.removeLines is deprecated. Use the removeFullLines method instead."); + return this.removeFullLines(firstRow, lastRow); + }; + this.insertNewLine = function(position) { + console.warn("Use of document.insertNewLine is deprecated. Use insertMergedLines(position, [\'\', \'\']) instead."); + return this.insertMergedLines(position, ["", ""]); }; /** @@ -241,53 +261,97 @@ var Document = function(text) { * **/ this.insert = function(position, text) { - if (!text || text.length === 0) - return position; - - position = this.$clipPosition(position); - - // only detect new lines if the document has no line break yet + // Only detect new lines if the document has no line break yet. if (this.getLength() <= 1) this.$detectNewLine(text); - - var lines = this.$split(text); - var firstLine = lines.splice(0, 1)[0]; - var lastLine = lines.length == 0 ? null : lines.splice(lines.length - 1, 1)[0]; - - position = this.insertInLine(position, firstLine); - if (lastLine !== null) { - position = this.insertNewLine(position); // terminate first line - position = this._insertLines(position.row, lines); - position = this.insertInLine(position, lastLine || ""); + + return this.insertMergedLines(position, this.$split(text)); + }; + + /** + * Inserts `text` into the `position` at the current row. This method also triggers the `"change"` event. + * + * This differs from the `insert` method in two ways: + * 1. This does NOT handle newline characters (single-line text only). + * 2. This is faster than the `insert` method for single-line text insertions. + * + * @param {Object} position The position to insert at; it's an object that looks like `{ row: row, column: column}` + * @param {String} text A chunk of text + * @returns {Object} Returns an object containing the final row and column, like this: + * ``` + * {row: endRow, column: 0} + * ``` + **/ + this.insertInLine = function(position, text) { + var start = this.clippedPos(position.row, position.column); + var end = this.pos(position.row, position.column + text.length); + + this.applyDelta({ + start: start, + end: end, + action: "insert", + lines: [text] + }, true); + + return this.clonePos(end); + }; + + this.clippedPos = function(row, column) { + var length = this.getLength(); + if (row === undefined) { + row = length; + } else if (row < 0) { + row = 0; + } else if (row >= length) { + row = length - 1; + column = undefined; + } + var line = this.getLine(row); + if (column == undefined) + column = line.length; + column = Math.min(Math.max(column, 0), line.length); + return {row: row, column: column}; + }; + + this.clonePos = function(pos) { + return {row: pos.row, column: pos.column}; + }; + + this.pos = function(row, column) { + return {row: row, column: column}; + }; + + this.$clipPosition = function(position) { + var length = this.getLength(); + if (position.row >= length) { + position.row = Math.max(0, length - 1); + position.column = this.getLine(length - 1).length; + } else { + position.row = Math.max(0, position.row); + position.column = Math.min(Math.max(position.column, 0), this.getLine(position.row).length); } return position; }; /** - * Fires whenever the document changes. - * - * Several methods trigger different `"change"` events. Below is a list of each action type, followed by each property that's also available: - * - * * `"insertLines"` (emitted by [[Document.insertLines]]) - * * `range`: the [[Range]] of the change within the document - * * `lines`: the lines in the document that are changing - * * `"insertText"` (emitted by [[Document.insertNewLine]]) - * * `range`: the [[Range]] of the change within the document - * * `text`: the text that's being added - * * `"removeLines"` (emitted by [[Document.insertLines]]) - * * `range`: the [[Range]] of the change within the document - * * `lines`: the lines in the document that were removed - * * `nl`: the new line character (as defined by [[Document.getNewLineCharacter]]) - * * `"removeText"` (emitted by [[Document.removeInLine]] and [[Document.removeNewLine]]) - * * `range`: the [[Range]] of the change within the document - * * `text`: the text that's being removed - * - * @event change - * @param {Object} e Contains at least one property called `"action"`. `"action"` indicates the action that triggered the change. Each action also has a set of additional properties. - * - **/ + * Fires whenever the document changes. + * + * Several methods trigger different `"change"` events. Below is a list of each action type, followed by each property that's also available: + * + * * `"insert"` + * * `range`: the [[Range]] of the change within the document + * * `lines`: the lines being added + * * `"remove"` + * * `range`: the [[Range]] of the change within the document + * * `lines`: the lines being removed + * + * @event change + * @param {Object} e Contains at least one property called `"action"`. `"action"` indicates the action that triggered the change. Each action also has a set of additional properties. + * + **/ + /** - * Inserts the elements in `lines` into the document, starting at the row index given by `row`. This method also triggers the `'change'` event. + * Inserts the elements in `lines` into the document as full lines (does not merge with existing line), starting at the row index given by `row`. This method also triggers the `"change"` event. * @param {Number} row The index of the row to insert at * @param {Array} lines An array of strings * @returns {Object} Contains the final row and column, like this: @@ -300,99 +364,57 @@ var Document = function(text) { * ``` * **/ - this.insertLines = function(row, lines) { - if (row >= this.getLength()) - return this.insert({row: row, column: 0}, "\n" + lines.join("\n")); - return this._insertLines(Math.max(row, 0), lines); - }; - this._insertLines = function(row, lines) { - if (lines.length == 0) - return {row: row, column: 0}; - - // apply doesn't work for big arrays (smallest threshold is on safari 0xFFFF) - // to circumvent that we have to break huge inserts into smaller chunks here - if (lines.length > 0xFFFF) { - var end = this._insertLines(row, lines.slice(0xFFFF)); - lines = lines.slice(0, 0xFFFF); + this.insertFullLines = function(row, lines) { + // Clip to document. + // Allow one past the document end. + row = Math.min(Math.max(row, 0), this.getLength()); + + // Calculate insertion point. + var column = 0; + if (row < this.getLength()) { + // Insert before the specified row. + lines = lines.concat([""]); + column = 0; + } else { + // Insert after the last row in the document. + lines = [""].concat(lines); + row--; + column = this.$lines[row].length; } + + // Insert. + this.insertMergedLines({row: row, column: column}, lines); + }; - var args = [row, 0]; - args.push.apply(args, lines); - this.$lines.splice.apply(this.$lines, args); - - var range = new Range(row, 0, row + lines.length, 0); - var delta = { - action: "insertLines", - range: range, + /** + * Inserts the elements in `lines` into the document, starting at the position index given by `row`. This method also triggers the `"change"` event. + * @param {Number} row The index of the row to insert at + * @param {Array} lines An array of strings + * @returns {Object} Contains the final row and column, like this: + * ``` + * {row: endRow, column: 0} + * ``` + * If `lines` is empty, this function returns an object containing the current row, and column, like this: + * ``` + * {row: row, column: 0} + * ``` + * + **/ + this.insertMergedLines = function(position, lines) { + var start = this.clippedPos(position.row, position.column); + var end = { + row: start.row + lines.length - 1, + column: (lines.length == 1 ? start.column : 0) + lines[lines.length - 1].length + }; + + this.applyDelta({ + start: start, + end: end, + action: "insert", lines: lines - }; - this._emit("change", { data: delta }); - return end || range.end; - }; - - /** - * Inserts a new line into the document at the current row's `position`. This method also triggers the `'change'` event. - * @param {Object} position The position to insert at - * @returns {Object} Returns an object containing the final row and column, like this:
    - * ``` - * {row: endRow, column: 0} - * ``` - * - **/ - this.insertNewLine = function(position) { - position = this.$clipPosition(position); - var line = this.$lines[position.row] || ""; - - this.$lines[position.row] = line.substring(0, position.column); - this.$lines.splice(position.row + 1, 0, line.substring(position.column, line.length)); - - var end = { - row : position.row + 1, - column : 0 - }; - - var delta = { - action: "insertText", - range: Range.fromPoints(position, end), - text: this.getNewLineCharacter() - }; - this._emit("change", { data: delta }); - - return end; - }; - - /** - * Inserts `text` into the `position` at the current row. This method also triggers the `'change'` event. - * @param {Object} position The position to insert at; it's an object that looks like `{ row: row, column: column}` - * @param {String} text A chunk of text - * @returns {Object} Returns an object containing the final row and column, like this: - * ``` - * {row: endRow, column: 0} - * ``` - * - **/ - this.insertInLine = function(position, text) { - if (text.length == 0) - return position; - - var line = this.$lines[position.row] || ""; - - this.$lines[position.row] = line.substring(0, position.column) + text - + line.substring(position.column); - - var end = { - row : position.row, - column : position.column + text.length - }; - - var delta = { - action: "insertText", - range: Range.fromPoints(position, end), - text: text - }; - this._emit("change", { data: delta }); - - return end; + }); + + return this.clonePos(end); }; /** @@ -402,111 +424,90 @@ var Document = function(text) { * **/ this.remove = function(range) { - // clip to document - range.start = this.$clipPosition(range.start); - range.end = this.$clipPosition(range.end); - - if (range.isEmpty()) - return range.start; - - var firstRow = range.start.row; - var lastRow = range.end.row; - - if (range.isMultiLine()) { - var firstFullRow = range.start.column == 0 ? firstRow : firstRow + 1; - var lastFullRow = lastRow - 1; - - if (range.end.column > 0) - this.removeInLine(lastRow, 0, range.end.column); - - if (lastFullRow >= firstFullRow) - this._removeLines(firstFullRow, lastFullRow); - - if (firstFullRow != firstRow) { - this.removeInLine(firstRow, range.start.column, this.getLine(firstRow).length); - this.removeNewLine(range.start.row); - } - } - else { - this.removeInLine(firstRow, range.start.column, range.end.column); - } - return range.start; + var start = this.clippedPos(range.start.row, range.start.column); + var end = this.clippedPos(range.end.row, range.end.column); + this.applyDelta({ + start: start, + end: end, + action: "remove", + lines: this.getLinesForRange({start: start, end: end}) + }); + return this.clonePos(start); }; /** - * Removes the specified columns from the `row`. This method also triggers the `'change'` event. - * @param {Number} row The row to remove from - * @param {Number} startColumn The column to start removing at - * @param {Number} endColumn The column to stop removing at - * @returns {Object} Returns an object containing `startRow` and `startColumn`, indicating the new row and column values.
    If `startColumn` is equal to `endColumn`, this function returns nothing. - * - **/ + * Removes the specified columns from the `row`. This method also triggers a `"change"` event. + * @param {Number} row The row to remove from + * @param {Number} startColumn The column to start removing at + * @param {Number} endColumn The column to stop removing at + * @returns {Object} Returns an object containing `startRow` and `startColumn`, indicating the new row and column values.
    If `startColumn` is equal to `endColumn`, this function returns nothing. + * + **/ this.removeInLine = function(row, startColumn, endColumn) { - if (startColumn == endColumn) - return; - - var range = new Range(row, startColumn, row, endColumn); - var line = this.getLine(row); - var removed = line.substring(startColumn, endColumn); - var newLine = line.substring(0, startColumn) + line.substring(endColumn, line.length); - this.$lines.splice(row, 1, newLine); - - var delta = { - action: "removeText", - range: range, - text: removed - }; - this._emit("change", { data: delta }); - return range.start; + var start = this.clippedPos(row, startColumn); + var end = this.clippedPos(row, endColumn); + + this.applyDelta({ + start: start, + end: end, + action: "remove", + lines: this.getLinesForRange({start: start, end: end}) + }, true); + + return this.clonePos(start); }; /** - * Removes a range of full lines. This method also triggers the `'change'` event. + * Removes a range of full lines. This method also triggers the `"change"` event. * @param {Number} firstRow The first row to be removed * @param {Number} lastRow The last row to be removed * @returns {[String]} Returns all the removed lines. * **/ - this.removeLines = function(firstRow, lastRow) { - if (firstRow < 0 || lastRow >= this.getLength()) - return this.remove(new Range(firstRow, 0, lastRow + 1, 0)); - return this._removeLines(firstRow, lastRow); - }; - - this._removeLines = function(firstRow, lastRow) { - var range = new Range(firstRow, 0, lastRow + 1, 0); - var removed = this.$lines.splice(firstRow, lastRow - firstRow + 1); - - var delta = { - action: "removeLines", - range: range, - nl: this.getNewLineCharacter(), - lines: removed - }; - this._emit("change", { data: delta }); - return removed; + this.removeFullLines = function(firstRow, lastRow) { + // Clip to document. + firstRow = Math.min(Math.max(0, firstRow), this.getLength() - 1); + lastRow = Math.min(Math.max(0, lastRow ), this.getLength() - 1); + + // Calculate deletion range. + // Delete the ending new line unless we're at the end of the document. + // If we're at the end of the document, delete the starting new line. + var deleteFirstNewLine = lastRow == this.getLength() - 1 && firstRow > 0; + var deleteLastNewLine = lastRow < this.getLength() - 1; + var startRow = ( deleteFirstNewLine ? firstRow - 1 : firstRow ); + var startCol = ( deleteFirstNewLine ? this.getLine(startRow).length : 0 ); + var endRow = ( deleteLastNewLine ? lastRow + 1 : lastRow ); + var endCol = ( deleteLastNewLine ? 0 : this.getLine(endRow).length ); + var range = new Range(startRow, startCol, endRow, endCol); + + // Store delelted lines with bounding newlines ommitted (maintains previous behavior). + var deletedLines = this.$lines.slice(firstRow, lastRow + 1); + + this.applyDelta({ + start: range.start, + end: range.end, + action: "remove", + lines: this.getLinesForRange(range) + }); + + // Return the deleted lines. + return deletedLines; }; /** - * Removes the new line between `row` and the row immediately following it. This method also triggers the `'change'` event. + * Removes the new line between `row` and the row immediately following it. This method also triggers the `"change"` event. * @param {Number} row The row to check * **/ this.removeNewLine = function(row) { - var firstLine = this.getLine(row); - var secondLine = this.getLine(row+1); - - var range = new Range(row, firstLine.length, row+1, 0); - var line = firstLine + secondLine; - - this.$lines.splice(row, 2, line); - - var delta = { - action: "removeText", - range: range, - text: this.getNewLineCharacter() - }; - this._emit("change", { data: delta }); + if (row < this.getLength() - 1 && row >= 0) { + this.applyDelta({ + start: this.pos(row, this.getLine(row).length), + end: this.pos(row + 1, 0), + action: "remove", + lines: ["", ""] + }); + } }; /** @@ -520,7 +521,9 @@ var Document = function(text) { * **/ this.replace = function(range, text) { - if (text.length == 0 && range.isEmpty()) + if (!range instanceof Range) + range = Range.fromPoints(range.start, range.end); + if (text.length === 0 && range.isEmpty()) return range.start; // Shortcut: If the text we want to insert is the same as it is already @@ -529,55 +532,106 @@ var Document = function(text) { return range.end; this.remove(range); + var end; if (text) { - var end = this.insert(range.start, text); + end = this.insert(range.start, text); } else { end = range.start; } - + return end; }; /** - * Applies all the changes previously accumulated. These can be either `'includeText'`, `'insertLines'`, `'removeText'`, and `'removeLines'`. + * Applies all changes in `deltas` to the document. + * @param {Array} deltas An array of delta objects (can include "insert" and "remove" actions) **/ this.applyDeltas = function(deltas) { for (var i=0; i=0; i--) { - var delta = deltas[i]; - - var range = Range.fromPoints(delta.range.start, delta.range.end); - - if (delta.action == "insertLines") - this._removeLines(range.start.row, range.end.row - 1); - else if (delta.action == "insertText") - this.remove(range); - else if (delta.action == "removeLines") - this._insertLines(range.start.row, delta.lines); - else if (delta.action == "removeText") - this.insert(range.start, delta.text); + this.revertDelta(deltas[i]); } }; - + + /** + * Applies `delta` to the document. + * @param {Object} delta A delta object (can include "insert" and "remove" actions) + **/ + this.applyDelta = function(delta, doNotValidate) { + var isInsert = delta.action == "insert"; + // An empty range is a NOOP. + if (isInsert ? delta.lines.length <= 1 && !delta.lines[0] + : !Range.comparePoints(delta.start, delta.end)) { + return; + } + + if (isInsert && delta.lines.length > 20000) + this.$splitAndapplyLargeDelta(delta, 20000); + + // Apply. + applyDelta(this.$lines, delta, doNotValidate); + this._signal("change", delta); + }; + + this.$splitAndapplyLargeDelta = function(delta, MAX) { + // Split large insert deltas. This is necessary because: + // 1. We need to support splicing delta lines into the document via $lines.splice.apply(...) + // 2. fn.apply() doesn't work for a large number of params. The smallest threshold is on chrome 40 ~42000. + // we use 20000 to leave some space for actual stack + // + // To Do: Ideally we'd be consistent and also split 'delete' deltas. We don't do this now, because delete + // delta handling is too slow. If we make delete delta handling faster we can split all large deltas + // as shown in https://gist.github.com/aldendaniels/8367109#file-document-snippet-js + // If we do this, update validateDelta() to limit the number of lines in a delete delta. + var lines = delta.lines; + var l = lines.length; + var row = delta.start.row; + var column = delta.start.column; + var from = 0, to = 0; + do { + from = to; + to += MAX - 1; + var chunk = lines.slice(from, to); + if (to > l) { + // Update remaining delta. + delta.lines = chunk; + delta.start.row = row + from; + delta.start.column = column; + break; + } + chunk.push(""); + this.applyDelta({ + start: this.pos(row + from, column), + end: this.pos(row + to, column = 0), + action: delta.action, + lines: chunk + }, true); + } while(true); + }; + + /** + * Reverts `delta` from the document. + * @param {Object} delta A delta object (can include "insert" and "remove" actions) + **/ + this.revertDelta = function(delta) { + this.applyDelta({ + start: this.clonePos(delta.start), + end: this.clonePos(delta.end), + action: (delta.action == "insert" ? "remove" : "insert"), + lines: delta.lines.slice() + }); + }; + /** * Converts an index position in a document to a `{row, column}` object. * diff --git a/lib/ace/document_test.js b/lib/ace/document_test.js index 5c324db0..ada56cd2 100644 --- a/lib/ace/document_test.js +++ b/lib/ace/document_test.js @@ -46,7 +46,7 @@ module.exports = { var doc = new Document(["12", "34"]); var deltas = []; - doc.on("change", function(e) { deltas.push(e.data); }); + doc.on("change", function(e) { deltas.push(e); }); doc.insert({row: 0, column: 1}, "juhu"); assert.equal(doc.getValue(), ["1juhu2", "34"].join("\n")); @@ -63,9 +63,9 @@ module.exports = { var doc = new Document(["12", "34"]); var deltas = []; - doc.on("change", function(e) { deltas.push(e.data); }); + doc.on("change", function(e) { deltas.push(e); }); - doc.insertNewLine({row: 0, column: 1}); + doc.insertMergedLines({row: 0, column: 1}, ['', '']); assert.equal(doc.getValue(), ["1", "2", "34"].join("\n")); var d = deltas.concat(); @@ -80,9 +80,9 @@ module.exports = { var doc = new Document(["12", "34"]); var deltas = []; - doc.on("change", function(e) { deltas.push(e.data); }); + doc.on("change", function(e) { deltas.push(e); }); - doc.insertLines(0, ["aa", "bb"]); + doc.insertFullLines(0, ["aa", "bb"]); assert.equal(doc.getValue(), ["aa", "bb", "12", "34"].join("\n")); var d = deltas.concat(); @@ -97,9 +97,9 @@ module.exports = { var doc = new Document(["12", "34"]); var deltas = []; - doc.on("change", function(e) { deltas.push(e.data); }); + doc.on("change", function(e) { deltas.push(e); }); - doc.insertLines(2, ["aa", "bb"]); + doc.insertFullLines(2, ["aa", "bb"]); assert.equal(doc.getValue(), ["12", "34", "aa", "bb"].join("\n")); }, @@ -107,9 +107,9 @@ module.exports = { var doc = new Document(["12", "34"]); var deltas = []; - doc.on("change", function(e) { deltas.push(e.data); }); + doc.on("change", function(e) { deltas.push(e); }); - doc.insertLines(1, ["aa", "bb"]); + doc.insertFullLines(1, ["aa", "bb"]); assert.equal(doc.getValue(), ["12", "aa", "bb", "34"].join("\n")); var d = deltas.concat(); @@ -124,7 +124,7 @@ module.exports = { var doc = new Document(["12", "34"]); var deltas = []; - doc.on("change", function(e) { deltas.push(e.data); }); + doc.on("change", function(e) { deltas.push(e); }); doc.insert({row: 0, column: 0}, "aa\nbb\ncc"); assert.equal(doc.getValue(), ["aa", "bb", "cc12", "34"].join("\n")); @@ -141,9 +141,9 @@ module.exports = { var doc = new Document(["12", "34"]); var deltas = []; - doc.on("change", function(e) { deltas.push(e.data); }); + doc.on("change", function(e) { deltas.push(e); }); - doc.insert({row: 2, column: 0}, "aa\nbb\ncc"); + doc.insert({row: 1, column: 2}, "aa\nbb\ncc"); assert.equal(doc.getValue(), ["12", "34aa", "bb", "cc"].join("\n")); var d = deltas.concat(); @@ -158,7 +158,7 @@ module.exports = { var doc = new Document(["12", "34"]); var deltas = []; - doc.on("change", function(e) { deltas.push(e.data); }); + doc.on("change", function(e) { deltas.push(e); }); doc.insert({row: 0, column: 1}, "aa\nbb\ncc"); assert.equal(doc.getValue(), ["1aa", "bb", "cc2", "34"].join("\n")); @@ -175,7 +175,7 @@ module.exports = { var doc = new Document(["1234", "5678"]); var deltas = []; - doc.on("change", function(e) { deltas.push(e.data); }); + doc.on("change", function(e) { deltas.push(e); }); doc.remove(new Range(0, 1, 0, 3)); assert.equal(doc.getValue(), ["14", "5678"].join("\n")); @@ -192,7 +192,7 @@ module.exports = { var doc = new Document(["1234", "5678"]); var deltas = []; - doc.on("change", function(e) { deltas.push(e.data); }); + doc.on("change", function(e) { deltas.push(e); }); doc.remove(new Range(0, 4, 1, 0)); assert.equal(doc.getValue(), ["12345678"].join("\n")); @@ -209,7 +209,7 @@ module.exports = { var doc = new Document(["1234", "5678", "abcd"]); var deltas = []; - doc.on("change", function(e) { deltas.push(e.data); }); + doc.on("change", function(e) { deltas.push(e); }); doc.remove(new Range(0, 2, 2, 2)); assert.equal(doc.getValue(), ["12cd"].join("\n")); @@ -226,7 +226,7 @@ module.exports = { var doc = new Document(["1234", "5678", "abcd"]); var deltas = []; - doc.on("change", function(e) { deltas.push(e.data); }); + doc.on("change", function(e) { deltas.push(e); }); doc.remove(new Range(1, 0, 3, 0)); assert.equal(doc.getValue(), ["1234", ""].join("\n")); @@ -235,7 +235,7 @@ module.exports = { "test: remove lines should return the removed lines" : function() { var doc = new Document(["1234", "5678", "abcd"]); - var removed = doc.removeLines(1, 2); + var removed = doc.removeFullLines(1, 2); assert.equal(removed.join("\n"), ["5678", "abcd"].join("\n")); }, @@ -296,6 +296,35 @@ module.exports = { "test: empty document has to contain one line": function() { var doc = new Document(""); assert.equal(doc.$lines.length, 1); + }, + + "test: ignore empty delta": function() { + var doc = new Document(""); + doc.on("change", function() { + throw "should ignore empty delta"; + }) + doc.insert({row: 0, column: 0}, ""); + doc.insert({row: 1, column: 1}, ""); + doc.remove({start: {row: 1, column: 1}, end: {row: 1, column: 1}}); + }, + + "test: inserting huge delta": function() { + var doc = new Document(""); + var val = ""; + var MAX = 0xF000; + for (var i = 0; i < 10 * MAX; i++) { + val += i + "\n" + } + doc.setValue(val); + assert.equal(doc.getValue(), val); + + for (var i = 3 * MAX + 2; i >= 3 * MAX - 2; i--) { + val = doc.getLines(0, i).join("\n"); + doc.setValue("\nab"); + assert.equal(doc.getValue(), "\nab"); + doc.insert({row: 1, column: 1}, val); + assert.equal(doc.getValue(), "\na" + val + "b"); + } } }; diff --git a/lib/ace/edit_session.js b/lib/ace/edit_session.js index c8cb43ff..2aa9b378 100644 --- a/lib/ace/edit_session.js +++ b/lib/ace/edit_session.js @@ -151,7 +151,7 @@ var EditSession = function(text, mode) { this.$foldData = []; this.$foldData.toString = function() { return this.join("\n"); - } + }; this.on("changeFold", this.onChangeFold.bind(this)); this.$onChange = this.onChange.bind(this); @@ -163,7 +163,7 @@ var EditSession = function(text, mode) { config.resetOptions(this); this.setMode(mode); - config._emit("session", this); + config._signal("session", this); }; @@ -249,13 +249,12 @@ var EditSession = function(text, mode) { this.$resetRowCache(fold.start.row); }; - this.onChange = function(e) { - var delta = e.data; + this.onChange = function(delta) { this.$modified = true; - this.$resetRowCache(delta.range.start.row); + this.$resetRowCache(delta.start.row); - var removedFolds = this.$updateInternalDataOnChange(e); + var removedFolds = this.$updateInternalDataOnChange(delta); if (!this.$fromUndo && this.$undoManager && !delta.ignore) { this.$deltasDoc.push(delta); if (removedFolds && removedFolds.length != 0) { @@ -268,26 +267,24 @@ var EditSession = function(text, mode) { this.$informUndoManager.schedule(); } - this.bgTokenizer.$updateOnChange(delta); - this._emit("change", e); + this.bgTokenizer && this.bgTokenizer.$updateOnChange(delta); + this._signal("change", delta); }; /** * Sets the session text. * @param {String} text The new text to place * - * - * **/ this.setValue = function(text) { this.doc.setValue(text); - this.selection.moveCursorTo(0, 0); - this.selection.clearSelection(); + this.selection.moveTo(0, 0); this.$resetRowCache(0); this.$deltas = []; this.$deltasDoc = []; this.$deltasFold = []; + this.setUndoManager(this.$undoManager); this.getUndoManager().reset(); }; @@ -406,12 +403,13 @@ var EditSession = function(text, mode) { if (self.$deltas.length > 0) { undoManager.execute({ action: "aceupdate", - args: [self.$deltas, self] + args: [self.$deltas, self], + merge: self.mergeUndoDeltas }); } - + self.mergeUndoDeltas = false; self.$deltas = []; - } + }; this.$informUndoManager = lang.delayedCall(this.$syncInformUndoManager); } }; @@ -461,14 +459,15 @@ var EditSession = function(text, mode) { * @returns {Boolean} **/ this.getUseSoftTabs = function() { - return this.$useSoftTabs; + // todo might need more general way for changing settings from mode, but this is ok for now + return this.$useSoftTabs && !this.$mode.$indentWithTabs; }; /** * Set the number of spaces that define a soft tab; for example, passing in `4` transforms the soft tabs to be equivalent to four spaces. This function also emits the `changeTabSize` event. * @param {Number} tabSize The new tab size **/ this.setTabSize = function(tabSize) { - this.setOption("tabSize", tabSize) + this.setOption("tabSize", tabSize); }; /** * Returns the current tab size. @@ -484,7 +483,7 @@ var EditSession = function(text, mode) { * **/ this.isTabStop = function(position) { - return this.$useSoftTabs && (position.column % this.$tabSize == 0); + return this.$useSoftTabs && (position.column % this.$tabSize === 0); }; this.$overwrite = false; @@ -498,7 +497,7 @@ var EditSession = function(text, mode) { * **/ this.setOverwrite = function(overwrite) { - this.setOption("overwrite", overwrite) + this.setOption("overwrite", overwrite); }; /** @@ -526,7 +525,7 @@ var EditSession = function(text, mode) { if (!this.$decorations[row]) this.$decorations[row] = ""; this.$decorations[row] += " " + className; - this._emit("changeBreakpoint", {}); + this._signal("changeBreakpoint", {}); }; /** @@ -538,7 +537,7 @@ var EditSession = function(text, mode) { **/ this.removeGutterDecoration = function(row, className) { this.$decorations[row] = (this.$decorations[row] || "").replace(" " + className, ""); - this._emit("changeBreakpoint", {}); + this._signal("changeBreakpoint", {}); }; /** @@ -561,7 +560,7 @@ var EditSession = function(text, mode) { for (var i=0; i width) + width = w.screenWidth; + }); + return this.lineWidgetWidth = width; + }; this.$computeWidth = function(force) { if (this.$modified || force) { @@ -1129,6 +1145,19 @@ var EditSession = function(text, mode) { this.remove = function(range) { return this.doc.remove(range); }; + + /** + * Removes a range of full lines. This method also triggers the `'change'` event. + * @param {Number} firstRow The first row to be removed + * @param {Number} lastRow The last row to be removed + * @returns {[String]} Returns all the removed lines. + * + * @related Document.removeFullLines + * + **/ + this.removeFullLines = function(firstRow, lastRow){ + return this.doc.removeFullLines(firstRow, lastRow); + }; /** * Reverts previous changes to your document. @@ -1205,39 +1234,36 @@ var EditSession = function(text, mode) { this.$getUndoSelection = function(deltas, isUndo, lastUndoRange) { function isInsert(delta) { - var insert = - delta.action === "insertText" || delta.action === "insertLines"; - return isUndo ? !insert : insert; + return isUndo ? delta.action !== "insert" : delta.action === "insert"; } var delta = deltas[0]; var range, point; var lastDeltaIsInsert = false; if (isInsert(delta)) { - range = delta.range.clone(); + range = Range.fromPoints(delta.start, delta.end); lastDeltaIsInsert = true; } else { - range = Range.fromPoints(delta.range.start, delta.range.start); + range = Range.fromPoints(delta.start, delta.start); lastDeltaIsInsert = false; } for (var i = 1; i < deltas.length; i++) { delta = deltas[i]; if (isInsert(delta)) { - point = delta.range.start; + point = delta.start; if (range.compare(point.row, point.column) == -1) { - range.setStart(delta.range.start); + range.setStart(point); } - point = delta.range.end; + point = delta.end; if (range.compare(point.row, point.column) == 1) { - range.setEnd(delta.range.end); + range.setEnd(point); } lastDeltaIsInsert = true; } else { - point = delta.range.start; + point = delta.start; if (range.compare(point.row, point.column) == -1) { - range = - Range.fromPoints(delta.range.start, delta.range.start); + range = Range.fromPoints(delta.start, delta.start); } lastDeltaIsInsert = false; } @@ -1246,6 +1272,11 @@ var EditSession = function(text, mode) { // Check if this range and the last undo range has something in common. // If true, merge the ranges. if (lastUndoRange != null) { + if (Range.comparePoints(lastUndoRange.start, range.start) === 0) { + lastUndoRange.start.column += range.end.column - range.start.column; + lastUndoRange.end.column += range.end.column - range.start.column; + } + var cmp = lastUndoRange.compareRange(range); if (cmp == 1) { range.setStart(lastUndoRange.start); @@ -1312,7 +1343,7 @@ var EditSession = function(text, mode) { } } - this.insert(toRange.start, text); + toRange.end = this.insert(toRange.start, text); if (folds.length) { var oldStart = fromRange.start; var newStart = toRange.start; @@ -1346,7 +1377,7 @@ var EditSession = function(text, mode) { this.indentRows = function(startRow, endRow, indentString) { indentString = indentString.replace(/\t/g, this.getTabString()); for (var row=startRow; row<=endRow; row++) - this.insert({row: row, column:0}, indentString); + this.doc.insertInLine({row: row, column: 0}, indentString); }; /** @@ -1403,11 +1434,11 @@ var EditSession = function(text, mode) { x.end.row += diff; return x; }); - + var lines = dir == 0 ? this.doc.getLines(firstRow, lastRow) - : this.doc.removeLines(firstRow, lastRow); - this.doc.insertLines(firstRow+diff, lines); + : this.doc.removeFullLines(firstRow, lastRow); + this.doc.insertFullLines(firstRow+diff, lines); folds.length && this.addFolds(folds); return diff; }; @@ -1417,8 +1448,6 @@ var EditSession = function(text, mode) { * @param {Number} lastRow The final row to move up * @returns {Number} If `firstRow` is less-than or equal to 0, this function returns 0. Otherwise, on success, it returns -1. * - * @related Document.insertLines - * **/ this.moveLinesUp = function(firstRow, lastRow) { return this.$moveLines(firstRow, lastRow, -1); @@ -1429,8 +1458,6 @@ var EditSession = function(text, mode) { * @param {Number} firstRow The starting row to move down * @param {Number} lastRow The final row to move down * @returns {Number} If `firstRow` is less-than or equal to 0, this function returns 0. Otherwise, on success, it returns -1. - * - * @related Document.insertLines **/ this.moveLinesDown = function(firstRow, lastRow) { return this.$moveLines(firstRow, lastRow, 1); @@ -1529,14 +1556,11 @@ var EditSession = function(text, mode) { // If wrapMode is activaed, the wrapData array has to be initialized. if (useWrapMode) { var len = this.getLength(); - this.$wrapData = []; - for (var i = 0; i < len; i++) { - this.$wrapData.push([]); - } + this.$wrapData = Array(len); this.$updateWrapData(0, len - 1); } - this._emit("changeWrapMode"); + this._signal("changeWrapMode"); } }; @@ -1561,11 +1585,11 @@ var EditSession = function(text, mode) { **/ this.setWrapLimitRange = function(min, max) { if (this.$wrapLimitRange.min !== min || this.$wrapLimitRange.max !== max) { - this.$wrapLimitRange.min = min; - this.$wrapLimitRange.max = max; + this.$wrapLimitRange = { min: min, max: max }; this.$modified = true; // This will force a recalculation of the wrap limit - this._emit("changeWrapMode"); + if (this.$useWrapMode) + this._signal("changeWrapMode"); } }; @@ -1577,7 +1601,7 @@ var EditSession = function(text, mode) { * @private **/ this.adjustWrapLimit = function(desiredLimit, $printMargin) { - var limits = this.$wrapLimitRange + var limits = this.$wrapLimitRange; if (limits.max < 0) limits = {min: $printMargin, max: $printMargin}; var wrapLimit = this.$constrainWrapLimit(desiredLimit, limits.min, limits.max); @@ -1587,7 +1611,7 @@ var EditSession = function(text, mode) { if (this.$useWrapMode) { this.$updateWrapData(0, this.getLength() - 1); this.$resetRowCache(0); - this._emit("changeWrapLimit"); + this._signal("changeWrapLimit"); } return true; } @@ -1637,34 +1661,23 @@ var EditSession = function(text, mode) { }; }; - this.$updateInternalDataOnChange = function(e) { + this.$updateInternalDataOnChange = function(delta) { var useWrapMode = this.$useWrapMode; - var len; - var action = e.data.action; - var firstRow = e.data.range.start.row; - var lastRow = e.data.range.end.row; - var start = e.data.range.start; - var end = e.data.range.end; + var action = delta.action; + var start = delta.start; + var end = delta.end; + var firstRow = start.row; + var lastRow = end.row; + var len = lastRow - firstRow; var removedFolds = null; - - if (action.indexOf("Lines") != -1) { - if (action == "insertLines") { - lastRow = firstRow + (e.data.lines.length); - } else { - lastRow = firstRow; - } - len = e.data.lines ? e.data.lines.length : lastRow - firstRow; - } else { - len = lastRow - firstRow; - } - + this.$updating = true; if (len != 0) { - if (action.indexOf("remove") != -1) { + if (action === "remove") { this[useWrapMode ? "$wrapData" : "$rowLengthCache"].splice(firstRow, len); var foldLines = this.$foldData; - removedFolds = this.getFoldsInRange(e.data.range); + removedFolds = this.getFoldsInRange(delta); this.removeFolds(removedFolds); var foldLine = this.getFoldLine(end.row); @@ -1690,16 +1703,10 @@ var EditSession = function(text, mode) { lastRow = firstRow; } else { - var args; - if (useWrapMode) { - args = [firstRow, 0]; - for (var i = 0; i < len; i++) args.push([]); - this.$wrapData.splice.apply(this.$wrapData, args); - } else { - args = Array(len); - args.unshift(firstRow, 0); - this.$rowLengthCache.splice.apply(this.$rowLengthCache, args); - } + var args = Array(len); + args.unshift(firstRow, 0); + var arr = useWrapMode ? this.$wrapData : this.$rowLengthCache + arr.splice.apply(arr, args); // If some new line is added inside of a foldLine, then split // the fold line up. @@ -1707,13 +1714,14 @@ var EditSession = function(text, mode) { var foldLine = this.getFoldLine(firstRow); var idx = 0; if (foldLine) { - var cmp = foldLine.range.compareInside(start.row, start.column) + var cmp = foldLine.range.compareInside(start.row, start.column); // Inside of the foldLine range. Need to split stuff up. if (cmp == 0) { foldLine = foldLine.split(start.row, start.column); - foldLine.shiftRow(len); - foldLine.addRemoveChars( - lastRow, 0, end.column - start.column); + if (foldLine) { + foldLine.shiftRow(len); + foldLine.addRemoveChars(lastRow, 0, end.column - start.column); + } } else // Infront of the foldLine but same row. Need to shift column. if (cmp == -1) { @@ -1734,10 +1742,10 @@ var EditSession = function(text, mode) { } else { // Realign folds. E.g. if you add some new chars before a fold, the // fold should "move" to the right. - len = Math.abs(e.data.range.start.column - e.data.range.end.column); - if (action.indexOf("remove") != -1) { + len = Math.abs(delta.start.column - delta.end.column); + if (action === "remove") { // Get all the folds in the change range and remove them. - removedFolds = this.getFoldsInRange(e.data.range); + removedFolds = this.getFoldsInRange(delta); this.removeFolds(removedFolds); len = -len; @@ -1779,7 +1787,7 @@ var EditSession = function(text, mode) { while (row <= lastRow) { foldLine = this.getFoldLine(row, foldLine); if (!foldLine) { - tokens = this.$getDisplayTokens(lang.stringTrimRight(lines[row])); + tokens = this.$getDisplayTokens(lines[row]); wrapData[row] = this.$computeWrapSplits(tokens, wrapLimit, tabSize); row ++; } else { @@ -1803,12 +1811,8 @@ var EditSession = function(text, mode) { foldLine.end.row, lines[foldLine.end.row].length + 1 ); - // Remove spaces/tabs from the back of the token array. - while (tokens.length != 0 && tokens[tokens.length - 1] >= SPACE) - tokens.pop(); - wrapData[foldLine.start.row] - = this.$computeWrapSplits(tokens, wrapLimit, tabSize); + wrapData[foldLine.start.row] = this.$computeWrapSplits(tokens, wrapLimit, tabSize); row = foldLine.end.row + 1; } } @@ -1825,7 +1829,7 @@ var EditSession = function(text, mode) { TAB_SPACE = 12; - this.$computeWrapSplits = function(tokens, wrapLimit) { + this.$computeWrapSplits = function(tokens, wrapLimit, tabSize) { if (tokens.length == 0) { return []; } @@ -1834,6 +1838,33 @@ var EditSession = function(text, mode) { var displayLength = tokens.length; var lastSplit = 0, lastDocSplit = 0; + var isCode = this.$wrapAsCode; + + var indentedSoftWrap = this.$indentedSoftWrap; + var maxIndent = wrapLimit <= Math.max(2 * tabSize, 8) + || indentedSoftWrap === false ? 0 : Math.floor(wrapLimit / 2); + + function getWrapIndent() { + var indentation = 0; + if (maxIndent === 0) + return indentation; + if (indentedSoftWrap) { + for (var i = 0; i < tokens.length; i++) { + var token = tokens[i]; + if (token == SPACE) + indentation += 1; + else if (token == TAB) + indentation += tabSize; + else if (token == TAB_SPACE) + continue; + else + break; + } + } + if (isCode && indentedSoftWrap !== false) + indentation += tabSize; + return Math.min(indentation, maxIndent); + } function addSplit(screenPos) { var displayed = tokens.slice(lastSplit, screenPos); @@ -1850,22 +1881,27 @@ var EditSession = function(text, mode) { len -= 1; }); + if (!splits.length) { + indent = getWrapIndent(); + splits.indent = indent; + } lastDocSplit += len; splits.push(lastDocSplit); lastSplit = screenPos; } - - while (displayLength - lastSplit > wrapLimit) { + var indent = 0; + while (displayLength - lastSplit > wrapLimit - indent) { // This is, where the split should be. - var split = lastSplit + wrapLimit; + var split = lastSplit + wrapLimit - indent; // If there is a space or tab at this split position, then making // a split is simple. - if (tokens[split] >= SPACE) { + if (tokens[split - 1] >= SPACE && tokens[split] >= SPACE) { + /* disabled see https://github.com/ajaxorg/ace/issues/1186 // Include all following spaces + tabs in this split as well. while (tokens[split] >= SPACE) { split ++; - } + } */ addSplit(split); continue; } @@ -1874,9 +1910,7 @@ var EditSession = function(text, mode) { // Check if split is inside of a placeholder. Placeholder are // not splitable. Therefore, seek the beginning of the placeholder // and try to place the split beofre the placeholder's start. - if (tokens[split] == PLACEHOLDER_START - || tokens[split] == PLACEHOLDER_BODY) - { + if (tokens[split] == PLACEHOLDER_START || tokens[split] == PLACEHOLDER_BODY) { // Seek the start of the placeholder and do the split // before the placeholder. By definition there always // a PLACEHOLDER_START between split and lastSplit. @@ -1900,8 +1934,7 @@ var EditSession = function(text, mode) { // placeholder. So, let's seek for the end of the placeholder. split = lastSplit + wrapLimit; for (split; split < tokens.length; split++) { - if (tokens[split] != PLACEHOLDER_BODY) - { + if (tokens[split] != PLACEHOLDER_BODY) { break; } } @@ -1919,12 +1952,21 @@ var EditSession = function(text, mode) { // === ELSE === // Search for the first non space/tab/placeholder/punctuation token backwards. - var minSplit = Math.max(split - 10, lastSplit - 1); + var minSplit = Math.max(split - (wrapLimit -(wrapLimit>>2)), lastSplit - 1); while (split > minSplit && tokens[split] < PLACEHOLDER_START) { split --; } - while (split > minSplit && tokens[split] == PUNCTUATION) { - split --; + if (isCode) { + while (split > minSplit && tokens[split] < PLACEHOLDER_START) { + split --; + } + while (split > minSplit && tokens[split] == PUNCTUATION) { + split --; + } + } else { + while (split > minSplit && tokens[split] < SPACE) { + split --; + } } // If we found one, then add the split. if (split > minSplit) { @@ -1936,7 +1978,9 @@ var EditSession = function(text, mode) { split = lastSplit + wrapLimit; // The split is inside of a CHAR or CHAR_EXT token and no space // around -> force a split. - addSplit(split); + if (tokens[split] == CHAR_EXT) + split--; + addSplit(split - indent); } return splits; }; @@ -1988,9 +2032,6 @@ var EditSession = function(text, mode) { * The first position indicates the number of columns for `str` on screen.
    * The second value contains the position of the document column that this function read until. * - * - * - * **/ this.$getStringScreenWidth = function(str, maxScreenColumn, screenColumn) { if (maxScreenColumn == 0) @@ -2020,6 +2061,7 @@ var EditSession = function(text, mode) { return [screenColumn, column]; }; + this.lineWidgets = null; /** * Returns number of screenrows in a wrapped line. * @param {Number} row The row number to check @@ -2027,6 +2069,17 @@ var EditSession = function(text, mode) { * @returns {Number} **/ this.getRowLength = function(row) { + if (this.lineWidgets) + var h = this.lineWidgets[row] && this.lineWidgets[row].rowCount || 0; + else + h = 0 + if (!this.$useWrapMode || !this.$wrapData[row]) { + return 1 + h; + } else { + return this.$wrapData[row].length + 1 + h; + } + }; + this.getRowLineCount = function(row) { if (!this.$useWrapMode || !this.$wrapData[row]) { return 1; } else { @@ -2034,6 +2087,16 @@ var EditSession = function(text, mode) { } }; + this.getRowWrapIndent = function(screenRow) { + if (this.$useWrapMode) { + var pos = this.screenToDocumentPosition(screenRow, Number.MAX_VALUE); + var splits = this.$wrapData[pos.row]; + return splits.length && splits[0] < pos.column ? splits.indent : 0; + } else { + return 0; + } + } + /** * Returns the position (on screen) for the last character in the provided screen row. * @param {Number} screenRow The screen row to check @@ -2140,7 +2203,7 @@ var EditSession = function(text, mode) { while (row <= screenRow) { rowLength = this.getRowLength(docRow); - if (row + rowLength - 1 >= screenRow || docRow >= maxRow) { + if (row + rowLength > screenRow || docRow >= maxRow) { break; } else { row += rowLength; @@ -2166,24 +2229,26 @@ var EditSession = function(text, mode) { return { row: maxRow, column: this.getLine(maxRow).length - } + }; } else { line = this.getLine(docRow); foldLine = null; } - + var wrapIndent = 0; if (this.$useWrapMode) { var splits = this.$wrapData[docRow]; if (splits) { - column = splits[screenRow - row]; - if(screenRow > row && splits.length) { - docColumn = splits[screenRow - row - 1] || splits[splits.length - 1]; + var splitIndex = Math.floor(screenRow - row); + column = splits[splitIndex]; + if(splitIndex > 0 && splits.length) { + wrapIndent = splits.indent; + docColumn = splits[splitIndex - 1] || splits[splits.length - 1]; line = line.substring(docColumn); } } } - docColumn += this.$getStringScreenWidth(line, screenColumn)[1]; + docColumn += this.$getStringScreenWidth(line, screenColumn - wrapIndent)[1]; // We remove one character at the end so that the docColumn // position returned is not associated to the next row on the screen. @@ -2275,22 +2340,26 @@ var EditSession = function(text, mode) { textLine = this.getLine(docRow).substring(0, docColumn); foldStartRow = docRow; } + var wrapIndent = 0; // Clamp textLine if in wrapMode. if (this.$useWrapMode) { var wrapRow = this.$wrapData[foldStartRow]; - var screenRowOffset = 0; - while (textLine.length >= wrapRow[screenRowOffset]) { - screenRow ++; - screenRowOffset++; + if (wrapRow) { + var screenRowOffset = 0; + while (textLine.length >= wrapRow[screenRowOffset]) { + screenRow ++; + screenRowOffset++; + } + textLine = textLine.substring( + wrapRow[screenRowOffset - 1] || 0, textLine.length + ); + wrapIndent = screenRowOffset > 0 ? wrapRow.indent : 0; } - textLine = textLine.substring( - wrapRow[screenRowOffset - 1] || 0, textLine.length - ); } return { row: screenRow, - column: this.$getStringScreenWidth(textLine)[0] + column: wrapIndent + this.$getStringScreenWidth(textLine)[0] }; }; @@ -2339,7 +2408,8 @@ var EditSession = function(text, mode) { var foldStart = fold ? fold.start.row :Infinity; while (row < lastRow) { - screenRows += this.$wrapData[row].length + 1; + var splits = this.$wrapData[row]; + screenRows += splits ? splits.length + 1 : 1; row ++; if (row > foldStart) { row = fold.end.row+1; @@ -2349,16 +2419,31 @@ var EditSession = function(text, mode) { } } + // todo + if (this.lineWidgets) + screenRows += this.$getWidgetScreenLength(); + return screenRows; }; - - // For every keystroke this gets called once per char in the whole doc!! - // Wouldn't hurt to make it a bit faster for c >= 0x1100 - + /** * @private * */ + this.$setFontMetrics = function(fm) { + // todo + }; + + this.destroy = function() { + if (this.bgTokenizer) { + this.bgTokenizer.setDocument(null); + this.bgTokenizer = null; + } + this.$stopWorker(); + }; + + // For every keystroke this gets called once per char in the whole doc!! + // Wouldn't hurt to make it a bit faster for c >= 0x1100 function isFullWidth(c) { if (c < 0x1100) return false; @@ -2416,6 +2501,7 @@ config.defineOptions(EditSession.prototype, "session", { if (this.$wrap == value) return; + this.$wrap = value; if (!value) { this.setUseWrapMode(false); } else { @@ -2423,15 +2509,39 @@ config.defineOptions(EditSession.prototype, "session", { this.setWrapLimitRange(col, col); this.setUseWrapMode(true); } - this.$wrap = value; }, get: function() { - return this.getUseWrapMode() ? this.getWrapLimitRange().min || "free" : "off"; + if (this.getUseWrapMode()) { + if (this.$wrap == -1) + return "printMargin"; + if (!this.getWrapLimitRange().min) + return "free"; + return this.$wrap; + } + return "off"; }, handlesSet: true + }, + wrapMethod: { + // code|text|auto + set: function(val) { + val = val == "auto" + ? this.$mode.type != "text" + : val != "text"; + if (val != this.$wrapAsCode) { + this.$wrapAsCode = val; + if (this.$useWrapMode) { + this.$modified = true; + this.$resetRowCache(0); + this.$updateWrapData(0, this.getLength() - 1); + } + } + }, + initialValue: "auto" }, + indentedSoftWrap: { initialValue: true }, firstLineNumber: { - set: function() {this._emit("changeBreakpoint");}, + set: function() {this._signal("changeBreakpoint");}, initialValue: 1 }, useWorker: { @@ -2452,19 +2562,23 @@ config.defineOptions(EditSession.prototype, "session", { this.$modified = true; this.$rowLengthCache = []; this.$tabSize = tabSize; - this._emit("changeTabSize"); + this._signal("changeTabSize"); }, initialValue: 4, handlesSet: true }, overwrite: { - set: function(val) {this._emit("changeOverwrite");}, + set: function(val) {this._signal("changeOverwrite");}, initialValue: false }, newLineMode: { set: function(val) {this.doc.setNewLineMode(val)}, get: function() {return this.doc.getNewLineMode()}, handlesSet: true + }, + mode: { + set: function(val) { this.setMode(val) }, + get: function() { return this.$modeId } } }); diff --git a/lib/ace/edit_session/bracket_match.js b/lib/ace/edit_session/bracket_match.js index 825f6924..62a8499c 100644 --- a/lib/ace/edit_session/bracket_match.js +++ b/lib/ace/edit_session/bracket_match.js @@ -117,6 +117,7 @@ function BracketMatch() { typeRe = new RegExp( "(\\.?" + token.type.replace(".", "\\.").replace("rparen", ".paren") + .replace(/\b(?:end)\b/, "(?:start|begin|end)") + ")+" ); } @@ -173,6 +174,7 @@ function BracketMatch() { typeRe = new RegExp( "(\\.?" + token.type.replace(".", "\\.").replace("lparen", ".paren") + .replace(/\b(?:start|begin)\b/, "(?:start|begin|end)") + ")+" ); } diff --git a/lib/ace/edit_session/fold.js b/lib/ace/edit_session/fold.js index 0f898021..232101bd 100644 --- a/lib/ace/edit_session/fold.js +++ b/lib/ace/edit_session/fold.js @@ -78,7 +78,7 @@ oop.inherits(Fold, RangeList); return; if (!this.range.containsRange(fold)) - throw "A fold can't intersect already existing fold" + fold.range + this.range; + throw new Error("A fold can't intersect already existing fold" + fold.range + this.range); // transform fold to local coordinates consumeRange(fold, this.start); @@ -104,7 +104,7 @@ oop.inherits(Fold, RangeList); var afterEnd = this.subFolds[j]; if (cmp == 0) - throw "A fold can't intersect already existing fold" + fold.range + this.range; + throw new Error("A fold can't intersect already existing fold" + fold.range + this.range); var consumedFolds = this.subFolds.splice(i, j - i, fold); fold.setFoldLine(this.foldLine); diff --git a/lib/ace/edit_session/fold_line.js b/lib/ace/edit_session/fold_line.js index e9f732c4..9d73154d 100644 --- a/lib/ace/edit_session/fold_line.js +++ b/lib/ace/edit_session/fold_line.js @@ -44,7 +44,7 @@ function FoldLine(foldData, folds) { folds = this.folds = [ folds ]; } - var last = folds[folds.length - 1] + var last = folds[folds.length - 1]; this.range = new Range(folds[0].start.row, folds[0].start.column, last.end.row, last.end.column); this.start = this.range.start; @@ -66,12 +66,12 @@ function FoldLine(foldData, folds) { fold.start.row += shift; fold.end.row += shift; }); - } + }; this.addFold = function(fold) { if (fold.sameRow) { if (fold.start.row < this.startRow || fold.endRow > this.endRow) { - throw "Can't add a fold to this FoldLine as it has no connection"; + throw new Error("Can't add a fold to this FoldLine as it has no connection"); } this.folds.push(fold); this.folds.sort(function(a, b) { @@ -93,20 +93,20 @@ function FoldLine(foldData, folds) { this.start.row = fold.start.row; this.start.column = fold.start.column; } else { - throw "Trying to add fold to FoldRow that doesn't have a matching row"; + throw new Error("Trying to add fold to FoldRow that doesn't have a matching row"); } fold.foldLine = this; - } + }; this.containsRow = function(row) { return row >= this.start.row && row <= this.end.row; - } + }; this.walk = function(callback, endRow, endColumn) { var lastEnd = 0, folds = this.folds, fold, - comp, stop, isNewRow = true; + cmp, stop, isNewRow = true; if (endRow == null) { endRow = this.end.row; @@ -116,9 +116,9 @@ function FoldLine(foldData, folds) { for (var i = 0; i < folds.length; i++) { fold = folds[i]; - comp = fold.range.compareStart(endRow, endColumn); + cmp = fold.range.compareStart(endRow, endColumn); // This fold is after the endRow/Column. - if (comp == -1) { + if (cmp == -1) { callback(null, endRow, endColumn, lastEnd, isNewRow); return; } @@ -127,8 +127,8 @@ function FoldLine(foldData, folds) { stop = !stop && callback(fold.placeholder, fold.start.row, fold.start.column, lastEnd); // If the user requested to stop the walk or endRow/endColumn is - // inside of this fold (comp == 0), then end here. - if (stop || comp == 0) { + // inside of this fold (cmp == 0), then end here. + if (stop || cmp === 0) { return; } @@ -138,7 +138,7 @@ function FoldLine(foldData, folds) { lastEnd = fold.end.column; } callback(null, endRow, endColumn, lastEnd, isNewRow); - } + }; this.getNextFoldTo = function(row, column) { var fold, cmp; @@ -150,15 +150,15 @@ function FoldLine(foldData, folds) { fold: fold, kind: "after" }; - } else if (cmp == 0) { + } else if (cmp === 0) { return { fold: fold, kind: "inside" - } + }; } } return null; - } + }; this.addRemoveChars = function(row, column, len) { var ret = this.getNextFoldTo(row, column), @@ -175,7 +175,7 @@ function FoldLine(foldData, folds) { } else if (fold.start.row == row) { folds = this.folds; var i = folds.indexOf(fold); - if (i == 0) { + if (i === 0) { this.start.column += len; } for (i; i < folds.length; i++) { @@ -189,16 +189,18 @@ function FoldLine(foldData, folds) { this.end.column += len; } } - } + }; this.split = function(row, column) { - var fold = this.getNextFoldTo(row, column).fold; + var pos = this.getNextFoldTo(row, column); + + if (!pos || pos.kind == "inside") + return null; + + var fold = pos.fold; var folds = this.folds; var foldData = this.foldData; - - if (!fold) - return null; - + var i = folds.indexOf(fold); var foldBefore = folds[i - 1]; this.end.row = foldBefore.end.row; @@ -211,7 +213,7 @@ function FoldLine(foldData, folds) { var newFoldLine = new FoldLine(foldData, folds); foldData.splice(foldData.indexOf(this) + 1, 0, newFoldLine); return newFoldLine; - } + }; this.merge = function(foldLineNext) { var folds = foldLineNext.folds; @@ -222,7 +224,7 @@ function FoldLine(foldData, folds) { // it's merged now with foldLineNext. var foldData = this.foldData; foldData.splice(foldData.indexOf(foldLineNext), 1); - } + }; this.toString = function() { var ret = [this.range.toString() + ": [" ]; @@ -230,13 +232,12 @@ function FoldLine(foldData, folds) { this.folds.forEach(function(fold) { ret.push(" " + fold.toString()); }); - ret.push("]") + ret.push("]"); return ret.join("\n"); - } + }; this.idxToPosition = function(idx) { var lastFoldEndColumn = 0; - var fold; for (var i = 0; i < this.folds.length; i++) { var fold = this.folds[i]; @@ -261,7 +262,7 @@ function FoldLine(foldData, folds) { row: this.end.row, column: this.end.column + idx }; - } + }; }).call(FoldLine.prototype); exports.FoldLine = FoldLine; diff --git a/lib/ace/edit_session/folding.js b/lib/ace/edit_session/folding.js index e85d4f0c..77c0f22d 100644 --- a/lib/ace/edit_session/folding.js +++ b/lib/ace/edit_session/folding.js @@ -108,6 +108,18 @@ function Folding() { return foundFolds; }; + + this.getFoldsInRangeList = function(ranges) { + if (Array.isArray(ranges)) { + var folds = []; + ranges.forEach(function(range) { + folds = folds.concat(this.getFoldsInRange(range)); + }, this); + } else { + var folds = this.getFoldsInRange(ranges); + } + return folds; + } /* * Returns all folds in the document @@ -116,13 +128,9 @@ function Folding() { var folds = []; var foldLines = this.$foldData; - function addFold(fold) { - folds.push(fold); - } - for (var i = 0; i < foldLines.length; i++) for (var j = 0; j < foldLines[i].folds.length; j++) - addFold(foldLines[i].folds[j]); + folds.push(foldLines[i].folds[j]); return folds; }; @@ -272,21 +280,21 @@ function Folding() { var endColumn = fold.end.column; // --- Some checking --- - if (startRow == endRow && endColumn - startColumn < 2) - throw "The range has to be at least 2 characters width"; + if (!(startRow < endRow || + startRow == endRow && startColumn <= endColumn - 2)) + throw new Error("The range has to be at least 2 characters width"); var startFold = this.getFoldAt(startRow, startColumn, 1); var endFold = this.getFoldAt(endRow, endColumn, -1); if (startFold && endFold == startFold) return startFold.addSubFold(fold); - if ( - (startFold && !startFold.range.isStart(startRow, startColumn)) - || (endFold && !endFold.range.isEnd(endRow, endColumn)) - ) { - throw "A fold can't intersect already existing fold" + fold.range + startFold.range; - } - + if (startFold && !startFold.range.isStart(startRow, startColumn)) + this.removeFold(startFold); + + if (endFold && !endFold.range.isEnd(endRow, endColumn)) + this.removeFold(endFold); + // Check if there are folds in the range we create the new fold for. var folds = this.getFoldsInRange(fold.range); if (folds.length > 0) { @@ -412,7 +420,7 @@ function Folding() { }; this.expandFold = function(fold) { - this.removeFold(fold); + this.removeFold(fold); fold.subFolds.forEach(function(subFold) { fold.restoreRange(subFold); this.addFold(subFold); @@ -440,18 +448,21 @@ function Folding() { range = Range.fromPoints(location, location); else range = location; - - folds = this.getFoldsInRange(range); + + folds = this.getFoldsInRangeList(range); if (expandInner) { this.removeFolds(folds); } else { - // TODO: might need to remove and add folds in one go instead of using + var subFolds = folds; + // TODO: might be better to remove and add folds in one go instead of using // expandFolds several times. - while (folds.length) { - this.expandFolds(folds); - folds = this.getFoldsInRange(range); + while (subFolds.length) { + this.expandFolds(subFolds); + subFolds = this.getFoldsInRangeList(range); } } + if (folds.length) + return folds; }; /* @@ -473,15 +484,15 @@ function Folding() { }; this.getFoldDisplayLine = function(foldLine, endRow, endColumn, startRow, startColumn) { - if (startRow == null) { + if (startRow == null) startRow = foldLine.start.row; + if (startColumn == null) startColumn = 0; - } - - if (endRow == null) { + if (endRow == null) endRow = foldLine.end.row; + if (endColumn == null) endColumn = this.getLine(endRow).length; - } + // Build the textline using the FoldLine walker. var doc = this.doc; @@ -626,8 +637,11 @@ function Folding() { if (depth == undefined) depth = 100000; // JSON.stringify doesn't hanle Infinity var foldWidgets = this.foldWidgets; + if (!foldWidgets) + return; // mode doesn't support folding endRow = endRow || this.getLength(); - for (var row = startRow || 0; row < endRow; row++) { + startRow = startRow || 0; + for (var row = startRow; row < endRow; row++) { if (foldWidgets[row] == null) foldWidgets[row] = this.getFoldWidget(row); if (foldWidgets[row] != "start") @@ -636,11 +650,18 @@ function Folding() { var range = this.getFoldWidgetRange(row); // sometimes range can be incompatible with existing fold // TODO change addFold to return null istead of throwing - if (range && range.end.row <= endRow) try { - var fold = this.addFold("...", range); - fold.collapseChildren = depth; - } catch(e) {} - row = range.end.row; + if (range && range.isMultiLine() + && range.end.row <= endRow + && range.start.row >= startRow + ) { + row = range.end.row; + try { + // addFold can change the range + var fold = this.addFold("...", range); + if (fold) + fold.collapseChildren = depth; + } catch(e) {} + } } }; @@ -675,7 +696,8 @@ function Folding() { this.$foldMode = foldMode; - this.removeListener('change', this.$updateFoldWidgets); + this.off('change', this.$updateFoldWidgets); + this.off('tokenizerUpdate', this.$tokenizerUpdateFoldWidgets); this._emit("changeAnnotation"); if (!foldMode || this.$foldStyle == "manual") { @@ -688,8 +710,9 @@ function Folding() { this.getFoldWidgetRange = foldMode.getFoldWidgetRange.bind(foldMode, this, this.$foldStyle); this.$updateFoldWidgets = this.updateFoldWidgets.bind(this); + this.$tokenizerUpdateFoldWidgets = this.tokenizerUpdateFoldWidgets.bind(this); this.on('change', this.$updateFoldWidgets); - + this.on('tokenizerUpdate', this.$tokenizerUpdateFoldWidgets); }; this.getParentFoldRangeData = function (row, ignoreCurrent) { @@ -720,25 +743,39 @@ function Folding() { } this.onFoldWidgetClick = function(row, e) { + e = e.domEvent; + var options = { + children: e.shiftKey, + all: e.ctrlKey || e.metaKey, + siblings: e.altKey + }; + + var range = this.$toggleFoldWidget(row, options); + if (!range) { + var el = (e.target || e.srcElement) + if (el && /ace_fold-widget/.test(el.className)) + el.className += " ace_invalid"; + } + }; + + this.$toggleFoldWidget = function(row, options) { + if (!this.getFoldWidget) + return; var type = this.getFoldWidget(row); var line = this.getLine(row); - e = e.domEvent; - var children = e.shiftKey; - var all = e.ctrlKey || e.metaKey; - var siblings = e.altKey; var dir = type === "end" ? -1 : 1; var fold = this.getFoldAt(row, dir === -1 ? 0 : line.length, dir); if (fold) { - if (children || all) + if (options.children || options.all) this.removeFold(fold); else this.expandFold(fold); return; } - var range = this.getFoldWidgetRange(row); + var range = this.getFoldWidgetRange(row, true); // sometimes singleline folds can be missed by the code above if (range && !range.isMultiLine()) { fold = this.getFoldAt(range.start.row, range.start.column, 1); @@ -748,35 +785,57 @@ function Folding() { } } - if (siblings) { + if (options.siblings) { var data = this.getParentFoldRangeData(row); if (data.range) { var startRow = data.range.start.row + 1; var endRow = data.range.end.row; } - this.foldAll(startRow, endRow, all ? 10000 : 0); - } else if (children) { - var endRow = range ? range.end.row : this.getLength(); - this.foldAll(row + 1, range.end.row, all ? 10000 : 0); + this.foldAll(startRow, endRow, options.all ? 10000 : 0); + } else if (options.children) { + endRow = range ? range.end.row : this.getLength(); + this.foldAll(row + 1, endRow, options.all ? 10000 : 0); } else if (range) { - if (all) + if (options.all) range.collapseChildren = 10000; this.addFold("...", range); } - if (!range) - (e.target || e.srcElement).className += " ace_invalid" + return range; + }; + + + + this.toggleFoldWidget = function(toggleParent) { + var row = this.selection.getCursor().row; + row = this.getRowFoldStart(row); + var range = this.$toggleFoldWidget(row, {}); + + if (range) + return; + // handle toggleParent + var data = this.getParentFoldRangeData(row, true); + range = data.range || data.firstRange; + + if (range) { + row = range.start.row; + var fold = this.getFoldAt(row, this.getLine(row).length, 1); + + if (fold) { + this.removeFold(fold); + } else { + this.addFold("...", range); + } + } }; - this.updateFoldWidgets = function(e) { - var delta = e.data; - var range = delta.range; - var firstRow = range.start.row; - var len = range.end.row - firstRow; + this.updateFoldWidgets = function(delta) { + var firstRow = delta.start.row; + var len = delta.end.row - firstRow; if (len === 0) { this.foldWidgets[firstRow] = null; - } else if (delta.action == "removeText" || delta.action == "removeLines") { + } else if (delta.action == 'remove') { this.foldWidgets.splice(firstRow, len + 1, null); } else { var args = Array(len + 1); @@ -784,7 +843,13 @@ function Folding() { this.foldWidgets.splice.apply(this.foldWidgets, args); } }; - + this.tokenizerUpdateFoldWidgets = function(e) { + var rows = e.data; + if (rows.first != rows.last) { + if (this.foldWidgets.length > rows.first) + this.foldWidgets.splice(rows.first, this.foldWidgets.length); + } + } } exports.Folding = Folding; diff --git a/lib/ace/edit_session_test.js b/lib/ace/edit_session_test.js index fd1c0508..0b904b63 100644 --- a/lib/ace/edit_session_test.js +++ b/lib/ace/edit_session_test.js @@ -280,7 +280,7 @@ module.exports = { session.setUseWrapMode(true); session.setWrapLimitRange(12, 12); session.adjustWrapLimit(80); - + session.setOption("wrapMethod", "text"); assert.position(session.documentToScreenPosition(0, 11), 0, 11); assert.position(session.documentToScreenPosition(0, 12), 1, 0); }, @@ -380,17 +380,20 @@ module.exports = { line = lang.stringTrimRight(line); var tokens = EditSession.prototype.$getDisplayTokens(line); var splits = EditSession.prototype.$computeWrapSplits(tokens, wrapLimit, tabSize); - // console.log("String:", line, "Result:", splits, "Expected:", assertEqual); + console.log("String:", line, "Result:", splits, "Expected:", assertEqual); + assert.ok(splits.length == assertEqual.length); for (var i = 0; i < splits.length; i++) { assert.ok(splits[i] == assertEqual[i]); } } - + + EditSession.prototype.$wrapAsCode = true; + EditSession.prototype.$indentedSoftWrap = false; // Basic splitting. computeAndAssert("foo bar foo bar", [ 12 ]); computeAndAssert("foo bar f bar", [ 12 ]); - computeAndAssert("foo bar f r", [ 14 ]); + computeAndAssert("foo bar f r", [ 12 ]); // 14 if we enable computeAndAssert("foo bar foo bar foo bara foo", [12, 25]); // Don't split if there is only whitespaces/tabs at the end of the line. @@ -406,18 +409,32 @@ module.exports = { computeAndAssert("foo \t \tbar", [ 7 ]); // Ignore spaces/tabs at beginning of split. - computeAndAssert("foo \t \t \t \t bar", [ 14 ]); + computeAndAssert("foo \t \t \t \t bar", [ 7 ]); // 14 // Test wrapping for asian characters. computeAndAssert("ぁぁ", [1], 2); computeAndAssert(" ぁぁ", [1, 2], 2); computeAndAssert(" ぁ\tぁ", [1, 3], 2); - computeAndAssert(" ぁぁ\tぁ", [1, 4], 4); + computeAndAssert(" ぁぁ\tぁ", [2, 4], 4); + computeAndAssert("ぁぁ ぁぁ\tぁ", [3, 6], 6); // Test wrapping for punctuation. - computeAndAssert(" ab.c;ef++", [1, 3, 5, 7, 8], 2); + computeAndAssert(" ab.c;ef++", [2, 4, 6, 8], 2); + computeAndAssert(" ab.c;ef++", [3, 5, 8], 3); computeAndAssert(" a.b", [1, 2, 3], 1); computeAndAssert("#>>", [1, 2], 1); + + // Test wrapping for punctuation in + EditSession.prototype.$wrapAsCode = false; + computeAndAssert("ab cde, Juhu kinners", [3, 8, 13, 19], 6); + + // test indented wrapping + EditSession.prototype.$indentedSoftWrap = true; + computeAndAssert("foo bar foo bar foo bara foo", [12, 25]); + computeAndAssert("fooooooooooooooooooooooooooo", [12, 24]); + computeAndAssert("\t\tfoo bar fooooooooooobooooooo", [6, 10, 16, 22, 28]); + computeAndAssert("\t\t\tfoo bar fooooooooooobooooooo", [3, 7, 11, 17, 23, 29]); + computeAndAssert("\tfoo \t \t \t \t bar", [6, 12]); // 14 }, "test get longest line" : function() { @@ -425,12 +442,12 @@ module.exports = { session.setTabSize(4); assert.equal(session.getScreenWidth(), 2); - session.doc.insertNewLine({row: 0, column: Infinity}); - session.doc.insertLines(1, ["123"]); + session.doc.insertMergedLines({row: 0, column: Infinity}, ['', '']); + session.doc.insertFullLines(1, ["123"]); assert.equal(session.getScreenWidth(), 3); - session.doc.insertNewLine({row: 0, column: Infinity}); - session.doc.insertLines(1, ["\t\t"]); + session.doc.insertMergedLines({row: 0, column: Infinity}, ['', '']); + session.doc.insertFullLines(1, ["\t\t"]); assert.equal(session.getScreenWidth(), 8); @@ -454,9 +471,9 @@ module.exports = { session.setUseWrapMode(true); - document.insertLines(0, ["a", "b"]); - document.insertLines(2, ["c", "d"]); - document.removeLines(1, 2); + document.insertFullLines(0, ["a", "b"]); + document.insertFullLines(2, ["c", "d"]); + document.removeFullLines(1, 2); }, "test wrapMode init has to create wrapData array": function() { @@ -932,7 +949,7 @@ module.exports = { fail = true; } if (fail != shouldFail) { - throw "Expected to get an exception"; + throw new Error("Expected to get an exception"); } } @@ -1037,11 +1054,34 @@ module.exports = { assertArray(session.getAnnotations(), []); session.setAnnotations([annotation]); assertArray(session.getAnnotations(), [annotation]); + }, + + "test: mode loading" : function(next) { + if (!require.undef) { + console.log("Skipping test: This test only runs in the browser"); + next(); + return; + } + var session = new EditSession([]); + session.setMode("ace/mode/javascript"); + assert.equal(session.$modeid, "ace/mode/javascript"); + session.on("changeMode", function() { + assert.equal(session.$modeid, "ace/mode/javascript"); + }); + session.setMode("ace/mode/sh", function(mode) { + assert.ok(!mode); + }); + setTimeout(function() { + session.setMode("ace/mode/javascript", function(mode) { + session.setMode("ace/mode/javascript"); + assert.equal(session.$modeid, "ace/mode/javascript"); + next(); + }); + }, 0); } }; - }); if (typeof module !== "undefined" && module === require.main) { - require("asyncjs").test.testcase(module.exports).exec() + require("asyncjs").test.testcase(module.exports).exec(); } diff --git a/lib/ace/editor.js b/lib/ace/editor.js index 62a4c37f..5da8a961 100644 --- a/lib/ace/editor.js +++ b/lib/ace/editor.js @@ -48,10 +48,9 @@ var EventEmitter = require("./lib/event_emitter").EventEmitter; var CommandManager = require("./commands/command_manager").CommandManager; var defaultCommands = require("./commands/default_commands").commands; var config = require("./config"); +var TokenIterator = require("./token_iterator").TokenIterator; /** - * - * * The main entry point into the Ace functionality. * * The `Editor` manages the [[EditSession]] (which manages [[Document]]s), as well as the [[VirtualRenderer]], which draws everything to the screen. @@ -88,34 +87,169 @@ var Editor = function(renderer, session) { wrap: true }); + this.$historyTracker = this.$historyTracker.bind(this); + this.commands.on("exec", this.$historyTracker); + + this.$initOperationListeners(); + + this._$emitInputEvent = lang.delayedCall(function() { + this._signal("input", {}); + if (this.session && this.session.bgTokenizer) + this.session.bgTokenizer.scheduleStart(); + }.bind(this)); + + this.on("change", function(_, _self) { + _self._$emitInputEvent.schedule(31); + }); + this.setSession(session || new EditSession("")); config.resetOptions(this); - config._emit("editor", this); + config._signal("editor", this); }; (function(){ oop.implement(this, EventEmitter); + this.$initOperationListeners = function() { + function last(a) {return a[a.length - 1]} + + this.selections = []; + this.commands.on("exec", this.startOperation.bind(this), true); + this.commands.on("afterExec", this.endOperation.bind(this), true); + + this.$opResetTimer = lang.delayedCall(this.endOperation.bind(this)); + + this.on("change", function() { + this.curOp || this.startOperation(); + this.curOp.docChanged = true; + }.bind(this), true); + + this.on("changeSelection", function() { + this.curOp || this.startOperation(); + this.curOp.selectionChanged = true; + }.bind(this), true); + }; + + this.curOp = null; + this.prevOp = {}; + this.startOperation = function(commadEvent) { + if (this.curOp) { + if (!commadEvent || this.curOp.command) + return; + this.prevOp = this.curOp; + } + if (!commadEvent) { + this.previousCommand = null; + commadEvent = {}; + } + + this.$opResetTimer.schedule(); + this.curOp = { + command: commadEvent.command || {}, + args: commadEvent.args, + scrollTop: this.renderer.scrollTop + }; + if (this.curOp.command.name && this.curOp.command.scrollIntoView !== undefined) + this.$blockScrolling++; + }; + + this.endOperation = function(e) { + if (this.curOp) { + if (e && e.returnValue === false) + return this.curOp = null; + this._signal("beforeEndOperation"); + var command = this.curOp.command; + if (command.name && this.$blockScrolling > 0) + this.$blockScrolling--; + var scrollIntoView = command && command.scrollIntoView; + if (scrollIntoView) { + switch (scrollIntoView) { + case "center-animate": + scrollIntoView = "animate"; + /* fall through */ + case "center": + this.renderer.scrollCursorIntoView(null, 0.5); + break; + case "animate": + case "cursor": + this.renderer.scrollCursorIntoView(); + break; + case "selectionPart": + var range = this.selection.getRange(); + var config = this.renderer.layerConfig; + if (range.start.row >= config.lastRow || range.end.row <= config.firstRow) { + this.renderer.scrollSelectionIntoView(this.selection.anchor, this.selection.lead); + } + break; + default: + break; + } + if (scrollIntoView == "animate") + this.renderer.animateScrolling(this.curOp.scrollTop); + } + + this.prevOp = this.curOp; + this.curOp = null; + } + }; + + // TODO use property on commands instead of this + this.$mergeableCommands = ["backspace", "del", "insertstring"]; + this.$historyTracker = function(e) { + if (!this.$mergeUndoDeltas) + return; + + var prev = this.prevOp; + var mergeableCommands = this.$mergeableCommands; + // previous command was the same + var shouldMerge = prev.command && (e.command.name == prev.command.name); + if (e.command.name == "insertstring") { + var text = e.args; + if (this.mergeNextCommand === undefined) + this.mergeNextCommand = true; + + shouldMerge = shouldMerge + && this.mergeNextCommand // previous command allows to coalesce with + && (!/\s/.test(text) || /\s/.test(prev.args)); // previous insertion was of same type + + this.mergeNextCommand = true; + } else { + shouldMerge = shouldMerge + && mergeableCommands.indexOf(e.command.name) !== -1; // the command is mergeable + } + + if ( + this.$mergeUndoDeltas != "always" + && Date.now() - this.sequenceStartTime > 2000 + ) { + shouldMerge = false; // the sequence is too long + } + + if (shouldMerge) + this.session.mergeUndoDeltas = true; + else if (mergeableCommands.indexOf(e.command.name) !== -1) + this.sequenceStartTime = Date.now(); + }; + /** * Sets a new key handler, such as "vim" or "windows". * @param {String} keyboardHandler The new key handler * - * **/ - this.setKeyboardHandler = function(keyboardHandler) { - if (!keyboardHandler) { - this.keyBinding.setKeyboardHandler(null); - } else if (typeof keyboardHandler == "string") { + this.setKeyboardHandler = function(keyboardHandler, cb) { + if (keyboardHandler && typeof keyboardHandler === "string") { this.$keybindingId = keyboardHandler; var _self = this; config.loadModule(["keybinding", keyboardHandler], function(module) { if (_self.$keybindingId == keyboardHandler) _self.keyBinding.setKeyboardHandler(module && module.handler); + cb && cb(); }); } else { - delete this.$keybindingId; + this.$keybindingId = null; this.keyBinding.setKeyboardHandler(keyboardHandler); + cb && cb(); } }; @@ -135,20 +269,22 @@ var Editor = function(renderer, session) { * @event changeSession * @param {Object} e An object with two properties, `oldSession` and `session`, that represent the old and new [[EditSession]]s. * - * **/ /** * Sets a new editsession to use. This method also emits the `'changeSession'` event. * @param {EditSession} session The new session to use * - * **/ this.setSession = function(session) { if (this.session == session) return; + + // make sure operationEnd events are not emitted to wrong session + if (this.curOp) this.endOperation(); + this.curOp = {}; - if (this.session) { - var oldSession = this.session; + var oldSession = this.session; + if (oldSession) { this.session.removeEventListener("change", this.$onDocumentChange); this.session.removeEventListener("changeMode", this.$onChangeMode); this.session.removeEventListener("tokenizerUpdate", this.$onTokenizerUpdate); @@ -170,76 +306,85 @@ var Editor = function(renderer, session) { } this.session = session; + if (session) { + this.$onDocumentChange = this.onDocumentChange.bind(this); + session.addEventListener("change", this.$onDocumentChange); + this.renderer.setSession(session); + + this.$onChangeMode = this.onChangeMode.bind(this); + session.addEventListener("changeMode", this.$onChangeMode); + + this.$onTokenizerUpdate = this.onTokenizerUpdate.bind(this); + session.addEventListener("tokenizerUpdate", this.$onTokenizerUpdate); + + this.$onChangeTabSize = this.renderer.onChangeTabSize.bind(this.renderer); + session.addEventListener("changeTabSize", this.$onChangeTabSize); + + this.$onChangeWrapLimit = this.onChangeWrapLimit.bind(this); + session.addEventListener("changeWrapLimit", this.$onChangeWrapLimit); + + this.$onChangeWrapMode = this.onChangeWrapMode.bind(this); + session.addEventListener("changeWrapMode", this.$onChangeWrapMode); + + this.$onChangeFold = this.onChangeFold.bind(this); + session.addEventListener("changeFold", this.$onChangeFold); + + this.$onChangeFrontMarker = this.onChangeFrontMarker.bind(this); + this.session.addEventListener("changeFrontMarker", this.$onChangeFrontMarker); + + this.$onChangeBackMarker = this.onChangeBackMarker.bind(this); + this.session.addEventListener("changeBackMarker", this.$onChangeBackMarker); + + this.$onChangeBreakpoint = this.onChangeBreakpoint.bind(this); + this.session.addEventListener("changeBreakpoint", this.$onChangeBreakpoint); + + this.$onChangeAnnotation = this.onChangeAnnotation.bind(this); + this.session.addEventListener("changeAnnotation", this.$onChangeAnnotation); + + this.$onCursorChange = this.onCursorChange.bind(this); + this.session.addEventListener("changeOverwrite", this.$onCursorChange); + + this.$onScrollTopChange = this.onScrollTopChange.bind(this); + this.session.addEventListener("changeScrollTop", this.$onScrollTopChange); + + this.$onScrollLeftChange = this.onScrollLeftChange.bind(this); + this.session.addEventListener("changeScrollLeft", this.$onScrollLeftChange); + + this.selection = session.getSelection(); + this.selection.addEventListener("changeCursor", this.$onCursorChange); + + this.$onSelectionChange = this.onSelectionChange.bind(this); + this.selection.addEventListener("changeSelection", this.$onSelectionChange); + + this.onChangeMode(); + + this.$blockScrolling += 1; + this.onCursorChange(); + this.$blockScrolling -= 1; + + this.onScrollTopChange(); + this.onScrollLeftChange(); + this.onSelectionChange(); + this.onChangeFrontMarker(); + this.onChangeBackMarker(); + this.onChangeBreakpoint(); + this.onChangeAnnotation(); + this.session.getUseWrapMode() && this.renderer.adjustWrapLimit(); + this.renderer.updateFull(); + } else { + this.selection = null; + this.renderer.setSession(session); + } - this.$onDocumentChange = this.onDocumentChange.bind(this); - session.addEventListener("change", this.$onDocumentChange); - this.renderer.setSession(session); - - this.$onChangeMode = this.onChangeMode.bind(this); - session.addEventListener("changeMode", this.$onChangeMode); - - this.$onTokenizerUpdate = this.onTokenizerUpdate.bind(this); - session.addEventListener("tokenizerUpdate", this.$onTokenizerUpdate); - - this.$onChangeTabSize = this.renderer.onChangeTabSize.bind(this.renderer); - session.addEventListener("changeTabSize", this.$onChangeTabSize); - - this.$onChangeWrapLimit = this.onChangeWrapLimit.bind(this); - session.addEventListener("changeWrapLimit", this.$onChangeWrapLimit); - - this.$onChangeWrapMode = this.onChangeWrapMode.bind(this); - session.addEventListener("changeWrapMode", this.$onChangeWrapMode); - - this.$onChangeFold = this.onChangeFold.bind(this); - session.addEventListener("changeFold", this.$onChangeFold); - - this.$onChangeFrontMarker = this.onChangeFrontMarker.bind(this); - this.session.addEventListener("changeFrontMarker", this.$onChangeFrontMarker); - - this.$onChangeBackMarker = this.onChangeBackMarker.bind(this); - this.session.addEventListener("changeBackMarker", this.$onChangeBackMarker); - - this.$onChangeBreakpoint = this.onChangeBreakpoint.bind(this); - this.session.addEventListener("changeBreakpoint", this.$onChangeBreakpoint); - - this.$onChangeAnnotation = this.onChangeAnnotation.bind(this); - this.session.addEventListener("changeAnnotation", this.$onChangeAnnotation); - - this.$onCursorChange = this.onCursorChange.bind(this); - this.session.addEventListener("changeOverwrite", this.$onCursorChange); - - this.$onScrollTopChange = this.onScrollTopChange.bind(this); - this.session.addEventListener("changeScrollTop", this.$onScrollTopChange); - - this.$onScrollLeftChange = this.onScrollLeftChange.bind(this); - this.session.addEventListener("changeScrollLeft", this.$onScrollLeftChange); - - this.selection = session.getSelection(); - this.selection.addEventListener("changeCursor", this.$onCursorChange); - - this.$onSelectionChange = this.onSelectionChange.bind(this); - this.selection.addEventListener("changeSelection", this.$onSelectionChange); - - this.onChangeMode(); - - this.$blockScrolling += 1; - this.onCursorChange(); - this.$blockScrolling -= 1; - - this.onScrollTopChange(); - this.onScrollLeftChange(); - this.onSelectionChange(); - this.onChangeFrontMarker(); - this.onChangeBackMarker(); - this.onChangeBreakpoint(); - this.onChangeAnnotation(); - this.session.getUseWrapMode() && this.renderer.adjustWrapLimit(); - this.renderer.updateFull(); - - this._emit("changeSession", { + this._signal("changeSession", { session: session, oldSession: oldSession }); + + this.curOp = null; + + oldSession && oldSession._signal("changeEditor", {oldEditor: this}); + session && session._signal("changeEditor", {editor: this}); }; /** @@ -304,11 +449,10 @@ var Editor = function(renderer, session) { /** * {:VirtualRenderer.setTheme} * @param {String} theme The path to a theme - * - * + * @param {Function} cb optional callback called when theme is loaded **/ - this.setTheme = function(theme) { - this.renderer.setTheme(theme); + this.setTheme = function(theme, cb) { + this.renderer.setTheme(theme, cb); }; /** @@ -373,15 +517,105 @@ var Editor = function(renderer, session) { this.$highlightPending = true; setTimeout(function() { self.$highlightPending = false; - - var pos = self.session.findMatchingBracket(self.getCursorPosition()); + var session = self.session; + if (!session || !session.bgTokenizer) return; + var pos = session.findMatchingBracket(self.getCursorPosition()); if (pos) { - var range = new Range(pos.row, pos.column, pos.row, pos.column+1); - } else if (self.session.$mode.getMatching) { - var range = self.session.$mode.getMatching(self.session); + var range = new Range(pos.row, pos.column, pos.row, pos.column + 1); + } else if (session.$mode.getMatching) { + var range = session.$mode.getMatching(self.session); } if (range) - self.session.$bracketHighlight = self.session.addMarker(range, "ace_bracket", "text"); + session.$bracketHighlight = session.addMarker(range, "ace_bracket", "text"); + }, 50); + }; + + // todo: move to mode.getMatching + this.$highlightTags = function() { + if (this.$highlightTagPending) + return; + + // perform highlight async to not block the browser during navigation + var self = this; + this.$highlightTagPending = true; + setTimeout(function() { + self.$highlightTagPending = false; + + var session = self.session; + if (!session || !session.bgTokenizer) return; + + var pos = self.getCursorPosition(); + var iterator = new TokenIterator(self.session, pos.row, pos.column); + var token = iterator.getCurrentToken(); + + if (!token || !/\b(?:tag-open|tag-name)/.test(token.type)) { + session.removeMarker(session.$tagHighlight); + session.$tagHighlight = null; + return; + } + + if (token.type.indexOf("tag-open") != -1) { + token = iterator.stepForward(); + if (!token) + return; + } + + var tag = token.value; + var depth = 0; + var prevToken = iterator.stepBackward(); + + if (prevToken.value == '<'){ + //find closing tag + do { + prevToken = token; + token = iterator.stepForward(); + + if (token && token.value === tag && token.type.indexOf('tag-name') !== -1) { + if (prevToken.value === '<'){ + depth++; + } else if (prevToken.value === '= 0); + } else { + //find opening tag + do { + token = prevToken; + prevToken = iterator.stepBackward(); + + if (token && token.value === tag && token.type.indexOf('tag-name') !== -1) { + if (prevToken.value === '<') { + depth++; + } else if (prevToken.value === ' 1)) + highlight = false; } if (session.$highlightLineMarker && !highlight) { @@ -525,7 +762,7 @@ var Editor = function(renderer, session) { session.$highlightLineMarker.start.row = highlight.row; session.$highlightLineMarker.end.row = highlight.row; session.$highlightLineMarker.start.column = highlight.column; - session._emit("changeBackMarker"); + session._signal("changeBackMarker"); } }; @@ -545,10 +782,10 @@ var Editor = function(renderer, session) { this.$updateHighlightActiveLine(); } - var re = this.$highlightSelectedWord && this.$getSelectionHighLightRegexp() + var re = this.$highlightSelectedWord && this.$getSelectionHighLightRegexp(); this.session.highlight(re); - this._emit("changeSelection"); + this._signal("changeSelection"); }; this.$getSelectionHighLightRegexp = function() { @@ -625,25 +862,29 @@ var Editor = function(renderer, session) { this.renderer.updateFull(); }; + + /** + * Returns the string of text currently highlighted. + * @returns {String} + **/ + this.getSelectedText = function() { + return this.session.getTextRange(this.getSelectionRange()); + }; + /** * Emitted when text is copied. * @event copy * @param {String} text The copied text * - * **/ /** - * * Returns the string of text currently highlighted. * @returns {String} + * @deprecated Use getSelectedText instead. **/ - this.getCopyText = function() { - var text = ""; - if (!this.selection.isEmpty()) - text = this.session.getTextRange(this.getSelectionRange()); - - this._emit("copy", text); + var text = this.getSelectedText(); + this._signal("copy", text); return text; }; @@ -664,7 +905,7 @@ var Editor = function(renderer, session) { /** * Emitted when text is pasted. * @event paste - * @param {String} text The pasted text + * @param {Object} an object which contains one property, `text`, that represents the text to be pasted. Editing this property will alter the text that is pasted. * * **/ @@ -674,42 +915,69 @@ var Editor = function(renderer, session) { * * **/ - this.onPaste = function(text) { - // todo this should change when paste becomes a command - if (this.$readOnly) - return; - this._emit("paste", text); - this.insert(text); + this.onPaste = function(text, event) { + var e = {text: text, event: event}; + this.commands.exec("paste", this, e); + }; + + this.$handlePaste = function(e) { + if (typeof e == "string") + e = {text: e}; + this._signal("paste", e); + var text = e.text; + if (!this.inMultiSelectMode || this.inVirtualSelectionMode) { + this.insert(text); + } else { + var lines = text.split(/\r\n|\r|\n/); + var ranges = this.selection.rangeList.ranges; + + if (lines.length > ranges.length || lines.length < 2 || !lines[1]) + return this.commands.exec("insertstring", this, text); + + for (var i = ranges.length; i--;) { + var range = ranges[i]; + if (!range.isEmpty()) + this.session.remove(range); + + this.session.insert(range.start, lines[i]); + } + } }; - this.execCommand = function(command, args) { - this.commands.exec(command, this, args); + return this.commands.exec(command, this, args); }; /** * Inserts `text` into wherever the cursor is pointing. * @param {String} text The new text to add * - * **/ - this.insert = function(text) { + this.insert = function(text, pasted) { var session = this.session; var mode = session.getMode(); var cursor = this.getCursorPosition(); - if (this.getBehavioursEnabled()) { + if (this.getBehavioursEnabled() && !pasted) { // Get a transform if the current mode wants one. var transform = mode.transformAction(session.getState(cursor.row), 'insertion', this, session, text); - if (transform) + if (transform) { + if (text !== transform.text) { + this.session.mergeUndoDeltas = false; + this.$mergeNextCommand = false; + } text = transform.text; - } - text = text.replace("\t", this.session.getTabString()); + } + } + + if (text == "\t") + text = this.session.getTabString(); // remove selected text if (!this.selection.isEmpty()) { - cursor = this.session.remove(this.getSelectionRange()); + var range = this.getSelectionRange(); + cursor = this.session.remove(range); this.clearSelection(); } else if (this.session.getOverwrite()) { @@ -718,6 +986,13 @@ var Editor = function(renderer, session) { this.session.remove(range); } + if (text == "\n" || text == "\r\n") { + var line = session.getLine(cursor.row); + if (cursor.column > line.search(/\S|$/)) { + var d = line.substr(cursor.column).search(/\S|$/); + session.doc.removeInLine(cursor.row, cursor.column, cursor.column + d); + } + } this.clearSelection(); var start = cursor.column; @@ -740,44 +1015,10 @@ var Editor = function(renderer, session) { } } - // TODO disabled multiline auto indent - // possibly doing the indent before inserting the text - // if (cursor.row !== end.row) { if (session.getDocument().isNewLine(text)) { var lineIndent = mode.getNextLineIndent(lineState, line.slice(0, cursor.column), session.getTabString()); - this.moveCursorTo(cursor.row+1, 0); - - var size = session.getTabSize(); - var minIndent = Number.MAX_VALUE; - - for (var row = cursor.row + 1; row <= end.row; ++row) { - var indent = 0; - - line = session.getLine(row); - for (var i = 0; i < line.length; ++i) - if (line.charAt(i) == '\t') - indent += size; - else if (line.charAt(i) == ' ') - indent += 1; - else - break; - if (/[^\s]/.test(line)) - minIndent = Math.min(indent, minIndent); - } - - for (var row = cursor.row + 1; row <= end.row; ++row) { - var outdent = minIndent; - - line = session.getLine(row); - for (var i = 0; i < line.length && outdent > 0; ++i) - if (line.charAt(i) == '\t') - outdent -= size; - else if (line.charAt(i) == ' ') - outdent -= 1; - session.remove(new Range(row, 0, row, i)); - } - session.indentRows(cursor.row + 1, end.row, lineIndent); + session.insert({row: cursor.row+1, column: 0}, lineIndent); } if (shouldOutdent) mode.autoOutdent(lineState, session, cursor.row); @@ -894,6 +1135,7 @@ var Editor = function(renderer, session) { this.getHighlightGutterLine = function() { return this.getOption("highlightGutterLine"); }; + /** * Determines if the currently selected word should be highlighted. * @param {Boolean} shouldHighlight Set to `true` to highlight the currently selected word @@ -1055,7 +1297,7 @@ var Editor = function(renderer, session) { }; /** - * Removes words of text from the editor. A "word" is defined as a string of characters bookended by whitespace. + * Removes the current selection or one character. * @param {String} dir The direction of the deletion to occur, either "left" or "right" * **/ @@ -1072,6 +1314,16 @@ var Editor = function(renderer, session) { var session = this.session; var state = session.getState(range.start.row); var new_range = session.getMode().transformAction(state, 'deletion', this, session, range); + + if (range.end.column === 0) { + var text = session.getTextRange(range); + if (text[text.length - 1] == "\n") { + var line = session.getLine(range.end.row); + if (/^\s+$/.test(line)) { + range.end.column = line.length; + } + } + } if (new_range) range = new_range; } @@ -1209,23 +1461,37 @@ var Editor = function(renderer, session) { var session = this.session; var range = this.getSelectionRange(); - if (range.start.row < range.end.row || range.start.column < range.end.column) { + if (range.start.row < range.end.row) { var rows = this.$getSelectedRows(); session.indentRows(rows.first, rows.last, "\t"); - } else { - var indentString; - - if (this.session.getUseSoftTabs()) { - var size = session.getTabSize(), - position = this.getCursorPosition(), - column = session.documentToScreenColumn(position.row, position.column), - count = (size - column % size); - - indentString = lang.stringRepeat(" ", count); - } else - indentString = "\t"; - return this.insert(indentString); + return; + } else if (range.start.column < range.end.column) { + var text = session.getTextRange(range); + if (!/^\s+$/.test(text)) { + var rows = this.$getSelectedRows(); + session.indentRows(rows.first, rows.last, "\t"); + return; + } } + + var line = session.getLine(range.start.row); + var position = range.start; + var size = session.getTabSize(); + var column = session.documentToScreenColumn(position.row, position.column); + + if (this.session.getUseSoftTabs()) { + var count = (size - column % size); + var indentString = lang.stringRepeat(" ", count); + } else { + var count = column % size; + while (line[range.start.column] == " " && count) { + range.start.column--; + count--; + } + this.selection.setSelectionRange(range); + indentString = "\t"; + } + return this.insert(indentString); }; /** @@ -1291,19 +1557,19 @@ var Editor = function(renderer, session) { * Works like [[EditSession.getTokenAt]], except it returns a number. * @returns {Number} **/ - this.getNumberAt = function( row, column ) { - var _numberRx = /[\-]?[0-9]+(?:\.[0-9]+)?/g - _numberRx.lastIndex = 0 + this.getNumberAt = function(row, column) { + var _numberRx = /[\-]?[0-9]+(?:\.[0-9]+)?/g; + _numberRx.lastIndex = 0; - var s = this.session.getLine(row) + var s = this.session.getLine(row); while (_numberRx.lastIndex < column) { - var m = _numberRx.exec(s) + var m = _numberRx.exec(s); if(m.index <= column && m.index+m[0].length >= column){ var number = { value: m[0], start: m.index, end: m.index+m[0].length - } + }; return number; } } @@ -1363,15 +1629,7 @@ var Editor = function(renderer, session) { **/ this.removeLines = function() { var rows = this.$getSelectedRows(); - var range; - if (rows.first === 0 || rows.last+1 < this.session.getLength()) - range = new Range(rows.first, 0, rows.last+1, 0); - else - range = new Range( - rows.first-1, this.session.getLine(rows.first-1).length, - rows.last, this.session.getLine(rows.last).length - ); - this.session.remove(range); + this.session.removeFullLines(rows.first, rows.last); this.clearSelection(); }; @@ -1389,7 +1647,7 @@ var Editor = function(renderer, session) { range.start = point; range.end = endPoint; - sel.setSelectionRange(range, reverse) + sel.setSelectionRange(range, reverse); } }; @@ -1400,9 +1658,7 @@ var Editor = function(renderer, session) { * @related EditSession.moveLinesUp **/ this.moveLinesDown = function() { - this.$moveLines(function(firstRow, lastRow) { - return this.session.moveLinesDown(firstRow, lastRow); - }); + this.$moveLines(1, false); }; /** @@ -1411,9 +1667,7 @@ var Editor = function(renderer, session) { * @related EditSession.moveLinesDown **/ this.moveLinesUp = function() { - this.$moveLines(function(firstRow, lastRow) { - return this.session.moveLinesUp(firstRow, lastRow); - }); + this.$moveLines(-1, false); }; /** @@ -1427,8 +1681,8 @@ var Editor = function(renderer, session) { * @returns {Range} The new range where the text was moved to. * @related EditSession.moveText **/ - this.moveText = function(range, toPosition) { - return this.session.moveText(range, toPosition); + this.moveText = function(range, toPosition, copy) { + return this.session.moveText(range, toPosition, copy); }; /** @@ -1437,10 +1691,7 @@ var Editor = function(renderer, session) { * **/ this.copyLinesUp = function() { - this.$moveLines(function(firstRow, lastRow) { - this.session.duplicateLines(firstRow, lastRow); - return 0; - }); + this.$moveLines(-1, true); }; /** @@ -1450,51 +1701,61 @@ var Editor = function(renderer, session) { * **/ this.copyLinesDown = function() { - this.$moveLines(function(firstRow, lastRow) { - return this.session.duplicateLines(firstRow, lastRow); - }); + this.$moveLines(1, true); }; /** - * Executes a specific function, which can be anything that manipulates selected lines, such as copying them, duplicating them, or shifting them. - * @param {Function} mover A method to call on each selected row - * + * for internal use + * @ignore * **/ - this.$moveLines = function(mover) { + this.$moveLines = function(dir, copy) { + var rows, moved; var selection = this.selection; if (!selection.inMultiSelectMode || this.inVirtualSelectionMode) { var range = selection.toOrientedRange(); - var rows = this.$getSelectedRows(range); - var linesMoved = mover.call(this, rows.first, rows.last); - range.moveBy(linesMoved, 0); + rows = this.$getSelectedRows(range); + moved = this.session.$moveLines(rows.first, rows.last, copy ? 0 : dir); + if (copy && dir == -1) moved = 0; + range.moveBy(moved, 0); selection.fromOrientedRange(range); } else { var ranges = selection.rangeList.ranges; selection.rangeList.detach(this.session); - - for (var i = ranges.length; i--; ) { + this.inVirtualSelectionMode = true; + + var diff = 0; + var totalDiff = 0; + var l = ranges.length; + for (var i = 0; i < l; i++) { var rangeIndex = i; - var rows = ranges[i].collapseRows(); - var last = rows.end.row; - var first = rows.start.row; - while (i--) { - var rows = ranges[i].collapseRows(); - if (first - rows.end.row <= 1) - first = rows.end.row; - else + ranges[i].moveBy(diff, 0); + rows = this.$getSelectedRows(ranges[i]); + var first = rows.first; + var last = rows.last; + while (++i < l) { + if (totalDiff) ranges[i].moveBy(totalDiff, 0); + var subRows = this.$getSelectedRows(ranges[i]); + if (copy && subRows.first != last) break; + else if (!copy && subRows.first > last + 1) + break; + last = subRows.last; } - i++; - - var linesMoved = mover.call(this, first, last); - while (rangeIndex >= i) { - ranges[rangeIndex].moveBy(linesMoved, 0); - rangeIndex--; + i--; + diff = this.session.$moveLines(first, last, copy ? 0 : dir); + if (copy && dir == -1) rangeIndex = i + 1; + while (rangeIndex <= i) { + ranges[rangeIndex].moveBy(diff, 0); + rangeIndex++; } + if (!copy) diff = 0; + totalDiff += diff; } + selection.fromOrientedRange(selection.ranges[0]); selection.rangeList.attach(this.session); + this.inVirtualSelectionMode = false; } }; @@ -1507,12 +1768,12 @@ var Editor = function(renderer, session) { * * @returns {Object} **/ - this.$getSelectedRows = function() { - var range = this.getSelectionRange().collapseRows(); + this.$getSelectedRows = function(range) { + range = (range || this.getSelectionRange()).collapseRows(); return { - first: range.start.row, - last: range.end.row + first: this.session.getRowFoldStart(range.start.row), + last: this.session.getRowFoldEnd(range.end.row) }; }; @@ -1583,11 +1844,11 @@ var Editor = function(renderer, session) { var rows = dir * Math.floor(config.height / config.lineHeight); this.$blockScrolling++; - if (select == true) { + if (select === true) { this.selection.$moveSelection(function(){ this.moveCursorBy(rows, 0); }); - } else if (select == false) { + } else if (select === false) { this.selection.moveCursorBy(rows, 0); this.selection.clearSelection(); } @@ -1674,7 +1935,7 @@ var Editor = function(renderer, session) { var pos = { row: Math.floor(range.start.row + (range.end.row - range.start.row) / 2), column: Math.floor(range.start.column + (range.end.column - range.start.column) / 2) - } + }; this.renderer.alignCursor(pos, 0.5); }; @@ -1753,36 +2014,168 @@ var Editor = function(renderer, session) { }; /** - * Moves the cursor's row and column to the next matching bracket. + * Moves the cursor's row and column to the next matching bracket or HTML tag. * **/ - this.jumpToMatching = function(select) { + this.jumpToMatching = function(select, expand) { var cursor = this.getCursorPosition(); + var iterator = new TokenIterator(this.session, cursor.row, cursor.column); + var prevToken = iterator.getCurrentToken(); + var token = prevToken || iterator.stepForward(); - var range = this.session.getBracketRange(cursor); - if (!range) { - range = this.find({ - needle: /[{}()\[\]]/g, - preventScroll:true, - start: {row: cursor.row, column: cursor.column - 1} - }); - if (!range) + if (!token) return; + + //get next closing tag or bracket + var matchType; + var found = false; + var depth = {}; + var i = cursor.column - token.start; + var bracketType; + var brackets = { + ")": "(", + "(": "(", + "]": "[", + "[": "[", + "{": "{", + "}": "{" + }; + + do { + if (token.value.match(/[{}()\[\]]/g)) { + for (; i < token.value.length && !found; i++) { + if (!brackets[token.value[i]]) { + continue; + } + + bracketType = brackets[token.value[i]] + '.' + token.type.replace("rparen", "lparen"); + + if (isNaN(depth[bracketType])) { + depth[bracketType] = 0; + } + + switch (token.value[i]) { + case '(': + case '[': + case '{': + depth[bracketType]++; + break; + case ')': + case ']': + case '}': + depth[bracketType]--; + + if (depth[bracketType] === -1) { + matchType = 'bracket'; + found = true; + } + break; + } + } + } + else if (token && token.type.indexOf('tag-name') !== -1) { + if (isNaN(depth[token.value])) { + depth[token.value] = 0; + } + + if (prevToken.value === '<') { + depth[token.value]++; + } + else if (prevToken.value === '= 0; --i) { if(this.$tryReplace(ranges[i], replacement)) { @@ -2113,7 +2498,7 @@ var Editor = function(renderer, session) { var scrollTop = this.renderer.scrollTop; this.renderer.scrollSelectionIntoView(range.start, range.end, 0.5); - if (animate != false) + if (animate !== false) this.renderer.animateScrolling(scrollTop); }; @@ -2145,7 +2530,10 @@ var Editor = function(renderer, session) { **/ this.destroy = function() { this.renderer.destroy(); - this._emit("destroy", this); + this._signal("destroy", this); + if (this.session) { + this.session.destroy(); + } }; /** @@ -2153,7 +2541,7 @@ var Editor = function(renderer, session) { * @param {Boolean} enable default true **/ this.setAutoScrollEditorIntoView = function(enable) { - if (enable === false) + if (!enable) return; var rect; var self = this; @@ -2172,7 +2560,9 @@ var Editor = function(renderer, session) { rect = self.renderer.container.getBoundingClientRect(); }); var onAfterRender = this.renderer.on("afterRender", function() { - if (shouldScroll && rect && self.isFocused()) { + if (shouldScroll && rect && (self.isFocused() + || self.searchBox && self.searchBox.isFocused()) + ) { var renderer = self.renderer; var pos = renderer.$cursorLayer.$pixelPos; var config = renderer.layerConfig; @@ -2195,7 +2585,7 @@ var Editor = function(renderer, session) { } }); this.setAutoScrollEditorIntoView = function(enable) { - if (enable === true) + if (enable) return; delete this.setAutoScrollEditorIntoView; this.removeEventListener("changeSelection", onChangeSelection); @@ -2210,8 +2600,9 @@ var Editor = function(renderer, session) { var cursorLayer = this.renderer.$cursorLayer; if (!cursorLayer) return; - cursorLayer.setSmoothBlinking(style == "smooth"); + cursorLayer.setSmoothBlinking(/smooth/.test(style)); cursorLayer.isBlinking = !this.$readOnly && style != "wide"; + dom.setCssClass(cursorLayer.element, "ace_slim-cursors", /slim/.test(style)); }; }).call(Editor.prototype); @@ -2222,7 +2613,7 @@ config.defineOptions(Editor.prototype, "editor", { selectionStyle: { set: function(style) { this.onSelectionChange(); - this._emit("changeSelectionStyle", {data: style}); + this._signal("changeSelectionStyle", {data: style}); }, initialValue: "line" }, @@ -2235,7 +2626,11 @@ config.defineOptions(Editor.prototype, "editor", { initialValue: true }, readOnly: { - set: function(readOnly) { this.$resetCursorStyle(); }, + set: function(readOnly) { + // disabled to not break vim mode! + // this.textInput.setReadOnly(readOnly); + this.$resetCursorStyle(); + }, initialValue: false }, cursorStyle: { @@ -2243,10 +2638,18 @@ config.defineOptions(Editor.prototype, "editor", { values: ["ace", "slim", "smooth", "wide"], initialValue: "ace" }, + mergeUndoDeltas: { + values: [false, true, "always"], + initialValue: true + }, behavioursEnabled: {initialValue: true}, wrapBehavioursEnabled: {initialValue: true}, + autoScrollEditorIntoView: { + set: function(val) {this.setAutoScrollEditorIntoView(val)} + }, hScrollBarAlwaysVisible: "renderer", + vScrollBarAlwaysVisible: "renderer", highlightGutterLine: "renderer", animatedScroll: "renderer", showInvisibles: "renderer", @@ -2255,14 +2658,22 @@ config.defineOptions(Editor.prototype, "editor", { printMargin: "renderer", fadeFoldWidgets: "renderer", showFoldWidgets: "renderer", + showLineNumbers: "renderer", showGutter: "renderer", displayIndentGuides: "renderer", fontSize: "renderer", fontFamily: "renderer", + maxLines: "renderer", + minLines: "renderer", + scrollPastEnd: "renderer", + fixedWidthGutter: "renderer", + theme: "renderer", scrollSpeed: "$mouseHandler", dragDelay: "$mouseHandler", + dragEnabled: "$mouseHandler", focusTimout: "$mouseHandler", + tooltipFollowsMouse: "$mouseHandler", firstLineNumber: "session", overwrite: "session", @@ -2271,7 +2682,9 @@ config.defineOptions(Editor.prototype, "editor", { useSoftTabs: "session", tabSize: "session", wrap: "session", - foldStyle: "session" + indentedSoftWrap: "session", + foldStyle: "session", + mode: "session" }); exports.Editor = Editor; diff --git a/lib/ace/ext/beautify.js b/lib/ace/ext/beautify.js new file mode 100644 index 00000000..d0fa1799 --- /dev/null +++ b/lib/ace/ext/beautify.js @@ -0,0 +1,57 @@ +/* ***** 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. + * + * ***** END LICENSE BLOCK ***** */ + +// [WIP] + +define(function(require, exports, module) { +"use strict"; +var TokenIterator = require("ace/token_iterator").TokenIterator; + +var phpTransform = require("./beautify/php_rules").transform; + +exports.beautify = function(session) { + var iterator = new TokenIterator(session, 0, 0); + var token = iterator.getCurrentToken(); + + var context = session.$modeId.split("/").pop(); + + var code = phpTransform(iterator, context); + session.doc.setValue(code); +}; + +exports.commands = [{ + name: "beautify", + exec: function(editor) { + exports.beautify(editor.session); + }, + bindKey: "Ctrl-Shift-B" +}] + +}); \ No newline at end of file diff --git a/lib/ace/ext/beautify/php_rules.js b/lib/ace/ext/beautify/php_rules.js new file mode 100644 index 00000000..9a5bed36 --- /dev/null +++ b/lib/ace/ext/beautify/php_rules.js @@ -0,0 +1,366 @@ +/* ***** 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. + * + * ***** END LICENSE BLOCK ***** */ + +define(function(require, exports, module) { +"use strict"; +var TokenIterator = require("ace/token_iterator").TokenIterator; +exports.newLines = [{ + type: 'support.php_tag', + value: '' +}, { + type: 'paren.lparen', + value: '{', + indent: true +}, { + type: 'paren.rparen', + breakBefore: true, + value: '}', + indent: false +}, { + type: 'paren.rparen', + breakBefore: true, + value: '})', + indent: false, + dontBreak: true +}, { + type: 'comment' +}, { + type: 'text', + value: ';' +}, { + type: 'text', + value: ':', + context: 'php' +}, { + type: 'keyword', + value: 'case', + indent: true, + dontBreak: true +}, { + type: 'keyword', + value: 'default', + indent: true, + dontBreak: true +}, { + type: 'keyword', + value: 'break', + indent: false, + dontBreak: true +}, { + type: 'punctuation.doctype.end', + value: '>' +}, { + type: 'meta.tag.punctuation.end', + value: '>' +}, { + type: 'meta.tag.punctuation.begin', + value: '<', + blockTag: true, + indent: true, + dontBreak: true +}, { + type: 'meta.tag.punctuation.begin', + value: '' ){ + context = 'php'; + } + else if( token.type == 'support.php_tag' && token.value == '?>' ){ + context = 'html'; + } + //css + else if( token.type == 'meta.tag.name.style' && context != 'css' ){ + context = 'css'; + } + else if( token.type == 'meta.tag.name.style' && context == 'css' ){ + context = 'html'; + } + //js + else if( token.type == 'meta.tag.name.script' && context != 'js' ){ + context = 'js'; + } + else if( token.type == 'meta.tag.name.script' && context == 'js' ){ + context = 'html'; + } + + nextToken = iterator.stepForward(); + + //tag name + if (nextToken && nextToken.type.indexOf('meta.tag.name') == 0) { + nextTag = nextToken.value; + } + + //don't linebreak + if ( lastToken.type == 'support.php_tag' && lastToken.value == '' ) { + dontBreak = false; + } + + //next token + lastTag = tag; + + lastToken = token; + + token = nextToken; + + if (token===null) { + break; + } + } + + return code; +}; + + + +}); \ No newline at end of file diff --git a/lib/ace/ext/chromevox.js b/lib/ace/ext/chromevox.js new file mode 100644 index 00000000..52a180d4 --- /dev/null +++ b/lib/ace/ext/chromevox.js @@ -0,0 +1,979 @@ +define(function(require, exports, module) { + +/* ChromeVox Ace namespace. */ +var cvoxAce = {}; + +/* Typedefs for Closure compiler. */ +/** + * @typedef {{ + rate: number, + pitch: number, + volume: number, + relativePitch: number, + punctuationEcho: string + }} + */ +/* TODO(peterxiao): Export this typedef through cvox.Api. */ +cvoxAce.SpeechProperty; + +/** + * @typedef {{ + * row: number, + * column: number + * }} + */ +cvoxAce.Cursor; + +/** + * @typedef {{ + type: string, + value: string + }} + } + */ +cvoxAce.Token; + +/** + * These are errors and information that Ace will display in the gutter. + * @typedef {{ + row: number, + column: number, + value: string + }} + } + */ +cvoxAce.Annotation; + +/* Speech Properties. */ +/** + * Speech property for speaking constant tokens. + * @type {cvoxAce.SpeechProperty} + */ +var CONSTANT_PROP = { + 'rate': 0.8, + 'pitch': 0.4, + 'volume': 0.9 +}; + +/** + * Default speech property for speaking tokens. + * @type {cvoxAce.SpeechProperty} + */ +var DEFAULT_PROP = { + 'rate': 1, + 'pitch': 0.5, + 'volume': 0.9 +}; + +/** + * Speech property for speaking entity tokens. + * @type {cvoxAce.SpeechProperty} + */ +var ENTITY_PROP = { + 'rate': 0.8, + 'pitch': 0.8, + 'volume': 0.9 +}; + +/** + * Speech property for speaking keywords. + * @type {cvoxAce.SpeechProperty} + */ +var KEYWORD_PROP = { + 'rate': 0.8, + 'pitch': 0.3, + 'volume': 0.9 +}; + +/** + * Speech property for speaking storage tokens. + * @type {cvoxAce.SpeechProperty} + */ +var STORAGE_PROP = { + 'rate': 0.8, + 'pitch': 0.7, + 'volume': 0.9 +}; + +/** + * Speech property for speaking variable tokens. + * @type {cvoxAce.SpeechProperty} + */ +var VARIABLE_PROP = { + 'rate': 0.8, + 'pitch': 0.8, + 'volume': 0.9 +}; + +/** + * Speech property for speaking deleted text. + * @type {cvoxAce.SpeechProperty} + */ +var DELETED_PROP = { + 'punctuationEcho': 'none', + 'relativePitch': -0.6 +}; + +/* Constants for Earcons. */ +var ERROR_EARCON = 'ALERT_NONMODAL'; +var MODE_SWITCH_EARCON = 'ALERT_MODAL'; +var NO_MATCH_EARCON = 'INVALID_KEYPRESS'; + +/* Constants for vim state. */ +var INSERT_MODE_STATE = 'insertMode'; +var COMMAND_MODE_STATE = 'start'; + +var REPLACE_LIST = [ + { + substr: ';', + newSubstr: ' semicolon ' + }, + { + substr: ':', + newSubstr: ' colon ' + } +]; + +/** + * Context menu commands. + */ +var Command = { + SPEAK_ANNOT: 'annots', + SPEAK_ALL_ANNOTS: 'all_annots', + TOGGLE_LOCATION: 'toggle_location', + SPEAK_MODE: 'mode', + SPEAK_ROW_COL: 'row_col', + TOGGLE_DISPLACEMENT: 'toggle_displacement', + FOCUS_TEXT: 'focus_text' +}; + +/** + * Key prefix for each shortcut. + */ +var KEY_PREFIX = 'CONTROL + SHIFT '; + +/* Globals. */ +cvoxAce.editor = null; +/** + * Last cursor position. + * @type {cvoxAce.Cursor} + */ +var lastCursor = null; + +/** + * Table of annotations. + * @typedef {!Object.>} + */ +var annotTable = {}; + +/** + * Whether to speak character, word, and then line. This allows blind users + * to know the location of the cursor when they change lines. + * @typedef {boolean} + */ +var shouldSpeakRowLocation = false; + +/** + * Whether to speak displacement. + * @typedef {boolean} + */ +var shouldSpeakDisplacement = false; + +/** + * Whether text was changed to cause a cursor change event. + * @typedef {boolean} + */ +var changed = false; + +/** + * Current state vim is in. + */ +var vimState = null; + +/** + * Mapping from key code to shortcut. + */ +var keyCodeToShortcutMap = {}; + +/** + * Mapping from command to shortcut. + */ +var cmdToShortcutMap = {}; + +/** + * Get shortcut string from keyCode. + * @param {number} keyCode Key code of shortcut. + * @return {string} String representation of shortcut. + */ +var getKeyShortcutString = function(keyCode) { + return KEY_PREFIX + String.fromCharCode(keyCode); +}; + +/** + * Return if in vim mode. + * @return {boolean} True if in Vim mode. + */ +var isVimMode = function() { + var keyboardHandler = cvoxAce.editor.keyBinding.getKeyboardHandler(); + return keyboardHandler.$id === 'ace/keyboard/vim'; +}; + +/** + * Gets the current token. + * @param {!cvoxAce.Cursor} cursor Current position of the cursor. + * @return {!cvoxAce.Token} Token at the current position. + */ +var getCurrentToken = function(cursor) { + return cvoxAce.editor.getSession().getTokenAt(cursor.row, cursor.column + 1); +}; + +/** + * Gets the current line the cursor is under. + * @param {!cvoxAce.Cursor} cursor Current cursor position. + */ +var getCurrentLine = function(cursor) { + return cvoxAce.editor.getSession().getLine(cursor.row); +}; + +/** + * Event handler for row changes. When the user changes rows we want to speak + * the line so the user can work on this line. If shouldSpeakRowLocation is on + * then we speak the character, then the row, then the line so the user knows + * where the cursor is. + * @param {!cvoxAce.Cursor} currCursor Current cursor position. + */ +var onRowChange = function(currCursor) { + /* Notify that this line has an annotation. */ + if (annotTable[currCursor.row]) { + cvox.Api.playEarcon(ERROR_EARCON); + } + if (shouldSpeakRowLocation) { + cvox.Api.stop(); + speakChar(currCursor); + speakTokenQueue(getCurrentToken(currCursor)); + speakLine(currCursor.row, 1); + } else { + speakLine(currCursor.row, 0); + } +}; + +/** + * Returns whether the cursor is at the beginning of a word. A word is + * a grouping of alphanumeric characters including underscores. + * @param {!cvoxAce.Cursor} cursor Current cursor position. + * @return {boolean} Whether there is word. + */ +var isWord = function(cursor) { + var line = getCurrentLine(cursor); + var lineSuffix = line.substr(cursor.column - 1); + if (cursor.column === 0) { + lineSuffix = ' ' + line; + } + /* Use regex to tell if the suffix is at the start of a new word. */ + var firstWordRegExp = /^\W(\w+)/; + var words = firstWordRegExp.exec(lineSuffix); + return words !== null; +}; + +/** + * A mapping of syntax type to speech properties / expanding rules. + */ +var rules = { + 'constant': { + prop: CONSTANT_PROP + }, + 'entity': { + prop: ENTITY_PROP + }, + 'keyword': { + prop: KEYWORD_PROP + }, + 'storage': { + prop: STORAGE_PROP + }, + 'variable': { + prop: VARIABLE_PROP + }, + 'meta': { + prop: DEFAULT_PROP, + replace: [ + { + substr: '', + newSubstr: ' close tag ' + }, + { + substr: '<', + newSubstr: ' tag start ' + }, + { + substr: '>', + newSubstr: ' tag end ' + } + ] + } +}; + +/** + * Default rule to be used. + */ +var DEFAULT_RULE = { + prop: DEFAULT_RULE +}; + +/** + * Expands substrings to how they are read based on the given rules. + * @param {string} value Text to be expanded. + * @param {Array.} replaceRules Rules to determine expansion. + * @return {string} New expanded value. + */ +var expand = function(value, replaceRules) { + var newValue = value; + for (var i = 0; i < replaceRules.length; i++) { + var replaceRule = replaceRules[i]; + var regexp = new RegExp(replaceRule.substr, 'g'); + newValue = newValue.replace(regexp, replaceRule.newSubstr); + } + return newValue; +}; + +/** + * Merges tokens from start inclusive to end exclusive. + * @param {Array.} Tokens to be merged. + * @param {number} start Start index inclusive. + * @param {number} end End index exclusive. + * @return {cvoxAce.Token} Merged token. + */ +var mergeTokens = function(tokens, start, end) { + /* Different type of token found! Merge all previous like tokens. */ + var newToken = {}; + newToken.value = ''; + newToken.type = tokens[start].type; + for (var j = start; j < end; j++) { + newToken.value += tokens[j].value; + } + return newToken; +}; + +/** + * Merges tokens that use the same speech properties. + * @param {Array.} tokens Tokens to be merged. + * @return {Array.} Merged tokens. + */ +var mergeLikeTokens = function(tokens) { + if (tokens.length <= 1) { + return tokens; + } + var newTokens = []; + var lastLikeIndex = 0; + for (var i = 1; i < tokens.length; i++) { + var lastLikeToken = tokens[lastLikeIndex]; + var currToken = tokens[i]; + if (getTokenRule(lastLikeToken) !== getTokenRule(currToken)) { + newTokens.push(mergeTokens(tokens, lastLikeIndex, i)); + lastLikeIndex = i; + } + } + newTokens.push(mergeTokens(tokens, lastLikeIndex, tokens.length)); + return newTokens; +}; + +/** + * Returns if given row is a whitespace row. + * @param {number} row Row. + * @return {boolean} True if row is whitespaces. + */ +var isRowWhiteSpace = function(row) { + var line = cvoxAce.editor.getSession().getLine(row); + var whiteSpaceRegexp = /^\s*$/; + return whiteSpaceRegexp.exec(line) !== null; +}; + +/** + * Speak the line with syntax properties. + * @param {number} row Row to speak. + * @param {number} queue Queue mode to speak. + */ +var speakLine = function(row, queue) { + var tokens = cvoxAce.editor.getSession().getTokens(row); + if (tokens.length === 0 || isRowWhiteSpace(row)) { + cvox.Api.playEarcon('EDITABLE_TEXT'); + return; + } + tokens = mergeLikeTokens(tokens); + var firstToken = tokens[0]; + /* Filter out first token. */ + tokens = tokens.filter(function(token) { + return token !== firstToken; + }); + /* Speak first token separately to flush if queue. */ + speakToken_(firstToken, queue); + /* Speak rest of tokens. */ + tokens.forEach(speakTokenQueue); +}; + +/** + * Speak the token based on the syntax of the token, flushing. + * @param {!cvoxAce.Token} token Token to speak. + * @param {number} queue Queue mode. + */ +var speakTokenFlush = function(token) { + speakToken_(token, 0); +}; + +/** + * Speak the token based on the syntax of the token, queueing. + * @param {!cvoxAce.Token} token Token to speak. + * @param {number} queue Queue mode. + */ +var speakTokenQueue = function(token) { + speakToken_(token, 1); +}; + +/** + * @param {!cvoxAce.Token} token Token to speak. + * Get the token speech property. + */ +var getTokenRule = function(token) { + /* Types are period delimited. In this case, we only syntax speak the outer + * most type of token. */ + if (!token || !token.type) { + return; + } + var split = token.type.split('.'); + if (split.length === 0) { + return; + } + var type = split[0]; + var rule = rules[type]; + if (!rule) { + return DEFAULT_RULE; + } + return rule; +}; + +/** + * Speak the token based on the syntax of the token. + * @private + * @param {!cvoxAce.Token} token Token to speak. + * @param {number} queue Queue mode. + */ +var speakToken_ = function(token, queue) { + var rule = getTokenRule(token); + var value = expand(token.value, REPLACE_LIST); + if (rule.replace) { + value = expand(value, rule.replace); + } + cvox.Api.speak(value, queue, rule.prop); +}; + +/** + * Speaks the character under the cursor. This is queued. + * @param {!cvoxAce.Cursor} cursor Current cursor position. + * @return {string} Character. + */ +var speakChar = function(cursor) { + var line = getCurrentLine(cursor); + cvox.Api.speak(line[cursor.column], 1); +}; + +/** + * Speaks the jump from lastCursor to currCursor. This function assumes the + * jump takes place on the current line. + * @param {!cvoxAce.Cursor} lastCursor Previous cursor position. + * @param {!cvoxAce.Cursor} currCursor Current cursor position. + */ +var speakDisplacement = function(lastCursor, currCursor) { + var line = getCurrentLine(currCursor); + + /* Get the text that we jumped past. */ + var displace = line.substring(lastCursor.column, currCursor.column); + + /* Speak out loud spaces. */ + displace = displace.replace(/ /g, ' space '); + cvox.Api.speak(displace); +}; + +/** + * Speaks the word if the cursor jumped to a new word or to the beginning + * of the line. Otherwise speak the charactor. + * @param {!cvoxAce.Cursor} lastCursor Previous cursor position. + * @param {!cvoxAce.Cursor} currCursor Current cursor position. + */ +var speakCharOrWordOrLine = function(lastCursor, currCursor) { + /* Say word only if jump. */ + if (Math.abs(lastCursor.column - currCursor.column) !== 1) { + var currLineLength = getCurrentLine(currCursor).length; + /* Speak line if jumping to beginning or end of line. */ + if (currCursor.column === 0 || currCursor.column === currLineLength) { + speakLine(currCursor.row, 0); + return; + } + if (isWord(currCursor)) { + cvox.Api.stop(); + speakTokenQueue(getCurrentToken(currCursor)); + return; + } + } + speakChar(currCursor); +}; + +/** + * Event handler for column changes. If shouldSpeakDisplacement is on, then + * we just speak displacements in row changes. Otherwise, we either speak + * the character for single character movements, the word when jumping to the + * next word, or the entire line if jumping to beginning or end of the line. + * @param {!cvoxAce.Cursor} lastCursor Previous cursor position. + * @param {!cvoxAce.Cursor} currCursor Current cursor position. + */ +var onColumnChange = function(lastCursor, currCursor) { + if (!cvoxAce.editor.selection.isEmpty()) { + speakDisplacement(lastCursor, currCursor); + cvox.Api.speak('selected', 1); + } + else if (shouldSpeakDisplacement) { + speakDisplacement(lastCursor, currCursor); + } else { + speakCharOrWordOrLine(lastCursor, currCursor); + } +}; + +/** + * Event handler for cursor changes. Classify cursor changes as either row or + * column changes, then delegate accordingly. + * @param {!Event} evt The event. + */ +var onCursorChange = function(evt) { + /* Do not speak if cursor change was a result of text insertion. We want to + * speak the text that was inserted and not where the cursor lands. */ + if (changed) { + changed = false; + return; + } + var currCursor = cvoxAce.editor.selection.getCursor(); + if (currCursor.row !== lastCursor.row) { + onRowChange(currCursor); + } else { + onColumnChange(lastCursor, currCursor); + } + lastCursor = currCursor; +}; + +/** + * Event handler for selection changes. + * @param {!Event} evt The event. + */ +var onSelectionChange = function(evt) { + /* Assumes that when selection changes to empty, the user has unselected. */ + if (cvoxAce.editor.selection.isEmpty()) { + cvox.Api.speak('unselected'); + } +}; + +/** + * Event handler for source changes. We want auditory feedback for inserting + * and deleting text. + * @param {!Event} evt The event. + */ +var onChange = function(delta) { + switch (data.action) { + case 'remove': + cvox.Api.speak(data.text, 0, DELETED_PROP); + /* Let the future cursor change event know it's from text change. */ + changed = true; + break; + case 'insert': + cvox.Api.speak(data.text, 0); + /* Let the future cursor change event know it's from text change. */ + changed = true; + break; + } +}; + +/** + * Returns whether or not the annotation is new. + * @param {!cvoxAce.Annotation} annot Annotation in question. + * @return {boolean} Whether annot is new. + */ +var isNewAnnotation = function(annot) { + var row = annot.row; + var col = annot.column; + return !annotTable[row] || !annotTable[row][col]; +}; + +/** + * Populates the annotation table. + * @param {!Array.} annotations Array of annotations. + */ +var populateAnnotations = function(annotations) { + annotTable = {}; + for (var i = 0; i < annotations.length; i++) { + var annotation = annotations[i]; + var row = annotation.row; + var col = annotation.column; + if (!annotTable[row]) { + annotTable[row] = {}; + } + annotTable[row][col] = annotation; + } +}; + +/** + * Event handler for annotation changes. We want to notify the user when an + * a new annotation appears. + * @param {!Event} evt Event. + */ +var onAnnotationChange = function(evt) { + var annotations = cvoxAce.editor.getSession().getAnnotations(); + var newAnnotations = annotations.filter(isNewAnnotation); + if (newAnnotations.length > 0) { + cvox.Api.playEarcon(ERROR_EARCON); + } + populateAnnotations(annotations); +}; + +/** + * Speak annotation. + * @param {!cvoxAce.Annotation} annot Annotation to speak. + */ +var speakAnnot = function(annot) { + var annotText = annot.type + ' ' + annot.text + ' on ' + + rowColToString(annot.row, annot.column); + annotText = annotText.replace(';', 'semicolon'); + cvox.Api.speak(annotText, 1); +}; + +/** + * Speak annotations in a row. + * @param {number} row Row of annotations to speak. + */ +var speakAnnotsByRow = function(row) { + var annots = annotTable[row]; + for (var col in annots) { + speakAnnot(annots[col]); + } +}; + +/** + * Get a string representation of a row and column. + * @param {boolean} row Zero indexed row. + * @param {boolean} col Zero indexed column. + * @return {string} Row and column to be spoken. + */ +var rowColToString = function(row, col) { + return 'row ' + (row + 1) + ' column ' + (col + 1); +}; + +/** + * Speaks the row and column. + */ +var speakCurrRowAndCol = function() { + cvox.Api.speak(rowColToString(lastCursor.row, lastCursor.column)); +}; + +/** + * Speaks all annotations. + */ +var speakAllAnnots = function() { + for (var row in annotTable) { + speakAnnotsByRow(row); + } +}; + +/** + * Speak the vim mode. If no vim mode, this function does nothing. + */ +var speakMode = function() { + if (!isVimMode()) { + return; + } + switch (cvoxAce.editor.keyBinding.$data.state) { + case INSERT_MODE_STATE: + cvox.Api.speak('Insert mode'); + break; + case COMMAND_MODE_STATE: + cvox.Api.speak('Command mode'); + break; + } +}; + +/** + * Toggle speak location. + */ +var toggleSpeakRowLocation = function() { + shouldSpeakRowLocation = !shouldSpeakRowLocation; + /* Auditory feedback of the change. */ + if (shouldSpeakRowLocation) { + cvox.Api.speak('Speak location on row change enabled.'); + } else { + cvox.Api.speak('Speak location on row change disabled.'); + } +}; + +/** + * Toggle speak displacement. + */ +var toggleSpeakDisplacement = function() { + shouldSpeakDisplacement = !shouldSpeakDisplacement; + /* Auditory feedback of the change. */ + if (shouldSpeakDisplacement) { + cvox.Api.speak('Speak displacement on column changes.'); + } else { + cvox.Api.speak('Speak current character or word on column changes.'); + } +}; + +/** + * Event handler for key down events. Gets the right shortcut from the map, + * and calls the associated function. + * @param {!Event} evt Keyboard event. + */ +var onKeyDown = function(evt) { + if (evt.ctrlKey && evt.shiftKey) { + var shortcut = keyCodeToShortcutMap[evt.keyCode]; + if (shortcut) { + shortcut.func(); + } + } +}; + +/** + * Event handler for status change events. Auditory feedback of changing + * between vim states. + * @param {!Event} evt Change status event. + * @param {!Object} editor Editor state. + */ +var onChangeStatus = function(evt, editor) { + if (!isVimMode()) { + return; + } + var state = editor.keyBinding.$data.state; + if (state === vimState) { + /* State hasn't changed, do nothing. */ + return; + } + switch (state) { + case INSERT_MODE_STATE: + cvox.Api.playEarcon(MODE_SWITCH_EARCON); + /* When in insert mode, we want to speak out keys as feedback. */ + cvox.Api.setKeyEcho(true); + break; + case COMMAND_MODE_STATE: + cvox.Api.playEarcon(MODE_SWITCH_EARCON); + /* When in command mode, we want don't speak out keys because those keys + * are not being inserted in the document. */ + cvox.Api.setKeyEcho(false); + break; + } + vimState = state; +}; + +/** + * Handles context menu events. This is a ChromeVox feature where hitting + * the shortcut ChromeVox + comma will open up a search bar where you can + * type in various commands. All keyboard shortcuts are also commands that + * can be invoked. This handles the event that ChromeVox sends to the page. + * @param {Event} evt Event received. + */ +var contextMenuHandler = function(evt) { + var cmd = evt.detail['customCommand']; + var shortcut = cmdToShortcutMap[cmd]; + if (shortcut) { + shortcut.func(); + /* ChromeVox will bring focus to an element near the cursor instead of the + * text input. */ + cvoxAce.editor.focus(); + } +}; + +/** + * Initialize the ChromeVox context menu. + */ +var initContextMenu = function() { + var ACTIONS = SHORTCUTS.map(function(shortcut) { + return { + desc: shortcut.desc + getKeyShortcutString(shortcut.keyCode), + cmd: shortcut.cmd + }; + }); + + /* Attach ContextMenuActions. */ + var body = document.querySelector('body'); + body.setAttribute('contextMenuActions', JSON.stringify(ACTIONS)); + + /* Listen for ContextMenu events. */ + body.addEventListener('ATCustomEvent', contextMenuHandler, true); +}; + +/** + * Event handler for find events. When there is a match, we want to speak the + * line we are now at. Otherwise, we want to notify the user there was no + * match + * @param {!Event} evt The event. + */ +var onFindSearchbox = function(evt) { + if (evt.match) { + /* There is still a match! Speak the line. */ + speakLine(lastCursor.row, 0); + } else { + /* No match, give auditory feedback! */ + cvox.Api.playEarcon(NO_MATCH_EARCON); + } +}; + +/** + * Focus to text input. + */ +var focus = function() { + cvoxAce.editor.focus(); +}; + +/** + * Shortcut definitions. + */ +var SHORTCUTS = [ + { + /* 1 key. */ + keyCode: 49, + func: function() { + speakAnnotsByRow(lastCursor.row); + }, + cmd: Command.SPEAK_ANNOT, + desc: 'Speak annotations on line' + }, + { + /* 2 key. */ + keyCode: 50, + func: speakAllAnnots, + cmd: Command.SPEAK_ALL_ANNOTS, + desc: 'Speak all annotations' + }, + { + /* 3 key. */ + keyCode: 51, + func: speakMode, + cmd: Command.SPEAK_MODE, + desc: 'Speak Vim mode' + }, + { + /* 4 key. */ + keyCode: 52, + func: toggleSpeakRowLocation, + cmd: Command.TOGGLE_LOCATION, + desc: 'Toggle speak row location' + }, + { + /* 5 key. */ + keyCode: 53, + func: speakCurrRowAndCol, + cmd: Command.SPEAK_ROW_COL, + desc: 'Speak row and column' + }, + { + /* 6 key. */ + keyCode: 54, + func: toggleSpeakDisplacement, + cmd: Command.TOGGLE_DISPLACEMENT, + desc: 'Toggle speak displacement' + }, + { + /* 7 key. */ + keyCode: 55, + func: focus, + cmd: Command.FOCUS_TEXT, + desc: 'Focus text' + } +]; + +/** + * Event handler for focus events. + */ +var onFocus = function() { + cvoxAce.editor = editor; + + /* Set up listeners. */ + editor.getSession().selection.on('changeCursor', onCursorChange); + editor.getSession().selection.on('changeSelection', onSelectionChange); + editor.getSession().on('change', onChange); + editor.getSession().on('changeAnnotation', onAnnotationChange); + editor.on('changeStatus', onChangeStatus); + editor.on('findSearchBox', onFindSearchbox); + editor.container.addEventListener('keydown', onKeyDown); + + lastCursor = editor.selection.getCursor(); +}; + +/** + * Initialize the theme. + * @param {Object} editor Editor to use. + */ +var init = function(editor) { + onFocus(); + + /* Construct maps. */ + SHORTCUTS.forEach(function(shortcut) { + keyCodeToShortcutMap[shortcut.keyCode] = shortcut; + cmdToShortcutMap[shortcut.cmd] = shortcut; + }); + + editor.on('focus', onFocus); + + /* Assume we start in command mode if vim. */ + if (isVimMode()) { + cvox.Api.setKeyEcho(false); + } + initContextMenu(); +}; + +/** + * Returns if cvox exists, and the api exists. + * @return {boolean} Whether not Cvox Api exists. + */ +function cvoxApiExists() { + return (typeof(cvox) !== 'undefined') && cvox && cvox.Api; +} + +/** + * Number of tries for Cvox loading. + * @type {number} + */ +var tries = 0; + +/** + * Max number of tries to watch for Cvox loading. + * @type {number} + */ +var MAX_TRIES = 15; + +/** + * Check for ChromeVox load. + * @param {Object} editor Editor to use. + */ +function watchForCvoxLoad(editor) { + if (cvoxApiExists()) { + init(editor); + } else { + tries++; + if (tries >= MAX_TRIES) { + return; + } + window.setTimeout(watchForCvoxLoad, 500, editor); + } +} + +var Editor = require('../editor').Editor; +require('../config').defineOptions(Editor.prototype, 'editor', { + enableChromevoxEnhancements: { + set: function(val) { + if (val) { + watchForCvoxLoad(this); + } + }, + value: true // turn it on by default or check for window.cvox + } +}); + +}); diff --git a/lib/ace/ext/elastic_tabstops_lite.js b/lib/ace/ext/elastic_tabstops_lite.js index 9901c5df..0f89423a 100644 --- a/lib/ace/ext/elastic_tabstops_lite.js +++ b/lib/ace/ext/elastic_tabstops_lite.js @@ -44,13 +44,12 @@ var ElasticTabstopsLite = function(editor) { this.onExec = function() { recordChanges = true; }; - this.onChange = function(e) { - var range = e.data.range + this.onChange = function(delta) { if (recordChanges) { - if (changedRows.indexOf(range.start.row) == -1) - changedRows.push(range.start.row); - if (range.end.row != range.start.row) - changedRows.push(range.end.row); + if (changedRows.indexOf(delta.start.row) == -1) + changedRows.push(delta.start.row); + if (delta.end.row != delta.start.row) + changedRows.push(delta.end.row); } }; }; diff --git a/lib/ace/ext/emmet.js b/lib/ace/ext/emmet.js index d6c141bf..4faacef2 100644 --- a/lib/ace/ext/emmet.js +++ b/lib/ace/ext/emmet.js @@ -32,15 +32,9 @@ define(function(require, exports, module) { "use strict"; var HashHandler = require("ace/keyboard/hash_handler").HashHandler; var Editor = require("ace/editor").Editor; -var emmet; - -Editor.prototype.indexToPosition = function(index) { - return this.session.doc.indexToPosition(index); -}; - -Editor.prototype.positionToIndex = function(pos) { - return this.session.doc.positionToIndex(pos); -}; +var snippetManager = require("ace/snippets").snippetManager; +var Range = require("ace/range").Range; +var emmet, emmetPath; /** * Implementation of {@link IEmmetEditor} interface for Ace @@ -70,9 +64,10 @@ AceEmmetEditor.prototype = { getSelectionRange: function() { // TODO should start be caret position instead? var range = this.ace.getSelectionRange(); + var doc = this.ace.session.doc; return { - start: this.ace.positionToIndex(range.start), - end: this.ace.positionToIndex(range.end) + start: doc.positionToIndex(range.start), + end: doc.positionToIndex(range.end) }; }, @@ -89,9 +84,10 @@ AceEmmetEditor.prototype = { * editor.createSelection(15); */ createSelection: function(start, end) { + var doc = this.ace.session.doc; this.ace.selection.setRange({ - start: this.ace.indexToPosition(start), - end: this.ace.indexToPosition(end) + start: doc.indexToPosition(start), + end: doc.indexToPosition(end) }); }, @@ -104,9 +100,10 @@ AceEmmetEditor.prototype = { * alert(range.start + ', ' + range.end); */ getCurrentLineRange: function() { - var row = this.ace.getCursorPosition().row; - var lineLength = this.ace.session.getLine(row).length; - var index = this.ace.positionToIndex({row: row, column: 0}); + var ace = this.ace; + var row = ace.getCursorPosition().row; + var lineLength = ace.session.getLine(row).length; + var index = ace.session.doc.positionToIndex({row: row, column: 0}); return { start: index, end: index + lineLength @@ -119,7 +116,7 @@ AceEmmetEditor.prototype = { */ getCaretPos: function(){ var pos = this.ace.getCursorPosition(); - return this.ace.positionToIndex(pos); + return this.ace.session.doc.positionToIndex(pos); }, /** @@ -127,9 +124,8 @@ AceEmmetEditor.prototype = { * @param {Number} index Caret position */ setCaretPos: function(index){ - var pos = this.ace.indexToPosition(index); - this.ace.clearSelection(); - this.ace.selection.moveCursorToPosition(pos); + var pos = this.ace.session.doc.indexToPosition(index); + this.ace.selection.moveToPosition(pos); }, /** @@ -165,43 +161,18 @@ AceEmmetEditor.prototype = { if (end == null) end = start == null ? this.getContent().length : start; if (start == null) - start = 0; - var utils = emmet.require("utils"); - - // indent new value - if (!noIndent) { - value = utils.padString(value, utils.getLinePaddingFromPosition(this.getContent(), start)); - } - - // find new caret position - var tabstopData = emmet.require("tabStops").extract(value, { - escape: function(ch) { - return ch; - } - }); - - value = tabstopData.text; - var firstTabStop = tabstopData.tabstops[0]; - - if (firstTabStop) { - firstTabStop.start += start; - firstTabStop.end += start; - } else { - firstTabStop = { - start: value.length + start, - end: value.length + start - }; - } - - var range = this.ace.getSelectionRange(); - range.start = this.ace.indexToPosition(start); - range.end = this.ace.indexToPosition(end); - - this.ace.session.replace(range, value); - - range.start = this.ace.indexToPosition(firstTabStop.start); - range.end = this.ace.indexToPosition(firstTabStop.end); - this.ace.selection.setRange(range); + start = 0; + + var editor = this.ace; + var doc = editor.session.doc; + var range = Range.fromPoints(doc.indexToPosition(start), doc.indexToPosition(end)); + editor.session.remove(range); + + range.end = range.start; + //editor.selection.setRange(range); + + value = this.$updateTabstops(value); + snippetManager.insertSnippet(editor, value); }, /** @@ -282,6 +253,59 @@ AceEmmetEditor.prototype = { */ getFilePath: function() { return ""; + }, + + // update tabstops: make sure all caret placeholders are unique + // by default, abbreviation parser generates all unlinked (un-mirrored) + // tabstops as ${0}, so we have upgrade all caret tabstops with unique + // positions but make sure that all other tabstops are not linked accidentally + // based on https://github.com/sergeche/emmet-sublime/blob/master/editor.js#L119-L171 + $updateTabstops: function(value) { + var base = 1000; + var zeroBase = 0; + var lastZero = null; + var range = emmet.require('range'); + var ts = emmet.require('tabStops'); + var settings = emmet.require('resources').getVocabulary("user"); + var tabstopOptions = { + tabstop: function(data) { + var group = parseInt(data.group, 10); + var isZero = group === 0; + if (isZero) + group = ++zeroBase; + else + group += base; + + var placeholder = data.placeholder; + if (placeholder) { + // recursively update nested tabstops + placeholder = ts.processText(placeholder, tabstopOptions); + } + + var result = '${' + group + (placeholder ? ':' + placeholder : '') + '}'; + + if (isZero) { + lastZero = range.create(data.start, result); + } + + return result; + }, + escape: function(ch) { + if (ch == '$') return '\\$'; + if (ch == '\\') return '\\\\'; + return ch; + } + }; + + value = ts.processText(value, tabstopOptions); + + if (settings.variables['insert_final_tabstop'] && !/\$\{0\}$/.test(value)) { + value += '${0}'; + } else if (lastZero) { + value = emmet.require('utils').replaceSubstring(value, '${0}', lastZero); + } + + return value; } }; @@ -318,28 +342,34 @@ var keymap = { var editorProxy = new AceEmmetEditor(); exports.commands = new HashHandler(); exports.runEmmetCommand = function(editor) { - editorProxy.setupContext(editor); - if (editorProxy.getSyntax() == "php") - return false; - var actions = emmet.require("actions"); - - if (this.action == "expand_abbreviation_with_tab") { - if (!editor.selection.isEmpty()) - return false; - } - - if (this.action == "wrap_with_abbreviation") { - // without setTimeout prompt doesn't work on firefox - return setTimeout(function() { - actions.run("wrap_with_abbreviation", editorProxy); - }, 0); - } - try { + editorProxy.setupContext(editor); + if (editorProxy.getSyntax() == "php") + return false; + var actions = emmet.require("actions"); + + if (this.action == "expand_abbreviation_with_tab") { + if (!editor.selection.isEmpty()) + return false; + } + + if (this.action == "wrap_with_abbreviation") { + // without setTimeout prompt doesn't work on firefox + return setTimeout(function() { + actions.run("wrap_with_abbreviation", editorProxy); + }, 0); + } + + var pos = editor.selection.lead; + var token = editor.session.getTokenAt(pos.row, pos.column); + if (token && /\btag\b/.test(token.type)) + return false; + var result = actions.run(this.action, editorProxy); } catch(e) { editor._signal("changeStatus", typeof e == "string" ? e : e.message); console.log(e); + result = false; } return result; }; @@ -354,21 +384,35 @@ for (var command in keymap) { }); } +exports.updateCommands = function(editor, enabled) { + if (enabled) { + editor.keyBinding.addKeyboardHandler(exports.commands); + } else { + editor.keyBinding.removeKeyboardHandler(exports.commands); + } +}; + +exports.isSupportedMode = function(modeId) { + return modeId && /css|less|scss|sass|stylus|html|php|twig|ejs|handlebars/.test(modeId); +}; + var onChangeMode = function(e, target) { var editor = target; if (!editor) return; - var modeId = editor.session.$modeId; - var enabled = modeId && /css|less|sass|html|php/.test(modeId); + var enabled = exports.isSupportedMode(editor.session.$modeId); if (e.enableEmmet === false) enabled = false; - if (enabled) - editor.keyBinding.addKeyboardHandler(exports.commands); - else - editor.keyBinding.removeKeyboardHandler(exports.commands); + if (enabled) { + if (typeof emmetPath == "string") { + require("ace/config").loadModule(emmetPath, function() { + emmetPath = null; + }); + } + } + exports.updateCommands(editor, enabled); }; - exports.AceEmmetEditor = AceEmmetEditor; require("ace/config").defineOptions(Editor.prototype, "editor", { enableEmmet: { @@ -380,7 +424,11 @@ require("ace/config").defineOptions(Editor.prototype, "editor", { } }); - -exports.setCore = function(e) {emmet = e;}; +exports.setCore = function(e) { + if (typeof e == "string") + emmetPath = e; + else + emmet = e; +}; }); diff --git a/lib/ace/ext/error_marker.js b/lib/ace/ext/error_marker.js new file mode 100644 index 00000000..5dbe3d2e --- /dev/null +++ b/lib/ace/ext/error_marker.js @@ -0,0 +1,214 @@ +/* ***** 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. + * + * ***** END LICENSE BLOCK ***** */ + +define(function(require, exports, module) { +"use strict"; +var LineWidgets = require("../line_widgets").LineWidgets; +var dom = require("../lib/dom"); +var Range = require("../range").Range; + +function binarySearch(array, needle, comparator) { + var first = 0; + var last = array.length - 1; + + while (first <= last) { + var mid = (first + last) >> 1; + var c = comparator(needle, array[mid]); + if (c > 0) + first = mid + 1; + else if (c < 0) + last = mid - 1; + else + return mid; + } + + // Return the nearest lesser index, "-1" means "0, "-2" means "1", etc. + return -(first + 1); +} + +function findAnnotations(session, row, dir) { + var annotations = session.getAnnotations().sort(Range.comparePoints); + if (!annotations.length) + return; + + var i = binarySearch(annotations, {row: row, column: -1}, Range.comparePoints); + if (i < 0) + i = -i - 1; + + if (i >= annotations.length) + i = dir > 0 ? 0 : annotations.length - 1; + else if (i === 0 && dir < 0) + i = annotations.length - 1; + + var annotation = annotations[i]; + if (!annotation || !dir) + return; + + if (annotation.row === row) { + do { + annotation = annotations[i += dir]; + } while (annotation && annotation.row === row); + if (!annotation) + return annotations.slice(); + } + + + var matched = []; + row = annotation.row; + do { + matched[dir < 0 ? "unshift" : "push"](annotation); + annotation = annotations[i += dir]; + } while (annotation && annotation.row == row); + return matched.length && matched; +} + +exports.showErrorMarker = function(editor, dir) { + var session = editor.session; + if (!session.widgetManager) { + session.widgetManager = new LineWidgets(session); + session.widgetManager.attach(editor); + } + + var pos = editor.getCursorPosition(); + var row = pos.row; + var oldWidget = session.lineWidgets && session.lineWidgets[row]; + if (oldWidget) { + oldWidget.destroy(); + } else { + row -= dir; + } + var annotations = findAnnotations(session, row, dir); + var gutterAnno; + if (annotations) { + var annotation = annotations[0]; + pos.column = (annotation.pos && typeof annotation.column != "number" + ? annotation.pos.sc + : annotation.column) || 0; + pos.row = annotation.row; + gutterAnno = editor.renderer.$gutterLayer.$annotations[pos.row]; + } else if (oldWidget) { + return; + } else { + gutterAnno = { + text: ["Looks good!"], + className: "ace_ok" + }; + } + editor.session.unfold(pos.row); + editor.selection.moveToPosition(pos); + + var w = { + row: pos.row, + fixedWidth: true, + coverGutter: true, + el: dom.createElement("div") + }; + var el = w.el.appendChild(dom.createElement("div")); + var arrow = w.el.appendChild(dom.createElement("div")); + arrow.className = "error_widget_arrow " + gutterAnno.className; + + var left = editor.renderer.$cursorLayer + .getPixelPosition(pos).left; + arrow.style.left = left + editor.renderer.gutterWidth - 5 + "px"; + + w.el.className = "error_widget_wrapper"; + el.className = "error_widget " + gutterAnno.className; + el.innerHTML = gutterAnno.text.join("
    "); + + el.appendChild(dom.createElement("div")); + + var kb = function(_, hashId, keyString) { + if (hashId === 0 && (keyString === "esc" || keyString === "return")) { + w.destroy(); + return {command: "null"}; + } + }; + + w.destroy = function() { + if (editor.$mouseHandler.isMousePressed) + return; + editor.keyBinding.removeKeyboardHandler(kb); + session.widgetManager.removeLineWidget(w); + editor.off("changeSelection", w.destroy); + editor.off("changeSession", w.destroy); + editor.off("mouseup", w.destroy); + editor.off("change", w.destroy); + }; + + editor.keyBinding.addKeyboardHandler(kb); + editor.on("changeSelection", w.destroy); + editor.on("changeSession", w.destroy); + editor.on("mouseup", w.destroy); + editor.on("change", w.destroy); + + editor.session.widgetManager.addLineWidget(w); + + w.el.onmousedown = editor.focus.bind(editor); + + editor.renderer.scrollCursorIntoView(null, 0.5, {bottom: w.el.offsetHeight}); +}; + + +dom.importCssString("\ + .error_widget_wrapper {\ + background: inherit;\ + color: inherit;\ + border:none\ + }\ + .error_widget {\ + border-top: solid 2px;\ + border-bottom: solid 2px;\ + margin: 5px 0;\ + padding: 10px 40px;\ + white-space: pre-wrap;\ + }\ + .error_widget.ace_error, .error_widget_arrow.ace_error{\ + border-color: #ff5a5a\ + }\ + .error_widget.ace_warning, .error_widget_arrow.ace_warning{\ + border-color: #F1D817\ + }\ + .error_widget.ace_info, .error_widget_arrow.ace_info{\ + border-color: #5a5a5a\ + }\ + .error_widget.ace_ok, .error_widget_arrow.ace_ok{\ + border-color: #5aaa5a\ + }\ + .error_widget_arrow {\ + position: absolute;\ + border: solid 5px;\ + border-top-color: transparent!important;\ + border-right-color: transparent!important;\ + border-left-color: transparent!important;\ + top: -5px;\ + }\ +", ""); + +}); \ No newline at end of file diff --git a/lib/ace/ext/language_tools.js b/lib/ace/ext/language_tools.js new file mode 100644 index 00000000..563fe58a --- /dev/null +++ b/lib/ace/ext/language_tools.js @@ -0,0 +1,225 @@ +/* ***** 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. + * + * ***** END LICENSE BLOCK ***** */ + +define(function(require, exports, module) { +"use strict"; + +var snippetManager = require("../snippets").snippetManager; +var Autocomplete = require("../autocomplete").Autocomplete; +var config = require("../config"); +var lang = require("../lib/lang"); +var util = require("../autocomplete/util"); + +var textCompleter = require("../autocomplete/text_completer"); +var keyWordCompleter = { + getCompletions: function(editor, session, pos, prefix, callback) { + if (session.$mode.completer) { + return session.$mode.completer.getCompletions(editor, session, pos, prefix, callback); + } + var state = editor.session.getState(pos.row); + var completions = session.$mode.getCompletions(state, session, pos, prefix); + callback(null, completions); + } +}; + +var snippetCompleter = { + getCompletions: function(editor, session, pos, prefix, callback) { + var snippetMap = snippetManager.snippetMap; + var completions = []; + snippetManager.getActiveScopes(editor).forEach(function(scope) { + var snippets = snippetMap[scope] || []; + for (var i = snippets.length; i--;) { + var s = snippets[i]; + var caption = s.name || s.tabTrigger; + if (!caption) + continue; + completions.push({ + caption: caption, + snippet: s.content, + meta: s.tabTrigger && !s.name ? s.tabTrigger + "\u21E5 " : "snippet", + type: "snippet" + }); + } + }, this); + callback(null, completions); + }, + getDocTooltip: function(item) { + if (item.type == "snippet" && !item.docHTML) { + item.docHTML = [ + "", lang.escapeHTML(item.caption), "", "
    ", + lang.escapeHTML(item.snippet) + ].join(""); + } + } +}; + +var completers = [snippetCompleter, textCompleter, keyWordCompleter]; +// Allows default completers to be removed or replaced with a explict set of completers +// A null argument here will result in an empty completer array, not a null attribute +exports.setCompleters = function(val) { + completers = val || []; +}; +exports.addCompleter = function(completer) { + completers.push(completer); +}; + +// Exports existing completer so that user can construct his own set of completers. +exports.textCompleter = textCompleter; +exports.keyWordCompleter = keyWordCompleter; +exports.snippetCompleter = snippetCompleter; + +var expandSnippet = { + name: "expandSnippet", + exec: function(editor) { + return snippetManager.expandWithTab(editor); + }, + bindKey: "Tab" +}; + +var onChangeMode = function(e, editor) { + loadSnippetsForMode(editor.session.$mode); +}; + +var loadSnippetsForMode = function(mode) { + var id = mode.$id; + if (!snippetManager.files) + snippetManager.files = {}; + loadSnippetFile(id); + if (mode.modes) + mode.modes.forEach(loadSnippetsForMode); +}; + +var loadSnippetFile = function(id) { + if (!id || snippetManager.files[id]) + return; + var snippetFilePath = id.replace("mode", "snippets"); + snippetManager.files[id] = {}; + config.loadModule(snippetFilePath, function(m) { + if (m) { + snippetManager.files[id] = m; + if (!m.snippets && m.snippetText) + m.snippets = snippetManager.parseSnippetFile(m.snippetText); + snippetManager.register(m.snippets || [], m.scope); + if (m.includeScopes) { + snippetManager.snippetMap[m.scope].includeScopes = m.includeScopes; + m.includeScopes.forEach(function(x) { + loadSnippetFile("ace/mode/" + x); + }); + } + } + }); +}; + +function getCompletionPrefix(editor) { + var pos = editor.getCursorPosition(); + var line = editor.session.getLine(pos.row); + var prefix; + // Try to find custom prefixes on the completers + editor.completers.forEach(function(completer) { + if (completer.identifierRegexps) { + completer.identifierRegexps.forEach(function(identifierRegex) { + if (!prefix && identifierRegex) + prefix = util.retrievePrecedingIdentifier(line, pos.column, identifierRegex); + }); + } + }); + return prefix || util.retrievePrecedingIdentifier(line, pos.column); +} + +var doLiveAutocomplete = function(e) { + var editor = e.editor; + var hasCompleter = editor.completer && editor.completer.activated; + + // We don't want to autocomplete with no prefix + if (e.command.name === "backspace") { + if (hasCompleter && !getCompletionPrefix(editor)) + editor.completer.detach(); + } + else if (e.command.name === "insertstring") { + var prefix = getCompletionPrefix(editor); + // Only autocomplete if there's a prefix that can be matched + if (prefix && !hasCompleter) { + if (!editor.completer) { + // Create new autocompleter + editor.completer = new Autocomplete(); + } + // Disable autoInsert + editor.completer.autoInsert = false; + editor.completer.showPopup(editor); + } + } +}; + +var Editor = require("../editor").Editor; +require("../config").defineOptions(Editor.prototype, "editor", { + enableBasicAutocompletion: { + set: function(val) { + if (val) { + if (!this.completers) + this.completers = Array.isArray(val)? val: completers; + this.commands.addCommand(Autocomplete.startCommand); + } else { + this.commands.removeCommand(Autocomplete.startCommand); + } + }, + value: false + }, + /** + * Enable live autocomplete. If the value is an array, it is assumed to be an array of completers + * and will use them instead of the default completers. + */ + enableLiveAutocompletion: { + set: function(val) { + if (val) { + if (!this.completers) + this.completers = Array.isArray(val)? val: completers; + // On each change automatically trigger the autocomplete + this.commands.on('afterExec', doLiveAutocomplete); + } else { + this.commands.removeListener('afterExec', doLiveAutocomplete); + } + }, + value: false + }, + enableSnippets: { + set: function(val) { + if (val) { + this.commands.addCommand(expandSnippet); + this.on("changeMode", onChangeMode); + onChangeMode(null, this); + } else { + this.commands.removeCommand(expandSnippet); + this.off("changeMode", onChangeMode); + } + }, + value: false + } +}); +}); diff --git a/lib/ace/ext/linking.js b/lib/ace/ext/linking.js new file mode 100644 index 00000000..cfd333b2 --- /dev/null +++ b/lib/ace/ext/linking.js @@ -0,0 +1,78 @@ +/* ***** 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. + * + * ***** END LICENSE BLOCK ***** */ + +define(function(require, exports, module) { + +var Editor = require("ace/editor").Editor; + +require("../config").defineOptions(Editor.prototype, "editor", { + enableLinking: { + set: function(val) { + if (val) { + this.on("click", onClick); + this.on("mousemove", onMouseMove); + } else { + this.off("click", onClick); + this.off("mousemove", onMouseMove); + } + }, + value: false + } +}) + +function onMouseMove(e) { + var editor = e.editor; + var ctrl = e.getAccelKey(); + + if (ctrl) { + var editor = e.editor; + var docPos = e.getDocumentPosition(); + var session = editor.session; + var token = session.getTokenAt(docPos.row, docPos.column); + + editor._emit("linkHover", {position: docPos, token: token}); + } +} + +function onClick(e) { + var ctrl = e.getAccelKey(); + var button = e.getButton(); + + if (button == 0 && ctrl) { + var editor = e.editor; + var docPos = e.getDocumentPosition(); + var session = editor.session; + var token = session.getTokenAt(docPos.row, docPos.column); + + editor._emit("linkClick", {position: docPos, token: token}); + } +} + +}); diff --git a/lib/ace/ext/menu_tools/add_editor_menu_options.js b/lib/ace/ext/menu_tools/add_editor_menu_options.js index fd56859b..eb90e31d 100644 --- a/lib/ace/ext/menu_tools/add_editor_menu_options.js +++ b/lib/ace/ext/menu_tools/add_editor_menu_options.js @@ -60,44 +60,50 @@ module.exports.addEditorMenuOptions = function addEditorMenuOptions (editor) { var modelist = require('../modelist'); var themelist = require('../themelist'); editor.menuOptions = { - "setNewLineMode" : [{ - "textContent" : "unix", - "value" : "unix" + setNewLineMode: [{ + textContent: "unix", + value: "unix" }, { - "textContent" : "windows", - "value" : "windows" + textContent: "windows", + value: "windows" }, { - "textContent" : "auto", - "value" : "auto" + textContent: "auto", + value: "auto" }], - "setTheme" : [], - "setMode" : [], - "setKeyboardHandler": [{ - "textContent" : "ace", - "value" : "" + setTheme: [], + setMode: [], + setKeyboardHandler: [{ + textContent: "ace", + value: "" }, { - "textContent" : "vim", - "value" : "ace/keyboard/vim" + textContent: "vim", + value: "ace/keyboard/vim" }, { - "textContent" : "emacs", - "value" : "ace/keyboard/emacs" + textContent: "emacs", + value: "ace/keyboard/emacs" + }, { + textContent: "textarea", + value: "ace/keyboard/textarea" + }, { + textContent: "sublime", + value: "ace/keyboard/sublime" }] }; editor.menuOptions.setTheme = themelist.themes.map(function(theme) { return { - 'textContent' : theme.desc, - 'value' : theme.theme + textContent: theme.caption, + value: theme.theme }; }); editor.menuOptions.setMode = modelist.modes.map(function(mode) { return { - 'textContent' : mode.name, - 'value' : mode.mode + textContent: mode.name, + value: mode.mode }; }); }; -}); \ No newline at end of file +}); diff --git a/lib/ace/ext/menu_tools/generate_settings_menu.js b/lib/ace/ext/menu_tools/generate_settings_menu.js index 16d3a76c..2ee1ae09 100644 --- a/lib/ace/ext/menu_tools/generate_settings_menu.js +++ b/lib/ace/ext/menu_tools/generate_settings_menu.js @@ -91,6 +91,12 @@ module.exports.generateSettingsMenu = function generateSettingsMenu (editor) { elements.forEach(function(element) { topmenu.appendChild(element); }); + + var el = topmenu.appendChild(document.createElement('div')); + var version = "1.1.9"; + el.style.padding = "1em"; + el.textContent = "Ace version " + version; + return topmenu; } /** diff --git a/lib/ace/ext/menu_tools/get_editor_keyboard_shortcuts.js b/lib/ace/ext/menu_tools/get_editor_keyboard_shortcuts.js index e62d931a..99e006b0 100644 --- a/lib/ace/ext/menu_tools/get_editor_keyboard_shortcuts.js +++ b/lib/ace/ext/menu_tools/get_editor_keyboard_shortcuts.js @@ -67,31 +67,22 @@ module.exports.getEditorKeybordShortcuts = function(editor) { var keybindings = []; var commandMap = {}; editor.keyBinding.$handlers.forEach(function(handler) { - var ckb = handler.commmandKeyBinding; + var ckb = handler.commandKeyBinding; for (var i in ckb) { - var modifier = parseInt(i); - if (modifier == -1) { - modifier = ""; - } else if(isNaN(modifier)) { - modifier = i; - } else { - modifier = "" + - (modifier & KEY_MODS.command ? "Cmd-" : "") + - (modifier & KEY_MODS.ctrl ? "Ctrl-" : "") + - (modifier & KEY_MODS.alt ? "Alt-" : "") + - (modifier & KEY_MODS.shift ? "Shift-" : ""); - } - for (var key in ckb[i]) { - var command = ckb[i][key] + var key = i.replace(/(^|-)\w/g, function(x) { return x.toUpperCase(); }); + var commands = ckb[i]; + if (!Array.isArray(commands)) + commands = [commands]; + commands.forEach(function(command) { if (typeof command != "string") command = command.name if (commandMap[command]) { - commandMap[command].key += "|" + modifier + key; + commandMap[command].key += "|" + key; } else { - commandMap[command] = {key: modifier+key, command: command}; + commandMap[command] = {key: key, command: command}; keybindings.push(commandMap[command]); - } - } + } + }); } }); return keybindings; diff --git a/lib/ace/ext/modelist.js b/lib/ace/ext/modelist.js index ef8cc7d3..675a4b85 100644 --- a/lib/ace/ext/modelist.js +++ b/lib/ace/ext/modelist.js @@ -43,17 +43,20 @@ Mode.prototype.supportsFile = function(filename) { // todo firstlinematch var supportedModes = { ABAP: ["abap"], - ADA: ["ada|adb"], + ABC: ["abc"], ActionScript:["as"], - AsciiDoc: ["asciidoc"], + ADA: ["ada|adb"], + Apache_Conf: ["^htaccess|^htgroups|^htpasswd|^conf|htaccess|htgroups|htpasswd"], + AsciiDoc: ["asciidoc|adoc"], Assembly_x86:["asm"], AutoHotKey: ["ahk"], BatchFile: ["bat|cmd"], C9Search: ["c9search_results"], - C_Cpp: ["c|cc|cpp|cxx|h|hh|hpp"], - Clojure: ["clj"], - Cobol: ["^CBL|COB"], - coffee: ["^Cakefile|coffee|cf|cson"], + C_Cpp: ["cpp|c|cc|cxx|h|hh|hpp"], + Cirru: ["cirru|cr"], + Clojure: ["clj|cljs"], + Cobol: ["CBL|COB"], + coffee: ["coffee|cf|cson|^Cakefile"], ColdFusion: ["cfm"], CSharp: ["cs"], CSS: ["css"], @@ -61,29 +64,42 @@ var supportedModes = { D: ["d|di"], Dart: ["dart"], Diff: ["diff|patch"], + Dockerfile: ["^Dockerfile"], Dot: ["dot"], - Erlang: ["erl|hrl"], + Dummy: ["dummy"], + DummySyntax: ["dummy"], + Eiffel: ["e"], EJS: ["ejs"], + Elixir: ["ex|exs"], + Elm: ["elm"], + Erlang: ["erl|hrl"], Forth: ["frt|fs|ldr"], - FreeMarker: ["ftl"], + FTL: ["ftl"], + Gcode: ["gcode"], + Gherkin: ["feature"], + Gitignore: ["^.gitignore"], Glsl: ["glsl|frag|vert"], golang: ["go"], Groovy: ["groovy"], HAML: ["haml"], + Handlebars: ["hbs|handlebars|tpl|mustache"], Haskell: ["hs"], haXe: ["hx"], - HTML: ["htm|html|xhtml"], + HTML: ["html|htm|xhtml"], HTML_Ruby: ["erb|rhtml|html.erb"], - Ini: ["Ini|conf"], + INI: ["ini|conf|cfg|prefs"], + Io: ["io"], + Jack: ["jack"], Jade: ["jade"], Java: ["java"], - JavaScript: ["js"], + JavaScript: ["js|jsm"], JSON: ["json"], JSONiq: ["jq"], JSP: ["jsp"], JSX: ["jsx"], Julia: ["jl"], - LaTeX: ["latex|tex|ltx|bib"], + LaTeX: ["tex|latex|ltx|bib"], + Lean: ["lean|hlean"], LESS: ["less"], Liquid: ["liquid"], Lisp: ["lisp"], @@ -93,34 +109,45 @@ var supportedModes = { Lua: ["lua"], LuaPage: ["lp"], Lucene: ["lucene"], - Makefile: ["^GNUmakefile|^makefile|^Makefile|^OCamlMakefile|make"], - MATLAB: ["matlab"], + Makefile: ["^Makefile|^GNUmakefile|^makefile|^OCamlMakefile|make"], Markdown: ["md|markdown"], - MySQL: ["mysql"], + Mask: ["mask"], + MATLAB: ["matlab"], + MEL: ["mel"], MUSHCode: ["mc|mush"], + MySQL: ["mysql"], + Nix: ["nix"], + Nim: ["nim"], ObjectiveC: ["m|mm"], OCaml: ["ml|mli"], Pascal: ["pas|p"], Perl: ["pl|pm"], pgSQL: ["pgsql"], - PHP: ["php|phtml"], + PHP: ["php|phtml|shtml|php3|php4|php5|phps|phpt|aw|ctp"], Powershell: ["ps1"], + Praat: ["praat|praatscript|psc|proc"], Prolog: ["plg|prolog"], Properties: ["properties"], + Protobuf: ["proto"], Python: ["py"], R: ["r"], RDoc: ["Rd"], RHTML: ["Rhtml"], - Ruby: ["ru|gemspec|rake|rb"], + Ruby: ["rb|ru|gemspec|rake|^Guardfile|^Rakefile|^Gemfile"], Rust: ["rs"], SASS: ["sass"], SCAD: ["scad"], Scala: ["scala"], Scheme: ["scm|rkt"], SCSS: ["scss"], - SH: ["sh|bash"], + SH: ["sh|bash|^.bashrc"], + SJS: ["sjs"], + Smarty: ["smarty|tpl"], snippets: ["snippets"], + Soy_Template:["soy"], + Space: ["space"], SQL: ["sql"], + SQLServer: ["sqlserver"], Stylus: ["styl|stylus"], SVG: ["svg"], Tcl: ["tcl"], @@ -129,26 +156,32 @@ var supportedModes = { Textile: ["textile"], Toml: ["toml"], Twig: ["twig"], - Typescript: ["typescript|ts|str"], - VBScript: ["vbs"], + Typescript: ["ts|typescript|str"], + Vala: ["vala"], + VBScript: ["vbs|vb"], Velocity: ["vm"], - XML: ["xml|rdf|rss|wsdl|xslt|atom|mathml|mml|xul|xbl"], + Verilog: ["v|vh|sv|svh"], + VHDL: ["vhd|vhdl"], + XML: ["xml|rdf|rss|wsdl|xslt|atom|mathml|mml|xul|xbl|xaml"], XQuery: ["xq"], - YAML: ["yaml"] + YAML: ["yaml|yml"], + // Add the missing mode "Django" to ext-modelist + Django: ["html"] }; var nameOverrides = { ObjectiveC: "Objective-C", CSharp: "C#", golang: "Go", - C_Cpp: "C/C++", + C_Cpp: "C and C++", coffee: "CoffeeScript", - HTML_Ruby: "HTML (Ruby)" + HTML_Ruby: "HTML (Ruby)", + FTL: "FreeMarker" }; var modesByName = {}; for (var name in supportedModes) { var data = supportedModes[name]; - var displayName = nameOverrides[name] || name; + var displayName = (nameOverrides[name] || name).replace(/_/g, " "); var filename = name.toLowerCase(); var mode = new Mode(filename, displayName, data[0]); modesByName[filename] = mode; @@ -162,4 +195,3 @@ module.exports = { }; }); - diff --git a/lib/ace/ext/old_ie.js b/lib/ace/ext/old_ie.js new file mode 100644 index 00000000..8b8ce977 --- /dev/null +++ b/lib/ace/ext/old_ie.js @@ -0,0 +1,114 @@ +/* ***** 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. + * + * ***** END LICENSE BLOCK ***** */ + +define(function(require, exports, module) { +"use strict"; +var MAX_TOKEN_COUNT = 1000; +var useragent = require("../lib/useragent"); +var TokenizerModule = require("../tokenizer"); + +function patch(obj, name, regexp, replacement) { + eval("obj['" + name + "']=" + obj[name].toString().replace( + regexp, replacement + )); +} + +if (useragent.isIE && useragent.isIE < 10 && window.top.document.compatMode === "BackCompat") + useragent.isOldIE = true; + +if (typeof document != "undefined" && !document.documentElement.querySelector) { + useragent.isOldIE = true; + var qs = function(el, selector) { + if (selector.charAt(0) == ".") { + var classNeme = selector.slice(1); + } else { + var m = selector.match(/(\w+)=(\w+)/); + var attr = m && m[1]; + var attrVal = m && m[2]; + } + for (var i = 0; i < el.all.length; i++) { + var ch = el.all[i]; + if (classNeme) { + if (ch.className.indexOf(classNeme) != -1) + return ch; + } else if (attr) { + if (ch.getAttribute(attr) == attrVal) + return ch; + } + } + }; + var sb = require("./searchbox").SearchBox.prototype; + patch( + sb, "$initElements", + /([^\s=]*).querySelector\((".*?")\)/g, + "qs($1, $2)" + ); +} + +var compliantExecNpcg = /()??/.exec("")[1] === undefined; +if (compliantExecNpcg) + return; +var proto = TokenizerModule.Tokenizer.prototype; +TokenizerModule.Tokenizer_orig = TokenizerModule.Tokenizer; +proto.getLineTokens_orig = proto.getLineTokens; + +patch( + TokenizerModule, "Tokenizer", + "ruleRegExps.push(adjustedregex);\n", + function(m) { + return m + '\ + if (state[i].next && RegExp(adjustedregex).test(""))\n\ + rule._qre = RegExp(adjustedregex, "g");\n\ + '; + } +); +TokenizerModule.Tokenizer.prototype = proto; +patch( + proto, "getLineTokens", + /if \(match\[i \+ 1\] === undefined\)\s*continue;/, + "if (!match[i + 1]) {\n\ + if (value)continue;\n\ + var qre = state[mapping[i]]._qre;\n\ + if (!qre) continue;\n\ + qre.lastIndex = lastIndex;\n\ + if (!qre.exec(line) || qre.lastIndex != lastIndex)\n\ + continue;\n\ + }" +); + +patch( + require("../mode/text").Mode.prototype, "getTokenizer", + /Tokenizer/, + "TokenizerModule.Tokenizer" +); + +useragent.isOldIE = true; + +}); diff --git a/lib/ace/ext/old_ie_test.js b/lib/ace/ext/old_ie_test.js new file mode 100644 index 00000000..98652e14 --- /dev/null +++ b/lib/ace/ext/old_ie_test.js @@ -0,0 +1,77 @@ +/* ***** 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. + * + * ***** END LICENSE BLOCK ***** */ + +if (typeof process !== "undefined") { + require("amd-loader"); +} + +define(function(require, exports, module) { +"use strict"; + +var assert = require("../test/assertions"); + +module.exports = { + "test: getTokenizer() (smoke test)" : function() { + var exec = RegExp.prototype.exec + var brokenExec = function(str) { + var result = exec.call(this, str); + if (result) { + for (var i = result.length; i--;) + if (!result[i]) + result[i] = ""; + } + return result; + } + + try { + // break this to emulate old ie + RegExp.prototype.exec = brokenExec; + require("./old_ie"); + var Tokenizer = require("../tokenizer").Tokenizer; + var JavaScriptHighlightRules = require("../mode/javascript_highlight_rules").JavaScriptHighlightRules; + var tokenizer = new Tokenizer((new JavaScriptHighlightRules).getRules()); + + var tokens = tokenizer.getLineTokens("'juhu'", "start").tokens; + assert.equal("string", tokens[0].type); + } finally { + // restore modified functions + RegExp.prototype.exec = exec; + var module = require("../tokenizer"); + module.Tokenizer = module.Tokenizer_orig; + module.Tokenizer.prototype.getLineTokens = module.Tokenizer.prototype.getLineTokens_orig; + } + } +}; + +}); + +if (typeof module !== "undefined" && module === require.main) { + require("asyncjs").test.testcase(module.exports).exec() +} diff --git a/lib/ace/ext/searchbox.css b/lib/ace/ext/searchbox.css index c0f5f284..5de8d847 100644 --- a/lib/ace/ext/searchbox.css +++ b/lib/ace/ext/searchbox.css @@ -7,7 +7,7 @@ background-color: #ddd; border: 1px solid #cbcbcb; border-top: 0 none; - max-width: 297px; + max-width: 325px; overflow: hidden; margin: 0; padding: 4px; @@ -16,6 +16,7 @@ position: absolute; top: 0px; z-index: 99; + white-space: normal; } .ace_search.left { border-left: 0 none; @@ -46,7 +47,6 @@ -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; - display: block; float: left; height: 22px; outline: 0; @@ -60,7 +60,6 @@ border: 0 none; border-left: 1px solid #dcdcdc; cursor: pointer; - display: block; float: left; height: 22px; margin: 0; @@ -93,12 +92,9 @@ border: 0 none; color: #656565; cursor: pointer; - display: block; float: right; - font-family: Arial; - font-size: 16px; + font: 16px/16px Arial; height: 14px; - line-height: 16px; margin: 5px 1px 9px 5px; padding: 0; text-align: center; diff --git a/lib/ace/ext/searchbox.js b/lib/ace/ext/searchbox.js index 3eacb580..b316aa75 100644 --- a/lib/ace/ext/searchbox.js +++ b/lib/ace/ext/searchbox.js @@ -46,10 +46,11 @@ var html = '\
    \ \ - \ + \ \
    \
    \ @@ -75,9 +76,7 @@ var SearchBox = function(editor, range, showReplaceForm) { this.editor = editor; }; - this.$init = function() { - var sb = this.element; - + this.$initElements = function(sb) { this.searchBox = sb.querySelector(".ace_search_form"); this.replaceBox = sb.querySelector(".ace_replace_form"); this.searchOptions = sb.querySelector(".ace_search_options"); @@ -86,7 +85,13 @@ var SearchBox = function(editor, range, showReplaceForm) { this.wholeWordOption = sb.querySelector("[action=toggleWholeWords]"); this.searchInput = this.searchBox.querySelector(".ace_search_field"); this.replaceInput = this.replaceBox.querySelector(".ace_search_field"); - + }; + + this.$init = function() { + var sb = this.element; + + this.$initElements(sb); + var _this = this; event.addListener(sb, "mousedown", function(e) { setTimeout(function(){ @@ -95,7 +100,7 @@ var SearchBox = function(editor, range, showReplaceForm) { event.stopPropagation(e); }); event.addListener(sb, "click", function(e) { - var t = e.target; + var t = e.target || e.srcElement; var action = t.getAttribute("action"); if (action && _this[action]) _this[action](); @@ -166,6 +171,11 @@ var SearchBox = function(editor, range, showReplaceForm) { sb.replace(); sb.findPrev(); }, + "Alt-Return": function(sb) { + if (sb.activeInput == sb.replaceInput) + sb.replaceAll(); + sb.findAll(); + }, "Tab": function(sb) { (sb.activeInput == sb.replaceInput ? sb.searchInput : sb.replaceInput).focus(); } @@ -214,7 +224,9 @@ var SearchBox = function(editor, range, showReplaceForm) { caseSensitive: this.caseSensitiveOption.checked, wholeWord: this.wholeWordOption.checked }); - dom.setCssClass(this.searchBox, "ace_nomatch", !range && this.searchInput.value); + var noMatch = !range && this.searchInput.value; + dom.setCssClass(this.searchBox, "ace_nomatch", noMatch); + this.editor._emit("findSearchBox", { match: !noMatch }); this.highlight(); }; this.findNext = function() { @@ -223,11 +235,31 @@ var SearchBox = function(editor, range, showReplaceForm) { this.findPrev = function() { this.find(true, true); }; + this.findAll = function(){ + var range = this.editor.findAll(this.searchInput.value, { + regExp: this.regExpOption.checked, + caseSensitive: this.caseSensitiveOption.checked, + wholeWord: this.wholeWordOption.checked + }); + var noMatch = !range && this.searchInput.value; + dom.setCssClass(this.searchBox, "ace_nomatch", noMatch); + this.editor._emit("findSearchBox", { match: !noMatch }); + this.highlight(); + this.hide(); + }; this.replace = function() { - this.editor.replace(this.replaceInput.value); + if (!this.editor.getReadOnly()) + this.editor.replace(this.replaceInput.value); + }; + this.replaceAndFindNext = function() { + if (!this.editor.getReadOnly()) { + this.editor.replace(this.replaceInput.value); + this.findNext() + } }; this.replaceAll = function() { - this.editor.replaceAll(this.replaceInput.value); + if (!this.editor.getReadOnly()) + this.editor.replaceAll(this.replaceInput.value); }; this.hide = function() { @@ -249,6 +281,10 @@ var SearchBox = function(editor, range, showReplaceForm) { this.editor.keyBinding.addKeyboardHandler(this.$closeSearchBarKb); }; + this.isFocused = function() { + var el = document.activeElement; + return el == this.searchInput || el == this.replaceInput; + } }).call(SearchBox.prototype); exports.SearchBox = SearchBox; @@ -258,47 +294,6 @@ exports.Search = function(editor, isReplace) { sb.show(editor.session.getTextRange(), isReplace); }; - -exports.ISearch = function(session, options) { - this.$changeListener = this.$changeListener.bind(this); - this.startRange = session.selection.toOrientedRange(); - this.options = options || {}; -}; - -(function(){ - this.setSession = function(session) { - if (this.session) { - this.session.removeListener(this.$changeListener); - } - this.session = session; - this.session.addListener(this.$changeListener); - }; - this.setSearchString = function() { - - }; - this.getValue = function() { - if (this.value == null) - this.value = this.session.getValue(); - return this.value; - }; - this.$changeListener = function() { - this.value = null; - }; - this.find = function() { - - }; - this.$edgeBefore = function() { - this.cursor = this.startRange[this.options.backwards ? "start" : "end"]; - }; - this.$edgeAfter = function() { - - }; - this.next = function(dir) { - - }; -}).call(exports.ISearch.prototype); - - }); diff --git a/lib/ace/ext/spellcheck.js b/lib/ace/ext/spellcheck.js index af596a49..08bf2189 100644 --- a/lib/ace/ext/spellcheck.js +++ b/lib/ace/ext/spellcheck.js @@ -17,8 +17,9 @@ exports.contextMenuHandler = function(e){ var PLACEHOLDER = "\x01\x01"; var value = w + " " + PLACEHOLDER; text.value = value; - text.setSelectionRange(w.length + 1, w.length + 1); + text.setSelectionRange(w.length, w.length + 1); text.setSelectionRange(0, 0); + text.setSelectionRange(0, w.length); var afterKeydown = false; event.addListener(text, "keydown", function onKeydown() { diff --git a/lib/ace/keyboard/vim/registers.js b/lib/ace/ext/split.js similarity index 92% rename from lib/ace/keyboard/vim/registers.js rename to lib/ace/ext/split.js index ef929a35..8316562f 100644 --- a/lib/ace/keyboard/vim/registers.js +++ b/lib/ace/ext/split.js @@ -3,7 +3,7 @@ * * 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 @@ -14,7 +14,7 @@ * * 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 @@ -29,14 +29,12 @@ * ***** END LICENSE BLOCK ***** */ define(function(require, exports, module) { +"use strict"; -"never use strict"; - -module.exports = { - _default: { - text: "", - isLine: false - } -}; +/** + * this is experimental, and subject to change, use at your own risk! + */ +module.exports = require("../split"); }); + diff --git a/lib/ace/ext/static.css b/lib/ace/ext/static.css index c080b575..51986c3f 100644 --- a/lib/ace/ext/static.css +++ b/lib/ace/ext/static.css @@ -1,22 +1,38 @@ -.ace_editor { - font-family: 'Monaco', 'Menlo', 'Droid Sans Mono', 'Courier New', monospace; - font-size: 12px; +.ace_static_highlight { + font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'source-code-pro', 'Droid Sans Mono', monospace; + font-size: 12px; + white-space: pre-wrap } -.ace_editor .ace_gutter { - width: 25px !important; - display: block; - float: left; +.ace_static_highlight .ace_gutter { + width: 2em; text-align: right; padding: 0 3px 0 0; margin-right: 3px; } -.ace_line { clear: both; } +.ace_static_highlight.ace_show_gutter .ace_line { + padding-left: 2.6em; +} -*.ace_gutter-cell { - -moz-user-select: -moz-none; - -khtml-user-select: none; - -webkit-user-select: none; - user-select: none; -} \ No newline at end of file +.ace_static_highlight .ace_line { position: relative; } + +.ace_static_highlight .ace_gutter-cell { + -moz-user-select: -moz-none; + -khtml-user-select: none; + -webkit-user-select: none; + user-select: none; + top: 0; + bottom: 0; + left: 0; + position: absolute; +} + + +.ace_static_highlight .ace_gutter-cell:before { + content: counter(ace_line, decimal); + counter-increment: ace_line; +} +.ace_static_highlight { + counter-reset: ace_line; +} diff --git a/lib/ace/ext/static_highlight.js b/lib/ace/ext/static_highlight.js index 3585476c..2acb3ac5 100644 --- a/lib/ace/ext/static_highlight.js +++ b/lib/ace/ext/static_highlight.js @@ -35,6 +35,54 @@ var EditSession = require("../edit_session").EditSession; var TextLayer = require("../layer/text").Text; var baseStyles = require("../requirejs/text!./static.css"); var config = require("../config"); +var dom = require("../lib/dom"); + +var SimpleTextLayer = function() { + this.config = {}; +}; +SimpleTextLayer.prototype = TextLayer.prototype; + +var highlight = function(el, opts, callback) { + var m = el.className.match(/lang-(\w+)/); + var mode = opts.mode || m && ("ace/mode/" + m[1]); + if (!mode) + return false; + var theme = opts.theme || "ace/theme/textmate"; + + var data = ""; + var nodes = []; + + if (el.firstElementChild) { + var textLen = 0; + for (var i = 0; i < el.childNodes.length; i++) { + var ch = el.childNodes[i]; + if (ch.nodeType == 3) { + textLen += ch.data.length; + data += ch.data; + } else { + nodes.push(textLen, ch); + } + } + } else { + data = dom.getInnerText(el); + if (opts.trim) + data = data.trim(); + } + + highlight.render(data, mode, theme, opts.firstLineNumber, !opts.showGutter, function (highlighted) { + dom.importCssString(highlighted.css, "ace_highlight"); + el.innerHTML = highlighted.html; + var container = el.firstChild.firstChild; + for (var i = 0; i < nodes.length; i += 2) { + var pos = highlighted.session.doc.indexToPosition(nodes[i]); + var node = nodes[i + 1]; + var lineEl = container.children[pos.row]; + lineEl && lineEl.appendChild(node); + } + callback && callback(); + }); +}; + /** * Transforms a given input code snippet into HTML using the given mode * @@ -54,9 +102,9 @@ var config = require("../config"); * and `css`. * @returns {object} An object containing the properties `html` and `css`. */ - -exports.render = function(input, mode, theme, lineStart, disableGutter, callback) { - var waiting = 0 +highlight.render = function(input, mode, theme, lineStart, disableGutter, callback) { + var waiting = 1; + var modeCache = EditSession.prototype.$modes; // if either the theme or the mode were specified as objects // then we need to lazily load them. @@ -67,44 +115,46 @@ exports.render = function(input, mode, theme, lineStart, disableGutter, callback --waiting || done(); }); } - + // allow setting mode options e.h {path: "ace/mode/php", inline:true} + var modeOptions; + if (mode && typeof mode === "object" && !mode.getTokenizer) { + modeOptions = mode; + mode = modeOptions.path; + } if (typeof mode == "string") { waiting++; config.loadModule(['mode', mode], function(m) { - mode = new m.Mode() + if (!modeCache[mode] || modeOptions) + modeCache[mode] = new m.Mode(modeOptions); + mode = modeCache[mode]; --waiting || done(); }); } // loads or passes the specified mode module then calls renderer function done() { - var result = exports.renderSync(input, mode, theme, lineStart, disableGutter); + var result = highlight.renderSync(input, mode, theme, lineStart, disableGutter); return callback ? callback(result) : result; } - return waiting || done(); + return --waiting || done(); }; -/* Transforms a given input code snippet into HTML using the given mode -* -* @param {string} input Code snippet -* @param {mode} mode Mode loaded from /ace/mode (use 'ServerSideHiglighter.getMode') -* @param {string} r Code snippet -* @returns {object} An object containing: html, css -*/ - -exports.renderSync = function(input, mode, theme, lineStart, disableGutter) { +/** + * Transforms a given input code snippet into HTML using the given mode + * @param {string} input Code snippet + * @param {mode} mode Mode loaded from /ace/mode (use 'ServerSideHiglighter.getMode') + * @param {string} r Code snippet + * @returns {object} An object containing: html, css + */ +highlight.renderSync = function(input, mode, theme, lineStart, disableGutter) { lineStart = parseInt(lineStart || 1, 10); var session = new EditSession(""); session.setUseWorker(false); session.setMode(mode); - var textLayer = new TextLayer(document.createElement("div")); + var textLayer = new SimpleTextLayer(); textLayer.setSession(session); - textLayer.config = { - characterWidth: 10, - lineHeight: 20 - }; session.setValue(input); @@ -114,24 +164,28 @@ exports.renderSync = function(input, mode, theme, lineStart, disableGutter) { for(var ix = 0; ix < length; ix++) { stringBuilder.push("
    "); if (!disableGutter) - stringBuilder.push("" + (ix + lineStart) + ""); + stringBuilder.push("" + /*(ix + lineStart) + */ ""); textLayer.$renderLine(stringBuilder, ix, true, false); - stringBuilder.push("
    "); + stringBuilder.push("\n
    "); } // let's prepare the whole html - var html = "
    \ -
    \ - :code\ -
    \ -
    ".replace(/:cssClass/, theme.cssClass).replace(/:code/, stringBuilder.join("")); + var html = "
    " + + "
    " + + stringBuilder.join("") + + "
    " + + "
    "; textLayer.destroy(); return { css: baseStyles + theme.cssText, - html: html + html: html, + session: session }; }; +module.exports = highlight; +module.exports.highlight =highlight; }); diff --git a/lib/ace/ext/static_highlight_test.js b/lib/ace/ext/static_highlight_test.js index 2113d14f..6271666d 100644 --- a/lib/ace/ext/static_highlight_test.js +++ b/lib/ace/ext/static_highlight_test.js @@ -9,6 +9,7 @@ define(function(require, exports, module) { var assert = require("assert"); var highlighter = require("./static_highlight"); var JavaScriptMode = require("../mode/javascript").Mode; +var TextMode = require("../mode/text").Mode; // Execution ORDER: test.setUpSuite, setUp, testFn, tearDown, test.tearDownSuite module.exports = { @@ -16,34 +17,42 @@ module.exports = { "test simple snippet": function(next) { var theme = require("../theme/tomorrow"); - var snippet = "\ -/** this is a function\n\ -*\n\ -*/\n\ -function hello (a, b, c) {\n\ - console.log(a * b + c + 'sup?');\n\ -}"; + var snippet = [ + "/** this is a function", + "*", + "*/", + "function hello (a, b, c) {", + " console.log(a * b + c + 'sup$');", + "}" + ].join("\n"); var mode = new JavaScriptMode(); var result = highlighter.render(snippet, mode, theme); - assert.equal(result.html, "
    1/**\xa0this\xa0is\xa0a\xa0function
    2*
    3*/
    4function\xa0hello\xa0(a,\xa0b,\xa0c)\xa0{
    5\xa0\xa0\xa0\xa0console.log(a\xa0*\xa0b\xa0+\xa0c\xa0+\xa0'sup?');
    6}
    "); + assert.equal(result.html, "
    " + + "
    /** this is a function\n
    " + + "
    *\n
    " + + "
    */\n
    " + + "
    function hello (a, b, c) {\n
    " + + "
    console.log(a * b + c + 'sup$');\n
    " + + "
    }\n
    " + + "
    "); assert.ok(!!result.css); next(); }, "test css from theme is used": function(next) { var theme = require("../theme/tomorrow"); - var snippet = "\ -/** this is a function\n\ -*\n\ -*/\n\ -function hello (a, b, c) {\n\ - console.log(a * b + c + 'sup?');\n\ -}"; + var snippet = [ + "/** this is a function", + "*", + "*/", + "function hello (a, b, c) {", + " console.log(a * b + c + 'sup?');", + "}" + ].join("\n"); var mode = new JavaScriptMode(); - var isError = false, result; - result = highlighter.render(snippet, mode, theme); + var result = highlighter.render(snippet, mode, theme); assert.ok(result.css.indexOf(theme.cssText) !== -1); @@ -52,19 +61,30 @@ function hello (a, b, c) {\n\ "test theme classname should be in output html": function(next) { var theme = require("../theme/tomorrow"); - var snippet = "\ -/** this is a function\n\ -*\n\ -*/\n\ -function hello (a, b, c) {\n\ - console.log(a * b + c + 'sup?');\n\ -}"; + var snippet = [ + "/** this is a function", + "*", + "*/", + "function hello (a, b, c) {", + " console.log(a * b + c + 'sup?');", + "}" + ].join("\n"); var mode = new JavaScriptMode(); - var isError = false, result; - result = highlighter.render(snippet, mode, theme); + var result = highlighter.render(snippet, mode, theme); assert.equal(!!result.html.match(/
    /), true); + next(); + }, + + "test js string replace specials": function(next) { + var theme = require("../theme/tomorrow"); + var snippet = "$'$1$2$$$&"; + var mode = new TextMode(); + + var result = highlighter.render(snippet, mode, theme); + assert.ok(result.html.indexOf(snippet) != -1); + next(); } }; diff --git a/lib/ace/ext/statusbar.js b/lib/ace/ext/statusbar.js index 666febfa..5e5b0572 100644 --- a/lib/ace/ext/statusbar.js +++ b/lib/ace/ext/statusbar.js @@ -28,9 +28,8 @@ var StatusBar = function(editor, parentNode) { str && status.push(str, separator || "|"); } - if (editor.$vimModeHandler) - add(editor.$vimModeHandler.getStatusText()); - else if (editor.commands.recording) + add(editor.keyBinding.getStatusText(editor)); + if (editor.commands.recording) add("REC"); var c = editor.selection.lead; diff --git a/lib/ace/ext/textarea.js b/lib/ace/ext/textarea.js index a402e65f..c9972488 100644 --- a/lib/ace/ext/textarea.js +++ b/lib/ace/ext/textarea.js @@ -74,7 +74,7 @@ function applyStyles(elm, styles) { function setupContainer(element, getValue) { if (element.type != 'textarea') { - throw "Textarea required!"; + throw new Error("Textarea required!"); } var parentNode = element.parentNode; @@ -155,7 +155,7 @@ function setupContainer(element, getValue) { return container; } -exports.transformTextarea = function(element, loader) { +exports.transformTextarea = function(element, options) { var session; var container = setupContainer(element, function() { return session.getValue(); @@ -215,9 +215,8 @@ exports.transformTextarea = function(element, loader) { applyStyles(settingDiv, settingDivStyles); container.appendChild(settingDiv); + options = options || exports.defaultOptions; // Power up ace on the textarea: - var options = {}; - var editor = ace.edit(editorDiv); session = editor.getSession(); @@ -228,10 +227,10 @@ exports.transformTextarea = function(element, loader) { container.appendChild(settingOpener); // Create the API. - setupApi(editor, editorDiv, settingDiv, ace, options, loader); + setupApi(editor, editorDiv, settingDiv, ace, options, load); // Create the setting's panel. - setupSettingPanel(settingDiv, settingOpener, editor, options); + setupSettingPanel(settingDiv, settingOpener, editor); var state = ""; event.addListener(settingOpener, "mousemove", function(e) { @@ -288,48 +287,23 @@ function setupApi(editor, editorDiv, settingDiv, ace, options, loader) { settingDiv.hideButton.focus(); editor.on("focus", function onFocus() { editor.removeListener("focus", onFocus); - settingDiv.style.display = "none" + settingDiv.style.display = "none"; }); } else { editor.focus(); - }; + } }; + editor.$setOption = editor.setOption; + editor.$getOption = editor.getOption; editor.setOption = function(key, value) { - if (options[key] == value) return; - switch (key) { - case "gutter": - renderer.setShowGutter(toBool(value)); - break; - case "mode": - if (value != "text") { - // Load the required mode file. Files get loaded only once. - loader("mode-" + value + ".js", "ace/mode/" + value, function() { - var aceMode = require("../mode/" + value).Mode; - session.setMode(new aceMode()); - }); - } else { - session.setMode(new (require("../mode/text").Mode)); - } + editor.$setOption("mode", "ace/mode/" + value) break; - case "theme": - if (value != "textmate") { - // Load the required theme file. Files get loaded only once. - loader("theme-" + value + ".js", "ace/theme/" + value, function() { - editor.setTheme("ace/theme/" + value); - }); - } else { - editor.setTheme("ace/theme/textmate"); - } + editor.$setOption("theme", "ace/theme/" + value) break; - - case "fontSize": - editorDiv.style.fontSize = value; - break; - case "keybindings": switch (value) { case "vim": @@ -344,69 +318,55 @@ function setupApi(editor, editorDiv, settingDiv, ace, options, loader) { break; case "softWrap": - switch (value) { - case "off": - session.setUseWrapMode(false); - renderer.setPrintMarginColumn(80); - break; - case "40": - session.setUseWrapMode(true); - session.setWrapLimitRange(40, 40); - renderer.setPrintMarginColumn(40); - break; - case "80": - session.setUseWrapMode(true); - session.setWrapLimitRange(80, 80); - renderer.setPrintMarginColumn(80); - break; - case "free": - session.setUseWrapMode(true); - session.setWrapLimitRange(null, null); - renderer.setPrintMarginColumn(80); - break; - } - break; - - case "useSoftTabs": - session.setUseSoftTabs(toBool(value)); - break; - - case "showPrintMargin": - renderer.setShowPrintMargin(toBool(value)); - break; - - case "showInvisibles": - editor.setShowInvisibles(toBool(value)); + case "fontSize": + editor.$setOption(key, value); break; + + default: + editor.$setOption(key, toBool(value)); } - - options[key] = value; }; editor.getOption = function(key) { - return options[key]; + switch (key) { + case "mode": + return editor.$getOption("mode").substr("ace/mode/".length) + break; + + case "theme": + return editor.$getOption("theme").substr("ace/theme/".length) + break; + + case "keybindings": + var value = editor.getKeyboardHandler() + switch (value && value.$id) { + case "ace/keyboard/vim": + return "vim"; + case "ace/keyboard/emacs": + return "emacs"; + default: + return "ace"; + } + break; + + default: + return editor.$getOption(key); + } }; - editor.getOptions = function() { - return options; - }; - - for (var option in exports.options) { - editor.setOption(option, exports.options[option]); - } - + editor.setOptions(options); return editor; } -function setupSettingPanel(settingDiv, settingOpener, editor, options) { +function setupSettingPanel(settingDiv, settingOpener, editor) { var BOOL = null; var desc = { mode: "Mode:", - gutter: "Display Gutter:", + wrap: "Soft Wrap:", theme: "Theme:", fontSize: "Font Size:", - softWrap: "Soft Wrap:", + showGutter: "Display Gutter:", keybindings: "Keyboard", showPrintMargin: "Show Print Margin:", useSoftTabs: "Use Soft Tabs:", @@ -459,7 +419,7 @@ function setupSettingPanel(settingDiv, settingOpener, editor, options) { twilight: "Twilight", vibrant_ink: "Vibrant Ink" }, - gutter: BOOL, + showGutter: BOOL, fontSize: { "10px": "10px", "11px": "11px", @@ -467,7 +427,7 @@ function setupSettingPanel(settingDiv, settingOpener, editor, options) { "14px": "14px", "16px": "16px" }, - softWrap: { + wrap: { off: "Off", 40: "40", 80: "80", @@ -490,10 +450,10 @@ function setupSettingPanel(settingDiv, settingOpener, editor, options) { if (!obj) { builder.push( "" ); - return + return; } builder.push(""); } - for (var option in options) { + for (var option in exports.defaultOptions) { table.push("", desc[option], ""); table.push(""); - renderOption(table, option, optionValues[option], options[option]); + renderOption(table, option, optionValues[option], editor.getOption(option)); table.push(""); } table.push(""); @@ -546,12 +506,12 @@ function setupSettingPanel(settingDiv, settingOpener, editor, options) { } // Default startup options. -exports.options = { - mode: "text", +exports.defaultOptions = { + mode: "javascript", theme: "textmate", - gutter: "false", + wrap: "off", fontSize: "12px", - softWrap: "off", + showGutter: "false", keybindings: "ace", showPrintMargin: "false", useSoftTabs: "true", diff --git a/lib/ace/ext/themelist.js b/lib/ace/ext/themelist.js index 1032f72c..0df76b02 100644 --- a/lib/ace/ext/themelist.js +++ b/lib/ace/ext/themelist.js @@ -30,8 +30,6 @@ * * ***** END LICENSE BLOCK ***** */ -/*jslint indent: 4, maxerr: 50, white: true, browser: true, vars: true*/ -/*global define, require */ /** * Generates a list of themes available when ace was built. @@ -43,36 +41,62 @@ define(function(require, exports, module) { "use strict"; +require("ace/lib/fixoldbrowsers"); + +var themeData = [ + ["Chrome" ], + ["Clouds" ], + ["Crimson Editor" ], + ["Dawn" ], + ["Dreamweaver" ], + ["Eclipse" ], + ["GitHub" ], + ["IPlastic" ], + ["Solarized Light"], + ["TextMate" ], + ["Tomorrow" ], + ["XCode" ], + ["Kuroir"], + ["KatzenMilch"], + ["SQL Server" ,"sqlserver" , "light"], + ["Ambiance" ,"ambiance" , "dark"], + ["Chaos" ,"chaos" , "dark"], + ["Clouds Midnight" ,"clouds_midnight" , "dark"], + ["Cobalt" ,"cobalt" , "dark"], + ["idle Fingers" ,"idle_fingers" , "dark"], + ["krTheme" ,"kr_theme" , "dark"], + ["Merbivore" ,"merbivore" , "dark"], + ["Merbivore Soft" ,"merbivore_soft" , "dark"], + ["Mono Industrial" ,"mono_industrial" , "dark"], + ["Monokai" ,"monokai" , "dark"], + ["Pastel on dark" ,"pastel_on_dark" , "dark"], + ["Solarized Dark" ,"solarized_dark" , "dark"], + ["Terminal" ,"terminal" , "dark"], + ["Tomorrow Night" ,"tomorrow_night" , "dark"], + ["The Night After Tomorrow" ,"the_night_after_tomorrow" , "dark"], + ["Tomorrow Night Blue" ,"tomorrow_night_blue" , "dark"], + ["Tomorrow Night Bright","tomorrow_night_bright" , "dark"], + ["Tomorrow Night 80s" ,"tomorrow_night_eighties" , "dark"], + ["Twilight" ,"twilight" , "dark"], + ["Vibrant Ink" ,"vibrant_ink" , "dark"] +]; + + +exports.themesByName = {}; /** * An array containing information about available themes. */ -module.exports.themes = require('ace/ext/themelist_utils/themes').themes; - -/** - * Creates a theme description. - * @param {string} name The file name of the theme. - * @returns {ThemeDescription} Returns a theme description object which has - * three properties: the name gives the filename, the desc gives a menu - * friendly name, and the theme gives the string to set the theme with - * `setTheme` - */ -module.exports.ThemeDescription = function(name) { - this.name = name; - this.desc = name.split('_' - ).map( - function(namePart) { - return namePart[0].toUpperCase() + namePart.slice(1); - } - ).join(' '); - this.theme = "ace/theme/" + name; -}; - -module.exports.themesByName = {}; - -module.exports.themes = module.exports.themes.map(function(name) { - module.exports.themesByName[name] = new module.exports.ThemeDescription(name); - return module.exports.themesByName[name]; +exports.themes = themeData.map(function(data) { + var name = data[1] || data[0].replace(/ /g, "_").toLowerCase(); + var theme = { + caption: data[0], + theme: "ace/theme/" + name, + isDark: data[2] == "dark", + name: name + }; + exports.themesByName[name] = theme; + return theme; }); }); diff --git a/lib/ace/ext/themelist_utils/themes.js b/lib/ace/ext/themelist_utils/themes.js deleted file mode 100644 index 6b20770a..00000000 --- a/lib/ace/ext/themelist_utils/themes.js +++ /dev/null @@ -1,36 +0,0 @@ -define(function(require, exports, module) { - -module.exports.themes = [ - "ambiance", - "chaos", - "chrome", - "clouds", - "clouds_midnight", - "cobalt", - "crimson_editor", - "dawn", - "dreamweaver", - "eclipse", - "github", - "idle_fingers", - "kr_theme", - "merbivore", - "merbivore_soft", - "monokai", - "mono_industrial", - "pastel_on_dark", - "solarized_dark", - "solarized_light", - "terminal", - "textmate", - "tomorrow", - "tomorrow_night", - "tomorrow_night_blue", - "tomorrow_night_bright", - "tomorrow_night_eighties", - "twilight", - "vibrant_ink", - "xcode" -]; - -}); \ No newline at end of file diff --git a/lib/ace/ext/whitespace.js b/lib/ace/ext/whitespace.js index 234a9579..27ee223e 100644 --- a/lib/ace/ext/whitespace.js +++ b/lib/ace/ext/whitespace.js @@ -46,7 +46,6 @@ exports.$detectIndentation = function(lines, fallback) { if (!/^\s*[^*+\-\s]/.test(line)) continue; - var tabs = line.match(/^\t*/)[0].length; if (line[0] == "\t") tabIndents++; @@ -61,10 +60,10 @@ exports.$detectIndentation = function(lines, fallback) { prevSpaces = spaces; // ignore lines ending with backslash - while (line[line.length - 1] == "\\") + while (i < max && line[line.length - 1] == "\\") line = lines[i++]; - }; - + } + function getScore(indent) { var score = 0; for (var i = indent; i < stats.length; i += indent) @@ -77,15 +76,17 @@ exports.$detectIndentation = function(lines, fallback) { var first = {score: 0, length: 0}; var spaceIndents = 0; for (var i = 1; i < 12; i++) { + var score = getScore(i); if (i == 1) { - spaceIndents = getScore(i); - var score = 1; + spaceIndents = score; + score = stats[1] ? 0.9 : 0.8; + if (!stats.length) + score = 0 } else - var score = getScore(i) / spaceIndents; + score /= spaceIndents; - if (changes[i]) { + if (changes[i]) score += changes[i] / changesTotal; - } if (score > first.score) first = {score: score, length: i}; @@ -97,7 +98,7 @@ exports.$detectIndentation = function(lines, fallback) { if (tabIndents > spaceIndents + 1) return {ch: "\t", length: tabLength}; - if (spaceIndents + 1 > tabIndents) + if (spaceIndents > tabIndents + 1) return {ch: " ", length: tabLength}; }; @@ -113,15 +114,17 @@ exports.detectIndentation = function(session) { return indent; }; -exports.trimTrailingSpace = function(session) { +exports.trimTrailingSpace = function(session, trimEmpty) { var doc = session.getDocument(); var lines = doc.getAllLines(); + + var min = trimEmpty ? -1 : 0; for (var i = 0, l=lines.length; i < l; i++) { var line = lines[i]; var index = line.search(/\s+$/); - if (index !== -1) + if (index > min) doc.removeInLine(i, index, line.length); } }; @@ -160,14 +163,14 @@ exports.convertIndentation = function(session, ch, len) { }; exports.$parseStringArg = function(text) { - var indent = {} + var indent = {}; if (/t/.test(text)) indent.ch = "\t"; else if (/s/.test(text)) indent.ch = " "; var m = text.match(/\d+/); if (m) - indent.length = parseInt(m[0]); + indent.length = parseInt(m[0], 10); return indent; }; @@ -179,7 +182,7 @@ exports.$parseArg = function(arg) { if (typeof arg.text == "string") return exports.$parseStringArg(arg.text); return arg; -} +}; exports.commands = [{ name: "detectIndentation", @@ -196,7 +199,7 @@ exports.commands = [{ name: "convertIndentation", exec: function(editor, arg) { var indent = exports.$parseArg(arg); - exports.convertIndentation(editor.session, arg.ch, arg.length); + exports.convertIndentation(editor.session, indent.ch, indent.length); } }, { name: "setIndentation", @@ -205,6 +208,6 @@ exports.commands = [{ indent.length && editor.session.setTabSize(indent.length); indent.ch && editor.session.setUseSoftTabs(indent.ch == " "); } -}] +}]; }); diff --git a/lib/ace/ext/whitespace_test.js b/lib/ace/ext/whitespace_test.js new file mode 100644 index 00000000..be4f360f --- /dev/null +++ b/lib/ace/ext/whitespace_test.js @@ -0,0 +1,116 @@ +if (typeof process !== "undefined") { + require("amd-loader"); + require("../test/mockdom"); +} + +define(function(require, exports, module) { +"use strict"; + +var assert = require("assert"); +var EditSession = require("../edit_session").EditSession; +var whitespace = require("./whitespace"); + +// Execution ORDER: test.setUpSuite, setUp, testFn, tearDown, test.tearDownSuite +module.exports = { + timeout: 10000, + + "test tab detection": function(next) { + var s = new EditSession([ + "define({", + "\tfoo:1,", + "\tbar:2,", + "\tbaz:{,", + "\t\tx:3", + "\t}", + "})" + ]); + + var indent = whitespace.$detectIndentation(s.doc.$lines); + assert.equal(indent.ch, "\t"); + assert.equal(indent.length, undefined); + + s.insert({row: 0, column: 0}, " "); + indent = whitespace.$detectIndentation(s.doc.$lines); + assert.equal(indent.ch, "\t"); + assert.equal(indent.length, 4); + + s.setValue(""); + indent = whitespace.$detectIndentation(s.doc.$lines); + assert.ok(!indent); + + next(); + }, + + "test empty session": function(next) { + var s = new EditSession([ + "define({", + "foo:1,", + "})" + ]); + var indent = whitespace.$detectIndentation(s.doc.$lines); + assert.ok(!indent); + s.insert({row: 1, column: 0}, " x\n "); + + indent = whitespace.$detectIndentation(s.doc.$lines); + assert.equal(indent.ch, " "); + assert.equal(indent.length, 4); + + next(); + }, + + "!test one line": function(next) { + var s = new EditSession([ + "define({", + " foo:1,", + "})" + ]); + var indent = whitespace.$detectIndentation(s.doc.$lines); + assert.equal(indent.ch, " "); + assert.equal(indent.length, 4); + + next(); + }, + + "test 1 width indents": function(next) { + var s = new EditSession([ + "define({", + " foo:1,", + "})", + "define({", + " bar:1,", + "})", + " t", + " t", + " t", + " t", + " t", + " t", + " t", + " t" + ]); + var indent = whitespace.$detectIndentation(s.doc.$lines); + // assert.equal(indent.ch, " "); + // assert.equal(indent.length, 4); + + s = new EditSession([ + "{", + " foo:1,", + " bar: {", + " baz:2", + " }", + "}" + ]); + indent = whitespace.$detectIndentation(s.doc.$lines); + assert.equal(indent.ch, " "); + assert.equal(indent.length, 1); + + next(); + }, + +}; + +}); + +if (typeof module !== "undefined" && module === require.main) { + require("asyncjs").test.testcase(module.exports).exec(); +} diff --git a/lib/ace/incremental_search.js b/lib/ace/incremental_search.js index e6fa8928..e4c1bdf8 100644 --- a/lib/ace/incremental_search.js +++ b/lib/ace/incremental_search.js @@ -64,6 +64,34 @@ function IncrementalSearch() { oop.inherits(IncrementalSearch, Search); +// regexp handling + +function isRegExp(obj) { + return obj instanceof RegExp; +} + +function regExpToObject(re) { + var string = String(re), + start = string.indexOf('/'), + flagStart = string.lastIndexOf('/'); + return { + expression: string.slice(start+1, flagStart), + flags: string.slice(flagStart+1) + } +} + +function stringToRegExp(string, flags) { + try { + return new RegExp(string, flags); + } catch (e) { return string; } +} + +function objectToRegExp(obj) { + return stringToRegExp(obj.expression, obj.flags); +} + +// iSearch class + ;(function() { this.activate = function(ed, backwards) { @@ -72,20 +100,24 @@ oop.inherits(IncrementalSearch, Search); this.$options.needle = ''; this.$options.backwards = backwards; ed.keyBinding.addKeyboardHandler(this.$keyboardHandler); + // we need to completely intercept paste, just registering an event handler does not work + this.$originalEditorOnPaste = ed.onPaste; ed.onPaste = this.onPaste.bind(this); this.$mousedownHandler = ed.addEventListener('mousedown', this.onMouseDown.bind(this)); this.selectionFix(ed); this.statusMessage(true); - } + }; this.deactivate = function(reset) { this.cancelSearch(reset); - this.$editor.keyBinding.removeKeyboardHandler(this.$keyboardHandler); + var ed = this.$editor; + ed.keyBinding.removeKeyboardHandler(this.$keyboardHandler); if (this.$mousedownHandler) { - this.$editor.removeEventListener('mousedown', this.$mousedownHandler); + ed.removeEventListener('mousedown', this.$mousedownHandler); delete this.$mousedownHandler; } + ed.onPaste = this.$originalEditorOnPaste; this.message(''); - } + }; this.selectionFix = function(editor) { // Fix selection bug: When clicked inside the editor @@ -96,7 +128,7 @@ oop.inherits(IncrementalSearch, Search); if (editor.selection.isEmpty() && !editor.session.$emacsMark) { editor.clearSelection(); } - } + }; this.highlight = function(regexp) { var sess = this.$editor.session, @@ -104,7 +136,7 @@ oop.inherits(IncrementalSearch, Search); new SearchHighlight(null, "ace_isearch-result", "text")); hl.setRegexp(regexp); sess._emit("changeBackMarker"); // force highlight layer redraw - } + }; this.cancelSearch = function(reset) { var e = this.$editor; @@ -118,7 +150,7 @@ oop.inherits(IncrementalSearch, Search); } this.highlight(null); return Range.fromPoints(this.$currentPos, this.$currentPos); - } + }; this.highlightAndFindWithNeedle = function(moveToNext, needleUpdateFunc) { if (!this.$editor) return null; @@ -131,36 +163,46 @@ oop.inherits(IncrementalSearch, Search); if (options.needle.length === 0) { this.statusMessage(true); return this.cancelSearch(true); - }; + } // try to find the next occurence and enable highlighting marker options.start = this.$currentPos; var session = this.$editor.session, - found = this.find(session); + found = this.find(session), + shouldSelect = this.$editor.emacsMark ? + !!this.$editor.emacsMark() : !this.$editor.selection.isEmpty(); if (found) { if (options.backwards) found = Range.fromPoints(found.end, found.start); - this.$editor.moveCursorToPosition(found.end); + this.$editor.selection.setRange(Range.fromPoints(shouldSelect ? this.$startPos : found.end, found.end)); if (moveToNext) this.$currentPos = found.end; // highlight after cursor move, so selection works properly - this.highlight(options.re) + this.highlight(options.re); } this.statusMessage(found); return found; - } + }; - this.addChar = function(c) { + this.addString = function(s) { return this.highlightAndFindWithNeedle(false, function(needle) { - return needle + c; + if (!isRegExp(needle)) + return needle + s; + var reObj = regExpToObject(needle); + reObj.expression += s; + return objectToRegExp(reObj); }); - } + }; this.removeChar = function(c) { return this.highlightAndFindWithNeedle(false, function(needle) { - return needle.length > 0 ? needle.substring(0, needle.length-1) : needle; + if (!isRegExp(needle)) + return needle.substring(0, needle.length-1); + var reObj = regExpToObject(needle); + reObj.expression = reObj.expression.substring(0, reObj.expression.length-1); + return objectToRegExp(reObj); }); - } + }; this.next = function(options) { // try to find the next occurence of whatever we have searched for @@ -173,13 +215,29 @@ oop.inherits(IncrementalSearch, Search); return options.useCurrentOrPrevSearch && needle.length === 0 ? this.$prevNeedle || '' : needle; }); - } + }; this.onMouseDown = function(evt) { // when mouse interaction happens then we quit incremental search this.deactivate(); return true; - } + }; + + this.onPaste = function(text) { + this.addString(text); + }; + + this.convertNeedleToRegExp = function() { + return this.highlightAndFindWithNeedle(false, function(needle) { + return isRegExp(needle) ? needle : stringToRegExp(needle, 'ig'); + }); + }; + + this.convertNeedleToString = function() { + return this.highlightAndFindWithNeedle(false, function(needle) { + return isRegExp(needle) ? regExpToObject(needle).expression : needle; + }); + }; this.statusMessage = function(found) { var options = this.$options, msg = ''; @@ -187,7 +245,7 @@ oop.inherits(IncrementalSearch, Search); msg += 'isearch: ' + options.needle; msg += found ? '' : ' (not found)'; this.message(msg); - } + }; this.message = function(msg) { if (this.$editor.showCommandLine) { @@ -196,7 +254,7 @@ oop.inherits(IncrementalSearch, Search); } else { console.log(msg); } - } + }; }).call(IncrementalSearch.prototype); diff --git a/lib/ace/incremental_search_test.js b/lib/ace/incremental_search_test.js index c351d8e2..d1303b42 100644 --- a/lib/ace/incremental_search_test.js +++ b/lib/ace/incremental_search_test.js @@ -35,13 +35,17 @@ if (typeof process !== "undefined") { define(function(require, exports, module) { "use strict"; +var emacs = require('./keyboard/emacs'); var EditSession = require("./edit_session").EditSession; var Editor = require("./editor").Editor; var MockRenderer = require("./test/mockrenderer").MockRenderer; var Range = require("./range").Range; +var MultiSelect = require("./multi_select").MultiSelect; var assert = require("./test/assertions"); var IncrementalSearch = require("./incremental_search").IncrementalSearch; +require("./multi_select"); + var editor, iSearch; function testRanges(str, ranges) { ranges = ranges || editor.selection.getAllRanges(); @@ -69,6 +73,7 @@ module.exports = { setUp: function() { var session = new EditSession(["abc123", "xyz124"]); editor = new Editor(new MockRenderer(), session); + new MultiSelect(editor); iSearch = new IncrementalSearch(); }, @@ -95,17 +100,17 @@ module.exports = { "test: find simple text incrementally" : function() { iSearch.activate(editor); - var range = iSearch.addChar('1'), // "1" + var range = iSearch.addString('1'), // "1" highlightRanges = callHighlighterUpdate(editor.session); testRanges("Range: [0/3] -> [0/4]", [range], "range"); testRanges("Range: [0/3] -> [0/4],Range: [1/3] -> [1/4]", highlightRanges, "highlight"); - range = iSearch.addChar('2'); // "12" + range = iSearch.addString('2'); // "12" highlightRanges = callHighlighterUpdate(editor.session); testRanges("Range: [0/3] -> [0/5]", [range], "range"); testRanges("Range: [0/3] -> [0/5],Range: [1/3] -> [1/5]", highlightRanges, "highlight"); - range = iSearch.addChar('3'); // "123" + range = iSearch.addString('3'); // "123" highlightRanges = callHighlighterUpdate(editor.session); testRanges("Range: [0/3] -> [0/6]", [range], "range"); testRanges("Range: [0/3] -> [0/6]", highlightRanges, "highlight"); @@ -118,7 +123,7 @@ module.exports = { "test: forward / backward" : function() { iSearch.activate(editor); - iSearch.addChar('1'); iSearch.addChar('2'); + iSearch.addString('1'); iSearch.addString('2'); var range = iSearch.next(); testRanges("Range: [1/3] -> [1/5]", [range], "range"); @@ -131,18 +136,18 @@ module.exports = { "test: cancelSearch" : function() { iSearch.activate(editor); - iSearch.addChar('1'); iSearch.addChar('2'); + iSearch.addString('1'); iSearch.addString('2'); var range = iSearch.cancelSearch(true); testRanges("Range: [0/0] -> [0/0]", [range], "range"); - iSearch.addChar('1'); range = iSearch.addChar('2'); + iSearch.addString('1'); range = iSearch.addString('2'); testRanges("Range: [0/3] -> [0/5]", [range], "range"); }, "test: failing search keeps pos" : function() { iSearch.activate(editor); - iSearch.addChar('1'); iSearch.addChar('2'); - var range = iSearch.addChar('x'); + iSearch.addString('1'); iSearch.addString('2'); + var range = iSearch.addString('x'); testRanges("", [range], "range"); assert.position(editor.getCursorPosition(), 0, 5); }, @@ -150,14 +155,14 @@ module.exports = { "test: backwards search" : function() { editor.moveCursorTo(1,0); iSearch.activate(editor, true); - iSearch.addChar('1'); var range = iSearch.addChar('2');; + iSearch.addString('1'); var range = iSearch.addString('2');; testRanges("Range: [0/5] -> [0/3]", [range], "range"); assert.position(editor.getCursorPosition(), 0, 3); }, "test: forwards then backwards, same result, reoriented range" : function() { iSearch.activate(editor); - iSearch.addChar('1'); var range = iSearch.addChar('2');; + iSearch.addString('1'); var range = iSearch.addString('2');; testRanges("Range: [0/3] -> [0/5]", [range], "range"); assert.position(editor.getCursorPosition(), 0, 5); @@ -168,7 +173,7 @@ module.exports = { "test: reuse prev search via option" : function() { iSearch.activate(editor); - iSearch.addChar('1'); iSearch.addChar('2');; + iSearch.addString('1'); iSearch.addString('2');; assert.position(editor.getCursorPosition(), 0, 5); iSearch.deactivate(); @@ -179,14 +184,14 @@ module.exports = { "test: don't extend selection range if selection is empty" : function() { iSearch.activate(editor); - iSearch.addChar('1'); iSearch.addChar('2');; + iSearch.addString('1'); iSearch.addString('2');; testRanges("Range: [0/5] -> [0/5]", [editor.getSelectionRange()], "sel range"); }, "test: extend selection range if selection exists" : function() { iSearch.activate(editor); editor.selection.selectTo(0, 1); - iSearch.addChar('1'); iSearch.addChar('2');; + iSearch.addString('1'); iSearch.addString('2');; testRanges("Range: [0/0] -> [0/5]", [editor.getSelectionRange()], "sel range"); }, @@ -195,7 +200,7 @@ module.exports = { editor.keyBinding.addKeyboardHandler(emacs.handler); emacs.handler.commands.setMark.exec(editor); iSearch.activate(editor); - iSearch.addChar('1'); iSearch.addChar('2');; + iSearch.addString('1'); iSearch.addString('2'); testRanges("Range: [0/0] -> [0/5]", [editor.getSelectionRange()], "sel range"); } diff --git a/lib/ace/keyboard/emacs.js b/lib/ace/keyboard/emacs.js index 1cb84f59..8cecad1b 100644 --- a/lib/ace/keyboard/emacs.js +++ b/lib/ace/keyboard/emacs.js @@ -64,14 +64,14 @@ exports.handler.attach = function(editor) { initialized = true; dom.importCssString('\ .emacs-mode .ace_cursor{\ - border: 2px rgba(50,250,50,0.8) solid!important;\ + border: 1px rgba(50,250,50,0.8) solid!important;\ -moz-box-sizing: border-box!important;\ -webkit-box-sizing: border-box!important;\ box-sizing: border-box!important;\ background-color: rgba(0,250,0,0.9);\ opacity: 0.5;\ }\ - .emacs-mode .ace_cursor.ace_hidden{\ + .emacs-mode .ace_hidden-cursors .ace_cursor{\ opacity: 1;\ background-color: transparent;\ }\ @@ -100,29 +100,47 @@ exports.handler.attach = function(editor) { editor.emacsMark = function() { return this.session.$emacsMark; - } + }; editor.setEmacsMark = function(p) { // to deactivate pass in a falsy value this.session.$emacsMark = p; - } + }; editor.pushEmacsMark = function(p, activate) { var prevMark = this.session.$emacsMark; if (prevMark) this.session.$emacsMarkRing.push(prevMark); - if (!p || activate) this.setEmacsMark(p) + if (!p || activate) this.setEmacsMark(p); else this.session.$emacsMarkRing.push(p); - } + }; editor.popEmacsMark = function() { var mark = this.emacsMark(); if (mark) { this.setEmacsMark(null); return mark; } return this.session.$emacsMarkRing.pop(); - } + }; editor.getLastEmacsMark = function(p) { return this.session.$emacsMark || this.session.$emacsMarkRing.slice(-1)[0]; + }; + + editor.emacsMarkForSelection = function(replacement) { + // find the mark in $emacsMarkRing corresponding to the current + // selection + var sel = this.selection, + multiRangeLength = this.multiSelect ? + this.multiSelect.getAllRanges().length : 1, + selIndex = sel.index || 0, + markRing = this.session.$emacsMarkRing, + markIndex = markRing.length - (multiRangeLength - selIndex), + lastMark = markRing[markIndex] || sel.anchor; + if (replacement) { + markRing.splice(markIndex, 1, + "row" in replacement && "column" in replacement ? + replacement : undefined); + } + return lastMark; } editor.on("click", $resetMarkMode); @@ -146,6 +164,7 @@ exports.handler.detach = function(editor) { editor.commands.removeCommands(commands); editor.removeEventListener('copy', this.onCopy); editor.removeEventListener('paste', this.onPaste); + editor.$emacsModeHandler = null; }; var $kbSessionChange = function(e) { @@ -163,15 +182,15 @@ var $kbSessionChange = function(e) { e.session.$emacsMark = null; if (!e.session.hasOwnProperty('$emacsMarkRing')) e.session.$emacsMarkRing = []; -} +}; var $resetMarkMode = function(e) { e.editor.session.$emacsMark = null; -} +}; -var keys = require("../lib/keys").KEY_MODS, - eMods = {C: "ctrl", S: "shift", M: "alt", CMD: "command"}, - combinations = ["C-S-M-CMD", +var keys = require("../lib/keys").KEY_MODS; +var eMods = {C: "ctrl", S: "shift", M: "alt", CMD: "command"}; +var combinations = ["C-S-M-CMD", "S-M-CMD", "C-M-CMD", "C-S-CMD", "C-S-M", "M-CMD", "S-CMD", "S-M", "C-CMD", "C-M", "C-S", "CMD", "M", "S", "C"]; @@ -187,18 +206,20 @@ exports.handler.onCopy = function(e, editor) { if (editor.$handlesEmacsOnCopy) return; editor.$handlesEmacsOnCopy = true; exports.handler.commands.killRingSave.exec(editor); - delete editor.$handlesEmacsOnCopy; -} + editor.$handlesEmacsOnCopy = false; +}; exports.handler.onPaste = function(e, editor) { editor.pushEmacsMark(editor.getCursorPosition()); -} +}; exports.handler.bindKey = function(key, command) { + if (typeof key == "object") + key = key[this.platform]; if (!key) return; - var ckb = this.commmandKeyBinding; + var ckb = this.commandKeyBinding; key.split("|").forEach(function(keyPart) { keyPart = keyPart.toLowerCase(); ckb[keyPart] = command; @@ -206,7 +227,7 @@ exports.handler.bindKey = function(key, command) { // to be able to activate key combos with arbitrary length // Example: if keyPart is "C-c C-l t" then "C-c C-l t" will // get command assigned and "C-c" and "C-c C-l" will get - // a null command assigned in this.commmandKeyBinding. For + // a null command assigned in this.commandKeyBinding. For // the lookup logic see handleKeyboard() var keyParts = keyPart.split(" ").slice(0,-1); keyParts.reduce(function(keyMapKeys, keyPart, i) { @@ -216,38 +237,45 @@ exports.handler.bindKey = function(key, command) { if (!ckb[keyPart]) ckb[keyPart] = "null"; }); }, this); -} +}; + +exports.handler.getStatusText = function(editor, data) { + var str = ""; + if (data.count) + str += data.count; + if (data.keyChain) + str += " " + data.keyChain + return str; +}; exports.handler.handleKeyboard = function(data, hashId, key, keyCode) { + // if keyCode == -1 a non-printable key was pressed, such as just + // control. Handling those is currently not supported in this handler + if (keyCode === -1) return undefined; + var editor = data.editor; + editor._signal("changeStatus"); // insertstring data.count times if (hashId == -1) { editor.pushEmacsMark(); if (data.count) { - var str = Array(data.count + 1).join(key); + var str = new Array(data.count + 1).join(key); data.count = null; return {command: "insertstring", args: str}; } } - if (key == "\x00") return undefined; - var modifier = eMods[hashId]; // CTRL + number / universalArgument for setting data.count - if (modifier == "c-" || data.universalArgument) { - var prevCount = String(data.count || 0); + if (modifier == "c-" || data.count) { var count = parseInt(key[key.length - 1]); if (typeof count === 'number' && !isNaN(count)) { - data.count = parseInt(prevCount + count); + data.count = Math.max(data.count, 0) || 0; + data.count = 10 * data.count + count; return {command: "null"}; - } else if (data.universalArgument) { - // if no number pressed use emacs defaults for universalArgument - // which is 4 - data.count = 4; } } - data.universalArgument = false; // this.commandKeyBinding maps key specs like "c-p" (for CTRL + P) to // command objects, for lookup key needs to include the modifier @@ -257,9 +285,9 @@ exports.handler.handleKeyboard = function(data, hashId, key, keyCode) { if (data.keyChain) key = data.keyChain += " " + key; // Key combo prefixes get stored as "null" (String!) in this - // this.commmandKeyBinding. When encountered no command is invoked but we + // this.commandKeyBinding. When encountered no command is invoked but we // buld up data.keyChain - var command = this.commmandKeyBinding[key]; + var command = this.commandKeyBinding[key]; data.keyChain = command == "null" ? key : ""; // there really is no command @@ -269,7 +297,9 @@ exports.handler.handleKeyboard = function(data, hashId, key, keyCode) { if (command === "null") return {command: "null"}; if (command === "universalArgument") { - data.universalArgument = true; + // if no number pressed emacs repeats action 4 times. + // minus sign is needed to allow next keypress to replace it + data.count = -4; return {command: "null"}; } @@ -296,9 +326,12 @@ exports.handler.handleKeyboard = function(data, hashId, key, keyCode) { if (!command) return undefined; } - if (!command.readonly && !command.isYank) + if (!command.readOnly && !command.isYank) data.lastCommand = null; + if (!command.readOnly && editor.emacsMark()) + editor.setEmacsMark(null) + if (data.count) { var count = data.count; data.count = 0; @@ -309,11 +342,12 @@ exports.handler.handleKeyboard = function(data, hashId, key, keyCode) { exec: function(editor, args) { for (var i = 0; i < count; i++) command.exec(editor, args); - } + }, + multiSelectAction: command.multiSelectAction } }; } else { - if (!args) args = {} + if (!args) args = {}; if (typeof args === 'object') args.count = count; } } @@ -380,7 +414,7 @@ exports.emacsKeys = { "M-y": "yankRotate", "C-g": "keyboardQuit", - "C-w": "killRegion", + "C-w|C-S-W": "killRegion", "M-w": "killRingSave", "C-Space": "setMark", "C-x C-x": "exchangePointAndMark", @@ -394,7 +428,7 @@ exports.emacsKeys = { "M-;": "togglecomment", "C-/|C-x u|S-C--|C-z": "undo", - "S-C-/|S-C-x u|C--|S-C-z": "redo", //infinite undo? + "S-C-/|S-C-x u|C--|S-C-z": "redo", // infinite undo? // vertical editing "C-x r": "selectRectangularRegion", "M-x": {command: "focusCommandLine", args: "M-x "} @@ -430,61 +464,65 @@ exports.handler.addCommands({ // selection modification commands. That is, // "goto" commands become "select" commands. // Any insertion or mouse click resets mark-mode. - // setMark twice in a row at the same place resets markmode + // setMark twice in a row at the same place resets markmode. + // in multi select mode, ea selection is handled individually + if (args && args.count) { - var mark = editor.popEmacsMark(); - mark && editor.selection.moveCursorToPosition(mark); + if (editor.inMultiSelectMode) editor.forEachSelection(moveToMark); + else moveToMark(); + moveToMark(); return; } var mark = editor.emacsMark(), - transientMarkModeActive = true; - + ranges = editor.selection.getAllRanges(), + rangePositions = ranges.map(function(r) { return {row: r.start.row, column: r.start.column}; }), + transientMarkModeActive = true, + hasNoSelection = ranges.every(function(range) { return range.isEmpty(); }); // if transientMarkModeActive then mark behavior is a little // different. Deactivate the mark when setMark is run with active // mark - if (transientMarkModeActive && (mark || !editor.selection.isEmpty())) { - editor.pushEmacsMark(); - editor.clearSelection(); + if (transientMarkModeActive && (mark || !hasNoSelection)) { + if (editor.inMultiSelectMode) editor.forEachSelection({exec: editor.clearSelection.bind(editor)}); + else editor.clearSelection(); + if (mark) editor.pushEmacsMark(null); return; } - if (mark) { - var cp = editor.getCursorPosition(); - if (editor.selection.isEmpty() && - mark.row == cp.row && mark.column == cp.column) { - editor.pushEmacsMark(); - return; - } + if (!mark) { + rangePositions.forEach(function(pos) { editor.pushEmacsMark(pos); }); + editor.setEmacsMark(rangePositions[rangePositions.length-1]); + return; } - // turn on mark mode - mark = editor.getCursorPosition(); - editor.setEmacsMark(mark); - editor.selection.setSelectionAnchor(mark.row, mark.column); + + // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- + + function moveToMark() { + var mark = editor.popEmacsMark(); + mark && editor.moveCursorToPosition(mark); + } + }, - readonly: true, - handlesCount: true, - multiSelectAction: "forEach" + readOnly: true, + handlesCount: true }, exchangePointAndMark: { - exec: function(editor, args) { + exec: function exchangePointAndMark$exec(editor, args) { var sel = editor.selection; - if (args.count) { - var pos = editor.getCursorPosition(); + if (!args.count && !sel.isEmpty()) { // just invert selection + sel.setSelectionRange(sel.getRange(), !sel.isBackwards()); + return; + } + + if (args.count) { // replace mark and point + var pos = {row: sel.lead.row, column: sel.lead.column}; sel.clearSelection(); - sel.moveCursorToPosition(editor.popEmacsMark()); - editor.pushEmacsMark(pos); - return; + sel.moveCursorToPosition(editor.emacsMarkForSelection(pos)); + } else { // create selection to last mark + sel.selectToPosition(editor.emacsMarkForSelection()); } - var lastMark = editor.getLastEmacsMark(); - var range = sel.getRange(); - if (range.isEmpty()) { - sel.selectToPosition(lastMark); - return; - } - sel.setSelectionRange(range, !sel.isBackwards()); }, - readonly: true, + readOnly: true, handlesCount: true, multiSelectAction: "forEach" }, @@ -508,8 +546,8 @@ exports.handler.addCommands({ killLine: function(editor) { editor.pushEmacsMark(null); var pos = editor.getCursorPosition(); - if (pos.column == 0 && - editor.session.doc.getLine(pos.row).length == 0) { + if (pos.column === 0 && + editor.session.doc.getLine(pos.row).length === 0) { // If an already empty line is killed, remove // the line entirely editor.selection.selectLine(); @@ -535,6 +573,7 @@ exports.handler.addCommands({ if (editor.keyBinding.$data.lastCommand != "yank") return; editor.undo(); + editor.session.$emacsMarkRing.pop(); // also undo recording mark editor.onPaste(exports.killRing.rotate()); editor.keyBinding.$data.lastCommand = "yank"; }, @@ -543,24 +582,38 @@ exports.handler.addCommands({ exports.killRing.add(editor.getCopyText()); editor.commands.byName.cut.exec(editor); }, - readonly: true, + readOnly: true, multiSelectAction: "forEach" }, killRingSave: { exec: function(editor) { + // copy text and deselect. will save marks for starts of the + // selection(s) + + editor.$handlesEmacsOnCopy = true; + var marks = editor.session.$emacsMarkRing.slice(), + deselectedMarks = []; exports.killRing.add(editor.getCopyText()); + setTimeout(function() { - var sel = editor.selection, - range = sel.getRange(); - editor.pushEmacsMark(sel.isBackwards() ? range.end : range.start); - sel.clearSelection(); + function deselect() { + var sel = editor.selection, range = sel.getRange(), + pos = sel.isBackwards() ? range.end : range.start; + deselectedMarks.push({row: pos.row, column: pos.column}); + sel.clearSelection(); + } + editor.$handlesEmacsOnCopy = false; + if (editor.inMultiSelectMode) editor.forEachSelection({exec: deselect}); + else deselect(); + editor.session.$emacsMarkRing = marks.concat(deselectedMarks.reverse()); }, 0); }, - readonly: true + readOnly: true }, keyboardQuit: function(editor) { editor.selection.clearSelection(); editor.setEmacsMark(null); + editor.keyBinding.$data.count = null; }, focusCommandLine: function(editor, arg) { if (editor.showCommandLine) diff --git a/lib/ace/keyboard/emacs_test.js b/lib/ace/keyboard/emacs_test.js index d1aba564..3ba5efaa 100644 --- a/lib/ace/keyboard/emacs_test.js +++ b/lib/ace/keyboard/emacs_test.js @@ -35,17 +35,29 @@ if (typeof process !== "undefined") { define(function(require, exports, module) { "use strict"; +require("../multi_select"); + var EditSession = require("./../edit_session").EditSession, Editor = require("./../editor").Editor, + Range = require("./../range").Range, MockRenderer = require("./../test/mockrenderer").MockRenderer, emacs = require('./emacs'), assert = require("./../test/assertions"), - editor; + editor, sel; function initEditor(docString) { var doc = new EditSession(docString.split("\n")); editor = new Editor(new MockRenderer(), doc); editor.setKeyboardHandler(emacs.handler); + sel = editor.selection; +} + +function print(obj) { + return JSON.stringify(obj, null, 2); +} + +function pluck(arr, what) { + return arr.map(function(ea) { return ea[what]; }); } module.exports = { @@ -62,6 +74,72 @@ module.exports = { editor.selectAll(); editor.execCommand('keyboardQuit'); assert.ok(editor.selection.isEmpty(), 'selection non-empty'); + }, + + "test: exchangePointAndMark without mark set": function() { + initEditor('foo'); + sel.setRange(Range.fromPoints({row: 0, column: 1}, {row: 0, column: 3})); + editor.execCommand('exchangePointAndMark'); + assert.deepEqual({row: 0, column: 1}, editor.getCursorPosition(), print(editor.getCursorPosition())); + }, + + "test: exchangePointAndMark with mark set": function() { + initEditor('foo'); + editor.pushEmacsMark({row: 0, column: 1}); + editor.pushEmacsMark({row: 0, column: 2}); + editor.execCommand('exchangePointAndMark', {count: 4}); + assert.deepEqual({row: 0, column: 2}, editor.getCursorPosition(), print(editor.getCursorPosition())); + assert.deepEqual([{row: 0, column: 1}, {row: 0, column: 0}], editor.session.$emacsMarkRing, print(editor.session.$emacsMarkRing)); + }, + + "test: exchangePointAndMark with selection": function() { + initEditor('foo'); + editor.pushEmacsMark({row: 0, column: 1}); + editor.pushEmacsMark({row: 0, column: 2}); + sel.setRange(Range.fromPoints({row: 0, column: 0}, {row: 0, column: 1}), true); + editor.execCommand('exchangePointAndMark'); + assert.deepEqual({row: 0, column: 1}, editor.getCursorPosition(), print(editor.getCursorPosition())); + assert.deepEqual([{row: 0, column: 1}, {row: 0, column: 2}], editor.session.$emacsMarkRing, print(editor.session.$emacsMarkRing)); + }, + + "test: exchangePointAndMark with multi selection": function() { + initEditor('foo\nhello world\n123'); + var ranges = [[{row: 0, column: 0}, {row: 0, column: 3}], + [{row: 1, column: 0}, {row: 1, column: 5}], + [{row: 1, column: 6}, {row: 1, column: 11}]] + ranges.forEach(function(r) { + sel.addRange(Range.fromPoints(r[0], r[1])); + }); + assert.equal("foo\nhello\nworld", editor.getSelectedText()); + editor.execCommand('exchangePointAndMark'); + assert.equal("foo\nhello\nworld", editor.getSelectedText()); + assert.deepEqual(pluck(ranges, 0), pluck(sel.getAllRanges(), 'cursor'), "selections dir not inverted"); + }, + + "test: exchangePointAndMark with multi cursors": function() { + initEditor('foo\nhello world\n123'); + var ranges = [[{row: 0, column: 0}, {row: 0, column: 3}], + [{row: 1, column: 0}, {row: 1, column: 5}], + [{row: 1, column: 6}, {row: 1, column: 11}]]; + // move cursors to the start of each range and set a mark to its end + // without selecting anything + ranges.forEach(function(r) { + editor.pushEmacsMark(r[1]); + sel.addRange(Range.fromPoints(r[0], r[0])); + }); + assert.deepEqual(pluck(ranges, 0), pluck(sel.getAllRanges(), 'cursor'), print(sel.getAllRanges())); + editor.execCommand('exchangePointAndMark'); + assert.deepEqual(pluck(ranges, 1), pluck(sel.getAllRanges(), 'cursor'), "not inverted: " + print(sel.getAllRanges())); + }, + + "test: setMark with multi cursors": function() { + initEditor('foo\nhello world\n123'); + var positions = [{row: 0, column: 0}, + {row: 1, column: 0}, + {row: 1, column: 6}]; + positions.forEach(function(p) { sel.addRange(Range.fromPoints(p,p)); }); + editor.execCommand('setMark'); + assert.deepEqual(positions, editor.session.$emacsMarkRing, print(editor.session.$emacsMarkRing)); } }; diff --git a/lib/ace/keyboard/hash_handler.js b/lib/ace/keyboard/hash_handler.js index 2ef110da..a7dc1a93 100644 --- a/lib/ace/keyboard/hash_handler.js +++ b/lib/ace/keyboard/hash_handler.js @@ -33,16 +33,25 @@ define(function(require, exports, module) { var keyUtil = require("../lib/keys"); var useragent = require("../lib/useragent"); +var KEY_MODS = keyUtil.KEY_MODS; function HashHandler(config, platform) { this.platform = platform || (useragent.isMac ? "mac" : "win"); this.commands = {}; - this.commmandKeyBinding = {}; - + this.commandKeyBinding = {}; this.addCommands(config); -}; + this.$singleCommand = true; +} + +function MultiHashHandler(config, platform) { + HashHandler.call(this, config, platform); + this.$singleCommand = false; +} + +MultiHashHandler.prototype = HashHandler.prototype; (function() { + this.addCommand = function(command) { if (this.commands[command.name]) @@ -54,47 +63,109 @@ function HashHandler(config, platform) { this._buildKeyHash(command); }; - this.removeCommand = function(command) { - var name = (typeof command === 'string' ? command : command.name); + this.removeCommand = function(command, keepCommand) { + var name = command && (typeof command === 'string' ? command : command.name); command = this.commands[name]; - delete this.commands[name]; + if (!keepCommand) + delete this.commands[name]; // exhaustive search is brute force but since removeCommand is // not a performance critical operation this should be OK - var ckb = this.commmandKeyBinding; - for (var hashId in ckb) { - for (var key in ckb[hashId]) { - if (ckb[hashId][key] == command) - delete ckb[hashId][key]; + var ckb = this.commandKeyBinding; + for (var keyId in ckb) { + var cmdGroup = ckb[keyId]; + if (cmdGroup == command) { + delete ckb[keyId]; + } else if (Array.isArray(cmdGroup)) { + var i = cmdGroup.indexOf(command); + if (i != -1) { + cmdGroup.splice(i, 1); + if (cmdGroup.length == 1) + ckb[keyId] = cmdGroup[0]; + } } } }; - this.bindKey = function(key, command) { - if(!key) - return; - if (typeof command == "function") { - this.addCommand({exec: command, bindKey: key, name: command.name || key}); - return; + this.bindKey = function(key, command, position) { + if (typeof key == "object") { + if (position == undefined) + position = key.position; + key = key[this.platform]; } - - var ckb = this.commmandKeyBinding; + if (!key) + return; + if (typeof command == "function") + return this.addCommand({exec: command, bindKey: key, name: command.name || key}); + key.split("|").forEach(function(keyPart) { - var binding = this.parseKeys(keyPart, command); - var hashId = binding.hashId; - (ckb[hashId] || (ckb[hashId] = {}))[binding.key] = command; + var chain = ""; + if (keyPart.indexOf(" ") != -1) { + var parts = keyPart.split(/\s+/); + keyPart = parts.pop(); + parts.forEach(function(keyPart) { + var binding = this.parseKeys(keyPart); + var id = KEY_MODS[binding.hashId] + binding.key; + chain += (chain ? " " : "") + id; + this._addCommandToBinding(chain, "chainKeys"); + }, this); + chain += " "; + } + var binding = this.parseKeys(keyPart); + var id = KEY_MODS[binding.hashId] + binding.key; + this._addCommandToBinding(chain + id, command, position); }, this); }; + + function getPosition(command) { + return typeof command == "object" && command.bindKey + && command.bindKey.position || 0; + } + this._addCommandToBinding = function(keyId, command, position) { + var ckb = this.commandKeyBinding, i; + if (!command) { + delete ckb[keyId]; + } else if (!ckb[keyId] || this.$singleCommand) { + ckb[keyId] = command; + } else { + if (!Array.isArray(ckb[keyId])) { + ckb[keyId] = [ckb[keyId]]; + } else if ((i = ckb[keyId].indexOf(command)) != -1) { + ckb[keyId].splice(i, 1); + } + + if (typeof position != "number") { + if (position || command.isDefault) + position = -100; + else + position = getPosition(command); + } + var commands = ckb[keyId]; + for (i = 0; i < commands.length; i++) { + var other = commands[i]; + var otherPos = getPosition(other); + if (otherPos > position) + break; + } + commands.splice(i, 0, command); + } + }; this.addCommands = function(commands) { commands && Object.keys(commands).forEach(function(name) { var command = commands[name]; + if (!command) + return; + if (typeof command === "string") return this.bindKey(command, name); if (typeof command === "function") command = { exec: command }; + if (typeof command !== "object") + return; + if (!command.name) command.name = name; @@ -115,21 +186,12 @@ function HashHandler(config, platform) { }; this._buildKeyHash = function(command) { - var binding = command.bindKey; - if (!binding) - return; - - var key = typeof binding == "string" ? binding: binding[this.platform]; - this.bindKey(key, command); + this.bindKey(command.bindKey, command); }; // accepts keys in the form ctrl+Enter or ctrl-Enter // keys without modifiers or shift only this.parseKeys = function(keys) { - // todo support keychains - if (keys.indexOf(" ") != -1) - keys = keys.split(/\s+/).pop(); - var parts = keys.toLowerCase().split(/[\-\+]([\-\+])?/).filter(function(x){return x}); var key = parts.pop(); @@ -146,7 +208,7 @@ function HashHandler(config, platform) { var modifier = keyUtil.KEY_MODS[parts[i]]; if (modifier == null) { if (typeof console != "undefined") - console.error("invalid modifier " + parts[i] + " in " + keys); + console.error("invalid modifier " + parts[i] + " in " + keys); return false; } hashId |= modifier; @@ -155,17 +217,40 @@ function HashHandler(config, platform) { }; this.findKeyCommand = function findKeyCommand(hashId, keyString) { - var ckbr = this.commmandKeyBinding; - return ckbr[hashId] && ckbr[hashId][keyString]; + var key = KEY_MODS[hashId] + keyString; + return this.commandKeyBinding[key]; }; this.handleKeyboard = function(data, hashId, keyString, keyCode) { - return { - command: this.findKeyCommand(hashId, keyString) - }; + var key = KEY_MODS[hashId] + keyString; + var command = this.commandKeyBinding[key]; + if (data.$keyChain) { + data.$keyChain += " " + key; + command = this.commandKeyBinding[data.$keyChain] || command; + } + + if (command) { + if (command == "chainKeys" || command[command.length - 1] == "chainKeys") { + data.$keyChain = data.$keyChain || key; + return {command: "null"}; + } + } + + if (data.$keyChain) { + if ((!hashId || hashId == 4) && keyString.length == 1) + data.$keyChain = data.$keyChain.slice(0, -key.length - 1); // wait for input + else if (hashId == -1 || keyCode > 0) + data.$keyChain = ""; // reset keyChain + } + return {command: command}; + }; + + this.getStatusText = function(editor, data) { + return data.$keyChain || ""; }; -}).call(HashHandler.prototype) +}).call(HashHandler.prototype); exports.HashHandler = HashHandler; +exports.MultiHashHandler = MultiHashHandler; }); diff --git a/lib/ace/keyboard/keybinding.js b/lib/ace/keyboard/keybinding.js index 9c54a947..cddf0666 100644 --- a/lib/ace/keyboard/keybinding.js +++ b/lib/ace/keyboard/keybinding.js @@ -36,7 +36,7 @@ var event = require("../lib/event"); var KeyBinding = function(editor) { this.$editor = editor; - this.$data = { }; + this.$data = {editor: editor}; this.$handlers = []; this.setDefaultHandler(editor.commands); }; @@ -46,7 +46,6 @@ var KeyBinding = function(editor) { this.removeKeyboardHandler(this.$defaultHandler); this.$defaultHandler = kb; this.addKeyboardHandler(kb, 0); - this.$data = {editor: this.$editor}; }; this.setKeyboardHandler = function(kb) { @@ -63,6 +62,8 @@ var KeyBinding = function(editor) { this.addKeyboardHandler = function(kb, pos) { if (!kb) return; + if (typeof kb == "function" && !kb.handleKeyboard) + kb.handleKeyboard = kb; var i = this.$handlers.indexOf(kb); if (i != -1) this.$handlers.splice(i, 1); @@ -88,8 +89,16 @@ var KeyBinding = function(editor) { this.getKeyboardHandler = function() { return this.$handlers[this.$handlers.length - 1]; }; + + this.getStatusText = function() { + var data = this.$data; + var editor = data.editor; + return this.$handlers.map(function(h) { + return h.getStatusText && h.getStatusText(editor, data) || ""; + }).filter(Boolean).join(" "); + }; - this.$callKeyboardHandlers = function (hashId, keyString, keyCode, e) { + this.$callKeyboardHandlers = function(hashId, keyString, keyCode, e) { var toExecute; var success = false; var commands = this.$editor.commands; @@ -108,8 +117,11 @@ var KeyBinding = function(editor) { success = commands.exec(toExecute.command, this.$editor, toExecute.args, e); } // do not stop input events to not break repeating - if (success && e && hashId != -1 && toExecute.passEvent != true) + if (success && e && hashId != -1 && + toExecute.passEvent != true && toExecute.command.passEvent != true + ) { event.stopEvent(e); + } if (success) break; } diff --git a/lib/ace/keyboard/textarea.js b/lib/ace/keyboard/textarea.js new file mode 100644 index 00000000..470b2940 --- /dev/null +++ b/lib/ace/keyboard/textarea.js @@ -0,0 +1,82 @@ +/* ***** 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. + * + * ***** END LICENSE BLOCK ***** */ + +define(function(require, exports, module) { +"use strict"; + +var HashHandler = require("./hash_handler").HashHandler; +exports.handler = new HashHandler(); + +[{ + bindKey: "Shift-Tab|Tab", + command: "passKeysToBrowser" +}, { + bindKey: {win: "Ctrl-L", mac: "Cmd-L"}, + command: "passKeysToBrowser" +}, { + bindKey: {win: "Ctrl-G", mac: "Cmd-G"}, + command: "gotoline" +}, { + bindKey: {win: "Ctrl-T|Ctrl-Shift-T", mac: "Cmd-T|Cmd-Shift-T"}, + command: "passKeysToBrowser" +}, { + bindKey: {win: "Ctrl-G", mac: "Cmd-G"}, + command: "passKeysToBrowser" +}, { + bindKey: {win: "Ctrl-G", mac: "Cmd-G"}, + command: "passKeysToBrowser" +}, { + name: "golineup", + bindKey: {win: null, mac: "Ctrl-P"}, +}, { + name: "golinedown", + bindKey: {win: null, mac: "Ctrl-N"}, +}, { + name: "gotoleft", + bindKey: {win: null, mac: "Ctrl-B"}, +}, { + name: "gotoright", + bindKey: {win: null, mac: "Ctrl-F"}, +}, { + name: "gotolineend", + bindKey: {win: null, mac: "Ctrl-E"}, +}, { + name: "gotolinestart", + bindKey: {win: null, mac: "Ctrl-A"}, +} +].forEach(function(k) { + var bindKey = k.bindKey; + if (typeof bindKey == "object") + bindKey = bindKey[exports.handler.platform]; + exports.handler.bindKey(bindKey, k.command); +}); +exports.handler.$id = "ace/keyboard/textarea"; + +}); diff --git a/lib/ace/keyboard/textinput.js b/lib/ace/keyboard/textinput.js index e7fbab5b..4a2bb72c 100644 --- a/lib/ace/keyboard/textinput.js +++ b/lib/ace/keyboard/textinput.js @@ -36,27 +36,26 @@ var useragent = require("../lib/useragent"); var dom = require("../lib/dom"); var lang = require("../lib/lang"); var BROKEN_SETDATA = useragent.isChrome < 18; +var USE_IE_MIME_TYPE = useragent.isIE; var TextInput = function(parentNode, host) { var text = dom.createElement("textarea"); text.className = "ace_text-input"; - /*/ debug - text.style.cssText = "opacity:1;background:rgba(0, 250, 0, 0.3);outline:rgba(0, 250, 0, 0.8) solid 1px;outline-offset:3px;width:5em;z-index:500"; - /**/ + if (useragent.isTouchPad) text.setAttribute("x-palm-disable-auto-cap", true); - text.wrap = "off"; - text.autocorrect = "off"; - text.autocapitalize = "off"; - text.spellcheck = false; + text.setAttribute("wrap", "off"); + text.setAttribute("autocorrect", "off"); + text.setAttribute("autocapitalize", "off"); + text.setAttribute("spellcheck", false); - text.style.bottom = "2000em"; + text.style.opacity = "0"; + if (useragent.isOldIE) text.style.top = "-1000px"; parentNode.insertBefore(text, parentNode.firstChild); var PLACEHOLDER = "\x01\x01"; - var cut = false; var copied = false; var pasted = false; var inComposition = false; @@ -67,16 +66,24 @@ var TextInput = function(parentNode, host) { // ie9 throws error if document.activeElement is accessed too soon try { var isFocused = document.activeElement === text; } catch(e) {} - event.addListener(text, "blur", function() { - host.onBlur(); + event.addListener(text, "blur", function(e) { + host.onBlur(e); isFocused = false; }); - event.addListener(text, "focus", function() { + event.addListener(text, "focus", function(e) { isFocused = true; - host.onFocus(); + host.onFocus(e); resetSelection(); }); - this.focus = function() { text.focus(); }; + this.focus = function() { + if (tempStyle) return text.focus(); + text.style.position = "fixed"; + text.style.top = "-1000px"; + text.focus(); + setTimeout(function() { + text.style.position = ""; + }, 0); + }; this.blur = function() { text.blur(); }; this.isFocused = function() { return isFocused; @@ -96,6 +103,11 @@ var TextInput = function(parentNode, host) { function resetSelection(isEmpty) { if (inComposition) return; + + // this prevents infinite recursion on safari 8 + // see https://github.com/ajaxorg/ace/issues/2114 + inComposition = true; + if (inputHandler) { selectionStart = 0; selectionEnd = isEmpty ? 0 : text.value.length - 1; @@ -107,6 +119,8 @@ var TextInput = function(parentNode, host) { try { text.setSelectionRange(selectionStart, selectionEnd); } catch(e){} + + inComposition = false; } function resetValue() { @@ -176,16 +190,19 @@ var TextInput = function(parentNode, host) { if (inComposition && (!text.value || keytable[e.keyCode])) setTimeout(onCompositionEnd, 0); if ((text.value.charCodeAt(0)||0) < 129) { - return; + return syncProperty.call(); } inComposition ? onCompositionUpdate() : onCompositionStart(); }); + // when user presses backspace after focusing the editor + // propertychange isn't called for the next character + event.addListener(text, "keydown", function (e) { + syncProperty.schedule(50); + }); } var onSelect = function(e) { - if (cut) { - cut = false; - } else if (copied) { + if (copied) { copied = false; } else if (isAllSelected(text)) { host.selectAll(); @@ -210,18 +227,20 @@ var TextInput = function(parentNode, host) { if (data) host.onPaste(data); pasted = false; - } else if (data == PLACEHOLDER[0]) { + } else if (data == PLACEHOLDER.charAt(0)) { if (afterContextMenu) host.execCommand("del", {source: "ace"}); + else // some versions of android do not fire keydown when pressing backspace + host.execCommand("backspace", {source: "ace"}); } else { if (data.substring(0, 2) == PLACEHOLDER) data = data.substr(2); - else if (data[0] == PLACEHOLDER[0]) + else if (data.charAt(0) == PLACEHOLDER.charAt(0)) data = data.substr(1); - else if (data[data.length - 1] == PLACEHOLDER[0]) + else if (data.charAt(data.length - 1) == PLACEHOLDER.charAt(0)) data = data.slice(0, -1); // can happen if undo in textarea isn't stopped - if (data[data.length - 1] == PLACEHOLDER[0]) + if (data.charAt(data.length - 1) == PLACEHOLDER.charAt(0)) data = data.slice(0, -1); if (data) @@ -238,55 +257,31 @@ var TextInput = function(parentNode, host) { sendText(data); resetValue(); }; - - var onCut = function(e) { - var data = host.getCopyText(); - if (!data) { - event.preventDefault(e); - return; - } - + + var handleClipboardData = function(e, data) { var clipboardData = e.clipboardData || window.clipboardData; - - if (clipboardData && !BROKEN_SETDATA) { + if (!clipboardData || BROKEN_SETDATA) + return; + // using "Text" doesn't work on old webkit but ie needs it + // TODO are there other browsers that require "Text"? + var mime = USE_IE_MIME_TYPE ? "Text" : "text/plain"; + if (data) { // Safari 5 has clipboardData object, but does not handle setData() - var supported = clipboardData.setData("Text", data); - if (supported) { - host.onCut(); - event.preventDefault(e); - } - } - - if (!supported) { - cut = true; - text.value = data; - text.select(); - setTimeout(function(){ - cut = false; - resetValue(); - resetSelection(); - host.onCut(); - }); + return clipboardData.setData(mime, data) !== false; + } else { + return clipboardData.getData(mime); } }; - var onCopy = function(e) { + var doCopy = function(e, isCut) { var data = host.getCopyText(); - if (!data) { - event.preventDefault(e); - return; - } + if (!data) + return event.preventDefault(e); - var clipboardData = e.clipboardData || window.clipboardData; - if (clipboardData && !BROKEN_SETDATA) { - // Safari 5 has clipboardData object, but does not handle setData() - var supported = clipboardData.setData("Text", data); - if (supported) { - host.onCopy(); - event.preventDefault(e); - } - } - if (!supported) { + if (handleClipboardData(e, data)) { + isCut ? host.onCut() : host.onCopy(); + event.preventDefault(e); + } else { copied = true; text.value = data; text.select(); @@ -294,18 +289,24 @@ var TextInput = function(parentNode, host) { copied = false; resetValue(); resetSelection(); - host.onCopy(); + isCut ? host.onCut() : host.onCopy(); }); } }; - + + var onCut = function(e) { + doCopy(e, true); + }; + + var onCopy = function(e) { + doCopy(e, false); + }; + var onPaste = function(e) { - var clipboardData = e.clipboardData || window.clipboardData; - - if (clipboardData) { - var data = clipboardData.getData("Text"); + var data = handleClipboardData(e); + if (typeof data == "string") { if (data) - host.onPaste(data); + host.onPaste(data, e); if (useragent.isIE) setTimeout(resetSelection); event.preventDefault(e); @@ -331,7 +332,7 @@ var TextInput = function(parentNode, host) { if (!('oncut' in text) || !('oncopy' in text) || !('onpaste' in text)){ event.addListener(parentNode, "keydown", function(e) { if ((useragent.isMac && !e.metaKey) || !e.ctrlKey) - return; + return; switch (e.keyCode) { case 67: @@ -350,7 +351,8 @@ var TextInput = function(parentNode, host) { // COMPOSITION var onCompositionStart = function(e) { - if (inComposition) return; + if (inComposition || !host.onCompositionStart || host.$readOnly) + return; // console.log("onCompositionStart", inComposition) inComposition = {}; host.onCompositionStart(); @@ -366,11 +368,15 @@ var TextInput = function(parentNode, host) { var onCompositionUpdate = function() { // console.log("onCompositionUpdate", inComposition && JSON.stringify(text.value)) - if (!inComposition) return; - host.onCompositionUpdate(text.value); + if (!inComposition || !host.onCompositionUpdate || host.$readOnly) + return; + var val = text.value.replace(/\x01/g, ""); + if (inComposition.lastValue === val) return; + + host.onCompositionUpdate(val); if (inComposition.lastValue) host.undo(); - inComposition.lastValue = text.value.replace(/\x01/g, "") + inComposition.lastValue = val; if (inComposition.lastValue) { var r = host.selection.getRange(); host.insert(inComposition.lastValue); @@ -382,14 +388,16 @@ var TextInput = function(parentNode, host) { }; var onCompositionEnd = function(e) { + if (!host.onCompositionEnd || host.$readOnly) return; // console.log("onCompositionEnd", inComposition &&inComposition.lastValue) var c = inComposition; inComposition = false; var timer = setTimeout(function() { + timer = null; var str = text.value.replace(/\x01/g, ""); // console.log(str, c.lastValue) if (inComposition) - return + return; else if (str == c.lastValue) resetValue(); else if (!c.lastValue && str) { @@ -399,14 +407,15 @@ var TextInput = function(parentNode, host) { }); inputHandler = function compositionInputHandler(str) { // console.log("onCompositionEnd", str, c.lastValue) - clearTimeout(timer); + if (timer) + clearTimeout(timer); str = str.replace(/\x01/g, ""); if (str == c.lastValue) return ""; - if (c.lastValue) + if (c.lastValue && timer) host.undo(); return str; - } + }; host.onCompositionEnd(); host.removeListener("mousedown", onCompositionEnd); if (e.type == "compositionend" && c.range) { @@ -419,7 +428,12 @@ var TextInput = function(parentNode, host) { var syncComposition = lang.delayedCall(onCompositionUpdate, 50); event.addListener(text, "compositionstart", onCompositionStart); - event.addListener(text, useragent.isGecko ? "text" : "keyup", function(){syncComposition.schedule()}); + if (useragent.isGecko) { + event.addListener(text, "text", function(){syncComposition.schedule()}); + } else { + event.addListener(text, "keyup", function(){syncComposition.schedule()}); + event.addListener(text, "keydown", function(){syncComposition.schedule()}); + } event.addListener(text, "compositionend", onCompositionEnd); this.getElement = function() { @@ -432,19 +446,25 @@ var TextInput = function(parentNode, host) { this.onContextMenu = function(e) { afterContextMenu = true; + resetSelection(host.selection.isEmpty()); + host._emit("nativecontextmenu", {target: host, domEvent: e}); + this.moveToMouse(e, true); + }; + + this.moveToMouse = function(e, bringToFront) { + if (!bringToFront && useragent.isOldIE) + return; if (!tempStyle) tempStyle = text.style.cssText; + text.style.cssText = (bringToFront ? "z-index:100000;" : "") + + "height:" + text.style.height + ";" + + (useragent.isIE ? "opacity:0.1;" : ""); - text.style.cssText = "z-index:100000;" + (useragent.isIE ? "opacity:0.1;" : ""); - // text.style.cssText += "background:rgba(250, 0, 0, 0.3); opacity:1;"; - - resetSelection(host.selection.isEmpty()); - host._emit("nativecontextmenu", {target: host}); var rect = host.container.getBoundingClientRect(); var style = dom.computedStyle(host.container); var top = rect.top + (parseInt(style.borderTopWidth) || 0); var left = rect.left + (parseInt(rect.borderLeftWidth) || 0); - var maxTop = rect.bottom - top - text.clientHeight; + var maxTop = rect.bottom - top - text.clientHeight -2; var move = function(e) { text.style.left = e.clientX - left - 2 + "px"; text.style.top = Math.min(e.clientY - top - 2, maxTop) + "px"; @@ -458,13 +478,15 @@ var TextInput = function(parentNode, host) { host.renderer.$keepTextAreaAtCursor = null; // on windows context menu is opened after mouseup - if (useragent.isWin) + if (useragent.isWin && !useragent.isOldIE) event.capture(host.container, move, onContextMenuClose); }; this.onContextMenuClose = onContextMenuClose; + var closeTimeout; function onContextMenuClose() { - setTimeout(function () { + clearTimeout(closeTimeout) + closeTimeout = setTimeout(function () { if (tempStyle) { text.style.cssText = tempStyle; tempStyle = ''; @@ -473,16 +495,15 @@ var TextInput = function(parentNode, host) { host.renderer.$keepTextAreaAtCursor = true; host.renderer.$moveTextAreaToCursor(); } - }, 0); + }, useragent.isOldIE ? 200 : 0); } - // firefox fires contextmenu event after opening it - if (!useragent.isGecko) { - event.addListener(text, "contextmenu", function(e) { - host.textInput.onContextMenu(e); - onContextMenuClose(); - }); - } + var onContextMenu = function(e) { + host.textInput.onContextMenu(e); + onContextMenuClose(); + }; + event.addListener(host.renderer.scroller, "contextmenu", onContextMenu); + event.addListener(text, "contextmenu", onContextMenu); }; exports.TextInput = TextInput; diff --git a/lib/ace/keyboard/vim.js b/lib/ace/keyboard/vim.js index 417bf556..17c26c16 100644 --- a/lib/ace/keyboard/vim.js +++ b/lib/ace/keyboard/vim.js @@ -1,159 +1,6177 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Distributed under the BSD license: +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: http://codemirror.net/LICENSE + +/** + * Supported keybindings: * - * 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. + * Motion: + * h, j, k, l + * gj, gk + * e, E, w, W, b, B, ge, gE + * f, F, t, T + * $, ^, 0, -, +, _ + * gg, G + * % + * ', ` * - * ***** END LICENSE BLOCK ***** */ + * Operator: + * d, y, c + * dd, yy, cc + * g~, g~g~ + * >, <, >>, << + * + * Operator-Motion: + * x, X, D, Y, C, ~ + * + * Action: + * a, i, s, A, I, S, o, O + * zz, z., z, zt, zb, z- + * J + * u, Ctrl-r + * m + * r + * + * Modes: + * ESC - leave insert mode, visual mode, and clear input state. + * Ctrl-[, Ctrl-c - same as ESC. + * + * Registers: unnamed, -, a-z, A-Z, 0-9 + * (Does not respect the special case for number registers when delete + * operator is made with these commands: %, (, ), , /, ?, n, N, {, } ) + * TODO: Implement the remaining registers. + * Marks: a-z, A-Z, and 0-9 + * TODO: Implement the remaining special marks. They have more complex + * behavior. + * + * Events: + * 'vim-mode-change' - raised on the editor anytime the current mode changes, + * Event object: {mode: "visual", subMode: "linewise"} + * + * Code structure: + * 1. Default keymap + * 2. Variable declarations and short basic helpers + * 3. Instance (External API) implementation + * 4. Internal state tracking objects (input state, counter) implementation + * and instanstiation + * 5. Key handler (the main command dispatcher) implementation + * 6. Motion, operator, and action implementations + * 7. Helper functions for the key handler, motions, operators, and actions + * 8. Set up Vim to work as a keymap for CodeMirror. + */ define(function(require, exports, module) { -"use strict"; + 'use strict'; -var cmds = require("./vim/commands"); -var coreCommands = cmds.coreCommands; -var util = require("./vim/maps/util"); -var useragent = require("../lib/useragent"); - -var startCommands = { - "i": { - command: coreCommands.start - }, - "I": { - command: coreCommands.startBeginning - }, - "a": { - command: coreCommands.append - }, - "A": { - command: coreCommands.appendEnd - }, - "ctrl-f": { - command: "gotopagedown" - }, - "ctrl-b": { - command: "gotopageup" + function log() { + var d = ""; + function format(p) { + if (typeof p != "object") + return p + ""; + if ("line" in p) { + return p.line + ":" + p.ch; + } + if ("anchor" in p) { + return format(p.anchor) + "->" + format(p.head); + } + if (Array.isArray(p)) + return "[" + p.map(function(x) { + return format(x); + }) + "]"; + return JSON.stringify(p); } -}; + for (var i = 0; i < arguments.length; i++) { + var p = arguments[i]; + var f = format(p); + d += f + " "; + } + console.log(d); + } + var Range = require("../range").Range; + var EventEmitter = require("../lib/event_emitter").EventEmitter; + var dom = require("../lib/dom"); + var oop = require("../lib/oop"); + var KEYS = require("../lib/keys"); + var event = require("../lib/event"); + var Search = require("../search").Search; + var useragent = require("../lib/useragent"); + var SearchHighlight = require("../search_highlight").SearchHighlight; + var multiSelectCommands = require("../commands/multi_select_commands"); + var TextModeTokenRe = require("../mode/text").Mode.prototype.tokenRe; + require("../multi_select"); -exports.handler = { - $id: "ace/keyboard/vim", + var CodeMirror = function(ace) { + this.ace = ace; + this.state = {}; + this.marks = {}; + this.$uid = 0; + this.onChange = this.onChange.bind(this); + this.onSelectionChange = this.onSelectionChange.bind(this); + this.onBeforeEndOperation = this.onBeforeEndOperation.bind(this); + this.ace.on('change', this.onChange); + this.ace.on('changeSelection', this.onSelectionChange); + this.ace.on('beforeEndOperation', this.onBeforeEndOperation); + }; + CodeMirror.Pos = function(line, ch) { + if (!(this instanceof Pos)) return new Pos(line, ch); + this.line = line; this.ch = ch; + }; + CodeMirror.defineOption = function(name, val, setter) {}; + CodeMirror.commands = { + redo: function(cm) { cm.ace.redo(); }, + undo: function(cm) { cm.ace.undo(); }, + newlineAndIndent: function(cm) { cm.ace.insert("\n"); }, + }; + CodeMirror.keyMap = {}; + CodeMirror.addClass = CodeMirror.rmClass = + CodeMirror.e_stop = function() {}; + CodeMirror.keyName = function(e) { + if (e.key) return e.key; + var key = (KEYS[e.keyCode] || ""); + if (key.length == 1) key = key.toUpperCase(); + key = event.getModifierString(e).replace(/(^|-)\w/g, function(m) { + return m.toUpperCase(); + }) + key; + return key; + }; + CodeMirror.keyMap['default'] = function(key) { + return function(cm) { + var cmd = cm.ace.commands.commandKeyBinding[key.toLowerCase()]; + return cmd && cm.ace.execCommand(cmd) !== false; + }; + }; + CodeMirror.lookupKey = function lookupKey(key, map, handle) { + if (typeof map == "string") + map = CodeMirror.keyMap[map]; + var found = typeof map == "function" ? map(key) : map[key]; + if (found === false) return "nothing"; + if (found === "...") return "multi"; + if (found != null && handle(found)) return "handled"; + + if (map.fallthrough) { + if (!Array.isArray(map.fallthrough)) + return lookupKey(key, map.fallthrough, handle); + for (var i = 0; i < map.fallthrough.length; i++) { + var result = lookupKey(key, map.fallthrough[i], handle); + if (result) return result; + } + } + }; + + CodeMirror.signal = function(o, name, e) { return o._signal(name, e) }; + CodeMirror.on = event.addListener; + CodeMirror.off = event.removeListener; + CodeMirror.isWordChar = function(ch) { + TextModeTokenRe.lastIndex = 0; + return TextModeTokenRe.test(ch); + }; + +(function() { + oop.implement(CodeMirror.prototype, EventEmitter); + + this.destroy = function() { + this.ace.off('change', this.onChange); + this.ace.off('changeSelection', this.onSelectionChange); + this.ace.off('beforeEndOperation', this.onBeforeEndOperation); + this.removeOverlay(); + }; + this.virtualSelectionMode = function() { + return this.ace.inVirtualSelectionMode && this.ace.selection.index; + }; + this.onChange = function(delta) { + if (delta.action[0] == 'i') { + var change = { text: delta.lines }; + var curOp = this.curOp = this.curOp || {}; + if (!curOp.changeHandlers) + curOp.changeHandlers = this._eventRegistry["change"] && this._eventRegistry["change"].slice(); + if (this.virtualSelectionMode()) return; + if (!curOp.lastChange) { + curOp.lastChange = curOp.change = change; + } else { + curOp.lastChange.next = curOp.lastChange = change; + } + } + this.$updateMarkers(delta); + }; + this.onSelectionChange = function() { + var curOp = this.curOp = this.curOp || {}; + if (!curOp.cursorActivityHandlers) + curOp.cursorActivityHandlers = this._eventRegistry["cursorActivity"] && this._eventRegistry["cursorActivity"].slice(); + this.curOp.cursorActivity = true; + if (this.ace.inMultiSelectMode) { + this.ace.keyBinding.removeKeyboardHandler(multiSelectCommands.keyboardHandler); + } + }; + this.operation = function(fn, force) { + if (!force && this.curOp || force && this.curOp && this.curOp.force) { + return fn(); + } + if (force || !this.ace.curOp) { + if (this.curOp) + this.onBeforeEndOperation(); + } + if (!this.ace.curOp) { + var prevOp = this.ace.prevOp; + this.ace.startOperation({ + command: { name: "vim", scrollIntoView: "cursor" } + }); + } + var curOp = this.curOp = this.curOp || {}; + this.curOp.force = force; + var result = fn(); + if (this.ace.curOp && this.ace.curOp.command.name == "vim") { + this.ace.endOperation(); + if (!curOp.cursorActivity && !curOp.lastChange && prevOp) + this.ace.prevOp = prevOp; + } + if (force || !this.ace.curOp) { + if (this.curOp) + this.onBeforeEndOperation(); + } + return result; + }; + this.onBeforeEndOperation = function() { + var op = this.curOp; + if (op) { + if (op.change) { this.signal("change", op.change, op); } + if (op && op.cursorActivity) { this.signal("cursorActivity", null, op); } + this.curOp = null; + } + }; + + this.signal = function(eventName, e, handlers) { + var listeners = handlers ? handlers[eventName + "Handlers"] + : (this._eventRegistry || {})[eventName]; + if (!listeners) + return; + listeners = listeners.slice(); + for (var i=0; i 0) { + point.row += rowShift; + point.column += point.row == end.row ? colShift : 0; + continue; + } + if (!isInsert && cmp2 <= 0) { + point.row = start.row; + point.column = start.column; + if (cmp2 === 0) + point.bias = 1; + } + } + }; + var Marker = function(cm, id, row, column) { + this.cm = cm; + this.id = id; + this.row = row; + this.column = column; + cm.marks[this.id] = this; + }; + Marker.prototype.clear = function() { delete this.cm.marks[this.id] }; + Marker.prototype.find = function() { return toCmPos(this) }; + this.setBookmark = function(cursor, options) { + var bm = new Marker(this, this.$uid++, cursor.line, cursor.ch); + if (!options || !options.insertLeft) + bm.$insertRight = true; + this.marks[bm.id] = bm; + return bm; + }; + this.moveH = function(increment, unit) { + if (unit == 'char') { + var sel = this.ace.selection; + sel.clearSelection(); + sel.moveCursorBy(0, increment); + } + }; + this.findPosV = function(start, amount, unit, goalColumn) { + if (unit == 'page') { + var renderer = this.ace.renderer; + var config = renderer.layerConfig; + amount = amount * Math.floor(config.height / config.lineHeight); + unit = 'line'; + } + if (unit == 'line') { + var screenPos = this.ace.session.documentToScreenPosition(start.line, start.ch); + if (goalColumn != null) + screenPos.column = goalColumn; + screenPos.row += amount; + // not what codemirror does but vim mode needs only this + screenPos.row = Math.min(Math.max(0, screenPos.row), this.ace.session.getScreenLength() - 1); + var pos = this.ace.session.screenToDocumentPosition(screenPos.row, screenPos.column); + return toCmPos(pos); + } else { + debugger; + } + }; + this.charCoords = function(pos, mode) { + if (mode == 'div' || !mode) { + var sc = this.ace.session.documentToScreenPosition(pos.line, pos.ch); + return {left: sc.column, top: sc.row}; + }if (mode == 'local') { + var renderer = this.ace.renderer; + var sc = this.ace.session.documentToScreenPosition(pos.line, pos.ch); + var lh = renderer.layerConfig.lineHeight; + var cw = renderer.layerConfig.characterWidth; + var top = lh * sc.row; + return {left: sc.column * cw, top: top, bottom: top + lh}; + } + }; + this.coordsChar = function(pos, mode) { + var renderer = this.ace.renderer; + if (mode == 'local') { + var row = Math.max(0, Math.floor(pos.top / renderer.lineHeight)); + var col = Math.max(0, Math.floor(pos.left / renderer.characterWidth)); + var ch = renderer.session.screenToDocumentPosition(row, col); + return toCmPos(ch); + } else if (mode == 'div') { + throw "not implemented"; + } + }; + this.getSearchCursor = function(query, pos, caseFold) { + var caseSensitive = false; + var isRegexp = false; + if (query instanceof RegExp && !query.global) { + caseSensitive = !query.ignoreCase; + query = query.source; + isRegexp = true; + } + var search = new Search(); + if (pos.ch == undefined) pos.ch = Number.MAX_VALUE; + var acePos = {row: pos.line, column: pos.ch}; + var cm = this; + var last = null; + return { + findNext: function() { return this.find(false) }, + findPrevious: function() {return this.find(true) }, + find: function(back) { + search.setOptions({ + needle: query, + caseSensitive: caseSensitive, + wrap: false, + backwards: back, + regExp: isRegexp, + start: last || acePos + }); + var range = search.find(cm.ace.session); + if (range && range.isEmpty()) { + if (cm.getLine(range.start.row).length == range.start.column) { + search.$options.start = range; + range = search.find(cm.ace.session); + } + } + last = range; + return last; + }, + from: function() { return last && toCmPos(last.start) }, + to: function() { return last && toCmPos(last.end) }, + replace: function(text) { + if (last) { + last.end = cm.ace.session.doc.replace(last, text); + } + } + }; + }; + this.scrollTo = function(x, y) { + var renderer = this.ace.renderer; + var config = renderer.layerConfig; + var maxHeight = config.maxHeight; + maxHeight -= (renderer.$size.scrollerHeight - renderer.lineHeight) * renderer.$scrollPastEnd; + if (y != null) this.ace.session.setScrollTop(Math.max(0, Math.min(y, maxHeight))); + if (x != null) this.ace.session.setScrollLeft(Math.max(0, Math.min(x, config.width))); + }; + this.scrollInfo = function() { return 0; }; + this.scrollIntoView = function(pos, margin) { + if (pos) { + var renderer = this.ace.renderer; + var viewMargin = { "top": 0, "bottom": margin }; + renderer.scrollCursorIntoView(toAcePos(pos), + (renderer.lineHeight * 2) / renderer.$size.scrollerHeight, viewMargin); + } + }; + this.getLine = function(row) { return this.ace.session.getLine(row) }; + this.getRange = function(s, e) { + return this.ace.session.getTextRange(new Range(s.line, s.ch, e.line, e.ch)); + }; + this.replaceRange = function(text, s, e) { + if (!e) e = s; + return this.ace.session.replace(new Range(s.line, s.ch, e.line, e.ch), text); + }; + this.replaceSelections = function(p) { + var sel = this.ace.selection; + if (this.ace.inVirtualSelectionMode) { + this.ace.session.replace(sel.getRange(), p[0] || ""); + return; + } + sel.inVirtualSelectionMode = true; + var ranges = sel.rangeList.ranges; + if (!ranges.length) ranges = [this.ace.multiSelect.getRange()]; + for (var i = ranges.length; i--;) + this.ace.session.replace(ranges[i], p[i] || ""); + sel.inVirtualSelectionMode = false; + }; + this.getSelection = function() { + return this.ace.getSelectedText(); + }; + this.getSelections = function() { + return this.listSelections().map(function(x) { + return this.getRange(x.anchor, x.head); + }, this); + }; + this.getInputField = function() { + return this.ace.textInput.getElement(); + }; + this.getWrapperElement = function() { + return this.ace.containter; + }; + var optMap = { + indentWithTabs: "useSoftTabs", + indentUnit: "tabSize", + firstLineNumber: "firstLineNumber" + }; + this.setOption = function(name, val) { + this.state[name] = val; + switch (name) { + case 'indentWithTabs': + name = optMap[name]; + val = !val; + break; + default: + name = optMap[name]; + } + if (name) + this.ace.setOption(name, val); + }; + this.getOption = function(name, val) { + var aceOpt = optMap[name]; + if (aceOpt) + val = this.ace.getOption(aceOpt); + switch (name) { + case 'indentWithTabs': + name = optMap[name]; + return !val; + } + return aceOpt ? val : this.state[name]; + }; + this.toggleOverwrite = function(on) { + this.state.overwrite = on; + return this.ace.setOverwrite(on); + }; + this.addOverlay = function(o) { + if (!this.$searchHighlight || !this.$searchHighlight.session) { + var highlight = new SearchHighlight(null, "ace_highlight-marker", "text"); + var marker = this.ace.session.addDynamicMarker(highlight); + highlight.id = marker.id; + highlight.session = this.ace.session; + highlight.destroy = function(o) { + highlight.session.off("change", highlight.updateOnChange); + highlight.session.off("changeEditor", highlight.destroy); + highlight.session.removeMarker(highlight.id); + highlight.session = null; + }; + highlight.updateOnChange = function(delta) { + var row = delta.start.row; + if (row == delta.end.row) highlight.cache[row] = undefined; + else highlight.cache.splice(row, highlight.cache.length); + }; + highlight.session.on("changeEditor", highlight.destroy); + highlight.session.on("change", highlight.updateOnChange); + } + var re = new RegExp(o.query.source, "gmi"); + this.$searchHighlight = o.highlight = highlight; + this.$searchHighlight.setRegexp(re); + this.ace.renderer.updateBackMarkers(); + }; + this.removeOverlay = function(o) { + if (this.$searchHighlight && this.$searchHighlight.session) { + this.$searchHighlight.destroy(); + } + }; + this.getScrollInfo = function() { + var renderer = this.ace.renderer; + var config = renderer.layerConfig; + return { + left: renderer.scrollLeft, + top: renderer.scrollTop, + height: config.maxHeight, + width: config.width, + clientHeight: config.height, + clientWidth: config.width + }; + }; + this.getValue = function() { + return this.ace.getValue(); + }; + this.setValue = function(v) { + return this.ace.setValue(v); + }; + this.getTokenTypeAt = function(pos) { + var token = this.ace.session.getTokenAt(pos.line, pos.ch); + return token && /comment|string/.test(token.type) ? "string" : ""; + }; + this.findMatchingBracket = function(pos) { + var m = this.ace.session.findMatchingBracket(toAcePos(pos)); + return {to: m && toCmPos(m)}; + }; + this.indentLine = function(line, method) { + if (method === true) + this.ace.session.indentRows(line, line, "\t"); + else if (method === false) + this.ace.session.outdentRows(new Range(line, 0, line, 0)); + }; + this.indexFromPos = function(pos) { + return this.ace.session.doc.positionToIndex(toAcePos(pos)); + }; + this.posFromIndex = function(index) { + return toCmPos(this.ace.session.doc.indexToPosition(index)); + }; + this.focus = function(index) { + return this.ace.focus(); + }; + this.blur = function(index) { + return this.ace.blur(); + }; + this.defaultTextHeight = function(index) { + return this.ace.renderer.layerConfig.lineHeight; + }; + this.scanForBracket = function(pos, dir, _, options) { + var re = options.bracketRegex.source; + if (dir == 1) { + var m = this.ace.session.$findClosingBracket(re.slice(1, 2), toAcePos(pos), /paren|text/); + } else { + var m = this.ace.session.$findOpeningBracket(re.slice(-2, -1), {row: pos.line, column: pos.ch + 1}, /paren|text/); + } + return m && {pos: toCmPos(m)}; + }; + this.refresh = function() { + return this.ace.resize(true); + }; + this.getMode = function() { + return { name : this.getOption("mode") }; + } +}).call(CodeMirror.prototype); + function toAcePos(cmPos) { + return {row: cmPos.line, column: cmPos.ch}; + } + function toCmPos(acePos) { + return new Pos(acePos.row, acePos.column); + } + + var StringStream = CodeMirror.StringStream = function(string, tabSize) { + this.pos = this.start = 0; + this.string = string; + this.tabSize = tabSize || 8; + this.lastColumnPos = this.lastColumnValue = 0; + this.lineStart = 0; + }; + + StringStream.prototype = { + eol: function() {return this.pos >= this.string.length;}, + sol: function() {return this.pos == this.lineStart;}, + peek: function() {return this.string.charAt(this.pos) || undefined;}, + next: function() { + if (this.pos < this.string.length) + return this.string.charAt(this.pos++); + }, + eat: function(match) { + var ch = this.string.charAt(this.pos); + if (typeof match == "string") var ok = ch == match; + else var ok = ch && (match.test ? match.test(ch) : match(ch)); + if (ok) {++this.pos; return ch;} + }, + eatWhile: function(match) { + var start = this.pos; + while (this.eat(match)){} + return this.pos > start; + }, + eatSpace: function() { + var start = this.pos; + while (/[\s\u00a0]/.test(this.string.charAt(this.pos))) ++this.pos; + return this.pos > start; + }, + skipToEnd: function() {this.pos = this.string.length;}, + skipTo: function(ch) { + var found = this.string.indexOf(ch, this.pos); + if (found > -1) {this.pos = found; return true;} + }, + backUp: function(n) {this.pos -= n;}, + column: function() { + throw "not implemented"; + }, + indentation: function() { + throw "not implemented"; + }, + match: function(pattern, consume, caseInsensitive) { + if (typeof pattern == "string") { + var cased = function(str) {return caseInsensitive ? str.toLowerCase() : str;}; + var substr = this.string.substr(this.pos, pattern.length); + if (cased(substr) == cased(pattern)) { + if (consume !== false) this.pos += pattern.length; + return true; + } + } else { + var match = this.string.slice(this.pos).match(pattern); + if (match && match.index > 0) return null; + if (match && consume !== false) this.pos += match[0].length; + return match; + } + }, + current: function(){return this.string.slice(this.start, this.pos);}, + hideFirstChars: function(n, inner) { + this.lineStart += n; + try { return inner(); } + finally { this.lineStart -= n; } + } + }; + +// todo replace with showCommandLine +CodeMirror.defineExtension = function(name, fn) { + CodeMirror.prototype[name] = fn; +}; +dom.importCssString(".normal-mode .ace_cursor{\ + border: 1px solid red;\ + background-color: red;\ + opacity: 0.5;\ +}\ +.normal-mode .ace_hidden-cursors .ace_cursor{\ + background-color: transparent;\ +}\ +.ace_dialog {\ + position: absolute;\ + left: 0; right: 0;\ + background: white;\ + z-index: 15;\ + padding: .1em .8em;\ + overflow: hidden;\ + color: #333;\ +}\ +.ace_dialog-top {\ + border-bottom: 1px solid #eee;\ + top: 0;\ +}\ +.ace_dialog-bottom {\ + border-top: 1px solid #eee;\ + bottom: 0;\ +}\ +.ace_dialog input {\ + border: none;\ + outline: none;\ + background: transparent;\ + width: 20em;\ + color: inherit;\ + font-family: monospace;\ +}", "vimMode"); +(function() { + function closeNotification(cm, newVal) { + if (cm.state.currentNotificationClose) + cm.state.currentNotificationClose(); + cm.state.currentNotificationClose = newVal; + } + + CodeMirror.defineExtension("openDialog", function(template, callback, options) { + if (this.virtualSelectionMode()) return; + if (!options) options = {}; + + closeNotification(this, null); + + var dialog = dialogDiv(this, template, options.bottom); + var closed = false, me = this; + function close(newVal) { + if (typeof newVal == 'string') { + inp.value = newVal; + } else { + if (closed) return; + closed = true; + dialog.parentNode.removeChild(dialog); + me.focus(); + + if (options.onClose) options.onClose(dialog); + } + } + + var inp = dialog.getElementsByTagName("input")[0], button; + if (inp) { + if (options.value) { + inp.value = options.value; + if (options.select !== false) inp.select(); + } + + if (options.onInput) + CodeMirror.on(inp, "input", function(e) { options.onInput(e, inp.value, close);}); + if (options.onKeyUp) + CodeMirror.on(inp, "keyup", function(e) {options.onKeyUp(e, inp.value, close);}); + + CodeMirror.on(inp, "keydown", function(e) { + if (options && options.onKeyDown && options.onKeyDown(e, inp.value, close)) { return; } + if (e.keyCode == 27 || (options.closeOnEnter !== false && e.keyCode == 13)) { + inp.blur(); + CodeMirror.e_stop(e); + close(); + } + if (e.keyCode == 13) callback(inp.value); + }); + + if (options.closeOnBlur !== false) CodeMirror.on(inp, "blur", close); + + inp.focus(); + } else if (button = dialog.getElementsByTagName("button")[0]) { + CodeMirror.on(button, "click", function() { + close(); + me.focus(); + }); + + if (options.closeOnBlur !== false) CodeMirror.on(button, "blur", close); + + button.focus(); + } + return close; + }); + + CodeMirror.defineExtension("openNotification", function(template, options) { + if (this.virtualSelectionMode()) return; + closeNotification(this, close); + var dialog = dialogDiv(this, template, options && options.bottom); + var closed = false, doneTimer; + var duration = options && typeof options.duration !== "undefined" ? options.duration : 5000; + + function close() { + if (closed) return; + closed = true; + clearTimeout(doneTimer); + dialog.parentNode.removeChild(dialog); + } + + CodeMirror.on(dialog, 'click', function(e) { + CodeMirror.e_preventDefault(e); + close(); + }); + + if (duration) + doneTimer = setTimeout(close, duration); + + return close; + }); +})(); + + + var defaultKeymap = [ + // Key to key mapping. This goes first to make it possible to override + // existing mappings. + { keys: '', type: 'keyToKey', toKeys: 'h' }, + { keys: '', type: 'keyToKey', toKeys: 'l' }, + { keys: '', type: 'keyToKey', toKeys: 'k' }, + { keys: '', type: 'keyToKey', toKeys: 'j' }, + { keys: '', type: 'keyToKey', toKeys: 'l' }, + { keys: '', type: 'keyToKey', toKeys: 'h', context: 'normal'}, + { keys: '', type: 'keyToKey', toKeys: 'W' }, + { keys: '', type: 'keyToKey', toKeys: 'B', context: 'normal' }, + { keys: '', type: 'keyToKey', toKeys: 'w' }, + { keys: '', type: 'keyToKey', toKeys: 'b', context: 'normal' }, + { keys: '', type: 'keyToKey', toKeys: 'j' }, + { keys: '', type: 'keyToKey', toKeys: 'k' }, + { keys: '', type: 'keyToKey', toKeys: '' }, + { keys: '', type: 'keyToKey', toKeys: '' }, + { keys: '', type: 'keyToKey', toKeys: '', context: 'insert' }, + { keys: '', type: 'keyToKey', toKeys: '', context: 'insert' }, + { keys: 's', type: 'keyToKey', toKeys: 'cl', context: 'normal' }, + { keys: 's', type: 'keyToKey', toKeys: 'xi', context: 'visual'}, + { keys: 'S', type: 'keyToKey', toKeys: 'cc', context: 'normal' }, + { keys: 'S', type: 'keyToKey', toKeys: 'dcc', context: 'visual' }, + { keys: '', type: 'keyToKey', toKeys: '0' }, + { keys: '', type: 'keyToKey', toKeys: '$' }, + { keys: '', type: 'keyToKey', toKeys: '' }, + { keys: '', type: 'keyToKey', toKeys: '' }, + { keys: '', type: 'keyToKey', toKeys: 'j^', context: 'normal' }, + // Motions + { keys: 'H', type: 'motion', motion: 'moveToTopLine', motionArgs: { linewise: true, toJumplist: true }}, + { keys: 'M', type: 'motion', motion: 'moveToMiddleLine', motionArgs: { linewise: true, toJumplist: true }}, + { keys: 'L', type: 'motion', motion: 'moveToBottomLine', motionArgs: { linewise: true, toJumplist: true }}, + { keys: 'h', type: 'motion', motion: 'moveByCharacters', motionArgs: { forward: false }}, + { keys: 'l', type: 'motion', motion: 'moveByCharacters', motionArgs: { forward: true }}, + { keys: 'j', type: 'motion', motion: 'moveByLines', motionArgs: { forward: true, linewise: true }}, + { keys: 'k', type: 'motion', motion: 'moveByLines', motionArgs: { forward: false, linewise: true }}, + { keys: 'gj', type: 'motion', motion: 'moveByDisplayLines', motionArgs: { forward: true }}, + { keys: 'gk', type: 'motion', motion: 'moveByDisplayLines', motionArgs: { forward: false }}, + { keys: 'w', type: 'motion', motion: 'moveByWords', motionArgs: { forward: true, wordEnd: false }}, + { keys: 'W', type: 'motion', motion: 'moveByWords', motionArgs: { forward: true, wordEnd: false, bigWord: true }}, + { keys: 'e', type: 'motion', motion: 'moveByWords', motionArgs: { forward: true, wordEnd: true, inclusive: true }}, + { keys: 'E', type: 'motion', motion: 'moveByWords', motionArgs: { forward: true, wordEnd: true, bigWord: true, inclusive: true }}, + { keys: 'b', type: 'motion', motion: 'moveByWords', motionArgs: { forward: false, wordEnd: false }}, + { keys: 'B', type: 'motion', motion: 'moveByWords', motionArgs: { forward: false, wordEnd: false, bigWord: true }}, + { keys: 'ge', type: 'motion', motion: 'moveByWords', motionArgs: { forward: false, wordEnd: true, inclusive: true }}, + { keys: 'gE', type: 'motion', motion: 'moveByWords', motionArgs: { forward: false, wordEnd: true, bigWord: true, inclusive: true }}, + { keys: '{', type: 'motion', motion: 'moveByParagraph', motionArgs: { forward: false, toJumplist: true }}, + { keys: '}', type: 'motion', motion: 'moveByParagraph', motionArgs: { forward: true, toJumplist: true }}, + { keys: '', type: 'motion', motion: 'moveByPage', motionArgs: { forward: true }}, + { keys: '', type: 'motion', motion: 'moveByPage', motionArgs: { forward: false }}, + { keys: '', type: 'motion', motion: 'moveByScroll', motionArgs: { forward: true, explicitRepeat: true }}, + { keys: '', type: 'motion', motion: 'moveByScroll', motionArgs: { forward: false, explicitRepeat: true }}, + { keys: 'gg', type: 'motion', motion: 'moveToLineOrEdgeOfDocument', motionArgs: { forward: false, explicitRepeat: true, linewise: true, toJumplist: true }}, + { keys: 'G', type: 'motion', motion: 'moveToLineOrEdgeOfDocument', motionArgs: { forward: true, explicitRepeat: true, linewise: true, toJumplist: true }}, + { keys: '0', type: 'motion', motion: 'moveToStartOfLine' }, + { keys: '^', type: 'motion', motion: 'moveToFirstNonWhiteSpaceCharacter' }, + { keys: '+', type: 'motion', motion: 'moveByLines', motionArgs: { forward: true, toFirstChar:true }}, + { keys: '-', type: 'motion', motion: 'moveByLines', motionArgs: { forward: false, toFirstChar:true }}, + { keys: '_', type: 'motion', motion: 'moveByLines', motionArgs: { forward: true, toFirstChar:true, repeatOffset:-1 }}, + { keys: '$', type: 'motion', motion: 'moveToEol', motionArgs: { inclusive: true }}, + { keys: '%', type: 'motion', motion: 'moveToMatchedSymbol', motionArgs: { inclusive: true, toJumplist: true }}, + { keys: 'f', type: 'motion', motion: 'moveToCharacter', motionArgs: { forward: true , inclusive: true }}, + { keys: 'F', type: 'motion', motion: 'moveToCharacter', motionArgs: { forward: false }}, + { keys: 't', type: 'motion', motion: 'moveTillCharacter', motionArgs: { forward: true, inclusive: true }}, + { keys: 'T', type: 'motion', motion: 'moveTillCharacter', motionArgs: { forward: false }}, + { keys: ';', type: 'motion', motion: 'repeatLastCharacterSearch', motionArgs: { forward: true }}, + { keys: ',', type: 'motion', motion: 'repeatLastCharacterSearch', motionArgs: { forward: false }}, + { keys: '\'', type: 'motion', motion: 'goToMark', motionArgs: {toJumplist: true, linewise: true}}, + { keys: '`', type: 'motion', motion: 'goToMark', motionArgs: {toJumplist: true}}, + { keys: ']`', type: 'motion', motion: 'jumpToMark', motionArgs: { forward: true } }, + { keys: '[`', type: 'motion', motion: 'jumpToMark', motionArgs: { forward: false } }, + { keys: ']\'', type: 'motion', motion: 'jumpToMark', motionArgs: { forward: true, linewise: true } }, + { keys: '[\'', type: 'motion', motion: 'jumpToMark', motionArgs: { forward: false, linewise: true } }, + // the next two aren't motions but must come before more general motion declarations + { keys: ']p', type: 'action', action: 'paste', isEdit: true, actionArgs: { after: true, isEdit: true, matchIndent: true}}, + { keys: '[p', type: 'action', action: 'paste', isEdit: true, actionArgs: { after: false, isEdit: true, matchIndent: true}}, + { keys: ']', type: 'motion', motion: 'moveToSymbol', motionArgs: { forward: true, toJumplist: true}}, + { keys: '[', type: 'motion', motion: 'moveToSymbol', motionArgs: { forward: false, toJumplist: true}}, + { keys: '|', type: 'motion', motion: 'moveToColumn'}, + { keys: 'o', type: 'motion', motion: 'moveToOtherHighlightedEnd', context:'visual'}, + { keys: 'O', type: 'motion', motion: 'moveToOtherHighlightedEnd', motionArgs: {sameLine: true}, context:'visual'}, + // Operators + { keys: 'd', type: 'operator', operator: 'delete' }, + { keys: 'y', type: 'operator', operator: 'yank' }, + { keys: 'c', type: 'operator', operator: 'change' }, + { keys: '>', type: 'operator', operator: 'indent', operatorArgs: { indentRight: true }}, + { keys: '<', type: 'operator', operator: 'indent', operatorArgs: { indentRight: false }}, + { keys: 'g~', type: 'operator', operator: 'changeCase' }, + { keys: 'gu', type: 'operator', operator: 'changeCase', operatorArgs: {toLower: true}, isEdit: true }, + { keys: 'gU', type: 'operator', operator: 'changeCase', operatorArgs: {toLower: false}, isEdit: true }, + { keys: 'n', type: 'motion', motion: 'findNext', motionArgs: { forward: true, toJumplist: true }}, + { keys: 'N', type: 'motion', motion: 'findNext', motionArgs: { forward: false, toJumplist: true }}, + // Operator-Motion dual commands + { keys: 'x', type: 'operatorMotion', operator: 'delete', motion: 'moveByCharacters', motionArgs: { forward: true }, operatorMotionArgs: { visualLine: false }}, + { keys: 'X', type: 'operatorMotion', operator: 'delete', motion: 'moveByCharacters', motionArgs: { forward: false }, operatorMotionArgs: { visualLine: true }}, + { keys: 'D', type: 'operatorMotion', operator: 'delete', motion: 'moveToEol', motionArgs: { inclusive: true }, context: 'normal'}, + { keys: 'D', type: 'operator', operator: 'delete', operatorArgs: { linewise: true }, context: 'visual'}, + { keys: 'Y', type: 'operatorMotion', operator: 'yank', motion: 'moveToEol', motionArgs: { inclusive: true }, context: 'normal'}, + { keys: 'Y', type: 'operator', operator: 'yank', operatorArgs: { linewise: true }, context: 'visual'}, + { keys: 'C', type: 'operatorMotion', operator: 'change', motion: 'moveToEol', motionArgs: { inclusive: true }, context: 'normal'}, + { keys: 'C', type: 'operator', operator: 'change', operatorArgs: { linewise: true }, context: 'visual'}, + { keys: '~', type: 'operatorMotion', operator: 'changeCase', motion: 'moveByCharacters', motionArgs: { forward: true }, operatorArgs: { shouldMoveCursor: true }, context: 'normal'}, + { keys: '~', type: 'operator', operator: 'changeCase', context: 'visual'}, + { keys: '', type: 'operatorMotion', operator: 'delete', motion: 'moveByWords', motionArgs: { forward: false, wordEnd: false }, context: 'insert' }, + // Actions + { keys: '', type: 'action', action: 'jumpListWalk', actionArgs: { forward: true }}, + { keys: '', type: 'action', action: 'jumpListWalk', actionArgs: { forward: false }}, + { keys: '', type: 'action', action: 'scroll', actionArgs: { forward: true, linewise: true }}, + { keys: '', type: 'action', action: 'scroll', actionArgs: { forward: false, linewise: true }}, + { keys: 'a', type: 'action', action: 'enterInsertMode', isEdit: true, actionArgs: { insertAt: 'charAfter' }, context: 'normal' }, + { keys: 'A', type: 'action', action: 'enterInsertMode', isEdit: true, actionArgs: { insertAt: 'eol' }, context: 'normal' }, + { keys: 'A', type: 'action', action: 'enterInsertMode', isEdit: true, actionArgs: { insertAt: 'endOfSelectedArea' }, context: 'visual' }, + { keys: 'i', type: 'action', action: 'enterInsertMode', isEdit: true, actionArgs: { insertAt: 'inplace' }, context: 'normal' }, + { keys: 'I', type: 'action', action: 'enterInsertMode', isEdit: true, actionArgs: { insertAt: 'firstNonBlank'}, context: 'normal' }, + { keys: 'I', type: 'action', action: 'enterInsertMode', isEdit: true, actionArgs: { insertAt: 'startOfSelectedArea' }, context: 'visual' }, + { keys: 'o', type: 'action', action: 'newLineAndEnterInsertMode', isEdit: true, interlaceInsertRepeat: true, actionArgs: { after: true }, context: 'normal' }, + { keys: 'O', type: 'action', action: 'newLineAndEnterInsertMode', isEdit: true, interlaceInsertRepeat: true, actionArgs: { after: false }, context: 'normal' }, + { keys: 'v', type: 'action', action: 'toggleVisualMode' }, + { keys: 'V', type: 'action', action: 'toggleVisualMode', actionArgs: { linewise: true }}, + { keys: '', type: 'action', action: 'toggleVisualMode', actionArgs: { blockwise: true }}, + { keys: 'gv', type: 'action', action: 'reselectLastSelection' }, + { keys: 'J', type: 'action', action: 'joinLines', isEdit: true }, + { keys: 'p', type: 'action', action: 'paste', isEdit: true, actionArgs: { after: true, isEdit: true }}, + { keys: 'P', type: 'action', action: 'paste', isEdit: true, actionArgs: { after: false, isEdit: true }}, + { keys: 'r', type: 'action', action: 'replace', isEdit: true }, + { keys: '@', type: 'action', action: 'replayMacro' }, + { keys: 'q', type: 'action', action: 'enterMacroRecordMode' }, + // Handle Replace-mode as a special case of insert mode. + { keys: 'R', type: 'action', action: 'enterInsertMode', isEdit: true, actionArgs: { replace: true }}, + { keys: 'u', type: 'action', action: 'undo', context: 'normal' }, + { keys: 'u', type: 'operator', operator: 'changeCase', operatorArgs: {toLower: true}, context: 'visual', isEdit: true }, + { keys: 'U', type: 'operator', operator: 'changeCase', operatorArgs: {toLower: false}, context: 'visual', isEdit: true }, + { keys: '', type: 'action', action: 'redo' }, + { keys: 'm', type: 'action', action: 'setMark' }, + { keys: '"', type: 'action', action: 'setRegister' }, + { keys: 'zz', type: 'action', action: 'scrollToCursor', actionArgs: { position: 'center' }}, + { keys: 'z.', type: 'action', action: 'scrollToCursor', actionArgs: { position: 'center' }, motion: 'moveToFirstNonWhiteSpaceCharacter' }, + { keys: 'zt', type: 'action', action: 'scrollToCursor', actionArgs: { position: 'top' }}, + { keys: 'z', type: 'action', action: 'scrollToCursor', actionArgs: { position: 'top' }, motion: 'moveToFirstNonWhiteSpaceCharacter' }, + { keys: 'z-', type: 'action', action: 'scrollToCursor', actionArgs: { position: 'bottom' }}, + { keys: 'zb', type: 'action', action: 'scrollToCursor', actionArgs: { position: 'bottom' }, motion: 'moveToFirstNonWhiteSpaceCharacter' }, + { keys: '.', type: 'action', action: 'repeatLastEdit' }, + { keys: '', type: 'action', action: 'incrementNumberToken', isEdit: true, actionArgs: {increase: true, backtrack: false}}, + { keys: '', type: 'action', action: 'incrementNumberToken', isEdit: true, actionArgs: {increase: false, backtrack: false}}, + // Text object motions + { keys: 'a', type: 'motion', motion: 'textObjectManipulation' }, + { keys: 'i', type: 'motion', motion: 'textObjectManipulation', motionArgs: { textObjectInner: true }}, + // Search + { keys: '/', type: 'search', searchArgs: { forward: true, querySrc: 'prompt', toJumplist: true }}, + { keys: '?', type: 'search', searchArgs: { forward: false, querySrc: 'prompt', toJumplist: true }}, + { keys: '*', type: 'search', searchArgs: { forward: true, querySrc: 'wordUnderCursor', wholeWordOnly: true, toJumplist: true }}, + { keys: '#', type: 'search', searchArgs: { forward: false, querySrc: 'wordUnderCursor', wholeWordOnly: true, toJumplist: true }}, + { keys: 'g*', type: 'search', searchArgs: { forward: true, querySrc: 'wordUnderCursor', toJumplist: true }}, + { keys: 'g#', type: 'search', searchArgs: { forward: false, querySrc: 'wordUnderCursor', toJumplist: true }}, + // Ex command + { keys: ':', type: 'ex' } + ]; + + var Pos = CodeMirror.Pos; + + var Vim = function() { return vimApi; } //{ + function enterVimMode(cm) { + cm.setOption('disableInput', true); + cm.setOption('showCursorWhenSelecting', false); + CodeMirror.signal(cm, "vim-mode-change", {mode: "normal"}); + cm.on('cursorActivity', onCursorActivity); + maybeInitVimState(cm); + CodeMirror.on(cm.getInputField(), 'paste', getOnPasteFn(cm)); + } + + function leaveVimMode(cm) { + cm.setOption('disableInput', false); + cm.off('cursorActivity', onCursorActivity); + CodeMirror.off(cm.getInputField(), 'paste', getOnPasteFn(cm)); + cm.state.vim = null; + } + + function detachVimMap(cm, next) { + if (this == CodeMirror.keyMap.vim) + CodeMirror.rmClass(cm.getWrapperElement(), "cm-fat-cursor"); + + if (!next || next.attach != attachVimMap) + leaveVimMode(cm, false); + } + function attachVimMap(cm, prev) { + if (this == CodeMirror.keyMap.vim) + CodeMirror.addClass(cm.getWrapperElement(), "cm-fat-cursor"); + + if (!prev || prev.attach != attachVimMap) + enterVimMode(cm); + } + + // Deprecated, simply setting the keymap works again. + CodeMirror.defineOption('vimMode', false, function(cm, val, prev) { + if (val && cm.getOption("keyMap") != "vim") + cm.setOption("keyMap", "vim"); + else if (!val && prev != CodeMirror.Init && /^vim/.test(cm.getOption("keyMap"))) + cm.setOption("keyMap", "default"); + }); + + function cmKey(key, cm) { + if (!cm) { return undefined; } + var vimKey = cmKeyToVimKey(key); + if (!vimKey) { + return false; + } + var cmd = CodeMirror.Vim.findKey(cm, vimKey); + if (typeof cmd == 'function') { + CodeMirror.signal(cm, 'vim-keypress', vimKey); + } + return cmd; + } + + var modifiers = {'Shift': 'S', 'Ctrl': 'C', 'Alt': 'A', 'Cmd': 'D', 'Mod': 'A'}; + var specialKeys = {Enter:'CR',Backspace:'BS',Delete:'Del'}; + function cmKeyToVimKey(key) { + if (key.charAt(0) == '\'') { + // Keypress character binding of format "'a'" + return key.charAt(1); + } + var pieces = key.split('-'); + if (/-$/.test(key)) { + // If the - key was typed, split will result in 2 extra empty strings + // in the array. Replace them with 1 '-'. + pieces.splice(-2, 2, '-'); + } + var lastPiece = pieces[pieces.length - 1]; + if (pieces.length == 1 && pieces[0].length == 1) { + // No-modifier bindings use literal character bindings above. Skip. + return false; + } else if (pieces.length == 2 && pieces[0] == 'Shift' && lastPiece.length == 1) { + // Ignore Shift+char bindings as they should be handled by literal character. + return false; + } + var hasCharacter = false; + for (var i = 0; i < pieces.length; i++) { + var piece = pieces[i]; + if (piece in modifiers) { pieces[i] = modifiers[piece]; } + else { hasCharacter = true; } + if (piece in specialKeys) { pieces[i] = specialKeys[piece]; } + } + if (!hasCharacter) { + // Vim does not support modifier only keys. + return false; + } + // TODO: Current bindings expect the character to be lower case, but + // it looks like vim key notation uses upper case. + if (isUpperCase(lastPiece)) { + pieces[pieces.length - 1] = lastPiece.toLowerCase(); + } + return '<' + pieces.join('-') + '>'; + } + + function getOnPasteFn(cm) { + var vim = cm.state.vim; + if (!vim.onPasteFn) { + vim.onPasteFn = function() { + if (!vim.insertMode) { + cm.setCursor(offsetCursor(cm.getCursor(), 0, 1)); + actions.enterInsertMode(cm, {}, vim); + } + }; + } + return vim.onPasteFn; + } + + var numberRegex = /[\d]/; + var wordCharTest = [CodeMirror.isWordChar, function(ch) { + return ch && !CodeMirror.isWordChar(ch) && !/\s/.test(ch); + }], bigWordCharTest = [function(ch) { + return /\S/.test(ch); + }]; + function makeKeyRange(start, size) { + var keys = []; + for (var i = start; i < start + size; i++) { + keys.push(String.fromCharCode(i)); + } + return keys; + } + var upperCaseAlphabet = makeKeyRange(65, 26); + var lowerCaseAlphabet = makeKeyRange(97, 26); + var numbers = makeKeyRange(48, 10); + var validMarks = [].concat(upperCaseAlphabet, lowerCaseAlphabet, numbers, ['<', '>']); + var validRegisters = [].concat(upperCaseAlphabet, lowerCaseAlphabet, numbers, ['-', '"', '.', ':', '/']); + + function isLine(cm, line) { + return line >= cm.firstLine() && line <= cm.lastLine(); + } + function isLowerCase(k) { + return (/^[a-z]$/).test(k); + } + function isMatchableSymbol(k) { + return '()[]{}'.indexOf(k) != -1; + } + function isNumber(k) { + return numberRegex.test(k); + } + function isUpperCase(k) { + return (/^[A-Z]$/).test(k); + } + function isWhiteSpaceString(k) { + return (/^\s*$/).test(k); + } + function inArray(val, arr) { + for (var i = 0; i < arr.length; i++) { + if (arr[i] == val) { + return true; + } + } + return false; + } + + var options = {}; + function defineOption(name, defaultValue, type, aliases, callback) { + if (defaultValue === undefined && !callback) { + throw Error('defaultValue is required unless callback is provided'); + } + if (!type) { type = 'string'; } + options[name] = { + type: type, + defaultValue: defaultValue, + callback: callback + }; + if (aliases) { + for (var i = 0; i < aliases.length; i++) { + options[aliases[i]] = options[name]; + } + } + if (defaultValue) { + setOption(name, defaultValue); + } + } + + function setOption(name, value, cm, cfg) { + var option = options[name]; + cfg = cfg || {}; + var scope = cfg.scope; + if (!option) { + throw Error('Unknown option: ' + name); + } + if (option.type == 'boolean') { + if (value && value !== true) { + throw Error('Invalid argument: ' + name + '=' + value); + } else if (value !== false) { + // Boolean options are set to true if value is not defined. + value = true; + } + } + if (option.callback) { + if (scope !== 'local') { + option.callback(value, undefined); + } + if (scope !== 'global' && cm) { + option.callback(value, cm); + } + } else { + if (scope !== 'local') { + option.value = option.type == 'boolean' ? !!value : value; + } + if (scope !== 'global' && cm) { + cm.state.vim.options[name] = {value: value}; + } + } + } + + function getOption(name, cm, cfg) { + var option = options[name]; + cfg = cfg || {}; + var scope = cfg.scope; + if (!option) { + throw Error('Unknown option: ' + name); + } + if (option.callback) { + var local = cm && option.callback(undefined, cm); + if (scope !== 'global' && local !== undefined) { + return local; + } + if (scope !== 'local') { + return option.callback(); + } + return; + } else { + var local = (scope !== 'global') && (cm && cm.state.vim.options[name]); + return (local || (scope !== 'local') && option || {}).value; + } + } + + defineOption('filetype', undefined, 'string', ['ft'], function(name, cm) { + // Option is local. Do nothing for global. + if (cm === undefined) { + return; + } + // The 'filetype' option proxies to the CodeMirror 'mode' option. + if (name === undefined) { + var mode = cm.getMode().name; + return mode == 'null' ? '' : mode; + } else { + var mode = name == '' ? 'null' : name; + cm.setOption('mode', mode); + } + }); + + var createCircularJumpList = function() { + var size = 100; + var pointer = -1; + var head = 0; + var tail = 0; + var buffer = new Array(size); + function add(cm, oldCur, newCur) { + var current = pointer % size; + var curMark = buffer[current]; + function useNextSlot(cursor) { + var next = ++pointer % size; + var trashMark = buffer[next]; + if (trashMark) { + trashMark.clear(); + } + buffer[next] = cm.setBookmark(cursor); + } + if (curMark) { + var markPos = curMark.find(); + // avoid recording redundant cursor position + if (markPos && !cursorEqual(markPos, oldCur)) { + useNextSlot(oldCur); + } + } else { + useNextSlot(oldCur); + } + useNextSlot(newCur); + head = pointer; + tail = pointer - size + 1; + if (tail < 0) { + tail = 0; + } + } + function move(cm, offset) { + pointer += offset; + if (pointer > head) { + pointer = head; + } else if (pointer < tail) { + pointer = tail; + } + var mark = buffer[(size + pointer) % size]; + // skip marks that are temporarily removed from text buffer + if (mark && !mark.find()) { + var inc = offset > 0 ? 1 : -1; + var newCur; + var oldCur = cm.getCursor(); + do { + pointer += inc; + mark = buffer[(size + pointer) % size]; + // skip marks that are the same as current position + if (mark && + (newCur = mark.find()) && + !cursorEqual(oldCur, newCur)) { + break; + } + } while (pointer < head && pointer > tail); + } + return mark; + } + return { + cachedCursor: undefined, //used for # and * jumps + add: add, + move: move + }; + }; + + // Returns an object to track the changes associated insert mode. It + // clones the object that is passed in, or creates an empty object one if + // none is provided. + var createInsertModeChanges = function(c) { + if (c) { + // Copy construction + return { + changes: c.changes, + expectCursorActivityForChange: c.expectCursorActivityForChange + }; + } + return { + // Change list + changes: [], + // Set to true on change, false on cursorActivity. + expectCursorActivityForChange: false + }; + }; + + function MacroModeState() { + this.latestRegister = undefined; + this.isPlaying = false; + this.isRecording = false; + this.replaySearchQueries = []; + this.onRecordingDone = undefined; + this.lastInsertModeChanges = createInsertModeChanges(); + } + MacroModeState.prototype = { + exitMacroRecordMode: function() { + var macroModeState = vimGlobalState.macroModeState; + if (macroModeState.onRecordingDone) { + macroModeState.onRecordingDone(); // close dialog + } + macroModeState.onRecordingDone = undefined; + macroModeState.isRecording = false; + }, + enterMacroRecordMode: function(cm, registerName) { + var register = + vimGlobalState.registerController.getRegister(registerName); + if (register) { + register.clear(); + this.latestRegister = registerName; + if (cm.openDialog) { + this.onRecordingDone = cm.openDialog( + '(recording)['+registerName+']', null, {bottom:true}); + } + this.isRecording = true; + } + } + }; + + function maybeInitVimState(cm) { + if (!cm.state.vim) { + // Store instance state in the CodeMirror object. + cm.state.vim = { + inputState: new InputState(), + // Vim's input state that triggered the last edit, used to repeat + // motions and operators with '.'. + lastEditInputState: undefined, + // Vim's action command before the last edit, used to repeat actions + // with '.' and insert mode repeat. + lastEditActionCommand: undefined, + // When using jk for navigation, if you move from a longer line to a + // shorter line, the cursor may clip to the end of the shorter line. + // If j is pressed again and cursor goes to the next line, the + // cursor should go back to its horizontal position on the longer + // line if it can. This is to keep track of the horizontal position. + lastHPos: -1, + // Doing the same with screen-position for gj/gk + lastHSPos: -1, + // The last motion command run. Cleared if a non-motion command gets + // executed in between. + lastMotion: null, + marks: {}, + // Mark for rendering fake cursor for visual mode. + fakeCursor: null, + insertMode: false, + // Repeat count for changes made in insert mode, triggered by key + // sequences like 3,i. Only exists when insertMode is true. + insertModeRepeat: undefined, + visualMode: false, + // If we are in visual line mode. No effect if visualMode is false. + visualLine: false, + visualBlock: false, + lastSelection: null, + lastPastedText: null, + sel: {}, + // Buffer-local/window-local values of vim options. + options: {} + }; + } + return cm.state.vim; + } + var vimGlobalState; + function resetVimGlobalState() { + vimGlobalState = { + // The current search query. + searchQuery: null, + // Whether we are searching backwards. + searchIsReversed: false, + // Replace part of the last substituted pattern + lastSubstituteReplacePart: undefined, + jumpList: createCircularJumpList(), + macroModeState: new MacroModeState, + // Recording latest f, t, F or T motion command. + lastChararacterSearch: {increment:0, forward:true, selectedCharacter:''}, + registerController: new RegisterController({}), + // search history buffer + searchHistoryController: new HistoryController({}), + // ex Command history buffer + exCommandHistoryController : new HistoryController({}) + }; + for (var optionName in options) { + var option = options[optionName]; + option.value = option.defaultValue; + } + } + + var lastInsertModeKeyTimer; + var vimApi= { + buildKeyMap: function() { + // TODO: Convert keymap into dictionary format for fast lookup. + }, + // Testing hook, though it might be useful to expose the register + // controller anyways. + getRegisterController: function() { + return vimGlobalState.registerController; + }, + // Testing hook. + resetVimGlobalState_: resetVimGlobalState, + + // Testing hook. + getVimGlobalState_: function() { + return vimGlobalState; + }, + + // Testing hook. + maybeInitVimState_: maybeInitVimState, + + suppressErrorLogging: false, + + InsertModeKey: InsertModeKey, + map: function(lhs, rhs, ctx) { + // Add user defined key bindings. + exCommandDispatcher.map(lhs, rhs, ctx); + }, + unmap: function(lhs, ctx) { + // remove user defined key bindings. + exCommandDispatcher.unmap(lhs, ctx); + }, + // TODO: Expose setOption and getOption as instance methods. Need to decide how to namespace + // them, or somehow make them work with the existing CodeMirror setOption/getOption API. + setOption: setOption, + getOption: getOption, + defineOption: defineOption, + defineEx: function(name, prefix, func){ + if (name.indexOf(prefix) !== 0) { + throw new Error('(Vim.defineEx) "'+prefix+'" is not a prefix of "'+name+'", command not registered'); + } + exCommands[name]=func; + exCommandDispatcher.commandMap_[prefix]={name:name, shortName:prefix, type:'api'}; + }, + handleKey: function (cm, key, origin) { + var command = this.findKey(cm, key, origin); + if (typeof command === 'function') { + return command(); + } + }, + /** + * This is the outermost function called by CodeMirror, after keys have + * been mapped to their Vim equivalents. + * + * Finds a command based on the key (and cached keys if there is a + * multi-key sequence). Returns `undefined` if no key is matched, a noop + * function if a partial match is found (multi-key), and a function to + * execute the bound command if a a key is matched. The function always + * returns true. + */ + findKey: function(cm, key, origin) { + var vim = maybeInitVimState(cm); + function handleMacroRecording() { + var macroModeState = vimGlobalState.macroModeState; + if (macroModeState.isRecording) { + if (key == 'q') { + macroModeState.exitMacroRecordMode(); + clearInputState(cm); + return true; + } + if (origin != 'mapping') { + logKey(macroModeState, key); + } + } + } + function handleEsc() { + if (key == '') { + // Clear input state and get back to normal mode. + clearInputState(cm); + if (vim.visualMode) { + exitVisualMode(cm); + } else if (vim.insertMode) { + exitInsertMode(cm); + } + return true; + } + } + function doKeyToKey(keys) { + // TODO: prevent infinite recursion. + var match; + while (keys) { + // Pull off one command key, which is either a single character + // or a special sequence wrapped in '<' and '>', e.g. ''. + match = (/<\w+-.+?>|<\w+>|./).exec(keys); + key = match[0]; + keys = keys.substring(match.index + key.length); + CodeMirror.Vim.handleKey(cm, key, 'mapping'); + } + } + + function handleKeyInsertMode() { + if (handleEsc()) { return true; } + var keys = vim.inputState.keyBuffer = vim.inputState.keyBuffer + key; + var keysAreChars = key.length == 1; + var match = commandDispatcher.matchCommand(keys, defaultKeymap, vim.inputState, 'insert'); + // Need to check all key substrings in insert mode. + while (keys.length > 1 && match.type != 'full') { + var keys = vim.inputState.keyBuffer = keys.slice(1); + var thisMatch = commandDispatcher.matchCommand(keys, defaultKeymap, vim.inputState, 'insert'); + if (thisMatch.type != 'none') { match = thisMatch; } + } + if (match.type == 'none') { clearInputState(cm); return false; } + else if (match.type == 'partial') { + if (lastInsertModeKeyTimer) { window.clearTimeout(lastInsertModeKeyTimer); } + lastInsertModeKeyTimer = window.setTimeout( + function() { if (vim.insertMode && vim.inputState.keyBuffer) { clearInputState(cm); } }, + getOption('insertModeEscKeysTimeout')); + return !keysAreChars; + } + + if (lastInsertModeKeyTimer) { window.clearTimeout(lastInsertModeKeyTimer); } + if (keysAreChars) { + var here = cm.getCursor(); + cm.replaceRange('', offsetCursor(here, 0, -(keys.length - 1)), here, '+input'); + } + clearInputState(cm); + return match.command; + } + + function handleKeyNonInsertMode() { + if (handleMacroRecording() || handleEsc()) { return true; }; + + var keys = vim.inputState.keyBuffer = vim.inputState.keyBuffer + key; + if (/^[1-9]\d*$/.test(keys)) { return true; } + + var keysMatcher = /^(\d*)(.*)$/.exec(keys); + if (!keysMatcher) { clearInputState(cm); return false; } + var context = vim.visualMode ? 'visual' : + 'normal'; + var match = commandDispatcher.matchCommand(keysMatcher[2] || keysMatcher[1], defaultKeymap, vim.inputState, context); + if (match.type == 'none') { clearInputState(cm); return false; } + else if (match.type == 'partial') { return true; } + + vim.inputState.keyBuffer = ''; + var keysMatcher = /^(\d*)(.*)$/.exec(keys); + if (keysMatcher[1] && keysMatcher[1] != '0') { + vim.inputState.pushRepeatDigit(keysMatcher[1]); + } + return match.command; + } + + var command; + if (vim.insertMode) { command = handleKeyInsertMode(); } + else { command = handleKeyNonInsertMode(); } + if (command === false) { + return undefined; + } else if (command === true) { + // TODO: Look into using CodeMirror's multi-key handling. + // Return no-op since we are caching the key. Counts as handled, but + // don't want act on it just yet. + return function() {}; + } else { + return function() { + return cm.operation(function() { + cm.curOp.isVimOp = true; + try { + if (command.type == 'keyToKey') { + doKeyToKey(command.toKeys); + } else { + commandDispatcher.processCommand(cm, vim, command); + } + } catch (e) { + // clear VIM state in case it's in a bad state. + cm.state.vim = undefined; + maybeInitVimState(cm); + if (!CodeMirror.Vim.suppressErrorLogging) { + console['log'](e); + } + throw e; + } + return true; + }); + }; + } + }, + handleEx: function(cm, input) { + exCommandDispatcher.processCommand(cm, input); + }, + + defineMotion: defineMotion, + defineAction: defineAction, + defineOperator: defineOperator, + mapCommand: mapCommand, + _mapCommand: _mapCommand, + + exitVisualMode: exitVisualMode, + exitInsertMode: exitInsertMode + }; + + // Represents the current input state. + function InputState() { + this.prefixRepeat = []; + this.motionRepeat = []; + + this.operator = null; + this.operatorArgs = null; + this.motion = null; + this.motionArgs = null; + this.keyBuffer = []; // For matching multi-key commands. + this.registerName = null; // Defaults to the unnamed register. + } + InputState.prototype.pushRepeatDigit = function(n) { + if (!this.operator) { + this.prefixRepeat = this.prefixRepeat.concat(n); + } else { + this.motionRepeat = this.motionRepeat.concat(n); + } + }; + InputState.prototype.getRepeat = function() { + var repeat = 0; + if (this.prefixRepeat.length > 0 || this.motionRepeat.length > 0) { + repeat = 1; + if (this.prefixRepeat.length > 0) { + repeat *= parseInt(this.prefixRepeat.join(''), 10); + } + if (this.motionRepeat.length > 0) { + repeat *= parseInt(this.motionRepeat.join(''), 10); + } + } + return repeat; + }; + + function clearInputState(cm, reason) { + cm.state.vim.inputState = new InputState(); + CodeMirror.signal(cm, 'vim-command-done', reason); + } + + /* + * Register stores information about copy and paste registers. Besides + * text, a register must store whether it is linewise (i.e., when it is + * pasted, should it insert itself into a new line, or should the text be + * inserted at the cursor position.) + */ + function Register(text, linewise, blockwise) { + this.clear(); + this.keyBuffer = [text || '']; + this.insertModeChanges = []; + this.searchQueries = []; + this.linewise = !!linewise; + this.blockwise = !!blockwise; + } + Register.prototype = { + setText: function(text, linewise, blockwise) { + this.keyBuffer = [text || '']; + this.linewise = !!linewise; + this.blockwise = !!blockwise; + }, + pushText: function(text, linewise) { + // if this register has ever been set to linewise, use linewise. + if (linewise) { + if (!this.linewise) { + this.keyBuffer.push('\n'); + } + this.linewise = true; + } + this.keyBuffer.push(text); + }, + pushInsertModeChanges: function(changes) { + this.insertModeChanges.push(createInsertModeChanges(changes)); + }, + pushSearchQuery: function(query) { + this.searchQueries.push(query); + }, + clear: function() { + this.keyBuffer = []; + this.insertModeChanges = []; + this.searchQueries = []; + this.linewise = false; + }, + toString: function() { + return this.keyBuffer.join(''); + } + }; + + /* + * vim registers allow you to keep many independent copy and paste buffers. + * See http://usevim.com/2012/04/13/registers/ for an introduction. + * + * RegisterController keeps the state of all the registers. An initial + * state may be passed in. The unnamed register '"' will always be + * overridden. + */ + function RegisterController(registers) { + this.registers = registers; + this.unnamedRegister = registers['"'] = new Register(); + registers['.'] = new Register(); + registers[':'] = new Register(); + registers['/'] = new Register(); + } + RegisterController.prototype = { + pushText: function(registerName, operator, text, linewise, blockwise) { + if (linewise && text.charAt(0) == '\n') { + text = text.slice(1) + '\n'; + } + if (linewise && text.charAt(text.length - 1) !== '\n'){ + text += '\n'; + } + // Lowercase and uppercase registers refer to the same register. + // Uppercase just means append. + var register = this.isValidRegister(registerName) ? + this.getRegister(registerName) : null; + // if no register/an invalid register was specified, things go to the + // default registers + if (!register) { + switch (operator) { + case 'yank': + // The 0 register contains the text from the most recent yank. + this.registers['0'] = new Register(text, linewise, blockwise); + break; + case 'delete': + case 'change': + if (text.indexOf('\n') == -1) { + // Delete less than 1 line. Update the small delete register. + this.registers['-'] = new Register(text, linewise); + } else { + // Shift down the contents of the numbered registers and put the + // deleted text into register 1. + this.shiftNumericRegisters_(); + this.registers['1'] = new Register(text, linewise); + } + break; + } + // Make sure the unnamed register is set to what just happened + this.unnamedRegister.setText(text, linewise, blockwise); + return; + } + + // If we've gotten to this point, we've actually specified a register + var append = isUpperCase(registerName); + if (append) { + register.pushText(text, linewise); + } else { + register.setText(text, linewise, blockwise); + } + // The unnamed register always has the same value as the last used + // register. + this.unnamedRegister.setText(register.toString(), linewise); + }, + // Gets the register named @name. If one of @name doesn't already exist, + // create it. If @name is invalid, return the unnamedRegister. + getRegister: function(name) { + if (!this.isValidRegister(name)) { + return this.unnamedRegister; + } + name = name.toLowerCase(); + if (!this.registers[name]) { + this.registers[name] = new Register(); + } + return this.registers[name]; + }, + isValidRegister: function(name) { + return name && inArray(name, validRegisters); + }, + shiftNumericRegisters_: function() { + for (var i = 9; i >= 2; i--) { + this.registers[i] = this.getRegister('' + (i - 1)); + } + } + }; + function HistoryController() { + this.historyBuffer = []; + this.iterator; + this.initialPrefix = null; + } + HistoryController.prototype = { + // the input argument here acts a user entered prefix for a small time + // until we start autocompletion in which case it is the autocompleted. + nextMatch: function (input, up) { + var historyBuffer = this.historyBuffer; + var dir = up ? -1 : 1; + if (this.initialPrefix === null) this.initialPrefix = input; + for (var i = this.iterator + dir; up ? i >= 0 : i < historyBuffer.length; i+= dir) { + var element = historyBuffer[i]; + for (var j = 0; j <= element.length; j++) { + if (this.initialPrefix == element.substring(0, j)) { + this.iterator = i; + return element; + } + } + } + // should return the user input in case we reach the end of buffer. + if (i >= historyBuffer.length) { + this.iterator = historyBuffer.length; + return this.initialPrefix; + } + // return the last autocompleted query or exCommand as it is. + if (i < 0 ) return input; + }, + pushInput: function(input) { + var index = this.historyBuffer.indexOf(input); + if (index > -1) this.historyBuffer.splice(index, 1); + if (input.length) this.historyBuffer.push(input); + }, + reset: function() { + this.initialPrefix = null; + this.iterator = this.historyBuffer.length; + } + }; + var commandDispatcher = { + matchCommand: function(keys, keyMap, inputState, context) { + var matches = commandMatches(keys, keyMap, context, inputState); + if (!matches.full && !matches.partial) { + return {type: 'none'}; + } else if (!matches.full && matches.partial) { + return {type: 'partial'}; + } + + var bestMatch; + for (var i = 0; i < matches.full.length; i++) { + var match = matches.full[i]; + if (!bestMatch) { + bestMatch = match; + } + } + if (bestMatch.keys.slice(-11) == '') { + inputState.selectedCharacter = lastChar(keys); + } + return {type: 'full', command: bestMatch}; + }, + processCommand: function(cm, vim, command) { + vim.inputState.repeatOverride = command.repeatOverride; + switch (command.type) { + case 'motion': + this.processMotion(cm, vim, command); + break; + case 'operator': + this.processOperator(cm, vim, command); + break; + case 'operatorMotion': + this.processOperatorMotion(cm, vim, command); + break; + case 'action': + this.processAction(cm, vim, command); + break; + case 'search': + this.processSearch(cm, vim, command); + break; + case 'ex': + case 'keyToEx': + this.processEx(cm, vim, command); + break; + default: + break; + } + }, + processMotion: function(cm, vim, command) { + vim.inputState.motion = command.motion; + vim.inputState.motionArgs = copyArgs(command.motionArgs); + this.evalInput(cm, vim); + }, + processOperator: function(cm, vim, command) { + var inputState = vim.inputState; + if (inputState.operator) { + if (inputState.operator == command.operator) { + // Typing an operator twice like 'dd' makes the operator operate + // linewise + inputState.motion = 'expandToLine'; + inputState.motionArgs = { linewise: true }; + this.evalInput(cm, vim); + return; + } else { + // 2 different operators in a row doesn't make sense. + clearInputState(cm); + } + } + inputState.operator = command.operator; + inputState.operatorArgs = copyArgs(command.operatorArgs); + if (vim.visualMode) { + // Operating on a selection in visual mode. We don't need a motion. + this.evalInput(cm, vim); + } + }, + processOperatorMotion: function(cm, vim, command) { + var visualMode = vim.visualMode; + var operatorMotionArgs = copyArgs(command.operatorMotionArgs); + if (operatorMotionArgs) { + // Operator motions may have special behavior in visual mode. + if (visualMode && operatorMotionArgs.visualLine) { + vim.visualLine = true; + } + } + this.processOperator(cm, vim, command); + if (!visualMode) { + this.processMotion(cm, vim, command); + } + }, + processAction: function(cm, vim, command) { + var inputState = vim.inputState; + var repeat = inputState.getRepeat(); + var repeatIsExplicit = !!repeat; + var actionArgs = copyArgs(command.actionArgs) || {}; + if (inputState.selectedCharacter) { + actionArgs.selectedCharacter = inputState.selectedCharacter; + } + // Actions may or may not have motions and operators. Do these first. + if (command.operator) { + this.processOperator(cm, vim, command); + } + if (command.motion) { + this.processMotion(cm, vim, command); + } + if (command.motion || command.operator) { + this.evalInput(cm, vim); + } + actionArgs.repeat = repeat || 1; + actionArgs.repeatIsExplicit = repeatIsExplicit; + actionArgs.registerName = inputState.registerName; + clearInputState(cm); + vim.lastMotion = null; + if (command.isEdit) { + this.recordLastEdit(vim, inputState, command); + } + actions[command.action](cm, actionArgs, vim); + }, + processSearch: function(cm, vim, command) { + if (!cm.getSearchCursor) { + // Search depends on SearchCursor. + return; + } + var forward = command.searchArgs.forward; + var wholeWordOnly = command.searchArgs.wholeWordOnly; + getSearchState(cm).setReversed(!forward); + var promptPrefix = (forward) ? '/' : '?'; + var originalQuery = getSearchState(cm).getQuery(); + var originalScrollPos = cm.getScrollInfo(); + function handleQuery(query, ignoreCase, smartCase) { + vimGlobalState.searchHistoryController.pushInput(query); + vimGlobalState.searchHistoryController.reset(); + try { + updateSearchQuery(cm, query, ignoreCase, smartCase); + } catch (e) { + showConfirm(cm, 'Invalid regex: ' + query); + clearInputState(cm); + return; + } + commandDispatcher.processMotion(cm, vim, { + type: 'motion', + motion: 'findNext', + motionArgs: { forward: true, toJumplist: command.searchArgs.toJumplist } + }); + } + function onPromptClose(query) { + cm.scrollTo(originalScrollPos.left, originalScrollPos.top); + handleQuery(query, true /** ignoreCase */, true /** smartCase */); + var macroModeState = vimGlobalState.macroModeState; + if (macroModeState.isRecording) { + logSearchQuery(macroModeState, query); + } + } + function onPromptKeyUp(e, query, close) { + var keyName = CodeMirror.keyName(e), up; + if (keyName == 'Up' || keyName == 'Down') { + up = keyName == 'Up' ? true : false; + query = vimGlobalState.searchHistoryController.nextMatch(query, up) || ''; + close(query); + } else { + if ( keyName != 'Left' && keyName != 'Right' && keyName != 'Ctrl' && keyName != 'Alt' && keyName != 'Shift') + vimGlobalState.searchHistoryController.reset(); + } + var parsedQuery; + try { + parsedQuery = updateSearchQuery(cm, query, + true /** ignoreCase */, true /** smartCase */); + } catch (e) { + // Swallow bad regexes for incremental search. + } + if (parsedQuery) { + cm.scrollIntoView(findNext(cm, !forward, parsedQuery), 30); + } else { + clearSearchHighlight(cm); + cm.scrollTo(originalScrollPos.left, originalScrollPos.top); + } + } + function onPromptKeyDown(e, query, close) { + var keyName = CodeMirror.keyName(e); + if (keyName == 'Esc' || keyName == 'Ctrl-C' || keyName == 'Ctrl-[' || + (keyName == 'Backspace' && query == '')) { + vimGlobalState.searchHistoryController.pushInput(query); + vimGlobalState.searchHistoryController.reset(); + updateSearchQuery(cm, originalQuery); + clearSearchHighlight(cm); + cm.scrollTo(originalScrollPos.left, originalScrollPos.top); + CodeMirror.e_stop(e); + clearInputState(cm); + close(); + cm.focus(); + } else if (keyName == 'Ctrl-U') { + // Ctrl-U clears input. + CodeMirror.e_stop(e); + close(''); + } + } + switch (command.searchArgs.querySrc) { + case 'prompt': + var macroModeState = vimGlobalState.macroModeState; + if (macroModeState.isPlaying) { + var query = macroModeState.replaySearchQueries.shift(); + handleQuery(query, true /** ignoreCase */, false /** smartCase */); + } else { + showPrompt(cm, { + onClose: onPromptClose, + prefix: promptPrefix, + desc: searchPromptDesc, + onKeyUp: onPromptKeyUp, + onKeyDown: onPromptKeyDown + }); + } + break; + case 'wordUnderCursor': + var word = expandWordUnderCursor(cm, false /** inclusive */, + true /** forward */, false /** bigWord */, + true /** noSymbol */); + var isKeyword = true; + if (!word) { + word = expandWordUnderCursor(cm, false /** inclusive */, + true /** forward */, false /** bigWord */, + false /** noSymbol */); + isKeyword = false; + } + if (!word) { + return; + } + var query = cm.getLine(word.start.line).substring(word.start.ch, + word.end.ch); + if (isKeyword && wholeWordOnly) { + query = '\\b' + query + '\\b'; + } else { + query = escapeRegex(query); + } + + // cachedCursor is used to save the old position of the cursor + // when * or # causes vim to seek for the nearest word and shift + // the cursor before entering the motion. + vimGlobalState.jumpList.cachedCursor = cm.getCursor(); + cm.setCursor(word.start); + + handleQuery(query, true /** ignoreCase */, false /** smartCase */); + break; + } + }, + processEx: function(cm, vim, command) { + function onPromptClose(input) { + // Give the prompt some time to close so that if processCommand shows + // an error, the elements don't overlap. + vimGlobalState.exCommandHistoryController.pushInput(input); + vimGlobalState.exCommandHistoryController.reset(); + exCommandDispatcher.processCommand(cm, input); + } + function onPromptKeyDown(e, input, close) { + var keyName = CodeMirror.keyName(e), up; + if (keyName == 'Esc' || keyName == 'Ctrl-C' || keyName == 'Ctrl-[' || + (keyName == 'Backspace' && input == '')) { + vimGlobalState.exCommandHistoryController.pushInput(input); + vimGlobalState.exCommandHistoryController.reset(); + CodeMirror.e_stop(e); + clearInputState(cm); + close(); + cm.focus(); + } + if (keyName == 'Up' || keyName == 'Down') { + up = keyName == 'Up' ? true : false; + input = vimGlobalState.exCommandHistoryController.nextMatch(input, up) || ''; + close(input); + } else if (keyName == 'Ctrl-U') { + // Ctrl-U clears input. + CodeMirror.e_stop(e); + close(''); + } else { + if ( keyName != 'Left' && keyName != 'Right' && keyName != 'Ctrl' && keyName != 'Alt' && keyName != 'Shift') + vimGlobalState.exCommandHistoryController.reset(); + } + } + if (command.type == 'keyToEx') { + // Handle user defined Ex to Ex mappings + exCommandDispatcher.processCommand(cm, command.exArgs.input); + } else { + if (vim.visualMode) { + showPrompt(cm, { onClose: onPromptClose, prefix: ':', value: '\'<,\'>', + onKeyDown: onPromptKeyDown, select: false}); + } else { + showPrompt(cm, { onClose: onPromptClose, prefix: ':', + onKeyDown: onPromptKeyDown}); + } + } + }, + evalInput: function(cm, vim) { + // If the motion comand is set, execute both the operator and motion. + // Otherwise return. + var inputState = vim.inputState; + var motion = inputState.motion; + var motionArgs = inputState.motionArgs || {}; + var operator = inputState.operator; + var operatorArgs = inputState.operatorArgs || {}; + var registerName = inputState.registerName; + var sel = vim.sel; + // TODO: Make sure cm and vim selections are identical outside visual mode. + var origHead = copyCursor(vim.visualMode ? clipCursorToContent(cm, sel.head): cm.getCursor('head')); + var origAnchor = copyCursor(vim.visualMode ? clipCursorToContent(cm, sel.anchor) : cm.getCursor('anchor')); + var oldHead = copyCursor(origHead); + var oldAnchor = copyCursor(origAnchor); + var newHead, newAnchor; + var repeat; + if (operator) { + this.recordLastEdit(vim, inputState); + } + if (inputState.repeatOverride !== undefined) { + // If repeatOverride is specified, that takes precedence over the + // input state's repeat. Used by Ex mode and can be user defined. + repeat = inputState.repeatOverride; + } else { + repeat = inputState.getRepeat(); + } + if (repeat > 0 && motionArgs.explicitRepeat) { + motionArgs.repeatIsExplicit = true; + } else if (motionArgs.noRepeat || + (!motionArgs.explicitRepeat && repeat === 0)) { + repeat = 1; + motionArgs.repeatIsExplicit = false; + } + if (inputState.selectedCharacter) { + // If there is a character input, stick it in all of the arg arrays. + motionArgs.selectedCharacter = operatorArgs.selectedCharacter = + inputState.selectedCharacter; + } + motionArgs.repeat = repeat; + clearInputState(cm); + if (motion) { + var motionResult = motions[motion](cm, origHead, motionArgs, vim); + vim.lastMotion = motions[motion]; + if (!motionResult) { + return; + } + if (motionArgs.toJumplist) { + if (!operator) + cm.ace.curOp.command.scrollIntoView = "center-animate"; // ace patch + var jumpList = vimGlobalState.jumpList; + // if the current motion is # or *, use cachedCursor + var cachedCursor = jumpList.cachedCursor; + if (cachedCursor) { + recordJumpPosition(cm, cachedCursor, motionResult); + delete jumpList.cachedCursor; + } else { + recordJumpPosition(cm, origHead, motionResult); + } + } + if (motionResult instanceof Array) { + newAnchor = motionResult[0]; + newHead = motionResult[1]; + } else { + newHead = motionResult; + } + // TODO: Handle null returns from motion commands better. + if (!newHead) { + newHead = copyCursor(origHead); + } + if (vim.visualMode) { + if (!(vim.visualBlock && newHead.ch === Infinity)) { + newHead = clipCursorToContent(cm, newHead, vim.visualBlock); + } + if (newAnchor) { + newAnchor = clipCursorToContent(cm, newAnchor, true); + } + newAnchor = newAnchor || oldAnchor; + sel.anchor = newAnchor; + sel.head = newHead; + updateCmSelection(cm); + updateMark(cm, vim, '<', + cursorIsBefore(newAnchor, newHead) ? newAnchor + : newHead); + updateMark(cm, vim, '>', + cursorIsBefore(newAnchor, newHead) ? newHead + : newAnchor); + } else if (!operator) { + newHead = clipCursorToContent(cm, newHead); + cm.setCursor(newHead.line, newHead.ch); + } + } + if (operator) { + if (operatorArgs.lastSel) { + // Replaying a visual mode operation + newAnchor = oldAnchor; + var lastSel = operatorArgs.lastSel; + var lineOffset = Math.abs(lastSel.head.line - lastSel.anchor.line); + var chOffset = Math.abs(lastSel.head.ch - lastSel.anchor.ch); + if (lastSel.visualLine) { + // Linewise Visual mode: The same number of lines. + newHead = Pos(oldAnchor.line + lineOffset, oldAnchor.ch); + } else if (lastSel.visualBlock) { + // Blockwise Visual mode: The same number of lines and columns. + newHead = Pos(oldAnchor.line + lineOffset, oldAnchor.ch + chOffset); + } else if (lastSel.head.line == lastSel.anchor.line) { + // Normal Visual mode within one line: The same number of characters. + newHead = Pos(oldAnchor.line, oldAnchor.ch + chOffset); + } else { + // Normal Visual mode with several lines: The same number of lines, in the + // last line the same number of characters as in the last line the last time. + newHead = Pos(oldAnchor.line + lineOffset, oldAnchor.ch); + } + vim.visualMode = true; + vim.visualLine = lastSel.visualLine; + vim.visualBlock = lastSel.visualBlock; + sel = vim.sel = { + anchor: newAnchor, + head: newHead + }; + updateCmSelection(cm); + } else if (vim.visualMode) { + operatorArgs.lastSel = { + anchor: copyCursor(sel.anchor), + head: copyCursor(sel.head), + visualBlock: vim.visualBlock, + visualLine: vim.visualLine + }; + } + var curStart, curEnd, linewise, mode; + var cmSel; + if (vim.visualMode) { + // Init visual op + curStart = cursorMin(sel.head, sel.anchor); + curEnd = cursorMax(sel.head, sel.anchor); + linewise = vim.visualLine || operatorArgs.linewise; + mode = vim.visualBlock ? 'block' : + linewise ? 'line' : + 'char'; + cmSel = makeCmSelection(cm, { + anchor: curStart, + head: curEnd + }, mode); + if (linewise) { + var ranges = cmSel.ranges; + if (mode == 'block') { + // Linewise operators in visual block mode extend to end of line + for (var i = 0; i < ranges.length; i++) { + ranges[i].head.ch = lineLength(cm, ranges[i].head.line); + } + } else if (mode == 'line') { + ranges[0].head = Pos(ranges[0].head.line + 1, 0); + } + } + } else { + // Init motion op + curStart = copyCursor(newAnchor || oldAnchor); + curEnd = copyCursor(newHead || oldHead); + if (cursorIsBefore(curEnd, curStart)) { + var tmp = curStart; + curStart = curEnd; + curEnd = tmp; + } + linewise = motionArgs.linewise || operatorArgs.linewise; + if (linewise) { + // Expand selection to entire line. + expandSelectionToLine(cm, curStart, curEnd); + } else if (motionArgs.forward) { + // Clip to trailing newlines only if the motion goes forward. + clipToLine(cm, curStart, curEnd); + } + mode = 'char'; + var exclusive = !motionArgs.inclusive || linewise; + cmSel = makeCmSelection(cm, { + anchor: curStart, + head: curEnd + }, mode, exclusive); + } + cm.setSelections(cmSel.ranges, cmSel.primary); + vim.lastMotion = null; + operatorArgs.repeat = repeat; // For indent in visual mode. + operatorArgs.registerName = registerName; + // Keep track of linewise as it affects how paste and change behave. + operatorArgs.linewise = linewise; + var operatorMoveTo = operators[operator]( + cm, operatorArgs, cmSel.ranges, oldAnchor, newHead); + if (vim.visualMode) { + exitVisualMode(cm, operatorMoveTo != null); + } + if (operatorMoveTo) { + cm.setCursor(operatorMoveTo); + } + } + }, + recordLastEdit: function(vim, inputState, actionCommand) { + var macroModeState = vimGlobalState.macroModeState; + if (macroModeState.isPlaying) { return; } + vim.lastEditInputState = inputState; + vim.lastEditActionCommand = actionCommand; + macroModeState.lastInsertModeChanges.changes = []; + macroModeState.lastInsertModeChanges.expectCursorActivityForChange = false; + } + }; + + /** + * typedef {Object{line:number,ch:number}} Cursor An object containing the + * position of the cursor. + */ + // All of the functions below return Cursor objects. + var motions = { + moveToTopLine: function(cm, _head, motionArgs) { + var line = getUserVisibleLines(cm).top + motionArgs.repeat -1; + return Pos(line, findFirstNonWhiteSpaceCharacter(cm.getLine(line))); + }, + moveToMiddleLine: function(cm) { + var range = getUserVisibleLines(cm); + var line = Math.floor((range.top + range.bottom) * 0.5); + return Pos(line, findFirstNonWhiteSpaceCharacter(cm.getLine(line))); + }, + moveToBottomLine: function(cm, _head, motionArgs) { + var line = getUserVisibleLines(cm).bottom - motionArgs.repeat +1; + return Pos(line, findFirstNonWhiteSpaceCharacter(cm.getLine(line))); + }, + expandToLine: function(_cm, head, motionArgs) { + // Expands forward to end of line, and then to next line if repeat is + // >1. Does not handle backward motion! + var cur = head; + return Pos(cur.line + motionArgs.repeat - 1, Infinity); + }, + findNext: function(cm, _head, motionArgs) { + var state = getSearchState(cm); + var query = state.getQuery(); + if (!query) { + return; + } + var prev = !motionArgs.forward; + // If search is initiated with ? instead of /, negate direction. + prev = (state.isReversed()) ? !prev : prev; + highlightSearchMatches(cm, query); + return findNext(cm, prev/** prev */, query, motionArgs.repeat); + }, + goToMark: function(cm, _head, motionArgs, vim) { + var mark = vim.marks[motionArgs.selectedCharacter]; + if (mark) { + var pos = mark.find(); + return motionArgs.linewise ? { line: pos.line, ch: findFirstNonWhiteSpaceCharacter(cm.getLine(pos.line)) } : pos; + } + return null; + }, + moveToOtherHighlightedEnd: function(cm, _head, motionArgs, vim) { + if (vim.visualBlock && motionArgs.sameLine) { + var sel = vim.sel; + return [ + clipCursorToContent(cm, Pos(sel.anchor.line, sel.head.ch)), + clipCursorToContent(cm, Pos(sel.head.line, sel.anchor.ch)) + ]; + } else { + return ([vim.sel.head, vim.sel.anchor]); + } + }, + jumpToMark: function(cm, head, motionArgs, vim) { + var best = head; + for (var i = 0; i < motionArgs.repeat; i++) { + var cursor = best; + for (var key in vim.marks) { + if (!isLowerCase(key)) { + continue; + } + var mark = vim.marks[key].find(); + var isWrongDirection = (motionArgs.forward) ? + cursorIsBefore(mark, cursor) : cursorIsBefore(cursor, mark); + + if (isWrongDirection) { + continue; + } + if (motionArgs.linewise && (mark.line == cursor.line)) { + continue; + } + + var equal = cursorEqual(cursor, best); + var between = (motionArgs.forward) ? + cursorIsBetween(cursor, mark, best) : + cursorIsBetween(best, mark, cursor); + + if (equal || between) { + best = mark; + } + } + } + + if (motionArgs.linewise) { + // Vim places the cursor on the first non-whitespace character of + // the line if there is one, else it places the cursor at the end + // of the line, regardless of whether a mark was found. + best = Pos(best.line, findFirstNonWhiteSpaceCharacter(cm.getLine(best.line))); + } + return best; + }, + moveByCharacters: function(_cm, head, motionArgs) { + var cur = head; + var repeat = motionArgs.repeat; + var ch = motionArgs.forward ? cur.ch + repeat : cur.ch - repeat; + return Pos(cur.line, ch); + }, + moveByLines: function(cm, head, motionArgs, vim) { + var cur = head; + var endCh = cur.ch; + // Depending what our last motion was, we may want to do different + // things. If our last motion was moving vertically, we want to + // preserve the HPos from our last horizontal move. If our last motion + // was going to the end of a line, moving vertically we should go to + // the end of the line, etc. + switch (vim.lastMotion) { + case this.moveByLines: + case this.moveByDisplayLines: + case this.moveByScroll: + case this.moveToColumn: + case this.moveToEol: + endCh = vim.lastHPos; + break; + default: + vim.lastHPos = endCh; + } + var repeat = motionArgs.repeat+(motionArgs.repeatOffset||0); + var line = motionArgs.forward ? cur.line + repeat : cur.line - repeat; + var first = cm.firstLine(); + var last = cm.lastLine(); + // Vim cancels linewise motions that start on an edge and move beyond + // that edge. It does not cancel motions that do not start on an edge. + if ((line < first && cur.line == first) || + (line > last && cur.line == last)) { + return; + } + // /ace patch + var fold = cm.ace.session.getFoldAt(line, endCh); + if (fold) { + if (motionArgs.forward) + line = fold.end.row + 1; + else + line = fold.start.row - 1; + } + // /ace patche + if (motionArgs.toFirstChar){ + endCh=findFirstNonWhiteSpaceCharacter(cm.getLine(line)); + vim.lastHPos = endCh; + } + vim.lastHSPos = cm.charCoords(Pos(line, endCh),'div').left; + return Pos(line, endCh); + }, + moveByDisplayLines: function(cm, head, motionArgs, vim) { + var cur = head; + switch (vim.lastMotion) { + case this.moveByDisplayLines: + case this.moveByScroll: + case this.moveByLines: + case this.moveToColumn: + case this.moveToEol: + break; + default: + vim.lastHSPos = cm.charCoords(cur,'div').left; + } + var repeat = motionArgs.repeat; + var res=cm.findPosV(cur,(motionArgs.forward ? repeat : -repeat),'line',vim.lastHSPos); + if (res.hitSide) { + if (motionArgs.forward) { + var lastCharCoords = cm.charCoords(res, 'div'); + var goalCoords = { top: lastCharCoords.top + 8, left: vim.lastHSPos }; + var res = cm.coordsChar(goalCoords, 'div'); + } else { + var resCoords = cm.charCoords(Pos(cm.firstLine(), 0), 'div'); + resCoords.left = vim.lastHSPos; + res = cm.coordsChar(resCoords, 'div'); + } + } + vim.lastHPos = res.ch; + return res; + }, + moveByPage: function(cm, head, motionArgs) { + // CodeMirror only exposes functions that move the cursor page down, so + // doing this bad hack to move the cursor and move it back. evalInput + // will move the cursor to where it should be in the end. + var curStart = head; + var repeat = motionArgs.repeat; + return cm.findPosV(curStart, (motionArgs.forward ? repeat : -repeat), 'page'); + }, + moveByParagraph: function(cm, head, motionArgs) { + var dir = motionArgs.forward ? 1 : -1; + return findParagraph(cm, head, motionArgs.repeat, dir); + }, + moveByScroll: function(cm, head, motionArgs, vim) { + var scrollbox = cm.getScrollInfo(); + var curEnd = null; + var repeat = motionArgs.repeat; + if (!repeat) { + repeat = scrollbox.clientHeight / (2 * cm.defaultTextHeight()); + } + var orig = cm.charCoords(head, 'local'); + motionArgs.repeat = repeat; + var curEnd = motions.moveByDisplayLines(cm, head, motionArgs, vim); + if (!curEnd) { + return null; + } + var dest = cm.charCoords(curEnd, 'local'); + cm.scrollTo(null, scrollbox.top + dest.top - orig.top); + return curEnd; + }, + moveByWords: function(cm, head, motionArgs) { + return moveToWord(cm, head, motionArgs.repeat, !!motionArgs.forward, + !!motionArgs.wordEnd, !!motionArgs.bigWord); + }, + moveTillCharacter: function(cm, _head, motionArgs) { + var repeat = motionArgs.repeat; + var curEnd = moveToCharacter(cm, repeat, motionArgs.forward, + motionArgs.selectedCharacter); + var increment = motionArgs.forward ? -1 : 1; + recordLastCharacterSearch(increment, motionArgs); + if (!curEnd) return null; + curEnd.ch += increment; + return curEnd; + }, + moveToCharacter: function(cm, head, motionArgs) { + var repeat = motionArgs.repeat; + recordLastCharacterSearch(0, motionArgs); + return moveToCharacter(cm, repeat, motionArgs.forward, + motionArgs.selectedCharacter) || head; + }, + moveToSymbol: function(cm, head, motionArgs) { + var repeat = motionArgs.repeat; + return findSymbol(cm, repeat, motionArgs.forward, + motionArgs.selectedCharacter) || head; + }, + moveToColumn: function(cm, head, motionArgs, vim) { + var repeat = motionArgs.repeat; + // repeat is equivalent to which column we want to move to! + vim.lastHPos = repeat - 1; + vim.lastHSPos = cm.charCoords(head,'div').left; + return moveToColumn(cm, repeat); + }, + moveToEol: function(cm, head, motionArgs, vim) { + var cur = head; + vim.lastHPos = Infinity; + var retval= Pos(cur.line + motionArgs.repeat - 1, Infinity); + var end=cm.clipPos(retval); + end.ch--; + vim.lastHSPos = cm.charCoords(end,'div').left; + return retval; + }, + moveToFirstNonWhiteSpaceCharacter: function(cm, head) { + // Go to the start of the line where the text begins, or the end for + // whitespace-only lines + var cursor = head; + return Pos(cursor.line, + findFirstNonWhiteSpaceCharacter(cm.getLine(cursor.line))); + }, + moveToMatchedSymbol: function(cm, head) { + var cursor = head; + var line = cursor.line; + var ch = cursor.ch; + var lineText = cm.getLine(line); + var symbol; + do { + symbol = lineText.charAt(ch++); + if (symbol && isMatchableSymbol(symbol)) { + var style = cm.getTokenTypeAt(Pos(line, ch)); + if (style !== "string" && style !== "comment") { + break; + } + } + } while (symbol); + if (symbol) { + var matched = cm.findMatchingBracket(Pos(line, ch)); + return matched.to; + } else { + return cursor; + } + }, + moveToStartOfLine: function(_cm, head) { + return Pos(head.line, 0); + }, + moveToLineOrEdgeOfDocument: function(cm, _head, motionArgs) { + var lineNum = motionArgs.forward ? cm.lastLine() : cm.firstLine(); + if (motionArgs.repeatIsExplicit) { + lineNum = motionArgs.repeat - cm.getOption('firstLineNumber'); + } + return Pos(lineNum, + findFirstNonWhiteSpaceCharacter(cm.getLine(lineNum))); + }, + textObjectManipulation: function(cm, head, motionArgs, vim) { + // TODO: lots of possible exceptions that can be thrown here. Try da( + // outside of a () block. + + // TODO: adding <> >< to this map doesn't work, presumably because + // they're operators + var mirroredPairs = {'(': ')', ')': '(', + '{': '}', '}': '{', + '[': ']', ']': '['}; + var selfPaired = {'\'': true, '"': true}; + + var character = motionArgs.selectedCharacter; + // 'b' refers to '()' block. + // 'B' refers to '{}' block. + if (character == 'b') { + character = '('; + } else if (character == 'B') { + character = '{'; + } + + // Inclusive is the difference between a and i + // TODO: Instead of using the additional text object map to perform text + // object operations, merge the map into the defaultKeyMap and use + // motionArgs to define behavior. Define separate entries for 'aw', + // 'iw', 'a[', 'i[', etc. + var inclusive = !motionArgs.textObjectInner; + + var tmp; + if (mirroredPairs[character]) { + tmp = selectCompanionObject(cm, head, character, inclusive); + } else if (selfPaired[character]) { + tmp = findBeginningAndEnd(cm, head, character, inclusive); + } else if (character === 'W') { + tmp = expandWordUnderCursor(cm, inclusive, true /** forward */, + true /** bigWord */); + } else if (character === 'w') { + tmp = expandWordUnderCursor(cm, inclusive, true /** forward */, + false /** bigWord */); + } else if (character === 'p') { + tmp = findParagraph(cm, head, motionArgs.repeat, 0, inclusive); + motionArgs.linewise = true; + if (vim.visualMode) { + if (!vim.visualLine) { vim.visualLine = true; } + } else { + var operatorArgs = vim.inputState.operatorArgs; + if (operatorArgs) { operatorArgs.linewise = true; } + tmp.end.line--; + } + } else { + // No text object defined for this, don't move. + return null; + } + + if (!cm.state.vim.visualMode) { + return [tmp.start, tmp.end]; + } else { + return expandSelection(cm, tmp.start, tmp.end); + } + }, + + repeatLastCharacterSearch: function(cm, head, motionArgs) { + var lastSearch = vimGlobalState.lastChararacterSearch; + var repeat = motionArgs.repeat; + var forward = motionArgs.forward === lastSearch.forward; + var increment = (lastSearch.increment ? 1 : 0) * (forward ? -1 : 1); + cm.moveH(-increment, 'char'); + motionArgs.inclusive = forward ? true : false; + var curEnd = moveToCharacter(cm, repeat, forward, lastSearch.selectedCharacter); + if (!curEnd) { + cm.moveH(increment, 'char'); + return head; + } + curEnd.ch += increment; + return curEnd; + } + }; + + function defineMotion(name, fn) { + motions[name] = fn; + } + + function fillArray(val, times) { + var arr = []; + for (var i = 0; i < times; i++) { + arr.push(val); + } + return arr; + } + /** + * An operator acts on a text selection. It receives the list of selections + * as input. The corresponding CodeMirror selection is guaranteed to + * match the input selection. + */ + var operators = { + change: function(cm, args, ranges) { + var finalHead, text; + var vim = cm.state.vim; + vimGlobalState.macroModeState.lastInsertModeChanges.inVisualBlock = vim.visualBlock; + if (!vim.visualMode) { + var anchor = ranges[0].anchor, + head = ranges[0].head; + text = cm.getRange(anchor, head); + var lastState = vim.lastEditInputState || {}; + if (lastState.motion == "moveByWords" && !isWhiteSpaceString(text)) { + // Exclude trailing whitespace if the range is not all whitespace. + var match = (/\s+$/).exec(text); + if (match && lastState.motionArgs && lastState.motionArgs.forward) { + head = offsetCursor(head, 0, - match[0].length); + text = text.slice(0, - match[0].length); + } + } + var wasLastLine = head.line - 1 == cm.lastLine(); + cm.replaceRange('', anchor, head); + if (args.linewise && !wasLastLine) { + // Push the next line back down, if there is a next line. + CodeMirror.commands.newlineAndIndent(cm); + // null ch so setCursor moves to end of line. + anchor.ch = null; + } + finalHead = anchor; + } else { + text = cm.getSelection(); + var replacement = fillArray('', ranges.length); + cm.replaceSelections(replacement); + finalHead = cursorMin(ranges[0].head, ranges[0].anchor); + } + vimGlobalState.registerController.pushText( + args.registerName, 'change', text, + args.linewise, ranges.length > 1); + actions.enterInsertMode(cm, {head: finalHead}, cm.state.vim); + }, + // delete is a javascript keyword. + 'delete': function(cm, args, ranges) { + var finalHead, text; + var vim = cm.state.vim; + if (!vim.visualBlock) { + var anchor = ranges[0].anchor, + head = ranges[0].head; + if (args.linewise && + head.line != cm.firstLine() && + anchor.line == cm.lastLine() && + anchor.line == head.line - 1) { + // Special case for dd on last line (and first line). + if (anchor.line == cm.firstLine()) { + anchor.ch = 0; + } else { + anchor = Pos(anchor.line - 1, lineLength(cm, anchor.line - 1)); + } + } + text = cm.getRange(anchor, head); + cm.replaceRange('', anchor, head); + finalHead = anchor; + if (args.linewise) { + finalHead = motions.moveToFirstNonWhiteSpaceCharacter(cm, anchor); + } + } else { + text = cm.getSelection(); + var replacement = fillArray('', ranges.length); + cm.replaceSelections(replacement); + finalHead = ranges[0].anchor; + } + vimGlobalState.registerController.pushText( + args.registerName, 'delete', text, + args.linewise, vim.visualBlock); + return clipCursorToContent(cm, finalHead); + }, + indent: function(cm, args, ranges) { + var vim = cm.state.vim; + var startLine = ranges[0].anchor.line; + var endLine = vim.visualBlock ? + ranges[ranges.length - 1].anchor.line : + ranges[0].head.line; + // In visual mode, n> shifts the selection right n times, instead of + // shifting n lines right once. + var repeat = (vim.visualMode) ? args.repeat : 1; + if (args.linewise) { + // The only way to delete a newline is to delete until the start of + // the next line, so in linewise mode evalInput will include the next + // line. We don't want this in indent, so we go back a line. + endLine--; + } + for (var i = startLine; i <= endLine; i++) { + for (var j = 0; j < repeat; j++) { + cm.indentLine(i, args.indentRight); + } + } + return motions.moveToFirstNonWhiteSpaceCharacter(cm, ranges[0].anchor); + }, + changeCase: function(cm, args, ranges, oldAnchor, newHead) { + var selections = cm.getSelections(); + var swapped = []; + var toLower = args.toLower; + for (var j = 0; j < selections.length; j++) { + var toSwap = selections[j]; + var text = ''; + if (toLower === true) { + text = toSwap.toLowerCase(); + } else if (toLower === false) { + text = toSwap.toUpperCase(); + } else { + for (var i = 0; i < toSwap.length; i++) { + var character = toSwap.charAt(i); + text += isUpperCase(character) ? character.toLowerCase() : + character.toUpperCase(); + } + } + swapped.push(text); + } + cm.replaceSelections(swapped); + if (args.shouldMoveCursor){ + return newHead; + } else if (!cm.state.vim.visualMode && args.linewise && ranges[0].anchor.line + 1 == ranges[0].head.line) { + return motions.moveToFirstNonWhiteSpaceCharacter(cm, oldAnchor); + } else if (args.linewise){ + return oldAnchor; + } else { + return cursorMin(ranges[0].anchor, ranges[0].head); + } + }, + yank: function(cm, args, ranges, oldAnchor) { + var vim = cm.state.vim; + var text = cm.getSelection(); + var endPos = vim.visualMode + ? cursorMin(vim.sel.anchor, vim.sel.head, ranges[0].head, ranges[0].anchor) + : oldAnchor; + vimGlobalState.registerController.pushText( + args.registerName, 'yank', + text, args.linewise, vim.visualBlock); + return endPos; + } + }; + + function defineOperator(name, fn) { + operators[name] = fn; + } + + var actions = { + jumpListWalk: function(cm, actionArgs, vim) { + if (vim.visualMode) { + return; + } + var repeat = actionArgs.repeat; + var forward = actionArgs.forward; + var jumpList = vimGlobalState.jumpList; + + var mark = jumpList.move(cm, forward ? repeat : -repeat); + var markPos = mark ? mark.find() : undefined; + markPos = markPos ? markPos : cm.getCursor(); + cm.setCursor(markPos); + cm.ace.curOp.command.scrollIntoView = "center-animate"; // ace patch + }, + scroll: function(cm, actionArgs, vim) { + if (vim.visualMode) { + return; + } + var repeat = actionArgs.repeat || 1; + var lineHeight = cm.defaultTextHeight(); + var top = cm.getScrollInfo().top; + var delta = lineHeight * repeat; + var newPos = actionArgs.forward ? top + delta : top - delta; + var cursor = copyCursor(cm.getCursor()); + var cursorCoords = cm.charCoords(cursor, 'local'); + if (actionArgs.forward) { + if (newPos > cursorCoords.top) { + cursor.line += (newPos - cursorCoords.top) / lineHeight; + cursor.line = Math.ceil(cursor.line); + cm.setCursor(cursor); + cursorCoords = cm.charCoords(cursor, 'local'); + cm.scrollTo(null, cursorCoords.top); + } else { + // Cursor stays within bounds. Just reposition the scroll window. + cm.scrollTo(null, newPos); + } + } else { + var newBottom = newPos + cm.getScrollInfo().clientHeight; + if (newBottom < cursorCoords.bottom) { + cursor.line -= (cursorCoords.bottom - newBottom) / lineHeight; + cursor.line = Math.floor(cursor.line); + cm.setCursor(cursor); + cursorCoords = cm.charCoords(cursor, 'local'); + cm.scrollTo( + null, cursorCoords.bottom - cm.getScrollInfo().clientHeight); + } else { + // Cursor stays within bounds. Just reposition the scroll window. + cm.scrollTo(null, newPos); + } + } + }, + scrollToCursor: function(cm, actionArgs) { + var lineNum = cm.getCursor().line; + var charCoords = cm.charCoords(Pos(lineNum, 0), 'local'); + var height = cm.getScrollInfo().clientHeight; + var y = charCoords.top; + var lineHeight = charCoords.bottom - y; + switch (actionArgs.position) { + case 'center': y = y - (height / 2) + lineHeight; + break; + case 'bottom': y = y - height + lineHeight*1.4; + break; + case 'top': y = y + lineHeight*0.4; + break; + } + cm.scrollTo(null, y); + }, + replayMacro: function(cm, actionArgs, vim) { + var registerName = actionArgs.selectedCharacter; + var repeat = actionArgs.repeat; + var macroModeState = vimGlobalState.macroModeState; + if (registerName == '@') { + registerName = macroModeState.latestRegister; + } + while(repeat--){ + executeMacroRegister(cm, vim, macroModeState, registerName); + } + }, + enterMacroRecordMode: function(cm, actionArgs) { + var macroModeState = vimGlobalState.macroModeState; + var registerName = actionArgs.selectedCharacter; + macroModeState.enterMacroRecordMode(cm, registerName); + }, + enterInsertMode: function(cm, actionArgs, vim) { + if (cm.getOption('readOnly')) { return; } + vim.insertMode = true; + vim.insertModeRepeat = actionArgs && actionArgs.repeat || 1; + var insertAt = (actionArgs) ? actionArgs.insertAt : null; + var sel = vim.sel; + var head = actionArgs.head || cm.getCursor('head'); + var height = cm.listSelections().length; + if (insertAt == 'eol') { + head = Pos(head.line, lineLength(cm, head.line)); + } else if (insertAt == 'charAfter') { + head = offsetCursor(head, 0, 1); + } else if (insertAt == 'firstNonBlank') { + head = motions.moveToFirstNonWhiteSpaceCharacter(cm, head); + } else if (insertAt == 'startOfSelectedArea') { + if (!vim.visualBlock) { + if (sel.head.line < sel.anchor.line) { + head = sel.head; + } else { + head = Pos(sel.anchor.line, 0); + } + } else { + head = Pos( + Math.min(sel.head.line, sel.anchor.line), + Math.min(sel.head.ch, sel.anchor.ch)); + height = Math.abs(sel.head.line - sel.anchor.line) + 1; + } + } else if (insertAt == 'endOfSelectedArea') { + if (!vim.visualBlock) { + if (sel.head.line >= sel.anchor.line) { + head = offsetCursor(sel.head, 0, 1); + } else { + head = Pos(sel.anchor.line, 0); + } + } else { + head = Pos( + Math.min(sel.head.line, sel.anchor.line), + Math.max(sel.head.ch + 1, sel.anchor.ch)); + height = Math.abs(sel.head.line - sel.anchor.line) + 1; + } + } else if (insertAt == 'inplace') { + if (vim.visualMode){ + return; + } + } + cm.setOption('keyMap', 'vim-insert'); + cm.setOption('disableInput', false); + if (actionArgs && actionArgs.replace) { + // Handle Replace-mode as a special case of insert mode. + cm.toggleOverwrite(true); + cm.setOption('keyMap', 'vim-replace'); + CodeMirror.signal(cm, "vim-mode-change", {mode: "replace"}); + } else { + cm.setOption('keyMap', 'vim-insert'); + CodeMirror.signal(cm, "vim-mode-change", {mode: "insert"}); + } + if (!vimGlobalState.macroModeState.isPlaying) { + // Only record if not replaying. + cm.on('change', onChange); + CodeMirror.on(cm.getInputField(), 'keydown', onKeyEventTargetKeyDown); + } + if (vim.visualMode) { + exitVisualMode(cm); + } + selectForInsert(cm, head, height); + }, + toggleVisualMode: function(cm, actionArgs, vim) { + var repeat = actionArgs.repeat; + var anchor = cm.getCursor(); + var head; + // TODO: The repeat should actually select number of characters/lines + // equal to the repeat times the size of the previous visual + // operation. + if (!vim.visualMode) { + // Entering visual mode + vim.visualMode = true; + vim.visualLine = !!actionArgs.linewise; + vim.visualBlock = !!actionArgs.blockwise; + head = clipCursorToContent( + cm, Pos(anchor.line, anchor.ch + repeat - 1), + true /** includeLineBreak */); + vim.sel = { + anchor: anchor, + head: head + }; + CodeMirror.signal(cm, "vim-mode-change", {mode: "visual", subMode: vim.visualLine ? "linewise" : vim.visualBlock ? "blockwise" : ""}); + updateCmSelection(cm); + updateMark(cm, vim, '<', cursorMin(anchor, head)); + updateMark(cm, vim, '>', cursorMax(anchor, head)); + } else if (vim.visualLine ^ actionArgs.linewise || + vim.visualBlock ^ actionArgs.blockwise) { + // Toggling between modes + vim.visualLine = !!actionArgs.linewise; + vim.visualBlock = !!actionArgs.blockwise; + CodeMirror.signal(cm, "vim-mode-change", {mode: "visual", subMode: vim.visualLine ? "linewise" : vim.visualBlock ? "blockwise" : ""}); + updateCmSelection(cm); + } else { + exitVisualMode(cm); + } + }, + reselectLastSelection: function(cm, _actionArgs, vim) { + var lastSelection = vim.lastSelection; + if (vim.visualMode) { + updateLastSelection(cm, vim); + } + if (lastSelection) { + var anchor = lastSelection.anchorMark.find(); + var head = lastSelection.headMark.find(); + if (!anchor || !head) { + // If the marks have been destroyed due to edits, do nothing. + return; + } + vim.sel = { + anchor: anchor, + head: head + }; + vim.visualMode = true; + vim.visualLine = lastSelection.visualLine; + vim.visualBlock = lastSelection.visualBlock; + updateCmSelection(cm); + updateMark(cm, vim, '<', cursorMin(anchor, head)); + updateMark(cm, vim, '>', cursorMax(anchor, head)); + CodeMirror.signal(cm, 'vim-mode-change', { + mode: 'visual', + subMode: vim.visualLine ? 'linewise' : + vim.visualBlock ? 'blockwise' : ''}); + } + }, + joinLines: function(cm, actionArgs, vim) { + var curStart, curEnd; + if (vim.visualMode) { + curStart = cm.getCursor('anchor'); + curEnd = cm.getCursor('head'); + if (cursorIsBefore(curEnd, curStart)) { + var tmp = curEnd; + curEnd = curStart; + curStart = tmp; + } + curEnd.ch = lineLength(cm, curEnd.line) - 1; + } else { + // Repeat is the number of lines to join. Minimum 2 lines. + var repeat = Math.max(actionArgs.repeat, 2); + curStart = cm.getCursor(); + curEnd = clipCursorToContent(cm, Pos(curStart.line + repeat - 1, + Infinity)); + } + var finalCh = 0; + for (var i = curStart.line; i < curEnd.line; i++) { + finalCh = lineLength(cm, curStart.line); + var tmp = Pos(curStart.line + 1, + lineLength(cm, curStart.line + 1)); + var text = cm.getRange(curStart, tmp); + text = text.replace(/\n\s*/g, ' '); + cm.replaceRange(text, curStart, tmp); + } + var curFinalPos = Pos(curStart.line, finalCh); + if (vim.visualMode) { + exitVisualMode(cm, false); + } + cm.setCursor(curFinalPos); + }, + newLineAndEnterInsertMode: function(cm, actionArgs, vim) { + vim.insertMode = true; + var insertAt = copyCursor(cm.getCursor()); + if (insertAt.line === cm.firstLine() && !actionArgs.after) { + // Special case for inserting newline before start of document. + cm.replaceRange('\n', Pos(cm.firstLine(), 0)); + cm.setCursor(cm.firstLine(), 0); + } else { + insertAt.line = (actionArgs.after) ? insertAt.line : + insertAt.line - 1; + insertAt.ch = lineLength(cm, insertAt.line); + cm.setCursor(insertAt); + var newlineFn = CodeMirror.commands.newlineAndIndentContinueComment || + CodeMirror.commands.newlineAndIndent; + newlineFn(cm); + } + this.enterInsertMode(cm, { repeat: actionArgs.repeat }, vim); + }, + paste: function(cm, actionArgs, vim) { + var cur = copyCursor(cm.getCursor()); + var register = vimGlobalState.registerController.getRegister( + actionArgs.registerName); + var text = register.toString(); + if (!text) { + return; + } + if (actionArgs.matchIndent) { + var tabSize = cm.getOption("tabSize"); + // length that considers tabs and tabSize + var whitespaceLength = function(str) { + var tabs = (str.split("\t").length - 1); + var spaces = (str.split(" ").length - 1); + return tabs * tabSize + spaces * 1; + }; + var currentLine = cm.getLine(cm.getCursor().line); + var indent = whitespaceLength(currentLine.match(/^\s*/)[0]); + // chomp last newline b/c don't want it to match /^\s*/gm + var chompedText = text.replace(/\n$/, ''); + var wasChomped = text !== chompedText; + var firstIndent = whitespaceLength(text.match(/^\s*/)[0]); + var text = chompedText.replace(/^\s*/gm, function(wspace) { + var newIndent = indent + (whitespaceLength(wspace) - firstIndent); + if (newIndent < 0) { + return ""; + } + else if (cm.getOption("indentWithTabs")) { + var quotient = Math.floor(newIndent / tabSize); + return Array(quotient + 1).join('\t'); + } + else { + return Array(newIndent + 1).join(' '); + } + }); + text += wasChomped ? "\n" : ""; + } + if (actionArgs.repeat > 1) { + var text = Array(actionArgs.repeat + 1).join(text); + } + var linewise = register.linewise; + var blockwise = register.blockwise; + if (linewise) { + if(vim.visualMode) { + text = vim.visualLine ? text.slice(0, -1) : '\n' + text.slice(0, text.length - 1) + '\n'; + } else if (actionArgs.after) { + // Move the newline at the end to the start instead, and paste just + // before the newline character of the line we are on right now. + text = '\n' + text.slice(0, text.length - 1); + cur.ch = lineLength(cm, cur.line); + } else { + cur.ch = 0; + } + } else { + if (blockwise) { + text = text.split('\n'); + for (var i = 0; i < text.length; i++) { + text[i] = (text[i] == '') ? ' ' : text[i]; + } + } + cur.ch += actionArgs.after ? 1 : 0; + } + var curPosFinal; + var idx; + if (vim.visualMode) { + // save the pasted text for reselection if the need arises + vim.lastPastedText = text; + var lastSelectionCurEnd; + var selectedArea = getSelectedAreaRange(cm, vim); + var selectionStart = selectedArea[0]; + var selectionEnd = selectedArea[1]; + var selectedText = cm.getSelection(); + var selections = cm.listSelections(); + var emptyStrings = new Array(selections.length).join('1').split('1'); + // save the curEnd marker before it get cleared due to cm.replaceRange. + if (vim.lastSelection) { + lastSelectionCurEnd = vim.lastSelection.headMark.find(); + } + // push the previously selected text to unnamed register + vimGlobalState.registerController.unnamedRegister.setText(selectedText); + if (blockwise) { + // first delete the selected text + cm.replaceSelections(emptyStrings); + // Set new selections as per the block length of the yanked text + selectionEnd = Pos(selectionStart.line + text.length-1, selectionStart.ch); + cm.setCursor(selectionStart); + selectBlock(cm, selectionEnd); + cm.replaceSelections(text); + curPosFinal = selectionStart; + } else if (vim.visualBlock) { + cm.replaceSelections(emptyStrings); + cm.setCursor(selectionStart); + cm.replaceRange(text, selectionStart, selectionStart); + curPosFinal = selectionStart; + } else { + cm.replaceRange(text, selectionStart, selectionEnd); + curPosFinal = cm.posFromIndex(cm.indexFromPos(selectionStart) + text.length - 1); + } + // restore the the curEnd marker + if(lastSelectionCurEnd) { + vim.lastSelection.headMark = cm.setBookmark(lastSelectionCurEnd); + } + if (linewise) { + curPosFinal.ch=0; + } + } else { + if (blockwise) { + cm.setCursor(cur); + for (var i = 0; i < text.length; i++) { + var line = cur.line+i; + if (line > cm.lastLine()) { + cm.replaceRange('\n', Pos(line, 0)); + } + var lastCh = lineLength(cm, line); + if (lastCh < cur.ch) { + extendLineToColumn(cm, line, cur.ch); + } + } + cm.setCursor(cur); + selectBlock(cm, Pos(cur.line + text.length-1, cur.ch)); + cm.replaceSelections(text); + curPosFinal = cur; + } else { + cm.replaceRange(text, cur); + // Now fine tune the cursor to where we want it. + if (linewise && actionArgs.after) { + curPosFinal = Pos( + cur.line + 1, + findFirstNonWhiteSpaceCharacter(cm.getLine(cur.line + 1))); + } else if (linewise && !actionArgs.after) { + curPosFinal = Pos( + cur.line, + findFirstNonWhiteSpaceCharacter(cm.getLine(cur.line))); + } else if (!linewise && actionArgs.after) { + idx = cm.indexFromPos(cur); + curPosFinal = cm.posFromIndex(idx + text.length - 1); + } else { + idx = cm.indexFromPos(cur); + curPosFinal = cm.posFromIndex(idx + text.length); + } + } + } + if (vim.visualMode) { + exitVisualMode(cm, false); + } + cm.setCursor(curPosFinal); + }, + undo: function(cm, actionArgs) { + cm.operation(function() { + repeatFn(cm, CodeMirror.commands.undo, actionArgs.repeat)(); + cm.setCursor(cm.getCursor('anchor')); + }); + }, + redo: function(cm, actionArgs) { + repeatFn(cm, CodeMirror.commands.redo, actionArgs.repeat)(); + }, + setRegister: function(_cm, actionArgs, vim) { + vim.inputState.registerName = actionArgs.selectedCharacter; + }, + setMark: function(cm, actionArgs, vim) { + var markName = actionArgs.selectedCharacter; + updateMark(cm, vim, markName, cm.getCursor()); + }, + replace: function(cm, actionArgs, vim) { + var replaceWith = actionArgs.selectedCharacter; + var curStart = cm.getCursor(); + var replaceTo; + var curEnd; + var selections = cm.listSelections(); + if (vim.visualMode) { + curStart = cm.getCursor('start'); + curEnd = cm.getCursor('end'); + } else { + var line = cm.getLine(curStart.line); + replaceTo = curStart.ch + actionArgs.repeat; + if (replaceTo > line.length) { + replaceTo=line.length; + } + curEnd = Pos(curStart.line, replaceTo); + } + if (replaceWith=='\n') { + if (!vim.visualMode) cm.replaceRange('', curStart, curEnd); + // special case, where vim help says to replace by just one line-break + (CodeMirror.commands.newlineAndIndentContinueComment || CodeMirror.commands.newlineAndIndent)(cm); + } else { + var replaceWithStr = cm.getRange(curStart, curEnd); + //replace all characters in range by selected, but keep linebreaks + replaceWithStr = replaceWithStr.replace(/[^\n]/g, replaceWith); + if (vim.visualBlock) { + // Tabs are split in visua block before replacing + var spaces = new Array(cm.getOption("tabSize")+1).join(' '); + replaceWithStr = cm.getSelection(); + replaceWithStr = replaceWithStr.replace(/\t/g, spaces).replace(/[^\n]/g, replaceWith).split('\n'); + cm.replaceSelections(replaceWithStr); + } else { + cm.replaceRange(replaceWithStr, curStart, curEnd); + } + if (vim.visualMode) { + curStart = cursorIsBefore(selections[0].anchor, selections[0].head) ? + selections[0].anchor : selections[0].head; + cm.setCursor(curStart); + exitVisualMode(cm, false); + } else { + cm.setCursor(offsetCursor(curEnd, 0, -1)); + } + } + }, + incrementNumberToken: function(cm, actionArgs) { + var cur = cm.getCursor(); + var lineStr = cm.getLine(cur.line); + var re = /-?\d+/g; + var match; + var start; + var end; + var numberStr; + var token; + while ((match = re.exec(lineStr)) !== null) { + token = match[0]; + start = match.index; + end = start + token.length; + if (cur.ch < end)break; + } + if (!actionArgs.backtrack && (end <= cur.ch))return; + if (token) { + var increment = actionArgs.increase ? 1 : -1; + var number = parseInt(token) + (increment * actionArgs.repeat); + var from = Pos(cur.line, start); + var to = Pos(cur.line, end); + numberStr = number.toString(); + cm.replaceRange(numberStr, from, to); + } else { + return; + } + cm.setCursor(Pos(cur.line, start + numberStr.length - 1)); + }, + repeatLastEdit: function(cm, actionArgs, vim) { + var lastEditInputState = vim.lastEditInputState; + if (!lastEditInputState) { return; } + var repeat = actionArgs.repeat; + if (repeat && actionArgs.repeatIsExplicit) { + vim.lastEditInputState.repeatOverride = repeat; + } else { + repeat = vim.lastEditInputState.repeatOverride || repeat; + } + repeatLastEdit(cm, vim, repeat, false /** repeatForInsert */); + }, + exitInsertMode: exitInsertMode + }; + + function defineAction(name, fn) { + actions[name] = fn; + } + + /* + * Below are miscellaneous utility functions used by vim.js + */ + + /** + * Clips cursor to ensure that line is within the buffer's range + * If includeLineBreak is true, then allow cur.ch == lineLength. + */ + function clipCursorToContent(cm, cur, includeLineBreak) { + var line = Math.min(Math.max(cm.firstLine(), cur.line), cm.lastLine() ); + var maxCh = lineLength(cm, line) - 1; + maxCh = (includeLineBreak) ? maxCh + 1 : maxCh; + var ch = Math.min(Math.max(0, cur.ch), maxCh); + return Pos(line, ch); + } + function copyArgs(args) { + var ret = {}; + for (var prop in args) { + if (args.hasOwnProperty(prop)) { + ret[prop] = args[prop]; + } + } + return ret; + } + function offsetCursor(cur, offsetLine, offsetCh) { + if (typeof offsetLine === 'object') { + offsetCh = offsetLine.ch; + offsetLine = offsetLine.line; + } + return Pos(cur.line + offsetLine, cur.ch + offsetCh); + } + function getOffset(anchor, head) { + return { + line: head.line - anchor.line, + ch: head.line - anchor.line + }; + } + function commandMatches(keys, keyMap, context, inputState) { + // Partial matches are not applied. They inform the key handler + // that the current key sequence is a subsequence of a valid key + // sequence, so that the key buffer is not cleared. + var match, partial = [], full = []; + for (var i = 0; i < keyMap.length; i++) { + var command = keyMap[i]; + if (context == 'insert' && command.context != 'insert' || + command.context && command.context != context || + inputState.operator && command.type == 'action' || + !(match = commandMatch(keys, command.keys))) { continue; } + if (match == 'partial') { partial.push(command); } + if (match == 'full') { full.push(command); } + } + return { + partial: partial.length && partial, + full: full.length && full + }; + } + function commandMatch(pressed, mapped) { + if (mapped.slice(-11) == '') { + // Last character matches anything. + var prefixLen = mapped.length - 11; + var pressedPrefix = pressed.slice(0, prefixLen); + var mappedPrefix = mapped.slice(0, prefixLen); + return pressedPrefix == mappedPrefix && pressed.length > prefixLen ? 'full' : + mappedPrefix.indexOf(pressedPrefix) == 0 ? 'partial' : false; + } else { + return pressed == mapped ? 'full' : + mapped.indexOf(pressed) == 0 ? 'partial' : false; + } + } + function lastChar(keys) { + var match = /^.*(<[\w\-]+>)$/.exec(keys); + var selectedCharacter = match ? match[1] : keys.slice(-1); + if (selectedCharacter.length > 1){ + switch(selectedCharacter){ + case '': + selectedCharacter='\n'; + break; + case '': + selectedCharacter=' '; + break; + default: + break; + } + } + return selectedCharacter; + } + function repeatFn(cm, fn, repeat) { + return function() { + for (var i = 0; i < repeat; i++) { + fn(cm); + } + }; + } + function copyCursor(cur) { + return Pos(cur.line, cur.ch); + } + function cursorEqual(cur1, cur2) { + return cur1.ch == cur2.ch && cur1.line == cur2.line; + } + function cursorIsBefore(cur1, cur2) { + if (cur1.line < cur2.line) { + return true; + } + if (cur1.line == cur2.line && cur1.ch < cur2.ch) { + return true; + } + return false; + } + function cursorMin(cur1, cur2) { + if (arguments.length > 2) { + cur2 = cursorMin.apply(undefined, Array.prototype.slice.call(arguments, 1)); + } + return cursorIsBefore(cur1, cur2) ? cur1 : cur2; + } + function cursorMax(cur1, cur2) { + if (arguments.length > 2) { + cur2 = cursorMax.apply(undefined, Array.prototype.slice.call(arguments, 1)); + } + return cursorIsBefore(cur1, cur2) ? cur2 : cur1; + } + function cursorIsBetween(cur1, cur2, cur3) { + // returns true if cur2 is between cur1 and cur3. + var cur1before2 = cursorIsBefore(cur1, cur2); + var cur2before3 = cursorIsBefore(cur2, cur3); + return cur1before2 && cur2before3; + } + function lineLength(cm, lineNum) { + return cm.getLine(lineNum).length; + } + function trim(s) { + if (s.trim) { + return s.trim(); + } + return s.replace(/^\s+|\s+$/g, ''); + } + function escapeRegex(s) { + return s.replace(/([.?*+$\[\]\/\\(){}|\-])/g, '\\$1'); + } + function extendLineToColumn(cm, lineNum, column) { + var endCh = lineLength(cm, lineNum); + var spaces = new Array(column-endCh+1).join(' '); + cm.setCursor(Pos(lineNum, endCh)); + cm.replaceRange(spaces, cm.getCursor()); + } + // This functions selects a rectangular block + // of text with selectionEnd as any of its corner + // Height of block: + // Difference in selectionEnd.line and first/last selection.line + // Width of the block: + // Distance between selectionEnd.ch and any(first considered here) selection.ch + function selectBlock(cm, selectionEnd) { + var selections = [], ranges = cm.listSelections(); + var head = copyCursor(cm.clipPos(selectionEnd)); + var isClipped = !cursorEqual(selectionEnd, head); + var curHead = cm.getCursor('head'); + var primIndex = getIndex(ranges, curHead); + var wasClipped = cursorEqual(ranges[primIndex].head, ranges[primIndex].anchor); + var max = ranges.length - 1; + var index = max - primIndex > primIndex ? max : 0; + var base = ranges[index].anchor; + + var firstLine = Math.min(base.line, head.line); + var lastLine = Math.max(base.line, head.line); + var baseCh = base.ch, headCh = head.ch; + + var dir = ranges[index].head.ch - baseCh; + var newDir = headCh - baseCh; + if (dir > 0 && newDir <= 0) { + baseCh++; + if (!isClipped) { headCh--; } + } else if (dir < 0 && newDir >= 0) { + baseCh--; + if (!wasClipped) { headCh++; } + } else if (dir < 0 && newDir == -1) { + baseCh--; + headCh++; + } + for (var line = firstLine; line <= lastLine; line++) { + var range = {anchor: new Pos(line, baseCh), head: new Pos(line, headCh)}; + selections.push(range); + } + primIndex = head.line == lastLine ? selections.length - 1 : 0; + cm.setSelections(selections); + selectionEnd.ch = headCh; + base.ch = baseCh; + return base; + } + function selectForInsert(cm, head, height) { + var sel = []; + for (var i = 0; i < height; i++) { + var lineHead = offsetCursor(head, i, 0); + sel.push({anchor: lineHead, head: lineHead}); + } + cm.setSelections(sel, 0); + } + // getIndex returns the index of the cursor in the selections. + function getIndex(ranges, cursor, end) { + for (var i = 0; i < ranges.length; i++) { + var atAnchor = end != 'head' && cursorEqual(ranges[i].anchor, cursor); + var atHead = end != 'anchor' && cursorEqual(ranges[i].head, cursor); + if (atAnchor || atHead) { + return i; + } + } + return -1; + } + function getSelectedAreaRange(cm, vim) { + var lastSelection = vim.lastSelection; + var getCurrentSelectedAreaRange = function() { + var selections = cm.listSelections(); + var start = selections[0]; + var end = selections[selections.length-1]; + var selectionStart = cursorIsBefore(start.anchor, start.head) ? start.anchor : start.head; + var selectionEnd = cursorIsBefore(end.anchor, end.head) ? end.head : end.anchor; + return [selectionStart, selectionEnd]; + }; + var getLastSelectedAreaRange = function() { + var selectionStart = cm.getCursor(); + var selectionEnd = cm.getCursor(); + var block = lastSelection.visualBlock; + if (block) { + var width = block.width; + var height = block.height; + selectionEnd = Pos(selectionStart.line + height, selectionStart.ch + width); + var selections = []; + // selectBlock creates a 'proper' rectangular block. + // We do not want that in all cases, so we manually set selections. + for (var i = selectionStart.line; i < selectionEnd.line; i++) { + var anchor = Pos(i, selectionStart.ch); + var head = Pos(i, selectionEnd.ch); + var range = {anchor: anchor, head: head}; + selections.push(range); + } + cm.setSelections(selections); + } else { + var start = lastSelection.anchorMark.find(); + var end = lastSelection.headMark.find(); + var line = end.line - start.line; + var ch = end.ch - start.ch; + selectionEnd = {line: selectionEnd.line + line, ch: line ? selectionEnd.ch : ch + selectionEnd.ch}; + if (lastSelection.visualLine) { + selectionStart = Pos(selectionStart.line, 0); + selectionEnd = Pos(selectionEnd.line, lineLength(cm, selectionEnd.line)); + } + cm.setSelection(selectionStart, selectionEnd); + } + return [selectionStart, selectionEnd]; + }; + if (!vim.visualMode) { + // In case of replaying the action. + return getLastSelectedAreaRange(); + } else { + return getCurrentSelectedAreaRange(); + } + } + // Updates the previous selection with the current selection's values. This + // should only be called in visual mode. + function updateLastSelection(cm, vim) { + var anchor = vim.sel.anchor; + var head = vim.sel.head; + // To accommodate the effect of lastPastedText in the last selection + if (vim.lastPastedText) { + head = cm.posFromIndex(cm.indexFromPos(anchor) + vim.lastPastedText.length); + vim.lastPastedText = null; + } + vim.lastSelection = {'anchorMark': cm.setBookmark(anchor), + 'headMark': cm.setBookmark(head), + 'anchor': copyCursor(anchor), + 'head': copyCursor(head), + 'visualMode': vim.visualMode, + 'visualLine': vim.visualLine, + 'visualBlock': vim.visualBlock}; + } + function expandSelection(cm, start, end) { + var sel = cm.state.vim.sel; + var head = sel.head; + var anchor = sel.anchor; + var tmp; + if (cursorIsBefore(end, start)) { + tmp = end; + end = start; + start = tmp; + } + if (cursorIsBefore(head, anchor)) { + head = cursorMin(start, head); + anchor = cursorMax(anchor, end); + } else { + anchor = cursorMin(start, anchor); + head = cursorMax(head, end); + head = offsetCursor(head, 0, -1); + if (head.ch == -1 && head.line != cm.firstLine()) { + head = Pos(head.line - 1, lineLength(cm, head.line - 1)); + } + } + return [anchor, head]; + } + /** + * Updates the CodeMirror selection to match the provided vim selection. + * If no arguments are given, it uses the current vim selection state. + */ + function updateCmSelection(cm, sel, mode) { + var vim = cm.state.vim; + sel = sel || vim.sel; + var mode = mode || + vim.visualLine ? 'line' : vim.visualBlock ? 'block' : 'char'; + var cmSel = makeCmSelection(cm, sel, mode); + cm.setSelections(cmSel.ranges, cmSel.primary); + updateFakeCursor(cm); + } + function makeCmSelection(cm, sel, mode, exclusive) { + var head = copyCursor(sel.head); + var anchor = copyCursor(sel.anchor); + if (mode == 'char') { + var headOffset = !exclusive && !cursorIsBefore(sel.head, sel.anchor) ? 1 : 0; + var anchorOffset = cursorIsBefore(sel.head, sel.anchor) ? 1 : 0; + head = offsetCursor(sel.head, 0, headOffset); + anchor = offsetCursor(sel.anchor, 0, anchorOffset); + return { + ranges: [{anchor: anchor, head: head}], + primary: 0 + }; + } else if (mode == 'line') { + if (!cursorIsBefore(sel.head, sel.anchor)) { + anchor.ch = 0; + + var lastLine = cm.lastLine(); + if (head.line > lastLine) { + head.line = lastLine; + } + head.ch = lineLength(cm, head.line); + } else { + head.ch = 0; + anchor.ch = lineLength(cm, anchor.line); + } + return { + ranges: [{anchor: anchor, head: head}], + primary: 0 + }; + } else if (mode == 'block') { + var top = Math.min(anchor.line, head.line), + left = Math.min(anchor.ch, head.ch), + bottom = Math.max(anchor.line, head.line), + right = Math.max(anchor.ch, head.ch) + 1; + var height = bottom - top + 1; + var primary = head.line == top ? 0 : height - 1; + var ranges = []; + for (var i = 0; i < height; i++) { + ranges.push({ + anchor: Pos(top + i, left), + head: Pos(top + i, right) + }); + } + return { + ranges: ranges, + primary: primary + }; + } + } + function getHead(cm) { + var cur = cm.getCursor('head'); + if (cm.getSelection().length == 1) { + // Small corner case when only 1 character is selected. The "real" + // head is the left of head and anchor. + cur = cursorMin(cur, cm.getCursor('anchor')); + } + return cur; + } + + /** + * If moveHead is set to false, the CodeMirror selection will not be + * touched. The caller assumes the responsibility of putting the cursor + * in the right place. + */ + function exitVisualMode(cm, moveHead) { + var vim = cm.state.vim; + if (moveHead !== false) { + cm.setCursor(clipCursorToContent(cm, vim.sel.head)); + } + updateLastSelection(cm, vim); + vim.visualMode = false; + vim.visualLine = false; + vim.visualBlock = false; + CodeMirror.signal(cm, "vim-mode-change", {mode: "normal"}); + if (vim.fakeCursor) { + vim.fakeCursor.clear(); + } + } + + // Remove any trailing newlines from the selection. For + // example, with the caret at the start of the last word on the line, + // 'dw' should word, but not the newline, while 'w' should advance the + // caret to the first character of the next line. + function clipToLine(cm, curStart, curEnd) { + var selection = cm.getRange(curStart, curEnd); + // Only clip if the selection ends with trailing newline + whitespace + if (/\n\s*$/.test(selection)) { + var lines = selection.split('\n'); + // We know this is all whitepsace. + lines.pop(); + + // Cases: + // 1. Last word is an empty line - do not clip the trailing '\n' + // 2. Last word is not an empty line - clip the trailing '\n' + var line; + // Find the line containing the last word, and clip all whitespace up + // to it. + for (var line = lines.pop(); lines.length > 0 && line && isWhiteSpaceString(line); line = lines.pop()) { + curEnd.line--; + curEnd.ch = 0; + } + // If the last word is not an empty line, clip an additional newline + if (line) { + curEnd.line--; + curEnd.ch = lineLength(cm, curEnd.line); + } else { + curEnd.ch = 0; + } + } + } + + // Expand the selection to line ends. + function expandSelectionToLine(_cm, curStart, curEnd) { + curStart.ch = 0; + curEnd.ch = 0; + curEnd.line++; + } + + function findFirstNonWhiteSpaceCharacter(text) { + if (!text) { + return 0; + } + var firstNonWS = text.search(/\S/); + return firstNonWS == -1 ? text.length : firstNonWS; + } + + function expandWordUnderCursor(cm, inclusive, _forward, bigWord, noSymbol) { + var cur = getHead(cm); + var line = cm.getLine(cur.line); + var idx = cur.ch; + + // Seek to first word or non-whitespace character, depending on if + // noSymbol is true. + var test = noSymbol ? wordCharTest[0] : bigWordCharTest [0]; + while (!test(line.charAt(idx))) { + idx++; + if (idx >= line.length) { return null; } + } + + if (bigWord) { + test = bigWordCharTest[0]; + } else { + test = wordCharTest[0]; + if (!test(line.charAt(idx))) { + test = wordCharTest[1]; + } + } + + var end = idx, start = idx; + while (test(line.charAt(end)) && end < line.length) { end++; } + while (test(line.charAt(start)) && start >= 0) { start--; } + start++; + + if (inclusive) { + // If present, include all whitespace after word. + // Otherwise, include all whitespace before word, except indentation. + var wordEnd = end; + while (/\s/.test(line.charAt(end)) && end < line.length) { end++; } + if (wordEnd == end) { + var wordStart = start; + while (/\s/.test(line.charAt(start - 1)) && start > 0) { start--; } + if (!start) { start = wordStart; } + } + } + return { start: Pos(cur.line, start), end: Pos(cur.line, end) }; + } + + function recordJumpPosition(cm, oldCur, newCur) { + if (!cursorEqual(oldCur, newCur)) { + vimGlobalState.jumpList.add(cm, oldCur, newCur); + } + } + + function recordLastCharacterSearch(increment, args) { + vimGlobalState.lastChararacterSearch.increment = increment; + vimGlobalState.lastChararacterSearch.forward = args.forward; + vimGlobalState.lastChararacterSearch.selectedCharacter = args.selectedCharacter; + } + + var symbolToMode = { + '(': 'bracket', ')': 'bracket', '{': 'bracket', '}': 'bracket', + '[': 'section', ']': 'section', + '*': 'comment', '/': 'comment', + 'm': 'method', 'M': 'method', + '#': 'preprocess' + }; + var findSymbolModes = { + bracket: { + isComplete: function(state) { + if (state.nextCh === state.symb) { + state.depth++; + if (state.depth >= 1)return true; + } else if (state.nextCh === state.reverseSymb) { + state.depth--; + } + return false; + } + }, + section: { + init: function(state) { + state.curMoveThrough = true; + state.symb = (state.forward ? ']' : '[') === state.symb ? '{' : '}'; + }, + isComplete: function(state) { + return state.index === 0 && state.nextCh === state.symb; + } + }, + comment: { + isComplete: function(state) { + var found = state.lastCh === '*' && state.nextCh === '/'; + state.lastCh = state.nextCh; + return found; + } + }, + // TODO: The original Vim implementation only operates on level 1 and 2. + // The current implementation doesn't check for code block level and + // therefore it operates on any levels. + method: { + init: function(state) { + state.symb = (state.symb === 'm' ? '{' : '}'); + state.reverseSymb = state.symb === '{' ? '}' : '{'; + }, + isComplete: function(state) { + if (state.nextCh === state.symb)return true; + return false; + } + }, + preprocess: { + init: function(state) { + state.index = 0; + }, + isComplete: function(state) { + if (state.nextCh === '#') { + var token = state.lineText.match(/#(\w+)/)[1]; + if (token === 'endif') { + if (state.forward && state.depth === 0) { + return true; + } + state.depth++; + } else if (token === 'if') { + if (!state.forward && state.depth === 0) { + return true; + } + state.depth--; + } + if (token === 'else' && state.depth === 0)return true; + } + return false; + } + } + }; + function findSymbol(cm, repeat, forward, symb) { + var cur = copyCursor(cm.getCursor()); + var increment = forward ? 1 : -1; + var endLine = forward ? cm.lineCount() : -1; + var curCh = cur.ch; + var line = cur.line; + var lineText = cm.getLine(line); + var state = { + lineText: lineText, + nextCh: lineText.charAt(curCh), + lastCh: null, + index: curCh, + symb: symb, + reverseSymb: (forward ? { ')': '(', '}': '{' } : { '(': ')', '{': '}' })[symb], + forward: forward, + depth: 0, + curMoveThrough: false + }; + var mode = symbolToMode[symb]; + if (!mode)return cur; + var init = findSymbolModes[mode].init; + var isComplete = findSymbolModes[mode].isComplete; + if (init) { init(state); } + while (line !== endLine && repeat) { + state.index += increment; + state.nextCh = state.lineText.charAt(state.index); + if (!state.nextCh) { + line += increment; + state.lineText = cm.getLine(line) || ''; + if (increment > 0) { + state.index = 0; + } else { + var lineLen = state.lineText.length; + state.index = (lineLen > 0) ? (lineLen-1) : 0; + } + state.nextCh = state.lineText.charAt(state.index); + } + if (isComplete(state)) { + cur.line = line; + cur.ch = state.index; + repeat--; + } + } + if (state.nextCh || state.curMoveThrough) { + return Pos(line, state.index); + } + return cur; + } + + /* + * Returns the boundaries of the next word. If the cursor in the middle of + * the word, then returns the boundaries of the current word, starting at + * the cursor. If the cursor is at the start/end of a word, and we are going + * forward/backward, respectively, find the boundaries of the next word. + * + * @param {CodeMirror} cm CodeMirror object. + * @param {Cursor} cur The cursor position. + * @param {boolean} forward True to search forward. False to search + * backward. + * @param {boolean} bigWord True if punctuation count as part of the word. + * False if only [a-zA-Z0-9] characters count as part of the word. + * @param {boolean} emptyLineIsWord True if empty lines should be treated + * as words. + * @return {Object{from:number, to:number, line: number}} The boundaries of + * the word, or null if there are no more words. + */ + function findWord(cm, cur, forward, bigWord, emptyLineIsWord) { + var lineNum = cur.line; + var pos = cur.ch; + var line = cm.getLine(lineNum); + var dir = forward ? 1 : -1; + var charTests = bigWord ? bigWordCharTest: wordCharTest; + + if (emptyLineIsWord && line == '') { + lineNum += dir; + line = cm.getLine(lineNum); + if (!isLine(cm, lineNum)) { + return null; + } + pos = (forward) ? 0 : line.length; + } + + while (true) { + if (emptyLineIsWord && line == '') { + return { from: 0, to: 0, line: lineNum }; + } + var stop = (dir > 0) ? line.length : -1; + var wordStart = stop, wordEnd = stop; + // Find bounds of next word. + while (pos != stop) { + var foundWord = false; + for (var i = 0; i < charTests.length && !foundWord; ++i) { + if (charTests[i](line.charAt(pos))) { + wordStart = pos; + // Advance to end of word. + while (pos != stop && charTests[i](line.charAt(pos))) { + pos += dir; + } + wordEnd = pos; + foundWord = wordStart != wordEnd; + if (wordStart == cur.ch && lineNum == cur.line && + wordEnd == wordStart + dir) { + // We started at the end of a word. Find the next one. + continue; + } else { + return { + from: Math.min(wordStart, wordEnd + 1), + to: Math.max(wordStart, wordEnd), + line: lineNum }; + } + } + } + if (!foundWord) { + pos += dir; + } + } + // Advance to next/prev line. + lineNum += dir; + if (!isLine(cm, lineNum)) { + return null; + } + line = cm.getLine(lineNum); + pos = (dir > 0) ? 0 : line.length; + } + // Should never get here. + throw new Error('The impossible happened.'); + } + + /** + * @param {CodeMirror} cm CodeMirror object. + * @param {Pos} cur The position to start from. + * @param {int} repeat Number of words to move past. + * @param {boolean} forward True to search forward. False to search + * backward. + * @param {boolean} wordEnd True to move to end of word. False to move to + * beginning of word. + * @param {boolean} bigWord True if punctuation count as part of the word. + * False if only alphabet characters count as part of the word. + * @return {Cursor} The position the cursor should move to. + */ + function moveToWord(cm, cur, repeat, forward, wordEnd, bigWord) { + var curStart = copyCursor(cur); + var words = []; + if (forward && !wordEnd || !forward && wordEnd) { + repeat++; + } + // For 'e', empty lines are not considered words, go figure. + var emptyLineIsWord = !(forward && wordEnd); + for (var i = 0; i < repeat; i++) { + var word = findWord(cm, cur, forward, bigWord, emptyLineIsWord); + if (!word) { + var eodCh = lineLength(cm, cm.lastLine()); + words.push(forward + ? {line: cm.lastLine(), from: eodCh, to: eodCh} + : {line: 0, from: 0, to: 0}); + break; + } + words.push(word); + cur = Pos(word.line, forward ? (word.to - 1) : word.from); + } + var shortCircuit = words.length != repeat; + var firstWord = words[0]; + var lastWord = words.pop(); + if (forward && !wordEnd) { + // w + if (!shortCircuit && (firstWord.from != curStart.ch || firstWord.line != curStart.line)) { + // We did not start in the middle of a word. Discard the extra word at the end. + lastWord = words.pop(); + } + return Pos(lastWord.line, lastWord.from); + } else if (forward && wordEnd) { + return Pos(lastWord.line, lastWord.to - 1); + } else if (!forward && wordEnd) { + // ge + if (!shortCircuit && (firstWord.to != curStart.ch || firstWord.line != curStart.line)) { + // We did not start in the middle of a word. Discard the extra word at the end. + lastWord = words.pop(); + } + return Pos(lastWord.line, lastWord.to); + } else { + // b + return Pos(lastWord.line, lastWord.from); + } + } + + function moveToCharacter(cm, repeat, forward, character) { + var cur = cm.getCursor(); + var start = cur.ch; + var idx; + for (var i = 0; i < repeat; i ++) { + var line = cm.getLine(cur.line); + idx = charIdxInLine(start, line, character, forward, true); + if (idx == -1) { + return null; + } + start = idx; + } + return Pos(cm.getCursor().line, idx); + } + + function moveToColumn(cm, repeat) { + // repeat is always >= 1, so repeat - 1 always corresponds + // to the column we want to go to. + var line = cm.getCursor().line; + return clipCursorToContent(cm, Pos(line, repeat - 1)); + } + + function updateMark(cm, vim, markName, pos) { + if (!inArray(markName, validMarks)) { + return; + } + if (vim.marks[markName]) { + vim.marks[markName].clear(); + } + vim.marks[markName] = cm.setBookmark(pos); + } + + function charIdxInLine(start, line, character, forward, includeChar) { + // Search for char in line. + // motion_options: {forward, includeChar} + // If includeChar = true, include it too. + // If forward = true, search forward, else search backwards. + // If char is not found on this line, do nothing + var idx; + if (forward) { + idx = line.indexOf(character, start + 1); + if (idx != -1 && !includeChar) { + idx -= 1; + } + } else { + idx = line.lastIndexOf(character, start - 1); + if (idx != -1 && !includeChar) { + idx += 1; + } + } + return idx; + } + + function findParagraph(cm, head, repeat, dir, inclusive) { + var line = head.line; + var min = cm.firstLine(); + var max = cm.lastLine(); + var start, end, i = line; + function isEmpty(i) { return !/\S/.test(cm.getLine(i)); } + function isBoundary(i, dir, any) { + if (any) { return isEmpty(i) != isEmpty(i + dir); } + return !isEmpty(i) && isEmpty(i + dir); + } + if (dir) { + while (min <= i && i <= max && repeat > 0) { + if (isBoundary(i, dir)) { repeat--; } + i += dir; + } + return new Pos(i, 0); + } + + var vim = cm.state.vim; + if (vim.visualLine && isBoundary(line, 1, true)) { + var anchor = vim.sel.anchor; + if (isBoundary(anchor.line, -1, true)) { + if (!inclusive || anchor.line != line) { + line += 1; + } + } + } + var startState = isEmpty(line); + for (i = line; i <= max && repeat; i++) { + if (isBoundary(i, 1, true)) { + if (!inclusive || isEmpty(i) != startState) { + repeat--; + } + } + } + end = new Pos(i, 0); + // select boundary before paragraph for the last one + if (i > max && !startState) { startState = true; } + else { inclusive = false; } + for (i = line; i > min; i--) { + if (!inclusive || isEmpty(i) == startState || i == line) { + if (isBoundary(i, -1, true)) { break; } + } + } + start = new Pos(i, 0); + return { start: start, end: end }; + } + + // TODO: perhaps this finagling of start and end positions belonds + // in codmirror/replaceRange? + function selectCompanionObject(cm, head, symb, inclusive) { + var cur = head, start, end; + + var bracketRegexp = ({ + '(': /[()]/, ')': /[()]/, + '[': /[[\]]/, ']': /[[\]]/, + '{': /[{}]/, '}': /[{}]/})[symb]; + var openSym = ({ + '(': '(', ')': '(', + '[': '[', ']': '[', + '{': '{', '}': '{'})[symb]; + var curChar = cm.getLine(cur.line).charAt(cur.ch); + // Due to the behavior of scanForBracket, we need to add an offset if the + // cursor is on a matching open bracket. + var offset = curChar === openSym ? 1 : 0; + + start = cm.scanForBracket(Pos(cur.line, cur.ch + offset), -1, null, {'bracketRegex': bracketRegexp}); + end = cm.scanForBracket(Pos(cur.line, cur.ch + offset), 1, null, {'bracketRegex': bracketRegexp}); + + if (!start || !end) { + return { start: cur, end: cur }; + } + + start = start.pos; + end = end.pos; + + if ((start.line == end.line && start.ch > end.ch) + || (start.line > end.line)) { + var tmp = start; + start = end; + end = tmp; + } + + if (inclusive) { + end.ch += 1; + } else { + start.ch += 1; + } + + return { start: start, end: end }; + } + + // Takes in a symbol and a cursor and tries to simulate text objects that + // have identical opening and closing symbols + // TODO support across multiple lines + function findBeginningAndEnd(cm, head, symb, inclusive) { + var cur = copyCursor(head); + var line = cm.getLine(cur.line); + var chars = line.split(''); + var start, end, i, len; + var firstIndex = chars.indexOf(symb); + + // the decision tree is to always look backwards for the beginning first, + // but if the cursor is in front of the first instance of the symb, + // then move the cursor forward + if (cur.ch < firstIndex) { + cur.ch = firstIndex; + // Why is this line even here??? + // cm.setCursor(cur.line, firstIndex+1); + } + // otherwise if the cursor is currently on the closing symbol + else if (firstIndex < cur.ch && chars[cur.ch] == symb) { + end = cur.ch; // assign end to the current cursor + --cur.ch; // make sure to look backwards + } + + // if we're currently on the symbol, we've got a start + if (chars[cur.ch] == symb && !end) { + start = cur.ch + 1; // assign start to ahead of the cursor + } else { + // go backwards to find the start + for (i = cur.ch; i > -1 && !start; i--) { + if (chars[i] == symb) { + start = i + 1; + } + } + } + + // look forwards for the end symbol + if (start && !end) { + for (i = start, len = chars.length; i < len && !end; i++) { + if (chars[i] == symb) { + end = i; + } + } + } + + // nothing found + if (!start || !end) { + return { start: cur, end: cur }; + } + + // include the symbols + if (inclusive) { + --start; ++end; + } + + return { + start: Pos(cur.line, start), + end: Pos(cur.line, end) + }; + } + + // Search functions + defineOption('pcre', true, 'boolean'); + function SearchState() {} + SearchState.prototype = { + getQuery: function() { + return vimGlobalState.query; + }, + setQuery: function(query) { + vimGlobalState.query = query; + }, + getOverlay: function() { + return this.searchOverlay; + }, + setOverlay: function(overlay) { + this.searchOverlay = overlay; + }, + isReversed: function() { + return vimGlobalState.isReversed; + }, + setReversed: function(reversed) { + vimGlobalState.isReversed = reversed; + }, + getScrollbarAnnotate: function() { + return this.annotate; + }, + setScrollbarAnnotate: function(annotate) { + this.annotate = annotate; + } + }; + function getSearchState(cm) { + var vim = cm.state.vim; + return vim.searchState_ || (vim.searchState_ = new SearchState()); + } + function dialog(cm, template, shortText, onClose, options) { + if (cm.openDialog) { + cm.openDialog(template, onClose, { bottom: true, value: options.value, + onKeyDown: options.onKeyDown, onKeyUp: options.onKeyUp, + selectValueOnOpen: false}); + } + else { + onClose(prompt(shortText, '')); + } + } + function splitBySlash(argString) { + var slashes = findUnescapedSlashes(argString) || []; + if (!slashes.length) return []; + var tokens = []; + // in case of strings like foo/bar + if (slashes[0] !== 0) return; + for (var i = 0; i < slashes.length; i++) { + if (typeof slashes[i] == 'number') + tokens.push(argString.substring(slashes[i] + 1, slashes[i+1])); + } + return tokens; + } + + function findUnescapedSlashes(str) { + var escapeNextChar = false; + var slashes = []; + for (var i = 0; i < str.length; i++) { + var c = str.charAt(i); + if (!escapeNextChar && c == '/') { + slashes.push(i); + } + escapeNextChar = !escapeNextChar && (c == '\\'); + } + return slashes; + } + + // Translates a search string from ex (vim) syntax into javascript form. + function translateRegex(str) { + // When these match, add a '\' if unescaped or remove one if escaped. + var specials = '|(){'; + // Remove, but never add, a '\' for these. + var unescape = '}'; + var escapeNextChar = false; + var out = []; + for (var i = -1; i < str.length; i++) { + var c = str.charAt(i) || ''; + var n = str.charAt(i+1) || ''; + var specialComesNext = (n && specials.indexOf(n) != -1); + if (escapeNextChar) { + if (c !== '\\' || !specialComesNext) { + out.push(c); + } + escapeNextChar = false; + } else { + if (c === '\\') { + escapeNextChar = true; + // Treat the unescape list as special for removing, but not adding '\'. + if (n && unescape.indexOf(n) != -1) { + specialComesNext = true; + } + // Not passing this test means removing a '\'. + if (!specialComesNext || n === '\\') { + out.push(c); + } + } else { + out.push(c); + if (specialComesNext && n !== '\\') { + out.push('\\'); + } + } + } + } + return out.join(''); + } + + // Translates the replace part of a search and replace from ex (vim) syntax into + // javascript form. Similar to translateRegex, but additionally fixes back references + // (translates '\[0..9]' to '$[0..9]') and follows different rules for escaping '$'. + function translateRegexReplace(str) { + var escapeNextChar = false; + var out = []; + for (var i = -1; i < str.length; i++) { + var c = str.charAt(i) || ''; + var n = str.charAt(i+1) || ''; + if (escapeNextChar) { + // At any point in the loop, escapeNextChar is true if the previous + // character was a '\' and was not escaped. + out.push(c); + escapeNextChar = false; + } else { + if (c === '\\') { + escapeNextChar = true; + if ((isNumber(n) || n === '$')) { + out.push('$'); + } else if (n !== '/' && n !== '\\') { + out.push('\\'); + } + } else { + if (c === '$') { + out.push('$'); + } + out.push(c); + if (n === '/') { + out.push('\\'); + } + } + } + } + return out.join(''); + } + + // Unescape \ and / in the replace part, for PCRE mode. + function unescapeRegexReplace(str) { + var stream = new CodeMirror.StringStream(str); + var output = []; + while (!stream.eol()) { + // Search for \. + while (stream.peek() && stream.peek() != '\\') { + output.push(stream.next()); + } + if (stream.match('\\/', true)) { + // \/ => / + output.push('/'); + } else if (stream.match('\\\\', true)) { + // \\ => \ + output.push('\\'); + } else { + // Don't change anything + output.push(stream.next()); + } + } + return output.join(''); + } + + /** + * Extract the regular expression from the query and return a Regexp object. + * Returns null if the query is blank. + * If ignoreCase is passed in, the Regexp object will have the 'i' flag set. + * If smartCase is passed in, and the query contains upper case letters, + * then ignoreCase is overridden, and the 'i' flag will not be set. + * If the query contains the /i in the flag part of the regular expression, + * then both ignoreCase and smartCase are ignored, and 'i' will be passed + * through to the Regex object. + */ + function parseQuery(query, ignoreCase, smartCase) { + // First update the last search register + var lastSearchRegister = vimGlobalState.registerController.getRegister('/'); + lastSearchRegister.setText(query); + // Check if the query is already a regex. + if (query instanceof RegExp) { return query; } + // First try to extract regex + flags from the input. If no flags found, + // extract just the regex. IE does not accept flags directly defined in + // the regex string in the form /regex/flags + var slashes = findUnescapedSlashes(query); + var regexPart; + var forceIgnoreCase; + if (!slashes.length) { + // Query looks like 'regexp' + regexPart = query; + } else { + // Query looks like 'regexp/...' + regexPart = query.substring(0, slashes[0]); + var flagsPart = query.substring(slashes[0]); + forceIgnoreCase = (flagsPart.indexOf('i') != -1); + } + if (!regexPart) { + return null; + } + if (!getOption('pcre')) { + regexPart = translateRegex(regexPart); + } + if (smartCase) { + ignoreCase = (/^[^A-Z]*$/).test(regexPart); + } + var regexp = new RegExp(regexPart, + (ignoreCase || forceIgnoreCase) ? 'i' : undefined); + return regexp; + } + function showConfirm(cm, text) { + if (cm.openNotification) { + cm.openNotification('' + text + '', + {bottom: true, duration: 5000}); + } else { + alert(text); + } + } + function makePrompt(prefix, desc) { + var raw = ''; + if (prefix) { + raw += '' + prefix + ''; + } + raw += ' ' + + ''; + if (desc) { + raw += ''; + raw += desc; + raw += ''; + } + return raw; + } + var searchPromptDesc = '(Javascript regexp)'; + function showPrompt(cm, options) { + var shortText = (options.prefix || '') + ' ' + (options.desc || ''); + var prompt = makePrompt(options.prefix, options.desc); + dialog(cm, prompt, shortText, options.onClose, options); + } + function regexEqual(r1, r2) { + if (r1 instanceof RegExp && r2 instanceof RegExp) { + var props = ['global', 'multiline', 'ignoreCase', 'source']; + for (var i = 0; i < props.length; i++) { + var prop = props[i]; + if (r1[prop] !== r2[prop]) { + return false; + } + } + return true; + } + return false; + } + // Returns true if the query is valid. + function updateSearchQuery(cm, rawQuery, ignoreCase, smartCase) { + if (!rawQuery) { + return; + } + var state = getSearchState(cm); + var query = parseQuery(rawQuery, !!ignoreCase, !!smartCase); + if (!query) { + return; + } + highlightSearchMatches(cm, query); + if (regexEqual(query, state.getQuery())) { + return query; + } + state.setQuery(query); + return query; + } + function searchOverlay(query) { + if (query.source.charAt(0) == '^') { + var matchSol = true; + } + return { + token: function(stream) { + if (matchSol && !stream.sol()) { + stream.skipToEnd(); + return; + } + var match = stream.match(query, false); + if (match) { + if (match[0].length == 0) { + // Matched empty string, skip to next. + stream.next(); + return 'searching'; + } + if (!stream.sol()) { + // Backtrack 1 to match \b + stream.backUp(1); + if (!query.exec(stream.next() + match[0])) { + stream.next(); + return null; + } + } + stream.match(query); + return 'searching'; + } + while (!stream.eol()) { + stream.next(); + if (stream.match(query, false)) break; + } + }, + query: query + }; + } + function highlightSearchMatches(cm, query) { + var searchState = getSearchState(cm); + var overlay = searchState.getOverlay(); + if (!overlay || query != overlay.query) { + if (overlay) { + cm.removeOverlay(overlay); + } + overlay = searchOverlay(query); + cm.addOverlay(overlay); + if (cm.showMatchesOnScrollbar) { + if (searchState.getScrollbarAnnotate()) { + searchState.getScrollbarAnnotate().clear(); + } + searchState.setScrollbarAnnotate(cm.showMatchesOnScrollbar(query)); + } + searchState.setOverlay(overlay); + } + } + function findNext(cm, prev, query, repeat) { + if (repeat === undefined) { repeat = 1; } + return cm.operation(function() { + var pos = cm.getCursor(); + var cursor = cm.getSearchCursor(query, pos); + for (var i = 0; i < repeat; i++) { + var found = cursor.find(prev); + if (i == 0 && found && cursorEqual(cursor.from(), pos)) { found = cursor.find(prev); } + if (!found) { + // SearchCursor may have returned null because it hit EOF, wrap + // around and try again. + cursor = cm.getSearchCursor(query, + (prev) ? Pos(cm.lastLine()) : Pos(cm.firstLine(), 0) ); + if (!cursor.find(prev)) { + return; + } + } + } + return cursor.from(); + }); + } + function clearSearchHighlight(cm) { + var state = getSearchState(cm); + cm.removeOverlay(getSearchState(cm).getOverlay()); + state.setOverlay(null); + if (state.getScrollbarAnnotate()) { + state.getScrollbarAnnotate().clear(); + state.setScrollbarAnnotate(null); + } + } + /** + * Check if pos is in the specified range, INCLUSIVE. + * Range can be specified with 1 or 2 arguments. + * If the first range argument is an array, treat it as an array of line + * numbers. Match pos against any of the lines. + * If the first range argument is a number, + * if there is only 1 range argument, check if pos has the same line + * number + * if there are 2 range arguments, then check if pos is in between the two + * range arguments. + */ + function isInRange(pos, start, end) { + if (typeof pos != 'number') { + // Assume it is a cursor position. Get the line number. + pos = pos.line; + } + if (start instanceof Array) { + return inArray(pos, start); + } else { + if (end) { + return (pos >= start && pos <= end); + } else { + return pos == start; + } + } + } + function getUserVisibleLines(cm) { + var renderer = cm.ace.renderer; + return { + top: renderer.getFirstFullyVisibleRow(), + bottom: renderer.getLastFullyVisibleRow() + } + } + + // Ex command handling + // Care must be taken when adding to the default Ex command map. For any + // pair of commands that have a shared prefix, at least one of their + // shortNames must not match the prefix of the other command. + var defaultExCommandMap = [ + { name: 'colorscheme', shortName: 'colo' }, + { name: 'map' }, + { name: 'imap', shortName: 'im' }, + { name: 'nmap', shortName: 'nm' }, + { name: 'vmap', shortName: 'vm' }, + { name: 'unmap' }, + { name: 'write', shortName: 'w' }, + { name: 'undo', shortName: 'u' }, + { name: 'redo', shortName: 'red' }, + { name: 'set', shortName: 'se' }, + { name: 'set', shortName: 'se' }, + { name: 'setlocal', shortName: 'setl' }, + { name: 'setglobal', shortName: 'setg' }, + { name: 'sort', shortName: 'sor' }, + { name: 'substitute', shortName: 's', possiblyAsync: true }, + { name: 'nohlsearch', shortName: 'noh' }, + { name: 'delmarks', shortName: 'delm' }, + { name: 'registers', shortName: 'reg', excludeFromCommandHistory: true }, + { name: 'global', shortName: 'g' } + ]; + var ExCommandDispatcher = function() { + this.buildCommandMap_(); + }; + ExCommandDispatcher.prototype = { + processCommand: function(cm, input, opt_params) { + var that = this; + cm.operation(function () { + cm.curOp.isVimOp = true; + that._processCommand(cm, input, opt_params); + }); + }, + _processCommand: function(cm, input, opt_params) { + var vim = cm.state.vim; + var commandHistoryRegister = vimGlobalState.registerController.getRegister(':'); + var previousCommand = commandHistoryRegister.toString(); + if (vim.visualMode) { + exitVisualMode(cm); + } + var inputStream = new CodeMirror.StringStream(input); + // update ": with the latest command whether valid or invalid + commandHistoryRegister.setText(input); + var params = opt_params || {}; + params.input = input; + try { + this.parseInput_(cm, inputStream, params); + } catch(e) { + showConfirm(cm, e); + throw e; + } + var command; + var commandName; + if (!params.commandName) { + // If only a line range is defined, move to the line. + if (params.line !== undefined) { + commandName = 'move'; + } + } else { + command = this.matchCommand_(params.commandName); + if (command) { + commandName = command.name; + if (command.excludeFromCommandHistory) { + commandHistoryRegister.setText(previousCommand); + } + this.parseCommandArgs_(inputStream, params, command); + if (command.type == 'exToKey') { + // Handle Ex to Key mapping. + for (var i = 0; i < command.toKeys.length; i++) { + CodeMirror.Vim.handleKey(cm, command.toKeys[i], 'mapping'); + } + return; + } else if (command.type == 'exToEx') { + // Handle Ex to Ex mapping. + this.processCommand(cm, command.toInput); + return; + } + } + } + if (!commandName) { + showConfirm(cm, 'Not an editor command ":' + input + '"'); + return; + } + try { + exCommands[commandName](cm, params); + // Possibly asynchronous commands (e.g. substitute, which might have a + // user confirmation), are responsible for calling the callback when + // done. All others have it taken care of for them here. + if ((!command || !command.possiblyAsync) && params.callback) { + params.callback(); + } + } catch(e) { + showConfirm(cm, e); + throw e; + } + }, + parseInput_: function(cm, inputStream, result) { + inputStream.eatWhile(':'); + // Parse range. + if (inputStream.eat('%')) { + result.line = cm.firstLine(); + result.lineEnd = cm.lastLine(); + } else { + result.line = this.parseLineSpec_(cm, inputStream); + if (result.line !== undefined && inputStream.eat(',')) { + result.lineEnd = this.parseLineSpec_(cm, inputStream); + } + } + + // Parse command name. + var commandMatch = inputStream.match(/^(\w+)/); + if (commandMatch) { + result.commandName = commandMatch[1]; + } else { + result.commandName = inputStream.match(/.*/)[0]; + } + + return result; + }, + parseLineSpec_: function(cm, inputStream) { + var numberMatch = inputStream.match(/^(\d+)/); + if (numberMatch) { + return parseInt(numberMatch[1], 10) - 1; + } + switch (inputStream.next()) { + case '.': + return cm.getCursor().line; + case '$': + return cm.lastLine(); + case '\'': + var mark = cm.state.vim.marks[inputStream.next()]; + if (mark && mark.find()) { + return mark.find().line; + } + throw new Error('Mark not set'); + default: + inputStream.backUp(1); + return undefined; + } + }, + parseCommandArgs_: function(inputStream, params, command) { + if (inputStream.eol()) { + return; + } + params.argString = inputStream.match(/.*/)[0]; + // Parse command-line arguments + var delim = command.argDelimiter || /\s+/; + var args = trim(params.argString).split(delim); + if (args.length && args[0]) { + params.args = args; + } + }, + matchCommand_: function(commandName) { + // Return the command in the command map that matches the shortest + // prefix of the passed in command name. The match is guaranteed to be + // unambiguous if the defaultExCommandMap's shortNames are set up + // correctly. (see @code{defaultExCommandMap}). + for (var i = commandName.length; i > 0; i--) { + var prefix = commandName.substring(0, i); + if (this.commandMap_[prefix]) { + var command = this.commandMap_[prefix]; + if (command.name.indexOf(commandName) === 0) { + return command; + } + } + } + return null; + }, + buildCommandMap_: function() { + this.commandMap_ = {}; + for (var i = 0; i < defaultExCommandMap.length; i++) { + var command = defaultExCommandMap[i]; + var key = command.shortName || command.name; + this.commandMap_[key] = command; + } + }, + map: function(lhs, rhs, ctx) { + if (lhs != ':' && lhs.charAt(0) == ':') { + if (ctx) { throw Error('Mode not supported for ex mappings'); } + var commandName = lhs.substring(1); + if (rhs != ':' && rhs.charAt(0) == ':') { + // Ex to Ex mapping + this.commandMap_[commandName] = { + name: commandName, + type: 'exToEx', + toInput: rhs.substring(1), + user: true + }; + } else { + // Ex to key mapping + this.commandMap_[commandName] = { + name: commandName, + type: 'exToKey', + toKeys: rhs, + user: true + }; + } + } else { + if (rhs != ':' && rhs.charAt(0) == ':') { + // Key to Ex mapping. + var mapping = { + keys: lhs, + type: 'keyToEx', + exArgs: { input: rhs.substring(1) }, + user: true}; + if (ctx) { mapping.context = ctx; } + defaultKeymap.unshift(mapping); + } else { + // Key to key mapping + var mapping = { + keys: lhs, + type: 'keyToKey', + toKeys: rhs, + user: true + }; + if (ctx) { mapping.context = ctx; } + defaultKeymap.unshift(mapping); + } + } + }, + unmap: function(lhs, ctx) { + if (lhs != ':' && lhs.charAt(0) == ':') { + // Ex to Ex or Ex to key mapping + if (ctx) { throw Error('Mode not supported for ex mappings'); } + var commandName = lhs.substring(1); + if (this.commandMap_[commandName] && this.commandMap_[commandName].user) { + delete this.commandMap_[commandName]; + return; + } + } else { + // Key to Ex or key to key mapping + var keys = lhs; + for (var i = 0; i < defaultKeymap.length; i++) { + if (keys == defaultKeymap[i].keys + && defaultKeymap[i].context === ctx + && defaultKeymap[i].user) { + defaultKeymap.splice(i, 1); + return; + } + } + } + throw Error('No such mapping.'); + } + }; + + var exCommands = { + colorscheme: function(cm, params) { + if (!params.args || params.args.length < 1) { + showConfirm(cm, cm.getOption('theme')); + return; + } + cm.setOption('theme', params.args[0]); + }, + map: function(cm, params, ctx) { + var mapArgs = params.args; + if (!mapArgs || mapArgs.length < 2) { + if (cm) { + showConfirm(cm, 'Invalid mapping: ' + params.input); + } + return; + } + exCommandDispatcher.map(mapArgs[0], mapArgs[1], ctx); + }, + imap: function(cm, params) { this.map(cm, params, 'insert'); }, + nmap: function(cm, params) { this.map(cm, params, 'normal'); }, + vmap: function(cm, params) { this.map(cm, params, 'visual'); }, + unmap: function(cm, params, ctx) { + var mapArgs = params.args; + if (!mapArgs || mapArgs.length < 1) { + if (cm) { + showConfirm(cm, 'No such mapping: ' + params.input); + } + return; + } + exCommandDispatcher.unmap(mapArgs[0], ctx); + }, + move: function(cm, params) { + commandDispatcher.processCommand(cm, cm.state.vim, { + type: 'motion', + motion: 'moveToLineOrEdgeOfDocument', + motionArgs: { forward: false, explicitRepeat: true, + linewise: true }, + repeatOverride: params.line+1}); + }, + set: function(cm, params) { + var setArgs = params.args; + // Options passed through to the setOption/getOption calls. May be passed in by the + // local/global versions of the set command + var setCfg = params.setCfg || {}; + if (!setArgs || setArgs.length < 1) { + if (cm) { + showConfirm(cm, 'Invalid mapping: ' + params.input); + } + return; + } + var expr = setArgs[0].split('='); + var optionName = expr[0]; + var value = expr[1]; + var forceGet = false; + + if (optionName.charAt(optionName.length - 1) == '?') { + // If post-fixed with ?, then the set is actually a get. + if (value) { throw Error('Trailing characters: ' + params.argString); } + optionName = optionName.substring(0, optionName.length - 1); + forceGet = true; + } + if (value === undefined && optionName.substring(0, 2) == 'no') { + // To set boolean options to false, the option name is prefixed with + // 'no'. + optionName = optionName.substring(2); + value = false; + } + + var optionIsBoolean = options[optionName] && options[optionName].type == 'boolean'; + if (optionIsBoolean && value == undefined) { + // Calling set with a boolean option sets it to true. + value = true; + } + // If no value is provided, then we assume this is a get. + if (!optionIsBoolean && value === undefined || forceGet) { + var oldValue = getOption(optionName, cm, setCfg); + if (oldValue === true || oldValue === false) { + showConfirm(cm, ' ' + (oldValue ? '' : 'no') + optionName); + } else { + showConfirm(cm, ' ' + optionName + '=' + oldValue); + } + } else { + setOption(optionName, value, cm, setCfg); + } + }, + setlocal: function (cm, params) { + // setCfg is passed through to setOption + params.setCfg = {scope: 'local'}; + this.set(cm, params); + }, + setglobal: function (cm, params) { + // setCfg is passed through to setOption + params.setCfg = {scope: 'global'}; + this.set(cm, params); + }, + registers: function(cm, params) { + var regArgs = params.args; + var registers = vimGlobalState.registerController.registers; + var regInfo = '----------Registers----------

    '; + if (!regArgs) { + for (var registerName in registers) { + var text = registers[registerName].toString(); + if (text.length) { + regInfo += '"' + registerName + ' ' + text + '
    '; + } + } + } else { + var registerName; + regArgs = regArgs.join(''); + for (var i = 0; i < regArgs.length; i++) { + registerName = regArgs.charAt(i); + if (!vimGlobalState.registerController.isValidRegister(registerName)) { + continue; + } + var register = registers[registerName] || new Register(); + regInfo += '"' + registerName + ' ' + register.toString() + '
    '; + } + } + showConfirm(cm, regInfo); + }, + sort: function(cm, params) { + var reverse, ignoreCase, unique, number; + function parseArgs() { + if (params.argString) { + var args = new CodeMirror.StringStream(params.argString); + if (args.eat('!')) { reverse = true; } + if (args.eol()) { return; } + if (!args.eatSpace()) { return 'Invalid arguments'; } + var opts = args.match(/[a-z]+/); + if (opts) { + opts = opts[0]; + ignoreCase = opts.indexOf('i') != -1; + unique = opts.indexOf('u') != -1; + var decimal = opts.indexOf('d') != -1 && 1; + var hex = opts.indexOf('x') != -1 && 1; + var octal = opts.indexOf('o') != -1 && 1; + if (decimal + hex + octal > 1) { return 'Invalid arguments'; } + number = decimal && 'decimal' || hex && 'hex' || octal && 'octal'; + } + if (args.eatSpace() && args.match(/\/.*\//)) { 'patterns not supported'; } + } + } + var err = parseArgs(); + if (err) { + showConfirm(cm, err + ': ' + params.argString); + return; + } + var lineStart = params.line || cm.firstLine(); + var lineEnd = params.lineEnd || params.line || cm.lastLine(); + if (lineStart == lineEnd) { return; } + var curStart = Pos(lineStart, 0); + var curEnd = Pos(lineEnd, lineLength(cm, lineEnd)); + var text = cm.getRange(curStart, curEnd).split('\n'); + var numberRegex = (number == 'decimal') ? /(-?)([\d]+)/ : + (number == 'hex') ? /(-?)(?:0x)?([0-9a-f]+)/i : + (number == 'octal') ? /([0-7]+)/ : null; + var radix = (number == 'decimal') ? 10 : (number == 'hex') ? 16 : (number == 'octal') ? 8 : null; + var numPart = [], textPart = []; + if (number) { + for (var i = 0; i < text.length; i++) { + if (numberRegex.exec(text[i])) { + numPart.push(text[i]); + } else { + textPart.push(text[i]); + } + } + } else { + textPart = text; + } + function compareFn(a, b) { + if (reverse) { var tmp; tmp = a; a = b; b = tmp; } + if (ignoreCase) { a = a.toLowerCase(); b = b.toLowerCase(); } + var anum = number && numberRegex.exec(a); + var bnum = number && numberRegex.exec(b); + if (!anum) { return a < b ? -1 : 1; } + anum = parseInt((anum[1] + anum[2]).toLowerCase(), radix); + bnum = parseInt((bnum[1] + bnum[2]).toLowerCase(), radix); + return anum - bnum; + } + numPart.sort(compareFn); + textPart.sort(compareFn); + text = (!reverse) ? textPart.concat(numPart) : numPart.concat(textPart); + if (unique) { // Remove duplicate lines + var textOld = text; + var lastLine; + text = []; + for (var i = 0; i < textOld.length; i++) { + if (textOld[i] != lastLine) { + text.push(textOld[i]); + } + lastLine = textOld[i]; + } + } + cm.replaceRange(text.join('\n'), curStart, curEnd); + }, + global: function(cm, params) { + // a global command is of the form + // :[range]g/pattern/[cmd] + // argString holds the string /pattern/[cmd] + var argString = params.argString; + if (!argString) { + showConfirm(cm, 'Regular Expression missing from global'); + return; + } + // range is specified here + var lineStart = (params.line !== undefined) ? params.line : cm.firstLine(); + var lineEnd = params.lineEnd || params.line || cm.lastLine(); + // get the tokens from argString + var tokens = splitBySlash(argString); + var regexPart = argString, cmd; + if (tokens.length) { + regexPart = tokens[0]; + cmd = tokens.slice(1, tokens.length).join('/'); + } + if (regexPart) { + // If regex part is empty, then use the previous query. Otherwise + // use the regex part as the new query. + try { + updateSearchQuery(cm, regexPart, true /** ignoreCase */, + true /** smartCase */); + } catch (e) { + showConfirm(cm, 'Invalid regex: ' + regexPart); + return; + } + } + // now that we have the regexPart, search for regex matches in the + // specified range of lines + var query = getSearchState(cm).getQuery(); + var matchedLines = [], content = ''; + for (var i = lineStart; i <= lineEnd; i++) { + var matched = query.test(cm.getLine(i)); + if (matched) { + matchedLines.push(i+1); + content+= cm.getLine(i) + '
    '; + } + } + // if there is no [cmd], just display the list of matched lines + if (!cmd) { + showConfirm(cm, content); + return; + } + var index = 0; + var nextCommand = function() { + if (index < matchedLines.length) { + var command = matchedLines[index] + cmd; + exCommandDispatcher.processCommand(cm, command, { + callback: nextCommand + }); + } + index++; + }; + nextCommand(); + }, + substitute: function(cm, params) { + if (!cm.getSearchCursor) { + throw new Error('Search feature not available. Requires searchcursor.js or ' + + 'any other getSearchCursor implementation.'); + } + var argString = params.argString; + var tokens = argString ? splitBySlash(argString) : []; + var regexPart, replacePart = '', trailing, flagsPart, count; + var confirm = false; // Whether to confirm each replace. + var global = false; // True to replace all instances on a line, false to replace only 1. + if (tokens.length) { + regexPart = tokens[0]; + replacePart = tokens[1]; + if (replacePart !== undefined) { + if (getOption('pcre')) { + replacePart = unescapeRegexReplace(replacePart); + } else { + replacePart = translateRegexReplace(replacePart); + } + vimGlobalState.lastSubstituteReplacePart = replacePart; + } + trailing = tokens[2] ? tokens[2].split(' ') : []; + } else { + // either the argString is empty or its of the form ' hello/world' + // actually splitBySlash returns a list of tokens + // only if the string starts with a '/' + if (argString && argString.length) { + showConfirm(cm, 'Substitutions should be of the form ' + + ':s/pattern/replace/'); + return; + } + } + // After the 3rd slash, we can have flags followed by a space followed + // by count. + if (trailing) { + flagsPart = trailing[0]; + count = parseInt(trailing[1]); + if (flagsPart) { + if (flagsPart.indexOf('c') != -1) { + confirm = true; + flagsPart.replace('c', ''); + } + if (flagsPart.indexOf('g') != -1) { + global = true; + flagsPart.replace('g', ''); + } + regexPart = regexPart + '/' + flagsPart; + } + } + if (regexPart) { + // If regex part is empty, then use the previous query. Otherwise use + // the regex part as the new query. + try { + updateSearchQuery(cm, regexPart, true /** ignoreCase */, + true /** smartCase */); + } catch (e) { + showConfirm(cm, 'Invalid regex: ' + regexPart); + return; + } + } + replacePart = replacePart || vimGlobalState.lastSubstituteReplacePart; + if (replacePart === undefined) { + showConfirm(cm, 'No previous substitute regular expression'); + return; + } + var state = getSearchState(cm); + var query = state.getQuery(); + var lineStart = (params.line !== undefined) ? params.line : cm.getCursor().line; + var lineEnd = params.lineEnd || lineStart; + if (count) { + lineStart = lineEnd; + lineEnd = lineStart + count - 1; + } + var startPos = clipCursorToContent(cm, Pos(lineStart, 0)); + var cursor = cm.getSearchCursor(query, startPos); + doReplace(cm, confirm, global, lineStart, lineEnd, cursor, query, replacePart, params.callback); + }, + redo: CodeMirror.commands.redo, + undo: CodeMirror.commands.undo, + write: function(cm) { + if (CodeMirror.commands.save) { + // If a save command is defined, call it. + CodeMirror.commands.save(cm); + } else { + // Saves to text area if no save command is defined. + cm.save(); + } + }, + nohlsearch: function(cm) { + clearSearchHighlight(cm); + }, + delmarks: function(cm, params) { + if (!params.argString || !trim(params.argString)) { + showConfirm(cm, 'Argument required'); + return; + } + + var state = cm.state.vim; + var stream = new CodeMirror.StringStream(trim(params.argString)); + while (!stream.eol()) { + stream.eatSpace(); + + // Record the streams position at the beginning of the loop for use + // in error messages. + var count = stream.pos; + + if (!stream.match(/[a-zA-Z]/, false)) { + showConfirm(cm, 'Invalid argument: ' + params.argString.substring(count)); + return; + } + + var sym = stream.next(); + // Check if this symbol is part of a range + if (stream.match('-', true)) { + // This symbol is part of a range. + + // The range must terminate at an alphabetic character. + if (!stream.match(/[a-zA-Z]/, false)) { + showConfirm(cm, 'Invalid argument: ' + params.argString.substring(count)); + return; + } + + var startMark = sym; + var finishMark = stream.next(); + // The range must terminate at an alphabetic character which + // shares the same case as the start of the range. + if (isLowerCase(startMark) && isLowerCase(finishMark) || + isUpperCase(startMark) && isUpperCase(finishMark)) { + var start = startMark.charCodeAt(0); + var finish = finishMark.charCodeAt(0); + if (start >= finish) { + showConfirm(cm, 'Invalid argument: ' + params.argString.substring(count)); + return; + } + + // Because marks are always ASCII values, and we have + // determined that they are the same case, we can use + // their char codes to iterate through the defined range. + for (var j = 0; j <= finish - start; j++) { + var mark = String.fromCharCode(start + j); + delete state.marks[mark]; + } + } else { + showConfirm(cm, 'Invalid argument: ' + startMark + '-'); + return; + } + } else { + // This symbol is a valid mark, and is not part of a range. + delete state.marks[sym]; + } + } + } + }; + + var exCommandDispatcher = new ExCommandDispatcher(); + + /** + * @param {CodeMirror} cm CodeMirror instance we are in. + * @param {boolean} confirm Whether to confirm each replace. + * @param {Cursor} lineStart Line to start replacing from. + * @param {Cursor} lineEnd Line to stop replacing at. + * @param {RegExp} query Query for performing matches with. + * @param {string} replaceWith Text to replace matches with. May contain $1, + * $2, etc for replacing captured groups using Javascript replace. + * @param {function()} callback A callback for when the replace is done. + */ + function doReplace(cm, confirm, global, lineStart, lineEnd, searchCursor, query, + replaceWith, callback) { + // Set up all the functions. + cm.state.vim.exMode = true; + var done = false; + var lastPos = searchCursor.from(); + function replaceAll() { + cm.operation(function() { + while (!done) { + replace(); + next(); + } + stop(); + }); + } + function replace() { + var text = cm.getRange(searchCursor.from(), searchCursor.to()); + var newText = text.replace(query, replaceWith); + searchCursor.replace(newText); + } + function next() { + var found; + // The below only loops to skip over multiple occurrences on the same + // line when 'global' is not true. + while(found = searchCursor.findNext() && + isInRange(searchCursor.from(), lineStart, lineEnd)) { + if (!global && lastPos && searchCursor.from().line == lastPos.line) { + continue; + } + cm.scrollIntoView(searchCursor.from(), 30); + cm.setSelection(searchCursor.from(), searchCursor.to()); + lastPos = searchCursor.from(); + done = false; + return; + } + done = true; + } + function stop(close) { + if (close) { close(); } + cm.focus(); + if (lastPos) { + cm.setCursor(lastPos); + var vim = cm.state.vim; + vim.exMode = false; + vim.lastHPos = vim.lastHSPos = lastPos.ch; + } + if (callback) { callback(); } + } + function onPromptKeyDown(e, _value, close) { + // Swallow all keys. + CodeMirror.e_stop(e); + var keyName = CodeMirror.keyName(e); + switch (keyName) { + case 'Y': + replace(); next(); break; + case 'N': + next(); break; + case 'A': + // replaceAll contains a call to close of its own. We don't want it + // to fire too early or multiple times. + var savedCallback = callback; + callback = undefined; + cm.operation(replaceAll); + callback = savedCallback; + break; + case 'L': + replace(); + // fall through and exit. + case 'Q': + case 'Esc': + case 'Ctrl-C': + case 'Ctrl-[': + stop(close); + break; + } + if (done) { stop(close); } + return true; + } + + // Actually do replace. + next(); + if (done) { + showConfirm(cm, 'No matches for ' + query.source); + return; + } + if (!confirm) { + replaceAll(); + if (callback) { callback(); }; + return; + } + showPrompt(cm, { + prefix: 'replace with ' + replaceWith + ' (y/n/a/q/l)', + onKeyDown: onPromptKeyDown + }); + } + + CodeMirror.keyMap.vim = { + attach: attachVimMap, + detach: detachVimMap, + call: cmKey + }; + + function exitInsertMode(cm) { + var vim = cm.state.vim; + var macroModeState = vimGlobalState.macroModeState; + var insertModeChangeRegister = vimGlobalState.registerController.getRegister('.'); + var isPlaying = macroModeState.isPlaying; + var lastChange = macroModeState.lastInsertModeChanges; + // In case of visual block, the insertModeChanges are not saved as a + // single word, so we convert them to a single word + // so as to update the ". register as expected in real vim. + var text = []; + if (!isPlaying) { + var selLength = lastChange.inVisualBlock ? vim.lastSelection.visualBlock.height : 1; + var changes = lastChange.changes; + var text = []; + var i = 0; + // In case of multiple selections in blockwise visual, + // the inserted text, for example: 'foo', is stored as + // 'f', 'f', InsertModeKey 'o', 'o', 'o', 'o'. (if you have a block with 2 lines). + // We push the contents of the changes array as per the following: + // 1. In case of InsertModeKey, just increment by 1. + // 2. In case of a character, jump by selLength (2 in the example). + while (i < changes.length) { + // This loop will convert 'ffoooo' to 'foo'. + text.push(changes[i]); + if (changes[i] instanceof InsertModeKey) { + i++; + } else { + i+= selLength; + } + } + lastChange.changes = text; + cm.off('change', onChange); + CodeMirror.off(cm.getInputField(), 'keydown', onKeyEventTargetKeyDown); + } + if (!isPlaying && vim.insertModeRepeat > 1) { + // Perform insert mode repeat for commands like 3,a and 3,o. + repeatLastEdit(cm, vim, vim.insertModeRepeat - 1, + true /** repeatForInsert */); + vim.lastEditInputState.repeatOverride = vim.insertModeRepeat; + } + delete vim.insertModeRepeat; + vim.insertMode = false; + cm.setCursor(cm.getCursor().line, cm.getCursor().ch-1); + cm.setOption('keyMap', 'vim'); + cm.setOption('disableInput', true); + cm.toggleOverwrite(false); // exit replace mode if we were in it. + // update the ". register before exiting insert mode + insertModeChangeRegister.setText(lastChange.changes.join('')); + CodeMirror.signal(cm, "vim-mode-change", {mode: "normal"}); + if (macroModeState.isRecording) { + logInsertModeChange(macroModeState); + } + } + + function _mapCommand(command) { + defaultKeymap.push(command); + } + + function mapCommand(keys, type, name, args, extra) { + var command = {keys: keys, type: type}; + command[type] = name; + command[type + "Args"] = args; + for (var key in extra) + command[key] = extra[key]; + _mapCommand(command); + } + + // The timeout in milliseconds for the two-character ESC keymap should be + // adjusted according to your typing speed to prevent false positives. + defineOption('insertModeEscKeysTimeout', 200, 'number'); + + CodeMirror.keyMap['vim-insert'] = { + // TODO: override navigation keys so that Esc will cancel automatic + // indentation from o, O, i_ + 'Ctrl-N': 'autocomplete', + 'Ctrl-P': 'autocomplete', + 'Enter': function(cm) { + var fn = CodeMirror.commands.newlineAndIndentContinueComment || + CodeMirror.commands.newlineAndIndent; + fn(cm); + }, + fallthrough: ['default'], + attach: attachVimMap, + detach: detachVimMap, + call: cmKey + }; + + CodeMirror.keyMap['vim-replace'] = { + 'Backspace': 'goCharLeft', + fallthrough: ['vim-insert'], + attach: attachVimMap, + detach: detachVimMap, + call: cmKey + }; + + function executeMacroRegister(cm, vim, macroModeState, registerName) { + var register = vimGlobalState.registerController.getRegister(registerName); + var keyBuffer = register.keyBuffer; + var imc = 0; + macroModeState.isPlaying = true; + macroModeState.replaySearchQueries = register.searchQueries.slice(0); + for (var i = 0; i < keyBuffer.length; i++) { + var text = keyBuffer[i]; + var match, key; + while (text) { + // Pull off one command key, which is either a single character + // or a special sequence wrapped in '<' and '>', e.g. ''. + match = (/<\w+-.+?>|<\w+>|./).exec(text); + key = match[0]; + text = text.substring(match.index + key.length); + CodeMirror.Vim.handleKey(cm, key, 'macro'); + if (vim.insertMode) { + var changes = register.insertModeChanges[imc++].changes; + vimGlobalState.macroModeState.lastInsertModeChanges.changes = + changes; + repeatInsertModeChanges(cm, changes, 1); + exitInsertMode(cm); + } + } + }; + macroModeState.isPlaying = false; + } + + function logKey(macroModeState, key) { + if (macroModeState.isPlaying) { return; } + var registerName = macroModeState.latestRegister; + var register = vimGlobalState.registerController.getRegister(registerName); + if (register) { + register.pushText(key); + } + } + + function logInsertModeChange(macroModeState) { + if (macroModeState.isPlaying) { return; } + var registerName = macroModeState.latestRegister; + var register = vimGlobalState.registerController.getRegister(registerName); + if (register) { + register.pushInsertModeChanges(macroModeState.lastInsertModeChanges); + } + } + + function logSearchQuery(macroModeState, query) { + if (macroModeState.isPlaying) { return; } + var registerName = macroModeState.latestRegister; + var register = vimGlobalState.registerController.getRegister(registerName); + if (register) { + register.pushSearchQuery(query); + } + } + + /** + * Listens for changes made in insert mode. + * Should only be active in insert mode. + */ + function onChange(_cm, changeObj) { + var macroModeState = vimGlobalState.macroModeState; + var lastChange = macroModeState.lastInsertModeChanges; + if (!macroModeState.isPlaying) { + while(changeObj) { + lastChange.expectCursorActivityForChange = true; + if (changeObj.origin == '+input' || changeObj.origin == 'paste' + || changeObj.origin === undefined /* only in testing */) { + var text = changeObj.text.join('\n'); + lastChange.changes.push(text); + } + // Change objects may be chained with next. + changeObj = changeObj.next; + } + } + } + + /** + * Listens for any kind of cursor activity on CodeMirror. + */ + function onCursorActivity(cm) { + var vim = cm.state.vim; + if (vim.insertMode) { + // Tracking cursor activity in insert mode (for macro support). + var macroModeState = vimGlobalState.macroModeState; + if (macroModeState.isPlaying) { return; } + var lastChange = macroModeState.lastInsertModeChanges; + if (lastChange.expectCursorActivityForChange) { + lastChange.expectCursorActivityForChange = false; + } else { + // Cursor moved outside the context of an edit. Reset the change. + lastChange.changes = []; + } + } else if (!cm.curOp.isVimOp) { + handleExternalSelection(cm, vim); + } + if (vim.visualMode) { + updateFakeCursor(cm); + } + } + function updateFakeCursor(cm) { + var vim = cm.state.vim; + var from = clipCursorToContent(cm, copyCursor(vim.sel.head)); + var to = offsetCursor(from, 0, 1); + if (vim.fakeCursor) { + vim.fakeCursor.clear(); + } + vim.fakeCursor = cm.markText(from, to, {className: 'cm-animate-fat-cursor'}); + } + function handleExternalSelection(cm, vim) { + var anchor = cm.getCursor('anchor'); + var head = cm.getCursor('head'); + // Enter or exit visual mode to match mouse selection. + if (vim.visualMode && !cm.somethingSelected()) { + exitVisualMode(cm, false); + } else if (!vim.visualMode && !vim.insertMode && cm.somethingSelected()) { + vim.visualMode = true; + vim.visualLine = false; + CodeMirror.signal(cm, "vim-mode-change", {mode: "visual"}); + } + if (vim.visualMode) { + // Bind CodeMirror selection model to vim selection model. + // Mouse selections are considered visual characterwise. + var headOffset = !cursorIsBefore(head, anchor) ? -1 : 0; + var anchorOffset = cursorIsBefore(head, anchor) ? -1 : 0; + head = offsetCursor(head, 0, headOffset); + anchor = offsetCursor(anchor, 0, anchorOffset); + vim.sel = { + anchor: anchor, + head: head + }; + updateMark(cm, vim, '<', cursorMin(head, anchor)); + updateMark(cm, vim, '>', cursorMax(head, anchor)); + } else if (!vim.insertMode) { + // Reset lastHPos if selection was modified by something outside of vim mode e.g. by mouse. + vim.lastHPos = cm.getCursor().ch; + } + } + + /** Wrapper for special keys pressed in insert mode */ + function InsertModeKey(keyName) { + this.keyName = keyName; + } + + /** + * Handles raw key down events from the text area. + * - Should only be active in insert mode. + * - For recording deletes in insert mode. + */ + function onKeyEventTargetKeyDown(e) { + var macroModeState = vimGlobalState.macroModeState; + var lastChange = macroModeState.lastInsertModeChanges; + var keyName = CodeMirror.keyName(e); + if (!keyName) { return; } + function onKeyFound() { + lastChange.changes.push(new InsertModeKey(keyName)); + return true; + } + if (keyName.indexOf('Delete') != -1 || keyName.indexOf('Backspace') != -1) { + CodeMirror.lookupKey(keyName, 'vim-insert', onKeyFound); + } + } + + /** + * Repeats the last edit, which includes exactly 1 command and at most 1 + * insert. Operator and motion commands are read from lastEditInputState, + * while action commands are read from lastEditActionCommand. + * + * If repeatForInsert is true, then the function was called by + * exitInsertMode to repeat the insert mode changes the user just made. The + * corresponding enterInsertMode call was made with a count. + */ + function repeatLastEdit(cm, vim, repeat, repeatForInsert) { + var macroModeState = vimGlobalState.macroModeState; + macroModeState.isPlaying = true; + var isAction = !!vim.lastEditActionCommand; + var cachedInputState = vim.inputState; + function repeatCommand() { + if (isAction) { + commandDispatcher.processAction(cm, vim, vim.lastEditActionCommand); + } else { + commandDispatcher.evalInput(cm, vim); + } + } + function repeatInsert(repeat) { + if (macroModeState.lastInsertModeChanges.changes.length > 0) { + // For some reason, repeat cw in desktop VIM does not repeat + // insert mode changes. Will conform to that behavior. + repeat = !vim.lastEditActionCommand ? 1 : repeat; + var changeObject = macroModeState.lastInsertModeChanges; + repeatInsertModeChanges(cm, changeObject.changes, repeat); + } + } + vim.inputState = vim.lastEditInputState; + if (isAction && vim.lastEditActionCommand.interlaceInsertRepeat) { + // o and O repeat have to be interlaced with insert repeats so that the + // insertions appear on separate lines instead of the last line. + for (var i = 0; i < repeat; i++) { + repeatCommand(); + repeatInsert(1); + } + } else { + if (!repeatForInsert) { + // Hack to get the cursor to end up at the right place. If I is + // repeated in insert mode repeat, cursor will be 1 insert + // change set left of where it should be. + repeatCommand(); + } + repeatInsert(repeat); + } + vim.inputState = cachedInputState; + if (vim.insertMode && !repeatForInsert) { + // Don't exit insert mode twice. If repeatForInsert is set, then we + // were called by an exitInsertMode call lower on the stack. + exitInsertMode(cm); + } + macroModeState.isPlaying = false; + }; + + function repeatInsertModeChanges(cm, changes, repeat) { + function keyHandler(binding) { + if (typeof binding == 'string') { + CodeMirror.commands[binding](cm); + } else { + binding(cm); + } + return true; + } + var head = cm.getCursor('head'); + var inVisualBlock = vimGlobalState.macroModeState.lastInsertModeChanges.inVisualBlock; + if (inVisualBlock) { + // Set up block selection again for repeating the changes. + var vim = cm.state.vim; + var lastSel = vim.lastSelection; + var offset = getOffset(lastSel.anchor, lastSel.head); + selectForInsert(cm, head, offset.line + 1); + repeat = cm.listSelections().length; + cm.setCursor(head); + } + for (var i = 0; i < repeat; i++) { + if (inVisualBlock) { + cm.setCursor(offsetCursor(head, i, 0)); + } + for (var j = 0; j < changes.length; j++) { + var change = changes[j]; + if (change instanceof InsertModeKey) { + CodeMirror.lookupKey(change.keyName, 'vim-insert', keyHandler); + } else { + var cur = cm.getCursor(); + cm.replaceRange(change, cur, cur); + } + } + } + if (inVisualBlock) { + cm.setCursor(offsetCursor(head, 0, 1)); + } + } + + resetVimGlobalState(); + //}; + // Initialize Vim and make it available as an API. + CodeMirror.Vim = Vim(); + + Vim = CodeMirror.Vim; + + var specialKey = {'return':'CR',backspace:'BS','delete':'Del',esc:'Esc', + left:'Left',right:'Right',up:'Up',down:'Down',space: 'Space', + home:'Home',end:'End',pageup:'PageUp',pagedown:'PageDown', enter: 'CR' + }; + function lookupKey(hashId, key, e) { + if (key.length > 1 && key[0] == "n") { + key = key.replace("numpad", ""); + } + key = specialKey[key] || key; + var name = ''; + if (e.ctrlKey) { name += 'C-'; } + if (e.altKey) { name += 'A-'; } + if (e.shiftKey) { name += 'S-'; } + + name += key; + if (name.length > 1) { name = '<' + name + '>'; } + return name; + } + var handleKey = Vim.handleKey.bind(Vim); + Vim.handleKey = function(cm, key, origin) { + return cm.operation(function() { + return handleKey(cm, key, origin); + }, true); + } + function cloneVimState(state) { + var n = new state.constructor(); + Object.keys(state).forEach(function(key) { + var o = state[key]; + if (Array.isArray(o)) + o = o.slice(); + else if (o && typeof o == "object" && o.constructor != Object) + o = cloneVimState(o); + n[key] = o; + }); + if (state.sel) { + n.sel = { + head: state.sel.head && copyCursor(state.sel.head), + anchor: state.sel.anchor && copyCursor(state.sel.anchor) + }; + } + return n; + } + function multiSelectHandleKey(cm, key, origin) { + var isHandled = false; + var vim = Vim.maybeInitVimState_(cm); + var visualBlock = vim.visualBlock || vim.wasInVisualBlock; + if (vim.wasInVisualBlock && !cm.ace.inMultiSelectMode) { + vim.wasInVisualBlock = false; + } else if (cm.ace.inMultiSelectMode && vim.visualBlock) { + vim.wasInVisualBlock = true; + } + + if (key == '' && !vim.insertMode && !vim.visualMode && cm.ace.inMultiSelectMode) { + cm.ace.exitMultiSelectMode(); + } else if (visualBlock || !cm.ace.inMultiSelectMode || cm.ace.inVirtualSelectionMode) { + isHandled = Vim.handleKey(cm, key, origin); + } else { + var old = cloneVimState(vim); + cm.operation(function() { + cm.ace.forEachSelection(function() { + var sel = cm.ace.selection; + cm.state.vim.lastHPos = sel.$desiredColumn == null ? sel.lead.column : sel.$desiredColumn; + var head = cm.getCursor("head"); + var anchor = cm.getCursor("anchor"); + var headOffset = !cursorIsBefore(head, anchor) ? -1 : 0; + var anchorOffset = cursorIsBefore(head, anchor) ? -1 : 0; + head = offsetCursor(head, 0, headOffset); + anchor = offsetCursor(anchor, 0, anchorOffset); + cm.state.vim.sel.head = head; + cm.state.vim.sel.anchor = anchor; + + isHandled = handleKey(cm, key, origin); + sel.$desiredColumn = cm.state.vim.lastHPos == -1 ? null : cm.state.vim.lastHPos; + if (cm.virtualSelectionMode()) { + cm.state.vim = cloneVimState(old); + } + }); + if (cm.curOp.cursorActivity && !isHandled) + cm.curOp.cursorActivity = false; + }, true); + } + return isHandled; + } + exports.CodeMirror = CodeMirror; + var getVim = Vim.maybeInitVimState_; + exports.handler = { + $id: "ace/keyboard/vim", + drawCursor: function(style, pixelPos, config, sel, session) { + var vim = this.state.vim || {}; + var w = config.characterWidth; + var h = config.lineHeight; + var top = pixelPos.top; + var left = pixelPos.left; + if (!vim.insertMode) { + var isbackwards = !sel.cursor + ? session.selection.isBackwards() || session.selection.isEmpty() + : Range.comparePoints(sel.cursor, sel.start) <= 0; + if (!isbackwards && left > w) + left -= w; + } + if (!vim.insertMode && vim.status) { + h = h / 2; + top += h; + } + style.left = left + "px"; + style.top = top + "px"; + style.width = w + "px"; + style.height = h + "px"; + }, + handleKeyboard: function(data, hashId, key, keyCode, e) { + var editor = data.editor; + var cm = editor.state.cm; + var vim = getVim(cm); + if (keyCode == -1) return; + + if (key == "c" && hashId == 1) { // key == "ctrl-c" + if (!useragent.isMac && editor.getCopyText()) { + editor.once("copy", function() { + editor.selection.clearSelection(); + }); + return {command: "null", passEvent: true}; + } + } else if (!vim.insertMode) { + if (useragent.isMac && this.handleMacRepeat(data, hashId, key)) { + hashId = -1; + key = data.inputChar; + } + } + + if (hashId == -1 || hashId & 1 || hashId === 0 && key.length > 1) { + var insertMode = vim.insertMode; + var name = lookupKey(hashId, key, e || {}); + if (vim.status == null) + vim.status = ""; + var isHandled = multiSelectHandleKey(cm, name, 'user'); + vim = getVim(cm); // may be changed by multiSelectHandleKey + if (isHandled && vim.status != null) + vim.status += name; + else if (vim.status == null) + vim.status = ""; + cm._signal("changeStatus"); + if (!isHandled && (hashId != -1 || insertMode)) + return; + return {command: "null", passEvent: !isHandled}; + } + }, + attach: function(editor) { + if (!editor.state) editor.state = {}; + var cm = new CodeMirror(editor); + editor.state.cm = cm; + editor.$vimModeHandler = this; + CodeMirror.keyMap.vim.attach(cm); + getVim(cm).status = null; + cm.on('vim-command-done', function() { + if (cm.virtualSelectionMode()) return; + getVim(cm).status = null; + cm.ace._signal("changeStatus"); + cm.ace.session.markUndoGroup(); + }); + cm.on("changeStatus", function() { + cm.ace.renderer.updateCursor(); + cm.ace._signal("changeStatus"); + }); + cm.on("vim-mode-change", function() { + if (cm.virtualSelectionMode()) return; + cm.ace.renderer.setStyle("normal-mode", !getVim(cm).insertMode); + cm._signal("changeStatus"); + }); + cm.ace.renderer.setStyle("normal-mode", !getVim(cm).insertMode); + editor.renderer.$cursorLayer.drawCursor = this.drawCursor.bind(cm); + // renderVirtualNumbers.attach(editor); + this.updateMacCompositionHandlers(editor, true); + }, + detach: function(editor) { + var cm = editor.state.cm; + CodeMirror.keyMap.vim.detach(cm); + cm.destroy(); + editor.state.cm = null; + editor.$vimModeHandler = null; + editor.renderer.$cursorLayer.drawCursor = null; + editor.renderer.setStyle("normal-mode", false); + // renderVirtualNumbers.detach(editor); + this.updateMacCompositionHandlers(editor, false); + }, + getStatusText: function(editor) { + var cm = editor.state.cm; + var vim = getVim(cm); + if (vim.insertMode) + return "INSERT"; + var status = ""; + if (vim.visualMode) { + status += "VISUAL"; + if (vim.visualLine) + status += " LINE"; + if (vim.visualBlock) + status += " BLOCK"; + } + if (vim.status) + status += (status ? " " : "") + vim.status; + return status; + }, // workaround for j not repeating with `defaults write -g ApplePressAndHoldEnabled -bool true` handleMacRepeat: function(data, hashId, key) { - if (hashId == -1) { - // record key - data.inputChar = key; - data.lastEvent = "input"; - } else if (data.inputChar && data.$lastHash == hashId && data.$lastKey == key) { - // check for repeated keypress - if (data.lastEvent == "input") { - data.lastEvent = "input1"; - } else if (data.lastEvent == "input1") { - // simulate textinput - return true; - } - } else { - // reset - data.$lastHash = hashId; - data.$lastKey = key; - data.lastEvent = "keypress"; + if (hashId == -1) { + // record key + data.inputChar = key; + data.lastEvent = "input"; + } else if (data.inputChar && data.$lastHash == hashId && data.$lastKey == key) { + // check for repeated keypress + if (data.lastEvent == "input") { + data.lastEvent = "input1"; + } else if (data.lastEvent == "input1") { + // simulate textinput + return true; } + } else { + // reset + data.$lastHash = hashId; + data.$lastKey = key; + data.lastEvent = "keypress"; + } }, - - handleKeyboard: function(data, hashId, key, keyCode, e) { - // ignore command keys (shift, ctrl etc.) - if (hashId != 0 && (key == "" || key == "\x00")) - return null; - - var editor = data.editor; - - if (hashId == 1) - key = "ctrl-" + key; - if (key == "ctrl-c") { - if (!useragent.isMac && editor.getCopyText()) { - editor.once("copy", function() { - if (data.state == "start") - coreCommands.stop.exec(editor); - else - editor.selection.clearSelection(); - }); - return {command: "null", passEvent: true}; - } - return {command: coreCommands.stop}; - } else if ((key == "esc" && hashId == 0) || key == "ctrl-[") { - return {command: coreCommands.stop}; - } else if (data.state == "start") { - if (useragent.isMac && this.handleMacRepeat(data, hashId, key)) { - hashId = -1; - key = data.inputChar; - } - - if (hashId == -1 || hashId == 1 || hashId == 0 && key.length > 1) { - if (cmds.inputBuffer.idle && startCommands[key]) - return startCommands[key]; - cmds.inputBuffer.push(editor, key); - return {command: "null", passEvent: false}; - } // if no modifier || shift: wait for input. - else if (key.length == 1 && (hashId == 0 || hashId == 4)) { - return {command: "null", passEvent: true}; - } else if (key == "esc" && hashId == 0) { - return {command: coreCommands.stop}; - } + // on mac, with some keyboard layouts (e.g swedish) ^ starts composition, we don't need it in normal mode + updateMacCompositionHandlers: function(editor, enable) { + var onCompositionUpdateOverride = function(text) { + var cm = editor.state.cm; + var vim = getVim(cm); + if (!vim.insertMode) { + var el = this.textInput.getElement(); + el.blur(); + el.focus(); + el.value = text; } else { - if (key == "ctrl-w") { - return {command: "removewordleft"}; - } + this.onCompositionUpdateOrig(text); } - }, - - attach: function(editor) { - editor.on("click", exports.onCursorMove); - if (util.currentMode !== "insert") - cmds.coreCommands.stop.exec(editor); - editor.$vimModeHandler = this; - }, - - detach: function(editor) { - editor.removeListener("click", exports.onCursorMove); - util.noMode(editor); - util.currentMode = "normal"; - }, - - actions: cmds.actions, - getStatusText: function() { - if (util.currentMode == "insert") - return "INSERT"; - if (util.onVisualMode) - return (util.onVisualLineMode ? "VISUAL LINE " : "VISUAL ") + cmds.inputBuffer.status; - return cmds.inputBuffer.status; + }; + var onCompositionStartOverride = function(text) { + var cm = editor.state.cm; + var vim = getVim(cm); + if (!vim.insertMode) { + this.onCompositionStartOrig(text); + } + }; + if (enable) { + if (!editor.onCompositionUpdateOrig) { + editor.onCompositionUpdateOrig = editor.onCompositionUpdate; + editor.onCompositionUpdate = onCompositionUpdateOverride; + editor.onCompositionStartOrig = editor.onCompositionStart; + editor.onCompositionStart = onCompositionStartOverride; + } + } else { + if (editor.onCompositionUpdateOrig) { + editor.onCompositionUpdate = editor.onCompositionUpdateOrig; + editor.onCompositionUpdateOrig = null; + editor.onCompositionStart = editor.onCompositionStartOrig; + editor.onCompositionStartOrig = null; + } + } } -}; - - -exports.onCursorMove = function(e) { - cmds.onCursorMove(e.editor, e); - exports.onCursorMove.scheduled = false; -}; + }; + var renderVirtualNumbers = { + getText: function(session, row) { + return (Math.abs(session.selection.lead.row - row) || (row + 1 + (row < 9? "\xb7" : "" ))) + ""; + }, + getWidth: function(session, lastLineNumber, config) { + return session.getLength().toString().length * config.characterWidth; + }, + update: function(e, editor) { + editor.renderer.$loop.schedule(editor.renderer.CHANGE_GUTTER); + }, + attach: function(editor) { + editor.renderer.$gutterLayer.$renderer = this; + editor.on("changeSelection", this.update); + }, + detach: function(editor) { + editor.renderer.$gutterLayer.$renderer = null; + editor.off("changeSelection", this.update); + } + }; + Vim.defineOption({ + name: "wrap", + set: function(value, cm) { + if (cm) {cm.ace.setOption("wrap", value)} + }, + type: "boolean" + }, false); + Vim.defineEx('write', 'w', function() { + console.log(':write is not implemented') + }); + defaultKeymap.push( + { keys: 'zc', type: 'action', action: 'fold', actionArgs: { open: false } }, + { keys: 'zC', type: 'action', action: 'fold', actionArgs: { open: false, all: true } }, + { keys: 'zo', type: 'action', action: 'fold', actionArgs: { open: true, } }, + { keys: 'zO', type: 'action', action: 'fold', actionArgs: { open: true, all: true } }, + { keys: 'za', type: 'action', action: 'fold', actionArgs: { toggle: true } }, + { keys: 'zA', type: 'action', action: 'fold', actionArgs: { toggle: true, all: true } }, + { keys: 'zf', type: 'action', action: 'fold', actionArgs: { open: true, all: true } }, + { keys: 'zd', type: 'action', action: 'fold', actionArgs: { open: true, all: true } }, + + { keys: '', type: 'action', action: 'aceCommand', actionArgs: { name: "addCursorAbove" } }, + { keys: '', type: 'action', action: 'aceCommand', actionArgs: { name: "addCursorBelow" } }, + { keys: '', type: 'action', action: 'aceCommand', actionArgs: { name: "addCursorAboveSkipCurrent" } }, + { keys: '', type: 'action', action: 'aceCommand', actionArgs: { name: "addCursorBelowSkipCurrent" } }, + { keys: '', type: 'action', action: 'aceCommand', actionArgs: { name: "selectMoreBefore" } }, + { keys: '', type: 'action', action: 'aceCommand', actionArgs: { name: "selectMoreAfter" } }, + { keys: '', type: 'action', action: 'aceCommand', actionArgs: { name: "selectNextBefore" } }, + { keys: '', type: 'action', action: 'aceCommand', actionArgs: { name: "selectNextAfter" } } + ); + actions.aceCommand = function(cm, actionArgs, vim) { + cm.vimCmd = actionArgs; + if (cm.ace.inVirtualSelectionMode) + cm.ace.on("beforeEndOperation", delayedExecAceCommand); + else + delayedExecAceCommand(null, cm.ace); + }; + function delayedExecAceCommand(op, ace) { + ace.off("beforeEndOperation", delayedExecAceCommand); + var cmd = ace.state.cm.vimCmd; + if (cmd) { + ace.execCommand(cmd.exec ? cmd : cmd.name, cmd.args); + } + ace.curOp = ace.prevOp; + } + actions.fold = function(cm, actionArgs, vim) { + cm.ace.execCommand(['toggleFoldWidget', 'toggleFoldWidget', 'foldOther', 'unfoldall' + ][(actionArgs.all ? 2 : 0) + (actionArgs.open ? 1 : 0)]); + }, + exports.handler.defaultKeymap = defaultKeymap; + exports.handler.actions = actions; + exports.Vim = Vim; + + Vim.map("Y", "yy", "normal"); }); diff --git a/lib/ace/keyboard/vim/commands.js b/lib/ace/keyboard/vim/commands.js deleted file mode 100644 index b3c12049..00000000 --- a/lib/ace/keyboard/vim/commands.js +++ /dev/null @@ -1,601 +0,0 @@ -/* ***** 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. - * - * ***** END LICENSE BLOCK ***** */ - -define(function(require, exports, module) { - -"never use strict"; - -var lang = require("../../lib/lang"); -var util = require("./maps/util"); -var motions = require("./maps/motions"); -var operators = require("./maps/operators"); -var alias = require("./maps/aliases"); -var registers = require("./registers"); - -var NUMBER = 1; -var OPERATOR = 2; -var MOTION = 3; -var ACTION = 4; -var HMARGIN = 8; // Minimum amount of line separation between margins; - -var repeat = function repeat(fn, count, args) { - while (0 < count--) - fn.apply(this, args); -}; - -var ensureScrollMargin = function(editor) { - var renderer = editor.renderer; - var pos = renderer.$cursorLayer.getPixelPosition(); - - var top = pos.top; - - var margin = HMARGIN * renderer.layerConfig.lineHeight; - if (2 * margin > renderer.$size.scrollerHeight) - margin = renderer.$size.scrollerHeight / 2; - - if (renderer.scrollTop > top - margin) { - renderer.session.setScrollTop(top - margin); - } - - if (renderer.scrollTop + renderer.$size.scrollerHeight < top + margin + renderer.lineHeight) { - renderer.session.setScrollTop(top + margin + renderer.lineHeight - renderer.$size.scrollerHeight); - } -}; - -var actions = exports.actions = { - "z": { - param: true, - fn: function(editor, range, count, param) { - switch (param) { - case "z": - editor.renderer.alignCursor(null, 0.5); - break; - case "t": - editor.renderer.alignCursor(null, 0); - break; - case "b": - editor.renderer.alignCursor(null, 1); - break; - } - } - }, - "r": { - param: true, - fn: function(editor, range, count, param) { - if (param && param.length) { - if (param.length > 1) - param = param == "return" ? "\n" : param == "tab" ? "\t" : param; - repeat(function() { editor.insert(param); }, count || 1); - editor.navigateLeft(); - } - } - }, - "R": { - fn: function(editor, range, count, param) { - util.insertMode(editor); - editor.setOverwrite(true); - } - }, - "~": { - fn: function(editor, range, count) { - repeat(function() { - var range = editor.selection.getRange(); - if (range.isEmpty()) - range.end.column++; - var text = editor.session.getTextRange(range); - var toggled = text.toUpperCase(); - if (toggled == text) - editor.navigateRight(); - else - editor.session.replace(range, toggled); - }, count || 1); - } - }, - "*": { - fn: function(editor, range, count, param) { - editor.selection.selectWord(); - editor.findNext(); - ensureScrollMargin(editor); - var r = editor.selection.getRange(); - editor.selection.setSelectionRange(r, true); - } - }, - "#": { - fn: function(editor, range, count, param) { - editor.selection.selectWord(); - editor.findPrevious(); - ensureScrollMargin(editor); - var r = editor.selection.getRange(); - editor.selection.setSelectionRange(r, true); - } - }, - "m": { - param: true, - fn: function(editor, range, count, param) { - var s = editor.session; - var markers = s.vimMarkers || (s.vimMarkers = {}); - var c = editor.getCursorPosition(); - if (!markers[param]) { - markers[param] = editor.session.doc.createAnchor(c); - } - markers[param].setPosition(c.row, c.column, true); - } - }, - "n": { - fn: function(editor, range, count, param) { - var options = editor.getLastSearchOptions(); - options.backwards = false; - - editor.selection.moveCursorRight(); - editor.selection.clearSelection(); - editor.findNext(options); - - ensureScrollMargin(editor); - var r = editor.selection.getRange(); - r.end.row = r.start.row; - r.end.column = r.start.column; - editor.selection.setSelectionRange(r, true); - } - }, - "N": { - fn: function(editor, range, count, param) { - var options = editor.getLastSearchOptions(); - options.backwards = true; - - editor.findPrevious(options); - ensureScrollMargin(editor); - var r = editor.selection.getRange(); - r.end.row = r.start.row; - r.end.column = r.start.column; - editor.selection.setSelectionRange(r, true); - } - }, - "v": { - fn: function(editor, range, count, param) { - editor.selection.selectRight(); - util.visualMode(editor, false); - }, - acceptsMotion: true - }, - "V": { - fn: function(editor, range, count, param) { - //editor.selection.selectLine(); - //editor.selection.selectLeft(); - var row = editor.getCursorPosition().row; - editor.selection.clearSelection(); - editor.selection.moveCursorTo(row, 0); - editor.selection.selectLineEnd(); - editor.selection.visualLineStart = row; - - util.visualMode(editor, true); - }, - acceptsMotion: true - }, - "Y": { - fn: function(editor, range, count, param) { - util.copyLine(editor); - } - }, - "p": { - fn: function(editor, range, count, param) { - var defaultReg = registers._default; - - editor.setOverwrite(false); - if (defaultReg.isLine) { - var pos = editor.getCursorPosition(); - pos.column = editor.session.getLine(pos.row).length; - var text = lang.stringRepeat("\n" + defaultReg.text, count || 1); - editor.session.insert(pos, text); - editor.moveCursorTo(pos.row + 1, 0); - } - else { - editor.navigateRight(); - editor.insert(lang.stringRepeat(defaultReg.text, count || 1)); - editor.navigateLeft(); - } - editor.setOverwrite(true); - editor.selection.clearSelection(); - } - }, - "P": { - fn: function(editor, range, count, param) { - var defaultReg = registers._default; - editor.setOverwrite(false); - - if (defaultReg.isLine) { - var pos = editor.getCursorPosition(); - pos.column = 0; - var text = lang.stringRepeat(defaultReg.text + "\n", count || 1); - editor.session.insert(pos, text); - editor.moveCursorToPosition(pos); - } - else { - editor.insert(lang.stringRepeat(defaultReg.text, count || 1)); - } - editor.setOverwrite(true); - editor.selection.clearSelection(); - } - }, - "J": { - fn: function(editor, range, count, param) { - var session = editor.session; - range = editor.getSelectionRange(); - var pos = {row: range.start.row, column: range.start.column}; - count = count || range.end.row - range.start.row; - var maxRow = Math.min(pos.row + (count || 1), session.getLength() - 1); - - range.start.column = session.getLine(pos.row).length; - range.end.column = session.getLine(maxRow).length; - range.end.row = maxRow; - - var text = ""; - for (var i = pos.row; i < maxRow; i++) { - var nextLine = session.getLine(i + 1); - text += " " + /^\s*(.*)$/.exec(nextLine)[1] || ""; - } - - session.replace(range, text); - editor.moveCursorTo(pos.row, pos.column); - } - }, - "u": { - fn: function(editor, range, count, param) { - count = parseInt(count || 1, 10); - for (var i = 0; i < count; i++) { - editor.undo(); - } - editor.selection.clearSelection(); - } - }, - "ctrl-r": { - fn: function(editor, range, count, param) { - count = parseInt(count || 1, 10); - for (var i = 0; i < count; i++) { - editor.redo(); - } - editor.selection.clearSelection(); - } - }, - ":": { - fn: function(editor, range, count, param) { - var val = ":"; - if (count > 1) - val = ".,.+" + count + val; - if (editor.showCommandLine) - editor.showCommandLine(val); - } - }, - "/": { - fn: function(editor, range, count, param) { - if (editor.showCommandLine) - editor.showCommandLine("/"); - } - }, - "?": { - fn: function(editor, range, count, param) { - if (editor.showCommandLine) - editor.showCommandLine("?"); - } - }, - ".": { - fn: function(editor, range, count, param) { - util.onInsertReplaySequence = inputBuffer.lastInsertCommands; - var previous = inputBuffer.previous; - if (previous) // If there is a previous action - inputBuffer.exec(editor, previous.action, previous.param); - } - }, - "ctrl-x": { - fn: function(editor, range, count, param) { - editor.modifyNumber(-(count || 1)); - } - }, - "ctrl-a": { - fn: function(editor, range, count, param) { - editor.modifyNumber(count || 1); - } - } -}; - -var inputBuffer = exports.inputBuffer = { - accepting: [NUMBER, OPERATOR, MOTION, ACTION], - currentCmd: null, - //currentMode: 0, - currentCount: "", - status: "", - - // Types - operator: null, - motion: null, - - lastInsertCommands: [], - - push: function(editor, ch, keyId) { - var status = this.status; - var isKeyHandled = true; - this.idle = false; - var wObj = this.waitingForParam; - if (/^numpad\d+$/i.test(ch)) - ch = ch.substr(6); - - if (wObj) { - this.exec(editor, wObj, ch); - } - // If input is a number (that doesn't start with 0) - else if (!(ch === "0" && !this.currentCount.length) && - (/^\d+$/.test(ch) && this.isAccepting(NUMBER))) { - // Assuming that ch is always of type String, and not Number - this.currentCount += ch; - this.currentCmd = NUMBER; - this.accepting = [NUMBER, OPERATOR, MOTION, ACTION]; - } - else if (!this.operator && this.isAccepting(OPERATOR) && operators[ch]) { - this.operator = { - ch: ch, - count: this.getCount() - }; - this.currentCmd = OPERATOR; - this.accepting = [NUMBER, MOTION, ACTION]; - this.exec(editor, { operator: this.operator }); - } - else if (motions[ch] && this.isAccepting(MOTION)) { - this.currentCmd = MOTION; - - var ctx = { - operator: this.operator, - motion: { - ch: ch, - count: this.getCount() - } - }; - - if (motions[ch].param) - this.waitForParam(ctx); - else - this.exec(editor, ctx); - } - else if (alias[ch] && this.isAccepting(MOTION)) { - alias[ch].operator.count = this.getCount(); - this.exec(editor, alias[ch]); - } - else if (actions[ch] && this.isAccepting(ACTION)) { - var actionObj = { - action: { - fn: actions[ch].fn, - count: this.getCount() - } - }; - - if (actions[ch].param) { - this.waitForParam(actionObj); - } - else { - this.exec(editor, actionObj); - } - - if (actions[ch].acceptsMotion) - this.idle = false; - } - else if (this.operator) { - this.operator.count = this.getCount(); - this.exec(editor, { operator: this.operator }, ch); - } - else { - isKeyHandled = ch.length == 1; - this.reset(); - } - - if (this.waitingForParam || this.motion || this.operator) { - this.status += ch; - } else if (this.currentCount) { - this.status = this.currentCount; - } else if (this.status) { - this.status = ""; - } - if (this.status != status) - editor._emit("changeStatus"); - return isKeyHandled; - }, - - waitForParam: function(cmd) { - this.waitingForParam = cmd; - }, - - getCount: function() { - var count = this.currentCount; - this.currentCount = ""; - return count && parseInt(count, 10); - }, - - exec: function(editor, action, param) { - var m = action.motion; - var o = action.operator; - var a = action.action; - - if (!param) - param = action.param; - - if (o) { - this.previous = { - action: action, - param: param - }; - } - - if (o && !editor.selection.isEmpty()) { - if (operators[o.ch].selFn) { - operators[o.ch].selFn(editor, editor.getSelectionRange(), o.count, param); - this.reset(); - } - return; - } - - // There is an operator, but no motion or action. We try to pass the - // current ch to the operator to see if it responds to it (an example - // of this is the 'dd' operator). - else if (!m && !a && o && param) { - operators[o.ch].fn(editor, null, o.count, param); - this.reset(); - } - else if (m) { - var run = function(fn) { - if (fn && typeof fn === "function") { // There should always be a motion - if (m.count && !motionObj.handlesCount) - repeat(fn, m.count, [editor, null, m.count, param]); - else - fn(editor, null, m.count, param); - } - }; - - var motionObj = motions[m.ch]; - var selectable = motionObj.sel; - - if (!o) { - if ((util.onVisualMode || util.onVisualLineMode) && selectable) - run(motionObj.sel); - else - run(motionObj.nav); - } - else if (selectable) { - repeat(function() { - run(motionObj.sel); - operators[o.ch].fn(editor, editor.getSelectionRange(), o.count, param); - }, o.count || 1); - } - this.reset(); - } - else if (a) { - a.fn(editor, editor.getSelectionRange(), a.count, param); - this.reset(); - } - handleCursorMove(editor); - }, - - isAccepting: function(type) { - return this.accepting.indexOf(type) !== -1; - }, - - reset: function() { - this.operator = null; - this.motion = null; - this.currentCount = ""; - this.status = ""; - this.accepting = [NUMBER, OPERATOR, MOTION, ACTION]; - this.idle = true; - this.waitingForParam = null; - } -}; - -function setPreviousCommand(fn) { - inputBuffer.previous = { action: { action: { fn: fn } } }; -} - -exports.coreCommands = { - start: { - exec: function start(editor) { - util.insertMode(editor); - setPreviousCommand(start); - } - }, - startBeginning: { - exec: function startBeginning(editor) { - editor.navigateLineStart(); - util.insertMode(editor); - setPreviousCommand(startBeginning); - } - }, - // Stop Insert mode as soon as possible. Works like typing in - // insert mode. - stop: { - exec: function stop(editor) { - inputBuffer.reset(); - util.onVisualMode = false; - util.onVisualLineMode = false; - inputBuffer.lastInsertCommands = util.normalMode(editor); - } - }, - append: { - exec: function append(editor) { - var pos = editor.getCursorPosition(); - var lineLen = editor.session.getLine(pos.row).length; - if (lineLen) - editor.navigateRight(); - util.insertMode(editor); - setPreviousCommand(append); - } - }, - appendEnd: { - exec: function appendEnd(editor) { - editor.navigateLineEnd(); - util.insertMode(editor); - setPreviousCommand(appendEnd); - } - } -}; - -var handleCursorMove = exports.onCursorMove = function(editor, e) { - if (util.currentMode === 'insert' || handleCursorMove.running) - return; - else if(!editor.selection.isEmpty()) { - handleCursorMove.running = true; - if (util.onVisualLineMode) { - var originRow = editor.selection.visualLineStart; - var cursorRow = editor.getCursorPosition().row; - if(originRow <= cursorRow) { - var endLine = editor.session.getLine(cursorRow); - editor.selection.clearSelection(); - editor.selection.moveCursorTo(originRow, 0); - editor.selection.selectTo(cursorRow, endLine.length); - } else { - var endLine = editor.session.getLine(originRow); - editor.selection.clearSelection(); - editor.selection.moveCursorTo(originRow, endLine.length); - editor.selection.selectTo(cursorRow, 0); - } - } - handleCursorMove.running = false; - return; - } - else { - if (e && (util.onVisualLineMode || util.onVisualMode)) { - editor.selection.clearSelection(); - util.normalMode(editor); - } - - handleCursorMove.running = true; - var pos = editor.getCursorPosition(); - var lineLen = editor.session.getLine(pos.row).length; - - if (lineLen && pos.column === lineLen) - editor.navigateLeft(); - handleCursorMove.running = false; - } -}; -}); diff --git a/lib/ace/keyboard/vim/maps/motions.js b/lib/ace/keyboard/vim/maps/motions.js deleted file mode 100644 index 91c8b8af..00000000 --- a/lib/ace/keyboard/vim/maps/motions.js +++ /dev/null @@ -1,664 +0,0 @@ -/* ***** 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. - * - * ***** END LICENSE BLOCK ***** */ - - -define(function(require, exports, module) { -"use strict"; - -var util = require("./util"); - -var keepScrollPosition = function(editor, fn) { - var scrollTopRow = editor.renderer.getScrollTopRow(); - var initialRow = editor.getCursorPosition().row; - var diff = initialRow - scrollTopRow; - fn && fn.call(editor); - editor.renderer.scrollToRow(editor.getCursorPosition().row - diff); -}; - -function Motion(m) { - if (typeof m == "function") { - var getPos = m; - m = this; - } else { - var getPos = m.getPos; - } - m.nav = function(editor, range, count, param) { - var a = getPos(editor, range, count, param, false); - if (!a) - return; - editor.clearSelection(); - editor.moveCursorTo(a.row, a.column); - }; - m.sel = function(editor, range, count, param) { - var a = getPos(editor, range, count, param, true); - if (!a) - return; - editor.selection.selectTo(a.row, a.column); - }; - return m; -} - -var nonWordRe = /[\s.\/\\()\"'-:,.;<>~!@#$%^&*|+=\[\]{}`~?]/; -var wordSeparatorRe = /[.\/\\()\"'-:,.;<>~!@#$%^&*|+=\[\]{}`~?]/; -var whiteRe = /\s/; -var StringStream = function(editor, cursor) { - var sel = editor.selection; - this.range = sel.getRange(); - cursor = cursor || sel.selectionLead; - this.row = cursor.row; - this.col = cursor.column; - var line = editor.session.getLine(this.row); - var maxRow = editor.session.getLength(); - this.ch = line[this.col] || '\n'; - this.skippedLines = 0; - - this.next = function() { - this.ch = line[++this.col] || this.handleNewLine(1); - //this.debug() - return this.ch; - }; - this.prev = function() { - this.ch = line[--this.col] || this.handleNewLine(-1); - //this.debug() - return this.ch; - }; - this.peek = function(dir) { - var ch = line[this.col + dir]; - if (ch) - return ch; - if (dir == -1) - return '\n'; - if (this.col == line.length - 1) - return '\n'; - return editor.session.getLine(this.row + 1)[0] || '\n'; - }; - - this.handleNewLine = function(dir) { - if (dir == 1){ - if (this.col == line.length) - return '\n'; - if (this.row == maxRow - 1) - return ''; - this.col = 0; - this.row ++; - line = editor.session.getLine(this.row); - this.skippedLines++; - return line[0] || '\n'; - } - if (dir == -1) { - if (this.row === 0) - return ''; - this.row --; - line = editor.session.getLine(this.row); - this.col = line.length; - this.skippedLines--; - return '\n'; - } - }; - this.debug = function() { - console.log(line.substring(0, this.col)+'|'+this.ch+'\''+this.col+'\''+line.substr(this.col+1)); - }; -}; - -var Search = require("../../../search").Search; -var search = new Search(); - -function find(editor, needle, dir) { - search.$options.needle = needle; - search.$options.backwards = dir == -1; - return search.find(editor.session); -} - -var Range = require("../../../range").Range; - -var LAST_SEARCH_MOTION = {}; - -module.exports = { - "w": new Motion(function(editor) { - var str = new StringStream(editor); - - if (str.ch && wordSeparatorRe.test(str.ch)) { - while (str.ch && wordSeparatorRe.test(str.ch)) - str.next(); - } else { - while (str.ch && !nonWordRe.test(str.ch)) - str.next(); - } - while (str.ch && whiteRe.test(str.ch) && str.skippedLines < 2) - str.next(); - - str.skippedLines == 2 && str.prev(); - return {column: str.col, row: str.row}; - }), - "W": new Motion(function(editor) { - var str = new StringStream(editor); - while(str.ch && !(whiteRe.test(str.ch) && !whiteRe.test(str.peek(1))) && str.skippedLines < 2) - str.next(); - if (str.skippedLines == 2) - str.prev(); - else - str.next(); - - return {column: str.col, row: str.row}; - }), - "b": new Motion(function(editor) { - var str = new StringStream(editor); - - str.prev(); - while (str.ch && whiteRe.test(str.ch) && str.skippedLines > -2) - str.prev(); - - if (str.ch && wordSeparatorRe.test(str.ch)) { - while (str.ch && wordSeparatorRe.test(str.ch)) - str.prev(); - } else { - while (str.ch && !nonWordRe.test(str.ch)) - str.prev(); - } - str.ch && str.next(); - return {column: str.col, row: str.row}; - }), - "B": new Motion(function(editor) { - var str = new StringStream(editor); - str.prev(); - while(str.ch && !(!whiteRe.test(str.ch) && whiteRe.test(str.peek(-1))) && str.skippedLines > -2) - str.prev(); - - if (str.skippedLines == -2) - str.next(); - - return {column: str.col, row: str.row}; - }), - "e": new Motion(function(editor) { - var str = new StringStream(editor); - - str.next(); - while (str.ch && whiteRe.test(str.ch)) - str.next(); - - if (str.ch && wordSeparatorRe.test(str.ch)) { - while (str.ch && wordSeparatorRe.test(str.ch)) - str.next(); - } else { - while (str.ch && !nonWordRe.test(str.ch)) - str.next(); - } - str.ch && str.prev(); - return {column: str.col, row: str.row}; - }), - "E": new Motion(function(editor) { - var str = new StringStream(editor); - str.next(); - while(str.ch && !(!whiteRe.test(str.ch) && whiteRe.test(str.peek(1)))) - str.next(); - - return {column: str.col, row: str.row}; - }), - - "l": { - nav: function(editor) { - var pos = editor.getCursorPosition(); - var col = pos.column; - var lineLen = editor.session.getLine(pos.row).length; - if (lineLen && col !== lineLen) - editor.navigateRight(); - }, - sel: function(editor) { - var pos = editor.getCursorPosition(); - var col = pos.column; - var lineLen = editor.session.getLine(pos.row).length; - - // Solving the behavior at the end of the line due to the - // different 0 index-based colum positions in ACE. - if (lineLen && col !== lineLen) //In selection mode you can select the newline - editor.selection.selectRight(); - } - }, - "h": { - nav: function(editor) { - var pos = editor.getCursorPosition(); - if (pos.column > 0) - editor.navigateLeft(); - }, - sel: function(editor) { - var pos = editor.getCursorPosition(); - if (pos.column > 0) - editor.selection.selectLeft(); - } - }, - "H": { - nav: function(editor) { - var row = editor.renderer.getScrollTopRow(); - editor.moveCursorTo(row); - }, - sel: function(editor) { - var row = editor.renderer.getScrollTopRow(); - editor.selection.selectTo(row); - } - }, - "M": { - nav: function(editor) { - var topRow = editor.renderer.getScrollTopRow(); - var bottomRow = editor.renderer.getScrollBottomRow(); - var row = topRow + ((bottomRow - topRow) / 2); - editor.moveCursorTo(row); - }, - sel: function(editor) { - var topRow = editor.renderer.getScrollTopRow(); - var bottomRow = editor.renderer.getScrollBottomRow(); - var row = topRow + ((bottomRow - topRow) / 2); - editor.selection.selectTo(row); - } - }, - "L": { - nav: function(editor) { - var row = editor.renderer.getScrollBottomRow(); - editor.moveCursorTo(row); - }, - sel: function(editor) { - var row = editor.renderer.getScrollBottomRow(); - editor.selection.selectTo(row); - } - }, - "k": { - nav: function(editor) { - editor.navigateUp(); - }, - sel: function(editor) { - editor.selection.selectUp(); - } - }, - "j": { - nav: function(editor) { - editor.navigateDown(); - }, - sel: function(editor) { - editor.selection.selectDown(); - } - }, - - "i": { - param: true, - sel: function(editor, range, count, param) { - switch (param) { - case "w": - editor.selection.selectWord(); - break; - case "W": - editor.selection.selectAWord(); - break; - case "(": - case "{": - case "[": - var cursor = editor.getCursorPosition(); - var end = editor.session.$findClosingBracket(param, cursor, /paren/); - if (!end) - return; - var start = editor.session.$findOpeningBracket(editor.session.$brackets[param], cursor, /paren/); - if (!start) - return; - start.column ++; - editor.selection.setSelectionRange(Range.fromPoints(start, end)); - break; - case "'": - case '"': - case "/": - var end = find(editor, param, 1); - if (!end) - return; - var start = find(editor, param, -1); - if (!start) - return; - editor.selection.setSelectionRange(Range.fromPoints(start.end, end.start)); - break; - } - } - }, - "a": { - param: true, - sel: function(editor, range, count, param) { - switch (param) { - case "w": - editor.selection.selectAWord(); - break; - case "W": - editor.selection.selectAWord(); - break; - case "(": - case "{": - case "[": - var cursor = editor.getCursorPosition(); - var end = editor.session.$findClosingBracket(param, cursor, /paren/); - if (!end) - return; - var start = editor.session.$findOpeningBracket(editor.session.$brackets[param], cursor, /paren/); - if (!start) - return; - end.column ++; - editor.selection.setSelectionRange(Range.fromPoints(start, end)); - break; - case "'": - case "\"": - case "/": - var end = find(editor, param, 1); - if (!end) - return; - var start = find(editor, param, -1); - if (!start) - return; - end.column ++; - editor.selection.setSelectionRange(Range.fromPoints(start.start, end.end)); - break; - } - } - }, - - "f": new Motion({ - param: true, - handlesCount: true, - getPos: function(editor, range, count, param, isSel, isRepeat) { - if (!isRepeat) - LAST_SEARCH_MOTION = {ch: "f", param: param}; - var cursor = editor.getCursorPosition(); - var column = util.getRightNthChar(editor, cursor, param, count || 1); - - if (typeof column === "number") { - cursor.column += column + (isSel ? 2 : 1); - return cursor; - } - } - }), - "F": new Motion({ - param: true, - handlesCount: true, - getPos: function(editor, range, count, param, isSel, isRepeat) { - if (!isRepeat) - LAST_SEARCH_MOTION = {ch: "F", param: param}; - var cursor = editor.getCursorPosition(); - var column = util.getLeftNthChar(editor, cursor, param, count || 1); - - if (typeof column === "number") { - cursor.column -= column + 1; - return cursor; - } - } - }), - "t": new Motion({ - param: true, - handlesCount: true, - getPos: function(editor, range, count, param, isSel, isRepeat) { - if (!isRepeat) - LAST_SEARCH_MOTION = {ch: "t", param: param}; - var cursor = editor.getCursorPosition(); - var column = util.getRightNthChar(editor, cursor, param, count || 1); - - if (isRepeat && column == 0 && !(count > 1)) - var column = util.getRightNthChar(editor, cursor, param, 2); - - if (typeof column === "number") { - cursor.column += column + (isSel ? 1 : 0); - return cursor; - } - } - }), - "T": new Motion({ - param: true, - handlesCount: true, - getPos: function(editor, range, count, param, isSel, isRepeat) { - if (!isRepeat) - LAST_SEARCH_MOTION = {ch: "T", param: param}; - var cursor = editor.getCursorPosition(); - var column = util.getLeftNthChar(editor, cursor, param, count || 1); - - if (isRepeat && column == 0 && !(count > 1)) - var column = util.getLeftNthChar(editor, cursor, param, 2); - - if (typeof column === "number") { - cursor.column -= column; - return cursor; - } - } - }), - ";": new Motion({ - handlesCount: true, - getPos: function(editor, range, count, param, isSel) { - var ch = LAST_SEARCH_MOTION.ch; - if (!ch) - return; - return module.exports[ch].getPos( - editor, range, count, LAST_SEARCH_MOTION.param, isSel, true - ); - } - }), - ",": new Motion({ - handlesCount: true, - getPos: function(editor, range, count, param, isSel) { - var ch = LAST_SEARCH_MOTION.ch; - if (!ch) - return; - var up = ch.toUpperCase(); - ch = ch === up ? ch.toLowerCase() : up; - - return module.exports[ch].getPos( - editor, range, count, LAST_SEARCH_MOTION.param, isSel, true - ); - } - }), - - "^": { - nav: function(editor) { - editor.navigateLineStart(); - }, - sel: function(editor) { - editor.selection.selectLineStart(); - } - }, - "$": { - nav: function(editor) { - editor.navigateLineEnd(); - }, - sel: function(editor) { - editor.selection.selectLineEnd(); - } - }, - "0": new Motion(function(ed) { - return {row: ed.selection.lead.row, column: 0}; - }), - "G": { - nav: function(editor, range, count, param) { - if (!count && count !== 0) { // Stupid JS - count = editor.session.getLength(); - } - editor.gotoLine(count); - }, - sel: function(editor, range, count, param) { - if (!count && count !== 0) { // Stupid JS - count = editor.session.getLength(); - } - editor.selection.selectTo(count, 0); - } - }, - "g": { - param: true, - nav: function(editor, range, count, param) { - switch(param) { - case "m": - console.log("Middle line"); - break; - case "e": - console.log("End of prev word"); - break; - case "g": - editor.gotoLine(count || 0); - case "u": - editor.gotoLine(count || 0); - case "U": - editor.gotoLine(count || 0); - } - }, - sel: function(editor, range, count, param) { - switch(param) { - case "m": - console.log("Middle line"); - break; - case "e": - console.log("End of prev word"); - break; - case "g": - editor.selection.selectTo(count || 0, 0); - } - } - }, - "o": { - nav: function(editor, range, count, param) { - count = count || 1; - var content = ""; - while (0 < count--) - content += "\n"; - - if (content.length) { - editor.navigateLineEnd() - editor.insert(content); - util.insertMode(editor); - } - } - }, - "O": { - nav: function(editor, range, count, param) { - var row = editor.getCursorPosition().row; - count = count || 1; - var content = ""; - while (0 < count--) - content += "\n"; - - if (content.length) { - if(row > 0) { - editor.navigateUp(); - editor.navigateLineEnd() - editor.insert(content); - } else { - editor.session.insert({row: 0, column: 0}, content); - editor.navigateUp(); - } - util.insertMode(editor); - } - } - }, - "%": new Motion(function(editor){ - var brRe = /[\[\]{}()]/g; - var cursor = editor.getCursorPosition(); - var ch = editor.session.getLine(cursor.row)[cursor.column]; - if (!brRe.test(ch)) { - var range = find(editor, brRe); - if (!range) - return; - cursor = range.start; - } - var match = editor.session.findMatchingBracket({ - row: cursor.row, - column: cursor.column + 1 - }); - - return match; - }), - "{": new Motion(function(ed) { - var session = ed.session; - var row = session.selection.lead.row; - while(row > 0 && !/\S/.test(session.getLine(row))) - row--; - while(/\S/.test(session.getLine(row))) - row--; - return {column: 0, row: row}; - }), - "}": new Motion(function(ed) { - var session = ed.session; - var l = session.getLength(); - var row = session.selection.lead.row; - while(row < l && !/\S/.test(session.getLine(row))) - row++; - while(/\S/.test(session.getLine(row))) - row++; - return {column: 0, row: row}; - }), - "ctrl-d": { - nav: function(editor, range, count, param) { - editor.selection.clearSelection(); - keepScrollPosition(editor, editor.gotoPageDown); - }, - sel: function(editor, range, count, param) { - keepScrollPosition(editor, editor.selectPageDown); - } - }, - "ctrl-u": { - nav: function(editor, range, count, param) { - editor.selection.clearSelection(); - keepScrollPosition(editor, editor.gotoPageUp); - }, - sel: function(editor, range, count, param) { - keepScrollPosition(editor, editor.selectPageUp); - } - }, - "`": new Motion({ - param: true, - handlesCount: true, - getPos: function(editor, range, count, param, isSel) { - var s = editor.session; - var marker = s.vimMarkers && s.vimMarkers[param]; - if (marker) { - return marker.getPosition(); - } - } - }), - "'": new Motion({ - param: true, - handlesCount: true, - getPos: function(editor, range, count, param, isSel) { - var s = editor.session; - var marker = s.vimMarkers && s.vimMarkers[param]; - if (marker) { - var pos = marker.getPosition(); - var line = editor.session.getLine(pos.row); - pos.column = line.search(/\S/); - if (pos.column == -1) - pos.column = line.length; - return pos; - } - } - }) -}; - -module.exports.backspace = module.exports.left = module.exports.h; -module.exports.space = module.exports['return'] = module.exports.right = module.exports.l; -module.exports.up = module.exports.k; -module.exports.down = module.exports.j; -module.exports.pagedown = module.exports["ctrl-d"]; -module.exports.pageup = module.exports["ctrl-u"]; - -}); diff --git a/lib/ace/keyboard/vim/maps/operators.js b/lib/ace/keyboard/vim/maps/operators.js deleted file mode 100644 index 067562a0..00000000 --- a/lib/ace/keyboard/vim/maps/operators.js +++ /dev/null @@ -1,195 +0,0 @@ -/* ***** 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. - * - * ***** END LICENSE BLOCK ***** */ - -define(function(require, exports, module) { - -"use strict"; - -var util = require("./util"); -var registers = require("../registers"); - -module.exports = { - "d": { - selFn: function(editor, range, count, param) { - registers._default.text = editor.getCopyText(); - registers._default.isLine = util.onVisualLineMode; - if(util.onVisualLineMode) - editor.removeLines(); - else - editor.session.remove(range); - util.normalMode(editor); - }, - fn: function(editor, range, count, param) { - count = count || 1; - switch (param) { - case "d": - registers._default.text = ""; - registers._default.isLine = true; - for (var i = 0; i < count; i++) { - editor.selection.selectLine(); - registers._default.text += editor.getCopyText(); - var selRange = editor.getSelectionRange(); - // check if end of the document was reached - if (!selRange.isMultiLine()) { - var row = selRange.start.row - 1; - var col = editor.session.getLine(row).length - selRange.setStart(row, col); - editor.session.remove(selRange); - editor.selection.clearSelection(); - break; - } - editor.session.remove(selRange); - editor.selection.clearSelection(); - } - registers._default.text = registers._default.text.replace(/\n$/, ""); - break; - default: - if (range) { - editor.selection.setSelectionRange(range); - registers._default.text = editor.getCopyText(); - registers._default.isLine = false; - editor.session.remove(range); - editor.selection.clearSelection(); - } - } - } - }, - "c": { - selFn: function(editor, range, count, param) { - editor.session.remove(range); - util.insertMode(editor); - }, - fn: function(editor, range, count, param) { - count = count || 1; - switch (param) { - case "c": - for (var i = 0; i < count; i++) { - editor.removeLines(); - util.insertMode(editor); - } - - break; - default: - if (range) { - - // range.end.column ++; - editor.session.remove(range); - util.insertMode(editor); - } - } - } - }, - "y": { - selFn: function(editor, range, count, param) { - registers._default.text = editor.getCopyText(); - registers._default.isLine = util.onVisualLineMode; - editor.selection.clearSelection(); - util.normalMode(editor); - }, - fn: function(editor, range, count, param) { - count = count || 1; - switch (param) { - case "y": - var pos = editor.getCursorPosition(); - editor.selection.selectLine(); - for (var i = 0; i < count - 1; i++) { - editor.selection.moveCursorDown(); - } - registers._default.text = editor.getCopyText().replace(/\n$/, ""); - editor.selection.clearSelection(); - registers._default.isLine = true; - editor.moveCursorToPosition(pos); - break; - default: - if (range) { - var pos = editor.getCursorPosition(); - editor.selection.setSelectionRange(range); - registers._default.text = editor.getCopyText(); - registers._default.isLine = false; - editor.selection.clearSelection(); - editor.moveCursorTo(pos.row, pos.column); - } - } - } - }, - ">": { - selFn: function(editor, range, count, param) { - count = count || 1; - for (var i = 0; i < count; i++) { - editor.indent(); - } - util.normalMode(editor); - }, - fn: function(editor, range, count, param) { - count = parseInt(count || 1, 10); - switch (param) { - case ">": - var pos = editor.getCursorPosition(); - editor.selection.selectLine(); - for (var i = 0; i < count - 1; i++) { - editor.selection.moveCursorDown(); - } - editor.indent(); - editor.selection.clearSelection(); - editor.moveCursorToPosition(pos); - editor.navigateLineEnd(); - editor.navigateLineStart(); - break; - } - } - }, - "<": { - selFn: function(editor, range, count, param) { - count = count || 1; - for (var i = 0; i < count; i++) { - editor.blockOutdent(); - } - util.normalMode(editor); - }, - fn: function(editor, range, count, param) { - count = count || 1; - switch (param) { - case "<": - var pos = editor.getCursorPosition(); - editor.selection.selectLine(); - for (var i = 0; i < count - 1; i++) { - editor.selection.moveCursorDown(); - } - editor.blockOutdent(); - editor.selection.clearSelection(); - editor.moveCursorToPosition(pos); - editor.navigateLineEnd(); - editor.navigateLineStart(); - break; - } - } - } -}; -}); diff --git a/lib/ace/keyboard/vim/maps/util.js b/lib/ace/keyboard/vim/maps/util.js deleted file mode 100644 index af0e07c7..00000000 --- a/lib/ace/keyboard/vim/maps/util.js +++ /dev/null @@ -1,134 +0,0 @@ -define(function(require, exports, module) { -var registers = require("../registers"); - -var dom = require("../../../lib/dom"); -dom.importCssString('.insert-mode .ace_cursor{\ - border-left: 2px solid #333333;\ -}\ -.ace_dark.insert-mode .ace_cursor{\ - border-left: 2px solid #eeeeee;\ -}\ -.normal-mode .ace_cursor{\ - border: 0!important;\ - background-color: red;\ - opacity: 0.5;\ -}', 'vimMode'); - -module.exports = { - onVisualMode: false, - onVisualLineMode: false, - currentMode: 'normal', - noMode: function(editor) { - editor.unsetStyle('insert-mode'); - editor.unsetStyle('normal-mode'); - if (editor.commands.recording) - editor.commands.toggleRecording(editor); - editor.setOverwrite(false); - }, - insertMode: function(editor) { - this.currentMode = 'insert'; - // Switch editor to insert mode - editor.setStyle('insert-mode'); - editor.unsetStyle('normal-mode'); - - editor.setOverwrite(false); - editor.keyBinding.$data.buffer = ""; - editor.keyBinding.$data.state = "insertMode"; - this.onVisualMode = false; - this.onVisualLineMode = false; - if(this.onInsertReplaySequence) { - // Ok, we're apparently replaying ("."), so let's do it - editor.commands.macro = this.onInsertReplaySequence; - editor.commands.replay(editor); - this.onInsertReplaySequence = null; - this.normalMode(editor); - } else { - editor._emit("changeStatus"); - // Record any movements, insertions in insert mode - if(!editor.commands.recording) - editor.commands.toggleRecording(editor); - } - }, - normalMode: function(editor) { - // Switch editor to normal mode - this.currentMode = 'normal'; - - editor.unsetStyle('insert-mode'); - editor.setStyle('normal-mode'); - editor.clearSelection(); - - var pos; - if (!editor.getOverwrite()) { - pos = editor.getCursorPosition(); - if (pos.column > 0) - editor.navigateLeft(); - } - - editor.setOverwrite(true); - editor.keyBinding.$data.buffer = ""; - editor.keyBinding.$data.state = "start"; - this.onVisualMode = false; - this.onVisualLineMode = false; - editor._emit("changeStatus"); - // Save recorded keystrokes - if (editor.commands.recording) { - editor.commands.toggleRecording(editor); - return editor.commands.macro; - } - else { - return []; - } - }, - visualMode: function(editor, lineMode) { - if ( - (this.onVisualLineMode && lineMode) - || (this.onVisualMode && !lineMode) - ) { - this.normalMode(editor); - return; - } - - editor.setStyle('insert-mode'); - editor.unsetStyle('normal-mode'); - - editor._emit("changeStatus"); - if (lineMode) { - this.onVisualLineMode = true; - } else { - this.onVisualMode = true; - this.onVisualLineMode = false; - } - }, - getRightNthChar: function(editor, cursor, ch, n) { - var line = editor.getSession().getLine(cursor.row); - var matches = line.substr(cursor.column + 1).split(ch); - - return n < matches.length ? matches.slice(0, n).join(ch).length : null; - }, - getLeftNthChar: function(editor, cursor, ch, n) { - var line = editor.getSession().getLine(cursor.row); - var matches = line.substr(0, cursor.column).split(ch); - - return n < matches.length ? matches.slice(-1 * n).join(ch).length : null; - }, - toRealChar: function(ch) { - if (ch.length === 1) - return ch; - - if (/^shift-./.test(ch)) - return ch[ch.length - 1].toUpperCase(); - else - return ""; - }, - copyLine: function(editor) { - var pos = editor.getCursorPosition(); - editor.selection.clearSelection(); - editor.moveCursorTo(pos.row, pos.column); - editor.selection.selectLine(); - registers._default.isLine = true; - registers._default.text = editor.getCopyText().replace(/\n$/, ""); - editor.selection.clearSelection(); - editor.moveCursorTo(pos.row, pos.column); - } -}; -}); diff --git a/lib/ace/keyboard/vim_test.js b/lib/ace/keyboard/vim_test.js new file mode 100644 index 00000000..127f0706 --- /dev/null +++ b/lib/ace/keyboard/vim_test.js @@ -0,0 +1,4041 @@ + +if (typeof process !== "undefined") { + require("amd-loader"); +} + +define(function(require, exports, module) { + +var EditSession = require("./../edit_session").EditSession; +var Editor = require("./../editor").Editor; +var UndoManager = require("./../undomanager").UndoManager; +var MockRenderer = require("./../test/mockrenderer").MockRenderer; +var JavaScriptMode = require("./../mode/javascript").Mode; +var VirtualRenderer = require("./../virtual_renderer").VirtualRenderer; +var assert = require("./../test/assertions"); +var keys = require("./../lib/keys"); +var vim = require("./vim"); + +var el = document.createElement("div"); +el.style.position = "fixed"; +el.style.left = "20px"; +el.style.top = "30px"; +el.style.width = "500px"; +el.style.height = "300px"; +document.body.appendChild(el); + +if (!el.getBoundingClientRect) + return console.log("Skipping test: This test only runs in the browser"); + +var renderer = new VirtualRenderer(el); +editor = new Editor(renderer);//(new MockRenderer()); +editor.session.setUndoManager(new UndoManager()); +editor.session.setUseWorker(false); +editor.session.setMode(new JavaScriptMode()); +function CodeMirror(place, opts) { + if (opts.value != null) + editor.session.setValue(opts.value); + editor.setOption("indentedSoftWrap", false); + editor.setOption("wrap", opts.lineWrapping); + editor.setOption("useSoftTabs", !opts.indentWithTabs); + editor.setKeyboardHandler(null); + editor.setKeyboardHandler(vim.handler); + var cm = editor.state.cm; + cm.setOption("tabSize", opts.tabSize || 4); + cm.setOption("indentUnit", opts.indentUnit || 2); + + cm.setSize = function(w, h) { + var changed = false; + if (w && editor.w != w) { + changed = true; + el.style.width = (editor.w = w) + "px"; + } + if (h && editor.h != h) { + changed = true; + el.style.height = (editor.h = h) + "px"; + } + if (changed) + editor.resize(true); + }; + cm.setSize(500, 300); + return cm; +} +CodeMirror.defineMode = function() {} +for (var key in vim.CodeMirror) + CodeMirror[key] = vim.CodeMirror[key]; +var editor; +var i = 0; +function test(name, fn) { + // if (name != 'vim_search_history') return + // for (i = 0; i < 1000; i++) + // exports["test " + name + i] = fn; // vim_ex_global_confirm + if (i++ < 0 || /- /.test(name)) + exports["test " + name] = function() {}; + else + exports["test " + name] = fn; +} + +vim.CodeMirror.Vim.unmap("Y"); +vim.CodeMirror.Vim.defineEx('write', 'w', function(cm) { + CodeMirror.commands.save(cm); +}); + + + +// cm.setBookmark({ch: 5, line: 0}) +// cm.setBookmark({ch: 4, line: 0}) +// cm.replaceRange("x-", {ch: 4, line: 0}, {ch: 5, line: 0}); [editor.$vimModeHandler.cm.marks[0].find(),editor.$vimModeHandler.cm.marks[1].find()] + +var lineText, verbose, phantom; +var Pos = CodeMirror.Pos; +var place = document.createElement("div"); +var eqPos = assert.deepEqual; +var eq = assert.equal; +var is = assert.ok; + + +var code = '' + +' wOrd1 (#%\n' + +' word3] \n' + +'aopop pop 0 1 2 3 4\n' + +' (a) [b] {c} \n' + +'int getchar(void) {\n' + +' static char buf[BUFSIZ];\n' + +' static char *bufp = buf;\n' + +' if (n == 0) { /* buffer is empty */\n' + +' n = read(0, buf, sizeof buf);\n' + +' bufp = buf;\n' + +' }\n' + +'\n' + +' return (--n >= 0) ? (unsigned char) *bufp++ : EOF;\n' + +' \n' + +'}\n'; + +var lines = (function() { + lineText = code.split('\n'); + var ret = []; + for (var i = 0; i < lineText.length; i++) { + ret[i] = { + line: i, + length: lineText[i].length, + lineText: lineText[i], + textStart: /^\s*/.exec(lineText[i])[0].length + }; + } + return ret; +})(); +var endOfDocument = makeCursor(lines.length - 1, + lines[lines.length - 1].length); +var wordLine = lines[0]; +var bigWordLine = lines[1]; +var charLine = lines[2]; +var bracesLine = lines[3]; +var seekBraceLine = lines[4]; + +var word1 = { + start: { line: wordLine.line, ch: 1 }, + end: { line: wordLine.line, ch: 5 } +}; +var word2 = { + start: { line: wordLine.line, ch: word1.end.ch + 2 }, + end: { line: wordLine.line, ch: word1.end.ch + 4 } +}; +var word3 = { + start: { line: bigWordLine.line, ch: 1 }, + end: { line: bigWordLine.line, ch: 5 } +}; +var bigWord1 = word1; +var bigWord2 = word2; +var bigWord3 = { + start: { line: bigWordLine.line, ch: 1 }, + end: { line: bigWordLine.line, ch: 7 } +}; +var bigWord4 = { + start: { line: bigWordLine.line, ch: bigWord1.end.ch + 3 }, + end: { line: bigWordLine.line, ch: bigWord1.end.ch + 7 } +}; + +var oChars = [ { line: charLine.line, ch: 1 }, + { line: charLine.line, ch: 3 }, + { line: charLine.line, ch: 7 } ]; +var pChars = [ { line: charLine.line, ch: 2 }, + { line: charLine.line, ch: 4 }, + { line: charLine.line, ch: 6 }, + { line: charLine.line, ch: 8 } ]; +var numChars = [ { line: charLine.line, ch: 10 }, + { line: charLine.line, ch: 12 }, + { line: charLine.line, ch: 14 }, + { line: charLine.line, ch: 16 }, + { line: charLine.line, ch: 18 }]; +var parens1 = { + start: { line: bracesLine.line, ch: 1 }, + end: { line: bracesLine.line, ch: 3 } +}; +var squares1 = { + start: { line: bracesLine.line, ch: 5 }, + end: { line: bracesLine.line, ch: 7 } +}; +var curlys1 = { + start: { line: bracesLine.line, ch: 9 }, + end: { line: bracesLine.line, ch: 11 } +}; +var seekOutside = { + start: { line: seekBraceLine.line, ch: 1 }, + end: { line: seekBraceLine.line, ch: 16 } +}; +var seekInside = { + start: { line: seekBraceLine.line, ch: 14 }, + end: { line: seekBraceLine.line, ch: 11 } +}; + +function copyCursor(cur) { + return { ch: cur.ch, line: cur.line }; +} + +function forEach(arr, func) { + for (var i = 0; i < arr.length; i++) { + func(arr[i], i, arr); + } +} + +function testVim(name, run, opts, expectedFail) { + var vimOpts = { + lineNumbers: true, + vimMode: true, + showCursorWhenSelecting: true, + value: code + }; + for (var prop in opts) { + if (opts.hasOwnProperty(prop)) { + vimOpts[prop] = opts[prop]; + } + } + return test('vim_' + name, function() { + var place = document.getElementById("testground"); + var cm = CodeMirror(place, vimOpts); + var vim = CodeMirror.Vim.maybeInitVimState_(cm); + + function doKeysFn(cm) { + return function(args) { + if (args instanceof Array) { + arguments = args; + } + for (var i = 0; i < arguments.length; i++) { + CodeMirror.Vim.handleKey(cm, arguments[i]); + } + } + } + function doInsertModeKeysFn(cm) { + return function(args) { + if (args instanceof Array) { arguments = args; } + function executeHandler(handler) { + if (typeof handler == 'string') { + CodeMirror.commands[handler](cm); + } else { + handler(cm); + } + return true; + } + for (var i = 0; i < arguments.length; i++) { + var key = arguments[i]; + // Find key in keymap and handle. + var handled = CodeMirror.lookupKey(key, 'vim-insert', executeHandler); + // Record for insert mode. + if (handled == "handled" && cm.state.vim.insertMode && arguments[i] != 'Esc') { + var lastChange = CodeMirror.Vim.getVimGlobalState_().macroModeState.lastInsertModeChanges; + if (lastChange) { + lastChange.changes.push(new CodeMirror.Vim.InsertModeKey(key)); + } + } + } + } + } + function doExFn(cm) { + return function(command) { + cm.openDialog = helpers.fakeOpenDialog(command); + helpers.doKeys(':'); + } + } + function assertCursorAtFn(cm) { + return function(line, ch) { + var pos; + if (ch == null && typeof line.line == 'number') { + pos = line; + } else { + pos = makeCursor(line, ch); + } + eqPos(pos, cm.getCursor()); + } + } + function fakeOpenDialog(result) { + return function(text, callback) { + return callback(result); + } + } + function fakeOpenNotification(matcher) { + return function(text) { + matcher(text); + } + } + var helpers = { + doKeys: doKeysFn(cm), + // Warning: Only emulates keymap events, not character insertions. Use + // replaceRange to simulate character insertions. + // Keys are in CodeMirror format, NOT vim format. + doInsertModeKeys: doInsertModeKeysFn(cm), + doEx: doExFn(cm), + assertCursorAt: assertCursorAtFn(cm), + fakeOpenDialog: fakeOpenDialog, + fakeOpenNotification: fakeOpenNotification, + getRegisterController: function() { + return CodeMirror.Vim.getRegisterController(); + } + } + CodeMirror.Vim.resetVimGlobalState_(); + var successful = false; + var savedOpenNotification = cm.openNotification; + try { + run(cm, vim, helpers); + successful = true; + } finally { + cm.openNotification = savedOpenNotification; + // if (!successful || verbose) { + // place.style.visibility = "visible"; + // } else { + // place.removeChild(cm.getWrapperElement()); + // } + } + }, expectedFail); +}; +testVim('qq@q', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys('q', 'q', 'l', 'l', 'q'); + helpers.assertCursorAt(0,2); + helpers.doKeys('@', 'q'); + helpers.assertCursorAt(0,4); +}, { value: ' '}); +testVim('@@', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys('q', 'q', 'l', 'l', 'q'); + helpers.assertCursorAt(0,2); + helpers.doKeys('@', 'q'); + helpers.assertCursorAt(0,4); + helpers.doKeys('@', '@'); + helpers.assertCursorAt(0,6); +}, { value: ' '}); +var jumplistScene = ''+ + 'word\n'+ + '(word)\n'+ + '{word\n'+ + 'word.\n'+ + '\n'+ + 'word search\n'+ + '}word\n'+ + 'word\n'+ + 'word\n'; +function testJumplist(name, keys, endPos, startPos, dialog) { + endPos = makeCursor(endPos[0], endPos[1]); + startPos = makeCursor(startPos[0], startPos[1]); + testVim(name, function(cm, vim, helpers) { + CodeMirror.Vim.resetVimGlobalState_(); + if(dialog)cm.openDialog = helpers.fakeOpenDialog('word'); + cm.setCursor(startPos); + helpers.doKeys.apply(null, keys); + helpers.assertCursorAt(endPos); + }, {value: jumplistScene}); +}; +testJumplist('jumplist_H', ['H', ''], [5,2], [5,2]); +testJumplist('jumplist_M', ['M', ''], [2,2], [2,2]); +testJumplist('jumplist_L', ['L', ''], [2,2], [2,2]); +testJumplist('jumplist_[[', ['[', '[', ''], [5,2], [5,2]); +testJumplist('jumplist_]]', [']', ']', ''], [2,2], [2,2]); +testJumplist('jumplist_G', ['G', ''], [5,2], [5,2]); +testJumplist('jumplist_gg', ['g', 'g', ''], [5,2], [5,2]); +testJumplist('jumplist_%', ['%', ''], [1,5], [1,5]); +testJumplist('jumplist_{', ['{', ''], [1,5], [1,5]); +testJumplist('jumplist_}', ['}', ''], [1,5], [1,5]); +testJumplist('jumplist_\'', ['m', 'a', 'h', '\'', 'a', 'h', ''], [1,0], [1,5]); +testJumplist('jumplist_`', ['m', 'a', 'h', '`', 'a', 'h', ''], [1,5], [1,5]); +testJumplist('jumplist_*_cachedCursor', ['*', ''], [1,3], [1,3]); +testJumplist('jumplist_#_cachedCursor', ['#', ''], [1,3], [1,3]); +testJumplist('jumplist_n', ['#', 'n', ''], [1,1], [2,3]); +testJumplist('jumplist_N', ['#', 'N', ''], [1,1], [2,3]); +testJumplist('jumplist_repeat_', ['*', '*', '*', '3', ''], [2,3], [2,3]); +testJumplist('jumplist_repeat_', ['*', '*', '*', '3', '', '2', ''], [5,0], [2,3]); +testJumplist('jumplist_repeated_motion', ['3', '*', ''], [2,3], [2,3]); +testJumplist('jumplist_/', ['/', ''], [2,3], [2,3], 'dialog'); +testJumplist('jumplist_?', ['?', ''], [2,3], [2,3], 'dialog'); +testJumplist('jumplist_skip_delted_mark', + ['*', 'n', 'n', 'k', 'd', 'k', '', '', ''], + [0,2], [0,2]); +testJumplist('jumplist_skip_delted_mark', + ['*', 'n', 'n', 'k', 'd', 'k', '', '', ''], + [1,0], [0,2]); + +/** + * @param name Name of the test + * @param keys An array of keys or a string with a single key to simulate. + * @param endPos The expected end position of the cursor. + * @param startPos The position the cursor should start at, defaults to 0, 0. + */ +function testMotion(name, keys, endPos, startPos) { + testVim(name, function(cm, vim, helpers) { + if (!startPos) { + startPos = { line: 0, ch: 0 }; + } + cm.setCursor(startPos); + helpers.doKeys(keys); + helpers.assertCursorAt(endPos); + }); +}; + +function makeCursor(line, ch) { + return { line: line, ch: ch }; +}; + +function offsetCursor(cur, offsetLine, offsetCh) { + return { line: cur.line + offsetLine, ch: cur.ch + offsetCh }; +}; + +// Motion tests +testMotion('|', '|', makeCursor(0, 0), makeCursor(0,4)); +testMotion('|_repeat', ['3', '|'], makeCursor(0, 2), makeCursor(0,4)); +testMotion('h', 'h', makeCursor(0, 0), word1.start); +testMotion('h_repeat', ['3', 'h'], offsetCursor(word1.end, 0, -3), word1.end); +testMotion('l', 'l', makeCursor(0, 1)); +testMotion('l_repeat', ['2', 'l'], makeCursor(0, 2)); +testMotion('j', 'j', offsetCursor(word1.end, 1, 0), word1.end); +testMotion('j_repeat', ['2', 'j'], offsetCursor(word1.end, 2, 0), word1.end); +testMotion('j_repeat_clip', ['1000', 'j'], endOfDocument); +testMotion('k', 'k', offsetCursor(word3.end, -1, 0), word3.end); +testMotion('k_repeat', ['2', 'k'], makeCursor(0, 4), makeCursor(2, 4)); +testMotion('k_repeat_clip', ['1000', 'k'], makeCursor(0, 4), makeCursor(2, 4)); +testMotion('w', 'w', word1.start); +testMotion('w_multiple_newlines_no_space', 'w', makeCursor(12, 2), makeCursor(11, 2)); +testMotion('w_multiple_newlines_with_space', 'w', makeCursor(14, 0), makeCursor(12, 51)); +testMotion('w_repeat', ['2', 'w'], word2.start); +testMotion('w_wrap', ['w'], word3.start, word2.start); +testMotion('w_endOfDocument', 'w', endOfDocument, endOfDocument); +testMotion('w_start_to_end', ['1000', 'w'], endOfDocument, makeCursor(0, 0)); +testMotion('W', 'W', bigWord1.start); +testMotion('W_repeat', ['2', 'W'], bigWord3.start, bigWord1.start); +testMotion('e', 'e', word1.end); +testMotion('e_repeat', ['2', 'e'], word2.end); +testMotion('e_wrap', 'e', word3.end, word2.end); +testMotion('e_endOfDocument', 'e', endOfDocument, endOfDocument); +testMotion('e_start_to_end', ['1000', 'e'], endOfDocument, makeCursor(0, 0)); +testMotion('b', 'b', word3.start, word3.end); +testMotion('b_repeat', ['2', 'b'], word2.start, word3.end); +testMotion('b_wrap', 'b', word2.start, word3.start); +testMotion('b_startOfDocument', 'b', makeCursor(0, 0), makeCursor(0, 0)); +testMotion('b_end_to_start', ['1000', 'b'], makeCursor(0, 0), endOfDocument); +testMotion('ge', ['g', 'e'], word2.end, word3.end); +testMotion('ge_repeat', ['2', 'g', 'e'], word1.end, word3.start); +testMotion('ge_wrap', ['g', 'e'], word2.end, word3.start); +testMotion('ge_startOfDocument', ['g', 'e'], makeCursor(0, 0), + makeCursor(0, 0)); +testMotion('ge_end_to_start', ['1000', 'g', 'e'], makeCursor(0, 0), endOfDocument); +testMotion('gg', ['g', 'g'], makeCursor(lines[0].line, lines[0].textStart), + makeCursor(3, 1)); +testMotion('gg_repeat', ['3', 'g', 'g'], + makeCursor(lines[2].line, lines[2].textStart)); +testMotion('G', 'G', + makeCursor(lines[lines.length - 1].line, lines[lines.length - 1].textStart), + makeCursor(3, 1)); +testMotion('G_repeat', ['3', 'G'], makeCursor(lines[2].line, + lines[2].textStart)); +// TODO: Make the test code long enough to test Ctrl-F and Ctrl-B. +testMotion('0', '0', makeCursor(0, 0), makeCursor(0, 8)); +testMotion('^', '^', makeCursor(0, lines[0].textStart), makeCursor(0, 8)); +testMotion('+', '+', makeCursor(1, lines[1].textStart), makeCursor(0, 8)); +testMotion('-', '-', makeCursor(0, lines[0].textStart), makeCursor(1, 4)); +testMotion('_', ['6','_'], makeCursor(5, lines[5].textStart), makeCursor(0, 8)); +testMotion('$', '$', makeCursor(0, lines[0].length - 1), makeCursor(0, 1)); +testMotion('$_repeat', ['2', '$'], makeCursor(1, lines[1].length - 1), + makeCursor(0, 3)); +testMotion('f', ['f', 'p'], pChars[0], makeCursor(charLine.line, 0)); +testMotion('f_repeat', ['2', 'f', 'p'], pChars[2], pChars[0]); +testMotion('f_num', ['f', '2'], numChars[2], makeCursor(charLine.line, 0)); +testMotion('t', ['t','p'], offsetCursor(pChars[0], 0, -1), + makeCursor(charLine.line, 0)); +testMotion('t_repeat', ['2', 't', 'p'], offsetCursor(pChars[2], 0, -1), + pChars[0]); +testMotion('F', ['F', 'p'], pChars[0], pChars[1]); +testMotion('F_repeat', ['2', 'F', 'p'], pChars[0], pChars[2]); +testMotion('T', ['T', 'p'], offsetCursor(pChars[0], 0, 1), pChars[1]); +testMotion('T_repeat', ['2', 'T', 'p'], offsetCursor(pChars[0], 0, 1), pChars[2]); +testMotion('%_parens', ['%'], parens1.end, parens1.start); +testMotion('%_squares', ['%'], squares1.end, squares1.start); +testMotion('%_braces', ['%'], curlys1.end, curlys1.start); +testMotion('%_seek_outside', ['%'], seekOutside.end, seekOutside.start); +testMotion('%_seek_inside', ['%'], seekInside.end, seekInside.start); +testVim('%_seek_skip', function(cm, vim, helpers) { + cm.setCursor(0,0); + helpers.doKeys(['%']); + helpers.assertCursorAt(0,9); +}, {value:'01234"("()'}); +testVim('%_skip_string', function(cm, vim, helpers) { + cm.setCursor(0,0); + helpers.doKeys(['%']); + helpers.assertCursorAt(0,4); + cm.setCursor(0,2); + helpers.doKeys(['%']); + helpers.assertCursorAt(0,0); +}, {value:'(")")'}); +(')') +testVim('%_skip_comment', function(cm, vim, helpers) { + cm.setCursor(0,0); + helpers.doKeys(['%']); + helpers.assertCursorAt(0,6); + cm.setCursor(0,3); + helpers.doKeys(['%']); + helpers.assertCursorAt(0,0); +}, {value:'(/*)*/)'}); +// Make sure that moving down after going to the end of a line always leaves you +// at the end of a line, but preserves the offset in other cases +testVim('Changing lines after Eol operation', function(cm, vim, helpers) { + cm.setCursor(0,0); + helpers.doKeys(['$']); + helpers.doKeys(['j']); + // After moving to Eol and then down, we should be at Eol of line 2 + helpers.assertCursorAt({ line: 1, ch: lines[1].length - 1 }); + helpers.doKeys(['j']); + // After moving down, we should be at Eol of line 3 + helpers.assertCursorAt({ line: 2, ch: lines[2].length - 1 }); + helpers.doKeys(['h']); + helpers.doKeys(['j']); + // After moving back one space and then down, since line 4 is shorter than line 2, we should + // be at Eol of line 2 - 1 + helpers.assertCursorAt({ line: 3, ch: lines[3].length - 1 }); + helpers.doKeys(['j']); + helpers.doKeys(['j']); + // After moving down again, since line 3 has enough characters, we should be back to the + // same place we were at on line 1 + helpers.assertCursorAt({ line: 5, ch: lines[2].length - 2 }); +}); +//making sure gj and gk recover from clipping +testVim('gj_gk_clipping', function(cm,vim,helpers){ + cm.setCursor(0, 1); + helpers.doKeys('g','j','g','j'); + helpers.assertCursorAt(2, 1); + helpers.doKeys('g','k','g','k'); + helpers.assertCursorAt(0, 1); +},{value: 'line 1\n\nline 2'}); +//testing a mix of j/k and gj/gk +testVim('j_k_and_gj_gk', function(cm,vim,helpers){ + cm.setSize(120); + cm.setCursor(0, 0); + //go to the last character on the first line + helpers.doKeys('$'); + //move up/down on the column within the wrapped line + //side-effect: cursor is not locked to eol anymore + helpers.doKeys('g','k'); + var cur=cm.getCursor(); + eq(cur.line,0); + is((cur.ch<176),'gk didn\'t move cursor back (1)'); + helpers.doKeys('g','j'); + helpers.assertCursorAt(0, 176); + //should move to character 177 on line 2 (j/k preserve character index within line) + helpers.doKeys('j'); + //due to different line wrapping, the cursor can be on a different screen-x now + //gj and gk preserve screen-x on movement, much like moveV + helpers.doKeys('3','g','k'); + cur=cm.getCursor(); + eq(cur.line,1); + is((cur.ch<176),'gk didn\'t move cursor back (2)'); + helpers.doKeys('g','j','2','g','j'); + //should return to the same character-index + helpers.doKeys('k'); + helpers.assertCursorAt(0, 176); +},{ lineWrapping:true, value: 'This line is intentially long to test movement of gj and gk over wrapped lines. I will start on the end of this line, then make a step up and back to set the origin for j and k.\nThis line is supposed to be even longer than the previous. I will jump here and make another wiggle with gj and gk, before I jump back to the line above. Both wiggles should not change my cursor\'s target character but both j/k and gj/gk change each other\'s reference position.'}); +testVim('gj_gk', function(cm, vim, helpers) { + if (phantom) return; + cm.setSize(120); + // Test top of document edge case. + cm.setCursor(0, 4); + helpers.doKeys('g', 'j'); + helpers.doKeys('10', 'g', 'k'); + helpers.assertCursorAt(0, 4); + + // Test moving down preserves column position. + helpers.doKeys('g', 'j'); + var pos1 = cm.getCursor(); + var expectedPos2 = { line: 0, ch: (pos1.ch - 4) * 2 + 4}; + helpers.doKeys('g', 'j'); + helpers.assertCursorAt(expectedPos2); + + // Move to the last character + cm.setCursor(0, 0); + // Move left to reset HSPos + helpers.doKeys('h'); + // Test bottom of document edge case. + helpers.doKeys('100', 'g', 'j'); + var endingPos = cm.getCursor(); + is(endingPos != 0, 'gj should not be on wrapped line 0'); + var topLeftCharCoords = cm.charCoords(makeCursor(0, 0)); + var endingCharCoords = cm.charCoords(endingPos); + is(topLeftCharCoords.left == endingCharCoords.left, 'gj should end up on column 0'); +},{ lineNumbers: false, lineWrapping:true, value: 'Thislineisintentiallylongtotestmovementofgjandgkoverwrappedlines.' }); +testVim('}', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys('}'); + helpers.assertCursorAt(1, 0); + cm.setCursor(0, 0); + helpers.doKeys('2', '}'); + helpers.assertCursorAt(4, 0); + cm.setCursor(0, 0); + helpers.doKeys('6', '}'); + helpers.assertCursorAt(5, 0); +}, { value: 'a\n\nb\nc\n\nd' }); +testVim('{', function(cm, vim, helpers) { + cm.setCursor(5, 0); + helpers.doKeys('{'); + helpers.assertCursorAt(4, 0); + cm.setCursor(5, 0); + helpers.doKeys('2', '{'); + helpers.assertCursorAt(1, 0); + cm.setCursor(5, 0); + helpers.doKeys('6', '{'); + helpers.assertCursorAt(0, 0); +}, { value: 'a\n\nb\nc\n\nd' }); +testVim('paragraph_motions', function(cm, vim, helpers) { + cm.setCursor(10, 0); + helpers.doKeys('{'); + helpers.assertCursorAt(4, 0); + helpers.doKeys('{'); + helpers.assertCursorAt(0, 0); + helpers.doKeys('2', '}'); + helpers.assertCursorAt(7, 0); + helpers.doKeys('2', '}'); + helpers.assertCursorAt(16, 0); + + cm.setCursor(9, 0); + helpers.doKeys('}'); + helpers.assertCursorAt(14, 0); + + cm.setCursor(6, 0); + helpers.doKeys('}'); + helpers.assertCursorAt(7, 0); + + // ip inside empty space + cm.setCursor(10, 0); + helpers.doKeys('v', 'i', 'p'); + eqPos(Pos(7, 0), cm.getCursor('anchor')); + eqPos(Pos(12, 0), cm.getCursor('head')); + helpers.doKeys('i', 'p'); + eqPos(Pos(7, 0), cm.getCursor('anchor')); + eqPos(Pos(13, 1), cm.getCursor('head')); + helpers.doKeys('2', 'i', 'p'); + eqPos(Pos(7, 0), cm.getCursor('anchor')); + eqPos(Pos(16, 1), cm.getCursor('head')); + + // should switch to visualLine mode + cm.setCursor(14, 0); + helpers.doKeys('', 'v', 'i', 'p'); + helpers.assertCursorAt(14, 0); + + cm.setCursor(14, 0); + helpers.doKeys('', 'V', 'i', 'p'); + eqPos(Pos(16, 1), cm.getCursor('head')); + + // ap inside empty space + cm.setCursor(10, 0); + helpers.doKeys('', 'v', 'a', 'p'); + eqPos(Pos(7, 0), cm.getCursor('anchor')); + eqPos(Pos(13, 1), cm.getCursor('head')); + helpers.doKeys('a', 'p'); + eqPos(Pos(7, 0), cm.getCursor('anchor')); + eqPos(Pos(16, 1), cm.getCursor('head')); + + cm.setCursor(13, 0); + helpers.doKeys('v', 'a', 'p'); + eqPos(Pos(13, 0), cm.getCursor('anchor')); + eqPos(Pos(14, 0), cm.getCursor('head')); + + cm.setCursor(16, 0); + helpers.doKeys('v', 'a', 'p'); + eqPos(Pos(14, 0), cm.getCursor('anchor')); + eqPos(Pos(16, 1), cm.getCursor('head')); + + cm.setCursor(0, 0); + helpers.doKeys('v', 'a', 'p'); + eqPos(Pos(0, 0), cm.getCursor('anchor')); + eqPos(Pos(4, 0), cm.getCursor('head')); + + cm.setCursor(0, 0); + helpers.doKeys('d', 'i', 'p'); + var register = helpers.getRegisterController().getRegister(); + eq('a\na\n', register.toString()); + is(register.linewise); + helpers.doKeys('3', 'j', 'p'); + helpers.doKeys('y', 'i', 'p'); + is(register.linewise); + eq('b\na\na\nc\n', register.toString()); +}, { value: 'a\na\n\n\n\nb\nc\n\n\n\n\n\n\nd\n\ne\nf' }); + +// Operator tests +testVim('dl', function(cm, vim, helpers) { + var curStart = makeCursor(0, 0); + cm.setCursor(curStart); + helpers.doKeys('d', 'l'); + eq('word1 ', cm.getValue()); + var register = helpers.getRegisterController().getRegister(); + eq(' ', register.toString()); + is(!register.linewise); + eqPos(curStart, cm.getCursor()); +}, { value: ' word1 ' }); +testVim('dl_eol', function(cm, vim, helpers) { + cm.setCursor(0, 6); + helpers.doKeys('d', 'l'); + eq(' word1', cm.getValue()); + var register = helpers.getRegisterController().getRegister(); + eq(' ', register.toString()); + is(!register.linewise); + helpers.assertCursorAt(0, 5); +}, { value: ' word1 ' }); +testVim('dl_repeat', function(cm, vim, helpers) { + var curStart = makeCursor(0, 0); + cm.setCursor(curStart); + helpers.doKeys('2', 'd', 'l'); + eq('ord1 ', cm.getValue()); + var register = helpers.getRegisterController().getRegister(); + eq(' w', register.toString()); + is(!register.linewise); + eqPos(curStart, cm.getCursor()); +}, { value: ' word1 ' }); +testVim('dh', function(cm, vim, helpers) { + var curStart = makeCursor(0, 3); + cm.setCursor(curStart); + helpers.doKeys('d', 'h'); + eq(' wrd1 ', cm.getValue()); + var register = helpers.getRegisterController().getRegister(); + eq('o', register.toString()); + is(!register.linewise); + eqPos(offsetCursor(curStart, 0 , -1), cm.getCursor()); +}, { value: ' word1 ' }); +testVim('dj', function(cm, vim, helpers) { + var curStart = makeCursor(0, 3); + cm.setCursor(curStart); + helpers.doKeys('d', 'j'); + eq(' word3', cm.getValue()); + var register = helpers.getRegisterController().getRegister(); + eq(' word1\nword2\n', register.toString()); + is(register.linewise); + helpers.assertCursorAt(0, 1); +}, { value: ' word1\nword2\n word3' }); +testVim('dj_end_of_document', function(cm, vim, helpers) { + var curStart = makeCursor(0, 3); + cm.setCursor(curStart); + helpers.doKeys('d', 'j'); + eq(' word1 ', cm.getValue()); + var register = helpers.getRegisterController().getRegister(); + eq('', register.toString()); + is(!register.linewise); + helpers.assertCursorAt(0, 3); +}, { value: ' word1 ' }); +testVim('dk', function(cm, vim, helpers) { + var curStart = makeCursor(1, 3); + cm.setCursor(curStart); + helpers.doKeys('d', 'k'); + eq(' word3', cm.getValue()); + var register = helpers.getRegisterController().getRegister(); + eq(' word1\nword2\n', register.toString()); + is(register.linewise); + helpers.assertCursorAt(0, 1); +}, { value: ' word1\nword2\n word3' }); +testVim('dk_start_of_document', function(cm, vim, helpers) { + var curStart = makeCursor(0, 3); + cm.setCursor(curStart); + helpers.doKeys('d', 'k'); + eq(' word1 ', cm.getValue()); + var register = helpers.getRegisterController().getRegister(); + eq('', register.toString()); + is(!register.linewise); + helpers.assertCursorAt(0, 3); +}, { value: ' word1 ' }); +testVim('dw_space', function(cm, vim, helpers) { + var curStart = makeCursor(0, 0); + cm.setCursor(curStart); + helpers.doKeys('d', 'w'); + eq('word1 ', cm.getValue()); + var register = helpers.getRegisterController().getRegister(); + eq(' ', register.toString()); + is(!register.linewise); + eqPos(curStart, cm.getCursor()); +}, { value: ' word1 ' }); +testVim('dw_word', function(cm, vim, helpers) { + var curStart = makeCursor(0, 1); + cm.setCursor(curStart); + helpers.doKeys('d', 'w'); + eq(' word2', cm.getValue()); + var register = helpers.getRegisterController().getRegister(); + eq('word1 ', register.toString()); + is(!register.linewise); + eqPos(curStart, cm.getCursor()); +}, { value: ' word1 word2' }); +testVim('dw_unicode_word', function(cm, vim, helpers) { + helpers.doKeys('d', 'w'); + eq(cm.getValue().length, 10); + helpers.doKeys('d', 'w'); + eq(cm.getValue().length, 6); + helpers.doKeys('d', 'w'); + eq(cm.getValue().length, 5); + helpers.doKeys('d', 'e'); + eq(cm.getValue().length, 2); +}, { value: ' \u0562\u0561\u0580\u0587\xbbe\xb5g ' }); +testVim('dw_only_word', function(cm, vim, helpers) { + // Test that if there is only 1 word left, dw deletes till the end of the + // line. + cm.setCursor(0, 1); + helpers.doKeys('d', 'w'); + eq(' ', cm.getValue()); + var register = helpers.getRegisterController().getRegister(); + eq('word1 ', register.toString()); + is(!register.linewise); + helpers.assertCursorAt(0, 0); +}, { value: ' word1 ' }); +testVim('dw_eol', function(cm, vim, helpers) { + // Assert that dw does not delete the newline if last word to delete is at end + // of line. + cm.setCursor(0, 1); + helpers.doKeys('d', 'w'); + eq(' \nword2', cm.getValue()); + var register = helpers.getRegisterController().getRegister(); + eq('word1', register.toString()); + is(!register.linewise); + helpers.assertCursorAt(0, 0); +}, { value: ' word1\nword2' }); +testVim('dw_eol_with_multiple_newlines', function(cm, vim, helpers) { + // Assert that dw does not delete the newline if last word to delete is at end + // of line and it is followed by multiple newlines. + cm.setCursor(0, 1); + helpers.doKeys('d', 'w'); + eq(' \n\nword2', cm.getValue()); + var register = helpers.getRegisterController().getRegister(); + eq('word1', register.toString()); + is(!register.linewise); + helpers.assertCursorAt(0, 0); +}, { value: ' word1\n\nword2' }); +testVim('dw_empty_line_followed_by_whitespace', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys('d', 'w'); + eq(' \nword', cm.getValue()); +}, { value: '\n \nword' }); +testVim('dw_empty_line_followed_by_word', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys('d', 'w'); + eq('word', cm.getValue()); +}, { value: '\nword' }); +testVim('dw_empty_line_followed_by_empty_line', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys('d', 'w'); + eq('\n', cm.getValue()); +}, { value: '\n\n' }); +testVim('dw_whitespace_followed_by_whitespace', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys('d', 'w'); + eq('\n \n', cm.getValue()); +}, { value: ' \n \n' }); +testVim('dw_whitespace_followed_by_empty_line', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys('d', 'w'); + eq('\n\n', cm.getValue()); +}, { value: ' \n\n' }); +testVim('dw_word_whitespace_word', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys('d', 'w'); + eq('\n \nword2', cm.getValue()); +}, { value: 'word1\n \nword2'}) +testVim('dw_end_of_document', function(cm, vim, helpers) { + cm.setCursor(1, 2); + helpers.doKeys('d', 'w'); + eq('\nab', cm.getValue()); +}, { value: '\nabc' }); +testVim('dw_repeat', function(cm, vim, helpers) { + // Assert that dw does delete newline if it should go to the next line, and + // that repeat works properly. + cm.setCursor(0, 1); + helpers.doKeys('d', '2', 'w'); + eq(' ', cm.getValue()); + var register = helpers.getRegisterController().getRegister(); + eq('word1\nword2', register.toString()); + is(!register.linewise); + helpers.assertCursorAt(0, 0); +}, { value: ' word1\nword2' }); +testVim('de_word_start_and_empty_lines', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys('d', 'e'); + eq('\n\n', cm.getValue()); +}, { value: 'word\n\n' }); +testVim('de_word_end_and_empty_lines', function(cm, vim, helpers) { + cm.setCursor(0, 3); + helpers.doKeys('d', 'e'); + eq('wor', cm.getValue()); +}, { value: 'word\n\n\n' }); +testVim('de_whitespace_and_empty_lines', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys('d', 'e'); + eq('', cm.getValue()); +}, { value: ' \n\n\n' }); +testVim('de_end_of_document', function(cm, vim, helpers) { + cm.setCursor(1, 2); + helpers.doKeys('d', 'e'); + eq('\nab', cm.getValue()); +}, { value: '\nabc' }); +testVim('db_empty_lines', function(cm, vim, helpers) { + cm.setCursor(2, 0); + helpers.doKeys('d', 'b'); + eq('\n\n', cm.getValue()); +}, { value: '\n\n\n' }); +testVim('db_word_start_and_empty_lines', function(cm, vim, helpers) { + cm.setCursor(2, 0); + helpers.doKeys('d', 'b'); + eq('\nword', cm.getValue()); +}, { value: '\n\nword' }); +testVim('db_word_end_and_empty_lines', function(cm, vim, helpers) { + cm.setCursor(2, 3); + helpers.doKeys('d', 'b'); + eq('\n\nd', cm.getValue()); +}, { value: '\n\nword' }); +testVim('db_whitespace_and_empty_lines', function(cm, vim, helpers) { + cm.setCursor(2, 0); + helpers.doKeys('d', 'b'); + eq('', cm.getValue()); +}, { value: '\n \n' }); +testVim('db_start_of_document', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys('d', 'b'); + eq('abc\n', cm.getValue()); +}, { value: 'abc\n' }); +testVim('dge_empty_lines', function(cm, vim, helpers) { + cm.setCursor(1, 0); + helpers.doKeys('d', 'g', 'e'); + // Note: In real VIM the result should be '', but it's not quite consistent, + // since 2 newlines are deleted. But in the similar case of word\n\n, only + // 1 newline is deleted. We'll diverge from VIM's behavior since it's much + // easier this way. + eq('\n', cm.getValue()); +}, { value: '\n\n' }); +testVim('dge_word_and_empty_lines', function(cm, vim, helpers) { + cm.setCursor(1, 0); + helpers.doKeys('d', 'g', 'e'); + eq('wor\n', cm.getValue()); +}, { value: 'word\n\n'}); +testVim('dge_whitespace_and_empty_lines', function(cm, vim, helpers) { + cm.setCursor(2, 0); + helpers.doKeys('d', 'g', 'e'); + eq('', cm.getValue()); +}, { value: '\n \n' }); +testVim('dge_start_of_document', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys('d', 'g', 'e'); + eq('bc\n', cm.getValue()); +}, { value: 'abc\n' }); +testVim('d_inclusive', function(cm, vim, helpers) { + // Assert that when inclusive is set, the character the cursor is on gets + // deleted too. + var curStart = makeCursor(0, 1); + cm.setCursor(curStart); + helpers.doKeys('d', 'e'); + eq(' ', cm.getValue()); + var register = helpers.getRegisterController().getRegister(); + eq('word1', register.toString()); + is(!register.linewise); + eqPos(curStart, cm.getCursor()); +}, { value: ' word1 ' }); +testVim('d_reverse', function(cm, vim, helpers) { + // Test that deleting in reverse works. + cm.setCursor(1, 0); + helpers.doKeys('d', 'b'); + eq(' word2 ', cm.getValue()); + var register = helpers.getRegisterController().getRegister(); + eq('word1\n', register.toString()); + is(!register.linewise); + helpers.assertCursorAt(0, 1); +}, { value: ' word1\nword2 ' }); +testVim('dd', function(cm, vim, helpers) { + cm.setCursor(0, 3); + var expectedBuffer = cm.getRange({ line: 0, ch: 0 }, + { line: 1, ch: 0 }); + var expectedLineCount = cm.lineCount() - 1; + helpers.doKeys('d', 'd'); + eq(expectedLineCount, cm.lineCount()); + var register = helpers.getRegisterController().getRegister(); + eq(expectedBuffer, register.toString()); + is(register.linewise); + helpers.assertCursorAt(0, lines[1].textStart); +}); +testVim('dd_prefix_repeat', function(cm, vim, helpers) { + cm.setCursor(0, 3); + var expectedBuffer = cm.getRange({ line: 0, ch: 0 }, + { line: 2, ch: 0 }); + var expectedLineCount = cm.lineCount() - 2; + helpers.doKeys('2', 'd', 'd'); + eq(expectedLineCount, cm.lineCount()); + var register = helpers.getRegisterController().getRegister(); + eq(expectedBuffer, register.toString()); + is(register.linewise); + helpers.assertCursorAt(0, lines[2].textStart); +}); +testVim('dd_motion_repeat', function(cm, vim, helpers) { + cm.setCursor(0, 3); + var expectedBuffer = cm.getRange({ line: 0, ch: 0 }, + { line: 2, ch: 0 }); + var expectedLineCount = cm.lineCount() - 2; + helpers.doKeys('d', '2', 'd'); + eq(expectedLineCount, cm.lineCount()); + var register = helpers.getRegisterController().getRegister(); + eq(expectedBuffer, register.toString()); + is(register.linewise); + helpers.assertCursorAt(0, lines[2].textStart); +}); +testVim('dd_multiply_repeat', function(cm, vim, helpers) { + cm.setCursor(0, 3); + var expectedBuffer = cm.getRange({ line: 0, ch: 0 }, + { line: 6, ch: 0 }); + var expectedLineCount = cm.lineCount() - 6; + helpers.doKeys('2', 'd', '3', 'd'); + eq(expectedLineCount, cm.lineCount()); + var register = helpers.getRegisterController().getRegister(); + eq(expectedBuffer, register.toString()); + is(register.linewise); + helpers.assertCursorAt(0, lines[6].textStart); +}); +testVim('dd_lastline', function(cm, vim, helpers) { + cm.setCursor(cm.lineCount(), 0); + var expectedLineCount = cm.lineCount() - 1; + helpers.doKeys('d', 'd'); + eq(expectedLineCount, cm.lineCount()); + helpers.assertCursorAt(cm.lineCount() - 1, 0); +}); +testVim('dd_only_line', function(cm, vim, helpers) { + cm.setCursor(0, 0); + var expectedRegister = cm.getValue() + "\n"; + helpers.doKeys('d','d'); + eq(1, cm.lineCount()); + eq('', cm.getValue()); + var register = helpers.getRegisterController().getRegister(); + eq(expectedRegister, register.toString()); +}, { value: "thisistheonlyline" }); +// Yank commands should behave the exact same as d commands, expect that nothing +// gets deleted. +testVim('yw_repeat', function(cm, vim, helpers) { + // Assert that yw does yank newline if it should go to the next line, and + // that repeat works properly. + var curStart = makeCursor(0, 1); + cm.setCursor(curStart); + helpers.doKeys('y', '2', 'w'); + eq(' word1\nword2', cm.getValue()); + var register = helpers.getRegisterController().getRegister(); + eq('word1\nword2', register.toString()); + is(!register.linewise); + eqPos(curStart, cm.getCursor()); +}, { value: ' word1\nword2' }); +testVim('yy_multiply_repeat', function(cm, vim, helpers) { + var curStart = makeCursor(0, 3); + cm.setCursor(curStart); + var expectedBuffer = cm.getRange({ line: 0, ch: 0 }, + { line: 6, ch: 0 }); + var expectedLineCount = cm.lineCount(); + helpers.doKeys('2', 'y', '3', 'y'); + eq(expectedLineCount, cm.lineCount()); + var register = helpers.getRegisterController().getRegister(); + eq(expectedBuffer, register.toString()); + is(register.linewise); + eqPos(curStart, cm.getCursor()); +}); +// Change commands behave like d commands except that it also enters insert +// mode. In addition, when the change is linewise, an additional newline is +// inserted so that insert mode starts on that line. +testVim('cw', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys('c', '2', 'w'); + eq(' word3', cm.getValue()); + helpers.assertCursorAt(0, 0); +}, { value: 'word1 word2 word3'}); +testVim('cw_repeat', function(cm, vim, helpers) { + // Assert that cw does delete newline if it should go to the next line, and + // that repeat works properly. + var curStart = makeCursor(0, 1); + cm.setCursor(curStart); + helpers.doKeys('c', '2', 'w'); + eq(' ', cm.getValue()); + var register = helpers.getRegisterController().getRegister(); + eq('word1\nword2', register.toString()); + is(!register.linewise); + eqPos(curStart, cm.getCursor()); + eq('vim-insert', cm.getOption('keyMap')); +}, { value: ' word1\nword2' }); +testVim('cc_multiply_repeat', function(cm, vim, helpers) { + cm.setCursor(0, 3); + var expectedBuffer = cm.getRange({ line: 0, ch: 0 }, + { line: 6, ch: 0 }); + var expectedLineCount = cm.lineCount() - 5; + helpers.doKeys('2', 'c', '3', 'c'); + eq(expectedLineCount, cm.lineCount()); + var register = helpers.getRegisterController().getRegister(); + eq(expectedBuffer, register.toString()); + is(register.linewise); + eq('vim-insert', cm.getOption('keyMap')); +}); +testVim('ct', function(cm, vim, helpers) { + cm.setCursor(0, 9); + helpers.doKeys('c', 't', 'w'); + eq(' word1 word3', cm.getValue()); + helpers.doKeys('', 'c', '|'); + eq(' word3', cm.getValue()); + helpers.assertCursorAt(0, 0); + helpers.doKeys('', '2', 'u', 'w', 'h'); + helpers.doKeys('c', '2', 'g', 'e'); + eq(' wordword3', cm.getValue()); +}, { value: ' word1 word2 word3'}); +testVim('cc_should_not_append_to_document', function(cm, vim, helpers) { + var expectedLineCount = cm.lineCount(); + cm.setCursor(cm.lastLine(), 0); + helpers.doKeys('c', 'c'); + eq(expectedLineCount, cm.lineCount()); +}); +function fillArray(val, times) { + var arr = []; + for (var i = 0; i < times; i++) { + arr.push(val); + } + return arr; +} +testVim('c_visual_block', function(cm, vim, helpers) { + cm.setCursor(0, 1); + helpers.doKeys('', '2', 'j', 'l', 'l', 'l', 'c'); + var replacement = fillArray('hello', 3); + cm.replaceSelections(replacement); + eq('1hello\n5hello\nahellofg', cm.getValue()); + helpers.doKeys(''); + cm.setCursor(2, 3); + helpers.doKeys('', '2', 'k', 'h', 'C'); + replacement = fillArray('world', 3); + cm.replaceSelections(replacement); + eq('1hworld\n5hworld\nahworld', cm.getValue()); +}, {value: '1234\n5678\nabcdefg'}); +testVim('c_visual_block_replay', function(cm, vim, helpers) { + cm.setCursor(0, 1); + helpers.doKeys('', '2', 'j', 'l', 'c'); + var replacement = fillArray('fo', 3); + cm.replaceSelections(replacement); + eq('1fo4\n5fo8\nafodefg', cm.getValue()); + helpers.doKeys(''); + cm.setCursor(0, 0); + helpers.doKeys('.'); + eq('foo4\nfoo8\nfoodefg', cm.getValue()); +}, {value: '1234\n5678\nabcdefg'}); + +testVim('d_visual_block', function(cm, vim, helpers) { + cm.setCursor(0, 1); + helpers.doKeys('', '2', 'j', 'l', 'l', 'l', 'd'); + eq('1\n5\nafg', cm.getValue()); +}, {value: '1234\n5678\nabcdefg'}); +testVim('D_visual_block', function(cm, vim, helpers) { + cm.setCursor(0, 1); + helpers.doKeys('', '2', 'j', 'l', 'D'); + eq('1\n5\na', cm.getValue()); +}, {value: '1234\n5678\nabcdefg'}); + +// Swapcase commands edit in place and do not modify registers. +testVim('g~w_repeat', function(cm, vim, helpers) { + // Assert that dw does delete newline if it should go to the next line, and + // that repeat works properly. + var curStart = makeCursor(0, 1); + cm.setCursor(curStart); + helpers.doKeys('g', '~', '2', 'w'); + eq(' WORD1\nWORD2', cm.getValue()); + var register = helpers.getRegisterController().getRegister(); + eq('', register.toString()); + is(!register.linewise); + eqPos(curStart, cm.getCursor()); +}, { value: ' word1\nword2' }); +testVim('g~g~', function(cm, vim, helpers) { + var curStart = makeCursor(0, 3); + cm.setCursor(curStart); + var expectedLineCount = cm.lineCount(); + var expectedValue = cm.getValue().toUpperCase(); + helpers.doKeys('2', 'g', '~', '3', 'g', '~'); + eq(expectedValue, cm.getValue()); + var register = helpers.getRegisterController().getRegister(); + eq('', register.toString()); + is(!register.linewise); + eqPos(curStart, cm.getCursor()); +}, { value: ' word1\nword2\nword3\nword4\nword5\nword6' }); +testVim('gu_and_gU', function(cm, vim, helpers) { + var curStart = makeCursor(0, 7); + var value = cm.getValue(); + cm.setCursor(curStart); + helpers.doKeys('2', 'g', 'U', 'w'); + eq(cm.getValue(), 'wa wb xX WC wd'); + eqPos(curStart, cm.getCursor()); + helpers.doKeys('2', 'g', 'u', 'w'); + eq(cm.getValue(), value); + + helpers.doKeys('2', 'g', 'U', 'B'); + eq(cm.getValue(), 'wa WB Xx wc wd'); + eqPos(makeCursor(0, 3), cm.getCursor()); + + cm.setCursor(makeCursor(0, 4)); + helpers.doKeys('g', 'u', 'i', 'w'); + eq(cm.getValue(), 'wa wb Xx wc wd'); + eqPos(makeCursor(0, 3), cm.getCursor()); + + // TODO: support gUgU guu + // eqPos(makeCursor(0, 0), cm.getCursor()); + + var register = helpers.getRegisterController().getRegister(); + eq('', register.toString()); + is(!register.linewise); +}, { value: 'wa wb xx wc wd' }); +testVim('visual_block_~', function(cm, vim, helpers) { + cm.setCursor(1, 1); + helpers.doKeys('', 'l', 'l', 'j', '~'); + helpers.assertCursorAt(1, 1); + eq('hello\nwoRLd\naBCDe', cm.getValue()); + cm.setCursor(2, 0); + helpers.doKeys('v', 'l', 'l', '~'); + helpers.assertCursorAt(2, 0); + eq('hello\nwoRLd\nAbcDe', cm.getValue()); +},{value: 'hello\nwOrld\nabcde' }); +testVim('._swapCase_visualBlock', function(cm, vim, helpers) { + helpers.doKeys('', 'j', 'j', 'l', '~'); + cm.setCursor(0, 3); + helpers.doKeys('.'); + eq('HelLO\nWorLd\nAbcdE', cm.getValue()); +},{value: 'hEllo\nwOrlD\naBcDe' }); +testVim('._delete_visualBlock', function(cm, vim, helpers) { + helpers.doKeys('', 'j', 'x'); + eq('ive\ne\nsome\nsugar', cm.getValue()); + helpers.doKeys('.'); + eq('ve\n\nsome\nsugar', cm.getValue()); + helpers.doKeys('j', 'j', '.'); + eq('ve\n\nome\nugar', cm.getValue()); + helpers.doKeys('u', '', '.'); + eq('ve\n\nme\ngar', cm.getValue()); +},{value: 'give\nme\nsome\nsugar' }); +testVim('>{motion}', function(cm, vim, helpers) { + cm.setCursor(1, 3); + var expectedLineCount = cm.lineCount(); + var expectedValue = ' word1\n word2\nword3 '; + helpers.doKeys('>', 'k'); + eq(expectedValue, cm.getValue()); + var register = helpers.getRegisterController().getRegister(); + eq('', register.toString()); + is(!register.linewise); + helpers.assertCursorAt(0, 3); +}, { value: ' word1\nword2\nword3 ', indentUnit: 2 }); +testVim('>>', function(cm, vim, helpers) { + cm.setCursor(0, 3); + var expectedLineCount = cm.lineCount(); + var expectedValue = ' word1\n word2\nword3 '; + helpers.doKeys('2', '>', '>'); + eq(expectedValue, cm.getValue()); + var register = helpers.getRegisterController().getRegister(); + eq('', register.toString()); + is(!register.linewise); + helpers.assertCursorAt(0, 3); +}, { value: ' word1\nword2\nword3 ', indentUnit: 2 }); +testVim('<{motion}', function(cm, vim, helpers) { + cm.setCursor(1, 3); + var expectedLineCount = cm.lineCount(); + var expectedValue = ' word1\nword2\nword3 '; + helpers.doKeys('<', 'k'); + eq(expectedValue, cm.getValue()); + var register = helpers.getRegisterController().getRegister(); + eq('', register.toString()); + is(!register.linewise); + helpers.assertCursorAt(0, 1); +}, { value: ' word1\n word2\nword3 ', indentUnit: 2 }); +testVim('<<', function(cm, vim, helpers) { + cm.setCursor(0, 3); + var expectedLineCount = cm.lineCount(); + var expectedValue = ' word1\nword2\nword3 '; + helpers.doKeys('2', '<', '<'); + eq(expectedValue, cm.getValue()); + var register = helpers.getRegisterController().getRegister(); + eq('', register.toString()); + is(!register.linewise); + helpers.assertCursorAt(0, 1); +}, { value: ' word1\n word2\nword3 ', indentUnit: 2 }); + +// Edit tests +function testEdit(name, before, pos, edit, after) { + return testVim(name, function(cm, vim, helpers) { + var ch = before.search(pos) + var line = before.substring(0, ch).split('\n').length - 1; + if (line) { + ch = before.substring(0, ch).split('\n').pop().length; + } + cm.setCursor(line, ch); + helpers.doKeys.apply(this, edit.split('')); + eq(after, cm.getValue()); + }, {value: before}); +} + +// These Delete tests effectively cover word-wise Change, Visual & Yank. +// Tabs are used as differentiated whitespace to catch edge cases. +// Normal word: +testEdit('diw_mid_spc', 'foo \tbAr\t baz', /A/, 'diw', 'foo \t\t baz'); +testEdit('daw_mid_spc', 'foo \tbAr\t baz', /A/, 'daw', 'foo \tbaz'); +testEdit('diw_mid_punct', 'foo \tbAr.\t baz', /A/, 'diw', 'foo \t.\t baz'); +testEdit('daw_mid_punct', 'foo \tbAr.\t baz', /A/, 'daw', 'foo.\t baz'); +testEdit('diw_mid_punct2', 'foo \t,bAr.\t baz', /A/, 'diw', 'foo \t,.\t baz'); +testEdit('daw_mid_punct2', 'foo \t,bAr.\t baz', /A/, 'daw', 'foo \t,.\t baz'); +testEdit('diw_start_spc', 'bAr \tbaz', /A/, 'diw', ' \tbaz'); +testEdit('daw_start_spc', 'bAr \tbaz', /A/, 'daw', 'baz'); +testEdit('diw_start_punct', 'bAr. \tbaz', /A/, 'diw', '. \tbaz'); +testEdit('daw_start_punct', 'bAr. \tbaz', /A/, 'daw', '. \tbaz'); +testEdit('diw_end_spc', 'foo \tbAr', /A/, 'diw', 'foo \t'); +testEdit('daw_end_spc', 'foo \tbAr', /A/, 'daw', 'foo'); +testEdit('diw_end_punct', 'foo \tbAr.', /A/, 'diw', 'foo \t.'); +testEdit('daw_end_punct', 'foo \tbAr.', /A/, 'daw', 'foo.'); +// Big word: +testEdit('diW_mid_spc', 'foo \tbAr\t baz', /A/, 'diW', 'foo \t\t baz'); +testEdit('daW_mid_spc', 'foo \tbAr\t baz', /A/, 'daW', 'foo \tbaz'); +testEdit('diW_mid_punct', 'foo \tbAr.\t baz', /A/, 'diW', 'foo \t\t baz'); +testEdit('daW_mid_punct', 'foo \tbAr.\t baz', /A/, 'daW', 'foo \tbaz'); +testEdit('diW_mid_punct2', 'foo \t,bAr.\t baz', /A/, 'diW', 'foo \t\t baz'); +testEdit('daW_mid_punct2', 'foo \t,bAr.\t baz', /A/, 'daW', 'foo \tbaz'); +testEdit('diW_start_spc', 'bAr\t baz', /A/, 'diW', '\t baz'); +testEdit('daW_start_spc', 'bAr\t baz', /A/, 'daW', 'baz'); +testEdit('diW_start_punct', 'bAr.\t baz', /A/, 'diW', '\t baz'); +testEdit('daW_start_punct', 'bAr.\t baz', /A/, 'daW', 'baz'); +testEdit('diW_end_spc', 'foo \tbAr', /A/, 'diW', 'foo \t'); +testEdit('daW_end_spc', 'foo \tbAr', /A/, 'daW', 'foo'); +testEdit('diW_end_punct', 'foo \tbAr.', /A/, 'diW', 'foo \t'); +testEdit('daW_end_punct', 'foo \tbAr.', /A/, 'daW', 'foo'); +// Deleting text objects +// Open and close on same line +testEdit('di(_open_spc', 'foo (bAr) baz', /\(/, 'di(', 'foo () baz'); +testEdit('di)_open_spc', 'foo (bAr) baz', /\(/, 'di)', 'foo () baz'); +testEdit('dib_open_spc', 'foo (bAr) baz', /\(/, 'dib', 'foo () baz'); +testEdit('da(_open_spc', 'foo (bAr) baz', /\(/, 'da(', 'foo baz'); +testEdit('da)_open_spc', 'foo (bAr) baz', /\(/, 'da)', 'foo baz'); + +testEdit('di(_middle_spc', 'foo (bAr) baz', /A/, 'di(', 'foo () baz'); +testEdit('di)_middle_spc', 'foo (bAr) baz', /A/, 'di)', 'foo () baz'); +testEdit('da(_middle_spc', 'foo (bAr) baz', /A/, 'da(', 'foo baz'); +testEdit('da)_middle_spc', 'foo (bAr) baz', /A/, 'da)', 'foo baz'); + +testEdit('di(_close_spc', 'foo (bAr) baz', /\)/, 'di(', 'foo () baz'); +testEdit('di)_close_spc', 'foo (bAr) baz', /\)/, 'di)', 'foo () baz'); +testEdit('da(_close_spc', 'foo (bAr) baz', /\)/, 'da(', 'foo baz'); +testEdit('da)_close_spc', 'foo (bAr) baz', /\)/, 'da)', 'foo baz'); + +// delete around and inner b. +testEdit('dab_on_(_should_delete_around_()block', 'o( in(abc) )', /\(a/, 'dab', 'o( in )'); + +// delete around and inner B. +testEdit('daB_on_{_should_delete_around_{}block', 'o{ in{abc} }', /{a/, 'daB', 'o{ in }'); +testEdit('diB_on_{_should_delete_inner_{}block', 'o{ in{abc} }', /{a/, 'diB', 'o{ in{} }'); + +testEdit('da{_on_{_should_delete_inner_block', 'o{ in{abc} }', /{a/, 'da{', 'o{ in }'); +testEdit('di[_on_(_should_not_delete', 'foo (bAr) baz', /\(/, 'di[', 'foo (bAr) baz'); +testEdit('di[_on_)_should_not_delete', 'foo (bAr) baz', /\)/, 'di[', 'foo (bAr) baz'); +testEdit('da[_on_(_should_not_delete', 'foo (bAr) baz', /\(/, 'da[', 'foo (bAr) baz'); +testEdit('da[_on_)_should_not_delete', 'foo (bAr) baz', /\)/, 'da[', 'foo (bAr) baz'); +testMotion('di(_outside_should_stay', ['d', 'i', '('], { line: 0, ch: 0}, { line: 0, ch: 0}); + +// Open and close on different lines, equally indented +testEdit('di{_middle_spc', 'a{\n\tbar\n}b', /r/, 'di{', 'a{}b'); +testEdit('di}_middle_spc', 'a{\n\tbar\n}b', /r/, 'di}', 'a{}b'); +testEdit('da{_middle_spc', 'a{\n\tbar\n}b', /r/, 'da{', 'ab'); +testEdit('da}_middle_spc', 'a{\n\tbar\n}b', /r/, 'da}', 'ab'); +testEdit('daB_middle_spc', 'a{\n\tbar\n}b', /r/, 'daB', 'ab'); + +// open and close on diff lines, open indented less than close +testEdit('di{_middle_spc', 'a{\n\tbar\n\t}b', /r/, 'di{', 'a{}b'); +testEdit('di}_middle_spc', 'a{\n\tbar\n\t}b', /r/, 'di}', 'a{}b'); +testEdit('da{_middle_spc', 'a{\n\tbar\n\t}b', /r/, 'da{', 'ab'); +testEdit('da}_middle_spc', 'a{\n\tbar\n\t}b', /r/, 'da}', 'ab'); + +// open and close on diff lines, open indented more than close +testEdit('di[_middle_spc', 'a\t[\n\tbar\n]b', /r/, 'di[', 'a\t[]b'); +testEdit('di]_middle_spc', 'a\t[\n\tbar\n]b', /r/, 'di]', 'a\t[]b'); +testEdit('da[_middle_spc', 'a\t[\n\tbar\n]b', /r/, 'da[', 'a\tb'); +testEdit('da]_middle_spc', 'a\t[\n\tbar\n]b', /r/, 'da]', 'a\tb'); + +function testSelection(name, before, pos, keys, sel) { + return testVim(name, function(cm, vim, helpers) { + var ch = before.search(pos) + var line = before.substring(0, ch).split('\n').length - 1; + if (line) { + ch = before.substring(0, ch).split('\n').pop().length; + } + cm.setCursor(line, ch); + helpers.doKeys.apply(this, keys.split('')); + eq(sel, cm.getSelection()); + }, {value: before}); +} +testSelection('viw_middle_spc', 'foo \tbAr\t baz', /A/, 'viw', 'bAr'); +testSelection('vaw_middle_spc', 'foo \tbAr\t baz', /A/, 'vaw', 'bAr\t '); +testSelection('viw_middle_punct', 'foo \tbAr,\t baz', /A/, 'viw', 'bAr'); +testSelection('vaW_middle_punct', 'foo \tbAr,\t baz', /A/, 'vaW', 'bAr,\t '); +testSelection('viw_start_spc', 'foo \tbAr\t baz', /b/, 'viw', 'bAr'); +testSelection('viw_end_spc', 'foo \tbAr\t baz', /r/, 'viw', 'bAr'); +testSelection('viw_eol', 'foo \tbAr', /r/, 'viw', 'bAr'); +testSelection('vi{_middle_spc', 'a{\n\tbar\n\t}b', /r/, 'vi{', '\n\tbar\n\t'); +testSelection('va{_middle_spc', 'a{\n\tbar\n\t}b', /r/, 'va{', '{\n\tbar\n\t}'); + +testVim('mouse_select', function(cm, vim, helpers) { + cm.setSelection(Pos(0, 2), Pos(0, 4), {origin: '*mouse'}); + is(cm.state.vim.visualMode); + is(!cm.state.vim.visualLine); + is(!cm.state.vim.visualBlock); + helpers.doKeys(''); + is(!cm.somethingSelected()); + helpers.doKeys('g', 'v'); + eq('cd', cm.getSelection()); +}, {value: 'abcdef'}); + +// Operator-motion tests +testVim('D', function(cm, vim, helpers) { + cm.setCursor(0, 3); + helpers.doKeys('D'); + eq(' wo\nword2\n word3', cm.getValue()); + var register = helpers.getRegisterController().getRegister(); + eq('rd1', register.toString()); + is(!register.linewise); + helpers.assertCursorAt(0, 2); +}, { value: ' word1\nword2\n word3' }); +testVim('C', function(cm, vim, helpers) { + var curStart = makeCursor(0, 3); + cm.setCursor(curStart); + helpers.doKeys('C'); + eq(' wo\nword2\n word3', cm.getValue()); + var register = helpers.getRegisterController().getRegister(); + eq('rd1', register.toString()); + is(!register.linewise); + eqPos(curStart, cm.getCursor()); + eq('vim-insert', cm.getOption('keyMap')); +}, { value: ' word1\nword2\n word3' }); +testVim('Y', function(cm, vim, helpers) { + var curStart = makeCursor(0, 3); + cm.setCursor(curStart); + helpers.doKeys('Y'); + eq(' word1\nword2\n word3', cm.getValue()); + var register = helpers.getRegisterController().getRegister(); + eq('rd1', register.toString()); + is(!register.linewise); + helpers.assertCursorAt(0, 3); +}, { value: ' word1\nword2\n word3' }); +testVim('~', function(cm, vim, helpers) { + helpers.doKeys('3', '~'); + eq('ABCdefg', cm.getValue()); + helpers.assertCursorAt(0, 3); +}, { value: 'abcdefg' }); + +// Action tests +testVim('ctrl-a', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys(''); + eq('-9', cm.getValue()); + helpers.assertCursorAt(0, 1); + helpers.doKeys('2',''); + eq('-7', cm.getValue()); +}, {value: '-10'}); +testVim('ctrl-x', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys(''); + eq('-1', cm.getValue()); + helpers.assertCursorAt(0, 1); + helpers.doKeys('2',''); + eq('-3', cm.getValue()); +}, {value: '0'}); +testVim('/ search forward', function(cm, vim, helpers) { + forEach(['', ''], function(key) { + cm.setCursor(0, 0); + helpers.doKeys(key); + helpers.assertCursorAt(0, 5); + helpers.doKeys('l'); + helpers.doKeys(key); + helpers.assertCursorAt(0, 10); + cm.setCursor(0, 11); + helpers.doKeys(key); + helpers.assertCursorAt(0, 11); + }); +}, {value: '__jmp1 jmp2 jmp'}); +testVim('a', function(cm, vim, helpers) { + cm.setCursor(0, 1); + helpers.doKeys('a'); + helpers.assertCursorAt(0, 2); + eq('vim-insert', cm.getOption('keyMap')); +}); +testVim('a_eol', function(cm, vim, helpers) { + cm.setCursor(0, lines[0].length - 1); + helpers.doKeys('a'); + helpers.assertCursorAt(0, lines[0].length); + eq('vim-insert', cm.getOption('keyMap')); +}); +testVim('A_endOfSelectedArea', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys('v', 'j', 'l'); + helpers.doKeys('A'); + helpers.assertCursorAt(1, 2); + eq('vim-insert', cm.getOption('keyMap')); +}, {value: 'foo\nbar'}); +testVim('i', function(cm, vim, helpers) { + cm.setCursor(0, 1); + helpers.doKeys('i'); + helpers.assertCursorAt(0, 1); + eq('vim-insert', cm.getOption('keyMap')); +}); +testVim('i_repeat', function(cm, vim, helpers) { + helpers.doKeys('3', 'i'); + cm.replaceRange('test', cm.getCursor()); + helpers.doKeys(''); + eq('testtesttest', cm.getValue()); + helpers.assertCursorAt(0, 11); +}, { value: '' }); +testVim('i_repeat_delete', function(cm, vim, helpers) { + cm.setCursor(0, 4); + helpers.doKeys('2', 'i'); + cm.replaceRange('z', cm.getCursor()); + helpers.doInsertModeKeys('Backspace', 'Backspace'); + helpers.doKeys(''); + eq('abe', cm.getValue()); + helpers.assertCursorAt(0, 1); +}, { value: 'abcde' }); +testVim('A', function(cm, vim, helpers) { + helpers.doKeys('A'); + helpers.assertCursorAt(0, lines[0].length); + eq('vim-insert', cm.getOption('keyMap')); +}); +testVim('A_visual_block', function(cm, vim, helpers) { + cm.setCursor(0, 1); + helpers.doKeys('', '2', 'j', 'l', 'l', 'A'); + var replacement = new Array(cm.listSelections().length+1).join('hello ').split(' '); + replacement.pop(); + cm.replaceSelections(replacement); + eq('testhello\nmehello\npleahellose', cm.getValue()); + helpers.doKeys(''); + cm.setCursor(0, 0); + helpers.doKeys('.'); + // TODO this doesn't work yet + // eq('teshellothello\nme hello hello\nplehelloahellose', cm.getValue()); +}, {value: 'test\nme\nplease'}); +testVim('I', function(cm, vim, helpers) { + cm.setCursor(0, 4); + helpers.doKeys('I'); + helpers.assertCursorAt(0, lines[0].textStart); + eq('vim-insert', cm.getOption('keyMap')); +}); +testVim('I_repeat', function(cm, vim, helpers) { + cm.setCursor(0, 1); + helpers.doKeys('3', 'I'); + cm.replaceRange('test', cm.getCursor()); + helpers.doKeys(''); + eq('testtesttestblah', cm.getValue()); + helpers.assertCursorAt(0, 11); +}, { value: 'blah' }); +testVim('I_visual_block', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys('', '2', 'j', 'l', 'l', 'I'); + var replacement = new Array(cm.listSelections().length+1).join('hello ').split(' '); + replacement.pop(); + cm.replaceSelections(replacement); + eq('hellotest\nhellome\nhelloplease', cm.getValue()); +}, {value: 'test\nme\nplease'}); +testVim('o', function(cm, vim, helpers) { + cm.setCursor(0, 4); + helpers.doKeys('o'); + eq('word1\n\nword2', cm.getValue()); + helpers.assertCursorAt(1, 0); + eq('vim-insert', cm.getOption('keyMap')); +}, { value: 'word1\nword2' }); +testVim('o_repeat', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys('3', 'o'); + cm.replaceRange('test', cm.getCursor()); + helpers.doKeys(''); + eq('\ntest\ntest\ntest', cm.getValue()); + helpers.assertCursorAt(3, 3); +}, { value: '' }); +testVim('O', function(cm, vim, helpers) { + cm.setCursor(0, 4); + helpers.doKeys('O'); + eq('\nword1\nword2', cm.getValue()); + helpers.assertCursorAt(0, 0); + eq('vim-insert', cm.getOption('keyMap')); +}, { value: 'word1\nword2' }); +testVim('J', function(cm, vim, helpers) { + cm.setCursor(0, 4); + helpers.doKeys('J'); + var expectedValue = 'word1 word2\nword3\n word4'; + eq(expectedValue, cm.getValue()); + helpers.assertCursorAt(0, expectedValue.indexOf('word2') - 1); +}, { value: 'word1 \n word2\nword3\n word4' }); +testVim('J_repeat', function(cm, vim, helpers) { + cm.setCursor(0, 4); + helpers.doKeys('3', 'J'); + var expectedValue = 'word1 word2 word3\n word4'; + eq(expectedValue, cm.getValue()); + helpers.assertCursorAt(0, expectedValue.indexOf('word3') - 1); +}, { value: 'word1 \n word2\nword3\n word4' }); +testVim('p', function(cm, vim, helpers) { + cm.setCursor(0, 1); + helpers.getRegisterController().pushText('"', 'yank', 'abc\ndef', false); + helpers.doKeys('p'); + eq('__abc\ndef_', cm.getValue()); + helpers.assertCursorAt(1, 2); +}, { value: '___' }); +testVim('p_register', function(cm, vim, helpers) { + cm.setCursor(0, 1); + helpers.getRegisterController().getRegister('a').setText('abc\ndef', false); + helpers.doKeys('"', 'a', 'p'); + eq('__abc\ndef_', cm.getValue()); + helpers.assertCursorAt(1, 2); +}, { value: '___' }); +testVim('p_wrong_register', function(cm, vim, helpers) { + cm.setCursor(0, 1); + helpers.getRegisterController().getRegister('a').setText('abc\ndef', false); + helpers.doKeys('p'); + eq('___', cm.getValue()); + helpers.assertCursorAt(0, 1); +}, { value: '___' }); +testVim('p_line', function(cm, vim, helpers) { + cm.setCursor(0, 1); + helpers.getRegisterController().pushText('"', 'yank', ' a\nd\n', true); + helpers.doKeys('2', 'p'); + eq('___\n a\nd\n a\nd', cm.getValue()); + helpers.assertCursorAt(1, 2); +}, { value: '___' }); +testVim('p_lastline', function(cm, vim, helpers) { + cm.setCursor(0, 1); + helpers.getRegisterController().pushText('"', 'yank', ' a\nd', true); + helpers.doKeys('2', 'p'); + eq('___\n a\nd\n a\nd', cm.getValue()); + helpers.assertCursorAt(1, 2); +}, { value: '___' }); +testVim(']p_first_indent_is_smaller', function(cm, vim, helpers) { + helpers.getRegisterController().pushText('"', 'yank', ' abc\n def\n', true); + helpers.doKeys(']', 'p'); + eq(' ___\n abc\n def', cm.getValue()); +}, { value: ' ___' }); +testVim(']p_first_indent_is_larger', function(cm, vim, helpers) { + helpers.getRegisterController().pushText('"', 'yank', ' abc\n def\n', true); + helpers.doKeys(']', 'p'); + eq(' ___\n abc\ndef', cm.getValue()); +}, { value: ' ___' }); +testVim(']p_with_tab_indents', function(cm, vim, helpers) { + helpers.getRegisterController().pushText('"', 'yank', '\t\tabc\n\t\t\tdef\n', true); + helpers.doKeys(']', 'p'); + eq('\t___\n\tabc\n\t\tdef', cm.getValue()); +}, { value: '\t___', indentWithTabs: true}); +testVim(']p_with_spaces_translated_to_tabs', function(cm, vim, helpers) { + helpers.getRegisterController().pushText('"', 'yank', ' abc\n def\n', true); + helpers.doKeys(']', 'p'); + eq('\t___\n\tabc\n\t\tdef', cm.getValue()); +}, { value: '\t___', indentWithTabs: true, tabSize: 2 }); +testVim('[p', function(cm, vim, helpers) { + helpers.getRegisterController().pushText('"', 'yank', ' abc\n def\n', true); + helpers.doKeys('[', 'p'); + eq(' abc\n def\n ___', cm.getValue()); +}, { value: ' ___' }); +testVim('P', function(cm, vim, helpers) { + cm.setCursor(0, 1); + helpers.getRegisterController().pushText('"', 'yank', 'abc\ndef', false); + helpers.doKeys('P'); + eq('_abc\ndef__', cm.getValue()); + helpers.assertCursorAt(1, 3); +}, { value: '___' }); +testVim('P_line', function(cm, vim, helpers) { + cm.setCursor(0, 1); + helpers.getRegisterController().pushText('"', 'yank', ' a\nd\n', true); + helpers.doKeys('2', 'P'); + eq(' a\nd\n a\nd\n___', cm.getValue()); + helpers.assertCursorAt(0, 2); +}, { value: '___' }); +testVim('r', function(cm, vim, helpers) { + cm.setCursor(0, 1); + helpers.doKeys('3', 'r', 'u'); + eq('wuuuet\nanother', cm.getValue(),'3r failed'); + helpers.assertCursorAt(0, 3); + cm.setCursor(0, 4); + helpers.doKeys('v', 'j', 'h', 'r', ''); + eq('wuuu \n her', cm.getValue(),'Replacing selection by space-characters failed'); +}, { value: 'wordet\nanother' }); +testVim('r_visual_block', function(cm, vim, helpers) { + cm.setCursor(2, 3); + helpers.doKeys('', 'k', 'k', 'h', 'h', 'r', 'l'); + eq('1lll\n5lll\nalllefg', cm.getValue()); + helpers.doKeys('', 'l', 'j', 'r', ''); + eq('1 l\n5 l\nalllefg', cm.getValue()); + cm.setCursor(2, 0); + helpers.doKeys('o'); + helpers.doKeys(''); + cm.replaceRange('\t\t', cm.getCursor()); + helpers.doKeys('', 'h', 'h', 'r', 'r'); + eq('1 l\n5 l\nalllefg\nrrrrrrrr', cm.getValue()); +}, {value: '1234\n5678\nabcdefg'}); +testVim('R', function(cm, vim, helpers) { + cm.setCursor(0, 1); + helpers.doKeys('R'); + helpers.assertCursorAt(0, 1); + eq('vim-replace', cm.getOption('keyMap')); + is(cm.state.overwrite, 'Setting overwrite state failed'); +}); +testVim('mark', function(cm, vim, helpers) { + cm.setCursor(2, 2); + helpers.doKeys('m', 't'); + cm.setCursor(0, 0); + helpers.doKeys('`', 't'); + helpers.assertCursorAt(2, 2); + cm.setCursor(2, 0); + cm.replaceRange(' h', cm.getCursor()); + cm.setCursor(0, 0); + helpers.doKeys('\'', 't'); + helpers.assertCursorAt(2, 3); +}); +testVim('jumpToMark_next', function(cm, vim, helpers) { + cm.setCursor(2, 2); + helpers.doKeys('m', 't'); + cm.setCursor(0, 0); + helpers.doKeys(']', '`'); + helpers.assertCursorAt(2, 2); + cm.setCursor(0, 0); + helpers.doKeys(']', '\''); + helpers.assertCursorAt(2, 0); +}); +testVim('jumpToMark_next_repeat', function(cm, vim, helpers) { + cm.setCursor(2, 2); + helpers.doKeys('m', 'a'); + cm.setCursor(3, 2); + helpers.doKeys('m', 'b'); + cm.setCursor(4, 2); + helpers.doKeys('m', 'c'); + cm.setCursor(0, 0); + helpers.doKeys('2', ']', '`'); + helpers.assertCursorAt(3, 2); + cm.setCursor(0, 0); + helpers.doKeys('2', ']', '\''); + helpers.assertCursorAt(3, 1); +}); +testVim('jumpToMark_next_sameline', function(cm, vim, helpers) { + cm.setCursor(2, 0); + helpers.doKeys('m', 'a'); + cm.setCursor(2, 4); + helpers.doKeys('m', 'b'); + cm.setCursor(2, 2); + helpers.doKeys(']', '`'); + helpers.assertCursorAt(2, 4); +}); +testVim('jumpToMark_next_onlyprev', function(cm, vim, helpers) { + cm.setCursor(2, 0); + helpers.doKeys('m', 'a'); + cm.setCursor(4, 0); + helpers.doKeys(']', '`'); + helpers.assertCursorAt(4, 0); +}); +testVim('jumpToMark_next_nomark', function(cm, vim, helpers) { + cm.setCursor(2, 2); + helpers.doKeys(']', '`'); + helpers.assertCursorAt(2, 2); + helpers.doKeys(']', '\''); + helpers.assertCursorAt(2, 0); +}); +testVim('jumpToMark_next_linewise_over', function(cm, vim, helpers) { + cm.setCursor(2, 2); + helpers.doKeys('m', 'a'); + cm.setCursor(3, 4); + helpers.doKeys('m', 'b'); + cm.setCursor(2, 1); + helpers.doKeys(']', '\''); + helpers.assertCursorAt(3, 1); +}); +testVim('jumpToMark_next_action', function(cm, vim, helpers) { + cm.setCursor(2, 2); + helpers.doKeys('m', 't'); + cm.setCursor(0, 0); + helpers.doKeys('d', ']', '`'); + helpers.assertCursorAt(0, 0); + var actual = cm.getLine(0); + var expected = 'pop pop 0 1 2 3 4'; + eq(actual, expected, "Deleting while jumping to the next mark failed."); +}); +testVim('jumpToMark_next_line_action', function(cm, vim, helpers) { + cm.setCursor(2, 2); + helpers.doKeys('m', 't'); + cm.setCursor(0, 0); + helpers.doKeys('d', ']', '\''); + helpers.assertCursorAt(0, 1); + var actual = cm.getLine(0); + var expected = ' (a) [b] {c} ' + eq(actual, expected, "Deleting while jumping to the next mark line failed."); +}); +testVim('jumpToMark_prev', function(cm, vim, helpers) { + cm.setCursor(2, 2); + helpers.doKeys('m', 't'); + cm.setCursor(4, 0); + helpers.doKeys('[', '`'); + helpers.assertCursorAt(2, 2); + cm.setCursor(4, 0); + helpers.doKeys('[', '\''); + helpers.assertCursorAt(2, 0); +}); +testVim('jumpToMark_prev_repeat', function(cm, vim, helpers) { + cm.setCursor(2, 2); + helpers.doKeys('m', 'a'); + cm.setCursor(3, 2); + helpers.doKeys('m', 'b'); + cm.setCursor(4, 2); + helpers.doKeys('m', 'c'); + cm.setCursor(5, 0); + helpers.doKeys('2', '[', '`'); + helpers.assertCursorAt(3, 2); + cm.setCursor(5, 0); + helpers.doKeys('2', '[', '\''); + helpers.assertCursorAt(3, 1); +}); +testVim('jumpToMark_prev_sameline', function(cm, vim, helpers) { + cm.setCursor(2, 0); + helpers.doKeys('m', 'a'); + cm.setCursor(2, 4); + helpers.doKeys('m', 'b'); + cm.setCursor(2, 2); + helpers.doKeys('[', '`'); + helpers.assertCursorAt(2, 0); +}); +testVim('jumpToMark_prev_onlynext', function(cm, vim, helpers) { + cm.setCursor(4, 4); + helpers.doKeys('m', 'a'); + cm.setCursor(2, 0); + helpers.doKeys('[', '`'); + helpers.assertCursorAt(2, 0); +}); +testVim('jumpToMark_prev_nomark', function(cm, vim, helpers) { + cm.setCursor(2, 2); + helpers.doKeys('[', '`'); + helpers.assertCursorAt(2, 2); + helpers.doKeys('[', '\''); + helpers.assertCursorAt(2, 0); +}); +testVim('jumpToMark_prev_linewise_over', function(cm, vim, helpers) { + cm.setCursor(2, 2); + helpers.doKeys('m', 'a'); + cm.setCursor(3, 4); + helpers.doKeys('m', 'b'); + cm.setCursor(3, 6); + helpers.doKeys('[', '\''); + helpers.assertCursorAt(2, 0); +}); +testVim('delmark_single', function(cm, vim, helpers) { + cm.setCursor(1, 2); + helpers.doKeys('m', 't'); + helpers.doEx('delmarks t'); + cm.setCursor(0, 0); + helpers.doKeys('`', 't'); + helpers.assertCursorAt(0, 0); +}); +testVim('delmark_range', function(cm, vim, helpers) { + cm.setCursor(1, 2); + helpers.doKeys('m', 'a'); + cm.setCursor(2, 2); + helpers.doKeys('m', 'b'); + cm.setCursor(3, 2); + helpers.doKeys('m', 'c'); + cm.setCursor(4, 2); + helpers.doKeys('m', 'd'); + cm.setCursor(5, 2); + helpers.doKeys('m', 'e'); + helpers.doEx('delmarks b-d'); + cm.setCursor(0, 0); + helpers.doKeys('`', 'a'); + helpers.assertCursorAt(1, 2); + helpers.doKeys('`', 'b'); + helpers.assertCursorAt(1, 2); + helpers.doKeys('`', 'c'); + helpers.assertCursorAt(1, 2); + helpers.doKeys('`', 'd'); + helpers.assertCursorAt(1, 2); + helpers.doKeys('`', 'e'); + helpers.assertCursorAt(5, 2); +}); +testVim('delmark_multi', function(cm, vim, helpers) { + cm.setCursor(1, 2); + helpers.doKeys('m', 'a'); + cm.setCursor(2, 2); + helpers.doKeys('m', 'b'); + cm.setCursor(3, 2); + helpers.doKeys('m', 'c'); + cm.setCursor(4, 2); + helpers.doKeys('m', 'd'); + cm.setCursor(5, 2); + helpers.doKeys('m', 'e'); + helpers.doEx('delmarks bcd'); + cm.setCursor(0, 0); + helpers.doKeys('`', 'a'); + helpers.assertCursorAt(1, 2); + helpers.doKeys('`', 'b'); + helpers.assertCursorAt(1, 2); + helpers.doKeys('`', 'c'); + helpers.assertCursorAt(1, 2); + helpers.doKeys('`', 'd'); + helpers.assertCursorAt(1, 2); + helpers.doKeys('`', 'e'); + helpers.assertCursorAt(5, 2); +}); +testVim('delmark_multi_space', function(cm, vim, helpers) { + cm.setCursor(1, 2); + helpers.doKeys('m', 'a'); + cm.setCursor(2, 2); + helpers.doKeys('m', 'b'); + cm.setCursor(3, 2); + helpers.doKeys('m', 'c'); + cm.setCursor(4, 2); + helpers.doKeys('m', 'd'); + cm.setCursor(5, 2); + helpers.doKeys('m', 'e'); + helpers.doEx('delmarks b c d'); + cm.setCursor(0, 0); + helpers.doKeys('`', 'a'); + helpers.assertCursorAt(1, 2); + helpers.doKeys('`', 'b'); + helpers.assertCursorAt(1, 2); + helpers.doKeys('`', 'c'); + helpers.assertCursorAt(1, 2); + helpers.doKeys('`', 'd'); + helpers.assertCursorAt(1, 2); + helpers.doKeys('`', 'e'); + helpers.assertCursorAt(5, 2); +}); +testVim('delmark_all', function(cm, vim, helpers) { + cm.setCursor(1, 2); + helpers.doKeys('m', 'a'); + cm.setCursor(2, 2); + helpers.doKeys('m', 'b'); + cm.setCursor(3, 2); + helpers.doKeys('m', 'c'); + cm.setCursor(4, 2); + helpers.doKeys('m', 'd'); + cm.setCursor(5, 2); + helpers.doKeys('m', 'e'); + helpers.doEx('delmarks a b-de'); + cm.setCursor(0, 0); + helpers.doKeys('`', 'a'); + helpers.assertCursorAt(0, 0); + helpers.doKeys('`', 'b'); + helpers.assertCursorAt(0, 0); + helpers.doKeys('`', 'c'); + helpers.assertCursorAt(0, 0); + helpers.doKeys('`', 'd'); + helpers.assertCursorAt(0, 0); + helpers.doKeys('`', 'e'); + helpers.assertCursorAt(0, 0); +}); +testVim('visual', function(cm, vim, helpers) { + helpers.doKeys('l', 'v', 'l', 'l'); + helpers.assertCursorAt(0, 4); + eqPos(makeCursor(0, 1), cm.getCursor('anchor')); + helpers.doKeys('d'); + eq('15', cm.getValue()); +}, { value: '12345' }); +testVim('visual_yank', function(cm, vim, helpers) { + helpers.doKeys('v', '3', 'l', 'y'); + helpers.assertCursorAt(0, 0); + helpers.doKeys('p'); + eq('aa te test for yank', cm.getValue()); +}, { value: 'a test for yank' }) +testVim('visual_w', function(cm, vim, helpers) { + helpers.doKeys('v', 'w'); + eq(cm.getSelection(), 'motion t'); +}, { value: 'motion test'}); +testVim('visual_initial_selection', function(cm, vim, helpers) { + cm.setCursor(0, 1); + helpers.doKeys('v'); + cm.getSelection('n'); +}, { value: 'init'}); +testVim('visual_crossover_left', function(cm, vim, helpers) { + cm.setCursor(0, 2); + helpers.doKeys('v', 'l', 'h', 'h'); + cm.getSelection('ro'); +}, { value: 'cross'}); +testVim('visual_crossover_left', function(cm, vim, helpers) { + cm.setCursor(0, 2); + helpers.doKeys('v', 'h', 'l', 'l'); + cm.getSelection('os'); +}, { value: 'cross'}); +testVim('visual_crossover_up', function(cm, vim, helpers) { + cm.setCursor(3, 2); + helpers.doKeys('v', 'j', 'k', 'k'); + eqPos(Pos(2, 2), cm.getCursor('head')); + eqPos(Pos(3, 3), cm.getCursor('anchor')); + helpers.doKeys('k'); + eqPos(Pos(1, 2), cm.getCursor('head')); + eqPos(Pos(3, 3), cm.getCursor('anchor')); +}, { value: 'cross\ncross\ncross\ncross\ncross\n'}); +testVim('visual_crossover_down', function(cm, vim, helpers) { + cm.setCursor(1, 2); + helpers.doKeys('v', 'k', 'j', 'j'); + eqPos(Pos(2, 3), cm.getCursor('head')); + eqPos(Pos(1, 2), cm.getCursor('anchor')); + helpers.doKeys('j'); + eqPos(Pos(3, 3), cm.getCursor('head')); + eqPos(Pos(1, 2), cm.getCursor('anchor')); +}, { value: 'cross\ncross\ncross\ncross\ncross\n'}); +testVim('visual_exit', function(cm, vim, helpers) { + helpers.doKeys('', 'l', 'j', 'j', ''); + eqPos(cm.getCursor('anchor'), cm.getCursor('head')); + eq(vim.visualMode, false); +}, { value: 'hello\nworld\nfoo' }); +testVim('visual_line', function(cm, vim, helpers) { + helpers.doKeys('l', 'V', 'l', 'j', 'j', 'd'); + eq(' 4\n 5', cm.getValue()); +}, { value: ' 1\n 2\n 3\n 4\n 5' }); +testVim('visual_block_move_to_eol', function(cm, vim, helpers) { + // moveToEol should move all block cursors to end of line + cm.setCursor(0, 0); + helpers.doKeys('', 'G', '$'); + var selections = cm.getSelections().join(); + eq('123,45,6', selections); + // Checks that with cursor at Infinity, finding words backwards still works. + helpers.doKeys('2', 'k', 'b'); + selections = cm.getSelections().join(); + eq('1', selections); +}, {value: '123\n45\n6'}); +testVim('visual_block_different_line_lengths', function(cm, vim, helpers) { + // test the block selection with lines of different length + // i.e. extending the selection + // till the end of the longest line. + helpers.doKeys('', 'l', 'j', 'j', '6', 'l', 'd'); + helpers.doKeys('d', 'd', 'd', 'd'); + eq('', cm.getValue()); +}, {value: '1234\n5678\nabcdefg'}); +testVim('visual_block_truncate_on_short_line', function(cm, vim, helpers) { + // check for left side selection in case + // of moving up to a shorter line. + cm.replaceRange('', cm.getCursor()); + cm.setCursor(3, 4); + helpers.doKeys('', 'l', 'k', 'k', 'd'); + eq('hello world\n{\ntis\nsa!', cm.getValue()); +}, {value: 'hello world\n{\nthis is\nsparta!'}); +testVim('visual_block_corners', function(cm, vim, helpers) { + cm.setCursor(1, 2); + helpers.doKeys('', '2', 'l', 'k'); + // circle around the anchor + // and check the selections + var selections = cm.getSelections(); + eq('345891', selections.join('')); + helpers.doKeys('4', 'h'); + selections = cm.getSelections(); + eq('123678', selections.join('')); + helpers.doKeys('j', 'j'); + selections = cm.getSelections(); + eq('678abc', selections.join('')); + helpers.doKeys('4', 'l'); + selections = cm.getSelections(); + eq('891cde', selections.join('')); +}, {value: '12345\n67891\nabcde'}); +testVim('visual_block_mode_switch', function(cm, vim, helpers) { + // switch between visual modes + cm.setCursor(1, 1); + // blockwise to characterwise visual + helpers.doKeys('', 'j', 'l', 'v'); + selections = cm.getSelections(); + eq('7891\nabc', selections.join('')); + // characterwise to blockwise + helpers.doKeys(''); + selections = cm.getSelections(); + eq('78bc', selections.join('')); + // blockwise to linewise visual + helpers.doKeys('V'); + selections = cm.getSelections(); + eq('67891\nabcde', selections.join('')); +}, {value: '12345\n67891\nabcde'}); +testVim('visual_block_crossing_short_line', function(cm, vim, helpers) { + // visual block with long and short lines + cm.setCursor(0, 3); + helpers.doKeys('', 'j', 'j', 'j'); + var selections = cm.getSelections().join(); + eq('4,,d,b', selections); + helpers.doKeys('3', 'k'); + selections = cm.getSelections().join(); + eq('4', selections); + helpers.doKeys('5', 'j', 'k'); + selections = cm.getSelections().join(""); + eq(10, selections.length); +}, {value: '123456\n78\nabcdefg\nfoobar\n}\n'}); +testVim('visual_block_curPos_on_exit', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys('', '3' , 'l', ''); + eqPos(makeCursor(0, 3), cm.getCursor()); + helpers.doKeys('h', '', '2' , 'j' ,'3' , 'l'); + eq(cm.getSelections().join(), "3456,,cdef"); + helpers.doKeys('4' , 'h'); + eq(cm.getSelections().join(), "23,8,bc"); + helpers.doKeys('2' , 'l'); + eq(cm.getSelections().join(), "34,,cd"); +}, {value: '123456\n78\nabcdefg\nfoobar'}); + +testVim('visual_marks', function(cm, vim, helpers) { + helpers.doKeys('l', 'v', 'l', 'l', 'j', 'j', 'v'); + // Test visual mode marks + cm.setCursor(2, 1); + helpers.doKeys('\'', '<'); + helpers.assertCursorAt(0, 1); + helpers.doKeys('\'', '>'); + helpers.assertCursorAt(2, 0); +}); +testVim('visual_join', function(cm, vim, helpers) { + helpers.doKeys('l', 'V', 'l', 'j', 'j', 'J'); + eq(' 1 2 3\n 4\n 5', cm.getValue()); + is(!vim.visualMode); +}, { value: ' 1\n 2\n 3\n 4\n 5' }); +testVim('visual_join_2', function(cm, vim, helpers) { + helpers.doKeys('G', 'V', 'g', 'g', 'J'); + eq('1 2 3 4 5 6 ', cm.getValue()); + is(!vim.visualMode); +}, { value: '1\n2\n3\n4\n5\n6\n'}); +testVim('visual_blank', function(cm, vim, helpers) { + helpers.doKeys('v', 'k'); + eq(vim.visualMode, true); +}, { value: '\n' }); +testVim('reselect_visual', function(cm, vim, helpers) { + helpers.doKeys('l', 'v', 'l', 'l', 'l', 'y', 'g', 'v'); + helpers.assertCursorAt(0, 5); + eqPos(makeCursor(0, 1), cm.getCursor('anchor')); + helpers.doKeys('v'); + cm.setCursor(1, 0); + helpers.doKeys('v', 'l', 'l', 'p'); + eq('123456\n2345\nbar', cm.getValue()); + cm.setCursor(0, 0); + helpers.doKeys('g', 'v'); + // here the fake cursor is at (1, 3) + helpers.assertCursorAt(1, 4); + eqPos(makeCursor(1, 0), cm.getCursor('anchor')); + helpers.doKeys('v'); + cm.setCursor(2, 0); + helpers.doKeys('v', 'l', 'l', 'g', 'v'); + helpers.assertCursorAt(1, 4); + eqPos(makeCursor(1, 0), cm.getCursor('anchor')); + helpers.doKeys('g', 'v'); + helpers.assertCursorAt(2, 3); + eqPos(makeCursor(2, 0), cm.getCursor('anchor')); + eq('123456\n2345\nbar', cm.getValue()); +}, { value: '123456\nfoo\nbar' }); +testVim('reselect_visual_line', function(cm, vim, helpers) { + helpers.doKeys('l', 'V', 'j', 'j', 'V', 'g', 'v', 'd'); + eq('foo\nand\nbar', cm.getValue()); + cm.setCursor(1, 0); + helpers.doKeys('V', 'y', 'j'); + helpers.doKeys('V', 'p' , 'g', 'v', 'd'); + eq('foo\nand', cm.getValue()); +}, { value: 'hello\nthis\nis\nfoo\nand\nbar' }); +testVim('reselect_visual_block', function(cm, vim, helpers) { + cm.setCursor(1, 2); + helpers.doKeys('', 'k', 'h', ''); + cm.setCursor(2, 1); + helpers.doKeys('v', 'l', 'g', 'v'); + eqPos(Pos(1, 2), vim.sel.anchor); + eqPos(Pos(0, 1), vim.sel.head); + // Ensure selection is done with visual block mode rather than one + // continuous range. + eq(cm.getSelections().join(''), '23oo') + helpers.doKeys('g', 'v'); + eqPos(Pos(2, 1), vim.sel.anchor); + eqPos(Pos(2, 2), vim.sel.head); + helpers.doKeys(''); + // Ensure selection of deleted range + cm.setCursor(1, 1); + helpers.doKeys('v', '', 'j', 'd', 'g', 'v'); + eq(cm.getSelections().join(''), 'or'); +}, { value: '123456\nfoo\nbar' }); +testVim('s_normal', function(cm, vim, helpers) { + cm.setCursor(0, 1); + helpers.doKeys('s'); + helpers.doKeys(''); + eq('ac', cm.getValue()); +}, { value: 'abc'}); +testVim('s_visual', function(cm, vim, helpers) { + cm.setCursor(0, 1); + helpers.doKeys('v', 's'); + helpers.doKeys(''); + helpers.assertCursorAt(0, 0); + eq('ac', cm.getValue()); +}, { value: 'abc'}); +testVim('o_visual', function(cm, vim, helpers) { + cm.setCursor(0,0); + helpers.doKeys('v','l','l','l','o'); + helpers.assertCursorAt(0,0); + helpers.doKeys('v','v','j','j','j','o'); + helpers.assertCursorAt(0,0); + helpers.doKeys('O'); + helpers.doKeys('l','l') + helpers.assertCursorAt(3, 3); + helpers.doKeys('d'); + eq('p',cm.getValue()); +}, { value: 'abcd\nefgh\nijkl\nmnop'}); +testVim('o_visual_block', function(cm, vim, helpers) { + cm.setCursor(0, 1); + helpers.doKeys('','3','j','l','l', 'o'); + eqPos(Pos(3, 3), vim.sel.anchor); + eqPos(Pos(0, 1), vim.sel.head); + helpers.doKeys('O'); + eqPos(Pos(3, 1), vim.sel.anchor); + eqPos(Pos(0, 3), vim.sel.head); + helpers.doKeys('o'); + eqPos(Pos(0, 3), vim.sel.anchor); + eqPos(Pos(3, 1), vim.sel.head); +}, { value: 'abcd\nefgh\nijkl\nmnop'}); +testVim('changeCase_visual', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys('v', 'l', 'l'); + helpers.doKeys('U'); + helpers.assertCursorAt(0, 0); + helpers.doKeys('v', 'l', 'l'); + helpers.doKeys('u'); + helpers.assertCursorAt(0, 0); + helpers.doKeys('l', 'l', 'l', '.'); + helpers.assertCursorAt(0, 3); + cm.setCursor(0, 0); + helpers.doKeys('q', 'a', 'v', 'j', 'U', 'q'); + helpers.assertCursorAt(0, 0); + helpers.doKeys('j', '@', 'a'); + helpers.assertCursorAt(1, 0); + cm.setCursor(3, 0); + helpers.doKeys('V', 'U', 'j', '.'); + eq('ABCDEF\nGHIJKL\nMnopq\nSHORT LINE\nLONG LINE OF TEXT', cm.getValue()); +}, { value: 'abcdef\nghijkl\nmnopq\nshort line\nlong line of text'}); +testVim('changeCase_visual_block', function(cm, vim, helpers) { + cm.setCursor(2, 1); + helpers.doKeys('', 'k', 'k', 'h', 'U'); + eq('ABcdef\nGHijkl\nMNopq\nfoo', cm.getValue()); + cm.setCursor(0, 2); + helpers.doKeys('.'); + eq('ABCDef\nGHIJkl\nMNOPq\nfoo', cm.getValue()); + // check when last line is shorter. + cm.setCursor(2, 2); + helpers.doKeys('.'); + eq('ABCDef\nGHIJkl\nMNOPq\nfoO', cm.getValue()); +}, { value: 'abcdef\nghijkl\nmnopq\nfoo'}); +testVim('visual_paste', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys('v', 'l', 'l', 'y'); + helpers.assertCursorAt(0, 0); + helpers.doKeys('3', 'l', 'j', 'v', 'l', 'p'); + helpers.assertCursorAt(1, 5); + eq('this is a\nunithitest for visual paste', cm.getValue()); + cm.setCursor(0, 0); + // in case of pasting whole line + helpers.doKeys('y', 'y'); + cm.setCursor(1, 6); + helpers.doKeys('v', 'l', 'l', 'l', 'p'); + helpers.assertCursorAt(2, 0); + eq('this is a\nunithi\nthis is a\n for visual paste', cm.getValue()); +}, { value: 'this is a\nunit test for visual paste'}); + +// This checks the contents of the register used to paste the text +testVim('v_paste_from_register', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys('"', 'a', 'y', 'w'); + cm.setCursor(1, 0); + helpers.doKeys('v', 'p'); + cm.openDialog = helpers.fakeOpenDialog('registers'); + cm.openNotification = helpers.fakeOpenNotification(function(text) { + is(/a\s+register/.test(text)); + }); +}, { value: 'register contents\nare not erased'}); +testVim('S_normal', function(cm, vim, helpers) { + cm.setCursor(0, 1); + helpers.doKeys('j', 'S'); + helpers.doKeys(''); + helpers.assertCursorAt(1, 0); + eq('aa\n\ncc', cm.getValue()); +}, { value: 'aa\nbb\ncc'}); +testVim('blockwise_paste', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys('', '3', 'j', 'l', 'y'); + cm.setCursor(0, 2); + // paste one char after the current cursor position + helpers.doKeys('p'); + eq('helhelo\nworwold\nfoofo\nbarba', cm.getValue()); + cm.setCursor(0, 0); + helpers.doKeys('v', '4', 'l', 'y'); + cm.setCursor(0, 0); + helpers.doKeys('', '3', 'j', 'p'); + eq('helheelhelo\norwold\noofo\narba', cm.getValue()); +}, { value: 'hello\nworld\nfoo\nbar'}); +testVim('blockwise_paste_long/short_line', function(cm, vim, helpers) { + // extend short lines in case of different line lengths. + cm.setCursor(0, 0); + helpers.doKeys('', 'j', 'j', 'y'); + cm.setCursor(0, 3); + helpers.doKeys('p'); + eq('hellho\nfoo f\nbar b', cm.getValue()); +}, { value: 'hello\nfoo\nbar'}); +testVim('blockwise_paste_cut_paste', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys('', '2', 'j', 'x'); + cm.setCursor(0, 0); + helpers.doKeys('P'); + eq('cut\nand\npaste\nme', cm.getValue()); +}, { value: 'cut\nand\npaste\nme'}); +testVim('blockwise_paste_from_register', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys('', '2', 'j', '"', 'a', 'y'); + cm.setCursor(0, 3); + helpers.doKeys('"', 'a', 'p'); + eq('foobfar\nhellho\nworlwd', cm.getValue()); +}, { value: 'foobar\nhello\nworld'}); +testVim('blockwise_paste_last_line', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys('', '2', 'j', 'l', 'y'); + cm.setCursor(3, 0); + helpers.doKeys('p'); + eq('cut\nand\npaste\nmcue\n an\n pa', cm.getValue()); +}, { value: 'cut\nand\npaste\nme'}); + +testVim('S_visual', function(cm, vim, helpers) { + cm.setCursor(0, 1); + helpers.doKeys('v', 'j', 'S'); + helpers.doKeys(''); + helpers.assertCursorAt(0, 0); + eq('\ncc', cm.getValue()); +}, { value: 'aa\nbb\ncc'}); + +testVim('d_/', function(cm, vim, helpers) { + cm.openDialog = helpers.fakeOpenDialog('match'); + helpers.doKeys('2', 'd', '/'); + helpers.assertCursorAt(0, 0); + eq('match \n next', cm.getValue()); + cm.openDialog = helpers.fakeOpenDialog('2'); + helpers.doKeys('d', ':'); + // TODO eq(' next', cm.getValue()); +}, { value: 'text match match \n next' }); +testVim('/ and n/N', function(cm, vim, helpers) { + cm.openDialog = helpers.fakeOpenDialog('match'); + helpers.doKeys('/'); + helpers.assertCursorAt(0, 11); + helpers.doKeys('n'); + helpers.assertCursorAt(1, 6); + helpers.doKeys('N'); + helpers.assertCursorAt(0, 11); + + cm.setCursor(0, 0); + helpers.doKeys('2', '/'); + helpers.assertCursorAt(1, 6); +}, { value: 'match nope match \n nope Match' }); +testVim('/_case', function(cm, vim, helpers) { + cm.openDialog = helpers.fakeOpenDialog('Match'); + helpers.doKeys('/'); + helpers.assertCursorAt(1, 6); +}, { value: 'match nope match \n nope Match' }); +testVim('/_2_pcre', function(cm, vim, helpers) { + CodeMirror.Vim.setOption('pcre', true); + cm.openDialog = helpers.fakeOpenDialog('(word){2}'); + helpers.doKeys('/'); + helpers.assertCursorAt(1, 9); + helpers.doKeys('n'); + helpers.assertCursorAt(2, 1); +}, { value: 'word\n another wordword\n wordwordword\n' }); +testVim('/_2_nopcre', function(cm, vim, helpers) { + CodeMirror.Vim.setOption('pcre', false); + cm.openDialog = helpers.fakeOpenDialog('\\(word\\)\\{2}'); + helpers.doKeys('/'); + helpers.assertCursorAt(1, 9); + helpers.doKeys('n'); + helpers.assertCursorAt(2, 1); +}, { value: 'word\n another wordword\n wordwordword\n' }); +testVim('/_nongreedy', function(cm, vim, helpers) { + cm.openDialog = helpers.fakeOpenDialog('aa'); + helpers.doKeys('/'); + helpers.assertCursorAt(0, 4); + helpers.doKeys('n'); + helpers.assertCursorAt(1, 3); + helpers.doKeys('n'); + helpers.assertCursorAt(0, 0); +}, { value: 'aaa aa \n a aa'}); +testVim('?_nongreedy', function(cm, vim, helpers) { + cm.openDialog = helpers.fakeOpenDialog('aa'); + helpers.doKeys('?'); + helpers.assertCursorAt(1, 3); + helpers.doKeys('n'); + helpers.assertCursorAt(0, 4); + helpers.doKeys('n'); + helpers.assertCursorAt(0, 0); +}, { value: 'aaa aa \n a aa'}); +testVim('/_greedy', function(cm, vim, helpers) { + cm.openDialog = helpers.fakeOpenDialog('a+'); + helpers.doKeys('/'); + helpers.assertCursorAt(0, 4); + helpers.doKeys('n'); + helpers.assertCursorAt(1, 1); + helpers.doKeys('n'); + helpers.assertCursorAt(1, 3); + helpers.doKeys('n'); + helpers.assertCursorAt(0, 0); +}, { value: 'aaa aa \n a aa'}); +testVim('?_greedy', function(cm, vim, helpers) { + cm.openDialog = helpers.fakeOpenDialog('a+'); + helpers.doKeys('?'); + helpers.assertCursorAt(1, 3); + helpers.doKeys('n'); + helpers.assertCursorAt(1, 1); + helpers.doKeys('n'); + helpers.assertCursorAt(0, 4); + helpers.doKeys('n'); + helpers.assertCursorAt(0, 0); +}, { value: 'aaa aa \n a aa'}); +testVim('/_greedy_0_or_more', function(cm, vim, helpers) { + cm.openDialog = helpers.fakeOpenDialog('a*'); + helpers.doKeys('/'); + helpers.assertCursorAt(0, 3); + helpers.doKeys('n'); + helpers.assertCursorAt(0, 4); + helpers.doKeys('n'); + helpers.assertCursorAt(0, 5); + helpers.doKeys('n'); + helpers.assertCursorAt(1, 0); + helpers.doKeys('n'); + helpers.assertCursorAt(1, 1); + helpers.doKeys('n'); + helpers.assertCursorAt(0, 0); +}, { value: 'aaa aa\n aa'}); +testVim('?_greedy_0_or_more', function(cm, vim, helpers) { + cm.openDialog = helpers.fakeOpenDialog('a*'); + helpers.doKeys('?'); + helpers.assertCursorAt(1, 1); + helpers.doKeys('n'); + helpers.assertCursorAt(1, 0); + helpers.doKeys('n'); + helpers.assertCursorAt(0, 5); + helpers.doKeys('n'); + helpers.assertCursorAt(0, 4); + helpers.doKeys('n'); + helpers.assertCursorAt(0, 3); + helpers.doKeys('n'); + helpers.assertCursorAt(0, 0); +}, { value: 'aaa aa\n aa'}); +testVim('? and n/N', function(cm, vim, helpers) { + cm.openDialog = helpers.fakeOpenDialog('match'); + helpers.doKeys('?'); + helpers.assertCursorAt(1, 6); + helpers.doKeys('n'); + helpers.assertCursorAt(0, 11); + helpers.doKeys('N'); + helpers.assertCursorAt(1, 6); + + cm.setCursor(0, 0); + helpers.doKeys('2', '?'); + helpers.assertCursorAt(0, 11); +}, { value: 'match nope match \n nope Match' }); +testVim('*', function(cm, vim, helpers) { + cm.setCursor(0, 9); + helpers.doKeys('*'); + helpers.assertCursorAt(0, 22); + + cm.setCursor(0, 9); + helpers.doKeys('2', '*'); + helpers.assertCursorAt(1, 8); +}, { value: 'nomatch match nomatch match \nnomatch Match' }); +testVim('*_no_word', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys('*'); + helpers.assertCursorAt(0, 0); +}, { value: ' \n match \n' }); +testVim('*_symbol', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys('*'); + helpers.assertCursorAt(1, 0); +}, { value: ' /}\n/} match \n' }); +testVim('#', function(cm, vim, helpers) { + cm.setCursor(0, 9); + helpers.doKeys('#'); + helpers.assertCursorAt(1, 8); + + cm.setCursor(0, 9); + helpers.doKeys('2', '#'); + helpers.assertCursorAt(0, 22); +}, { value: 'nomatch match nomatch match \nnomatch Match' }); +testVim('*_seek', function(cm, vim, helpers) { + // Should skip over space and symbols. + cm.setCursor(0, 3); + helpers.doKeys('*'); + helpers.assertCursorAt(0, 22); +}, { value: ' := match nomatch match \nnomatch Match' }); +testVim('#', function(cm, vim, helpers) { + // Should skip over space and symbols. + cm.setCursor(0, 3); + helpers.doKeys('#'); + helpers.assertCursorAt(1, 8); +}, { value: ' := match nomatch match \nnomatch Match' }); +testVim('g*', function(cm, vim, helpers) { + cm.setCursor(0, 8); + helpers.doKeys('g', '*'); + helpers.assertCursorAt(0, 18); + cm.setCursor(0, 8); + helpers.doKeys('3', 'g', '*'); + helpers.assertCursorAt(1, 8); +}, { value: 'matches match alsoMatch\nmatchme matching' }); +testVim('g#', function(cm, vim, helpers) { + cm.setCursor(0, 8); + helpers.doKeys('g', '#'); + helpers.assertCursorAt(0, 0); + cm.setCursor(0, 8); + helpers.doKeys('3', 'g', '#'); + helpers.assertCursorAt(1, 0); +}, { value: 'matches match alsoMatch\nmatchme matching' }); +testVim('macro_insert', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys('q', 'a', '0', 'i'); + cm.replaceRange('foo', cm.getCursor()); + helpers.doKeys(''); + helpers.doKeys('q', '@', 'a'); + eq('foofoo', cm.getValue()); +}, { value: ''}); +testVim('macro_insert_repeat', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys('q', 'a', '$', 'a'); + cm.replaceRange('larry.', cm.getCursor()); + helpers.doKeys(''); + helpers.doKeys('a'); + cm.replaceRange('curly.', cm.getCursor()); + helpers.doKeys(''); + helpers.doKeys('q'); + helpers.doKeys('a'); + cm.replaceRange('moe.', cm.getCursor()); + helpers.doKeys(''); + helpers.doKeys('@', 'a'); + // At this point, the most recent edit should be the 2nd insert change + // inside the macro, i.e. "curly.". + helpers.doKeys('.'); + eq('larry.curly.moe.larry.curly.curly.', cm.getValue()); +}, { value: ''}); +testVim('macro_space', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys('', ''); + helpers.assertCursorAt(0, 2); + helpers.doKeys('q', 'a', '', '', 'q'); + helpers.assertCursorAt(0, 4); + helpers.doKeys('@', 'a'); + helpers.assertCursorAt(0, 6); + helpers.doKeys('@', 'a'); + helpers.assertCursorAt(0, 8); +}, { value: 'one line of text.'}); +testVim('macro_t_search', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys('q', 'a', 't', 'e', 'q'); + helpers.assertCursorAt(0, 1); + helpers.doKeys('l', '@', 'a'); + helpers.assertCursorAt(0, 6); + helpers.doKeys('l', ';'); + helpers.assertCursorAt(0, 12); +}, { value: 'one line of text.'}); +testVim('macro_f_search', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys('q', 'b', 'f', 'e', 'q'); + helpers.assertCursorAt(0, 2); + helpers.doKeys('@', 'b'); + helpers.assertCursorAt(0, 7); + helpers.doKeys(';'); + helpers.assertCursorAt(0, 13); +}, { value: 'one line of text.'}); +testVim('macro_slash_search', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys('q', 'c'); + cm.openDialog = helpers.fakeOpenDialog('e'); + helpers.doKeys('/', 'q'); + helpers.assertCursorAt(0, 2); + helpers.doKeys('@', 'c'); + helpers.assertCursorAt(0, 7); + helpers.doKeys('n'); + helpers.assertCursorAt(0, 13); +}, { value: 'one line of text.'}); +testVim('macro_multislash_search', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys('q', 'd'); + cm.openDialog = helpers.fakeOpenDialog('e'); + helpers.doKeys('/'); + cm.openDialog = helpers.fakeOpenDialog('t'); + helpers.doKeys('/', 'q'); + helpers.assertCursorAt(0, 12); + helpers.doKeys('@', 'd'); + helpers.assertCursorAt(0, 15); +}, { value: 'one line of text to rule them all.'}); +testVim('macro_parens', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys('q', 'z', 'i'); + cm.replaceRange('(', cm.getCursor()); + helpers.doKeys(''); + helpers.doKeys('e', 'a'); + cm.replaceRange(')', cm.getCursor()); + helpers.doKeys(''); + helpers.doKeys('q'); + helpers.doKeys('w', '@', 'z'); + helpers.doKeys('w', '@', 'z'); + eq('(see) (spot) (run)', cm.getValue()); +}, { value: 'see spot run'}); +testVim('macro_overwrite', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys('q', 'z', '0', 'i'); + cm.replaceRange('I ', cm.getCursor()); + helpers.doKeys(''); + helpers.doKeys('q'); + helpers.doKeys('e'); + // Now replace the macro with something else. + helpers.doKeys('q', 'z', 'a'); + cm.replaceRange('.', cm.getCursor()); + helpers.doKeys(''); + helpers.doKeys('q'); + helpers.doKeys('e', '@', 'z'); + helpers.doKeys('e', '@', 'z'); + eq('I see. spot. run.', cm.getValue()); +}, { value: 'see spot run'}); +testVim('macro_search_f', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys('q', 'a', 'f', ' '); + helpers.assertCursorAt(0,3); + helpers.doKeys('q', '0'); + helpers.assertCursorAt(0,0); + helpers.doKeys('@', 'a'); + helpers.assertCursorAt(0,3); +}, { value: 'The quick brown fox jumped over the lazy dog.'}); +testVim('macro_search_2f', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys('q', 'a', '2', 'f', ' '); + helpers.assertCursorAt(0,9); + helpers.doKeys('q', '0'); + helpers.assertCursorAt(0,0); + helpers.doKeys('@', 'a'); + helpers.assertCursorAt(0,9); +}, { value: 'The quick brown fox jumped over the lazy dog.'}); +testVim('yank_register', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys('"', 'a', 'y', 'y'); + helpers.doKeys('j', '"', 'b', 'y', 'y'); + cm.openDialog = helpers.fakeOpenDialog('registers'); + cm.openNotification = helpers.fakeOpenNotification(function(text) { + is(/a\s+foo/.test(text)); + is(/b\s+bar/.test(text)); + }); + helpers.doKeys(':'); +}, { value: 'foo\nbar'}); +testVim('yank_visual_block', function(cm, vim, helpers) { + cm.setCursor(0, 1); + helpers.doKeys('', 'l', 'j', '"', 'a', 'y'); + cm.openNotification = helpers.fakeOpenNotification(function(text) { + is(/a\s+oo\nar/.test(text)); + }); + helpers.doKeys(':'); +}, { value: 'foo\nbar'}); +testVim('yank_append_line_to_line_register', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys('"', 'a', 'y', 'y'); + helpers.doKeys('j', '"', 'A', 'y', 'y'); + cm.openDialog = helpers.fakeOpenDialog('registers'); + cm.openNotification = helpers.fakeOpenNotification(function(text) { + is(/a\s+foo\nbar/.test(text)); + is(/"\s+foo\nbar/.test(text)); + }); + helpers.doKeys(':'); +}, { value: 'foo\nbar'}); +testVim('yank_append_word_to_word_register', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys('"', 'a', 'y', 'w'); + helpers.doKeys('j', '"', 'A', 'y', 'w'); + cm.openDialog = helpers.fakeOpenDialog('registers'); + cm.openNotification = helpers.fakeOpenNotification(function(text) { + is(/a\s+foobar/.test(text)); + is(/"\s+foobar/.test(text)); + }); + helpers.doKeys(':'); +}, { value: 'foo\nbar'}); +testVim('yank_append_line_to_word_register', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys('"', 'a', 'y', 'w'); + helpers.doKeys('j', '"', 'A', 'y', 'y'); + cm.openDialog = helpers.fakeOpenDialog('registers'); + cm.openNotification = helpers.fakeOpenNotification(function(text) { + is(/a\s+foo\nbar/.test(text)); + is(/"\s+foo\nbar/.test(text)); + }); + helpers.doKeys(':'); +}, { value: 'foo\nbar'}); +testVim('yank_append_word_to_line_register', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys('"', 'a', 'y', 'y'); + helpers.doKeys('j', '"', 'A', 'y', 'w'); + cm.openDialog = helpers.fakeOpenDialog('registers'); + cm.openNotification = helpers.fakeOpenNotification(function(text) { + is(/a\s+foo\nbar/.test(text)); + is(/"\s+foo\nbar/.test(text)); + }); + helpers.doKeys(':'); +}, { value: 'foo\nbar'}); +testVim('macro_register', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys('q', 'a', 'i'); + cm.replaceRange('gangnam', cm.getCursor()); + helpers.doKeys(''); + helpers.doKeys('q'); + helpers.doKeys('q', 'b', 'o'); + cm.replaceRange('style', cm.getCursor()); + helpers.doKeys(''); + helpers.doKeys('q'); + cm.openDialog = helpers.fakeOpenDialog('registers'); + cm.openNotification = helpers.fakeOpenNotification(function(text) { + is(/a\s+i/.test(text)); + is(/b\s+o/.test(text)); + }); + helpers.doKeys(':'); +}, { value: ''}); +testVim('._register', function(cm,vim,helpers) { + cm.setCursor(0,0); + helpers.doKeys('i'); + cm.replaceRange('foo',cm.getCursor()); + helpers.doKeys(''); + cm.openDialog = helpers.fakeOpenDialog('registers'); + cm.openNotification = helpers.fakeOpenNotification(function(text) { + is(/\.\s+foo/.test(text)); + }); + helpers.doKeys(':'); +}, {value: ''}); +testVim(':_register', function(cm,vim,helpers) { + helpers.doEx('bar'); + cm.openDialog = helpers.fakeOpenDialog('registers'); + cm.openNotification = helpers.fakeOpenNotification(function(text) { + is(/:\s+bar/.test(text)); + }); + helpers.doKeys(':'); +}, {value: ''}); +testVim('search_register_escape', function(cm, vim, helpers) { + // Check that the register is restored if the user escapes rather than confirms. + cm.openDialog = helpers.fakeOpenDialog('waldo'); + helpers.doKeys('/'); + var onKeyDown; + var onKeyUp; + var KEYCODES = { + f: 70, + o: 79, + Esc: 27 + }; + cm.openDialog = function(template, callback, options) { + onKeyDown = options.onKeyDown; + onKeyUp = options.onKeyUp; + }; + var close = function() {}; + helpers.doKeys('/'); + // Fake some keyboard events coming in. + onKeyDown({keyCode: KEYCODES.f}, '', close); + onKeyUp({keyCode: KEYCODES.f}, '', close); + onKeyDown({keyCode: KEYCODES.o}, 'f', close); + onKeyUp({keyCode: KEYCODES.o}, 'f', close); + onKeyDown({keyCode: KEYCODES.o}, 'fo', close); + onKeyUp({keyCode: KEYCODES.o}, 'fo', close); + onKeyDown({keyCode: KEYCODES.Esc}, 'foo', close); + cm.openDialog = helpers.fakeOpenDialog('registers'); + cm.openNotification = helpers.fakeOpenNotification(function(text) { + is(/waldo/.test(text)); + is(!/foo/.test(text)); + }); + helpers.doKeys(':'); +}, {value: ''}); +testVim('search_register', function(cm, vim, helpers) { + cm.openDialog = helpers.fakeOpenDialog('foo'); + helpers.doKeys('/'); + cm.openDialog = helpers.fakeOpenDialog('registers'); + cm.openNotification = helpers.fakeOpenNotification(function(text) { + is(/\/\s+foo/.test(text)); + }); + helpers.doKeys(':'); +}, {value: ''}); +testVim('search_history', function(cm, vim, helpers) { + cm.openDialog = helpers.fakeOpenDialog('this'); + helpers.doKeys('/'); + cm.openDialog = helpers.fakeOpenDialog('checks'); + helpers.doKeys('/'); + cm.openDialog = helpers.fakeOpenDialog('search'); + helpers.doKeys('/'); + cm.openDialog = helpers.fakeOpenDialog('history'); + helpers.doKeys('/'); + cm.openDialog = helpers.fakeOpenDialog('checks'); + helpers.doKeys('/'); + var onKeyDown; + var onKeyUp; + var query = ''; + var keyCodes = { + Up: 38, + Down: 40 + }; + cm.openDialog = function(template, callback, options) { + onKeyUp = options.onKeyUp; + onKeyDown = options.onKeyDown; + }; + var close = function(newVal) { + if (typeof newVal == 'string') query = newVal; + } + helpers.doKeys('/'); + onKeyDown({keyCode: keyCodes.Up}, query, close); + onKeyUp({keyCode: keyCodes.Up}, query, close); + eq(query, 'checks'); + onKeyDown({keyCode: keyCodes.Up}, query, close); + onKeyUp({keyCode: keyCodes.Up}, query, close); + eq(query, 'history'); + onKeyDown({keyCode: keyCodes.Up}, query, close); + onKeyUp({keyCode: keyCodes.Up}, query, close); + eq(query, 'search'); + onKeyDown({keyCode: keyCodes.Up}, query, close); + onKeyUp({keyCode: keyCodes.Up}, query, close); + eq(query, 'this'); + onKeyDown({keyCode: keyCodes.Down}, query, close); + onKeyUp({keyCode: keyCodes.Down}, query, close); + eq(query, 'search'); +}, {value: ''}); +testVim('exCommand_history', function(cm, vim, helpers) { + cm.openDialog = helpers.fakeOpenDialog('registers'); + helpers.doKeys(':'); + cm.openDialog = helpers.fakeOpenDialog('sort'); + helpers.doKeys(':'); + cm.openDialog = helpers.fakeOpenDialog('map'); + helpers.doKeys(':'); + cm.openDialog = helpers.fakeOpenDialog('invalid'); + helpers.doKeys(':'); + var onKeyDown; + var onKeyUp; + var input = ''; + var keyCodes = { + Up: 38, + Down: 40, + s: 115 + }; + cm.openDialog = function(template, callback, options) { + onKeyUp = options.onKeyUp; + onKeyDown = options.onKeyDown; + }; + var close = function(newVal) { + if (typeof newVal == 'string') input = newVal; + } + helpers.doKeys(':'); + onKeyDown({keyCode: keyCodes.Up}, input, close); + eq(input, 'invalid'); + onKeyDown({keyCode: keyCodes.Up}, input, close); + eq(input, 'map'); + onKeyDown({keyCode: keyCodes.Up}, input, close); + eq(input, 'sort'); + onKeyDown({keyCode: keyCodes.Up}, input, close); + eq(input, 'registers'); + onKeyDown({keyCode: keyCodes.s}, '', close); + input = 's'; + onKeyDown({keyCode: keyCodes.Up}, input, close); + eq(input, 'sort'); +}, {value: ''}); +testVim('search_clear', function(cm, vim, helpers) { + var onKeyDown; + var input = ''; + var keyCodes = { + Ctrl: 17, + u: 85 + }; + cm.openDialog = function(template, callback, options) { + onKeyDown = options.onKeyDown; + }; + var close = function(newVal) { + if (typeof newVal == 'string') input = newVal; + } + helpers.doKeys('/'); + input = 'foo'; + onKeyDown({keyCode: keyCodes.Ctrl}, input, close); + onKeyDown({keyCode: keyCodes.u, ctrlKey: true}, input, close); + eq(input, ''); +}); +testVim('exCommand_clear', function(cm, vim, helpers) { + var onKeyDown; + var input = ''; + var keyCodes = { + Ctrl: 17, + u: 85 + }; + cm.openDialog = function(template, callback, options) { + onKeyDown = options.onKeyDown; + }; + var close = function(newVal) { + if (typeof newVal == 'string') input = newVal; + } + helpers.doKeys(':'); + input = 'foo'; + onKeyDown({keyCode: keyCodes.Ctrl}, input, close); + onKeyDown({keyCode: keyCodes.u, ctrlKey: true}, input, close); + eq(input, ''); +}); +testVim('.', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys('2', 'd', 'w'); + helpers.doKeys('.'); + eq('5 6', cm.getValue()); +}, { value: '1 2 3 4 5 6'}); +testVim('._repeat', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys('2', 'd', 'w'); + helpers.doKeys('3', '.'); + eq('6', cm.getValue()); +}, { value: '1 2 3 4 5 6'}); +testVim('._insert', function(cm, vim, helpers) { + helpers.doKeys('i'); + cm.replaceRange('test', cm.getCursor()); + helpers.doKeys(''); + helpers.doKeys('.'); + eq('testestt', cm.getValue()); + helpers.assertCursorAt(0, 6); +}, { value: ''}); +testVim('._insert_repeat', function(cm, vim, helpers) { + helpers.doKeys('i'); + cm.replaceRange('test', cm.getCursor()); + cm.setCursor(0, 4); + helpers.doKeys(''); + helpers.doKeys('2', '.'); + eq('testesttestt', cm.getValue()); + helpers.assertCursorAt(0, 10); +}, { value: ''}); +testVim('._repeat_insert', function(cm, vim, helpers) { + helpers.doKeys('3', 'i'); + cm.replaceRange('te', cm.getCursor()); + cm.setCursor(0, 2); + helpers.doKeys(''); + helpers.doKeys('.'); + eq('tetettetetee', cm.getValue()); + helpers.assertCursorAt(0, 10); +}, { value: ''}); +testVim('._insert_o', function(cm, vim, helpers) { + helpers.doKeys('o'); + cm.replaceRange('z', cm.getCursor()); + cm.setCursor(1, 1); + helpers.doKeys(''); + helpers.doKeys('.'); + eq('\nz\nz', cm.getValue()); + helpers.assertCursorAt(2, 0); +}, { value: ''}); +testVim('._insert_o_repeat', function(cm, vim, helpers) { + helpers.doKeys('o'); + cm.replaceRange('z', cm.getCursor()); + helpers.doKeys(''); + cm.setCursor(1, 0); + helpers.doKeys('2', '.'); + eq('\nz\nz\nz', cm.getValue()); + helpers.assertCursorAt(3, 0); +}, { value: ''}); +testVim('._insert_o_indent', function(cm, vim, helpers) { + helpers.doKeys('o'); + cm.replaceRange('z', cm.getCursor()); + helpers.doKeys(''); + cm.setCursor(1, 2); + helpers.doKeys('.'); + eq('{\n z\n z', cm.getValue()); + helpers.assertCursorAt(2, 2); +}, { value: '{'}); +testVim('._insert_cw', function(cm, vim, helpers) { + helpers.doKeys('c', 'w'); + cm.replaceRange('test', cm.getCursor()); + helpers.doKeys(''); + cm.setCursor(0, 3); + helpers.doKeys('2', 'l'); + helpers.doKeys('.'); + eq('test test word3', cm.getValue()); + helpers.assertCursorAt(0, 8); +}, { value: 'word1 word2 word3' }); +testVim('._insert_cw_repeat', function(cm, vim, helpers) { + // For some reason, repeat cw in desktop VIM will does not repeat insert mode + // changes. Will conform to that behavior. + helpers.doKeys('c', 'w'); + cm.replaceRange('test', cm.getCursor()); + helpers.doKeys(''); + cm.setCursor(0, 4); + helpers.doKeys('l'); + helpers.doKeys('2', '.'); + eq('test test', cm.getValue()); + helpers.assertCursorAt(0, 8); +}, { value: 'word1 word2 word3' }); +testVim('._delete', function(cm, vim, helpers) { + cm.setCursor(0, 5); + helpers.doKeys('i'); + helpers.doInsertModeKeys('Backspace'); + helpers.doKeys(''); + helpers.doKeys('.'); + eq('zace', cm.getValue()); + helpers.assertCursorAt(0, 1); +}, { value: 'zabcde'}); +testVim('._delete_repeat', function(cm, vim, helpers) { + cm.setCursor(0, 6); + helpers.doKeys('i'); + helpers.doInsertModeKeys('Backspace'); + helpers.doKeys(''); + helpers.doKeys('2', '.'); + eq('zzce', cm.getValue()); + helpers.assertCursorAt(0, 1); +}, { value: 'zzabcde'}); +testVim('._visual_>', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys('V', 'j', '>'); + cm.setCursor(2, 0) + helpers.doKeys('.'); + eq(' 1\n 2\n 3\n 4', cm.getValue()); + helpers.assertCursorAt(2, 2); +}, { value: '1\n2\n3\n4'}); +testVim('f;', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys('f', 'x'); + helpers.doKeys(';'); + helpers.doKeys('2', ';'); + eq(9, cm.getCursor().ch); +}, { value: '01x3xx678x'}); +testVim('F;', function(cm, vim, helpers) { + cm.setCursor(0, 8); + helpers.doKeys('F', 'x'); + helpers.doKeys(';'); + helpers.doKeys('2', ';'); + eq(2, cm.getCursor().ch); +}, { value: '01x3xx6x8x'}); +testVim('t;', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys('t', 'x'); + helpers.doKeys(';'); + helpers.doKeys('2', ';'); + eq(8, cm.getCursor().ch); +}, { value: '01x3xx678x'}); +testVim('T;', function(cm, vim, helpers) { + cm.setCursor(0, 9); + helpers.doKeys('T', 'x'); + helpers.doKeys(';'); + helpers.doKeys('2', ';'); + eq(2, cm.getCursor().ch); +}, { value: '0xx3xx678x'}); +testVim('f,', function(cm, vim, helpers) { + cm.setCursor(0, 6); + helpers.doKeys('f', 'x'); + helpers.doKeys(','); + helpers.doKeys('2', ','); + eq(2, cm.getCursor().ch); +}, { value: '01x3xx678x'}); +testVim('F,', function(cm, vim, helpers) { + cm.setCursor(0, 3); + helpers.doKeys('F', 'x'); + helpers.doKeys(','); + helpers.doKeys('2', ','); + eq(9, cm.getCursor().ch); +}, { value: '01x3xx678x'}); +testVim('t,', function(cm, vim, helpers) { + cm.setCursor(0, 6); + helpers.doKeys('t', 'x'); + helpers.doKeys(','); + helpers.doKeys('2', ','); + eq(3, cm.getCursor().ch); +}, { value: '01x3xx678x'}); +testVim('T,', function(cm, vim, helpers) { + cm.setCursor(0, 4); + helpers.doKeys('T', 'x'); + helpers.doKeys(','); + helpers.doKeys('2', ','); + eq(8, cm.getCursor().ch); +}, { value: '01x3xx67xx'}); +testVim('fd,;', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys('f', '4'); + cm.setCursor(0, 0); + helpers.doKeys('d', ';'); + eq('56789', cm.getValue()); + helpers.doKeys('u'); + cm.setCursor(0, 9); + helpers.doKeys('d', ','); + eq('01239', cm.getValue()); +}, { value: '0123456789'}); +testVim('Fd,;', function(cm, vim, helpers) { + cm.setCursor(0, 9); + helpers.doKeys('F', '4'); + cm.setCursor(0, 9); + helpers.doKeys('d', ';'); + eq('01239', cm.getValue()); + helpers.doKeys('u'); + cm.setCursor(0, 0); + helpers.doKeys('d', ','); + eq('56789', cm.getValue()); +}, { value: '0123456789'}); +testVim('td,;', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys('t', '4'); + cm.setCursor(0, 0); + helpers.doKeys('d', ';'); + eq('456789', cm.getValue()); + helpers.doKeys('u'); + cm.setCursor(0, 9); + helpers.doKeys('d', ','); + eq('012349', cm.getValue()); +}, { value: '0123456789'}); +testVim('Td,;', function(cm, vim, helpers) { + cm.setCursor(0, 9); + helpers.doKeys('T', '4'); + cm.setCursor(0, 9); + helpers.doKeys('d', ';'); + eq('012349', cm.getValue()); + helpers.doKeys('u'); + cm.setCursor(0, 0); + helpers.doKeys('d', ','); + eq('456789', cm.getValue()); +}, { value: '0123456789'}); +testVim('fc,;', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys('f', '4'); + cm.setCursor(0, 0); + helpers.doKeys('c', ';', ''); + eq('56789', cm.getValue()); + helpers.doKeys('u'); + cm.setCursor(0, 9); + helpers.doKeys('c', ','); + eq('01239', cm.getValue()); +}, { value: '0123456789'}); +testVim('Fc,;', function(cm, vim, helpers) { + cm.setCursor(0, 9); + helpers.doKeys('F', '4'); + cm.setCursor(0, 9); + helpers.doKeys('c', ';', ''); + eq('01239', cm.getValue()); + helpers.doKeys('u'); + cm.setCursor(0, 0); + helpers.doKeys('c', ','); + eq('56789', cm.getValue()); +}, { value: '0123456789'}); +testVim('tc,;', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys('t', '4'); + cm.setCursor(0, 0); + helpers.doKeys('c', ';', ''); + eq('456789', cm.getValue()); + helpers.doKeys('u'); + cm.setCursor(0, 9); + helpers.doKeys('c', ','); + eq('012349', cm.getValue()); +}, { value: '0123456789'}); +testVim('Tc,;', function(cm, vim, helpers) { + cm.setCursor(0, 9); + helpers.doKeys('T', '4'); + cm.setCursor(0, 9); + helpers.doKeys('c', ';', ''); + eq('012349', cm.getValue()); + helpers.doKeys('u'); + cm.setCursor(0, 0); + helpers.doKeys('c', ','); + eq('456789', cm.getValue()); +}, { value: '0123456789'}); +testVim('fy,;', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys('f', '4'); + cm.setCursor(0, 0); + helpers.doKeys('y', ';', 'P'); + eq('012340123456789', cm.getValue()); + helpers.doKeys('u'); + cm.setCursor(0, 9); + helpers.doKeys('y', ',', 'P'); + eq('012345678456789', cm.getValue()); +}, { value: '0123456789'}); +testVim('Fy,;', function(cm, vim, helpers) { + cm.setCursor(0, 9); + helpers.doKeys('F', '4'); + cm.setCursor(0, 9); + helpers.doKeys('y', ';', 'p'); + eq('012345678945678', cm.getValue()); + helpers.doKeys('u'); + cm.setCursor(0, 0); + helpers.doKeys('y', ',', 'P'); + eq('012340123456789', cm.getValue()); +}, { value: '0123456789'}); +testVim('ty,;', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys('t', '4'); + cm.setCursor(0, 0); + helpers.doKeys('y', ';', 'P'); + eq('01230123456789', cm.getValue()); + helpers.doKeys('u'); + cm.setCursor(0, 9); + helpers.doKeys('y', ',', 'p'); + eq('01234567895678', cm.getValue()); +}, { value: '0123456789'}); +testVim('Ty,;', function(cm, vim, helpers) { + cm.setCursor(0, 9); + helpers.doKeys('T', '4'); + cm.setCursor(0, 9); + helpers.doKeys('y', ';', 'p'); + eq('01234567895678', cm.getValue()); + helpers.doKeys('u'); + cm.setCursor(0, 0); + helpers.doKeys('y', ',', 'P'); + eq('01230123456789', cm.getValue()); +}, { value: '0123456789'}); +testVim('HML', function(cm, vim, helpers) { + var lines = 35; + var textHeight = cm.defaultTextHeight(); + cm.setSize(600, lines*textHeight); + cm.setCursor(120, 0); + cm.refresh(); //ace! + helpers.doKeys('H'); + helpers.assertCursorAt(86, 2); + helpers.doKeys('L'); + helpers.assertCursorAt(120, 4); + helpers.doKeys('M'); + helpers.assertCursorAt(103,4); +}, { value: (function(){ + var lines = new Array(100); + var upper = ' xx\n'; + var lower = ' xx\n'; + upper = lines.join(upper); + lower = lines.join(lower); + return upper + lower; +})()}); + +var zVals = []; +forEach(['zb','zz','zt','z-','z.','z'], function(e, idx){ + var lineNum = 250; + var lines = 35; + testVim(e, function(cm, vim, helpers) { + var k1 = e[0]; + var k2 = e.substring(1); + var textHeight = cm.defaultTextHeight(); + cm.setSize(600, lines*textHeight); + cm.setCursor(lineNum, 0); + helpers.doKeys(k1, k2); + zVals[idx] = cm.getScrollInfo().top; + }, { value: (function(){ + return new Array(500).join('\n'); + })()}); +}); +testVim('zb', function(cm, vim, helpers){ + eq(zVals[2], zVals[5]); +}); + +var moveTillCharacterSandbox = + 'The quick brown fox \n' + 'jumped over the lazy dog.' +testVim('moveTillCharacter', function(cm, vim, helpers){ + cm.setCursor(0, 0); + // Search for the 'q'. + cm.openDialog = helpers.fakeOpenDialog('q'); + helpers.doKeys('/'); + eq(4, cm.getCursor().ch); + // Jump to just before the first o in the list. + helpers.doKeys('t'); + helpers.doKeys('o'); + eq('The quick brown fox \n', cm.getValue()); + // Delete that one character. + helpers.doKeys('d'); + helpers.doKeys('t'); + helpers.doKeys('o'); + eq('The quick bown fox \n', cm.getValue()); + // Delete everything until the next 'o'. + helpers.doKeys('.'); + eq('The quick box \n', cm.getValue()); + // An unmatched character should have no effect. + helpers.doKeys('d'); + helpers.doKeys('t'); + helpers.doKeys('q'); + eq('The quick box \n', cm.getValue()); + // Matches should only be possible on single lines. + helpers.doKeys('d'); + helpers.doKeys('t'); + helpers.doKeys('z'); + eq('The quick box \n', cm.getValue()); + // After all that, the search for 'q' should still be active, so the 'N' command + // can run it again in reverse. Use that to delete everything back to the 'q'. + helpers.doKeys('d'); + helpers.doKeys('N'); + eq('The ox \n', cm.getValue()); + eq(4, cm.getCursor().ch); +}, { value: moveTillCharacterSandbox}); +testVim('searchForPipe', function(cm, vim, helpers){ + CodeMirror.Vim.setOption('pcre', false); + cm.setCursor(0, 0); + // Search for the '|'. + cm.openDialog = helpers.fakeOpenDialog('|'); + helpers.doKeys('/'); + eq(4, cm.getCursor().ch); +}, { value: 'this|that'}); + + +var scrollMotionSandbox = + '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n' + '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n' + '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n' + '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n'; +testVim('scrollMotion', function(cm, vim, helpers){ + var prevCursor, prevScrollInfo; + cm.setCursor(0, 0); + // ctrl-y at the top of the file should have no effect. + helpers.doKeys(''); + eq(0, cm.getCursor().line); + prevScrollInfo = cm.getScrollInfo(); + helpers.doKeys(''); + eq(1, cm.getCursor().line); + is(prevScrollInfo.top < cm.getScrollInfo().top); + // Jump to the end of the sandbox. + cm.setCursor(1000, 0); + cm.refresh(); //ace! + prevCursor = cm.getCursor(); + // ctrl-e at the bottom of the file should have no effect. + helpers.doKeys(''); + eq(prevCursor.line, cm.getCursor().line); + cm.refresh(); //ace! + prevScrollInfo = cm.getScrollInfo(); + helpers.doKeys(''); + eq(prevCursor.line - 1, cm.getCursor().line, "Y"); + is(prevScrollInfo.top > cm.getScrollInfo().top); +}, { value: scrollMotionSandbox}); + +var squareBracketMotionSandbox = ''+ + '({\n'+//0 + ' ({\n'+//11 + ' /*comment {\n'+//2 + ' */(\n'+//3 + '#else \n'+//4 + ' /* )\n'+//5 + '#if }\n'+//6 + ' )}*/\n'+//7 + ')}\n'+//8 + '{}\n'+//9 + '#else {{\n'+//10 + '{}\n'+//11 + '}\n'+//12 + '{\n'+//13 + '#endif\n'+//14 + '}\n'+//15 + '}\n'+//16 + '#else';//17 +testVim('[[, ]]', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys(']', ']'); + helpers.assertCursorAt(9,0); + helpers.doKeys('2', ']', ']'); + helpers.assertCursorAt(13,0); + helpers.doKeys(']', ']'); + helpers.assertCursorAt(17,0); + helpers.doKeys('[', '['); + helpers.assertCursorAt(13,0); + helpers.doKeys('2', '[', '['); + helpers.assertCursorAt(9,0); + helpers.doKeys('[', '['); + helpers.assertCursorAt(0,0); +}, { value: squareBracketMotionSandbox}); +testVim('[], ][', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doKeys(']', '['); + helpers.assertCursorAt(12,0); + helpers.doKeys('2', ']', '['); + helpers.assertCursorAt(16,0); + helpers.doKeys(']', '['); + helpers.assertCursorAt(17,0); + helpers.doKeys('[', ']'); + helpers.assertCursorAt(16,0); + helpers.doKeys('2', '[', ']'); + helpers.assertCursorAt(12,0); + helpers.doKeys('[', ']'); + helpers.assertCursorAt(0,0); +}, { value: squareBracketMotionSandbox}); +testVim('[{, ]}', function(cm, vim, helpers) { + cm.setCursor(4, 10); + helpers.doKeys('[', '{'); + helpers.assertCursorAt(2,12); + helpers.doKeys('2', '[', '{'); + helpers.assertCursorAt(0,1); + cm.setCursor(4, 10); + helpers.doKeys(']', '}'); + helpers.assertCursorAt(6,11); + helpers.doKeys('2', ']', '}'); + helpers.assertCursorAt(8,1); + cm.setCursor(0,1); + helpers.doKeys(']', '}'); + helpers.assertCursorAt(8,1); + helpers.doKeys('[', '{'); + helpers.assertCursorAt(0,1); +}, { value: squareBracketMotionSandbox}); +testVim('[(, ])', function(cm, vim, helpers) { + cm.setCursor(4, 10); + helpers.doKeys('[', '('); + helpers.assertCursorAt(3,14); + helpers.doKeys('2', '[', '('); + helpers.assertCursorAt(0,0); + cm.setCursor(4, 10); + helpers.doKeys(']', ')'); + helpers.assertCursorAt(5,11); + helpers.doKeys('2', ']', ')'); + helpers.assertCursorAt(8,0); + helpers.doKeys('[', '('); + helpers.assertCursorAt(0,0); + helpers.doKeys(']', ')'); + helpers.assertCursorAt(8,0); +}, { value: squareBracketMotionSandbox}); +testVim('[*, ]*, [/, ]/', function(cm, vim, helpers) { + forEach(['*', '/'], function(key){ + cm.setCursor(7, 0); + helpers.doKeys('2', '[', key); + helpers.assertCursorAt(2,2); + helpers.doKeys('2', ']', key); + helpers.assertCursorAt(7,5); + }); +}, { value: squareBracketMotionSandbox}); +testVim('[#, ]#', function(cm, vim, helpers) { + cm.setCursor(10, 3); + helpers.doKeys('2', '[', '#'); + helpers.assertCursorAt(4,0); + helpers.doKeys('5', ']', '#'); + helpers.assertCursorAt(17,0); + cm.setCursor(10, 3); + helpers.doKeys(']', '#'); + helpers.assertCursorAt(14,0); +}, { value: squareBracketMotionSandbox}); +testVim('[m, ]m, [M, ]M', function(cm, vim, helpers) { + cm.setCursor(11, 0); + helpers.doKeys('[', 'm'); + helpers.assertCursorAt(10,7); + helpers.doKeys('4', '[', 'm'); + helpers.assertCursorAt(1,3); + helpers.doKeys('5', ']', 'm'); + helpers.assertCursorAt(11,0); + helpers.doKeys('[', 'M'); + helpers.assertCursorAt(9,1); + helpers.doKeys('3', ']', 'M'); + helpers.assertCursorAt(15,0); + helpers.doKeys('5', '[', 'M'); + helpers.assertCursorAt(7,3); +}, { value: squareBracketMotionSandbox}); + +// Ex mode tests +testVim('ex_go_to_line', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doEx('4'); + helpers.assertCursorAt(3, 0); +}, { value: 'a\nb\nc\nd\ne\n'}); +testVim('ex_write', function(cm, vim, helpers) { + var tmp = CodeMirror.commands.save; + var written; + var actualCm; + CodeMirror.commands.save = function(cm) { + written = true; + actualCm = cm; + }; + // Test that w, wr, wri ... write all trigger :write. + var command = 'write'; + for (var i = 1; i < command.length; i++) { + written = false; + actualCm = null; + helpers.doEx(command.substring(0, i)); + eq(written, true); + eq(actualCm, cm); + } + CodeMirror.commands.save = tmp; +}); +testVim('ex_sort', function(cm, vim, helpers) { + helpers.doEx('sort'); + eq('Z\na\nb\nc\nd', cm.getValue()); +}, { value: 'b\nZ\nd\nc\na'}); +testVim('ex_sort_reverse', function(cm, vim, helpers) { + helpers.doEx('sort!'); + eq('d\nc\nb\na', cm.getValue()); +}, { value: 'b\nd\nc\na'}); +testVim('ex_sort_range', function(cm, vim, helpers) { + helpers.doEx('2,3sort'); + eq('b\nc\nd\na', cm.getValue()); +}, { value: 'b\nd\nc\na'}); +testVim('ex_sort_oneline', function(cm, vim, helpers) { + helpers.doEx('2sort'); + // Expect no change. + eq('b\nd\nc\na', cm.getValue()); +}, { value: 'b\nd\nc\na'}); +testVim('ex_sort_ignoreCase', function(cm, vim, helpers) { + helpers.doEx('sort i'); + eq('a\nb\nc\nd\nZ', cm.getValue()); +}, { value: 'b\nZ\nd\nc\na'}); +testVim('ex_sort_unique', function(cm, vim, helpers) { + helpers.doEx('sort u'); + eq('Z\na\nb\nc\nd', cm.getValue()); +}, { value: 'b\nZ\na\na\nd\na\nc\na'}); +testVim('ex_sort_decimal', function(cm, vim, helpers) { + helpers.doEx('sort d'); + eq('d3\n s5\n6\n.9', cm.getValue()); +}, { value: '6\nd3\n s5\n.9'}); +testVim('ex_sort_decimal_negative', function(cm, vim, helpers) { + helpers.doEx('sort d'); + eq('z-9\nd3\n s5\n6\n.9', cm.getValue()); +}, { value: '6\nd3\n s5\n.9\nz-9'}); +testVim('ex_sort_decimal_reverse', function(cm, vim, helpers) { + helpers.doEx('sort! d'); + eq('.9\n6\n s5\nd3', cm.getValue()); +}, { value: '6\nd3\n s5\n.9'}); +testVim('ex_sort_hex', function(cm, vim, helpers) { + helpers.doEx('sort x'); + eq(' s5\n6\n.9\n&0xB\nd3', cm.getValue()); +}, { value: '6\nd3\n s5\n&0xB\n.9'}); +testVim('ex_sort_octal', function(cm, vim, helpers) { + helpers.doEx('sort o'); + eq('.8\n.9\nd3\n s5\n6', cm.getValue()); +}, { value: '6\nd3\n s5\n.9\n.8'}); +testVim('ex_sort_decimal_mixed', function(cm, vim, helpers) { + helpers.doEx('sort d'); + eq('y\nz\nc1\nb2\na3', cm.getValue()); +}, { value: 'a3\nz\nc1\ny\nb2'}); +testVim('ex_sort_decimal_mixed_reverse', function(cm, vim, helpers) { + helpers.doEx('sort! d'); + eq('a3\nb2\nc1\nz\ny', cm.getValue()); +}, { value: 'a3\nz\nc1\ny\nb2'}); +// test for :global command +testVim('ex_global', function(cm, vim, helpers) { + cm.setCursor(0, 0); + helpers.doEx('g/one/s//two'); + eq('two two\n two two\n two two', cm.getValue()); + helpers.doEx('1,2g/two/s//one'); + eq('one one\n one one\n two two', cm.getValue()); +}, {value: 'one one\n one one\n one one'}); +testVim('ex_global_confirm', function(cm, vim, helpers) { + cm.setCursor(0, 0); + var onKeyDown; + var openDialogSave = cm.openDialog; + var KEYCODES = { + a: 65, + n: 78, + q: 81, + y: 89 + }; + // Intercept the ex command, 'global' + cm.openDialog = function(template, callback, options) { + // Intercept the prompt for the embedded ex command, 'substitute' + cm.openDialog = function(template, callback, options) { + onKeyDown = options.onKeyDown; + }; + callback('g/one/s//two/gc'); + }; + helpers.doKeys(':'); + var close = function() {}; + onKeyDown({keyCode: KEYCODES.n}, '', close); + onKeyDown({keyCode: KEYCODES.y}, '', close); + onKeyDown({keyCode: KEYCODES.a}, '', close); + onKeyDown({keyCode: KEYCODES.q}, '', close); + onKeyDown({keyCode: KEYCODES.y}, '', close); + eq('one two\n two two\n one one\n two one\n one one', cm.getValue()); +}, {value: 'one one\n one one\n one one\n one one\n one one'}); +// Basic substitute tests. +testVim('ex_substitute_same_line', function(cm, vim, helpers) { + cm.setCursor(1, 0); + helpers.doEx('s/one/two/g'); + eq('one one\n two two', cm.getValue()); +}, { value: 'one one\n one one'}); +testVim('ex_substitute_full_file', function(cm, vim, helpers) { + cm.setCursor(1, 0); + helpers.doEx('%s/one/two/g'); + eq('two two\n two two', cm.getValue()); +}, { value: 'one one\n one one'}); +testVim('ex_substitute_input_range', function(cm, vim, helpers) { + cm.setCursor(1, 0); + helpers.doEx('1,3s/\\d/0/g'); + eq('0\n0\n0\n4', cm.getValue()); +}, { value: '1\n2\n3\n4' }); +testVim('ex_substitute_visual_range', function(cm, vim, helpers) { + cm.setCursor(1, 0); + // Set last visual mode selection marks '< and '> at lines 2 and 4 + helpers.doKeys('V', '2', 'j', 'v'); + helpers.doEx('\'<,\'>s/\\d/0/g'); + eq('1\n0\n0\n0\n5', cm.getValue()); +}, { value: '1\n2\n3\n4\n5' }); +testVim('ex_substitute_empty_query', function(cm, vim, helpers) { + // If the query is empty, use last query. + cm.setCursor(1, 0); + cm.openDialog = helpers.fakeOpenDialog('1'); + helpers.doKeys('/'); + helpers.doEx('s//b/g'); + eq('abb ab2 ab3', cm.getValue()); +}, { value: 'a11 a12 a13' }); +testVim('ex_substitute_javascript', function(cm, vim, helpers) { + CodeMirror.Vim.setOption('pcre', false); + cm.setCursor(1, 0); + // Throw all the things that javascript likes to treat as special values + // into the replace part. All should be literal (this is VIM). + helpers.doEx('s/\\(\\d+\\)/$$ $\' $` $& \\1/g') + eq('a $$ $\' $` $& 0 b', cm.getValue()); +}, { value: 'a 0 b' }); +testVim('ex_substitute_empty_arguments', function(cm,vim,helpers) { + cm.setCursor(0, 0); + helpers.doEx('s/a/b/g'); + cm.setCursor(1, 0); + helpers.doEx('s'); + eq('b b\nb a', cm.getValue()); +}, {value: 'a a\na a'}); + +// More complex substitute tests that test both pcre and nopcre options. +function testSubstitute(name, options) { + testVim(name + '_pcre', function(cm, vim, helpers) { + cm.setCursor(1, 0); + CodeMirror.Vim.setOption('pcre', true); + helpers.doEx(options.expr); + eq(options.expectedValue, cm.getValue()); + }, options); + // If no noPcreExpr is defined, assume that it's the same as the expr. + var noPcreExpr = options.noPcreExpr ? options.noPcreExpr : options.expr; + testVim(name + '_nopcre', function(cm, vim, helpers) { + cm.setCursor(1, 0); + CodeMirror.Vim.setOption('pcre', false); + helpers.doEx(noPcreExpr); + eq(options.expectedValue, cm.getValue()); + }, options); +} +testSubstitute('ex_substitute_capture', { + value: 'a11 a12 a13', + expectedValue: 'a1111 a1212 a1313', + // $n is a backreference + expr: 's/(\\d+)/$1$1/g', + // \n is a backreference. + noPcreExpr: 's/\\(\\d+\\)/\\1\\1/g'}); +testSubstitute('ex_substitute_capture2', { + value: 'a 0 b', + expectedValue: 'a $00 b', + expr: 's/(\\d+)/$$$1$1/g', + noPcreExpr: 's/\\(\\d+\\)/$\\1\\1/g'}); +testSubstitute('ex_substitute_nocapture', { + value: 'a11 a12 a13', + expectedValue: 'a$1$1 a$1$1 a$1$1', + expr: 's/(\\d+)/$$1$$1/g', + noPcreExpr: 's/\\(\\d+\\)/$1$1/g'}); +testSubstitute('ex_substitute_nocapture2', { + value: 'a 0 b', + expectedValue: 'a $10 b', + expr: 's/(\\d+)/$$1$1/g', + noPcreExpr: 's/\\(\\d+\\)/\\$1\\1/g'}); +testSubstitute('ex_substitute_nocapture', { + value: 'a b c', + expectedValue: 'a $ c', + expr: 's/b/$$/', + noPcreExpr: 's/b/$/'}); +testSubstitute('ex_substitute_slash_regex', { + value: 'one/two \n three/four', + expectedValue: 'one|two \n three|four', + expr: '%s/\\//|'}); +testSubstitute('ex_substitute_pipe_regex', { + value: 'one|two \n three|four', + expectedValue: 'one,two \n three,four', + expr: '%s/\\|/,/', + noPcreExpr: '%s/|/,/'}); +testSubstitute('ex_substitute_or_regex', { + value: 'one|two \n three|four', + expectedValue: 'ana|twa \n thraa|faar', + expr: '%s/o|e|u/a/g', + noPcreExpr: '%s/o\\|e\\|u/a/g'}); +testSubstitute('ex_substitute_or_word_regex', { + value: 'one|two \n three|four', + expectedValue: 'five|five \n three|four', + expr: '%s/(one|two)/five/g', + noPcreExpr: '%s/\\(one\\|two\\)/five/g'}); +testSubstitute('ex_substitute_backslashslash_regex', { + value: 'one\\two \n three\\four', + expectedValue: 'one,two \n three,four', + expr: '%s/\\\\/,'}); +testSubstitute('ex_substitute_slash_replacement', { + value: 'one,two \n three,four', + expectedValue: 'one/two \n three/four', + expr: '%s/,/\\/'}); +testSubstitute('ex_substitute_backslash_replacement', { + value: 'one,two \n three,four', + expectedValue: 'one\\two \n three\\four', + expr: '%s/,/\\\\/g'}); +testSubstitute('ex_substitute_multibackslash_replacement', { + value: 'one,two \n three,four', + expectedValue: 'one\\\\\\\\two \n three\\\\\\\\four', // 2*8 backslashes. + expr: '%s/,/\\\\\\\\\\\\\\\\/g'}); // 16 backslashes. +testSubstitute('ex_substitute_braces_word', { + value: 'ababab abb ab{2}', + expectedValue: 'ab abb ab{2}', + expr: '%s/(ab){2}//g', + noPcreExpr: '%s/\\(ab\\)\\{2\\}//g'}); +testSubstitute('ex_substitute_braces_range', { + value: 'a aa aaa aaaa', + expectedValue: 'a a', + expr: '%s/a{2,3}//g', + noPcreExpr: '%s/a\\{2,3\\}//g'}); +testSubstitute('ex_substitute_braces_literal', { + value: 'ababab abb ab{2}', + expectedValue: 'ababab abb ', + expr: '%s/ab\\{2\\}//g', + noPcreExpr: '%s/ab{2}//g'}); +testSubstitute('ex_substitute_braces_char', { + value: 'ababab abb ab{2}', + expectedValue: 'ababab ab{2}', + expr: '%s/ab{2}//g', + noPcreExpr: '%s/ab\\{2\\}//g'}); +testSubstitute('ex_substitute_braces_no_escape', { + value: 'ababab abb ab{2}', + expectedValue: 'ababab ab{2}', + expr: '%s/ab{2}//g', + noPcreExpr: '%s/ab\\{2}//g'}); +testSubstitute('ex_substitute_count', { + value: '1\n2\n3\n4', + expectedValue: '1\n0\n0\n4', + expr: 's/\\d/0/i 2'}); +testSubstitute('ex_substitute_count_with_range', { + value: '1\n2\n3\n4', + expectedValue: '1\n2\n0\n0', + expr: '1,3s/\\d/0/ 3'}); +testSubstitute('ex_substitute_not_global', { + value: 'aaa\nbaa\ncaa', + expectedValue: 'xaa\nbxa\ncxa', + expr: '%s/a/x/'}); +function testSubstituteConfirm(name, command, initialValue, expectedValue, keys, finalPos) { + testVim(name, function(cm, vim, helpers) { + var savedOpenDialog = cm.openDialog; + var savedKeyName = CodeMirror.keyName; + var onKeyDown; + var recordedCallback; + var closed = true; // Start out closed, set false on second openDialog. + function close() { + closed = true; + } + // First openDialog should save callback. + cm.openDialog = function(template, callback, options) { + recordedCallback = callback; + } + // Do first openDialog. + helpers.doKeys(':'); + // Second openDialog should save keyDown handler. + cm.openDialog = function(template, callback, options) { + onKeyDown = options.onKeyDown; + closed = false; + }; + // Return the command to Vim and trigger second openDialog. + recordedCallback(command); + // The event should really use keyCode, but here just mock it out and use + // key and replace keyName to just return key. + CodeMirror.keyName = function (e) { return e.key; } + keys = keys.toUpperCase(); + for (var i = 0; i < keys.length; i++) { + is(!closed); + onKeyDown({ key: keys.charAt(i) }, '', close); + } + try { + eq(expectedValue, cm.getValue()); + helpers.assertCursorAt(finalPos); + is(closed); + } catch(e) { + throw e + } finally { + // Restore overriden functions. + CodeMirror.keyName = savedKeyName; + cm.openDialog = savedOpenDialog; + } + }, { value: initialValue }); +}; +testSubstituteConfirm('ex_substitute_confirm_emptydoc', + '%s/x/b/c', '', '', '', makeCursor(0, 0)); +testSubstituteConfirm('ex_substitute_confirm_nomatch', + '%s/x/b/c', 'ba a\nbab', 'ba a\nbab', '', makeCursor(0, 0)); +testSubstituteConfirm('ex_substitute_confirm_accept', + '%s/a/b/cg', 'ba a\nbab', 'bb b\nbbb', 'yyy', makeCursor(1, 1)); +testSubstituteConfirm('ex_substitute_confirm_random_keys', + '%s/a/b/cg', 'ba a\nbab', 'bb b\nbbb', 'ysdkywerty', makeCursor(1, 1)); +testSubstituteConfirm('ex_substitute_confirm_some', + '%s/a/b/cg', 'ba a\nbab', 'bb a\nbbb', 'yny', makeCursor(1, 1)); +testSubstituteConfirm('ex_substitute_confirm_all', + '%s/a/b/cg', 'ba a\nbab', 'bb b\nbbb', 'a', makeCursor(1, 1)); +testSubstituteConfirm('ex_substitute_confirm_accept_then_all', + '%s/a/b/cg', 'ba a\nbab', 'bb b\nbbb', 'ya', makeCursor(1, 1)); +testSubstituteConfirm('ex_substitute_confirm_quit', + '%s/a/b/cg', 'ba a\nbab', 'bb a\nbab', 'yq', makeCursor(0, 3)); +testSubstituteConfirm('ex_substitute_confirm_last', + '%s/a/b/cg', 'ba a\nbab', 'bb b\nbab', 'yl', makeCursor(0, 3)); +testSubstituteConfirm('ex_substitute_confirm_oneline', + '1s/a/b/cg', 'ba a\nbab', 'bb b\nbab', 'yl', makeCursor(0, 3)); +testSubstituteConfirm('ex_substitute_confirm_range_accept', + '1,2s/a/b/cg', 'aa\na \na\na', 'bb\nb \na\na', 'yyy', makeCursor(1, 0)); +testSubstituteConfirm('ex_substitute_confirm_range_some', + '1,3s/a/b/cg', 'aa\na \na\na', 'ba\nb \nb\na', 'ynyy', makeCursor(2, 0)); +testSubstituteConfirm('ex_substitute_confirm_range_all', + '1,3s/a/b/cg', 'aa\na \na\na', 'bb\nb \nb\na', 'a', makeCursor(2, 0)); +testSubstituteConfirm('ex_substitute_confirm_range_last', + '1,3s/a/b/cg', 'aa\na \na\na', 'bb\nb \na\na', 'yyl', makeCursor(1, 0)); +//:noh should clear highlighting of search-results but allow to resume search through n +testVim('ex_noh_clearSearchHighlight', function(cm, vim, helpers) { + cm.openDialog = helpers.fakeOpenDialog('match'); + helpers.doKeys('?'); + helpers.doEx('noh'); + eq(vim.searchState_.getOverlay(),null,'match-highlighting wasn\'t cleared'); + helpers.doKeys('n'); + helpers.assertCursorAt(0, 11,'can\'t resume search after clearing highlighting'); +}, { value: 'match nope match \n nope Match' }); +testVim('set_boolean', function(cm, vim, helpers) { + CodeMirror.Vim.defineOption('testoption', true, 'boolean'); + // Test default value is set. + is(CodeMirror.Vim.getOption('testoption')); + try { + // Test fail to set to non-boolean + CodeMirror.Vim.setOption('testoption', '5'); + fail(); + } catch (expected) {}; + // Test setOption + CodeMirror.Vim.setOption('testoption', false); + is(!CodeMirror.Vim.getOption('testoption')); +}); +testVim('ex_set_boolean', function(cm, vim, helpers) { + CodeMirror.Vim.defineOption('testoption', true, 'boolean'); + // Test default value is set. + is(CodeMirror.Vim.getOption('testoption')); + try { + // Test fail to set to non-boolean + helpers.doEx('set testoption=22'); + fail(); + } catch (expected) {}; + // Test setOption + helpers.doEx('set notestoption'); + is(!CodeMirror.Vim.getOption('testoption')); +}); +testVim('set_string', function(cm, vim, helpers) { + CodeMirror.Vim.defineOption('testoption', 'a', 'string'); + // Test default value is set. + eq('a', CodeMirror.Vim.getOption('testoption')); + try { + // Test fail to set non-string. + CodeMirror.Vim.setOption('testoption', true); + fail(); + } catch (expected) {}; + try { + // Test fail to set 'notestoption' + CodeMirror.Vim.setOption('notestoption', 'b'); + fail(); + } catch (expected) {}; + // Test setOption + CodeMirror.Vim.setOption('testoption', 'c'); + eq('c', CodeMirror.Vim.getOption('testoption')); +}); +testVim('ex_set_string', function(cm, vim, helpers) { + CodeMirror.Vim.defineOption('testopt', 'a', 'string'); + // Test default value is set. + eq('a', CodeMirror.Vim.getOption('testopt')); + try { + // Test fail to set 'notestopt' + helpers.doEx('set notestopt=b'); + fail(); + } catch (expected) {}; + // Test setOption + helpers.doEx('set testopt=c') + eq('c', CodeMirror.Vim.getOption('testopt')); + helpers.doEx('set testopt=c') + eq('c', CodeMirror.Vim.getOption('testopt', cm)); //local || global + eq('c', CodeMirror.Vim.getOption('testopt', cm, {scope: 'local'})); // local + eq('c', CodeMirror.Vim.getOption('testopt', cm, {scope: 'global'})); // global + eq('c', CodeMirror.Vim.getOption('testopt')); // global + // Test setOption global + helpers.doEx('setg testopt=d') + eq('c', CodeMirror.Vim.getOption('testopt', cm)); + eq('c', CodeMirror.Vim.getOption('testopt', cm, {scope: 'local'})); + eq('d', CodeMirror.Vim.getOption('testopt', cm, {scope: 'global'})); + eq('d', CodeMirror.Vim.getOption('testopt')); + // Test setOption local + helpers.doEx('setl testopt=e') + eq('e', CodeMirror.Vim.getOption('testopt', cm)); + eq('e', CodeMirror.Vim.getOption('testopt', cm, {scope: 'local'})); + eq('d', CodeMirror.Vim.getOption('testopt', cm, {scope: 'global'})); + eq('d', CodeMirror.Vim.getOption('testopt')); +}); +testVim('ex_set_callback', function(cm, vim, helpers) { + var global; + + function cb(val, cm, cfg) { + if (val === undefined) { + // Getter + if (cm) { + return cm._local; + } else { + return global; + } + } else { + // Setter + if (cm) { + cm._local = val; + } else { + global = val; + } + } + } + + CodeMirror.Vim.defineOption('testopt', 'a', 'string', cb); + // Test default value is set. + eq('a', CodeMirror.Vim.getOption('testopt')); + try { + // Test fail to set 'notestopt' + helpers.doEx('set notestopt=b'); + fail(); + } catch (expected) {}; + // Test setOption (Identical to the string tests, but via callback instead) + helpers.doEx('set testopt=c') + eq('c', CodeMirror.Vim.getOption('testopt', cm)); //local || global + eq('c', CodeMirror.Vim.getOption('testopt', cm, {scope: 'local'})); // local + eq('c', CodeMirror.Vim.getOption('testopt', cm, {scope: 'global'})); // global + eq('c', CodeMirror.Vim.getOption('testopt')); // global + // Test setOption global + helpers.doEx('setg testopt=d') + eq('c', CodeMirror.Vim.getOption('testopt', cm)); + eq('c', CodeMirror.Vim.getOption('testopt', cm, {scope: 'local'})); + eq('d', CodeMirror.Vim.getOption('testopt', cm, {scope: 'global'})); + eq('d', CodeMirror.Vim.getOption('testopt')); + // Test setOption local + helpers.doEx('setl testopt=e') + eq('e', CodeMirror.Vim.getOption('testopt', cm)); + eq('e', CodeMirror.Vim.getOption('testopt', cm, {scope: 'local'})); + eq('d', CodeMirror.Vim.getOption('testopt', cm, {scope: 'global'})); + eq('d', CodeMirror.Vim.getOption('testopt')); +}) +testVim('ex_set_filetype', function(cm, vim, helpers) { + CodeMirror.defineMode('test_mode', function() { + return {token: function(stream) { + stream.match(/^\s+|^\S+/); + }}; + }); + CodeMirror.defineMode('test_mode_2', function() { + return {token: function(stream) { + stream.match(/^\s+|^\S+/); + }}; + }); + // Test mode is set. + helpers.doEx('set filetype=test_mode'); + eq('test_mode', cm.getMode().name); + // Test 'ft' alias also sets mode. + helpers.doEx('set ft=test_mode_2'); + eq('test_mode_2', cm.getMode().name); +}); +testVim('ex_set_filetype_null', function(cm, vim, helpers) { + CodeMirror.defineMode('test_mode', function() { + return {token: function(stream) { + stream.match(/^\s+|^\S+/); + }}; + }); + cm.setOption('mode', 'test_mode'); + // Test mode is set to null. + helpers.doEx('set filetype='); + eq('null', cm.getMode().name); +}); +// TODO: Reset key maps after each test. +testVim('ex_map_key2key', function(cm, vim, helpers) { + helpers.doEx('map a x'); + helpers.doKeys('a'); + helpers.assertCursorAt(0, 0); + eq('bc', cm.getValue()); +}, { value: 'abc' }); +testVim('ex_unmap_key2key', function(cm, vim, helpers) { + helpers.doEx('unmap a'); + helpers.doKeys('a'); + eq('vim-insert', cm.getOption('keyMap')); +}, { value: 'abc' }); +testVim('ex_unmap_key2key_does_not_remove_default', function(cm, vim, helpers) { + try { + helpers.doEx('unmap a'); + fail(); + } catch (expected) {} + helpers.doKeys('a'); + eq('vim-insert', cm.getOption('keyMap')); +}, { value: 'abc' }); +testVim('ex_map_key2key_to_colon', function(cm, vim, helpers) { + helpers.doEx('map ; :'); + var dialogOpened = false; + cm.openDialog = function() { + dialogOpened = true; + } + helpers.doKeys(';'); + eq(dialogOpened, true); +}); +testVim('ex_map_ex2key:', function(cm, vim, helpers) { + helpers.doEx('map :del x'); + helpers.doEx('del'); + helpers.assertCursorAt(0, 0); + eq('bc', cm.getValue()); +}, { value: 'abc' }); +testVim('ex_map_ex2ex', function(cm, vim, helpers) { + helpers.doEx('map :del :w'); + var tmp = CodeMirror.commands.save; + var written = false; + var actualCm; + CodeMirror.commands.save = function(cm) { + written = true; + actualCm = cm; + }; + helpers.doEx('del'); + CodeMirror.commands.save = tmp; + eq(written, true); + eq(actualCm, cm); +}); +testVim('ex_map_key2ex', function(cm, vim, helpers) { + helpers.doEx('map a :w'); + var tmp = CodeMirror.commands.save; + var written = false; + var actualCm; + CodeMirror.commands.save = function(cm) { + written = true; + actualCm = cm; + }; + helpers.doKeys('a'); + CodeMirror.commands.save = tmp; + eq(written, true); + eq(actualCm, cm); +}); +testVim('ex_map_key2key_visual_api', function(cm, vim, helpers) { + CodeMirror.Vim.map('b', ':w', 'visual'); + var tmp = CodeMirror.commands.save; + var written = false; + var actualCm; + CodeMirror.commands.save = function(cm) { + written = true; + actualCm = cm; + }; + // Mapping should not work in normal mode. + helpers.doKeys('b'); + eq(written, false); + // Mapping should work in visual mode. + helpers.doKeys('v', 'b'); + eq(written, true); + eq(actualCm, cm); + + CodeMirror.commands.save = tmp; +}); +testVim('ex_imap', function(cm, vim, helpers) { + CodeMirror.Vim.map('jk', '', 'insert'); + helpers.doKeys('i'); + is(vim.insertMode); + helpers.doKeys('j', 'k'); + is(!vim.insertMode); +}) + +// Testing registration of functions as ex-commands and mapping to -keys +testVim('ex_api_test', function(cm, vim, helpers) { + var res=false; + var val='from'; + CodeMirror.Vim.defineEx('extest','ext',function(cm,params){ + if(params.args)val=params.args[0]; + else res=true; + }); + helpers.doEx(':ext to'); + eq(val,'to','Defining ex-command failed'); + CodeMirror.Vim.map('',':ext'); + helpers.doKeys('',''); + is(res,'Mapping to key failed'); +}); +// For now, this test needs to be last because it messes up : for future tests. +testVim('ex_map_key2key_from_colon', function(cm, vim, helpers) { + helpers.doEx('map : x'); + helpers.doKeys(':'); + helpers.assertCursorAt(0, 0); + eq('bc', cm.getValue()); +}, { value: 'abc' }); + +// Test event handlers +testVim('beforeSelectionChange', function(cm, vim, helpers) { + cm.setCursor(0, 100); + eqPos(cm.getCursor('head'), cm.getCursor('anchor')); +}, { value: 'abc' }); + + +}); + + +if (typeof module !== "undefined" && module === require.main) { + require("asyncjs").test.testcase(module.exports).exec(); +} diff --git a/lib/ace/layer/cursor.js b/lib/ace/layer/cursor.js index 26ade52b..53c30e56 100644 --- a/lib/ace/layer/cursor.js +++ b/lib/ace/layer/cursor.js @@ -32,11 +32,15 @@ define(function(require, exports, module) { "use strict"; var dom = require("../lib/dom"); +var IE8; var Cursor = function(parentEl) { this.element = dom.createElement("div"); this.element.className = "ace_layer ace_cursor-layer"; parentEl.appendChild(this.element); + + if (IE8 === undefined) + IE8 = "opacity" in this.element; this.isVisible = false; this.isBlinking = true; @@ -46,9 +50,22 @@ var Cursor = function(parentEl) { this.cursors = []; this.cursor = this.addCursor(); dom.addCssClass(this.element, "ace_hidden-cursors"); + this.$updateCursors = this.$updateVisibility.bind(this); }; (function() { + + this.$updateVisibility = function(val) { + var cursors = this.cursors; + for (var i = cursors.length; i--; ) + cursors[i].style.visibility = val ? "" : "hidden"; + }; + this.$updateOpacity = function(val) { + var cursors = this.cursors; + for (var i = cursors.length; i--; ) + cursors[i].style.opacity = val ? "" : "0"; + }; + this.$padding = 0; this.setPadding = function(padding) { @@ -74,12 +91,13 @@ var Cursor = function(parentEl) { }; this.setSmoothBlinking = function(smoothBlinking) { - if (smoothBlinking != this.smoothBlinking) { + if (smoothBlinking != this.smoothBlinking && !IE8) { this.smoothBlinking = smoothBlinking; - if (smoothBlinking) - dom.addCssClass(this.element, "ace_smooth-blinking"); - else - dom.removeCssClass(this.element, "ace_smooth-blinking"); + dom.setCssClass(this.element, "ace_smooth-blinking", smoothBlinking); + this.$updateCursors(true); + this.$updateCursors = (smoothBlinking + ? this.$updateOpacity + : this.$updateVisibility).bind(this); this.restartTimer(); } }; @@ -113,35 +131,34 @@ var Cursor = function(parentEl) { }; this.restartTimer = function() { + var update = this.$updateCursors; clearInterval(this.intervalId); clearTimeout(this.timeoutId); - if (this.smoothBlinking) + if (this.smoothBlinking) { dom.removeCssClass(this.element, "ace_smooth-blinking"); - for (var i = this.cursors.length; i--; ) - this.cursors[i].style.opacity = ""; + } + + update(true); if (!this.isBlinking || !this.blinkInterval || !this.isVisible) return; - if (this.smoothBlinking) + if (this.smoothBlinking) { setTimeout(function(){ dom.addCssClass(this.element, "ace_smooth-blinking"); }.bind(this)); - + } + var blink = function(){ this.timeoutId = setTimeout(function() { - for (var i = this.cursors.length; i--; ) { - this.cursors[i].style.opacity = 0; - } - }.bind(this), 0.6 * this.blinkInterval); + update(false); + }, 0.6 * this.blinkInterval); }.bind(this); this.intervalId = setInterval(function() { - for (var i = this.cursors.length; i--; ) { - this.cursors[i].style.opacity = ""; - } + update(true); blink(); - }.bind(this), this.blinkInterval); + }, this.blinkInterval); blink(); }; @@ -173,16 +190,20 @@ var Cursor = function(parentEl) { for (var i = 0, n = selections.length; i < n; i++) { var pixelPos = this.getPixelPosition(selections[i].cursor, true); if ((pixelPos.top > config.height + config.offset || - pixelPos.top < -config.offset) && i > 1) { + pixelPos.top < 0) && i > 1) { continue; } var style = (this.cursors[cursorIndex++] || this.addCursor()).style; - - style.left = pixelPos.left + "px"; - style.top = pixelPos.top + "px"; - style.width = config.characterWidth + "px"; - style.height = config.lineHeight + "px"; + + if (!this.drawCursor) { + style.left = pixelPos.left + "px"; + style.top = pixelPos.top + "px"; + style.width = config.characterWidth + "px"; + style.height = config.lineHeight + "px"; + } else { + this.drawCursor(style, pixelPos, config, selections[i], this.session); + } } while (this.cursors.length > cursorIndex) this.removeCursor(); @@ -194,6 +215,8 @@ var Cursor = function(parentEl) { this.$pixelPos = pixelPos; this.restartTimer(); }; + + this.drawCursor = null; this.$setOverwrite = function(overwrite) { if (overwrite != this.overwrite) { diff --git a/lib/ace/layer/font_metrics.js b/lib/ace/layer/font_metrics.js new file mode 100644 index 00000000..715c6cf3 --- /dev/null +++ b/lib/ace/layer/font_metrics.js @@ -0,0 +1,176 @@ +/* ***** 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. + * + * ***** END LICENSE BLOCK ***** */ + +define(function(require, exports, module) { + +var oop = require("../lib/oop"); +var dom = require("../lib/dom"); +var lang = require("../lib/lang"); +var useragent = require("../lib/useragent"); +var EventEmitter = require("../lib/event_emitter").EventEmitter; + +var CHAR_COUNT = 0; + +var FontMetrics = exports.FontMetrics = function(parentEl, interval) { + this.el = dom.createElement("div"); + this.$setMeasureNodeStyles(this.el.style, true); + + this.$main = dom.createElement("div"); + this.$setMeasureNodeStyles(this.$main.style); + + this.$measureNode = dom.createElement("div"); + this.$setMeasureNodeStyles(this.$measureNode.style); + + + this.el.appendChild(this.$main); + this.el.appendChild(this.$measureNode); + parentEl.appendChild(this.el); + + if (!CHAR_COUNT) + this.$testFractionalRect(); + this.$measureNode.innerHTML = lang.stringRepeat("X", CHAR_COUNT); + + this.$characterSize = {width: 0, height: 0}; + this.checkForSizeChanges(); +}; + +(function() { + + oop.implement(this, EventEmitter); + + this.$characterSize = {width: 0, height: 0}; + + this.$testFractionalRect = function() { + var el = dom.createElement("div"); + this.$setMeasureNodeStyles(el.style); + el.style.width = "0.2px"; + document.documentElement.appendChild(el); + var w = el.getBoundingClientRect().width; + if (w > 0 && w < 1) + CHAR_COUNT = 50; + else + CHAR_COUNT = 100; + el.parentNode.removeChild(el); + }; + + this.$setMeasureNodeStyles = function(style, isRoot) { + style.width = style.height = "auto"; + style.left = style.top = "0px"; + style.visibility = "hidden"; + style.position = "absolute"; + style.whiteSpace = "pre"; + + if (useragent.isIE < 8) { + style["font-family"] = "inherit"; + } else { + style.font = "inherit"; + } + style.overflow = isRoot ? "hidden" : "visible"; + }; + + this.checkForSizeChanges = function() { + var size = this.$measureSizes(); + if (size && (this.$characterSize.width !== size.width || this.$characterSize.height !== size.height)) { + this.$measureNode.style.fontWeight = "bold"; + var boldSize = this.$measureSizes(); + this.$measureNode.style.fontWeight = ""; + this.$characterSize = size; + this.charSizes = Object.create(null); + this.allowBoldFonts = boldSize && boldSize.width === size.width && boldSize.height === size.height; + this._emit("changeCharacterSize", {data: size}); + } + }; + + this.$pollSizeChanges = function() { + if (this.$pollSizeChangesTimer) + return this.$pollSizeChangesTimer; + var self = this; + return this.$pollSizeChangesTimer = setInterval(function() { + self.checkForSizeChanges(); + }, 500); + }; + + this.setPolling = function(val) { + if (val) { + this.$pollSizeChanges(); + } else if (this.$pollSizeChangesTimer) { + clearInterval(this.$pollSizeChangesTimer); + this.$pollSizeChangesTimer = 0; + } + }; + + this.$measureSizes = function() { + if (CHAR_COUNT === 50) { + var rect = null; + try { + rect = this.$measureNode.getBoundingClientRect(); + } catch(e) { + rect = {width: 0, height:0 }; + }; + var size = { + height: rect.height, + width: rect.width / CHAR_COUNT + }; + } else { + var size = { + height: this.$measureNode.clientHeight, + width: this.$measureNode.clientWidth / CHAR_COUNT + }; + } + // Size and width can be null if the editor is not visible or + // detached from the document + if (size.width === 0 || size.height === 0) + return null; + return size; + }; + + this.$measureCharWidth = function(ch) { + this.$main.innerHTML = lang.stringRepeat(ch, CHAR_COUNT); + var rect = this.$main.getBoundingClientRect(); + return rect.width / CHAR_COUNT; + }; + + this.getCharacterWidth = function(ch) { + var w = this.charSizes[ch]; + if (w === undefined) { + this.charSizes[ch] = this.$measureCharWidth(ch) / this.$characterSize.width; + } + return w; + }; + + this.destroy = function() { + clearInterval(this.$pollSizeChangesTimer); + if (this.el && this.el.parentNode) + this.el.parentNode.removeChild(this.el); + }; + +}).call(FontMetrics.prototype); + +}); diff --git a/lib/ace/layer/gutter.js b/lib/ace/layer/gutter.js index 109d6a67..dc1055c2 100644 --- a/lib/ace/layer/gutter.js +++ b/lib/ace/layer/gutter.js @@ -46,6 +46,8 @@ var Gutter = function(parentEl) { this.$annotations = []; this.$updateAnnotations = this.$updateAnnotations.bind(this); + + this.$cells = []; }; (function() { @@ -56,7 +58,8 @@ var Gutter = function(parentEl) { if (this.session) this.session.removeEventListener("change", this.$updateAnnotations); this.session = session; - session.on("change", this.$updateAnnotations); + if (session) + session.on("change", this.$updateAnnotations); }; this.addGutterDecoration = function(row, className){ @@ -73,8 +76,7 @@ var Gutter = function(parentEl) { this.setAnnotations = function(annotations) { // iterate over sparse array - this.$annotations = [] - var rowInfo, row; + this.$annotations = []; for (var i = 0; i < annotations.length; i++) { var annotation = annotations[i]; var row = annotation.row; @@ -98,89 +100,150 @@ var Gutter = function(parentEl) { } }; - this.$updateAnnotations = function (e) { + this.$updateAnnotations = function (delta) { if (!this.$annotations.length) return; - var delta = e.data; - var range = delta.range; - var firstRow = range.start.row; - var len = range.end.row - firstRow; + var firstRow = delta.start.row; + var len = delta.end.row - firstRow; if (len === 0) { // do nothing - } else if (delta.action == "removeText" || delta.action == "removeLines") { + } else if (delta.action == 'remove') { this.$annotations.splice(firstRow, len + 1, null); } else { - var args = Array(len + 1); + var args = new Array(len + 1); args.unshift(firstRow, 1); this.$annotations.splice.apply(this.$annotations, args); } }; this.update = function(config) { - var emptyAnno = {className: ""}; - var html = []; - var i = config.firstRow; - var lastRow = config.lastRow; - var fold = this.session.getNextFoldLine(i); + var session = this.session; + var firstRow = config.firstRow; + var lastRow = Math.min(config.lastRow + config.gutterOffset, // needed to compensate for hor scollbar + session.getLength() - 1); + var fold = session.getNextFoldLine(firstRow); var foldStart = fold ? fold.start.row : Infinity; - var foldWidgets = this.$showFoldWidgets && this.session.foldWidgets; - var breakpoints = this.session.$breakpoints; - var decorations = this.session.$decorations; - var firstLineNumber = this.session.$firstLineNumber; + var foldWidgets = this.$showFoldWidgets && session.foldWidgets; + var breakpoints = session.$breakpoints; + var decorations = session.$decorations; + var firstLineNumber = session.$firstLineNumber; var lastLineNumber = 0; + + var gutterRenderer = session.gutterRenderer || this.$renderer; + var cell = null; + var index = -1; + var row = firstRow; while (true) { - if(i > foldStart) { - i = fold.end.row + 1; - fold = this.session.getNextFoldLine(i, fold); - foldStart = fold ?fold.start.row :Infinity; + if (row > foldStart) { + row = fold.end.row + 1; + fold = session.getNextFoldLine(row, fold); + foldStart = fold ? fold.start.row : Infinity; } - if(i > lastRow) + if (row > lastRow) { + while (this.$cells.length > index + 1) { + cell = this.$cells.pop(); + this.element.removeChild(cell.element); + } break; + } - var annotation = this.$annotations[i] || emptyAnno; - html.push( - "
    ", - lastLineNumber = i + firstLineNumber - ); + cell = this.$cells[++index]; + if (!cell) { + cell = {element: null, textNode: null, foldWidget: null}; + cell.element = dom.createElement("div"); + cell.textNode = document.createTextNode(''); + cell.element.appendChild(cell.textNode); + this.element.appendChild(cell.element); + this.$cells[index] = cell; + } + + var className = "ace_gutter-cell "; + if (breakpoints[row]) + className += breakpoints[row]; + if (decorations[row]) + className += decorations[row]; + if (this.$annotations[row]) + className += this.$annotations[row].className; + if (cell.element.className != className) + cell.element.className = className; + + var height = session.getRowLength(row) * config.lineHeight + "px"; + if (height != cell.element.style.height) + cell.element.style.height = height; if (foldWidgets) { - var c = foldWidgets[i]; + var c = foldWidgets[row]; // check if cached value is invalidated and we need to recompute if (c == null) - c = foldWidgets[i] = this.session.getFoldWidget(i); - if (c) - html.push( - "" - ); + c = foldWidgets[row] = session.getFoldWidget(row); } - html.push("
    "); + if (c) { + if (!cell.foldWidget) { + cell.foldWidget = dom.createElement("span"); + cell.element.appendChild(cell.foldWidget); + } + var className = "ace_fold-widget ace_" + c; + if (c == "start" && row == foldStart && row < fold.end.row) + className += " ace_closed"; + else + className += " ace_open"; + if (cell.foldWidget.className != className) + cell.foldWidget.className = className; - i++; + var height = config.lineHeight + "px"; + if (cell.foldWidget.style.height != height) + cell.foldWidget.style.height = height; + } else { + if (cell.foldWidget) { + cell.element.removeChild(cell.foldWidget); + cell.foldWidget = null; + } + } + + var text = lastLineNumber = gutterRenderer + ? gutterRenderer.getText(session, row) + : row + firstLineNumber; + if (text != cell.textNode.data) + cell.textNode.data = text; + + row++; } - this.element = dom.setInnerHtml(this.element, html.join("")); this.element.style.height = config.minHeight + "px"; + + if (this.$fixedWidth || session.$useWrapMode) + lastLineNumber = session.getLength() + firstLineNumber; + + var gutterWidth = gutterRenderer + ? gutterRenderer.getWidth(session, lastLineNumber, config) + : lastLineNumber.toString().length * config.characterWidth; - if (this.session.$useWrapMode) - lastLineNumber = this.session.getLength(); - - var gutterWidth = ("" + lastLineNumber).length * config.characterWidth; var padding = this.$padding || this.$computePadding(); gutterWidth += padding.left + padding.right; - if (gutterWidth !== this.gutterWidth) { + if (gutterWidth !== this.gutterWidth && !isNaN(gutterWidth)) { this.gutterWidth = gutterWidth; this.element.style.width = Math.ceil(this.gutterWidth) + "px"; this._emit("changeGutterWidth", gutterWidth); } }; + this.$fixedWidth = false; + + this.$showLineNumbers = true; + this.$renderer = ""; + this.setShowLineNumbers = function(show) { + this.$renderer = !show && { + getWidth: function() {return ""}, + getText: function() {return ""} + }; + }; + + this.getShowLineNumbers = function() { + return this.$showLineNumbers; + }; + this.$showFoldWidgets = true; this.setShowFoldWidgets = function(show) { if (show) @@ -200,9 +263,9 @@ var Gutter = function(parentEl) { if (!this.element.firstChild) return {left: 0, right: 0}; var style = dom.computedStyle(this.element.firstChild); - this.$padding = {} - this.$padding.left = parseInt(style.paddingLeft) + 1; - this.$padding.right = parseInt(style.paddingRight); + this.$padding = {}; + this.$padding.left = parseInt(style.paddingLeft) + 1 || 0; + this.$padding.right = parseInt(style.paddingRight) || 0; return this.$padding; }; diff --git a/lib/ace/layer/marker.js b/lib/ace/layer/marker.js index cd1b992d..9818d225 100644 --- a/lib/ace/layer/marker.js +++ b/lib/ace/layer/marker.js @@ -90,37 +90,40 @@ var Marker = function(parentEl) { else this.drawMultiLineMarker(html, range, marker.clazz, config); } else { - this.drawSingleLineMarker(html, range, marker.clazz + " ace_start", config); + this.drawSingleLineMarker(html, range, marker.clazz + " ace_start" + " ace_br15", config); } } - this.element = dom.setInnerHtml(this.element, html.join("")); + this.element.innerHTML = html.join(""); }; this.$getTop = function(row, layerConfig) { return (row - layerConfig.firstRowScreen) * layerConfig.lineHeight; }; + function getBorderClass(tl, tr, br, bl) { + return (tl ? 1 : 0) | (tr ? 2 : 0) | (br ? 4 : 0) | (bl ? 8 : 0); + } // Draws a marker, which spans a range of text on multiple lines this.drawTextMarker = function(stringBuilder, range, clazz, layerConfig, extraStyle) { - // selection start - var row = range.start.row; - - var lineRange = new Range( - row, range.start.column, - row, this.session.getScreenLastRowColumn(row) - ); - this.drawSingleLineMarker(stringBuilder, lineRange, clazz + " ace_start", layerConfig, 1, extraStyle); - - // selection end - row = range.end.row; - lineRange = new Range(row, 0, row, range.end.column); - this.drawSingleLineMarker(stringBuilder, lineRange, clazz, layerConfig, 0, extraStyle); - - for (row = range.start.row + 1; row < range.end.row; row++) { - lineRange.start.row = row; - lineRange.end.row = row; - lineRange.end.column = this.session.getScreenLastRowColumn(row); - this.drawSingleLineMarker(stringBuilder, lineRange, clazz, layerConfig, 1, extraStyle); + var session = this.session; + var start = range.start.row; + var end = range.end.row; + var row = start; + var prev = 0; + var curr = 0; + var next = session.getScreenLastRowColumn(row); + var lineRange = new Range(row, range.start.column, row, curr); + for (; row <= end; row++) { + lineRange.start.row = lineRange.end.row = row; + lineRange.start.column = row == start ? range.start.column : session.getRowWrapIndent(row); + lineRange.end.column = next; + prev = curr; + curr = next; + next = row + 1 < end ? session.getScreenLastRowColumn(row + 1) : row == end ? 0 : range.end.column; + this.drawSingleLineMarker(stringBuilder, lineRange, + clazz + (row == start ? " ace_start" : "") + " ace_br" + + getBorderClass(row == start || row == start + 1 && range.start.column, prev < curr, curr > next, row == end), + layerConfig, row == end ? 0 : 1, extraStyle); } }; @@ -134,7 +137,7 @@ var Marker = function(parentEl) { extraStyle = extraStyle || ""; stringBuilder.push( - "
    " - + this.TAB_CHAR - + lang.stringRepeat("\xa0", i - 1) + tabStr.push("" + + lang.stringRepeat(this.TAB_CHAR, i) + ""); } else { - tabStr.push(lang.stringRepeat("\xa0", i)); + tabStr.push(lang.stringRepeat(" ", i)); } } if (this.displayIndentGuides) { this.$indentGuideRe = /\s\S| \t|\t |\s$/; var className = "ace_indent-guide"; + var spaceClass = ""; + var tabClass = ""; if (this.showInvisibles) { className += " ace_invisible"; + spaceClass = " ace_invisible_space"; + tabClass = " ace_invisible_tab"; var spaceContent = lang.stringRepeat(this.SPACE_CHAR, this.tabSize); - var tabContent = this.TAB_CHAR + lang.stringRepeat("\xa0", this.tabSize - 1); + var tabContent = lang.stringRepeat(this.TAB_CHAR, this.tabSize); } else{ - var spaceContent = lang.stringRepeat("\xa0", this.tabSize); + var spaceContent = lang.stringRepeat(" ", this.tabSize); var tabContent = spaceContent; } - this.$tabStrings[" "] = "" + spaceContent + ""; - this.$tabStrings["\t"] = "" + tabContent + ""; + this.$tabStrings[" "] = "" + spaceContent + ""; + this.$tabStrings["\t"] = "" + tabContent + ""; } }; @@ -293,7 +202,8 @@ var Text = function(parentEl) { this.$renderLine( html, row, !this.$useLineGroups(), row == foldStart ? foldLine : false ); - dom.setInnerHtml(lineElement, html.join("")); + lineElement.style.height = config.lineHeight * this.session.getRowLength(row) + "px"; + lineElement.innerHTML = html.join(""); } row++; } @@ -359,10 +269,11 @@ var Text = function(parentEl) { if (this.$useLineGroups()) { container.className = 'ace_line_group'; fragment.appendChild(container); + container.style.height = config.lineHeight * this.session.getRowLength(row) + "px"; + } else { - var lines = container.childNodes - while(lines.length) - fragment.appendChild(lines[0]); + while(container.firstChild) + fragment.appendChild(container.firstChild); } row++; @@ -390,7 +301,7 @@ var Text = function(parentEl) { break; if (this.$useLineGroups()) - html.push("
    ") + html.push("
    ") this.$renderLine(html, row, false, row == foldStart ? foldLine : false); @@ -399,7 +310,7 @@ var Text = function(parentEl) { row++; } - this.element = dom.setInnerHtml(this.element, html.join("")); + this.element.innerHTML = html.join(""); }; this.$textToken = { @@ -410,12 +321,12 @@ var Text = function(parentEl) { this.$renderToken = function(stringBuilder, screenColumn, token, value) { var self = this; - var replaceReg = /\t|&|<|( +)|([\x00-\x1f\x80-\xa0\u1680\u180E\u2000-\u200f\u2028\u2029\u202F\u205F\u3000\uFEFF])|[\u1100-\u115F\u11A3-\u11A7\u11FA-\u11FF\u2329-\u232A\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u2FFB\u3000-\u303E\u3041-\u3096\u3099-\u30FF\u3105-\u312D\u3131-\u318E\u3190-\u31BA\u31C0-\u31E3\u31F0-\u321E\u3220-\u3247\u3250-\u32FE\u3300-\u4DBF\u4E00-\uA48C\uA490-\uA4C6\uA960-\uA97C\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFAFF\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE66\uFE68-\uFE6B\uFF01-\uFF60\uFFE0-\uFFE6]/g; + var replaceReg = /\t|&|<|( +)|([\x00-\x1f\x80-\xa0\xad\u1680\u180E\u2000-\u200f\u2028\u2029\u202F\u205F\u3000\uFEFF])|[\u1100-\u115F\u11A3-\u11A7\u11FA-\u11FF\u2329-\u232A\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u2FFB\u3000-\u303E\u3041-\u3096\u3099-\u30FF\u3105-\u312D\u3131-\u318E\u3190-\u31BA\u31C0-\u31E3\u31F0-\u321E\u3220-\u3247\u3250-\u32FE\u3300-\u4DBF\u4E00-\uA48C\uA490-\uA4C6\uA960-\uA97C\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFAFF\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE66\uFE68-\uFE6B\uFF01-\uFF60\uFFE0-\uFFE6]/g; var replaceFunc = function(c, a, b, tabIdx, idx4) { if (a) { - return self.showInvisibles ? - "" + lang.stringRepeat(self.SPACE_CHAR, c.length) + "" : - lang.stringRepeat("\xa0", c.length); + return self.showInvisibles + ? "" + lang.stringRepeat(self.SPACE_CHAR, c.length) + "" + : c; } else if (c == "&") { return "&"; } else if (c == "<") { @@ -426,14 +337,14 @@ var Text = function(parentEl) { return self.$tabStrings[tabSize]; } else if (c == "\u3000") { // U+3000 is both invisible AND full-width, so must be handled uniquely - var classToUse = self.showInvisibles ? "ace_cjk ace_invisible" : "ace_cjk"; + var classToUse = self.showInvisibles ? "ace_cjk ace_invisible ace_invisible_space" : "ace_cjk"; var space = self.showInvisibles ? self.SPACE_CHAR : ""; screenColumn += 1; return "" + space + ""; } else if (b) { - return "" + self.SPACE_CHAR + ""; + return "" + self.SPACE_CHAR + ""; } else { screenColumn += 1; return "" + "
    " ); } @@ -567,7 +483,7 @@ var Text = function(parentEl) { row = foldLine.end.row stringBuilder.push( - "", + "", row == this.session.getLength() - 1 ? this.EOF_CHAR : this.EOL_CHAR, "" ); diff --git a/lib/ace/layer/text_test.js b/lib/ace/layer/text_test.js index a14a37e6..3946ec66 100644 --- a/lib/ace/layer/text_test.js +++ b/lib/ace/layer/text_test.js @@ -81,17 +81,17 @@ module.exports = { this.textLayer.$renderLine(stringBuilder, 0, true); assert.equal( stringBuilder.join(""), - "" + this.textLayer.SPACE_CHAR + "" - + "\xB6" + "" + this.textLayer.SPACE_CHAR + "" + + "\xB6" ); }, - - "test rendering of indent guides" : function() { + + "test rendering of indent guides" : function() { var textLayer = this.textLayer - var EOL = "" + textLayer.EOL_CHAR + ""; - var SPACE = function(i) {return Array(i+1).join("\xa0")} + var EOL = "" + textLayer.EOL_CHAR + ""; + var SPACE = function(i) {return Array(i+1).join(" ")} var DOT = function(i) {return Array(i+1).join(textLayer.SPACE_CHAR)} - var TAB = function(i) {return textLayer.TAB_CHAR + SPACE(i-1)} + var TAB = function(i) {return Array(i+1).join(textLayer.TAB_CHAR)} function testRender(results) { for (var i = results.length; i--; ) { var stringBuilder = []; @@ -108,13 +108,13 @@ module.exports = { ]); this.textLayer.setShowInvisibles(true); testRender([ - "" + DOT(4) + "" + DOT(2) + "" + EOL, - "" + TAB(4) + "" + TAB(4) + "f" + EOL, + "" + DOT(4) + "" + DOT(2) + "" + EOL, + "" + TAB(4) + "" + TAB(4) + "f" + EOL, ]); this.textLayer.setDisplayIndentGuides(false); testRender([ - "" + DOT(6) + "" + EOL, - "" + TAB(4) + "" + TAB(4) + "f" + EOL + "" + DOT(6) + "" + EOL, + "" + TAB(4) + "" + TAB(4) + "f" + EOL ]); } }; diff --git a/lib/ace/lib/app_config.js b/lib/ace/lib/app_config.js new file mode 100644 index 00000000..4fe78a1d --- /dev/null +++ b/lib/ace/lib/app_config.js @@ -0,0 +1,157 @@ +/* ***** 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. + * + * ***** END LICENSE BLOCK ***** */ + +define(function(require, exports, module) { +"no use strict"; + +var oop = require("./oop"); +var EventEmitter = require("./event_emitter").EventEmitter; + +var optionsProvider = { + setOptions: function(optList) { + Object.keys(optList).forEach(function(key) { + this.setOption(key, optList[key]); + }, this); + }, + getOptions: function(optionNames) { + var result = {}; + if (!optionNames) { + optionNames = Object.keys(this.$options); + } else if (!Array.isArray(optionNames)) { + result = optionNames; + optionNames = Object.keys(result); + } + optionNames.forEach(function(key) { + result[key] = this.getOption(key); + }, this); + return result; + }, + setOption: function(name, value) { + if (this["$" + name] === value) + return; + var opt = this.$options[name]; + if (!opt) { + return warn('misspelled option "' + name + '"'); + } + if (opt.forwardTo) + return this[opt.forwardTo] && this[opt.forwardTo].setOption(name, value); + + if (!opt.handlesSet) + this["$" + name] = value; + if (opt && opt.set) + opt.set.call(this, value); + }, + getOption: function(name) { + var opt = this.$options[name]; + if (!opt) { + return warn('misspelled option "' + name + '"'); + } + if (opt.forwardTo) + return this[opt.forwardTo] && this[opt.forwardTo].getOption(name); + return opt && opt.get ? opt.get.call(this) : this["$" + name]; + } +}; + +function warn(message) { + if (typeof console != "undefined" && console.warn) + console.warn.apply(console, arguments); +} + +function reportError(msg, data) { + var e = new Error(msg); + e.data = data; + if (typeof console == "object" && console.error) + console.error(e); + setTimeout(function() { throw e; }); +} + +var AppConfig = function() { + this.$defaultOptions = {}; +}; + +(function() { + // module loading + oop.implement(this, EventEmitter); + /* + * option {name, value, initialValue, setterName, set, get } + */ + this.defineOptions = function(obj, path, options) { + if (!obj.$options) + this.$defaultOptions[path] = obj.$options = {}; + + Object.keys(options).forEach(function(key) { + var opt = options[key]; + if (typeof opt == "string") + opt = {forwardTo: opt}; + + opt.name || (opt.name = key); + obj.$options[opt.name] = opt; + if ("initialValue" in opt) + obj["$" + opt.name] = opt.initialValue; + }); + + // implement option provider interface + oop.implement(obj, optionsProvider); + + return this; + }; + + this.resetOptions = function(obj) { + Object.keys(obj.$options).forEach(function(key) { + var opt = obj.$options[key]; + if ("value" in opt) + obj.setOption(key, opt.value); + }); + }; + + this.setDefaultValue = function(path, name, value) { + var opts = this.$defaultOptions[path] || (this.$defaultOptions[path] = {}); + if (opts[name]) { + if (opts.forwardTo) + this.setDefaultValue(opts.forwardTo, name, value); + else + opts[name].value = value; + } + }; + + this.setDefaultValues = function(path, optionHash) { + Object.keys(optionHash).forEach(function(key) { + this.setDefaultValue(path, key, optionHash[key]); + }, this); + }; + + this.warn = warn; + this.reportError = reportError; + +}).call(AppConfig.prototype); + +exports.AppConfig = AppConfig; + +}); diff --git a/lib/ace/lib/dom.js b/lib/ace/lib/dom.js index b3724009..2cbfe23e 100644 --- a/lib/ace/lib/dom.js +++ b/lib/ace/lib/dom.js @@ -31,9 +31,6 @@ define(function(require, exports, module) { "use strict"; -if (typeof document == "undefined") - return; - var XHTML_NS = "http://www.w3.org/1999/xhtml"; exports.getDocumentHead = function(doc) { @@ -49,7 +46,7 @@ exports.createElement = function(tag, ns) { }; exports.hasCssClass = function(el, name) { - var classes = el.className.split(/\s+/g); + var classes = (el.className || "").split(/\s+/g); return classes.indexOf(name) !== -1; }; @@ -94,6 +91,11 @@ exports.toggleCssClass = function(el, name) { return add; }; +if (typeof document == "undefined") { + exports.importCssString = function() {}; + return; +} + /* * Add or remove a CSS class from the list of classes on the given node * depending on the value of include @@ -175,6 +177,7 @@ exports.getInnerHeight = function(element) { ); }; + if (window.pageYOffset !== undefined) { exports.getPageScrollTop = function() { return window.pageYOffset; diff --git a/lib/ace/lib/event.js b/lib/ace/lib/event.js index f80c2042..57924056 100644 --- a/lib/ace/lib/event.js +++ b/lib/ace/lib/event.js @@ -33,7 +33,6 @@ define(function(require, exports, module) { var keys = require("./keys"); var useragent = require("./useragent"); -var dom = require("./dom"); exports.addListener = function(elem, type, callback) { if (elem.addEventListener) { @@ -41,7 +40,7 @@ exports.addListener = function(elem, type, callback) { } if (elem.attachEvent) { var wrapper = function() { - callback(window.event); + callback.call(elem, window.event); }; callback._wrapper = wrapper; elem.attachEvent("on" + type, wrapper); @@ -86,7 +85,7 @@ exports.preventDefault = function(e) { exports.getButton = function(e) { if (e.type == "dblclick") return 0; - if (e.type == "contextmenu" || (e.ctrlKey && useragent.isMac)) + if (e.type == "contextmenu" || (useragent.isMac && (e.ctrlKey && !e.altKey && !e.shiftKey))) return 2; // DOM Event @@ -99,51 +98,27 @@ exports.getButton = function(e) { } }; -if (document.documentElement.setCapture) { - exports.capture = function(el, eventHandler, releaseCaptureHandler) { - var called = false; - function onReleaseCapture(e) { - eventHandler(e); +exports.capture = function(el, eventHandler, releaseCaptureHandler) { + function onMouseUp(e) { + eventHandler && eventHandler(e); + releaseCaptureHandler && releaseCaptureHandler(e); - if (!called) { - called = true; - releaseCaptureHandler(e); - } + exports.removeListener(document, "mousemove", eventHandler, true); + exports.removeListener(document, "mouseup", onMouseUp, true); + exports.removeListener(document, "dragstart", onMouseUp, true); + } - exports.removeListener(el, "mousemove", eventHandler); - exports.removeListener(el, "mouseup", onReleaseCapture); - exports.removeListener(el, "losecapture", onReleaseCapture); - - el.releaseCapture(); - } - - exports.addListener(el, "mousemove", eventHandler); - exports.addListener(el, "mouseup", onReleaseCapture); - exports.addListener(el, "losecapture", onReleaseCapture); - el.setCapture(); - }; -} -else { - exports.capture = function(el, eventHandler, releaseCaptureHandler) { - function onMouseUp(e) { - eventHandler && eventHandler(e); - releaseCaptureHandler && releaseCaptureHandler(e); - - document.removeEventListener("mousemove", eventHandler, true); - document.removeEventListener("mouseup", onMouseUp, true); - - e.stopPropagation(); - } - - document.addEventListener("mousemove", eventHandler, true); - document.addEventListener("mouseup", onMouseUp, true); - }; -} + exports.addListener(document, "mousemove", eventHandler, true); + exports.addListener(document, "mouseup", onMouseUp, true); + exports.addListener(document, "dragstart", onMouseUp, true); + + return onMouseUp; +}; exports.addMouseWheelListener = function(el, callback) { - var factor = 8; - var listener = function(e) { - if (e.wheelDelta !== undefined) { + if ("onmousewheel" in el) { + exports.addListener(el, "mousewheel", function(e) { + var factor = 8; if (e.wheelDeltaX !== undefined) { e.wheelX = -e.wheelDeltaX / factor; e.wheelY = -e.wheelDeltaY / factor; @@ -151,8 +126,27 @@ exports.addMouseWheelListener = function(el, callback) { e.wheelX = 0; e.wheelY = -e.wheelDelta / factor; } - } - else { + callback(e); + }); + } else if ("onwheel" in el) { + exports.addListener(el, "wheel", function(e) { + var factor = 0.35; + switch (e.deltaMode) { + case e.DOM_DELTA_PIXEL: + e.wheelX = e.deltaX * factor || 0; + e.wheelY = e.deltaY * factor || 0; + break; + case e.DOM_DELTA_LINE: + case e.DOM_DELTA_PAGE: + e.wheelX = (e.deltaX || 0) * 5; + e.wheelY = (e.deltaY || 0) * 5; + break; + } + + callback(e); + }); + } else { + exports.addListener(el, "DOMMouseScroll", function(e) { if (e.axis && e.axis == e.HORIZONTAL_AXIS) { e.wheelX = (e.detail || 0) * 5; e.wheelY = 0; @@ -160,16 +154,14 @@ exports.addMouseWheelListener = function(el, callback) { e.wheelX = 0; e.wheelY = (e.detail || 0) * 5; } - } - callback(e); - }; - exports.addListener(el, "DOMMouseScroll", listener); - exports.addListener(el, "mousewheel", listener); + callback(e); + }); + } }; exports.addMultiMouseDownListener = function(el, timeouts, eventHandler, callbackName) { var clicks = 0; - var startX, startY, timer; + var startX, startY, timer; var eventNames = { 2: "dblclick", 3: "tripleclick", @@ -177,24 +169,30 @@ exports.addMultiMouseDownListener = function(el, timeouts, eventHandler, callbac }; exports.addListener(el, "mousedown", function(e) { - if (exports.getButton(e) != 0) { + if (exports.getButton(e) !== 0) { clicks = 0; + } else if (e.detail > 1) { + clicks++; + if (clicks > 4) + clicks = 1; } else { + clicks = 1; + } + if (useragent.isIE) { var isNewClick = Math.abs(e.clientX - startX) > 5 || Math.abs(e.clientY - startY) > 5; - if (!timer || isNewClick) - clicks = 0; - - clicks += 1; - + clicks = 1; if (timer) - clearTimeout(timer) + clearTimeout(timer); timer = setTimeout(function() {timer = null}, timeouts[clicks - 1] || 600); + + if (clicks == 1) { + startX = e.clientX; + startY = e.clientY; + } } - if (clicks == 1) { - startX = e.clientX; - startY = e.clientY; - } + + e._clicks = clicks; eventHandler[callbackName]("mousedown", e); @@ -216,51 +214,80 @@ exports.addMultiMouseDownListener = function(el, timeouts, eventHandler, callbac } }; +var getModifierHash = useragent.isMac && useragent.isOpera && !("KeyboardEvent" in window) + ? function(e) { + return 0 | (e.metaKey ? 1 : 0) | (e.altKey ? 2 : 0) | (e.shiftKey ? 4 : 0) | (e.ctrlKey ? 8 : 0); + } + : function(e) { + return 0 | (e.ctrlKey ? 1 : 0) | (e.altKey ? 2 : 0) | (e.shiftKey ? 4 : 0) | (e.metaKey ? 8 : 0); + }; + +exports.getModifierString = function(e) { + return keys.KEY_MODS[getModifierHash(e)]; +}; + function normalizeCommandKeys(callback, e, keyCode) { - var hashId = 0; - if ((useragent.isOpera && !("KeyboardEvent" in window)) && useragent.isMac) { - hashId = 0 | (e.metaKey ? 1 : 0) | (e.altKey ? 2 : 0) - | (e.shiftKey ? 4 : 0) | (e.ctrlKey ? 8 : 0); - } else { - hashId = 0 | (e.ctrlKey ? 1 : 0) | (e.altKey ? 2 : 0) - | (e.shiftKey ? 4 : 0) | (e.metaKey ? 8 : 0); - } + var hashId = getModifierHash(e); - if (keyCode in keys.MODIFIER_KEYS) { - switch (keys.MODIFIER_KEYS[keyCode]) { - case "Alt": - hashId = 2; - break; - case "Shift": - hashId = 4; - break; - case "Ctrl": - hashId = 1; - break; - default: - hashId = 8; - break; + if (!useragent.isMac && pressedKeys) { + if (pressedKeys[91] || pressedKeys[92]) + hashId |= 8; + if (pressedKeys.altGr) { + if ((3 & hashId) != 3) + pressedKeys.altGr = 0; + else + return; } - keyCode = 0; + if (keyCode === 18 || keyCode === 17) { + var location = "location" in e ? e.location : e.keyLocation; + if (keyCode === 17 && location === 1) { + if (pressedKeys[keyCode] == 1) + ts = e.timeStamp; + } else if (keyCode === 18 && hashId === 3 && location === 2) { + var dt = e.timeStamp - ts; + if (dt < 50) + pressedKeys.altGr = true; + } + } + } + + if (keyCode in keys.MODIFIER_KEYS) { + keyCode = -1; } - if (!useragent.isMac && pressedKeys[91] || pressedKeys[92]) - hashId |= 8; - - if (hashId & 8 && (keyCode == 91 || keyCode == 93)) { - keyCode = 0; + if (hashId & 8 && (keyCode === 91 || keyCode === 93)) { + keyCode = -1; + } + + if (!hashId && keyCode === 13) { + var location = "location" in e ? e.location : e.keyLocation; + if (location === 3) { + callback(e, hashId, -keyCode); + if (e.defaultPrevented) + return; + } + } + + if (useragent.isChromeOS && hashId & 8) { + callback(e, hashId, keyCode); + if (e.defaultPrevented) + return; + else + hashId &= ~8; } - // If there is no hashID and the keyCode is not a function key, then + // If there is no hashId and the keyCode is not a function key, then // we don't call the callback as we don't handle a command key here // (it's a normal key/character input). if (!hashId && !(keyCode in keys.FUNCTION_KEYS) && !(keyCode in keys.PRINTABLE_KEYS)) { return false; } + return callback(e, hashId, keyCode); } -var pressedKeys = Object.create(null); +var pressedKeys = null; +var ts = 0; exports.addCommandKeyListener = function(el, callback) { var addListener = exports.addListener; if (useragent.isOldGecko || (useragent.isOpera && !("KeyboardEvent" in window))) { @@ -281,7 +308,7 @@ exports.addCommandKeyListener = function(el, callback) { var lastDefaultPrevented = null; addListener(el, "keydown", function(e) { - pressedKeys[e.keyCode] = true; + pressedKeys[e.keyCode] = (pressedKeys[e.keyCode] || 0) + 1; var result = normalizeCommandKeys(callback, e, e.keyCode); lastDefaultPrevented = e.defaultPrevented; return result; @@ -298,11 +325,15 @@ exports.addCommandKeyListener = function(el, callback) { pressedKeys[e.keyCode] = null; }); - addListener(el, "focus", function(e) { - pressedKeys = Object.create(null); - }); + if (!pressedKeys) { + resetPressedKeys(); + addListener(window, "focus", resetPressedKeys); + } } }; +function resetPressedKeys(e) { + pressedKeys = Object.create(null); +} if (window.postMessage && !useragent.isOldIE) { var postMessageId = 1; diff --git a/lib/ace/lib/event_emitter.js b/lib/ace/lib/event_emitter.js index 482ae0d4..b9860145 100644 --- a/lib/ace/lib/event_emitter.js +++ b/lib/ace/lib/event_emitter.js @@ -55,6 +55,7 @@ EventEmitter._dispatchEvent = function(eventName, e) { if (!e.preventDefault) e.preventDefault = preventDefault; + listeners = listeners.slice(); for (var i=0; i= 0) - && parseFloat(navigator.userAgent.match(/MSIE ([0-9]+[\.0-9]+)/)[1]); + ? parseFloat((ua.match(/(?:MSIE |Trident\/[0-9]+[\.0-9]+;.*rv:)([0-9]+[\.0-9]+)/)||[])[1]) + : parseFloat((ua.match(/(?:Trident\/[0-9]+[\.0-9]+;.*rv:)([0-9]+[\.0-9]+)/)||[])[1]); // for ie exports.isOldIE = exports.isIE && exports.isIE < 9; // Is this Firefox or related? -exports.isGecko = exports.isMozilla = window.controllers && window.navigator.product === "Gecko"; +exports.isGecko = exports.isMozilla = (window.Controllers || window.controllers) && window.navigator.product === "Gecko"; // oldGecko == rev < 2.0 -exports.isOldGecko = exports.isGecko && parseInt((navigator.userAgent.match(/rv\:(\d+)/)||[])[1], 10) < 4; +exports.isOldGecko = exports.isGecko && parseInt((ua.match(/rv\:(\d+)/)||[])[1], 10) < 4; // Is this Opera exports.isOpera = window.opera && Object.prototype.toString.call(window.opera) == "[object Opera]"; @@ -100,4 +101,6 @@ exports.isIPad = ua.indexOf("iPad") >= 0; exports.isTouchPad = ua.indexOf("TouchPad") >= 0; +exports.isChromeOS = ua.indexOf(" CrOS ") >= 0; + }); diff --git a/lib/ace/line_widgets.js b/lib/ace/line_widgets.js new file mode 100644 index 00000000..ba87d857 --- /dev/null +++ b/lib/ace/line_widgets.js @@ -0,0 +1,295 @@ +/* ***** 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. + * + * ***** END LICENSE BLOCK ***** */ + +define(function(require, exports, module) { +"use strict"; + +var oop = require("./lib/oop"); +var dom = require("./lib/dom"); +var Range = require("./range").Range; + + +function LineWidgets(session) { + this.session = session; + this.session.widgetManager = this; + this.session.getRowLength = this.getRowLength; + this.session.$getWidgetScreenLength = this.$getWidgetScreenLength; + this.updateOnChange = this.updateOnChange.bind(this); + this.renderWidgets = this.renderWidgets.bind(this); + this.measureWidgets = this.measureWidgets.bind(this); + this.session._changedWidgets = []; + this.$onChangeEditor = this.$onChangeEditor.bind(this); + + this.session.on("change", this.updateOnChange); + this.session.on("changeEditor", this.$onChangeEditor); +} + +(function() { + this.getRowLength = function(row) { + var h; + if (this.lineWidgets) + h = this.lineWidgets[row] && this.lineWidgets[row].rowCount || 0; + else + h = 0; + if (!this.$useWrapMode || !this.$wrapData[row]) { + return 1 + h; + } else { + return this.$wrapData[row].length + 1 + h; + } + }; + + this.$getWidgetScreenLength = function() { + var screenRows = 0; + this.lineWidgets.forEach(function(w){ + if (w && w.rowCount) + screenRows +=w.rowCount; + }); + return screenRows; + }; + + this.$onChangeEditor = function(e) { + this.attach(e.editor); + }; + + this.attach = function(editor) { + if (editor && editor.widgetManager && editor.widgetManager != this) + editor.widgetManager.detach(); + + if (this.editor == editor) + return; + + this.detach(); + this.editor = editor; + + if (editor) { + editor.widgetManager = this; + editor.renderer.on("beforeRender", this.measureWidgets); + editor.renderer.on("afterRender", this.renderWidgets); + } + }; + this.detach = function(e) { + var editor = this.editor; + if (!editor) + return; + + this.editor = null; + editor.widgetManager = null; + + editor.renderer.off("beforeRender", this.measureWidgets); + editor.renderer.off("afterRender", this.renderWidgets); + var lineWidgets = this.session.lineWidgets; + lineWidgets && lineWidgets.forEach(function(w) { + if (w && w.el && w.el.parentNode) { + w._inDocument = false; + w.el.parentNode.removeChild(w.el); + } + }); + }; + + this.updateOnChange = function(delta) { + var lineWidgets = this.session.lineWidgets; + if (!lineWidgets) return; + + var startRow = delta.start.row; + var len = delta.end.row - startRow; + + if (len === 0) { + // return + } else if (delta.action == 'remove') { + var removed = lineWidgets.splice(startRow + 1, len); + removed.forEach(function(w) { + w && this.removeLineWidget(w); + }, this); + this.$updateRows(); + } else { + var args = new Array(len); + args.unshift(startRow, 0); + lineWidgets.splice.apply(lineWidgets, args); + this.$updateRows(); + } + }; + + this.$updateRows = function() { + var lineWidgets = this.session.lineWidgets; + if (!lineWidgets) return; + var noWidgets = true; + lineWidgets.forEach(function(w, i) { + if (w) { + noWidgets = false; + w.row = i; + } + }); + if (noWidgets) + this.session.lineWidgets = null; + }; + + this.addLineWidget = function(w) { + if (!this.session.lineWidgets) + this.session.lineWidgets = new Array(this.session.getLength()); + + this.session.lineWidgets[w.row] = w; + + var renderer = this.editor.renderer; + if (w.html && !w.el) { + w.el = dom.createElement("div"); + w.el.innerHTML = w.html; + } + if (w.el) { + dom.addCssClass(w.el, "ace_lineWidgetContainer"); + w.el.style.position = "absolute"; + w.el.style.zIndex = 5; + renderer.container.appendChild(w.el); + w._inDocument = true; + } + + if (!w.coverGutter) { + w.el.style.zIndex = 3; + } + if (!w.pixelHeight) { + w.pixelHeight = w.el.offsetHeight; + } + if (w.rowCount == null) + w.rowCount = w.pixelHeight / renderer.layerConfig.lineHeight; + + this.session._emit("changeFold", {data:{start:{row: w.row}}}); + + this.$updateRows(); + this.renderWidgets(null, renderer); + return w; + }; + + this.removeLineWidget = function(w) { + w._inDocument = false; + if (w.el && w.el.parentNode) + w.el.parentNode.removeChild(w.el); + if (w.editor && w.editor.destroy) try { + w.editor.destroy(); + } catch(e){} + if (this.session.lineWidgets) + this.session.lineWidgets[w.row] = undefined; + this.session._emit("changeFold", {data:{start:{row: w.row}}}); + this.$updateRows(); + }; + + this.onWidgetChanged = function(w) { + this.session._changedWidgets.push(w); + this.editor && this.editor.renderer.updateFull(); + }; + + this.measureWidgets = function(e, renderer) { + var changedWidgets = this.session._changedWidgets; + var config = renderer.layerConfig; + + if (!changedWidgets || !changedWidgets.length) return; + var min = Infinity; + for (var i = 0; i < changedWidgets.length; i++) { + var w = changedWidgets[i]; + if (!w._inDocument) { + w._inDocument = true; + renderer.container.appendChild(w.el); + } + + w.h = w.el.offsetHeight; + + if (!w.fixedWidth) { + w.w = w.el.offsetWidth; + w.screenWidth = Math.ceil(w.w / config.characterWidth); + } + + var rowCount = w.h / config.lineHeight; + if (w.coverLine) { + rowCount -= this.session.getRowLineCount(w.row); + if (rowCount < 0) + rowCount = 0; + } + if (w.rowCount != rowCount) { + w.rowCount = rowCount; + if (w.row < min) + min = w.row; + } + } + if (min != Infinity) { + this.session._emit("changeFold", {data:{start:{row: min}}}); + this.session.lineWidgetWidth = null; + } + this.session._changedWidgets = []; + }; + + this.renderWidgets = function(e, renderer) { + var config = renderer.layerConfig; + var lineWidgets = this.session.lineWidgets; + if (!lineWidgets) + return; + var first = Math.min(this.firstRow, config.firstRow); + var last = Math.max(this.lastRow, config.lastRow, lineWidgets.length); + + while (first > 0 && !lineWidgets[first]) + first--; + + this.firstRow = config.firstRow; + this.lastRow = config.lastRow; + + renderer.$cursorLayer.config = config; + for (var i = first; i <= last; i++) { + var w = lineWidgets[i]; + if (!w || !w.el) continue; + + if (!w._inDocument) { + w._inDocument = true; + renderer.container.appendChild(w.el); + } + var top = renderer.$cursorLayer.getPixelPosition({row: i, column:0}, true).top; + if (!w.coverLine) + top += config.lineHeight * this.session.getRowLineCount(w.row); + w.el.style.top = top - config.offset + "px"; + + var left = w.coverGutter ? 0 : renderer.gutterWidth; + if (!w.fixedWidth) + left -= renderer.scrollLeft; + w.el.style.left = left + "px"; + + if (w.fixedWidth) { + w.el.style.right = renderer.scrollBar.getWidth() + "px"; + } else { + w.el.style.right = ""; + } + } + }; + +}).call(LineWidgets.prototype); + + +exports.LineWidgets = LineWidgets; + +}); + + + + diff --git a/lib/ace/mode/_test/highlight_rules_test.js b/lib/ace/mode/_test/highlight_rules_test.js index be6656d8..c3b877ec 100644 --- a/lib/ace/mode/_test/highlight_rules_test.js +++ b/lib/ace/mode/_test/highlight_rules_test.js @@ -1,23 +1,70 @@ var fs = require("fs"); +var path = require("path"); if (!fs.existsSync) - fs.existsSync = require("path").existsSync; + fs.existsSync = path.existsSync; require("amd-loader"); var cwd = __dirname + "/"; +var root = path.normalize(cwd + Array(5).join("../")); + +function jsFileList(path, filter) { + if (!filter) filter = /_test/; + return fs.readdirSync(path).map(function(x) { + if (x.slice(-3) == ".js" && !filter.test(x) && !/\s/.test(x)) + return x.slice(0, -3); + }).filter(Boolean); +} + +function modeList() { + return jsFileList(cwd + "../", /_highlight_rules|_test|_worker|xml_util|_outdent|behaviour|completions/); +} + +function checkModes() { + modeList().forEach(function(modeName) { + try { + var Mode = require("../" + modeName).Mode; + } catch(e) { + console.warn("Can't load mode :" + modeName, e); + return; + } + var m = new Mode(); + if (!m.lineCommentStart && !m.blockComment) + console.warn("missing comment in " + modeName); + if (!m.$id) + console.warn("missing id in " + modeName); + var tokenizer = (new Mode).getTokenizer(); + if (m.lineCommentStart) { + if (Array.isArray(m.lineCommentStart)) { + m.lineCommentStart.forEach(function(x) { + testLineComment(tokenizer, x, modeName) + }); + } else { + testLineComment(tokenizer, m.lineCommentStart, modeName) + } + } + // if (m.blockComment) { + // var tokens = tok.getLineTokens(m.lineCommentStart, "start"); + // if (!/comment/.test(tokens[0])) + // console.warn("broken lineCommentStart in " + modeName); + // } + }); + + function testLineComment(tokenizer, commentStart, modeName) { + var tokens = tokenizer.getLineTokens(commentStart + " ", "start").tokens; + if (!/comment/.test(tokens[0].type)) + console.warn("broken lineCommentStart in " + modeName); + } +} function generateTestData() { - var root = Array(5).join("../") + "/demo/kitchen-sink/docs"; - var docs = fs.readdirSync(cwd + root); + var docRoot = root + "/demo/kitchen-sink/docs"; + var docs = fs.readdirSync(docRoot); var specialDocs = fs.readdirSync(cwd); - var modes = fs.readdirSync(cwd + "../").filter(function(x){ - return !/(_highlight_rules|behaviour|worker)\.js$/.test(x) && /\.js$/.test(x); - }).map(function(x) { - return x.replace(/\.js$/, ""); - }); + var modes = modeList(); - console.log("Docs:", docs); - console.log("Modes:", modes); + // console.log("Docs:", docs); + // console.log("Modes:", modes); docs.forEach(function(docName) { var p = docName.toLowerCase().split("."); @@ -33,31 +80,38 @@ function generateTestData() { var filePath = "text_" + modeName + ".txt"; if (specialDocs.indexOf(filePath) == -1) { - filePath = root + "/" + docName; + filePath = docRoot + "/" + docName; + } else { + filePath = cwd + filePath; } - var text = fs.readFileSync(cwd + filePath, "utf8"); + var text = fs.readFileSync(filePath, "utf8"); try { var Mode = require("../" + modeName).Mode; } catch(e) { console.warn("Can't load mode :" + modeName, p, e); return; } + console.log(modeName); var tokenizer = new Mode().getTokenizer(); var state = "start"; - var data = text.split(/\n|\r|\r\n/).map(function(line) { + var data = text.split(/\r\n|\r|\n/).map(function(line) { var data = tokenizer.getLineTokens(line, state); var tmp = []; tmp.push(JSON.stringify(data.state)); + var tokenizedLine = ""; data.tokens.forEach(function(x) { + tokenizedLine += x.value; tmp.push(JSON.stringify([x.type, x.value])); }); + if (tokenizedLine != line) + tmp.push(JSON.stringify(line)); state = data.state; return tmp.join(",\n "); }); - jsonStr = "[[\n " + data.join("\n],[\n ") + "\n]]"; + var jsonStr = "[[\n " + data.join("\n],[\n ") + "\n]]"; fs.writeFileSync(cwd + "tokens_" + modeName + ".json", jsonStr, "utf8"); }); } @@ -85,29 +139,31 @@ function testMode(modeName, i) { lineData.values = []; lineData.types = []; lineData.state = lineData.shift(); + var line = null; + if (typeof lineData[lineData.length - 1] == "string") + line = lineData.pop(); lineData.forEach(function(x) { lineData.types.push(x[0]); lineData.values.push(x[1]); }); - - var line = lineData.values.join(""); + if (typeof line != "string") + line = lineData.values.join(""); var tokens = tokenizer.getLineTokens(line, state); var values = tokens.tokens.map(function(x) {return x.value;}); var types = tokens.tokens.map(function(x) {return x.type;}); - var success = true; var err = testEqual([ - lineData.state, tokens.state, + JSON.stringify(lineData.state), JSON.stringify(tokens.state), lineData.types, types, lineData.values, values]); if (err) { - console.log(line) + console.log(line); throw "error"; } - state = lineData.state; + state = tokens.state; }); } function testEqual(a) { @@ -143,10 +199,12 @@ function padNumber(num, digits) { // cli var arg = process.argv[2]; if (!arg) - test() + test(); else if (/--?g(en)?/.test(arg)) generateTestData(process.argv.splice(3)); +else if (/--?c(heck)?/.test(arg)) + checkModes(process.argv.splice(3)); else if (/\d+/.test(arg)) test(parseInt(process.argv[2],10) || 0); else - testMode(arg, -1) \ No newline at end of file + testMode(arg, -1); \ No newline at end of file diff --git a/lib/ace/mode/_test/text_coffee.txt b/lib/ace/mode/_test/text_coffee.txt index 094e61b7..2d9ba5ad 100644 --- a/lib/ace/mode/_test/text_coffee.txt +++ b/lib/ace/mode/_test/text_coffee.txt @@ -42,6 +42,7 @@ class Foo extends Bar foo.static.function #!test tokenize string with interpolation a = "#{ 22 / 7 + {x: "#{a + b}"} + 2}" +" #{ "" + {} } )" """heredoc """ do -> diff --git a/lib/ace/mode/_test/text_html.txt b/lib/ace/mode/_test/text_html.txt index 64a32cb2..d2ce8aaa 100644 --- a/lib/ace/mode/_test/text_html.txt +++ b/lib/ace/mode/_test/text_html.txt @@ -1,5 +1,7 @@ -'123' + +'123' + +/*this is js + not &js; diff --git a/lib/ace/mode/_test/text_ruby.txt b/lib/ace/mode/_test/text_ruby.txt index 1343a270..c16ff7c5 100644 --- a/lib/ace/mode/_test/text_ruby.txt +++ b/lib/ace/mode/_test/text_ruby.txt @@ -13,7 +13,7 @@ [1, +1, -1, 12_345, 0.000_1, _, 3_1, 1_2, 1_.0, 0._1]; -{:id => 34, :key => "value"} +{:id => ?", :key => "value", anotherKey: [x, y?]} =begin =end diff --git a/lib/ace/mode/_test/tokens_abc.json b/lib/ace/mode/_test/tokens_abc.json new file mode 100644 index 00000000..c65ae2a5 --- /dev/null +++ b/lib/ace/mode/_test/tokens_abc.json @@ -0,0 +1,2207 @@ +[[ + "start", + ["comment.line.percentage","%abc-2.1"] +],[ + "start", + ["information.keyword","H:"], + ["information.argument.string.unquoted","This file contains some example English tunes"] +],[ + "start", + ["comment.line.percentage","% note that the comments (like this one) are to highlight usages"] +],[ + "start", + ["comment.line.percentage","% and would not normally be included in such detail"] +],[ + "start", + ["information.keyword","O:"], + ["information.argument.string.unquoted","England "], + ["comment.line.percentage","% the origin of all tunes is England"] +],[ + "start" +],[ + "start", + ["information.keyword","X:"], + ["information.argument.string.unquoted","1 "], + ["comment.line.percentage","% tune no 1"] +],[ + "start", + ["information.keyword","T:"], + ["information.argument.string.unquoted","Dusty Miller, The "], + ["comment.line.percentage","% title"] +],[ + "start", + ["information.keyword","T:"], + ["information.argument.string.unquoted","Binny's Jig "], + ["comment.line.percentage","% an alternative title"] +],[ + "start", + ["information.keyword","C:"], + ["information.argument.string.unquoted","Trad. "], + ["comment.line.percentage","% traditional"] +],[ + "start", + ["information.keyword","R:"], + ["information.argument.string.unquoted","DH "], + ["comment.line.percentage","% double hornpipe"] +],[ + "start", + ["information.keyword","M:"], + ["information.argument.string.unquoted","3/4 "], + ["comment.line.percentage","% meter"] +],[ + "start", + ["information.keyword","K:"], + ["information.argument.string.unquoted","G "], + ["comment.line.percentage","% key"] +],[ + "start", + ["pitch.constant.numeric","B"], + ["duration.constant.numeric",">"], + ["pitch.constant.numeric","c"], + ["pitch.constant.numeric","d"], + ["text"," "], + ["pitch.constant.numeric","B"], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","G"], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","F"], + ["pitch.constant.numeric","A"], + ["text"," "], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","c"], + ["text"," "], + ["pitch.constant.numeric","B"], + ["pitch.constant.numeric","A"], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","B"], + ["duration.constant.numeric",">"], + ["pitch.constant.numeric","c"], + ["pitch.constant.numeric","d"], + ["text"," "], + ["pitch.constant.numeric","B"], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","G"], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","D"], + ["pitch.constant.numeric","G"], + ["text"," "], + ["pitch.constant.numeric","G"], + ["pitch.constant.numeric","B"], + ["text"," "], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","G"], + ["barline.keyword.operator",":|"] +],[ + "start", + ["pitch.constant.numeric","B"], + ["pitch.constant.numeric","d"], + ["pitch.constant.numeric","d"], + ["text"," "], + ["pitch.constant.numeric","g"], + ["pitch.constant.numeric","f"], + ["pitch.constant.numeric","g"], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","a"], + ["pitch.constant.numeric","A"], + ["text"," "], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","c"], + ["text"," "], + ["pitch.constant.numeric","B"], + ["pitch.constant.numeric","A"], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","B"], + ["pitch.constant.numeric","d"], + ["pitch.constant.numeric","d"], + ["text"," "], + ["pitch.constant.numeric","g"], + ["pitch.constant.numeric","f"], + ["pitch.constant.numeric","a"], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","g"], + ["pitch.constant.numeric","G"], + ["text"," "], + ["pitch.constant.numeric","G"], + ["pitch.constant.numeric","B"], + ["text"," "], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","G"], + ["barline.keyword.operator",":|"] +],[ + "start", + ["pitch.constant.numeric","B"], + ["pitch.constant.numeric","G"], + ["text"," "], + ["pitch.constant.numeric","G"], + ["duration.constant.numeric","/2"], + ["pitch.constant.numeric","G"], + ["duration.constant.numeric","/2"], + ["pitch.constant.numeric","G"], + ["text"," "], + ["pitch.constant.numeric","B"], + ["pitch.constant.numeric","G"], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","F"], + ["pitch.constant.numeric","A"], + ["text"," "], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","c"], + ["text"," "], + ["pitch.constant.numeric","B"], + ["pitch.constant.numeric","A"], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","B"], + ["pitch.constant.numeric","G"], + ["text"," "], + ["pitch.constant.numeric","G"], + ["duration.constant.numeric","/2"], + ["pitch.constant.numeric","G"], + ["duration.constant.numeric","/2"], + ["pitch.constant.numeric","G"], + ["text"," "], + ["pitch.constant.numeric","B"], + ["pitch.constant.numeric","G"], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","D"], + ["pitch.constant.numeric","G"], + ["text"," "], + ["pitch.constant.numeric","G"], + ["pitch.constant.numeric","B"], + ["text"," "], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","G"], + ["barline.keyword.operator",":|"] +],[ + "start", + ["information.keyword","W:"], + ["information.argument.string.unquoted","Hey, the dusty miller, and his dusty coat;"] +],[ + "start", + ["information.keyword","W:"], + ["information.argument.string.unquoted","He will win a shilling, or he spend a groat."] +],[ + "start", + ["information.keyword","W:"], + ["information.argument.string.unquoted","Dusty was the coat, dusty was the colour;"] +],[ + "start", + ["information.keyword","W:"], + ["information.argument.string.unquoted","Dusty was the kiss, that I got frae the miller."] +],[ + "start" +],[ + "start", + ["information.keyword","X:"], + ["information.argument.string.unquoted","2"] +],[ + "start", + ["information.keyword","T:"], + ["information.argument.string.unquoted","Old Sir Simon the King"] +],[ + "start", + ["information.keyword","C:"], + ["information.argument.string.unquoted","Trad."] +],[ + "start", + ["information.keyword","S:"], + ["information.argument.string.unquoted","Offord MSS "], + ["comment.line.percentage","% from Offord manuscript"] +],[ + "start", + ["information.keyword","N:"], + ["information.argument.string.unquoted","see also Playford "], + ["comment.line.percentage","% reference note"] +],[ + "start", + ["information.keyword","M:"], + ["information.argument.string.unquoted","9/8"] +],[ + "start", + ["information.keyword","R:"], + ["information.argument.string.unquoted","SJ "], + ["comment.line.percentage","% slip jig"] +],[ + "start", + ["information.keyword","N:"], + ["information.argument.string.unquoted","originally in C "], + ["comment.line.percentage","% transcription note"] +],[ + "start", + ["information.keyword","K:"], + ["information.argument.string.unquoted","G"] +],[ + "start", + ["pitch.constant.numeric","D"], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","G"], + ["pitch.constant.numeric","F"], + ["pitch.constant.numeric","G"], + ["text"," "], + ["pitch.constant.numeric","G"], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","G"], + ["text"," "], + ["pitch.constant.numeric","G"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","D"], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","G"], + ["pitch.constant.numeric","F"], + ["pitch.constant.numeric","G"], + ["text"," "], + ["pitch.constant.numeric","G"], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","G"], + ["text"," "], + ["pitch.constant.numeric","F"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","D"], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","E"], + ["pitch.constant.numeric","F"], + ["pitch.constant.numeric","E"], + ["text"," "], + ["pitch.constant.numeric","E"], + ["pitch.constant.numeric","F"], + ["pitch.constant.numeric","E"], + ["text"," "], + ["pitch.constant.numeric","E"], + ["pitch.constant.numeric","F"], + ["pitch.constant.numeric","G"], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","A"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","G"], + ["text"," "], + ["pitch.constant.numeric","F"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","E"], + ["text"," "], + ["pitch.constant.numeric","D"], + ["duration.constant.numeric","2"], + ["barline.keyword.operator",":|"] +],[ + "start", + ["pitch.constant.numeric","D"], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","G"], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","G"], + ["text"," "], + ["pitch.constant.numeric","G"], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","B"], + ["text"," "], + ["pitch.constant.numeric","d"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","D"], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","G"], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","G"], + ["text"," "], + ["pitch.constant.numeric","G"], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","B"], + ["text"," "], + ["pitch.constant.numeric","c"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","D"], + ["barline.keyword.operator","|[1"], + ["text"," "], + ["pitch.constant.numeric","E"], + ["pitch.constant.numeric","F"], + ["pitch.constant.numeric","E"], + ["text"," "], + ["pitch.constant.numeric","E"], + ["pitch.constant.numeric","F"], + ["pitch.constant.numeric","E"], + ["text"," "], + ["pitch.constant.numeric","E"], + ["pitch.constant.numeric","F"], + ["pitch.constant.numeric","G"], + ["barline.keyword.operator","|"], + ["text","["], + ["pitch.constant.numeric","A"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","G"], + ["text","] "], + ["pitch.constant.numeric","F"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","E"], + ["text"," "], + ["pitch.constant.numeric","D"], + ["duration.constant.numeric","2"], + ["barline.keyword.operator",":|"], + ["text","\\ "], + ["comment.line.percentage","% no line-break in score"] +],[ + "start", + ["information.keyword","M:"], + ["information.argument.string.unquoted","12/8 "], + ["comment.line.percentage","% change of meter"] +],[ + "start", + ["barline.keyword.operator","[2"], + ["text"," "], + ["pitch.constant.numeric","E"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","E"], + ["text"," "], + ["pitch.constant.numeric","E"], + ["pitch.constant.numeric","F"], + ["pitch.constant.numeric","E"], + ["text"," "], + ["pitch.constant.numeric","E"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","E"], + ["text"," "], + ["pitch.constant.numeric","E"], + ["pitch.constant.numeric","F"], + ["pitch.constant.numeric","G"], + ["barline.keyword.operator","|"], + ["text","\\ "], + ["comment.line.percentage","% no line-break in score"] +],[ + "start", + ["information.keyword","M:"], + ["information.argument.string.unquoted","9/8 "], + ["comment.line.percentage","% change of meter"] +],[ + "start", + ["pitch.constant.numeric","A"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","G"], + ["text"," "], + ["pitch.constant.numeric","F"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","E"], + ["text"," "], + ["pitch.constant.numeric","D"], + ["duration.constant.numeric","2"], + ["barline.keyword.operator","|]"] +],[ + "start" +],[ + "start", + ["information.keyword","X:"], + ["information.argument.string.unquoted","3"] +],[ + "start", + ["information.keyword","T:"], + ["information.argument.string.unquoted","William and Nancy"] +],[ + "start", + ["information.keyword","T:"], + ["information.argument.string.unquoted","New Mown Hay"] +],[ + "start", + ["information.keyword","T:"], + ["information.argument.string.unquoted","Legacy, The"] +],[ + "start", + ["information.keyword","C:"], + ["information.argument.string.unquoted","Trad."] +],[ + "start", + ["information.keyword","O:"], + ["information.argument.string.unquoted","England; Gloucs; Bledington "], + ["comment.line.percentage","% place of origin"] +],[ + "start", + ["information.keyword","B:"], + ["information.argument.string.unquoted","Sussex Tune Book "], + ["comment.line.percentage","% can be found in these books"] +],[ + "start", + ["information.keyword","B:"], + ["information.argument.string.unquoted","Mally's Cotswold Morris vol.1 2"] +],[ + "start", + ["information.keyword","D:"], + ["information.argument.string.unquoted","Morris On "], + ["comment.line.percentage","% can be heard on this record"] +],[ + "start", + ["information.keyword","P:"], + ["information.argument.string.unquoted","(AB)2(AC)2A "], + ["comment.line.percentage","% play the parts in this order"] +],[ + "start", + ["information.keyword","M:"], + ["information.argument.string.unquoted","6/8"] +],[ + "start", + ["information.keyword","K:"], + ["information.argument.string.unquoted","G "] +],[ + "start", + ["information.keyword.embedded","[P:"], + ["information.argument.string.unquoted","A]"], + ["text"," "], + ["pitch.constant.numeric","D"], + ["barline.keyword.operator","|"], + ["string.quoted","\"G\""], + ["pitch.constant.numeric","G"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","G"], + ["text"," "], + ["pitch.constant.numeric","G"], + ["pitch.constant.numeric","B"], + ["pitch.constant.numeric","d"], + ["barline.keyword.operator","|"], + ["string.quoted","\"C\""], + ["pitch.constant.numeric","e"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","e"], + ["text"," "], + ["string.quoted","\"G\""], + ["pitch.constant.numeric","d"], + ["pitch.constant.numeric","B"], + ["pitch.constant.numeric","G"], + ["barline.keyword.operator","|"], + ["string.quoted","\"D7\""], + ["pitch.constant.numeric","A"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","d"], + ["text"," "], + ["string.quoted","\"G\""], + ["pitch.constant.numeric","B"], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","G"], + ["barline.keyword.operator","|"], + ["string.quoted","\"C\""], + ["pitch.constant.numeric","E"], + ["duration.constant.numeric","2"], + ["string.quoted","\"D7\""], + ["pitch.constant.numeric","F"], + ["text"," "], + ["string.quoted","\"G\""], + ["pitch.constant.numeric","G"], + ["duration.constant.numeric","2"], + ["barline.keyword.operator",":|"] +],[ + "start", + ["information.keyword.embedded","[P:"], + ["information.argument.string.unquoted","B]"], + ["text"," "], + ["pitch.constant.numeric","d"], + ["barline.keyword.operator","|"], + ["string.quoted","\"G\""], + ["pitch.constant.numeric","e"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","d"], + ["text"," "], + ["pitch.constant.numeric","B"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","d"], + ["barline.keyword.operator","|"], + ["string.quoted","\"C\""], + ["pitch.constant.numeric","g"], + ["pitch.constant.numeric","f"], + ["pitch.constant.numeric","e"], + ["text"," "], + ["string.quoted","\"G\""], + ["pitch.constant.numeric","d"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","d"], + ["barline.keyword.operator","|"], + ["text"," "], + ["string.quoted","\"G\""], + ["pitch.constant.numeric","e"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","d"], + ["text"," "], + ["pitch.constant.numeric","B"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","d"], + ["barline.keyword.operator","|"], + ["string.quoted","\"C\""], + ["pitch.constant.numeric","g"], + ["pitch.constant.numeric","f"], + ["pitch.constant.numeric","e"], + ["text"," "], + ["string.quoted","\"D7\""], + ["pitch.constant.numeric","d"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","c"], + ["barline.keyword.operator","|"] +],[ + "start", + ["text"," "], + ["string.quoted","\"G\""], + ["pitch.constant.numeric","B"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","B"], + ["text"," "], + ["pitch.constant.numeric","B"], + ["pitch.constant.numeric","c"], + ["pitch.constant.numeric","d"], + ["barline.keyword.operator","|"], + ["string.quoted","\"C\""], + ["pitch.constant.numeric","e"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","e"], + ["text"," "], + ["string.quoted","\"G\""], + ["pitch.constant.numeric","d"], + ["pitch.constant.numeric","B"], + ["pitch.constant.numeric","G"], + ["barline.keyword.operator","|"], + ["string.quoted","\"D7\""], + ["pitch.constant.numeric","A"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","d"], + ["text"," "], + ["string.quoted","\"G\""], + ["pitch.constant.numeric","B"], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","G"], + ["barline.keyword.operator","|"], + ["string.quoted","\"C\""], + ["pitch.constant.numeric","E"], + ["duration.constant.numeric","2"], + ["string.quoted","\"D7\""], + ["pitch.constant.numeric","F"], + ["text"," "], + ["string.quoted","\"G\""], + ["pitch.constant.numeric","G"], + ["duration.constant.numeric","2"], + ["barline.keyword.operator",":|"] +],[ + "start", + ["comment.line.percentage","% changes of meter, using inline fields"] +],[ + "start", + ["information.keyword.embedded","[T:"], + ["information.argument.string.unquoted","Slows]"], + ["information.keyword.embedded","[M:"], + ["information.argument.string.unquoted","4/4]"], + ["information.keyword.embedded","[L:"], + ["information.argument.string.unquoted","1/4]"], + ["information.keyword.embedded","[P:"], + ["information.argument.string.unquoted","C]"], + ["string.quoted","\"G\""], + ["pitch.constant.numeric","d"], + ["duration.constant.numeric","2"], + ["barline.keyword.operator","|"], + ["string.quoted","\"C\""], + ["pitch.constant.numeric","e"], + ["duration.constant.numeric","2"], + ["text"," "], + ["string.quoted","\"G\""], + ["pitch.constant.numeric","d"], + ["duration.constant.numeric","2"], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","B"], + ["duration.constant.numeric","2"], + ["text"," "], + ["pitch.constant.numeric","d"], + ["duration.constant.numeric","2"], + ["barline.keyword.operator","|"], + ["string.quoted","\"Em\""], + ["pitch.constant.numeric","g"], + ["pitch.constant.numeric","f"], + ["text"," "], + ["string.quoted","\"A7\""], + ["pitch.constant.numeric","e"], + ["duration.constant.numeric","2"], + ["barline.keyword.operator","|"], + ["string.quoted","\"D7\""], + ["pitch.constant.numeric","d"], + ["duration.constant.numeric","2"], + ["text"," "], + ["string.quoted","\"G\""], + ["pitch.constant.numeric","d"], + ["duration.constant.numeric","2"], + ["barline.keyword.operator","|"], + ["text","\\"] +],[ + "start", + ["text"," "], + ["string.quoted","\"C\""], + ["pitch.constant.numeric","e"], + ["duration.constant.numeric","2"], + ["text"," "], + ["string.quoted","\"G\""], + ["pitch.constant.numeric","d"], + ["duration.constant.numeric","2"], + ["barline.keyword.operator","|"], + ["information.keyword.embedded","[M:"], + ["information.argument.string.unquoted","3/8]"], + ["information.keyword.embedded","[L:"], + ["information.argument.string.unquoted","1/8]"], + ["text"," "], + ["string.quoted","\"G\""], + ["pitch.constant.numeric","B"], + ["duration.constant.numeric","2"], + ["text"," "], + ["pitch.constant.numeric","d"], + ["text"," "], + ["barline.keyword.operator","|"], + ["information.keyword.embedded","[M:"], + ["information.argument.string.unquoted","6/8]"], + ["text"," "], + ["string.quoted","\"C\""], + ["pitch.constant.numeric","g"], + ["pitch.constant.numeric","f"], + ["pitch.constant.numeric","e"], + ["text"," "], + ["string.quoted","\"D7\""], + ["pitch.constant.numeric","d"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","c"], + ["barline.keyword.operator","|"] +],[ + "start", + ["text"," "], + ["string.quoted","\"G\""], + ["pitch.constant.numeric","B"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","B"], + ["text"," "], + ["pitch.constant.numeric","B"], + ["pitch.constant.numeric","c"], + ["pitch.constant.numeric","d"], + ["barline.keyword.operator","|"], + ["string.quoted","\"C\""], + ["pitch.constant.numeric","e"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","e"], + ["text"," "], + ["string.quoted","\"G\""], + ["pitch.constant.numeric","d"], + ["pitch.constant.numeric","B"], + ["pitch.constant.numeric","G"], + ["barline.keyword.operator","|"], + ["string.quoted","\"D7\""], + ["pitch.constant.numeric","A"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","d"], + ["text"," "], + ["string.quoted","\"G\""], + ["pitch.constant.numeric","B"], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","G"], + ["barline.keyword.operator","|"], + ["string.quoted","\"C\""], + ["pitch.constant.numeric","E"], + ["duration.constant.numeric","2"], + ["string.quoted","\"D7\""], + ["pitch.constant.numeric","F"], + ["text"," "], + ["string.quoted","\"G\""], + ["pitch.constant.numeric","G"], + ["duration.constant.numeric","2"], + ["barline.keyword.operator",":|"] +],[ + "start" +],[ + "start", + ["information.keyword","X:"], + ["information.argument.string.unquoted","4"] +],[ + "start", + ["information.keyword","T:"], + ["information.argument.string.unquoted","South Downs Jig"] +],[ + "start", + ["information.keyword","R:"], + ["information.argument.string.unquoted","jig"] +],[ + "start", + ["information.keyword","S:"], + ["information.argument.string.unquoted","Robert Harbron"] +],[ + "start", + ["information.keyword","M:"], + ["information.argument.string.unquoted","6/8"] +],[ + "start", + ["information.keyword","L:"], + ["information.argument.string.unquoted","1/8"] +],[ + "start", + ["information.keyword","K:"], + ["information.argument.string.unquoted","G"] +],[ + "start", + ["barline.keyword.operator","|:"], + ["text"," "], + ["pitch.constant.numeric","d"], + ["text"," "], + ["barline.keyword.operator","|"], + ["text"," "], + ["pitch.constant.numeric","d"], + ["pitch.constant.numeric","c"], + ["pitch.constant.numeric","A"], + ["text"," "], + ["pitch.constant.numeric","G"], + ["duration.constant.numeric","3"], + ["text"," "], + ["barline.keyword.operator","|"], + ["text"," "], + ["pitch.constant.numeric","E"], + ["pitch.constant.numeric","F"], + ["pitch.constant.numeric","G"], + ["text"," "], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","F"], + ["pitch.constant.numeric","E"], + ["text"," "], + ["barline.keyword.operator","|"], + ["text"," "], + ["pitch.constant.numeric","D"], + ["pitch.constant.numeric","E"], + ["pitch.constant.numeric","F"], + ["text"," "], + ["pitch.constant.numeric","G"], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","B"], + ["text"," "], + ["barline.keyword.operator","|"], + ["text"," "], + ["pitch.constant.numeric","c"], + ["pitch.constant.numeric","d"], + ["pitch.constant.numeric","e"], + ["text"," "], + ["pitch.constant.numeric","d"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","d"], + ["text"," "], + ["barline.keyword.operator","|"] +],[ + "start", + ["pitch.constant.numeric","d"], + ["pitch.constant.numeric","c"], + ["pitch.constant.numeric","A"], + ["text"," "], + ["pitch.constant.numeric","G"], + ["duration.constant.numeric","3"], + ["text"," "], + ["barline.keyword.operator","|"], + ["text"," "], + ["pitch.constant.numeric","E"], + ["pitch.constant.numeric","F"], + ["pitch.constant.numeric","G"], + ["text"," "], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","F"], + ["pitch.constant.numeric","E"], + ["text"," "], + ["barline.keyword.operator","|"], + ["text"," "], + ["pitch.constant.numeric","D"], + ["pitch.constant.numeric","E"], + ["pitch.constant.numeric","F"], + ["text"," "], + ["pitch.constant.numeric","G"], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","B"], + ["text"," "], + ["barline.keyword.operator","|"], + ["text"," "], + ["pitch.constant.numeric","c"], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","F"], + ["text"," "], + ["pitch.constant.numeric","G"], + ["duration.constant.numeric","2"], + ["text"," "], + ["barline.keyword.operator",":|"] +],[ + "start", + ["pitch.constant.numeric","B"], + ["text"," "], + ["barline.keyword.operator","|"], + ["text"," "], + ["pitch.constant.numeric","B"], + ["pitch.constant.numeric","c"], + ["pitch.constant.numeric","d"], + ["text"," "], + ["pitch.constant.numeric","e"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","c"], + ["text"," "], + ["barline.keyword.operator","|"], + ["text"," "], + ["pitch.constant.numeric","d"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","B"], + ["text"," "], + ["pitch.constant.numeric","c"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","A"], + ["text"," "], + ["barline.keyword.operator","|"], + ["text"," "], + ["pitch.constant.numeric","B"], + ["pitch.constant.numeric","c"], + ["pitch.constant.numeric","d"], + ["text"," "], + ["pitch.constant.numeric","e"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","c"], + ["text"," "], + ["barline.keyword.operator","|"], + ["text"," "], + ["information.keyword.embedded","[M:"], + ["information.argument.string.unquoted","9/8]"], + ["pitch.constant.numeric","d"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","B"], + ["text"," "], + ["pitch.constant.numeric","c"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","B"], + ["text"," "], + ["pitch.constant.numeric","A"], + ["duration.constant.numeric","3"], + ["text"," "], + ["barline.keyword.operator","|"] +],[ + "start", + ["information.keyword.embedded","[M:"], + ["information.argument.string.unquoted","6/8]"], + ["pitch.constant.numeric","D"], + ["pitch.constant.numeric","G"], + ["pitch.constant.numeric","F"], + ["text"," "], + ["pitch.constant.numeric","E"], + ["duration.constant.numeric","3"], + ["text"," "], + ["barline.keyword.operator","|"], + ["text"," "], + ["pitch.constant.numeric","c"], + ["pitch.constant.numeric","B"], + ["pitch.constant.numeric","A"], + ["text"," "], + ["pitch.constant.numeric","F"], + ["pitch.constant.numeric","E"], + ["pitch.constant.numeric","D"], + ["text"," "], + ["barline.keyword.operator","|"], + ["text"," "], + ["pitch.constant.numeric","D"], + ["pitch.constant.numeric","E"], + ["pitch.constant.numeric","F"], + ["text"," "], + ["pitch.constant.numeric","G"], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","B"], + ["text"," "], + ["barline.keyword.operator","|1"], + ["text"," "], + ["pitch.constant.numeric","c"], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","F"], + ["text"," "], + ["pitch.constant.numeric","G"], + ["duration.constant.numeric","2"], + ["text"," "], + ["barline.keyword.operator",":|2"], + ["text"," "], + ["pitch.constant.numeric","c"], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","F"], + ["text"," "], + ["pitch.constant.numeric","G"], + ["duration.constant.numeric","3"], + ["text"," "], + ["barline.keyword.operator","|]"] +],[ + "start" +],[ + "start", + ["information.keyword","X:"], + ["information.argument.string.unquoted","5"] +],[ + "start", + ["information.keyword","T:"], + ["information.argument.string.unquoted","Atholl Brose"] +],[ + "start", + ["comment.line.percentage","% in this example, which reproduces Highland Bagpipe gracing,"] +],[ + "start", + ["comment.line.percentage","% the large number of grace notes mean that it is more convenient to be specific about"] +],[ + "start", + ["comment.line.percentage","% score line-breaks (using the $ symbol), rather than using code line breaks to indicate them"] +],[ + "start", + ["information.keyword","I:"], + ["information.argument.string.unquoted","linebreak $"] +],[ + "start", + ["information.keyword","K:"], + ["information.argument.string.unquoted","D"] +],[ + "start", + ["text","{"], + ["pitch.constant.numeric","g"], + ["pitch.constant.numeric","c"], + ["pitch.constant.numeric","d"], + ["text","}"], + ["pitch.constant.numeric","c"], + ["duration.constant.numeric","<"], + ["text","{"], + ["pitch.constant.numeric","e"], + ["text","}"], + ["pitch.constant.numeric","A"], + ["text"," {"], + ["pitch.constant.numeric","g"], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","G"], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","G"], + ["text","}"], + ["pitch.constant.numeric","A"], + ["duration.constant.numeric","2"], + ["text"," {"], + ["pitch.constant.numeric","g"], + ["pitch.constant.numeric","e"], + ["pitch.constant.numeric","f"], + ["text","}"], + ["pitch.constant.numeric","e"], + ["duration.constant.numeric",">"], + ["pitch.constant.numeric","A"], + ["text"," {"], + ["pitch.constant.numeric","g"], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","G"], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","G"], + ["text","}"], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","d"], + ["barline.keyword.operator","|"] +],[ + "start", + ["text","{"], + ["pitch.constant.numeric","g"], + ["pitch.constant.numeric","c"], + ["pitch.constant.numeric","d"], + ["text","}"], + ["pitch.constant.numeric","c"], + ["duration.constant.numeric","<"], + ["text","{"], + ["pitch.constant.numeric","e"], + ["text","}"], + ["pitch.constant.numeric","A"], + ["text"," {"], + ["pitch.constant.numeric","g"], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","G"], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","G"], + ["text","}"], + ["pitch.constant.numeric","A"], + ["duration.constant.numeric",">"], + ["pitch.constant.numeric","e"], + ["text"," {"], + ["pitch.constant.numeric","a"], + ["pitch.constant.numeric","g"], + ["text","}"], + ["pitch.constant.numeric","a"], + ["duration.constant.numeric",">"], + ["pitch.constant.numeric","f"], + ["text"," {"], + ["pitch.constant.numeric","g"], + ["pitch.constant.numeric","e"], + ["pitch.constant.numeric","f"], + ["text","}"], + ["pitch.constant.numeric","e"], + ["duration.constant.numeric",">"], + ["pitch.constant.numeric","d"], + ["barline.keyword.operator","|"] +],[ + "start", + ["text","{"], + ["pitch.constant.numeric","g"], + ["pitch.constant.numeric","c"], + ["pitch.constant.numeric","d"], + ["text","}"], + ["pitch.constant.numeric","c"], + ["duration.constant.numeric","<"], + ["text","{"], + ["pitch.constant.numeric","e"], + ["text","}"], + ["pitch.constant.numeric","A"], + ["text"," {"], + ["pitch.constant.numeric","g"], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","G"], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","G"], + ["text","}"], + ["pitch.constant.numeric","A"], + ["duration.constant.numeric","2"], + ["text"," {"], + ["pitch.constant.numeric","g"], + ["pitch.constant.numeric","e"], + ["pitch.constant.numeric","f"], + ["text","}"], + ["pitch.constant.numeric","e"], + ["duration.constant.numeric",">"], + ["pitch.constant.numeric","A"], + ["text"," {"], + ["pitch.constant.numeric","g"], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","G"], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","G"], + ["text","}"], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","d"], + ["barline.keyword.operator","|"] +],[ + "start", + ["text","{"], + ["pitch.constant.numeric","g"], + ["text","}"], + ["pitch.constant.numeric","c"], + ["duration.constant.numeric","/"], + ["pitch.constant.numeric","d"], + ["duration.constant.numeric","/"], + ["pitch.constant.numeric","e"], + ["text"," {"], + ["pitch.constant.numeric","g"], + ["text","}"], + ["pitch.constant.numeric","G"], + ["duration.constant.numeric",">"], + ["text","{"], + ["pitch.constant.numeric","d"], + ["text","}"], + ["pitch.constant.numeric","B"], + ["text"," {"], + ["pitch.constant.numeric","g"], + ["pitch.constant.numeric","f"], + ["text","}"], + ["pitch.constant.numeric","g"], + ["pitch.constant.numeric","G"], + ["text"," {"], + ["pitch.constant.numeric","d"], + ["pitch.constant.numeric","c"], + ["text","}"], + ["pitch.constant.numeric","d"], + ["duration.constant.numeric",">"], + ["pitch.constant.numeric","B"], + ["barline.keyword.operator",":|"], + ["text","$"] +],[ + "start", + ["text","{"], + ["pitch.constant.numeric","g"], + ["text","}"], + ["pitch.constant.numeric","c"], + ["duration.constant.numeric","<"], + ["pitch.constant.numeric","e"], + ["text"," {"], + ["pitch.constant.numeric","g"], + ["pitch.constant.numeric","f"], + ["text","}"], + ["pitch.constant.numeric","g"], + ["duration.constant.numeric",">"], + ["pitch.constant.numeric","e"], + ["text"," {"], + ["pitch.constant.numeric","a"], + ["pitch.constant.numeric","g"], + ["text","}"], + ["pitch.constant.numeric","a"], + ["duration.constant.numeric",">"], + ["pitch.constant.numeric","e"], + ["text"," {"], + ["pitch.constant.numeric","g"], + ["pitch.constant.numeric","f"], + ["text","}"], + ["pitch.constant.numeric","g"], + ["duration.constant.numeric",">"], + ["pitch.constant.numeric","e"], + ["barline.keyword.operator","|"] +],[ + "start", + ["text","{"], + ["pitch.constant.numeric","g"], + ["text","}"], + ["pitch.constant.numeric","c"], + ["duration.constant.numeric","<"], + ["pitch.constant.numeric","e"], + ["text"," {"], + ["pitch.constant.numeric","g"], + ["pitch.constant.numeric","f"], + ["text","}"], + ["pitch.constant.numeric","g"], + ["duration.constant.numeric",">"], + ["pitch.constant.numeric","e"], + ["text"," {"], + ["pitch.constant.numeric","a"], + ["pitch.constant.numeric","g"], + ["text","}"], + ["pitch.constant.numeric","a"], + ["duration.constant.numeric","2"], + ["text"," {"], + ["pitch.constant.numeric","G"], + ["pitch.constant.numeric","d"], + ["pitch.constant.numeric","G"], + ["text","}"], + ["pitch.constant.numeric","a"], + ["duration.constant.numeric",">"], + ["pitch.constant.numeric","d"], + ["barline.keyword.operator","|"] +],[ + "start", + ["text","{"], + ["pitch.constant.numeric","g"], + ["text","}"], + ["pitch.constant.numeric","c"], + ["duration.constant.numeric","<"], + ["pitch.constant.numeric","e"], + ["text"," {"], + ["pitch.constant.numeric","g"], + ["pitch.constant.numeric","f"], + ["text","}"], + ["pitch.constant.numeric","g"], + ["duration.constant.numeric",">"], + ["pitch.constant.numeric","e"], + ["text"," {"], + ["pitch.constant.numeric","a"], + ["pitch.constant.numeric","g"], + ["text","}"], + ["pitch.constant.numeric","a"], + ["duration.constant.numeric",">"], + ["pitch.constant.numeric","e"], + ["text"," {"], + ["pitch.constant.numeric","g"], + ["pitch.constant.numeric","f"], + ["text","}"], + ["pitch.constant.numeric","g"], + ["duration.constant.numeric",">"], + ["pitch.constant.numeric","f"], + ["barline.keyword.operator","|"] +],[ + "start", + ["text","{"], + ["pitch.constant.numeric","g"], + ["pitch.constant.numeric","e"], + ["pitch.constant.numeric","f"], + ["text","}"], + ["pitch.constant.numeric","e"], + ["duration.constant.numeric",">"], + ["pitch.constant.numeric","d"], + ["text"," {"], + ["pitch.constant.numeric","g"], + ["pitch.constant.numeric","f"], + ["text","}"], + ["pitch.constant.numeric","g"], + ["duration.constant.numeric",">"], + ["pitch.constant.numeric","d"], + ["text"," {"], + ["pitch.constant.numeric","g"], + ["pitch.constant.numeric","B"], + ["pitch.constant.numeric","d"], + ["text","}"], + ["pitch.constant.numeric","B"], + ["duration.constant.numeric","<"], + ["text","{"], + ["pitch.constant.numeric","e"], + ["text","}"], + ["pitch.constant.numeric","G"], + ["text"," {"], + ["pitch.constant.numeric","d"], + ["pitch.constant.numeric","c"], + ["text","}"], + ["pitch.constant.numeric","d"], + ["duration.constant.numeric",">"], + ["pitch.constant.numeric","B"], + ["barline.keyword.operator","|"] +],[ + "start", + ["text","{"], + ["pitch.constant.numeric","g"], + ["text","}"], + ["pitch.constant.numeric","c"], + ["duration.constant.numeric","<"], + ["pitch.constant.numeric","e"], + ["text"," {"], + ["pitch.constant.numeric","g"], + ["pitch.constant.numeric","f"], + ["text","}"], + ["pitch.constant.numeric","g"], + ["duration.constant.numeric",">"], + ["pitch.constant.numeric","e"], + ["text"," {"], + ["pitch.constant.numeric","a"], + ["pitch.constant.numeric","g"], + ["text","}"], + ["pitch.constant.numeric","a"], + ["duration.constant.numeric",">"], + ["pitch.constant.numeric","e"], + ["text"," {"], + ["pitch.constant.numeric","g"], + ["pitch.constant.numeric","f"], + ["text","}"], + ["pitch.constant.numeric","g"], + ["duration.constant.numeric",">"], + ["pitch.constant.numeric","e"], + ["barline.keyword.operator","|"] +],[ + "start", + ["text","{"], + ["pitch.constant.numeric","g"], + ["text","}"], + ["pitch.constant.numeric","c"], + ["duration.constant.numeric","<"], + ["pitch.constant.numeric","e"], + ["text"," {"], + ["pitch.constant.numeric","g"], + ["pitch.constant.numeric","f"], + ["text","}"], + ["pitch.constant.numeric","g"], + ["duration.constant.numeric",">"], + ["pitch.constant.numeric","e"], + ["text"," {"], + ["pitch.constant.numeric","a"], + ["pitch.constant.numeric","g"], + ["text","}"], + ["pitch.constant.numeric","a"], + ["duration.constant.numeric","2"], + ["text"," {"], + ["pitch.constant.numeric","G"], + ["pitch.constant.numeric","d"], + ["pitch.constant.numeric","G"], + ["text","}"], + ["pitch.constant.numeric","a"], + ["pitch.constant.numeric","d"], + ["barline.keyword.operator","|"] +],[ + "start", + ["text","{"], + ["pitch.constant.numeric","g"], + ["text","}"], + ["pitch.constant.numeric","c"], + ["duration.constant.numeric","<"], + ["text","{"], + ["pitch.constant.numeric","G"], + ["pitch.constant.numeric","d"], + ["pitch.constant.numeric","G"], + ["text","}"], + ["pitch.constant.numeric","e"], + ["text"," {"], + ["pitch.constant.numeric","g"], + ["pitch.constant.numeric","f"], + ["text","}"], + ["pitch.constant.numeric","g"], + ["pitch.constant.numeric","a"], + ["text"," {"], + ["pitch.constant.numeric","f"], + ["text","}"], + ["pitch.constant.numeric","g"], + ["duration.constant.numeric",">"], + ["pitch.constant.numeric","e"], + ["text"," {"], + ["pitch.constant.numeric","g"], + ["text","}"], + ["pitch.constant.numeric","f"], + ["duration.constant.numeric",">"], + ["pitch.constant.numeric","d"], + ["barline.keyword.operator","|"] +],[ + "start", + ["text","{"], + ["pitch.constant.numeric","g"], + ["text","}"], + ["pitch.constant.numeric","e"], + ["duration.constant.numeric","/"], + ["pitch.constant.numeric","f"], + ["duration.constant.numeric","/"], + ["pitch.constant.numeric","g"], + ["text"," {"], + ["pitch.constant.numeric","G"], + ["pitch.constant.numeric","d"], + ["pitch.constant.numeric","c"], + ["text","}"], + ["pitch.constant.numeric","d"], + ["duration.constant.numeric",">"], + ["pitch.constant.numeric","c"], + ["text"," {"], + ["pitch.constant.numeric","g"], + ["pitch.constant.numeric","B"], + ["pitch.constant.numeric","d"], + ["text","}"], + ["pitch.constant.numeric","B"], + ["duration.constant.numeric","<"], + ["text","{"], + ["pitch.constant.numeric","e"], + ["text","}"], + ["pitch.constant.numeric","G"], + ["text"," {"], + ["pitch.constant.numeric","d"], + ["pitch.constant.numeric","c"], + ["text","}"], + ["pitch.constant.numeric","d"], + ["duration.constant.numeric","2"], + ["barline.keyword.operator","|]"] +],[ + "start" +],[ + "start", + ["information.keyword","X:"], + ["information.argument.string.unquoted","6"] +],[ + "start", + ["information.keyword","T:"], + ["information.argument.string.unquoted","Untitled Reel"] +],[ + "start", + ["information.keyword","C:"], + ["information.argument.string.unquoted","Trad."] +],[ + "start", + ["information.keyword","K:"], + ["information.argument.string.unquoted","D"] +],[ + "start", + ["pitch.constant.numeric","e"], + ["pitch.constant.numeric","g"], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","a"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","a"], + ["pitch.constant.numeric","b"], + ["text"," "], + ["pitch.constant.numeric","a"], + ["pitch.constant.numeric","g"], + ["pitch.constant.numeric","e"], + ["pitch.constant.numeric","g"], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","a"], + ["pitch.constant.numeric","g"], + ["pitch.constant.numeric","b"], + ["pitch.constant.numeric","g"], + ["text"," "], + ["pitch.constant.numeric","a"], + ["pitch.constant.numeric","g"], + ["pitch.constant.numeric","e"], + ["pitch.constant.numeric","f"], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","g"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","g"], + ["duration.constant.numeric","2"], + ["text"," "], + ["pitch.constant.numeric","f"], + ["pitch.constant.numeric","g"], + ["pitch.constant.numeric","a"], + ["pitch.constant.numeric","g"], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","f"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","d"], + ["duration.constant.numeric","2"], + ["text"," "], + ["pitch.constant.numeric","d"], + ["duration.constant.numeric","2"], + ["barline.keyword.operator",":|"], + ["text","\\"] +],[ + "start", + ["pitch.constant.numeric","e"], + ["pitch.constant.numeric","d"], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","c"], + ["pitch.constant.numeric","e"], + ["pitch.constant.numeric","c"], + ["pitch.constant.numeric","A"], + ["text"," "], + ["pitch.constant.numeric","B"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","e"], + ["pitch.constant.numeric","d"], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","c"], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","c"], + ["pitch.constant.numeric","A"], + ["text"," "], + ["pitch.constant.numeric","E"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","e"], + ["pitch.constant.numeric","d"], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","c"], + ["pitch.constant.numeric","e"], + ["pitch.constant.numeric","c"], + ["pitch.constant.numeric","A"], + ["text"," "], + ["pitch.constant.numeric","B"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","e"], + ["pitch.constant.numeric","d"], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","c"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","A"], + ["duration.constant.numeric","2"], + ["text"," "], + ["pitch.constant.numeric","A"], + ["duration.constant.numeric","2"], + ["barline.keyword.operator",":|"] +],[ + "start", + ["information.keyword","K:"], + ["information.argument.string.unquoted","G"] +],[ + "start", + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","B"], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","c"], + ["pitch.constant.numeric","d"], + ["pitch.constant.numeric","e"], + ["pitch.constant.numeric","c"], + ["text"," "], + ["pitch.constant.numeric","B"], + ["pitch.constant.numeric","c"], + ["pitch.constant.numeric","d"], + ["pitch.constant.numeric","B"], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","B"], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","F"], + ["text"," "], + ["pitch.constant.numeric","G"], + ["pitch.constant.numeric","F"], + ["pitch.constant.numeric","E"], + ["duration.constant.numeric","2"], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","c"], + ["pitch.constant.numeric","d"], + ["pitch.constant.numeric","e"], + ["pitch.constant.numeric","c"], + ["text"," "], + ["pitch.constant.numeric","B"], + ["pitch.constant.numeric","c"], + ["pitch.constant.numeric","d"], + ["pitch.constant.numeric","B"], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","c"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","A"], + ["duration.constant.numeric","2"], + ["text"," "], + ["pitch.constant.numeric","A"], + ["duration.constant.numeric","2"], + ["barline.keyword.operator",":|"] +],[ + "start" +],[ + "start", + ["information.keyword","X:"], + ["information.argument.string.unquoted","7"] +],[ + "start", + ["information.keyword","T:"], + ["information.argument.string.unquoted","Kitchen Girl"] +],[ + "start", + ["information.keyword","C:"], + ["information.argument.string.unquoted","Trad."] +],[ + "start", + ["information.keyword","K:"], + ["information.argument.string.unquoted","D"] +],[ + "start", + ["text","["], + ["pitch.constant.numeric","c"], + ["duration.constant.numeric","4"], + ["pitch.constant.numeric","a"], + ["duration.constant.numeric","4"], + ["text","] ["], + ["pitch.constant.numeric","B"], + ["duration.constant.numeric","4"], + ["pitch.constant.numeric","g"], + ["duration.constant.numeric","4"], + ["text","]"], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","e"], + ["pitch.constant.numeric","f"], + ["pitch.constant.numeric","e"], + ["pitch.constant.numeric","d"], + ["text"," "], + ["pitch.constant.numeric","c"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","c"], + ["pitch.constant.numeric","d"], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","e"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","f"], + ["duration.constant.numeric","2"], + ["text"," "], + ["pitch.constant.numeric","g"], + ["pitch.constant.numeric","a"], + ["pitch.constant.numeric","b"], + ["pitch.constant.numeric","a"], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","g"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","e"], + ["duration.constant.numeric","2"], + ["text"," "], + ["pitch.constant.numeric","e"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","f"], + ["pitch.constant.numeric","g"], + ["barline.keyword.operator","|"] +],[ + "start", + ["pitch.constant.numeric","a"], + ["duration.constant.numeric","4"], + ["text"," "], + ["pitch.constant.numeric","g"], + ["duration.constant.numeric","4"], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","e"], + ["pitch.constant.numeric","f"], + ["pitch.constant.numeric","e"], + ["pitch.constant.numeric","d"], + ["text"," "], + ["pitch.constant.numeric","c"], + ["pitch.constant.numeric","d"], + ["pitch.constant.numeric","e"], + ["pitch.constant.numeric","f"], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","g"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","d"], + ["duration.constant.numeric","2"], + ["text"," "], + ["pitch.constant.numeric","e"], + ["pitch.constant.numeric","f"], + ["pitch.constant.numeric","e"], + ["pitch.constant.numeric","d"], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","c"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","A"], + ["duration.constant.numeric","2"], + ["text"," "], + ["pitch.constant.numeric","A"], + ["duration.constant.numeric","4"], + ["barline.keyword.operator",":|"] +],[ + "start", + ["information.keyword","K:"], + ["information.argument.string.unquoted","G"] +],[ + "start", + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","B"], + ["pitch.constant.numeric","c"], + ["pitch.constant.numeric","A"], + ["text"," "], + ["pitch.constant.numeric","B"], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","G"], + ["pitch.constant.numeric","B"], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","B"], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","G"], + ["text"," "], + ["pitch.constant.numeric","E"], + ["pitch.constant.numeric","D"], + ["pitch.constant.numeric","E"], + ["pitch.constant.numeric","G"], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","A"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","B"], + ["text"," "], + ["pitch.constant.numeric","c"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","d"], + ["duration.constant.numeric","2"], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","e"], + ["duration.constant.numeric","3"], + ["pitch.constant.numeric","f"], + ["text"," "], + ["pitch.constant.numeric","e"], + ["pitch.constant.numeric","d"], + ["pitch.constant.numeric","c"], + ["pitch.constant.numeric","B"], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","B"], + ["pitch.constant.numeric","c"], + ["pitch.constant.numeric","A"], + ["text"," "], + ["pitch.constant.numeric","B"], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","G"], + ["pitch.constant.numeric","B"], + ["barline.keyword.operator","|"] +],[ + "start", + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","B"], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","G"], + ["text"," "], + ["pitch.constant.numeric","E"], + ["pitch.constant.numeric","G"], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","B"], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","c"], + ["pitch.constant.numeric","B"], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","c"], + ["text"," "], + ["pitch.constant.numeric","B"], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","G"], + ["duration.constant.numeric","2"], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","A"], + ["duration.constant.numeric","4"], + ["text"," "], + ["pitch.constant.numeric","A"], + ["duration.constant.numeric","4"], + ["barline.keyword.operator",":|"] +],[ + "start" +],[ + "start", + ["comment.line.percentage","%abc-2.1"] +],[ + "start", + ["information.comment.line.percentage","%%"], + ["information.keyword.embedded","pagewidth 21cm"] +],[ + "start", + ["information.comment.line.percentage","%%"], + ["information.keyword.embedded","pageheight 29.7cm"] +],[ + "start", + ["information.comment.line.percentage","%%"], + ["information.keyword.embedded","topspace 0.5cm"] +],[ + "start", + ["information.comment.line.percentage","%%"], + ["information.keyword.embedded","topmargin 1cm"] +],[ + "start", + ["information.comment.line.percentage","%%"], + ["information.keyword.embedded","botmargin 0cm"] +],[ + "start", + ["information.comment.line.percentage","%%"], + ["information.keyword.embedded","leftmargin 1cm"] +],[ + "start", + ["information.comment.line.percentage","%%"], + ["information.keyword.embedded","rightmargin 1cm"] +],[ + "start", + ["information.comment.line.percentage","%%"], + ["information.keyword.embedded","titlespace 0cm"] +],[ + "start", + ["information.comment.line.percentage","%%"], + ["information.keyword.embedded","titlefont Times-Bold 32"] +],[ + "start", + ["information.comment.line.percentage","%%"], + ["information.keyword.embedded","subtitlefont Times-Bold 24"] +],[ + "start", + ["information.comment.line.percentage","%%"], + ["information.keyword.embedded","composerfont Times 16"] +],[ + "start", + ["information.comment.line.percentage","%%"], + ["information.keyword.embedded","vocalfont Times-Roman 14"] +],[ + "start", + ["information.comment.line.percentage","%%"], + ["information.keyword.embedded","staffsep 60pt"] +],[ + "start", + ["information.comment.line.percentage","%%"], + ["information.keyword.embedded","sysstaffsep 20pt"] +],[ + "start", + ["information.comment.line.percentage","%%"], + ["information.keyword.embedded","musicspace 1cm"] +],[ + "start", + ["information.comment.line.percentage","%%"], + ["information.keyword.embedded","vocalspace 5pt"] +],[ + "start", + ["information.comment.line.percentage","%%"], + ["information.keyword.embedded","measurenb 0"] +],[ + "start", + ["information.comment.line.percentage","%%"], + ["information.keyword.embedded","barsperstaff 5"] +],[ + "start", + ["information.comment.line.percentage","%%"], + ["information.keyword.embedded","scale 0.7"] +],[ + "start", + ["information.keyword","X:"], + ["information.argument.string.unquoted"," 1"] +],[ + "start", + ["information.keyword","T:"], + ["information.argument.string.unquoted"," Canzonetta a tre voci"] +],[ + "start", + ["information.keyword","C:"], + ["information.argument.string.unquoted"," Claudio Monteverdi (1567-1643)"] +],[ + "start", + ["information.keyword","M:"], + ["information.argument.string.unquoted"," C"] +],[ + "start", + ["information.keyword","L:"], + ["information.argument.string.unquoted"," 1/4"] +],[ + "start", + ["information.keyword","Q:"], + ["information.argument.string.unquoted"," \"Andante mosso\" 1/4 = 110"] +],[ + "start", + ["information.comment.line.percentage","%%"], + ["information.keyword.embedded","score [1 2 3]"] +],[ + "start", + ["information.keyword","V:"], + ["information.argument.string.unquoted"," 1 clef=treble name=\"Soprano\"sname=\"A\""] +],[ + "start", + ["information.keyword","V:"], + ["information.argument.string.unquoted"," 2 clef=treble name=\"Alto\" sname=\"T\""] +],[ + "start", + ["information.keyword","V:"], + ["information.argument.string.unquoted"," 3 clef=bass middle=d name=\"Tenor\" sname=\"B\""] +],[ + "start", + ["information.comment.line.percentage","%%"], + ["information.keyword.embedded","MIDI program 1 75 % recorder"] +],[ + "start", + ["information.comment.line.percentage","%%"], + ["information.keyword.embedded","MIDI program 2 75"] +],[ + "start", + ["information.comment.line.percentage","%%"], + ["information.keyword.embedded","MIDI program 3 75"] +],[ + "start", + ["information.keyword","K:"], + ["information.argument.string.unquoted"," Eb"] +],[ + "start", + ["comment.line.percentage","% 1 - 4"] +],[ + "start", + ["information.keyword.embedded","[V:"], + ["information.argument.string.unquoted"," 1]"], + ["text"," "], + ["barline.keyword.operator","|:"], + ["pitch.constant.numeric","z"], + ["duration.constant.numeric","4"], + ["text"," "], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","z"], + ["duration.constant.numeric","4"], + ["text"," "], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","f"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","e"], + ["pitch.constant.numeric","c"], + ["text"," "], + ["barline.keyword.operator","|"], + ["accent.constant.language","_"], + ["pitch.constant.numeric","d"], + ["pitch.constant.numeric","d"], + ["pitch.constant.numeric","c"], + ["pitch.constant.numeric","c"], + ["text"," "], + ["barline.keyword.operator","|"] +],[ + "start", + ["information.keyword","w:"], + ["information.argument.string.unquoted"," Son que-sti~i cre-spi cri-ni~e"] +],[ + "start", + ["information.keyword","w:"], + ["information.argument.string.unquoted"," Que-sti son gli~oc-chi che mi-"] +],[ + "start", + ["information.keyword.embedded","[V:"], + ["information.argument.string.unquoted"," 2]"], + ["text"," "], + ["barline.keyword.operator","|:"], + ["pitch.constant.numeric","c"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","B"], + ["pitch.constant.numeric","G"], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","G"], + ["pitch.constant.numeric","c"], + ["barline.keyword.operator","|"], + ["text","("], + ["pitch.constant.numeric","F"], + ["duration.constant.numeric","/"], + ["pitch.constant.numeric","G"], + ["duration.constant.numeric","/"], + ["pitch.constant.numeric","A"], + ["duration.constant.numeric","/"], + ["pitch.constant.numeric","B"], + ["duration.constant.numeric","/"], + ["text",")"], + ["pitch.constant.numeric","c"], + ["accent.constant.language","="], + ["pitch.constant.numeric","A"], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","B"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","A"], + ["text"," "], + ["barline.keyword.operator","|"] +],[ + "start", + ["information.keyword","w:"], + ["information.argument.string.unquoted"," Son que-sti~i cre-spi cri-ni~e que - - - - sto~il vi-so e"] +],[ + "start", + ["information.keyword","w:"], + ["information.argument.string.unquoted"," Que-sti son~gli oc-chi che mi-ran - - - - do fi-so mi-"] +],[ + "start", + ["information.keyword.embedded","[V:"], + ["information.argument.string.unquoted"," 3]"], + ["text"," "], + ["barline.keyword.operator","|:"], + ["pitch.constant.numeric","z"], + ["duration.constant.numeric","4"], + ["text"," "], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","f"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","e"], + ["pitch.constant.numeric","c"], + ["barline.keyword.operator","|"], + ["accent.constant.language","_"], + ["pitch.constant.numeric","d"], + ["pitch.constant.numeric","d"], + ["pitch.constant.numeric","c"], + ["pitch.constant.numeric","f"], + ["text"," "], + ["barline.keyword.operator","|"], + ["text","("], + ["pitch.constant.numeric","B"], + ["duration.constant.numeric","/"], + ["pitch.constant.numeric","c"], + ["duration.constant.numeric","/"], + ["accent.constant.language","_"], + ["pitch.constant.numeric","d"], + ["duration.constant.numeric","/"], + ["pitch.constant.numeric","e"], + ["duration.constant.numeric","/"], + ["text",")"], + ["pitch.constant.numeric","f"], + ["pitch.constant.numeric","f"], + ["barline.keyword.operator","|"] +],[ + "start", + ["information.keyword","w:"], + ["information.argument.string.unquoted"," Son que-sti~i cre-spi cri-ni~e que - - - - sto~il"] +],[ + "start", + ["information.keyword","w:"], + ["information.argument.string.unquoted"," Que-sti son~gli oc-chi che mi-ran - - - - do"] +],[ + "start", + ["comment.line.percentage","% 5 - 9"] +],[ + "start", + ["information.keyword.embedded","[V:"], + ["information.argument.string.unquoted"," 1]"], + ["text"," "], + ["pitch.constant.numeric","c"], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","B"], + ["duration.constant.numeric","2"], + ["text"," "], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","c"], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","A"], + ["text"," "], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","c"], + ["duration.constant.numeric","3"], + ["pitch.constant.numeric","B"], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","G"], + ["duration.constant.numeric","2"], + ["string.quoted","!fermata!"], + ["pitch.constant.numeric","G"], + ["pitch.constant.numeric","z"], + ["text"," "], + ["barline.keyword.operator","::"], + ["pitch.constant.numeric","e"], + ["duration.constant.numeric","4"], + ["barline.keyword.operator","|"] +],[ + "start", + ["information.keyword","w:"], + ["information.argument.string.unquoted"," que-sto~il vi-so ond' io ri-man-go~uc-ci-so. Deh,"] +],[ + "start", + ["information.keyword","w:"], + ["information.argument.string.unquoted"," ran-do fi-so, tut-to re-stai con-qui-so."] +],[ + "start", + ["information.keyword.embedded","[V:"], + ["information.argument.string.unquoted"," 2]"], + ["text"," "], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","G"], + ["duration.constant.numeric","2"], + ["text"," "], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","F"], + ["pitch.constant.numeric","F"], + ["pitch.constant.numeric","F"], + ["text"," "], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","A"], + ["duration.constant.numeric","3"], + ["pitch.constant.numeric","F"], + ["barline.keyword.operator","|"], + ["accent.constant.language","="], + ["pitch.constant.numeric","E"], + ["duration.constant.numeric","2"], + ["string.quoted","!fermata!"], + ["pitch.constant.numeric","E"], + ["pitch.constant.numeric","z"], + ["barline.keyword.operator","::"], + ["pitch.constant.numeric","c"], + ["duration.constant.numeric","4"], + ["barline.keyword.operator","|"] +],[ + "start", + ["information.keyword","w:"], + ["information.argument.string.unquoted"," que-sto~il vi-so ond' io ri-man-go~uc-ci-so. Deh,"] +],[ + "start", + ["information.keyword","w:"], + ["information.argument.string.unquoted"," ran-do fi-so tut-to re-stai con-qui-so."] +],[ + "start", + ["information.keyword.embedded","[V:"], + ["information.argument.string.unquoted"," 3]"], + ["text"," ("], + ["pitch.constant.numeric","a"], + ["pitch.constant.numeric","g"], + ["duration.constant.numeric","/"], + ["pitch.constant.numeric","f"], + ["duration.constant.numeric","/"], + ["pitch.constant.numeric","e"], + ["duration.constant.numeric","2"], + ["text",")"], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","A"], + ["accent.constant.language","_"], + ["pitch.constant.numeric","d"], + ["pitch.constant.numeric","d"], + ["pitch.constant.numeric","d"], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","A"], + ["duration.constant.numeric","3"], + ["pitch.constant.numeric","B"], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","c"], + ["duration.constant.numeric","2"], + ["string.quoted","!fermata!"], + ["pitch.constant.numeric","c"], + ["pitch.constant.numeric","z"], + ["text"," "], + ["barline.keyword.operator","::"], + ["pitch.constant.numeric","A"], + ["duration.constant.numeric","4"], + ["barline.keyword.operator","|"] +],[ + "start", + ["information.keyword","w:"], + ["information.argument.string.unquoted"," vi - - - so ond' io ti-man-go~uc-ci-so. Deh,"] +],[ + "start", + ["information.keyword","w:"], + ["information.argument.string.unquoted"," fi - - - so tut-to re-stai con-qui-so."] +],[ + "start", + ["comment.line.percentage","% 10 - 15"] +],[ + "start", + ["information.keyword.embedded","[V:"], + ["information.argument.string.unquoted"," 1]"], + ["text"," "], + ["pitch.constant.numeric","f"], + ["accent.constant.language","_"], + ["pitch.constant.numeric","d"], + ["pitch.constant.numeric","e"], + ["pitch.constant.numeric","c"], + ["text"," "], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","B"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","c"], + ["duration.constant.numeric","2"], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","z"], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","G"], + ["pitch.constant.numeric","F"], + ["text"," "], + ["barline.keyword.operator","|"], + ["text","\\"] +],[ + "start", + ["information.keyword","w:"], + ["information.argument.string.unquoted"," dim-me-lo ben mi-o, che que-sto"], + ["text","\\"] +],[ + "start", + ["accent.constant.language","="], + ["pitch.constant.numeric","E"], + ["pitch.constant.numeric","F"], + ["pitch.constant.numeric","G"], + ["duration.constant.numeric","2"], + ["text"," "], + ["barline.keyword.operator","|1"], + ["pitch.constant.numeric","F"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","z"], + ["duration.constant.numeric","2"], + ["barline.keyword.operator",":|2"], + ["pitch.constant.numeric","F"], + ["duration.constant.numeric","8"], + ["barline.keyword.operator","|]"], + ["text"," "], + ["comment.line.percentage","% more notes"] +],[ + "start", + ["information.keyword","w:"], + ["information.argument.string.unquoted"," sol de-si-o_. "], + ["comment.line.percentage","% more lyrics"] +],[ + "start", + ["information.keyword.embedded","[V:"], + ["information.argument.string.unquoted"," 2]"], + ["text"," "], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","B"], + ["pitch.constant.numeric","G"], + ["pitch.constant.numeric","A"], + ["text"," "], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","G"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","A"], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","G"], + ["pitch.constant.numeric","F"], + ["accent.constant.language","="], + ["pitch.constant.numeric","E"], + ["pitch.constant.numeric","F"], + ["text"," "], + ["barline.keyword.operator","|"], + ["text","("], + ["pitch.constant.numeric","G"], + ["pitch.constant.numeric","F"], + ["duration.constant.numeric","3/2"], + ["accent.constant.language","="], + ["pitch.constant.numeric","E"], + ["duration.constant.numeric","//"], + ["pitch.constant.numeric","D"], + ["duration.constant.numeric","//"], + ["pitch.constant.numeric","E"], + ["text",")"], + ["barline.keyword.operator","|1"], + ["pitch.constant.numeric","F"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","z"], + ["duration.constant.numeric","2"], + ["barline.keyword.operator",":|2"], + ["pitch.constant.numeric","F"], + ["duration.constant.numeric","8"], + ["barline.keyword.operator","|]"] +],[ + "start", + ["information.keyword","w:"], + ["information.argument.string.unquoted"," dim-me-lo ben mi-o, che que-sto sol de-si - - - - o_."] +],[ + "start", + ["information.keyword.embedded","[V:"], + ["information.argument.string.unquoted"," 3]"], + ["text"," "], + ["accent.constant.language","_"], + ["pitch.constant.numeric","d"], + ["pitch.constant.numeric","B"], + ["pitch.constant.numeric","c"], + ["duration.constant.numeric",">"], + ["pitch.constant.numeric","d"], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","e"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","A"], + ["pitch.constant.numeric","F"], + ["barline.keyword.operator","|"], + ["accent.constant.language","="], + ["pitch.constant.numeric","E"], + ["pitch.constant.numeric","F"], + ["pitch.constant.numeric","c"], + ["accent.constant.language","_"], + ["pitch.constant.numeric","d"], + ["barline.keyword.operator","|"], + ["pitch.constant.numeric","c"], + ["duration.constant.numeric","4"], + ["text"," "], + ["barline.keyword.operator","|1"], + ["pitch.constant.numeric","F"], + ["duration.constant.numeric","2"], + ["pitch.constant.numeric","z"], + ["duration.constant.numeric","2"], + ["barline.keyword.operator",":|2"], + ["pitch.constant.numeric","F"], + ["duration.constant.numeric","8"], + ["barline.keyword.operator","|]"] +],[ + "start", + ["information.keyword","w:"], + ["information.argument.string.unquoted"," dim-me-lo ben mi-o, che que-sto sol de-si-o_."] +]] \ No newline at end of file diff --git a/lib/ace/mode/_test/tokens_ada.json b/lib/ace/mode/_test/tokens_ada.json new file mode 100644 index 00000000..bdef7256 --- /dev/null +++ b/lib/ace/mode/_test/tokens_ada.json @@ -0,0 +1,39 @@ +[[ + "start", + ["keyword","with"], + ["text"," "], + ["identifier","Ada"], + ["text","."], + ["identifier","Text_IO"], + ["text","; "], + ["keyword","use"], + ["text"," "], + ["identifier","Ada"], + ["text","."], + ["identifier","Text_IO"], + ["text",";"] +],[ + "start", + ["keyword","procedure"], + ["text"," "], + ["identifier","Hello"], + ["text"," "], + ["keyword","is"] +],[ + "start", + ["keyword","begin"] +],[ + "start", + ["text"," "], + ["identifier","Put_Line"], + ["paren.lparen","("], + ["string","\"Hello, world!\""], + ["paren.rparen",")"], + ["text",";"] +],[ + "start", + ["keyword","end"], + ["text"," "], + ["identifier","Hello"], + ["text",";"] +]] \ No newline at end of file diff --git a/lib/ace/mode/_test/tokens_assembly_x86.json b/lib/ace/mode/_test/tokens_assembly_x86.json new file mode 100644 index 00000000..5da0470e --- /dev/null +++ b/lib/ace/mode/_test/tokens_assembly_x86.json @@ -0,0 +1,114 @@ +[[ + "start", + ["support.function.directive.assembly","section"], + ["text","\t.text"] +],[ + "start", + ["text"," "], + ["support.function.directive.assembly","global"], + ["text"," "], + ["entity.name.function.assembly","main"], + ["text"," "], + ["comment.assembly",";must be declared for using gcc"] +],[ + "start" +],[ + "start", + ["entity.name.function.assembly","main:"], + ["text","\t "], + ["comment.assembly",";tell linker entry point"] +],[ + "start" +],[ + "start", + ["text","\t"], + ["keyword.control.assembly","mov"], + ["text","\t"], + ["variable.parameter.register.assembly","edx"], + ["text",", len\t "], + ["comment.assembly",";message length"] +],[ + "start", + ["text","\t"], + ["keyword.control.assembly","mov"], + ["text","\t"], + ["variable.parameter.register.assembly","ecx"], + ["text",", msg\t "], + ["comment.assembly",";message to write"] +],[ + "start", + ["text","\t"], + ["keyword.control.assembly","mov"], + ["text","\t"], + ["variable.parameter.register.assembly","ebx"], + ["text",", "], + ["constant.character.decimal.assembly","1"], + ["text","\t "], + ["comment.assembly",";file descriptor (stdout)"] +],[ + "start", + ["text","\t"], + ["keyword.control.assembly","mov"], + ["text","\t"], + ["variable.parameter.register.assembly","eax"], + ["text",", "], + ["constant.character.decimal.assembly","4"], + ["text","\t "], + ["comment.assembly",";system call number (sys_write)"] +],[ + "start", + ["text","\t"], + ["keyword.control.assembly","int"], + ["text","\t"], + ["constant.character.hexadecimal.assembly","0x80"], + ["text","\t "], + ["comment.assembly",";call kernel"] +],[ + "start" +],[ + "start", + ["text","\t"], + ["keyword.control.assembly","mov"], + ["text","\t"], + ["variable.parameter.register.assembly","eax"], + ["text",", "], + ["constant.character.decimal.assembly","1"], + ["text","\t "], + ["comment.assembly",";system call number (sys_exit)"] +],[ + "start", + ["text","\t"], + ["keyword.control.assembly","int"], + ["text","\t"], + ["constant.character.hexadecimal.assembly","0x80"], + ["text","\t "], + ["comment.assembly",";call kernel"] +],[ + "start" +],[ + "start", + ["support.function.directive.assembly","section"], + ["text","\t.data"] +],[ + "start" +],[ + "start", + ["entity.name.function.assembly","msg"], + ["text","\t"], + ["support.function.directive.assembly","db"], + ["text","\t"], + ["string.assembly","'Hello, world!'"], + ["text",","], + ["constant.character.hexadecimal.assembly","0xa"], + ["text","\t"], + ["comment.assembly",";our dear string"] +],[ + "start", + ["entity.name.function.assembly","len"], + ["text","\t"], + ["support.function.directive.assembly","equ"], + ["text","\t$ - msg\t\t\t"], + ["comment.assembly",";length of our dear string"] +],[ + "start" +]] \ No newline at end of file diff --git a/lib/ace/mode/_test/tokens_batchfile.json b/lib/ace/mode/_test/tokens_batchfile.json new file mode 100644 index 00000000..0f1f138c --- /dev/null +++ b/lib/ace/mode/_test/tokens_batchfile.json @@ -0,0 +1,70 @@ +[[ + "start", + ["comment.line.colons.dosbatch",":: batch file highlighting in Ace!"] +],[ + "start", + ["text","@"], + ["keyword.command.dosbatch","echo"], + ["text"," off"] +],[ + "start" +],[ + "start", + ["keyword.control.statement.dosbatch","CALL"], + ["text"," "], + ["keyword.command.dosbatch","set"], + ["text"," var1="], + ["constant.numeric","%cd%"] +],[ + "start", + ["keyword.command.dosbatch","echo"], + ["text"," unhide everything in "], + ["constant.numeric","%var1%"], + ["text","!"] +],[ + "start" +],[ + "start", + ["comment.line.colons.dosbatch",":: FOR loop in bat is super strange!"] +],[ + "start", + ["keyword.control.repeat.dosbatch","FOR"], + ["text"," /f "], + ["punctuation.definition.string.begin.shell","\""], + ["string.quoted.double.dosbatch","tokens=*"], + ["punctuation.definition.string.end.shell","\""], + ["text"," "], + ["constant.numeric","%%G"], + ["text"," IN ('"], + ["keyword.command.dosbatch","dir"], + ["text"," /A:D /b') DO ("] +],[ + "start", + ["keyword.command.dosbatch","echo"], + ["text"," "], + ["constant.numeric","%var1%%%G"] +],[ + "start", + ["keyword.command.dosbatch","attrib"], + ["text"," -r -a -h -s "], + ["punctuation.definition.string.begin.shell","\""], + ["constant.numeric","%var1%%%G"], + ["punctuation.definition.string.end.shell","\""], + ["text"," /D /S"] +],[ + "start", + ["text",")"] +],[ + "start" +],[ + "start", + ["keyword.command.dosbatch","pause"] +],[ + "start" +],[ + "start", + ["doc.comment","REM"], + ["comment"," that's all"] +],[ + "start" +]] \ No newline at end of file diff --git a/lib/ace/mode/_test/tokens_c9search.json b/lib/ace/mode/_test/tokens_c9search.json index 98052746..902d8dce 100644 --- a/lib/ace/mode/_test/tokens_c9search.json +++ b/lib/ace/mode/_test/tokens_c9search.json @@ -1,104 +1,131 @@ [[ - "start", - ["text","Searching for 'var' in /workspace/configs"] + ["start",{}], + ["text","Searching for '"], + ["text","var"], + ["text","' in"], + ["text"," /.c9/metadata/workspace/plugins "], + ["text","(regexp, case sensitive, whole word)"], + "Searching for \u0001var\u0001 in\u0001/.c9/metadata/workspace/plugins\u0001\u0001regexp, case sensitive, whole word\u0001" ],[ - "start" + ["start",{}] ],[ - "start", + ["start",{}], ["string","configs/default.js"], ["text",":"] ],[ - "start", + ["start",{}], ["c9searchresults.constant.numeric"," 1"], ["c9searchresults.text",": "], - ["c9searchresults.text","var fs = require(\"fs\");"] + ["c9searchresults.keyword","var"], + ["c9searchresults.text"," fs = require(\"fs\");"] ],[ - "start", + ["start",{}], ["c9searchresults.constant.numeric","\t2"], ["c9searchresults.text",": "], - ["c9searchresults.text","var argv = require('optimist').argv;"] + ["c9searchresults.keyword","var"], + ["c9searchresults.text"," argv = require('optimist').argv;"] ],[ - "start", + ["start",{}], ["c9searchresults.constant.numeric","\t3"], ["c9searchresults.text",": "], - ["c9searchresults.text","var path = require(\"path\");"] + ["c9searchresults.keyword","var"], + ["c9searchresults.text"," path = require(\"path\");"] ],[ - "start", + ["start",{}], ["c9searchresults.constant.numeric","\t5"], ["c9searchresults.text",": "], - ["c9searchresults.text","var clientExtensions = {};"] + ["c9searchresults.keyword","var"], + ["c9searchresults.text"," clientExtensions = {};"] ],[ - "start", + ["start",{}], ["c9searchresults.constant.numeric","\t6"], ["c9searchresults.text",": "], - ["c9searchresults.text","var clientDirs = fs.readdirSync(__dirname + \"/../plugins-client\");"] + ["c9searchresults.keyword","var"], + ["c9searchresults.text"," clientDirs = fs.readdirSync(__dirname + \"/../plugins-client\");"] ],[ - "start", + ["start",{}], ["c9searchresults.constant.numeric","\t7"], ["c9searchresults.text",": "], - ["c9searchresults.text","for (var i = 0; i < clientDirs.length; i++) {"] + ["c9searchresults.text","for ("], + ["c9searchresults.keyword","var"], + ["c9searchresults.text"," i = 0; i < clientDirs.length; i++) {"] ],[ - "start", + ["start",{}], ["c9searchresults.constant.numeric","\t8"], - ["c9searchresults.text",": "], - ["c9searchresults.text","var dir = clientDirs[i];"] + ["c9searchresults.text",": "], + ["c9searchresults.text"," "], + ["c9searchresults.keyword","var"], + ["c9searchresults.text"," dir = clientDirs[i];"] ],[ - "start", + ["start",{}], ["c9searchresults.constant.numeric","\t12"], - ["c9searchresults.text",": "], - ["c9searchresults.text","var name = dir.split(\".\")[1];"] + ["c9searchresults.text",": "], + ["c9searchresults.text"," "], + ["c9searchresults.keyword","var"], + ["c9searchresults.text"," name = dir.split(\".\")[1];"] ],[ - "start", + ["start",{}], ["c9searchresults.constant.numeric","\t16"], ["c9searchresults.text",": "], - ["c9searchresults.text","var projectDir = (argv.w && path.resolve(process.cwd(), argv.w)) || process.cwd();"] + ["c9searchresults.keyword","var"], + ["c9searchresults.text"," projectDir = (argv.w && path.resolve(process.cwd(), argv.w)) || process.cwd();"] ],[ - "start", + ["start",{}], ["c9searchresults.constant.numeric","\t17"], ["c9searchresults.text",": "], - ["c9searchresults.text","var fsUrl = \"/workspace\";"] + ["c9searchresults.keyword","var"], + ["c9searchresults.text"," fsUrl = \"/workspace\";"] ],[ - "start", + ["start",{}], ["c9searchresults.constant.numeric","\t19"], ["c9searchresults.text",": "], - ["c9searchresults.text","var port = argv.p || process.env.PORT || 3131;"] + ["c9searchresults.keyword","var"], + ["c9searchresults.text"," port = argv.p || process.env.PORT || 3131;"] ],[ - "start", + ["start",{}], ["c9searchresults.constant.numeric","\t20"], ["c9searchresults.text",": "], - ["c9searchresults.text","var host = argv.l || \"localhost\";"] + ["c9searchresults.keyword","var"], + ["c9searchresults.text"," host = argv.l || \"localhost\";"] ],[ - "start", + ["start",{}], ["c9searchresults.constant.numeric","\t22"], ["c9searchresults.text",": "], - ["c9searchresults.text","var config = {"] + ["c9searchresults.keyword","var"], + ["c9searchresults.text"," config = {"] ],[ - "start" + ["start",{}] ],[ - "start", + ["start",{}], ["string","configs/local.js"], ["text",":"] ],[ - "start", + ["start",{}], ["c9searchresults.constant.numeric","\t2"], ["c9searchresults.text",": "], - ["c9searchresults.text","var config = require(\"./default\");"] + ["c9searchresults.keyword","var"], + ["c9searchresults.text"," config = require(\"./default\");"] ],[ - "start" + ["start",{}] ],[ - "start", + ["start",{}], ["string","configs/packed.js"], ["text",":"] ],[ - "start", + ["start",{}], ["c9searchresults.constant.numeric","\t1"], ["c9searchresults.text",": "], - ["c9searchresults.text","var config = require(\"./default\");"] + ["c9searchresults.keyword","var"], + ["c9searchresults.text"," config = require(\"./default\");"] ],[ - "start" + ["start",{}] ],[ - "start" + ["start",{}] ],[ - "start", - ["text","Found 15 matches in 3 files"] + ["start",{}], + ["text","Found "], + ["constant.numeric","15"], + ["text"," matches in "], + ["constant.numeric","3"], + ["text"," files"] ]] \ No newline at end of file diff --git a/lib/ace/mode/_test/tokens_c_cpp.json b/lib/ace/mode/_test/tokens_c_cpp.json index 2818526f..a8668b0b 100644 --- a/lib/ace/mode/_test/tokens_c_cpp.json +++ b/lib/ace/mode/_test/tokens_c_cpp.json @@ -137,7 +137,12 @@ "start", ["text"," "], ["keyword","#if"], - ["constant.other"," VERBOSE >= 2"] + ["text"," "], + ["identifier","VERBOSE"], + ["text"," "], + ["keyword.operator",">="], + ["text"," "], + ["constant.numeric","2"] ],[ "start", ["text"," "], diff --git a/lib/ace/mode/_test/tokens_cirru.json b/lib/ace/mode/_test/tokens_cirru.json new file mode 100644 index 00000000..de4852e6 --- /dev/null +++ b/lib/ace/mode/_test/tokens_cirru.json @@ -0,0 +1,267 @@ +[[ + "start", + ["comment.line.double-dash","-- https://github.com/Cirru/cirru-gopher/blob/master/code/scope.cr,"] +],[ + "start" +],[ + "line", + ["support.function","set"], + ["text"," "], + ["variable.parameter","a"], + ["text"," "], + ["storage.modifier","("], + ["support.function","int"], + ["text"," "], + ["constant.numeric","2"], + ["storage.modifier",")"] +],[ + "start" +],[ + "line", + ["support.function","print"], + ["text"," "], + ["storage.modifier","("], + ["support.function","self"], + ["storage.modifier",")"] +],[ + "start" +],[ + "line", + ["support.function","set"], + ["text"," "], + ["variable.parameter","c"], + ["text"," "], + ["storage.modifier","("], + ["support.function","child"], + ["storage.modifier",")"] +],[ + "start" +],[ + "line", + ["support.function","under"], + ["text"," "], + ["variable.parameter","c"] +],[ + "line", + ["markup.raw"," "], + ["support.function","under"], + ["text"," "], + ["variable.parameter","parent"] +],[ + "line", + ["markup.raw"," "], + ["support.function","print"], + ["text"," "], + ["variable.parameter","a"] +],[ + "start" +],[ + "line", + ["support.function","print"], + ["text"," "], + ["storage.modifier","$"], + ["text"," "], + ["support.function","get"], + ["text"," "], + ["variable.parameter","c"], + ["text"," "], + ["variable.parameter","a"] +],[ + "start" +],[ + "line", + ["support.function","set"], + ["text"," "], + ["variable.parameter","c"], + ["text"," "], + ["variable.parameter","x"], + ["text"," "], + ["storage.modifier","("], + ["support.function","int"], + ["text"," "], + ["constant.numeric","3"], + ["storage.modifier",")"] +],[ + "line", + ["support.function","print"], + ["text"," "], + ["storage.modifier","$"], + ["text"," "], + ["support.function","get"], + ["text"," "], + ["variable.parameter","c"], + ["text"," "], + ["variable.parameter","x"] +],[ + "start" +],[ + "line", + ["support.function","set"], + ["text"," "], + ["variable.parameter","just-print"], + ["text"," "], + ["storage.modifier","$"], + ["text"," "], + ["support.function","code"] +],[ + "line", + ["markup.raw"," "], + ["support.function","print"], + ["text"," "], + ["variable.parameter","a"] +],[ + "start" +],[ + "line", + ["support.function","print"], + ["text"," "], + ["variable.parameter","just-print"] +],[ + "start" +],[ + "line", + ["support.function","eval"], + ["text"," "], + ["storage.modifier","("], + ["support.function","self"], + ["storage.modifier",")"], + ["text"," "], + ["variable.parameter","just-print"] +],[ + "line", + ["support.function","eval"], + ["text"," "], + ["variable.parameter","just-print"] +],[ + "start" +],[ + "line", + ["support.function","print"], + ["text"," "], + ["storage.modifier","("], + ["support.function","string"], + ["text"," "], + ["string.quoted.double","\"string with space\""], + ["storage.modifier",")"] +],[ + "line", + ["support.function","print"], + ["text"," "], + ["storage.modifier","("], + ["support.function","string"], + ["text"," "], + ["string.quoted.double","\"escapes "], + ["constant.character.escape","\\n"], + ["string.quoted.double"," "], + ["constant.character.escape","\\\"\\\\"], + ["string.quoted.double","\""], + ["storage.modifier",")"] +],[ + "start" +],[ + "start", + ["support.function","brackets"], + ["text"," "], + ["storage.modifier","((((()))))"] +],[ + "start" +],[ + "line", + ["string.quoted.double","\"eval\""], + ["text"," "], + ["storage.modifier","$"], + ["text"," "], + ["support.function","string"], + ["text"," "], + ["string.quoted.double","\"eval\""] +],[ + "start" +],[ + "line", + ["support.function","print"], + ["text"," "], + ["storage.modifier","("], + ["support.function","add"], + ["text"," "], + ["storage.modifier","$"], + ["text"," "], + ["storage.modifier","("], + ["support.function","int"], + ["text"," "], + ["constant.numeric","1"], + ["storage.modifier",")"], + ["text"," "], + ["storage.modifier","("], + ["support.function","int"], + ["text"," "], + ["constant.numeric","2"], + ["storage.modifier","))"] +],[ + "start" +],[ + "start", + ["support.function","print"], + ["text"," "], + ["storage.modifier","$"], + ["text"," "], + ["support.function","unwrap"], + ["text"," "], + ["storage.modifier","$"] +],[ + "line", + ["text"," "], + ["support.function","map"], + ["text"," "], + ["storage.modifier","("], + ["support.function","a"], + ["text"," "], + ["storage.modifier","$"], + ["text"," "], + ["support.function","int"], + ["text"," "], + ["constant.numeric","1"], + ["storage.modifier",")"], + ["text"," "], + ["storage.modifier","("], + ["support.function","b"], + ["text"," "], + ["storage.modifier","$"], + ["text"," "], + ["support.function","int"], + ["text"," "], + ["constant.numeric","2"], + ["storage.modifier",")"] +],[ + "start" +],[ + "line", + ["support.function","print"], + ["text"," "], + ["variable.parameter","a"] +],[ + "line", + ["markup.raw"," "], + ["support.function","int"], + ["text"," "], + ["constant.numeric","1"] +],[ + "line", + ["markup.raw"," "], + ["storage.modifier",","], + ["text"," "], + ["variable.parameter","b"], + ["text"," "], + ["variable.parameter","c"] +],[ + "line", + ["markup.raw"," "], + ["support.function","int"], + ["text"," "], + ["constant.numeric","2"] +],[ + "line", + ["markup.raw"," "], + ["storage.modifier",","], + ["text"," "], + ["variable.parameter","d"] +]] \ No newline at end of file diff --git a/lib/ace/mode/_test/tokens_cobol.json b/lib/ace/mode/_test/tokens_cobol.json new file mode 100644 index 00000000..9909eadd --- /dev/null +++ b/lib/ace/mode/_test/tokens_cobol.json @@ -0,0 +1,4 @@ +[[ + "start", + ["identifier","TODO"] +]] \ No newline at end of file diff --git a/lib/ace/mode/_test/tokens_coffee.json b/lib/ace/mode/_test/tokens_coffee.json index 9c3967e4..b0703b37 100644 --- a/lib/ace/mode/_test/tokens_coffee.json +++ b/lib/ace/mode/_test/tokens_coffee.json @@ -466,6 +466,23 @@ ["constant.numeric","2"], ["paren.string","}"], ["string.end","\""] +],[ + "start", + ["string.start","\""], + ["string"," "], + ["paren.string","#{"], + ["text"," "], + ["string.start","\""], + ["string.end","\""], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["paren","{}"], + ["text"," "], + ["paren.string","}"], + ["string"," )"], + ["string.end","\""], + ["text"," "] ],[ "qqdoc", ["string","\"\"\"heredoc"] diff --git a/lib/ace/mode/_test/tokens_coldfusion.json b/lib/ace/mode/_test/tokens_coldfusion.json index e636d3cf..804e647d 100644 --- a/lib/ace/mode/_test/tokens_coldfusion.json +++ b/lib/ace/mode/_test/tokens_coldfusion.json @@ -1,26 +1,26 @@ [[ "start", - ["comment",""] + ["comment.xml",""] ],[ "start" ],[ "start", - ["meta.tag","<"], - ["meta.tag.tag-name","cfset"], - ["text"," "], - ["entity.other.attribute-name","welcome"], - ["keyword.operator","="], - ["string","\"Hello World!\""], - ["meta.tag.r",">"] + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","cfset"], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","welcome"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"Hello World!\""], + ["meta.tag.punctuation.tag-close.xml",">"] ],[ "start" ],[ "start", - ["meta.tag","<"], - ["meta.tag.tag-name","cfoutput"], - ["meta.tag.r",">"], - ["text","#welcome#"], - ["meta.tag",""] + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","cfoutput"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["text.xml","#welcome#"], + ["meta.tag.punctuation.end-tag-open.xml",""] ]] \ No newline at end of file diff --git a/lib/ace/mode/_test/tokens_css.json b/lib/ace/mode/_test/tokens_css.json index 244f0a03..e1a7ba05 100644 --- a/lib/ace/mode/_test/tokens_css.json +++ b/lib/ace/mode/_test/tokens_css.json @@ -76,13 +76,13 @@ "media", ["string","@keyframes blink {"] ],[ - "media_ruleset", + ["ruleset","media"], ["text"," "], ["constant","0"], ["text","% "], ["paren.lparen","{"] ],[ - "media_ruleset", + ["ruleset","media"], ["text"," "], ["support.type","opacity"], ["text",": "], @@ -93,13 +93,13 @@ ["text"," "], ["paren.rparen","}"] ],[ - "media_ruleset", + ["ruleset","media"], ["text"," "], ["constant","40"], ["text","% "], ["paren.lparen","{"] ],[ - "media_ruleset", + ["ruleset","media"], ["text"," "], ["support.type","opacity"], ["text",": "], @@ -110,14 +110,14 @@ ["text"," "], ["paren.rparen","}"] ],[ - "media_ruleset", + ["ruleset","media"], ["text"," "], ["constant","40"], ["variable",".5"], ["text","% "], ["paren.lparen","{"] ],[ - "media_ruleset", + ["ruleset","media"], ["text"," "], ["support.type","opacity"], ["text",": "], @@ -127,13 +127,13 @@ ["text"," "], ["paren.rparen","}"] ],[ - "media_ruleset", + ["ruleset","media"], ["text"," "], ["constant","100"], ["text","% "], ["paren.lparen","{"] ],[ - "media_ruleset", + ["ruleset","media"], ["text"," "], ["support.type","opacity"], ["text",": "], diff --git a/lib/ace/mode/_test/tokens_curly.json b/lib/ace/mode/_test/tokens_curly.json index 14144479..d87a627a 100644 --- a/lib/ace/mode/_test/tokens_curly.json +++ b/lib/ace/mode/_test/tokens_curly.json @@ -1,56 +1,56 @@ [[ "start", - ["text","tokenize Curly template"], + ["text.xml","tokenize Curly template"], ["variable","{{"], ["text","test"], ["variable","}}"] ],[ "start", - ["text","tokenize embedded script"] + ["text.xml","tokenize embedded script"] ],[ "start", - ["meta.tag","<"], - ["meta.tag.tag-name.script","script"], - ["text"," "], - ["entity.other.attribute-name","a"], - ["keyword.operator","="], - ["string","'a'"], - ["meta.tag.r",">"], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.script.tag-name.xml","script"], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","a"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","'a'"], + ["meta.tag.punctuation.tag-close.xml",">"], ["storage.type","var"], - ["meta.tag",""], - ["text","'123'"] + ["meta.tag.punctuation.end-tag-open.xml",""], + ["text.xml","'123'"] ],[ "start", - ["text","tokenize multiline attribute value with double quotes"] + ["text.xml","tokenize multiline attribute value with double quotes"] ],[ - "tag_qqstring", - ["meta.tag","<"], - ["meta.tag.tag-name.anchor","a"], - ["text"," "], - ["entity.other.attribute-name","href"], - ["keyword.operator","="], - ["string","\"abc{{xyz}}"] + ["string.attribute-value.xml0","tag_stuff"], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.anchor.tag-name.xml","a"], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","href"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"abc{{xyz}}"] ],[ "start", - ["string","def\""], - ["meta.tag.r",">"] + ["string.attribute-value.xml","def\""], + ["meta.tag.punctuation.tag-close.xml",">"] ],[ "start", - ["text","tokenize multiline attribute value with single quotes"] + ["text.xml","tokenize multiline attribute value with single quotes"] ],[ - "tag_qstring", - ["meta.tag","<"], - ["meta.tag.tag-name.anchor","a"], - ["text"," "], - ["entity.other.attribute-name","href"], - ["keyword.operator","="], - ["string","'abc"] + ["string.attribute-value.xml","tag_stuff"], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.anchor.tag-name.xml","a"], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","href"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","'abc"] ],[ "start", - ["string","def\\\"'"], - ["meta.tag.r",">"] + ["string.attribute-value.xml","def\\\"'"], + ["meta.tag.punctuation.tag-close.xml",">"] ],[ "start" ]] \ No newline at end of file diff --git a/lib/ace/mode/_test/tokens_d.json b/lib/ace/mode/_test/tokens_d.json new file mode 100644 index 00000000..85831cc3 --- /dev/null +++ b/lib/ace/mode/_test/tokens_d.json @@ -0,0 +1,111 @@ +[[ + "start", + ["comment.shebang","#!/usr/bin/env rdmd"] +],[ + "start", + ["comment","// Computes average line length for standard input."] +],[ + "start", + ["keyword","import"], + ["text"," "], + ["variable.module","std.stdio"], + ["punctuation.operator",";"] +],[ + "start" +],[ + "start", + ["keyword.type","void"], + ["text"," "], + ["identifier","main"], + ["paren.lparen","("], + ["paren.rparen",")"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["keyword.type","ulong"], + ["text"," "], + ["identifier","lines"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["constant.numeric","0"], + ["punctuation.operator",";"] +],[ + "start", + ["text"," "], + ["keyword.type","double"], + ["text"," "], + ["identifier","sumLength"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["constant.numeric","0"], + ["punctuation.operator",";"] +],[ + "start", + ["text"," "], + ["keyword.control","foreach"], + ["text"," "], + ["paren.lparen","("], + ["identifier","line"], + ["punctuation.operator",";"], + ["text"," "], + ["identifier","stdin"], + ["punctuation.operator","."], + ["identifier","byLine"], + ["paren.lparen","("], + ["paren.rparen","))"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["keyword.operator","++"], + ["identifier","lines"], + ["punctuation.operator",";"] +],[ + "start", + ["text"," "], + ["identifier","sumLength"], + ["text"," "], + ["keyword.operator","+="], + ["text"," "], + ["identifier","line"], + ["punctuation.operator","."], + ["identifier","length"], + ["punctuation.operator",";"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start", + ["text"," "], + ["identifier","writeln"], + ["paren.lparen","("], + ["string","\"Average line length: \""], + ["punctuation.operator",","] +],[ + "start", + ["text"," "], + ["identifier","lines"], + ["text"," "], + ["keyword.operator","?"], + ["text"," "], + ["identifier","sumLength"], + ["text"," "], + ["keyword.operator","/"], + ["text"," "], + ["identifier","lines"], + ["text"," "], + ["punctuation.operator",":"], + ["text"," "], + ["constant.numeric","0"], + ["paren.rparen",")"], + ["punctuation.operator",";"] +],[ + "start", + ["paren.rparen","}"] +]] \ No newline at end of file diff --git a/lib/ace/mode/_test/tokens_dart.json b/lib/ace/mode/_test/tokens_dart.json index 5964791a..37cdc323 100644 --- a/lib/ace/mode/_test/tokens_dart.json +++ b/lib/ace/mode/_test/tokens_dart.json @@ -330,7 +330,7 @@ ["text",";"] ],[ "start", - ["identifier","assert"], + ["keyword.control.dart","assert"], ["text","("], ["identifier","unicorn"], ["text"," "], @@ -357,7 +357,7 @@ ["text",";"] ],[ "start", - ["identifier","assert"], + ["keyword.control.dart","assert"], ["text","("], ["identifier","iMeantToDoThis"], ["text","."], diff --git a/lib/ace/mode/_test/tokens_diff.json b/lib/ace/mode/_test/tokens_diff.json index 6063991e..6c36f5fa 100644 --- a/lib/ace/mode/_test/tokens_diff.json +++ b/lib/ace/mode/_test/tokens_diff.json @@ -4,393 +4,257 @@ ["variable"," --git"], ["keyword"," a/lib/ace/edit_session.js"], ["variable"," b/lib/ace/edit_session.js"] -],[ - "start" ],[ "start", ["variable","index 23fc3fc..ed3b273 100644"] -],[ - "start" ],[ "start", ["constant.numeric","---"], ["meta.tag"," a/lib/ace/edit_session.js"] -],[ - "start" ],[ "start", ["constant.numeric","+++"], ["meta.tag"," b/lib/ace/edit_session.js"] -],[ - "start" ],[ "start", ["constant","@@"], ["constant.numeric"," -51,6 +51,7 "], ["constant","@@"], ["comment.doc.tag"," var TextMode = require(\"./mode/text\").Mode;"] -],[ - "start" ],[ "start", ["invisible"," var Range = require(\"./range\").Range;"] -],[ - "start" ],[ "start", ["invisible"," var Document = require(\"./document\").Document;"] -],[ - "start" ],[ "start", ["invisible"," var BackgroundTokenizer = require(\"./background_tokenizer\").BackgroundTokenizer;"] -],[ - "start" ],[ "start", ["support.constant","+"], ["text","var SearchHighlight = require(\"./search_highlight\").SearchHighlight;"] -],[ - "start" ],[ "start", - ["invalid"," "] -],[ - "start" + ["text"," "] ],[ "start", ["invisible"," /**"] -],[ - "start" ],[ "start", ["invisible"," * class EditSession"] -],[ - "start" ],[ "start", ["constant","@@"], ["constant.numeric"," -307,6 +308,13 "], ["constant","@@"], ["comment.doc.tag"," var EditSession = function(text, mode) {"] -],[ - "start" ],[ "start", ["invisible"," return token;"] -],[ - "start" ],[ "start", ["invisible"," };"] -],[ - "start" ],[ "start", - ["invalid"," "] -],[ - "start" + ["text"," "] ],[ "start", ["support.constant","+"], ["text"," this.highlight = function(re) {"] -],[ - "start" ],[ "start", ["support.constant","+"], ["text"," if (!this.$searchHighlight) {"] -],[ - "start" ],[ "start", ["support.constant","+"], ["text"," var highlight = new SearchHighlight(null, \"ace_selected-word\", \"text\");"] -],[ - "start" ],[ "start", ["support.constant","+"], ["text"," this.$searchHighlight = this.addDynamicMarker(highlight);"] -],[ - "start" ],[ "start", ["support.constant","+"], ["text"," }"] -],[ - "start" ],[ "start", ["support.constant","+"], ["text"," this.$searchHighlight.setRegexp(re);"] -],[ - "start" ],[ "start", ["support.constant","+"], ["text"," }"] -],[ - "start" ],[ "start", ["invisible"," /**"] -],[ - "start" ],[ "start", ["invisible"," * EditSession.setUndoManager(undoManager)"] -],[ - "start" ],[ "start", ["invisible"," * - undoManager (UndoManager): The new undo manager"] -],[ - "start" ],[ "start", ["constant","@@"], ["constant.numeric"," -556,7 +564,8 "], ["constant","@@"], ["comment.doc.tag"," var EditSession = function(text, mode) {"] -],[ - "start" ],[ "start", ["invisible"," type : type || \"line\","] -],[ - "start" ],[ "start", ["invisible"," renderer: typeof type == \"function\" ? type : null,"] -],[ - "start" ],[ "start", ["invisible"," clazz : clazz,"] -],[ - "start" ],[ "start", ["support.function","-"], ["string"," inFront: !!inFront"] -],[ - "start" ],[ "start", ["support.constant","+"], ["text"," inFront: !!inFront,"] -],[ - "start" ],[ "start", ["support.constant","+"], ["text"," id: id"] -],[ - "start" ],[ "start", ["invisible"," }"] -],[ - "start" ],[ "start", - ["invalid"," "] -],[ - "start" + ["text"," "] ],[ "start", ["invisible"," if (inFront) {"] -],[ - "start" ],[ "start", ["variable","diff"], ["variable"," --git"], ["keyword"," a/lib/ace/editor.js"], ["variable"," b/lib/ace/editor.js"] -],[ - "start" ],[ "start", ["variable","index 834e603..b27ec73 100644"] -],[ - "start" ],[ "start", ["constant.numeric","---"], ["meta.tag"," a/lib/ace/editor.js"] -],[ - "start" ],[ "start", ["constant.numeric","+++"], ["meta.tag"," b/lib/ace/editor.js"] -],[ - "start" ],[ "start", ["constant","@@"], ["constant.numeric"," -494,7 +494,7 "], ["constant","@@"], ["comment.doc.tag"," var Editor = function(renderer, session) {"] -],[ - "start" ],[ "start", ["invisible"," * Emitted when a selection has changed."] -],[ - "start" ],[ "start", ["invisible"," **/"] -],[ - "start" ],[ "start", ["invisible"," this.onSelectionChange = function(e) {"] -],[ - "start" ],[ "start", ["support.function","-"], ["string"," var session = this.getSession();"] -],[ - "start" ],[ "start", ["support.constant","+"], ["text"," var session = this.session;"] -],[ - "start" ],[ "start", - ["invalid"," "] -],[ - "start" + ["text"," "] ],[ "start", ["invisible"," if (session.$selectionMarker) {"] -],[ - "start" ],[ "start", ["invisible"," session.removeMarker(session.$selectionMarker);"] -],[ - "start" ],[ "start", ["constant","@@"], ["constant.numeric"," -509,12 +509,40 "], ["constant","@@"], ["comment.doc.tag"," var Editor = function(renderer, session) {"] -],[ - "start" ],[ "start", ["invisible"," this.$updateHighlightActiveLine();"] -],[ - "start" ],[ "start", ["invisible"," }"] -],[ - "start" ],[ "start", - ["invalid"," "] -],[ - "start" + ["text"," "] ],[ "start", ["support.function","-"], ["string"," var self = this;"] -],[ - "start" ],[ "start", ["support.function","-"], ["string"," if (this.$highlightSelectedWord && !this.$wordHighlightTimer)"] -],[ - "start" ],[ "start", ["support.function","-"], ["string"," this.$wordHighlightTimer = setTimeout(function() {"] -],[ - "start" ],[ "start", ["support.function","-"], ["string"," self.session.$mode.highlightSelection(self);"] -],[ - "start" ],[ "start", ["support.function","-"], ["string"," self.$wordHighlightTimer = null;"] -],[ - "start" ],[ "start", ["support.function","-"], ["string"," }, 30, this);"] -],[ - "start" ],[ "start", ["support.constant","+"], ["text"," var re = this.$highlightSelectedWord && this.$getSelectionHighLightRegexp()"] -],[ - "start" ],[ "start", ["invisible"," };"] -],[ - "start" ],[ "start", ["variable","diff"], ["variable"," --git"], ["keyword"," a/lib/ace/search_highlight.js"], ["variable"," b/lib/ace/search_highlight.js"] -],[ - "start" ],[ "start", ["invisible","new file mode 100644"] -],[ - "start" ],[ "start", ["variable","index 0000000..b2df779"] -],[ - "start" ],[ "start", ["constant.numeric","---"], ["meta.tag"," /dev/null"] -],[ - "start" ],[ "start", ["constant.numeric","+++"], ["meta.tag"," b/lib/ace/search_highlight.js"] -],[ - "start" ],[ "start", ["constant","@@"], ["constant.numeric"," -0,0 +1,3 "], ["constant","@@"] -],[ - "start" ],[ "start", ["support.constant","+"], ["text","new"] -],[ - "start" ],[ "start", ["support.constant","+"], diff --git a/lib/ace/mode/_test/tokens_eiffel.json b/lib/ace/mode/_test/tokens_eiffel.json new file mode 100644 index 00000000..344dbc62 --- /dev/null +++ b/lib/ace/mode/_test/tokens_eiffel.json @@ -0,0 +1,141 @@ +[[ + "start", + ["keyword","note"] +],[ + "start", + ["text","\t"], + ["identifier","description"], + ["keyword.operator",":"], + ["text"," "], + ["string.quoted.double","\"Represents a person.\""] +],[ + "start" +],[ + "start", + ["keyword","class"] +],[ + "start", + ["text","\t"], + ["entity.name.type","PERSON"] +],[ + "start" +],[ + "start", + ["keyword","create"] +],[ + "start", + ["text","\t"], + ["identifier","make"], + ["keyword.operator",","], + ["text"," "], + ["identifier","make_unknown"] +],[ + "start" +],[ + "start", + ["keyword","feature"], + ["text"," "], + ["paren.lparen","{"], + ["entity.name.type","NONE"], + ["paren.rparen","}"], + ["text"," "], + ["comment.line.double-dash","-- Creation"] +],[ + "start" +],[ + "start", + ["text","\t"], + ["identifier","make"], + ["text"," "], + ["paren.lparen","("], + ["identifier","a_name"], + ["keyword.operator",":"], + ["text"," "], + ["keyword","like"], + ["text"," "], + ["identifier","name"], + ["paren.rparen",")"] +],[ + "start", + ["text","\t\t\t"], + ["comment.line.double-dash","-- Create a person with `a_name' as `name'."] +],[ + "start", + ["text","\t\t"], + ["keyword","do"] +],[ + "start", + ["text","\t\t\t"], + ["identifier","name"], + ["text"," "], + ["keyword.operator",":="], + ["text"," "], + ["identifier","a_name"] +],[ + "start", + ["text","\t\t"], + ["keyword","ensure"] +],[ + "start", + ["text","\t\t\t"], + ["identifier","name"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["identifier","a_name"] +],[ + "start", + ["text","\t\t"], + ["keyword","end"] +],[ + "start" +],[ + "start", + ["text","\t"], + ["identifier","make_unknown"] +],[ + "start", + ["text","\t\t"], + ["keyword","do"], + ["text"," "], + ["keyword","ensure"] +],[ + "start", + ["text","\t\t\t"], + ["identifier","name"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["constant.language","Void"] +],[ + "start", + ["text","\t\t"], + ["keyword","end"] +],[ + "start" +],[ + "start", + ["keyword","feature"], + ["text"," "], + ["comment.line.double-dash","-- Access"] +],[ + "start" +],[ + "start", + ["text","\t"], + ["identifier","name"], + ["keyword.operator",":"], + ["text"," "], + ["keyword","detachable"], + ["text"," "], + ["entity.name.type","STRING"] +],[ + "start", + ["text","\t\t\t"], + ["comment.line.double-dash","-- Full name or Void if unknown."] +],[ + "start" +],[ + "start", + ["keyword","end"] +]] \ No newline at end of file diff --git a/lib/ace/mode/_test/tokens_ejs.json b/lib/ace/mode/_test/tokens_ejs.json new file mode 100644 index 00000000..7e54af91 --- /dev/null +++ b/lib/ace/mode/_test/tokens_ejs.json @@ -0,0 +1,296 @@ +[[ + "start", + ["xml-pe.doctype.xml",""] +],[ + "start", + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","html"], + ["meta.tag.punctuation.tag-close.xml",">"] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","head"], + ["meta.tag.punctuation.tag-close.xml",">"] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","title"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["text.xml","Cloud9 Rocks!"], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","body"], + ["meta.tag.punctuation.tag-close.xml",">"] +],[ + "start" +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.table.tag-name.xml","table"], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","class"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"table\""], + ["meta.tag.punctuation.tag-close.xml",">"] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.table.tag-name.xml","tr"], + ["meta.tag.punctuation.tag-close.xml",">"] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.table.tag-name.xml","th"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["text.xml","Name"], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.table.tag-name.xml","th"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["text.xml","Size"], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["text.xml"," "], + ["markup.list.meta.tag","<%"], + ["text"," "], + ["keyword","if"], + ["text"," "], + ["paren.lparen","("], + ["keyword.operator","!"], + ["identifier","isRoot"], + ["paren.rparen",")"], + ["text"," "], + ["paren.lparen","{"], + ["text"," "], + ["markup.list.meta.tag","%>"] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.table.tag-name.xml","tr"], + ["meta.tag.punctuation.tag-close.xml",">"] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.table.tag-name.xml","td"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.anchor.tag-name.xml","a"], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","href"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"..\""], + ["meta.tag.punctuation.tag-close.xml",">"], + ["text.xml",".."], + ["meta.tag.punctuation.end-tag-open.xml",""], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.table.tag-name.xml","td"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["meta.tag.punctuation.end-tag-open.xml",""], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["text.xml"," "], + ["markup.list.meta.tag","<%"], + ["text"," "], + ["paren.rparen","}"], + ["text"," "], + ["markup.list.meta.tag","%>"] +],[ + "start", + ["text.xml"," "], + ["markup.list.meta.tag","<%"], + ["text"," "], + ["identifier","entries"], + ["punctuation.operator","."], + ["identifier","forEach"], + ["paren.lparen","("], + ["storage.type","function"], + ["paren.lparen","("], + ["identifier","entry"], + ["paren.rparen",")"], + ["text"," "], + ["paren.lparen","{"], + ["text"," "], + ["markup.list.meta.tag","%>"] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.table.tag-name.xml","tr"], + ["meta.tag.punctuation.tag-close.xml",">"] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.table.tag-name.xml","td"], + ["meta.tag.punctuation.tag-close.xml",">"] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","span"], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","class"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"glyphicon "], + ["markup.list.meta.tag","<%="], + ["text"," "], + ["identifier","entry"], + ["punctuation.operator","."], + ["identifier","mime"], + ["text"," "], + ["keyword.operator","=="], + ["text"," "], + ["string","'directory'"], + ["text"," "], + ["punctuation.operator","?"], + ["text"," "], + ["string","'folder'"], + ["punctuation.operator",":"], + ["text"," "], + ["string","'file'"], + ["markup.list.meta.tag","%>"], + ["string.attribute-value.xml","\""], + ["meta.tag.punctuation.tag-close.xml",">"], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.anchor.tag-name.xml","a"], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","href"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\""], + ["markup.list.meta.tag","<%="], + ["text"," "], + ["identifier","entry"], + ["punctuation.operator","."], + ["identifier","name"], + ["text"," "], + ["markup.list.meta.tag","%>"], + ["string.attribute-value.xml","\""], + ["meta.tag.punctuation.tag-close.xml",">"], + ["markup.list.meta.tag","<%="], + ["text"," "], + ["identifier","entry"], + ["punctuation.operator","."], + ["identifier","name"], + ["text"," "], + ["markup.list.meta.tag","%>"], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.table.tag-name.xml","td"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["markup.list.meta.tag","<%="], + ["text"," "], + ["identifier","entry"], + ["punctuation.operator","."], + ["identifier","size"], + ["text"," "], + ["markup.list.meta.tag","%>"], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["text.xml"," "], + ["markup.list.meta.tag","<%"], + ["text"," "], + ["paren.rparen","})"], + ["text"," "], + ["markup.list.meta.tag","%>"] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["text.xml"," "] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["meta.tag.punctuation.end-tag-open.xml",""] +]] \ No newline at end of file diff --git a/lib/ace/mode/_test/tokens_elixir.json b/lib/ace/mode/_test/tokens_elixir.json new file mode 100644 index 00000000..cbbe1fee --- /dev/null +++ b/lib/ace/mode/_test/tokens_elixir.json @@ -0,0 +1,196 @@ +[[ + "start", + ["keyword.control.module.elixir","defmodule"], + ["meta.module.elixir"," "], + ["entity.name.type.module.elixir","HelloModule"], + ["text"," "], + ["keyword.control.elixir","do"] +],[ + "comment.documentation.heredoc", + ["text"," "], + ["comment.documentation.heredoc","@moduledoc \"\"\""] +],[ + "comment.documentation.heredoc", + ["comment.documentation.heredoc"," This is supposed to be `markdown`."] +],[ + "comment.documentation.heredoc", + ["comment.documentation.heredoc"," __Yes__ this is [mark](http://down.format)"] +],[ + "comment.documentation.heredoc" +],[ + "comment.documentation.heredoc", + ["comment.documentation.heredoc"," # Truly"] +],[ + "comment.documentation.heredoc" +],[ + "comment.documentation.heredoc", + ["comment.documentation.heredoc"," ## marked"] +],[ + "comment.documentation.heredoc" +],[ + "comment.documentation.heredoc", + ["comment.documentation.heredoc"," * with lists"] +],[ + "comment.documentation.heredoc", + ["comment.documentation.heredoc"," * more"] +],[ + "comment.documentation.heredoc", + ["comment.documentation.heredoc"," * and more"] +],[ + "comment.documentation.heredoc" +],[ + "comment.documentation.heredoc", + ["comment.documentation.heredoc"," Even.with(code)"] +],[ + "comment.documentation.heredoc", + ["comment.documentation.heredoc"," blocks |> with |> samples"] +],[ + "comment.documentation.heredoc" +],[ + "comment.documentation.heredoc", + ["comment.documentation.heredoc"," _Docs are first class citizens in Elixir_ (Jose Valim)"] +],[ + "start", + ["comment.documentation.heredoc"," \"\"\""] +],[ + "start", + ["text"," "] +],[ + "start", + ["text"," "], + ["punctuation.definition.comment.elixir","#"], + ["comment.line.number-sign.elixir"," A \"Hello world\" function"] +],[ + "start", + ["text"," "], + ["keyword.control.elixir","def"], + ["text"," some_fun "], + ["keyword.control.elixir","do"] +],[ + "start", + ["text"," "], + ["variable.other.constant.elixir","IO"], + ["punctuation.separator.method.elixir","."], + ["text","puts "], + ["punctuation.definition.string.begin.elixir","\""], + ["string.quoted.double.elixir","Juhu Kinners!"], + ["punctuation.definition.string.end.elixir","\""] +],[ + "start", + ["text"," "], + ["keyword.control.elixir","end"] +],[ + "start", + ["text"," "], + ["punctuation.definition.comment.elixir","#"], + ["comment.line.number-sign.elixir"," A private function"] +],[ + "start", + ["text"," "], + ["keyword.control.elixir","defp"], + ["text"," priv "], + ["keyword.control.elixir","do"] +],[ + "punctuation.definition.string.begin.elixir7", + ["text"," is_regex "], + ["punctuation.definition.string.begin.elixir","~r\"\"\""] +],[ + "punctuation.definition.string.begin.elixir7", + ["string.quoted.double.heredoc.elixir"," This is a regex"] +],[ + "punctuation.definition.string.begin.elixir7", + ["string.quoted.double.heredoc.elixir"," spanning several"] +],[ + "punctuation.definition.string.begin.elixir7", + ["string.quoted.double.heredoc.elixir"," lines."] +],[ + "start", + ["punctuation.definition.string.end.elixir"," \"\"\""] +],[ + "start", + ["text"," x "], + ["keyword.operator.assignment.elixir","="], + ["text"," elem"], + ["punctuation.section.function.elixir","("], + ["punctuation.section.scope.elixir","{"], + ["text"," "], + ["punctuation.definition.constant.elixir",":"], + ["constant.other.symbol.elixir","a"], + ["punctuation.separator.object.elixir",","], + ["text"," "], + ["punctuation.definition.constant.elixir",":"], + ["constant.other.symbol.elixir","b"], + ["punctuation.separator.object.elixir",","], + ["text"," "], + ["punctuation.definition.constant.elixir",":"], + ["constant.other.symbol.elixir","c"], + ["text"," "], + ["punctuation.section.scope.elixir","}"], + ["punctuation.separator.object.elixir",","], + ["text"," "], + ["constant.numeric.elixir","0"], + ["punctuation.section.function.elixir",")"], + ["text"," "], + ["punctuation.definition.comment.elixir","#"], + ["comment.line.number-sign.elixir","=> :a"] +],[ + "start", + ["text"," "], + ["keyword.control.elixir","end"] +],[ + "start", + ["keyword.control.elixir","end"] +],[ + "start" +],[ + "start", + ["text","test_fun "], + ["keyword.operator.assignment.elixir","="], + ["text"," "], + ["keyword.control.elixir","fn"], + ["punctuation.section.function.elixir","("], + ["text","x"], + ["punctuation.section.function.elixir",")"], + ["text"," "], + ["keyword.operator.arithmetic.elixir","-"], + ["keyword.operator.comparison.elixir",">"] +],[ + "start", + ["text"," "], + ["keyword.control.elixir","cond"], + ["text"," "], + ["keyword.control.elixir","do"] +],[ + "start", + ["text"," x "], + ["keyword.operator.comparison.elixir",">"], + ["text"," "], + ["constant.numeric.elixir","10"], + ["text"," "], + ["keyword.operator.arithmetic.elixir","-"], + ["keyword.operator.comparison.elixir",">"] +],[ + "start", + ["text"," "], + ["punctuation.definition.constant.elixir",":"], + ["constant.other.symbol.elixir","greater_than_ten"] +],[ + "start", + ["text"," "], + ["constant.language.elixir","true"], + ["text"," "], + ["keyword.operator.arithmetic.elixir","-"], + ["keyword.operator.comparison.elixir",">"] +],[ + "start", + ["text"," "], + ["punctuation.definition.constant.elixir",":"], + ["constant.other.symbol.elixir","maybe_ten"] +],[ + "start", + ["text"," "], + ["keyword.control.elixir","end"] +],[ + "start", + ["keyword.control.elixir","end"] +]] \ No newline at end of file diff --git a/lib/ace/mode/_test/tokens_elm.json b/lib/ace/mode/_test/tokens_elm.json new file mode 100644 index 00000000..b39de92f --- /dev/null +++ b/lib/ace/mode/_test/tokens_elm.json @@ -0,0 +1,198 @@ +[[ + "start", + ["comment.start","{-"], + ["comment"," Ace "], + ["comment.start","{-"], + ["comment"," 4 "], + ["comment.end","-}"], + ["comment"," Elm "], + ["comment.end","-}"] +],[ + "start", + ["constant.language","main"], + ["text"," "], + ["keyword","="], + ["text"," "], + ["identifier","lift"], + ["text"," "], + ["identifier","clock"], + ["text"," "], + ["paren.lparen","("], + ["identifier","every"], + ["text"," "], + ["identifier","second"], + ["paren.rparen",")"] +],[ + "start" +],[ + "start", + ["constant.language","clock"], + ["text"," "], + ["identifier","t"], + ["text"," "], + ["keyword","="], + ["text"," "], + ["identifier","collage"], + ["text"," "], + ["constant.numeric","400"], + ["text"," "], + ["constant.numeric","400"], + ["text"," "], + ["paren.lparen","["], + ["text"," "], + ["identifier","filled"], + ["text"," "], + ["identifier","lightGrey"], + ["text"," "], + ["paren.lparen","("], + ["identifier","ngon"], + ["text"," "], + ["constant.numeric","12"], + ["text"," "], + ["constant.numeric","110"], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["operator.punctuation",","], + ["text"," "], + ["identifier","outlined"], + ["text"," "], + ["paren.lparen","("], + ["identifier","solid"], + ["text"," "], + ["identifier","grey"], + ["paren.rparen",")"], + ["text"," "], + ["paren.lparen","("], + ["identifier","ngon"], + ["text"," "], + ["constant.numeric","12"], + ["text"," "], + ["constant.numeric","110"], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["operator.punctuation",","], + ["text"," "], + ["identifier","hand"], + ["text"," "], + ["identifier","orange"], + ["text"," "], + ["constant.numeric","100"], + ["text"," "], + ["identifier","t"] +],[ + "start", + ["text"," "], + ["operator.punctuation",","], + ["text"," "], + ["identifier","hand"], + ["text"," "], + ["identifier","charcoal"], + ["text"," "], + ["constant.numeric","100"], + ["text"," "], + ["paren.lparen","("], + ["identifier","t"], + ["keyword.operator","/"], + ["constant.numeric","60"], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["operator.punctuation",","], + ["text"," "], + ["identifier","hand"], + ["text"," "], + ["identifier","charcoal"], + ["text"," "], + ["constant.numeric","60"], + ["text"," "], + ["paren.lparen","("], + ["identifier","t"], + ["keyword.operator","/"], + ["constant.numeric","720"], + ["paren.rparen",")"], + ["text"," "], + ["paren.rparen","]"] +],[ + "start" +],[ + "start", + ["constant.language","hand"], + ["text"," "], + ["identifier","clr"], + ["text"," "], + ["identifier","len"], + ["text"," "], + ["identifier","time"], + ["text"," "], + ["keyword","="] +],[ + "start", + ["text"," "], + ["keyword","let"], + ["text"," "], + ["identifier","angle"], + ["text"," "], + ["keyword","="], + ["text"," "], + ["identifier","degrees"], + ["text"," "], + ["paren.lparen","("], + ["constant.numeric","90"], + ["text"," "], + ["keyword.operator","-"], + ["text"," "], + ["constant.numeric","6"], + ["text"," "], + ["keyword.operator","*"], + ["text"," "], + ["identifier","inSeconds"], + ["text"," "], + ["identifier","time"], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["keyword","in"], + ["text"," "], + ["identifier","traced"], + ["text"," "], + ["paren.lparen","("], + ["identifier","solid"], + ["text"," "], + ["identifier","clr"], + ["paren.rparen",")"], + ["text"," "], + ["keyword.operator","<|"], + ["text"," "], + ["identifier","segment"], + ["text"," "], + ["paren.lparen","("], + ["constant.numeric","0"], + ["operator.punctuation",","], + ["constant.numeric","0"], + ["paren.rparen",")"], + ["text"," "], + ["paren.lparen","("], + ["identifier","len"], + ["text"," "], + ["keyword.operator","*"], + ["text"," "], + ["identifier","cos"], + ["text"," "], + ["identifier","angle"], + ["operator.punctuation",","], + ["text"," "], + ["identifier","len"], + ["text"," "], + ["keyword.operator","*"], + ["text"," "], + ["identifier","sin"], + ["text"," "], + ["identifier","angle"], + ["paren.rparen",")"] +]] \ No newline at end of file diff --git a/lib/ace/mode/_test/tokens_ftl.json b/lib/ace/mode/_test/tokens_ftl.json index 19773674..75e7a6f1 100644 --- a/lib/ace/mode/_test/tokens_ftl.json +++ b/lib/ace/mode/_test/tokens_ftl.json @@ -28,13 +28,13 @@ ["text"," "], ["keyword","/>"] ],[ - "comment", + "ftl-dcomment", ["comment","<#--"] ],[ - "comment", + "ftl-dcomment", ["comment"," FreeMarker comment"] ],[ - "comment", + "ftl-dcomment", ["comment"," ${abc} <#assign a=12 />"] ],[ "start", @@ -43,106 +43,110 @@ "start" ],[ "start", - ["xml-pe",""] + ["xml-pe.doctype.xml",""] ],[ "start", - ["meta.tag","<"], - ["meta.tag.tag-name","html"], - ["text"," "], - ["entity.other.attribute-name","lang"], - ["keyword.operator","="], - ["string","\"en-us\""], - ["meta.tag.r",">"] + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","html"], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","lang"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"en-us\""], + ["meta.tag.punctuation.tag-close.xml",">"] ],[ "start", - ["text"," "], - ["meta.tag","<"], - ["meta.tag.tag-name","head"], - ["meta.tag.r",">"] + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","head"], + ["meta.tag.punctuation.tag-close.xml",">"] ],[ "start", - ["text"," "], - ["meta.tag","<"], - ["meta.tag.tag-name","meta"], - ["text"," "], - ["entity.other.attribute-name","charset"], - ["keyword.operator","="], - ["string","\"utf-8\""], - ["text"," "], - ["meta.tag.r","/>"] + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","meta"], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","charset"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"utf-8\""], + ["text.tag-whitespace.xml"," "], + ["meta.tag.punctuation.tag-close.xml","/>"] ],[ "start", - ["text"," "] + ["text.xml"," "] ],[ "start", - ["text"," "], - ["meta.tag","<"], - ["meta.tag.tag-name","title"], - ["meta.tag.r",">"], + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","title"], + ["meta.tag.punctuation.tag-close.xml",">"], ["string.interpolated","${"], ["variable","title"], ["keyword.operator","!"], ["string","\"FreeMarker\""], ["string.interpolated","}"], - ["meta.tag","<"], - ["meta.tag.tag-name","title"], - ["meta.tag.r",">"] + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","title"], + ["meta.tag.punctuation.tag-close.xml",">"] ],[ "start", - ["text"," "], - ["meta.tag",""] + ["text.xml"," "], + ["meta.tag.punctuation.end-tag-open.xml",""] ],[ "start", - ["text"," "] + ["text.xml"," "] ],[ "start", - ["text"," "], - ["meta.tag","<"], - ["meta.tag.tag-name","body"], - ["meta.tag.r",">"] + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","body"], + ["meta.tag.punctuation.tag-close.xml",">"] ],[ "start", - ["text"," "] + ["text.xml"," "] ],[ "start", - ["text"," "], - ["meta.tag","<"], - ["meta.tag.tag-name","h1"], - ["meta.tag.r",">"], - ["text","Hello "], + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","h1"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["text.xml","Hello "], ["string.interpolated","${"], ["variable","name"], ["keyword.operator","!"], ["string","\"\""], ["string.interpolated","}"], - ["meta.tag",""] + ["meta.tag.punctuation.end-tag-open.xml",""] ],[ "start", - ["text"," "] + ["text.xml"," "] ],[ "start", - ["text"," "], - ["meta.tag","<"], - ["meta.tag.tag-name","p"], - ["meta.tag.r",">"], - ["text","Today is: "], + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","p"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["text.xml","Today is: "], ["string.interpolated","${"], ["language.variable",".now"], ["support.function","?date"], ["string.interpolated","}"], - ["meta.tag",""] + ["meta.tag.punctuation.end-tag-open.xml",""] ],[ "start", - ["text"," "] + ["text.xml"," "] ],[ "start", - ["text"," "], + ["text.xml"," "], ["keyword.function","<#assign"], ["text"," "], ["variable","x"], @@ -153,7 +157,7 @@ ["keyword",">"] ],[ "start", - ["text"," "], + ["text.xml"," "], ["keyword.function","<#if"], ["text"," "], ["variable","x"], @@ -170,7 +174,7 @@ ["text"," "], ["constant.numeric","14"], ["keyword",">"], - ["text","x equals 13: "], + ["text.xml","x equals 13: "], ["string.interpolated","${"], ["variable","x"], ["string.interpolated","}"], @@ -178,16 +182,16 @@ ["keyword",">"] ],[ "start", - ["text"," "] + ["text.xml"," "] ],[ "start", - ["text"," "], - ["meta.tag","<"], - ["meta.tag.tag-name","ul"], - ["meta.tag.r",">"] + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","ul"], + ["meta.tag.punctuation.tag-close.xml",">"] ],[ "start", - ["text"," "], + ["text.xml"," "], ["keyword.function","<#list"], ["text"," "], ["variable","items"], @@ -198,14 +202,14 @@ ["keyword",">"] ],[ "start", - ["text"," "], - ["meta.tag","<"], - ["meta.tag.tag-name","li"], - ["meta.tag.r",">"], + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","li"], + ["meta.tag.punctuation.tag-close.xml",">"], ["string.interpolated","${"], ["variable","item_index"], ["string.interpolated","}"], - ["text",": "], + ["text.xml",": "], ["string.interpolated","${"], ["variable","item.name"], ["keyword.operator","!"], @@ -219,26 +223,26 @@ ["constant.numeric","0"], ["paren.rparen","]"], ["string.interpolated","}"], - ["meta.tag",""] + ["meta.tag.punctuation.end-tag-open.xml",""] ],[ "start", - ["text"," "], + ["text.xml"," "], ["keyword.function",""] ],[ "start", - ["text"," "], - ["meta.tag",""] + ["text.xml"," "], + ["meta.tag.punctuation.end-tag-open.xml",""] ],[ "start", - ["text"," "] + ["text.xml"," "] ],[ "start", - ["text"," User directive: "], + ["text.xml"," User directive: "], ["keyword.other","<@lib.function"], ["text"," "], ["variable","attr1"], @@ -253,21 +257,21 @@ ["keyword.operator","="], ["constant.numeric","-42.12"], ["keyword",">"], - ["text","Test"], + ["text.xml","Test"], ["keyword.other",""] ],[ "start", - ["text"," "], + ["text.xml"," "], ["keyword.other","<@anotherOne"], ["text"," "], ["keyword","/>"] ],[ "start", - ["text"," "] + ["text.xml"," "] ],[ "start", - ["text"," "], + ["text.xml"," "], ["keyword.function","<#if"], ["text"," "], ["variable","variable"], @@ -275,10 +279,10 @@ ["keyword",">"] ],[ "start", - ["text"," Deprecated"] + ["text.xml"," Deprecated"] ],[ "start", - ["text"," "], + ["text.xml"," "], ["keyword.function","<#elseif"], ["text"," "], ["variable","variable"], @@ -286,52 +290,52 @@ ["keyword",">"] ],[ "start", - ["text"," Better"] + ["text.xml"," Better"] ],[ "start", - ["text"," "], + ["text.xml"," "], ["keyword.function","<#else"], ["keyword",">"] ],[ "start", - ["text"," Default"] + ["text.xml"," Default"] ],[ "start", - ["text"," "], + ["text.xml"," "], ["keyword.function",""] ],[ "start", - ["text"," "] + ["text.xml"," "] ],[ "start", - ["text"," "], - ["meta.tag","<"], - ["meta.tag.tag-name.image","img"], - ["text"," "], - ["entity.other.attribute-name","src"], - ["keyword.operator","="], - ["string","\"images/"], + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.image.tag-name.xml","img"], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","src"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"images/"], ["string.interpolated","${"], ["variable","user.id"], ["string.interpolated","}"], - ["string",".png\""], - ["text"," "], - ["meta.tag.r","/>"] + ["string.attribute-value.xml",".png\""], + ["text.tag-whitespace.xml"," "], + ["meta.tag.punctuation.tag-close.xml","/>"] ],[ "start", - ["text"," "] + ["text.xml"," "] ],[ "start", - ["text"," "], - ["meta.tag",""] + ["text.xml"," "], + ["meta.tag.punctuation.end-tag-open.xml",""] ],[ "start", - ["meta.tag",""] + ["meta.tag.punctuation.end-tag-open.xml",""] ],[ "start" ]] \ No newline at end of file diff --git a/lib/ace/mode/_test/tokens_gcode.json b/lib/ace/mode/_test/tokens_gcode.json new file mode 100644 index 00000000..d6227473 --- /dev/null +++ b/lib/ace/mode/_test/tokens_gcode.json @@ -0,0 +1,296 @@ +[[ + "start", + ["identifier","O"], + ["constant.numeric","003"], + ["text"," "], + ["comment","(DIAMOND SQUARE)"] +],[ + "start", + ["comment","N2"], + ["text"," "], + ["string","G54"], + ["text"," "], + ["string","G90"], + ["text"," "], + ["string","G49"], + ["text"," "], + ["string","G80"] +],[ + "start", + ["comment","N3"], + ["text"," "], + ["string","M6"], + ["text"," "], + ["identifier","T"], + ["constant.numeric","1"], + ["text"," "], + ["comment","(1.ENDMILL)"] +],[ + "start", + ["comment","N4"], + ["text"," "], + ["string","M3"], + ["text"," "], + ["identifier","S"], + ["constant.numeric","1800"] +],[ + "start", + ["comment","N5"], + ["text"," "], + ["string","G0"], + ["text"," "], + ["identifier","X"], + ["constant.numeric","-.6"], + ["text"," "], + ["identifier","Y"], + ["constant.numeric","2.050"] +],[ + "start", + ["comment","N6"], + ["text"," "], + ["string","G43"], + ["text"," "], + ["identifier","H"], + ["constant.numeric","1"], + ["text"," "], + ["identifier","Z"], + ["constant.numeric",".1"] +],[ + "start", + ["comment","N7"], + ["text"," "], + ["string","G1"], + ["text"," "], + ["identifier","Z"], + ["constant.numeric","-.3"], + ["text"," "], + ["identifier","F"], + ["constant.numeric","50."] +],[ + "start", + ["comment","N8"], + ["text"," "], + ["string","G41"], + ["text"," "], + ["identifier","D"], + ["constant.numeric","1"], + ["text"," "], + ["identifier","Y"], + ["constant.numeric","1.45"] +],[ + "start", + ["comment","N9"], + ["text"," "], + ["string","G1"], + ["text"," "], + ["identifier","X"], + ["constant.numeric","0"], + ["text"," "], + ["identifier","F"], + ["constant.numeric","20."] +],[ + "start", + ["comment","N10"], + ["text"," "], + ["string","G2"], + ["text"," "], + ["identifier","J"], + ["constant.numeric","-1.45"] +],[ + "start", + ["comment","(CUTTER COMP CANCEL)"] +],[ + "start", + ["comment","N11"], + ["text"," "], + ["string","G1"], + ["text"," "], + ["identifier","Z"], + ["constant.numeric","-.2"], + ["text"," "], + ["identifier","F"], + ["constant.numeric","50."] +],[ + "start", + ["comment","N12"], + ["text"," "], + ["identifier","Y"], + ["constant.numeric","-.990"] +],[ + "start", + ["comment","N13"], + ["text"," "], + ["string","G40"] +],[ + "start", + ["comment","N14"], + ["text"," "], + ["string","G0"], + ["text"," "], + ["identifier","X"], + ["constant.numeric","-.6"], + ["text"," "], + ["identifier","Y"], + ["constant.numeric","1.590"] +],[ + "start", + ["comment","N15"], + ["text"," "], + ["string","G0"], + ["text"," "], + ["identifier","Z"], + ["constant.numeric",".1"] +],[ + "start", + ["comment","N16"], + ["text"," "], + ["string","M5"], + ["text"," "], + ["string","G49"], + ["text"," "], + ["string","G28"], + ["text"," "], + ["string","G91"], + ["text"," "], + ["identifier","Z"], + ["constant.numeric","0"] +],[ + "start", + ["comment","N17"], + ["text"," "], + ["identifier","CALL"], + ["text"," "], + ["identifier","O"], + ["constant.numeric","9456"] +],[ + "start", + ["comment","N18"], + ["text"," #"], + ["constant.numeric","500"], + ["text","="], + ["constant.numeric","0.004"] +],[ + "start", + ["comment","N19"], + ["text"," #"], + ["constant.numeric","503"], + ["text","="], + ["paren.lparen","["], + ["text","#"], + ["constant.numeric","500"], + ["text","+#"], + ["constant.numeric","501"], + ["paren.rparen","]"] +],[ + "start", + ["comment","N20"], + ["text"," "], + ["identifier","VC"], + ["constant.numeric","45"], + ["text","="], + ["constant.numeric","0.0006"] +],[ + "start", + ["identifier","VS"], + ["constant.numeric","4"], + ["text","="], + ["constant.numeric","0.0007"] +],[ + "start", + ["comment","N21"], + ["text"," "], + ["string","G90"], + ["text"," "], + ["string","G10"], + ["text"," "], + ["identifier","L"], + ["constant.numeric","20"], + ["text"," "], + ["identifier","P"], + ["constant.numeric","3"], + ["text"," "], + ["identifier","X"], + ["constant.numeric","5."], + ["identifier","Y"], + ["constant.numeric","4."], + ["text"," "], + ["identifier","Z"], + ["constant.numeric","6.567"] +],[ + "start", + ["comment","N22"], + ["text"," "], + ["string","G0"], + ["text"," "], + ["identifier","X"], + ["constant.numeric","5000"] +],[ + "start", + ["comment","N23"], + ["text"," "], + ["identifier","IF"], + ["text"," "], + ["paren.lparen","["], + ["text","#"], + ["constant.numeric","1"], + ["text"," "], + ["identifier","LT"], + ["text"," "], + ["constant.numeric","0.370"], + ["paren.rparen","]"], + ["text"," "], + ["identifier","GOTO"], + ["text"," "], + ["constant.numeric","49"] +],[ + "start", + ["comment","N24"], + ["text"," "], + ["identifier","X"], + ["constant.numeric","-0.678"], + ["text"," "], + ["identifier","Y"], + ["constant.numeric","+.990"] +],[ + "start", + ["comment","N25"], + ["text"," "], + ["string","G84.3"], + ["text"," "], + ["identifier","X"], + ["constant.numeric","-0.1"] +],[ + "start", + ["comment","N26"], + ["text"," #"], + ["constant.numeric","4"], + ["text","=#"], + ["constant.numeric","5"], + ["text","*"], + ["identifier","COS"], + ["paren.lparen","["], + ["constant.numeric","45"], + ["paren.rparen","]"] +],[ + "start", + ["comment","N27"], + ["text"," #"], + ["constant.numeric","4"], + ["text","=#"], + ["constant.numeric","5"], + ["text","*"], + ["identifier","SIN"], + ["paren.lparen","["], + ["constant.numeric","45"], + ["paren.rparen","]"] +],[ + "start", + ["comment","N28"], + ["text"," "], + ["identifier","VZOFZ"], + ["text","="], + ["constant.numeric","652.9658"] +],[ + "start", + ["text","%"] +]] \ No newline at end of file diff --git a/lib/ace/mode/_test/tokens_gherkin.json b/lib/ace/mode/_test/tokens_gherkin.json new file mode 100644 index 00000000..173d9798 --- /dev/null +++ b/lib/ace/mode/_test/tokens_gherkin.json @@ -0,0 +1,142 @@ +[[ + "start", + ["comment","@these"], + ["text"," "], + ["comment","@are"], + ["text"," "], + ["comment","@tags"] +],[ + "start", + ["keyword","Feature:"], + ["text"," Serve coffee"] +],[ + "start", + ["text"," Coffee should not be served until paid for"] +],[ + "start", + ["text"," Coffee should not be served until the button has been pressed"] +],[ + "start", + ["text"," If there is no coffee left then money should be refunded"] +],[ + "start", + ["text"," "] +],[ + "start", + ["text"," "], + ["keyword","Scenario Outline:"], + ["text"," Eating"] +],[ + "start", + ["text"," "], + ["keyword","Given"], + ["text"," there are "], + ["comment",""], + ["text"," cucumbers"] +],[ + "start", + ["text"," "], + ["keyword","When"], + ["text"," I eat "], + ["comment",""], + ["text"," cucumbers"] +],[ + "start", + ["text"," "], + ["keyword","Then"], + ["text"," I should have "], + ["comment",""], + ["text"," cucumbers"] +],[ + "start" +],[ + "start", + ["text"," "], + ["keyword","Examples:"] +],[ + "start", + ["text"," "], + ["comment","|"], + ["string"," start "], + ["comment","|"], + ["string"," eat "], + ["comment","|"], + ["string"," left "], + ["comment","|"] +],[ + "start", + ["text"," "], + ["comment","|"], + ["string"," 12 "], + ["comment","|"], + ["string"," 5 "], + ["comment","|"], + ["string"," 7 "], + ["comment","|"] +],[ + "start", + ["text"," "], + ["comment","|"], + ["string"," 20 "], + ["comment","|"], + ["string"," 5 "], + ["comment","|"], + ["string"," 15 "], + ["comment","|"], + ["string"," "] +],[ + "start" +],[ + "start", + ["text"," "], + ["keyword","Scenario:"], + ["text"," Buy last coffee"] +],[ + "start", + ["text"," "], + ["keyword","Given"], + ["text"," there are "], + ["constant.numeric","1"], + ["text"," coffees left in the machine"] +],[ + "start", + ["text"," "], + ["keyword","And"], + ["text"," I have deposited "], + ["constant.numeric","1"], + ["text","$ "] +],[ + "start", + ["text"," "], + ["keyword","When"], + ["text"," I press the coffee button"] +],[ + "start", + ["text"," "], + ["keyword","Then"], + ["text"," I should be served a "], + ["string","\"coffee\""] +],[ + "start", + ["text"," "] +],[ + "start", + ["text"," "], + ["comment","# this a comment"] +],[ + "start", + ["text"," "] +],[ + "qqstring3", + ["text"," "], + ["string","\"\"\""] +],[ + "qqstring3", + ["string"," this is a "] +],[ + "qqstring3", + ["string"," pystring"] +],[ + "start", + ["string"," \"\"\""] +]] \ No newline at end of file diff --git a/lib/ace/mode/_test/tokens_gitignore.json b/lib/ace/mode/_test/tokens_gitignore.json new file mode 100644 index 00000000..8689a724 --- /dev/null +++ b/lib/ace/mode/_test/tokens_gitignore.json @@ -0,0 +1,33 @@ +[[ + "start", + ["comment","# A sample .gitignore file."] +],[ + "start" +],[ + "start", + ["text",".buildlog"] +],[ + "start", + ["text",".DS_Store"] +],[ + "start", + ["text",".svn"] +],[ + "start" +],[ + "start", + ["comment","# Negated patterns:"] +],[ + "start", + ["keyword","!foo.bar"] +],[ + "start" +],[ + "start", + ["comment","# Also ignore user settings..."] +],[ + "start", + ["text","/.settings"] +],[ + "start" +]] \ No newline at end of file diff --git a/lib/ace/mode/_test/tokens_golang.json b/lib/ace/mode/_test/tokens_golang.json index 4257369b..070c0a17 100644 --- a/lib/ace/mode/_test/tokens_golang.json +++ b/lib/ace/mode/_test/tokens_golang.json @@ -80,10 +80,10 @@ ["paren.lparen","("], ["identifier","n"], ["text"," "], - ["identifier","int"], + ["support.type","int"], ["paren.rparen",")"], ["text"," "], - ["identifier","float64"], + ["support.type","float64"], ["text"," "], ["paren.lparen","{"] ],[ @@ -94,11 +94,11 @@ ["punctuation.operator",":"], ["keyword.operator","="], ["text"," "], - ["identifier","make"], + ["support.function","make"], ["paren.lparen","("], ["keyword","chan"], ["text"," "], - ["identifier","float64"], + ["support.type","float64"], ["paren.rparen",")"] ],[ "start", @@ -134,7 +134,7 @@ ["identifier","ch"], ["punctuation.operator",","], ["text"," "], - ["identifier","float64"], + ["support.type","float64"], ["paren.lparen","("], ["identifier","k"], ["paren.rparen","))"] @@ -209,12 +209,12 @@ ["text"," "], ["keyword","chan"], ["text"," "], - ["identifier","float64"], + ["support.type","float64"], ["punctuation.operator",","], ["text"," "], ["identifier","k"], ["text"," "], - ["identifier","float64"], + ["support.type","float64"], ["paren.rparen",")"], ["text"," "], ["paren.lparen","{"] diff --git a/lib/ace/mode/_test/tokens_handlebars.json b/lib/ace/mode/_test/tokens_handlebars.json new file mode 100644 index 00000000..1ec79139 --- /dev/null +++ b/lib/ace/mode/_test/tokens_handlebars.json @@ -0,0 +1,81 @@ +[[ + "start", + ["comment.start","{{!--"], + ["comment"," Ace + :-}} "], + ["comment.end","--}}"] +],[ + "start" +],[ + "start", + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","div"], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","id"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"comments\""], + ["meta.tag.punctuation.tag-close.xml",">"] +],[ + "start", + ["text.xml"," "], + ["storage.type.start","{{#"], + ["variable.parameter","each"], + ["text"," "], + ["variable.parameter","comments"], + ["storage.type.end","}}"] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","h2"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.anchor.tag-name.xml","a"], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","href"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"/posts/"], + ["storage.type.start","{{"], + ["text","../"], + ["variable.parameter","permalink"], + ["storage.type.end","}}"], + ["string.attribute-value.xml","#"], + ["storage.type.start","{{"], + ["variable.parameter","id"], + ["storage.type.end","}}"], + ["string.attribute-value.xml","\""], + ["meta.tag.punctuation.tag-close.xml",">"], + ["storage.type.start","{{"], + ["variable.parameter","title"], + ["storage.type.end","}}"], + ["meta.tag.punctuation.end-tag-open.xml",""], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","div"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["support.function","{{{"], + ["variable.parameter","body"], + ["support.function","}}}"], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["text.xml"," "], + ["storage.type.start","{{/"], + ["variable.parameter","each"], + ["storage.type.end","}}"] +],[ + "start", + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start" +]] \ No newline at end of file diff --git a/lib/ace/mode/_test/tokens_html.json b/lib/ace/mode/_test/tokens_html.json index 726c704f..c5f75eff 100644 --- a/lib/ace/mode/_test/tokens_html.json +++ b/lib/ace/mode/_test/tokens_html.json @@ -1,51 +1,63 @@ [[ "start", - ["meta.tag","<"], - ["meta.tag.tag-name","html"], - ["meta.tag.r",">"] + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","html"], + ["meta.tag.punctuation.tag-close.xml",">"] ],[ "start", - ["meta.tag","<"], - ["meta.tag.tag-name.script","script"], - ["text"," "], - ["entity.other.attribute-name","a"], - ["keyword.operator","="], - ["string","'a'"], - ["meta.tag.r",">"], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","scripts"], + ["meta.tag.punctuation.tag-close.xml",">"] +],[ + "start", + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.script.tag-name.xml","script"], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","a"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","'a'"], + ["meta.tag.punctuation.tag-close.xml",">"], ["storage.type","var"], - ["meta.tag",""], - ["text","'123'"] -],[ - "tag_qqstring", - ["meta.tag","<"], - ["meta.tag.tag-name.anchor","a"], ["text"," "], - ["entity.other.attribute-name","href"], - ["keyword.operator","="], - ["string","\"abc"] + ["string","\""], + ["meta.tag.punctuation.end-tag-open.xml",""], + ["text.xml","'123'"] ],[ "start", - ["string"," def\""], - ["meta.tag.r",">"] + ["meta.tag.punctuation.end-tag-open.xml",""] ],[ - "tag_qstring", - ["meta.tag","<"], - ["meta.tag.tag-name.anchor","a"], - ["text"," "], - ["entity.other.attribute-name","href"], - ["keyword.operator","="], - ["string","'abc"] + ["string.attribute-value.xml0","tag_stuff"], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.anchor.tag-name.xml","a"], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","href"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"abc"] ],[ "start", - ["string","def\\'"], - ["meta.tag.r",">"] + ["string.attribute-value.xml"," def\""], + ["meta.tag.punctuation.tag-close.xml",">"] +],[ + ["string.attribute-value.xml","tag_stuff"], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.anchor.tag-name.xml","a"], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","href"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","'abc"] +],[ + "start", + ["string.attribute-value.xml","def\\'"], + ["meta.tag.punctuation.tag-close.xml",">"] ],[ "start" ],[ "start", - ["meta.tag",""] + ["meta.tag.punctuation.end-tag-open.xml",""] ]] \ No newline at end of file diff --git a/lib/ace/mode/_test/tokens_html_ruby.json b/lib/ace/mode/_test/tokens_html_ruby.json new file mode 100644 index 00000000..8ff5f6ea --- /dev/null +++ b/lib/ace/mode/_test/tokens_html_ruby.json @@ -0,0 +1,257 @@ +[[ + "start", + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","h1"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["text.xml","Listing Books"], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["text.xml"," "] +],[ + "start", + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.table.tag-name.xml","table"], + ["meta.tag.punctuation.tag-close.xml",">"] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.table.tag-name.xml","tr"], + ["meta.tag.punctuation.tag-close.xml",">"] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.table.tag-name.xml","th"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["text.xml","Title"], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.table.tag-name.xml","th"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["text.xml","Summary"], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.table.tag-name.xml","th"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.table.tag-name.xml","th"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.table.tag-name.xml","th"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["text.xml"," "] +],[ + "start", + ["support.ruby_tag","<%"], + ["text"," "], + ["variable.instance","@books"], + ["text","."], + ["identifier","each"], + ["text"," "], + ["keyword","do"], + ["text"," |"], + ["identifier","book"], + ["text","| "], + ["support.ruby_tag","%>"] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.table.tag-name.xml","tr"], + ["meta.tag.punctuation.tag-close.xml",">"] +],[ + "start", + ["text.xml"," "], + ["comment.start.erb","<%#"], + ["comment"," comment "], + ["comment.end.erb","%>"] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.table.tag-name.xml","td"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["support.ruby_tag","<%="], + ["text"," "], + ["identifier","book"], + ["text","."], + ["identifier","title"], + ["text"," "], + ["support.ruby_tag","%>"], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.table.tag-name.xml","td"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["support.ruby_tag","<%="], + ["text"," "], + ["identifier","book"], + ["text","."], + ["identifier","content"], + ["text"," "], + ["support.ruby_tag","%>"], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.table.tag-name.xml","td"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["support.ruby_tag","<%="], + ["text"," "], + ["support.function","link_to"], + ["text"," "], + ["string.start","'"], + ["string","Show"], + ["string.end","'"], + ["text",", "], + ["identifier","book"], + ["text"," "], + ["support.ruby_tag","%>"], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.table.tag-name.xml","td"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["support.ruby_tag","<%="], + ["text"," "], + ["support.function","link_to"], + ["text"," "], + ["string.start","'"], + ["string","Edit"], + ["string.end","'"], + ["text",", "], + ["identifier","edit_book_path"], + ["paren.lparen","("], + ["identifier","book"], + ["paren.rparen",")"], + ["text"," "], + ["support.ruby_tag","%>"], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.table.tag-name.xml","td"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["support.ruby_tag","<%="], + ["text"," "], + ["support.function","link_to"], + ["text"," "], + ["string.start","'"], + ["string","Remove"], + ["string.end","'"], + ["text",", "], + ["identifier","book"], + ["text",", "], + ["constant.other.symbol.ruby",":confirm"], + ["text"," "], + ["punctuation.separator.key-value","=>"], + ["text"," "], + ["string.start","'"], + ["string","Are you sure?"], + ["string.end","'"], + ["text",", "], + ["constant.other.symbol.ruby",":method"], + ["text"," "], + ["punctuation.separator.key-value","=>"], + ["text"," "], + ["constant.other.symbol.ruby",":delete"], + ["text"," "], + ["support.ruby_tag","%>"], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["support.ruby_tag","<%"], + ["text"," "], + ["keyword","end"], + ["text"," "], + ["support.ruby_tag","%>"] +],[ + "start", + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["text.xml"," "] +],[ + "start", + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","br"], + ["text.tag-whitespace.xml"," "], + ["meta.tag.punctuation.tag-close.xml","/>"] +],[ + "start", + ["text.xml"," "] +],[ + "start", + ["support.ruby_tag","<%="], + ["text"," "], + ["support.function","link_to"], + ["text"," "], + ["string.start","'"], + ["string","New book"], + ["string.end","'"], + ["text",", "], + ["identifier","new_book_path"], + ["text"," "], + ["support.ruby_tag","%>"] +]] \ No newline at end of file diff --git a/lib/ace/mode/_test/tokens_ini.json b/lib/ace/mode/_test/tokens_ini.json new file mode 100644 index 00000000..11d28017 --- /dev/null +++ b/lib/ace/mode/_test/tokens_ini.json @@ -0,0 +1,23 @@ +[[ + "start", + ["punctuation.definition.entity.ini","["], + ["constant.section.group-title.ini",".ShellClassInfo"], + ["punctuation.definition.entity.ini","]"] +],[ + "start", + ["keyword.other.definition.ini","IconResource"], + ["punctuation.separator.key-value.ini","="], + ["text","..\\logo.png"] +],[ + "start", + ["punctuation.definition.entity.ini","["], + ["constant.section.group-title.ini","ViewState"], + ["punctuation.definition.entity.ini","]"] +],[ + "start", + ["keyword.other.definition.ini","FolderType"], + ["punctuation.separator.key-value.ini","="], + ["text","Generic"] +],[ + "start" +]] \ No newline at end of file diff --git a/lib/ace/mode/_test/tokens_io.json b/lib/ace/mode/_test/tokens_io.json new file mode 100644 index 00000000..b83a675a --- /dev/null +++ b/lib/ace/mode/_test/tokens_io.json @@ -0,0 +1,49 @@ +[[ + "start", + ["punctuation.definition.comment.io","//"], + ["comment.line.double-slash.io"," computes factorial of a number"] +],[ + "start", + ["text","factorial "], + ["keyword.operator.io",":="], + ["text"," "], + ["support.function.io","method"], + ["text","(n,"] +],[ + "start", + ["text"," "], + ["keyword.control.io","if"], + ["text","(n "], + ["keyword.operator.io","=="], + ["text"," "], + ["constant.numeric.io","0"], + ["text",", "], + ["keyword.control.io","return"], + ["text"," "], + ["constant.numeric.io","1"], + ["text",")"] +],[ + "start", + ["text"," res "], + ["keyword.operator.io",":="], + ["text"," "], + ["constant.numeric.io","1"] +],[ + "start", + ["text"," "], + ["support.class.io","Range"], + ["text"," "], + ["constant.numeric.io","1"], + ["text"," "], + ["support.function.io","to"], + ["text","(n) "], + ["keyword.control.io","foreach"], + ["text","(i, res "], + ["keyword.operator.io","="], + ["text"," res "], + ["keyword.operator.io","*"], + ["text"," i)"] +],[ + "start", + ["text",")"] +]] \ No newline at end of file diff --git a/lib/ace/mode/_test/tokens_jack.json b/lib/ace/mode/_test/tokens_jack.json new file mode 100644 index 00000000..c3d694dd --- /dev/null +++ b/lib/ace/mode/_test/tokens_jack.json @@ -0,0 +1,1786 @@ +[[ + "start", + ["keyword","vars"], + ["text"," "], + ["variable","it"], + ["text",", "], + ["variable","p"] +],[ + "start" +],[ + "start", + ["variable","p"], + ["text"," = "], + ["paren.lparen","{"], + ["variable","label"], + ["text",", "], + ["variable","value"], + ["text","|"] +],[ + "start", + ["text"," "], + ["language.builtin","print"], + ["paren.lparen","("], + ["string","\""], + ["constant.language.escape","\\n"], + ["string","\""], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["variable","label"], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["language.builtin","print"], + ["paren.lparen","("], + ["language.builtin","inspect"], + ["paren.lparen","("], + ["variable","value"], + ["paren.rparen","))"] +],[ + "start", + ["paren.rparen","}"] +],[ + "start", + ["comment","-- Create an array from 0 to 15"] +],[ + "start", + ["variable","p"], + ["paren.lparen","("], + ["string","\"range\""], + ["text",", "], + ["language.builtin","i-collect"], + ["paren.lparen","("], + ["language.builtin","range"], + ["paren.lparen","("], + ["constant.numeric","5"], + ["paren.rparen",")))"] +],[ + "start" +],[ + "start", + ["comment","-- Create an array from 0 to 15 and break up in chunks of 4"] +],[ + "start", + ["variable","p"], + ["paren.lparen","("], + ["string","\"chunked range\""], + ["text",", "], + ["language.builtin","i-collect"], + ["paren.lparen","("], + ["language.builtin","i-chunk"], + ["paren.lparen","("], + ["constant.numeric","4"], + ["text",", "], + ["language.builtin","range"], + ["paren.lparen","("], + ["constant.numeric","16"], + ["paren.rparen","))))"] +],[ + "start" +],[ + "start", + ["comment","-- Check if all or none items in stream pass test."] +],[ + "start", + ["variable","p"], + ["paren.lparen","("], + ["string","\"all < 60 in range(60)\""], + ["text",", "], + ["variable","i-all?"], + ["paren.lparen","({"], + ["variable","i"], + ["text","|"], + ["variable","i"], + ["keyword.operator","<"], + ["constant.numeric","60"], + ["paren.rparen","}"], + ["text",", "], + ["language.builtin","range"], + ["paren.lparen","("], + ["constant.numeric","60"], + ["paren.rparen",")))"] +],[ + "start", + ["variable","p"], + ["paren.lparen","("], + ["string","\"any < 60 in range(60)\""], + ["text",", "], + ["variable","i-any?"], + ["paren.lparen","({"], + ["variable","i"], + ["text","|"], + ["variable","i"], + ["keyword.operator",">"], + ["constant.numeric","60"], + ["paren.rparen","}"], + ["text",", "], + ["language.builtin","range"], + ["paren.lparen","("], + ["constant.numeric","60"], + ["paren.rparen",")))"] +],[ + "start", + ["variable","p"], + ["paren.lparen","("], + ["string","\"all < 60 in range(70)\""], + ["text",", "], + ["variable","i-all?"], + ["paren.lparen","({"], + ["variable","i"], + ["text","|"], + ["variable","i"], + ["keyword.operator","<"], + ["constant.numeric","60"], + ["paren.rparen","}"], + ["text",", "], + ["language.builtin","range"], + ["paren.lparen","("], + ["constant.numeric","70"], + ["paren.rparen",")))"] +],[ + "start", + ["variable","p"], + ["paren.lparen","("], + ["string","\"any < 60 in range(70)\""], + ["text",", "], + ["variable","i-any?"], + ["paren.lparen","({"], + ["variable","i"], + ["text","|"], + ["variable","i"], + ["keyword.operator",">"], + ["constant.numeric","60"], + ["paren.rparen","}"], + ["text",", "], + ["language.builtin","range"], + ["paren.lparen","("], + ["constant.numeric","70"], + ["paren.rparen",")))"] +],[ + "start" +],[ + "start", + ["comment","-- Zip three different collections together"] +],[ + "start", + ["variable","p"], + ["paren.lparen","("], + ["string","\"zipped\""], + ["text",", "], + ["language.builtin","i-collect"], + ["paren.lparen","("], + ["language.builtin","i-zip"], + ["paren.lparen","("] +],[ + "start", + ["text"," "], + ["language.builtin","range"], + ["paren.lparen","("], + ["constant.numeric","10"], + ["paren.rparen",")"], + ["text",","] +],[ + "start", + ["text"," "], + ["paren.lparen","["], + ["constant.numeric","1"], + ["text",","], + ["constant.numeric","2"], + ["text",","], + ["constant.numeric","3"], + ["text",","], + ["constant.numeric","4"], + ["text",","], + ["constant.numeric","5"], + ["paren.rparen","]"], + ["text",","] +],[ + "start", + ["text"," "], + ["language.builtin","i-map"], + ["paren.lparen","({"], + ["variable","i"], + ["text","|"], + ["variable","i"], + ["keyword.operator","*"], + ["variable","i"], + ["paren.rparen","}"], + ["text",", "], + ["language.builtin","range"], + ["paren.lparen","("], + ["constant.numeric","10"], + ["paren.rparen","))"] +],[ + "start", + ["paren.rparen",")))"] +],[ + "start" +],[ + "start", + ["keyword","vars"], + ["text"," "], + ["variable","names"], + ["text",", "], + ["variable","person"], + ["text",", "], + ["variable","i"], + ["text",", "], + ["variable","doubles"], + ["text",", "], + ["variable","lengths"], + ["text",", "], + ["variable","cubeRange"] +],[ + "start", + ["variable","names"], + ["text"," = "], + ["paren.lparen","["], + ["string","\"Thorin\""], + ["text",", "], + ["string","\"Dwalin\""], + ["text",", "], + ["string","\"Balin\""], + ["text",", "], + ["string","\"Bifur\""], + ["text",", "], + ["string","\"Bofur\""], + ["text",", "], + ["string","\"Bombur\""], + ["text",", "], + ["string","\"Oin\""], + ["text",","] +],[ + "start", + ["text"," "], + ["string","\"Gloin\""], + ["text",", "], + ["string","\"Ori\""], + ["text",", "], + ["string","\"Nori\""], + ["text",", "], + ["string","\"Dori\""], + ["text",", "], + ["string","\"Fili\""], + ["text",", "], + ["string","\"Kili\""], + ["text",", "], + ["string","\"Bilbo\""], + ["text",", "], + ["string","\"Gandalf\""], + ["paren.rparen","]"] +],[ + "start" +],[ + "start", + ["keyword","for"], + ["text"," "], + ["variable","name"], + ["text"," "], + ["keyword","in"], + ["text"," "], + ["variable","names"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["keyword","if"], + ["text"," "], + ["variable","name"], + ["text"," "], + ["keyword.operator","!="], + ["text"," "], + ["string","\"Bilbo\""], + ["text"," "], + ["keyword.operator","&&"], + ["text"," "], + ["variable","name"], + ["text"," "], + ["keyword.operator","!="], + ["text"," "], + ["string","\"Gandalf\""], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["language.builtin","print"], + ["paren.lparen","("], + ["variable","name"], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start", + ["paren.rparen","}"] +],[ + "start" +],[ + "start", + ["variable","person"], + ["text"," = "], + ["paren.lparen","{"], + ["variable","name"], + ["text",": "], + ["string","\"Tim\""], + ["text",", "], + ["variable","age"], + ["text",": "], + ["constant.numeric","30"], + ["paren.rparen","}"] +],[ + "start", + ["keyword","for"], + ["text"," "], + ["variable","key"], + ["text",", "], + ["variable","value"], + ["text"," "], + ["keyword","in"], + ["text"," "], + ["variable","person"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["language.builtin","print"], + ["paren.lparen","("], + ["variable","key"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["string","\" = \""], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["variable","value"], + ["paren.rparen",")"] +],[ + "start", + ["paren.rparen","}"] +],[ + "start" +],[ + "start", + ["variable","i"], + ["text"," = "], + ["constant.numeric","0"] +],[ + "start", + ["keyword","while"], + ["text"," "], + ["variable","i"], + ["text"," "], + ["keyword.operator","<"], + ["text"," "], + ["constant.numeric","10"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["variable","i"], + ["text"," = "], + ["variable","i"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["constant.numeric","1"] +],[ + "start", + ["text"," "], + ["language.builtin","print"], + ["paren.lparen","("], + ["variable","i"], + ["paren.rparen",")"] +],[ + "start", + ["paren.rparen","}"] +],[ + "start" +],[ + "start", + ["language.builtin","print"], + ["paren.lparen","("], + ["string","\"range\""], + ["paren.rparen",")"] +],[ + "start", + ["keyword","for"], + ["text"," "], + ["variable","i"], + ["text"," "], + ["keyword","in"], + ["text"," "], + ["language.builtin","range"], + ["paren.lparen","("], + ["constant.numeric","10"], + ["paren.rparen",")"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["language.builtin","print"], + ["paren.lparen","("], + ["variable","i"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["constant.numeric","1"], + ["paren.rparen",")"] +],[ + "start", + ["paren.rparen","}"] +],[ + "start", + ["keyword","for"], + ["text"," "], + ["variable","i"], + ["text"," "], + ["keyword","in"], + ["text"," "], + ["language.builtin","range"], + ["paren.lparen","("], + ["constant.numeric","10"], + ["paren.rparen",")"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["language.builtin","print"], + ["paren.lparen","("], + ["constant.numeric","10"], + ["text"," "], + ["keyword.operator","-"], + ["text"," "], + ["variable","i"], + ["paren.rparen",")"] +],[ + "start", + ["paren.rparen","}"] +],[ + "start" +],[ + "start", + ["comment","-- Dynamic object that gives the first 10 doubles"] +],[ + "start", + ["variable","doubles"], + ["text"," = "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["storage.form","@len"], + ["text",": "], + ["paren.lparen","{"], + ["text","| "], + ["constant.numeric","10"], + ["text"," "], + ["paren.rparen","}"] +],[ + "start", + ["text"," "], + ["storage.form","@get"], + ["text",": "], + ["paren.lparen","{"], + ["variable","key"], + ["text","|"] +],[ + "start", + ["text"," "], + ["keyword","if"], + ["text"," "], + ["variable","key"], + ["text"," "], + ["keyword","is"], + ["text"," "], + ["storage.type","Integer"], + ["text"," "], + ["paren.lparen","{"], + ["text"," "], + ["variable","key"], + ["text"," "], + ["keyword.operator","*"], + ["text"," "], + ["variable","key"], + ["text"," "], + ["paren.rparen","}"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start", + ["paren.rparen","}"] +],[ + "start", + ["language.builtin","print"], + ["paren.lparen","("], + ["string","\"#doubles\""], + ["text",", "], + ["keyword.operator","#"], + ["variable","doubles"], + ["paren.rparen",")"] +],[ + "start" +],[ + "start", + ["language.builtin","print"], + ["paren.lparen","("], + ["string","\"Doubles\""], + ["paren.rparen",")"] +],[ + "start", + ["keyword","for"], + ["text"," "], + ["variable","k"], + ["text",", "], + ["variable","v"], + ["text"," "], + ["keyword","in"], + ["text"," "], + ["variable","doubles"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["language.builtin","print"], + ["paren.lparen","(["], + ["variable","k"], + ["text",", "], + ["variable","v"], + ["paren.rparen","])"] +],[ + "start", + ["paren.rparen","}"] +],[ + "start" +],[ + "start", + ["comment","-- Dynamic object that has names list as keys and string lenth as values"] +],[ + "start", + ["variable","lengths"], + ["text"," = "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["storage.form","@keys"], + ["text",": "], + ["paren.lparen","{"], + ["text","| "], + ["variable","names"], + ["text"," "], + ["paren.rparen","}"] +],[ + "start", + ["text"," "], + ["storage.form","@get"], + ["text",": "], + ["paren.lparen","{"], + ["variable","key"], + ["text","|"] +],[ + "start", + ["text"," "], + ["keyword","if"], + ["text"," "], + ["variable","key"], + ["text"," "], + ["keyword","is"], + ["text"," "], + ["storage.type","String"], + ["text"," "], + ["paren.lparen","{"], + ["text"," "], + ["keyword.operator","#"], + ["variable","key"], + ["text"," "], + ["paren.rparen","}"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start", + ["paren.rparen","}"] +],[ + "start" +],[ + "start", + ["language.builtin","print"], + ["text"," "], + ["paren.lparen","("], + ["string","\"Lengths\""], + ["paren.rparen",")"] +],[ + "start", + ["keyword","for"], + ["text"," "], + ["variable","k"], + ["text",", "], + ["variable","v"], + ["text"," "], + ["keyword","in"], + ["text"," "], + ["variable","lengths"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["language.builtin","print"], + ["paren.lparen","(["], + ["variable","k"], + ["text",", "], + ["variable","v"], + ["paren.rparen","])"] +],[ + "start", + ["paren.rparen","}"] +],[ + "start" +],[ + "start" +],[ + "start", + ["variable","cubeRange"], + ["text"," = "], + ["paren.lparen","{"], + ["variable","n"], + ["text","|"] +],[ + "start", + ["text"," "], + ["keyword","vars"], + ["text"," "], + ["variable","i"], + ["text",", "], + ["variable","v"] +],[ + "start", + ["text"," "], + ["variable","i"], + ["text"," = "], + ["constant.numeric","0"] +],[ + "start", + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["storage.form","@call"], + ["text",": "], + ["paren.lparen","{"], + ["text","|"] +],[ + "start", + ["text"," "], + ["variable","v"], + ["text"," = "], + ["variable","i"] +],[ + "start", + ["text"," "], + ["variable","i"], + ["text"," = "], + ["variable","i"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["constant.numeric","1"] +],[ + "start", + ["text"," "], + ["keyword","if"], + ["text"," "], + ["variable","v"], + ["text"," "], + ["keyword.operator","<"], + ["text"," "], + ["variable","n"], + ["text"," "], + ["paren.lparen","{"], + ["text"," "], + ["variable","v"], + ["text"," "], + ["keyword.operator","*"], + ["text"," "], + ["variable","v"], + ["text"," "], + ["keyword.operator","*"], + ["text"," "], + ["variable","v"], + ["text"," "], + ["paren.rparen","}"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start", + ["paren.rparen","}"] +],[ + "start" +],[ + "start", + ["language.builtin","print"], + ["paren.lparen","("], + ["string","\"Cubes\""], + ["paren.rparen",")"] +],[ + "start", + ["keyword","for"], + ["text"," "], + ["variable","k"], + ["text",", "], + ["variable","v"], + ["text"," "], + ["keyword","in"], + ["text"," "], + ["variable","cubeRange"], + ["paren.lparen","("], + ["constant.numeric","5"], + ["paren.rparen",")"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["language.builtin","print"], + ["paren.lparen","(["], + ["variable","k"], + ["text",", "], + ["variable","v"], + ["paren.rparen","])"] +],[ + "start", + ["paren.rparen","}"] +],[ + "start", + ["language.builtin","print"], + ["paren.lparen","("], + ["string","\"String\""], + ["paren.rparen",")"] +],[ + "start", + ["keyword","for"], + ["text"," "], + ["variable","k"], + ["text",", "], + ["variable","v"], + ["text"," "], + ["keyword","in"], + ["text"," "], + ["string","\"Hello World\""], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["language.builtin","print"], + ["paren.lparen","(["], + ["variable","k"], + ["text",", "], + ["variable","v"], + ["paren.rparen","])"] +],[ + "start", + ["paren.rparen","}"] +],[ + "start" +],[ + "start" +],[ + "start", + ["language.builtin","print"], + ["paren.lparen","(["], + ["variable","i"], + ["text"," "], + ["keyword","for"], + ["text"," "], + ["variable","i"], + ["text"," "], + ["keyword","in"], + ["text"," "], + ["language.builtin","range"], + ["paren.lparen","("], + ["constant.numeric","10"], + ["paren.rparen",")])"] +],[ + "start", + ["language.builtin","print"], + ["paren.lparen","(["], + ["variable","i"], + ["text"," "], + ["keyword","for"], + ["text"," "], + ["variable","i"], + ["text"," "], + ["keyword","in"], + ["text"," "], + ["language.builtin","range"], + ["paren.lparen","("], + ["constant.numeric","20"], + ["paren.rparen",")"], + ["text"," "], + ["keyword","if"], + ["text"," "], + ["variable","i"], + ["text"," "], + ["keyword.operator","%"], + ["text"," "], + ["constant.numeric","3"], + ["paren.rparen","])"] +],[ + "start" +],[ + "start" +],[ + "start" +],[ + "start", + ["comment","-- Example showing how to do parallel work using split..and"] +],[ + "start", + ["variable","base"], + ["text"," = "], + ["paren.lparen","{"], + ["variable","bootstrap"], + ["text",", "], + ["variable","target-dir"], + ["text","|"] +],[ + "start", + ["text"," "], + ["keyword","split"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["variable","copy"], + ["paren.lparen","("], + ["string","\"res\""], + ["text",", "], + ["variable","target-dir"], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"], + ["text"," "], + ["keyword","and"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["keyword","if"], + ["text"," "], + ["variable","newer"], + ["paren.lparen","("], + ["string","\"src/*.less\""], + ["text",", "], + ["variable","target-dir"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["string","\"/style.css\""], + ["paren.rparen",")"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["variable","lessc"], + ["paren.lparen","("], + ["string","\"src/\""], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["variable","bootstrap"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["string","\".less\""], + ["text",", "], + ["variable","target-dir"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["string","\"/style.css\""], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"], + ["text"," "], + ["keyword","and"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["variable","build"], + ["paren.lparen","("], + ["string","\"src/\""], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["variable","bootstrap"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["string","\".js\""], + ["text",", "], + ["variable","target-dir"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["string","\"/app.js\""], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start", + ["paren.rparen","}"] +],[ + "start" +],[ + "start" +],[ + "start", + ["keyword","vars"], + ["text"," "], + ["variable","Dragon"], + ["text",", "], + ["variable","pet"] +],[ + "start" +],[ + "start", + ["variable","Dragon"], + ["text"," = "], + ["paren.lparen","{"], + ["variable","name"], + ["text","|"] +],[ + "start", + ["text"," "], + ["keyword","vars"], + ["text"," "], + ["variable","asleep"], + ["text",", "], + ["variable","stuff-in-belly"], + ["text",", "], + ["variable","stuff-in-intestine"], + ["text",","] +],[ + "start", + ["text"," "], + ["variable","feed"], + ["text",", "], + ["variable","walk"], + ["text",", "], + ["variable","put-to-bed"], + ["text",", "], + ["variable","toss"], + ["text",", "], + ["variable","rock"], + ["text",","] +],[ + "start", + ["text"," "], + ["variable","hungry?"], + ["text",", "], + ["variable","poopy?"], + ["text",", "], + ["variable","passage-of-time"] +],[ + "start" +],[ + "start", + ["text"," "], + ["variable","asleep"], + ["text"," = "], + ["constant.language.boolean","false"] +],[ + "start", + ["text"," "], + ["variable","stuff-in-belly"], + ["text"," = "], + ["constant.numeric","10"], + ["text"," "], + ["comment","-- He's full."] +],[ + "start", + ["text"," "], + ["variable","stuff-in-intestine"], + ["text"," = "], + ["constant.numeric","0"], + ["text"," "], + ["comment","-- He doesn't need to go."] +],[ + "start" +],[ + "start", + ["text"," "], + ["language.builtin","print"], + ["paren.lparen","("], + ["variable","name"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["string","' is born.'"], + ["paren.rparen",")"] +],[ + "start" +],[ + "start", + ["text"," "], + ["variable","feed"], + ["text"," = "], + ["paren.lparen","{"], + ["text","|"] +],[ + "start", + ["text"," "], + ["language.builtin","print"], + ["paren.lparen","("], + ["string","'You feed '"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["variable","name"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["string","'.'"], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["variable","stuff-in-belly"], + ["text"," = "], + ["constant.numeric","10"] +],[ + "start", + ["text"," "], + ["variable","passage-of-time"], + ["paren.lparen","("], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start" +],[ + "start", + ["text"," "], + ["variable","walk"], + ["text"," = "], + ["paren.lparen","{"], + ["text","|"] +],[ + "start", + ["text"," "], + ["language.builtin","print"], + ["paren.lparen","("], + ["string","'You walk '"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["variable","name"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["string","\".\""], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["variable","stuff-in-intestine"], + ["text"," = "], + ["constant.numeric","0"] +],[ + "start", + ["text"," "], + ["variable","passage-of-time"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start" +],[ + "start", + ["text"," "], + ["variable","put-to-bed"], + ["text"," = "], + ["paren.lparen","{"], + ["text","|"] +],[ + "start", + ["text"," "], + ["language.builtin","print"], + ["paren.lparen","("], + ["string","'You put '"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["variable","name"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["string","' to bed.'"], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["variable","asleep"], + ["text"," = "], + ["constant.language.boolean","true"] +],[ + "start", + ["text"," "], + ["keyword","for"], + ["text"," "], + ["variable","i"], + ["text"," "], + ["keyword","in"], + ["text"," "], + ["language.builtin","range"], + ["paren.lparen","("], + ["constant.numeric","3"], + ["paren.rparen",")"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["keyword","if"], + ["text"," "], + ["variable","asleep"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["variable","passage-of-time"], + ["paren.lparen","("], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start", + ["text"," "], + ["keyword","if"], + ["text"," "], + ["variable","asleep"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["language.builtin","print"], + ["paren.lparen","("], + ["variable","name"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["string","' snores, filling the room with smoke.'"], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start", + ["text"," "], + ["keyword","if"], + ["text"," "], + ["variable","asleep"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["variable","asleep"], + ["text"," = "], + ["constant.language.boolean","false"] +],[ + "start", + ["text"," "], + ["language.builtin","print"], + ["paren.lparen","("], + ["variable","name"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["string","' wakes up slowly.'"], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start" +],[ + "start", + ["text"," "], + ["variable","toss"], + ["text"," = "], + ["paren.lparen","{"], + ["text","|"] +],[ + "start", + ["text"," "], + ["language.builtin","print"], + ["paren.lparen","("], + ["string","'You toss '"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["variable","name"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["string","' up into the air.'"], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["language.builtin","print"], + ["paren.lparen","("], + ["string","'He giggles, which singes your eyebrows.'"], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["variable","passage-of-time"], + ["paren.lparen","("], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start" +],[ + "start", + ["text"," "], + ["variable","rock"], + ["text"," = "], + ["paren.lparen","{"], + ["text","|"] +],[ + "start", + ["text"," "], + ["language.builtin","print"], + ["paren.lparen","("], + ["string","'You rock '"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["variable","name"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["string","' gently.'"], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["variable","asleep"], + ["text"," = "], + ["constant.language.boolean","true"] +],[ + "start", + ["text"," "], + ["language.builtin","print"], + ["paren.lparen","("], + ["string","'He briefly dozes off...'"], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["variable","passage-of-time"], + ["paren.lparen","("], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["keyword","if"], + ["text"," "], + ["variable","asleep"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["variable","asleep"], + ["text"," = "], + ["constant.language.boolean","false"] +],[ + "start", + ["text"," "], + ["language.builtin","print"], + ["paren.lparen","("], + ["string","'...but wakes when you stop.'"], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start" +],[ + "start", + ["text"," "], + ["variable","hungry?"], + ["text"," = "], + ["paren.lparen","{"], + ["text","|"] +],[ + "start", + ["text"," "], + ["variable","stuff-in-belly"], + ["text"," "], + ["keyword.operator","<="], + ["text"," "], + ["constant.numeric","2"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start" +],[ + "start", + ["text"," "], + ["variable","poopy?"], + ["text"," = "], + ["paren.lparen","{"], + ["text","|"] +],[ + "start", + ["text"," "], + ["variable","stuff-in-intestine"], + ["text"," "], + ["keyword.operator",">="], + ["text"," "], + ["constant.numeric","8"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start" +],[ + "start", + ["text"," "], + ["variable","passage-of-time"], + ["text"," = "], + ["paren.lparen","{"], + ["text","|"] +],[ + "start", + ["text"," "], + ["keyword","if"], + ["text"," "], + ["variable","stuff-in-belly"], + ["text"," "], + ["keyword.operator",">"], + ["text"," "], + ["constant.numeric","0"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["comment","-- Move food from belly to intestine"] +],[ + "start", + ["text"," "], + ["variable","stuff-in-belly"], + ["text"," = "], + ["variable","stuff-in-belly"], + ["text"," "], + ["keyword.operator","-"], + ["text"," "], + ["constant.numeric","1"] +],[ + "start", + ["text"," "], + ["variable","stuff-in-intestine"], + ["text"," = "], + ["variable","stuff-in-intestine"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["constant.numeric","1"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"], + ["text"," "], + ["keyword","else"], + ["text"," "], + ["paren.lparen","{"], + ["text"," "], + ["comment","-- Our dragon is starving!"] +],[ + "start", + ["text"," "], + ["keyword","if"], + ["text"," "], + ["variable","asleep"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["variable","asleep"], + ["text"," = "], + ["constant.language.boolean","false"] +],[ + "start", + ["text"," "], + ["language.builtin","print"], + ["paren.lparen","("], + ["string","'He wakes up suddenly!'"], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start", + ["text"," "], + ["language.builtin","print"], + ["paren.lparen","("], + ["variable","name"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["string","' is starving! In desperation, he ate YOU!'"], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["keyword","abort"], + ["text"," "], + ["string","\"died\""] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start" +],[ + "start", + ["text"," "], + ["keyword","if"], + ["text"," "], + ["variable","stuff-in-intestine"], + ["text"," "], + ["keyword.operator",">="], + ["text"," "], + ["constant.numeric","10"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["variable","stuff-in-intestine"], + ["text"," = "], + ["constant.numeric","0"] +],[ + "start", + ["text"," "], + ["language.builtin","print"], + ["paren.lparen","("], + ["string","'Whoops! '"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["variable","name"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["string","' had an accident...'"], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start" +],[ + "start", + ["text"," "], + ["keyword","if"], + ["text"," "], + ["variable","hungry?"], + ["paren.lparen","("], + ["paren.rparen",")"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["keyword","if"], + ["text"," "], + ["variable","asleep"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["variable","asleep"], + ["text"," = "], + ["constant.language.boolean","false"] +],[ + "start", + ["text"," "], + ["language.builtin","print"], + ["paren.lparen","("], + ["string","'He wakes up suddenly!'"], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start", + ["text"," "], + ["language.builtin","print"], + ["paren.lparen","("], + ["variable","name"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["string","\"'s stomach grumbles...\""], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start" +],[ + "start", + ["text"," "], + ["keyword","if"], + ["text"," "], + ["variable","poopy?"], + ["paren.lparen","("], + ["paren.rparen",")"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["keyword","if"], + ["text"," "], + ["variable","asleep"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["variable","asleep"], + ["text"," = "], + ["constant.language.boolean","false"] +],[ + "start", + ["text"," "], + ["language.builtin","print"], + ["paren.lparen","("], + ["string","'He wakes up suddenly!'"], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start", + ["text"," "], + ["language.builtin","print"], + ["paren.lparen","("], + ["variable","name"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["string","' does the potty dance...'"], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start" +],[ + "start", + ["text"," "], + ["comment","-- Export the public interface to this closure object."] +],[ + "start", + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text"," "], + ["variable","feed"], + ["text",": "], + ["variable","feed"] +],[ + "start", + ["text"," "], + ["variable","walk"], + ["text",": "], + ["variable","walk"] +],[ + "start", + ["text"," "], + ["variable","put-to-bed"], + ["text",": "], + ["variable","put-to-bed"] +],[ + "start", + ["text"," "], + ["variable","toss"], + ["text",": "], + ["variable","toss"] +],[ + "start", + ["text"," "], + ["variable","rock"], + ["text",": "], + ["variable","rock"] +],[ + "start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start" +],[ + "start", + ["paren.rparen","}"] +],[ + "start" +],[ + "start", + ["variable","pet"], + ["text"," = "], + ["variable","Dragon"], + ["paren.lparen","("], + ["string","'Norbert'"], + ["paren.rparen",")"] +],[ + "start", + ["variable","pet"], + ["text","."], + ["variable","feed"], + ["paren.lparen","("], + ["paren.rparen",")"] +],[ + "start", + ["variable","pet"], + ["text","."], + ["variable","toss"], + ["paren.lparen","("], + ["paren.rparen",")"] +],[ + "start", + ["variable","pet"], + ["text","."], + ["variable","walk"], + ["paren.lparen","("], + ["paren.rparen",")"] +],[ + "start", + ["variable","pet"], + ["text","."], + ["variable","put-to-bed"], + ["paren.lparen","("], + ["paren.rparen",")"] +],[ + "start", + ["variable","pet"], + ["text","."], + ["variable","rock"], + ["paren.lparen","("], + ["paren.rparen",")"] +],[ + "start", + ["variable","pet"], + ["text","."], + ["variable","put-to-bed"], + ["paren.lparen","("], + ["paren.rparen",")"] +],[ + "start", + ["variable","pet"], + ["text","."], + ["variable","put-to-bed"], + ["paren.lparen","("], + ["paren.rparen",")"] +],[ + "start", + ["variable","pet"], + ["text","."], + ["variable","put-to-bed"], + ["paren.lparen","("], + ["paren.rparen",")"] +],[ + "start", + ["variable","pet"], + ["text","."], + ["variable","put-to-bed"], + ["paren.lparen","("], + ["paren.rparen",")"] +],[ + "start" +]] \ No newline at end of file diff --git a/lib/ace/mode/_test/tokens_javascript.json b/lib/ace/mode/_test/tokens_javascript.json index 5044f21e..1be3f605 100644 --- a/lib/ace/mode/_test/tokens_javascript.json +++ b/lib/ace/mode/_test/tokens_javascript.json @@ -96,7 +96,8 @@ ["text"," "], ["string.regexp","/2 "], ["constant.language.escape","+"], - ["string.regexp"," 1/b"] + ["string.regexp"," 1/gimyx"], + ["identifier","k"] ],[ "no_regex", ["identifier","a"], @@ -287,9 +288,9 @@ ["string.regexp.charachterclass","r"], ["constant.language.escape","-"], ["string.regexp.charachterclass","o"], - ["regexp.keyword.operator","\\f\\f"], + ["regexp.charclass.keyword.operator","\\f\\f"], ["string.regexp.charachterclass","["], - ["regexp.keyword.operator","\\f"], + ["regexp.charclass.keyword.operator","\\f"], ["constant.language.escape","]?"], ["string.regexp","r"], ["invalid","{7}+"], @@ -378,7 +379,7 @@ ["constant.numeric","1."], ["text","00"], ["identifier","E"], - ["text","^"], + ["keyword.operator","^"], ["constant.numeric","1"], ["punctuation.operator",","], ["text"," "], diff --git a/lib/ace/mode/_test/tokens_jsoniq.json b/lib/ace/mode/_test/tokens_jsoniq.json new file mode 100644 index 00000000..0f4ee6e9 --- /dev/null +++ b/lib/ace/mode/_test/tokens_jsoniq.json @@ -0,0 +1,4 @@ +[[ + "[\"start\"]", + ["support.function","TODO"] +]] \ No newline at end of file diff --git a/lib/ace/mode/_test/tokens_jsp.json b/lib/ace/mode/_test/tokens_jsp.json index b57e5d12..25d3af4d 100644 --- a/lib/ace/mode/_test/tokens_jsp.json +++ b/lib/ace/mode/_test/tokens_jsp.json @@ -1,19 +1,19 @@ [[ "start", - ["meta.tag","<"], - ["meta.tag.tag-name","html"], - ["meta.tag.r",">"] + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","html"], + ["meta.tag.punctuation.tag-close.xml",">"] ],[ "start", - ["meta.tag","<"], - ["meta.tag.tag-name","body"], - ["meta.tag.r",">"] + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","body"], + ["meta.tag.punctuation.tag-close.xml",">"] ],[ "js-start", - ["text"," "], - ["meta.tag","<"], - ["meta.tag.tag-name.script","script"], - ["meta.tag.r",">"] + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.script.tag-name.xml","script"], + ["meta.tag.punctuation.tag-close.xml",">"] ],[ "js-start", ["text"," "], @@ -40,23 +40,23 @@ ],[ "start", ["text"," "], - ["meta.tag",""] + ["meta.tag.punctuation.end-tag-open.xml",""] ],[ "css-start", - ["text"," "], - ["meta.tag","<"], - ["meta.tag.tag-name.style","style"], - ["meta.tag.r",">"] + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.style.tag-name.xml","style"], + ["meta.tag.punctuation.tag-close.xml",">"] ],[ - "css-ruleset", + ["css-ruleset","css-start"], ["text"," "], ["variable",".class"], ["text"," "], ["paren.lparen","{"] ],[ - "css-ruleset", + ["css-ruleset","css-start"], ["text"," "], ["support.type","background"], ["text",": "], @@ -69,20 +69,20 @@ ],[ "start", ["text"," "], - ["meta.tag",""] + ["meta.tag.punctuation.end-tag-open.xml",""] ],[ "start" ],[ "start", - ["text"," "], - ["meta.tag","<"], - ["meta.tag.tag-name","p"], - ["meta.tag.r",">"] + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","p"], + ["meta.tag.punctuation.tag-close.xml",">"] ],[ "start", - ["text"," Today's date: "], + ["text.xml"," Today's date: "], ["meta.tag","<%"], ["keyword.operator","="], ["text"," "], @@ -103,13 +103,13 @@ ["meta.tag","%>"] ],[ "start", - ["text"," "], - ["meta.tag",""] + ["text.xml"," "], + ["meta.tag.punctuation.end-tag-open.xml",""] ],[ "start", - ["text"," "], + ["text.xml"," "], ["meta.tag","<%"], ["keyword.operator","!"], ["text"," "], @@ -124,7 +124,7 @@ ["meta.tag","%>"] ],[ "jsp-start", - ["text"," "], + ["text.xml"," "], ["meta.tag",""] ],[ "jsp-start", @@ -145,11 +145,11 @@ "start" ],[ "start", - ["text"," "], + ["text.xml"," "], ["comment","<%-- This is JSP comment --%>"] ],[ "start", - ["text"," "], + ["text.xml"," "], ["meta.tag","<%@"], ["text"," "], ["identifier","directive"], @@ -163,161 +163,161 @@ "start" ],[ "start", - ["text"," "], - ["meta.tag","<"], - ["meta.tag.tag-name","h2"], - ["meta.tag.r",">"], - ["text","Select Languages:"], - ["meta.tag",""] + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","h2"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["text.xml","Select Languages:"], + ["meta.tag.punctuation.end-tag-open.xml",""] ],[ "start" ],[ "start", - ["text"," "], - ["meta.tag","<"], - ["meta.tag.tag-name.form","form"], - ["text"," "], - ["entity.other.attribute-name","ACTION"], - ["keyword.operator","="], - ["string","\"jspCheckBox.jsp\""], - ["meta.tag.r",">"] + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.form.tag-name.xml","form"], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","ACTION"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"jspCheckBox.jsp\""], + ["meta.tag.punctuation.tag-close.xml",">"] ],[ "start", - ["text"," "], - ["meta.tag","<"], - ["meta.tag.tag-name.form","input"], - ["text"," "], - ["entity.other.attribute-name","type"], - ["keyword.operator","="], - ["string","\"checkbox\""], - ["text"," "], - ["entity.other.attribute-name","name"], - ["keyword.operator","="], - ["string","\"id\""], - ["text"," "], - ["entity.other.attribute-name","value"], - ["keyword.operator","="], - ["string","\"Java\""], - ["meta.tag.r",">"], - ["text"," Java"], - ["meta.tag","<"], - ["meta.tag.tag-name","BR"], - ["meta.tag.r",">"] + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.form.tag-name.xml","input"], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","type"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"checkbox\""], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","name"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"id\""], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","value"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"Java\""], + ["meta.tag.punctuation.tag-close.xml",">"], + ["text.xml"," Java"], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","BR"], + ["meta.tag.punctuation.tag-close.xml",">"] ],[ "start", - ["text"," "], - ["meta.tag","<"], - ["meta.tag.tag-name.form","input"], - ["text"," "], - ["entity.other.attribute-name","type"], - ["keyword.operator","="], - ["string","\"checkbox\""], - ["text"," "], - ["entity.other.attribute-name","name"], - ["keyword.operator","="], - ["string","\"id\""], - ["text"," "], - ["entity.other.attribute-name","value"], - ["keyword.operator","="], - ["string","\".NET\""], - ["meta.tag.r",">"], - ["text"," .NET"], - ["meta.tag","<"], - ["meta.tag.tag-name","BR"], - ["meta.tag.r",">"] + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.form.tag-name.xml","input"], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","type"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"checkbox\""], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","name"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"id\""], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","value"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\".NET\""], + ["meta.tag.punctuation.tag-close.xml",">"], + ["text.xml"," .NET"], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","BR"], + ["meta.tag.punctuation.tag-close.xml",">"] ],[ "start", - ["text"," "], - ["meta.tag","<"], - ["meta.tag.tag-name.form","input"], - ["text"," "], - ["entity.other.attribute-name","type"], - ["keyword.operator","="], - ["string","\"checkbox\""], - ["text"," "], - ["entity.other.attribute-name","name"], - ["keyword.operator","="], - ["string","\"id\""], - ["text"," "], - ["entity.other.attribute-name","value"], - ["keyword.operator","="], - ["string","\"PHP\""], - ["meta.tag.r",">"], - ["text"," PHP"], - ["meta.tag","<"], - ["meta.tag.tag-name","BR"], - ["meta.tag.r",">"] + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.form.tag-name.xml","input"], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","type"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"checkbox\""], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","name"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"id\""], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","value"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"PHP\""], + ["meta.tag.punctuation.tag-close.xml",">"], + ["text.xml"," PHP"], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","BR"], + ["meta.tag.punctuation.tag-close.xml",">"] ],[ "start", - ["text"," "], - ["meta.tag","<"], - ["meta.tag.tag-name.form","input"], - ["text"," "], - ["entity.other.attribute-name","type"], - ["keyword.operator","="], - ["string","\"checkbox\""], - ["text"," "], - ["entity.other.attribute-name","name"], - ["keyword.operator","="], - ["string","\"id\""], - ["text"," "], - ["entity.other.attribute-name","value"], - ["keyword.operator","="], - ["string","\"C/C++\""], - ["meta.tag.r",">"], - ["text"," C/C++"], - ["meta.tag","<"], - ["meta.tag.tag-name","BR"], - ["meta.tag.r",">"] + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.form.tag-name.xml","input"], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","type"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"checkbox\""], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","name"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"id\""], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","value"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"C/C++\""], + ["meta.tag.punctuation.tag-close.xml",">"], + ["text.xml"," C/C++"], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","BR"], + ["meta.tag.punctuation.tag-close.xml",">"] ],[ "start", - ["text"," "], - ["meta.tag","<"], - ["meta.tag.tag-name.form","input"], - ["text"," "], - ["entity.other.attribute-name","type"], - ["keyword.operator","="], - ["string","\"checkbox\""], - ["text"," "], - ["entity.other.attribute-name","name"], - ["keyword.operator","="], - ["string","\"id\""], - ["text"," "], - ["entity.other.attribute-name","value"], - ["keyword.operator","="], - ["string","\"PERL\""], - ["meta.tag.r",">"], - ["text"," PERL "], - ["meta.tag","<"], - ["meta.tag.tag-name","BR"], - ["meta.tag.r",">"] + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.form.tag-name.xml","input"], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","type"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"checkbox\""], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","name"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"id\""], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","value"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"PERL\""], + ["meta.tag.punctuation.tag-close.xml",">"], + ["text.xml"," PERL "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","BR"], + ["meta.tag.punctuation.tag-close.xml",">"] ],[ "start", - ["text"," "], - ["meta.tag","<"], - ["meta.tag.tag-name.form","input"], - ["text"," "], - ["entity.other.attribute-name","type"], - ["keyword.operator","="], - ["string","\"submit\""], - ["text"," "], - ["entity.other.attribute-name","value"], - ["keyword.operator","="], - ["string","\"Submit\""], - ["meta.tag.r",">"] + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.form.tag-name.xml","input"], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","type"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"submit\""], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","value"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"Submit\""], + ["meta.tag.punctuation.tag-close.xml",">"] ],[ "start", - ["text"," "], - ["meta.tag",""] + ["text.xml"," "], + ["meta.tag.punctuation.end-tag-open.xml",""] ],[ "start" ],[ "jsp-start", - ["text"," "], + ["text.xml"," "], ["meta.tag","<%"] ],[ "jsp-start", @@ -424,12 +424,12 @@ ["meta.tag","%>"] ],[ "start", - ["meta.tag",""] + ["meta.tag.punctuation.end-tag-open.xml",""] ],[ "start", - ["meta.tag",""] + ["meta.tag.punctuation.end-tag-open.xml",""] ]] \ No newline at end of file diff --git a/lib/ace/mode/_test/tokens_julia.json b/lib/ace/mode/_test/tokens_julia.json index f4ce4eab..5aaef6f9 100644 --- a/lib/ace/mode/_test/tokens_julia.json +++ b/lib/ace/mode/_test/tokens_julia.json @@ -38,7 +38,13 @@ ],[ "start" ],[ - "start" + "start", + ["text","v "], + ["keyword.operator.update.julia","="], + ["text"," "], + ["variable","α"], + ["keyword.operator.transposed-variable.julia","'"], + ["text",";"] ],[ "start", ["keyword.other.julia","function"], diff --git a/lib/ace/mode/_test/tokens_latex.json b/lib/ace/mode/_test/tokens_latex.json index 0ac37725..52508e0d 100644 --- a/lib/ace/mode/_test/tokens_latex.json +++ b/lib/ace/mode/_test/tokens_latex.json @@ -2,37 +2,37 @@ "start", ["keyword","\\usepackage"], ["lparen","{"], - ["text","amsmath"], + ["storage.type","amsmath"], ["rparen","}"] ],[ "start", - ["keyword","\\title"], + ["storage.type","\\title"], ["lparen","{"], - ["keyword","\\LaTeX"], + ["storage.type","\\LaTeX"], ["rparen","}"] ],[ "start", - ["keyword","\\date"], + ["storage.type","\\date"], ["lparen","{"], ["rparen","}"] ],[ "start", - ["keyword","\\begin"], + ["storage.type","\\begin"], ["lparen","{"], - ["text","document"], + ["variable.parameter","document"], ["rparen","}"] ],[ "start", ["text"," "], - ["keyword","\\maketitle"] + ["storage.type","\\maketitle"] ],[ "start", ["text"," "], - ["keyword","\\LaTeX"], + ["storage.type","\\LaTeX"], ["lparen","{"], ["rparen","}"], ["text"," is a document preparation system for the "], - ["keyword","\\TeX"], + ["storage.type","\\TeX"], ["lparen","{"], ["rparen","}"] ],[ @@ -50,26 +50,26 @@ ],[ "start", ["text"," and much more. "], - ["keyword","\\LaTeX"], + ["storage.type","\\LaTeX"], ["lparen","{"], ["rparen","}"], ["text"," was originally written in 1984 by Leslie"] ],[ "start", ["text"," Lamport and has become the dominant method for using "], - ["keyword","\\TeX"], + ["storage.type","\\TeX"], ["text","; few"] ],[ "start", ["text"," people write in plain "], - ["keyword","\\TeX"], + ["storage.type","\\TeX"], ["lparen","{"], ["rparen","}"], ["text"," anymore. The current version is"] ],[ "start", ["text"," "], - ["keyword","\\LaTeXe"], + ["storage.type","\\LaTeXe"], ["text","."] ],[ "start", @@ -85,26 +85,26 @@ ],[ "start", ["text"," "], - ["keyword","\\begin"], + ["storage.type","\\begin"], ["lparen","{"], - ["text","align"], + ["variable.parameter","align"], ["rparen","}"] ],[ "start", ["text"," E &= mc^2 "], - ["keyword","\\\\"] + ["constant.character.escape","\\\\"] ],[ "start", ["text"," m &= "], - ["keyword","\\frac"], + ["storage.type","\\frac"], ["lparen","{"], ["text","m_0"], ["rparen","}"], ["lparen","{"], - ["keyword","\\sqrt"], + ["storage.type","\\sqrt"], ["lparen","{"], ["text","1-"], - ["keyword","\\frac"], + ["storage.type","\\frac"], ["lparen","{"], ["text","v^2"], ["rparen","}"], @@ -114,14 +114,14 @@ ],[ "start", ["text"," "], - ["keyword","\\end"], + ["storage.type","\\end"], ["lparen","{"], - ["text","align"], + ["variable.parameter","align"], ["rparen","}"] ],[ "start", - ["keyword","\\end"], + ["storage.type","\\end"], ["lparen","{"], - ["text","document"], + ["variable.parameter","document"], ["rparen","}"] ]] \ No newline at end of file diff --git a/lib/ace/mode/_test/tokens_liquid.json b/lib/ace/mode/_test/tokens_liquid.json index c218b08e..30d003cb 100644 --- a/lib/ace/mode/_test/tokens_liquid.json +++ b/lib/ace/mode/_test/tokens_liquid.json @@ -1,56 +1,56 @@ [[ "start", - ["text","The following examples can be found in full at http://liquidmarkup.org/"] + ["text.xml","The following examples can be found in full at http://liquidmarkup.org/"] ],[ "start" ],[ "start", - ["text","Liquid is an extraction from the e-commerce system Shopify."] + ["text.xml","Liquid is an extraction from the e-commerce system Shopify."] ],[ "start", - ["text","Shopify powers many thousands of e-commerce stores which all call for unique designs."] + ["text.xml","Shopify powers many thousands of e-commerce stores which all call for unique designs."] ],[ "start", - ["text","For this we developed Liquid which allows our customers complete design freedom while"] + ["text.xml","For this we developed Liquid which allows our customers complete design freedom while"] ],[ "start", - ["text","maintaining the integrity of our servers."] + ["text.xml","maintaining the integrity of our servers."] ],[ "start" ],[ "start", - ["text","Liquid has been in production use since June 2006 and is now used by many other"] + ["text.xml","Liquid has been in production use since June 2006 and is now used by many other"] ],[ "start", - ["text","hosted web applications."] + ["text.xml","hosted web applications."] ],[ "start" ],[ "start", - ["text","It was developed for usage in Ruby on Rails web applications and integrates seamlessly"] + ["text.xml","It was developed for usage in Ruby on Rails web applications and integrates seamlessly"] ],[ "start", - ["text","as a plugin but it also works excellently as a stand alone library."] + ["text.xml","as a plugin but it also works excellently as a stand alone library."] ],[ "start" ],[ "start", - ["text","Here's what it looks like:"] + ["text.xml","Here's what it looks like:"] ],[ "start" ],[ "start", - ["text"," "], - ["meta.tag","<"], - ["meta.tag.tag-name","ul"], - ["text"," "], - ["entity.other.attribute-name","id"], - ["keyword.operator","="], - ["string","\"products\""], - ["meta.tag.r",">"] + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","ul"], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","id"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"products\""], + ["meta.tag.punctuation.tag-close.xml",">"] ],[ "start", - ["text"," "], + ["text.xml"," "], ["variable","{%"], ["text"," "], ["keyword","for"], @@ -64,16 +64,16 @@ ["variable","%}"] ],[ "start", - ["text"," "], - ["meta.tag","<"], - ["meta.tag.tag-name","li"], - ["meta.tag.r",">"] + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","li"], + ["meta.tag.punctuation.tag-close.xml",">"] ],[ "start", - ["text"," "], - ["meta.tag","<"], - ["meta.tag.tag-name","h2"], - ["meta.tag.r",">"], + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","h2"], + ["meta.tag.punctuation.tag-close.xml",">"], ["variable","{{"], ["text"," "], ["identifier","product"], @@ -81,12 +81,12 @@ ["identifier","title"], ["text"," "], ["variable","}}"], - ["meta.tag",""] + ["meta.tag.punctuation.end-tag-open.xml",""] ],[ "start", - ["text"," Only "], + ["text.xml"," Only "], ["variable","{{"], ["text"," "], ["identifier","product"], @@ -100,10 +100,10 @@ "start" ],[ "start", - ["text"," "], - ["meta.tag","<"], - ["meta.tag.tag-name","p"], - ["meta.tag.r",">"], + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","p"], + ["meta.tag.punctuation.tag-close.xml",">"], ["variable","{{"], ["text"," "], ["identifier","product"], @@ -117,20 +117,20 @@ ["constant.numeric","200"], ["text"," "], ["variable","}}"], - ["meta.tag",""] + ["meta.tag.punctuation.end-tag-open.xml",""] ],[ "start" ],[ "start", - ["text"," "], - ["meta.tag",""] + ["text.xml"," "], + ["meta.tag.punctuation.end-tag-open.xml",""] ],[ "start", - ["text"," "], + ["text.xml"," "], ["variable","{%"], ["text"," "], ["keyword","endfor"], @@ -138,34 +138,34 @@ ["variable","%}"] ],[ "start", - ["text"," "], - ["meta.tag",""] + ["text.xml"," "], + ["meta.tag.punctuation.end-tag-open.xml",""] ],[ "start" ],[ "start" ],[ "start", - ["text","Some more features include:"] + ["text.xml","Some more features include:"] ],[ "start" ],[ "start", - ["meta.tag","<"], - ["meta.tag.tag-name","h2"], - ["meta.tag.r",">"], - ["text","Filters"], - ["meta.tag",""] + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","h2"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["text.xml","Filters"], + ["meta.tag.punctuation.end-tag-open.xml",""] ],[ "start", - ["meta.tag","<"], - ["meta.tag.tag-name","p"], - ["meta.tag.r",">"], - ["text"," The word \"tobi\" in uppercase: "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","p"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["text.xml"," The word \"tobi\" in uppercase: "], ["variable","{{"], ["text"," "], ["string","'tobi'"], @@ -173,16 +173,16 @@ ["support.function","upcase"], ["text"," "], ["variable","}}"], - ["text"," "], - ["meta.tag",""] + ["text.xml"," "], + ["meta.tag.punctuation.end-tag-open.xml",""] ],[ "start", - ["meta.tag","<"], - ["meta.tag.tag-name","p"], - ["meta.tag.r",">"], - ["text","The word \"tobi\" has "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","p"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["text.xml","The word \"tobi\" has "], ["variable","{{"], ["text"," "], ["string","'tobi'"], @@ -190,16 +190,16 @@ ["support.function","size"], ["text"," "], ["variable","}}"], - ["text"," letters! "], - ["meta.tag",""] + ["text.xml"," letters! "], + ["meta.tag.punctuation.end-tag-open.xml",""] ],[ "start", - ["meta.tag","<"], - ["meta.tag.tag-name","p"], - ["meta.tag.r",">"], - ["text","Change \"Hello world\" to \"Hi world\": "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","p"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["text.xml","Change \"Hello world\" to \"Hi world\": "], ["variable","{{"], ["text"," "], ["string","'Hello world'"], @@ -211,16 +211,16 @@ ["string","'Hi'"], ["text"," "], ["variable","}}"], - ["text"," "], - ["meta.tag",""] + ["text.xml"," "], + ["meta.tag.punctuation.end-tag-open.xml",""] ],[ "start", - ["meta.tag","<"], - ["meta.tag.tag-name","p"], - ["meta.tag.r",">"], - ["text","The date today is "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","p"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["text.xml","The date today is "], ["variable","{{"], ["text"," "], ["string","'now'"], @@ -230,31 +230,31 @@ ["string","\"%Y %b %d\""], ["text"," "], ["variable","}}"], - ["text"," "], - ["meta.tag",""] + ["text.xml"," "], + ["meta.tag.punctuation.end-tag-open.xml",""] ],[ "start" ],[ "start" ],[ "start", - ["meta.tag","<"], - ["meta.tag.tag-name","h2"], - ["meta.tag.r",">"], - ["text","If"], - ["meta.tag",""] + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","h2"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["text.xml","If"], + ["meta.tag.punctuation.end-tag-open.xml",""] ],[ "start", - ["meta.tag","<"], - ["meta.tag.tag-name","p"], - ["meta.tag.r",">"] + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","p"], + ["meta.tag.punctuation.tag-close.xml",">"] ],[ "start", - ["text"," "], + ["text.xml"," "], ["variable","{%"], ["text"," "], ["keyword","if"], @@ -278,13 +278,13 @@ ["string","'marc'"], ["text"," "], ["variable","%}"], - ["text"," "] + ["text.xml"," "] ],[ "start", - ["text"," hi marc or tobi"] + ["text.xml"," hi marc or tobi"] ],[ "start", - ["text"," "], + ["text.xml"," "], ["variable","{%"], ["text"," "], ["keyword","endif"], @@ -292,30 +292,30 @@ ["variable","%}"] ],[ "start", - ["meta.tag",""] + ["meta.tag.punctuation.end-tag-open.xml",""] ],[ "start" ],[ "start" ],[ "start", - ["meta.tag","<"], - ["meta.tag.tag-name","h2"], - ["meta.tag.r",">"], - ["text","Case"], - ["meta.tag",""] + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","h2"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["text.xml","Case"], + ["meta.tag.punctuation.end-tag-open.xml",""] ],[ "start", - ["meta.tag","<"], - ["meta.tag.tag-name","p"], - ["meta.tag.r",">"] + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","p"], + ["meta.tag.punctuation.tag-close.xml",">"] ],[ "start", - ["text"," "], + ["text.xml"," "], ["variable","{%"], ["text"," "], ["keyword","case"], @@ -325,7 +325,7 @@ ["variable","%}"] ],[ "start", - ["text"," "], + ["text.xml"," "], ["variable","{%"], ["text"," "], ["keyword","when"], @@ -335,10 +335,10 @@ ["variable","%}"] ],[ "start", - ["text"," Welcome"] + ["text.xml"," Welcome"] ],[ "start", - ["text"," "], + ["text.xml"," "], ["variable","{%"], ["text"," "], ["keyword","when"], @@ -348,7 +348,7 @@ ["variable","%}"] ],[ "start", - ["text"," "], + ["text.xml"," "], ["variable","{{"], ["text"," "], ["identifier","product"], @@ -358,7 +358,7 @@ ["identifier","link_to_vendor"], ["text"," "], ["variable","}}"], - ["text"," / "], + ["text.xml"," / "], ["variable","{{"], ["text"," "], ["identifier","product"], @@ -368,7 +368,7 @@ ["variable","}}"] ],[ "start", - ["text"," "], + ["text.xml"," "], ["variable","{%"], ["text"," "], ["keyword","else"], @@ -376,7 +376,7 @@ ["variable","%}"] ],[ "start", - ["text"," "], + ["text.xml"," "], ["variable","{{"], ["text"," "], ["identifier","page_title"], @@ -384,7 +384,7 @@ ["variable","}}"] ],[ "start", - ["text"," "], + ["text.xml"," "], ["variable","{%"], ["text"," "], ["keyword","endcase"], @@ -392,30 +392,30 @@ ["variable","%}"] ],[ "start", - ["meta.tag",""] + ["meta.tag.punctuation.end-tag-open.xml",""] ],[ "start" ],[ "start" ],[ "start", - ["meta.tag","<"], - ["meta.tag.tag-name","h2"], - ["meta.tag.r",">"], - ["text","For Loops"], - ["meta.tag",""] + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","h2"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["text.xml","For Loops"], + ["meta.tag.punctuation.end-tag-open.xml",""] ],[ "start", - ["meta.tag","<"], - ["meta.tag.tag-name","p"], - ["meta.tag.r",">"] + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","p"], + ["meta.tag.punctuation.tag-close.xml",">"] ],[ "start", - ["text"," "], + ["text.xml"," "], ["variable","{%"], ["text"," "], ["keyword","for"], @@ -427,10 +427,10 @@ ["identifier","array"], ["text"," "], ["variable","%}"], - ["text"," "] + ["text.xml"," "] ],[ "start", - ["text"," "], + ["text.xml"," "], ["variable","{{"], ["text"," "], ["identifier","item"], @@ -438,7 +438,7 @@ ["variable","}}"] ],[ "start", - ["text"," "], + ["text.xml"," "], ["variable","{%"], ["text"," "], ["keyword","endfor"], @@ -446,30 +446,30 @@ ["variable","%}"] ],[ "start", - ["meta.tag",""] + ["meta.tag.punctuation.end-tag-open.xml",""] ],[ "start" ],[ "start" ],[ "start", - ["meta.tag","<"], - ["meta.tag.tag-name","h2"], - ["meta.tag.r",">"], - ["text","Tables"], - ["meta.tag",""] + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","h2"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["text.xml","Tables"], + ["meta.tag.punctuation.end-tag-open.xml",""] ],[ "start", - ["meta.tag","<"], - ["meta.tag.tag-name","p"], - ["meta.tag.r",">"] + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","p"], + ["meta.tag.punctuation.tag-close.xml",">"] ],[ "start", - ["text"," "], + ["text.xml"," "], ["variable","{%"], ["text"," "], ["keyword","tablerow"], @@ -487,7 +487,7 @@ ["variable","%}"] ],[ "start", - ["text"," "], + ["text.xml"," "], ["variable","{%"], ["text"," "], ["keyword","if"], @@ -499,7 +499,7 @@ ["variable","%}"] ],[ "start", - ["text"," First column: "], + ["text.xml"," First column: "], ["variable","{{"], ["text"," "], ["identifier","item"], @@ -509,7 +509,7 @@ ["variable","}}"] ],[ "start", - ["text"," "], + ["text.xml"," "], ["variable","{%"], ["text"," "], ["keyword","else"], @@ -517,7 +517,7 @@ ["variable","%}"] ],[ "start", - ["text"," Different column: "], + ["text.xml"," Different column: "], ["variable","{{"], ["text"," "], ["identifier","item"], @@ -527,7 +527,7 @@ ["variable","}}"] ],[ "start", - ["text"," "], + ["text.xml"," "], ["variable","{%"], ["text"," "], ["keyword","endif"], @@ -535,7 +535,7 @@ ["variable","%}"] ],[ "start", - ["text"," "], + ["text.xml"," "], ["variable","{%"], ["text"," "], ["keyword","endtablerow"], @@ -543,9 +543,9 @@ ["variable","%}"] ],[ "start", - ["meta.tag",""] + ["meta.tag.punctuation.end-tag-open.xml",""] ],[ "start" ]] \ No newline at end of file diff --git a/lib/ace/mode/_test/tokens_lsl.json b/lib/ace/mode/_test/tokens_lsl.json index a34106a6..2248a607 100644 --- a/lib/ace/mode/_test/tokens_lsl.json +++ b/lib/ace/mode/_test/tokens_lsl.json @@ -1,6 +1,6 @@ [[ "comment", - ["comment.block.lsl","/*"] + ["comment.block.begin.lsl","/*"] ],[ "comment", ["comment.block.lsl"," Testing syntax highlighting"] @@ -12,7 +12,7 @@ ["comment.block.lsl"," for the Linden Scripting Language"] ],[ "start", - ["comment.block.lsl","*/"] + ["comment.block.end.lsl","*/"] ],[ "start" ],[ @@ -58,7 +58,7 @@ ["constant.numeric.lsl","5673"], ["punctuation.operator.lsl",";"], ["text.lsl"," "], - ["comment.line.double-slash.lsl","// invalid reserved keyword!"] + ["comment.line.double-slash.lsl","// invalid.illegal"] ],[ "start" ],[ @@ -375,7 +375,7 @@ ["constant.numeric.lsl","5673"], ["punctuation.operator.lsl",";"], ["text.lsl"," "], - ["comment.line.double-slash.lsl","// invalid reserved keyword!"] + ["comment.line.double-slash.lsl","// invalid.illegal"] ],[ "start" ],[ @@ -401,13 +401,21 @@ ],[ "start", ["text.lsl"," "], - ["invalid.deprecated.lsl","llCollisionSprite"], + ["reserved.godmode.lsl","llSetInventoryPermMask"], ["paren.lparen.lsl","("], - ["identifier","someKeyTexture"], + ["string.quoted.double.lsl.start","\""], + ["string.quoted.double.lsl","some item"], + ["string.quoted.double.lsl.end","\""], + ["punctuation.operator.lsl",","], + ["text.lsl"," "], + ["constant.language.integer.lsl","MASK_NEXT"], + ["punctuation.operator.lsl",","], + ["text.lsl"," "], + ["constant.language.integer.lsl","PERM_ALL"], ["paren.rparen.lsl",")"], ["punctuation.operator.lsl",";"], - ["text.lsl"," "], - ["comment.line.double-slash.lsl","// invalid deprecated function!"] + ["text.lsl"," "], + ["comment.line.double-slash.lsl","// reserved.godmode"] ],[ "start" ],[ @@ -420,9 +428,9 @@ ["text.lsl"," "], ["string.quoted.double.lsl.start","\""], ["string.quoted.double.lsl","Leaving "], - ["constant.language.escape.lsl","\\\""], + ["constant.character.escape.lsl","\\\""], ["string.quoted.double.lsl","default"], - ["constant.language.escape.lsl","\\\""], + ["constant.character.escape.lsl","\\\""], ["string.quoted.double.lsl"," now..."], ["string.quoted.double.lsl.end","\""], ["paren.rparen.lsl",")"], @@ -467,13 +475,13 @@ ["text.lsl"," "], ["string.quoted.double.lsl.start","\""], ["string.quoted.double.lsl","Entered "], - ["constant.language.escape.lsl","\\\""], + ["constant.character.escape.lsl","\\\""], ["string.quoted.double.lsl","state other"], - ["constant.language.escape.lsl","\\\""], + ["constant.character.escape.lsl","\\\""], ["string.quoted.double.lsl",", returning to "], - ["constant.language.escape.lsl","\\\""], + ["constant.character.escape.lsl","\\\""], ["string.quoted.double.lsl","default"], - ["constant.language.escape.lsl","\\\""], + ["constant.character.escape.lsl","\\\""], ["string.quoted.double.lsl"," again..."], ["string.quoted.double.lsl.end","\""], ["paren.rparen.lsl",")"], @@ -492,4 +500,4 @@ ["paren.rparen.lsl","}"] ],[ "start" -]] +]] \ No newline at end of file diff --git a/lib/ace/mode/_test/tokens_lua.json b/lib/ace/mode/_test/tokens_lua.json index cc2676ea..b60c7cb1 100644 --- a/lib/ace/mode/_test/tokens_lua.json +++ b/lib/ace/mode/_test/tokens_lua.json @@ -1,11 +1,11 @@ [[ - ["bracketedComment",4,"start"], + ["bracketedComment",2,"start"], ["comment","--[[--"] ],[ - ["bracketedComment",4,"start"], + ["bracketedComment",2,"start"], ["comment","num_args takes in 5.1 byte code and extracts the number of arguments"] ],[ - ["bracketedComment",4,"start"], + ["bracketedComment",2,"start"], ["comment","from its function header."] ],[ "start", @@ -201,7 +201,7 @@ ["keyword.operator","="], ["keyword","function"], ["paren.lparen","("], - ["identifier","self"], + ["variable.language","self"], ["text",", "], ["identifier","other"], ["paren.rparen",")"] @@ -266,7 +266,7 @@ ["text"," "], ["keyword","return"], ["text"," "], - ["identifier","self"], + ["variable.language","self"], ["keyword.operator",":"], ["support.function","format"], ["paren.lparen","("], @@ -301,10 +301,10 @@ ],[ "start" ],[ - ["bracketedComment",5,"start"], + ["bracketedComment",3,"start"], ["comment","--[=[--"] ],[ - ["bracketedComment",5,"start"], + ["bracketedComment",3,"start"], ["comment","table.maxn is deprecated, use # instead."] ],[ "start", @@ -337,4 +337,12 @@ ["comment","-- outputs 8 instead of 2"] ],[ "start" +],[ + "start", + ["support.function","print"], + ["paren.lparen","("], + ["constant.numeric","5"], + ["text"," "], + ["comment","--[[ blah ]]"], + ["paren.rparen",")"] ]] \ No newline at end of file diff --git a/lib/ace/mode/_test/tokens_luapage.json b/lib/ace/mode/_test/tokens_luapage.json index d63f30e9..1fa765dd 100644 --- a/lib/ace/mode/_test/tokens_luapage.json +++ b/lib/ace/mode/_test/tokens_luapage.json @@ -1,35 +1,34 @@ [[ - "tag_embed_attribute_list", - ["text",""], - ["meta.tag","<"], - ["text","!"], - ["entity.other.attribute-name","DOCTYPE"], - ["text"," "], - ["entity.other.attribute-name","html"], - ["text"," "], - ["entity.other.attribute-name","PUBLIC"], - ["text"," "], - ["string","\"-//W3C//DTD XHTML 1.0 Strict//EN\""] + "doctype", + ["text.xml",""], + ["xml-pe.doctype.xml",""] + ["text.whitespace.xml"," "], + ["string.xml","\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\""], + ["xml-pe.doctype.xml",">"] ],[ "start", - ["meta.tag","<"], - ["meta.tag.tag-name","html"], - ["meta.tag.r",">"] + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","html"], + ["meta.tag.punctuation.tag-close.xml",">"] ],[ - ["lua-bracketedComment",4,"lua-start"], + ["lua-bracketedComment",2,"lua-start"], ["keyword","<%"], ["text"," "], ["comment","--[[--"] ],[ - ["lua-bracketedComment",4,"lua-start"], + ["lua-bracketedComment",2,"lua-start"], ["comment"," index.lp from the Kepler Project's LuaDoc HTML doclet."] ],[ - ["lua-bracketedComment",4,"lua-start"], + ["lua-bracketedComment",2,"lua-start"], ["comment"," http://keplerproject.github.com/luadoc/"] ],[ "start", @@ -38,32 +37,32 @@ ["keyword","%>"] ],[ "start", - ["meta.tag","<"], - ["meta.tag.tag-name","head"], - ["meta.tag.r",">"] + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","head"], + ["meta.tag.punctuation.tag-close.xml",">"] ],[ "start", - ["text"," "], - ["meta.tag","<"], - ["meta.tag.tag-name","title"], - ["meta.tag.r",">"], - ["text","Reference"], - ["meta.tag",""] + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","title"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["text.xml","Reference"], + ["meta.tag.punctuation.end-tag-open.xml",""] ],[ "start", - ["text"," "], - ["meta.tag","<"], - ["meta.tag.tag-name","link"], - ["text"," "], - ["entity.other.attribute-name","rel"], - ["keyword.operator","="], - ["string","\"stylesheet\""], - ["text"," "], - ["entity.other.attribute-name","href"], - ["keyword.operator","="], - ["string","\""], + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","link"], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","rel"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"stylesheet\""], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","href"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\""], ["keyword","<%="], ["identifier","luadoc"], ["text","."], @@ -76,123 +75,129 @@ ["string","\"luadoc.css\""], ["paren.rparen",")"], ["keyword","%>"], - ["text","\" type=\"text/css\" />"] + ["string.attribute-value.xml","\""], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","type"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"text/css\""], + ["text.tag-whitespace.xml"," "], + ["meta.tag.punctuation.tag-close.xml","/>"] ],[ "start", - ["text","\t"], - ["comment",""] + ["text.xml","\t"], + ["comment.xml",""] ],[ "start", - ["meta.tag",""] + ["meta.tag.punctuation.end-tag-open.xml",""] ],[ "start" ],[ "start", - ["meta.tag","<"], - ["meta.tag.tag-name","body"], - ["meta.tag.r",">"] + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","body"], + ["meta.tag.punctuation.tag-close.xml",">"] ],[ "start", - ["meta.tag","<"], - ["meta.tag.tag-name","div"], - ["text"," "], - ["entity.other.attribute-name","id"], - ["keyword.operator","="], - ["string","\"container\""], - ["meta.tag.r",">"] + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","div"], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","id"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"container\""], + ["meta.tag.punctuation.tag-close.xml",">"] ],[ "start" ],[ "start", - ["meta.tag","<"], - ["meta.tag.tag-name","div"], - ["text"," "], - ["entity.other.attribute-name","id"], - ["keyword.operator","="], - ["string","\"product\""], - ["meta.tag.r",">"] + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","div"], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","id"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"product\""], + ["meta.tag.punctuation.tag-close.xml",">"] ],[ "start", - ["text","\t"], - ["meta.tag","<"], - ["meta.tag.tag-name","div"], - ["text"," "], - ["entity.other.attribute-name","id"], - ["keyword.operator","="], - ["string","\"product_logo\""], - ["meta.tag.r",">"], - ["meta.tag",""] + ["text.xml","\t"], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","div"], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","id"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"product_logo\""], + ["meta.tag.punctuation.tag-close.xml",">"], + ["meta.tag.punctuation.end-tag-open.xml",""] ],[ "start", - ["text","\t"], - ["meta.tag","<"], - ["meta.tag.tag-name","div"], - ["text"," "], - ["entity.other.attribute-name","id"], - ["keyword.operator","="], - ["string","\"product_name\""], - ["meta.tag.r",">"], - ["meta.tag","<"], - ["meta.tag.tag-name","big"], - ["meta.tag.r",">"], - ["meta.tag","<"], - ["meta.tag.tag-name","b"], - ["meta.tag.r",">"], - ["meta.tag",""], - ["meta.tag",""], - ["meta.tag",""] + ["text.xml","\t"], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","div"], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","id"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"product_name\""], + ["meta.tag.punctuation.tag-close.xml",">"], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","big"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","b"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["meta.tag.punctuation.end-tag-open.xml",""], + ["meta.tag.punctuation.end-tag-open.xml",""], + ["meta.tag.punctuation.end-tag-open.xml",""] ],[ "start", - ["text","\t"], - ["meta.tag","<"], - ["meta.tag.tag-name","div"], - ["text"," "], - ["entity.other.attribute-name","id"], - ["keyword.operator","="], - ["string","\"product_description\""], - ["meta.tag.r",">"], - ["meta.tag",""] + ["text.xml","\t"], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","div"], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","id"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"product_description\""], + ["meta.tag.punctuation.tag-close.xml",">"], + ["meta.tag.punctuation.end-tag-open.xml",""] ],[ "start", - ["meta.tag",""], - ["text"," "], - ["comment",""] + ["meta.tag.punctuation.end-tag-open.xml",""], + ["text.xml"," "], + ["comment.xml",""] ],[ "start" ],[ "start", - ["meta.tag","<"], - ["meta.tag.tag-name","div"], - ["text"," "], - ["entity.other.attribute-name","id"], - ["keyword.operator","="], - ["string","\"main\""], - ["meta.tag.r",">"] + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","div"], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","id"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"main\""], + ["meta.tag.punctuation.tag-close.xml",">"] ],[ "start" ],[ "start", - ["meta.tag","<"], - ["meta.tag.tag-name","div"], - ["text"," "], - ["entity.other.attribute-name","id"], - ["keyword.operator","="], - ["string","\"navigation\""], - ["meta.tag.r",">"] + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","div"], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","id"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"navigation\""], + ["meta.tag.punctuation.tag-close.xml",">"] ],[ "start", ["keyword","<%="], @@ -218,22 +223,22 @@ "start" ],[ "start", - ["meta.tag",""], - ["text"," "], - ["comment",""] + ["meta.tag.punctuation.end-tag-open.xml",""], + ["text.xml"," "], + ["comment.xml",""] ],[ "start" ],[ "start", - ["meta.tag","<"], - ["meta.tag.tag-name","div"], - ["text"," "], - ["entity.other.attribute-name","id"], - ["keyword.operator","="], - ["string","\"content\""], - ["meta.tag.r",">"] + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","div"], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","id"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"content\""], + ["meta.tag.punctuation.tag-close.xml",">"] ],[ "start" ],[ @@ -262,25 +267,25 @@ ["keyword","then%>"] ],[ "start", - ["meta.tag","<"], - ["meta.tag.tag-name","h2"], - ["meta.tag.r",">"], - ["text","Modules"], - ["meta.tag",""] + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","h2"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["text.xml","Modules"], + ["meta.tag.punctuation.end-tag-open.xml",""] ],[ "start", - ["meta.tag","<"], - ["meta.tag.tag-name.table","table"], - ["text"," "], - ["entity.other.attribute-name","class"], - ["keyword.operator","="], - ["string","\"module_list\""], - ["meta.tag.r",">"] + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.table.tag-name.xml","table"], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","class"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"module_list\""], + ["meta.tag.punctuation.tag-close.xml",">"] ],[ "start", - ["comment",""] + ["comment.xml",""] ],[ "start", ["keyword","<%for"], @@ -301,26 +306,26 @@ ["keyword","do%>"] ],[ "start", - ["text","\t"], - ["meta.tag","<"], - ["meta.tag.tag-name.table","tr"], - ["meta.tag.r",">"] + ["text.xml","\t"], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.table.tag-name.xml","tr"], + ["meta.tag.punctuation.tag-close.xml",">"] ],[ "start", - ["text","\t\t"], - ["meta.tag","<"], - ["meta.tag.tag-name.table","td"], - ["text"," "], - ["entity.other.attribute-name","class"], - ["keyword.operator","="], - ["string","\"name\""], - ["meta.tag.r",">"], - ["meta.tag","<"], - ["meta.tag.tag-name.anchor","a"], - ["text"," "], - ["entity.other.attribute-name","href"], - ["keyword.operator","="], - ["string","\""], + ["text.xml","\t\t"], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.table.tag-name.xml","td"], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","class"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"name\""], + ["meta.tag.punctuation.tag-close.xml",">"], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.anchor.tag-name.xml","a"], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","href"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\""], ["keyword","<%="], ["identifier","luadoc"], ["text","."], @@ -335,26 +340,27 @@ ["identifier","doc"], ["paren.rparen",")"], ["keyword","%>"], - ["text","\">"], + ["string.attribute-value.xml","\""], + ["meta.tag.punctuation.tag-close.xml",">"], ["keyword","<%="], ["identifier","modulename"], ["keyword","%>"], - ["meta.tag",""], - ["meta.tag",""] + ["meta.tag.punctuation.end-tag-open.xml",""], + ["meta.tag.punctuation.end-tag-open.xml",""] ],[ "start", - ["text","\t\t"], - ["meta.tag","<"], - ["meta.tag.tag-name.table","td"], - ["text"," "], - ["entity.other.attribute-name","class"], - ["keyword.operator","="], - ["string","\"summary\""], - ["meta.tag.r",">"], + ["text.xml","\t\t"], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.table.tag-name.xml","td"], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","class"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"summary\""], + ["meta.tag.punctuation.tag-close.xml",">"], ["keyword","<%="], ["identifier","doc"], ["text","."], @@ -365,23 +371,23 @@ ["text","."], ["identifier","summary"], ["keyword","%>"], - ["meta.tag",""] + ["meta.tag.punctuation.end-tag-open.xml",""] ],[ "start", - ["text","\t"], - ["meta.tag",""] + ["text.xml","\t"], + ["meta.tag.punctuation.end-tag-open.xml",""] ],[ "start", ["keyword","<%end%>"] ],[ "start", - ["meta.tag",""] + ["meta.tag.punctuation.end-tag-open.xml",""] ],[ "start", ["keyword","<%end%>"] @@ -415,25 +421,25 @@ ["keyword","then%>"] ],[ "start", - ["meta.tag","<"], - ["meta.tag.tag-name","h2"], - ["meta.tag.r",">"], - ["text","Files"], - ["meta.tag",""] + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","h2"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["text.xml","Files"], + ["meta.tag.punctuation.end-tag-open.xml",""] ],[ "start", - ["meta.tag","<"], - ["meta.tag.tag-name.table","table"], - ["text"," "], - ["entity.other.attribute-name","class"], - ["keyword.operator","="], - ["string","\"file_list\""], - ["meta.tag.r",">"] + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.table.tag-name.xml","table"], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","class"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"file_list\""], + ["meta.tag.punctuation.tag-close.xml",">"] ],[ "start", - ["comment",""] + ["comment.xml",""] ],[ "start", ["keyword","<%for"], @@ -454,26 +460,26 @@ ["keyword","do%>"] ],[ "start", - ["text","\t"], - ["meta.tag","<"], - ["meta.tag.tag-name.table","tr"], - ["meta.tag.r",">"] + ["text.xml","\t"], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.table.tag-name.xml","tr"], + ["meta.tag.punctuation.tag-close.xml",">"] ],[ "start", - ["text","\t\t"], - ["meta.tag","<"], - ["meta.tag.tag-name.table","td"], - ["text"," "], - ["entity.other.attribute-name","class"], - ["keyword.operator","="], - ["string","\"name\""], - ["meta.tag.r",">"], - ["meta.tag","<"], - ["meta.tag.tag-name.anchor","a"], - ["text"," "], - ["entity.other.attribute-name","href"], - ["keyword.operator","="], - ["string","\""], + ["text.xml","\t\t"], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.table.tag-name.xml","td"], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","class"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"name\""], + ["meta.tag.punctuation.tag-close.xml",">"], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.anchor.tag-name.xml","a"], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","href"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\""], ["keyword","<%="], ["identifier","luadoc"], ["text","."], @@ -486,43 +492,44 @@ ["identifier","filepath"], ["paren.rparen",")"], ["keyword","%>"], - ["text","\">"], + ["string.attribute-value.xml","\""], + ["meta.tag.punctuation.tag-close.xml",">"], ["keyword","<%="], ["identifier","filepath"], ["keyword","%>"], - ["meta.tag",""], - ["meta.tag",""] + ["meta.tag.punctuation.end-tag-open.xml",""], + ["meta.tag.punctuation.end-tag-open.xml",""] ],[ "start", - ["text","\t\t"], - ["meta.tag","<"], - ["meta.tag.tag-name.table","td"], - ["text"," "], - ["entity.other.attribute-name","class"], - ["keyword.operator","="], - ["string","\"summary\""], - ["meta.tag.r",">"], - ["meta.tag",""] + ["text.xml","\t\t"], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.table.tag-name.xml","td"], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","class"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"summary\""], + ["meta.tag.punctuation.tag-close.xml",">"], + ["meta.tag.punctuation.end-tag-open.xml",""] ],[ "start", - ["text","\t"], - ["meta.tag",""] + ["text.xml","\t"], + ["meta.tag.punctuation.end-tag-open.xml",""] ],[ "start", ["keyword","<%end%>"] ],[ "start", - ["meta.tag",""] + ["meta.tag.punctuation.end-tag-open.xml",""] ],[ "start", ["keyword","<%end%>"] @@ -530,97 +537,97 @@ "start" ],[ "start", - ["meta.tag",""], - ["text"," "], - ["comment",""] + ["meta.tag.punctuation.end-tag-open.xml",""], + ["text.xml"," "], + ["comment.xml",""] ],[ "start" ],[ "start", - ["meta.tag",""], - ["text"," "], - ["comment",""] + ["meta.tag.punctuation.end-tag-open.xml",""], + ["text.xml"," "], + ["comment.xml",""] ],[ "start" ],[ "start", - ["meta.tag","<"], - ["meta.tag.tag-name","div"], - ["text"," "], - ["entity.other.attribute-name","id"], - ["keyword.operator","="], - ["string","\"about\""], - ["meta.tag.r",">"] + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","div"], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","id"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"about\""], + ["meta.tag.punctuation.tag-close.xml",">"] ],[ "start", - ["text","\t"], - ["meta.tag","<"], - ["meta.tag.tag-name","p"], - ["meta.tag.r",">"], - ["meta.tag","<"], - ["meta.tag.tag-name.anchor","a"], - ["text"," "], - ["entity.other.attribute-name","href"], - ["keyword.operator","="], - ["string","\"http://validator.w3.org/check?uri=referer\""], - ["meta.tag.r",">"], - ["meta.tag","<"], - ["meta.tag.tag-name.image","img"], - ["text"," "], - ["entity.other.attribute-name","src"], - ["keyword.operator","="], - ["string","\"http://www.w3.org/Icons/valid-xhtml10\""], - ["text"," "], - ["entity.other.attribute-name","alt"], - ["keyword.operator","="], - ["string","\"Valid XHTML 1.0!\""], - ["text"," "], - ["entity.other.attribute-name","height"], - ["keyword.operator","="], - ["string","\"31\""], - ["text"," "], - ["entity.other.attribute-name","width"], - ["keyword.operator","="], - ["string","\"88\""], - ["text"," "], - ["meta.tag.r","/>"], - ["meta.tag",""], - ["meta.tag",""] + ["text.xml","\t"], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","p"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.anchor.tag-name.xml","a"], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","href"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"http://validator.w3.org/check?uri=referer\""], + ["meta.tag.punctuation.tag-close.xml",">"], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.image.tag-name.xml","img"], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","src"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"http://www.w3.org/Icons/valid-xhtml10\""], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","alt"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"Valid XHTML 1.0!\""], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","height"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"31\""], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","width"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"88\""], + ["text.tag-whitespace.xml"," "], + ["meta.tag.punctuation.tag-close.xml","/>"], + ["meta.tag.punctuation.end-tag-open.xml",""], + ["meta.tag.punctuation.end-tag-open.xml",""] ],[ "start", - ["meta.tag",""], - ["text"," "], - ["comment",""] + ["meta.tag.punctuation.end-tag-open.xml",""], + ["text.xml"," "], + ["comment.xml",""] ],[ "start" ],[ "start", - ["meta.tag",""], - ["text"," "], - ["comment",""], - ["text","\t"] + ["meta.tag.punctuation.end-tag-open.xml",""], + ["text.xml"," "], + ["comment.xml",""], + ["text.xml","\t"] ],[ "start", - ["meta.tag",""] + ["meta.tag.punctuation.end-tag-open.xml",""] ],[ "start", - ["meta.tag",""] + ["meta.tag.punctuation.end-tag-open.xml",""] ],[ "start" ]] \ No newline at end of file diff --git a/lib/ace/mode/_test/tokens_markdown.json b/lib/ace/mode/_test/tokens_markdown.json index 91f7f992..29e878b2 100644 --- a/lib/ace/mode/_test/tokens_markdown.json +++ b/lib/ace/mode/_test/tokens_markdown.json @@ -1,61 +1,61 @@ [[ "start", - ["text","test: header 1 "] + ["text.xml","test: header 1 "] ],[ "start", ["markup.heading.1","#"], - ["markup.heading","f"] + ["heading","f"] ],[ "start", - ["text","test: header 2"] + ["text.xml","test: header 2"] ],[ "start", ["markup.heading.2","##"], - ["markup.heading"," foo"] + ["heading"," foo"] ],[ "start", - ["text","test: header ends with ' #'"] + ["text.xml","test: header ends with ' #'"] ],[ "start", ["markup.heading.1","#"], - ["markup.heading"," # # "] + ["heading"," # # "] ],[ "start", - ["text","test: header ends with '#'"] + ["text.xml","test: header ends with '#'"] ],[ "start", ["markup.heading.1","#"], - ["markup.heading","foo# "] + ["heading","foo# "] ],[ "start", - ["text","test: 6+ #s is not a valid header"] + ["text.xml","test: 6+ #s is not a valid header"] ],[ "start", - ["text","####### foo"] + ["text.xml","####### foo"] ],[ "start", - ["text","test: # followed be only space is not a valid header"] + ["text.xml","test: # followed be only space is not a valid header"] ],[ "start", - ["text","# "] + ["text.xml","# "] ],[ "start", - ["text","test: only space between #s is not a valid header"] + ["text.xml","test: only space between #s is not a valid header"] ],[ "start", - ["text","# #"] + ["text.xml","# #"] ],[ "allowBlock" ],[ "start", ["markup.heading.1","#"], - ["markup.heading"," test links "], + ["heading"," test links "], ["text","["], ["string","Cloud9 IDE"], ["text","]("], ["markup.underline","http://www.c9.io/"], ["text",")"], - ["markup.heading"," #"] + ["heading"," #"] ],[ "listblock", ["markup.list","* "], @@ -64,29 +64,49 @@ ["text","]("], ["markup.underline","http://ajaxorg.github.com/ace/"], ["text",")"], - ["markup.list"," "] + ["list"," "], + ["text","["], + ["string","+"], + ["text","]("], + ["markup.underline","escape(\\) "], + ["text",")"], + ["list"," "], + ["text","["], + ["string","+"], + ["text","]("], + ["markup.underline","a"], + ["string"," \"title\""], + ["text",")"], + ["list"," "], + ["text","["], + ["string","+"], + ["text","]("], + ["markup.underline","a"], + ["string"," \"space\" "], + ["text",")"] ],[ "listblock", - ["markup.list","* usually "], - ["string","*work*"], - ["markup.list"," fine ("], - ["string","_em_"], - ["markup.list",")"] + ["markup.list","* "], + ["list","usually "], + ["string.emphasis","*work*"], + ["list"," fine ("], + ["string.emphasis","_em_"], + ["list",")"] ],[ "listblock", - ["markup.list","in lists"] + ["list","in lists"] ],[ "start" ],[ "start", - ["text","in plain text "], - ["meta.tag","<"], - ["meta.tag.tag-name","b"], - ["meta.tag.r",">"], - ["text","http://ace.ajaxorg.com"], - ["meta.tag","<"], - ["meta.tag.tag-name","b"], - ["meta.tag.r",">"] + ["text.xml","in plain text "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","b"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["text.xml","http://ace.ajaxorg.com"], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","b"], + ["meta.tag.punctuation.tag-close.xml",">"] ],[ "allowBlock" ],[ diff --git a/lib/ace/mode/_test/tokens_mask.json b/lib/ace/mode/_test/tokens_mask.json new file mode 100644 index 00000000..5f2b9762 --- /dev/null +++ b/lib/ace/mode/_test/tokens_mask.json @@ -0,0 +1,302 @@ +[[ + "start", + ["comment","/* Mask Syntax Demo */"] +],[ + "start" +],[ + "start", + ["keyword.support.constant.language","div"], + ["text"," "], + ["paren.lparen",">"], + ["text"," "], + ["string.start","'"], + ["string"," Test "], + ["paren.lparen.markup.italic","~["], + ["identifier","name"], + ["paren.rparen.markup.italic","]"], + ["string.end","'"], + ["paren.rparen",";"] +],[ + "start" +],[ + "start", + ["keyword","define"], + ["text"," :"], + ["support.variable.class","userProfile"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text","\t"], + ["keyword.support.constant.language","header"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text","\t\t"], + ["keyword.support.constant.language","h4"], + ["text"," "], + ["paren.lparen",">"], + ["text"," "], + ["support.function.markup.bold","@title"], + ["paren.lparen",";"] +],[ + "start", + ["text","\t\t"], + ["keyword.support.constant.language","button"], + ["support.variable.class",".close"], + ["paren.lparen",";"] +],[ + "start", + ["text","\t"], + ["paren.rparen","}"] +],[ + "start", + ["paren.rparen","}"] +],[ + "start" +],[ + "start", + ["support.function.markup.bold",":userProfile"], + ["text"," "], + ["paren.lparen","{"] +],[ + "start", + ["text","\t"], + ["support.function.markup.bold","@title"], + ["text"," "], + ["paren.lparen",">"], + ["text"," "], + ["string.start","'"], + ["string"," Hello "], + ["paren.lparen.markup.italic","~["], + ["keyword.control.markup.italic",":"], + ["text"," "], + ["identifier","username"], + ["punctuation.operator","."], + ["support.function","toUpperCase"], + ["paren.lparen","("], + ["paren.rparen",")"], + ["paren.rparen.markup.italic","]"], + ["string.end","'"] +],[ + "start", + ["paren.rparen","}"] +],[ + "start" +],[ + ["paren.lparen52","constant.language40"], + ["constant.language","style"], + ["text"," "], + ["paren.lparen","{"] +],[ + ["css-block-ruleset","paren.lparen52","paren.lparen52","constant.language40"], + ["text"," "], + ["constant","html"], + ["text",", "], + ["constant","body"], + ["text"," "], + ["paren.lparen","{"] +],[ + ["css-block-ruleset","paren.lparen52","paren.lparen52","constant.language40"], + ["text"," "], + ["support.type","background"], + ["text",": "], + ["support.function","url("], + ["string","'name.png'"], + ["support.function",")"], + ["text"," "], + ["constant.numeric","0"], + ["text"," "], + ["constant.numeric","0"], + ["text"," "], + ["support.constant","no-repeat"], + ["text",";"] +],[ + ["paren.lparen52","constant.language40"], + ["text"," "], + ["paren.rparen","}"] +],[ + ["#tmp","css-block-end","paren.lparen52","constant.language40"], + ["paren.rparen","}"] +],[ + ["#tmp","start","paren.lparen52","constant.language40"] +],[ + ["#tmp","start","paren.lparen52","constant.language40"], + ["keyword.support.constant.language","button"], + ["text"," "], + ["paren.lparen","{"] +],[ + ["paren.lparen39","constant.language27","constant.language27","start","paren.lparen52","constant.language40"], + ["text","\t"], + ["constant.language","event"], + ["text"," "], + ["support.variable.class","click"], + ["text"," "], + ["paren.lparen","("], + ["identifier","e"], + ["paren.rparen",")"], + ["text"," "], + ["paren.lparen","{"] +],[ + ["#tmp","js-block-start","paren.lparen39","constant.language27","constant.language27","start","paren.lparen52","constant.language40"], + ["text","\t "], + ["variable.language","this"], + ["punctuation.operator","."], + ["identifier","textContent"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["string.quasi.start","`"], + ["string.quasi","name "], + ["paren.quasi.start","${"], + ["identifier","e"], + ["punctuation.operator","."], + ["identifier","clientX"], + ["paren.quasi.end","}"], + ["string.quasi"," !"], + ["string.quasi.end","`"], + ["punctuation.operator",";"] +],[ + ["#tmp","js-block-end","paren.lparen39","constant.language27","constant.language27","start","paren.lparen52","constant.language40"], + ["text","\t"], + ["paren.rparen","}"] +],[ + ["#tmp","start","paren.lparen39","constant.language27","constant.language27","start","paren.lparen52","constant.language40"], + ["paren.rparen","}"] +],[ + ["#tmp","start","paren.lparen39","constant.language27","constant.language27","start","paren.lparen52","constant.language40"] +],[ + ["paren.lparen13","constant.language","constant.language","start","paren.lparen39","constant.language27","constant.language27","start","paren.lparen52","constant.language40"], + ["constant.language","md"], + ["text"," "], + ["paren.lparen",">"], + ["text"," "], + ["paren.lparen","\"\"\""] +],[ + ["#tmp","md-multiline-allowBlock","paren.lparen13","constant.language","constant.language","start","paren.lparen39","constant.language27","constant.language27","start","paren.lparen52","constant.language40"] +],[ + ["#tmp","md-multiline-listblock","paren.lparen13","constant.language","constant.language","start","paren.lparen39","constant.language27","constant.language27","start","paren.lparen52","constant.language40"], + ["markup.list","- "], + ["list","div"] +],[ + ["#tmp","md-multiline-listblock","paren.lparen13","constant.language","constant.language","start","paren.lparen39","constant.language27","constant.language27","start","paren.lparen52","constant.language40"], + ["markup.list","- "], + ["list","span"] +],[ + ["#tmp","md-multiline-listblock","paren.lparen13","constant.language","constant.language","start","paren.lparen39","constant.language27","constant.language27","start","paren.lparen52","constant.language40"], + ["list"," "] +],[ + ["#tmp","md-multiline-listblock","paren.lparen13","constant.language","constant.language","start","paren.lparen39","constant.language27","constant.language27","start","paren.lparen52","constant.language40"], + ["list","Hello"] +],[ + ["#tmp","md-multiline-start","paren.lparen13","constant.language","constant.language","start","paren.lparen39","constant.language27","constant.language27","start","paren.lparen52","constant.language40"] +],[ + ["#tmp","md-multiline-start","paren.lparen13","constant.language","constant.language","start","paren.lparen39","constant.language27","constant.language27","start","paren.lparen52","constant.language40"], + ["text","["], + ["string","one"], + ["text","]("], + ["markup.underline","http://google.com"], + ["text",")"] +],[ + ["#tmp","md-multiline-allowBlock","paren.lparen13","constant.language","constant.language","start","paren.lparen39","constant.language27","constant.language27","start","paren.lparen52","constant.language40"] +],[ + ["#tmp","start","paren.lparen13","constant.language","constant.language","start","paren.lparen39","constant.language27","constant.language27","start","paren.lparen52","constant.language40"], + ["paren.rparen","\"\"\";"] +],[ + ["#tmp","start","paren.lparen13","constant.language","constant.language","start","paren.lparen39","constant.language27","constant.language27","start","paren.lparen52","constant.language40"] +],[ + ["#tmp","start","paren.lparen13","constant.language","constant.language","start","paren.lparen39","constant.language27","constant.language27","start","paren.lparen52","constant.language40"] +],[ + ["#tmp","start","paren.lparen13","constant.language","constant.language","start","paren.lparen39","constant.language27","constant.language27","start","paren.lparen52","constant.language40"], + ["keyword.support.constant.language","header"], + ["text"," "], + ["support.variable.class",".foo"], + ["text"," "], + ["paren.lparen",">"], + ["text"," "], + ["string.start","'"], + ["string","Heading"], + ["string.end","'"] +],[ + ["#tmp","start","paren.lparen13","constant.language","constant.language","start","paren.lparen39","constant.language27","constant.language27","start","paren.lparen52","constant.language40"] +],[ + ["string.start2","start","paren.lparen13","constant.language","constant.language","start","paren.lparen39","constant.language27","constant.language27","start","paren.lparen52","constant.language40"], + ["keyword.support.constant.language","button"], + ["text"," "], + ["support.variable.class",".baz"], + ["text"," "], + ["support.variable.class.markup.bold","x-signal"], + ["keyword.operator","="], + ["string.start","'"], + ["string","click: test"], + ["string.end","'"], + ["text"," "], + ["support.variable.class","disabled"], + ["text"," "], + ["paren.lparen",">"], + ["text"," "], + ["string.start","\""] +],[ + ["string.start2","start","paren.lparen13","constant.language","constant.language","start","paren.lparen39","constant.language27","constant.language27","start","paren.lparen52","constant.language40"], + ["string","\tHello,"] +],[ + ["string.start2","start","paren.lparen13","constant.language","constant.language","start","paren.lparen39","constant.language27","constant.language27","start","paren.lparen52","constant.language40"], + ["string","\tworld "] +],[ + ["string.start2","start","paren.lparen13","constant.language","constant.language","start","paren.lparen39","constant.language27","constant.language27","start","paren.lparen52","constant.language40"], + ["string","\t"], + ["string.escape","\\\""], + ["string","Buddy"], + ["string.escape","\\\""] +],[ + ["#tmp","start","paren.lparen13","constant.language","constant.language","start","paren.lparen39","constant.language27","constant.language27","start","paren.lparen52","constant.language40"], + ["string.end","\""] +],[ + ["#tmp","start","paren.lparen13","constant.language","constant.language","start","paren.lparen39","constant.language27","constant.language27","start","paren.lparen52","constant.language40"] +],[ + ["#tmp","js-statement-start","start","js-statement-no_regex","constant.language53","start","paren.lparen13","constant.language","constant.language","start","paren.lparen39","constant.language27","constant.language27","start","paren.lparen52","constant.language40"], + ["constant.language","var"], + ["text"," "], + ["identifier","a"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["paren","{"] +],[ + ["#tmp","js-statement-no_regex","start","js-statement-no_regex","constant.language53","start","paren.lparen13","constant.language","constant.language","start","paren.lparen39","constant.language27","constant.language27","start","paren.lparen52","constant.language40"], + ["text"," "], + ["identifier","name"], + ["punctuation.operator",":"], + ["text"," "], + ["string.quasi.start","`"], + ["string.quasi","name "], + ["paren.quasi.start","${"], + ["variable.language","window"], + ["punctuation.operator","."], + ["support.constant","innerWidth"], + ["paren.rparen","}"], + ["string.quasi.end","`"] +],[ + ["#tmp","start","paren.lparen13","constant.language","constant.language","start","paren.lparen39","constant.language27","constant.language27","start","paren.lparen52","constant.language40"], + ["paren.rparen","};"] +],[ + ["#tmp","start","paren.lparen13","constant.language","constant.language","start","paren.lparen39","constant.language27","constant.language27","start","paren.lparen52","constant.language40"] +],[ + ["#tmp","start","paren.lparen13","constant.language","constant.language","start","paren.lparen39","constant.language27","constant.language27","start","paren.lparen52","constant.language40"], + ["keyword.support.constant.language","span"], + ["text"," "], + ["support.variable.class",".foo"], + ["text"," "], + ["paren.lparen",">"], + ["text"," "], + ["string.start","\""], + ["paren.lparen.markup.italic","~["], + ["keyword.control.markup.italic","bind:"], + ["text"," "], + ["identifier","a"], + ["punctuation.operator","."], + ["identifier","name"], + ["paren.rparen.markup.italic","]"], + ["string.end","\""] +]] \ No newline at end of file diff --git a/lib/ace/mode/_test/tokens_matlab.json b/lib/ace/mode/_test/tokens_matlab.json new file mode 100644 index 00000000..6b4a8567 --- /dev/null +++ b/lib/ace/mode/_test/tokens_matlab.json @@ -0,0 +1,90 @@ +[[ + ["blockComment","noQstring"], + ["comment.start","%{"] +],[ + ["blockComment","blockComment","blockComment","noQstring"], + ["comment.start"," %{"] +],[ + ["blockComment","blockComment","blockComment","noQstring"], + ["comment"," Ace Matlab demo"] +],[ + ["blockComment","noQstring"], + ["comment.end"," %}"] +],[ + "noQstring", + ["comment.end","%}"] +],[ + "start" +],[ + "start", + ["keyword","classdef"], + ["text"," "], + ["identifier","hello"] +],[ + "start", + ["text"," "], + ["support.function","methods"] +],[ + "start", + ["text"," "], + ["keyword","function"], + ["text"," "], + ["identifier","greet"], + ["paren.lparen","("], + ["identifier","this"], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["support.function","disp"], + ["paren.lparen","("], + ["string","'Hello!'"], + ["paren.rparen",")"], + ["text"," "], + ["comment","% say hi"] +],[ + "start", + ["text"," "], + ["keyword","end"] +],[ + "start", + ["text"," "], + ["keyword","end"] +],[ + "start", + ["keyword","end"] +],[ + "noQstring" +],[ + "start", + ["comment","% transpose "] +],[ + "qqstring", + ["identifier","a"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["paren.lparen","["], + ["text"," "], + ["string","'x"], + ["constant.language.escape","''"], + ["string","y'"], + ["punctuation.operator",","], + ["text"," "], + ["string","\"x"], + ["constant.language.escape","\\n"], + ["string","\\"] +],[ + "start", + ["string"," y\""], + ["punctuation.operator",","], + ["text"," "], + ["constant.numeric","1"], + ["text","' "], + ["paren.rparen","]"], + ["text","' "], + ["keyword.operator","+"], + ["text"," "], + ["constant.numeric","2"], + ["text","'"] +]] \ No newline at end of file diff --git a/lib/ace/mode/_test/tokens_mel.json b/lib/ace/mode/_test/tokens_mel.json new file mode 100644 index 00000000..a2d618a9 --- /dev/null +++ b/lib/ace/mode/_test/tokens_mel.json @@ -0,0 +1,257 @@ +[[ + "start", + ["comment.line.double-slash.mel","//"], + ["punctuation.definition.comment.mel"," animated duplicates, instances script"] +],[ + "start", + ["meta.function.mel","proc"], + ["keyword.other.mel"," "], + ["storage.type.mel","animatedDuplication"], + ["entity.name.function.mel"," ("], + ["punctuation.section.function.mel","("], + ["meta.function.mel","int $rangeStart, int $rangeEnd, int $numOfDuplicates, int $duplicateOrInstance"], + ["punctuation.section.function.mel",")"], + "proc animatedDuplication (int $rangeStart, int $rangeEnd, int $numOfDuplicates, int $duplicateOrInstance)" +],[ + "start", + ["text","{"] +],[ + "start", + ["text"," "], + ["storage.type.mel","int"], + ["text"," "], + ["variable.other.mel","$"], + ["punctuation.definition.variable.mel","range_start"], + ["text"," "], + ["keyword.operator.symbolic.mel","="], + ["text"," "], + ["variable.other.mel","$"], + ["punctuation.definition.variable.mel","rangeStart"], + ["text",";"] +],[ + "start", + ["text"," "], + ["storage.type.mel","int"], + ["text"," "], + ["variable.other.mel","$"], + ["punctuation.definition.variable.mel","range_end"], + ["text"," "], + ["keyword.operator.symbolic.mel","="], + ["text"," "], + ["variable.other.mel","$"], + ["punctuation.definition.variable.mel","rangeEnd"], + ["text",";"] +],[ + "start", + ["text"," "], + ["storage.type.mel","int"], + ["text"," "], + ["variable.other.mel","$"], + ["punctuation.definition.variable.mel","num_of_duplicates"], + ["text"," "], + ["keyword.operator.symbolic.mel","="], + ["text"," "], + ["variable.other.mel","$"], + ["punctuation.definition.variable.mel","numOfDuplicates"], + ["text",";"] +],[ + "start", + ["text"," "], + ["storage.type.mel","int"], + ["text"," "], + ["variable.other.mel","$"], + ["punctuation.definition.variable.mel","step_size"], + ["text"," "], + ["keyword.operator.symbolic.mel","="], + ["text"," ("], + ["variable.other.mel","$"], + ["punctuation.definition.variable.mel","range_end"], + ["text"," "], + ["keyword.operator.symbolic.mel","-"], + ["text"," "], + ["variable.other.mel","$"], + ["punctuation.definition.variable.mel","range_start"], + ["text",") "], + ["keyword.operator.symbolic.mel","/"], + ["text"," "], + ["variable.other.mel","$"], + ["punctuation.definition.variable.mel","num_of_duplicates"], + ["text",";"] +],[ + "start", + ["text"," "], + ["storage.type.mel","int"], + ["text"," "], + ["variable.other.mel","$"], + ["punctuation.definition.variable.mel","i"], + ["text"," "], + ["keyword.operator.symbolic.mel","="], + ["text"," "], + ["constant.numeric.mel","0"], + ["text",";"] +],[ + "start", + ["text"," "], + ["storage.type.mel","int"], + ["text"," "], + ["variable.other.mel","$"], + ["punctuation.definition.variable.mel","temp"], + ["text",";"] +],[ + "start" +],[ + "start", + ["text"," "], + ["support.function.mel","currentTime"], + ["text"," "], + ["variable.other.mel","$"], + ["punctuation.definition.variable.mel","range_start"], + ["text","; "], + ["comment.line.double-slash.mel","//"], + ["punctuation.definition.comment.mel"," set to range start"] +],[ + "start" +],[ + "start", + ["text"," "], + ["storage.type.mel","string"], + ["text"," "], + ["variable.other.mel","$"], + ["punctuation.definition.variable.mel","selectedObjects"], + ["text","[]; "], + ["comment.line.double-slash.mel","//"], + ["punctuation.definition.comment.mel"," to store selected objects"] +],[ + "start", + ["text"," "], + ["variable.other.mel","$"], + ["punctuation.definition.variable.mel","selectedObjects"], + ["text"," "], + ["keyword.operator.symbolic.mel","="], + ["text"," `"], + ["support.function.mel","ls"], + ["text"," "], + ["keyword.operator.symbolic.mel","-"], + ["text","sl`; "], + ["comment.line.double-slash.mel","//"], + ["punctuation.definition.comment.mel"," store selected objects"] +],[ + "start", + ["text"," "], + ["support.function.mel","select"], + ["text"," "], + ["variable.other.mel","$"], + ["punctuation.definition.variable.mel","selectedObjects"], + ["text",";"] +],[ + "start" +],[ + "start", + ["text"," "], + ["keyword.control.mel","while"], + ["text"," ("], + ["variable.other.mel","$"], + ["punctuation.definition.variable.mel","i"], + ["text"," <"], + ["keyword.operator.symbolic.mel","="], + ["text"," "], + ["variable.other.mel","$"], + ["punctuation.definition.variable.mel","num_of_duplicates"], + ["text",")"] +],[ + "start", + ["text"," {"] +],[ + "start", + ["text"," "], + ["variable.other.mel","$"], + ["punctuation.definition.variable.mel","temp"], + ["text"," "], + ["keyword.operator.symbolic.mel","="], + ["text"," "], + ["variable.other.mel","$"], + ["punctuation.definition.variable.mel","range_start"], + ["text"," "], + ["keyword.operator.symbolic.mel","+"], + ["text"," ("], + ["variable.other.mel","$"], + ["punctuation.definition.variable.mel","step_size"], + ["text"," "], + ["keyword.operator.symbolic.mel","*"], + ["text"," "], + ["variable.other.mel","$"], + ["punctuation.definition.variable.mel","i"], + ["text",");"] +],[ + "start", + ["text"," "], + ["support.function.mel","currentTime"], + ["text"," ("], + ["variable.other.mel","$"], + ["punctuation.definition.variable.mel","temp"], + ["text",");"] +],[ + "start", + ["text"," "], + ["comment.line.double-slash.mel","//"], + ["punctuation.definition.comment.mel"," seleced the objects to duplicate or instance"] +],[ + "start", + ["text"," "], + ["support.function.mel","select"], + ["text"," "], + ["variable.other.mel","$"], + ["punctuation.definition.variable.mel","selectedObjects"], + ["text",";"] +],[ + "start", + ["text"," "], + ["keyword.control.mel","if"], + ["text","("], + ["variable.other.mel","$"], + ["punctuation.definition.variable.mel","duplicateOrInstance"], + ["text"," "], + ["keyword.operator.symbolic.mel","=="], + ["text"," "], + ["constant.numeric.mel","0"], + ["text",")"] +],[ + "start", + ["text"," {"] +],[ + "start", + ["text"," "], + ["support.function.mel","duplicate"], + ["text",";"] +],[ + "start", + ["text"," }"] +],[ + "start", + ["text"," "], + ["keyword.control.mel","else"] +],[ + "start", + ["text"," {"] +],[ + "start", + ["text"," "], + ["support.function.mel","instance"], + ["text",";"] +],[ + "start", + ["text"," }"] +],[ + "start", + ["text"," "], + ["variable.other.mel","$"], + ["punctuation.definition.variable.mel","i"], + ["keyword.operator.symbolic.mel","++"], + ["text",";"] +],[ + "start", + ["text"," }"] +],[ + "start", + ["text","}"] +]] \ No newline at end of file diff --git a/lib/ace/mode/_test/tokens_mushcode.json b/lib/ace/mode/_test/tokens_mushcode.json new file mode 100644 index 00000000..9f8e7cc2 --- /dev/null +++ b/lib/ace/mode/_test/tokens_mushcode.json @@ -0,0 +1,790 @@ +[[ + "start", + ["text","@"], + ["support.function","create"], + ["text"," "], + ["identifier","phone"] +],[ + "start", + ["text","&"], + ["identifier","pickup"], + ["text"," "], + ["identifier","phone"], + ["keyword.operator","="], + ["identifier","$pick"], + ["text"," "], + ["identifier","up"], + ["text",":@"], + ["support.function","ifelse"], + ["text"," "], + ["paren.lparen","["], + ["support.function","u"], + ["paren.lparen","("], + ["identifier","is"], + ["text",","], + ["support.function","u"], + ["paren.lparen","("], + ["identifier","mode"], + ["paren.rparen",")"], + ["text",","], + ["identifier","ICC"], + ["paren.rparen",")]"], + ["keyword.operator","="], + ["paren.lparen","{"], + ["text","@"], + ["support.function","pemit"], + ["text"," "], + ["keyword.operator","%#="], + ["identifier","You"], + ["text"," "], + ["support.function","pick"], + ["text"," "], + ["identifier","up"], + ["text"," "], + ["identifier","the"], + ["text"," "], + ["paren.lparen","["], + ["support.function","fullname"], + ["paren.lparen","("], + ["identifier","me"], + ["paren.rparen",")]"], + ["text","."], + ["paren.lparen","["], + ["support.function","set"], + ["paren.lparen","("], + ["identifier","me"], + ["text",","], + ["identifier","PHONER"], + ["text",":"], + ["keyword.operator","%#"], + ["paren.rparen",")]"], + ["paren.lparen","["], + ["support.function","set"], + ["paren.lparen","("], + ["identifier","me"], + ["text",","], + ["identifier","MODE"], + ["text",":"], + ["identifier","CIP"], + ["paren.rparen",")]"], + ["paren.lparen","["], + ["support.function","set"], + ["paren.lparen","(["], + ["support.function","u"], + ["paren.lparen","("], + ["identifier","INCOMING"], + ["paren.rparen",")]"], + ["text",","], + ["identifier","CONNECTED"], + ["text",":"], + ["paren.lparen","["], + ["support.function","num"], + ["paren.lparen","("], + ["identifier","me"], + ["paren.rparen",")])]"], + ["paren.lparen","["], + ["support.function","set"], + ["paren.lparen","("], + ["identifier","me"], + ["text",","], + ["identifier","CONNECTED"], + ["text",":"], + ["paren.lparen","["], + ["support.function","u"], + ["paren.lparen","("], + ["identifier","INCOMING"], + ["paren.rparen",")])]"], + ["variable","%r"], + ["paren.lparen","["], + ["support.function","showpicture"], + ["paren.lparen","("], + ["identifier","PICPICKUP"], + ["paren.rparen",")]"], + ["variable","%r"], + ["identifier","Use"], + ["text"," '"], + ["paren.lparen","["], + ["identifier","color"], + ["paren.lparen","("], + ["identifier","green"], + ["text",","], + ["identifier","black"], + ["text",","], + ["identifier","psay"], + ["text"," "], + ["keyword.operator","<"], + ["identifier","message"], + ["keyword.operator",">"], + ["paren.rparen",")]"], + ["text","' "], + ["paren.lparen","("], + ["support.function","or"], + ["text"," '"], + ["paren.lparen","["], + ["identifier","color"], + ["paren.lparen","("], + ["identifier","green"], + ["text",","], + ["identifier","black"], + ["text",","], + ["identifier","p"], + ["text"," "], + ["keyword.operator","<"], + ["identifier","message"], + ["keyword.operator",">"], + ["paren.rparen",")]"], + ["text","'"], + ["paren.rparen",")"], + ["text"," "], + ["identifier","to"], + ["text"," "], + ["identifier","talk"], + ["text"," "], + ["identifier","into"], + ["text"," "], + ["identifier","the"], + ["text"," "], + ["identifier","phone"], + ["text",".;@"], + ["support.function","oemit"], + ["text"," "], + ["keyword.operator","%#="], + ["variable","%N"], + ["text"," "], + ["identifier","picks"], + ["text"," "], + ["identifier","up"], + ["text"," "], + ["identifier","the"], + ["text"," "], + ["paren.lparen","["], + ["support.function","fullname"], + ["paren.lparen","("], + ["identifier","me"], + ["paren.rparen",")]"], + ["text","."], + ["paren.rparen","}"], + ["text",","], + ["paren.lparen","{"], + ["text","@"], + ["support.function","pemit"], + ["text"," "], + ["keyword.operator","%#="], + ["identifier","You"], + ["text"," "], + ["support.function","pick"], + ["text"," "], + ["identifier","up"], + ["text"," "], + ["identifier","the"], + ["text"," "], + ["identifier","phone"], + ["text"," "], + ["identifier","but"], + ["text"," "], + ["identifier","no"], + ["text"," "], + ["identifier","one"], + ["text"," "], + ["identifier","is"], + ["text"," "], + ["identifier","there"], + ["text",". "], + ["identifier","You"], + ["text"," "], + ["identifier","hear"], + ["text"," "], + ["identifier","a"], + ["text"," "], + ["identifier","dialtone"], + ["text"," "], + ["support.function","and"], + ["text"," "], + ["identifier","then"], + ["text"," "], + ["identifier","hang"], + ["text"," "], + ["identifier","up"], + ["text",". "], + ["paren.lparen","["], + ["support.function","play"], + ["paren.lparen","("], + ["support.function","u"], + ["paren.lparen","("], + ["identifier","DIALTONE"], + ["paren.rparen","))]"], + ["text",";@"], + ["support.function","oemit"], + ["text"," "], + ["keyword.operator","%#="], + ["variable","%N"], + ["text"," "], + ["identifier","picks"], + ["text"," "], + ["identifier","up"], + ["text"," "], + ["identifier","the"], + ["text"," "], + ["identifier","phone"], + ["text",", "], + ["identifier","but"], + ["text"," "], + ["identifier","no"], + ["text"," "], + ["identifier","one"], + ["text"," "], + ["identifier","is"], + ["text"," "], + ["identifier","on"], + ["text"," "], + ["identifier","the"], + ["text"," "], + ["identifier","other"], + ["text"," "], + ["identifier","end"], + ["text","."], + ["paren.rparen","}"] +],[ + "start", + ["text","&"], + ["identifier","ringfun"], + ["text"," "], + ["identifier","phone"], + ["keyword.operator","="], + ["paren.lparen","["], + ["support.function","ifelse"], + ["paren.lparen","("], + ["support.function","eq"], + ["paren.lparen","("], + ["support.function","comp"], + ["paren.lparen","(["], + ["support.function","u"], + ["paren.lparen","("], + ["variable","%0"], + ["keyword.operator","/"], + ["identifier","ringtone"], + ["paren.rparen",")]"], + ["text",","], + ["identifier","off"], + ["paren.rparen",")"], + ["text",","], + ["constant.numeric","0"], + ["paren.rparen",")"], + ["text",","], + ["paren.lparen","["], + ["identifier","color"], + ["paren.lparen","("], + ["identifier","black"], + ["text",","], + ["identifier","cyan"], + ["text",","], + ["identifier","INCOMING"], + ["text"," "], + ["identifier","CALL"], + ["text"," "], + ["identifier","FROM"], + ["text"," "], + ["variable","%1"], + ["paren.rparen",")]"], + ["text",","], + ["paren.lparen","["], + ["support.function","play"], + ["paren.lparen","(["], + ["support.function","switch"], + ["paren.lparen","(["], + ["support.function","u"], + ["paren.lparen","("], + ["variable","%0"], + ["keyword.operator","/"], + ["identifier","ringtone"], + ["paren.rparen",")]"], + ["text",","], + ["constant.numeric","1"], + ["text",","], + ["paren.lparen","["], + ["support.function","u"], + ["paren.lparen","("], + ["variable","%0"], + ["keyword.operator","/"], + ["identifier","ringtone1"], + ["paren.rparen",")]"], + ["text",","], + ["constant.numeric","2"], + ["text",","], + ["paren.lparen","["], + ["support.function","u"], + ["paren.lparen","("], + ["variable","%0"], + ["keyword.operator","/"], + ["identifier","ringtone2"], + ["paren.rparen",")]"], + ["text",","], + ["constant.numeric","3"], + ["text",","], + ["paren.lparen","["], + ["support.function","u"], + ["paren.lparen","("], + ["variable","%0"], + ["keyword.operator","/"], + ["identifier","ringtone3"], + ["paren.rparen",")]"], + ["text",","], + ["constant.numeric","4"], + ["text",","], + ["paren.lparen","["], + ["support.function","u"], + ["paren.lparen","("], + ["variable","%0"], + ["keyword.operator","/"], + ["identifier","ringtone4"], + ["paren.rparen",")]"], + ["text",","], + ["constant.numeric","5"], + ["text",","], + ["paren.lparen","["], + ["support.function","u"], + ["paren.lparen","("], + ["variable","%0"], + ["keyword.operator","/"], + ["identifier","ringtone5"], + ["paren.rparen",")]"], + ["text",","], + ["constant.numeric","6"], + ["text",","], + ["paren.lparen","["], + ["support.function","u"], + ["paren.lparen","("], + ["variable","%0"], + ["keyword.operator","/"], + ["identifier","ringtone6"], + ["paren.rparen",")]"], + ["text",","], + ["constant.numeric","7"], + ["text",","], + ["paren.lparen","["], + ["support.function","u"], + ["paren.lparen","("], + ["variable","%0"], + ["keyword.operator","/"], + ["identifier","ringtone7"], + ["paren.rparen",")]"], + ["text",","], + ["constant.numeric","8"], + ["text",","], + ["paren.lparen","["], + ["support.function","u"], + ["paren.lparen","("], + ["variable","%0"], + ["keyword.operator","/"], + ["identifier","ringtone8"], + ["paren.rparen",")]"], + ["text",","], + ["constant.numeric","9"], + ["text",","], + ["paren.lparen","["], + ["support.function","u"], + ["paren.lparen","("], + ["variable","%0"], + ["keyword.operator","/"], + ["identifier","ringtone9"], + ["paren.rparen",")]"], + ["text",","], + ["identifier","custom"], + ["text",","], + ["paren.lparen","["], + ["support.function","u"], + ["paren.lparen","("], + ["variable","%0"], + ["keyword.operator","/"], + ["identifier","customtone"], + ["paren.rparen",")]"], + ["text",","], + ["identifier","vibrate"], + ["text",","], + ["paren.lparen","["], + ["support.function","u"], + ["paren.lparen","("], + ["variable","%0"], + ["keyword.operator","/"], + ["identifier","vibrate"], + ["paren.rparen",")])])]"] +],[ + "start", + ["text","&"], + ["identifier","ringloop"], + ["text"," "], + ["identifier","phone"], + ["keyword.operator","="], + ["text","@"], + ["support.function","switch"], + ["text"," "], + ["paren.lparen","["], + ["support.function","u"], + ["paren.lparen","("], + ["identifier","ringstate"], + ["paren.rparen",")]"], + ["keyword.operator","="], + ["constant.numeric","1"], + ["text",","], + ["paren.lparen","{"], + ["text","@"], + ["support.function","emit"], + ["text"," "], + ["paren.lparen","["], + ["support.function","setq"], + ["paren.lparen","("], + ["identifier","q"], + ["text",","], + ["paren.lparen","["], + ["support.function","u"], + ["paren.lparen","("], + ["identifier","connecting"], + ["paren.rparen",")])]"], + ["paren.lparen","["], + ["support.function","set"], + ["paren.lparen","("], + ["variable","%qq"], + ["text",","], + ["identifier","rangs"], + ["text",":"], + ["constant.numeric","0"], + ["paren.rparen",")]"], + ["paren.lparen","["], + ["support.function","set"], + ["paren.lparen","("], + ["variable","%qq"], + ["text",","], + ["identifier","mode"], + ["text",":"], + ["identifier","WFC"], + ["paren.rparen",")]"], + ["paren.lparen","["], + ["support.function","set"], + ["paren.lparen","("], + ["variable","%qq"], + ["text",","], + ["identifier","INCOMING"], + ["text",":"], + ["paren.rparen",")]"], + ["text",";@"], + ["support.function","ifelse"], + ["text"," "], + ["paren.lparen","["], + ["support.function","u"], + ["paren.lparen","("], + ["variable","%qq"], + ["keyword.operator","/"], + ["identifier","HASVMB"], + ["paren.rparen",")]"], + ["keyword.operator","="], + ["paren.lparen","{"], + ["text","@"], + ["support.function","tr"], + ["text"," "], + ["identifier","me"], + ["keyword.operator","/"], + ["identifier","ROUTEVMB"], + ["keyword.operator","="], + ["paren.lparen","["], + ["support.function","u"], + ["paren.lparen","("], + ["identifier","connecting"], + ["paren.rparen",")]"], + ["text",";"], + ["paren.rparen","}"], + ["text",","], + ["paren.lparen","{"], + ["text","@"], + ["support.function","pemit"], + ["text"," "], + ["keyword.operator","%#="], + ["paren.lparen","["], + ["support.function","u"], + ["paren.lparen","("], + ["identifier","MSGCNC"], + ["paren.rparen",")]"], + ["text",";"], + ["paren.rparen","}}"], + ["text",","], + ["constant.numeric","2"], + ["text",","], + ["paren.lparen","{"], + ["text","@"], + ["support.function","pemit"], + ["text"," "], + ["keyword.operator","%#="], + ["identifier","The"], + ["text"," "], + ["identifier","call"], + ["text"," "], + ["identifier","is"], + ["text"," "], + ["identifier","connected"], + ["text","."], + ["paren.lparen","["], + ["support.function","setq"], + ["paren.lparen","("], + ["identifier","q"], + ["text",","], + ["paren.lparen","["], + ["support.function","u"], + ["paren.lparen","("], + ["identifier","CONNECTING"], + ["paren.rparen",")])]"], + ["paren.lparen","["], + ["support.function","set"], + ["paren.lparen","("], + ["identifier","me"], + ["text",","], + ["identifier","CONNECTED"], + ["text",":"], + ["variable","%qq"], + ["paren.rparen",")]"], + ["paren.lparen","["], + ["support.function","set"], + ["paren.lparen","("], + ["variable","%qq"], + ["text",","], + ["identifier","CONNECTED"], + ["text",":"], + ["paren.lparen","["], + ["support.function","num"], + ["paren.lparen","("], + ["identifier","me"], + ["paren.rparen",")])]"], + ["paren.lparen","["], + ["support.function","set"], + ["paren.lparen","("], + ["variable","%qq"], + ["text",","], + ["identifier","MODE"], + ["text",":"], + ["identifier","CIP"], + ["paren.rparen",")]"], + ["text",";@"], + ["support.function","tr"], + ["text"," "], + ["identifier","me"], + ["keyword.operator","/"], + ["identifier","ciploop"], + ["text",";@"], + ["support.function","tr"], + ["text"," "], + ["variable","%qq"], + ["keyword.operator","/"], + ["identifier","ciploop"], + ["text",";"], + ["paren.rparen","}"], + ["text",","], + ["constant.numeric","3"], + ["text",","], + ["paren.lparen","{"], + ["text","@"], + ["support.function","emit"], + ["text"," "], + ["identifier","On"], + ["text"," "], + ["paren.lparen","["], + ["support.function","fullname"], + ["paren.lparen","("], + ["identifier","me"], + ["paren.rparen",")]"], + ["text","'"], + ["support.function","s"], + ["text"," "], + ["identifier","earpiece"], + ["text"," "], + ["identifier","you"], + ["text"," "], + ["identifier","hear"], + ["text"," "], + ["identifier","a"], + ["text"," "], + ["identifier","ringing"], + ["text"," "], + ["identifier","sound"], + ["text","."], + ["paren.lparen","["], + ["support.function","play"], + ["paren.lparen","("], + ["support.function","u"], + ["paren.lparen","("], + ["identifier","LINETONE"], + ["paren.rparen","))]"], + ["text",";@"], + ["support.function","tr"], + ["text"," "], + ["identifier","me"], + ["keyword.operator","/"], + ["identifier","ringhere"], + ["text",";@"], + ["identifier","increment"], + ["text"," "], + ["paren.lparen","["], + ["support.function","u"], + ["paren.lparen","("], + ["identifier","connecting"], + ["paren.rparen",")]"], + ["keyword.operator","/"], + ["identifier","RANGS"], + ["text",";@"], + ["identifier","wait"], + ["text"," "], + ["constant.numeric","5"], + ["keyword.operator","="], + ["paren.lparen","{"], + ["text","@"], + ["support.function","tr"], + ["text"," "], + ["identifier","me"], + ["keyword.operator","/"], + ["identifier","ringloop"], + ["paren.rparen","}"], + ["text",";"], + ["paren.rparen","}"], + ["text",","], + ["constant.numeric","4"], + ["text",","], + ["paren.lparen","{"], + ["paren.rparen","}"] +],[ + "start", + ["text","&"], + ["identifier","ringstate"], + ["text"," "], + ["identifier","phone"], + ["keyword.operator","="], + ["paren.lparen","["], + ["support.function","setq"], + ["paren.lparen","("], + ["identifier","q"], + ["text",","], + ["support.function","u"], + ["paren.lparen","("], + ["identifier","connecting"], + ["paren.rparen","))]"], + ["paren.lparen","["], + ["support.function","setq"], + ["paren.lparen","("], + ["constant.numeric","1"], + ["text",","], + ["paren.lparen","["], + ["support.function","gt"], + ["paren.lparen","("], + ["support.function","u"], + ["paren.lparen","("], + ["variable","%qq"], + ["keyword.operator","/"], + ["identifier","rangs"], + ["paren.rparen",")"], + ["text",","], + ["support.function","sub"], + ["paren.lparen","("], + ["support.function","u"], + ["paren.lparen","("], + ["variable","%qq"], + ["keyword.operator","/"], + ["identifier","rings"], + ["paren.rparen",")"], + ["text",","], + ["constant.numeric","1"], + ["paren.rparen","))])]"], + ["paren.lparen","["], + ["support.function","setq"], + ["paren.lparen","("], + ["constant.numeric","2"], + ["text",","], + ["paren.lparen","["], + ["support.function","and"], + ["paren.lparen","("], + ["support.function","u"], + ["paren.lparen","("], + ["identifier","is"], + ["text",","], + ["support.function","u"], + ["paren.lparen","("], + ["variable","%qq"], + ["keyword.operator","/"], + ["identifier","MODE"], + ["paren.rparen",")"], + ["text",","], + ["identifier","CIP"], + ["paren.rparen",")"], + ["text",","], + ["support.function","u"], + ["paren.lparen","("], + ["identifier","is"], + ["text",","], + ["support.function","u"], + ["paren.lparen","("], + ["variable","%qq"], + ["keyword.operator","/"], + ["identifier","INCOMING"], + ["paren.rparen",")"], + ["text",","], + ["paren.lparen","["], + ["support.function","num"], + ["paren.lparen","("], + ["identifier","me"], + ["paren.rparen",")]))]"], + ["paren.lparen","["], + ["support.function","setq"], + ["paren.lparen","("], + ["constant.numeric","3"], + ["text",","], + ["paren.lparen","["], + ["support.function","u"], + ["paren.lparen","("], + ["identifier","is"], + ["text",","], + ["support.function","u"], + ["paren.lparen","("], + ["variable","%qq"], + ["keyword.operator","/"], + ["identifier","MODE"], + ["paren.rparen",")"], + ["text",","], + ["identifier","ICC"], + ["paren.rparen",")])]"], + ["paren.lparen","["], + ["support.function","ifelse"], + ["paren.lparen","("], + ["variable","%q1"], + ["text",","], + ["constant.numeric","1"], + ["text",","], + ["support.function","ifelse"], + ["paren.lparen","("], + ["variable","%q2"], + ["text",","], + ["constant.numeric","2"], + ["text",","], + ["support.function","ifelse"], + ["paren.lparen","("], + ["variable","%q3"], + ["text",","], + ["constant.numeric","3"], + ["text",","], + ["constant.numeric","4"], + ["paren.rparen",")))]"] +],[ + "start", + ["text",";"], + ["identifier","comment"] +],[ + "start", + ["text","@@"], + ["paren.lparen","("], + ["identifier","comment"], + ["paren.rparen",")"] +],[ + "start", + ["keyword","say"], + ["text"," "], + ["paren.lparen","["], + ["support.function","time"], + ["paren.lparen","("], + ["paren.rparen",")]"] +],[ + "start" +]] \ No newline at end of file diff --git a/lib/ace/mode/_test/tokens_mysql.json b/lib/ace/mode/_test/tokens_mysql.json new file mode 100644 index 00000000..9909eadd --- /dev/null +++ b/lib/ace/mode/_test/tokens_mysql.json @@ -0,0 +1,4 @@ +[[ + "start", + ["identifier","TODO"] +]] \ No newline at end of file diff --git a/lib/ace/mode/_test/tokens_nix.json b/lib/ace/mode/_test/tokens_nix.json new file mode 100644 index 00000000..b9424456 --- /dev/null +++ b/lib/ace/mode/_test/tokens_nix.json @@ -0,0 +1,360 @@ +[[ + "start", + ["text","{"] +],[ + "start", + ["text"," "], + ["comment","# Name of our deployment"] +],[ + "start", + ["text"," "], + ["identifier","network"], + ["text","."], + ["identifier","description"], + ["text"," "], + ["keyword.operator.assignment.nix","="], + ["text"," "], + ["string","\"HelloWorld\""], + ["text",";"] +],[ + "start", + ["text"," "], + ["comment","# Enable rolling back to previous versions of our infrastructure"] +],[ + "start", + ["text"," "], + ["identifier","network"], + ["text","."], + ["identifier","enableRollback"], + ["text"," "], + ["keyword.operator.assignment.nix","="], + ["text"," "], + ["constant.language.nix","true"], + ["text",";"] +],[ + "start" +],[ + "start", + ["text"," "], + ["comment","# It consists of a single server named 'helloserver'"] +],[ + "start", + ["text"," "], + ["identifier","helloserver"], + ["text"," "], + ["keyword.operator.assignment.nix","="] +],[ + "start", + ["text"," "], + ["comment","# Every server gets passed a few arguments, including a reference"] +],[ + "start", + ["text"," "], + ["comment","# to nixpkgs (pkgs)"] +],[ + "start", + ["text"," { "], + ["identifier","config"], + ["text",", "], + ["identifier","pkgs"], + ["text",", ... }:"] +],[ + "start", + ["text"," "], + ["keyword.declaration.nix","let"] +],[ + "start", + ["text"," "], + ["comment","# We import our custom packages from ./default passing pkgs as argument"] +],[ + "start", + ["text"," "], + ["identifier","packages"], + ["text"," "], + ["keyword.operator.assignment.nix","="], + ["text"," "], + ["keyword.control.nix","import"], + ["text"," ./"], + ["identifier","default"], + ["text","."], + ["identifier","nix"], + ["text"," { "], + ["identifier","pkgs"], + ["text"," "], + ["keyword.operator.assignment.nix","="], + ["text"," "], + ["identifier","pkgs"], + ["text","; };"] +],[ + "start", + ["text"," "], + ["comment","# This is the nodejs version specified in default.nix"] +],[ + "start", + ["text"," "], + ["identifier","nodejs"], + ["text"," "], + ["keyword.operator.assignment.nix","="], + ["text"," "], + ["identifier","packages"], + ["text","."], + ["identifier","nodejs"], + ["text",";"] +],[ + "start", + ["text"," "], + ["comment","# And this is the application we'd like to deploy"] +],[ + "start", + ["text"," "], + ["identifier","app"], + ["text"," "], + ["keyword.operator.assignment.nix","="], + ["text"," "], + ["identifier","packages"], + ["text","."], + ["identifier","app"], + ["text",";"] +],[ + "start", + ["text"," "], + ["keyword.declaration.nix","in"] +],[ + "start", + ["text"," {"] +],[ + "start", + ["text"," "], + ["comment","# We'll be running our application on port 8080, because a regular"] +],[ + "start", + ["text"," "], + ["comment","# user cannot bind to port 80"] +],[ + "start", + ["text"," "], + ["comment","# Then, using some iptables magic we'll forward traffic designated to port 80 to 8080"] +],[ + "start", + ["text"," "], + ["identifier","networking"], + ["text","."], + ["identifier","firewall"], + ["text","."], + ["identifier","enable"], + ["text"," "], + ["keyword.operator.assignment.nix","="], + ["text"," "], + ["constant.language.nix","true"], + ["text",";"] +],[ + "start", + ["text"," "], + ["comment","# We will open up port 22 (SSH) as well otherwise we're locking ourselves out"] +],[ + "start", + ["text"," "], + ["identifier","networking"], + ["text","."], + ["identifier","firewall"], + ["text","."], + ["identifier","allowedTCPPorts"], + ["text"," "], + ["keyword.operator.assignment.nix","="], + ["text"," [ "], + ["constant.numeric","80"], + ["text"," "], + ["constant.numeric","8080"], + ["text"," "], + ["constant.numeric","22"], + ["text"," ];"] +],[ + "start", + ["text"," "], + ["identifier","networking"], + ["text","."], + ["identifier","firewall"], + ["text","."], + ["identifier","allowPing"], + ["text"," "], + ["keyword.operator.assignment.nix","="], + ["text"," "], + ["constant.language.nix","true"], + ["text",";"] +],[ + "start" +],[ + "start", + ["text"," "], + ["comment","# Port forwarding using iptables"] +],[ + "qqdoc", + ["text"," "], + ["identifier","networking"], + ["text","."], + ["identifier","firewall"], + ["text","."], + ["identifier","extraCommands"], + ["text"," "], + ["keyword.operator.assignment.nix","="], + ["text"," "], + ["string","''"] +],[ + "qqdoc", + ["string"," iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080"] +],[ + "start", + ["string"," ''"], + ["text",";"] +],[ + "start" +],[ + "start", + ["text"," "], + ["comment","# To run our node.js program we're going to use a systemd service"] +],[ + "start", + ["text"," "], + ["comment","# We can configure the service to automatically start on boot and to restart"] +],[ + "start", + ["text"," "], + ["comment","# the process in case it crashes"] +],[ + "start", + ["text"," "], + ["identifier","systemd"], + ["text","."], + ["identifier","services"], + ["text","."], + ["identifier","helloserver"], + ["text"," "], + ["keyword.operator.assignment.nix","="], + ["text"," {"] +],[ + "start", + ["text"," "], + ["identifier","description"], + ["text"," "], + ["keyword.operator.assignment.nix","="], + ["text"," "], + ["string","\"Hello world application\""], + ["text",";"] +],[ + "start", + ["text"," "], + ["comment","# Start the service after the network is available"] +],[ + "start", + ["text"," "], + ["identifier","after"], + ["text"," "], + ["keyword.operator.assignment.nix","="], + ["text"," [ "], + ["string","\"network.target\""], + ["text"," ];"] +],[ + "start", + ["text"," "], + ["comment","# We're going to run it on port 8080 in production"] +],[ + "start", + ["text"," "], + ["identifier","environment"], + ["text"," "], + ["keyword.operator.assignment.nix","="], + ["text"," { "], + ["identifier","PORT"], + ["text"," "], + ["keyword.operator.assignment.nix","="], + ["text"," "], + ["string","\"8080\""], + ["text","; };"] +],[ + "start", + ["text"," "], + ["identifier","serviceConfig"], + ["text"," "], + ["keyword.operator.assignment.nix","="], + ["text"," {"] +],[ + "start", + ["text"," "], + ["comment","# The actual command to run"] +],[ + "start", + ["text"," "], + ["identifier","ExecStart"], + ["text"," "], + ["keyword.operator.assignment.nix","="], + ["text"," "], + ["string","\""], + ["constant.language.escape","${"], + ["identifier","nodejs"], + ["constant.language.escape","}"], + ["string","/bin/node "], + ["constant.language.escape","${"], + ["identifier","app"], + ["constant.language.escape","}"], + ["string","/server.js\""], + ["text",";"] +],[ + "start", + ["text"," "], + ["comment","# For security reasons we'll run this process as a special 'nodejs' user"] +],[ + "start", + ["text"," "], + ["identifier","User"], + ["text"," "], + ["keyword.operator.assignment.nix","="], + ["text"," "], + ["string","\"nodejs\""], + ["text",";"] +],[ + "start", + ["text"," "], + ["identifier","Restart"], + ["text"," "], + ["keyword.operator.assignment.nix","="], + ["text"," "], + ["string","\"always\""], + ["text",";"] +],[ + "start", + ["text"," };"] +],[ + "start", + ["text"," };"] +],[ + "start" +],[ + "start", + ["text"," "], + ["comment","# And lastly we ensure the user we run our application as is created"] +],[ + "start", + ["text"," "], + ["identifier","users"], + ["text","."], + ["identifier","extraUsers"], + ["text"," "], + ["keyword.operator.assignment.nix","="], + ["text"," {"] +],[ + "start", + ["text"," "], + ["identifier","nodejs"], + ["text"," "], + ["keyword.operator.assignment.nix","="], + ["text"," { };"] +],[ + "start", + ["text"," };"] +],[ + "start", + ["text"," };"] +],[ + "start", + ["text","}"] +]] \ No newline at end of file diff --git a/lib/ace/mode/_test/tokens_objectivec.json b/lib/ace/mode/_test/tokens_objectivec.json index c6582d20..cdfd1196 100644 --- a/lib/ace/mode/_test/tokens_objectivec.json +++ b/lib/ace/mode/_test/tokens_objectivec.json @@ -727,7 +727,8 @@ ],[ "start", ["keyword","#ifndef"], - ["constant.other"," Nil"] + ["text"," "], + ["constant.language.objc","Nil"] ],[ "start", ["keyword","#define"], diff --git a/lib/ace/mode/_test/tokens_pgsql.json b/lib/ace/mode/_test/tokens_pgsql.json index ded4bb86..fef23fd2 100644 --- a/lib/ace/mode/_test/tokens_pgsql.json +++ b/lib/ace/mode/_test/tokens_pgsql.json @@ -297,10 +297,10 @@ ["comment.doc","* Dollar quotes starting at the end of the line are colored as SQL unless"] ],[ "doc-start", - ["comment.doc","* a special language tag is used. Pearl and Python are currently implemented"] + ["comment.doc","* a special language tag is used. Dollar quote syntax coloring is implemented"] ],[ "doc-start", - ["comment.doc","* but lots of others are possible."] + ["comment.doc","* for Perl, Python, JavaScript, and Json."] ],[ "start", ["comment.doc","*/"] @@ -662,6 +662,160 @@ ["statementEnd",";"] ],[ "start" +],[ + "start", + ["comment","-- pl/v8 (javascript)"] +],[ + "javascript-start", + ["keyword.statementBegin","CREATE"], + ["text"," "], + ["keyword","FUNCTION"], + ["text"," "], + ["identifier","plv8_test"], + ["paren.lparen","("], + ["identifier","keys"], + ["text"," "], + ["keyword","text"], + ["text","[], "], + ["identifier","vals"], + ["text"," "], + ["keyword","text"], + ["text","[]"], + ["paren.rparen",")"], + ["text"," "], + ["keyword","RETURNS"], + ["text"," "], + ["keyword","text"], + ["text"," "], + ["keyword","AS"], + ["text"," "], + ["string","$javascript$"] +],[ + "javascript-start", + ["storage.type","var"], + ["text"," "], + ["identifier","o"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["paren.lparen","{"], + ["paren.rparen","}"], + ["punctuation.operator",";"] +],[ + "javascript-start", + ["keyword","for"], + ["paren.lparen","("], + ["storage.type","var"], + ["text"," "], + ["identifier","i"], + ["keyword.operator","="], + ["constant.numeric","0"], + ["punctuation.operator",";"], + ["text"," "], + ["identifier","i"], + ["keyword.operator","<"], + ["identifier","keys"], + ["punctuation.operator","."], + ["support.constant","length"], + ["punctuation.operator",";"], + ["text"," "], + ["identifier","i"], + ["keyword.operator","++"], + ["paren.rparen",")"], + ["paren.lparen","{"] +],[ + "javascript-start", + ["text"," "], + ["identifier","o"], + ["paren.lparen","["], + ["identifier","keys"], + ["paren.lparen","["], + ["identifier","i"], + ["paren.rparen","]]"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["identifier","vals"], + ["paren.lparen","["], + ["identifier","i"], + ["paren.rparen","]"], + ["punctuation.operator",";"] +],[ + "javascript-no_regex", + ["paren.rparen","}"] +],[ + "javascript-start", + ["keyword","return"], + ["text"," "], + ["variable.language","JSON"], + ["punctuation.operator","."], + ["identifier","stringify"], + ["paren.lparen","("], + ["identifier","o"], + ["paren.rparen",")"], + ["punctuation.operator",";"] +],[ + "start", + ["string","$javascript$"], + ["text"," "], + ["keyword","LANGUAGE"], + ["text"," "], + ["identifier","plv8"], + ["text"," "], + ["keyword","IMMUTABLE"], + ["text"," "], + ["keyword","STRICT"], + ["statementEnd",";"] +],[ + "start" +],[ + "start", + ["comment","-- json"] +],[ + "json-start", + ["keyword.statementBegin","select"], + ["text"," "], + ["keyword.operator","*"], + ["text"," "], + ["keyword","from"], + ["text"," "], + ["support.function","json_object_keys"], + ["paren.lparen","("], + ["string","$json$"] +],[ + "json-start", + ["paren.lparen","{"] +],[ + "json-start", + ["text"," "], + ["variable","\"f1\""], + ["text",": "], + ["constant.numeric","5"], + ["text",","] +],[ + "json-start", + ["text"," "], + ["variable","\"f2\""], + ["text",": "], + ["string","\"test\""], + ["text",","] +],[ + "json-start", + ["text"," "], + ["variable","\"f3\""], + ["text",": "], + ["paren.lparen","{"], + ["paren.rparen","}"] +],[ + "json-start", + ["paren.rparen","}"] +],[ + "start", + ["string","$json$"], + ["paren.rparen",")"], + ["statementEnd",";"] +],[ + "start" ],[ "start" ],[ diff --git a/lib/ace/mode/_test/tokens_php.json b/lib/ace/mode/_test/tokens_php.json index d8a41eec..2134dccb 100644 --- a/lib/ace/mode/_test/tokens_php.json +++ b/lib/ace/mode/_test/tokens_php.json @@ -129,6 +129,43 @@ ],[ "php-start" ],[ - "start", + ["php-start","js-start"], + ["support.php_tag","?>"], + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.script.tag-name.xml","script"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["text"," "], + ["support.php_tag",""] +],[ + "js-comment_regex_allowed", + ["comment","/*this is js "], + ["support.php_tag",""] +],[ + "start", + ["meta.tag.punctuation.end-tag-open.xml",""], + ["text.xml"," not "], + ["constant.language.escape.reference.xml","&js;"] +],[ + "start" ]] \ No newline at end of file diff --git a/lib/ace/mode/_test/tokens_prolog.json b/lib/ace/mode/_test/tokens_prolog.json index e42b65b5..4c0f5c5c 100644 --- a/lib/ace/mode/_test/tokens_prolog.json +++ b/lib/ace/mode/_test/tokens_prolog.json @@ -117,85 +117,67 @@ "start", ["text"," "] ],[ - "entity.name.function.fact.prolog", + "start", ["entity.name.function.fact.prolog","quicksort"], ["punctuation.begin.fact.parameters.prolog","("], ["punctuation.begin.list.prolog","["], ["punctuation.end.list.prolog","]"], - ["invalid.illegal.invalidchar.prolog",")"], - ["meta.fact.prolog"," "], - ["invalid.illegal.invalidchar.prolog","-"], - ["keyword.operator.prolog","->"], - ["meta.fact.prolog"," "], - ["punctuation.begin.list.prolog","["], - ["punctuation.end.list.prolog","]"], - ["invalid.illegal.invalidchar.prolog","."] + ["punctuation.end.fact.parameters.prolog",")"], + ["text"," --> []."] ],[ - "entity.name.function.fact.prolog", - ["constant.other.atom.prolog","quicksort"], - ["punctuation.begin.statement.parameters.prolog","("], + "start", + ["entity.name.function.fact.prolog","quicksort"], + ["punctuation.begin.fact.parameters.prolog","("], ["punctuation.begin.list.prolog","["], ["variable.other.prolog","X"], ["punctuation.concat.list.prolog","|"], ["variable.other.prolog","Xs"], ["punctuation.end.list.prolog","]"], - ["punctuation.end.statement.parameters.prolog",")"], - ["meta.fact.prolog"," "], - ["invalid.illegal.invalidchar.prolog","-"], - ["keyword.operator.prolog","->"] + ["punctuation.end.fact.parameters.prolog",")"], + ["text"," -->"] ],[ - "entity.name.function.fact.prolog", - ["meta.fact.prolog"," "], - ["invalid.illegal.invalidchar.prolog","{"], - ["meta.fact.prolog"," "], - ["constant.other.atom.prolog","partition"], - ["punctuation.begin.statement.parameters.prolog","("], - ["variable.other.prolog","Xs"], - ["punctuation.separator.statement.prolog",","], - ["meta.statement.parameters.prolog"," "], - ["variable.other.prolog","X"], - ["punctuation.separator.statement.prolog",","], - ["meta.statement.parameters.prolog"," "], - ["variable.other.prolog","Smaller"], - ["punctuation.separator.statement.prolog",","], - ["meta.statement.parameters.prolog"," "], - ["variable.other.prolog","Bigger"], - ["punctuation.end.statement.parameters.prolog",")"], - ["meta.fact.prolog"," "], - ["invalid.illegal.invalidchar.prolog","}"], - ["punctuation.separator.parameters.prolog",","] -],[ - "entity.name.function.fact.prolog", - ["meta.fact.prolog"," "], - ["constant.other.atom.prolog","quicksort"], - ["punctuation.begin.statement.parameters.prolog","("], - ["variable.other.prolog","Smaller"], - ["punctuation.end.statement.parameters.prolog",")"], + "start", + ["text"," { "], + ["entity.name.function.fact.prolog","partition"], + ["punctuation.begin.fact.parameters.prolog","("], + ["variable.parameter.prolog","Xs"], ["punctuation.separator.parameters.prolog",","], ["meta.fact.prolog"," "], - ["punctuation.begin.list.prolog","["], - ["variable.other.prolog","X"], - ["punctuation.end.list.prolog","]"], + ["variable.parameter.prolog","X"], ["punctuation.separator.parameters.prolog",","], ["meta.fact.prolog"," "], - ["constant.other.atom.prolog","quicksort"], - ["punctuation.begin.statement.parameters.prolog","("], - ["variable.other.prolog","Bigger"], - ["punctuation.end.statement.parameters.prolog",")"], - ["invalid.illegal.invalidchar.prolog","."] -],[ - "entity.name.function.fact.prolog" -],[ - "entity.name.function.fact.prolog", - ["constant.other.atom.prolog","perfect"], - ["punctuation.begin.statement.parameters.prolog","("], - ["variable.other.prolog","N"], - ["punctuation.end.statement.parameters.prolog",")"], + ["variable.parameter.prolog","Smaller"], + ["punctuation.separator.parameters.prolog",","], ["meta.fact.prolog"," "], - ["invalid.illegal.invalidchar.prolog",":-"] + ["variable.parameter.prolog","Bigger"], + ["punctuation.end.fact.parameters.prolog",")"], + ["text"," },"] ],[ - "entity.name.function.fact.prolog", - ["meta.fact.prolog"," "], + "start", + ["text"," "], + ["entity.name.function.fact.prolog","quicksort"], + ["punctuation.begin.fact.parameters.prolog","("], + ["variable.parameter.prolog","Smaller"], + ["punctuation.end.fact.parameters.prolog",")"], + ["text",", [X], "], + ["entity.name.function.fact.prolog","quicksort"], + ["punctuation.begin.fact.parameters.prolog","("], + ["variable.parameter.prolog","Bigger"], + ["punctuation.end.fact.parameters.prolog",")"], + ["punctuation.end.fact.prolog","."] +],[ + "start" +],[ + ["keyword.operator.definition.prolog","meta.rule.prolog"], + ["entity.name.function.rule.prolog","perfect"], + ["punctuation.rule.parameters.begin.prolog","("], + ["variable.parameter.prolog","N"], + ["punctuation.rule.parameters.end.prolog",")"], + ["meta.rule.signature.prolog"," "], + ["keyword.operator.definition.prolog",":-"] +],[ + ["keyword.operator.definition.prolog","meta.rule.prolog"], + ["meta.rule.definition.prolog"," "], ["constant.other.atom.prolog","between"], ["punctuation.begin.statement.parameters.prolog","("], ["constant.numeric.prolog","1"], @@ -206,21 +188,19 @@ ["meta.statement.parameters.prolog"," "], ["variable.other.prolog","N"], ["punctuation.end.statement.parameters.prolog",")"], - ["punctuation.separator.parameters.prolog",","], - ["meta.fact.prolog"," "], - ["variable.parameter.prolog","U"], - ["meta.fact.prolog"," "], + ["punctuation.control.and.prolog",","], + ["meta.rule.definition.prolog"," "], + ["variable.other.prolog","U"], + ["meta.rule.definition.prolog"," "], ["keyword.operator.prolog","is"], - ["meta.fact.prolog"," "], - ["variable.parameter.prolog","N"], - ["meta.fact.prolog"," "], - ["invalid.illegal.invalidchar.prolog","//"], - ["meta.fact.prolog"," "], + ["meta.rule.definition.prolog"," "], + ["variable.other.prolog","N"], + ["meta.rule.definition.prolog"," // "], ["constant.numeric.prolog","2"], - ["punctuation.separator.parameters.prolog",","] + ["punctuation.control.and.prolog",","] ],[ - "entity.name.function.fact.prolog", - ["meta.fact.prolog"," "], + ["keyword.operator.definition.prolog","meta.rule.prolog"], + ["meta.rule.definition.prolog"," "], ["constant.other.atom.prolog","findall"], ["punctuation.begin.statement.parameters.prolog","("], ["variable.other.prolog","D"], @@ -246,14 +226,14 @@ ["meta.statement.parameters.prolog"," "], ["constant.numeric.prolog","0"], ["punctuation.end.statement.parameters.prolog",")"], - ["punctuation.separator.parameters.prolog",","], - ["meta.fact.prolog"," "], - ["variable.parameter.prolog","Ds"], - ["invalid.illegal.invalidchar.prolog",")"], - ["punctuation.separator.parameters.prolog",","] + ["punctuation.control.and.prolog",","], + ["meta.rule.definition.prolog"," "], + ["variable.other.prolog","Ds"], + ["meta.rule.definition.prolog",")"], + ["punctuation.control.and.prolog",","] ],[ - "entity.name.function.fact.prolog", - ["meta.fact.prolog"," "], + "start", + ["meta.rule.definition.prolog"," "], ["constant.other.atom.prolog","sumlist"], ["punctuation.begin.statement.parameters.prolog","("], ["variable.other.prolog","Ds"], @@ -261,5 +241,5 @@ ["meta.statement.parameters.prolog"," "], ["variable.other.prolog","N"], ["punctuation.end.statement.parameters.prolog",")"], - ["invalid.illegal.invalidchar.prolog","."] + ["punctuation.rule.end.prolog","."] ]] \ No newline at end of file diff --git a/lib/ace/mode/_test/tokens_properties.json b/lib/ace/mode/_test/tokens_properties.json new file mode 100644 index 00000000..8831045e --- /dev/null +++ b/lib/ace/mode/_test/tokens_properties.json @@ -0,0 +1,68 @@ +[[ + "start", + ["comment","# You are reading the \".properties\" entry."] +],[ + "start", + ["comment","! The exclamation mark can also mark text as comments."] +],[ + "start", + ["comment","# The key and element characters #, !, =, and : are written with a preceding backslash to ensure that they are properly loaded."] +],[ + "start", + ["variable","website "], + ["keyword","="], + ["string"," http"], + ["constant.language.escape","\\"], + ["string","://en.wikipedia.org/"] +],[ + "start", + ["variable","language "], + ["keyword","="], + ["string"," English"] +],[ + "start", + ["comment","# The backslash below tells the application to continue reading"] +],[ + "start", + ["comment","# the value onto the next line."] +],[ + "value", + ["variable","message "], + ["keyword","="], + ["string"," Welcome to \\"] +],[ + "start", + ["string"," Wikipedia!"] +],[ + "start", + ["comment","# Add spaces to the key"] +],[ + "start", + ["variable","key"], + ["constant.language.escape","\\"], + ["variable"," with"], + ["constant.language.escape","\\"], + ["variable"," spaces "], + ["keyword","="], + ["string"," This is the value that could be looked up with the key \"key with spaces\"."] +],[ + "start", + ["comment","# Unicode"] +],[ + "start", + ["variable","tab "], + ["keyword",":"], + ["string"," "], + ["constant.language.escape","\\u0009"] +],[ + "start", + ["variable","empty-key"], + ["keyword","="] +],[ + "start", + ["variable","last.line"], + ["keyword","="], + ["string","value"] +],[ + "start" +]] \ No newline at end of file diff --git a/lib/ace/mode/_test/tokens_protobuf.json b/lib/ace/mode/_test/tokens_protobuf.json new file mode 100644 index 00000000..469dba06 --- /dev/null +++ b/lib/ace/mode/_test/tokens_protobuf.json @@ -0,0 +1,136 @@ +[[ + "start", + ["keyword.declaration.protobuf","message"], + ["text"," "], + ["identifier","Point"], + ["text"," {"] +],[ + "start", + ["text"," "], + ["keyword.declaration.protobuf","required"], + ["text"," "], + ["support.type","int32"], + ["text"," "], + ["identifier","x"], + ["text"," "], + ["keyword.operator.assignment.protobuf","="], + ["text"," "], + ["constant.numeric","1"], + ["text",";"] +],[ + "start", + ["text"," "], + ["keyword.declaration.protobuf","required"], + ["text"," "], + ["support.type","int32"], + ["text"," "], + ["identifier","y"], + ["text"," "], + ["keyword.operator.assignment.protobuf","="], + ["text"," "], + ["constant.numeric","2"], + ["text",";"] +],[ + "start", + ["text"," "], + ["keyword.declaration.protobuf","optional"], + ["text"," "], + ["support.type","string"], + ["text"," "], + ["identifier","label"], + ["text"," "], + ["keyword.operator.assignment.protobuf","="], + ["text"," "], + ["constant.numeric","3"], + ["text",";"] +],[ + "start", + ["text","}"] +],[ + "start" +],[ + "start", + ["keyword.declaration.protobuf","message"], + ["text"," "], + ["identifier","Line"], + ["text"," {"] +],[ + "start", + ["text"," "], + ["keyword.declaration.protobuf","required"], + ["text"," "], + ["identifier","Point"], + ["text"," "], + ["identifier","start"], + ["text"," "], + ["keyword.operator.assignment.protobuf","="], + ["text"," "], + ["constant.numeric","1"], + ["text",";"] +],[ + "start", + ["text"," "], + ["keyword.declaration.protobuf","required"], + ["text"," "], + ["identifier","Point"], + ["text"," "], + ["identifier","end"], + ["text"," "], + ["keyword.operator.assignment.protobuf","="], + ["text"," "], + ["constant.numeric","2"], + ["text",";"] +],[ + "start", + ["text"," "], + ["keyword.declaration.protobuf","optional"], + ["text"," "], + ["support.type","string"], + ["text"," "], + ["identifier","label"], + ["text"," "], + ["keyword.operator.assignment.protobuf","="], + ["text"," "], + ["constant.numeric","3"], + ["text",";"] +],[ + "start", + ["text","}"] +],[ + "start" +],[ + "start", + ["keyword.declaration.protobuf","message"], + ["text"," "], + ["identifier","Polyline"], + ["text"," {"] +],[ + "start", + ["text"," "], + ["keyword.declaration.protobuf","repeated"], + ["text"," "], + ["identifier","Point"], + ["text"," "], + ["identifier","point"], + ["text"," "], + ["keyword.operator.assignment.protobuf","="], + ["text"," "], + ["constant.numeric","1"], + ["text",";"] +],[ + "start", + ["text"," "], + ["keyword.declaration.protobuf","optional"], + ["text"," "], + ["support.type","string"], + ["text"," "], + ["identifier","label"], + ["text"," "], + ["keyword.operator.assignment.protobuf","="], + ["text"," "], + ["constant.numeric","2"], + ["text",";"] +],[ + "start", + ["text","}"] +]] \ No newline at end of file diff --git a/lib/ace/mode/_test/tokens_rhtml.json b/lib/ace/mode/_test/tokens_rhtml.json index e3c1fdf1..a536f851 100644 --- a/lib/ace/mode/_test/tokens_rhtml.json +++ b/lib/ace/mode/_test/tokens_rhtml.json @@ -1,55 +1,55 @@ [[ "start", - ["meta.tag","<"], - ["meta.tag.tag-name","html"], - ["meta.tag.r",">"] + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","html"], + ["meta.tag.punctuation.tag-close.xml",">"] ],[ "start" ],[ "start", - ["meta.tag","<"], - ["meta.tag.tag-name","head"], - ["meta.tag.r",">"] + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","head"], + ["meta.tag.punctuation.tag-close.xml",">"] ],[ "start", - ["meta.tag","<"], - ["meta.tag.tag-name","title"], - ["meta.tag.r",">"], - ["text","Title"], - ["meta.tag",""] + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","title"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["text.xml","Title"], + ["meta.tag.punctuation.end-tag-open.xml",""] ],[ "start", - ["meta.tag",""] + ["meta.tag.punctuation.end-tag-open.xml",""] ],[ "start" ],[ "start", - ["meta.tag","<"], - ["meta.tag.tag-name","body"], - ["meta.tag.r",">"] + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","body"], + ["meta.tag.punctuation.tag-close.xml",">"] ],[ "start" ],[ "start", - ["meta.tag","<"], - ["meta.tag.tag-name","p"], - ["meta.tag.r",">"], - ["text","This is an R HTML document. When you click the "], - ["meta.tag","<"], - ["meta.tag.tag-name","b"], - ["meta.tag.r",">"], - ["text","Knit HTML"], - ["meta.tag",""], - ["text"," button a web page will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:"], - ["meta.tag",""] + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","p"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["text.xml","This is an R HTML document. When you click the "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","b"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["text.xml","Knit HTML"], + ["meta.tag.punctuation.end-tag-open.xml",""], + ["text.xml"," button a web page will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:"], + ["meta.tag.punctuation.end-tag-open.xml",""] ],[ "start" ],[ @@ -68,13 +68,13 @@ "start" ],[ "start", - ["meta.tag","<"], - ["meta.tag.tag-name","p"], - ["meta.tag.r",">"], - ["text","You can also embed plots, for example:"], - ["meta.tag",""] + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","p"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["text.xml","You can also embed plots, for example:"], + ["meta.tag.punctuation.end-tag-open.xml",""] ],[ "start" ],[ @@ -93,14 +93,14 @@ "start" ],[ "start", - ["meta.tag",""] + ["meta.tag.punctuation.end-tag-open.xml",""] ],[ "start", - ["meta.tag",""] + ["meta.tag.punctuation.end-tag-open.xml",""] ],[ "start" ]] \ No newline at end of file diff --git a/lib/ace/mode/_test/tokens_ruby.json b/lib/ace/mode/_test/tokens_ruby.json index 19b98b70..f9991e9c 100644 --- a/lib/ace/mode/_test/tokens_ruby.json +++ b/lib/ace/mode/_test/tokens_ruby.json @@ -139,14 +139,24 @@ ["text"," "], ["punctuation.separator.key-value","=>"], ["text"," "], - ["constant.numeric","34"], + ["string.character","?\""], ["text",", "], ["constant.other.symbol.ruby",":key"], ["text"," "], ["punctuation.separator.key-value","=>"], ["text"," "], - ["string","\"value\""], - ["paren.rparen","}"] + ["string.start","\""], + ["string","value"], + ["string.end","\""], + ["text",", "], + ["identifier","anotherKey"], + ["text",": "], + ["paren.lparen","["], + ["identifier","x"], + ["text",", "], + ["identifier","y"], + ["text","?"], + ["paren.rparen","]}"] ],[ "start" ],[ diff --git a/lib/ace/mode/_test/tokens_rust.json b/lib/ace/mode/_test/tokens_rust.json index 6592575b..8c59a3aa 100644 --- a/lib/ace/mode/_test/tokens_rust.json +++ b/lib/ace/mode/_test/tokens_rust.json @@ -10,10 +10,9 @@ ],[ "start", ["keyword.source.rust","fn"], - ["meta.function.source.rust"," "], + ["text"," "], ["entity.name.function.source.rust","main"], - ["meta.function.source.rust","("], - ["text",") {"] + ["text","() {"] ],[ "start", ["text"," "], @@ -88,10 +87,14 @@ ],[ "start", ["keyword.source.rust","fn"], - ["meta.function.source.rust"," "], - ["entity.name.function.source.rust","map"], - ["meta.function.source.rust","("], - ["text","vector: &[T]"], + ["text"," "], + ["entity.name.function.source.rust","map"], + ["keyword.operator","<"], + ["text","T"], + ["keyword.operator",","], + ["text"," U"], + ["keyword.operator",">"], + ["text","(vector: &[T]"], ["keyword.operator",","], ["text"," function: &fn(v: &T) "], ["keyword.operator","->"], diff --git a/lib/ace/mode/_test/tokens_sh.json b/lib/ace/mode/_test/tokens_sh.json index 811f7db0..f2c6b276 100644 --- a/lib/ace/mode/_test/tokens_sh.json +++ b/lib/ace/mode/_test/tokens_sh.json @@ -11,13 +11,13 @@ ["comment","# Repo formats:"] ],[ "start", - ["comment","# ssh git@github.com:richoH/gh_pr.git"] + ["comment","# ssh git@github.com:richo/gh_pr.git"] ],[ "start", - ["comment","# http https://richoH@github.com/richoH/gh_pr.git"] + ["comment","# http https://richoH@github.com/richo/gh_pr.git"] ],[ "start", - ["comment","# git git://github.com/richoH/gh_pr.git"] + ["comment","# git git://github.com/richo/gh_pr.git"] ],[ "start" ],[ @@ -314,7 +314,9 @@ ["text"," "], ["support.function.builtin","echo"], ["text"," "], - ["string","\"http://github.com/$repo/pull/new/${branch##refs/heads/}\""] + ["string","\"http://github.com/"], + ["constant","$repo"], + ["string","/pull/new/${branch##refs/heads/}\""] ],[ "start", ["keyword","else"] diff --git a/lib/ace/mode/_test/tokens_sjs.json b/lib/ace/mode/_test/tokens_sjs.json new file mode 100644 index 00000000..5cd96451 --- /dev/null +++ b/lib/ace/mode/_test/tokens_sjs.json @@ -0,0 +1,276 @@ +[[ + "start", + ["storage.type","var"], + ["text"," "], + ["paren.lparen","{"], + ["text"," "], + ["identifier","each"], + ["punctuation.operator",","], + ["text"," "], + ["identifier","map"], + ["text"," "], + ["paren.rparen","}"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["identifier","require"], + ["paren.lparen","("], + ["string","'sjs:sequence'"], + ["paren.rparen",")"], + ["punctuation.operator",";"] +],[ + "start", + ["storage.type","var"], + ["text"," "], + ["paren.lparen","{"], + ["text"," "], + ["keyword","get"], + ["text"," "], + ["paren.rparen","}"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["identifier","require"], + ["paren.lparen","("], + ["string","'sjs:http'"], + ["paren.rparen",")"], + ["punctuation.operator",";"] +],[ + "start" +],[ + "start", + ["storage.type","function"], + ["text"," "], + ["entity.name.function","foo"], + ["paren.lparen","("], + ["variable.parameter","items"], + ["punctuation.operator",", "], + ["variable.parameter","nada"], + ["paren.rparen",")"], + ["text"," "], + ["paren.lparen","{"] +],[ + ["no_regex"], + ["text"," "], + ["storage.type","var"], + ["text"," "], + ["identifier","component"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["paren.lparen","{"], + ["text"," "], + ["identifier","name"], + ["punctuation.operator",":"], + ["text"," "], + ["string","\"Ace\""], + ["punctuation.operator",","], + ["text"," "], + ["identifier","role"], + ["punctuation.operator",":"], + ["text"," "], + ["string","\"Editor\""], + ["text"," "], + ["paren.rparen","}"], + ["punctuation.operator",";"] +],[ + ["qqstring","no_regex"], + ["text"," "], + ["storage.type","console"], + ["punctuation.operator","."], + ["support.function.firebug","log"], + ["paren.lparen","("], + ["string","\""] +],[ + ["qqstring","no_regex"], + ["string"," Welcome, "], + ["paren.lparen","#{"], + ["identifier","component"], + ["text","."], + ["identifier","name"], + ["paren.rparen","}"] +],[ + ["no_regex"], + ["string"," \""], + ["punctuation.operator","."], + ["identifier","trim"], + ["paren.lparen","("], + ["paren.rparen","))"], + ["punctuation.operator",";"] +],[ + ["no_regex"] +],[ + ["no_regex"], + ["text"," "], + ["identifier","logging"], + ["punctuation.operator","."], + ["identifier","debug"], + ["paren.lparen","("], + ["string","`Component added: "], + ["paren.lparen","$"], + ["identifier","String"], + ["paren.lparen","("], + ["identifier","component"], + ["paren.rparen",")"], + ["string"," ("], + ["paren.lparen","${"], + ["identifier","component"], + ["paren.rparen","}"], + ["string",")`"], + ["paren.rparen",")"], + ["punctuation.operator",";"] +],[ + ["no_regex"] +],[ + ["bstring","no_regex"], + ["text"," "], + ["storage.type","console"], + ["punctuation.operator","."], + ["support.function.firebug","log"], + ["paren.lparen","("], + ["string","`"] +],[ + ["string_interp","string_interp","bstring","no_regex"], + ["string"," Welcome, {"], + ["paren.lparen","${"], + ["storage.type","function"], + ["text","() "], + ["paren.lparen","{"] +],[ + ["string_interp","string_interp","bstring","no_regex"], + ["text"," "], + ["keyword","return"], + ["text"," "], + ["paren.lparen","{"], + ["text"," "], + ["identifier","x"], + ["text",": "], + ["constant.numeric","1"], + ["text",", "], + ["identifier","y"], + ["text",": "], + ["string","\"why?}\""], + ["paren.rparen","}"], + ["text",";"] +],[ + ["bstring","no_regex"], + ["text"," "], + ["paren.rparen","}"], + ["text","()"], + ["paren.rparen","}"] +],[ + ["no_regex"], + ["string"," `"], + ["punctuation.operator","."], + ["identifier","trim"], + ["paren.lparen","("], + ["paren.rparen","))"], + ["punctuation.operator",";"] +],[ + ["no_regex"] +],[ + ["no_regex"], + ["text"," "], + ["keyword","waitfor"], + ["text"," "], + ["paren.lparen","{"] +],[ + ["no_regex"], + ["text"," "], + ["identifier","items"], + ["text"," "], + ["keyword.operator",".."], + ["text"," "], + ["identifier","each"], + ["punctuation.operator","."], + ["identifier","par"], + ["text"," "], + ["paren.lparen","{"], + ["text"," "], + ["paren.rparen","|"], + ["variable.parameter","item"], + ["paren.rparen","|"] +],[ + ["no_regex"], + ["text"," "], + ["keyword","get"], + ["paren.lparen","("], + ["identifier","item"], + ["paren.rparen",")"], + ["punctuation.operator",";"] +],[ + ["no_regex"], + ["text"," "], + ["paren.rparen","}"] +],[ + ["no_regex"], + ["text"," "], + ["paren.rparen","}"], + ["text"," "], + ["keyword","and"], + ["text"," "], + ["paren.lparen","{"] +],[ + ["no_regex"], + ["text"," "], + ["storage.type","var"], + ["text"," "], + ["identifier","lengths"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["identifier","items"], + ["text"," "], + ["keyword.operator",".."], + ["text"," "], + ["identifier","map"], + ["paren.lparen","("], + ["identifier","i"], + ["text"," "], + ["keyword.operator","->"], + ["text"," "], + ["identifier","i"], + ["punctuation.operator","."], + ["support.constant","length"], + ["paren.rparen",")"], + ["punctuation.operator",";"] +],[ + ["no_regex"], + ["text"," "], + ["paren.rparen","}"], + ["text"," "], + ["keyword","or"], + ["text"," "], + ["paren.lparen","{"] +],[ + ["no_regex"], + ["text"," "], + ["variable.language","hold"], + ["paren.lparen","("], + ["constant.numeric","1500"], + ["paren.rparen",")"], + ["punctuation.operator",";"] +],[ + ["no_regex"], + ["text"," "], + ["keyword","throw"], + ["text"," "], + ["keyword","new"], + ["text"," "], + ["variable.language","Error"], + ["paren.lparen","("], + ["string","\"timed out\""], + ["paren.rparen",")"], + ["punctuation.operator",";"] +],[ + ["no_regex"], + ["text"," "], + ["paren.rparen","}"] +],[ + ["no_regex"], + ["paren.rparen","}"], + ["text","\t"], + ["comment","// Real Tab."] +],[ + ["no_regex"] +]] \ No newline at end of file diff --git a/lib/ace/mode/_test/tokens_smarty.json b/lib/ace/mode/_test/tokens_smarty.json new file mode 100644 index 00000000..0f56985d --- /dev/null +++ b/lib/ace/mode/_test/tokens_smarty.json @@ -0,0 +1,98 @@ +[[ + "start", + ["punctuation.section.embedded.begin.smarty","{"], + ["keyword.control.smarty","foreach"], + ["source.smarty"," "], + ["punctuation.definition.variable.smarty","$"], + ["variable.other.smarty","foo"], + ["source.smarty"," as "], + ["punctuation.definition.variable.smarty","$"], + ["variable.other.smarty","bar"], + ["punctuation.section.embedded.end.smarty","}"] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.anchor.tag-name.xml","a"], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","href"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\""], + ["punctuation.section.embedded.begin.smarty","{"], + ["punctuation.definition.variable.smarty","$"], + ["variable.other.smarty","bar"], + ["source.smarty",".zig"], + ["punctuation.section.embedded.end.smarty","}"], + ["string.attribute-value.xml","\""], + ["meta.tag.punctuation.tag-close.xml",">"], + ["punctuation.section.embedded.begin.smarty","{"], + ["punctuation.definition.variable.smarty","$"], + ["variable.other.smarty","bar"], + ["source.smarty",".zag"], + ["punctuation.section.embedded.end.smarty","}"], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.anchor.tag-name.xml","a"], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","href"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\""], + ["punctuation.section.embedded.begin.smarty","{"], + ["punctuation.definition.variable.smarty","$"], + ["variable.other.smarty","bar"], + ["source.smarty",".zig2"], + ["punctuation.section.embedded.end.smarty","}"], + ["string.attribute-value.xml","\""], + ["meta.tag.punctuation.tag-close.xml",">"], + ["punctuation.section.embedded.begin.smarty","{"], + ["punctuation.definition.variable.smarty","$"], + ["variable.other.smarty","bar"], + ["source.smarty",".zag2"], + ["punctuation.section.embedded.end.smarty","}"], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.anchor.tag-name.xml","a"], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","href"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\""], + ["punctuation.section.embedded.begin.smarty","{"], + ["punctuation.definition.variable.smarty","$"], + ["variable.other.smarty","bar"], + ["source.smarty",".zig3"], + ["punctuation.section.embedded.end.smarty","}"], + ["string.attribute-value.xml","\""], + ["meta.tag.punctuation.tag-close.xml",">"], + ["punctuation.section.embedded.begin.smarty","{"], + ["punctuation.definition.variable.smarty","$"], + ["variable.other.smarty","bar"], + ["source.smarty",".zag3"], + ["punctuation.section.embedded.end.smarty","}"], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["punctuation.section.embedded.begin.smarty","{"], + ["keyword.control.smarty","foreachelse"], + ["punctuation.section.embedded.end.smarty","}"] +],[ + "start", + ["text.xml"," There were no rows found."] +],[ + "start", + ["punctuation.section.embedded.begin.smarty","{"], + ["source.smarty","/"], + ["keyword.control.smarty","foreach"], + ["punctuation.section.embedded.end.smarty","}"] +]] \ No newline at end of file diff --git a/lib/ace/mode/_test/tokens_snippets.json b/lib/ace/mode/_test/tokens_snippets.json index f695403d..308683b7 100644 --- a/lib/ace/mode/_test/tokens_snippets.json +++ b/lib/ace/mode/_test/tokens_snippets.json @@ -1,14 +1,10 @@ [[ "start", ["comment","# Function"] -],[ - "start" ],[ "start", ["constant.language.escape","snippet"], ["text"," fun"] -],[ - "start" ],[ "sn-start", ["text","\tfunction "], @@ -23,8 +19,6 @@ ["text","argument"], ["markup.list","}"], ["text",") {"] -],[ - "start" ],[ "sn-start", ["text","\t\t"], @@ -33,18 +27,12 @@ ["punctuation.operator",":"], ["text","// body..."], ["markup.list","}"] -],[ - "start" ],[ "sn-start", ["text","\t}"] -],[ - "start" ],[ "start", ["comment","# Anonymous Function"] -],[ - "start" ],[ "start", ["constant.language.escape","regex "], @@ -55,14 +43,10 @@ ["keyword","/"], ["text","(\\))?"], ["keyword","/"] -],[ - "start" ],[ "start", ["constant.language.escape","name"], ["text"," f"] -],[ - "start" ],[ "sn-start", ["text","\tfunction"], @@ -77,8 +61,6 @@ ["text","("], ["variable","$2"], ["text",") {"] -],[ - "start" ],[ "sn-start", ["text","\t\t"], @@ -87,8 +69,6 @@ ["punctuation.operator",":"], ["keyword","$TM_SELECTED_TEXT"], ["markup.list","}"] -],[ - "start" ],[ "sn-start", ["text","\t}"], @@ -102,31 +82,21 @@ ["variable","M4"], ["text","?)"], ["markup.list","}"] -],[ - "start" ],[ "start", ["comment","# Immediate function"] -],[ - "start" ],[ "start", ["constant.language.escape","trigger"], ["text"," \\(?f\\("] -],[ - "start" ],[ "start", ["constant.language.escape","endTrigger"], ["text"," \\)?"] -],[ - "start" ],[ "start", ["constant.language.escape","snippet"], ["text"," f("] -],[ - "start" ],[ "sn-start", ["text","\t(function("], @@ -134,8 +104,6 @@ ["constant.numeric","1"], ["markup.list","}"], ["text",") {"] -],[ - "start" ],[ "sn-start", ["text","\t\t"], @@ -147,8 +115,6 @@ ["punctuation.operator",":"], ["text","/* code */"], ["markup.list","}}"] -],[ - "start" ],[ "sn-start", ["text","\t}("], @@ -156,19 +122,13 @@ ["constant.numeric","1"], ["markup.list","}"], ["text","));"] -],[ - "start" ],[ "start", ["comment","# if"] -],[ - "start" ],[ "start", ["constant.language.escape","snippet"], ["text"," if"] -],[ - "start" ],[ "sn-start", ["text","\tif ("], @@ -178,31 +138,21 @@ ["text","true"], ["markup.list","}"], ["text",") {"] -],[ - "start" ],[ "sn-start", ["text","\t\t"], ["markup.list","${"], ["constant.numeric","0"], ["markup.list","}"] -],[ - "start" ],[ "sn-start", ["text","\t}"] -],[ - "start" ],[ "sn-start", ["text","\t"] -],[ - "start" ],[ "sn-start", ["text","\t"] -],[ - "start" ],[ "sn-start", ["text","\t"] diff --git a/lib/ace/mode/_test/tokens_soy_template.json b/lib/ace/mode/_test/tokens_soy_template.json new file mode 100644 index 00000000..9ae7c4ed --- /dev/null +++ b/lib/ace/mode/_test/tokens_soy_template.json @@ -0,0 +1,286 @@ +[[ + "punctuation.definition.comment.begin.soy1", + ["punctuation.definition.comment.begin.soy","/**"] +],[ + "punctuation.definition.comment.begin.soy1", + ["comment.block.documentation.soy"," * Greets a person using \"Hello\" by default."] +],[ + "punctuation.definition.comment.begin.soy1", + ["comment.block.documentation.soy"," * "], + ["support.type.soy","@param"], + ["text"," "], + ["variable.parameter.soy","name"], + ["comment.block.documentation.soy"," The name of the person."] +],[ + "punctuation.definition.comment.begin.soy1", + ["comment.block.documentation.soy"," * "], + ["support.type.soy","@param?"], + ["text"," "], + ["variable.parameter.soy","greetingWord"], + ["comment.block.documentation.soy"," Optional greeting word to use instead of \"Hello\"."] +],[ + "start", + ["comment.block.documentation.soy"," "], + ["punctuation.definition.comment.end.soy","*/"] +],[ + "start", + ["punctuation.definition.tag.begin.soy","{"], + ["entity.name.tag.soy","template"], + ["text"," "], + ["entity.name.function.soy",".helloName"], + ["meta.tag.template.soy"," #eee"], + ["punctuation.definition.tag.end.soy","}"] +],[ + "start", + ["text.xml"," "], + ["punctuation.definition.tag.begin.soy","{"], + ["entity.name.tag.soy","if"], + ["meta.tag.if.soy"," "], + ["keyword.operator.soy","not"], + ["meta.tag.if.soy"," "], + ["variable.other.soy","$greetingWord"], + ["punctuation.definition.tag.end.soy","}"] +],[ + "start", + ["text.xml"," Hello "], + ["punctuation.definition.tag.begin.soy","{"], + ["variable.other.soy","$name"], + ["punctuation.definition.tag.end.soy","}"], + ["text.xml","!"] +],[ + "start", + ["text.xml"," "], + ["punctuation.definition.tag.begin.soy","{"], + ["text","else"], + ["punctuation.definition.tag.end.soy","}"] +],[ + "start", + ["text.xml"," "], + ["punctuation.definition.tag.begin.soy","{"], + ["variable.other.soy","$greetingWord"], + ["punctuation.definition.tag.end.soy","}"], + ["text.xml"," "], + ["punctuation.definition.tag.begin.soy","{"], + ["variable.other.soy","$name"], + ["punctuation.definition.tag.end.soy","}"], + ["text.xml","!"] +],[ + "start", + ["text.xml"," "], + ["punctuation.definition.tag.begin.soy","{/"], + ["entity.name.tag.soy","if"], + ["punctuation.definition.tag.end.soy","}"] +],[ + "start", + ["punctuation.definition.tag.begin.soy","{/"], + ["meta.tag.template.soy","template"], + ["punctuation.definition.tag.end.soy","}"] +],[ + "start" +],[ + "punctuation.definition.comment.begin.soy1", + ["punctuation.definition.comment.begin.soy","/**"] +],[ + "punctuation.definition.comment.begin.soy1", + ["comment.block.documentation.soy"," * Greets a person and optionally a list of other people."] +],[ + "punctuation.definition.comment.begin.soy1", + ["comment.block.documentation.soy"," * "], + ["support.type.soy","@param"], + ["text"," "], + ["variable.parameter.soy","name"], + ["comment.block.documentation.soy"," The name of the person."] +],[ + "punctuation.definition.comment.begin.soy1", + ["comment.block.documentation.soy"," * "], + ["support.type.soy","@param"], + ["text"," "], + ["variable.parameter.soy","additionalNames"], + ["comment.block.documentation.soy"," The additional names to greet. May be an empty list."] +],[ + "start", + ["comment.block.documentation.soy"," "], + ["punctuation.definition.comment.end.soy","*/"] +],[ + "start", + ["punctuation.definition.tag.begin.soy","{"], + ["entity.name.tag.soy","template"], + ["text"," "], + ["entity.name.function.soy",".helloNames"], + ["punctuation.definition.tag.end.soy","}"] +],[ + "start", + ["comment.line.double-slash.soy"," "], + ["punctuation.definition.comment.soy","//"], + ["comment.line.double-slash.soy"," Greet the person."] +],[ + "start", + ["text.xml"," "], + ["punctuation.definition.tag.begin.soy","{"], + ["entity.name.tag.soy","call"], + ["variable.parameter.soy"," .helloName"], + ["meta.tag.call.soy"," "], + ["entity.other.attribute-name.soy","data"], + ["keyword.operator.soy","="], + ["string.quoted.double","\"all\""], + ["meta.tag.call.soy"," /"], + ["punctuation.definition.tag.end.soy","}"], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","br"], + ["meta.tag.punctuation.tag-close.xml",">"] +],[ + "start", + ["comment.line.double-slash.soy"," "], + ["punctuation.definition.comment.soy","//"], + ["comment.line.double-slash.soy"," Greet the additional people."] +],[ + "start", + ["text.xml"," "], + ["punctuation.definition.tag.begin.soy","{"], + ["entity.name.tag.soy","foreach"], + ["meta.tag.foreach.soy"," "], + ["variable.other.soy","$additionalName"], + ["meta.tag.foreach.soy"," "], + ["keyword.operator.soy","in"], + ["meta.tag.foreach.soy"," "], + ["variable.other.soy","$additionalNames"], + ["punctuation.definition.tag.end.soy","}"] +],[ + "start", + ["text.xml"," "], + ["punctuation.definition.tag.begin.soy","{"], + ["entity.name.tag.soy","call"], + ["variable.parameter.soy"," .helloName"], + ["punctuation.definition.tag.end.soy","}"] +],[ + "start", + ["text.xml"," "], + ["punctuation.definition.tag.begin.soy","{"], + ["entity.name.tag.soy","param"], + ["meta.tag.param.soy"," "], + ["entity.other.attribute-name.soy","name"], + ["keyword.operator.soy",":"], + ["meta.tag.param.soy"," "], + ["variable.other.soy","$additionalName"], + ["meta.tag.param.soy"," /"], + ["punctuation.definition.tag.end.soy","}"] +],[ + "start", + ["text.xml"," "], + ["punctuation.definition.tag.begin.soy","{/"], + ["meta.tag.call.soy","call"], + ["punctuation.definition.tag.end.soy","}"] +],[ + "start", + ["text.xml"," "], + ["punctuation.definition.tag.begin.soy","{"], + ["entity.name.tag.soy","if"], + ["meta.tag.if.soy"," "], + ["keyword.operator.soy","not"], + ["meta.tag.if.soy"," "], + ["support.function.soy","isLast"], + ["meta.tag.if.soy","("], + ["variable.other.soy","$additionalName"], + ["meta.tag.if.soy",")"], + ["punctuation.definition.tag.end.soy","}"] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","br"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["comment.line.double-slash.soy"," "], + ["punctuation.definition.comment.soy","//"], + ["comment.line.double-slash.soy"," break after every line except the last"] +],[ + "start", + ["text.xml"," "], + ["punctuation.definition.tag.begin.soy","{/"], + ["entity.name.tag.soy","if"], + ["punctuation.definition.tag.end.soy","}"] +],[ + "start", + ["text.xml"," "], + ["punctuation.definition.tag.begin.soy","{"], + ["text","ifempty"], + ["punctuation.definition.tag.end.soy","}"] +],[ + "start", + ["text.xml"," No additional people to greet."] +],[ + "start", + ["text.xml"," "], + ["punctuation.definition.tag.begin.soy","{/"], + ["entity.name.tag.soy","foreach"], + ["punctuation.definition.tag.end.soy","}"] +],[ + "start", + ["punctuation.definition.tag.begin.soy","{/"], + ["meta.tag.template.soy","template"], + ["punctuation.definition.tag.end.soy","}"] +],[ + "start" +],[ + "start" +],[ + "start", + ["punctuation.definition.tag.begin.soy","{/"], + ["entity.name.tag.soy","foreach"], + ["punctuation.definition.tag.end.soy","}"] +],[ + "start", + ["punctuation.definition.tag.begin.soy","{"], + ["entity.name.tag.soy","if"], + ["meta.tag.if.soy"," "], + ["support.function.soy","length"], + ["meta.tag.if.soy","("], + ["variable.other.soy","$items"], + ["meta.tag.if.soy",") > 5"], + ["punctuation.definition.tag.end.soy","}"] +],[ + "start", + ["punctuation.definition.tag.begin.soy","{"], + ["entity.name.tag.soy","msg"], + ["meta.tag.msg.soy"," "], + ["entity.other.attribute-name.soy","desc"], + ["keyword.operator.soy","="], + ["string.quoted.double","\"Says hello to the user.\""], + ["punctuation.definition.tag.end.soy","}"] +],[ + "start" +],[ + "start" +],[ + "start", + ["punctuation.definition.tag.begin.soy","{"], + ["entity.name.tag.soy","namespace"], + ["text"," "], + ["variable.parameter.soy","ns"], + ["text"," autoescape=\"contextual\""], + ["punctuation.definition.tag.end.soy","}"] +],[ + "start" +],[ + "start", + ["punctuation.definition.comment.begin.soy","/**"], + ["comment.block.documentation.soy"," Example. "], + ["punctuation.definition.comment.end.soy","*/"] +],[ + "start", + ["punctuation.definition.tag.begin.soy","{"], + ["entity.name.tag.soy","template"], + ["text"," "], + ["entity.name.function.soy",".example"], + ["punctuation.definition.tag.end.soy","}"] +],[ + "start", + ["text.xml"," foo is "], + ["punctuation.definition.tag.begin.soy","{"], + ["variable.other.soy","$ij.foo"], + ["punctuation.definition.tag.end.soy","}"] +],[ + "start", + ["punctuation.definition.tag.begin.soy","{/"], + ["meta.tag.template.soy","template"], + ["punctuation.definition.tag.end.soy","}"] +]] \ No newline at end of file diff --git a/lib/ace/mode/_test/tokens_space.json b/lib/ace/mode/_test/tokens_space.json new file mode 100644 index 00000000..918b9a67 --- /dev/null +++ b/lib/ace/mode/_test/tokens_space.json @@ -0,0 +1,322 @@ +[[ + "start", + ["variable","query"] +],[ + "start", + ["empty_line"," "], + ["variable","count"], + ["keyword.operator"," "], + ["string","10"] +],[ + "start", + ["empty_line"," "], + ["variable","created"], + ["keyword.operator"," "], + ["string","2011-06-21T08:10:46Z"] +],[ + "start", + ["empty_line"," "], + ["variable","lang"], + ["keyword.operator"," "], + ["string","en-US"] +],[ + "start", + ["empty_line"," "], + ["variable","results"] +],[ + "start", + ["empty_line"," "], + ["variable","photo"] +],[ + "start", + ["empty_line"," "], + ["variable","0"] +],[ + "start", + ["empty_line"," "], + ["variable","farm"], + ["keyword.operator"," "], + ["string","6"] +],[ + "start", + ["empty_line"," "], + ["variable","id"], + ["keyword.operator"," "], + ["string","5855620975"] +],[ + "start", + ["empty_line"," "], + ["variable","isfamily"], + ["keyword.operator"," "], + ["string","0"] +],[ + "start", + ["empty_line"," "], + ["variable","isfriend"], + ["keyword.operator"," "], + ["string","0"] +],[ + "start", + ["empty_line"," "], + ["variable","ispublic"], + ["keyword.operator"," "], + ["string","1"] +],[ + "start", + ["empty_line"," "], + ["variable","owner"], + ["keyword.operator"," "], + ["string","32021554@N04"] +],[ + "start", + ["empty_line"," "], + ["variable","secret"], + ["keyword.operator"," "], + ["string","f1f5e8515d"] +],[ + "start", + ["empty_line"," "], + ["variable","server"], + ["keyword.operator"," "], + ["string","5110"] +],[ + "start", + ["empty_line"," "], + ["variable","title"], + ["keyword.operator"," "], + ["string","7087 bandit cat"] +],[ + "start", + ["empty_line"," "], + ["variable","1"] +],[ + "start", + ["empty_line"," "], + ["variable","farm"], + ["keyword.operator"," "], + ["string","4"] +],[ + "start", + ["empty_line"," "], + ["variable","id"], + ["keyword.operator"," "], + ["string","5856170534"] +],[ + "start", + ["empty_line"," "], + ["variable","isfamily"], + ["keyword.operator"," "], + ["string","0"] +],[ + "start", + ["empty_line"," "], + ["variable","isfriend"], + ["keyword.operator"," "], + ["string","0"] +],[ + "start", + ["empty_line"," "], + ["variable","ispublic"], + ["keyword.operator"," "], + ["string","1"] +],[ + "start", + ["empty_line"," "], + ["variable","owner"], + ["keyword.operator"," "], + ["string","32021554@N04"] +],[ + "start", + ["empty_line"," "], + ["variable","secret"], + ["keyword.operator"," "], + ["string","ff1efb2a6f"] +],[ + "start", + ["empty_line"," "], + ["variable","server"], + ["keyword.operator"," "], + ["string","3217"] +],[ + "start", + ["empty_line"," "], + ["variable","title"], + ["keyword.operator"," "], + ["string","6975 rusty cat"] +],[ + "start", + ["empty_line"," "], + ["variable","2"] +],[ + "start", + ["empty_line"," "], + ["variable","farm"], + ["keyword.operator"," "], + ["string","6"] +],[ + "start", + ["empty_line"," "], + ["variable","id"], + ["keyword.operator"," "], + ["string","5856172972"] +],[ + "start", + ["empty_line"," "], + ["variable","isfamily"], + ["keyword.operator"," "], + ["string","0"] +],[ + "start", + ["empty_line"," "], + ["variable","isfriend"], + ["keyword.operator"," "], + ["string","0"] +],[ + "start", + ["empty_line"," "], + ["variable","ispublic"], + ["keyword.operator"," "], + ["string","1"] +],[ + "start", + ["empty_line"," "], + ["variable","owner"], + ["keyword.operator"," "], + ["string","51249875@N03"] +],[ + "start", + ["empty_line"," "], + ["variable","secret"], + ["keyword.operator"," "], + ["string","6c6887347c"] +],[ + "start", + ["empty_line"," "], + ["variable","server"], + ["keyword.operator"," "], + ["string","5192"] +],[ + "start", + ["empty_line"," "], + ["variable","title"], + ["keyword.operator"," "], + ["string","watermarked-cats"] +],[ + "start", + ["empty_line"," "], + ["variable","3"] +],[ + "start", + ["empty_line"," "], + ["variable","farm"], + ["keyword.operator"," "], + ["string","6"] +],[ + "start", + ["empty_line"," "], + ["variable","id"], + ["keyword.operator"," "], + ["string","5856168328"] +],[ + "start", + ["empty_line"," "], + ["variable","isfamily"], + ["keyword.operator"," "], + ["string","0"] +],[ + "start", + ["empty_line"," "], + ["variable","isfriend"], + ["keyword.operator"," "], + ["string","0"] +],[ + "start", + ["empty_line"," "], + ["variable","ispublic"], + ["keyword.operator"," "], + ["string","1"] +],[ + "start", + ["empty_line"," "], + ["variable","owner"], + ["keyword.operator"," "], + ["string","32021554@N04"] +],[ + "start", + ["empty_line"," "], + ["variable","secret"], + ["keyword.operator"," "], + ["string","0c1cfdf64c"] +],[ + "start", + ["empty_line"," "], + ["variable","server"], + ["keyword.operator"," "], + ["string","5078"] +],[ + "start", + ["empty_line"," "], + ["variable","title"], + ["keyword.operator"," "], + ["string","7020 mandy cat"] +],[ + "start", + ["empty_line"," "], + ["variable","4"] +],[ + "start", + ["empty_line"," "], + ["variable","farm"], + ["keyword.operator"," "], + ["string","3"] +],[ + "start", + ["empty_line"," "], + ["variable","id"], + ["keyword.operator"," "], + ["string","5856171774"] +],[ + "start", + ["empty_line"," "], + ["variable","isfamily"], + ["keyword.operator"," "], + ["string","0"] +],[ + "start", + ["empty_line"," "], + ["variable","isfriend"], + ["keyword.operator"," "], + ["string","0"] +],[ + "start", + ["empty_line"," "], + ["variable","ispublic"], + ["keyword.operator"," "], + ["string","1"] +],[ + "start", + ["empty_line"," "], + ["variable","owner"], + ["keyword.operator"," "], + ["string","32021554@N04"] +],[ + "start", + ["empty_line"," "], + ["variable","secret"], + ["keyword.operator"," "], + ["string","7f5a3180ab"] +],[ + "start", + ["empty_line"," "], + ["variable","server"], + ["keyword.operator"," "], + ["string","2696"] +],[ + "start", + ["empty_line"," "], + ["variable","title"], + ["keyword.operator"," "], + ["string","7448 bobby cat"] +],[ + "key" +]] \ No newline at end of file diff --git a/lib/ace/mode/_test/tokens_svg.json b/lib/ace/mode/_test/tokens_svg.json index efaa0fca..66ebae75 100644 --- a/lib/ace/mode/_test/tokens_svg.json +++ b/lib/ace/mode/_test/tokens_svg.json @@ -1,68 +1,65 @@ [[ - "tag_embed_attribute_list", - ["meta.tag","<"], - ["meta.tag.tag-name","svg"] + "meta.tag.punctuation.tag-open.xml1", + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","svg"] ],[ - "tag_embed_attribute_list", - ["text"," "], - ["entity.other.attribute-name","width"], - ["keyword.operator","="], - ["string","\"800\""], - ["text"," "], - ["entity.other.attribute-name","height"], - ["keyword.operator","="], - ["string","\"600\""] + "meta.tag.punctuation.tag-open.xml1", + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","width"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"800\""], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","height"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"600\""] ],[ - "tag_embed_attribute_list", - ["text"," "], - ["entity.other.attribute-name","xmlns"], - ["keyword.operator","="], - ["string","\"http://www.w3.org/2000/svg\""] + "meta.tag.punctuation.tag-open.xml1", + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","xmlns"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"http://www.w3.org/2000/svg\""] ],[ "start", - ["text"," "], - ["entity.other.attribute-name","onload"], - ["keyword.operator","="], - ["string","\"StartAnimation(evt)\""], - ["meta.tag.r",">"] + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","onload"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"StartAnimation(evt)\""], + ["meta.tag.punctuation.tag-close.xml",">"] ],[ "start" ],[ "start", - ["text"," "], - ["meta.tag","<"], - ["meta.tag.tag-name","title"], - ["meta.tag.r",">"], - ["text","Test Tube Progress Bar"], - ["meta.tag",""] + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","title"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["text.xml","Test Tube Progress Bar"], + ["meta.tag.punctuation.end-tag-open.xml",""] ],[ "start", - ["text"," "], - ["meta.tag","<"], - ["meta.tag.tag-name","desc"], - ["meta.tag.r",">"], - ["text","Created for the Web Directions SVG competition"], - ["meta.tag",""] + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","desc"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["text.xml","Created for the Web Directions SVG competition"], + ["meta.tag.punctuation.end-tag-open.xml",""] ],[ "start" ],[ - "js-start", - ["text"," "], - ["meta.tag","<"], - ["meta.tag.tag-name","script"], - ["text"," "], - ["entity.other.attribute-name","type"], - ["keyword.operator","="], - ["string","\"text/ecmascript\""], - ["meta.tag.r",">"], - ["keyword.operator",""], + ["string.cdata.xml",""], - ["meta.tag",""] + ["string.cdata.xml","]]>"], + ["meta.tag.punctuation.end-tag-open.xml",""] ],[ "start" ],[ - "tag_embed_attribute_list", - ["text"," "], - ["meta.tag","<"], - ["meta.tag.tag-name","rect"] + "meta.tag.punctuation.tag-open.xml1", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","rect"] ],[ - "tag_embed_attribute_list", - ["text"," "], - ["entity.other.attribute-name","fill"], - ["keyword.operator","="], - ["string","\"#2e3436\""] + "meta.tag.punctuation.tag-open.xml1", + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","fill"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"#2e3436\""] ],[ - "tag_embed_attribute_list", - ["text"," "], - ["entity.other.attribute-name","fill-rule"], - ["keyword.operator","="], - ["string","\"nonzero\""] + "meta.tag.punctuation.tag-open.xml1", + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","fill-rule"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"nonzero\""] ],[ - "tag_embed_attribute_list", - ["text"," "], - ["entity.other.attribute-name","stroke-width"], - ["keyword.operator","="], - ["string","\"3\""] + "meta.tag.punctuation.tag-open.xml1", + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","stroke-width"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"3\""] ],[ - "tag_embed_attribute_list", - ["text"," "], - ["entity.other.attribute-name","y"], - ["keyword.operator","="], - ["string","\"0\""] + "meta.tag.punctuation.tag-open.xml1", + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","y"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"0\""] ],[ - "tag_embed_attribute_list", - ["text"," "], - ["entity.other.attribute-name","x"], - ["keyword.operator","="], - ["string","\"0\""] + "meta.tag.punctuation.tag-open.xml1", + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","x"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"0\""] ],[ - "tag_embed_attribute_list", - ["text"," "], - ["entity.other.attribute-name","height"], - ["keyword.operator","="], - ["string","\"600\""] + "meta.tag.punctuation.tag-open.xml1", + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","height"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"600\""] ],[ - "tag_embed_attribute_list", - ["text"," "], - ["entity.other.attribute-name","width"], - ["keyword.operator","="], - ["string","\"800\""] + "meta.tag.punctuation.tag-open.xml1", + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","width"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"800\""] ],[ "start", - ["text"," "], - ["entity.other.attribute-name","id"], - ["keyword.operator","="], - ["string","\"rect3590\""], - ["meta.tag.r","/>"] + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","id"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"rect3590\""], + ["meta.tag.punctuation.tag-close.xml","/>"] ],[ "start" ],[ - "tag_embed_attribute_list", - ["text"," "], - ["meta.tag","<"], - ["meta.tag.tag-name","text"] + "meta.tag.punctuation.tag-open.xml1", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","text"] ],[ - "tag_embed_attribute_list", - ["text"," "], - ["entity.other.attribute-name","style"], - ["keyword.operator","="], - ["string","\"font-size:144px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans Bold\""] + "meta.tag.punctuation.tag-open.xml1", + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","style"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"font-size:144px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans Bold\""] ],[ - "tag_embed_attribute_list", - ["text"," "], - ["entity.other.attribute-name","x"], - ["keyword.operator","="], - ["string","\"50\""] + "meta.tag.punctuation.tag-open.xml1", + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","x"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"50\""] ],[ - "tag_embed_attribute_list", - ["text"," "], - ["entity.other.attribute-name","y"], - ["keyword.operator","="], - ["string","\"350\""] + "meta.tag.punctuation.tag-open.xml1", + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","y"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"350\""] ],[ - "tag_embed_attribute_list", - ["text"," "], - ["entity.other.attribute-name","id"], - ["keyword.operator","="], - ["string","\"hickory\""] + "meta.tag.punctuation.tag-open.xml1", + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","id"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"hickory\""] ],[ "start", - ["text"," "], - ["entity.other.attribute-name","display"], - ["keyword.operator","="], - ["string","\"none\""], - ["meta.tag.r",">"] + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","display"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"none\""], + ["meta.tag.punctuation.tag-close.xml",">"] ],[ "start", - ["text"," Hickory,"], - ["meta.tag",""] + ["text.xml"," Hickory,"], + ["meta.tag.punctuation.end-tag-open.xml",""] ],[ - "tag_embed_attribute_list", - ["text"," "], - ["meta.tag","<"], - ["meta.tag.tag-name","text"] + "meta.tag.punctuation.tag-open.xml1", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","text"] ],[ - "tag_embed_attribute_list", - ["text"," "], - ["entity.other.attribute-name","style"], - ["keyword.operator","="], - ["string","\"font-size:144px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans Bold\""] + "meta.tag.punctuation.tag-open.xml1", + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","style"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"font-size:144px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans Bold\""] ],[ - "tag_embed_attribute_list", - ["text"," "], - ["entity.other.attribute-name","x"], - ["keyword.operator","="], - ["string","\"50\""] + "meta.tag.punctuation.tag-open.xml1", + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","x"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"50\""] ],[ - "tag_embed_attribute_list", - ["text"," "], - ["entity.other.attribute-name","y"], - ["keyword.operator","="], - ["string","\"350\""] + "meta.tag.punctuation.tag-open.xml1", + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","y"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"350\""] ],[ - "tag_embed_attribute_list", - ["text"," "], - ["entity.other.attribute-name","id"], - ["keyword.operator","="], - ["string","\"dickory\""] + "meta.tag.punctuation.tag-open.xml1", + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","id"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"dickory\""] ],[ "start", - ["text"," "], - ["entity.other.attribute-name","display"], - ["keyword.operator","="], - ["string","\"none\""], - ["meta.tag.r",">"] + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","display"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"none\""], + ["meta.tag.punctuation.tag-close.xml",">"] ],[ "start", - ["text"," dickory,"], - ["meta.tag",""] + ["text.xml"," dickory,"], + ["meta.tag.punctuation.end-tag-open.xml",""] ],[ - "tag_embed_attribute_list", - ["text"," "], - ["meta.tag","<"], - ["meta.tag.tag-name","text"] + "meta.tag.punctuation.tag-open.xml1", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","text"] ],[ - "tag_embed_attribute_list", - ["text"," "], - ["entity.other.attribute-name","style"], - ["keyword.operator","="], - ["string","\"font-size:144px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans Bold\""] + "meta.tag.punctuation.tag-open.xml1", + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","style"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"font-size:144px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans Bold\""] ],[ - "tag_embed_attribute_list", - ["text"," "], - ["entity.other.attribute-name","x"], - ["keyword.operator","="], - ["string","\"50\""] + "meta.tag.punctuation.tag-open.xml1", + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","x"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"50\""] ],[ - "tag_embed_attribute_list", - ["text"," "], - ["entity.other.attribute-name","y"], - ["keyword.operator","="], - ["string","\"350\""] + "meta.tag.punctuation.tag-open.xml1", + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","y"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"350\""] ],[ - "tag_embed_attribute_list", - ["text"," "], - ["entity.other.attribute-name","id"], - ["keyword.operator","="], - ["string","\"dock\""] + "meta.tag.punctuation.tag-open.xml1", + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","id"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"dock\""] ],[ "start", - ["text"," "], - ["entity.other.attribute-name","display"], - ["keyword.operator","="], - ["string","\"none\""], - ["meta.tag.r",">"] + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","display"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"none\""], + ["meta.tag.punctuation.tag-close.xml",">"] ],[ "start", - ["text"," dock!"], - ["meta.tag",""] + ["text.xml"," dock!"], + ["meta.tag.punctuation.end-tag-open.xml",""] ],[ "start", - ["meta.tag",""] + ["meta.tag.punctuation.end-tag-open.xml",""] ]] \ No newline at end of file diff --git a/lib/ace/mode/_test/tokens_twig.json b/lib/ace/mode/_test/tokens_twig.json new file mode 100644 index 00000000..ada8b4a7 --- /dev/null +++ b/lib/ace/mode/_test/tokens_twig.json @@ -0,0 +1,288 @@ +[[ + "start", + ["xml-pe.doctype.xml",""] +],[ + "start", + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","html"], + ["meta.tag.punctuation.tag-close.xml",">"] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","head"], + ["meta.tag.punctuation.tag-close.xml",">"] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","title"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["text.xml","My Webpage"], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","body"], + ["meta.tag.punctuation.tag-close.xml",">"] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","ul"], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","id"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"navigation\""], + ["meta.tag.punctuation.tag-close.xml",">"] +],[ + "start", + ["text.xml"," "], + ["meta.tag.twig","{%"], + ["text"," "], + ["keyword.control.twig","for"], + ["text"," "], + ["identifier","item"], + ["text"," "], + ["keyword.operator.twig","in"], + ["text"," "], + ["identifier","navigation"], + ["text"," "], + ["meta.tag.twig","%}"] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","li"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.anchor.tag-name.xml","a"], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","href"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\""], + ["variable.other.readwrite.local.twig","{{"], + ["text"," "], + ["identifier","item"], + ["punctuation.operator","."], + ["identifier","href"], + ["keyword.operator.other","|"], + ["support.function.twig","escape"], + ["text"," "], + ["variable.other.readwrite.local.twig","}}"], + ["string.attribute-value.xml","\""], + ["meta.tag.punctuation.tag-close.xml",">"], + ["variable.other.readwrite.local.twig","{{"], + ["text"," "], + ["identifier","item"], + ["punctuation.operator","."], + ["identifier","caption"], + ["text"," "], + ["variable.other.readwrite.local.twig","}}"], + ["meta.tag.punctuation.end-tag-open.xml",""], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["text.xml"," "], + ["meta.tag.twig","{%"], + ["text"," "], + ["keyword.control.twig","endfor"], + ["text"," "], + ["meta.tag.twig","%}"] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start" +],[ + "start", + ["text.xml"," "], + ["meta.tag.twig","{%"], + ["text"," "], + ["keyword.control.twig","if"], + ["text"," "], + ["constant.numeric","1"], + ["text"," "], + ["keyword.operator.twig","not"], + ["text"," "], + ["keyword.operator.twig","in"], + ["text"," "], + ["paren.lparen","["], + ["constant.numeric","1"], + ["punctuation.operator",","], + ["text"," "], + ["constant.numeric","2"], + ["punctuation.operator",","], + ["text"," "], + ["constant.numeric","3"], + ["paren.rparen","]"], + ["text"," "], + ["meta.tag.twig","%}"] +],[ + "start" +],[ + "start", + ["text.xml"," "], + ["comment.block.twig","{# is equivalent to #}"] +],[ + "start", + ["text.xml"," "], + ["meta.tag.twig","{%"], + ["text"," "], + ["keyword.control.twig","if"], + ["text"," "], + ["keyword.operator.twig","not"], + ["text"," "], + ["paren.lparen","("], + ["constant.numeric","1"], + ["text"," "], + ["keyword.operator.twig","in"], + ["text"," "], + ["paren.lparen","["], + ["constant.numeric","1"], + ["punctuation.operator",","], + ["text"," "], + ["constant.numeric","2"], + ["punctuation.operator",","], + ["text"," "], + ["constant.numeric","3"], + ["paren.rparen","])"], + ["text"," "], + ["meta.tag.twig","%}"] +],[ + "start" +],[ + "start", + ["text.xml"," "], + ["meta.tag.twig","{%"], + ["text"," "], + ["keyword.control.twig","autoescape"], + ["text"," "], + ["constant.language.boolean","true"], + ["text"," "], + ["meta.tag.twig","%}"] +],[ + "start", + ["text.xml"," "], + ["variable.other.readwrite.local.twig","{{"], + ["text"," "], + ["identifier","var"], + ["text"," "], + ["variable.other.readwrite.local.twig","}}"] +],[ + "start", + ["text.xml"," "], + ["variable.other.readwrite.local.twig","{{"], + ["text"," "], + ["identifier","var"], + ["keyword.operator.other","|"], + ["support.function.twig","raw"], + ["text"," "], + ["variable.other.readwrite.local.twig","}}"], + ["text.xml"," "], + ["comment.block.twig","{# var won't be escaped #}"] +],[ + "start", + ["text.xml"," "], + ["variable.other.readwrite.local.twig","{{"], + ["text"," "], + ["identifier","var"], + ["keyword.operator.other","|"], + ["support.function.twig","escape"], + ["text"," "], + ["variable.other.readwrite.local.twig","}}"], + ["text.xml"," "], + ["comment.block.twig","{# var won't be doubled-escaped #}"] +],[ + "start", + ["text.xml"," "], + ["meta.tag.twig","{%"], + ["text"," "], + ["keyword.control.twig","endautoescape"], + ["text"," "], + ["meta.tag.twig","%}"] +],[ + "start" +],[ + "start", + ["text.xml"," "], + ["variable.other.readwrite.local.twig","{{"], + ["text"," "], + ["keyword.control.twig","include"], + ["paren.lparen","("], + ["string","'twig.html'"], + ["punctuation.operator",","], + ["text"," "], + ["identifier","sandboxed"], + ["text"," "], + ["keyword.operator.assignment","="], + ["text"," "], + ["constant.language.boolean","true"], + ["paren.rparen",")"], + ["text"," "], + ["variable.other.readwrite.local.twig","}}"] +],[ + "start" +],[ + "start", + ["text.xml"," "], + ["variable.other.readwrite.local.twig","{{"], + ["string","\"string "], + ["constant.language.escape","#{with}"], + ["string"," "], + ["constant.language.escape","\\\""], + ["string"," escapes\""], + ["text"," "], + ["string","'another#one'"], + ["text"," "], + ["variable.other.readwrite.local.twig","}}"] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","h1"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["text.xml","My Webpage"], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["text.xml"," "], + ["variable.other.readwrite.local.twig","{{"], + ["text"," "], + ["identifier","a_variable"], + ["text"," "], + ["variable.other.readwrite.local.twig","}}"] +],[ + "start", + ["text.xml"," "], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["meta.tag.punctuation.end-tag-open.xml",""] +]] \ No newline at end of file diff --git a/lib/ace/mode/_test/tokens_vala.json b/lib/ace/mode/_test/tokens_vala.json new file mode 100644 index 00000000..efe6e7c8 --- /dev/null +++ b/lib/ace/mode/_test/tokens_vala.json @@ -0,0 +1,158 @@ +[[ + "start", + ["meta.using.vala",""], + ["keyword.other.using.vala","using"], + ["meta.using.vala"," "], + ["storage.modifier.using.vala","Gtk"], + ["punctuation.terminator.vala",";"] +],[ + "start", + ["text"," "] +],[ + "text0", + ["storage.type.primitive.array.vala","int"], + ["text"," main ("], + ["storage.type.primitive.array.vala","string"], + ["text","[] args) {"] +],[ + "text0", + ["text"," "], + ["storage.type.vala","Gtk"], + ["keyword.operator.dereference.vala","."], + ["text","init ("], + ["storage.modifier.vala","ref"], + ["text"," args)"], + ["punctuation.terminator.vala",";"] +],[ + "text0", + ["text"," "], + ["storage.type.primitive.vala","var"], + ["text"," foo "], + ["keyword.operator.assignment.vala","="], + ["text"," "], + ["keyword.control.new.vala","new"], + ["text"," "], + ["storage.type.generic.vala","MyFoo>"], + ["text","()"], + ["punctuation.terminator.vala",";"] +],[ + "text0" +],[ + "text0", + ["text"," "], + ["storage.type.primitive.vala","var"], + ["text"," window "], + ["keyword.operator.assignment.vala","="], + ["text"," "], + ["keyword.control.new.vala","new"], + ["text"," "], + ["storage.type.vala","Window"], + ["text","()"], + ["punctuation.terminator.vala",";"] +],[ + "text0", + ["text"," window"], + ["keyword.operator.dereference.vala","."], + ["text","title "], + ["keyword.operator.assignment.vala","="], + ["text"," "], + ["punctuation.definition.string.begin.vala","\""], + ["string.quoted.double.vala","Hello, World!"], + ["punctuation.definition.string.end.vala","\""], + ["punctuation.terminator.vala",";"] +],[ + "text0", + ["text"," window"], + ["keyword.operator.dereference.vala","."], + ["text","border_width "], + ["keyword.operator.assignment.vala","="], + ["text"," "], + ["constant.numeric.vala","10"], + ["punctuation.terminator.vala",";"] +],[ + "text0", + ["text"," window"], + ["keyword.operator.dereference.vala","."], + ["text","window_position "], + ["keyword.operator.assignment.vala","="], + ["text"," "], + ["storage.type.vala","WindowPosition"], + ["keyword.operator.dereference.vala","."], + ["constant.other.vala","CENTER"], + ["punctuation.terminator.vala",";"] +],[ + "text0", + ["text"," window"], + ["keyword.operator.dereference.vala","."], + ["text","set_default_size("], + ["constant.numeric.vala","350"], + ["text",", "], + ["constant.numeric.vala","70"], + ["text",")"], + ["punctuation.terminator.vala",";"] +],[ + "text0", + ["text"," window"], + ["keyword.operator.dereference.vala","."], + ["text","destroy"], + ["keyword.operator.dereference.vala","."], + ["text","connect("], + ["storage.type.vala","Gtk"], + ["keyword.operator.dereference.vala","."], + ["text","main_quit)"], + ["punctuation.terminator.vala",";"] +],[ + "text0", + ["text"," "] +],[ + "text0", + ["text"," "], + ["storage.type.primitive.vala","var"], + ["text"," label "], + ["keyword.operator.assignment.vala","="], + ["text"," "], + ["keyword.control.new.vala","new"], + ["text"," "], + ["storage.type.vala","Label"], + ["text","("], + ["punctuation.definition.string.begin.vala","\""], + ["string.quoted.double.vala","Hello, World!"], + ["punctuation.definition.string.end.vala","\""], + ["text",")"], + ["punctuation.terminator.vala",";"] +],[ + "text0", + ["text"," "] +],[ + "text0", + ["text"," window"], + ["keyword.operator.dereference.vala","."], + ["text","add(label)"], + ["punctuation.terminator.vala",";"] +],[ + "text0", + ["text"," window"], + ["keyword.operator.dereference.vala","."], + ["text","show_all()"], + ["punctuation.terminator.vala",";"] +],[ + "text0", + ["text"," "] +],[ + "text0", + ["text"," "], + ["storage.type.vala","Gtk"], + ["keyword.operator.dereference.vala","."], + ["text","main()"], + ["punctuation.terminator.vala",";"] +],[ + "text0", + ["text"," "], + ["keyword.control.vala","return"], + ["text"," "], + ["constant.numeric.vala","0"], + ["punctuation.terminator.vala",";"] +],[ + "start", + ["text","}"] +]] \ No newline at end of file diff --git a/lib/ace/mode/_test/tokens_vbscript.json b/lib/ace/mode/_test/tokens_vbscript.json index 6a2346d3..05d5dd22 100644 --- a/lib/ace/mode/_test/tokens_vbscript.json +++ b/lib/ace/mode/_test/tokens_vbscript.json @@ -5,18 +5,12 @@ ["text"," "], ["punctuation.definition.string.begin.asp","\""], ["string.quoted.double.asp","C:\\Wikipedia - VBScript - Example - Hello World.txt\""] -],[ - "start" ],[ "start", ["text","MakeHelloWorldFile myfilename"] -],[ - "start" ],[ "state_4", ["meta.leading-space"," "] -],[ - "state_4" ],[ "start", ["storage.type.function.asp","Sub"], @@ -26,14 +20,10 @@ ["punctuation.definition.parameters.asp","("], ["variable.parameter.function.asp","FileName"], ["punctuation.definition.parameters.asp",")"] -],[ - "start" ],[ "start", ["punctuation.definition.comment.asp","'"], ["comment.line.apostrophe.asp","Create a new file in C: drive or overwrite existing file"] -],[ - "start" ],[ "start", ["meta.odd-tab.spaces"," "], @@ -47,8 +37,6 @@ ["punctuation.definition.string.begin.asp","\""], ["string.quoted.double.asp","Scripting.FileSystemObject\""], ["text",")"] -],[ - "start" ],[ "start", ["meta.odd-tab.spaces"," "], @@ -59,8 +47,6 @@ ["text","(FileName) "], ["keyword.control.asp","Then"], ["text"," "] -],[ - "start" ],[ "start", ["meta.odd-tab.spaces"," "], @@ -81,8 +67,6 @@ ["punctuation.definition.string.begin.asp","\""], ["string.quoted.double.asp"," exists ... OK to overwrite?\""], ["text",", vbOKCancel)"] -],[ - "start" ],[ "start", ["meta.odd-tab.spaces"," "], @@ -90,8 +74,6 @@ ["meta.odd-tab.spaces"," "], ["punctuation.definition.comment.asp","'"], ["comment.line.apostrophe.asp","If button selected is not OK, then quit now"] -],[ - "start" ],[ "start", ["meta.odd-tab.spaces"," "], @@ -99,8 +81,6 @@ ["meta.odd-tab.spaces"," "], ["punctuation.definition.comment.asp","'"], ["comment.line.apostrophe.asp","vbOK is a language constant"] -],[ - "start" ],[ "start", ["meta.odd-tab.spaces"," "], @@ -113,15 +93,11 @@ ["keyword.control.asp","Then"], ["text"," "], ["keyword.control.asp","Exit Sub"] -],[ - "start" ],[ "start", ["meta.odd-tab.spaces"," "], ["meta.leading-space"," "], ["keyword.control.asp","Else"] -],[ - "start" ],[ "start", ["meta.odd-tab.spaces"," "], @@ -129,8 +105,6 @@ ["meta.odd-tab.spaces"," "], ["punctuation.definition.comment.asp","'"], ["comment.line.apostrophe.asp","Confirm OK to create"] -],[ - "start" ],[ "start", ["meta.odd-tab.spaces"," "], @@ -151,8 +125,6 @@ ["punctuation.definition.string.begin.asp","\""], ["string.quoted.double.asp"," ... OK to create?\""], ["text",", vbOKCancel)"] -],[ - "start" ],[ "start", ["meta.odd-tab.spaces"," "], @@ -165,23 +137,17 @@ ["keyword.control.asp","Then"], ["text"," "], ["keyword.control.asp","Exit Sub"] -],[ - "start" ],[ "start", ["meta.odd-tab.spaces"," "], ["meta.leading-space"," "], ["keyword.control.asp","End If"] -],[ - "start" ],[ "start", ["meta.odd-tab.spaces"," "], ["meta.leading-space"," "], ["punctuation.definition.comment.asp","'"], ["comment.line.apostrophe.asp","Create new file (or replace an existing file)"] -],[ - "start" ],[ "start", ["meta.odd-tab.spaces"," "], @@ -190,8 +156,6 @@ ["text"," FileObject "], ["keyword.operator.asp","="], ["text"," FSO.CreateTextFile (FileName)"] -],[ - "start" ],[ "start", ["meta.odd-tab.spaces"," "], @@ -204,8 +168,6 @@ ["text"," "], ["support.function.vb.asp","Now"], ["text","()"] -],[ - "start" ],[ "start", ["meta.odd-tab.spaces"," "], @@ -213,8 +175,6 @@ ["text","FileObject.WriteLine "], ["punctuation.definition.string.begin.asp","\""], ["string.quoted.double.asp","Hello World\""] -],[ - "start" ],[ "start", ["meta.odd-tab.spaces"," "], @@ -222,8 +182,6 @@ ["text","FileObject."], ["entity.name.function.asp","Close"], ["text","()"] -],[ - "start" ],[ "start", ["meta.odd-tab.spaces"," "], @@ -239,11 +197,7 @@ ["text"," "], ["punctuation.definition.string.begin.asp","\""], ["string.quoted.double.asp"," ... updated.\""] -],[ - "start" ],[ "start", - ["support.function.asp","End"], - ["text"," "], - ["storage.type.asp","Sub"] + ["storage.type.asp","End Sub"] ]] \ No newline at end of file diff --git a/lib/ace/mode/_test/tokens_velocity.json b/lib/ace/mode/_test/tokens_velocity.json new file mode 100644 index 00000000..ee40761c --- /dev/null +++ b/lib/ace/mode/_test/tokens_velocity.json @@ -0,0 +1,285 @@ +[[ + "vm_comment", + ["comment.block","#*"] +],[ + "vm_comment", + ["comment"," This is a sample comment block that"] +],[ + "vm_comment", + ["comment"," spans multiple lines."] +],[ + "start", + ["comment","*#"] +],[ + "start" +],[ + "start", + ["keyword","#macro"], + ["text"," "], + ["lparen","("], + ["text"," "], + ["identifier","outputItem"], + ["text"," "], + ["variable","$item"], + ["text"," "], + ["rparen",")"] +],[ + "start", + ["text"," "], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","li"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["variable","${"], + ["identifier","item"], + ["variable","}"], + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start", + ["keyword","#end"] +],[ + "start" +],[ + "start", + ["comment","## Define the items to iterate"] +],[ + "start", + ["keyword","#set"], + ["text"," "], + ["lparen","("], + ["text"," "], + ["variable","$items"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["lparen","["], + ["constant.numeric","1"], + ["text.xml",","], + ["text"," "], + ["constant.numeric","2"], + ["text.xml",","], + ["text"," "], + ["constant.numeric","3"], + ["text.xml",","], + ["text"," "], + ["constant.numeric","4"], + ["rparen","]"], + ["text"," "], + ["rparen",")"] +],[ + "start" +],[ + "start", + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","ul"], + ["meta.tag.punctuation.tag-close.xml",">"] +],[ + "start", + ["text"," "], + ["comment","## Iterate over the items and output the evens."] +],[ + "start", + ["text"," "], + ["keyword","#foreach"], + ["text"," "], + ["lparen","("], + ["text"," "], + ["variable","$item"], + ["text"," "], + ["identifier","in"], + ["text"," "], + ["variable","$items"], + ["text"," "], + ["rparen",")"] +],[ + "start", + ["text"," "], + ["keyword","#if"], + ["text"," "], + ["lparen","("], + ["text"," "], + ["support.function","$_MathTool"], + ["text.xml","."], + ["identifier","mod"], + ["lparen","("], + ["variable","$item"], + ["text.xml",","], + ["text"," "], + ["constant.numeric","2"], + ["rparen",")"], + ["text"," "], + ["keyword.operator","=="], + ["text"," "], + ["constant.numeric","0"], + ["text"," "], + ["rparen",")"] +],[ + "start", + ["text"," "], + ["identifier","#outputItem"], + ["text"," "], + ["lparen","("], + ["variable","$item"], + ["rparen",")"] +],[ + "start", + ["text"," "], + ["keyword","#end"] +],[ + "start", + ["text"," "], + ["keyword","#end"] +],[ + "start", + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start" +],[ + "js-start", + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.script.tag-name.xml","script"], + ["meta.tag.punctuation.tag-close.xml",">"] +],[ + "js-comment_regex_allowed", + ["text"," "], + ["comment","/*"] +],[ + "js-comment_regex_allowed", + ["comment"," A sample function to decomstrate"] +],[ + "js-comment_regex_allowed", + ["comment"," JavaScript highlighting and folding."] +],[ + "js-start", + ["comment"," */"] +],[ + "js-start", + ["text"," "], + ["storage.type","function"], + ["text"," "], + ["entity.name.function","foo"], + ["paren.lparen","("], + ["variable.parameter","items"], + ["punctuation.operator",", "], + ["variable.parameter","nada"], + ["paren.rparen",")"], + ["text"," "], + ["paren.lparen","{"] +],[ + "js-start", + ["text"," "], + ["keyword","for"], + ["text"," "], + ["paren.lparen","("], + ["storage.type","var"], + ["text"," "], + ["identifier","i"], + ["keyword.operator","="], + ["constant.numeric","0"], + ["punctuation.operator",";"], + ["text"," "], + ["identifier","i"], + ["keyword.operator","<"], + ["identifier","items"], + ["punctuation.operator","."], + ["support.constant","length"], + ["punctuation.operator",";"], + ["text"," "], + ["identifier","i"], + ["keyword.operator","++"], + ["paren.rparen",")"], + ["text"," "], + ["paren.lparen","{"] +],[ + "js-start", + ["text"," "], + ["support.function","alert"], + ["paren.lparen","("], + ["identifier","items"], + ["paren.lparen","["], + ["identifier","i"], + ["paren.rparen","]"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["string","\"juhu"], + ["constant.language.escape","\\n"], + ["string","\""], + ["paren.rparen",")"], + ["punctuation.operator",";"] +],[ + "js-no_regex", + ["text"," "], + ["paren.rparen","}"] +],[ + "js-no_regex", + ["text"," "], + ["paren.rparen","}"] +],[ + "start", + ["meta.tag.punctuation.end-tag-open.xml",""] +],[ + "start" +],[ + "css-start", + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.style.tag-name.xml","style"], + ["meta.tag.punctuation.tag-close.xml",">"] +],[ + ["css-comment","css-start"], + ["text"," "], + ["comment","/*"] +],[ + ["css-comment","css-start"], + ["comment"," A sample style to decomstrate"] +],[ + ["css-comment","css-start"], + ["comment"," CSS highlighting and folding."] +],[ + "css-start", + ["comment"," */"] +],[ + ["css-ruleset","css-start"], + ["text"," "], + ["variable",".class"], + ["text"," "], + ["paren.lparen","{"] +],[ + ["css-ruleset","css-start"], + ["text"," "], + ["support.type","font-family"], + ["text",": Monaco, "], + ["string","\"Courier New\""], + ["text",", "], + ["support.constant.fonts","monospace"], + ["text",";"] +],[ + ["css-ruleset","css-start"], + ["text"," "], + ["support.type","font-size"], + ["text",": "], + ["constant.numeric","12"], + ["keyword","px"], + ["text",";"] +],[ + ["css-ruleset","css-start"], + ["text"," "], + ["support.type","cursor"], + ["text",": "], + ["support.constant","text"], + ["text",";"] +],[ + "css-start", + ["text"," "], + ["paren.rparen","}"] +],[ + "start", + ["meta.tag.punctuation.end-tag-open.xml",""] +]] \ No newline at end of file diff --git a/lib/ace/mode/_test/tokens_verilog.json b/lib/ace/mode/_test/tokens_verilog.json new file mode 100644 index 00000000..9680a964 --- /dev/null +++ b/lib/ace/mode/_test/tokens_verilog.json @@ -0,0 +1,113 @@ +[[ + "start", + ["keyword","always"], + ["text"," @"], + ["paren.lparen","("], + ["keyword","negedge"], + ["text"," "], + ["identifier","reset"], + ["text"," "], + ["keyword","or"], + ["text"," "], + ["keyword","posedge"], + ["text"," "], + ["identifier","clk"], + ["paren.rparen",")"], + ["text"," "], + ["keyword","begin"] +],[ + "start", + ["text"," "], + ["keyword","if"], + ["text"," "], + ["paren.lparen","("], + ["identifier","reset"], + ["text"," "], + ["keyword.operator","=="], + ["text"," "], + ["constant.numeric","0"], + ["paren.rparen",")"], + ["text"," "], + ["keyword","begin"] +],[ + "start", + ["text"," "], + ["identifier","d_out"], + ["text"," "], + ["keyword.operator","<="], + ["text"," "], + ["constant.numeric","16"], + ["text","'"], + ["identifier","h0000"], + ["text",";"] +],[ + "start", + ["text"," "], + ["identifier","d_out_mem"], + ["text","["], + ["identifier","resetcount"], + ["text","] "], + ["keyword.operator","<="], + ["text"," "], + ["identifier","d_out"], + ["text",";"] +],[ + "start", + ["text"," "], + ["identifier","laststoredvalue"], + ["text"," "], + ["keyword.operator","<="], + ["text"," "], + ["identifier","d_out"], + ["text",";"] +],[ + "start", + ["text"," "], + ["keyword","end"], + ["text"," "], + ["keyword","else"], + ["text"," "], + ["keyword","begin"] +],[ + "start", + ["text"," "], + ["identifier","d_out"], + ["text"," "], + ["keyword.operator","<="], + ["text"," "], + ["identifier","d_out"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["constant.numeric","1"], + ["text","'"], + ["identifier","b1"], + ["text","; "] +],[ + "start", + ["text"," "], + ["keyword","end"] +],[ + "start", + ["keyword","end"] +],[ + "start" +],[ + "start", + ["keyword","always"], + ["text"," @"], + ["paren.lparen","("], + ["identifier","bufreadaddr"], + ["paren.rparen",")"] +],[ + "start", + ["text"," "], + ["identifier","bufreadval"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["identifier","d_out_mem"], + ["text","["], + ["identifier","bufreadaddr"], + ["text","];"] +]] \ No newline at end of file diff --git a/lib/ace/mode/_test/tokens_vhdl.json b/lib/ace/mode/_test/tokens_vhdl.json new file mode 100644 index 00000000..88c6e222 --- /dev/null +++ b/lib/ace/mode/_test/tokens_vhdl.json @@ -0,0 +1,271 @@ +[[ + "start", + ["keyword","library"], + ["text"," "], + ["identifier","IEEE"] +],[ + "start", + ["identifier","user"], + ["text"," "], + ["identifier","IEEE"], + ["punctuation.operator","."], + ["identifier","std_logic_1164"], + ["punctuation.operator","."], + ["keyword","all"], + ["punctuation.operator",";"] +],[ + "start", + ["keyword","use"], + ["text"," "], + ["identifier","IEEE"], + ["punctuation.operator","."], + ["identifier","numeric_std"], + ["punctuation.operator","."], + ["keyword","all"], + ["punctuation.operator",";"] +],[ + "start" +],[ + "start", + ["keyword","entity"], + ["text"," "], + ["identifier","COUNT16"], + ["text"," "], + ["keyword","is"] +],[ + "start" +],[ + "start", + ["text"," "], + ["keyword","port"], + ["text"," "], + ["paren.lparen","("] +],[ + "start", + ["text"," "], + ["identifier","cOut"], + ["text"," "], + ["punctuation.operator",":"], + ["keyword","out"], + ["text"," "], + ["storage.type","std_logic_vector"], + ["paren.lparen","("], + ["constant.numeric","15"], + ["text"," "], + ["keyword","downto"], + ["text"," "], + ["constant.numeric","0"], + ["paren.rparen",")"], + ["punctuation.operator",";"], + ["text"," "], + ["comment","-- counter output"] +],[ + "start", + ["text"," "], + ["identifier","clkEn"], + ["text"," "], + ["punctuation.operator",":"], + ["keyword","in"], + ["text"," "], + ["storage.type","std_logic"], + ["punctuation.operator",";"], + ["text"," "], + ["comment","-- count enable"] +],[ + "start", + ["text"," "], + ["identifier","clk"], + ["text"," "], + ["punctuation.operator",":"], + ["keyword","in"], + ["text"," "], + ["storage.type","std_logic"], + ["punctuation.operator",";"], + ["text"," "], + ["comment","-- clock input"] +],[ + "start", + ["text"," "], + ["identifier","rst"], + ["text"," "], + ["punctuation.operator",":"], + ["keyword","in"], + ["text"," "], + ["storage.type","std_logic"], + ["text"," "], + ["comment","-- reset input"] +],[ + "start", + ["text"," "], + ["paren.rparen",")"], + ["punctuation.operator",";"] +],[ + "start", + ["text"," "] +],[ + "start", + ["keyword","end"], + ["text"," "], + ["keyword","entity"], + ["punctuation.operator",";"] +],[ + "start" +],[ + "start", + ["keyword","architecture"], + ["text"," "], + ["identifier","count_rtl"], + ["text"," "], + ["keyword","of"], + ["text"," "], + ["identifier","COUNT16"], + ["text"," "], + ["keyword","is"] +],[ + "start", + ["text"," "], + ["storage.type","signal"], + ["text"," "], + ["identifier","count"], + ["text"," "], + ["punctuation.operator",":"], + ["storage.type","std_logic_vector"], + ["text"," "], + ["paren.lparen","("], + ["constant.numeric","15"], + ["text"," "], + ["keyword","downto"], + ["text"," "], + ["constant.numeric","0"], + ["paren.rparen",")"], + ["punctuation.operator",";"] +],[ + "start", + ["text"," "] +],[ + "start", + ["keyword","begin"] +],[ + "start", + ["text"," "], + ["keyword","process"], + ["text"," "], + ["paren.lparen","("], + ["identifier","clk"], + ["punctuation.operator",","], + ["text"," "], + ["identifier","rst"], + ["paren.rparen",")"], + ["text"," "], + ["keyword","begin"] +],[ + "start", + ["text"," "] +],[ + "start", + ["text"," "], + ["keyword","if"], + ["paren.lparen","("], + ["identifier","rst"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["string","'1'"], + ["paren.rparen",")"], + ["text"," "], + ["keyword","then"] +],[ + "start", + ["text"," "], + ["identifier","count"], + ["text"," "], + ["keyword.operator","<="], + ["text"," "], + ["paren.lparen","("], + ["keyword","others"], + ["keyword.operator","=>"], + ["string","'0'"], + ["paren.rparen",")"], + ["punctuation.operator",";"] +],[ + "start", + ["text"," "], + ["keyword","elsif"], + ["paren.lparen","("], + ["identifier","rising_edge"], + ["paren.lparen","("], + ["identifier","clk"], + ["paren.rparen","))"], + ["text"," "], + ["keyword","then"] +],[ + "start", + ["text"," "], + ["keyword","if"], + ["paren.lparen","("], + ["identifier","clkEn"], + ["text"," "], + ["keyword.operator","="], + ["text"," "], + ["string","'1'"], + ["paren.rparen",")"], + ["text"," "], + ["keyword","then"] +],[ + "start", + ["text"," "], + ["identifier","count"], + ["text"," "], + ["keyword.operator","<="], + ["text"," "], + ["identifier","count"], + ["text"," "], + ["keyword.operator","+"], + ["text"," "], + ["constant.numeric","1"], + ["punctuation.operator",";"] +],[ + "start", + ["text"," "], + ["keyword","end"], + ["text"," "], + ["keyword","if"], + ["punctuation.operator",";"] +],[ + "start", + ["text"," "], + ["keyword","end"], + ["text"," "], + ["keyword","if"], + ["punctuation.operator",";"] +],[ + "start", + ["text"," "] +],[ + "start", + ["text"," "], + ["keyword","end"], + ["text"," "], + ["keyword","process"], + ["punctuation.operator",";"] +],[ + "start", + ["text"," "], + ["identifier","cOut"], + ["text"," "], + ["keyword.operator","<="], + ["text"," "], + ["identifier","count"], + ["punctuation.operator",";"] +],[ + "start" +],[ + "start", + ["keyword","end"], + ["text"," "], + ["keyword","architecture"], + ["punctuation.operator",";"] +],[ + "start", + ["text"," "] +]] \ No newline at end of file diff --git a/lib/ace/mode/_test/tokens_xml.json b/lib/ace/mode/_test/tokens_xml.json index f7c1ed64..728be4db 100644 --- a/lib/ace/mode/_test/tokens_xml.json +++ b/lib/ace/mode/_test/tokens_xml.json @@ -1,43 +1,43 @@ [[ "start", - ["meta.tag","<"], - ["meta.tag.tag-name","Juhu"], - ["meta.tag.r",">"], - ["text","//Juhu Kinners"], - ["meta.tag",""] + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","Juhu"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["text.xml","//Juhu Kinners"], + ["meta.tag.punctuation.end-tag-open.xml",""] ],[ "start", - ["text","test: two tags in the same lines should be in separate tokens\""] + ["text.xml","test: two tags in the same lines should be in separate tokens\""] ],[ "start", - ["meta.tag","<"], - ["meta.tag.tag-name","Juhu"], - ["meta.tag.r",">"], - ["meta.tag","<"], - ["meta.tag.tag-name","Kinners"], - ["meta.tag.r",">"] + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","Juhu"], + ["meta.tag.punctuation.tag-close.xml",">"], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","Kinners"], + ["meta.tag.punctuation.tag-close.xml",">"] ],[ "start", - ["text","test: multiline attributes\""] + ["text.xml","test: multiline attributes\""] ],[ - "tag_qqstring", - ["meta.tag","<"], - ["meta.tag.tag-name","copy"], - ["text"," "], - ["entity.other.attribute-name","set"], - ["keyword.operator","="], - ["string","\"{"] + ["string.attribute-value.xml0","meta.tag.punctuation.tag-open.xml"], + ["meta.tag.punctuation.tag-open.xml","<"], + ["meta.tag.tag-name.xml","copy"], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","set"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"{"] ],[ - "tag_qqstring", - ["string","}\""], - ["text"," "], - ["entity.other.attribute-name","undo"], - ["keyword.operator","="], - ["string","\"{"] + ["string.attribute-value.xml0","meta.tag.punctuation.tag-open.xml"], + ["string.attribute-value.xml","}\""], + ["text.tag-whitespace.xml"," "], + ["entity.other.attribute-name.xml","undo"], + ["keyword.operator.attribute-equals.xml","="], + ["string.attribute-value.xml","\"{"] ],[ "start", - ["string","}\""], - ["meta.tag.r","/>"] + ["string.attribute-value.xml","}\""], + ["meta.tag.punctuation.tag-close.xml","/>"] ]] \ No newline at end of file diff --git a/lib/ace/mode/abap.js b/lib/ace/mode/abap.js index b2ba82c4..c9d5a991 100644 --- a/lib/ace/mode/abap.js +++ b/lib/ace/mode/abap.js @@ -31,7 +31,6 @@ define(function(require, exports, module) { "use strict"; -var Tokenizer = require("../tokenizer").Tokenizer; var Rules = require("./abap_highlight_rules").AbapHighlightRules; var FoldMode = require("./folding/coffee").FoldMode; var Range = require("../range").Range; @@ -39,7 +38,7 @@ var TextMode = require("./text").Mode; var oop = require("../lib/oop"); function Mode() { - this.$tokenizer = new Tokenizer(new Rules().getRules()); + this.HighlightRules = Rules; this.foldingRules = new FoldMode(); } @@ -70,6 +69,7 @@ oop.inherits(Mode, TextMode); } }; + this.$id = "ace/mode/abap"; }).call(Mode.prototype); exports.Mode = Mode; diff --git a/lib/ace/mode/abap_highlight_rules.js b/lib/ace/mode/abap_highlight_rules.js index 6b232c90..bab1e504 100644 --- a/lib/ace/mode/abap_highlight_rules.js +++ b/lib/ace/mode/abap_highlight_rules.js @@ -126,7 +126,7 @@ var AbapHighlightRules = function() { {token : "string", regex : "`", next : "start"}, {defaultToken : "string"} ] - } + }; }; oop.inherits(AbapHighlightRules, TextHighlightRules); diff --git a/lib/ace/mode/abc.js b/lib/ace/mode/abc.js new file mode 100644 index 00000000..b6eb237a --- /dev/null +++ b/lib/ace/mode/abc.js @@ -0,0 +1,58 @@ +/* ***** 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. + * + * ***** 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 ABCHighlightRules = require("./abc_highlight_rules").ABCHighlightRules; +// TODO: pick appropriate fold mode + var FoldMode = require("./folding/cstyle").FoldMode; + + var Mode = function () { + this.HighlightRules = ABCHighlightRules; + this.foldingRules = new FoldMode(); + }; + oop.inherits(Mode, TextMode); + + (function () { + // this.lineCommentStart = ""%.*""; + // this.blockComment = {start: ""/*"", end: ""*/""}; + // Extra logic goes here. + this.$id = "ace/mode/abc" + }).call(Mode.prototype); + + exports.Mode = Mode; +}); \ No newline at end of file diff --git a/lib/ace/mode/abc_highlight_rules.js b/lib/ace/mode/abc_highlight_rules.js new file mode 100644 index 00000000..6ffe9c9b --- /dev/null +++ b/lib/ace/mode/abc_highlight_rules.js @@ -0,0 +1,114 @@ +/* This file was partially autogenerated from https://github.com/jimhawkridge/SublimeABC + + Modifications + + - more classes to express the abc semantic + - added syntax highlighting for Zupfnoter conventions (https://github.com/bwl21/zupfnoter) + - separate note pitch and note duration - even if it looks the same + + ***********************************************************************************************/ + + +define(function (require, exports, module) { + "use strict"; + + var oop = require("../lib/oop"); + var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + + var ABCHighlightRules = function () { + // regexp must not have capturing parentheses. Use (?:) instead. + // regexps are ordered -> the first match is used + + this.$rules = { + start: [ + { + token: ['zupfnoter.information.comment.line.percentage', 'information.keyword', 'in formation.keyword.embedded'], + regex: '(%%%%)(hn\\.[a-z]*)(.*)', + comment: 'Instruction Comment' + }, + { + token: ['information.comment.line.percentage', 'information.keyword.embedded'], + regex: '(%%)(.*)', + comment: 'Instruction Comment' + }, + + { + token: 'comment.line.percentage', + regex: '%.*', + comment: 'Comments' + }, + + { + token: 'barline.keyword.operator', + regex: '[\\[:]*[|:][|\\]:]*(?:\\[?[0-9]+)?|\\[[0-9]+', + comment: 'Bar lines' + }, + { + token: ['information.keyword.embedded', 'information.argument.string.unquoted'], + regex: '(\\[[A-Za-z]:)([^\\]]*\\])', + comment: 'embedded Header lines' + }, + { + token: ['information.keyword', 'information.argument.string.unquoted'], + regex: '^([A-Za-z]:)([^%\\\\]*)', + comment: 'Header lines' + }, + { + token: ['text', 'entity.name.function', 'string.unquoted', 'text'], + regex: '(\\[)([A-Z]:)(.*?)(\\])', + comment: 'Inline fields' + }, + { + token: ['accent.constant.language', 'pitch.constant.numeric', 'duration.constant.numeric'], + regex: '([\\^=_]*)([A-Ga-gz][,\']*)([0-9]*/*[><0-9]*)', + comment: 'Notes' + }, + { + token: 'zupfnoter.jumptarget.string.quoted', + regex: '[\\"!]\\^\\:.*?[\\"!]', + comment: 'Zupfnoter jumptarget' + }, { + token: 'zupfnoter.goto.string.quoted', + regex: '[\\"!]\\^\\@.*?[\\"!]', + comment: 'Zupfnoter goto' + }, + { + token: 'zupfnoter.annotation.string.quoted', + regex: '[\\"!]\\^\\!.*?[\\"!]', + comment: 'Zupfnoter annoation' + }, + { + token: 'zupfnoter.annotationref.string.quoted', + regex: '[\\"!]\\^\\#.*?[\\"!]', + comment: 'Zupfnoter annotation reference' + }, + { + token: 'chordname.string.quoted', + regex: '[\\"!]\\^.*?[\\"!]', + comment: 'abc chord' + }, + { + token: 'string.quoted', + regex: '[\\"!].*?[\\"!]', + comment: 'abc annotation' + } + + ] + }; + + // this.embedRules(JsonHighlightRules, "json-") + + this.normalizeRules(); + }; + + ABCHighlightRules.metaData = { + fileTypes: ['abc'], + name: 'ABC', + scopeName: 'text.abcnotation' + }; + + + oop.inherits(ABCHighlightRules, TextHighlightRules); + + exports.ABCHighlightRules = ABCHighlightRules; +}); diff --git a/lib/ace/mode/actionscript.js b/lib/ace/mode/actionscript.js index 7411413d..7daf2941 100644 --- a/lib/ace/mode/actionscript.js +++ b/lib/ace/mode/actionscript.js @@ -27,10 +27,6 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * - * Contributor(s): - * - * - * * ***** END LICENSE BLOCK ***** */ /* @@ -42,22 +38,20 @@ define(function(require, exports, module) { var oop = require("../lib/oop"); var TextMode = require("./text").Mode; -var Tokenizer = require("../tokenizer").Tokenizer; var ActionScriptHighlightRules = require("./actionscript_highlight_rules").ActionScriptHighlightRules; // TODO: pick appropriate fold mode var FoldMode = require("./folding/cstyle").FoldMode; var Mode = function() { - var highlighter = new ActionScriptHighlightRules(); + this.HighlightRules = ActionScriptHighlightRules; this.foldingRules = new FoldMode(); - this.$tokenizer = new Tokenizer(highlighter.getRules()); }; oop.inherits(Mode, TextMode); (function() { this.lineCommentStart = "//"; this.blockComment = {start: "/*", end: "*/"}; - // Extra logic goes here. + this.$id = "ace/mode/actionscript"; }).call(Mode.prototype); exports.Mode = Mode; diff --git a/lib/ace/mode/ada.js b/lib/ace/mode/ada.js index 8db5a21f..dc1dfa14 100644 --- a/lib/ace/mode/ada.js +++ b/lib/ace/mode/ada.js @@ -33,12 +33,11 @@ define(function(require, exports, module) { var oop = require("../lib/oop"); var TextMode = require("./text").Mode; -var Tokenizer = require("../tokenizer").Tokenizer; var AdaHighlightRules = require("./ada_highlight_rules").AdaHighlightRules; var Range = require("../range").Range; var Mode = function() { - this.$tokenizer = new Tokenizer(new AdaHighlightRules().getRules()); + this.HighlightRules = AdaHighlightRules; }; oop.inherits(Mode, TextMode); @@ -46,6 +45,7 @@ oop.inherits(Mode, TextMode); this.lineCommentStart = "--"; + this.$id = "ace/mode/ada"; }).call(Mode.prototype); exports.Mode = Mode; diff --git a/lib/ace/mode/eex.js b/lib/ace/mode/apache_conf.js similarity index 87% rename from lib/ace/mode/eex.js rename to lib/ace/mode/apache_conf.js index 1cd59040..2379b44b 100644 --- a/lib/ace/mode/eex.js +++ b/lib/ace/mode/apache_conf.js @@ -42,21 +42,19 @@ define(function(require, exports, module) { var oop = require("../lib/oop"); var TextMode = require("./text").Mode; -var Tokenizer = require("../tokenizer").Tokenizer; -var EExHighlightRules = require("./eex_highlight_rules").EExHighlightRules; +var ApacheConfHighlightRules = require("./apache_conf_highlight_rules").ApacheConfHighlightRules; // TODO: pick appropriate fold mode var FoldMode = require("./folding/cstyle").FoldMode; var Mode = function() { - var highlighter = new EExHighlightRules(); + this.HighlightRules = ApacheConfHighlightRules; this.foldingRules = new FoldMode(); - this.$tokenizer = new Tokenizer(highlighter.getRules()); }; oop.inherits(Mode, TextMode); (function() { - this.lineCommentStart = "<%+#"; - this.blockComment = {start: "/*", end: "*/"}; + this.lineCommentStart = "#"; + this.$id = "ace/mode/apache_conf"; // Extra logic goes here. }).call(Mode.prototype); diff --git a/lib/ace/mode/apache_conf_highlight_rules.js b/lib/ace/mode/apache_conf_highlight_rules.js new file mode 100644 index 00000000..c310612d --- /dev/null +++ b/lib/ace/mode/apache_conf_highlight_rules.js @@ -0,0 +1,231 @@ +/* ***** 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. + * + * ***** END LICENSE BLOCK ***** */ + +/* This file was autogenerated from https://raw.github.com/colinta/ApacheConf.tmLanguage/master/ApacheConf.tmLanguage (uuid: ) */ +/**************************************************************************************** + * IT MIGHT NOT BE PERFECT ...But it's a good start from an existing *.tmlanguage file. * + * fileTypes * + ****************************************************************************************/ + +define(function(require, exports, module) { +"use strict"; + +var oop = require("../lib/oop"); +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +var ApacheConfHighlightRules = function() { + // regexp must not have capturing parentheses. Use (?:) instead. + // regexps are ordered -> the first match is used + + this.$rules = { start: + [ { token: + [ 'punctuation.definition.comment.apacheconf', + 'comment.line.hash.ini', + 'comment.line.hash.ini' ], + regex: '^((?:\\s)*)(#)(.*$)' }, + { token: + [ 'punctuation.definition.tag.apacheconf', + 'entity.tag.apacheconf', + 'text', + 'string.value.apacheconf', + 'punctuation.definition.tag.apacheconf' ], + regex: '(<)(Proxy|ProxyMatch|IfVersion|Directory|DirectoryMatch|Files|FilesMatch|IfDefine|IfModule|Limit|LimitExcept|Location|LocationMatch|VirtualHost)(?:(\\s)(.+?))?(>)' }, + { token: + [ 'punctuation.definition.tag.apacheconf', + 'entity.tag.apacheconf', + 'punctuation.definition.tag.apacheconf' ], + regex: '()' }, + { token: + [ 'keyword.alias.apacheconf', 'text', + 'string.regexp.apacheconf', 'text', + 'string.replacement.apacheconf', 'text' ], + regex: '(Rewrite(?:Rule|Cond))(\\s+)(.+?)(\\s+)(.+?)($|\\s)' }, + { token: + [ 'keyword.alias.apacheconf', 'text', + 'entity.status.apacheconf', 'text', + 'string.regexp.apacheconf', 'text', + 'string.path.apacheconf', 'text' ], + regex: '(RedirectMatch)(?:(\\s+)(\\d\\d\\d|permanent|temp|seeother|gone))?(\\s+)(.+?)(\\s+)(?:(.+?)($|\\s))?' }, + { token: + [ 'keyword.alias.apacheconf', 'text', + 'entity.status.apacheconf', 'text', + 'string.path.apacheconf', 'text', + 'string.path.apacheconf', 'text' ], + regex: '(Redirect)(?:(\\s+)(\\d\\d\\d|permanent|temp|seeother|gone))?(\\s+)(.+?)(\\s+)(?:(.+?)($|\\s))?' }, + { token: + [ 'keyword.alias.apacheconf', 'text', + 'string.regexp.apacheconf', 'text', + 'string.path.apacheconf', 'text' ], + regex: '(ScriptAliasMatch|AliasMatch)(\\s+)(.+?)(\\s+)(?:(.+?)(\\s))?' }, + { token: + [ 'keyword.alias.apacheconf', 'text', + 'string.path.apacheconf', 'text', + 'string.path.apacheconf', 'text' ], + regex: '(RedirectPermanent|RedirectTemp|ScriptAlias|Alias)(\\s+)(.+?)(\\s+)(?:(.+?)($|\\s))?' }, + { token: 'keyword.core.apacheconf', + regex: '\\b(?:AcceptPathInfo|AccessFileName|AddDefaultCharset|AddOutputFilterByType|AllowEncodedSlashes|AllowOverride|AuthName|AuthType|CGIMapExtension|ContentDigest|DefaultType|DocumentRoot|EnableMMAP|EnableSendfile|ErrorDocument|ErrorLog|FileETag|ForceType|HostnameLookups|IdentityCheck|Include|KeepAlive|KeepAliveTimeout|LimitInternalRecursion|LimitRequestBody|LimitRequestFields|LimitRequestFieldSize|LimitRequestLine|LimitXMLRequestBody|LogLevel|MaxKeepAliveRequests|NameVirtualHost|Options|Require|RLimitCPU|RLimitMEM|RLimitNPROC|Satisfy|ScriptInterpreterSource|ServerAdmin|ServerAlias|ServerName|ServerPath|ServerRoot|ServerSignature|ServerTokens|SetHandler|SetInputFilter|SetOutputFilter|TimeOut|TraceEnable|UseCanonicalName)\\b' }, + { token: 'keyword.mpm.apacheconf', + regex: '\\b(?:AcceptMutex|AssignUserID|BS2000Account|ChildPerUserID|CoreDumpDirectory|EnableExceptionHook|Group|Listen|ListenBacklog|LockFile|MaxClients|MaxMemFree|MaxRequestsPerChild|MaxRequestsPerThread|MaxSpareServers|MaxSpareThreads|MaxThreads|MaxThreadsPerChild|MinSpareServers|MinSpareThreads|NumServers|PidFile|ReceiveBufferSize|ScoreBoardFile|SendBufferSize|ServerLimit|StartServers|StartThreads|ThreadLimit|ThreadsPerChild|ThreadStackSize|User|Win32DisableAcceptEx)\\b' }, + { token: 'keyword.access.apacheconf', + regex: '\\b(?:Allow|Deny|Order)\\b' }, + { token: 'keyword.actions.apacheconf', + regex: '\\b(?:Action|Script)\\b' }, + { token: 'keyword.alias.apacheconf', + regex: '\\b(?:Alias|AliasMatch|Redirect|RedirectMatch|RedirectPermanent|RedirectTemp|ScriptAlias|ScriptAliasMatch)\\b' }, + { token: 'keyword.auth.apacheconf', + regex: '\\b(?:AuthAuthoritative|AuthGroupFile|AuthUserFile)\\b' }, + { token: 'keyword.auth_anon.apacheconf', + regex: '\\b(?:Anonymous|Anonymous_Authoritative|Anonymous_LogEmail|Anonymous_MustGiveEmail|Anonymous_NoUserID|Anonymous_VerifyEmail)\\b' }, + { token: 'keyword.auth_dbm.apacheconf', + regex: '\\b(?:AuthDBMAuthoritative|AuthDBMGroupFile|AuthDBMType|AuthDBMUserFile)\\b' }, + { token: 'keyword.auth_digest.apacheconf', + regex: '\\b(?:AuthDigestAlgorithm|AuthDigestDomain|AuthDigestFile|AuthDigestGroupFile|AuthDigestNcCheck|AuthDigestNonceFormat|AuthDigestNonceLifetime|AuthDigestQop|AuthDigestShmemSize)\\b' }, + { token: 'keyword.auth_ldap.apacheconf', + regex: '\\b(?:AuthLDAPAuthoritative|AuthLDAPBindDN|AuthLDAPBindPassword|AuthLDAPCharsetConfig|AuthLDAPCompareDNOnServer|AuthLDAPDereferenceAliases|AuthLDAPEnabled|AuthLDAPFrontPageHack|AuthLDAPGroupAttribute|AuthLDAPGroupAttributeIsDN|AuthLDAPRemoteUserIsDN|AuthLDAPUrl)\\b' }, + { token: 'keyword.autoindex.apacheconf', + regex: '\\b(?:AddAlt|AddAltByEncoding|AddAltByType|AddDescription|AddIcon|AddIconByEncoding|AddIconByType|DefaultIcon|HeaderName|IndexIgnore|IndexOptions|IndexOrderDefault|ReadmeName)\\b' }, + { token: 'keyword.cache.apacheconf', + regex: '\\b(?:CacheDefaultExpire|CacheDisable|CacheEnable|CacheForceCompletion|CacheIgnoreCacheControl|CacheIgnoreHeaders|CacheIgnoreNoLastMod|CacheLastModifiedFactor|CacheMaxExpire)\\b' }, + { token: 'keyword.cern_meta.apacheconf', + regex: '\\b(?:MetaDir|MetaFiles|MetaSuffix)\\b' }, + { token: 'keyword.cgi.apacheconf', + regex: '\\b(?:ScriptLog|ScriptLogBuffer|ScriptLogLength)\\b' }, + { token: 'keyword.cgid.apacheconf', + regex: '\\b(?:ScriptLog|ScriptLogBuffer|ScriptLogLength|ScriptSock)\\b' }, + { token: 'keyword.charset_lite.apacheconf', + regex: '\\b(?:CharsetDefault|CharsetOptions|CharsetSourceEnc)\\b' }, + { token: 'keyword.dav.apacheconf', + regex: '\\b(?:Dav|DavDepthInfinity|DavMinTimeout|DavLockDB)\\b' }, + { token: 'keyword.deflate.apacheconf', + regex: '\\b(?:DeflateBufferSize|DeflateCompressionLevel|DeflateFilterNote|DeflateMemLevel|DeflateWindowSize)\\b' }, + { token: 'keyword.dir.apacheconf', + regex: '\\b(?:DirectoryIndex|DirectorySlash)\\b' }, + { token: 'keyword.disk_cache.apacheconf', + regex: '\\b(?:CacheDirLength|CacheDirLevels|CacheExpiryCheck|CacheGcClean|CacheGcDaily|CacheGcInterval|CacheGcMemUsage|CacheGcUnused|CacheMaxFileSize|CacheMinFileSize|CacheRoot|CacheSize|CacheTimeMargin)\\b' }, + { token: 'keyword.dumpio.apacheconf', + regex: '\\b(?:DumpIOInput|DumpIOOutput)\\b' }, + { token: 'keyword.env.apacheconf', + regex: '\\b(?:PassEnv|SetEnv|UnsetEnv)\\b' }, + { token: 'keyword.expires.apacheconf', + regex: '\\b(?:ExpiresActive|ExpiresByType|ExpiresDefault)\\b' }, + { token: 'keyword.ext_filter.apacheconf', + regex: '\\b(?:ExtFilterDefine|ExtFilterOptions)\\b' }, + { token: 'keyword.file_cache.apacheconf', + regex: '\\b(?:CacheFile|MMapFile)\\b' }, + { token: 'keyword.headers.apacheconf', + regex: '\\b(?:Header|RequestHeader)\\b' }, + { token: 'keyword.imap.apacheconf', + regex: '\\b(?:ImapBase|ImapDefault|ImapMenu)\\b' }, + { token: 'keyword.include.apacheconf', + regex: '\\b(?:SSIEndTag|SSIErrorMsg|SSIStartTag|SSITimeFormat|SSIUndefinedEcho|XBitHack)\\b' }, + { token: 'keyword.isapi.apacheconf', + regex: '\\b(?:ISAPIAppendLogToErrors|ISAPIAppendLogToQuery|ISAPICacheFile|ISAPIFakeAsync|ISAPILogNotSupported|ISAPIReadAheadBuffer)\\b' }, + { token: 'keyword.ldap.apacheconf', + regex: '\\b(?:LDAPCacheEntries|LDAPCacheTTL|LDAPConnectionTimeout|LDAPOpCacheEntries|LDAPOpCacheTTL|LDAPSharedCacheFile|LDAPSharedCacheSize|LDAPTrustedCA|LDAPTrustedCAType)\\b' }, + { token: 'keyword.log.apacheconf', + regex: '\\b(?:BufferedLogs|CookieLog|CustomLog|LogFormat|TransferLog|ForensicLog)\\b' }, + { token: 'keyword.mem_cache.apacheconf', + regex: '\\b(?:MCacheMaxObjectCount|MCacheMaxObjectSize|MCacheMaxStreamingBuffer|MCacheMinObjectSize|MCacheRemovalAlgorithm|MCacheSize)\\b' }, + { token: 'keyword.mime.apacheconf', + regex: '\\b(?:AddCharset|AddEncoding|AddHandler|AddInputFilter|AddLanguage|AddOutputFilter|AddType|DefaultLanguage|ModMimeUsePathInfo|MultiviewsMatch|RemoveCharset|RemoveEncoding|RemoveHandler|RemoveInputFilter|RemoveLanguage|RemoveOutputFilter|RemoveType|TypesConfig)\\b' }, + { token: 'keyword.misc.apacheconf', + regex: '\\b(?:ProtocolEcho|Example|AddModuleInfo|MimeMagicFile|CheckSpelling|ExtendedStatus|SuexecUserGroup|UserDir)\\b' }, + { token: 'keyword.negotiation.apacheconf', + regex: '\\b(?:CacheNegotiatedDocs|ForceLanguagePriority|LanguagePriority)\\b' }, + { token: 'keyword.nw_ssl.apacheconf', + regex: '\\b(?:NWSSLTrustedCerts|NWSSLUpgradeable|SecureListen)\\b' }, + { token: 'keyword.proxy.apacheconf', + regex: '\\b(?:AllowCONNECT|NoProxy|ProxyBadHeader|ProxyBlock|ProxyDomain|ProxyErrorOverride|ProxyFtpDirCharset|ProxyIOBufferSize|ProxyMaxForwards|ProxyPass|ProxyPassReverse|ProxyPreserveHost|ProxyReceiveBufferSize|ProxyRemote|ProxyRemoteMatch|ProxyRequests|ProxyTimeout|ProxyVia)\\b' }, + { token: 'keyword.rewrite.apacheconf', + regex: '\\b(?:RewriteBase|RewriteCond|RewriteEngine|RewriteLock|RewriteLog|RewriteLogLevel|RewriteMap|RewriteOptions|RewriteRule)\\b' }, + { token: 'keyword.setenvif.apacheconf', + regex: '\\b(?:BrowserMatch|BrowserMatchNoCase|SetEnvIf|SetEnvIfNoCase)\\b' }, + { token: 'keyword.so.apacheconf', + regex: '\\b(?:LoadFile|LoadModule)\\b' }, + { token: 'keyword.ssl.apacheconf', + regex: '\\b(?:SSLCACertificateFile|SSLCACertificatePath|SSLCARevocationFile|SSLCARevocationPath|SSLCertificateChainFile|SSLCertificateFile|SSLCertificateKeyFile|SSLCipherSuite|SSLEngine|SSLMutex|SSLOptions|SSLPassPhraseDialog|SSLProtocol|SSLProxyCACertificateFile|SSLProxyCACertificatePath|SSLProxyCARevocationFile|SSLProxyCARevocationPath|SSLProxyCipherSuite|SSLProxyEngine|SSLProxyMachineCertificateFile|SSLProxyMachineCertificatePath|SSLProxyProtocol|SSLProxyVerify|SSLProxyVerifyDepth|SSLRandomSeed|SSLRequire|SSLRequireSSL|SSLSessionCache|SSLSessionCacheTimeout|SSLUserName|SSLVerifyClient|SSLVerifyDepth)\\b' }, + { token: 'keyword.usertrack.apacheconf', + regex: '\\b(?:CookieDomain|CookieExpires|CookieName|CookieStyle|CookieTracking)\\b' }, + { token: 'keyword.vhost_alias.apacheconf', + regex: '\\b(?:VirtualDocumentRoot|VirtualDocumentRootIP|VirtualScriptAlias|VirtualScriptAliasIP)\\b' }, + { token: + [ 'keyword.php.apacheconf', + 'text', + 'entity.property.apacheconf', + 'text', + 'string.value.apacheconf', + 'text' ], + regex: '\\b(php_value|php_flag)\\b(?:(\\s+)(.+?)(?:(\\s+)(.+?))?)?(\\s)' }, + { token: + [ 'punctuation.variable.apacheconf', + 'variable.env.apacheconf', + 'variable.misc.apacheconf', + 'punctuation.variable.apacheconf' ], + regex: '(%\\{)(?:(HTTP_USER_AGENT|HTTP_REFERER|HTTP_COOKIE|HTTP_FORWARDED|HTTP_HOST|HTTP_PROXY_CONNECTION|HTTP_ACCEPT|REMOTE_ADDR|REMOTE_HOST|REMOTE_PORT|REMOTE_USER|REMOTE_IDENT|REQUEST_METHOD|SCRIPT_FILENAME|PATH_INFO|QUERY_STRING|AUTH_TYPE|DOCUMENT_ROOT|SERVER_ADMIN|SERVER_NAME|SERVER_ADDR|SERVER_PORT|SERVER_PROTOCOL|SERVER_SOFTWARE|TIME_YEAR|TIME_MON|TIME_DAY|TIME_HOUR|TIME_MIN|TIME_SEC|TIME_WDAY|TIME|API_VERSION|THE_REQUEST|REQUEST_URI|REQUEST_FILENAME|IS_SUBREQ|HTTPS)|(.*?))(\\})' }, + { token: [ 'entity.mime-type.apacheconf', 'text' ], + regex: '\\b((?:text|image|application|video|audio)/.+?)(\\s)' }, + { token: 'entity.helper.apacheconf', + regex: '\\b(?:from|unset|set|on|off)\\b', + caseInsensitive: true }, + { token: 'constant.integer.apacheconf', regex: '\\b\\d+\\b' }, + { token: + [ 'text', + 'punctuation.definition.flag.apacheconf', + 'string.flag.apacheconf', + 'punctuation.definition.flag.apacheconf', + 'text' ], + regex: '(\\s)(\\[)(.*?)(\\])(\\s)' } ] } + + this.normalizeRules(); +}; + +ApacheConfHighlightRules.metaData = { fileTypes: + [ 'conf', + 'CONF', + 'htaccess', + 'HTACCESS', + 'htgroups', + 'HTGROUPS', + 'htpasswd', + 'HTPASSWD', + '.htaccess', + '.HTACCESS', + '.htgroups', + '.HTGROUPS', + '.htpasswd', + '.HTPASSWD' ], + name: 'Apache Conf', + scopeName: 'source.apacheconf' } + + +oop.inherits(ApacheConfHighlightRules, TextHighlightRules); + +exports.ApacheConfHighlightRules = ApacheConfHighlightRules; +}); \ No newline at end of file diff --git a/lib/ace/mode/applescript.js b/lib/ace/mode/applescript.js new file mode 100644 index 00000000..81bc3533 --- /dev/null +++ b/lib/ace/mode/applescript.js @@ -0,0 +1,55 @@ +/* ***** 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. + * + * ***** END LICENSE BLOCK ***** */ + +define(function(require, exports, module) { +"use strict"; + +var oop = require("../lib/oop"); +var TextMode = require("./text").Mode; +var Tokenizer = require("../tokenizer").Tokenizer; +var AppleScriptHighlightRules = require("./applescript_highlight_rules").AppleScriptHighlightRules; +// TODO: pick appropriate fold mode +var FoldMode = require("./folding/cstyle").FoldMode; + +var Mode = function() { + this.HighlightRules = AppleScriptHighlightRules; + this.foldingRules = new FoldMode(); +}; +oop.inherits(Mode, TextMode); + +(function() { + this.lineCommentStart = "--"; + this.blockComment = {start: "(*", end: "*)"}; + this.$id = "ace/mode/applescript"; + // Extra logic goes here. +}).call(Mode.prototype); + +exports.Mode = Mode; +}); diff --git a/lib/ace/mode/applescript_highlight_rules.js b/lib/ace/mode/applescript_highlight_rules.js new file mode 100644 index 00000000..d830d780 --- /dev/null +++ b/lib/ace/mode/applescript_highlight_rules.js @@ -0,0 +1,139 @@ +/* ***** 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. + * + * ***** END LICENSE BLOCK ***** */ + +define(function(require, exports, module) { +"use strict"; + +var oop = require("../lib/oop"); +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +var AppleScriptHighlightRules = function() { + // regexp must not have capturing parentheses. Use (?:) instead. + // regexps are ordered -> the first match is used + var keywords = ( + "about|above|after|against|and|around|as|at|back|before|beginning|" + + "behind|below|beneath|beside|between|but|by|considering|" + + "contain|contains|continue|copy|div|does|eighth|else|end|equal|" + + "equals|error|every|exit|fifth|first|for|fourth|from|front|" + + "get|given|global|if|ignoring|in|into|is|it|its|last|local|me|" + + "middle|mod|my|ninth|not|of|on|onto|or|over|prop|property|put|ref|" + + "reference|repeat|returning|script|second|set|seventh|since|" + + "sixth|some|tell|tenth|that|the|then|third|through|thru|" + + "timeout|times|to|transaction|try|until|where|while|whose|with|without" + ); + + var builtinConstants = ( + "AppleScript|false|linefeed|return|pi|quote|result|space|tab|true" + ); + + var builtinFunctions = ( + "activate|beep|count|delay|launch|log|offset|read|round|run|say|" + + "summarize|write" + ); + + var builtinTypes = ( + "alias|application|boolean|class|constant|date|file|integer|list|" + + "number|real|record|string|text|character|characters|contents|day|" + + "frontmost|id|item|length|month|name|paragraph|paragraphs|rest|" + + "reverse|running|time|version|weekday|word|words|year" + ); + + var keywordMapper = this.createKeywordMapper({ + "support.function": builtinFunctions, + "constant.language": builtinConstants, + "support.type": builtinTypes, + "keyword": keywords + }, "identifier"); + + this.$rules = { + "start": [ + { + token: "comment", + regex: "--.*$" + }, + { + token : "comment", // multi line comment + regex : "\\(\\*", + next : "comment" + }, + { + token: "string", // " string + regex: '".*?"' + }, + { + token: "support.type", + regex: '\\b(POSIX file|POSIX path|(date|time) string|quoted form)\\b' + }, + { + token: "support.function", + regex: '\\b(clipboard info|the clipboard|info for|list (disks|folder)|' + + 'mount volume|path to|(close|open for) access|(get|set) eof|' + + 'current date|do shell script|get volume settings|random number|' + + 'set volume|system attribute|system info|time to GMT|' + + '(load|run|store) script|scripting components|' + + 'ASCII (character|number)|localized string|' + + 'choose (application|color|file|file name|' + + 'folder|from list|remote application|URL)|' + + 'display (alert|dialog))\\b|^\\s*return\\b' + }, + { + token: "constant.language", + regex: '\\b(text item delimiters|current application|missing value)\\b' + }, + { + token: "keyword", + regex: '\\b(apart from|aside from|instead of|out of|greater than|' + + "isn't|(doesn't|does not) (equal|come before|come after|contain)|" + + '(greater|less) than( or equal)?|(starts?|ends|begins?) with|' + + 'contained by|comes (before|after)|a (ref|reference))\\b' + }, + { + token: keywordMapper, + regex: "[a-zA-Z][a-zA-Z0-9_]*\\b" + } + ], + "comment": [ + { + token: "comment", // closing comment + regex: "\\*\\)", + next: "start" + }, { + defaultToken: "comment" + } + ] + } + + this.normalizeRules(); +}; + +oop.inherits(AppleScriptHighlightRules, TextHighlightRules); + +exports.AppleScriptHighlightRules = AppleScriptHighlightRules; +}); diff --git a/lib/ace/mode/asciidoc.js b/lib/ace/mode/asciidoc.js index b4e83f67..894d9763 100644 --- a/lib/ace/mode/asciidoc.js +++ b/lib/ace/mode/asciidoc.js @@ -33,19 +33,18 @@ define(function(require, exports, module) { var oop = require("../lib/oop"); var TextMode = require("./text").Mode; -var Tokenizer = require("../tokenizer").Tokenizer; var AsciidocHighlightRules = require("./asciidoc_highlight_rules").AsciidocHighlightRules; var AsciidocFoldMode = require("./folding/asciidoc").FoldMode; var Mode = function() { - var highlighter = new AsciidocHighlightRules(); + this.HighlightRules = AsciidocHighlightRules; - this.$tokenizer = new Tokenizer(highlighter.getRules()); this.foldingRules = new AsciidocFoldMode(); }; oop.inherits(Mode, TextMode); (function() { + this.type = "text"; this.getNextLineIndent = function(state, line, tab) { if (state == "listblock") { var match = /^((?:.+)?)([-+*][ ]+)/.exec(line); @@ -58,6 +57,7 @@ oop.inherits(Mode, TextMode); return this.$getIndent(line); } }; + this.$id = "ace/mode/asciidoc"; }).call(Mode.prototype); exports.Mode = Mode; diff --git a/lib/ace/mode/assembly_x86.js b/lib/ace/mode/assembly_x86.js index e4d6d8f7..d6343e80 100644 --- a/lib/ace/mode/assembly_x86.js +++ b/lib/ace/mode/assembly_x86.js @@ -38,20 +38,18 @@ define(function(require, exports, module) { var oop = require("../lib/oop"); var TextMode = require("./text").Mode; -var Tokenizer = require("../tokenizer").Tokenizer; var AssemblyX86HighlightRules = require("./assembly_x86_highlight_rules").AssemblyX86HighlightRules; var FoldMode = require("./folding/coffee").FoldMode; var Mode = function() { - var highlighter = new AssemblyX86HighlightRules(); + this.HighlightRules = AssemblyX86HighlightRules; this.foldingRules = new FoldMode(); - this.$tokenizer = new Tokenizer(highlighter.getRules()); }; oop.inherits(Mode, TextMode); (function() { this.lineCommentStart = ";"; - // Extra logic goes here. + this.$id = "ace/mode/assembly_x86"; }).call(Mode.prototype); exports.Mode = Mode; diff --git a/lib/ace/mode/autohotkey.js b/lib/ace/mode/autohotkey.js index b8e69fd9..d7093fd5 100644 --- a/lib/ace/mode/autohotkey.js +++ b/lib/ace/mode/autohotkey.js @@ -26,11 +26,6 @@ * (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 ***** */ /* @@ -42,22 +37,20 @@ define(function(require, exports, module) { var oop = require("../lib/oop"); var TextMode = require("./text").Mode; -var Tokenizer = require("../tokenizer").Tokenizer; var AutoHotKeyHighlightRules = require("./autohotkey_highlight_rules").AutoHotKeyHighlightRules; // TODO: pick appropriate fold mode var FoldMode = require("./folding/cstyle").FoldMode; var Mode = function() { - var highlighter = new AutoHotKeyHighlightRules(); + this.HighlightRules = AutoHotKeyHighlightRules; this.foldingRules = new FoldMode(); - this.$tokenizer = new Tokenizer(highlighter.getRules()); }; oop.inherits(Mode, TextMode); (function() { - this.lineCommentStart = "/\\*"; + this.lineCommentStart = ";"; this.blockComment = {start: "/*", end: "*/"}; - // Extra logic goes here. + this.$id = "ace/mode/autohotkey"; }).call(Mode.prototype); exports.Mode = Mode; diff --git a/lib/ace/mode/batchfile.js b/lib/ace/mode/batchfile.js index 5b293c0b..e080464c 100644 --- a/lib/ace/mode/batchfile.js +++ b/lib/ace/mode/batchfile.js @@ -42,21 +42,19 @@ define(function(require, exports, module) { var oop = require("../lib/oop"); var TextMode = require("./text").Mode; -var Tokenizer = require("../tokenizer").Tokenizer; var BatchFileHighlightRules = require("./batchfile_highlight_rules").BatchFileHighlightRules; var FoldMode = require("./folding/cstyle").FoldMode; var Mode = function() { - var highlighter = new BatchFileHighlightRules(); + this.HighlightRules = BatchFileHighlightRules; this.foldingRules = new FoldMode(); - this.$tokenizer = new Tokenizer(highlighter.getRules()); }; oop.inherits(Mode, TextMode); (function() { this.lineCommentStart = "::"; this.blockComment = ""; - // Extra logic goes here. + this.$id = "ace/mode/batchfile"; }).call(Mode.prototype); exports.Mode = Mode; diff --git a/lib/ace/mode/batchfile_highlight_rules.js b/lib/ace/mode/batchfile_highlight_rules.js index 488edbb9..be0380d8 100644 --- a/lib/ace/mode/batchfile_highlight_rules.js +++ b/lib/ace/mode/batchfile_highlight_rules.js @@ -78,7 +78,8 @@ var BatchFileHighlightRules = function() { { token: 'keyword.operator.redirect.shell', regex: '&>|\\d*>&\\d*|\\d*(?:>>|>|<)|\\d*<&|\\d*<>' } ], variable: [ - { token: 'constant.numeric', regex: '%%\\w+'}, + { token: 'constant.numeric', regex: '%%\\w+|%[*\\d]|%\\w+%'}, + { token: 'constant.numeric', regex: '%~\\d+'}, { token: ['markup.list', 'constant.other', 'markup.list'], regex: '(%)(\\w+)(%?)' }]} diff --git a/lib/ace/mode/behaviour/behaviour_test.js b/lib/ace/mode/behaviour/behaviour_test.js new file mode 100644 index 00000000..245edf99 --- /dev/null +++ b/lib/ace/mode/behaviour/behaviour_test.js @@ -0,0 +1,179 @@ +/* ***** 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. + * + * ***** END LICENSE BLOCK ***** */ + +if (typeof process !== "undefined") { + require("amd-loader"); + require("../../test/mockdom"); +} + +define(function(require, exports, module) { +"use strict"; + +require("../../multi_select"); +var assert = require("../../test/assertions"); +var Range = require("../../range").Range; +var Editor = require("../../editor").Editor; +var EditSession = require("../../edit_session").EditSession; +var MockRenderer = require("../../test/mockrenderer").MockRenderer; +var JavaScriptMode = require("../javascript").Mode; +var XMLMode = require("../xml").Mode; +var editor; +var exec = function(name, times, args) { + do { + editor.commands.exec(name, editor, args); + } while(times --> 1); +}; +var testRanges = function(str) { + assert.equal(editor.selection.getAllRanges() + "", str + ""); +}; + +module.exports = { + "test: cstyle": function() { + function testValue(line) { + assert.equal(editor.getValue(), Array(4).join(line + "\n")); + } + function testSelection(line, col, inc) { + editor.selection.rangeList.ranges.forEach(function(r) { + assert.range(r, line, col, line, col); + line += (inc || 1); + }); + } + var doc = new EditSession([ + "", + "", + "", + "" + ], new JavaScriptMode()); + editor = new Editor(new MockRenderer(), doc); + editor.setOption("behavioursEnabled", true); + + editor.navigateFileStart(); + exec("addCursorBelow", 2); + + exec("insertstring", 1, "if "); + + // pairing ( + exec("insertstring", 1, "("); + testValue("if ()"); + testSelection(0, 4); + exec("insertstring", 1, ")"); + testValue("if ()"); + testSelection(0, 5); + + // pairing [ + exec("gotoleft", 1); + exec("insertstring", 1, "["); + testValue("if ([])"); + testSelection(0, 5); + + exec("insertstring", 1, "]"); + testValue("if ([])"); + testSelection(0, 6); + + // test deletion + exec("gotoleft", 1); + exec("backspace", 1); + testValue("if ()"); + testSelection(0, 4); + + exec("gotolineend", 1); + exec("insertstring", 1, "{"); + testValue("if (){}"); + testSelection(0, 6); + + exec("insertstring", 1, "}"); + testValue("if (){}"); + testSelection(0, 7); + + exec("gotolinestart", 1); + exec("insertstring", 1, "("); + testValue("(if (){}"); + exec("backspace", 1); + + editor.setValue(""); + exec("insertstring", 1, "{"); + assert.equal(editor.getValue(), "{"); + exec("insertstring", 1, "\n"); + assert.equal(editor.getValue(), "{\n \n}"); + + editor.setValue(""); + exec("insertstring", 1, "("); + exec("insertstring", 1, '"'); + exec("insertstring", 1, '"'); + assert.equal(editor.getValue(), '("")'); + exec("backspace", 1); + exec("insertstring", 1, '"'); + assert.equal(editor.getValue(), '("")'); + + editor.setValue("('foo')", 1); + exec("gotoleft", 1); + exec("selectleft", 1); + exec("selectMoreBefore", 1); + exec("insertstring", 1, "'"); + assert.equal(editor.getValue(), "('foo')"); + exec("selectleft", 1); + exec("insertstring", 1, '"'); + assert.equal(editor.getValue(), '("foo")'); + exec("selectleft", 1); + exec("insertstring", 1, '"'); + assert.equal(editor.getValue(), '("foo")'); + + editor.setValue("", 1); + exec("selectleft", 1); + exec("insertstring", 1, '"'); + assert.equal(editor.getValue(), '""'); + exec("insertstring", 1, '\\'); + exec("insertstring", 1, 'n'); + exec("insertstring", 1, '"'); + assert.equal(editor.getValue(), '"\\n"'); + + }, + "test: xml": function() { + editor = new Editor(new MockRenderer()); + editor.setValue(["", + " " + ].join("\n")); + editor.session.setMode(new XMLMode); + exec("gotolinedown", 1); + exec("gotolineend", 1); + exec("insertstring", 1, '\n'); + assert.equal(editor.session.getLine(2), " "); + exec("gotolineup", 1); + exec("gotolineend", 1); + exec("insertstring", 1, '\n'); + assert.equal(editor.session.getLine(2), " "); + } +}; + +}); + +if (typeof module !== "undefined" && module === require.main) { + require("asyncjs").test.testcase(module.exports).exec(); +} diff --git a/lib/ace/mode/behaviour/cstyle.js b/lib/ace/mode/behaviour/cstyle.js index 54f75526..dd1b0d14 100644 --- a/lib/ace/mode/behaviour/cstyle.js +++ b/lib/ace/mode/behaviour/cstyle.js @@ -41,98 +41,53 @@ var SAFE_INSERT_IN_TOKENS = var SAFE_INSERT_BEFORE_TOKENS = ["text", "paren.rparen", "punctuation.operator", "comment"]; +var context; +var contextCache = {}; +var initContext = function(editor) { + var id = -1; + if (editor.multiSelect) { + id = editor.selection.index; + if (contextCache.rangeCount != editor.multiSelect.rangeCount) + contextCache = {rangeCount: editor.multiSelect.rangeCount}; + } + if (contextCache[id]) + return context = contextCache[id]; + context = contextCache[id] = { + autoInsertedBrackets: 0, + autoInsertedRow: -1, + autoInsertedLineEnd: "", + maybeInsertedBrackets: 0, + maybeInsertedRow: -1, + maybeInsertedLineStart: "", + maybeInsertedLineEnd: "" + }; +}; -var autoInsertedBrackets = 0; -var autoInsertedRow = -1; -var autoInsertedLineEnd = ""; -var maybeInsertedBrackets = 0; -var maybeInsertedRow = -1; -var maybeInsertedLineStart = ""; -var maybeInsertedLineEnd = ""; +var getWrapped = function(selection, selected, opening, closing) { + var rowDiff = selection.end.row - selection.start.row; + return { + text: opening + selected + closing, + selection: [ + 0, + selection.start.column + 1, + rowDiff, + selection.end.column + (rowDiff ? 0 : 1) + ] + }; +}; -var CstyleBehaviour = function () { - - CstyleBehaviour.isSaneInsertion = function(editor, session) { - var cursor = editor.getCursorPosition(); - var iterator = new TokenIterator(session, cursor.row, cursor.column); - - // Don't insert in the middle of a keyword/identifier/lexical - if (!this.$matchTokenType(iterator.getCurrentToken() || "text", SAFE_INSERT_IN_TOKENS)) { - // Look ahead in case we're at the end of a token - var iterator2 = new TokenIterator(session, cursor.row, cursor.column + 1); - if (!this.$matchTokenType(iterator2.getCurrentToken() || "text", SAFE_INSERT_IN_TOKENS)) - return false; - } - - // Only insert in front of whitespace/comments - iterator.stepForward(); - return iterator.getCurrentTokenRow() !== cursor.row || - this.$matchTokenType(iterator.getCurrentToken() || "text", SAFE_INSERT_BEFORE_TOKENS); - }; - - CstyleBehaviour.$matchTokenType = function(token, types) { - return types.indexOf(token.type || token) > -1; - }; - - CstyleBehaviour.recordAutoInsert = function(editor, session, bracket) { - var cursor = editor.getCursorPosition(); - var line = session.doc.getLine(cursor.row); - // Reset previous state if text or context changed too much - if (!this.isAutoInsertedClosing(cursor, line, autoInsertedLineEnd[0])) - autoInsertedBrackets = 0; - autoInsertedRow = cursor.row; - autoInsertedLineEnd = bracket + line.substr(cursor.column); - autoInsertedBrackets++; - }; - - CstyleBehaviour.recordMaybeInsert = function(editor, session, bracket) { - var cursor = editor.getCursorPosition(); - var line = session.doc.getLine(cursor.row); - if (!this.isMaybeInsertedClosing(cursor, line)) - maybeInsertedBrackets = 0; - maybeInsertedRow = cursor.row; - maybeInsertedLineStart = line.substr(0, cursor.column) + bracket; - maybeInsertedLineEnd = line.substr(cursor.column); - maybeInsertedBrackets++; - }; - - CstyleBehaviour.isAutoInsertedClosing = function(cursor, line, bracket) { - return autoInsertedBrackets > 0 && - cursor.row === autoInsertedRow && - bracket === autoInsertedLineEnd[0] && - line.substr(cursor.column) === autoInsertedLineEnd; - }; - - CstyleBehaviour.isMaybeInsertedClosing = function(cursor, line) { - return maybeInsertedBrackets > 0 && - cursor.row === maybeInsertedRow && - line.substr(cursor.column) === maybeInsertedLineEnd && - line.substr(0, cursor.column) == maybeInsertedLineStart; - }; - - CstyleBehaviour.popAutoInsertedClosing = function() { - autoInsertedLineEnd = autoInsertedLineEnd.substr(1); - autoInsertedBrackets--; - }; - - CstyleBehaviour.clearMaybeInsertedClosing = function() { - maybeInsertedBrackets = 0; - maybeInsertedRow = -1; - }; - - this.add("braces", "insertion", function (state, action, editor, session, text) { +var CstyleBehaviour = function() { + this.add("braces", "insertion", function(state, action, editor, session, text) { var cursor = editor.getCursorPosition(); var line = session.doc.getLine(cursor.row); if (text == '{') { + initContext(editor); var selection = editor.getSelectionRange(); var selected = session.doc.getTextRange(selection); if (selected !== "" && selected !== "{" && editor.getWrapBehavioursEnabled()) { - return { - text: '{' + selected + '}', - selection: false - }; + return getWrapped(selection, selected, '{', '}'); } else if (CstyleBehaviour.isSaneInsertion(editor, session)) { - if (/[\]\}\)]/.test(line[cursor.column])) { + if (/[\]\}\)]/.test(line[cursor.column]) || editor.inMultiSelectMode) { CstyleBehaviour.recordAutoInsert(editor, session, "}"); return { text: '{}', @@ -147,6 +102,7 @@ var CstyleBehaviour = function () { } } } else if (text == '}') { + initContext(editor); var rightChar = line.substring(cursor.column, cursor.column + 1); if (rightChar == '}') { var matching = session.$findOpeningBracket('}', {column: cursor.column + 1, row: cursor.row}); @@ -159,51 +115,57 @@ var CstyleBehaviour = function () { } } } else if (text == "\n" || text == "\r\n") { + initContext(editor); var closing = ""; if (CstyleBehaviour.isMaybeInsertedClosing(cursor, line)) { - closing = lang.stringRepeat("}", maybeInsertedBrackets); + closing = lang.stringRepeat("}", context.maybeInsertedBrackets); CstyleBehaviour.clearMaybeInsertedClosing(); } var rightChar = line.substring(cursor.column, cursor.column + 1); - if (rightChar == '}' || closing !== "") { - var openBracePos = session.findMatchingBracket({row: cursor.row, column: cursor.column}, '}'); + if (rightChar === '}') { + var openBracePos = session.findMatchingBracket({row: cursor.row, column: cursor.column+1}, '}'); if (!openBracePos) return null; - - var indent = this.getNextLineIndent(state, line.substring(0, cursor.column), session.getTabString()); + var next_indent = this.$getIndent(session.getLine(openBracePos.row)); + } else if (closing) { var next_indent = this.$getIndent(line); - - return { - text: '\n' + indent + '\n' + next_indent + closing, - selection: [1, indent.length, 1, indent.length] - }; + } else { + CstyleBehaviour.clearMaybeInsertedClosing(); + return; } + var indent = next_indent + session.getTabString(); + + return { + text: '\n' + indent + '\n' + next_indent + closing, + selection: [1, indent.length, 1, indent.length] + }; + } else { + CstyleBehaviour.clearMaybeInsertedClosing(); } }); - this.add("braces", "deletion", function (state, action, editor, session, range) { + this.add("braces", "deletion", function(state, action, editor, session, range) { var selected = session.doc.getTextRange(range); if (!range.isMultiLine() && selected == '{') { + initContext(editor); var line = session.doc.getLine(range.start.row); var rightChar = line.substring(range.end.column, range.end.column + 1); if (rightChar == '}') { range.end.column++; return range; } else { - maybeInsertedBrackets--; + context.maybeInsertedBrackets--; } } }); - this.add("parens", "insertion", function (state, action, editor, session, text) { + this.add("parens", "insertion", function(state, action, editor, session, text) { if (text == '(') { + initContext(editor); var selection = editor.getSelectionRange(); var selected = session.doc.getTextRange(selection); if (selected !== "" && editor.getWrapBehavioursEnabled()) { - return { - text: '(' + selected + ')', - selection: false - }; + return getWrapped(selection, selected, '(', ')'); } else if (CstyleBehaviour.isSaneInsertion(editor, session)) { CstyleBehaviour.recordAutoInsert(editor, session, ")"); return { @@ -212,6 +174,7 @@ var CstyleBehaviour = function () { }; } } else if (text == ')') { + initContext(editor); var cursor = editor.getCursorPosition(); var line = session.doc.getLine(cursor.row); var rightChar = line.substring(cursor.column, cursor.column + 1); @@ -228,9 +191,10 @@ var CstyleBehaviour = function () { } }); - this.add("parens", "deletion", function (state, action, editor, session, range) { + this.add("parens", "deletion", function(state, action, editor, session, range) { var selected = session.doc.getTextRange(range); if (!range.isMultiLine() && selected == '(') { + initContext(editor); var line = session.doc.getLine(range.start.row); var rightChar = line.substring(range.start.column + 1, range.start.column + 2); if (rightChar == ')') { @@ -240,15 +204,13 @@ var CstyleBehaviour = function () { } }); - this.add("brackets", "insertion", function (state, action, editor, session, text) { + this.add("brackets", "insertion", function(state, action, editor, session, text) { if (text == '[') { + initContext(editor); var selection = editor.getSelectionRange(); var selected = session.doc.getTextRange(selection); if (selected !== "" && editor.getWrapBehavioursEnabled()) { - return { - text: '[' + selected + ']', - selection: false - }; + return getWrapped(selection, selected, '[', ']'); } else if (CstyleBehaviour.isSaneInsertion(editor, session)) { CstyleBehaviour.recordAutoInsert(editor, session, "]"); return { @@ -257,6 +219,7 @@ var CstyleBehaviour = function () { }; } } else if (text == ']') { + initContext(editor); var cursor = editor.getCursorPosition(); var line = session.doc.getLine(cursor.row); var rightChar = line.substring(cursor.column, cursor.column + 1); @@ -273,9 +236,10 @@ var CstyleBehaviour = function () { } }); - this.add("brackets", "deletion", function (state, action, editor, session, range) { + this.add("brackets", "deletion", function(state, action, editor, session, range) { var selected = session.doc.getTextRange(range); if (!range.isMultiLine() && selected == '[') { + initContext(editor); var line = session.doc.getLine(range.start.row); var rightChar = line.substring(range.start.column + 1, range.start.column + 2); if (rightChar == ']') { @@ -285,69 +249,60 @@ var CstyleBehaviour = function () { } }); - this.add("string_dquotes", "insertion", function (state, action, editor, session, text) { + this.add("string_dquotes", "insertion", function(state, action, editor, session, text) { if (text == '"' || text == "'") { + initContext(editor); var quote = text; var selection = editor.getSelectionRange(); var selected = session.doc.getTextRange(selection); if (selected !== "" && selected !== "'" && selected != '"' && editor.getWrapBehavioursEnabled()) { - return { - text: quote + selected + quote, - selection: false - }; - } else { + return getWrapped(selection, selected, quote, quote); + } else if (!selected) { var cursor = editor.getCursorPosition(); var line = session.doc.getLine(cursor.row); var leftChar = line.substring(cursor.column-1, cursor.column); - + var rightChar = line.substring(cursor.column, cursor.column + 1); + + var token = session.getTokenAt(cursor.row, cursor.column); + var rightToken = session.getTokenAt(cursor.row, cursor.column + 1); // We're escaped. - if (leftChar == '\\') { + if (leftChar == "\\" && token && /escape/.test(token.type)) return null; + + var stringBefore = token && /string|escape/.test(token.type); + var stringAfter = !rightToken || /string|escape/.test(rightToken.type); + + var pair; + if (rightChar == quote) { + pair = stringBefore !== stringAfter; + } else { + if (stringBefore && !stringAfter) + return null; // wrap string with different quote + if (stringBefore && stringAfter) + return null; // do not pair quotes inside strings + var wordRe = session.$mode.tokenRe; + wordRe.lastIndex = 0; + var isWordBefore = wordRe.test(leftChar); + wordRe.lastIndex = 0; + var isWordAfter = wordRe.test(leftChar); + if (isWordBefore || isWordAfter) + return null; // before or after alphanumeric + if (rightChar && !/[\s;,.})\]\\]/.test(rightChar)) + return null; // there is rightChar and it isn't closing + pair = true; } - - // Find what token we're inside. - var tokens = session.getTokens(selection.start.row); - var col = 0, token; - var quotepos = -1; // Track whether we're inside an open quote. - - for (var x = 0; x < tokens.length; x++) { - token = tokens[x]; - if (token.type == "string") { - quotepos = -1; - } else if (quotepos < 0) { - quotepos = token.value.indexOf(quote); - } - if ((token.value.length + col) > selection.start.column) { - break; - } - col += tokens[x].value.length; - } - - // Try and be smart about when we auto insert. - if (!token || (quotepos < 0 && token.type !== "comment" && (token.type !== "string" || ((selection.start.column !== token.value.length+col-1) && token.value.lastIndexOf(quote) === token.value.length-1)))) { - if (!CstyleBehaviour.isSaneInsertion(editor, session)) - return; - return { - text: quote + quote, - selection: [1,1] - }; - } else if (token && token.type === "string") { - // Ignore input and move right one if we're typing over the closing quote. - var rightChar = line.substring(cursor.column, cursor.column + 1); - if (rightChar == quote) { - return { - text: '', - selection: [1, 1] - }; - } - } + return { + text: pair ? quote + quote : "", + selection: [1,1] + }; } } }); - this.add("string_dquotes", "deletion", function (state, action, editor, session, range) { + this.add("string_dquotes", "deletion", function(state, action, editor, session, range) { var selected = session.doc.getTextRange(range); if (!range.isMultiLine() && (selected == '"' || selected == "'")) { + initContext(editor); var line = session.doc.getLine(range.start.row); var rightChar = line.substring(range.start.column + 1, range.start.column + 2); if (rightChar == selected) { @@ -359,6 +314,79 @@ var CstyleBehaviour = function () { }; + +CstyleBehaviour.isSaneInsertion = function(editor, session) { + var cursor = editor.getCursorPosition(); + var iterator = new TokenIterator(session, cursor.row, cursor.column); + + // Don't insert in the middle of a keyword/identifier/lexical + if (!this.$matchTokenType(iterator.getCurrentToken() || "text", SAFE_INSERT_IN_TOKENS)) { + // Look ahead in case we're at the end of a token + var iterator2 = new TokenIterator(session, cursor.row, cursor.column + 1); + if (!this.$matchTokenType(iterator2.getCurrentToken() || "text", SAFE_INSERT_IN_TOKENS)) + return false; + } + + // Only insert in front of whitespace/comments + iterator.stepForward(); + return iterator.getCurrentTokenRow() !== cursor.row || + this.$matchTokenType(iterator.getCurrentToken() || "text", SAFE_INSERT_BEFORE_TOKENS); +}; + +CstyleBehaviour.$matchTokenType = function(token, types) { + return types.indexOf(token.type || token) > -1; +}; + +CstyleBehaviour.recordAutoInsert = function(editor, session, bracket) { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + // Reset previous state if text or context changed too much + if (!this.isAutoInsertedClosing(cursor, line, context.autoInsertedLineEnd[0])) + context.autoInsertedBrackets = 0; + context.autoInsertedRow = cursor.row; + context.autoInsertedLineEnd = bracket + line.substr(cursor.column); + context.autoInsertedBrackets++; +}; + +CstyleBehaviour.recordMaybeInsert = function(editor, session, bracket) { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + if (!this.isMaybeInsertedClosing(cursor, line)) + context.maybeInsertedBrackets = 0; + context.maybeInsertedRow = cursor.row; + context.maybeInsertedLineStart = line.substr(0, cursor.column) + bracket; + context.maybeInsertedLineEnd = line.substr(cursor.column); + context.maybeInsertedBrackets++; +}; + +CstyleBehaviour.isAutoInsertedClosing = function(cursor, line, bracket) { + return context.autoInsertedBrackets > 0 && + cursor.row === context.autoInsertedRow && + bracket === context.autoInsertedLineEnd[0] && + line.substr(cursor.column) === context.autoInsertedLineEnd; +}; + +CstyleBehaviour.isMaybeInsertedClosing = function(cursor, line) { + return context.maybeInsertedBrackets > 0 && + cursor.row === context.maybeInsertedRow && + line.substr(cursor.column) === context.maybeInsertedLineEnd && + line.substr(0, cursor.column) == context.maybeInsertedLineStart; +}; + +CstyleBehaviour.popAutoInsertedClosing = function() { + context.autoInsertedLineEnd = context.autoInsertedLineEnd.substr(1); + context.autoInsertedBrackets--; +}; + +CstyleBehaviour.clearMaybeInsertedClosing = function() { + if (context) { + context.maybeInsertedBrackets = 0; + context.maybeInsertedRow = -1; + } +}; + + + oop.inherits(CstyleBehaviour, Behaviour); exports.CstyleBehaviour = CstyleBehaviour; diff --git a/lib/ace/mode/behaviour/html.js b/lib/ace/mode/behaviour/html.js index e7a74cf9..181655c0 100644 --- a/lib/ace/mode/behaviour/html.js +++ b/lib/ace/mode/behaviour/html.js @@ -33,60 +33,13 @@ define(function(require, exports, module) { var oop = require("../../lib/oop"); var XmlBehaviour = require("../behaviour/xml").XmlBehaviour; -var CstyleBehaviour = require("./cstyle").CstyleBehaviour; -var TokenIterator = require("../../token_iterator").TokenIterator; -var voidElements = ['area', 'base', 'br', 'col', 'command', 'embed', 'hr', 'img', 'input', 'keygen', 'link', 'meta', 'param', 'source', 'track', 'wbr']; - -function hasType(token, type) { - var hasType = true; - var typeList = token.type.split('.'); - var needleList = type.split('.'); - needleList.forEach(function(needle){ - if (typeList.indexOf(needle) == -1) { - hasType = false; - return false; - } - }); - return hasType; -} var HtmlBehaviour = function () { - this.inherit(XmlBehaviour); // Get xml behaviour - - this.add("autoclosing", "insertion", function (state, action, editor, session, text) { - if (text == '>') { - var position = editor.getCursorPosition(); - var iterator = new TokenIterator(session, position.row, position.column); - var token = iterator.getCurrentToken(); + XmlBehaviour.call(this); + +}; - if (hasType(token, 'string') && iterator.getCurrentTokenColumn() + token.value.length > position.column) - return; - var atCursor = false; - if (!token || !hasType(token, 'meta.tag') && !(hasType(token, 'text') && token.value.match('/'))){ - do { - token = iterator.stepBackward(); - } while (token && (hasType(token, 'string') || hasType(token, 'keyword.operator') || hasType(token, 'entity.attribute-name') || hasType(token, 'text'))); - } else { - atCursor = true; - } - if (!token || !hasType(token, 'meta.tag-name') || iterator.stepBackward().value.match('/')) { - return - } - var element = token.value; - if (atCursor){ - var element = element.substring(0, position.column - token.start); - } - if (voidElements.indexOf(element) !== -1){ - return; - } - return { - text: '>' + '', - selection: [1, 1] - } - } - }); -} oop.inherits(HtmlBehaviour, XmlBehaviour); exports.HtmlBehaviour = HtmlBehaviour; diff --git a/lib/ace/mode/behaviour/xml.js b/lib/ace/mode/behaviour/xml.js index 0d03b763..068fdb31 100644 --- a/lib/ace/mode/behaviour/xml.js +++ b/lib/ace/mode/behaviour/xml.js @@ -3,7 +3,7 @@ * * 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 @@ -14,7 +14,7 @@ * * 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 @@ -33,72 +33,171 @@ define(function(require, exports, module) { var oop = require("../../lib/oop"); var Behaviour = require("../behaviour").Behaviour; -var CstyleBehaviour = require("./cstyle").CstyleBehaviour; var TokenIterator = require("../../token_iterator").TokenIterator; +var lang = require("../../lib/lang"); -function hasType(token, type) { - var hasType = true; - var typeList = token.type.split('.'); - var needleList = type.split('.'); - needleList.forEach(function(needle){ - if (typeList.indexOf(needle) == -1) { - hasType = false; - return false; - } - }); - return hasType; +function is(token, type) { + return token.type.lastIndexOf(type + ".xml") > -1; } var XmlBehaviour = function () { - - this.inherit(CstyleBehaviour, ["string_dquotes"]); // Get string behaviour - + + this.add("string_dquotes", "insertion", function (state, action, editor, session, text) { + if (text == '"' || text == "'") { + var quote = text; + var selected = session.doc.getTextRange(editor.getSelectionRange()); + if (selected !== "" && selected !== "'" && selected != '"' && editor.getWrapBehavioursEnabled()) { + return { + text: quote + selected + quote, + selection: false + }; + } + + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var rightChar = line.substring(cursor.column, cursor.column + 1); + var iterator = new TokenIterator(session, cursor.row, cursor.column); + var token = iterator.getCurrentToken(); + + if (rightChar == quote && (is(token, "attribute-value") || is(token, "string"))) { + // Ignore input and move right one if we're typing over the closing quote. + return { + text: "", + selection: [1, 1] + }; + } + + if (!token) + token = iterator.stepBackward(); + + if (!token) + return; + + while (is(token, "tag-whitespace") || is(token, "whitespace")) { + token = iterator.stepBackward(); + } + var rightSpace = !rightChar || rightChar.match(/\s/); + if (is(token, "attribute-equals") && (rightSpace || rightChar == '>') || (is(token, "decl-attribute-equals") && (rightSpace || rightChar == '?'))) { + return { + text: quote + quote, + selection: [1, 1] + }; + } + } + }); + + this.add("string_dquotes", "deletion", function(state, action, editor, session, range) { + var selected = session.doc.getTextRange(range); + if (!range.isMultiLine() && (selected == '"' || selected == "'")) { + var line = session.doc.getLine(range.start.row); + var rightChar = line.substring(range.start.column + 1, range.start.column + 2); + if (rightChar == selected) { + range.end.column++; + return range; + } + } + }); + this.add("autoclosing", "insertion", function (state, action, editor, session, text) { if (text == '>') { var position = editor.getCursorPosition(); var iterator = new TokenIterator(session, position.row, position.column); - var token = iterator.getCurrentToken(); - var atCursor = false; - if (!token || !hasType(token, 'meta.tag') && !(hasType(token, 'text') && token.value.match('/'))){ - do { - token = iterator.stepBackward(); - } while (token && (hasType(token, 'string') || hasType(token, 'keyword.operator') || hasType(token, 'entity.attribute-name') || hasType(token, 'text'))); - } else { - atCursor = true; - } - if (!token || !hasType(token, 'meta.tag-name') || iterator.stepBackward().value.match('/')) { - return - } - var tag = token.value; - if (atCursor){ - var tag = tag.substring(0, position.column - token.start); + var token = iterator.getCurrentToken() || iterator.stepBackward(); + + // exit if we're not in a tag + if (!token || !(is(token, "tag-name") || is(token, "tag-whitespace") || is(token, "attribute-name") || is(token, "attribute-equals") || is(token, "attribute-value"))) + return; + + // exit if we're inside of a quoted attribute value + if (is(token, "reference.attribute-value")) + return; + if (is(token, "attribute-value")) { + var firstChar = token.value.charAt(0); + if (firstChar == '"' || firstChar == "'") { + var lastChar = token.value.charAt(token.value.length - 1); + var tokenEnd = iterator.getCurrentTokenColumn() + token.value.length; + if (tokenEnd > position.column || tokenEnd == position.column && firstChar != lastChar) + return; + } } - return { - text: '>' + '', - selection: [1, 1] + // find tag name + while (!is(token, "tag-name")) { + token = iterator.stepBackward(); } + + var tokenRow = iterator.getCurrentTokenRow(); + var tokenColumn = iterator.getCurrentTokenColumn(); + + // exit if the tag is ending + if (is(iterator.stepBackward(), "end-tag-open")) + return; + + var element = token.value; + if (tokenRow == position.row) + element = element.substring(0, position.column - tokenColumn); + + if (this.voidElements.hasOwnProperty(element.toLowerCase())) + return; + + return { + text: ">" + "", + selection: [1, 1] + }; } }); - this.add('autoindent', 'insertion', function (state, action, editor, session, text) { + this.add("autoindent", "insertion", function (state, action, editor, session, text) { if (text == "\n") { var cursor = editor.getCursorPosition(); - var line = session.doc.getLine(cursor.row); - var rightChars = line.substring(cursor.column, cursor.column + 2); - if (rightChars == '") + return; + //get tag name + while (token && token.type.indexOf("tag-name") === -1) { + token = iterator.stepBackward(); + } + + if (!token) { + return; + } + + var tag = token.value; + var row = iterator.getCurrentTokenRow(); + + //don't indent after closing tag + token = iterator.stepBackward(); + if (!token || token.type.indexOf("end-tag") !== -1) { + return; + } + + if (this.voidElements && !this.voidElements[tag]) { + var nextToken = session.getTokenAt(cursor.row, cursor.column+1); + var line = session.getLine(row); + var nextIndent = this.$getIndent(line); + var indent = nextIndent + session.getTabString(); + + if (nextToken && nextToken.value === " the first match is used - this.$rules = { + this.$rules = { "start" : [ { token : "comment", - regex : "\\/\\/.*$" + regex : "//", + next : "singleLineComment" }, DocCommentHighlightRules.getStartRule("doc-start"), { @@ -82,11 +84,11 @@ var c_cppHighlightRules = function() { regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?(L|l|UL|ul|u|U|F|f|ll|LL|ull|ULL)?\\b" }, { token : "keyword", // pre-compiler directives - regex : "#\\s*(?:include|import|pragma|line|define|undef|if|ifdef|else|elif|ifndef)\\b", + regex : "#\\s*(?:include|import|pragma|line|define|undef)\\b", next : "directive" }, { token : "keyword", // special case pre-compiler directive - regex : "(?:#\\s*endif)\\b" + regex : "#\\s*(?:endif|if|ifdef|else|elif|ifndef)\\b" }, { token : "support.function.C99.c", regex : cFunctions @@ -120,14 +122,26 @@ var c_cppHighlightRules = function() { regex : ".+" } ], + "singleLineComment" : [ + { + token : "comment", + regex : /\\$/, + next : "singleLineComment" + }, { + token : "comment", + regex : /$/, + next : "start" + }, { + defaultToken: "comment" + } + ], "qqstring" : [ { token : "string", regex : '(?:(?:\\\\.)|(?:[^"\\\\]))*?"', next : "start" }, { - token : "string", - regex : '.+' + defaultToken : "string" } ], "qstring" : [ @@ -136,8 +150,7 @@ var c_cppHighlightRules = function() { regex : "(?:(?:\\\\.)|(?:[^'\\\\]))*?'", next : "start" }, { - token : "string", - regex : '.+' + defaultToken : "string" } ], "directive" : [ diff --git a/lib/ace/mode/cirru.js b/lib/ace/mode/cirru.js new file mode 100644 index 00000000..5f1c4d9e --- /dev/null +++ b/lib/ace/mode/cirru.js @@ -0,0 +1,51 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2014, 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. + * + * ***** END LICENSE BLOCK ***** */ + +define(function(require, exports, module) { +"use strict"; + +var oop = require("../lib/oop"); +var TextMode = require("./text").Mode; +var CirruHighlightRules = require("./cirru_highlight_rules").CirruHighlightRules; +var CoffeeFoldMode = require("./folding/coffee").FoldMode; + +var Mode = function() { + this.HighlightRules = CirruHighlightRules; + this.foldingRules = new CoffeeFoldMode(); +}; +oop.inherits(Mode, TextMode); + +(function() { + this.lineCommentStart = "--"; + this.$id = "ace/mode/cirru"; +}).call(Mode.prototype); + +exports.Mode = Mode; +}); diff --git a/lib/ace/mode/cirru_highlight_rules.js b/lib/ace/mode/cirru_highlight_rules.js new file mode 100644 index 00000000..737ec0be --- /dev/null +++ b/lib/ace/mode/cirru_highlight_rules.js @@ -0,0 +1,125 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2014, 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. + * + * ***** END LICENSE BLOCK ***** */ + +define(function(require, exports, module) { +"use strict"; + +var oop = require("../lib/oop"); +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +// see http://cirru.org for more about this language +var CirruHighlightRules = function() { + this.$rules = { + start: [{ + token: 'constant.numeric', + regex: /[\d\.]+/ + }, { + token: 'comment.line.double-dash', + regex: /--/, + next: 'comment', + }, { + token: 'storage.modifier', + regex: /\(/, + }, { + token: 'storage.modifier', + regex: /\,/, + next: 'line', + }, { + token: 'support.function', + regex: /[^\(\)\"\s]+/, + next: 'line' + }, { + token: 'string.quoted.double', + regex: /"/, + next: 'string', + }, { + token: 'storage.modifier', + regex: /\)/, + }], + comment: [{ + token: 'comment.line.double-dash', + regex: /\ +[^\n]+/, + next: 'start', + }], + string: [{ + token: 'string.quoted.double', + regex: /"/, + next: 'line', + }, { + token: 'constant.character.escape', + regex: /\\/, + next: 'escape', + }, { + token: 'string.quoted.double', + regex: /[^\\\"]+/, + }], + escape: [{ + token: 'constant.character.escape', + regex: /./, + next: 'string', + }], + line: [{ + token: 'constant.numeric', + regex: /[\d\.]+/ + }, { + token: 'markup.raw', + regex: /^\s*/, + next: 'start', + }, { + token: 'storage.modifier', + regex: /\$/, + next: 'start', + }, { + token: 'variable.parameter', + regex: /[^\(\)\"\s]+/ + }, { + token: 'storage.modifier', + regex: /\(/, + next: 'start' + }, { + token: 'storage.modifier', + regex: /\)/, + }, { + token: 'markup.raw', + regex: /^\ */, + next: 'start', + }, { + token: 'string.quoted.double', + regex: /"/, + next: 'string', + }] + } + +}; + +oop.inherits(CirruHighlightRules, TextHighlightRules); + +exports.CirruHighlightRules = CirruHighlightRules; +}); diff --git a/lib/ace/mode/clojure.js b/lib/ace/mode/clojure.js index d1494e02..ee44ac3e 100644 --- a/lib/ace/mode/clojure.js +++ b/lib/ace/mode/clojure.js @@ -3,7 +3,7 @@ * * 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 @@ -14,7 +14,7 @@ * * 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 @@ -33,13 +33,11 @@ define(function(require, exports, module) { var oop = require("../lib/oop"); var TextMode = require("./text").Mode; -var Tokenizer = require("../tokenizer").Tokenizer; var ClojureHighlightRules = require("./clojure_highlight_rules").ClojureHighlightRules; var MatchingParensOutdent = require("./matching_parens_outdent").MatchingParensOutdent; -var Range = require("../range").Range; var Mode = function() { - this.$tokenizer = new Tokenizer(new ClojureHighlightRules().getRules()); + this.HighlightRules = ClojureHighlightRules; this.$outdent = new MatchingParensOutdent(); }; oop.inherits(Mode, TextMode); @@ -47,29 +45,72 @@ oop.inherits(Mode, TextMode); (function() { this.lineCommentStart = ";"; + this.minorIndentFunctions = ["defn", "defn-", "defmacro", "def", "deftest", "testing"]; + + this.$toIndent = function(str) { + return str.split('').map(function(ch) { + if (/\s/.exec(ch)) { + return ch; + } else { + return ' '; + } + }).join(''); + }; + + this.$calculateIndent = function(line, tab) { + var baseIndent = this.$getIndent(line); + var delta = 0; + var isParen, ch; + // Walk back from end of line, find matching braces + for (var i = line.length - 1; i >= 0; i--) { + ch = line[i]; + if (ch === '(') { + delta--; + isParen = true; + } else if (ch === '(' || ch === '[' || ch === '{') { + delta--; + isParen = false; + } else if (ch === ')' || ch === ']' || ch === '}') { + delta++; + } + if (delta < 0) { + break; + } + } + if (delta < 0 && isParen) { + // Were more brackets opened than closed and was a ( left open? + i += 1; + var iBefore = i; + var fn = ''; + while (true) { + ch = line[i]; + if (ch === ' ' || ch === '\t') { + if(this.minorIndentFunctions.indexOf(fn) !== -1) { + return this.$toIndent(line.substring(0, iBefore - 1) + tab); + } else { + return this.$toIndent(line.substring(0, i + 1)); + } + } else if (ch === undefined) { + return this.$toIndent(line.substring(0, iBefore - 1) + tab); + } + fn += line[i]; + i++; + } + } else if(delta < 0 && !isParen) { + // Were more brackets openend than closed and was it not a (? + return this.$toIndent(line.substring(0, i+1)); + } else if(delta > 0) { + // Mere more brackets closed than opened? Outdent. + baseIndent = baseIndent.substring(0, baseIndent.length - tab.length); + return baseIndent; + } else { + // Were they nicely matched? Just indent like line before. + return baseIndent; + } + }; this.getNextLineIndent = function(state, line, tab) { - var indent = this.$getIndent(line); - - var tokenizedLine = this.$tokenizer.getLineTokens(line, state); - var tokens = tokenizedLine.tokens; - - if (tokens.length && tokens[tokens.length-1].type == "comment") { - return indent; - } - - if (state == "start") { - var match = line.match(/[\(\[]/); - if (match) { - indent += " "; - } - match = line.match(/[\)]/); - if (match) { - indent = ""; - } - } - - return indent; + return this.$calculateIndent(line, tab); }; this.checkOutdent = function(state, line, input) { @@ -80,6 +121,7 @@ oop.inherits(Mode, TextMode); this.$outdent.autoOutdent(doc, row); }; + this.$id = "ace/mode/clojure"; }).call(Mode.prototype); exports.Mode = Mode; diff --git a/lib/ace/mode/cobol.js b/lib/ace/mode/cobol.js index 4ff2f7ef..91713bd0 100644 --- a/lib/ace/mode/cobol.js +++ b/lib/ace/mode/cobol.js @@ -33,12 +33,11 @@ define(function(require, exports, module) { var oop = require("../lib/oop"); var TextMode = require("./text").Mode; -var Tokenizer = require("../tokenizer").Tokenizer; var CobolHighlightRules = require("./cobol_highlight_rules").CobolHighlightRules; var Range = require("../range").Range; var Mode = function() { - this.$tokenizer = new Tokenizer(new CobolHighlightRules().getRules()); + this.HighlightRules = CobolHighlightRules; }; oop.inherits(Mode, TextMode); @@ -46,6 +45,7 @@ oop.inherits(Mode, TextMode); this.lineCommentStart = "*"; + this.$id = "ace/mode/cobol"; }).call(Mode.prototype); exports.Mode = Mode; diff --git a/lib/ace/mode/coffee.js b/lib/ace/mode/coffee.js index b2bb55ad..e866f2b0 100644 --- a/lib/ace/mode/coffee.js +++ b/lib/ace/mode/coffee.js @@ -31,7 +31,6 @@ define(function(require, exports, module) { "use strict"; -var Tokenizer = require("../tokenizer").Tokenizer; var Rules = require("./coffee_highlight_rules").CoffeeHighlightRules; var Outdent = require("./matching_brace_outdent").MatchingBraceOutdent; var FoldMode = require("./folding/coffee").FoldMode; @@ -41,7 +40,7 @@ var WorkerClient = require("../worker/worker_client").WorkerClient; var oop = require("../lib/oop"); function Mode() { - this.$tokenizer = new Tokenizer(new Rules().getRules()); + this.HighlightRules = Rules; this.$outdent = new Outdent(); this.foldingRules = new FoldMode(); } @@ -50,14 +49,35 @@ oop.inherits(Mode, TextMode); (function() { - var indenter = /(?:[({[=:]|[-=]>|\b(?:else|switch|try|catch(?:\s*[$A-Za-z_\x7f-\uffff][$\w\x7f-\uffff]*)?|finally))\s*$/; + /*: + [({[=:] # Opening parentheses or brackets + |[-=]> # OR single or double arrow + |\b(?: # OR one of these words: + else # else + |try # OR try + |(?:swi|ca)tch # OR catch, optionally followed by: + (?:\s*[$A-Za-z_\x7f-\uffff][$\w\x7f-\uffff]*)? # a variable + |finally # OR finally + ))\s*$ # all as the last thing on a line (allowing trailing space) + | # ---- OR ---- : + ^\s* # a line starting with optional space + (else\b\s*)? # followed by an optional "else" + (?: # followed by one of the following: + if # if + |for # OR for + |while # OR while + |loop # OR loop + )\b # (as a word) + (?!.*\bthen\b) # ... but NOT followed by "then" on the line + */ + var indenter = /(?:[({[=:]|[-=]>|\b(?:else|try|(?:swi|ca)tch(?:\s+[$A-Za-z_\x7f-\uffff][$\w\x7f-\uffff]*)?|finally))\s*$|^\s*(else\b\s*)?(?:if|for|while|loop)\b(?!.*\bthen\b)/; var commentLine = /^(\s*)#/; var hereComment = /^\s*###(?!#)/; var indentation = /^\s*/; this.getNextLineIndent = function(state, line, tab) { var indent = this.$getIndent(line); - var tokens = this.$tokenizer.getLineTokens(line, state).tokens; + var tokens = this.getTokenizer().getLineTokens(line, state).tokens; if (!(tokens.length && tokens[tokens.length - 1].type === 'comment') && state === 'start' && indenter.test(line)) @@ -96,17 +116,18 @@ oop.inherits(Mode, TextMode); var worker = new WorkerClient(["ace"], "ace/mode/coffee_worker", "Worker"); worker.attachToDocument(session.getDocument()); - worker.on("error", function(e) { - session.setAnnotations([e.data]); + worker.on("annotate", function(e) { + session.setAnnotations(e.data); }); - worker.on("ok", function(e) { + worker.on("terminate", function() { session.clearAnnotations(); }); return worker; }; + this.$id = "ace/mode/coffee"; }).call(Mode.prototype); exports.Mode = Mode; diff --git a/lib/ace/mode/coffee/helpers.js b/lib/ace/mode/coffee/helpers.js index 0ea2f3fe..60412fc6 100644 --- a/lib/ace/mode/coffee/helpers.js +++ b/lib/ace/mode/coffee/helpers.js @@ -25,9 +25,9 @@ */ define(function(require, exports, module) { -// Generated by CoffeeScript 1.6.2 +// Generated by CoffeeScript 1.6.3 - var buildLocationData, extend, flatten, last, repeat, _ref; + var buildLocationData, extend, flatten, last, repeat, syntaxErrorToString, _ref; exports.starts = function(string, literal, start) { return literal === string.substr(start, literal.length); @@ -194,7 +194,7 @@ define(function(require, exports, module) { pathSep = useWinPathSep ? /\\|\// : /\//; parts = file.split(pathSep); file = parts[parts.length - 1]; - if (!stripExt) { + if (!(stripExt && file.indexOf('.') >= 0)) { return file; } parts = file.split('.'); @@ -214,37 +214,57 @@ define(function(require, exports, module) { }; exports.throwSyntaxError = function(message, location) { - var error, _ref1, _ref2; - if ((_ref1 = location.last_line) == null) { + var error; + if (location.last_line == null) { location.last_line = location.first_line; } - if ((_ref2 = location.last_column) == null) { + if (location.last_column == null) { location.last_column = location.first_column; } error = new SyntaxError(message); error.location = location; + error.toString = syntaxErrorToString; + error.stack = error.toString(); throw error; }; - exports.prettyErrorMessage = function(error, fileName, code, useColors) { - var codeLine, colorize, end, first_column, first_line, last_column, last_line, marker, message, start, _ref1; - if (!error.location) { - return error.stack || ("" + error); + exports.updateSyntaxError = function(error, code, filename) { + if (error.toString === syntaxErrorToString) { + error.code || (error.code = code); + error.filename || (error.filename = filename); + error.stack = error.toString(); } - _ref1 = error.location, first_line = _ref1.first_line, first_column = _ref1.first_column, last_line = _ref1.last_line, last_column = _ref1.last_column; - codeLine = code.split('\n')[first_line]; + return error; + }; + + syntaxErrorToString = function() { + var codeLine, colorize, colorsEnabled, end, filename, first_column, first_line, last_column, last_line, marker, start, _ref1, _ref2; + if (!(this.code && this.location)) { + return Error.prototype.toString.call(this); + } + _ref1 = this.location, first_line = _ref1.first_line, first_column = _ref1.first_column, last_line = _ref1.last_line, last_column = _ref1.last_column; + if (last_line == null) { + last_line = first_line; + } + if (last_column == null) { + last_column = first_column; + } + filename = this.filename || '[stdin]'; + codeLine = this.code.split('\n')[first_line]; start = first_column; end = first_line === last_line ? last_column + 1 : codeLine.length; marker = repeat(' ', start) + repeat('^', end - start); - if (useColors) { + if (typeof process !== "undefined" && process !== null) { + colorsEnabled = process.stdout.isTTY && !process.env.NODE_DISABLE_COLORS; + } + if ((_ref2 = this.colorful) != null ? _ref2 : colorsEnabled) { colorize = function(str) { return "\x1B[1;31m" + str + "\x1B[0m"; }; codeLine = codeLine.slice(0, start) + colorize(codeLine.slice(start, end)) + codeLine.slice(end); marker = colorize(marker); } - message = "" + fileName + ":" + (first_line + 1) + ":" + (first_column + 1) + ": error: " + error.message + "\n" + codeLine + "\n" + marker; - return message; + return "" + filename + ":" + (first_line + 1) + ":" + (first_column + 1) + ": error: " + this.message + "\n" + codeLine + "\n" + marker; }; diff --git a/lib/ace/mode/coffee/lexer.js b/lib/ace/mode/coffee/lexer.js index e493b09d..05d85236 100644 --- a/lib/ace/mode/coffee/lexer.js +++ b/lib/ace/mode/coffee/lexer.js @@ -25,14 +25,14 @@ */ define(function(require, exports, module) { -// Generated by CoffeeScript 1.6.2 +// Generated by CoffeeScript 1.6.3 - var BOM, BOOL, CALLABLE, CODE, COFFEE_ALIASES, COFFEE_ALIAS_MAP, COFFEE_KEYWORDS, COMMENT, COMPARE, COMPOUND_ASSIGN, HEREDOC, HEREDOC_ILLEGAL, HEREDOC_INDENT, HEREGEX, HEREGEX_OMIT, IDENTIFIER, INDEXABLE, INVERSES, JSTOKEN, JS_FORBIDDEN, JS_KEYWORDS, LINE_BREAK, LINE_CONTINUER, LOGIC, Lexer, MATH, MULTILINER, MULTI_DENT, NOT_REGEX, NOT_SPACED_REGEX, NUMBER, OPERATOR, REGEX, RELATION, RESERVED, Rewriter, SHIFT, SIMPLESTR, STRICT_PROSCRIBED, TRAILING_SPACES, UNARY, WHITESPACE, compact, count, invertLiterate, key, last, locationDataToString, starts, throwSyntaxError, _ref, _ref1, + var BOM, BOOL, CALLABLE, CODE, COFFEE_ALIASES, COFFEE_ALIAS_MAP, COFFEE_KEYWORDS, COMMENT, COMPARE, COMPOUND_ASSIGN, HEREDOC, HEREDOC_ILLEGAL, HEREDOC_INDENT, HEREGEX, HEREGEX_OMIT, IDENTIFIER, INDEXABLE, INVERSES, JSTOKEN, JS_FORBIDDEN, JS_KEYWORDS, LINE_BREAK, LINE_CONTINUER, LOGIC, Lexer, MATH, MULTILINER, MULTI_DENT, NOT_REGEX, NOT_SPACED_REGEX, NUMBER, OPERATOR, REGEX, RELATION, RESERVED, Rewriter, SHIFT, SIMPLESTR, STRICT_PROSCRIBED, TRAILING_SPACES, UNARY, WHITESPACE, compact, count, invertLiterate, key, last, locationDataToString, repeat, starts, throwSyntaxError, _ref, _ref1, __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }; _ref = require('./rewriter'), Rewriter = _ref.Rewriter, INVERSES = _ref.INVERSES; - _ref1 = require('./helpers'), count = _ref1.count, starts = _ref1.starts, compact = _ref1.compact, last = _ref1.last, invertLiterate = _ref1.invertLiterate, locationDataToString = _ref1.locationDataToString, throwSyntaxError = _ref1.throwSyntaxError; + _ref1 = require('./helpers'), count = _ref1.count, starts = _ref1.starts, compact = _ref1.compact, last = _ref1.last, repeat = _ref1.repeat, invertLiterate = _ref1.invertLiterate, locationDataToString = _ref1.locationDataToString, throwSyntaxError = _ref1.throwSyntaxError; exports.Lexer = Lexer = (function() { function Lexer() {} @@ -44,6 +44,7 @@ define(function(require, exports, module) { } this.literate = opts.literate; this.indent = 0; + this.baseIndent = 0; this.indebt = 0; this.outdebt = 0; this.indents = []; @@ -182,40 +183,35 @@ define(function(require, exports, module) { } lexedLength = number.length; if (octalLiteral = /^0o([0-7]+)/.exec(number)) { - number = '0x' + (parseInt(octalLiteral[1], 8)).toString(16); + number = '0x' + parseInt(octalLiteral[1], 8).toString(16); } if (binaryLiteral = /^0b([01]+)/.exec(number)) { - number = '0x' + (parseInt(binaryLiteral[1], 2)).toString(16); + number = '0x' + parseInt(binaryLiteral[1], 2).toString(16); } this.token('NUMBER', number, 0, lexedLength); return lexedLength; }; Lexer.prototype.stringToken = function() { - var match, octalEsc, string; - switch (this.chunk.charAt(0)) { + var octalEsc, quote, string, trimmed; + switch (quote = this.chunk.charAt(0)) { case "'": - if (!(match = SIMPLESTR.exec(this.chunk))) { - return 0; - } - string = match[0]; - this.token('STRING', string.replace(MULTILINER, '\\\n'), 0, string.length); + string = SIMPLESTR.exec(this.chunk)[0]; break; case '"': - if (!(string = this.balancedString(this.chunk, '"'))) { - return 0; - } - if (0 < string.indexOf('#{', 1)) { - this.interpolateString(string.slice(1, -1), { - strOffset: 1, - lexedLength: string.length - }); - } else { - this.token('STRING', this.escapeLines(string, 0, string.length)); - } - break; - default: - return 0; + string = this.balancedString(this.chunk, '"'); + } + if (!string) { + return 0; + } + trimmed = this.removeNewlines(string.slice(1, -1)); + if (quote === '"' && 0 < string.indexOf('#{', 1)) { + this.interpolateString(trimmed, { + strOffset: 1, + lexedLength: string.length + }); + } else { + this.token('STRING', quote + this.escapeLines(trimmed) + quote, 0, string.length); } if (octalEsc = /^(?:\\.|[^\\])*\\(?:0[0-7]|[1-7])/.test(string)) { this.error("octal escape sequences " + string + " are not allowed"); @@ -255,7 +251,7 @@ define(function(require, exports, module) { if (here) { this.token('HERECOMMENT', this.sanitizeHeredoc(here, { herecomment: true, - indent: Array(this.indent + 1).join(' ') + indent: repeat(' ', this.indent) }), 0, comment.length); } return comment.length; @@ -301,7 +297,7 @@ define(function(require, exports, module) { var body, flags, flagsOffset, heregex, plusToken, prev, re, tag, token, tokens, value, _i, _len, _ref2, _ref3, _ref4; heregex = match[0], body = match[1], flags = match[2]; if (0 > body.indexOf('#{')) { - re = body.replace(HEREGEX_OMIT, '').replace(/\//g, '\\/'); + re = this.escapeLines(body.replace(HEREGEX_OMIT, '$1$2').replace(/\//g, '\\/'), true); if (re.match(/^\*/)) { this.error('regular expressions cannot begin with `*`'); } @@ -320,7 +316,7 @@ define(function(require, exports, module) { if (tag === 'TOKENS') { tokens.push.apply(tokens, value); } else if (tag === 'NEOSTRING') { - if (!(value = value.replace(HEREGEX_OMIT, ''))) { + if (!(value = value.replace(HEREGEX_OMIT, '$1$2'))) { continue; } value = value.replace(/\\/g, '\\\\'); @@ -373,11 +369,17 @@ define(function(require, exports, module) { this.suppressNewlines(); return indent.length; } + if (!this.tokens.length) { + this.baseIndent = this.indent = size; + return indent.length; + } diff = size - this.indent + this.outdebt; this.token('INDENT', diff, indent.length - size, size); this.indents.push(diff); this.ends.push('OUTDENT'); this.outdebt = this.indebt = 0; + } else if (size < this.baseIndent) { + this.error('missing indentation', indent.length); } else { this.indebt = 0; this.outdentToken(this.indent - size, noNewlines, indent.length); @@ -621,10 +623,6 @@ define(function(require, exports, module) { offsetInChunk = offsetInChunk || 0; strOffset = strOffset || 0; lexedLength = lexedLength || str.length; - if (heredoc && str.length > 0 && str[0] === '\n') { - str = str.slice(1); - strOffset++; - } tokens = []; pi = 0; i = -1; @@ -737,7 +735,7 @@ define(function(require, exports, module) { column = this.chunkColumn; if (lineCount > 0) { lines = string.split('\n'); - column = (last(lines)).length; + column = last(lines).length; } else { column += string.length; } @@ -782,16 +780,31 @@ define(function(require, exports, module) { return LINE_CONTINUER.test(this.chunk) || ((_ref2 = this.tag()) === '\\' || _ref2 === '.' || _ref2 === '?.' || _ref2 === '?::' || _ref2 === 'UNARY' || _ref2 === 'MATH' || _ref2 === '+' || _ref2 === '-' || _ref2 === 'SHIFT' || _ref2 === 'RELATION' || _ref2 === 'COMPARE' || _ref2 === 'LOGIC' || _ref2 === 'THROW' || _ref2 === 'EXTENDS'); }; + Lexer.prototype.removeNewlines = function(str) { + return str.replace(/^\s*\n\s*/, '').replace(/([^\\]|\\\\)\s*\n\s*$/, '$1'); + }; + Lexer.prototype.escapeLines = function(str, heredoc) { - return str.replace(MULTILINER, heredoc ? '\\n' : ''); + str = str.replace(/\\[^\S\n]*(\n|\\)\s*/g, function(escaped, character) { + if (character === '\n') { + return ''; + } else { + return escaped; + } + }); + if (heredoc) { + return str.replace(MULTILINER, '\\n'); + } else { + return str.replace(/\s*\n\s*/g, ' '); + } }; Lexer.prototype.makeString = function(body, quote, heredoc) { if (!body) { return quote + quote; } - body = body.replace(/\\([\s\S])/g, function(match, contents) { - if (contents === '\n' || contents === quote) { + body = body.replace(RegExp("\\\\(" + quote + "|\\\\)", "g"), function(match, contents) { + if (contents === quote) { return contents; } else { return match; @@ -801,10 +814,15 @@ define(function(require, exports, module) { return quote + this.escapeLines(body, heredoc) + quote; }; - Lexer.prototype.error = function(message) { + Lexer.prototype.error = function(message, offset) { + var first_column, first_line, _ref2; + if (offset == null) { + offset = 0; + } + _ref2 = this.getLineAndColumnFromChunk(offset), first_line = _ref2[0], first_column = _ref2[1]; return throwSyntaxError(message, { - first_line: this.chunkLine, - first_column: this.chunkColumn + first_line: first_line, + first_column: first_column }); }; @@ -855,27 +873,27 @@ define(function(require, exports, module) { NUMBER = /^0b[01]+|^0o[0-7]+|^0x[\da-f]+|^\d*\.?\d+(?:e[+-]?\d+)?/i; - HEREDOC = /^("""|''')([\s\S]*?)(?:\n[^\n\S]*)?\1/; + HEREDOC = /^("""|''')((?:\\[\s\S]|[^\\])*?)(?:\n[^\n\S]*)?\1/; OPERATOR = /^(?:[-=]>|[-+*\/%<>&|^!?=]=|>>>=?|([-+:])\1|([&|<>])\2=?|\?(\.|::)|\.{2,3})/; WHITESPACE = /^[^\n\S]+/; - COMMENT = /^###([^#][\s\S]*?)(?:###[^\n\S]*|(?:###)$)|^(?:\s*#(?!##[^#]).*)+/; + COMMENT = /^###([^#][\s\S]*?)(?:###[^\n\S]*|###$)|^(?:\s*#(?!##[^#]).*)+/; CODE = /^[-=]>/; MULTI_DENT = /^(?:\n[^\n\S]*)+/; - SIMPLESTR = /^'[^\\']*(?:\\.[^\\']*)*'/; + SIMPLESTR = /^'[^\\']*(?:\\[\s\S][^\\']*)*'/; JSTOKEN = /^`[^\\`]*(?:\\.[^\\`]*)*`/; REGEX = /^(\/(?![\s=])[^[\/\n\\]*(?:(?:\\[\s\S]|\[[^\]\n\\]*(?:\\[\s\S][^\]\n\\]*)*])[^[\/\n\\]*)*\/)([imgy]{0,4})(?!\w)/; - HEREGEX = /^\/{3}([\s\S]+?)\/{3}([imgy]{0,4})(?!\w)/; + HEREGEX = /^\/{3}((?:\\?[\s\S])+?)\/{3}([imgy]{0,4})(?!\w)/; - HEREGEX_OMIT = /\s+(?:#.*)?/g; + HEREGEX_OMIT = /((?:\\\\)+)|\\(\s|\/)|\s+(?:#.*)?/g; MULTILINER = /\n/g; @@ -903,9 +921,9 @@ define(function(require, exports, module) { BOOL = ['TRUE', 'FALSE']; - NOT_REGEX = ['NUMBER', 'REGEX', 'BOOL', 'NULL', 'UNDEFINED', '++', '--', ']']; + NOT_REGEX = ['NUMBER', 'REGEX', 'BOOL', 'NULL', 'UNDEFINED', '++', '--']; - NOT_SPACED_REGEX = NOT_REGEX.concat(')', '}', 'THIS', 'IDENTIFIER', 'STRING'); + NOT_SPACED_REGEX = NOT_REGEX.concat(')', '}', 'THIS', 'IDENTIFIER', 'STRING', ']'); CALLABLE = ['IDENTIFIER', 'STRING', 'REGEX', ')', ']', '}', '?', '::', '@', 'THIS', 'SUPER']; diff --git a/lib/ace/mode/coffee/nodes.js b/lib/ace/mode/coffee/nodes.js index ef26ecf1..52afdf2c 100644 --- a/lib/ace/mode/coffee/nodes.js +++ b/lib/ace/mode/coffee/nodes.js @@ -25,9 +25,9 @@ */ define(function(require, exports, module) { -// Generated by CoffeeScript 1.6.2 +// Generated by CoffeeScript 1.6.3 - var Access, Arr, Assign, Base, Block, Call, Class, Closure, Code, CodeFragment, Comment, Existence, Extends, For, IDENTIFIER, IDENTIFIER_STR, IS_STRING, If, In, Index, LEVEL_ACCESS, LEVEL_COND, LEVEL_LIST, LEVEL_OP, LEVEL_PAREN, LEVEL_TOP, Literal, METHOD_DEF, NEGATE, NO, Obj, Op, Param, Parens, RESERVED, Range, Return, SIMPLENUM, STRICT_PROSCRIBED, Scope, Slice, Splat, Switch, TAB, THIS, Throw, Try, UTILITIES, Value, While, YES, addLocationDataFn, compact, del, ends, extend, flatten, fragmentsToText, last, locationDataToString, merge, multident, some, starts, throwSyntaxError, unfoldSoak, utility, _ref, _ref1, _ref2, _ref3, + var Access, Arr, Assign, Base, Block, Call, Class, Code, CodeFragment, Comment, Existence, Extends, For, HEXNUM, IDENTIFIER, IDENTIFIER_STR, IS_REGEX, IS_STRING, If, In, Index, LEVEL_ACCESS, LEVEL_COND, LEVEL_LIST, LEVEL_OP, LEVEL_PAREN, LEVEL_TOP, Literal, METHOD_DEF, NEGATE, NO, NUMBER, Obj, Op, Param, Parens, RESERVED, Range, Return, SIMPLENUM, STRICT_PROSCRIBED, Scope, Slice, Splat, Switch, TAB, THIS, Throw, Try, UTILITIES, Value, While, YES, addLocationDataFn, compact, del, ends, extend, flatten, fragmentsToText, isLiteralArguments, isLiteralThis, last, locationDataToString, merge, multident, parseNum, some, starts, throwSyntaxError, unfoldSoak, utility, _ref, _ref1, __hasProp = {}.hasOwnProperty, __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }, @@ -71,7 +71,7 @@ define(function(require, exports, module) { } CodeFragment.prototype.toString = function() { - return "" + this.code + [this.locationData ? ": " + locationDataToString(this.locationData) : void 0]; + return "" + this.code + (this.locationData ? ": " + locationDataToString(this.locationData) : ''); }; return CodeFragment; @@ -114,12 +114,24 @@ define(function(require, exports, module) { }; Base.prototype.compileClosure = function(o) { - var jumpNode; + var args, argumentsNode, func, jumpNode, meth; if (jumpNode = this.jumps()) { jumpNode.error('cannot use a pure statement in an expression'); } o.sharedScope = true; - return Closure.wrap(this).compileNode(o); + func = new Code([], Block.wrap([this])); + args = []; + if ((argumentsNode = this.contains(isLiteralArguments)) || this.contains(isLiteralThis)) { + args = [new Literal('this')]; + if (argumentsNode) { + meth = 'apply'; + args.push(new Literal('arguments')); + } else { + meth = 'call'; + } + func = new Value(func, [new Access(new Literal(meth))]); + } + return (new Call(func, args)).compileNode(o); }; Base.prototype.cache = function(o, level, reused) { @@ -256,7 +268,10 @@ define(function(require, exports, module) { Base.prototype.assigns = NO; Base.prototype.updateLocationDataIfMissing = function(locationData) { - this.locationData || (this.locationData = locationData); + if (this.locationData) { + return this; + } + this.locationData = locationData; return this.eachChild(function(child) { return child.updateLocationDataIfMissing(locationData); }); @@ -339,12 +354,12 @@ define(function(require, exports, module) { }; Block.prototype.jumps = function(o) { - var exp, _i, _len, _ref2; + var exp, jumpNode, _i, _len, _ref2; _ref2 = this.expressions; for (_i = 0, _len = _ref2.length; _i < _len; _i++) { exp = _ref2[_i]; - if (exp.jumps(o)) { - return exp; + if (jumpNode = exp.jumps(o)) { + return jumpNode; } } }; @@ -503,6 +518,8 @@ define(function(require, exports, module) { fragments.push(this.makeCode(scope.assignedVariables().join(",\n" + (this.tab + TAB)))); } fragments.push(this.makeCode(";\n" + (this.spaced ? '\n' : ''))); + } else if (fragments.length && post.length) { + fragments.push(this.makeCode("\n")); } } return fragments.concat(post); @@ -577,8 +594,7 @@ define(function(require, exports, module) { __extends(Undefined, _super); function Undefined() { - _ref2 = Undefined.__super__.constructor.apply(this, arguments); - return _ref2; + return Undefined.__super__.constructor.apply(this, arguments); } Undefined.prototype.isAssignable = NO; @@ -597,8 +613,7 @@ define(function(require, exports, module) { __extends(Null, _super); function Null() { - _ref3 = Null.__super__.constructor.apply(this, arguments); - return _ref3; + return Null.__super__.constructor.apply(this, arguments); } Null.prototype.isAssignable = NO; @@ -650,8 +665,8 @@ define(function(require, exports, module) { Return.prototype.jumps = THIS; Return.prototype.compileToFragments = function(o, level) { - var expr, _ref4; - expr = (_ref4 = this.expression) != null ? _ref4.makeReturn() : void 0; + var expr, _ref2; + expr = (_ref2 = this.expression) != null ? _ref2.makeReturn() : void 0; if (expr && !(expr instanceof Return)) { return expr.compileToFragments(o, level); } else { @@ -662,7 +677,7 @@ define(function(require, exports, module) { Return.prototype.compileNode = function(o) { var answer; answer = []; - answer.push(this.makeCode(this.tab + ("return" + [this.expression ? " " : void 0]))); + answer.push(this.makeCode(this.tab + ("return" + (this.expression ? " " : "")))); if (this.expression) { answer = answer.concat(this.expression.compileToFragments(o, LEVEL_PAREN)); } @@ -700,8 +715,16 @@ define(function(require, exports, module) { return !!this.properties.length; }; + Value.prototype.bareLiteral = function(type) { + return !this.properties.length && this.base instanceof type; + }; + Value.prototype.isArray = function() { - return !this.properties.length && this.base instanceof Arr; + return this.bareLiteral(Arr); + }; + + Value.prototype.isRange = function() { + return this.bareLiteral(Range); }; Value.prototype.isComplex = function() { @@ -713,18 +736,22 @@ define(function(require, exports, module) { }; Value.prototype.isSimpleNumber = function() { - return this.base instanceof Literal && SIMPLENUM.test(this.base.value); + return this.bareLiteral(Literal) && SIMPLENUM.test(this.base.value); }; Value.prototype.isString = function() { - return this.base instanceof Literal && IS_STRING.test(this.base.value); + return this.bareLiteral(Literal) && IS_STRING.test(this.base.value); + }; + + Value.prototype.isRegex = function() { + return this.bareLiteral(Literal) && IS_REGEX.test(this.base.value); }; Value.prototype.isAtomic = function() { - var node, _i, _len, _ref4; - _ref4 = this.properties.concat(this.base); - for (_i = 0, _len = _ref4.length; _i < _len; _i++) { - node = _ref4[_i]; + var node, _i, _len, _ref2; + _ref2 = this.properties.concat(this.base); + for (_i = 0, _len = _ref2.length; _i < _len; _i++) { + node = _ref2[_i]; if (node.soak || node instanceof Call) { return false; } @@ -732,6 +759,10 @@ define(function(require, exports, module) { return true; }; + Value.prototype.isNotCallable = function() { + return this.isSimpleNumber() || this.isString() || this.isRegex() || this.isArray() || this.isRange() || this.isSplice() || this.isObject(); + }; + Value.prototype.isStatement = function(o) { return !this.properties.length && this.base.isStatement(o); }; @@ -755,6 +786,11 @@ define(function(require, exports, module) { return last(this.properties) instanceof Slice; }; + Value.prototype.looksStatic = function(className) { + var _ref2; + return this.base.value === className && this.properties.length && ((_ref2 = this.properties[0].name) != null ? _ref2.value : void 0) !== 'prototype'; + }; + Value.prototype.unwrap = function() { if (this.properties.length) { return this; @@ -801,34 +837,34 @@ define(function(require, exports, module) { }; Value.prototype.unfoldSoak = function(o) { - var _ref4, - _this = this; - return (_ref4 = this.unfoldedSoak) != null ? _ref4 : this.unfoldedSoak = (function() { - var fst, i, ifn, prop, ref, snd, _i, _len, _ref5, _ref6; - if (ifn = _this.base.unfoldSoak(o)) { - (_ref5 = ifn.body.properties).push.apply(_ref5, _this.properties); - return ifn; - } - _ref6 = _this.properties; - for (i = _i = 0, _len = _ref6.length; _i < _len; i = ++_i) { - prop = _ref6[i]; - if (!prop.soak) { - continue; + return this.unfoldedSoak != null ? this.unfoldedSoak : this.unfoldedSoak = (function(_this) { + return function() { + var fst, i, ifn, prop, ref, snd, _i, _len, _ref2, _ref3; + if (ifn = _this.base.unfoldSoak(o)) { + (_ref2 = ifn.body.properties).push.apply(_ref2, _this.properties); + return ifn; } - prop.soak = false; - fst = new Value(_this.base, _this.properties.slice(0, i)); - snd = new Value(_this.base, _this.properties.slice(i)); - if (fst.isComplex()) { - ref = new Literal(o.scope.freeVariable('ref')); - fst = new Parens(new Assign(ref, fst)); - snd.base = ref; + _ref3 = _this.properties; + for (i = _i = 0, _len = _ref3.length; _i < _len; i = ++_i) { + prop = _ref3[i]; + if (!prop.soak) { + continue; + } + prop.soak = false; + fst = new Value(_this.base, _this.properties.slice(0, i)); + snd = new Value(_this.base, _this.properties.slice(i)); + if (fst.isComplex()) { + ref = new Literal(o.scope.freeVariable('ref')); + fst = new Parens(new Assign(ref, fst)); + snd.base = ref; + } + return new If(new Existence(fst), snd, { + soak: true + }); } - return new If(new Existence(fst), snd, { - soak: true - }); - } - return false; - })(); + return false; + }; + })(this)(); }; return Value; @@ -847,12 +883,13 @@ define(function(require, exports, module) { Comment.prototype.makeReturn = THIS; Comment.prototype.compileNode = function(o, level) { - var code; - code = "/*" + (multident(this.comment, this.tab)) + (__indexOf.call(this.comment, '\n') >= 0 ? "\n" + this.tab : '') + "*/\n"; + var code, comment; + comment = this.comment.replace(/^(\s*)#/gm, "$1 *"); + code = "/*" + (multident(comment, this.tab)) + (__indexOf.call(comment, '\n') >= 0 ? "\n" + this.tab : '') + " */"; if ((level || o.level) === LEVEL_TOP) { code = o.indent + code; } - return [this.makeCode(code)]; + return [this.makeCode("\n"), this.makeCode(code)]; }; return Comment; @@ -868,13 +905,16 @@ define(function(require, exports, module) { this.isNew = false; this.isSuper = variable === 'super'; this.variable = this.isSuper ? null : variable; + if (variable instanceof Value && variable.isNotCallable()) { + variable.error("literal is not a function"); + } } Call.prototype.children = ['variable', 'args']; Call.prototype.newInstance = function() { - var base, _ref4; - base = ((_ref4 = this.variable) != null ? _ref4.base : void 0) || this.variable; + var base, _ref2; + base = ((_ref2 = this.variable) != null ? _ref2.base : void 0) || this.variable; if (base instanceof Call && !base.isNew) { base.newInstance(); } else { @@ -907,13 +947,13 @@ define(function(require, exports, module) { }; Call.prototype.unfoldSoak = function(o) { - var call, ifn, left, list, rite, _i, _len, _ref4, _ref5; + var call, ifn, left, list, rite, _i, _len, _ref2, _ref3; if (this.soak) { if (this.variable) { if (ifn = unfoldSoak(o, this, 'variable')) { return ifn; } - _ref4 = new Value(this.variable).cacheReference(o), left = _ref4[0], rite = _ref4[1]; + _ref2 = new Value(this.variable).cacheReference(o), left = _ref2[0], rite = _ref2[1]; } else { left = new Literal(this.superReference(o)); rite = new Value(left); @@ -941,9 +981,9 @@ define(function(require, exports, module) { break; } } - _ref5 = list.reverse(); - for (_i = 0, _len = _ref5.length; _i < _len; _i++) { - call = _ref5[_i]; + _ref3 = list.reverse(); + for (_i = 0, _len = _ref3.length; _i < _len; _i++) { + call = _ref3[_i]; if (ifn) { if (call.variable instanceof Call) { call.variable = ifn; @@ -957,18 +997,18 @@ define(function(require, exports, module) { }; Call.prototype.compileNode = function(o) { - var arg, argIndex, compiledArgs, compiledArray, fragments, preface, _i, _len, _ref4, _ref5; - if ((_ref4 = this.variable) != null) { - _ref4.front = this.front; + var arg, argIndex, compiledArgs, compiledArray, fragments, preface, _i, _len, _ref2, _ref3; + if ((_ref2 = this.variable) != null) { + _ref2.front = this.front; } compiledArray = Splat.compileSplattedArray(o, this.args, true); if (compiledArray.length) { return this.compileSplat(o, compiledArray); } compiledArgs = []; - _ref5 = this.args; - for (argIndex = _i = 0, _len = _ref5.length; _i < _len; argIndex = ++_i) { - arg = _ref5[argIndex]; + _ref3 = this.args; + for (argIndex = _i = 0, _len = _ref3.length; _i < _len; argIndex = ++_i) { + arg = _ref3[argIndex]; if (argIndex) { compiledArgs.push(this.makeCode(", ")); } @@ -1108,23 +1148,23 @@ define(function(require, exports, module) { } Range.prototype.compileVariables = function(o) { - var step, _ref4, _ref5, _ref6, _ref7; + var step, _ref2, _ref3, _ref4, _ref5; o = merge(o, { top: true }); - _ref4 = this.cacheToCodeFragments(this.from.cache(o, LEVEL_LIST)), this.fromC = _ref4[0], this.fromVar = _ref4[1]; - _ref5 = this.cacheToCodeFragments(this.to.cache(o, LEVEL_LIST)), this.toC = _ref5[0], this.toVar = _ref5[1]; + _ref2 = this.cacheToCodeFragments(this.from.cache(o, LEVEL_LIST)), this.fromC = _ref2[0], this.fromVar = _ref2[1]; + _ref3 = this.cacheToCodeFragments(this.to.cache(o, LEVEL_LIST)), this.toC = _ref3[0], this.toVar = _ref3[1]; if (step = del(o, 'step')) { - _ref6 = this.cacheToCodeFragments(step.cache(o, LEVEL_LIST)), this.step = _ref6[0], this.stepVar = _ref6[1]; + _ref4 = this.cacheToCodeFragments(step.cache(o, LEVEL_LIST)), this.step = _ref4[0], this.stepVar = _ref4[1]; } - _ref7 = [this.fromVar.match(SIMPLENUM), this.toVar.match(SIMPLENUM)], this.fromNum = _ref7[0], this.toNum = _ref7[1]; + _ref5 = [this.fromVar.match(NUMBER), this.toVar.match(NUMBER)], this.fromNum = _ref5[0], this.toNum = _ref5[1]; if (this.stepVar) { - return this.stepNum = this.stepVar.match(SIMPLENUM); + return this.stepNum = this.stepVar.match(NUMBER); } }; Range.prototype.compileNode = function(o) { - var cond, condPart, from, gt, idx, idxName, known, lt, namedIndex, stepPart, to, varPart, _ref4, _ref5; + var cond, condPart, from, gt, idx, idxName, known, lt, namedIndex, stepPart, to, varPart, _ref2, _ref3; if (!this.fromVar) { this.compileVariables(o); } @@ -1142,8 +1182,8 @@ define(function(require, exports, module) { if (this.step !== this.stepVar) { varPart += ", " + this.step; } - _ref4 = ["" + idx + " <" + this.equals, "" + idx + " >" + this.equals], lt = _ref4[0], gt = _ref4[1]; - condPart = this.stepNum ? +this.stepNum > 0 ? "" + lt + " " + this.toVar : "" + gt + " " + this.toVar : known ? ((_ref5 = [+this.fromNum, +this.toNum], from = _ref5[0], to = _ref5[1], _ref5), from <= to ? "" + lt + " " + to : "" + gt + " " + to) : (cond = this.stepVar ? "" + this.stepVar + " > 0" : "" + this.fromVar + " <= " + this.toVar, "" + cond + " ? " + lt + " " + this.toVar + " : " + gt + " " + this.toVar); + _ref2 = ["" + idx + " <" + this.equals, "" + idx + " >" + this.equals], lt = _ref2[0], gt = _ref2[1]; + condPart = this.stepNum ? parseNum(this.stepNum[0]) > 0 ? "" + lt + " " + this.toVar : "" + gt + " " + this.toVar : known ? ((_ref3 = [parseNum(this.fromNum[0]), parseNum(this.toNum[0])], from = _ref3[0], to = _ref3[1], _ref3), from <= to ? "" + lt + " " + to : "" + gt + " " + to) : (cond = this.stepVar ? "" + this.stepVar + " > 0" : "" + this.fromVar + " <= " + this.toVar, "" + cond + " ? " + lt + " " + this.toVar + " : " + gt + " " + this.toVar); stepPart = this.stepVar ? "" + idx + " += " + this.stepVar : known ? namedIndex ? from <= to ? "++" + idx : "--" + idx : from <= to ? "" + idx + "++" : "" + idx + "--" : namedIndex ? "" + cond + " ? ++" + idx + " : --" + idx : "" + cond + " ? " + idx + "++ : " + idx + "--"; if (namedIndex) { varPart = "" + idxName + " = " + varPart; @@ -1155,11 +1195,11 @@ define(function(require, exports, module) { }; Range.prototype.compileArray = function(o) { - var args, body, cond, hasArgs, i, idt, post, pre, range, result, vars, _i, _ref4, _ref5, _results; + var args, body, cond, hasArgs, i, idt, post, pre, range, result, vars, _i, _ref2, _ref3, _results; if (this.fromNum && this.toNum && Math.abs(this.fromNum - this.toNum) <= 20) { range = (function() { _results = []; - for (var _i = _ref4 = +this.fromNum, _ref5 = +this.toNum; _ref4 <= _ref5 ? _i <= _ref5 : _i >= _ref5; _ref4 <= _ref5 ? _i++ : _i--){ _results.push(_i); } + for (var _i = _ref2 = +this.fromNum, _ref3 = +this.toNum; _ref2 <= _ref3 ? _i <= _ref3 : _i >= _ref3; _ref2 <= _ref3 ? _i++ : _i--){ _results.push(_i); } return _results; }).apply(this); if (this.exclusive) { @@ -1181,9 +1221,7 @@ define(function(require, exports, module) { } post = "{ " + result + ".push(" + i + "); }\n" + idt + "return " + result + ";\n" + o.indent; hasArgs = function(node) { - return node != null ? node.contains(function(n) { - return n instanceof Literal && n.value === 'arguments' && !n.asKey; - }) : void 0; + return node != null ? node.contains(isLiteralArguments) : void 0; }; if (hasArgs(this.from) || hasArgs(this.to)) { args = ', arguments'; @@ -1206,8 +1244,8 @@ define(function(require, exports, module) { } Slice.prototype.compileNode = function(o) { - var compiled, compiledText, from, fromCompiled, to, toStr, _ref4; - _ref4 = this.range, to = _ref4.to, from = _ref4.from; + var compiled, compiledText, from, fromCompiled, to, toStr, _ref2; + _ref2 = this.range, to = _ref2.to, from = _ref2.from; fromCompiled = from && from.compileToFragments(o, LEVEL_PAREN) || [this.makeCode('0')]; if (to) { compiled = to.compileToFragments(o, LEVEL_PAREN); @@ -1284,10 +1322,10 @@ define(function(require, exports, module) { }; Obj.prototype.assigns = function(name) { - var prop, _i, _len, _ref4; - _ref4 = this.properties; - for (_i = 0, _len = _ref4.length; _i < _len; _i++) { - prop = _ref4[_i]; + var prop, _i, _len, _ref2; + _ref2 = this.properties; + for (_i = 0, _len = _ref2.length; _i < _len; _i++) { + prop = _ref2[_i]; if (prop.assigns(name)) { return true; } @@ -1320,11 +1358,11 @@ define(function(require, exports, module) { } answer = []; compiledObjs = (function() { - var _i, _len, _ref4, _results; - _ref4 = this.objects; + var _i, _len, _ref2, _results; + _ref2 = this.objects; _results = []; - for (_i = 0, _len = _ref4.length; _i < _len; _i++) { - obj = _ref4[_i]; + for (_i = 0, _len = _ref2.length; _i < _len; _i++) { + obj = _ref2[_i]; _results.push(obj.compileToFragments(o, LEVEL_LIST)); } return _results; @@ -1336,7 +1374,7 @@ define(function(require, exports, module) { } answer.push.apply(answer, fragments); } - if ((fragmentsToText(answer)).indexOf('\n') >= 0) { + if (fragmentsToText(answer).indexOf('\n') >= 0) { answer.unshift(this.makeCode("[\n" + o.indent)); answer.push(this.makeCode("\n" + this.tab + "]")); } else { @@ -1347,10 +1385,10 @@ define(function(require, exports, module) { }; Arr.prototype.assigns = function(name) { - var obj, _i, _len, _ref4; - _ref4 = this.objects; - for (_i = 0, _len = _ref4.length; _i < _len; _i++) { - obj = _ref4[_i]; + var obj, _i, _len, _ref2; + _ref2 = this.objects; + for (_i = 0, _len = _ref2.length; _i < _len; _i++) { + obj = _ref2[_i]; if (obj.assigns(name)) { return true; } @@ -1404,10 +1442,10 @@ define(function(require, exports, module) { }; Class.prototype.addBoundFunctions = function(o) { - var bvar, lhs, _i, _len, _ref4; - _ref4 = this.boundFuncs; - for (_i = 0, _len = _ref4.length; _i < _len; _i++) { - bvar = _ref4[_i]; + var bvar, lhs, _i, _len, _ref2; + _ref2 = this.boundFuncs; + for (_i = 0, _len = _ref2.length; _i < _len; _i++) { + bvar = _ref2[_i]; lhs = (new Value(new Literal("this"), [new Access(bvar)])).compile(o); this.ctor.body.unshift(new Literal("" + lhs + " = " + (utility('bind')) + "(" + lhs + ", this)")); } @@ -1434,15 +1472,12 @@ define(function(require, exports, module) { if (func instanceof Code) { assign = this.ctor = func; } else { - this.externalCtor = o.scope.freeVariable('class'); + this.externalCtor = o.classScope.freeVariable('class'); assign = new Assign(new Literal(this.externalCtor), func); } } else { if (assign.variable["this"]) { func["static"] = true; - if (func.bound) { - func.context = name; - } } else { assign.variable = new Value(new Literal(name), [new Access(new Literal('prototype')), new Access(base)]); if (func instanceof Code && func.bound) { @@ -1460,26 +1495,29 @@ define(function(require, exports, module) { }; Class.prototype.walkBody = function(name, o) { - var _this = this; - return this.traverseChildren(false, function(child) { - var cont, exps, i, node, _i, _len, _ref4; - cont = true; - if (child instanceof Class) { - return false; - } - if (child instanceof Block) { - _ref4 = exps = child.expressions; - for (i = _i = 0, _len = _ref4.length; _i < _len; i = ++_i) { - node = _ref4[i]; - if (node instanceof Value && node.isObject(true)) { - cont = false; - exps[i] = _this.addProperties(node, name, o); - } + return this.traverseChildren(false, (function(_this) { + return function(child) { + var cont, exps, i, node, _i, _len, _ref2; + cont = true; + if (child instanceof Class) { + return false; } - child.expressions = exps = flatten(exps); - } - return cont && !(child instanceof Class); - }); + if (child instanceof Block) { + _ref2 = exps = child.expressions; + for (i = _i = 0, _len = _ref2.length; _i < _len; i = ++_i) { + node = _ref2[i]; + if (node instanceof Assign && node.variable.looksStatic(name)) { + node.value["static"] = true; + } else if (node instanceof Value && node.isObject(true)) { + cont = false; + exps[i] = _this.addProperties(node, name, o); + } + } + child.expressions = exps = flatten(exps); + } + return cont && !(child instanceof Class); + }; + })(this)); }; Class.prototype.hoistDirectivePrologue = function() { @@ -1492,62 +1530,53 @@ define(function(require, exports, module) { return this.directives = expressions.splice(0, index); }; - Class.prototype.ensureConstructor = function(name, o) { - var missing, ref, superCall; - missing = !this.ctor; - this.ctor || (this.ctor = new Code); + Class.prototype.ensureConstructor = function(name) { + if (!this.ctor) { + this.ctor = new Code; + if (this.externalCtor) { + this.ctor.body.push(new Literal("" + this.externalCtor + ".apply(this, arguments)")); + } else if (this.parent) { + this.ctor.body.push(new Literal("" + name + ".__super__.constructor.apply(this, arguments)")); + } + this.ctor.body.makeReturn(); + this.body.expressions.unshift(this.ctor); + } this.ctor.ctor = this.ctor.name = name; this.ctor.klass = null; - this.ctor.noReturn = true; - if (missing) { - if (this.parent) { - superCall = new Literal("" + name + ".__super__.constructor.apply(this, arguments)"); - } - if (this.externalCtor) { - superCall = new Literal("" + this.externalCtor + ".apply(this, arguments)"); - } - if (superCall) { - ref = new Literal(o.scope.freeVariable('ref')); - this.ctor.body.unshift(new Assign(ref, superCall)); - } - this.addBoundFunctions(o); - if (superCall) { - this.ctor.body.push(ref); - this.ctor.body.makeReturn(); - } - return this.body.expressions.unshift(this.ctor); - } else { - return this.addBoundFunctions(o); - } + return this.ctor.noReturn = true; }; Class.prototype.compileNode = function(o) { - var call, decl, klass, lname, name, params, _ref4; - decl = this.determineName(); - name = decl || '_Class'; + var args, argumentsNode, func, jumpNode, klass, lname, name, superClass, _ref2; + if (jumpNode = this.body.jumps()) { + jumpNode.error('Class bodies cannot contain pure statements'); + } + if (argumentsNode = this.body.contains(isLiteralArguments)) { + argumentsNode.error("Class bodies shouldn't reference arguments"); + } + name = this.determineName() || '_Class'; if (name.reserved) { name = "_" + name; } lname = new Literal(name); + func = new Code([], Block.wrap([this.body])); + args = []; + o.classScope = func.makeScope(o.scope); this.hoistDirectivePrologue(); this.setContext(name); this.walkBody(name, o); - this.ensureConstructor(name, o); + this.ensureConstructor(name); + this.addBoundFunctions(o); this.body.spaced = true; - if (!(this.ctor instanceof Code)) { - this.body.expressions.unshift(this.ctor); - } this.body.expressions.push(lname); - (_ref4 = this.body.expressions).unshift.apply(_ref4, this.directives); - call = Closure.wrap(this.body); if (this.parent) { - this.superClass = new Literal(o.scope.freeVariable('super', false)); - this.body.expressions.unshift(new Extends(lname, this.superClass)); - call.args.push(this.parent); - params = call.variable.params || call.variable.base.params; - params.push(new Param(this.superClass)); + superClass = new Literal(o.classScope.freeVariable('super', false)); + this.body.expressions.unshift(new Extends(lname, superClass)); + func.params.push(new Param(superClass)); + args.push(this.parent); } - klass = new Parens(call, true); + (_ref2 = this.body.expressions).unshift.apply(_ref2, this.directives); + klass = new Parens(new Call(func, args)); if (this.variable) { klass = new Assign(this.variable, klass); } @@ -1562,13 +1591,13 @@ define(function(require, exports, module) { __extends(Assign, _super); function Assign(variable, value, context, options) { - var forbidden, name, _ref4; + var forbidden, name, _ref2; this.variable = variable; this.value = value; this.context = context; this.param = options && options.param; this.subpattern = options && options.subpattern; - forbidden = (_ref4 = (name = this.variable.unwrapAll().value), __indexOf.call(STRICT_PROSCRIBED, _ref4) >= 0); + forbidden = (_ref2 = (name = this.variable.unwrapAll().value), __indexOf.call(STRICT_PROSCRIBED, _ref2) >= 0); if (forbidden && this.context !== 'object') { this.variable.error("variable name may not be \"" + name + "\""); } @@ -1589,7 +1618,7 @@ define(function(require, exports, module) { }; Assign.prototype.compileNode = function(o) { - var answer, compiledName, isValue, match, name, val, varBase, _ref4, _ref5, _ref6, _ref7; + var answer, compiledName, isValue, match, name, val, varBase, _ref2, _ref3, _ref4; if (isValue = this.variable instanceof Value) { if (this.variable.isArray() || this.variable.isObject()) { return this.compilePatternMatch(o); @@ -1597,7 +1626,7 @@ define(function(require, exports, module) { if (this.variable.isSplice()) { return this.compileSplice(o); } - if ((_ref4 = this.context) === '||=' || _ref4 === '&&=' || _ref4 === '?=') { + if ((_ref2 = this.context) === '||=' || _ref2 === '&&=' || _ref2 === '?=') { return this.compileConditional(o); } } @@ -1617,10 +1646,10 @@ define(function(require, exports, module) { } } if (this.value instanceof Code && (match = METHOD_DEF.exec(name))) { - if (match[1]) { + if (match[2]) { this.value.klass = match[1]; } - this.value.name = (_ref5 = (_ref6 = (_ref7 = match[2]) != null ? _ref7 : match[3]) != null ? _ref6 : match[4]) != null ? _ref5 : match[5]; + this.value.name = (_ref3 = (_ref4 = match[3]) != null ? _ref4 : match[4]) != null ? _ref3 : match[5]; } val = this.value.compileToFragments(o, LEVEL_LIST); if (this.context === 'object') { @@ -1635,7 +1664,7 @@ define(function(require, exports, module) { }; Assign.prototype.compilePatternMatch = function(o) { - var acc, assigns, code, fragments, i, idx, isObject, ivar, name, obj, objects, olen, ref, rest, splat, top, val, value, vvar, vvarText, _i, _len, _ref4, _ref5, _ref6, _ref7, _ref8, _ref9; + var acc, assigns, code, fragments, i, idx, isObject, ivar, name, obj, objects, olen, ref, rest, splat, top, val, value, vvar, vvarText, _i, _len, _ref2, _ref3, _ref4, _ref5, _ref6, _ref7; top = o.level === LEVEL_TOP; value = this.value; objects = this.variable.base.objects; @@ -1650,14 +1679,14 @@ define(function(require, exports, module) { isObject = this.variable.isObject(); if (top && olen === 1 && !((obj = objects[0]) instanceof Splat)) { if (obj instanceof Assign) { - _ref4 = obj, (_ref5 = _ref4.variable, idx = _ref5.base), obj = _ref4.value; + _ref2 = obj, (_ref3 = _ref2.variable, idx = _ref3.base), obj = _ref2.value; } else { idx = isObject ? obj["this"] ? obj.properties[0].name : obj : new Literal(0); } acc = IDENTIFIER.test(idx.unwrap().value || 0); value = new Value(value); value.properties.push(new (acc ? Access : Index)(idx)); - if (_ref6 = obj.unwrap().value, __indexOf.call(RESERVED, _ref6) >= 0) { + if (_ref4 = obj.unwrap().value, __indexOf.call(RESERVED, _ref4) >= 0) { obj.error("assignment to a reserved word: " + (obj.compile(o))); } return new Assign(obj, value, null, { @@ -1678,10 +1707,10 @@ define(function(require, exports, module) { idx = i; if (isObject) { if (obj instanceof Assign) { - _ref7 = obj, (_ref8 = _ref7.variable, idx = _ref8.base), obj = _ref7.value; + _ref5 = obj, (_ref6 = _ref5.variable, idx = _ref6.base), obj = _ref5.value; } else { if (obj.base instanceof Parens) { - _ref9 = new Value(obj.unwrapAll()).cacheReference(o), obj = _ref9[0], idx = _ref9[1]; + _ref7 = new Value(obj.unwrapAll()).cacheReference(o), obj = _ref7[0], idx = _ref7[1]; } else { idx = obj["this"] ? obj.properties[0].name : obj; } @@ -1732,29 +1761,38 @@ define(function(require, exports, module) { }; Assign.prototype.compileConditional = function(o) { - var left, right, _ref4; - _ref4 = this.variable.cacheReference(o), left = _ref4[0], right = _ref4[1]; + var fragments, left, right, _ref2; + _ref2 = this.variable.cacheReference(o), left = _ref2[0], right = _ref2[1]; if (!left.properties.length && left.base instanceof Literal && left.base.value !== "this" && !o.scope.check(left.base.value)) { this.variable.error("the variable \"" + left.base.value + "\" can't be assigned with " + this.context + " because it has not been declared before"); } if (__indexOf.call(this.context, "?") >= 0) { o.isExistentialEquals = true; + return new If(new Existence(left), right, { + type: 'if' + }).addElse(new Assign(right, this.value, '=')).compileToFragments(o); + } else { + fragments = new Op(this.context.slice(0, -1), left, new Assign(right, this.value, '=')).compileToFragments(o); + if (o.level <= LEVEL_LIST) { + return fragments; + } else { + return this.wrapInBraces(fragments); + } } - return new Op(this.context.slice(0, -1), left, new Assign(right, this.value, '=')).compileToFragments(o); }; Assign.prototype.compileSplice = function(o) { - var answer, exclusive, from, fromDecl, fromRef, name, to, valDef, valRef, _ref4, _ref5, _ref6; - _ref4 = this.variable.properties.pop().range, from = _ref4.from, to = _ref4.to, exclusive = _ref4.exclusive; + var answer, exclusive, from, fromDecl, fromRef, name, to, valDef, valRef, _ref2, _ref3, _ref4; + _ref2 = this.variable.properties.pop().range, from = _ref2.from, to = _ref2.to, exclusive = _ref2.exclusive; name = this.variable.compile(o); if (from) { - _ref5 = this.cacheToCodeFragments(from.cache(o, LEVEL_OP)), fromDecl = _ref5[0], fromRef = _ref5[1]; + _ref3 = this.cacheToCodeFragments(from.cache(o, LEVEL_OP)), fromDecl = _ref3[0], fromRef = _ref3[1]; } else { fromDecl = fromRef = '0'; } if (to) { - if ((from != null ? from.isSimpleNumber() : void 0) && to.isSimpleNumber()) { - to = +to.compile(o) - +fromRef; + if (from instanceof Value && from.isSimpleNumber() && to instanceof Value && to.isSimpleNumber()) { + to = to.compile(o) - fromRef; if (!exclusive) { to += 1; } @@ -1767,7 +1805,7 @@ define(function(require, exports, module) { } else { to = "9e9"; } - _ref6 = this.value.cache(o, LEVEL_LIST), valDef = _ref6[0], valRef = _ref6[1]; + _ref4 = this.value.cache(o, LEVEL_LIST), valDef = _ref4[0], valRef = _ref4[1]; answer = [].concat(this.makeCode("[].splice.apply(" + name + ", [" + fromDecl + ", " + to + "].concat("), valDef, this.makeCode(")), "), valRef); if (o.level > LEVEL_TOP) { return this.wrapInBraces(answer); @@ -1787,9 +1825,6 @@ define(function(require, exports, module) { this.params = params || []; this.body = body || new Block; this.bound = tag === 'boundfunc'; - if (this.bound) { - this.context = '_this'; - } } Code.prototype.children = ['params', 'body']; @@ -1800,29 +1835,43 @@ define(function(require, exports, module) { Code.prototype.jumps = NO; + Code.prototype.makeScope = function(parentScope) { + return new Scope(parentScope, this.body, this); + }; + Code.prototype.compileNode = function(o) { - var answer, code, exprs, i, idt, lit, p, param, params, ref, splats, uniqs, val, wasEmpty, _i, _j, _k, _l, _len, _len1, _len2, _len3, _len4, _m, _ref4, _ref5, _ref6, _ref7, _ref8; - o.scope = new Scope(o.scope, this.body, this); + var answer, boundfunc, code, exprs, i, lit, p, param, params, ref, splats, uniqs, val, wasEmpty, wrapper, _i, _j, _k, _l, _len, _len1, _len2, _len3, _len4, _len5, _m, _n, _ref2, _ref3, _ref4, _ref5, _ref6, _ref7; + if (this.bound && ((_ref2 = o.scope.method) != null ? _ref2.bound : void 0)) { + this.context = o.scope.method.context; + } + if (this.bound && !this.context) { + this.context = '_this'; + wrapper = new Code([new Param(new Literal(this.context))], new Block([this])); + boundfunc = new Call(wrapper, [new Literal('this')]); + boundfunc.updateLocationDataIfMissing(this.locationData); + return boundfunc.compileNode(o); + } + o.scope = del(o, 'classScope') || this.makeScope(o.scope); o.scope.shared = del(o, 'sharedScope'); o.indent += TAB; delete o.bare; delete o.isExistentialEquals; params = []; exprs = []; - this.eachParamName(function(name) { - if (!o.scope.check(name)) { - return o.scope.parameter(name); - } - }); + _ref3 = this.params; + for (_i = 0, _len = _ref3.length; _i < _len; _i++) { + param = _ref3[_i]; + o.scope.parameter(param.asReference(o)); + } _ref4 = this.params; - for (_i = 0, _len = _ref4.length; _i < _len; _i++) { - param = _ref4[_i]; + for (_j = 0, _len1 = _ref4.length; _j < _len1; _j++) { + param = _ref4[_j]; if (!param.splat) { continue; } _ref5 = this.params; - for (_j = 0, _len1 = _ref5.length; _j < _len1; _j++) { - p = _ref5[_j].name; + for (_k = 0, _len2 = _ref5.length; _k < _len2; _k++) { + p = _ref5[_k].name; if (p["this"]) { p = p.properties[0].name; } @@ -1831,11 +1880,11 @@ define(function(require, exports, module) { } } splats = new Assign(new Value(new Arr((function() { - var _k, _len2, _ref6, _results; + var _l, _len3, _ref6, _results; _ref6 = this.params; _results = []; - for (_k = 0, _len2 = _ref6.length; _k < _len2; _k++) { - p = _ref6[_k]; + for (_l = 0, _len3 = _ref6.length; _l < _len3; _l++) { + p = _ref6[_l]; _results.push(p.asReference(o)); } return _results; @@ -1843,8 +1892,8 @@ define(function(require, exports, module) { break; } _ref6 = this.params; - for (_k = 0, _len2 = _ref6.length; _k < _len2; _k++) { - param = _ref6[_k]; + for (_l = 0, _len3 = _ref6.length; _l < _len3; _l++) { + param = _ref6[_l]; if (param.isComplex()) { val = ref = param.asReference(o); if (param.value) { @@ -1872,7 +1921,7 @@ define(function(require, exports, module) { if (exprs.length) { (_ref7 = this.body.expressions).unshift.apply(_ref7, exprs); } - for (i = _l = 0, _len3 = params.length; _l < _len3; i = ++_l) { + for (i = _m = 0, _len4 = params.length; _m < _len4; i = ++_m) { p = params[i]; params[i] = p.compileToFragments(o); o.scope.parameter(fragmentsToText(params[i])); @@ -1887,21 +1936,13 @@ define(function(require, exports, module) { if (!(wasEmpty || this.noReturn)) { this.body.makeReturn(); } - if (this.bound) { - if ((_ref8 = o.scope.parent.method) != null ? _ref8.bound : void 0) { - this.bound = this.context = o.scope.parent.method.context; - } else if (!this["static"]) { - o.scope.parent.assign('_this', 'this'); - } - } - idt = o.indent; code = 'function'; if (this.ctor) { code += ' ' + this.name; } code += '('; answer = [this.makeCode(code)]; - for (i = _m = 0, _len4 = params.length; _m < _len4; i = ++_m) { + for (i = _n = 0, _len5 = params.length; _n < _len5; i = ++_n) { p = params[i]; if (i) { answer.push(this.makeCode(", ")); @@ -1924,11 +1965,11 @@ define(function(require, exports, module) { }; Code.prototype.eachParamName = function(iterator) { - var param, _i, _len, _ref4, _results; - _ref4 = this.params; + var param, _i, _len, _ref2, _results; + _ref2 = this.params; _results = []; - for (_i = 0, _len = _ref4.length; _i < _len; _i++) { - param = _ref4[_i]; + for (_i = 0, _len = _ref2.length; _i < _len; _i++) { + param = _ref2[_i]; _results.push(param.eachName(iterator)); } return _results; @@ -1948,11 +1989,11 @@ define(function(require, exports, module) { __extends(Param, _super); function Param(name, value, splat) { - var _ref4; + var _ref2; this.name = name; this.value = value; this.splat = splat; - if (_ref4 = (name = this.name.unwrapAll().value), __indexOf.call(STRICT_PROSCRIBED, _ref4) >= 0) { + if (_ref2 = (name = this.name.unwrapAll().value), __indexOf.call(STRICT_PROSCRIBED, _ref2) >= 0) { this.name.error("parameter name \"" + name + "\" is not allowed"); } } @@ -1981,6 +2022,7 @@ define(function(require, exports, module) { if (this.splat) { node = new Splat(node); } + node.updateLocationDataIfMissing(this.locationData); return this.reference = node; }; @@ -1989,7 +2031,7 @@ define(function(require, exports, module) { }; Param.prototype.eachName = function(iterator, name) { - var atParam, node, obj, _i, _len, _ref4; + var atParam, node, obj, _i, _len, _ref2; if (name == null) { name = this.name; } @@ -2006,9 +2048,9 @@ define(function(require, exports, module) { if (name instanceof Value) { return atParam(name); } - _ref4 = name.objects; - for (_i = 0, _len = _ref4.length; _i < _len; _i++) { - obj = _ref4[_i]; + _ref2 = name.objects; + for (_i = 0, _len = _ref2.length; _i < _len; _i++) { + obj = _ref2[_i]; if (obj instanceof Assign) { this.eachName(iterator, obj.value.unwrap()); } else if (obj instanceof Splat) { @@ -2084,11 +2126,11 @@ define(function(require, exports, module) { return args[0].concat(node.makeCode(".concat("), concatPart, node.makeCode(")")); } base = (function() { - var _j, _len1, _ref4, _results; - _ref4 = list.slice(0, index); + var _j, _len1, _ref2, _results; + _ref2 = list.slice(0, index); _results = []; - for (_j = 0, _len1 = _ref4.length; _j < _len1; _j++) { - node = _ref4[_j]; + for (_j = 0, _len1 = _ref2.length; _j < _len1; _j++) { + node = _ref2[_j]; _results.push(node.compileToFragments(o, LEVEL_LIST)); } return _results; @@ -2131,17 +2173,17 @@ define(function(require, exports, module) { }; While.prototype.jumps = function() { - var expressions, node, _i, _len; + var expressions, jumpNode, node, _i, _len; expressions = this.body.expressions; if (!expressions.length) { return false; } for (_i = 0, _len = expressions.length; _i < _len; _i++) { node = expressions[_i]; - if (node.jumps({ + if (jumpNode = node.jumps({ loop: true })) { - return node; + return jumpNode; } } return false; @@ -2228,17 +2270,17 @@ define(function(require, exports, module) { }; Op.prototype.isComplex = function() { - var _ref4; - return !(this.isUnary() && ((_ref4 = this.operator) === '+' || _ref4 === '-')) || this.first.isComplex(); + var _ref2; + return !(this.isUnary() && ((_ref2 = this.operator) === '+' || _ref2 === '-')) || this.first.isComplex(); }; Op.prototype.isChainable = function() { - var _ref4; - return (_ref4 = this.operator) === '<' || _ref4 === '>' || _ref4 === '>=' || _ref4 === '<=' || _ref4 === '===' || _ref4 === '!=='; + var _ref2; + return (_ref2 = this.operator) === '<' || _ref2 === '>' || _ref2 === '>=' || _ref2 === '<=' || _ref2 === '===' || _ref2 === '!=='; }; Op.prototype.invert = function() { - var allInvertable, curr, fst, op, _ref4; + var allInvertable, curr, fst, op, _ref2; if (this.isChainable() && this.first.isChainable()) { allInvertable = true; curr = this; @@ -2264,7 +2306,7 @@ define(function(require, exports, module) { return this; } else if (this.second) { return new Parens(this).invert(); - } else if (this.operator === '!' && (fst = this.first.unwrap()) instanceof Op && ((_ref4 = fst.operator) === '!' || _ref4 === 'in' || _ref4 === 'instanceof')) { + } else if (this.operator === '!' && (fst = this.first.unwrap()) instanceof Op && ((_ref2 = fst.operator) === '!' || _ref2 === 'in' || _ref2 === 'instanceof')) { return fst; } else { return new Op('!', this); @@ -2272,17 +2314,17 @@ define(function(require, exports, module) { }; Op.prototype.unfoldSoak = function(o) { - var _ref4; - return ((_ref4 = this.operator) === '++' || _ref4 === '--' || _ref4 === 'delete') && unfoldSoak(o, this, 'first'); + var _ref2; + return ((_ref2 = this.operator) === '++' || _ref2 === '--' || _ref2 === 'delete') && unfoldSoak(o, this, 'first'); }; Op.prototype.generateDo = function(exp) { - var call, func, param, passedParams, ref, _i, _len, _ref4; + var call, func, param, passedParams, ref, _i, _len, _ref2; passedParams = []; func = exp instanceof Assign && (ref = exp.value.unwrap()) instanceof Code ? ref : exp; - _ref4 = func.params || []; - for (_i = 0, _len = _ref4.length; _i < _len; _i++) { - param = _ref4[_i]; + _ref2 = func.params || []; + for (_i = 0, _len = _ref2.length; _i < _len; _i++) { + param = _ref2[_i]; if (param.value) { passedParams.push(param.value); delete param.value; @@ -2296,7 +2338,7 @@ define(function(require, exports, module) { }; Op.prototype.compileNode = function(o) { - var answer, isChain, _ref4, _ref5; + var answer, isChain, _ref2, _ref3; isChain = this.isChainable() && this.first.isChainable(); if (!isChain) { this.first.front = this.front; @@ -2304,7 +2346,7 @@ define(function(require, exports, module) { if (this.operator === 'delete' && o.scope.check(this.first.unwrapAll().value)) { this.error('delete operand may not be argument or var'); } - if (((_ref4 = this.operator) === '--' || _ref4 === '++') && (_ref5 = this.first.unwrapAll().value, __indexOf.call(STRICT_PROSCRIBED, _ref5) >= 0)) { + if (((_ref2 = this.operator) === '--' || _ref2 === '++') && (_ref3 = this.first.unwrapAll().value, __indexOf.call(STRICT_PROSCRIBED, _ref3) >= 0)) { this.error("cannot increment/decrement \"" + (this.first.unwrapAll().value) + "\""); } if (this.isUnary()) { @@ -2325,8 +2367,8 @@ define(function(require, exports, module) { }; Op.prototype.compileChain = function(o) { - var fragments, fst, shared, _ref4; - _ref4 = this.first.second.cache(o), this.first.second = _ref4[0], shared = _ref4[1]; + var fragments, fst, shared, _ref2; + _ref2 = this.first.second.cache(o), this.first.second = _ref2[0], shared = _ref2[1]; fst = this.first.compileToFragments(o, LEVEL_OP); fragments = fst.concat(this.makeCode(" " + (this.invert ? '&&' : '||') + " "), shared.compileToFragments(o), this.makeCode(" " + this.operator + " "), this.second.compileToFragments(o, LEVEL_OP)); return this.wrapInBraces(fragments); @@ -2393,11 +2435,11 @@ define(function(require, exports, module) { In.prototype.invert = NEGATE; In.prototype.compileNode = function(o) { - var hasSplat, obj, _i, _len, _ref4; + var hasSplat, obj, _i, _len, _ref2; if (this.array instanceof Value && this.array.isArray()) { - _ref4 = this.array.base.objects; - for (_i = 0, _len = _ref4.length; _i < _len; _i++) { - obj = _ref4[_i]; + _ref2 = this.array.base.objects; + for (_i = 0, _len = _ref2.length; _i < _len; _i++) { + obj = _ref2[_i]; if (!(obj instanceof Splat)) { continue; } @@ -2412,16 +2454,16 @@ define(function(require, exports, module) { }; In.prototype.compileOrTest = function(o) { - var cmp, cnj, i, item, ref, sub, tests, _i, _len, _ref4, _ref5, _ref6; + var cmp, cnj, i, item, ref, sub, tests, _i, _len, _ref2, _ref3, _ref4; if (this.array.base.objects.length === 0) { return [this.makeCode("" + (!!this.negated))]; } - _ref4 = this.object.cache(o, LEVEL_OP), sub = _ref4[0], ref = _ref4[1]; - _ref5 = this.negated ? [' !== ', ' && '] : [' === ', ' || '], cmp = _ref5[0], cnj = _ref5[1]; + _ref2 = this.object.cache(o, LEVEL_OP), sub = _ref2[0], ref = _ref2[1]; + _ref3 = this.negated ? [' !== ', ' && '] : [' === ', ' || '], cmp = _ref3[0], cnj = _ref3[1]; tests = []; - _ref6 = this.array.base.objects; - for (i = _i = 0, _len = _ref6.length; _i < _len; i = ++_i) { - item = _ref6[i]; + _ref4 = this.array.base.objects; + for (i = _i = 0, _len = _ref4.length; _i < _len; i = ++_i) { + item = _ref4[i]; if (i) { tests.push(this.makeCode(cnj)); } @@ -2435,10 +2477,10 @@ define(function(require, exports, module) { }; In.prototype.compileLoopTest = function(o) { - var fragments, ref, sub, _ref4; - _ref4 = this.object.cache(o, LEVEL_LIST), sub = _ref4[0], ref = _ref4[1]; + var fragments, ref, sub, _ref2; + _ref2 = this.object.cache(o, LEVEL_LIST), sub = _ref2[0], ref = _ref2[1]; fragments = [].concat(this.makeCode(utility('indexOf') + ".call("), this.array.compileToFragments(o, LEVEL_LIST), this.makeCode(", "), ref, this.makeCode(") " + (this.negated ? '< 0' : '>= 0'))); - if ((fragmentsToText(sub)) === (fragmentsToText(ref))) { + if (fragmentsToText(sub) === fragmentsToText(ref)) { return fragments; } fragments = sub.concat(this.makeCode(', '), fragments); @@ -2472,8 +2514,8 @@ define(function(require, exports, module) { Try.prototype.isStatement = YES; Try.prototype.jumps = function(o) { - var _ref4; - return this.attempt.jumps(o) || ((_ref4 = this.recovery) != null ? _ref4.jumps(o) : void 0); + var _ref2; + return this.attempt.jumps(o) || ((_ref2 = this.recovery) != null ? _ref2.jumps(o) : void 0); }; Try.prototype.makeReturn = function(res) { @@ -2534,11 +2576,11 @@ define(function(require, exports, module) { Existence.prototype.invert = NEGATE; Existence.prototype.compileNode = function(o) { - var cmp, cnj, code, _ref4; + var cmp, cnj, code, _ref2; this.expression.front = this.front; code = this.expression.compile(o, LEVEL_OP); if (IDENTIFIER.test(code) && !o.scope.check(code)) { - _ref4 = this.negated ? ['===', '||'] : ['!==', '&&'], cmp = _ref4[0], cnj = _ref4[1]; + _ref2 = this.negated ? ['===', '||'] : ['!==', '&&'], cmp = _ref2[0], cnj = _ref2[1]; code = "typeof " + code + " " + cmp + " \"undefined\" " + cnj + " " + code + " " + cmp + " null"; } else { code = "" + code + " " + (this.negated ? '==' : '!=') + " null"; @@ -2591,13 +2633,13 @@ define(function(require, exports, module) { __extends(For, _super); function For(body, source) { - var _ref4; + var _ref2; this.source = source.source, this.guard = source.guard, this.step = source.step, this.name = source.name, this.index = source.index; this.body = Block.wrap([body]); this.own = !!source.own; this.object = !!source.object; if (this.object) { - _ref4 = [this.index, this.name], this.name = _ref4[0], this.index = _ref4[1]; + _ref2 = [this.index, this.name], this.name = _ref2[0], this.index = _ref2[1]; } if (this.index instanceof Value) { this.index.error('index cannot be a pattern matching expression'); @@ -2610,15 +2652,18 @@ define(function(require, exports, module) { if (this.range && this.pattern) { this.name.error('cannot pattern match over range loops'); } + if (this.own && !this.object) { + this.name.error('cannot use own with for-in'); + } this.returns = false; } For.prototype.children = ['body', 'source', 'guard', 'step']; For.prototype.compileNode = function(o) { - var body, bodyFragments, compare, compareDown, declare, declareDown, defPart, defPartFragments, down, forPartFragments, guardPart, idt1, increment, index, ivar, kvar, kvarAssign, lastJumps, lvar, name, namePart, ref, resultPart, returnResult, rvar, scope, source, step, stepNum, stepVar, svar, varPart, _ref4, _ref5; + var body, bodyFragments, compare, compareDown, declare, declareDown, defPart, defPartFragments, down, forPartFragments, guardPart, idt1, increment, index, ivar, kvar, kvarAssign, lastJumps, lvar, name, namePart, ref, resultPart, returnResult, rvar, scope, source, step, stepNum, stepVar, svar, varPart, _ref2, _ref3; body = Block.wrap([this.body]); - lastJumps = (_ref4 = last(body.expressions)) != null ? _ref4.jumps() : void 0; + lastJumps = (_ref2 = last(body.expressions)) != null ? _ref2.jumps() : void 0; if (lastJumps && lastJumps instanceof Return) { this.returns = false; } @@ -2639,8 +2684,8 @@ define(function(require, exports, module) { kvar = (this.range && name) || index || ivar; kvarAssign = kvar !== ivar ? "" + kvar + " = " : ""; if (this.step && !this.range) { - _ref5 = this.cacheToCodeFragments(this.step.cache(o, LEVEL_LIST)), step = _ref5[0], stepVar = _ref5[1]; - stepNum = stepVar.match(SIMPLENUM); + _ref3 = this.cacheToCodeFragments(this.step.cache(o, LEVEL_LIST)), step = _ref3[0], stepVar = _ref3[1]; + stepNum = stepVar.match(NUMBER); } if (this.pattern) { name = ivar; @@ -2668,7 +2713,7 @@ define(function(require, exports, module) { if (step !== stepVar) { defPart += "" + this.tab + step + ";\n"; } - if (!(this.step && stepNum && (down = +stepNum < 0))) { + if (!(this.step && stepNum && (down = parseNum(stepNum[0]) < 0))) { lvar = scope.freeVariable('len'); } declare = "" + kvarAssign + ivar + " = 0, " + lvar + " = " + svar + ".length"; @@ -2729,24 +2774,24 @@ define(function(require, exports, module) { }; For.prototype.pluckDirectCall = function(o, body) { - var base, defs, expr, fn, idx, ref, val, _i, _len, _ref4, _ref5, _ref6, _ref7, _ref8, _ref9; + var base, defs, expr, fn, idx, ref, val, _i, _len, _ref2, _ref3, _ref4, _ref5, _ref6, _ref7, _ref8; defs = []; - _ref4 = body.expressions; - for (idx = _i = 0, _len = _ref4.length; _i < _len; idx = ++_i) { - expr = _ref4[idx]; + _ref2 = body.expressions; + for (idx = _i = 0, _len = _ref2.length; _i < _len; idx = ++_i) { + expr = _ref2[idx]; expr = expr.unwrapAll(); if (!(expr instanceof Call)) { continue; } - val = expr.variable.unwrapAll(); - if (!((val instanceof Code) || (val instanceof Value && ((_ref5 = val.base) != null ? _ref5.unwrapAll() : void 0) instanceof Code && val.properties.length === 1 && ((_ref6 = (_ref7 = val.properties[0].name) != null ? _ref7.value : void 0) === 'call' || _ref6 === 'apply')))) { + val = (_ref3 = expr.variable) != null ? _ref3.unwrapAll() : void 0; + if (!((val instanceof Code) || (val instanceof Value && ((_ref4 = val.base) != null ? _ref4.unwrapAll() : void 0) instanceof Code && val.properties.length === 1 && ((_ref5 = (_ref6 = val.properties[0].name) != null ? _ref6.value : void 0) === 'call' || _ref5 === 'apply')))) { continue; } - fn = ((_ref8 = val.base) != null ? _ref8.unwrapAll() : void 0) || val; + fn = ((_ref7 = val.base) != null ? _ref7.unwrapAll() : void 0) || val; ref = new Literal(o.scope.freeVariable('fn')); base = new Value(ref); if (val.base) { - _ref9 = [base, val], val.base = _ref9[0], base = _ref9[1]; + _ref8 = [base, val], val.base = _ref8[0], base = _ref8[1]; } body.expressions[idx] = new Call(base, expr.args); defs = defs.concat(this.makeCode(this.tab), new Assign(ref, fn).compileToFragments(o, LEVEL_TOP), this.makeCode(';\n')); @@ -2772,49 +2817,49 @@ define(function(require, exports, module) { Switch.prototype.isStatement = YES; Switch.prototype.jumps = function(o) { - var block, conds, _i, _len, _ref4, _ref5, _ref6; + var block, conds, jumpNode, _i, _len, _ref2, _ref3, _ref4; if (o == null) { o = { block: true }; } - _ref4 = this.cases; - for (_i = 0, _len = _ref4.length; _i < _len; _i++) { - _ref5 = _ref4[_i], conds = _ref5[0], block = _ref5[1]; - if (block.jumps(o)) { - return block; + _ref2 = this.cases; + for (_i = 0, _len = _ref2.length; _i < _len; _i++) { + _ref3 = _ref2[_i], conds = _ref3[0], block = _ref3[1]; + if (jumpNode = block.jumps(o)) { + return jumpNode; } } - return (_ref6 = this.otherwise) != null ? _ref6.jumps(o) : void 0; + return (_ref4 = this.otherwise) != null ? _ref4.jumps(o) : void 0; }; Switch.prototype.makeReturn = function(res) { - var pair, _i, _len, _ref4, _ref5; - _ref4 = this.cases; - for (_i = 0, _len = _ref4.length; _i < _len; _i++) { - pair = _ref4[_i]; + var pair, _i, _len, _ref2, _ref3; + _ref2 = this.cases; + for (_i = 0, _len = _ref2.length; _i < _len; _i++) { + pair = _ref2[_i]; pair[1].makeReturn(res); } if (res) { this.otherwise || (this.otherwise = new Block([new Literal('void 0')])); } - if ((_ref5 = this.otherwise) != null) { - _ref5.makeReturn(res); + if ((_ref3 = this.otherwise) != null) { + _ref3.makeReturn(res); } return this; }; Switch.prototype.compileNode = function(o) { - var block, body, cond, conditions, expr, fragments, i, idt1, idt2, _i, _j, _len, _len1, _ref4, _ref5, _ref6; + var block, body, cond, conditions, expr, fragments, i, idt1, idt2, _i, _j, _len, _len1, _ref2, _ref3, _ref4; idt1 = o.indent + TAB; idt2 = o.indent = idt1 + TAB; fragments = [].concat(this.makeCode(this.tab + "switch ("), (this.subject ? this.subject.compileToFragments(o, LEVEL_PAREN) : this.makeCode("false")), this.makeCode(") {\n")); - _ref4 = this.cases; - for (i = _i = 0, _len = _ref4.length; _i < _len; i = ++_i) { - _ref5 = _ref4[i], conditions = _ref5[0], block = _ref5[1]; - _ref6 = flatten([conditions]); - for (_j = 0, _len1 = _ref6.length; _j < _len1; _j++) { - cond = _ref6[_j]; + _ref2 = this.cases; + for (i = _i = 0, _len = _ref2.length; _i < _len; i = ++_i) { + _ref3 = _ref2[i], conditions = _ref3[0], block = _ref3[1]; + _ref4 = flatten([conditions]); + for (_j = 0, _len1 = _ref4.length; _j < _len1; _j++) { + cond = _ref4[_j]; if (!this.subject) { cond = cond.invert(); } @@ -2860,13 +2905,13 @@ define(function(require, exports, module) { If.prototype.children = ['condition', 'body', 'elseBody']; If.prototype.bodyNode = function() { - var _ref4; - return (_ref4 = this.body) != null ? _ref4.unwrap() : void 0; + var _ref2; + return (_ref2 = this.body) != null ? _ref2.unwrap() : void 0; }; If.prototype.elseBodyNode = function() { - var _ref4; - return (_ref4 = this.elseBody) != null ? _ref4.unwrap() : void 0; + var _ref2; + return (_ref2 = this.elseBody) != null ? _ref2.unwrap() : void 0; }; If.prototype.addElse = function(elseBody) { @@ -2875,18 +2920,19 @@ define(function(require, exports, module) { } else { this.isChain = elseBody instanceof If; this.elseBody = this.ensureBlock(elseBody); + this.elseBody.updateLocationDataIfMissing(elseBody.locationData); } return this; }; If.prototype.isStatement = function(o) { - var _ref4; - return (o != null ? o.level : void 0) === LEVEL_TOP || this.bodyNode().isStatement(o) || ((_ref4 = this.elseBodyNode()) != null ? _ref4.isStatement(o) : void 0); + var _ref2; + return (o != null ? o.level : void 0) === LEVEL_TOP || this.bodyNode().isStatement(o) || ((_ref2 = this.elseBodyNode()) != null ? _ref2.isStatement(o) : void 0); }; If.prototype.jumps = function(o) { - var _ref4; - return this.body.jumps(o) || ((_ref4 = this.elseBody) != null ? _ref4.jumps(o) : void 0); + var _ref2; + return this.body.jumps(o) || ((_ref2 = this.elseBody) != null ? _ref2.jumps(o) : void 0); }; If.prototype.compileNode = function(o) { @@ -2968,52 +3014,6 @@ define(function(require, exports, module) { })(Base); - Closure = { - wrap: function(expressions, statement, noReturn) { - var args, argumentsNode, call, func, meth; - if (expressions.jumps()) { - return expressions; - } - func = new Code([], Block.wrap([expressions])); - args = []; - argumentsNode = expressions.contains(this.isLiteralArguments); - if (argumentsNode && expressions.classBody) { - argumentsNode.error("Class bodies shouldn't reference arguments"); - } - if (argumentsNode || expressions.contains(this.isLiteralThis)) { - meth = new Literal(argumentsNode ? 'apply' : 'call'); - args = [new Literal('this')]; - if (argumentsNode) { - args.push(new Literal('arguments')); - } - func = new Value(func, [new Access(meth)]); - } - func.noReturn = noReturn; - call = new Call(func, args); - if (statement) { - return Block.wrap([call]); - } else { - return call; - } - }, - isLiteralArguments: function(node) { - return node instanceof Literal && node.value === 'arguments' && !node.asKey; - }, - isLiteralThis: function(node) { - return (node instanceof Literal && node.value === 'this' && !node.asKey) || (node instanceof Code && node.bound) || (node instanceof Call && node.isSuper); - } - }; - - unfoldSoak = function(o, parent, name) { - var ifn; - if (!(ifn = parent[name].unfoldSoak(o))) { - return; - } - parent[name] = ifn.body; - ifn.body = new Value(parent); - return ifn; - }; - UTILITIES = { "extends": function() { return "function(child, parent) { for (var key in parent) { if (" + (utility('hasProp')) + ".call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }"; @@ -3052,10 +3052,16 @@ define(function(require, exports, module) { SIMPLENUM = /^[+-]?\d+$/; - METHOD_DEF = RegExp("^(?:(" + IDENTIFIER_STR + ")\\.prototype(?:\\.(" + IDENTIFIER_STR + ")|\\[(\"(?:[^\\\\\"\\r\\n]|\\\\.)*\"|'(?:[^\\\\'\\r\\n]|\\\\.)*')\\]|\\[(0x[\\da-fA-F]+|\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)\\]))|(" + IDENTIFIER_STR + ")$"); + HEXNUM = /^[+-]?0x[\da-f]+/i; + + NUMBER = /^[+-]?(?:0x[\da-f]+|\d*\.?\d+(?:e[+-]?\d+)?)$/i; + + METHOD_DEF = RegExp("^(" + IDENTIFIER_STR + ")(\\.prototype)?(?:\\.(" + IDENTIFIER_STR + ")|\\[(\"(?:[^\\\\\"\\r\\n]|\\\\.)*\"|'(?:[^\\\\'\\r\\n]|\\\\.)*')\\]|\\[(0x[\\da-fA-F]+|\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)\\])$"); IS_STRING = /^['"]/; + IS_REGEX = /^\//; + utility = function(name) { var ref; ref = "__" + name; @@ -3068,5 +3074,33 @@ define(function(require, exports, module) { return code.replace(/\s+$/, ''); }; + parseNum = function(x) { + if (x == null) { + return 0; + } else if (x.match(HEXNUM)) { + return parseInt(x, 16); + } else { + return parseFloat(x); + } + }; + + isLiteralArguments = function(node) { + return node instanceof Literal && node.value === 'arguments' && !node.asKey; + }; + + isLiteralThis = function(node) { + return (node instanceof Literal && node.value === 'this' && !node.asKey) || (node instanceof Code && node.bound) || (node instanceof Call && node.isSuper); + }; + + unfoldSoak = function(o, parent, name) { + var ifn; + if (!(ifn = parent[name].unfoldSoak(o))) { + return; + } + parent[name] = ifn.body; + ifn.body = new Value(parent); + return ifn; + }; + }); \ No newline at end of file diff --git a/lib/ace/mode/coffee/parser.js b/lib/ace/mode/coffee/parser.js index 5bd3660e..00d1b723 100644 --- a/lib/ace/mode/coffee/parser.js +++ b/lib/ace/mode/coffee/parser.js @@ -25,14 +25,87 @@ */ define(function(require, exports, module) { -/* parser generated by jison 0.4.2 */ +/* parser generated by jison 0.4.4 */ +/* + Returns a Parser object of the following structure: + + Parser: { + yy: {} + } + + Parser.prototype: { + yy: {}, + trace: function(), + symbols_: {associative list: name ==> number}, + terminals_: {associative list: number ==> name}, + productions_: [...], + performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$), + table: [...], + defaultActions: {...}, + parseError: function(str, hash), + parse: function(input), + + lexer: { + EOF: 1, + parseError: function(str, hash), + setInput: function(input), + input: function(), + unput: function(str), + more: function(), + less: function(n), + pastInput: function(), + upcomingInput: function(), + showPosition: function(), + test_match: function(regex_match_array, rule_index), + next: function(), + lex: function(), + begin: function(condition), + popState: function(), + _currentRules: function(), + topState: function(), + pushState: function(condition), + + options: { + ranges: boolean (optional: true ==> token location info will include a .range[] member) + flex: boolean (optional: true ==> flex-like lexing behaviour where the rules are tested exhaustively to find the longest match) + backtrack_lexer: boolean (optional: true ==> lexer regexes are tested in order and for each matching regex the action code is invoked; the lexer terminates the scan when a token is returned by the action code) + }, + + performAction: function(yy, yy_, $avoiding_name_collisions, YY_START), + rules: [...], + conditions: {associative list: name ==> set}, + } + } + + + token location info (@$, _$, etc.): { + first_line: n, + last_line: n, + first_column: n, + last_column: n, + range: [start_number, end_number] (where the numbers are indexes into the input string, regular zero-based) + } + + + the parseError function receives a 'hash' object with these members for lexer and parser errors: { + text: (matched text) + token: (the produced terminal token, if any) + line: (yylineno) + } + while parser (grammar) errors will also provide these members, i.e. parser errors deliver a superset of attributes: { + loc: (yylloc) + expected: (string describing the set of expected tokens) + recoverable: (boolean: TRUE when the parser has a error recovery rule available for this particular error) + } +*/ var parser = {trace: function trace() { }, yy: {}, -symbols_: {"error":2,"Root":3,"Body":4,"Block":5,"TERMINATOR":6,"Line":7,"Expression":8,"Statement":9,"Return":10,"Comment":11,"STATEMENT":12,"Value":13,"Invocation":14,"Code":15,"Operation":16,"Assign":17,"If":18,"Try":19,"While":20,"For":21,"Switch":22,"Class":23,"Throw":24,"INDENT":25,"OUTDENT":26,"Identifier":27,"IDENTIFIER":28,"AlphaNumeric":29,"NUMBER":30,"STRING":31,"Literal":32,"JS":33,"REGEX":34,"DEBUGGER":35,"UNDEFINED":36,"NULL":37,"BOOL":38,"Assignable":39,"=":40,"AssignObj":41,"ObjAssignable":42,":":43,"ThisProperty":44,"RETURN":45,"HERECOMMENT":46,"PARAM_START":47,"ParamList":48,"PARAM_END":49,"FuncGlyph":50,"->":51,"=>":52,"OptComma":53,",":54,"Param":55,"ParamVar":56,"...":57,"Array":58,"Object":59,"Splat":60,"SimpleAssignable":61,"Accessor":62,"Parenthetical":63,"Range":64,"This":65,".":66,"?.":67,"::":68,"?::":69,"Index":70,"INDEX_START":71,"IndexValue":72,"INDEX_END":73,"INDEX_SOAK":74,"Slice":75,"{":76,"AssignList":77,"}":78,"CLASS":79,"EXTENDS":80,"OptFuncExist":81,"Arguments":82,"SUPER":83,"FUNC_EXIST":84,"CALL_START":85,"CALL_END":86,"ArgList":87,"THIS":88,"@":89,"[":90,"]":91,"RangeDots":92,"..":93,"Arg":94,"SimpleArgs":95,"TRY":96,"Catch":97,"FINALLY":98,"CATCH":99,"THROW":100,"(":101,")":102,"WhileSource":103,"WHILE":104,"WHEN":105,"UNTIL":106,"Loop":107,"LOOP":108,"ForBody":109,"FOR":110,"ForStart":111,"ForSource":112,"ForVariables":113,"OWN":114,"ForValue":115,"FORIN":116,"FOROF":117,"BY":118,"SWITCH":119,"Whens":120,"ELSE":121,"When":122,"LEADING_WHEN":123,"IfBlock":124,"IF":125,"POST_IF":126,"UNARY":127,"-":128,"+":129,"--":130,"++":131,"?":132,"MATH":133,"SHIFT":134,"COMPARE":135,"LOGIC":136,"RELATION":137,"COMPOUND_ASSIGN":138,"$accept":0,"$end":1}, -terminals_: {2:"error",6:"TERMINATOR",12:"STATEMENT",25:"INDENT",26:"OUTDENT",28:"IDENTIFIER",30:"NUMBER",31:"STRING",33:"JS",34:"REGEX",35:"DEBUGGER",36:"UNDEFINED",37:"NULL",38:"BOOL",40:"=",43:":",45:"RETURN",46:"HERECOMMENT",47:"PARAM_START",49:"PARAM_END",51:"->",52:"=>",54:",",57:"...",66:".",67:"?.",68:"::",69:"?::",71:"INDEX_START",73:"INDEX_END",74:"INDEX_SOAK",76:"{",78:"}",79:"CLASS",80:"EXTENDS",83:"SUPER",84:"FUNC_EXIST",85:"CALL_START",86:"CALL_END",88:"THIS",89:"@",90:"[",91:"]",93:"..",96:"TRY",98:"FINALLY",99:"CATCH",100:"THROW",101:"(",102:")",104:"WHILE",105:"WHEN",106:"UNTIL",108:"LOOP",110:"FOR",114:"OWN",116:"FORIN",117:"FOROF",118:"BY",119:"SWITCH",121:"ELSE",123:"LEADING_WHEN",125:"IF",126:"POST_IF",127:"UNARY",128:"-",129:"+",130:"--",131:"++",132:"?",133:"MATH",134:"SHIFT",135:"COMPARE",136:"LOGIC",137:"RELATION",138:"COMPOUND_ASSIGN"}, -productions_: [0,[3,0],[3,1],[3,2],[4,1],[4,3],[4,2],[7,1],[7,1],[9,1],[9,1],[9,1],[8,1],[8,1],[8,1],[8,1],[8,1],[8,1],[8,1],[8,1],[8,1],[8,1],[8,1],[8,1],[5,2],[5,3],[27,1],[29,1],[29,1],[32,1],[32,1],[32,1],[32,1],[32,1],[32,1],[32,1],[17,3],[17,4],[17,5],[41,1],[41,3],[41,5],[41,1],[42,1],[42,1],[42,1],[10,2],[10,1],[11,1],[15,5],[15,2],[50,1],[50,1],[53,0],[53,1],[48,0],[48,1],[48,3],[48,4],[48,6],[55,1],[55,2],[55,3],[56,1],[56,1],[56,1],[56,1],[60,2],[61,1],[61,2],[61,2],[61,1],[39,1],[39,1],[39,1],[13,1],[13,1],[13,1],[13,1],[13,1],[62,2],[62,2],[62,2],[62,2],[62,1],[62,1],[70,3],[70,2],[72,1],[72,1],[59,4],[77,0],[77,1],[77,3],[77,4],[77,6],[23,1],[23,2],[23,3],[23,4],[23,2],[23,3],[23,4],[23,5],[14,3],[14,3],[14,1],[14,2],[81,0],[81,1],[82,2],[82,4],[65,1],[65,1],[44,2],[58,2],[58,4],[92,1],[92,1],[64,5],[75,3],[75,2],[75,2],[75,1],[87,1],[87,3],[87,4],[87,4],[87,6],[94,1],[94,1],[95,1],[95,3],[19,2],[19,3],[19,4],[19,5],[97,3],[97,3],[97,2],[24,2],[63,3],[63,5],[103,2],[103,4],[103,2],[103,4],[20,2],[20,2],[20,2],[20,1],[107,2],[107,2],[21,2],[21,2],[21,2],[109,2],[109,2],[111,2],[111,3],[115,1],[115,1],[115,1],[115,1],[113,1],[113,3],[112,2],[112,2],[112,4],[112,4],[112,4],[112,6],[112,6],[22,5],[22,7],[22,4],[22,6],[120,1],[120,2],[122,3],[122,4],[124,3],[124,5],[18,1],[18,3],[18,3],[18,3],[16,2],[16,2],[16,2],[16,2],[16,2],[16,2],[16,2],[16,2],[16,3],[16,3],[16,3],[16,3],[16,3],[16,3],[16,3],[16,3],[16,5],[16,4],[16,3]], -performAction: function anonymous(yytext,yyleng,yylineno,yy,yystate,$$,_$) { +symbols_: {"error":2,"Root":3,"Body":4,"Line":5,"TERMINATOR":6,"Expression":7,"Statement":8,"Return":9,"Comment":10,"STATEMENT":11,"Value":12,"Invocation":13,"Code":14,"Operation":15,"Assign":16,"If":17,"Try":18,"While":19,"For":20,"Switch":21,"Class":22,"Throw":23,"Block":24,"INDENT":25,"OUTDENT":26,"Identifier":27,"IDENTIFIER":28,"AlphaNumeric":29,"NUMBER":30,"STRING":31,"Literal":32,"JS":33,"REGEX":34,"DEBUGGER":35,"UNDEFINED":36,"NULL":37,"BOOL":38,"Assignable":39,"=":40,"AssignObj":41,"ObjAssignable":42,":":43,"ThisProperty":44,"RETURN":45,"HERECOMMENT":46,"PARAM_START":47,"ParamList":48,"PARAM_END":49,"FuncGlyph":50,"->":51,"=>":52,"OptComma":53,",":54,"Param":55,"ParamVar":56,"...":57,"Array":58,"Object":59,"Splat":60,"SimpleAssignable":61,"Accessor":62,"Parenthetical":63,"Range":64,"This":65,".":66,"?.":67,"::":68,"?::":69,"Index":70,"INDEX_START":71,"IndexValue":72,"INDEX_END":73,"INDEX_SOAK":74,"Slice":75,"{":76,"AssignList":77,"}":78,"CLASS":79,"EXTENDS":80,"OptFuncExist":81,"Arguments":82,"SUPER":83,"FUNC_EXIST":84,"CALL_START":85,"CALL_END":86,"ArgList":87,"THIS":88,"@":89,"[":90,"]":91,"RangeDots":92,"..":93,"Arg":94,"SimpleArgs":95,"TRY":96,"Catch":97,"FINALLY":98,"CATCH":99,"THROW":100,"(":101,")":102,"WhileSource":103,"WHILE":104,"WHEN":105,"UNTIL":106,"Loop":107,"LOOP":108,"ForBody":109,"FOR":110,"ForStart":111,"ForSource":112,"ForVariables":113,"OWN":114,"ForValue":115,"FORIN":116,"FOROF":117,"BY":118,"SWITCH":119,"Whens":120,"ELSE":121,"When":122,"LEADING_WHEN":123,"IfBlock":124,"IF":125,"POST_IF":126,"UNARY":127,"-":128,"+":129,"--":130,"++":131,"?":132,"MATH":133,"SHIFT":134,"COMPARE":135,"LOGIC":136,"RELATION":137,"COMPOUND_ASSIGN":138,"$accept":0,"$end":1}, +terminals_: {2:"error",6:"TERMINATOR",11:"STATEMENT",25:"INDENT",26:"OUTDENT",28:"IDENTIFIER",30:"NUMBER",31:"STRING",33:"JS",34:"REGEX",35:"DEBUGGER",36:"UNDEFINED",37:"NULL",38:"BOOL",40:"=",43:":",45:"RETURN",46:"HERECOMMENT",47:"PARAM_START",49:"PARAM_END",51:"->",52:"=>",54:",",57:"...",66:".",67:"?.",68:"::",69:"?::",71:"INDEX_START",73:"INDEX_END",74:"INDEX_SOAK",76:"{",78:"}",79:"CLASS",80:"EXTENDS",83:"SUPER",84:"FUNC_EXIST",85:"CALL_START",86:"CALL_END",88:"THIS",89:"@",90:"[",91:"]",93:"..",96:"TRY",98:"FINALLY",99:"CATCH",100:"THROW",101:"(",102:")",104:"WHILE",105:"WHEN",106:"UNTIL",108:"LOOP",110:"FOR",114:"OWN",116:"FORIN",117:"FOROF",118:"BY",119:"SWITCH",121:"ELSE",123:"LEADING_WHEN",125:"IF",126:"POST_IF",127:"UNARY",128:"-",129:"+",130:"--",131:"++",132:"?",133:"MATH",134:"SHIFT",135:"COMPARE",136:"LOGIC",137:"RELATION",138:"COMPOUND_ASSIGN"}, +productions_: [0,[3,0],[3,1],[4,1],[4,3],[4,2],[5,1],[5,1],[8,1],[8,1],[8,1],[7,1],[7,1],[7,1],[7,1],[7,1],[7,1],[7,1],[7,1],[7,1],[7,1],[7,1],[7,1],[24,2],[24,3],[27,1],[29,1],[29,1],[32,1],[32,1],[32,1],[32,1],[32,1],[32,1],[32,1],[16,3],[16,4],[16,5],[41,1],[41,3],[41,5],[41,1],[42,1],[42,1],[42,1],[9,2],[9,1],[10,1],[14,5],[14,2],[50,1],[50,1],[53,0],[53,1],[48,0],[48,1],[48,3],[48,4],[48,6],[55,1],[55,2],[55,3],[56,1],[56,1],[56,1],[56,1],[60,2],[61,1],[61,2],[61,2],[61,1],[39,1],[39,1],[39,1],[12,1],[12,1],[12,1],[12,1],[12,1],[62,2],[62,2],[62,2],[62,2],[62,1],[62,1],[70,3],[70,2],[72,1],[72,1],[59,4],[77,0],[77,1],[77,3],[77,4],[77,6],[22,1],[22,2],[22,3],[22,4],[22,2],[22,3],[22,4],[22,5],[13,3],[13,3],[13,1],[13,2],[81,0],[81,1],[82,2],[82,4],[65,1],[65,1],[44,2],[58,2],[58,4],[92,1],[92,1],[64,5],[75,3],[75,2],[75,2],[75,1],[87,1],[87,3],[87,4],[87,4],[87,6],[94,1],[94,1],[95,1],[95,3],[18,2],[18,3],[18,4],[18,5],[97,3],[97,3],[97,2],[23,2],[63,3],[63,5],[103,2],[103,4],[103,2],[103,4],[19,2],[19,2],[19,2],[19,1],[107,2],[107,2],[20,2],[20,2],[20,2],[109,2],[109,2],[111,2],[111,3],[115,1],[115,1],[115,1],[115,1],[113,1],[113,3],[112,2],[112,2],[112,4],[112,4],[112,4],[112,6],[112,6],[21,5],[21,7],[21,4],[21,6],[120,1],[120,2],[122,3],[122,4],[124,3],[124,5],[17,1],[17,3],[17,3],[17,3],[15,2],[15,2],[15,2],[15,2],[15,2],[15,2],[15,2],[15,2],[15,3],[15,3],[15,3],[15,3],[15,3],[15,3],[15,3],[15,3],[15,5],[15,4],[15,3]], +performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate /* action[1] */, $$ /* vstack */, _$ /* lstack */) { +/* this == yyval */ var $0 = $$.length - 1; switch (yystate) { @@ -40,13 +113,13 @@ case 1:return this.$ = yy.addLocationDataFn(_$[$0], _$[$0])(new yy.Block); break; case 2:return this.$ = $$[$0]; break; -case 3:return this.$ = $$[$0-1]; +case 3:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])(yy.Block.wrap([$$[$0]])); break; -case 4:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])(yy.Block.wrap([$$[$0]])); +case 4:this.$ = yy.addLocationDataFn(_$[$0-2], _$[$0])($$[$0-2].push($$[$0])); break; -case 5:this.$ = yy.addLocationDataFn(_$[$0-2], _$[$0])($$[$0-2].push($$[$0])); +case 5:this.$ = $$[$0-1]; break; -case 6:this.$ = $$[$0-1]; +case 6:this.$ = $$[$0]; break; case 7:this.$ = $$[$0]; break; @@ -54,9 +127,9 @@ case 8:this.$ = $$[$0]; break; case 9:this.$ = $$[$0]; break; -case 10:this.$ = $$[$0]; +case 10:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])(new yy.Literal($$[$0])); break; -case 11:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])(new yy.Literal($$[$0])); +case 11:this.$ = $$[$0]; break; case 12:this.$ = $$[$0]; break; @@ -80,43 +153,43 @@ case 21:this.$ = $$[$0]; break; case 22:this.$ = $$[$0]; break; -case 23:this.$ = $$[$0]; +case 23:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])(new yy.Block); break; -case 24:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])(new yy.Block); +case 24:this.$ = yy.addLocationDataFn(_$[$0-2], _$[$0])($$[$0-1]); break; -case 25:this.$ = yy.addLocationDataFn(_$[$0-2], _$[$0])($$[$0-1]); +case 25:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])(new yy.Literal($$[$0])); break; case 26:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])(new yy.Literal($$[$0])); break; case 27:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])(new yy.Literal($$[$0])); break; -case 28:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])(new yy.Literal($$[$0])); +case 28:this.$ = $$[$0]; break; -case 29:this.$ = $$[$0]; +case 29:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])(new yy.Literal($$[$0])); break; case 30:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])(new yy.Literal($$[$0])); break; case 31:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])(new yy.Literal($$[$0])); break; -case 32:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])(new yy.Literal($$[$0])); +case 32:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])(new yy.Undefined); break; -case 33:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])(new yy.Undefined); +case 33:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])(new yy.Null); break; -case 34:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])(new yy.Null); +case 34:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])(new yy.Bool($$[$0])); break; -case 35:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])(new yy.Bool($$[$0])); +case 35:this.$ = yy.addLocationDataFn(_$[$0-2], _$[$0])(new yy.Assign($$[$0-2], $$[$0])); break; -case 36:this.$ = yy.addLocationDataFn(_$[$0-2], _$[$0])(new yy.Assign($$[$0-2], $$[$0])); +case 36:this.$ = yy.addLocationDataFn(_$[$0-3], _$[$0])(new yy.Assign($$[$0-3], $$[$0])); break; -case 37:this.$ = yy.addLocationDataFn(_$[$0-3], _$[$0])(new yy.Assign($$[$0-3], $$[$0])); +case 37:this.$ = yy.addLocationDataFn(_$[$0-4], _$[$0])(new yy.Assign($$[$0-4], $$[$0-1])); break; -case 38:this.$ = yy.addLocationDataFn(_$[$0-4], _$[$0])(new yy.Assign($$[$0-4], $$[$0-1])); +case 38:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])(new yy.Value($$[$0])); break; -case 39:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])(new yy.Value($$[$0])); +case 39:this.$ = yy.addLocationDataFn(_$[$0-2], _$[$0])(new yy.Assign(yy.addLocationDataFn(_$[$0-2])(new yy.Value($$[$0-2])), $$[$0], 'object')); break; -case 40:this.$ = yy.addLocationDataFn(_$[$0-2], _$[$0])(new yy.Assign(yy.addLocationDataFn(_$[$0-2])(new yy.Value($$[$0-2])), $$[$0], 'object')); +case 40:this.$ = yy.addLocationDataFn(_$[$0-4], _$[$0])(new yy.Assign(yy.addLocationDataFn(_$[$0-4])(new yy.Value($$[$0-4])), $$[$0-1], 'object')); break; -case 41:this.$ = yy.addLocationDataFn(_$[$0-4], _$[$0])(new yy.Assign(yy.addLocationDataFn(_$[$0-4])(new yy.Value($$[$0-4])), $$[$0-1], 'object')); +case 41:this.$ = $$[$0]; break; case 42:this.$ = $$[$0]; break; @@ -124,41 +197,41 @@ case 43:this.$ = $$[$0]; break; case 44:this.$ = $$[$0]; break; -case 45:this.$ = $$[$0]; +case 45:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])(new yy.Return($$[$0])); break; -case 46:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])(new yy.Return($$[$0])); +case 46:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])(new yy.Return); break; -case 47:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])(new yy.Return); +case 47:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])(new yy.Comment($$[$0])); break; -case 48:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])(new yy.Comment($$[$0])); +case 48:this.$ = yy.addLocationDataFn(_$[$0-4], _$[$0])(new yy.Code($$[$0-3], $$[$0], $$[$0-1])); break; -case 49:this.$ = yy.addLocationDataFn(_$[$0-4], _$[$0])(new yy.Code($$[$0-3], $$[$0], $$[$0-1])); +case 49:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])(new yy.Code([], $$[$0], $$[$0-1])); break; -case 50:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])(new yy.Code([], $$[$0], $$[$0-1])); +case 50:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])('func'); break; -case 51:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])('func'); +case 51:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])('boundfunc'); break; -case 52:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])('boundfunc'); +case 52:this.$ = $$[$0]; break; case 53:this.$ = $$[$0]; break; -case 54:this.$ = $$[$0]; +case 54:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])([]); break; -case 55:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])([]); +case 55:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])([$$[$0]]); break; -case 56:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])([$$[$0]]); +case 56:this.$ = yy.addLocationDataFn(_$[$0-2], _$[$0])($$[$0-2].concat($$[$0])); break; -case 57:this.$ = yy.addLocationDataFn(_$[$0-2], _$[$0])($$[$0-2].concat($$[$0])); +case 57:this.$ = yy.addLocationDataFn(_$[$0-3], _$[$0])($$[$0-3].concat($$[$0])); break; -case 58:this.$ = yy.addLocationDataFn(_$[$0-3], _$[$0])($$[$0-3].concat($$[$0])); +case 58:this.$ = yy.addLocationDataFn(_$[$0-5], _$[$0])($$[$0-5].concat($$[$0-2])); break; -case 59:this.$ = yy.addLocationDataFn(_$[$0-5], _$[$0])($$[$0-5].concat($$[$0-2])); +case 59:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])(new yy.Param($$[$0])); break; -case 60:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])(new yy.Param($$[$0])); +case 60:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])(new yy.Param($$[$0-1], null, true)); break; -case 61:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])(new yy.Param($$[$0-1], null, true)); +case 61:this.$ = yy.addLocationDataFn(_$[$0-2], _$[$0])(new yy.Param($$[$0-2], $$[$0])); break; -case 62:this.$ = yy.addLocationDataFn(_$[$0-2], _$[$0])(new yy.Param($$[$0-2], $$[$0])); +case 62:this.$ = $$[$0]; break; case 63:this.$ = $$[$0]; break; @@ -166,319 +239,319 @@ case 64:this.$ = $$[$0]; break; case 65:this.$ = $$[$0]; break; -case 66:this.$ = $$[$0]; +case 66:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])(new yy.Splat($$[$0-1])); break; -case 67:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])(new yy.Splat($$[$0-1])); +case 67:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])(new yy.Value($$[$0])); break; -case 68:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])(new yy.Value($$[$0])); +case 68:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])($$[$0-1].add($$[$0])); break; -case 69:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])($$[$0-1].add($$[$0])); +case 69:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])(new yy.Value($$[$0-1], [].concat($$[$0]))); break; -case 70:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])(new yy.Value($$[$0-1], [].concat($$[$0]))); +case 70:this.$ = $$[$0]; break; case 71:this.$ = $$[$0]; break; -case 72:this.$ = $$[$0]; +case 72:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])(new yy.Value($$[$0])); break; case 73:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])(new yy.Value($$[$0])); break; -case 74:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])(new yy.Value($$[$0])); +case 74:this.$ = $$[$0]; break; -case 75:this.$ = $$[$0]; +case 75:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])(new yy.Value($$[$0])); break; case 76:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])(new yy.Value($$[$0])); break; case 77:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])(new yy.Value($$[$0])); break; -case 78:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])(new yy.Value($$[$0])); +case 78:this.$ = $$[$0]; break; -case 79:this.$ = $$[$0]; +case 79:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])(new yy.Access($$[$0])); break; -case 80:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])(new yy.Access($$[$0])); +case 80:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])(new yy.Access($$[$0], 'soak')); break; -case 81:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])(new yy.Access($$[$0], 'soak')); +case 81:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])([yy.addLocationDataFn(_$[$0-1])(new yy.Access(new yy.Literal('prototype'))), yy.addLocationDataFn(_$[$0])(new yy.Access($$[$0]))]); break; -case 82:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])([yy.addLocationDataFn(_$[$0-1])(new yy.Access(new yy.Literal('prototype'))), yy.addLocationDataFn(_$[$0])(new yy.Access($$[$0]))]); +case 82:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])([yy.addLocationDataFn(_$[$0-1])(new yy.Access(new yy.Literal('prototype'), 'soak')), yy.addLocationDataFn(_$[$0])(new yy.Access($$[$0]))]); break; -case 83:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])([yy.addLocationDataFn(_$[$0-1])(new yy.Access(new yy.Literal('prototype'), 'soak')), yy.addLocationDataFn(_$[$0])(new yy.Access($$[$0]))]); +case 83:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])(new yy.Access(new yy.Literal('prototype'))); break; -case 84:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])(new yy.Access(new yy.Literal('prototype'))); +case 84:this.$ = $$[$0]; break; -case 85:this.$ = $$[$0]; +case 85:this.$ = yy.addLocationDataFn(_$[$0-2], _$[$0])($$[$0-1]); break; -case 86:this.$ = yy.addLocationDataFn(_$[$0-2], _$[$0])($$[$0-1]); -break; -case 87:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])(yy.extend($$[$0], { +case 86:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])(yy.extend($$[$0], { soak: true })); break; -case 88:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])(new yy.Index($$[$0])); +case 87:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])(new yy.Index($$[$0])); break; -case 89:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])(new yy.Slice($$[$0])); +case 88:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])(new yy.Slice($$[$0])); break; -case 90:this.$ = yy.addLocationDataFn(_$[$0-3], _$[$0])(new yy.Obj($$[$0-2], $$[$0-3].generated)); +case 89:this.$ = yy.addLocationDataFn(_$[$0-3], _$[$0])(new yy.Obj($$[$0-2], $$[$0-3].generated)); break; -case 91:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])([]); +case 90:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])([]); break; -case 92:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])([$$[$0]]); +case 91:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])([$$[$0]]); break; -case 93:this.$ = yy.addLocationDataFn(_$[$0-2], _$[$0])($$[$0-2].concat($$[$0])); +case 92:this.$ = yy.addLocationDataFn(_$[$0-2], _$[$0])($$[$0-2].concat($$[$0])); break; -case 94:this.$ = yy.addLocationDataFn(_$[$0-3], _$[$0])($$[$0-3].concat($$[$0])); +case 93:this.$ = yy.addLocationDataFn(_$[$0-3], _$[$0])($$[$0-3].concat($$[$0])); break; -case 95:this.$ = yy.addLocationDataFn(_$[$0-5], _$[$0])($$[$0-5].concat($$[$0-2])); +case 94:this.$ = yy.addLocationDataFn(_$[$0-5], _$[$0])($$[$0-5].concat($$[$0-2])); break; -case 96:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])(new yy.Class); +case 95:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])(new yy.Class); break; -case 97:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])(new yy.Class(null, null, $$[$0])); +case 96:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])(new yy.Class(null, null, $$[$0])); break; -case 98:this.$ = yy.addLocationDataFn(_$[$0-2], _$[$0])(new yy.Class(null, $$[$0])); +case 97:this.$ = yy.addLocationDataFn(_$[$0-2], _$[$0])(new yy.Class(null, $$[$0])); break; -case 99:this.$ = yy.addLocationDataFn(_$[$0-3], _$[$0])(new yy.Class(null, $$[$0-1], $$[$0])); +case 98:this.$ = yy.addLocationDataFn(_$[$0-3], _$[$0])(new yy.Class(null, $$[$0-1], $$[$0])); break; -case 100:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])(new yy.Class($$[$0])); +case 99:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])(new yy.Class($$[$0])); break; -case 101:this.$ = yy.addLocationDataFn(_$[$0-2], _$[$0])(new yy.Class($$[$0-1], null, $$[$0])); +case 100:this.$ = yy.addLocationDataFn(_$[$0-2], _$[$0])(new yy.Class($$[$0-1], null, $$[$0])); break; -case 102:this.$ = yy.addLocationDataFn(_$[$0-3], _$[$0])(new yy.Class($$[$0-2], $$[$0])); +case 101:this.$ = yy.addLocationDataFn(_$[$0-3], _$[$0])(new yy.Class($$[$0-2], $$[$0])); break; -case 103:this.$ = yy.addLocationDataFn(_$[$0-4], _$[$0])(new yy.Class($$[$0-3], $$[$0-1], $$[$0])); +case 102:this.$ = yy.addLocationDataFn(_$[$0-4], _$[$0])(new yy.Class($$[$0-3], $$[$0-1], $$[$0])); +break; +case 103:this.$ = yy.addLocationDataFn(_$[$0-2], _$[$0])(new yy.Call($$[$0-2], $$[$0], $$[$0-1])); break; case 104:this.$ = yy.addLocationDataFn(_$[$0-2], _$[$0])(new yy.Call($$[$0-2], $$[$0], $$[$0-1])); break; -case 105:this.$ = yy.addLocationDataFn(_$[$0-2], _$[$0])(new yy.Call($$[$0-2], $$[$0], $$[$0-1])); +case 105:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])(new yy.Call('super', [new yy.Splat(new yy.Literal('arguments'))])); break; -case 106:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])(new yy.Call('super', [new yy.Splat(new yy.Literal('arguments'))])); +case 106:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])(new yy.Call('super', $$[$0])); break; -case 107:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])(new yy.Call('super', $$[$0])); +case 107:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])(false); break; -case 108:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])(false); +case 108:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])(true); break; -case 109:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])(true); +case 109:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])([]); break; -case 110:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])([]); +case 110:this.$ = yy.addLocationDataFn(_$[$0-3], _$[$0])($$[$0-2]); break; -case 111:this.$ = yy.addLocationDataFn(_$[$0-3], _$[$0])($$[$0-2]); +case 111:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])(new yy.Value(new yy.Literal('this'))); break; case 112:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])(new yy.Value(new yy.Literal('this'))); break; -case 113:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])(new yy.Value(new yy.Literal('this'))); +case 113:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])(new yy.Value(yy.addLocationDataFn(_$[$0-1])(new yy.Literal('this')), [yy.addLocationDataFn(_$[$0])(new yy.Access($$[$0]))], 'this')); break; -case 114:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])(new yy.Value(yy.addLocationDataFn(_$[$0-1])(new yy.Literal('this')), [yy.addLocationDataFn(_$[$0])(new yy.Access($$[$0]))], 'this')); +case 114:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])(new yy.Arr([])); break; -case 115:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])(new yy.Arr([])); +case 115:this.$ = yy.addLocationDataFn(_$[$0-3], _$[$0])(new yy.Arr($$[$0-2])); break; -case 116:this.$ = yy.addLocationDataFn(_$[$0-3], _$[$0])(new yy.Arr($$[$0-2])); +case 116:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])('inclusive'); break; -case 117:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])('inclusive'); +case 117:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])('exclusive'); break; -case 118:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])('exclusive'); +case 118:this.$ = yy.addLocationDataFn(_$[$0-4], _$[$0])(new yy.Range($$[$0-3], $$[$0-1], $$[$0-2])); break; -case 119:this.$ = yy.addLocationDataFn(_$[$0-4], _$[$0])(new yy.Range($$[$0-3], $$[$0-1], $$[$0-2])); +case 119:this.$ = yy.addLocationDataFn(_$[$0-2], _$[$0])(new yy.Range($$[$0-2], $$[$0], $$[$0-1])); break; -case 120:this.$ = yy.addLocationDataFn(_$[$0-2], _$[$0])(new yy.Range($$[$0-2], $$[$0], $$[$0-1])); +case 120:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])(new yy.Range($$[$0-1], null, $$[$0])); break; -case 121:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])(new yy.Range($$[$0-1], null, $$[$0])); +case 121:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])(new yy.Range(null, $$[$0], $$[$0-1])); break; -case 122:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])(new yy.Range(null, $$[$0], $$[$0-1])); +case 122:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])(new yy.Range(null, null, $$[$0])); break; -case 123:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])(new yy.Range(null, null, $$[$0])); +case 123:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])([$$[$0]]); break; -case 124:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])([$$[$0]]); +case 124:this.$ = yy.addLocationDataFn(_$[$0-2], _$[$0])($$[$0-2].concat($$[$0])); break; -case 125:this.$ = yy.addLocationDataFn(_$[$0-2], _$[$0])($$[$0-2].concat($$[$0])); +case 125:this.$ = yy.addLocationDataFn(_$[$0-3], _$[$0])($$[$0-3].concat($$[$0])); break; -case 126:this.$ = yy.addLocationDataFn(_$[$0-3], _$[$0])($$[$0-3].concat($$[$0])); +case 126:this.$ = yy.addLocationDataFn(_$[$0-3], _$[$0])($$[$0-2]); break; -case 127:this.$ = yy.addLocationDataFn(_$[$0-3], _$[$0])($$[$0-2]); +case 127:this.$ = yy.addLocationDataFn(_$[$0-5], _$[$0])($$[$0-5].concat($$[$0-2])); break; -case 128:this.$ = yy.addLocationDataFn(_$[$0-5], _$[$0])($$[$0-5].concat($$[$0-2])); +case 128:this.$ = $$[$0]; break; case 129:this.$ = $$[$0]; break; case 130:this.$ = $$[$0]; break; -case 131:this.$ = $$[$0]; +case 131:this.$ = yy.addLocationDataFn(_$[$0-2], _$[$0])([].concat($$[$0-2], $$[$0])); break; -case 132:this.$ = yy.addLocationDataFn(_$[$0-2], _$[$0])([].concat($$[$0-2], $$[$0])); +case 132:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])(new yy.Try($$[$0])); break; -case 133:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])(new yy.Try($$[$0])); +case 133:this.$ = yy.addLocationDataFn(_$[$0-2], _$[$0])(new yy.Try($$[$0-1], $$[$0][0], $$[$0][1])); break; -case 134:this.$ = yy.addLocationDataFn(_$[$0-2], _$[$0])(new yy.Try($$[$0-1], $$[$0][0], $$[$0][1])); +case 134:this.$ = yy.addLocationDataFn(_$[$0-3], _$[$0])(new yy.Try($$[$0-2], null, null, $$[$0])); break; -case 135:this.$ = yy.addLocationDataFn(_$[$0-3], _$[$0])(new yy.Try($$[$0-2], null, null, $$[$0])); +case 135:this.$ = yy.addLocationDataFn(_$[$0-4], _$[$0])(new yy.Try($$[$0-3], $$[$0-2][0], $$[$0-2][1], $$[$0])); break; -case 136:this.$ = yy.addLocationDataFn(_$[$0-4], _$[$0])(new yy.Try($$[$0-3], $$[$0-2][0], $$[$0-2][1], $$[$0])); +case 136:this.$ = yy.addLocationDataFn(_$[$0-2], _$[$0])([$$[$0-1], $$[$0]]); break; -case 137:this.$ = yy.addLocationDataFn(_$[$0-2], _$[$0])([$$[$0-1], $$[$0]]); +case 137:this.$ = yy.addLocationDataFn(_$[$0-2], _$[$0])([yy.addLocationDataFn(_$[$0-1])(new yy.Value($$[$0-1])), $$[$0]]); break; -case 138:this.$ = yy.addLocationDataFn(_$[$0-2], _$[$0])([yy.addLocationDataFn(_$[$0-1])(new yy.Value($$[$0-1])), $$[$0]]); +case 138:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])([null, $$[$0]]); break; -case 139:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])([null, $$[$0]]); +case 139:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])(new yy.Throw($$[$0])); break; -case 140:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])(new yy.Throw($$[$0])); +case 140:this.$ = yy.addLocationDataFn(_$[$0-2], _$[$0])(new yy.Parens($$[$0-1])); break; -case 141:this.$ = yy.addLocationDataFn(_$[$0-2], _$[$0])(new yy.Parens($$[$0-1])); +case 141:this.$ = yy.addLocationDataFn(_$[$0-4], _$[$0])(new yy.Parens($$[$0-2])); break; -case 142:this.$ = yy.addLocationDataFn(_$[$0-4], _$[$0])(new yy.Parens($$[$0-2])); +case 142:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])(new yy.While($$[$0])); break; -case 143:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])(new yy.While($$[$0])); -break; -case 144:this.$ = yy.addLocationDataFn(_$[$0-3], _$[$0])(new yy.While($$[$0-2], { +case 143:this.$ = yy.addLocationDataFn(_$[$0-3], _$[$0])(new yy.While($$[$0-2], { guard: $$[$0] })); break; -case 145:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])(new yy.While($$[$0], { +case 144:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])(new yy.While($$[$0], { invert: true })); break; -case 146:this.$ = yy.addLocationDataFn(_$[$0-3], _$[$0])(new yy.While($$[$0-2], { +case 145:this.$ = yy.addLocationDataFn(_$[$0-3], _$[$0])(new yy.While($$[$0-2], { invert: true, guard: $$[$0] })); break; -case 147:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])($$[$0-1].addBody($$[$0])); +case 146:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])($$[$0-1].addBody($$[$0])); +break; +case 147:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])($$[$0].addBody(yy.addLocationDataFn(_$[$0-1])(yy.Block.wrap([$$[$0-1]])))); break; case 148:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])($$[$0].addBody(yy.addLocationDataFn(_$[$0-1])(yy.Block.wrap([$$[$0-1]])))); break; -case 149:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])($$[$0].addBody(yy.addLocationDataFn(_$[$0-1])(yy.Block.wrap([$$[$0-1]])))); +case 149:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])($$[$0]); break; -case 150:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])($$[$0]); +case 150:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])(new yy.While(yy.addLocationDataFn(_$[$0-1])(new yy.Literal('true'))).addBody($$[$0])); break; -case 151:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])(new yy.While(yy.addLocationDataFn(_$[$0-1])(new yy.Literal('true'))).addBody($$[$0])); +case 151:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])(new yy.While(yy.addLocationDataFn(_$[$0-1])(new yy.Literal('true'))).addBody(yy.addLocationDataFn(_$[$0])(yy.Block.wrap([$$[$0]])))); break; -case 152:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])(new yy.While(yy.addLocationDataFn(_$[$0-1])(new yy.Literal('true'))).addBody(yy.addLocationDataFn(_$[$0])(yy.Block.wrap([$$[$0]])))); +case 152:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])(new yy.For($$[$0-1], $$[$0])); break; case 153:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])(new yy.For($$[$0-1], $$[$0])); break; -case 154:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])(new yy.For($$[$0-1], $$[$0])); +case 154:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])(new yy.For($$[$0], $$[$0-1])); break; -case 155:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])(new yy.For($$[$0], $$[$0-1])); -break; -case 156:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])({ +case 155:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])({ source: yy.addLocationDataFn(_$[$0])(new yy.Value($$[$0])) }); break; -case 157:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])((function () { +case 156:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])((function () { $$[$0].own = $$[$0-1].own; $$[$0].name = $$[$0-1][0]; $$[$0].index = $$[$0-1][1]; return $$[$0]; }())); break; -case 158:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])($$[$0]); +case 157:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])($$[$0]); break; -case 159:this.$ = yy.addLocationDataFn(_$[$0-2], _$[$0])((function () { +case 158:this.$ = yy.addLocationDataFn(_$[$0-2], _$[$0])((function () { $$[$0].own = true; return $$[$0]; }())); break; +case 159:this.$ = $$[$0]; +break; case 160:this.$ = $$[$0]; break; -case 161:this.$ = $$[$0]; +case 161:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])(new yy.Value($$[$0])); break; case 162:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])(new yy.Value($$[$0])); break; -case 163:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])(new yy.Value($$[$0])); +case 163:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])([$$[$0]]); break; -case 164:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])([$$[$0]]); +case 164:this.$ = yy.addLocationDataFn(_$[$0-2], _$[$0])([$$[$0-2], $$[$0]]); break; -case 165:this.$ = yy.addLocationDataFn(_$[$0-2], _$[$0])([$$[$0-2], $$[$0]]); -break; -case 166:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])({ +case 165:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])({ source: $$[$0] }); break; -case 167:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])({ +case 166:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])({ source: $$[$0], object: true }); break; -case 168:this.$ = yy.addLocationDataFn(_$[$0-3], _$[$0])({ +case 167:this.$ = yy.addLocationDataFn(_$[$0-3], _$[$0])({ source: $$[$0-2], guard: $$[$0] }); break; -case 169:this.$ = yy.addLocationDataFn(_$[$0-3], _$[$0])({ +case 168:this.$ = yy.addLocationDataFn(_$[$0-3], _$[$0])({ source: $$[$0-2], guard: $$[$0], object: true }); break; -case 170:this.$ = yy.addLocationDataFn(_$[$0-3], _$[$0])({ +case 169:this.$ = yy.addLocationDataFn(_$[$0-3], _$[$0])({ source: $$[$0-2], step: $$[$0] }); break; -case 171:this.$ = yy.addLocationDataFn(_$[$0-5], _$[$0])({ +case 170:this.$ = yy.addLocationDataFn(_$[$0-5], _$[$0])({ source: $$[$0-4], guard: $$[$0-2], step: $$[$0] }); break; -case 172:this.$ = yy.addLocationDataFn(_$[$0-5], _$[$0])({ +case 171:this.$ = yy.addLocationDataFn(_$[$0-5], _$[$0])({ source: $$[$0-4], step: $$[$0-2], guard: $$[$0] }); break; -case 173:this.$ = yy.addLocationDataFn(_$[$0-4], _$[$0])(new yy.Switch($$[$0-3], $$[$0-1])); +case 172:this.$ = yy.addLocationDataFn(_$[$0-4], _$[$0])(new yy.Switch($$[$0-3], $$[$0-1])); break; -case 174:this.$ = yy.addLocationDataFn(_$[$0-6], _$[$0])(new yy.Switch($$[$0-5], $$[$0-3], $$[$0-1])); +case 173:this.$ = yy.addLocationDataFn(_$[$0-6], _$[$0])(new yy.Switch($$[$0-5], $$[$0-3], $$[$0-1])); break; -case 175:this.$ = yy.addLocationDataFn(_$[$0-3], _$[$0])(new yy.Switch(null, $$[$0-1])); +case 174:this.$ = yy.addLocationDataFn(_$[$0-3], _$[$0])(new yy.Switch(null, $$[$0-1])); break; -case 176:this.$ = yy.addLocationDataFn(_$[$0-5], _$[$0])(new yy.Switch(null, $$[$0-3], $$[$0-1])); +case 175:this.$ = yy.addLocationDataFn(_$[$0-5], _$[$0])(new yy.Switch(null, $$[$0-3], $$[$0-1])); break; -case 177:this.$ = $$[$0]; +case 176:this.$ = $$[$0]; break; -case 178:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])($$[$0-1].concat($$[$0])); +case 177:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])($$[$0-1].concat($$[$0])); break; -case 179:this.$ = yy.addLocationDataFn(_$[$0-2], _$[$0])([[$$[$0-1], $$[$0]]]); +case 178:this.$ = yy.addLocationDataFn(_$[$0-2], _$[$0])([[$$[$0-1], $$[$0]]]); break; -case 180:this.$ = yy.addLocationDataFn(_$[$0-3], _$[$0])([[$$[$0-2], $$[$0-1]]]); +case 179:this.$ = yy.addLocationDataFn(_$[$0-3], _$[$0])([[$$[$0-2], $$[$0-1]]]); break; -case 181:this.$ = yy.addLocationDataFn(_$[$0-2], _$[$0])(new yy.If($$[$0-1], $$[$0], { +case 180:this.$ = yy.addLocationDataFn(_$[$0-2], _$[$0])(new yy.If($$[$0-1], $$[$0], { type: $$[$0-2] })); break; -case 182:this.$ = yy.addLocationDataFn(_$[$0-4], _$[$0])($$[$0-4].addElse(new yy.If($$[$0-1], $$[$0], { +case 181:this.$ = yy.addLocationDataFn(_$[$0-4], _$[$0])($$[$0-4].addElse(yy.addLocationDataFn(_$[$0-2], _$[$0])(new yy.If($$[$0-1], $$[$0], { type: $$[$0-2] - }))); + })))); break; -case 183:this.$ = $$[$0]; +case 182:this.$ = $$[$0]; break; -case 184:this.$ = yy.addLocationDataFn(_$[$0-2], _$[$0])($$[$0-2].addElse($$[$0])); +case 183:this.$ = yy.addLocationDataFn(_$[$0-2], _$[$0])($$[$0-2].addElse($$[$0])); +break; +case 184:this.$ = yy.addLocationDataFn(_$[$0-2], _$[$0])(new yy.If($$[$0], yy.addLocationDataFn(_$[$0-2])(yy.Block.wrap([$$[$0-2]])), { + type: $$[$0-1], + statement: true + })); break; case 185:this.$ = yy.addLocationDataFn(_$[$0-2], _$[$0])(new yy.If($$[$0], yy.addLocationDataFn(_$[$0-2])(yy.Block.wrap([$$[$0-2]])), { type: $$[$0-1], statement: true })); break; -case 186:this.$ = yy.addLocationDataFn(_$[$0-2], _$[$0])(new yy.If($$[$0], yy.addLocationDataFn(_$[$0-2])(yy.Block.wrap([$$[$0-2]])), { - type: $$[$0-1], - statement: true - })); +case 186:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])(new yy.Op($$[$0-1], $$[$0])); break; -case 187:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])(new yy.Op($$[$0-1], $$[$0])); +case 187:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])(new yy.Op('-', $$[$0])); break; -case 188:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])(new yy.Op('-', $$[$0])); +case 188:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])(new yy.Op('+', $$[$0])); break; -case 189:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])(new yy.Op('+', $$[$0])); +case 189:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])(new yy.Op('--', $$[$0])); break; -case 190:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])(new yy.Op('--', $$[$0])); +case 190:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])(new yy.Op('++', $$[$0])); break; -case 191:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])(new yy.Op('++', $$[$0])); +case 191:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])(new yy.Op('--', $$[$0-1], null, true)); break; -case 192:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])(new yy.Op('--', $$[$0-1], null, true)); +case 192:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])(new yy.Op('++', $$[$0-1], null, true)); break; -case 193:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])(new yy.Op('++', $$[$0-1], null, true)); +case 193:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])(new yy.Existence($$[$0-1])); break; -case 194:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])(new yy.Existence($$[$0-1])); +case 194:this.$ = yy.addLocationDataFn(_$[$0-2], _$[$0])(new yy.Op('+', $$[$0-2], $$[$0])); break; -case 195:this.$ = yy.addLocationDataFn(_$[$0-2], _$[$0])(new yy.Op('+', $$[$0-2], $$[$0])); +case 195:this.$ = yy.addLocationDataFn(_$[$0-2], _$[$0])(new yy.Op('-', $$[$0-2], $$[$0])); break; -case 196:this.$ = yy.addLocationDataFn(_$[$0-2], _$[$0])(new yy.Op('-', $$[$0-2], $$[$0])); +case 196:this.$ = yy.addLocationDataFn(_$[$0-2], _$[$0])(new yy.Op($$[$0-1], $$[$0-2], $$[$0])); break; case 197:this.$ = yy.addLocationDataFn(_$[$0-2], _$[$0])(new yy.Op($$[$0-1], $$[$0-2], $$[$0])); break; @@ -486,9 +559,7 @@ case 198:this.$ = yy.addLocationDataFn(_$[$0-2], _$[$0])(new yy.Op($$[$0-1], $$[ break; case 199:this.$ = yy.addLocationDataFn(_$[$0-2], _$[$0])(new yy.Op($$[$0-1], $$[$0-2], $$[$0])); break; -case 200:this.$ = yy.addLocationDataFn(_$[$0-2], _$[$0])(new yy.Op($$[$0-1], $$[$0-2], $$[$0])); -break; -case 201:this.$ = yy.addLocationDataFn(_$[$0-2], _$[$0])((function () { +case 200:this.$ = yy.addLocationDataFn(_$[$0-2], _$[$0])((function () { if ($$[$0-1].charAt(0) === '!') { return new yy.Op($$[$0-1].slice(1), $$[$0-2], $$[$0]).invert(); } else { @@ -496,36 +567,45 @@ case 201:this.$ = yy.addLocationDataFn(_$[$0-2], _$[$0])((function () { } }())); break; -case 202:this.$ = yy.addLocationDataFn(_$[$0-2], _$[$0])(new yy.Assign($$[$0-2], $$[$0], $$[$0-1])); +case 201:this.$ = yy.addLocationDataFn(_$[$0-2], _$[$0])(new yy.Assign($$[$0-2], $$[$0], $$[$0-1])); break; -case 203:this.$ = yy.addLocationDataFn(_$[$0-4], _$[$0])(new yy.Assign($$[$0-4], $$[$0-1], $$[$0-3])); +case 202:this.$ = yy.addLocationDataFn(_$[$0-4], _$[$0])(new yy.Assign($$[$0-4], $$[$0-1], $$[$0-3])); break; -case 204:this.$ = yy.addLocationDataFn(_$[$0-3], _$[$0])(new yy.Assign($$[$0-3], $$[$0], $$[$0-2])); +case 203:this.$ = yy.addLocationDataFn(_$[$0-3], _$[$0])(new yy.Assign($$[$0-3], $$[$0], $$[$0-2])); break; -case 205:this.$ = yy.addLocationDataFn(_$[$0-2], _$[$0])(new yy.Extends($$[$0-2], $$[$0])); +case 204:this.$ = yy.addLocationDataFn(_$[$0-2], _$[$0])(new yy.Extends($$[$0-2], $$[$0])); break; } }, -table: [{1:[2,1],3:1,4:2,5:3,7:4,8:6,9:7,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,25:[1,5],27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,76:[1,70],79:[1,43],83:[1,28],88:[1,58],89:[1,59],90:[1,57],96:[1,38],100:[1,44],101:[1,56],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{1:[3]},{1:[2,2],6:[1,74]},{6:[1,75]},{1:[2,4],6:[2,4],26:[2,4],102:[2,4]},{4:77,7:4,8:6,9:7,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,26:[1,76],27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,76:[1,70],79:[1,43],83:[1,28],88:[1,58],89:[1,59],90:[1,57],96:[1,38],100:[1,44],101:[1,56],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{1:[2,7],6:[2,7],26:[2,7],102:[2,7],103:87,104:[1,65],106:[1,66],109:88,110:[1,68],111:69,126:[1,86],128:[1,80],129:[1,79],132:[1,78],133:[1,81],134:[1,82],135:[1,83],136:[1,84],137:[1,85]},{1:[2,8],6:[2,8],26:[2,8],102:[2,8],103:90,104:[1,65],106:[1,66],109:91,110:[1,68],111:69,126:[1,89]},{1:[2,12],6:[2,12],25:[2,12],26:[2,12],49:[2,12],54:[2,12],57:[2,12],62:93,66:[1,95],67:[1,96],68:[1,97],69:[1,98],70:99,71:[1,100],73:[2,12],74:[1,101],78:[2,12],81:92,84:[1,94],85:[2,108],86:[2,12],91:[2,12],93:[2,12],102:[2,12],104:[2,12],105:[2,12],106:[2,12],110:[2,12],118:[2,12],126:[2,12],128:[2,12],129:[2,12],132:[2,12],133:[2,12],134:[2,12],135:[2,12],136:[2,12],137:[2,12]},{1:[2,13],6:[2,13],25:[2,13],26:[2,13],49:[2,13],54:[2,13],57:[2,13],62:103,66:[1,95],67:[1,96],68:[1,97],69:[1,98],70:99,71:[1,100],73:[2,13],74:[1,101],78:[2,13],81:102,84:[1,94],85:[2,108],86:[2,13],91:[2,13],93:[2,13],102:[2,13],104:[2,13],105:[2,13],106:[2,13],110:[2,13],118:[2,13],126:[2,13],128:[2,13],129:[2,13],132:[2,13],133:[2,13],134:[2,13],135:[2,13],136:[2,13],137:[2,13]},{1:[2,14],6:[2,14],25:[2,14],26:[2,14],49:[2,14],54:[2,14],57:[2,14],73:[2,14],78:[2,14],86:[2,14],91:[2,14],93:[2,14],102:[2,14],104:[2,14],105:[2,14],106:[2,14],110:[2,14],118:[2,14],126:[2,14],128:[2,14],129:[2,14],132:[2,14],133:[2,14],134:[2,14],135:[2,14],136:[2,14],137:[2,14]},{1:[2,15],6:[2,15],25:[2,15],26:[2,15],49:[2,15],54:[2,15],57:[2,15],73:[2,15],78:[2,15],86:[2,15],91:[2,15],93:[2,15],102:[2,15],104:[2,15],105:[2,15],106:[2,15],110:[2,15],118:[2,15],126:[2,15],128:[2,15],129:[2,15],132:[2,15],133:[2,15],134:[2,15],135:[2,15],136:[2,15],137:[2,15]},{1:[2,16],6:[2,16],25:[2,16],26:[2,16],49:[2,16],54:[2,16],57:[2,16],73:[2,16],78:[2,16],86:[2,16],91:[2,16],93:[2,16],102:[2,16],104:[2,16],105:[2,16],106:[2,16],110:[2,16],118:[2,16],126:[2,16],128:[2,16],129:[2,16],132:[2,16],133:[2,16],134:[2,16],135:[2,16],136:[2,16],137:[2,16]},{1:[2,17],6:[2,17],25:[2,17],26:[2,17],49:[2,17],54:[2,17],57:[2,17],73:[2,17],78:[2,17],86:[2,17],91:[2,17],93:[2,17],102:[2,17],104:[2,17],105:[2,17],106:[2,17],110:[2,17],118:[2,17],126:[2,17],128:[2,17],129:[2,17],132:[2,17],133:[2,17],134:[2,17],135:[2,17],136:[2,17],137:[2,17]},{1:[2,18],6:[2,18],25:[2,18],26:[2,18],49:[2,18],54:[2,18],57:[2,18],73:[2,18],78:[2,18],86:[2,18],91:[2,18],93:[2,18],102:[2,18],104:[2,18],105:[2,18],106:[2,18],110:[2,18],118:[2,18],126:[2,18],128:[2,18],129:[2,18],132:[2,18],133:[2,18],134:[2,18],135:[2,18],136:[2,18],137:[2,18]},{1:[2,19],6:[2,19],25:[2,19],26:[2,19],49:[2,19],54:[2,19],57:[2,19],73:[2,19],78:[2,19],86:[2,19],91:[2,19],93:[2,19],102:[2,19],104:[2,19],105:[2,19],106:[2,19],110:[2,19],118:[2,19],126:[2,19],128:[2,19],129:[2,19],132:[2,19],133:[2,19],134:[2,19],135:[2,19],136:[2,19],137:[2,19]},{1:[2,20],6:[2,20],25:[2,20],26:[2,20],49:[2,20],54:[2,20],57:[2,20],73:[2,20],78:[2,20],86:[2,20],91:[2,20],93:[2,20],102:[2,20],104:[2,20],105:[2,20],106:[2,20],110:[2,20],118:[2,20],126:[2,20],128:[2,20],129:[2,20],132:[2,20],133:[2,20],134:[2,20],135:[2,20],136:[2,20],137:[2,20]},{1:[2,21],6:[2,21],25:[2,21],26:[2,21],49:[2,21],54:[2,21],57:[2,21],73:[2,21],78:[2,21],86:[2,21],91:[2,21],93:[2,21],102:[2,21],104:[2,21],105:[2,21],106:[2,21],110:[2,21],118:[2,21],126:[2,21],128:[2,21],129:[2,21],132:[2,21],133:[2,21],134:[2,21],135:[2,21],136:[2,21],137:[2,21]},{1:[2,22],6:[2,22],25:[2,22],26:[2,22],49:[2,22],54:[2,22],57:[2,22],73:[2,22],78:[2,22],86:[2,22],91:[2,22],93:[2,22],102:[2,22],104:[2,22],105:[2,22],106:[2,22],110:[2,22],118:[2,22],126:[2,22],128:[2,22],129:[2,22],132:[2,22],133:[2,22],134:[2,22],135:[2,22],136:[2,22],137:[2,22]},{1:[2,23],6:[2,23],25:[2,23],26:[2,23],49:[2,23],54:[2,23],57:[2,23],73:[2,23],78:[2,23],86:[2,23],91:[2,23],93:[2,23],102:[2,23],104:[2,23],105:[2,23],106:[2,23],110:[2,23],118:[2,23],126:[2,23],128:[2,23],129:[2,23],132:[2,23],133:[2,23],134:[2,23],135:[2,23],136:[2,23],137:[2,23]},{1:[2,9],6:[2,9],26:[2,9],102:[2,9],104:[2,9],106:[2,9],110:[2,9],126:[2,9]},{1:[2,10],6:[2,10],26:[2,10],102:[2,10],104:[2,10],106:[2,10],110:[2,10],126:[2,10]},{1:[2,11],6:[2,11],26:[2,11],102:[2,11],104:[2,11],106:[2,11],110:[2,11],126:[2,11]},{1:[2,75],6:[2,75],25:[2,75],26:[2,75],40:[1,104],49:[2,75],54:[2,75],57:[2,75],66:[2,75],67:[2,75],68:[2,75],69:[2,75],71:[2,75],73:[2,75],74:[2,75],78:[2,75],84:[2,75],85:[2,75],86:[2,75],91:[2,75],93:[2,75],102:[2,75],104:[2,75],105:[2,75],106:[2,75],110:[2,75],118:[2,75],126:[2,75],128:[2,75],129:[2,75],132:[2,75],133:[2,75],134:[2,75],135:[2,75],136:[2,75],137:[2,75]},{1:[2,76],6:[2,76],25:[2,76],26:[2,76],49:[2,76],54:[2,76],57:[2,76],66:[2,76],67:[2,76],68:[2,76],69:[2,76],71:[2,76],73:[2,76],74:[2,76],78:[2,76],84:[2,76],85:[2,76],86:[2,76],91:[2,76],93:[2,76],102:[2,76],104:[2,76],105:[2,76],106:[2,76],110:[2,76],118:[2,76],126:[2,76],128:[2,76],129:[2,76],132:[2,76],133:[2,76],134:[2,76],135:[2,76],136:[2,76],137:[2,76]},{1:[2,77],6:[2,77],25:[2,77],26:[2,77],49:[2,77],54:[2,77],57:[2,77],66:[2,77],67:[2,77],68:[2,77],69:[2,77],71:[2,77],73:[2,77],74:[2,77],78:[2,77],84:[2,77],85:[2,77],86:[2,77],91:[2,77],93:[2,77],102:[2,77],104:[2,77],105:[2,77],106:[2,77],110:[2,77],118:[2,77],126:[2,77],128:[2,77],129:[2,77],132:[2,77],133:[2,77],134:[2,77],135:[2,77],136:[2,77],137:[2,77]},{1:[2,78],6:[2,78],25:[2,78],26:[2,78],49:[2,78],54:[2,78],57:[2,78],66:[2,78],67:[2,78],68:[2,78],69:[2,78],71:[2,78],73:[2,78],74:[2,78],78:[2,78],84:[2,78],85:[2,78],86:[2,78],91:[2,78],93:[2,78],102:[2,78],104:[2,78],105:[2,78],106:[2,78],110:[2,78],118:[2,78],126:[2,78],128:[2,78],129:[2,78],132:[2,78],133:[2,78],134:[2,78],135:[2,78],136:[2,78],137:[2,78]},{1:[2,79],6:[2,79],25:[2,79],26:[2,79],49:[2,79],54:[2,79],57:[2,79],66:[2,79],67:[2,79],68:[2,79],69:[2,79],71:[2,79],73:[2,79],74:[2,79],78:[2,79],84:[2,79],85:[2,79],86:[2,79],91:[2,79],93:[2,79],102:[2,79],104:[2,79],105:[2,79],106:[2,79],110:[2,79],118:[2,79],126:[2,79],128:[2,79],129:[2,79],132:[2,79],133:[2,79],134:[2,79],135:[2,79],136:[2,79],137:[2,79]},{1:[2,106],6:[2,106],25:[2,106],26:[2,106],49:[2,106],54:[2,106],57:[2,106],66:[2,106],67:[2,106],68:[2,106],69:[2,106],71:[2,106],73:[2,106],74:[2,106],78:[2,106],82:105,84:[2,106],85:[1,106],86:[2,106],91:[2,106],93:[2,106],102:[2,106],104:[2,106],105:[2,106],106:[2,106],110:[2,106],118:[2,106],126:[2,106],128:[2,106],129:[2,106],132:[2,106],133:[2,106],134:[2,106],135:[2,106],136:[2,106],137:[2,106]},{6:[2,55],25:[2,55],27:110,28:[1,73],44:111,48:107,49:[2,55],54:[2,55],55:108,56:109,58:112,59:113,76:[1,70],89:[1,114],90:[1,115]},{5:116,25:[1,5]},{8:117,9:118,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,76:[1,70],79:[1,43],83:[1,28],88:[1,58],89:[1,59],90:[1,57],96:[1,38],100:[1,44],101:[1,56],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{8:119,9:118,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,76:[1,70],79:[1,43],83:[1,28],88:[1,58],89:[1,59],90:[1,57],96:[1,38],100:[1,44],101:[1,56],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{8:120,9:118,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,76:[1,70],79:[1,43],83:[1,28],88:[1,58],89:[1,59],90:[1,57],96:[1,38],100:[1,44],101:[1,56],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{13:122,14:123,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:124,44:63,58:47,59:48,61:121,63:25,64:26,65:27,76:[1,70],83:[1,28],88:[1,58],89:[1,59],90:[1,57],101:[1,56]},{13:122,14:123,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:124,44:63,58:47,59:48,61:125,63:25,64:26,65:27,76:[1,70],83:[1,28],88:[1,58],89:[1,59],90:[1,57],101:[1,56]},{1:[2,72],6:[2,72],25:[2,72],26:[2,72],40:[2,72],49:[2,72],54:[2,72],57:[2,72],66:[2,72],67:[2,72],68:[2,72],69:[2,72],71:[2,72],73:[2,72],74:[2,72],78:[2,72],80:[1,129],84:[2,72],85:[2,72],86:[2,72],91:[2,72],93:[2,72],102:[2,72],104:[2,72],105:[2,72],106:[2,72],110:[2,72],118:[2,72],126:[2,72],128:[2,72],129:[2,72],130:[1,126],131:[1,127],132:[2,72],133:[2,72],134:[2,72],135:[2,72],136:[2,72],137:[2,72],138:[1,128]},{1:[2,183],6:[2,183],25:[2,183],26:[2,183],49:[2,183],54:[2,183],57:[2,183],73:[2,183],78:[2,183],86:[2,183],91:[2,183],93:[2,183],102:[2,183],104:[2,183],105:[2,183],106:[2,183],110:[2,183],118:[2,183],121:[1,130],126:[2,183],128:[2,183],129:[2,183],132:[2,183],133:[2,183],134:[2,183],135:[2,183],136:[2,183],137:[2,183]},{5:131,25:[1,5]},{5:132,25:[1,5]},{1:[2,150],6:[2,150],25:[2,150],26:[2,150],49:[2,150],54:[2,150],57:[2,150],73:[2,150],78:[2,150],86:[2,150],91:[2,150],93:[2,150],102:[2,150],104:[2,150],105:[2,150],106:[2,150],110:[2,150],118:[2,150],126:[2,150],128:[2,150],129:[2,150],132:[2,150],133:[2,150],134:[2,150],135:[2,150],136:[2,150],137:[2,150]},{5:133,25:[1,5]},{8:134,9:118,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,25:[1,135],27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,76:[1,70],79:[1,43],83:[1,28],88:[1,58],89:[1,59],90:[1,57],96:[1,38],100:[1,44],101:[1,56],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{1:[2,96],5:136,6:[2,96],13:122,14:123,25:[1,5],26:[2,96],27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:124,44:63,49:[2,96],54:[2,96],57:[2,96],58:47,59:48,61:138,63:25,64:26,65:27,73:[2,96],76:[1,70],78:[2,96],80:[1,137],83:[1,28],86:[2,96],88:[1,58],89:[1,59],90:[1,57],91:[2,96],93:[2,96],101:[1,56],102:[2,96],104:[2,96],105:[2,96],106:[2,96],110:[2,96],118:[2,96],126:[2,96],128:[2,96],129:[2,96],132:[2,96],133:[2,96],134:[2,96],135:[2,96],136:[2,96],137:[2,96]},{8:139,9:118,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,76:[1,70],79:[1,43],83:[1,28],88:[1,58],89:[1,59],90:[1,57],96:[1,38],100:[1,44],101:[1,56],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{1:[2,47],6:[2,47],8:140,9:118,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,26:[2,47],27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,76:[1,70],79:[1,43],83:[1,28],88:[1,58],89:[1,59],90:[1,57],96:[1,38],100:[1,44],101:[1,56],102:[2,47],103:39,104:[2,47],106:[2,47],107:40,108:[1,67],109:41,110:[2,47],111:69,119:[1,42],124:37,125:[1,64],126:[2,47],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{1:[2,48],6:[2,48],25:[2,48],26:[2,48],54:[2,48],78:[2,48],102:[2,48],104:[2,48],106:[2,48],110:[2,48],126:[2,48]},{1:[2,73],6:[2,73],25:[2,73],26:[2,73],40:[2,73],49:[2,73],54:[2,73],57:[2,73],66:[2,73],67:[2,73],68:[2,73],69:[2,73],71:[2,73],73:[2,73],74:[2,73],78:[2,73],84:[2,73],85:[2,73],86:[2,73],91:[2,73],93:[2,73],102:[2,73],104:[2,73],105:[2,73],106:[2,73],110:[2,73],118:[2,73],126:[2,73],128:[2,73],129:[2,73],132:[2,73],133:[2,73],134:[2,73],135:[2,73],136:[2,73],137:[2,73]},{1:[2,74],6:[2,74],25:[2,74],26:[2,74],40:[2,74],49:[2,74],54:[2,74],57:[2,74],66:[2,74],67:[2,74],68:[2,74],69:[2,74],71:[2,74],73:[2,74],74:[2,74],78:[2,74],84:[2,74],85:[2,74],86:[2,74],91:[2,74],93:[2,74],102:[2,74],104:[2,74],105:[2,74],106:[2,74],110:[2,74],118:[2,74],126:[2,74],128:[2,74],129:[2,74],132:[2,74],133:[2,74],134:[2,74],135:[2,74],136:[2,74],137:[2,74]},{1:[2,29],6:[2,29],25:[2,29],26:[2,29],49:[2,29],54:[2,29],57:[2,29],66:[2,29],67:[2,29],68:[2,29],69:[2,29],71:[2,29],73:[2,29],74:[2,29],78:[2,29],84:[2,29],85:[2,29],86:[2,29],91:[2,29],93:[2,29],102:[2,29],104:[2,29],105:[2,29],106:[2,29],110:[2,29],118:[2,29],126:[2,29],128:[2,29],129:[2,29],132:[2,29],133:[2,29],134:[2,29],135:[2,29],136:[2,29],137:[2,29]},{1:[2,30],6:[2,30],25:[2,30],26:[2,30],49:[2,30],54:[2,30],57:[2,30],66:[2,30],67:[2,30],68:[2,30],69:[2,30],71:[2,30],73:[2,30],74:[2,30],78:[2,30],84:[2,30],85:[2,30],86:[2,30],91:[2,30],93:[2,30],102:[2,30],104:[2,30],105:[2,30],106:[2,30],110:[2,30],118:[2,30],126:[2,30],128:[2,30],129:[2,30],132:[2,30],133:[2,30],134:[2,30],135:[2,30],136:[2,30],137:[2,30]},{1:[2,31],6:[2,31],25:[2,31],26:[2,31],49:[2,31],54:[2,31],57:[2,31],66:[2,31],67:[2,31],68:[2,31],69:[2,31],71:[2,31],73:[2,31],74:[2,31],78:[2,31],84:[2,31],85:[2,31],86:[2,31],91:[2,31],93:[2,31],102:[2,31],104:[2,31],105:[2,31],106:[2,31],110:[2,31],118:[2,31],126:[2,31],128:[2,31],129:[2,31],132:[2,31],133:[2,31],134:[2,31],135:[2,31],136:[2,31],137:[2,31]},{1:[2,32],6:[2,32],25:[2,32],26:[2,32],49:[2,32],54:[2,32],57:[2,32],66:[2,32],67:[2,32],68:[2,32],69:[2,32],71:[2,32],73:[2,32],74:[2,32],78:[2,32],84:[2,32],85:[2,32],86:[2,32],91:[2,32],93:[2,32],102:[2,32],104:[2,32],105:[2,32],106:[2,32],110:[2,32],118:[2,32],126:[2,32],128:[2,32],129:[2,32],132:[2,32],133:[2,32],134:[2,32],135:[2,32],136:[2,32],137:[2,32]},{1:[2,33],6:[2,33],25:[2,33],26:[2,33],49:[2,33],54:[2,33],57:[2,33],66:[2,33],67:[2,33],68:[2,33],69:[2,33],71:[2,33],73:[2,33],74:[2,33],78:[2,33],84:[2,33],85:[2,33],86:[2,33],91:[2,33],93:[2,33],102:[2,33],104:[2,33],105:[2,33],106:[2,33],110:[2,33],118:[2,33],126:[2,33],128:[2,33],129:[2,33],132:[2,33],133:[2,33],134:[2,33],135:[2,33],136:[2,33],137:[2,33]},{1:[2,34],6:[2,34],25:[2,34],26:[2,34],49:[2,34],54:[2,34],57:[2,34],66:[2,34],67:[2,34],68:[2,34],69:[2,34],71:[2,34],73:[2,34],74:[2,34],78:[2,34],84:[2,34],85:[2,34],86:[2,34],91:[2,34],93:[2,34],102:[2,34],104:[2,34],105:[2,34],106:[2,34],110:[2,34],118:[2,34],126:[2,34],128:[2,34],129:[2,34],132:[2,34],133:[2,34],134:[2,34],135:[2,34],136:[2,34],137:[2,34]},{1:[2,35],6:[2,35],25:[2,35],26:[2,35],49:[2,35],54:[2,35],57:[2,35],66:[2,35],67:[2,35],68:[2,35],69:[2,35],71:[2,35],73:[2,35],74:[2,35],78:[2,35],84:[2,35],85:[2,35],86:[2,35],91:[2,35],93:[2,35],102:[2,35],104:[2,35],105:[2,35],106:[2,35],110:[2,35],118:[2,35],126:[2,35],128:[2,35],129:[2,35],132:[2,35],133:[2,35],134:[2,35],135:[2,35],136:[2,35],137:[2,35]},{4:141,7:4,8:6,9:7,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,25:[1,142],27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,76:[1,70],79:[1,43],83:[1,28],88:[1,58],89:[1,59],90:[1,57],96:[1,38],100:[1,44],101:[1,56],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{8:143,9:118,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,25:[1,147],27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,60:148,61:36,63:25,64:26,65:27,76:[1,70],79:[1,43],83:[1,28],87:145,88:[1,58],89:[1,59],90:[1,57],91:[1,144],94:146,96:[1,38],100:[1,44],101:[1,56],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{1:[2,112],6:[2,112],25:[2,112],26:[2,112],49:[2,112],54:[2,112],57:[2,112],66:[2,112],67:[2,112],68:[2,112],69:[2,112],71:[2,112],73:[2,112],74:[2,112],78:[2,112],84:[2,112],85:[2,112],86:[2,112],91:[2,112],93:[2,112],102:[2,112],104:[2,112],105:[2,112],106:[2,112],110:[2,112],118:[2,112],126:[2,112],128:[2,112],129:[2,112],132:[2,112],133:[2,112],134:[2,112],135:[2,112],136:[2,112],137:[2,112]},{1:[2,113],6:[2,113],25:[2,113],26:[2,113],27:149,28:[1,73],49:[2,113],54:[2,113],57:[2,113],66:[2,113],67:[2,113],68:[2,113],69:[2,113],71:[2,113],73:[2,113],74:[2,113],78:[2,113],84:[2,113],85:[2,113],86:[2,113],91:[2,113],93:[2,113],102:[2,113],104:[2,113],105:[2,113],106:[2,113],110:[2,113],118:[2,113],126:[2,113],128:[2,113],129:[2,113],132:[2,113],133:[2,113],134:[2,113],135:[2,113],136:[2,113],137:[2,113]},{25:[2,51]},{25:[2,52]},{1:[2,68],6:[2,68],25:[2,68],26:[2,68],40:[2,68],49:[2,68],54:[2,68],57:[2,68],66:[2,68],67:[2,68],68:[2,68],69:[2,68],71:[2,68],73:[2,68],74:[2,68],78:[2,68],80:[2,68],84:[2,68],85:[2,68],86:[2,68],91:[2,68],93:[2,68],102:[2,68],104:[2,68],105:[2,68],106:[2,68],110:[2,68],118:[2,68],126:[2,68],128:[2,68],129:[2,68],130:[2,68],131:[2,68],132:[2,68],133:[2,68],134:[2,68],135:[2,68],136:[2,68],137:[2,68],138:[2,68]},{1:[2,71],6:[2,71],25:[2,71],26:[2,71],40:[2,71],49:[2,71],54:[2,71],57:[2,71],66:[2,71],67:[2,71],68:[2,71],69:[2,71],71:[2,71],73:[2,71],74:[2,71],78:[2,71],80:[2,71],84:[2,71],85:[2,71],86:[2,71],91:[2,71],93:[2,71],102:[2,71],104:[2,71],105:[2,71],106:[2,71],110:[2,71],118:[2,71],126:[2,71],128:[2,71],129:[2,71],130:[2,71],131:[2,71],132:[2,71],133:[2,71],134:[2,71],135:[2,71],136:[2,71],137:[2,71],138:[2,71]},{8:150,9:118,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,76:[1,70],79:[1,43],83:[1,28],88:[1,58],89:[1,59],90:[1,57],96:[1,38],100:[1,44],101:[1,56],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{8:151,9:118,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,76:[1,70],79:[1,43],83:[1,28],88:[1,58],89:[1,59],90:[1,57],96:[1,38],100:[1,44],101:[1,56],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{8:152,9:118,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,76:[1,70],79:[1,43],83:[1,28],88:[1,58],89:[1,59],90:[1,57],96:[1,38],100:[1,44],101:[1,56],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{5:153,8:154,9:118,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,25:[1,5],27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,76:[1,70],79:[1,43],83:[1,28],88:[1,58],89:[1,59],90:[1,57],96:[1,38],100:[1,44],101:[1,56],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{27:159,28:[1,73],44:160,58:161,59:162,64:155,76:[1,70],89:[1,114],90:[1,57],113:156,114:[1,157],115:158},{112:163,116:[1,164],117:[1,165]},{6:[2,91],11:169,25:[2,91],27:170,28:[1,73],29:171,30:[1,71],31:[1,72],41:167,42:168,44:172,46:[1,46],54:[2,91],77:166,78:[2,91],89:[1,114]},{1:[2,27],6:[2,27],25:[2,27],26:[2,27],43:[2,27],49:[2,27],54:[2,27],57:[2,27],66:[2,27],67:[2,27],68:[2,27],69:[2,27],71:[2,27],73:[2,27],74:[2,27],78:[2,27],84:[2,27],85:[2,27],86:[2,27],91:[2,27],93:[2,27],102:[2,27],104:[2,27],105:[2,27],106:[2,27],110:[2,27],118:[2,27],126:[2,27],128:[2,27],129:[2,27],132:[2,27],133:[2,27],134:[2,27],135:[2,27],136:[2,27],137:[2,27]},{1:[2,28],6:[2,28],25:[2,28],26:[2,28],43:[2,28],49:[2,28],54:[2,28],57:[2,28],66:[2,28],67:[2,28],68:[2,28],69:[2,28],71:[2,28],73:[2,28],74:[2,28],78:[2,28],84:[2,28],85:[2,28],86:[2,28],91:[2,28],93:[2,28],102:[2,28],104:[2,28],105:[2,28],106:[2,28],110:[2,28],118:[2,28],126:[2,28],128:[2,28],129:[2,28],132:[2,28],133:[2,28],134:[2,28],135:[2,28],136:[2,28],137:[2,28]},{1:[2,26],6:[2,26],25:[2,26],26:[2,26],40:[2,26],43:[2,26],49:[2,26],54:[2,26],57:[2,26],66:[2,26],67:[2,26],68:[2,26],69:[2,26],71:[2,26],73:[2,26],74:[2,26],78:[2,26],80:[2,26],84:[2,26],85:[2,26],86:[2,26],91:[2,26],93:[2,26],102:[2,26],104:[2,26],105:[2,26],106:[2,26],110:[2,26],116:[2,26],117:[2,26],118:[2,26],126:[2,26],128:[2,26],129:[2,26],130:[2,26],131:[2,26],132:[2,26],133:[2,26],134:[2,26],135:[2,26],136:[2,26],137:[2,26],138:[2,26]},{1:[2,6],6:[2,6],7:173,8:6,9:7,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,26:[2,6],27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,76:[1,70],79:[1,43],83:[1,28],88:[1,58],89:[1,59],90:[1,57],96:[1,38],100:[1,44],101:[1,56],102:[2,6],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{1:[2,3]},{1:[2,24],6:[2,24],25:[2,24],26:[2,24],49:[2,24],54:[2,24],57:[2,24],73:[2,24],78:[2,24],86:[2,24],91:[2,24],93:[2,24],98:[2,24],99:[2,24],102:[2,24],104:[2,24],105:[2,24],106:[2,24],110:[2,24],118:[2,24],121:[2,24],123:[2,24],126:[2,24],128:[2,24],129:[2,24],132:[2,24],133:[2,24],134:[2,24],135:[2,24],136:[2,24],137:[2,24]},{6:[1,74],26:[1,174]},{1:[2,194],6:[2,194],25:[2,194],26:[2,194],49:[2,194],54:[2,194],57:[2,194],73:[2,194],78:[2,194],86:[2,194],91:[2,194],93:[2,194],102:[2,194],104:[2,194],105:[2,194],106:[2,194],110:[2,194],118:[2,194],126:[2,194],128:[2,194],129:[2,194],132:[2,194],133:[2,194],134:[2,194],135:[2,194],136:[2,194],137:[2,194]},{8:175,9:118,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,76:[1,70],79:[1,43],83:[1,28],88:[1,58],89:[1,59],90:[1,57],96:[1,38],100:[1,44],101:[1,56],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{8:176,9:118,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,76:[1,70],79:[1,43],83:[1,28],88:[1,58],89:[1,59],90:[1,57],96:[1,38],100:[1,44],101:[1,56],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{8:177,9:118,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,76:[1,70],79:[1,43],83:[1,28],88:[1,58],89:[1,59],90:[1,57],96:[1,38],100:[1,44],101:[1,56],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{8:178,9:118,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,76:[1,70],79:[1,43],83:[1,28],88:[1,58],89:[1,59],90:[1,57],96:[1,38],100:[1,44],101:[1,56],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{8:179,9:118,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,76:[1,70],79:[1,43],83:[1,28],88:[1,58],89:[1,59],90:[1,57],96:[1,38],100:[1,44],101:[1,56],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{8:180,9:118,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,76:[1,70],79:[1,43],83:[1,28],88:[1,58],89:[1,59],90:[1,57],96:[1,38],100:[1,44],101:[1,56],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{8:181,9:118,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,76:[1,70],79:[1,43],83:[1,28],88:[1,58],89:[1,59],90:[1,57],96:[1,38],100:[1,44],101:[1,56],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{8:182,9:118,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,76:[1,70],79:[1,43],83:[1,28],88:[1,58],89:[1,59],90:[1,57],96:[1,38],100:[1,44],101:[1,56],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{1:[2,149],6:[2,149],25:[2,149],26:[2,149],49:[2,149],54:[2,149],57:[2,149],73:[2,149],78:[2,149],86:[2,149],91:[2,149],93:[2,149],102:[2,149],104:[2,149],105:[2,149],106:[2,149],110:[2,149],118:[2,149],126:[2,149],128:[2,149],129:[2,149],132:[2,149],133:[2,149],134:[2,149],135:[2,149],136:[2,149],137:[2,149]},{1:[2,154],6:[2,154],25:[2,154],26:[2,154],49:[2,154],54:[2,154],57:[2,154],73:[2,154],78:[2,154],86:[2,154],91:[2,154],93:[2,154],102:[2,154],104:[2,154],105:[2,154],106:[2,154],110:[2,154],118:[2,154],126:[2,154],128:[2,154],129:[2,154],132:[2,154],133:[2,154],134:[2,154],135:[2,154],136:[2,154],137:[2,154]},{8:183,9:118,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,76:[1,70],79:[1,43],83:[1,28],88:[1,58],89:[1,59],90:[1,57],96:[1,38],100:[1,44],101:[1,56],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{1:[2,148],6:[2,148],25:[2,148],26:[2,148],49:[2,148],54:[2,148],57:[2,148],73:[2,148],78:[2,148],86:[2,148],91:[2,148],93:[2,148],102:[2,148],104:[2,148],105:[2,148],106:[2,148],110:[2,148],118:[2,148],126:[2,148],128:[2,148],129:[2,148],132:[2,148],133:[2,148],134:[2,148],135:[2,148],136:[2,148],137:[2,148]},{1:[2,153],6:[2,153],25:[2,153],26:[2,153],49:[2,153],54:[2,153],57:[2,153],73:[2,153],78:[2,153],86:[2,153],91:[2,153],93:[2,153],102:[2,153],104:[2,153],105:[2,153],106:[2,153],110:[2,153],118:[2,153],126:[2,153],128:[2,153],129:[2,153],132:[2,153],133:[2,153],134:[2,153],135:[2,153],136:[2,153],137:[2,153]},{82:184,85:[1,106]},{1:[2,69],6:[2,69],25:[2,69],26:[2,69],40:[2,69],49:[2,69],54:[2,69],57:[2,69],66:[2,69],67:[2,69],68:[2,69],69:[2,69],71:[2,69],73:[2,69],74:[2,69],78:[2,69],80:[2,69],84:[2,69],85:[2,69],86:[2,69],91:[2,69],93:[2,69],102:[2,69],104:[2,69],105:[2,69],106:[2,69],110:[2,69],118:[2,69],126:[2,69],128:[2,69],129:[2,69],130:[2,69],131:[2,69],132:[2,69],133:[2,69],134:[2,69],135:[2,69],136:[2,69],137:[2,69],138:[2,69]},{85:[2,109]},{27:185,28:[1,73]},{27:186,28:[1,73]},{1:[2,84],6:[2,84],25:[2,84],26:[2,84],27:187,28:[1,73],40:[2,84],49:[2,84],54:[2,84],57:[2,84],66:[2,84],67:[2,84],68:[2,84],69:[2,84],71:[2,84],73:[2,84],74:[2,84],78:[2,84],80:[2,84],84:[2,84],85:[2,84],86:[2,84],91:[2,84],93:[2,84],102:[2,84],104:[2,84],105:[2,84],106:[2,84],110:[2,84],118:[2,84],126:[2,84],128:[2,84],129:[2,84],130:[2,84],131:[2,84],132:[2,84],133:[2,84],134:[2,84],135:[2,84],136:[2,84],137:[2,84],138:[2,84]},{27:188,28:[1,73]},{1:[2,85],6:[2,85],25:[2,85],26:[2,85],40:[2,85],49:[2,85],54:[2,85],57:[2,85],66:[2,85],67:[2,85],68:[2,85],69:[2,85],71:[2,85],73:[2,85],74:[2,85],78:[2,85],80:[2,85],84:[2,85],85:[2,85],86:[2,85],91:[2,85],93:[2,85],102:[2,85],104:[2,85],105:[2,85],106:[2,85],110:[2,85],118:[2,85],126:[2,85],128:[2,85],129:[2,85],130:[2,85],131:[2,85],132:[2,85],133:[2,85],134:[2,85],135:[2,85],136:[2,85],137:[2,85],138:[2,85]},{8:190,9:118,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],57:[1,194],58:47,59:48,61:36,63:25,64:26,65:27,72:189,75:191,76:[1,70],79:[1,43],83:[1,28],88:[1,58],89:[1,59],90:[1,57],92:192,93:[1,193],96:[1,38],100:[1,44],101:[1,56],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{70:195,71:[1,100],74:[1,101]},{82:196,85:[1,106]},{1:[2,70],6:[2,70],25:[2,70],26:[2,70],40:[2,70],49:[2,70],54:[2,70],57:[2,70],66:[2,70],67:[2,70],68:[2,70],69:[2,70],71:[2,70],73:[2,70],74:[2,70],78:[2,70],80:[2,70],84:[2,70],85:[2,70],86:[2,70],91:[2,70],93:[2,70],102:[2,70],104:[2,70],105:[2,70],106:[2,70],110:[2,70],118:[2,70],126:[2,70],128:[2,70],129:[2,70],130:[2,70],131:[2,70],132:[2,70],133:[2,70],134:[2,70],135:[2,70],136:[2,70],137:[2,70],138:[2,70]},{6:[1,198],8:197,9:118,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,25:[1,199],27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,76:[1,70],79:[1,43],83:[1,28],88:[1,58],89:[1,59],90:[1,57],96:[1,38],100:[1,44],101:[1,56],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{1:[2,107],6:[2,107],25:[2,107],26:[2,107],49:[2,107],54:[2,107],57:[2,107],66:[2,107],67:[2,107],68:[2,107],69:[2,107],71:[2,107],73:[2,107],74:[2,107],78:[2,107],84:[2,107],85:[2,107],86:[2,107],91:[2,107],93:[2,107],102:[2,107],104:[2,107],105:[2,107],106:[2,107],110:[2,107],118:[2,107],126:[2,107],128:[2,107],129:[2,107],132:[2,107],133:[2,107],134:[2,107],135:[2,107],136:[2,107],137:[2,107]},{8:202,9:118,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,25:[1,147],27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,60:148,61:36,63:25,64:26,65:27,76:[1,70],79:[1,43],83:[1,28],86:[1,200],87:201,88:[1,58],89:[1,59],90:[1,57],94:146,96:[1,38],100:[1,44],101:[1,56],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{6:[2,53],25:[2,53],49:[1,203],53:205,54:[1,204]},{6:[2,56],25:[2,56],26:[2,56],49:[2,56],54:[2,56]},{6:[2,60],25:[2,60],26:[2,60],40:[1,207],49:[2,60],54:[2,60],57:[1,206]},{6:[2,63],25:[2,63],26:[2,63],40:[2,63],49:[2,63],54:[2,63],57:[2,63]},{6:[2,64],25:[2,64],26:[2,64],40:[2,64],49:[2,64],54:[2,64],57:[2,64]},{6:[2,65],25:[2,65],26:[2,65],40:[2,65],49:[2,65],54:[2,65],57:[2,65]},{6:[2,66],25:[2,66],26:[2,66],40:[2,66],49:[2,66],54:[2,66],57:[2,66]},{27:149,28:[1,73]},{8:202,9:118,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,25:[1,147],27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,60:148,61:36,63:25,64:26,65:27,76:[1,70],79:[1,43],83:[1,28],87:145,88:[1,58],89:[1,59],90:[1,57],91:[1,144],94:146,96:[1,38],100:[1,44],101:[1,56],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{1:[2,50],6:[2,50],25:[2,50],26:[2,50],49:[2,50],54:[2,50],57:[2,50],73:[2,50],78:[2,50],86:[2,50],91:[2,50],93:[2,50],102:[2,50],104:[2,50],105:[2,50],106:[2,50],110:[2,50],118:[2,50],126:[2,50],128:[2,50],129:[2,50],132:[2,50],133:[2,50],134:[2,50],135:[2,50],136:[2,50],137:[2,50]},{1:[2,187],6:[2,187],25:[2,187],26:[2,187],49:[2,187],54:[2,187],57:[2,187],73:[2,187],78:[2,187],86:[2,187],91:[2,187],93:[2,187],102:[2,187],103:87,104:[2,187],105:[2,187],106:[2,187],109:88,110:[2,187],111:69,118:[2,187],126:[2,187],128:[2,187],129:[2,187],132:[1,78],133:[2,187],134:[2,187],135:[2,187],136:[2,187],137:[2,187]},{103:90,104:[1,65],106:[1,66],109:91,110:[1,68],111:69,126:[1,89]},{1:[2,188],6:[2,188],25:[2,188],26:[2,188],49:[2,188],54:[2,188],57:[2,188],73:[2,188],78:[2,188],86:[2,188],91:[2,188],93:[2,188],102:[2,188],103:87,104:[2,188],105:[2,188],106:[2,188],109:88,110:[2,188],111:69,118:[2,188],126:[2,188],128:[2,188],129:[2,188],132:[1,78],133:[2,188],134:[2,188],135:[2,188],136:[2,188],137:[2,188]},{1:[2,189],6:[2,189],25:[2,189],26:[2,189],49:[2,189],54:[2,189],57:[2,189],73:[2,189],78:[2,189],86:[2,189],91:[2,189],93:[2,189],102:[2,189],103:87,104:[2,189],105:[2,189],106:[2,189],109:88,110:[2,189],111:69,118:[2,189],126:[2,189],128:[2,189],129:[2,189],132:[1,78],133:[2,189],134:[2,189],135:[2,189],136:[2,189],137:[2,189]},{1:[2,190],6:[2,190],25:[2,190],26:[2,190],49:[2,190],54:[2,190],57:[2,190],66:[2,72],67:[2,72],68:[2,72],69:[2,72],71:[2,72],73:[2,190],74:[2,72],78:[2,190],84:[2,72],85:[2,72],86:[2,190],91:[2,190],93:[2,190],102:[2,190],104:[2,190],105:[2,190],106:[2,190],110:[2,190],118:[2,190],126:[2,190],128:[2,190],129:[2,190],132:[2,190],133:[2,190],134:[2,190],135:[2,190],136:[2,190],137:[2,190]},{62:93,66:[1,95],67:[1,96],68:[1,97],69:[1,98],70:99,71:[1,100],74:[1,101],81:92,84:[1,94],85:[2,108]},{62:103,66:[1,95],67:[1,96],68:[1,97],69:[1,98],70:99,71:[1,100],74:[1,101],81:102,84:[1,94],85:[2,108]},{66:[2,75],67:[2,75],68:[2,75],69:[2,75],71:[2,75],74:[2,75],84:[2,75],85:[2,75]},{1:[2,191],6:[2,191],25:[2,191],26:[2,191],49:[2,191],54:[2,191],57:[2,191],66:[2,72],67:[2,72],68:[2,72],69:[2,72],71:[2,72],73:[2,191],74:[2,72],78:[2,191],84:[2,72],85:[2,72],86:[2,191],91:[2,191],93:[2,191],102:[2,191],104:[2,191],105:[2,191],106:[2,191],110:[2,191],118:[2,191],126:[2,191],128:[2,191],129:[2,191],132:[2,191],133:[2,191],134:[2,191],135:[2,191],136:[2,191],137:[2,191]},{1:[2,192],6:[2,192],25:[2,192],26:[2,192],49:[2,192],54:[2,192],57:[2,192],73:[2,192],78:[2,192],86:[2,192],91:[2,192],93:[2,192],102:[2,192],104:[2,192],105:[2,192],106:[2,192],110:[2,192],118:[2,192],126:[2,192],128:[2,192],129:[2,192],132:[2,192],133:[2,192],134:[2,192],135:[2,192],136:[2,192],137:[2,192]},{1:[2,193],6:[2,193],25:[2,193],26:[2,193],49:[2,193],54:[2,193],57:[2,193],73:[2,193],78:[2,193],86:[2,193],91:[2,193],93:[2,193],102:[2,193],104:[2,193],105:[2,193],106:[2,193],110:[2,193],118:[2,193],126:[2,193],128:[2,193],129:[2,193],132:[2,193],133:[2,193],134:[2,193],135:[2,193],136:[2,193],137:[2,193]},{6:[1,210],8:208,9:118,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,25:[1,209],27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,76:[1,70],79:[1,43],83:[1,28],88:[1,58],89:[1,59],90:[1,57],96:[1,38],100:[1,44],101:[1,56],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{8:211,9:118,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,76:[1,70],79:[1,43],83:[1,28],88:[1,58],89:[1,59],90:[1,57],96:[1,38],100:[1,44],101:[1,56],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{5:212,25:[1,5],125:[1,213]},{1:[2,133],6:[2,133],25:[2,133],26:[2,133],49:[2,133],54:[2,133],57:[2,133],73:[2,133],78:[2,133],86:[2,133],91:[2,133],93:[2,133],97:214,98:[1,215],99:[1,216],102:[2,133],104:[2,133],105:[2,133],106:[2,133],110:[2,133],118:[2,133],126:[2,133],128:[2,133],129:[2,133],132:[2,133],133:[2,133],134:[2,133],135:[2,133],136:[2,133],137:[2,133]},{1:[2,147],6:[2,147],25:[2,147],26:[2,147],49:[2,147],54:[2,147],57:[2,147],73:[2,147],78:[2,147],86:[2,147],91:[2,147],93:[2,147],102:[2,147],104:[2,147],105:[2,147],106:[2,147],110:[2,147],118:[2,147],126:[2,147],128:[2,147],129:[2,147],132:[2,147],133:[2,147],134:[2,147],135:[2,147],136:[2,147],137:[2,147]},{1:[2,155],6:[2,155],25:[2,155],26:[2,155],49:[2,155],54:[2,155],57:[2,155],73:[2,155],78:[2,155],86:[2,155],91:[2,155],93:[2,155],102:[2,155],104:[2,155],105:[2,155],106:[2,155],110:[2,155],118:[2,155],126:[2,155],128:[2,155],129:[2,155],132:[2,155],133:[2,155],134:[2,155],135:[2,155],136:[2,155],137:[2,155]},{25:[1,217],103:87,104:[1,65],106:[1,66],109:88,110:[1,68],111:69,126:[1,86],128:[1,80],129:[1,79],132:[1,78],133:[1,81],134:[1,82],135:[1,83],136:[1,84],137:[1,85]},{120:218,122:219,123:[1,220]},{1:[2,97],6:[2,97],25:[2,97],26:[2,97],49:[2,97],54:[2,97],57:[2,97],73:[2,97],78:[2,97],86:[2,97],91:[2,97],93:[2,97],102:[2,97],104:[2,97],105:[2,97],106:[2,97],110:[2,97],118:[2,97],126:[2,97],128:[2,97],129:[2,97],132:[2,97],133:[2,97],134:[2,97],135:[2,97],136:[2,97],137:[2,97]},{8:221,9:118,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,76:[1,70],79:[1,43],83:[1,28],88:[1,58],89:[1,59],90:[1,57],96:[1,38],100:[1,44],101:[1,56],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{1:[2,100],5:222,6:[2,100],25:[1,5],26:[2,100],49:[2,100],54:[2,100],57:[2,100],66:[2,72],67:[2,72],68:[2,72],69:[2,72],71:[2,72],73:[2,100],74:[2,72],78:[2,100],80:[1,223],84:[2,72],85:[2,72],86:[2,100],91:[2,100],93:[2,100],102:[2,100],104:[2,100],105:[2,100],106:[2,100],110:[2,100],118:[2,100],126:[2,100],128:[2,100],129:[2,100],132:[2,100],133:[2,100],134:[2,100],135:[2,100],136:[2,100],137:[2,100]},{1:[2,140],6:[2,140],25:[2,140],26:[2,140],49:[2,140],54:[2,140],57:[2,140],73:[2,140],78:[2,140],86:[2,140],91:[2,140],93:[2,140],102:[2,140],103:87,104:[2,140],105:[2,140],106:[2,140],109:88,110:[2,140],111:69,118:[2,140],126:[2,140],128:[1,80],129:[1,79],132:[1,78],133:[1,81],134:[1,82],135:[1,83],136:[1,84],137:[1,85]},{1:[2,46],6:[2,46],26:[2,46],102:[2,46],103:87,104:[2,46],106:[2,46],109:88,110:[2,46],111:69,126:[2,46],128:[1,80],129:[1,79],132:[1,78],133:[1,81],134:[1,82],135:[1,83],136:[1,84],137:[1,85]},{6:[1,74],102:[1,224]},{4:225,7:4,8:6,9:7,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,76:[1,70],79:[1,43],83:[1,28],88:[1,58],89:[1,59],90:[1,57],96:[1,38],100:[1,44],101:[1,56],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{6:[2,129],25:[2,129],54:[2,129],57:[1,227],91:[2,129],92:226,93:[1,193],103:87,104:[1,65],106:[1,66],109:88,110:[1,68],111:69,126:[1,86],128:[1,80],129:[1,79],132:[1,78],133:[1,81],134:[1,82],135:[1,83],136:[1,84],137:[1,85]},{1:[2,115],6:[2,115],25:[2,115],26:[2,115],40:[2,115],49:[2,115],54:[2,115],57:[2,115],66:[2,115],67:[2,115],68:[2,115],69:[2,115],71:[2,115],73:[2,115],74:[2,115],78:[2,115],84:[2,115],85:[2,115],86:[2,115],91:[2,115],93:[2,115],102:[2,115],104:[2,115],105:[2,115],106:[2,115],110:[2,115],116:[2,115],117:[2,115],118:[2,115],126:[2,115],128:[2,115],129:[2,115],132:[2,115],133:[2,115],134:[2,115],135:[2,115],136:[2,115],137:[2,115]},{6:[2,53],25:[2,53],53:228,54:[1,229],91:[2,53]},{6:[2,124],25:[2,124],26:[2,124],54:[2,124],86:[2,124],91:[2,124]},{8:202,9:118,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,25:[1,147],27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,60:148,61:36,63:25,64:26,65:27,76:[1,70],79:[1,43],83:[1,28],87:230,88:[1,58],89:[1,59],90:[1,57],94:146,96:[1,38],100:[1,44],101:[1,56],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{6:[2,130],25:[2,130],26:[2,130],54:[2,130],86:[2,130],91:[2,130]},{1:[2,114],6:[2,114],25:[2,114],26:[2,114],40:[2,114],43:[2,114],49:[2,114],54:[2,114],57:[2,114],66:[2,114],67:[2,114],68:[2,114],69:[2,114],71:[2,114],73:[2,114],74:[2,114],78:[2,114],80:[2,114],84:[2,114],85:[2,114],86:[2,114],91:[2,114],93:[2,114],102:[2,114],104:[2,114],105:[2,114],106:[2,114],110:[2,114],116:[2,114],117:[2,114],118:[2,114],126:[2,114],128:[2,114],129:[2,114],130:[2,114],131:[2,114],132:[2,114],133:[2,114],134:[2,114],135:[2,114],136:[2,114],137:[2,114],138:[2,114]},{5:231,25:[1,5],103:87,104:[1,65],106:[1,66],109:88,110:[1,68],111:69,126:[1,86],128:[1,80],129:[1,79],132:[1,78],133:[1,81],134:[1,82],135:[1,83],136:[1,84],137:[1,85]},{1:[2,143],6:[2,143],25:[2,143],26:[2,143],49:[2,143],54:[2,143],57:[2,143],73:[2,143],78:[2,143],86:[2,143],91:[2,143],93:[2,143],102:[2,143],103:87,104:[1,65],105:[1,232],106:[1,66],109:88,110:[1,68],111:69,118:[2,143],126:[2,143],128:[1,80],129:[1,79],132:[1,78],133:[1,81],134:[1,82],135:[1,83],136:[1,84],137:[1,85]},{1:[2,145],6:[2,145],25:[2,145],26:[2,145],49:[2,145],54:[2,145],57:[2,145],73:[2,145],78:[2,145],86:[2,145],91:[2,145],93:[2,145],102:[2,145],103:87,104:[1,65],105:[1,233],106:[1,66],109:88,110:[1,68],111:69,118:[2,145],126:[2,145],128:[1,80],129:[1,79],132:[1,78],133:[1,81],134:[1,82],135:[1,83],136:[1,84],137:[1,85]},{1:[2,151],6:[2,151],25:[2,151],26:[2,151],49:[2,151],54:[2,151],57:[2,151],73:[2,151],78:[2,151],86:[2,151],91:[2,151],93:[2,151],102:[2,151],104:[2,151],105:[2,151],106:[2,151],110:[2,151],118:[2,151],126:[2,151],128:[2,151],129:[2,151],132:[2,151],133:[2,151],134:[2,151],135:[2,151],136:[2,151],137:[2,151]},{1:[2,152],6:[2,152],25:[2,152],26:[2,152],49:[2,152],54:[2,152],57:[2,152],73:[2,152],78:[2,152],86:[2,152],91:[2,152],93:[2,152],102:[2,152],103:87,104:[1,65],105:[2,152],106:[1,66],109:88,110:[1,68],111:69,118:[2,152],126:[2,152],128:[1,80],129:[1,79],132:[1,78],133:[1,81],134:[1,82],135:[1,83],136:[1,84],137:[1,85]},{1:[2,156],6:[2,156],25:[2,156],26:[2,156],49:[2,156],54:[2,156],57:[2,156],73:[2,156],78:[2,156],86:[2,156],91:[2,156],93:[2,156],102:[2,156],104:[2,156],105:[2,156],106:[2,156],110:[2,156],118:[2,156],126:[2,156],128:[2,156],129:[2,156],132:[2,156],133:[2,156],134:[2,156],135:[2,156],136:[2,156],137:[2,156]},{116:[2,158],117:[2,158]},{27:159,28:[1,73],44:160,58:161,59:162,76:[1,70],89:[1,114],90:[1,115],113:234,115:158},{54:[1,235],116:[2,164],117:[2,164]},{54:[2,160],116:[2,160],117:[2,160]},{54:[2,161],116:[2,161],117:[2,161]},{54:[2,162],116:[2,162],117:[2,162]},{54:[2,163],116:[2,163],117:[2,163]},{1:[2,157],6:[2,157],25:[2,157],26:[2,157],49:[2,157],54:[2,157],57:[2,157],73:[2,157],78:[2,157],86:[2,157],91:[2,157],93:[2,157],102:[2,157],104:[2,157],105:[2,157],106:[2,157],110:[2,157],118:[2,157],126:[2,157],128:[2,157],129:[2,157],132:[2,157],133:[2,157],134:[2,157],135:[2,157],136:[2,157],137:[2,157]},{8:236,9:118,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,76:[1,70],79:[1,43],83:[1,28],88:[1,58],89:[1,59],90:[1,57],96:[1,38],100:[1,44],101:[1,56],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{8:237,9:118,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,76:[1,70],79:[1,43],83:[1,28],88:[1,58],89:[1,59],90:[1,57],96:[1,38],100:[1,44],101:[1,56],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{6:[2,53],25:[2,53],53:238,54:[1,239],78:[2,53]},{6:[2,92],25:[2,92],26:[2,92],54:[2,92],78:[2,92]},{6:[2,39],25:[2,39],26:[2,39],43:[1,240],54:[2,39],78:[2,39]},{6:[2,42],25:[2,42],26:[2,42],54:[2,42],78:[2,42]},{6:[2,43],25:[2,43],26:[2,43],43:[2,43],54:[2,43],78:[2,43]},{6:[2,44],25:[2,44],26:[2,44],43:[2,44],54:[2,44],78:[2,44]},{6:[2,45],25:[2,45],26:[2,45],43:[2,45],54:[2,45],78:[2,45]},{1:[2,5],6:[2,5],26:[2,5],102:[2,5]},{1:[2,25],6:[2,25],25:[2,25],26:[2,25],49:[2,25],54:[2,25],57:[2,25],73:[2,25],78:[2,25],86:[2,25],91:[2,25],93:[2,25],98:[2,25],99:[2,25],102:[2,25],104:[2,25],105:[2,25],106:[2,25],110:[2,25],118:[2,25],121:[2,25],123:[2,25],126:[2,25],128:[2,25],129:[2,25],132:[2,25],133:[2,25],134:[2,25],135:[2,25],136:[2,25],137:[2,25]},{1:[2,195],6:[2,195],25:[2,195],26:[2,195],49:[2,195],54:[2,195],57:[2,195],73:[2,195],78:[2,195],86:[2,195],91:[2,195],93:[2,195],102:[2,195],103:87,104:[2,195],105:[2,195],106:[2,195],109:88,110:[2,195],111:69,118:[2,195],126:[2,195],128:[2,195],129:[2,195],132:[1,78],133:[1,81],134:[2,195],135:[2,195],136:[2,195],137:[2,195]},{1:[2,196],6:[2,196],25:[2,196],26:[2,196],49:[2,196],54:[2,196],57:[2,196],73:[2,196],78:[2,196],86:[2,196],91:[2,196],93:[2,196],102:[2,196],103:87,104:[2,196],105:[2,196],106:[2,196],109:88,110:[2,196],111:69,118:[2,196],126:[2,196],128:[2,196],129:[2,196],132:[1,78],133:[1,81],134:[2,196],135:[2,196],136:[2,196],137:[2,196]},{1:[2,197],6:[2,197],25:[2,197],26:[2,197],49:[2,197],54:[2,197],57:[2,197],73:[2,197],78:[2,197],86:[2,197],91:[2,197],93:[2,197],102:[2,197],103:87,104:[2,197],105:[2,197],106:[2,197],109:88,110:[2,197],111:69,118:[2,197],126:[2,197],128:[2,197],129:[2,197],132:[1,78],133:[2,197],134:[2,197],135:[2,197],136:[2,197],137:[2,197]},{1:[2,198],6:[2,198],25:[2,198],26:[2,198],49:[2,198],54:[2,198],57:[2,198],73:[2,198],78:[2,198],86:[2,198],91:[2,198],93:[2,198],102:[2,198],103:87,104:[2,198],105:[2,198],106:[2,198],109:88,110:[2,198],111:69,118:[2,198],126:[2,198],128:[1,80],129:[1,79],132:[1,78],133:[1,81],134:[2,198],135:[2,198],136:[2,198],137:[2,198]},{1:[2,199],6:[2,199],25:[2,199],26:[2,199],49:[2,199],54:[2,199],57:[2,199],73:[2,199],78:[2,199],86:[2,199],91:[2,199],93:[2,199],102:[2,199],103:87,104:[2,199],105:[2,199],106:[2,199],109:88,110:[2,199],111:69,118:[2,199],126:[2,199],128:[1,80],129:[1,79],132:[1,78],133:[1,81],134:[1,82],135:[2,199],136:[2,199],137:[1,85]},{1:[2,200],6:[2,200],25:[2,200],26:[2,200],49:[2,200],54:[2,200],57:[2,200],73:[2,200],78:[2,200],86:[2,200],91:[2,200],93:[2,200],102:[2,200],103:87,104:[2,200],105:[2,200],106:[2,200],109:88,110:[2,200],111:69,118:[2,200],126:[2,200],128:[1,80],129:[1,79],132:[1,78],133:[1,81],134:[1,82],135:[1,83],136:[2,200],137:[1,85]},{1:[2,201],6:[2,201],25:[2,201],26:[2,201],49:[2,201],54:[2,201],57:[2,201],73:[2,201],78:[2,201],86:[2,201],91:[2,201],93:[2,201],102:[2,201],103:87,104:[2,201],105:[2,201],106:[2,201],109:88,110:[2,201],111:69,118:[2,201],126:[2,201],128:[1,80],129:[1,79],132:[1,78],133:[1,81],134:[1,82],135:[2,201],136:[2,201],137:[2,201]},{1:[2,186],6:[2,186],25:[2,186],26:[2,186],49:[2,186],54:[2,186],57:[2,186],73:[2,186],78:[2,186],86:[2,186],91:[2,186],93:[2,186],102:[2,186],103:87,104:[1,65],105:[2,186],106:[1,66],109:88,110:[1,68],111:69,118:[2,186],126:[1,86],128:[1,80],129:[1,79],132:[1,78],133:[1,81],134:[1,82],135:[1,83],136:[1,84],137:[1,85]},{1:[2,185],6:[2,185],25:[2,185],26:[2,185],49:[2,185],54:[2,185],57:[2,185],73:[2,185],78:[2,185],86:[2,185],91:[2,185],93:[2,185],102:[2,185],103:87,104:[1,65],105:[2,185],106:[1,66],109:88,110:[1,68],111:69,118:[2,185],126:[1,86],128:[1,80],129:[1,79],132:[1,78],133:[1,81],134:[1,82],135:[1,83],136:[1,84],137:[1,85]},{1:[2,104],6:[2,104],25:[2,104],26:[2,104],49:[2,104],54:[2,104],57:[2,104],66:[2,104],67:[2,104],68:[2,104],69:[2,104],71:[2,104],73:[2,104],74:[2,104],78:[2,104],84:[2,104],85:[2,104],86:[2,104],91:[2,104],93:[2,104],102:[2,104],104:[2,104],105:[2,104],106:[2,104],110:[2,104],118:[2,104],126:[2,104],128:[2,104],129:[2,104],132:[2,104],133:[2,104],134:[2,104],135:[2,104],136:[2,104],137:[2,104]},{1:[2,80],6:[2,80],25:[2,80],26:[2,80],40:[2,80],49:[2,80],54:[2,80],57:[2,80],66:[2,80],67:[2,80],68:[2,80],69:[2,80],71:[2,80],73:[2,80],74:[2,80],78:[2,80],80:[2,80],84:[2,80],85:[2,80],86:[2,80],91:[2,80],93:[2,80],102:[2,80],104:[2,80],105:[2,80],106:[2,80],110:[2,80],118:[2,80],126:[2,80],128:[2,80],129:[2,80],130:[2,80],131:[2,80],132:[2,80],133:[2,80],134:[2,80],135:[2,80],136:[2,80],137:[2,80],138:[2,80]},{1:[2,81],6:[2,81],25:[2,81],26:[2,81],40:[2,81],49:[2,81],54:[2,81],57:[2,81],66:[2,81],67:[2,81],68:[2,81],69:[2,81],71:[2,81],73:[2,81],74:[2,81],78:[2,81],80:[2,81],84:[2,81],85:[2,81],86:[2,81],91:[2,81],93:[2,81],102:[2,81],104:[2,81],105:[2,81],106:[2,81],110:[2,81],118:[2,81],126:[2,81],128:[2,81],129:[2,81],130:[2,81],131:[2,81],132:[2,81],133:[2,81],134:[2,81],135:[2,81],136:[2,81],137:[2,81],138:[2,81]},{1:[2,82],6:[2,82],25:[2,82],26:[2,82],40:[2,82],49:[2,82],54:[2,82],57:[2,82],66:[2,82],67:[2,82],68:[2,82],69:[2,82],71:[2,82],73:[2,82],74:[2,82],78:[2,82],80:[2,82],84:[2,82],85:[2,82],86:[2,82],91:[2,82],93:[2,82],102:[2,82],104:[2,82],105:[2,82],106:[2,82],110:[2,82],118:[2,82],126:[2,82],128:[2,82],129:[2,82],130:[2,82],131:[2,82],132:[2,82],133:[2,82],134:[2,82],135:[2,82],136:[2,82],137:[2,82],138:[2,82]},{1:[2,83],6:[2,83],25:[2,83],26:[2,83],40:[2,83],49:[2,83],54:[2,83],57:[2,83],66:[2,83],67:[2,83],68:[2,83],69:[2,83],71:[2,83],73:[2,83],74:[2,83],78:[2,83],80:[2,83],84:[2,83],85:[2,83],86:[2,83],91:[2,83],93:[2,83],102:[2,83],104:[2,83],105:[2,83],106:[2,83],110:[2,83],118:[2,83],126:[2,83],128:[2,83],129:[2,83],130:[2,83],131:[2,83],132:[2,83],133:[2,83],134:[2,83],135:[2,83],136:[2,83],137:[2,83],138:[2,83]},{73:[1,241]},{57:[1,194],73:[2,88],92:242,93:[1,193],103:87,104:[1,65],106:[1,66],109:88,110:[1,68],111:69,126:[1,86],128:[1,80],129:[1,79],132:[1,78],133:[1,81],134:[1,82],135:[1,83],136:[1,84],137:[1,85]},{73:[2,89]},{8:243,9:118,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,73:[2,123],76:[1,70],79:[1,43],83:[1,28],88:[1,58],89:[1,59],90:[1,57],96:[1,38],100:[1,44],101:[1,56],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{12:[2,117],28:[2,117],30:[2,117],31:[2,117],33:[2,117],34:[2,117],35:[2,117],36:[2,117],37:[2,117],38:[2,117],45:[2,117],46:[2,117],47:[2,117],51:[2,117],52:[2,117],73:[2,117],76:[2,117],79:[2,117],83:[2,117],88:[2,117],89:[2,117],90:[2,117],96:[2,117],100:[2,117],101:[2,117],104:[2,117],106:[2,117],108:[2,117],110:[2,117],119:[2,117],125:[2,117],127:[2,117],128:[2,117],129:[2,117],130:[2,117],131:[2,117]},{12:[2,118],28:[2,118],30:[2,118],31:[2,118],33:[2,118],34:[2,118],35:[2,118],36:[2,118],37:[2,118],38:[2,118],45:[2,118],46:[2,118],47:[2,118],51:[2,118],52:[2,118],73:[2,118],76:[2,118],79:[2,118],83:[2,118],88:[2,118],89:[2,118],90:[2,118],96:[2,118],100:[2,118],101:[2,118],104:[2,118],106:[2,118],108:[2,118],110:[2,118],119:[2,118],125:[2,118],127:[2,118],128:[2,118],129:[2,118],130:[2,118],131:[2,118]},{1:[2,87],6:[2,87],25:[2,87],26:[2,87],40:[2,87],49:[2,87],54:[2,87],57:[2,87],66:[2,87],67:[2,87],68:[2,87],69:[2,87],71:[2,87],73:[2,87],74:[2,87],78:[2,87],80:[2,87],84:[2,87],85:[2,87],86:[2,87],91:[2,87],93:[2,87],102:[2,87],104:[2,87],105:[2,87],106:[2,87],110:[2,87],118:[2,87],126:[2,87],128:[2,87],129:[2,87],130:[2,87],131:[2,87],132:[2,87],133:[2,87],134:[2,87],135:[2,87],136:[2,87],137:[2,87],138:[2,87]},{1:[2,105],6:[2,105],25:[2,105],26:[2,105],49:[2,105],54:[2,105],57:[2,105],66:[2,105],67:[2,105],68:[2,105],69:[2,105],71:[2,105],73:[2,105],74:[2,105],78:[2,105],84:[2,105],85:[2,105],86:[2,105],91:[2,105],93:[2,105],102:[2,105],104:[2,105],105:[2,105],106:[2,105],110:[2,105],118:[2,105],126:[2,105],128:[2,105],129:[2,105],132:[2,105],133:[2,105],134:[2,105],135:[2,105],136:[2,105],137:[2,105]},{1:[2,36],6:[2,36],25:[2,36],26:[2,36],49:[2,36],54:[2,36],57:[2,36],73:[2,36],78:[2,36],86:[2,36],91:[2,36],93:[2,36],102:[2,36],103:87,104:[2,36],105:[2,36],106:[2,36],109:88,110:[2,36],111:69,118:[2,36],126:[2,36],128:[1,80],129:[1,79],132:[1,78],133:[1,81],134:[1,82],135:[1,83],136:[1,84],137:[1,85]},{8:244,9:118,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,76:[1,70],79:[1,43],83:[1,28],88:[1,58],89:[1,59],90:[1,57],96:[1,38],100:[1,44],101:[1,56],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{8:245,9:118,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,76:[1,70],79:[1,43],83:[1,28],88:[1,58],89:[1,59],90:[1,57],96:[1,38],100:[1,44],101:[1,56],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{1:[2,110],6:[2,110],25:[2,110],26:[2,110],49:[2,110],54:[2,110],57:[2,110],66:[2,110],67:[2,110],68:[2,110],69:[2,110],71:[2,110],73:[2,110],74:[2,110],78:[2,110],84:[2,110],85:[2,110],86:[2,110],91:[2,110],93:[2,110],102:[2,110],104:[2,110],105:[2,110],106:[2,110],110:[2,110],118:[2,110],126:[2,110],128:[2,110],129:[2,110],132:[2,110],133:[2,110],134:[2,110],135:[2,110],136:[2,110],137:[2,110]},{6:[2,53],25:[2,53],53:246,54:[1,229],86:[2,53]},{6:[2,129],25:[2,129],26:[2,129],54:[2,129],57:[1,247],86:[2,129],91:[2,129],103:87,104:[1,65],106:[1,66],109:88,110:[1,68],111:69,126:[1,86],128:[1,80],129:[1,79],132:[1,78],133:[1,81],134:[1,82],135:[1,83],136:[1,84],137:[1,85]},{50:248,51:[1,60],52:[1,61]},{6:[2,54],25:[2,54],26:[2,54],27:110,28:[1,73],44:111,55:249,56:109,58:112,59:113,76:[1,70],89:[1,114],90:[1,115]},{6:[1,250],25:[1,251]},{6:[2,61],25:[2,61],26:[2,61],49:[2,61],54:[2,61]},{8:252,9:118,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,76:[1,70],79:[1,43],83:[1,28],88:[1,58],89:[1,59],90:[1,57],96:[1,38],100:[1,44],101:[1,56],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{1:[2,202],6:[2,202],25:[2,202],26:[2,202],49:[2,202],54:[2,202],57:[2,202],73:[2,202],78:[2,202],86:[2,202],91:[2,202],93:[2,202],102:[2,202],103:87,104:[2,202],105:[2,202],106:[2,202],109:88,110:[2,202],111:69,118:[2,202],126:[2,202],128:[1,80],129:[1,79],132:[1,78],133:[1,81],134:[1,82],135:[1,83],136:[1,84],137:[1,85]},{8:253,9:118,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,76:[1,70],79:[1,43],83:[1,28],88:[1,58],89:[1,59],90:[1,57],96:[1,38],100:[1,44],101:[1,56],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{8:254,9:118,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,76:[1,70],79:[1,43],83:[1,28],88:[1,58],89:[1,59],90:[1,57],96:[1,38],100:[1,44],101:[1,56],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{1:[2,205],6:[2,205],25:[2,205],26:[2,205],49:[2,205],54:[2,205],57:[2,205],73:[2,205],78:[2,205],86:[2,205],91:[2,205],93:[2,205],102:[2,205],103:87,104:[2,205],105:[2,205],106:[2,205],109:88,110:[2,205],111:69,118:[2,205],126:[2,205],128:[1,80],129:[1,79],132:[1,78],133:[1,81],134:[1,82],135:[1,83],136:[1,84],137:[1,85]},{1:[2,184],6:[2,184],25:[2,184],26:[2,184],49:[2,184],54:[2,184],57:[2,184],73:[2,184],78:[2,184],86:[2,184],91:[2,184],93:[2,184],102:[2,184],104:[2,184],105:[2,184],106:[2,184],110:[2,184],118:[2,184],126:[2,184],128:[2,184],129:[2,184],132:[2,184],133:[2,184],134:[2,184],135:[2,184],136:[2,184],137:[2,184]},{8:255,9:118,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,76:[1,70],79:[1,43],83:[1,28],88:[1,58],89:[1,59],90:[1,57],96:[1,38],100:[1,44],101:[1,56],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{1:[2,134],6:[2,134],25:[2,134],26:[2,134],49:[2,134],54:[2,134],57:[2,134],73:[2,134],78:[2,134],86:[2,134],91:[2,134],93:[2,134],98:[1,256],102:[2,134],104:[2,134],105:[2,134],106:[2,134],110:[2,134],118:[2,134],126:[2,134],128:[2,134],129:[2,134],132:[2,134],133:[2,134],134:[2,134],135:[2,134],136:[2,134],137:[2,134]},{5:257,25:[1,5]},{5:260,25:[1,5],27:258,28:[1,73],59:259,76:[1,70]},{120:261,122:219,123:[1,220]},{26:[1,262],121:[1,263],122:264,123:[1,220]},{26:[2,177],121:[2,177],123:[2,177]},{8:266,9:118,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,76:[1,70],79:[1,43],83:[1,28],88:[1,58],89:[1,59],90:[1,57],95:265,96:[1,38],100:[1,44],101:[1,56],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{1:[2,98],5:267,6:[2,98],25:[1,5],26:[2,98],49:[2,98],54:[2,98],57:[2,98],73:[2,98],78:[2,98],86:[2,98],91:[2,98],93:[2,98],102:[2,98],103:87,104:[1,65],105:[2,98],106:[1,66],109:88,110:[1,68],111:69,118:[2,98],126:[2,98],128:[1,80],129:[1,79],132:[1,78],133:[1,81],134:[1,82],135:[1,83],136:[1,84],137:[1,85]},{1:[2,101],6:[2,101],25:[2,101],26:[2,101],49:[2,101],54:[2,101],57:[2,101],73:[2,101],78:[2,101],86:[2,101],91:[2,101],93:[2,101],102:[2,101],104:[2,101],105:[2,101],106:[2,101],110:[2,101],118:[2,101],126:[2,101],128:[2,101],129:[2,101],132:[2,101],133:[2,101],134:[2,101],135:[2,101],136:[2,101],137:[2,101]},{8:268,9:118,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,76:[1,70],79:[1,43],83:[1,28],88:[1,58],89:[1,59],90:[1,57],96:[1,38],100:[1,44],101:[1,56],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{1:[2,141],6:[2,141],25:[2,141],26:[2,141],49:[2,141],54:[2,141],57:[2,141],66:[2,141],67:[2,141],68:[2,141],69:[2,141],71:[2,141],73:[2,141],74:[2,141],78:[2,141],84:[2,141],85:[2,141],86:[2,141],91:[2,141],93:[2,141],102:[2,141],104:[2,141],105:[2,141],106:[2,141],110:[2,141],118:[2,141],126:[2,141],128:[2,141],129:[2,141],132:[2,141],133:[2,141],134:[2,141],135:[2,141],136:[2,141],137:[2,141]},{6:[1,74],26:[1,269]},{8:270,9:118,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,76:[1,70],79:[1,43],83:[1,28],88:[1,58],89:[1,59],90:[1,57],96:[1,38],100:[1,44],101:[1,56],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{6:[2,67],12:[2,118],25:[2,67],28:[2,118],30:[2,118],31:[2,118],33:[2,118],34:[2,118],35:[2,118],36:[2,118],37:[2,118],38:[2,118],45:[2,118],46:[2,118],47:[2,118],51:[2,118],52:[2,118],54:[2,67],76:[2,118],79:[2,118],83:[2,118],88:[2,118],89:[2,118],90:[2,118],91:[2,67],96:[2,118],100:[2,118],101:[2,118],104:[2,118],106:[2,118],108:[2,118],110:[2,118],119:[2,118],125:[2,118],127:[2,118],128:[2,118],129:[2,118],130:[2,118],131:[2,118]},{6:[1,272],25:[1,273],91:[1,271]},{6:[2,54],8:202,9:118,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,25:[2,54],26:[2,54],27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,60:148,61:36,63:25,64:26,65:27,76:[1,70],79:[1,43],83:[1,28],86:[2,54],88:[1,58],89:[1,59],90:[1,57],91:[2,54],94:274,96:[1,38],100:[1,44],101:[1,56],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{6:[2,53],25:[2,53],26:[2,53],53:275,54:[1,229]},{1:[2,181],6:[2,181],25:[2,181],26:[2,181],49:[2,181],54:[2,181],57:[2,181],73:[2,181],78:[2,181],86:[2,181],91:[2,181],93:[2,181],102:[2,181],104:[2,181],105:[2,181],106:[2,181],110:[2,181],118:[2,181],121:[2,181],126:[2,181],128:[2,181],129:[2,181],132:[2,181],133:[2,181],134:[2,181],135:[2,181],136:[2,181],137:[2,181]},{8:276,9:118,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,76:[1,70],79:[1,43],83:[1,28],88:[1,58],89:[1,59],90:[1,57],96:[1,38],100:[1,44],101:[1,56],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{8:277,9:118,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,76:[1,70],79:[1,43],83:[1,28],88:[1,58],89:[1,59],90:[1,57],96:[1,38],100:[1,44],101:[1,56],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{116:[2,159],117:[2,159]},{27:159,28:[1,73],44:160,58:161,59:162,76:[1,70],89:[1,114],90:[1,115],115:278},{1:[2,166],6:[2,166],25:[2,166],26:[2,166],49:[2,166],54:[2,166],57:[2,166],73:[2,166],78:[2,166],86:[2,166],91:[2,166],93:[2,166],102:[2,166],103:87,104:[2,166],105:[1,279],106:[2,166],109:88,110:[2,166],111:69,118:[1,280],126:[2,166],128:[1,80],129:[1,79],132:[1,78],133:[1,81],134:[1,82],135:[1,83],136:[1,84],137:[1,85]},{1:[2,167],6:[2,167],25:[2,167],26:[2,167],49:[2,167],54:[2,167],57:[2,167],73:[2,167],78:[2,167],86:[2,167],91:[2,167],93:[2,167],102:[2,167],103:87,104:[2,167],105:[1,281],106:[2,167],109:88,110:[2,167],111:69,118:[2,167],126:[2,167],128:[1,80],129:[1,79],132:[1,78],133:[1,81],134:[1,82],135:[1,83],136:[1,84],137:[1,85]},{6:[1,283],25:[1,284],78:[1,282]},{6:[2,54],11:169,25:[2,54],26:[2,54],27:170,28:[1,73],29:171,30:[1,71],31:[1,72],41:285,42:168,44:172,46:[1,46],78:[2,54],89:[1,114]},{8:286,9:118,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,25:[1,287],27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,76:[1,70],79:[1,43],83:[1,28],88:[1,58],89:[1,59],90:[1,57],96:[1,38],100:[1,44],101:[1,56],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{1:[2,86],6:[2,86],25:[2,86],26:[2,86],40:[2,86],49:[2,86],54:[2,86],57:[2,86],66:[2,86],67:[2,86],68:[2,86],69:[2,86],71:[2,86],73:[2,86],74:[2,86],78:[2,86],80:[2,86],84:[2,86],85:[2,86],86:[2,86],91:[2,86],93:[2,86],102:[2,86],104:[2,86],105:[2,86],106:[2,86],110:[2,86],118:[2,86],126:[2,86],128:[2,86],129:[2,86],130:[2,86],131:[2,86],132:[2,86],133:[2,86],134:[2,86],135:[2,86],136:[2,86],137:[2,86],138:[2,86]},{8:288,9:118,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,73:[2,121],76:[1,70],79:[1,43],83:[1,28],88:[1,58],89:[1,59],90:[1,57],96:[1,38],100:[1,44],101:[1,56],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{73:[2,122],103:87,104:[1,65],106:[1,66],109:88,110:[1,68],111:69,126:[1,86],128:[1,80],129:[1,79],132:[1,78],133:[1,81],134:[1,82],135:[1,83],136:[1,84],137:[1,85]},{1:[2,37],6:[2,37],25:[2,37],26:[2,37],49:[2,37],54:[2,37],57:[2,37],73:[2,37],78:[2,37],86:[2,37],91:[2,37],93:[2,37],102:[2,37],103:87,104:[2,37],105:[2,37],106:[2,37],109:88,110:[2,37],111:69,118:[2,37],126:[2,37],128:[1,80],129:[1,79],132:[1,78],133:[1,81],134:[1,82],135:[1,83],136:[1,84],137:[1,85]},{26:[1,289],103:87,104:[1,65],106:[1,66],109:88,110:[1,68],111:69,126:[1,86],128:[1,80],129:[1,79],132:[1,78],133:[1,81],134:[1,82],135:[1,83],136:[1,84],137:[1,85]},{6:[1,272],25:[1,273],86:[1,290]},{6:[2,67],25:[2,67],26:[2,67],54:[2,67],86:[2,67],91:[2,67]},{5:291,25:[1,5]},{6:[2,57],25:[2,57],26:[2,57],49:[2,57],54:[2,57]},{27:110,28:[1,73],44:111,55:292,56:109,58:112,59:113,76:[1,70],89:[1,114],90:[1,115]},{6:[2,55],25:[2,55],26:[2,55],27:110,28:[1,73],44:111,48:293,54:[2,55],55:108,56:109,58:112,59:113,76:[1,70],89:[1,114],90:[1,115]},{6:[2,62],25:[2,62],26:[2,62],49:[2,62],54:[2,62],103:87,104:[1,65],106:[1,66],109:88,110:[1,68],111:69,126:[1,86],128:[1,80],129:[1,79],132:[1,78],133:[1,81],134:[1,82],135:[1,83],136:[1,84],137:[1,85]},{26:[1,294],103:87,104:[1,65],106:[1,66],109:88,110:[1,68],111:69,126:[1,86],128:[1,80],129:[1,79],132:[1,78],133:[1,81],134:[1,82],135:[1,83],136:[1,84],137:[1,85]},{1:[2,204],6:[2,204],25:[2,204],26:[2,204],49:[2,204],54:[2,204],57:[2,204],73:[2,204],78:[2,204],86:[2,204],91:[2,204],93:[2,204],102:[2,204],103:87,104:[2,204],105:[2,204],106:[2,204],109:88,110:[2,204],111:69,118:[2,204],126:[2,204],128:[1,80],129:[1,79],132:[1,78],133:[1,81],134:[1,82],135:[1,83],136:[1,84],137:[1,85]},{5:295,25:[1,5],103:87,104:[1,65],106:[1,66],109:88,110:[1,68],111:69,126:[1,86],128:[1,80],129:[1,79],132:[1,78],133:[1,81],134:[1,82],135:[1,83],136:[1,84],137:[1,85]},{5:296,25:[1,5]},{1:[2,135],6:[2,135],25:[2,135],26:[2,135],49:[2,135],54:[2,135],57:[2,135],73:[2,135],78:[2,135],86:[2,135],91:[2,135],93:[2,135],102:[2,135],104:[2,135],105:[2,135],106:[2,135],110:[2,135],118:[2,135],126:[2,135],128:[2,135],129:[2,135],132:[2,135],133:[2,135],134:[2,135],135:[2,135],136:[2,135],137:[2,135]},{5:297,25:[1,5]},{5:298,25:[1,5]},{1:[2,139],6:[2,139],25:[2,139],26:[2,139],49:[2,139],54:[2,139],57:[2,139],73:[2,139],78:[2,139],86:[2,139],91:[2,139],93:[2,139],98:[2,139],102:[2,139],104:[2,139],105:[2,139],106:[2,139],110:[2,139],118:[2,139],126:[2,139],128:[2,139],129:[2,139],132:[2,139],133:[2,139],134:[2,139],135:[2,139],136:[2,139],137:[2,139]},{26:[1,299],121:[1,300],122:264,123:[1,220]},{1:[2,175],6:[2,175],25:[2,175],26:[2,175],49:[2,175],54:[2,175],57:[2,175],73:[2,175],78:[2,175],86:[2,175],91:[2,175],93:[2,175],102:[2,175],104:[2,175],105:[2,175],106:[2,175],110:[2,175],118:[2,175],126:[2,175],128:[2,175],129:[2,175],132:[2,175],133:[2,175],134:[2,175],135:[2,175],136:[2,175],137:[2,175]},{5:301,25:[1,5]},{26:[2,178],121:[2,178],123:[2,178]},{5:302,25:[1,5],54:[1,303]},{25:[2,131],54:[2,131],103:87,104:[1,65],106:[1,66],109:88,110:[1,68],111:69,126:[1,86],128:[1,80],129:[1,79],132:[1,78],133:[1,81],134:[1,82],135:[1,83],136:[1,84],137:[1,85]},{1:[2,99],6:[2,99],25:[2,99],26:[2,99],49:[2,99],54:[2,99],57:[2,99],73:[2,99],78:[2,99],86:[2,99],91:[2,99],93:[2,99],102:[2,99],104:[2,99],105:[2,99],106:[2,99],110:[2,99],118:[2,99],126:[2,99],128:[2,99],129:[2,99],132:[2,99],133:[2,99],134:[2,99],135:[2,99],136:[2,99],137:[2,99]},{1:[2,102],5:304,6:[2,102],25:[1,5],26:[2,102],49:[2,102],54:[2,102],57:[2,102],73:[2,102],78:[2,102],86:[2,102],91:[2,102],93:[2,102],102:[2,102],103:87,104:[1,65],105:[2,102],106:[1,66],109:88,110:[1,68],111:69,118:[2,102],126:[2,102],128:[1,80],129:[1,79],132:[1,78],133:[1,81],134:[1,82],135:[1,83],136:[1,84],137:[1,85]},{102:[1,305]},{91:[1,306],103:87,104:[1,65],106:[1,66],109:88,110:[1,68],111:69,126:[1,86],128:[1,80],129:[1,79],132:[1,78],133:[1,81],134:[1,82],135:[1,83],136:[1,84],137:[1,85]},{1:[2,116],6:[2,116],25:[2,116],26:[2,116],40:[2,116],49:[2,116],54:[2,116],57:[2,116],66:[2,116],67:[2,116],68:[2,116],69:[2,116],71:[2,116],73:[2,116],74:[2,116],78:[2,116],84:[2,116],85:[2,116],86:[2,116],91:[2,116],93:[2,116],102:[2,116],104:[2,116],105:[2,116],106:[2,116],110:[2,116],116:[2,116],117:[2,116],118:[2,116],126:[2,116],128:[2,116],129:[2,116],132:[2,116],133:[2,116],134:[2,116],135:[2,116],136:[2,116],137:[2,116]},{8:202,9:118,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,60:148,61:36,63:25,64:26,65:27,76:[1,70],79:[1,43],83:[1,28],88:[1,58],89:[1,59],90:[1,57],94:307,96:[1,38],100:[1,44],101:[1,56],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{8:202,9:118,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,25:[1,147],27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,60:148,61:36,63:25,64:26,65:27,76:[1,70],79:[1,43],83:[1,28],87:308,88:[1,58],89:[1,59],90:[1,57],94:146,96:[1,38],100:[1,44],101:[1,56],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{6:[2,125],25:[2,125],26:[2,125],54:[2,125],86:[2,125],91:[2,125]},{6:[1,272],25:[1,273],26:[1,309]},{1:[2,144],6:[2,144],25:[2,144],26:[2,144],49:[2,144],54:[2,144],57:[2,144],73:[2,144],78:[2,144],86:[2,144],91:[2,144],93:[2,144],102:[2,144],103:87,104:[1,65],105:[2,144],106:[1,66],109:88,110:[1,68],111:69,118:[2,144],126:[2,144],128:[1,80],129:[1,79],132:[1,78],133:[1,81],134:[1,82],135:[1,83],136:[1,84],137:[1,85]},{1:[2,146],6:[2,146],25:[2,146],26:[2,146],49:[2,146],54:[2,146],57:[2,146],73:[2,146],78:[2,146],86:[2,146],91:[2,146],93:[2,146],102:[2,146],103:87,104:[1,65],105:[2,146],106:[1,66],109:88,110:[1,68],111:69,118:[2,146],126:[2,146],128:[1,80],129:[1,79],132:[1,78],133:[1,81],134:[1,82],135:[1,83],136:[1,84],137:[1,85]},{116:[2,165],117:[2,165]},{8:310,9:118,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,76:[1,70],79:[1,43],83:[1,28],88:[1,58],89:[1,59],90:[1,57],96:[1,38],100:[1,44],101:[1,56],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{8:311,9:118,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,76:[1,70],79:[1,43],83:[1,28],88:[1,58],89:[1,59],90:[1,57],96:[1,38],100:[1,44],101:[1,56],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{8:312,9:118,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,76:[1,70],79:[1,43],83:[1,28],88:[1,58],89:[1,59],90:[1,57],96:[1,38],100:[1,44],101:[1,56],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{1:[2,90],6:[2,90],25:[2,90],26:[2,90],40:[2,90],49:[2,90],54:[2,90],57:[2,90],66:[2,90],67:[2,90],68:[2,90],69:[2,90],71:[2,90],73:[2,90],74:[2,90],78:[2,90],84:[2,90],85:[2,90],86:[2,90],91:[2,90],93:[2,90],102:[2,90],104:[2,90],105:[2,90],106:[2,90],110:[2,90],116:[2,90],117:[2,90],118:[2,90],126:[2,90],128:[2,90],129:[2,90],132:[2,90],133:[2,90],134:[2,90],135:[2,90],136:[2,90],137:[2,90]},{11:169,27:170,28:[1,73],29:171,30:[1,71],31:[1,72],41:313,42:168,44:172,46:[1,46],89:[1,114]},{6:[2,91],11:169,25:[2,91],26:[2,91],27:170,28:[1,73],29:171,30:[1,71],31:[1,72],41:167,42:168,44:172,46:[1,46],54:[2,91],77:314,89:[1,114]},{6:[2,93],25:[2,93],26:[2,93],54:[2,93],78:[2,93]},{6:[2,40],25:[2,40],26:[2,40],54:[2,40],78:[2,40],103:87,104:[1,65],106:[1,66],109:88,110:[1,68],111:69,126:[1,86],128:[1,80],129:[1,79],132:[1,78],133:[1,81],134:[1,82],135:[1,83],136:[1,84],137:[1,85]},{8:315,9:118,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,76:[1,70],79:[1,43],83:[1,28],88:[1,58],89:[1,59],90:[1,57],96:[1,38],100:[1,44],101:[1,56],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{73:[2,120],103:87,104:[1,65],106:[1,66],109:88,110:[1,68],111:69,126:[1,86],128:[1,80],129:[1,79],132:[1,78],133:[1,81],134:[1,82],135:[1,83],136:[1,84],137:[1,85]},{1:[2,38],6:[2,38],25:[2,38],26:[2,38],49:[2,38],54:[2,38],57:[2,38],73:[2,38],78:[2,38],86:[2,38],91:[2,38],93:[2,38],102:[2,38],104:[2,38],105:[2,38],106:[2,38],110:[2,38],118:[2,38],126:[2,38],128:[2,38],129:[2,38],132:[2,38],133:[2,38],134:[2,38],135:[2,38],136:[2,38],137:[2,38]},{1:[2,111],6:[2,111],25:[2,111],26:[2,111],49:[2,111],54:[2,111],57:[2,111],66:[2,111],67:[2,111],68:[2,111],69:[2,111],71:[2,111],73:[2,111],74:[2,111],78:[2,111],84:[2,111],85:[2,111],86:[2,111],91:[2,111],93:[2,111],102:[2,111],104:[2,111],105:[2,111],106:[2,111],110:[2,111],118:[2,111],126:[2,111],128:[2,111],129:[2,111],132:[2,111],133:[2,111],134:[2,111],135:[2,111],136:[2,111],137:[2,111]},{1:[2,49],6:[2,49],25:[2,49],26:[2,49],49:[2,49],54:[2,49],57:[2,49],73:[2,49],78:[2,49],86:[2,49],91:[2,49],93:[2,49],102:[2,49],104:[2,49],105:[2,49],106:[2,49],110:[2,49],118:[2,49],126:[2,49],128:[2,49],129:[2,49],132:[2,49],133:[2,49],134:[2,49],135:[2,49],136:[2,49],137:[2,49]},{6:[2,58],25:[2,58],26:[2,58],49:[2,58],54:[2,58]},{6:[2,53],25:[2,53],26:[2,53],53:316,54:[1,204]},{1:[2,203],6:[2,203],25:[2,203],26:[2,203],49:[2,203],54:[2,203],57:[2,203],73:[2,203],78:[2,203],86:[2,203],91:[2,203],93:[2,203],102:[2,203],104:[2,203],105:[2,203],106:[2,203],110:[2,203],118:[2,203],126:[2,203],128:[2,203],129:[2,203],132:[2,203],133:[2,203],134:[2,203],135:[2,203],136:[2,203],137:[2,203]},{1:[2,182],6:[2,182],25:[2,182],26:[2,182],49:[2,182],54:[2,182],57:[2,182],73:[2,182],78:[2,182],86:[2,182],91:[2,182],93:[2,182],102:[2,182],104:[2,182],105:[2,182],106:[2,182],110:[2,182],118:[2,182],121:[2,182],126:[2,182],128:[2,182],129:[2,182],132:[2,182],133:[2,182],134:[2,182],135:[2,182],136:[2,182],137:[2,182]},{1:[2,136],6:[2,136],25:[2,136],26:[2,136],49:[2,136],54:[2,136],57:[2,136],73:[2,136],78:[2,136],86:[2,136],91:[2,136],93:[2,136],102:[2,136],104:[2,136],105:[2,136],106:[2,136],110:[2,136],118:[2,136],126:[2,136],128:[2,136],129:[2,136],132:[2,136],133:[2,136],134:[2,136],135:[2,136],136:[2,136],137:[2,136]},{1:[2,137],6:[2,137],25:[2,137],26:[2,137],49:[2,137],54:[2,137],57:[2,137],73:[2,137],78:[2,137],86:[2,137],91:[2,137],93:[2,137],98:[2,137],102:[2,137],104:[2,137],105:[2,137],106:[2,137],110:[2,137],118:[2,137],126:[2,137],128:[2,137],129:[2,137],132:[2,137],133:[2,137],134:[2,137],135:[2,137],136:[2,137],137:[2,137]},{1:[2,138],6:[2,138],25:[2,138],26:[2,138],49:[2,138],54:[2,138],57:[2,138],73:[2,138],78:[2,138],86:[2,138],91:[2,138],93:[2,138],98:[2,138],102:[2,138],104:[2,138],105:[2,138],106:[2,138],110:[2,138],118:[2,138],126:[2,138],128:[2,138],129:[2,138],132:[2,138],133:[2,138],134:[2,138],135:[2,138],136:[2,138],137:[2,138]},{1:[2,173],6:[2,173],25:[2,173],26:[2,173],49:[2,173],54:[2,173],57:[2,173],73:[2,173],78:[2,173],86:[2,173],91:[2,173],93:[2,173],102:[2,173],104:[2,173],105:[2,173],106:[2,173],110:[2,173],118:[2,173],126:[2,173],128:[2,173],129:[2,173],132:[2,173],133:[2,173],134:[2,173],135:[2,173],136:[2,173],137:[2,173]},{5:317,25:[1,5]},{26:[1,318]},{6:[1,319],26:[2,179],121:[2,179],123:[2,179]},{8:320,9:118,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,76:[1,70],79:[1,43],83:[1,28],88:[1,58],89:[1,59],90:[1,57],96:[1,38],100:[1,44],101:[1,56],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{1:[2,103],6:[2,103],25:[2,103],26:[2,103],49:[2,103],54:[2,103],57:[2,103],73:[2,103],78:[2,103],86:[2,103],91:[2,103],93:[2,103],102:[2,103],104:[2,103],105:[2,103],106:[2,103],110:[2,103],118:[2,103],126:[2,103],128:[2,103],129:[2,103],132:[2,103],133:[2,103],134:[2,103],135:[2,103],136:[2,103],137:[2,103]},{1:[2,142],6:[2,142],25:[2,142],26:[2,142],49:[2,142],54:[2,142],57:[2,142],66:[2,142],67:[2,142],68:[2,142],69:[2,142],71:[2,142],73:[2,142],74:[2,142],78:[2,142],84:[2,142],85:[2,142],86:[2,142],91:[2,142],93:[2,142],102:[2,142],104:[2,142],105:[2,142],106:[2,142],110:[2,142],118:[2,142],126:[2,142],128:[2,142],129:[2,142],132:[2,142],133:[2,142],134:[2,142],135:[2,142],136:[2,142],137:[2,142]},{1:[2,119],6:[2,119],25:[2,119],26:[2,119],49:[2,119],54:[2,119],57:[2,119],66:[2,119],67:[2,119],68:[2,119],69:[2,119],71:[2,119],73:[2,119],74:[2,119],78:[2,119],84:[2,119],85:[2,119],86:[2,119],91:[2,119],93:[2,119],102:[2,119],104:[2,119],105:[2,119],106:[2,119],110:[2,119],118:[2,119],126:[2,119],128:[2,119],129:[2,119],132:[2,119],133:[2,119],134:[2,119],135:[2,119],136:[2,119],137:[2,119]},{6:[2,126],25:[2,126],26:[2,126],54:[2,126],86:[2,126],91:[2,126]},{6:[2,53],25:[2,53],26:[2,53],53:321,54:[1,229]},{6:[2,127],25:[2,127],26:[2,127],54:[2,127],86:[2,127],91:[2,127]},{1:[2,168],6:[2,168],25:[2,168],26:[2,168],49:[2,168],54:[2,168],57:[2,168],73:[2,168],78:[2,168],86:[2,168],91:[2,168],93:[2,168],102:[2,168],103:87,104:[2,168],105:[2,168],106:[2,168],109:88,110:[2,168],111:69,118:[1,322],126:[2,168],128:[1,80],129:[1,79],132:[1,78],133:[1,81],134:[1,82],135:[1,83],136:[1,84],137:[1,85]},{1:[2,170],6:[2,170],25:[2,170],26:[2,170],49:[2,170],54:[2,170],57:[2,170],73:[2,170],78:[2,170],86:[2,170],91:[2,170],93:[2,170],102:[2,170],103:87,104:[2,170],105:[1,323],106:[2,170],109:88,110:[2,170],111:69,118:[2,170],126:[2,170],128:[1,80],129:[1,79],132:[1,78],133:[1,81],134:[1,82],135:[1,83],136:[1,84],137:[1,85]},{1:[2,169],6:[2,169],25:[2,169],26:[2,169],49:[2,169],54:[2,169],57:[2,169],73:[2,169],78:[2,169],86:[2,169],91:[2,169],93:[2,169],102:[2,169],103:87,104:[2,169],105:[2,169],106:[2,169],109:88,110:[2,169],111:69,118:[2,169],126:[2,169],128:[1,80],129:[1,79],132:[1,78],133:[1,81],134:[1,82],135:[1,83],136:[1,84],137:[1,85]},{6:[2,94],25:[2,94],26:[2,94],54:[2,94],78:[2,94]},{6:[2,53],25:[2,53],26:[2,53],53:324,54:[1,239]},{26:[1,325],103:87,104:[1,65],106:[1,66],109:88,110:[1,68],111:69,126:[1,86],128:[1,80],129:[1,79],132:[1,78],133:[1,81],134:[1,82],135:[1,83],136:[1,84],137:[1,85]},{6:[1,250],25:[1,251],26:[1,326]},{26:[1,327]},{1:[2,176],6:[2,176],25:[2,176],26:[2,176],49:[2,176],54:[2,176],57:[2,176],73:[2,176],78:[2,176],86:[2,176],91:[2,176],93:[2,176],102:[2,176],104:[2,176],105:[2,176],106:[2,176],110:[2,176],118:[2,176],126:[2,176],128:[2,176],129:[2,176],132:[2,176],133:[2,176],134:[2,176],135:[2,176],136:[2,176],137:[2,176]},{26:[2,180],121:[2,180],123:[2,180]},{25:[2,132],54:[2,132],103:87,104:[1,65],106:[1,66],109:88,110:[1,68],111:69,126:[1,86],128:[1,80],129:[1,79],132:[1,78],133:[1,81],134:[1,82],135:[1,83],136:[1,84],137:[1,85]},{6:[1,272],25:[1,273],26:[1,328]},{8:329,9:118,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,76:[1,70],79:[1,43],83:[1,28],88:[1,58],89:[1,59],90:[1,57],96:[1,38],100:[1,44],101:[1,56],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{8:330,9:118,10:20,11:21,12:[1,22],13:8,14:9,15:10,16:11,17:12,18:13,19:14,20:15,21:16,22:17,23:18,24:19,27:62,28:[1,73],29:49,30:[1,71],31:[1,72],32:24,33:[1,50],34:[1,51],35:[1,52],36:[1,53],37:[1,54],38:[1,55],39:23,44:63,45:[1,45],46:[1,46],47:[1,29],50:30,51:[1,60],52:[1,61],58:47,59:48,61:36,63:25,64:26,65:27,76:[1,70],79:[1,43],83:[1,28],88:[1,58],89:[1,59],90:[1,57],96:[1,38],100:[1,44],101:[1,56],103:39,104:[1,65],106:[1,66],107:40,108:[1,67],109:41,110:[1,68],111:69,119:[1,42],124:37,125:[1,64],127:[1,31],128:[1,32],129:[1,33],130:[1,34],131:[1,35]},{6:[1,283],25:[1,284],26:[1,331]},{6:[2,41],25:[2,41],26:[2,41],54:[2,41],78:[2,41]},{6:[2,59],25:[2,59],26:[2,59],49:[2,59],54:[2,59]},{1:[2,174],6:[2,174],25:[2,174],26:[2,174],49:[2,174],54:[2,174],57:[2,174],73:[2,174],78:[2,174],86:[2,174],91:[2,174],93:[2,174],102:[2,174],104:[2,174],105:[2,174],106:[2,174],110:[2,174],118:[2,174],126:[2,174],128:[2,174],129:[2,174],132:[2,174],133:[2,174],134:[2,174],135:[2,174],136:[2,174],137:[2,174]},{6:[2,128],25:[2,128],26:[2,128],54:[2,128],86:[2,128],91:[2,128]},{1:[2,171],6:[2,171],25:[2,171],26:[2,171],49:[2,171],54:[2,171],57:[2,171],73:[2,171],78:[2,171],86:[2,171],91:[2,171],93:[2,171],102:[2,171],103:87,104:[2,171],105:[2,171],106:[2,171],109:88,110:[2,171],111:69,118:[2,171],126:[2,171],128:[1,80],129:[1,79],132:[1,78],133:[1,81],134:[1,82],135:[1,83],136:[1,84],137:[1,85]},{1:[2,172],6:[2,172],25:[2,172],26:[2,172],49:[2,172],54:[2,172],57:[2,172],73:[2,172],78:[2,172],86:[2,172],91:[2,172],93:[2,172],102:[2,172],103:87,104:[2,172],105:[2,172],106:[2,172],109:88,110:[2,172],111:69,118:[2,172],126:[2,172],128:[1,80],129:[1,79],132:[1,78],133:[1,81],134:[1,82],135:[1,83],136:[1,84],137:[1,85]},{6:[2,95],25:[2,95],26:[2,95],54:[2,95],78:[2,95]}], -defaultActions: {60:[2,51],61:[2,52],75:[2,3],94:[2,109],191:[2,89]}, +table: [{1:[2,1],3:1,4:2,5:3,7:4,8:5,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,61:34,63:23,64:24,65:25,76:[1,68],79:[1,41],83:[1,26],88:[1,56],89:[1,57],90:[1,55],96:[1,36],100:[1,42],101:[1,54],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{1:[3]},{1:[2,2],6:[1,72]},{1:[2,3],6:[2,3],26:[2,3],102:[2,3]},{1:[2,6],6:[2,6],26:[2,6],102:[2,6],103:82,104:[1,63],106:[1,64],109:83,110:[1,66],111:67,126:[1,81],128:[1,75],129:[1,74],132:[1,73],133:[1,76],134:[1,77],135:[1,78],136:[1,79],137:[1,80]},{1:[2,7],6:[2,7],26:[2,7],102:[2,7],103:85,104:[1,63],106:[1,64],109:86,110:[1,66],111:67,126:[1,84]},{1:[2,11],6:[2,11],25:[2,11],26:[2,11],49:[2,11],54:[2,11],57:[2,11],62:88,66:[1,90],67:[1,91],68:[1,92],69:[1,93],70:94,71:[1,95],73:[2,11],74:[1,96],78:[2,11],81:87,84:[1,89],85:[2,107],86:[2,11],91:[2,11],93:[2,11],102:[2,11],104:[2,11],105:[2,11],106:[2,11],110:[2,11],118:[2,11],126:[2,11],128:[2,11],129:[2,11],132:[2,11],133:[2,11],134:[2,11],135:[2,11],136:[2,11],137:[2,11]},{1:[2,12],6:[2,12],25:[2,12],26:[2,12],49:[2,12],54:[2,12],57:[2,12],62:98,66:[1,90],67:[1,91],68:[1,92],69:[1,93],70:94,71:[1,95],73:[2,12],74:[1,96],78:[2,12],81:97,84:[1,89],85:[2,107],86:[2,12],91:[2,12],93:[2,12],102:[2,12],104:[2,12],105:[2,12],106:[2,12],110:[2,12],118:[2,12],126:[2,12],128:[2,12],129:[2,12],132:[2,12],133:[2,12],134:[2,12],135:[2,12],136:[2,12],137:[2,12]},{1:[2,13],6:[2,13],25:[2,13],26:[2,13],49:[2,13],54:[2,13],57:[2,13],73:[2,13],78:[2,13],86:[2,13],91:[2,13],93:[2,13],102:[2,13],104:[2,13],105:[2,13],106:[2,13],110:[2,13],118:[2,13],126:[2,13],128:[2,13],129:[2,13],132:[2,13],133:[2,13],134:[2,13],135:[2,13],136:[2,13],137:[2,13]},{1:[2,14],6:[2,14],25:[2,14],26:[2,14],49:[2,14],54:[2,14],57:[2,14],73:[2,14],78:[2,14],86:[2,14],91:[2,14],93:[2,14],102:[2,14],104:[2,14],105:[2,14],106:[2,14],110:[2,14],118:[2,14],126:[2,14],128:[2,14],129:[2,14],132:[2,14],133:[2,14],134:[2,14],135:[2,14],136:[2,14],137:[2,14]},{1:[2,15],6:[2,15],25:[2,15],26:[2,15],49:[2,15],54:[2,15],57:[2,15],73:[2,15],78:[2,15],86:[2,15],91:[2,15],93:[2,15],102:[2,15],104:[2,15],105:[2,15],106:[2,15],110:[2,15],118:[2,15],126:[2,15],128:[2,15],129:[2,15],132:[2,15],133:[2,15],134:[2,15],135:[2,15],136:[2,15],137:[2,15]},{1:[2,16],6:[2,16],25:[2,16],26:[2,16],49:[2,16],54:[2,16],57:[2,16],73:[2,16],78:[2,16],86:[2,16],91:[2,16],93:[2,16],102:[2,16],104:[2,16],105:[2,16],106:[2,16],110:[2,16],118:[2,16],126:[2,16],128:[2,16],129:[2,16],132:[2,16],133:[2,16],134:[2,16],135:[2,16],136:[2,16],137:[2,16]},{1:[2,17],6:[2,17],25:[2,17],26:[2,17],49:[2,17],54:[2,17],57:[2,17],73:[2,17],78:[2,17],86:[2,17],91:[2,17],93:[2,17],102:[2,17],104:[2,17],105:[2,17],106:[2,17],110:[2,17],118:[2,17],126:[2,17],128:[2,17],129:[2,17],132:[2,17],133:[2,17],134:[2,17],135:[2,17],136:[2,17],137:[2,17]},{1:[2,18],6:[2,18],25:[2,18],26:[2,18],49:[2,18],54:[2,18],57:[2,18],73:[2,18],78:[2,18],86:[2,18],91:[2,18],93:[2,18],102:[2,18],104:[2,18],105:[2,18],106:[2,18],110:[2,18],118:[2,18],126:[2,18],128:[2,18],129:[2,18],132:[2,18],133:[2,18],134:[2,18],135:[2,18],136:[2,18],137:[2,18]},{1:[2,19],6:[2,19],25:[2,19],26:[2,19],49:[2,19],54:[2,19],57:[2,19],73:[2,19],78:[2,19],86:[2,19],91:[2,19],93:[2,19],102:[2,19],104:[2,19],105:[2,19],106:[2,19],110:[2,19],118:[2,19],126:[2,19],128:[2,19],129:[2,19],132:[2,19],133:[2,19],134:[2,19],135:[2,19],136:[2,19],137:[2,19]},{1:[2,20],6:[2,20],25:[2,20],26:[2,20],49:[2,20],54:[2,20],57:[2,20],73:[2,20],78:[2,20],86:[2,20],91:[2,20],93:[2,20],102:[2,20],104:[2,20],105:[2,20],106:[2,20],110:[2,20],118:[2,20],126:[2,20],128:[2,20],129:[2,20],132:[2,20],133:[2,20],134:[2,20],135:[2,20],136:[2,20],137:[2,20]},{1:[2,21],6:[2,21],25:[2,21],26:[2,21],49:[2,21],54:[2,21],57:[2,21],73:[2,21],78:[2,21],86:[2,21],91:[2,21],93:[2,21],102:[2,21],104:[2,21],105:[2,21],106:[2,21],110:[2,21],118:[2,21],126:[2,21],128:[2,21],129:[2,21],132:[2,21],133:[2,21],134:[2,21],135:[2,21],136:[2,21],137:[2,21]},{1:[2,22],6:[2,22],25:[2,22],26:[2,22],49:[2,22],54:[2,22],57:[2,22],73:[2,22],78:[2,22],86:[2,22],91:[2,22],93:[2,22],102:[2,22],104:[2,22],105:[2,22],106:[2,22],110:[2,22],118:[2,22],126:[2,22],128:[2,22],129:[2,22],132:[2,22],133:[2,22],134:[2,22],135:[2,22],136:[2,22],137:[2,22]},{1:[2,8],6:[2,8],26:[2,8],102:[2,8],104:[2,8],106:[2,8],110:[2,8],126:[2,8]},{1:[2,9],6:[2,9],26:[2,9],102:[2,9],104:[2,9],106:[2,9],110:[2,9],126:[2,9]},{1:[2,10],6:[2,10],26:[2,10],102:[2,10],104:[2,10],106:[2,10],110:[2,10],126:[2,10]},{1:[2,74],6:[2,74],25:[2,74],26:[2,74],40:[1,99],49:[2,74],54:[2,74],57:[2,74],66:[2,74],67:[2,74],68:[2,74],69:[2,74],71:[2,74],73:[2,74],74:[2,74],78:[2,74],84:[2,74],85:[2,74],86:[2,74],91:[2,74],93:[2,74],102:[2,74],104:[2,74],105:[2,74],106:[2,74],110:[2,74],118:[2,74],126:[2,74],128:[2,74],129:[2,74],132:[2,74],133:[2,74],134:[2,74],135:[2,74],136:[2,74],137:[2,74]},{1:[2,75],6:[2,75],25:[2,75],26:[2,75],49:[2,75],54:[2,75],57:[2,75],66:[2,75],67:[2,75],68:[2,75],69:[2,75],71:[2,75],73:[2,75],74:[2,75],78:[2,75],84:[2,75],85:[2,75],86:[2,75],91:[2,75],93:[2,75],102:[2,75],104:[2,75],105:[2,75],106:[2,75],110:[2,75],118:[2,75],126:[2,75],128:[2,75],129:[2,75],132:[2,75],133:[2,75],134:[2,75],135:[2,75],136:[2,75],137:[2,75]},{1:[2,76],6:[2,76],25:[2,76],26:[2,76],49:[2,76],54:[2,76],57:[2,76],66:[2,76],67:[2,76],68:[2,76],69:[2,76],71:[2,76],73:[2,76],74:[2,76],78:[2,76],84:[2,76],85:[2,76],86:[2,76],91:[2,76],93:[2,76],102:[2,76],104:[2,76],105:[2,76],106:[2,76],110:[2,76],118:[2,76],126:[2,76],128:[2,76],129:[2,76],132:[2,76],133:[2,76],134:[2,76],135:[2,76],136:[2,76],137:[2,76]},{1:[2,77],6:[2,77],25:[2,77],26:[2,77],49:[2,77],54:[2,77],57:[2,77],66:[2,77],67:[2,77],68:[2,77],69:[2,77],71:[2,77],73:[2,77],74:[2,77],78:[2,77],84:[2,77],85:[2,77],86:[2,77],91:[2,77],93:[2,77],102:[2,77],104:[2,77],105:[2,77],106:[2,77],110:[2,77],118:[2,77],126:[2,77],128:[2,77],129:[2,77],132:[2,77],133:[2,77],134:[2,77],135:[2,77],136:[2,77],137:[2,77]},{1:[2,78],6:[2,78],25:[2,78],26:[2,78],49:[2,78],54:[2,78],57:[2,78],66:[2,78],67:[2,78],68:[2,78],69:[2,78],71:[2,78],73:[2,78],74:[2,78],78:[2,78],84:[2,78],85:[2,78],86:[2,78],91:[2,78],93:[2,78],102:[2,78],104:[2,78],105:[2,78],106:[2,78],110:[2,78],118:[2,78],126:[2,78],128:[2,78],129:[2,78],132:[2,78],133:[2,78],134:[2,78],135:[2,78],136:[2,78],137:[2,78]},{1:[2,105],6:[2,105],25:[2,105],26:[2,105],49:[2,105],54:[2,105],57:[2,105],66:[2,105],67:[2,105],68:[2,105],69:[2,105],71:[2,105],73:[2,105],74:[2,105],78:[2,105],82:100,84:[2,105],85:[1,101],86:[2,105],91:[2,105],93:[2,105],102:[2,105],104:[2,105],105:[2,105],106:[2,105],110:[2,105],118:[2,105],126:[2,105],128:[2,105],129:[2,105],132:[2,105],133:[2,105],134:[2,105],135:[2,105],136:[2,105],137:[2,105]},{6:[2,54],25:[2,54],27:105,28:[1,71],44:106,48:102,49:[2,54],54:[2,54],55:103,56:104,58:107,59:108,76:[1,68],89:[1,109],90:[1,110]},{24:111,25:[1,112]},{7:113,8:114,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,61:34,63:23,64:24,65:25,76:[1,68],79:[1,41],83:[1,26],88:[1,56],89:[1,57],90:[1,55],96:[1,36],100:[1,42],101:[1,54],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{7:115,8:114,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,61:34,63:23,64:24,65:25,76:[1,68],79:[1,41],83:[1,26],88:[1,56],89:[1,57],90:[1,55],96:[1,36],100:[1,42],101:[1,54],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{7:116,8:114,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,61:34,63:23,64:24,65:25,76:[1,68],79:[1,41],83:[1,26],88:[1,56],89:[1,57],90:[1,55],96:[1,36],100:[1,42],101:[1,54],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{12:118,13:119,27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:120,44:61,58:45,59:46,61:117,63:23,64:24,65:25,76:[1,68],83:[1,26],88:[1,56],89:[1,57],90:[1,55],101:[1,54]},{12:118,13:119,27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:120,44:61,58:45,59:46,61:121,63:23,64:24,65:25,76:[1,68],83:[1,26],88:[1,56],89:[1,57],90:[1,55],101:[1,54]},{1:[2,71],6:[2,71],25:[2,71],26:[2,71],40:[2,71],49:[2,71],54:[2,71],57:[2,71],66:[2,71],67:[2,71],68:[2,71],69:[2,71],71:[2,71],73:[2,71],74:[2,71],78:[2,71],80:[1,125],84:[2,71],85:[2,71],86:[2,71],91:[2,71],93:[2,71],102:[2,71],104:[2,71],105:[2,71],106:[2,71],110:[2,71],118:[2,71],126:[2,71],128:[2,71],129:[2,71],130:[1,122],131:[1,123],132:[2,71],133:[2,71],134:[2,71],135:[2,71],136:[2,71],137:[2,71],138:[1,124]},{1:[2,182],6:[2,182],25:[2,182],26:[2,182],49:[2,182],54:[2,182],57:[2,182],73:[2,182],78:[2,182],86:[2,182],91:[2,182],93:[2,182],102:[2,182],104:[2,182],105:[2,182],106:[2,182],110:[2,182],118:[2,182],121:[1,126],126:[2,182],128:[2,182],129:[2,182],132:[2,182],133:[2,182],134:[2,182],135:[2,182],136:[2,182],137:[2,182]},{24:127,25:[1,112]},{24:128,25:[1,112]},{1:[2,149],6:[2,149],25:[2,149],26:[2,149],49:[2,149],54:[2,149],57:[2,149],73:[2,149],78:[2,149],86:[2,149],91:[2,149],93:[2,149],102:[2,149],104:[2,149],105:[2,149],106:[2,149],110:[2,149],118:[2,149],126:[2,149],128:[2,149],129:[2,149],132:[2,149],133:[2,149],134:[2,149],135:[2,149],136:[2,149],137:[2,149]},{24:129,25:[1,112]},{7:130,8:114,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,25:[1,131],27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,61:34,63:23,64:24,65:25,76:[1,68],79:[1,41],83:[1,26],88:[1,56],89:[1,57],90:[1,55],96:[1,36],100:[1,42],101:[1,54],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{1:[2,95],6:[2,95],12:118,13:119,24:132,25:[1,112],26:[2,95],27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:120,44:61,49:[2,95],54:[2,95],57:[2,95],58:45,59:46,61:134,63:23,64:24,65:25,73:[2,95],76:[1,68],78:[2,95],80:[1,133],83:[1,26],86:[2,95],88:[1,56],89:[1,57],90:[1,55],91:[2,95],93:[2,95],101:[1,54],102:[2,95],104:[2,95],105:[2,95],106:[2,95],110:[2,95],118:[2,95],126:[2,95],128:[2,95],129:[2,95],132:[2,95],133:[2,95],134:[2,95],135:[2,95],136:[2,95],137:[2,95]},{7:135,8:114,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,61:34,63:23,64:24,65:25,76:[1,68],79:[1,41],83:[1,26],88:[1,56],89:[1,57],90:[1,55],96:[1,36],100:[1,42],101:[1,54],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{1:[2,46],6:[2,46],7:136,8:114,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,26:[2,46],27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,61:34,63:23,64:24,65:25,76:[1,68],79:[1,41],83:[1,26],88:[1,56],89:[1,57],90:[1,55],96:[1,36],100:[1,42],101:[1,54],102:[2,46],103:37,104:[2,46],106:[2,46],107:38,108:[1,65],109:39,110:[2,46],111:67,119:[1,40],124:35,125:[1,62],126:[2,46],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{1:[2,47],6:[2,47],25:[2,47],26:[2,47],54:[2,47],78:[2,47],102:[2,47],104:[2,47],106:[2,47],110:[2,47],126:[2,47]},{1:[2,72],6:[2,72],25:[2,72],26:[2,72],40:[2,72],49:[2,72],54:[2,72],57:[2,72],66:[2,72],67:[2,72],68:[2,72],69:[2,72],71:[2,72],73:[2,72],74:[2,72],78:[2,72],84:[2,72],85:[2,72],86:[2,72],91:[2,72],93:[2,72],102:[2,72],104:[2,72],105:[2,72],106:[2,72],110:[2,72],118:[2,72],126:[2,72],128:[2,72],129:[2,72],132:[2,72],133:[2,72],134:[2,72],135:[2,72],136:[2,72],137:[2,72]},{1:[2,73],6:[2,73],25:[2,73],26:[2,73],40:[2,73],49:[2,73],54:[2,73],57:[2,73],66:[2,73],67:[2,73],68:[2,73],69:[2,73],71:[2,73],73:[2,73],74:[2,73],78:[2,73],84:[2,73],85:[2,73],86:[2,73],91:[2,73],93:[2,73],102:[2,73],104:[2,73],105:[2,73],106:[2,73],110:[2,73],118:[2,73],126:[2,73],128:[2,73],129:[2,73],132:[2,73],133:[2,73],134:[2,73],135:[2,73],136:[2,73],137:[2,73]},{1:[2,28],6:[2,28],25:[2,28],26:[2,28],49:[2,28],54:[2,28],57:[2,28],66:[2,28],67:[2,28],68:[2,28],69:[2,28],71:[2,28],73:[2,28],74:[2,28],78:[2,28],84:[2,28],85:[2,28],86:[2,28],91:[2,28],93:[2,28],102:[2,28],104:[2,28],105:[2,28],106:[2,28],110:[2,28],118:[2,28],126:[2,28],128:[2,28],129:[2,28],132:[2,28],133:[2,28],134:[2,28],135:[2,28],136:[2,28],137:[2,28]},{1:[2,29],6:[2,29],25:[2,29],26:[2,29],49:[2,29],54:[2,29],57:[2,29],66:[2,29],67:[2,29],68:[2,29],69:[2,29],71:[2,29],73:[2,29],74:[2,29],78:[2,29],84:[2,29],85:[2,29],86:[2,29],91:[2,29],93:[2,29],102:[2,29],104:[2,29],105:[2,29],106:[2,29],110:[2,29],118:[2,29],126:[2,29],128:[2,29],129:[2,29],132:[2,29],133:[2,29],134:[2,29],135:[2,29],136:[2,29],137:[2,29]},{1:[2,30],6:[2,30],25:[2,30],26:[2,30],49:[2,30],54:[2,30],57:[2,30],66:[2,30],67:[2,30],68:[2,30],69:[2,30],71:[2,30],73:[2,30],74:[2,30],78:[2,30],84:[2,30],85:[2,30],86:[2,30],91:[2,30],93:[2,30],102:[2,30],104:[2,30],105:[2,30],106:[2,30],110:[2,30],118:[2,30],126:[2,30],128:[2,30],129:[2,30],132:[2,30],133:[2,30],134:[2,30],135:[2,30],136:[2,30],137:[2,30]},{1:[2,31],6:[2,31],25:[2,31],26:[2,31],49:[2,31],54:[2,31],57:[2,31],66:[2,31],67:[2,31],68:[2,31],69:[2,31],71:[2,31],73:[2,31],74:[2,31],78:[2,31],84:[2,31],85:[2,31],86:[2,31],91:[2,31],93:[2,31],102:[2,31],104:[2,31],105:[2,31],106:[2,31],110:[2,31],118:[2,31],126:[2,31],128:[2,31],129:[2,31],132:[2,31],133:[2,31],134:[2,31],135:[2,31],136:[2,31],137:[2,31]},{1:[2,32],6:[2,32],25:[2,32],26:[2,32],49:[2,32],54:[2,32],57:[2,32],66:[2,32],67:[2,32],68:[2,32],69:[2,32],71:[2,32],73:[2,32],74:[2,32],78:[2,32],84:[2,32],85:[2,32],86:[2,32],91:[2,32],93:[2,32],102:[2,32],104:[2,32],105:[2,32],106:[2,32],110:[2,32],118:[2,32],126:[2,32],128:[2,32],129:[2,32],132:[2,32],133:[2,32],134:[2,32],135:[2,32],136:[2,32],137:[2,32]},{1:[2,33],6:[2,33],25:[2,33],26:[2,33],49:[2,33],54:[2,33],57:[2,33],66:[2,33],67:[2,33],68:[2,33],69:[2,33],71:[2,33],73:[2,33],74:[2,33],78:[2,33],84:[2,33],85:[2,33],86:[2,33],91:[2,33],93:[2,33],102:[2,33],104:[2,33],105:[2,33],106:[2,33],110:[2,33],118:[2,33],126:[2,33],128:[2,33],129:[2,33],132:[2,33],133:[2,33],134:[2,33],135:[2,33],136:[2,33],137:[2,33]},{1:[2,34],6:[2,34],25:[2,34],26:[2,34],49:[2,34],54:[2,34],57:[2,34],66:[2,34],67:[2,34],68:[2,34],69:[2,34],71:[2,34],73:[2,34],74:[2,34],78:[2,34],84:[2,34],85:[2,34],86:[2,34],91:[2,34],93:[2,34],102:[2,34],104:[2,34],105:[2,34],106:[2,34],110:[2,34],118:[2,34],126:[2,34],128:[2,34],129:[2,34],132:[2,34],133:[2,34],134:[2,34],135:[2,34],136:[2,34],137:[2,34]},{4:137,5:3,7:4,8:5,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,25:[1,138],27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,61:34,63:23,64:24,65:25,76:[1,68],79:[1,41],83:[1,26],88:[1,56],89:[1,57],90:[1,55],96:[1,36],100:[1,42],101:[1,54],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{7:139,8:114,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,25:[1,143],27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,60:144,61:34,63:23,64:24,65:25,76:[1,68],79:[1,41],83:[1,26],87:141,88:[1,56],89:[1,57],90:[1,55],91:[1,140],94:142,96:[1,36],100:[1,42],101:[1,54],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{1:[2,111],6:[2,111],25:[2,111],26:[2,111],49:[2,111],54:[2,111],57:[2,111],66:[2,111],67:[2,111],68:[2,111],69:[2,111],71:[2,111],73:[2,111],74:[2,111],78:[2,111],84:[2,111],85:[2,111],86:[2,111],91:[2,111],93:[2,111],102:[2,111],104:[2,111],105:[2,111],106:[2,111],110:[2,111],118:[2,111],126:[2,111],128:[2,111],129:[2,111],132:[2,111],133:[2,111],134:[2,111],135:[2,111],136:[2,111],137:[2,111]},{1:[2,112],6:[2,112],25:[2,112],26:[2,112],27:145,28:[1,71],49:[2,112],54:[2,112],57:[2,112],66:[2,112],67:[2,112],68:[2,112],69:[2,112],71:[2,112],73:[2,112],74:[2,112],78:[2,112],84:[2,112],85:[2,112],86:[2,112],91:[2,112],93:[2,112],102:[2,112],104:[2,112],105:[2,112],106:[2,112],110:[2,112],118:[2,112],126:[2,112],128:[2,112],129:[2,112],132:[2,112],133:[2,112],134:[2,112],135:[2,112],136:[2,112],137:[2,112]},{25:[2,50]},{25:[2,51]},{1:[2,67],6:[2,67],25:[2,67],26:[2,67],40:[2,67],49:[2,67],54:[2,67],57:[2,67],66:[2,67],67:[2,67],68:[2,67],69:[2,67],71:[2,67],73:[2,67],74:[2,67],78:[2,67],80:[2,67],84:[2,67],85:[2,67],86:[2,67],91:[2,67],93:[2,67],102:[2,67],104:[2,67],105:[2,67],106:[2,67],110:[2,67],118:[2,67],126:[2,67],128:[2,67],129:[2,67],130:[2,67],131:[2,67],132:[2,67],133:[2,67],134:[2,67],135:[2,67],136:[2,67],137:[2,67],138:[2,67]},{1:[2,70],6:[2,70],25:[2,70],26:[2,70],40:[2,70],49:[2,70],54:[2,70],57:[2,70],66:[2,70],67:[2,70],68:[2,70],69:[2,70],71:[2,70],73:[2,70],74:[2,70],78:[2,70],80:[2,70],84:[2,70],85:[2,70],86:[2,70],91:[2,70],93:[2,70],102:[2,70],104:[2,70],105:[2,70],106:[2,70],110:[2,70],118:[2,70],126:[2,70],128:[2,70],129:[2,70],130:[2,70],131:[2,70],132:[2,70],133:[2,70],134:[2,70],135:[2,70],136:[2,70],137:[2,70],138:[2,70]},{7:146,8:114,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,61:34,63:23,64:24,65:25,76:[1,68],79:[1,41],83:[1,26],88:[1,56],89:[1,57],90:[1,55],96:[1,36],100:[1,42],101:[1,54],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{7:147,8:114,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,61:34,63:23,64:24,65:25,76:[1,68],79:[1,41],83:[1,26],88:[1,56],89:[1,57],90:[1,55],96:[1,36],100:[1,42],101:[1,54],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{7:148,8:114,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,61:34,63:23,64:24,65:25,76:[1,68],79:[1,41],83:[1,26],88:[1,56],89:[1,57],90:[1,55],96:[1,36],100:[1,42],101:[1,54],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{7:150,8:114,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,24:149,25:[1,112],27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,61:34,63:23,64:24,65:25,76:[1,68],79:[1,41],83:[1,26],88:[1,56],89:[1,57],90:[1,55],96:[1,36],100:[1,42],101:[1,54],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{27:155,28:[1,71],44:156,58:157,59:158,64:151,76:[1,68],89:[1,109],90:[1,55],113:152,114:[1,153],115:154},{112:159,116:[1,160],117:[1,161]},{6:[2,90],10:165,25:[2,90],27:166,28:[1,71],29:167,30:[1,69],31:[1,70],41:163,42:164,44:168,46:[1,44],54:[2,90],77:162,78:[2,90],89:[1,109]},{1:[2,26],6:[2,26],25:[2,26],26:[2,26],43:[2,26],49:[2,26],54:[2,26],57:[2,26],66:[2,26],67:[2,26],68:[2,26],69:[2,26],71:[2,26],73:[2,26],74:[2,26],78:[2,26],84:[2,26],85:[2,26],86:[2,26],91:[2,26],93:[2,26],102:[2,26],104:[2,26],105:[2,26],106:[2,26],110:[2,26],118:[2,26],126:[2,26],128:[2,26],129:[2,26],132:[2,26],133:[2,26],134:[2,26],135:[2,26],136:[2,26],137:[2,26]},{1:[2,27],6:[2,27],25:[2,27],26:[2,27],43:[2,27],49:[2,27],54:[2,27],57:[2,27],66:[2,27],67:[2,27],68:[2,27],69:[2,27],71:[2,27],73:[2,27],74:[2,27],78:[2,27],84:[2,27],85:[2,27],86:[2,27],91:[2,27],93:[2,27],102:[2,27],104:[2,27],105:[2,27],106:[2,27],110:[2,27],118:[2,27],126:[2,27],128:[2,27],129:[2,27],132:[2,27],133:[2,27],134:[2,27],135:[2,27],136:[2,27],137:[2,27]},{1:[2,25],6:[2,25],25:[2,25],26:[2,25],40:[2,25],43:[2,25],49:[2,25],54:[2,25],57:[2,25],66:[2,25],67:[2,25],68:[2,25],69:[2,25],71:[2,25],73:[2,25],74:[2,25],78:[2,25],80:[2,25],84:[2,25],85:[2,25],86:[2,25],91:[2,25],93:[2,25],102:[2,25],104:[2,25],105:[2,25],106:[2,25],110:[2,25],116:[2,25],117:[2,25],118:[2,25],126:[2,25],128:[2,25],129:[2,25],130:[2,25],131:[2,25],132:[2,25],133:[2,25],134:[2,25],135:[2,25],136:[2,25],137:[2,25],138:[2,25]},{1:[2,5],5:169,6:[2,5],7:4,8:5,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,26:[2,5],27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,61:34,63:23,64:24,65:25,76:[1,68],79:[1,41],83:[1,26],88:[1,56],89:[1,57],90:[1,55],96:[1,36],100:[1,42],101:[1,54],102:[2,5],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{1:[2,193],6:[2,193],25:[2,193],26:[2,193],49:[2,193],54:[2,193],57:[2,193],73:[2,193],78:[2,193],86:[2,193],91:[2,193],93:[2,193],102:[2,193],104:[2,193],105:[2,193],106:[2,193],110:[2,193],118:[2,193],126:[2,193],128:[2,193],129:[2,193],132:[2,193],133:[2,193],134:[2,193],135:[2,193],136:[2,193],137:[2,193]},{7:170,8:114,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,61:34,63:23,64:24,65:25,76:[1,68],79:[1,41],83:[1,26],88:[1,56],89:[1,57],90:[1,55],96:[1,36],100:[1,42],101:[1,54],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{7:171,8:114,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,61:34,63:23,64:24,65:25,76:[1,68],79:[1,41],83:[1,26],88:[1,56],89:[1,57],90:[1,55],96:[1,36],100:[1,42],101:[1,54],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{7:172,8:114,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,61:34,63:23,64:24,65:25,76:[1,68],79:[1,41],83:[1,26],88:[1,56],89:[1,57],90:[1,55],96:[1,36],100:[1,42],101:[1,54],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{7:173,8:114,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,61:34,63:23,64:24,65:25,76:[1,68],79:[1,41],83:[1,26],88:[1,56],89:[1,57],90:[1,55],96:[1,36],100:[1,42],101:[1,54],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{7:174,8:114,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,61:34,63:23,64:24,65:25,76:[1,68],79:[1,41],83:[1,26],88:[1,56],89:[1,57],90:[1,55],96:[1,36],100:[1,42],101:[1,54],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{7:175,8:114,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,61:34,63:23,64:24,65:25,76:[1,68],79:[1,41],83:[1,26],88:[1,56],89:[1,57],90:[1,55],96:[1,36],100:[1,42],101:[1,54],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{7:176,8:114,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,61:34,63:23,64:24,65:25,76:[1,68],79:[1,41],83:[1,26],88:[1,56],89:[1,57],90:[1,55],96:[1,36],100:[1,42],101:[1,54],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{7:177,8:114,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,61:34,63:23,64:24,65:25,76:[1,68],79:[1,41],83:[1,26],88:[1,56],89:[1,57],90:[1,55],96:[1,36],100:[1,42],101:[1,54],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{1:[2,148],6:[2,148],25:[2,148],26:[2,148],49:[2,148],54:[2,148],57:[2,148],73:[2,148],78:[2,148],86:[2,148],91:[2,148],93:[2,148],102:[2,148],104:[2,148],105:[2,148],106:[2,148],110:[2,148],118:[2,148],126:[2,148],128:[2,148],129:[2,148],132:[2,148],133:[2,148],134:[2,148],135:[2,148],136:[2,148],137:[2,148]},{1:[2,153],6:[2,153],25:[2,153],26:[2,153],49:[2,153],54:[2,153],57:[2,153],73:[2,153],78:[2,153],86:[2,153],91:[2,153],93:[2,153],102:[2,153],104:[2,153],105:[2,153],106:[2,153],110:[2,153],118:[2,153],126:[2,153],128:[2,153],129:[2,153],132:[2,153],133:[2,153],134:[2,153],135:[2,153],136:[2,153],137:[2,153]},{7:178,8:114,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,61:34,63:23,64:24,65:25,76:[1,68],79:[1,41],83:[1,26],88:[1,56],89:[1,57],90:[1,55],96:[1,36],100:[1,42],101:[1,54],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{1:[2,147],6:[2,147],25:[2,147],26:[2,147],49:[2,147],54:[2,147],57:[2,147],73:[2,147],78:[2,147],86:[2,147],91:[2,147],93:[2,147],102:[2,147],104:[2,147],105:[2,147],106:[2,147],110:[2,147],118:[2,147],126:[2,147],128:[2,147],129:[2,147],132:[2,147],133:[2,147],134:[2,147],135:[2,147],136:[2,147],137:[2,147]},{1:[2,152],6:[2,152],25:[2,152],26:[2,152],49:[2,152],54:[2,152],57:[2,152],73:[2,152],78:[2,152],86:[2,152],91:[2,152],93:[2,152],102:[2,152],104:[2,152],105:[2,152],106:[2,152],110:[2,152],118:[2,152],126:[2,152],128:[2,152],129:[2,152],132:[2,152],133:[2,152],134:[2,152],135:[2,152],136:[2,152],137:[2,152]},{82:179,85:[1,101]},{1:[2,68],6:[2,68],25:[2,68],26:[2,68],40:[2,68],49:[2,68],54:[2,68],57:[2,68],66:[2,68],67:[2,68],68:[2,68],69:[2,68],71:[2,68],73:[2,68],74:[2,68],78:[2,68],80:[2,68],84:[2,68],85:[2,68],86:[2,68],91:[2,68],93:[2,68],102:[2,68],104:[2,68],105:[2,68],106:[2,68],110:[2,68],118:[2,68],126:[2,68],128:[2,68],129:[2,68],130:[2,68],131:[2,68],132:[2,68],133:[2,68],134:[2,68],135:[2,68],136:[2,68],137:[2,68],138:[2,68]},{85:[2,108]},{27:180,28:[1,71]},{27:181,28:[1,71]},{1:[2,83],6:[2,83],25:[2,83],26:[2,83],27:182,28:[1,71],40:[2,83],49:[2,83],54:[2,83],57:[2,83],66:[2,83],67:[2,83],68:[2,83],69:[2,83],71:[2,83],73:[2,83],74:[2,83],78:[2,83],80:[2,83],84:[2,83],85:[2,83],86:[2,83],91:[2,83],93:[2,83],102:[2,83],104:[2,83],105:[2,83],106:[2,83],110:[2,83],118:[2,83],126:[2,83],128:[2,83],129:[2,83],130:[2,83],131:[2,83],132:[2,83],133:[2,83],134:[2,83],135:[2,83],136:[2,83],137:[2,83],138:[2,83]},{27:183,28:[1,71]},{1:[2,84],6:[2,84],25:[2,84],26:[2,84],40:[2,84],49:[2,84],54:[2,84],57:[2,84],66:[2,84],67:[2,84],68:[2,84],69:[2,84],71:[2,84],73:[2,84],74:[2,84],78:[2,84],80:[2,84],84:[2,84],85:[2,84],86:[2,84],91:[2,84],93:[2,84],102:[2,84],104:[2,84],105:[2,84],106:[2,84],110:[2,84],118:[2,84],126:[2,84],128:[2,84],129:[2,84],130:[2,84],131:[2,84],132:[2,84],133:[2,84],134:[2,84],135:[2,84],136:[2,84],137:[2,84],138:[2,84]},{7:185,8:114,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],57:[1,189],58:45,59:46,61:34,63:23,64:24,65:25,72:184,75:186,76:[1,68],79:[1,41],83:[1,26],88:[1,56],89:[1,57],90:[1,55],92:187,93:[1,188],96:[1,36],100:[1,42],101:[1,54],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{70:190,71:[1,95],74:[1,96]},{82:191,85:[1,101]},{1:[2,69],6:[2,69],25:[2,69],26:[2,69],40:[2,69],49:[2,69],54:[2,69],57:[2,69],66:[2,69],67:[2,69],68:[2,69],69:[2,69],71:[2,69],73:[2,69],74:[2,69],78:[2,69],80:[2,69],84:[2,69],85:[2,69],86:[2,69],91:[2,69],93:[2,69],102:[2,69],104:[2,69],105:[2,69],106:[2,69],110:[2,69],118:[2,69],126:[2,69],128:[2,69],129:[2,69],130:[2,69],131:[2,69],132:[2,69],133:[2,69],134:[2,69],135:[2,69],136:[2,69],137:[2,69],138:[2,69]},{6:[1,193],7:192,8:114,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,25:[1,194],27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,61:34,63:23,64:24,65:25,76:[1,68],79:[1,41],83:[1,26],88:[1,56],89:[1,57],90:[1,55],96:[1,36],100:[1,42],101:[1,54],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{1:[2,106],6:[2,106],25:[2,106],26:[2,106],49:[2,106],54:[2,106],57:[2,106],66:[2,106],67:[2,106],68:[2,106],69:[2,106],71:[2,106],73:[2,106],74:[2,106],78:[2,106],84:[2,106],85:[2,106],86:[2,106],91:[2,106],93:[2,106],102:[2,106],104:[2,106],105:[2,106],106:[2,106],110:[2,106],118:[2,106],126:[2,106],128:[2,106],129:[2,106],132:[2,106],133:[2,106],134:[2,106],135:[2,106],136:[2,106],137:[2,106]},{7:197,8:114,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,25:[1,143],27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,60:144,61:34,63:23,64:24,65:25,76:[1,68],79:[1,41],83:[1,26],86:[1,195],87:196,88:[1,56],89:[1,57],90:[1,55],94:142,96:[1,36],100:[1,42],101:[1,54],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{6:[2,52],25:[2,52],49:[1,198],53:200,54:[1,199]},{6:[2,55],25:[2,55],26:[2,55],49:[2,55],54:[2,55]},{6:[2,59],25:[2,59],26:[2,59],40:[1,202],49:[2,59],54:[2,59],57:[1,201]},{6:[2,62],25:[2,62],26:[2,62],40:[2,62],49:[2,62],54:[2,62],57:[2,62]},{6:[2,63],25:[2,63],26:[2,63],40:[2,63],49:[2,63],54:[2,63],57:[2,63]},{6:[2,64],25:[2,64],26:[2,64],40:[2,64],49:[2,64],54:[2,64],57:[2,64]},{6:[2,65],25:[2,65],26:[2,65],40:[2,65],49:[2,65],54:[2,65],57:[2,65]},{27:145,28:[1,71]},{7:197,8:114,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,25:[1,143],27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,60:144,61:34,63:23,64:24,65:25,76:[1,68],79:[1,41],83:[1,26],87:141,88:[1,56],89:[1,57],90:[1,55],91:[1,140],94:142,96:[1,36],100:[1,42],101:[1,54],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{1:[2,49],6:[2,49],25:[2,49],26:[2,49],49:[2,49],54:[2,49],57:[2,49],73:[2,49],78:[2,49],86:[2,49],91:[2,49],93:[2,49],102:[2,49],104:[2,49],105:[2,49],106:[2,49],110:[2,49],118:[2,49],126:[2,49],128:[2,49],129:[2,49],132:[2,49],133:[2,49],134:[2,49],135:[2,49],136:[2,49],137:[2,49]},{4:204,5:3,7:4,8:5,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,26:[1,203],27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,61:34,63:23,64:24,65:25,76:[1,68],79:[1,41],83:[1,26],88:[1,56],89:[1,57],90:[1,55],96:[1,36],100:[1,42],101:[1,54],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{1:[2,186],6:[2,186],25:[2,186],26:[2,186],49:[2,186],54:[2,186],57:[2,186],73:[2,186],78:[2,186],86:[2,186],91:[2,186],93:[2,186],102:[2,186],103:82,104:[2,186],105:[2,186],106:[2,186],109:83,110:[2,186],111:67,118:[2,186],126:[2,186],128:[2,186],129:[2,186],132:[1,73],133:[2,186],134:[2,186],135:[2,186],136:[2,186],137:[2,186]},{103:85,104:[1,63],106:[1,64],109:86,110:[1,66],111:67,126:[1,84]},{1:[2,187],6:[2,187],25:[2,187],26:[2,187],49:[2,187],54:[2,187],57:[2,187],73:[2,187],78:[2,187],86:[2,187],91:[2,187],93:[2,187],102:[2,187],103:82,104:[2,187],105:[2,187],106:[2,187],109:83,110:[2,187],111:67,118:[2,187],126:[2,187],128:[2,187],129:[2,187],132:[1,73],133:[2,187],134:[2,187],135:[2,187],136:[2,187],137:[2,187]},{1:[2,188],6:[2,188],25:[2,188],26:[2,188],49:[2,188],54:[2,188],57:[2,188],73:[2,188],78:[2,188],86:[2,188],91:[2,188],93:[2,188],102:[2,188],103:82,104:[2,188],105:[2,188],106:[2,188],109:83,110:[2,188],111:67,118:[2,188],126:[2,188],128:[2,188],129:[2,188],132:[1,73],133:[2,188],134:[2,188],135:[2,188],136:[2,188],137:[2,188]},{1:[2,189],6:[2,189],25:[2,189],26:[2,189],49:[2,189],54:[2,189],57:[2,189],66:[2,71],67:[2,71],68:[2,71],69:[2,71],71:[2,71],73:[2,189],74:[2,71],78:[2,189],84:[2,71],85:[2,71],86:[2,189],91:[2,189],93:[2,189],102:[2,189],104:[2,189],105:[2,189],106:[2,189],110:[2,189],118:[2,189],126:[2,189],128:[2,189],129:[2,189],132:[2,189],133:[2,189],134:[2,189],135:[2,189],136:[2,189],137:[2,189]},{62:88,66:[1,90],67:[1,91],68:[1,92],69:[1,93],70:94,71:[1,95],74:[1,96],81:87,84:[1,89],85:[2,107]},{62:98,66:[1,90],67:[1,91],68:[1,92],69:[1,93],70:94,71:[1,95],74:[1,96],81:97,84:[1,89],85:[2,107]},{66:[2,74],67:[2,74],68:[2,74],69:[2,74],71:[2,74],74:[2,74],84:[2,74],85:[2,74]},{1:[2,190],6:[2,190],25:[2,190],26:[2,190],49:[2,190],54:[2,190],57:[2,190],66:[2,71],67:[2,71],68:[2,71],69:[2,71],71:[2,71],73:[2,190],74:[2,71],78:[2,190],84:[2,71],85:[2,71],86:[2,190],91:[2,190],93:[2,190],102:[2,190],104:[2,190],105:[2,190],106:[2,190],110:[2,190],118:[2,190],126:[2,190],128:[2,190],129:[2,190],132:[2,190],133:[2,190],134:[2,190],135:[2,190],136:[2,190],137:[2,190]},{1:[2,191],6:[2,191],25:[2,191],26:[2,191],49:[2,191],54:[2,191],57:[2,191],73:[2,191],78:[2,191],86:[2,191],91:[2,191],93:[2,191],102:[2,191],104:[2,191],105:[2,191],106:[2,191],110:[2,191],118:[2,191],126:[2,191],128:[2,191],129:[2,191],132:[2,191],133:[2,191],134:[2,191],135:[2,191],136:[2,191],137:[2,191]},{1:[2,192],6:[2,192],25:[2,192],26:[2,192],49:[2,192],54:[2,192],57:[2,192],73:[2,192],78:[2,192],86:[2,192],91:[2,192],93:[2,192],102:[2,192],104:[2,192],105:[2,192],106:[2,192],110:[2,192],118:[2,192],126:[2,192],128:[2,192],129:[2,192],132:[2,192],133:[2,192],134:[2,192],135:[2,192],136:[2,192],137:[2,192]},{6:[1,207],7:205,8:114,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,25:[1,206],27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,61:34,63:23,64:24,65:25,76:[1,68],79:[1,41],83:[1,26],88:[1,56],89:[1,57],90:[1,55],96:[1,36],100:[1,42],101:[1,54],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{7:208,8:114,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,61:34,63:23,64:24,65:25,76:[1,68],79:[1,41],83:[1,26],88:[1,56],89:[1,57],90:[1,55],96:[1,36],100:[1,42],101:[1,54],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{24:209,25:[1,112],125:[1,210]},{1:[2,132],6:[2,132],25:[2,132],26:[2,132],49:[2,132],54:[2,132],57:[2,132],73:[2,132],78:[2,132],86:[2,132],91:[2,132],93:[2,132],97:211,98:[1,212],99:[1,213],102:[2,132],104:[2,132],105:[2,132],106:[2,132],110:[2,132],118:[2,132],126:[2,132],128:[2,132],129:[2,132],132:[2,132],133:[2,132],134:[2,132],135:[2,132],136:[2,132],137:[2,132]},{1:[2,146],6:[2,146],25:[2,146],26:[2,146],49:[2,146],54:[2,146],57:[2,146],73:[2,146],78:[2,146],86:[2,146],91:[2,146],93:[2,146],102:[2,146],104:[2,146],105:[2,146],106:[2,146],110:[2,146],118:[2,146],126:[2,146],128:[2,146],129:[2,146],132:[2,146],133:[2,146],134:[2,146],135:[2,146],136:[2,146],137:[2,146]},{1:[2,154],6:[2,154],25:[2,154],26:[2,154],49:[2,154],54:[2,154],57:[2,154],73:[2,154],78:[2,154],86:[2,154],91:[2,154],93:[2,154],102:[2,154],104:[2,154],105:[2,154],106:[2,154],110:[2,154],118:[2,154],126:[2,154],128:[2,154],129:[2,154],132:[2,154],133:[2,154],134:[2,154],135:[2,154],136:[2,154],137:[2,154]},{25:[1,214],103:82,104:[1,63],106:[1,64],109:83,110:[1,66],111:67,126:[1,81],128:[1,75],129:[1,74],132:[1,73],133:[1,76],134:[1,77],135:[1,78],136:[1,79],137:[1,80]},{120:215,122:216,123:[1,217]},{1:[2,96],6:[2,96],25:[2,96],26:[2,96],49:[2,96],54:[2,96],57:[2,96],73:[2,96],78:[2,96],86:[2,96],91:[2,96],93:[2,96],102:[2,96],104:[2,96],105:[2,96],106:[2,96],110:[2,96],118:[2,96],126:[2,96],128:[2,96],129:[2,96],132:[2,96],133:[2,96],134:[2,96],135:[2,96],136:[2,96],137:[2,96]},{7:218,8:114,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,61:34,63:23,64:24,65:25,76:[1,68],79:[1,41],83:[1,26],88:[1,56],89:[1,57],90:[1,55],96:[1,36],100:[1,42],101:[1,54],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{1:[2,99],6:[2,99],24:219,25:[1,112],26:[2,99],49:[2,99],54:[2,99],57:[2,99],66:[2,71],67:[2,71],68:[2,71],69:[2,71],71:[2,71],73:[2,99],74:[2,71],78:[2,99],80:[1,220],84:[2,71],85:[2,71],86:[2,99],91:[2,99],93:[2,99],102:[2,99],104:[2,99],105:[2,99],106:[2,99],110:[2,99],118:[2,99],126:[2,99],128:[2,99],129:[2,99],132:[2,99],133:[2,99],134:[2,99],135:[2,99],136:[2,99],137:[2,99]},{1:[2,139],6:[2,139],25:[2,139],26:[2,139],49:[2,139],54:[2,139],57:[2,139],73:[2,139],78:[2,139],86:[2,139],91:[2,139],93:[2,139],102:[2,139],103:82,104:[2,139],105:[2,139],106:[2,139],109:83,110:[2,139],111:67,118:[2,139],126:[2,139],128:[1,75],129:[1,74],132:[1,73],133:[1,76],134:[1,77],135:[1,78],136:[1,79],137:[1,80]},{1:[2,45],6:[2,45],26:[2,45],102:[2,45],103:82,104:[2,45],106:[2,45],109:83,110:[2,45],111:67,126:[2,45],128:[1,75],129:[1,74],132:[1,73],133:[1,76],134:[1,77],135:[1,78],136:[1,79],137:[1,80]},{6:[1,72],102:[1,221]},{4:222,5:3,7:4,8:5,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,61:34,63:23,64:24,65:25,76:[1,68],79:[1,41],83:[1,26],88:[1,56],89:[1,57],90:[1,55],96:[1,36],100:[1,42],101:[1,54],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{6:[2,128],25:[2,128],54:[2,128],57:[1,224],91:[2,128],92:223,93:[1,188],103:82,104:[1,63],106:[1,64],109:83,110:[1,66],111:67,126:[1,81],128:[1,75],129:[1,74],132:[1,73],133:[1,76],134:[1,77],135:[1,78],136:[1,79],137:[1,80]},{1:[2,114],6:[2,114],25:[2,114],26:[2,114],40:[2,114],49:[2,114],54:[2,114],57:[2,114],66:[2,114],67:[2,114],68:[2,114],69:[2,114],71:[2,114],73:[2,114],74:[2,114],78:[2,114],84:[2,114],85:[2,114],86:[2,114],91:[2,114],93:[2,114],102:[2,114],104:[2,114],105:[2,114],106:[2,114],110:[2,114],116:[2,114],117:[2,114],118:[2,114],126:[2,114],128:[2,114],129:[2,114],132:[2,114],133:[2,114],134:[2,114],135:[2,114],136:[2,114],137:[2,114]},{6:[2,52],25:[2,52],53:225,54:[1,226],91:[2,52]},{6:[2,123],25:[2,123],26:[2,123],54:[2,123],86:[2,123],91:[2,123]},{7:197,8:114,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,25:[1,143],27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,60:144,61:34,63:23,64:24,65:25,76:[1,68],79:[1,41],83:[1,26],87:227,88:[1,56],89:[1,57],90:[1,55],94:142,96:[1,36],100:[1,42],101:[1,54],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{6:[2,129],25:[2,129],26:[2,129],54:[2,129],86:[2,129],91:[2,129]},{1:[2,113],6:[2,113],25:[2,113],26:[2,113],40:[2,113],43:[2,113],49:[2,113],54:[2,113],57:[2,113],66:[2,113],67:[2,113],68:[2,113],69:[2,113],71:[2,113],73:[2,113],74:[2,113],78:[2,113],80:[2,113],84:[2,113],85:[2,113],86:[2,113],91:[2,113],93:[2,113],102:[2,113],104:[2,113],105:[2,113],106:[2,113],110:[2,113],116:[2,113],117:[2,113],118:[2,113],126:[2,113],128:[2,113],129:[2,113],130:[2,113],131:[2,113],132:[2,113],133:[2,113],134:[2,113],135:[2,113],136:[2,113],137:[2,113],138:[2,113]},{24:228,25:[1,112],103:82,104:[1,63],106:[1,64],109:83,110:[1,66],111:67,126:[1,81],128:[1,75],129:[1,74],132:[1,73],133:[1,76],134:[1,77],135:[1,78],136:[1,79],137:[1,80]},{1:[2,142],6:[2,142],25:[2,142],26:[2,142],49:[2,142],54:[2,142],57:[2,142],73:[2,142],78:[2,142],86:[2,142],91:[2,142],93:[2,142],102:[2,142],103:82,104:[1,63],105:[1,229],106:[1,64],109:83,110:[1,66],111:67,118:[2,142],126:[2,142],128:[1,75],129:[1,74],132:[1,73],133:[1,76],134:[1,77],135:[1,78],136:[1,79],137:[1,80]},{1:[2,144],6:[2,144],25:[2,144],26:[2,144],49:[2,144],54:[2,144],57:[2,144],73:[2,144],78:[2,144],86:[2,144],91:[2,144],93:[2,144],102:[2,144],103:82,104:[1,63],105:[1,230],106:[1,64],109:83,110:[1,66],111:67,118:[2,144],126:[2,144],128:[1,75],129:[1,74],132:[1,73],133:[1,76],134:[1,77],135:[1,78],136:[1,79],137:[1,80]},{1:[2,150],6:[2,150],25:[2,150],26:[2,150],49:[2,150],54:[2,150],57:[2,150],73:[2,150],78:[2,150],86:[2,150],91:[2,150],93:[2,150],102:[2,150],104:[2,150],105:[2,150],106:[2,150],110:[2,150],118:[2,150],126:[2,150],128:[2,150],129:[2,150],132:[2,150],133:[2,150],134:[2,150],135:[2,150],136:[2,150],137:[2,150]},{1:[2,151],6:[2,151],25:[2,151],26:[2,151],49:[2,151],54:[2,151],57:[2,151],73:[2,151],78:[2,151],86:[2,151],91:[2,151],93:[2,151],102:[2,151],103:82,104:[1,63],105:[2,151],106:[1,64],109:83,110:[1,66],111:67,118:[2,151],126:[2,151],128:[1,75],129:[1,74],132:[1,73],133:[1,76],134:[1,77],135:[1,78],136:[1,79],137:[1,80]},{1:[2,155],6:[2,155],25:[2,155],26:[2,155],49:[2,155],54:[2,155],57:[2,155],73:[2,155],78:[2,155],86:[2,155],91:[2,155],93:[2,155],102:[2,155],104:[2,155],105:[2,155],106:[2,155],110:[2,155],118:[2,155],126:[2,155],128:[2,155],129:[2,155],132:[2,155],133:[2,155],134:[2,155],135:[2,155],136:[2,155],137:[2,155]},{116:[2,157],117:[2,157]},{27:155,28:[1,71],44:156,58:157,59:158,76:[1,68],89:[1,109],90:[1,110],113:231,115:154},{54:[1,232],116:[2,163],117:[2,163]},{54:[2,159],116:[2,159],117:[2,159]},{54:[2,160],116:[2,160],117:[2,160]},{54:[2,161],116:[2,161],117:[2,161]},{54:[2,162],116:[2,162],117:[2,162]},{1:[2,156],6:[2,156],25:[2,156],26:[2,156],49:[2,156],54:[2,156],57:[2,156],73:[2,156],78:[2,156],86:[2,156],91:[2,156],93:[2,156],102:[2,156],104:[2,156],105:[2,156],106:[2,156],110:[2,156],118:[2,156],126:[2,156],128:[2,156],129:[2,156],132:[2,156],133:[2,156],134:[2,156],135:[2,156],136:[2,156],137:[2,156]},{7:233,8:114,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,61:34,63:23,64:24,65:25,76:[1,68],79:[1,41],83:[1,26],88:[1,56],89:[1,57],90:[1,55],96:[1,36],100:[1,42],101:[1,54],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{7:234,8:114,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,61:34,63:23,64:24,65:25,76:[1,68],79:[1,41],83:[1,26],88:[1,56],89:[1,57],90:[1,55],96:[1,36],100:[1,42],101:[1,54],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{6:[2,52],25:[2,52],53:235,54:[1,236],78:[2,52]},{6:[2,91],25:[2,91],26:[2,91],54:[2,91],78:[2,91]},{6:[2,38],25:[2,38],26:[2,38],43:[1,237],54:[2,38],78:[2,38]},{6:[2,41],25:[2,41],26:[2,41],54:[2,41],78:[2,41]},{6:[2,42],25:[2,42],26:[2,42],43:[2,42],54:[2,42],78:[2,42]},{6:[2,43],25:[2,43],26:[2,43],43:[2,43],54:[2,43],78:[2,43]},{6:[2,44],25:[2,44],26:[2,44],43:[2,44],54:[2,44],78:[2,44]},{1:[2,4],6:[2,4],26:[2,4],102:[2,4]},{1:[2,194],6:[2,194],25:[2,194],26:[2,194],49:[2,194],54:[2,194],57:[2,194],73:[2,194],78:[2,194],86:[2,194],91:[2,194],93:[2,194],102:[2,194],103:82,104:[2,194],105:[2,194],106:[2,194],109:83,110:[2,194],111:67,118:[2,194],126:[2,194],128:[2,194],129:[2,194],132:[1,73],133:[1,76],134:[2,194],135:[2,194],136:[2,194],137:[2,194]},{1:[2,195],6:[2,195],25:[2,195],26:[2,195],49:[2,195],54:[2,195],57:[2,195],73:[2,195],78:[2,195],86:[2,195],91:[2,195],93:[2,195],102:[2,195],103:82,104:[2,195],105:[2,195],106:[2,195],109:83,110:[2,195],111:67,118:[2,195],126:[2,195],128:[2,195],129:[2,195],132:[1,73],133:[1,76],134:[2,195],135:[2,195],136:[2,195],137:[2,195]},{1:[2,196],6:[2,196],25:[2,196],26:[2,196],49:[2,196],54:[2,196],57:[2,196],73:[2,196],78:[2,196],86:[2,196],91:[2,196],93:[2,196],102:[2,196],103:82,104:[2,196],105:[2,196],106:[2,196],109:83,110:[2,196],111:67,118:[2,196],126:[2,196],128:[2,196],129:[2,196],132:[1,73],133:[2,196],134:[2,196],135:[2,196],136:[2,196],137:[2,196]},{1:[2,197],6:[2,197],25:[2,197],26:[2,197],49:[2,197],54:[2,197],57:[2,197],73:[2,197],78:[2,197],86:[2,197],91:[2,197],93:[2,197],102:[2,197],103:82,104:[2,197],105:[2,197],106:[2,197],109:83,110:[2,197],111:67,118:[2,197],126:[2,197],128:[1,75],129:[1,74],132:[1,73],133:[1,76],134:[2,197],135:[2,197],136:[2,197],137:[2,197]},{1:[2,198],6:[2,198],25:[2,198],26:[2,198],49:[2,198],54:[2,198],57:[2,198],73:[2,198],78:[2,198],86:[2,198],91:[2,198],93:[2,198],102:[2,198],103:82,104:[2,198],105:[2,198],106:[2,198],109:83,110:[2,198],111:67,118:[2,198],126:[2,198],128:[1,75],129:[1,74],132:[1,73],133:[1,76],134:[1,77],135:[2,198],136:[2,198],137:[1,80]},{1:[2,199],6:[2,199],25:[2,199],26:[2,199],49:[2,199],54:[2,199],57:[2,199],73:[2,199],78:[2,199],86:[2,199],91:[2,199],93:[2,199],102:[2,199],103:82,104:[2,199],105:[2,199],106:[2,199],109:83,110:[2,199],111:67,118:[2,199],126:[2,199],128:[1,75],129:[1,74],132:[1,73],133:[1,76],134:[1,77],135:[1,78],136:[2,199],137:[1,80]},{1:[2,200],6:[2,200],25:[2,200],26:[2,200],49:[2,200],54:[2,200],57:[2,200],73:[2,200],78:[2,200],86:[2,200],91:[2,200],93:[2,200],102:[2,200],103:82,104:[2,200],105:[2,200],106:[2,200],109:83,110:[2,200],111:67,118:[2,200],126:[2,200],128:[1,75],129:[1,74],132:[1,73],133:[1,76],134:[1,77],135:[2,200],136:[2,200],137:[2,200]},{1:[2,185],6:[2,185],25:[2,185],26:[2,185],49:[2,185],54:[2,185],57:[2,185],73:[2,185],78:[2,185],86:[2,185],91:[2,185],93:[2,185],102:[2,185],103:82,104:[1,63],105:[2,185],106:[1,64],109:83,110:[1,66],111:67,118:[2,185],126:[1,81],128:[1,75],129:[1,74],132:[1,73],133:[1,76],134:[1,77],135:[1,78],136:[1,79],137:[1,80]},{1:[2,184],6:[2,184],25:[2,184],26:[2,184],49:[2,184],54:[2,184],57:[2,184],73:[2,184],78:[2,184],86:[2,184],91:[2,184],93:[2,184],102:[2,184],103:82,104:[1,63],105:[2,184],106:[1,64],109:83,110:[1,66],111:67,118:[2,184],126:[1,81],128:[1,75],129:[1,74],132:[1,73],133:[1,76],134:[1,77],135:[1,78],136:[1,79],137:[1,80]},{1:[2,103],6:[2,103],25:[2,103],26:[2,103],49:[2,103],54:[2,103],57:[2,103],66:[2,103],67:[2,103],68:[2,103],69:[2,103],71:[2,103],73:[2,103],74:[2,103],78:[2,103],84:[2,103],85:[2,103],86:[2,103],91:[2,103],93:[2,103],102:[2,103],104:[2,103],105:[2,103],106:[2,103],110:[2,103],118:[2,103],126:[2,103],128:[2,103],129:[2,103],132:[2,103],133:[2,103],134:[2,103],135:[2,103],136:[2,103],137:[2,103]},{1:[2,79],6:[2,79],25:[2,79],26:[2,79],40:[2,79],49:[2,79],54:[2,79],57:[2,79],66:[2,79],67:[2,79],68:[2,79],69:[2,79],71:[2,79],73:[2,79],74:[2,79],78:[2,79],80:[2,79],84:[2,79],85:[2,79],86:[2,79],91:[2,79],93:[2,79],102:[2,79],104:[2,79],105:[2,79],106:[2,79],110:[2,79],118:[2,79],126:[2,79],128:[2,79],129:[2,79],130:[2,79],131:[2,79],132:[2,79],133:[2,79],134:[2,79],135:[2,79],136:[2,79],137:[2,79],138:[2,79]},{1:[2,80],6:[2,80],25:[2,80],26:[2,80],40:[2,80],49:[2,80],54:[2,80],57:[2,80],66:[2,80],67:[2,80],68:[2,80],69:[2,80],71:[2,80],73:[2,80],74:[2,80],78:[2,80],80:[2,80],84:[2,80],85:[2,80],86:[2,80],91:[2,80],93:[2,80],102:[2,80],104:[2,80],105:[2,80],106:[2,80],110:[2,80],118:[2,80],126:[2,80],128:[2,80],129:[2,80],130:[2,80],131:[2,80],132:[2,80],133:[2,80],134:[2,80],135:[2,80],136:[2,80],137:[2,80],138:[2,80]},{1:[2,81],6:[2,81],25:[2,81],26:[2,81],40:[2,81],49:[2,81],54:[2,81],57:[2,81],66:[2,81],67:[2,81],68:[2,81],69:[2,81],71:[2,81],73:[2,81],74:[2,81],78:[2,81],80:[2,81],84:[2,81],85:[2,81],86:[2,81],91:[2,81],93:[2,81],102:[2,81],104:[2,81],105:[2,81],106:[2,81],110:[2,81],118:[2,81],126:[2,81],128:[2,81],129:[2,81],130:[2,81],131:[2,81],132:[2,81],133:[2,81],134:[2,81],135:[2,81],136:[2,81],137:[2,81],138:[2,81]},{1:[2,82],6:[2,82],25:[2,82],26:[2,82],40:[2,82],49:[2,82],54:[2,82],57:[2,82],66:[2,82],67:[2,82],68:[2,82],69:[2,82],71:[2,82],73:[2,82],74:[2,82],78:[2,82],80:[2,82],84:[2,82],85:[2,82],86:[2,82],91:[2,82],93:[2,82],102:[2,82],104:[2,82],105:[2,82],106:[2,82],110:[2,82],118:[2,82],126:[2,82],128:[2,82],129:[2,82],130:[2,82],131:[2,82],132:[2,82],133:[2,82],134:[2,82],135:[2,82],136:[2,82],137:[2,82],138:[2,82]},{73:[1,238]},{57:[1,189],73:[2,87],92:239,93:[1,188],103:82,104:[1,63],106:[1,64],109:83,110:[1,66],111:67,126:[1,81],128:[1,75],129:[1,74],132:[1,73],133:[1,76],134:[1,77],135:[1,78],136:[1,79],137:[1,80]},{73:[2,88]},{7:240,8:114,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,61:34,63:23,64:24,65:25,73:[2,122],76:[1,68],79:[1,41],83:[1,26],88:[1,56],89:[1,57],90:[1,55],96:[1,36],100:[1,42],101:[1,54],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{11:[2,116],28:[2,116],30:[2,116],31:[2,116],33:[2,116],34:[2,116],35:[2,116],36:[2,116],37:[2,116],38:[2,116],45:[2,116],46:[2,116],47:[2,116],51:[2,116],52:[2,116],73:[2,116],76:[2,116],79:[2,116],83:[2,116],88:[2,116],89:[2,116],90:[2,116],96:[2,116],100:[2,116],101:[2,116],104:[2,116],106:[2,116],108:[2,116],110:[2,116],119:[2,116],125:[2,116],127:[2,116],128:[2,116],129:[2,116],130:[2,116],131:[2,116]},{11:[2,117],28:[2,117],30:[2,117],31:[2,117],33:[2,117],34:[2,117],35:[2,117],36:[2,117],37:[2,117],38:[2,117],45:[2,117],46:[2,117],47:[2,117],51:[2,117],52:[2,117],73:[2,117],76:[2,117],79:[2,117],83:[2,117],88:[2,117],89:[2,117],90:[2,117],96:[2,117],100:[2,117],101:[2,117],104:[2,117],106:[2,117],108:[2,117],110:[2,117],119:[2,117],125:[2,117],127:[2,117],128:[2,117],129:[2,117],130:[2,117],131:[2,117]},{1:[2,86],6:[2,86],25:[2,86],26:[2,86],40:[2,86],49:[2,86],54:[2,86],57:[2,86],66:[2,86],67:[2,86],68:[2,86],69:[2,86],71:[2,86],73:[2,86],74:[2,86],78:[2,86],80:[2,86],84:[2,86],85:[2,86],86:[2,86],91:[2,86],93:[2,86],102:[2,86],104:[2,86],105:[2,86],106:[2,86],110:[2,86],118:[2,86],126:[2,86],128:[2,86],129:[2,86],130:[2,86],131:[2,86],132:[2,86],133:[2,86],134:[2,86],135:[2,86],136:[2,86],137:[2,86],138:[2,86]},{1:[2,104],6:[2,104],25:[2,104],26:[2,104],49:[2,104],54:[2,104],57:[2,104],66:[2,104],67:[2,104],68:[2,104],69:[2,104],71:[2,104],73:[2,104],74:[2,104],78:[2,104],84:[2,104],85:[2,104],86:[2,104],91:[2,104],93:[2,104],102:[2,104],104:[2,104],105:[2,104],106:[2,104],110:[2,104],118:[2,104],126:[2,104],128:[2,104],129:[2,104],132:[2,104],133:[2,104],134:[2,104],135:[2,104],136:[2,104],137:[2,104]},{1:[2,35],6:[2,35],25:[2,35],26:[2,35],49:[2,35],54:[2,35],57:[2,35],73:[2,35],78:[2,35],86:[2,35],91:[2,35],93:[2,35],102:[2,35],103:82,104:[2,35],105:[2,35],106:[2,35],109:83,110:[2,35],111:67,118:[2,35],126:[2,35],128:[1,75],129:[1,74],132:[1,73],133:[1,76],134:[1,77],135:[1,78],136:[1,79],137:[1,80]},{7:241,8:114,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,61:34,63:23,64:24,65:25,76:[1,68],79:[1,41],83:[1,26],88:[1,56],89:[1,57],90:[1,55],96:[1,36],100:[1,42],101:[1,54],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{7:242,8:114,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,61:34,63:23,64:24,65:25,76:[1,68],79:[1,41],83:[1,26],88:[1,56],89:[1,57],90:[1,55],96:[1,36],100:[1,42],101:[1,54],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{1:[2,109],6:[2,109],25:[2,109],26:[2,109],49:[2,109],54:[2,109],57:[2,109],66:[2,109],67:[2,109],68:[2,109],69:[2,109],71:[2,109],73:[2,109],74:[2,109],78:[2,109],84:[2,109],85:[2,109],86:[2,109],91:[2,109],93:[2,109],102:[2,109],104:[2,109],105:[2,109],106:[2,109],110:[2,109],118:[2,109],126:[2,109],128:[2,109],129:[2,109],132:[2,109],133:[2,109],134:[2,109],135:[2,109],136:[2,109],137:[2,109]},{6:[2,52],25:[2,52],53:243,54:[1,226],86:[2,52]},{6:[2,128],25:[2,128],26:[2,128],54:[2,128],57:[1,244],86:[2,128],91:[2,128],103:82,104:[1,63],106:[1,64],109:83,110:[1,66],111:67,126:[1,81],128:[1,75],129:[1,74],132:[1,73],133:[1,76],134:[1,77],135:[1,78],136:[1,79],137:[1,80]},{50:245,51:[1,58],52:[1,59]},{6:[2,53],25:[2,53],26:[2,53],27:105,28:[1,71],44:106,55:246,56:104,58:107,59:108,76:[1,68],89:[1,109],90:[1,110]},{6:[1,247],25:[1,248]},{6:[2,60],25:[2,60],26:[2,60],49:[2,60],54:[2,60]},{7:249,8:114,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,61:34,63:23,64:24,65:25,76:[1,68],79:[1,41],83:[1,26],88:[1,56],89:[1,57],90:[1,55],96:[1,36],100:[1,42],101:[1,54],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{1:[2,23],6:[2,23],25:[2,23],26:[2,23],49:[2,23],54:[2,23],57:[2,23],73:[2,23],78:[2,23],86:[2,23],91:[2,23],93:[2,23],98:[2,23],99:[2,23],102:[2,23],104:[2,23],105:[2,23],106:[2,23],110:[2,23],118:[2,23],121:[2,23],123:[2,23],126:[2,23],128:[2,23],129:[2,23],132:[2,23],133:[2,23],134:[2,23],135:[2,23],136:[2,23],137:[2,23]},{6:[1,72],26:[1,250]},{1:[2,201],6:[2,201],25:[2,201],26:[2,201],49:[2,201],54:[2,201],57:[2,201],73:[2,201],78:[2,201],86:[2,201],91:[2,201],93:[2,201],102:[2,201],103:82,104:[2,201],105:[2,201],106:[2,201],109:83,110:[2,201],111:67,118:[2,201],126:[2,201],128:[1,75],129:[1,74],132:[1,73],133:[1,76],134:[1,77],135:[1,78],136:[1,79],137:[1,80]},{7:251,8:114,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,61:34,63:23,64:24,65:25,76:[1,68],79:[1,41],83:[1,26],88:[1,56],89:[1,57],90:[1,55],96:[1,36],100:[1,42],101:[1,54],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{7:252,8:114,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,61:34,63:23,64:24,65:25,76:[1,68],79:[1,41],83:[1,26],88:[1,56],89:[1,57],90:[1,55],96:[1,36],100:[1,42],101:[1,54],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{1:[2,204],6:[2,204],25:[2,204],26:[2,204],49:[2,204],54:[2,204],57:[2,204],73:[2,204],78:[2,204],86:[2,204],91:[2,204],93:[2,204],102:[2,204],103:82,104:[2,204],105:[2,204],106:[2,204],109:83,110:[2,204],111:67,118:[2,204],126:[2,204],128:[1,75],129:[1,74],132:[1,73],133:[1,76],134:[1,77],135:[1,78],136:[1,79],137:[1,80]},{1:[2,183],6:[2,183],25:[2,183],26:[2,183],49:[2,183],54:[2,183],57:[2,183],73:[2,183],78:[2,183],86:[2,183],91:[2,183],93:[2,183],102:[2,183],104:[2,183],105:[2,183],106:[2,183],110:[2,183],118:[2,183],126:[2,183],128:[2,183],129:[2,183],132:[2,183],133:[2,183],134:[2,183],135:[2,183],136:[2,183],137:[2,183]},{7:253,8:114,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,61:34,63:23,64:24,65:25,76:[1,68],79:[1,41],83:[1,26],88:[1,56],89:[1,57],90:[1,55],96:[1,36],100:[1,42],101:[1,54],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{1:[2,133],6:[2,133],25:[2,133],26:[2,133],49:[2,133],54:[2,133],57:[2,133],73:[2,133],78:[2,133],86:[2,133],91:[2,133],93:[2,133],98:[1,254],102:[2,133],104:[2,133],105:[2,133],106:[2,133],110:[2,133],118:[2,133],126:[2,133],128:[2,133],129:[2,133],132:[2,133],133:[2,133],134:[2,133],135:[2,133],136:[2,133],137:[2,133]},{24:255,25:[1,112]},{24:258,25:[1,112],27:256,28:[1,71],59:257,76:[1,68]},{120:259,122:216,123:[1,217]},{26:[1,260],121:[1,261],122:262,123:[1,217]},{26:[2,176],121:[2,176],123:[2,176]},{7:264,8:114,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,61:34,63:23,64:24,65:25,76:[1,68],79:[1,41],83:[1,26],88:[1,56],89:[1,57],90:[1,55],95:263,96:[1,36],100:[1,42],101:[1,54],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{1:[2,97],6:[2,97],24:265,25:[1,112],26:[2,97],49:[2,97],54:[2,97],57:[2,97],73:[2,97],78:[2,97],86:[2,97],91:[2,97],93:[2,97],102:[2,97],103:82,104:[1,63],105:[2,97],106:[1,64],109:83,110:[1,66],111:67,118:[2,97],126:[2,97],128:[1,75],129:[1,74],132:[1,73],133:[1,76],134:[1,77],135:[1,78],136:[1,79],137:[1,80]},{1:[2,100],6:[2,100],25:[2,100],26:[2,100],49:[2,100],54:[2,100],57:[2,100],73:[2,100],78:[2,100],86:[2,100],91:[2,100],93:[2,100],102:[2,100],104:[2,100],105:[2,100],106:[2,100],110:[2,100],118:[2,100],126:[2,100],128:[2,100],129:[2,100],132:[2,100],133:[2,100],134:[2,100],135:[2,100],136:[2,100],137:[2,100]},{7:266,8:114,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,61:34,63:23,64:24,65:25,76:[1,68],79:[1,41],83:[1,26],88:[1,56],89:[1,57],90:[1,55],96:[1,36],100:[1,42],101:[1,54],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{1:[2,140],6:[2,140],25:[2,140],26:[2,140],49:[2,140],54:[2,140],57:[2,140],66:[2,140],67:[2,140],68:[2,140],69:[2,140],71:[2,140],73:[2,140],74:[2,140],78:[2,140],84:[2,140],85:[2,140],86:[2,140],91:[2,140],93:[2,140],102:[2,140],104:[2,140],105:[2,140],106:[2,140],110:[2,140],118:[2,140],126:[2,140],128:[2,140],129:[2,140],132:[2,140],133:[2,140],134:[2,140],135:[2,140],136:[2,140],137:[2,140]},{6:[1,72],26:[1,267]},{7:268,8:114,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,61:34,63:23,64:24,65:25,76:[1,68],79:[1,41],83:[1,26],88:[1,56],89:[1,57],90:[1,55],96:[1,36],100:[1,42],101:[1,54],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{6:[2,66],11:[2,117],25:[2,66],28:[2,117],30:[2,117],31:[2,117],33:[2,117],34:[2,117],35:[2,117],36:[2,117],37:[2,117],38:[2,117],45:[2,117],46:[2,117],47:[2,117],51:[2,117],52:[2,117],54:[2,66],76:[2,117],79:[2,117],83:[2,117],88:[2,117],89:[2,117],90:[2,117],91:[2,66],96:[2,117],100:[2,117],101:[2,117],104:[2,117],106:[2,117],108:[2,117],110:[2,117],119:[2,117],125:[2,117],127:[2,117],128:[2,117],129:[2,117],130:[2,117],131:[2,117]},{6:[1,270],25:[1,271],91:[1,269]},{6:[2,53],7:197,8:114,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,25:[2,53],26:[2,53],27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,60:144,61:34,63:23,64:24,65:25,76:[1,68],79:[1,41],83:[1,26],86:[2,53],88:[1,56],89:[1,57],90:[1,55],91:[2,53],94:272,96:[1,36],100:[1,42],101:[1,54],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{6:[2,52],25:[2,52],26:[2,52],53:273,54:[1,226]},{1:[2,180],6:[2,180],25:[2,180],26:[2,180],49:[2,180],54:[2,180],57:[2,180],73:[2,180],78:[2,180],86:[2,180],91:[2,180],93:[2,180],102:[2,180],104:[2,180],105:[2,180],106:[2,180],110:[2,180],118:[2,180],121:[2,180],126:[2,180],128:[2,180],129:[2,180],132:[2,180],133:[2,180],134:[2,180],135:[2,180],136:[2,180],137:[2,180]},{7:274,8:114,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,61:34,63:23,64:24,65:25,76:[1,68],79:[1,41],83:[1,26],88:[1,56],89:[1,57],90:[1,55],96:[1,36],100:[1,42],101:[1,54],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{7:275,8:114,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,61:34,63:23,64:24,65:25,76:[1,68],79:[1,41],83:[1,26],88:[1,56],89:[1,57],90:[1,55],96:[1,36],100:[1,42],101:[1,54],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{116:[2,158],117:[2,158]},{27:155,28:[1,71],44:156,58:157,59:158,76:[1,68],89:[1,109],90:[1,110],115:276},{1:[2,165],6:[2,165],25:[2,165],26:[2,165],49:[2,165],54:[2,165],57:[2,165],73:[2,165],78:[2,165],86:[2,165],91:[2,165],93:[2,165],102:[2,165],103:82,104:[2,165],105:[1,277],106:[2,165],109:83,110:[2,165],111:67,118:[1,278],126:[2,165],128:[1,75],129:[1,74],132:[1,73],133:[1,76],134:[1,77],135:[1,78],136:[1,79],137:[1,80]},{1:[2,166],6:[2,166],25:[2,166],26:[2,166],49:[2,166],54:[2,166],57:[2,166],73:[2,166],78:[2,166],86:[2,166],91:[2,166],93:[2,166],102:[2,166],103:82,104:[2,166],105:[1,279],106:[2,166],109:83,110:[2,166],111:67,118:[2,166],126:[2,166],128:[1,75],129:[1,74],132:[1,73],133:[1,76],134:[1,77],135:[1,78],136:[1,79],137:[1,80]},{6:[1,281],25:[1,282],78:[1,280]},{6:[2,53],10:165,25:[2,53],26:[2,53],27:166,28:[1,71],29:167,30:[1,69],31:[1,70],41:283,42:164,44:168,46:[1,44],78:[2,53],89:[1,109]},{7:284,8:114,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,25:[1,285],27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,61:34,63:23,64:24,65:25,76:[1,68],79:[1,41],83:[1,26],88:[1,56],89:[1,57],90:[1,55],96:[1,36],100:[1,42],101:[1,54],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{1:[2,85],6:[2,85],25:[2,85],26:[2,85],40:[2,85],49:[2,85],54:[2,85],57:[2,85],66:[2,85],67:[2,85],68:[2,85],69:[2,85],71:[2,85],73:[2,85],74:[2,85],78:[2,85],80:[2,85],84:[2,85],85:[2,85],86:[2,85],91:[2,85],93:[2,85],102:[2,85],104:[2,85],105:[2,85],106:[2,85],110:[2,85],118:[2,85],126:[2,85],128:[2,85],129:[2,85],130:[2,85],131:[2,85],132:[2,85],133:[2,85],134:[2,85],135:[2,85],136:[2,85],137:[2,85],138:[2,85]},{7:286,8:114,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,61:34,63:23,64:24,65:25,73:[2,120],76:[1,68],79:[1,41],83:[1,26],88:[1,56],89:[1,57],90:[1,55],96:[1,36],100:[1,42],101:[1,54],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{73:[2,121],103:82,104:[1,63],106:[1,64],109:83,110:[1,66],111:67,126:[1,81],128:[1,75],129:[1,74],132:[1,73],133:[1,76],134:[1,77],135:[1,78],136:[1,79],137:[1,80]},{1:[2,36],6:[2,36],25:[2,36],26:[2,36],49:[2,36],54:[2,36],57:[2,36],73:[2,36],78:[2,36],86:[2,36],91:[2,36],93:[2,36],102:[2,36],103:82,104:[2,36],105:[2,36],106:[2,36],109:83,110:[2,36],111:67,118:[2,36],126:[2,36],128:[1,75],129:[1,74],132:[1,73],133:[1,76],134:[1,77],135:[1,78],136:[1,79],137:[1,80]},{26:[1,287],103:82,104:[1,63],106:[1,64],109:83,110:[1,66],111:67,126:[1,81],128:[1,75],129:[1,74],132:[1,73],133:[1,76],134:[1,77],135:[1,78],136:[1,79],137:[1,80]},{6:[1,270],25:[1,271],86:[1,288]},{6:[2,66],25:[2,66],26:[2,66],54:[2,66],86:[2,66],91:[2,66]},{24:289,25:[1,112]},{6:[2,56],25:[2,56],26:[2,56],49:[2,56],54:[2,56]},{27:105,28:[1,71],44:106,55:290,56:104,58:107,59:108,76:[1,68],89:[1,109],90:[1,110]},{6:[2,54],25:[2,54],26:[2,54],27:105,28:[1,71],44:106,48:291,54:[2,54],55:103,56:104,58:107,59:108,76:[1,68],89:[1,109],90:[1,110]},{6:[2,61],25:[2,61],26:[2,61],49:[2,61],54:[2,61],103:82,104:[1,63],106:[1,64],109:83,110:[1,66],111:67,126:[1,81],128:[1,75],129:[1,74],132:[1,73],133:[1,76],134:[1,77],135:[1,78],136:[1,79],137:[1,80]},{1:[2,24],6:[2,24],25:[2,24],26:[2,24],49:[2,24],54:[2,24],57:[2,24],73:[2,24],78:[2,24],86:[2,24],91:[2,24],93:[2,24],98:[2,24],99:[2,24],102:[2,24],104:[2,24],105:[2,24],106:[2,24],110:[2,24],118:[2,24],121:[2,24],123:[2,24],126:[2,24],128:[2,24],129:[2,24],132:[2,24],133:[2,24],134:[2,24],135:[2,24],136:[2,24],137:[2,24]},{26:[1,292],103:82,104:[1,63],106:[1,64],109:83,110:[1,66],111:67,126:[1,81],128:[1,75],129:[1,74],132:[1,73],133:[1,76],134:[1,77],135:[1,78],136:[1,79],137:[1,80]},{1:[2,203],6:[2,203],25:[2,203],26:[2,203],49:[2,203],54:[2,203],57:[2,203],73:[2,203],78:[2,203],86:[2,203],91:[2,203],93:[2,203],102:[2,203],103:82,104:[2,203],105:[2,203],106:[2,203],109:83,110:[2,203],111:67,118:[2,203],126:[2,203],128:[1,75],129:[1,74],132:[1,73],133:[1,76],134:[1,77],135:[1,78],136:[1,79],137:[1,80]},{24:293,25:[1,112],103:82,104:[1,63],106:[1,64],109:83,110:[1,66],111:67,126:[1,81],128:[1,75],129:[1,74],132:[1,73],133:[1,76],134:[1,77],135:[1,78],136:[1,79],137:[1,80]},{24:294,25:[1,112]},{1:[2,134],6:[2,134],25:[2,134],26:[2,134],49:[2,134],54:[2,134],57:[2,134],73:[2,134],78:[2,134],86:[2,134],91:[2,134],93:[2,134],102:[2,134],104:[2,134],105:[2,134],106:[2,134],110:[2,134],118:[2,134],126:[2,134],128:[2,134],129:[2,134],132:[2,134],133:[2,134],134:[2,134],135:[2,134],136:[2,134],137:[2,134]},{24:295,25:[1,112]},{24:296,25:[1,112]},{1:[2,138],6:[2,138],25:[2,138],26:[2,138],49:[2,138],54:[2,138],57:[2,138],73:[2,138],78:[2,138],86:[2,138],91:[2,138],93:[2,138],98:[2,138],102:[2,138],104:[2,138],105:[2,138],106:[2,138],110:[2,138],118:[2,138],126:[2,138],128:[2,138],129:[2,138],132:[2,138],133:[2,138],134:[2,138],135:[2,138],136:[2,138],137:[2,138]},{26:[1,297],121:[1,298],122:262,123:[1,217]},{1:[2,174],6:[2,174],25:[2,174],26:[2,174],49:[2,174],54:[2,174],57:[2,174],73:[2,174],78:[2,174],86:[2,174],91:[2,174],93:[2,174],102:[2,174],104:[2,174],105:[2,174],106:[2,174],110:[2,174],118:[2,174],126:[2,174],128:[2,174],129:[2,174],132:[2,174],133:[2,174],134:[2,174],135:[2,174],136:[2,174],137:[2,174]},{24:299,25:[1,112]},{26:[2,177],121:[2,177],123:[2,177]},{24:300,25:[1,112],54:[1,301]},{25:[2,130],54:[2,130],103:82,104:[1,63],106:[1,64],109:83,110:[1,66],111:67,126:[1,81],128:[1,75],129:[1,74],132:[1,73],133:[1,76],134:[1,77],135:[1,78],136:[1,79],137:[1,80]},{1:[2,98],6:[2,98],25:[2,98],26:[2,98],49:[2,98],54:[2,98],57:[2,98],73:[2,98],78:[2,98],86:[2,98],91:[2,98],93:[2,98],102:[2,98],104:[2,98],105:[2,98],106:[2,98],110:[2,98],118:[2,98],126:[2,98],128:[2,98],129:[2,98],132:[2,98],133:[2,98],134:[2,98],135:[2,98],136:[2,98],137:[2,98]},{1:[2,101],6:[2,101],24:302,25:[1,112],26:[2,101],49:[2,101],54:[2,101],57:[2,101],73:[2,101],78:[2,101],86:[2,101],91:[2,101],93:[2,101],102:[2,101],103:82,104:[1,63],105:[2,101],106:[1,64],109:83,110:[1,66],111:67,118:[2,101],126:[2,101],128:[1,75],129:[1,74],132:[1,73],133:[1,76],134:[1,77],135:[1,78],136:[1,79],137:[1,80]},{102:[1,303]},{91:[1,304],103:82,104:[1,63],106:[1,64],109:83,110:[1,66],111:67,126:[1,81],128:[1,75],129:[1,74],132:[1,73],133:[1,76],134:[1,77],135:[1,78],136:[1,79],137:[1,80]},{1:[2,115],6:[2,115],25:[2,115],26:[2,115],40:[2,115],49:[2,115],54:[2,115],57:[2,115],66:[2,115],67:[2,115],68:[2,115],69:[2,115],71:[2,115],73:[2,115],74:[2,115],78:[2,115],84:[2,115],85:[2,115],86:[2,115],91:[2,115],93:[2,115],102:[2,115],104:[2,115],105:[2,115],106:[2,115],110:[2,115],116:[2,115],117:[2,115],118:[2,115],126:[2,115],128:[2,115],129:[2,115],132:[2,115],133:[2,115],134:[2,115],135:[2,115],136:[2,115],137:[2,115]},{7:197,8:114,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,60:144,61:34,63:23,64:24,65:25,76:[1,68],79:[1,41],83:[1,26],88:[1,56],89:[1,57],90:[1,55],94:305,96:[1,36],100:[1,42],101:[1,54],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{7:197,8:114,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,25:[1,143],27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,60:144,61:34,63:23,64:24,65:25,76:[1,68],79:[1,41],83:[1,26],87:306,88:[1,56],89:[1,57],90:[1,55],94:142,96:[1,36],100:[1,42],101:[1,54],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{6:[2,124],25:[2,124],26:[2,124],54:[2,124],86:[2,124],91:[2,124]},{6:[1,270],25:[1,271],26:[1,307]},{1:[2,143],6:[2,143],25:[2,143],26:[2,143],49:[2,143],54:[2,143],57:[2,143],73:[2,143],78:[2,143],86:[2,143],91:[2,143],93:[2,143],102:[2,143],103:82,104:[1,63],105:[2,143],106:[1,64],109:83,110:[1,66],111:67,118:[2,143],126:[2,143],128:[1,75],129:[1,74],132:[1,73],133:[1,76],134:[1,77],135:[1,78],136:[1,79],137:[1,80]},{1:[2,145],6:[2,145],25:[2,145],26:[2,145],49:[2,145],54:[2,145],57:[2,145],73:[2,145],78:[2,145],86:[2,145],91:[2,145],93:[2,145],102:[2,145],103:82,104:[1,63],105:[2,145],106:[1,64],109:83,110:[1,66],111:67,118:[2,145],126:[2,145],128:[1,75],129:[1,74],132:[1,73],133:[1,76],134:[1,77],135:[1,78],136:[1,79],137:[1,80]},{116:[2,164],117:[2,164]},{7:308,8:114,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,61:34,63:23,64:24,65:25,76:[1,68],79:[1,41],83:[1,26],88:[1,56],89:[1,57],90:[1,55],96:[1,36],100:[1,42],101:[1,54],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{7:309,8:114,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,61:34,63:23,64:24,65:25,76:[1,68],79:[1,41],83:[1,26],88:[1,56],89:[1,57],90:[1,55],96:[1,36],100:[1,42],101:[1,54],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{7:310,8:114,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,61:34,63:23,64:24,65:25,76:[1,68],79:[1,41],83:[1,26],88:[1,56],89:[1,57],90:[1,55],96:[1,36],100:[1,42],101:[1,54],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{1:[2,89],6:[2,89],25:[2,89],26:[2,89],40:[2,89],49:[2,89],54:[2,89],57:[2,89],66:[2,89],67:[2,89],68:[2,89],69:[2,89],71:[2,89],73:[2,89],74:[2,89],78:[2,89],84:[2,89],85:[2,89],86:[2,89],91:[2,89],93:[2,89],102:[2,89],104:[2,89],105:[2,89],106:[2,89],110:[2,89],116:[2,89],117:[2,89],118:[2,89],126:[2,89],128:[2,89],129:[2,89],132:[2,89],133:[2,89],134:[2,89],135:[2,89],136:[2,89],137:[2,89]},{10:165,27:166,28:[1,71],29:167,30:[1,69],31:[1,70],41:311,42:164,44:168,46:[1,44],89:[1,109]},{6:[2,90],10:165,25:[2,90],26:[2,90],27:166,28:[1,71],29:167,30:[1,69],31:[1,70],41:163,42:164,44:168,46:[1,44],54:[2,90],77:312,89:[1,109]},{6:[2,92],25:[2,92],26:[2,92],54:[2,92],78:[2,92]},{6:[2,39],25:[2,39],26:[2,39],54:[2,39],78:[2,39],103:82,104:[1,63],106:[1,64],109:83,110:[1,66],111:67,126:[1,81],128:[1,75],129:[1,74],132:[1,73],133:[1,76],134:[1,77],135:[1,78],136:[1,79],137:[1,80]},{7:313,8:114,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,61:34,63:23,64:24,65:25,76:[1,68],79:[1,41],83:[1,26],88:[1,56],89:[1,57],90:[1,55],96:[1,36],100:[1,42],101:[1,54],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{73:[2,119],103:82,104:[1,63],106:[1,64],109:83,110:[1,66],111:67,126:[1,81],128:[1,75],129:[1,74],132:[1,73],133:[1,76],134:[1,77],135:[1,78],136:[1,79],137:[1,80]},{1:[2,37],6:[2,37],25:[2,37],26:[2,37],49:[2,37],54:[2,37],57:[2,37],73:[2,37],78:[2,37],86:[2,37],91:[2,37],93:[2,37],102:[2,37],104:[2,37],105:[2,37],106:[2,37],110:[2,37],118:[2,37],126:[2,37],128:[2,37],129:[2,37],132:[2,37],133:[2,37],134:[2,37],135:[2,37],136:[2,37],137:[2,37]},{1:[2,110],6:[2,110],25:[2,110],26:[2,110],49:[2,110],54:[2,110],57:[2,110],66:[2,110],67:[2,110],68:[2,110],69:[2,110],71:[2,110],73:[2,110],74:[2,110],78:[2,110],84:[2,110],85:[2,110],86:[2,110],91:[2,110],93:[2,110],102:[2,110],104:[2,110],105:[2,110],106:[2,110],110:[2,110],118:[2,110],126:[2,110],128:[2,110],129:[2,110],132:[2,110],133:[2,110],134:[2,110],135:[2,110],136:[2,110],137:[2,110]},{1:[2,48],6:[2,48],25:[2,48],26:[2,48],49:[2,48],54:[2,48],57:[2,48],73:[2,48],78:[2,48],86:[2,48],91:[2,48],93:[2,48],102:[2,48],104:[2,48],105:[2,48],106:[2,48],110:[2,48],118:[2,48],126:[2,48],128:[2,48],129:[2,48],132:[2,48],133:[2,48],134:[2,48],135:[2,48],136:[2,48],137:[2,48]},{6:[2,57],25:[2,57],26:[2,57],49:[2,57],54:[2,57]},{6:[2,52],25:[2,52],26:[2,52],53:314,54:[1,199]},{1:[2,202],6:[2,202],25:[2,202],26:[2,202],49:[2,202],54:[2,202],57:[2,202],73:[2,202],78:[2,202],86:[2,202],91:[2,202],93:[2,202],102:[2,202],104:[2,202],105:[2,202],106:[2,202],110:[2,202],118:[2,202],126:[2,202],128:[2,202],129:[2,202],132:[2,202],133:[2,202],134:[2,202],135:[2,202],136:[2,202],137:[2,202]},{1:[2,181],6:[2,181],25:[2,181],26:[2,181],49:[2,181],54:[2,181],57:[2,181],73:[2,181],78:[2,181],86:[2,181],91:[2,181],93:[2,181],102:[2,181],104:[2,181],105:[2,181],106:[2,181],110:[2,181],118:[2,181],121:[2,181],126:[2,181],128:[2,181],129:[2,181],132:[2,181],133:[2,181],134:[2,181],135:[2,181],136:[2,181],137:[2,181]},{1:[2,135],6:[2,135],25:[2,135],26:[2,135],49:[2,135],54:[2,135],57:[2,135],73:[2,135],78:[2,135],86:[2,135],91:[2,135],93:[2,135],102:[2,135],104:[2,135],105:[2,135],106:[2,135],110:[2,135],118:[2,135],126:[2,135],128:[2,135],129:[2,135],132:[2,135],133:[2,135],134:[2,135],135:[2,135],136:[2,135],137:[2,135]},{1:[2,136],6:[2,136],25:[2,136],26:[2,136],49:[2,136],54:[2,136],57:[2,136],73:[2,136],78:[2,136],86:[2,136],91:[2,136],93:[2,136],98:[2,136],102:[2,136],104:[2,136],105:[2,136],106:[2,136],110:[2,136],118:[2,136],126:[2,136],128:[2,136],129:[2,136],132:[2,136],133:[2,136],134:[2,136],135:[2,136],136:[2,136],137:[2,136]},{1:[2,137],6:[2,137],25:[2,137],26:[2,137],49:[2,137],54:[2,137],57:[2,137],73:[2,137],78:[2,137],86:[2,137],91:[2,137],93:[2,137],98:[2,137],102:[2,137],104:[2,137],105:[2,137],106:[2,137],110:[2,137],118:[2,137],126:[2,137],128:[2,137],129:[2,137],132:[2,137],133:[2,137],134:[2,137],135:[2,137],136:[2,137],137:[2,137]},{1:[2,172],6:[2,172],25:[2,172],26:[2,172],49:[2,172],54:[2,172],57:[2,172],73:[2,172],78:[2,172],86:[2,172],91:[2,172],93:[2,172],102:[2,172],104:[2,172],105:[2,172],106:[2,172],110:[2,172],118:[2,172],126:[2,172],128:[2,172],129:[2,172],132:[2,172],133:[2,172],134:[2,172],135:[2,172],136:[2,172],137:[2,172]},{24:315,25:[1,112]},{26:[1,316]},{6:[1,317],26:[2,178],121:[2,178],123:[2,178]},{7:318,8:114,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,61:34,63:23,64:24,65:25,76:[1,68],79:[1,41],83:[1,26],88:[1,56],89:[1,57],90:[1,55],96:[1,36],100:[1,42],101:[1,54],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{1:[2,102],6:[2,102],25:[2,102],26:[2,102],49:[2,102],54:[2,102],57:[2,102],73:[2,102],78:[2,102],86:[2,102],91:[2,102],93:[2,102],102:[2,102],104:[2,102],105:[2,102],106:[2,102],110:[2,102],118:[2,102],126:[2,102],128:[2,102],129:[2,102],132:[2,102],133:[2,102],134:[2,102],135:[2,102],136:[2,102],137:[2,102]},{1:[2,141],6:[2,141],25:[2,141],26:[2,141],49:[2,141],54:[2,141],57:[2,141],66:[2,141],67:[2,141],68:[2,141],69:[2,141],71:[2,141],73:[2,141],74:[2,141],78:[2,141],84:[2,141],85:[2,141],86:[2,141],91:[2,141],93:[2,141],102:[2,141],104:[2,141],105:[2,141],106:[2,141],110:[2,141],118:[2,141],126:[2,141],128:[2,141],129:[2,141],132:[2,141],133:[2,141],134:[2,141],135:[2,141],136:[2,141],137:[2,141]},{1:[2,118],6:[2,118],25:[2,118],26:[2,118],49:[2,118],54:[2,118],57:[2,118],66:[2,118],67:[2,118],68:[2,118],69:[2,118],71:[2,118],73:[2,118],74:[2,118],78:[2,118],84:[2,118],85:[2,118],86:[2,118],91:[2,118],93:[2,118],102:[2,118],104:[2,118],105:[2,118],106:[2,118],110:[2,118],118:[2,118],126:[2,118],128:[2,118],129:[2,118],132:[2,118],133:[2,118],134:[2,118],135:[2,118],136:[2,118],137:[2,118]},{6:[2,125],25:[2,125],26:[2,125],54:[2,125],86:[2,125],91:[2,125]},{6:[2,52],25:[2,52],26:[2,52],53:319,54:[1,226]},{6:[2,126],25:[2,126],26:[2,126],54:[2,126],86:[2,126],91:[2,126]},{1:[2,167],6:[2,167],25:[2,167],26:[2,167],49:[2,167],54:[2,167],57:[2,167],73:[2,167],78:[2,167],86:[2,167],91:[2,167],93:[2,167],102:[2,167],103:82,104:[2,167],105:[2,167],106:[2,167],109:83,110:[2,167],111:67,118:[1,320],126:[2,167],128:[1,75],129:[1,74],132:[1,73],133:[1,76],134:[1,77],135:[1,78],136:[1,79],137:[1,80]},{1:[2,169],6:[2,169],25:[2,169],26:[2,169],49:[2,169],54:[2,169],57:[2,169],73:[2,169],78:[2,169],86:[2,169],91:[2,169],93:[2,169],102:[2,169],103:82,104:[2,169],105:[1,321],106:[2,169],109:83,110:[2,169],111:67,118:[2,169],126:[2,169],128:[1,75],129:[1,74],132:[1,73],133:[1,76],134:[1,77],135:[1,78],136:[1,79],137:[1,80]},{1:[2,168],6:[2,168],25:[2,168],26:[2,168],49:[2,168],54:[2,168],57:[2,168],73:[2,168],78:[2,168],86:[2,168],91:[2,168],93:[2,168],102:[2,168],103:82,104:[2,168],105:[2,168],106:[2,168],109:83,110:[2,168],111:67,118:[2,168],126:[2,168],128:[1,75],129:[1,74],132:[1,73],133:[1,76],134:[1,77],135:[1,78],136:[1,79],137:[1,80]},{6:[2,93],25:[2,93],26:[2,93],54:[2,93],78:[2,93]},{6:[2,52],25:[2,52],26:[2,52],53:322,54:[1,236]},{26:[1,323],103:82,104:[1,63],106:[1,64],109:83,110:[1,66],111:67,126:[1,81],128:[1,75],129:[1,74],132:[1,73],133:[1,76],134:[1,77],135:[1,78],136:[1,79],137:[1,80]},{6:[1,247],25:[1,248],26:[1,324]},{26:[1,325]},{1:[2,175],6:[2,175],25:[2,175],26:[2,175],49:[2,175],54:[2,175],57:[2,175],73:[2,175],78:[2,175],86:[2,175],91:[2,175],93:[2,175],102:[2,175],104:[2,175],105:[2,175],106:[2,175],110:[2,175],118:[2,175],126:[2,175],128:[2,175],129:[2,175],132:[2,175],133:[2,175],134:[2,175],135:[2,175],136:[2,175],137:[2,175]},{26:[2,179],121:[2,179],123:[2,179]},{25:[2,131],54:[2,131],103:82,104:[1,63],106:[1,64],109:83,110:[1,66],111:67,126:[1,81],128:[1,75],129:[1,74],132:[1,73],133:[1,76],134:[1,77],135:[1,78],136:[1,79],137:[1,80]},{6:[1,270],25:[1,271],26:[1,326]},{7:327,8:114,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,61:34,63:23,64:24,65:25,76:[1,68],79:[1,41],83:[1,26],88:[1,56],89:[1,57],90:[1,55],96:[1,36],100:[1,42],101:[1,54],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{7:328,8:114,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,61:34,63:23,64:24,65:25,76:[1,68],79:[1,41],83:[1,26],88:[1,56],89:[1,57],90:[1,55],96:[1,36],100:[1,42],101:[1,54],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{6:[1,281],25:[1,282],26:[1,329]},{6:[2,40],25:[2,40],26:[2,40],54:[2,40],78:[2,40]},{6:[2,58],25:[2,58],26:[2,58],49:[2,58],54:[2,58]},{1:[2,173],6:[2,173],25:[2,173],26:[2,173],49:[2,173],54:[2,173],57:[2,173],73:[2,173],78:[2,173],86:[2,173],91:[2,173],93:[2,173],102:[2,173],104:[2,173],105:[2,173],106:[2,173],110:[2,173],118:[2,173],126:[2,173],128:[2,173],129:[2,173],132:[2,173],133:[2,173],134:[2,173],135:[2,173],136:[2,173],137:[2,173]},{6:[2,127],25:[2,127],26:[2,127],54:[2,127],86:[2,127],91:[2,127]},{1:[2,170],6:[2,170],25:[2,170],26:[2,170],49:[2,170],54:[2,170],57:[2,170],73:[2,170],78:[2,170],86:[2,170],91:[2,170],93:[2,170],102:[2,170],103:82,104:[2,170],105:[2,170],106:[2,170],109:83,110:[2,170],111:67,118:[2,170],126:[2,170],128:[1,75],129:[1,74],132:[1,73],133:[1,76],134:[1,77],135:[1,78],136:[1,79],137:[1,80]},{1:[2,171],6:[2,171],25:[2,171],26:[2,171],49:[2,171],54:[2,171],57:[2,171],73:[2,171],78:[2,171],86:[2,171],91:[2,171],93:[2,171],102:[2,171],103:82,104:[2,171],105:[2,171],106:[2,171],109:83,110:[2,171],111:67,118:[2,171],126:[2,171],128:[1,75],129:[1,74],132:[1,73],133:[1,76],134:[1,77],135:[1,78],136:[1,79],137:[1,80]},{6:[2,94],25:[2,94],26:[2,94],54:[2,94],78:[2,94]}], +defaultActions: {58:[2,50],59:[2,51],89:[2,108],186:[2,88]}, parseError: function parseError(str, hash) { - var e = new Error(str) - e.location = hash.loc - throw e; + if (hash.recoverable) { + this.trace(str); + } else { + // ace_mod + var e = new Error(str) + e.location = hash.loc + throw e; + } }, parse: function parse(input) { - var self = this, stack = [0], vstack = [null], lstack = [], table = this.table, yytext = "", yylineno = 0, yyleng = 0, recovering = 0, TERROR = 2, EOF = 1; + var self = this, stack = [0], vstack = [null], lstack = [], table = this.table, yytext = '', yylineno = 0, yyleng = 0, recovering = 0, TERROR = 2, EOF = 1; this.lexer.setInput(input); this.lexer.yy = this.yy; this.yy.lexer = this.lexer; this.yy.parser = this; - if (typeof this.lexer.yylloc == "undefined") + if (typeof this.lexer.yylloc == 'undefined') { this.lexer.yylloc = {}; + } var yyloc = this.lexer.yylloc; lstack.push(yyloc); var ranges = this.lexer.options && this.lexer.options.ranges; - if (typeof this.yy.parseError === "function") + if (typeof this.yy.parseError === 'function') { this.parseError = this.yy.parseError; + } else { + this.parseError = Object.getPrototypeOf(this).parseError; + } function popStack(n) { stack.length = stack.length - 2 * n; vstack.length = vstack.length - n; @@ -533,8 +613,8 @@ parse: function parse(input) { } function lex() { var token; - token = self.lexer.lex() || 1; - if (typeof token !== "number") { + token = self.lexer.lex() || EOF; + if (typeof token !== 'number') { token = self.symbols_[token] || token; } return token; @@ -545,29 +625,36 @@ parse: function parse(input) { if (this.defaultActions[state]) { action = this.defaultActions[state]; } else { - if (symbol === null || typeof symbol == "undefined") { + if (symbol === null || typeof symbol == 'undefined') { symbol = lex(); } action = table[state] && table[state][symbol]; } - if (typeof action === "undefined" || !action.length || !action[0]) { - var errStr = ""; - if (!recovering) { + if (typeof action === 'undefined' || !action.length || !action[0]) { + var errStr = ''; expected = []; - for (p in table[state]) - if (this.terminals_[p] && p > 2) { - expected.push("'" + this.terminals_[p] + "'"); + for (p in table[state]) { + if (this.terminals_[p] && p > TERROR) { + expected.push('\'' + this.terminals_[p] + '\''); } - if (this.lexer.showPosition) { - errStr = this.lexer.showPosition() + "\nExpecting " + expected.join(", ") + ", got '" + (this.terminals_[symbol] || symbol) + "'"; - } else { - errStr = "Unexpected " + (symbol == 1?"end of input":"'" + (this.terminals_[symbol] || symbol) + "'"); } - this.parseError(errStr, {text: this.lexer.match, token: this.terminals_[symbol] || symbol, line: this.lexer.yylineno, loc: yyloc, expected: expected}); + if (this.lexer.showPosition) { + errStr = 'Expecting ' + expected.join(', ') + ', got \'' + (this.terminals_[symbol] || symbol) + '\''; + } else { + errStr = 'Unexpected ' + (symbol == EOF ? 'end of input' : '\'' + (this.terminals_[symbol] || symbol) + '\''); + } + // ace_mod + if (this.lexer.yylloc.first_line !== yyloc.first_line) yyloc = this.lexer.yylloc; + this.parseError(errStr, { + text: this.lexer.match, + token: this.terminals_[symbol] || symbol, + line: this.lexer.yylineno, + loc: yyloc, + expected: expected + }); } - } if (action[0] instanceof Array && action.length > 1) { - throw new Error("Parse Error: multiple actions possible at state: " + state + ", token: " + symbol); + throw new Error('Parse Error: multiple actions possible at state: ' + state + ', token: ' + symbol); } switch (action[0]) { case 1: @@ -581,8 +668,9 @@ parse: function parse(input) { yytext = this.lexer.yytext; yylineno = this.lexer.yylineno; yyloc = this.lexer.yylloc; - if (recovering > 0) + if (recovering > 0) { recovering--; + } } else { symbol = preErrorSymbol; preErrorSymbol = null; @@ -591,12 +679,20 @@ parse: function parse(input) { case 2: len = this.productions_[action[1]][1]; yyval.$ = vstack[vstack.length - len]; - yyval._$ = {first_line: lstack[lstack.length - (len || 1)].first_line, last_line: lstack[lstack.length - 1].last_line, first_column: lstack[lstack.length - (len || 1)].first_column, last_column: lstack[lstack.length - 1].last_column}; + yyval._$ = { + first_line: lstack[lstack.length - (len || 1)].first_line, + last_line: lstack[lstack.length - 1].last_line, + first_column: lstack[lstack.length - (len || 1)].first_column, + last_column: lstack[lstack.length - 1].last_column + }; if (ranges) { - yyval._$.range = [lstack[lstack.length - (len || 1)].range[0], lstack[lstack.length - 1].range[1]]; + yyval._$.range = [ + lstack[lstack.length - (len || 1)].range[0], + lstack[lstack.length - 1].range[1] + ]; } r = this.performAction.call(yyval, yytext, yyleng, yylineno, this.yy, action[1], vstack, lstack); - if (typeof r !== "undefined") { + if (typeof r !== 'undefined') { return r; } if (len) { @@ -615,10 +711,12 @@ parse: function parse(input) { } } return true; -} -}; +}}; undefined -function Parser () { this.yy = {}; }Parser.prototype = parser;parser.Parser = Parser; +function Parser () { + this.yy = {}; +} +Parser.prototype = parser;parser.Parser = Parser; module.exports = new Parser; diff --git a/lib/ace/mode/coffee/parser_test.js b/lib/ace/mode/coffee/parser_test.js index e4ccf1bb..001262b6 100644 --- a/lib/ace/mode/coffee/parser_test.js +++ b/lib/ace/mode/coffee/parser_test.js @@ -72,7 +72,7 @@ module.exports = { "test unexpected indent": function() { var e = parse("a\n a\n"); assert.equal(e.message, "Unexpected 'INDENT'"); - assertLocation(e, 0, 0, 0, 0); + assertLocation(e, 1, 0, 1, 1); }, "test invalid destructuring": function() { var e = parse("\n{b: 5} = {}"); diff --git a/lib/ace/mode/coffee/rewriter.js b/lib/ace/mode/coffee/rewriter.js index a25ff29f..acb5c420 100644 --- a/lib/ace/mode/coffee/rewriter.js +++ b/lib/ace/mode/coffee/rewriter.js @@ -25,9 +25,9 @@ */ define(function(require, exports, module) { -// Generated by CoffeeScript 1.6.2 +// Generated by CoffeeScript 1.6.3 - var BALANCED_PAIRS, EXPRESSION_CLOSE, EXPRESSION_END, EXPRESSION_START, IMPLICIT_BLOCK, IMPLICIT_CALL, IMPLICIT_END, IMPLICIT_FUNC, IMPLICIT_UNSPACED_CALL, INVERSES, LINEBREAKS, SINGLE_CLOSERS, SINGLE_LINERS, generate, left, rite, _i, _len, _ref, + var BALANCED_PAIRS, CALL_CLOSERS, EXPRESSION_CLOSE, EXPRESSION_END, EXPRESSION_START, IMPLICIT_CALL, IMPLICIT_END, IMPLICIT_FUNC, IMPLICIT_UNSPACED_CALL, INVERSES, LINEBREAKS, SINGLE_CLOSERS, SINGLE_LINERS, generate, left, rite, _i, _len, _ref, __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }, __slice = [].slice; @@ -44,10 +44,9 @@ define(function(require, exports, module) { Rewriter.prototype.rewrite = function(tokens) { this.tokens = tokens; this.removeLeadingNewlines(); - this.removeMidExpressionNewlines(); this.closeOpenCalls(); this.closeOpenIndexes(); - this.addImplicitIndentation(); + this.normalizeLines(); this.tagPostfixConditionals(); this.addImplicitBracesAndParens(); this.addLocationDataToGeneratedTokens(); @@ -99,17 +98,6 @@ define(function(require, exports, module) { } }; - Rewriter.prototype.removeMidExpressionNewlines = function() { - return this.scanTokens(function(token, i, tokens) { - var _ref; - if (!(token[0] === 'TERMINATOR' && (_ref = this.tag(i + 1), __indexOf.call(EXPRESSION_CLOSE, _ref) >= 0))) { - return 1; - } - tokens.splice(i, 1); - return 0; - }); - }; - Rewriter.prototype.closeOpenCalls = function() { var action, condition; condition = function(token, i) { @@ -188,9 +176,9 @@ define(function(require, exports, module) { var stack; stack = []; return this.scanTokens(function(token, i, tokens) { - var endImplicitCall, endImplicitObject, forward, inImplicit, inImplicitCall, inImplicitControl, inImplicitObject, nextTag, offset, prevTag, s, sameLine, stackIdx, stackTag, stackTop, startIdx, startImplicitCall, startImplicitObject, startsLine, tag, _ref, _ref1, _ref2, _ref3, _ref4, _ref5; + var endAllImplicitCalls, endImplicitCall, endImplicitObject, forward, inImplicit, inImplicitCall, inImplicitControl, inImplicitObject, nextTag, offset, prevTag, prevToken, s, sameLine, stackIdx, stackTag, stackTop, startIdx, startImplicitCall, startImplicitObject, startsLine, tag, _ref, _ref1, _ref2, _ref3, _ref4, _ref5; tag = token[0]; - prevTag = (i > 0 ? tokens[i - 1] : [])[0]; + prevTag = (prevToken = i > 0 ? tokens[i - 1] : [])[0]; nextTag = (i < tokens.length - 1 ? tokens[i + 1] : [])[0]; stackTop = function() { return stack[stack.length - 1]; @@ -233,6 +221,11 @@ define(function(require, exports, module) { tokens.splice(i, 0, generate('CALL_END', ')')); return i += 1; }; + endAllImplicitCalls = function() { + while (inImplicitCall()) { + endImplicitCall(); + } + }; startImplicitObject = function(j, startsLine) { var idx; if (startsLine == null) { @@ -300,7 +293,7 @@ define(function(require, exports, module) { startImplicitCall(i + 1); return forward(2); } - if (this.matchTags(i, IMPLICIT_FUNC, 'INDENT', null, ':') && !this.findTagsBackwards(i, ['CLASS', 'EXTENDS', 'IF', 'CATCH', 'SWITCH', 'LEADING_WHEN', 'FOR', 'WHILE', 'UNTIL'])) { + if (__indexOf.call(IMPLICIT_FUNC, tag) >= 0 && this.matchTags(i + 1, 'INDENT', null, ':') && !this.findTagsBackwards(i, ['CLASS', 'EXTENDS', 'IF', 'CATCH', 'SWITCH', 'LEADING_WHEN', 'FOR', 'WHILE', 'UNTIL'])) { startImplicitCall(i + 1); stack.push(['INDENT', i + 2]); return forward(3); @@ -324,9 +317,15 @@ define(function(require, exports, module) { startImplicitObject(s, !!startsLine); return forward(2); } - if (prevTag === 'OUTDENT' && inImplicitCall() && (tag === '.' || tag === '?.' || tag === '::' || tag === '?::')) { - endImplicitCall(); - return forward(1); + if (inImplicitCall() && __indexOf.call(CALL_CLOSERS, tag) >= 0) { + if (prevTag === 'OUTDENT') { + endImplicitCall(); + return forward(1); + } + if (prevToken.newLine) { + endAllImplicitCalls(); + return forward(1); + } } if (inImplicitObject() && __indexOf.call(LINEBREAKS, tag) >= 0) { stackTop()[2].sameLine = false; @@ -381,30 +380,32 @@ define(function(require, exports, module) { }); }; - Rewriter.prototype.addImplicitIndentation = function() { + Rewriter.prototype.normalizeLines = function() { var action, condition, indent, outdent, starter; starter = indent = outdent = null; condition = function(token, i) { - var _ref; - return token[1] !== ';' && (_ref = token[0], __indexOf.call(SINGLE_CLOSERS, _ref) >= 0) && !(token[0] === 'ELSE' && (starter !== 'IF' && starter !== 'THEN')); + var _ref, _ref1, _ref2, _ref3; + return token[1] !== ';' && (_ref = token[0], __indexOf.call(SINGLE_CLOSERS, _ref) >= 0) && !(token[0] === 'TERMINATOR' && (_ref1 = this.tag(i + 1), __indexOf.call(EXPRESSION_CLOSE, _ref1) >= 0)) && !(token[0] === 'ELSE' && starter !== 'THEN') && !(((_ref2 = token[0]) === 'CATCH' || _ref2 === 'FINALLY') && (starter === '->' || starter === '=>')) || (_ref3 = token[0], __indexOf.call(CALL_CLOSERS, _ref3) >= 0) && this.tokens[i - 1].newLine; }; action = function(token, i) { return this.tokens.splice((this.tag(i - 1) === ',' ? i - 1 : i), 0, outdent); }; return this.scanTokens(function(token, i, tokens) { - var j, tag, _i, _ref, _ref1; + var j, tag, _i, _ref, _ref1, _ref2; tag = token[0]; - if (tag === 'TERMINATOR' && this.tag(i + 1) === 'THEN') { - tokens.splice(i, 1); - return 0; - } - if (tag === 'ELSE' && this.tag(i - 1) !== 'OUTDENT') { - tokens.splice.apply(tokens, [i, 0].concat(__slice.call(this.indentation()))); - return 2; + if (tag === 'TERMINATOR') { + if (this.tag(i + 1) === 'ELSE' && this.tag(i - 1) !== 'OUTDENT') { + tokens.splice.apply(tokens, [i, 1].concat(__slice.call(this.indentation()))); + return 1; + } + if (_ref = this.tag(i + 1), __indexOf.call(EXPRESSION_CLOSE, _ref) >= 0) { + tokens.splice(i, 1); + return 0; + } } if (tag === 'CATCH') { for (j = _i = 1; _i <= 2; j = ++_i) { - if (!((_ref = this.tag(i + j)) === 'OUTDENT' || _ref === 'TERMINATOR' || _ref === 'FINALLY')) { + if (!((_ref1 = this.tag(i + j)) === 'OUTDENT' || _ref1 === 'TERMINATOR' || _ref1 === 'FINALLY')) { continue; } tokens.splice.apply(tokens, [i + j, 0].concat(__slice.call(this.indentation()))); @@ -413,7 +414,7 @@ define(function(require, exports, module) { } if (__indexOf.call(SINGLE_LINERS, tag) >= 0 && this.tag(i + 1) !== 'INDENT' && !(tag === 'ELSE' && this.tag(i + 1) === 'IF')) { starter = tag; - _ref1 = this.indentation(true), indent = _ref1[0], outdent = _ref1[1]; + _ref2 = this.indentation(true), indent = _ref2[0], outdent = _ref2[1]; if (starter === 'THEN') { indent.fromThen = true; } @@ -493,7 +494,7 @@ define(function(require, exports, module) { EXPRESSION_END.push(INVERSES[left] = rite); } - EXPRESSION_CLOSE = ['CATCH', 'WHEN', 'ELSE', 'FINALLY'].concat(EXPRESSION_END); + EXPRESSION_CLOSE = ['CATCH', 'THEN', 'ELSE', 'FINALLY'].concat(EXPRESSION_END); IMPLICIT_FUNC = ['IDENTIFIER', 'SUPER', ')', 'CALL_END', ']', 'INDEX_END', '@', 'THIS']; @@ -501,8 +502,6 @@ define(function(require, exports, module) { IMPLICIT_UNSPACED_CALL = ['+', '-']; - IMPLICIT_BLOCK = ['->', '=>', '{', '[', ',']; - IMPLICIT_END = ['POST_IF', 'FOR', 'WHILE', 'UNTIL', 'WHEN', 'BY', 'LOOP', 'TERMINATOR']; SINGLE_LINERS = ['ELSE', '->', '=>', 'TRY', 'FINALLY', 'THEN']; @@ -511,5 +510,7 @@ define(function(require, exports, module) { LINEBREAKS = ['TERMINATOR', 'INDENT', 'OUTDENT']; + CALL_CLOSERS = ['.', '?.', '::', '?::']; + }); \ No newline at end of file diff --git a/lib/ace/mode/coffee/scope.js b/lib/ace/mode/coffee/scope.js index e0b47928..5834963b 100644 --- a/lib/ace/mode/coffee/scope.js +++ b/lib/ace/mode/coffee/scope.js @@ -25,7 +25,7 @@ */ define(function(require, exports, module) { -// Generated by CoffeeScript 1.6.2 +// Generated by CoffeeScript 1.6.3 var Scope, extend, last, _ref; diff --git a/lib/ace/mode/coffee_highlight_rules.js b/lib/ace/mode/coffee_highlight_rules.js index c050f78a..94c9476f 100644 --- a/lib/ace/mode/coffee_highlight_rules.js +++ b/lib/ace/mode/coffee_highlight_rules.js @@ -41,7 +41,7 @@ define(function(require, exports, module) { var keywords = ( "this|throw|then|try|typeof|super|switch|return|break|by|continue|" + - "catch|class|in|instanceof|is|isnt|if|else|extends|for|forown|" + + "catch|class|in|instanceof|is|isnt|if|else|extends|for|own|" + "finally|function|while|when|new|no|not|delete|debugger|do|loop|of|off|" + "or|on|unless|until|and|yes" ); @@ -142,7 +142,7 @@ define(function(require, exports, module) { } if (val == "}" && stack.length) { stack.shift(); - this.next = stack.shift(); + this.next = stack.shift() || ""; if (this.next.indexOf("string") != -1) return "paren.string"; } diff --git a/lib/ace/mode/coffee_worker.js b/lib/ace/mode/coffee_worker.js index a5f700f8..d68f1296 100644 --- a/lib/ace/mode/coffee_worker.js +++ b/lib/ace/mode/coffee_worker.js @@ -49,13 +49,13 @@ oop.inherits(Worker, Mirror); this.onUpdate = function() { var value = this.doc.getValue(); - + var errors = []; try { coffee.parse(value).compile(); } catch(e) { var loc = e.location; if (loc) { - this.sender.emit("error", { + errors.push({ row: loc.first_line, column: loc.first_column, endRow: loc.last_line, @@ -64,9 +64,8 @@ oop.inherits(Worker, Mirror); type: "error" }); } - return; } - this.sender.emit("ok"); + this.sender.emit("annotate", errors); }; }).call(Worker.prototype); diff --git a/lib/ace/mode/coldfusion.js b/lib/ace/mode/coldfusion.js index fc62a89e..0b4ea449 100644 --- a/lib/ace/mode/coldfusion.js +++ b/lib/ace/mode/coldfusion.js @@ -32,32 +32,29 @@ define(function(require, exports, module) { "use strict"; var oop = require("../lib/oop"); -var XmlMode = require("./xml").Mode; -var JavaScriptMode = require("./javascript").Mode; -var CssMode = require("./css").Mode; -var Tokenizer = require("../tokenizer").Tokenizer; +var lang = require("../lib/lang"); +var HtmlMode = require("./html").Mode; var ColdfusionHighlightRules = require("./coldfusion_highlight_rules").ColdfusionHighlightRules; +var voidElements = "cfabort|cfapplication|cfargument|cfassociate|cfbreak|cfcache|cfcollection|cfcookie|cfdbinfo|cfdirectory|cfdump|cfelse|cfelseif|cferror|cfexchangecalendar|cfexchangeconnection|cfexchangecontact|cfexchangefilter|cfexchangetask|cfexit|cffeed|cffile|cfflush|cfftp|cfheader|cfhtmlhead|cfhttpparam|cfimage|cfimport|cfinclude|cfindex|cfinsert|cfinvokeargument|cflocation|cflog|cfmailparam|cfNTauthenticate|cfobject|cfobjectcache|cfparam|cfpdfformparam|cfprint|cfprocparam|cfprocresult|cfproperty|cfqueryparam|cfregistry|cfreportparam|cfrethrow|cfreturn|cfschedule|cfsearch|cfset|cfsetting|cfthrow|cfzipparam)".split("|"); + var Mode = function() { - XmlMode.call(this); + HtmlMode.call(this); - var highlighter = new ColdfusionHighlightRules(); - this.$tokenizer = new Tokenizer(highlighter.getRules()); - - this.$embeds = highlighter.getEmbeds(); - this.createModeDelegates({ - "js-": JavaScriptMode, - "css-": CssMode - }); + this.HighlightRules = ColdfusionHighlightRules; }; -oop.inherits(Mode, XmlMode); +oop.inherits(Mode, HtmlMode); (function() { + // mix with html void elements + this.voidElements = oop.mixin(lang.arrayToMap(voidElements), this.voidElements); + this.getNextLineIndent = function(state, line, tab) { return this.$getIndent(line); }; + this.$id = "ace/mode/coldfusion"; }).call(Mode.prototype); exports.Mode = Mode; diff --git a/lib/ace/mode/coldfusion_highlight_rules.js b/lib/ace/mode/coldfusion_highlight_rules.js index dddf867d..5feff6d6 100644 --- a/lib/ace/mode/coldfusion_highlight_rules.js +++ b/lib/ace/mode/coldfusion_highlight_rules.js @@ -32,92 +32,18 @@ define(function(require, exports, module) { "use strict"; var oop = require("../lib/oop"); -var CssHighlightRules = require("./css_highlight_rules").CssHighlightRules; var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScriptHighlightRules; -var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; -var xml_util = require("./xml_util"); +var HtmlHighlightRules = require("./html_highlight_rules").HtmlHighlightRules; var ColdfusionHighlightRules = function() { + HtmlHighlightRules.call(this); - // regexp must not have capturing parentheses - // regexps are ordered -> the first match is used + this.embedTagRules(JavaScriptHighlightRules, "cfjs-", "cfscript"); - this.$rules = { - start : [ { - token : "text", - regex : "<\\!\\[CDATA\\[", - next : "cdata" - }, { - token : "xml-pe", - regex : "<\\?.*?\\?>" - }, { - token : "comment", - regex : "<\\!--", - next : "comment" - }, { - token : "meta.tag", - regex : "<(?=script)", - next : "script" - }, { - token : "meta.tag", - regex : "<(?=cfscript)", - next : "cfscript" - }, { - token : "meta.tag", - regex : "<(?=style)", - next : "style" - }, { - token : "meta.tag", // opening tag - regex : "<\\/?", - next : "tag" - } ], - - cdata : [ { - token : "text", - regex : "\\]\\]>", - next : "start" - } ], - - comment : [ { - token : "comment", - regex : ".*?-->", - next : "start" - }, { - defaultToken : "comment" - } ] - }; - - xml_util.tag(this.$rules, "tag", "start"); - xml_util.tag(this.$rules, "style", "css-start"); - xml_util.tag(this.$rules, "script", "js-start"); - xml_util.tag(this.$rules, "cfscript", "js-start"); - - this.embedRules(JavaScriptHighlightRules, "js-", [{ - token: "comment", - regex: "\\/\\/.*(?=<\\/script>)", - next: "tag" - }, { - token: "meta.tag", - regex: "<\\/(?=script)", - next: "tag" - }, { - token: "comment", - regex: "\\/\\/.*(?=<\\/cfscript>)", - next: "tag" - }, { - token: "meta.tag", - regex: "<\\/(?=cfscript)", - next: "tag" - }]); - - this.embedRules(CssHighlightRules, "css-", [{ - token: "meta.tag", - regex: "<\\/(?=style)", - next: "tag" - }]); + this.normalizeRules(); }; -oop.inherits(ColdfusionHighlightRules, TextHighlightRules); +oop.inherits(ColdfusionHighlightRules, HtmlHighlightRules); exports.ColdfusionHighlightRules = ColdfusionHighlightRules; }); diff --git a/lib/ace/mode/csharp.js b/lib/ace/mode/csharp.js index 2e536294..a3b2964f 100644 --- a/lib/ace/mode/csharp.js +++ b/lib/ace/mode/csharp.js @@ -3,14 +3,13 @@ define(function(require, exports, module) { var oop = require("../lib/oop"); var TextMode = require("./text").Mode; -var Tokenizer = require("../tokenizer").Tokenizer; var CSharpHighlightRules = require("./csharp_highlight_rules").CSharpHighlightRules; var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour; -var CStyleFoldMode = require("./folding/cstyle").FoldMode; +var CStyleFoldMode = require("./folding/csharp").FoldMode; var Mode = function() { - this.$tokenizer = new Tokenizer(new CSharpHighlightRules().getRules()); + this.HighlightRules = CSharpHighlightRules; this.$outdent = new MatchingBraceOutdent(); this.$behaviour = new CstyleBehaviour(); this.foldingRules = new CStyleFoldMode(); @@ -25,7 +24,7 @@ oop.inherits(Mode, TextMode); this.getNextLineIndent = function(state, line, tab) { var indent = this.$getIndent(line); - var tokenizedLine = this.$tokenizer.getLineTokens(line, state); + var tokenizedLine = this.getTokenizer().getLineTokens(line, state); var tokens = tokenizedLine.tokens; if (tokens.length && tokens[tokens.length-1].type == "comment") { @@ -55,6 +54,7 @@ oop.inherits(Mode, TextMode); return null; }; + this.$id = "ace/mode/csharp"; }).call(Mode.prototype); exports.Mode = Mode; diff --git a/lib/ace/mode/csharp_highlight_rules.js b/lib/ace/mode/csharp_highlight_rules.js index c18be8ea..6e7ba5d4 100644 --- a/lib/ace/mode/csharp_highlight_rules.js +++ b/lib/ace/mode/csharp_highlight_rules.js @@ -26,9 +26,6 @@ var CSharpHighlightRules = function() { token : "comment", // multi line comment regex : "\\/\\*", next : "comment" - }, { - token : "string.regexp", - regex : "[/](?:(?:\\[(?:\\\\]|[^\\]])+\\])|(?:\\\\/|[^\\]/]))*[/]\\w*\\s*(?=[).,;]|$)" }, { token : "string", // character regex : /'(?:.|\\(:?u[\da-fA-F]+|x[\da-fA-F]+|[tbrf'"n]))'/ @@ -56,6 +53,9 @@ var CSharpHighlightRules = function() { }, { token : "keyword.operator", regex : "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|instanceof|new|delete|typeof|void)" + }, { + token : "keyword", + regex : "^\\s*#(if|else|elif|endif|define|undef|warning|error|line|region|endregion|pragma)" }, { token : "punctuation.operator", regex : "\\?|\\:|\\,|\\;|\\." diff --git a/lib/ace/mode/css.js b/lib/ace/mode/css.js index 2c5807c7..6fef5ccd 100644 --- a/lib/ace/mode/css.js +++ b/lib/ace/mode/css.js @@ -33,7 +33,6 @@ define(function(require, exports, module) { var oop = require("../lib/oop"); var TextMode = require("./text").Mode; -var Tokenizer = require("../tokenizer").Tokenizer; var CssHighlightRules = require("./css_highlight_rules").CssHighlightRules; var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; var WorkerClient = require("../worker/worker_client").WorkerClient; @@ -41,7 +40,7 @@ var CssBehaviour = require("./behaviour/css").CssBehaviour; var CStyleFoldMode = require("./folding/cstyle").FoldMode; var Mode = function() { - this.$tokenizer = new Tokenizer(new CssHighlightRules().getRules()); + this.HighlightRules = CssHighlightRules; this.$outdent = new MatchingBraceOutdent(); this.$behaviour = new CssBehaviour(); this.foldingRules = new CStyleFoldMode(); @@ -57,7 +56,7 @@ oop.inherits(Mode, TextMode); var indent = this.$getIndent(line); // ignore braces in comments - var tokens = this.$tokenizer.getLineTokens(line, state).tokens; + var tokens = this.getTokenizer().getLineTokens(line, state).tokens; if (tokens.length && tokens[tokens.length-1].type == "comment") { return indent; } @@ -82,7 +81,7 @@ oop.inherits(Mode, TextMode); var worker = new WorkerClient(["ace"], "ace/mode/css_worker", "Worker"); worker.attachToDocument(session.getDocument()); - worker.on("csslint", function(e) { + worker.on("annotate", function(e) { session.setAnnotations(e.data); }); @@ -93,6 +92,7 @@ oop.inherits(Mode, TextMode); return worker; }; + this.$id = "ace/mode/css"; }).call(Mode.prototype); exports.Mode = Mode; diff --git a/lib/ace/mode/css/csslint.js b/lib/ace/mode/css/csslint.js index 9f4c3bc8..c3c79a80 100644 --- a/lib/ace/mode/css/csslint.js +++ b/lib/ace/mode/css/csslint.js @@ -1,10 +1,10 @@ define(function(require, exports, module) { /*! CSSLint -Copyright (c) 2011 Nicole Sullivan and Nicholas C. Zakas. All rights reserved. +Copyright (c) 2014 Nicole Sullivan and Nicholas C. Zakas. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal +of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is @@ -13,7 +13,7 @@ furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER @@ -22,7 +22,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/* Build time: 17-January-2013 10:55:01 */ +/* Build: v0.10.0 22-July-2014 01:17:52 */ /*! Parser-Lib Copyright (c) 2009-2011 Nicholas C. Zakas. All rights reserved. @@ -46,11 +46,10 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/* Version v0.2.2, Build time: 17-January-2013 10:26:34 */ +/* Version v0.2.5, Build time: 7-May-2014 03:37:38 */ var parserlib = {}; (function(){ - /** * A generic base to inherit from for any object * that needs event handling. @@ -65,7 +64,7 @@ function EventTarget(){ * @property _listeners * @private */ - this._listeners = {}; + this._listeners = {}; } EventTarget.prototype = { @@ -87,14 +86,14 @@ EventTarget.prototype = { this._listeners[type].push(listener); }, - + /** * Fires an event based on the passed-in object. * @param {Object|String} event An object with at least a 'type' attribute * or a string indicating the event name. * @return {void} * @method fire - */ + */ fire: function(event){ if (typeof event == "string"){ event = { type: event }; @@ -102,19 +101,19 @@ EventTarget.prototype = { if (typeof event.target != "undefined"){ event.target = this; } - + if (typeof event.type == "undefined"){ throw new Error("Event object missing 'type' property."); } - + if (this._listeners[event.type]){ - + //create a copy of the array and use that so listeners can't chane var listeners = this._listeners[event.type].concat(); for (var i=0, len=listeners.length; i < len; i++){ listeners[i].call(this, event); } - } + } }, /** @@ -133,9 +132,9 @@ EventTarget.prototype = { break; } } - - - } + + + } } }; /** @@ -499,16 +498,16 @@ SyntaxUnit.prototype = { //restore constructor constructor: SyntaxUnit, - + /** * Returns the text representation of the unit. * @return {String} The text representation of the unit. * @method valueOf */ valueOf: function(){ - return this.toString(); + return this.text; }, - + /** * Returns the text representation of the unit. * @return {String} The text representation of the unit. @@ -526,7 +525,7 @@ SyntaxUnit.prototype = { * @class TokenStreamBase * @namespace parserlib.util * @constructor - * @param {String|StringReader} input The text to tokenize or a reader from + * @param {String|StringReader} input The text to tokenize or a reader from * which to read the input. */ function TokenStreamBase(input, tokenData){ @@ -538,15 +537,15 @@ function TokenStreamBase(input, tokenData){ * @private */ this._reader = input ? new StringReader(input.toString()) : null; - + /** * Token object for the last consumed token. * @type Token * @property _token * @private */ - this._token = null; - + this._token = null; + /** * The array of token information. * @type Array @@ -554,7 +553,7 @@ function TokenStreamBase(input, tokenData){ * @private */ this._tokenData = tokenData; - + /** * Lookahead token buffer. * @type Array @@ -562,7 +561,7 @@ function TokenStreamBase(input, tokenData){ * @private */ this._lt = []; - + /** * Lookahead token buffer index. * @type int @@ -570,7 +569,7 @@ function TokenStreamBase(input, tokenData){ * @private */ this._ltIndex = 0; - + this._ltIndexCache = []; } @@ -590,7 +589,7 @@ TokenStreamBase.createTokenData = function(tokens){ tokenData = tokens.concat([]), i = 0, len = tokenData.length+1; - + tokenData.UNKNOWN = -1; tokenData.unshift({name:"EOF"}); @@ -601,27 +600,27 @@ TokenStreamBase.createTokenData = function(tokens){ typeMap[tokenData[i].text] = i; } } - + tokenData.name = function(tt){ return nameMap[tt]; }; - + tokenData.type = function(c){ return typeMap[c]; }; - + return tokenData; }; TokenStreamBase.prototype = { //restore constructor - constructor: TokenStreamBase, - + constructor: TokenStreamBase, + //------------------------------------------------------------------------- // Matching methods //------------------------------------------------------------------------- - + /** * Determines if the next token matches the given token type. * If so, that token is consumed; if not, the token is placed @@ -637,27 +636,27 @@ TokenStreamBase.prototype = { * @method match */ match: function(tokenTypes, channel){ - + //always convert to an array, makes things easier if (!(tokenTypes instanceof Array)){ tokenTypes = [tokenTypes]; } - + var tt = this.get(channel), i = 0, len = tokenTypes.length; - + while(i < len){ if (tt == tokenTypes[i++]){ return true; } } - + //no match found, put the token back this.unget(); return false; - }, - + }, + /** * Determines if the next token matches the given token type. * If so, that token is consumed; if not, an error is thrown. @@ -668,7 +667,7 @@ TokenStreamBase.prototype = { * provided, reads from the default (unnamed) channel. * @return {void} * @method mustMatch - */ + */ mustMatch: function(tokenTypes, channel){ var token; @@ -678,17 +677,17 @@ TokenStreamBase.prototype = { tokenTypes = [tokenTypes]; } - if (!this.match.apply(this, arguments)){ + if (!this.match.apply(this, arguments)){ token = this.LT(1); - throw new SyntaxError("Expected " + this._tokenData[tokenTypes[0]].name + + throw new SyntaxError("Expected " + this._tokenData[tokenTypes[0]].name + " at line " + token.startLine + ", col " + token.startCol + ".", token.startLine, token.startCol); } }, - + //------------------------------------------------------------------------- // Consuming methods //------------------------------------------------------------------------- - + /** * Keeps reading from the token stream until either one of the specified * token types is found or until the end of the input is reached. @@ -701,21 +700,21 @@ TokenStreamBase.prototype = { * @method advance */ advance: function(tokenTypes, channel){ - + while(this.LA(0) !== 0 && !this.match(tokenTypes, channel)){ this.get(); } - return this.LA(0); + return this.LA(0); }, - + /** - * Consumes the next token from the token stream. + * Consumes the next token from the token stream. * @return {int} The token type of the token that was just consumed. * @method get - */ + */ get: function(channel){ - + var tokenInfo = this._tokenData, reader = this._reader, value, @@ -724,14 +723,14 @@ TokenStreamBase.prototype = { found = false, token, info; - + //check the lookahead buffer first - if (this._lt.length && this._ltIndex >= 0 && this._ltIndex < this._lt.length){ - + if (this._lt.length && this._ltIndex >= 0 && this._ltIndex < this._lt.length){ + i++; this._token = this._lt[this._ltIndex++]; info = tokenInfo[this._token.type]; - + //obey channels logic while((info.channel !== undefined && channel !== info.channel) && this._ltIndex < this._lt.length){ @@ -739,7 +738,7 @@ TokenStreamBase.prototype = { info = tokenInfo[this._token.type]; i++; } - + //here be dragons if ((info.channel === undefined || channel === info.channel) && this._ltIndex <= this._lt.length){ @@ -747,45 +746,45 @@ TokenStreamBase.prototype = { return this._token.type; } } - + //call token retriever method token = this._getToken(); //if it should be hidden, don't save a token if (token.type > -1 && !tokenInfo[token.type].hide){ - + //apply token channel token.channel = tokenInfo[token.type].channel; - + //save for later this._token = token; this._lt.push(token); //save space that will be moved (must be done before array is truncated) - this._ltIndexCache.push(this._lt.length - this._ltIndex + i); - + this._ltIndexCache.push(this._lt.length - this._ltIndex + i); + //keep the buffer under 5 items if (this._lt.length > 5){ - this._lt.shift(); + this._lt.shift(); } - + //also keep the shift buffer under 5 items if (this._ltIndexCache.length > 5){ this._ltIndexCache.shift(); } - + //update lookahead index this._ltIndex = this._lt.length; } - + /* * Skip to the next token if: * 1. The token type is marked as hidden. * 2. The token type has a channel specified and it isn't the current channel. */ info = tokenInfo[token.type]; - if (info && - (info.hide || + if (info && + (info.hide || (info.channel !== undefined && channel !== info.channel))){ return this.get(channel); } else { @@ -793,7 +792,7 @@ TokenStreamBase.prototype = { return token.type; } }, - + /** * Looks ahead a certain number of tokens and returns the token type at * that position. This will throw an error if you lookahead past the @@ -812,34 +811,34 @@ TokenStreamBase.prototype = { if (index > 5){ throw new Error("Too much lookahead."); } - + //get all those tokens while(total){ - tt = this.get(); - total--; + tt = this.get(); + total--; } - + //unget all those tokens while(total < index){ this.unget(); total++; } } else if (index < 0){ - + if(this._lt[this._ltIndex+index]){ tt = this._lt[this._ltIndex+index].type; } else { throw new Error("Too much lookbehind."); } - + } else { tt = this._token.type; } - + return tt; - + }, - + /** * Looks ahead a certain number of tokens and returns the token at * that position. This will throw an error if you lookahead past the @@ -849,18 +848,18 @@ TokenStreamBase.prototype = { * current token, 1 for the next, -1 for the previous, etc. * @return {Object} The token of the token in the given position. * @method LA - */ + */ LT: function(index){ - + //lookahead first to prime the token buffer this.LA(index); - + //now find the token, subtract one because _ltIndex is already at the next index - return this._lt[this._ltIndex+index-1]; + return this._lt[this._ltIndex+index-1]; }, - + /** - * Returns the token type for the next token in the stream without + * Returns the token type for the next token in the stream without * consuming it. * @return {int} The token type of the next token in the stream. * @method peek @@ -868,7 +867,7 @@ TokenStreamBase.prototype = { peek: function(){ return this.LA(1); }, - + /** * Returns the actual token object for the last consumed token. * @return {Token} The token object for the last consumed token. @@ -877,7 +876,7 @@ TokenStreamBase.prototype = { token: function(){ return this._token; }, - + /** * Returns the name of the token for the given token type. * @param {int} tokenType The type of token to get the name of. @@ -892,22 +891,22 @@ TokenStreamBase.prototype = { return this._tokenData[tokenType].name; } }, - + /** * Returns the token type value for the given token name. * @param {String} tokenName The name of the token whose value should be returned. * @return {int} The token type value for the given token name or -1 * for an unknown token. * @method tokenName - */ + */ tokenType: function(tokenName){ return this._tokenData[tokenName] || -1; }, - + /** * Returns the last consumed token to the token stream. * @method unget - */ + */ unget: function(){ //if (this._ltIndex > -1){ if (this._ltIndexCache.length){ @@ -921,8 +920,6 @@ TokenStreamBase.prototype = { }; - - parserlib.util = { StringReader: StringReader, SyntaxError : SyntaxError, @@ -931,8 +928,6 @@ EventTarget : EventTarget, TokenStreamBase : TokenStreamBase }; })(); - - /* Parser-Lib Copyright (c) 2009-2011 Nicholas C. Zakas. All rights reserved. @@ -956,7 +951,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/* Version v0.2.2, Build time: 17-January-2013 10:26:34 */ +/* Version v0.2.5, Build time: 7-May-2014 03:37:38 */ (function(){ var EventTarget = parserlib.util.EventTarget, TokenStreamBase = parserlib.util.TokenStreamBase, @@ -964,7 +959,6 @@ StringReader = parserlib.util.StringReader, SyntaxError = parserlib.util.SyntaxError, SyntaxUnit = parserlib.util.SyntaxUnit; - var Colors = { aliceblue :"#f0f8ff", antiquewhite :"#faebd7", @@ -991,6 +985,7 @@ var Colors = { darkcyan :"#008b8b", darkgoldenrod :"#b8860b", darkgray :"#a9a9a9", + darkgrey :"#a9a9a9", darkgreen :"#006400", darkkhaki :"#bdb76b", darkmagenta :"#8b008b", @@ -1002,11 +997,13 @@ var Colors = { darkseagreen :"#8fbc8f", darkslateblue :"#483d8b", darkslategray :"#2f4f4f", + darkslategrey :"#2f4f4f", darkturquoise :"#00ced1", darkviolet :"#9400d3", deeppink :"#ff1493", deepskyblue :"#00bfff", dimgray :"#696969", + dimgrey :"#696969", dodgerblue :"#1e90ff", firebrick :"#b22222", floralwhite :"#fffaf0", @@ -1017,6 +1014,7 @@ var Colors = { gold :"#ffd700", goldenrod :"#daa520", gray :"#808080", + grey :"#808080", green :"#008000", greenyellow :"#adff2f", honeydew :"#f0fff0", @@ -1034,12 +1032,14 @@ var Colors = { lightcyan :"#e0ffff", lightgoldenrodyellow :"#fafad2", lightgray :"#d3d3d3", + lightgrey :"#d3d3d3", lightgreen :"#90ee90", lightpink :"#ffb6c1", lightsalmon :"#ffa07a", lightseagreen :"#20b2aa", lightskyblue :"#87cefa", lightslategray :"#778899", + lightslategrey :"#778899", lightsteelblue :"#b0c4de", lightyellow :"#ffffe0", lime :"#00ff00", @@ -1092,6 +1092,7 @@ var Colors = { skyblue :"#87ceeb", slateblue :"#6a5acd", slategray :"#708090", + slategrey :"#708090", snow :"#fffafa", springgreen :"#00ff7f", steelblue :"#4682b4", @@ -1117,6 +1118,7 @@ var Colors = { buttontext :"Text on push buttons.", captiontext :"Text in caption, size box, and scrollbar arrow box.", graytext :"Grayed (disabled) text. This color is set to #000 if the current display driver does not support a solid gray color.", + greytext :"Greyed (disabled) text. This color is set to #000 if the current display driver does not support a solid grey color.", highlight :"Item(s) selected in a control.", highlighttext :"Text of item(s) selected in a control.", inactiveborder :"Inactive window border.", @@ -1143,12 +1145,12 @@ var Colors = { * @class Combinator * @extends parserlib.util.SyntaxUnit * @constructor - * @param {String} text The text representation of the unit. + * @param {String} text The text representation of the unit. * @param {int} line The line of text on which the unit resides. * @param {int} col The column of text on which the unit resides. */ function Combinator(text, line, col){ - + SyntaxUnit.call(this, text, line, col, Parser.COMBINATOR_TYPE); /** @@ -1157,7 +1159,7 @@ function Combinator(text, line, col){ * @property type */ this.type = "unknown"; - + //pretty simple if (/^\s+$/.test(text)){ this.type = "descendant"; @@ -1174,7 +1176,6 @@ function Combinator(text, line, col){ Combinator.prototype = new SyntaxUnit(); Combinator.prototype.constructor = Combinator; - /*global SyntaxUnit, Parser*/ /** * Represents a media feature, such as max-width:500. @@ -1186,7 +1187,7 @@ Combinator.prototype.constructor = Combinator; * @param {SyntaxUnit} value The value of the feature or null if none. */ function MediaFeature(name, value){ - + SyntaxUnit.call(this, "(" + name + (value !== null ? ":" + value : "") + ")", name.startLine, name.startCol, Parser.MEDIA_FEATURE_TYPE); /** @@ -1207,7 +1208,6 @@ function MediaFeature(name, value){ MediaFeature.prototype = new SyntaxUnit(); MediaFeature.prototype.constructor = MediaFeature; - /*global SyntaxUnit, Parser*/ /** * Represents an individual media query. @@ -1222,8 +1222,8 @@ MediaFeature.prototype.constructor = MediaFeature; * @param {int} col The column of text on which the unit resides. */ function MediaQuery(modifier, mediaType, features, line, col){ - - SyntaxUnit.call(this, (modifier ? modifier + " ": "") + (mediaType ? mediaType : "") + (mediaType && features.length > 0 ? " and " : "") + features.join(" and "), line, col, Parser.MEDIA_QUERY_TYPE); + + SyntaxUnit.call(this, (modifier ? modifier + " ": "") + (mediaType ? mediaType : "") + (mediaType && features.length > 0 ? " and " : "") + features.join(" and "), line, col, Parser.MEDIA_QUERY_TYPE); /** * The media modifier ("not" or "only") @@ -1237,8 +1237,8 @@ function MediaQuery(modifier, mediaType, features, line, col){ * @type String * @property mediaType */ - this.mediaType = mediaType; - + this.mediaType = mediaType; + /** * The parts that make up the selector. * @type Array @@ -1251,7 +1251,6 @@ function MediaQuery(modifier, mediaType, features, line, col){ MediaQuery.prototype = new SyntaxUnit(); MediaQuery.prototype.constructor = MediaQuery; - /*global Tokens, TokenStream, SyntaxError, Properties, Validation, ValidationError, SyntaxUnit, PropertyValue, PropertyValuePart, SelectorPart, SelectorSubPart, Selector, PropertyName, Combinator, MediaFeature, MediaQuery, EventTarget */ @@ -1296,10 +1295,10 @@ Parser.prototype = function(){ var proto = new EventTarget(), //new prototype prop, additions = { - + //restore constructor constructor: Parser, - + //instance constants - yuck DEFAULT_TYPE : 0, COMBINATOR_TYPE : 1, @@ -1310,14 +1309,14 @@ Parser.prototype = function(){ PROPERTY_VALUE_PART_TYPE : 6, SELECTOR_TYPE : 7, SELECTOR_PART_TYPE : 8, - SELECTOR_SUB_PART_TYPE : 9, - + SELECTOR_SUB_PART_TYPE : 9, + //----------------------------------------------------------------- // Grammar //----------------------------------------------------------------- - + _stylesheet: function(){ - + /* * stylesheet * : [ CHARSET_SYM S* STRING S* ';' ]? @@ -1325,19 +1324,19 @@ Parser.prototype = function(){ * [ namespace [S|CDO|CDC]* ]* * [ [ ruleset | media | page | font_face | keyframes ] [S|CDO|CDC]* ]* * ; - */ - + */ + var tokenStream = this._tokenStream, charset = null, count, token, tt; - + this.fire("startstylesheet"); - + //try to read character set this._charset(); - + this._skipCruft(); //try to read imports - may be more than one @@ -1345,42 +1344,46 @@ Parser.prototype = function(){ this._import(); this._skipCruft(); } - + //try to read namespaces - may be more than one while (tokenStream.peek() == Tokens.NAMESPACE_SYM){ this._namespace(); this._skipCruft(); } - + //get the next token tt = tokenStream.peek(); - + //try to read the rest while(tt > Tokens.EOF){ - + try { - + switch(tt){ case Tokens.MEDIA_SYM: this._media(); this._skipCruft(); break; case Tokens.PAGE_SYM: - this._page(); + this._page(); this._skipCruft(); - break; + break; case Tokens.FONT_FACE_SYM: - this._font_face(); + this._font_face(); this._skipCruft(); - break; + break; case Tokens.KEYFRAMES_SYM: - this._keyframes(); + this._keyframes(); this._skipCruft(); - break; + break; + case Tokens.VIEWPORT_SYM: + this._viewport(); + this._skipCruft(); + break; case Tokens.UNKNOWN_SYM: //unknown @ rule tokenStream.get(); if (!this.options.strict){ - + //fire error event this.fire({ type: "error", @@ -1388,30 +1391,30 @@ Parser.prototype = function(){ message: "Unknown @ rule: " + tokenStream.LT(0).value + ".", line: tokenStream.LT(0).startLine, col: tokenStream.LT(0).startCol - }); - + }); + //skip braces count=0; while (tokenStream.advance([Tokens.LBRACE, Tokens.RBRACE]) == Tokens.LBRACE){ count++; //keep track of nesting depth } - + while(count){ tokenStream.advance([Tokens.RBRACE]); count--; } - + } else { //not a syntax error, rethrow it throw new SyntaxError("Unknown @ rule.", tokenStream.LT(0).startLine, tokenStream.LT(0).startCol); - } + } break; case Tokens.S: this._readWhitespace(); break; - default: + default: if(!this._ruleset()){ - + //error handling for known issues switch(tt){ case Tokens.CHARSET_SYM: @@ -1430,7 +1433,7 @@ Parser.prototype = function(){ tokenStream.get(); //get the last token this._unexpectedToken(tokenStream.token()); } - + } } } catch(ex) { @@ -1441,84 +1444,84 @@ Parser.prototype = function(){ message: ex.message, line: ex.line, col: ex.col - }); + }); } else { throw ex; } } - + tt = tokenStream.peek(); } - + if (tt != Tokens.EOF){ this._unexpectedToken(tokenStream.token()); } - + this.fire("endstylesheet"); }, - + _charset: function(emit){ var tokenStream = this._tokenStream, charset, token, line, col; - + if (tokenStream.match(Tokens.CHARSET_SYM)){ line = tokenStream.token().startLine; col = tokenStream.token().startCol; - + this._readWhitespace(); tokenStream.mustMatch(Tokens.STRING); - + token = tokenStream.token(); charset = token.value; - + this._readWhitespace(); tokenStream.mustMatch(Tokens.SEMICOLON); - + if (emit !== false){ - this.fire({ + this.fire({ type: "charset", charset:charset, line: line, col: col }); } - } + } }, - + _import: function(emit){ /* * import * : IMPORT_SYM S* * [STRING|URI] S* media_query_list? ';' S* - */ - + */ + var tokenStream = this._tokenStream, tt, uri, importToken, mediaList = []; - + //read import symbol tokenStream.mustMatch(Tokens.IMPORT_SYM); importToken = tokenStream.token(); this._readWhitespace(); - + tokenStream.mustMatch([Tokens.STRING, Tokens.URI]); - + //grab the URI value - uri = tokenStream.token().value.replace(/(?:url\()?["']([^"']+)["']\)?/, "$1"); + uri = tokenStream.token().value.replace(/^(?:url\()?["']?([^"']+?)["']?\)?$/, "$1"); this._readWhitespace(); - + mediaList = this._media_query_list(); - + //must end with a semicolon tokenStream.mustMatch(Tokens.SEMICOLON); this._readWhitespace(); - + if (emit !== false){ this.fire({ type: "import", @@ -1528,47 +1531,47 @@ Parser.prototype = function(){ col: importToken.startCol }); } - + }, - + _namespace: function(emit){ /* * namespace * : NAMESPACE_SYM S* [namespace_prefix S*]? [STRING|URI] S* ';' S* - */ - + */ + var tokenStream = this._tokenStream, line, col, prefix, uri; - + //read import symbol tokenStream.mustMatch(Tokens.NAMESPACE_SYM); line = tokenStream.token().startLine; col = tokenStream.token().startCol; this._readWhitespace(); - + //it's a namespace prefix - no _namespace_prefix() method because it's just an IDENT if (tokenStream.match(Tokens.IDENT)){ prefix = tokenStream.token().value; this._readWhitespace(); } - + tokenStream.mustMatch([Tokens.STRING, Tokens.URI]); /*if (!tokenStream.match(Tokens.STRING)){ tokenStream.mustMatch(Tokens.URI); }*/ - + //grab the URI value - uri = tokenStream.token().value.replace(/(?:url\()?["']([^"']+)["']\)?/, "$1"); + uri = tokenStream.token().value.replace(/(?:url\()?["']([^"']+)["']\)?/, "$1"); this._readWhitespace(); //must end with a semicolon tokenStream.mustMatch(Tokens.SEMICOLON); this._readWhitespace(); - + if (emit !== false){ this.fire({ type: "namespace", @@ -1578,9 +1581,9 @@ Parser.prototype = function(){ col: col }); } - - }, - + + }, + _media: function(){ /* * media @@ -1591,45 +1594,49 @@ Parser.prototype = function(){ line, col, mediaList;// = []; - + //look for @media tokenStream.mustMatch(Tokens.MEDIA_SYM); line = tokenStream.token().startLine; col = tokenStream.token().startCol; - - this._readWhitespace(); + + this._readWhitespace(); mediaList = this._media_query_list(); tokenStream.mustMatch(Tokens.LBRACE); this._readWhitespace(); - + this.fire({ type: "startmedia", media: mediaList, line: line, col: col }); - + while(true) { if (tokenStream.peek() == Tokens.PAGE_SYM){ this._page(); + } else if (tokenStream.peek() == Tokens.FONT_FACE_SYM){ + this._font_face(); + } else if (tokenStream.peek() == Tokens.VIEWPORT_SYM){ + this._viewport(); } else if (!this._ruleset()){ break; - } + } } - + tokenStream.mustMatch(Tokens.RBRACE); this._readWhitespace(); - + this.fire({ type: "endmedia", media: mediaList, line: line, col: col }); - }, - + }, + //CSS3 Media Queries _media_query_list: function(){ @@ -1640,26 +1647,26 @@ Parser.prototype = function(){ */ var tokenStream = this._tokenStream, mediaList = []; - - + + this._readWhitespace(); - + if (tokenStream.peek() == Tokens.IDENT || tokenStream.peek() == Tokens.LPAREN){ mediaList.push(this._media_query()); } - + while(tokenStream.match(Tokens.COMMA)){ this._readWhitespace(); mediaList.push(this._media_query()); } - + return mediaList; }, - + /* * Note: "expression" in the grammar maps to the _media_expression * method. - + */ _media_query: function(){ /* @@ -1673,10 +1680,10 @@ Parser.prototype = function(){ ident = null, token = null, expressions = []; - + if (tokenStream.match(Tokens.IDENT)){ ident = tokenStream.token().value.toLowerCase(); - + //since there's no custom tokens for these, need to manually check if (ident != "only" && ident != "not"){ tokenStream.unget(); @@ -1685,9 +1692,9 @@ Parser.prototype = function(){ token = tokenStream.token(); } } - + this._readWhitespace(); - + if (tokenStream.peek() == Tokens.IDENT){ type = this._media_type(); if (token === null){ @@ -1698,17 +1705,17 @@ Parser.prototype = function(){ token = tokenStream.LT(1); } expressions.push(this._media_expression()); - } - + } + if (type === null && expressions.length === 0){ return null; - } else { + } else { this._readWhitespace(); while (tokenStream.match(Tokens.IDENT)){ if (tokenStream.token().value.toLowerCase() != "and"){ this._unexpectedToken(tokenStream.token()); } - + this._readWhitespace(); expressions.push(this._media_expression()); } @@ -1724,7 +1731,7 @@ Parser.prototype = function(){ * : IDENT * ; */ - return this._media_feature(); + return this._media_feature(); }, /** @@ -1745,22 +1752,22 @@ Parser.prototype = function(){ feature = null, token, expression = null; - + tokenStream.mustMatch(Tokens.LPAREN); - + feature = this._media_feature(); this._readWhitespace(); - + if (tokenStream.match(Tokens.COLON)){ this._readWhitespace(); token = tokenStream.LT(1); expression = this._expression(); } - + tokenStream.mustMatch(Tokens.RPAREN); this._readWhitespace(); - return new MediaFeature(feature, (expression ? new SyntaxUnit(expression, token.startLine, token.startCol) : null)); + return new MediaFeature(feature, (expression ? new SyntaxUnit(expression, token.startLine, token.startCol) : null)); }, //CSS3 Media Queries @@ -1771,33 +1778,33 @@ Parser.prototype = function(){ * ; */ var tokenStream = this._tokenStream; - + tokenStream.mustMatch(Tokens.IDENT); - - return SyntaxUnit.fromToken(tokenStream.token()); + + return SyntaxUnit.fromToken(tokenStream.token()); }, - + //CSS3 Paged Media _page: function(){ /* * page: - * PAGE_SYM S* IDENT? pseudo_page? S* + * PAGE_SYM S* IDENT? pseudo_page? S* * '{' S* [ declaration | margin ]? [ ';' S* [ declaration | margin ]? ]* '}' S* * ; - */ + */ var tokenStream = this._tokenStream, line, col, identifier = null, pseudoPage = null; - + //look for @page tokenStream.mustMatch(Tokens.PAGE_SYM); line = tokenStream.token().startLine; col = tokenStream.token().startCol; - + this._readWhitespace(); - + if (tokenStream.match(Tokens.IDENT)){ identifier = tokenStream.token().value; @@ -1805,35 +1812,35 @@ Parser.prototype = function(){ if (identifier.toLowerCase() === "auto"){ this._unexpectedToken(tokenStream.token()); } - } - + } + //see if there's a colon upcoming if (tokenStream.peek() == Tokens.COLON){ pseudoPage = this._pseudo_page(); } - + this._readWhitespace(); - + this.fire({ type: "startpage", id: identifier, pseudo: pseudoPage, line: line, col: col - }); + }); + + this._readDeclarations(true, true); - this._readDeclarations(true, true); - this.fire({ type: "endpage", id: identifier, pseudo: pseudoPage, line: line, col: col - }); - + }); + }, - + //CSS3 Paged Media _margin: function(){ /* @@ -1849,14 +1856,14 @@ Parser.prototype = function(){ if (marginSym){ line = tokenStream.token().startLine; col = tokenStream.token().startCol; - + this.fire({ type: "startpagemargin", margin: marginSym, line: line, col: col - }); - + }); + this._readDeclarations(true); this.fire({ @@ -1864,7 +1871,7 @@ Parser.prototype = function(){ margin: marginSym, line: line, col: col - }); + }); return true; } else { return false; @@ -1873,17 +1880,17 @@ Parser.prototype = function(){ //CSS3 Paged Media _margin_sym: function(){ - + /* * margin_sym : - * TOPLEFTCORNER_SYM | - * TOPLEFT_SYM | - * TOPCENTER_SYM | - * TOPRIGHT_SYM | + * TOPLEFTCORNER_SYM | + * TOPLEFT_SYM | + * TOPCENTER_SYM | + * TOPRIGHT_SYM | * TOPRIGHTCORNER_SYM | - * BOTTOMLEFTCORNER_SYM | - * BOTTOMLEFT_SYM | - * BOTTOMCENTER_SYM | + * BOTTOMLEFTCORNER_SYM | + * BOTTOMLEFT_SYM | + * BOTTOMCENTER_SYM | * BOTTOMRIGHT_SYM | * BOTTOMRIGHTCORNER_SYM | * LEFTTOP_SYM | @@ -1891,145 +1898,178 @@ Parser.prototype = function(){ * LEFTBOTTOM_SYM | * RIGHTTOP_SYM | * RIGHTMIDDLE_SYM | - * RIGHTBOTTOM_SYM + * RIGHTBOTTOM_SYM * ; */ - + var tokenStream = this._tokenStream; - + if(tokenStream.match([Tokens.TOPLEFTCORNER_SYM, Tokens.TOPLEFT_SYM, Tokens.TOPCENTER_SYM, Tokens.TOPRIGHT_SYM, Tokens.TOPRIGHTCORNER_SYM, - Tokens.BOTTOMLEFTCORNER_SYM, Tokens.BOTTOMLEFT_SYM, + Tokens.BOTTOMLEFTCORNER_SYM, Tokens.BOTTOMLEFT_SYM, Tokens.BOTTOMCENTER_SYM, Tokens.BOTTOMRIGHT_SYM, - Tokens.BOTTOMRIGHTCORNER_SYM, Tokens.LEFTTOP_SYM, + Tokens.BOTTOMRIGHTCORNER_SYM, Tokens.LEFTTOP_SYM, Tokens.LEFTMIDDLE_SYM, Tokens.LEFTBOTTOM_SYM, Tokens.RIGHTTOP_SYM, Tokens.RIGHTMIDDLE_SYM, Tokens.RIGHTBOTTOM_SYM])) { - return SyntaxUnit.fromToken(tokenStream.token()); + return SyntaxUnit.fromToken(tokenStream.token()); } else { return null; } - + }, - + _pseudo_page: function(){ /* * pseudo_page * : ':' IDENT - * ; + * ; */ - + var tokenStream = this._tokenStream; - + tokenStream.mustMatch(Tokens.COLON); tokenStream.mustMatch(Tokens.IDENT); - + //TODO: CSS3 Paged Media says only "left", "center", and "right" are allowed - + return tokenStream.token().value; }, - + _font_face: function(){ /* * font_face - * : FONT_FACE_SYM S* + * : FONT_FACE_SYM S* * '{' S* declaration [ ';' S* declaration ]* '}' S* * ; - */ + */ var tokenStream = this._tokenStream, line, col; - + //look for @page tokenStream.mustMatch(Tokens.FONT_FACE_SYM); line = tokenStream.token().startLine; col = tokenStream.token().startCol; - + this._readWhitespace(); this.fire({ type: "startfontface", line: line, col: col - }); - + }); + this._readDeclarations(true); - + this.fire({ type: "endfontface", line: line, col: col - }); + }); + }, + + _viewport: function(){ + /* + * viewport + * : VIEWPORT_SYM S* + * '{' S* declaration? [ ';' S* declaration? ]* '}' S* + * ; + */ + var tokenStream = this._tokenStream, + line, + col; + + tokenStream.mustMatch(Tokens.VIEWPORT_SYM); + line = tokenStream.token().startLine; + col = tokenStream.token().startCol; + + this._readWhitespace(); + + this.fire({ + type: "startviewport", + line: line, + col: col + }); + + this._readDeclarations(true); + + this.fire({ + type: "endviewport", + line: line, + col: col + }); + }, _operator: function(inFunction){ - + /* * operator (outside function) * : '/' S* | ',' S* | /( empty )/ * operator (inside function) * : '/' S* | '+' S* | '*' S* | '-' S* /( empty )/ * ; - */ - + */ + var tokenStream = this._tokenStream, token = null; - + if (tokenStream.match([Tokens.SLASH, Tokens.COMMA]) || (inFunction && tokenStream.match([Tokens.PLUS, Tokens.STAR, Tokens.MINUS]))){ token = tokenStream.token(); this._readWhitespace(); - } + } return token ? PropertyValuePart.fromToken(token) : null; - + }, - + _combinator: function(){ - + /* * combinator * : PLUS S* | GREATER S* | TILDE S* | S+ * ; - */ - + */ + var tokenStream = this._tokenStream, value = null, token; - - if(tokenStream.match([Tokens.PLUS, Tokens.GREATER, Tokens.TILDE])){ + + if(tokenStream.match([Tokens.PLUS, Tokens.GREATER, Tokens.TILDE])){ token = tokenStream.token(); value = new Combinator(token.value, token.startLine, token.startCol); this._readWhitespace(); } - + return value; }, - + _unary_operator: function(){ - + /* * unary_operator * : '-' | '+' * ; */ - + var tokenStream = this._tokenStream; - + if (tokenStream.match([Tokens.MINUS, Tokens.PLUS])){ return tokenStream.token().value; } else { return null; - } + } }, - + _property: function(){ - + /* * property * : IDENT S* - * ; + * ; */ - + var tokenStream = this._tokenStream, value = null, hack = null, @@ -2037,7 +2077,7 @@ Parser.prototype = function(){ token, line, col; - + //check for star hack - throws error if not allowed if (tokenStream.peek() == Tokens.STAR && this.options.starHack){ tokenStream.get(); @@ -2046,33 +2086,33 @@ Parser.prototype = function(){ line = token.startLine; col = token.startCol; } - + if(tokenStream.match(Tokens.IDENT)){ token = tokenStream.token(); tokenValue = token.value; - + //check for underscore hack - no error if not allowed because it's valid CSS syntax if (tokenValue.charAt(0) == "_" && this.options.underscoreHack){ hack = "_"; tokenValue = tokenValue.substring(1); } - + value = new PropertyName(tokenValue, hack, (line||token.startLine), (col||token.startCol)); this._readWhitespace(); } - + return value; }, - + //Augmented with CSS3 Selectors _ruleset: function(){ /* * ruleset * : selectors_group * '{' S* declaration? [ ';' S* declaration? ]* '}' S* - * ; - */ - + * ; + */ + var tokenStream = this._tokenStream, tt, selectors; @@ -2086,7 +2126,7 @@ Parser.prototype = function(){ selectors = this._selectors_group(); } catch (ex){ if (ex instanceof SyntaxError && !this.options.strict){ - + //fire error event this.fire({ type: "error", @@ -2094,8 +2134,8 @@ Parser.prototype = function(){ message: ex.message, line: ex.line, col: ex.col - }); - + }); + //skip over everything until closing brace tt = tokenStream.advance([Tokens.RBRACE]); if (tt == Tokens.RBRACE){ @@ -2103,57 +2143,57 @@ Parser.prototype = function(){ } else { //otherwise, rethrow the error because it wasn't handled properly throw ex; - } - + } + } else { //not a syntax error, rethrow it throw ex; - } - + } + //trigger parser to continue return true; } - + //if it got here, all selectors parsed - if (selectors){ - + if (selectors){ + this.fire({ type: "startrule", selectors: selectors, line: selectors[0].line, col: selectors[0].col - }); - - this._readDeclarations(true); - + }); + + this._readDeclarations(true); + this.fire({ type: "endrule", selectors: selectors, line: selectors[0].line, col: selectors[0].col - }); - + }); + } - + return selectors; - + }, //CSS3 Selectors _selectors_group: function(){ - - /* + + /* * selectors_group * : selector [ COMMA S* selector ]* * ; - */ + */ var tokenStream = this._tokenStream, selectors = [], selector; - + selector = this._selector(); if (selector !== null){ - + selectors.push(selector); while(tokenStream.match(Tokens.COMMA)){ this._readWhitespace(); @@ -2168,83 +2208,83 @@ Parser.prototype = function(){ return selectors.length ? selectors : null; }, - + //CSS3 Selectors _selector: function(){ /* * selector * : simple_selector_sequence [ combinator simple_selector_sequence ]* - * ; + * ; */ - + var tokenStream = this._tokenStream, selector = [], nextSelector = null, combinator = null, ws = null; - + //if there's no simple selector, then there's no selector nextSelector = this._simple_selector_sequence(); if (nextSelector === null){ return null; } - + selector.push(nextSelector); - + do { - + //look for a combinator combinator = this._combinator(); - + if (combinator !== null){ selector.push(combinator); nextSelector = this._simple_selector_sequence(); - + //there must be a next selector if (nextSelector === null){ this._unexpectedToken(tokenStream.LT(1)); } else { - + //nextSelector is an instance of SelectorPart selector.push(nextSelector); } } else { - + //if there's not whitespace, we're done - if (this._readWhitespace()){ - + if (this._readWhitespace()){ + //add whitespace separator ws = new Combinator(tokenStream.token().value, tokenStream.token().startLine, tokenStream.token().startCol); - + //combinator is not required combinator = this._combinator(); - + //selector is required if there's a combinator nextSelector = this._simple_selector_sequence(); - if (nextSelector === null){ + if (nextSelector === null){ if (combinator !== null){ this._unexpectedToken(tokenStream.LT(1)); } } else { - + if (combinator !== null){ selector.push(combinator); } else { selector.push(ws); } - + selector.push(nextSelector); - } + } } else { break; - } - + } + } } while(true); - + return new Selector(selector, selector[0].line, selector[0].col); }, - + //CSS3 Selectors _simple_selector_sequence: function(){ /* @@ -2254,13 +2294,13 @@ Parser.prototype = function(){ * | [ HASH | class | attrib | pseudo | negation ]+ * ; */ - + var tokenStream = this._tokenStream, - + //parts of a simple selector elementName = null, modifiers = [], - + //complete selector text selectorText= "", @@ -2283,35 +2323,35 @@ Parser.prototype = function(){ found = false, line, col; - - + + //get starting line and column for the selector line = tokenStream.LT(1).startLine; col = tokenStream.LT(1).startCol; - + elementName = this._type_selector(); if (!elementName){ elementName = this._universal(); } - + if (elementName !== null){ selectorText += elementName; - } - + } + while(true){ //whitespace means we're done if (tokenStream.peek() === Tokens.S){ break; } - + //check for each component while(i < len && component === null){ component = components[i++].call(this); } - + if (component === null){ - + //we don't have a selector if (selectorText === ""){ return null; @@ -2321,17 +2361,17 @@ Parser.prototype = function(){ } else { i = 0; modifiers.push(component); - selectorText += component.toString(); + selectorText += component.toString(); component = null; } } - + return selectorText !== "" ? new SelectorPart(elementName, modifiers, selectorText, line, col) : null; - }, - + }, + //CSS3 Selectors _type_selector: function(){ /* @@ -2339,12 +2379,12 @@ Parser.prototype = function(){ * : [ namespace_prefix ]? element_name * ; */ - + var tokenStream = this._tokenStream, ns = this._namespace_prefix(), elementName = this._element_name(); - - if (!elementName){ + + if (!elementName){ /* * Need to back out the namespace that was read due to both * type_selector and universal reading namespace_prefix @@ -2357,9 +2397,9 @@ Parser.prototype = function(){ tokenStream.unget(); } } - + return null; - } else { + } else { if (ns){ elementName.text = ns + elementName.text; elementName.col -= ns.length; @@ -2367,97 +2407,97 @@ Parser.prototype = function(){ return elementName; } }, - + //CSS3 Selectors _class: function(){ /* * class * : '.' IDENT * ; - */ - + */ + var tokenStream = this._tokenStream, token; - + if (tokenStream.match(Tokens.DOT)){ - tokenStream.mustMatch(Tokens.IDENT); + tokenStream.mustMatch(Tokens.IDENT); token = tokenStream.token(); - return new SelectorSubPart("." + token.value, "class", token.startLine, token.startCol - 1); + return new SelectorSubPart("." + token.value, "class", token.startLine, token.startCol - 1); } else { return null; } - + }, - + //CSS3 Selectors _element_name: function(){ /* * element_name * : IDENT * ; - */ - + */ + var tokenStream = this._tokenStream, token; - + if (tokenStream.match(Tokens.IDENT)){ token = tokenStream.token(); - return new SelectorSubPart(token.value, "elementName", token.startLine, token.startCol); - + return new SelectorSubPart(token.value, "elementName", token.startLine, token.startCol); + } else { return null; } }, - + //CSS3 Selectors _namespace_prefix: function(){ - /* + /* * namespace_prefix * : [ IDENT | '*' ]? '|' * ; */ var tokenStream = this._tokenStream, value = ""; - + //verify that this is a namespace prefix if (tokenStream.LA(1) === Tokens.PIPE || tokenStream.LA(2) === Tokens.PIPE){ - + if(tokenStream.match([Tokens.IDENT, Tokens.STAR])){ value += tokenStream.token().value; } - + tokenStream.mustMatch(Tokens.PIPE); value += "|"; - + } - - return value.length ? value : null; + + return value.length ? value : null; }, - + //CSS3 Selectors _universal: function(){ /* * universal * : [ namespace_prefix ]? '*' - * ; + * ; */ var tokenStream = this._tokenStream, value = "", ns; - + ns = this._namespace_prefix(); if(ns){ value += ns; } - + if(tokenStream.match(Tokens.STAR)){ value += "*"; } - + return value.length ? value : null; - + }, - + //CSS3 Selectors _attrib: function(){ /* @@ -2470,69 +2510,69 @@ Parser.prototype = function(){ * INCLUDES | * DASHMATCH ] S* [ IDENT | STRING ] S* * ]? ']' - * ; + * ; */ - + var tokenStream = this._tokenStream, value = null, ns, token; - + if (tokenStream.match(Tokens.LBRACKET)){ token = tokenStream.token(); value = token.value; value += this._readWhitespace(); - + ns = this._namespace_prefix(); - + if (ns){ value += ns; } - + tokenStream.mustMatch(Tokens.IDENT); - value += tokenStream.token().value; + value += tokenStream.token().value; value += this._readWhitespace(); - + if(tokenStream.match([Tokens.PREFIXMATCH, Tokens.SUFFIXMATCH, Tokens.SUBSTRINGMATCH, Tokens.EQUALS, Tokens.INCLUDES, Tokens.DASHMATCH])){ - - value += tokenStream.token().value; + + value += tokenStream.token().value; value += this._readWhitespace(); - + tokenStream.mustMatch([Tokens.IDENT, Tokens.STRING]); - value += tokenStream.token().value; + value += tokenStream.token().value; value += this._readWhitespace(); } - + tokenStream.mustMatch(Tokens.RBRACKET); - + return new SelectorSubPart(value + "]", "attribute", token.startLine, token.startCol); } else { return null; } }, - + //CSS3 Selectors _pseudo: function(){ - + /* * pseudo * : ':' ':'? [ IDENT | functional_pseudo ] - * ; - */ - + * ; + */ + var tokenStream = this._tokenStream, pseudo = null, colons = ":", line, col; - + if (tokenStream.match(Tokens.COLON)){ - + if (tokenStream.match(Tokens.COLON)){ colons += ":"; } - + if (tokenStream.match(Tokens.IDENT)){ pseudo = tokenStream.token().value; line = tokenStream.token().startLine; @@ -2542,26 +2582,26 @@ Parser.prototype = function(){ col = tokenStream.LT(1).startCol - colons.length; pseudo = this._functional_pseudo(); } - + if (pseudo){ pseudo = new SelectorSubPart(colons + pseudo, "pseudo", line, col); } } - + return pseudo; }, - + //CSS3 Selectors _functional_pseudo: function(){ /* * functional_pseudo * : FUNCTION S* expression ')' * ; - */ - + */ + var tokenStream = this._tokenStream, value = null; - + if(tokenStream.match(Tokens.FUNCTION)){ value = tokenStream.token().value; value += this._readWhitespace(); @@ -2569,10 +2609,10 @@ Parser.prototype = function(){ tokenStream.mustMatch(Tokens.RPAREN); value += ")"; } - + return value; }, - + //CSS3 Selectors _expression: function(){ /* @@ -2580,26 +2620,26 @@ Parser.prototype = function(){ * : [ [ PLUS | '-' | DIMENSION | NUMBER | STRING | IDENT ] S* ]+ * ; */ - + var tokenStream = this._tokenStream, value = ""; - + while(tokenStream.match([Tokens.PLUS, Tokens.MINUS, Tokens.DIMENSION, Tokens.NUMBER, Tokens.STRING, Tokens.IDENT, Tokens.LENGTH, Tokens.FREQ, Tokens.ANGLE, Tokens.TIME, Tokens.RESOLUTION, Tokens.SLASH])){ - + value += tokenStream.token().value; - value += this._readWhitespace(); + value += this._readWhitespace(); } - + return value.length ? value : null; - + }, //CSS3 Selectors _negation: function(){ - /* + /* * negation * : NOT S* negation_arg S* ')' * ; @@ -2611,7 +2651,7 @@ Parser.prototype = function(){ value = "", arg, subpart = null; - + if (tokenStream.match(Tokens.NOT)){ value = tokenStream.token().value; line = tokenStream.token().startLine; @@ -2622,22 +2662,22 @@ Parser.prototype = function(){ value += this._readWhitespace(); tokenStream.match(Tokens.RPAREN); value += tokenStream.token().value; - + subpart = new SelectorSubPart(value, "not", line, col); subpart.args.push(arg); } - + return subpart; }, - + //CSS3 Selectors - _negation_arg: function(){ + _negation_arg: function(){ /* * negation_arg * : type_selector | universal | HASH | class | attrib | pseudo - * ; - */ - + * ; + */ + var tokenStream = this._tokenStream, args = [ this._type_selector, @@ -2645,11 +2685,11 @@ Parser.prototype = function(){ function(){ return tokenStream.match(Tokens.HASH) ? new SelectorSubPart(tokenStream.token().value, "id", tokenStream.token().startLine, tokenStream.token().startCol) : - null; + null; }, this._class, this._attrib, - this._pseudo + this._pseudo ], arg = null, i = 0, @@ -2658,40 +2698,40 @@ Parser.prototype = function(){ line, col, part; - + line = tokenStream.LT(1).startLine; col = tokenStream.LT(1).startCol; - + while(i < len && arg === null){ - + arg = args[i].call(this); i++; } - + //must be a negation arg if (arg === null){ this._unexpectedToken(tokenStream.LT(1)); } - + //it's an element name if (arg.type == "elementName"){ part = new SelectorPart(arg, [], arg.toString(), line, col); } else { part = new SelectorPart(null, [arg], arg.toString(), line, col); } - - return part; + + return part; }, - + _declaration: function(){ - + /* * declaration * : property ':' S* expr prio? * | /( empty )/ - * ; - */ - + * ; + */ + var tokenStream = this._tokenStream, property = null, expr = null, @@ -2699,22 +2739,22 @@ Parser.prototype = function(){ error = null, invalid = null, propertyName= ""; - + property = this._property(); if (property !== null){ tokenStream.mustMatch(Tokens.COLON); this._readWhitespace(); - + expr = this._expr(); - + //if there's no parts for the value, it's an error if (!expr || expr.length === 0){ this._unexpectedToken(tokenStream.LT(1)); } - + prio = this._prio(); - + /* * If hacks should be allowed, then only check the root * property. If hacks should not be allowed, treat @@ -2723,16 +2763,16 @@ Parser.prototype = function(){ propertyName = property.toString(); if (this.options.starHack && property.hack == "*" || this.options.underscoreHack && property.hack == "_") { - + propertyName = property.text; } - + try { this._validateProperty(propertyName, expr); } catch (ex) { invalid = ex; } - + this.fire({ type: "property", property: property, @@ -2741,46 +2781,46 @@ Parser.prototype = function(){ line: property.line, col: property.col, invalid: invalid - }); - + }); + return true; } else { return false; } }, - + _prio: function(){ /* * prio * : IMPORTANT_SYM S* - * ; + * ; */ - + var tokenStream = this._tokenStream, result = tokenStream.match(Tokens.IMPORTANT_SYM); - + this._readWhitespace(); return result; }, - + _expr: function(inFunction){ /* * expr * : term [ operator term ]* * ; */ - + var tokenStream = this._tokenStream, values = [], //valueParts = [], value = null, operator = null; - - value = this._term(); + + value = this._term(inFunction); if (value !== null){ - + values.push(value); - + do { operator = this._operator(inFunction); @@ -2792,9 +2832,9 @@ Parser.prototype = function(){ values.push(new PropertyValue(valueParts, valueParts[0].line, valueParts[0].col)); valueParts = []; }*/ - - value = this._term(); - + + value = this._term(inFunction); + if (value === null){ break; } else { @@ -2802,17 +2842,17 @@ Parser.prototype = function(){ } } while(true); } - + //cleanup /*if (valueParts.length){ values.push(new PropertyValue(valueParts, valueParts[0].line, valueParts[0].col)); }*/ - + return values.length > 0 ? new PropertyValue(values, values[0].line, values[0].col) : null; }, - - _term: function(){ - + + _term: function(inFunction){ + /* * term * : unary_operator? @@ -2820,36 +2860,51 @@ Parser.prototype = function(){ * TIME S* | FREQ S* | function | ie_function ] * | STRING S* | IDENT S* | URI S* | UNICODERANGE S* | hexcolor * ; - */ - + */ + var tokenStream = this._tokenStream, unary = null, value = null, + endChar = null, token, line, col; - + //returns the operator or null unary = this._unary_operator(); if (unary !== null){ line = tokenStream.token().startLine; col = tokenStream.token().startCol; - } - + } + //exception for IE filters if (tokenStream.peek() == Tokens.IE_FUNCTION && this.options.ieFilters){ - + value = this._ie_function(); if (unary === null){ line = tokenStream.token().startLine; col = tokenStream.token().startCol; } - + + //see if it's a simple block + } else if (inFunction && tokenStream.match([Tokens.LPAREN, Tokens.LBRACE, Tokens.LBRACKET])){ + + token = tokenStream.token(); + endChar = token.endChar; + value = token.value + this._expr(inFunction).text; + if (unary === null){ + line = tokenStream.token().startLine; + col = tokenStream.token().startCol; + } + tokenStream.mustMatch(Tokens.type(endChar)); + value += endChar; + this._readWhitespace(); + //see if there's a simple match } else if (tokenStream.match([Tokens.NUMBER, Tokens.PERCENTAGE, Tokens.LENGTH, Tokens.ANGLE, Tokens.TIME, Tokens.FREQ, Tokens.STRING, Tokens.IDENT, Tokens.URI, Tokens.UNICODE_RANGE])){ - + value = tokenStream.token().value; if (unary === null){ line = tokenStream.token().startLine; @@ -2857,20 +2912,20 @@ Parser.prototype = function(){ } this._readWhitespace(); } else { - + //see if it's a color token = this._hexcolor(); if (token === null){ - + //if there's no unary, get the start of the next token for line/col info if (unary === null){ line = tokenStream.LT(1).startLine; col = tokenStream.LT(1).startCol; - } - + } + //has to be a function if (value === null){ - + /* * This checks for alpha(opacity=0) style of IE * functions. IE_FUNCTION only presents progid: style. @@ -2886,61 +2941,61 @@ Parser.prototype = function(){ return null; //throw new Error("Expected identifier at line " + tokenStream.token().startLine + ", character " + tokenStream.token().startCol + "."); }*/ - + } else { value = token.value; if (unary === null){ line = token.startLine; col = token.startCol; - } + } } - - } - + + } + return value !== null ? new PropertyValuePart(unary !== null ? unary + value : value, line, col) : null; - + }, - + _function: function(){ - + /* * function * : FUNCTION S* expr ')' S* * ; */ - + var tokenStream = this._tokenStream, functionText = null, expr = null, lt; - + if (tokenStream.match(Tokens.FUNCTION)){ functionText = tokenStream.token().value; this._readWhitespace(); expr = this._expr(true); functionText += expr; - + //START: Horrible hack in case it's an IE filter if (this.options.ieFilters && tokenStream.peek() == Tokens.EQUALS){ do { - + if (this._readWhitespace()){ functionText += tokenStream.token().value; } - + //might be second time in the loop if (tokenStream.LA(0) == Tokens.COMMA){ functionText += tokenStream.token().value; } - + tokenStream.match(Tokens.IDENT); functionText += tokenStream.token().value; - + tokenStream.match(Tokens.EQUALS); functionText += tokenStream.token().value; - + //functionText += this._term(); lt = tokenStream.peek(); while(lt != Tokens.COMMA && lt != Tokens.S && lt != Tokens.RPAREN){ @@ -2952,49 +3007,49 @@ Parser.prototype = function(){ } //END: Horrible Hack - - tokenStream.match(Tokens.RPAREN); + + tokenStream.match(Tokens.RPAREN); functionText += ")"; this._readWhitespace(); - } - + } + return functionText; - }, - + }, + _ie_function: function(){ - + /* (My own extension) * ie_function * : IE_FUNCTION S* IDENT '=' term [S* ','? IDENT '=' term]+ ')' S* * ; */ - + var tokenStream = this._tokenStream, functionText = null, expr = null, lt; - + //IE function can begin like a regular function, too if (tokenStream.match([Tokens.IE_FUNCTION, Tokens.FUNCTION])){ functionText = tokenStream.token().value; - + do { - + if (this._readWhitespace()){ functionText += tokenStream.token().value; } - + //might be second time in the loop if (tokenStream.LA(0) == Tokens.COMMA){ functionText += tokenStream.token().value; } - + tokenStream.match(Tokens.IDENT); functionText += tokenStream.token().value; - + tokenStream.match(Tokens.EQUALS); functionText += tokenStream.token().value; - + //functionText += this._term(); lt = tokenStream.peek(); while(lt != Tokens.COMMA && lt != Tokens.S && lt != Tokens.RPAREN){ @@ -3002,16 +3057,16 @@ Parser.prototype = function(){ functionText += tokenStream.token().value; lt = tokenStream.peek(); } - } while(tokenStream.match([Tokens.COMMA, Tokens.S])); - - tokenStream.match(Tokens.RPAREN); + } while(tokenStream.match([Tokens.COMMA, Tokens.S])); + + tokenStream.match(Tokens.RPAREN); functionText += ")"; this._readWhitespace(); - } - + } + return functionText; - }, - + }, + _hexcolor: function(){ /* * There is a constraint on the color that it must @@ -3022,15 +3077,15 @@ Parser.prototype = function(){ * : HASH S* * ; */ - + var tokenStream = this._tokenStream, token = null, color; - + if(tokenStream.match(Tokens.HASH)){ - + //need to do some validation here - + token = tokenStream.token(); color = token.value; if (!/#[a-f0-9]{3,6}/i.test(color)){ @@ -3038,16 +3093,16 @@ Parser.prototype = function(){ } this._readWhitespace(); } - + return token; }, - + //----------------------------------------------------------------- // Animations methods //----------------------------------------------------------------- - + _keyframes: function(){ - + /* * keyframes: * : KEYFRAMES_SYM S* keyframe_name S* '{' S* keyframe_rule* '}' { @@ -3057,53 +3112,53 @@ Parser.prototype = function(){ token, tt, name, - prefix = ""; - + prefix = ""; + tokenStream.mustMatch(Tokens.KEYFRAMES_SYM); token = tokenStream.token(); if (/^@\-([^\-]+)\-/.test(token.value)) { prefix = RegExp.$1; } - + this._readWhitespace(); name = this._keyframe_name(); - + this._readWhitespace(); tokenStream.mustMatch(Tokens.LBRACE); - + this.fire({ type: "startkeyframes", name: name, prefix: prefix, line: token.startLine, col: token.startCol - }); - + }); + this._readWhitespace(); tt = tokenStream.peek(); - + //check for key while(tt == Tokens.IDENT || tt == Tokens.PERCENTAGE) { this._keyframe_rule(); this._readWhitespace(); tt = tokenStream.peek(); - } - + } + this.fire({ type: "endkeyframes", name: name, prefix: prefix, line: token.startLine, col: token.startCol - }); - + }); + this._readWhitespace(); - tokenStream.mustMatch(Tokens.RBRACE); - + tokenStream.mustMatch(Tokens.RBRACE); + }, - + _keyframe_name: function(){ - + /* * keyframe_name: * : IDENT @@ -3114,41 +3169,41 @@ Parser.prototype = function(){ token; tokenStream.mustMatch([Tokens.IDENT, Tokens.STRING]); - return SyntaxUnit.fromToken(tokenStream.token()); + return SyntaxUnit.fromToken(tokenStream.token()); }, - + _keyframe_rule: function(){ - + /* * keyframe_rule: - * : key_list S* + * : key_list S* * '{' S* declaration [ ';' S* declaration ]* '}' S* * ; */ var tokenStream = this._tokenStream, token, keyList = this._key_list(); - + this.fire({ type: "startkeyframerule", keys: keyList, line: keyList[0].line, col: keyList[0].col - }); - - this._readDeclarations(true); - + }); + + this._readDeclarations(true); + this.fire({ type: "endkeyframerule", keys: keyList, line: keyList[0].line, col: keyList[0].col - }); - + }); + }, - + _key_list: function(){ - + /* * key_list: * : key [ S* ',' S* key]* @@ -3158,12 +3213,12 @@ Parser.prototype = function(){ token, key, keyList = []; - + //must be least one key keyList.push(this._key()); - + this._readWhitespace(); - + while(tokenStream.match(Tokens.COMMA)){ this._readWhitespace(); keyList.push(this._key()); @@ -3172,7 +3227,7 @@ Parser.prototype = function(){ return keyList; }, - + _key: function(){ /* * There is a restriction that IDENT can be only "from" or "to". @@ -3182,30 +3237,30 @@ Parser.prototype = function(){ * | IDENT * ; */ - + var tokenStream = this._tokenStream, token; - + if (tokenStream.match(Tokens.PERCENTAGE)){ return SyntaxUnit.fromToken(tokenStream.token()); } else if (tokenStream.match(Tokens.IDENT)){ - token = tokenStream.token(); - + token = tokenStream.token(); + if (/from|to/i.test(token.value)){ return SyntaxUnit.fromToken(token); } - + tokenStream.unget(); } - + //if it gets here, there wasn't a valid token, so time to explode this._unexpectedToken(tokenStream.LT(1)); }, - + //----------------------------------------------------------------- // Helper methods //----------------------------------------------------------------- - + /** * Not part of CSS grammar, but useful for skipping over * combination of white space and HTML-style comments. @@ -3238,25 +3293,25 @@ Parser.prototype = function(){ * or * S* '{' S* [ declaration | margin ]? [ ';' S* [ declaration | margin ]? ]* '}' S* * Note that this is how it is described in CSS3 Paged Media, but is actually incorrect. - * A semicolon is only necessary following a delcaration is there's another declaration - * or margin afterwards. + * A semicolon is only necessary following a declaration is there's another declaration + * or margin afterwards. */ var tokenStream = this._tokenStream, tt; - + this._readWhitespace(); - + if (checkStart){ - tokenStream.mustMatch(Tokens.LBRACE); + tokenStream.mustMatch(Tokens.LBRACE); } - + this._readWhitespace(); try { - + while(true){ - + if (tokenStream.match(Tokens.SEMICOLON) || (readMargins && this._margin())){ //noop } else if (this._declaration()){ @@ -3266,19 +3321,19 @@ Parser.prototype = function(){ } else { break; } - + //if ((!this._margin() && !this._declaration()) || !tokenStream.match(Tokens.SEMICOLON)){ // break; //} this._readWhitespace(); } - + tokenStream.mustMatch(Tokens.RBRACE); this._readWhitespace(); - + } catch (ex) { if (ex instanceof SyntaxError && !this.options.strict){ - + //fire error event this.fire({ type: "error", @@ -3286,27 +3341,27 @@ Parser.prototype = function(){ message: ex.message, line: ex.line, col: ex.col - }); - + }); + //see if there's another declaration tt = tokenStream.advance([Tokens.SEMICOLON, Tokens.RBRACE]); if (tt == Tokens.SEMICOLON){ //if there's a semicolon, then there might be another declaration - this._readDeclarations(false, readMargins); + this._readDeclarations(false, readMargins); } else if (tt != Tokens.RBRACE){ //if there's a right brace, the rule is finished so don't do anything //otherwise, rethrow the error because it wasn't handled properly throw ex; - } - + } + } else { //not a syntax error, rethrow it throw ex; } - } - - }, - + } + + }, + /** * In some cases, you can end up with two white space tokens in a * row. Instead of making a change in every function that looks for @@ -3317,17 +3372,17 @@ Parser.prototype = function(){ * @private */ _readWhitespace: function(){ - + var tokenStream = this._tokenStream, ws = ""; - + while(tokenStream.match(Tokens.S)){ ws += tokenStream.token().value; } - + return ws; }, - + /** * Throws an error when an unexpected token is found. @@ -3339,7 +3394,7 @@ Parser.prototype = function(){ _unexpectedToken: function(token){ throw new SyntaxError("Unexpected token '" + token.value + "' at line " + token.startLine + ", col " + token.startCol + ".", token.startLine, token.startCol); }, - + /** * Helper method used for parsing subparts of a style sheet. * @return {void} @@ -3349,64 +3404,64 @@ Parser.prototype = function(){ _verifyEnd: function(){ if (this._tokenStream.LA(1) != Tokens.EOF){ this._unexpectedToken(this._tokenStream.LT(1)); - } + } }, - + //----------------------------------------------------------------- // Validation methods //----------------------------------------------------------------- _validateProperty: function(property, value){ Validation.validate(property, value); }, - + //----------------------------------------------------------------- // Parsing methods //----------------------------------------------------------------- - - parse: function(input){ + + parse: function(input){ this._tokenStream = new TokenStream(input, Tokens); this._stylesheet(); }, - + parseStyleSheet: function(input){ //just passthrough return this.parse(input); }, - + parseMediaQuery: function(input){ this._tokenStream = new TokenStream(input, Tokens); var result = this._media_query(); - + //if there's anything more, then it's an invalid selector this._verifyEnd(); - + //otherwise return result - return result; + return result; }, - + /** * Parses a property value (everything after the semicolon). * @return {parserlib.css.PropertyValue} The property value. * @throws parserlib.util.SyntaxError If an unexpected token is found. * @method parserPropertyValue - */ + */ parsePropertyValue: function(input){ - + this._tokenStream = new TokenStream(input, Tokens); this._readWhitespace(); - + var result = this._expr(); - + //okay to have a trailing white space this._readWhitespace(); - + //if there's anything more, then it's an invalid selector this._verifyEnd(); - + //otherwise return result return result; }, - + /** * Parses a complete CSS rule, including selectors and * properties. @@ -3416,22 +3471,22 @@ Parser.prototype = function(){ */ parseRule: function(input){ this._tokenStream = new TokenStream(input, Tokens); - + //skip any leading white space this._readWhitespace(); - + var result = this._ruleset(); - + //skip any trailing white space this._readWhitespace(); //if there's anything more, then it's an invalid selector this._verifyEnd(); - + //otherwise return result - return result; + return result; }, - + /** * Parses a single CSS selector (no comma) * @param {String} input The text to parse as a CSS selector. @@ -3440,29 +3495,29 @@ Parser.prototype = function(){ * @method parseSelector */ parseSelector: function(input){ - + this._tokenStream = new TokenStream(input, Tokens); - + //skip any leading white space this._readWhitespace(); - + var result = this._selector(); - + //skip any trailing white space this._readWhitespace(); //if there's anything more, then it's an invalid selector this._verifyEnd(); - + //otherwise return result return result; }, /** - * Parses an HTML style attribute: a set of CSS declarations + * Parses an HTML style attribute: a set of CSS declarations * separated by semicolons. * @param {String} input The text to parse as a style attribute - * @return {void} + * @return {void} * @method parseStyleAttribute */ parseStyleAttribute: function(input){ @@ -3471,14 +3526,14 @@ Parser.prototype = function(){ this._readDeclarations(); } }; - + //copy over onto prototype for (prop in additions){ if (additions.hasOwnProperty(prop)){ proto[prop] = additions[prop]; } - } - + } + return proto; }(); @@ -3493,17 +3548,24 @@ nth var Properties = { //A + "align-items" : "flex-start | flex-end | center | baseline | stretch", + "align-content" : "flex-start | flex-end | center | space-between | space-around | stretch", + "align-self" : "auto | flex-start | flex-end | center | baseline | stretch", + "-webkit-align-items" : "flex-start | flex-end | center | baseline | stretch", + "-webkit-align-content" : "flex-start | flex-end | center | space-between | space-around | stretch", + "-webkit-align-self" : "auto | flex-start | flex-end | center | baseline | stretch", "alignment-adjust" : "auto | baseline | before-edge | text-before-edge | middle | central | after-edge | text-after-edge | ideographic | alphabetic | hanging | mathematical | | ", "alignment-baseline" : "baseline | use-script | before-edge | text-before-edge | after-edge | text-after-edge | central | middle | ideographic | alphabetic | hanging | mathematical", "animation" : 1, "animation-delay" : { multi: "