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>
@ -1778,4 +1778,4 @@
<script defer src="./resources/javascripts/disqus-ext.js"></script> <script defer src="./resources/javascripts/disqus-ext.js"></script>
<script defer src="./resources/javascripts/ga.js"></script> <script defer src="./resources/javascripts/ga.js"></script>
<div id="disqus_thread"></div> <div id="disqus_thread"></div>
</div> </div>

View file

@ -51,7 +51,7 @@ function foo() {
function inject(options, callback) { function inject(options, callback) {
var baseUrl = options.baseUrl || "../../src-noconflict"; var baseUrl = options.baseUrl || "../../src-noconflict";
var load = function(path, callback) { var load = function(path, callback) {
var head = document.getElementsByTagName('head')[0]; var head = document.getElementsByTagName('head')[0];
var s = document.createElement('script'); var s = document.createElement('script');
@ -87,7 +87,7 @@ function inject(options, callback) {
// Call the inject function to load the ace files. // Call the inject function to load the ace files.
var textAce; var textAce;
inject({}, function () { inject({}, function () {
// Transform the textarea on the page into an ace editor. // Transform the textarea on the page into an ace editor.
var t = document.querySelector("textarea"); var t = document.querySelector("textarea");
textAce = ace.require("ace/ext/textarea").transformTextarea(t); textAce = ace.require("ace/ext/textarea").transformTextarea(t);
setTimeout(function(){textAce.setDisplaySettings(true)}); setTimeout(function(){textAce.setDisplaySettings(true)});

View file

@ -8,8 +8,8 @@
body { body {
overflow: hidden; overflow: hidden;
} }
#editor { #editor {
margin: 0; margin: 0;
position: absolute; position: absolute;
top: 0; top: 0;
@ -27,7 +27,7 @@
alert("Ace Rocks " + items[i]); alert("Ace Rocks " + items[i]);
} }
}</pre> }</pre>
<script src="src-noconflict/ace.js" type="text/javascript" charset="utf-8"></script> <script src="src-noconflict/ace.js" type="text/javascript" charset="utf-8"></script>
<script> <script>
var editor = ace.edit("editor"); var editor = ace.edit("editor");

View file

@ -3,7 +3,7 @@
* *
* Copyright (c) 2010, Ajax.org B.V. * Copyright (c) 2010, Ajax.org B.V.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright * * Redistributions of source code must retain the above copyright
@ -14,7 +14,7 @@
* * Neither the name of Ajax.org B.V. nor the * * Neither the name of Ajax.org B.V. nor the
* names of its contributors may be used to endorse or promote products * names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission. * derived from this software without specific prior written permission.
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * 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 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
@ -65,7 +65,7 @@ var _define = function(module, deps, payload) {
_define.modules = {}; _define.modules = {};
_define.payloads = {}; _define.payloads = {};
} }
_define.payloads[module] = payload; _define.payloads[module] = payload;
_define.modules[module] = null; _define.modules[module] = null;
}; };
@ -160,7 +160,7 @@ var lookup = function(parentId, moduleName) {
function exportAce(ns) { function exportAce(ns) {
var require = function(module, callback) { var require = function(module, callback) {
return _require("", module, callback); return _require("", module, callback);
}; };
var root = global; var root = global;
if (ns) { if (ns) {

View file

@ -4,7 +4,7 @@ body {
margin:0; margin:0;
padding:0; padding:0;
background-color:#e6f5fc; background-color:#e6f5fc;
} }
H2, H3, H4 { H2, H3, H4 {
@ -58,7 +58,7 @@ PRE{
position:relative; position:relative;
overflow:hidden; overflow:hidden;
background: url(images/background.png) repeat-x 0 0; background: url(images/background.png) repeat-x 0 0;
border-bottom:1px solid #c9e8fa; border-bottom:1px solid #c9e8fa;
} }
#header .content .signature { #header .content .signature {
@ -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

@ -46,4 +46,10 @@ body {
position: absolute; position: absolute;
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,39 +1,49 @@
var editor; var editor;
var embedded_editor; var embedded_editor;
$(function() { $(function() {
ace.config.set("workerPath", "build/src-min"); if (typeof ace !== "undefined") {
editor = ace.edit("ace_editor_demo"); ace.config.set("workerPath", "build/src-min");
editor.container.style.opacity = ""; editor = ace.edit("ace_editor_demo");
embedded_editor = ace.edit("embedded_ace_code"); editor.container.style.opacity = "";
embedded_editor.container.style.opacity = ""; embedded_editor = ace.edit("embedded_ace_code");
embedded_editor.session.setMode("ace/mode/html"); embedded_editor.container.style.opacity = "";
embedded_editor.setAutoScrollEditorIntoView(true); embedded_editor.session.setMode("ace/mode/html");
embedded_editor.setOption("maxLines", 40); embedded_editor.setAutoScrollEditorIntoView(true);
embedded_editor.setOption("maxLines", 40);
editor.setOptions({
maxLines: 30,
mode: "ace/mode/javascript",
autoScrollEditorIntoView: true
});
ace.config.loadModule("ace/ext/emmet", function() {
ace.require("ace/lib/net").loadScript("http://nightwing.github.io/emmet-core/emmet.js", function() {
embedded_editor.setOption("enableEmmet", true);
editor.setOption("enableEmmet", true);
});
});
ace.config.loadModule("ace/ext/language_tools", function() {
embedded_editor.setOptions({
enableSnippets: true,
enableBasicAutocompletion: true
});
editor.setOptions({ editor.setOptions({
enableSnippets: true, maxLines: 30,
enableBasicAutocompletion: true mode: "ace/mode/javascript",
autoScrollEditorIntoView: true
}); });
});
ace.config.loadModule("ace/ext/emmet", function() {
ace.require("ace/lib/net").loadScript("http://nightwing.github.io/emmet-core/emmet.js", function() {
embedded_editor.setOption("enableEmmet", true);
editor.setOption("enableEmmet", true);
});
});
ace.config.loadModule("ace/ext/language_tools", function() {
embedded_editor.setOptions({
enableSnippets: true,
enableBasicAutocompletion: true
});
editor.setOptions({
enableSnippets: true,
enableBasicAutocompletion: true
});
});
} else {
document.body.insertAdjacentHTML("afterbegin", '<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();
@ -137,22 +147,22 @@ $(function() {
}); });
}); });
$(window).on("hashchange", function(e) { $(window).on("hashchange", function(e) {
_gaq.push(['_trackPageview',location.pathname + location.search + location.hash]); _gaq.push(['_trackPageview',location.pathname + location.search + location.hash]);
tabs.each(function() { tabs.each(function() {
var idx = $.bbq.getState("nav") || "about"; var idx = $.bbq.getState("nav") || "about";
var section = e.fragment.split("&")[1] || ""; var section = e.fragment.split("&")[1] || "";
$(this).find(tab_a_selector + "[href='#" + idx + "']").triggerHandler('click'); $(this).find(tab_a_selector + "[href='#" + idx + "']").triggerHandler('click');
// handles dropping in from new link // handles dropping in from new link
var api = $.bbq.getState("api"); var api = $.bbq.getState("api");
if (api) { if (api) {
$(tab_a_selector + "[href='./api/" + api + ".html']").triggerHandler('click'); $(tab_a_selector + "[href='./api/" + api + ".html']").triggerHandler('click');
} }
}); });
}).trigger("hashchange"); }).trigger("hashchange");
highlight(); highlight();
}); });
@ -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 = "";
el.innerHTML = ''; if (el && /input|textarea/i.test(el.tagName)) {
var oldNode = el;
value = oldNode.value;
el = dom.createElement("pre");
oldNode.parentNode.replaceChild(el, oldNode);
} else {
value = dom.getInnerText(el);
el.innerHTML = '';
}
var doc = exports.createEditSession(value);
var editor = new Editor(new Renderer(el)); 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;
}
if (this.popup)
this.popup.hide(); this.popup.hide();
}
if (this.base)
this.base.detach();
this.activated = false; this.activated = false;
this.completions = this.base = null; this.completions = this.base = null;
}; };
@ -205,9 +207,9 @@ 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;
editor.completers.forEach(function(completer, i) { editor.completers.forEach(function(completer, i) {
@ -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

@ -80,8 +80,8 @@ 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; }
}
}
else
this.$worker = null; 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);
foldLine.shiftRow(len); if (foldLine) {
foldLine.addRemoveChars( foldLine.shiftRow(len);
lastRow, 0, end.column - start.column); foldLine.addRemoveChars(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();
@ -572,28 +577,28 @@ var Editor = function(renderer, session) {
token = iterator.stepForward(); token = iterator.stepForward();
if (token && token.value === tag && token.type.indexOf('tag-name') !== -1) { if (token && token.value === tag && token.type.indexOf('tag-name') !== -1) {
if (prevToken.value==='<'){ if (prevToken.value === '<'){
depth++; depth++;
} else if (prevToken.value==='</'){ } else if (prevToken.value === '</'){
depth--; depth--;
} }
} }
} while (token && depth>=0); } while (token && depth >= 0);
}else{ } else {
//find opening tag //find opening tag
do { do {
token = prevToken; token = prevToken;
prevToken = iterator.stepBackward(); prevToken = iterator.stepBackward();
if(token && token.value === tag && token.type.indexOf('tag-name') !== -1) { if (token && token.value === tag && token.type.indexOf('tag-name') !== -1) {
if (prevToken.value==='<') { if (prevToken.value === '<') {
depth++; depth++;
} else if( prevToken.value==='</') { } else if (prevToken.value === '</') {
depth--; depth--;
} }
} }
} while (prevToken && depth<=0); } while (prevToken && depth <= 0);
//select tag again //select tag again
iterator.stepForward(); iterator.stepForward();
@ -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;
@ -2019,12 +2023,12 @@ var Editor = function(renderer, session) {
do { do {
if (token.value.match(/[{}()\[\]]/g)) { if (token.value.match(/[{}()\[\]]/g)) {
for (; i<token.value.length && !found; i++) { for (; i < token.value.length && !found; i++) {
if (!brackets[token.value[i]]) { if (!brackets[token.value[i]]) {
continue; continue;
} }
bracketType = brackets[token.value[i]]+'.'+token.type.replace("rparen", "lparen"); bracketType = brackets[token.value[i]] + '.' + token.type.replace("rparen", "lparen");
if (isNaN(depth[bracketType])) { if (isNaN(depth[bracketType])) {
depth[bracketType] = 0; depth[bracketType] = 0;
@ -2035,27 +2039,29 @@ var Editor = function(renderer, session) {
case '[': case '[':
case '{': case '{':
depth[bracketType]++; depth[bracketType]++;
break; break;
case ')': case ')':
case ']': case ']':
case '}': case '}':
depth[bracketType]--; depth[bracketType]--;
if (depth[bracketType]===-1) { if (depth[bracketType] === -1) {
matchType = 'bracket'; matchType = 'bracket';
found = true; found = true;
} }
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,37 +2079,35 @@ 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) {
range = new Range( range = new Range(
iterator.getCurrentTokenRow(), iterator.getCurrentTokenRow(),
iterator.getCurrentTokenColumn()+i-1, iterator.getCurrentTokenColumn() + i - 1,
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') { }
if (token && token.type.indexOf('tag-name') !== -1) else if (matchType === 'tag') {
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(),
iterator.getCurrentTokenColumn()-2 iterator.getCurrentTokenColumn() - 2
); );
//find matching tag //find matching tag
@ -2115,17 +2119,18 @@ var Editor = function(renderer, session) {
if (prevToken) { if (prevToken) {
if (prevToken.type.indexOf('tag-close') !== -1) { if (prevToken.type.indexOf('tag-close') !== -1) {
range.setEnd(iterator.getCurrentTokenRow(), iterator.getCurrentTokenColumn()+1); range.setEnd(iterator.getCurrentTokenRow(), iterator.getCurrentTokenColumn() + 1);
} }
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]--;
} }
if (depth[tag]===0) if (depth[tag] === 0)
found = true; found = true;
} }
} }
@ -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 var onContextMenu = function(e) {
if (!useragent.isGecko || useragent.isMac) { host.textInput.onContextMenu(e);
var onContextMenu = function(e) { onContextMenuClose();
host.textInput.onContextMenu(e); };
onContextMenuClose(); event.addListener(host.renderer.scroller, "contextmenu", onContextMenu);
}; event.addListener(text, "contextmenu", onContextMenu);
event.addListener(host.renderer.scroller, "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,7 +58,8 @@ 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;
session.on("change", this.$updateAnnotations); if (session)
session.on("change", this.$updateAnnotations);
}; };
this.addGutterDecoration = function(row, className){ this.addGutterDecoration = function(row, className){

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,7 +95,8 @@ var Text = function(parentEl) {
}; };
this.setSession = function(session) { this.setSession = function(session) {
this.session = session; this.session = session;
this.$computeTabString(); if (session)
this.$computeTabString();
}; };
this.showInvisibles = false; this.showInvisibles = false;
@ -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

@ -191,6 +191,8 @@ exports.addMultiMouseDownListener = function(el, timeouts, eventHandler, callbac
startY = e.clientY; startY = e.clientY;
} }
} }
e._clicks = clicks;
eventHandler[callbackName]("mousedown", e); eventHandler[callbackName]("mousedown", e);
@ -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");
/* /*
@ -136,7 +138,7 @@ var Keys = (function() {
(function() { (function() {
var mods = ["cmd", "ctrl", "alt", "shift"]; var mods = ["cmd", "ctrl", "alt", "shift"];
for (var i = Math.pow(2, mods.length); i--;) { for (var i = Math.pow(2, mods.length); i--;) {
ret.KEY_MODS[i] = mods.filter(function(x) { ret.KEY_MODS[i] = mods.filter(function(x) {
return i & ret.KEY_MODS[x]; return i & ret.KEY_MODS[x];
}).join("-") + "-"; }).join("-") + "-";

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

@ -500,4 +500,4 @@
["paren.rparen.lsl","}"] ["paren.rparen.lsl","}"]
],[ ],[
"start" "start"
]] ]]

View file

@ -345,4 +345,4 @@
["text"," "], ["text"," "],
["comment","--[[ blah ]]"], ["comment","--[[ blah ]]"],
["paren.rparen",")"] ["paren.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",
@ -354,9 +350,49 @@ 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

@ -4,12 +4,30 @@ define(function(require, exports, module) {
var oop = require("../lib/oop"); 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",
token : "string", // ' string next : [{
regex : "'.*?'" token : "constant.language.escape",
regex : /\\./
}, {
token : "string",
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,10 +53,10 @@ 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);
exports.Mode = Mode; exports.Mode = Mode;
}); });

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
@ -177,10 +177,10 @@ var SJSHighlightRules = function() {
// for use within interpreted contexts // for use within interpreted contexts
// without interfering with context nesting // without interfering with context nesting
var embeddableRules = []; var embeddableRules = [];
for (var i=0; i<this.$rules.no_regex.length; i++) { for (var i=0; i < this.$rules.no_regex.length; i++) {
var rule = this.$rules.no_regex[i]; var rule = this.$rules.no_regex[i];
var token = String(rule.token); var token = String(rule.token);
if(token.indexOf('paren') == -1 && (!rule.next || rule.next.isContextAware)) { if (token.indexOf('paren') == -1 && (!rule.next || rule.next.isContextAware)) {
embeddableRules.push(rule); embeddableRules.push(rule);
} }
}; };

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' } ] } ],

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

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)
} editor.selection.moveToPosition(pos);
else if (!this.$clickSelection) { if (!waitForClickSelection)
editor.selection.moveToPosition(pos);
}
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()
}; };

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