Fix message log match highlighting

This commit is contained in:
Salad Dais
2021-05-08 01:23:00 +00:00
parent 00e9ecb765
commit c8f7231eae
2 changed files with 13 additions and 10 deletions

View File

@@ -271,21 +271,23 @@ class ProxyGUI(QtWidgets.QMainWindow):
# Match result was a tuple indicating what matched
if isinstance(match_result, tuple):
highlight_range = req.spans.get(match_result)
resp = entry.response(beautify=self.checkBeautify.isChecked())
self.textRequest.setPlainText(req)
if highlight_range:
cursor = self.textRequest.textCursor()
cursor.setPosition(highlight_range[0], QtGui.QTextCursor.MoveAnchor)
cursor.setPosition(highlight_range[1], QtGui.QTextCursor.KeepAnchor)
highlight_format = QtGui.QTextBlockFormat()
highlight_format.setBackground(QtCore.Qt.yellow)
cursor.setBlockFormat(highlight_format)
resp = entry.response(beautify=self.checkBeautify.isChecked())
if resp:
self.textResponse.show()
self.textResponse.setPlainText(resp)
else:
self.textResponse.hide()
if highlight_range:
cursor = self.textRequest.textCursor()
cursor.setPosition(highlight_range[0], QtGui.QTextCursor.KeepAnchor)
highlight_format = QtGui.QTextBlockFormat()
highlight_format.setBackground(QtCore.Qt.yellow)
cursor.setBlockFormat(highlight_format)
def beforeInsert(self):
vbar = self.tableView.verticalScrollBar()
self._shouldScrollOnInsert = vbar.value() == vbar.maximum()

View File

@@ -119,6 +119,7 @@ class ProxiedMessage(Message):
end_len = len(string)
# Store the spans for each var so we can highlight specific matches
spans[(self.name, block_name, block_num, var_name)] = (start_len, end_len)
string += "\n"
spanned = SpannedString(string)
spanned.spans = spans
return spanned
@@ -145,7 +146,7 @@ class ProxiedMessage(Message):
if serializer.AS_HEX and isinstance(var_val, int):
var_data = hex(var_val)
if serializer.ORIG_INLINE:
string += f" #{var_data}\n"
string += f" #{var_data}"
return string
else:
string += "\n"
@@ -162,7 +163,7 @@ class ProxiedMessage(Message):
if "CircuitCode" in var_name or ("Code" in var_name and "Circuit" in block.name):
if var_val == replacements.get("CIRCUIT_CODE"):
var_data = "[[CIRCUIT_CODE]]"
string += f" {field_prefix}{var_name} = {var_data}\n"
string += f" {field_prefix}{var_name} = {var_data}"
return string
@staticmethod