Exemplo n.º 1
0
    def updateDecoratedMatch(self):
        '''Update the cached decorated match formatted string'''
        if self.hovered and self.selected:
            attributes = (curses.COLOR_WHITE, curses.COLOR_RED, 0)
        elif self.hovered:
            attributes = (curses.COLOR_WHITE, curses.COLOR_BLUE, 0)
        elif self.selected:
            attributes = (curses.COLOR_WHITE, curses.COLOR_GREEN, 0)
        else:
            attributes = (0, 0, FormattedText.UNDERLINE_ATTRIBUTE)

        decoratorText = self.getDecorator()
        self.decoratedMatch = FormattedText(
            FormattedText.getSequenceForAttributes(*attributes) +
            decoratorText + self.getMatch())

        # because decorators add length to the line, when the decorator
        # is removed, we need to print blank space (aka "erase") the
        # part of the line that is stale. calculate how much this is based
        # on the max length decorator.
        self.endingClearText = FormattedText(
            FormattedText.getSequenceForAttributes(
                FormattedText.DEFAULT_COLOR_FOREGROUND,
                FormattedText.DEFAULT_COLOR_BACKGROUND,
                0) +
            " " * (self.getMaxDecoratorLength() - len(decoratorText)))
Exemplo n.º 2
0
    def updateDecoratedMatch(self, maxLen=None):
        '''Update the cached decorated match formatted string, and
        dirty the line, if needed'''
        if self.hovered and self.selected:
            attributes = (curses.COLOR_WHITE, curses.COLOR_RED, 0)
        elif self.hovered:
            attributes = (curses.COLOR_WHITE, curses.COLOR_BLUE, 0)
        elif self.selected:
            attributes = (curses.COLOR_WHITE, curses.COLOR_GREEN, 0)
        elif not self.allInput:
            attributes = (0, 0, FormattedText.UNDERLINE_ATTRIBUTE)
        else:
            attributes = (0, 0, 0)

        decoratorText = self.getDecorator()

        # we may not be connected to a controller (during processInput,
        # for example)
        if self.controller:
            self.controller.dirtyLine(self.index)

        plainText = decoratorText + self.getMatch()
        if maxLen and len(plainText) > maxLen:
            # alright, we need to chop the ends off of our
            # decorated match and glue them together with our
            # truncation decorator
            spaceAllowed = maxLen - len(self.TRUNCATE_DECORATOR)
            midPoint = int(spaceAllowed / 2)
            beginMatch = plainText[0:midPoint]
            endMatch = plainText[-midPoint:len(plainText)]
            plainText = beginMatch + self.TRUNCATE_DECORATOR + endMatch

        self.decoratedMatch = FormattedText(
            FormattedText.getSequenceForAttributes(*attributes) + plainText)
Exemplo n.º 3
0
    def updateDecoratedMatch(self, maxLen=None):
        '''Update the cached decorated match formatted string, and
        dirty the line, if needed'''
        if self.hovered and self.selected:
            attributes = (curses.COLOR_WHITE, curses.COLOR_RED, 0)
        elif self.hovered:
            attributes = (curses.COLOR_WHITE, curses.COLOR_BLUE, 0)
        elif self.selected:
            attributes = (curses.COLOR_WHITE, curses.COLOR_GREEN, 0)
        elif not self.allInput:
            attributes = (0, 0, FormattedText.UNDERLINE_ATTRIBUTE)
        else:
            attributes = (0, 0, 0)

        decoratorText = self.getDecorator()

        # we may not be connected to a controller (during processInput,
        # for example)
        if self.controller:
            self.controller.dirtyLine(self.index)

        plainText = decoratorText + self.getMatch()
        if maxLen and len(plainText) > maxLen:
            # alright, we need to chop the ends off of our
            # decorated match and glue them together with our
            # truncation decorator
            spaceAllowed = maxLen - len(self.TRUNCATE_DECORATOR)
            midPoint = int(spaceAllowed / 2)
            beginMatch = plainText[0:midPoint]
            endMatch = plainText[-midPoint:len(plainText)]
            plainText = beginMatch + self.TRUNCATE_DECORATOR + endMatch

        self.decoratedMatch = FormattedText(
            FormattedText.getSequenceForAttributes(*attributes) +
            plainText)
Exemplo n.º 4
0
    def updateDecoratedMatch(self):
        '''Update the cached decorated match formatted string'''
        if self.hovered and self.selected:
            attributes = (curses.COLOR_WHITE, curses.COLOR_RED, 0)
        elif self.hovered:
            attributes = (curses.COLOR_WHITE, curses.COLOR_BLUE, 0)
        elif self.selected:
            attributes = (curses.COLOR_WHITE, curses.COLOR_GREEN, 0)
        else:
            attributes = (0, 0, FormattedText.UNDERLINE_ATTRIBUTE)

        self.decoratedMatch = FormattedText(
            FormattedText.getSequenceForAttributes(*attributes) +
            self.getDecorator() + self.getMatch())
Exemplo n.º 5
0
    def updateDecoratedMatch(self):
        '''Update the cached decorated match formatted string, and
        dirty the line, if needed'''
        if self.hovered and self.selected:
            attributes = (curses.COLOR_WHITE, curses.COLOR_RED, 0)
        elif self.hovered:
            attributes = (curses.COLOR_WHITE, curses.COLOR_BLUE, 0)
        elif self.selected:
            attributes = (curses.COLOR_WHITE, curses.COLOR_GREEN, 0)
        else:
            attributes = (0, 0, FormattedText.UNDERLINE_ATTRIBUTE)

        decoratorText = self.getDecorator()

        # we may not be connected to a controller (during processInput,
        # for example)
        if self.controller:
            self.controller.dirtyLine(self.index)

        self.decoratedMatch = FormattedText(
            FormattedText.getSequenceForAttributes(*attributes) +
            decoratorText + self.getMatch())