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.setPageStep(1)
|
||||||
self.v_scroll_bar.valueChanged.connect(big_text.v_scroll_event)
|
self.v_scroll_bar.valueChanged.connect(big_text.v_scroll_event)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
self.grid.addWidget(big_text,0,0)
|
self.grid.addWidget(big_text,0,0)
|
||||||
|
|
||||||
self.grid.addWidget(self.h_scroll_bar, 1, 0)
|
self.grid.addWidget(self.h_scroll_bar, 1, 0)
|
||||||
self.grid.addWidget(self.v_scroll_bar, 0, 1)
|
self.grid.addWidget(self.v_scroll_bar, 0, 1)
|
||||||
|
|
||||||
@@ -69,14 +66,13 @@ class InnerBigText(QWidget):
|
|||||||
self.font = QFont("monospace", 12)
|
self.font = QFont("monospace", 12)
|
||||||
self.update_font_metrics(QPainter(self))
|
self.update_font_metrics(QPainter(self))
|
||||||
self.lines = []
|
self.lines = []
|
||||||
self.selection_highlight = HighlightSelection(0, 0)
|
self.selection_highlight = HighlightSelection()
|
||||||
self.highlights = [
|
self.highlights = [
|
||||||
HighlightRegex(
|
HighlightRegex(
|
||||||
r"INFO",
|
r"INFO",
|
||||||
brush=QBrush(QColor(220, 112, 122)),
|
brush=QBrush(QColor(220, 112, 122)),
|
||||||
brush_full_line=QBrush(QColor(255, 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:
|
for l in self.lines:
|
||||||
self.update_longest_line(len(l.line()))
|
self.update_longest_line(len(l.line()))
|
||||||
|
|
||||||
|
highlighters = self.highlights + [self.selection_highlight]
|
||||||
|
|
||||||
# draw hightlights first - some characters may overlap to the next line
|
# draw hightlights first - some characters may overlap to the next line
|
||||||
# by drawing the background hightlights first we prevent that the hightlight
|
# by drawing the background hightlights first we prevent that the hightlight
|
||||||
# draws over a character
|
# draws over a character
|
||||||
y_line_offset = self.char_height;
|
y_line_offset = self.char_height;
|
||||||
for l in self.lines:
|
for l in self.lines:
|
||||||
for h in self.highlights:
|
for h in highlighters:
|
||||||
optional_highlight_range = h.compute_highlight(l)
|
optional_highlight_range = h.compute_highlight(l)
|
||||||
if optional_highlight_range:
|
if optional_highlight_range:
|
||||||
for highlight in optional_highlight_range:
|
for highlight in optional_highlight_range:
|
||||||
|
|||||||
@@ -11,10 +11,8 @@ from settings import Settings
|
|||||||
|
|
||||||
|
|
||||||
class HighlightSelection(Highlight):
|
class HighlightSelection(Highlight):
|
||||||
|
start_byte = 0
|
||||||
def __init__(self, start_byte: int, end_byte: int):
|
end_byte = 0
|
||||||
self.start_byte = start_byte
|
|
||||||
self.end_byte = end_byte
|
|
||||||
|
|
||||||
def set_start(self, start_byte):
|
def set_start(self, start_byte):
|
||||||
self.start_byte = start_byte
|
self.start_byte = start_byte
|
||||||
|
|||||||
Reference in New Issue
Block a user