separate highlight selection from other selections

will make it easier to manage other selections externally
This commit is contained in:
2021-10-25 17:26:00 +02:00
parent 76d4dccf1d
commit b8eb62a3bf
2 changed files with 9 additions and 13 deletions

View File

@@ -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:

View File

@@ -11,10 +11,8 @@ from settings import Settings
class HighlightSelection(Highlight):
def __init__(self, start_byte: int, end_byte: int):
self.start_byte = start_byte
self.end_byte = end_byte
start_byte = 0
end_byte = 0
def set_start(self, start_byte):
self.start_byte = start_byte