From 77b463b79a2e446989c04883a0cf939969c38bd8 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 25 Jan 2014 17:00:01 +0530 Subject: [PATCH] Highlighting the starting line number for changes --- src/calibre/gui2/tweak_book/diff.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/calibre/gui2/tweak_book/diff.py b/src/calibre/gui2/tweak_book/diff.py index 2a08388a57..9186184db0 100644 --- a/src/calibre/gui2/tweak_book/diff.py +++ b/src/calibre/gui2/tweak_book/diff.py @@ -191,11 +191,19 @@ class TextBrowser(PlainTextEdit): # {{{ top = int(self.blockBoundingGeometry(block).translated(self.contentOffset()).top()) bottom = top + int(self.blockBoundingRect(block).height()) painter.setPen(self.line_number_palette.color(QPalette.Text)) + change_starts = {x[0] for x in self.changes} while block.isValid() and top <= ev.rect().bottom(): r = ev.rect() if block.isVisible() and bottom >= r.top(): text = unicode(self.line_number_map.get(num, '')) + is_start = num in change_starts + if is_start: + painter.save() + f = QFont(self.font()) + f.setBold(True) + painter.setFont(f) + painter.setPen(self.line_number_palette.color(QPalette.BrightText)) if text == '-': painter.drawLine(r.left() + 2, (top + bottom)//2, r.right() - 2, (top + bottom)//2) else: @@ -205,6 +213,8 @@ class TextBrowser(PlainTextEdit): # {{{ else: painter.drawText(r.left(), top, r.right() - 5, self.fontMetrics().height(), Qt.AlignRight, text) + if is_start: + painter.restore() block = block.next() top = bottom bottom = top + int(self.blockBoundingRect(block).height())