Merge branch 'master' of github.com:ajaxorg/ace

This commit is contained in:
Fabian Jakobs 2011-02-18 15:44:56 +01:00
commit e2ee67f5fc
21 changed files with 138 additions and 51 deletions

8
.gitignore vendored
View file

@ -12,4 +12,10 @@
.*.gz
# A handy place to put stuff that git should ignore:
/ignore/
/ignore/
support/async/
support/dryice/
support/jsdom/
support/node-htmlparser/
support/node-o3-xml/
support/requirejs/

View file

@ -50,38 +50,41 @@ var deps = [
require(deps, function() {
var catalog = require("pilot/plugin_manager").catalog;
catalog.registerPlugins([ "pilot/index" ]);
var Dom = require("pilot/dom");
var Event = require("pilot/event");
var Editor = require("ace/editor").Editor;
var EditSession = require("ace/edit_session").EditSession;
var UndoManager = require("ace/undomanager").UndoManager;
var Renderer = require("ace/virtual_renderer").VirtualRenderer;
window.ace = {
edit: function(el) {
if (typeof(el) == "string") {
el = document.getElementById(el);
}
var doc = new EditSession(Dom.getInnerText(el));
doc.setUndoManager(new UndoManager());
el.innerHTML = '';
var editor = new Editor(new Renderer(el, "ace/theme/textmate"));
editor.setSession(doc);
var env = require("pilot/environment").create();
catalog.startupPlugins({ env: env }).then(function() {
env.document = doc;
env.editor = env;
env.editor = editor;
editor.resize();
Event.addListener(window, "resize", function() {
editor.resize();
});
el.env = env;
});
// Store env on editor such that it can be accessed later on from
// the returned object.
editor.env = env;
return editor;
}
};

View file

@ -1,4 +1,5 @@
/* ***** BEGIN LICENSE BLOCK *****
/* 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
@ -21,6 +22,7 @@
* Contributor(s):
* Fabian Jakobs <fabian AT ajax DOT org>
* Julian Viereck <julian.viereck@gmail.com>
* Mihai Sucan <mihai.sucan@gmail.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
@ -82,6 +84,30 @@ canon.addCommand({
env.editor.find(needle);
}
});
canon.addCommand({
name: "replace",
exec: function(env, args, request) {
var needle = prompt("Find:");
if (!needle)
return;
var replacement = prompt("Replacement:");
if (!replacement)
return;
env.editor.replace(replacement, {needle: needle});
}
});
canon.addCommand({
name: "replaceall",
exec: function(env, args, request) {
var needle = prompt("Find:");
if (!needle)
return;
var replacement = prompt("Replacement:");
if (!replacement)
return;
env.editor.replaceAll(replacement, {needle: needle});
}
});
canon.addCommand({
name: "undo",
exec: function(env, args, request) { env.editor.undo(); }

View file

@ -283,7 +283,7 @@ var EditSession = function(text, mode) {
};
this.tokenRe = /^[\w\d]+/g;
this.nonTokenRe = /^(?:[^\w\d|[\u3040-\u309F]|[\u30A0-\u30FF]|[\u4E00-\u9FFF\uF900-\uFAFF\u3400-\u4DBF])+/g;
this.nonTokenRe = /^(?:[^\w\d]|[\u3040-\u309F]|[\u30A0-\u30FF]|[\u4E00-\u9FFF\uF900-\uFAFF\u3400-\u4DBF])+/g;
this.getWordRange = function(row, column) {
var line = this.getLine(row);

View file

@ -42,8 +42,8 @@ exports.bindings = {
"removeline": "Command-D",
"gotoline": "Command-L",
"togglecomment": "Command-7",
"findnext": "Command-K",
"findprevious": "Command-Shift-K",
"findnext": "Command-G",
"findprevious": "Command-Shift-G",
"find": "Command-F",
"replace": "Command-R",
"undo": "Command-Z",

View file

@ -254,13 +254,13 @@ var Test = {
assert.equal(doc.getValue(), ["1", "2", "3"].join("\n"));
},
"test: set new line mode to 'windows' should use '\r\n' as new lines": function() {
"test: set new line mode to 'windows' should use '\\r\\n' as new lines": function() {
var doc = new Document(["1", "2", "3"].join("\n"));
doc.setNewLineMode("windows");
assert.equal(doc.getValue(), ["1", "2", "3"].join("\r\n"));
},
"test: set new line mode to 'unix' should use '\n' as new lines": function() {
"test: set new line mode to 'unix' should use '\\n' as new lines": function() {
var doc = new Document(["1", "2", "3"].join("\r\n"));
doc.setNewLineMode("unix");

View file

@ -287,6 +287,42 @@ var Test = {
selection.moveCursorTo(0, 5);
assert.notOk(called);
},
"test: moveWordLeft should move past || and [": function() {
var session = new EditSession("||foo[");
var selection = session.getSelection();
// Move behind ||
selection.moveCursorWordRight();
assert.position(selection.getCursor(), 0, 2);
// Move beind foo
selection.moveCursorWordRight();
assert.position(selection.getCursor(), 0, 5);
// Move behind [
selection.moveCursorWordRight();
assert.position(selection.getCursor(), 0, 6);
},
"test: moveWordRight should move past || and [": function() {
var session = new EditSession("||foo[");
var selection = session.getSelection();
selection.moveCursorTo(0, 6);
// Move behind [
selection.moveCursorWordLeft();
assert.position(selection.getCursor(), 0, 5);
// Move beind foo
selection.moveCursorWordLeft();
assert.position(selection.getCursor(), 0, 2);
// Move behind ||
selection.moveCursorWordLeft();
assert.position(selection.getCursor(), 0, 0);
}
};

View file

@ -192,4 +192,4 @@ define(function(require, exports, module) {
dom.importCssString(cssText);
exports.cssClass = "ace-clouds";
});
});

View file

@ -193,4 +193,4 @@ background-color:#E92E2E;\
dom.importCssString(cssText);
exports.cssClass = "ace-clouds-midnight";
});
});

View file

@ -194,4 +194,4 @@ color:#0088FF;\
dom.importCssString(cssText);
exports.cssClass = "ace-cobalt";
});
});

View file

@ -198,4 +198,4 @@ color:#5A525F;\
dom.importCssString(cssText);
exports.cssClass = "ace-dawn";
});
});

View file

@ -146,7 +146,7 @@ background-color:#FF0000;\
}\
\
.ace-idle-fingers .ace_support {\
color:#bc9458;\
\
}\
\
.ace-idle-fingers .ace_support.ace_function {\
@ -167,7 +167,7 @@ background-color:#FF0000;\
\
.ace-idle-fingers .ace_comment {\
font-style:italic;\
color:#BC9458;\
color:#BC9458;\
}\
\
.ace-idle-fingers .ace_comment.ace_doc {\
@ -179,19 +179,24 @@ background-color:#FF0000;\
}\
\
.ace-idle-fingers .ace_variable {\
color:#b7dff8;\
\
}\
\
.ace-idle-fingers .ace_variable.ace_language {\
color:#b7dff8;\
\
}\
\
.ace-idle-fingers .ace_xml_pe {\
\
}\
\
.ace-idle-fingers .ace_collab.ace_user1 {\
color:#323232;\
background-color:#FFF980; \
}";
// import CSS once
dom.importCssString(cssText);
exports.cssClass = "ace-idle-fingers";
});
});

View file

@ -194,4 +194,4 @@ color:#706D5B;\
dom.importCssString(cssText);
exports.cssClass = "ace-kr-theme";
});
});

View file

@ -194,4 +194,4 @@ background-color:#151C19;\
dom.importCssString(cssText);
exports.cssClass = "ace-mono-industrial";
});
});

View file

@ -194,4 +194,4 @@ background-color:#AE81FF;\
dom.importCssString(cssText);
exports.cssClass = "ace-monokai";
});
});

View file

@ -64,9 +64,8 @@ define(function(require, exports, module) {
}\
\
.ace-twilight .ace_print_margin {\
border-left: 1px solid #3C3C3C;\
width: 100%;\
background: #242424;\
width: 1px;\
background: #e8e8e8;\
}\
\
.ace-twilight .ace_scroller {\
@ -85,13 +84,6 @@ define(function(require, exports, module) {
.ace-twilight .ace_cursor.ace_overwrite {\
border-left: 0px;\
border-bottom: 1px solid #A7A7A7;\
}\
.ace-twilight.normal-mode .ace_cursor.ace_overwrite {\
border: 1px solid #FFE300;\
background: #766B13;\
}\
.ace-twilight.normal-mode .ace_cursor-layer {\
z-index: 0;\
}\
\
.ace-twilight .ace_marker-layer .ace_selection {\
@ -204,4 +196,4 @@ color:#5F5A60;\
dom.importCssString(cssText);
exports.cssClass = "ace-twilight";
});
});

View file

@ -634,17 +634,17 @@ var VirtualRenderer = function(container, theme) {
};
this.scrollToLine = function(line, center) {
var lineHeight = { lineHeight: this.lineHeight };
var offset = 0;
for (var l = 1; l < line; l++) {
offset += this.session.getRowHeight(lineHeight, l-1);
}
if (center) {
offset -= this.$size.scrollerHeight / 2;
}
this.scrollToY(offset);
};
var lineHeight = { lineHeight: this.lineHeight };
var offset = 0;
for (var l = 1; l < line; l++) {
offset += this.session.getRowHeight(lineHeight, l-1);
}
if (center) {
offset -= this.$size.scrollerHeight / 2;
}
this.scrollToY(offset);
};
this.scrollToY = function(scrollTop) {
var maxHeight = this.session.getScreenLength() * this.lineHeight - this.$size.scrollerHeight;
@ -777,4 +777,4 @@ var VirtualRenderer = function(container, theme) {
}).call(VirtualRenderer.prototype);
exports.VirtualRenderer = VirtualRenderer;
});
});

@ -1 +1 @@
Subproject commit cbfac498d30d43fdb7687d198c5b752736222c2f
Subproject commit 6e1fbe1dfdff64020f15cd9e23ea72b7803cf406

View file

@ -145,4 +145,8 @@
.%cssClass% .ace_xml_pe {
%xml_pe%
}
.%cssClass% .ace_collab.ace_user1 {
%collab.user1%
}

View file

@ -83,7 +83,9 @@ var supportedScopes = {
"variable": "variable",
"variable.language": "variable.language",
"meta.tag.sgml.doctype": "xml_pe"
"meta.tag.sgml.doctype": "xml_pe",
"collab.user1": "collab.user1"
};
function extractStyles(theme) {
@ -116,7 +118,7 @@ function extractStyles(theme) {
}
}
}
return colors;
};

View file

@ -373,6 +373,19 @@
<string>#FFFFFF</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>User1</string>
<key>scope</key>
<string>collab.user1</string>
<key>settings</key>
<dict>
<key>background</key>
<string>#FFF980</string>
<key>foreground</key>
<string>#323232</string>
</dict>
</dict>
</array>
<key>uuid</key>
<string>95BEF169-A2E5-4041-A84A-AAFC1DD61558</string>