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.clearSelection();
}; };
this.replace = function(replacement) { this.replace = function(replacement, options) {
if (options)
this.$search.set(options);
var range = this.$tryReplace(this.getSelectionRange(), replacement); var range = this.$tryReplace(this.getSelectionRange(), replacement);
if (range !== null) if (range !== null)
this.selection.setSelectionRange(range); this.selection.setSelectionRange(range);
this.$updateDesiredColumn(); this.$updateDesiredColumn();
}, },
this.replaceAll = function(replacement) { this.replaceAll = function(replacement, options) {
if (options)
this.$search.set(options);
this.clearSelection(); this.clearSelection();
this.selection.moveCursorTo(0, 0); 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.clearSelection();
this.$search.set({needle: needle}); options = options || {};
this.findNext(); options.needle = needle;
this.$search.set(options);
console.log("options: ", JSON.stringify(this.$search.$options));
this.$find();
}, },
this.findNext = function() { this.findNext = function(options) {
this.$find(false); options = options || {};
if (typeof options.backwards == "undefined")
options.backwards = false;
this.$search.set(options);
this.$find();
}; };
this.findPrevious = function() { this.findPrevious = function(options) {
this.$find(true); options = options || {};
if (typeof options.backwards == "undefined")
options.backwards = true;
this.$search.set(options);
this.$find();
}; };
this.$find = function(backwards) { 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({needle: this.doc.getTextRange(this.getSelectionRange())});
} }
this.$search.set({ if (typeof backwards != "undefined")
backwards: backwards this.$search.set({backwards: backwards});
});
var range = this.$search.find(this.doc); var range = this.$search.find(this.doc);
if (range) { if (range) {

View file

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