# eric7.HexEdit.HexEditSearchReplaceWidget

Module implementing a search and replace widget for the hex editor.

### Global Attributes

None

### Classes

HexEditSearchReplaceWidget | Class implementing a search and replace widget for the hex editor.

### Functions

None

## HexEditSearchReplaceWidget

Class implementing a search and replace widget for the hex editor.

### Derived from

QWidget

### Class Attributes

None

### Class Methods

None

### Methods

HexEditSearchReplaceWidget | Constructor
__bytearray2int | Private method to convert a byte array to an integer value.
__bytearray2text | Private method to convert a byte array to a text.
__convertText | Private method to convert text from one format into another.
__doReplace | Private method to replace one occurrence of data.
__findByReturnPressed | Private slot to handle a return pressed in the find combo.
__getContent | Private method to get the contents of the find/replace combo as a bytearray.
__int2bytearray | Private method to convert an integer to a byte array.
__showFind | Private method to display this widget in find mode.
__showReplace | Private slot to display this widget in replace mode.
__text2bytearray | Private method to convert a text to a byte array.
findPrevNext | Public slot to find the next occurrence of the search term.
keyPressEvent | Protected slot to handle key press events.
on_closeButton_clicked | Private slot to close the widget.
on_findFormatCombo_currentIndexChanged | Private slot to handle a selection from the find format.
on_findNextButton_clicked | Private slot to find the next occurrence.
on_findPrevButton_clicked | Private slot to find the previous occurrence.
on_findtextCombo_activated | Private slot to handle a selection from the find history.
on_findtextCombo_editTextChanged | Private slot to enable/disable the find buttons.
on_replaceAllButton_clicked | Private slot to replace all occurrences of data.
on_replaceButton_clicked | Private slot to replace one occurrence of data.
on_replaceFormatCombo_currentIndexChanged | Private slot to handle a selection from the replace format.
on_replaceSearchButton_clicked | Private slot to replace one occurrence of data and search for the next one.
on_replacetextCombo_activated | Private slot to handle a selection from the replace history.
show | Public slot to show the widget.

### Static Methods

None

#### HexEditSearchReplaceWidget (Constructor)

HexEditSearchReplaceWidget(editor, mainWindow, replace=False, parent=None)

Constructor

editor (HexEditWidget)
  reference to the hex editor widget
mainWindow (HexEditMainWindow)
  reference to the main window
replace (bool)
  flag indicating a replace widget
parent (QWidget)
  reference to the parent widget

#### HexEditSearchReplaceWidget.__bytearray2int

__bytearray2int(array)

Private method to convert a byte array to an integer value.

array (bytearray)
  byte array to be converted

Return:
  integer value of the given array

Return Type:
  int

#### HexEditSearchReplaceWidget.__bytearray2text

__bytearray2text(array, dataFormat)

Private method to convert a byte array to a text.

array (bytearray)
  byte array to be converted
dataFormat (str)
  format of the text

Return:
  formatted text

Return Type:
  str

Raises ValueError:
  raised to indicate an invalid dataFormat parameter

#### HexEditSearchReplaceWidget.__convertText

__convertText(txt, oldFormat, newFormat)

Private method to convert text from one format into another.

txt (str)
  text to be converted
oldFormat (str)
  current format of the text
newFormat (str)
  format to convert to

Return:
  converted text

Return Type:
  str

#### HexEditSearchReplaceWidget.__doReplace

__doReplace(searchNext)

Private method to replace one occurrence of data.

searchNext (bool)
  flag indicating to search for the next occurrence

#### HexEditSearchReplaceWidget.__findByReturnPressed

__findByReturnPressed()

Private slot to handle a return pressed in the find combo.

#### HexEditSearchReplaceWidget.__getContent

__getContent(replace=False)

Private method to get the contents of the find/replace combo as a bytearray.

replace (bool)
  flag indicating to retrieve the replace contents

Return:
  search or replace term as text and binary data

Return Type:
  tuple of bytearray and str

#### HexEditSearchReplaceWidget.__int2bytearray

__int2bytearray(value)

Private method to convert an integer to a byte array.

value (int)
  value to be converted

Return:
  byte array for the given value

Return Type:
  bytearray

#### HexEditSearchReplaceWidget.__showFind

__showFind(text='')

Private method to display this widget in find mode.

text (str)
  hex encoded text to be shown in the findtext edit

#### HexEditSearchReplaceWidget.__showReplace

__showReplace(text='')

Private slot to display this widget in replace mode.

text (str)
  hex encoded text to be shown in the findtext edit

#### HexEditSearchReplaceWidget.__text2bytearray

__text2bytearray(txt, dataFormat)

Private method to convert a text to a byte array.

txt (str)
  text to be converted
dataFormat (str)
  format of the text

Return:
  converted text

Return Type:
  bytearray

Raises ValueError:
  raised to indicate an invalid dataFormat parameter

#### HexEditSearchReplaceWidget.findPrevNext

findPrevNext(prev=False)

Public slot to find the next occurrence of the search term.

prev (bool)
  flag indicating a backwards search

Return:
  flag indicating a successful search

Return Type:
  bool

#### HexEditSearchReplaceWidget.keyPressEvent

keyPressEvent(event)

Protected slot to handle key press events.

event (QKeyEvent)
  reference to the key press event

#### HexEditSearchReplaceWidget.on_closeButton_clicked

on_closeButton_clicked()

Private slot to close the widget.

#### HexEditSearchReplaceWidget.on_findFormatCombo_currentIndexChanged

on_findFormatCombo_currentIndexChanged(idx)

Private slot to handle a selection from the find format.

idx (int)
  index of the selected entry

#### HexEditSearchReplaceWidget.on_findNextButton_clicked

on_findNextButton_clicked()

Private slot to find the next occurrence.

#### HexEditSearchReplaceWidget.on_findPrevButton_clicked

on_findPrevButton_clicked()

Private slot to find the previous occurrence.

#### HexEditSearchReplaceWidget.on_findtextCombo_activated

on_findtextCombo_activated(idx)

Private slot to handle a selection from the find history.

idx (int)
  index of the selected entry

#### HexEditSearchReplaceWidget.on_findtextCombo_editTextChanged

on_findtextCombo_editTextChanged(txt)

Private slot to enable/disable the find buttons.

txt (str)
  text of the find text combo

#### HexEditSearchReplaceWidget.on_replaceAllButton_clicked

on_replaceAllButton_clicked()

Private slot to replace all occurrences of data.

#### HexEditSearchReplaceWidget.on_replaceButton_clicked

on_replaceButton_clicked()

Private slot to replace one occurrence of data.

#### HexEditSearchReplaceWidget.on_replaceFormatCombo_currentIndexChanged

on_replaceFormatCombo_currentIndexChanged(idx)

Private slot to handle a selection from the replace format.

idx (int)
  index of the selected entry

#### HexEditSearchReplaceWidget.on_replaceSearchButton_clicked

on_replaceSearchButton_clicked()

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

#### HexEditSearchReplaceWidget.on_replacetextCombo_activated

on_replacetextCombo_activated(idx)

Private slot to handle a selection from the replace history.

idx (int)
  index of the selected entry

#### HexEditSearchReplaceWidget.show

show(text='')

Public slot to show the widget.

text (str)
  hex encoded text to be shown in the findtext edit

Up