Merge pull request #2157 from cvoege/master

Added Find All Functionality to Ctrl-F searchbox.
This commit is contained in:
Harutyun Amirjanyan 2014-09-27 13:35:16 +04:00
commit f4356993b2
2 changed files with 19 additions and 1 deletions

View file

@ -7,7 +7,7 @@
background-color: #ddd;
border: 1px solid #cbcbcb;
border-top: 0 none;
max-width: 297px;
max-width: 325px;
overflow: hidden;
margin: 0;
padding: 4px;

View file

@ -46,6 +46,7 @@ var html = '<div class="ace_search right">\
<input class="ace_search_field" placeholder="Search for" spellcheck="false"></input>\
<button type="button" action="findNext" class="ace_searchbtn next"></button>\
<button type="button" action="findPrev" class="ace_searchbtn prev"></button>\
<button type="button" action="findAll" class="ace_searchbtn" title="Alt-Enter">All</button>\
</div>\
<div class="ace_replace_form">\
<input class="ace_search_field" placeholder="Replace with" spellcheck="false"></input>\
@ -170,6 +171,11 @@ var SearchBox = function(editor, range, showReplaceForm) {
sb.replace();
sb.findPrev();
},
"Alt-Return": function(sb) {
if (sb.activeInput == sb.replaceInput)
sb.replaceAll();
sb.findAll();
},
"Tab": function(sb) {
(sb.activeInput == sb.replaceInput ? sb.searchInput : sb.replaceInput).focus();
}
@ -229,6 +235,18 @@ var SearchBox = function(editor, range, showReplaceForm) {
this.findPrev = function() {
this.find(true, true);
};
this.findAll = function(){
var range = this.editor.findAll(this.searchInput.value, {
regExp: this.regExpOption.checked,
caseSensitive: this.caseSensitiveOption.checked,
wholeWord: this.wholeWordOption.checked
});
var noMatch = !range && this.searchInput.value;
dom.setCssClass(this.searchBox, "ace_nomatch", noMatch);
this.editor._emit("findSearchBox", { match: !noMatch });
this.highlight();
this.hide();
};
this.replace = function() {
if (!this.editor.getReadOnly())
this.editor.replace(this.replaceInput.value);