9 |
9 |
10 from PyQt6.QtCore import pyqtSlot, Qt, QByteArray, QRegularExpression |
10 from PyQt6.QtCore import pyqtSlot, Qt, QByteArray, QRegularExpression |
11 from PyQt6.QtGui import QRegularExpressionValidator |
11 from PyQt6.QtGui import QRegularExpressionValidator |
12 from PyQt6.QtWidgets import QWidget |
12 from PyQt6.QtWidgets import QWidget |
13 |
13 |
14 from E5Gui.E5Action import E5Action |
14 from E5Gui.EricAction import EricAction |
15 from E5Gui import E5MessageBox |
15 from E5Gui import EricMessageBox |
16 |
16 |
17 import UI.PixmapCache |
17 import UI.PixmapCache |
18 |
18 |
19 |
19 |
20 class HexEditSearchReplaceWidget(QWidget): |
20 class HexEditSearchReplaceWidget(QWidget): |
97 if replace: |
97 if replace: |
98 self.__ui.replacetextCombo.setCompleter(None) |
98 self.__ui.replacetextCombo.setCompleter(None) |
99 self.__ui.replacetextCombo.lineEdit().returnPressed.connect( |
99 self.__ui.replacetextCombo.lineEdit().returnPressed.connect( |
100 self.on_replaceButton_clicked) |
100 self.on_replaceButton_clicked) |
101 |
101 |
102 self.findNextAct = E5Action( |
102 self.findNextAct = EricAction( |
103 self.tr('Find Next'), |
103 self.tr('Find Next'), |
104 self.tr('Find Next'), |
104 self.tr('Find Next'), |
105 0, 0, self, 'hexEditor_search_widget_find_next') |
105 0, 0, self, 'hexEditor_search_widget_find_next') |
106 self.findNextAct.triggered.connect(self.on_findNextButton_clicked) |
106 self.findNextAct.triggered.connect(self.on_findNextButton_clicked) |
107 self.findNextAct.setEnabled(False) |
107 self.findNextAct.setEnabled(False) |
108 self.__ui.findtextCombo.addAction(self.findNextAct) |
108 self.__ui.findtextCombo.addAction(self.findNextAct) |
109 |
109 |
110 self.findPrevAct = E5Action( |
110 self.findPrevAct = EricAction( |
111 self.tr('Find Prev'), |
111 self.tr('Find Prev'), |
112 self.tr('Find Prev'), |
112 self.tr('Find Prev'), |
113 0, 0, self, 'hexEditor_search_widget_find_prev') |
113 0, 0, self, 'hexEditor_search_widget_find_prev') |
114 self.findPrevAct.triggered.connect(self.on_findPrevButton_clicked) |
114 self.findPrevAct.triggered.connect(self.on_findPrevButton_clicked) |
115 self.findPrevAct.setEnabled(False) |
115 self.findPrevAct.setEnabled(False) |
268 if idx >= 0: |
268 if idx >= 0: |
269 if self.__replace: |
269 if self.__replace: |
270 self.__ui.replaceButton.setEnabled(True) |
270 self.__ui.replaceButton.setEnabled(True) |
271 self.__ui.replaceSearchButton.setEnabled(True) |
271 self.__ui.replaceSearchButton.setEnabled(True) |
272 else: |
272 else: |
273 E5MessageBox.information( |
273 EricMessageBox.information( |
274 self, self.windowTitle(), |
274 self, self.windowTitle(), |
275 self.tr("'{0}' was not found.").format(txt)) |
275 self.tr("'{0}' was not found.").format(txt)) |
276 |
276 |
277 return idx >= 0 |
277 return idx >= 0 |
278 |
278 |
384 self.__editor.replaceByteArray(idx, len(fba), rba) |
384 self.__editor.replaceByteArray(idx, len(fba), rba) |
385 idx += len(rba) |
385 idx += len(rba) |
386 replacements += 1 |
386 replacements += 1 |
387 |
387 |
388 if replacements: |
388 if replacements: |
389 E5MessageBox.information( |
389 EricMessageBox.information( |
390 self, self.windowTitle(), |
390 self, self.windowTitle(), |
391 self.tr("Replaced {0} occurrences.") |
391 self.tr("Replaced {0} occurrences.") |
392 .format(replacements)) |
392 .format(replacements)) |
393 else: |
393 else: |
394 E5MessageBox.information( |
394 EricMessageBox.information( |
395 self, self.windowTitle(), |
395 self, self.windowTitle(), |
396 self.tr("Nothing replaced because '{0}' was not found.") |
396 self.tr("Nothing replaced because '{0}' was not found.") |
397 .format(ftxt)) |
397 .format(ftxt)) |
398 |
398 |
399 self.__editor.setCursorPosition(cursorPosition) |
399 self.__editor.setCursorPosition(cursorPosition) |