move highlights to model

makes it easier to manage highlights
This commit is contained in:
2021-10-28 09:52:00 +02:00
parent a0e6c24098
commit dbfe0bebf8
2 changed files with 13 additions and 10 deletions

View File

@@ -106,8 +106,6 @@ class InnerBigText(QWidget):
scroll_lines = 0
longest_line = 0
highlights: [Highlight] = []
def __init__(self, parent: BigText, model: LogFileModel):
super(InnerBigText, self).__init__()
self.model = model
@@ -118,13 +116,6 @@ class InnerBigText(QWidget):
self.update_font_metrics(QPainter(self))
self.lines = []
self.selection_highlight = HighlightSelection()
self.highlights = [
HighlightRegex(
r"ERROR",
brush=QBrush(QColor(220, 112, 122)),
brush_full_line=QBrush(QColor(255, 112, 122))
)
]
def keyPressEvent(self, e: QKeyEvent) -> None:
@@ -259,7 +250,7 @@ class InnerBigText(QWidget):
for l in self.lines:
self.update_longest_line(len(l.line()))
highlighters = self.highlights + [self.selection_highlight]
highlighters = self.model.highlights + [self.selection_highlight]
# draw hightlights first - some characters may overlap to the next line
# by drawing the background hightlights first we prevent that the hightlight