mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix for #5414
This commit is contained in:
parent
c79091e71b
commit
b5f5a5f5d9
@ -53,16 +53,16 @@ class RegexBuilder(QDialog, Ui_RegexBuilder):
|
|||||||
if self.regex_valid():
|
if self.regex_valid():
|
||||||
text = qstring_to_unicode(self.preview.toPlainText())
|
text = qstring_to_unicode(self.preview.toPlainText())
|
||||||
regex = qstring_to_unicode(self.regex.text())
|
regex = qstring_to_unicode(self.regex.text())
|
||||||
|
cursor = QTextCursor(self.preview.document())
|
||||||
|
extsel = QTextEdit.ExtraSelection()
|
||||||
|
extsel.cursor = cursor
|
||||||
|
extsel.format.setBackground(QBrush(Qt.yellow))
|
||||||
try:
|
try:
|
||||||
for match in re.finditer(regex, text):
|
for match in re.finditer(regex, text):
|
||||||
cursor = QTextCursor(self.preview.document())
|
es = QTextEdit.ExtraSelection(extsel)
|
||||||
cursor.setPosition(match.start(), QTextCursor.MoveAnchor)
|
es.cursor.setPosition(match.start(), QTextCursor.MoveAnchor)
|
||||||
cursor.setPosition(match.end(), QTextCursor.KeepAnchor)
|
es.cursor.setPosition(match.end(), QTextCursor.KeepAnchor)
|
||||||
sel = QTextEdit.ExtraSelection()
|
selections.append(es)
|
||||||
sel.cursor = cursor
|
|
||||||
sel.format.setBackground(QBrush(Qt.yellow))
|
|
||||||
selections.append(sel)
|
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
self.preview.setExtraSelections(selections)
|
self.preview.setExtraSelections(selections)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user