diff --git a/src/ui/bigtext/bigtext.py b/src/ui/bigtext/bigtext.py index c4a3207..719bb64 100644 --- a/src/ui/bigtext/bigtext.py +++ b/src/ui/bigtext/bigtext.py @@ -131,7 +131,7 @@ class BigText(QWidget): # noinspection PyArgumentList,PyTypeChecker class InnerBigText(QWidget): _byte_offset = 0 - _left_offset = 0 + _left_offset = 0 # number of characters the horizontal scrollbar was moved to the right scroll_lines = 0 longest_line = 0 @@ -504,12 +504,17 @@ class InnerBigText(QWidget): y_line_offset = self.char_height for line in self.lines: text = line.line_prepared_for_display() - painter.drawText(left_offset, y_line_offset, text) + leftmost_visible_char_index = line.column_to_char(self._left_offset - 1) + rightmost_visible_char_index = line.column_to_char(self._left_offset + math.ceil(self.columns_shown())) + text = text[ + leftmost_visible_char_index:rightmost_visible_char_index] # reduce string to the visible section before drawing + painter.drawText(0, y_line_offset, text) + # painter.drawText(left_offset, y_line_offset, text) y_line_offset = y_line_offset + self.char_height painter.end() end_ns = time.process_time_ns() - #print(f"paint took {(end_ns - start_ns) / 1000000.0}") + print(f"paint took {(end_ns - start_ns) / 1000000.0}") def draw_highlights(self, highlights: [HighlightedRange], painter: QPainter, y_line_offset: int):