Creates a Find bar for the current search session.
@param {!Editor} editor
@param {boolean} replace Whether to show the Replace UI; default false
192465
function openSearchBar(editor, replace) {
        var cm = editor._codeMirror,
            state = getSearchState(cm);

        // Use the selection start as the searchStartPos. This way if you
        // start with a pre-populated search and enter an additional character,
        // it will extend the initial selection instead of jumping to the next
        // occurrence.
        state.searchStartPos = editor.getCursorPos(false, "start");

        // Prepopulate the search field
        var initialQuery = FindBar.getInitialQuery(findBar, editor);
        if (initialQuery.query === "" && editor.lastParsedQuery !== "") {
            initialQuery.query = editor.lastParsedQuery;
        }

        // Close our previous find bar, if any. (The open() of the new findBar will
        // take care of closing any other find bar instances.)
        if (findBar) {
            findBar.close();
        }

        // Create the search bar UI (closing any previous find bar in the process)
        findBar = new FindBar({
            multifile: false,
            replace: replace,
            initialQuery: initialQuery.query,
            initialReplaceText: initialQuery.replaceText,
            queryPlaceholder: Strings.FIND_QUERY_PLACEHOLDER
        });
        findBar.open();

        findBar
            .on("queryChange.FindReplace", function (e) {
                handleQueryChange(editor, state);
            })
            .on("doFind.FindReplace", function (e, searchBackwards) {
                findNext(editor, searchBackwards);
            })
            .on("close.FindReplace", function (e) {
                editor.lastParsedQuery = state.parsedQuery;
                // Clear highlights but leave search state in place so Find Next/Previous work after closing
                clearHighlights(cm, state);

                // Dispose highlighting UI (important to restore normal selection color as soon as focus goes back to the editor)
                toggleHighlighting(editor, false);

                findBar.off(".FindReplace");
                findBar = null;
            });

        handleQueryChange(editor, state, true);
    }
50489
def show(self, hide_replace=True):
        """"""
        QWidget.show(self)
        self.visibility_changed.emit(True)
        self.change_number_matches()
        if self.editor is not None:
            if hide_replace:
                if self.replace_widgets[0].isVisible():
                    self.hide_replace()
            text = self.editor.get_selected_text()
            # When selecting several lines, and replace box is activated the
            # text won't be replaced for the selection
            if hide_replace or len(text.splitlines())<=1:
                highlighted = True
                # If no text is highlighted for search, use whatever word is
                # under the cursor
                if not text:
                    highlighted = False
                    try:
                        cursor = self.editor.textCursor()
                        cursor.select(QTextCursor.WordUnderCursor)
                        text = to_text_string(cursor.selectedText())
                    except AttributeError:
                        # We can't do this for all widgets, e.g. WebView's
                        pass
    
                # Now that text value is sorted out, use it for the search
                if text and not self.search_text.currentText() or highlighted:
                    self.search_text.setEditText(text)
                    self.search_text.lineEdit().selectAll()
                    self.refresh()
                else:
                    self.search_text.lineEdit().selectAll()
            self.search_text.setFocus()
573351
function searchFocus() {
  			if (dropDown.style.display !== "none") {
  				return;
  			}

  			dropDown.style.display = "block";
  			addEvent(document$$1, "click", hideHandler);
  			addEvent(document$$1, "keydown", hideHandler);

  			// Hide on Escape keydown or outside-container click
  			function hideHandler(e) {
  				var inContainer = moduleFilter.contains(e.target);

  				if (e.keyCode === 27 || !inContainer) {
  					if (e.keyCode === 27 && inContainer) {
  						moduleSearch.focus();
  					}
  					dropDown.style.display = "none";
  					removeEvent(document$$1, "click", hideHandler);
  					removeEvent(document$$1, "keydown", hideHandler);
  					moduleSearch.value = "";
  					searchInput();
  				}
  			}
  		}
800308
def show_replace(self):
        """"""
        self.show(hide_replace=False)
        for widget in self.replace_widgets:
            widget.show()
834639
function drawLink(editor) {
	var cm = editor.codemirror;
	var stat = getState(cm);
	var options = editor.options;
	var url = "http://";
	if(options.promptURLs) {
		url = prompt(options.promptTexts.link);
		if(!url) {
			return false;
		}
	}
	_replaceSelection(cm, stat.link, options.insertTexts.link, url);
}
412249
def replace(self, nodes):
        

        files = {}
        for node in nodes:
            if node.family == "SearchFile":
                files[node.file] = node.children
            elif node.family == "SearchOccurence":
                file = node.parent.file
                if not file in files:
                    files[file] = []
                files[file].append(node)

        replacement_pattern = self.Replace_With_comboBox.currentText()
        SearchAndReplace.insert_pattern(replacement_pattern, self.__replace_with_patterns_model)

        replace_results = {}
        for file, occurrences in files.iteritems():
            editor = self.__container.get_editor(file)
            if editor:
                document = editor.document()
            else:
                cache_data = self.__files_cache.get_content(file)
                if cache_data is None:
                    LOGGER.warning(
                        "!> {0} | '{1}' file doesn't exists in files cache!".format(self.__class__.__name__, file))
                    continue

                content = self.__files_cache.get_content(file).content
                document = self.__get_document(content)
                self.__cache(file, content, document)
            replace_results[file] = self.__replace_within_document(document, occurrences, replacement_pattern)

        self.set_replace_results(replace_results)
        self.__container.engine.notifications_manager.notify(
            "{0} | '{1}' pattern occurence(s) replaced in '{2}' files!".format(self.__class__.__name__,
                                                                               sum(replace_results.values()),
                                                                               len(replace_results.keys())))
1370517
def OnReplace(self, event):
        """"""

        find_string = event.GetFindString()
        flags = self._wxflag2flag(event.GetFlags())
        replace_string = event.GetReplaceString()

        gridpos = list(self.grid.actions.cursor)

        findpos = self.grid.actions.find(gridpos, find_string, flags,
                                         search_result=False)

        if findpos is None:
            statustext = _(u"'{find_string}' not found.")
            statustext = statustext.format(find_string=find_string)

        else:
            with undo.group(_("Replace")):
                self.grid.actions.replace(findpos, find_string, replace_string)
            self.grid.actions.cursor = findpos

            # Update statusbar
            statustext = _(u"Replaced '{find_string}' in cell {key} with "
                           u"{replace_string}.")
            statustext = statustext.format(find_string=find_string,
                                           key=findpos,
                                           replace_string=replace_string)

        post_command_event(self.grid.main_window, self.grid.StatusBarMsg,
                           text=statustext)

        event.Skip()
528323
function findNextHTMLItem(editor) {
		var isFirst = true;
		return findItem(editor, false, function(content, searchPos){
			if (isFirst) {
				isFirst = false;
				return findOpeningTagFromPosition(content, searchPos);
			} else {
				return getOpeningTagFromPosition(content, searchPos);
			}
		}, function(tag, offset, selRange) {
			return getRangeForHTMLItem(tag, offset, selRange, false);
		});
	}
895131
function replaceAll(str, find, replace) {
	let s = '',
		index,
		next;
	while (~(next = str.indexOf(find, index))) {
		s += str.substring(index, next) + replace;
		index = next + find.length;
	}
	return s + str.substring(index);
}
577732
def replace(document, search, replace):
    
    newdocument = document
    searchre = re.compile(search)
    for element in newdocument.iter():
        if element.tag == '{%s}t' % nsprefixes['w']:  # t (text) elements
            if element.text:
                if searchre.search(element.text):
                    element.text = re.sub(search, replace, element.text)
    return newdocument
525606
function replaceF ($search, $replace)
	{
		ensure('Search argument',  $search,  'is_a_string', __CLASS__, __METHOD__);
		ensure('Replace argument', $replace, 'is_a_string', __CLASS__, __METHOD__);

		$this->string = str_replace($search, $replace, $this);

		return $this;
	}
593295
def eventFilter(self, object, event):
        
        result = super(XOrbSearchCompleter, self).eventFilter(object, event)
        
        # update the search results
        if event.type() == event.KeyPress:
            # ignore return keys
            if event.key() in (Qt.Key_Return,
                               Qt.Key_Enter):
                return False
            
            # ignore navigation keys
            if event.key() in (Qt.Key_Up,
                               Qt.Key_Down,
                               Qt.Key_Left,
                               Qt.Key_Right,
                               Qt.Key_Shift,
                               Qt.Key_Control,
                               Qt.Key_Alt):
                return result
            
            text = self._pywidget.text()
            if text != self._lastSearch:
                # clear the current completion
                self.model().setStringList([])
                
                # mark for reset
                self._refreshTimer.start()
        
        return result
629562
public static ReplacedString replaceString(String s, String find, String replace) {
        if (replace == null) replace = "-";
        int index = -1;
        int l = find.length();
        boolean replaced = false;
        do {
            index = s.indexOf(find, index);
            if (index >= 0) {
                replaced = true;
                s = s.substring(0, index) + replace + s.substring(index + l);
            }
        } while (index >= 0);
        return new ReplacedString(s, replaced);
    }
1273405
function doSearch(editor, searchBackwards) {
        var state = getSearchState(editor._codeMirror);

        if (state.parsedQuery) {
            findNext(editor, searchBackwards);
        } else {
            openSearchBar(editor, false);
        }
    }
383125
function (data, title, url, replace) {
                if (replace && this._isIE7OrLess) {
                    var stateInfo = this._retrieveFromMemory();
                    stateMemory.discarded.push(stateInfo.state.id);
                }
                var id = this._generateId();
                var hash = url || "";
                hash += this.ID_KEY + id;
                title = this._setTitle(title);
                this._currentId = id;
                var stateEntry = {
                    id : id,
                    title : title,
                    state : data ? ariaUtilsJson.copy(data) : {}
                };
                this._currentPos++;
                stateMemory.states.splice(this._currentPos, stateMemory.states.length - this._currentPos, stateEntry);
                if (!replace || this._isIE7OrLess) {
                    hashManager.setHash(hash);
                } else {
                    window.location.replace(window.location.href.replace(/#.*$/, "") + "#" + hash);
                }
                this.state = this.getState();

            }
100033
function replace($search,$replace){
		$this->_String = str_replace($search,$replace,$this->_String);
	}
880410
public void registerSearchReplace(Button search, Button replace) {

        if (getState().m_enableSearchReplace) {
            throw new RuntimeException("Search/replace already registered.");
        }
        search.setId(HTML_ID_PREFIX + m_componentId + "-search");
        replace.setId(HTML_ID_PREFIX + m_componentId + "-replace");
        getState().m_enableSearchReplace = true;
        markAsDirty();
    }