separate highlight selection from other selections
will make it easier to manage other selections externally
This commit is contained in:
12
bigtext.py
12
bigtext.py
@@ -43,10 +43,7 @@ class BigText(QWidget):
|
||||
self.v_scroll_bar.setPageStep(1)
|
||||
self.v_scroll_bar.valueChanged.connect(big_text.v_scroll_event)
|
||||
|
||||
|
||||
|
||||
self.grid.addWidget(big_text,0,0)
|
||||
|
||||
self.grid.addWidget(self.h_scroll_bar, 1, 0)
|
||||
self.grid.addWidget(self.v_scroll_bar, 0, 1)
|
||||
|
||||
@@ -69,14 +66,13 @@ class InnerBigText(QWidget):
|
||||
self.font = QFont("monospace", 12)
|
||||
self.update_font_metrics(QPainter(self))
|
||||
self.lines = []
|
||||
self.selection_highlight = HighlightSelection(0, 0)
|
||||
self.selection_highlight = HighlightSelection()
|
||||
self.highlights = [
|
||||
HighlightRegex(
|
||||
r"INFO",
|
||||
brush=QBrush(QColor(220, 112, 122)),
|
||||
brush_full_line=QBrush(QColor(255, 112, 122))
|
||||
),
|
||||
self.selection_highlight,
|
||||
)
|
||||
]
|
||||
|
||||
|
||||
@@ -207,12 +203,14 @@ class InnerBigText(QWidget):
|
||||
for l in self.lines:
|
||||
self.update_longest_line(len(l.line()))
|
||||
|
||||
highlighters = self.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
|
||||
# draws over a character
|
||||
y_line_offset = self.char_height;
|
||||
for l in self.lines:
|
||||
for h in self.highlights:
|
||||
for h in highlighters:
|
||||
optional_highlight_range = h.compute_highlight(l)
|
||||
if optional_highlight_range:
|
||||
for highlight in optional_highlight_range:
|
||||
|
||||
Reference in New Issue
Block a user