vhdl_navigation.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:SmartVHDL 作者: TheClams 项目源码 文件源码
def init_css():
    global tooltip_css
    color_plist = readPlistFromBytes(sublime.load_binary_resource(pref_settings.get('color_scheme')))
    color_dict = {}
    for x in color_plist['settings'] :
        if 'scope' in x:
            for s in x['scope'].split(','):
                color_dict[s.strip()] = x['settings']
    color_dict['__GLOBAL__'] = color_plist['settings'][0]['settings'] # first settings contains global settings, without scope(hopefully)
    bg = int(color_dict['__GLOBAL__']['background'][1:],16)
    fg = int(color_dict['__GLOBAL__']['foreground'][1:],16)
    # Get color for keyword, support, storage, default to foreground
    kw  = fg if 'keyword' not in color_dict else int(color_dict['keyword']['foreground'][1:],16)
    sup = fg if 'support' not in color_dict else int(color_dict['support']['foreground'][1:],16)
    sto = fg if 'storage' not in color_dict else int(color_dict['storage']['foreground'][1:],16)
    ent = fg if 'entity' not in color_dict else int(color_dict['entity']['foreground'][1:],16)
    fct = fg if 'support.function' not in color_dict else int(color_dict['support.function']['foreground'][1:],16)
    op  = fg if 'keyword.operator' not in color_dict else int(color_dict['keyword.operator']['foreground'][1:],16)
    num = fg if 'constant.numeric' not in color_dict else int(color_dict['constant.numeric']['foreground'][1:],16)
    st  = fg if 'string' not in color_dict else int(color_dict['string']['foreground'][1:],16)
    # Create background and border color based on the background color
    b = bg & 255
    g = (bg>>8) & 255
    r = (bg>>16) & 255
    if b > 128:
        bgHtml = b - 0x33
        bgBody = b - 0x20
    else:
        bgHtml = b + 0x33
        bgBody = b + 0x20
    if g > 128:
        bgHtml += (g - 0x33)<<8
        bgBody += (g - 0x20)<<8
    else:
        bgHtml += (g + 0x33)<<8
        bgBody += (g + 0x20)<<8
    if r > 128:
        bgHtml += (r - 0x33)<<16
        bgBody += (r - 0x20)<<16
    else:
        bgHtml += (r + 0x33)<<16
        bgBody += (r + 0x20)<<16
    tooltip_css = 'html {{ background-color: #{bg:06x}; color: #{fg:06x}; }}\n'.format(bg=bgHtml, fg=fg)
    tooltip_css+= 'body {{ background-color: #{bg:06x}; margin: 1px; font-size: 1em; }}\n'.format(bg=bgBody)
    tooltip_css+= 'p {padding-left: 0.6em;}\n'
    tooltip_css+= '.content {margin: 0.8em;}\n'
    tooltip_css+= '.keyword {{color: #{c:06x};}}\n'.format(c=kw)
    tooltip_css+= '.support {{color: #{c:06x};}}\n'.format(c=sup)
    tooltip_css+= '.storage {{color: #{c:06x};}}\n'.format(c=sto)
    tooltip_css+= '.function {{color: #{c:06x};}}\n'.format(c=fct)
    tooltip_css+= '.entity {{color: #{c:06x};}}\n'.format(c=ent)
    tooltip_css+= '.operator {{color: #{c:06x};}}\n'.format(c=op)
    tooltip_css+= '.numeric {{color: #{c:06x};}}\n'.format(c=num)
    tooltip_css+= '.string {{color: #{c:06x};}}\n'.format(c=st)
    tooltip_css+= '.extra-info {font-size: 0.9em; }\n'

############################################################################
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号