Merge remote-tracking branch 'remotes/origin/master' into v-1.2

Conflicts:
	build
	lib/ace/document.js
	lib/ace/editor.js
This commit is contained in:
nightwing 2014-10-05 23:04:57 +04:00
commit 29023787e5
125 changed files with 89027 additions and 86666 deletions

4
.gitmodules vendored
View file

@ -1,6 +1,6 @@
[submodule "doc/wiki"] [submodule "doc/wiki"]
path = doc/wiki path = doc/wiki
url = git://github.com/ajaxorg/ace.wiki.git url = https://github.com/ajaxorg/ace.wiki.git
[submodule "build"] [submodule "build"]
path = build path = build
url = git://github.com/ajaxorg/ace-builds.git url = https://github.com/ajaxorg/ace-builds.git

View file

@ -1,3 +1,31 @@
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 2014.07.01 Version 1.1.4
* New Features * New Features

View file

@ -359,7 +359,7 @@ function buildAce(options) {
buildSubmodule(options, { buildSubmodule(options, {
projectType: "theme", projectType: "theme",
require: ["ace/theme/" + name] require: ["ace/theme/" + name]
}, "theme-" + name.replace("_theme", "")); }, "theme-" + name);
}); });
// keybindings // keybindings
["vim", "emacs"].forEach(function(name) { ["vim", "emacs"].forEach(function(name) {
@ -536,7 +536,7 @@ function generateThemesModule(themes) {
function addSnippetFile(modeName) { function addSnippetFile(modeName) {
var snippetFilePath = ACE_HOME + "/lib/ace/snippets/" + modeName; var snippetFilePath = ACE_HOME + "/lib/ace/snippets/" + modeName;
if (!fs.existsSync(snippetFilePath + ".js")) { if (!fs.existsSync(snippetFilePath + ".js")) {
copy.file(ACE_HOME + "/tool/snippets.tmpl.js", snippetFilePath + ".js", function(t) { copy.file(ACE_HOME + "/tool/templates/snippets.js", snippetFilePath + ".js", function(t) {
return t.replace(/%modeName%/g, modeName); return t.replace(/%modeName%/g, modeName);
}); });
} }

View file

@ -30,7 +30,7 @@ Take Ace for a spin!
Check out the Ace live [demo](http://ace.c9.io/build/kitchen-sink.html) or get a [Cloud9 IDE account](https://c9.io/) to experience Ace while editing one of your own GitHub projects. Check out the Ace live [demo](http://ace.c9.io/build/kitchen-sink.html) or get a [Cloud9 IDE account](https://c9.io/) to experience Ace while editing one of your own GitHub projects.
If you want, you can use Ace as a textarea replacement thanks to the [Ace Bookmarklet](http://ajaxorg.github.io/ace/build/textarea/editor.html). If you want, you can use Ace as a textarea replacement thanks to the [Ace Bookmarklet](http://ajaxorg.github.io/ace/build/demo/bookmarklet/index.html).
Embedding Ace Embedding Ace
------------- -------------

View file

@ -163,7 +163,7 @@
<article id="Selection" data-title="Selection (class)" class="article"> <article id="Selection" data-title="Selection (class)" class="article">
<div class="section description"> <div class="section description">
<div class="memberContent"><p>Contains the cursor position and the text selection of an edit session.</p> <div class="memberContent"><p>Contains the cursor position and the text selection of an edit session.</p>
<p>The row/columns used in the selection are in document coordinates representing ths coordinates as thez appear in the document before applying soft wrap and folding.</p> <p>The row/columns used in the selection are in document coordinates representing the coordinates as they appear in the document before applying soft wrap and folding.</p>
</div> </div>
</div> </div>

View file

@ -224,7 +224,3 @@ UL.menu-footer LI A {
UL.menu-footer LI A:hover { UL.menu-footer LI A:hover {
text-decoration:underline; text-decoration:underline;
} }

View file

@ -415,28 +415,11 @@ bindDropdown("folding", function(value) {
}); });
bindDropdown("soft_wrap", function(value) { bindDropdown("soft_wrap", function(value) {
var session = env.editor.session; env.editor.setOption("wrap", value);
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);
}
}); });
bindCheckbox("select_style", function(checked) { bindCheckbox("select_style", function(checked) {
env.editor.setSelectionStyle(checked ? "line" : "text"); env.editor.setOption("selectionStyle", checked ? "line" : "text");
}); });
bindCheckbox("highlight_active", function(checked) { bindCheckbox("highlight_active", function(checked) {
@ -592,7 +575,7 @@ env.editSnippets = function() {
require("ace/ext/language_tools"); require("ace/ext/language_tools");
env.editor.setOptions({ env.editor.setOptions({
enableBasicAutocompletion: true, enableBasicAutocompletion: true,
enableLiveAutocompletion: true, enableLiveAutocompletion: false,
enableSnippets: true enableSnippets: true
}); });

11
demo/kitchen-sink/docs/.gitignore vendored Normal file
View file

@ -0,0 +1,11 @@
# A sample .gitignore file.
.buildlog
.DS_Store
.svn
# Negated patterns:
!foo.bar
# Also ignore user settings...
/.settings

View file

@ -1,28 +1,18 @@
.text-layer { .text-layer {
font-family: Monaco, "Courier New", monospace; font: 12px Monaco, "Courier New", monospace;
font-size: 12pX;
cursor: text; cursor: text;
} }
.blinker { .blinker {
animation-duration: 1s; animation: blink 1s linear infinite alternate;
animation-name: blink;
animation-iteration-count: infinite;
animation-direction: alternate;
animation-timing-function: linear;
} }
@keyframes blink { @keyframes blink {
0% { 0%, 40% {
opacity: 0; opacity: 0;
} }
40% {
opacity: 0; 40.5%, 100% {
}
40.5% {
opacity: 1
}
100% {
opacity: 1 opacity: 1
} }
} }

View file

@ -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

View file

@ -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
%

View file

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

View file

@ -1 +1,17 @@
TODO %{
%{
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'

View file

@ -0,0 +1,148 @@
form Highlighter test
sentence My_sentence This should all be a string
text My_text This should also all be a string
word My_word Only the first word is a string, the rest is invalid
boolean Binary 1
boolean Text no
boolean Quoted "yes"
comment This should be a string
real left_Range -123.6
positive right_Range_max 3.3
integer Int 4
natural Nat 4
endform
# External scripts
include /path/to/file
runScript: "/path/to/file"
execute /path/to/file
stopwatch
# old-style procedure call
call oldStyle "quoted" 2 unquoted string
assert oldStyle.local = 1
# New-style procedure call with parens
@newStyle("quoted", 2, "quoted string")
if praatVersion >= 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

View file

@ -47,3 +47,9 @@ body {
right: 0; right: 0;
border-left: 1px solid; border-left: 1px solid;
} }
/* .ace_text-input {
z-index: 10!important;
opacity: 1!important;
background: rgb(84, 0, 255)!important;
}*/

View file

@ -1,6 +1,7 @@
var editor; var editor;
var embedded_editor; var embedded_editor;
$(function() { $(function() {
if (typeof ace !== "undefined") {
ace.config.set("workerPath", "build/src-min"); ace.config.set("workerPath", "build/src-min");
editor = ace.edit("ace_editor_demo"); editor = ace.edit("ace_editor_demo");
editor.container.style.opacity = ""; editor.container.style.opacity = "";
@ -33,7 +34,16 @@ $(function() {
enableBasicAutocompletion: true enableBasicAutocompletion: true
}); });
}); });
} else {
document.body.insertAdjacentHTML("afterbegin", '<div class="bs-docs-example">\
<div class="alert alert-error">\
<button type="button" class="close" data-dismiss="alert">\xd7</button>\
<strong>Oh No!</strong> Couldn\'t load <code>build/src/ace.js</code>.<br>\
You can build it by running <code>node Makefile.dryice.js</code><br>\
Or download older version by running <code>git submodule update --init --recursive</code><br>\
</div>\
</div>');
}
$("ul.menu-list").mousedown(function(e) { $("ul.menu-list").mousedown(function(e) {
if (e.button === 1) { if (e.button === 1) {
e.preventDefault(); e.preventDefault();
@ -161,7 +171,11 @@ function highlight() {
var highlighter = ace.require("ace/ext/static_highlight") var highlighter = ace.require("ace/ext/static_highlight")
var dom = ace.require("ace/lib/dom") var dom = ace.require("ace/lib/dom")
function qsa(sel) { function qsa(sel) {
return Array.apply(null, document.querySelectorAll(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) { qsa("code[class]").forEach(function(el) {

View file

@ -79,11 +79,21 @@ exports.edit = function(el) {
throw new Error("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; return el.env.editor;
var doc = exports.createEditSession(dom.getInnerText(el)); 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 = ''; el.innerHTML = '';
}
var doc = exports.createEditSession(value);
var editor = new Editor(new Renderer(el)); var editor = new Editor(new Renderer(el));
editor.setSession(doc); editor.setSession(doc);
@ -93,11 +103,13 @@ exports.edit = function(el) {
editor: editor, editor: editor,
onResize: editor.resize.bind(editor, null) onResize: editor.resize.bind(editor, null)
}; };
if (oldNode) env.textarea = oldNode;
event.addListener(window, "resize", env.onResize); event.addListener(window, "resize", env.onResize);
editor.on("destroy", function() { editor.on("destroy", function() {
event.removeListener(window, "resize", env.onResize); 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; return editor;
}; };

View file

@ -89,6 +89,8 @@ var Autocomplete = function() {
pos.left += renderer.$gutterLayer.gutterWidth; pos.left += renderer.$gutterLayer.gutterWidth;
this.popup.show(pos, lineHeight); this.popup.show(pos, lineHeight);
} else if (keepPopupPosition && !prefix) {
this.detach();
} }
}; };
@ -101,12 +103,12 @@ var Autocomplete = function() {
this.changeTimer.cancel(); this.changeTimer.cancel();
if (this.popup && this.popup.isOpen) { if (this.popup && this.popup.isOpen) {
this.gatherCompletionsId = this.gatherCompletionsId + 1; this.gatherCompletionsId += 1;
this.popup.hide();
} }
if (this.popup) if (this.base)
this.popup.hide(); this.base.detach();
this.activated = false; this.activated = false;
this.completions = this.base = null; this.completions = this.base = null;
}; };
@ -205,8 +207,8 @@ var Autocomplete = function() {
var line = session.getLine(pos.row); var line = session.getLine(pos.row);
var prefix = util.retrievePrecedingIdentifier(line, pos.column); var prefix = util.retrievePrecedingIdentifier(line, pos.column);
this.base = editor.getCursorPosition(); this.base = session.doc.createAnchor(pos.row, pos.column - prefix.length);
this.base.column -= prefix.length; this.base.$insertRight = true;
var matches = []; var matches = [];
var total = editor.completers.length; var total = editor.completers.length;
@ -298,7 +300,7 @@ var Autocomplete = function() {
return detachIfFinished(); return detachIfFinished();
// Autoinsert if one result // Autoinsert if one result
if (this.autoInsert && filtered.length == 1) if (this.autoInsert && filtered.length == 1 && results.finished)
return this.insertMatch(filtered[0]); return this.insertMatch(filtered[0]);
this.openPopup(this.editor, prefix, keepPopupPosition); this.openPopup(this.editor, prefix, keepPopupPosition);
@ -346,7 +348,7 @@ var FilteredList = function(array, filterText, mutateData) {
// make unique // make unique
var prev = null; var prev = null;
matches = matches.filter(function(item){ matches = matches.filter(function(item){
var caption = item.value || item.caption || item.snippet; var caption = item.snippet || item.caption || item.value;
if (caption === prev) return false; if (caption === prev) return false;
prev = caption; prev = caption;
return true; return true;

View file

@ -52,6 +52,7 @@ var $singleLineEditor = function(el) {
editor.renderer.setHighlightGutterLine(false); editor.renderer.setHighlightGutterLine(false);
editor.$mouseHandler.$focusWaitTimout = 0; editor.$mouseHandler.$focusWaitTimout = 0;
editor.$highlightTagPending = true;
return editor; return editor;
}; };
@ -67,6 +68,7 @@ var AcePopup = function(parentNode) {
popup.renderer.setStyle("ace_autocomplete"); popup.renderer.setStyle("ace_autocomplete");
popup.setOption("displayIndentGuides", false); popup.setOption("displayIndentGuides", false);
popup.setOption("dragDelay", 150);
var noop = function(){}; var noop = function(){};
@ -102,7 +104,7 @@ var AcePopup = function(parentNode) {
popup.session.removeMarker(hoverMarker.id); popup.session.removeMarker(hoverMarker.id);
hoverMarker.id = null; hoverMarker.id = null;
} }
} };
popup.setSelectOnHover(false); popup.setSelectOnHover(false);
popup.on("mousemove", function(e) { popup.on("mousemove", function(e) {
if (!lastMouseEvent) { if (!lastMouseEvent) {
@ -170,15 +172,15 @@ var AcePopup = function(parentNode) {
}; };
var bgTokenizer = popup.session.bgTokenizer; var bgTokenizer = popup.session.bgTokenizer;
bgTokenizer.$tokenizeRow = function(i) { bgTokenizer.$tokenizeRow = function(row) {
var data = popup.data[i]; var data = popup.data[row];
var tokens = []; var tokens = [];
if (!data) if (!data)
return tokens; return tokens;
if (typeof data == "string") if (typeof data == "string")
data = {value: data}; data = {value: data};
if (!data.caption) if (!data.caption)
data.caption = data.value; data.caption = data.value || data.name;
var last = -1; var last = -1;
var flag, c; var flag, c;
@ -205,7 +207,7 @@ var AcePopup = function(parentNode) {
popup.session.$computeWidth = function() { popup.session.$computeWidth = function() {
return this.screenWidth = 0; return this.screenWidth = 0;
} };
// public // public
popup.isOpen = false; popup.isOpen = false;

View file

@ -68,7 +68,7 @@ define(function(require, exports, module) {
var wordList = Object.keys(wordScore); var wordList = Object.keys(wordScore);
callback(null, wordList.map(function(word) { callback(null, wordList.map(function(word) {
return { return {
name: word, caption: word,
value: word, value: word,
score: wordScore[word], score: wordScore[word],
meta: "local" meta: "local"

View file

@ -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. * 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. * 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 {Tokenizer} tokenizer The tokenizer to use
* @param {Editor} editor The editor to associate with * @param {Editor} editor The editor to associate with
* *
*
*
* @constructor * @constructor
**/ **/
@ -89,10 +85,9 @@ var BackgroundTokenizer = function(tokenizer, editor) {
// only check every 5 lines // only check every 5 lines
processedLines ++; processedLines ++;
if ((processedLines % 5 == 0) && (new Date() - workerStart) > 20) { if ((processedLines % 5 === 0) && (new Date() - workerStart) > 20) {
self.running = setTimeout(self.$worker, 20); self.running = setTimeout(self.$worker, 20);
self.currentLine = currentLine; break;
return;
} }
} }
self.currentLine = currentLine; self.currentLine = currentLine;

View file

@ -81,7 +81,7 @@ exports.moduleUrl = function(name, component) {
// todo make this configurable or get rid of '-' // todo make this configurable or get rid of '-'
var sep = component == "snippets" ? "/" : "-"; var sep = component == "snippets" ? "/" : "-";
var base = parts[parts.length - 1]; var base = parts[parts.length - 1];
if (sep == "-") { if (component == "worker" && sep == "-") {
var re = new RegExp("^" + component + "[\\-_]|[\\-_]" + component + "$", "g"); var re = new RegExp("^" + component + "[\\-_]|[\\-_]" + component + "$", "g");
base = base.replace(re, ""); base = base.replace(re, "");
} }

View file

@ -43,7 +43,7 @@ module.exports = {
"test: path resolution" : function() { "test: path resolution" : function() {
config.set("packaged", "true"); config.set("packaged", "true");
var url = config.moduleUrl("kr_theme", "theme"); var url = config.moduleUrl("kr_theme", "theme");
assert.equal(url, "theme-kr.js"); assert.equal(url, "theme-kr_theme.js");
config.set("basePath", "a/b"); config.set("basePath", "a/b");
url = config.moduleUrl("m/theme", "theme"); url = config.moduleUrl("m/theme", "theme");

View file

@ -1,9 +1,7 @@
.ace_editor { .ace_editor {
position: relative; position: relative;
overflow: hidden; overflow: hidden;
font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'source-code-pro', monospace; font: 12px/normal 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'source-code-pro', monospace;
font-size: 12px;
line-height: normal;
direction: ltr; direction: ltr;
} }
@ -17,6 +15,7 @@
-moz-user-select: none; -moz-user-select: none;
-webkit-user-select: none; -webkit-user-select: none;
user-select: none; user-select: none;
cursor: text;
} }
.ace_content { .ace_content {
@ -24,14 +23,9 @@
-moz-box-sizing: border-box; -moz-box-sizing: border-box;
-webkit-box-sizing: border-box; -webkit-box-sizing: border-box;
box-sizing: border-box; box-sizing: border-box;
cursor: text;
min-width: 100%; min-width: 100%;
} }
.ace_dragging, .ace_dragging * {
cursor: move !important;
}
.ace_dragging .ace_scroller:before{ .ace_dragging .ace_scroller:before{
position: absolute; position: absolute;
top: 0; top: 0;
@ -155,8 +149,8 @@
} }
.ace_text-input.ace_composition { .ace_text-input.ace_composition {
background: #f8f8f8; background: inherit;
color: #111; color: inherit;
z-index: 1000; z-index: 1000;
opacity: 1; opacity: 1;
text-indent: 0; text-indent: 0;
@ -211,7 +205,7 @@
} }
.ace_overwrite-cursors .ace_cursor { .ace_overwrite-cursors .ace_cursor {
border-left-width: 0px; border-left-width: 0;
border-bottom: 1px solid; border-bottom: 1px solid;
} }
@ -220,10 +214,7 @@
} }
.ace_smooth-blinking .ace_cursor { .ace_smooth-blinking .ace_cursor {
-moz-transition: opacity 0.18s;
-webkit-transition: opacity 0.18s; -webkit-transition: opacity 0.18s;
-o-transition: opacity 0.18s;
-ms-transition: opacity 0.18s;
transition: opacity 0.18s; transition: opacity 0.18s;
} }
@ -277,8 +268,6 @@
color: transparent; color: transparent;
border: 1px solid black; border: 1px solid black;
-moz-border-radius: 2px;
-webkit-border-radius: 2px;
border-radius: 2px; border-radius: 2px;
cursor: pointer; cursor: pointer;
@ -302,7 +291,6 @@
border-radius: 1px; border-radius: 1px;
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
color: black; color: black;
display: block;
max-width: 100%; max-width: 100%;
padding: 3px 4px; padding: 3px 4px;
position: fixed; position: fixed;
@ -359,16 +347,12 @@
.ace_fold-widget:hover { .ace_fold-widget:hover {
border: 1px solid rgba(0, 0, 0, 0.3); border: 1px solid rgba(0, 0, 0, 0.3);
background-color: rgba(255, 255, 255, 0.2); 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); box-shadow: 0 1px 1px rgba(255, 255, 255, 0.7);
} }
.ace_fold-widget:active { .ace_fold-widget:active {
border: 1px solid rgba(0, 0, 0, 0.4); border: 1px solid rgba(0, 0, 0, 0.4);
background-color: rgba(0, 0, 0, 0.05); 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); box-shadow: 0 1px 1px rgba(255, 255, 255, 0.8);
} }
/** /**
@ -388,8 +372,6 @@
background-color: rgba(255, 255, 255, 0.1); background-color: rgba(255, 255, 255, 0.1);
} }
.ace_dark .ace_fold-widget:active { .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); box-shadow: 0 1px 1px rgba(255, 255, 255, 0.2);
} }
@ -399,19 +381,13 @@
} }
.ace_fade-fold-widgets .ace_fold-widget { .ace_fade-fold-widgets .ace_fold-widget {
-moz-transition: opacity 0.4s ease 0.05s;
-webkit-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; transition: opacity 0.4s ease 0.05s;
opacity: 0; opacity: 0;
} }
.ace_fade-fold-widgets:hover .ace_fold-widget { .ace_fade-fold-widgets:hover .ace_fold-widget {
-moz-transition: opacity 0.05s ease 0.05s;
-webkit-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; transition: opacity 0.05s ease 0.05s;
opacity:1; opacity:1;
} }

View file

@ -268,7 +268,7 @@ var EditSession = function(text, mode) {
this.$informUndoManager.schedule(); this.$informUndoManager.schedule();
} }
this.bgTokenizer.$updateOnChange(delta); this.bgTokenizer && this.bgTokenizer.$updateOnChange(delta);
this._signal("change", e); this._signal("change", e);
}; };
@ -276,8 +276,6 @@ var EditSession = function(text, mode) {
* Sets the session text. * Sets the session text.
* @param {String} text The new text to place * @param {String} text The new text to place
* *
*
*
**/ **/
this.setValue = function(text) { this.setValue = function(text) {
this.doc.setValue(text); this.doc.setValue(text);
@ -950,6 +948,9 @@ var EditSession = function(text, mode) {
if (!$isPlaceholder) { if (!$isPlaceholder) {
// experimental method, used by c9 findiniles
if (mode.attachToSession)
mode.attachToSession(this);
this.$options.wrapMethod.set.call(this, this.$wrapMethod); this.$options.wrapMethod.set.call(this, this.$wrapMethod);
this.$setFolding(mode.foldingRules); this.$setFolding(mode.foldingRules);
this.bgTokenizer.start(0); this.bgTokenizer.start(0);
@ -957,26 +958,23 @@ var EditSession = function(text, mode) {
} }
}; };
this.$stopWorker = function() { this.$stopWorker = function() {
if (this.$worker) if (this.$worker) {
this.$worker.terminate(); this.$worker.terminate();
this.$worker = null; this.$worker = null;
}
}; };
this.$startWorker = function() { this.$startWorker = function() {
if (typeof Worker !== "undefined" && !require.noWorker) {
try { try {
this.$worker = this.$mode.createWorker(this); this.$worker = this.$mode.createWorker(this);
} catch (e) { } catch (e) {
if (typeof console == "object") {
console.log("Could not load worker"); console.log("Could not load worker");
console.log(e); console.log(e);
}
this.$worker = null; this.$worker = null;
} }
}
else
this.$worker = null;
}; };
/** /**
@ -1726,9 +1724,10 @@ var EditSession = function(text, mode) {
// Inside of the foldLine range. Need to split stuff up. // Inside of the foldLine range. Need to split stuff up.
if (cmp == 0) { if (cmp == 0) {
foldLine = foldLine.split(start.row, start.column); foldLine = foldLine.split(start.row, start.column);
if (foldLine) {
foldLine.shiftRow(len); foldLine.shiftRow(len);
foldLine.addRemoveChars( foldLine.addRemoveChars(lastRow, 0, end.column - start.column);
lastRow, 0, end.column - start.column); }
} else } else
// Infront of the foldLine but same row. Need to shift column. // Infront of the foldLine but same row. Need to shift column.
if (cmp == -1) { if (cmp == -1) {
@ -1956,6 +1955,8 @@ var EditSession = function(text, mode) {
split = lastSplit + wrapLimit; split = lastSplit + wrapLimit;
// The split is inside of a CHAR or CHAR_EXT token and no space // The split is inside of a CHAR or CHAR_EXT token and no space
// around -> force a split. // around -> force a split.
if (tokens[split] == CHAR_EXT)
split--;
addSplit(split); addSplit(split);
} }
return splits; return splits;
@ -2395,7 +2396,15 @@ var EditSession = function(text, mode) {
*/ */
this.$setFontMetrics = function(fm) { this.$setFontMetrics = function(fm) {
// todo // 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!! // 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 // Wouldn't hurt to make it a bit faster for c >= 0x1100

View file

@ -117,6 +117,7 @@ function BracketMatch() {
typeRe = new RegExp( typeRe = new RegExp(
"(\\.?" + "(\\.?" +
token.type.replace(".", "\\.").replace("rparen", ".paren") token.type.replace(".", "\\.").replace("rparen", ".paren")
.replace(/\b(?:end|start|begin)\b/, "")
+ ")+" + ")+"
); );
} }
@ -173,6 +174,7 @@ function BracketMatch() {
typeRe = new RegExp( typeRe = new RegExp(
"(\\.?" + "(\\.?" +
token.type.replace(".", "\\.").replace("lparen", ".paren") token.type.replace(".", "\\.").replace("lparen", ".paren")
.replace(/\b(?:end|start|begin)\b/, "")
+ ")+" + ")+"
); );
} }

View file

@ -44,7 +44,7 @@ function FoldLine(foldData, folds) {
folds = this.folds = [ 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, this.range = new Range(folds[0].start.row, folds[0].start.column,
last.end.row, last.end.column); last.end.row, last.end.column);
this.start = this.range.start; this.start = this.range.start;
@ -66,7 +66,7 @@ function FoldLine(foldData, folds) {
fold.start.row += shift; fold.start.row += shift;
fold.end.row += shift; fold.end.row += shift;
}); });
} };
this.addFold = function(fold) { this.addFold = function(fold) {
if (fold.sameRow) { if (fold.sameRow) {
@ -96,17 +96,17 @@ function FoldLine(foldData, folds) {
throw new Error("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; fold.foldLine = this;
} };
this.containsRow = function(row) { this.containsRow = function(row) {
return row >= this.start.row && row <= this.end.row; return row >= this.start.row && row <= this.end.row;
} };
this.walk = function(callback, endRow, endColumn) { this.walk = function(callback, endRow, endColumn) {
var lastEnd = 0, var lastEnd = 0,
folds = this.folds, folds = this.folds,
fold, fold,
comp, stop, isNewRow = true; cmp, stop, isNewRow = true;
if (endRow == null) { if (endRow == null) {
endRow = this.end.row; endRow = this.end.row;
@ -116,9 +116,9 @@ function FoldLine(foldData, folds) {
for (var i = 0; i < folds.length; i++) { for (var i = 0; i < folds.length; i++) {
fold = folds[i]; fold = folds[i];
comp = fold.range.compareStart(endRow, endColumn); cmp = fold.range.compareStart(endRow, endColumn);
// This fold is after the endRow/Column. // This fold is after the endRow/Column.
if (comp == -1) { if (cmp == -1) {
callback(null, endRow, endColumn, lastEnd, isNewRow); callback(null, endRow, endColumn, lastEnd, isNewRow);
return; return;
} }
@ -127,8 +127,8 @@ function FoldLine(foldData, folds) {
stop = !stop && callback(fold.placeholder, fold.start.row, fold.start.column, lastEnd); stop = !stop && callback(fold.placeholder, fold.start.row, fold.start.column, lastEnd);
// If the user requested to stop the walk or endRow/endColumn is // If the user requested to stop the walk or endRow/endColumn is
// inside of this fold (comp == 0), then end here. // inside of this fold (cmp == 0), then end here.
if (stop || comp == 0) { if (stop || cmp === 0) {
return; return;
} }
@ -138,7 +138,7 @@ function FoldLine(foldData, folds) {
lastEnd = fold.end.column; lastEnd = fold.end.column;
} }
callback(null, endRow, endColumn, lastEnd, isNewRow); callback(null, endRow, endColumn, lastEnd, isNewRow);
} };
this.getNextFoldTo = function(row, column) { this.getNextFoldTo = function(row, column) {
var fold, cmp; var fold, cmp;
@ -150,15 +150,15 @@ function FoldLine(foldData, folds) {
fold: fold, fold: fold,
kind: "after" kind: "after"
}; };
} else if (cmp == 0) { } else if (cmp === 0) {
return { return {
fold: fold, fold: fold,
kind: "inside" kind: "inside"
} };
} }
} }
return null; return null;
} };
this.addRemoveChars = function(row, column, len) { this.addRemoveChars = function(row, column, len) {
var ret = this.getNextFoldTo(row, column), var ret = this.getNextFoldTo(row, column),
@ -175,7 +175,7 @@ function FoldLine(foldData, folds) {
} else if (fold.start.row == row) { } else if (fold.start.row == row) {
folds = this.folds; folds = this.folds;
var i = folds.indexOf(fold); var i = folds.indexOf(fold);
if (i == 0) { if (i === 0) {
this.start.column += len; this.start.column += len;
} }
for (i; i < folds.length; i++) { for (i; i < folds.length; i++) {
@ -189,16 +189,18 @@ function FoldLine(foldData, folds) {
this.end.column += len; this.end.column += len;
} }
} }
} };
this.split = function(row, column) { 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 folds = this.folds;
var foldData = this.foldData; var foldData = this.foldData;
if (!fold)
return null;
var i = folds.indexOf(fold); var i = folds.indexOf(fold);
var foldBefore = folds[i - 1]; var foldBefore = folds[i - 1];
this.end.row = foldBefore.end.row; this.end.row = foldBefore.end.row;
@ -211,7 +213,7 @@ function FoldLine(foldData, folds) {
var newFoldLine = new FoldLine(foldData, folds); var newFoldLine = new FoldLine(foldData, folds);
foldData.splice(foldData.indexOf(this) + 1, 0, newFoldLine); foldData.splice(foldData.indexOf(this) + 1, 0, newFoldLine);
return newFoldLine; return newFoldLine;
} };
this.merge = function(foldLineNext) { this.merge = function(foldLineNext) {
var folds = foldLineNext.folds; var folds = foldLineNext.folds;
@ -222,7 +224,7 @@ function FoldLine(foldData, folds) {
// it's merged now with foldLineNext. // it's merged now with foldLineNext.
var foldData = this.foldData; var foldData = this.foldData;
foldData.splice(foldData.indexOf(foldLineNext), 1); foldData.splice(foldData.indexOf(foldLineNext), 1);
} };
this.toString = function() { this.toString = function() {
var ret = [this.range.toString() + ": [" ]; var ret = [this.range.toString() + ": [" ];
@ -230,13 +232,12 @@ function FoldLine(foldData, folds) {
this.folds.forEach(function(fold) { this.folds.forEach(function(fold) {
ret.push(" " + fold.toString()); ret.push(" " + fold.toString());
}); });
ret.push("]") ret.push("]");
return ret.join("\n"); return ret.join("\n");
} };
this.idxToPosition = function(idx) { this.idxToPosition = function(idx) {
var lastFoldEndColumn = 0; var lastFoldEndColumn = 0;
var fold;
for (var i = 0; i < this.folds.length; i++) { for (var i = 0; i < this.folds.length; i++) {
var fold = this.folds[i]; var fold = this.folds[i];
@ -261,7 +262,7 @@ function FoldLine(foldData, folds) {
row: this.end.row, row: this.end.row,
column: this.end.column + idx column: this.end.column + idx
}; };
} };
}).call(FoldLine.prototype); }).call(FoldLine.prototype);
exports.FoldLine = FoldLine; exports.FoldLine = FoldLine;

View file

@ -94,7 +94,8 @@ var Editor = function(renderer, session) {
this._$emitInputEvent = lang.delayedCall(function() { this._$emitInputEvent = lang.delayedCall(function() {
this._signal("input", {}); this._signal("input", {});
this.session.bgTokenizer && this.session.bgTokenizer.scheduleStart(); if (this.session && this.session.bgTokenizer)
this.session.bgTokenizer.scheduleStart();
}.bind(this)); }.bind(this));
this.on("change", function(_, _self) { this.on("change", function(_, _self) {
@ -384,6 +385,9 @@ var Editor = function(renderer, session) {
this.onChangeAnnotation(); this.onChangeAnnotation();
this.session.getUseWrapMode() && this.renderer.adjustWrapLimit(); this.session.getUseWrapMode() && this.renderer.adjustWrapLimit();
this.renderer.updateFull(); this.renderer.updateFull();
} else {
this.selection = null;
this.renderer.setSession(session);
} }
this._signal("changeSession", { this._signal("changeSession", {
@ -525,25 +529,23 @@ var Editor = function(renderer, session) {
this.$highlightPending = true; this.$highlightPending = true;
setTimeout(function() { setTimeout(function() {
self.$highlightPending = false; self.$highlightPending = false;
var session = self.session;
var pos = self.session.findMatchingBracket(self.getCursorPosition()); if (!session || !session.bgTokenizer) return;
var pos = session.findMatchingBracket(self.getCursorPosition());
if (pos) { if (pos) {
var range = new Range(pos.row, pos.column, pos.row, pos.column + 1); var range = new Range(pos.row, pos.column, pos.row, pos.column + 1);
} else if (self.session.$mode.getMatching) { } else if (session.$mode.getMatching) {
var range = self.session.$mode.getMatching(self.session); var range = session.$mode.getMatching(self.session);
} }
if (range) if (range)
self.session.$bracketHighlight = self.session.addMarker(range, "ace_bracket", "text"); session.$bracketHighlight = session.addMarker(range, "ace_bracket", "text");
}, 50); }, 50);
}; };
// todo: move to mode.getMatching // todo: move to mode.getMatching
this.$highlightTags = function() { this.$highlightTags = function() {
var session = this.session; if (this.$highlightTagPending)
if (this.$highlightTagPending) {
return; return;
}
// perform highlight async to not block the browser during navigation // perform highlight async to not block the browser during navigation
var self = this; var self = this;
@ -551,6 +553,9 @@ var Editor = function(renderer, session) {
setTimeout(function() { setTimeout(function() {
self.$highlightTagPending = false; self.$highlightTagPending = false;
var session = self.session;
if (!session || !session.bgTokenizer) return;
var pos = self.getCursorPosition(); var pos = self.getCursorPosition();
var iterator = new TokenIterator(self.session, pos.row, pos.column); var iterator = new TokenIterator(self.session, pos.row, pos.column);
var token = iterator.getCurrentToken(); var token = iterator.getCurrentToken();
@ -696,12 +701,15 @@ var Editor = function(renderer, session) {
this.onDocumentChange = function(e) { this.onDocumentChange = function(e) {
// Rerender and emit "change" event. // Rerender and emit "change" event.
var delta = e.data; var delta = e.data;
var wrap = this.session.$useWrapMode;
var lastRow = (delta.start.row == delta.end.row ? delta.end.row : Infinity); var lastRow = (delta.start.row == delta.end.row ? delta.end.row : Infinity);
this.renderer.updateLines(delta.start.row, lastRow); this.renderer.updateLines(delta.start.row, lastRow, wrap);
this._signal("change", e); this._signal("change", e);
// Update cursor because tab characters can influence the cursor position. // Update cursor because tab characters can influence the cursor position.
this.$cursorChange(); this.$cursorChange();
this.$updateHighlightActiveLine();
}; };
this.onTokenizerUpdate = function(e) { this.onTokenizerUpdate = function(e) {
@ -1990,17 +1998,13 @@ var Editor = function(renderer, session) {
* Moves the cursor's row and column to the next matching bracket or HTML tag. * 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 cursor = this.getCursorPosition();
var iterator = new TokenIterator(this.session, cursor.row, cursor.column); var iterator = new TokenIterator(this.session, cursor.row, cursor.column);
var prevToken = iterator.getCurrentToken(); var prevToken = iterator.getCurrentToken();
var token = prevToken; var token = prevToken || iterator.stepForward();
if (!token) if (!token) return;
token = iterator.stepForward();
if (!token)
return;
//get next closing tag or bracket //get next closing tag or bracket
var matchType; var matchType;
@ -2048,14 +2052,16 @@ var Editor = function(renderer, session) {
break; break;
} }
} }
} else if (token && token.type.indexOf('tag-name') !== -1) { }
else if (token && token.type.indexOf('tag-name') !== -1) {
if (isNaN(depth[token.value])) { if (isNaN(depth[token.value])) {
depth[token.value] = 0; depth[token.value] = 0;
} }
if (prevToken.value === '<') { if (prevToken.value === '<') {
depth[token.value]++; depth[token.value]++;
} else if (prevToken.value === '</') { }
else if (prevToken.value === '</') {
depth[token.value]--; depth[token.value]--;
} }
@ -2073,11 +2079,10 @@ var Editor = function(renderer, session) {
} while (token && !found); } while (token && !found);
//no match found //no match found
if (!matchType) { if (!matchType)
return; return;
}
var range; var range, pos;
if (matchType === 'bracket') { if (matchType === 'bracket') {
range = this.session.getBracketRange(cursor); range = this.session.getBracketRange(cursor);
if (!range) { if (!range) {
@ -2087,19 +2092,18 @@ var Editor = function(renderer, session) {
iterator.getCurrentTokenRow(), iterator.getCurrentTokenRow(),
iterator.getCurrentTokenColumn() + i - 1 iterator.getCurrentTokenColumn() + i - 1
); );
if (!range) pos = range.start;
return; if (expand || pos.row === cursor.row && Math.abs(pos.column - cursor.column) < 2)
var pos = range.start;
if (pos.row === cursor.row && Math.abs(pos.column - cursor.column) < 2)
range = this.session.getBracketRange(pos); range = this.session.getBracketRange(pos);
} }
} else if(matchType==='tag') { }
else if (matchType === 'tag') {
if (token && token.type.indexOf('tag-name') !== -1) if (token && token.type.indexOf('tag-name') !== -1)
var tag = token.value; var tag = token.value;
else else
return; return;
var range = new Range( range = new Range(
iterator.getCurrentTokenRow(), iterator.getCurrentTokenRow(),
iterator.getCurrentTokenColumn() - 2, iterator.getCurrentTokenColumn() - 2,
iterator.getCurrentTokenRow(), iterator.getCurrentTokenRow(),
@ -2121,7 +2125,8 @@ var Editor = function(renderer, session) {
if (token.value === tag && token.type.indexOf('tag-name') !== -1) { if (token.value === tag && token.type.indexOf('tag-name') !== -1) {
if (prevToken.value === '<') { if (prevToken.value === '<') {
depth[tag]++; depth[tag]++;
} else if ( prevToken.value === '</') { }
else if (prevToken.value === '</') {
depth[tag]--; depth[tag]--;
} }
@ -2134,7 +2139,7 @@ var Editor = function(renderer, session) {
//we found it //we found it
if (token && token.type.indexOf('tag-name')) { if (token && token.type.indexOf('tag-name')) {
var pos = range.start; pos = range.start;
if (pos.row == cursor.row && Math.abs(pos.column - cursor.column) < 2) if (pos.row == cursor.row && Math.abs(pos.column - cursor.column) < 2)
pos = range.end; pos = range.end;
} }
@ -2143,10 +2148,13 @@ var Editor = function(renderer, session) {
pos = range && range.cursor || pos; pos = range && range.cursor || pos;
if (pos) { if (pos) {
if (select) { if (select) {
if (range && range.isEqual(this.getSelectionRange())) if (range && expand) {
this.selection.setRange(range);
} else if (range && range.isEqual(this.getSelectionRange())) {
this.clearSelection(); this.clearSelection();
else } else {
this.selection.selectTo(pos.row, pos.column); this.selection.selectTo(pos.row, pos.column);
}
} else { } else {
this.selection.moveTo(pos.row, pos.column); this.selection.moveTo(pos.row, pos.column);
} }
@ -2504,6 +2512,9 @@ var Editor = function(renderer, session) {
this.destroy = function() { this.destroy = function() {
this.renderer.destroy(); this.renderer.destroy();
this._signal("destroy", this); this._signal("destroy", this);
if (this.session) {
this.session.destroy();
}
}; };
/** /**

View file

@ -30,9 +30,9 @@
define(function(require, exports, module) { define(function(require, exports, module) {
"use strict"; "use strict";
var LineWidgets = require("ace/line_widgets").LineWidgets; var LineWidgets = require("../line_widgets").LineWidgets;
var dom = require("ace/lib/dom"); var dom = require("../lib/dom");
var Range = require("ace/range").Range; var Range = require("../range").Range;
function binarySearch(array, needle, comparator) { function binarySearch(array, needle, comparator) {
var first = 0; var first = 0;

View file

@ -161,10 +161,6 @@ var doLiveAutocomplete = function(e) {
editor.completer.autoSelect = false; editor.completer.autoSelect = false;
editor.completer.autoInsert = false; editor.completer.autoInsert = false;
editor.completer.showPopup(editor); editor.completer.showPopup(editor);
} else if (!prefix && hasCompleter) {
// When the prefix is empty
// close the autocomplete dialog
editor.completer.detach();
} }
} }
}; };

View file

@ -65,11 +65,14 @@ var supportedModes = {
Diff: ["diff|patch"], Diff: ["diff|patch"],
Dockerfile: ["^Dockerfile"], Dockerfile: ["^Dockerfile"],
Dot: ["dot"], Dot: ["dot"],
Erlang: ["erl|hrl"], Eiffel: ["e"],
EJS: ["ejs"], EJS: ["ejs"],
Erlang: ["erl|hrl"],
Forth: ["frt|fs|ldr"], Forth: ["frt|fs|ldr"],
FTL: ["ftl"], FTL: ["ftl"],
Gcode: ["gcode"],
Gherkin: ["feature"], Gherkin: ["feature"],
Gitignore: ["^.gitignore"],
Glsl: ["glsl|frag|vert"], Glsl: ["glsl|frag|vert"],
golang: ["go"], golang: ["go"],
Groovy: ["groovy"], Groovy: ["groovy"],
@ -80,6 +83,7 @@ var supportedModes = {
HTML: ["html|htm|xhtml"], HTML: ["html|htm|xhtml"],
HTML_Ruby: ["erb|rhtml|html.erb"], HTML_Ruby: ["erb|rhtml|html.erb"],
INI: ["ini|conf|cfg|prefs"], INI: ["ini|conf|cfg|prefs"],
Io: ["io"],
Jack: ["jack"], Jack: ["jack"],
Jade: ["jade"], Jade: ["jade"],
Java: ["java"], Java: ["java"],
@ -100,11 +104,11 @@ var supportedModes = {
LuaPage: ["lp"], LuaPage: ["lp"],
Lucene: ["lucene"], Lucene: ["lucene"],
Makefile: ["^Makefile|^GNUmakefile|^makefile|^OCamlMakefile|make"], Makefile: ["^Makefile|^GNUmakefile|^makefile|^OCamlMakefile|make"],
MATLAB: ["matlab"],
Markdown: ["md|markdown"], Markdown: ["md|markdown"],
MATLAB: ["matlab"],
MEL: ["mel"], MEL: ["mel"],
MySQL: ["mysql"],
MUSHCode: ["mc|mush"], MUSHCode: ["mc|mush"],
MySQL: ["mysql"],
Nix: ["nix"], Nix: ["nix"],
ObjectiveC: ["m|mm"], ObjectiveC: ["m|mm"],
OCaml: ["ml|mli"], OCaml: ["ml|mli"],
@ -113,6 +117,7 @@ var supportedModes = {
pgSQL: ["pgsql"], pgSQL: ["pgsql"],
PHP: ["php|phtml"], PHP: ["php|phtml"],
Powershell: ["ps1"], Powershell: ["ps1"],
Praat: ["praat|praatscript|psc|proc"],
Prolog: ["plg|prolog"], Prolog: ["plg|prolog"],
Properties: ["properties"], Properties: ["properties"],
Protobuf: ["proto"], Protobuf: ["proto"],
@ -125,14 +130,14 @@ var supportedModes = {
SASS: ["sass"], SASS: ["sass"],
SCAD: ["scad"], SCAD: ["scad"],
Scala: ["scala"], Scala: ["scala"],
Smarty: ["smarty|tpl"],
Scheme: ["scm|rkt"], Scheme: ["scm|rkt"],
SCSS: ["scss"], SCSS: ["scss"],
SH: ["sh|bash|^.bashrc"], SH: ["sh|bash|^.bashrc"],
SJS: ["sjs"], SJS: ["sjs"],
Space: ["space"], Smarty: ["smarty|tpl"],
snippets: ["snippets"], snippets: ["snippets"],
Soy_Template:["soy"], Soy_Template:["soy"],
Space: ["space"],
SQL: ["sql"], SQL: ["sql"],
Stylus: ["styl|stylus"], Stylus: ["styl|stylus"],
SVG: ["svg"], SVG: ["svg"],
@ -144,9 +149,10 @@ var supportedModes = {
Twig: ["twig"], Twig: ["twig"],
Typescript: ["ts|typescript|str"], Typescript: ["ts|typescript|str"],
Vala: ["vala"], Vala: ["vala"],
VBScript: ["vbs"], VBScript: ["vbs|vb"],
Velocity: ["vm"], Velocity: ["vm"],
Verilog: ["v|vh|sv|svh"], Verilog: ["v|vh|sv|svh"],
VHDL: ["vhd|vhdl"],
XML: ["xml|rdf|rss|wsdl|xslt|atom|mathml|mml|xul|xbl"], XML: ["xml|rdf|rss|wsdl|xslt|atom|mathml|mml|xul|xbl"],
XQuery: ["xq"], XQuery: ["xq"],
YAML: ["yaml|yml"] YAML: ["yaml|yml"]
@ -156,7 +162,7 @@ var nameOverrides = {
ObjectiveC: "Objective-C", ObjectiveC: "Objective-C",
CSharp: "C#", CSharp: "C#",
golang: "Go", golang: "Go",
C_Cpp: "C/C++", C_Cpp: "C and C++",
coffee: "CoffeeScript", coffee: "CoffeeScript",
HTML_Ruby: "HTML (Ruby)", HTML_Ruby: "HTML (Ruby)",
FTL: "FreeMarker" FTL: "FreeMarker"

View file

@ -7,7 +7,7 @@
background-color: #ddd; background-color: #ddd;
border: 1px solid #cbcbcb; border: 1px solid #cbcbcb;
border-top: 0 none; border-top: 0 none;
max-width: 297px; max-width: 325px;
overflow: hidden; overflow: hidden;
margin: 0; margin: 0;
padding: 4px; padding: 4px;
@ -47,7 +47,6 @@
-webkit-box-sizing: border-box; -webkit-box-sizing: border-box;
-moz-box-sizing: border-box; -moz-box-sizing: border-box;
box-sizing: border-box; box-sizing: border-box;
display: block;
float: left; float: left;
height: 22px; height: 22px;
outline: 0; outline: 0;
@ -61,7 +60,6 @@
border: 0 none; border: 0 none;
border-left: 1px solid #dcdcdc; border-left: 1px solid #dcdcdc;
cursor: pointer; cursor: pointer;
display: block;
float: left; float: left;
height: 22px; height: 22px;
margin: 0; margin: 0;
@ -94,12 +92,9 @@
border: 0 none; border: 0 none;
color: #656565; color: #656565;
cursor: pointer; cursor: pointer;
display: block;
float: right; float: right;
font-family: Arial; font: 16px/16px Arial;
font-size: 16px;
height: 14px; height: 14px;
line-height: 16px;
margin: 5px 1px 9px 5px; margin: 5px 1px 9px 5px;
padding: 0; padding: 0;
text-align: center; text-align: center;

View file

@ -46,6 +46,7 @@ var html = '<div class="ace_search right">\
<input class="ace_search_field" placeholder="Search for" spellcheck="false"></input>\ <input class="ace_search_field" placeholder="Search for" spellcheck="false"></input>\
<button type="button" action="findNext" class="ace_searchbtn next"></button>\ <button type="button" action="findNext" class="ace_searchbtn next"></button>\
<button type="button" action="findPrev" class="ace_searchbtn prev"></button>\ <button type="button" action="findPrev" class="ace_searchbtn prev"></button>\
<button type="button" action="findAll" class="ace_searchbtn" title="Alt-Enter">All</button>\
</div>\ </div>\
<div class="ace_replace_form">\ <div class="ace_replace_form">\
<input class="ace_search_field" placeholder="Replace with" spellcheck="false"></input>\ <input class="ace_search_field" placeholder="Replace with" spellcheck="false"></input>\
@ -170,6 +171,11 @@ var SearchBox = function(editor, range, showReplaceForm) {
sb.replace(); sb.replace();
sb.findPrev(); sb.findPrev();
}, },
"Alt-Return": function(sb) {
if (sb.activeInput == sb.replaceInput)
sb.replaceAll();
sb.findAll();
},
"Tab": function(sb) { "Tab": function(sb) {
(sb.activeInput == sb.replaceInput ? sb.searchInput : sb.replaceInput).focus(); (sb.activeInput == sb.replaceInput ? sb.searchInput : sb.replaceInput).focus();
} }
@ -229,6 +235,18 @@ var SearchBox = function(editor, range, showReplaceForm) {
this.findPrev = function() { this.findPrev = function() {
this.find(true, true); 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.replace = function() {
if (!this.editor.getReadOnly()) if (!this.editor.getReadOnly())
this.editor.replace(this.replaceInput.value); this.editor.replace(this.replaceInput.value);

View file

@ -5,7 +5,6 @@
.ace_static_highlight .ace_gutter { .ace_static_highlight .ace_gutter {
width: 25px !important; width: 25px !important;
display: block;
float: left; float: left;
text-align: right; text-align: right;
padding: 0 3px 0 0; padding: 0 3px 0 0;

View file

@ -98,7 +98,6 @@ var highlight = function(el, opts, callback) {
* and `css`. * and `css`.
* @returns {object} An object containing the properties `html` and `css`. * @returns {object} An object containing the properties `html` and `css`.
*/ */
highlight.render = function(input, mode, theme, lineStart, disableGutter, callback) { highlight.render = function(input, mode, theme, lineStart, disableGutter, callback) {
var waiting = 1; var waiting = 1;
var modeCache = EditSession.prototype.$modes; var modeCache = EditSession.prototype.$modes;
@ -112,11 +111,17 @@ highlight.render = function(input, mode, theme, lineStart, disableGutter, callba
--waiting || done(); --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") { if (typeof mode == "string") {
waiting++; waiting++;
config.loadModule(['mode', mode], function(m) { config.loadModule(['mode', mode], function(m) {
if (!modeCache[mode]) modeCache[mode] = new m.Mode(); if (!modeCache[mode] || modeOptions)
modeCache[mode] = new m.Mode(modeOptions);
mode = modeCache[mode]; mode = modeCache[mode];
--waiting || done(); --waiting || done();
}); });
@ -130,14 +135,13 @@ highlight.render = function(input, mode, theme, lineStart, disableGutter, callba
return --waiting || done(); return --waiting || done();
}; };
/* /**
* Transforms a given input code snippet into HTML using the given mode * Transforms a given input code snippet into HTML using the given mode
* @param {string} input Code snippet * @param {string} input Code snippet
* @param {mode} mode Mode loaded from /ace/mode (use 'ServerSideHiglighter.getMode') * @param {mode} mode Mode loaded from /ace/mode (use 'ServerSideHiglighter.getMode')
* @param {string} r Code snippet * @param {string} r Code snippet
* @returns {object} An object containing: html, css * @returns {object} An object containing: html, css
*/ */
highlight.renderSync = function(input, mode, theme, lineStart, disableGutter) { highlight.renderSync = function(input, mode, theme, lineStart, disableGutter) {
lineStart = parseInt(lineStart || 1, 10); lineStart = parseInt(lineStart || 1, 10);

View file

@ -76,11 +76,14 @@ exports.$detectIndentation = function(lines, fallback) {
var first = {score: 0, length: 0}; var first = {score: 0, length: 0};
var spaceIndents = 0; var spaceIndents = 0;
for (var i = 1; i < 12; i++) { for (var i = 1; i < 12; i++) {
var score = getScore(i);
if (i == 1) { if (i == 1) {
spaceIndents = getScore(i); spaceIndents = score;
var score = stats.length && 1; score = stats[1] ? 0.9 : 0.8;
if (!stats.length)
score = 0
} else } else
var score = getScore(i) / spaceIndents; score /= spaceIndents;
if (changes[i]) if (changes[i])
score += changes[i] / changesTotal; score += changes[i] / changesTotal;

View file

@ -300,9 +300,12 @@ exports.handler.handleKeyboard = function(data, hashId, key, keyCode) {
if (!command) return undefined; if (!command) return undefined;
} }
if (!command.readonly && !command.isYank) if (!command.readOnly && !command.isYank)
data.lastCommand = null; data.lastCommand = null;
if (!command.readOnly && editor.emacsMark())
editor.setEmacsMark(null)
if (data.count) { if (data.count) {
var count = data.count; var count = data.count;
data.count = 0; data.count = 0;
@ -384,7 +387,7 @@ exports.emacsKeys = {
"M-y": "yankRotate", "M-y": "yankRotate",
"C-g": "keyboardQuit", "C-g": "keyboardQuit",
"C-w": "killRegion", "C-w|C-S-W": "killRegion",
"M-w": "killRingSave", "M-w": "killRingSave",
"C-Space": "setMark", "C-Space": "setMark",
"C-x C-x": "exchangePointAndMark", "C-x C-x": "exchangePointAndMark",
@ -466,7 +469,7 @@ exports.handler.addCommands({
editor.setEmacsMark(mark); editor.setEmacsMark(mark);
editor.selection.setSelectionAnchor(mark.row, mark.column); editor.selection.setSelectionAnchor(mark.row, mark.column);
}, },
readonly: true, readOnly: true,
handlesCount: true, handlesCount: true,
multiSelectAction: "forEach" multiSelectAction: "forEach"
}, },
@ -488,7 +491,7 @@ exports.handler.addCommands({
} }
sel.setSelectionRange(range, !sel.isBackwards()); sel.setSelectionRange(range, !sel.isBackwards());
}, },
readonly: true, readOnly: true,
handlesCount: true, handlesCount: true,
multiSelectAction: "forEach" multiSelectAction: "forEach"
}, },
@ -547,7 +550,7 @@ exports.handler.addCommands({
exports.killRing.add(editor.getCopyText()); exports.killRing.add(editor.getCopyText());
editor.commands.byName.cut.exec(editor); editor.commands.byName.cut.exec(editor);
}, },
readonly: true, readOnly: true,
multiSelectAction: "forEach" multiSelectAction: "forEach"
}, },
killRingSave: { killRingSave: {
@ -560,7 +563,7 @@ exports.handler.addCommands({
sel.clearSelection(); sel.clearSelection();
}, 0); }, 0);
}, },
readonly: true readOnly: true
}, },
keyboardQuit: function(editor) { keyboardQuit: function(editor) {
editor.selection.clearSelection(); editor.selection.clearSelection();

View file

@ -51,6 +51,7 @@ var TextInput = function(parentNode, host) {
text.spellcheck = false; text.spellcheck = false;
text.style.opacity = "0"; text.style.opacity = "0";
if (useragent.isOldIE) text.style.top = "-100px";
parentNode.insertBefore(text, parentNode.firstChild); parentNode.insertBefore(text, parentNode.firstChild);
var PLACEHOLDER = "\x01\x01"; var PLACEHOLDER = "\x01\x01";
@ -255,7 +256,7 @@ var TextInput = function(parentNode, host) {
} else { } else {
return clipboardData.getData(mime); return clipboardData.getData(mime);
} }
} };
var doCopy = function(e, isCut) { var doCopy = function(e, isCut) {
var data = host.getCopyText(); var data = host.getCopyText();
@ -280,11 +281,11 @@ var TextInput = function(parentNode, host) {
var onCut = function(e) { var onCut = function(e) {
doCopy(e, true); doCopy(e, true);
} };
var onCopy = function(e) { var onCopy = function(e) {
doCopy(e, false); doCopy(e, false);
} };
var onPaste = function(e) { var onPaste = function(e) {
var data = handleClipboardData(e); var data = handleClipboardData(e);
@ -335,7 +336,8 @@ var TextInput = function(parentNode, host) {
// COMPOSITION // COMPOSITION
var onCompositionStart = function(e) { var onCompositionStart = function(e) {
if (inComposition || !host.onCompositionStart) return; if (inComposition || !host.onCompositionStart || host.$readOnly)
return;
// console.log("onCompositionStart", inComposition) // console.log("onCompositionStart", inComposition)
inComposition = {}; inComposition = {};
host.onCompositionStart(); host.onCompositionStart();
@ -351,7 +353,8 @@ var TextInput = function(parentNode, host) {
var onCompositionUpdate = function() { var onCompositionUpdate = function() {
// console.log("onCompositionUpdate", inComposition && JSON.stringify(text.value)) // console.log("onCompositionUpdate", inComposition && JSON.stringify(text.value))
if (!inComposition || !host.onCompositionUpdate) return; if (!inComposition || !host.onCompositionUpdate || host.$readOnly)
return;
var val = text.value.replace(/\x01/g, ""); var val = text.value.replace(/\x01/g, "");
if (inComposition.lastValue === val) return; if (inComposition.lastValue === val) return;
@ -370,7 +373,7 @@ var TextInput = function(parentNode, host) {
}; };
var onCompositionEnd = function(e) { var onCompositionEnd = function(e) {
if (!host.onCompositionEnd) return; if (!host.onCompositionEnd || host.$readOnly) return;
// console.log("onCompositionEnd", inComposition &&inComposition.lastValue) // console.log("onCompositionEnd", inComposition &&inComposition.lastValue)
var c = inComposition; var c = inComposition;
inComposition = false; inComposition = false;
@ -379,7 +382,7 @@ var TextInput = function(parentNode, host) {
var str = text.value.replace(/\x01/g, ""); var str = text.value.replace(/\x01/g, "");
// console.log(str, c.lastValue) // console.log(str, c.lastValue)
if (inComposition) if (inComposition)
return return;
else if (str == c.lastValue) else if (str == c.lastValue)
resetValue(); resetValue();
else if (!c.lastValue && str) { else if (!c.lastValue && str) {
@ -428,18 +431,25 @@ var TextInput = function(parentNode, host) {
this.onContextMenu = function(e) { this.onContextMenu = function(e) {
afterContextMenu = true; afterContextMenu = true;
if (!tempStyle)
tempStyle = text.style.cssText;
text.style.cssText = "z-index:100000;" + (useragent.isIE ? "opacity:0.1;" : "");
resetSelection(host.selection.isEmpty()); resetSelection(host.selection.isEmpty());
host._emit("nativecontextmenu", {target: host, domEvent: e}); 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;" : "");
var rect = host.container.getBoundingClientRect(); var rect = host.container.getBoundingClientRect();
var style = dom.computedStyle(host.container); var style = dom.computedStyle(host.container);
var top = rect.top + (parseInt(style.borderTopWidth) || 0); var top = rect.top + (parseInt(style.borderTopWidth) || 0);
var left = rect.left + (parseInt(rect.borderLeftWidth) || 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) { var move = function(e) {
text.style.left = e.clientX - left - 2 + "px"; text.style.left = e.clientX - left - 2 + "px";
text.style.top = Math.min(e.clientY - top - 2, maxTop) + "px"; text.style.top = Math.min(e.clientY - top - 2, maxTop) + "px";
@ -453,13 +463,15 @@ var TextInput = function(parentNode, host) {
host.renderer.$keepTextAreaAtCursor = null; host.renderer.$keepTextAreaAtCursor = null;
// on windows context menu is opened after mouseup // on windows context menu is opened after mouseup
if (useragent.isWin) if (useragent.isWin && !useragent.isOldIE)
event.capture(host.container, move, onContextMenuClose); event.capture(host.container, move, onContextMenuClose);
}; };
this.onContextMenuClose = onContextMenuClose; this.onContextMenuClose = onContextMenuClose;
var closeTimeout;
function onContextMenuClose() { function onContextMenuClose() {
setTimeout(function () { clearTimeout(closeTimeout)
closeTimeout = setTimeout(function () {
if (tempStyle) { if (tempStyle) {
text.style.cssText = tempStyle; text.style.cssText = tempStyle;
tempStyle = ''; tempStyle = '';
@ -468,18 +480,15 @@ var TextInput = function(parentNode, host) {
host.renderer.$keepTextAreaAtCursor = true; host.renderer.$keepTextAreaAtCursor = true;
host.renderer.$moveTextAreaToCursor(); host.renderer.$moveTextAreaToCursor();
} }
}, 0); }, useragent.isOldIE ? 200 : 0);
} }
// firefox fires contextmenu event after opening it
if (!useragent.isGecko || useragent.isMac) {
var onContextMenu = function(e) { var onContextMenu = function(e) {
host.textInput.onContextMenu(e); host.textInput.onContextMenu(e);
onContextMenuClose(); onContextMenuClose();
}; };
event.addListener(host.renderer.scroller, "contextmenu", onContextMenu); event.addListener(host.renderer.scroller, "contextmenu", onContextMenu);
event.addListener(text, "contextmenu", onContextMenu); event.addListener(text, "contextmenu", onContextMenu);
}
}; };
exports.TextInput = TextInput; exports.TextInput = TextInput;

View file

@ -426,7 +426,7 @@ module.exports = {
var column = util.getRightNthChar(editor, cursor, param, count || 1); var column = util.getRightNthChar(editor, cursor, param, count || 1);
if (isRepeat && column == 0 && !(count > 1)) if (isRepeat && column == 0 && !(count > 1))
var column = util.getRightNthChar(editor, cursor, param, 2); column = util.getRightNthChar(editor, cursor, param, 2);
if (typeof column === "number") { if (typeof column === "number") {
cursor.column += column + (isSel ? 1 : 0); cursor.column += column + (isSel ? 1 : 0);
@ -444,8 +444,8 @@ module.exports = {
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
var column = util.getLeftNthChar(editor, cursor, param, count || 1); var column = util.getLeftNthChar(editor, cursor, param, count || 1);
if (isRepeat && column == 0 && !(count > 1)) if (isRepeat && column === 0 && !(count > 1))
var column = util.getLeftNthChar(editor, cursor, param, 2); column = util.getLeftNthChar(editor, cursor, param, 2);
if (typeof column === "number") { if (typeof column === "number") {
cursor.column -= column; cursor.column -= column;
@ -558,7 +558,7 @@ module.exports = {
content += "\n"; content += "\n";
if (content.length) { if (content.length) {
editor.navigateLineEnd() editor.navigateLineEnd();
editor.insert(content); editor.insert(content);
util.insertMode(editor); util.insertMode(editor);
} }
@ -575,7 +575,7 @@ module.exports = {
if (content.length) { if (content.length) {
if(row > 0) { if(row > 0) {
editor.navigateUp(); editor.navigateUp();
editor.navigateLineEnd() editor.navigateLineEnd();
editor.insert(content); editor.insert(content);
} else { } else {
editor.session.insert({row: 0, column: 0}, content); editor.session.insert({row: 0, column: 0}, content);

View file

@ -74,7 +74,7 @@ var FontMetrics = exports.FontMetrics = function(parentEl, interval) {
document.documentElement.appendChild(el); document.documentElement.appendChild(el);
var w = el.getBoundingClientRect().width; var w = el.getBoundingClientRect().width;
if (w > 0 && w < 1) if (w > 0 && w < 1)
CHAR_COUNT = 1; CHAR_COUNT = 50;
else else
CHAR_COUNT = 100; CHAR_COUNT = 100;
el.parentNode.removeChild(el); el.parentNode.removeChild(el);
@ -127,11 +127,16 @@ var FontMetrics = exports.FontMetrics = function(parentEl, interval) {
}; };
this.$measureSizes = function() { this.$measureSizes = function() {
if (CHAR_COUNT === 1) { if (CHAR_COUNT === 50) {
var rect = this.$measureNode.getBoundingClientRect(); var rect = null;
try {
rect = this.$measureNode.getBoundingClientRect();
} catch(e) {
rect = {width: 0, height:0 };
};
var size = { var size = {
height: rect.height, height: rect.height,
width: rect.width width: rect.width / CHAR_COUNT
}; };
} else { } else {
var size = { var size = {

View file

@ -58,6 +58,7 @@ var Gutter = function(parentEl) {
if (this.session) if (this.session)
this.session.removeEventListener("change", this.$updateAnnotations); this.session.removeEventListener("change", this.$updateAnnotations);
this.session = session; this.session = session;
if (session)
session.on("change", this.$updateAnnotations); session.on("change", this.$updateAnnotations);
}; };

View file

@ -93,7 +93,7 @@ var Marker = function(parentEl) {
this.drawSingleLineMarker(html, range, marker.clazz + " ace_start", config); this.drawSingleLineMarker(html, range, marker.clazz + " ace_start", config);
} }
} }
this.element = dom.setInnerHtml(this.element, html.join("")); this.element.innerHTML = html.join("");
}; };
this.$getTop = function(row, layerConfig) { this.$getTop = function(row, layerConfig) {

View file

@ -95,6 +95,7 @@ var Text = function(parentEl) {
}; };
this.setSession = function(session) { this.setSession = function(session) {
this.session = session; this.session = session;
if (session)
this.$computeTabString(); this.$computeTabString();
}; };
@ -203,7 +204,7 @@ var Text = function(parentEl) {
html, row, !this.$useLineGroups(), row == foldStart ? foldLine : false html, row, !this.$useLineGroups(), row == foldStart ? foldLine : false
); );
lineElement.style.height = config.lineHeight * this.session.getRowLength(row) + "px"; lineElement.style.height = config.lineHeight * this.session.getRowLength(row) + "px";
dom.setInnerHtml(lineElement, html.join("")); lineElement.innerHTML = html.join("");
} }
row++; row++;
} }
@ -310,7 +311,7 @@ var Text = function(parentEl) {
row++; row++;
} }
this.element = dom.setInnerHtml(this.element, html.join("")); this.element.innerHTML = html.join("");
}; };
this.$textToken = { this.$textToken = {
@ -321,7 +322,7 @@ var Text = function(parentEl) {
this.$renderToken = function(stringBuilder, screenColumn, token, value) { this.$renderToken = function(stringBuilder, screenColumn, token, value) {
var self = this; 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) { var replaceFunc = function(c, a, b, tabIdx, idx4) {
if (a) { if (a) {
return self.showInvisibles ? return self.showInvisibles ?

View file

@ -49,7 +49,7 @@ exports.createElement = function(tag, ns) {
}; };
exports.hasCssClass = function(el, name) { exports.hasCssClass = function(el, name) {
var classes = el.className.split(/\s+/g); var classes = (el.className || "").split(/\s+/g);
return classes.indexOf(name) !== -1; return classes.indexOf(name) !== -1;
}; };

View file

@ -192,6 +192,8 @@ exports.addMultiMouseDownListener = function(el, timeouts, eventHandler, callbac
} }
} }
e._clicks = clicks;
eventHandler[callbackName]("mousedown", e); eventHandler[callbackName]("mousedown", e);
if (clicks > 4) if (clicks > 4)
@ -237,7 +239,7 @@ function normalizeCommandKeys(callback, e, keyCode) {
return; return;
} }
if (keyCode === 18 || keyCode === 17) { if (keyCode === 18 || keyCode === 17) {
var location = e.location || e.keyLocation; var location = "location" in e ? e.location : e.keyLocation;
if (keyCode === 17 && location === 1) { if (keyCode === 17 && location === 1) {
ts = e.timeStamp; ts = e.timeStamp;
} else if (keyCode === 18 && hashId === 3 && location === 2) { } else if (keyCode === 18 && hashId === 3 && location === 2) {
@ -273,7 +275,8 @@ function normalizeCommandKeys(callback, e, keyCode) {
} }
if (!hashId && keyCode === 13) { if (!hashId && keyCode === 13) {
if (e.location || e.keyLocation === 3) { var location = "location" in e ? e.location : e.keyLocation;
if (location === 3) {
callback(e, hashId, -keyCode); callback(e, hashId, -keyCode);
if (e.defaultPrevented) if (e.defaultPrevented)
return; return;

View file

@ -34,6 +34,8 @@ For more information about SproutCore, visit http://www.sproutcore.com
define(function(require, exports, module) { define(function(require, exports, module) {
"use strict"; "use strict";
require("./fixoldbrowsers");
var oop = require("./oop"); var oop = require("./oop");
/* /*

View file

@ -42,6 +42,7 @@ class Foo extends Bar
foo.static.function foo.static.function
#!test tokenize string with interpolation #!test tokenize string with interpolation
a = "#{ 22 / 7 + {x: "#{a + b}"} + 2}" a = "#{ 22 / 7 + {x: "#{a + b}"} + 2}"
" #{ "" + {} } )"
"""heredoc """heredoc
""" """
do -> do ->

View file

@ -0,0 +1,24 @@
<?php
function nfact($n) {
if ($n == 0) {
return 1;
}
else {
return $n * nfact($n - 1);
}
}
echo "\n\nPlease enter a whole number ... ";
$num = trim(fgets(STDIN));
// ===== PROCESS - Determing the factorial of the input number =====
$output = "\n\nFactorial " . $num . " = " . nfact($num) . "\n\n";
echo $output;
?> <script> <?php
echo '
';
?>
/*this is js <?php echo ':)'; ?>
</script> not &js;

View file

@ -466,6 +466,23 @@
["constant.numeric","2"], ["constant.numeric","2"],
["paren.string","}"], ["paren.string","}"],
["string.end","\""] ["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", "qqdoc",
["string","\"\"\"heredoc"] ["string","\"\"\"heredoc"]

View file

@ -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"
]]

View file

@ -288,9 +288,9 @@
["string.regexp.charachterclass","r"], ["string.regexp.charachterclass","r"],
["constant.language.escape","-"], ["constant.language.escape","-"],
["string.regexp.charachterclass","o"], ["string.regexp.charachterclass","o"],
["regexp.keyword.operator","\\f\\f"], ["regexp.charclass.keyword.operator","\\f\\f"],
["string.regexp.charachterclass","["], ["string.regexp.charachterclass","["],
["regexp.keyword.operator","\\f"], ["regexp.charclass.keyword.operator","\\f"],
["constant.language.escape","]?"], ["constant.language.escape","]?"],
["string.regexp","r"], ["string.regexp","r"],
["invalid","{7}+"], ["invalid","{7}+"],
@ -379,7 +379,7 @@
["constant.numeric","1."], ["constant.numeric","1."],
["text","00"], ["text","00"],
["identifier","E"], ["identifier","E"],
["text","^"], ["keyword.operator","^"],
["constant.numeric","1"], ["constant.numeric","1"],
["punctuation.operator",","], ["punctuation.operator",","],
["text"," "], ["text"," "],

View file

@ -2,37 +2,37 @@
"start", "start",
["keyword","\\usepackage"], ["keyword","\\usepackage"],
["lparen","{"], ["lparen","{"],
["text","amsmath"], ["storage.type","amsmath"],
["rparen","}"] ["rparen","}"]
],[ ],[
"start", "start",
["keyword","\\title"], ["storage.type","\\title"],
["lparen","{"], ["lparen","{"],
["keyword","\\LaTeX"], ["storage.type","\\LaTeX"],
["rparen","}"] ["rparen","}"]
],[ ],[
"start", "start",
["keyword","\\date"], ["storage.type","\\date"],
["lparen","{"], ["lparen","{"],
["rparen","}"] ["rparen","}"]
],[ ],[
"start", "start",
["keyword","\\begin"], ["storage.type","\\begin"],
["lparen","{"], ["lparen","{"],
["text","document"], ["variable.parameter","document"],
["rparen","}"] ["rparen","}"]
],[ ],[
"start", "start",
["text"," "], ["text"," "],
["keyword","\\maketitle"] ["storage.type","\\maketitle"]
],[ ],[
"start", "start",
["text"," "], ["text"," "],
["keyword","\\LaTeX"], ["storage.type","\\LaTeX"],
["lparen","{"], ["lparen","{"],
["rparen","}"], ["rparen","}"],
["text"," is a document preparation system for the "], ["text"," is a document preparation system for the "],
["keyword","\\TeX"], ["storage.type","\\TeX"],
["lparen","{"], ["lparen","{"],
["rparen","}"] ["rparen","}"]
],[ ],[
@ -50,26 +50,26 @@
],[ ],[
"start", "start",
["text"," and much more. "], ["text"," and much more. "],
["keyword","\\LaTeX"], ["storage.type","\\LaTeX"],
["lparen","{"], ["lparen","{"],
["rparen","}"], ["rparen","}"],
["text"," was originally written in 1984 by Leslie"] ["text"," was originally written in 1984 by Leslie"]
],[ ],[
"start", "start",
["text"," Lamport and has become the dominant method for using "], ["text"," Lamport and has become the dominant method for using "],
["keyword","\\TeX"], ["storage.type","\\TeX"],
["text","; few"] ["text","; few"]
],[ ],[
"start", "start",
["text"," people write in plain "], ["text"," people write in plain "],
["keyword","\\TeX"], ["storage.type","\\TeX"],
["lparen","{"], ["lparen","{"],
["rparen","}"], ["rparen","}"],
["text"," anymore. The current version is"] ["text"," anymore. The current version is"]
],[ ],[
"start", "start",
["text"," "], ["text"," "],
["keyword","\\LaTeXe"], ["storage.type","\\LaTeXe"],
["text","."] ["text","."]
],[ ],[
"start", "start",
@ -85,26 +85,26 @@
],[ ],[
"start", "start",
["text"," "], ["text"," "],
["keyword","\\begin"], ["storage.type","\\begin"],
["lparen","{"], ["lparen","{"],
["text","align"], ["variable.parameter","align"],
["rparen","}"] ["rparen","}"]
],[ ],[
"start", "start",
["text"," E &= mc^2 "], ["text"," E &= mc^2 "],
["keyword","\\\\"] ["constant.character.escape","\\\\"]
],[ ],[
"start", "start",
["text"," m &= "], ["text"," m &= "],
["keyword","\\frac"], ["storage.type","\\frac"],
["lparen","{"], ["lparen","{"],
["text","m_0"], ["text","m_0"],
["rparen","}"], ["rparen","}"],
["lparen","{"], ["lparen","{"],
["keyword","\\sqrt"], ["storage.type","\\sqrt"],
["lparen","{"], ["lparen","{"],
["text","1-"], ["text","1-"],
["keyword","\\frac"], ["storage.type","\\frac"],
["lparen","{"], ["lparen","{"],
["text","v^2"], ["text","v^2"],
["rparen","}"], ["rparen","}"],
@ -114,14 +114,14 @@
],[ ],[
"start", "start",
["text"," "], ["text"," "],
["keyword","\\end"], ["storage.type","\\end"],
["lparen","{"], ["lparen","{"],
["text","align"], ["variable.parameter","align"],
["rparen","}"] ["rparen","}"]
],[ ],[
"start", "start",
["keyword","\\end"], ["storage.type","\\end"],
["lparen","{"], ["lparen","{"],
["text","document"], ["variable.parameter","document"],
["rparen","}"] ["rparen","}"]
]] ]]

View file

@ -129,6 +129,43 @@
],[ ],[
"php-start" "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","<?php"]
],[
["#tmp","php-qstring","php-start","js-start"],
["support.function","echo"],
["text"," "],
["string","'"]
],[
["php-start","js-start"],
["string","'"],
["text",";"]
],[
"js-start",
["support.php_tag","?>"] ["support.php_tag","?>"]
],[
"js-comment_regex_allowed",
["comment","/*this is js "],
["support.php_tag","<?php"],
["text"," "],
["support.function","echo"],
["text"," "],
["string","':)'"],
["text","; "],
["support.php_tag","?>"]
],[
"start",
["meta.tag.punctuation.end-tag-open.xml","</"],
["meta.tag.script.tag-name.xml","script"],
["meta.tag.punctuation.tag-close.xml",">"],
["text.xml"," not "],
["constant.language.escape.reference.xml","&js;"]
],[
"start"
]] ]]

View file

@ -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<string[](), MyBar<string, int>>"],
["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","}"]
]]

View file

@ -1,44 +0,0 @@
[[
"[\"start\"]",
["keyword","xquery"],
["text"," "],
["keyword","version"],
["text"," "],
["string","\""],
["string","1.0"],
["string","\""],
["text",";"]
],[
"[\"start\"]"
],[
"[\"start\"]",
["keyword","let"],
["text"," "],
["variable","$message"],
["text"," "],
["keyword.operator",":="],
["text"," "],
["string","\""],
["string","Hello World!"],
["string","\""]
],[
"[\"start\",\"StartTag\",\"TagContent\"]",
["keyword","return"],
["text"," "],
["meta.tag","<results"],
["meta.tag",">"]
],[
"[\"start\",\"StartTag\",\"TagContent\"]",
["text"," "],
["meta.tag","<message"],
["meta.tag",">"],
["text","{"],
["variable","$message"],
["text","}"],
["meta.tag","</message>"]
],[
"[\"start\"]",
["meta.tag","</results>"]
],[
"[\"start\"]"
]]

View file

@ -22,8 +22,9 @@ var c_cppHighlightRules = function() {
); );
var storageModifiers = ( var storageModifiers = (
"const|extern|register|restrict|static|volatile|inline|private:|" + "const|extern|register|restrict|static|volatile|inline|private|" +
"protected:|public:|friend|explicit|virtual|export|mutable|typename" "protected|public|friend|explicit|virtual|export|mutable|typename|" +
"constexpr|new|delete"
); );
var keywordOperators = ( var keywordOperators = (

File diff suppressed because it is too large Load diff

View file

@ -40,8 +40,11 @@ var Worker = exports.Worker = function(sender) {
Mirror.call(this, sender); Mirror.call(this, sender);
this.setTimeout(400); this.setTimeout(400);
this.ruleset = null; this.ruleset = null;
this.setDisabledRules("ids"); this.setDisabledRules("ids|order-alphabetical");
this.setInfoRules("adjoining-classes|qualified-headings|zero-units|gradients|import|outline-none"); this.setInfoRules(
"adjoining-classes|qualified-headings|zero-units|gradients|" +
"import|outline-none|vendor-prefix"
);
}; };
oop.inherits(Worker, Mirror); oop.inherits(Worker, Mirror);

View file

@ -54,7 +54,7 @@ var DartHighlightRules = function() {
}, },
{ {
token: "keyword.other.import.dart", token: "keyword.other.import.dart",
regex: "(?:\\b)(?:library|import|export|part|of)(?:\\b)" regex: "(?:\\b)(?:library|import|export|part|of|show|hide)(?:\\b)"
}, },
{ {
token : ["keyword.other.import.dart", "text"], token : ["keyword.other.import.dart", "text"],

View file

@ -41,7 +41,7 @@ var DockerfileHighlightRules = function() {
for (var i = 0; i < startRules.length; i++) { for (var i = 0; i < startRules.length; i++) {
if (startRules[i].token == "variable.language") { if (startRules[i].token == "variable.language") {
startRules.splice(i, 0, { startRules.splice(i, 0, {
token: "variable.language", token: "constant.language",
regex: "(?:^(?:FROM|MAINTAINER|RUN|CMD|EXPOSE|ENV|ADD|ENTRYPOINT|VOLUME|USER|WORKDIR|ONBUILD)\\b)", regex: "(?:^(?:FROM|MAINTAINER|RUN|CMD|EXPOSE|ENV|ADD|ENTRYPOINT|VOLUME|USER|WORKDIR|ONBUILD)\\b)",
caseInsensitive: true caseInsensitive: true
}); });

52
lib/ace/mode/eiffel.js Normal file
View file

@ -0,0 +1,52 @@
/* ***** 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 EiffelHighlightRules = require("./eiffel_highlight_rules").EiffelHighlightRules;
var Range = require("../range").Range;
var Mode = function() {
this.HighlightRules = EiffelHighlightRules;
};
oop.inherits(Mode, TextMode);
(function() {
this.lineCommentStart = "--";
this.$id = "ace/mode/eiffel";
}).call(Mode.prototype);
exports.Mode = Mode;
});

View file

@ -0,0 +1,143 @@
/* ***** 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;
var EiffelHighlightRules = function() {
var keywords = "across|agent|alias|all|attached|as|assign|attribute|check|" +
"class|convert|create|debug|deferred|detachable|do|else|elseif|end|" +
"ensure|expanded|export|external|feature|from|frozen|if|inherit|" +
"inspect|invariant|like|local|loop|not|note|obsolete|old|once|" +
"Precursor|redefine|rename|require|rescue|retry|select|separate|" +
"some|then|undefine|until|variant|when";
var operatorKeywords = "and|implies|or|xor";
var languageConstants = "Void";
var booleanConstants = "True|False";
var languageVariables = "Current|Result";
var keywordMapper = this.createKeywordMapper({
"constant.language": languageConstants,
"constant.language.boolean": booleanConstants,
"variable.language": languageVariables,
"keyword.operator": operatorKeywords,
"keyword": keywords
}, "identifier", true);
this.$rules = {
"start": [{
token : "comment.line.double-dash",
regex : /--.*$/
}, {
token : "string.quoted.double",
regex : /"(?:%"|[^%])*?"/
}, {
token : "string.quoted.other", // "[ ]" aligned verbatim string
regex : /"\[/,
next: "aligned_verbatim_string"
}, {
token : "string.quoted.other", // "{ }" non-aligned verbatim string
regex : /"\{/,
next: "non-aligned_verbatim_string"
}, {
token : "constant.character",
regex : /'(?:%%|%T|%R|%N|%F|%'|[^%])'/
}, {
token : "constant.numeric", // real
regex : /(?:\d(?:_?\d)*\.|\.\d)(?:\d*[eE][+-]?\d+)?\b/
}, {
token : "constant.numeric", // integer
regex : /\d(?:_?\d)*\b/
}, {
token : "constant.numeric", // hex
regex : /0[xX][a-fA-F\d](?:_?[a-fA-F\d])*\b/
}, {
token : "constant.numeric", // octal
regex : /0[cC][0-7](?:_?[0-7])*\b/
},{
token : "constant.numeric", // bin
regex : /0[bB][01](?:_?[01])*\b/
}, {
token : "keyword.operator",
regex : /\+|\-|\*|\/|\\\\|\/\/|\^|~|\/~|<|>|<=|>=|\/=|=|:=|\|\.\.\||\.\./
}, {
token : "keyword.operator", // punctuation
regex : /\.|:|,|;\b/
}, {
token : function (v) {
var result = keywordMapper (v);
if (result === "identifier" && v === v.toUpperCase ()) {
result = "entity.name.type";
}
return result;
},
regex : /[a-zA-Z][a-zA-Z\d_]*\b/
}, {
token : "paren.lparen",
regex : /[\[({]/
}, {
token : "paren.rparen",
regex : /[\])}]/
}, {
token : "text",
regex : /\s+/
}
],
"aligned_verbatim_string" : [{
token : "string", // closing multi-line comment
regex : /]"/,
next : "start"
}, {
token : "string", // comment spanning whole line
regex : /[^(?:\]")]+/
}
],
"non-aligned_verbatim_string" : [{
token : "string.quoted.other", // closing multi-line comment
regex : /}"/,
next : "start"
}, {
token : "string.quoted.other", // comment spanning whole line
regex : /[^(?:\}")]+/
}
]};
};
oop.inherits(EiffelHighlightRules, TextHighlightRules);
exports.EiffelHighlightRules = EiffelHighlightRules;
});

View file

@ -145,9 +145,9 @@ module.exports = {
session.setFoldStyle("markbeginend"); session.setFoldStyle("markbeginend");
assert.equal(session.getFoldWidget(0), "start"); assert.equal(session.getFoldWidget(0), "start");
assert.equal(session.getFoldWidget(1), ""); assert.equal(session.getFoldWidget(1), "start");
assert.equal(session.getFoldWidget(2), ""); assert.equal(session.getFoldWidget(2), "");
assert.equal(session.getFoldWidget(3), ""); assert.equal(session.getFoldWidget(3), "start");
assert.equal(session.getFoldWidget(4), ""); assert.equal(session.getFoldWidget(4), "");
assert.equal(session.getFoldWidget(5), "end"); assert.equal(session.getFoldWidget(5), "end");

View file

@ -42,7 +42,7 @@ oop.inherits(FoldMode, BaseFoldMode);
(function() { (function() {
this.foldingStartMarker = /^\s*\\(begin)|(section|subsection)\b|{\s*$/; this.foldingStartMarker = /^\s*\\(begin)|(section|subsection|paragraph)\b|{\s*$/;
this.foldingStopMarker = /^\s*\\(end)\b|^\s*}/; this.foldingStopMarker = /^\s*\\(end)\b|^\s*}/;
this.getFoldWidgetRange = function(session, foldStyle, row) { this.getFoldWidgetRange = function(session, foldStyle, row) {
@ -74,7 +74,7 @@ oop.inherits(FoldMode, BaseFoldMode);
var stream = new TokenIterator(session, row, column); var stream = new TokenIterator(session, row, column);
var token = stream.getCurrentToken(); var token = stream.getCurrentToken();
if (!token || token.type !== "keyword") if (!token || !(token.type == "storage.type" || token.type == "constant.character.escape"))
return; return;
var val = token.value; var val = token.value;
@ -96,7 +96,7 @@ oop.inherits(FoldMode, BaseFoldMode);
stream.step = dir === -1 ? stream.stepBackward : stream.stepForward; stream.step = dir === -1 ? stream.stepBackward : stream.stepForward;
while(token = stream.step()) { while(token = stream.step()) {
if (token.type !== "keyword") if (!token || !(token.type == "storage.type" || token.type == "constant.character.escape"))
continue; continue;
var level = keywords[token.value]; var level = keywords[token.value];
if (!level) if (!level)
@ -119,11 +119,11 @@ oop.inherits(FoldMode, BaseFoldMode);
}; };
this.latexSection = function(session, row, column) { this.latexSection = function(session, row, column) {
var keywords = ["\\subsection", "\\section", "\\begin", "\\end"]; var keywords = ["\\subsection", "\\section", "\\begin", "\\end", "\\paragraph"];
var stream = new TokenIterator(session, row, column); var stream = new TokenIterator(session, row, column);
var token = stream.getCurrentToken(); var token = stream.getCurrentToken();
if (!token || token.type != "keyword") if (!token || token.type != "storage.type")
return; return;
var startLevel = keywords.indexOf(token.value); var startLevel = keywords.indexOf(token.value);
@ -131,7 +131,7 @@ oop.inherits(FoldMode, BaseFoldMode);
var endRow = row; var endRow = row;
while(token = stream.stepForward()) { while(token = stream.stepForward()) {
if (token.type !== "keyword") if (token.type !== "storage.type")
continue; continue;
var level = keywords.indexOf(token.value); var level = keywords.indexOf(token.value);

View file

@ -39,8 +39,11 @@ var TokenIterator = require("../../token_iterator").TokenIterator;
var FoldMode = exports.FoldMode = function(voidElements, optionalEndTags) { var FoldMode = exports.FoldMode = function(voidElements, optionalEndTags) {
BaseFoldMode.call(this); BaseFoldMode.call(this);
// TODO folding support for optional end tags this.voidElements = voidElements || {};
this.voidElements = oop.mixin(voidElements || {}, optionalEndTags || {}); this.optionalEndTags = oop.mixin({}, this.voidElements);
if (optionalEndTags)
oop.mixin(this.optionalEndTags, optionalEndTags);
}; };
oop.inherits(FoldMode, BaseFoldMode); oop.inherits(FoldMode, BaseFoldMode);
@ -189,10 +192,10 @@ function is(token, type) {
if (!tag || top.tagName == tag.tagName) { if (!tag || top.tagName == tag.tagName) {
return stack.pop(); return stack.pop();
} }
else if (this.voidElements.hasOwnProperty(tag.tagName)) { else if (this.optionalEndTags.hasOwnProperty(tag.tagName)) {
return; return;
} }
else if (this.voidElements.hasOwnProperty(top.tagName)) { else if (this.optionalEndTags.hasOwnProperty(top.tagName)) {
stack.pop(); stack.pop();
continue; continue;
} else { } else {

51
lib/ace/mode/gcode.js Normal file
View file

@ -0,0 +1,51 @@
/* ***** 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 TextMode = require("./text").Mode;
var GcodeHighlightRules = require("./gcode_highlight_rules").GcodeHighlightRules;
var Range = require("../range").Range;
var Mode = function() {
this.HighlightRules = GcodeHighlightRules;
};
oop.inherits(Mode, TextMode);
(function() {
this.$id = "ace/mode/gcode";
}).call(Mode.prototype);
exports.Mode = Mode;
});

View file

@ -0,0 +1,94 @@
/* ***** 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 GcodeHighlightRules = function() {
var keywords = (
"IF|DO|WHILE|ENDWHILE|CALL|ENDIF|SUB|ENDSUB|GOTO|REPEAT|ENDREPEAT|CALL"
);
var builtinConstants = (
"PI"
);
var builtinFunctions = (
"ATAN|ABS|ACOS|ASIN|SIN|COS|EXP|FIX|FUP|ROUND|LN|TAN"
);
var keywordMapper = this.createKeywordMapper({
"support.function": builtinFunctions,
"keyword": keywords,
"constant.language": builtinConstants
}, "identifier", true);
this.$rules = {
"start" : [ {
token : "comment",
regex : "\\(.*\\)"
}, {
token : "comment", // block number
regex : "([N])([0-9]+)"
}, {
token : "string", // " string
regex : "([G])([0-9]+\\.?[0-9]?)"
}, {
token : "string", // ' string
regex : "([M])([0-9]+\\.?[0-9]?)"
}, {
token : "constant.numeric", // float
regex : "([-+]?([0-9]*\\.?[0-9]+\\.?))|(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)"
}, {
token : keywordMapper,
regex : "[A-Z]"
}, {
token : "keyword.operator",
regex : "EQ|LT|GT|NE|GE|LE|OR|XOR"
}, {
token : "paren.lparen",
regex : "[\\[]"
}, {
token : "paren.rparen",
regex : "[\\]]"
}, {
token : "text",
regex : "\\s+"
} ]
};
};
oop.inherits(GcodeHighlightRules, TextHighlightRules);
exports.GcodeHighlightRules = GcodeHighlightRules;
});

19
lib/ace/mode/gitignore.js Normal file
View file

@ -0,0 +1,19 @@
define(function(require, exports, module) {
"use strict";
var oop = require("../lib/oop");
var TextMode = require("./text").Mode;
var GitignoreHighlightRules = require("./gitignore_highlight_rules").GitignoreHighlightRules;
var Mode = function() {
this.HighlightRules = GitignoreHighlightRules;
};
oop.inherits(Mode, TextMode);
(function() {
this.$id = "ace/mode/gitignore";
}).call(Mode.prototype);
exports.Mode = Mode;
});

View file

@ -0,0 +1,31 @@
define(function(require, exports, module) {
"use strict";
var oop = require("../lib/oop");
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
var GitignoreHighlightRules = function() {
this.$rules = {
"start" : [
{
token : "comment",
regex : /^\s*#.*$/
}, {
token : "keyword", // negated patterns
regex : /^\s*!.*$/
}
]
};
this.normalizeRules();
};
GitignoreHighlightRules.metaData = {
fileTypes: ['gitignore'],
name: 'Gitignore'
};
oop.inherits(GitignoreHighlightRules, TextHighlightRules);
exports.GitignoreHighlightRules = GitignoreHighlightRules;
});

View file

@ -43,7 +43,7 @@ var HtmlCompletions = require("./html_completions").HtmlCompletions;
var WorkerClient = require("../worker/worker_client").WorkerClient; var WorkerClient = require("../worker/worker_client").WorkerClient;
// http://www.w3.org/TR/html5/syntax.html#void-elements // http://www.w3.org/TR/html5/syntax.html#void-elements
var voidElements = ["area", "base", "br", "col", "embed", "hr", "img", "input", "keygen", "link", "meta", "param", "source", "track", "wbr"]; var voidElements = ["area", "base", "br", "col", "embed", "hr", "img", "input", "keygen", "link", "meta", "menuitem", "param", "source", "track", "wbr"];
var optionalEndTags = ["li", "dt", "dd", "p", "rt", "rp", "optgroup", "option", "colgroup", "td", "th"]; var optionalEndTags = ["li", "dt", "dd", "p", "rt", "rp", "optgroup", "option", "colgroup", "td", "th"];
var Mode = function(options) { var Mode = function(options) {

58
lib/ace/mode/io.js Normal file
View file

@ -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 Tokenizer = require("../tokenizer").Tokenizer;
var IoHighlightRules = require("./io_highlight_rules").IoHighlightRules;
var FoldMode = require("./folding/cstyle").FoldMode;
var Mode = function() {
this.HighlightRules = IoHighlightRules;
this.foldingRules = new FoldMode();
};
oop.inherits(Mode, TextMode);
(function() {
this.lineCommentStart = "//";
this.blockComment = {start: "/*", end: "*/"};
// Extra logic goes here.
this.$id = "ace/mode/io"
}).call(Mode.prototype);
exports.Mode = Mode;
});

View file

@ -0,0 +1,120 @@
/* ***** 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 tm bundles\io.tmbundle/Syntaxes/io.plist (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 IoHighlightRules = function() {
// regexp must not have capturing parentheses. Use (?:) instead.
// regexps are ordered -> the first match is used
this.$rules = { start:
[ { token: [ 'text', 'meta.empty-parenthesis.io' ],
regex: '(\\()(\\))',
comment: 'we match this to overload return inside () --Allan; scoping rules for what gets the scope have changed, so we now group the ) instead of the ( -- Rob' },
{ token: [ 'text', 'meta.comma-parenthesis.io' ],
regex: '(\\,)(\\))',
comment: 'We want to do the same for ,) -- Seckar; same as above -- Rob' },
{ token: 'keyword.control.io',
regex: '\\b(?:if|ifTrue|ifFalse|ifTrueIfFalse|for|loop|reverseForeach|foreach|map|continue|break|while|do|return)\\b' },
{ token: 'punctuation.definition.comment.io',
regex: '/\\*',
push:
[ { token: 'punctuation.definition.comment.io',
regex: '\\*/',
next: 'pop' },
{ defaultToken: 'comment.block.io' } ] },
{ token: 'punctuation.definition.comment.io',
regex: '//',
push:
[ { token: 'comment.line.double-slash.io',
regex: '$',
next: 'pop' },
{ defaultToken: 'comment.line.double-slash.io' } ] },
{ token: 'punctuation.definition.comment.io',
regex: '#',
push:
[ { token: 'comment.line.number-sign.io', regex: '$', next: 'pop' },
{ defaultToken: 'comment.line.number-sign.io' } ] },
{ token: 'variable.language.io',
regex: '\\b(?:self|sender|target|proto|protos|parent)\\b',
comment: 'I wonder if some of this isn\'t variable.other.language? --Allan; scoping this as variable.language to match Objective-C\'s handling of \'self\', which is inconsistent with C++\'s handling of \'this\' but perhaps intentionally so -- Rob' },
{ token: 'keyword.operator.io',
regex: '<=|>=|=|:=|\\*|\\||\\|\\||\\+|-|/|&|&&|>|<|\\?|@|@@|\\b(?:and|or)\\b' },
{ token: 'constant.other.io', regex: '\\bGL[\\w_]+\\b' },
{ token: 'support.class.io', regex: '\\b[A-Z](?:\\w+)?\\b' },
{ token: 'support.function.io',
regex: '\\b(?:clone|call|init|method|list|vector|block|\\w+(?=\\s*\\())\\b' },
{ token: 'support.function.open-gl.io',
regex: '\\bgl(?:u|ut)?[A-Z]\\w+\\b' },
{ token: 'punctuation.definition.string.begin.io',
regex: '"""',
push:
[ { token: 'punctuation.definition.string.end.io',
regex: '"""',
next: 'pop' },
{ token: 'constant.character.escape.io', regex: '\\\\.' },
{ defaultToken: 'string.quoted.triple.io' } ] },
{ token: 'punctuation.definition.string.begin.io',
regex: '"',
push:
[ { token: 'punctuation.definition.string.end.io',
regex: '"',
next: 'pop' },
{ token: 'constant.character.escape.io', regex: '\\\\.' },
{ defaultToken: 'string.quoted.double.io' } ] },
{ token: 'constant.numeric.io',
regex: '\\b(?:0(?:x|X)[0-9a-fA-F]*|(?:[0-9]+\\.?[0-9]*|\\.[0-9]+)(?:(?:e|E)(?:\\+|-)?[0-9]+)?)(?:L|l|UL|ul|u|U|F|f)?\\b' },
{ token: 'variable.other.global.io', regex: 'Lobby\\b' },
{ token: 'constant.language.io',
regex: '\\b(?:TRUE|true|FALSE|false|NULL|null|Null|Nil|nil|YES|NO)\\b' } ] }
this.normalizeRules();
};
IoHighlightRules.metaData = { fileTypes: [ 'io' ],
keyEquivalent: '^~I',
name: 'Io',
scopeName: 'source.io' }
oop.inherits(IoHighlightRules, TextHighlightRules);
exports.IoHighlightRules = IoHighlightRules;
});

View file

@ -1979,7 +1979,7 @@ var JSHINT = (function () {
function doOption() { function doOption() {
var nt = state.tokens.next; var nt = state.tokens.next;
var body = nt.body.match(/(-\s+)?[^\s,:]+(?:\s*:\s*(-\s+)?[^\s,]+)?/g); var body = nt.body.match(/(-\s+)?[^\s,:]+(?:\s*:\s*(-\s+)?[^\s,]+)?/g) || [];
var predef = {}; var predef = {};
if (nt.type === "globals") { if (nt.type === "globals") {

View file

@ -35,7 +35,7 @@ var oop = require("../lib/oop");
var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules; var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules;
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
var JavaScriptHighlightRules = function() { var JavaScriptHighlightRules = function(options) {
// see: https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects // see: https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects
var keywordMapper = this.createKeywordMapper({ var keywordMapper = this.createKeywordMapper({
"variable.language": "variable.language":
@ -187,11 +187,11 @@ var JavaScriptHighlightRules = function() {
regex : identifierRe regex : identifierRe
}, { }, {
token : "keyword.operator", token : "keyword.operator",
regex : /--|\+\+|[!$%&*+\-~]|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\|\||\?\:|\*=|%=|\+=|\-=|&=|\^=/, regex : /--|\+\+|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\|\||\?\:|[!$%&*+\-~\/^]=?/,
next : "start" next : "start"
}, { }, {
token : "punctuation.operator", token : "punctuation.operator",
regex : /\?|\:|\,|\;|\./, regex : /[?:,;.]/,
next : "start" next : "start"
}, { }, {
token : "paren.lparen", token : "paren.lparen",
@ -200,10 +200,6 @@ var JavaScriptHighlightRules = function() {
}, { }, {
token : "paren.rparen", token : "paren.rparen",
regex : /[\])}]/ regex : /[\])}]/
}, {
token : "keyword.operator",
regex : /\/=?/,
next : "start"
}, { }, {
token: "comment", token: "comment",
regex: /^#!.*$/ regex: /^#!.*$/
@ -272,7 +268,7 @@ var JavaScriptHighlightRules = function() {
], ],
"regex_character_class": [ "regex_character_class": [
{ {
token: "regexp.keyword.operator", token: "regexp.charclass.keyword.operator",
regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)" regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)"
}, { }, {
token: "constant.language.escape", token: "constant.language.escape",
@ -355,8 +351,48 @@ var JavaScriptHighlightRules = function() {
] ]
}; };
if (!options || !options.noES6) {
this.$rules.no_regex.unshift({
regex: "[{}]", onMatch: function(val, state, stack) {
this.next = val == "{" ? this.nextState : "";
if (val == "{" && stack.length) {
stack.unshift("start", state);
return "paren";
}
if (val == "}" && stack.length) {
stack.shift();
this.next = stack.shift();
if (this.next.indexOf("string") != -1)
return "paren.quasi.end";
}
return val == "{" ? "paren.lparen" : "paren.rparen";
},
nextState: "start"
}, {
token : "string.quasi.start",
regex : /`/,
push : [{
token : "constant.language.escape",
regex : escapedRe
}, {
token : "paren.quasi.start",
regex : /\${/,
push : "start"
}, {
token : "string.quasi.end",
regex : /`/,
next : "pop"
}, {
defaultToken: "string.quasi"
}]
});
}
this.embedRules(DocCommentHighlightRules, "doc-", this.embedRules(DocCommentHighlightRules, "doc-",
[ DocCommentHighlightRules.getEndRule("no_regex") ]); [ DocCommentHighlightRules.getEndRule("no_regex") ]);
this.normalizeRules();
}; };
oop.inherits(JavaScriptHighlightRules, TextHighlightRules); oop.inherits(JavaScriptHighlightRules, TextHighlightRules);

View file

@ -14,6 +14,8 @@ var Mode = function() {
oop.inherits(Mode, TextMode); oop.inherits(Mode, TextMode);
(function() { (function() {
this.type = "text";
this.lineCommentStart = "%"; this.lineCommentStart = "%";
this.$id = "ace/mode/latex"; this.$id = "ace/mode/latex";

View file

@ -5,11 +5,29 @@ var oop = require("../lib/oop");
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
var LatexHighlightRules = function() { var LatexHighlightRules = function() {
this.$rules = { this.$rules = {
"start" : [{ "start" : [{
// A comment. Tex comments start with % and go to
// the end of the line
token : "comment",
regex : "%.*$"
}, {
// Documentclass and usepackage
token : ["keyword", "lparen", "variable.parameter", "rparen", "lparen", "storage.type", "rparen"],
regex : "(\\\\(?:documentclass|usepackage|input))(?:(\\[)([^\\]]*)(\\]))?({)([^}]*)(})"
}, {
// A label
token : ["keyword","lparen", "variable.parameter", "rparen"],
regex : "(\\\\label)(?:({)([^}]*)(}))?"
}, {
// A block
token : ["storage.type", "lparen", "variable.parameter", "rparen"],
regex : "(\\\\(?:begin|end))({)(\\w*)(})"
}, {
// A tex command e.g. \foo // A tex command e.g. \foo
token : "keyword", token : "storage.type",
regex : "\\\\(?:[^a-zA-Z]|[a-zA-Z]+)" regex : "\\\\[a-zA-Z]+"
}, { }, {
// Curly and square braces // Curly and square braces
token : "lparen", token : "lparen",
@ -19,18 +37,35 @@ var LatexHighlightRules = function() {
token : "rparen", token : "rparen",
regex : "[\\])}]" regex : "[\\])}]"
}, { }, {
// Inline math between two $ symbols // Escaped character (including new line)
token : "string", token : "constant.character.escape",
regex : "\\$(?:(?:\\\\.)|(?:[^\\$\\\\]))*?\\$" regex : "\\\\[^a-zA-Z]?"
}, { }, {
// A comment. Tex comments start with % and go to // An equation
// the end of the line token : "string",
regex : "\\${1,2}",
next : "equation"
}],
"equation" : [{
token : "comment", token : "comment",
regex : "%.*$" regex : "%.*$"
}, {
token : "string",
regex : "\\${1,2}",
next : "start"
}, {
token : "constant.character.escape",
regex : "\\\\(?:[^a-zA-Z]|[a-zA-Z]+)"
}, {
token : "error",
regex : "^\\s*$",
next : "start"
}, {
defaultToken : "string"
}] }]
};
};
};
};
oop.inherits(LatexHighlightRules, TextHighlightRules); oop.inherits(LatexHighlightRules, TextHighlightRules);
exports.LatexHighlightRules = LatexHighlightRules; exports.LatexHighlightRules = LatexHighlightRules;

File diff suppressed because one or more lines are too long

View file

@ -164,15 +164,53 @@ var keywords = (
}, "identifier", true); }, "identifier", true);
this.$rules = { this.$rules = {
"start" : [ { // allowQstring
start: [{
token : "string",
regex : "'",
stateName : "qstring",
next : [{
token : "constant.language.escape",
regex : "''"
}, {
token : "string",
regex : "'|$",
next : "start"
}, {
defaultToken: "string"
}]
}, {
token : "text",
regex : "\\s+"
}, {
regex: "",
next: "noQstring"
}],
noQstring : [{
regex: "^\\s*%{\\s*$",
token: "comment.start",
push: "blockComment"
}, {
token : "comment", token : "comment",
regex : "%[^\r\n]*" regex : "%[^\r\n]*"
}, { }, {
token : "string", // " string token : "string",
regex : '".*?"' regex : '"',
stateName : "qqstring",
next : [{
token : "constant.language.escape",
regex : /\\./
}, { }, {
token : "string", // ' string token : "string",
regex : "'.*?'" regex : "\\\\$",
next : "qqstring"
}, {
token : "string",
regex : '"|$',
next : "start"
}, {
defaultToken: "string"
}]
}, { }, {
token : "constant.numeric", // float token : "constant.numeric", // float
regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b" regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
@ -181,21 +219,41 @@ var keywords = (
regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b" regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
}, { }, {
token : "keyword.operator", token : "keyword.operator",
regex : "\\+|\\-|\\/|\\/\\/|<@>|@>|<@|&|\\^|~|<|>|<=|=>|==|!=|<>|=" regex : "\\+|\\-|\\/|\\/\\/|<@>|@>|<@|&|\\^|~|<|>|<=|=>|==|!=|<>|=",
next: "start"
}, { }, {
token : "punctuation.operator", token : "punctuation.operator",
regex : "\\?|\\:|\\,|\\;|\\." regex : "\\?|\\:|\\,|\\;|\\.",
next: "start"
}, { }, {
token : "paren.lparen", token : "paren.lparen",
regex : "[\\(]" regex : "[({\\[]",
next: "start"
}, { }, {
token : "paren.rparen", token : "paren.rparen",
regex : "[\\)]" regex : "[\\]})]"
}, { }, {
token : "text", token : "text",
regex : "\\s+" regex : "\\s+"
} ] }, {
token : "text",
regex : "$",
next : "start"
}],
blockComment: [{
regex: "^\\s*%{\\s*$",
token: "comment.start",
push: "blockComment"
}, {
regex: "^\\s*%}\\s*$",
token: "comment.end",
next: "pop"
}, {
defaultToken: "comment"
}],
}; };
this.normalizeRules();
}; };
oop.inherits(MatlabHighlightRules, TextHighlightRules); oop.inherits(MatlabHighlightRules, TextHighlightRules);

View file

@ -1005,7 +1005,7 @@ var PhpLangHighlightRules = function() {
return "string"; return "string";
stack.shift(); stack.shift();
stack.shift(); stack.shift();
return "markup.list" return "markup.list";
}, },
regex : "^\\w+(?=;?$)", regex : "^\\w+(?=;?$)",
next: "start" next: "start"
@ -1016,12 +1016,11 @@ var PhpLangHighlightRules = function() {
], ],
"comment" : [ "comment" : [
{ {
token : "comment", // closing comment token : "comment",
regex : ".*?\\*\\/", regex : "\\*\\/",
next : "start" next : "start"
}, { }, {
token : "comment", // comment spanning whole line defaultToken : "comment"
regex : ".+"
} }
], ],
"qqstring" : [ "qqstring" : [
@ -1029,10 +1028,10 @@ var PhpLangHighlightRules = function() {
token : "constant.language.escape", token : "constant.language.escape",
regex : '\\\\(?:[nrtvef\\\\"$]|[0-7]{1,3}|x[0-9A-Fa-f]{1,2})' regex : '\\\\(?:[nrtvef\\\\"$]|[0-7]{1,3}|x[0-9A-Fa-f]{1,2})'
}, { }, {
token : "constant.language.escape", token : "variable",
regex : /\$[\w]+(?:\[[\w\]+]|=>\w+)?/ regex : /\$[\w]+(?:\[[\w\]+]|[=\-]>\w+)?/
}, { }, {
token : "constant.language.escape", token : "variable",
regex : /\$\{[^"\}]+\}?/ // this is wrong but ok for now regex : /\$\{[^"\}]+\}?/ // this is wrong but ok for now
}, },
{token : "string", regex : '"', next : "start"}, {token : "string", regex : '"', next : "start"},

84
lib/ace/mode/praat.js Normal file
View file

@ -0,0 +1,84 @@
/* ***** 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 TextMode = require("./text").Mode;
var PraatHighlightRules = require("./praat_highlight_rules").PraatHighlightRules;
var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
var Range = require("../range").Range;
var CStyleFoldMode = require("./folding/cstyle").FoldMode;
var Mode = function() {
this.HighlightRules = PraatHighlightRules;
this.$outdent = new MatchingBraceOutdent();
};
oop.inherits(Mode, TextMode);
(function() {
this.lineCommentStart = "#";
this.getNextLineIndent = function(state, line, tab) {
var indent = this.$getIndent(line);
var tokenizedLine = this.getTokenizer().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(/^.*[\{\(\[\:]\s*$/);
if (match) {
indent += tab;
}
}
return indent;
};
this.checkOutdent = function(state, line, input) {
return this.$outdent.checkOutdent(line, input);
};
this.autoOutdent = function(state, doc, row) {
this.$outdent.autoOutdent(doc, row);
};
this.$id = "ace/mode/praat";
}).call(Mode.prototype);
exports.Mode = Mode;
});

View file

@ -0,0 +1,262 @@
define(function(require, exports, module) {
"use strict";
var oop = require("../lib/oop");
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
var PraatHighlightRules = function() {
var keywords = (
"if|then|else|elsif|elif|endif|fi|" +
"endfor|endproc|" + // related keywords specified below
"while|endwhile|" +
"repeat|until|" +
"select|plus|minus|" +
"assert"
);
var predefinedVariables = (
"macintosh|windows|unix|" +
"praatVersion|praatVersion\\$" +
"pi|undefined|" +
"newline\\$|tab\\$|" +
"shellDirectory\\$|homeDirectory\\$|preferencesDirectory\\$|" +
"temporaryDirectory\\$|defaultDirectory\\$"
);
// What is "endSendPraat"? Function? Directive?
var directives = (
"clearinfo|endSendPraat"
);
var functions = (
// Info functions
"writeInfo|writeInfoLine|appendInfo|appendInfoLine|" +
"writeFile|writeFileLine|appendFile|appendFileLine|" +
// Math functions
"abs|round|floor|ceiling|min|max|imin|imax|" +
"sqrt|sin|cos|tan|arcsin|arccos|arctan|arctan2|sinc|sincpi|" +
"exp|ln|log10|log2|" +
"sinh|cosh|tanh|arcsinh|arccosh|actanh|" +
"sigmoid|invSigmoid|erf|erfc|" +
"randomUniform|randomInteger|randomGauss|randomPoisson|" +
"lnGamma|gaussP|gaussQ|invGaussQ|" +
"chiSquareP|chiSquareQ|invChiSquareQ|studentP|studentQ|invStudentQ|" +
"fisherP|fisherQ|invFisherQ|" +
"binomialP|binomialQ|invBinomialP|invBinomialQ|" +
"hertzToBark|barkToHerz|" +
"hertzToMel|melToHertz|" +
"hertzToSemitones|semitonesToHerz|" +
"erb|hertzToErb|erbToHertz|" +
"phonToDifferenceLimens|differenceLimensToPhon|" +
"beta|besselI|besselK|" +
// String functions
"selected|selected\\$|numberOfSelected|variableExists|"+
"index|rindex|startsWith|endsWith|"+
"index_regex|rindex_regex|replace_regex\\$|"+
"length|extractWord\\$|extractLine\\$|extractNumber|" +
"left\\$|right\\$|mid\\$|replace\\$|" +
// Pause functions
"beginPause|endPause|" +
// Demo functions
"demoShow|demoWindowTitle|demoInput|demoWaitForInput|" +
"demoClicked|demoClickedIn|demoX|demoY|" +
"demoKeyPressed|demoKey\\$|" +
"demoExtraControlKeyPressed|demoShiftKeyPressed|"+
"demoCommandKeyPressed|demoOptionKeyPressed|" +
// File functions
"environment\\$|chooseReadFile\\$|" +
"chooseDirectory\\$|createDirectory|fileReadable|deleteFile|" +
"selectObject|removeObject|plusObject|minusObject|" +
"runScript|exitScript|" +
// sendpraat functions
"beginSendPraat|endSendPraat"
);
var objectTypes = (
"Activation|AffineTransform|AmplitudeTier|Art|Artword|Autosegment|" +
"BarkFilter|CCA|Categories|Cepstrum|Cepstrumc|ChebyshevSeries|" +
"ClassificationTable|Cochleagram|Collection|Configuration|" +
"Confusion|ContingencyTable|Corpus|Correlation|Covariance|" +
"CrossCorrelationTable|CrossCorrelationTables|DTW|Diagonalizer|" +
"Discriminant|Dissimilarity|Distance|Distributions|DurationTier|" +
"EEG|ERP|ERPTier|Eigen|Excitation|Excitations|ExperimentMFC|FFNet|" +
"FeatureWeights|Formant|FormantFilter|FormantGrid|FormantPoint|" +
"FormantTier|GaussianMixture|HMM|HMM_Observation|" +
"HMM_ObservationSequence|HMM_State|HMM_StateSequence|Harmonicity|" +
"ISpline|Index|Intensity|IntensityTier|IntervalTier|KNN|KlattGrid|" +
"KlattTable|LFCC|LPC|Label|LegendreSeries|LinearRegression|" +
"LogisticRegression|LongSound|Ltas|MFCC|MSpline|ManPages|" +
"Manipulation|Matrix|MelFilter|MixingMatrix|Movie|Network|" +
"OTGrammar|OTHistory|OTMulti|PCA|PairDistribution|ParamCurve|" +
"Pattern|Permutation|Pitch|PitchTier|PointProcess|Polygon|" +
"Polynomial|Procrustes|RealPoint|RealTier|ResultsMFC|Roots|SPINET|" +
"SSCP|SVD|Salience|ScalarProduct|Similarity|SimpleString|" +
"SortedSetOfString|Sound|Speaker|Spectrogram|Spectrum|SpectrumTier|" +
"SpeechSynthesizer|SpellingChecker|Strings|StringsIndex|Table|" +
"TableOfReal|TextGrid|TextInterval|TextPoint|TextTier|Tier|" +
"Transition|VocalTract|Weight|WordList"
);
// regexp must not have capturing parentheses. Use (?:) instead.
// regexps are ordered -> the first match is used
this.$rules = {
"start" : [
{
// Interpolated strings
token : "string.interpolated",
regex : /'((?:[a-z][a-zA-Z0-9_]*)(?:\$|#|:[0-9]+)?)'/
}, {
// stopwatch
token : ["text", "text", "keyword.operator", "text", "keyword"],
regex : /(^\s*)(?:([a-z][a-zA-Z0-9_]*\$?\s+)(=)(\s+))?(stopwatch)/
}, {
// Directives which introduce unquoted strings
token : ["text", "keyword", "text", "string"],
regex : /(^\s*)(print(?:line)?|echo|exit|pause|sendpraat|include|execute)(\s+)(.*)/
}, {
// Directives with no arguments
token : ["text", "keyword"],
regex : "(^\\s*)(" + directives + ")$"
}, {
// Operators
token : ["text", "keyword.operator", "text"],
regex : /(\s+)((?:\+|-|\/|\*|<|>)=?|==?|!=|%|\^|\||and|or|not)(\s+)/
}, {
// Commands
token : ["text", "text", "keyword.operator", "text", "keyword", "text", "keyword"],
regex : /(^\s*)(?:([a-z][a-zA-Z0-9_]*\$?\s+)(=)(\s+))?(?:((?:no)?warn|nocheck|noprogress)(\s+))?((?:[A-Z][^.:"]+)(?:$|(?:\.{3}|:)))/
}, {
// Demo commands
token : ["text", "keyword", "text", "keyword"],
regex : /(^\s*)(?:(demo)?(\s+))((?:[A-Z][^.:"]+)(?:$|(?:\.{3}|:)))/
}, {
// Font-sizing commands
token : ["text", "keyword", "text", "keyword"],
regex : /^(\s*)(?:(demo)(\s+))?(10|12|14|16|24)$/
}, {
// do-style command calls
token : ["text", "support.function", "text"],
regex : /(\s*)(do\$?)(\s*:\s*|\s*\(\s*)/
}, {
// Object types
token : "entity.name.type",
regex : "(" + objectTypes + ")"
}, {
// Predefined variables
token : "variable.language",
regex : "(" + predefinedVariables + ")"
}, {
// Functions
token : ["support.function", "text"],
regex : "((?:" + functions + ")\\$?)(\\s*(?::|\\())"
}, {
// For-loop declarations
token : "keyword",
regex : /(\bfor\b)/,
next : "for"
}, {
// Generic keywords
token : "keyword",
regex : "(\\b(?:" + keywords + ")\\b)"
}, {
// Generic strings
token : "string",
regex : /"[^"]*"/
}, {
// Multiline quoted strings
token : "string",
regex : /"[^"]*$/,
next : "brokenstring"
}, {
// Form declarations
token : ["text", "keyword", "text", "entity.name.section"],
regex : /(^\s*)(\bform\b)(\s+)(.*)/,
next : "form"
}, {
// Numeric constants
token : "constant.numeric",
regex : /\b[+-]?\d+(?:(?:\.\d*)?(?:[eE][+-]?\d+)?)?\b/
}, {
// Procedure declarations
token : ["keyword", "text", "entity.name.function"],
regex : /(procedure)(\s+)(\S+)/
}, {
// New-style procedure calls
token : ["entity.name.function", "text"],
regex : /(@\S+)(:|\s*\()/
}, {
// Old-style procedure calls
token : ["text", "keyword", "text", "entity.name.function"],
regex : /(^\s*)(call)(\s+)(\S+)/
}, {
// Comments
token : "comment",
regex : /(^\s*#|;).*$/
}, {
token : "text",
regex : /\s+/
}
],
"form" : [
{
token : ["keyword", "text", "constant.numeric"],
regex : /((?:optionmenu|choice)\s+)(\S+:\s+)([0-9]+)/
}, {
token : ["keyword", "constant.numeric"],
regex : /((?:option|button)\s+)([+-]?\d+(?:(?:\.\d*)?(?:[eE][+-]?\d+)?)?\b)/
}, {
token : ["keyword", "string"],
regex : /((?:option|button)\s+)(.*)/
}, {
token : ["keyword", "text", "string"],
regex : /((?:sentence|text)\s+)(\S+\s*)(.*)/
}, {
token : ["keyword", "text", "string", "invalid.illegal"],
regex : /(word\s+)(\S+\s*)(\S+)?(\s.*)?/
}, {
token : ["keyword", "text", "constant.language"],
regex : /(boolean\s+)(\S+\s*)(0|1|"?(?:yes|no)"?)/
}, {
token : ["keyword", "text", "constant.numeric"],
regex : /((?:real|natural|positive|integer)\s+)(\S+\s*)([+-]?\d+(?:(?:\.\d*)?(?:[eE][+-]?\d+)?)?\b)/
}, {
token : ["keyword", "string"],
regex : /(comment\s+)(.*)/
}, {
token : "keyword",
regex : 'endform',
next : "start"
}
],
"for" : [
{
token : ["keyword", "text", "constant.numeric", "text"],
regex : /(from|to)(\s+)([+-]?\d+(?:(?:\.\d*)?(?:[eE][+-]?\d+)?)?)(\s*)/
}, {
token : ["keyword", "text"],
regex : /(from|to)(\s+\S+\s*)/
}, {
token : "text",
regex : /$/,
next : "start"
}
],
"brokenstring" : [
{
token : ["text", "string"],
regex : /(\s*\.{3})([^"]*)/
}, {
token : "string",
regex : /"/,
next : "start"
}
],
};
};
oop.inherits(PraatHighlightRules, TextHighlightRules);
exports.PraatHighlightRules = PraatHighlightRules;
});

View file

@ -36,11 +36,13 @@ var TextMode = require("./text").Mode;
var RubyHighlightRules = require("./ruby_highlight_rules").RubyHighlightRules; var RubyHighlightRules = require("./ruby_highlight_rules").RubyHighlightRules;
var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
var Range = require("../range").Range; var Range = require("../range").Range;
var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour;
var FoldMode = require("./folding/coffee").FoldMode; var FoldMode = require("./folding/coffee").FoldMode;
var Mode = function() { var Mode = function() {
this.HighlightRules = RubyHighlightRules; this.HighlightRules = RubyHighlightRules;
this.$outdent = new MatchingBraceOutdent(); this.$outdent = new MatchingBraceOutdent();
this.$behaviour = new CstyleBehaviour();
this.foldingRules = new FoldMode(); this.foldingRules = new FoldMode();
}; };
oop.inherits(Mode, TextMode); oop.inherits(Mode, TextMode);

View file

@ -53,7 +53,7 @@ var Mode = function() {
oop.inherits(Mode, TextMode); oop.inherits(Mode, TextMode);
(function() { (function() {
this.lineCommentStart = "/\\*"; this.lineCommentStart = "//";
this.blockComment = {start: "/*", end: "*/"}; this.blockComment = {start: "/*", end: "*/"};
this.$id = "ace/mode/rust"; this.$id = "ace/mode/rust";
}).call(Mode.prototype); }).call(Mode.prototype);

View file

@ -99,6 +99,65 @@ var ShHighlightRules = function() {
}, { }, {
defaultToken: "string" defaultToken: "string"
}] }]
}, {
regex : "<<<",
token : "keyword.operator"
}, {
stateName: "heredoc",
regex : "(<<)(\\s*)(['\"`]?)([\\w\\-]+)(['\"`]?)",
onMatch : function(value, currentState, stack) {
var next = value[2] == '-' ? "indentedHeredoc" : "heredoc";
var tokens = value.split(this.splitRegex);
stack.push(next, tokens[4]);
return [
{type:"constant", value: tokens[1]},
{type:"text", value: tokens[2]},
{type:"string", value: tokens[3]},
{type:"support.class", value: tokens[4]},
{type:"string", value: tokens[5]}
];
},
rules: {
heredoc: [{
onMatch: function(value, currentState, stack) {
if (value === stack[1]) {
stack.shift();
stack.shift();
this.next = stack[0] || "start";
return "support.class";
}
this.next = "";
return "string";
},
regex: ".*$",
next: "start"
}],
indentedHeredoc: [{
token: "string",
regex: "^\t+"
}, {
onMatch: function(value, currentState, stack) {
if (value === stack[1]) {
stack.shift();
stack.shift();
this.next = stack[0] || "start";
return "support.class";
}
this.next = "";
return "string";
},
regex: ".*$",
next: "start"
}]
}
}, {
regex : "$",
token : "empty",
next : function(currentState, stack) {
if (stack[0] === "heredoc" || stack[0] === "indentedHeredoc")
return stack[0];
return currentState;
}
}, { }, {
token : "variable.language", token : "variable.language",
regex : builtinVariable regex : builtinVariable
@ -122,7 +181,7 @@ var ShHighlightRules = function() {
regex : integer + "\\b" regex : integer + "\\b"
}, { }, {
token : keywordMapper, token : keywordMapper,
regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b" regex : "[a-zA-Z_][a-zA-Z0-9_]*\\b"
}, { }, {
token : "keyword.operator", token : "keyword.operator",
regex : "\\+|\\-|\\*|\\*\\*|\\/|\\/\\/|~|<|>|<=|=>|=|!=" regex : "\\+|\\-|\\*|\\*\\*|\\/|\\/\\/|~|<|>|<=|=>|=|!="

View file

@ -36,7 +36,7 @@ var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScrip
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
var SJSHighlightRules = function() { var SJSHighlightRules = function() {
var parent = new JavaScriptHighlightRules(); var parent = new JavaScriptHighlightRules({noES6: true});
var escapedRe = "\\\\(?:x[0-9a-fA-F]{2}|" + // hex var escapedRe = "\\\\(?:x[0-9a-fA-F]{2}|" + // hex
"u[0-9a-fA-F]{4}|" + // unicode "u[0-9a-fA-F]{4}|" + // unicode
"[0-2][0-7]{0,2}|" + // oct "[0-2][0-7]{0,2}|" + // oct

View file

@ -104,6 +104,7 @@ oop.inherits(Mode, TextMode);
(function() { (function() {
this.$indentWithTabs = true; this.$indentWithTabs = true;
this.lineCommentStart = "#";
this.$id = "ace/mode/snippets"; this.$id = "ace/mode/snippets";
}).call(Mode.prototype); }).call(Mode.prototype);
exports.Mode = Mode; exports.Mode = Mode;

View file

@ -38,7 +38,7 @@ var SqlHighlightRules = function() {
var keywords = ( var keywords = (
"select|insert|update|delete|from|where|and|or|group|by|order|limit|offset|having|as|case|" + "select|insert|update|delete|from|where|and|or|group|by|order|limit|offset|having|as|case|" +
"when|else|end|type|left|right|join|on|outer|desc|asc" "when|else|end|type|left|right|join|on|outer|desc|asc|union"
); );
var builtinConstants = ( var builtinConstants = (

View file

@ -60,7 +60,7 @@ var TextHighlightRules = function() {
var state = rules[key]; var state = rules[key];
for (var i = 0; i < state.length; i++) { for (var i = 0; i < state.length; i++) {
var rule = state[i]; var rule = state[i];
if (rule.next) { if (rule.next || rule.onMatch) {
if (typeof rule.next != "string") { if (typeof rule.next != "string") {
if (rule.nextState && rule.nextState.indexOf(prefix) !== 0) if (rule.nextState && rule.nextState.indexOf(prefix) !== 0)
rule.nextState = prefix + rule.nextState; rule.nextState = prefix + rule.nextState;
@ -68,7 +68,6 @@ var TextHighlightRules = function() {
if (rule.next.indexOf(prefix) !== 0) if (rule.next.indexOf(prefix) !== 0)
rule.next = prefix + rule.next; rule.next = prefix + rule.next;
} }
} }
} }
this.$rules[prefix + key] = state; this.$rules[prefix + key] = state;

View file

@ -136,7 +136,7 @@ var ValaHighlightRules = function() {
[ { token: 'meta.class.vala', [ { token: 'meta.class.vala',
regex: '(?=\\w?[\\w\\s]*(?:class|(?:@)?interface|enum|struct|namespace)\\s+\\w+)', regex: '(?=\\w?[\\w\\s]*(?:class|(?:@)?interface|enum|struct|namespace)\\s+\\w+)',
push: push:
[ { token: 'punctuation.section.class.end.vala', [ { token: 'paren.vala',
regex: '}', regex: '}',
next: 'pop' }, next: 'pop' },
{ include: '#storage-modifiers' }, { include: '#storage-modifiers' },
@ -166,10 +166,10 @@ var ValaHighlightRules = function() {
{ include: '#object-types-inherited' }, { include: '#object-types-inherited' },
{ include: '#comments' }, { include: '#comments' },
{ defaultToken: 'meta.definition.class.implemented.interfaces.vala' } ] }, { defaultToken: 'meta.definition.class.implemented.interfaces.vala' } ] },
{ token: 'meta.class.body.vala', { token: 'paren.vala',
regex: '{', regex: '{',
push: push:
[ { token: 'meta.class.body.vala', regex: '(?=})', next: 'pop' }, [ { token: 'paren.vala', regex: '(?=})', next: 'pop' },
{ include: '#class-body' }, { include: '#class-body' },
{ defaultToken: 'meta.class.body.vala' } ] }, { defaultToken: 'meta.class.body.vala' } ] },
{ defaultToken: 'meta.class.vala' } ], { defaultToken: 'meta.class.vala' } ],
@ -266,7 +266,7 @@ var ValaHighlightRules = function() {
[ { token: 'meta.method.vala', [ { token: 'meta.method.vala',
regex: '(?!new)(?=\\w.*\\s+)(?=[^=]+\\()', regex: '(?!new)(?=\\w.*\\s+)(?=[^=]+\\()',
push: push:
[ { token: 'meta.method.vala', regex: '}|(?=;)', next: 'pop' }, [ { token: 'paren.vala', regex: '}|(?=;)', next: 'pop' },
{ include: '#storage-modifiers' }, { include: '#storage-modifiers' },
{ token: [ 'entity.name.function.vala', 'meta.method.identifier.vala' ], { token: [ 'entity.name.function.vala', 'meta.method.identifier.vala' ],
regex: '([\\~\\w\\.]+)(\\s*\\()', regex: '([\\~\\w\\.]+)(\\s*\\()',
@ -285,10 +285,10 @@ var ValaHighlightRules = function() {
{ include: '#all-types' }, { include: '#all-types' },
{ defaultToken: 'meta.method.return-type.vala' } ] }, { defaultToken: 'meta.method.return-type.vala' } ] },
{ include: '#throws' }, { include: '#throws' },
{ token: 'meta.method.body.vala', { token: 'paren.vala',
regex: '{', regex: '{',
push: push:
[ { token: 'meta.method.body.vala', regex: '(?=})', next: 'pop' }, [ { token: 'paren.vala', regex: '(?=})', next: 'pop' },
{ include: '#code' }, { include: '#code' },
{ defaultToken: 'meta.method.body.vala' } ] }, { defaultToken: 'meta.method.body.vala' } ] },
{ defaultToken: 'meta.method.vala' } ] } ], { defaultToken: 'meta.method.vala' } ] } ],

View file

@ -1,7 +1,7 @@
define(function(require, exports, module) { define(function(require, exports, module) {
module.exports = (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({ module.exports = (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({
1:[function(_dereq_,module,exports){ 1:[function(_dereq_,module,exports){
// This file was generated on Sun Mar 23, 2014 21:29 (UTC+01) by REx v5.30 which is Copyright (c) 1979-2014 by Gunther Rademacher <grd@gmx.net> // This file was generated on Thu Jul 24, 2014 15:01 (UTC+01) by REx v5.30 which is Copyright (c) 1979-2014 by Gunther Rademacher <grd@gmx.net>
// REx command line: JSONiqTokenizer.ebnf -ll 2 -backtrack -tree -javascript -a xqlint // REx command line: JSONiqTokenizer.ebnf -ll 2 -backtrack -tree -javascript -a xqlint
// line 2 "JSONiqTokenizer.ebnf" // line 2 "JSONiqTokenizer.ebnf"
@ -4212,33 +4212,7 @@ JSONiqTokenizer.TOKEN =
'use strict'; 'use strict';
var JSONiqTokenizer = _dereq_('./JSONiqTokenizer').JSONiqTokenizer; var JSONiqTokenizer = _dereq_('./JSONiqTokenizer').JSONiqTokenizer;
var Lexer = _dereq_('./lexer').Lexer;
var TokenHandler = function(code) {
var input = code;
this.tokens = [];
this.reset = function() {
input = input;
this.tokens = [];
};
this.startNonterminal = function() {};
this.endNonterminal = function() {};
this.terminal = function(name, begin, end) {
this.tokens.push({
name: name,
value: input.substring(begin, end)
});
};
this.whitespace = function(begin, end) {
this.tokens.push({
name: 'WS',
value: input.substring(begin, end)
});
};
};
var keys = 'NaN|after|allowing|ancestor|ancestor-or-self|and|append|array|as|ascending|at|attribute|base-uri|before|boundary-space|break|by|case|cast|castable|catch|child|collation|comment|constraint|construction|contains|context|continue|copy|copy-namespaces|count|decimal-format|decimal-separator|declare|default|delete|descendant|descendant-or-self|descending|digit|div|document|document-node|element|else|empty|empty-sequence|encoding|end|eq|every|except|exit|external|false|first|following|following-sibling|for|from|ft-option|function|ge|greatest|group|grouping-separator|gt|idiv|if|import|in|index|infinity|insert|instance|integrity|intersect|into|is|item|json|json-item|jsoniq|last|lax|le|least|let|loop|lt|minus-sign|mod|modify|module|namespace|namespace-node|ne|next|node|nodes|not|null|object|of|only|option|or|order|ordered|ordering|paragraphs|parent|pattern-separator|per-mille|percent|preceding|preceding-sibling|previous|processing-instruction|rename|replace|return|returning|revalidation|satisfies|schema|schema-attribute|schema-element|score|select|self|sentences|sliding|some|stable|start|strict|switch|text|then|times|to|treat|true|try|tumbling|type|typeswitch|union|unordered|updating|validate|value|variable|version|when|where|while|window|with|words|xquery|zero-digit'.split('|'); var keys = 'NaN|after|allowing|ancestor|ancestor-or-self|and|append|array|as|ascending|at|attribute|base-uri|before|boundary-space|break|by|case|cast|castable|catch|child|collation|comment|constraint|construction|contains|context|continue|copy|copy-namespaces|count|decimal-format|decimal-separator|declare|default|delete|descendant|descendant-or-self|descending|digit|div|document|document-node|element|else|empty|empty-sequence|encoding|end|eq|every|except|exit|external|false|first|following|following-sibling|for|from|ft-option|function|ge|greatest|group|grouping-separator|gt|idiv|if|import|in|index|infinity|insert|instance|integrity|intersect|into|is|item|json|json-item|jsoniq|last|lax|le|least|let|loop|lt|minus-sign|mod|modify|module|namespace|namespace-node|ne|next|node|nodes|not|null|object|of|only|option|or|order|ordered|ordering|paragraphs|parent|pattern-separator|per-mille|percent|preceding|preceding-sibling|previous|processing-instruction|rename|replace|return|returning|revalidation|satisfies|schema|schema-attribute|schema-element|score|select|self|sentences|sliding|some|stable|start|strict|switch|text|then|times|to|treat|true|try|tumbling|type|typeswitch|union|unordered|updating|validate|value|variable|version|when|where|while|window|with|words|xquery|zero-digit'.split('|');
var keywords = keys.map(function(val) { return { name: '\'' + val + '\'', token: 'keyword' }; }); var keywords = keys.map(function(val) { return { name: '\'' + val + '\'', token: 'keyword' }; });
@ -4368,7 +4342,40 @@ var Rules = {
] ]
}; };
exports.JSONiqLexer = function() { exports.JSONiqLexer = function(){ return new Lexer(JSONiqTokenizer, Rules); };
},
{"./JSONiqTokenizer":1,"./lexer":3}],
3:[function(_dereq_,module,exports){
'use strict';
var TokenHandler = function(code) {
var input = code;
this.tokens = [];
this.reset = function() {
input = input;
this.tokens = [];
};
this.startNonterminal = function() {};
this.endNonterminal = function() {};
this.terminal = function(name, begin, end) {
this.tokens.push({
name: name,
value: input.substring(begin, end)
});
};
this.whitespace = function(begin, end) {
this.tokens.push({
name: 'WS',
value: input.substring(begin, end)
});
};
};
exports.Lexer = function(Tokenizer, Rules) {
this.tokens = []; this.tokens = [];
@ -4376,7 +4383,7 @@ exports.JSONiqLexer = function() {
state = (state === 'start' || !state) ? '["start"]' : state; state = (state === 'start' || !state) ? '["start"]' : state;
var stack = JSON.parse(state); var stack = JSON.parse(state);
var h = new TokenHandler(line); var h = new TokenHandler(line);
var tokenizer = new JSONiqTokenizer(line, h); var tokenizer = new Tokenizer(line, h);
var tokens = []; var tokens = [];
while(true) { while(true) {
@ -4440,7 +4447,7 @@ exports.JSONiqLexer = function() {
}; };
}; };
}, },
{"./JSONiqTokenizer":1}]},{},[2]) {}]},{},[2])
(2) (2)
}); });

File diff suppressed because it is too large Load diff

View file

@ -1,7 +1,7 @@
define(function(require, exports, module) { define(function(require, exports, module) {
module.exports = (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({ module.exports = (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({
1:[function(_dereq_,module,exports){ 1:[function(_dereq_,module,exports){
// This file was generated on Sun Mar 23, 2014 21:29 (UTC+01) by REx v5.30 which is Copyright (c) 1979-2014 by Gunther Rademacher <grd@gmx.net> // This file was generated on Thu Jul 24, 2014 15:01 (UTC+01) by REx v5.30 which is Copyright (c) 1979-2014 by Gunther Rademacher <grd@gmx.net>
// REx command line: XQueryTokenizer.ebnf -ll 2 -backtrack -tree -javascript -a xqlint // REx command line: XQueryTokenizer.ebnf -ll 2 -backtrack -tree -javascript -a xqlint
// line 2 "XQueryTokenizer.ebnf" // line 2 "XQueryTokenizer.ebnf"
@ -4178,8 +4178,6 @@ XQueryTokenizer.TOKEN =
2:[function(_dereq_,module,exports){ 2:[function(_dereq_,module,exports){
'use strict'; 'use strict';
var XQueryTokenizer = _dereq_('./XQueryTokenizer').XQueryTokenizer;
var TokenHandler = function(code) { var TokenHandler = function(code) {
var input = code; var input = code;
this.tokens = []; this.tokens = [];
@ -4207,6 +4205,85 @@ var TokenHandler = function(code) {
}; };
}; };
exports.Lexer = function(Tokenizer, Rules) {
this.tokens = [];
this.getLineTokens = function(line, state) {
state = (state === 'start' || !state) ? '["start"]' : state;
var stack = JSON.parse(state);
var h = new TokenHandler(line);
var tokenizer = new Tokenizer(line, h);
var tokens = [];
while(true) {
var currentState = stack[stack.length - 1];
try {
h.tokens = [];
tokenizer['parse_' + currentState]();
var info = null;
if(h.tokens.length > 1 && h.tokens[0].name === 'WS') {
tokens.push({
type: 'text',
value: h.tokens[0].value
});
h.tokens.splice(0, 1);
}
var token = h.tokens[0];
var rules = Rules[currentState];
for(var k = 0; k < rules.length; k++) {
var rule = Rules[currentState][k];
if((typeof(rule.name) === 'function' && rule.name(token)) || rule.name === token.name) {
info = rule;
break;
}
}
if(token.name === 'EOF') { break; }
if(token.value === '') { throw 'Encountered empty string lexical rule.'; }
tokens.push({
type: info === null ? 'text' : (typeof(info.token) === 'function' ? info.token(token.value) : info.token),
value: token.value
});
if(info && info.next) {
info.next(stack);
}
} catch(e) {
if(e instanceof tokenizer.ParseException) {
var index = 0;
for(var i=0; i < tokens.length; i++) {
index += tokens[i].value.length;
}
tokens.push({ type: 'text', value: line.substring(index) });
return {
tokens: tokens,
state: JSON.stringify(['start'])
};
} else {
throw e;
}
}
}
return {
tokens: tokens,
state: JSON.stringify(stack)
};
};
};
},
{}],
3:[function(_dereq_,module,exports){
'use strict';
var XQueryTokenizer = _dereq_('./XQueryTokenizer').XQueryTokenizer;
var Lexer = _dereq_('./lexer').Lexer;
var keys = 'after|ancestor|ancestor-or-self|and|as|ascending|attribute|before|case|cast|castable|child|collation|comment|copy|count|declare|default|delete|descendant|descendant-or-self|descending|div|document|document-node|element|else|empty|empty-sequence|end|eq|every|except|first|following|following-sibling|for|function|ge|group|gt|idiv|if|import|insert|instance|intersect|into|is|item|last|le|let|lt|mod|modify|module|namespace|namespace-node|ne|node|only|or|order|ordered|parent|preceding|preceding-sibling|processing-instruction|rename|replace|return|satisfies|schema-attribute|schema-element|self|some|stable|start|switch|text|to|treat|try|typeswitch|union|unordered|validate|where|with|xquery|contains|paragraphs|sentences|times|words|by|collectionreturn|variable|version|option|when|encoding|toswitch|catch|tumbling|sliding|window|at|using|stemming|collection|schema|while|on|nodes|index|external|then|in|updating|value|of|containsbreak|loop|continue|exit|returning|append|json|position|strict'.split('|'); var keys = 'after|ancestor|ancestor-or-self|and|as|ascending|attribute|before|case|cast|castable|child|collation|comment|copy|count|declare|default|delete|descendant|descendant-or-self|descending|div|document|document-node|element|else|empty|empty-sequence|end|eq|every|except|first|following|following-sibling|for|function|ge|group|gt|idiv|if|import|insert|instance|intersect|into|is|item|last|le|let|lt|mod|modify|module|namespace|namespace-node|ne|node|only|or|order|ordered|parent|preceding|preceding-sibling|processing-instruction|rename|replace|return|satisfies|schema-attribute|schema-element|self|some|stable|start|switch|text|to|treat|try|typeswitch|union|unordered|validate|where|with|xquery|contains|paragraphs|sentences|times|words|by|collectionreturn|variable|version|option|when|encoding|toswitch|catch|tumbling|sliding|window|at|using|stemming|collection|schema|while|on|nodes|index|external|then|in|updating|value|of|containsbreak|loop|continue|exit|returning|append|json|position|strict'.split('|');
var keywords = keys.map(function(val) { return { name: '\'' + val + '\'', token: 'keyword' }; }); var keywords = keys.map(function(val) { return { name: '\'' + val + '\'', token: 'keyword' }; });
@ -4337,114 +4414,9 @@ var Rules = {
] ]
}; };
exports.XQueryLexer = function() { exports.XQueryLexer = function(){ return new Lexer(XQueryTokenizer, Rules); };
this.tokens = [];
this.getLineTokens = function(line, state, row) {
state = (state === 'start' || !state) ? '["start"]' : state;
var stack = JSON.parse(state);
var h = new TokenHandler(line);
var tokenizer = new XQueryTokenizer(line, h);
var tokens = [];
while(true) {
var currentState = stack[stack.length - 1];
try {
h.tokens = [];
tokenizer['parse_' + currentState]();
var info = null;
if(h.tokens.length > 1 && h.tokens[0].name === 'WS') {
tokens.push({
type: 'text',
value: h.tokens[0].value
});
h.tokens.splice(0, 1);
}
var token = h.tokens[0];
var rules = Rules[currentState];
for(var k = 0; k < rules.length; k++) {
var rule = Rules[currentState][k];
if((typeof(rule.name) === 'function' && rule.name(token)) || rule.name === token.name) {
info = rule;
break;
}
}
if(token.name === 'EOF') { break; }
if(token.value === '') { throw 'Encountered empty string lexical rule.'; }
tokens.push({
type: info === null ? 'text' : (typeof(info.token) === 'function' ? info.token(token.value) : info.token),
value: token.value
});
if(info && info.next) {
info.next(stack);
}
} catch(e) {
if(e instanceof tokenizer.ParseException) {
var index = 0;
for(var i=0; i < tokens.length; i++) {
index += tokens[i].value.length;
}
tokens.push({ type: 'text', value: line.substring(index) });
return {
tokens: tokens,
state: JSON.stringify(['start'])
};
} else {
throw e;
}
}
}
if(this.tokens[row] !== undefined) {
var cachedLine = this.lines[row];
var begin = sharedStart([line, cachedLine]);
var diff = cachedLine.length - line.length;
var idx = 0;
var col = 0;
for(var i = 0; i < tokens.length; i++) {
var t = tokens[i];
for(var j = 0; j < this.tokens[row].length; j++) {
var semanticToken = this.tokens[row][j];
if(
((col + t.value.length) <= begin.length && semanticToken.sc === col && semanticToken.ec === (col + t.value.length)) ||
(semanticToken.sc === (col + diff) && semanticToken.ec === (col + t.value.length + diff))
) {
idx = i;
t.type = semanticToken.type;
}
}
col += t.value.length;
}
}
return {
tokens: tokens,
state: JSON.stringify(stack)
};
};
function sharedStart(A) {
A = A.slice(0).sort();
var tem1, tem2, s;
tem1 = A[0];
s = tem1.length;
tem2 = A.pop();
while(s && tem2.indexOf(tem1) === -1) {
tem1 = tem1.substring(0, --s);
}
return tem1;
}
};
}, },
{"./XQueryTokenizer":1}]},{},[2]) {"./XQueryTokenizer":1,"./lexer":2}]},{},[3])
(2) (3)
}); });

View file

@ -71,21 +71,20 @@ function DefaultHandlers(mouseHandler) {
var selectionRange = editor.getSelectionRange(); var selectionRange = editor.getSelectionRange();
var selectionEmpty = selectionRange.isEmpty(); var selectionEmpty = selectionRange.isEmpty();
if (selectionEmpty) { if (selectionEmpty)
editor.selection.moveToPosition(pos); editor.selection.moveToPosition(pos);
}
// 2: contextmenu, 1: linux paste // 2: contextmenu, 1: linux paste
editor.textInput.onContextMenu(ev.domEvent); editor.textInput.onContextMenu(ev.domEvent);
return; // stopping event here breaks contextmenu on ff mac return; // stopping event here breaks contextmenu on ff mac
} }
this.mousedownEvent.time = Date.now();
// if this click caused the editor to be focused should not clear the // if this click caused the editor to be focused should not clear the
// selection // selection
if (inSelection && !editor.isFocused()) { if (inSelection && !editor.isFocused()) {
editor.focus(); editor.focus();
if (this.$focusTimout && !this.$clickSelection && !editor.inMultiSelectMode) { if (this.$focusTimout && !this.$clickSelection && !editor.inMultiSelectMode) {
this.mousedownEvent.time = Date.now();
this.setState("focusWait"); this.setState("focusWait");
this.captureMouse(ev); this.captureMouse(ev);
return; return;
@ -93,31 +92,21 @@ function DefaultHandlers(mouseHandler) {
} }
this.captureMouse(ev); this.captureMouse(ev);
if (!inSelection || this.$clickSelection || ev.getShiftKey() || editor.inMultiSelectMode) { this.startSelect(pos, ev.domEvent._clicks > 1);
// Directly pick STATE_SELECT, since the user is not clicking inside
// a selection.
this.startSelect(pos);
} else if (inSelection) {
this.mousedownEvent.time = Date.now();
this.startSelect(pos);
}
return ev.preventDefault(); return ev.preventDefault();
}; };
this.startSelect = function(pos) { this.startSelect = function(pos, waitForClickSelection) {
pos = pos || this.editor.renderer.screenToTextCoordinates(this.x, this.y); pos = pos || this.editor.renderer.screenToTextCoordinates(this.x, this.y);
var editor = this.editor; var editor = this.editor;
// allow double/triple click handlers to change selection // allow double/triple click handlers to change selection
var shiftPressed = this.mousedownEvent.getShiftKey();
setTimeout(function(){ if (this.mousedownEvent.getShiftKey())
if (shiftPressed) {
editor.selection.selectToPosition(pos); editor.selection.selectToPosition(pos);
} else if (!waitForClickSelection)
else if (!this.$clickSelection) {
editor.selection.moveToPosition(pos); editor.selection.moveToPosition(pos);
} if (!waitForClickSelection)
this.select(); this.select();
}.bind(this), 0);
if (editor.renderer.scroller.setCapture) { if (editor.renderer.scroller.setCapture) {
editor.renderer.scroller.setCapture(); editor.renderer.scroller.setCapture();
} }
@ -216,6 +205,7 @@ function DefaultHandlers(mouseHandler) {
this.setState("selectByWords"); this.setState("selectByWords");
} }
this.$clickSelection = range; this.$clickSelection = range;
this.select();
}; };
this.onTripleClick = function(ev) { this.onTripleClick = function(ev) {
@ -230,6 +220,7 @@ function DefaultHandlers(mouseHandler) {
} else { } else {
this.$clickSelection = editor.selection.getLineRange(pos.row); this.$clickSelection = editor.selection.getLineRange(pos.row);
} }
this.select();
}; };
this.onQuadClick = function(ev) { this.onQuadClick = function(ev) {

View file

@ -84,7 +84,7 @@ function DragdropHandler(mouseHandler) {
if (useragent.isOpera) { if (useragent.isOpera) {
editor.container.appendChild(blankImage); editor.container.appendChild(blankImage);
// force layout // force layout
blankImage._top = blankImage.offsetTop; blankImage.scrollTop = 0;
} }
dataTransfer.setDragImage && dataTransfer.setDragImage(blankImage, 0, 0); dataTransfer.setDragImage && dataTransfer.setDragImage(blankImage, 0, 0);
if (useragent.isOpera) { if (useragent.isOpera) {
@ -110,11 +110,14 @@ function DragdropHandler(mouseHandler) {
editor.renderer.$cursorLayer.setBlinking(true); editor.renderer.$cursorLayer.setBlinking(true);
} }
this.editor.unsetStyle("ace_dragging"); this.editor.unsetStyle("ace_dragging");
this.editor.renderer.setCursorStyle("");
}; };
this.onDragEnter = function(e) { this.onDragEnter = function(e) {
if (editor.getReadOnly() || !canAccept(e.dataTransfer)) if (editor.getReadOnly() || !canAccept(e.dataTransfer))
return; return;
x = e.clientX;
y = e.clientY;
if (!dragSelectionMarker) if (!dragSelectionMarker)
addDragMarker(); addDragMarker();
counter++; counter++;
@ -126,6 +129,8 @@ function DragdropHandler(mouseHandler) {
this.onDragOver = function(e) { this.onDragOver = function(e) {
if (editor.getReadOnly() || !canAccept(e.dataTransfer)) if (editor.getReadOnly() || !canAccept(e.dataTransfer))
return; return;
x = e.clientX;
y = e.clientY;
// Opera doesn't trigger dragenter event on drag start // Opera doesn't trigger dragenter event on drag start
if (!dragSelectionMarker) { if (!dragSelectionMarker) {
addDragMarker(); addDragMarker();
@ -133,8 +138,6 @@ function DragdropHandler(mouseHandler) {
} }
if (onMouseMoveTimer !== null) if (onMouseMoveTimer !== null)
onMouseMoveTimer = null; onMouseMoveTimer = null;
x = e.clientX;
y = e.clientY;
e.dataTransfer.dropEffect = dragOperation = getDropEffect(e); e.dataTransfer.dropEffect = dragOperation = getDropEffect(e);
return event.preventDefault(e); return event.preventDefault(e);
@ -150,7 +153,7 @@ function DragdropHandler(mouseHandler) {
}; };
this.onDrop = function(e) { this.onDrop = function(e) {
if (!dragSelectionMarker) if (!dragCursor)
return; return;
var dataTransfer = e.dataTransfer; var dataTransfer = e.dataTransfer;
if (isInternal) { if (isInternal) {
@ -264,6 +267,7 @@ function DragdropHandler(mouseHandler) {
if (editor.isFocused()) if (editor.isFocused())
editor.renderer.$cursorLayer.setBlinking(false); editor.renderer.$cursorLayer.setBlinking(false);
clearInterval(timerId); clearInterval(timerId);
onDragInterval();
timerId = setInterval(onDragInterval, 20); timerId = setInterval(onDragInterval, 20);
counter = 0; counter = 0;
event.addListener(document, "mousemove", onMouseMove); event.addListener(document, "mousemove", onMouseMove);
@ -279,6 +283,7 @@ function DragdropHandler(mouseHandler) {
if (editor.isFocused() && !isInternal) if (editor.isFocused() && !isInternal)
editor.renderer.$cursorLayer.setBlinking(!editor.getReadOnly()); editor.renderer.$cursorLayer.setBlinking(!editor.getReadOnly());
range = null; range = null;
dragCursor = null;
counter = 0; counter = 0;
autoScrollStartTime = null; autoScrollStartTime = null;
cursorMovedTime = null; cursorMovedTime = null;
@ -345,15 +350,19 @@ function DragdropHandler(mouseHandler) {
this.dragReadyEnd = function(e) { this.dragReadyEnd = function(e) {
this.editor.renderer.$cursorLayer.setBlinking(!this.editor.getReadOnly()); this.editor.renderer.$cursorLayer.setBlinking(!this.editor.getReadOnly());
this.editor.unsetStyle("ace_dragging"); this.editor.unsetStyle("ace_dragging");
this.editor.renderer.setCursorStyle("");
this.dragWaitEnd(); this.dragWaitEnd();
}; };
this.startDrag = function(){ this.startDrag = function(){
this.cancelDrag = false; this.cancelDrag = false;
var target = this.editor.container; var editor = this.editor;
var target = editor.container;
target.draggable = true; target.draggable = true;
this.editor.renderer.$cursorLayer.setBlinking(false); editor.renderer.$cursorLayer.setBlinking(false);
this.editor.setStyle("ace_dragging"); editor.setStyle("ace_dragging");
var cursorStyle = useragent.isWin ? "default" : "move";
editor.renderer.setCursorStyle(cursorStyle);
this.setState("dragReady"); this.setState("dragReady");
}; };

View file

@ -49,7 +49,7 @@ var MouseHandler = function(editor) {
var focusEditor = function(e) { var focusEditor = function(e) {
if (!editor.isFocused() && editor.textInput) if (!editor.isFocused() && editor.textInput)
editor.textInput.onContextMenu(e); editor.textInput.moveToMouse(e);
editor.focus() editor.focus()
}; };

View file

@ -58,17 +58,15 @@ module.exports = {
next(); next();
}, },
"test: double tap. issue #956" : function(done) { "test: double tap. issue #956" : function() {
// mouse up fired immediately after mouse down // mouse up fired immediately after mouse down
var target = this.editor.renderer.getMouseEventTarget(); var target = this.editor.renderer.getMouseEventTarget();
target.dispatchEvent(MouseEvent("down", {x: 1, y: 1})); target.dispatchEvent(MouseEvent("down", {x: 1, y: 1}));
target.dispatchEvent(MouseEvent("up", {x: 1, y: 1})); target.dispatchEvent(MouseEvent("up", {x: 1, y: 1}));
target.dispatchEvent(MouseEvent("down", {x: 1, y: 1, detail: 2})); target.dispatchEvent(MouseEvent("down", {x: 1, y: 1, detail: 2}));
target.dispatchEvent(MouseEvent("up", {x: 1, y: 1, detail: 2})); target.dispatchEvent(MouseEvent("up", {x: 1, y: 1, detail: 2}));
setTimeout(function() {
assert.equal(this.editor.getSelectedText(), "Juhu"); assert.equal(this.editor.getSelectedText(), "Juhu");
done();
}.bind(this));
} }
}; };

View file

@ -720,7 +720,7 @@ var Editor = require("./editor").Editor;
* @param {Boolean} skip If `true`, removes the active selection range * @param {Boolean} skip If `true`, removes the active selection range
* @method Editor.selectMore * @method Editor.selectMore
**/ **/
this.selectMore = function(dir, skip) { this.selectMore = function(dir, skip, stopAtFirst) {
var session = this.session; var session = this.session;
var sel = session.multiSelect; var sel = session.multiSelect;
@ -729,8 +729,8 @@ var Editor = require("./editor").Editor;
range = session.getWordRange(range.start.row, range.start.column); range = session.getWordRange(range.start.row, range.start.column);
range.cursor = dir == -1 ? range.start : range.end; range.cursor = dir == -1 ? range.start : range.end;
this.multiSelect.addRange(range); this.multiSelect.addRange(range);
// todo add option for sublime like behavior if (stopAtFirst)
// return; return;
} }
var needle = session.getTextRange(range); var needle = session.getTextRange(range);
@ -890,12 +890,12 @@ function isSamePoint(p1, p2) {
// adds multicursor support to a session // adds multicursor support to a session
exports.onSessionChange = function(e) { exports.onSessionChange = function(e) {
var session = e.session; var session = e.session;
if (!session.multiSelect) { if (session && !session.multiSelect) {
session.$selectionMarkers = []; session.$selectionMarkers = [];
session.selection.$initRangeList(); session.selection.$initRangeList();
session.multiSelect = session.selection; session.multiSelect = session.selection;
} }
this.multiSelect = session.multiSelect; this.multiSelect = session && session.multiSelect;
var oldSession = e.oldSession; var oldSession = e.oldSession;
if (oldSession) { if (oldSession) {
@ -907,16 +907,16 @@ exports.onSessionChange = function(e) {
oldSession.multiSelect.anchor.off("change", this.$checkMultiselectChange); oldSession.multiSelect.anchor.off("change", this.$checkMultiselectChange);
} }
if (session) {
session.multiSelect.on("addRange", this.$onAddRange); session.multiSelect.on("addRange", this.$onAddRange);
session.multiSelect.on("removeRange", this.$onRemoveRange); session.multiSelect.on("removeRange", this.$onRemoveRange);
session.multiSelect.on("multiSelect", this.$onMultiSelect); session.multiSelect.on("multiSelect", this.$onMultiSelect);
session.multiSelect.on("singleSelect", this.$onSingleSelect); session.multiSelect.on("singleSelect", this.$onSingleSelect);
session.multiSelect.lead.on("change", this.$checkMultiselectChange); session.multiSelect.lead.on("change", this.$checkMultiselectChange);
session.multiSelect.anchor.on("change", this.$checkMultiselectChange); session.multiSelect.anchor.on("change", this.$checkMultiselectChange);
}
// this.$onSelectionChange = this.onSelectionChange.bind(this); if (session && this.inMultiSelectMode != session.selection.inMultiSelectMode) {
if (this.inMultiSelectMode != session.selection.inMultiSelectMode) {
if (session.selection.inMultiSelectMode) if (session.selection.inMultiSelectMode)
this.$onMultiSelect(); this.$onMultiSelect();
else else

View file

@ -37,7 +37,6 @@ var oop = require("./lib/oop");
/** /**
* @class PlaceHolder * @class PlaceHolder
* *
*
**/ **/
/** /**
@ -48,7 +47,6 @@ var oop = require("./lib/oop");
* - mainClass (String): * - mainClass (String):
* - othersClass (String): * - othersClass (String):
* *
*
* @constructor * @constructor
**/ **/
@ -94,6 +92,10 @@ var PlaceHolder = function(session, length, pos, others, mainClass, othersClass)
var session = this.session; var session = this.session;
var pos = this.$pos; var pos = this.$pos;
this.selectionBefore = session.selection.toJSON();
if (session.selection.inMultiSelectMode)
session.selection.toSingleRange();
this.pos = doc.createAnchor(pos.row, pos.column); this.pos = doc.createAnchor(pos.row, pos.column);
this.markerId = session.addMarker(new Range(pos.row, pos.column, pos.row, pos.column + this.length), this.mainClass, null, false); this.markerId = session.addMarker(new Range(pos.row, pos.column, pos.row, pos.column + this.length), this.mainClass, null, false);
this.pos.on("change", function(event) { this.pos.on("change", function(event) {
@ -218,7 +220,7 @@ var PlaceHolder = function(session, length, pos, others, mainClass, othersClass)
**/ **/
this.onCursorChange = function(event) { this.onCursorChange = function(event) {
if (this.$updating) return; if (this.$updating || !this.session) return;
var pos = this.session.selection.getCursor(); var pos = this.session.selection.getCursor();
if (pos.row === this.pos.row && pos.column >= this.pos.column && pos.column <= this.pos.column + this.length) { if (pos.row === this.pos.row && pos.column >= this.pos.column && pos.column <= this.pos.column + this.length) {
this.showOtherMarkers(); this.showOtherMarkers();
@ -245,6 +247,7 @@ var PlaceHolder = function(session, length, pos, others, mainClass, othersClass)
this.others[i].detach(); this.others[i].detach();
} }
this.session.setUndoSelect(true); this.session.setUndoSelect(true);
this.session = null;
}; };
/** /**
@ -261,6 +264,8 @@ var PlaceHolder = function(session, length, pos, others, mainClass, othersClass)
for (var i = 0; i < undosRequired; i++) { for (var i = 0; i < undosRequired; i++) {
undoManager.undo(true); undoManager.undo(true);
} }
if (this.selectionBefore)
this.session.selection.fromJSON(this.selectionBefore);
}; };
}).call(PlaceHolder.prototype); }).call(PlaceHolder.prototype);

View file

@ -39,7 +39,7 @@ var Range = require("./range").Range;
/** /**
* Contains the cursor position and the text selection of an edit session. * Contains the cursor position and the text selection of an edit session.
* *
* The row/columns used in the selection are in document coordinates representing ths coordinates as thez appear in the document before applying soft wrap and folding. * The row/columns used in the selection are in document coordinates representing the coordinates as they appear in the document before applying soft wrap and folding.
* @class Selection * @class Selection
**/ **/
@ -143,7 +143,7 @@ var Selection = function(session) {
**/ **/
this.getSelectionAnchor = function() { this.getSelectionAnchor = function() {
if (this.$isEmpty) if (this.$isEmpty)
return this.getSelectionLead() return this.getSelectionLead();
else else
return this.anchor.getPosition(); return this.anchor.getPosition();
}; };
@ -168,7 +168,7 @@ var Selection = function(session) {
if (this.$isEmpty) { if (this.$isEmpty) {
this.moveCursorTo(this.lead.row, this.lead.column + columns); this.moveCursorTo(this.lead.row, this.lead.column + columns);
return; return;
}; }
var anchor = this.getSelectionAnchor(); var anchor = this.getSelectionAnchor();
var lead = this.getSelectionLead(); var lead = this.getSelectionLead();
@ -474,7 +474,7 @@ var Selection = function(session) {
if (fold = this.session.getFoldAt(cursor.row, cursor.column, -1)) { if (fold = this.session.getFoldAt(cursor.row, cursor.column, -1)) {
this.moveCursorTo(fold.start.row, fold.start.column); this.moveCursorTo(fold.start.row, fold.start.column);
} else if (cursor.column == 0) { } else if (cursor.column === 0) {
// cursor is a line (start // cursor is a line (start
if (cursor.row > 0) { if (cursor.row > 0) {
this.moveCursorTo(cursor.row - 1, this.doc.getLine(cursor.row - 1).length); this.moveCursorTo(cursor.row - 1, this.doc.getLine(cursor.row - 1).length);
@ -639,7 +639,7 @@ var Selection = function(session) {
var str = this.session.getFoldStringAt(row, column, -1); var str = this.session.getFoldStringAt(row, column, -1);
if (str == null) { if (str == null) {
str = this.doc.getLine(row).substring(0, column) str = this.doc.getLine(row).substring(0, column);
} }
var leftOfCursor = lang.stringReverse(str); var leftOfCursor = lang.stringReverse(str);
@ -691,13 +691,13 @@ var Selection = function(session) {
index ++; index ++;
if (whitespaceRe.test(ch)) { if (whitespaceRe.test(ch)) {
if (index > 2) { if (index > 2) {
index-- index--;
break; break;
} else { } else {
while ((ch = rightOfCursor[index]) && whitespaceRe.test(ch)) while ((ch = rightOfCursor[index]) && whitespaceRe.test(ch))
index ++; index ++;
if (index > 2) if (index > 2)
break break;
} }
} }
} }
@ -722,11 +722,11 @@ var Selection = function(session) {
var l = this.doc.getLength(); var l = this.doc.getLength();
do { do {
row++; row++;
rightOfCursor = this.doc.getLine(row) rightOfCursor = this.doc.getLine(row);
} while (row < l && /^\s*$/.test(rightOfCursor)) } while (row < l && /^\s*$/.test(rightOfCursor));
if (!/^\s+/.test(rightOfCursor)) if (!/^\s+/.test(rightOfCursor))
rightOfCursor = "" rightOfCursor = "";
column = 0; column = 0;
} }
@ -744,15 +744,15 @@ var Selection = function(session) {
return this.moveCursorTo(fold.start.row, fold.start.column); return this.moveCursorTo(fold.start.row, fold.start.column);
var line = this.session.getLine(row).substring(0, column); var line = this.session.getLine(row).substring(0, column);
if (column == 0) { if (column === 0) {
do { do {
row--; row--;
line = this.doc.getLine(row); line = this.doc.getLine(row);
} while (row > 0 && /^\s*$/.test(line)) } while (row > 0 && /^\s*$/.test(line));
column = line.length; column = line.length;
if (!/\s+$/.test(line)) if (!/\s+$/.test(line))
line = "" line = "";
} }
var leftOfCursor = lang.stringReverse(line); var leftOfCursor = lang.stringReverse(line);
@ -859,12 +859,12 @@ var Selection = function(session) {
this.lead.detach(); this.lead.detach();
this.anchor.detach(); this.anchor.detach();
this.session = this.doc = null; this.session = this.doc = null;
} };
this.fromOrientedRange = function(range) { this.fromOrientedRange = function(range) {
this.setSelectionRange(range, range.cursor == range.start); this.setSelectionRange(range, range.cursor == range.start);
this.$desiredColumn = range.desiredColumn || this.$desiredColumn; this.$desiredColumn = range.desiredColumn || this.$desiredColumn;
} };
this.toOrientedRange = function(range) { this.toOrientedRange = function(range) {
var r = this.getRange(); var r = this.getRange();
@ -880,7 +880,7 @@ var Selection = function(session) {
range.cursor = this.isBackwards() ? range.start : range.end; range.cursor = this.isBackwards() ? range.start : range.end;
range.desiredColumn = this.$desiredColumn; range.desiredColumn = this.$desiredColumn;
return range; return range;
} };
/** /**
* Saves the current cursor position and calls `func` that can change the cursor * Saves the current cursor position and calls `func` that can change the cursor
@ -901,7 +901,7 @@ var Selection = function(session) {
} finally { } finally {
this.moveCursorToPosition(start); this.moveCursorToPosition(start);
} }
} };
this.toJSON = function() { this.toJSON = function() {
if (this.rangeCount) { if (this.rangeCount) {
@ -944,10 +944,10 @@ var Selection = function(session) {
for (var i = this.ranges.length; i--; ) { for (var i = this.ranges.length; i--; ) {
if (!this.ranges[i].isEqual(data[i])) if (!this.ranges[i].isEqual(data[i]))
return false return false;
} }
return true; return true;
} };
}).call(Selection.prototype); }).call(Selection.prototype);

View file

@ -497,6 +497,10 @@ var SnippetManager = function() {
var snippetMap = this.snippetMap; var snippetMap = this.snippetMap;
var snippetNameMap = this.snippetNameMap; var snippetNameMap = this.snippetNameMap;
var self = this; var self = this;
if (!snippets)
snippets = [];
function wrapRegexp(src) { function wrapRegexp(src) {
if (src && !/^\^?\(.*\)\$?$|^\\b$/.test(src)) if (src && !/^\^?\(.*\)\$?$|^\\b$/.test(src))
src = "(?:" + src + ")"; src = "(?:" + src + ")";
@ -549,7 +553,7 @@ var SnippetManager = function() {
s.endTriggerRe = new RegExp(s.endTrigger, "", true); s.endTriggerRe = new RegExp(s.endTrigger, "", true);
} }
if (snippets.content) if (snippets && snippets.content)
addSnippet(snippets); addSnippet(snippets);
else if (Array.isArray(snippets)) else if (Array.isArray(snippets))
snippets.forEach(addSnippet); snippets.forEach(addSnippet);

Some files were not shown because too many files have changed in this diff Show more