def drawLineNumbers(self):
    limit = min(self.rows, (len(self.host.textBuffer.lines) - self.host.scrollRow))
    cursorBookmarkColorIndex = None
    visibleBookmarks = self.getVisibleBookmarks(self.host.scrollRow, (self.host.scrollRow + limit))
    currentBookmarkIndex = 0
    colorPrefs = self.program.color
    for i in range(limit):
        color = colorPrefs.get(u'line_number')
        currentRow = (self.host.scrollRow + i)
        if (currentBookmarkIndex < len(visibleBookmarks)):
            currentBookmark = visibleBookmarks[currentBookmarkIndex]
        else:
            currentBookmark = None
        if currentBookmark:
            if ((currentRow >= currentBookmark.begin) and (currentRow <= currentBookmark.end)):
                color = colorPrefs.get(currentBookmark.data.get(u'colorIndex'))
                if (self.host.textBuffer.penRow == currentRow):
                    cursorBookmarkColorIndex = currentBookmark.data.get(u'colorIndex')
            if ((currentRow + 1) > currentBookmark.end):
                currentBookmarkIndex += 1
        self.addStr(i, 0, (u' %5d ' % (currentRow + 1)), color)
    if (self.host.scrollCol > 0):
        color = colorPrefs.get(u'line_overflow')
        for i in range(limit):
            if (len(self.host.textBuffer.lines[(self.host.scrollRow + i)]) > 0):
                self.addStr(i, 6, u' ', color)
    color = colorPrefs.get(u'outside_document')
    for i in range(limit, self.rows):
        self.addStr(i, 0, u'       ', color)
    cursorAt = (self.host.textBuffer.penRow - self.host.scrollRow)
    if (0 <= cursorAt < limit):
        if cursorBookmarkColorIndex:
            if (self.program.prefs.startup[u'numColors'] == 8):
                color = colorPrefs.get(cursorBookmarkColorIndex)
            else:
                color = colorPrefs.get(((cursorBookmarkColorIndex % 32) + 128))
        else:
            color = colorPrefs.get(u'line_number_current')
        self.addStr(cursorAt, 1, (u'%5d' % (self.host.textBuffer.penRow + 1)), color)
def drawLineNumbers(self):
    limit = min(self.rows, (len(self.host.textBuffer.lines) - self.host.scrollRow))
    cursorBookmarkColorIndex = None
    visibleBookmarks = self.getVisibleBookmarks(self.host.scrollRow, (self.host.scrollRow + limit))
    currentBookmarkIndex = 0
    colorPrefs = self.program.color
    for i in range(limit):
        color = colorPrefs.get(u'line_number')
        currentRow = (self.host.scrollRow + i)
        if (currentBookmarkIndex < len(visibleBookmarks)):
            currentBookmark = visibleBookmarks[currentBookmarkIndex]
        else:
            currentBookmark = None
        if currentBookmark:
            if ((currentRow >= currentBookmark.begin) and (currentRow <= currentBookmark.end)):
                color = colorPrefs.get(currentBookmark.data.get(u'colorIndex'))
                if (self.host.textBuffer.penRow == currentRow):
                    cursorBookmarkColorIndex = currentBookmark.data.get(u'colorIndex')
            if ((currentRow + 1) > currentBookmark.end):
                currentBookmarkIndex += 1
        self.addStr(i, 0, (u' %5d ' % (currentRow + 1)), color)
    if (self.host.scrollCol > 0):
        color = colorPrefs.get(u'line_overflow')
        for i in range(limit):
            if (len(self.host.textBuffer.lines[(self.host.scrollRow + i)]) > 0):
                self.addStr(i, 6, u' ', color)
    color = colorPrefs.get(u'outside_document')
    for i in range(limit, self.rows):
        self.addStr(i, 0, u'       ', color)
    cursorAt = (self.host.textBuffer.penRow - self.host.scrollRow)
    if (0 <= cursorAt < limit):
        if cursorBookmarkColorIndex:
            if (self.program.prefs.startup[u'numColors'] == 8):
                color = colorPrefs.get(cursorBookmarkColorIndex)
            else:
                color = colorPrefs.get(((cursorBookmarkColorIndex % 32) + 128))
        else:
            color = colorPrefs.get(u'line_number_current')
        self.addStr(cursorAt, 1, (u'%5d' % (self.host.textBuffer.penRow + 1)), color)