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

6
.gitignore vendored
View file

@ -13,3 +13,9 @@
# A handy place to put stuff that git should ignore: # 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

@ -75,13 +75,16 @@ require(deps, function() {
var env = require("pilot/environment").create(); var env = require("pilot/environment").create();
catalog.startupPlugins({ env: env }).then(function() { catalog.startupPlugins({ env: env }).then(function() {
env.document = doc; env.document = doc;
env.editor = env; env.editor = editor;
editor.resize(); editor.resize();
Event.addListener(window, "resize", function() { Event.addListener(window, "resize", function() {
editor.resize(); editor.resize();
}); });
el.env = env; el.env = env;
}); });
// Store env on editor such that it can be accessed later on from
// the returned object.
editor.env = env;
return editor; 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 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
* *
* The contents of this file are subject to the Mozilla Public License Version * The contents of this file are subject to the Mozilla Public License Version
@ -21,6 +22,7 @@
* Contributor(s): * Contributor(s):
* Fabian Jakobs <fabian AT ajax DOT org> * Fabian Jakobs <fabian AT ajax DOT org>
* Julian Viereck <julian.viereck@gmail.com> * 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 * 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 * either the GNU General Public License Version 2 or later (the "GPL"), or
@ -82,6 +84,30 @@ canon.addCommand({
env.editor.find(needle); 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({ canon.addCommand({
name: "undo", name: "undo",
exec: function(env, args, request) { env.editor.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.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) { this.getWordRange = function(row, column) {
var line = this.getLine(row); var line = this.getLine(row);

View file

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

View file

@ -254,13 +254,13 @@ var Test = {
assert.equal(doc.getValue(), ["1", "2", "3"].join("\n")); 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")); var doc = new Document(["1", "2", "3"].join("\n"));
doc.setNewLineMode("windows"); doc.setNewLineMode("windows");
assert.equal(doc.getValue(), ["1", "2", "3"].join("\r\n")); 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")); var doc = new Document(["1", "2", "3"].join("\r\n"));
doc.setNewLineMode("unix"); doc.setNewLineMode("unix");

View file

@ -287,6 +287,42 @@ var Test = {
selection.moveCursorTo(0, 5); selection.moveCursorTo(0, 5);
assert.notOk(called); 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

@ -146,7 +146,7 @@ background-color:#FF0000;\
}\ }\
\ \
.ace-idle-fingers .ace_support {\ .ace-idle-fingers .ace_support {\
color:#bc9458;\ \
}\ }\
\ \
.ace-idle-fingers .ace_support.ace_function {\ .ace-idle-fingers .ace_support.ace_function {\
@ -167,7 +167,7 @@ background-color:#FF0000;\
\ \
.ace-idle-fingers .ace_comment {\ .ace-idle-fingers .ace_comment {\
font-style:italic;\ font-style:italic;\
color:#BC9458;\ color:#BC9458;\
}\ }\
\ \
.ace-idle-fingers .ace_comment.ace_doc {\ .ace-idle-fingers .ace_comment.ace_doc {\
@ -179,15 +179,20 @@ background-color:#FF0000;\
}\ }\
\ \
.ace-idle-fingers .ace_variable {\ .ace-idle-fingers .ace_variable {\
color:#b7dff8;\ \
}\ }\
\ \
.ace-idle-fingers .ace_variable.ace_language {\ .ace-idle-fingers .ace_variable.ace_language {\
color:#b7dff8;\ \
}\ }\
\ \
.ace-idle-fingers .ace_xml_pe {\ .ace-idle-fingers .ace_xml_pe {\
\ \
}\
\
.ace-idle-fingers .ace_collab.ace_user1 {\
color:#323232;\
background-color:#FFF980; \
}"; }";
// import CSS once // import CSS once

View file

@ -64,9 +64,8 @@ define(function(require, exports, module) {
}\ }\
\ \
.ace-twilight .ace_print_margin {\ .ace-twilight .ace_print_margin {\
border-left: 1px solid #3C3C3C;\ width: 1px;\
width: 100%;\ background: #e8e8e8;\
background: #242424;\
}\ }\
\ \
.ace-twilight .ace_scroller {\ .ace-twilight .ace_scroller {\
@ -85,13 +84,6 @@ define(function(require, exports, module) {
.ace-twilight .ace_cursor.ace_overwrite {\ .ace-twilight .ace_cursor.ace_overwrite {\
border-left: 0px;\ border-left: 0px;\
border-bottom: 1px solid #A7A7A7;\ 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 {\ .ace-twilight .ace_marker-layer .ace_selection {\

View file

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

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

View file

@ -146,3 +146,7 @@
.%cssClass% .ace_xml_pe { .%cssClass% .ace_xml_pe {
%xml_pe% %xml_pe%
} }
.%cssClass% .ace_collab.ace_user1 {
%collab.user1%
}

View file

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

View file

@ -373,6 +373,19 @@
<string>#FFFFFF</string> <string>#FFFFFF</string>
</dict> </dict>
</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> </array>
<key>uuid</key> <key>uuid</key>
<string>95BEF169-A2E5-4041-A84A-AAFC1DD61558</string> <string>95BEF169-A2E5-4041-A84A-AAFC1DD61558</string>