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:
|
||||
|
||||
@@ -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
|
||||
@@ -33,9 +31,9 @@ class HighlightSelection(Highlight):
|
||||
start = 0
|
||||
|
||||
if line.includes_byte(end):
|
||||
length = end - line.byte_offset() - start
|
||||
length = end - line.byte_offset() - start
|
||||
else:
|
||||
length = Settings.max_line_length() -start
|
||||
length = Settings.max_line_length() - start
|
||||
|
||||
return [HighlightedRange(start, length, brush=QBrush(QColor(156, 215, 255)), pen=Qt.PenStyle.NoPen)]
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user