This commit is contained in:
Resolver Developers 2011-08-31 16:21:13 +01:00
commit cf44a62780
178 changed files with 11826 additions and 14910 deletions

View file

@ -95,7 +95,7 @@ canon.addCommand({
name: "find",
bindKey: bindKey("Ctrl-F", "Command-F"),
exec: function(env, args, request) {
var needle = prompt("Find:");
var needle = prompt("Find:", env.editor.getCopyText());
env.editor.find(needle);
}
});
@ -103,7 +103,7 @@ canon.addCommand({
name: "replace",
bindKey: bindKey("Ctrl-R", "Command-Option-F"),
exec: function(env, args, request) {
var needle = prompt("Find:");
var needle = prompt("Find:", env.editor.getCopyText());
if (!needle)
return;
var replacement = prompt("Replacement:");

View file

@ -1,7 +1,10 @@
@import url(http://fonts.googleapis.com/css?family=Droid+Sans+Mono);
.ace_editor {
position: absolute;
overflow: hidden;
font-family: Monaco, "Menlo", "Courier New", monospace;
font-family: 'Monaco', 'Menlo', 'Droid Sans Mono', 'Courier New', monospace;
font-size: 12px;
}

View file

@ -831,9 +831,8 @@ var EditSession = function(text, mode) {
this.indentRows = function(startRow, endRow, indentString) {
indentString = indentString.replace(/\t/g, this.getTabString());
for (var row=startRow; row<=endRow; row++) {
for (var row=startRow; row<=endRow; row++)
this.insert({row: row, column:0}, indentString);
}
};
this.outdentRows = function (range) {

View file

@ -47,7 +47,7 @@ var lang = require("pilot/lang");
var EditSession = require("ace/edit_session").EditSession;
var Editor = require("ace/editor").Editor;
var UndoManager = require("ace/undomanager").UndoManager;
var MockRenderer = require("ace/test/mockrenderer");
var MockRenderer = require("ace/test/mockrenderer").MockRenderer;
var Range = require("ace/range").Range;
var assert = require("ace/test/assertions");

View file

@ -263,13 +263,10 @@ var Editor =function(renderer, session) {
// Safari needs the timeout
// iOS and Firefox need it called immediately
// to be on the save side we do both
// except for IE
var _self = this;
if (!useragent.isIE) {
setTimeout(function() {
_self.textInput.focus();
});
}
setTimeout(function() {
_self.textInput.focus();
});
this.textInput.focus();
};
@ -405,20 +402,23 @@ var Editor =function(renderer, session) {
};
this.getCopyText = function() {
if (!this.selection.isEmpty()) {
return this.session.getTextRange(this.getSelectionRange());
}
else {
return "";
}
var text = "";
if (!this.selection.isEmpty())
text = this.session.getTextRange(this.getSelectionRange());
this._emit("copy", text);
return text;
};
this.onCut = function() {
if (this.$readOnly)
return;
var range = this.getSelectionRange();
this._emit("cut", range);
if (!this.selection.isEmpty()) {
this.session.remove(this.getSelectionRange())
this.session.remove(range)
this.clearSelection();
}
};
@ -513,14 +513,15 @@ var Editor =function(renderer, session) {
session.remove(new Range(row, 0, row, i));
}
session.indentRows(cursor.row + 1, end.row, lineIndent);
} else {
if (shouldOutdent) {
mode.autoOutdent(lineState, session, cursor.row);
}
}
if (shouldOutdent)
mode.autoOutdent(lineState, session, cursor.row);
};
this.onTextInput = function(text, notPasted) {
if (!notPasted)
this._emit("paste", text);
// In case the text was not pasted and we got only one character, then
// handel it as a command key stroke.
if (notPasted && text.length == 1) {
@ -826,7 +827,7 @@ var Editor =function(renderer, session) {
var range = new Range(rows.first, 0, rows.last+1, 0)
else
var range = new Range(
rows.first-1, this.session.getLine(rows.first).length,
rows.first-1, this.session.getLine(rows.first-1).length,
rows.last, this.session.getLine(rows.last).length
);
this.session.remove(range);

View file

@ -46,7 +46,7 @@ var EditSession = require("ace/edit_session").EditSession;
var Editor = require("ace/editor").Editor;
var Text = require("ace/mode/text").Mode;
var JavaScriptMode = require("ace/mode/javascript").Mode;
var MockRenderer = require("ace/test/mockrenderer");
var MockRenderer = require("ace/test/mockrenderer").MockRenderer;
var assert = require("ace/test/assertions");
module.exports = {
@ -54,6 +54,8 @@ module.exports = {
setUp : function(next) {
this.session1 = new EditSession(["abc", "def"]);
this.session2 = new EditSession(["ghi", "jkl"]);
this.editor = new Editor(new MockRenderer());
next();
},

View file

@ -45,7 +45,7 @@ define(function(require, exports, module) {
var EditSession = require("ace/edit_session").EditSession;
var Editor = require("ace/editor").Editor;
var MockRenderer = require("ace/test/mockrenderer");
var MockRenderer = require("ace/test/mockrenderer").MockRenderer;
var TextMode = require("ace/mode/text").Mode;
var assert = require("ace/test/assertions");

View file

@ -44,7 +44,7 @@ define(function(require, exports, module) {
var EditSession = require("ace/edit_session").EditSession;
var Editor = require("ace/editor").Editor;
var MockRenderer = require("ace/test/mockrenderer");
var MockRenderer = require("ace/test/mockrenderer").MockRenderer;
var assert = require("ace/test/assertions");
module.exports = {

View file

@ -46,7 +46,7 @@ var EditSession = require("ace/edit_session").EditSession;
var Editor = require("ace/editor").Editor;
var JavaScriptMode = require("ace/mode/javascript").Mode;
var UndoManager = require("ace/undomanager").UndoManager;
var MockRenderer = require("ace/test/mockrenderer");
var MockRenderer = require("ace/test/mockrenderer").MockRenderer;
var assert = require("ace/test/assertions");
module.exports = {
@ -99,12 +99,16 @@ module.exports = {
},
"test: delete last should also delete the new line of the previous line" : function() {
var session = new EditSession(["a", "b", "c"].join("\n"));
var session = new EditSession(["a", "b", "c", ""].join("\n"));
var editor = new Editor(new MockRenderer(), session);
editor.moveCursorTo(2, 1);
editor.removeLines();
editor.moveCursorTo(3, 0);
editor.removeLines();
assert.equal(session.toString(), "a\nb\nc");
assert.position(editor.getCursorPosition(), 2, 1);
editor.removeLines();
assert.equal(session.toString(), "a\nb");
assert.position(editor.getCursorPosition(), 1, 1);
},

View file

@ -40,6 +40,22 @@ define(function(require, exports, module) {
var StateHandler = require("ace/keyboard/state_handler").StateHandler;
var matchCharacterOnly = require("ace/keyboard/state_handler").matchCharacterOnly;
var vimcommand = function(key, exec, then) {
return {
regex: [ "([0-9]*)", key ],
exec: exec,
params: [
{
name: "times",
match: 1,
type: "number",
defaultValue: 1
}
],
then: then
}
}
var vimStates = {
start: [
{
@ -75,78 +91,20 @@ var vimStates = {
exec: "overwrite",
then: "replaceMode"
},
{
regex: [ "([0-9]*)", "(k|up)" ],
exec: "golineup",
params: [
{
name: "times",
match: 1,
type: "number",
defaultValue: 1
}
]
},
{
regex: [ "([0-9]*)", "(j|down|enter)" ],
exec: "golinedown",
params: [
{
name: "times",
match: 1,
type: "number",
defaultValue: 1
}
]
},
{
regex: [ "([0-9]*)", "(l|right)" ],
exec: "gotoright",
params: [
{
name: "times",
match: 1,
type: "number",
defaultValue: 1
}
]
},
{
regex: [ "([0-9]*)", "(h|left)" ],
exec: "gotoleft",
params: [
{
name: "times",
match: 1,
type: "number",
defaultValue: 1
}
]
},
vimcommand("(k|up)", "golineup"),
vimcommand("(j|down)", "golinedown"),
vimcommand("(l|right)", "golineright"),
vimcommand("(h|left)", "golineleft"),
{
key: "shift-g",
exec: "gotoend"
},
{
key: "b",
exec: "gotowordleft"
},
{
key: "e",
exec: "gotowordright"
},
{
key: "x",
exec: "del"
},
{
key: "shift-x",
exec: "backspace"
},
{
key: "shift-d",
exec: "removetolineend"
},
vimcommand("b", "gotowordleft"),
vimcommand("e", "gotowordright"),
vimcommand("x", "del"),
vimcommand("shift-x", "backspace"),
vimcommand("shift-d", "removetolineend"),
vimcommand("u", "undo"), // [count] on this may/may not work, depending on browser implementation...
{
comment: "Catch some keyboard input to stop it here",
match: matchCharacterOnly

View file

@ -46,6 +46,8 @@ var dom = require("pilot/dom");
var TextInput = function(parentNode, host) {
var text = dom.createElement("textarea");
if (useragent.isTouchPad)
text.setAttribute('x-palm-disable-auto-cap',true);
text.style.left = "-10000px";
parentNode.appendChild(text);
@ -57,6 +59,12 @@ var TextInput = function(parentNode, host) {
var pasted = false;
var tempStyle = '';
function select() {
try {
text.select();
} catch (e) {}
};
function sendText(valueToSend) {
if (!copied) {
var value = valueToSend || text.value;
@ -82,7 +90,7 @@ var TextInput = function(parentNode, host) {
// Safari doesn't fire copy events if no text is selected
text.value = PLACEHOLDER;
text.select();
select();
}
var onTextInput = function(e) {
@ -92,8 +100,8 @@ var TextInput = function(parentNode, host) {
}, 0);
};
var onKeyPress = function(e) {
if (useragent.isIE && text.value.charCodeAt(0) > 128) return;
var onPropertyChange = function(e) {
if (useragent.isOldIE && text.value.charCodeAt(0) > 128) return;
setTimeout(function() {
if (!inCompostion)
sendText();
@ -123,12 +131,12 @@ var TextInput = function(parentNode, host) {
text.value = copyText;
else
e.preventDefault();
text.select();
select();
setTimeout(function () {
sendText();
}, 0);
};
var onCut = function(e) {
copied = true;
var copyText = host.getCopyText();
@ -137,14 +145,14 @@ var TextInput = function(parentNode, host) {
host.onCut();
} else
e.preventDefault();
text.select();
select();
setTimeout(function () {
sendText();
}, 0);
};
event.addCommandKeyListener(text, host.onCommandKey.bind(host));
if (useragent.isIE) {
if (useragent.isOldIE) {
var keytable = { 13:1, 27:1 };
event.addListener(text, "keyup", function (e) {
if (inCompostion && (!text.value || keytable[e.keyCode]))
@ -155,22 +163,11 @@ var TextInput = function(parentNode, host) {
inCompostion ? onCompositionUpdate() : onCompositionStart();
});
};
if (text.attachEvent) {
// Old IE + Opera
event.addListener(text, "propertychange", onKeyPress);
}
else {
if (useragent.isChrome || useragent.isSafari)
event.addListener(text, "textInput", onTextInput);
else if (useragent.isIE)
// IE9
event.addListener(text, "textinput", onTextInput);
else
// All browsers except old IE
event.addListener(text, "input", onTextInput);
}
if ("onpropertychange" in text && !("oninput" in text))
event.addListener(text, "propertychange", onPropertyChange);
else
event.addListener(text, "input", onTextInput);
event.addListener(text, "paste", function(e) {
// Mark that the next input text comes from past.
@ -184,11 +181,11 @@ var TextInput = function(parentNode, host) {
else {
// If a browser doesn't support any of the things above, use the regular
// method to detect the pasted input.
onKeyPress();
onPropertyChange();
}
});
if (useragent.isIE) {
if ("onbeforecopy" in text && typeof clipboardData !== "undefined") {
event.addListener(text, "beforecopy", function(e) {
var copyText = host.getCopyText();
if(copyText)
@ -227,12 +224,12 @@ var TextInput = function(parentNode, host) {
event.addListener(text, "focus", function() {
host.onFocus();
text.select();
select();
});
this.focus = function() {
host.onFocus();
text.select();
select();
text.focus();
};

View file

@ -215,7 +215,7 @@ var Text = function(parentEl) {
var html = [];
var tokens = this.session.getTokens(i, i);
this.$renderLine(html, i, tokens[0].tokens, true);
this.$renderLine(html, i, tokens[0].tokens, !this.$useLineGroups());
lineElement = dom.setInnerHtml(lineElement, html.join(""));
i = this.session.getRowFoldEnd(i);
@ -284,9 +284,14 @@ var Text = function(parentEl) {
// don't use setInnerHtml since we are working with an empty DIV
container.innerHTML = html.join("");
var lines = container.childNodes
while(lines.length)
fragment.appendChild(lines[0]);
if (this.$useLineGroups()) {
container.className = 'ace_line_group';
fragment.appendChild(container);
} else {
var lines = container.childNodes
while(lines.length)
fragment.appendChild(lines[0]);
}
row++;
}
@ -313,6 +318,9 @@ var Text = function(parentEl) {
if(row > lastRow)
break;
if (this.$useLineGroups())
html.push("<div class='ace_line_group'>")
// Get the tokens per line as there might be some lines in between
// beeing folded.
// OPTIMIZE: If there is a long block of unfolded lines, just make
@ -321,6 +329,9 @@ var Text = function(parentEl) {
if (tokens.length == 1)
this.$renderLine(html, row, tokens[0].tokens, false);
if (this.$useLineGroups())
html.push("</div>"); // end the line group
row++;
}
this.element = dom.setInnerHtml(this.element, html.join(""));
@ -530,6 +541,15 @@ var Text = function(parentEl) {
var splits = this.session.$useWrapMode?this.session.$wrapData[row]:null;
this.$renderLineCore(stringBuilder, row, renderTokens, splits, onlyContents);
};
this.$useLineGroups = function() {
// For the updateLines function to work correctly, it's important that the
// child nodes of this.element correspond on a 1-to-1 basis to rows in the
// document (as distinct from lines on the screen). For sessions that are
// wrapped, this means we need to add a layer to the node hierarchy (tagged
// with the class name ace_line_group).
return this.session.getUseWrapMode();
};
this.destroy = function() {
clearInterval(this.$pollSizeChangesTimer);

62
lib/ace/lib/net.js Normal file
View file

@ -0,0 +1,62 @@
/**
* based on code from:
*
* @license RequireJS text 0.25.0 Copyright (c) 2010-2011, The Dojo Foundation All Rights Reserved.
* Available via the MIT or new BSD license.
* see: http://github.com/jrburke/requirejs for details
*/
define(function(require, exports, module) {
exports.get = function (url, callback) {
var xhr = exports.createXhr();
xhr.open('GET', url, true);
xhr.onreadystatechange = function (evt) {
//Do not explicitly handle errors, those should be
//visible via console output in the browser.
if (xhr.readyState === 4) {
callback(xhr.responseText);
}
};
xhr.send(null);
};
var progIds = ['Msxml2.XMLHTTP', 'Microsoft.XMLHTTP', 'Msxml2.XMLHTTP.4.0'];
exports.createXhr = function () {
//Would love to dump the ActiveX crap in here. Need IE 6 to die first.
var xhr, i, progId;
if (typeof XMLHttpRequest !== "undefined") {
return new XMLHttpRequest();
} else {
for (i = 0; i < 3; i++) {
progId = progIds[i];
try {
xhr = new ActiveXObject(progId);
} catch (e) {}
if (xhr) {
progIds = [progId]; // so faster next time
break;
}
}
}
if (!xhr) {
throw new Error("createXhr(): XMLHttpRequest not available");
}
return xhr;
};
exports.loadScript = function(path, callback) {
var head = document.getElementsByTagName('head')[0];
var s = document.createElement('script');
s.src = path;
head.appendChild(s);
s.onload = callback;
};
});

View file

@ -46,10 +46,8 @@ var HtmlHighlightRules = function() {
// regexp must not have capturing parentheses
// regexps are ordered -> the first match is used
function string(state) {
return [
{
return [{
token : "string",
regex : '".*?"'
}, {
@ -80,6 +78,39 @@ var HtmlHighlightRules = function() {
regex : '.+'
}]
}
function tag(states, name, nextState) {
states[name] = [{
token : "text",
regex : "\\s+"
}, {
token : "meta.tag",
regex : "[-_a-zA-Z0-9:]+",
next : name + "-attribute-list"
}, {
token: "empty",
regex: "",
next : name + "-attribute-list"
}];
states[name + "-qstring"] = multiLineString("'", name);
states[name + "-qqstring"] = multiLineString("\"", name);
states[name + "-attribute-list"] = [{
token : "text",
regex : ">",
next : nextState
}, {
token : "entity.other.attribute-name",
regex : "[-_a-zA-Z0-9:]+"
}, {
token : "constant.numeric", // float
regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
}, {
token : "text",
regex : "\\s+"
}].concat(string(name));
};
this.$rules = {
start : [ {
@ -114,50 +145,7 @@ var HtmlHighlightRules = function() {
token : "text",
regex : "[^<]+"
} ],
script : [ {
token : "text",
regex : ">",
next : "js-start"
}, {
token : "keyword",
regex : "[-_a-zA-Z0-9:]+"
}, {
token : "text",
regex : "\\s+"
}].concat(string("script")),
css : [ {
token : "text",
regex : ">",
next : "css-start"
}, {
token : "keyword",
regex : "[-_a-zA-Z0-9:]+"
}, {
token : "text",
regex : "\\s+"
}].concat(string("style")),
tag : [ {
token : "text",
regex : ">",
next : "start"
}, {
token : "keyword",
regex : "[-_a-zA-Z0-9:]+"
}, {
token : "text",
regex : "\\s+"
}].concat(string("tag")),
"style-qstring": multiLineString("'", "style"),
"style-qqstring": multiLineString('"', "style"),
"script-qstring": multiLineString("'", "script"),
"script-qqstring": multiLineString('"', "script"),
"tag-qstring": multiLineString("'", "tag"),
"tag-qqstring": multiLineString('"', "tag"),
cdata : [ {
token : "text",
regex : "\\]\\]>",
@ -183,6 +171,10 @@ var HtmlHighlightRules = function() {
} ]
};
tag(this.$rules, "tag", "start");
tag(this.$rules, "css", "css-start");
tag(this.$rules, "script", "js-start");
this.embedRules(JavaScriptHighlightRules, "js-", [{
token: "comment",
regex: "\\/\\/.*(?=<\\/script>)",

View file

@ -56,15 +56,15 @@ module.exports = {
//assert.equal(10, tokens.length);
assert.equal("text", tokens[0].type);
assert.equal("keyword", tokens[1].type);
assert.equal("meta.tag", tokens[1].type);
assert.equal("text", tokens[2].type);
assert.equal("keyword", tokens[3].type);
assert.equal("entity.other.attribute-name", tokens[3].type);
assert.equal("text", tokens[4].type);
assert.equal("string", tokens[5].type);
assert.equal("text", tokens[6].type);
assert.equal("keyword", tokens[7].type);
assert.equal("text", tokens[8].type);
assert.equal("keyword", tokens[9].type);
assert.equal("meta.tag", tokens[9].type);
assert.equal("text", tokens[10].type);
},
@ -77,7 +77,7 @@ module.exports = {
},
"test: tokenize multiline attribute value with single quotes": function() {
var line1 = this.tokenizer.getLineTokens('<a href=\'abc', "start");
var line1 = this.tokenizer.getLineTokens("<a href='abc", "start");
var t1 = line1.tokens;
var t2 = this.tokenizer.getLineTokens('def\'>', line1.state).tokens;
assert.equal(t1[t1.length-1].type, "string");

View file

@ -95,13 +95,13 @@ oop.inherits(Mode, TextMode);
return indent;
}
if (state == "start") {
if (state == "start" || state == "regex_allowed") {
var match = line.match(/^.*[\{\(\[\:]\s*$/);
if (match) {
indent += tab;
}
} else if (state == "doc-start") {
if (endState == "start") {
if (endState == "start" || state == "regex_allowed") {
return "";
}
var match = line.match(/^\s*(\/?)\*/);

View file

@ -117,6 +117,7 @@ module.exports = {
"test: no auto indent should add to existing indent" : function() {
assert.equal(" ", this.mode.getNextLineIndent("start", " if () {", " "));
assert.equal(" ", this.mode.getNextLineIndent("start", " cde", " "));
assert.equal(" ", this.mode.getNextLineIndent("regex_allowed", "function foo(items) {", " "));
},
"test: special indent in doc comments" : function() {

View file

@ -25,10 +25,13 @@ oop.inherits(JavaScriptWorker, Mirror);
} catch(e) {
// console.log("narcissus")
// console.log(e);
var chunks = e.message.split(":")
var message = chunks.pop().trim();
var lineNumber = parseInt(chunks.pop().trim()) - 1;
this.sender.emit("narcissus", {
row: e.lineno-1,
row: lineNumber,
column: null, // TODO convert e.cursor
text: e.message,
text: message,
type: "error"
});
return;

View file

@ -63,7 +63,12 @@ module.exports = {
var worker = new JavaScriptWorker(this.sender);
worker.setValue("Juhu Kinners");
worker.deferredUpdate.call();
assert.equal(this.sender.events[0][1].type, "error");
var error = this.sender.events[0][1];
assert.equal(error.text, "missing ; before statement");
assert.equal(error.type, "error");
assert.equal(error.row, 0);
assert.equal(error.column, null);
},
"test check for narcissus bug": function() {

120
lib/ace/mode/lua.js Normal file
View file

@ -0,0 +1,120 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Ajax.org Code Editor (ACE).
*
* The Initial Developer of the Original Code is
* Ajax.org B.V.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Fabian Jakobs <fabian AT ajax DOT org>
* Colin Gourlay <colin DOT j DOT gourlay AT gmail DOT com>
* Lee Gao
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
define(function(require, exports, module) {
var oop = require("pilot/oop");
var TextMode = require("ace/mode/text").Mode;
var Tokenizer = require("ace/tokenizer").Tokenizer;
var LuaHighlightRules = require("ace/mode/lua_highlight_rules").LuaHighlightRules;
var Range = require("ace/range").Range;
var Mode = function() {
this.$tokenizer = new Tokenizer(new LuaHighlightRules().getRules());
};
oop.inherits(Mode, TextMode);
(function() {
this.getNextLineIndent = function(state, line, tab) {
var indent = this.$getIndent(line);
var tokenizedLine = this.$tokenizer.getLineTokens(line, state);
var tokens = tokenizedLine.tokens;
var endState = tokenizedLine.state;
var chunks = ["function", "then", "do", "repeat"];
if (state == "start") {
var match = line.match(/^.*[\{\(\[]\s*$/);
if (match) {
indent += tab;
} else {
for (var i in tokens){
var token = tokens[i];
if (token.type != "keyword") continue;
var chunk_i = chunks.indexOf(token.value);
if (chunk_i != -1){
indent += tab;
break;
}
}
}
}
return indent;
};
/*this.checkOutdent = function(state, line, input) {
if (input !== "\r\n" && input !== "\r" && input !== "\n")
return false;
var tokens = this.$tokenizer.getLineTokens(line.trim(), state).tokens;
if (!tokens)
return false;
// ignore trailing comments
do {
var last = tokens.pop();
} while (last && (last.type == "comment" || (last.type == "text" && last.value.match(/^\s+$/))));
if (!last)
return false;
var outdents = {
"end" : 1,
"until" : 1,
"else" : 1
}
return (last.type == "keyword" && outdents[last.value]);
};
this.autoOutdent = function(state, doc, row) {
console.log(doc, row);
var indent = this.$getIndent(doc.getLine(row));
var tab = doc.getTabString();
if (indent.slice(-tab.length) == tab)
doc.remove(new Range(row, indent.length-tab.length, row, indent.length));
};*/
}).call(Mode.prototype);
exports.Mode = Mode;
});

View file

@ -0,0 +1,435 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Ajax.org Code Editor (ACE).
*
* The Initial Developer of the Original Code is
* Ajax.org B.V.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Fabian Jakobs <fabian AT ajax DOT org>
* Colin Gourlay <colin DOT j DOT gourlay AT gmail DOT com>
* Lee Gao
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
define(function(require, exports, module) {
var oop = require("pilot/oop");
var lang = require("pilot/lang");
var TextHighlightRules = require("ace/mode/text_highlight_rules").TextHighlightRules;
var LuaHighlightRules = function() {
var keywords = lang.arrayToMap(
("break|do|else|elseif|end|for|function|if|in|local|repeat|"+
"return|then|until|while|or|and|not").split("|")
);
var builtinConstants = lang.arrayToMap(
("true|false|nil|_G|_VERSION").split("|")
);
var builtinFunctions = lang.arrayToMap(
("string|xpcall|package|tostring|print|os|unpack|require|"+
"getfenv|setmetatable|next|assert|tonumber|io|rawequal|"+
"collectgarbage|getmetatable|module|rawset|math|debug|"+
"pcall|table|newproxy|type|coroutine|_G|select|gcinfo|"+
"pairs|rawget|loadstring|ipairs|_VERSION|dofile|setfenv|"+
"load|error|loadfile|"+
"sub|upper|len|gfind|rep|find|match|char|dump|gmatch|"+
"reverse|byte|format|gsub|lower|preload|loadlib|loaded|"+
"loaders|cpath|config|path|seeall|exit|setlocale|date|"+
"getenv|difftime|remove|time|clock|tmpname|rename|execute|"+
"lines|write|close|flush|open|output|type|read|stderr|"+
"stdin|input|stdout|popen|tmpfile|log|max|acos|huge|"+
"ldexp|pi|cos|tanh|pow|deg|tan|cosh|sinh|random|randomseed|"+
"frexp|ceil|floor|rad|abs|sqrt|modf|asin|min|mod|fmod|log10|"+
"atan2|exp|sin|atan|getupvalue|debug|sethook|getmetatable|"+
"gethook|setmetatable|setlocal|traceback|setfenv|getinfo|"+
"setupvalue|getlocal|getregistry|getfenv|setn|insert|getn|"+
"foreachi|maxn|foreach|concat|sort|remove|resume|yield|"+
"status|wrap|create|running").split("|")
);
var stdLibaries = lang.arrayToMap(
("string|package|os|io|math|debug|table|coroutine").split("|")
);
var metatableMethods = lang.arrayToMap(
("__add|__sub|__mod|__unm|__concat|__lt|__index|__call|__gc|__metatable|"+
"__mul|__div|__pow|__len|__eq|__le|__newindex|__tostring|__mode|__tonumber").split("|")
);
var futureReserved = lang.arrayToMap(
("").split("|")
);
var deprecatedIn5152 = lang.arrayToMap(
("setn|foreach|foreachi|gcinfo|log10|maxn").split("|")
);
var strPre = "";
var decimalInteger = "(?:(?:[1-9]\\d*)|(?:0))";
var hexInteger = "(?:0[xX][\\dA-Fa-f]+)";
var integer = "(?:" + decimalInteger + "|" + hexInteger + ")";
var fraction = "(?:\\.\\d+)";
var intPart = "(?:\\d+)";
var pointFloat = "(?:(?:" + intPart + "?" + fraction + ")|(?:" + intPart + "\\.))";
var floatNumber = "(?:" + pointFloat + ")";
var comment_stack = [];
this.$rules = {
"start" :
// bracketed comments
[{
token : "comment", // --[[ comment
regex : strPre + '\\-\\-\\[\\[.*\\]\\]'
}, {
token : "comment", // --[=[ comment
regex : strPre + '\\-\\-\\[\\=\\[.*\\]\\=\\]'
}, {
token : "comment", // --[==[ comment
regex : strPre + '\\-\\-\\[\\={2}\\[.*\\]\\={2}\\]'
}, {
token : "comment", // --[===[ comment
regex : strPre + '\\-\\-\\[\\={3}\\[.*\\]\\={3}\\]'
}, {
token : "comment", // --[====[ comment
regex : strPre + '\\-\\-\\[\\={4}\\[.*\\]\\={4}\\]'
}, {
token : "comment", // --[====+[ comment
regex : strPre + '\\-\\-\\[\\={5}\\=*\\[.*\\]\\={5}\\=*\\]'
},
// multiline bracketed comments
{
token : "comment", // --[[ comment
regex : strPre + '\\-\\-\\[\\[.*$',
merge : true,
next : "qcomment"
}, {
token : "comment", // --[=[ comment
regex : strPre + '\\-\\-\\[\\=\\[.*$',
merge : true,
next : "qcomment1"
}, {
token : "comment", // --[==[ comment
regex : strPre + '\\-\\-\\[\\={2}\\[.*$',
merge : true,
next : "qcomment2"
}, {
token : "comment", // --[===[ comment
regex : strPre + '\\-\\-\\[\\={3}\\[.*$',
merge : true,
next : "qcomment3"
}, {
token : "comment", // --[====[ comment
regex : strPre + '\\-\\-\\[\\={4}\\[.*$',
merge : true,
next : "qcomment4"
}, {
token : function(value){ // --[====+[ comment
// WARNING: EXTREMELY SLOW, but this is the only way to circumvent the
// limits imposed by the current automaton.
// I've never personally seen any practical code where 5 or more '='s are
// used for string or commenting, so this will rarely be invoked.
var pattern = /\-\-\[(\=+)\[/, match;
// you can never be too paranoid ;)
if ((match = pattern.exec(value)) != null && (match = match[1]) != undefined)
comment_stack.push(match.length);
return "comment";
},
regex : strPre + '\\-\\-\\[\\={5}\\=*\\[.*$',
merge : true,
next : "qcomment5"
},
// single line comments
{
token : "comment",
regex : "\\-\\-.*$"
},
// bracketed strings
{
token : "string", // [[ string
regex : strPre + '\\[\\[.*\\]\\]'
}, {
token : "string", // [=[ string
regex : strPre + '\\[\\=\\[.*\\]\\=\\]'
}, {
token : "string", // [==[ string
regex : strPre + '\\[\\={2}\\[.*\\]\\={2}\\]'
}, {
token : "string", // [===[ string
regex : strPre + '\\[\\={3}\\[.*\\]\\={3}\\]'
}, {
token : "string", // [====[ string
regex : strPre + '\\[\\={4}\\[.*\\]\\={4}\\]'
}, {
token : "string", // [====+[ string
regex : strPre + '\\[\\={5}\\=*\\[.*\\]\\={5}\\=*\\]'
},
// multiline bracketed strings
{
token : "string", // [[ string
regex : strPre + '\\[\\[.*$',
merge : true,
next : "qstring"
}, {
token : "string", // [=[ string
regex : strPre + '\\[\\=\\[.*$',
merge : true,
next : "qstring1"
}, {
token : "string", // [==[ string
regex : strPre + '\\[\\={2}\\[.*$',
merge : true,
next : "qstring2"
}, {
token : "string", // [===[ string
regex : strPre + '\\[\\={3}\\[.*$',
merge : true,
next : "qstring3"
}, {
token : "string", // [====[ string
regex : strPre + '\\[\\={4}\\[.*$',
merge : true,
next : "qstring4"
}, {
token : function(value){ // --[====+[ string
// WARNING: EXTREMELY SLOW, see above.
var pattern = /\[(\=+)\[/, match;
if ((match = pattern.exec(value)) != null && (match = match[1]) != undefined)
comment_stack.push(match.length);
return "string";
},
regex : strPre + '\\[\\={5}\\=*\\[.*$',
merge : true,
next : "qstring5"
},
{
token : "string", // " string
regex : strPre + '"(?:[^\\\\]|\\\\.)*?"'
}, {
token : "string", // ' string
regex : strPre + "'(?:[^\\\\]|\\\\.)*?'"
}, {
token : "constant.numeric", // float
regex : floatNumber
}, {
token : "constant.numeric", // integer
regex : integer + "\\b"
}, {
token : function(value) {
if (keywords.hasOwnProperty(value))
return "keyword";
else if (builtinConstants.hasOwnProperty(value))
return "constant.language";
else if (futureReserved.hasOwnProperty(value))
return "invalid.illegal";
else if (stdLibaries.hasOwnProperty(value))
return "constant.library";
else if (deprecatedIn5152.hasOwnProperty(value))
return "invalid.deprecated";
else if (builtinFunctions.hasOwnProperty(value))
return "support.function";
else if (metatableMethods.hasOwnProperty(value))
return "support.function";
else
return "identifier";
},
regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
}, {
token : "keyword.operator",
regex : "\\+|\\-|\\*|\\/|%|\\#|\\^|~|<|>|<=|=>|==|~=|=|\\:|\\.\\.\\.|\\.\\."
}, {
token : "lparen",
regex : "[\\[\\(\\{]"
}, {
token : "rparen",
regex : "[\\]\\)\\}]"
}, {
token : "text",
regex : "\\s+"
} ],
"qcomment": [ {
token : "comment",
regex : "(?:[^\\\\]|\\\\.)*?\\]\\]",
next : "start"
}, {
token : "comment",
merge : true,
regex : '.+'
} ],
"qcomment1": [ {
token : "comment",
regex : "(?:[^\\\\]|\\\\.)*?\\]\\=\\]",
next : "start"
}, {
token : "comment",
merge : true,
regex : '.+'
} ],
"qcomment2": [ {
token : "comment",
regex : "(?:[^\\\\]|\\\\.)*?\\]\\={2}\\]",
next : "start"
}, {
token : "comment",
merge : true,
regex : '.+'
} ],
"qcomment3": [ {
token : "comment",
regex : "(?:[^\\\\]|\\\\.)*?\\]\\={3}\\]",
next : "start"
}, {
token : "comment",
merge : true,
regex : '.+'
} ],
"qcomment4": [ {
token : "comment",
regex : "(?:[^\\\\]|\\\\.)*?\\]\\={4}\\]",
next : "start"
}, {
token : "comment",
merge : true,
regex : '.+'
} ],
"qcomment5": [ {
token : function(value){
// very hackish, mutates the qcomment5 field on the fly.
var pattern = /\](\=+)\]/, rule = this.rules.qcomment5[0], match;
rule.next = "start";
if ((match = pattern.exec(value)) != null && (match = match[1]) != undefined){
var found = match.length, expected;
if ((expected = comment_stack.pop()) != found){
comment_stack.push(expected);
rule.next = "qcomment5";
}
}
return "comment";
},
regex : "(?:[^\\\\]|\\\\.)*?\\]\\={5}\\=*\\]",
next : "start"
}, {
token : "comment",
merge : true,
regex : '.+'
} ],
"qstring": [ {
token : "string",
regex : "(?:[^\\\\]|\\\\.)*?\\]\\]",
next : "start"
}, {
token : "string",
merge : true,
regex : '.+'
} ],
"qstring1": [ {
token : "string",
regex : "(?:[^\\\\]|\\\\.)*?\\]\\=\\]",
next : "start"
}, {
token : "string",
merge : true,
regex : '.+'
} ],
"qstring2": [ {
token : "string",
regex : "(?:[^\\\\]|\\\\.)*?\\]\\={2}\\]",
next : "start"
}, {
token : "string",
merge : true,
regex : '.+'
} ],
"qstring3": [ {
token : "string",
regex : "(?:[^\\\\]|\\\\.)*?\\]\\={3}\\]",
next : "start"
}, {
token : "string",
merge : true,
regex : '.+'
} ],
"qstring4": [ {
token : "string",
regex : "(?:[^\\\\]|\\\\.)*?\\]\\={4}\\]",
next : "start"
}, {
token : "string",
merge : true,
regex : '.+'
} ],
"qstring5": [ {
token : function(value){
// very hackish, mutates the qstring5 field on the fly.
var pattern = /\](\=+)\]/, rule = this.rules.qstring5[0], match;
rule.next = "start";
if ((match = pattern.exec(value)) != null && (match = match[1]) != undefined){
var found = match.length, expected;
if ((expected = comment_stack.pop()) != found){
comment_stack.push(expected);
rule.next = "qstring5";
}
}
return "string";
},
regex : "(?:[^\\\\]|\\\\.)*?\\]\\={5}\\=*\\]",
next : "start"
}, {
token : "string",
merge : true,
regex : '.+'
} ]
};
}
oop.inherits(LuaHighlightRules, TextHighlightRules);
exports.LuaHighlightRules = LuaHighlightRules;
});

81
lib/ace/mode/markdown.js Normal file
View file

@ -0,0 +1,81 @@
/* vim:ts=4:sts=4:sw=4:
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Ajax.org Code Editor (ACE).
*
* The Initial Developer of the Original Code is
* Ajax.org B.V.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Fabian Jakobs <fabian AT ajax DOT org>
* Mihai Sucan <mihai DOT sucan AT gmail DOT com>
* Chris Spencer <chris.ag.spencer AT googlemail DOT com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
define(function(require, exports, module) {
var oop = require("pilot/oop");
var TextMode = require("ace/mode/text").Mode;
var JavaScriptMode = require("ace/mode/javascript").Mode;
var XmlMode = require("ace/mode/xml").Mode;
var HtmlMode = require("ace/mode/html").Mode;
var Tokenizer = require("ace/tokenizer").Tokenizer;
var MarkdownHighlightRules = require("ace/mode/markdown_highlight_rules").MarkdownHighlightRules;
var Range = require("ace/range").Range;
var Mode = function() {
var highlighter = new MarkdownHighlightRules();
this.$tokenizer = new Tokenizer(highlighter.getRules());
this.$embeds = highlighter.getEmbeds();
this.createModeDelegates({
"js-": JavaScriptMode,
"xml-": XmlMode,
"html-": HtmlMode
});
};
oop.inherits(Mode, TextMode);
(function() {
this.getNextLineIndent = function(state, line, tab) {
if (state == "listblock") {
var match = /^((?:.+)?)([-+*][ ]+)/.exec(line);
if (match) {
return new Array(match[1].length + 1).join(" ") + match[2];
} else {
return "";
}
} else {
return this.$getIndent(line);
}
};
}).call(Mode.prototype);
exports.Mode = Mode;
});

View file

@ -0,0 +1,194 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Ajax.org Code Editor (ACE).
*
* The Initial Developer of the Original Code is
* Ajax.org B.V.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Fabian Jakobs <fabian AT ajax DOT org>
* Chris Spencer <chris.ag.spencer AT googlemail DOT com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
define(function(require, exports, module) {
var oop = require("pilot/oop");
var TextHighlightRules = require("ace/mode/text_highlight_rules").TextHighlightRules;
var JavaScriptHighlightRules = require("ace/mode/javascript_highlight_rules").JavaScriptHighlightRules;
var XmlHighlightRules = require("ace/mode/xml_highlight_rules").XmlHighlightRules;
var HtmlHighlightRules = require("ace/mode/html_highlight_rules").HtmlHighlightRules;
var CssHighlightRules = require("ace/mode/css_highlight_rules").CssHighlightRules;
function github_embed(tag, prefix) {
return { // Github style block
token : "support.function",
regex : "^```" + tag + "\\s*$",
next : prefix + "start"
}
}
var MarkdownHighlightRules = function() {
// regexp must not have capturing parentheses
// regexps are ordered -> the first match is used
this.$rules = {
"start" : [ {
token : "empty_line",
regex : '^$'
}, { // code span `
token : "support.function",
regex : "(`+)([^\\r]*?[^`])(\\1)"
}, { // code block
token : "support.function",
regex : "^[ ]{4}.+"
}, { // h1
token: "markup.heading.1",
regex: "^=+(?=\\s*$)"
}, { // h2
token: "markup.heading.1",
regex: "^\\-+(?=\\s*$)"
}, { // header
token : function(value) {
return "markup.heading." + value.length;
},
regex : "^#{1,6}"
}, github_embed("javascript", "js-"),
github_embed("xml", "xml-"),
github_embed("html", "html-"),
github_embed("css", "css-"),
{ // Github style block
token : "support.function",
regex : "^```[a-zA-Z]+\\s*$",
next : "githubblock"
}, { // block quote
token : "string",
regex : "^>[ ].+$",
next : "blockquote"
}, { // reference
token : ["text", "constant", "text", "url", "string", "text"],
regex : "^([ ]{0,3}\\[)([^\\]]+)(\\]:\\s*)([^ ]+)(\\s*(?:[\"][^\"]+[\"])?\\s*)$"
}, { // link by reference
token : ["text", "string", "text", "constant", "text"],
regex : "(\\[)((?:[[^\\]]*\\]|[^\\[\\]])*)(\\][ ]?(?:\\n[ ]*)?\\[)(.*?)(\\])"
}, { // link by url
token : ["text", "string", "text", "markup.underline", "string", "text"],
regex : "(\\[)"+
"(\\[[^\\]]*\\]|[^\\[\\]]*)"+
"(\\]\\([ \\t]*)"+
"(<?(?:(?:[^\\(]*?\\([^\\)]*?\\)\\S*?)|(?:.*?))>?)"+
"((?:[ \t]*\"(?:.*?)\"[ \\t]*)?)"+
"(\\))"
}, { // HR *
token : "constant",
regex : "^[ ]{0,2}(?:[ ]?\\*[ ]?){3,}\\s*$"
}, { // HR -
token : "constant",
regex : "^[ ]{0,2}(?:[ ]?\\-[ ]?){3,}\\s*$"
}, { // HR _
token : "constant",
regex : "^[ ]{0,2}(?:[ ]?\\_[ ]?){3,}\\s*$"
}, { // list
token : "markup.list",
regex : "^\\s{0,3}(?:[*+-]|\\d+\\.)\\s+",
next : "listblock"
}, { // strong ** __
token : "string",
regex : "([*]{2}|[_]{2}(?=\\S))([^\\r]*?\\S[*_]*)(\\1)"
}, { // emphasis * _
token : "string",
regex : "([*]|[_](?=\\S))([^\\r]*?\\S[*_]*)(\\1)"
}, { //
token : ["text", "url", "text"],
regex : "(<)("+
"(?:https?|ftp|dict):[^'\">\\s]+"+
"|"+
"(?:mailto:)?[-.\\w]+\\@[-a-z0-9]+(?:\\.[-a-z0-9]+)*\\.[a-z]+"+
")(>)"
}, {
token : "text",
regex : "[^\\*_%$`\\[#<>]+"
} ],
"listblock" : [ { // Lists only escape on completely blank lines.
token : "empty_line",
regex : "^$",
next : "start"
}, {
token : "markup.list",
regex : ".+"
} ],
"blockquote" : [ { // BLockquotes only escape on blank lines.
token : "empty_line",
regex : "^\\s*$",
next : "start"
}, {
token : "string",
regex : ".+"
} ],
"githubblock" : [ {
token : "support.function",
regex : "^```",
next : "start"
}, {
token : "support.function",
regex : ".+"
} ]
};
this.embedRules(JavaScriptHighlightRules, "js-", [{
token : "support.function",
regex : "^```",
next : "start"
}]);
this.embedRules(HtmlHighlightRules, "html-", [{
token : "support.function",
regex : "^```",
next : "start"
}]);
this.embedRules(CssHighlightRules, "css-", [{
token : "support.function",
regex : "^```",
next : "start"
}]);
this.embedRules(XmlHighlightRules, "xml-", [{
token : "support.function",
regex : "^```",
next : "start"
}]);
};
oop.inherits(MarkdownHighlightRules, TextHighlightRules);
exports.MarkdownHighlightRules = MarkdownHighlightRules;
});

View file

@ -47,7 +47,6 @@ var Range = require("ace/range").Range;
var Mode = function() {
this.$tokenizer = new Tokenizer(new PythonHighlightRules().getRules());
this.$outdent = new MatchingBraceOutdent();
};
oop.inherits(Mode, TextMode);
@ -103,12 +102,43 @@ oop.inherits(Mode, TextMode);
return indent;
};
var outdents = {
"pass": 1,
"return": 1,
"raise": 1,
"break": 1,
"continue": 1
};
this.checkOutdent = function(state, line, input) {
return this.$outdent.checkOutdent(line, input);
if (input !== "\r\n" && input !== "\r" && input !== "\n")
return false;
var tokens = this.$tokenizer.getLineTokens(line.trim(), state).tokens;
if (!tokens)
return false;
// ignore trailing comments
do {
var last = tokens.pop();
} while (last && (last.type == "comment" || (last.type == "text" && last.value.match(/^\s+$/))));
if (!last)
return false;
return (last.type == "keyword" && outdents[last.value]);
};
this.autoOutdent = function(state, doc, row) {
this.$outdent.autoOutdent(doc, row);
// outdenting in python is slightly different because it always applies
// to the next line and only of a new line is inserted
row += 1;
var indent = this.$getIndent(doc.getLine(row));
var tab = doc.getTabString();
if (indent.slice(-tab.length) == tab)
doc.remove(new Range(row, indent.length-tab.length, row, indent.length));
};
}).call(Mode.prototype);

View file

@ -0,0 +1,85 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Ajax.org Code Editor (ACE).
*
* The Initial Developer of the Original Code is
* Ajax.org B.V.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Fabian Jakobs <fabian AT ajax DOT org>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
if (typeof process !== "undefined") {
require("../../../support/paths");
}
define(function(require, exports, module) {
var EditSession = require("ace/edit_session").EditSession;
var Tokenizer = require("ace/tokenizer").Tokenizer;
var Mode = require("ace/mode/python").Mode;
var assert = require("ace/test/assertions");
module.exports = {
setUp : function() {
this.mode = new Mode();
},
"test: getTokenizer() (smoke test)" : function() {
var tokenizer = this.mode.getTokenizer();
assert.ok(tokenizer instanceof Tokenizer);
var tokens = tokenizer.getLineTokens("'juhu'", "start").tokens;
assert.equal("string", tokens[0].type);
},
"test: auto outdent after 'pass', 'return' and 'raise'" : function() {
assert.ok(this.mode.checkOutdent("start", " pass", "\n"));
assert.ok(this.mode.checkOutdent("start", " pass ", "\n"));
assert.ok(this.mode.checkOutdent("start", " return", "\n"));
assert.ok(this.mode.checkOutdent("start", " raise", "\n"));
assert.equal(this.mode.checkOutdent("start", " raise", " "), false);
assert.ok(this.mode.checkOutdent("start", " pass # comment", "\n"));
assert.equal(this.mode.checkOutdent("start", "'juhu'", "\n"), false);
},
"test: auto outdent" : function() {
var session = new EditSession([" if True:", " pass", " "]);
this.mode.autoOutdent("start", session, 1);
assert.equal(" ", session.getLine(2));
}
};
});
if (typeof module !== "undefined" && module === require.main) {
require("asyncjs").test.testcase(module.exports).exec()
}

View file

@ -45,6 +45,12 @@ var TextileHighlightRules = function() {
"start" : [
{
token : "keyword", // start of block
token : function(value) {
if (value.match(/^h\d$/))
return "markup.heading." + value.charAt(1);
else
return "markup.heading";
},
regex : "h1|h2|h3|h4|h5|h6|bq|p|bc|pre",
next : "blocktag"
},

View file

@ -67,7 +67,7 @@ var MouseHandler = function(editor) {
event.addMultiMouseDownListener(mouseTarget, 0, 2, 500, this.onMouseDoubleClick.bind(this));
event.addMultiMouseDownListener(mouseTarget, 0, 3, 600, this.onMouseTripleClick.bind(this));
event.addMultiMouseDownListener(mouseTarget, 0, 4, 600, this.onMouseQuadClick.bind(this));
event.addMouseWheelListener(mouseTarget, this.onMouseWheel.bind(this));
event.addMouseWheelListener(editor.container, this.onMouseWheel.bind(this));
};
(function() {
@ -94,24 +94,33 @@ var MouseHandler = function(editor) {
};
this.onMouseDown = function(e) {
// if this click caused the editor to be focused ignore the click
// for selection and cursor placement
if (
!this.browserFocus.isFocused()
|| new Date().getTime() - this.browserFocus.lastFocus < 20
|| !this.editor.isFocused()
)
return;
var pageX = event.getDocumentX(e);
var pageY = event.getDocumentY(e);
var pos = this.$getEventPosition(e);
var editor = this.editor;
var self = this;
var selectionRange = editor.getSelectionRange();
var selectionEmpty = selectionRange.isEmpty();
var inSelection = !editor.getReadOnly()
&& !selectionEmpty
&& selectionRange.contains(pos.row, pos.column);
var state = STATE_UNKNOWN;
var inSelection = false;
// if this click caused the editor to be focused should not clear the
// selection
if (
inSelection && (
!this.browserFocus.isFocused()
|| new Date().getTime() - this.browserFocus.lastFocus < 20
|| !this.editor.isFocused()
)
) {
this.editor.focus();
return;
}
var button = event.getButton(e);
if (button !== 0) {
@ -130,10 +139,6 @@ var MouseHandler = function(editor) {
editor.selection.setSelectionRange(fold.range);
return;
}
inSelection = !editor.getReadOnly()
&& !selectionEmpty
&& selectionRange.contains(pos.row, pos.column);
}
if (!inSelection) {
@ -261,8 +266,7 @@ var MouseHandler = function(editor) {
var onDragSelectionInterval = function() {
dragCursor = editor.renderer.screenToTextCoordinates(mousePageX, mousePageY);
dragCursor.row = Math.max(0, Math.min(dragCursor.row,
editor.session.getLength() - 1));
dragCursor.row = Math.max(0, Math.min(dragCursor.row, editor.session.getLength() - 1));
editor.moveCursorToPosition(dragCursor);
};
@ -304,7 +308,8 @@ var MouseHandler = function(editor) {
var speed = this.$scrollSpeed * 2;
this.editor.renderer.scrollBy(e.wheelX * speed, e.wheelY * speed);
return event.preventDefault(e);
if (this.editor.renderer.isScrollableBy(e.wheelX, e.wheelY))
return event.preventDefault(e);
};

47
lib/ace/requirejs/text.js Normal file
View file

@ -0,0 +1,47 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Ajax.org Code Editor (ACE).
*
* The Initial Developer of the Original Code is
* Ajax.org B.V.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Fabian Jakobs <fabian AT ajax DOT org>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
* Extremely simplified version of the requireJS text plugin
*/
define(function (require, exports, module) {
var net = require("ace/lib/net");
exports.load = function (name, req, onLoad, config) {
net.get(req.toUrl(name), onLoad);
}
});

View file

@ -54,8 +54,10 @@ var ScrollBar = function(parent) {
// in OSX lion the scrollbars appear to have no width. In this case resize
// the to show the scrollbar but still pretend that the scrollbar has a width
// of 0px
// in Firefox 6+ scrollbar is hidden if element has the same width as scrollbar
// make element a little bit wider to retain scrollbar when page is zoomed
this.width = dom.scrollbarWidth();
this.element.style.width = (this.width || 15) + "px";
this.element.style.width = (this.width || 15) + 5 + "px";
event.addListener(this.element, "scroll", this.onScroll.bind(this));
};

View file

@ -153,6 +153,7 @@ var Split = function(container, theme, splits) {
this.$editors.forEach(callback, scope);
};
this.$fontSize = "";
this.setFontSize = function(size) {
this.$fontSize = size;
this.forEach(function(editor) {

View file

@ -1,7 +1,7 @@
define(function(require, exports, module) {
require("pilot/fixoldbrowsers");
var AsyncTest = require("asyncjs").test;
var AsyncTest = require("asyncjs/test");
var async = require("asyncjs");
var dom = require("pilot/dom");
@ -10,28 +10,32 @@ var failed = 0
var log = document.getElementById("log")
var tests = [
require("ace/editor_change_document_test"),
require("ace/editor_navigation_test"),
require("ace/editor_highlight_selected_word_test"),
require("ace/editor_text_edit_test"),
require("ace/anchor_test"),
require("ace/document_test"),
require("ace/edit_session_test"),
require("ace/test/event_emitter_test"),
require("ace/range_test"),
require("ace/search_test"),
require("ace/selection_test"),
require("ace/virtual_renderer_test"),
require("ace/anchor_test"),
require("ace/editor_change_document_test"),
require("ace/editor_highlight_selected_word_test"),
require("ace/editor_navigation_test"),
require("ace/editor_text_edit_test"),
require("ace/layer/text_test"),
require("ace/mode/coffee/parser_test"),
require("ace/mode/css_test"),
require("ace/mode/css_tokenizer_test"),
require("ace/mode/css_worker"),
require("ace/mode/html_test"),
require("ace/mode/html_tokenizer_test"),
require("ace/mode/javascript_test"),
require("ace/mode/javascript_tokenizer_test"),
require("ace/mode/javascript_worker_test"),
require("ace/mode/ruby_tokenizer_test"),
require("ace/mode/text_test"),
require("ace/mode/xml_test"),
require("ace/mode/xml_tokenizer_test")
require("ace/mode/xml_tokenizer_test"),
require("ace/range_test"),
require("ace/search_test"),
require("ace/selection_test"),
require("ace/test/event_emitter_test"),
require("ace/virtual_renderer_test")
]
async.list(tests)

View file

@ -53,14 +53,21 @@ assert.AssertionError = function AssertionError(options) {
};
oop.inherits(assert.AssertionError, Error);
toJSON = function(obj) {
if (typeof JSON !== "undefined")
return JSON.stringify(obj);
else
return obj.toString();
}
assert.AssertionError.prototype.toString = function() {
if (this.message) {
return [this.name + ':', this.message].join(' ');
} else {
return [this.name + ':',
JSON.stringify(this.expected),
toJSON(this.expected),
this.operator,
JSON.stringify(this.actual)].join(' ');
toJSON(this.actual)].join(' ');
}
};

View file

@ -11,7 +11,9 @@ var async = require("asyncjs/async")
async.plugin({
delay: function(delay) {
return this.each(function(item, next) {
setTimeout(next, delay)
setTimeout(function() {
next();
}, delay)
})
},

View file

@ -37,7 +37,7 @@
define(function(require, exports, module) {
MockRenderer = function(visibleRowCount) {
var MockRenderer = exports.MockRenderer = function(visibleRowCount) {
this.container = document.createElement("div");
this.visibleRowCount = visibleRowCount || 20;
@ -161,5 +161,4 @@ MockRenderer.prototype.textToScreenCoordinates = function() {
}
};
return MockRenderer;
});

View file

@ -23,32 +23,26 @@
<div id="log"></div>
<script src="../../../demo/require.js" type="text/javascript" charset="utf-8"></script>
<script>
require({
paths: {
ace: "../lib/ace",
cockpit: "../support/cockpit/lib/cockpit",
pilot: "../support/pilot/lib/pilot"
},
packages : [{
name: "asyncjs",
location: "../lib/ace/test",
lib: "asyncjs",
main: "index"
}, {
name: "assert",
location: "../lib/ace/test",
lib: "asyncjs",
main: "assert"
}]
});
require(["ace/test/all_browser"], function(tests) {
});
<script type="text/javascript">
var require = {
paths: {
ace: "../",
cockpit: "../../../../support/cockpit/lib/cockpit",
pilot: "../../../../support/pilot/lib/pilot"
},
packages : [{
name: "asyncjs",
location: "./asyncjs",
main: "index"
}, {
name: "assert",
location: "./asyncjs",
main: "assert"
}]
};
</script>
<script src="../../../demo/require.js" data-main="all_browser" type="text/javascript" charset="utf-8"></script>
</body>
</html>

View file

@ -186,6 +186,62 @@ define(function(require, exports, module) {
\
.ace-clouds .ace_xml_pe {\
\
}\
\
.ace-clouds .ace_meta {\
\
}\
\
.ace-clouds .ace_meta.ace_tag {\
\
}\
\
.ace-clouds .ace_meta.ace_tag.ace_input {\
\
}\
\
.ace-clouds .ace_entity.ace_other.ace_attribute-name {\
color:#606060;\
}\
\
.ace-clouds .ace_markup.ace_underline {\
text-decoration:underline;\
}\
\
.ace-clouds .ace_markup.ace_heading {\
\
}\
\
.ace-clouds .ace_markup.ace_heading.ace_1 {\
\
}\
\
.ace-clouds .ace_markup.ace_heading.ace_2 {\
\
}\
\
.ace-clouds .ace_markup.ace_heading.ace_3 {\
\
}\
\
.ace-clouds .ace_markup.ace_heading.ace_4 {\
\
}\
\
.ace-clouds .ace_markup.ace_heading.ace_5 {\
\
}\
\
.ace-clouds .ace_markup.ace_heading.ace_6 {\
\
}\
\
.ace-clouds .ace_markup.ace_list {\
\
}\
\
.ace-clouds .ace_collab.ace_user1 {\
\
}";
// import CSS once

View file

@ -187,6 +187,62 @@ background-color:#E92E2E;\
\
.ace-clouds-midnight .ace_xml_pe {\
\
}\
\
.ace-clouds-midnight .ace_meta {\
\
}\
\
.ace-clouds-midnight .ace_meta.ace_tag {\
\
}\
\
.ace-clouds-midnight .ace_meta.ace_tag.ace_input {\
\
}\
\
.ace-clouds-midnight .ace_entity.ace_other.ace_attribute-name {\
color:#606060;\
}\
\
.ace-clouds-midnight .ace_markup.ace_underline {\
text-decoration:underline;\
}\
\
.ace-clouds-midnight .ace_markup.ace_heading {\
\
}\
\
.ace-clouds-midnight .ace_markup.ace_heading.ace_1 {\
\
}\
\
.ace-clouds-midnight .ace_markup.ace_heading.ace_2 {\
\
}\
\
.ace-clouds-midnight .ace_markup.ace_heading.ace_3 {\
\
}\
\
.ace-clouds-midnight .ace_markup.ace_heading.ace_4 {\
\
}\
\
.ace-clouds-midnight .ace_markup.ace_heading.ace_5 {\
\
}\
\
.ace-clouds-midnight .ace_markup.ace_heading.ace_6 {\
\
}\
\
.ace-clouds-midnight .ace_markup.ace_list {\
\
}\
\
.ace-clouds-midnight .ace_collab.ace_user1 {\
\
}";
// import CSS once

View file

@ -188,6 +188,63 @@ color:#0088FF;\
\
.ace-cobalt .ace_xml_pe {\
\
}\
\
.ace-cobalt .ace_meta {\
\
}\
\
.ace-cobalt .ace_meta.ace_tag {\
color:#9EFFFF;\
}\
\
.ace-cobalt .ace_meta.ace_tag.ace_input {\
\
}\
\
.ace-cobalt .ace_entity.ace_other.ace_attribute-name {\
\
}\
\
.ace-cobalt .ace_markup.ace_underline {\
text-decoration:underline;\
}\
\
.ace-cobalt .ace_markup.ace_heading {\
color:#C8E4FD;\
background-color:#001221;\
}\
\
.ace-cobalt .ace_markup.ace_heading.ace_1 {\
\
}\
\
.ace-cobalt .ace_markup.ace_heading.ace_2 {\
\
}\
\
.ace-cobalt .ace_markup.ace_heading.ace_3 {\
\
}\
\
.ace-cobalt .ace_markup.ace_heading.ace_4 {\
\
}\
\
.ace-cobalt .ace_markup.ace_heading.ace_5 {\
\
}\
\
.ace-cobalt .ace_markup.ace_heading.ace_6 {\
\
}\
\
.ace-cobalt .ace_markup.ace_list {\
background-color:#130D26;\
}\
\
.ace-cobalt .ace_collab.ace_user1 {\
\
}";
// import CSS once

View file

@ -182,6 +182,10 @@ define(function(require, exports, module) {
background: rgb(232, 242, 254);\
}\
\
.ace-crimson-editor .ace_meta.ace_tag {\
color:rgb(28, 2, 255);\
}\
\
.ace-crimson-editor .ace_marker-layer .ace_selected_word {\
background: rgb(250, 250, 255);\
border: 1px solid rgb(200, 200, 250);\

View file

@ -192,6 +192,62 @@ color:#5A525F;\
\
.ace-dawn .ace_xml_pe {\
\
}\
\
.ace-dawn .ace_meta {\
\
}\
\
.ace-dawn .ace_meta.ace_tag {\
\
}\
\
.ace-dawn .ace_meta.ace_tag.ace_input {\
\
}\
\
.ace-dawn .ace_entity.ace_other.ace_attribute-name {\
\
}\
\
.ace-dawn .ace_markup.ace_underline {\
text-decoration:underline;\
}\
\
.ace-dawn .ace_markup.ace_heading {\
color:#19356D;\
}\
\
.ace-dawn .ace_markup.ace_heading.ace_1 {\
\
}\
\
.ace-dawn .ace_markup.ace_heading.ace_2 {\
\
}\
\
.ace-dawn .ace_markup.ace_heading.ace_3 {\
\
}\
\
.ace-dawn .ace_markup.ace_heading.ace_4 {\
\
}\
\
.ace-dawn .ace_markup.ace_heading.ace_5 {\
\
}\
\
.ace-dawn .ace_markup.ace_heading.ace_6 {\
\
}\
\
.ace-dawn .ace_markup.ace_list {\
color:#693A17;\
}\
\
.ace-dawn .ace_collab.ace_user1 {\
\
}";
// import CSS once

View file

@ -63,6 +63,10 @@ define(function(require, exports, module) {
padding-right: 6px;\
}\
\
.ace-eclipse .ace_print_margin {\
width: 1px;\
background: #b1b4ba;\
}\
.ace-eclipse .ace_text-layer {\
cursor: text;\
}\
@ -107,7 +111,11 @@ define(function(require, exports, module) {
}\
\
.ace-eclipse .ace_line .ace_tag {\
color: rgb(63, 127, 127);\
color: rgb(63, 127, 127);\
}\
\
.ace-eclipse .ace_line .ace_type {\
color: rgb(127, 0, 127);\
}\
\
.ace-eclipse .ace_line .ace_xml_pe {\
@ -123,6 +131,14 @@ define(function(require, exports, module) {
border: 1px solid rgb(192, 192, 192);\
}\
\
.ace-eclipse .ace_line .ace_meta.ace_tag {\
color:rgb(63, 127, 127);\
}\
\
.ace-eclipse .ace_entity.ace_other.ace_attribute-name {\
color:rgb(127, 0, 127);\
}\
\
.ace-eclipse .ace_marker-layer .ace_active_line {\
background: rgb(232, 242, 254);\
}";

View file

@ -190,6 +190,58 @@ color:#BC9458;\
\
}\
\
.ace-idle-fingers .ace_meta {\
\
}\
\
.ace-idle-fingers .ace_meta.ace_tag {\
color:#FFE5BB;\
}\
\
.ace-idle-fingers .ace_meta.ace_tag.ace_input {\
\
}\
\
.ace-idle-fingers .ace_entity.ace_other.ace_attribute-name {\
\
}\
\
.ace-idle-fingers .ace_markup.ace_underline {\
text-decoration:underline;\
}\
\
.ace-idle-fingers .ace_markup.ace_heading {\
\
}\
\
.ace-idle-fingers .ace_markup.ace_heading.ace_1 {\
\
}\
\
.ace-idle-fingers .ace_markup.ace_heading.ace_2 {\
\
}\
\
.ace-idle-fingers .ace_markup.ace_heading.ace_3 {\
\
}\
\
.ace-idle-fingers .ace_markup.ace_heading.ace_4 {\
\
}\
\
.ace-idle-fingers .ace_markup.ace_heading.ace_5 {\
\
}\
\
.ace-idle-fingers .ace_markup.ace_heading.ace_6 {\
\
}\
\
.ace-idle-fingers .ace_markup.ace_list {\
\
}\
\
.ace-idle-fingers .ace_collab.ace_user1 {\
color:#323232;\
background-color:#FFF980; \

View file

@ -188,6 +188,62 @@ color:#706D5B;\
\
.ace-kr-theme .ace_xml_pe {\
\
}\
\
.ace-kr-theme .ace_meta {\
\
}\
\
.ace-kr-theme .ace_meta.ace_tag {\
color:#BABD9C;\
}\
\
.ace-kr-theme .ace_meta.ace_tag.ace_input {\
\
}\
\
.ace-kr-theme .ace_entity.ace_other.ace_attribute-name {\
\
}\
\
.ace-kr-theme .ace_markup.ace_underline {\
text-decoration:underline;\
}\
\
.ace-kr-theme .ace_markup.ace_heading {\
\
}\
\
.ace-kr-theme .ace_markup.ace_heading.ace_1 {\
\
}\
\
.ace-kr-theme .ace_markup.ace_heading.ace_2 {\
\
}\
\
.ace-kr-theme .ace_markup.ace_heading.ace_3 {\
\
}\
\
.ace-kr-theme .ace_markup.ace_heading.ace_4 {\
\
}\
\
.ace-kr-theme .ace_markup.ace_heading.ace_5 {\
\
}\
\
.ace-kr-theme .ace_markup.ace_heading.ace_6 {\
\
}\
\
.ace-kr-theme .ace_markup.ace_list {\
background-color:#0F0040;\
}\
\
.ace-kr-theme .ace_collab.ace_user1 {\
\
}";
// import CSS once

View file

@ -134,7 +134,7 @@ define(function(require, exports, module) {
\
.ace-merbivore .ace_invalid {\
color:#FFFFFF;\
background-color:#990000;\
background-color:#990000;\
}\
\
.ace-merbivore .ace_invalid.ace_illegal {\
@ -188,6 +188,62 @@ define(function(require, exports, module) {
\
.ace-merbivore .ace_xml_pe {\
\
}\
\
.ace-merbivore .ace_meta {\
\
}\
\
.ace-merbivore .ace_meta.ace_tag {\
color:#FC6F09;\
}\
\
.ace-merbivore .ace_meta.ace_tag.ace_input {\
\
}\
\
.ace-merbivore .ace_entity.ace_other.ace_attribute-name {\
color:#FFFF89;\
}\
\
.ace-merbivore .ace_markup.ace_underline {\
text-decoration:underline;\
}\
\
.ace-merbivore .ace_markup.ace_heading {\
\
}\
\
.ace-merbivore .ace_markup.ace_heading.ace_1 {\
\
}\
\
.ace-merbivore .ace_markup.ace_heading.ace_2 {\
\
}\
\
.ace-merbivore .ace_markup.ace_heading.ace_3 {\
\
}\
\
.ace-merbivore .ace_markup.ace_heading.ace_4 {\
\
}\
\
.ace-merbivore .ace_markup.ace_heading.ace_5 {\
\
}\
\
.ace-merbivore .ace_markup.ace_heading.ace_6 {\
\
}\
\
.ace-merbivore .ace_markup.ace_list {\
\
}\
\
.ace-merbivore .ace_collab.ace_user1 {\
\
}";
// import CSS once

View file

@ -134,7 +134,7 @@ define(function(require, exports, module) {
\
.ace-merbivore-soft .ace_invalid {\
color:#FFFFFF;\
background-color:#FE3838;\
background-color:#FE3838;\
}\
\
.ace-merbivore-soft .ace_invalid.ace_illegal {\
@ -188,6 +188,62 @@ define(function(require, exports, module) {
\
.ace-merbivore-soft .ace_xml_pe {\
\
}\
\
.ace-merbivore-soft .ace_meta {\
\
}\
\
.ace-merbivore-soft .ace_meta.ace_tag {\
color:#FC803A;\
}\
\
.ace-merbivore-soft .ace_meta.ace_tag.ace_input {\
\
}\
\
.ace-merbivore-soft .ace_entity.ace_other.ace_attribute-name {\
color:#EAF1A3;\
}\
\
.ace-merbivore-soft .ace_markup.ace_underline {\
text-decoration:underline;\
}\
\
.ace-merbivore-soft .ace_markup.ace_heading {\
\
}\
\
.ace-merbivore-soft .ace_markup.ace_heading.ace_1 {\
\
}\
\
.ace-merbivore-soft .ace_markup.ace_heading.ace_2 {\
\
}\
\
.ace-merbivore-soft .ace_markup.ace_heading.ace_3 {\
\
}\
\
.ace-merbivore-soft .ace_markup.ace_heading.ace_4 {\
\
}\
\
.ace-merbivore-soft .ace_markup.ace_heading.ace_5 {\
\
}\
\
.ace-merbivore-soft .ace_markup.ace_heading.ace_6 {\
\
}\
\
.ace-merbivore-soft .ace_markup.ace_list {\
\
}\
\
.ace-merbivore-soft .ace_collab.ace_user1 {\
\
}";
// import CSS once

View file

@ -188,6 +188,62 @@ background-color:#151C19;\
\
.ace-mono-industrial .ace_xml_pe {\
\
}\
\
.ace-mono-industrial .ace_meta {\
\
}\
\
.ace-mono-industrial .ace_meta.ace_tag {\
\
}\
\
.ace-mono-industrial .ace_meta.ace_tag.ace_input {\
\
}\
\
.ace-mono-industrial .ace_entity.ace_other.ace_attribute-name {\
color:#909993;\
}\
\
.ace-mono-industrial .ace_markup.ace_underline {\
text-decoration:underline;\
}\
\
.ace-mono-industrial .ace_markup.ace_heading {\
\
}\
\
.ace-mono-industrial .ace_markup.ace_heading.ace_1 {\
\
}\
\
.ace-mono-industrial .ace_markup.ace_heading.ace_2 {\
\
}\
\
.ace-mono-industrial .ace_markup.ace_heading.ace_3 {\
\
}\
\
.ace-mono-industrial .ace_markup.ace_heading.ace_4 {\
\
}\
\
.ace-mono-industrial .ace_markup.ace_heading.ace_5 {\
\
}\
\
.ace-mono-industrial .ace_markup.ace_heading.ace_6 {\
\
}\
\
.ace-mono-industrial .ace_markup.ace_list {\
\
}\
\
.ace-mono-industrial .ace_collab.ace_user1 {\
\
}";
// import CSS once

View file

@ -188,6 +188,62 @@ background-color:#AE81FF;\
\
.ace-monokai .ace_xml_pe {\
\
}\
\
.ace-monokai .ace_meta {\
\
}\
\
.ace-monokai .ace_meta.ace_tag {\
\
}\
\
.ace-monokai .ace_meta.ace_tag.ace_input {\
\
}\
\
.ace-monokai .ace_entity.ace_other.ace_attribute-name {\
color:#A6E22E;\
}\
\
.ace-monokai .ace_markup.ace_underline {\
text-decoration:underline;\
}\
\
.ace-monokai .ace_markup.ace_heading {\
\
}\
\
.ace-monokai .ace_markup.ace_heading.ace_1 {\
\
}\
\
.ace-monokai .ace_markup.ace_heading.ace_2 {\
\
}\
\
.ace-monokai .ace_markup.ace_heading.ace_3 {\
\
}\
\
.ace-monokai .ace_markup.ace_heading.ace_4 {\
\
}\
\
.ace-monokai .ace_markup.ace_heading.ace_5 {\
\
}\
\
.ace-monokai .ace_markup.ace_heading.ace_6 {\
\
}\
\
.ace-monokai .ace_markup.ace_list {\
\
}\
\
.ace-monokai .ace_collab.ace_user1 {\
\
}";
// import CSS once

View file

@ -187,6 +187,10 @@ color:#D2A8A1;\
color:#bebf55;\
}\
\
.ace-pastel-on-dark .ace_markup.ace_underline {\
text-decoration:underline;\
}\
\
.ace-pastel-on-dark .ace_xml_pe {\
color:#494949;\
}";

View file

@ -189,6 +189,58 @@ color:#657B83;\
\
}\
\
.ace-solarized-dark .ace_meta {\
\
}\
\
.ace-solarized-dark .ace_meta.ace_tag {\
\
}\
\
.ace-solarized-dark .ace_meta.ace_tag.ace_input {\
\
}\
\
.ace-solarized-dark .ace_entity.ace_other.ace_attribute-name {\
color:#93A1A1;\
}\
\
.ace-solarized-dark .ace_markup.ace_underline {\
text-decoration:underline;\
}\
\
.ace-solarized-dark .ace_markup.ace_heading {\
\
}\
\
.ace-solarized-dark .ace_markup.ace_heading.ace_1 {\
\
}\
\
.ace-solarized-dark .ace_markup.ace_heading.ace_2 {\
\
}\
\
.ace-solarized-dark .ace_markup.ace_heading.ace_3 {\
\
}\
\
.ace-solarized-dark .ace_markup.ace_heading.ace_4 {\
\
}\
\
.ace-solarized-dark .ace_markup.ace_heading.ace_5 {\
\
}\
\
.ace-solarized-dark .ace_markup.ace_heading.ace_6 {\
\
}\
\
.ace-solarized-dark .ace_markup.ace_list {\
\
}\
\
.ace-solarized-dark .ace_collab.ace_user1 {\
\
}";

View file

@ -188,6 +188,58 @@ define(function(require, exports, module) {
\
}\
\
.ace-solarized-light .ace_meta {\
\
}\
\
.ace-solarized-light .ace_meta.ace_tag {\
\
}\
\
.ace-solarized-light .ace_meta.ace_tag.ace_input {\
\
}\
\
.ace-solarized-light .ace_entity.ace_other.ace_attribute-name {\
color:#93A1A1;\
}\
\
.ace-solarized-light .ace_markup.ace_underline {\
text-decoration:underline;\
}\
\
.ace-solarized-light .ace_markup.ace_heading {\
\
}\
\
.ace-solarized-light .ace_markup.ace_heading.ace_1 {\
\
}\
\
.ace-solarized-light .ace_markup.ace_heading.ace_2 {\
\
}\
\
.ace-solarized-light .ace_markup.ace_heading.ace_3 {\
\
}\
\
.ace-solarized-light .ace_markup.ace_heading.ace_4 {\
\
}\
\
.ace-solarized-light .ace_markup.ace_heading.ace_5 {\
\
}\
\
.ace-solarized-light .ace_markup.ace_heading.ace_6 {\
\
}\
\
.ace-solarized-light .ace_markup.ace_list {\
\
}\
\
.ace-solarized-light .ace_collab.ace_user1 {\
\
}";

View file

@ -156,6 +156,18 @@ define(function(require, exports, module) {
color: rgb(104, 104, 91);\
}\
\
.ace-tm .ace_markup.ace_underline {\
text-decoration:underline;\
}\
\
.ace-tm .ace_markup.ace_heading {\
color: rgb(12, 7, 255);\
}\
\
.ace-tm .ace_markup.ace_list {\
color:rgb(185, 6, 144);\
}\
\
.ace-tm .ace_marker-layer .ace_selection {\
background: rgb(181, 213, 255);\
}\
@ -182,6 +194,10 @@ define(function(require, exports, module) {
border: 1px solid rgb(200, 200, 250);\
}\
\
.ace-tm .ace_meta.ace_tag {\
color:rgb(28, 2, 255);\
}\
\
.ace-tm .ace_string.ace_regex {\
color: rgb(255, 0, 0)\
}";

View file

@ -190,6 +190,62 @@ color:#5F5A60;\
\
.ace-twilight .ace_xml_pe {\
color:#494949;\
}\
\
.ace-twilight .ace_meta {\
\
}\
\
.ace-twilight .ace_meta.ace_tag {\
color:#AC885B;\
}\
\
.ace-twilight .ace_meta.ace_tag.ace_input {\
\
}\
\
.ace-twilight .ace_entity.ace_other.ace_attribute-name {\
\
}\
\
.ace-twilight .ace_markup.ace_underline {\
text-decoration:underline;\
}\
\
.ace-twilight .ace_markup.ace_heading {\
color:#CF6A4C;\
}\
\
.ace-twilight .ace_markup.ace_heading.ace_1 {\
\
}\
\
.ace-twilight .ace_markup.ace_heading.ace_2 {\
\
}\
\
.ace-twilight .ace_markup.ace_heading.ace_3 {\
\
}\
\
.ace-twilight .ace_markup.ace_heading.ace_4 {\
\
}\
\
.ace-twilight .ace_markup.ace_heading.ace_5 {\
\
}\
\
.ace-twilight .ace_markup.ace_heading.ace_6 {\
\
}\
\
.ace-twilight .ace_markup.ace_list {\
color:#F9EE98;\
}\
\
.ace-twilight .ace_collab.ace_user1 {\
\
}";
// import CSS once

View file

@ -163,7 +163,7 @@ define(function(require, exports, module) {
}\
\
.ace-vibrant-ink .ace_string.ace_regexp {\
\
color:#44B4CC;\
}\
\
.ace-vibrant-ink .ace_comment {\
@ -188,6 +188,63 @@ define(function(require, exports, module) {
\
.ace-vibrant-ink .ace_xml_pe {\
\
}\
\
.ace-vibrant-ink .ace_meta {\
\
}\
\
.ace-vibrant-ink .ace_meta.ace_tag {\
\
}\
\
.ace-vibrant-ink .ace_meta.ace_tag.ace_input {\
\
}\
\
.ace-vibrant-ink .ace_entity.ace_other.ace_attribute-name {\
font-style:italic;\
color:#99CC99;\
}\
\
.ace-vibrant-ink .ace_markup.ace_underline {\
text-decoration:underline;\
}\
\
.ace-vibrant-ink .ace_markup.ace_heading {\
\
}\
\
.ace-vibrant-ink .ace_markup.ace_heading.ace_1 {\
\
}\
\
.ace-vibrant-ink .ace_markup.ace_heading.ace_2 {\
\
}\
\
.ace-vibrant-ink .ace_markup.ace_heading.ace_3 {\
\
}\
\
.ace-vibrant-ink .ace_markup.ace_heading.ace_4 {\
\
}\
\
.ace-vibrant-ink .ace_markup.ace_heading.ace_5 {\
\
}\
\
.ace-vibrant-ink .ace_markup.ace_heading.ace_6 {\
\
}\
\
.ace-vibrant-ink .ace_markup.ace_list {\
\
}\
\
.ace-vibrant-ink .ace_collab.ace_user1 {\
\
}";
// import CSS once

View file

@ -51,7 +51,7 @@ var CursorLayer = require("ace/layer/cursor").Cursor;
var ScrollBar = require("ace/scrollbar").ScrollBar;
var RenderLoop = require("ace/renderloop").RenderLoop;
var EventEmitter = require("pilot/event_emitter").EventEmitter;
var editorCss = require("text!ace/css/editor.css");
var editorCss = require("ace/requirejs/text!ace/css/editor.css");
// import CSS once
dom.importCssString(editorCss);
@ -338,6 +338,7 @@ var VirtualRenderer = function(container, theme) {
this.moveTextAreaToCursor = function(textarea) {
// in IE the native cursor always shines through
// this persists in IE9
if (useragent.isIE)
return;
@ -712,6 +713,14 @@ var VirtualRenderer = function(container, theme) {
deltaX && this.scrollToX(this.scroller.scrollLeft + deltaX);
};
this.isScrollableBy = function(deltaX, deltaY) {
if (deltaY < 0 && this.scrollTop > 0)
return true;
if (deltaY > 0 && this.scrollTop + this.$size.scrollerHeight < this.layerConfig.maxHeight)
return true;
// todo: handle horizontal scrolling
};
this.screenToTextCoordinates = function(pageX, pageY) {
var canvasPos = this.scroller.getBoundingClientRect();

View file

@ -103,8 +103,12 @@ var WorkerClient = function(topLevelNamespaces, packagedJs, module, classname) {
oop.implement(this, EventEmitter);
this.$normalizePath = function(path) {
if (!path.match(/^\w+:/))
path = location.protocol + "//" + location.host + location.pathname.replace(/\/.*?$/, "/") + "/" + path;
if (!path.match(/^\w+:/)) {
path = location.protocol + "//" + location.host
// paths starting with a slash are relative to the root (host)
+ (path.charAt(0) == "/" ? "" : location.pathname.replace(/\/[^\/]*$/, ""))
+ "/" + path.replace(/^[\/]+/, "");
}
return path;
};