Merge branch 'master' of github.com:ajaxorg/editor into HEAD

This commit is contained in:
Fabian Jakobs 2010-09-22 14:15:12 +02:00
commit 649d6cf3e8
2 changed files with 32 additions and 18 deletions

View file

@ -811,14 +811,18 @@ var Editor = function(renderer, doc) {
this.clearSelection();
};
this.replace = function(replacement) {
this.replace = function(replacement, options) {
if (options)
this.$search.set(options);
var range = this.$tryReplace(this.getSelectionRange(), replacement);
if (range !== null)
this.selection.setSelectionRange(range);
this.$updateDesiredColumn();
},
this.replaceAll = function(replacement) {
this.replaceAll = function(replacement, options) {
if (options)
this.$search.set(options);
this.clearSelection();
this.selection.moveCursorTo(0, 0);
@ -845,18 +849,29 @@ var Editor = function(renderer, doc) {
}
};
this.find = function(needle) {
this.find = function(needle, options) {
this.clearSelection();
this.$search.set({needle: needle});
this.findNext();
options = options || {};
options.needle = needle;
this.$search.set(options);
console.log("options: ", JSON.stringify(this.$search.$options));
this.$find();
},
this.findNext = function() {
this.$find(false);
this.findNext = function(options) {
options = options || {};
if (typeof options.backwards == "undefined")
options.backwards = false;
this.$search.set(options);
this.$find();
};
this.findPrevious = function() {
this.$find(true);
this.findPrevious = function(options) {
options = options || {};
if (typeof options.backwards == "undefined")
options.backwards = true;
this.$search.set(options);
this.$find();
};
this.$find = function(backwards) {
@ -864,9 +879,8 @@ var Editor = function(renderer, doc) {
this.$search.set({needle: this.doc.getTextRange(this.getSelectionRange())});
}
this.$search.set({
backwards: backwards
});
if (typeof backwards != "undefined")
this.$search.set({backwards: backwards});
var range = this.$search.find(this.doc);
if (range) {

View file

@ -31,7 +31,7 @@ Search.SELECTION = 2;
if (this.$options.backwards) {
var iterator = this.$backwardMatchIterator(doc);
} else {
var iterator = this.$forwardMatchIterator(doc);
iterator = this.$forwardMatchIterator(doc);
}
var firstRange = null;
@ -50,7 +50,7 @@ Search.SELECTION = 2;
if (this.$options.backwards) {
var iterator = this.$backwardMatchIterator(doc);
} else {
var iterator = this.$forwardMatchIterator(doc);
iterator = this.$forwardMatchIterator(doc);
}
var ranges = [];
@ -149,7 +149,7 @@ Search.SELECTION = 2;
if (this.$options.regExp) {
var needle = this.$options.needle;
} else {
var needle = ace.escapeRegExp(this.$options.needle);
needle = ace.escapeRegExp(this.$options.needle);
}
if (this.$options.wholeWord) {
@ -190,7 +190,7 @@ Search.SELECTION = 2;
var row = start.row;
var line = getLine(row);
startIndex = start.column;
var startIndex = start.column;
var stop = false;
@ -215,7 +215,7 @@ Search.SELECTION = 2;
if (row == start.row)
stop = true;
var line = getLine(row);
line = getLine(row);
}
}
};
@ -247,7 +247,7 @@ Search.SELECTION = 2;
return;
row--;
var startIndex = 0;
startIndex = 0;
if (row < firstRow) {
if (wrap) {