def get_256_colors(container="gateone"): """ Returns the rendered 256-color CSS. If *container* is provided it will be used as the ``{{container}}`` variable when rendering the template ( defaults to "gateone"). """ terminal_app_path = os.path.join(GATEONE_DIR, 'applications', 'terminal') colors_json_path = os.path.join(terminal_app_path, '256colors.json') # Using get_settings() as a cool hack to get the color data as a nice dict: color_map = get_settings(colors_json_path, add_default=False) # Setup our 256-color support CSS: colors_256 = "" for i in xrange(256): i = str(i) fg = u"#%s span.✈fx%s {color: #%s;}" % ( container, i, color_map[i]) bg = u"#%s span.✈bx%s {background-color: #%s;} " % ( container, i, color_map[i]) fg_rev =( u"#%s span.✈reverse.fx%s {background-color: #%s; color: " u"inherit;}" % (container, i, color_map[i])) bg_rev =( u"#%s span.✈reverse.bx%s {color: #%s; background-color: " u"inherit;} " % (container, i, color_map[i])) colors_256 += "%s %s %s %s\n" % (fg, bg, fg_rev, bg_rev) return colors_256
def get_256_colors(container="gateone"): """ Returns the rendered 256-color CSS. If *container* is provided it will be used as the ``{{container}}`` variable when rendering the template ( defaults to "gateone"). """ colors_json_path = os.path.join( APPLICATION_PATH, 'static', '256colors.json') # Using get_settings() as a cool hack to get the color data as a nice dict: color_map = get_settings(colors_json_path, add_default=False) # Setup our 256-color support CSS: colors_256 = "" for i in xrange(256): i = str(i) fg = u"#%s span.✈fx%s {color: #%s;}" % ( container, i, color_map[i]) bg = u"#%s span.✈bx%s {background-color: #%s;} " % ( container, i, color_map[i]) fg_rev =( u"#%s span.✈reverse.fx%s {background-color: #%s; color: " u"inherit;}" % (container, i, color_map[i])) bg_rev =( u"#%s span.✈reverse.bx%s {color: #%s; background-color: " u"inherit;} " % (container, i, color_map[i])) colors_256 += "%s %s %s %s\n" % (fg, bg, fg_rev, bg_rev) return colors_256