formatter.py 文件源码

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

项目:CodeReader 作者: jasonrbr 项目源码 文件源码
def _ReformatStyle(self, style):
        ## Selection (background only for now)
        ## Passing False for WPARAM to SCI_SETSELBACK is documented as resetting to scintilla default,
        ## but does not work - selection background is not visible at all.
        ## Default value in SPECIAL_STYLES taken from scintilla source.
        if style.name == STYLE_SELECTION:
            clr = style.background
            self.scintilla.SendScintilla(scintillacon.SCI_SETSELBACK, True, clr)

            ## Can't change font for selection, but could set color
            ## However, the font color dropbox has no option for default, and thus would
            ## always override syntax coloring
            ## clr = style.format[4]
            ## self.scintilla.SendScintilla(scintillacon.SCI_SETSELFORE, clr != CLR_INVALID, clr)
            return          

        assert style.stylenum is not None, "Unregistered style."
        #print "Reformat style", style.name, style.stylenum
        scintilla=self.scintilla
        stylenum = style.stylenum
        # Now we have the style number, indirect for the actual style.
        if style.aliased is not None:
            style = self.styles[style.aliased]
        f=style.format
        if style.IsBasedOnDefault():
            baseFormat = self.GetDefaultFormat()
        else: baseFormat = f
        scintilla.SCIStyleSetFore(stylenum, f[4])
        scintilla.SCIStyleSetFont(stylenum, baseFormat[7], baseFormat[5])
        if f[1] & 1: scintilla.SCIStyleSetBold(stylenum, 1)
        else: scintilla.SCIStyleSetBold(stylenum, 0)
        if f[1] & 2: scintilla.SCIStyleSetItalic(stylenum, 1)
        else: scintilla.SCIStyleSetItalic(stylenum, 0)
        scintilla.SCIStyleSetSize(stylenum, int(baseFormat[2]/20))
        scintilla.SCIStyleSetEOLFilled(stylenum, 1) # Only needed for unclosed strings.

        ## Default style background to whitespace background if set,
        ##  otherwise use system window color
        bg = style.background
        if bg == CLR_INVALID:
            bg = self.styles[STYLE_DEFAULT].background
        if bg == CLR_INVALID:
            bg = win32api.GetSysColor(win32con.COLOR_WINDOW)
        scintilla.SCIStyleSetBack(stylenum, bg)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号