Пример #1
0
def make_pygments_style(palette):
    """Makes a pygments style based on a color palette."""
    global Color
    style = {getattr(Color, "DEFAULT"): "noinherit"}
    for name, t in BASE_XONSH_COLORS.items():
        color = find_closest_color(t, palette)
        style[getattr(Color, name)] = "#" + color
    return style
Пример #2
0
def make_pygments_style(palette):
    """Makes a pygments style based on a color palette."""
    global Color
    style = {getattr(Color, "NO_COLOR"): "noinherit"}
    for name, t in BASE_XONSH_COLORS.items():
        color = find_closest_color(t, palette)
        style[getattr(Color, name)] = "#" + color
    return style
Пример #3
0
def make_ansi_style(palette):
    """Makes an ANSI color style from a color palette"""
    style = {"RESET": "0"}
    for name, t in BASE_XONSH_COLORS.items():
        closest = find_closest_color(t, palette)
        if len(closest) == 3:
            closest = "".join([a * 2 for a in closest])
        short = rgb2short(closest)[0]
        style[name] = "38;5;" + short
    return style
Пример #4
0
def make_ansi_style(palette):
    """Makes an ANSI color style from a color palette"""
    style = {"NO_COLOR": "0"}
    for name, t in BASE_XONSH_COLORS.items():
        closest = find_closest_color(t, palette)
        if len(closest) == 3:
            closest = "".join([a * 2 for a in closest])
        short = rgb2short(closest)[0]
        style[name] = "38;5;" + short
    return style
Пример #5
0
def make_pygments_style(palette):
    """Makes a pygments style based on a color palette."""
    global Color
    style = {getattr(Color, 'NO_COLOR'): 'noinherit'}
    for name, t in BASE_XONSH_COLORS.items():
        color = find_closest_color(t, palette)
        style[getattr(Color, name)] = '#' + color
        style[getattr(Color, 'BOLD_'+name)] = 'bold #' + color
        style[getattr(Color, 'UNDERLINE_'+name)] = 'underline #' + color
        style[getattr(Color, 'BOLD_UNDERLINE_'+name)] = 'bold underline #' + color
        style[getattr(Color, 'BACKGROUND_'+name)] = 'bg:#' + color
    return style
Пример #6
0
def make_pygments_style(palette):
    """Makes a pygments style based on a color palette."""
    global Color
    style = {getattr(Color, "NO_COLOR"): "noinherit"}
    for name, t in BASE_XONSH_COLORS.items():
        color = find_closest_color(t, palette)
        style[getattr(Color, name)] = "#" + color
        style[getattr(Color, "BOLD_" + name)] = "bold #" + color
        style[getattr(Color, "UNDERLINE_" + name)] = "underline #" + color
        style[getattr(Color, "BOLD_UNDERLINE_" + name)] = "bold underline #" + color
        style[getattr(Color, "BACKGROUND_" + name)] = "bg:#" + color
    return style
Пример #7
0
def make_pygments_style(pallette):
    """Makes a pygments style based on a color pallete."""
    global Color
    style = {getattr(Color, 'NO_COLOR'): 'noinherit'}
    for name, t in BASE_XONSH_COLORS.items():
        color = find_closest_color(t, pallette)
        style[getattr(Color, name)] = '#' + color
        style[getattr(Color, 'BOLD_'+name)] = 'bold #' + color
        style[getattr(Color, 'UNDERLINE_'+name)] = 'underline #' + color
        style[getattr(Color, 'BOLD_UNDERLINE_'+name)] = 'bold underline #' + color
        style[getattr(Color, 'BACKGROUND_'+name)] = 'bg:#' + color
    return style
Пример #8
0
def make_ansi_style(palette):
    """Makes an ANSI color style from a color palette"""
    style = {"NO_COLOR": "0"}
    for name, t in BASE_XONSH_COLORS.items():
        closest = find_closest_color(t, palette)
        if len(closest) == 3:
            closest = "".join([a * 2 for a in closest])
        short = rgb2short(closest)[0]
        style[name] = "38;5;" + short
        style["BOLD_" + name] = "1;38;5;" + short
        style["UNDERLINE_" + name] = "4;38;5;" + short
        style["BOLD_UNDERLINE_" + name] = "1;4;38;5;" + short
        style["BACKGROUND_" + name] = "48;5;" + short
    return style
Пример #9
0
def make_ansi_style(palette):
    """Makes an ANSI color style from a color palette"""
    style = {'NO_COLOR': '0'}
    for name, t in BASE_XONSH_COLORS.items():
        closest = find_closest_color(t, palette)
        if len(closest) == 3:
            closest = ''.join([a * 2 for a in closest])
        short = rgb2short(closest)[0]
        style[name] = '38;5;' + short
        style['BOLD_' + name] = '1;38;5;' + short
        style['UNDERLINE_' + name] = '4;38;5;' + short
        style['BOLD_UNDERLINE_' + name] = '1;4;38;5;' + short
        style['BACKGROUND_' + name] = '48;5;' + short
    return style
Пример #10
0
def make_ansi_style(pallette):
    """Makes an ANSI color style from a color pallette"""
    style = {'NO_COLOR': '0'}
    for name, t in BASE_XONSH_COLORS.items():
        closest = find_closest_color(t, pallette)
        if len(closest) == 3:
            closest = ''.join([a*2 for a in closest])
        short = rgb2short(closest)[0]
        style[name] = '38;5;' + short
        style['BOLD_'+name] = '1;38;5;' + short
        style['UNDERLINE_'+name] = '4;38;5;' + short
        style['BOLD_UNDERLINE_'+name] = '1;4;38;5;' + short
        style['BACKGROUND_'+name] = '48;5;' + short
    return style
Пример #11
0
def _color_name_from_ints(ints, background=False, prefix=None):
    name = find_closest_color(ints, BASE_XONSH_COLORS)
    if background:
        name = "BACKGROUND_" + name
    name = name if prefix is None else prefix + name
    return name
Пример #12
0
def _color_name_from_ints(ints, background=False, prefix=None):
    name = find_closest_color(ints, BASE_XONSH_COLORS)
    if background:
        name = "BACKGROUND_" + name
    name = name if prefix is None else prefix + name
    return name