mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-06-23 15:30:45 -04:00
Highlighting the starting line number for changes
This commit is contained in:
parent
ce99832337
commit
77b463b79a
@ -191,11 +191,19 @@ class TextBrowser(PlainTextEdit): # {{{
|
|||||||
top = int(self.blockBoundingGeometry(block).translated(self.contentOffset()).top())
|
top = int(self.blockBoundingGeometry(block).translated(self.contentOffset()).top())
|
||||||
bottom = top + int(self.blockBoundingRect(block).height())
|
bottom = top + int(self.blockBoundingRect(block).height())
|
||||||
painter.setPen(self.line_number_palette.color(QPalette.Text))
|
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():
|
while block.isValid() and top <= ev.rect().bottom():
|
||||||
r = ev.rect()
|
r = ev.rect()
|
||||||
if block.isVisible() and bottom >= r.top():
|
if block.isVisible() and bottom >= r.top():
|
||||||
text = unicode(self.line_number_map.get(num, ''))
|
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 == '-':
|
if text == '-':
|
||||||
painter.drawLine(r.left() + 2, (top + bottom)//2, r.right() - 2, (top + bottom)//2)
|
painter.drawLine(r.left() + 2, (top + bottom)//2, r.right() - 2, (top + bottom)//2)
|
||||||
else:
|
else:
|
||||||
@ -205,6 +213,8 @@ class TextBrowser(PlainTextEdit): # {{{
|
|||||||
else:
|
else:
|
||||||
painter.drawText(r.left(), top, r.right() - 5, self.fontMetrics().height(),
|
painter.drawText(r.left(), top, r.right() - 5, self.fontMetrics().height(),
|
||||||
Qt.AlignRight, text)
|
Qt.AlignRight, text)
|
||||||
|
if is_start:
|
||||||
|
painter.restore()
|
||||||
block = block.next()
|
block = block.next()
|
||||||
top = bottom
|
top = bottom
|
||||||
bottom = top + int(self.blockBoundingRect(block).height())
|
bottom = top + int(self.blockBoundingRect(block).height())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user