# eric7.QScintilla.SearchReplaceWidget

Module implementing the search and replace widget.

### Global Attributes

None

### Classes

SearchReplaceSlidingWidget | Class implementing the search and replace widget with sliding behavior.
SearchReplaceWidget | Class implementing the search and replace widget.

### Functions

None

## SearchReplaceSlidingWidget

Class implementing the search and replace widget with sliding behavior.

### Signals

searchListChanged()
  emitted to indicate a change of the search list

### Derived from

QWidget

### Class Attributes

None

### Class Methods

None

### Methods

SearchReplaceSlidingWidget | Constructor
__enableScrollerButtons | Private method to set the enabled state of the scroll buttons.
__slide | Private method to move the sliding widget.
__slideLeft | Private slot to move the widget to the left, i.e.
__slideRight | Private slot to move the widget to the right, i.e.
changeEvent | Protected method handling state changes.
findNext | Public slot to find the next occurrence of text.
findPrev | Public slot to find the next previous of text.
replace | Public method to replace the current selection.
replaceAll | Public method to replace all occurrences.
replaceSearch | Public method to replace the current selection and search again.
resizeEvent | Protected method to handle resize events.
selectionChanged | Public slot tracking changes of selected text.
show | Public slot to show the widget.
updateSelectionCheckBox | Public slot to update the selection check box.

### Static Methods

None

#### SearchReplaceSlidingWidget (Constructor)

SearchReplaceSlidingWidget(vm, parent=None)

Constructor

vm (ViewManager)
  reference to the viewmanager object
parent (QWidget (optional))
  parent widget of this widget (defaults to None)

#### SearchReplaceSlidingWidget.__enableScrollerButtons

__enableScrollerButtons()

Private method to set the enabled state of the scroll buttons.

#### SearchReplaceSlidingWidget.__slide

__slide(toLeft)

Private method to move the sliding widget.

toLeft (bool)
  flag indicating to move to the left

#### SearchReplaceSlidingWidget.__slideLeft

__slideLeft()

Private slot to move the widget to the left, i.e. show contents to the right.

#### SearchReplaceSlidingWidget.__slideRight

__slideRight()

Private slot to move the widget to the right, i.e. show contents to the left.

#### SearchReplaceSlidingWidget.changeEvent

changeEvent(evt)

Protected method handling state changes.

evt (QEvent)
  event containing the state change

#### SearchReplaceSlidingWidget.findNext

findNext()

Public slot to find the next occurrence of text.

#### SearchReplaceSlidingWidget.findPrev

findPrev()

Public slot to find the next previous of text.

#### SearchReplaceSlidingWidget.replace

replace()

Public method to replace the current selection.

#### SearchReplaceSlidingWidget.replaceAll

replaceAll()

Public method to replace all occurrences.

#### SearchReplaceSlidingWidget.replaceSearch

replaceSearch()

Public method to replace the current selection and search again.

#### SearchReplaceSlidingWidget.resizeEvent

resizeEvent(evt)

Protected method to handle resize events.

evt (QResizeEvent)
  reference to the resize event

#### SearchReplaceSlidingWidget.selectionChanged

selectionChanged(editor)

Public slot tracking changes of selected text.

editor (Editor)
  reference to the editor

#### SearchReplaceSlidingWidget.show

show(text="", replaceMode=False)

Public slot to show the widget.

text (str (optional))
  text to be shown in the findtext edit (defaults to "")
replaceMode (bool (optional))
  flag indicating to show the widget with replace mode enabled (defaults to False)

#### SearchReplaceSlidingWidget.updateSelectionCheckBox

updateSelectionCheckBox(editor)

Public slot to update the selection check box.

editor (Editor)
  reference to the editor

Up

## SearchReplaceWidget

Class implementing the search and replace widget.

### Signals

searchListChanged()
  emitted to indicate a change of the search list

### Derived from

QWidget, Ui_SearchReplaceWidget

### Class Attributes

None

### Class Methods

None

### Methods

SearchReplaceWidget | Constructor
__doReplace | Private method to replace one occurrence of text.
__findByReturnPressed | Private slot to handle the returnPressed signal of the findtext combobox.
__findNextPrev | Private method to find the next occurrence of the search text.
__markOccurrences | Private method to mark all occurrences of the search text.
__quickSearch | Private slot to search for the entered text while typing.
__quickSearchMarkOccurrences | Private method to mark all occurrences of the search text.
__selectionBoundary | Private method to calculate the current selection boundary.
__setFindNextEnabled | Private method to set the enabled state of "Find Next".
__setFindPrevEnabled | Private method to set the enabled state of "Find Prev".
__setReplaceAllEnabled | Private method to set the enabled state of "Replace All".
__setReplaceAndSearchEnabled | Private method to set the enabled state of "Replace And Search".
__setReplaceSelectionEnabled | Private method to set the enabled state of "Replace Occurrence".
__setSearchEditColors | Private method to set the search edit colors.
__setShortcuts | Private method to set the local action's shortcuts to the same key sequences as in the view manager.
__showFind | Private method to display this widget in find mode.
__showReplace | Private slot to display this widget in replace mode.
__updateQuickSearchMarkers | Private slot to handle the selection of the various check boxes.
changeEvent | Protected method handling state changes.
findNext | Public slot to find the next occurrence of text.
findPrev | Public slot to find the next previous of text.
keyPressEvent | Protected slot to handle key press events.
on_closeButton_clicked | Private slot to close the widget.
on_extendButton_clicked | Private slot to handle the quick search extend action.
on_findNextButton_clicked | Private slot to find the next occurrence of text.
on_findPrevButton_clicked | Private slot to find the previous occurrence of text.
on_findtextCombo_editTextChanged | Private slot to enable/disable the find buttons.
on_replaceAllButton_clicked | Private slot to replace all occurrences of text.
on_replaceButton_clicked | Private slot to replace one occurrence of text.
on_replaceSearchButton_clicked | Private slot to replace one occurrence of text and search for the next one.
replace | Public method to replace the current selection.
replaceAll | Public method to replace all occurrences.
replaceSearch | Public method to replace the current selection and search again.
selectionChanged | Public slot tracking changes of selected text.
show | Public slot to show the widget.
updateSelectionCheckBox | Public slot to update the selection check box.

### Static Methods

None

#### SearchReplaceWidget (Constructor)

SearchReplaceWidget(vm, parent=None, sliding=False)

Constructor

vm (ViewManager)
  reference to the viewmanager object
parent (QWidget (optional))
  parent widget of this widget (defaults to None)
sliding (bool (optional))
  flag indicating the widget is embedded in the sliding widget (defaults to False)

#### SearchReplaceWidget.__doReplace

__doReplace(searchNext)

Private method to replace one occurrence of text.

searchNext
  flag indicating to search for the next occurrence (boolean).

#### SearchReplaceWidget.__findByReturnPressed

__findByReturnPressed()

Private slot to handle the returnPressed signal of the findtext combobox.

#### SearchReplaceWidget.__findNextPrev

__findNextPrev(txt, backwards)

Private method to find the next occurrence of the search text.

txt (str)
  text to search for
backwards (bool)
  flag indicating a backwards search

Return:
  flag indicating success

Return Type:
  bool

#### SearchReplaceWidget.__markOccurrences

__markOccurrences(txt)

Private method to mark all occurrences of the search text.

txt (str)
  text to search for

#### SearchReplaceWidget.__quickSearch

__quickSearch(txt)

Private slot to search for the entered text while typing.

txt (str)
  text of the search edit

#### SearchReplaceWidget.__quickSearchMarkOccurrences

__quickSearchMarkOccurrences(txt)

Private method to mark all occurrences of the search text.

txt (str)
  text to search for

#### SearchReplaceWidget.__selectionBoundary

__selectionBoundary(selections=None)

Private method to calculate the current selection boundary.

selections (list of tuples of four int)
  optional parameter giving the selections to calculate the boundary for (defaults to None)

Return:
  tuple of start line and index and end line and index

Return Type:
  tuple (int, int, int, int)

#### SearchReplaceWidget.__setFindNextEnabled

__setFindNextEnabled(enable)

Private method to set the enabled state of "Find Next".

enable (bool)
  flag indicating the enable state to be set

#### SearchReplaceWidget.__setFindPrevEnabled

__setFindPrevEnabled(enable)

Private method to set the enabled state of "Find Prev".

enable (bool)
  flag indicating the enable state to be set

#### SearchReplaceWidget.__setReplaceAllEnabled

__setReplaceAllEnabled(enable)

Private method to set the enabled state of "Replace All".

enable (bool)
  flag indicating the enable state to be set

#### SearchReplaceWidget.__setReplaceAndSearchEnabled

__setReplaceAndSearchEnabled(enable)

Private method to set the enabled state of "Replace And Search".

enable (bool)
  flag indicating the enable state to be set

#### SearchReplaceWidget.__setReplaceSelectionEnabled

__setReplaceSelectionEnabled(enable)

Private method to set the enabled state of "Replace Occurrence".

enable (bool)
  flag indicating the enable state to be set

#### SearchReplaceWidget.__setSearchEditColors

__setSearchEditColors(ok)

Private method to set the search edit colors.

ok (bool)
  flag indicating a match

#### SearchReplaceWidget.__setShortcuts

__setShortcuts()

Private method to set the local action's shortcuts to the same key sequences as in the view manager.

#### SearchReplaceWidget.__showFind

__showFind(text="")

Private method to display this widget in find mode.

text (str (optional))
  text to be shown in the findtext edit (defaults to "")

#### SearchReplaceWidget.__showReplace

__showReplace(text="")

Private slot to display this widget in replace mode.

text (str (optional))
  text to be shown in the findtext edit (defaults to "")

#### SearchReplaceWidget.__updateQuickSearchMarkers

__updateQuickSearchMarkers(on)

Private slot to handle the selection of the various check boxes.

on (bool)
  status of the check box (ignored)

#### SearchReplaceWidget.changeEvent

changeEvent(evt)

Protected method handling state changes.

evt (QEvent)
  event containing the state change

#### SearchReplaceWidget.findNext

findNext()

Public slot to find the next occurrence of text.

#### SearchReplaceWidget.findPrev

findPrev()

Public slot to find the next previous of text.

#### SearchReplaceWidget.keyPressEvent

keyPressEvent(event)

Protected slot to handle key press events.

event (QKeyEvent)
  reference to the key press event

#### SearchReplaceWidget.on_closeButton_clicked

on_closeButton_clicked()

Private slot to close the widget.

#### SearchReplaceWidget.on_extendButton_clicked

on_extendButton_clicked()

Private slot to handle the quick search extend action.

#### SearchReplaceWidget.on_findNextButton_clicked

on_findNextButton_clicked()

Private slot to find the next occurrence of text.

#### SearchReplaceWidget.on_findPrevButton_clicked

on_findPrevButton_clicked()

Private slot to find the previous occurrence of text.

#### SearchReplaceWidget.on_findtextCombo_editTextChanged

on_findtextCombo_editTextChanged(txt)

Private slot to enable/disable the find buttons.

txt (str)
  text of the find text combo

#### SearchReplaceWidget.on_replaceAllButton_clicked

on_replaceAllButton_clicked()

Private slot to replace all occurrences of text.

#### SearchReplaceWidget.on_replaceButton_clicked

on_replaceButton_clicked()

Private slot to replace one occurrence of text.

#### SearchReplaceWidget.on_replaceSearchButton_clicked

on_replaceSearchButton_clicked()

Private slot to replace one occurrence of text and search for the next one.

#### SearchReplaceWidget.replace

replace()

Public method to replace the current selection.

#### SearchReplaceWidget.replaceAll

replaceAll()

Public method to replace all occurrences.

#### SearchReplaceWidget.replaceSearch

replaceSearch()

Public method to replace the current selection and search again.

#### SearchReplaceWidget.selectionChanged

selectionChanged(editor)

Public slot tracking changes of selected text.

editor (Editor)
  reference to the editor

#### SearchReplaceWidget.show

show(text="", replaceMode=False)

Public slot to show the widget.

text (str (optional))
  text to be shown in the findtext edit (defaults to "")
replaceMode (bool (optional))
  flag indicating to show the widget in 'replace' mode (defaults to False)

#### SearchReplaceWidget.updateSelectionCheckBox

updateSelectionCheckBox(editor)

Public slot to update the selection check box.

editor (Editor)
  reference to the editor

Up