def METHOD_NAME(self, ev):
    foreground_color = QColor(self._highlighter.formats[Token.Text].foreground().color()).darker(120)
    painter = QPainter(self._line_number_area)
    painter.setFont(self.font())
    painter.setPen(foreground_color)
    block = self.firstVisibleBlock()
    block_number = block.blockNumber()
    top = round(self.blockBoundingGeometry(block).translated(self.contentOffset()).top())
    bottom = top + round(self.blockBoundingRect(block).height())
    width = self._line_number_area.width()
    while block.isValid() and top <= ev.rect().bottom():
        if self._file_selected:
            if block.isVisible() and bottom >= ev.rect().top():
                if block_number == self.textCursor().blockNumber():
                    painter.fillRect(0, top, width, bottom - top, foreground_color.darker())
                number = str(block_number + 1)
                painter.drawText(0, top, width - self._right_margin, bottom - top, Qt.AlignRight, number)
        block = block.next()
        top = bottom
        bottom = top + round(self.blockBoundingRect(block).height())
        block_number += 1
    painter.end()