(self, current_attr, fore, back, bord)
return attr, bord
Helper function for COLOR in text mode (SCREEN 0).
Helper function for COLOR in text mode (SCREEN 0).
Helper function for COLOR in text mode ( SCREEN 0 ) .
def color(self, current_attr, fore, back, bord):
        """Helper function for COLOR in text mode (SCREEN 0)."""
        if fore is not None:
            # allow twice the number of foreground attributes (16) - because of blink
            error.range_check(0, self.num_palette*2-1, fore)
            # COLOR > 17 means blink, but the blink bit is the top bit of the true attribute
            bit, fore = divmod(fore, self.num_palette)
        else:
            # use explicit fore-back-bit split here, we don't care if it's actually blink/underline
            # and split_attr/join_attr are being overridden
            fore = current_attr & 0xf
            bit = (current_attr >> 7) == 1
        if back is not None:
            # allow background attributes up to 15 though highest bit is ignored
            error.range_check(0, self.num_palette-1, back)
        else:
            back = (current_attr >> 4) & 7
        if bord is not None:
            error.range_check(0, self.num_palette-1, bord)
        # set attribute and border
        attr = ((bit & 1) << 7) + ((back & 7) << 4) + (fore & 0xf)
        return attr, bord
def color ( self , current_attr , fore , back , bord ) : if fore is not None : # allow twice the number of foreground attributes (16) - because of blink error . range_check ( 0 , self . num_palette * 2 - 1 , fore ) # COLOR > 17 means blink, but the blink bit is the top bit of the true attribute bit , fore = divmod ( fore , self . num_palette ) else : # use explicit fore-back-bit split here, we don't care if it's actually blink/underline # and split_attr/join_attr are being overridden fore = current_attr & 0xf bit = ( current_attr >> 7 ) == 1 if back is not None : # allow background attributes up to 15 though highest bit is ignored error . range_check ( 0 , self . num_palette - 1 , back ) else : back = ( current_attr >> 4 ) & 7 if bord is not None : error . range_check ( 0 , self . num_palette - 1 , bord ) # set attribute and border attr = ( ( bit & 1 ) << 7 ) + ( ( back & 7 ) << 4 ) + ( fore & 0xf ) return attr , bord