only-draw-visible-stuff #2

Merged
andi merged 5 commits from only-draw-visible-stuff into master 2022-12-19 17:00:19 +00:00
Showing only changes of commit addca937c5 - Show all commits

View File

@@ -504,7 +504,7 @@ class InnerBigText(QWidget):
y_line_offset = self.char_height y_line_offset = self.char_height
for line in self.lines: for line in self.lines:
text = line.line_prepared_for_display() text = line.line_prepared_for_display()
leftmost_visible_char_index = line.column_to_char(self._left_offset - 1) leftmost_visible_char_index = line.column_to_char(self._left_offset)
rightmost_visible_char_index = line.column_to_char(self._left_offset + math.ceil(self.columns_shown())) rightmost_visible_char_index = line.column_to_char(self._left_offset + math.ceil(self.columns_shown()))
text = text[ text = text[
leftmost_visible_char_index:rightmost_visible_char_index] # reduce string to the visible section before drawing leftmost_visible_char_index:rightmost_visible_char_index] # reduce string to the visible section before drawing
@@ -532,7 +532,13 @@ class InnerBigText(QWidget):
y1 = y_line_offset - self.char_height + self.char_height / 7 y1 = y_line_offset - self.char_height + self.char_height / 7
height = self.char_height height = self.char_height
rect = QRect(round(x1 - left_offset), round(y1), round(width), round(height)) left = round(x1 - left_offset)
if x1 + width < left_offset \
or x1 > left_offset + self.width():
# too far left or too far right
continue
rect = QRect(left, round(y1), round(width), round(height))
self.highlight_background(painter, rect, highlight.get_brush()) self.highlight_background(painter, rect, highlight.get_brush())
def highlight_background(self, painter: QPainter, rect: QRect, brush: QBrush): def highlight_background(self, painter: QPainter, rect: QRect, brush: QBrush):